/**
 * Minified by jsDelivr using Terser v5.39.0.
 * Original file: /npm/youverify-web-sdk@2.2.1/dist/index.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
"use strict";const _excluded=["type"];function ownKeys(e,t){var o,i=Object.keys(e);return Object.getOwnPropertySymbols&&(o=Object.getOwnPropertySymbols(e),t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,o)),i}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(o),!0).forEach((function(t){_defineProperty(e,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):ownKeys(Object(o)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t))}))}return e}function _defineProperty(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}function _objectWithoutProperties(e,t){if(null==e)return{};var o,i=_objectWithoutPropertiesLoose(e,t);if(Object.getOwnPropertySymbols)for(var s=Object.getOwnPropertySymbols(e),n=0;n<s.length;n++)o=s[n],0<=t.indexOf(o)||Object.prototype.propertyIsEnumerable.call(e,o)&&(i[o]=e[o]);return i}function _objectWithoutPropertiesLoose(e,t){if(null==e)return{};for(var o,i={},s=Object.keys(e),n=0;n<s.length;n++)o=s[n],0<=t.indexOf(o)||(i[o]=e[o]);return i}(()=>{var e=class{constructor(e={}){var{publicMerchantKey:e,personalInformation:t={firstName:void 0,lastName:void 0,middleName:void 0,email:void 0,mobile:void 0,gender:void 0},appearance:o={greeting:void 0,actionText:void 0,buttonBackgroundColor:void 0,buttonTextColor:void 0,primaryColor:void 0},dev:i,countries:s,province:n,idTypes:a,sandboxEnvironment:r}=e;this.genderTypes=["MALE","FEMALE","NOT_IDENTIFIED"],this.allowedPersonalInformationFields=["firstName","lastName","middleName","email","mobile","gender"],this.businessId=e,this.dev=i,this.personalInformation=t,this.countries=s,this.province=n,this.idTypes=a,this.appearance=o,this.baseURL="https://os.youverify.co",this.sandboxEnvironment=r,!0===this.dev&&(this.baseURL="https://os.dev.youverify.co"),this.modalContent=this.createElement({tag:"div",attributes:{style:{position:"relative",height:"100%",width:"100%"},id:"modal-content"},children:[this.createElement({tag:"button",text:"X",attributes:{class:"close-button",style:{position:"absolute",top:"10px",left:"10px",zIndex:2}}}),this.createElement({tag:"div",attributes:{style:{height:"100%",width:"100%",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1,backgroundColor:"white"},class:"preliminary-content animate"},children:[this.createElement({tag:"div",attributes:{class:"loader"}}),this.createElement({tag:"div",attributes:{style:{maxWidth:"400px",margin:"0 auto"},class:"personalization hide"},children:[this.createElement({tag:"h1",attributes:{style:{fontWeight:"bold",margin:"5px 0"}},text:t.firstName?"Hey, "+t.firstName:"Hey,"}),this.createElement({tag:"p",attributes:{style:{margin:"10px 0",lineHeight:"1.4"}},html:this.appearance.greeting}),this.createElement({tag:"button",text:this.appearance.actionText,attributes:{style:{background:this.appearance.buttonBackgroundColor||"#46B2C8",color:this.appearance.buttonTextColor||"white"},class:"start-button"}})]})]})]}),this.modal=this.createElement({tag:"div",attributes:{id:"yv-sdk-modal",style:{position:"fixed",top:0,right:0,bottom:0,left:0,backgroundColor:"white",zIndex:2,maxWidth:"100vw",minHeight:"100vh",overflow:"hidden"},class:"hide animate"},children:[this.modalContent]}),this.preliminaryContent=this.modal.querySelector(".preliminary-content"),this.loader=this.preliminaryContent.querySelector(".loader"),this.personalization=this.preliminaryContent.querySelector(".personalization"),this.closeButton=this.modal.querySelector(".close-button"),this.startButton=this.modal.querySelector(".start-button"),this.overlay=this.createElement({tag:"div",attributes:{class:"overlay hide animate",style:{position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:2,backgroundColor:"rgba(0, 0, 0, 0.5)"}}})}createElement(e={}){const{tag:t="div",attributes:o={},children:i=[],text:s=null,html:n=null}=e,a=document.createElement(t);for(const e of Object.keys(o)){const t=o[e];"object"!=typeof t||Array.isArray(t)||null===t?a.setAttribute(e,t):Object.assign(a[e],t)}for(const e of i)a.appendChild(e);return s&&(a.innerText=s),n&&(a.innerHTML=n),a}loadStyles(){var e=this.createElement({tag:"style",attributes:{type:"text/css"},children:[document.createTextNode(`\n          #yv-sdk-modal {\n            font-family: BRSonoma, sans-serif;\n            -webkit-font-smoothing: antialiased;\n            -moz-osx-font-smoothing: grayscale;\n            color: #666666;\n            max-height: 100%;\n            position: fixed;\n            z-index: 1000; /* modal above overlay */\n          }\n          @media only screen and (min-width: 600px) {\n            #yv-sdk-modal {\n              max-height: 80%;\n            }\n          }\n\n          #yv-sdk-modal .overlay {\n            position: fixed;\n            top: 0;\n            left: 0;\n            right: 0;\n            bottom: 0;\n            background-color: rgba(0, 0, 0, 0.5);\n            z-index: 900; /* always behind modal */\n          }\n\n          #yv-sdk-modal .modal-content {\n            position: relative;\n            height: 100%;\n            width: 100%;\n            z-index: 1100; /* modal content above overlay */\n          }\n\n          #yv-sdk-modal iframe {\n            position: relative;\n            z-index: 1101; /* iframe is always the top clickable element */\n            height: 100%;\n            width: 100%;\n            border: none;\n          }\n\n          #yv-sdk-modal .loader {\n            border: 2px solid;\n            border-color: ${this.appearance.primaryColor};\n            border-left-color: transparent;\n            border-radius: 50%;\n            animation: spin 0.7s linear infinite;\n            height: 20px;\n            width: 20px;\n          }\n\n          #yv-sdk-modal .close-button {\n            height: 30px;\n            width: 30px;\n            display: flex;\n            align-items: center;\n            justify-content: center;\n            border-radius: 100%;\n            background-color: rgba(0, 0, 0, 0.5);\n            color: white;\n            z-index: 1200; /* always above iframe */\n          }\n\n          #yv-sdk-modal .close-button:hover {\n            background-color: rgba(0, 0, 0, 1);\n          }\n\n          #yv-sdk-modal button {\n            outline: none;\n            border: none;\n            cursor: pointer;\n          }\n\n          #yv-sdk-modal .start-button {\n            padding: 15px 30px;\n            margin-top: 20px;\n            font-size: 16px;\n            font-weight: 500;\n          }\n\n          @keyframes spin {\n            0% { transform: rotate(0deg); }\n            100% { transform: rotate(360deg); }\n          }\n          #yv-sdk-modal.animate, #yv-sdk-modal .animate {\n            transition: all 0.5s ease-in-out;\n          }\n          #yv-sdk-modal.hide, #yv-sdk-modal .hide {\n            visibility: hidden;\n            position: absolute;\n            display: none;\n            top: 0;\n            opacity: 0;\n          }\n\n          #yv-sdk-modal #list {\n            transition: all 0.5s;\n            transform: translateY(30px);\n          }\n\n          `)]});document.head.prepend(e)}startProcess(){}validateOptions(){}initialize(){this.loadStyles(),this.validateOptions(),this.closeButton.addEventListener("click",(()=>{this.setShowModal(!1)})),this.startButton.addEventListener("click",(()=>{this.startProcess()}))}resetModal(){this.modal.classList.add("hide"),this.preliminaryContent.classList.remove("hide"),this.iFrame.classList.add("hide"),this.personalization.classList.add("hide"),this.loader.classList.remove("hide"),document.body.removeChild(this.modal),this.overlay.classList.add("hide"),document.body.removeChild(this.overlay),window.removeEventListener("message",this.iFrameMessageHandler)}setShowModal(e=!1){e?(document.body.appendChild(this.overlay),document.body.appendChild(this.modal),setTimeout((()=>{this.modal.classList.remove("hide"),this.overlay.classList.remove("hide")}))):(this.resetModal(),this.onClose())}};e={vForm:class extends e{constructor(e={}){var{publicMerchantKey:e,vFormId:t,metadata:o={},dev:i,sandboxEnvironment:s,personalInformation:n={firstName:void 0,lastName:void 0,middleName:void 0,email:void 0,mobile:void 0,gender:void 0},appearance:a={actionText:void 0},onSuccess:r=()=>{},onComplete:l=()=>{},onFailure:d=()=>{},onClose:c=()=>{}}=e;super({publicMerchantKey:e,personalInformation:n,dev:i,sandboxEnvironment:s,appearance:{actionText:a.actionText||"Verify Identity",greeting:a.greeting||"We will need to verify your identity. It will only take a moment.",buttonBackgroundColor:a.buttonBackgroundColor||"#46B2C8",primaryColor:a.primaryColor||"#46B2C8",buttonTextColor:a.buttonTextColor||"white"}}),this.apiBaseURL="https://vform.svc.youverify.co",this.sandboxEnvironment&&!this.dev&&(this.apiBaseURL="https://vform.staging.svc.youverify.co"),this.dev&&!this.sandboxEnvironment&&(this.apiBaseURL="https://vform.dev.svc.youverify.co"),this.vFormId=t,this.metadata=o,this.onSuccess=r,this.onFailure=d,this.onComplete=l,this.onClose=c,this.iFrameMessageHandler=e=>{this.handleIFrameMessage(e)}}validateOptions(){if(!this.vFormId)throw new Error("vForm Id is required");if(!this.businessId)throw new Error("Public Merchant Key is required");if(this.personalInformation&&this.personalInformation.gender&&!this.genderTypes.includes(this.personalInformation.gender))throw new Error(`Gender must be one of "${this.genderTypes.join(", ")}"`);if(this.onSuccess&&"function"!=typeof this.onSuccess)throw new Error("onSuccess callback must be of type function");if(this.onFailure&&"function"!=typeof this.onFailure)throw new Error("onFailure callback must be of type function");if(this.onComplete&&"function"!=typeof this.onComplete)throw new Error("onComplete callback must be of type function");if(this.onClose&&"function"!=typeof this.onClose)throw new Error("onClose callback must be of type function");if(this.personalInformation&&("object"!=typeof this.personalInformation||Array.isArray(this.personalInformation)))throw new Error("Personal Information should be of type object");if(this.personalInformation)for(const e of Object.keys(this.personalInformation))if(!this.allowedPersonalInformationFields.includes(e))throw new Error(e+" is not allowed in Personal Information. Must be one of "+this.allowedPersonalInformationFields.join(", "))}handleIFrameMessage(e){var{data:t={},origin:e}=e;if(e===this.baseURL)switch(t.id){case"yvos:vform:submit-success":this.onSuccess(t.data);break;case"yvos:vform:submit-failed":this.onFailure(t.data);break;case"yvos:vform:submit-completed":this.onComplete(t.data)}}initIFrame(){return new Promise((async(e,t)=>{try{const t=await fetch(this.apiBaseURL+"/v1/v-forms/access-points/",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:"sdk",templateId:this.vFormId,details:this.personalInformation,businessId:this.businessId,metadata:this.metadata})});if(!t.ok)throw this.error=await t.json(),t;var o=(await t.json()).data;this.accessPoint=o,this.iFrame=this.createElement({tag:"iframe",attributes:{src:this.sandboxEnvironment?`${this.baseURL}/v-forms/${this.vFormId}?accessId=${this.accessPoint.id}&e=s`:`${this.baseURL}/v-forms/${this.vFormId}?accessId=`+this.accessPoint.id,style:{height:"100%",width:"100%"},class:"hide animate",allow:"camera; microphone; clipboard-read; clipboard-write"}}),this.iFrame.addEventListener("load",(()=>{this.loader.classList.add("hide"),this.personalization.classList.remove("hide")})),this.modalContent.appendChild(this.iFrame),e({done:!0})}catch(e){this.alert=this.createElement({tag:"div",html:this.error.message,attributes:{class:"alert",id:"list",style:{position:"absolute",top:"10px",right:"10px",zIndex:2,background:"red",minWidth:"20rem",maxWidth:"40rem",padding:"20px",color:"white",fontSize:"1rem",lineHeight:"1.5rem",borderRadius:"0.25rem",boxShadow:"0px 15px 25px rgba(0, 0, 0, 0.15)"}}}),this.modalContent.appendChild(this.alert),this.loader.classList.add("hide"),t(e)}}))}async start(){try{this.setShowModal(!0),window.addEventListener("message",this.iFrameMessageHandler),this.iFrame||await this.initIFrame()}catch(e){throw e}}startProcess(){this.preliminaryContent.classList.add("hide"),this.iFrame.classList.remove("hide")}},liveness:class extends e{constructor(e={}){var{publicMerchantKey:e,dev:t,sandboxEnvironment:o,personalInformation:i={firstName:void 0},appearance:s={actionText:void 0},onSuccess:n=()=>{},onFailure:a=()=>{},onClose:r=()=>{},onCancel:l=()=>{},onRetry:d=()=>{},metadata:c}=e;super({publicMerchantKey:e,personalInformation:i,appearance:{actionText:s.actionText||"Start Liveness Test",greeting:s.greeting||"We will need to carry out a liveness test. It will only take a moment.",buttonBackgroundColor:s.buttonBackgroundColor||"#46B2C8",primaryColor:s.primaryColor||"#46B2C8",buttonTextColor:s.buttonTextColor||"white"},metadata:c,dev:t,sandboxEnvironment:o}),this.allowedPersonalInformationFields=["firstName"],this.personalInformation=i,this.appearance=s,this.apiBaseURL="https://identity.svc.youverify.co",this.sandboxEnvironment&&!this.dev&&(this.apiBaseURL="https://identity.staging.svc.youverify.co"),this.dev&&!this.sandboxEnvironment&&(this.apiBaseURL="https://identity.dev.svc.youverify.co"),this.publicMerchantKey=e,this.onSuccess=n,this.onFailure=a,this.onClose=r,this.onCancel=l,this.onRetry=d,this.metadata=c,this.iFrameMessageHandler=e=>{this.handleIFrameMessage(e)}}validateOptions(){if(!this.businessId)throw new Error("Public Merchant Key is required");if(this.onSuccess&&"function"!=typeof this.onSuccess)throw new Error("onSuccess callback must be of type function");if(this.onFailure&&"function"!=typeof this.onFailure)throw new Error("onFailure callback must be of type function");if(this.onRetry&&"function"!=typeof this.onRetry)throw new Error("onRetry callback must be of type function");if(this.onClose&&"function"!=typeof this.onClose)throw new Error("onClose callback must be of type function");if(this.personalInformation&&("object"!=typeof this.personalInformation||Array.isArray(this.personalInformation)))throw new Error("Personal Information should be of type object");if(this.personalInformation)for(const e of Object.keys(this.personalInformation))if(!this.allowedPersonalInformationFields.includes(e))throw new Error(e+" is not allowed in Personal Information. Must be one of "+this.allowedPersonalInformationFields.join(", "))}async postLivenessData(e={}){await fetch(this.apiBaseURL+"/v1/sdk/identity/liveness/",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({publicMerchantID:this.publicMerchantKey,components:["liveness"],faceImage:e.photo||"",passed:e.passed,metadata:this.metadata})})}handleIFrameMessage(e){var{data:t={},origin:e}=e;if(e===this.baseURL)switch(t.id){case"yvos:liveness:success":this.postLivenessData(t.data),this.onSuccess(t.data);break;case"yvos:liveness:failed":this.postLivenessData(t.data),this.onFailure(t.data);break;case"yvos:liveness:cancelled":this.onCancel(t.data);break;case"yvos:liveness:closed":this.setShowModal(!1);break;case"yvos:liveness:retry":this.onRetry(t.data)}}initIFrame(){return new Promise((async(e,t)=>{try{this.iFrame=this.createElement({tag:"iframe",attributes:{src:`${this.baseURL}/services/${this.businessId}/liveness`,style:{height:"100%",width:"100%"},class:"hide animate",allow:"camera; microphone; clipboard-read; clipboard-write"}}),this.iFrame.addEventListener("load",(()=>{this.loader.classList.add("hide"),this.personalization.classList.remove("hide")})),this.modalContent.appendChild(this.iFrame),e({done:!0})}catch(e){t(e)}}))}async start(){try{this.setShowModal(!0),window.addEventListener("message",this.iFrameMessageHandler),this.iFrame||await this.initIFrame()}catch(e){throw e}}startProcess(){this.preliminaryContent.classList.add("hide"),this.iFrame.classList.remove("hide")}},documentCapture:class extends e{constructor(e={}){var{publicMerchantKey:e,personalInformation:t={firstName:void 0},appearance:o={actionText:void 0},type:i,dev:s,countries:n,province:a,idTypes:r,sandboxEnvironment:l,onSuccess:d=()=>{},onFailure:c=()=>{},onClose:h=()=>{},onCancel:m=()=>{},metadata:p,hideUsingSecondaryDevice:u}=e;super({publicMerchantKey:e,personalInformation:t,metadata:p,dev:s,countries:n,province:a,idTypes:r,sandboxEnvironment:l,appearance:{actionText:o.actionText||"Start Document Capture",greeting:o.greeting||"We will need to carry out a  document capture. It will only take a moment.",buttonBackgroundColor:o.buttonBackgroundColor||"#46B2C8",primaryColor:o.primaryColor||"#46B2C8",buttonTextColor:o.buttonTextColor||"white"}}),this.publicMerchantKey=e,this.allowedDocumentTypes=Object.keys({nin:"National ID",passport:"Passport","drivers-license":"Driver License",voters_card:"Voters Card",pr_card:"Permit Card"}),this.allowedPersonalInformationFields=["firstName"],this.personalInformation=t,this.type=i,this.countries=n,this.province=a,this.idTypes=r,this.appearance=o,this.apiBaseURL="https://identity.svc.youverify.co",this.hideUsingSecondaryDevice=u,this.sandboxEnvironment&&!this.dev&&(this.apiBaseURL="https://identity.staging.svc.youverify.co"),this.dev&&!this.sandboxEnvironment&&(this.apiBaseURL="https://identity.dev.svc.youverify.co"),this.onSuccess=d,this.onFailure=c,this.onClose=h,this.onCancel=m,this.metadata=p,this.iFrameMessageHandler=e=>{this.handleIFrameMessage(e)}}validateOptions(){if(!this.businessId)throw new Error("Public Merchant Key is required");if(this.onSuccess&&"function"!=typeof this.onSuccess)throw new Error("onSuccess callback must be of type function");if(this.onFailure&&"function"!=typeof this.onFailure)throw new Error("onFailure callback must be of type function");if(this.onClose&&"function"!=typeof this.onClose)throw new Error("onClose callback must be of type function");if(this.personalInformation&&("object"!=typeof this.personalInformation||Array.isArray(this.personalInformation)))throw new Error("Personal Information should be of type object");if(this.personalInformation)for(const e of Object.keys(this.personalInformation))if(!this.allowedPersonalInformationFields.includes(e))throw new Error(e+" is not allowed in Personal Information. Must be one of "+this.allowedPersonalInformationFields.join(", "))}async postScannedData(e){const t=e.type,{}=e,o=_objectWithoutProperties(e,_excluded);try{const e=await fetch(this.apiBaseURL+"/v1/sdk/identity/document-capture/",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(_objectSpread({publicMerchantID:this.publicMerchantKey,components:["id_capture"],documentType:t,method:"documentCapture",metadata:this.metadata},o))});if(!e.ok){let t;try{t=await e.json()}catch(o){t={message:e.statusText}}const o=new Error("API request failed");throw o.isApiError=!0,o.response={status:e.status,statusText:e.statusText,error:t},o}return(await e.json()).data}catch(e){if(e.isApiError){const t=new Error(e.message);throw t.response=e.response,t}const t=new Error("Network or unexpected error");throw t.response={status:0,statusText:"",error:{message:e.message,name:e.name||"NetworkError",statusCode:0,success:!1,data:{}}},t}}async handleIFrameMessage(e){const{data:t={},origin:o}=e;if(o===this.baseURL)switch(t.id){case"yvos:document:success":try{const{fullDocumentFrontImage:e,fullDocumentImage:o}=t.data,i=await this.postScannedData(_objectSpread(_objectSpread({},t.data),{},{fullDocumentFrontImage:e||o,fullDocumentImage:void 0,photo:void 0}));this.onSuccess(i)}catch(e){e.response?this.onFailure(e.response.error):this.onFailure(e)}break;case"yvos:document-upload:success":this.onSuccess(t.data);break;case"yvos:document:failed":default:break;case"yvos:document:closed":this.onClose(t.data),this.setShowModal(!1);break;case"yvos:document:cancelled":this.onCancel(t.data)}}initIFrame(){const e=this.countries&&this.countries.length?JSON.stringify(this.countries):"",t=btoa(this.appearance.primaryColor),o=btoa(this.publicMerchantKey),i=this.hideUsingSecondaryDevice?"true":"false";return new Promise((async(s,n)=>{try{this.iFrame=this.createElement({tag:"iframe",attributes:{src:`${this.baseURL}/services/${this.businessId}/document?countries=${e}&primaryColor=${t}&pmk=${o}&hideUsingSecondaryDevice=`+i,style:{height:"100%",width:"100%"},class:"hide animate",allow:"camera; microphone; clipboard-read; clipboard-write"}}),this.iFrame.addEventListener("load",(()=>{this.loader.classList.add("hide"),this.personalization.classList.remove("hide")})),this.modalContent.appendChild(this.iFrame),s({done:!0})}catch(s){n(s)}}))}async start(){try{this.setShowModal(!0),window.addEventListener("message",this.iFrameMessageHandler),this.iFrame||await this.initIFrame()}catch(e){throw e}}startProcess(){this.preliminaryContent.classList.add("hide"),this.iFrame.classList.remove("hide")}}};"undefined"!=typeof window&&(window.YouverifySDK=e)})();
//# sourceMappingURL=/sm/ee57be3f01105489d028a1bc956f62d0ffb0cc1fe9127033ef33f25d4e1215ab.map