@vpdev2/metakyc-sdk 1.0.42 → 1.0.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/CreateApplicantForm.d.ts.map +1 -1
- package/dist/components/core/Select.d.ts +1 -1
- package/dist/components/core/Select.d.ts.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +74 -52
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var ar=Object.defineProperty;var nr=(t,r,s)=>r in t?ar(t,r,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[r]=s;var Q=(t,r,s)=>nr(t,typeof r!="symbol"?r+"":r,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ir=require("axios"),l=require("react"),e=require("react/jsx-runtime"),ke=require("react-hook-form"),ve=require("zod");function lr(t){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const s in t)if(s!=="default"){const a=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(r,s,a.get?a:{enumerable:!0,get:()=>t[s]})}}return r.default=t,Object.freeze(r)}const Ke=lr(l);var z=(t=>(t[t.IdentitySdk=0]="IdentitySdk",t[t.RiskScoring=1]="RiskScoring",t[t.Questionaries=2]="Questionaries",t[t.AdditionalData=3]="AdditionalData",t[t.AppropriatenessTest=4]="AppropriatenessTest",t[t.UploadDocument=5]="UploadDocument",t[t.ManualReview=6]="ManualReview",t[t.Overview=7]="Overview",t[t.InvestorCategorization=8]="InvestorCategorization",t))(z||{}),Re=(t=>(t[t.NotStarted=0]="NotStarted",t[t.InProgress=1]="InProgress",t[t.Success=2]="Success",t[t.PartialSuccess=3]="PartialSuccess",t[t.Failed=4]="Failed",t[t.Skipped=5]="Skipped",t[t.AdminReview=6]="AdminReview",t[t.SkippedAndAdminReview=7]="SkippedAndAdminReview",t))(Re||{}),me=(t=>(t[t.None=0]="None",t[t.InProgress=1]="InProgress",t[t.Finished=2]="Finished",t[t.OnHold=3]="OnHold",t[t.IdentityPending=4]="IdentityPending",t))(me||{}),He=(t=>(t[t.None=0]="None",t[t.RepresentativeKYC=1]="RepresentativeKYC",t[t.ManualRiskCriteria=2]="ManualRiskCriteria",t[t.UploadDocumentReview=3]="UploadDocumentReview",t[t.AdminReview=4]="AdminReview",t))(He||{}),We=(t=>(t[t.LowRisk=0]="LowRisk",t[t.MediumRisk=1]="MediumRisk",t[t.HighRisk=2]="HighRisk",t[t.Alert=3]="Alert",t))(We||{}),we=(t=>(t[t.None=0]="None",t[t.Pending=1]="Pending",t[t.Approved=2]="Approved",t[t.Rejected=3]="Rejected",t[t.ResendRequested=4]="ResendRequested",t[t.Unknown=5]="Unknown",t[t.InProgress=6]="InProgress",t))(we||{}),je=(t=>(t[t.Approved=0]="Approved",t[t.Reject=1]="Reject",t[t.UnderReview=2]="UnderReview",t[t.Closed=3]="Closed",t[t.AdminReview=4]="AdminReview",t[t.New=5]="New",t[t.InProgress=6]="InProgress",t))(je||{}),Ye=(t=>(t[t.ProviderResultPending=0]="ProviderResultPending",t[t.ProviderResultReceived=1]="ProviderResultReceived",t[t.Canceled=2]="Canceled",t[t.ExtendedToNewApplicant=3]="ExtendedToNewApplicant",t))(Ye||{}),Qe=(t=>(t[t.None=0]="None",t[t.ProviderResultPending=1]="ProviderResultPending",t[t.ProviderResultReceived=2]="ProviderResultReceived",t[t.Canceled=3]="Canceled",t))(Qe||{}),ue=(t=>(t[t.Onfido=0]="Onfido",t[t.Sumsub=2]="Sumsub",t[t.SardinAI=3]="SardinAI",t))(ue||{}),Ve=(t=>(t[t.Individual=0]="Individual",t[t.Company=1]="Company",t))(Ve||{}),Ie=(t=>(t[t.Male=0]="Male",t[t.Female=1]="Female",t[t.Other=2]="Other",t))(Ie||{}),Ge=(t=>(t[t.Image=0]="Image",t[t.Video=1]="Video",t[t.PDF=2]="PDF",t[t.OfficePDF=3]="OfficePDF",t[t.Custom=4]="Custom",t))(Ge||{}),Ze=(t=>(t[t.Pending=0]="Pending",t[t.Approved=1]="Approved",t[t.Rejected=2]="Rejected",t[t.RequiresRevision=3]="RequiresRevision",t))(Ze||{}),Je=(t=>(t[t.SingleChoice=0]="SingleChoice",t[t.MultipleChoice=1]="MultipleChoice",t[t.Text=2]="Text",t))(Je||{}),fe=(t=>(t[t.String=0]="String",t[t.Integer=1]="Integer",t[t.Decimal=2]="Decimal",t[t.Boolean=3]="Boolean",t[t.Date=4]="Date",t[t.Country=5]="Country",t[t.DigitOnly=6]="DigitOnly",t))(fe||{}),Xe=(t=>(t[t.Text=0]="Text",t[t.Radio=1]="Radio",t[t.Checkbox=2]="Checkbox",t[t.Dropdown=3]="Dropdown",t[t.Country=4]="Country",t))(Xe||{}),et=(t=>(t[t.None=0]="None",t[t.Country=1]="Country",t))(et||{}),ce=(t=>(t[t.Individual=0]="Individual",t[t.Sophisticated=1]="Sophisticated",t[t.HighNetWorth=2]="HighNetWorth",t[t.Business=3]="Business",t))(ce||{}),tt=(t=>(t[t.Retail=0]="Retail",t[t.Professional=1]="Professional",t[t.EligibleCounterparty=2]="EligibleCounterparty",t))(tt||{});const Fe={firstName:{label:"First Name",type:"text"},lastName:{label:"Last Name",type:"text"},email:{label:"Email",type:"email"},phonenumber:{label:"Phone Number",type:"tel"},dateOfBirth:{label:"Date of Birth",type:"date"},salutation:{label:"Salutation",type:"select"},title:{label:"Title",type:"text"},mobileCountryCode:{label:"Mobile Country Code",type:"text"},street:{label:"Street",type:"text"},streetNumber:{label:"Street Number",type:"text"},zip:{label:"ZIP / Postal Code",type:"text"},city:{label:"City",type:"text"},country:{label:"Country",type:"select"},nationality:{label:"Nationality",type:"select"},otherNationality:{label:"Other Nationalities",type:"multiselect"},countryOfBirth:{label:"Country of Birth",type:"select"},placeOfBirth:{label:"Place of Birth",type:"text"},taxCountry:{label:"Tax Country",type:"select"},taxNumber:{label:"Tax Number",type:"text"},defaultLanguage:{label:"Default Language",type:"select"},educationLevel:{label:"Education Level",type:"text"},occupation:{label:"Occupation",type:"text"}},rt=["firstName","lastName","email","phonenumber","dateOfBirth"],ze=[{value:"EN",label:"English"},{value:"DE",label:"German"},{value:"FR",label:"French"},{value:"ES",label:"Spanish"},{value:"IT",label:"Italian"},{value:"PT",label:"Portuguese"},{value:"NL",label:"Dutch"},{value:"PL",label:"Polish"},{value:"RU",label:"Russian"},{value:"ZH",label:"Chinese"},{value:"JA",label:"Japanese"},{value:"AR",label:"Arabic"},{value:"TR",label:"Turkish"},{value:"SV",label:"Swedish"},{value:"DA",label:"Danish"},{value:"FI",label:"Finnish"},{value:"NO",label:"Norwegian"}];var ee=(t=>(t.Default="default",t.Corporate="corporate",t.Fintech="fintech",t.Healthcare="healthcare",t.Modern="modern",t.Minimal="minimal",t))(ee||{});const st={timeout:3e4,retries:3,locale:"en",endpoints:{pattern:"host-controller"}};class at{constructor(r){this.config=r}build(r,s){const a=`${r}.${s}`;if(this.config.customPaths&&this.config.customPaths[a])return this.config.customPaths[a];switch(this.config.pattern){case"host-controller":return`/api/${r}/${s}`;case"application-service":return`/services/app/${this.getServiceName(r)}/${s}`;case"custom":throw new Error(`Custom endpoint path not found for ${a}. Please provide it in customPaths.`);default:throw new Error(`Unknown endpoint pattern: ${this.config.pattern}`)}}getServiceName(r){return{Applicant:"MetaKYCVerification",Questionnaire:"MetaKYCVerification",UploadDocument:"MetaKYCVerification",AppropriatenessTest:"MetaKYCVerification",BaseInformation:"MetaKYCVerification"}[r]||r}}class xe extends Error{constructor(s,a,n,i,o){super(s);Q(this,"response");this.code=a,this.details=n,this.validationErrors=i,this.name="MetaKYCError",this.response=o,Object.setPrototypeOf(this,xe.prototype)}}class Ce{static handleApiError(r){return new xe(r.message||"An unknown error occurred",r.code,r.details||void 0,r.validationErrors||void 0)}static handleAxiosError(r){if(r.response){const s=r.response.data;return s&&s.error?new xe(s.error.message||"An unknown error occurred",s.error.code,s.error.details||void 0,s.error.validationErrors||void 0,r.response):s&&s.result&&s.result.message?new xe(s.result.message,r.response.status,`HTTP ${r.response.status}: ${r.response.statusText}`,void 0,r.response):new xe((s==null?void 0:s.message)||r.message||"Request failed",r.response.status,`HTTP ${r.response.status}: ${r.response.statusText}`,void 0,r.response)}else return r.request?new xe("No response from server",0,"The request was made but no response was received. Please check your network connection."):new xe(r.message||"An unexpected error occurred",0,r.toString())}static isMetaKYCError(r){return r instanceof xe}}class nt{constructor(r){Q(this,"axiosInstance");Q(this,"endpointBuilder");Q(this,"config");this.config={...st,...r},this.endpointBuilder=new at(this.config.endpoints),this.axiosInstance=ir.create({baseURL:this.config.baseUrl,timeout:this.config.timeout,headers:{"Content-Type":"application/json"}}),this.axiosInstance.interceptors.request.use(s=>(s.headers["Abp-TenantId"]=this.config.tenantId.toString(),s.headers.ApiKey=this.config.apiKey,s.headers["X-API-KEY"]=this.config.apiKey,this.config.locale&&(s.headers["Accept-Language"]=this.config.locale),s),s=>Promise.reject(s)),this.axiosInstance.interceptors.response.use(s=>s,async s=>{var n;const a=s.config;return((n=s.response)==null?void 0:n.status)>=500&&!a._retry&&(a._retry=!0,a._retryCount=(a._retryCount||0)+1,a._retryCount<(this.config.retries||3))?(await new Promise(i=>setTimeout(i,1e3*a._retryCount)),this.axiosInstance(a)):Promise.reject(s)})}buildEndpoint(r,s){return this.endpointBuilder.build(r,s)}async get(r,s,a){try{const n=this.buildEndpoint(r,s),i=await this.axiosInstance.get(n,{params:a});return this.handleResponse(i)}catch(n){throw Ce.handleAxiosError(n)}}async post(r,s,a){try{const n=this.buildEndpoint(r,s),i=await this.axiosInstance.post(n,a);return this.handleResponse(i)}catch(n){throw Ce.handleAxiosError(n)}}async put(r,s,a){try{const n=this.buildEndpoint(r,s),i=await this.axiosInstance.put(n,a);return this.handleResponse(i)}catch(n){throw Ce.handleAxiosError(n)}}async delete(r,s,a){try{const n=this.buildEndpoint(r,s),i=await this.axiosInstance.delete(n,{params:a});return this.handleResponse(i)}catch(n){throw Ce.handleAxiosError(n)}}handleResponse(r){const s=r.data;if(!s.success&&s.error)throw Ce.handleApiError(s.error);return s}getAxiosInstance(){return this.axiosInstance}}class it{constructor(r){this.httpClient=r}async createApplicant(r){return(await this.httpClient.post("Applicant","ApplicantRegistrationRequest",r)).result}async createCompanyApplicant(r){return(await this.httpClient.post("Applicant","ApplicantCompanyRegistrationRequest",r)).result}async duplicateApplicant(r){return(await this.httpClient.post("Applicant","DuplicateApplicantRegistrationRequest",r)).result}async getProgress(r){return(await this.httpClient.get("Applicant","GetApplicantProgress",{applicantId:r})).result}async getProgressStatus(r){return(await this.httpClient.get("Applicant","GetApplicantProgressStaus",{applicantId:r})).result}async getApplicantData(r){return(await this.httpClient.get("Applicant","GetApplicantData",{applicantId:r})).result}async getApplicantStatus(r){return(await this.httpClient.get("Applicant","GetApplicantStatus",{applicantId:r})).result}async stopProgress(r){await this.httpClient.get("Applicant","StopProgress",{applicantId:r})}async progressStepBack(r){await this.httpClient.get("Applicant","ProgressStepBack",{applicantId:r})}async setLanguage(r,s){await this.httpClient.post("Applicant","SetApplicantLng",{applicantId:r,language:s})}async activateApplicant(r){await this.httpClient.get("Applicant","ActivateApplicant",{applicantId:r})}async deleteApplicant(r){await this.httpClient.delete("Applicant","DeleteApplicant",{applicantId:r})}async checkApplicantExists(r){return(await this.httpClient.get("Applicant","CheckApplicantIfExists",{externalRefId:r})).result}}class lt{constructor(r){this.httpClient=r}async getQuestionnaire(r){return(await this.httpClient.get("Questionnaire","GetQuestionnaire",{applicantid:r})).result}async fillQuestionnaire(r){return(await this.httpClient.post("Applicant","FillQuestionnarie",r)).result}}class ot{constructor(r){this.httpClient=r}async getUploadDocument(r){return(await this.httpClient.get("UploadDocument","GetUploadDocument",{applicantid:r})).result}async fillUploadDocument(r){await this.httpClient.post("Applicant","FillUploadDocument",r)}async reviewUploadDocument(r){await this.httpClient.post("UploadDocument","ReviewUploadDocument",r)}}class ct{constructor(r){this.httpClient=r}async getAppropriatenessTest(r){return(await this.httpClient.get("AppropriatenessTest","GetAppropriatenessTest",{applicantid:r})).result}async fillAppropriatenessTest(r){return(await this.httpClient.post("Applicant","FillAppropriatenessTest",r)).result}}class dt{constructor(r){this.httpClient=r}async getOverviewData(r){return(await this.httpClient.get("Applicant","GetOverviewData",{ApplicantId:r})).result}async passOverview(r){await this.httpClient.get("Applicant","PassOverview",{applicantId:r})}}class ut{constructor(r){this.httpClient=r}async getRiskScoringPlan(){return(await this.httpClient.get("Applicant","GetRiskScoringPlanInfo")).result}async getRiskCriterias(r){return(await this.httpClient.get("Risk","GetCriterias",{applicantId:r})).result}async submitRiskScoring(r){return(await this.httpClient.post("Applicant","RiskScoringRequest",r)).result}}class mt{constructor(r){this.httpClient=r}async identityRequest(r){console.log("[IdentityService] Calling IdentityRequest with input:",r);const s=await this.httpClient.post("Applicant","IdentityRequest",r);return console.log("[IdentityService] IdentityRequest response:",s),s.result}async identityCompanyRequest(r){return(await this.httpClient.post("Applicant","IdentityCompanyRequest",r)).result}async restartIdentityRequest(r){const s={applicantId:r,restart:!0,redirectUrl:"",ttl:604800};return console.log("[IdentityService] Restarting identity with restart=true:",s),this.identityRequest(s)}async restartIdentityCompanyRequest(r){const s={applicantId:r,restart:!0,redirectUrl:"",ttl:604800};return this.identityCompanyRequest(s)}}class pt{constructor(r){this.httpClient=r}async getCountries(r,s,a){return(await this.httpClient.get("BaseInformation","GetAllCountries",{filter:r||"",lng:s||"en",type:a})).result}async getBranches(){return(await this.httpClient.get("BaseInformation","GetBranches")).result}async getLegalEntities(){return(await this.httpClient.get("BaseInformation","GetLegalEntities")).result}}class ht{constructor(r){this.httpClient=r}async setInvestorCategorization(r){return(await this.httpClient.post("Applicant","SetInvestorCategorization",r)).result}async getInvestorCategorization(r){return(await this.httpClient.get("Applicant","GetInvestorCategorisation",{applicantId:r})).result}}const ne={name:"Default",title:"KYC Verification",logo:{url:"",height:"40px",visible:!0},colors:{primary:"#2563eb",primaryHover:"#1d4ed8",primaryLight:"#dbeafe",primaryDark:"#1e40af",secondary:"#64748b",secondaryHover:"#475569",success:"#10b981",warning:"#f59e0b",danger:"#ef4444",info:"#3b82f6",background:"#ffffff",surface:"#f9fafb",border:"#e5e7eb",textPrimary:"#111827",textSecondary:"#6b7280",textMuted:"#9ca3af"},typography:{fontFamily:"Inter, system-ui, -apple-system, sans-serif",fontSize:{xs:"0.75rem",sm:"0.875rem",base:"1rem",lg:"1.125rem",xl:"1.25rem","2xl":"1.5rem","3xl":"1.875rem"},fontWeight:{normal:400,medium:500,semibold:600,bold:700}},spacing:{borderRadius:"0.5rem",cardPadding:"1.5rem",inputHeight:"2.5rem"},darkMode:{colors:{background:"#111827",surface:"#1f2937",border:"#374151",textPrimary:"#f9fafb",textSecondary:"#d1d5db",textMuted:"#9ca3af"}}},gt={name:"Corporate",logo:{url:"",height:"40px",visible:!0},colors:{primary:"#0052CC",primaryHover:"#0747A6",primaryLight:"#DEEBFF",primaryDark:"#0747A6",secondary:"#6B778C",secondaryHover:"#5E6C84",success:"#00875A",warning:"#FF991F",danger:"#DE350B",info:"#0065FF",background:"#ffffff",surface:"#F4F5F7",border:"#DFE1E6",textPrimary:"#172B4D",textSecondary:"#5E6C84",textMuted:"#97A0AF"},typography:{fontFamily:"system-ui, -apple-system, sans-serif"},spacing:{borderRadius:"0.25rem",cardPadding:"1.5rem",inputHeight:"2.5rem"}},xt={name:"Fintech",logo:{url:"",height:"36px",visible:!0},colors:{primary:"#00B386",primaryHover:"#009973",primaryLight:"#D1FAE5",primaryDark:"#047857",secondary:"#7C3AED",secondaryHover:"#6D28D9",success:"#10B981",warning:"#F59E0B",danger:"#EF4444",info:"#3B82F6",background:"#ffffff",surface:"#F9FAFB",border:"#E5E7EB",textPrimary:"#111827",textSecondary:"#6B7280",textMuted:"#9CA3AF"},typography:{fontFamily:"Montserrat, system-ui, sans-serif"},spacing:{borderRadius:"0.75rem",cardPadding:"2rem",inputHeight:"3rem"}},yt={name:"Healthcare",logo:{url:"",height:"44px",visible:!0},colors:{primary:"#06B6D4",primaryHover:"#0891B2",primaryLight:"#CFFAFE",primaryDark:"#0E7490",secondary:"#8B5CF6",secondaryHover:"#7C3AED",success:"#059669",warning:"#D97706",danger:"#DC2626",info:"#0284C7",background:"#ffffff",surface:"#F0F9FF",border:"#E0F2FE",textPrimary:"#0F172A",textSecondary:"#475569",textMuted:"#94A3B8"},typography:{fontFamily:"Lato, system-ui, sans-serif"},spacing:{borderRadius:"0.5rem",cardPadding:"1.75rem",inputHeight:"2.75rem"},darkMode:{colors:{background:"#0F172A",surface:"#1E293B",border:"#334155",textPrimary:"#F1F5F9",textSecondary:"#CBD5E1"}}},ft={name:"Modern",logo:{url:"",height:"38px",visible:!0},colors:{primary:"#8B5CF6",primaryHover:"#7C3AED",primaryLight:"#EDE9FE",primaryDark:"#6D28D9",secondary:"#EC4899",secondaryHover:"#DB2777",success:"#10B981",warning:"#F59E0B",danger:"#EF4444",info:"#3B82F6",background:"#ffffff",surface:"#FAFAFA",border:"#E5E5E5",textPrimary:"#171717",textSecondary:"#737373",textMuted:"#A3A3A3"},typography:{fontFamily:"Poppins, system-ui, sans-serif"},spacing:{borderRadius:"1rem",cardPadding:"2rem",inputHeight:"3rem"}},bt={name:"Minimal",logo:{url:"",height:"32px",visible:!0},colors:{primary:"#000000",primaryHover:"#18181B",primaryLight:"#F4F4F5",primaryDark:"#000000",secondary:"#71717A",secondaryHover:"#52525B",success:"#22C55E",warning:"#EAB308",danger:"#EF4444",info:"#3B82F6",background:"#ffffff",surface:"#FAFAFA",border:"#E4E4E7",textPrimary:"#09090B",textSecondary:"#71717A",textMuted:"#A1A1AA"},typography:{fontFamily:"system-ui, -apple-system, sans-serif"},spacing:{borderRadius:"0.25rem",cardPadding:"1.25rem",inputHeight:"2.25rem"}},vt={[ee.Default]:ne,[ee.Corporate]:gt,[ee.Fintech]:xt,[ee.Healthcare]:yt,[ee.Modern]:ft,[ee.Minimal]:bt};function Ae(t){return vt[t]||ne}class kt{constructor(r){this.httpClient=r}async getThemeConfiguration(){var r;try{const s=await this.httpClient.get("Tenant","GetThemeConfiguration");if(!s.result.isEnabled)return Ae(ee.Default);let a=s.result.preset?Ae(s.result.preset):Ae(ee.Default);if(s.result.title&&(a.title=s.result.title),s.result.logo&&(a.logo={...a.logo,...s.result.logo}),s.result.colors&&(a.colors={...a.colors,...s.result.colors}),s.result.typography&&(a.typography={...a.typography,...s.result.typography}),s.result.spacing&&(a.spacing={...a.spacing,...s.result.spacing}),s.result.customCSS&&(a.customCSS=s.result.customCSS),s.result.darkMode&&(a.darkMode={colors:{...(r=a.darkMode)==null?void 0:r.colors,...s.result.darkMode.colors}}),s.result.applicantFormVisibleFields&&s.result.applicantFormVisibleFields.length>0&&(a.applicantFormVisibleFields=s.result.applicantFormVisibleFields),s.result.applicantFormRequiredFields&&s.result.applicantFormRequiredFields.length>0&&(a.applicantFormRequiredFields=s.result.applicantFormRequiredFields),s.result.allowedLanguages&&s.result.allowedLanguages.length>0&&(a.allowedLanguages=s.result.allowedLanguages),s.result.applicantFormPages)try{const n=typeof s.result.applicantFormPages=="string"?JSON.parse(s.result.applicantFormPages):s.result.applicantFormPages;Array.isArray(n)&&n.length>0&&(a.applicantFormPages=n)}catch{}return a}catch(s){return console.warn("[ThemeService] Failed to fetch theme configuration:",s),Ae(ee.Default)}}async saveThemeConfiguration(r){await this.httpClient.post("Tenant","SaveThemeConfiguration",r)}getAvailablePresets(){return[{id:ee.Default,name:"Default"},{id:ee.Corporate,name:"Corporate"},{id:ee.Fintech,name:"Fintech"},{id:ee.Healthcare,name:"Healthcare"},{id:ee.Modern,name:"Modern"},{id:ee.Minimal,name:"Minimal"}]}getPreviewTheme(r,s){const a=Ae(r);return s?{...a,...s,logo:{...a.logo,...s.logo},colors:{...a.colors,...s.colors},typography:s.typography?{...a.typography,...s.typography}:a.typography,spacing:s.spacing?{...a.spacing,...s.spacing}:a.spacing}:a}}class wt{constructor(){Q(this,"listeners",new Map)}on(r,s){return this.listeners.has(r)||this.listeners.set(r,new Set),this.listeners.get(r).add(s),()=>{this.off(r,s)}}off(r,s){const a=this.listeners.get(r);a&&a.delete(s)}emit(r,s){const a=this.listeners.get(r);a&&a.forEach(n=>{try{n(s)}catch(i){console.error(`Error in event listener for "${r}":`,i)}})}clear(){this.listeners.clear()}clearEvent(r){this.listeners.delete(r)}}class jt{constructor(){Q(this,"events",new wt);Q(this,"_applicantId",null);Q(this,"_progress",null);Q(this,"_error",null)}get applicantId(){return this._applicantId}get progress(){return this._progress}get currentStep(){var r;return((r=this._progress)==null?void 0:r.currentStep)||null}get steps(){var r;return((r=this._progress)==null?void 0:r.stepInfoList)||[]}get status(){var r;return((r=this._progress)==null?void 0:r.status)||me.None}get workflowResult(){var r;return((r=this._progress)==null?void 0:r.workflowResult)||null}get error(){return this._error}get isComplete(){return this.status===me.Finished}get isOnHold(){return this.status===me.OnHold}get isInProgress(){return this.status===me.InProgress}setApplicantId(r){this._applicantId=r}updateProgress(r){var a,n;const s=(a=this._progress)==null?void 0:a.currentStep;this._progress=r,this._applicantId=r.applicantId,this._error=null,this.events.emit("progressUpdated",r),(s==null?void 0:s.order)!==((n=r.currentStep)==null?void 0:n.order)&&this.events.emit("stepChanged",r.currentStep),this.events.emit("statusChanged",r.status),r.status===me.Finished&&r.workflowResult&&this.events.emit("completed",r.workflowResult)}setError(r){this._error=r,this.events.emit("error",r)}clearError(){this._error=null}reset(){this._applicantId=null,this._progress=null,this._error=null}onProgressUpdated(r){return this.events.on("progressUpdated",r)}onStepChanged(r){return this.events.on("stepChanged",r)}onStatusChanged(r){return this.events.on("statusChanged",r)}onError(r){return this.events.on("error",r)}onCompleted(r){return this.events.on("completed",r)}clearListeners(){this.events.clear()}}class Nt{constructor(){Q(this,"handlers",new Map)}registerHandler(r,s){this.handlers.set(r,s)}getHandler(r){return this.handlers.get(r)}hasHandler(r){return this.handlers.has(r)}async loadStepData(r,s){const a=this.getHandler(r);if(!a)throw new Error(`No handler registered for step action: ${z[r]}`);return a.loadData(s)}async submitStepData(r,s){const a=this.getHandler(r);if(!a)throw new Error(`No handler registered for step action: ${z[r]}`);return a.submitData(s)}}class St{constructor(r,s,a,n,i,o,c,d){Q(this,"state");Q(this,"stepRouter");this.applicantService=r,this.questionnaireService=s,this.uploadDocumentService=a,this.appropriatenessTestService=n,this.overviewService=i,this.riskScoringService=o,this.investorCategorizationService=d,this.state=new jt,this.stepRouter=new Nt,this.registerStepHandlers()}registerStepHandlers(){this.stepRouter.registerHandler(z.Questionaries,{loadData:r=>this.questionnaireService.getQuestionnaire(r),submitData:async r=>{await this.questionnaireService.fillQuestionnaire(r)}}),this.stepRouter.registerHandler(z.UploadDocument,{loadData:r=>this.uploadDocumentService.getUploadDocument(r),submitData:r=>this.uploadDocumentService.fillUploadDocument(r)}),this.stepRouter.registerHandler(z.AppropriatenessTest,{loadData:r=>this.appropriatenessTestService.getAppropriatenessTest(r),submitData:async r=>{await this.appropriatenessTestService.fillAppropriatenessTest(r)}}),this.stepRouter.registerHandler(z.Overview,{loadData:r=>this.overviewService.getOverviewData(r),submitData:r=>this.overviewService.passOverview(r.applicantId)}),this.stepRouter.registerHandler(z.RiskScoring,{loadData:r=>this.riskScoringService.getRiskCriterias(r),submitData:async r=>{await this.riskScoringService.submitRiskScoring(r)}}),this.stepRouter.registerHandler(z.IdentitySdk,{loadData:async r=>({applicantId:r,message:"Identity verification required"}),submitData:async()=>{}}),this.stepRouter.registerHandler(z.InvestorCategorization,{loadData:r=>this.investorCategorizationService.getInvestorCategorization(r),submitData:async r=>{await this.investorCategorizationService.setInvestorCategorization(r)}}),this.stepRouter.registerHandler(z.ManualReview,{loadData:async r=>({applicantId:r,message:"Your application is under manual review"}),submitData:async()=>{}}),this.stepRouter.registerHandler(z.AdditionalData,{loadData:async r=>({applicantId:r,message:"Additional data required"}),submitData:async()=>{}})}async initialize(r){try{this.state.setApplicantId(r);const s=await this.applicantService.getProgress(r);return this.state.updateProgress(s),s}catch(s){throw this.state.setError(s),s}}async refreshProgress(){if(!this.state.applicantId)throw new Error("Workflow not initialized. Call initialize() first.");try{const r=await this.applicantService.getProgress(this.state.applicantId);return this.state.updateProgress(r),r}catch(r){throw this.state.setError(r),r}}async getCurrentStepData(){if(!this.state.currentStep)throw new Error("No current step available");if(!this.state.applicantId)throw new Error("Workflow not initialized");try{return await this.stepRouter.loadStepData(this.state.currentStep.action,this.state.applicantId)}catch(r){throw this.state.setError(r),r}}async submitCurrentStep(r){if(!this.state.currentStep)throw new Error("No current step available");try{await this.stepRouter.submitStepData(this.state.currentStep.action,r),await this.refreshProgress()}catch(s){throw this.state.setError(s),s}}async moveToNextStep(){return this.refreshProgress()}async moveToPreviousStep(){if(!this.state.applicantId)throw new Error("Workflow not initialized");try{return await this.applicantService.progressStepBack(this.state.applicantId),await this.refreshProgress()}catch(r){throw this.state.setError(r),r}}getState(){return this.state}getStepRouter(){return this.stepRouter}}function $e(t,r){return new Promise((s,a)=>{if(r&&document.getElementById(r)){s();return}const n=document.createElement("script");n.src=t,r&&(n.id=r),n.async=!0,n.onload=()=>s(),n.onerror=()=>a(new Error(`Failed to load script: ${t}`)),document.head.appendChild(n)})}function or(t){return!!document.getElementById(t)}function cr(t){const r=document.getElementById(t);r&&r.remove()}class Ct{constructor(r){Q(this,"sdk",null);Q(this,"config");this.config=r}async loadSDK(){await $e("https://cdn.sumsub.com/websdk/v2/production/websdk.js","sumsub-sdk")}async initialize(r){if(window.snsWebSdk||await this.loadSDK(),!window.snsWebSdk)throw new Error("Sumsub SDK failed to load");this.sdk=window.snsWebSdk.init(this.config.accessToken,()=>this.config.accessToken).withConf({lang:this.config.lang||"en",email:this.config.applicantEmail,phone:this.config.applicantPhone,i18n:{}}).on("idCheck.onStepCompleted",s=>{console.log("Sumsub step completed:",s)}).on("idCheck.onError",s=>{console.error("Sumsub error:",s)}).build(),this.sdk.launch(`#${r}`)}destroy(){this.sdk&&(this.sdk.destroy(),this.sdk=null)}onComplete(r){this.sdk&&this.sdk.on("idCheck.applicantStatus",s=>{s.applicantStatus==="completed"&&r(s)})}onError(r){this.sdk&&this.sdk.on("idCheck.onError",r)}}class At{constructor(r){Q(this,"sdk",null);Q(this,"config");this.config=r}async loadSDK(){await $e("https://sdk.onfido.com/v12.0.0/onfido.min.js","onfido-sdk")}async initialize(r){if(window.Onfido||await this.loadSDK(),!window.Onfido)throw new Error("Onfido SDK failed to load");this.sdk=window.Onfido.init({token:this.config.token,containerId:r,steps:this.config.steps||[{type:"welcome",options:{title:"Identity Verification"}},{type:"document",options:{documentTypes:{passport:!0,driving_licence:!0,national_identity_card:!0}}},{type:"face",options:{requestedVariant:"standard"}},{type:"complete"}],onComplete:()=>{this.config.onComplete&&this.config.onComplete()},onError:s=>{this.config.onError&&this.config.onError(s)}})}destroy(){this.sdk&&(this.sdk.tearDown(),this.sdk=null)}}class Et{constructor(r){Q(this,"sardineContext",null);Q(this,"config");Q(this,"sessionKey");this.config=r,this.sessionKey=r.sessionKey||this.generateSessionKey()}generateSessionKey(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(r){const s=Math.random()*16|0;return(r==="x"?s:s&3|8).toString(16)})}getSardineHost(){const{environment:r,region:s}=this.config;if(r==="sandbox")return"api.sandbox.sardine.ai";switch(s){case"eu":return"api.eu.sardine.ai";case"ca":return"api.ca.sardine.ai";case"au":return"api.au.sardine.ai";default:return"api.sardine.ai"}}async loadSDK(){return new Promise((r,s)=>{if(window._Sardine){r();return}const a=this.getSardineHost(),n=document.createElement("script");n.type="text/javascript",n.async=!0,n.src=`https://${a}/assets/loader.min.js`,n.onload=()=>{console.log("[SardinAI] SDK loaded successfully"),r()},n.onerror=()=>{s(new Error("Failed to load SardinAI SDK"))};const i=document.getElementsByTagName("script")[0];i&&i.parentNode?i.parentNode.insertBefore(n,i):document.head.appendChild(n)})}async initialize(){try{if(await this.loadSDK(),!window._Sardine)throw new Error("SardinAI SDK not available after loading");const r=this.getSardineHost(),{clientId:s,environment:a,flow:n,enableBiometrics:i,enablePortScanning:o}=this.config;this.sardineContext=window._Sardine.createContext({clientId:s,sessionKey:this.sessionKey,userIdHash:void 0,flow:n||window.location.pathname,environment:a||"production",parentElement:document.body,enableBiometrics:i!==!1,enablePortScanning:o===!0,region:this.config.region,onDeviceResponse:c=>{console.log(`[SardinAI] Device ID: ${c.deviceId}`)},onConfigUpdate:(c,d,m)=>{switch(c){case"SESSION_UPDATE_FAILED":console.error("[SardinAI] Session update failed:",m);break;case"SESSION_UPDATED":console.log("[SardinAI] Session updated:",d);break;case"SESSION_NO_UPDATE":console.log("[SardinAI] No session update");break;default:console.warn("[SardinAI] Unknown event:",c)}}}),this.addNoScriptFallback(r),console.log("[SardinAI] SDK initialized with sessionKey:",this.sessionKey)}catch(r){throw console.error("[SardinAI] Initialization failed:",r),r}}addNoScriptFallback(r){const s=document.createElement("noscript"),a=document.createElement("img"),{clientId:n,flow:i}=this.config;a.src=`https://${r}/v1/a.png?clientId=${n}&sessionKey=${this.sessionKey}&flow=${i||"kyc"}&ns=1`,a.style.display="none",s.appendChild(a),document.body.appendChild(s)}updateConfig(r){if(!this.sardineContext){console.warn("[SardinAI] Cannot update config - SDK not initialized");return}r.sessionKey&&(this.sessionKey=r.sessionKey),this.sardineContext.updateConfig({...r,onConfigUpdate:(s,a,n)=>{switch(s){case"SESSION_UPDATE_FAILED":console.error("[SardinAI] Config update failed:",n);break;case"SESSION_UPDATED":console.log("[SardinAI] Config updated:",a);break;case"SESSION_NO_UPDATE":console.log("[SardinAI] No config update needed");break}}})}getSessionKey(){return this.sessionKey}destroy(){this.sardineContext&&(this.sardineContext=null)}}class Ne{static createProvider(r,s){switch(r){case ue.Sumsub:return new Ct(s);case ue.Onfido:return new At(s);case ue.SardinAI:return new Et(s);default:throw new Error(`Unsupported identity provider: ${r}`)}}static parseProviderConfig(r,s,a){var n;switch(r){case ue.Sumsub:return{accessToken:s.accessToken||s.token,applicantEmail:s.email,applicantPhone:s.phone,externalUserId:s.externalUserId,lang:s.lang||"en"};case ue.Onfido:return{token:s.token||s.sdkToken};case ue.SardinAI:const i=((n=a==null?void 0:a.identityProviders)==null?void 0:n.sardinai)||{};return{clientId:i.clientId||s.clientId,sessionKey:i.sessionKey||s.sessionKey,environment:i.environment||s.environment||"production",flow:i.flow||s.flow,region:i.region,enableBiometrics:i.enableBiometrics,enablePortScanning:i.enablePortScanning};default:throw new Error(`Unsupported identity provider: ${r}`)}}}class Rt{constructor(r){Q(this,"currentTheme",ne);Q(this,"customStyleElement",null);Q(this,"container");this.container=r||document.documentElement}applyTheme(r){this.currentTheme=this.mergeWithDefault(r),this.applyColors(this.currentTheme.colors),this.currentTheme.typography&&this.applyTypography(this.currentTheme.typography),this.currentTheme.spacing&&this.applySpacing(this.currentTheme.spacing),this.currentTheme.customCSS&&this.injectCustomCSS(this.currentTheme.customCSS),console.log("[ThemeManager] Theme applied:",this.currentTheme.name||"Custom")}applyColors(r){var a;const s={primary:r.primary,"primary-hover":r.primaryHover,"primary-light":r.primaryLight,"primary-dark":r.primaryDark,secondary:r.secondary,"secondary-hover":r.secondaryHover,success:r.success,warning:r.warning,danger:r.danger,info:r.info,background:r.background,surface:r.surface,border:r.border,"text-primary":r.textPrimary,"text-secondary":r.textSecondary,"text-muted":r.textMuted};Object.entries(s).forEach(([n,i])=>{this.container.style.setProperty(`--metakyc-${n}`,i)}),(a=this.currentTheme.darkMode)!=null&&a.colors&&this.applyDarkModeColors(this.currentTheme.darkMode.colors)}applyDarkModeColors(r){Object.entries(r).forEach(([s,a])=>{if(a){const n=`--metakyc-dark-${this.kebabCase(s)}`;this.container.style.setProperty(n,a)}})}applyTypography(r){r&&(r.fontFamily&&this.container.style.setProperty("--metakyc-font-family",r.fontFamily),r.headingFont&&this.container.style.setProperty("--metakyc-heading-font",r.headingFont),r.fontSize&&Object.entries(r.fontSize).forEach(([s,a])=>{this.container.style.setProperty(`--metakyc-font-size-${s}`,a)}),r.fontWeight&&Object.entries(r.fontWeight).forEach(([s,a])=>{this.container.style.setProperty(`--metakyc-font-weight-${s}`,a.toString())}))}applySpacing(r){r&&Object.entries(r).forEach(([s,a])=>{const n=`--metakyc-${this.kebabCase(s)}`;this.container.style.setProperty(n,a)})}injectCustomCSS(r){this.customStyleElement&&this.customStyleElement.remove(),this.customStyleElement=document.createElement("style"),this.customStyleElement.id="metakyc-custom-css",this.customStyleElement.textContent=r,document.head.appendChild(this.customStyleElement)}mergeWithDefault(r){var s;return{name:r.name||ne.name,title:r.title||ne.title,logo:{...ne.logo,...r.logo},colors:{...ne.colors,...r.colors},typography:r.typography?{...ne.typography,...r.typography}:ne.typography,spacing:r.spacing?{...ne.spacing,...r.spacing}:ne.spacing,customCSS:r.customCSS,darkMode:r.darkMode?{colors:{...(s=ne.darkMode)==null?void 0:s.colors,...r.darkMode.colors}}:ne.darkMode,applicantFormVisibleFields:r.applicantFormVisibleFields,applicantFormRequiredFields:r.applicantFormRequiredFields,allowedLanguages:r.allowedLanguages,applicantFormPages:r.applicantFormPages}}getCurrentTheme(){return this.currentTheme}resetTheme(){this.applyTheme(ne)}cleanup(){this.customStyleElement&&(this.customStyleElement.remove(),this.customStyleElement=null)}kebabCase(r){return r.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}}const Ue=l.createContext(null),dr=({config:t,children:r})=>{const[s,a]=l.useState(null),n=l.useRef(!1),i=l.useRef(!1),o=l.useMemo(()=>{const d=new nt(t),m=new it(d),v=new lt(d),w=new ot(d),x=new ct(d),h=new dt(d),g=new ut(d),k=new mt(d),f=new pt(d),p=new ht(d),R=new kt(d),N=new Rt;return{httpClient:d,applicantService:m,questionnaireService:v,uploadDocumentService:w,appropriatenessTestService:x,overviewService:h,riskScoringService:g,identityService:k,baseInformationService:f,investorCategorizationService:p,themeService:R,themeManager:N}},[t]),c=l.useMemo(()=>({config:t,...o,currentTheme:s,createOrchestrator:()=>new St(o.applicantService,o.questionnaireService,o.uploadDocumentService,o.appropriatenessTestService,o.overviewService,o.riskScoringService,o.identityService,o.investorCategorizationService)}),[t,o,s]);return l.useEffect(()=>((async()=>{if(n.current||i.current){console.log("[MetaKYC] Theme already loading or loaded, skipping...");return}n.current=!0;try{if(t.theme){console.log("[MetaKYC] Applying static theme from config"),o.themeManager.applyTheme(t.theme),a(o.themeManager.getCurrentTheme()),i.current=!0;return}console.log("[MetaKYC] Fetching theme from backend...");const m=await o.themeService.getThemeConfiguration();o.themeManager.applyTheme(m),a(o.themeManager.getCurrentTheme()),i.current=!0,console.log("[MetaKYC] Theme loaded and applied",m)}catch(m){console.warn("[MetaKYC] Failed to load theme, using default:",m),a(o.themeManager.getCurrentTheme()),i.current=!0}finally{n.current=!1}})(),()=>{o.themeManager.cleanup()}),[]),e.jsx(Ue.Provider,{value:c,children:r})};function de(){const t=l.useContext(Ue);if(!t)throw new Error("useMetaKYC must be used within a MetaKYCProvider");return t}async function It(t){return new Promise((r,s)=>{const a=new FileReader;a.readAsDataURL(t),a.onload=()=>{const i=a.result.split(",")[1];r(i)},a.onerror=n=>s(n)})}function ur(t,r){return t.size<=r}function mr(t,r){return r.split(",").map(a=>a.trim()).some(a=>{if(a.endsWith("/*")){const n=a.slice(0,-2);return t.type.startsWith(n)}return t.type===a})}function Pe(t){if(t===0)return"0 Bytes";const r=1024,s=["Bytes","KB","MB","GB"],a=Math.floor(Math.log(t)/Math.log(r));return Math.round(t/Math.pow(r,a)*100)/100+" "+s[a]}function pr(t){return t}function te(...t){return t.filter(Boolean).join(" ")}const Ee={APPLICANT_ID:"metakyc_applicant_id",WORKFLOW_STATE:"metakyc_workflow_state"};function Dt(t){try{localStorage.setItem(Ee.APPLICANT_ID,t.toString())}catch(r){console.warn("Failed to save applicant ID to storage:",r)}}function Ft(){try{const t=localStorage.getItem(Ee.APPLICANT_ID);return t?parseInt(t,10):null}catch(t){return console.warn("Failed to retrieve applicant ID from storage:",t),null}}function Pt(){try{localStorage.removeItem(Ee.APPLICANT_ID)}catch(t){console.warn("Failed to clear applicant ID from storage:",t)}}function Lt(t){try{localStorage.setItem(Ee.WORKFLOW_STATE,JSON.stringify(t))}catch(r){console.warn("Failed to save workflow state to storage:",r)}}function hr(){try{const t=localStorage.getItem(Ee.WORKFLOW_STATE);return t?JSON.parse(t):null}catch(t){return console.warn("Failed to retrieve workflow state from storage:",t),null}}function Tt(){try{localStorage.removeItem(Ee.WORKFLOW_STATE)}catch(t){console.warn("Failed to clear workflow state from storage:",t)}}function gr(){Pt(),Tt()}function Mt(t){const{createOrchestrator:r}=de(),[s,a]=l.useState(null),[n,i]=l.useState(!1),[o,c]=l.useState(null),d=l.useRef(null),m=t||Ft();l.useEffect(()=>{d.current||(d.current=r())},[r]),l.useEffect(()=>{var N;s&&m&&(Dt(m),Lt({applicantId:m,currentStepOrder:(N=s.currentStep)==null?void 0:N.order,status:s.status,lastUpdated:new Date().toISOString(),workflowKey:s.workFlowKey,nextWorkflowKey:s.nextWorkflowKey}))},[s,m]);const v=l.useRef(!1),w=l.useRef(!1),x=l.useCallback(async()=>{if(!(!m||!d.current)){if(v.current){console.log("[Workflow] Load already in progress, skipping...");return}v.current=!0,i(!0),c(null);try{const N=await d.current.initialize(m);a(N),w.current=!0}catch(N){c(N)}finally{i(!1),v.current=!1}}},[m]);l.useEffect(()=>{m&&!w.current&&x()},[m,x]);const h=l.useCallback(async()=>{if(d.current){if(v.current){console.log("[Workflow] Refresh already in progress, skipping...");return}v.current=!0,i(!0),c(null);try{const N=await d.current.refreshProgress();a(N)}catch(N){c(N)}finally{i(!1),v.current=!1}}},[]),g=l.useCallback(async()=>{if(d.current){i(!0),c(null);try{const N=await d.current.moveToNextStep();a(N)}catch(N){c(N)}finally{i(!1)}}},[]),k=l.useCallback(async()=>{if(d.current){i(!0),c(null);try{const N=await d.current.moveToPreviousStep();a(N)}catch(N){c(N)}finally{i(!1)}}},[]),f=l.useCallback(async N=>{if(d.current){i(!0),c(null);try{await d.current.submitCurrentStep(N);const b=await d.current.refreshProgress();a(b)}catch(b){throw c(b),b}finally{i(!1)}}},[]),p=Ke.useMemo(()=>s!=null&&s.stepInfoList?[...s.stepInfoList].sort((N,b)=>N.order-b.order):[],[s==null?void 0:s.stepInfoList]),R=Ke.useMemo(()=>s?s.nextWorkflowKey&&s.nextWorkflowKey!==s.workFlowKey:!1,[s]);return{progress:s,applicantId:m,currentStep:(s==null?void 0:s.currentStep)||null,steps:p,status:(s==null?void 0:s.status)||me.None,workflowResult:(s==null?void 0:s.workflowResult)||null,workflowKey:s==null?void 0:s.workFlowKey,nextWorkflowKey:s==null?void 0:s.nextWorkflowKey,hasWorkflowChanged:R,isLoading:n,error:o,isComplete:(s==null?void 0:s.status)===me.Finished,isOnHold:(s==null?void 0:s.status)===me.OnHold,refreshProgress:h,moveToNext:g,moveBack:k,submitCurrentStep:f,orchestrator:d.current}}function Ot(t){const{questionnaireService:r,applicantService:s}=de(),[a,n]=l.useState(null),[i,o]=l.useState({}),[c,d]=l.useState(!1),[m,v]=l.useState(!1),[w,x]=l.useState(null),h=l.useRef(!1),g=l.useRef(null),k=l.useCallback(async()=>{var p,R;if(t){if(h.current){console.log("[Questionnaire] Load already in progress, skipping...");return}h.current=!0,d(!0),x(null);try{const[N,b]=await Promise.all([r.getQuestionnaire(t),s.getApplicantData(t).catch(()=>null)]);if(n(N),(p=b==null?void 0:b.questionnaireResults)!=null&&p.length&&N){const _=new Map;for(const y of b.questionnaireResults)y.question&&((R=y.answers)!=null&&R.length)&&_.set(y.question.trim().toLowerCase(),y.answers);const W={},P=N.questionGroups.flatMap(y=>y.questions??[]);for(const y of P){const S=y.text.trim().toLowerCase();_.has(S)&&(W[y.id]=_.get(S))}o(W)}g.current=t}catch(N){x(N)}finally{d(!1),h.current=!1}}},[t,r,s]);l.useEffect(()=>{t&&g.current!==t&&k()},[t]);const f=l.useCallback(async p=>{v(!0),x(null);try{return await r.fillQuestionnaire(p)}catch(R){throw x(R),R}finally{v(!1)}},[r]);return{questionnaire:a,initialAnswers:i,isLoading:c,isSubmitting:m,error:w,load:k,submit:f}}function zt(t){const{uploadDocumentService:r}=de(),[s,a]=l.useState(null),[n,i]=l.useState(!1),[o,c]=l.useState(!1),[d,m]=l.useState(0),[v,w]=l.useState(null),x=l.useRef(!1),h=l.useRef(null),g=l.useCallback(async()=>{if(t){if(x.current){console.log("[UploadDocument] Load already in progress, skipping...");return}x.current=!0,i(!0),w(null);try{const f=await r.getUploadDocument(t);a(f),h.current=t}catch(f){w(f)}finally{i(!1),x.current=!1}}},[t,r]);l.useEffect(()=>{t&&h.current!==t&&g()},[t]);const k=l.useCallback(async f=>{c(!0),m(0),w(null);try{await r.fillUploadDocument(f),m(100)}catch(p){throw w(p),p}finally{c(!1)}},[r]);return{uploadDocument:s,isLoading:n,isSubmitting:o,uploadProgress:d,error:v,load:g,submit:k}}function xr(t){const{appropriatenessTestService:r}=de(),[s,a]=l.useState(null),[n,i]=l.useState(!1),[o,c]=l.useState(!1),[d,m]=l.useState(null),[v,w]=l.useState(null),x=l.useRef(!1),h=l.useRef(null),g=l.useCallback(async()=>{if(t){if(x.current){console.log("[AppropriatenessTest] Load already in progress, skipping...");return}x.current=!0,i(!0),m(null);try{const f=await r.getAppropriatenessTest(t);a(f),h.current=t}catch(f){m(f)}finally{i(!1),x.current=!1}}},[t,r]);l.useEffect(()=>{t&&h.current!==t&&g()},[t]);const k=l.useCallback(async f=>{c(!0),m(null);try{const p=await r.fillAppropriatenessTest(f);return w(p),p}catch(p){throw m(p),p}finally{c(!1)}},[r]);return{test:s,result:v,isLoading:n,isSubmitting:o,error:d,load:g,submit:k}}function Bt(t){const{overviewService:r}=de(),[s,a]=l.useState(null),[n,i]=l.useState(!1),[o,c]=l.useState(!1),[d,m]=l.useState(null),v=l.useRef(!1),w=l.useRef(null),x=l.useCallback(async()=>{if(t){if(v.current){console.log("[Overview] Load already in progress, skipping...");return}v.current=!0,i(!0),m(null);try{const g=await r.getOverviewData(t);a(g),w.current=t}catch(g){m(g)}finally{i(!1),v.current=!1}}},[t,r]);l.useEffect(()=>{t&&w.current!==t&&x()},[t]);const h=l.useCallback(async()=>{if(t){c(!0),m(null);try{await r.passOverview(t)}catch(g){throw m(g),g}finally{c(!1)}}},[t,r]);return{overview:s,isLoading:n,isSubmitting:o,error:d,load:x,passOverview:h}}function $t(t){const{identityService:r}=de(),[s,a]=l.useState(null),[n,i]=l.useState(!1),[o,c]=l.useState(null),d=l.useRef(!1),m=l.useCallback(async(x,h)=>{if(t){if(d.current){console.log("[Identity] Request already in progress, skipping...");return}d.current=!0,i(!0),c(null);try{const g={applicantId:t,restart:!1,redirectUrl:x||"",ttl:h||604800};console.log("Identity request input:",g);const k=await r.identityRequest(g);return console.log("Identity request result:",k),a(k),k}catch(g){throw c(g),g}finally{i(!1),d.current=!1}}},[t,r]),v=l.useCallback(async(x,h)=>{if(t){i(!0),c(null);try{const g={applicantId:t,restart:!1,redirectUrl:x,ttl:h},k=await r.identityCompanyRequest(g);return a(k),k}catch(g){throw c(g),g}finally{i(!1)}}},[t,r]),w=l.useCallback(async()=>{if(t){if(d.current){console.log("[Identity] Restart already in progress, skipping...");return}d.current=!0,i(!0),c(null);try{const x={applicantId:t,restart:!0,redirectUrl:"",ttl:604800};console.log("Restarting identity with input:",x);const h=await r.identityRequest(x);return console.log("Restart identity result:",h),a(h),h}catch(x){throw c(x),x}finally{i(!1),d.current=!1}}},[t,r]);return{identityData:s,provider:(s==null?void 0:s.provider)||null,token:(s==null?void 0:s.publicProviderTokenObject)||null,isLoading:n,error:o,requestIdentity:m,requestCompanyIdentity:v,restartIdentity:w}}function Ut(t){const{riskScoringService:r,applicantService:s}=de(),[a,n]=l.useState(null),[i,o]=l.useState({}),[c,d]=l.useState(!1),[m,v]=l.useState(!1),[w,x]=l.useState(null),[h,g]=l.useState(null),k=l.useRef(!1),f=l.useRef(null),p=l.useCallback(async()=>{var N;if(t){if(k.current){console.log("[RiskScoring] Load already in progress, skipping...");return}k.current=!0,d(!0),x(null);try{const[b,_]=await Promise.all([r.getRiskCriterias(t),s.getApplicantData(t).catch(()=>null)]);if(n(b),(N=_==null?void 0:_.riskScoringResults)!=null&&N.length){const W=_.riskScoringResults[0],P={};for(const y of W.riskCriteriaResults??[])if(y.riskCriteriaId!=null&&y.answer!=null&&y.answer!==""){const S=[...new Set(y.answer.split(",").map(I=>I.trim()).filter(I=>I!==""))];S.length>0&&(P[y.riskCriteriaId]=S)}o(P)}f.current=t}catch(b){x(b)}finally{d(!1),k.current=!1}}},[t,r,s]);l.useEffect(()=>{t&&f.current!==t&&p()},[t]);const R=l.useCallback(async N=>{v(!0),x(null);try{const b=await r.submitRiskScoring(N);return g(b),b}catch(b){throw x(b),b}finally{v(!1)}},[r]);return{criteria:a,initialAnswers:i,result:h,isLoading:c,isSubmitting:m,error:w,load:p,submit:R}}function _t(){const{applicantService:t,config:r}=de(),[s,a]=l.useState(!1),[n,i]=l.useState(null),o=l.useRef(!1),c=l.useRef(!1),d=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(h){const g=Math.random()*16|0;return(h==="x"?g:g&3|8).toString(16)}),m=l.useCallback(async h=>{var g;if(o.current)throw console.log("[Applicant] Create already in progress, skipping..."),new Error("Creation already in progress");o.current=!0,a(!0),i(null);try{if(h.applicantAdditionalDatas||(h.applicantAdditionalDatas=[]),(g=r.identityProviders)!=null&&g.sardinai){const f=d();console.log("[SardinAI] Generated session key:",f),h.applicantAdditionalDatas.push({paramName:"sessionKey",value:f})}return await t.createApplicant(h)}catch(k){throw i(k),k}finally{a(!1),o.current=!1}},[t,r]),v=l.useCallback(async h=>{a(!0),i(null);try{return await t.createCompanyApplicant(h)}catch(g){throw i(g),g}finally{a(!1)}},[t]),w=l.useCallback(async h=>{if(c.current)throw console.log("[Applicant] Data load already in progress, skipping..."),new Error("Data load already in progress");c.current=!0,a(!0),i(null);try{return await t.getApplicantData(h)}catch(g){throw i(g),g}finally{a(!1),c.current=!1}},[t]),x=l.useCallback(async h=>{a(!0),i(null);try{await t.stopProgress(h)}catch(g){throw i(g),g}finally{a(!1)}},[t]);return{isLoading:s,error:n,createApplicant:m,createCompanyApplicant:v,getApplicantData:w,stopProgress:x}}const B=({children:t,variant:r="primary",size:s="md",isLoading:a=!1,disabled:n,className:i,...o})=>{const c="inline-flex items-center justify-center rounded-lg font-medium transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 disabled:opacity-50 disabled:cursor-not-allowed",d={primary:"bg-primary-500 text-white hover:bg-primary-600 focus:ring-primary-500",secondary:"bg-gray-200 text-gray-900 hover:bg-gray-300 focus:ring-gray-400",outline:"border-2 border-primary-500 text-primary-500 hover:bg-primary-50 focus:ring-primary-500",danger:"bg-danger-500 text-white hover:bg-danger-600 focus:ring-danger-500",ghost:"text-gray-700 hover:bg-gray-100 focus:ring-gray-400"},m={sm:"px-3 py-1.5 text-sm",md:"px-4 py-2 text-base",lg:"px-6 py-3 text-lg"};return e.jsxs("button",{className:te(c,d[r],m[s],i),disabled:n||a,...o,children:[a&&e.jsxs("svg",{className:"animate-spin -ml-1 mr-2 h-4 w-4",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),t]})},ie=l.forwardRef(({label:t,error:r,helperText:s,leftIcon:a,rightIcon:n,className:i,...o},c)=>e.jsxs("div",{className:"w-full",children:[t&&e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:[t,o.required&&e.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),e.jsxs("div",{className:"relative",children:[a&&e.jsx("div",{className:"absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none",children:a}),e.jsx("input",{ref:c,className:te("block w-full rounded-lg border px-3 py-2 text-sm transition-colors","focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent","disabled:bg-gray-100 disabled:cursor-not-allowed",r?"border-danger-500 focus:ring-danger-500":"border-gray-300 dark:border-gray-600","dark:bg-gray-800 dark:text-white",a?"pl-10":"",n?"pr-10":"",i),...o}),n&&e.jsx("div",{className:"absolute inset-y-0 right-0 pr-3 flex items-center pointer-events-none",children:n})]}),r&&e.jsx("p",{className:"mt-1 text-sm text-danger-500",children:r}),!r&&s&&e.jsx("p",{className:"mt-1 text-sm text-gray-500",children:s})]}));ie.displayName="Input";const T=({children:t,className:r,...s})=>e.jsx("div",{className:te("metakyc-card rounded-xl shadow-sm border",r),style:{backgroundColor:"var(--metakyc-surface, #ffffff)",borderColor:"var(--metakyc-border, #e5e7eb)"},...s,children:t}),se=({children:t,className:r,...s})=>e.jsx("div",{className:te("px-6 py-4 border-b",r),style:{borderColor:"var(--metakyc-border, #e5e7eb)"},...s,children:t}),M=({children:t,className:r,...s})=>e.jsx("div",{className:te("px-6 py-4",r),...s,children:t}),le=({children:t,className:r,...s})=>e.jsx("div",{className:te("px-6 py-4 border-t",r),style:{borderColor:"var(--metakyc-border, #e5e7eb)"},...s,children:t}),ye=({children:t,variant:r="default",className:s,...a})=>{const n={default:"bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300",success:"bg-success-100 text-success-800 dark:bg-success-900 dark:text-success-300",danger:"bg-danger-100 text-danger-800 dark:bg-danger-900 dark:text-danger-300",warning:"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300",info:"bg-primary-100 text-primary-800 dark:bg-primary-900 dark:text-primary-300"};return e.jsx("span",{className:te("inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium",n[r],s),...a,children:t})},pe=({size:t="md",className:r,...s})=>{const a={sm:"h-4 w-4",md:"h-8 w-8",lg:"h-12 w-12"};return e.jsx("div",{className:te("flex items-center justify-center",r),...s,children:e.jsxs("svg",{className:te("animate-spin text-primary-500",a[t]),xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]})})},be=l.forwardRef(({label:t,error:r,helperText:s,options:a,placeholder:n,className:i,...o},c)=>e.jsxs("div",{className:"w-full",children:[t&&e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:[t,o.required&&e.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),e.jsxs("select",{ref:c,className:te("block w-full rounded-lg border px-3 py-2 text-sm transition-colors","focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent","disabled:bg-gray-100 disabled:cursor-not-allowed",r?"border-danger-500 focus:ring-danger-500":"border-gray-300 dark:border-gray-600","dark:bg-gray-800 dark:text-white",i),...o,children:[n&&e.jsx("option",{value:"",disabled:!0,children:n},"__placeholder__"),a.map((d,m)=>e.jsx("option",{value:d.value,disabled:d.disabled,children:d.label},d.value||`option-${m}`))]}),r&&e.jsx("p",{className:"mt-1 text-sm text-danger-500",children:r}),!r&&s&&e.jsx("p",{className:"mt-1 text-sm text-gray-500",children:s})]}));be.displayName="Select";const Kt=({label:t,value:r,onChange:s,options:a,placeholder:n="Select...",disabled:i=!1,required:o=!1})=>{const[c,d]=l.useState(!1),[m,v]=l.useState(""),w=l.useRef(null);l.useEffect(()=>{const f=p=>{w.current&&!w.current.contains(p.target)&&(d(!1),v(""))};return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[]);const x=a.filter(f=>f.label.toLowerCase().includes(m.toLowerCase())),h=f=>{i||(r.includes(f)?s(r.filter(p=>p!==f)):s([...r,f]))},g=(f,p)=>{p.stopPropagation(),i||s(r.filter(R=>R!==f))},k=f=>{var p;return((p=a.find(R=>R.value===f))==null?void 0:p.label)||f};return e.jsxs("div",{className:"w-full metakyc-multiselect",ref:w,children:[t&&e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:[t,o&&e.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),e.jsxs("div",{className:"relative",children:[e.jsxs("div",{onClick:()=>!i&&d(!c),className:te("metakyc-multiselect-trigger","min-h-[42px] w-full px-3 py-2 rounded-lg border text-sm transition-colors","bg-white dark:bg-gray-800","border-gray-300 dark:border-gray-600",c&&"ring-2 ring-blue-500 border-transparent",i?"opacity-50 cursor-not-allowed":"cursor-pointer"),children:[r.length===0?e.jsx("span",{className:"metakyc-multiselect-placeholder text-gray-400 dark:text-gray-500 leading-6",children:n}):e.jsx("div",{className:"flex flex-wrap gap-1 pr-6",children:r.map(f=>e.jsxs("span",{className:"metakyc-multiselect-chip inline-flex items-center gap-1 px-2 py-0.5 rounded bg-blue-100 dark:bg-blue-900/40 text-blue-800 dark:text-blue-300 text-xs font-medium",children:[k(f),!i&&e.jsx("button",{type:"button",onClick:p=>g(f,p),className:"metakyc-multiselect-chip-remove",style:{background:"transparent",border:"none",padding:"0 0 0 2px",margin:0,cursor:"pointer",fontSize:"14px",lineHeight:1,fontWeight:"bold",display:"inline-flex",alignItems:"center",boxShadow:"none",transform:"none",minWidth:0,width:"auto",height:"auto",letterSpacing:"normal",textTransform:"none"},children:"×"})]},f))}),e.jsx("span",{className:"metakyc-multiselect-arrow absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none text-xs",children:c?"▲":"▼"})]}),c&&e.jsxs("div",{className:"metakyc-multiselect-dropdown absolute z-50 w-full mt-1 rounded-lg shadow-lg",style:{background:"inherit",border:"1px solid #d1d5db"},children:[e.jsx("div",{className:"metakyc-multiselect-search-wrapper p-2",style:{borderBottom:"1px solid #e5e7eb"},children:e.jsx("input",{type:"text",value:m,onChange:f=>v(f.target.value),placeholder:"Search...",autoFocus:!0,onClick:f=>f.stopPropagation(),className:"metakyc-multiselect-search w-full px-2 py-1.5 text-sm rounded focus:outline-none focus:ring-1 focus:ring-blue-500",style:{border:"1px solid #d1d5db"}})}),e.jsx("ul",{className:"max-h-48 overflow-y-auto py-1",children:x.length===0?e.jsx("li",{className:"px-3 py-2 text-sm text-gray-500 dark:text-gray-400",children:"No results"}):x.map(f=>e.jsxs("li",{onClick:()=>h(f.value),className:te("metakyc-multiselect-option","flex items-center gap-2 px-3 py-2 text-sm cursor-pointer","hover:bg-gray-50 dark:hover:bg-gray-700",r.includes(f.value)&&"metakyc-multiselect-option-selected bg-blue-50 dark:bg-blue-900/20"),children:[e.jsx("input",{type:"checkbox",checked:r.includes(f.value),readOnly:!0,className:"rounded border-gray-300 text-blue-600 pointer-events-none"}),e.jsx("span",{className:"text-gray-900 dark:text-gray-100",children:f.label})]},f.value))}),r.length>0&&e.jsx("div",{className:"metakyc-multiselect-clear p-2 border-t border-gray-100 dark:border-gray-700",children:e.jsxs("button",{type:"button",onClick:()=>{s([]),v("")},className:"text-xs text-red-500 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300",children:["Clear all (",r.length," selected)"]})})]})]})]})},qt=({label:t,error:r,accept:s,multiple:a=!1,maxSize:n,onChange:i,value:o=[],className:c})=>{const[d,m]=l.useState(!1),v=l.useRef(null),w=p=>{if(!p)return;const R=Array.from(p);if(n&&R.filter(b=>b.size>n).length>0){const b=Pe(n);alert(`Some files exceed the maximum size of ${b}`);return}i==null||i(a?[...o,...R]:[R[0]])},x=p=>{p.preventDefault(),m(!0)},h=()=>{m(!1)},g=p=>{p.preventDefault(),m(!1),w(p.dataTransfer.files)},k=()=>{var p;(p=v.current)==null||p.click()},f=p=>{const R=o.filter((N,b)=>b!==p);i==null||i(R)};return e.jsxs("div",{className:te("w-full",c),children:[t&&e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:t}),e.jsxs("div",{className:te("border-2 border-dashed rounded-lg p-6 text-center cursor-pointer transition-colors",d?"border-primary-500 bg-primary-50 dark:bg-primary-900/20":"border-gray-300 dark:border-gray-600 hover:border-primary-500",r&&"border-danger-500"),onDragOver:x,onDragLeave:h,onDrop:g,onClick:k,children:[e.jsx("input",{ref:v,type:"file",className:"hidden",accept:s,multiple:a,onChange:p=>w(p.target.files)}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("svg",{className:"mx-auto h-12 w-12 text-gray-400",stroke:"currentColor",fill:"none",viewBox:"0 0 48 48",children:e.jsx("path",{d:"M28 8H12a4 4 0 00-4 4v20m32-12v8m0 0v8a4 4 0 01-4 4H12a4 4 0 01-4-4v-4m32-4l-3.172-3.172a4 4 0 00-5.656 0L28 28M8 32l9.172-9.172a4 4 0 015.656 0L28 28m0 0l4 4m4-24h8m-4-4v8m-12 4h.02",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}),e.jsxs("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:[e.jsx("span",{className:"font-medium text-primary-500",children:"Click to upload"})," or drag and drop"]}),n&&e.jsxs("p",{className:"text-xs text-gray-500",children:["Maximum file size: ",Pe(n)]})]})]}),o.length>0&&e.jsx("div",{className:"mt-3 space-y-2",children:o.map((p,R)=>e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[e.jsxs("div",{className:"flex items-center space-x-2 flex-1 min-w-0",children:[e.jsx("svg",{className:"h-5 w-5 text-gray-400 flex-shrink-0",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M4 4a2 2 0 012-2h4.586A2 2 0 0112 2.586L15.414 6A2 2 0 0116 7.414V16a2 2 0 01-2 2H6a2 2 0 01-2-2V4z",clipRule:"evenodd"})}),e.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300 truncate",children:p.name}),e.jsxs("span",{className:"text-xs text-gray-500",children:["(",Pe(p.size),")"]})]}),e.jsx("button",{type:"button",onClick:N=>{N.stopPropagation(),f(R)},className:"ml-2 text-danger-500 hover:text-danger-700 focus:outline-none",children:e.jsx("svg",{className:"h-5 w-5",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})})]},R))}),r&&e.jsx("p",{className:"mt-1 text-sm text-danger-500",children:r})]})},Ht=l.forwardRef(({countryCode:t="+1",onCountryCodeChange:r,className:s,...a},n)=>e.jsxs("div",{className:"w-full",children:[a.label&&e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:[a.label,a.required&&e.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:t,onChange:i=>r==null?void 0:r(i.target.value),className:te("w-20 rounded-lg border px-3 py-2 text-sm","focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent","border-gray-300 dark:border-gray-600 dark:bg-gray-800 dark:text-white"),placeholder:"+1"}),e.jsx(ie,{ref:n,type:"tel",className:te("flex-1",s),...a,label:""})]}),a.error&&e.jsx("p",{className:"mt-1 text-sm text-danger-500",children:a.error})]}));Ht.displayName="PhoneInput";/**
|
|
1
|
+
"use strict";var ar=Object.defineProperty;var nr=(t,r,s)=>r in t?ar(t,r,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[r]=s;var Q=(t,r,s)=>nr(t,typeof r!="symbol"?r+"":r,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ir=require("axios"),l=require("react"),e=require("react/jsx-runtime"),ke=require("react-hook-form"),ve=require("zod");function lr(t){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const s in t)if(s!=="default"){const a=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(r,s,a.get?a:{enumerable:!0,get:()=>t[s]})}}return r.default=t,Object.freeze(r)}const Ke=lr(l);var z=(t=>(t[t.IdentitySdk=0]="IdentitySdk",t[t.RiskScoring=1]="RiskScoring",t[t.Questionaries=2]="Questionaries",t[t.AdditionalData=3]="AdditionalData",t[t.AppropriatenessTest=4]="AppropriatenessTest",t[t.UploadDocument=5]="UploadDocument",t[t.ManualReview=6]="ManualReview",t[t.Overview=7]="Overview",t[t.InvestorCategorization=8]="InvestorCategorization",t))(z||{}),Re=(t=>(t[t.NotStarted=0]="NotStarted",t[t.InProgress=1]="InProgress",t[t.Success=2]="Success",t[t.PartialSuccess=3]="PartialSuccess",t[t.Failed=4]="Failed",t[t.Skipped=5]="Skipped",t[t.AdminReview=6]="AdminReview",t[t.SkippedAndAdminReview=7]="SkippedAndAdminReview",t))(Re||{}),me=(t=>(t[t.None=0]="None",t[t.InProgress=1]="InProgress",t[t.Finished=2]="Finished",t[t.OnHold=3]="OnHold",t[t.IdentityPending=4]="IdentityPending",t))(me||{}),He=(t=>(t[t.None=0]="None",t[t.RepresentativeKYC=1]="RepresentativeKYC",t[t.ManualRiskCriteria=2]="ManualRiskCriteria",t[t.UploadDocumentReview=3]="UploadDocumentReview",t[t.AdminReview=4]="AdminReview",t))(He||{}),We=(t=>(t[t.LowRisk=0]="LowRisk",t[t.MediumRisk=1]="MediumRisk",t[t.HighRisk=2]="HighRisk",t[t.Alert=3]="Alert",t))(We||{}),we=(t=>(t[t.None=0]="None",t[t.Pending=1]="Pending",t[t.Approved=2]="Approved",t[t.Rejected=3]="Rejected",t[t.ResendRequested=4]="ResendRequested",t[t.Unknown=5]="Unknown",t[t.InProgress=6]="InProgress",t))(we||{}),je=(t=>(t[t.Approved=0]="Approved",t[t.Reject=1]="Reject",t[t.UnderReview=2]="UnderReview",t[t.Closed=3]="Closed",t[t.AdminReview=4]="AdminReview",t[t.New=5]="New",t[t.InProgress=6]="InProgress",t))(je||{}),Ye=(t=>(t[t.ProviderResultPending=0]="ProviderResultPending",t[t.ProviderResultReceived=1]="ProviderResultReceived",t[t.Canceled=2]="Canceled",t[t.ExtendedToNewApplicant=3]="ExtendedToNewApplicant",t))(Ye||{}),Qe=(t=>(t[t.None=0]="None",t[t.ProviderResultPending=1]="ProviderResultPending",t[t.ProviderResultReceived=2]="ProviderResultReceived",t[t.Canceled=3]="Canceled",t))(Qe||{}),ue=(t=>(t[t.Onfido=0]="Onfido",t[t.Sumsub=2]="Sumsub",t[t.SardinAI=3]="SardinAI",t))(ue||{}),Ve=(t=>(t[t.Individual=0]="Individual",t[t.Company=1]="Company",t))(Ve||{}),Ie=(t=>(t[t.Male=0]="Male",t[t.Female=1]="Female",t[t.Other=2]="Other",t))(Ie||{}),Ge=(t=>(t[t.Image=0]="Image",t[t.Video=1]="Video",t[t.PDF=2]="PDF",t[t.OfficePDF=3]="OfficePDF",t[t.Custom=4]="Custom",t))(Ge||{}),Ze=(t=>(t[t.Pending=0]="Pending",t[t.Approved=1]="Approved",t[t.Rejected=2]="Rejected",t[t.RequiresRevision=3]="RequiresRevision",t))(Ze||{}),Je=(t=>(t[t.SingleChoice=0]="SingleChoice",t[t.MultipleChoice=1]="MultipleChoice",t[t.Text=2]="Text",t))(Je||{}),fe=(t=>(t[t.String=0]="String",t[t.Integer=1]="Integer",t[t.Decimal=2]="Decimal",t[t.Boolean=3]="Boolean",t[t.Date=4]="Date",t[t.Country=5]="Country",t[t.DigitOnly=6]="DigitOnly",t))(fe||{}),Xe=(t=>(t[t.Text=0]="Text",t[t.Radio=1]="Radio",t[t.Checkbox=2]="Checkbox",t[t.Dropdown=3]="Dropdown",t[t.Country=4]="Country",t))(Xe||{}),et=(t=>(t[t.None=0]="None",t[t.Country=1]="Country",t))(et||{}),ce=(t=>(t[t.Individual=0]="Individual",t[t.Sophisticated=1]="Sophisticated",t[t.HighNetWorth=2]="HighNetWorth",t[t.Business=3]="Business",t))(ce||{}),tt=(t=>(t[t.Retail=0]="Retail",t[t.Professional=1]="Professional",t[t.EligibleCounterparty=2]="EligibleCounterparty",t))(tt||{});const Fe={firstName:{label:"First Name",type:"text"},lastName:{label:"Last Name",type:"text"},email:{label:"Email",type:"email"},phonenumber:{label:"Phone Number",type:"tel"},dateOfBirth:{label:"Date of Birth",type:"date"},salutation:{label:"Salutation",type:"select"},title:{label:"Title",type:"text"},mobileCountryCode:{label:"Mobile Country Code",type:"text"},street:{label:"Street",type:"text"},streetNumber:{label:"Street Number",type:"text"},zip:{label:"ZIP / Postal Code",type:"text"},city:{label:"City",type:"text"},country:{label:"Country",type:"select"},nationality:{label:"Nationality",type:"select"},otherNationality:{label:"Other Nationalities",type:"multiselect"},countryOfBirth:{label:"Country of Birth",type:"select"},placeOfBirth:{label:"Place of Birth",type:"text"},taxCountry:{label:"Tax Country",type:"select"},taxNumber:{label:"Tax Number",type:"text"},defaultLanguage:{label:"Default Language",type:"select"},educationLevel:{label:"Education Level",type:"text"},occupation:{label:"Occupation",type:"text"}},rt=["firstName","lastName","email","phonenumber","dateOfBirth"],ze=[{value:"EN",label:"English"},{value:"DE",label:"German"},{value:"FR",label:"French"},{value:"ES",label:"Spanish"},{value:"IT",label:"Italian"},{value:"PT",label:"Portuguese"},{value:"NL",label:"Dutch"},{value:"PL",label:"Polish"},{value:"RU",label:"Russian"},{value:"ZH",label:"Chinese"},{value:"JA",label:"Japanese"},{value:"AR",label:"Arabic"},{value:"TR",label:"Turkish"},{value:"SV",label:"Swedish"},{value:"DA",label:"Danish"},{value:"FI",label:"Finnish"},{value:"NO",label:"Norwegian"}];var ee=(t=>(t.Default="default",t.Corporate="corporate",t.Fintech="fintech",t.Healthcare="healthcare",t.Modern="modern",t.Minimal="minimal",t))(ee||{});const st={timeout:3e4,retries:3,locale:"en",endpoints:{pattern:"host-controller"}};class at{constructor(r){this.config=r}build(r,s){const a=`${r}.${s}`;if(this.config.customPaths&&this.config.customPaths[a])return this.config.customPaths[a];switch(this.config.pattern){case"host-controller":return`/api/${r}/${s}`;case"application-service":return`/services/app/${this.getServiceName(r)}/${s}`;case"custom":throw new Error(`Custom endpoint path not found for ${a}. Please provide it in customPaths.`);default:throw new Error(`Unknown endpoint pattern: ${this.config.pattern}`)}}getServiceName(r){return{Applicant:"MetaKYCVerification",Questionnaire:"MetaKYCVerification",UploadDocument:"MetaKYCVerification",AppropriatenessTest:"MetaKYCVerification",BaseInformation:"MetaKYCVerification"}[r]||r}}class xe extends Error{constructor(s,a,n,i,o){super(s);Q(this,"response");this.code=a,this.details=n,this.validationErrors=i,this.name="MetaKYCError",this.response=o,Object.setPrototypeOf(this,xe.prototype)}}class Ce{static handleApiError(r){return new xe(r.message||"An unknown error occurred",r.code,r.details||void 0,r.validationErrors||void 0)}static handleAxiosError(r){if(r.response){const s=r.response.data;return s&&s.error?new xe(s.error.message||"An unknown error occurred",s.error.code,s.error.details||void 0,s.error.validationErrors||void 0,r.response):s&&s.result&&s.result.message?new xe(s.result.message,r.response.status,`HTTP ${r.response.status}: ${r.response.statusText}`,void 0,r.response):new xe((s==null?void 0:s.message)||r.message||"Request failed",r.response.status,`HTTP ${r.response.status}: ${r.response.statusText}`,void 0,r.response)}else return r.request?new xe("No response from server",0,"The request was made but no response was received. Please check your network connection."):new xe(r.message||"An unexpected error occurred",0,r.toString())}static isMetaKYCError(r){return r instanceof xe}}class nt{constructor(r){Q(this,"axiosInstance");Q(this,"endpointBuilder");Q(this,"config");this.config={...st,...r},this.endpointBuilder=new at(this.config.endpoints),this.axiosInstance=ir.create({baseURL:this.config.baseUrl,timeout:this.config.timeout,headers:{"Content-Type":"application/json"}}),this.axiosInstance.interceptors.request.use(s=>(s.headers["Abp-TenantId"]=this.config.tenantId.toString(),s.headers.ApiKey=this.config.apiKey,s.headers["X-API-KEY"]=this.config.apiKey,this.config.locale&&(s.headers["Accept-Language"]=this.config.locale),s),s=>Promise.reject(s)),this.axiosInstance.interceptors.response.use(s=>s,async s=>{var n;const a=s.config;return((n=s.response)==null?void 0:n.status)>=500&&!a._retry&&(a._retry=!0,a._retryCount=(a._retryCount||0)+1,a._retryCount<(this.config.retries||3))?(await new Promise(i=>setTimeout(i,1e3*a._retryCount)),this.axiosInstance(a)):Promise.reject(s)})}buildEndpoint(r,s){return this.endpointBuilder.build(r,s)}async get(r,s,a){try{const n=this.buildEndpoint(r,s),i=await this.axiosInstance.get(n,{params:a});return this.handleResponse(i)}catch(n){throw Ce.handleAxiosError(n)}}async post(r,s,a){try{const n=this.buildEndpoint(r,s),i=await this.axiosInstance.post(n,a);return this.handleResponse(i)}catch(n){throw Ce.handleAxiosError(n)}}async put(r,s,a){try{const n=this.buildEndpoint(r,s),i=await this.axiosInstance.put(n,a);return this.handleResponse(i)}catch(n){throw Ce.handleAxiosError(n)}}async delete(r,s,a){try{const n=this.buildEndpoint(r,s),i=await this.axiosInstance.delete(n,{params:a});return this.handleResponse(i)}catch(n){throw Ce.handleAxiosError(n)}}handleResponse(r){const s=r.data;if(!s.success&&s.error)throw Ce.handleApiError(s.error);return s}getAxiosInstance(){return this.axiosInstance}}class it{constructor(r){this.httpClient=r}async createApplicant(r){return(await this.httpClient.post("Applicant","ApplicantRegistrationRequest",r)).result}async createCompanyApplicant(r){return(await this.httpClient.post("Applicant","ApplicantCompanyRegistrationRequest",r)).result}async duplicateApplicant(r){return(await this.httpClient.post("Applicant","DuplicateApplicantRegistrationRequest",r)).result}async getProgress(r){return(await this.httpClient.get("Applicant","GetApplicantProgress",{applicantId:r})).result}async getProgressStatus(r){return(await this.httpClient.get("Applicant","GetApplicantProgressStaus",{applicantId:r})).result}async getApplicantData(r){return(await this.httpClient.get("Applicant","GetApplicantData",{applicantId:r})).result}async getApplicantStatus(r){return(await this.httpClient.get("Applicant","GetApplicantStatus",{applicantId:r})).result}async stopProgress(r){await this.httpClient.get("Applicant","StopProgress",{applicantId:r})}async progressStepBack(r){await this.httpClient.get("Applicant","ProgressStepBack",{applicantId:r})}async setLanguage(r,s){await this.httpClient.post("Applicant","SetApplicantLng",{applicantId:r,language:s})}async activateApplicant(r){await this.httpClient.get("Applicant","ActivateApplicant",{applicantId:r})}async deleteApplicant(r){await this.httpClient.delete("Applicant","DeleteApplicant",{applicantId:r})}async checkApplicantExists(r){return(await this.httpClient.get("Applicant","CheckApplicantIfExists",{externalRefId:r})).result}}class lt{constructor(r){this.httpClient=r}async getQuestionnaire(r){return(await this.httpClient.get("Questionnaire","GetQuestionnaire",{applicantid:r})).result}async fillQuestionnaire(r){return(await this.httpClient.post("Applicant","FillQuestionnarie",r)).result}}class ot{constructor(r){this.httpClient=r}async getUploadDocument(r){return(await this.httpClient.get("UploadDocument","GetUploadDocument",{applicantid:r})).result}async fillUploadDocument(r){await this.httpClient.post("Applicant","FillUploadDocument",r)}async reviewUploadDocument(r){await this.httpClient.post("UploadDocument","ReviewUploadDocument",r)}}class ct{constructor(r){this.httpClient=r}async getAppropriatenessTest(r){return(await this.httpClient.get("AppropriatenessTest","GetAppropriatenessTest",{applicantid:r})).result}async fillAppropriatenessTest(r){return(await this.httpClient.post("Applicant","FillAppropriatenessTest",r)).result}}class dt{constructor(r){this.httpClient=r}async getOverviewData(r){return(await this.httpClient.get("Applicant","GetOverviewData",{ApplicantId:r})).result}async passOverview(r){await this.httpClient.get("Applicant","PassOverview",{applicantId:r})}}class ut{constructor(r){this.httpClient=r}async getRiskScoringPlan(){return(await this.httpClient.get("Applicant","GetRiskScoringPlanInfo")).result}async getRiskCriterias(r){return(await this.httpClient.get("Risk","GetCriterias",{applicantId:r})).result}async submitRiskScoring(r){return(await this.httpClient.post("Applicant","RiskScoringRequest",r)).result}}class mt{constructor(r){this.httpClient=r}async identityRequest(r){console.log("[IdentityService] Calling IdentityRequest with input:",r);const s=await this.httpClient.post("Applicant","IdentityRequest",r);return console.log("[IdentityService] IdentityRequest response:",s),s.result}async identityCompanyRequest(r){return(await this.httpClient.post("Applicant","IdentityCompanyRequest",r)).result}async restartIdentityRequest(r){const s={applicantId:r,restart:!0,redirectUrl:"",ttl:604800};return console.log("[IdentityService] Restarting identity with restart=true:",s),this.identityRequest(s)}async restartIdentityCompanyRequest(r){const s={applicantId:r,restart:!0,redirectUrl:"",ttl:604800};return this.identityCompanyRequest(s)}}class pt{constructor(r){this.httpClient=r}async getCountries(r,s,a){return(await this.httpClient.get("BaseInformation","GetAllCountries",{filter:r||"",lng:s||"en",type:a})).result}async getBranches(){return(await this.httpClient.get("BaseInformation","GetBranches")).result}async getLegalEntities(){return(await this.httpClient.get("BaseInformation","GetLegalEntities")).result}}class ht{constructor(r){this.httpClient=r}async setInvestorCategorization(r){return(await this.httpClient.post("Applicant","SetInvestorCategorization",r)).result}async getInvestorCategorization(r){return(await this.httpClient.get("Applicant","GetInvestorCategorisation",{applicantId:r})).result}}const ne={name:"Default",title:"KYC Verification",logo:{url:"",height:"40px",visible:!0},colors:{primary:"#2563eb",primaryHover:"#1d4ed8",primaryLight:"#dbeafe",primaryDark:"#1e40af",secondary:"#64748b",secondaryHover:"#475569",success:"#10b981",warning:"#f59e0b",danger:"#ef4444",info:"#3b82f6",background:"#ffffff",surface:"#f9fafb",border:"#e5e7eb",textPrimary:"#111827",textSecondary:"#6b7280",textMuted:"#9ca3af"},typography:{fontFamily:"Inter, system-ui, -apple-system, sans-serif",fontSize:{xs:"0.75rem",sm:"0.875rem",base:"1rem",lg:"1.125rem",xl:"1.25rem","2xl":"1.5rem","3xl":"1.875rem"},fontWeight:{normal:400,medium:500,semibold:600,bold:700}},spacing:{borderRadius:"0.5rem",cardPadding:"1.5rem",inputHeight:"2.5rem"},darkMode:{colors:{background:"#111827",surface:"#1f2937",border:"#374151",textPrimary:"#f9fafb",textSecondary:"#d1d5db",textMuted:"#9ca3af"}}},gt={name:"Corporate",logo:{url:"",height:"40px",visible:!0},colors:{primary:"#0052CC",primaryHover:"#0747A6",primaryLight:"#DEEBFF",primaryDark:"#0747A6",secondary:"#6B778C",secondaryHover:"#5E6C84",success:"#00875A",warning:"#FF991F",danger:"#DE350B",info:"#0065FF",background:"#ffffff",surface:"#F4F5F7",border:"#DFE1E6",textPrimary:"#172B4D",textSecondary:"#5E6C84",textMuted:"#97A0AF"},typography:{fontFamily:"system-ui, -apple-system, sans-serif"},spacing:{borderRadius:"0.25rem",cardPadding:"1.5rem",inputHeight:"2.5rem"}},xt={name:"Fintech",logo:{url:"",height:"36px",visible:!0},colors:{primary:"#00B386",primaryHover:"#009973",primaryLight:"#D1FAE5",primaryDark:"#047857",secondary:"#7C3AED",secondaryHover:"#6D28D9",success:"#10B981",warning:"#F59E0B",danger:"#EF4444",info:"#3B82F6",background:"#ffffff",surface:"#F9FAFB",border:"#E5E7EB",textPrimary:"#111827",textSecondary:"#6B7280",textMuted:"#9CA3AF"},typography:{fontFamily:"Montserrat, system-ui, sans-serif"},spacing:{borderRadius:"0.75rem",cardPadding:"2rem",inputHeight:"3rem"}},yt={name:"Healthcare",logo:{url:"",height:"44px",visible:!0},colors:{primary:"#06B6D4",primaryHover:"#0891B2",primaryLight:"#CFFAFE",primaryDark:"#0E7490",secondary:"#8B5CF6",secondaryHover:"#7C3AED",success:"#059669",warning:"#D97706",danger:"#DC2626",info:"#0284C7",background:"#ffffff",surface:"#F0F9FF",border:"#E0F2FE",textPrimary:"#0F172A",textSecondary:"#475569",textMuted:"#94A3B8"},typography:{fontFamily:"Lato, system-ui, sans-serif"},spacing:{borderRadius:"0.5rem",cardPadding:"1.75rem",inputHeight:"2.75rem"},darkMode:{colors:{background:"#0F172A",surface:"#1E293B",border:"#334155",textPrimary:"#F1F5F9",textSecondary:"#CBD5E1"}}},ft={name:"Modern",logo:{url:"",height:"38px",visible:!0},colors:{primary:"#8B5CF6",primaryHover:"#7C3AED",primaryLight:"#EDE9FE",primaryDark:"#6D28D9",secondary:"#EC4899",secondaryHover:"#DB2777",success:"#10B981",warning:"#F59E0B",danger:"#EF4444",info:"#3B82F6",background:"#ffffff",surface:"#FAFAFA",border:"#E5E5E5",textPrimary:"#171717",textSecondary:"#737373",textMuted:"#A3A3A3"},typography:{fontFamily:"Poppins, system-ui, sans-serif"},spacing:{borderRadius:"1rem",cardPadding:"2rem",inputHeight:"3rem"}},bt={name:"Minimal",logo:{url:"",height:"32px",visible:!0},colors:{primary:"#000000",primaryHover:"#18181B",primaryLight:"#F4F4F5",primaryDark:"#000000",secondary:"#71717A",secondaryHover:"#52525B",success:"#22C55E",warning:"#EAB308",danger:"#EF4444",info:"#3B82F6",background:"#ffffff",surface:"#FAFAFA",border:"#E4E4E7",textPrimary:"#09090B",textSecondary:"#71717A",textMuted:"#A1A1AA"},typography:{fontFamily:"system-ui, -apple-system, sans-serif"},spacing:{borderRadius:"0.25rem",cardPadding:"1.25rem",inputHeight:"2.25rem"}},vt={[ee.Default]:ne,[ee.Corporate]:gt,[ee.Fintech]:xt,[ee.Healthcare]:yt,[ee.Modern]:ft,[ee.Minimal]:bt};function Ae(t){return vt[t]||ne}class kt{constructor(r){this.httpClient=r}async getThemeConfiguration(){var r;try{const s=await this.httpClient.get("Tenant","GetThemeConfiguration");if(!s.result.isEnabled)return Ae(ee.Default);let a=s.result.preset?Ae(s.result.preset):Ae(ee.Default);if(s.result.title&&(a.title=s.result.title),s.result.logo&&(a.logo={...a.logo,...s.result.logo}),s.result.colors&&(a.colors={...a.colors,...s.result.colors}),s.result.typography&&(a.typography={...a.typography,...s.result.typography}),s.result.spacing&&(a.spacing={...a.spacing,...s.result.spacing}),s.result.customCSS&&(a.customCSS=s.result.customCSS),s.result.darkMode&&(a.darkMode={colors:{...(r=a.darkMode)==null?void 0:r.colors,...s.result.darkMode.colors}}),s.result.applicantFormVisibleFields&&s.result.applicantFormVisibleFields.length>0&&(a.applicantFormVisibleFields=s.result.applicantFormVisibleFields),s.result.applicantFormRequiredFields&&s.result.applicantFormRequiredFields.length>0&&(a.applicantFormRequiredFields=s.result.applicantFormRequiredFields),s.result.allowedLanguages&&s.result.allowedLanguages.length>0&&(a.allowedLanguages=s.result.allowedLanguages),s.result.applicantFormPages)try{const n=typeof s.result.applicantFormPages=="string"?JSON.parse(s.result.applicantFormPages):s.result.applicantFormPages;Array.isArray(n)&&n.length>0&&(a.applicantFormPages=n)}catch{}return a}catch(s){return console.warn("[ThemeService] Failed to fetch theme configuration:",s),Ae(ee.Default)}}async saveThemeConfiguration(r){await this.httpClient.post("Tenant","SaveThemeConfiguration",r)}getAvailablePresets(){return[{id:ee.Default,name:"Default"},{id:ee.Corporate,name:"Corporate"},{id:ee.Fintech,name:"Fintech"},{id:ee.Healthcare,name:"Healthcare"},{id:ee.Modern,name:"Modern"},{id:ee.Minimal,name:"Minimal"}]}getPreviewTheme(r,s){const a=Ae(r);return s?{...a,...s,logo:{...a.logo,...s.logo},colors:{...a.colors,...s.colors},typography:s.typography?{...a.typography,...s.typography}:a.typography,spacing:s.spacing?{...a.spacing,...s.spacing}:a.spacing}:a}}class wt{constructor(){Q(this,"listeners",new Map)}on(r,s){return this.listeners.has(r)||this.listeners.set(r,new Set),this.listeners.get(r).add(s),()=>{this.off(r,s)}}off(r,s){const a=this.listeners.get(r);a&&a.delete(s)}emit(r,s){const a=this.listeners.get(r);a&&a.forEach(n=>{try{n(s)}catch(i){console.error(`Error in event listener for "${r}":`,i)}})}clear(){this.listeners.clear()}clearEvent(r){this.listeners.delete(r)}}class jt{constructor(){Q(this,"events",new wt);Q(this,"_applicantId",null);Q(this,"_progress",null);Q(this,"_error",null)}get applicantId(){return this._applicantId}get progress(){return this._progress}get currentStep(){var r;return((r=this._progress)==null?void 0:r.currentStep)||null}get steps(){var r;return((r=this._progress)==null?void 0:r.stepInfoList)||[]}get status(){var r;return((r=this._progress)==null?void 0:r.status)||me.None}get workflowResult(){var r;return((r=this._progress)==null?void 0:r.workflowResult)||null}get error(){return this._error}get isComplete(){return this.status===me.Finished}get isOnHold(){return this.status===me.OnHold}get isInProgress(){return this.status===me.InProgress}setApplicantId(r){this._applicantId=r}updateProgress(r){var a,n;const s=(a=this._progress)==null?void 0:a.currentStep;this._progress=r,this._applicantId=r.applicantId,this._error=null,this.events.emit("progressUpdated",r),(s==null?void 0:s.order)!==((n=r.currentStep)==null?void 0:n.order)&&this.events.emit("stepChanged",r.currentStep),this.events.emit("statusChanged",r.status),r.status===me.Finished&&r.workflowResult&&this.events.emit("completed",r.workflowResult)}setError(r){this._error=r,this.events.emit("error",r)}clearError(){this._error=null}reset(){this._applicantId=null,this._progress=null,this._error=null}onProgressUpdated(r){return this.events.on("progressUpdated",r)}onStepChanged(r){return this.events.on("stepChanged",r)}onStatusChanged(r){return this.events.on("statusChanged",r)}onError(r){return this.events.on("error",r)}onCompleted(r){return this.events.on("completed",r)}clearListeners(){this.events.clear()}}class Nt{constructor(){Q(this,"handlers",new Map)}registerHandler(r,s){this.handlers.set(r,s)}getHandler(r){return this.handlers.get(r)}hasHandler(r){return this.handlers.has(r)}async loadStepData(r,s){const a=this.getHandler(r);if(!a)throw new Error(`No handler registered for step action: ${z[r]}`);return a.loadData(s)}async submitStepData(r,s){const a=this.getHandler(r);if(!a)throw new Error(`No handler registered for step action: ${z[r]}`);return a.submitData(s)}}class St{constructor(r,s,a,n,i,o,c,d){Q(this,"state");Q(this,"stepRouter");this.applicantService=r,this.questionnaireService=s,this.uploadDocumentService=a,this.appropriatenessTestService=n,this.overviewService=i,this.riskScoringService=o,this.investorCategorizationService=d,this.state=new jt,this.stepRouter=new Nt,this.registerStepHandlers()}registerStepHandlers(){this.stepRouter.registerHandler(z.Questionaries,{loadData:r=>this.questionnaireService.getQuestionnaire(r),submitData:async r=>{await this.questionnaireService.fillQuestionnaire(r)}}),this.stepRouter.registerHandler(z.UploadDocument,{loadData:r=>this.uploadDocumentService.getUploadDocument(r),submitData:r=>this.uploadDocumentService.fillUploadDocument(r)}),this.stepRouter.registerHandler(z.AppropriatenessTest,{loadData:r=>this.appropriatenessTestService.getAppropriatenessTest(r),submitData:async r=>{await this.appropriatenessTestService.fillAppropriatenessTest(r)}}),this.stepRouter.registerHandler(z.Overview,{loadData:r=>this.overviewService.getOverviewData(r),submitData:r=>this.overviewService.passOverview(r.applicantId)}),this.stepRouter.registerHandler(z.RiskScoring,{loadData:r=>this.riskScoringService.getRiskCriterias(r),submitData:async r=>{await this.riskScoringService.submitRiskScoring(r)}}),this.stepRouter.registerHandler(z.IdentitySdk,{loadData:async r=>({applicantId:r,message:"Identity verification required"}),submitData:async()=>{}}),this.stepRouter.registerHandler(z.InvestorCategorization,{loadData:r=>this.investorCategorizationService.getInvestorCategorization(r),submitData:async r=>{await this.investorCategorizationService.setInvestorCategorization(r)}}),this.stepRouter.registerHandler(z.ManualReview,{loadData:async r=>({applicantId:r,message:"Your application is under manual review"}),submitData:async()=>{}}),this.stepRouter.registerHandler(z.AdditionalData,{loadData:async r=>({applicantId:r,message:"Additional data required"}),submitData:async()=>{}})}async initialize(r){try{this.state.setApplicantId(r);const s=await this.applicantService.getProgress(r);return this.state.updateProgress(s),s}catch(s){throw this.state.setError(s),s}}async refreshProgress(){if(!this.state.applicantId)throw new Error("Workflow not initialized. Call initialize() first.");try{const r=await this.applicantService.getProgress(this.state.applicantId);return this.state.updateProgress(r),r}catch(r){throw this.state.setError(r),r}}async getCurrentStepData(){if(!this.state.currentStep)throw new Error("No current step available");if(!this.state.applicantId)throw new Error("Workflow not initialized");try{return await this.stepRouter.loadStepData(this.state.currentStep.action,this.state.applicantId)}catch(r){throw this.state.setError(r),r}}async submitCurrentStep(r){if(!this.state.currentStep)throw new Error("No current step available");try{await this.stepRouter.submitStepData(this.state.currentStep.action,r),await this.refreshProgress()}catch(s){throw this.state.setError(s),s}}async moveToNextStep(){return this.refreshProgress()}async moveToPreviousStep(){if(!this.state.applicantId)throw new Error("Workflow not initialized");try{return await this.applicantService.progressStepBack(this.state.applicantId),await this.refreshProgress()}catch(r){throw this.state.setError(r),r}}getState(){return this.state}getStepRouter(){return this.stepRouter}}function $e(t,r){return new Promise((s,a)=>{if(r&&document.getElementById(r)){s();return}const n=document.createElement("script");n.src=t,r&&(n.id=r),n.async=!0,n.onload=()=>s(),n.onerror=()=>a(new Error(`Failed to load script: ${t}`)),document.head.appendChild(n)})}function or(t){return!!document.getElementById(t)}function cr(t){const r=document.getElementById(t);r&&r.remove()}class Ct{constructor(r){Q(this,"sdk",null);Q(this,"config");this.config=r}async loadSDK(){await $e("https://cdn.sumsub.com/websdk/v2/production/websdk.js","sumsub-sdk")}async initialize(r){if(window.snsWebSdk||await this.loadSDK(),!window.snsWebSdk)throw new Error("Sumsub SDK failed to load");this.sdk=window.snsWebSdk.init(this.config.accessToken,()=>this.config.accessToken).withConf({lang:this.config.lang||"en",email:this.config.applicantEmail,phone:this.config.applicantPhone,i18n:{}}).on("idCheck.onStepCompleted",s=>{console.log("Sumsub step completed:",s)}).on("idCheck.onError",s=>{console.error("Sumsub error:",s)}).build(),this.sdk.launch(`#${r}`)}destroy(){this.sdk&&(this.sdk.destroy(),this.sdk=null)}onComplete(r){this.sdk&&this.sdk.on("idCheck.applicantStatus",s=>{s.applicantStatus==="completed"&&r(s)})}onError(r){this.sdk&&this.sdk.on("idCheck.onError",r)}}class At{constructor(r){Q(this,"sdk",null);Q(this,"config");this.config=r}async loadSDK(){await $e("https://sdk.onfido.com/v12.0.0/onfido.min.js","onfido-sdk")}async initialize(r){if(window.Onfido||await this.loadSDK(),!window.Onfido)throw new Error("Onfido SDK failed to load");this.sdk=window.Onfido.init({token:this.config.token,containerId:r,steps:this.config.steps||[{type:"welcome",options:{title:"Identity Verification"}},{type:"document",options:{documentTypes:{passport:!0,driving_licence:!0,national_identity_card:!0}}},{type:"face",options:{requestedVariant:"standard"}},{type:"complete"}],onComplete:()=>{this.config.onComplete&&this.config.onComplete()},onError:s=>{this.config.onError&&this.config.onError(s)}})}destroy(){this.sdk&&(this.sdk.tearDown(),this.sdk=null)}}class Et{constructor(r){Q(this,"sardineContext",null);Q(this,"config");Q(this,"sessionKey");this.config=r,this.sessionKey=r.sessionKey||this.generateSessionKey()}generateSessionKey(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(r){const s=Math.random()*16|0;return(r==="x"?s:s&3|8).toString(16)})}getSardineHost(){const{environment:r,region:s}=this.config;if(r==="sandbox")return"api.sandbox.sardine.ai";switch(s){case"eu":return"api.eu.sardine.ai";case"ca":return"api.ca.sardine.ai";case"au":return"api.au.sardine.ai";default:return"api.sardine.ai"}}async loadSDK(){return new Promise((r,s)=>{if(window._Sardine){r();return}const a=this.getSardineHost(),n=document.createElement("script");n.type="text/javascript",n.async=!0,n.src=`https://${a}/assets/loader.min.js`,n.onload=()=>{console.log("[SardinAI] SDK loaded successfully"),r()},n.onerror=()=>{s(new Error("Failed to load SardinAI SDK"))};const i=document.getElementsByTagName("script")[0];i&&i.parentNode?i.parentNode.insertBefore(n,i):document.head.appendChild(n)})}async initialize(){try{if(await this.loadSDK(),!window._Sardine)throw new Error("SardinAI SDK not available after loading");const r=this.getSardineHost(),{clientId:s,environment:a,flow:n,enableBiometrics:i,enablePortScanning:o}=this.config;this.sardineContext=window._Sardine.createContext({clientId:s,sessionKey:this.sessionKey,userIdHash:void 0,flow:n||window.location.pathname,environment:a||"production",parentElement:document.body,enableBiometrics:i!==!1,enablePortScanning:o===!0,region:this.config.region,onDeviceResponse:c=>{console.log(`[SardinAI] Device ID: ${c.deviceId}`)},onConfigUpdate:(c,d,m)=>{switch(c){case"SESSION_UPDATE_FAILED":console.error("[SardinAI] Session update failed:",m);break;case"SESSION_UPDATED":console.log("[SardinAI] Session updated:",d);break;case"SESSION_NO_UPDATE":console.log("[SardinAI] No session update");break;default:console.warn("[SardinAI] Unknown event:",c)}}}),this.addNoScriptFallback(r),console.log("[SardinAI] SDK initialized with sessionKey:",this.sessionKey)}catch(r){throw console.error("[SardinAI] Initialization failed:",r),r}}addNoScriptFallback(r){const s=document.createElement("noscript"),a=document.createElement("img"),{clientId:n,flow:i}=this.config;a.src=`https://${r}/v1/a.png?clientId=${n}&sessionKey=${this.sessionKey}&flow=${i||"kyc"}&ns=1`,a.style.display="none",s.appendChild(a),document.body.appendChild(s)}updateConfig(r){if(!this.sardineContext){console.warn("[SardinAI] Cannot update config - SDK not initialized");return}r.sessionKey&&(this.sessionKey=r.sessionKey),this.sardineContext.updateConfig({...r,onConfigUpdate:(s,a,n)=>{switch(s){case"SESSION_UPDATE_FAILED":console.error("[SardinAI] Config update failed:",n);break;case"SESSION_UPDATED":console.log("[SardinAI] Config updated:",a);break;case"SESSION_NO_UPDATE":console.log("[SardinAI] No config update needed");break}}})}getSessionKey(){return this.sessionKey}destroy(){this.sardineContext&&(this.sardineContext=null)}}class Ne{static createProvider(r,s){switch(r){case ue.Sumsub:return new Ct(s);case ue.Onfido:return new At(s);case ue.SardinAI:return new Et(s);default:throw new Error(`Unsupported identity provider: ${r}`)}}static parseProviderConfig(r,s,a){var n;switch(r){case ue.Sumsub:return{accessToken:s.accessToken||s.token,applicantEmail:s.email,applicantPhone:s.phone,externalUserId:s.externalUserId,lang:s.lang||"en"};case ue.Onfido:return{token:s.token||s.sdkToken};case ue.SardinAI:const i=((n=a==null?void 0:a.identityProviders)==null?void 0:n.sardinai)||{};return{clientId:i.clientId||s.clientId,sessionKey:i.sessionKey||s.sessionKey,environment:i.environment||s.environment||"production",flow:i.flow||s.flow,region:i.region,enableBiometrics:i.enableBiometrics,enablePortScanning:i.enablePortScanning};default:throw new Error(`Unsupported identity provider: ${r}`)}}}class Rt{constructor(r){Q(this,"currentTheme",ne);Q(this,"customStyleElement",null);Q(this,"container");this.container=r||document.documentElement}applyTheme(r){this.currentTheme=this.mergeWithDefault(r),this.applyColors(this.currentTheme.colors),this.currentTheme.typography&&this.applyTypography(this.currentTheme.typography),this.currentTheme.spacing&&this.applySpacing(this.currentTheme.spacing),this.currentTheme.customCSS&&this.injectCustomCSS(this.currentTheme.customCSS),console.log("[ThemeManager] Theme applied:",this.currentTheme.name||"Custom")}applyColors(r){var a;const s={primary:r.primary,"primary-hover":r.primaryHover,"primary-light":r.primaryLight,"primary-dark":r.primaryDark,secondary:r.secondary,"secondary-hover":r.secondaryHover,success:r.success,warning:r.warning,danger:r.danger,info:r.info,background:r.background,surface:r.surface,border:r.border,"text-primary":r.textPrimary,"text-secondary":r.textSecondary,"text-muted":r.textMuted};Object.entries(s).forEach(([n,i])=>{this.container.style.setProperty(`--metakyc-${n}`,i)}),(a=this.currentTheme.darkMode)!=null&&a.colors&&this.applyDarkModeColors(this.currentTheme.darkMode.colors)}applyDarkModeColors(r){Object.entries(r).forEach(([s,a])=>{if(a){const n=`--metakyc-dark-${this.kebabCase(s)}`;this.container.style.setProperty(n,a)}})}applyTypography(r){r&&(r.fontFamily&&this.container.style.setProperty("--metakyc-font-family",r.fontFamily),r.headingFont&&this.container.style.setProperty("--metakyc-heading-font",r.headingFont),r.fontSize&&Object.entries(r.fontSize).forEach(([s,a])=>{this.container.style.setProperty(`--metakyc-font-size-${s}`,a)}),r.fontWeight&&Object.entries(r.fontWeight).forEach(([s,a])=>{this.container.style.setProperty(`--metakyc-font-weight-${s}`,a.toString())}))}applySpacing(r){r&&Object.entries(r).forEach(([s,a])=>{const n=`--metakyc-${this.kebabCase(s)}`;this.container.style.setProperty(n,a)})}injectCustomCSS(r){this.customStyleElement&&this.customStyleElement.remove(),this.customStyleElement=document.createElement("style"),this.customStyleElement.id="metakyc-custom-css",this.customStyleElement.textContent=r,document.head.appendChild(this.customStyleElement)}mergeWithDefault(r){var s;return{name:r.name||ne.name,title:r.title||ne.title,logo:{...ne.logo,...r.logo},colors:{...ne.colors,...r.colors},typography:r.typography?{...ne.typography,...r.typography}:ne.typography,spacing:r.spacing?{...ne.spacing,...r.spacing}:ne.spacing,customCSS:r.customCSS,darkMode:r.darkMode?{colors:{...(s=ne.darkMode)==null?void 0:s.colors,...r.darkMode.colors}}:ne.darkMode,applicantFormVisibleFields:r.applicantFormVisibleFields,applicantFormRequiredFields:r.applicantFormRequiredFields,allowedLanguages:r.allowedLanguages,applicantFormPages:r.applicantFormPages}}getCurrentTheme(){return this.currentTheme}resetTheme(){this.applyTheme(ne)}cleanup(){this.customStyleElement&&(this.customStyleElement.remove(),this.customStyleElement=null)}kebabCase(r){return r.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}}const Ue=l.createContext(null),dr=({config:t,children:r})=>{const[s,a]=l.useState(null),n=l.useRef(!1),i=l.useRef(!1),o=l.useMemo(()=>{const d=new nt(t),m=new it(d),v=new lt(d),w=new ot(d),x=new ct(d),h=new dt(d),g=new ut(d),k=new mt(d),f=new pt(d),p=new ht(d),R=new kt(d),N=new Rt;return{httpClient:d,applicantService:m,questionnaireService:v,uploadDocumentService:w,appropriatenessTestService:x,overviewService:h,riskScoringService:g,identityService:k,baseInformationService:f,investorCategorizationService:p,themeService:R,themeManager:N}},[t]),c=l.useMemo(()=>({config:t,...o,currentTheme:s,createOrchestrator:()=>new St(o.applicantService,o.questionnaireService,o.uploadDocumentService,o.appropriatenessTestService,o.overviewService,o.riskScoringService,o.identityService,o.investorCategorizationService)}),[t,o,s]);return l.useEffect(()=>((async()=>{if(n.current||i.current){console.log("[MetaKYC] Theme already loading or loaded, skipping...");return}n.current=!0;try{if(t.theme){console.log("[MetaKYC] Applying static theme from config"),o.themeManager.applyTheme(t.theme),a(o.themeManager.getCurrentTheme()),i.current=!0;return}console.log("[MetaKYC] Fetching theme from backend...");const m=await o.themeService.getThemeConfiguration();o.themeManager.applyTheme(m),a(o.themeManager.getCurrentTheme()),i.current=!0,console.log("[MetaKYC] Theme loaded and applied",m)}catch(m){console.warn("[MetaKYC] Failed to load theme, using default:",m),a(o.themeManager.getCurrentTheme()),i.current=!0}finally{n.current=!1}})(),()=>{o.themeManager.cleanup()}),[]),e.jsx(Ue.Provider,{value:c,children:r})};function de(){const t=l.useContext(Ue);if(!t)throw new Error("useMetaKYC must be used within a MetaKYCProvider");return t}async function It(t){return new Promise((r,s)=>{const a=new FileReader;a.readAsDataURL(t),a.onload=()=>{const i=a.result.split(",")[1];r(i)},a.onerror=n=>s(n)})}function ur(t,r){return t.size<=r}function mr(t,r){return r.split(",").map(a=>a.trim()).some(a=>{if(a.endsWith("/*")){const n=a.slice(0,-2);return t.type.startsWith(n)}return t.type===a})}function Pe(t){if(t===0)return"0 Bytes";const r=1024,s=["Bytes","KB","MB","GB"],a=Math.floor(Math.log(t)/Math.log(r));return Math.round(t/Math.pow(r,a)*100)/100+" "+s[a]}function pr(t){return t}function te(...t){return t.filter(Boolean).join(" ")}const Ee={APPLICANT_ID:"metakyc_applicant_id",WORKFLOW_STATE:"metakyc_workflow_state"};function Dt(t){try{localStorage.setItem(Ee.APPLICANT_ID,t.toString())}catch(r){console.warn("Failed to save applicant ID to storage:",r)}}function Ft(){try{const t=localStorage.getItem(Ee.APPLICANT_ID);return t?parseInt(t,10):null}catch(t){return console.warn("Failed to retrieve applicant ID from storage:",t),null}}function Pt(){try{localStorage.removeItem(Ee.APPLICANT_ID)}catch(t){console.warn("Failed to clear applicant ID from storage:",t)}}function Lt(t){try{localStorage.setItem(Ee.WORKFLOW_STATE,JSON.stringify(t))}catch(r){console.warn("Failed to save workflow state to storage:",r)}}function hr(){try{const t=localStorage.getItem(Ee.WORKFLOW_STATE);return t?JSON.parse(t):null}catch(t){return console.warn("Failed to retrieve workflow state from storage:",t),null}}function Tt(){try{localStorage.removeItem(Ee.WORKFLOW_STATE)}catch(t){console.warn("Failed to clear workflow state from storage:",t)}}function gr(){Pt(),Tt()}function Mt(t){const{createOrchestrator:r}=de(),[s,a]=l.useState(null),[n,i]=l.useState(!1),[o,c]=l.useState(null),d=l.useRef(null),m=t||Ft();l.useEffect(()=>{d.current||(d.current=r())},[r]),l.useEffect(()=>{var N;s&&m&&(Dt(m),Lt({applicantId:m,currentStepOrder:(N=s.currentStep)==null?void 0:N.order,status:s.status,lastUpdated:new Date().toISOString(),workflowKey:s.workFlowKey,nextWorkflowKey:s.nextWorkflowKey}))},[s,m]);const v=l.useRef(!1),w=l.useRef(!1),x=l.useCallback(async()=>{if(!(!m||!d.current)){if(v.current){console.log("[Workflow] Load already in progress, skipping...");return}v.current=!0,i(!0),c(null);try{const N=await d.current.initialize(m);a(N),w.current=!0}catch(N){c(N)}finally{i(!1),v.current=!1}}},[m]);l.useEffect(()=>{m&&!w.current&&x()},[m,x]);const h=l.useCallback(async()=>{if(d.current){if(v.current){console.log("[Workflow] Refresh already in progress, skipping...");return}v.current=!0,i(!0),c(null);try{const N=await d.current.refreshProgress();a(N)}catch(N){c(N)}finally{i(!1),v.current=!1}}},[]),g=l.useCallback(async()=>{if(d.current){i(!0),c(null);try{const N=await d.current.moveToNextStep();a(N)}catch(N){c(N)}finally{i(!1)}}},[]),k=l.useCallback(async()=>{if(d.current){i(!0),c(null);try{const N=await d.current.moveToPreviousStep();a(N)}catch(N){c(N)}finally{i(!1)}}},[]),f=l.useCallback(async N=>{if(d.current){i(!0),c(null);try{await d.current.submitCurrentStep(N);const b=await d.current.refreshProgress();a(b)}catch(b){throw c(b),b}finally{i(!1)}}},[]),p=Ke.useMemo(()=>s!=null&&s.stepInfoList?[...s.stepInfoList].sort((N,b)=>N.order-b.order):[],[s==null?void 0:s.stepInfoList]),R=Ke.useMemo(()=>s?s.nextWorkflowKey&&s.nextWorkflowKey!==s.workFlowKey:!1,[s]);return{progress:s,applicantId:m,currentStep:(s==null?void 0:s.currentStep)||null,steps:p,status:(s==null?void 0:s.status)||me.None,workflowResult:(s==null?void 0:s.workflowResult)||null,workflowKey:s==null?void 0:s.workFlowKey,nextWorkflowKey:s==null?void 0:s.nextWorkflowKey,hasWorkflowChanged:R,isLoading:n,error:o,isComplete:(s==null?void 0:s.status)===me.Finished,isOnHold:(s==null?void 0:s.status)===me.OnHold,refreshProgress:h,moveToNext:g,moveBack:k,submitCurrentStep:f,orchestrator:d.current}}function Ot(t){const{questionnaireService:r,applicantService:s}=de(),[a,n]=l.useState(null),[i,o]=l.useState({}),[c,d]=l.useState(!1),[m,v]=l.useState(!1),[w,x]=l.useState(null),h=l.useRef(!1),g=l.useRef(null),k=l.useCallback(async()=>{var p,R;if(t){if(h.current){console.log("[Questionnaire] Load already in progress, skipping...");return}h.current=!0,d(!0),x(null);try{const[N,b]=await Promise.all([r.getQuestionnaire(t),s.getApplicantData(t).catch(()=>null)]);if(n(N),(p=b==null?void 0:b.questionnaireResults)!=null&&p.length&&N){const _=new Map;for(const y of b.questionnaireResults)y.question&&((R=y.answers)!=null&&R.length)&&_.set(y.question.trim().toLowerCase(),y.answers);const W={},P=N.questionGroups.flatMap(y=>y.questions??[]);for(const y of P){const S=y.text.trim().toLowerCase();_.has(S)&&(W[y.id]=_.get(S))}o(W)}g.current=t}catch(N){x(N)}finally{d(!1),h.current=!1}}},[t,r,s]);l.useEffect(()=>{t&&g.current!==t&&k()},[t]);const f=l.useCallback(async p=>{v(!0),x(null);try{return await r.fillQuestionnaire(p)}catch(R){throw x(R),R}finally{v(!1)}},[r]);return{questionnaire:a,initialAnswers:i,isLoading:c,isSubmitting:m,error:w,load:k,submit:f}}function zt(t){const{uploadDocumentService:r}=de(),[s,a]=l.useState(null),[n,i]=l.useState(!1),[o,c]=l.useState(!1),[d,m]=l.useState(0),[v,w]=l.useState(null),x=l.useRef(!1),h=l.useRef(null),g=l.useCallback(async()=>{if(t){if(x.current){console.log("[UploadDocument] Load already in progress, skipping...");return}x.current=!0,i(!0),w(null);try{const f=await r.getUploadDocument(t);a(f),h.current=t}catch(f){w(f)}finally{i(!1),x.current=!1}}},[t,r]);l.useEffect(()=>{t&&h.current!==t&&g()},[t]);const k=l.useCallback(async f=>{c(!0),m(0),w(null);try{await r.fillUploadDocument(f),m(100)}catch(p){throw w(p),p}finally{c(!1)}},[r]);return{uploadDocument:s,isLoading:n,isSubmitting:o,uploadProgress:d,error:v,load:g,submit:k}}function xr(t){const{appropriatenessTestService:r}=de(),[s,a]=l.useState(null),[n,i]=l.useState(!1),[o,c]=l.useState(!1),[d,m]=l.useState(null),[v,w]=l.useState(null),x=l.useRef(!1),h=l.useRef(null),g=l.useCallback(async()=>{if(t){if(x.current){console.log("[AppropriatenessTest] Load already in progress, skipping...");return}x.current=!0,i(!0),m(null);try{const f=await r.getAppropriatenessTest(t);a(f),h.current=t}catch(f){m(f)}finally{i(!1),x.current=!1}}},[t,r]);l.useEffect(()=>{t&&h.current!==t&&g()},[t]);const k=l.useCallback(async f=>{c(!0),m(null);try{const p=await r.fillAppropriatenessTest(f);return w(p),p}catch(p){throw m(p),p}finally{c(!1)}},[r]);return{test:s,result:v,isLoading:n,isSubmitting:o,error:d,load:g,submit:k}}function Bt(t){const{overviewService:r}=de(),[s,a]=l.useState(null),[n,i]=l.useState(!1),[o,c]=l.useState(!1),[d,m]=l.useState(null),v=l.useRef(!1),w=l.useRef(null),x=l.useCallback(async()=>{if(t){if(v.current){console.log("[Overview] Load already in progress, skipping...");return}v.current=!0,i(!0),m(null);try{const g=await r.getOverviewData(t);a(g),w.current=t}catch(g){m(g)}finally{i(!1),v.current=!1}}},[t,r]);l.useEffect(()=>{t&&w.current!==t&&x()},[t]);const h=l.useCallback(async()=>{if(t){c(!0),m(null);try{await r.passOverview(t)}catch(g){throw m(g),g}finally{c(!1)}}},[t,r]);return{overview:s,isLoading:n,isSubmitting:o,error:d,load:x,passOverview:h}}function $t(t){const{identityService:r}=de(),[s,a]=l.useState(null),[n,i]=l.useState(!1),[o,c]=l.useState(null),d=l.useRef(!1),m=l.useCallback(async(x,h)=>{if(t){if(d.current){console.log("[Identity] Request already in progress, skipping...");return}d.current=!0,i(!0),c(null);try{const g={applicantId:t,restart:!1,redirectUrl:x||"",ttl:h||604800};console.log("Identity request input:",g);const k=await r.identityRequest(g);return console.log("Identity request result:",k),a(k),k}catch(g){throw c(g),g}finally{i(!1),d.current=!1}}},[t,r]),v=l.useCallback(async(x,h)=>{if(t){i(!0),c(null);try{const g={applicantId:t,restart:!1,redirectUrl:x,ttl:h},k=await r.identityCompanyRequest(g);return a(k),k}catch(g){throw c(g),g}finally{i(!1)}}},[t,r]),w=l.useCallback(async()=>{if(t){if(d.current){console.log("[Identity] Restart already in progress, skipping...");return}d.current=!0,i(!0),c(null);try{const x={applicantId:t,restart:!0,redirectUrl:"",ttl:604800};console.log("Restarting identity with input:",x);const h=await r.identityRequest(x);return console.log("Restart identity result:",h),a(h),h}catch(x){throw c(x),x}finally{i(!1),d.current=!1}}},[t,r]);return{identityData:s,provider:(s==null?void 0:s.provider)||null,token:(s==null?void 0:s.publicProviderTokenObject)||null,isLoading:n,error:o,requestIdentity:m,requestCompanyIdentity:v,restartIdentity:w}}function Ut(t){const{riskScoringService:r,applicantService:s}=de(),[a,n]=l.useState(null),[i,o]=l.useState({}),[c,d]=l.useState(!1),[m,v]=l.useState(!1),[w,x]=l.useState(null),[h,g]=l.useState(null),k=l.useRef(!1),f=l.useRef(null),p=l.useCallback(async()=>{var N;if(t){if(k.current){console.log("[RiskScoring] Load already in progress, skipping...");return}k.current=!0,d(!0),x(null);try{const[b,_]=await Promise.all([r.getRiskCriterias(t),s.getApplicantData(t).catch(()=>null)]);if(n(b),(N=_==null?void 0:_.riskScoringResults)!=null&&N.length){const W=_.riskScoringResults[0],P={};for(const y of W.riskCriteriaResults??[])if(y.riskCriteriaId!=null&&y.answer!=null&&y.answer!==""){const S=[...new Set(y.answer.split(",").map(I=>I.trim()).filter(I=>I!==""))];S.length>0&&(P[y.riskCriteriaId]=S)}o(P)}f.current=t}catch(b){x(b)}finally{d(!1),k.current=!1}}},[t,r,s]);l.useEffect(()=>{t&&f.current!==t&&p()},[t]);const R=l.useCallback(async N=>{v(!0),x(null);try{const b=await r.submitRiskScoring(N);return g(b),b}catch(b){throw x(b),b}finally{v(!1)}},[r]);return{criteria:a,initialAnswers:i,result:h,isLoading:c,isSubmitting:m,error:w,load:p,submit:R}}function _t(){const{applicantService:t,config:r}=de(),[s,a]=l.useState(!1),[n,i]=l.useState(null),o=l.useRef(!1),c=l.useRef(!1),d=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(h){const g=Math.random()*16|0;return(h==="x"?g:g&3|8).toString(16)}),m=l.useCallback(async h=>{var g;if(o.current)throw console.log("[Applicant] Create already in progress, skipping..."),new Error("Creation already in progress");o.current=!0,a(!0),i(null);try{if(h.applicantAdditionalDatas||(h.applicantAdditionalDatas=[]),(g=r.identityProviders)!=null&&g.sardinai){const f=d();console.log("[SardinAI] Generated session key:",f),h.applicantAdditionalDatas.push({paramName:"sessionKey",value:f})}return await t.createApplicant(h)}catch(k){throw i(k),k}finally{a(!1),o.current=!1}},[t,r]),v=l.useCallback(async h=>{a(!0),i(null);try{return await t.createCompanyApplicant(h)}catch(g){throw i(g),g}finally{a(!1)}},[t]),w=l.useCallback(async h=>{if(c.current)throw console.log("[Applicant] Data load already in progress, skipping..."),new Error("Data load already in progress");c.current=!0,a(!0),i(null);try{return await t.getApplicantData(h)}catch(g){throw i(g),g}finally{a(!1),c.current=!1}},[t]),x=l.useCallback(async h=>{a(!0),i(null);try{await t.stopProgress(h)}catch(g){throw i(g),g}finally{a(!1)}},[t]);return{isLoading:s,error:n,createApplicant:m,createCompanyApplicant:v,getApplicantData:w,stopProgress:x}}const B=({children:t,variant:r="primary",size:s="md",isLoading:a=!1,disabled:n,className:i,...o})=>{const c="inline-flex items-center justify-center rounded-lg font-medium transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 disabled:opacity-50 disabled:cursor-not-allowed",d={primary:"bg-primary-500 text-white hover:bg-primary-600 focus:ring-primary-500",secondary:"bg-gray-200 text-gray-900 hover:bg-gray-300 focus:ring-gray-400",outline:"border-2 border-primary-500 text-primary-500 hover:bg-primary-50 focus:ring-primary-500",danger:"bg-danger-500 text-white hover:bg-danger-600 focus:ring-danger-500",ghost:"text-gray-700 hover:bg-gray-100 focus:ring-gray-400"},m={sm:"px-3 py-1.5 text-sm",md:"px-4 py-2 text-base",lg:"px-6 py-3 text-lg"};return e.jsxs("button",{className:te(c,d[r],m[s],i),disabled:n||a,...o,children:[a&&e.jsxs("svg",{className:"animate-spin -ml-1 mr-2 h-4 w-4",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),t]})},ie=l.forwardRef(({label:t,error:r,helperText:s,leftIcon:a,rightIcon:n,className:i,...o},c)=>e.jsxs("div",{className:"w-full",children:[t&&e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:[t,o.required&&e.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),e.jsxs("div",{className:"relative",children:[a&&e.jsx("div",{className:"absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none",children:a}),e.jsx("input",{ref:c,className:te("block w-full rounded-lg border px-3 py-2 text-sm transition-colors","focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent","disabled:bg-gray-100 disabled:cursor-not-allowed",r?"border-danger-500 focus:ring-danger-500":"border-gray-300 dark:border-gray-600","dark:bg-gray-800 dark:text-white",a?"pl-10":"",n?"pr-10":"",i),...o}),n&&e.jsx("div",{className:"absolute inset-y-0 right-0 pr-3 flex items-center pointer-events-none",children:n})]}),r&&e.jsx("p",{className:"mt-1 text-sm text-danger-500",children:r}),!r&&s&&e.jsx("p",{className:"mt-1 text-sm text-gray-500",children:s})]}));ie.displayName="Input";const T=({children:t,className:r,...s})=>e.jsx("div",{className:te("metakyc-card rounded-xl shadow-sm border",r),style:{backgroundColor:"var(--metakyc-surface, #ffffff)",borderColor:"var(--metakyc-border, #e5e7eb)"},...s,children:t}),se=({children:t,className:r,...s})=>e.jsx("div",{className:te("px-6 py-4 border-b",r),style:{borderColor:"var(--metakyc-border, #e5e7eb)"},...s,children:t}),M=({children:t,className:r,...s})=>e.jsx("div",{className:te("px-6 py-4",r),...s,children:t}),le=({children:t,className:r,...s})=>e.jsx("div",{className:te("px-6 py-4 border-t",r),style:{borderColor:"var(--metakyc-border, #e5e7eb)"},...s,children:t}),ye=({children:t,variant:r="default",className:s,...a})=>{const n={default:"bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300",success:"bg-success-100 text-success-800 dark:bg-success-900 dark:text-success-300",danger:"bg-danger-100 text-danger-800 dark:bg-danger-900 dark:text-danger-300",warning:"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300",info:"bg-primary-100 text-primary-800 dark:bg-primary-900 dark:text-primary-300"};return e.jsx("span",{className:te("inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium",n[r],s),...a,children:t})},pe=({size:t="md",className:r,...s})=>{const a={sm:"h-4 w-4",md:"h-8 w-8",lg:"h-12 w-12"};return e.jsx("div",{className:te("flex items-center justify-center",r),...s,children:e.jsxs("svg",{className:te("animate-spin text-primary-500",a[t]),xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]})})},be=l.forwardRef(({label:t,error:r,helperText:s,options:a,placeholder:n,className:i,style:o,...c},d)=>e.jsxs("div",{className:"w-full",children:[t&&e.jsxs("label",{className:"block text-sm font-medium mb-1",style:{color:"var(--metakyc-text-primary, #374151)"},children:[t,c.required&&e.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),e.jsxs("select",{ref:d,className:te("block w-full rounded-lg border px-3 py-2 text-sm transition-colors","focus:outline-none focus:ring-2 focus:ring-offset-0","disabled:opacity-60 disabled:cursor-not-allowed",r?"border-danger-500":"",i),style:{backgroundColor:"var(--metakyc-input-bg, #ffffff)",color:"var(--metakyc-text-primary, #111827)",borderColor:r?"var(--metakyc-error, #ef4444)":"var(--metakyc-border, #d1d5db)",...o},...c,children:[n&&e.jsx("option",{value:"",disabled:!0,style:{backgroundColor:"var(--metakyc-input-bg, #ffffff)",color:"var(--metakyc-text-secondary, #6b7280)"},children:n},"__placeholder__"),a.map((m,v)=>e.jsx("option",{value:m.value,disabled:m.disabled,style:{backgroundColor:"var(--metakyc-input-bg, #ffffff)",color:m.disabled?"var(--metakyc-text-secondary, #9ca3af)":"var(--metakyc-text-primary, #111827)"},children:m.label},m.value||`option-${v}`))]}),r&&e.jsx("p",{className:"mt-1 text-sm",style:{color:"var(--metakyc-error, #ef4444)"},children:r}),!r&&s&&e.jsx("p",{className:"mt-1 text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:s})]}));be.displayName="Select";const Kt=({label:t,value:r,onChange:s,options:a,placeholder:n="Select...",disabled:i=!1,required:o=!1})=>{const[c,d]=l.useState(!1),[m,v]=l.useState(""),w=l.useRef(null);l.useEffect(()=>{const f=p=>{w.current&&!w.current.contains(p.target)&&(d(!1),v(""))};return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[]);const x=a.filter(f=>f.label.toLowerCase().includes(m.toLowerCase())),h=f=>{i||(r.includes(f)?s(r.filter(p=>p!==f)):s([...r,f]))},g=(f,p)=>{p.stopPropagation(),i||s(r.filter(R=>R!==f))},k=f=>{var p;return((p=a.find(R=>R.value===f))==null?void 0:p.label)||f};return e.jsxs("div",{className:"w-full metakyc-multiselect",ref:w,children:[t&&e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:[t,o&&e.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),e.jsxs("div",{className:"relative",children:[e.jsxs("div",{onClick:()=>!i&&d(!c),className:te("metakyc-multiselect-trigger","min-h-[42px] w-full px-3 py-2 rounded-lg border text-sm transition-colors","bg-white dark:bg-gray-800","border-gray-300 dark:border-gray-600",c&&"ring-2 ring-blue-500 border-transparent",i?"opacity-50 cursor-not-allowed":"cursor-pointer"),children:[r.length===0?e.jsx("span",{className:"metakyc-multiselect-placeholder text-gray-400 dark:text-gray-500 leading-6",children:n}):e.jsx("div",{className:"flex flex-wrap gap-1 pr-6",children:r.map(f=>e.jsxs("span",{className:"metakyc-multiselect-chip inline-flex items-center gap-1 px-2 py-0.5 rounded bg-blue-100 dark:bg-blue-900/40 text-blue-800 dark:text-blue-300 text-xs font-medium",children:[k(f),!i&&e.jsx("button",{type:"button",onClick:p=>g(f,p),className:"metakyc-multiselect-chip-remove",style:{background:"transparent",border:"none",padding:"0 0 0 2px",margin:0,cursor:"pointer",fontSize:"14px",lineHeight:1,fontWeight:"bold",display:"inline-flex",alignItems:"center",boxShadow:"none",transform:"none",minWidth:0,width:"auto",height:"auto",letterSpacing:"normal",textTransform:"none"},children:"×"})]},f))}),e.jsx("span",{className:"metakyc-multiselect-arrow absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none text-xs",children:c?"▲":"▼"})]}),c&&e.jsxs("div",{className:"metakyc-multiselect-dropdown absolute z-50 w-full mt-1 rounded-lg shadow-lg",style:{background:"inherit",border:"1px solid #d1d5db"},children:[e.jsx("div",{className:"metakyc-multiselect-search-wrapper p-2",style:{borderBottom:"1px solid #e5e7eb"},children:e.jsx("input",{type:"text",value:m,onChange:f=>v(f.target.value),placeholder:"Search...",autoFocus:!0,onClick:f=>f.stopPropagation(),className:"metakyc-multiselect-search w-full px-2 py-1.5 text-sm rounded focus:outline-none focus:ring-1 focus:ring-blue-500",style:{border:"1px solid #d1d5db"}})}),e.jsx("ul",{className:"max-h-48 overflow-y-auto py-1",children:x.length===0?e.jsx("li",{className:"px-3 py-2 text-sm text-gray-500 dark:text-gray-400",children:"No results"}):x.map(f=>e.jsxs("li",{onClick:()=>h(f.value),className:te("metakyc-multiselect-option","flex items-center gap-2 px-3 py-2 text-sm cursor-pointer","hover:bg-gray-50 dark:hover:bg-gray-700",r.includes(f.value)&&"metakyc-multiselect-option-selected bg-blue-50 dark:bg-blue-900/20"),children:[e.jsx("input",{type:"checkbox",checked:r.includes(f.value),readOnly:!0,className:"rounded border-gray-300 text-blue-600 pointer-events-none"}),e.jsx("span",{className:"text-gray-900 dark:text-gray-100",children:f.label})]},f.value))}),r.length>0&&e.jsx("div",{className:"metakyc-multiselect-clear p-2 border-t border-gray-100 dark:border-gray-700",children:e.jsxs("button",{type:"button",onClick:()=>{s([]),v("")},className:"text-xs text-red-500 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300",children:["Clear all (",r.length," selected)"]})})]})]})]})},qt=({label:t,error:r,accept:s,multiple:a=!1,maxSize:n,onChange:i,value:o=[],className:c})=>{const[d,m]=l.useState(!1),v=l.useRef(null),w=p=>{if(!p)return;const R=Array.from(p);if(n&&R.filter(b=>b.size>n).length>0){const b=Pe(n);alert(`Some files exceed the maximum size of ${b}`);return}i==null||i(a?[...o,...R]:[R[0]])},x=p=>{p.preventDefault(),m(!0)},h=()=>{m(!1)},g=p=>{p.preventDefault(),m(!1),w(p.dataTransfer.files)},k=()=>{var p;(p=v.current)==null||p.click()},f=p=>{const R=o.filter((N,b)=>b!==p);i==null||i(R)};return e.jsxs("div",{className:te("w-full",c),children:[t&&e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:t}),e.jsxs("div",{className:te("border-2 border-dashed rounded-lg p-6 text-center cursor-pointer transition-colors",d?"border-primary-500 bg-primary-50 dark:bg-primary-900/20":"border-gray-300 dark:border-gray-600 hover:border-primary-500",r&&"border-danger-500"),onDragOver:x,onDragLeave:h,onDrop:g,onClick:k,children:[e.jsx("input",{ref:v,type:"file",className:"hidden",accept:s,multiple:a,onChange:p=>w(p.target.files)}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("svg",{className:"mx-auto h-12 w-12 text-gray-400",stroke:"currentColor",fill:"none",viewBox:"0 0 48 48",children:e.jsx("path",{d:"M28 8H12a4 4 0 00-4 4v20m32-12v8m0 0v8a4 4 0 01-4 4H12a4 4 0 01-4-4v-4m32-4l-3.172-3.172a4 4 0 00-5.656 0L28 28M8 32l9.172-9.172a4 4 0 015.656 0L28 28m0 0l4 4m4-24h8m-4-4v8m-12 4h.02",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}),e.jsxs("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:[e.jsx("span",{className:"font-medium text-primary-500",children:"Click to upload"})," or drag and drop"]}),n&&e.jsxs("p",{className:"text-xs text-gray-500",children:["Maximum file size: ",Pe(n)]})]})]}),o.length>0&&e.jsx("div",{className:"mt-3 space-y-2",children:o.map((p,R)=>e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[e.jsxs("div",{className:"flex items-center space-x-2 flex-1 min-w-0",children:[e.jsx("svg",{className:"h-5 w-5 text-gray-400 flex-shrink-0",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M4 4a2 2 0 012-2h4.586A2 2 0 0112 2.586L15.414 6A2 2 0 0116 7.414V16a2 2 0 01-2 2H6a2 2 0 01-2-2V4z",clipRule:"evenodd"})}),e.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300 truncate",children:p.name}),e.jsxs("span",{className:"text-xs text-gray-500",children:["(",Pe(p.size),")"]})]}),e.jsx("button",{type:"button",onClick:N=>{N.stopPropagation(),f(R)},className:"ml-2 text-danger-500 hover:text-danger-700 focus:outline-none",children:e.jsx("svg",{className:"h-5 w-5",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})})]},R))}),r&&e.jsx("p",{className:"mt-1 text-sm text-danger-500",children:r})]})},Ht=l.forwardRef(({countryCode:t="+1",onCountryCodeChange:r,className:s,...a},n)=>e.jsxs("div",{className:"w-full",children:[a.label&&e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:[a.label,a.required&&e.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:t,onChange:i=>r==null?void 0:r(i.target.value),className:te("w-20 rounded-lg border px-3 py-2 text-sm","focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent","border-gray-300 dark:border-gray-600 dark:bg-gray-800 dark:text-white"),placeholder:"+1"}),e.jsx(ie,{ref:n,type:"tel",className:te("flex-1",s),...a,label:""})]}),a.error&&e.jsx("p",{className:"mt-1 text-sm text-danger-500",children:a.error})]}));Ht.displayName="PhoneInput";/**
|
|
2
2
|
* @license lucide-react v0.574.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
Failed to reload test data. Please refresh the page.`)}};if(o)return e.jsx(T,{children:e.jsxs(M,{children:[e.jsx(pe,{className:"my-8"}),e.jsx("p",{className:"text-center text-gray-600 dark:text-gray-400 mt-4",children:"Loading appropriateness test..."})]})});if(!n)return e.jsx(T,{children:e.jsxs(M,{className:"py-12 text-center",children:[e.jsx("p",{className:"text-danger-500 text-lg mb-4",children:"No test data available"}),v&&e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:v})]})});if(b>0)return e.jsxs(T,{children:[e.jsxs(se,{children:[e.jsx("h2",{className:"text-lg font-bold text-gray-900 dark:text-white",children:n.displayName}),n.subtitle&&e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-2",children:n.subtitle})]}),e.jsxs(M,{className:"py-12 text-center",children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("div",{className:"text-6xl font-bold text-primary-500 mb-2",children:P(b)}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:"Please wait before attempting the test again"})]}),v&&e.jsx("div",{className:"mt-4 p-4 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg",children:e.jsx("p",{className:"text-red-600 dark:text-red-400 text-sm",children:v})})]})]});const q=n.testAllowedMaxTry-n.totalFailedTries;return f?e.jsx("form",{onSubmit:I,children:e.jsxs(T,{children:[e.jsx(se,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-bold text-gray-900 dark:text-white",children:n.displayName}),n.subtitle&&e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:n.subtitle})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("div",{className:`text-3xl font-bold ${g<=60?"text-danger-500":"text-primary-500"}`,children:P(g)}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Time Remaining"})]})]})}),e.jsxs(M,{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs(ye,{variant:"info",children:["Question ",Object.keys(x).length," of ",n.totalQuestionCount]}),e.jsxs(ye,{variant:q>1?"success":"warning",children:[q," attempt",q!==1?"s":""," remaining"]})]}),n.appropriatenessQuestions.map((D,A)=>e.jsxs("div",{className:"p-4 border border-gray-200 dark:border-gray-700 rounded-lg",children:[e.jsxs("div",{className:"mb-4",children:[e.jsxs("span",{className:"inline-block px-2 py-1 text-xs font-semibold text-primary-700 bg-primary-100 dark:text-primary-300 dark:bg-primary-900/30 rounded mb-2",children:["Question ",A+1]}),D.groupName&&e.jsx("span",{className:"ml-2 text-xs text-gray-500 dark:text-gray-400",children:D.groupName}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mt-2",children:D.question})]}),e.jsx("div",{className:"space-y-2",children:D.answers.map((V,K)=>e.jsxs("label",{className:`
|
|
63
63
|
flex items-center p-3 border-2 rounded-lg cursor-pointer transition-all
|
|
64
64
|
${x[D.id]===V?"border-primary-500 bg-primary-50 dark:bg-primary-900/20":"border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"}
|
|
65
|
-
`,children:[e.jsx("input",{type:"radio",name:`question-${D.id}`,value:V,checked:x[D.id]===V,onChange:ae=>S(D.id,ae.target.value),className:"h-4 w-4 text-primary-500 border-gray-300 focus:ring-primary-500",disabled:d}),e.jsx("span",{className:"ml-3 text-gray-700 dark:text-gray-300",children:V})]},K))})]},D.id)),v&&!R&&e.jsx("div",{className:"p-4 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg",children:e.jsxs("p",{className:"text-red-600 dark:text-red-400 text-sm",children:[e.jsx("strong",{children:"Error:"})," ",v]})}),R&&e.jsx("div",{className:"p-4 bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg",children:e.jsxs("p",{className:"text-yellow-700 dark:text-yellow-400 text-sm",children:[e.jsx("strong",{children:"Time's up!"})," Your answers are being submitted automatically."]})})]}),e.jsxs(le,{className:"flex justify-between",children:[e.jsx(B,{type:"button",variant:"outline",onClick:s,disabled:d,children:"Cancel"}),e.jsx(B,{type:"submit",isLoading:d,disabled:Object.keys(x).length<n.totalQuestionCount,children:R?"Submitting...":"Submit Test"})]})]})}):e.jsxs(T,{children:[e.jsxs(se,{children:[e.jsx("h2",{className:"text-lg font-bold text-gray-900 dark:text-white",children:n.displayName}),n.subtitle&&e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-2",children:n.subtitle})]}),e.jsxs(M,{children:[n.description&&e.jsx("div",{className:"mb-6 p-4 bg-gray-50 dark:bg-gray-800 rounded-lg",children:e.jsx("p",{className:"text-gray-700 dark:text-gray-300",children:n.description})}),e.jsxs("div",{className:"space-y-4 mb-6",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 bg-blue-50 dark:bg-blue-900/20 rounded-lg",children:[e.jsx("span",{className:"text-gray-700 dark:text-gray-300 font-medium",children:"Total Questions:"}),e.jsx(ye,{variant:"info",children:n.totalQuestionCount})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 bg-blue-50 dark:bg-blue-900/20 rounded-lg",children:[e.jsx("span",{className:"text-gray-700 dark:text-gray-300 font-medium",children:"Time Limit:"}),e.jsx(ye,{variant:"info",children:P(n.testDurationSec)})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 bg-blue-50 dark:bg-blue-900/20 rounded-lg",children:[e.jsx("span",{className:"text-gray-700 dark:text-gray-300 font-medium",children:"Correct Answers Required:"}),e.jsx(ye,{variant:"info",children:n.testCorrectAnswerPassLimit})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 bg-blue-50 dark:bg-blue-900/20 rounded-lg",children:[e.jsx("span",{className:"text-gray-700 dark:text-gray-300 font-medium",children:"Attempts Remaining:"}),e.jsx(ye,{variant:q>1?"success":"warning",children:q})]})]}),v&&e.jsx("div",{className:"mb-4 p-4 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg",children:e.jsxs("p",{className:"text-red-600 dark:text-red-400 text-sm",children:[e.jsx("strong",{children:"Previous Attempt:"})," ",v]})}),q<=0&&e.jsx("div",{className:"p-4 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg",children:e.jsx("p",{className:"text-red-600 dark:text-red-400",children:"You have used all your attempts. Please contact support for assistance."})})]}),e.jsxs(le,{className:"flex justify-between",children:[s&&e.jsx(B,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(B,{type:"button",onClick:y,disabled:q<=0,children:"Start Test"})]})]})},rr=({applicantId:t,onComplete:r,onBack:s})=>{var V,K,ae,J;const{applicantService:a,baseInformationService:n,config:i}=de(),{identityData:o,provider:c,token:d,isLoading:m,error:v,requestIdentity:w,restartIdentity:x}=$t(t),[h,g]=l.useState(null),[k,f]=l.useState(null),[p,R]=l.useState([]),[N,b]=l.useState(!0),[_,W]=l.useState(!1),[P,y]=l.useState(null),[S,I]=l.useState(!1),Y=l.useRef(!1),q=ke.useForm({defaultValues:{street:"",streetNumber:"",city:"",zip:"",country:"",nationality:"",phonenumber:""}});l.useEffect(()=>{(async()=>{try{const[F,X]=await Promise.all([a.getApplicantData(t),n.getCountries("","en")]);f(F);const G=new Set,oe=X.filter(ge=>{const u=ge.abbreviation3||ge.abbreviation;return!u||G.has(u)?!1:(G.add(u),!0)});R(oe);const $=F.applicantRequestData;if(q.reset({street:($==null?void 0:$.street)||"",streetNumber:($==null?void 0:$.streetNumber)||"",city:($==null?void 0:$.city)||"",zip:($==null?void 0:$.zip)||"",country:($==null?void 0:$.country)||"",nationality:($==null?void 0:$.nationality)||"",phonenumber:($==null?void 0:$.phonenumber)||""}),F.kycRecords&&F.kycRecords.length>0&&F.kycRecords[0].providerTokenObject!==null&&!Y.current){console.log("[Identity] Found existing identity verification, auto-requesting..."),Y.current=!0;try{await w(),W(!0)}catch(ge){console.error("[Identity] Auto-request failed:",ge)}}}catch(F){console.error("Error loading applicant data:",F)}finally{b(!1)}})()},[t]),l.useEffect(()=>{o&&!_&&(console.log("[Identity] Identity data already loaded, showing provider"),W(!0))},[o,_]),l.useEffect(()=>{if(d){if(d.expiresAt){const O=new Date(d.expiresAt).getTime();if(Date.now()>=O){console.warn("[Identity] Token has expired (expiresAt)"),I(!0),y("Your verification session has expired. Please restart.");return}}if(d.url)try{const F=new URL(d.url).toString().toLowerCase();if(F.includes("expired")||F.includes("invalid")||F.includes("error")){console.warn("[Identity] Token URL indicates expiration"),I(!0),y("Your verification link has expired. Please restart.");return}}catch{console.error("[Identity] Invalid token URL")}if(d.status==="expired"||d.error==="expired"||d.expired===!0){console.warn("[Identity] Token object indicates expiration"),I(!0),y("Your verification session has expired. Please restart.");return}}},[d]),l.useEffect(()=>{if(c!==null&&d&&!h&&_&&!S){const O=c;if(d.url){console.log("[Identity] Loading provider URL for user verification:",d.url),y(null);try{if(new URL(d.url),O===ue.SardinAI){console.log("[SardinAI] Initializing Risk SDK in background...");try{const F=Ne.parseProviderConfig(c,d,i);Ne.createProvider(c,F).initialize().then(()=>{console.log("[SardinAI] Risk SDK initialized successfully in background")}).catch(G=>{console.warn("[SardinAI] Risk SDK initialization failed (non-blocking):",G)})}catch(F){console.warn("[SardinAI] Risk SDK setup failed (non-blocking):",F)}}g({type:"url",url:d.url})}catch(F){console.error("[Identity] Invalid URL:",F),y("Invalid verification URL. Please restart."),I(!0)}return}if(O===ue.SardinAI){console.log("[SardinAI] No URL provided - initializing Risk SDK only..."),y(null);try{const F=Ne.parseProviderConfig(c,d,i),X=Ne.createProvider(c,F);X.initialize().then(()=>{console.log("[SardinAI] Risk SDK initialized successfully"),g(X),setTimeout(()=>{r==null||r()},2e3)}).catch(G=>{var $;console.error("[SardinAI] Failed to initialize:",G);const oe=(($=G.message)==null?void 0:$.toLowerCase())||"";oe.includes("expired")||oe.includes("invalid")||oe.includes("401")||oe.includes("400")?(I(!0),y("Session expired or invalid. Please restart verification.")):y(`Failed to initialize: ${G.message}`)})}catch(F){console.error("[SardinAI] Error creating provider:",F),y(`Configuration error: ${F.message}`)}return}try{y(null);const F=Ne.parseProviderConfig(c,d,i),X=Ne.createProvider(c,F);O===ue.Sumsub?(X.initialize("identity-container").catch(G=>{var oe;console.error("[Sumsub] Initialization error:",G),y(`Failed to initialize: ${G.message}`),(oe=G.message)!=null&&oe.toLowerCase().includes("expired")&&I(!0)}),X.onComplete&&X.onComplete(()=>{r==null||r()})):O===ue.Onfido&&X.initialize("identity-container").catch(G=>{console.error("[Onfido] Initialization error:",G),y(`Failed to initialize: ${G.message}`)}),g(X)}catch(F){console.error("[Identity] Provider setup error:",F),y(`Setup error: ${F.message}`)}}return()=>{if(h&&h.destroy)try{h.destroy()}catch(O){console.error("[Identity] Error destroying provider:",O)}}},[c,d,h,_,r,S]);const D=async()=>{try{y(null),I(!1),await w(),W(!0)}catch(O){console.error("Error starting identity verification:",O)}},A=async()=>{try{y(null),I(!1),g(null),console.log("[Identity] Restarting verification..."),await x(),W(!0)}catch(O){console.error("Error restarting identity verification:",O),y(O.message||"Failed to restart verification")}};if(N||m)return e.jsx(T,{children:e.jsxs(M,{children:[e.jsx(pe,{className:"my-8"}),e.jsx("p",{className:"text-center text-gray-600 dark:text-gray-400 mt-4",children:"Loading identity verification..."})]})});if(v)return e.jsx(T,{children:e.jsx(M,{children:e.jsxs("p",{className:"text-danger-500",children:["Error: ",v.message]})})});if(_&&(P||S))return e.jsxs(T,{children:[e.jsx(se,{children:e.jsx("h2",{className:"text-2xl font-bold text-gray-900 dark:text-white",children:"Verification Session Issue"})}),e.jsxs(M,{children:[e.jsx("div",{className:"p-4 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg mb-6",children:e.jsxs("div",{className:"flex items-start",children:[e.jsx("svg",{className:"h-6 w-6 text-red-600 dark:text-red-400 mr-3 mt-0.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-red-900 dark:text-red-100 mb-1",children:S?"Session Expired":"Verification Error"}),e.jsx("p",{className:"text-red-800 dark:text-red-200 text-sm",children:P||"Your verification session has expired and needs to be restarted."})]})]})}),e.jsxs("div",{className:"bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg p-4",children:[e.jsx("h3",{className:"font-semibold text-blue-900 dark:text-blue-100 mb-2",children:"What to do next:"}),e.jsxs("ul",{className:"text-blue-800 dark:text-blue-200 text-sm space-y-1 list-disc list-inside",children:[e.jsx("li",{children:'Click "Restart Verification" below to generate a new session'}),e.jsx("li",{children:"Complete the verification process without delays"}),e.jsx("li",{children:"If issues persist, contact support"})]})]})]}),e.jsxs(le,{className:"flex justify-between",children:[s&&e.jsx(B,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(B,{type:"button",onClick:A,disabled:m,children:m?"Restarting...":"Restart Verification"})]})]});if(_&&o){const O=c;return d!=null&&d.url?e.jsxs(T,{children:[e.jsx(se,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold",children:"Identity Verification"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:"Please complete the identity verification process"})]}),e.jsx(B,{type:"button",variant:"outline",size:"sm",onClick:A,disabled:m,children:"Restart"})]})}),e.jsxs(M,{children:[e.jsx("div",{className:"mb-4 p-3 bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg",children:e.jsxs("p",{className:"text-yellow-800 dark:text-yellow-200 text-sm",children:[e.jsx("strong",{children:"Important:"}),' If you see an "expired" or "invalid link" message below, click the "Restart" button above to generate a new verification session.']})}),e.jsx("div",{className:"w-full",style:{height:"600px"},children:e.jsx("iframe",{src:d.url,className:"w-full h-full border-0 rounded-lg",allow:"camera; microphone; geolocation",title:"Identity Verification",onLoad:F=>{var X,G,oe;console.log("[Identity] Iframe loaded");try{const $=F.target,Se=$.contentDocument||((X=$.contentWindow)==null?void 0:X.document);if(Se){const ge=((oe=(G=Se.body)==null?void 0:G.textContent)==null?void 0:oe.toLowerCase())||"";(ge.includes("expired")||ge.includes("invalid")||ge.includes("error"))&&(console.warn("[Identity] Iframe shows expiration message"),I(!0),y("Your verification link has expired."))}}catch{console.log("[Identity] Cannot check iframe content (CORS)")}}})})]}),s&&e.jsx(le,{children:e.jsx(B,{variant:"outline",onClick:s,children:"Back"})})]}):O===ue.SardinAI?e.jsxs(T,{children:[e.jsxs(se,{children:[e.jsx("h2",{className:"text-2xl font-bold",children:"Device Risk Assessment"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:"Analyzing device security and behavioral patterns..."})]}),e.jsx(M,{children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx(pe,{className:"mb-4"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:"Please wait while we verify your device security"}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-500 mt-2",children:"This process is automatic and will complete in a few seconds"})]})})]}):e.jsxs(T,{children:[e.jsxs(se,{children:[e.jsx("h2",{className:"text-2xl font-bold",children:"Identity Verification"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:"Please complete the identity verification process"})]}),e.jsx(M,{children:e.jsx("div",{id:"identity-container",className:"min-h-[400px]"})}),s&&e.jsx(le,{children:e.jsx(B,{variant:"outline",onClick:s,children:"Back"})})]})}return e.jsx("form",{onSubmit:q.handleSubmit(D),children:e.jsxs(T,{children:[e.jsxs(se,{children:[e.jsx("h2",{className:"text-lg font-bold",children:"Review Your Information"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:"Please review and confirm your information before starting identity verification"})]}),e.jsxs(M,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-4 pb-4 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-500 dark:text-gray-400",children:"Name"}),e.jsxs("p",{className:"mt-1 text-base",children:[(V=k==null?void 0:k.applicantRequestData)==null?void 0:V.firstName," ",(K=k==null?void 0:k.applicantRequestData)==null?void 0:K.lastName]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-500 dark:text-gray-400",children:"Email"}),e.jsx("p",{className:"mt-1 text-base",children:(ae=k==null?void 0:k.applicantRequestData)==null?void 0:ae.email})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-500 dark:text-gray-400",children:"Date of Birth"}),e.jsx("p",{className:"mt-1 text-base",children:((J=k==null?void 0:k.applicantRequestData)==null?void 0:J.dateOfBirth)||"Not provided"})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-lg font-semibold",children:"Address Information"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(ke.Controller,{control:q.control,name:"country",render:({field:O})=>e.jsx(be,{...O,label:"Country",options:[{value:"",label:"Select country..."},...p.map(F=>({value:F.abbreviation3||F.abbreviation,label:F.name}))]})}),e.jsx(ke.Controller,{control:q.control,name:"nationality",render:({field:O})=>e.jsx(be,{...O,label:"Nationality",options:[{value:"",label:"Select nationality..."},...p.map(F=>({value:F.abbreviation3||F.abbreviation,label:F.name}))]})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(ke.Controller,{control:q.control,name:"street",render:({field:O})=>e.jsx(ie,{...O,label:"Street"})}),e.jsx(ke.Controller,{control:q.control,name:"streetNumber",render:({field:O})=>e.jsx(ie,{...O,label:"Street Number"})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(ke.Controller,{control:q.control,name:"city",render:({field:O})=>e.jsx(ie,{...O,label:"City"})}),e.jsx(ke.Controller,{control:q.control,name:"zip",render:({field:O})=>e.jsx(ie,{...O,label:"ZIP/Postal Code"})})]}),e.jsx(ke.Controller,{control:q.control,name:"phonenumber",render:({field:O})=>e.jsx(ie,{...O,label:"Phone Number",type:"tel"})})]})]}),e.jsxs(le,{className:"flex justify-between",children:[s&&e.jsx(B,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(B,{type:"submit",isLoading:m,children:"Confirm and Start Verification"})]})]})})},Be=({kycStatus:t,reviewStatus:r,workflowResult:s,customMessage:a,onContinue:n,onContactSupport:i})=>{const c=t===we.Approved?{type:"success",title:"Verification Approved",icon:"✓",iconBg:"bg-green-100 dark:bg-green-900/30",iconColor:"text-green-600 dark:text-green-400",message:"Your identity verification has been successfully approved."}:t===we.Rejected?{type:"error",title:"Verification Rejected",icon:"✕",iconBg:"bg-red-100 dark:bg-red-900/30",iconColor:"text-red-600 dark:text-red-400",message:"Unfortunately, your identity verification was not approved."}:t===we.Pending||t===we.InProgress?{type:"pending",title:"Verification Pending",icon:"⏱",iconBg:"bg-blue-100 dark:bg-blue-900/30",iconColor:"text-blue-600 dark:text-blue-400",message:"Your identity verification is currently being processed."}:r===je.Approved?{type:"success",title:"Application Approved",icon:"✓",iconBg:"bg-green-100 dark:bg-green-900/30",iconColor:"text-green-600 dark:text-green-400",message:"Your application has been approved."}:r===je.Reject?{type:"error",title:"Application Rejected",icon:"✕",iconBg:"bg-red-100 dark:bg-red-900/30",iconColor:"text-red-600 dark:text-red-400",message:"Your application has been rejected."}:r===je.UnderReview||r===je.AdminReview?{type:"pending",title:"Under Review",icon:"📋",iconBg:"bg-yellow-100 dark:bg-yellow-900/30",iconColor:"text-yellow-700 dark:text-yellow-400",message:"Your application is currently under manual review."}:s===Re.Success?{type:"success",title:"Process Complete",icon:"✓",iconBg:"bg-green-100 dark:bg-green-900/30",iconColor:"text-green-600 dark:text-green-400",message:"Your verification process has been completed successfully."}:s===Re.Failed?{type:"error",title:"Process Failed",icon:"✕",iconBg:"bg-red-100 dark:bg-red-900/30",iconColor:"text-red-600 dark:text-red-400",message:"The verification process could not be completed."}:s===Re.AdminReview?{type:"pending",title:"Admin Review Required",icon:"📋",iconBg:"bg-yellow-100 dark:bg-yellow-900/30",iconColor:"text-yellow-700 dark:text-yellow-400",message:"Your application requires administrator review."}:{type:"pending",title:"Processing",icon:"⏱",iconBg:"bg-blue-100 dark:bg-blue-900/30",iconColor:"text-blue-600 dark:text-blue-400",message:"Your application is being reviewed."};return e.jsxs(T,{children:[e.jsxs(M,{className:"py-12",children:[e.jsx("div",{className:"flex justify-center mb-6",children:e.jsx("div",{className:`w-24 h-24 rounded-full flex items-center justify-center ${c.iconBg}`,children:e.jsx("span",{className:`text-5xl ${c.iconColor}`,children:c.icon})})}),e.jsx("h2",{className:"text-3xl font-bold text-center text-gray-900 dark:text-white mb-4",children:c.title}),e.jsx("div",{className:"flex justify-center mb-6",children:e.jsx(ye,{variant:c.type==="success"?"success":c.type==="error"?"danger":c.type==="pending"?"warning":"info",children:t!=null?we[t]:je[r]})}),e.jsx("p",{className:"text-center text-gray-600 dark:text-gray-400 mb-6 max-w-md mx-auto",children:a||c.message}),c.type==="success"&&e.jsxs("div",{className:"bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg p-4 mb-6",children:[e.jsx("h3",{className:"font-semibold text-green-900 dark:text-green-100 mb-2",children:"What's Next?"}),e.jsxs("ul",{className:"text-sm text-green-800 dark:text-green-200 space-y-1",children:[e.jsx("li",{children:"✓ Your identity has been verified"}),e.jsx("li",{children:"✓ You can now proceed with your application"}),e.jsx("li",{children:"✓ All features are now accessible"})]})]}),c.type==="error"&&e.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4 mb-6",children:[e.jsx("h3",{className:"font-semibold text-red-900 dark:text-red-100 mb-2",children:"What Can You Do?"}),e.jsxs("ul",{className:"text-sm text-red-800 dark:text-red-200 space-y-2",children:[e.jsx("li",{children:"• Review the requirements and ensure all information is correct"}),e.jsx("li",{children:"• Contact our support team for assistance"}),e.jsx("li",{children:"• You may be able to resubmit your application"})]})]}),c.type==="pending"&&e.jsxs("div",{className:"bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg p-4 mb-6",children:[e.jsx("h3",{className:"font-semibold text-blue-900 dark:text-blue-100 mb-2",children:"What Happens Next?"}),e.jsxs("ul",{className:"text-sm text-blue-800 dark:text-blue-200 space-y-2",children:[e.jsx("li",{children:"• Our team is reviewing your information"}),e.jsx("li",{children:"• You will be notified via email once the review is complete"}),e.jsx("li",{children:"• This typically takes 24-48 hours"}),e.jsx("li",{children:"• No action is required from you at this time"})]})]}),e.jsx("div",{className:"mt-6 pt-6 border-t border-gray-200 dark:border-gray-700",children:e.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:"KYC Status:"}),e.jsx("div",{className:"font-medium text-gray-900 dark:text-white mt-1",children:t!=null?we[t]:"Not Available"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:"Review Status:"}),e.jsx("div",{className:"font-medium text-gray-900 dark:text-white mt-1",children:je[r]})]})]})})]}),e.jsxs(le,{className:"flex justify-center gap-4",children:[c.type==="success"&&n&&e.jsx(B,{onClick:n,size:"lg",children:"Continue"}),c.type==="error"&&e.jsxs(e.Fragment,{children:[i&&e.jsx(B,{variant:"outline",onClick:i,children:"Contact Support"}),n&&e.jsx(B,{onClick:n,children:"Try Again"})]}),c.type==="pending"&&e.jsx("div",{className:"text-center",children:e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Please check back later or wait for our email notification"})})]})]})},sr=({config:t,className:r=""})=>!(t!=null&&t.visible)||!(t!=null&&t.url)?null:e.jsx("div",{className:`metakyc-logo ${r}`,children:e.jsx("img",{src:t.url,alt:t.alt||"Company Logo",style:{width:t.width||"auto",height:t.height||"40px",maxWidth:"100%",objectFit:"contain"},onError:s=>{console.warn("[Logo] Failed to load logo:",t.url),s.target.style.display="none"}})}),Le=({title:t,subtitle:r,className:s=""})=>{const{currentTheme:a}=de(),n=t||(a==null?void 0:a.title)||"",i=!!(a!=null&&a.logo&&a.logo.visible&&a.logo.url),o=!!n;return!i&&!o?null:e.jsxs("div",{className:`metakyc-header ${s}`,children:[e.jsxs("div",{className:"metakyc-header-title flex items-center text-xl font-bold text-gray-900 dark:text-white",children:[i&&e.jsx(sr,{config:a.logo}),i&&o&&e.jsx("span",{className:"text-gray-400 dark:text-gray-500 mx-3",style:{fontSize:"1.5rem",fontWeight:300},children:"|"}),o&&e.jsx("span",{children:n})]}),r&&e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mt-1",children:r})]})},Me=["firstName","lastName","email","phonenumber","dateOfBirth"];function Oe(t){return t==null||t===""||Array.isArray(t)&&t.length===0}const De={width:"16px",height:"16px",minWidth:"16px",flexShrink:0,flexGrow:0,accentColor:"var(--metakyc-primary, #2563eb)",cursor:"pointer",margin:0,padding:0,display:"inline-block",verticalAlign:"middle"},Dr=({workflowKey:t,externalRefId:r,onSuccess:s,onCancel:a})=>{var $,Se,ge;const{config:n,baseInformationService:i,currentTheme:o}=de(),{createApplicant:c,isLoading:d}=_t(),m=t||(($=n.applicantForm)==null?void 0:$.workflowKey);if(!m)throw new Error("workflowKey is required. Provide it either as a prop to CreateApplicantForm or set it in config.applicantForm.workflowKey");const v=r||((Se=n.applicantForm)==null?void 0:Se.externalRefId)||"",[w,x]=l.useState([]),[h,g]=l.useState(!0),k=l.useRef(!1),f=l.useRef(!1);l.useEffect(()=>{(async()=>{if(!(k.current||f.current)){k.current=!0,g(!0);try{const C=await i.getCountries("",n.locale||"en"),L=new Set;x(C.map(j=>({value:j.abbreviation3||j.abbreviation,label:j.name})).filter(j=>!j.value||L.has(j.value)?!1:(L.add(j.value),!0))),f.current=!0}catch(C){console.error("Failed to load countries:",C)}finally{g(!1),k.current=!1}}})()},[]);const p=l.useMemo(()=>o!=null&&o.applicantFormPages&&o.applicantFormPages.length>0?o.applicantFormPages:null,[o==null?void 0:o.applicantFormPages]),R=l.useMemo(()=>{const u=new Set(Me),C=o==null?void 0:o.applicantFormRequiredFields;if(C)for(const L of C)u.add(L);if(p)for(const L of p)for(const j of L.fields)!j.isCustom&&j.name&&j.required&&u.add(j.name);return Array.from(u)},[o==null?void 0:o.applicantFormRequiredFields,p]),N=l.useMemo(()=>{var L;if(p){const j=p.flatMap(U=>U.fields).filter(U=>!U.isCustom&&U.name).map(U=>U.name),E=new Set(j);for(const U of Me)E.add(U);return Array.from(E)}let u;(L=n.applicantForm)!=null&&L.visibleFields?u=n.applicantForm.visibleFields:o!=null&&o.applicantFormVisibleFields&&o.applicantFormVisibleFields.length>0?u=o.applicantFormVisibleFields:u=rt;const C=new Set(u);for(const j of Me)C.add(j);return Array.from(C)},[(ge=n.applicantForm)==null?void 0:ge.visibleFields,o==null?void 0:o.applicantFormVisibleFields,p]),[b,_]=l.useState({workflowKey:m,firstName:"",lastName:"",title:"",email:"",dateOfBirth:"",phonenumber:"",externalRefId:v,mobileCountryCode:"",street:"",streetNumber:"",zip:"",city:"",country:"",nationality:"",otherNationality:[],defaultLanguage:"EN",taxCountry:"",placeOfBirth:"",countryOfBirth:"",salutation:null,educationLevel:"",occupation:"",taxNumber:""}),[W,P]=l.useState({}),[y,S]=l.useState(0),[I,Y]=l.useState({}),[q,D]=l.useState(null),[A,V]=l.useState(!1),K=(u,C)=>_(L=>({...L,[u]:C})),ae=(u,C)=>P(L=>({...L,[u]:C})),J=l.useMemo(()=>p?p.filter(u=>!u.conditionalOn||W[u.conditionalOn]==="true"):null,[p,W]);l.useEffect(()=>{J&&y>=J.length&&J.length>0&&S(J.length-1)},[J==null?void 0:J.length]);const O=u=>{var L;const C={};for(const j of u.fields)if(j.isCustom){if(j.required&&j.paramName){const E=W[j.paramName],U=j.displayText||j.label||j.paramName;j.customType==="checkbox"||j.customType==="link_checkbox"?E!=="true"&&(C[j.paramName]=`${U} is required.`):(!E||E.trim()==="")&&(C[j.paramName]=`${U} is required.`)}}else if(j.name){const E=j.name;if(R.includes(E)&&Oe(b[E])){const U=j.displayText||((L=Fe[E])==null?void 0:L.label)||E;C[E]=`${U} is required.`}}return C},F=async u=>{var L;const C=J;if(C&&!u){const j=O(C[y]);if(Object.keys(j).length>0){Y(j);return}Y({}),S(E=>E+1);return}if(C){let j={};for(const E of C)j={...j,...O(E)};if(Object.keys(j).length>0){Y(j);return}}V(!0),D(null);try{if(!b.externalRefId||b.externalRefId.trim()===""){D("External Reference ID is required. Please pass it via config.applicantForm.externalRefId.");return}for(const H of R)if(Oe(b[H])){const Z=((L=Fe[H])==null?void 0:L.label)||H;D(`${Z} is required.`);return}const j={workflowKey:b.workflowKey,externalRefId:b.externalRefId.trim()};N.forEach(H=>{if(H==="externalRefId")return;const Z=b[H];Oe(Z)||(j[H]=Z)});const E=[];if(C){for(const H of C)for(const Z of H.fields)if(Z.isCustom&&Z.paramName){const he=W[Z.paramName]??"";E.push({paramName:Z.paramName,paramValue:he})}}E.length>0&&(j.applicantAdditionalDatas=E);const U=await c(j);s(U.applicantId)}catch(j){console.error("Error creating applicant:",j),D(j.message||"Failed to create applicant")}finally{V(!1)}},X=(u,C,L)=>{var _e;const j=Fe[u];if(!j)return null;const E=R.includes(u),U=I[u],H=L||j.label,Z=C??u,he={required:E};switch(j.type){case"select":if(u==="country"||u==="nationality"||u==="taxCountry"||u==="countryOfBirth")return e.jsx(be,{...he,label:H,value:b[u]||"",onChange:re=>K(u,re.target.value),options:[{value:"",label:`Select ${H.toLowerCase()}...`},...w],disabled:h},Z);if(u==="salutation")return e.jsx(be,{...he,label:H,value:((_e=b[u])==null?void 0:_e.toString())||"",onChange:re=>K(u,re.target.value?Number(re.target.value):null),options:[{value:"",label:"Select salutation..."},{value:Ie.Male.toString(),label:"Male"},{value:Ie.Female.toString(),label:"Female"},{value:Ie.Other.toString(),label:"Other"}]},Z);if(u==="defaultLanguage"){const re=o!=null&&o.allowedLanguages&&o.allowedLanguages.length>0?ze.filter(Te=>o.allowedLanguages.includes(Te.value)):ze;return e.jsx(be,{...he,label:H,value:b[u]||"",onChange:Te=>K(u,Te.target.value),options:[{value:"",label:"Select language..."},...re]},Z)}return null;case"multiselect":return u==="otherNationality"?e.jsx(Kt,{...he,label:H,value:b[u]||[],onChange:re=>K(u,re),options:w,placeholder:"Select other nationalities...",disabled:h},Z):null;case"date":return e.jsx(ie,{...he,type:"date",label:H,value:b[u]||"",onChange:re=>K(u,re.target.value),error:U},Z);case"email":return e.jsx(ie,{...he,type:"email",label:H,value:b[u]||"",onChange:re=>K(u,re.target.value),error:U},Z);case"tel":return e.jsx(ie,{...he,type:"tel",label:H,value:b[u]||"",onChange:re=>K(u,re.target.value),error:U},Z);default:return e.jsx(ie,{...he,type:"text",label:H,value:b[u]||"",onChange:re=>K(u,re.target.value),error:U},Z)}},G=(u,C)=>{if(!u.paramName)return null;const L=I[u.paramName],j=u.displayText||u.label||u.paramName;if(u.customType==="checkbox")return e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"checkbox",checked:W[u.paramName]==="true",onChange:E=>ae(u.paramName,E.target.checked?"true":"false"),className:"metakyc-option-input",style:De}),e.jsxs("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4"},children:[j,u.required&&e.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]})]}),L&&e.jsx("p",{className:"text-red-500 text-xs mt-0.5",children:L})]},`custom-${C}`);if(u.customType==="link_checkbox")return e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"checkbox",checked:W[u.paramName]==="true",onChange:E=>ae(u.paramName,E.target.checked?"true":"false"),className:"metakyc-option-input",style:{...De,alignSelf:"flex-start",marginTop:"2px"}}),e.jsxs("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4"},children:[j," ",u.linkUrl&&e.jsx("a",{href:u.linkUrl,target:"_blank",rel:"noopener noreferrer",className:"underline",style:{color:"var(--metakyc-primary, #2563eb)"},onClick:E=>E.stopPropagation(),children:u.linkText||u.linkUrl}),u.required&&e.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]})]}),L&&e.jsx("p",{className:"text-red-500 text-xs mt-0.5",children:L})]},`custom-${C}`);if(u.customType==="group_checkbox"){const E=(W[u.paramName]||"").split(",").filter(Boolean);return e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs("div",{className:"text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:[j,u.required&&e.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]}),e.jsx("div",{className:"metakyc-options-group",style:{display:"flex",flexDirection:"column",gap:"8px"},children:(u.options||[]).map(U=>e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"checkbox",checked:E.includes(U.value),onChange:H=>{const Z=H.target.checked?[...E,U.value]:E.filter(he=>he!==U.value);ae(u.paramName,Z.join(","))},className:"metakyc-option-input",style:De}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4"},children:U.label})]},U.value))}),L&&e.jsx("p",{className:"text-red-500 text-xs",children:L})]},`custom-${C}`)}return u.customType==="radio_group"?e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs("div",{className:"text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:[j,u.required&&e.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]}),e.jsx("div",{className:"metakyc-options-group",style:{display:"flex",flexDirection:"column",gap:"8px"},children:(u.options||[]).map(E=>e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"radio",checked:W[u.paramName]===E.value,onChange:()=>ae(u.paramName,E.value),name:`radio-group-${u.paramName}-${C}`,className:"metakyc-option-input",style:De}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4"},children:E.label})]},E.value))}),L&&e.jsx("p",{className:"text-red-500 text-xs",children:L})]},`custom-${C}`):e.jsx(ie,{type:"text",label:`${j}${u.required?" *":""}`,value:W[u.paramName]||"",onChange:E=>ae(u.paramName,E.target.value),required:u.required,error:L},`custom-${C}`)},oe=u=>e.jsx("div",{className:"grid grid-cols-2 gap-4",children:u.fields.map((C,L)=>{const j=C.colSpan===1?"col-span-1":"col-span-2",E=C.isCustom?`custom-${L}-${C.paramName}`:`builtin-${C.name}-${L}`;return e.jsx("div",{className:j,children:C.isCustom?G(C,L):X(C.name,E,C.displayText)},E)})});if(h)return e.jsx("div",{className:"metakyc-sdk",children:e.jsx(T,{children:e.jsxs(M,{children:[e.jsx(pe,{className:"my-8"}),e.jsx("p",{className:"text-center text-gray-600 dark:text-gray-400 mt-4",children:"Loading form..."})]})})});if(J){const u=J[y]??J[0],C=y===0,L=y===J.length-1,j=J.length,E=Object.values(I);return e.jsx("div",{className:"metakyc-sdk",children:e.jsxs(T,{children:[e.jsx(se,{children:e.jsx(Le,{title:(o==null?void 0:o.title)||"Create Applicant"})}),e.jsxs(M,{children:[(u.title||u.subtitle||u.description)&&e.jsxs("div",{className:"mb-4 pb-3 border-b",style:{borderColor:"var(--metakyc-border, #e5e7eb)"},children:[u.title&&e.jsx("h3",{className:"font-semibold text-base",style:{color:"var(--metakyc-text-primary, #111827)"},children:u.title}),u.subtitle&&e.jsx("p",{className:"text-sm mt-0.5",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:u.subtitle}),u.description&&u.description!==u.subtitle&&e.jsx("p",{className:"text-xs mt-1",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:u.description})]}),(q||E.length>0)&&e.jsxs("div",{className:"mb-4 p-3 bg-red-50 border border-red-200 rounded-lg",children:[q&&e.jsxs("p",{className:"text-red-600 text-sm",children:[e.jsx("strong",{children:"Error:"})," ",q]}),E.map((U,H)=>e.jsx("p",{className:"text-red-600 text-sm",children:U},H))]}),j>1&&e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[J.map((U,H)=>e.jsx("div",{className:`h-1.5 rounded-full transition-all ${H===y?"bg-blue-600 flex-1":H<y?"bg-blue-300 w-8":"bg-gray-200 w-8"}`,style:H===y?{backgroundColor:"var(--metakyc-primary, #2563eb)"}:H<y?{backgroundColor:"var(--metakyc-primary-light, #dbeafe)",opacity:.7}:void 0},H)),e.jsxs("span",{className:"text-xs text-gray-400 flex-shrink-0",children:[y+1," / ",j]})]}),oe(u)]}),e.jsxs(le,{className:"flex justify-between",children:[e.jsxs("div",{children:[!C&&e.jsx(B,{type:"button",variant:"outline",onClick:()=>{S(U=>U-1),Y({})},disabled:A||d,children:"Previous"}),C&&a&&e.jsx(B,{type:"button",variant:"outline",onClick:a,disabled:A||d,children:"Cancel"})]}),e.jsx(B,{type:"button",isLoading:A||d,onClick:()=>F(L),children:L?"Submit":"Next"})]})]})})}return e.jsx("div",{className:"metakyc-sdk",children:e.jsx("form",{onSubmit:async u=>{u.preventDefault(),await F(!0)},children:e.jsxs(T,{children:[e.jsx(se,{children:e.jsx(Le,{title:(o==null?void 0:o.title)||"Create Applicant"})}),e.jsxs(M,{children:[q&&e.jsx("div",{className:"mb-6 p-4 bg-red-50 border border-red-200 rounded-lg",children:e.jsxs("p",{className:"text-red-600 text-sm",children:[e.jsx("strong",{children:"Error:"})," ",q]})}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:N.map(u=>X(u))})]}),e.jsxs(le,{className:"flex justify-between",children:[a&&e.jsx(B,{type:"button",variant:"outline",onClick:a,disabled:A||d,children:"Cancel"}),e.jsx(B,{type:"submit",isLoading:A||d,children:"Create Applicant"})]})]})})})},Fr=({applicantId:t,onComplete:r,onError:s,theme:a="light",className:n})=>{const{progress:i,currentStep:o,steps:c,workflowKey:d,nextWorkflowKey:m,hasWorkflowChanged:v,isLoading:w,error:x,moveBack:h,refreshProgress:g}=Mt(t),[k,f]=l.useState(!1);if(l.useEffect(()=>{x&&s&&s(x)},[x,s]),l.useEffect(()=>{i!=null&&i.workflowResult&&r&&r(i.workflowResult)},[i==null?void 0:i.workflowResult,r]),l.useEffect(()=>{a==="dark"?document.documentElement.classList.add("dark"):document.documentElement.classList.remove("dark")},[a]),l.useEffect(()=>{v&&f(!1)},[v]),w||!i)return e.jsx("div",{className:n,children:e.jsx(T,{children:e.jsxs(M,{children:[e.jsx(pe,{className:"my-8"}),e.jsx("p",{className:"text-center text-gray-600 dark:text-gray-400 mt-4",children:"Loading workflow..."})]})})});if(x)return e.jsx("div",{className:n,children:e.jsx(T,{children:e.jsx(M,{children:e.jsxs("div",{className:"text-center py-8",children:[e.jsx("p",{className:"text-danger-500 text-lg mb-4",children:"An error occurred"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:x.message})]})})})});if(v&&!k)return e.jsx("div",{className:`metakyc-sdk ${n||""}`,children:e.jsx(T,{children:e.jsx(M,{children:e.jsxs("div",{className:"text-center py-8",children:[e.jsx("div",{className:"mb-6",children:e.jsx("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-full bg-blue-100 dark:bg-blue-900 mb-4",children:e.jsx("svg",{className:"w-8 h-8 text-blue-600 dark:text-blue-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})})}),e.jsx("h3",{className:"text-xl font-semibold text-gray-900 dark:text-white mb-2",children:"Workflow Transition"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mb-6",children:"Your application workflow has been updated based on your progress."}),e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-lg p-4 mb-6 max-w-md mx-auto",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-gray-500 dark:text-gray-400 mb-1",children:"Previous Workflow"}),e.jsx("p",{className:"font-medium text-gray-900 dark:text-white",children:d})]}),e.jsx("svg",{className:"w-6 h-6 text-gray-400 mx-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 7l5 5m0 0l-5 5m5-5H6"})}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-gray-500 dark:text-gray-400 mb-1",children:"New Workflow"}),e.jsx("p",{className:"font-medium text-blue-600 dark:text-blue-400",children:m})]})]}),i.nextWorkflowName&&e.jsx("p",{className:"text-center text-gray-600 dark:text-gray-400 mt-2 text-xs",children:i.nextWorkflowName})]}),e.jsx("button",{onClick:()=>f(!0),className:"px-6 py-3 bg-blue-600 hover:bg-blue-700 text-white font-medium rounded-lg transition-colors",children:"Continue with New Workflow"})]})})})});if(i.status===me.Finished||i.status===me.OnHold)return e.jsx("div",{className:`metakyc-sdk ${n||""}`,children:e.jsx(Be,{kycStatus:i.kycStatus,reviewStatus:i.reviewStatus,workflowResult:i.workflowResult,customMessage:i.customMessage,onContinue:r&&i.workflowResult?()=>r(i.workflowResult):void 0,onContactSupport:()=>{typeof window<"u"&&(window.location.href="mailto:support@example.com")}})});if(!o)return e.jsx("div",{className:`metakyc-sdk ${n||""}`,children:e.jsx(T,{children:e.jsxs(M,{children:[e.jsx(pe,{className:"my-8"}),e.jsx("p",{className:"text-center text-gray-600 dark:text-gray-400 mt-4",children:i.status===me.IdentityPending?"Loading identity verification...":"Loading current step..."})]})})});const p=b=>{switch(b){case z.Overview:return"Overview";case z.Questionaries:return"Questionnaire";case z.UploadDocument:return"Documents";case z.IdentitySdk:return"Identity";case z.RiskScoring:return"Risk Assessment";case z.InvestorCategorization:return"Investor Categorization";case z.AppropriatenessTest:return"Appropriateness Test";case z.AdditionalData:return"Additional Data";case z.ManualReview:return"Review";default:return""}},R=()=>{const b=c.filter(y=>y.visibility!==!1),_=b.findIndex(y=>y.order===o.order),W=_>=0?_+1:1,P=b.length;return e.jsxs("div",{className:"mb-6",children:[e.jsxs("div",{className:"flex items-start justify-between mb-4",children:[e.jsx(Le,{}),e.jsxs(ye,{variant:i.status===1?"info":"success",children:["Step ",W," of ",P]})]}),e.jsx("div",{className:"flex items-center",children:b.map((y,S)=>{const I=S<_,Y=y.order===o.order;return e.jsxs(l.Fragment,{children:[e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:`
|
|
65
|
+
`,children:[e.jsx("input",{type:"radio",name:`question-${D.id}`,value:V,checked:x[D.id]===V,onChange:ae=>S(D.id,ae.target.value),className:"h-4 w-4 text-primary-500 border-gray-300 focus:ring-primary-500",disabled:d}),e.jsx("span",{className:"ml-3 text-gray-700 dark:text-gray-300",children:V})]},K))})]},D.id)),v&&!R&&e.jsx("div",{className:"p-4 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg",children:e.jsxs("p",{className:"text-red-600 dark:text-red-400 text-sm",children:[e.jsx("strong",{children:"Error:"})," ",v]})}),R&&e.jsx("div",{className:"p-4 bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg",children:e.jsxs("p",{className:"text-yellow-700 dark:text-yellow-400 text-sm",children:[e.jsx("strong",{children:"Time's up!"})," Your answers are being submitted automatically."]})})]}),e.jsxs(le,{className:"flex justify-between",children:[e.jsx(B,{type:"button",variant:"outline",onClick:s,disabled:d,children:"Cancel"}),e.jsx(B,{type:"submit",isLoading:d,disabled:Object.keys(x).length<n.totalQuestionCount,children:R?"Submitting...":"Submit Test"})]})]})}):e.jsxs(T,{children:[e.jsxs(se,{children:[e.jsx("h2",{className:"text-lg font-bold text-gray-900 dark:text-white",children:n.displayName}),n.subtitle&&e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-2",children:n.subtitle})]}),e.jsxs(M,{children:[n.description&&e.jsx("div",{className:"mb-6 p-4 bg-gray-50 dark:bg-gray-800 rounded-lg",children:e.jsx("p",{className:"text-gray-700 dark:text-gray-300",children:n.description})}),e.jsxs("div",{className:"space-y-4 mb-6",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 bg-blue-50 dark:bg-blue-900/20 rounded-lg",children:[e.jsx("span",{className:"text-gray-700 dark:text-gray-300 font-medium",children:"Total Questions:"}),e.jsx(ye,{variant:"info",children:n.totalQuestionCount})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 bg-blue-50 dark:bg-blue-900/20 rounded-lg",children:[e.jsx("span",{className:"text-gray-700 dark:text-gray-300 font-medium",children:"Time Limit:"}),e.jsx(ye,{variant:"info",children:P(n.testDurationSec)})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 bg-blue-50 dark:bg-blue-900/20 rounded-lg",children:[e.jsx("span",{className:"text-gray-700 dark:text-gray-300 font-medium",children:"Correct Answers Required:"}),e.jsx(ye,{variant:"info",children:n.testCorrectAnswerPassLimit})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 bg-blue-50 dark:bg-blue-900/20 rounded-lg",children:[e.jsx("span",{className:"text-gray-700 dark:text-gray-300 font-medium",children:"Attempts Remaining:"}),e.jsx(ye,{variant:q>1?"success":"warning",children:q})]})]}),v&&e.jsx("div",{className:"mb-4 p-4 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg",children:e.jsxs("p",{className:"text-red-600 dark:text-red-400 text-sm",children:[e.jsx("strong",{children:"Previous Attempt:"})," ",v]})}),q<=0&&e.jsx("div",{className:"p-4 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg",children:e.jsx("p",{className:"text-red-600 dark:text-red-400",children:"You have used all your attempts. Please contact support for assistance."})})]}),e.jsxs(le,{className:"flex justify-between",children:[s&&e.jsx(B,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(B,{type:"button",onClick:y,disabled:q<=0,children:"Start Test"})]})]})},rr=({applicantId:t,onComplete:r,onBack:s})=>{var V,K,ae,J;const{applicantService:a,baseInformationService:n,config:i}=de(),{identityData:o,provider:c,token:d,isLoading:m,error:v,requestIdentity:w,restartIdentity:x}=$t(t),[h,g]=l.useState(null),[k,f]=l.useState(null),[p,R]=l.useState([]),[N,b]=l.useState(!0),[_,W]=l.useState(!1),[P,y]=l.useState(null),[S,I]=l.useState(!1),Y=l.useRef(!1),q=ke.useForm({defaultValues:{street:"",streetNumber:"",city:"",zip:"",country:"",nationality:"",phonenumber:""}});l.useEffect(()=>{(async()=>{try{const[F,X]=await Promise.all([a.getApplicantData(t),n.getCountries("","en")]);f(F);const G=new Set,oe=X.filter(ge=>{const u=ge.abbreviation3||ge.abbreviation;return!u||G.has(u)?!1:(G.add(u),!0)});R(oe);const $=F.applicantRequestData;if(q.reset({street:($==null?void 0:$.street)||"",streetNumber:($==null?void 0:$.streetNumber)||"",city:($==null?void 0:$.city)||"",zip:($==null?void 0:$.zip)||"",country:($==null?void 0:$.country)||"",nationality:($==null?void 0:$.nationality)||"",phonenumber:($==null?void 0:$.phonenumber)||""}),F.kycRecords&&F.kycRecords.length>0&&F.kycRecords[0].providerTokenObject!==null&&!Y.current){console.log("[Identity] Found existing identity verification, auto-requesting..."),Y.current=!0;try{await w(),W(!0)}catch(ge){console.error("[Identity] Auto-request failed:",ge)}}}catch(F){console.error("Error loading applicant data:",F)}finally{b(!1)}})()},[t]),l.useEffect(()=>{o&&!_&&(console.log("[Identity] Identity data already loaded, showing provider"),W(!0))},[o,_]),l.useEffect(()=>{if(d){if(d.expiresAt){const O=new Date(d.expiresAt).getTime();if(Date.now()>=O){console.warn("[Identity] Token has expired (expiresAt)"),I(!0),y("Your verification session has expired. Please restart.");return}}if(d.url)try{const F=new URL(d.url).toString().toLowerCase();if(F.includes("expired")||F.includes("invalid")||F.includes("error")){console.warn("[Identity] Token URL indicates expiration"),I(!0),y("Your verification link has expired. Please restart.");return}}catch{console.error("[Identity] Invalid token URL")}if(d.status==="expired"||d.error==="expired"||d.expired===!0){console.warn("[Identity] Token object indicates expiration"),I(!0),y("Your verification session has expired. Please restart.");return}}},[d]),l.useEffect(()=>{if(c!==null&&d&&!h&&_&&!S){const O=c;if(d.url){console.log("[Identity] Loading provider URL for user verification:",d.url),y(null);try{if(new URL(d.url),O===ue.SardinAI){console.log("[SardinAI] Initializing Risk SDK in background...");try{const F=Ne.parseProviderConfig(c,d,i);Ne.createProvider(c,F).initialize().then(()=>{console.log("[SardinAI] Risk SDK initialized successfully in background")}).catch(G=>{console.warn("[SardinAI] Risk SDK initialization failed (non-blocking):",G)})}catch(F){console.warn("[SardinAI] Risk SDK setup failed (non-blocking):",F)}}g({type:"url",url:d.url})}catch(F){console.error("[Identity] Invalid URL:",F),y("Invalid verification URL. Please restart."),I(!0)}return}if(O===ue.SardinAI){console.log("[SardinAI] No URL provided - initializing Risk SDK only..."),y(null);try{const F=Ne.parseProviderConfig(c,d,i),X=Ne.createProvider(c,F);X.initialize().then(()=>{console.log("[SardinAI] Risk SDK initialized successfully"),g(X),setTimeout(()=>{r==null||r()},2e3)}).catch(G=>{var $;console.error("[SardinAI] Failed to initialize:",G);const oe=(($=G.message)==null?void 0:$.toLowerCase())||"";oe.includes("expired")||oe.includes("invalid")||oe.includes("401")||oe.includes("400")?(I(!0),y("Session expired or invalid. Please restart verification.")):y(`Failed to initialize: ${G.message}`)})}catch(F){console.error("[SardinAI] Error creating provider:",F),y(`Configuration error: ${F.message}`)}return}try{y(null);const F=Ne.parseProviderConfig(c,d,i),X=Ne.createProvider(c,F);O===ue.Sumsub?(X.initialize("identity-container").catch(G=>{var oe;console.error("[Sumsub] Initialization error:",G),y(`Failed to initialize: ${G.message}`),(oe=G.message)!=null&&oe.toLowerCase().includes("expired")&&I(!0)}),X.onComplete&&X.onComplete(()=>{r==null||r()})):O===ue.Onfido&&X.initialize("identity-container").catch(G=>{console.error("[Onfido] Initialization error:",G),y(`Failed to initialize: ${G.message}`)}),g(X)}catch(F){console.error("[Identity] Provider setup error:",F),y(`Setup error: ${F.message}`)}}return()=>{if(h&&h.destroy)try{h.destroy()}catch(O){console.error("[Identity] Error destroying provider:",O)}}},[c,d,h,_,r,S]);const D=async()=>{try{y(null),I(!1),await w(),W(!0)}catch(O){console.error("Error starting identity verification:",O)}},A=async()=>{try{y(null),I(!1),g(null),console.log("[Identity] Restarting verification..."),await x(),W(!0)}catch(O){console.error("Error restarting identity verification:",O),y(O.message||"Failed to restart verification")}};if(N||m)return e.jsx(T,{children:e.jsxs(M,{children:[e.jsx(pe,{className:"my-8"}),e.jsx("p",{className:"text-center text-gray-600 dark:text-gray-400 mt-4",children:"Loading identity verification..."})]})});if(v)return e.jsx(T,{children:e.jsx(M,{children:e.jsxs("p",{className:"text-danger-500",children:["Error: ",v.message]})})});if(_&&(P||S))return e.jsxs(T,{children:[e.jsx(se,{children:e.jsx("h2",{className:"text-2xl font-bold text-gray-900 dark:text-white",children:"Verification Session Issue"})}),e.jsxs(M,{children:[e.jsx("div",{className:"p-4 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg mb-6",children:e.jsxs("div",{className:"flex items-start",children:[e.jsx("svg",{className:"h-6 w-6 text-red-600 dark:text-red-400 mr-3 mt-0.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-red-900 dark:text-red-100 mb-1",children:S?"Session Expired":"Verification Error"}),e.jsx("p",{className:"text-red-800 dark:text-red-200 text-sm",children:P||"Your verification session has expired and needs to be restarted."})]})]})}),e.jsxs("div",{className:"bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg p-4",children:[e.jsx("h3",{className:"font-semibold text-blue-900 dark:text-blue-100 mb-2",children:"What to do next:"}),e.jsxs("ul",{className:"text-blue-800 dark:text-blue-200 text-sm space-y-1 list-disc list-inside",children:[e.jsx("li",{children:'Click "Restart Verification" below to generate a new session'}),e.jsx("li",{children:"Complete the verification process without delays"}),e.jsx("li",{children:"If issues persist, contact support"})]})]})]}),e.jsxs(le,{className:"flex justify-between",children:[s&&e.jsx(B,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(B,{type:"button",onClick:A,disabled:m,children:m?"Restarting...":"Restart Verification"})]})]});if(_&&o){const O=c;return d!=null&&d.url?e.jsxs(T,{children:[e.jsx(se,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold",children:"Identity Verification"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:"Please complete the identity verification process"})]}),e.jsx(B,{type:"button",variant:"outline",size:"sm",onClick:A,disabled:m,children:"Restart"})]})}),e.jsxs(M,{children:[e.jsx("div",{className:"mb-4 p-3 bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg",children:e.jsxs("p",{className:"text-yellow-800 dark:text-yellow-200 text-sm",children:[e.jsx("strong",{children:"Important:"}),' If you see an "expired" or "invalid link" message below, click the "Restart" button above to generate a new verification session.']})}),e.jsx("div",{className:"w-full",style:{height:"600px"},children:e.jsx("iframe",{src:d.url,className:"w-full h-full border-0 rounded-lg",allow:"camera; microphone; geolocation",title:"Identity Verification",onLoad:F=>{var X,G,oe;console.log("[Identity] Iframe loaded");try{const $=F.target,Se=$.contentDocument||((X=$.contentWindow)==null?void 0:X.document);if(Se){const ge=((oe=(G=Se.body)==null?void 0:G.textContent)==null?void 0:oe.toLowerCase())||"";(ge.includes("expired")||ge.includes("invalid")||ge.includes("error"))&&(console.warn("[Identity] Iframe shows expiration message"),I(!0),y("Your verification link has expired."))}}catch{console.log("[Identity] Cannot check iframe content (CORS)")}}})})]}),s&&e.jsx(le,{children:e.jsx(B,{variant:"outline",onClick:s,children:"Back"})})]}):O===ue.SardinAI?e.jsxs(T,{children:[e.jsxs(se,{children:[e.jsx("h2",{className:"text-2xl font-bold",children:"Device Risk Assessment"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:"Analyzing device security and behavioral patterns..."})]}),e.jsx(M,{children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx(pe,{className:"mb-4"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:"Please wait while we verify your device security"}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-500 mt-2",children:"This process is automatic and will complete in a few seconds"})]})})]}):e.jsxs(T,{children:[e.jsxs(se,{children:[e.jsx("h2",{className:"text-2xl font-bold",children:"Identity Verification"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:"Please complete the identity verification process"})]}),e.jsx(M,{children:e.jsx("div",{id:"identity-container",className:"min-h-[400px]"})}),s&&e.jsx(le,{children:e.jsx(B,{variant:"outline",onClick:s,children:"Back"})})]})}return e.jsx("form",{onSubmit:q.handleSubmit(D),children:e.jsxs(T,{children:[e.jsxs(se,{children:[e.jsx("h2",{className:"text-lg font-bold",children:"Review Your Information"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:"Please review and confirm your information before starting identity verification"})]}),e.jsxs(M,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-4 pb-4 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-500 dark:text-gray-400",children:"Name"}),e.jsxs("p",{className:"mt-1 text-base",children:[(V=k==null?void 0:k.applicantRequestData)==null?void 0:V.firstName," ",(K=k==null?void 0:k.applicantRequestData)==null?void 0:K.lastName]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-500 dark:text-gray-400",children:"Email"}),e.jsx("p",{className:"mt-1 text-base",children:(ae=k==null?void 0:k.applicantRequestData)==null?void 0:ae.email})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-500 dark:text-gray-400",children:"Date of Birth"}),e.jsx("p",{className:"mt-1 text-base",children:((J=k==null?void 0:k.applicantRequestData)==null?void 0:J.dateOfBirth)||"Not provided"})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-lg font-semibold",children:"Address Information"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(ke.Controller,{control:q.control,name:"country",render:({field:O})=>e.jsx(be,{...O,label:"Country",options:[{value:"",label:"Select country..."},...p.map(F=>({value:F.abbreviation3||F.abbreviation,label:F.name}))]})}),e.jsx(ke.Controller,{control:q.control,name:"nationality",render:({field:O})=>e.jsx(be,{...O,label:"Nationality",options:[{value:"",label:"Select nationality..."},...p.map(F=>({value:F.abbreviation3||F.abbreviation,label:F.name}))]})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(ke.Controller,{control:q.control,name:"street",render:({field:O})=>e.jsx(ie,{...O,label:"Street"})}),e.jsx(ke.Controller,{control:q.control,name:"streetNumber",render:({field:O})=>e.jsx(ie,{...O,label:"Street Number"})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(ke.Controller,{control:q.control,name:"city",render:({field:O})=>e.jsx(ie,{...O,label:"City"})}),e.jsx(ke.Controller,{control:q.control,name:"zip",render:({field:O})=>e.jsx(ie,{...O,label:"ZIP/Postal Code"})})]}),e.jsx(ke.Controller,{control:q.control,name:"phonenumber",render:({field:O})=>e.jsx(ie,{...O,label:"Phone Number",type:"tel"})})]})]}),e.jsxs(le,{className:"flex justify-between",children:[s&&e.jsx(B,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(B,{type:"submit",isLoading:m,children:"Confirm and Start Verification"})]})]})})},Be=({kycStatus:t,reviewStatus:r,workflowResult:s,customMessage:a,onContinue:n,onContactSupport:i})=>{const c=t===we.Approved?{type:"success",title:"Verification Approved",icon:"✓",iconBg:"bg-green-100 dark:bg-green-900/30",iconColor:"text-green-600 dark:text-green-400",message:"Your identity verification has been successfully approved."}:t===we.Rejected?{type:"error",title:"Verification Rejected",icon:"✕",iconBg:"bg-red-100 dark:bg-red-900/30",iconColor:"text-red-600 dark:text-red-400",message:"Unfortunately, your identity verification was not approved."}:t===we.Pending||t===we.InProgress?{type:"pending",title:"Verification Pending",icon:"⏱",iconBg:"bg-blue-100 dark:bg-blue-900/30",iconColor:"text-blue-600 dark:text-blue-400",message:"Your identity verification is currently being processed."}:r===je.Approved?{type:"success",title:"Application Approved",icon:"✓",iconBg:"bg-green-100 dark:bg-green-900/30",iconColor:"text-green-600 dark:text-green-400",message:"Your application has been approved."}:r===je.Reject?{type:"error",title:"Application Rejected",icon:"✕",iconBg:"bg-red-100 dark:bg-red-900/30",iconColor:"text-red-600 dark:text-red-400",message:"Your application has been rejected."}:r===je.UnderReview||r===je.AdminReview?{type:"pending",title:"Under Review",icon:"📋",iconBg:"bg-yellow-100 dark:bg-yellow-900/30",iconColor:"text-yellow-700 dark:text-yellow-400",message:"Your application is currently under manual review."}:s===Re.Success?{type:"success",title:"Process Complete",icon:"✓",iconBg:"bg-green-100 dark:bg-green-900/30",iconColor:"text-green-600 dark:text-green-400",message:"Your verification process has been completed successfully."}:s===Re.Failed?{type:"error",title:"Process Failed",icon:"✕",iconBg:"bg-red-100 dark:bg-red-900/30",iconColor:"text-red-600 dark:text-red-400",message:"The verification process could not be completed."}:s===Re.AdminReview?{type:"pending",title:"Admin Review Required",icon:"📋",iconBg:"bg-yellow-100 dark:bg-yellow-900/30",iconColor:"text-yellow-700 dark:text-yellow-400",message:"Your application requires administrator review."}:{type:"pending",title:"Processing",icon:"⏱",iconBg:"bg-blue-100 dark:bg-blue-900/30",iconColor:"text-blue-600 dark:text-blue-400",message:"Your application is being reviewed."};return e.jsxs(T,{children:[e.jsxs(M,{className:"py-12",children:[e.jsx("div",{className:"flex justify-center mb-6",children:e.jsx("div",{className:`w-24 h-24 rounded-full flex items-center justify-center ${c.iconBg}`,children:e.jsx("span",{className:`text-5xl ${c.iconColor}`,children:c.icon})})}),e.jsx("h2",{className:"text-3xl font-bold text-center text-gray-900 dark:text-white mb-4",children:c.title}),e.jsx("div",{className:"flex justify-center mb-6",children:e.jsx(ye,{variant:c.type==="success"?"success":c.type==="error"?"danger":c.type==="pending"?"warning":"info",children:t!=null?we[t]:je[r]})}),e.jsx("p",{className:"text-center text-gray-600 dark:text-gray-400 mb-6 max-w-md mx-auto",children:a||c.message}),c.type==="success"&&e.jsxs("div",{className:"bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg p-4 mb-6",children:[e.jsx("h3",{className:"font-semibold text-green-900 dark:text-green-100 mb-2",children:"What's Next?"}),e.jsxs("ul",{className:"text-sm text-green-800 dark:text-green-200 space-y-1",children:[e.jsx("li",{children:"✓ Your identity has been verified"}),e.jsx("li",{children:"✓ You can now proceed with your application"}),e.jsx("li",{children:"✓ All features are now accessible"})]})]}),c.type==="error"&&e.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4 mb-6",children:[e.jsx("h3",{className:"font-semibold text-red-900 dark:text-red-100 mb-2",children:"What Can You Do?"}),e.jsxs("ul",{className:"text-sm text-red-800 dark:text-red-200 space-y-2",children:[e.jsx("li",{children:"• Review the requirements and ensure all information is correct"}),e.jsx("li",{children:"• Contact our support team for assistance"}),e.jsx("li",{children:"• You may be able to resubmit your application"})]})]}),c.type==="pending"&&e.jsxs("div",{className:"bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg p-4 mb-6",children:[e.jsx("h3",{className:"font-semibold text-blue-900 dark:text-blue-100 mb-2",children:"What Happens Next?"}),e.jsxs("ul",{className:"text-sm text-blue-800 dark:text-blue-200 space-y-2",children:[e.jsx("li",{children:"• Our team is reviewing your information"}),e.jsx("li",{children:"• You will be notified via email once the review is complete"}),e.jsx("li",{children:"• This typically takes 24-48 hours"}),e.jsx("li",{children:"• No action is required from you at this time"})]})]}),e.jsx("div",{className:"mt-6 pt-6 border-t border-gray-200 dark:border-gray-700",children:e.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:"KYC Status:"}),e.jsx("div",{className:"font-medium text-gray-900 dark:text-white mt-1",children:t!=null?we[t]:"Not Available"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:"Review Status:"}),e.jsx("div",{className:"font-medium text-gray-900 dark:text-white mt-1",children:je[r]})]})]})})]}),e.jsxs(le,{className:"flex justify-center gap-4",children:[c.type==="success"&&n&&e.jsx(B,{onClick:n,size:"lg",children:"Continue"}),c.type==="error"&&e.jsxs(e.Fragment,{children:[i&&e.jsx(B,{variant:"outline",onClick:i,children:"Contact Support"}),n&&e.jsx(B,{onClick:n,children:"Try Again"})]}),c.type==="pending"&&e.jsx("div",{className:"text-center",children:e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Please check back later or wait for our email notification"})})]})]})},sr=({config:t,className:r=""})=>!(t!=null&&t.visible)||!(t!=null&&t.url)?null:e.jsx("div",{className:`metakyc-logo ${r}`,children:e.jsx("img",{src:t.url,alt:t.alt||"Company Logo",style:{width:t.width||"auto",height:t.height||"40px",maxWidth:"100%",objectFit:"contain"},onError:s=>{console.warn("[Logo] Failed to load logo:",t.url),s.target.style.display="none"}})}),Le=({title:t,subtitle:r,className:s=""})=>{const{currentTheme:a}=de(),n=t||(a==null?void 0:a.title)||"",i=!!(a!=null&&a.logo&&a.logo.visible&&a.logo.url),o=!!n;return!i&&!o?null:e.jsxs("div",{className:`metakyc-header ${s}`,children:[e.jsxs("div",{className:"metakyc-header-title flex items-center text-xl font-bold text-gray-900 dark:text-white",children:[i&&e.jsx(sr,{config:a.logo}),i&&o&&e.jsx("span",{className:"text-gray-400 dark:text-gray-500 mx-3",style:{fontSize:"1.5rem",fontWeight:300},children:"|"}),o&&e.jsx("span",{children:n})]}),r&&e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mt-1",children:r})]})},Me=["firstName","lastName","email","phonenumber","dateOfBirth"];function Oe(t){return t==null||t===""||Array.isArray(t)&&t.length===0}const De={width:"16px",height:"16px",minWidth:"16px",flexShrink:0,flexGrow:0,accentColor:"var(--metakyc-primary, #2563eb)",cursor:"pointer",margin:0,padding:0,display:"inline-block",verticalAlign:"middle"},Dr=({workflowKey:t,externalRefId:r,onSuccess:s,onCancel:a})=>{var $,Se,ge;const{config:n,baseInformationService:i,currentTheme:o}=de(),{createApplicant:c,isLoading:d}=_t(),m=t||(($=n.applicantForm)==null?void 0:$.workflowKey);if(!m)throw new Error("workflowKey is required. Provide it either as a prop to CreateApplicantForm or set it in config.applicantForm.workflowKey");const v=r||((Se=n.applicantForm)==null?void 0:Se.externalRefId)||"",[w,x]=l.useState([]),[h,g]=l.useState(!0),k=l.useRef(!1),f=l.useRef(!1);l.useEffect(()=>{(async()=>{if(!(k.current||f.current)){k.current=!0,g(!0);try{const C=await i.getCountries("",n.locale||"en"),L=new Set;x(C.map(j=>({value:j.abbreviation3||j.abbreviation,label:j.name})).filter(j=>!j.value||L.has(j.value)?!1:(L.add(j.value),!0))),f.current=!0}catch(C){console.error("Failed to load countries:",C)}finally{g(!1),k.current=!1}}})()},[]);const p=l.useMemo(()=>o!=null&&o.applicantFormPages&&o.applicantFormPages.length>0?o.applicantFormPages:null,[o==null?void 0:o.applicantFormPages]),R=l.useMemo(()=>{const u=new Set(Me),C=o==null?void 0:o.applicantFormRequiredFields;if(C)for(const L of C)u.add(L);if(p)for(const L of p)for(const j of L.fields)!j.isCustom&&j.name&&j.required&&u.add(j.name);return Array.from(u)},[o==null?void 0:o.applicantFormRequiredFields,p]),N=l.useMemo(()=>{var L;if(p){const j=p.flatMap(U=>U.fields).filter(U=>!U.isCustom&&U.name).map(U=>U.name),E=new Set(j);for(const U of Me)E.add(U);return Array.from(E)}let u;(L=n.applicantForm)!=null&&L.visibleFields?u=n.applicantForm.visibleFields:o!=null&&o.applicantFormVisibleFields&&o.applicantFormVisibleFields.length>0?u=o.applicantFormVisibleFields:u=rt;const C=new Set(u);for(const j of Me)C.add(j);return Array.from(C)},[(ge=n.applicantForm)==null?void 0:ge.visibleFields,o==null?void 0:o.applicantFormVisibleFields,p]),[b,_]=l.useState({workflowKey:m,firstName:"",lastName:"",title:"",email:"",dateOfBirth:"",phonenumber:"",externalRefId:v,mobileCountryCode:"",street:"",streetNumber:"",zip:"",city:"",country:"",nationality:"",otherNationality:[],defaultLanguage:"EN",taxCountry:"",placeOfBirth:"",countryOfBirth:"",salutation:null,educationLevel:"",occupation:"",taxNumber:""}),[W,P]=l.useState({}),[y,S]=l.useState(0),[I,Y]=l.useState({}),[q,D]=l.useState(null),[A,V]=l.useState(!1),K=(u,C)=>_(L=>({...L,[u]:C})),ae=(u,C)=>P(L=>({...L,[u]:C})),J=l.useMemo(()=>p?p.filter(u=>!u.conditionalOn||W[u.conditionalOn]==="true"):null,[p,W]);l.useEffect(()=>{J&&y>=J.length&&J.length>0&&S(J.length-1)},[J==null?void 0:J.length]);const O=u=>{var L;const C={};for(const j of u.fields)if(j.isCustom){if(j.required&&j.paramName){const E=W[j.paramName],U=j.displayText||j.label||j.paramName;j.customType==="checkbox"||j.customType==="link_checkbox"?E!=="true"&&(C[j.paramName]=`${U} is required.`):(!E||E.trim()==="")&&(C[j.paramName]=`${U} is required.`)}}else if(j.name){const E=j.name;if(R.includes(E)&&Oe(b[E])){const U=j.displayText||((L=Fe[E])==null?void 0:L.label)||E;C[E]=`${U} is required.`}}return C},F=async u=>{var L;const C=J;if(C&&!u){const j=O(C[y]);if(Object.keys(j).length>0){Y(j);return}Y({}),S(E=>E+1);return}if(C){let j={};for(const E of C)j={...j,...O(E)};if(Object.keys(j).length>0){Y(j);return}}V(!0),D(null);try{if(!b.externalRefId||b.externalRefId.trim()===""){D("External Reference ID is required. Please pass it via config.applicantForm.externalRefId.");return}for(const H of R)if(Oe(b[H])){const Z=((L=Fe[H])==null?void 0:L.label)||H;D(`${Z} is required.`);return}const j={workflowKey:b.workflowKey,externalRefId:b.externalRefId.trim()};N.forEach(H=>{if(H==="externalRefId")return;const Z=b[H];Oe(Z)||(j[H]=Z)});const E=[];if(C){for(const H of C)for(const Z of H.fields)if(Z.isCustom&&Z.paramName){const he=W[Z.paramName]??"";E.push({paramName:Z.paramName,paramValue:he})}}E.length>0&&(j.applicantAdditionalDatas=E);const U=await c(j);s(U.applicantId)}catch(j){console.error("Error creating applicant:",j),D(j.message||"Failed to create applicant")}finally{V(!1)}},X=(u,C,L)=>{var _e;const j=Fe[u];if(!j)return null;const E=R.includes(u),U=I[u],H=L||j.label,Z=C??u,he={required:E};switch(j.type){case"select":if(u==="country"||u==="nationality"||u==="taxCountry"||u==="countryOfBirth")return e.jsx(be,{...he,label:H,value:b[u]||"",onChange:re=>K(u,re.target.value),options:[{value:"",label:`Select ${H.toLowerCase()}...`},...w],disabled:h},Z);if(u==="salutation")return e.jsx(be,{...he,label:H,value:((_e=b[u])==null?void 0:_e.toString())||"",onChange:re=>K(u,re.target.value?Number(re.target.value):null),options:[{value:"",label:"Select salutation..."},{value:Ie.Male.toString(),label:"Male"},{value:Ie.Female.toString(),label:"Female"},{value:Ie.Other.toString(),label:"Other"}]},Z);if(u==="defaultLanguage"){const re=o!=null&&o.allowedLanguages&&o.allowedLanguages.length>0?ze.filter(Te=>o.allowedLanguages.includes(Te.value)):ze;return e.jsx(be,{...he,label:H,value:b[u]||"",onChange:Te=>K(u,Te.target.value),options:[{value:"",label:"Select language..."},...re]},Z)}return null;case"multiselect":return u==="otherNationality"?e.jsx(Kt,{...he,label:H,value:b[u]||[],onChange:re=>K(u,re),options:w,placeholder:"Select other nationalities...",disabled:h},Z):null;case"date":return e.jsx(ie,{...he,type:"date",label:H,value:b[u]||"",onChange:re=>K(u,re.target.value),error:U},Z);case"email":return e.jsx(ie,{...he,type:"email",label:H,value:b[u]||"",onChange:re=>K(u,re.target.value),error:U},Z);case"tel":return e.jsx(ie,{...he,type:"tel",label:H,value:b[u]||"",onChange:re=>K(u,re.target.value),error:U},Z);default:return e.jsx(ie,{...he,type:"text",label:H,value:b[u]||"",onChange:re=>K(u,re.target.value),error:U},Z)}},G=(u,C)=>{if(!u.paramName)return null;const L=I[u.paramName],j=u.displayText||u.label||u.paramName;if(u.customType==="checkbox")return e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"checkbox",checked:W[u.paramName]==="true",onChange:E=>ae(u.paramName,E.target.checked?"true":"false"),className:"metakyc-option-input",style:De}),e.jsxs("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4"},children:[j,u.required&&e.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]})]}),L&&e.jsx("p",{className:"text-red-500 text-xs mt-0.5",children:L})]},`custom-${C}`);if(u.customType==="link_checkbox")return e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"checkbox",checked:W[u.paramName]==="true",onChange:E=>ae(u.paramName,E.target.checked?"true":"false"),className:"metakyc-option-input",style:{...De,alignSelf:"flex-start",marginTop:"2px"}}),e.jsxs("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4"},children:[j," ",u.linkUrl&&e.jsx("a",{href:u.linkUrl,target:"_blank",rel:"noopener noreferrer",className:"underline",style:{color:"var(--metakyc-primary, #2563eb)"},onClick:E=>E.stopPropagation(),children:u.linkText||u.linkUrl}),u.required&&e.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]})]}),L&&e.jsx("p",{className:"text-red-500 text-xs mt-0.5",children:L})]},`custom-${C}`);if(u.customType==="group_checkbox"){const E=(W[u.paramName]||"").split(",").filter(Boolean);return e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs("div",{className:"text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:[j,u.required&&e.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]}),e.jsx("div",{className:"metakyc-options-group",style:{display:"flex",flexDirection:"column",gap:"8px"},children:(u.options||[]).map(U=>e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"checkbox",checked:E.includes(U.value),onChange:H=>{const Z=H.target.checked?[...E,U.value]:E.filter(he=>he!==U.value);ae(u.paramName,Z.join(","))},className:"metakyc-option-input",style:De}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4"},children:U.label})]},U.value))}),L&&e.jsx("p",{className:"text-red-500 text-xs",children:L})]},`custom-${C}`)}return u.customType==="radio_group"?e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs("div",{className:"text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:[j,u.required&&e.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]}),e.jsx("div",{className:"metakyc-options-group",style:{display:"flex",flexDirection:"column",gap:"8px"},children:(u.options||[]).map(E=>e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"radio",checked:W[u.paramName]===E.value,onChange:()=>ae(u.paramName,E.value),name:`radio-group-${u.paramName}-${C}`,className:"metakyc-option-input",style:De}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4"},children:E.label})]},E.value))}),L&&e.jsx("p",{className:"text-red-500 text-xs",children:L})]},`custom-${C}`):e.jsx(ie,{type:"text",label:`${j}${u.required?" *":""}`,value:W[u.paramName]||"",onChange:E=>ae(u.paramName,E.target.value),required:u.required,error:L},`custom-${C}`)},oe=u=>e.jsx("div",{className:"grid grid-cols-2 gap-4",children:u.fields.map((C,L)=>{const j=C.colSpan===1?"col-span-1":"col-span-2",E=C.isCustom?`custom-${L}-${C.paramName}`:`builtin-${C.name}-${L}`;return e.jsx("div",{className:j,children:C.isCustom?G(C,L):X(C.name,E,C.displayText)},E)})});if(h)return e.jsx("div",{className:"metakyc-sdk",children:e.jsx(T,{children:e.jsxs(M,{children:[e.jsx(pe,{className:"my-8"}),e.jsx("p",{className:"text-center text-gray-600 dark:text-gray-400 mt-4",children:"Loading form..."})]})})});if(J){const u=J[y]??J[0],C=y===0,L=y===J.length-1,j=J.length,E=Object.values(I);return e.jsx("div",{className:"metakyc-sdk",children:e.jsxs(T,{children:[e.jsx(se,{children:e.jsx(Le,{title:(o==null?void 0:o.title)||"Create Applicant"})}),e.jsxs(M,{children:[(u.title||u.subtitle||u.description)&&e.jsxs("div",{className:"mb-4",children:[u.title&&e.jsx("h3",{className:"font-semibold text-base",style:{color:"var(--metakyc-text-primary, #111827)"},children:u.title}),u.subtitle&&e.jsx("p",{className:"text-sm mt-0.5",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:u.subtitle}),u.description&&u.description!==u.subtitle&&e.jsx("p",{className:"text-xs mt-1",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:u.description})]}),(q||E.length>0)&&e.jsxs("div",{className:"mb-4 p-3 bg-red-50 border border-red-200 rounded-lg",children:[q&&e.jsxs("p",{className:"text-red-600 text-sm",children:[e.jsx("strong",{children:"Error:"})," ",q]}),E.map((U,H)=>e.jsx("p",{className:"text-red-600 text-sm",children:U},H))]}),j>1&&e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[J.map((U,H)=>e.jsx("div",{className:`h-1.5 rounded-full transition-all ${H===y?"bg-blue-600 flex-1":H<y?"bg-blue-300 w-8":"bg-gray-200 w-8"}`,style:H===y?{backgroundColor:"var(--metakyc-primary, #2563eb)"}:H<y?{backgroundColor:"var(--metakyc-primary-light, #dbeafe)",opacity:.7}:void 0},H)),e.jsxs("span",{className:"text-xs text-gray-400 flex-shrink-0",children:[y+1," / ",j]})]}),oe(u)]}),e.jsxs(le,{className:"flex justify-between",children:[e.jsxs("div",{children:[!C&&e.jsx(B,{type:"button",variant:"outline",onClick:()=>{S(U=>U-1),Y({})},disabled:A||d,children:"Previous"}),C&&a&&e.jsx(B,{type:"button",variant:"outline",onClick:a,disabled:A||d,children:"Cancel"})]}),e.jsx(B,{type:"button",isLoading:A||d,onClick:()=>F(L),children:L?"Submit":"Next"})]})]})})}return e.jsx("div",{className:"metakyc-sdk",children:e.jsx("form",{onSubmit:async u=>{u.preventDefault(),await F(!0)},children:e.jsxs(T,{children:[e.jsx(se,{children:e.jsx(Le,{title:(o==null?void 0:o.title)||"Create Applicant"})}),e.jsxs(M,{children:[q&&e.jsx("div",{className:"mb-6 p-4 bg-red-50 border border-red-200 rounded-lg",children:e.jsxs("p",{className:"text-red-600 text-sm",children:[e.jsx("strong",{children:"Error:"})," ",q]})}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:N.map(u=>X(u))})]}),e.jsxs(le,{className:"flex justify-between",children:[a&&e.jsx(B,{type:"button",variant:"outline",onClick:a,disabled:A||d,children:"Cancel"}),e.jsx(B,{type:"submit",isLoading:A||d,children:"Create Applicant"})]})]})})})},Fr=({applicantId:t,onComplete:r,onError:s,theme:a="light",className:n})=>{const{progress:i,currentStep:o,steps:c,workflowKey:d,nextWorkflowKey:m,hasWorkflowChanged:v,isLoading:w,error:x,moveBack:h,refreshProgress:g}=Mt(t),[k,f]=l.useState(!1);if(l.useEffect(()=>{x&&s&&s(x)},[x,s]),l.useEffect(()=>{i!=null&&i.workflowResult&&r&&r(i.workflowResult)},[i==null?void 0:i.workflowResult,r]),l.useEffect(()=>{a==="dark"?document.documentElement.classList.add("dark"):document.documentElement.classList.remove("dark")},[a]),l.useEffect(()=>{v&&f(!1)},[v]),w||!i)return e.jsx("div",{className:n,children:e.jsx(T,{children:e.jsxs(M,{children:[e.jsx(pe,{className:"my-8"}),e.jsx("p",{className:"text-center text-gray-600 dark:text-gray-400 mt-4",children:"Loading workflow..."})]})})});if(x)return e.jsx("div",{className:n,children:e.jsx(T,{children:e.jsx(M,{children:e.jsxs("div",{className:"text-center py-8",children:[e.jsx("p",{className:"text-danger-500 text-lg mb-4",children:"An error occurred"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:x.message})]})})})});if(v&&!k)return e.jsx("div",{className:`metakyc-sdk ${n||""}`,children:e.jsx(T,{children:e.jsx(M,{children:e.jsxs("div",{className:"text-center py-8",children:[e.jsx("div",{className:"mb-6",children:e.jsx("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-full bg-blue-100 dark:bg-blue-900 mb-4",children:e.jsx("svg",{className:"w-8 h-8 text-blue-600 dark:text-blue-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})})}),e.jsx("h3",{className:"text-xl font-semibold text-gray-900 dark:text-white mb-2",children:"Workflow Transition"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mb-6",children:"Your application workflow has been updated based on your progress."}),e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-lg p-4 mb-6 max-w-md mx-auto",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-gray-500 dark:text-gray-400 mb-1",children:"Previous Workflow"}),e.jsx("p",{className:"font-medium text-gray-900 dark:text-white",children:d})]}),e.jsx("svg",{className:"w-6 h-6 text-gray-400 mx-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 7l5 5m0 0l-5 5m5-5H6"})}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-gray-500 dark:text-gray-400 mb-1",children:"New Workflow"}),e.jsx("p",{className:"font-medium text-blue-600 dark:text-blue-400",children:m})]})]}),i.nextWorkflowName&&e.jsx("p",{className:"text-center text-gray-600 dark:text-gray-400 mt-2 text-xs",children:i.nextWorkflowName})]}),e.jsx("button",{onClick:()=>f(!0),className:"px-6 py-3 bg-blue-600 hover:bg-blue-700 text-white font-medium rounded-lg transition-colors",children:"Continue with New Workflow"})]})})})});if(i.status===me.Finished||i.status===me.OnHold)return e.jsx("div",{className:`metakyc-sdk ${n||""}`,children:e.jsx(Be,{kycStatus:i.kycStatus,reviewStatus:i.reviewStatus,workflowResult:i.workflowResult,customMessage:i.customMessage,onContinue:r&&i.workflowResult?()=>r(i.workflowResult):void 0,onContactSupport:()=>{typeof window<"u"&&(window.location.href="mailto:support@example.com")}})});if(!o)return e.jsx("div",{className:`metakyc-sdk ${n||""}`,children:e.jsx(T,{children:e.jsxs(M,{children:[e.jsx(pe,{className:"my-8"}),e.jsx("p",{className:"text-center text-gray-600 dark:text-gray-400 mt-4",children:i.status===me.IdentityPending?"Loading identity verification...":"Loading current step..."})]})})});const p=b=>{switch(b){case z.Overview:return"Overview";case z.Questionaries:return"Questionnaire";case z.UploadDocument:return"Documents";case z.IdentitySdk:return"Identity";case z.RiskScoring:return"Risk Assessment";case z.InvestorCategorization:return"Investor Categorization";case z.AppropriatenessTest:return"Appropriateness Test";case z.AdditionalData:return"Additional Data";case z.ManualReview:return"Review";default:return""}},R=()=>{const b=c.filter(y=>y.visibility!==!1),_=b.findIndex(y=>y.order===o.order),W=_>=0?_+1:1,P=b.length;return e.jsxs("div",{className:"mb-6",children:[e.jsxs("div",{className:"flex items-start justify-between mb-4",children:[e.jsx(Le,{}),e.jsxs(ye,{variant:i.status===1?"info":"success",children:["Step ",W," of ",P]})]}),e.jsx("div",{className:"flex items-center",children:b.map((y,S)=>{const I=S<_,Y=y.order===o.order;return e.jsxs(l.Fragment,{children:[e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:`
|
|
66
66
|
w-8 h-8 rounded-full flex items-center justify-center text-sm font-medium
|
|
67
67
|
${I||Y?"bg-primary-500 text-white":"bg-gray-200 text-gray-600 dark:bg-gray-700 dark:text-gray-400"}
|
|
68
68
|
`,children:S+1}),e.jsx("span",{className:`ml-2 text-sm ${Y?"font-semibold text-gray-900 dark:text-white":"text-gray-600 dark:text-gray-400"}`,children:y.displayName||y.name||p(y.action)||`Step ${S+1}`})]}),S<b.length-1&&e.jsx("div",{className:`flex-1 h-0.5 mx-4 ${I?"bg-primary-500":"bg-gray-200 dark:bg-gray-700"}`})]},y.order)})})]})},N=()=>{const b={applicantId:t,onComplete:async()=>{await g()},onBack:o.order>0?h:void 0};switch(o.action){case z.Questionaries:return e.jsx(Gt,{...b});case z.UploadDocument:return e.jsx(Zt,{...b});case z.Overview:return e.jsx(Jt,{...b});case z.IdentitySdk:return e.jsx(rr,{...b});case z.RiskScoring:return e.jsx(Xt,{...b});case z.AdditionalData:case z.InvestorCategorization:return e.jsx(er,{...b});case z.AppropriatenessTest:return e.jsx(tr,{...b});case z.ManualReview:return e.jsx(Be,{kycStatus:i.kycStatus,reviewStatus:i.reviewStatus,workflowResult:i.workflowResult,customMessage:i.customMessage});default:return e.jsx(T,{children:e.jsxs(M,{className:"py-12 text-center",children:[e.jsx("div",{className:"mb-4",children:e.jsx(pe,{})}),e.jsxs("p",{className:"text-gray-600 dark:text-gray-400 mb-2",children:["Processing step: ",o.title||o.name]}),e.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:["Action type: ",z[o.action]]})]})})}};return e.jsxs("div",{className:`metakyc-sdk ${n||""}`,children:[R(),N()]})};function Pr(t){return ve.z.object({questionResults:ve.z.any()}).passthrough()}function Lr(t){let r=ve.z.array(ve.z.instanceof(File));if(t.isRequired?r=r.min(1,`${t.displayName} is required`):r=r.optional(),t.multipleFile||(r=r.refine(s=>!s||s.length<=1,{message:"Only one file is allowed"})),t.maxEachFileSizeByte>0&&(r=r.refine(s=>!s||s.every(a=>a.size<=t.maxEachFileSizeByte),{message:`File size must not exceed ${Math.round(t.maxEachFileSizeByte/1024/1024)}MB`})),t.allowedTypes){const s=t.allowedTypes.split(",").map(a=>a.trim());r=r.refine(a=>a?a.every(n=>s.some(i=>i.endsWith("/*")?n.type.startsWith(i.slice(0,-2)):n.type===i)):!0,{message:"Invalid file type"})}return r}function Tr(t){const r={};return t.uploadDocumentFiles.forEach(s=>{const a=`file_${s.id}`;r[a]=Lr(s)}),ve.z.object(r)}function Mr(t){return ve.z.any()}function Or(t){return ve.z.string().min(1,"This question is required")}function zr(t){const r={};return t.appropriatenessQuestions.forEach(s=>{const a=`question_${s.id}`;r[a]=Or()}),ve.z.object(r)}const Br=ve.z.any();exports.ALLOWED_LANGUAGES=ze;exports.ApplicantProgressOnHoldReason=He;exports.ApplicantProgressStatus=me;exports.ApplicantService=it;exports.ApplicantStatus=Ye;exports.AppropriatenessQuestionType=Je;exports.AppropriatenessTestService=ct;exports.AppropriatenessTestStep=tr;exports.Badge=ye;exports.BaseInformationService=pt;exports.Button=B;exports.Card=T;exports.CardContent=M;exports.CardFooter=le;exports.CardHeader=se;exports.CreateApplicantForm=Dr;exports.CriteriaBuiltInType=et;exports.DEFAULT_VISIBLE_FIELDS=rt;exports.DocumentReviewStatus=Ze;exports.EndpointBuilder=at;exports.ErrorHandler=Ce;exports.EventEmitter=wt;exports.FIELD_METADATA=Fe;exports.FileType=Ge;exports.FileUpload=qt;exports.GenderType=Ie;exports.Header=Le;exports.HttpClient=nt;exports.IdentityProviderManager=Ne;exports.IdentityService=mt;exports.IdentityVerificationProvider=ue;exports.IdentityVerificationStep=rr;exports.Input=ie;exports.InvestorCategorizationService=ht;exports.InvestorCategorizationStep=er;exports.InvestorCategorizationType=ce;exports.InvestorCategoryType=tt;exports.KycProcessStatus=Qe;exports.KycStatus=we;exports.KycStatusDisplay=Be;exports.KycWorkflow=Fr;exports.Logo=sr;exports.MetaKYCContext=Ue;exports.MetaKYCError=xe;exports.MetaKYCProvider=dr;exports.MultiSelect=Kt;exports.OnfidoProvider=At;exports.OverviewService=dt;exports.OverviewStep=Jt;exports.PhoneInput=Ht;exports.QuestionnaireService=lt;exports.QuestionnaireStep=Gt;exports.ReviewStatus=je;exports.RiskCriteriaType=Xe;exports.RiskLevel=We;exports.RiskScoringService=ut;exports.RiskScoringStep=Xt;exports.SardinAIProvider=Et;exports.Select=be;exports.Spinner=pe;exports.StepRouter=Nt;exports.SumsubProvider=Ct;exports.ThemeManager=Rt;exports.ThemePreset=ee;exports.ThemeService=kt;exports.UploadDocumentService=ot;exports.UploadDocumentStep=Zt;exports.UserType=Ve;exports.ValueDataType=fe;exports.WorkflowOrchestrator=St;exports.WorkflowResultType=Re;exports.WorkflowState=jt;exports.WorkflowStepAction=z;exports.appropriatenessTestSchema=Br;exports.clearAllStorage=gr;exports.clearApplicantId=Pt;exports.clearWorkflowState=Tt;exports.cn=te;exports.corporateTheme=gt;exports.defaultConfig=st;exports.defaultTheme=ne;exports.fileToBase64=It;exports.fintechTheme=xt;exports.formatFileSize=Pe;exports.generateAppropriatenessSchema=zr;exports.generateQuestionnaireSchema=Pr;exports.generateRiskScoringSchema=Mr;exports.generateUploadDocumentSchema=Tr;exports.getAcceptString=pr;exports.getApplicantId=Ft;exports.getThemePreset=Ae;exports.getWorkflowState=hr;exports.healthcareTheme=yt;exports.isScriptLoaded=or;exports.loadScript=$e;exports.minimalTheme=bt;exports.modernTheme=ft;exports.removeScript=cr;exports.saveApplicantId=Dt;exports.saveWorkflowState=Lt;exports.themePresets=vt;exports.useApplicant=_t;exports.useAppropriatenessTest=xr;exports.useIdentityVerification=$t;exports.useKycWorkflow=Mt;exports.useMetaKYC=de;exports.useOverview=Bt;exports.useQuestionnaire=Ot;exports.useRiskScoring=Ut;exports.useUploadDocument=zt;exports.validateFileSize=ur;exports.validateFileType=mr;
|