@vpdev2/metakyc 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -49,7 +49,7 @@ a:hover { color: ${r}; }
49
49
  position: relative !important;
50
50
  z-index: 2 !important;
51
51
  }
52
- `}class xr{constructor(r){pe(this,"currentTheme",Re);pe(this,"customStyleElement",null);pe(this,"inputStyleElement",null);pe(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 n;const s={primary:r.primary,"primary-hover":r.primaryHover,"primary-light":r.primaryLight,"primary-dark":r.primaryDark,secondary:r.secondary,"secondary-hover":r.secondaryHover,success:r.success,warning:r.warning,danger:r.danger,info:r.info,background:r.background,surface:r.surface,border:r.border,"text-primary":r.textPrimary,"text-secondary":r.textSecondary,"text-muted":r.textMuted,"input-bg":r.inputBg||r.background,"input-text":r.inputText||r.textPrimary,"input-border":r.inputBorder||r.border,"input-border-focus":r.inputBorderFocus||r.primary,"input-placeholder":r.inputPlaceholder||r.textMuted};Object.entries(s).forEach(([a,o])=>{o&&this.container.style.setProperty(`--metakyc-${a}`,o)}),this.injectInputColors(),(n=this.currentTheme.darkMode)!=null&&n.colors&&this.applyDarkModeColors(this.currentTheme.darkMode.colors)}applyDarkModeColors(r){Object.entries(r).forEach(([s,n])=>{if(n){const a=`--metakyc-dark-${this.kebabCase(s)}`;this.container.style.setProperty(a,n)}})}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,n])=>{this.container.style.setProperty(`--metakyc-font-size-${s}`,n)}),r.fontWeight&&Object.entries(r.fontWeight).forEach(([s,n])=>{this.container.style.setProperty(`--metakyc-font-weight-${s}`,n.toString())}))}applySpacing(r){r&&Object.entries(r).forEach(([s,n])=>{const a=`--metakyc-${this.kebabCase(s)}`;this.container.style.setProperty(a,n)})}injectInputColors(){this.inputStyleElement&&this.inputStyleElement.remove(),this.inputStyleElement=document.createElement("style"),this.inputStyleElement.id="metakyc-input-colors",this.inputStyleElement.textContent=Zr(),this.customStyleElement&&this.customStyleElement.parentNode?document.head.insertBefore(this.inputStyleElement,this.customStyleElement):document.head.appendChild(this.inputStyleElement)}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||Re.name,title:r.title||Re.title,logo:{...Re.logo,...r.logo},colors:{...Re.colors,...r.colors},typography:r.typography?{...Re.typography,...r.typography}:Re.typography,spacing:r.spacing?{...Re.spacing,...r.spacing}:Re.spacing,customCSS:r.customCSS,darkMode:r.darkMode?{colors:{...(s=Re.darkMode)==null?void 0:s.colors,...r.darkMode.colors}}:Re.darkMode,applicantFormVisibleFields:r.applicantFormVisibleFields,applicantFormRequiredFields:r.applicantFormRequiredFields,allowedLanguages:r.allowedLanguages,applicantFormPages:r.applicantFormPages,reviewPageFields:r.reviewPageFields,reviewPageDisabled:r.reviewPageDisabled,fieldLabelMode:r.fieldLabelMode,companyFormVisibleFields:r.companyFormVisibleFields,companyFormRequiredFields:r.companyFormRequiredFields,companyFormPages:r.companyFormPages,companyReviewPageFields:r.companyReviewPageFields}}getCurrentTheme(){return this.currentTheme}resetTheme(){this.applyTheme(Re)}cleanup(){this.inputStyleElement&&(this.inputStyleElement.remove(),this.inputStyleElement=null),this.customStyleElement&&(this.customStyleElement.remove(),this.customStyleElement=null)}kebabCase(r){return r.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}}const bt=i.createContext(null),Xr=({config:t,children:r})=>{const[s,n]=i.useState(null),a=i.useRef(!1),o=i.useRef(!1),c=i.useMemo(()=>{const y=new Kt(t),p=new qt(y),b=new Vt(y),T=new Yt(y),v=new Qt(y),E=new Gt(y),A=new Jt(y),k=new Zt(y),S=new Xt(y),D=new er(y),Y=new or(y),L=new xr;return{httpClient:y,applicantService:p,questionnaireService:b,uploadDocumentService:T,appropriatenessTestService:v,overviewService:E,riskScoringService:A,identityService:k,baseInformationService:S,investorCategorizationService:D,themeService:Y,themeManager:L}},[t]),d=i.useMemo(()=>({config:t,...c,currentTheme:s,createOrchestrator:()=>new ur(c.applicantService,c.questionnaireService,c.uploadDocumentService,c.appropriatenessTestService,c.overviewService,c.riskScoringService,c.identityService,c.investorCategorizationService)}),[t,c,s]);return i.useEffect(()=>((async()=>{if(a.current||o.current){console.log("[MetaKYC] Theme already loading or loaded, skipping...");return}a.current=!0;try{if(t.theme){console.log("[MetaKYC] Applying static theme from config"),c.themeManager.applyTheme(t.theme),n(c.themeManager.getCurrentTheme()),o.current=!0;return}console.log("[MetaKYC] Fetching theme from backend...");const p=await c.themeService.getThemeConfiguration();c.themeManager.applyTheme(p),n(c.themeManager.getCurrentTheme()),o.current=!0,console.log("[MetaKYC] Theme loaded and applied",p)}catch(p){console.warn("[MetaKYC] Failed to load theme, using default:",p),n(c.themeManager.getCurrentTheme()),o.current=!0}finally{a.current=!1}})(),()=>{c.themeManager.cleanup()}),[]),e.jsx(bt.Provider,{value:d,children:r})};function Ne(){const t=i.useContext(bt);if(!t)throw new Error("useMetaKYC must be used within a MetaKYCProvider");return t}async function hr(t){return new Promise((r,s)=>{const n=new FileReader;n.readAsDataURL(t),n.onload=()=>{const o=n.result.split(",")[1];r(o)},n.onerror=a=>s(a)})}function es(t,r){return t.size<=r}function ts(t,r){return r.split(",").map(n=>n.trim()).some(n=>{if(n.endsWith("/*")){const a=n.slice(0,-2);return t.type.startsWith(a)}return t.type===n})}function ut(t){if(t===0)return"0 Bytes";const r=1024,s=["Bytes","KB","MB","GB"],n=Math.floor(Math.log(t)/Math.log(r));return Math.round(t/Math.pow(r,n)*100)/100+" "+s[n]}function rs(t){return t}function Se(...t){return t.filter(Boolean).join(" ")}const at={APPLICANT_ID:"metakyc_applicant_id",WORKFLOW_STATE:"metakyc_workflow_state"};function fr(t){try{localStorage.setItem(at.APPLICANT_ID,t.toString())}catch(r){console.warn("Failed to save applicant ID to storage:",r)}}function gr(){try{const t=localStorage.getItem(at.APPLICANT_ID);return t?parseInt(t,10):null}catch(t){return console.warn("Failed to retrieve applicant ID from storage:",t),null}}function br(){try{localStorage.removeItem(at.APPLICANT_ID)}catch(t){console.warn("Failed to clear applicant ID from storage:",t)}}function vr(t){try{localStorage.setItem(at.WORKFLOW_STATE,JSON.stringify(t))}catch(r){console.warn("Failed to save workflow state to storage:",r)}}function ss(){try{const t=localStorage.getItem(at.WORKFLOW_STATE);return t?JSON.parse(t):null}catch(t){return console.warn("Failed to retrieve workflow state from storage:",t),null}}function kr(){try{localStorage.removeItem(at.WORKFLOW_STATE)}catch(t){console.warn("Failed to clear workflow state from storage:",t)}}function ns(){br(),kr()}function jr(t){const{createOrchestrator:r}=Ne(),[s,n]=i.useState(null),[a,o]=i.useState(!1),[c,d]=i.useState(null),y=i.useRef(null),p=t||gr();i.useEffect(()=>{y.current||(y.current=r())},[r]),i.useEffect(()=>{var L;s&&p&&(fr(p),vr({applicantId:p,currentStepOrder:(L=s.currentStep)==null?void 0:L.order,status:s.status,lastUpdated:new Date().toISOString(),workflowKey:s.workFlowKey,nextWorkflowKey:s.nextWorkflowKey}))},[s,p]);const b=i.useRef(!1),T=i.useRef(!1),v=i.useCallback(async()=>{if(!(!p||!y.current)){if(b.current){console.log("[Workflow] Load already in progress, skipping...");return}b.current=!0,o(!0),d(null);try{const L=await y.current.initialize(p);n(L),T.current=!0}catch(L){d(L)}finally{o(!1),b.current=!1}}},[p]);i.useEffect(()=>{p&&!T.current&&v()},[p,v]);const E=i.useCallback(async()=>{if(y.current){if(b.current){console.log("[Workflow] Refresh already in progress, skipping...");return}b.current=!0,o(!0),d(null);try{const L=await y.current.refreshProgress();n(L)}catch(L){d(L)}finally{o(!1),b.current=!1}}},[]),A=i.useCallback(async()=>{if(y.current){o(!0),d(null);try{const L=await y.current.moveToNextStep();n(L)}catch(L){d(L)}finally{o(!1)}}},[]),k=i.useCallback(async()=>{if(y.current){o(!0),d(null);try{const L=await y.current.moveToPreviousStep();n(L)}catch(L){d(L)}finally{o(!1)}}},[]),S=i.useCallback(async L=>{if(y.current){o(!0),d(null);try{await y.current.submitCurrentStep(L);const B=await y.current.refreshProgress();n(B)}catch(B){throw d(B),B}finally{o(!1)}}},[]),D=wt.useMemo(()=>s!=null&&s.stepInfoList?[...s.stepInfoList].sort((L,B)=>L.order-B.order):[],[s==null?void 0:s.stepInfoList]),Y=wt.useMemo(()=>s?s.nextWorkflowKey&&s.nextWorkflowKey!==s.workFlowKey:!1,[s]);return{progress:s,applicantId:p,currentStep:(s==null?void 0:s.currentStep)||null,steps:D,status:(s==null?void 0:s.status)||Te.None,workflowResult:(s==null?void 0:s.workflowResult)||null,workflowKey:s==null?void 0:s.workFlowKey,nextWorkflowKey:s==null?void 0:s.nextWorkflowKey,hasWorkflowChanged:Y,isLoading:a,error:c,isComplete:(s==null?void 0:s.status)===Te.Finished,isOnHold:(s==null?void 0:s.status)===Te.OnHold,refreshProgress:E,moveToNext:A,moveBack:k,submitCurrentStep:S,orchestrator:y.current}}function wr(t){const{questionnaireService:r,applicantService:s}=Ne(),[n,a]=i.useState(null),[o,c]=i.useState({}),[d,y]=i.useState(!1),[p,b]=i.useState(!1),[T,v]=i.useState(null),E=i.useRef(!1),A=i.useRef(null),k=i.useCallback(async()=>{var D,Y;if(t){if(E.current){console.log("[Questionnaire] Load already in progress, skipping...");return}E.current=!0,y(!0),v(null);try{const[L,B]=await Promise.all([r.getQuestionnaire(t),s.getApplicantData(t).catch(()=>null)]);if(a(L),(D=B==null?void 0:B.questionnaireResults)!=null&&D.length&&L){const U=new Map;for(const f of B.questionnaireResults)f.question&&((Y=f.answers)!=null&&Y.length)&&U.set(f.question.trim().toLowerCase(),f.answers);const X={},R=L.questionGroups.flatMap(f=>f.questions??[]);for(const f of R){const O=f.text.trim().toLowerCase();U.has(O)&&(X[f.id]=U.get(O))}c(X)}A.current=t}catch(L){v(L)}finally{y(!1),E.current=!1}}},[t,r,s]);i.useEffect(()=>{t&&A.current!==t&&k()},[t]);const S=i.useCallback(async D=>{b(!0),v(null);try{return await r.fillQuestionnaire(D)}catch(Y){throw v(Y),Y}finally{b(!1)}},[r]);return{questionnaire:n,initialAnswers:o,isLoading:d,isSubmitting:p,error:T,load:k,submit:S}}function Sr(t){const{uploadDocumentService:r}=Ne(),[s,n]=i.useState(null),[a,o]=i.useState(!1),[c,d]=i.useState(!1),[y,p]=i.useState(0),[b,T]=i.useState(null),v=i.useRef(!1),E=i.useRef(null),A=i.useCallback(async()=>{if(t){if(v.current){console.log("[UploadDocument] Load already in progress, skipping...");return}v.current=!0,o(!0),T(null);try{const S=await r.getUploadDocument(t);n(S),E.current=t}catch(S){T(S)}finally{o(!1),v.current=!1}}},[t,r]);i.useEffect(()=>{t&&E.current!==t&&A()},[t]);const k=i.useCallback(async S=>{d(!0),p(0),T(null);try{await r.fillUploadDocument(S),p(100)}catch(D){throw T(D),D}finally{d(!1)}},[r]);return{uploadDocument:s,isLoading:a,isSubmitting:c,uploadProgress:y,error:b,load:A,submit:k}}function as(t){const{appropriatenessTestService:r}=Ne(),[s,n]=i.useState(null),[a,o]=i.useState(!1),[c,d]=i.useState(!1),[y,p]=i.useState(null),[b,T]=i.useState(null),v=i.useRef(!1),E=i.useRef(null),A=i.useCallback(async()=>{if(t){if(v.current){console.log("[AppropriatenessTest] Load already in progress, skipping...");return}v.current=!0,o(!0),p(null);try{const S=await r.getAppropriatenessTest(t);n(S),E.current=t}catch(S){p(S)}finally{o(!1),v.current=!1}}},[t,r]);i.useEffect(()=>{t&&E.current!==t&&A()},[t]);const k=i.useCallback(async S=>{d(!0),p(null);try{const D=await r.fillAppropriatenessTest(S);return T(D),D}catch(D){throw p(D),D}finally{d(!1)}},[r]);return{test:s,result:b,isLoading:a,isSubmitting:c,error:y,load:A,submit:k}}function Cr(t){const{overviewService:r}=Ne(),[s,n]=i.useState(null),[a,o]=i.useState(!1),[c,d]=i.useState(!1),[y,p]=i.useState(null),b=i.useRef(!1),T=i.useRef(null),v=i.useCallback(async()=>{if(t){if(b.current){console.log("[Overview] Load already in progress, skipping...");return}b.current=!0,o(!0),p(null);try{const A=await r.getOverviewData(t);n(A),T.current=t}catch(A){p(A)}finally{o(!1),b.current=!1}}},[t,r]);i.useEffect(()=>{t&&T.current!==t&&v()},[t]);const E=i.useCallback(async()=>{if(t){d(!0),p(null);try{await r.passOverview(t)}catch(A){throw p(A),A}finally{d(!1)}}},[t,r]);return{overview:s,isLoading:a,isSubmitting:c,error:y,load:v,passOverview:E}}function Nr(t){const{identityService:r}=Ne(),[s,n]=i.useState(null),[a,o]=i.useState(!1),[c,d]=i.useState(null),y=i.useRef(!1),p=i.useCallback(async(v,E)=>{if(t){if(y.current){console.log("[Identity] Request already in progress, skipping...");return}y.current=!0,o(!0),d(null);try{const A={applicantId:t,restart:!1,redirectUrl:v||"",ttl:E||604800};console.log("Identity request input:",A);const k=await r.identityRequest(A);return console.log("Identity request result:",k),n(k),k}catch(A){throw d(A),A}finally{o(!1),y.current=!1}}},[t,r]),b=i.useCallback(async(v,E)=>{if(t){o(!0),d(null);try{const A={applicantId:t,restart:!1,redirectUrl:v,ttl:E},k=await r.identityCompanyRequest(A);return n(k),k}catch(A){throw d(A),A}finally{o(!1)}}},[t,r]),T=i.useCallback(async()=>{if(t){if(y.current){console.log("[Identity] Restart already in progress, skipping...");return}y.current=!0,o(!0),d(null);try{const v={applicantId:t,restart:!0,redirectUrl:"",ttl:604800};console.log("Restarting identity with input:",v);const E=await r.identityRequest(v);return console.log("Restart identity result:",E),n(E),E}catch(v){throw d(v),v}finally{o(!1),y.current=!1}}},[t,r]);return{identityData:s,provider:(s==null?void 0:s.provider)||null,token:(s==null?void 0:s.publicProviderTokenObject)||null,isLoading:a,error:c,requestIdentity:p,requestCompanyIdentity:b,restartIdentity:T}}function Rr(t){const{riskScoringService:r,applicantService:s}=Ne(),[n,a]=i.useState(null),[o,c]=i.useState({}),[d,y]=i.useState(!1),[p,b]=i.useState(!1),[T,v]=i.useState(null),[E,A]=i.useState(null),k=i.useRef(!1),S=i.useRef(null),D=i.useCallback(async()=>{var L;if(t){if(k.current){console.log("[RiskScoring] Load already in progress, skipping...");return}k.current=!0,y(!0),v(null);try{const[B,U]=await Promise.all([r.getRiskCriterias(t),s.getApplicantData(t).catch(()=>null)]);if(a(B),(L=U==null?void 0:U.riskScoringResults)!=null&&L.length){const X=U.riskScoringResults[0],R={};for(const f of X.riskCriteriaResults??[])if(f.riskCriteriaId!=null&&f.answer!=null&&f.answer!==""){const O=[...new Set(f.answer.split(",").map(q=>q.trim()).filter(q=>q!==""))];O.length>0&&(R[f.riskCriteriaId]=O)}c(R)}S.current=t}catch(B){v(B)}finally{y(!1),k.current=!1}}},[t,r,s]);i.useEffect(()=>{t&&S.current!==t&&D()},[t]);const Y=i.useCallback(async L=>{b(!0),v(null);try{const B=await r.submitRiskScoring(L);return A(B),B}catch(B){throw v(B),B}finally{b(!1)}},[r]);return{criteria:n,initialAnswers:o,result:E,isLoading:d,isSubmitting:p,error:T,load:D,submit:Y}}function vt(){const{applicantService:t,config:r}=Ne(),[s,n]=i.useState(!1),[a,o]=i.useState(null),c=i.useRef(!1),d=i.useRef(!1),y=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(E){const A=Math.random()*16|0;return(E==="x"?A:A&3|8).toString(16)}),p=i.useCallback(async E=>{var A;if(c.current)throw console.log("[Applicant] Create already in progress, skipping..."),new Error("Creation already in progress");c.current=!0,n(!0),o(null);try{if(E.applicantAdditionalDatas||(E.applicantAdditionalDatas=[]),(A=r.identityProviders)!=null&&A.sardinai){const S=y();console.log("[SardinAI] Generated session key:",S),E.applicantAdditionalDatas.push({paramName:"sessionKey",value:S})}return await t.createApplicant(E)}catch(k){throw o(k),k}finally{n(!1),c.current=!1}},[t,r]),b=i.useCallback(async E=>{n(!0),o(null);try{return await t.createCompanyApplicant(E)}catch(A){throw o(A),A}finally{n(!1)}},[t]),T=i.useCallback(async E=>{if(d.current)throw console.log("[Applicant] Data load already in progress, skipping..."),new Error("Data load already in progress");d.current=!0,n(!0),o(null);try{return await t.getApplicantData(E)}catch(A){throw o(A),A}finally{n(!1),d.current=!1}},[t]),v=i.useCallback(async E=>{n(!0),o(null);try{await t.stopProgress(E)}catch(A){throw o(A),A}finally{n(!1)}},[t]);return{isLoading:s,error:a,createApplicant:p,createCompanyApplicant:b,getApplicantData:T,stopProgress:v}}const is={primary:{backgroundColor:"var(--metakyc-primary, #2563eb)",color:"#ffffff",borderColor:"transparent"},secondary:{backgroundColor:"var(--metakyc-surface, #f3f4f6)",color:"var(--metakyc-text-primary, #111827)",borderColor:"var(--metakyc-border, #e5e7eb)"},outline:{backgroundColor:"transparent",color:"var(--metakyc-primary, #2563eb)",borderColor:"var(--metakyc-primary, #2563eb)"},danger:{backgroundColor:"var(--metakyc-danger, #ef4444)",color:"#ffffff",borderColor:"transparent"},ghost:{backgroundColor:"transparent",color:"var(--metakyc-text-secondary, #6b7280)",borderColor:"transparent"}},J=({children:t,variant:r="primary",size:s="md",isLoading:n=!1,disabled:a,className:o,style:c,...d})=>{const y="inline-flex items-center justify-center rounded-lg font-medium transition-opacity border focus:outline-none focus:ring-2 focus:ring-offset-1 disabled:opacity-50 disabled:cursor-not-allowed",p={sm:"px-3 py-1.5 text-sm",md:"px-4 py-2 text-sm",lg:"px-6 py-3 text-base"};return e.jsxs("button",{className:Se(y,p[s],o),style:{...is[r],...c},disabled:a||n,...d,children:[n&&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]})},ye=i.forwardRef(({label:t,error:r,helperText:s,leftIcon:n,rightIcon:a,className:o,style:c,...d},y)=>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:[n&&e.jsx("div",{className:"absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none",children:n}),e.jsx("input",{ref:y,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",n?"pl-10":"",a?"pr-10":"",o),style:{minHeight:"38px",backgroundColor:d.readOnly?"var(--metakyc-surface, #f3f4f6)":"var(--metakyc-input-bg, #ffffff)",color:"var(--metakyc-input-text, var(--metakyc-text-primary, #111827))",borderColor:r?"var(--metakyc-danger, #ef4444)":"var(--metakyc-input-border, var(--metakyc-border, #d1d5db))",cursor:d.readOnly?"default":void 0,...c},...d}),a&&e.jsx("div",{className:"absolute inset-y-0 right-0 pr-3 flex items-center pointer-events-none",children:a})]}),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})]}));ye.displayName="Input";const ee=({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}),ge=({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}),te=({children:t,className:r,...s})=>e.jsx("div",{className:Se("px-6 py-4",r),...s,children:t}),be=({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}),os={default:{backgroundColor:"var(--metakyc-surface, #f3f4f6)",color:"var(--metakyc-text-secondary, #6b7280)"},info:{backgroundColor:"var(--metakyc-primary-light, #dbeafe)",color:"var(--metakyc-primary, #2563eb)"},success:{backgroundColor:"#d1fae5",color:"#065f46"},danger:{backgroundColor:"#fee2e2",color:"#991b1b"},warning:{backgroundColor:"#fef3c7",color:"#92400e"}},kt=({children:t,variant:r="default",className:s,style:n,...a})=>e.jsx("span",{className:Se("inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium",s),style:{...os[r],...n},...a,children:t}),Ee=({size:t="md",className:r,...s})=>{const n={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",n[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"})]})})},mt=i.forwardRef(({label:t,error:r,helperText:s,options:n,placeholder:a,className:o,style:c,...d},y)=>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:y,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":"",o),style:{minHeight:"38px",backgroundColor:"var(--metakyc-input-bg, #ffffff)",color:"var(--metakyc-input-text, var(--metakyc-text-primary, #111827))",borderColor:r?"var(--metakyc-danger, #ef4444)":"var(--metakyc-input-border, var(--metakyc-border, #d1d5db))",...c},...d,children:[a&&e.jsx("option",{value:"",disabled:!0,style:{backgroundColor:"var(--metakyc-input-bg, #ffffff)",color:"var(--metakyc-text-secondary, #6b7280)"},children:a},"__placeholder__"),n.map((p,b)=>e.jsx("option",{value:p.value,disabled:p.disabled,style:{backgroundColor:"var(--metakyc-input-bg, #ffffff)",color:p.disabled?"var(--metakyc-text-muted, #9ca3af)":"var(--metakyc-input-text, var(--metakyc-text-primary, #111827))"},children:p.label},p.value||`option-${b}`))]}),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})]}));mt.displayName="Select";const St=280,Ir=({label:t,value:r,onChange:s,options:n,placeholder:a="Select...",disabled:o=!1,readOnly:c=!1,required:d=!1})=>{const y=o||c,[p,b]=i.useState(!1),[T,v]=i.useState(""),[E,A]=i.useState(null),[k,S]=i.useState({bg:"#ffffff",borderColor:"#d1d5db",textPrimary:"#111827",textSecondary:"#6b7280",primaryColor:"#2563eb",primaryLight:"#eff6ff",hoverBg:"#f9fafb"}),D=i.useRef(null),Y=i.useRef(null),L=i.useRef(null),B=i.useCallback(()=>{if(!Y.current)return null;const I=Y.current.getBoundingClientRect(),z=window.innerHeight-I.bottom<St&&I.top>St;return{top:z?I.top:I.bottom+4,left:I.left,width:I.width,openUp:z}},[]),U=i.useCallback(()=>{const I=getComputedStyle(document.documentElement),W=(_,me)=>I.getPropertyValue(_).trim()||me,z=W("--metakyc-input-bg",W("--metakyc-background","#ffffff"));S({bg:z,borderColor:W("--metakyc-input-border",W("--metakyc-border","#d1d5db")),textPrimary:W("--metakyc-input-text",W("--metakyc-text-primary","#111827")),textSecondary:W("--metakyc-text-secondary","#6b7280"),primaryColor:W("--metakyc-primary","#2563eb"),primaryLight:W("--metakyc-primary-light","#eff6ff"),hoverBg:W("--metakyc-surface",z)})},[]),X=i.useCallback(()=>{if(y)return;U();const I=B();I&&A(I),b(!0)},[y,B,U]),R=i.useCallback(()=>{b(!1),v("")},[]);i.useEffect(()=>{if(!p)return;const I=W=>{var _,me;const z=W.target;!((_=D.current)!=null&&_.contains(z))&&!((me=L.current)!=null&&me.contains(z))&&R()};return document.addEventListener("mousedown",I),()=>document.removeEventListener("mousedown",I)},[p,R]),i.useEffect(()=>{if(!p)return;const I=()=>{const W=B();W&&A(W)};return window.addEventListener("scroll",I,!0),window.addEventListener("resize",I),()=>{window.removeEventListener("scroll",I,!0),window.removeEventListener("resize",I)}},[p,B]);const f=n.filter(I=>I.label.toLowerCase().includes(T.toLowerCase())),O=I=>{y||s(r.includes(I)?r.filter(W=>W!==I):[...r,I])},q=(I,W)=>{W.stopPropagation(),y||s(r.filter(z=>z!==I))},Q=I=>{var W;return((W=n.find(z=>z.value===I))==null?void 0:W.label)||I},{bg:$,borderColor:G,textPrimary:ne,textSecondary:V,primaryColor:he,primaryLight:le,hoverBg:de}=k,fe=p&&E&&e.jsxs("div",{ref:L,className:"metakyc-multiselect-dropdown",style:{position:"fixed",top:E.openUp?void 0:E.top,bottom:E.openUp?window.innerHeight-E.top+4:void 0,left:E.left,width:E.width,zIndex:99999,borderRadius:"8px",boxShadow:"0 4px 16px rgba(0,0,0,0.18)",border:`1px solid ${G}`,backgroundColor:$,overflow:"hidden"},children:[e.jsx("div",{style:{padding:"8px",borderBottom:`1px solid ${G}`},children:e.jsx("input",{type:"text",value:T,onChange:I=>v(I.target.value),placeholder:"Search...",autoFocus:!0,onClick:I=>I.stopPropagation(),className:"metakyc-multiselect-search w-full",style:{display:"block",width:"100%",padding:"6px 8px",fontSize:"13px",borderRadius:"6px",border:`1px solid ${G}`,backgroundColor:$,color:ne,outline:"none",boxSizing:"border-box"},onFocus:I=>{const W=getComputedStyle(document.documentElement),z=W.getPropertyValue("--metakyc-input-border-focus").trim()||W.getPropertyValue("--metakyc-primary").trim()||"#2563eb";I.currentTarget.style.backgroundColor=$,I.currentTarget.style.color=ne,I.currentTarget.style.borderColor=z,I.currentTarget.style.outline="none",I.currentTarget.style.boxShadow=`0 0 0 2px ${z}33`},onBlur:I=>{I.currentTarget.style.backgroundColor=$,I.currentTarget.style.color=ne,I.currentTarget.style.borderColor=G,I.currentTarget.style.outline="none",I.currentTarget.style.boxShadow="none"}})}),e.jsx("ul",{style:{listStyle:"none",margin:0,padding:"4px 0",maxHeight:"192px",overflowY:"auto"},children:f.length===0?e.jsx("li",{style:{padding:"8px 12px",fontSize:"13px",color:V},children:"No results"}):f.map(I=>{const W=r.includes(I.value);return e.jsxs("li",{onClick:()=>O(I.value),className:"metakyc-multiselect-option",style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",fontSize:"13px",cursor:"pointer",backgroundColor:W?le:"transparent",color:W?he:ne,userSelect:"none"},onMouseEnter:z=>{W||(z.currentTarget.style.backgroundColor=de)},onMouseLeave:z=>{W||(z.currentTarget.style.backgroundColor="transparent")},children:[e.jsx("input",{type:"checkbox",checked:W,readOnly:!0,style:{accentColor:he,pointerEvents:"none",flexShrink:0}}),e.jsx("span",{children:I.label})]},I.value)})}),r.length>0&&e.jsx("div",{style:{padding:"6px 12px",borderTop:`1px solid ${G}`},children:e.jsxs("button",{type:"button",onClick:()=>{s([]),v("")},style:{fontSize:"12px",color:"#ef4444",background:"none",border:"none",cursor:"pointer",padding:0},children:["Clear all (",r.length," selected)"]})})]});return e.jsxs("div",{className:"w-full metakyc-multiselect",ref:D,children:[t&&e.jsxs("label",{className:"block text-sm font-medium mb-1",style:{color:"var(--metakyc-text-primary, #374151)"},children:[t,d&&e.jsx("span",{style:{color:"var(--metakyc-error, #ef4444)",marginLeft:"4px"},children:"*"})]}),e.jsxs("div",{ref:Y,onClick:()=>p?R():X(),className:Se("metakyc-multiselect-trigger","w-full px-3 py-2 rounded-lg border text-sm transition-colors relative",y?"opacity-50 cursor-not-allowed":"cursor-pointer"),style:{minHeight:"38px",backgroundColor:"var(--metakyc-input-bg, #ffffff)",borderColor:p?"var(--metakyc-input-border-focus, var(--metakyc-primary, #2563eb))":"var(--metakyc-input-border, var(--metakyc-border, #d1d5db))",outline:p?"2px solid var(--metakyc-input-border-focus, var(--metakyc-primary, #2563eb))":"none",outlineOffset:"-1px"},children:[r.length===0?e.jsx("span",{className:"metakyc-multiselect-placeholder leading-6",style:{color:"var(--metakyc-text-secondary, #9ca3af)"},children:a}):e.jsx("div",{className:"flex flex-wrap gap-1 pr-6",children:r.map(I=>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:[Q(I),!y&&e.jsx("button",{type:"button",onClick:W=>q(I,W),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:"×"})]},I))}),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:p?"▲":"▼"})]}),typeof document<"u"&&fe?pt.createPortal(fe,document.body):null]})},Ct=260,De=({label:t,error:r,helperText:s,options:n,placeholder:a="Select...",value:o,onChange:c,disabled:d=!1,readOnly:y=!1,required:p=!1,className:b})=>{var me;const T=d||y,[v,E]=i.useState(!1),[A,k]=i.useState(""),[S,D]=i.useState(null),[Y,L]=i.useState({bg:"#ffffff",border:"#d1d5db",text:"#111827",textSecondary:"#6b7280",primary:"#2563eb",primaryLight:"#eff6ff",hoverBg:"#f9fafb"}),B=i.useCallback(()=>{const N=getComputedStyle(document.documentElement),re=(ae,ve)=>N.getPropertyValue(ae).trim()||ve,ue=re("--metakyc-input-bg",re("--metakyc-background","#ffffff"));L({bg:ue,border:re("--metakyc-input-border",re("--metakyc-border","#d1d5db")),text:re("--metakyc-input-text",re("--metakyc-text-primary","#111827")),textSecondary:re("--metakyc-text-secondary","#6b7280"),primary:re("--metakyc-primary","#2563eb"),primaryLight:re("--metakyc-primary-light","#eff6ff"),hoverBg:re("--metakyc-surface",ue)})},[]),U=i.useRef(null),X=i.useRef(null),R=i.useRef(null),f=i.useRef(null),O=i.useCallback(()=>{if(!X.current)return null;const N=X.current.getBoundingClientRect(),ue=window.innerHeight-N.bottom<Ct&&N.top>Ct;return{top:ue?N.top:N.bottom+4,left:N.left,width:N.width,openUp:ue}},[]),q=i.useCallback(()=>{if(T)return;B();const N=O();N&&D(N),E(!0)},[T,O,B]),Q=i.useCallback(()=>{E(!1),k("")},[]),$=()=>v?Q():q();i.useEffect(()=>{if(!v)return;const N=re=>{var ae,ve;const ue=re.target;!((ae=U.current)!=null&&ae.contains(ue))&&!((ve=R.current)!=null&&ve.contains(ue))&&Q()};return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[v,Q]),i.useEffect(()=>{if(!v)return;const N=()=>{const re=O();re&&D(re)};return window.addEventListener("scroll",N,!0),window.addEventListener("resize",N),()=>{window.removeEventListener("scroll",N,!0),window.removeEventListener("resize",N)}},[v,O]),i.useEffect(()=>{v&&f.current&&setTimeout(()=>{var N;return(N=f.current)==null?void 0:N.focus()},0)},[v]);const G=n.filter(N=>N.label.toLowerCase().includes(A.toLowerCase())||N.value.toLowerCase().includes(A.toLowerCase())),ne=(me=n.find(N=>N.value===o))==null?void 0:me.label,V=(N,re)=>{T||re||(c(N),Q())},{bg:he,border:le,text:de,textSecondary:fe,primary:I,primaryLight:W,hoverBg:z}=Y,_=v&&S&&e.jsxs("div",{ref:R,className:"metakyc-searchable-select-dropdown",style:{position:"fixed",top:S.openUp?void 0:S.top,bottom:S.openUp?window.innerHeight-S.top+4:void 0,left:S.left,width:S.width,zIndex:99999,borderRadius:"8px",boxShadow:"0 4px 16px rgba(0,0,0,0.18)",border:`1px solid ${le}`,backgroundColor:he,overflow:"hidden"},children:[e.jsx("div",{style:{padding:"8px",borderBottom:`1px solid ${le}`},children:e.jsx("input",{ref:f,type:"text",value:A,onChange:N=>k(N.target.value),placeholder:"Search...",onClick:N=>N.stopPropagation(),className:"metakyc-searchable-select-search w-full",style:{display:"block",width:"100%",padding:"6px 8px",fontSize:"13px",borderRadius:"6px",border:`1px solid ${le}`,backgroundColor:he,color:de,outline:"none",boxSizing:"border-box"},onFocus:N=>{const re=getComputedStyle(document.documentElement),ue=re.getPropertyValue("--metakyc-input-border-focus").trim()||re.getPropertyValue("--metakyc-primary").trim()||"#2563eb";N.currentTarget.style.backgroundColor=he,N.currentTarget.style.color=de,N.currentTarget.style.borderColor=ue,N.currentTarget.style.outline="none",N.currentTarget.style.boxShadow=`0 0 0 2px ${ue}33`},onBlur:N=>{N.currentTarget.style.backgroundColor=he,N.currentTarget.style.color=de,N.currentTarget.style.borderColor=le,N.currentTarget.style.outline="none",N.currentTarget.style.boxShadow="none"}})}),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:fe},children:"No results"}):G.map(N=>{const re=N.value===o;return e.jsx("li",{className:"metakyc-searchable-select-option",onClick:()=>V(N.value,N.disabled),style:{padding:"8px 12px",fontSize:"13px",cursor:N.disabled?"not-allowed":"pointer",opacity:N.disabled?.4:1,backgroundColor:re?W:"transparent",color:re?I:de,userSelect:"none"},onMouseEnter:ue=>{!re&&!N.disabled&&(ue.currentTarget.style.backgroundColor=z)},onMouseLeave:ue=>{re||(ue.currentTarget.style.backgroundColor="transparent")},children:N.label},N.value)})})]});return e.jsxs("div",{className:Se("w-full metakyc-searchable-select",b),ref:U,children:[t&&e.jsxs("label",{className:"block text-sm font-medium mb-1",style:{color:"var(--metakyc-text-primary, #374151)"},children:[t,p&&e.jsx("span",{style:{color:"var(--metakyc-error, #ef4444)",marginLeft:"4px"},children:"*"})]}),e.jsxs("div",{ref:X,role:"button",tabIndex:T?-1:0,onClick:$,onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),$()),N.key==="Escape"&&Q()},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",T?"opacity-60 cursor-not-allowed":"cursor-pointer"),style:{backgroundColor:"var(--metakyc-input-bg, #ffffff)",color:ne?"var(--metakyc-input-text, var(--metakyc-text-primary, #111827))":"var(--metakyc-input-placeholder, var(--metakyc-text-muted, #9ca3af))",borderColor:r?"var(--metakyc-danger, #ef4444)":v?"var(--metakyc-input-border-focus, var(--metakyc-primary, #2563eb))":"var(--metakyc-input-border, var(--metakyc-border, #d1d5db))",minHeight:"38px",outline:v?"2px solid var(--metakyc-input-border-focus, var(--metakyc-primary, #2563eb))":"none",outlineOffset:"-1px"},children:[e.jsx("span",{className:"truncate flex-1",children:ne||a}),e.jsx("span",{className:"flex-shrink-0 text-xs pointer-events-none",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:v?"▲":"▼"})]}),typeof document<"u"&&_?pt.createPortal(_,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})]})};De.displayName="SearchableSelect";function ls(t){const r=t.type;return r.startsWith("image/")?"image":r==="application/pdf"?"pdf":"file"}const Er=({label:t,subtitle:r,error:s,accept:n,multiple:a=!1,maxSize:o,required:c,onChange:d,value:y=[],className:p})=>{const[b,T]=i.useState(!1),[v,E]=i.useState(null),A=i.useRef(null),k=i.useCallback(R=>{if(!R)return;E(null);const f=Array.from(R);if(o&&f.filter(q=>q.size>o).length>0){E(`File exceeds the maximum size of ${ut(o)}`);return}d==null||d(a?[...y,...f]:[f[0]])},[o,a,d,y]),S=i.useCallback(R=>{R.preventDefault(),R.stopPropagation(),T(!0)},[]),D=i.useCallback(R=>{R.preventDefault(),R.stopPropagation(),T(!1)},[]),Y=i.useCallback(R=>{R.preventDefault(),R.stopPropagation(),T(!1),k(R.dataTransfer.files)},[k]),L=()=>{var R;(R=A.current)==null||R.click()},B=R=>{E(null);const f=y.filter((O,q)=>q!==R);d==null||d(f)},U=s||v,X=y.length>0;return e.jsxs("div",{className:Se("metakyc-file-upload",p),style:{width:"100%"},children:[t&&e.jsxs("div",{style:{marginBottom:"8px"},children:[e.jsxs("label",{style:{display:"block",fontSize:"14px",fontWeight:600,color:"var(--metakyc-text-primary, #111827)"},children:[t,c&&e.jsx("span",{style:{color:"var(--metakyc-danger, #ef4444)",marginLeft:"2px"},children:"*"})]}),r&&e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-text-muted, #9ca3af)",marginTop:"2px"},children:r})]}),e.jsxs("div",{className:"metakyc-file-dropzone",onClick:L,onDragOver:S,onDragLeave:D,onDrop:Y,style:{border:`2px dashed ${U?"var(--metakyc-danger, #ef4444)":b?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #d1d5db)"}`,borderRadius:"12px",padding:X?"20px":"32px 20px",textAlign:"center",cursor:"pointer",transition:"all 0.2s ease",backgroundColor:b?"color-mix(in srgb, var(--metakyc-primary, #2563eb) 5%, var(--metakyc-background, #ffffff))":"var(--metakyc-background, #ffffff)"},children:[e.jsx("input",{ref:A,type:"file",style:{display:"none"},accept:n,multiple:a,onChange:R=>{k(R.target.files),R.target.value=""}}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"12px"},children:[e.jsx("div",{style:{width:"48px",height:"48px",borderRadius:"12px",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:b?"color-mix(in srgb, var(--metakyc-primary, #2563eb) 15%, transparent)":"var(--metakyc-surface, #f9fafb)",transition:"background-color 0.2s ease"},children:e.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:b?"var(--metakyc-primary, #2563eb)":"var(--metakyc-text-muted, #9ca3af)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{transition:"stroke 0.2s ease"},children:[e.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),e.jsx("polyline",{points:"17 8 12 3 7 8"}),e.jsx("line",{x1:"12",y1:"3",x2:"12",y2:"15"})]})}),e.jsxs("div",{children:[e.jsxs("p",{style:{fontSize:"14px",color:"var(--metakyc-text-secondary, #6b7280)",margin:0},children:[e.jsx("span",{style:{fontWeight:600,color:"var(--metakyc-primary, #2563eb)"},children:"Click to upload"})," ","or drag and drop"]}),(n||o)&&e.jsxs("p",{style:{fontSize:"12px",color:"var(--metakyc-text-muted, #9ca3af)",marginTop:"4px"},children:[n&&e.jsx("span",{children:n}),n&&o&&e.jsx("span",{children:" · "}),o&&e.jsxs("span",{children:["Max ",ut(o)]})]})]})]})]}),X&&e.jsx("div",{style:{marginTop:"12px",display:"flex",flexDirection:"column",gap:"8px"},children:y.map((R,f)=>{const O=ls(R),q=O==="image",Q=q?URL.createObjectURL(R):null;return e.jsxs("div",{className:"metakyc-file-item",style:{display:"flex",alignItems:"center",gap:"12px",padding:"10px 12px",borderRadius:"10px",backgroundColor:"var(--metakyc-surface, #f9fafb)",border:"1px solid var(--metakyc-border, #e5e7eb)",transition:"background-color 0.15s ease"},children:[e.jsx("div",{style:{width:"40px",height:"40px",borderRadius:"8px",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",backgroundColor:q?"transparent":"color-mix(in srgb, var(--metakyc-primary, #2563eb) 10%, transparent)"},children:q&&Q?e.jsx("img",{src:Q,alt:R.name,style:{width:"100%",height:"100%",objectFit:"cover",borderRadius:"8px"}}):O==="pdf"?e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"var(--metakyc-danger, #ef4444)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),e.jsx("polyline",{points:"14 2 14 8 20 8"}),e.jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),e.jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"}),e.jsx("polyline",{points:"10 9 9 9 8 9"})]}):e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"var(--metakyc-primary, #2563eb)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),e.jsx("polyline",{points:"14 2 14 8 20 8"})]})}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("p",{style:{fontSize:"13px",fontWeight:500,color:"var(--metakyc-text-primary, #111827)",margin:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:R.name}),e.jsx("p",{style:{fontSize:"12px",color:"var(--metakyc-text-muted, #9ca3af)",margin:0,marginTop:"2px"},children:ut(R.size)})]}),e.jsx("button",{type:"button",onClick:$=>{$.stopPropagation(),B(f)},style:{display:"flex",alignItems:"center",justifyContent:"center",width:"28px",height:"28px",borderRadius:"6px",border:"none",backgroundColor:"transparent",color:"var(--metakyc-text-muted, #9ca3af)",cursor:"pointer",flexShrink:0,transition:"all 0.15s ease",padding:0},onMouseEnter:$=>{$.currentTarget.style.backgroundColor="color-mix(in srgb, var(--metakyc-danger, #ef4444) 10%, transparent)",$.currentTarget.style.color="var(--metakyc-danger, #ef4444)"},onMouseLeave:$=>{$.currentTarget.style.backgroundColor="transparent",$.currentTarget.style.color="var(--metakyc-text-muted, #9ca3af)"},children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},`${R.name}-${f}`)})}),U&&e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-danger, #ef4444)",marginTop:"6px"},children:U})]})},Ar=i.forwardRef(({countryCode:t="+1",onCountryCodeChange:r,className:s,...n},a)=>e.jsxs("div",{className:"w-full",children:[n.label&&e.jsxs("label",{className:"block text-sm font-medium mb-1",style:{color:"var(--metakyc-text-primary, #374151)"},children:[n.label,n.required&&e.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:t,onChange:o=>r==null?void 0:r(o.target.value),className:Se("w-20 rounded-lg border px-3 py-2 text-sm","focus:outline-none focus:ring-2 focus:ring-offset-0"),style:{minHeight:"38px",backgroundColor:"var(--metakyc-input-bg, #ffffff)",color:"var(--metakyc-text-primary, #111827)",borderColor:"var(--metakyc-border, #d1d5db)"},placeholder:"+1"}),e.jsx(ye,{ref:a,type:"tel",className:Se("flex-1",s),...n,label:""})]}),n.error&&e.jsx("p",{className:"mt-1 text-sm text-danger-500",children:n.error})]}));Ar.displayName="PhoneInput";/**
52
+ `}class xr{constructor(r){pe(this,"currentTheme",Re);pe(this,"customStyleElement",null);pe(this,"inputStyleElement",null);pe(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 n;const s={primary:r.primary,"primary-hover":r.primaryHover,"primary-light":r.primaryLight,"primary-dark":r.primaryDark,secondary:r.secondary,"secondary-hover":r.secondaryHover,success:r.success,warning:r.warning,danger:r.danger,info:r.info,background:r.background,surface:r.surface,border:r.border,"text-primary":r.textPrimary,"text-secondary":r.textSecondary,"text-muted":r.textMuted,"input-bg":r.inputBg||r.background,"input-text":r.inputText||r.textPrimary,"input-border":r.inputBorder||r.border,"input-border-focus":r.inputBorderFocus||r.primary,"input-placeholder":r.inputPlaceholder||r.textMuted};Object.entries(s).forEach(([a,o])=>{o&&this.container.style.setProperty(`--metakyc-${a}`,o)}),this.injectInputColors(),(n=this.currentTheme.darkMode)!=null&&n.colors&&this.applyDarkModeColors(this.currentTheme.darkMode.colors)}applyDarkModeColors(r){Object.entries(r).forEach(([s,n])=>{if(n){const a=`--metakyc-dark-${this.kebabCase(s)}`;this.container.style.setProperty(a,n)}})}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,n])=>{this.container.style.setProperty(`--metakyc-font-size-${s}`,n)}),r.fontWeight&&Object.entries(r.fontWeight).forEach(([s,n])=>{this.container.style.setProperty(`--metakyc-font-weight-${s}`,n.toString())}))}applySpacing(r){r&&Object.entries(r).forEach(([s,n])=>{const a=`--metakyc-${this.kebabCase(s)}`;this.container.style.setProperty(a,n)})}injectInputColors(){this.inputStyleElement&&this.inputStyleElement.remove(),this.inputStyleElement=document.createElement("style"),this.inputStyleElement.id="metakyc-input-colors",this.inputStyleElement.textContent=Zr(),this.customStyleElement&&this.customStyleElement.parentNode?document.head.insertBefore(this.inputStyleElement,this.customStyleElement):document.head.appendChild(this.inputStyleElement)}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||Re.name,title:r.title||Re.title,logo:{...Re.logo,...r.logo},colors:{...Re.colors,...r.colors},typography:r.typography?{...Re.typography,...r.typography}:Re.typography,spacing:r.spacing?{...Re.spacing,...r.spacing}:Re.spacing,customCSS:r.customCSS,darkMode:r.darkMode?{colors:{...(s=Re.darkMode)==null?void 0:s.colors,...r.darkMode.colors}}:Re.darkMode,applicantFormVisibleFields:r.applicantFormVisibleFields,applicantFormRequiredFields:r.applicantFormRequiredFields,allowedLanguages:r.allowedLanguages,applicantFormPages:r.applicantFormPages,reviewPageFields:r.reviewPageFields,reviewPageDisabled:r.reviewPageDisabled,fieldLabelMode:r.fieldLabelMode,companyFormVisibleFields:r.companyFormVisibleFields,companyFormRequiredFields:r.companyFormRequiredFields,companyFormPages:r.companyFormPages,companyReviewPageFields:r.companyReviewPageFields}}getCurrentTheme(){return this.currentTheme}resetTheme(){this.applyTheme(Re)}cleanup(){this.inputStyleElement&&(this.inputStyleElement.remove(),this.inputStyleElement=null),this.customStyleElement&&(this.customStyleElement.remove(),this.customStyleElement=null)}kebabCase(r){return r.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}}const bt=i.createContext(null),Xr=({config:t,children:r})=>{const[s,n]=i.useState(null),a=i.useRef(!1),o=i.useRef(!1),c=i.useMemo(()=>{const y=new Kt(t),p=new qt(y),g=new Vt(y),T=new Yt(y),v=new Qt(y),E=new Gt(y),A=new Jt(y),k=new Zt(y),S=new Xt(y),D=new er(y),Y=new or(y),L=new xr;return{httpClient:y,applicantService:p,questionnaireService:g,uploadDocumentService:T,appropriatenessTestService:v,overviewService:E,riskScoringService:A,identityService:k,baseInformationService:S,investorCategorizationService:D,themeService:Y,themeManager:L}},[t]),d=i.useMemo(()=>({config:t,...c,currentTheme:s,createOrchestrator:()=>new ur(c.applicantService,c.questionnaireService,c.uploadDocumentService,c.appropriatenessTestService,c.overviewService,c.riskScoringService,c.identityService,c.investorCategorizationService)}),[t,c,s]);return i.useEffect(()=>((async()=>{if(a.current||o.current){console.log("[MetaKYC] Theme already loading or loaded, skipping...");return}a.current=!0;try{if(t.theme){console.log("[MetaKYC] Applying static theme from config"),c.themeManager.applyTheme(t.theme),n(c.themeManager.getCurrentTheme()),o.current=!0;return}console.log("[MetaKYC] Fetching theme from backend...");const p=await c.themeService.getThemeConfiguration();c.themeManager.applyTheme(p),n(c.themeManager.getCurrentTheme()),o.current=!0,console.log("[MetaKYC] Theme loaded and applied",p)}catch(p){console.warn("[MetaKYC] Failed to load theme, using default:",p),n(c.themeManager.getCurrentTheme()),o.current=!0}finally{a.current=!1}})(),()=>{c.themeManager.cleanup()}),[]),e.jsx(bt.Provider,{value:d,children:r})};function Ne(){const t=i.useContext(bt);if(!t)throw new Error("useMetaKYC must be used within a MetaKYCProvider");return t}async function hr(t){return new Promise((r,s)=>{const n=new FileReader;n.readAsDataURL(t),n.onload=()=>{const o=n.result.split(",")[1];r(o)},n.onerror=a=>s(a)})}function es(t,r){return t.size<=r}function ts(t,r){return r.split(",").map(n=>n.trim()).some(n=>{if(n.endsWith("/*")){const a=n.slice(0,-2);return t.type.startsWith(a)}return t.type===n})}function ut(t){if(t===0)return"0 Bytes";const r=1024,s=["Bytes","KB","MB","GB"],n=Math.floor(Math.log(t)/Math.log(r));return Math.round(t/Math.pow(r,n)*100)/100+" "+s[n]}function rs(t){return t}function Se(...t){return t.filter(Boolean).join(" ")}const at={APPLICANT_ID:"metakyc_applicant_id",WORKFLOW_STATE:"metakyc_workflow_state"};function fr(t){try{localStorage.setItem(at.APPLICANT_ID,t.toString())}catch(r){console.warn("Failed to save applicant ID to storage:",r)}}function gr(){try{const t=localStorage.getItem(at.APPLICANT_ID);return t?parseInt(t,10):null}catch(t){return console.warn("Failed to retrieve applicant ID from storage:",t),null}}function br(){try{localStorage.removeItem(at.APPLICANT_ID)}catch(t){console.warn("Failed to clear applicant ID from storage:",t)}}function vr(t){try{localStorage.setItem(at.WORKFLOW_STATE,JSON.stringify(t))}catch(r){console.warn("Failed to save workflow state to storage:",r)}}function ss(){try{const t=localStorage.getItem(at.WORKFLOW_STATE);return t?JSON.parse(t):null}catch(t){return console.warn("Failed to retrieve workflow state from storage:",t),null}}function kr(){try{localStorage.removeItem(at.WORKFLOW_STATE)}catch(t){console.warn("Failed to clear workflow state from storage:",t)}}function ns(){br(),kr()}function jr(t){const{createOrchestrator:r}=Ne(),[s,n]=i.useState(null),[a,o]=i.useState(!1),[c,d]=i.useState(null),y=i.useRef(null),p=t||gr();i.useEffect(()=>{y.current||(y.current=r())},[r]),i.useEffect(()=>{var L;s&&p&&(fr(p),vr({applicantId:p,currentStepOrder:(L=s.currentStep)==null?void 0:L.order,status:s.status,lastUpdated:new Date().toISOString(),workflowKey:s.workFlowKey,nextWorkflowKey:s.nextWorkflowKey}))},[s,p]);const g=i.useRef(!1),T=i.useRef(!1),v=i.useCallback(async()=>{if(!(!p||!y.current)){if(g.current){console.log("[Workflow] Load already in progress, skipping...");return}g.current=!0,o(!0),d(null);try{const L=await y.current.initialize(p);n(L),T.current=!0}catch(L){d(L)}finally{o(!1),g.current=!1}}},[p]);i.useEffect(()=>{p&&!T.current&&v()},[p,v]);const E=i.useCallback(async()=>{if(y.current){if(g.current){console.log("[Workflow] Refresh already in progress, skipping...");return}g.current=!0,o(!0),d(null);try{const L=await y.current.refreshProgress();n(L)}catch(L){d(L)}finally{o(!1),g.current=!1}}},[]),A=i.useCallback(async()=>{if(y.current){o(!0),d(null);try{const L=await y.current.moveToNextStep();n(L)}catch(L){d(L)}finally{o(!1)}}},[]),k=i.useCallback(async()=>{if(y.current){o(!0),d(null);try{const L=await y.current.moveToPreviousStep();n(L)}catch(L){d(L)}finally{o(!1)}}},[]),S=i.useCallback(async L=>{if(y.current){o(!0),d(null);try{await y.current.submitCurrentStep(L);const B=await y.current.refreshProgress();n(B)}catch(B){throw d(B),B}finally{o(!1)}}},[]),D=wt.useMemo(()=>s!=null&&s.stepInfoList?[...s.stepInfoList].sort((L,B)=>L.order-B.order):[],[s==null?void 0:s.stepInfoList]),Y=wt.useMemo(()=>s?s.nextWorkflowKey&&s.nextWorkflowKey!==s.workFlowKey:!1,[s]);return{progress:s,applicantId:p,currentStep:(s==null?void 0:s.currentStep)||null,steps:D,status:(s==null?void 0:s.status)||Te.None,workflowResult:(s==null?void 0:s.workflowResult)||null,workflowKey:s==null?void 0:s.workFlowKey,nextWorkflowKey:s==null?void 0:s.nextWorkflowKey,hasWorkflowChanged:Y,isLoading:a,error:c,isComplete:(s==null?void 0:s.status)===Te.Finished,isOnHold:(s==null?void 0:s.status)===Te.OnHold,refreshProgress:E,moveToNext:A,moveBack:k,submitCurrentStep:S,orchestrator:y.current}}function wr(t){const{questionnaireService:r,applicantService:s}=Ne(),[n,a]=i.useState(null),[o,c]=i.useState({}),[d,y]=i.useState(!1),[p,g]=i.useState(!1),[T,v]=i.useState(null),E=i.useRef(!1),A=i.useRef(null),k=i.useCallback(async()=>{var D,Y;if(t){if(E.current){console.log("[Questionnaire] Load already in progress, skipping...");return}E.current=!0,y(!0),v(null);try{const[L,B]=await Promise.all([r.getQuestionnaire(t),s.getApplicantData(t).catch(()=>null)]);if(a(L),(D=B==null?void 0:B.questionnaireResults)!=null&&D.length&&L){const U=new Map;for(const f of B.questionnaireResults)f.question&&((Y=f.answers)!=null&&Y.length)&&U.set(f.question.trim().toLowerCase(),f.answers);const X={},R=L.questionGroups.flatMap(f=>f.questions??[]);for(const f of R){const O=f.text.trim().toLowerCase();U.has(O)&&(X[f.id]=U.get(O))}c(X)}A.current=t}catch(L){v(L)}finally{y(!1),E.current=!1}}},[t,r,s]);i.useEffect(()=>{t&&A.current!==t&&k()},[t]);const S=i.useCallback(async D=>{g(!0),v(null);try{return await r.fillQuestionnaire(D)}catch(Y){throw v(Y),Y}finally{g(!1)}},[r]);return{questionnaire:n,initialAnswers:o,isLoading:d,isSubmitting:p,error:T,load:k,submit:S}}function Sr(t){const{uploadDocumentService:r}=Ne(),[s,n]=i.useState(null),[a,o]=i.useState(!1),[c,d]=i.useState(!1),[y,p]=i.useState(0),[g,T]=i.useState(null),v=i.useRef(!1),E=i.useRef(null),A=i.useCallback(async()=>{if(t){if(v.current){console.log("[UploadDocument] Load already in progress, skipping...");return}v.current=!0,o(!0),T(null);try{const S=await r.getUploadDocument(t);n(S),E.current=t}catch(S){T(S)}finally{o(!1),v.current=!1}}},[t,r]);i.useEffect(()=>{t&&E.current!==t&&A()},[t]);const k=i.useCallback(async S=>{d(!0),p(0),T(null);try{await r.fillUploadDocument(S),p(100)}catch(D){throw T(D),D}finally{d(!1)}},[r]);return{uploadDocument:s,isLoading:a,isSubmitting:c,uploadProgress:y,error:g,load:A,submit:k}}function as(t){const{appropriatenessTestService:r}=Ne(),[s,n]=i.useState(null),[a,o]=i.useState(!1),[c,d]=i.useState(!1),[y,p]=i.useState(null),[g,T]=i.useState(null),v=i.useRef(!1),E=i.useRef(null),A=i.useCallback(async()=>{if(t){if(v.current){console.log("[AppropriatenessTest] Load already in progress, skipping...");return}v.current=!0,o(!0),p(null);try{const S=await r.getAppropriatenessTest(t);n(S),E.current=t}catch(S){p(S)}finally{o(!1),v.current=!1}}},[t,r]);i.useEffect(()=>{t&&E.current!==t&&A()},[t]);const k=i.useCallback(async S=>{d(!0),p(null);try{const D=await r.fillAppropriatenessTest(S);return T(D),D}catch(D){throw p(D),D}finally{d(!1)}},[r]);return{test:s,result:g,isLoading:a,isSubmitting:c,error:y,load:A,submit:k}}function Cr(t){const{overviewService:r}=Ne(),[s,n]=i.useState(null),[a,o]=i.useState(!1),[c,d]=i.useState(!1),[y,p]=i.useState(null),g=i.useRef(!1),T=i.useRef(null),v=i.useCallback(async()=>{if(t){if(g.current){console.log("[Overview] Load already in progress, skipping...");return}g.current=!0,o(!0),p(null);try{const A=await r.getOverviewData(t);n(A),T.current=t}catch(A){p(A)}finally{o(!1),g.current=!1}}},[t,r]);i.useEffect(()=>{t&&T.current!==t&&v()},[t]);const E=i.useCallback(async()=>{if(t){d(!0),p(null);try{await r.passOverview(t)}catch(A){throw p(A),A}finally{d(!1)}}},[t,r]);return{overview:s,isLoading:a,isSubmitting:c,error:y,load:v,passOverview:E}}function Nr(t){const{identityService:r}=Ne(),[s,n]=i.useState(null),[a,o]=i.useState(!1),[c,d]=i.useState(null),y=i.useRef(!1),p=i.useCallback(async(v,E)=>{if(t){if(y.current){console.log("[Identity] Request already in progress, skipping...");return}y.current=!0,o(!0),d(null);try{const A={applicantId:t,restart:!1,redirectUrl:v||"",ttl:E||604800};console.log("Identity request input:",A);const k=await r.identityRequest(A);return console.log("Identity request result:",k),n(k),k}catch(A){throw d(A),A}finally{o(!1),y.current=!1}}},[t,r]),g=i.useCallback(async(v,E)=>{if(t){o(!0),d(null);try{const A={applicantId:t,restart:!1,redirectUrl:v,ttl:E},k=await r.identityCompanyRequest(A);return n(k),k}catch(A){throw d(A),A}finally{o(!1)}}},[t,r]),T=i.useCallback(async()=>{if(t){if(y.current){console.log("[Identity] Restart already in progress, skipping...");return}y.current=!0,o(!0),d(null);try{const v={applicantId:t,restart:!0,redirectUrl:"",ttl:604800};console.log("Restarting identity with input:",v);const E=await r.identityRequest(v);return console.log("Restart identity result:",E),n(E),E}catch(v){throw d(v),v}finally{o(!1),y.current=!1}}},[t,r]);return{identityData:s,provider:(s==null?void 0:s.provider)||null,token:(s==null?void 0:s.publicProviderTokenObject)||null,isLoading:a,error:c,requestIdentity:p,requestCompanyIdentity:g,restartIdentity:T}}function Rr(t){const{riskScoringService:r,applicantService:s}=Ne(),[n,a]=i.useState(null),[o,c]=i.useState({}),[d,y]=i.useState(!1),[p,g]=i.useState(!1),[T,v]=i.useState(null),[E,A]=i.useState(null),k=i.useRef(!1),S=i.useRef(null),D=i.useCallback(async()=>{var L;if(t){if(k.current){console.log("[RiskScoring] Load already in progress, skipping...");return}k.current=!0,y(!0),v(null);try{const[B,U]=await Promise.all([r.getRiskCriterias(t),s.getApplicantData(t).catch(()=>null)]);if(a(B),(L=U==null?void 0:U.riskScoringResults)!=null&&L.length){const X=U.riskScoringResults[0],R={};for(const f of X.riskCriteriaResults??[])if(f.riskCriteriaId!=null&&f.answer!=null&&f.answer!==""){const O=[...new Set(f.answer.split(",").map(q=>q.trim()).filter(q=>q!==""))];O.length>0&&(R[f.riskCriteriaId]=O)}c(R)}S.current=t}catch(B){v(B)}finally{y(!1),k.current=!1}}},[t,r,s]);i.useEffect(()=>{t&&S.current!==t&&D()},[t]);const Y=i.useCallback(async L=>{g(!0),v(null);try{const B=await r.submitRiskScoring(L);return A(B),B}catch(B){throw v(B),B}finally{g(!1)}},[r]);return{criteria:n,initialAnswers:o,result:E,isLoading:d,isSubmitting:p,error:T,load:D,submit:Y}}function vt(){const{applicantService:t,config:r}=Ne(),[s,n]=i.useState(!1),[a,o]=i.useState(null),c=i.useRef(!1),d=i.useRef(!1),y=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(E){const A=Math.random()*16|0;return(E==="x"?A:A&3|8).toString(16)}),p=i.useCallback(async E=>{var A;if(c.current)throw console.log("[Applicant] Create already in progress, skipping..."),new Error("Creation already in progress");c.current=!0,n(!0),o(null);try{if(E.applicantAdditionalDatas||(E.applicantAdditionalDatas=[]),(A=r.identityProviders)!=null&&A.sardinai){const S=y();console.log("[SardinAI] Generated session key:",S),E.applicantAdditionalDatas.push({paramName:"sessionKey",value:S})}return await t.createApplicant(E)}catch(k){throw o(k),k}finally{n(!1),c.current=!1}},[t,r]),g=i.useCallback(async E=>{n(!0),o(null);try{return await t.createCompanyApplicant(E)}catch(A){throw o(A),A}finally{n(!1)}},[t]),T=i.useCallback(async E=>{if(d.current)throw console.log("[Applicant] Data load already in progress, skipping..."),new Error("Data load already in progress");d.current=!0,n(!0),o(null);try{return await t.getApplicantData(E)}catch(A){throw o(A),A}finally{n(!1),d.current=!1}},[t]),v=i.useCallback(async E=>{n(!0),o(null);try{await t.stopProgress(E)}catch(A){throw o(A),A}finally{n(!1)}},[t]);return{isLoading:s,error:a,createApplicant:p,createCompanyApplicant:g,getApplicantData:T,stopProgress:v}}const is={primary:{backgroundColor:"var(--metakyc-primary, #2563eb)",color:"#ffffff",borderColor:"transparent"},secondary:{backgroundColor:"var(--metakyc-surface, #f3f4f6)",color:"var(--metakyc-text-primary, #111827)",borderColor:"var(--metakyc-border, #e5e7eb)"},outline:{backgroundColor:"transparent",color:"var(--metakyc-primary, #2563eb)",borderColor:"var(--metakyc-primary, #2563eb)"},danger:{backgroundColor:"var(--metakyc-danger, #ef4444)",color:"#ffffff",borderColor:"transparent"},ghost:{backgroundColor:"transparent",color:"var(--metakyc-text-secondary, #6b7280)",borderColor:"transparent"}},J=({children:t,variant:r="primary",size:s="md",isLoading:n=!1,disabled:a,className:o,style:c,...d})=>{const y="inline-flex items-center justify-center rounded-lg font-medium transition-opacity border focus:outline-none focus:ring-2 focus:ring-offset-1 disabled:opacity-50 disabled:cursor-not-allowed",p={sm:"px-3 py-1.5 text-sm",md:"px-4 py-2 text-sm",lg:"px-6 py-3 text-base"},g={sm:{padding:"0.375rem 0.75rem",fontSize:"0.875rem"},md:{padding:"0.5rem 1rem",fontSize:"0.875rem"},lg:{padding:"0.75rem 1.5rem",fontSize:"1rem"}};return e.jsxs("button",{className:Se(y,p[s],o),style:{display:"inline-flex",alignItems:"center",justifyContent:"center",borderRadius:"0.5rem",fontWeight:500,borderWidth:"1px",borderStyle:"solid",cursor:a||n?"not-allowed":"pointer",opacity:a||n?.5:1,lineHeight:"1.25rem",...g[s],...is[r],...c},disabled:a||n,...d,children:[n&&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]})},ye=i.forwardRef(({label:t,error:r,helperText:s,leftIcon:n,rightIcon:a,className:o,style:c,...d},y)=>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:[n&&e.jsx("div",{className:"absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none",children:n}),e.jsx("input",{ref:y,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",n?"pl-10":"",a?"pr-10":"",o),style:{minHeight:"38px",backgroundColor:d.readOnly?"var(--metakyc-surface, #f3f4f6)":"var(--metakyc-input-bg, #ffffff)",color:"var(--metakyc-input-text, var(--metakyc-text-primary, #111827))",borderColor:r?"var(--metakyc-danger, #ef4444)":"var(--metakyc-input-border, var(--metakyc-border, #d1d5db))",cursor:d.readOnly?"default":void 0,...c},...d}),a&&e.jsx("div",{className:"absolute inset-y-0 right-0 pr-3 flex items-center pointer-events-none",children:a})]}),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})]}));ye.displayName="Input";const ee=({children:t,className:r,style:s,...n})=>e.jsx("div",{className:Se("metakyc-card rounded-xl shadow-sm border",r),style:{backgroundColor:"var(--metakyc-surface, #ffffff)",borderColor:"var(--metakyc-border, #e5e7eb)",borderWidth:"1px",borderStyle:"solid",borderRadius:"0.75rem",overflow:"hidden",...s},...n,children:t}),ge=({children:t,className:r,style:s,...n})=>e.jsx("div",{className:Se("px-6 py-4 border-b",r),style:{padding:"1rem 1.5rem",borderBottomWidth:"1px",borderBottomStyle:"solid",borderBottomColor:"var(--metakyc-border, #e5e7eb)",...s},...n,children:t}),te=({children:t,className:r,style:s,...n})=>e.jsx("div",{className:Se("px-6 py-4",r),style:{padding:"1rem 1.5rem",...s},...n,children:t}),be=({children:t,className:r,style:s,...n})=>e.jsx("div",{className:Se("px-6 py-4 border-t",r),style:{padding:"1rem 1.5rem",borderTopWidth:"1px",borderTopStyle:"solid",borderTopColor:"var(--metakyc-border, #e5e7eb)",...s},...n,children:t}),os={default:{backgroundColor:"var(--metakyc-surface, #f3f4f6)",color:"var(--metakyc-text-secondary, #6b7280)"},info:{backgroundColor:"var(--metakyc-primary-light, #dbeafe)",color:"var(--metakyc-primary, #2563eb)"},success:{backgroundColor:"#d1fae5",color:"#065f46"},danger:{backgroundColor:"#fee2e2",color:"#991b1b"},warning:{backgroundColor:"#fef3c7",color:"#92400e"}},kt=({children:t,variant:r="default",className:s,style:n,...a})=>e.jsx("span",{className:Se("inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium",s),style:{...os[r],...n},...a,children:t}),Ee=({size:t="md",className:r,...s})=>{const n={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",n[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"})]})})},mt=i.forwardRef(({label:t,error:r,helperText:s,options:n,placeholder:a,className:o,style:c,...d},y)=>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:y,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":"",o),style:{minHeight:"38px",backgroundColor:"var(--metakyc-input-bg, #ffffff)",color:"var(--metakyc-input-text, var(--metakyc-text-primary, #111827))",borderColor:r?"var(--metakyc-danger, #ef4444)":"var(--metakyc-input-border, var(--metakyc-border, #d1d5db))",...c},...d,children:[a&&e.jsx("option",{value:"",disabled:!0,style:{backgroundColor:"var(--metakyc-input-bg, #ffffff)",color:"var(--metakyc-text-secondary, #6b7280)"},children:a},"__placeholder__"),n.map((p,g)=>e.jsx("option",{value:p.value,disabled:p.disabled,style:{backgroundColor:"var(--metakyc-input-bg, #ffffff)",color:p.disabled?"var(--metakyc-text-muted, #9ca3af)":"var(--metakyc-input-text, var(--metakyc-text-primary, #111827))"},children:p.label},p.value||`option-${g}`))]}),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})]}));mt.displayName="Select";const St=280,Ir=({label:t,value:r,onChange:s,options:n,placeholder:a="Select...",disabled:o=!1,readOnly:c=!1,required:d=!1})=>{const y=o||c,[p,g]=i.useState(!1),[T,v]=i.useState(""),[E,A]=i.useState(null),[k,S]=i.useState({bg:"#ffffff",borderColor:"#d1d5db",textPrimary:"#111827",textSecondary:"#6b7280",primaryColor:"#2563eb",primaryLight:"#eff6ff",hoverBg:"#f9fafb"}),D=i.useRef(null),Y=i.useRef(null),L=i.useRef(null),B=i.useCallback(()=>{if(!Y.current)return null;const I=Y.current.getBoundingClientRect(),z=window.innerHeight-I.bottom<St&&I.top>St;return{top:z?I.top:I.bottom+4,left:I.left,width:I.width,openUp:z}},[]),U=i.useCallback(()=>{const I=getComputedStyle(document.documentElement),W=(_,me)=>I.getPropertyValue(_).trim()||me,z=W("--metakyc-input-bg",W("--metakyc-background","#ffffff"));S({bg:z,borderColor:W("--metakyc-input-border",W("--metakyc-border","#d1d5db")),textPrimary:W("--metakyc-input-text",W("--metakyc-text-primary","#111827")),textSecondary:W("--metakyc-text-secondary","#6b7280"),primaryColor:W("--metakyc-primary","#2563eb"),primaryLight:W("--metakyc-primary-light","#eff6ff"),hoverBg:W("--metakyc-surface",z)})},[]),X=i.useCallback(()=>{if(y)return;U();const I=B();I&&A(I),g(!0)},[y,B,U]),R=i.useCallback(()=>{g(!1),v("")},[]);i.useEffect(()=>{if(!p)return;const I=W=>{var _,me;const z=W.target;!((_=D.current)!=null&&_.contains(z))&&!((me=L.current)!=null&&me.contains(z))&&R()};return document.addEventListener("mousedown",I),()=>document.removeEventListener("mousedown",I)},[p,R]),i.useEffect(()=>{if(!p)return;const I=()=>{const W=B();W&&A(W)};return window.addEventListener("scroll",I,!0),window.addEventListener("resize",I),()=>{window.removeEventListener("scroll",I,!0),window.removeEventListener("resize",I)}},[p,B]);const f=n.filter(I=>I.label.toLowerCase().includes(T.toLowerCase())),O=I=>{y||s(r.includes(I)?r.filter(W=>W!==I):[...r,I])},q=(I,W)=>{W.stopPropagation(),y||s(r.filter(z=>z!==I))},Q=I=>{var W;return((W=n.find(z=>z.value===I))==null?void 0:W.label)||I},{bg:$,borderColor:G,textPrimary:se,textSecondary:V,primaryColor:he,primaryLight:ce,hoverBg:de}=k,fe=p&&E&&e.jsxs("div",{ref:L,className:"metakyc-multiselect-dropdown",style:{position:"fixed",top:E.openUp?void 0:E.top,bottom:E.openUp?window.innerHeight-E.top+4:void 0,left:E.left,width:E.width,zIndex:99999,borderRadius:"8px",boxShadow:"0 4px 16px rgba(0,0,0,0.18)",border:`1px solid ${G}`,backgroundColor:$,overflow:"hidden"},children:[e.jsx("div",{style:{padding:"8px",borderBottom:`1px solid ${G}`},children:e.jsx("input",{type:"text",value:T,onChange:I=>v(I.target.value),placeholder:"Search...",autoFocus:!0,onClick:I=>I.stopPropagation(),className:"metakyc-multiselect-search w-full",style:{display:"block",width:"100%",padding:"6px 8px",fontSize:"13px",borderRadius:"6px",border:`1px solid ${G}`,backgroundColor:$,color:se,outline:"none",boxSizing:"border-box"},onFocus:I=>{const W=getComputedStyle(document.documentElement),z=W.getPropertyValue("--metakyc-input-border-focus").trim()||W.getPropertyValue("--metakyc-primary").trim()||"#2563eb";I.currentTarget.style.backgroundColor=$,I.currentTarget.style.color=se,I.currentTarget.style.borderColor=z,I.currentTarget.style.outline="none",I.currentTarget.style.boxShadow=`0 0 0 2px ${z}33`},onBlur:I=>{I.currentTarget.style.backgroundColor=$,I.currentTarget.style.color=se,I.currentTarget.style.borderColor=G,I.currentTarget.style.outline="none",I.currentTarget.style.boxShadow="none"}})}),e.jsx("ul",{style:{listStyle:"none",margin:0,padding:"4px 0",maxHeight:"192px",overflowY:"auto"},children:f.length===0?e.jsx("li",{style:{padding:"8px 12px",fontSize:"13px",color:V},children:"No results"}):f.map(I=>{const W=r.includes(I.value);return e.jsxs("li",{onClick:()=>O(I.value),className:"metakyc-multiselect-option",style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",fontSize:"13px",cursor:"pointer",backgroundColor:W?ce:"transparent",color:W?he:se,userSelect:"none"},onMouseEnter:z=>{W||(z.currentTarget.style.backgroundColor=de)},onMouseLeave:z=>{W||(z.currentTarget.style.backgroundColor="transparent")},children:[e.jsx("input",{type:"checkbox",checked:W,readOnly:!0,style:{accentColor:he,pointerEvents:"none",flexShrink:0}}),e.jsx("span",{children:I.label})]},I.value)})}),r.length>0&&e.jsx("div",{style:{padding:"6px 12px",borderTop:`1px solid ${G}`},children:e.jsxs("button",{type:"button",onClick:()=>{s([]),v("")},style:{fontSize:"12px",color:"#ef4444",background:"none",border:"none",cursor:"pointer",padding:0},children:["Clear all (",r.length," selected)"]})})]});return e.jsxs("div",{className:"w-full metakyc-multiselect",ref:D,children:[t&&e.jsxs("label",{className:"block text-sm font-medium mb-1",style:{color:"var(--metakyc-text-primary, #374151)"},children:[t,d&&e.jsx("span",{style:{color:"var(--metakyc-error, #ef4444)",marginLeft:"4px"},children:"*"})]}),e.jsxs("div",{ref:Y,onClick:()=>p?R():X(),className:Se("metakyc-multiselect-trigger","w-full px-3 py-2 rounded-lg border text-sm transition-colors relative",y?"opacity-50 cursor-not-allowed":"cursor-pointer"),style:{minHeight:"38px",backgroundColor:"var(--metakyc-input-bg, #ffffff)",borderColor:p?"var(--metakyc-input-border-focus, var(--metakyc-primary, #2563eb))":"var(--metakyc-input-border, var(--metakyc-border, #d1d5db))",outline:p?"2px solid var(--metakyc-input-border-focus, var(--metakyc-primary, #2563eb))":"none",outlineOffset:"-1px"},children:[r.length===0?e.jsx("span",{className:"metakyc-multiselect-placeholder leading-6",style:{color:"var(--metakyc-text-secondary, #9ca3af)"},children:a}):e.jsx("div",{className:"flex flex-wrap gap-1 pr-6",children:r.map(I=>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:[Q(I),!y&&e.jsx("button",{type:"button",onClick:W=>q(I,W),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:"×"})]},I))}),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:p?"▲":"▼"})]}),typeof document<"u"&&fe?pt.createPortal(fe,document.body):null]})},Ct=260,De=({label:t,error:r,helperText:s,options:n,placeholder:a="Select...",value:o,onChange:c,disabled:d=!1,readOnly:y=!1,required:p=!1,className:g})=>{var me;const T=d||y,[v,E]=i.useState(!1),[A,k]=i.useState(""),[S,D]=i.useState(null),[Y,L]=i.useState({bg:"#ffffff",border:"#d1d5db",text:"#111827",textSecondary:"#6b7280",primary:"#2563eb",primaryLight:"#eff6ff",hoverBg:"#f9fafb"}),B=i.useCallback(()=>{const N=getComputedStyle(document.documentElement),re=(ne,ve)=>N.getPropertyValue(ne).trim()||ve,ue=re("--metakyc-input-bg",re("--metakyc-background","#ffffff"));L({bg:ue,border:re("--metakyc-input-border",re("--metakyc-border","#d1d5db")),text:re("--metakyc-input-text",re("--metakyc-text-primary","#111827")),textSecondary:re("--metakyc-text-secondary","#6b7280"),primary:re("--metakyc-primary","#2563eb"),primaryLight:re("--metakyc-primary-light","#eff6ff"),hoverBg:re("--metakyc-surface",ue)})},[]),U=i.useRef(null),X=i.useRef(null),R=i.useRef(null),f=i.useRef(null),O=i.useCallback(()=>{if(!X.current)return null;const N=X.current.getBoundingClientRect(),ue=window.innerHeight-N.bottom<Ct&&N.top>Ct;return{top:ue?N.top:N.bottom+4,left:N.left,width:N.width,openUp:ue}},[]),q=i.useCallback(()=>{if(T)return;B();const N=O();N&&D(N),E(!0)},[T,O,B]),Q=i.useCallback(()=>{E(!1),k("")},[]),$=()=>v?Q():q();i.useEffect(()=>{if(!v)return;const N=re=>{var ne,ve;const ue=re.target;!((ne=U.current)!=null&&ne.contains(ue))&&!((ve=R.current)!=null&&ve.contains(ue))&&Q()};return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[v,Q]),i.useEffect(()=>{if(!v)return;const N=()=>{const re=O();re&&D(re)};return window.addEventListener("scroll",N,!0),window.addEventListener("resize",N),()=>{window.removeEventListener("scroll",N,!0),window.removeEventListener("resize",N)}},[v,O]),i.useEffect(()=>{v&&f.current&&setTimeout(()=>{var N;return(N=f.current)==null?void 0:N.focus()},0)},[v]);const G=n.filter(N=>N.label.toLowerCase().includes(A.toLowerCase())||N.value.toLowerCase().includes(A.toLowerCase())),se=(me=n.find(N=>N.value===o))==null?void 0:me.label,V=(N,re)=>{T||re||(c(N),Q())},{bg:he,border:ce,text:de,textSecondary:fe,primary:I,primaryLight:W,hoverBg:z}=Y,_=v&&S&&e.jsxs("div",{ref:R,className:"metakyc-searchable-select-dropdown",style:{position:"fixed",top:S.openUp?void 0:S.top,bottom:S.openUp?window.innerHeight-S.top+4:void 0,left:S.left,width:S.width,zIndex:99999,borderRadius:"8px",boxShadow:"0 4px 16px rgba(0,0,0,0.18)",border:`1px solid ${ce}`,backgroundColor:he,overflow:"hidden"},children:[e.jsx("div",{style:{padding:"8px",borderBottom:`1px solid ${ce}`},children:e.jsx("input",{ref:f,type:"text",value:A,onChange:N=>k(N.target.value),placeholder:"Search...",onClick:N=>N.stopPropagation(),className:"metakyc-searchable-select-search w-full",style:{display:"block",width:"100%",padding:"6px 8px",fontSize:"13px",borderRadius:"6px",border:`1px solid ${ce}`,backgroundColor:he,color:de,outline:"none",boxSizing:"border-box"},onFocus:N=>{const re=getComputedStyle(document.documentElement),ue=re.getPropertyValue("--metakyc-input-border-focus").trim()||re.getPropertyValue("--metakyc-primary").trim()||"#2563eb";N.currentTarget.style.backgroundColor=he,N.currentTarget.style.color=de,N.currentTarget.style.borderColor=ue,N.currentTarget.style.outline="none",N.currentTarget.style.boxShadow=`0 0 0 2px ${ue}33`},onBlur:N=>{N.currentTarget.style.backgroundColor=he,N.currentTarget.style.color=de,N.currentTarget.style.borderColor=ce,N.currentTarget.style.outline="none",N.currentTarget.style.boxShadow="none"}})}),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:fe},children:"No results"}):G.map(N=>{const re=N.value===o;return e.jsx("li",{className:"metakyc-searchable-select-option",onClick:()=>V(N.value,N.disabled),style:{padding:"8px 12px",fontSize:"13px",cursor:N.disabled?"not-allowed":"pointer",opacity:N.disabled?.4:1,backgroundColor:re?W:"transparent",color:re?I:de,userSelect:"none"},onMouseEnter:ue=>{!re&&!N.disabled&&(ue.currentTarget.style.backgroundColor=z)},onMouseLeave:ue=>{re||(ue.currentTarget.style.backgroundColor="transparent")},children:N.label},N.value)})})]});return e.jsxs("div",{className:Se("w-full metakyc-searchable-select",g),ref:U,children:[t&&e.jsxs("label",{className:"block text-sm font-medium mb-1",style:{color:"var(--metakyc-text-primary, #374151)"},children:[t,p&&e.jsx("span",{style:{color:"var(--metakyc-error, #ef4444)",marginLeft:"4px"},children:"*"})]}),e.jsxs("div",{ref:X,role:"button",tabIndex:T?-1:0,onClick:$,onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),$()),N.key==="Escape"&&Q()},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",T?"opacity-60 cursor-not-allowed":"cursor-pointer"),style:{backgroundColor:"var(--metakyc-input-bg, #ffffff)",color:se?"var(--metakyc-input-text, var(--metakyc-text-primary, #111827))":"var(--metakyc-input-placeholder, var(--metakyc-text-muted, #9ca3af))",borderColor:r?"var(--metakyc-danger, #ef4444)":v?"var(--metakyc-input-border-focus, var(--metakyc-primary, #2563eb))":"var(--metakyc-input-border, var(--metakyc-border, #d1d5db))",minHeight:"38px",outline:v?"2px solid var(--metakyc-input-border-focus, var(--metakyc-primary, #2563eb))":"none",outlineOffset:"-1px"},children:[e.jsx("span",{className:"truncate flex-1",children:se||a}),e.jsx("span",{className:"flex-shrink-0 text-xs pointer-events-none",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:v?"▲":"▼"})]}),typeof document<"u"&&_?pt.createPortal(_,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})]})};De.displayName="SearchableSelect";function ls(t){const r=t.type;return r.startsWith("image/")?"image":r==="application/pdf"?"pdf":"file"}const Er=({label:t,subtitle:r,error:s,accept:n,multiple:a=!1,maxSize:o,required:c,onChange:d,value:y=[],className:p})=>{const[g,T]=i.useState(!1),[v,E]=i.useState(null),A=i.useRef(null),k=i.useCallback(R=>{if(!R)return;E(null);const f=Array.from(R);if(o&&f.filter(q=>q.size>o).length>0){E(`File exceeds the maximum size of ${ut(o)}`);return}d==null||d(a?[...y,...f]:[f[0]])},[o,a,d,y]),S=i.useCallback(R=>{R.preventDefault(),R.stopPropagation(),T(!0)},[]),D=i.useCallback(R=>{R.preventDefault(),R.stopPropagation(),T(!1)},[]),Y=i.useCallback(R=>{R.preventDefault(),R.stopPropagation(),T(!1),k(R.dataTransfer.files)},[k]),L=()=>{var R;(R=A.current)==null||R.click()},B=R=>{E(null);const f=y.filter((O,q)=>q!==R);d==null||d(f)},U=s||v,X=y.length>0;return e.jsxs("div",{className:Se("metakyc-file-upload",p),style:{width:"100%"},children:[t&&e.jsxs("div",{style:{marginBottom:"8px"},children:[e.jsxs("label",{style:{display:"block",fontSize:"14px",fontWeight:600,color:"var(--metakyc-text-primary, #111827)"},children:[t,c&&e.jsx("span",{style:{color:"var(--metakyc-danger, #ef4444)",marginLeft:"2px"},children:"*"})]}),r&&e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-text-muted, #9ca3af)",marginTop:"2px"},children:r})]}),e.jsxs("div",{className:"metakyc-file-dropzone",onClick:L,onDragOver:S,onDragLeave:D,onDrop:Y,style:{border:`2px dashed ${U?"var(--metakyc-danger, #ef4444)":g?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #d1d5db)"}`,borderRadius:"12px",padding:X?"20px":"32px 20px",textAlign:"center",cursor:"pointer",transition:"all 0.2s ease",backgroundColor:g?"color-mix(in srgb, var(--metakyc-primary, #2563eb) 5%, var(--metakyc-background, #ffffff))":"var(--metakyc-background, #ffffff)"},children:[e.jsx("input",{ref:A,type:"file",style:{display:"none"},accept:n,multiple:a,onChange:R=>{k(R.target.files),R.target.value=""}}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"12px"},children:[e.jsx("div",{style:{width:"48px",height:"48px",borderRadius:"12px",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:g?"color-mix(in srgb, var(--metakyc-primary, #2563eb) 15%, transparent)":"var(--metakyc-surface, #f9fafb)",transition:"background-color 0.2s ease"},children:e.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:g?"var(--metakyc-primary, #2563eb)":"var(--metakyc-text-muted, #9ca3af)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{transition:"stroke 0.2s ease"},children:[e.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),e.jsx("polyline",{points:"17 8 12 3 7 8"}),e.jsx("line",{x1:"12",y1:"3",x2:"12",y2:"15"})]})}),e.jsxs("div",{children:[e.jsxs("p",{style:{fontSize:"14px",color:"var(--metakyc-text-secondary, #6b7280)",margin:0},children:[e.jsx("span",{style:{fontWeight:600,color:"var(--metakyc-primary, #2563eb)"},children:"Click to upload"})," ","or drag and drop"]}),(n||o)&&e.jsxs("p",{style:{fontSize:"12px",color:"var(--metakyc-text-muted, #9ca3af)",marginTop:"4px"},children:[n&&e.jsx("span",{children:n}),n&&o&&e.jsx("span",{children:" · "}),o&&e.jsxs("span",{children:["Max ",ut(o)]})]})]})]})]}),X&&e.jsx("div",{style:{marginTop:"12px",display:"flex",flexDirection:"column",gap:"8px"},children:y.map((R,f)=>{const O=ls(R),q=O==="image",Q=q?URL.createObjectURL(R):null;return e.jsxs("div",{className:"metakyc-file-item",style:{display:"flex",alignItems:"center",gap:"12px",padding:"10px 12px",borderRadius:"10px",backgroundColor:"var(--metakyc-surface, #f9fafb)",border:"1px solid var(--metakyc-border, #e5e7eb)",transition:"background-color 0.15s ease"},children:[e.jsx("div",{style:{width:"40px",height:"40px",borderRadius:"8px",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",backgroundColor:q?"transparent":"color-mix(in srgb, var(--metakyc-primary, #2563eb) 10%, transparent)"},children:q&&Q?e.jsx("img",{src:Q,alt:R.name,style:{width:"100%",height:"100%",objectFit:"cover",borderRadius:"8px"}}):O==="pdf"?e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"var(--metakyc-danger, #ef4444)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),e.jsx("polyline",{points:"14 2 14 8 20 8"}),e.jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),e.jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"}),e.jsx("polyline",{points:"10 9 9 9 8 9"})]}):e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"var(--metakyc-primary, #2563eb)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),e.jsx("polyline",{points:"14 2 14 8 20 8"})]})}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("p",{style:{fontSize:"13px",fontWeight:500,color:"var(--metakyc-text-primary, #111827)",margin:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:R.name}),e.jsx("p",{style:{fontSize:"12px",color:"var(--metakyc-text-muted, #9ca3af)",margin:0,marginTop:"2px"},children:ut(R.size)})]}),e.jsx("button",{type:"button",onClick:$=>{$.stopPropagation(),B(f)},style:{display:"flex",alignItems:"center",justifyContent:"center",width:"28px",height:"28px",borderRadius:"6px",border:"none",backgroundColor:"transparent",color:"var(--metakyc-text-muted, #9ca3af)",cursor:"pointer",flexShrink:0,transition:"all 0.15s ease",padding:0},onMouseEnter:$=>{$.currentTarget.style.backgroundColor="color-mix(in srgb, var(--metakyc-danger, #ef4444) 10%, transparent)",$.currentTarget.style.color="var(--metakyc-danger, #ef4444)"},onMouseLeave:$=>{$.currentTarget.style.backgroundColor="transparent",$.currentTarget.style.color="var(--metakyc-text-muted, #9ca3af)"},children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},`${R.name}-${f}`)})}),U&&e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-danger, #ef4444)",marginTop:"6px"},children:U})]})},Ar=i.forwardRef(({countryCode:t="+1",onCountryCodeChange:r,className:s,...n},a)=>e.jsxs("div",{className:"w-full",children:[n.label&&e.jsxs("label",{className:"block text-sm font-medium mb-1",style:{color:"var(--metakyc-text-primary, #374151)"},children:[n.label,n.required&&e.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:t,onChange:o=>r==null?void 0:r(o.target.value),className:Se("w-20 rounded-lg border px-3 py-2 text-sm","focus:outline-none focus:ring-2 focus:ring-offset-0"),style:{minHeight:"38px",backgroundColor:"var(--metakyc-input-bg, #ffffff)",color:"var(--metakyc-text-primary, #111827)",borderColor:"var(--metakyc-border, #d1d5db)"},placeholder:"+1"}),e.jsx(ye,{ref:a,type:"tel",className:Se("flex-1",s),...n,label:""})]}),n.error&&e.jsx("p",{className:"mt-1 text-sm text-danger-500",children:n.error})]}));Ar.displayName="PhoneInput";/**
53
53
  * @license lucide-react v0.574.0 - ISC
54
54
  *
55
55
  * This source code is licensed under the ISC license.
@@ -84,7 +84,7 @@ a:hover { color: ${r}; }
84
84
  *
85
85
  * This source code is licensed under the ISC license.
86
86
  * See the LICENSE file in the root directory of this source tree.
87
- */const ms=i.forwardRef(({color:t="currentColor",size:r=24,strokeWidth:s=2,absoluteStrokeWidth:n,className:a="",children:o,iconNode:c,...d},y)=>i.createElement("svg",{ref:y,...us,width:r,height:r,stroke:t,strokeWidth:n?Number(s)*24/Number(r):s,className:Tr("lucide",a),...!o&&!ps(d)&&{"aria-hidden":"true"},...d},[...c.map(([p,b])=>i.createElement(p,b)),...Array.isArray(o)?o:[o]]));/**
87
+ */const ms=i.forwardRef(({color:t="currentColor",size:r=24,strokeWidth:s=2,absoluteStrokeWidth:n,className:a="",children:o,iconNode:c,...d},y)=>i.createElement("svg",{ref:y,...us,width:r,height:r,stroke:t,strokeWidth:n?Number(s)*24/Number(r):s,className:Tr("lucide",a),...!o&&!ps(d)&&{"aria-hidden":"true"},...d},[...c.map(([p,g])=>i.createElement(p,g)),...Array.isArray(o)?o:[o]]));/**
88
88
  * @license lucide-react v0.574.0 - ISC
89
89
  *
90
90
  * This source code is licensed under the ISC license.
@@ -99,5 +99,5 @@ a:hover { color: ${r}; }
99
99
  *
100
100
  * This source code is licensed under the ISC license.
101
101
  * See the LICENSE file in the root directory of this source tree.
102
- */const xs=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Lr=Fr("chevron-right",xs);function hs(t,r){const s=!r||r.length===0||r.every(n=>!n||!n.trim());if(t.isRequired&&s)return t.errorMessage||"This field is required";if(!s){const n=r[0]??"";if(n&&t.regex)try{if(!new RegExp(t.regex).test(n))return t.errorMessage||"Invalid format"}catch{}if(n!==""){const a=Number(n);if(!isNaN(a)&&n.trim()!==""){if(t.min!==void 0&&t.min!==null&&a<t.min)return`Minimum value is ${t.min}`;if(t.max!==void 0&&t.max!==null&&a>t.max)return`Maximum value is ${t.max}`}else{if(t.min!==void 0&&t.min!==null&&n.length<t.min)return`Minimum length is ${t.min} characters`;if(t.max!==void 0&&t.max!==null&&n.length>t.max)return`Maximum length is ${t.max} characters`}}}return null}function fs(t){const r=t.flatMap((n,a)=>(n.questions??[]).map((o,c)=>({question:o,groupIndex:a,qIdx:c}))),s=new Map;for(const n of r){const a=n.question.pageNumber!=null&&n.question.pageNumber>0?n.question.pageNumber:1;s.has(a)||s.set(a,[]),s.get(a).push(n)}return Array.from(s.entries()).sort(([n],[a])=>n-a).map(([,n])=>n)}const Mr=({applicantId:t,onComplete:r,onBack:s})=>{const{questionnaire:n,initialAnswers:a,isLoading:o,isSubmitting:c,error:d,submit:y}=wr(t),[p,b]=i.useState({}),[T,v]=i.useState({}),[E,A]=i.useState(0);i.useEffect(()=>{a&&Object.keys(a).length>0&&Object.keys(p).length===0&&b(a)},[a]);const k=i.useMemo(()=>n?fs(n.questionGroups):[],[n]),S=E===k.length-1,D=k[E]??[],Y=i.useCallback((R,f)=>{b(O=>({...O,[R]:f})),v(O=>{const q={...O};return delete q[R],q})},[]),L=i.useCallback(()=>{const R={};for(const{question:f}of D){const O=hs(f,p[f.id]??[]);O&&(R[f.id]=O)}return v(f=>({...f,...R})),Object.keys(R).length===0},[D,p]),B=()=>{L()&&A(R=>R+1)},U=()=>{E>0?A(R=>R-1):s==null||s()},X=async()=>{if(!(!L()||!n))try{const R=n.questionGroups.flatMap(O=>(O.questions??[]).map(q=>({questionId:q.id,values:p[q.id]??[]}))),f={applicantId:t,questionnarieId:n.id,questionResults:R};await y(f),r==null||r()}catch(R){console.error("Questionnaire submit error:",R)}};return o?e.jsx(ee,{children:e.jsx(te,{children:e.jsx(Ee,{className:"my-8"})})}):d?e.jsx(ee,{children:e.jsx(te,{children:e.jsxs("p",{className:"text-danger-500",children:["Error loading questionnaire: ",d.message]})})}):n?e.jsxs(ee,{children:[e.jsxs(ge,{children:[e.jsx("h2",{className:"text-lg font-bold",children:n.displayName}),n.subtitle&&e.jsx("p",{className:"text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:n.subtitle}),k.length>1&&e.jsxs("div",{className:"flex items-center justify-between mt-3",children:[e.jsxs("span",{className:"text-xs",style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:["Page ",E+1," of ",k.length]}),e.jsx("div",{className:"flex items-center gap-1.5",children:k.map((R,f)=>e.jsx("div",{className:"rounded-full transition-all duration-200",style:{height:"6px",width:f===E?"20px":"6px",backgroundColor:f<=E?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #e5e7eb)"}},f))})]})]}),e.jsx(te,{className:"space-y-6",children:D.map(({question:R})=>e.jsx(gs,{question:R,value:p[R.id]??[],error:T[R.id],onChange:f=>Y(R.id,f)},R.id))}),e.jsxs(be,{className:"flex items-center justify-between",children:[e.jsxs(J,{type:"button",variant:"outline",onClick:U,style:{display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx(Pr,{size:14}),E>0?"Previous":"Back"]}),S?e.jsx(J,{type:"button",isLoading:c,onClick:X,children:"Continue"}):e.jsxs(J,{type:"button",onClick:B,style:{display:"flex",alignItems:"center",gap:"4px"},children:["Next",e.jsx(Lr,{size:14})]})]}),d&&e.jsx("div",{className:"mx-6 mb-4 p-3 bg-red-50 border border-red-200 rounded",children:e.jsx("p",{className:"text-red-600 text-sm",children:d.message})})]}):null},gs=({question:t,value:r,error:s,onChange:n})=>{var c;const o=(((c=t.defaultAnswers)==null?void 0:c.length)??0)>0?t.showAsDropdown?t.canMultipleAnswer?"multi-select":"single-select":t.canMultipleAnswer?"checkbox":"radio":"text";return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"block text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:[t.text,t.isRequired&&e.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),t.subtitle&&e.jsx("p",{className:"text-xs",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:t.subtitle}),t.description&&e.jsx("p",{className:"text-xs",style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:t.description}),o==="text"&&e.jsx(ye,{value:r[0]??"",onChange:d=>n([d.target.value]),placeholder:t.subtitle?void 0:"Enter your answer…",error:s,required:t.isRequired}),o==="single-select"&&e.jsx(mt,{value:r[0]??"",onChange:d=>n([d.target.value]),options:(t.defaultAnswers??[]).map(d=>({value:d,label:d})),placeholder:"Select an option…",error:s,required:t.isRequired}),o==="radio"&&e.jsxs("div",{className:"metakyc-options-group",style:{display:"flex",flexDirection:"column",gap:"8px"},children:[(t.defaultAnswers??[]).map(d=>e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"radio",checked:r[0]===d,onChange:()=>n([d]),className:"metakyc-option-input",style:{width:"16px",height:"16px",minWidth:"16px",flexShrink:0,flexGrow:0,accentColor:"var(--metakyc-primary, #2563eb)",cursor:"pointer",margin:0,padding:0,display:"inline-block",verticalAlign:"middle"}}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4",marginLeft:0},children:d})]},d)),s&&e.jsx("p",{className:"text-sm text-danger-500",children:s})]}),(o==="checkbox"||o==="multi-select")&&e.jsxs("div",{className:"metakyc-options-group",style:{display:"flex",flexDirection:"column",gap:"8px"},children:[(t.defaultAnswers??[]).map(d=>e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"checkbox",checked:r.includes(d),onChange:y=>{y.target.checked?n([...r,d]):n(r.filter(p=>p!==d))},className:"metakyc-option-input",style:{width:"16px",height:"16px",minWidth:"16px",flexShrink:0,flexGrow:0,accentColor:"var(--metakyc-primary, #2563eb)",cursor:"pointer",margin:0,padding:0,display:"inline-block",verticalAlign:"middle"}}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4",marginLeft:0},children:d})]},d)),s&&e.jsx("p",{className:"text-sm text-danger-500",children:s})]}),s&&o==="text"&&null]})};function bs(t){const r=new Map;for(const s of t){const n=s.pageNumber!=null&&s.pageNumber>0?s.pageNumber:1;r.has(n)||r.set(n,[]),r.get(n).push(s)}return Array.from(r.entries()).sort(([s],[n])=>s-n).map(([,s])=>s)}const Dr=({applicantId:t,onComplete:r,onBack:s})=>{const{uploadDocument:n,isLoading:a,isSubmitting:o,error:c,submit:d}=Sr(t),[y,p]=i.useState({}),[b,T]=i.useState(null),[v,E]=i.useState(0),[A,k]=i.useState({}),S=i.useMemo(()=>n?bs(n.uploadDocumentFiles):[],[n]),D=S[v]??[],Y=v===S.length-1,L=S.length,B=i.useCallback(()=>{const f={};for(const O of D)O.isRequired&&(y[O.id]||[]).length===0&&(f[O.id]=`${O.displayName} is required`);return k(f),Object.keys(f).length===0},[D,y]),U=()=>{B()&&(E(f=>f+1),k({}))},X=()=>{v>0?(E(f=>f-1),k({})):s==null||s()},R=async()=>{if(!(!B()||!n)){T(null);try{const f=await Promise.all(n.uploadDocumentFiles.map(async q=>{const Q=y[q.id]||[],$=await Promise.all(Q.map(async G=>({fileName:G.name,fileData:await hr(G)})));return{uploadDocumentFileId:q.id,valueList:$}})),O={applicantId:t,uploadDocumentId:n.id,uploadDocumentResults:f};await d(O),r==null||r()}catch(f){T((f==null?void 0:f.message)||"Failed to submit documents. Please try again.")}}};return a?e.jsx(ee,{children:e.jsx(te,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",padding:"48px 0",gap:"16px"},children:[e.jsx(Ee,{className:"my-8"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--metakyc-text-muted, #9ca3af)"},children:"Loading document requirements..."})]})})}):c?e.jsx(ee,{children:e.jsx(te,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",padding:"32px 0",gap:"12px",textAlign:"center"},children:[e.jsx("div",{style:{width:"48px",height:"48px",borderRadius:"50%",backgroundColor:"color-mix(in srgb, var(--metakyc-danger, #ef4444) 10%, transparent)",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"var(--metakyc-danger, #ef4444)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),e.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]})}),e.jsx("p",{style:{fontSize:"14px",color:"var(--metakyc-danger, #ef4444)",fontWeight:500},children:"Error loading document requirements"}),e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-text-muted, #9ca3af)"},children:c.message})]})})}):n?e.jsxs(ee,{children:[e.jsxs(ge,{children:[e.jsx("h2",{style:{fontSize:"18px",fontWeight:700,color:"var(--metakyc-text-primary, #111827)",margin:0},children:n.displayName||"Upload Documents"}),n.subtitle&&e.jsx("p",{style:{fontSize:"14px",color:"var(--metakyc-text-secondary, #6b7280)",marginTop:"4px"},children:n.subtitle}),L>1&&e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginTop:"12px"},children:[e.jsxs("span",{style:{fontSize:"12px",color:"var(--metakyc-text-muted, #9ca3af)"},children:["Page ",v+1," of ",L]}),e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"6px"},children:S.map((f,O)=>e.jsx("div",{style:{height:"6px",width:O===v?"20px":"6px",borderRadius:"999px",transition:"all 0.2s ease",backgroundColor:O<=v?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #e5e7eb)"}},O))})]})]}),n.description&&v===0&&e.jsxs("div",{style:{margin:"0 24px",marginTop:"4px",display:"flex",gap:"10px",padding:"12px 14px",borderRadius:"10px",backgroundColor:"color-mix(in srgb, var(--metakyc-primary, #2563eb) 5%, var(--metakyc-background, #ffffff))",border:"1px solid color-mix(in srgb, var(--metakyc-primary, #2563eb) 15%, transparent)"},children:[e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"var(--metakyc-primary, #2563eb)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,marginTop:"1px"},children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),e.jsx("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"})]}),e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-text-secondary, #374151)",margin:0,lineHeight:1.5},children:n.description})]}),e.jsx(te,{children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"24px"},children:D.map(f=>e.jsx(Er,{label:f.displayName,subtitle:f.subtitle,accept:f.allowedTypes,multiple:f.multipleFile,maxSize:f.maxEachFileSizeByte,required:f.isRequired,error:A[f.id],value:y[f.id]||[],onChange:O=>{T(null),k(q=>{const Q={...q};return delete Q[f.id],Q}),p(q=>({...q,[f.id]:O}))}},f.id))})}),b&&e.jsxs("div",{style:{margin:"0 24px",padding:"10px 14px",borderRadius:"8px",backgroundColor:"color-mix(in srgb, var(--metakyc-danger, #ef4444) 8%, transparent)",border:"1px solid color-mix(in srgb, var(--metakyc-danger, #ef4444) 20%, transparent)",display:"flex",alignItems:"center",gap:"8px"},children:[e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"var(--metakyc-danger, #ef4444)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[e.jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),e.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),e.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-danger, #ef4444)",margin:0},children:b})]}),e.jsx(be,{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%"},children:[e.jsx(J,{type:"button",variant:"outline",onClick:X,children:v>0?"Previous":"Back"}),Y?e.jsx(J,{type:"button",isLoading:o,onClick:R,children:o?"Uploading...":"Continue"}):e.jsx(J,{type:"button",onClick:U,children:"Next"})]})})]}):null},Or=({applicantId:t,onComplete:r,onBack:s})=>{const{overview:n,isLoading:a,isSubmitting:o,error:c,passOverview:d}=Cr(t),y=async()=>{await d(),r==null||r()};return a?e.jsx(ee,{children:e.jsx(te,{children:e.jsx(Ee,{className:"my-8"})})}):c?e.jsx(ee,{children:e.jsx(te,{children:e.jsxs("p",{className:"text-danger-500",children:["Error loading overview: ",c.message]})})}):n?e.jsxs(ee,{children:[e.jsxs(ge,{children:[e.jsx("h2",{className:"text-lg font-bold",children:n.title||"Overview"}),n.description&&e.jsx("p",{className:"mt-1",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:n.description})]}),e.jsx(te,{className:"space-y-8",children:n.steps&&n.steps.length>0?n.steps.sort((p,b)=>p.order-b.order).map(p=>e.jsxs("div",{className:"metakyc-overview-step-item flex items-center space-x-3",children:[e.jsx("div",{className:"metakyc-step-icon flex-shrink-0",children:e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center font-medium text-sm",style:{backgroundColor:"var(--metakyc-primary, #2563eb)",color:"#ffffff"},children:p.order+1})}),e.jsxs("div",{className:"metakyc-step-content",style:{flex:1,border:"none",height:"auto",background:"transparent"},children:[e.jsx("span",{className:"metakyc-step-title text-sm font-semibold",style:{color:"var(--metakyc-text-primary, #111827)"},children:p.title}),p.description&&e.jsx("p",{className:"metakyc-step-description text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:p.description})]})]},p.order)):e.jsx("div",{className:"text-center py-8",children:e.jsx("p",{style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"Loading overview data..."})})}),e.jsxs(be,{className:"flex justify-between",children:[s&&e.jsx(J,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(J,{onClick:y,isLoading:o,children:"Continue"})]})]}):null};function vs(t){const r=(t??"en").toLowerCase().replace("_","-");try{return Intl.NumberFormat.supportedLocalesOf([r]),r}catch{return"en"}}function ks(t){return t.valueDataType===Me.Money&&Array.isArray(t.defaultValues)&&t.defaultValues.length>0}function js(t,r){const s=new Intl.NumberFormat(vs(r),{minimumFractionDigits:0,maximumFractionDigits:2});return t.replace(/([\d]+(?:\.\d+)?)/g,n=>{const a=parseFloat(n);return isNaN(a)?n:s.format(a)})}function ws(t,r){const s=!r||r.length===0||r.every(n=>!n||!n.trim());if(t.isRequired&&s)return t.errorMessage||`${t.displayName} is required`;if(!s){const n=r[0]??"";if(n&&t.regex)try{if(!new RegExp(t.regex).test(n))return t.errorMessage||"Invalid format"}catch{}const a=t.valueDataType===Me.Integer||t.valueDataType===Me.Money||t.valueDataType===Me.DigitOnly;if(a&&n.trim()!==""){const o=Number(n);if(!isNaN(o)){if(t.min!==void 0&&t.min!==null&&o<t.min)return`Minimum value is ${t.min}`;if(t.max!==void 0&&t.max!==null&&o>t.max)return`Maximum value is ${t.max}`}}else if(!a&&n!==""){if(t.min!==void 0&&t.min!==null&&n.length<t.min)return`Minimum length is ${t.min} characters`;if(t.max!==void 0&&t.max!==null&&n.length>t.max)return`Maximum length is ${t.max} characters`}}return null}function Ss(t){const r=new Map;return t.forEach((s,n)=>{const a=s.pageNumber!=null&&s.pageNumber>0?s.pageNumber:1;r.has(a)||r.set(a,[]),r.get(a).push({criterion:s,idx:n})}),Array.from(r.entries()).sort(([s],[n])=>s-n).map(([,s])=>s)}function Cs(t){return t.builtInType===1?"country":!t.defaultValues||t.defaultValues.length===0?"text":t.multipleValue?"checkbox":"radio"}const zr=({applicantId:t,onComplete:r,onBack:s})=>{const{config:n}=Ne(),a=n.locale??"en",{criteria:o,initialAnswers:c,isLoading:d,isSubmitting:y,error:p,submit:b}=Rr(t),[T,v]=i.useState({}),[E,A]=i.useState({}),[k,S]=i.useState(0),[D,Y]=i.useState(!1);i.useEffect(()=>{c&&Object.keys(c).length>0&&Object.keys(T).length===0&&v(c)},[c]);const L=i.useMemo(()=>o&&o.length>0?Ss(o):[],[o]),B=k===L.length-1,U=L[k]??[];i.useEffect(()=>{!d&&o&&o.length===0&&!D&&!y&&(Y(!0),b({applicantId:t,criteriaValueInputs:[]}).then(()=>r==null?void 0:r()).catch(console.error))},[d,o,D,y,b,t,r]);const X=i.useCallback((Q,$)=>{v(G=>({...G,[Q]:$})),A(G=>{const ne={...G};return delete ne[Q],ne})},[]),R=i.useCallback(()=>{const Q={};for(const{criterion:$}of U){const G=ws($,T[$.id]??[]);G&&(Q[$.id]=G)}return A($=>({...$,...Q})),Object.keys(Q).length===0},[U,T]),f=()=>{R()&&S(Q=>Q+1)},O=()=>{k>0?S(Q=>Q-1):s==null||s()},q=async()=>{if(!(!R()||!o))try{const Q=o.map(G=>{const ne=(T[G.id]??[]).filter(V=>V&&V.trim());return ne.length>0?{riskCriteriaId:G.id,values:ne}:null}).filter(G=>G!==null);await b({applicantId:t,criteriaValueInputs:Q}),r==null||r()}catch(Q){console.error("Risk scoring submit error:",Q)}};return d?e.jsx(ee,{children:e.jsxs(te,{children:[e.jsx(Ee,{className:"my-8"}),e.jsx("p",{className:"text-center text-sm mt-4",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"Loading risk scoring criteria…"})]})}):!d&&o&&o.length===0?e.jsx(ee,{children:e.jsxs(te,{children:[e.jsx(Ee,{className:"my-8"}),e.jsx("p",{className:"text-center text-sm mt-4",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"No criteria required. Moving to next step…"})]})}):p?e.jsx(ee,{children:e.jsx(te,{children:e.jsxs("p",{className:"text-danger-500",children:["Error loading criteria: ",p.message]})})}):o?e.jsxs(ee,{children:[e.jsxs(ge,{children:[e.jsx("h2",{className:"text-lg font-bold",children:"Risk Assessment"}),e.jsx("p",{className:"text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"Please answer the following questions for risk evaluation"}),L.length>1&&e.jsxs("div",{className:"flex items-center justify-between mt-3",children:[e.jsxs("span",{className:"text-xs",style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:["Page ",k+1," of ",L.length]}),e.jsx("div",{className:"flex items-center gap-1.5",children:L.map((Q,$)=>e.jsx("div",{className:"rounded-full transition-all duration-200",style:{height:"6px",width:$===k?"20px":"6px",backgroundColor:$<=k?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #e5e7eb)"}},$))})]})]}),e.jsx(te,{className:"space-y-6",children:U.map(({criterion:Q})=>e.jsx(Ns,{criterion:Q,value:T[Q.id]??[],error:E[Q.id],locale:a,onChange:$=>X(Q.id,$)},Q.id))}),e.jsxs(be,{className:"flex items-center justify-between",children:[e.jsxs(J,{type:"button",variant:"outline",onClick:O,style:{display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx(Pr,{size:14}),k>0?"Previous":"Back"]}),B?e.jsx(J,{type:"button",isLoading:y,onClick:q,children:"Continue"}):e.jsxs(J,{type:"button",onClick:f,style:{display:"flex",alignItems:"center",gap:"4px"},children:["Next",e.jsx(Lr,{size:14})]})]}),p&&e.jsx("div",{className:"mx-6 mb-4 p-3 bg-red-50 border border-red-200 rounded",children:e.jsx("p",{className:"text-red-600 text-sm",children:p.message})})]}):null},Ns=({criterion:t,value:r,error:s,locale:n,onChange:a})=>{const o=Cs(t),c=t.valueDataType===Me.Integer||t.valueDataType===Me.Money||t.valueDataType===Me.DigitOnly,d=ks(t),y=p=>d?js(p,n):p;return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"block text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:[t.displayName,t.isRequired&&e.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),t.description&&e.jsx("p",{className:"text-xs",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:t.description}),c&&(t.min!==void 0||t.max!==void 0)&&e.jsx("p",{className:"text-xs",style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:t.min!==void 0&&t.max!==void 0?`Range: ${t.min} – ${t.max}`:t.min!==void 0?`Minimum: ${t.min}`:`Maximum: ${t.max}`}),o==="text"&&e.jsx(ye,{value:r[0]??"",onChange:p=>a([p.target.value]),type:c?"number":"text",placeholder:"Enter your answer…",error:s,required:t.isRequired,min:t.min,max:t.max,onKeyDown:p=>{t.valueDataType===Me.DigitOnly&&["e","E","+","-","."].includes(p.key)&&p.preventDefault()}}),o==="radio"&&e.jsxs("div",{className:"metakyc-options-group",style:{display:"flex",flexDirection:"column",gap:"8px"},children:[(t.defaultValues??[]).map(p=>e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"radio",checked:r[0]===p,onChange:()=>a([p]),className:"metakyc-option-input",style:{width:"16px",height:"16px",minWidth:"16px",flexShrink:0,flexGrow:0,accentColor:"var(--metakyc-primary, #2563eb)",cursor:"pointer",margin:0,padding:0,display:"inline-block",verticalAlign:"middle"}}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4",marginLeft:0},children:y(p)})]},p)),s&&e.jsx("p",{className:"text-sm text-danger-500",children:s})]}),o==="checkbox"&&e.jsxs("div",{className:"metakyc-options-group",style:{display:"flex",flexDirection:"column",gap:"8px"},children:[(t.defaultValues??[]).map(p=>e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"checkbox",checked:r.includes(p),onChange:b=>{b.target.checked?a([...r,p]):a(r.filter(T=>T!==p))},className:"metakyc-option-input",style:{width:"16px",height:"16px",minWidth:"16px",flexShrink:0,flexGrow:0,accentColor:"var(--metakyc-primary, #2563eb)",cursor:"pointer",margin:0,padding:0,display:"inline-block",verticalAlign:"middle"}}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4",marginLeft:0},children:y(p)})]},p)),s&&e.jsx("p",{className:"text-sm text-danger-500",children:s})]}),o==="country"&&e.jsx(mt,{value:r[0]??"",onChange:p=>a([p.target.value]),options:[{value:"US",label:"United States"},{value:"GB",label:"United Kingdom"},{value:"DE",label:"Germany"},{value:"FR",label:"France"},{value:"AE",label:"United Arab Emirates"}],placeholder:"Select a country…",error:s,required:t.isRequired})]})},$r=({applicantId:t,onComplete:r,onBack:s})=>{const{investorCategorizationService:n}=Ne(),[a,o]=i.useState(null),[c,d]=i.useState(!1),[y,p]=i.useState(null),b=async T=>{if(T.preventDefault(),a===null){p("Please select an investor type");return}d(!0),p(null);try{const v={applicantId:t,investorType:a};console.log("Submitting investor categorization:",v);const E=await n.setInvestorCategorization(v);console.log("Investor categorization result:",E),r==null||r()}catch(v){console.error("Error submitting investor categorization:",v),p(v.message||"Failed to submit investor categorization")}finally{d(!1)}};return e.jsx("form",{onSubmit:b,children:e.jsxs(ee,{children:[e.jsxs(ge,{children:[e.jsx("h2",{className:"text-lg font-bold",style:{color:"var(--metakyc-text-primary, #111827)"},children:"Which statement best describes you?"}),e.jsx("p",{className:"mt-2",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"All Tokenise clients are treated as Retail Investors under EU regulation, which gives you the highest level of investor protection. For our internal purposes, we ask you to select the description that best matches your situation"})]}),e.jsxs(te,{className:"space-y-4",children:[e.jsx("p",{className:"text-sm font-medium mb-3",style:{color:"var(--metakyc-text-secondary, #374151)"},children:"Choose one"}),e.jsx("label",{className:"block p-4 border-2 rounded-lg cursor-pointer transition-all",style:{borderColor:a===je.Individual?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #e5e7eb)",backgroundColor:a===je.Individual?"var(--metakyc-primary-light, #dbeafe)":"transparent"},children:e.jsxs("div",{className:"flex items-start",children:[e.jsx("input",{type:"radio",name:"investorType",value:je.Individual,checked:a===je.Individual,onChange:()=>o(je.Individual),className:"mt-1"}),e.jsxs("div",{className:"ml-3",children:[e.jsx("div",{className:"text-base font-semibold",style:{color:"var(--metakyc-text-primary, #111827)"},children:"Individual investor"}),e.jsx("div",{className:"text-sm mt-1",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"(Recommended) Most of our clients choose this option. Provides the strongest protection and aligns with our mission to make investing accessible to everyone."})]})]})}),e.jsx("label",{className:"block p-4 border-2 rounded-lg cursor-pointer transition-all",style:{borderColor:a===je.Sophisticated?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #e5e7eb)",backgroundColor:a===je.Sophisticated?"var(--metakyc-primary-light, #dbeafe)":"transparent"},children:e.jsxs("div",{className:"flex items-start",children:[e.jsx("input",{type:"radio",name:"investorType",value:je.Sophisticated,checked:a===je.Sophisticated,onChange:()=>o(je.Sophisticated),className:"mt-1"}),e.jsxs("div",{className:"ml-3",children:[e.jsx("div",{className:"text-base font-semibold",style:{color:"var(--metakyc-text-primary, #111827)"},children:"Sophisticated investor"}),e.jsx("div",{className:"text-sm mt-1",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"In the last 2 years, I have done one or more of the following:"}),e.jsxs("ul",{className:"text-sm mt-2 space-y-1 list-none",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:[e.jsx("li",{children:"Worked in private equity or provided capital to small and medium enterprises, and/or"}),e.jsx("li",{children:"Been the director of a company with an annual turnover of at least (USD) $2m million, and/or"}),e.jsx("li",{children:"Invested directly in at least 2 private (not listed) companies."})]})]})]})}),e.jsx("label",{className:"block p-4 border-2 rounded-lg cursor-pointer transition-all",style:{borderColor:a===je.HighNetWorth?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #e5e7eb)",backgroundColor:a===je.HighNetWorth?"var(--metakyc-primary-light, #dbeafe)":"transparent"},children:e.jsxs("div",{className:"flex items-start",children:[e.jsx("input",{type:"radio",name:"investorType",value:je.HighNetWorth,checked:a===je.HighNetWorth,onChange:()=>o(je.HighNetWorth),className:"mt-1"}),e.jsxs("div",{className:"ml-3",children:[e.jsx("div",{className:"text-base font-semibold",style:{color:"var(--metakyc-text-primary, #111827)"},children:"High networth investor"}),e.jsxs("div",{className:"text-sm mt-1",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:["I earn more than (USD/EUR) $150,000 per year, and/or",e.jsx("br",{}),"I have net assets (excluding my main property) of at least $/EUR 300,000"]})]})]})}),y&&e.jsx("div",{className:"p-4 rounded-lg",style:{backgroundColor:"#fee2e2",border:"1px solid #fca5a5"},children:e.jsxs("p",{className:"text-sm",style:{color:"#991b1b"},children:[e.jsx("strong",{children:"Error:"})," ",y]})})]}),e.jsxs(be,{className:"flex justify-between",children:[s&&e.jsx(J,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(J,{type:"submit",isLoading:c,disabled:a===null,children:"Submit"})]})]})})};function Rt(t){const r=t.split(":").map(Number);return r.length===3?r[0]*3600+r[1]*60+r[2]:0}function yt(t){const r=Math.floor(t/60),s=t%60;return`${r.toString().padStart(2,"0")}:${s.toString().padStart(2,"0")}`}const Br=({applicantId:t,onComplete:r,onBack:s})=>{const{appropriatenessTestService:n}=Ne(),[a,o]=i.useState(null),[c,d]=i.useState(!0),[y,p]=i.useState(!1),[b,T]=i.useState(null),[v,E]=i.useState({}),[A,k]=i.useState(0),[S,D]=i.useState(!1),[Y,L]=i.useState(!1),[B,U]=i.useState(0),[X,R]=i.useState(0),[f,O]=i.useState(null);i.useEffect(()=>{(async()=>{try{d(!0),T(null);const z=await n.getAppropriatenessTest(t);if(o(z),z.waitTimeSpanForNextTry&&z.waitTimeSpanForNextTry!=="00:00:00"){const _=Rt(z.waitTimeSpanForNextTry);_>0&&U(_)}}catch(z){T(z.message||"Failed to load appropriateness test")}finally{d(!1)}})()},[t,n]),i.useEffect(()=>{if(!S||A<=0)return;const z=setInterval(()=>{k(_=>_<=1?(L(!0),0):_-1)},1e3);return()=>clearInterval(z)},[S,A]),i.useEffect(()=>{if(B<=0)return;const z=setInterval(()=>{U(_=>_<=1?0:_-1)},1e3);return()=>clearInterval(z)},[B]),i.useEffect(()=>{Y&&!y&&G()},[Y]);const q=()=>{a&&(D(!0),k(a.testDurationSec),R(0),E({}),T(null))},Q=(z,_)=>{E(me=>({...me,[z]:_}))},$=i.useCallback(async()=>{try{const z=await n.getAppropriatenessTest(t);if(o(z),z.waitTimeSpanForNextTry&&z.waitTimeSpanForNextTry!=="00:00:00"){const _=Rt(z.waitTimeSpanForNextTry);_>0&&U(_)}}catch{}},[t,n]),G=async z=>{if(a){if(!Y){const _=a.appropriatenessQuestions.length-Object.keys(v).length;if(_>0){T(`Please answer all questions. ${_} remaining.`);return}}p(!0),T(null);try{const _=a.appropriatenessQuestions.map(N=>({appropriatenessQuestionId:N.id,value:v[N.id]||""})),me={applicantId:t,appropriatenessTestId:a.id,appropriatenessQuestionResults:_};try{const N=await n.fillAppropriatenessTest(me);N.isSuccess?O({success:!0,message:N.message||"Congratulations! You have passed the test."}):(O({success:!1,message:N.message||"You did not pass the test."}),setTimeout(()=>$(),1e3))}catch(N){if(N.code===400&&N.message)O({success:!1,message:N.message}),setTimeout(()=>$(),1500);else throw N}}catch(_){T(_.message||"Failed to submit test. Please try again."),ne()}finally{p(!1)}}},ne=()=>{D(!1),L(!1),E({}),R(0)};if(c)return e.jsx(ee,{children:e.jsx(te,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",padding:"48px 0",gap:"16px"},children:[e.jsx(Ee,{className:"my-8"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--metakyc-text-muted, #9ca3af)"},children:"Loading test..."})]})})});if(!a)return e.jsx(ee,{children:e.jsx(te,{children:e.jsxs("div",{style:{textAlign:"center",padding:"48px 0"},children:[e.jsx("p",{style:{fontSize:"16px",fontWeight:600,color:"var(--metakyc-danger, #ef4444)"},children:"No test data available"}),b&&e.jsx("p",{style:{fontSize:"14px",color:"var(--metakyc-text-muted, #9ca3af)",marginTop:"8px"},children:b})]})})});const V=a.testAllowedMaxTry-a.totalFailedTries,he=a.appropriatenessQuestions.length,le=Object.keys(v).length;if(B>0)return e.jsxs(ee,{children:[e.jsx(ge,{children:e.jsx("h2",{style:{fontSize:"18px",fontWeight:700,color:"var(--metakyc-text-primary, #111827)",margin:0},children:a.displayName})}),e.jsx(te,{children:e.jsxs("div",{style:{textAlign:"center",padding:"32px 0"},children:[e.jsx("div",{style:{width:"100px",height:"100px",borderRadius:"50%",margin:"0 auto 20px",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"color-mix(in srgb, var(--metakyc-primary, #2563eb) 8%, transparent)"},children:e.jsx("span",{style:{fontSize:"28px",fontWeight:700,color:"var(--metakyc-primary, #2563eb)",fontVariantNumeric:"tabular-nums"},children:yt(B)})}),e.jsx("p",{style:{fontSize:"15px",fontWeight:500,color:"var(--metakyc-text-primary, #111827)"},children:"Please wait before retrying"}),e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-text-muted, #9ca3af)",marginTop:"4px"},children:"You can attempt the test again once the timer expires"}),b&&e.jsx("div",{style:{marginTop:"20px",padding:"12px 16px",borderRadius:"10px",backgroundColor:"color-mix(in srgb, var(--metakyc-danger, #ef4444) 8%, transparent)",border:"1px solid color-mix(in srgb, var(--metakyc-danger, #ef4444) 20%, transparent)"},children:e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-danger, #ef4444)",margin:0},children:b})})]})})]});if(f){const z=()=>{O(null),ne(),T(null)};return e.jsxs(ee,{children:[e.jsx(te,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",textAlign:"center",padding:"40px 16px",gap:"16px"},children:[e.jsx("div",{style:{width:"72px",height:"72px",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:f.success?"color-mix(in srgb, var(--metakyc-success, #10b981) 12%, transparent)":"color-mix(in srgb, var(--metakyc-danger, #ef4444) 10%, transparent)"},children:f.success?e.jsxs("svg",{width:"36",height:"36",viewBox:"0 0 24 24",fill:"none",stroke:"var(--metakyc-success, #10b981)",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),e.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]}):e.jsxs("svg",{width:"36",height:"36",viewBox:"0 0 24 24",fill:"none",stroke:"var(--metakyc-danger, #ef4444)",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),e.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]})}),e.jsx("h2",{style:{fontSize:"20px",fontWeight:700,color:f.success?"var(--metakyc-success, #10b981)":"var(--metakyc-danger, #ef4444)",margin:0},children:f.success?"Test Passed":"Test Failed"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--metakyc-text-secondary, #6b7280)",margin:0,lineHeight:1.6,maxWidth:"400px",whiteSpace:"pre-line"},children:f.message}),!f.success&&V>0&&e.jsx("div",{style:{marginTop:"4px",padding:"10px 20px",borderRadius:"10px",backgroundColor:"var(--metakyc-surface, #f9fafb)",border:"1px solid var(--metakyc-border, #e5e7eb)"},children:e.jsxs("p",{style:{fontSize:"13px",color:"var(--metakyc-text-muted, #9ca3af)",margin:0},children:["You have ",e.jsx("strong",{style:{color:"var(--metakyc-text-primary, #111827)"},children:V})," attempt",V!==1?"s":""," remaining"]})}),!f.success&&V<=0&&e.jsx("div",{style:{marginTop:"4px",padding:"10px 20px",borderRadius:"10px",backgroundColor:"color-mix(in srgb, var(--metakyc-danger, #ef4444) 8%, transparent)",border:"1px solid color-mix(in srgb, var(--metakyc-danger, #ef4444) 20%, transparent)"},children:e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-danger, #ef4444)",margin:0},children:"No attempts remaining. Please contact support for assistance."})})]})}),e.jsx(be,{children:e.jsx("div",{style:{display:"flex",justifyContent:"center",width:"100%",gap:"12px"},children:f.success?e.jsx(J,{type:"button",onClick:()=>r==null?void 0:r(),children:"Continue"}):e.jsxs(e.Fragment,{children:[V>0&&B<=0&&e.jsx(J,{type:"button",onClick:z,children:"Retake Test"}),V>0&&B>0&&e.jsx(J,{type:"button",onClick:z,children:"OK"}),V<=0&&s&&e.jsx(J,{type:"button",variant:"outline",onClick:s,children:"Back"})]})})})]})}if(!S)return e.jsxs(ee,{children:[e.jsxs(ge,{children:[e.jsx("h2",{style:{fontSize:"18px",fontWeight:700,color:"var(--metakyc-text-primary, #111827)",margin:0},children:a.displayName}),a.subtitle&&e.jsx("p",{style:{fontSize:"14px",color:"var(--metakyc-text-secondary, #6b7280)",marginTop:"4px"},children:a.subtitle})]}),e.jsxs(te,{children:[a.description&&e.jsxs("div",{style:{marginBottom:"20px",padding:"12px 14px",borderRadius:"10px",backgroundColor:"color-mix(in srgb, var(--metakyc-primary, #2563eb) 5%, var(--metakyc-background, #ffffff))",border:"1px solid color-mix(in srgb, var(--metakyc-primary, #2563eb) 15%, transparent)",display:"flex",gap:"10px"},children:[e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"var(--metakyc-primary, #2563eb)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,marginTop:"1px"},children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),e.jsx("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"})]}),e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-text-secondary, #374151)",margin:0,lineHeight:1.5},children:a.description})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px",marginBottom:"20px"},children:[e.jsx(ct,{icon:"questions",label:"Questions",value:String(a.totalQuestionCount)}),e.jsx(ct,{icon:"time",label:"Time Limit",value:yt(a.testDurationSec)}),e.jsx(ct,{icon:"target",label:"Pass Requirement",value:`${a.testCorrectAnswerPassLimit} correct`}),e.jsx(ct,{icon:"retry",label:"Attempts Left",value:String(V),variant:V<=1?"warning":"default"})]}),b&&e.jsxs("div",{style:{marginBottom:"16px",padding:"12px 14px",borderRadius:"10px",backgroundColor:"color-mix(in srgb, var(--metakyc-danger, #ef4444) 8%, transparent)",border:"1px solid color-mix(in srgb, var(--metakyc-danger, #ef4444) 20%, transparent)",display:"flex",gap:"10px"},children:[e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"var(--metakyc-danger, #ef4444)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,marginTop:"1px"},children:[e.jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),e.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),e.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),e.jsxs("p",{style:{fontSize:"13px",color:"var(--metakyc-danger, #ef4444)",margin:0,lineHeight:1.5},children:[e.jsx("strong",{children:"Previous attempt:"})," ",b]})]}),V<=0&&e.jsx("div",{style:{padding:"12px 14px",borderRadius:"10px",backgroundColor:"color-mix(in srgb, var(--metakyc-danger, #ef4444) 8%, transparent)",border:"1px solid color-mix(in srgb, var(--metakyc-danger, #ef4444) 20%, transparent)"},children:e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-danger, #ef4444)",margin:0},children:"You have used all your attempts. Please contact support for assistance."})})]}),e.jsx(be,{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:s?"space-between":"flex-end",width:"100%"},children:[s&&e.jsx(J,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(J,{type:"button",onClick:q,disabled:V<=0,children:"Start Test"})]})})]});const de=a.appropriatenessQuestions[X],fe=X===he-1,I=le===he,W=A<=60;return e.jsxs(ee,{children:[e.jsxs(ge,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx("h2",{style:{fontSize:"18px",fontWeight:700,color:"var(--metakyc-text-primary, #111827)",margin:0},children:a.displayName}),e.jsxs("p",{style:{fontSize:"12px",color:"var(--metakyc-text-muted, #9ca3af)",marginTop:"2px"},children:["Question ",X+1," of ",he]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 14px",borderRadius:"999px",backgroundColor:W?"color-mix(in srgb, var(--metakyc-danger, #ef4444) 10%, transparent)":"var(--metakyc-surface, #f3f4f6)",transition:"all 0.3s ease"},children:[e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:W?"var(--metakyc-danger, #ef4444)":"var(--metakyc-text-muted, #9ca3af)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("polyline",{points:"12 6 12 12 16 14"})]}),e.jsx("span",{style:{fontSize:"16px",fontWeight:700,fontVariantNumeric:"tabular-nums",color:W?"var(--metakyc-danger, #ef4444)":"var(--metakyc-text-primary, #111827)",transition:"color 0.3s ease"},children:yt(A)})]})]}),e.jsxs("div",{style:{marginTop:"12px"},children:[e.jsx("div",{style:{height:"4px",borderRadius:"999px",backgroundColor:"var(--metakyc-border, #e5e7eb)",overflow:"hidden"},children:e.jsx("div",{style:{height:"100%",borderRadius:"999px",backgroundColor:"var(--metakyc-primary, #2563eb)",width:`${le/he*100}%`,transition:"width 0.3s ease"}})}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginTop:"4px"},children:[e.jsxs("span",{style:{fontSize:"11px",color:"var(--metakyc-text-muted, #9ca3af)"},children:[le," answered"]}),e.jsxs("span",{style:{fontSize:"11px",color:"var(--metakyc-text-muted, #9ca3af)"},children:[V," attempt",V!==1?"s":""," left"]})]})]})]}),e.jsxs(te,{children:[de&&e.jsx(Is,{question:de,index:X,selectedAnswer:v[de.id],onSelect:z=>Q(de.id,z),disabled:y}),he>1&&e.jsx("div",{style:{display:"flex",justifyContent:"center",gap:"6px",marginTop:"20px",flexWrap:"wrap"},children:a.appropriatenessQuestions.map((z,_)=>e.jsx("button",{type:"button",onClick:()=>R(_),style:{width:"28px",height:"28px",borderRadius:"8px",border:_===X?"2px solid var(--metakyc-primary, #2563eb)":"1px solid var(--metakyc-border, #e5e7eb)",backgroundColor:v[z.id]?_===X?"color-mix(in srgb, var(--metakyc-primary, #2563eb) 15%, transparent)":"color-mix(in srgb, var(--metakyc-primary, #2563eb) 8%, transparent)":_===X?"var(--metakyc-surface, #f9fafb)":"var(--metakyc-background, #ffffff)",color:v[z.id]?"var(--metakyc-primary, #2563eb)":"var(--metakyc-text-muted, #9ca3af)",fontSize:"12px",fontWeight:600,cursor:"pointer",transition:"all 0.15s ease",padding:0,display:"flex",alignItems:"center",justifyContent:"center"},children:_+1},z.id))}),Y&&e.jsxs("div",{style:{marginTop:"16px",padding:"12px 14px",borderRadius:"10px",backgroundColor:"color-mix(in srgb, #f59e0b 10%, transparent)",border:"1px solid color-mix(in srgb, #f59e0b 25%, transparent)",display:"flex",alignItems:"center",gap:"10px"},children:[e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"#f59e0b",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("polyline",{points:"12 6 12 12 16 14"})]}),e.jsx("p",{style:{fontSize:"13px",color:"#b45309",margin:0,fontWeight:500},children:"Time's up! Your answers are being submitted."})]}),b&&!Y&&e.jsx("div",{style:{marginTop:"16px",padding:"12px 14px",borderRadius:"10px",backgroundColor:"color-mix(in srgb, var(--metakyc-danger, #ef4444) 8%, transparent)",border:"1px solid color-mix(in srgb, var(--metakyc-danger, #ef4444) 20%, transparent)"},children:e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-danger, #ef4444)",margin:0},children:b})})]}),e.jsx(be,{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%"},children:[e.jsx(J,{type:"button",variant:"outline",onClick:()=>{X>0?R(z=>z-1):s==null||s()},disabled:y,children:X>0?"Previous":"Cancel"}),e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[!fe&&e.jsx(J,{type:"button",onClick:()=>R(z=>z+1),children:"Next"}),(fe||I)&&e.jsx(J,{type:"button",isLoading:y,onClick:()=>G(),disabled:!I&&!Y,style:{opacity:I||Y?1:.5},children:Y?"Submitting...":"Submit Test"})]})]})})]})},Rs={questions:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M9 11l3 3L22 4"}),e.jsx("path",{d:"M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"})]}),time:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("polyline",{points:"12 6 12 12 16 14"})]}),target:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("circle",{cx:"12",cy:"12",r:"6"}),e.jsx("circle",{cx:"12",cy:"12",r:"2"})]}),retry:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polyline",{points:"23 4 23 10 17 10"}),e.jsx("path",{d:"M20.49 15a9 9 0 1 1-2.12-9.36L23 10"})]})},ct=({icon:t,label:r,value:s,variant:n="default"})=>{const a=n==="warning";return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",padding:"14px",borderRadius:"10px",backgroundColor:a?"color-mix(in srgb, #f59e0b 8%, transparent)":"var(--metakyc-surface, #f9fafb)",border:a?"1px solid color-mix(in srgb, #f59e0b 20%, transparent)":"1px solid var(--metakyc-border, #e5e7eb)"},children:[e.jsx("div",{style:{color:a?"#f59e0b":"var(--metakyc-primary, #2563eb)",flexShrink:0},children:Rs[t]}),e.jsxs("div",{children:[e.jsx("p",{style:{fontSize:"12px",color:"var(--metakyc-text-muted, #9ca3af)",margin:0},children:r}),e.jsx("p",{style:{fontSize:"15px",fontWeight:600,color:a?"#b45309":"var(--metakyc-text-primary, #111827)",margin:0,marginTop:"1px"},children:s})]})]})},Is=({question:t,selectedAnswer:r,onSelect:s,disabled:n})=>e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"16px"},children:[t.groupName&&e.jsx("span",{style:{display:"inline-block",fontSize:"11px",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em",color:"var(--metakyc-primary, #2563eb)",marginBottom:"8px"},children:t.groupName}),e.jsx("h3",{style:{fontSize:"16px",fontWeight:600,color:"var(--metakyc-text-primary, #111827)",margin:0,lineHeight:1.5},children:t.question})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:t.answers.map((a,o)=>{const c=r===a;return e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"12px",padding:"14px 16px",borderRadius:"10px",border:`2px solid ${c?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #e5e7eb)"}`,backgroundColor:c?"color-mix(in srgb, var(--metakyc-primary, #2563eb) 5%, var(--metakyc-background, #ffffff))":"var(--metakyc-background, #ffffff)",cursor:n?"default":"pointer",transition:"all 0.15s ease",opacity:n?.6:1},onMouseEnter:d=>{!n&&!c&&(d.currentTarget.style.borderColor="color-mix(in srgb, var(--metakyc-primary, #2563eb) 50%, var(--metakyc-border, #e5e7eb))")},onMouseLeave:d=>{c||(d.currentTarget.style.borderColor="var(--metakyc-border, #e5e7eb)")},children:[e.jsx("div",{style:{width:"20px",height:"20px",borderRadius:"50%",border:`2px solid ${c?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #d1d5db)"}`,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,transition:"border-color 0.15s ease"},children:c&&e.jsx("div",{style:{width:"10px",height:"10px",borderRadius:"50%",backgroundColor:"var(--metakyc-primary, #2563eb)"}})}),e.jsx("input",{type:"radio",name:`q-${t.id}`,value:a,checked:c,onChange:()=>s(a),disabled:n,style:{position:"absolute",opacity:0,width:0,height:0}}),e.jsx("span",{style:{fontSize:"14px",color:c?"var(--metakyc-text-primary, #111827)":"var(--metakyc-text-secondary, #6b7280)",fontWeight:c?500:400,transition:"color 0.15s ease"},children:a})]},o)})})]}),_r=({applicantId:t,onComplete:r,onBack:s})=>{var Ge,ze,et,Ue;const{applicantService:n,baseInformationService:a,identityService:o,config:c,currentTheme:d}=Ne(),{identityData:y,provider:p,token:b,isLoading:T,error:v,requestIdentity:E,restartIdentity:A}=Nr(t),[k,S]=i.useState(null),[D,Y]=i.useState(null),[L,B]=i.useState([]),[U,X]=i.useState([]),[R,f]=i.useState(!0),[O,q]=i.useState(!1),[Q,$]=i.useState(null),[G,ne]=i.useState(!1),V=i.useRef(!1),[he,le]=i.useState({}),[de,fe]=i.useState({}),I=d!=null&&d.reviewPageFields&&d.reviewPageFields.length>0?d.reviewPageFields[0]:null,W=!!(d!=null&&d.reviewPageDisabled),z=i.useRef(!1);z.current=W;const _=qe.useForm({defaultValues:{street:"",streetNumber:"",city:"",zip:"",country:"",nationality:"",phonenumber:""}});i.useEffect(()=>{if(W){V.current||(V.current=!0,E().then(()=>q(!0)).catch(M=>console.error("[Identity] Auto-request failed:",M)).finally(()=>f(!1)));return}(async()=>{try{const[M,K,H]=await Promise.all([n.getApplicantData(t),a.getCountries("","en"),a.getCountries("","en",40)]);Y(M);const Z=new Set,m=K.map(h=>({value:h.abbreviation3||h.abbreviation,label:h.name})).filter(h=>!h.value||Z.has(h.value)?!1:(Z.add(h.value),!0));B(m);const C=new Set,F=H.filter(h=>h.countryCode).map(h=>({value:h.countryCode,label:`${h.countryCode} – ${h.name}`})).filter(h=>C.has(h.value)?!1:(C.add(h.value),!0));X(F);const u=M.applicantRequestData;if(le({firstName:(u==null?void 0:u.firstName)||"",lastName:(u==null?void 0:u.lastName)||"",email:(u==null?void 0:u.email)||"",dateOfBirth:(u==null?void 0:u.dateOfBirth)||"",title:(u==null?void 0:u.title)||"",salutation:(u==null?void 0:u.salutation)||"",phonenumber:(u==null?void 0:u.phonenumber)||"",mobileCountryCode:(u==null?void 0:u.mobileCountryCode)||"",street:(u==null?void 0:u.street)||"",streetNumber:(u==null?void 0:u.streetNumber)||"",city:(u==null?void 0:u.city)||"",zip:(u==null?void 0:u.zip)||"",country:(u==null?void 0:u.country)||"",nationality:(u==null?void 0:u.nationality)||"",taxCountry:(u==null?void 0:u.taxCountry)||"",countryOfBirth:(u==null?void 0:u.countryOfBirth)||"",placeOfBirth:(u==null?void 0:u.placeOfBirth)||"",educationLevel:(u==null?void 0:u.educationLevel)||"",occupation:(u==null?void 0:u.occupation)||"",taxNumber:(u==null?void 0:u.taxNumber)||"",defaultLanguage:(u==null?void 0:u.defaultLanguage)||""}),_.reset({street:(u==null?void 0:u.street)||"",streetNumber:(u==null?void 0:u.streetNumber)||"",city:(u==null?void 0:u.city)||"",zip:(u==null?void 0:u.zip)||"",country:(u==null?void 0:u.country)||"",nationality:(u==null?void 0:u.nationality)||"",phonenumber:(u==null?void 0:u.phonenumber)||""}),M.kycRecords&&M.kycRecords.length>0&&M.kycRecords[0].providerTokenObject!==null&&!V.current&&z.current){console.log("[Identity] Review page disabled + existing identity — auto-requesting..."),V.current=!0;try{await E(),q(!0)}catch(h){console.error("[Identity] Auto-request failed:",h)}}}catch(M){console.error("Error loading applicant data:",M)}finally{f(!1)}})()},[t]),i.useEffect(()=>{y&&!O&&z.current&&(console.log("[Identity] Review page disabled — showing cached provider"),q(!0))},[y,O]),i.useEffect(()=>{if(b){if(b.expiresAt){const x=new Date(b.expiresAt).getTime();if(Date.now()>=x){console.warn("[Identity] Token has expired (expiresAt)"),ne(!0),$("Your verification session has expired. Please restart.");return}}if(b.url)try{const M=new URL(b.url).toString().toLowerCase();if(M.includes("expired")||M.includes("invalid")||M.includes("error")){console.warn("[Identity] Token URL indicates expiration"),ne(!0),$("Your verification link has expired. Please restart.");return}}catch{console.error("[Identity] Invalid token URL")}if(b.status==="expired"||b.error==="expired"||b.expired===!0){console.warn("[Identity] Token object indicates expiration"),ne(!0),$("Your verification session has expired. Please restart.");return}}},[b]);const me=p!==null&&p===Ae.Sumsub;i.useEffect(()=>{if(p!==null&&b&&!k&&O&&!G){const x=p;if(me){console.log("[Sumsub] Fetching access token for Web SDK…"),$(null),(async()=>{try{const M=await o.refreshSumsubToken(t),K=_e.parseProviderConfig(p,b,c);K.accessToken=M,K.onTokenRefresh=()=>o.refreshSumsubToken(t);const H=_e.createProvider(p,K);H.onComplete(Z=>{console.log("[Sumsub] Verification complete:",Z),r==null||r()}),H.onError(Z=>{console.error("[Sumsub] SDK error:",Z),(typeof Z=="string"?Z:(Z==null?void 0:Z.message)||"Unknown error").toLowerCase().includes("expired")&&(ne(!0),$("Session expired. Please restart."))}),await H.initialize("sumsub-websdk-container"),console.log("[Sumsub] Web SDK launched"),S(H)}catch(M){console.error("[Sumsub] Initialization error:",M),$(`Failed to initialize: ${M.message||M}`),String(M.message||M).toLowerCase().includes("expired")&&ne(!0)}})();return}if(b.url){console.log("[Identity] Loading provider URL for user verification:",b.url),$(null);try{if(new URL(b.url),x===Ae.SardinAI){console.log("[SardinAI] Initializing Risk SDK in background...");try{const M=_e.parseProviderConfig(p,b,c);_e.createProvider(p,M).initialize().then(()=>console.log("[SardinAI] Risk SDK initialized in background")).catch(H=>console.warn("[SardinAI] Risk SDK init failed (non-blocking):",H))}catch(M){console.warn("[SardinAI] Risk SDK setup failed (non-blocking):",M)}}S({type:"url",url:b.url})}catch(M){console.error("[Identity] Invalid URL:",M),$("Invalid verification URL. Please restart."),ne(!0)}return}if(x===Ae.SardinAI){console.log("[SardinAI] No URL provided - initializing Risk SDK only..."),$(null);try{const M=_e.parseProviderConfig(p,b,c),K=_e.createProvider(p,M);K.initialize().then(()=>{console.log("[SardinAI] Risk SDK initialized successfully"),S(K),setTimeout(()=>r==null?void 0:r(),2e3)}).catch(H=>{var m;console.error("[SardinAI] Failed to initialize:",H);const Z=((m=H.message)==null?void 0:m.toLowerCase())||"";Z.includes("expired")||Z.includes("invalid")||Z.includes("401")||Z.includes("400")?(ne(!0),$("Session expired or invalid. Please restart verification.")):$(`Failed to initialize: ${H.message}`)})}catch(M){console.error("[SardinAI] Error creating provider:",M),$(`Configuration error: ${M.message}`)}return}try{$(null);const M=_e.parseProviderConfig(p,b,c),K=_e.createProvider(p,M);x===Ae.Onfido&&K.initialize("identity-container").catch(H=>{console.error("[Onfido] Initialization error:",H),$(`Failed to initialize: ${H.message}`)}),S(K)}catch(M){console.error("[Identity] Provider setup error:",M),$(`Setup error: ${M.message}`)}}return()=>{if(k&&k.destroy)try{k.destroy()}catch(x){console.error("[Identity] Error destroying provider:",x)}}},[p,b,k,O,r,G,me,t,c,o]);const N=async()=>{try{$(null),ne(!1),await E(),q(!0)}catch(x){console.error("Error starting identity verification:",x)}},re=async()=>{try{$(null),ne(!1),S(null),console.log("[Identity] Restarting verification..."),await A(),q(!0)}catch(x){console.error("Error restarting identity verification:",x),$(x.message||"Failed to restart verification")}};if(R||T)return e.jsx(ee,{children:e.jsxs(te,{children:[e.jsx(Ee,{className:"my-8"}),e.jsx("p",{className:"text-center text-gray-600 dark:text-gray-400 mt-4",children:"Loading identity verification..."})]})});if(v)return e.jsx(ee,{children:e.jsx(te,{children:e.jsxs("p",{className:"text-danger-500",children:["Error: ",v.message]})})});if(O&&(Q||G))return e.jsxs(ee,{children:[e.jsx(ge,{children:e.jsx("h2",{className:"text-2xl font-bold text-gray-900 dark:text-white",children:"Verification Session Issue"})}),e.jsxs(te,{children:[e.jsx("div",{className:"p-4 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg mb-6",children:e.jsxs("div",{className:"flex items-start",children:[e.jsx("svg",{className:"h-6 w-6 text-red-600 dark:text-red-400 mr-3 mt-0.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-red-900 dark:text-red-100 mb-1",children:G?"Session Expired":"Verification Error"}),e.jsx("p",{className:"text-red-800 dark:text-red-200 text-sm",children:Q||"Your verification session has expired and needs to be restarted."})]})]})}),e.jsxs("div",{className:"bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg p-4",children:[e.jsx("h3",{className:"font-semibold text-blue-900 dark:text-blue-100 mb-2",children:"What to do next:"}),e.jsxs("ul",{className:"text-blue-800 dark:text-blue-200 text-sm space-y-1 list-disc list-inside",children:[e.jsx("li",{children:'Click "Restart Verification" below to generate a new session'}),e.jsx("li",{children:"Complete the verification process without delays"}),e.jsx("li",{children:"If issues persist, contact support"})]})]})]}),e.jsxs(be,{className:"flex justify-between",children:[s&&e.jsx(J,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(J,{type:"button",onClick:re,disabled:T,children:T?"Restarting...":"Restart Verification"})]})]});if(O&&y){const x=p;return me?e.jsxs("div",{style:{background:"var(--metakyc-background, #ffffff)",borderRadius:"12px",border:"1px solid var(--metakyc-border, #e5e7eb)",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"20px 24px",borderBottom:"1px solid var(--metakyc-border, #e5e7eb)"},children:[e.jsxs("div",{children:[e.jsx("h2",{style:{margin:0,fontSize:"20px",fontWeight:700,color:"var(--metakyc-text-primary, #111827)"},children:"Identity Verification"}),e.jsx("p",{style:{margin:"4px 0 0",fontSize:"14px",color:"var(--metakyc-text-secondary, #6b7280)"},children:"Please complete the identity verification process"})]}),e.jsx("button",{type:"button",onClick:re,disabled:T,style:{padding:"6px 14px",fontSize:"13px",fontWeight:500,borderRadius:"8px",border:"1px solid var(--metakyc-border, #d1d5db)",background:"var(--metakyc-background, #ffffff)",color:"var(--metakyc-text-primary, #111827)",cursor:T?"not-allowed":"pointer",opacity:T?.5:1},children:T?"Restarting…":"Restart"})]}),e.jsx("div",{id:"sumsub-websdk-container",style:{minHeight:"520px",width:"100%",padding:"16px 24px",background:"var(--metakyc-background, #ffffff)"}}),s&&e.jsx("div",{style:{padding:"16px 24px",borderTop:"1px solid var(--metakyc-border, #e5e7eb)"},children:e.jsx(J,{variant:"outline",onClick:s,children:"Back"})})]}):b!=null&&b.url?e.jsxs(ee,{children:[e.jsx(ge,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold",children:"Identity Verification"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:"Please complete the identity verification process"})]}),e.jsx(J,{type:"button",variant:"outline",size:"sm",onClick:re,disabled:T,children:"Restart"})]})}),e.jsxs(te,{children:[e.jsx("div",{className:"mb-4 p-3 bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg",children:e.jsxs("p",{className:"text-yellow-800 dark:text-yellow-200 text-sm",children:[e.jsx("strong",{children:"Important:"}),' If you see an "expired" or "invalid link" message below, click the "Restart" button above to generate a new verification session.']})}),e.jsx("div",{className:"w-full",style:{height:"600px"},children:e.jsx("iframe",{src:b.url,className:"w-full h-full border-0 rounded-lg",allow:"camera; microphone; geolocation",title:"Identity Verification",onLoad:M=>{var K,H,Z;console.log("[Identity] Iframe loaded");try{const m=M.target,C=m.contentDocument||((K=m.contentWindow)==null?void 0:K.document);if(C){const F=((Z=(H=C.body)==null?void 0:H.textContent)==null?void 0:Z.toLowerCase())||"";(F.includes("expired")||F.includes("invalid")||F.includes("error"))&&(console.warn("[Identity] Iframe shows expiration message"),ne(!0),$("Your verification link has expired."))}}catch{console.log("[Identity] Cannot check iframe content (CORS)")}}})})]}),s&&e.jsx(be,{children:e.jsx(J,{variant:"outline",onClick:s,children:"Back"})})]}):x===Ae.SardinAI?e.jsxs(ee,{children:[e.jsxs(ge,{children:[e.jsx("h2",{className:"text-2xl font-bold",children:"Device Risk Assessment"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:"Analyzing device security and behavioral patterns..."})]}),e.jsx(te,{children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx(Ee,{className:"mb-4"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:"Please wait while we verify your device security"}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-500 mt-2",children:"This process is automatic and will complete in a few seconds"})]})})]}):e.jsxs(ee,{children:[e.jsxs(ge,{children:[e.jsx("h2",{className:"text-2xl font-bold",children:"Identity Verification"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:"Please complete the identity verification process"})]}),e.jsx(te,{children:e.jsx("div",{id:"identity-container",className:"min-h-[400px]"})}),s&&e.jsx(be,{children:e.jsx(J,{variant:"outline",onClick:s,children:"Back"})})]})}const ue=new Set(["country","nationality","taxCountry","countryOfBirth","mobileCountryCode","otherNationality"]),ae=(x=4)=>{const M=Math.min(4,Math.max(1,Number(x)||4));return{gridColumn:`span ${M} / span ${M}`}},ve=(x,M)=>{if(!M&&M!==0)return"—";if(ue.has(x)&&x!=="mobileCountryCode"){const K=L.find(H=>H.value===M);return K?K.label:String(M)}return String(M)},Fe=({helpText:x})=>{const[M,K]=i.useState(!1),H=i.useRef(null),[,Z]=i.useState({top:0,left:0}),m=()=>{if(H.current){const C=H.current.getBoundingClientRect();Z({top:C.bottom+window.scrollY+6,left:C.left+window.scrollX})}K(!0)};return e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"metakyc-help-btn",ref:H,onClick:m,style:{width:18,height:18,borderRadius:"50%",border:"1.5px solid var(--metakyc-primary, #2563eb)",background:"transparent",color:"var(--metakyc-primary, #2563eb)",fontSize:11,fontWeight:700,cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,lineHeight:1,position:"relative",zIndex:2},children:"?"}),M&&pt.createPortal(e.jsx("div",{style:{position:"fixed",inset:0,zIndex:99999,background:"rgba(0,0,0,0.55)",backdropFilter:"blur(6px)",WebkitBackdropFilter:"blur(6px)",display:"flex",alignItems:"center",justifyContent:"center"},onClick:()=>K(!1),children:e.jsxs("div",{onClick:C=>C.stopPropagation(),style:{background:"var(--metakyc-surface, var(--metakyc-background, #ffffff))",border:"1px solid var(--metakyc-border, #e5e7eb)",borderRadius:"var(--metakyc-border-radius, 8px)",padding:"20px 24px",maxWidth:400,width:"90%",boxShadow:"0 24px 64px rgba(0,0,0,0.4)"},children:[e.jsx("div",{dangerouslySetInnerHTML:{__html:x},style:{fontSize:13,color:"var(--metakyc-text-primary, #111827)",lineHeight:1.6}}),e.jsx("button",{type:"button",onClick:()=>K(!1),style:{marginTop:12,padding:"4px 12px",fontSize:12,border:"1px solid var(--metakyc-border, #e5e7eb)",borderRadius:"var(--metakyc-border-radius, 6px)",background:"transparent",cursor:"pointer",color:"var(--metakyc-text-secondary, #6b7280)"},children:"Close"})]})}),document.body)]})},ke=(x,M)=>M?e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:5,flexWrap:"nowrap"},children:[e.jsx("div",{style:{flex:1,minWidth:0},children:x}),e.jsx("div",{style:{paddingTop:24},children:e.jsx(Fe,{helpText:M})})]}):x,Oe=(x,M)=>{const K=`cf-${M}`,H=x.paramName??"",Z=de[H];if(x.customType==="br")return e.jsx("div",{style:{...ae(x.colSpan),minHeight:"0.5rem"}},K);if(x.customType==="paragraph")return e.jsx("div",{style:ae(x.colSpan),children:e.jsx("div",{className:"text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},dangerouslySetInnerHTML:{__html:x.label||""}})},K);if(x.customType==="html")return e.jsx("div",{style:ae(x.colSpan),dangerouslySetInnerHTML:{__html:x.label||""}},K);if(x.customType==="link")return e.jsx("div",{style:ae(x.colSpan),children:ke(e.jsx("a",{href:x.linkUrl??"#",target:"_blank",rel:"noopener noreferrer",className:"text-sm underline",style:{color:"var(--metakyc-primary, #6366f1)"},children:x.displayText||x.label||x.linkText||x.linkUrl}),x.helpText)},K);if(x.customType==="checkbox"||x.customType==="link_checkbox"){const m=Z==="true"||Z===!0;return e.jsx("div",{style:ae(x.colSpan),children:ke(e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:8,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:!!m,onChange:C=>fe(F=>({...F,[H]:String(C.target.checked)})),style:{width:16,height:16,flexShrink:0,marginTop:2,accentColor:"var(--metakyc-primary, #6366f1)"}}),e.jsx("span",{className:"text-sm",style:{color:"var(--metakyc-text-primary, #111827)"},children:x.customType==="link_checkbox"&&x.linkUrl?e.jsxs(e.Fragment,{children:[e.jsx("a",{href:x.linkUrl,target:"_blank",rel:"noopener noreferrer",style:{color:"var(--metakyc-primary, #6366f1)",textDecoration:"underline"},children:x.linkText||x.label}),x.label&&x.linkText?` ${x.label}`:""]}):x.displayText||x.label})]}),x.helpText)},K)}if(x.customType==="group_checkbox"){const m=Array.isArray(Z)?Z:Z?[Z]:[],C=F=>{x.singleSelect?fe(u=>({...u,[H]:m[0]===F?[]:[F]})):fe(u=>({...u,[H]:m.includes(F)?m.filter(l=>l!==F):[...m,F]}))};return e.jsx("div",{style:ae(x.colSpan),children:ke(e.jsxs("div",{className:"space-y-1.5",children:[x.label&&e.jsx("p",{className:"text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:x.displayText||x.label}),(x.options||[]).map(F=>e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:8,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:m.includes(F.value),onChange:()=>C(F.value),style:{width:16,height:16,flexShrink:0,marginTop:2,accentColor:"var(--metakyc-primary, #6366f1)"}}),e.jsx("span",{className:"text-sm",style:{color:"var(--metakyc-text-primary, #111827)"},children:F.label})]},F.value))]}),x.helpText)},K)}return x.customType==="radio_group"?e.jsx("div",{style:ae(x.colSpan),children:ke(e.jsxs("div",{className:"space-y-1.5",children:[x.label&&e.jsx("p",{className:"text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:x.displayText||x.label}),(x.options||[]).map(m=>e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:8,cursor:"pointer"},children:[e.jsx("input",{type:"radio",name:`rg-${H}`,value:m.value,checked:Z===m.value,onChange:()=>fe(C=>({...C,[H]:m.value})),style:{width:16,height:16,flexShrink:0,marginTop:2,accentColor:"var(--metakyc-primary, #6366f1)"}}),e.jsx("span",{className:"text-sm",style:{color:"var(--metakyc-text-primary, #111827)"},children:m.label})]},m.value))]}),x.helpText)},K):e.jsx("div",{style:ae(x.colSpan),children:ke(e.jsx(ye,{label:x.displayText||x.label||H,value:String(Z??""),onChange:m=>fe(C=>({...C,[H]:m.target.value}))}),x.helpText)},K)},Xe=(x,M)=>{if(x.isCustom)return Oe(x,M);const K=x.name??"",H=Qe[K],Z=x.displayText||(H==null?void 0:H.label)||K,m=he[K]??"",C=K==="mobileCountryCode",F=!!(H!=null&&H.countriesType)&&!C;return x.editable?C?e.jsx("div",{style:ae(x.colSpan??2),children:ke(e.jsx(De,{label:Z,value:String(m),onChange:u=>le(l=>({...l,[K]:u})),options:[{value:"",label:"Select country code…"},...U]}),x.helpText)},`epc-${M}`):F?e.jsx("div",{style:ae(x.colSpan??2),children:ke(e.jsx(De,{label:Z,value:String(m),onChange:u=>le(l=>({...l,[K]:u})),options:[{value:"",label:`Select ${Z.toLowerCase()}…`},...L]}),x.helpText)},`ec-${M}`):e.jsx("div",{style:ae(x.colSpan??2),children:ke(e.jsx(ye,{label:Z,type:(H==null?void 0:H.type)==="date"?"date":(H==null?void 0:H.type)==="email"?"email":"text",value:String(m),onChange:u=>le(l=>({...l,[K]:u.target.value}))}),x.helpText)},`ei-${M}`):e.jsx("div",{style:ae(x.colSpan??2),children:ke(e.jsxs(e.Fragment,{children:[e.jsx("label",{className:"block text-sm font-medium mb-0.5",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:Z}),e.jsx("p",{className:"text-sm",style:{color:"var(--metakyc-text-primary, #111827)",minHeight:"1.5rem"},children:ve(K,m)})]}),x.helpText)},`ro-${M}`)};if(I){const x=I.title||"Review Your Information",M=I.subtitle||"Please review and confirm your information before starting identity verification";return e.jsx("form",{onSubmit:K=>{K.preventDefault(),N()},children:e.jsxs(ee,{children:[e.jsxs(ge,{children:[e.jsx("h2",{className:"text-lg font-bold",style:{color:"var(--metakyc-text-primary, #111827)"},children:x}),e.jsx("p",{className:"mt-1 text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:M})]}),e.jsx(te,{children:e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, minmax(0, 1fr))",gap:"1rem"},children:I.fields.map((K,H)=>Xe(K,H))})}),e.jsxs(be,{className:"flex justify-between",children:[s&&e.jsx(J,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(J,{type:"submit",isLoading:T,children:"Confirm and Start Verification"})]})]})})}return e.jsx("form",{onSubmit:_.handleSubmit(N),children:e.jsxs(ee,{children:[e.jsxs(ge,{children:[e.jsx("h2",{className:"text-lg font-bold",style:{color:"var(--metakyc-text-primary, #111827)"},children:"Review Your Information"}),e.jsx("p",{className:"mt-1 text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"Please review and confirm your information before starting identity verification"})]}),e.jsxs(te,{className:"space-y-6",children:[e.jsx("div",{className:"space-y-4 pb-4",style:{borderBottom:"1px solid var(--metakyc-border, #e5e7eb)"},children:[{label:"Name",value:`${((Ge=D==null?void 0:D.applicantRequestData)==null?void 0:Ge.firstName)||""} ${((ze=D==null?void 0:D.applicantRequestData)==null?void 0:ze.lastName)||""}`.trim()},{label:"Email",value:(et=D==null?void 0:D.applicantRequestData)==null?void 0:et.email},{label:"Date of Birth",value:((Ue=D==null?void 0:D.applicantRequestData)==null?void 0:Ue.dateOfBirth)||"Not provided"}].map(({label:x,value:M})=>e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:x}),e.jsx("p",{className:"mt-1 text-base",style:{color:"var(--metakyc-text-primary, #111827)"},children:M})]},x))}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-base font-semibold",style:{color:"var(--metakyc-text-primary, #111827)"},children:"Address Information"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(qe.Controller,{control:_.control,name:"country",render:({field:x})=>e.jsx(De,{label:"Country",value:x.value,onChange:x.onChange,options:[{value:"",label:"Select country…"},...L]})}),e.jsx(qe.Controller,{control:_.control,name:"nationality",render:({field:x})=>e.jsx(De,{label:"Nationality",value:x.value,onChange:x.onChange,options:[{value:"",label:"Select nationality…"},...L]})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(qe.Controller,{control:_.control,name:"street",render:({field:x})=>e.jsx(ye,{...x,label:"Street"})}),e.jsx(qe.Controller,{control:_.control,name:"streetNumber",render:({field:x})=>e.jsx(ye,{...x,label:"Street Number"})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(qe.Controller,{control:_.control,name:"city",render:({field:x})=>e.jsx(ye,{...x,label:"City"})}),e.jsx(qe.Controller,{control:_.control,name:"zip",render:({field:x})=>e.jsx(ye,{...x,label:"ZIP / Postal Code"})})]}),e.jsx(qe.Controller,{control:_.control,name:"phonenumber",render:({field:x})=>e.jsx(ye,{...x,label:"Phone Number",type:"tel"})})]})]}),e.jsxs(be,{className:"flex justify-between",children:[s&&e.jsx(J,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(J,{type:"submit",isLoading:T,children:"Confirm and Start Verification"})]})]})})},ft=({kycStatus:t,reviewStatus:r,workflowResult:s,customMessage:n,onContinue:a,onContactSupport:o})=>{const d=t===Ve.Approved?{type:"success",title:"Verification Approved",icon:"✓",iconBg:"bg-green-100 dark:bg-green-900/30",iconColor:"text-green-600 dark:text-green-400",message:"Your identity verification has been successfully approved."}:t===Ve.Rejected?{type:"error",title:"Verification Rejected",icon:"✕",iconBg:"bg-red-100 dark:bg-red-900/30",iconColor:"text-red-600 dark:text-red-400",message:"Unfortunately, your identity verification was not approved."}:t===Ve.Pending||t===Ve.InProgress?{type:"pending",title:"Verification Pending",icon:"⏱",iconBg:"bg-blue-100 dark:bg-blue-900/30",iconColor:"text-blue-600 dark:text-blue-400",message:"Your identity verification is currently being processed."}:r===Ye.Approved?{type:"success",title:"Application Approved",icon:"✓",iconBg:"bg-green-100 dark:bg-green-900/30",iconColor:"text-green-600 dark:text-green-400",message:"Your application has been approved."}:r===Ye.Reject?{type:"error",title:"Application Rejected",icon:"✕",iconBg:"bg-red-100 dark:bg-red-900/30",iconColor:"text-red-600 dark:text-red-400",message:"Your application has been rejected."}:r===Ye.UnderReview||r===Ye.AdminReview?{type:"pending",title:"Under Review",icon:"📋",iconBg:"bg-yellow-100 dark:bg-yellow-900/30",iconColor:"text-yellow-700 dark:text-yellow-400",message:"Your application is currently under manual review."}:s===ot.Success?{type:"success",title:"Process Complete",icon:"✓",iconBg:"bg-green-100 dark:bg-green-900/30",iconColor:"text-green-600 dark:text-green-400",message:"Your verification process has been completed successfully."}:s===ot.Failed?{type:"error",title:"Process Failed",icon:"✕",iconBg:"bg-red-100 dark:bg-red-900/30",iconColor:"text-red-600 dark:text-red-400",message:"The verification process could not be completed."}:s===ot.AdminReview?{type:"pending",title:"Admin Review Required",icon:"📋",iconBg:"bg-yellow-100 dark:bg-yellow-900/30",iconColor:"text-yellow-700 dark:text-yellow-400",message:"Your application requires administrator review."}:{type:"pending",title:"Processing",icon:"⏱",iconBg:"bg-blue-100 dark:bg-blue-900/30",iconColor:"text-blue-600 dark:text-blue-400",message:"Your application is being reviewed."};return e.jsxs(ee,{children:[e.jsxs(te,{className:"py-12",children:[e.jsx("div",{className:"flex justify-center mb-6",children:e.jsx("div",{className:`w-24 h-24 rounded-full flex items-center justify-center ${d.iconBg}`,children:e.jsx("span",{className:`text-5xl ${d.iconColor}`,children:d.icon})})}),e.jsx("h2",{className:"text-3xl font-bold text-center mb-4",style:{color:"var(--metakyc-text-primary, #111827)"},children:d.title}),e.jsx("div",{className:"flex justify-center mb-6",children:e.jsx(kt,{variant:d.type==="success"?"success":d.type==="error"?"danger":d.type==="pending"?"warning":"info",children:t!=null?Ve[t]:Ye[r]})}),e.jsx("p",{className:"text-center mb-6 max-w-md mx-auto",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:n||d.message}),d.type==="success"&&e.jsxs("div",{className:"bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg p-4 mb-6",children:[e.jsx("h3",{className:"font-semibold text-green-900 dark:text-green-100 mb-2",children:"What's Next?"}),e.jsxs("ul",{className:"text-sm text-green-800 dark:text-green-200 space-y-1",children:[e.jsx("li",{children:"✓ Your identity has been verified"}),e.jsx("li",{children:"✓ You can now proceed with your application"}),e.jsx("li",{children:"✓ All features are now accessible"})]})]}),d.type==="error"&&e.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4 mb-6",children:[e.jsx("h3",{className:"font-semibold text-red-900 dark:text-red-100 mb-2",children:"What Can You Do?"}),e.jsxs("ul",{className:"text-sm text-red-800 dark:text-red-200 space-y-2",children:[e.jsx("li",{children:"• Review the requirements and ensure all information is correct"}),e.jsx("li",{children:"• Contact our support team for assistance"}),e.jsx("li",{children:"• You may be able to resubmit your application"})]})]}),d.type==="pending"&&e.jsxs("div",{className:"bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg p-4 mb-6",children:[e.jsx("h3",{className:"font-semibold text-blue-900 dark:text-blue-100 mb-2",children:"What Happens Next?"}),e.jsxs("ul",{className:"text-sm text-blue-800 dark:text-blue-200 space-y-2",children:[e.jsx("li",{children:"• Our team is reviewing your information"}),e.jsx("li",{children:"• You will be notified via email once the review is complete"}),e.jsx("li",{children:"• This typically takes 24-48 hours"}),e.jsx("li",{children:"• No action is required from you at this time"})]})]}),e.jsx("div",{className:"mt-6 pt-6",style:{borderTop:"1px solid var(--metakyc-border, #e5e7eb)"},children:e.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:"KYC Status:"}),e.jsx("div",{className:"font-medium mt-1",style:{color:"var(--metakyc-text-primary, #111827)"},children:t!=null?Ve[t]:"Not Available"})]}),e.jsxs("div",{children:[e.jsx("span",{style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:"Review Status:"}),e.jsx("div",{className:"font-medium mt-1",style:{color:"var(--metakyc-text-primary, #111827)"},children:Ye[r]})]})]})})]}),e.jsxs(be,{className:"flex justify-center gap-4",children:[d.type==="success"&&a&&e.jsx(J,{onClick:a,size:"lg",children:"Continue"}),d.type==="error"&&e.jsxs(e.Fragment,{children:[o&&e.jsx(J,{variant:"outline",onClick:o,children:"Contact Support"}),a&&e.jsx(J,{onClick:a,children:"Try Again"})]}),d.type==="pending"&&e.jsx("div",{className:"text-center",children:e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Please check back later or wait for our email notification"})})]})]})},Hr=({config:t,className:r=""})=>!(t!=null&&t.visible)||!(t!=null&&t.url)?null:e.jsx("div",{className:`metakyc-logo ${r}`,children:e.jsx("img",{src:t.url,alt:t.alt||"Company Logo",style:{width:t.width||"auto",height:t.height||"40px",maxWidth:"100%",objectFit:"contain"},onError:s=>{console.warn("[Logo] Failed to load logo:",t.url),s.target.style.display="none"}})}),nt=({title:t,subtitle:r,className:s=""})=>{const{currentTheme:n}=Ne(),a=t||(n==null?void 0:n.title)||"",o=!!(n!=null&&n.logo&&n.logo.visible&&n.logo.url),c=!!a;return!o&&!c?null:e.jsxs("div",{className:`metakyc-header ${s}`,children:[e.jsxs("div",{className:"metakyc-header-title flex items-center text-xl font-bold",style:{color:"var(--metakyc-text-primary, #111827)"},children:[o&&e.jsx(Hr,{config:n.logo}),o&&c&&e.jsx("span",{style:{fontSize:"1.5rem",fontWeight:300,color:"var(--metakyc-text-muted, #9ca3af)",margin:"0 12px"},children:"|"}),c&&e.jsx("span",{style:{color:"var(--metakyc-text-primary, #111827)"},children:a})]}),r&&e.jsx("p",{className:"text-sm mt-1",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:r})]})},dt=["firstName","lastName","email","phonenumber","dateOfBirth"];function tt(t){return t==null||t===""||Array.isArray(t)&&t.length===0}const it={width:"16px",height:"16px",minWidth:"16px",flexShrink:0,flexGrow:0,accentColor:"var(--metakyc-primary, #2563eb)",cursor:"pointer",margin:0,padding:0,display:"inline-block",verticalAlign:"middle"},It=({helpText:t,children:r})=>{const[s,n]=i.useState(!1);if(!t)return e.jsx(e.Fragment,{children:r});const a=s?e.jsx("div",{role:"dialog","aria-modal":"true",onClick:()=>n(!1),style:{position:"fixed",inset:0,zIndex:999999,background:"rgba(0, 0, 0, 0.55)",backdropFilter:"blur(6px)",WebkitBackdropFilter:"blur(6px)",display:"flex",alignItems:"center",justifyContent:"center",padding:"16px"},children:e.jsxs("div",{onClick:o=>o.stopPropagation(),style:{background:"var(--metakyc-surface, var(--metakyc-background, #ffffff))",border:"1px solid var(--metakyc-border, #e5e7eb)",borderRadius:"12px",padding:"28px 24px 24px",maxWidth:"480px",width:"100%",maxHeight:"80vh",overflowY:"auto",boxShadow:"0 24px 64px rgba(0,0,0,0.4)",position:"relative"},children:[e.jsx("button",{type:"button",onClick:()=>n(!1),"aria-label":"Close",style:{position:"absolute",top:"12px",right:"12px",width:"28px",height:"28px",borderRadius:"50%",border:"1px solid var(--metakyc-border, #e5e7eb)",background:"var(--metakyc-input-bg, #f3f4f6)",color:"var(--metakyc-text-secondary, #6b7280)",fontSize:"16px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1},children:"×"}),e.jsx("div",{style:{color:"var(--metakyc-text-primary, #111827)",fontSize:"14px",lineHeight:1.75},dangerouslySetInnerHTML:{__html:t}})]})}):null;return e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"5px",flexWrap:"nowrap"},children:[r,e.jsx("button",{type:"button",className:"metakyc-help-btn",onClick:()=>n(!0),"aria-label":"Help",style:{flexShrink:0,marginTop:"2px",width:"18px",height:"18px",borderRadius:"50%",border:"1.5px solid var(--metakyc-primary, #2563eb)",background:"transparent",color:"var(--metakyc-primary, #2563eb)",fontSize:"10px",fontWeight:"700",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1,padding:0,position:"relative",zIndex:2,transition:"background 0.15s, color 0.15s"},onMouseEnter:o=>{o.currentTarget.style.background="var(--metakyc-primary, #2563eb)",o.currentTarget.style.color="#ffffff"},onMouseLeave:o=>{o.currentTarget.style.background="transparent",o.currentTarget.style.color="var(--metakyc-primary, #2563eb)"},children:"?"}),typeof document<"u"&&a?pt.createPortal(a,document.body):null]})},Es=({workflowKey:t,externalRefId:r,onSuccess:s,onCancel:n})=>{var K,H,Z,m,C,F,u;const{config:a,baseInformationService:o,currentTheme:c}=Ne(),{createApplicant:d,isLoading:y}=vt(),p=t||((K=a.applicantForm)==null?void 0:K.workflowKey);if(!p)throw new Error("workflowKey is required. Provide it either as a prop to CreateApplicantForm or set it in config.applicantForm.workflowKey");const b=r||((H=a.applicantForm)==null?void 0:H.externalRefId)||"",T=((Z=a.applicantForm)==null?void 0:Z.email)||"",v=((m=a.applicantForm)==null?void 0:m.hiddenValues)||{},E=((C=a.applicantForm)==null?void 0:C.initialValues)||{},k=(((F=a.applicantForm)==null?void 0:F.fieldLabelMode)||(c==null?void 0:c.fieldLabelMode)||"label")!=="placeholder",S=i.useMemo(()=>c!=null&&c.applicantFormPages&&c.applicantFormPages.length>0?c.applicantFormPages:null,[c==null?void 0:c.applicantFormPages]),D=i.useMemo(()=>{const l=new Set(dt),h=c==null?void 0:c.applicantFormRequiredFields;if(h)for(const P of h)l.add(P);if(S)for(const P of S)for(const g of P.fields)!g.isCustom&&g.name&&g.required&&l.add(g.name);return Array.from(l)},[c==null?void 0:c.applicantFormRequiredFields,S]),Y=i.useMemo(()=>{var P;if(S){const g=S.flatMap(j=>j.fields).filter(j=>!j.isCustom&&j.name).map(j=>j.name),w=new Set(g);for(const j of dt)w.add(j);return Array.from(w)}let l;(P=a.applicantForm)!=null&&P.visibleFields?l=a.applicantForm.visibleFields:c!=null&&c.applicantFormVisibleFields&&c.applicantFormVisibleFields.length>0?l=c.applicantFormVisibleFields:l=Ht;const h=new Set(l);for(const g of dt)h.add(g);return Array.from(h)},[(u=a.applicantForm)==null?void 0:u.visibleFields,c==null?void 0:c.applicantFormVisibleFields,S]),L=new Set(["country","nationality","taxCountry","countryOfBirth","mobileCountryCode","otherNationality"]),B=i.useMemo(()=>{var h,P;const l=new Set;if(S)for(const g of S)for(const w of g.fields)!w.isCustom&&w.name&&L.has(w.name)&&l.add(w.countriesType??((h=Qe[w.name])==null?void 0:h.countriesType));else for(const g of Y)L.has(g)&&l.add((P=Qe[g])==null?void 0:P.countriesType);return l.size===0&&l.add(void 0),Array.from(l)},[Y,S]),[U,X]=i.useState({}),[R,f]=i.useState(!0),O=i.useRef(new Set),q=i.useRef(new Set);i.useEffect(()=>{if(!c)return;const l=B.filter(g=>{const w=g!=null?String(g):"all";return!q.current.has(w)&&!O.current.has(w)});if(l.length===0){B.every(w=>{const j=w!=null?String(w):"all";return q.current.has(j)})&&f(!1);return}f(!0);const h=l.map(g=>g!=null?String(g):"all");h.forEach(g=>O.current.add(g)),(async()=>{try{const g=await Promise.all(l.map(async w=>{const j=w!=null?String(w):"all",ce=await o.getCountries("",a.locale||"en",w),se=w===40,xe=new Set,Ie=ce.map(ie=>se&&ie.countryCode?{value:ie.countryCode,label:`${ie.countryCode} – ${ie.name}`}:{value:ie.abbreviation3||ie.abbreviation,label:ie.name}).filter(ie=>!ie.value||xe.has(ie.value)?!1:(xe.add(ie.value),!0));return q.current.add(j),O.current.delete(j),[j,Ie]}));X(w=>({...w,...Object.fromEntries(g)}))}catch(g){h.forEach(w=>O.current.delete(w)),console.error("Failed to load countries:",g)}finally{B.every(w=>{const j=w!=null?String(w):"all";return q.current.has(j)})&&f(!1)}})()},[B,c]);const Q=(l,h)=>{var w;const P=h??((w=Qe[l])==null?void 0:w.countriesType),g=P!=null?String(P):"all";return U[g]||[]},$={firstName:1,lastName:1,title:1,email:1,dateOfBirth:1,phonenumber:1,mobileCountryCode:1,street:1,streetNumber:1,zip:1,city:1,country:1,nationality:1,otherNationality:1,defaultLanguage:1,taxCountry:1,placeOfBirth:1,countryOfBirth:1,salutation:1,educationLevel:1,occupation:1,taxNumber:1},G=Object.fromEntries(Object.entries(v).filter(([l])=>l in $)),ne=Object.fromEntries(Object.entries(E).filter(([l])=>l in $)),[V,he]=i.useState({workflowKey:p,firstName:"",lastName:"",title:"",email:T,dateOfBirth:"",phonenumber:"",externalRefId:b,mobileCountryCode:"",street:"",streetNumber:"",zip:"",city:"",country:"",nationality:"",otherNationality:[],defaultLanguage:"EN",taxCountry:"",placeOfBirth:"",countryOfBirth:"",salutation:null,educationLevel:"",occupation:"",taxNumber:"",...G,...ne}),le=Object.fromEntries(Object.entries(v).filter(([l])=>!(l in G)&&l!=="externalRefId"&&l!=="workflowKey")),[de,fe]=i.useState({...le}),[I,W]=i.useState(0),[z,_]=i.useState({}),[me,N]=i.useState(null),[re,ue]=i.useState(!1),ae=(l,h)=>he(P=>({...P,[l]:h})),ve=(l,h)=>fe(P=>({...P,[l]:h})),Fe=l=>!l.conditionalOn||de[l.conditionalOn]==="true",ke=S&&I<S.length-1?I+1:-1,Oe=S&&I>0?I-1:-1,Xe=l=>{var P;const h={};for(const g of l.fields)if(g.isCustom){if(g.customType==="paragraph"||g.customType==="html"||g.customType==="br"||g.customType==="link")continue;if(g.required&&g.paramName){const w=de[g.paramName],j=g.displayText||g.label||g.paramName;g.customType==="checkbox"||g.customType==="link_checkbox"?w!=="true"&&(h[g.paramName]=`${j} is required.`):(!w||w.trim()==="")&&(h[g.paramName]=`${j} is required.`)}}else if(g.name){const w=g.name;if(D.includes(w)&&tt(V[w])){const j=g.displayText||((P=Qe[w])==null?void 0:P.label)||w;h[w]=`${j} is required.`}}return h},Ge=async()=>{if(!S)return;const l=S[I];if(l.conditionalOn&&!Fe(l)){_({}),ke>=0?W(ke):await ze();return}const h=Xe(l);if(Object.keys(h).length>0){_(h);return}_({}),ke>=0?W(ke):await ze()},ze=async()=>{if(S){let l={};for(const h of S)Fe(h)&&(l={...l,...Xe(h)});if(Object.keys(l).length>0){_(l);return}}ue(!0),N(null);try{if(!V.externalRefId||V.externalRefId.trim()===""){N("External Reference ID is required. Please pass it via config.applicantForm.externalRefId.");return}const l={workflowKey:V.workflowKey,externalRefId:V.externalRefId.trim()};if(S){for(const w of S)if(Fe(w)){for(const j of w.fields)if(!j.isCustom&&j.name){const ce=j.name,se=V[ce];tt(se)||(l[ce]=se)}}for(const w of dt)if(l[w]===void 0){const j=V[w];tt(j)||(l[w]=j)}}else Y.forEach(w=>{if(w==="externalRefId")return;const j=V[w];tt(j)||(l[w]=j)});const h=[];if(S){for(const w of S)if(Fe(w))for(const j of w.fields){if(!j.isCustom||!j.paramName||j.customType==="paragraph"||j.customType==="html"||j.customType==="br"||j.customType==="link")continue;const ce=de[j.paramName]??"";let se;if(j.customType==="checkbox"||j.customType==="link_checkbox")se=ce==="true"?"yes":"no";else if(se=ce,!se&&!j.required)continue;h.push({paramName:j.paramName,value:se})}}for(const[w,j]of Object.entries(G))l[w]===void 0&&!tt(j)&&(l[w]=j);const P=new Set(h.map(w=>w.paramName));for(const[w,j]of Object.entries(le))!P.has(w)&&j&&h.push({paramName:w,value:j});h.length>0&&(l.applicantAdditionalDatas=h);const g=await d(l);s(g.applicantId)}catch(l){console.error("Error creating applicant:",l),N(l.message||"Failed to create applicant")}finally{ue(!1)}},et=async l=>{var h;l.preventDefault();for(const P of D)if(tt(V[P])){const g=((h=Qe[P])==null?void 0:h.label)||P;N(`${g} is required.`);return}await ze()},Ue=(l,h,P,g,w)=>{var jt;const j=Qe[l];if(!j)return null;const ce=D.includes(l),se=z[l],xe=P||j.label,Ie=l in ne,ie=h??l,Pe={required:ce},$e=w?w!=="placeholder":k,Ke=$e?xe:void 0,Wr=$e?"...":xe;switch(j.type){case"select":if(l==="country"||l==="nationality"||l==="taxCountry"||l==="countryOfBirth"||l==="mobileCountryCode"){const Ce=Q(l,g);return e.jsx(De,{...Pe,label:Ke,value:V[l]||"",onChange:Je=>ae(l,Je),options:[{value:"",label:`Select ${Wr.toLowerCase()}`},...Ce],disabled:R,readOnly:Ie,error:se},ie)}if(l==="salutation")return e.jsx(De,{...Pe,label:Ke,value:((jt=V[l])==null?void 0:jt.toString())||"",onChange:Ce=>ae(l,Ce?Number(Ce):null),options:[{value:"",label:$e?"Select salutation...":xe},{value:lt.Male.toString(),label:"Male"},{value:lt.Female.toString(),label:"Female"},{value:lt.Other.toString(),label:"Other"}],readOnly:Ie,error:se},ie);if(l==="defaultLanguage"){const Ce=c!=null&&c.allowedLanguages&&c.allowedLanguages.length>0?ht.filter(Je=>c.allowedLanguages.includes(Je.value)):ht;return e.jsx(De,{...Pe,label:Ke,value:V[l]||"",onChange:Je=>ae(l,Je),options:[{value:"",label:$e?"Select language...":xe},...Ce],readOnly:Ie,error:se},ie)}return null;case"multiselect":if(l==="otherNationality"){const Ce=Q(l,g);return e.jsx(Ir,{...Pe,label:Ke,value:V[l]||[],onChange:Je=>ae(l,Je),options:Ce,placeholder:$e?"Select other nationalities...":xe,disabled:R,readOnly:Ie},ie)}return null;case"date":return e.jsx(ye,{...Pe,type:"date",label:Ke,placeholder:$e?void 0:xe,value:V[l]||"",onChange:Ce=>ae(l,Ce.target.value),readOnly:Ie,error:se},ie);case"email":return e.jsx(ye,{...Pe,type:"email",label:Ke,placeholder:$e?void 0:xe,value:V[l]||"",onChange:Ce=>ae(l,Ce.target.value),readOnly:Ie,error:se},ie);case"tel":return e.jsx(ye,{...Pe,type:"tel",label:Ke,placeholder:$e?void 0:xe,value:V[l]||"",onChange:Ce=>ae(l,Ce.target.value),readOnly:Ie,error:se},ie);default:return e.jsx(ye,{...Pe,type:"text",label:Ke,placeholder:$e?void 0:xe,value:V[l]||"",onChange:Ce=>ae(l,Ce.target.value),readOnly:Ie,error:se},ie)}},x=(l,h)=>{const P=l.labelMode?l.labelMode!=="placeholder":k;if(l.customType==="paragraph"){const j=l.displayText||l.label||"";return e.jsx("p",{className:"metakyc-paragraph",style:{fontSize:"14px",lineHeight:"1.7",margin:0,color:"var(--metakyc-text-secondary, #6b7280)"},dangerouslySetInnerHTML:{__html:j}},`custom-${h}`)}if(l.customType==="html")return e.jsx("div",{dangerouslySetInnerHTML:{__html:l.label||""}},`custom-${h}`);if(l.customType==="br")return e.jsx("div",{style:{height:"12px"}},`custom-${h}`);if(l.customType==="link"){const j=l.displayText||l.label||l.linkText||l.linkUrl||"";return e.jsx("div",{className:"metakyc-link-field",children:e.jsxs("a",{href:l.linkUrl||"#",target:"_blank",rel:"noopener noreferrer",style:{display:"inline-flex",alignItems:"center",gap:"4px",color:"var(--metakyc-primary, #2563eb)",fontSize:"14px",textDecoration:"underline",cursor:"pointer"},children:[j,e.jsx("span",{style:{fontSize:"10px",opacity:.7},children:"↗"})]})},`custom-${h}`)}if(!l.paramName)return null;const g=z[l.paramName],w=l.displayText||l.label||l.paramName;if(l.customType==="checkbox")return e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"checkbox",checked:de[l.paramName]==="true",onChange:j=>ve(l.paramName,j.target.checked?"true":"false"),className:"metakyc-option-input",style:it}),e.jsxs("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4"},children:[w,l.required&&e.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]})]}),g&&e.jsx("p",{className:"text-red-500 text-xs mt-0.5",children:g})]},`custom-${h}`);if(l.customType==="link_checkbox")return e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"checkbox",checked:de[l.paramName]==="true",onChange:j=>ve(l.paramName,j.target.checked?"true":"false"),className:"metakyc-option-input",style:{...it,alignSelf:"flex-start",marginTop:"2px"}}),e.jsxs("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4"},children:[w," ",l.linkUrl&&e.jsx("a",{href:l.linkUrl,target:"_blank",rel:"noopener noreferrer",className:"underline",style:{color:"var(--metakyc-primary, #2563eb)"},onClick:j=>j.stopPropagation(),children:l.linkText||l.linkUrl}),l.required&&e.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]})]}),g&&e.jsx("p",{className:"text-red-500 text-xs mt-0.5",children:g})]},`custom-${h}`);if(l.customType==="group_checkbox"){const j=(de[l.paramName]||"").split(",").filter(Boolean);return e.jsxs("div",{className:"flex flex-col gap-1.5",children:[P&&e.jsxs("div",{className:"text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:[w,l.required&&e.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]}),e.jsx("div",{className:"metakyc-options-group",style:{display:"flex",flexDirection:"column",gap:"8px"},children:(l.options||[]).map(ce=>{const se=l.singleSelect?de[l.paramName]===ce.value:j.includes(ce.value);return e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"checkbox",checked:se,onChange:xe=>{if(l.singleSelect)ve(l.paramName,xe.target.checked?ce.value:"");else{const Ie=xe.target.checked?[...j,ce.value]:j.filter(ie=>ie!==ce.value);ve(l.paramName,Ie.join(","))}},className:"metakyc-option-input",style:it}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4"},children:ce.label})]},ce.value)})}),g&&e.jsx("p",{className:"text-red-500 text-xs",children:g})]},`custom-${h}`)}return l.customType==="radio_group"?e.jsxs("div",{className:"flex flex-col gap-1.5",children:[P&&e.jsxs("div",{className:"text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:[w,l.required&&e.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]}),e.jsx("div",{className:"metakyc-options-group",style:{display:"flex",flexDirection:"column",gap:"8px"},children:(l.options||[]).map(j=>e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"radio",checked:de[l.paramName]===j.value,onChange:()=>ve(l.paramName,j.value),name:`radio-group-${l.paramName}-${h}`,className:"metakyc-option-input",style:it}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4"},children:j.label})]},j.value))}),g&&e.jsx("p",{className:"text-red-500 text-xs",children:g})]},`custom-${h}`):e.jsx(ye,{type:"text",label:P?`${w}${l.required?" *":""}`:void 0,placeholder:P?void 0:w,value:de[l.paramName]||"",onChange:j=>ve(l.paramName,j.target.value),required:l.required,error:g},`custom-${h}`)},M=(l,h)=>{const P=Fe(l);return e.jsxs("div",{className:"space-y-4",children:[l.conditionalOn&&e.jsx(It,{helpText:l.conditionalHelpText,children:e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"checkbox",checked:P,onChange:g=>ve(l.conditionalOn,g.target.checked?"true":"false"),className:"metakyc-option-input",style:it}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4",fontWeight:500},children:l.conditionalOn})]})}),P&&e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, minmax(0, 1fr))",gap:"1rem"},children:l.fields.map((g,w)=>{const j=Math.min(4,Math.max(1,Number(g.colSpan)||4)),ce=g.isCustom?`custom-${w}-${g.paramName}`:`builtin-${g.name}-${w}`;return e.jsx("div",{style:{gridColumn:`span ${j} / span ${j}`},children:e.jsx(It,{helpText:g.helpText,children:g.isCustom?x(g,w):Ue(g.name,ce,g.displayText,g.countriesType,g.labelMode)})},ce)})})]})};if(!c||R)return e.jsx("div",{className:"metakyc-sdk",children:e.jsx(ee,{children:e.jsxs(te,{children:[e.jsx(Ee,{className:"my-8"}),e.jsx("p",{className:"text-center mt-4",style:{color:"var(--metakyc-text-secondary, #6b7280)",fontSize:"0.875rem"},children:"Loading form…"})]})})});if(S){const l=S[I]??S[0],h=Oe===-1,P=ke===-1,g=S.length,w=Fe(l),j=Object.values(z);return e.jsx("div",{className:"metakyc-sdk",children:e.jsxs(ee,{children:[e.jsx(ge,{children:e.jsx(nt,{title:(c==null?void 0:c.title)||"Create Applicant"})}),e.jsxs(te,{children:[(l.title||l.subtitle||l.description)&&e.jsxs("div",{className:"mb-4",children:[l.title&&e.jsx("h3",{className:"font-semibold text-base",style:{color:"var(--metakyc-text-primary, #111827)"},children:l.title}),l.subtitle&&e.jsx("p",{className:"text-sm mt-0.5",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:l.subtitle}),l.description&&l.description!==l.subtitle&&e.jsx("p",{className:"text-xs mt-1",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:l.description})]}),(me||j.length>0)&&e.jsxs("div",{className:"mb-4 p-3 bg-red-50 border border-red-200 rounded-lg",children:[me&&e.jsxs("p",{className:"text-red-600 text-sm",children:[e.jsx("strong",{children:"Error:"})," ",me]}),j.map((ce,se)=>e.jsx("p",{className:"text-red-600 text-sm",children:ce},se))]}),g>1&&e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[S.map((ce,se)=>e.jsx("div",{className:`h-1.5 rounded-full transition-all ${se===I?"flex-1":"w-8"}`,style:se===I?{backgroundColor:"var(--metakyc-primary, #2563eb)"}:se<I?{backgroundColor:"var(--metakyc-primary-light, #93c5fd)",opacity:.7}:{backgroundColor:"#e5e7eb"}},se)),e.jsxs("span",{className:"text-xs text-gray-400 flex-shrink-0",children:[I+1," / ",g]})]}),M(l)]}),e.jsxs(be,{className:"flex justify-between",children:[e.jsxs("div",{children:[!h&&e.jsx(J,{type:"button",variant:"outline",onClick:()=>{W(Oe),_({})},disabled:re||y,children:"Previous"}),h&&n&&e.jsx(J,{type:"button",variant:"outline",onClick:n,disabled:re||y,children:"Cancel"})]}),e.jsx(J,{type:"button",isLoading:re||y,onClick:P?ze:Ge,children:P?l.conditionalOn&&!w?"Skip & Submit":"Submit":l.conditionalOn&&!w?"Skip":"Next"})]})]})})}return e.jsx("div",{className:"metakyc-sdk",children:e.jsx("form",{onSubmit:et,children:e.jsxs(ee,{children:[e.jsx(ge,{children:e.jsx(nt,{title:(c==null?void 0:c.title)||"Create Applicant"})}),e.jsxs(te,{children:[me&&e.jsx("div",{className:"mb-6 p-4 bg-red-50 border border-red-200 rounded-lg",children:e.jsxs("p",{className:"text-red-600 text-sm",children:[e.jsx("strong",{children:"Error:"})," ",me]})}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, minmax(0, 1fr))",gap:"1rem"},children:Y.map(l=>e.jsx("div",{style:{gridColumn:"span 4 / span 4"},children:Ue(l)},l))})]}),e.jsxs(be,{className:"flex justify-between",children:[n&&e.jsx(J,{type:"button",variant:"outline",onClick:n,disabled:re||y,children:"Cancel"}),e.jsx(J,{type:"submit",isLoading:re||y,children:"Create Applicant"})]})]})})})},Et=["companyName","email"];function xt(t){return t==null||t===""||Array.isArray(t)&&t.length===0}const As=({workflowKey:t,externalRefId:r,onSuccess:s,onCancel:n})=>{var Ue,x,M,K,H,Z;const{config:a,baseInformationService:o,currentTheme:c}=Ne(),{createCompanyApplicant:d,isLoading:y}=vt(),p=t||((Ue=a.applicantForm)==null?void 0:Ue.workflowKey);if(!p)throw new Error("workflowKey is required. Provide it either as a prop to CreateCompanyApplicantForm or set it in config.applicantForm.workflowKey");const b=r||((x=a.applicantForm)==null?void 0:x.externalRefId)||"",T=((M=a.applicantForm)==null?void 0:M.email)||"",v=((K=a.applicantForm)==null?void 0:K.initialValues)||{},A=(((H=a.applicantForm)==null?void 0:H.fieldLabelMode)||(c==null?void 0:c.fieldLabelMode)||"label")!=="placeholder",k=i.useMemo(()=>c!=null&&c.companyFormPages&&c.companyFormPages.length>0?c.companyFormPages:null,[c==null?void 0:c.companyFormPages]),S=i.useMemo(()=>{const m=new Set(Et),C=c==null?void 0:c.companyFormRequiredFields;if(C)for(const F of C)m.add(F);if(k)for(const F of k)for(const u of F.fields)!u.isCustom&&u.name&&u.required&&m.add(u.name);return Array.from(m)},[c==null?void 0:c.companyFormRequiredFields,k]),D=i.useMemo(()=>{var m;if(k){const C=k.flatMap(u=>u.fields).filter(u=>!u.isCustom&&u.name).map(u=>u.name),F=new Set(C);for(const u of Et)F.add(u);return Array.from(F)}return(m=a.applicantForm)!=null&&m.visibleFields?a.applicantForm.visibleFields:c!=null&&c.companyFormVisibleFields&&c.companyFormVisibleFields.length>0?c.companyFormVisibleFields:_t},[(Z=a.applicantForm)==null?void 0:Z.visibleFields,c==null?void 0:c.companyFormVisibleFields,k]),Y=new Set(["countryResidence","addressCountry"]),L=i.useMemo(()=>{var C,F;const m=new Set;if(k)for(const u of k)for(const l of u.fields)!l.isCustom&&l.name&&Y.has(l.name)&&m.add(l.countriesType??((C=Ze[l.name])==null?void 0:C.countriesType));else for(const u of D)Y.has(u)&&m.add((F=Ze[u])==null?void 0:F.countriesType);return m.size===0&&m.add(void 0),Array.from(m)},[D,k]),[B,U]=i.useState({}),[X,R]=i.useState(!0),f=i.useRef(new Set),O=i.useRef(new Set);i.useEffect(()=>{if(!c)return;const m=L.filter(u=>{const l=u!=null?String(u):"all";return!O.current.has(l)&&!f.current.has(l)});if(m.length===0){L.every(l=>O.current.has(l!=null?String(l):"all"))&&R(!1);return}R(!0);const C=m.map(u=>u!=null?String(u):"all");C.forEach(u=>f.current.add(u)),(async()=>{try{const u=await Promise.all(m.map(async l=>{const h=l!=null?String(l):"all",P=await o.getCountries("",a.locale||"en",l),g=new Set,w=P.map(j=>({value:j.abbreviation3||j.abbreviation,label:j.name})).filter(j=>!j.value||g.has(j.value)?!1:(g.add(j.value),!0));return O.current.add(h),f.current.delete(h),[h,w]}));U(l=>({...l,...Object.fromEntries(u)}))}catch(u){C.forEach(l=>f.current.delete(l)),console.error("Failed to load countries:",u)}finally{L.every(l=>O.current.has(l!=null?String(l):"all"))&&R(!1)}})()},[L,c]);const q=(m,C)=>{var l;const F=C??((l=Ze[m])==null?void 0:l.countriesType),u=F!=null?String(F):"all";return B[u]||[]},Q={companyName:1,registrationNumber:1,email:1,phone:1,countryResidence:1,legalAddress:1,incorporatedOn:1,controlScheme:1,taxId:1,registrationLocation:1,website:1,postalAddress:1,street:1,streetNumber:1,city:1,state:1,postalCode:1,addressCountry:1,lei:1},$=Object.fromEntries(Object.entries(v).filter(([m])=>m in Q)),[G,ne]=i.useState({workflowKey:p,companyName:"",email:T,phone:"",registrationNumber:"",countryResidence:"",legalAddress:"",incorporatedOn:"",controlScheme:"",taxId:"",registrationLocation:"",website:"",postalAddress:"",street:"",streetNumber:"",city:"",state:"",postalCode:"",addressCountry:"",lei:"",externalRefId:b,...$}),[V,he]=i.useState({}),[le,de]=i.useState(0),[fe,I]=i.useState({}),[W,z]=i.useState(null),[_,me]=i.useState(!1),N=(m,C)=>ne(F=>({...F,[m]:C})),re=(m,C)=>he(F=>({...F,[m]:C})),ue=m=>!m.conditionalOn||V[m.conditionalOn]==="true",ae=k&&le<k.length-1?le+1:-1,ve=k&&le>0?le-1:-1,Fe=m=>{var F;const C={};for(const u of m.fields)if(u.isCustom){if(u.customType==="paragraph"||u.customType==="html"||u.customType==="br"||u.customType==="link")continue;if(u.required&&u.paramName){const l=V[u.paramName],h=u.displayText||u.label||u.paramName;u.customType==="checkbox"||u.customType==="link_checkbox"?l!=="true"&&(C[u.paramName]=`${h} is required.`):(!l||l.trim()==="")&&(C[u.paramName]=`${h} is required.`)}}else if(u.name){const l=u.name;if(S.includes(l)&&xt(G[l])){const h=u.displayText||((F=Ze[l])==null?void 0:F.label)||l;C[l]=`${h} is required.`}}return C},ke=async()=>{if(!k)return;const m=k[le];if(m.conditionalOn&&!ue(m)){I({}),ae>=0?de(ae):await Oe();return}const C=Fe(m);if(Object.keys(C).length>0){I(C);return}I({}),ae>=0?de(ae):await Oe()},Oe=async()=>{var m;if(k){let C={};for(const F of k)ue(F)&&(C={...C,...Fe(F)});if(Object.keys(C).length>0){I(C);return}}me(!0),z(null);try{const C={workflowKey:G.workflowKey,externalRefId:((m=G.externalRefId)==null?void 0:m.trim())||void 0},F=k?k.filter(h=>ue(h)).flatMap(h=>h.fields).filter(h=>!h.isCustom&&h.name).map(h=>h.name):D;for(const h of F){const P=G[h];if(!xt(P))switch(h){case"companyName":C.companyName=P;break;case"email":C.companyEmail=P;break;case"phone":C.companyPhone=P;break;case"registrationNumber":C.companyRegistrationNumber=P;break;case"countryResidence":C.companyCountry=P;break;case"city":C.companyCity=P;break;case"street":C.companyStreet=P;break;case"postalCode":C.companyZip=P;break;default:C[h]=P;break}}const u=[];if(k){for(const h of k)if(ue(h))for(const P of h.fields){if(!P.isCustom||!P.paramName||P.customType==="paragraph"||P.customType==="html"||P.customType==="br"||P.customType==="link")continue;const g=V[P.paramName]??"";let w;if(P.customType==="checkbox"||P.customType==="link_checkbox")w=g==="true"?"yes":"no";else if(w=g,!w&&!P.required)continue;u.push({paramName:P.paramName,value:w})}}u.length>0&&(C.applicantAdditionalDatas=u);const l=await d(C);s(l.applicantId)}catch(C){console.error("Error creating company applicant:",C),z(C.message||"Failed to create company applicant")}finally{me(!1)}},Xe=async m=>{var C;m.preventDefault();for(const F of S)if(xt(G[F])){const u=((C=Ze[F])==null?void 0:C.label)||F;z(`${u} is required.`);return}await Oe()},Ge=(m,C,F,u,l)=>{const h=Ze[m];if(!h)return null;const P=S.includes(m),g=fe[m],w=F||h.label,j=m in $,ce=C??m,se=l?l!=="placeholder":A,xe=se?w:void 0,Ie=se?"...":w;switch(h.type){case"select":if(m==="countryResidence"||m==="addressCountry"){const ie=q(m,u);return e.jsx(De,{required:P,label:xe,value:G[m]||"",onChange:Pe=>N(m,Pe),options:[{value:"",label:`Select ${Ie.toLowerCase()}`},...ie],disabled:X,readOnly:j,error:g},ce)}return null;case"date":return e.jsx(ye,{required:P,type:"date",label:xe,placeholder:se?void 0:w,value:G[m]||"",onChange:ie=>N(m,ie.target.value),readOnly:j,error:g},ce);case"email":return e.jsx(ye,{required:P,type:"email",label:xe,placeholder:se?void 0:w,value:G[m]||"",onChange:ie=>N(m,ie.target.value),readOnly:j,error:g},ce);case"tel":return e.jsx(ye,{required:P,type:"tel",label:xe,placeholder:se?void 0:w,value:G[m]||"",onChange:ie=>N(m,ie.target.value),readOnly:j,error:g},ce);default:return e.jsx(ye,{required:P,type:"text",label:xe,placeholder:se?void 0:w,value:G[m]||"",onChange:ie=>N(m,ie.target.value),readOnly:j,error:g},ce)}},ze=(m,C)=>{if(m.customType==="paragraph")return e.jsx("p",{style:{fontSize:"14px",lineHeight:"1.7",margin:0,color:"var(--metakyc-text-secondary, #6b7280)"},dangerouslySetInnerHTML:{__html:m.displayText||m.label||""}},`custom-${C}`);if(m.customType==="html")return e.jsx("div",{dangerouslySetInnerHTML:{__html:m.label||""}},`custom-${C}`);if(m.customType==="br")return e.jsx("div",{style:{height:"12px"}},`custom-${C}`);if(m.customType==="link")return e.jsx("div",{children:e.jsx("a",{href:m.linkUrl||"#",target:"_blank",rel:"noopener noreferrer",style:{color:"var(--metakyc-primary, #2563eb)",fontSize:"14px",textDecoration:"underline"},children:m.displayText||m.label||m.linkText||m.linkUrl||""})},`custom-${C}`);if(!m.paramName)return null;const F=fe[m.paramName],u=m.displayText||m.label||m.paramName,l=m.labelMode?m.labelMode!=="placeholder":A;return m.customType==="checkbox"?e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:V[m.paramName]==="true",onChange:h=>re(m.paramName,h.target.checked?"true":"false"),style:{width:"16px",height:"16px",accentColor:"var(--metakyc-primary, #2563eb)"}}),e.jsxs("span",{style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)"},children:[u,m.required&&e.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]})]}),F&&e.jsx("p",{className:"text-red-500 text-xs mt-0.5",children:F})]},`custom-${C}`):e.jsx(ye,{type:"text",label:l?`${u}${m.required?" *":""}`:void 0,placeholder:l?void 0:u,value:V[m.paramName]||"",onChange:h=>re(m.paramName,h.target.value),required:m.required,error:F},`custom-${C}`)},et=m=>{const C=ue(m);return e.jsxs("div",{className:"space-y-4",children:[m.conditionalOn&&e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:C,onChange:F=>re(m.conditionalOn,F.target.checked?"true":"false"),style:{width:"16px",height:"16px",accentColor:"var(--metakyc-primary, #2563eb)"}}),e.jsx("span",{style:{fontSize:"14px",fontWeight:500},children:m.conditionalOn})]}),C&&e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, minmax(0, 1fr))",gap:"1rem"},children:m.fields.map((F,u)=>{const l=Math.min(4,Math.max(1,Number(F.colSpan)||4)),h=F.isCustom?`custom-${u}-${F.paramName}`:`builtin-${F.name}-${u}`;return e.jsx("div",{style:{gridColumn:`span ${l} / span ${l}`},children:F.isCustom?ze(F,u):Ge(F.name,h,F.displayText,F.countriesType,F.labelMode)},h)})})]})};if(!c||X)return e.jsx("div",{className:"metakyc-sdk",children:e.jsx(ee,{children:e.jsxs(te,{children:[e.jsx(Ee,{className:"my-8"}),e.jsx("p",{className:"text-center mt-4",style:{color:"var(--metakyc-text-secondary, #6b7280)",fontSize:"0.875rem"},children:"Loading form…"})]})})});if(k){const m=k[le]??k[0],C=ve===-1,F=ae===-1,u=k.length,l=ue(m),h=Object.values(fe);return e.jsx("div",{className:"metakyc-sdk",children:e.jsxs(ee,{children:[e.jsx(ge,{children:e.jsx(nt,{title:(c==null?void 0:c.title)||"Company Registration"})}),e.jsxs(te,{children:[(m.title||m.subtitle)&&e.jsxs("div",{className:"mb-4",children:[m.title&&e.jsx("h3",{className:"font-semibold text-base",style:{color:"var(--metakyc-text-primary, #111827)"},children:m.title}),m.subtitle&&e.jsx("p",{className:"text-sm mt-0.5",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:m.subtitle})]}),(W||h.length>0)&&e.jsxs("div",{className:"mb-4 p-3 bg-red-50 border border-red-200 rounded-lg",children:[W&&e.jsxs("p",{className:"text-red-600 text-sm",children:[e.jsx("strong",{children:"Error:"})," ",W]}),h.map((P,g)=>e.jsx("p",{className:"text-red-600 text-sm",children:P},g))]}),u>1&&e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[k.map((P,g)=>e.jsx("div",{className:`h-1.5 rounded-full transition-all ${g===le?"flex-1":"w-8"}`,style:g===le?{backgroundColor:"var(--metakyc-primary, #2563eb)"}:g<le?{backgroundColor:"var(--metakyc-primary-light, #93c5fd)",opacity:.7}:{backgroundColor:"#e5e7eb"}},g)),e.jsxs("span",{className:"text-xs text-gray-400 flex-shrink-0",children:[le+1," / ",u]})]}),et(m)]}),e.jsxs(be,{className:"flex justify-between",children:[e.jsxs("div",{children:[!C&&e.jsx(J,{type:"button",variant:"outline",onClick:()=>{de(ve),I({})},disabled:_||y,children:"Previous"}),C&&n&&e.jsx(J,{type:"button",variant:"outline",onClick:n,disabled:_||y,children:"Cancel"})]}),e.jsx(J,{type:"button",isLoading:_||y,onClick:F?Oe:ke,children:F?m.conditionalOn&&!l?"Skip & Submit":"Submit":m.conditionalOn&&!l?"Skip":"Next"})]})]})})}return e.jsx("div",{className:"metakyc-sdk",children:e.jsx("form",{onSubmit:Xe,children:e.jsxs(ee,{children:[e.jsx(ge,{children:e.jsx(nt,{title:(c==null?void 0:c.title)||"Company Registration"})}),e.jsxs(te,{children:[W&&e.jsx("div",{className:"mb-6 p-4 bg-red-50 border border-red-200 rounded-lg",children:e.jsxs("p",{className:"text-red-600 text-sm",children:[e.jsx("strong",{children:"Error:"})," ",W]})}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, minmax(0, 1fr))",gap:"1rem"},children:D.map(m=>e.jsx("div",{style:{gridColumn:"span 4 / span 4"},children:Ge(m)},m))})]}),e.jsxs(be,{className:"flex justify-between",children:[n&&e.jsx(J,{type:"button",variant:"outline",onClick:n,disabled:_||y,children:"Cancel"}),e.jsx(J,{type:"submit",isLoading:_||y,children:"Register Company"})]})]})})})},Ts=({applicantId:t,onComplete:r,onError:s,theme:n="light",className:a})=>{const{progress:o,currentStep:c,steps:d,workflowKey:y,nextWorkflowKey:p,hasWorkflowChanged:b,isLoading:T,error:v,moveBack:E,refreshProgress:A}=jr(t),[k,S]=i.useState(!1),D=i.useRef(null);if(i.useEffect(()=>{v&&s&&s(v)},[v,s]),i.useEffect(()=>{o!=null&&o.workflowResult&&r&&r(o.workflowResult)},[o==null?void 0:o.workflowResult,r]),i.useEffect(()=>{n==="dark"?document.documentElement.classList.add("dark"):document.documentElement.classList.remove("dark")},[n]),i.useEffect(()=>{b&&S(!1)},[b]),T||!o)return e.jsx("div",{className:`metakyc-sdk ${a||""}`,children:e.jsx(ee,{children:e.jsxs(te,{children:[e.jsx(Ee,{className:"my-8"}),e.jsx("p",{className:"text-center mt-4",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"Loading workflow..."})]})})});if(v)return e.jsx("div",{className:`metakyc-sdk ${a||""}`,children:e.jsx(ee,{children:e.jsx(te,{children:e.jsxs("div",{className:"text-center py-8",children:[e.jsx("p",{className:"text-lg mb-4",style:{color:"var(--metakyc-danger, #ef4444)"},children:"An error occurred"}),e.jsx("p",{style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:v.message})]})})})});if(b&&!k)return e.jsx("div",{className:`metakyc-sdk ${a||""}`,children:e.jsx(ee,{children:e.jsx(te,{children:e.jsxs("div",{className:"text-center py-8",children:[e.jsx("div",{className:"mb-6",children:e.jsx("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-full mb-4",style:{backgroundColor:"var(--metakyc-primary-light, #dbeafe)"},children:e.jsx("svg",{className:"w-8 h-8",style:{color:"var(--metakyc-primary, #2563eb)"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})})}),e.jsx("h3",{className:"text-xl font-semibold mb-2",style:{color:"var(--metakyc-text-primary, #111827)"},children:"Workflow Transition"}),e.jsx("p",{className:"mb-6",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"Your application workflow has been updated based on your progress."}),e.jsxs("div",{className:"rounded-lg p-4 mb-6 max-w-md mx-auto",style:{backgroundColor:"var(--metakyc-surface, #f9fafb)"},children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"mb-1",style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:"Previous Workflow"}),e.jsx("p",{className:"font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:y})]}),e.jsx("svg",{className:"w-6 h-6 mx-4",style:{color:"var(--metakyc-text-muted, #9ca3af)"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 7l5 5m0 0l-5 5m5-5H6"})}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"mb-1",style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:"New Workflow"}),e.jsx("p",{className:"font-medium",style:{color:"var(--metakyc-primary, #2563eb)"},children:p})]})]}),o.nextWorkflowName&&e.jsx("p",{className:"text-center mt-2 text-xs",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:o.nextWorkflowName})]}),e.jsx("button",{onClick:()=>S(!0),className:"px-6 py-3 font-medium rounded-lg transition-opacity hover:opacity-90",style:{backgroundColor:"var(--metakyc-primary, #2563eb)",color:"#ffffff"},children:"Continue with New Workflow"})]})})})});if(o.status===Te.Finished||o.status===Te.OnHold)return e.jsx("div",{className:`metakyc-sdk ${a||""}`,children:e.jsx(ft,{kycStatus:o.kycStatus,reviewStatus:o.reviewStatus,workflowResult:o.workflowResult,customMessage:o.customMessage,onContinue:r&&o.workflowResult?()=>r(o.workflowResult):void 0,onContactSupport:()=>{typeof window<"u"&&(window.location.href="mailto:support@example.com")}})});if(!c)return e.jsx("div",{className:`metakyc-sdk ${a||""}`,children:e.jsx(ee,{children:e.jsxs(te,{children:[e.jsx(Ee,{className:"my-8"}),e.jsx("p",{className:"text-center mt-4",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:o.status===Te.IdentityPending?"Loading identity verification...":"Loading current step..."})]})})});const Y=U=>{switch(U){case oe.Overview:return"Overview";case oe.Questionaries:return"Questionnaire";case oe.UploadDocument:return"Documents";case oe.IdentitySdk:return"Identity";case oe.RiskScoring:return"Risk Assessment";case oe.InvestorCategorization:return"Investor Categorization";case oe.AppropriatenessTest:return"Appropriateness Test";case oe.AdditionalData:return"Additional Data";case oe.ManualReview:return"Review";default:return""}},L=()=>{const U=d.filter(q=>q.visibility!==!1),X=U.findIndex(q=>q.order===c.order),R=X>=0?X+1:1,f=U.length,O=f>1?X/(f-1)*100:100;return e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",marginBottom:"16px"},children:[e.jsx(nt,{}),e.jsxs(kt,{variant:o.status===1?"info":"success",children:["Step ",R," of ",f]})]}),e.jsx("div",{style:{marginBottom:"16px"},children:e.jsx("div",{style:{height:"4px",borderRadius:"999px",backgroundColor:"var(--metakyc-border, #e5e7eb)",overflow:"hidden"},children:e.jsx("div",{style:{height:"100%",borderRadius:"999px",backgroundColor:"var(--metakyc-primary, #2563eb)",width:`${O}%`,transition:"width 0.4s ease"}})})}),e.jsx(Fs,{ref:D,visibleSteps:U,currentVisibleStepIndex:X,getStepFallbackName:Y})]})},B=()=>{const U={applicantId:t,onComplete:async()=>{await A()},onBack:c.order>0?E:void 0};switch(c.action){case oe.Questionaries:return e.jsx(Mr,{...U});case oe.UploadDocument:return e.jsx(Dr,{...U});case oe.Overview:return e.jsx(Or,{...U});case oe.IdentitySdk:return e.jsx(_r,{...U});case oe.RiskScoring:return e.jsx(zr,{...U});case oe.AdditionalData:case oe.InvestorCategorization:return e.jsx($r,{...U});case oe.AppropriatenessTest:return e.jsx(Br,{...U});case oe.ManualReview:return e.jsx(ft,{kycStatus:o.kycStatus,reviewStatus:o.reviewStatus,workflowResult:o.workflowResult,customMessage:o.customMessage});default:return e.jsx(ee,{children:e.jsxs(te,{className:"py-12 text-center",children:[e.jsx("div",{className:"mb-4",children:e.jsx(Ee,{})}),e.jsxs("p",{className:"text-gray-600 dark:text-gray-400 mb-2",children:["Processing step: ",c.title||c.name]}),e.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:["Action type: ",oe[c.action]]})]})})}};return e.jsxs("div",{className:`metakyc-sdk ${a||""}`,children:[L(),B()]})},Fs=i.forwardRef(({visibleSteps:t,currentVisibleStepIndex:r,getStepFallbackName:s},n)=>{const a=i.useRef(null),o=i.useRef(null);return i.useImperativeHandle(n,()=>a.current),i.useEffect(()=>{if(o.current&&a.current){const c=a.current,d=o.current,y=d.offsetLeft-c.offsetWidth/2+d.offsetWidth/2;c.scrollTo({left:Math.max(0,y),behavior:"smooth"})}},[r]),e.jsx("div",{ref:a,className:"metakyc-stepper-scroll",style:{display:"flex",alignItems:"center",overflowX:"auto",overflowY:"hidden",scrollbarWidth:"none",msOverflowStyle:"none",WebkitOverflowScrolling:"touch",padding:"4px 0",gap:"0"},children:t.map((c,d)=>{const y=d<r,p=d===r,b=y||p,T=c.displayName||c.name||s(c.action)||`Step ${d+1}`;return e.jsxs(i.Fragment,{children:[e.jsxs("div",{ref:p?o:void 0,style:{display:"flex",alignItems:"center",flexShrink:0},children:[e.jsx("div",{style:{width:"28px",height:"28px",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"12px",fontWeight:600,flexShrink:0,transition:"all 0.2s ease",...b?{backgroundColor:"var(--metakyc-primary, #2563eb)",color:"#ffffff",border:"none"}:{backgroundColor:"transparent",color:"var(--metakyc-text-muted, #9ca3af)",border:"2px solid var(--metakyc-border, #e5e7eb)"}},children:y?e.jsx("svg",{width:"14",height:"14",fill:"none",stroke:"currentColor",strokeWidth:2.5,viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}):d+1}),e.jsx("span",{style:{marginLeft:"6px",fontSize:"13px",whiteSpace:"nowrap",fontWeight:p?600:400,color:p?"var(--metakyc-text-primary, #111827)":y?"var(--metakyc-primary, #2563eb)":"var(--metakyc-text-muted, #9ca3af)",transition:"color 0.2s ease"},children:T})]}),d<t.length-1&&e.jsx("div",{style:{width:"32px",minWidth:"16px",height:"2px",margin:"0 8px",flexShrink:0,borderRadius:"999px",backgroundColor:y?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #e5e7eb)",transition:"background-color 0.2s ease"}})]},c.order)})})});function Ps(t){return We.z.object({questionResults:We.z.any()}).passthrough()}function Ls(t){let r=We.z.array(We.z.instanceof(File));if(t.isRequired?r=r.min(1,`${t.displayName} is required`):r=r.optional(),t.multipleFile||(r=r.refine(s=>!s||s.length<=1,{message:"Only one file is allowed"})),t.maxEachFileSizeByte>0&&(r=r.refine(s=>!s||s.every(n=>n.size<=t.maxEachFileSizeByte),{message:`File size must not exceed ${Math.round(t.maxEachFileSizeByte/1024/1024)}MB`})),t.allowedTypes){const s=t.allowedTypes.split(",").map(n=>n.trim());r=r.refine(n=>n?n.every(a=>s.some(o=>o.endsWith("/*")?a.type.startsWith(o.slice(0,-2)):a.type===o)):!0,{message:"Invalid file type"})}return r}function Ms(t){const r={};return t.uploadDocumentFiles.forEach(s=>{const n=`file_${s.id}`;r[n]=Ls(s)}),We.z.object(r)}function Ds(t){return We.z.any()}function Os(t){return We.z.string().min(1,"This question is required")}function zs(t){const r={};return t.appropriatenessQuestions.forEach(s=>{const n=`question_${s.id}`;r[n]=Os()}),We.z.object(r)}const $s=We.z.any();exports.ALLOWED_LANGUAGES=ht;exports.ApplicantProgressOnHoldReason=At;exports.ApplicantProgressStatus=Te;exports.ApplicantService=qt;exports.ApplicantStatus=Ft;exports.AppropriatenessQuestionType=Ot;exports.AppropriatenessTestService=Qt;exports.AppropriatenessTestStep=Br;exports.Badge=kt;exports.BaseInformationService=Xt;exports.Button=J;exports.COMPANY_FIELD_METADATA=Ze;exports.Card=ee;exports.CardContent=te;exports.CardFooter=be;exports.CardHeader=ge;exports.CountriesType=He;exports.CreateApplicantForm=Es;exports.CreateCompanyApplicantForm=As;exports.CriteriaBuiltInType=$t;exports.DEFAULT_COMPANY_VISIBLE_FIELDS=_t;exports.DEFAULT_VISIBLE_FIELDS=Ht;exports.DocumentReviewStatus=Dt;exports.EndpointBuilder=Ut;exports.ErrorHandler=rt;exports.EventEmitter=lr;exports.FIELD_METADATA=Qe;exports.FileType=Mt;exports.FileUpload=Er;exports.GenderType=lt;exports.Header=nt;exports.HttpClient=Kt;exports.IdentityProviderManager=_e;exports.IdentityService=Zt;exports.IdentityVerificationProvider=Ae;exports.IdentityVerificationStep=_r;exports.Input=ye;exports.InvestorCategorizationService=er;exports.InvestorCategorizationStep=$r;exports.InvestorCategorizationType=je;exports.InvestorCategoryType=Bt;exports.KycProcessStatus=Pt;exports.KycStatus=Ve;exports.KycStatusDisplay=ft;exports.KycWorkflow=Ts;exports.Logo=Hr;exports.MetaKYCContext=bt;exports.MetaKYCError=Le;exports.MetaKYCProvider=Xr;exports.MultiSelect=Ir;exports.OnfidoProvider=mr;exports.OverviewService=Gt;exports.OverviewStep=Or;exports.PhoneInput=Ar;exports.QuestionnaireService=Vt;exports.QuestionnaireStep=Mr;exports.ReviewStatus=Ye;exports.RiskCriteriaType=zt;exports.RiskLevel=Tt;exports.RiskScoringService=Jt;exports.RiskScoringStep=zr;exports.SardinAIProvider=yr;exports.SearchableSelect=De;exports.Select=mt;exports.Spinner=Ee;exports.StepRouter=dr;exports.SumsubProvider=pr;exports.ThemeManager=xr;exports.ThemePreset=we;exports.ThemeService=or;exports.UploadDocumentService=Yt;exports.UploadDocumentStep=Dr;exports.UserType=Lt;exports.ValueDataType=Me;exports.WorkflowOrchestrator=ur;exports.WorkflowResultType=ot;exports.WorkflowState=cr;exports.WorkflowStepAction=oe;exports.appropriatenessTestSchema=$s;exports.clearAllStorage=ns;exports.clearApplicantId=br;exports.clearWorkflowState=kr;exports.cn=Se;exports.corporateTheme=tr;exports.defaultConfig=Wt;exports.defaultTheme=Re;exports.fileToBase64=hr;exports.fintechTheme=rr;exports.formatFileSize=ut;exports.generateAppropriatenessSchema=zs;exports.generateQuestionnaireSchema=Ps;exports.generateRiskScoringSchema=Ds;exports.generateUploadDocumentSchema=Ms;exports.getAcceptString=rs;exports.getApplicantId=gr;exports.getThemePreset=st;exports.getWorkflowState=ss;exports.healthcareTheme=sr;exports.isScriptLoaded=Yr;exports.loadScript=gt;exports.minimalTheme=ar;exports.modernTheme=nr;exports.removeScript=Qr;exports.saveApplicantId=fr;exports.saveWorkflowState=vr;exports.themePresets=ir;exports.useApplicant=vt;exports.useAppropriatenessTest=as;exports.useIdentityVerification=Nr;exports.useKycWorkflow=jr;exports.useMetaKYC=Ne;exports.useOverview=Cr;exports.useQuestionnaire=wr;exports.useRiskScoring=Rr;exports.useUploadDocument=Sr;exports.validateFileSize=es;exports.validateFileType=ts;
102
+ */const xs=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Lr=Fr("chevron-right",xs);function hs(t,r){const s=!r||r.length===0||r.every(n=>!n||!n.trim());if(t.isRequired&&s)return t.errorMessage||"This field is required";if(!s){const n=r[0]??"";if(n&&t.regex)try{if(!new RegExp(t.regex).test(n))return t.errorMessage||"Invalid format"}catch{}if(n!==""){const a=Number(n);if(!isNaN(a)&&n.trim()!==""){if(t.min!==void 0&&t.min!==null&&a<t.min)return`Minimum value is ${t.min}`;if(t.max!==void 0&&t.max!==null&&a>t.max)return`Maximum value is ${t.max}`}else{if(t.min!==void 0&&t.min!==null&&n.length<t.min)return`Minimum length is ${t.min} characters`;if(t.max!==void 0&&t.max!==null&&n.length>t.max)return`Maximum length is ${t.max} characters`}}}return null}function fs(t){const r=t.flatMap((n,a)=>(n.questions??[]).map((o,c)=>({question:o,groupIndex:a,qIdx:c}))),s=new Map;for(const n of r){const a=n.question.pageNumber!=null&&n.question.pageNumber>0?n.question.pageNumber:1;s.has(a)||s.set(a,[]),s.get(a).push(n)}return Array.from(s.entries()).sort(([n],[a])=>n-a).map(([,n])=>n)}const Mr=({applicantId:t,onComplete:r,onBack:s})=>{const{questionnaire:n,initialAnswers:a,isLoading:o,isSubmitting:c,error:d,submit:y}=wr(t),[p,g]=i.useState({}),[T,v]=i.useState({}),[E,A]=i.useState(0);i.useEffect(()=>{a&&Object.keys(a).length>0&&Object.keys(p).length===0&&g(a)},[a]);const k=i.useMemo(()=>n?fs(n.questionGroups):[],[n]),S=E===k.length-1,D=k[E]??[],Y=i.useCallback((R,f)=>{g(O=>({...O,[R]:f})),v(O=>{const q={...O};return delete q[R],q})},[]),L=i.useCallback(()=>{const R={};for(const{question:f}of D){const O=hs(f,p[f.id]??[]);O&&(R[f.id]=O)}return v(f=>({...f,...R})),Object.keys(R).length===0},[D,p]),B=()=>{L()&&A(R=>R+1)},U=()=>{E>0?A(R=>R-1):s==null||s()},X=async()=>{if(!(!L()||!n))try{const R=n.questionGroups.flatMap(O=>(O.questions??[]).map(q=>({questionId:q.id,values:p[q.id]??[]}))),f={applicantId:t,questionnarieId:n.id,questionResults:R};await y(f),r==null||r()}catch(R){console.error("Questionnaire submit error:",R)}};return o?e.jsx(ee,{children:e.jsx(te,{children:e.jsx(Ee,{className:"my-8"})})}):d?e.jsx(ee,{children:e.jsx(te,{children:e.jsxs("p",{className:"text-danger-500",children:["Error loading questionnaire: ",d.message]})})}):n?e.jsxs(ee,{children:[e.jsxs(ge,{children:[e.jsx("h2",{className:"text-lg font-bold",children:n.displayName}),n.subtitle&&e.jsx("p",{className:"text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:n.subtitle}),k.length>1&&e.jsxs("div",{className:"flex items-center justify-between mt-3",children:[e.jsxs("span",{className:"text-xs",style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:["Page ",E+1," of ",k.length]}),e.jsx("div",{className:"flex items-center gap-1.5",children:k.map((R,f)=>e.jsx("div",{className:"rounded-full transition-all duration-200",style:{height:"6px",width:f===E?"20px":"6px",backgroundColor:f<=E?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #e5e7eb)"}},f))})]})]}),e.jsx(te,{className:"space-y-6",children:D.map(({question:R})=>e.jsx(gs,{question:R,value:p[R.id]??[],error:T[R.id],onChange:f=>Y(R.id,f)},R.id))}),e.jsxs(be,{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs(J,{type:"button",variant:"outline",onClick:U,style:{display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx(Pr,{size:14}),E>0?"Previous":"Back"]}),S?e.jsx(J,{type:"button",isLoading:c,onClick:X,children:"Continue"}):e.jsxs(J,{type:"button",onClick:B,style:{display:"flex",alignItems:"center",gap:"4px"},children:["Next",e.jsx(Lr,{size:14})]})]}),d&&e.jsx("div",{className:"mx-6 mb-4 p-3 bg-red-50 border border-red-200 rounded",children:e.jsx("p",{className:"text-red-600 text-sm",children:d.message})})]}):null},gs=({question:t,value:r,error:s,onChange:n})=>{var c;const o=(((c=t.defaultAnswers)==null?void 0:c.length)??0)>0?t.showAsDropdown?t.canMultipleAnswer?"multi-select":"single-select":t.canMultipleAnswer?"checkbox":"radio":"text";return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"block text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:[t.text,t.isRequired&&e.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),t.subtitle&&e.jsx("p",{className:"text-xs",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:t.subtitle}),t.description&&e.jsx("p",{className:"text-xs",style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:t.description}),o==="text"&&e.jsx(ye,{value:r[0]??"",onChange:d=>n([d.target.value]),placeholder:t.subtitle?void 0:"Enter your answer…",error:s,required:t.isRequired}),o==="single-select"&&e.jsx(mt,{value:r[0]??"",onChange:d=>n([d.target.value]),options:(t.defaultAnswers??[]).map(d=>({value:d,label:d})),placeholder:"Select an option…",error:s,required:t.isRequired}),o==="radio"&&e.jsxs("div",{className:"metakyc-options-group",style:{display:"flex",flexDirection:"column",gap:"8px"},children:[(t.defaultAnswers??[]).map(d=>e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"radio",checked:r[0]===d,onChange:()=>n([d]),className:"metakyc-option-input",style:{width:"16px",height:"16px",minWidth:"16px",flexShrink:0,flexGrow:0,accentColor:"var(--metakyc-primary, #2563eb)",cursor:"pointer",margin:0,padding:0,display:"inline-block",verticalAlign:"middle"}}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4",marginLeft:0},children:d})]},d)),s&&e.jsx("p",{className:"text-sm text-danger-500",children:s})]}),(o==="checkbox"||o==="multi-select")&&e.jsxs("div",{className:"metakyc-options-group",style:{display:"flex",flexDirection:"column",gap:"8px"},children:[(t.defaultAnswers??[]).map(d=>e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"checkbox",checked:r.includes(d),onChange:y=>{y.target.checked?n([...r,d]):n(r.filter(p=>p!==d))},className:"metakyc-option-input",style:{width:"16px",height:"16px",minWidth:"16px",flexShrink:0,flexGrow:0,accentColor:"var(--metakyc-primary, #2563eb)",cursor:"pointer",margin:0,padding:0,display:"inline-block",verticalAlign:"middle"}}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4",marginLeft:0},children:d})]},d)),s&&e.jsx("p",{className:"text-sm text-danger-500",children:s})]}),s&&o==="text"&&null]})};function bs(t){const r=new Map;for(const s of t){const n=s.pageNumber!=null&&s.pageNumber>0?s.pageNumber:1;r.has(n)||r.set(n,[]),r.get(n).push(s)}return Array.from(r.entries()).sort(([s],[n])=>s-n).map(([,s])=>s)}const Dr=({applicantId:t,onComplete:r,onBack:s})=>{const{uploadDocument:n,isLoading:a,isSubmitting:o,error:c,submit:d}=Sr(t),[y,p]=i.useState({}),[g,T]=i.useState(null),[v,E]=i.useState(0),[A,k]=i.useState({}),S=i.useMemo(()=>n?bs(n.uploadDocumentFiles):[],[n]),D=S[v]??[],Y=v===S.length-1,L=S.length,B=i.useCallback(()=>{const f={};for(const O of D)O.isRequired&&(y[O.id]||[]).length===0&&(f[O.id]=`${O.displayName} is required`);return k(f),Object.keys(f).length===0},[D,y]),U=()=>{B()&&(E(f=>f+1),k({}))},X=()=>{v>0?(E(f=>f-1),k({})):s==null||s()},R=async()=>{if(!(!B()||!n)){T(null);try{const f=await Promise.all(n.uploadDocumentFiles.map(async q=>{const Q=y[q.id]||[],$=await Promise.all(Q.map(async G=>({fileName:G.name,fileData:await hr(G)})));return{uploadDocumentFileId:q.id,valueList:$}})),O={applicantId:t,uploadDocumentId:n.id,uploadDocumentResults:f};await d(O),r==null||r()}catch(f){T((f==null?void 0:f.message)||"Failed to submit documents. Please try again.")}}};return a?e.jsx(ee,{children:e.jsx(te,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",padding:"48px 0",gap:"16px"},children:[e.jsx(Ee,{className:"my-8"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--metakyc-text-muted, #9ca3af)"},children:"Loading document requirements..."})]})})}):c?e.jsx(ee,{children:e.jsx(te,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",padding:"32px 0",gap:"12px",textAlign:"center"},children:[e.jsx("div",{style:{width:"48px",height:"48px",borderRadius:"50%",backgroundColor:"color-mix(in srgb, var(--metakyc-danger, #ef4444) 10%, transparent)",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"var(--metakyc-danger, #ef4444)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),e.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]})}),e.jsx("p",{style:{fontSize:"14px",color:"var(--metakyc-danger, #ef4444)",fontWeight:500},children:"Error loading document requirements"}),e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-text-muted, #9ca3af)"},children:c.message})]})})}):n?e.jsxs(ee,{children:[e.jsxs(ge,{children:[e.jsx("h2",{style:{fontSize:"18px",fontWeight:700,color:"var(--metakyc-text-primary, #111827)",margin:0},children:n.displayName||"Upload Documents"}),n.subtitle&&e.jsx("p",{style:{fontSize:"14px",color:"var(--metakyc-text-secondary, #6b7280)",marginTop:"4px"},children:n.subtitle}),L>1&&e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginTop:"12px"},children:[e.jsxs("span",{style:{fontSize:"12px",color:"var(--metakyc-text-muted, #9ca3af)"},children:["Page ",v+1," of ",L]}),e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"6px"},children:S.map((f,O)=>e.jsx("div",{style:{height:"6px",width:O===v?"20px":"6px",borderRadius:"999px",transition:"all 0.2s ease",backgroundColor:O<=v?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #e5e7eb)"}},O))})]})]}),n.description&&v===0&&e.jsxs("div",{style:{margin:"0 24px",marginTop:"4px",display:"flex",gap:"10px",padding:"12px 14px",borderRadius:"10px",backgroundColor:"color-mix(in srgb, var(--metakyc-primary, #2563eb) 5%, var(--metakyc-background, #ffffff))",border:"1px solid color-mix(in srgb, var(--metakyc-primary, #2563eb) 15%, transparent)"},children:[e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"var(--metakyc-primary, #2563eb)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,marginTop:"1px"},children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),e.jsx("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"})]}),e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-text-secondary, #374151)",margin:0,lineHeight:1.5},children:n.description})]}),e.jsx(te,{children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"24px"},children:D.map(f=>e.jsx(Er,{label:f.displayName,subtitle:f.subtitle,accept:f.allowedTypes,multiple:f.multipleFile,maxSize:f.maxEachFileSizeByte,required:f.isRequired,error:A[f.id],value:y[f.id]||[],onChange:O=>{T(null),k(q=>{const Q={...q};return delete Q[f.id],Q}),p(q=>({...q,[f.id]:O}))}},f.id))})}),g&&e.jsxs("div",{style:{margin:"0 24px",padding:"10px 14px",borderRadius:"8px",backgroundColor:"color-mix(in srgb, var(--metakyc-danger, #ef4444) 8%, transparent)",border:"1px solid color-mix(in srgb, var(--metakyc-danger, #ef4444) 20%, transparent)",display:"flex",alignItems:"center",gap:"8px"},children:[e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"var(--metakyc-danger, #ef4444)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[e.jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),e.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),e.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-danger, #ef4444)",margin:0},children:g})]}),e.jsx(be,{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%"},children:[e.jsx(J,{type:"button",variant:"outline",onClick:X,children:v>0?"Previous":"Back"}),Y?e.jsx(J,{type:"button",isLoading:o,onClick:R,children:o?"Uploading...":"Continue"}):e.jsx(J,{type:"button",onClick:U,children:"Next"})]})})]}):null},Or=({applicantId:t,onComplete:r,onBack:s})=>{const{overview:n,isLoading:a,isSubmitting:o,error:c,passOverview:d}=Cr(t),y=async()=>{await d(),r==null||r()};return a?e.jsx(ee,{children:e.jsx(te,{children:e.jsx(Ee,{className:"my-8"})})}):c?e.jsx(ee,{children:e.jsx(te,{children:e.jsxs("p",{className:"text-danger-500",children:["Error loading overview: ",c.message]})})}):n?e.jsxs(ee,{children:[e.jsxs(ge,{children:[e.jsx("h2",{className:"text-lg font-bold",children:n.title||"Overview"}),n.description&&e.jsx("p",{className:"mt-1",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:n.description})]}),e.jsx(te,{className:"space-y-8",children:n.steps&&n.steps.length>0?n.steps.sort((p,g)=>p.order-g.order).map(p=>e.jsxs("div",{className:"metakyc-overview-step-item flex items-center space-x-3",children:[e.jsx("div",{className:"metakyc-step-icon flex-shrink-0",children:e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center font-medium text-sm",style:{backgroundColor:"var(--metakyc-primary, #2563eb)",color:"#ffffff"},children:p.order+1})}),e.jsxs("div",{className:"metakyc-step-content",style:{flex:1,border:"none",height:"auto",background:"transparent"},children:[e.jsx("span",{className:"metakyc-step-title text-sm font-semibold",style:{color:"var(--metakyc-text-primary, #111827)"},children:p.title}),p.description&&e.jsx("p",{className:"metakyc-step-description text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:p.description})]})]},p.order)):e.jsx("div",{className:"text-center py-8",children:e.jsx("p",{style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"Loading overview data..."})})}),e.jsxs(be,{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[s&&e.jsx(J,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(J,{onClick:y,isLoading:o,children:"Continue"})]})]}):null};function vs(t){const r=(t??"en").toLowerCase().replace("_","-");try{return Intl.NumberFormat.supportedLocalesOf([r]),r}catch{return"en"}}function ks(t){return t.valueDataType===Me.Money&&Array.isArray(t.defaultValues)&&t.defaultValues.length>0}function js(t,r){const s=new Intl.NumberFormat(vs(r),{minimumFractionDigits:0,maximumFractionDigits:2});return t.replace(/([\d]+(?:\.\d+)?)/g,n=>{const a=parseFloat(n);return isNaN(a)?n:s.format(a)})}function ws(t,r){const s=!r||r.length===0||r.every(n=>!n||!n.trim());if(t.isRequired&&s)return t.errorMessage||`${t.displayName} is required`;if(!s){const n=r[0]??"";if(n&&t.regex)try{if(!new RegExp(t.regex).test(n))return t.errorMessage||"Invalid format"}catch{}const a=t.valueDataType===Me.Integer||t.valueDataType===Me.Money||t.valueDataType===Me.DigitOnly;if(a&&n.trim()!==""){const o=Number(n);if(!isNaN(o)){if(t.min!==void 0&&t.min!==null&&o<t.min)return`Minimum value is ${t.min}`;if(t.max!==void 0&&t.max!==null&&o>t.max)return`Maximum value is ${t.max}`}}else if(!a&&n!==""){if(t.min!==void 0&&t.min!==null&&n.length<t.min)return`Minimum length is ${t.min} characters`;if(t.max!==void 0&&t.max!==null&&n.length>t.max)return`Maximum length is ${t.max} characters`}}return null}function Ss(t){const r=new Map;return t.forEach((s,n)=>{const a=s.pageNumber!=null&&s.pageNumber>0?s.pageNumber:1;r.has(a)||r.set(a,[]),r.get(a).push({criterion:s,idx:n})}),Array.from(r.entries()).sort(([s],[n])=>s-n).map(([,s])=>s)}function Cs(t){return t.builtInType===1?"country":!t.defaultValues||t.defaultValues.length===0?"text":t.multipleValue?"checkbox":"radio"}const zr=({applicantId:t,onComplete:r,onBack:s})=>{const{config:n}=Ne(),a=n.locale??"en",{criteria:o,initialAnswers:c,isLoading:d,isSubmitting:y,error:p,submit:g}=Rr(t),[T,v]=i.useState({}),[E,A]=i.useState({}),[k,S]=i.useState(0),[D,Y]=i.useState(!1);i.useEffect(()=>{c&&Object.keys(c).length>0&&Object.keys(T).length===0&&v(c)},[c]);const L=i.useMemo(()=>o&&o.length>0?Ss(o):[],[o]),B=k===L.length-1,U=L[k]??[];i.useEffect(()=>{!d&&o&&o.length===0&&!D&&!y&&(Y(!0),g({applicantId:t,criteriaValueInputs:[]}).then(()=>r==null?void 0:r()).catch(console.error))},[d,o,D,y,g,t,r]);const X=i.useCallback((Q,$)=>{v(G=>({...G,[Q]:$})),A(G=>{const se={...G};return delete se[Q],se})},[]),R=i.useCallback(()=>{const Q={};for(const{criterion:$}of U){const G=ws($,T[$.id]??[]);G&&(Q[$.id]=G)}return A($=>({...$,...Q})),Object.keys(Q).length===0},[U,T]),f=()=>{R()&&S(Q=>Q+1)},O=()=>{k>0?S(Q=>Q-1):s==null||s()},q=async()=>{if(!(!R()||!o))try{const Q=o.map(G=>{const se=(T[G.id]??[]).filter(V=>V&&V.trim());return se.length>0?{riskCriteriaId:G.id,values:se}:null}).filter(G=>G!==null);await g({applicantId:t,criteriaValueInputs:Q}),r==null||r()}catch(Q){console.error("Risk scoring submit error:",Q)}};return d?e.jsx(ee,{children:e.jsxs(te,{children:[e.jsx(Ee,{className:"my-8"}),e.jsx("p",{className:"text-center text-sm mt-4",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"Loading risk scoring criteria…"})]})}):!d&&o&&o.length===0?e.jsx(ee,{children:e.jsxs(te,{children:[e.jsx(Ee,{className:"my-8"}),e.jsx("p",{className:"text-center text-sm mt-4",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"No criteria required. Moving to next step…"})]})}):p?e.jsx(ee,{children:e.jsx(te,{children:e.jsxs("p",{className:"text-danger-500",children:["Error loading criteria: ",p.message]})})}):o?e.jsxs(ee,{children:[e.jsxs(ge,{children:[e.jsx("h2",{className:"text-lg font-bold",children:"Risk Assessment"}),e.jsx("p",{className:"text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"Please answer the following questions for risk evaluation"}),L.length>1&&e.jsxs("div",{className:"flex items-center justify-between mt-3",children:[e.jsxs("span",{className:"text-xs",style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:["Page ",k+1," of ",L.length]}),e.jsx("div",{className:"flex items-center gap-1.5",children:L.map((Q,$)=>e.jsx("div",{className:"rounded-full transition-all duration-200",style:{height:"6px",width:$===k?"20px":"6px",backgroundColor:$<=k?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #e5e7eb)"}},$))})]})]}),e.jsx(te,{className:"space-y-6",children:U.map(({criterion:Q})=>e.jsx(Ns,{criterion:Q,value:T[Q.id]??[],error:E[Q.id],locale:a,onChange:$=>X(Q.id,$)},Q.id))}),e.jsxs(be,{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs(J,{type:"button",variant:"outline",onClick:O,style:{display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx(Pr,{size:14}),k>0?"Previous":"Back"]}),B?e.jsx(J,{type:"button",isLoading:y,onClick:q,children:"Continue"}):e.jsxs(J,{type:"button",onClick:f,style:{display:"flex",alignItems:"center",gap:"4px"},children:["Next",e.jsx(Lr,{size:14})]})]}),p&&e.jsx("div",{className:"mx-6 mb-4 p-3 bg-red-50 border border-red-200 rounded",children:e.jsx("p",{className:"text-red-600 text-sm",children:p.message})})]}):null},Ns=({criterion:t,value:r,error:s,locale:n,onChange:a})=>{const o=Cs(t),c=t.valueDataType===Me.Integer||t.valueDataType===Me.Money||t.valueDataType===Me.DigitOnly,d=ks(t),y=p=>d?js(p,n):p;return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"block text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:[t.displayName,t.isRequired&&e.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),t.description&&e.jsx("p",{className:"text-xs",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:t.description}),c&&(t.min!==void 0||t.max!==void 0)&&e.jsx("p",{className:"text-xs",style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:t.min!==void 0&&t.max!==void 0?`Range: ${t.min} – ${t.max}`:t.min!==void 0?`Minimum: ${t.min}`:`Maximum: ${t.max}`}),o==="text"&&e.jsx(ye,{value:r[0]??"",onChange:p=>a([p.target.value]),type:c?"number":"text",placeholder:"Enter your answer…",error:s,required:t.isRequired,min:t.min,max:t.max,onKeyDown:p=>{t.valueDataType===Me.DigitOnly&&["e","E","+","-","."].includes(p.key)&&p.preventDefault()}}),o==="radio"&&e.jsxs("div",{className:"metakyc-options-group",style:{display:"flex",flexDirection:"column",gap:"8px"},children:[(t.defaultValues??[]).map(p=>e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"radio",checked:r[0]===p,onChange:()=>a([p]),className:"metakyc-option-input",style:{width:"16px",height:"16px",minWidth:"16px",flexShrink:0,flexGrow:0,accentColor:"var(--metakyc-primary, #2563eb)",cursor:"pointer",margin:0,padding:0,display:"inline-block",verticalAlign:"middle"}}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4",marginLeft:0},children:y(p)})]},p)),s&&e.jsx("p",{className:"text-sm text-danger-500",children:s})]}),o==="checkbox"&&e.jsxs("div",{className:"metakyc-options-group",style:{display:"flex",flexDirection:"column",gap:"8px"},children:[(t.defaultValues??[]).map(p=>e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"checkbox",checked:r.includes(p),onChange:g=>{g.target.checked?a([...r,p]):a(r.filter(T=>T!==p))},className:"metakyc-option-input",style:{width:"16px",height:"16px",minWidth:"16px",flexShrink:0,flexGrow:0,accentColor:"var(--metakyc-primary, #2563eb)",cursor:"pointer",margin:0,padding:0,display:"inline-block",verticalAlign:"middle"}}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4",marginLeft:0},children:y(p)})]},p)),s&&e.jsx("p",{className:"text-sm text-danger-500",children:s})]}),o==="country"&&e.jsx(mt,{value:r[0]??"",onChange:p=>a([p.target.value]),options:[{value:"US",label:"United States"},{value:"GB",label:"United Kingdom"},{value:"DE",label:"Germany"},{value:"FR",label:"France"},{value:"AE",label:"United Arab Emirates"}],placeholder:"Select a country…",error:s,required:t.isRequired})]})},$r=({applicantId:t,onComplete:r,onBack:s})=>{const{investorCategorizationService:n}=Ne(),[a,o]=i.useState(null),[c,d]=i.useState(!1),[y,p]=i.useState(null),g=async T=>{if(T.preventDefault(),a===null){p("Please select an investor type");return}d(!0),p(null);try{const v={applicantId:t,investorType:a};console.log("Submitting investor categorization:",v);const E=await n.setInvestorCategorization(v);console.log("Investor categorization result:",E),r==null||r()}catch(v){console.error("Error submitting investor categorization:",v),p(v.message||"Failed to submit investor categorization")}finally{d(!1)}};return e.jsx("form",{onSubmit:g,children:e.jsxs(ee,{children:[e.jsxs(ge,{children:[e.jsx("h2",{className:"text-lg font-bold",style:{color:"var(--metakyc-text-primary, #111827)"},children:"Which statement best describes you?"}),e.jsx("p",{className:"mt-2",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"All Tokenise clients are treated as Retail Investors under EU regulation, which gives you the highest level of investor protection. For our internal purposes, we ask you to select the description that best matches your situation"})]}),e.jsxs(te,{className:"space-y-4",children:[e.jsx("p",{className:"text-sm font-medium mb-3",style:{color:"var(--metakyc-text-secondary, #374151)"},children:"Choose one"}),e.jsx("label",{className:"block p-4 border-2 rounded-lg cursor-pointer transition-all",style:{borderColor:a===je.Individual?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #e5e7eb)",backgroundColor:a===je.Individual?"var(--metakyc-primary-light, #dbeafe)":"transparent"},children:e.jsxs("div",{className:"flex items-start",children:[e.jsx("input",{type:"radio",name:"investorType",value:je.Individual,checked:a===je.Individual,onChange:()=>o(je.Individual),className:"mt-1"}),e.jsxs("div",{className:"ml-3",children:[e.jsx("div",{className:"text-base font-semibold",style:{color:"var(--metakyc-text-primary, #111827)"},children:"Individual investor"}),e.jsx("div",{className:"text-sm mt-1",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"(Recommended) Most of our clients choose this option. Provides the strongest protection and aligns with our mission to make investing accessible to everyone."})]})]})}),e.jsx("label",{className:"block p-4 border-2 rounded-lg cursor-pointer transition-all",style:{borderColor:a===je.Sophisticated?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #e5e7eb)",backgroundColor:a===je.Sophisticated?"var(--metakyc-primary-light, #dbeafe)":"transparent"},children:e.jsxs("div",{className:"flex items-start",children:[e.jsx("input",{type:"radio",name:"investorType",value:je.Sophisticated,checked:a===je.Sophisticated,onChange:()=>o(je.Sophisticated),className:"mt-1"}),e.jsxs("div",{className:"ml-3",children:[e.jsx("div",{className:"text-base font-semibold",style:{color:"var(--metakyc-text-primary, #111827)"},children:"Sophisticated investor"}),e.jsx("div",{className:"text-sm mt-1",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"In the last 2 years, I have done one or more of the following:"}),e.jsxs("ul",{className:"text-sm mt-2 space-y-1 list-none",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:[e.jsx("li",{children:"Worked in private equity or provided capital to small and medium enterprises, and/or"}),e.jsx("li",{children:"Been the director of a company with an annual turnover of at least (USD) $2m million, and/or"}),e.jsx("li",{children:"Invested directly in at least 2 private (not listed) companies."})]})]})]})}),e.jsx("label",{className:"block p-4 border-2 rounded-lg cursor-pointer transition-all",style:{borderColor:a===je.HighNetWorth?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #e5e7eb)",backgroundColor:a===je.HighNetWorth?"var(--metakyc-primary-light, #dbeafe)":"transparent"},children:e.jsxs("div",{className:"flex items-start",children:[e.jsx("input",{type:"radio",name:"investorType",value:je.HighNetWorth,checked:a===je.HighNetWorth,onChange:()=>o(je.HighNetWorth),className:"mt-1"}),e.jsxs("div",{className:"ml-3",children:[e.jsx("div",{className:"text-base font-semibold",style:{color:"var(--metakyc-text-primary, #111827)"},children:"High networth investor"}),e.jsxs("div",{className:"text-sm mt-1",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:["I earn more than (USD/EUR) $150,000 per year, and/or",e.jsx("br",{}),"I have net assets (excluding my main property) of at least $/EUR 300,000"]})]})]})}),y&&e.jsx("div",{className:"p-4 rounded-lg",style:{backgroundColor:"#fee2e2",border:"1px solid #fca5a5"},children:e.jsxs("p",{className:"text-sm",style:{color:"#991b1b"},children:[e.jsx("strong",{children:"Error:"})," ",y]})})]}),e.jsxs(be,{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[s&&e.jsx(J,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(J,{type:"submit",isLoading:c,disabled:a===null,children:"Submit"})]})]})})};function Rt(t){const r=t.split(":").map(Number);return r.length===3?r[0]*3600+r[1]*60+r[2]:0}function yt(t){const r=Math.floor(t/60),s=t%60;return`${r.toString().padStart(2,"0")}:${s.toString().padStart(2,"0")}`}const Br=({applicantId:t,onComplete:r,onBack:s})=>{const{appropriatenessTestService:n}=Ne(),[a,o]=i.useState(null),[c,d]=i.useState(!0),[y,p]=i.useState(!1),[g,T]=i.useState(null),[v,E]=i.useState({}),[A,k]=i.useState(0),[S,D]=i.useState(!1),[Y,L]=i.useState(!1),[B,U]=i.useState(0),[X,R]=i.useState(0),[f,O]=i.useState(null);i.useEffect(()=>{(async()=>{try{d(!0),T(null);const z=await n.getAppropriatenessTest(t);if(o(z),z.waitTimeSpanForNextTry&&z.waitTimeSpanForNextTry!=="00:00:00"){const _=Rt(z.waitTimeSpanForNextTry);_>0&&U(_)}}catch(z){T(z.message||"Failed to load appropriateness test")}finally{d(!1)}})()},[t,n]),i.useEffect(()=>{if(!S||A<=0)return;const z=setInterval(()=>{k(_=>_<=1?(L(!0),0):_-1)},1e3);return()=>clearInterval(z)},[S,A]),i.useEffect(()=>{if(B<=0)return;const z=setInterval(()=>{U(_=>_<=1?0:_-1)},1e3);return()=>clearInterval(z)},[B]),i.useEffect(()=>{Y&&!y&&G()},[Y]);const q=()=>{a&&(D(!0),k(a.testDurationSec),R(0),E({}),T(null))},Q=(z,_)=>{E(me=>({...me,[z]:_}))},$=i.useCallback(async()=>{try{const z=await n.getAppropriatenessTest(t);if(o(z),z.waitTimeSpanForNextTry&&z.waitTimeSpanForNextTry!=="00:00:00"){const _=Rt(z.waitTimeSpanForNextTry);_>0&&U(_)}}catch{}},[t,n]),G=async z=>{if(a){if(!Y){const _=a.appropriatenessQuestions.length-Object.keys(v).length;if(_>0){T(`Please answer all questions. ${_} remaining.`);return}}p(!0),T(null);try{const _=a.appropriatenessQuestions.map(N=>({appropriatenessQuestionId:N.id,value:v[N.id]||""})),me={applicantId:t,appropriatenessTestId:a.id,appropriatenessQuestionResults:_};try{const N=await n.fillAppropriatenessTest(me);N.isSuccess?O({success:!0,message:N.message||"Congratulations! You have passed the test."}):(O({success:!1,message:N.message||"You did not pass the test."}),setTimeout(()=>$(),1e3))}catch(N){if(N.code===400&&N.message)O({success:!1,message:N.message}),setTimeout(()=>$(),1500);else throw N}}catch(_){T(_.message||"Failed to submit test. Please try again."),se()}finally{p(!1)}}},se=()=>{D(!1),L(!1),E({}),R(0)};if(c)return e.jsx(ee,{children:e.jsx(te,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",padding:"48px 0",gap:"16px"},children:[e.jsx(Ee,{className:"my-8"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--metakyc-text-muted, #9ca3af)"},children:"Loading test..."})]})})});if(!a)return e.jsx(ee,{children:e.jsx(te,{children:e.jsxs("div",{style:{textAlign:"center",padding:"48px 0"},children:[e.jsx("p",{style:{fontSize:"16px",fontWeight:600,color:"var(--metakyc-danger, #ef4444)"},children:"No test data available"}),g&&e.jsx("p",{style:{fontSize:"14px",color:"var(--metakyc-text-muted, #9ca3af)",marginTop:"8px"},children:g})]})})});const V=a.testAllowedMaxTry-a.totalFailedTries,he=a.appropriatenessQuestions.length,ce=Object.keys(v).length;if(B>0)return e.jsxs(ee,{children:[e.jsx(ge,{children:e.jsx("h2",{style:{fontSize:"18px",fontWeight:700,color:"var(--metakyc-text-primary, #111827)",margin:0},children:a.displayName})}),e.jsx(te,{children:e.jsxs("div",{style:{textAlign:"center",padding:"32px 0"},children:[e.jsx("div",{style:{width:"100px",height:"100px",borderRadius:"50%",margin:"0 auto 20px",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"color-mix(in srgb, var(--metakyc-primary, #2563eb) 8%, transparent)"},children:e.jsx("span",{style:{fontSize:"28px",fontWeight:700,color:"var(--metakyc-primary, #2563eb)",fontVariantNumeric:"tabular-nums"},children:yt(B)})}),e.jsx("p",{style:{fontSize:"15px",fontWeight:500,color:"var(--metakyc-text-primary, #111827)"},children:"Please wait before retrying"}),e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-text-muted, #9ca3af)",marginTop:"4px"},children:"You can attempt the test again once the timer expires"}),g&&e.jsx("div",{style:{marginTop:"20px",padding:"12px 16px",borderRadius:"10px",backgroundColor:"color-mix(in srgb, var(--metakyc-danger, #ef4444) 8%, transparent)",border:"1px solid color-mix(in srgb, var(--metakyc-danger, #ef4444) 20%, transparent)"},children:e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-danger, #ef4444)",margin:0},children:g})})]})})]});if(f){const z=()=>{O(null),se(),T(null)};return e.jsxs(ee,{children:[e.jsx(te,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",textAlign:"center",padding:"40px 16px",gap:"16px"},children:[e.jsx("div",{style:{width:"72px",height:"72px",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:f.success?"color-mix(in srgb, var(--metakyc-success, #10b981) 12%, transparent)":"color-mix(in srgb, var(--metakyc-danger, #ef4444) 10%, transparent)"},children:f.success?e.jsxs("svg",{width:"36",height:"36",viewBox:"0 0 24 24",fill:"none",stroke:"var(--metakyc-success, #10b981)",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),e.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]}):e.jsxs("svg",{width:"36",height:"36",viewBox:"0 0 24 24",fill:"none",stroke:"var(--metakyc-danger, #ef4444)",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),e.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]})}),e.jsx("h2",{style:{fontSize:"20px",fontWeight:700,color:f.success?"var(--metakyc-success, #10b981)":"var(--metakyc-danger, #ef4444)",margin:0},children:f.success?"Test Passed":"Test Failed"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--metakyc-text-secondary, #6b7280)",margin:0,lineHeight:1.6,maxWidth:"400px",whiteSpace:"pre-line"},children:f.message}),!f.success&&V>0&&e.jsx("div",{style:{marginTop:"4px",padding:"10px 20px",borderRadius:"10px",backgroundColor:"var(--metakyc-surface, #f9fafb)",border:"1px solid var(--metakyc-border, #e5e7eb)"},children:e.jsxs("p",{style:{fontSize:"13px",color:"var(--metakyc-text-muted, #9ca3af)",margin:0},children:["You have ",e.jsx("strong",{style:{color:"var(--metakyc-text-primary, #111827)"},children:V})," attempt",V!==1?"s":""," remaining"]})}),!f.success&&V<=0&&e.jsx("div",{style:{marginTop:"4px",padding:"10px 20px",borderRadius:"10px",backgroundColor:"color-mix(in srgb, var(--metakyc-danger, #ef4444) 8%, transparent)",border:"1px solid color-mix(in srgb, var(--metakyc-danger, #ef4444) 20%, transparent)"},children:e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-danger, #ef4444)",margin:0},children:"No attempts remaining. Please contact support for assistance."})})]})}),e.jsx(be,{children:e.jsx("div",{style:{display:"flex",justifyContent:"center",width:"100%",gap:"12px"},children:f.success?e.jsx(J,{type:"button",onClick:()=>r==null?void 0:r(),children:"Continue"}):e.jsxs(e.Fragment,{children:[V>0&&B<=0&&e.jsx(J,{type:"button",onClick:z,children:"Retake Test"}),V>0&&B>0&&e.jsx(J,{type:"button",onClick:z,children:"OK"}),V<=0&&s&&e.jsx(J,{type:"button",variant:"outline",onClick:s,children:"Back"})]})})})]})}if(!S)return e.jsxs(ee,{children:[e.jsxs(ge,{children:[e.jsx("h2",{style:{fontSize:"18px",fontWeight:700,color:"var(--metakyc-text-primary, #111827)",margin:0},children:a.displayName}),a.subtitle&&e.jsx("p",{style:{fontSize:"14px",color:"var(--metakyc-text-secondary, #6b7280)",marginTop:"4px"},children:a.subtitle})]}),e.jsxs(te,{children:[a.description&&e.jsxs("div",{style:{marginBottom:"20px",padding:"12px 14px",borderRadius:"10px",backgroundColor:"color-mix(in srgb, var(--metakyc-primary, #2563eb) 5%, var(--metakyc-background, #ffffff))",border:"1px solid color-mix(in srgb, var(--metakyc-primary, #2563eb) 15%, transparent)",display:"flex",gap:"10px"},children:[e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"var(--metakyc-primary, #2563eb)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,marginTop:"1px"},children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),e.jsx("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"})]}),e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-text-secondary, #374151)",margin:0,lineHeight:1.5},children:a.description})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px",marginBottom:"20px"},children:[e.jsx(ct,{icon:"questions",label:"Questions",value:String(a.totalQuestionCount)}),e.jsx(ct,{icon:"time",label:"Time Limit",value:yt(a.testDurationSec)}),e.jsx(ct,{icon:"target",label:"Pass Requirement",value:`${a.testCorrectAnswerPassLimit} correct`}),e.jsx(ct,{icon:"retry",label:"Attempts Left",value:String(V),variant:V<=1?"warning":"default"})]}),g&&e.jsxs("div",{style:{marginBottom:"16px",padding:"12px 14px",borderRadius:"10px",backgroundColor:"color-mix(in srgb, var(--metakyc-danger, #ef4444) 8%, transparent)",border:"1px solid color-mix(in srgb, var(--metakyc-danger, #ef4444) 20%, transparent)",display:"flex",gap:"10px"},children:[e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"var(--metakyc-danger, #ef4444)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,marginTop:"1px"},children:[e.jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),e.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),e.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),e.jsxs("p",{style:{fontSize:"13px",color:"var(--metakyc-danger, #ef4444)",margin:0,lineHeight:1.5},children:[e.jsx("strong",{children:"Previous attempt:"})," ",g]})]}),V<=0&&e.jsx("div",{style:{padding:"12px 14px",borderRadius:"10px",backgroundColor:"color-mix(in srgb, var(--metakyc-danger, #ef4444) 8%, transparent)",border:"1px solid color-mix(in srgb, var(--metakyc-danger, #ef4444) 20%, transparent)"},children:e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-danger, #ef4444)",margin:0},children:"You have used all your attempts. Please contact support for assistance."})})]}),e.jsx(be,{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:s?"space-between":"flex-end",width:"100%"},children:[s&&e.jsx(J,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(J,{type:"button",onClick:q,disabled:V<=0,children:"Start Test"})]})})]});const de=a.appropriatenessQuestions[X],fe=X===he-1,I=ce===he,W=A<=60;return e.jsxs(ee,{children:[e.jsxs(ge,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx("h2",{style:{fontSize:"18px",fontWeight:700,color:"var(--metakyc-text-primary, #111827)",margin:0},children:a.displayName}),e.jsxs("p",{style:{fontSize:"12px",color:"var(--metakyc-text-muted, #9ca3af)",marginTop:"2px"},children:["Question ",X+1," of ",he]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 14px",borderRadius:"999px",backgroundColor:W?"color-mix(in srgb, var(--metakyc-danger, #ef4444) 10%, transparent)":"var(--metakyc-surface, #f3f4f6)",transition:"all 0.3s ease"},children:[e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:W?"var(--metakyc-danger, #ef4444)":"var(--metakyc-text-muted, #9ca3af)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("polyline",{points:"12 6 12 12 16 14"})]}),e.jsx("span",{style:{fontSize:"16px",fontWeight:700,fontVariantNumeric:"tabular-nums",color:W?"var(--metakyc-danger, #ef4444)":"var(--metakyc-text-primary, #111827)",transition:"color 0.3s ease"},children:yt(A)})]})]}),e.jsxs("div",{style:{marginTop:"12px"},children:[e.jsx("div",{style:{height:"4px",borderRadius:"999px",backgroundColor:"var(--metakyc-border, #e5e7eb)",overflow:"hidden"},children:e.jsx("div",{style:{height:"100%",borderRadius:"999px",backgroundColor:"var(--metakyc-primary, #2563eb)",width:`${ce/he*100}%`,transition:"width 0.3s ease"}})}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginTop:"4px"},children:[e.jsxs("span",{style:{fontSize:"11px",color:"var(--metakyc-text-muted, #9ca3af)"},children:[ce," answered"]}),e.jsxs("span",{style:{fontSize:"11px",color:"var(--metakyc-text-muted, #9ca3af)"},children:[V," attempt",V!==1?"s":""," left"]})]})]})]}),e.jsxs(te,{children:[de&&e.jsx(Is,{question:de,index:X,selectedAnswer:v[de.id],onSelect:z=>Q(de.id,z),disabled:y}),he>1&&e.jsx("div",{style:{display:"flex",justifyContent:"center",gap:"6px",marginTop:"20px",flexWrap:"wrap"},children:a.appropriatenessQuestions.map((z,_)=>e.jsx("button",{type:"button",onClick:()=>R(_),style:{width:"28px",height:"28px",borderRadius:"8px",border:_===X?"2px solid var(--metakyc-primary, #2563eb)":"1px solid var(--metakyc-border, #e5e7eb)",backgroundColor:v[z.id]?_===X?"color-mix(in srgb, var(--metakyc-primary, #2563eb) 15%, transparent)":"color-mix(in srgb, var(--metakyc-primary, #2563eb) 8%, transparent)":_===X?"var(--metakyc-surface, #f9fafb)":"var(--metakyc-background, #ffffff)",color:v[z.id]?"var(--metakyc-primary, #2563eb)":"var(--metakyc-text-muted, #9ca3af)",fontSize:"12px",fontWeight:600,cursor:"pointer",transition:"all 0.15s ease",padding:0,display:"flex",alignItems:"center",justifyContent:"center"},children:_+1},z.id))}),Y&&e.jsxs("div",{style:{marginTop:"16px",padding:"12px 14px",borderRadius:"10px",backgroundColor:"color-mix(in srgb, #f59e0b 10%, transparent)",border:"1px solid color-mix(in srgb, #f59e0b 25%, transparent)",display:"flex",alignItems:"center",gap:"10px"},children:[e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"#f59e0b",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("polyline",{points:"12 6 12 12 16 14"})]}),e.jsx("p",{style:{fontSize:"13px",color:"#b45309",margin:0,fontWeight:500},children:"Time's up! Your answers are being submitted."})]}),g&&!Y&&e.jsx("div",{style:{marginTop:"16px",padding:"12px 14px",borderRadius:"10px",backgroundColor:"color-mix(in srgb, var(--metakyc-danger, #ef4444) 8%, transparent)",border:"1px solid color-mix(in srgb, var(--metakyc-danger, #ef4444) 20%, transparent)"},children:e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-danger, #ef4444)",margin:0},children:g})})]}),e.jsx(be,{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%"},children:[e.jsx(J,{type:"button",variant:"outline",onClick:()=>{X>0?R(z=>z-1):s==null||s()},disabled:y,children:X>0?"Previous":"Cancel"}),e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[!fe&&e.jsx(J,{type:"button",onClick:()=>R(z=>z+1),children:"Next"}),(fe||I)&&e.jsx(J,{type:"button",isLoading:y,onClick:()=>G(),disabled:!I&&!Y,style:{opacity:I||Y?1:.5},children:Y?"Submitting...":"Submit Test"})]})]})})]})},Rs={questions:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M9 11l3 3L22 4"}),e.jsx("path",{d:"M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"})]}),time:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("polyline",{points:"12 6 12 12 16 14"})]}),target:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("circle",{cx:"12",cy:"12",r:"6"}),e.jsx("circle",{cx:"12",cy:"12",r:"2"})]}),retry:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polyline",{points:"23 4 23 10 17 10"}),e.jsx("path",{d:"M20.49 15a9 9 0 1 1-2.12-9.36L23 10"})]})},ct=({icon:t,label:r,value:s,variant:n="default"})=>{const a=n==="warning";return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",padding:"14px",borderRadius:"10px",backgroundColor:a?"color-mix(in srgb, #f59e0b 8%, transparent)":"var(--metakyc-surface, #f9fafb)",border:a?"1px solid color-mix(in srgb, #f59e0b 20%, transparent)":"1px solid var(--metakyc-border, #e5e7eb)"},children:[e.jsx("div",{style:{color:a?"#f59e0b":"var(--metakyc-primary, #2563eb)",flexShrink:0},children:Rs[t]}),e.jsxs("div",{children:[e.jsx("p",{style:{fontSize:"12px",color:"var(--metakyc-text-muted, #9ca3af)",margin:0},children:r}),e.jsx("p",{style:{fontSize:"15px",fontWeight:600,color:a?"#b45309":"var(--metakyc-text-primary, #111827)",margin:0,marginTop:"1px"},children:s})]})]})},Is=({question:t,selectedAnswer:r,onSelect:s,disabled:n})=>e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"16px"},children:[t.groupName&&e.jsx("span",{style:{display:"inline-block",fontSize:"11px",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em",color:"var(--metakyc-primary, #2563eb)",marginBottom:"8px"},children:t.groupName}),e.jsx("h3",{style:{fontSize:"16px",fontWeight:600,color:"var(--metakyc-text-primary, #111827)",margin:0,lineHeight:1.5},children:t.question})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:t.answers.map((a,o)=>{const c=r===a;return e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"12px",padding:"14px 16px",borderRadius:"10px",border:`2px solid ${c?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #e5e7eb)"}`,backgroundColor:c?"color-mix(in srgb, var(--metakyc-primary, #2563eb) 5%, var(--metakyc-background, #ffffff))":"var(--metakyc-background, #ffffff)",cursor:n?"default":"pointer",transition:"all 0.15s ease",opacity:n?.6:1},onMouseEnter:d=>{!n&&!c&&(d.currentTarget.style.borderColor="color-mix(in srgb, var(--metakyc-primary, #2563eb) 50%, var(--metakyc-border, #e5e7eb))")},onMouseLeave:d=>{c||(d.currentTarget.style.borderColor="var(--metakyc-border, #e5e7eb)")},children:[e.jsx("div",{style:{width:"20px",height:"20px",borderRadius:"50%",border:`2px solid ${c?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #d1d5db)"}`,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,transition:"border-color 0.15s ease"},children:c&&e.jsx("div",{style:{width:"10px",height:"10px",borderRadius:"50%",backgroundColor:"var(--metakyc-primary, #2563eb)"}})}),e.jsx("input",{type:"radio",name:`q-${t.id}`,value:a,checked:c,onChange:()=>s(a),disabled:n,style:{position:"absolute",opacity:0,width:0,height:0}}),e.jsx("span",{style:{fontSize:"14px",color:c?"var(--metakyc-text-primary, #111827)":"var(--metakyc-text-secondary, #6b7280)",fontWeight:c?500:400,transition:"color 0.15s ease"},children:a})]},o)})})]}),_r=({applicantId:t,onComplete:r,onBack:s})=>{var Ge,ze,et,Ue;const{applicantService:n,baseInformationService:a,identityService:o,config:c,currentTheme:d}=Ne(),{identityData:y,provider:p,token:g,isLoading:T,error:v,requestIdentity:E,restartIdentity:A}=Nr(t),[k,S]=i.useState(null),[D,Y]=i.useState(null),[L,B]=i.useState([]),[U,X]=i.useState([]),[R,f]=i.useState(!0),[O,q]=i.useState(!1),[Q,$]=i.useState(null),[G,se]=i.useState(!1),V=i.useRef(!1),[he,ce]=i.useState({}),[de,fe]=i.useState({}),I=d!=null&&d.reviewPageFields&&d.reviewPageFields.length>0?d.reviewPageFields[0]:null,W=!!(d!=null&&d.reviewPageDisabled),z=i.useRef(!1);z.current=W;const _=qe.useForm({defaultValues:{street:"",streetNumber:"",city:"",zip:"",country:"",nationality:"",phonenumber:""}});i.useEffect(()=>{if(W){V.current||(V.current=!0,E().then(()=>q(!0)).catch(M=>console.error("[Identity] Auto-request failed:",M)).finally(()=>f(!1)));return}(async()=>{try{const[M,K,H]=await Promise.all([n.getApplicantData(t),a.getCountries("","en"),a.getCountries("","en",40)]);Y(M);const Z=new Set,m=K.map(h=>({value:h.abbreviation3||h.abbreviation,label:h.name})).filter(h=>!h.value||Z.has(h.value)?!1:(Z.add(h.value),!0));B(m);const C=new Set,F=H.filter(h=>h.countryCode).map(h=>({value:h.countryCode,label:`${h.countryCode} – ${h.name}`})).filter(h=>C.has(h.value)?!1:(C.add(h.value),!0));X(F);const u=M.applicantRequestData;if(ce({firstName:(u==null?void 0:u.firstName)||"",lastName:(u==null?void 0:u.lastName)||"",email:(u==null?void 0:u.email)||"",dateOfBirth:(u==null?void 0:u.dateOfBirth)||"",title:(u==null?void 0:u.title)||"",salutation:(u==null?void 0:u.salutation)||"",phonenumber:(u==null?void 0:u.phonenumber)||"",mobileCountryCode:(u==null?void 0:u.mobileCountryCode)||"",street:(u==null?void 0:u.street)||"",streetNumber:(u==null?void 0:u.streetNumber)||"",city:(u==null?void 0:u.city)||"",zip:(u==null?void 0:u.zip)||"",country:(u==null?void 0:u.country)||"",nationality:(u==null?void 0:u.nationality)||"",taxCountry:(u==null?void 0:u.taxCountry)||"",countryOfBirth:(u==null?void 0:u.countryOfBirth)||"",placeOfBirth:(u==null?void 0:u.placeOfBirth)||"",educationLevel:(u==null?void 0:u.educationLevel)||"",occupation:(u==null?void 0:u.occupation)||"",taxNumber:(u==null?void 0:u.taxNumber)||"",defaultLanguage:(u==null?void 0:u.defaultLanguage)||""}),_.reset({street:(u==null?void 0:u.street)||"",streetNumber:(u==null?void 0:u.streetNumber)||"",city:(u==null?void 0:u.city)||"",zip:(u==null?void 0:u.zip)||"",country:(u==null?void 0:u.country)||"",nationality:(u==null?void 0:u.nationality)||"",phonenumber:(u==null?void 0:u.phonenumber)||""}),M.kycRecords&&M.kycRecords.length>0&&M.kycRecords[0].providerTokenObject!==null&&!V.current&&z.current){console.log("[Identity] Review page disabled + existing identity — auto-requesting..."),V.current=!0;try{await E(),q(!0)}catch(h){console.error("[Identity] Auto-request failed:",h)}}}catch(M){console.error("Error loading applicant data:",M)}finally{f(!1)}})()},[t]),i.useEffect(()=>{y&&!O&&z.current&&(console.log("[Identity] Review page disabled — showing cached provider"),q(!0))},[y,O]),i.useEffect(()=>{if(g){if(g.expiresAt){const x=new Date(g.expiresAt).getTime();if(Date.now()>=x){console.warn("[Identity] Token has expired (expiresAt)"),se(!0),$("Your verification session has expired. Please restart.");return}}if(g.url)try{const M=new URL(g.url).toString().toLowerCase();if(M.includes("expired")||M.includes("invalid")||M.includes("error")){console.warn("[Identity] Token URL indicates expiration"),se(!0),$("Your verification link has expired. Please restart.");return}}catch{console.error("[Identity] Invalid token URL")}if(g.status==="expired"||g.error==="expired"||g.expired===!0){console.warn("[Identity] Token object indicates expiration"),se(!0),$("Your verification session has expired. Please restart.");return}}},[g]);const me=p!==null&&p===Ae.Sumsub;i.useEffect(()=>{if(p!==null&&g&&!k&&O&&!G){const x=p;if(me){console.log("[Sumsub] Fetching access token for Web SDK…"),$(null),(async()=>{try{const M=await o.refreshSumsubToken(t),K=_e.parseProviderConfig(p,g,c);K.accessToken=M,K.onTokenRefresh=()=>o.refreshSumsubToken(t);const H=_e.createProvider(p,K);H.onComplete(Z=>{console.log("[Sumsub] Verification complete:",Z),r==null||r()}),H.onError(Z=>{console.error("[Sumsub] SDK error:",Z),(typeof Z=="string"?Z:(Z==null?void 0:Z.message)||"Unknown error").toLowerCase().includes("expired")&&(se(!0),$("Session expired. Please restart."))}),await H.initialize("sumsub-websdk-container"),console.log("[Sumsub] Web SDK launched"),S(H)}catch(M){console.error("[Sumsub] Initialization error:",M),$(`Failed to initialize: ${M.message||M}`),String(M.message||M).toLowerCase().includes("expired")&&se(!0)}})();return}if(g.url){console.log("[Identity] Loading provider URL for user verification:",g.url),$(null);try{if(new URL(g.url),x===Ae.SardinAI){console.log("[SardinAI] Initializing Risk SDK in background...");try{const M=_e.parseProviderConfig(p,g,c);_e.createProvider(p,M).initialize().then(()=>console.log("[SardinAI] Risk SDK initialized in background")).catch(H=>console.warn("[SardinAI] Risk SDK init failed (non-blocking):",H))}catch(M){console.warn("[SardinAI] Risk SDK setup failed (non-blocking):",M)}}S({type:"url",url:g.url})}catch(M){console.error("[Identity] Invalid URL:",M),$("Invalid verification URL. Please restart."),se(!0)}return}if(x===Ae.SardinAI){console.log("[SardinAI] No URL provided - initializing Risk SDK only..."),$(null);try{const M=_e.parseProviderConfig(p,g,c),K=_e.createProvider(p,M);K.initialize().then(()=>{console.log("[SardinAI] Risk SDK initialized successfully"),S(K),setTimeout(()=>r==null?void 0:r(),2e3)}).catch(H=>{var m;console.error("[SardinAI] Failed to initialize:",H);const Z=((m=H.message)==null?void 0:m.toLowerCase())||"";Z.includes("expired")||Z.includes("invalid")||Z.includes("401")||Z.includes("400")?(se(!0),$("Session expired or invalid. Please restart verification.")):$(`Failed to initialize: ${H.message}`)})}catch(M){console.error("[SardinAI] Error creating provider:",M),$(`Configuration error: ${M.message}`)}return}try{$(null);const M=_e.parseProviderConfig(p,g,c),K=_e.createProvider(p,M);x===Ae.Onfido&&K.initialize("identity-container").catch(H=>{console.error("[Onfido] Initialization error:",H),$(`Failed to initialize: ${H.message}`)}),S(K)}catch(M){console.error("[Identity] Provider setup error:",M),$(`Setup error: ${M.message}`)}}return()=>{if(k&&k.destroy)try{k.destroy()}catch(x){console.error("[Identity] Error destroying provider:",x)}}},[p,g,k,O,r,G,me,t,c,o]);const N=async()=>{try{$(null),se(!1),await E(),q(!0)}catch(x){console.error("Error starting identity verification:",x)}},re=async()=>{try{$(null),se(!1),S(null),console.log("[Identity] Restarting verification..."),await A(),q(!0)}catch(x){console.error("Error restarting identity verification:",x),$(x.message||"Failed to restart verification")}};if(R||T)return e.jsx(ee,{children:e.jsxs(te,{children:[e.jsx(Ee,{className:"my-8"}),e.jsx("p",{className:"text-center text-gray-600 dark:text-gray-400 mt-4",children:"Loading identity verification..."})]})});if(v)return e.jsx(ee,{children:e.jsx(te,{children:e.jsxs("p",{className:"text-danger-500",children:["Error: ",v.message]})})});if(O&&(Q||G))return e.jsxs(ee,{children:[e.jsx(ge,{children:e.jsx("h2",{className:"text-2xl font-bold text-gray-900 dark:text-white",children:"Verification Session Issue"})}),e.jsxs(te,{children:[e.jsx("div",{className:"p-4 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg mb-6",children:e.jsxs("div",{className:"flex items-start",children:[e.jsx("svg",{className:"h-6 w-6 text-red-600 dark:text-red-400 mr-3 mt-0.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-red-900 dark:text-red-100 mb-1",children:G?"Session Expired":"Verification Error"}),e.jsx("p",{className:"text-red-800 dark:text-red-200 text-sm",children:Q||"Your verification session has expired and needs to be restarted."})]})]})}),e.jsxs("div",{className:"bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg p-4",children:[e.jsx("h3",{className:"font-semibold text-blue-900 dark:text-blue-100 mb-2",children:"What to do next:"}),e.jsxs("ul",{className:"text-blue-800 dark:text-blue-200 text-sm space-y-1 list-disc list-inside",children:[e.jsx("li",{children:'Click "Restart Verification" below to generate a new session'}),e.jsx("li",{children:"Complete the verification process without delays"}),e.jsx("li",{children:"If issues persist, contact support"})]})]})]}),e.jsxs(be,{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[s&&e.jsx(J,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(J,{type:"button",onClick:re,disabled:T,children:T?"Restarting...":"Restart Verification"})]})]});if(O&&y){const x=p;return me?e.jsxs("div",{style:{background:"var(--metakyc-background, #ffffff)",borderRadius:"12px",border:"1px solid var(--metakyc-border, #e5e7eb)",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"20px 24px",borderBottom:"1px solid var(--metakyc-border, #e5e7eb)"},children:[e.jsxs("div",{children:[e.jsx("h2",{style:{margin:0,fontSize:"20px",fontWeight:700,color:"var(--metakyc-text-primary, #111827)"},children:"Identity Verification"}),e.jsx("p",{style:{margin:"4px 0 0",fontSize:"14px",color:"var(--metakyc-text-secondary, #6b7280)"},children:"Please complete the identity verification process"})]}),e.jsx("button",{type:"button",onClick:re,disabled:T,style:{padding:"6px 14px",fontSize:"13px",fontWeight:500,borderRadius:"8px",border:"1px solid var(--metakyc-border, #d1d5db)",background:"var(--metakyc-background, #ffffff)",color:"var(--metakyc-text-primary, #111827)",cursor:T?"not-allowed":"pointer",opacity:T?.5:1},children:T?"Restarting…":"Restart"})]}),e.jsx("div",{id:"sumsub-websdk-container",style:{minHeight:"520px",width:"100%",padding:"16px 24px",background:"var(--metakyc-background, #ffffff)"}}),s&&e.jsx("div",{style:{padding:"16px 24px",borderTop:"1px solid var(--metakyc-border, #e5e7eb)"},children:e.jsx(J,{variant:"outline",onClick:s,children:"Back"})})]}):g!=null&&g.url?e.jsxs(ee,{children:[e.jsx(ge,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold",children:"Identity Verification"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:"Please complete the identity verification process"})]}),e.jsx(J,{type:"button",variant:"outline",size:"sm",onClick:re,disabled:T,children:"Restart"})]})}),e.jsxs(te,{children:[e.jsx("div",{className:"mb-4 p-3 bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg",children:e.jsxs("p",{className:"text-yellow-800 dark:text-yellow-200 text-sm",children:[e.jsx("strong",{children:"Important:"}),' If you see an "expired" or "invalid link" message below, click the "Restart" button above to generate a new verification session.']})}),e.jsx("div",{className:"w-full",style:{height:"600px"},children:e.jsx("iframe",{src:g.url,className:"w-full h-full border-0 rounded-lg",allow:"camera; microphone; geolocation",title:"Identity Verification",onLoad:M=>{var K,H,Z;console.log("[Identity] Iframe loaded");try{const m=M.target,C=m.contentDocument||((K=m.contentWindow)==null?void 0:K.document);if(C){const F=((Z=(H=C.body)==null?void 0:H.textContent)==null?void 0:Z.toLowerCase())||"";(F.includes("expired")||F.includes("invalid")||F.includes("error"))&&(console.warn("[Identity] Iframe shows expiration message"),se(!0),$("Your verification link has expired."))}}catch{console.log("[Identity] Cannot check iframe content (CORS)")}}})})]}),s&&e.jsx(be,{children:e.jsx(J,{variant:"outline",onClick:s,children:"Back"})})]}):x===Ae.SardinAI?e.jsxs(ee,{children:[e.jsxs(ge,{children:[e.jsx("h2",{className:"text-2xl font-bold",children:"Device Risk Assessment"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:"Analyzing device security and behavioral patterns..."})]}),e.jsx(te,{children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx(Ee,{className:"mb-4"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:"Please wait while we verify your device security"}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-500 mt-2",children:"This process is automatic and will complete in a few seconds"})]})})]}):e.jsxs(ee,{children:[e.jsxs(ge,{children:[e.jsx("h2",{className:"text-2xl font-bold",children:"Identity Verification"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:"Please complete the identity verification process"})]}),e.jsx(te,{children:e.jsx("div",{id:"identity-container",className:"min-h-[400px]"})}),s&&e.jsx(be,{children:e.jsx(J,{variant:"outline",onClick:s,children:"Back"})})]})}const ue=new Set(["country","nationality","taxCountry","countryOfBirth","mobileCountryCode","otherNationality"]),ne=(x=4)=>{const M=Math.min(4,Math.max(1,Number(x)||4));return{gridColumn:`span ${M} / span ${M}`}},ve=(x,M)=>{if(!M&&M!==0)return"—";if(ue.has(x)&&x!=="mobileCountryCode"){const K=L.find(H=>H.value===M);return K?K.label:String(M)}return String(M)},Fe=({helpText:x})=>{const[M,K]=i.useState(!1),H=i.useRef(null),[,Z]=i.useState({top:0,left:0}),m=()=>{if(H.current){const C=H.current.getBoundingClientRect();Z({top:C.bottom+window.scrollY+6,left:C.left+window.scrollX})}K(!0)};return e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"metakyc-help-btn",ref:H,onClick:m,style:{width:18,height:18,borderRadius:"50%",border:"1.5px solid var(--metakyc-primary, #2563eb)",background:"transparent",color:"var(--metakyc-primary, #2563eb)",fontSize:11,fontWeight:700,cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,lineHeight:1,position:"relative",zIndex:2},children:"?"}),M&&pt.createPortal(e.jsx("div",{style:{position:"fixed",inset:0,zIndex:99999,background:"rgba(0,0,0,0.55)",backdropFilter:"blur(6px)",WebkitBackdropFilter:"blur(6px)",display:"flex",alignItems:"center",justifyContent:"center"},onClick:()=>K(!1),children:e.jsxs("div",{onClick:C=>C.stopPropagation(),style:{background:"var(--metakyc-surface, var(--metakyc-background, #ffffff))",border:"1px solid var(--metakyc-border, #e5e7eb)",borderRadius:"var(--metakyc-border-radius, 8px)",padding:"20px 24px",maxWidth:400,width:"90%",boxShadow:"0 24px 64px rgba(0,0,0,0.4)"},children:[e.jsx("div",{dangerouslySetInnerHTML:{__html:x},style:{fontSize:13,color:"var(--metakyc-text-primary, #111827)",lineHeight:1.6}}),e.jsx("button",{type:"button",onClick:()=>K(!1),style:{marginTop:12,padding:"4px 12px",fontSize:12,border:"1px solid var(--metakyc-border, #e5e7eb)",borderRadius:"var(--metakyc-border-radius, 6px)",background:"transparent",cursor:"pointer",color:"var(--metakyc-text-secondary, #6b7280)"},children:"Close"})]})}),document.body)]})},ke=(x,M)=>M?e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:5,flexWrap:"nowrap"},children:[e.jsx("div",{style:{flex:1,minWidth:0},children:x}),e.jsx("div",{style:{paddingTop:24},children:e.jsx(Fe,{helpText:M})})]}):x,Oe=(x,M)=>{const K=`cf-${M}`,H=x.paramName??"",Z=de[H];if(x.customType==="br")return e.jsx("div",{style:{...ne(x.colSpan),minHeight:"0.5rem"}},K);if(x.customType==="paragraph")return e.jsx("div",{style:ne(x.colSpan),children:e.jsx("div",{className:"text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},dangerouslySetInnerHTML:{__html:x.label||""}})},K);if(x.customType==="html")return e.jsx("div",{style:ne(x.colSpan),dangerouslySetInnerHTML:{__html:x.label||""}},K);if(x.customType==="link")return e.jsx("div",{style:ne(x.colSpan),children:ke(e.jsx("a",{href:x.linkUrl??"#",target:"_blank",rel:"noopener noreferrer",className:"text-sm underline",style:{color:"var(--metakyc-primary, #6366f1)"},children:x.displayText||x.label||x.linkText||x.linkUrl}),x.helpText)},K);if(x.customType==="checkbox"||x.customType==="link_checkbox"){const m=Z==="true"||Z===!0;return e.jsx("div",{style:ne(x.colSpan),children:ke(e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:8,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:!!m,onChange:C=>fe(F=>({...F,[H]:String(C.target.checked)})),style:{width:16,height:16,flexShrink:0,marginTop:2,accentColor:"var(--metakyc-primary, #6366f1)"}}),e.jsx("span",{className:"text-sm",style:{color:"var(--metakyc-text-primary, #111827)"},children:x.customType==="link_checkbox"&&x.linkUrl?e.jsxs(e.Fragment,{children:[e.jsx("a",{href:x.linkUrl,target:"_blank",rel:"noopener noreferrer",style:{color:"var(--metakyc-primary, #6366f1)",textDecoration:"underline"},children:x.linkText||x.label}),x.label&&x.linkText?` ${x.label}`:""]}):x.displayText||x.label})]}),x.helpText)},K)}if(x.customType==="group_checkbox"){const m=Array.isArray(Z)?Z:Z?[Z]:[],C=F=>{x.singleSelect?fe(u=>({...u,[H]:m[0]===F?[]:[F]})):fe(u=>({...u,[H]:m.includes(F)?m.filter(l=>l!==F):[...m,F]}))};return e.jsx("div",{style:ne(x.colSpan),children:ke(e.jsxs("div",{className:"space-y-1.5",children:[x.label&&e.jsx("p",{className:"text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:x.displayText||x.label}),(x.options||[]).map(F=>e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:8,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:m.includes(F.value),onChange:()=>C(F.value),style:{width:16,height:16,flexShrink:0,marginTop:2,accentColor:"var(--metakyc-primary, #6366f1)"}}),e.jsx("span",{className:"text-sm",style:{color:"var(--metakyc-text-primary, #111827)"},children:F.label})]},F.value))]}),x.helpText)},K)}return x.customType==="radio_group"?e.jsx("div",{style:ne(x.colSpan),children:ke(e.jsxs("div",{className:"space-y-1.5",children:[x.label&&e.jsx("p",{className:"text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:x.displayText||x.label}),(x.options||[]).map(m=>e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:8,cursor:"pointer"},children:[e.jsx("input",{type:"radio",name:`rg-${H}`,value:m.value,checked:Z===m.value,onChange:()=>fe(C=>({...C,[H]:m.value})),style:{width:16,height:16,flexShrink:0,marginTop:2,accentColor:"var(--metakyc-primary, #6366f1)"}}),e.jsx("span",{className:"text-sm",style:{color:"var(--metakyc-text-primary, #111827)"},children:m.label})]},m.value))]}),x.helpText)},K):e.jsx("div",{style:ne(x.colSpan),children:ke(e.jsx(ye,{label:x.displayText||x.label||H,value:String(Z??""),onChange:m=>fe(C=>({...C,[H]:m.target.value}))}),x.helpText)},K)},Xe=(x,M)=>{if(x.isCustom)return Oe(x,M);const K=x.name??"",H=Qe[K],Z=x.displayText||(H==null?void 0:H.label)||K,m=he[K]??"",C=K==="mobileCountryCode",F=!!(H!=null&&H.countriesType)&&!C;return x.editable?C?e.jsx("div",{style:ne(x.colSpan??2),children:ke(e.jsx(De,{label:Z,value:String(m),onChange:u=>ce(l=>({...l,[K]:u})),options:[{value:"",label:"Select country code…"},...U]}),x.helpText)},`epc-${M}`):F?e.jsx("div",{style:ne(x.colSpan??2),children:ke(e.jsx(De,{label:Z,value:String(m),onChange:u=>ce(l=>({...l,[K]:u})),options:[{value:"",label:`Select ${Z.toLowerCase()}…`},...L]}),x.helpText)},`ec-${M}`):e.jsx("div",{style:ne(x.colSpan??2),children:ke(e.jsx(ye,{label:Z,type:(H==null?void 0:H.type)==="date"?"date":(H==null?void 0:H.type)==="email"?"email":"text",value:String(m),onChange:u=>ce(l=>({...l,[K]:u.target.value}))}),x.helpText)},`ei-${M}`):e.jsx("div",{style:ne(x.colSpan??2),children:ke(e.jsxs(e.Fragment,{children:[e.jsx("label",{className:"block text-sm font-medium mb-0.5",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:Z}),e.jsx("p",{className:"text-sm",style:{color:"var(--metakyc-text-primary, #111827)",minHeight:"1.5rem"},children:ve(K,m)})]}),x.helpText)},`ro-${M}`)};if(I){const x=I.title||"Review Your Information",M=I.subtitle||"Please review and confirm your information before starting identity verification";return e.jsx("form",{onSubmit:K=>{K.preventDefault(),N()},children:e.jsxs(ee,{children:[e.jsxs(ge,{children:[e.jsx("h2",{className:"text-lg font-bold",style:{color:"var(--metakyc-text-primary, #111827)"},children:x}),e.jsx("p",{className:"mt-1 text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:M})]}),e.jsx(te,{children:e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, minmax(0, 1fr))",gap:"1rem"},children:I.fields.map((K,H)=>Xe(K,H))})}),e.jsxs(be,{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[s&&e.jsx(J,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(J,{type:"submit",isLoading:T,children:"Confirm and Start Verification"})]})]})})}return e.jsx("form",{onSubmit:_.handleSubmit(N),children:e.jsxs(ee,{children:[e.jsxs(ge,{children:[e.jsx("h2",{className:"text-lg font-bold",style:{color:"var(--metakyc-text-primary, #111827)"},children:"Review Your Information"}),e.jsx("p",{className:"mt-1 text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"Please review and confirm your information before starting identity verification"})]}),e.jsxs(te,{className:"space-y-6",children:[e.jsx("div",{className:"space-y-4 pb-4",style:{borderBottom:"1px solid var(--metakyc-border, #e5e7eb)"},children:[{label:"Name",value:`${((Ge=D==null?void 0:D.applicantRequestData)==null?void 0:Ge.firstName)||""} ${((ze=D==null?void 0:D.applicantRequestData)==null?void 0:ze.lastName)||""}`.trim()},{label:"Email",value:(et=D==null?void 0:D.applicantRequestData)==null?void 0:et.email},{label:"Date of Birth",value:((Ue=D==null?void 0:D.applicantRequestData)==null?void 0:Ue.dateOfBirth)||"Not provided"}].map(({label:x,value:M})=>e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:x}),e.jsx("p",{className:"mt-1 text-base",style:{color:"var(--metakyc-text-primary, #111827)"},children:M})]},x))}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-base font-semibold",style:{color:"var(--metakyc-text-primary, #111827)"},children:"Address Information"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(qe.Controller,{control:_.control,name:"country",render:({field:x})=>e.jsx(De,{label:"Country",value:x.value,onChange:x.onChange,options:[{value:"",label:"Select country…"},...L]})}),e.jsx(qe.Controller,{control:_.control,name:"nationality",render:({field:x})=>e.jsx(De,{label:"Nationality",value:x.value,onChange:x.onChange,options:[{value:"",label:"Select nationality…"},...L]})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(qe.Controller,{control:_.control,name:"street",render:({field:x})=>e.jsx(ye,{...x,label:"Street"})}),e.jsx(qe.Controller,{control:_.control,name:"streetNumber",render:({field:x})=>e.jsx(ye,{...x,label:"Street Number"})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(qe.Controller,{control:_.control,name:"city",render:({field:x})=>e.jsx(ye,{...x,label:"City"})}),e.jsx(qe.Controller,{control:_.control,name:"zip",render:({field:x})=>e.jsx(ye,{...x,label:"ZIP / Postal Code"})})]}),e.jsx(qe.Controller,{control:_.control,name:"phonenumber",render:({field:x})=>e.jsx(ye,{...x,label:"Phone Number",type:"tel"})})]})]}),e.jsxs(be,{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[s&&e.jsx(J,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(J,{type:"submit",isLoading:T,children:"Confirm and Start Verification"})]})]})})},ft=({kycStatus:t,reviewStatus:r,workflowResult:s,customMessage:n,onContinue:a,onContactSupport:o})=>{const d=t===Ve.Approved?{type:"success",title:"Verification Approved",icon:"✓",iconBg:"bg-green-100 dark:bg-green-900/30",iconColor:"text-green-600 dark:text-green-400",message:"Your identity verification has been successfully approved."}:t===Ve.Rejected?{type:"error",title:"Verification Rejected",icon:"✕",iconBg:"bg-red-100 dark:bg-red-900/30",iconColor:"text-red-600 dark:text-red-400",message:"Unfortunately, your identity verification was not approved."}:t===Ve.Pending||t===Ve.InProgress?{type:"pending",title:"Verification Pending",icon:"⏱",iconBg:"bg-blue-100 dark:bg-blue-900/30",iconColor:"text-blue-600 dark:text-blue-400",message:"Your identity verification is currently being processed."}:r===Ye.Approved?{type:"success",title:"Application Approved",icon:"✓",iconBg:"bg-green-100 dark:bg-green-900/30",iconColor:"text-green-600 dark:text-green-400",message:"Your application has been approved."}:r===Ye.Reject?{type:"error",title:"Application Rejected",icon:"✕",iconBg:"bg-red-100 dark:bg-red-900/30",iconColor:"text-red-600 dark:text-red-400",message:"Your application has been rejected."}:r===Ye.UnderReview||r===Ye.AdminReview?{type:"pending",title:"Under Review",icon:"📋",iconBg:"bg-yellow-100 dark:bg-yellow-900/30",iconColor:"text-yellow-700 dark:text-yellow-400",message:"Your application is currently under manual review."}:s===ot.Success?{type:"success",title:"Process Complete",icon:"✓",iconBg:"bg-green-100 dark:bg-green-900/30",iconColor:"text-green-600 dark:text-green-400",message:"Your verification process has been completed successfully."}:s===ot.Failed?{type:"error",title:"Process Failed",icon:"✕",iconBg:"bg-red-100 dark:bg-red-900/30",iconColor:"text-red-600 dark:text-red-400",message:"The verification process could not be completed."}:s===ot.AdminReview?{type:"pending",title:"Admin Review Required",icon:"📋",iconBg:"bg-yellow-100 dark:bg-yellow-900/30",iconColor:"text-yellow-700 dark:text-yellow-400",message:"Your application requires administrator review."}:{type:"pending",title:"Processing",icon:"⏱",iconBg:"bg-blue-100 dark:bg-blue-900/30",iconColor:"text-blue-600 dark:text-blue-400",message:"Your application is being reviewed."};return e.jsxs(ee,{children:[e.jsxs(te,{className:"py-12",children:[e.jsx("div",{className:"flex justify-center mb-6",children:e.jsx("div",{className:`w-24 h-24 rounded-full flex items-center justify-center ${d.iconBg}`,children:e.jsx("span",{className:`text-5xl ${d.iconColor}`,children:d.icon})})}),e.jsx("h2",{className:"text-3xl font-bold text-center mb-4",style:{color:"var(--metakyc-text-primary, #111827)"},children:d.title}),e.jsx("div",{className:"flex justify-center mb-6",children:e.jsx(kt,{variant:d.type==="success"?"success":d.type==="error"?"danger":d.type==="pending"?"warning":"info",children:t!=null?Ve[t]:Ye[r]})}),e.jsx("p",{className:"text-center mb-6 max-w-md mx-auto",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:n||d.message}),d.type==="success"&&e.jsxs("div",{className:"bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg p-4 mb-6",children:[e.jsx("h3",{className:"font-semibold text-green-900 dark:text-green-100 mb-2",children:"What's Next?"}),e.jsxs("ul",{className:"text-sm text-green-800 dark:text-green-200 space-y-1",children:[e.jsx("li",{children:"✓ Your identity has been verified"}),e.jsx("li",{children:"✓ You can now proceed with your application"}),e.jsx("li",{children:"✓ All features are now accessible"})]})]}),d.type==="error"&&e.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4 mb-6",children:[e.jsx("h3",{className:"font-semibold text-red-900 dark:text-red-100 mb-2",children:"What Can You Do?"}),e.jsxs("ul",{className:"text-sm text-red-800 dark:text-red-200 space-y-2",children:[e.jsx("li",{children:"• Review the requirements and ensure all information is correct"}),e.jsx("li",{children:"• Contact our support team for assistance"}),e.jsx("li",{children:"• You may be able to resubmit your application"})]})]}),d.type==="pending"&&e.jsxs("div",{className:"bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg p-4 mb-6",children:[e.jsx("h3",{className:"font-semibold text-blue-900 dark:text-blue-100 mb-2",children:"What Happens Next?"}),e.jsxs("ul",{className:"text-sm text-blue-800 dark:text-blue-200 space-y-2",children:[e.jsx("li",{children:"• Our team is reviewing your information"}),e.jsx("li",{children:"• You will be notified via email once the review is complete"}),e.jsx("li",{children:"• This typically takes 24-48 hours"}),e.jsx("li",{children:"• No action is required from you at this time"})]})]}),e.jsx("div",{className:"mt-6 pt-6",style:{borderTop:"1px solid var(--metakyc-border, #e5e7eb)"},children:e.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:"KYC Status:"}),e.jsx("div",{className:"font-medium mt-1",style:{color:"var(--metakyc-text-primary, #111827)"},children:t!=null?Ve[t]:"Not Available"})]}),e.jsxs("div",{children:[e.jsx("span",{style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:"Review Status:"}),e.jsx("div",{className:"font-medium mt-1",style:{color:"var(--metakyc-text-primary, #111827)"},children:Ye[r]})]})]})})]}),e.jsxs(be,{style:{display:"flex",justifyContent:"center",gap:"1rem"},children:[d.type==="success"&&a&&e.jsx(J,{onClick:a,size:"lg",children:"Continue"}),d.type==="error"&&e.jsxs(e.Fragment,{children:[o&&e.jsx(J,{variant:"outline",onClick:o,children:"Contact Support"}),a&&e.jsx(J,{onClick:a,children:"Try Again"})]}),d.type==="pending"&&e.jsx("div",{className:"text-center",children:e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Please check back later or wait for our email notification"})})]})]})},Hr=({config:t,className:r=""})=>!(t!=null&&t.visible)||!(t!=null&&t.url)?null:e.jsx("div",{className:`metakyc-logo ${r}`,children:e.jsx("img",{src:t.url,alt:t.alt||"Company Logo",style:{width:t.width||"auto",height:t.height||"40px",maxWidth:"100%",objectFit:"contain"},onError:s=>{console.warn("[Logo] Failed to load logo:",t.url),s.target.style.display="none"}})}),nt=({title:t,subtitle:r,className:s=""})=>{const{currentTheme:n}=Ne(),a=t||(n==null?void 0:n.title)||"",o=!!(n!=null&&n.logo&&n.logo.visible&&n.logo.url),c=!!a;return!o&&!c?null:e.jsxs("div",{className:`metakyc-header ${s}`,children:[e.jsxs("div",{className:"metakyc-header-title flex items-center text-xl font-bold",style:{color:"var(--metakyc-text-primary, #111827)"},children:[o&&e.jsx(Hr,{config:n.logo}),o&&c&&e.jsx("span",{style:{fontSize:"1.5rem",fontWeight:300,color:"var(--metakyc-text-muted, #9ca3af)",margin:"0 12px"},children:"|"}),c&&e.jsx("span",{style:{color:"var(--metakyc-text-primary, #111827)"},children:a})]}),r&&e.jsx("p",{className:"text-sm mt-1",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:r})]})},dt=["firstName","lastName","email","phonenumber","dateOfBirth"];function tt(t){return t==null||t===""||Array.isArray(t)&&t.length===0}const it={width:"16px",height:"16px",minWidth:"16px",flexShrink:0,flexGrow:0,accentColor:"var(--metakyc-primary, #2563eb)",cursor:"pointer",margin:0,padding:0,display:"inline-block",verticalAlign:"middle"},It=({helpText:t,children:r})=>{const[s,n]=i.useState(!1);if(!t)return e.jsx(e.Fragment,{children:r});const a=s?e.jsx("div",{role:"dialog","aria-modal":"true",onClick:()=>n(!1),style:{position:"fixed",inset:0,zIndex:999999,background:"rgba(0, 0, 0, 0.55)",backdropFilter:"blur(6px)",WebkitBackdropFilter:"blur(6px)",display:"flex",alignItems:"center",justifyContent:"center",padding:"16px"},children:e.jsxs("div",{onClick:o=>o.stopPropagation(),style:{background:"var(--metakyc-surface, var(--metakyc-background, #ffffff))",border:"1px solid var(--metakyc-border, #e5e7eb)",borderRadius:"12px",padding:"28px 24px 24px",maxWidth:"480px",width:"100%",maxHeight:"80vh",overflowY:"auto",boxShadow:"0 24px 64px rgba(0,0,0,0.4)",position:"relative"},children:[e.jsx("button",{type:"button",onClick:()=>n(!1),"aria-label":"Close",style:{position:"absolute",top:"12px",right:"12px",width:"28px",height:"28px",borderRadius:"50%",border:"1px solid var(--metakyc-border, #e5e7eb)",background:"var(--metakyc-input-bg, #f3f4f6)",color:"var(--metakyc-text-secondary, #6b7280)",fontSize:"16px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1},children:"×"}),e.jsx("div",{style:{color:"var(--metakyc-text-primary, #111827)",fontSize:"14px",lineHeight:1.75},dangerouslySetInnerHTML:{__html:t}})]})}):null;return e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"5px",flexWrap:"nowrap"},children:[r,e.jsx("button",{type:"button",className:"metakyc-help-btn",onClick:()=>n(!0),"aria-label":"Help",style:{flexShrink:0,marginTop:"2px",width:"18px",height:"18px",borderRadius:"50%",border:"1.5px solid var(--metakyc-primary, #2563eb)",background:"transparent",color:"var(--metakyc-primary, #2563eb)",fontSize:"10px",fontWeight:"700",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1,padding:0,position:"relative",zIndex:2,transition:"background 0.15s, color 0.15s"},onMouseEnter:o=>{o.currentTarget.style.background="var(--metakyc-primary, #2563eb)",o.currentTarget.style.color="#ffffff"},onMouseLeave:o=>{o.currentTarget.style.background="transparent",o.currentTarget.style.color="var(--metakyc-primary, #2563eb)"},children:"?"}),typeof document<"u"&&a?pt.createPortal(a,document.body):null]})},Es=({workflowKey:t,externalRefId:r,onSuccess:s,onCancel:n})=>{var K,H,Z,m,C,F,u;const{config:a,baseInformationService:o,currentTheme:c}=Ne(),{createApplicant:d,isLoading:y}=vt(),p=t||((K=a.applicantForm)==null?void 0:K.workflowKey);if(!p)throw new Error("workflowKey is required. Provide it either as a prop to CreateApplicantForm or set it in config.applicantForm.workflowKey");const g=r||((H=a.applicantForm)==null?void 0:H.externalRefId)||"",T=((Z=a.applicantForm)==null?void 0:Z.email)||"",v=((m=a.applicantForm)==null?void 0:m.hiddenValues)||{},E=((C=a.applicantForm)==null?void 0:C.initialValues)||{},k=(((F=a.applicantForm)==null?void 0:F.fieldLabelMode)||(c==null?void 0:c.fieldLabelMode)||"label")!=="placeholder",S=i.useMemo(()=>c!=null&&c.applicantFormPages&&c.applicantFormPages.length>0?c.applicantFormPages:null,[c==null?void 0:c.applicantFormPages]),D=i.useMemo(()=>{const l=new Set(dt),h=c==null?void 0:c.applicantFormRequiredFields;if(h)for(const P of h)l.add(P);if(S)for(const P of S)for(const b of P.fields)!b.isCustom&&b.name&&b.required&&l.add(b.name);return Array.from(l)},[c==null?void 0:c.applicantFormRequiredFields,S]),Y=i.useMemo(()=>{var P;if(S){const b=S.flatMap(j=>j.fields).filter(j=>!j.isCustom&&j.name).map(j=>j.name),w=new Set(b);for(const j of dt)w.add(j);return Array.from(w)}let l;(P=a.applicantForm)!=null&&P.visibleFields?l=a.applicantForm.visibleFields:c!=null&&c.applicantFormVisibleFields&&c.applicantFormVisibleFields.length>0?l=c.applicantFormVisibleFields:l=Ht;const h=new Set(l);for(const b of dt)h.add(b);return Array.from(h)},[(u=a.applicantForm)==null?void 0:u.visibleFields,c==null?void 0:c.applicantFormVisibleFields,S]),L=new Set(["country","nationality","taxCountry","countryOfBirth","mobileCountryCode","otherNationality"]),B=i.useMemo(()=>{var h,P;const l=new Set;if(S)for(const b of S)for(const w of b.fields)!w.isCustom&&w.name&&L.has(w.name)&&l.add(w.countriesType??((h=Qe[w.name])==null?void 0:h.countriesType));else for(const b of Y)L.has(b)&&l.add((P=Qe[b])==null?void 0:P.countriesType);return l.size===0&&l.add(void 0),Array.from(l)},[Y,S]),[U,X]=i.useState({}),[R,f]=i.useState(!0),O=i.useRef(new Set),q=i.useRef(new Set);i.useEffect(()=>{if(!c)return;const l=B.filter(b=>{const w=b!=null?String(b):"all";return!q.current.has(w)&&!O.current.has(w)});if(l.length===0){B.every(w=>{const j=w!=null?String(w):"all";return q.current.has(j)})&&f(!1);return}f(!0);const h=l.map(b=>b!=null?String(b):"all");h.forEach(b=>O.current.add(b)),(async()=>{try{const b=await Promise.all(l.map(async w=>{const j=w!=null?String(w):"all",le=await o.getCountries("",a.locale||"en",w),ae=w===40,xe=new Set,Ie=le.map(ie=>ae&&ie.countryCode?{value:ie.countryCode,label:`${ie.countryCode} – ${ie.name}`}:{value:ie.abbreviation3||ie.abbreviation,label:ie.name}).filter(ie=>!ie.value||xe.has(ie.value)?!1:(xe.add(ie.value),!0));return q.current.add(j),O.current.delete(j),[j,Ie]}));X(w=>({...w,...Object.fromEntries(b)}))}catch(b){h.forEach(w=>O.current.delete(w)),console.error("Failed to load countries:",b)}finally{B.every(w=>{const j=w!=null?String(w):"all";return q.current.has(j)})&&f(!1)}})()},[B,c]);const Q=(l,h)=>{var w;const P=h??((w=Qe[l])==null?void 0:w.countriesType),b=P!=null?String(P):"all";return U[b]||[]},$={firstName:1,lastName:1,title:1,email:1,dateOfBirth:1,phonenumber:1,mobileCountryCode:1,street:1,streetNumber:1,zip:1,city:1,country:1,nationality:1,otherNationality:1,defaultLanguage:1,taxCountry:1,placeOfBirth:1,countryOfBirth:1,salutation:1,educationLevel:1,occupation:1,taxNumber:1},G=Object.fromEntries(Object.entries(v).filter(([l])=>l in $)),se=Object.fromEntries(Object.entries(E).filter(([l])=>l in $)),[V,he]=i.useState({workflowKey:p,firstName:"",lastName:"",title:"",email:T,dateOfBirth:"",phonenumber:"",externalRefId:g,mobileCountryCode:"",street:"",streetNumber:"",zip:"",city:"",country:"",nationality:"",otherNationality:[],defaultLanguage:"EN",taxCountry:"",placeOfBirth:"",countryOfBirth:"",salutation:null,educationLevel:"",occupation:"",taxNumber:"",...G,...se}),ce=Object.fromEntries(Object.entries(v).filter(([l])=>!(l in G)&&l!=="externalRefId"&&l!=="workflowKey")),[de,fe]=i.useState({...ce}),[I,W]=i.useState(0),[z,_]=i.useState({}),[me,N]=i.useState(null),[re,ue]=i.useState(!1),ne=(l,h)=>he(P=>({...P,[l]:h})),ve=(l,h)=>fe(P=>({...P,[l]:h})),Fe=l=>!l.conditionalOn||de[l.conditionalOn]==="true",ke=S&&I<S.length-1?I+1:-1,Oe=S&&I>0?I-1:-1,Xe=l=>{var P;const h={};for(const b of l.fields)if(b.isCustom){if(b.customType==="paragraph"||b.customType==="html"||b.customType==="br"||b.customType==="link")continue;if(b.required&&b.paramName){const w=de[b.paramName],j=b.displayText||b.label||b.paramName;b.customType==="checkbox"||b.customType==="link_checkbox"?w!=="true"&&(h[b.paramName]=`${j} is required.`):(!w||w.trim()==="")&&(h[b.paramName]=`${j} is required.`)}}else if(b.name){const w=b.name;if(D.includes(w)&&tt(V[w])){const j=b.displayText||((P=Qe[w])==null?void 0:P.label)||w;h[w]=`${j} is required.`}}return h},Ge=async()=>{if(!S)return;const l=S[I];if(l.conditionalOn&&!Fe(l)){_({}),ke>=0?W(ke):await ze();return}const h=Xe(l);if(Object.keys(h).length>0){_(h);return}_({}),ke>=0?W(ke):await ze()},ze=async()=>{if(S){let l={};for(const h of S)Fe(h)&&(l={...l,...Xe(h)});if(Object.keys(l).length>0){_(l);return}}ue(!0),N(null);try{if(!V.externalRefId||V.externalRefId.trim()===""){N("External Reference ID is required. Please pass it via config.applicantForm.externalRefId.");return}const l={workflowKey:V.workflowKey,externalRefId:V.externalRefId.trim()};if(S){for(const w of S)if(Fe(w)){for(const j of w.fields)if(!j.isCustom&&j.name){const le=j.name,ae=V[le];tt(ae)||(l[le]=ae)}}for(const w of dt)if(l[w]===void 0){const j=V[w];tt(j)||(l[w]=j)}}else Y.forEach(w=>{if(w==="externalRefId")return;const j=V[w];tt(j)||(l[w]=j)});const h=[];if(S){for(const w of S)if(Fe(w))for(const j of w.fields){if(!j.isCustom||!j.paramName||j.customType==="paragraph"||j.customType==="html"||j.customType==="br"||j.customType==="link")continue;const le=de[j.paramName]??"";let ae;if(j.customType==="checkbox"||j.customType==="link_checkbox")ae=le==="true"?"yes":"no";else if(ae=le,!ae&&!j.required)continue;h.push({paramName:j.paramName,value:ae})}}for(const[w,j]of Object.entries(G))l[w]===void 0&&!tt(j)&&(l[w]=j);const P=new Set(h.map(w=>w.paramName));for(const[w,j]of Object.entries(ce))!P.has(w)&&j&&h.push({paramName:w,value:j});h.length>0&&(l.applicantAdditionalDatas=h);const b=await d(l);s(b.applicantId)}catch(l){console.error("Error creating applicant:",l),N(l.message||"Failed to create applicant")}finally{ue(!1)}},et=async l=>{var h;l.preventDefault();for(const P of D)if(tt(V[P])){const b=((h=Qe[P])==null?void 0:h.label)||P;N(`${b} is required.`);return}await ze()},Ue=(l,h,P,b,w)=>{var jt;const j=Qe[l];if(!j)return null;const le=D.includes(l),ae=z[l],xe=P||j.label,Ie=l in se,ie=h??l,Pe={required:le},$e=w?w!=="placeholder":k,Ke=$e?xe:void 0,Wr=$e?"...":xe;switch(j.type){case"select":if(l==="country"||l==="nationality"||l==="taxCountry"||l==="countryOfBirth"||l==="mobileCountryCode"){const Ce=Q(l,b);return e.jsx(De,{...Pe,label:Ke,value:V[l]||"",onChange:Je=>ne(l,Je),options:[{value:"",label:`Select ${Wr.toLowerCase()}`},...Ce],disabled:R,readOnly:Ie,error:ae},ie)}if(l==="salutation")return e.jsx(De,{...Pe,label:Ke,value:((jt=V[l])==null?void 0:jt.toString())||"",onChange:Ce=>ne(l,Ce?Number(Ce):null),options:[{value:"",label:$e?"Select salutation...":xe},{value:lt.Male.toString(),label:"Male"},{value:lt.Female.toString(),label:"Female"},{value:lt.Other.toString(),label:"Other"}],readOnly:Ie,error:ae},ie);if(l==="defaultLanguage"){const Ce=c!=null&&c.allowedLanguages&&c.allowedLanguages.length>0?ht.filter(Je=>c.allowedLanguages.includes(Je.value)):ht;return e.jsx(De,{...Pe,label:Ke,value:V[l]||"",onChange:Je=>ne(l,Je),options:[{value:"",label:$e?"Select language...":xe},...Ce],readOnly:Ie,error:ae},ie)}return null;case"multiselect":if(l==="otherNationality"){const Ce=Q(l,b);return e.jsx(Ir,{...Pe,label:Ke,value:V[l]||[],onChange:Je=>ne(l,Je),options:Ce,placeholder:$e?"Select other nationalities...":xe,disabled:R,readOnly:Ie},ie)}return null;case"date":return e.jsx(ye,{...Pe,type:"date",label:Ke,placeholder:$e?void 0:xe,value:V[l]||"",onChange:Ce=>ne(l,Ce.target.value),readOnly:Ie,error:ae},ie);case"email":return e.jsx(ye,{...Pe,type:"email",label:Ke,placeholder:$e?void 0:xe,value:V[l]||"",onChange:Ce=>ne(l,Ce.target.value),readOnly:Ie,error:ae},ie);case"tel":return e.jsx(ye,{...Pe,type:"tel",label:Ke,placeholder:$e?void 0:xe,value:V[l]||"",onChange:Ce=>ne(l,Ce.target.value),readOnly:Ie,error:ae},ie);default:return e.jsx(ye,{...Pe,type:"text",label:Ke,placeholder:$e?void 0:xe,value:V[l]||"",onChange:Ce=>ne(l,Ce.target.value),readOnly:Ie,error:ae},ie)}},x=(l,h)=>{const P=l.labelMode?l.labelMode!=="placeholder":k;if(l.customType==="paragraph"){const j=l.displayText||l.label||"";return e.jsx("p",{className:"metakyc-paragraph",style:{fontSize:"14px",lineHeight:"1.7",margin:0,color:"var(--metakyc-text-secondary, #6b7280)"},dangerouslySetInnerHTML:{__html:j}},`custom-${h}`)}if(l.customType==="html")return e.jsx("div",{dangerouslySetInnerHTML:{__html:l.label||""}},`custom-${h}`);if(l.customType==="br")return e.jsx("div",{style:{height:"12px"}},`custom-${h}`);if(l.customType==="link"){const j=l.displayText||l.label||l.linkText||l.linkUrl||"";return e.jsx("div",{className:"metakyc-link-field",children:e.jsxs("a",{href:l.linkUrl||"#",target:"_blank",rel:"noopener noreferrer",style:{display:"inline-flex",alignItems:"center",gap:"4px",color:"var(--metakyc-primary, #2563eb)",fontSize:"14px",textDecoration:"underline",cursor:"pointer"},children:[j,e.jsx("span",{style:{fontSize:"10px",opacity:.7},children:"↗"})]})},`custom-${h}`)}if(!l.paramName)return null;const b=z[l.paramName],w=l.displayText||l.label||l.paramName;if(l.customType==="checkbox")return e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"checkbox",checked:de[l.paramName]==="true",onChange:j=>ve(l.paramName,j.target.checked?"true":"false"),className:"metakyc-option-input",style:it}),e.jsxs("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4"},children:[w,l.required&&e.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]})]}),b&&e.jsx("p",{className:"text-red-500 text-xs mt-0.5",children:b})]},`custom-${h}`);if(l.customType==="link_checkbox")return e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"checkbox",checked:de[l.paramName]==="true",onChange:j=>ve(l.paramName,j.target.checked?"true":"false"),className:"metakyc-option-input",style:{...it,alignSelf:"flex-start",marginTop:"2px"}}),e.jsxs("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4"},children:[w," ",l.linkUrl&&e.jsx("a",{href:l.linkUrl,target:"_blank",rel:"noopener noreferrer",className:"underline",style:{color:"var(--metakyc-primary, #2563eb)"},onClick:j=>j.stopPropagation(),children:l.linkText||l.linkUrl}),l.required&&e.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]})]}),b&&e.jsx("p",{className:"text-red-500 text-xs mt-0.5",children:b})]},`custom-${h}`);if(l.customType==="group_checkbox"){const j=(de[l.paramName]||"").split(",").filter(Boolean);return e.jsxs("div",{className:"flex flex-col gap-1.5",children:[P&&e.jsxs("div",{className:"text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:[w,l.required&&e.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]}),e.jsx("div",{className:"metakyc-options-group",style:{display:"flex",flexDirection:"column",gap:"8px"},children:(l.options||[]).map(le=>{const ae=l.singleSelect?de[l.paramName]===le.value:j.includes(le.value);return e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"checkbox",checked:ae,onChange:xe=>{if(l.singleSelect)ve(l.paramName,xe.target.checked?le.value:"");else{const Ie=xe.target.checked?[...j,le.value]:j.filter(ie=>ie!==le.value);ve(l.paramName,Ie.join(","))}},className:"metakyc-option-input",style:it}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4"},children:le.label})]},le.value)})}),b&&e.jsx("p",{className:"text-red-500 text-xs",children:b})]},`custom-${h}`)}return l.customType==="radio_group"?e.jsxs("div",{className:"flex flex-col gap-1.5",children:[P&&e.jsxs("div",{className:"text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:[w,l.required&&e.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]}),e.jsx("div",{className:"metakyc-options-group",style:{display:"flex",flexDirection:"column",gap:"8px"},children:(l.options||[]).map(j=>e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"radio",checked:de[l.paramName]===j.value,onChange:()=>ve(l.paramName,j.value),name:`radio-group-${l.paramName}-${h}`,className:"metakyc-option-input",style:it}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4"},children:j.label})]},j.value))}),b&&e.jsx("p",{className:"text-red-500 text-xs",children:b})]},`custom-${h}`):e.jsx(ye,{type:"text",label:P?`${w}${l.required?" *":""}`:void 0,placeholder:P?void 0:w,value:de[l.paramName]||"",onChange:j=>ve(l.paramName,j.target.value),required:l.required,error:b},`custom-${h}`)},M=(l,h)=>{const P=Fe(l);return e.jsxs("div",{className:"space-y-4",children:[l.conditionalOn&&e.jsx(It,{helpText:l.conditionalHelpText,children:e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"checkbox",checked:P,onChange:b=>ve(l.conditionalOn,b.target.checked?"true":"false"),className:"metakyc-option-input",style:it}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4",fontWeight:500},children:l.conditionalOn})]})}),P&&e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, minmax(0, 1fr))",gap:"1rem"},children:l.fields.map((b,w)=>{const j=Math.min(4,Math.max(1,Number(b.colSpan)||4)),le=b.isCustom?`custom-${w}-${b.paramName}`:`builtin-${b.name}-${w}`;return e.jsx("div",{style:{gridColumn:`span ${j} / span ${j}`},children:e.jsx(It,{helpText:b.helpText,children:b.isCustom?x(b,w):Ue(b.name,le,b.displayText,b.countriesType,b.labelMode)})},le)})})]})};if(!c||R)return e.jsx("div",{className:"metakyc-sdk",children:e.jsx(ee,{children:e.jsxs(te,{children:[e.jsx(Ee,{className:"my-8"}),e.jsx("p",{className:"text-center mt-4",style:{color:"var(--metakyc-text-secondary, #6b7280)",fontSize:"0.875rem"},children:"Loading form…"})]})})});if(S){const l=S[I]??S[0],h=Oe===-1,P=ke===-1,b=S.length,w=Fe(l),j=Object.values(z);return e.jsx("div",{className:"metakyc-sdk",children:e.jsxs(ee,{children:[e.jsx(ge,{children:e.jsx(nt,{title:(c==null?void 0:c.title)||"Create Applicant"})}),e.jsxs(te,{children:[(l.title||l.subtitle||l.description)&&e.jsxs("div",{className:"mb-4",children:[l.title&&e.jsx("h3",{className:"font-semibold text-base",style:{color:"var(--metakyc-text-primary, #111827)"},children:l.title}),l.subtitle&&e.jsx("p",{className:"text-sm mt-0.5",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:l.subtitle}),l.description&&l.description!==l.subtitle&&e.jsx("p",{className:"text-xs mt-1",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:l.description})]}),(me||j.length>0)&&e.jsxs("div",{className:"mb-4 p-3 bg-red-50 border border-red-200 rounded-lg",children:[me&&e.jsxs("p",{className:"text-red-600 text-sm",children:[e.jsx("strong",{children:"Error:"})," ",me]}),j.map((le,ae)=>e.jsx("p",{className:"text-red-600 text-sm",children:le},ae))]}),b>1&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"1rem"},children:[S.map((le,ae)=>e.jsx("div",{style:{height:"0.375rem",borderRadius:"9999px",transition:"all 150ms",...ae===I?{flex:"1 1 0%",backgroundColor:"var(--metakyc-primary, #2563eb)"}:ae<I?{width:"2rem",backgroundColor:"var(--metakyc-primary-light, #93c5fd)",opacity:.7}:{width:"2rem",backgroundColor:"#e5e7eb"}}},ae)),e.jsxs("span",{style:{fontSize:"0.75rem",color:"var(--metakyc-text-muted, #9ca3af)",flexShrink:0},children:[I+1," / ",b]})]}),M(l)]}),e.jsxs(be,{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsxs("div",{children:[!h&&e.jsx(J,{type:"button",variant:"outline",onClick:()=>{W(Oe),_({})},disabled:re||y,children:"Previous"}),h&&n&&e.jsx(J,{type:"button",variant:"outline",onClick:n,disabled:re||y,children:"Cancel"})]}),e.jsx(J,{type:"button",isLoading:re||y,onClick:P?ze:Ge,children:P?l.conditionalOn&&!w?"Skip & Submit":"Submit":l.conditionalOn&&!w?"Skip":"Next"})]})]})})}return e.jsx("div",{className:"metakyc-sdk",children:e.jsx("form",{onSubmit:et,children:e.jsxs(ee,{children:[e.jsx(ge,{children:e.jsx(nt,{title:(c==null?void 0:c.title)||"Create Applicant"})}),e.jsxs(te,{children:[me&&e.jsx("div",{className:"mb-6 p-4 bg-red-50 border border-red-200 rounded-lg",children:e.jsxs("p",{className:"text-red-600 text-sm",children:[e.jsx("strong",{children:"Error:"})," ",me]})}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, minmax(0, 1fr))",gap:"1rem"},children:Y.map(l=>e.jsx("div",{style:{gridColumn:"span 4 / span 4"},children:Ue(l)},l))})]}),e.jsxs(be,{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[n&&e.jsx(J,{type:"button",variant:"outline",onClick:n,disabled:re||y,children:"Cancel"}),e.jsx(J,{type:"submit",isLoading:re||y,children:"Create Applicant"})]})]})})})},Et=["companyName","email"];function xt(t){return t==null||t===""||Array.isArray(t)&&t.length===0}const As=({workflowKey:t,externalRefId:r,onSuccess:s,onCancel:n})=>{var Ue,x,M,K,H,Z;const{config:a,baseInformationService:o,currentTheme:c}=Ne(),{createCompanyApplicant:d,isLoading:y}=vt(),p=t||((Ue=a.applicantForm)==null?void 0:Ue.workflowKey);if(!p)throw new Error("workflowKey is required. Provide it either as a prop to CreateCompanyApplicantForm or set it in config.applicantForm.workflowKey");const g=r||((x=a.applicantForm)==null?void 0:x.externalRefId)||"",T=((M=a.applicantForm)==null?void 0:M.email)||"",v=((K=a.applicantForm)==null?void 0:K.initialValues)||{},A=(((H=a.applicantForm)==null?void 0:H.fieldLabelMode)||(c==null?void 0:c.fieldLabelMode)||"label")!=="placeholder",k=i.useMemo(()=>c!=null&&c.companyFormPages&&c.companyFormPages.length>0?c.companyFormPages:null,[c==null?void 0:c.companyFormPages]),S=i.useMemo(()=>{const m=new Set(Et),C=c==null?void 0:c.companyFormRequiredFields;if(C)for(const F of C)m.add(F);if(k)for(const F of k)for(const u of F.fields)!u.isCustom&&u.name&&u.required&&m.add(u.name);return Array.from(m)},[c==null?void 0:c.companyFormRequiredFields,k]),D=i.useMemo(()=>{var m;if(k){const C=k.flatMap(u=>u.fields).filter(u=>!u.isCustom&&u.name).map(u=>u.name),F=new Set(C);for(const u of Et)F.add(u);return Array.from(F)}return(m=a.applicantForm)!=null&&m.visibleFields?a.applicantForm.visibleFields:c!=null&&c.companyFormVisibleFields&&c.companyFormVisibleFields.length>0?c.companyFormVisibleFields:_t},[(Z=a.applicantForm)==null?void 0:Z.visibleFields,c==null?void 0:c.companyFormVisibleFields,k]),Y=new Set(["countryResidence","addressCountry"]),L=i.useMemo(()=>{var C,F;const m=new Set;if(k)for(const u of k)for(const l of u.fields)!l.isCustom&&l.name&&Y.has(l.name)&&m.add(l.countriesType??((C=Ze[l.name])==null?void 0:C.countriesType));else for(const u of D)Y.has(u)&&m.add((F=Ze[u])==null?void 0:F.countriesType);return m.size===0&&m.add(void 0),Array.from(m)},[D,k]),[B,U]=i.useState({}),[X,R]=i.useState(!0),f=i.useRef(new Set),O=i.useRef(new Set);i.useEffect(()=>{if(!c)return;const m=L.filter(u=>{const l=u!=null?String(u):"all";return!O.current.has(l)&&!f.current.has(l)});if(m.length===0){L.every(l=>O.current.has(l!=null?String(l):"all"))&&R(!1);return}R(!0);const C=m.map(u=>u!=null?String(u):"all");C.forEach(u=>f.current.add(u)),(async()=>{try{const u=await Promise.all(m.map(async l=>{const h=l!=null?String(l):"all",P=await o.getCountries("",a.locale||"en",l),b=new Set,w=P.map(j=>({value:j.abbreviation3||j.abbreviation,label:j.name})).filter(j=>!j.value||b.has(j.value)?!1:(b.add(j.value),!0));return O.current.add(h),f.current.delete(h),[h,w]}));U(l=>({...l,...Object.fromEntries(u)}))}catch(u){C.forEach(l=>f.current.delete(l)),console.error("Failed to load countries:",u)}finally{L.every(l=>O.current.has(l!=null?String(l):"all"))&&R(!1)}})()},[L,c]);const q=(m,C)=>{var l;const F=C??((l=Ze[m])==null?void 0:l.countriesType),u=F!=null?String(F):"all";return B[u]||[]},Q={companyName:1,registrationNumber:1,email:1,phone:1,countryResidence:1,legalAddress:1,incorporatedOn:1,controlScheme:1,taxId:1,registrationLocation:1,website:1,postalAddress:1,street:1,streetNumber:1,city:1,state:1,postalCode:1,addressCountry:1,lei:1},$=Object.fromEntries(Object.entries(v).filter(([m])=>m in Q)),[G,se]=i.useState({workflowKey:p,companyName:"",email:T,phone:"",registrationNumber:"",countryResidence:"",legalAddress:"",incorporatedOn:"",controlScheme:"",taxId:"",registrationLocation:"",website:"",postalAddress:"",street:"",streetNumber:"",city:"",state:"",postalCode:"",addressCountry:"",lei:"",externalRefId:g,...$}),[V,he]=i.useState({}),[ce,de]=i.useState(0),[fe,I]=i.useState({}),[W,z]=i.useState(null),[_,me]=i.useState(!1),N=(m,C)=>se(F=>({...F,[m]:C})),re=(m,C)=>he(F=>({...F,[m]:C})),ue=m=>!m.conditionalOn||V[m.conditionalOn]==="true",ne=k&&ce<k.length-1?ce+1:-1,ve=k&&ce>0?ce-1:-1,Fe=m=>{var F;const C={};for(const u of m.fields)if(u.isCustom){if(u.customType==="paragraph"||u.customType==="html"||u.customType==="br"||u.customType==="link")continue;if(u.required&&u.paramName){const l=V[u.paramName],h=u.displayText||u.label||u.paramName;u.customType==="checkbox"||u.customType==="link_checkbox"?l!=="true"&&(C[u.paramName]=`${h} is required.`):(!l||l.trim()==="")&&(C[u.paramName]=`${h} is required.`)}}else if(u.name){const l=u.name;if(S.includes(l)&&xt(G[l])){const h=u.displayText||((F=Ze[l])==null?void 0:F.label)||l;C[l]=`${h} is required.`}}return C},ke=async()=>{if(!k)return;const m=k[ce];if(m.conditionalOn&&!ue(m)){I({}),ne>=0?de(ne):await Oe();return}const C=Fe(m);if(Object.keys(C).length>0){I(C);return}I({}),ne>=0?de(ne):await Oe()},Oe=async()=>{var m;if(k){let C={};for(const F of k)ue(F)&&(C={...C,...Fe(F)});if(Object.keys(C).length>0){I(C);return}}me(!0),z(null);try{const C={workflowKey:G.workflowKey,externalRefId:((m=G.externalRefId)==null?void 0:m.trim())||void 0},F=k?k.filter(h=>ue(h)).flatMap(h=>h.fields).filter(h=>!h.isCustom&&h.name).map(h=>h.name):D;for(const h of F){const P=G[h];if(!xt(P))switch(h){case"companyName":C.companyName=P;break;case"email":C.companyEmail=P;break;case"phone":C.companyPhone=P;break;case"registrationNumber":C.companyRegistrationNumber=P;break;case"countryResidence":C.companyCountry=P;break;case"city":C.companyCity=P;break;case"street":C.companyStreet=P;break;case"postalCode":C.companyZip=P;break;default:C[h]=P;break}}const u=[];if(k){for(const h of k)if(ue(h))for(const P of h.fields){if(!P.isCustom||!P.paramName||P.customType==="paragraph"||P.customType==="html"||P.customType==="br"||P.customType==="link")continue;const b=V[P.paramName]??"";let w;if(P.customType==="checkbox"||P.customType==="link_checkbox")w=b==="true"?"yes":"no";else if(w=b,!w&&!P.required)continue;u.push({paramName:P.paramName,value:w})}}u.length>0&&(C.applicantAdditionalDatas=u);const l=await d(C);s(l.applicantId)}catch(C){console.error("Error creating company applicant:",C),z(C.message||"Failed to create company applicant")}finally{me(!1)}},Xe=async m=>{var C;m.preventDefault();for(const F of S)if(xt(G[F])){const u=((C=Ze[F])==null?void 0:C.label)||F;z(`${u} is required.`);return}await Oe()},Ge=(m,C,F,u,l)=>{const h=Ze[m];if(!h)return null;const P=S.includes(m),b=fe[m],w=F||h.label,j=m in $,le=C??m,ae=l?l!=="placeholder":A,xe=ae?w:void 0,Ie=ae?"...":w;switch(h.type){case"select":if(m==="countryResidence"||m==="addressCountry"){const ie=q(m,u);return e.jsx(De,{required:P,label:xe,value:G[m]||"",onChange:Pe=>N(m,Pe),options:[{value:"",label:`Select ${Ie.toLowerCase()}`},...ie],disabled:X,readOnly:j,error:b},le)}return null;case"date":return e.jsx(ye,{required:P,type:"date",label:xe,placeholder:ae?void 0:w,value:G[m]||"",onChange:ie=>N(m,ie.target.value),readOnly:j,error:b},le);case"email":return e.jsx(ye,{required:P,type:"email",label:xe,placeholder:ae?void 0:w,value:G[m]||"",onChange:ie=>N(m,ie.target.value),readOnly:j,error:b},le);case"tel":return e.jsx(ye,{required:P,type:"tel",label:xe,placeholder:ae?void 0:w,value:G[m]||"",onChange:ie=>N(m,ie.target.value),readOnly:j,error:b},le);default:return e.jsx(ye,{required:P,type:"text",label:xe,placeholder:ae?void 0:w,value:G[m]||"",onChange:ie=>N(m,ie.target.value),readOnly:j,error:b},le)}},ze=(m,C)=>{if(m.customType==="paragraph")return e.jsx("p",{style:{fontSize:"14px",lineHeight:"1.7",margin:0,color:"var(--metakyc-text-secondary, #6b7280)"},dangerouslySetInnerHTML:{__html:m.displayText||m.label||""}},`custom-${C}`);if(m.customType==="html")return e.jsx("div",{dangerouslySetInnerHTML:{__html:m.label||""}},`custom-${C}`);if(m.customType==="br")return e.jsx("div",{style:{height:"12px"}},`custom-${C}`);if(m.customType==="link")return e.jsx("div",{children:e.jsx("a",{href:m.linkUrl||"#",target:"_blank",rel:"noopener noreferrer",style:{color:"var(--metakyc-primary, #2563eb)",fontSize:"14px",textDecoration:"underline"},children:m.displayText||m.label||m.linkText||m.linkUrl||""})},`custom-${C}`);if(!m.paramName)return null;const F=fe[m.paramName],u=m.displayText||m.label||m.paramName,l=m.labelMode?m.labelMode!=="placeholder":A;return m.customType==="checkbox"?e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:V[m.paramName]==="true",onChange:h=>re(m.paramName,h.target.checked?"true":"false"),style:{width:"16px",height:"16px",accentColor:"var(--metakyc-primary, #2563eb)"}}),e.jsxs("span",{style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)"},children:[u,m.required&&e.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]})]}),F&&e.jsx("p",{className:"text-red-500 text-xs mt-0.5",children:F})]},`custom-${C}`):e.jsx(ye,{type:"text",label:l?`${u}${m.required?" *":""}`:void 0,placeholder:l?void 0:u,value:V[m.paramName]||"",onChange:h=>re(m.paramName,h.target.value),required:m.required,error:F},`custom-${C}`)},et=m=>{const C=ue(m);return e.jsxs("div",{className:"space-y-4",children:[m.conditionalOn&&e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:C,onChange:F=>re(m.conditionalOn,F.target.checked?"true":"false"),style:{width:"16px",height:"16px",accentColor:"var(--metakyc-primary, #2563eb)"}}),e.jsx("span",{style:{fontSize:"14px",fontWeight:500},children:m.conditionalOn})]}),C&&e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, minmax(0, 1fr))",gap:"1rem"},children:m.fields.map((F,u)=>{const l=Math.min(4,Math.max(1,Number(F.colSpan)||4)),h=F.isCustom?`custom-${u}-${F.paramName}`:`builtin-${F.name}-${u}`;return e.jsx("div",{style:{gridColumn:`span ${l} / span ${l}`},children:F.isCustom?ze(F,u):Ge(F.name,h,F.displayText,F.countriesType,F.labelMode)},h)})})]})};if(!c||X)return e.jsx("div",{className:"metakyc-sdk",children:e.jsx(ee,{children:e.jsxs(te,{children:[e.jsx(Ee,{className:"my-8"}),e.jsx("p",{className:"text-center mt-4",style:{color:"var(--metakyc-text-secondary, #6b7280)",fontSize:"0.875rem"},children:"Loading form…"})]})})});if(k){const m=k[ce]??k[0],C=ve===-1,F=ne===-1,u=k.length,l=ue(m),h=Object.values(fe);return e.jsx("div",{className:"metakyc-sdk",children:e.jsxs(ee,{children:[e.jsx(ge,{children:e.jsx(nt,{title:(c==null?void 0:c.title)||"Company Registration"})}),e.jsxs(te,{children:[(m.title||m.subtitle)&&e.jsxs("div",{className:"mb-4",children:[m.title&&e.jsx("h3",{className:"font-semibold text-base",style:{color:"var(--metakyc-text-primary, #111827)"},children:m.title}),m.subtitle&&e.jsx("p",{className:"text-sm mt-0.5",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:m.subtitle})]}),(W||h.length>0)&&e.jsxs("div",{className:"mb-4 p-3 bg-red-50 border border-red-200 rounded-lg",children:[W&&e.jsxs("p",{className:"text-red-600 text-sm",children:[e.jsx("strong",{children:"Error:"})," ",W]}),h.map((P,b)=>e.jsx("p",{className:"text-red-600 text-sm",children:P},b))]}),u>1&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"1rem"},children:[k.map((P,b)=>e.jsx("div",{style:{height:"0.375rem",borderRadius:"9999px",transition:"all 150ms",...b===ce?{flex:"1 1 0%",backgroundColor:"var(--metakyc-primary, #2563eb)"}:b<ce?{width:"2rem",backgroundColor:"var(--metakyc-primary-light, #93c5fd)",opacity:.7}:{width:"2rem",backgroundColor:"#e5e7eb"}}},b)),e.jsxs("span",{style:{fontSize:"0.75rem",color:"var(--metakyc-text-muted, #9ca3af)",flexShrink:0},children:[ce+1," / ",u]})]}),et(m)]}),e.jsxs(be,{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsxs("div",{children:[!C&&e.jsx(J,{type:"button",variant:"outline",onClick:()=>{de(ve),I({})},disabled:_||y,children:"Previous"}),C&&n&&e.jsx(J,{type:"button",variant:"outline",onClick:n,disabled:_||y,children:"Cancel"})]}),e.jsx(J,{type:"button",isLoading:_||y,onClick:F?Oe:ke,children:F?m.conditionalOn&&!l?"Skip & Submit":"Submit":m.conditionalOn&&!l?"Skip":"Next"})]})]})})}return e.jsx("div",{className:"metakyc-sdk",children:e.jsx("form",{onSubmit:Xe,children:e.jsxs(ee,{children:[e.jsx(ge,{children:e.jsx(nt,{title:(c==null?void 0:c.title)||"Company Registration"})}),e.jsxs(te,{children:[W&&e.jsx("div",{className:"mb-6 p-4 bg-red-50 border border-red-200 rounded-lg",children:e.jsxs("p",{className:"text-red-600 text-sm",children:[e.jsx("strong",{children:"Error:"})," ",W]})}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, minmax(0, 1fr))",gap:"1rem"},children:D.map(m=>e.jsx("div",{style:{gridColumn:"span 4 / span 4"},children:Ge(m)},m))})]}),e.jsxs(be,{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[n&&e.jsx(J,{type:"button",variant:"outline",onClick:n,disabled:_||y,children:"Cancel"}),e.jsx(J,{type:"submit",isLoading:_||y,children:"Register Company"})]})]})})})},Ts=({applicantId:t,onComplete:r,onError:s,theme:n="light",className:a})=>{const{progress:o,currentStep:c,steps:d,workflowKey:y,nextWorkflowKey:p,hasWorkflowChanged:g,isLoading:T,error:v,moveBack:E,refreshProgress:A}=jr(t),[k,S]=i.useState(!1),D=i.useRef(null);if(i.useEffect(()=>{v&&s&&s(v)},[v,s]),i.useEffect(()=>{o!=null&&o.workflowResult&&r&&r(o.workflowResult)},[o==null?void 0:o.workflowResult,r]),i.useEffect(()=>{n==="dark"?document.documentElement.classList.add("dark"):document.documentElement.classList.remove("dark")},[n]),i.useEffect(()=>{g&&S(!1)},[g]),T||!o)return e.jsx("div",{className:`metakyc-sdk ${a||""}`,children:e.jsx(ee,{children:e.jsxs(te,{children:[e.jsx(Ee,{className:"my-8"}),e.jsx("p",{className:"text-center mt-4",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"Loading workflow..."})]})})});if(v)return e.jsx("div",{className:`metakyc-sdk ${a||""}`,children:e.jsx(ee,{children:e.jsx(te,{children:e.jsxs("div",{className:"text-center py-8",children:[e.jsx("p",{className:"text-lg mb-4",style:{color:"var(--metakyc-danger, #ef4444)"},children:"An error occurred"}),e.jsx("p",{style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:v.message})]})})})});if(g&&!k)return e.jsx("div",{className:`metakyc-sdk ${a||""}`,children:e.jsx(ee,{children:e.jsx(te,{children:e.jsxs("div",{className:"text-center py-8",children:[e.jsx("div",{className:"mb-6",children:e.jsx("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-full mb-4",style:{backgroundColor:"var(--metakyc-primary-light, #dbeafe)"},children:e.jsx("svg",{className:"w-8 h-8",style:{color:"var(--metakyc-primary, #2563eb)"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})})}),e.jsx("h3",{className:"text-xl font-semibold mb-2",style:{color:"var(--metakyc-text-primary, #111827)"},children:"Workflow Transition"}),e.jsx("p",{className:"mb-6",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"Your application workflow has been updated based on your progress."}),e.jsxs("div",{className:"rounded-lg p-4 mb-6 max-w-md mx-auto",style:{backgroundColor:"var(--metakyc-surface, #f9fafb)"},children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"mb-1",style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:"Previous Workflow"}),e.jsx("p",{className:"font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:y})]}),e.jsx("svg",{className:"w-6 h-6 mx-4",style:{color:"var(--metakyc-text-muted, #9ca3af)"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 7l5 5m0 0l-5 5m5-5H6"})}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"mb-1",style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:"New Workflow"}),e.jsx("p",{className:"font-medium",style:{color:"var(--metakyc-primary, #2563eb)"},children:p})]})]}),o.nextWorkflowName&&e.jsx("p",{className:"text-center mt-2 text-xs",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:o.nextWorkflowName})]}),e.jsx("button",{onClick:()=>S(!0),className:"px-6 py-3 font-medium rounded-lg transition-opacity hover:opacity-90",style:{backgroundColor:"var(--metakyc-primary, #2563eb)",color:"#ffffff"},children:"Continue with New Workflow"})]})})})});if(o.status===Te.Finished||o.status===Te.OnHold)return e.jsx("div",{className:`metakyc-sdk ${a||""}`,children:e.jsx(ft,{kycStatus:o.kycStatus,reviewStatus:o.reviewStatus,workflowResult:o.workflowResult,customMessage:o.customMessage,onContinue:r&&o.workflowResult?()=>r(o.workflowResult):void 0,onContactSupport:()=>{typeof window<"u"&&(window.location.href="mailto:support@example.com")}})});if(!c)return e.jsx("div",{className:`metakyc-sdk ${a||""}`,children:e.jsx(ee,{children:e.jsxs(te,{children:[e.jsx(Ee,{className:"my-8"}),e.jsx("p",{className:"text-center mt-4",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:o.status===Te.IdentityPending?"Loading identity verification...":"Loading current step..."})]})})});const Y=U=>{switch(U){case oe.Overview:return"Overview";case oe.Questionaries:return"Questionnaire";case oe.UploadDocument:return"Documents";case oe.IdentitySdk:return"Identity";case oe.RiskScoring:return"Risk Assessment";case oe.InvestorCategorization:return"Investor Categorization";case oe.AppropriatenessTest:return"Appropriateness Test";case oe.AdditionalData:return"Additional Data";case oe.ManualReview:return"Review";default:return""}},L=()=>{const U=d.filter(q=>q.visibility!==!1),X=U.findIndex(q=>q.order===c.order),R=X>=0?X+1:1,f=U.length,O=f>1?X/(f-1)*100:100;return e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",marginBottom:"16px"},children:[e.jsx(nt,{}),e.jsxs(kt,{variant:o.status===1?"info":"success",children:["Step ",R," of ",f]})]}),e.jsx("div",{style:{marginBottom:"16px"},children:e.jsx("div",{style:{height:"4px",borderRadius:"999px",backgroundColor:"var(--metakyc-border, #e5e7eb)",overflow:"hidden"},children:e.jsx("div",{style:{height:"100%",borderRadius:"999px",backgroundColor:"var(--metakyc-primary, #2563eb)",width:`${O}%`,transition:"width 0.4s ease"}})})}),e.jsx(Fs,{ref:D,visibleSteps:U,currentVisibleStepIndex:X,getStepFallbackName:Y})]})},B=()=>{const U={applicantId:t,onComplete:async()=>{await A()},onBack:c.order>0?E:void 0};switch(c.action){case oe.Questionaries:return e.jsx(Mr,{...U});case oe.UploadDocument:return e.jsx(Dr,{...U});case oe.Overview:return e.jsx(Or,{...U});case oe.IdentitySdk:return e.jsx(_r,{...U});case oe.RiskScoring:return e.jsx(zr,{...U});case oe.AdditionalData:case oe.InvestorCategorization:return e.jsx($r,{...U});case oe.AppropriatenessTest:return e.jsx(Br,{...U});case oe.ManualReview:return e.jsx(ft,{kycStatus:o.kycStatus,reviewStatus:o.reviewStatus,workflowResult:o.workflowResult,customMessage:o.customMessage});default:return e.jsx(ee,{children:e.jsxs(te,{className:"py-12 text-center",children:[e.jsx("div",{className:"mb-4",children:e.jsx(Ee,{})}),e.jsxs("p",{className:"text-gray-600 dark:text-gray-400 mb-2",children:["Processing step: ",c.title||c.name]}),e.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:["Action type: ",oe[c.action]]})]})})}};return e.jsxs("div",{className:`metakyc-sdk ${a||""}`,children:[L(),B()]})},Fs=i.forwardRef(({visibleSteps:t,currentVisibleStepIndex:r,getStepFallbackName:s},n)=>{const a=i.useRef(null),o=i.useRef(null);return i.useImperativeHandle(n,()=>a.current),i.useEffect(()=>{if(o.current&&a.current){const c=a.current,d=o.current,y=d.offsetLeft-c.offsetWidth/2+d.offsetWidth/2;c.scrollTo({left:Math.max(0,y),behavior:"smooth"})}},[r]),e.jsx("div",{ref:a,className:"metakyc-stepper-scroll",style:{display:"flex",alignItems:"center",overflowX:"auto",overflowY:"hidden",scrollbarWidth:"none",msOverflowStyle:"none",WebkitOverflowScrolling:"touch",padding:"4px 0",gap:"0"},children:t.map((c,d)=>{const y=d<r,p=d===r,g=y||p,T=c.displayName||c.name||s(c.action)||`Step ${d+1}`;return e.jsxs(i.Fragment,{children:[e.jsxs("div",{ref:p?o:void 0,style:{display:"flex",alignItems:"center",flexShrink:0},children:[e.jsx("div",{style:{width:"28px",height:"28px",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"12px",fontWeight:600,flexShrink:0,transition:"all 0.2s ease",...g?{backgroundColor:"var(--metakyc-primary, #2563eb)",color:"#ffffff",border:"none"}:{backgroundColor:"transparent",color:"var(--metakyc-text-muted, #9ca3af)",border:"2px solid var(--metakyc-border, #e5e7eb)"}},children:y?e.jsx("svg",{width:"14",height:"14",fill:"none",stroke:"currentColor",strokeWidth:2.5,viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}):d+1}),e.jsx("span",{style:{marginLeft:"6px",fontSize:"13px",whiteSpace:"nowrap",fontWeight:p?600:400,color:p?"var(--metakyc-text-primary, #111827)":y?"var(--metakyc-primary, #2563eb)":"var(--metakyc-text-muted, #9ca3af)",transition:"color 0.2s ease"},children:T})]}),d<t.length-1&&e.jsx("div",{style:{width:"32px",minWidth:"16px",height:"2px",margin:"0 8px",flexShrink:0,borderRadius:"999px",backgroundColor:y?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #e5e7eb)",transition:"background-color 0.2s ease"}})]},c.order)})})});function Ps(t){return We.z.object({questionResults:We.z.any()}).passthrough()}function Ls(t){let r=We.z.array(We.z.instanceof(File));if(t.isRequired?r=r.min(1,`${t.displayName} is required`):r=r.optional(),t.multipleFile||(r=r.refine(s=>!s||s.length<=1,{message:"Only one file is allowed"})),t.maxEachFileSizeByte>0&&(r=r.refine(s=>!s||s.every(n=>n.size<=t.maxEachFileSizeByte),{message:`File size must not exceed ${Math.round(t.maxEachFileSizeByte/1024/1024)}MB`})),t.allowedTypes){const s=t.allowedTypes.split(",").map(n=>n.trim());r=r.refine(n=>n?n.every(a=>s.some(o=>o.endsWith("/*")?a.type.startsWith(o.slice(0,-2)):a.type===o)):!0,{message:"Invalid file type"})}return r}function Ms(t){const r={};return t.uploadDocumentFiles.forEach(s=>{const n=`file_${s.id}`;r[n]=Ls(s)}),We.z.object(r)}function Ds(t){return We.z.any()}function Os(t){return We.z.string().min(1,"This question is required")}function zs(t){const r={};return t.appropriatenessQuestions.forEach(s=>{const n=`question_${s.id}`;r[n]=Os()}),We.z.object(r)}const $s=We.z.any();exports.ALLOWED_LANGUAGES=ht;exports.ApplicantProgressOnHoldReason=At;exports.ApplicantProgressStatus=Te;exports.ApplicantService=qt;exports.ApplicantStatus=Ft;exports.AppropriatenessQuestionType=Ot;exports.AppropriatenessTestService=Qt;exports.AppropriatenessTestStep=Br;exports.Badge=kt;exports.BaseInformationService=Xt;exports.Button=J;exports.COMPANY_FIELD_METADATA=Ze;exports.Card=ee;exports.CardContent=te;exports.CardFooter=be;exports.CardHeader=ge;exports.CountriesType=He;exports.CreateApplicantForm=Es;exports.CreateCompanyApplicantForm=As;exports.CriteriaBuiltInType=$t;exports.DEFAULT_COMPANY_VISIBLE_FIELDS=_t;exports.DEFAULT_VISIBLE_FIELDS=Ht;exports.DocumentReviewStatus=Dt;exports.EndpointBuilder=Ut;exports.ErrorHandler=rt;exports.EventEmitter=lr;exports.FIELD_METADATA=Qe;exports.FileType=Mt;exports.FileUpload=Er;exports.GenderType=lt;exports.Header=nt;exports.HttpClient=Kt;exports.IdentityProviderManager=_e;exports.IdentityService=Zt;exports.IdentityVerificationProvider=Ae;exports.IdentityVerificationStep=_r;exports.Input=ye;exports.InvestorCategorizationService=er;exports.InvestorCategorizationStep=$r;exports.InvestorCategorizationType=je;exports.InvestorCategoryType=Bt;exports.KycProcessStatus=Pt;exports.KycStatus=Ve;exports.KycStatusDisplay=ft;exports.KycWorkflow=Ts;exports.Logo=Hr;exports.MetaKYCContext=bt;exports.MetaKYCError=Le;exports.MetaKYCProvider=Xr;exports.MultiSelect=Ir;exports.OnfidoProvider=mr;exports.OverviewService=Gt;exports.OverviewStep=Or;exports.PhoneInput=Ar;exports.QuestionnaireService=Vt;exports.QuestionnaireStep=Mr;exports.ReviewStatus=Ye;exports.RiskCriteriaType=zt;exports.RiskLevel=Tt;exports.RiskScoringService=Jt;exports.RiskScoringStep=zr;exports.SardinAIProvider=yr;exports.SearchableSelect=De;exports.Select=mt;exports.Spinner=Ee;exports.StepRouter=dr;exports.SumsubProvider=pr;exports.ThemeManager=xr;exports.ThemePreset=we;exports.ThemeService=or;exports.UploadDocumentService=Yt;exports.UploadDocumentStep=Dr;exports.UserType=Lt;exports.ValueDataType=Me;exports.WorkflowOrchestrator=ur;exports.WorkflowResultType=ot;exports.WorkflowState=cr;exports.WorkflowStepAction=oe;exports.appropriatenessTestSchema=$s;exports.clearAllStorage=ns;exports.clearApplicantId=br;exports.clearWorkflowState=kr;exports.cn=Se;exports.corporateTheme=tr;exports.defaultConfig=Wt;exports.defaultTheme=Re;exports.fileToBase64=hr;exports.fintechTheme=rr;exports.formatFileSize=ut;exports.generateAppropriatenessSchema=zs;exports.generateQuestionnaireSchema=Ps;exports.generateRiskScoringSchema=Ds;exports.generateUploadDocumentSchema=Ms;exports.getAcceptString=rs;exports.getApplicantId=gr;exports.getThemePreset=st;exports.getWorkflowState=ss;exports.healthcareTheme=sr;exports.isScriptLoaded=Yr;exports.loadScript=gt;exports.minimalTheme=ar;exports.modernTheme=nr;exports.removeScript=Qr;exports.saveApplicantId=fr;exports.saveWorkflowState=vr;exports.themePresets=ir;exports.useApplicant=vt;exports.useAppropriatenessTest=as;exports.useIdentityVerification=Nr;exports.useKycWorkflow=jr;exports.useMetaKYC=Ne;exports.useOverview=Cr;exports.useQuestionnaire=wr;exports.useRiskScoring=Rr;exports.useUploadDocument=Sr;exports.validateFileSize=es;exports.validateFileType=ts;
103
103
  //# sourceMappingURL=index.cjs.map