@vpdev2/metakyc-sdk 1.0.62 → 1.0.63
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/core/Input.d.ts +1 -1
- package/dist/components/core/Input.d.ts.map +1 -1
- package/dist/components/core/PhoneInput.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +43 -19
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/theme/theme-manager.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -8,7 +8,7 @@ export interface InputProps extends React.InputHTMLAttributes<HTMLInputElement>
|
|
|
8
8
|
rightIcon?: React.ReactNode;
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
|
-
* Input component
|
|
11
|
+
* Input component — uses CSS variables so it follows the SDK theme.
|
|
12
12
|
*/
|
|
13
13
|
export declare const Input: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<HTMLInputElement>>;
|
|
14
14
|
//# sourceMappingURL=Input.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.d.ts","sourceRoot":"","sources":["../../../src/components/core/Input.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAG1C,MAAM,WAAW,UAAW,SAAQ,KAAK,CAAC,mBAAmB,CAAC,gBAAgB,CAAC;IAC7E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,SAAS,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC7B;AAED;;GAEG;AACH,eAAO,MAAM,KAAK,
|
|
1
|
+
{"version":3,"file":"Input.d.ts","sourceRoot":"","sources":["../../../src/components/core/Input.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAG1C,MAAM,WAAW,UAAW,SAAQ,KAAK,CAAC,mBAAmB,CAAC,gBAAgB,CAAC;IAC7E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,SAAS,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC7B;AAED;;GAEG;AACH,eAAO,MAAM,KAAK,qFA8DjB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PhoneInput.d.ts","sourceRoot":"","sources":["../../../src/components/core/PhoneInput.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAS,UAAU,EAAE,MAAM,SAAS,CAAC;AAE5C,MAAM,WAAW,eAAgB,SAAQ,IAAI,CAAC,UAAU,EAAE,MAAM,GAAG,UAAU,CAAC;IAC5E,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mBAAmB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAC9C;AAED;;GAEG;AACH,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"PhoneInput.d.ts","sourceRoot":"","sources":["../../../src/components/core/PhoneInput.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAS,UAAU,EAAE,MAAM,SAAS,CAAC;AAE5C,MAAM,WAAW,eAAgB,SAAQ,IAAI,CAAC,UAAU,EAAE,MAAM,GAAG,UAAU,CAAC;IAC5E,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mBAAmB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAC9C;AAED;;GAEG;AACH,eAAO,MAAM,UAAU,8GA2CtB,CAAC"}
|
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"),o=require("react"),e=require("react/jsx-runtime"),Ke=require("react-dom"),je=require("react-hook-form"),ke=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 Xe=jr(o);var Y=(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))(Y||{}),Me=(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))(Me||{}),pe=(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))(pe||{}),at=(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))(at||{}),nt=(t=>(t[t.LowRisk=0]="LowRisk",t[t.MediumRisk=1]="MediumRisk",t[t.HighRisk=2]="HighRisk",t[t.Alert=3]="Alert",t))(nt||{}),Se=(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))(Se||{}),Ne=(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))(Ne||{}),it=(t=>(t[t.ProviderResultPending=0]="ProviderResultPending",t[t.ProviderResultReceived=1]="ProviderResultReceived",t[t.Canceled=2]="Canceled",t[t.ExtendedToNewApplicant=3]="ExtendedToNewApplicant",t))(it||{}),ot=(t=>(t[t.None=0]="None",t[t.ProviderResultPending=1]="ProviderResultPending",t[t.ProviderResultReceived=2]="ProviderResultReceived",t[t.Canceled=3]="Canceled",t))(ot||{}),me=(t=>(t[t.Onfido=0]="Onfido",t[t.Sumsub=2]="Sumsub",t[t.SardinAI=3]="SardinAI",t))(me||{}),lt=(t=>(t[t.Individual=0]="Individual",t[t.Company=1]="Company",t))(lt||{}),Oe=(t=>(t[t.Male=0]="Male",t[t.Female=1]="Female",t[t.Other=2]="Other",t))(Oe||{}),ct=(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))(ct||{}),dt=(t=>(t[t.Pending=0]="Pending",t[t.Approved=1]="Approved",t[t.Rejected=2]="Rejected",t[t.RequiresRevision=3]="RequiresRevision",t))(dt||{}),ut=(t=>(t[t.SingleChoice=0]="SingleChoice",t[t.MultipleChoice=1]="MultipleChoice",t[t.Text=2]="Text",t))(ut||{}),ve=(t=>(t[t.String=0]="String",t[t.Integer=1]="Integer",t[t.Decimal=2]="Decimal",t[t.Boolean=3]="Boolean",t[t.Date=4]="Date",t[t.Country=5]="Country",t[t.DigitOnly=6]="DigitOnly",t))(ve||{}),mt=(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))(mt||{}),pt=(t=>(t[t.None=0]="None",t[t.Country=1]="Country",t))(pt||{}),de=(t=>(t[t.Individual=0]="Individual",t[t.Sophisticated=1]="Sophisticated",t[t.HighNetWorth=2]="HighNetWorth",t[t.Business=3]="Business",t))(de||{}),ht=(t=>(t[t.Retail=0]="Retail",t[t.Professional=1]="Professional",t[t.EligibleCounterparty=2]="EligibleCounterparty",t))(ht||{});const Ae={Nationality:10,Address:20,CountryOfBirth:30,PhoneNumber:40,UboAddress:50},Ee={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:Ae.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:Ae.Address},nationality:{label:"Nationality",type:"select",countriesType:Ae.Nationality},otherNationality:{label:"Other Nationalities",type:"multiselect",countriesType:Ae.Nationality},countryOfBirth:{label:"Country of Birth",type:"select",countriesType:Ae.CountryOfBirth},placeOfBirth:{label:"Place of Birth",type:"text"},taxCountry:{label:"Tax Country",type:"select",countriesType:Ae.Address},taxNumber:{label:"Tax Number",type:"text"},defaultLanguage:{label:"Default Language",type:"select"},educationLevel:{label:"Education Level",type:"text"},occupation:{label:"Occupation",type:"text"}},gt=["firstName","lastName","email","phonenumber","dateOfBirth"],He=[{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 xt={timeout:3e4,retries:3,locale:"en",endpoints:{pattern:"host-controller"}};class yt{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 ye extends Error{constructor(s,a,n,i,c){super(s);X(this,"response");this.code=a,this.details=n,this.validationErrors=i,this.name="MetaKYCError",this.response=c,Object.setPrototypeOf(this,ye.prototype)}}class Ie{static handleApiError(r){return new ye(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 ye(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 ye(s.result.message,r.response.status,`HTTP ${r.response.status}: ${r.response.statusText}`,void 0,r.response):new ye((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 ye("No response from server",0,"The request was made but no response was received. Please check your network connection."):new ye(r.message||"An unexpected error occurred",0,r.toString())}static isMetaKYCError(r){return r instanceof ye}}class ft{constructor(r){X(this,"axiosInstance");X(this,"endpointBuilder");X(this,"config");this.config={...xt,...r},this.endpointBuilder=new yt(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 n;const a=s.config;return((n=s.response)==null?void 0:n.status)>=500&&!a._retry&&(a._retry=!0,a._retryCount=(a._retryCount||0)+1,a._retryCount<(this.config.retries||3))?(await new Promise(i=>setTimeout(i,1e3*a._retryCount)),this.axiosInstance(a)):Promise.reject(s)})}buildEndpoint(r,s){return this.endpointBuilder.build(r,s)}async get(r,s,a){try{const n=this.buildEndpoint(r,s),i=await this.axiosInstance.get(n,{params:a});return this.handleResponse(i)}catch(n){throw Ie.handleAxiosError(n)}}async post(r,s,a){try{const n=this.buildEndpoint(r,s),i=await this.axiosInstance.post(n,a);return this.handleResponse(i)}catch(n){throw Ie.handleAxiosError(n)}}async put(r,s,a){try{const n=this.buildEndpoint(r,s),i=await this.axiosInstance.put(n,a);return this.handleResponse(i)}catch(n){throw Ie.handleAxiosError(n)}}async delete(r,s,a){try{const n=this.buildEndpoint(r,s),i=await this.axiosInstance.delete(n,{params:a});return this.handleResponse(i)}catch(n){throw Ie.handleAxiosError(n)}}handleResponse(r){const s=r.data;if(!s.success&&s.error)throw Ie.handleApiError(s.error);return s}getAxiosInstance(){return this.axiosInstance}}class bt{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 vt{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 kt{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 wt{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 jt{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 St{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 Nt{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 Ct{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 At{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 oe={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"}}},Et={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"}},Rt={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"}},It={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"}}},Pt={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"}},Ft={[ae.Default]:oe,[ae.Corporate]:Et,[ae.Fintech]:Rt,[ae.Healthcare]:It,[ae.Modern]:Pt,[ae.Minimal]:Dt};function Pe(t){return Ft[t]||oe}class Lt{constructor(r){this.httpClient=r}async getThemeConfiguration(){var r;try{const s=await this.httpClient.get("Tenant","GetThemeConfiguration");if(!s.result.isEnabled)return Pe(ae.Default);let a=s.result.preset?Pe(s.result.preset):Pe(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 n=typeof s.result.applicantFormPages=="string"?JSON.parse(s.result.applicantFormPages):s.result.applicantFormPages;Array.isArray(n)&&n.length>0&&(a.applicantFormPages=n.map(i=>{const c=!i._v||i._v<4;return{...i,fields:(i.fields||[]).map(d=>({...d,colSpan:c?d.colSpan===1?2:4:Math.min(4,Math.max(1,d.colSpan??4))}))}}))}catch{}return a}catch(s){return console.warn("[ThemeService] Failed to fetch theme configuration:",s),Pe(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=Pe(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 Tt{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(n=>{try{n(s)}catch(i){console.error(`Error in event listener for "${r}":`,i)}})}clear(){this.listeners.clear()}clearEvent(r){this.listeners.delete(r)}}class Mt{constructor(){X(this,"events",new Tt);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)||pe.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===pe.Finished}get isOnHold(){return this.status===pe.OnHold}get isInProgress(){return this.status===pe.InProgress}setApplicantId(r){this._applicantId=r}updateProgress(r){var a,n;const s=(a=this._progress)==null?void 0:a.currentStep;this._progress=r,this._applicantId=r.applicantId,this._error=null,this.events.emit("progressUpdated",r),(s==null?void 0:s.order)!==((n=r.currentStep)==null?void 0:n.order)&&this.events.emit("stepChanged",r.currentStep),this.events.emit("statusChanged",r.status),r.status===pe.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 Ot{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: ${Y[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: ${Y[r]}`);return a.submitData(s)}}class zt{constructor(r,s,a,n,i,c,d,u){X(this,"state");X(this,"stepRouter");this.applicantService=r,this.questionnaireService=s,this.uploadDocumentService=a,this.appropriatenessTestService=n,this.overviewService=i,this.riskScoringService=c,this.investorCategorizationService=u,this.state=new Mt,this.stepRouter=new Ot,this.registerStepHandlers()}registerStepHandlers(){this.stepRouter.registerHandler(Y.Questionaries,{loadData:r=>this.questionnaireService.getQuestionnaire(r),submitData:async r=>{await this.questionnaireService.fillQuestionnaire(r)}}),this.stepRouter.registerHandler(Y.UploadDocument,{loadData:r=>this.uploadDocumentService.getUploadDocument(r),submitData:r=>this.uploadDocumentService.fillUploadDocument(r)}),this.stepRouter.registerHandler(Y.AppropriatenessTest,{loadData:r=>this.appropriatenessTestService.getAppropriatenessTest(r),submitData:async r=>{await this.appropriatenessTestService.fillAppropriatenessTest(r)}}),this.stepRouter.registerHandler(Y.Overview,{loadData:r=>this.overviewService.getOverviewData(r),submitData:r=>this.overviewService.passOverview(r.applicantId)}),this.stepRouter.registerHandler(Y.RiskScoring,{loadData:r=>this.riskScoringService.getRiskCriterias(r),submitData:async r=>{await this.riskScoringService.submitRiskScoring(r)}}),this.stepRouter.registerHandler(Y.IdentitySdk,{loadData:async r=>({applicantId:r,message:"Identity verification required"}),submitData:async()=>{}}),this.stepRouter.registerHandler(Y.InvestorCategorization,{loadData:r=>this.investorCategorizationService.getInvestorCategorization(r),submitData:async r=>{await this.investorCategorizationService.setInvestorCategorization(r)}}),this.stepRouter.registerHandler(Y.ManualReview,{loadData:async r=>({applicantId:r,message:"Your application is under manual review"}),submitData:async()=>{}}),this.stepRouter.registerHandler(Y.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 qe(t,r){return new Promise((s,a)=>{if(r&&document.getElementById(r)){s();return}const n=document.createElement("script");n.src=t,r&&(n.id=r),n.async=!0,n.onload=()=>s(),n.onerror=()=>a(new Error(`Failed to load script: ${t}`)),document.head.appendChild(n)})}function Sr(t){return!!document.getElementById(t)}function Nr(t){const r=document.getElementById(t);r&&r.remove()}class Bt{constructor(r){X(this,"sdk",null);X(this,"config");this.config=r}async loadSDK(){await qe("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 $t{constructor(r){X(this,"sdk",null);X(this,"config");this.config=r}async loadSDK(){await qe("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 _t{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(),n=document.createElement("script");n.type="text/javascript",n.async=!0,n.src=`https://${a}/assets/loader.min.js`,n.onload=()=>{console.log("[SardinAI] SDK loaded successfully"),r()},n.onerror=()=>{s(new Error("Failed to load SardinAI SDK"))};const i=document.getElementsByTagName("script")[0];i&&i.parentNode?i.parentNode.insertBefore(n,i):document.head.appendChild(n)})}async initialize(){try{if(await this.loadSDK(),!window._Sardine)throw new Error("SardinAI SDK not available after loading");const r=this.getSardineHost(),{clientId:s,environment:a,flow:n,enableBiometrics:i,enablePortScanning:c}=this.config;this.sardineContext=window._Sardine.createContext({clientId:s,sessionKey:this.sessionKey,userIdHash:void 0,flow:n||window.location.pathname,environment:a||"production",parentElement:document.body,enableBiometrics:i!==!1,enablePortScanning:c===!0,region:this.config.region,onDeviceResponse:d=>{console.log(`[SardinAI] Device ID: ${d.deviceId}`)},onConfigUpdate:(d,u,p)=>{switch(d){case"SESSION_UPDATE_FAILED":console.error("[SardinAI] Session update failed:",p);break;case"SESSION_UPDATED":console.log("[SardinAI] Session updated:",u);break;case"SESSION_NO_UPDATE":console.log("[SardinAI] No session update");break;default:console.warn("[SardinAI] Unknown event:",d)}}}),this.addNoScriptFallback(r),console.log("[SardinAI] SDK initialized with sessionKey:",this.sessionKey)}catch(r){throw console.error("[SardinAI] Initialization failed:",r),r}}addNoScriptFallback(r){const s=document.createElement("noscript"),a=document.createElement("img"),{clientId:n,flow:i}=this.config;a.src=`https://${r}/v1/a.png?clientId=${n}&sessionKey=${this.sessionKey}&flow=${i||"kyc"}&ns=1`,a.style.display="none",s.appendChild(a),document.body.appendChild(s)}updateConfig(r){if(!this.sardineContext){console.warn("[SardinAI] Cannot update config - SDK not initialized");return}r.sessionKey&&(this.sessionKey=r.sessionKey),this.sardineContext.updateConfig({...r,onConfigUpdate:(s,a,n)=>{switch(s){case"SESSION_UPDATE_FAILED":console.error("[SardinAI] Config update failed:",n);break;case"SESSION_UPDATED":console.log("[SardinAI] Config updated:",a);break;case"SESSION_NO_UPDATE":console.log("[SardinAI] No config update needed");break}}})}getSessionKey(){return this.sessionKey}destroy(){this.sardineContext&&(this.sardineContext=null)}}class Re{static createProvider(r,s){switch(r){case me.Sumsub:return new Bt(s);case me.Onfido:return new $t(s);case me.SardinAI:return new _t(s);default:throw new Error(`Unsupported identity provider: ${r}`)}}static parseProviderConfig(r,s,a){var n;switch(r){case me.Sumsub:return{accessToken:s.accessToken||s.token,applicantEmail:s.email,applicantPhone:s.phone,externalUserId:s.externalUserId,lang:s.lang||"en"};case me.Onfido:return{token:s.token||s.sdkToken};case me.SardinAI:const i=((n=a==null?void 0:a.identityProviders)==null?void 0:n.sardinai)||{};return{clientId:i.clientId||s.clientId,sessionKey:i.sessionKey||s.sessionKey,environment:i.environment||s.environment||"production",flow:i.flow||s.flow,region:i.region,enableBiometrics:i.enableBiometrics,enablePortScanning:i.enablePortScanning};default:throw new Error(`Unsupported identity provider: ${r}`)}}}class Ht{constructor(r){X(this,"currentTheme",oe);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};Object.entries(s).forEach(([n,i])=>{this.container.style.setProperty(`--metakyc-${n}`,i)}),(a=this.currentTheme.darkMode)!=null&&a.colors&&this.applyDarkModeColors(this.currentTheme.darkMode.colors)}applyDarkModeColors(r){Object.entries(r).forEach(([s,a])=>{if(a){const n=`--metakyc-dark-${this.kebabCase(s)}`;this.container.style.setProperty(n,a)}})}applyTypography(r){r&&(r.fontFamily&&this.container.style.setProperty("--metakyc-font-family",r.fontFamily),r.headingFont&&this.container.style.setProperty("--metakyc-heading-font",r.headingFont),r.fontSize&&Object.entries(r.fontSize).forEach(([s,a])=>{this.container.style.setProperty(`--metakyc-font-size-${s}`,a)}),r.fontWeight&&Object.entries(r.fontWeight).forEach(([s,a])=>{this.container.style.setProperty(`--metakyc-font-weight-${s}`,a.toString())}))}applySpacing(r){r&&Object.entries(r).forEach(([s,a])=>{const n=`--metakyc-${this.kebabCase(s)}`;this.container.style.setProperty(n,a)})}injectCustomCSS(r){this.customStyleElement&&this.customStyleElement.remove(),this.customStyleElement=document.createElement("style"),this.customStyleElement.id="metakyc-custom-css",this.customStyleElement.textContent=r,document.head.appendChild(this.customStyleElement)}mergeWithDefault(r){var s;return{name:r.name||oe.name,title:r.title||oe.title,logo:{...oe.logo,...r.logo},colors:{...oe.colors,...r.colors},typography:r.typography?{...oe.typography,...r.typography}:oe.typography,spacing:r.spacing?{...oe.spacing,...r.spacing}:oe.spacing,customCSS:r.customCSS,darkMode:r.darkMode?{colors:{...(s=oe.darkMode)==null?void 0:s.colors,...r.darkMode.colors}}:oe.darkMode,applicantFormVisibleFields:r.applicantFormVisibleFields,applicantFormRequiredFields:r.applicantFormRequiredFields,allowedLanguages:r.allowedLanguages,applicantFormPages:r.applicantFormPages}}getCurrentTheme(){return this.currentTheme}resetTheme(){this.applyTheme(oe)}cleanup(){this.customStyleElement&&(this.customStyleElement.remove(),this.customStyleElement=null)}kebabCase(r){return r.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}}const We=o.createContext(null),Cr=({config:t,children:r})=>{const[s,a]=o.useState(null),n=o.useRef(!1),i=o.useRef(!1),c=o.useMemo(()=>{const u=new ft(t),p=new bt(u),f=new vt(u),w=new kt(u),m=new wt(u),x=new jt(u),h=new St(u),S=new Nt(u),P=new Ct(u),v=new At(u),O=new Lt(u),N=new Ht;return{httpClient:u,applicantService:p,questionnaireService:f,uploadDocumentService:w,appropriatenessTestService:m,overviewService:x,riskScoringService:h,identityService:S,baseInformationService:P,investorCategorizationService:v,themeService:O,themeManager:N}},[t]),d=o.useMemo(()=>({config:t,...c,currentTheme:s,createOrchestrator:()=>new zt(c.applicantService,c.questionnaireService,c.uploadDocumentService,c.appropriatenessTestService,c.overviewService,c.riskScoringService,c.identityService,c.investorCategorizationService)}),[t,c,s]);return o.useEffect(()=>((async()=>{if(n.current||i.current){console.log("[MetaKYC] Theme already loading or loaded, skipping...");return}n.current=!0;try{if(t.theme){console.log("[MetaKYC] Applying static theme from config"),c.themeManager.applyTheme(t.theme),a(c.themeManager.getCurrentTheme()),i.current=!0;return}console.log("[MetaKYC] Fetching theme from backend...");const p=await c.themeService.getThemeConfiguration();c.themeManager.applyTheme(p),a(c.themeManager.getCurrentTheme()),i.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()),i.current=!0}finally{n.current=!1}})(),()=>{c.themeManager.cleanup()}),[]),e.jsx(We.Provider,{value:d,children:r})};function ue(){const t=o.useContext(We);if(!t)throw new Error("useMetaKYC must be used within a MetaKYCProvider");return t}async function Ut(t){return new Promise((r,s)=>{const a=new FileReader;a.readAsDataURL(t),a.onload=()=>{const i=a.result.split(",")[1];r(i)},a.onerror=n=>s(n)})}function Ar(t,r){return t.size<=r}function Er(t,r){return r.split(",").map(a=>a.trim()).some(a=>{if(a.endsWith("/*")){const n=a.slice(0,-2);return t.type.startsWith(n)}return t.type===a})}function $e(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 Rr(t){return t}function se(...t){return t.filter(Boolean).join(" ")}const Fe={APPLICANT_ID:"metakyc_applicant_id",WORKFLOW_STATE:"metakyc_workflow_state"};function Kt(t){try{localStorage.setItem(Fe.APPLICANT_ID,t.toString())}catch(r){console.warn("Failed to save applicant ID to storage:",r)}}function qt(){try{const t=localStorage.getItem(Fe.APPLICANT_ID);return t?parseInt(t,10):null}catch(t){return console.warn("Failed to retrieve applicant ID from storage:",t),null}}function Wt(){try{localStorage.removeItem(Fe.APPLICANT_ID)}catch(t){console.warn("Failed to clear applicant ID from storage:",t)}}function Yt(t){try{localStorage.setItem(Fe.WORKFLOW_STATE,JSON.stringify(t))}catch(r){console.warn("Failed to save workflow state to storage:",r)}}function Ir(){try{const t=localStorage.getItem(Fe.WORKFLOW_STATE);return t?JSON.parse(t):null}catch(t){return console.warn("Failed to retrieve workflow state from storage:",t),null}}function Qt(){try{localStorage.removeItem(Fe.WORKFLOW_STATE)}catch(t){console.warn("Failed to clear workflow state from storage:",t)}}function Pr(){Wt(),Qt()}function Gt(t){const{createOrchestrator:r}=ue(),[s,a]=o.useState(null),[n,i]=o.useState(!1),[c,d]=o.useState(null),u=o.useRef(null),p=t||qt();o.useEffect(()=>{u.current||(u.current=r())},[r]),o.useEffect(()=>{var N;s&&p&&(Kt(p),Yt({applicantId:p,currentStepOrder:(N=s.currentStep)==null?void 0:N.order,status:s.status,lastUpdated:new Date().toISOString(),workflowKey:s.workFlowKey,nextWorkflowKey:s.nextWorkflowKey}))},[s,p]);const f=o.useRef(!1),w=o.useRef(!1),m=o.useCallback(async()=>{if(!(!p||!u.current)){if(f.current){console.log("[Workflow] Load already in progress, skipping...");return}f.current=!0,i(!0),d(null);try{const N=await u.current.initialize(p);a(N),w.current=!0}catch(N){d(N)}finally{i(!1),f.current=!1}}},[p]);o.useEffect(()=>{p&&!w.current&&m()},[p,m]);const x=o.useCallback(async()=>{if(u.current){if(f.current){console.log("[Workflow] Refresh already in progress, skipping...");return}f.current=!0,i(!0),d(null);try{const N=await u.current.refreshProgress();a(N)}catch(N){d(N)}finally{i(!1),f.current=!1}}},[]),h=o.useCallback(async()=>{if(u.current){i(!0),d(null);try{const N=await u.current.moveToNextStep();a(N)}catch(N){d(N)}finally{i(!1)}}},[]),S=o.useCallback(async()=>{if(u.current){i(!0),d(null);try{const N=await u.current.moveToPreviousStep();a(N)}catch(N){d(N)}finally{i(!1)}}},[]),P=o.useCallback(async N=>{if(u.current){i(!0),d(null);try{await u.current.submitCurrentStep(N);const A=await u.current.refreshProgress();a(A)}catch(A){throw d(A),A}finally{i(!1)}}},[]),v=Xe.useMemo(()=>s!=null&&s.stepInfoList?[...s.stepInfoList].sort((N,A)=>N.order-A.order):[],[s==null?void 0:s.stepInfoList]),O=Xe.useMemo(()=>s?s.nextWorkflowKey&&s.nextWorkflowKey!==s.workFlowKey:!1,[s]);return{progress:s,applicantId:p,currentStep:(s==null?void 0:s.currentStep)||null,steps:v,status:(s==null?void 0:s.status)||pe.None,workflowResult:(s==null?void 0:s.workflowResult)||null,workflowKey:s==null?void 0:s.workFlowKey,nextWorkflowKey:s==null?void 0:s.nextWorkflowKey,hasWorkflowChanged:O,isLoading:n,error:c,isComplete:(s==null?void 0:s.status)===pe.Finished,isOnHold:(s==null?void 0:s.status)===pe.OnHold,refreshProgress:x,moveToNext:h,moveBack:S,submitCurrentStep:P,orchestrator:u.current}}function Vt(t){const{questionnaireService:r,applicantService:s}=ue(),[a,n]=o.useState(null),[i,c]=o.useState({}),[d,u]=o.useState(!1),[p,f]=o.useState(!1),[w,m]=o.useState(null),x=o.useRef(!1),h=o.useRef(null),S=o.useCallback(async()=>{var v,O;if(t){if(x.current){console.log("[Questionnaire] Load already in progress, skipping...");return}x.current=!0,u(!0),m(null);try{const[N,A]=await Promise.all([r.getQuestionnaire(t),s.getApplicantData(t).catch(()=>null)]);if(n(N),(v=A==null?void 0:A.questionnaireResults)!=null&&v.length&&N){const H=new Map;for(const g of A.questionnaireResults)g.question&&((O=g.answers)!=null&&O.length)&&H.set(g.question.trim().toLowerCase(),g.answers);const V={},C=N.questionGroups.flatMap(g=>g.questions??[]);for(const g of C){const E=g.text.trim().toLowerCase();H.has(E)&&(V[g.id]=H.get(E))}c(V)}h.current=t}catch(N){m(N)}finally{u(!1),x.current=!1}}},[t,r,s]);o.useEffect(()=>{t&&h.current!==t&&S()},[t]);const P=o.useCallback(async v=>{f(!0),m(null);try{return await r.fillQuestionnaire(v)}catch(O){throw m(O),O}finally{f(!1)}},[r]);return{questionnaire:a,initialAnswers:i,isLoading:d,isSubmitting:p,error:w,load:S,submit:P}}function Zt(t){const{uploadDocumentService:r}=ue(),[s,a]=o.useState(null),[n,i]=o.useState(!1),[c,d]=o.useState(!1),[u,p]=o.useState(0),[f,w]=o.useState(null),m=o.useRef(!1),x=o.useRef(null),h=o.useCallback(async()=>{if(t){if(m.current){console.log("[UploadDocument] Load already in progress, skipping...");return}m.current=!0,i(!0),w(null);try{const P=await r.getUploadDocument(t);a(P),x.current=t}catch(P){w(P)}finally{i(!1),m.current=!1}}},[t,r]);o.useEffect(()=>{t&&x.current!==t&&h()},[t]);const S=o.useCallback(async P=>{d(!0),p(0),w(null);try{await r.fillUploadDocument(P),p(100)}catch(v){throw w(v),v}finally{d(!1)}},[r]);return{uploadDocument:s,isLoading:n,isSubmitting:c,uploadProgress:u,error:f,load:h,submit:S}}function Dr(t){const{appropriatenessTestService:r}=ue(),[s,a]=o.useState(null),[n,i]=o.useState(!1),[c,d]=o.useState(!1),[u,p]=o.useState(null),[f,w]=o.useState(null),m=o.useRef(!1),x=o.useRef(null),h=o.useCallback(async()=>{if(t){if(m.current){console.log("[AppropriatenessTest] Load already in progress, skipping...");return}m.current=!0,i(!0),p(null);try{const P=await r.getAppropriatenessTest(t);a(P),x.current=t}catch(P){p(P)}finally{i(!1),m.current=!1}}},[t,r]);o.useEffect(()=>{t&&x.current!==t&&h()},[t]);const S=o.useCallback(async P=>{d(!0),p(null);try{const v=await r.fillAppropriatenessTest(P);return w(v),v}catch(v){throw p(v),v}finally{d(!1)}},[r]);return{test:s,result:f,isLoading:n,isSubmitting:c,error:u,load:h,submit:S}}function Jt(t){const{overviewService:r}=ue(),[s,a]=o.useState(null),[n,i]=o.useState(!1),[c,d]=o.useState(!1),[u,p]=o.useState(null),f=o.useRef(!1),w=o.useRef(null),m=o.useCallback(async()=>{if(t){if(f.current){console.log("[Overview] Load already in progress, skipping...");return}f.current=!0,i(!0),p(null);try{const h=await r.getOverviewData(t);a(h),w.current=t}catch(h){p(h)}finally{i(!1),f.current=!1}}},[t,r]);o.useEffect(()=>{t&&w.current!==t&&m()},[t]);const x=o.useCallback(async()=>{if(t){d(!0),p(null);try{await r.passOverview(t)}catch(h){throw p(h),h}finally{d(!1)}}},[t,r]);return{overview:s,isLoading:n,isSubmitting:c,error:u,load:m,passOverview:x}}function Xt(t){const{identityService:r}=ue(),[s,a]=o.useState(null),[n,i]=o.useState(!1),[c,d]=o.useState(null),u=o.useRef(!1),p=o.useCallback(async(m,x)=>{if(t){if(u.current){console.log("[Identity] Request already in progress, skipping...");return}u.current=!0,i(!0),d(null);try{const h={applicantId:t,restart:!1,redirectUrl:m||"",ttl:x||604800};console.log("Identity request input:",h);const S=await r.identityRequest(h);return console.log("Identity request result:",S),a(S),S}catch(h){throw d(h),h}finally{i(!1),u.current=!1}}},[t,r]),f=o.useCallback(async(m,x)=>{if(t){i(!0),d(null);try{const h={applicantId:t,restart:!1,redirectUrl:m,ttl:x},S=await r.identityCompanyRequest(h);return a(S),S}catch(h){throw d(h),h}finally{i(!1)}}},[t,r]),w=o.useCallback(async()=>{if(t){if(u.current){console.log("[Identity] Restart already in progress, skipping...");return}u.current=!0,i(!0),d(null);try{const m={applicantId:t,restart:!0,redirectUrl:"",ttl:604800};console.log("Restarting identity with input:",m);const x=await r.identityRequest(m);return console.log("Restart identity result:",x),a(x),x}catch(m){throw d(m),m}finally{i(!1),u.current=!1}}},[t,r]);return{identityData:s,provider:(s==null?void 0:s.provider)||null,token:(s==null?void 0:s.publicProviderTokenObject)||null,isLoading:n,error:c,requestIdentity:p,requestCompanyIdentity:f,restartIdentity:w}}function er(t){const{riskScoringService:r,applicantService:s}=ue(),[a,n]=o.useState(null),[i,c]=o.useState({}),[d,u]=o.useState(!1),[p,f]=o.useState(!1),[w,m]=o.useState(null),[x,h]=o.useState(null),S=o.useRef(!1),P=o.useRef(null),v=o.useCallback(async()=>{var N;if(t){if(S.current){console.log("[RiskScoring] Load already in progress, skipping...");return}S.current=!0,u(!0),m(null);try{const[A,H]=await Promise.all([r.getRiskCriterias(t),s.getApplicantData(t).catch(()=>null)]);if(n(A),(N=H==null?void 0:H.riskScoringResults)!=null&&N.length){const V=H.riskScoringResults[0],C={};for(const g of V.riskCriteriaResults??[])if(g.riskCriteriaId!=null&&g.answer!=null&&g.answer!==""){const E=[...new Set(g.answer.split(",").map(R=>R.trim()).filter(R=>R!==""))];E.length>0&&(C[g.riskCriteriaId]=E)}c(C)}P.current=t}catch(A){m(A)}finally{u(!1),S.current=!1}}},[t,r,s]);o.useEffect(()=>{t&&P.current!==t&&v()},[t]);const O=o.useCallback(async N=>{f(!0),m(null);try{const A=await r.submitRiskScoring(N);return h(A),A}catch(A){throw m(A),A}finally{f(!1)}},[r]);return{criteria:a,initialAnswers:i,result:x,isLoading:d,isSubmitting:p,error:w,load:v,submit:O}}function tr(){const{applicantService:t,config:r}=ue(),[s,a]=o.useState(!1),[n,i]=o.useState(null),c=o.useRef(!1),d=o.useRef(!1),u=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(x){const h=Math.random()*16|0;return(x==="x"?h:h&3|8).toString(16)}),p=o.useCallback(async x=>{var h;if(c.current)throw console.log("[Applicant] Create already in progress, skipping..."),new Error("Creation already in progress");c.current=!0,a(!0),i(null);try{if(x.applicantAdditionalDatas||(x.applicantAdditionalDatas=[]),(h=r.identityProviders)!=null&&h.sardinai){const P=u();console.log("[SardinAI] Generated session key:",P),x.applicantAdditionalDatas.push({paramName:"sessionKey",value:P})}return await t.createApplicant(x)}catch(S){throw i(S),S}finally{a(!1),c.current=!1}},[t,r]),f=o.useCallback(async x=>{a(!0),i(null);try{return await t.createCompanyApplicant(x)}catch(h){throw i(h),h}finally{a(!1)}},[t]),w=o.useCallback(async x=>{if(d.current)throw console.log("[Applicant] Data load already in progress, skipping..."),new Error("Data load already in progress");d.current=!0,a(!0),i(null);try{return await t.getApplicantData(x)}catch(h){throw i(h),h}finally{a(!1),d.current=!1}},[t]),m=o.useCallback(async x=>{a(!0),i(null);try{await t.stopProgress(x)}catch(h){throw i(h),h}finally{a(!1)}},[t]);return{isLoading:s,error:n,createApplicant:p,createCompanyApplicant:f,getApplicantData:w,stopProgress:m}}const Q=({children:t,variant:r="primary",size:s="md",isLoading:a=!1,disabled:n,className:i,...c})=>{const d="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",u={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:se(d,u[r],p[s],i),disabled:n||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]})},le=o.forwardRef(({label:t,error:r,helperText:s,leftIcon:a,rightIcon:n,className:i,...c},d)=>e.jsxs("div",{className:"w-full",children:[t&&e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:[t,c.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:d,className:se("block w-full rounded-lg border px-3 py-2 text-sm transition-colors","focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent","disabled:bg-gray-100 disabled:cursor-not-allowed",r?"border-danger-500 focus:ring-danger-500":"border-gray-300 dark:border-gray-600","dark:bg-gray-800 dark:text-white",a?"pl-10":"",n?"pr-10":"",i),...c}),n&&e.jsx("div",{className:"absolute inset-y-0 right-0 pr-3 flex items-center pointer-events-none",children:n})]}),r&&e.jsx("p",{className:"mt-1 text-sm text-danger-500",children:r}),!r&&s&&e.jsx("p",{className:"mt-1 text-sm text-gray-500",children:s})]}));le.displayName="Input";const U=({children:t,className:r,...s})=>e.jsx("div",{className:se("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:se("px-6 py-4 border-b",r),style:{borderColor:"var(--metakyc-border, #e5e7eb)"},...s,children:t}),K=({children:t,className:r,...s})=>e.jsx("div",{className:se("px-6 py-4",r),...s,children:t}),ce=({children:t,className:r,...s})=>e.jsx("div",{className:se("px-6 py-4 border-t",r),style:{borderColor:"var(--metakyc-border, #e5e7eb)"},...s,children:t}),be=({children:t,variant:r="default",className:s,...a})=>{const n={default:"bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300",success:"bg-success-100 text-success-800 dark:bg-success-900 dark:text-success-300",danger:"bg-danger-100 text-danger-800 dark:bg-danger-900 dark:text-danger-300",warning:"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300",info:"bg-primary-100 text-primary-800 dark:bg-primary-900 dark:text-primary-300"};return e.jsx("span",{className:se("inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium",n[r],s),...a,children:t})},he=({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:se("flex items-center justify-center",r),...s,children:e.jsxs("svg",{className:se("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"})]})})},De=o.forwardRef(({label:t,error:r,helperText:s,options:a,placeholder:n,className:i,style:c,...d},u)=>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,d.required&&e.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),e.jsxs("select",{ref:u,className:se("block w-full rounded-lg border px-3 py-2 text-sm transition-colors","focus:outline-none focus:ring-2 focus:ring-offset-0","disabled:opacity-60 disabled:cursor-not-allowed",r?"border-danger-500":"",i),style:{backgroundColor:"var(--metakyc-input-bg, #ffffff)",color:"var(--metakyc-text-primary, #111827)",borderColor:r?"var(--metakyc-error, #ef4444)":"var(--metakyc-border, #d1d5db)",...c},...d,children:[n&&e.jsx("option",{value:"",disabled:!0,style:{backgroundColor:"var(--metakyc-input-bg, #ffffff)",color:"var(--metakyc-text-secondary, #6b7280)"},children:n},"__placeholder__"),a.map((p,f)=>e.jsx("option",{value:p.value,disabled:p.disabled,style:{backgroundColor:"var(--metakyc-input-bg, #ffffff)",color:p.disabled?"var(--metakyc-text-secondary, #9ca3af)":"var(--metakyc-text-primary, #111827)"},children:p.label},p.value||`option-${f}`))]}),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})]}));De.displayName="Select";const et=280,rr=({label:t,value:r,onChange:s,options:a,placeholder:n="Select...",disabled:i=!1,required:c=!1})=>{const[d,u]=o.useState(!1),[p,f]=o.useState(""),[w,m]=o.useState(null),x=o.useRef(null),h=o.useRef(null),S=o.useRef(null),P=o.useCallback(()=>{if(!h.current)return null;const k=h.current.getBoundingClientRect(),J=window.innerHeight-k.bottom<et&&k.top>et;return{top:J?k.top:k.bottom+4,left:k.left,width:k.width,openUp:J}},[]),v=o.useCallback(()=>{if(i)return;const k=P();k&&m(k),u(!0)},[i,P]),O=o.useCallback(()=>{u(!1),f("")},[]);o.useEffect(()=>{if(!d)return;const k=_=>{var z,I;const J=_.target;!((z=x.current)!=null&&z.contains(J))&&!((I=S.current)!=null&&I.contains(J))&&O()};return document.addEventListener("mousedown",k),()=>document.removeEventListener("mousedown",k)},[d,O]),o.useEffect(()=>{if(!d)return;const k=()=>{const _=P();_&&m(_)};return window.addEventListener("scroll",k,!0),window.addEventListener("resize",k),()=>{window.removeEventListener("scroll",k,!0),window.removeEventListener("resize",k)}},[d,P]);const N=a.filter(k=>k.label.toLowerCase().includes(p.toLowerCase())),A=k=>{i||s(r.includes(k)?r.filter(_=>_!==k):[...r,k])},H=(k,_)=>{_.stopPropagation(),i||s(r.filter(J=>J!==k))},V=k=>{var _;return((_=a.find(J=>J.value===k))==null?void 0:_.label)||k},C=h.current?getComputedStyle(h.current):null,g=(C==null?void 0:C.getPropertyValue("--metakyc-input-bg").trim())||"#ffffff",E=(C==null?void 0:C.getPropertyValue("--metakyc-border").trim())||"#d1d5db",R=(C==null?void 0:C.getPropertyValue("--metakyc-text-primary").trim())||"#111827",M=(C==null?void 0:C.getPropertyValue("--metakyc-text-secondary").trim())||"#6b7280",B=(C==null?void 0:C.getPropertyValue("--metakyc-primary").trim())||"#2563eb",T=(C==null?void 0:C.getPropertyValue("--metakyc-primary-light").trim())||"#eff6ff",L=(C==null?void 0:C.getPropertyValue("--metakyc-hover-bg").trim())||"#f9fafb",G=d&&w&&e.jsxs("div",{ref:S,className:"metakyc-multiselect-dropdown",style:{position:"fixed",top:w.openUp?void 0:w.top,bottom:w.openUp?window.innerHeight-w.top+4:void 0,left:w.left,width:w.width,zIndex:99999,borderRadius:"8px",boxShadow:"0 4px 16px rgba(0,0,0,0.18)",border:`1px solid ${E}`,backgroundColor:g,overflow:"hidden"},children:[e.jsx("div",{style:{padding:"8px",borderBottom:`1px solid ${E}`},children:e.jsx("input",{type:"text",value:p,onChange:k=>f(k.target.value),placeholder:"Search...",autoFocus:!0,onClick:k=>k.stopPropagation(),className:"metakyc-multiselect-search w-full",style:{display:"block",width:"100%",padding:"6px 8px",fontSize:"13px",borderRadius:"6px",border:`1px solid ${E}`,backgroundColor:g,color:R,outline:"none",boxSizing:"border-box"}})}),e.jsx("ul",{style:{listStyle:"none",margin:0,padding:"4px 0",maxHeight:"192px",overflowY:"auto"},children:N.length===0?e.jsx("li",{style:{padding:"8px 12px",fontSize:"13px",color:M},children:"No results"}):N.map(k=>{const _=r.includes(k.value);return e.jsxs("li",{onClick:()=>A(k.value),className:"metakyc-multiselect-option",style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",fontSize:"13px",cursor:"pointer",backgroundColor:_?T:"transparent",color:_?B:R,userSelect:"none"},onMouseEnter:J=>{_||(J.currentTarget.style.backgroundColor=L)},onMouseLeave:J=>{_||(J.currentTarget.style.backgroundColor="transparent")},children:[e.jsx("input",{type:"checkbox",checked:_,readOnly:!0,style:{accentColor:B,pointerEvents:"none",flexShrink:0}}),e.jsx("span",{children:k.label})]},k.value)})}),r.length>0&&e.jsx("div",{style:{padding:"6px 12px",borderTop:`1px solid ${E}`},children:e.jsxs("button",{type:"button",onClick:()=>{s([]),f("")},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:x,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:h,onClick:()=>d?O():v(),className:se("metakyc-multiselect-trigger","min-h-[42px] w-full px-3 py-2 rounded-lg border text-sm transition-colors relative",i?"opacity-50 cursor-not-allowed":"cursor-pointer"),style:{backgroundColor:"var(--metakyc-input-bg, #ffffff)",borderColor:d?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #d1d5db)",outline:d?"2px solid 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:n}):e.jsx("div",{className:"flex flex-wrap gap-1 pr-6",children:r.map(k=>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:[V(k),!i&&e.jsx("button",{type:"button",onClick:_=>H(k,_),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:"×"})]},k))}),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:d?"▲":"▼"})]}),typeof document<"u"&&G?Ke.createPortal(G,document.body):null]})},tt=260,ze=({label:t,error:r,helperText:s,options:a,placeholder:n="Select...",value:i,onChange:c,disabled:d=!1,required:u=!1,className:p})=>{var I;const[f,w]=o.useState(!1),[m,x]=o.useState(""),[h,S]=o.useState(null),P=o.useRef(null),v=o.useRef(null),O=o.useRef(null),N=o.useRef(null),A=o.useCallback(()=>{if(!v.current)return null;const j=v.current.getBoundingClientRect(),Z=window.innerHeight-j.bottom<tt&&j.top>tt;return{top:Z?j.top:j.bottom+4,left:j.left,width:j.width,openUp:Z}},[]),H=o.useCallback(()=>{if(d)return;const j=A();j&&S(j),w(!0)},[d,A]),V=o.useCallback(()=>{w(!1),x("")},[]),C=()=>f?V():H();o.useEffect(()=>{if(!f)return;const j=$=>{var W,fe;const Z=$.target;!((W=P.current)!=null&&W.contains(Z))&&!((fe=O.current)!=null&&fe.contains(Z))&&V()};return document.addEventListener("mousedown",j),()=>document.removeEventListener("mousedown",j)},[f,V]),o.useEffect(()=>{if(!f)return;const j=()=>{const $=A();$&&S($)};return window.addEventListener("scroll",j,!0),window.addEventListener("resize",j),()=>{window.removeEventListener("scroll",j,!0),window.removeEventListener("resize",j)}},[f,A]),o.useEffect(()=>{f&&N.current&&setTimeout(()=>{var j;return(j=N.current)==null?void 0:j.focus()},0)},[f]);const g=a.filter(j=>j.label.toLowerCase().includes(m.toLowerCase())||j.value.toLowerCase().includes(m.toLowerCase())),E=(I=a.find(j=>j.value===i))==null?void 0:I.label,R=(j,$)=>{d||$||(c(j),V())},M=v.current?getComputedStyle(v.current):null,B=(M==null?void 0:M.getPropertyValue("--metakyc-input-bg").trim())||"#ffffff",T=(M==null?void 0:M.getPropertyValue("--metakyc-border").trim())||"#d1d5db",L=(M==null?void 0:M.getPropertyValue("--metakyc-text-primary").trim())||"#111827",G=(M==null?void 0:M.getPropertyValue("--metakyc-text-secondary").trim())||"#6b7280",k=(M==null?void 0:M.getPropertyValue("--metakyc-primary").trim())||"#2563eb",_=(M==null?void 0:M.getPropertyValue("--metakyc-primary-light").trim())||"#eff6ff",J=(M==null?void 0:M.getPropertyValue("--metakyc-hover-bg").trim())||"#f9fafb",z=f&&h&&e.jsxs("div",{ref:O,className:"metakyc-searchable-select-dropdown",style:{position:"fixed",top:h.openUp?void 0:h.top,bottom:h.openUp?window.innerHeight-h.top+4:void 0,left:h.left,width:h.width,zIndex:99999,borderRadius:"8px",boxShadow:"0 4px 16px rgba(0,0,0,0.18)",border:`1px solid ${T}`,backgroundColor:B,overflow:"hidden"},children:[e.jsx("div",{style:{padding:"8px",borderBottom:`1px solid ${T}`},children:e.jsx("input",{ref:N,type:"text",value:m,onChange:j=>x(j.target.value),placeholder:"Search...",onClick:j=>j.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:B,color:L,outline:"none",boxSizing:"border-box"}})}),e.jsx("ul",{style:{listStyle:"none",margin:0,padding:"4px 0",maxHeight:"208px",overflowY:"auto"},children:g.length===0?e.jsx("li",{style:{padding:"8px 12px",fontSize:"13px",color:G},children:"No results"}):g.map(j=>{const $=j.value===i;return e.jsx("li",{className:"metakyc-searchable-select-option",onClick:()=>R(j.value,j.disabled),style:{padding:"8px 12px",fontSize:"13px",cursor:j.disabled?"not-allowed":"pointer",opacity:j.disabled?.4:1,backgroundColor:$?_:"transparent",color:$?k:L,userSelect:"none"},onMouseEnter:Z=>{!$&&!j.disabled&&(Z.currentTarget.style.backgroundColor=J)},onMouseLeave:Z=>{$||(Z.currentTarget.style.backgroundColor="transparent")},children:j.label},j.value)})})]});return e.jsxs("div",{className:se("w-full metakyc-searchable-select",p),ref:P,children:[t&&e.jsxs("label",{className:"block text-sm font-medium mb-1",style:{color:"var(--metakyc-text-primary, #374151)"},children:[t,u&&e.jsx("span",{style:{color:"var(--metakyc-error, #ef4444)",marginLeft:"4px"},children:"*"})]}),e.jsxs("div",{ref:v,role:"button",tabIndex:d?-1:0,onClick:C,onKeyDown:j=>{(j.key==="Enter"||j.key===" ")&&(j.preventDefault(),C()),j.key==="Escape"&&V()},className:se("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",d?"opacity-60 cursor-not-allowed":"cursor-pointer"),style:{backgroundColor:"var(--metakyc-input-bg, #ffffff)",color:E?"var(--metakyc-text-primary, #111827)":"var(--metakyc-text-secondary, #9ca3af)",borderColor:r?"var(--metakyc-error, #ef4444)":f?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #d1d5db)",minHeight:"42px",outline:f?"2px solid var(--metakyc-primary, #2563eb)":"none",outlineOffset:"-1px"},children:[e.jsx("span",{className:"truncate flex-1",children:E||n}),e.jsx("span",{className:"flex-shrink-0 text-xs pointer-events-none",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:f?"▲":"▼"})]}),typeof document<"u"&&z?Ke.createPortal(z,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})]})};ze.displayName="SearchableSelect";const sr=({label:t,error:r,accept:s,multiple:a=!1,maxSize:n,onChange:i,value:c=[],className:d})=>{const[u,p]=o.useState(!1),f=o.useRef(null),w=v=>{if(!v)return;const O=Array.from(v);if(n&&O.filter(A=>A.size>n).length>0){const A=$e(n);alert(`Some files exceed the maximum size of ${A}`);return}i==null||i(a?[...c,...O]:[O[0]])},m=v=>{v.preventDefault(),p(!0)},x=()=>{p(!1)},h=v=>{v.preventDefault(),p(!1),w(v.dataTransfer.files)},S=()=>{var v;(v=f.current)==null||v.click()},P=v=>{const O=c.filter((N,A)=>A!==v);i==null||i(O)};return e.jsxs("div",{className:se("w-full",d),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:se("border-2 border-dashed rounded-lg p-6 text-center cursor-pointer transition-colors",u?"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:m,onDragLeave:x,onDrop:h,onClick:S,children:[e.jsx("input",{ref:f,type:"file",className:"hidden",accept:s,multiple:a,onChange:v=>w(v.target.files)}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("svg",{className:"mx-auto h-12 w-12 text-gray-400",stroke:"currentColor",fill:"none",viewBox:"0 0 48 48",children:e.jsx("path",{d:"M28 8H12a4 4 0 00-4 4v20m32-12v8m0 0v8a4 4 0 01-4 4H12a4 4 0 01-4-4v-4m32-4l-3.172-3.172a4 4 0 00-5.656 0L28 28M8 32l9.172-9.172a4 4 0 015.656 0L28 28m0 0l4 4m4-24h8m-4-4v8m-12 4h.02",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}),e.jsxs("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:[e.jsx("span",{className:"font-medium text-primary-500",children:"Click to upload"})," or drag and drop"]}),n&&e.jsxs("p",{className:"text-xs text-gray-500",children:["Maximum file size: ",$e(n)]})]})]}),c.length>0&&e.jsx("div",{className:"mt-3 space-y-2",children:c.map((v,O)=>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:v.name}),e.jsxs("span",{className:"text-xs text-gray-500",children:["(",$e(v.size),")"]})]}),e.jsx("button",{type:"button",onClick:N=>{N.stopPropagation(),P(O)},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"})})})]},O))}),r&&e.jsx("p",{className:"mt-1 text-sm text-danger-500",children:r})]})},ar=o.forwardRef(({countryCode:t="+1",onCountryCodeChange:r,className:s,...a},n)=>e.jsxs("div",{className:"w-full",children:[a.label&&e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:[a.label,a.required&&e.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:t,onChange:i=>r==null?void 0:r(i.target.value),className:se("w-20 rounded-lg border px-3 py-2 text-sm","focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent","border-gray-300 dark:border-gray-600 dark:bg-gray-800 dark:text-white"),placeholder:"+1"}),e.jsx(le,{ref:n,type:"tel",className:se("flex-1",s),...a,label:""})]}),a.error&&e.jsx("p",{className:"mt-1 text-sm text-danger-500",children:a.error})]}));ar.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"),o=require("react"),e=require("react/jsx-runtime"),Ke=require("react-dom"),je=require("react-hook-form"),ke=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 Xe=jr(o);var Y=(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))(Y||{}),Me=(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))(Me||{}),pe=(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))(pe||{}),at=(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))(at||{}),nt=(t=>(t[t.LowRisk=0]="LowRisk",t[t.MediumRisk=1]="MediumRisk",t[t.HighRisk=2]="HighRisk",t[t.Alert=3]="Alert",t))(nt||{}),Se=(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))(Se||{}),Ne=(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))(Ne||{}),it=(t=>(t[t.ProviderResultPending=0]="ProviderResultPending",t[t.ProviderResultReceived=1]="ProviderResultReceived",t[t.Canceled=2]="Canceled",t[t.ExtendedToNewApplicant=3]="ExtendedToNewApplicant",t))(it||{}),ot=(t=>(t[t.None=0]="None",t[t.ProviderResultPending=1]="ProviderResultPending",t[t.ProviderResultReceived=2]="ProviderResultReceived",t[t.Canceled=3]="Canceled",t))(ot||{}),me=(t=>(t[t.Onfido=0]="Onfido",t[t.Sumsub=2]="Sumsub",t[t.SardinAI=3]="SardinAI",t))(me||{}),lt=(t=>(t[t.Individual=0]="Individual",t[t.Company=1]="Company",t))(lt||{}),Oe=(t=>(t[t.Male=0]="Male",t[t.Female=1]="Female",t[t.Other=2]="Other",t))(Oe||{}),ct=(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))(ct||{}),dt=(t=>(t[t.Pending=0]="Pending",t[t.Approved=1]="Approved",t[t.Rejected=2]="Rejected",t[t.RequiresRevision=3]="RequiresRevision",t))(dt||{}),ut=(t=>(t[t.SingleChoice=0]="SingleChoice",t[t.MultipleChoice=1]="MultipleChoice",t[t.Text=2]="Text",t))(ut||{}),ve=(t=>(t[t.String=0]="String",t[t.Integer=1]="Integer",t[t.Decimal=2]="Decimal",t[t.Boolean=3]="Boolean",t[t.Date=4]="Date",t[t.Country=5]="Country",t[t.DigitOnly=6]="DigitOnly",t))(ve||{}),mt=(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))(mt||{}),pt=(t=>(t[t.None=0]="None",t[t.Country=1]="Country",t))(pt||{}),de=(t=>(t[t.Individual=0]="Individual",t[t.Sophisticated=1]="Sophisticated",t[t.HighNetWorth=2]="HighNetWorth",t[t.Business=3]="Business",t))(de||{}),ht=(t=>(t[t.Retail=0]="Retail",t[t.Professional=1]="Professional",t[t.EligibleCounterparty=2]="EligibleCounterparty",t))(ht||{});const Ae={Nationality:10,Address:20,CountryOfBirth:30,PhoneNumber:40,UboAddress:50},Ee={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:Ae.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:Ae.Address},nationality:{label:"Nationality",type:"select",countriesType:Ae.Nationality},otherNationality:{label:"Other Nationalities",type:"multiselect",countriesType:Ae.Nationality},countryOfBirth:{label:"Country of Birth",type:"select",countriesType:Ae.CountryOfBirth},placeOfBirth:{label:"Place of Birth",type:"text"},taxCountry:{label:"Tax Country",type:"select",countriesType:Ae.Address},taxNumber:{label:"Tax Number",type:"text"},defaultLanguage:{label:"Default Language",type:"select"},educationLevel:{label:"Education Level",type:"text"},occupation:{label:"Occupation",type:"text"}},gt=["firstName","lastName","email","phonenumber","dateOfBirth"],He=[{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 xt={timeout:3e4,retries:3,locale:"en",endpoints:{pattern:"host-controller"}};class yt{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 ye extends Error{constructor(s,a,n,i,c){super(s);X(this,"response");this.code=a,this.details=n,this.validationErrors=i,this.name="MetaKYCError",this.response=c,Object.setPrototypeOf(this,ye.prototype)}}class Ie{static handleApiError(r){return new ye(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 ye(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 ye(s.result.message,r.response.status,`HTTP ${r.response.status}: ${r.response.statusText}`,void 0,r.response):new ye((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 ye("No response from server",0,"The request was made but no response was received. Please check your network connection."):new ye(r.message||"An unexpected error occurred",0,r.toString())}static isMetaKYCError(r){return r instanceof ye}}class ft{constructor(r){X(this,"axiosInstance");X(this,"endpointBuilder");X(this,"config");this.config={...xt,...r},this.endpointBuilder=new yt(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 n;const a=s.config;return((n=s.response)==null?void 0:n.status)>=500&&!a._retry&&(a._retry=!0,a._retryCount=(a._retryCount||0)+1,a._retryCount<(this.config.retries||3))?(await new Promise(i=>setTimeout(i,1e3*a._retryCount)),this.axiosInstance(a)):Promise.reject(s)})}buildEndpoint(r,s){return this.endpointBuilder.build(r,s)}async get(r,s,a){try{const n=this.buildEndpoint(r,s),i=await this.axiosInstance.get(n,{params:a});return this.handleResponse(i)}catch(n){throw Ie.handleAxiosError(n)}}async post(r,s,a){try{const n=this.buildEndpoint(r,s),i=await this.axiosInstance.post(n,a);return this.handleResponse(i)}catch(n){throw Ie.handleAxiosError(n)}}async put(r,s,a){try{const n=this.buildEndpoint(r,s),i=await this.axiosInstance.put(n,a);return this.handleResponse(i)}catch(n){throw Ie.handleAxiosError(n)}}async delete(r,s,a){try{const n=this.buildEndpoint(r,s),i=await this.axiosInstance.delete(n,{params:a});return this.handleResponse(i)}catch(n){throw Ie.handleAxiosError(n)}}handleResponse(r){const s=r.data;if(!s.success&&s.error)throw Ie.handleApiError(s.error);return s}getAxiosInstance(){return this.axiosInstance}}class bt{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 vt{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 kt{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 wt{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 jt{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 St{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 Nt{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 Ct{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 At{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 oe={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"}}},Et={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"}},Rt={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"}},It={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"}}},Pt={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"}},Ft={[ae.Default]:oe,[ae.Corporate]:Et,[ae.Fintech]:Rt,[ae.Healthcare]:It,[ae.Modern]:Pt,[ae.Minimal]:Dt};function Pe(t){return Ft[t]||oe}class Lt{constructor(r){this.httpClient=r}async getThemeConfiguration(){var r;try{const s=await this.httpClient.get("Tenant","GetThemeConfiguration");if(!s.result.isEnabled)return Pe(ae.Default);let a=s.result.preset?Pe(s.result.preset):Pe(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 n=typeof s.result.applicantFormPages=="string"?JSON.parse(s.result.applicantFormPages):s.result.applicantFormPages;Array.isArray(n)&&n.length>0&&(a.applicantFormPages=n.map(i=>{const c=!i._v||i._v<4;return{...i,fields:(i.fields||[]).map(d=>({...d,colSpan:c?d.colSpan===1?2:4:Math.min(4,Math.max(1,d.colSpan??4))}))}}))}catch{}return a}catch(s){return console.warn("[ThemeService] Failed to fetch theme configuration:",s),Pe(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=Pe(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 Tt{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(n=>{try{n(s)}catch(i){console.error(`Error in event listener for "${r}":`,i)}})}clear(){this.listeners.clear()}clearEvent(r){this.listeners.delete(r)}}class Mt{constructor(){X(this,"events",new Tt);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)||pe.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===pe.Finished}get isOnHold(){return this.status===pe.OnHold}get isInProgress(){return this.status===pe.InProgress}setApplicantId(r){this._applicantId=r}updateProgress(r){var a,n;const s=(a=this._progress)==null?void 0:a.currentStep;this._progress=r,this._applicantId=r.applicantId,this._error=null,this.events.emit("progressUpdated",r),(s==null?void 0:s.order)!==((n=r.currentStep)==null?void 0:n.order)&&this.events.emit("stepChanged",r.currentStep),this.events.emit("statusChanged",r.status),r.status===pe.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 Ot{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: ${Y[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: ${Y[r]}`);return a.submitData(s)}}class zt{constructor(r,s,a,n,i,c,d,u){X(this,"state");X(this,"stepRouter");this.applicantService=r,this.questionnaireService=s,this.uploadDocumentService=a,this.appropriatenessTestService=n,this.overviewService=i,this.riskScoringService=c,this.investorCategorizationService=u,this.state=new Mt,this.stepRouter=new Ot,this.registerStepHandlers()}registerStepHandlers(){this.stepRouter.registerHandler(Y.Questionaries,{loadData:r=>this.questionnaireService.getQuestionnaire(r),submitData:async r=>{await this.questionnaireService.fillQuestionnaire(r)}}),this.stepRouter.registerHandler(Y.UploadDocument,{loadData:r=>this.uploadDocumentService.getUploadDocument(r),submitData:r=>this.uploadDocumentService.fillUploadDocument(r)}),this.stepRouter.registerHandler(Y.AppropriatenessTest,{loadData:r=>this.appropriatenessTestService.getAppropriatenessTest(r),submitData:async r=>{await this.appropriatenessTestService.fillAppropriatenessTest(r)}}),this.stepRouter.registerHandler(Y.Overview,{loadData:r=>this.overviewService.getOverviewData(r),submitData:r=>this.overviewService.passOverview(r.applicantId)}),this.stepRouter.registerHandler(Y.RiskScoring,{loadData:r=>this.riskScoringService.getRiskCriterias(r),submitData:async r=>{await this.riskScoringService.submitRiskScoring(r)}}),this.stepRouter.registerHandler(Y.IdentitySdk,{loadData:async r=>({applicantId:r,message:"Identity verification required"}),submitData:async()=>{}}),this.stepRouter.registerHandler(Y.InvestorCategorization,{loadData:r=>this.investorCategorizationService.getInvestorCategorization(r),submitData:async r=>{await this.investorCategorizationService.setInvestorCategorization(r)}}),this.stepRouter.registerHandler(Y.ManualReview,{loadData:async r=>({applicantId:r,message:"Your application is under manual review"}),submitData:async()=>{}}),this.stepRouter.registerHandler(Y.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 qe(t,r){return new Promise((s,a)=>{if(r&&document.getElementById(r)){s();return}const n=document.createElement("script");n.src=t,r&&(n.id=r),n.async=!0,n.onload=()=>s(),n.onerror=()=>a(new Error(`Failed to load script: ${t}`)),document.head.appendChild(n)})}function Sr(t){return!!document.getElementById(t)}function Nr(t){const r=document.getElementById(t);r&&r.remove()}class Bt{constructor(r){X(this,"sdk",null);X(this,"config");this.config=r}async loadSDK(){await qe("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 $t{constructor(r){X(this,"sdk",null);X(this,"config");this.config=r}async loadSDK(){await qe("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 _t{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(),n=document.createElement("script");n.type="text/javascript",n.async=!0,n.src=`https://${a}/assets/loader.min.js`,n.onload=()=>{console.log("[SardinAI] SDK loaded successfully"),r()},n.onerror=()=>{s(new Error("Failed to load SardinAI SDK"))};const i=document.getElementsByTagName("script")[0];i&&i.parentNode?i.parentNode.insertBefore(n,i):document.head.appendChild(n)})}async initialize(){try{if(await this.loadSDK(),!window._Sardine)throw new Error("SardinAI SDK not available after loading");const r=this.getSardineHost(),{clientId:s,environment:a,flow:n,enableBiometrics:i,enablePortScanning:c}=this.config;this.sardineContext=window._Sardine.createContext({clientId:s,sessionKey:this.sessionKey,userIdHash:void 0,flow:n||window.location.pathname,environment:a||"production",parentElement:document.body,enableBiometrics:i!==!1,enablePortScanning:c===!0,region:this.config.region,onDeviceResponse:d=>{console.log(`[SardinAI] Device ID: ${d.deviceId}`)},onConfigUpdate:(d,u,p)=>{switch(d){case"SESSION_UPDATE_FAILED":console.error("[SardinAI] Session update failed:",p);break;case"SESSION_UPDATED":console.log("[SardinAI] Session updated:",u);break;case"SESSION_NO_UPDATE":console.log("[SardinAI] No session update");break;default:console.warn("[SardinAI] Unknown event:",d)}}}),this.addNoScriptFallback(r),console.log("[SardinAI] SDK initialized with sessionKey:",this.sessionKey)}catch(r){throw console.error("[SardinAI] Initialization failed:",r),r}}addNoScriptFallback(r){const s=document.createElement("noscript"),a=document.createElement("img"),{clientId:n,flow:i}=this.config;a.src=`https://${r}/v1/a.png?clientId=${n}&sessionKey=${this.sessionKey}&flow=${i||"kyc"}&ns=1`,a.style.display="none",s.appendChild(a),document.body.appendChild(s)}updateConfig(r){if(!this.sardineContext){console.warn("[SardinAI] Cannot update config - SDK not initialized");return}r.sessionKey&&(this.sessionKey=r.sessionKey),this.sardineContext.updateConfig({...r,onConfigUpdate:(s,a,n)=>{switch(s){case"SESSION_UPDATE_FAILED":console.error("[SardinAI] Config update failed:",n);break;case"SESSION_UPDATED":console.log("[SardinAI] Config updated:",a);break;case"SESSION_NO_UPDATE":console.log("[SardinAI] No config update needed");break}}})}getSessionKey(){return this.sessionKey}destroy(){this.sardineContext&&(this.sardineContext=null)}}class Re{static createProvider(r,s){switch(r){case me.Sumsub:return new Bt(s);case me.Onfido:return new $t(s);case me.SardinAI:return new _t(s);default:throw new Error(`Unsupported identity provider: ${r}`)}}static parseProviderConfig(r,s,a){var n;switch(r){case me.Sumsub:return{accessToken:s.accessToken||s.token,applicantEmail:s.email,applicantPhone:s.phone,externalUserId:s.externalUserId,lang:s.lang||"en"};case me.Onfido:return{token:s.token||s.sdkToken};case me.SardinAI:const i=((n=a==null?void 0:a.identityProviders)==null?void 0:n.sardinai)||{};return{clientId:i.clientId||s.clientId,sessionKey:i.sessionKey||s.sessionKey,environment:i.environment||s.environment||"production",flow:i.flow||s.flow,region:i.region,enableBiometrics:i.enableBiometrics,enablePortScanning:i.enablePortScanning};default:throw new Error(`Unsupported identity provider: ${r}`)}}}class Ht{constructor(r){X(this,"currentTheme",oe);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,"input-bg":r.background,surface:r.surface,border:r.border,"text-primary":r.textPrimary,"text-secondary":r.textSecondary,"text-muted":r.textMuted};Object.entries(s).forEach(([n,i])=>{this.container.style.setProperty(`--metakyc-${n}`,i)}),(a=this.currentTheme.darkMode)!=null&&a.colors&&this.applyDarkModeColors(this.currentTheme.darkMode.colors)}applyDarkModeColors(r){Object.entries(r).forEach(([s,a])=>{if(a){const n=`--metakyc-dark-${this.kebabCase(s)}`;this.container.style.setProperty(n,a)}})}applyTypography(r){r&&(r.fontFamily&&this.container.style.setProperty("--metakyc-font-family",r.fontFamily),r.headingFont&&this.container.style.setProperty("--metakyc-heading-font",r.headingFont),r.fontSize&&Object.entries(r.fontSize).forEach(([s,a])=>{this.container.style.setProperty(`--metakyc-font-size-${s}`,a)}),r.fontWeight&&Object.entries(r.fontWeight).forEach(([s,a])=>{this.container.style.setProperty(`--metakyc-font-weight-${s}`,a.toString())}))}applySpacing(r){r&&Object.entries(r).forEach(([s,a])=>{const n=`--metakyc-${this.kebabCase(s)}`;this.container.style.setProperty(n,a)})}injectCustomCSS(r){this.customStyleElement&&this.customStyleElement.remove(),this.customStyleElement=document.createElement("style"),this.customStyleElement.id="metakyc-custom-css",this.customStyleElement.textContent=r,document.head.appendChild(this.customStyleElement)}mergeWithDefault(r){var s;return{name:r.name||oe.name,title:r.title||oe.title,logo:{...oe.logo,...r.logo},colors:{...oe.colors,...r.colors},typography:r.typography?{...oe.typography,...r.typography}:oe.typography,spacing:r.spacing?{...oe.spacing,...r.spacing}:oe.spacing,customCSS:r.customCSS,darkMode:r.darkMode?{colors:{...(s=oe.darkMode)==null?void 0:s.colors,...r.darkMode.colors}}:oe.darkMode,applicantFormVisibleFields:r.applicantFormVisibleFields,applicantFormRequiredFields:r.applicantFormRequiredFields,allowedLanguages:r.allowedLanguages,applicantFormPages:r.applicantFormPages}}getCurrentTheme(){return this.currentTheme}resetTheme(){this.applyTheme(oe)}cleanup(){this.customStyleElement&&(this.customStyleElement.remove(),this.customStyleElement=null)}kebabCase(r){return r.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}}const We=o.createContext(null),Cr=({config:t,children:r})=>{const[s,a]=o.useState(null),n=o.useRef(!1),i=o.useRef(!1),c=o.useMemo(()=>{const u=new ft(t),p=new bt(u),f=new vt(u),w=new kt(u),m=new wt(u),x=new jt(u),h=new St(u),S=new Nt(u),P=new Ct(u),v=new At(u),O=new Lt(u),N=new Ht;return{httpClient:u,applicantService:p,questionnaireService:f,uploadDocumentService:w,appropriatenessTestService:m,overviewService:x,riskScoringService:h,identityService:S,baseInformationService:P,investorCategorizationService:v,themeService:O,themeManager:N}},[t]),d=o.useMemo(()=>({config:t,...c,currentTheme:s,createOrchestrator:()=>new zt(c.applicantService,c.questionnaireService,c.uploadDocumentService,c.appropriatenessTestService,c.overviewService,c.riskScoringService,c.identityService,c.investorCategorizationService)}),[t,c,s]);return o.useEffect(()=>((async()=>{if(n.current||i.current){console.log("[MetaKYC] Theme already loading or loaded, skipping...");return}n.current=!0;try{if(t.theme){console.log("[MetaKYC] Applying static theme from config"),c.themeManager.applyTheme(t.theme),a(c.themeManager.getCurrentTheme()),i.current=!0;return}console.log("[MetaKYC] Fetching theme from backend...");const p=await c.themeService.getThemeConfiguration();c.themeManager.applyTheme(p),a(c.themeManager.getCurrentTheme()),i.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()),i.current=!0}finally{n.current=!1}})(),()=>{c.themeManager.cleanup()}),[]),e.jsx(We.Provider,{value:d,children:r})};function ue(){const t=o.useContext(We);if(!t)throw new Error("useMetaKYC must be used within a MetaKYCProvider");return t}async function Ut(t){return new Promise((r,s)=>{const a=new FileReader;a.readAsDataURL(t),a.onload=()=>{const i=a.result.split(",")[1];r(i)},a.onerror=n=>s(n)})}function Ar(t,r){return t.size<=r}function Er(t,r){return r.split(",").map(a=>a.trim()).some(a=>{if(a.endsWith("/*")){const n=a.slice(0,-2);return t.type.startsWith(n)}return t.type===a})}function $e(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 Rr(t){return t}function se(...t){return t.filter(Boolean).join(" ")}const Fe={APPLICANT_ID:"metakyc_applicant_id",WORKFLOW_STATE:"metakyc_workflow_state"};function Kt(t){try{localStorage.setItem(Fe.APPLICANT_ID,t.toString())}catch(r){console.warn("Failed to save applicant ID to storage:",r)}}function qt(){try{const t=localStorage.getItem(Fe.APPLICANT_ID);return t?parseInt(t,10):null}catch(t){return console.warn("Failed to retrieve applicant ID from storage:",t),null}}function Wt(){try{localStorage.removeItem(Fe.APPLICANT_ID)}catch(t){console.warn("Failed to clear applicant ID from storage:",t)}}function Yt(t){try{localStorage.setItem(Fe.WORKFLOW_STATE,JSON.stringify(t))}catch(r){console.warn("Failed to save workflow state to storage:",r)}}function Ir(){try{const t=localStorage.getItem(Fe.WORKFLOW_STATE);return t?JSON.parse(t):null}catch(t){return console.warn("Failed to retrieve workflow state from storage:",t),null}}function Qt(){try{localStorage.removeItem(Fe.WORKFLOW_STATE)}catch(t){console.warn("Failed to clear workflow state from storage:",t)}}function Pr(){Wt(),Qt()}function Gt(t){const{createOrchestrator:r}=ue(),[s,a]=o.useState(null),[n,i]=o.useState(!1),[c,d]=o.useState(null),u=o.useRef(null),p=t||qt();o.useEffect(()=>{u.current||(u.current=r())},[r]),o.useEffect(()=>{var N;s&&p&&(Kt(p),Yt({applicantId:p,currentStepOrder:(N=s.currentStep)==null?void 0:N.order,status:s.status,lastUpdated:new Date().toISOString(),workflowKey:s.workFlowKey,nextWorkflowKey:s.nextWorkflowKey}))},[s,p]);const f=o.useRef(!1),w=o.useRef(!1),m=o.useCallback(async()=>{if(!(!p||!u.current)){if(f.current){console.log("[Workflow] Load already in progress, skipping...");return}f.current=!0,i(!0),d(null);try{const N=await u.current.initialize(p);a(N),w.current=!0}catch(N){d(N)}finally{i(!1),f.current=!1}}},[p]);o.useEffect(()=>{p&&!w.current&&m()},[p,m]);const x=o.useCallback(async()=>{if(u.current){if(f.current){console.log("[Workflow] Refresh already in progress, skipping...");return}f.current=!0,i(!0),d(null);try{const N=await u.current.refreshProgress();a(N)}catch(N){d(N)}finally{i(!1),f.current=!1}}},[]),h=o.useCallback(async()=>{if(u.current){i(!0),d(null);try{const N=await u.current.moveToNextStep();a(N)}catch(N){d(N)}finally{i(!1)}}},[]),S=o.useCallback(async()=>{if(u.current){i(!0),d(null);try{const N=await u.current.moveToPreviousStep();a(N)}catch(N){d(N)}finally{i(!1)}}},[]),P=o.useCallback(async N=>{if(u.current){i(!0),d(null);try{await u.current.submitCurrentStep(N);const A=await u.current.refreshProgress();a(A)}catch(A){throw d(A),A}finally{i(!1)}}},[]),v=Xe.useMemo(()=>s!=null&&s.stepInfoList?[...s.stepInfoList].sort((N,A)=>N.order-A.order):[],[s==null?void 0:s.stepInfoList]),O=Xe.useMemo(()=>s?s.nextWorkflowKey&&s.nextWorkflowKey!==s.workFlowKey:!1,[s]);return{progress:s,applicantId:p,currentStep:(s==null?void 0:s.currentStep)||null,steps:v,status:(s==null?void 0:s.status)||pe.None,workflowResult:(s==null?void 0:s.workflowResult)||null,workflowKey:s==null?void 0:s.workFlowKey,nextWorkflowKey:s==null?void 0:s.nextWorkflowKey,hasWorkflowChanged:O,isLoading:n,error:c,isComplete:(s==null?void 0:s.status)===pe.Finished,isOnHold:(s==null?void 0:s.status)===pe.OnHold,refreshProgress:x,moveToNext:h,moveBack:S,submitCurrentStep:P,orchestrator:u.current}}function Vt(t){const{questionnaireService:r,applicantService:s}=ue(),[a,n]=o.useState(null),[i,c]=o.useState({}),[d,u]=o.useState(!1),[p,f]=o.useState(!1),[w,m]=o.useState(null),x=o.useRef(!1),h=o.useRef(null),S=o.useCallback(async()=>{var v,O;if(t){if(x.current){console.log("[Questionnaire] Load already in progress, skipping...");return}x.current=!0,u(!0),m(null);try{const[N,A]=await Promise.all([r.getQuestionnaire(t),s.getApplicantData(t).catch(()=>null)]);if(n(N),(v=A==null?void 0:A.questionnaireResults)!=null&&v.length&&N){const H=new Map;for(const g of A.questionnaireResults)g.question&&((O=g.answers)!=null&&O.length)&&H.set(g.question.trim().toLowerCase(),g.answers);const V={},C=N.questionGroups.flatMap(g=>g.questions??[]);for(const g of C){const E=g.text.trim().toLowerCase();H.has(E)&&(V[g.id]=H.get(E))}c(V)}h.current=t}catch(N){m(N)}finally{u(!1),x.current=!1}}},[t,r,s]);o.useEffect(()=>{t&&h.current!==t&&S()},[t]);const P=o.useCallback(async v=>{f(!0),m(null);try{return await r.fillQuestionnaire(v)}catch(O){throw m(O),O}finally{f(!1)}},[r]);return{questionnaire:a,initialAnswers:i,isLoading:d,isSubmitting:p,error:w,load:S,submit:P}}function Zt(t){const{uploadDocumentService:r}=ue(),[s,a]=o.useState(null),[n,i]=o.useState(!1),[c,d]=o.useState(!1),[u,p]=o.useState(0),[f,w]=o.useState(null),m=o.useRef(!1),x=o.useRef(null),h=o.useCallback(async()=>{if(t){if(m.current){console.log("[UploadDocument] Load already in progress, skipping...");return}m.current=!0,i(!0),w(null);try{const P=await r.getUploadDocument(t);a(P),x.current=t}catch(P){w(P)}finally{i(!1),m.current=!1}}},[t,r]);o.useEffect(()=>{t&&x.current!==t&&h()},[t]);const S=o.useCallback(async P=>{d(!0),p(0),w(null);try{await r.fillUploadDocument(P),p(100)}catch(v){throw w(v),v}finally{d(!1)}},[r]);return{uploadDocument:s,isLoading:n,isSubmitting:c,uploadProgress:u,error:f,load:h,submit:S}}function Dr(t){const{appropriatenessTestService:r}=ue(),[s,a]=o.useState(null),[n,i]=o.useState(!1),[c,d]=o.useState(!1),[u,p]=o.useState(null),[f,w]=o.useState(null),m=o.useRef(!1),x=o.useRef(null),h=o.useCallback(async()=>{if(t){if(m.current){console.log("[AppropriatenessTest] Load already in progress, skipping...");return}m.current=!0,i(!0),p(null);try{const P=await r.getAppropriatenessTest(t);a(P),x.current=t}catch(P){p(P)}finally{i(!1),m.current=!1}}},[t,r]);o.useEffect(()=>{t&&x.current!==t&&h()},[t]);const S=o.useCallback(async P=>{d(!0),p(null);try{const v=await r.fillAppropriatenessTest(P);return w(v),v}catch(v){throw p(v),v}finally{d(!1)}},[r]);return{test:s,result:f,isLoading:n,isSubmitting:c,error:u,load:h,submit:S}}function Jt(t){const{overviewService:r}=ue(),[s,a]=o.useState(null),[n,i]=o.useState(!1),[c,d]=o.useState(!1),[u,p]=o.useState(null),f=o.useRef(!1),w=o.useRef(null),m=o.useCallback(async()=>{if(t){if(f.current){console.log("[Overview] Load already in progress, skipping...");return}f.current=!0,i(!0),p(null);try{const h=await r.getOverviewData(t);a(h),w.current=t}catch(h){p(h)}finally{i(!1),f.current=!1}}},[t,r]);o.useEffect(()=>{t&&w.current!==t&&m()},[t]);const x=o.useCallback(async()=>{if(t){d(!0),p(null);try{await r.passOverview(t)}catch(h){throw p(h),h}finally{d(!1)}}},[t,r]);return{overview:s,isLoading:n,isSubmitting:c,error:u,load:m,passOverview:x}}function Xt(t){const{identityService:r}=ue(),[s,a]=o.useState(null),[n,i]=o.useState(!1),[c,d]=o.useState(null),u=o.useRef(!1),p=o.useCallback(async(m,x)=>{if(t){if(u.current){console.log("[Identity] Request already in progress, skipping...");return}u.current=!0,i(!0),d(null);try{const h={applicantId:t,restart:!1,redirectUrl:m||"",ttl:x||604800};console.log("Identity request input:",h);const S=await r.identityRequest(h);return console.log("Identity request result:",S),a(S),S}catch(h){throw d(h),h}finally{i(!1),u.current=!1}}},[t,r]),f=o.useCallback(async(m,x)=>{if(t){i(!0),d(null);try{const h={applicantId:t,restart:!1,redirectUrl:m,ttl:x},S=await r.identityCompanyRequest(h);return a(S),S}catch(h){throw d(h),h}finally{i(!1)}}},[t,r]),w=o.useCallback(async()=>{if(t){if(u.current){console.log("[Identity] Restart already in progress, skipping...");return}u.current=!0,i(!0),d(null);try{const m={applicantId:t,restart:!0,redirectUrl:"",ttl:604800};console.log("Restarting identity with input:",m);const x=await r.identityRequest(m);return console.log("Restart identity result:",x),a(x),x}catch(m){throw d(m),m}finally{i(!1),u.current=!1}}},[t,r]);return{identityData:s,provider:(s==null?void 0:s.provider)||null,token:(s==null?void 0:s.publicProviderTokenObject)||null,isLoading:n,error:c,requestIdentity:p,requestCompanyIdentity:f,restartIdentity:w}}function er(t){const{riskScoringService:r,applicantService:s}=ue(),[a,n]=o.useState(null),[i,c]=o.useState({}),[d,u]=o.useState(!1),[p,f]=o.useState(!1),[w,m]=o.useState(null),[x,h]=o.useState(null),S=o.useRef(!1),P=o.useRef(null),v=o.useCallback(async()=>{var N;if(t){if(S.current){console.log("[RiskScoring] Load already in progress, skipping...");return}S.current=!0,u(!0),m(null);try{const[A,H]=await Promise.all([r.getRiskCriterias(t),s.getApplicantData(t).catch(()=>null)]);if(n(A),(N=H==null?void 0:H.riskScoringResults)!=null&&N.length){const V=H.riskScoringResults[0],C={};for(const g of V.riskCriteriaResults??[])if(g.riskCriteriaId!=null&&g.answer!=null&&g.answer!==""){const E=[...new Set(g.answer.split(",").map(R=>R.trim()).filter(R=>R!==""))];E.length>0&&(C[g.riskCriteriaId]=E)}c(C)}P.current=t}catch(A){m(A)}finally{u(!1),S.current=!1}}},[t,r,s]);o.useEffect(()=>{t&&P.current!==t&&v()},[t]);const O=o.useCallback(async N=>{f(!0),m(null);try{const A=await r.submitRiskScoring(N);return h(A),A}catch(A){throw m(A),A}finally{f(!1)}},[r]);return{criteria:a,initialAnswers:i,result:x,isLoading:d,isSubmitting:p,error:w,load:v,submit:O}}function tr(){const{applicantService:t,config:r}=ue(),[s,a]=o.useState(!1),[n,i]=o.useState(null),c=o.useRef(!1),d=o.useRef(!1),u=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(x){const h=Math.random()*16|0;return(x==="x"?h:h&3|8).toString(16)}),p=o.useCallback(async x=>{var h;if(c.current)throw console.log("[Applicant] Create already in progress, skipping..."),new Error("Creation already in progress");c.current=!0,a(!0),i(null);try{if(x.applicantAdditionalDatas||(x.applicantAdditionalDatas=[]),(h=r.identityProviders)!=null&&h.sardinai){const P=u();console.log("[SardinAI] Generated session key:",P),x.applicantAdditionalDatas.push({paramName:"sessionKey",value:P})}return await t.createApplicant(x)}catch(S){throw i(S),S}finally{a(!1),c.current=!1}},[t,r]),f=o.useCallback(async x=>{a(!0),i(null);try{return await t.createCompanyApplicant(x)}catch(h){throw i(h),h}finally{a(!1)}},[t]),w=o.useCallback(async x=>{if(d.current)throw console.log("[Applicant] Data load already in progress, skipping..."),new Error("Data load already in progress");d.current=!0,a(!0),i(null);try{return await t.getApplicantData(x)}catch(h){throw i(h),h}finally{a(!1),d.current=!1}},[t]),m=o.useCallback(async x=>{a(!0),i(null);try{await t.stopProgress(x)}catch(h){throw i(h),h}finally{a(!1)}},[t]);return{isLoading:s,error:n,createApplicant:p,createCompanyApplicant:f,getApplicantData:w,stopProgress:m}}const Q=({children:t,variant:r="primary",size:s="md",isLoading:a=!1,disabled:n,className:i,...c})=>{const d="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",u={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:se(d,u[r],p[s],i),disabled:n||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]})},le=o.forwardRef(({label:t,error:r,helperText:s,leftIcon:a,rightIcon:n,className:i,style:c,...d},u)=>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,d.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:u,className:se("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":"",n?"pr-10":"",i),style:{backgroundColor:"var(--metakyc-input-bg, #ffffff)",color:"var(--metakyc-text-primary, #111827)",borderColor:r?"var(--metakyc-danger, #ef4444)":"var(--metakyc-border, #d1d5db)",...c},...d}),n&&e.jsx("div",{className:"absolute inset-y-0 right-0 pr-3 flex items-center pointer-events-none",children:n})]}),r&&e.jsx("p",{className:"mt-1 text-sm",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})]}));le.displayName="Input";const U=({children:t,className:r,...s})=>e.jsx("div",{className:se("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:se("px-6 py-4 border-b",r),style:{borderColor:"var(--metakyc-border, #e5e7eb)"},...s,children:t}),K=({children:t,className:r,...s})=>e.jsx("div",{className:se("px-6 py-4",r),...s,children:t}),ce=({children:t,className:r,...s})=>e.jsx("div",{className:se("px-6 py-4 border-t",r),style:{borderColor:"var(--metakyc-border, #e5e7eb)"},...s,children:t}),be=({children:t,variant:r="default",className:s,...a})=>{const n={default:"bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300",success:"bg-success-100 text-success-800 dark:bg-success-900 dark:text-success-300",danger:"bg-danger-100 text-danger-800 dark:bg-danger-900 dark:text-danger-300",warning:"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300",info:"bg-primary-100 text-primary-800 dark:bg-primary-900 dark:text-primary-300"};return e.jsx("span",{className:se("inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium",n[r],s),...a,children:t})},he=({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:se("flex items-center justify-center",r),...s,children:e.jsxs("svg",{className:se("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"})]})})},De=o.forwardRef(({label:t,error:r,helperText:s,options:a,placeholder:n,className:i,style:c,...d},u)=>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,d.required&&e.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),e.jsxs("select",{ref:u,className:se("block w-full rounded-lg border px-3 py-2 text-sm transition-colors","focus:outline-none focus:ring-2 focus:ring-offset-0","disabled:opacity-60 disabled:cursor-not-allowed",r?"border-danger-500":"",i),style:{backgroundColor:"var(--metakyc-input-bg, #ffffff)",color:"var(--metakyc-text-primary, #111827)",borderColor:r?"var(--metakyc-error, #ef4444)":"var(--metakyc-border, #d1d5db)",...c},...d,children:[n&&e.jsx("option",{value:"",disabled:!0,style:{backgroundColor:"var(--metakyc-input-bg, #ffffff)",color:"var(--metakyc-text-secondary, #6b7280)"},children:n},"__placeholder__"),a.map((p,f)=>e.jsx("option",{value:p.value,disabled:p.disabled,style:{backgroundColor:"var(--metakyc-input-bg, #ffffff)",color:p.disabled?"var(--metakyc-text-secondary, #9ca3af)":"var(--metakyc-text-primary, #111827)"},children:p.label},p.value||`option-${f}`))]}),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})]}));De.displayName="Select";const et=280,rr=({label:t,value:r,onChange:s,options:a,placeholder:n="Select...",disabled:i=!1,required:c=!1})=>{const[d,u]=o.useState(!1),[p,f]=o.useState(""),[w,m]=o.useState(null),x=o.useRef(null),h=o.useRef(null),S=o.useRef(null),P=o.useCallback(()=>{if(!h.current)return null;const k=h.current.getBoundingClientRect(),J=window.innerHeight-k.bottom<et&&k.top>et;return{top:J?k.top:k.bottom+4,left:k.left,width:k.width,openUp:J}},[]),v=o.useCallback(()=>{if(i)return;const k=P();k&&m(k),u(!0)},[i,P]),O=o.useCallback(()=>{u(!1),f("")},[]);o.useEffect(()=>{if(!d)return;const k=_=>{var z,I;const J=_.target;!((z=x.current)!=null&&z.contains(J))&&!((I=S.current)!=null&&I.contains(J))&&O()};return document.addEventListener("mousedown",k),()=>document.removeEventListener("mousedown",k)},[d,O]),o.useEffect(()=>{if(!d)return;const k=()=>{const _=P();_&&m(_)};return window.addEventListener("scroll",k,!0),window.addEventListener("resize",k),()=>{window.removeEventListener("scroll",k,!0),window.removeEventListener("resize",k)}},[d,P]);const N=a.filter(k=>k.label.toLowerCase().includes(p.toLowerCase())),A=k=>{i||s(r.includes(k)?r.filter(_=>_!==k):[...r,k])},H=(k,_)=>{_.stopPropagation(),i||s(r.filter(J=>J!==k))},V=k=>{var _;return((_=a.find(J=>J.value===k))==null?void 0:_.label)||k},C=h.current?getComputedStyle(h.current):null,g=(C==null?void 0:C.getPropertyValue("--metakyc-input-bg").trim())||"#ffffff",E=(C==null?void 0:C.getPropertyValue("--metakyc-border").trim())||"#d1d5db",R=(C==null?void 0:C.getPropertyValue("--metakyc-text-primary").trim())||"#111827",M=(C==null?void 0:C.getPropertyValue("--metakyc-text-secondary").trim())||"#6b7280",B=(C==null?void 0:C.getPropertyValue("--metakyc-primary").trim())||"#2563eb",T=(C==null?void 0:C.getPropertyValue("--metakyc-primary-light").trim())||"#eff6ff",L=(C==null?void 0:C.getPropertyValue("--metakyc-hover-bg").trim())||"#f9fafb",G=d&&w&&e.jsxs("div",{ref:S,className:"metakyc-multiselect-dropdown",style:{position:"fixed",top:w.openUp?void 0:w.top,bottom:w.openUp?window.innerHeight-w.top+4:void 0,left:w.left,width:w.width,zIndex:99999,borderRadius:"8px",boxShadow:"0 4px 16px rgba(0,0,0,0.18)",border:`1px solid ${E}`,backgroundColor:g,overflow:"hidden"},children:[e.jsx("div",{style:{padding:"8px",borderBottom:`1px solid ${E}`},children:e.jsx("input",{type:"text",value:p,onChange:k=>f(k.target.value),placeholder:"Search...",autoFocus:!0,onClick:k=>k.stopPropagation(),className:"metakyc-multiselect-search w-full",style:{display:"block",width:"100%",padding:"6px 8px",fontSize:"13px",borderRadius:"6px",border:`1px solid ${E}`,backgroundColor:g,color:R,outline:"none",boxSizing:"border-box"}})}),e.jsx("ul",{style:{listStyle:"none",margin:0,padding:"4px 0",maxHeight:"192px",overflowY:"auto"},children:N.length===0?e.jsx("li",{style:{padding:"8px 12px",fontSize:"13px",color:M},children:"No results"}):N.map(k=>{const _=r.includes(k.value);return e.jsxs("li",{onClick:()=>A(k.value),className:"metakyc-multiselect-option",style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",fontSize:"13px",cursor:"pointer",backgroundColor:_?T:"transparent",color:_?B:R,userSelect:"none"},onMouseEnter:J=>{_||(J.currentTarget.style.backgroundColor=L)},onMouseLeave:J=>{_||(J.currentTarget.style.backgroundColor="transparent")},children:[e.jsx("input",{type:"checkbox",checked:_,readOnly:!0,style:{accentColor:B,pointerEvents:"none",flexShrink:0}}),e.jsx("span",{children:k.label})]},k.value)})}),r.length>0&&e.jsx("div",{style:{padding:"6px 12px",borderTop:`1px solid ${E}`},children:e.jsxs("button",{type:"button",onClick:()=>{s([]),f("")},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:x,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:h,onClick:()=>d?O():v(),className:se("metakyc-multiselect-trigger","min-h-[42px] w-full px-3 py-2 rounded-lg border text-sm transition-colors relative",i?"opacity-50 cursor-not-allowed":"cursor-pointer"),style:{backgroundColor:"var(--metakyc-input-bg, #ffffff)",borderColor:d?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #d1d5db)",outline:d?"2px solid 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:n}):e.jsx("div",{className:"flex flex-wrap gap-1 pr-6",children:r.map(k=>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:[V(k),!i&&e.jsx("button",{type:"button",onClick:_=>H(k,_),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:"×"})]},k))}),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:d?"▲":"▼"})]}),typeof document<"u"&&G?Ke.createPortal(G,document.body):null]})},tt=260,ze=({label:t,error:r,helperText:s,options:a,placeholder:n="Select...",value:i,onChange:c,disabled:d=!1,required:u=!1,className:p})=>{var I;const[f,w]=o.useState(!1),[m,x]=o.useState(""),[h,S]=o.useState(null),P=o.useRef(null),v=o.useRef(null),O=o.useRef(null),N=o.useRef(null),A=o.useCallback(()=>{if(!v.current)return null;const j=v.current.getBoundingClientRect(),Z=window.innerHeight-j.bottom<tt&&j.top>tt;return{top:Z?j.top:j.bottom+4,left:j.left,width:j.width,openUp:Z}},[]),H=o.useCallback(()=>{if(d)return;const j=A();j&&S(j),w(!0)},[d,A]),V=o.useCallback(()=>{w(!1),x("")},[]),C=()=>f?V():H();o.useEffect(()=>{if(!f)return;const j=$=>{var W,fe;const Z=$.target;!((W=P.current)!=null&&W.contains(Z))&&!((fe=O.current)!=null&&fe.contains(Z))&&V()};return document.addEventListener("mousedown",j),()=>document.removeEventListener("mousedown",j)},[f,V]),o.useEffect(()=>{if(!f)return;const j=()=>{const $=A();$&&S($)};return window.addEventListener("scroll",j,!0),window.addEventListener("resize",j),()=>{window.removeEventListener("scroll",j,!0),window.removeEventListener("resize",j)}},[f,A]),o.useEffect(()=>{f&&N.current&&setTimeout(()=>{var j;return(j=N.current)==null?void 0:j.focus()},0)},[f]);const g=a.filter(j=>j.label.toLowerCase().includes(m.toLowerCase())||j.value.toLowerCase().includes(m.toLowerCase())),E=(I=a.find(j=>j.value===i))==null?void 0:I.label,R=(j,$)=>{d||$||(c(j),V())},M=v.current?getComputedStyle(v.current):null,B=(M==null?void 0:M.getPropertyValue("--metakyc-input-bg").trim())||"#ffffff",T=(M==null?void 0:M.getPropertyValue("--metakyc-border").trim())||"#d1d5db",L=(M==null?void 0:M.getPropertyValue("--metakyc-text-primary").trim())||"#111827",G=(M==null?void 0:M.getPropertyValue("--metakyc-text-secondary").trim())||"#6b7280",k=(M==null?void 0:M.getPropertyValue("--metakyc-primary").trim())||"#2563eb",_=(M==null?void 0:M.getPropertyValue("--metakyc-primary-light").trim())||"#eff6ff",J=(M==null?void 0:M.getPropertyValue("--metakyc-hover-bg").trim())||"#f9fafb",z=f&&h&&e.jsxs("div",{ref:O,className:"metakyc-searchable-select-dropdown",style:{position:"fixed",top:h.openUp?void 0:h.top,bottom:h.openUp?window.innerHeight-h.top+4:void 0,left:h.left,width:h.width,zIndex:99999,borderRadius:"8px",boxShadow:"0 4px 16px rgba(0,0,0,0.18)",border:`1px solid ${T}`,backgroundColor:B,overflow:"hidden"},children:[e.jsx("div",{style:{padding:"8px",borderBottom:`1px solid ${T}`},children:e.jsx("input",{ref:N,type:"text",value:m,onChange:j=>x(j.target.value),placeholder:"Search...",onClick:j=>j.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:B,color:L,outline:"none",boxSizing:"border-box"}})}),e.jsx("ul",{style:{listStyle:"none",margin:0,padding:"4px 0",maxHeight:"208px",overflowY:"auto"},children:g.length===0?e.jsx("li",{style:{padding:"8px 12px",fontSize:"13px",color:G},children:"No results"}):g.map(j=>{const $=j.value===i;return e.jsx("li",{className:"metakyc-searchable-select-option",onClick:()=>R(j.value,j.disabled),style:{padding:"8px 12px",fontSize:"13px",cursor:j.disabled?"not-allowed":"pointer",opacity:j.disabled?.4:1,backgroundColor:$?_:"transparent",color:$?k:L,userSelect:"none"},onMouseEnter:Z=>{!$&&!j.disabled&&(Z.currentTarget.style.backgroundColor=J)},onMouseLeave:Z=>{$||(Z.currentTarget.style.backgroundColor="transparent")},children:j.label},j.value)})})]});return e.jsxs("div",{className:se("w-full metakyc-searchable-select",p),ref:P,children:[t&&e.jsxs("label",{className:"block text-sm font-medium mb-1",style:{color:"var(--metakyc-text-primary, #374151)"},children:[t,u&&e.jsx("span",{style:{color:"var(--metakyc-error, #ef4444)",marginLeft:"4px"},children:"*"})]}),e.jsxs("div",{ref:v,role:"button",tabIndex:d?-1:0,onClick:C,onKeyDown:j=>{(j.key==="Enter"||j.key===" ")&&(j.preventDefault(),C()),j.key==="Escape"&&V()},className:se("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",d?"opacity-60 cursor-not-allowed":"cursor-pointer"),style:{backgroundColor:"var(--metakyc-input-bg, #ffffff)",color:E?"var(--metakyc-text-primary, #111827)":"var(--metakyc-text-secondary, #9ca3af)",borderColor:r?"var(--metakyc-error, #ef4444)":f?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #d1d5db)",minHeight:"42px",outline:f?"2px solid var(--metakyc-primary, #2563eb)":"none",outlineOffset:"-1px"},children:[e.jsx("span",{className:"truncate flex-1",children:E||n}),e.jsx("span",{className:"flex-shrink-0 text-xs pointer-events-none",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:f?"▲":"▼"})]}),typeof document<"u"&&z?Ke.createPortal(z,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})]})};ze.displayName="SearchableSelect";const sr=({label:t,error:r,accept:s,multiple:a=!1,maxSize:n,onChange:i,value:c=[],className:d})=>{const[u,p]=o.useState(!1),f=o.useRef(null),w=v=>{if(!v)return;const O=Array.from(v);if(n&&O.filter(A=>A.size>n).length>0){const A=$e(n);alert(`Some files exceed the maximum size of ${A}`);return}i==null||i(a?[...c,...O]:[O[0]])},m=v=>{v.preventDefault(),p(!0)},x=()=>{p(!1)},h=v=>{v.preventDefault(),p(!1),w(v.dataTransfer.files)},S=()=>{var v;(v=f.current)==null||v.click()},P=v=>{const O=c.filter((N,A)=>A!==v);i==null||i(O)};return e.jsxs("div",{className:se("w-full",d),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:se("border-2 border-dashed rounded-lg p-6 text-center cursor-pointer transition-colors",u?"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:m,onDragLeave:x,onDrop:h,onClick:S,children:[e.jsx("input",{ref:f,type:"file",className:"hidden",accept:s,multiple:a,onChange:v=>w(v.target.files)}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("svg",{className:"mx-auto h-12 w-12 text-gray-400",stroke:"currentColor",fill:"none",viewBox:"0 0 48 48",children:e.jsx("path",{d:"M28 8H12a4 4 0 00-4 4v20m32-12v8m0 0v8a4 4 0 01-4 4H12a4 4 0 01-4-4v-4m32-4l-3.172-3.172a4 4 0 00-5.656 0L28 28M8 32l9.172-9.172a4 4 0 015.656 0L28 28m0 0l4 4m4-24h8m-4-4v8m-12 4h.02",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}),e.jsxs("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:[e.jsx("span",{className:"font-medium text-primary-500",children:"Click to upload"})," or drag and drop"]}),n&&e.jsxs("p",{className:"text-xs text-gray-500",children:["Maximum file size: ",$e(n)]})]})]}),c.length>0&&e.jsx("div",{className:"mt-3 space-y-2",children:c.map((v,O)=>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:v.name}),e.jsxs("span",{className:"text-xs text-gray-500",children:["(",$e(v.size),")"]})]}),e.jsx("button",{type:"button",onClick:N=>{N.stopPropagation(),P(O)},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"})})})]},O))}),r&&e.jsx("p",{className:"mt-1 text-sm text-danger-500",children:r})]})},ar=o.forwardRef(({countryCode:t="+1",onCountryCodeChange:r,className:s,...a},n)=>e.jsxs("div",{className:"w-full",children:[a.label&&e.jsxs("label",{className:"block text-sm font-medium 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:i=>r==null?void 0:r(i.target.value),className:se("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(le,{ref:n,type:"tel",className:se("flex-1",s),...a,label:""})]}),a.error&&e.jsx("p",{className:"mt-1 text-sm text-danger-500",children:a.error})]}));ar.displayName="PhoneInput";/**
|
|
2
2
|
* @license lucide-react v0.574.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|