@vpdev2/metakyc-sdk 1.0.75 → 1.0.76
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/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +7 -6
- package/dist/index.js.map +1 -1
- package/dist/theme/theme-manager.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var vr=Object.defineProperty;var kr=(t,r,s)=>r in t?vr(t,r,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[r]=s;var X=(t,r,s)=>kr(t,typeof r!="symbol"?r+"":r,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const wr=require("axios"),l=require("react"),e=require("react/jsx-runtime"),qe=require("react-dom"),Se=require("react-hook-form"),we=require("zod");function jr(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 rt=jr(l);var G=(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))(G||{}),He=(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))(He||{}),xe=(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))(xe||{}),ot=(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))(ot||{}),lt=(t=>(t[t.LowRisk=0]="LowRisk",t[t.MediumRisk=1]="MediumRisk",t[t.HighRisk=2]="HighRisk",t[t.Alert=3]="Alert",t))(lt||{}),Ne=(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))(Ne||{}),Ce=(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))(Ce||{}),ct=(t=>(t[t.ProviderResultPending=0]="ProviderResultPending",t[t.ProviderResultReceived=1]="ProviderResultReceived",t[t.Canceled=2]="Canceled",t[t.ExtendedToNewApplicant=3]="ExtendedToNewApplicant",t))(ct||{}),dt=(t=>(t[t.None=0]="None",t[t.ProviderResultPending=1]="ProviderResultPending",t[t.ProviderResultReceived=2]="ProviderResultReceived",t[t.Canceled=3]="Canceled",t))(dt||{}),he=(t=>(t[t.Onfido=0]="Onfido",t[t.Sumsub=2]="Sumsub",t[t.SardinAI=3]="SardinAI",t))(he||{}),ut=(t=>(t[t.Individual=0]="Individual",t[t.Company=1]="Company",t))(ut||{}),Ue=(t=>(t[t.Male=0]="Male",t[t.Female=1]="Female",t[t.Other=2]="Other",t))(Ue||{}),pt=(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))(pt||{}),mt=(t=>(t[t.Pending=0]="Pending",t[t.Approved=1]="Approved",t[t.Rejected=2]="Rejected",t[t.RequiresRevision=3]="RequiresRevision",t))(mt||{}),ht=(t=>(t[t.SingleChoice=0]="SingleChoice",t[t.MultipleChoice=1]="MultipleChoice",t[t.Text=2]="Text",t))(ht||{}),be=(t=>(t[t.String=0]="String",t[t.Integer=1]="Integer",t[t.Money=2]="Money",t[t.Boolean=3]="Boolean",t[t.Date=4]="Date",t[t.Country=5]="Country",t[t.DigitOnly=6]="DigitOnly",t))(be||{}),xt=(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))(xt||{}),gt=(t=>(t[t.None=0]="None",t[t.Country=1]="Country",t))(gt||{}),pe=(t=>(t[t.Individual=0]="Individual",t[t.Sophisticated=1]="Sophisticated",t[t.HighNetWorth=2]="HighNetWorth",t[t.Business=3]="Business",t))(pe||{}),yt=(t=>(t[t.Retail=0]="Retail",t[t.Professional=1]="Professional",t[t.EligibleCounterparty=2]="EligibleCounterparty",t))(yt||{});const Ie={Nationality:10,Address:20,CountryOfBirth:30,PhoneNumber:40,UboAddress:50},Re={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:"select",countriesType:Ie.PhoneNumber},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",countriesType:Ie.Address},nationality:{label:"Nationality",type:"select",countriesType:Ie.Nationality},otherNationality:{label:"Other Nationalities",type:"multiselect",countriesType:Ie.Nationality},countryOfBirth:{label:"Country of Birth",type:"select",countriesType:Ie.CountryOfBirth},placeOfBirth:{label:"Place of Birth",type:"text"},taxCountry:{label:"Tax Country",type:"select",countriesType:Ie.Address},taxNumber:{label:"Tax Number",type:"text"},defaultLanguage:{label:"Default Language",type:"select"},educationLevel:{label:"Education Level",type:"text"},occupation:{label:"Occupation",type:"text"}},ft=["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 ae=(t=>(t.Default="default",t.Corporate="corporate",t.Fintech="fintech",t.Healthcare="healthcare",t.Modern="modern",t.Minimal="minimal",t))(ae||{});const bt={timeout:3e4,retries:3,locale:"en",endpoints:{pattern:"host-controller"}};class vt{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 fe extends Error{constructor(s,a,i,o,c){super(s);X(this,"response");this.code=a,this.details=i,this.validationErrors=o,this.name="MetaKYCError",this.response=c,Object.setPrototypeOf(this,fe.prototype)}}class Fe{static handleApiError(r){return new fe(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 fe(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 fe(s.result.message,r.response.status,`HTTP ${r.response.status}: ${r.response.statusText}`,void 0,r.response):new fe((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 fe("No response from server",0,"The request was made but no response was received. Please check your network connection."):new fe(r.message||"An unexpected error occurred",0,r.toString())}static isMetaKYCError(r){return r instanceof fe}}class kt{constructor(r){X(this,"axiosInstance");X(this,"endpointBuilder");X(this,"config");this.config={...bt,...r},this.endpointBuilder=new vt(this.config.endpoints),this.axiosInstance=wr.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 i;const a=s.config;return((i=s.response)==null?void 0:i.status)>=500&&!a._retry&&(a._retry=!0,a._retryCount=(a._retryCount||0)+1,a._retryCount<(this.config.retries||3))?(await new Promise(o=>setTimeout(o,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 i=this.buildEndpoint(r,s),o=await this.axiosInstance.get(i,{params:a});return this.handleResponse(o)}catch(i){throw Fe.handleAxiosError(i)}}async post(r,s,a){try{const i=this.buildEndpoint(r,s),o=await this.axiosInstance.post(i,a);return this.handleResponse(o)}catch(i){throw Fe.handleAxiosError(i)}}async put(r,s,a){try{const i=this.buildEndpoint(r,s),o=await this.axiosInstance.put(i,a);return this.handleResponse(o)}catch(i){throw Fe.handleAxiosError(i)}}async delete(r,s,a){try{const i=this.buildEndpoint(r,s),o=await this.axiosInstance.delete(i,{params:a});return this.handleResponse(o)}catch(i){throw Fe.handleAxiosError(i)}}handleResponse(r){const s=r.data;if(!s.success&&s.error)throw Fe.handleApiError(s.error);return s}getAxiosInstance(){return this.axiosInstance}}class wt{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 jt{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 St{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 Nt{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 Ct{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 Rt{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 At{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 Et{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 It{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 ce={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"}}},Pt={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"}},Tt={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"}},Ft={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"}}},Lt={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"}},Dt={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"}},Mt={[ae.Default]:ce,[ae.Corporate]:Pt,[ae.Fintech]:Tt,[ae.Healthcare]:Ft,[ae.Modern]:Lt,[ae.Minimal]:Dt};function Le(t){return Mt[t]||ce}class Ot{constructor(r){this.httpClient=r}async getThemeConfiguration(){var r;try{const s=await this.httpClient.get("Tenant","GetThemeConfiguration");if(!s.result.isEnabled)return Le(ae.Default);let a=s.result.preset?Le(s.result.preset):Le(ae.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 i=typeof s.result.applicantFormPages=="string"?JSON.parse(s.result.applicantFormPages):s.result.applicantFormPages;Array.isArray(i)&&i.length>0&&(a.applicantFormPages=i.map(o=>{const c=!o._v||o._v<4;return{...o,fields:(o.fields||[]).map(u=>({...u,colSpan:c?u.colSpan===1?2:4:Math.min(4,Math.max(1,u.colSpan??4))}))}}))}catch{}if(s.result.reviewPageFields)try{const i=typeof s.result.reviewPageFields=="string"?JSON.parse(s.result.reviewPageFields):s.result.reviewPageFields;Array.isArray(i)&&i.length>0&&(a.reviewPageFields=i)}catch{}return s.result.reviewPageDisabled&&(a.reviewPageDisabled=!0),a}catch(s){return console.warn("[ThemeService] Failed to fetch theme configuration:",s),Le(ae.Default)}}async saveThemeConfiguration(r){await this.httpClient.post("Tenant","SaveThemeConfiguration",r)}getAvailablePresets(){return[{id:ae.Default,name:"Default"},{id:ae.Corporate,name:"Corporate"},{id:ae.Fintech,name:"Fintech"},{id:ae.Healthcare,name:"Healthcare"},{id:ae.Modern,name:"Modern"},{id:ae.Minimal,name:"Minimal"}]}getPreviewTheme(r,s){const a=Le(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 zt{constructor(){X(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(i=>{try{i(s)}catch(o){console.error(`Error in event listener for "${r}":`,o)}})}clear(){this.listeners.clear()}clearEvent(r){this.listeners.delete(r)}}class Bt{constructor(){X(this,"events",new zt);X(this,"_applicantId",null);X(this,"_progress",null);X(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)||xe.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===xe.Finished}get isOnHold(){return this.status===xe.OnHold}get isInProgress(){return this.status===xe.InProgress}setApplicantId(r){this._applicantId=r}updateProgress(r){var a,i;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)!==((i=r.currentStep)==null?void 0:i.order)&&this.events.emit("stepChanged",r.currentStep),this.events.emit("statusChanged",r.status),r.status===xe.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 $t{constructor(){X(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: ${G[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: ${G[r]}`);return a.submitData(s)}}class _t{constructor(r,s,a,i,o,c,u,h){X(this,"state");X(this,"stepRouter");this.applicantService=r,this.questionnaireService=s,this.uploadDocumentService=a,this.appropriatenessTestService=i,this.overviewService=o,this.riskScoringService=c,this.investorCategorizationService=h,this.state=new Bt,this.stepRouter=new $t,this.registerStepHandlers()}registerStepHandlers(){this.stepRouter.registerHandler(G.Questionaries,{loadData:r=>this.questionnaireService.getQuestionnaire(r),submitData:async r=>{await this.questionnaireService.fillQuestionnaire(r)}}),this.stepRouter.registerHandler(G.UploadDocument,{loadData:r=>this.uploadDocumentService.getUploadDocument(r),submitData:r=>this.uploadDocumentService.fillUploadDocument(r)}),this.stepRouter.registerHandler(G.AppropriatenessTest,{loadData:r=>this.appropriatenessTestService.getAppropriatenessTest(r),submitData:async r=>{await this.appropriatenessTestService.fillAppropriatenessTest(r)}}),this.stepRouter.registerHandler(G.Overview,{loadData:r=>this.overviewService.getOverviewData(r),submitData:r=>this.overviewService.passOverview(r.applicantId)}),this.stepRouter.registerHandler(G.RiskScoring,{loadData:r=>this.riskScoringService.getRiskCriterias(r),submitData:async r=>{await this.riskScoringService.submitRiskScoring(r)}}),this.stepRouter.registerHandler(G.IdentitySdk,{loadData:async r=>({applicantId:r,message:"Identity verification required"}),submitData:async()=>{}}),this.stepRouter.registerHandler(G.InvestorCategorization,{loadData:r=>this.investorCategorizationService.getInvestorCategorization(r),submitData:async r=>{await this.investorCategorizationService.setInvestorCategorization(r)}}),this.stepRouter.registerHandler(G.ManualReview,{loadData:async r=>({applicantId:r,message:"Your application is under manual review"}),submitData:async()=>{}}),this.stepRouter.registerHandler(G.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 et(t,r){return new Promise((s,a)=>{if(r&&document.getElementById(r)){s();return}const i=document.createElement("script");i.src=t,r&&(i.id=r),i.async=!0,i.onload=()=>s(),i.onerror=()=>a(new Error(`Failed to load script: ${t}`)),document.head.appendChild(i)})}function Sr(t){return!!document.getElementById(t)}function Nr(t){const r=document.getElementById(t);r&&r.remove()}class Ht{constructor(r){X(this,"sdk",null);X(this,"config");this.config=r}async loadSDK(){await et("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 Ut{constructor(r){X(this,"sdk",null);X(this,"config");this.config=r}async loadSDK(){await et("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 Kt{constructor(r){X(this,"sardineContext",null);X(this,"config");X(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(),i=document.createElement("script");i.type="text/javascript",i.async=!0,i.src=`https://${a}/assets/loader.min.js`,i.onload=()=>{console.log("[SardinAI] SDK loaded successfully"),r()},i.onerror=()=>{s(new Error("Failed to load SardinAI SDK"))};const o=document.getElementsByTagName("script")[0];o&&o.parentNode?o.parentNode.insertBefore(i,o):document.head.appendChild(i)})}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:i,enableBiometrics:o,enablePortScanning:c}=this.config;this.sardineContext=window._Sardine.createContext({clientId:s,sessionKey:this.sessionKey,userIdHash:void 0,flow:i||window.location.pathname,environment:a||"production",parentElement:document.body,enableBiometrics:o!==!1,enablePortScanning:c===!0,region:this.config.region,onDeviceResponse:u=>{console.log(`[SardinAI] Device ID: ${u.deviceId}`)},onConfigUpdate:(u,h,p)=>{switch(u){case"SESSION_UPDATE_FAILED":console.error("[SardinAI] Session update failed:",p);break;case"SESSION_UPDATED":console.log("[SardinAI] Session updated:",h);break;case"SESSION_NO_UPDATE":console.log("[SardinAI] No session update");break;default:console.warn("[SardinAI] Unknown event:",u)}}}),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:i,flow:o}=this.config;a.src=`https://${r}/v1/a.png?clientId=${i}&sessionKey=${this.sessionKey}&flow=${o||"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,i)=>{switch(s){case"SESSION_UPDATE_FAILED":console.error("[SardinAI] Config update failed:",i);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 Pe{static createProvider(r,s){switch(r){case he.Sumsub:return new Ht(s);case he.Onfido:return new Ut(s);case he.SardinAI:return new Kt(s);default:throw new Error(`Unsupported identity provider: ${r}`)}}static parseProviderConfig(r,s,a){var i;switch(r){case he.Sumsub:return{accessToken:s.accessToken||s.token,applicantEmail:s.email,applicantPhone:s.phone,externalUserId:s.externalUserId,lang:s.lang||"en"};case he.Onfido:return{token:s.token||s.sdkToken};case he.SardinAI:const o=((i=a==null?void 0:a.identityProviders)==null?void 0:i.sardinai)||{};return{clientId:o.clientId||s.clientId,sessionKey:o.sessionKey||s.sessionKey,environment:o.environment||s.environment||"production",flow:o.flow||s.flow,region:o.region,enableBiometrics:o.enableBiometrics,enablePortScanning:o.enablePortScanning};default:throw new Error(`Unsupported identity provider: ${r}`)}}}class Wt{constructor(r){X(this,"currentTheme",ce);X(this,"customStyleElement",null);X(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,"input-bg":r.inputBg??r.background,"input-text":r.inputText??r.textPrimary,"input-border":r.inputBorder??r.border,"input-border-focus":r.inputBorderFocus??r.primary,"input-placeholder":r.inputPlaceholder??r.textMuted};Object.entries(s).forEach(([i,o])=>{this.container.style.setProperty(`--metakyc-${i}`,o)}),(a=this.currentTheme.darkMode)!=null&&a.colors&&this.applyDarkModeColors(this.currentTheme.darkMode.colors)}applyDarkModeColors(r){Object.entries(r).forEach(([s,a])=>{if(a){const i=`--metakyc-dark-${this.kebabCase(s)}`;this.container.style.setProperty(i,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 i=`--metakyc-${this.kebabCase(s)}`;this.container.style.setProperty(i,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||ce.name,title:r.title||ce.title,logo:{...ce.logo,...r.logo},colors:{...ce.colors,...r.colors},typography:r.typography?{...ce.typography,...r.typography}:ce.typography,spacing:r.spacing?{...ce.spacing,...r.spacing}:ce.spacing,customCSS:r.customCSS,darkMode:r.darkMode?{colors:{...(s=ce.darkMode)==null?void 0:s.colors,...r.darkMode.colors}}:ce.darkMode,applicantFormVisibleFields:r.applicantFormVisibleFields,applicantFormRequiredFields:r.applicantFormRequiredFields,allowedLanguages:r.allowedLanguages,applicantFormPages:r.applicantFormPages,reviewPageFields:r.reviewPageFields,reviewPageDisabled:r.reviewPageDisabled}}getCurrentTheme(){return this.currentTheme}resetTheme(){this.applyTheme(ce)}cleanup(){this.customStyleElement&&(this.customStyleElement.remove(),this.customStyleElement=null)}kebabCase(r){return r.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}}const tt=l.createContext(null),Cr=({config:t,children:r})=>{const[s,a]=l.useState(null),i=l.useRef(!1),o=l.useRef(!1),c=l.useMemo(()=>{const h=new kt(t),p=new wt(h),v=new jt(h),S=new St(h),y=new Nt(h),j=new Ct(h),f=new Rt(h),F=new At(h),I=new Et(h),E=new It(h),M=new Ot(h),A=new Wt;return{httpClient:h,applicantService:p,questionnaireService:v,uploadDocumentService:S,appropriatenessTestService:y,overviewService:j,riskScoringService:f,identityService:F,baseInformationService:I,investorCategorizationService:E,themeService:M,themeManager:A}},[t]),u=l.useMemo(()=>({config:t,...c,currentTheme:s,createOrchestrator:()=>new _t(c.applicantService,c.questionnaireService,c.uploadDocumentService,c.appropriatenessTestService,c.overviewService,c.riskScoringService,c.identityService,c.investorCategorizationService)}),[t,c,s]);return l.useEffect(()=>((async()=>{if(i.current||o.current){console.log("[MetaKYC] Theme already loading or loaded, skipping...");return}i.current=!0;try{if(t.theme){console.log("[MetaKYC] Applying static theme from config"),c.themeManager.applyTheme(t.theme),a(c.themeManager.getCurrentTheme()),o.current=!0;return}console.log("[MetaKYC] Fetching theme from backend...");const p=await c.themeService.getThemeConfiguration();c.themeManager.applyTheme(p),a(c.themeManager.getCurrentTheme()),o.current=!0,console.log("[MetaKYC] Theme loaded and applied",p)}catch(p){console.warn("[MetaKYC] Failed to load theme, using default:",p),a(c.themeManager.getCurrentTheme()),o.current=!0}finally{i.current=!1}})(),()=>{c.themeManager.cleanup()}),[]),e.jsx(tt.Provider,{value:u,children:r})};function de(){const t=l.useContext(tt);if(!t)throw new Error("useMetaKYC must be used within a MetaKYCProvider");return t}async function Yt(t){return new Promise((r,s)=>{const a=new FileReader;a.readAsDataURL(t),a.onload=()=>{const o=a.result.split(",")[1];r(o)},a.onerror=i=>s(i)})}function Rr(t,r){return t.size<=r}function Ar(t,r){return r.split(",").map(a=>a.trim()).some(a=>{if(a.endsWith("/*")){const i=a.slice(0,-2);return t.type.startsWith(i)}return t.type===a})}function We(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 Er(t){return t}function re(...t){return t.filter(Boolean).join(" ")}const De={APPLICANT_ID:"metakyc_applicant_id",WORKFLOW_STATE:"metakyc_workflow_state"};function qt(t){try{localStorage.setItem(De.APPLICANT_ID,t.toString())}catch(r){console.warn("Failed to save applicant ID to storage:",r)}}function Qt(){try{const t=localStorage.getItem(De.APPLICANT_ID);return t?parseInt(t,10):null}catch(t){return console.warn("Failed to retrieve applicant ID from storage:",t),null}}function Gt(){try{localStorage.removeItem(De.APPLICANT_ID)}catch(t){console.warn("Failed to clear applicant ID from storage:",t)}}function Vt(t){try{localStorage.setItem(De.WORKFLOW_STATE,JSON.stringify(t))}catch(r){console.warn("Failed to save workflow state to storage:",r)}}function Ir(){try{const t=localStorage.getItem(De.WORKFLOW_STATE);return t?JSON.parse(t):null}catch(t){return console.warn("Failed to retrieve workflow state from storage:",t),null}}function Jt(){try{localStorage.removeItem(De.WORKFLOW_STATE)}catch(t){console.warn("Failed to clear workflow state from storage:",t)}}function Pr(){Gt(),Jt()}function Zt(t){const{createOrchestrator:r}=de(),[s,a]=l.useState(null),[i,o]=l.useState(!1),[c,u]=l.useState(null),h=l.useRef(null),p=t||Qt();l.useEffect(()=>{h.current||(h.current=r())},[r]),l.useEffect(()=>{var A;s&&p&&(qt(p),Vt({applicantId:p,currentStepOrder:(A=s.currentStep)==null?void 0:A.order,status:s.status,lastUpdated:new Date().toISOString(),workflowKey:s.workFlowKey,nextWorkflowKey:s.nextWorkflowKey}))},[s,p]);const v=l.useRef(!1),S=l.useRef(!1),y=l.useCallback(async()=>{if(!(!p||!h.current)){if(v.current){console.log("[Workflow] Load already in progress, skipping...");return}v.current=!0,o(!0),u(null);try{const A=await h.current.initialize(p);a(A),S.current=!0}catch(A){u(A)}finally{o(!1),v.current=!1}}},[p]);l.useEffect(()=>{p&&!S.current&&y()},[p,y]);const j=l.useCallback(async()=>{if(h.current){if(v.current){console.log("[Workflow] Refresh already in progress, skipping...");return}v.current=!0,o(!0),u(null);try{const A=await h.current.refreshProgress();a(A)}catch(A){u(A)}finally{o(!1),v.current=!1}}},[]),f=l.useCallback(async()=>{if(h.current){o(!0),u(null);try{const A=await h.current.moveToNextStep();a(A)}catch(A){u(A)}finally{o(!1)}}},[]),F=l.useCallback(async()=>{if(h.current){o(!0),u(null);try{const A=await h.current.moveToPreviousStep();a(A)}catch(A){u(A)}finally{o(!1)}}},[]),I=l.useCallback(async A=>{if(h.current){o(!0),u(null);try{await h.current.submitCurrentStep(A);const P=await h.current.refreshProgress();a(P)}catch(P){throw u(P),P}finally{o(!1)}}},[]),E=rt.useMemo(()=>s!=null&&s.stepInfoList?[...s.stepInfoList].sort((A,P)=>A.order-P.order):[],[s==null?void 0:s.stepInfoList]),M=rt.useMemo(()=>s?s.nextWorkflowKey&&s.nextWorkflowKey!==s.workFlowKey:!1,[s]);return{progress:s,applicantId:p,currentStep:(s==null?void 0:s.currentStep)||null,steps:E,status:(s==null?void 0:s.status)||xe.None,workflowResult:(s==null?void 0:s.workflowResult)||null,workflowKey:s==null?void 0:s.workFlowKey,nextWorkflowKey:s==null?void 0:s.nextWorkflowKey,hasWorkflowChanged:M,isLoading:i,error:c,isComplete:(s==null?void 0:s.status)===xe.Finished,isOnHold:(s==null?void 0:s.status)===xe.OnHold,refreshProgress:j,moveToNext:f,moveBack:F,submitCurrentStep:I,orchestrator:h.current}}function Xt(t){const{questionnaireService:r,applicantService:s}=de(),[a,i]=l.useState(null),[o,c]=l.useState({}),[u,h]=l.useState(!1),[p,v]=l.useState(!1),[S,y]=l.useState(null),j=l.useRef(!1),f=l.useRef(null),F=l.useCallback(async()=>{var E,M;if(t){if(j.current){console.log("[Questionnaire] Load already in progress, skipping...");return}j.current=!0,h(!0),y(null);try{const[A,P]=await Promise.all([r.getQuestionnaire(t),s.getApplicantData(t).catch(()=>null)]);if(i(A),(E=P==null?void 0:P.questionnaireResults)!=null&&E.length&&A){const Y=new Map;for(const w of P.questionnaireResults)w.question&&((M=w.answers)!=null&&M.length)&&Y.set(w.question.trim().toLowerCase(),w.answers);const J={},R=A.questionGroups.flatMap(w=>w.questions??[]);for(const w of R){const $=w.text.trim().toLowerCase();Y.has($)&&(J[w.id]=Y.get($))}c(J)}f.current=t}catch(A){y(A)}finally{h(!1),j.current=!1}}},[t,r,s]);l.useEffect(()=>{t&&f.current!==t&&F()},[t]);const I=l.useCallback(async E=>{v(!0),y(null);try{return await r.fillQuestionnaire(E)}catch(M){throw y(M),M}finally{v(!1)}},[r]);return{questionnaire:a,initialAnswers:o,isLoading:u,isSubmitting:p,error:S,load:F,submit:I}}function er(t){const{uploadDocumentService:r}=de(),[s,a]=l.useState(null),[i,o]=l.useState(!1),[c,u]=l.useState(!1),[h,p]=l.useState(0),[v,S]=l.useState(null),y=l.useRef(!1),j=l.useRef(null),f=l.useCallback(async()=>{if(t){if(y.current){console.log("[UploadDocument] Load already in progress, skipping...");return}y.current=!0,o(!0),S(null);try{const I=await r.getUploadDocument(t);a(I),j.current=t}catch(I){S(I)}finally{o(!1),y.current=!1}}},[t,r]);l.useEffect(()=>{t&&j.current!==t&&f()},[t]);const F=l.useCallback(async I=>{u(!0),p(0),S(null);try{await r.fillUploadDocument(I),p(100)}catch(E){throw S(E),E}finally{u(!1)}},[r]);return{uploadDocument:s,isLoading:i,isSubmitting:c,uploadProgress:h,error:v,load:f,submit:F}}function Tr(t){const{appropriatenessTestService:r}=de(),[s,a]=l.useState(null),[i,o]=l.useState(!1),[c,u]=l.useState(!1),[h,p]=l.useState(null),[v,S]=l.useState(null),y=l.useRef(!1),j=l.useRef(null),f=l.useCallback(async()=>{if(t){if(y.current){console.log("[AppropriatenessTest] Load already in progress, skipping...");return}y.current=!0,o(!0),p(null);try{const I=await r.getAppropriatenessTest(t);a(I),j.current=t}catch(I){p(I)}finally{o(!1),y.current=!1}}},[t,r]);l.useEffect(()=>{t&&j.current!==t&&f()},[t]);const F=l.useCallback(async I=>{u(!0),p(null);try{const E=await r.fillAppropriatenessTest(I);return S(E),E}catch(E){throw p(E),E}finally{u(!1)}},[r]);return{test:s,result:v,isLoading:i,isSubmitting:c,error:h,load:f,submit:F}}function tr(t){const{overviewService:r}=de(),[s,a]=l.useState(null),[i,o]=l.useState(!1),[c,u]=l.useState(!1),[h,p]=l.useState(null),v=l.useRef(!1),S=l.useRef(null),y=l.useCallback(async()=>{if(t){if(v.current){console.log("[Overview] Load already in progress, skipping...");return}v.current=!0,o(!0),p(null);try{const f=await r.getOverviewData(t);a(f),S.current=t}catch(f){p(f)}finally{o(!1),v.current=!1}}},[t,r]);l.useEffect(()=>{t&&S.current!==t&&y()},[t]);const j=l.useCallback(async()=>{if(t){u(!0),p(null);try{await r.passOverview(t)}catch(f){throw p(f),f}finally{u(!1)}}},[t,r]);return{overview:s,isLoading:i,isSubmitting:c,error:h,load:y,passOverview:j}}function rr(t){const{identityService:r}=de(),[s,a]=l.useState(null),[i,o]=l.useState(!1),[c,u]=l.useState(null),h=l.useRef(!1),p=l.useCallback(async(y,j)=>{if(t){if(h.current){console.log("[Identity] Request already in progress, skipping...");return}h.current=!0,o(!0),u(null);try{const f={applicantId:t,restart:!1,redirectUrl:y||"",ttl:j||604800};console.log("Identity request input:",f);const F=await r.identityRequest(f);return console.log("Identity request result:",F),a(F),F}catch(f){throw u(f),f}finally{o(!1),h.current=!1}}},[t,r]),v=l.useCallback(async(y,j)=>{if(t){o(!0),u(null);try{const f={applicantId:t,restart:!1,redirectUrl:y,ttl:j},F=await r.identityCompanyRequest(f);return a(F),F}catch(f){throw u(f),f}finally{o(!1)}}},[t,r]),S=l.useCallback(async()=>{if(t){if(h.current){console.log("[Identity] Restart already in progress, skipping...");return}h.current=!0,o(!0),u(null);try{const y={applicantId:t,restart:!0,redirectUrl:"",ttl:604800};console.log("Restarting identity with input:",y);const j=await r.identityRequest(y);return console.log("Restart identity result:",j),a(j),j}catch(y){throw u(y),y}finally{o(!1),h.current=!1}}},[t,r]);return{identityData:s,provider:(s==null?void 0:s.provider)||null,token:(s==null?void 0:s.publicProviderTokenObject)||null,isLoading:i,error:c,requestIdentity:p,requestCompanyIdentity:v,restartIdentity:S}}function sr(t){const{riskScoringService:r,applicantService:s}=de(),[a,i]=l.useState(null),[o,c]=l.useState({}),[u,h]=l.useState(!1),[p,v]=l.useState(!1),[S,y]=l.useState(null),[j,f]=l.useState(null),F=l.useRef(!1),I=l.useRef(null),E=l.useCallback(async()=>{var A;if(t){if(F.current){console.log("[RiskScoring] Load already in progress, skipping...");return}F.current=!0,h(!0),y(null);try{const[P,Y]=await Promise.all([r.getRiskCriterias(t),s.getApplicantData(t).catch(()=>null)]);if(i(P),(A=Y==null?void 0:Y.riskScoringResults)!=null&&A.length){const J=Y.riskScoringResults[0],R={};for(const w of J.riskCriteriaResults??[])if(w.riskCriteriaId!=null&&w.answer!=null&&w.answer!==""){const $=[...new Set(w.answer.split(",").map(K=>K.trim()).filter(K=>K!==""))];$.length>0&&(R[w.riskCriteriaId]=$)}c(R)}I.current=t}catch(P){y(P)}finally{h(!1),F.current=!1}}},[t,r,s]);l.useEffect(()=>{t&&I.current!==t&&E()},[t]);const M=l.useCallback(async A=>{v(!0),y(null);try{const P=await r.submitRiskScoring(A);return f(P),P}catch(P){throw y(P),P}finally{v(!1)}},[r]);return{criteria:a,initialAnswers:o,result:j,isLoading:u,isSubmitting:p,error:S,load:E,submit:M}}function ar(){const{applicantService:t,config:r}=de(),[s,a]=l.useState(!1),[i,o]=l.useState(null),c=l.useRef(!1),u=l.useRef(!1),h=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(j){const f=Math.random()*16|0;return(j==="x"?f:f&3|8).toString(16)}),p=l.useCallback(async j=>{var f;if(c.current)throw console.log("[Applicant] Create already in progress, skipping..."),new Error("Creation already in progress");c.current=!0,a(!0),o(null);try{if(j.applicantAdditionalDatas||(j.applicantAdditionalDatas=[]),(f=r.identityProviders)!=null&&f.sardinai){const I=h();console.log("[SardinAI] Generated session key:",I),j.applicantAdditionalDatas.push({paramName:"sessionKey",value:I})}return await t.createApplicant(j)}catch(F){throw o(F),F}finally{a(!1),c.current=!1}},[t,r]),v=l.useCallback(async j=>{a(!0),o(null);try{return await t.createCompanyApplicant(j)}catch(f){throw o(f),f}finally{a(!1)}},[t]),S=l.useCallback(async j=>{if(u.current)throw console.log("[Applicant] Data load already in progress, skipping..."),new Error("Data load already in progress");u.current=!0,a(!0),o(null);try{return await t.getApplicantData(j)}catch(f){throw o(f),f}finally{a(!1),u.current=!1}},[t]),y=l.useCallback(async j=>{a(!0),o(null);try{await t.stopProgress(j)}catch(f){throw o(f),f}finally{a(!1)}},[t]);return{isLoading:s,error:i,createApplicant:p,createCompanyApplicant:v,getApplicantData:S,stopProgress:y}}const W=({children:t,variant:r="primary",size:s="md",isLoading:a=!1,disabled:i,className:o,...c})=>{const u="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",h={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"},p={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:re(u,h[r],p[s],o),disabled:i||a,...c,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]})},ne=l.forwardRef(({label:t,error:r,helperText:s,leftIcon:a,rightIcon:i,className:o,style:c,...u},h)=>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,u.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:h,className:re("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",a?"pl-10":"",i?"pr-10":"",o),style:{backgroundColor:"var(--metakyc-input-bg, #ffffff)",color:"var(--metakyc-input-text, var(--metakyc-text-primary, #111827))",borderColor:r?"var(--metakyc-danger, #ef4444)":"var(--metakyc-input-border, var(--metakyc-border, #d1d5db))",...c},...u}),i&&e.jsx("div",{className:"absolute inset-y-0 right-0 pr-3 flex items-center pointer-events-none",children:i})]}),r&&e.jsx("p",{className:"mt-1 text-sm",style:{color:"var(--metakyc-danger, #ef4444)"},children:r}),!r&&s&&e.jsx("p",{className:"mt-1 text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:s})]}));ne.displayName="Input";const _=({children:t,className:r,...s})=>e.jsx("div",{className:re("metakyc-card rounded-xl shadow-sm border",r),style:{backgroundColor:"var(--metakyc-surface, #ffffff)",borderColor:"var(--metakyc-border, #e5e7eb)"},...s,children:t}),ie=({children:t,className:r,...s})=>e.jsx("div",{className:re("px-6 py-4 border-b",r),style:{borderColor:"var(--metakyc-border, #e5e7eb)"},...s,children:t}),H=({children:t,className:r,...s})=>e.jsx("div",{className:re("px-6 py-4",r),...s,children:t}),le=({children:t,className:r,...s})=>e.jsx("div",{className:re("px-6 py-4 border-t",r),style:{borderColor:"var(--metakyc-border, #e5e7eb)"},...s,children:t}),ve=({children:t,variant:r="default",className:s,...a})=>{const i={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:re("inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium",i[r],s),...a,children:t})},ge=({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:re("flex items-center justify-center",r),...s,children:e.jsxs("svg",{className:re("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"})]})})},Qe=l.forwardRef(({label:t,error:r,helperText:s,options:a,placeholder:i,className:o,style:c,...u},h)=>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,u.required&&e.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),e.jsxs("select",{ref:h,className:re("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":"",o),style:{backgroundColor:"var(--metakyc-input-bg, #ffffff)",color:"var(--metakyc-input-text, var(--metakyc-text-primary, #111827))",borderColor:r?"var(--metakyc-danger, #ef4444)":"var(--metakyc-input-border, var(--metakyc-border, #d1d5db))",...c},...u,children:[i&&e.jsx("option",{value:"",disabled:!0,style:{backgroundColor:"var(--metakyc-input-bg, #ffffff)",color:"var(--metakyc-text-secondary, #6b7280)"},children:i},"__placeholder__"),a.map((p,v)=>e.jsx("option",{value:p.value,disabled:p.disabled,style:{backgroundColor:"var(--metakyc-input-bg, #ffffff)",color:p.disabled?"var(--metakyc-text-muted, #9ca3af)":"var(--metakyc-input-text, var(--metakyc-text-primary, #111827))"},children:p.label},p.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})]}));Qe.displayName="Select";const st=280,nr=({label:t,value:r,onChange:s,options:a,placeholder:i="Select...",disabled:o=!1,required:c=!1})=>{const[u,h]=l.useState(!1),[p,v]=l.useState(""),[S,y]=l.useState(null),j=l.useRef(null),f=l.useRef(null),F=l.useRef(null),I=l.useCallback(()=>{if(!f.current)return null;const C=f.current.getBoundingClientRect(),Z=window.innerHeight-C.bottom<st&&C.top>st;return{top:Z?C.top:C.bottom+4,left:C.left,width:C.width,openUp:Z}},[]),E=l.useCallback(()=>{if(o)return;const C=I();C&&y(C),h(!0)},[o,I]),M=l.useCallback(()=>{h(!1),v("")},[]);l.useEffect(()=>{if(!u)return;const C=U=>{var me,se;const Z=U.target;!((me=j.current)!=null&&me.contains(Z))&&!((se=F.current)!=null&&se.contains(Z))&&M()};return document.addEventListener("mousedown",C),()=>document.removeEventListener("mousedown",C)},[u,M]),l.useEffect(()=>{if(!u)return;const C=()=>{const U=I();U&&y(U)};return window.addEventListener("scroll",C,!0),window.addEventListener("resize",C),()=>{window.removeEventListener("scroll",C,!0),window.removeEventListener("resize",C)}},[u,I]);const A=a.filter(C=>C.label.toLowerCase().includes(p.toLowerCase())),P=C=>{o||s(r.includes(C)?r.filter(U=>U!==C):[...r,C])},Y=(C,U)=>{U.stopPropagation(),o||s(r.filter(Z=>Z!==C))},J=C=>{var U;return((U=a.find(Z=>Z.value===C))==null?void 0:U.label)||C},R=f.current?getComputedStyle(f.current):null,w=(R==null?void 0:R.getPropertyValue("--metakyc-input-bg").trim())||"#ffffff",$=(R==null?void 0:R.getPropertyValue("--metakyc-input-border").trim())||(R==null?void 0:R.getPropertyValue("--metakyc-border").trim())||"#d1d5db",K=(R==null?void 0:R.getPropertyValue("--metakyc-input-text").trim())||(R==null?void 0:R.getPropertyValue("--metakyc-text-primary").trim())||"#111827",k=(R==null?void 0:R.getPropertyValue("--metakyc-text-secondary").trim())||"#6b7280",z=(R==null?void 0:R.getPropertyValue("--metakyc-primary").trim())||"#2563eb",T=(R==null?void 0:R.getPropertyValue("--metakyc-primary-light").trim())||"#eff6ff",D=(R==null?void 0:R.getPropertyValue("--metakyc-hover-bg").trim())||"#f9fafb",Q=u&&S&&e.jsxs("div",{ref:F,className:"metakyc-multiselect-dropdown",style:{position:"fixed",top:S.openUp?void 0:S.top,bottom:S.openUp?window.innerHeight-S.top+4:void 0,left:S.left,width:S.width,zIndex:99999,borderRadius:"8px",boxShadow:"0 4px 16px rgba(0,0,0,0.18)",border:`1px solid ${$}`,backgroundColor:w,overflow:"hidden"},children:[e.jsx("div",{style:{padding:"8px",borderBottom:`1px solid ${$}`},children:e.jsx("input",{type:"text",value:p,onChange:C=>v(C.target.value),placeholder:"Search...",autoFocus:!0,onClick:C=>C.stopPropagation(),className:"metakyc-multiselect-search w-full",style:{display:"block",width:"100%",padding:"6px 8px",fontSize:"13px",borderRadius:"6px",border:`1px solid ${$}`,backgroundColor:w,color:K,outline:"none",boxSizing:"border-box"}})}),e.jsx("ul",{style:{listStyle:"none",margin:0,padding:"4px 0",maxHeight:"192px",overflowY:"auto"},children:A.length===0?e.jsx("li",{style:{padding:"8px 12px",fontSize:"13px",color:k},children:"No results"}):A.map(C=>{const U=r.includes(C.value);return e.jsxs("li",{onClick:()=>P(C.value),className:"metakyc-multiselect-option",style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",fontSize:"13px",cursor:"pointer",backgroundColor:U?T:"transparent",color:U?z:K,userSelect:"none"},onMouseEnter:Z=>{U||(Z.currentTarget.style.backgroundColor=D)},onMouseLeave:Z=>{U||(Z.currentTarget.style.backgroundColor="transparent")},children:[e.jsx("input",{type:"checkbox",checked:U,readOnly:!0,style:{accentColor:z,pointerEvents:"none",flexShrink:0}}),e.jsx("span",{children:C.label})]},C.value)})}),r.length>0&&e.jsx("div",{style:{padding:"6px 12px",borderTop:`1px solid ${$}`},children:e.jsxs("button",{type:"button",onClick:()=>{s([]),v("")},style:{fontSize:"12px",color:"#ef4444",background:"none",border:"none",cursor:"pointer",padding:0},children:["Clear all (",r.length," selected)"]})})]});return e.jsxs("div",{className:"w-full metakyc-multiselect",ref:j,children:[t&&e.jsxs("label",{className:"block text-sm font-medium mb-1",style:{color:"var(--metakyc-text-primary, #374151)"},children:[t,c&&e.jsx("span",{style:{color:"var(--metakyc-error, #ef4444)",marginLeft:"4px"},children:"*"})]}),e.jsxs("div",{ref:f,onClick:()=>u?M():E(),className:re("metakyc-multiselect-trigger","min-h-[42px] w-full px-3 py-2 rounded-lg border text-sm transition-colors relative",o?"opacity-50 cursor-not-allowed":"cursor-pointer"),style:{backgroundColor:"var(--metakyc-input-bg, #ffffff)",borderColor:u?"var(--metakyc-input-border-focus, var(--metakyc-primary, #2563eb))":"var(--metakyc-input-border, var(--metakyc-border, #d1d5db))",outline:u?"2px solid var(--metakyc-input-border-focus, var(--metakyc-primary, #2563eb))":"none",outlineOffset:"-1px"},children:[r.length===0?e.jsx("span",{className:"metakyc-multiselect-placeholder leading-6",style:{color:"var(--metakyc-text-secondary, #9ca3af)"},children:i}):e.jsx("div",{className:"flex flex-wrap gap-1 pr-6",children:r.map(C=>e.jsxs("span",{className:"metakyc-multiselect-chip inline-flex items-center gap-1 px-2 py-0.5 rounded text-xs font-medium",style:{backgroundColor:"var(--metakyc-primary-light, #eff6ff)",color:"var(--metakyc-primary, #2563eb)"},children:[J(C),!o&&e.jsx("button",{type:"button",onClick:U=>Y(C,U),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:"×"})]},C))}),e.jsx("span",{className:"metakyc-multiselect-arrow absolute right-3 top-1/2 -translate-y-1/2 pointer-events-none text-xs",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:u?"▲":"▼"})]}),typeof document<"u"&&Q?qe.createPortal(Q,document.body):null]})},at=260,ke=({label:t,error:r,helperText:s,options:a,placeholder:i="Select...",value:o,onChange:c,disabled:u=!1,required:h=!1,className:p})=>{var se;const[v,S]=l.useState(!1),[y,j]=l.useState(""),[f,F]=l.useState(null),I=l.useRef(null),E=l.useRef(null),M=l.useRef(null),A=l.useRef(null),P=l.useCallback(()=>{if(!E.current)return null;const L=E.current.getBoundingClientRect(),te=window.innerHeight-L.bottom<at&&L.top>at;return{top:te?L.top:L.bottom+4,left:L.left,width:L.width,openUp:te}},[]),Y=l.useCallback(()=>{if(u)return;const L=P();L&&F(L),S(!0)},[u,P]),J=l.useCallback(()=>{S(!1),j("")},[]),R=()=>v?J():Y();l.useEffect(()=>{if(!v)return;const L=V=>{var je,Ae;const te=V.target;!((je=I.current)!=null&&je.contains(te))&&!((Ae=M.current)!=null&&Ae.contains(te))&&J()};return document.addEventListener("mousedown",L),()=>document.removeEventListener("mousedown",L)},[v,J]),l.useEffect(()=>{if(!v)return;const L=()=>{const V=P();V&&F(V)};return window.addEventListener("scroll",L,!0),window.addEventListener("resize",L),()=>{window.removeEventListener("scroll",L,!0),window.removeEventListener("resize",L)}},[v,P]),l.useEffect(()=>{v&&A.current&&setTimeout(()=>{var L;return(L=A.current)==null?void 0:L.focus()},0)},[v]);const w=a.filter(L=>L.label.toLowerCase().includes(y.toLowerCase())||L.value.toLowerCase().includes(y.toLowerCase())),$=(se=a.find(L=>L.value===o))==null?void 0:se.label,K=(L,V)=>{u||V||(c(L),J())},k=E.current?getComputedStyle(E.current):null,z=(k==null?void 0:k.getPropertyValue("--metakyc-input-bg").trim())||"#ffffff",T=(k==null?void 0:k.getPropertyValue("--metakyc-input-border").trim())||(k==null?void 0:k.getPropertyValue("--metakyc-border").trim())||"#d1d5db",D=(k==null?void 0:k.getPropertyValue("--metakyc-input-text").trim())||(k==null?void 0:k.getPropertyValue("--metakyc-text-primary").trim())||"#111827",Q=(k==null?void 0:k.getPropertyValue("--metakyc-text-secondary").trim())||"#6b7280",C=(k==null?void 0:k.getPropertyValue("--metakyc-primary").trim())||"#2563eb",U=(k==null?void 0:k.getPropertyValue("--metakyc-primary-light").trim())||"#eff6ff",Z=(k==null?void 0:k.getPropertyValue("--metakyc-hover-bg").trim())||"#f9fafb",me=v&&f&&e.jsxs("div",{ref:M,className:"metakyc-searchable-select-dropdown",style:{position:"fixed",top:f.openUp?void 0:f.top,bottom:f.openUp?window.innerHeight-f.top+4:void 0,left:f.left,width:f.width,zIndex:99999,borderRadius:"8px",boxShadow:"0 4px 16px rgba(0,0,0,0.18)",border:`1px solid ${T}`,backgroundColor:z,overflow:"hidden"},children:[e.jsx("div",{style:{padding:"8px",borderBottom:`1px solid ${T}`},children:e.jsx("input",{ref:A,type:"text",value:y,onChange:L=>j(L.target.value),placeholder:"Search...",onClick:L=>L.stopPropagation(),className:"metakyc-searchable-select-search w-full",style:{display:"block",width:"100%",padding:"6px 8px",fontSize:"13px",borderRadius:"6px",border:`1px solid ${T}`,backgroundColor:z,color:D,outline:"none",boxSizing:"border-box"}})}),e.jsx("ul",{style:{listStyle:"none",margin:0,padding:"4px 0",maxHeight:"208px",overflowY:"auto"},children:w.length===0?e.jsx("li",{style:{padding:"8px 12px",fontSize:"13px",color:Q},children:"No results"}):w.map(L=>{const V=L.value===o;return e.jsx("li",{className:"metakyc-searchable-select-option",onClick:()=>K(L.value,L.disabled),style:{padding:"8px 12px",fontSize:"13px",cursor:L.disabled?"not-allowed":"pointer",opacity:L.disabled?.4:1,backgroundColor:V?U:"transparent",color:V?C:D,userSelect:"none"},onMouseEnter:te=>{!V&&!L.disabled&&(te.currentTarget.style.backgroundColor=Z)},onMouseLeave:te=>{V||(te.currentTarget.style.backgroundColor="transparent")},children:L.label},L.value)})})]});return e.jsxs("div",{className:re("w-full metakyc-searchable-select",p),ref:I,children:[t&&e.jsxs("label",{className:"block text-sm font-medium mb-1",style:{color:"var(--metakyc-text-primary, #374151)"},children:[t,h&&e.jsx("span",{style:{color:"var(--metakyc-error, #ef4444)",marginLeft:"4px"},children:"*"})]}),e.jsxs("div",{ref:E,role:"button",tabIndex:u?-1:0,onClick:R,onKeyDown:L=>{(L.key==="Enter"||L.key===" ")&&(L.preventDefault(),R()),L.key==="Escape"&&J()},className:re("metakyc-searchable-select-trigger","w-full px-3 py-2 rounded-lg border text-sm transition-colors text-left","flex items-center justify-between gap-2","focus:outline-none",u?"opacity-60 cursor-not-allowed":"cursor-pointer"),style:{backgroundColor:"var(--metakyc-input-bg, #ffffff)",color:$?"var(--metakyc-input-text, var(--metakyc-text-primary, #111827))":"var(--metakyc-input-placeholder, var(--metakyc-text-muted, #9ca3af))",borderColor:r?"var(--metakyc-danger, #ef4444)":v?"var(--metakyc-input-border-focus, var(--metakyc-primary, #2563eb))":"var(--metakyc-input-border, var(--metakyc-border, #d1d5db))",minHeight:"42px",outline:v?"2px solid var(--metakyc-input-border-focus, var(--metakyc-primary, #2563eb))":"none",outlineOffset:"-1px"},children:[e.jsx("span",{className:"truncate flex-1",children:$||i}),e.jsx("span",{className:"flex-shrink-0 text-xs pointer-events-none",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:v?"▲":"▼"})]}),typeof document<"u"&&me?qe.createPortal(me,document.body):null,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})]})};ke.displayName="SearchableSelect";const ir=({label:t,error:r,accept:s,multiple:a=!1,maxSize:i,onChange:o,value:c=[],className:u})=>{const[h,p]=l.useState(!1),v=l.useRef(null),S=E=>{if(!E)return;const M=Array.from(E);if(i&&M.filter(P=>P.size>i).length>0){const P=We(i);alert(`Some files exceed the maximum size of ${P}`);return}o==null||o(a?[...c,...M]:[M[0]])},y=E=>{E.preventDefault(),p(!0)},j=()=>{p(!1)},f=E=>{E.preventDefault(),p(!1),S(E.dataTransfer.files)},F=()=>{var E;(E=v.current)==null||E.click()},I=E=>{const M=c.filter((A,P)=>P!==E);o==null||o(M)};return e.jsxs("div",{className:re("w-full",u),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:re("border-2 border-dashed rounded-lg p-6 text-center cursor-pointer transition-colors",h?"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:y,onDragLeave:j,onDrop:f,onClick:F,children:[e.jsx("input",{ref:v,type:"file",className:"hidden",accept:s,multiple:a,onChange:E=>S(E.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"]}),i&&e.jsxs("p",{className:"text-xs text-gray-500",children:["Maximum file size: ",We(i)]})]})]}),c.length>0&&e.jsx("div",{className:"mt-3 space-y-2",children:c.map((E,M)=>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:E.name}),e.jsxs("span",{className:"text-xs text-gray-500",children:["(",We(E.size),")"]})]}),e.jsx("button",{type:"button",onClick:A=>{A.stopPropagation(),I(M)},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"})})})]},M))}),r&&e.jsx("p",{className:"mt-1 text-sm text-danger-500",children:r})]})},or=l.forwardRef(({countryCode:t="+1",onCountryCodeChange:r,className:s,...a},i)=>e.jsxs("div",{className:"w-full",children:[a.label&&e.jsxs("label",{className:"block text-sm font-medium mb-1",style:{color:"var(--metakyc-text-primary, #374151)"},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:o=>r==null?void 0:r(o.target.value),className:re("w-20 rounded-lg border px-3 py-2 text-sm","focus:outline-none focus:ring-2 focus:ring-offset-0"),style:{backgroundColor:"var(--metakyc-input-bg, #ffffff)",color:"var(--metakyc-text-primary, #111827)",borderColor:"var(--metakyc-border, #d1d5db)"},placeholder:"+1"}),e.jsx(ne,{ref:i,type:"tel",className:re("flex-1",s),...a,label:""})]}),a.error&&e.jsx("p",{className:"mt-1 text-sm text-danger-500",children:a.error})]}));or.displayName="PhoneInput";/**
|
|
1
|
+
"use strict";var vr=Object.defineProperty;var kr=(t,r,s)=>r in t?vr(t,r,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[r]=s;var X=(t,r,s)=>kr(t,typeof r!="symbol"?r+"":r,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const wr=require("axios"),l=require("react"),e=require("react/jsx-runtime"),qe=require("react-dom"),Se=require("react-hook-form"),we=require("zod");function jr(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 rt=jr(l);var G=(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))(G||{}),He=(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))(He||{}),xe=(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))(xe||{}),ot=(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))(ot||{}),lt=(t=>(t[t.LowRisk=0]="LowRisk",t[t.MediumRisk=1]="MediumRisk",t[t.HighRisk=2]="HighRisk",t[t.Alert=3]="Alert",t))(lt||{}),Ne=(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))(Ne||{}),Ce=(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))(Ce||{}),ct=(t=>(t[t.ProviderResultPending=0]="ProviderResultPending",t[t.ProviderResultReceived=1]="ProviderResultReceived",t[t.Canceled=2]="Canceled",t[t.ExtendedToNewApplicant=3]="ExtendedToNewApplicant",t))(ct||{}),dt=(t=>(t[t.None=0]="None",t[t.ProviderResultPending=1]="ProviderResultPending",t[t.ProviderResultReceived=2]="ProviderResultReceived",t[t.Canceled=3]="Canceled",t))(dt||{}),he=(t=>(t[t.Onfido=0]="Onfido",t[t.Sumsub=2]="Sumsub",t[t.SardinAI=3]="SardinAI",t))(he||{}),ut=(t=>(t[t.Individual=0]="Individual",t[t.Company=1]="Company",t))(ut||{}),Ue=(t=>(t[t.Male=0]="Male",t[t.Female=1]="Female",t[t.Other=2]="Other",t))(Ue||{}),pt=(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))(pt||{}),mt=(t=>(t[t.Pending=0]="Pending",t[t.Approved=1]="Approved",t[t.Rejected=2]="Rejected",t[t.RequiresRevision=3]="RequiresRevision",t))(mt||{}),ht=(t=>(t[t.SingleChoice=0]="SingleChoice",t[t.MultipleChoice=1]="MultipleChoice",t[t.Text=2]="Text",t))(ht||{}),be=(t=>(t[t.String=0]="String",t[t.Integer=1]="Integer",t[t.Money=2]="Money",t[t.Boolean=3]="Boolean",t[t.Date=4]="Date",t[t.Country=5]="Country",t[t.DigitOnly=6]="DigitOnly",t))(be||{}),xt=(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))(xt||{}),gt=(t=>(t[t.None=0]="None",t[t.Country=1]="Country",t))(gt||{}),pe=(t=>(t[t.Individual=0]="Individual",t[t.Sophisticated=1]="Sophisticated",t[t.HighNetWorth=2]="HighNetWorth",t[t.Business=3]="Business",t))(pe||{}),yt=(t=>(t[t.Retail=0]="Retail",t[t.Professional=1]="Professional",t[t.EligibleCounterparty=2]="EligibleCounterparty",t))(yt||{});const Ie={Nationality:10,Address:20,CountryOfBirth:30,PhoneNumber:40,UboAddress:50},Re={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:"select",countriesType:Ie.PhoneNumber},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",countriesType:Ie.Address},nationality:{label:"Nationality",type:"select",countriesType:Ie.Nationality},otherNationality:{label:"Other Nationalities",type:"multiselect",countriesType:Ie.Nationality},countryOfBirth:{label:"Country of Birth",type:"select",countriesType:Ie.CountryOfBirth},placeOfBirth:{label:"Place of Birth",type:"text"},taxCountry:{label:"Tax Country",type:"select",countriesType:Ie.Address},taxNumber:{label:"Tax Number",type:"text"},defaultLanguage:{label:"Default Language",type:"select"},educationLevel:{label:"Education Level",type:"text"},occupation:{label:"Occupation",type:"text"}},ft=["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 ae=(t=>(t.Default="default",t.Corporate="corporate",t.Fintech="fintech",t.Healthcare="healthcare",t.Modern="modern",t.Minimal="minimal",t))(ae||{});const bt={timeout:3e4,retries:3,locale:"en",endpoints:{pattern:"host-controller"}};class vt{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 fe extends Error{constructor(s,a,i,o,c){super(s);X(this,"response");this.code=a,this.details=i,this.validationErrors=o,this.name="MetaKYCError",this.response=c,Object.setPrototypeOf(this,fe.prototype)}}class Fe{static handleApiError(r){return new fe(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 fe(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 fe(s.result.message,r.response.status,`HTTP ${r.response.status}: ${r.response.statusText}`,void 0,r.response):new fe((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 fe("No response from server",0,"The request was made but no response was received. Please check your network connection."):new fe(r.message||"An unexpected error occurred",0,r.toString())}static isMetaKYCError(r){return r instanceof fe}}class kt{constructor(r){X(this,"axiosInstance");X(this,"endpointBuilder");X(this,"config");this.config={...bt,...r},this.endpointBuilder=new vt(this.config.endpoints),this.axiosInstance=wr.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 i;const a=s.config;return((i=s.response)==null?void 0:i.status)>=500&&!a._retry&&(a._retry=!0,a._retryCount=(a._retryCount||0)+1,a._retryCount<(this.config.retries||3))?(await new Promise(o=>setTimeout(o,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 i=this.buildEndpoint(r,s),o=await this.axiosInstance.get(i,{params:a});return this.handleResponse(o)}catch(i){throw Fe.handleAxiosError(i)}}async post(r,s,a){try{const i=this.buildEndpoint(r,s),o=await this.axiosInstance.post(i,a);return this.handleResponse(o)}catch(i){throw Fe.handleAxiosError(i)}}async put(r,s,a){try{const i=this.buildEndpoint(r,s),o=await this.axiosInstance.put(i,a);return this.handleResponse(o)}catch(i){throw Fe.handleAxiosError(i)}}async delete(r,s,a){try{const i=this.buildEndpoint(r,s),o=await this.axiosInstance.delete(i,{params:a});return this.handleResponse(o)}catch(i){throw Fe.handleAxiosError(i)}}handleResponse(r){const s=r.data;if(!s.success&&s.error)throw Fe.handleApiError(s.error);return s}getAxiosInstance(){return this.axiosInstance}}class wt{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 jt{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 St{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 Nt{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 Ct{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 Rt{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 At{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 Et{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 It{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 ce={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"}}},Pt={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"}},Tt={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"}},Ft={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"}}},Lt={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"}},Dt={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"}},Mt={[ae.Default]:ce,[ae.Corporate]:Pt,[ae.Fintech]:Tt,[ae.Healthcare]:Ft,[ae.Modern]:Lt,[ae.Minimal]:Dt};function Le(t){return Mt[t]||ce}class Ot{constructor(r){this.httpClient=r}async getThemeConfiguration(){var r;try{const s=await this.httpClient.get("Tenant","GetThemeConfiguration");if(!s.result.isEnabled)return Le(ae.Default);let a=s.result.preset?Le(s.result.preset):Le(ae.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 i=typeof s.result.applicantFormPages=="string"?JSON.parse(s.result.applicantFormPages):s.result.applicantFormPages;Array.isArray(i)&&i.length>0&&(a.applicantFormPages=i.map(o=>{const c=!o._v||o._v<4;return{...o,fields:(o.fields||[]).map(u=>({...u,colSpan:c?u.colSpan===1?2:4:Math.min(4,Math.max(1,u.colSpan??4))}))}}))}catch{}if(s.result.reviewPageFields)try{const i=typeof s.result.reviewPageFields=="string"?JSON.parse(s.result.reviewPageFields):s.result.reviewPageFields;Array.isArray(i)&&i.length>0&&(a.reviewPageFields=i)}catch{}return s.result.reviewPageDisabled&&(a.reviewPageDisabled=!0),a}catch(s){return console.warn("[ThemeService] Failed to fetch theme configuration:",s),Le(ae.Default)}}async saveThemeConfiguration(r){await this.httpClient.post("Tenant","SaveThemeConfiguration",r)}getAvailablePresets(){return[{id:ae.Default,name:"Default"},{id:ae.Corporate,name:"Corporate"},{id:ae.Fintech,name:"Fintech"},{id:ae.Healthcare,name:"Healthcare"},{id:ae.Modern,name:"Modern"},{id:ae.Minimal,name:"Minimal"}]}getPreviewTheme(r,s){const a=Le(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 zt{constructor(){X(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(i=>{try{i(s)}catch(o){console.error(`Error in event listener for "${r}":`,o)}})}clear(){this.listeners.clear()}clearEvent(r){this.listeners.delete(r)}}class Bt{constructor(){X(this,"events",new zt);X(this,"_applicantId",null);X(this,"_progress",null);X(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)||xe.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===xe.Finished}get isOnHold(){return this.status===xe.OnHold}get isInProgress(){return this.status===xe.InProgress}setApplicantId(r){this._applicantId=r}updateProgress(r){var a,i;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)!==((i=r.currentStep)==null?void 0:i.order)&&this.events.emit("stepChanged",r.currentStep),this.events.emit("statusChanged",r.status),r.status===xe.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 $t{constructor(){X(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: ${G[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: ${G[r]}`);return a.submitData(s)}}class _t{constructor(r,s,a,i,o,c,u,h){X(this,"state");X(this,"stepRouter");this.applicantService=r,this.questionnaireService=s,this.uploadDocumentService=a,this.appropriatenessTestService=i,this.overviewService=o,this.riskScoringService=c,this.investorCategorizationService=h,this.state=new Bt,this.stepRouter=new $t,this.registerStepHandlers()}registerStepHandlers(){this.stepRouter.registerHandler(G.Questionaries,{loadData:r=>this.questionnaireService.getQuestionnaire(r),submitData:async r=>{await this.questionnaireService.fillQuestionnaire(r)}}),this.stepRouter.registerHandler(G.UploadDocument,{loadData:r=>this.uploadDocumentService.getUploadDocument(r),submitData:r=>this.uploadDocumentService.fillUploadDocument(r)}),this.stepRouter.registerHandler(G.AppropriatenessTest,{loadData:r=>this.appropriatenessTestService.getAppropriatenessTest(r),submitData:async r=>{await this.appropriatenessTestService.fillAppropriatenessTest(r)}}),this.stepRouter.registerHandler(G.Overview,{loadData:r=>this.overviewService.getOverviewData(r),submitData:r=>this.overviewService.passOverview(r.applicantId)}),this.stepRouter.registerHandler(G.RiskScoring,{loadData:r=>this.riskScoringService.getRiskCriterias(r),submitData:async r=>{await this.riskScoringService.submitRiskScoring(r)}}),this.stepRouter.registerHandler(G.IdentitySdk,{loadData:async r=>({applicantId:r,message:"Identity verification required"}),submitData:async()=>{}}),this.stepRouter.registerHandler(G.InvestorCategorization,{loadData:r=>this.investorCategorizationService.getInvestorCategorization(r),submitData:async r=>{await this.investorCategorizationService.setInvestorCategorization(r)}}),this.stepRouter.registerHandler(G.ManualReview,{loadData:async r=>({applicantId:r,message:"Your application is under manual review"}),submitData:async()=>{}}),this.stepRouter.registerHandler(G.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 et(t,r){return new Promise((s,a)=>{if(r&&document.getElementById(r)){s();return}const i=document.createElement("script");i.src=t,r&&(i.id=r),i.async=!0,i.onload=()=>s(),i.onerror=()=>a(new Error(`Failed to load script: ${t}`)),document.head.appendChild(i)})}function Sr(t){return!!document.getElementById(t)}function Nr(t){const r=document.getElementById(t);r&&r.remove()}class Ht{constructor(r){X(this,"sdk",null);X(this,"config");this.config=r}async loadSDK(){await et("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 Ut{constructor(r){X(this,"sdk",null);X(this,"config");this.config=r}async loadSDK(){await et("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 Kt{constructor(r){X(this,"sardineContext",null);X(this,"config");X(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(),i=document.createElement("script");i.type="text/javascript",i.async=!0,i.src=`https://${a}/assets/loader.min.js`,i.onload=()=>{console.log("[SardinAI] SDK loaded successfully"),r()},i.onerror=()=>{s(new Error("Failed to load SardinAI SDK"))};const o=document.getElementsByTagName("script")[0];o&&o.parentNode?o.parentNode.insertBefore(i,o):document.head.appendChild(i)})}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:i,enableBiometrics:o,enablePortScanning:c}=this.config;this.sardineContext=window._Sardine.createContext({clientId:s,sessionKey:this.sessionKey,userIdHash:void 0,flow:i||window.location.pathname,environment:a||"production",parentElement:document.body,enableBiometrics:o!==!1,enablePortScanning:c===!0,region:this.config.region,onDeviceResponse:u=>{console.log(`[SardinAI] Device ID: ${u.deviceId}`)},onConfigUpdate:(u,h,p)=>{switch(u){case"SESSION_UPDATE_FAILED":console.error("[SardinAI] Session update failed:",p);break;case"SESSION_UPDATED":console.log("[SardinAI] Session updated:",h);break;case"SESSION_NO_UPDATE":console.log("[SardinAI] No session update");break;default:console.warn("[SardinAI] Unknown event:",u)}}}),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:i,flow:o}=this.config;a.src=`https://${r}/v1/a.png?clientId=${i}&sessionKey=${this.sessionKey}&flow=${o||"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,i)=>{switch(s){case"SESSION_UPDATE_FAILED":console.error("[SardinAI] Config update failed:",i);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 Pe{static createProvider(r,s){switch(r){case he.Sumsub:return new Ht(s);case he.Onfido:return new Ut(s);case he.SardinAI:return new Kt(s);default:throw new Error(`Unsupported identity provider: ${r}`)}}static parseProviderConfig(r,s,a){var i;switch(r){case he.Sumsub:return{accessToken:s.accessToken||s.token,applicantEmail:s.email,applicantPhone:s.phone,externalUserId:s.externalUserId,lang:s.lang||"en"};case he.Onfido:return{token:s.token||s.sdkToken};case he.SardinAI:const o=((i=a==null?void 0:a.identityProviders)==null?void 0:i.sardinai)||{};return{clientId:o.clientId||s.clientId,sessionKey:o.sessionKey||s.sessionKey,environment:o.environment||s.environment||"production",flow:o.flow||s.flow,region:o.region,enableBiometrics:o.enableBiometrics,enablePortScanning:o.enablePortScanning};default:throw new Error(`Unsupported identity provider: ${r}`)}}}class Wt{constructor(r){X(this,"currentTheme",ce);X(this,"customStyleElement",null);X(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,"input-bg":r.inputBg||r.background,"input-text":r.inputText||r.textPrimary,"input-border":r.inputBorder||r.border,"input-border-focus":r.inputBorderFocus||r.primary,"input-placeholder":r.inputPlaceholder||r.textMuted};Object.entries(s).forEach(([i,o])=>{this.container.style.setProperty(`--metakyc-${i}`,o)}),(a=this.currentTheme.darkMode)!=null&&a.colors&&this.applyDarkModeColors(this.currentTheme.darkMode.colors)}applyDarkModeColors(r){Object.entries(r).forEach(([s,a])=>{if(a){const i=`--metakyc-dark-${this.kebabCase(s)}`;this.container.style.setProperty(i,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 i=`--metakyc-${this.kebabCase(s)}`;this.container.style.setProperty(i,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||ce.name,title:r.title||ce.title,logo:{...ce.logo,...r.logo},colors:{...ce.colors,...r.colors},typography:r.typography?{...ce.typography,...r.typography}:ce.typography,spacing:r.spacing?{...ce.spacing,...r.spacing}:ce.spacing,customCSS:r.customCSS,darkMode:r.darkMode?{colors:{...(s=ce.darkMode)==null?void 0:s.colors,...r.darkMode.colors}}:ce.darkMode,applicantFormVisibleFields:r.applicantFormVisibleFields,applicantFormRequiredFields:r.applicantFormRequiredFields,allowedLanguages:r.allowedLanguages,applicantFormPages:r.applicantFormPages,reviewPageFields:r.reviewPageFields,reviewPageDisabled:r.reviewPageDisabled}}getCurrentTheme(){return this.currentTheme}resetTheme(){this.applyTheme(ce)}cleanup(){this.customStyleElement&&(this.customStyleElement.remove(),this.customStyleElement=null)}kebabCase(r){return r.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}}const tt=l.createContext(null),Cr=({config:t,children:r})=>{const[s,a]=l.useState(null),i=l.useRef(!1),o=l.useRef(!1),c=l.useMemo(()=>{const h=new kt(t),p=new wt(h),v=new jt(h),S=new St(h),y=new Nt(h),j=new Ct(h),f=new Rt(h),F=new At(h),I=new Et(h),E=new It(h),M=new Ot(h),A=new Wt;return{httpClient:h,applicantService:p,questionnaireService:v,uploadDocumentService:S,appropriatenessTestService:y,overviewService:j,riskScoringService:f,identityService:F,baseInformationService:I,investorCategorizationService:E,themeService:M,themeManager:A}},[t]),u=l.useMemo(()=>({config:t,...c,currentTheme:s,createOrchestrator:()=>new _t(c.applicantService,c.questionnaireService,c.uploadDocumentService,c.appropriatenessTestService,c.overviewService,c.riskScoringService,c.identityService,c.investorCategorizationService)}),[t,c,s]);return l.useEffect(()=>((async()=>{if(i.current||o.current){console.log("[MetaKYC] Theme already loading or loaded, skipping...");return}i.current=!0;try{if(t.theme){console.log("[MetaKYC] Applying static theme from config"),c.themeManager.applyTheme(t.theme),a(c.themeManager.getCurrentTheme()),o.current=!0;return}console.log("[MetaKYC] Fetching theme from backend...");const p=await c.themeService.getThemeConfiguration();c.themeManager.applyTheme(p),a(c.themeManager.getCurrentTheme()),o.current=!0,console.log("[MetaKYC] Theme loaded and applied",p)}catch(p){console.warn("[MetaKYC] Failed to load theme, using default:",p),a(c.themeManager.getCurrentTheme()),o.current=!0}finally{i.current=!1}})(),()=>{c.themeManager.cleanup()}),[]),e.jsx(tt.Provider,{value:u,children:r})};function de(){const t=l.useContext(tt);if(!t)throw new Error("useMetaKYC must be used within a MetaKYCProvider");return t}async function Yt(t){return new Promise((r,s)=>{const a=new FileReader;a.readAsDataURL(t),a.onload=()=>{const o=a.result.split(",")[1];r(o)},a.onerror=i=>s(i)})}function Rr(t,r){return t.size<=r}function Ar(t,r){return r.split(",").map(a=>a.trim()).some(a=>{if(a.endsWith("/*")){const i=a.slice(0,-2);return t.type.startsWith(i)}return t.type===a})}function We(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 Er(t){return t}function re(...t){return t.filter(Boolean).join(" ")}const De={APPLICANT_ID:"metakyc_applicant_id",WORKFLOW_STATE:"metakyc_workflow_state"};function qt(t){try{localStorage.setItem(De.APPLICANT_ID,t.toString())}catch(r){console.warn("Failed to save applicant ID to storage:",r)}}function Qt(){try{const t=localStorage.getItem(De.APPLICANT_ID);return t?parseInt(t,10):null}catch(t){return console.warn("Failed to retrieve applicant ID from storage:",t),null}}function Gt(){try{localStorage.removeItem(De.APPLICANT_ID)}catch(t){console.warn("Failed to clear applicant ID from storage:",t)}}function Vt(t){try{localStorage.setItem(De.WORKFLOW_STATE,JSON.stringify(t))}catch(r){console.warn("Failed to save workflow state to storage:",r)}}function Ir(){try{const t=localStorage.getItem(De.WORKFLOW_STATE);return t?JSON.parse(t):null}catch(t){return console.warn("Failed to retrieve workflow state from storage:",t),null}}function Jt(){try{localStorage.removeItem(De.WORKFLOW_STATE)}catch(t){console.warn("Failed to clear workflow state from storage:",t)}}function Pr(){Gt(),Jt()}function Zt(t){const{createOrchestrator:r}=de(),[s,a]=l.useState(null),[i,o]=l.useState(!1),[c,u]=l.useState(null),h=l.useRef(null),p=t||Qt();l.useEffect(()=>{h.current||(h.current=r())},[r]),l.useEffect(()=>{var A;s&&p&&(qt(p),Vt({applicantId:p,currentStepOrder:(A=s.currentStep)==null?void 0:A.order,status:s.status,lastUpdated:new Date().toISOString(),workflowKey:s.workFlowKey,nextWorkflowKey:s.nextWorkflowKey}))},[s,p]);const v=l.useRef(!1),S=l.useRef(!1),y=l.useCallback(async()=>{if(!(!p||!h.current)){if(v.current){console.log("[Workflow] Load already in progress, skipping...");return}v.current=!0,o(!0),u(null);try{const A=await h.current.initialize(p);a(A),S.current=!0}catch(A){u(A)}finally{o(!1),v.current=!1}}},[p]);l.useEffect(()=>{p&&!S.current&&y()},[p,y]);const j=l.useCallback(async()=>{if(h.current){if(v.current){console.log("[Workflow] Refresh already in progress, skipping...");return}v.current=!0,o(!0),u(null);try{const A=await h.current.refreshProgress();a(A)}catch(A){u(A)}finally{o(!1),v.current=!1}}},[]),f=l.useCallback(async()=>{if(h.current){o(!0),u(null);try{const A=await h.current.moveToNextStep();a(A)}catch(A){u(A)}finally{o(!1)}}},[]),F=l.useCallback(async()=>{if(h.current){o(!0),u(null);try{const A=await h.current.moveToPreviousStep();a(A)}catch(A){u(A)}finally{o(!1)}}},[]),I=l.useCallback(async A=>{if(h.current){o(!0),u(null);try{await h.current.submitCurrentStep(A);const P=await h.current.refreshProgress();a(P)}catch(P){throw u(P),P}finally{o(!1)}}},[]),E=rt.useMemo(()=>s!=null&&s.stepInfoList?[...s.stepInfoList].sort((A,P)=>A.order-P.order):[],[s==null?void 0:s.stepInfoList]),M=rt.useMemo(()=>s?s.nextWorkflowKey&&s.nextWorkflowKey!==s.workFlowKey:!1,[s]);return{progress:s,applicantId:p,currentStep:(s==null?void 0:s.currentStep)||null,steps:E,status:(s==null?void 0:s.status)||xe.None,workflowResult:(s==null?void 0:s.workflowResult)||null,workflowKey:s==null?void 0:s.workFlowKey,nextWorkflowKey:s==null?void 0:s.nextWorkflowKey,hasWorkflowChanged:M,isLoading:i,error:c,isComplete:(s==null?void 0:s.status)===xe.Finished,isOnHold:(s==null?void 0:s.status)===xe.OnHold,refreshProgress:j,moveToNext:f,moveBack:F,submitCurrentStep:I,orchestrator:h.current}}function Xt(t){const{questionnaireService:r,applicantService:s}=de(),[a,i]=l.useState(null),[o,c]=l.useState({}),[u,h]=l.useState(!1),[p,v]=l.useState(!1),[S,y]=l.useState(null),j=l.useRef(!1),f=l.useRef(null),F=l.useCallback(async()=>{var E,M;if(t){if(j.current){console.log("[Questionnaire] Load already in progress, skipping...");return}j.current=!0,h(!0),y(null);try{const[A,P]=await Promise.all([r.getQuestionnaire(t),s.getApplicantData(t).catch(()=>null)]);if(i(A),(E=P==null?void 0:P.questionnaireResults)!=null&&E.length&&A){const Y=new Map;for(const w of P.questionnaireResults)w.question&&((M=w.answers)!=null&&M.length)&&Y.set(w.question.trim().toLowerCase(),w.answers);const J={},R=A.questionGroups.flatMap(w=>w.questions??[]);for(const w of R){const $=w.text.trim().toLowerCase();Y.has($)&&(J[w.id]=Y.get($))}c(J)}f.current=t}catch(A){y(A)}finally{h(!1),j.current=!1}}},[t,r,s]);l.useEffect(()=>{t&&f.current!==t&&F()},[t]);const I=l.useCallback(async E=>{v(!0),y(null);try{return await r.fillQuestionnaire(E)}catch(M){throw y(M),M}finally{v(!1)}},[r]);return{questionnaire:a,initialAnswers:o,isLoading:u,isSubmitting:p,error:S,load:F,submit:I}}function er(t){const{uploadDocumentService:r}=de(),[s,a]=l.useState(null),[i,o]=l.useState(!1),[c,u]=l.useState(!1),[h,p]=l.useState(0),[v,S]=l.useState(null),y=l.useRef(!1),j=l.useRef(null),f=l.useCallback(async()=>{if(t){if(y.current){console.log("[UploadDocument] Load already in progress, skipping...");return}y.current=!0,o(!0),S(null);try{const I=await r.getUploadDocument(t);a(I),j.current=t}catch(I){S(I)}finally{o(!1),y.current=!1}}},[t,r]);l.useEffect(()=>{t&&j.current!==t&&f()},[t]);const F=l.useCallback(async I=>{u(!0),p(0),S(null);try{await r.fillUploadDocument(I),p(100)}catch(E){throw S(E),E}finally{u(!1)}},[r]);return{uploadDocument:s,isLoading:i,isSubmitting:c,uploadProgress:h,error:v,load:f,submit:F}}function Tr(t){const{appropriatenessTestService:r}=de(),[s,a]=l.useState(null),[i,o]=l.useState(!1),[c,u]=l.useState(!1),[h,p]=l.useState(null),[v,S]=l.useState(null),y=l.useRef(!1),j=l.useRef(null),f=l.useCallback(async()=>{if(t){if(y.current){console.log("[AppropriatenessTest] Load already in progress, skipping...");return}y.current=!0,o(!0),p(null);try{const I=await r.getAppropriatenessTest(t);a(I),j.current=t}catch(I){p(I)}finally{o(!1),y.current=!1}}},[t,r]);l.useEffect(()=>{t&&j.current!==t&&f()},[t]);const F=l.useCallback(async I=>{u(!0),p(null);try{const E=await r.fillAppropriatenessTest(I);return S(E),E}catch(E){throw p(E),E}finally{u(!1)}},[r]);return{test:s,result:v,isLoading:i,isSubmitting:c,error:h,load:f,submit:F}}function tr(t){const{overviewService:r}=de(),[s,a]=l.useState(null),[i,o]=l.useState(!1),[c,u]=l.useState(!1),[h,p]=l.useState(null),v=l.useRef(!1),S=l.useRef(null),y=l.useCallback(async()=>{if(t){if(v.current){console.log("[Overview] Load already in progress, skipping...");return}v.current=!0,o(!0),p(null);try{const f=await r.getOverviewData(t);a(f),S.current=t}catch(f){p(f)}finally{o(!1),v.current=!1}}},[t,r]);l.useEffect(()=>{t&&S.current!==t&&y()},[t]);const j=l.useCallback(async()=>{if(t){u(!0),p(null);try{await r.passOverview(t)}catch(f){throw p(f),f}finally{u(!1)}}},[t,r]);return{overview:s,isLoading:i,isSubmitting:c,error:h,load:y,passOverview:j}}function rr(t){const{identityService:r}=de(),[s,a]=l.useState(null),[i,o]=l.useState(!1),[c,u]=l.useState(null),h=l.useRef(!1),p=l.useCallback(async(y,j)=>{if(t){if(h.current){console.log("[Identity] Request already in progress, skipping...");return}h.current=!0,o(!0),u(null);try{const f={applicantId:t,restart:!1,redirectUrl:y||"",ttl:j||604800};console.log("Identity request input:",f);const F=await r.identityRequest(f);return console.log("Identity request result:",F),a(F),F}catch(f){throw u(f),f}finally{o(!1),h.current=!1}}},[t,r]),v=l.useCallback(async(y,j)=>{if(t){o(!0),u(null);try{const f={applicantId:t,restart:!1,redirectUrl:y,ttl:j},F=await r.identityCompanyRequest(f);return a(F),F}catch(f){throw u(f),f}finally{o(!1)}}},[t,r]),S=l.useCallback(async()=>{if(t){if(h.current){console.log("[Identity] Restart already in progress, skipping...");return}h.current=!0,o(!0),u(null);try{const y={applicantId:t,restart:!0,redirectUrl:"",ttl:604800};console.log("Restarting identity with input:",y);const j=await r.identityRequest(y);return console.log("Restart identity result:",j),a(j),j}catch(y){throw u(y),y}finally{o(!1),h.current=!1}}},[t,r]);return{identityData:s,provider:(s==null?void 0:s.provider)||null,token:(s==null?void 0:s.publicProviderTokenObject)||null,isLoading:i,error:c,requestIdentity:p,requestCompanyIdentity:v,restartIdentity:S}}function sr(t){const{riskScoringService:r,applicantService:s}=de(),[a,i]=l.useState(null),[o,c]=l.useState({}),[u,h]=l.useState(!1),[p,v]=l.useState(!1),[S,y]=l.useState(null),[j,f]=l.useState(null),F=l.useRef(!1),I=l.useRef(null),E=l.useCallback(async()=>{var A;if(t){if(F.current){console.log("[RiskScoring] Load already in progress, skipping...");return}F.current=!0,h(!0),y(null);try{const[P,Y]=await Promise.all([r.getRiskCriterias(t),s.getApplicantData(t).catch(()=>null)]);if(i(P),(A=Y==null?void 0:Y.riskScoringResults)!=null&&A.length){const J=Y.riskScoringResults[0],R={};for(const w of J.riskCriteriaResults??[])if(w.riskCriteriaId!=null&&w.answer!=null&&w.answer!==""){const $=[...new Set(w.answer.split(",").map(K=>K.trim()).filter(K=>K!==""))];$.length>0&&(R[w.riskCriteriaId]=$)}c(R)}I.current=t}catch(P){y(P)}finally{h(!1),F.current=!1}}},[t,r,s]);l.useEffect(()=>{t&&I.current!==t&&E()},[t]);const M=l.useCallback(async A=>{v(!0),y(null);try{const P=await r.submitRiskScoring(A);return f(P),P}catch(P){throw y(P),P}finally{v(!1)}},[r]);return{criteria:a,initialAnswers:o,result:j,isLoading:u,isSubmitting:p,error:S,load:E,submit:M}}function ar(){const{applicantService:t,config:r}=de(),[s,a]=l.useState(!1),[i,o]=l.useState(null),c=l.useRef(!1),u=l.useRef(!1),h=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(j){const f=Math.random()*16|0;return(j==="x"?f:f&3|8).toString(16)}),p=l.useCallback(async j=>{var f;if(c.current)throw console.log("[Applicant] Create already in progress, skipping..."),new Error("Creation already in progress");c.current=!0,a(!0),o(null);try{if(j.applicantAdditionalDatas||(j.applicantAdditionalDatas=[]),(f=r.identityProviders)!=null&&f.sardinai){const I=h();console.log("[SardinAI] Generated session key:",I),j.applicantAdditionalDatas.push({paramName:"sessionKey",value:I})}return await t.createApplicant(j)}catch(F){throw o(F),F}finally{a(!1),c.current=!1}},[t,r]),v=l.useCallback(async j=>{a(!0),o(null);try{return await t.createCompanyApplicant(j)}catch(f){throw o(f),f}finally{a(!1)}},[t]),S=l.useCallback(async j=>{if(u.current)throw console.log("[Applicant] Data load already in progress, skipping..."),new Error("Data load already in progress");u.current=!0,a(!0),o(null);try{return await t.getApplicantData(j)}catch(f){throw o(f),f}finally{a(!1),u.current=!1}},[t]),y=l.useCallback(async j=>{a(!0),o(null);try{await t.stopProgress(j)}catch(f){throw o(f),f}finally{a(!1)}},[t]);return{isLoading:s,error:i,createApplicant:p,createCompanyApplicant:v,getApplicantData:S,stopProgress:y}}const W=({children:t,variant:r="primary",size:s="md",isLoading:a=!1,disabled:i,className:o,...c})=>{const u="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",h={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"},p={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:re(u,h[r],p[s],o),disabled:i||a,...c,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]})},ne=l.forwardRef(({label:t,error:r,helperText:s,leftIcon:a,rightIcon:i,className:o,style:c,...u},h)=>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,u.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:h,className:re("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",a?"pl-10":"",i?"pr-10":"",o),style:{backgroundColor:"var(--metakyc-input-bg, #ffffff)",color:"var(--metakyc-input-text, var(--metakyc-text-primary, #111827))",borderColor:r?"var(--metakyc-danger, #ef4444)":"var(--metakyc-input-border, var(--metakyc-border, #d1d5db))",...c},...u}),i&&e.jsx("div",{className:"absolute inset-y-0 right-0 pr-3 flex items-center pointer-events-none",children:i})]}),r&&e.jsx("p",{className:"mt-1 text-sm",style:{color:"var(--metakyc-danger, #ef4444)"},children:r}),!r&&s&&e.jsx("p",{className:"mt-1 text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:s})]}));ne.displayName="Input";const _=({children:t,className:r,...s})=>e.jsx("div",{className:re("metakyc-card rounded-xl shadow-sm border",r),style:{backgroundColor:"var(--metakyc-surface, #ffffff)",borderColor:"var(--metakyc-border, #e5e7eb)"},...s,children:t}),ie=({children:t,className:r,...s})=>e.jsx("div",{className:re("px-6 py-4 border-b",r),style:{borderColor:"var(--metakyc-border, #e5e7eb)"},...s,children:t}),H=({children:t,className:r,...s})=>e.jsx("div",{className:re("px-6 py-4",r),...s,children:t}),le=({children:t,className:r,...s})=>e.jsx("div",{className:re("px-6 py-4 border-t",r),style:{borderColor:"var(--metakyc-border, #e5e7eb)"},...s,children:t}),ve=({children:t,variant:r="default",className:s,...a})=>{const i={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:re("inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium",i[r],s),...a,children:t})},ge=({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:re("flex items-center justify-center",r),...s,children:e.jsxs("svg",{className:re("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"})]})})},Qe=l.forwardRef(({label:t,error:r,helperText:s,options:a,placeholder:i,className:o,style:c,...u},h)=>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,u.required&&e.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),e.jsxs("select",{ref:h,className:re("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":"",o),style:{backgroundColor:"var(--metakyc-input-bg, #ffffff)",color:"var(--metakyc-input-text, var(--metakyc-text-primary, #111827))",borderColor:r?"var(--metakyc-danger, #ef4444)":"var(--metakyc-input-border, var(--metakyc-border, #d1d5db))",...c},...u,children:[i&&e.jsx("option",{value:"",disabled:!0,style:{backgroundColor:"var(--metakyc-input-bg, #ffffff)",color:"var(--metakyc-text-secondary, #6b7280)"},children:i},"__placeholder__"),a.map((p,v)=>e.jsx("option",{value:p.value,disabled:p.disabled,style:{backgroundColor:"var(--metakyc-input-bg, #ffffff)",color:p.disabled?"var(--metakyc-text-muted, #9ca3af)":"var(--metakyc-input-text, var(--metakyc-text-primary, #111827))"},children:p.label},p.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})]}));Qe.displayName="Select";const st=280,nr=({label:t,value:r,onChange:s,options:a,placeholder:i="Select...",disabled:o=!1,required:c=!1})=>{const[u,h]=l.useState(!1),[p,v]=l.useState(""),[S,y]=l.useState(null),j=l.useRef(null),f=l.useRef(null),F=l.useRef(null),I=l.useCallback(()=>{if(!f.current)return null;const C=f.current.getBoundingClientRect(),Z=window.innerHeight-C.bottom<st&&C.top>st;return{top:Z?C.top:C.bottom+4,left:C.left,width:C.width,openUp:Z}},[]),E=l.useCallback(()=>{if(o)return;const C=I();C&&y(C),h(!0)},[o,I]),M=l.useCallback(()=>{h(!1),v("")},[]);l.useEffect(()=>{if(!u)return;const C=U=>{var me,se;const Z=U.target;!((me=j.current)!=null&&me.contains(Z))&&!((se=F.current)!=null&&se.contains(Z))&&M()};return document.addEventListener("mousedown",C),()=>document.removeEventListener("mousedown",C)},[u,M]),l.useEffect(()=>{if(!u)return;const C=()=>{const U=I();U&&y(U)};return window.addEventListener("scroll",C,!0),window.addEventListener("resize",C),()=>{window.removeEventListener("scroll",C,!0),window.removeEventListener("resize",C)}},[u,I]);const A=a.filter(C=>C.label.toLowerCase().includes(p.toLowerCase())),P=C=>{o||s(r.includes(C)?r.filter(U=>U!==C):[...r,C])},Y=(C,U)=>{U.stopPropagation(),o||s(r.filter(Z=>Z!==C))},J=C=>{var U;return((U=a.find(Z=>Z.value===C))==null?void 0:U.label)||C},R=f.current?getComputedStyle(f.current):null,w=(R==null?void 0:R.getPropertyValue("--metakyc-input-bg").trim())||"#ffffff",$=(R==null?void 0:R.getPropertyValue("--metakyc-input-border").trim())||(R==null?void 0:R.getPropertyValue("--metakyc-border").trim())||"#d1d5db",K=(R==null?void 0:R.getPropertyValue("--metakyc-input-text").trim())||(R==null?void 0:R.getPropertyValue("--metakyc-text-primary").trim())||"#111827",k=(R==null?void 0:R.getPropertyValue("--metakyc-text-secondary").trim())||"#6b7280",z=(R==null?void 0:R.getPropertyValue("--metakyc-primary").trim())||"#2563eb",T=(R==null?void 0:R.getPropertyValue("--metakyc-primary-light").trim())||"#eff6ff",D=(R==null?void 0:R.getPropertyValue("--metakyc-hover-bg").trim())||"#f9fafb",Q=u&&S&&e.jsxs("div",{ref:F,className:"metakyc-multiselect-dropdown",style:{position:"fixed",top:S.openUp?void 0:S.top,bottom:S.openUp?window.innerHeight-S.top+4:void 0,left:S.left,width:S.width,zIndex:99999,borderRadius:"8px",boxShadow:"0 4px 16px rgba(0,0,0,0.18)",border:`1px solid ${$}`,backgroundColor:w,overflow:"hidden"},children:[e.jsx("div",{style:{padding:"8px",borderBottom:`1px solid ${$}`},children:e.jsx("input",{type:"text",value:p,onChange:C=>v(C.target.value),placeholder:"Search...",autoFocus:!0,onClick:C=>C.stopPropagation(),className:"metakyc-multiselect-search w-full",style:{display:"block",width:"100%",padding:"6px 8px",fontSize:"13px",borderRadius:"6px",border:`1px solid ${$}`,backgroundColor:w,color:K,outline:"none",boxSizing:"border-box"}})}),e.jsx("ul",{style:{listStyle:"none",margin:0,padding:"4px 0",maxHeight:"192px",overflowY:"auto"},children:A.length===0?e.jsx("li",{style:{padding:"8px 12px",fontSize:"13px",color:k},children:"No results"}):A.map(C=>{const U=r.includes(C.value);return e.jsxs("li",{onClick:()=>P(C.value),className:"metakyc-multiselect-option",style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",fontSize:"13px",cursor:"pointer",backgroundColor:U?T:"transparent",color:U?z:K,userSelect:"none"},onMouseEnter:Z=>{U||(Z.currentTarget.style.backgroundColor=D)},onMouseLeave:Z=>{U||(Z.currentTarget.style.backgroundColor="transparent")},children:[e.jsx("input",{type:"checkbox",checked:U,readOnly:!0,style:{accentColor:z,pointerEvents:"none",flexShrink:0}}),e.jsx("span",{children:C.label})]},C.value)})}),r.length>0&&e.jsx("div",{style:{padding:"6px 12px",borderTop:`1px solid ${$}`},children:e.jsxs("button",{type:"button",onClick:()=>{s([]),v("")},style:{fontSize:"12px",color:"#ef4444",background:"none",border:"none",cursor:"pointer",padding:0},children:["Clear all (",r.length," selected)"]})})]});return e.jsxs("div",{className:"w-full metakyc-multiselect",ref:j,children:[t&&e.jsxs("label",{className:"block text-sm font-medium mb-1",style:{color:"var(--metakyc-text-primary, #374151)"},children:[t,c&&e.jsx("span",{style:{color:"var(--metakyc-error, #ef4444)",marginLeft:"4px"},children:"*"})]}),e.jsxs("div",{ref:f,onClick:()=>u?M():E(),className:re("metakyc-multiselect-trigger","min-h-[42px] w-full px-3 py-2 rounded-lg border text-sm transition-colors relative",o?"opacity-50 cursor-not-allowed":"cursor-pointer"),style:{backgroundColor:"var(--metakyc-input-bg, #ffffff)",borderColor:u?"var(--metakyc-input-border-focus, var(--metakyc-primary, #2563eb))":"var(--metakyc-input-border, var(--metakyc-border, #d1d5db))",outline:u?"2px solid var(--metakyc-input-border-focus, var(--metakyc-primary, #2563eb))":"none",outlineOffset:"-1px"},children:[r.length===0?e.jsx("span",{className:"metakyc-multiselect-placeholder leading-6",style:{color:"var(--metakyc-text-secondary, #9ca3af)"},children:i}):e.jsx("div",{className:"flex flex-wrap gap-1 pr-6",children:r.map(C=>e.jsxs("span",{className:"metakyc-multiselect-chip inline-flex items-center gap-1 px-2 py-0.5 rounded text-xs font-medium",style:{backgroundColor:"var(--metakyc-primary-light, #eff6ff)",color:"var(--metakyc-primary, #2563eb)"},children:[J(C),!o&&e.jsx("button",{type:"button",onClick:U=>Y(C,U),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:"×"})]},C))}),e.jsx("span",{className:"metakyc-multiselect-arrow absolute right-3 top-1/2 -translate-y-1/2 pointer-events-none text-xs",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:u?"▲":"▼"})]}),typeof document<"u"&&Q?qe.createPortal(Q,document.body):null]})},at=260,ke=({label:t,error:r,helperText:s,options:a,placeholder:i="Select...",value:o,onChange:c,disabled:u=!1,required:h=!1,className:p})=>{var se;const[v,S]=l.useState(!1),[y,j]=l.useState(""),[f,F]=l.useState(null),I=l.useRef(null),E=l.useRef(null),M=l.useRef(null),A=l.useRef(null),P=l.useCallback(()=>{if(!E.current)return null;const L=E.current.getBoundingClientRect(),te=window.innerHeight-L.bottom<at&&L.top>at;return{top:te?L.top:L.bottom+4,left:L.left,width:L.width,openUp:te}},[]),Y=l.useCallback(()=>{if(u)return;const L=P();L&&F(L),S(!0)},[u,P]),J=l.useCallback(()=>{S(!1),j("")},[]),R=()=>v?J():Y();l.useEffect(()=>{if(!v)return;const L=V=>{var je,Ae;const te=V.target;!((je=I.current)!=null&&je.contains(te))&&!((Ae=M.current)!=null&&Ae.contains(te))&&J()};return document.addEventListener("mousedown",L),()=>document.removeEventListener("mousedown",L)},[v,J]),l.useEffect(()=>{if(!v)return;const L=()=>{const V=P();V&&F(V)};return window.addEventListener("scroll",L,!0),window.addEventListener("resize",L),()=>{window.removeEventListener("scroll",L,!0),window.removeEventListener("resize",L)}},[v,P]),l.useEffect(()=>{v&&A.current&&setTimeout(()=>{var L;return(L=A.current)==null?void 0:L.focus()},0)},[v]);const w=a.filter(L=>L.label.toLowerCase().includes(y.toLowerCase())||L.value.toLowerCase().includes(y.toLowerCase())),$=(se=a.find(L=>L.value===o))==null?void 0:se.label,K=(L,V)=>{u||V||(c(L),J())},k=E.current?getComputedStyle(E.current):null,z=(k==null?void 0:k.getPropertyValue("--metakyc-input-bg").trim())||"#ffffff",T=(k==null?void 0:k.getPropertyValue("--metakyc-input-border").trim())||(k==null?void 0:k.getPropertyValue("--metakyc-border").trim())||"#d1d5db",D=(k==null?void 0:k.getPropertyValue("--metakyc-input-text").trim())||(k==null?void 0:k.getPropertyValue("--metakyc-text-primary").trim())||"#111827",Q=(k==null?void 0:k.getPropertyValue("--metakyc-text-secondary").trim())||"#6b7280",C=(k==null?void 0:k.getPropertyValue("--metakyc-primary").trim())||"#2563eb",U=(k==null?void 0:k.getPropertyValue("--metakyc-primary-light").trim())||"#eff6ff",Z=(k==null?void 0:k.getPropertyValue("--metakyc-hover-bg").trim())||"#f9fafb",me=v&&f&&e.jsxs("div",{ref:M,className:"metakyc-searchable-select-dropdown",style:{position:"fixed",top:f.openUp?void 0:f.top,bottom:f.openUp?window.innerHeight-f.top+4:void 0,left:f.left,width:f.width,zIndex:99999,borderRadius:"8px",boxShadow:"0 4px 16px rgba(0,0,0,0.18)",border:`1px solid ${T}`,backgroundColor:z,overflow:"hidden"},children:[e.jsx("div",{style:{padding:"8px",borderBottom:`1px solid ${T}`},children:e.jsx("input",{ref:A,type:"text",value:y,onChange:L=>j(L.target.value),placeholder:"Search...",onClick:L=>L.stopPropagation(),className:"metakyc-searchable-select-search w-full",style:{display:"block",width:"100%",padding:"6px 8px",fontSize:"13px",borderRadius:"6px",border:`1px solid ${T}`,backgroundColor:z,color:D,outline:"none",boxSizing:"border-box"}})}),e.jsx("ul",{style:{listStyle:"none",margin:0,padding:"4px 0",maxHeight:"208px",overflowY:"auto"},children:w.length===0?e.jsx("li",{style:{padding:"8px 12px",fontSize:"13px",color:Q},children:"No results"}):w.map(L=>{const V=L.value===o;return e.jsx("li",{className:"metakyc-searchable-select-option",onClick:()=>K(L.value,L.disabled),style:{padding:"8px 12px",fontSize:"13px",cursor:L.disabled?"not-allowed":"pointer",opacity:L.disabled?.4:1,backgroundColor:V?U:"transparent",color:V?C:D,userSelect:"none"},onMouseEnter:te=>{!V&&!L.disabled&&(te.currentTarget.style.backgroundColor=Z)},onMouseLeave:te=>{V||(te.currentTarget.style.backgroundColor="transparent")},children:L.label},L.value)})})]});return e.jsxs("div",{className:re("w-full metakyc-searchable-select",p),ref:I,children:[t&&e.jsxs("label",{className:"block text-sm font-medium mb-1",style:{color:"var(--metakyc-text-primary, #374151)"},children:[t,h&&e.jsx("span",{style:{color:"var(--metakyc-error, #ef4444)",marginLeft:"4px"},children:"*"})]}),e.jsxs("div",{ref:E,role:"button",tabIndex:u?-1:0,onClick:R,onKeyDown:L=>{(L.key==="Enter"||L.key===" ")&&(L.preventDefault(),R()),L.key==="Escape"&&J()},className:re("metakyc-searchable-select-trigger","w-full px-3 py-2 rounded-lg border text-sm transition-colors text-left","flex items-center justify-between gap-2","focus:outline-none",u?"opacity-60 cursor-not-allowed":"cursor-pointer"),style:{backgroundColor:"var(--metakyc-input-bg, #ffffff)",color:$?"var(--metakyc-input-text, var(--metakyc-text-primary, #111827))":"var(--metakyc-input-placeholder, var(--metakyc-text-muted, #9ca3af))",borderColor:r?"var(--metakyc-danger, #ef4444)":v?"var(--metakyc-input-border-focus, var(--metakyc-primary, #2563eb))":"var(--metakyc-input-border, var(--metakyc-border, #d1d5db))",minHeight:"42px",outline:v?"2px solid var(--metakyc-input-border-focus, var(--metakyc-primary, #2563eb))":"none",outlineOffset:"-1px"},children:[e.jsx("span",{className:"truncate flex-1",children:$||i}),e.jsx("span",{className:"flex-shrink-0 text-xs pointer-events-none",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:v?"▲":"▼"})]}),typeof document<"u"&&me?qe.createPortal(me,document.body):null,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})]})};ke.displayName="SearchableSelect";const ir=({label:t,error:r,accept:s,multiple:a=!1,maxSize:i,onChange:o,value:c=[],className:u})=>{const[h,p]=l.useState(!1),v=l.useRef(null),S=E=>{if(!E)return;const M=Array.from(E);if(i&&M.filter(P=>P.size>i).length>0){const P=We(i);alert(`Some files exceed the maximum size of ${P}`);return}o==null||o(a?[...c,...M]:[M[0]])},y=E=>{E.preventDefault(),p(!0)},j=()=>{p(!1)},f=E=>{E.preventDefault(),p(!1),S(E.dataTransfer.files)},F=()=>{var E;(E=v.current)==null||E.click()},I=E=>{const M=c.filter((A,P)=>P!==E);o==null||o(M)};return e.jsxs("div",{className:re("w-full",u),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:re("border-2 border-dashed rounded-lg p-6 text-center cursor-pointer transition-colors",h?"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:y,onDragLeave:j,onDrop:f,onClick:F,children:[e.jsx("input",{ref:v,type:"file",className:"hidden",accept:s,multiple:a,onChange:E=>S(E.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"]}),i&&e.jsxs("p",{className:"text-xs text-gray-500",children:["Maximum file size: ",We(i)]})]})]}),c.length>0&&e.jsx("div",{className:"mt-3 space-y-2",children:c.map((E,M)=>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:E.name}),e.jsxs("span",{className:"text-xs text-gray-500",children:["(",We(E.size),")"]})]}),e.jsx("button",{type:"button",onClick:A=>{A.stopPropagation(),I(M)},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"})})})]},M))}),r&&e.jsx("p",{className:"mt-1 text-sm text-danger-500",children:r})]})},or=l.forwardRef(({countryCode:t="+1",onCountryCodeChange:r,className:s,...a},i)=>e.jsxs("div",{className:"w-full",children:[a.label&&e.jsxs("label",{className:"block text-sm font-medium mb-1",style:{color:"var(--metakyc-text-primary, #374151)"},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:o=>r==null?void 0:r(o.target.value),className:re("w-20 rounded-lg border px-3 py-2 text-sm","focus:outline-none focus:ring-2 focus:ring-offset-0"),style:{backgroundColor:"var(--metakyc-input-bg, #ffffff)",color:"var(--metakyc-text-primary, #111827)",borderColor:"var(--metakyc-border, #d1d5db)"},placeholder:"+1"}),e.jsx(ne,{ref:i,type:"tel",className:re("flex-1",s),...a,label:""})]}),a.error&&e.jsx("p",{className:"mt-1 text-sm text-danger-500",children:a.error})]}));or.displayName="PhoneInput";/**
|
|
2
2
|
* @license lucide-react v0.574.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|