@sekyro/web 0.1.0-rc.36 → 0.1.0-rc.37

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.
Files changed (55) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/camera-trait-DELAK3YN.js +1 -0
  3. package/dist/{capture-session-doc-LKMMJG4H.js → capture-session-doc-6MUKGUJ3.js} +1 -1
  4. package/dist/{capture-session-v3-DaRhtwrC.d.cts → capture-session-v3-BdpUe0ht.d.cts} +3 -1
  5. package/dist/{capture-session-v3-_JtEhXUz.d.ts → capture-session-v3-Q4otwuve.d.ts} +3 -1
  6. package/dist/{chunk-EF4VD4GD.js → chunk-2DBOZDYR.js} +1 -1
  7. package/dist/{chunk-K7ICBHSZ.js → chunk-5QUJHFOH.js} +1 -1
  8. package/dist/{chunk-NMPMXAH3.js → chunk-7GUHA2NM.js} +1 -1
  9. package/dist/chunk-AYWS6XTB.js +1 -0
  10. package/dist/{chunk-W42RLLAC.js → chunk-DTQTSZAX.js} +1 -1
  11. package/dist/{chunk-H2ZUHMIC.js → chunk-EP6FVAR4.js} +2 -2
  12. package/dist/{chunk-KCUXJT7L.js → chunk-GVAN773O.js} +1 -1
  13. package/dist/{chunk-AIRC3HT7.js → chunk-KORZGQLS.js} +1 -1
  14. package/dist/{chunk-XON3UNG3.js → chunk-LTGRPMMY.js} +1 -1
  15. package/dist/chunk-PW2HWXBJ.js +1 -0
  16. package/dist/{chunk-VZGTOE22.js → chunk-QPO6LOYB.js} +1 -1
  17. package/dist/chunk-VSLJZ7GH.js +1 -0
  18. package/dist/chunk-W357WDNU.js +1 -0
  19. package/dist/client/index.cjs +1 -1
  20. package/dist/client/index.d.cts +3 -3
  21. package/dist/client/index.d.ts +3 -3
  22. package/dist/client/index.js +1 -1
  23. package/dist/core/index.cjs +1 -1
  24. package/dist/core/index.d.cts +3 -3
  25. package/dist/core/index.d.ts +3 -3
  26. package/dist/core/index.js +1 -1
  27. package/dist/create-document-capture-EK7EDLTD.js +1 -0
  28. package/dist/{create-verification-C58r4HV-.d.cts → create-verification-BJGWTzCS.d.cts} +3 -3
  29. package/dist/{create-verification-Bda1l0t0.d.ts → create-verification-CCCvsDdp.d.ts} +3 -3
  30. package/dist/{detector-scanic-GGIKCF6B.js → detector-scanic-LYXXX77M.js} +1 -1
  31. package/dist/{icao-gate-67SejsPE.d.cts → icao-gate-C2B9Yyz0.d.cts} +1 -1
  32. package/dist/{icao-gate-CjdvLXEu.d.ts → icao-gate-toRhhMow.d.ts} +1 -1
  33. package/dist/{icao-policy-CJsmf9Vh.d.cts → icao-policy-CFoaL76l.d.cts} +2 -2
  34. package/dist/{icao-policy-COdRM4m_.d.ts → icao-policy-xp26r3lv.d.ts} +2 -2
  35. package/dist/index.cjs +2 -2
  36. package/dist/index.d.cts +7 -7
  37. package/dist/index.d.ts +7 -7
  38. package/dist/index.js +1 -1
  39. package/dist/internal/index.cjs +3 -3
  40. package/dist/internal/index.d.cts +6 -6
  41. package/dist/internal/index.d.ts +6 -6
  42. package/dist/internal/index.js +1 -1
  43. package/dist/plan-runner-7XZH4SBZ.js +1 -0
  44. package/dist/print-DCYX3CZD.js +1 -0
  45. package/dist/{types-BOfzAhqF.d.cts → types-BUvxjU5V.d.cts} +66 -2
  46. package/dist/{types-BOfzAhqF.d.ts → types-BUvxjU5V.d.ts} +66 -2
  47. package/package.json +1 -1
  48. package/sbom.cdx.json +19 -19
  49. package/dist/camera-trait-V4UAOPIQ.js +0 -1
  50. package/dist/chunk-2J6R5JOJ.js +0 -1
  51. package/dist/chunk-2LDOXGY3.js +0 -1
  52. package/dist/chunk-XFATG7QI.js +0 -1
  53. package/dist/create-document-capture-PG6NLCPH.js +0 -1
  54. package/dist/plan-runner-BZ7LODPB.js +0 -1
  55. package/dist/print-SEWS3VHQ.js +0 -1
@@ -1 +1 @@
1
- import{C as Me,F as ve,G as ie,H as Te,I as N,J as Y,d as q,e as Ce,f as Pe,g as Ae,i as Re,j as re,l as $,m as oe,o as we,p as xe,q as Ee,u as Ie}from"./chunk-K7ICBHSZ.js";import{c as _e,d as be,e as ke}from"./chunk-FPXL63KZ.js";import{c as j,h as J,i as Oe}from"./chunk-VZGTOE22.js";var Ne=["AD","AE","AF","AG","AI","AL","AM","AO","AQ","AR","AS","AT","AU","AW","AX","AZ","BA","BB","BD","BE","BF","BG","BH","BI","BJ","BL","BM","BN","BO","BQ","BR","BS","BT","BV","BW","BY","BZ","CA","CC","CD","CF","CG","CH","CI","CK","CL","CM","CN","CO","CR","CU","CV","CW","CX","CY","CZ","DE","DJ","DK","DM","DO","DZ","EC","EE","EG","EH","ER","ES","ET","FI","FJ","FK","FM","FO","FR","GA","GB","GD","GE","GF","GG","GH","GI","GL","GM","GN","GP","GQ","GR","GS","GT","GU","GW","GY","HK","HM","HN","HR","HT","HU","ID","IE","IL","IM","IN","IO","IQ","IR","IS","IT","JE","JM","JO","JP","KE","KG","KH","KI","KM","KN","KP","KR","KW","KY","KZ","LA","LB","LC","LI","LK","LR","LS","LT","LU","LV","LY","MA","MC","MD","ME","MF","MG","MH","MK","ML","MM","MN","MO","MP","MQ","MR","MS","MT","MU","MV","MW","MX","MY","MZ","NA","NC","NE","NF","NG","NI","NL","NO","NP","NR","NU","NZ","OM","PA","PE","PF","PG","PH","PK","PL","PM","PN","PR","PS","PT","PW","PY","QA","RE","RO","RS","RU","RW","SA","SB","SC","SD","SE","SG","SH","SI","SJ","SK","SL","SM","SN","SO","SR","SS","ST","SV","SX","SY","SZ","TC","TD","TF","TG","TH","TJ","TK","TL","TM","TN","TO","TR","TT","TV","TW","TZ","UA","UG","UM","US","UY","UZ","VA","VC","VE","VG","VI","VN","VU","WF","WS","XK","YE","YT","ZA","ZM","ZW"];var ut=["carte_identite","passport","residence_permit","drivers_license"],ct=["carte_identite","passport","residence_permit"];function dt(e,t){let n=e.byIssuer?.[t]??e.default;return ut.filter(i=>n==="*"?ct.includes(i):n.includes(i))}function Ln(e,t=Ne){return[...new Set([...t,...Object.keys(e.byIssuer??{})])].filter(i=>dt(e,i).length>0).sort()}function Le(e){if(e.acceptedDocuments)return e.acceptedDocuments;let t=e.acceptedDocumentTypes?.length?[...e.acceptedDocumentTypes]:["carte_identite","passport"];return{default:[],byIssuer:{MR:t}}}var lt=640,pt=new Set(["network_error","timeout","upload_failed","unknown_error","rate_limit_exceeded"]),Ve=6,Fe=1500,He={sharpness:1,exposure:1,meanLuma:128},De=null;function mt(e,t){try{De??(De=document.createElement("canvas"));let n=De,i=96/Math.max(1,t.width);n.width=Math.max(1,Math.round(t.width*i)),n.height=Math.max(1,Math.round(t.height*i));let r=n.getContext("2d");if(r===null)return He;r.drawImage(e,t.x,t.y,t.width,t.height,0,0,n.width,n.height);let a=r.getImageData(0,0,n.width,n.height);return{sharpness:be(a),exposure:ke(a),meanLuma:_e(a)}}catch{return He}}async function ft(e,t){let n=e.source;return"convertToBlob"in n?n.convertToBlob({type:"image/jpeg",quality:t}):new Promise((i,r)=>{n.toBlob(a=>a===null?r(new Error("encode failed")):i(a),"image/jpeg",t)})}function Gn(e,t={}){let n=t.now??(()=>performance.now()),i=t.setTimer??((f,k)=>setTimeout(f,k)),r=t.clearTimer??(f=>clearTimeout(f)),a=t.encode??ft,d=t.quality??mt,c=e.tuningVersion??null,p=new Set,S=!1,g=e.video??null,w=null,h=t.grabFrame??null,y=null,O=1e3/Ve,E=null,I=null,v=!1,V=!1,D=Number.NEGATIVE_INFINITY,x=null,U=0,F=null,K=null,te=Promise.all([import("./icao-gate-T3BTOKFJ.js"),import("./icao-tuning-4ETMF53W.js"),import("./create-portrait-capture-5VGYZUOK.js"),import("./landmarker-KB7LVXAU.js"),import("./background-monitor-A7FKJOAG.js")]).then(async([f,k,A,T,H])=>{let R=k.resolveIcaoTuning(e.tuning,e.tuningVersion??void 0);R.background.required&&(I=H.createBackgroundMonitor({tuning:R.backgroundCheck,assetBaseUrl:e.assetBaseUrl??"/models-v3",...t.createSegmenter!==void 0?{createSegmenter:t.createSegmenter}:{},now:n})),w=f.createIcaoGate(R,{policy:e.policy??"reject"}),h??(h=A.defaultGrabber()),y=A.observe,O=1e3/Math.min(Ve,R.cadenceHz);let M=(t.createLandmarker??T.createFaceLandmarker)(e.assetBaseUrl??"/models-v3"),o=await new Promise((s,u)=>{let l=setTimeout(()=>{u(new Error("landmarker init timeout")),M.then(m=>m.close(),()=>{})},T.LANDMARKER_INIT_TIMEOUT_MS);M.then(m=>{clearTimeout(l),s(m)},m=>{clearTimeout(l),u(m)})});S?o.close():E=o}).catch(()=>{v=!0}),Z=f=>{for(let k of p)k({holding:V||v,update:f})},G=()=>{if(x=null,!(S||E===null||w===null||h===null||y===null||g===null)){if(n()-D>Fe){Z(null);return}try{let f=h(g,lt);if(f!==null){let k=Math.max(n(),U+1);U=k;let A=E.detect(f.source,k),T=g.videoWidth||f.width,H=g.videoHeight||f.height,R=y(A,f,T,H);R.geometry!==null&&I!==null&&(R.backgroundCheck=I.measure(f,R.geometry.box,T,H));let M=w.push(R,n());V=M.ready,Z(M)}}catch{}x=i(G,O)}},ne=()=>{let f=n()-D>Fe;D=n(),f&&(w?.reset(),V=!1,F=null,K=null),x===null&&E!==null&&!S&&(x=i(G,0))},W=()=>{let f=h===null||g===null?null:h(g,null);if(f===null||w===null||Math.max(f.width,f.height)<e.still.minLongSidePx)return Promise.resolve(null);let k=w.summary();return a(f,e.still.jpegQuality).then(A=>({image:A,width:f.width,height:f.height,gate:k}),()=>null)},Q=null;return{engineOptions:{measureQuality:(f,k)=>{g=f,ne();let A=d(f,k);return V||v?A:{...A,sharpness:0}},telemetry:f=>{if(f.type!=="fired"||S)return;F=W();let k=Q;k!==null&&F.then(A=>A===null?void 0:k(A).catch(()=>{})),V=!1,x!==null&&r(x),x=null,D=Number.NEGATIVE_INFINITY}},decorate:f=>{let k=new WeakMap,A=new Map,T=o=>{let s=k.get(o);return s===void 0&&(s=(async()=>{let u=await Ie(f,"image","image/jpeg",o.image.size,{engine:"portrait"});return await f.uploadToSpaces(u.uploadUrl,o.image,"image/jpeg"),(await f.completeMedia(u.key)).key})(),s.catch(()=>k.delete(o)),k.set(o,s)),s};Q=T;let H=async o=>{let s;try{s=await T(o)}catch(u){let l=u?.code;if(typeof l=="string"&&pt.has(l))throw u;return null}return{media:{portrait:s},gate:Oe(o.gate),...c!==null?{tuningVersion:c}:{}}},R=f.submitCheck.bind(f),M=(async(o,s,u)=>{if(o!=="liveness")return R(o,s,u);let l=u?.idempotencyKey,m=l===void 0?void 0:A.get(l);if(m===void 0){let b=F;m=b===null?Promise.resolve(null):b.then(ye=>ye===null?null:H(ye)),l!==void 0&&(A.set(l,m),m.catch(()=>A.delete(l)))}let _=await m;if(_===null)return R("liveness",s,u);let P=await R("liveness",{...s,portraitIcao:_},u);return K=_,P});return new Proxy(f,{get(o,s){if(s==="submitCheck")return M;let u=Reflect.get(o,s);return typeof u=="function"?u.bind(o):u}})},onGate:f=>(p.add(f),()=>p.delete(f)),lastPortraitInput:()=>K,destroy:()=>{S=!0,F=null,K=null,x!==null&&r(x),x=null,p.clear(),te.then(()=>{E?.close(),E=null,I?.close(),I=null})}}}function Ge(e){return e.idNumberBound??e.nniBound}function Be(e){return e===void 0?void 0:e.idNumberFromDocument??e.nniFromDocument}function Ue(e){let t=e.idNumberMasked??e.nniMasked;return typeof t=="string"&&t!==""?t:void 0}var Ke=Object.freeze({nni_invalid:"id_number_invalid",nni_not_found:"registry_record_not_found",nni_recheck:"id_number_recheck",document_nni_mismatch:"document_id_number_mismatch",nni_locked:"id_number_locked",nni_unbound:"id_number_unbound",missing_nni:"missing_id_number",registry_needs_nni_source:"registry_needs_id_number_source"}),ht=new Map(Object.entries(Ke)),Kn=new Map(Object.entries(Ke).map(([e,t])=>[t,e]));function je(e){return ht.get(e)??e}var C={fullNameMin:2,fullName:200,email:254,occupation:120,shortText:120,longText:1e3,addressLine:120,addressLines:4,city:80,postcode:16,number:1e12,dateMin:"1900-01-01",dateMax:"2100-12-31"},St=new Set(["full_name","birth_date","email","phone","address","country","occupation"]),gt=new Set(["short_text","long_text","single_choice","multiple_choice","yes_no","date","number"]),yt=new Set(["ar","fa","he","ur"]);function qe(e){return yt.has(e.split("-")[0]?.toLowerCase()??"")?"rtl":"ltr"}function Ye(e){if(typeof e!="object"||e===null)return null;let t=e;if(typeof t.locale!="string"||!Array.isArray(t.questions)||t.questions.length===0)return null;let n=t.consents??[];if(!Array.isArray(n))return null;for(let r of t.questions)if(!_t(r))return null;for(let r of n)if(!bt(r))return null;let i={locale:t.locale,questions:t.questions,consents:n};return typeof t.title=="string"&&t.title.trim()!==""&&(i.title=t.title),typeof t.intro=="string"&&t.intro.trim()!==""&&(i.intro=t.intro),typeof t.prefill=="object"&&t.prefill!==null&&!Array.isArray(t.prefill)&&(i.prefill=t.prefill),i}function _t(e){if(typeof e!="object"||e===null)return!1;let t=e;return typeof t.id!="string"||typeof t.required!="boolean"?!1:t.kind==="field"?typeof t.field=="string"&&St.has(t.field):t.kind!=="custom"||typeof t.type!="string"||!gt.has(t.type)||typeof t.label!="string"?!1:t.type==="single_choice"||t.type==="multiple_choice"?Array.isArray(t.choices)&&t.choices.length>=2&&t.choices.every(n=>typeof n=="object"&&n!==null&&typeof n.value=="string"&&typeof n.label=="string"):!0}function bt(e){if(typeof e!="object"||e===null)return!1;let t=e;if(typeof t.id!="string"||typeof t.required!="boolean"||typeof t.text!="string")return!1;if(t.link===void 0)return!0;let n=t.link;return typeof n=="object"&&n!==null&&typeof n.url=="string"&&/^https:\/\//.test(n.url)&&typeof n.label=="string"}var kt=/^(\d{4})-(\d{2})-(\d{2})$/;function Ct(e){if(typeof e!="string")return!1;let t=kt.exec(e);return t===null?!1:new Date(Date.UTC(Number(t[1]),Number(t[2])-1,Number(t[3]))).toISOString().slice(0,10)===e&&e>=C.dateMin&&e<=C.dateMax}function Pt(e){return typeof e=="number"&&Number.isFinite(e)&&Math.abs(e)<C.number&&Math.round(e*100)/100===e}function Ze(e){for(let t of e.matchAll(/\d[\d -]{11,}\d/g)){let n=t[0].replace(/[ -]/g,"");if(n.length>=13&&n.length<=19&&At(n))return!0}return!1}function At(e){let t=0;for(let n=0;n<e.length;n++){let i=Number(e[e.length-1-n]);n%2===1&&(i*=2,i>9&&(i-=9)),t+=i}return t%10===0}var Rt=/^[^\s@]+@[^\s@.]+(\.[^\s@.]+)+$/,wt=/^\+[1-9]\d{6,14}$/,We=/^[A-Z]{2}$/,xt=e=>e===void 0||typeof e=="string"&&e.trim()===""||Array.isArray(e)&&e.length===0;function Qe(e=Date.now()){return new Date(e).toISOString().slice(0,10)}function X(e,t,n=Qe()){let i=[];for(let r of e.questions){let a=t.answers[r.id];if(xt(a)){r.required&&i.push({id:r.id,code:"required"});continue}let d=r.kind==="field"?Et(r.field,a,n):Mt(r,a,n);d!==null&&i.push({id:r.id,...d})}for(let r of e.consents)r.required&&t.consents[r.id]!==!0&&i.push({id:r.id,code:"consent_required"});return i}function z(e,t,n=1){if(typeof e!="string")return{code:"required"};let i=e.trim();return[...i].length>t?{code:"too_long",params:{max:t}}:[...i].length<n?{code:"too_short",params:{min:n}}:Ze(i)?{code:"card_number"}:null}function $e(e,t,n={}){return Ct(e)?n.period==="past"&&e>=t?{code:"date_not_past"}:n.period==="future"&&e<=t?{code:"date_not_future"}:n.min!==void 0&&e<n.min?{code:"date_too_early",params:{date:n.min}}:n.max!==void 0&&e>n.max?{code:"date_too_late",params:{date:n.max}}:null:{code:"date_invalid"}}function Et(e,t,n){switch(e){case"full_name":return z(t,C.fullName,C.fullNameMin);case"occupation":return z(t,C.occupation);case"birth_date":return $e(t,n,{period:"past"});case"email":return typeof t=="string"&&t.trim().length<=C.email&&Rt.test(t.trim())?null:{code:"email_invalid"};case"phone":return typeof t=="string"&&wt.test(t)?null:{code:"phone_invalid"};case"country":return typeof t=="string"&&We.test(t)?null:{code:"choice_invalid"};case"address":return It(t)?null:{code:"address_invalid"};default:return null}}function It(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=e,n=Array.isArray(t.lines)?t.lines.filter(i=>typeof i=="string"&&i.trim()!==""):[];return typeof t.country=="string"&&We.test(t.country)&&typeof t.city=="string"&&t.city.trim()!==""&&t.city.trim().length<=C.city&&n.length>=1&&n.length<=C.addressLines&&n.every(i=>i.trim().length<=C.addressLine&&!Ze(i))&&(t.postcode===void 0||typeof t.postcode=="string"&&t.postcode.trim().length<=C.postcode)}function Mt(e,t,n){let i=new Set((e.choices??[]).map(r=>r.value));switch(e.type){case"short_text":return z(t,C.shortText);case"long_text":return z(t,C.longText);case"single_choice":return typeof t=="string"&&i.has(t)?null:{code:"choice_invalid"};case"multiple_choice":return Array.isArray(t)&&t.length>0&&new Set(t).size===t.length&&t.every(r=>i.has(r))?null:{code:"choice_invalid"};case"yes_no":return typeof t=="boolean"?null:{code:"choice_invalid"};case"date":{let r=e.options??{};return $e(t,n,{...typeof r.min=="string"?{min:r.min}:{},...typeof r.max=="string"?{max:r.max}:{},...r.period==="past"||r.period==="future"?{period:r.period}:{}})}case"number":{if(typeof t!="number"||!Number.isFinite(t)||Math.abs(t)>=C.number)return{code:"number_invalid"};let r=e.options??{};return r.integer===!0&&!Number.isInteger(t)?{code:"number_not_integer"}:Pt(t)?typeof r.min=="number"&&t<r.min?{code:"number_too_small",params:{min:r.min}}:typeof r.max=="number"&&t>r.max?{code:"number_too_large",params:{max:r.max}}:null:{code:"number_decimals"}}default:return null}}function Je(e,t,n,i=Qe()){let r=e?.errors;return Array.isArray(r)?r.flatMap(a=>{if(typeof a!="object"||a===null)return[];let{id:d,code:c}=a;return typeof d!="string"||typeof c!="string"?[]:[vt(d,c,t,n)]}):X(t,n,i)}var Ot={full_name:C.fullName,occupation:C.occupation,email:C.email,short_text:C.shortText,long_text:C.longText};function vt(e,t,n,i){let r=n.questions.find(p=>p.id===e),a=r===void 0?void 0:r.kind==="field"?r.field:r.type,d=i.answers[e],c=r!==void 0&&r.kind==="custom"?r.options??{}:{};switch(t){case"required":case"card_number":return{id:e,code:t};case"consent_required":return{id:e,code:"consent_required"};case"too_short":return{id:e,code:t,params:{min:a==="full_name"?C.fullNameMin:1}};case"too_long":{let p=a===void 0?void 0:Ot[a];return p===void 0?{id:e,code:t}:{id:e,code:t,params:{max:p}}}case"not_a_choice":return{id:e,code:"choice_invalid"};case"not_in_past":return{id:e,code:"date_not_past"};case"not_in_future":return{id:e,code:"date_not_future"};case"not_an_integer":return{id:e,code:"number_not_integer"};case"out_of_range":return Tt(e,a,d,c);case"invalid":return r===void 0?n.consents.some(p=>p.id===e)?{id:e,code:"consent_required"}:{id:e,code:t}:{id:e,code:Nt(a,d)};default:return{id:e,code:t}}}function Tt(e,t,n,i){if(t==="date"){let c=typeof i.min=="string"?i.min:void 0,p=typeof i.max=="string"?i.max:void 0;return p!==void 0&&(c===void 0||typeof n=="string"&&n>p)?{id:e,code:"date_too_late",params:{date:p}}:c!==void 0?{id:e,code:"date_too_early",params:{date:c}}:{id:e,code:"date_invalid"}}let r=typeof i.min=="number"?i.min:void 0,a=typeof i.max=="number"?i.max:void 0;return a!==void 0&&(r===void 0||typeof n=="number"&&n>a)?{id:e,code:"number_too_large",params:{max:a}}:r!==void 0?{id:e,code:"number_too_small",params:{min:r}}:{id:e,code:"number_invalid"}}function Nt(e,t){switch(e){case"email":return"email_invalid";case"phone":return"phone_invalid";case"birth_date":case"date":return"date_invalid";case"number":return typeof t=="number"&&Number.isFinite(t)&&Math.abs(t)<C.number?"number_decimals":"number_invalid";case"address":return"address_invalid";case"full_name":case"occupation":case"short_text":case"long_text":return"required";default:return"choice_invalid"}}var Lt=new Set(["phone_otp","email_otp","national_eid","document","nfc","population_registry","supplied_identity","summary_confirm","liveness","portrait","face_match","aml_screening","face_dedup","age_estimation","proof_of_address","form"]),Vt=new Set(["supplied_identity","aml_screening","face_dedup","age_estimation"]),ae=["document","population_registry","national_eid"],ue=["phone_otp","email_otp"],et={identity_method:ae,contact:ue},Ft=["population_registry","document"],ce="platform_unsupported",Ht=new Set(["prefilled","user_entered","prefilled_or_entered"]),Dt={phone_otp:"contact",email_otp:"contact",eid_auth:"identity",doc_ocr:"identity",nfc_chip:"identity",population_registry:"identity",liveness:"live_photo",portrait_icao:"live_photo",face_match:"live_photo",poa:"documents",form:"form"};function L(e){return e.section??Dt[e.checkType]??null}function de(e,t){let n=e.plan?.choice;if(n===void 0||n.locked)return;let i=n.options.find(r=>r.id!==n.selected&&r.available!==!1&&t.includes(r.service));return i===void 0?void 0:{nodeId:n.nodeId,option:i}}function le(e){let t=e.plan,n=t?.choice;if(t===void 0||n===void 0||n.locked||t.current===null||t.current===n.nodeId||re(e))return null;let i=et[n.kind]??[...ae,...ue],r=n.options.flatMap(c=>c.available===!1||!i.includes(c.service)?[]:[c.nationalEid!=null?{id:c.id,service:c.service,nationalEid:c.nationalEid}:{id:c.id,service:c.service}]),a=t.steps.find(c=>c.id===t.current)?.service,d=n.selected??r.find(c=>c.service===a)?.id??null;return r.some(c=>c.id!==d)?{nodeId:n.nodeId,kind:n.kind,current:d,options:r}:null}function tt(e){return e==null?[]:e.options.filter(t=>t.id!==e.current)}function Gt(e){let t=e.simulation;if(typeof t!="object"||t===null)return;let{otpCode:n,skipCapture:i}=t;if(typeof n!="string"||n===""||typeof i!="boolean")return;let r=xe(e);return r!==void 0?{otpCode:n,skipCapture:i,reason:r}:{otpCode:n,skipCapture:i}}function Bt(e){let t=e.levelTarget?.max;return typeof t=="number"&&t<=1?"contact":e.purpose??"identity"}function Ut(e){let t=(e.plan?.sections??[]).map(d=>({id:d.id,state:d.state})),n={sessionId:oe(e.sessionId),orgName:e.orgName,sandbox:e.sandbox===!0,returning:e.returning===!0,consentRecorded:e.consentRecorded,expiresAt:e.expiresAt,sections:t.map(d=>d.id),progress:t,purpose:e.purpose??"identity",levelName:Bt(e)};e.branding!==void 0&&(n.branding=e.branding),e.cameraUnavailableHandled===!0&&(n.cameraUnavailableHandled=!0);let i=Gt(e);i!==void 0&&(n.simulation=i);let r=e.testerGate;r?.offered===!0&&typeof r.attemptsLeft=="number"&&r.attemptsLeft>0&&(n.testerGate={attemptsLeft:r.attemptsLeft});let a=le(e);return a!==null&&(n.switchable=a),n}function Kt(e){let t={attemptsRemaining:Pe(e),attemptsExhausted:e.attempts.used>=e.attempts.max};return e.reason!==void 0&&(t.reason=e.reason),e.retakeHint!==void 0&&(t.retakeHint=e.retakeHint),t}var nt={phone_otp:"phone",email_otp:"email"};function jt(e,t){let n=de(e,[t==="phone_otp"?"email_otp":"phone_otp"]);return n===void 0?void 0:nt[n.option.service]}function qt(e,t,n,i){let r=t.checkType==="email_otp",a=(r?t.emailOtp:t.otp)??{},d=r?t.emailOtp?.emailSource:t.otp?.numberSource,c=d!==void 0&&Ht.has(d)?d:r?"prefilled_or_entered":"user_entered",p=typeof a.sentToMasked=="string"&&a.sentToMasked.length>0,S=a.prefilled===!0,g=jt(e,r?"email_otp":"phone_otp"),w={key:t.checkType,context:n,section:L(t),phase:p?"verify":"send",canSwitch:g!==void 0,...i},h=r?{kind:"email_otp",...w,emailSource:c,needsEmail:c!=="prefilled"&&!S}:{kind:"phone_otp",...w,numberSource:c,needsPhone:c!=="prefilled"&&!S,channels:(t.otp?.channels??[]).filter(y=>y==="whatsapp"||y==="sms")};if(g!==void 0&&(h.switchChannel=g),S&&(h.prefilled=!0),p&&(h.sentToMasked=a.sentToMasked),!r&&t.otp?.channel!==void 0&&(h.channel=t.otp.channel),!r&&Array.isArray(t.phoneCountries)&&(h.phoneCountries=t.phoneCountries.filter(y=>typeof y=="string"&&/^[A-Z]{2}$/.test(y))),!r&&Array.isArray(t.phoneRules)){let y=h.phoneCountries??[];h.phoneRules=t.phoneRules.flatMap(O=>{let E=Wt(O);return E!==void 0&&y.includes(E.code)?[E]:[]})}return!r&&t.phoneInternational===!0&&(h.phoneInternational=!0),a.expiresAt!==void 0&&(h.codeExpiresAt=a.expiresAt),a.resendAvailableAt!==void 0&&(h.resendAvailableAt=a.resendAvailableAt),h}var Yt=/^[\d[\]\-|()?:^]{1,64}$/;function Zt(e){try{return typeof e=="string"&&Yt.test(e)&&new RegExp(e)!==null}catch{return!1}}var ze=e=>typeof e=="number"&&Number.isInteger(e)&&e>=1&&e<=15;function Wt(e){let{code:t,dial:n,trunk:i,lengths:r,formats:a}=e??{};if(typeof t!="string"||typeof n!="string"||!/^\d{1,3}$/.test(n)||i!==void 0&&(typeof i!="string"||!/^\d{1,3}$/.test(i))||!Array.isArray(r)||r.length===0||!r.every(ze))return;let d={code:t,dial:n,lengths:[...r].sort((c,p)=>c-p)};if(i!==void 0&&(d.trunk=i),a!==void 0){if(!(Array.isArray(a)&&a.length<=8&&a.every(p=>Zt(p?.leading)&&Array.isArray(p.groups)&&p.groups.every(ze)&&r.includes(p.groups.reduce((S,g)=>S+g,0)))))return;d.formats=a.map(p=>({leading:p.leading,groups:[...p.groups]}))}return d}function Qt(e,t,n,i){let r=Ge(e)===!0?"bound":Be(t)===!0?"document":"typed",a=r==="typed"&&t.state==="input_required"&&t.reason!==void 0&&je(t.reason)==="id_number_recheck",d=tt(le(e)),c=!i.attemptsExhausted&&d.length===1&&d[0]?.service==="document";return{kind:"registry",key:"registry",context:n,section:L(t),state:t.state==="input_required"?"input_required":"pending",source:r,recheck:a,canUseDocument:c,...i}}function $t(e,t,n,i,r){let a=[...t.acceptedSides??[]],d={kind:"document",key:"document",context:n,section:L(t),side:a.includes("recto")?"verso":"recto",acceptedSides:a,documents:Le(e),photo:me(pe(e.documents),r),...i};return e.detectedCountry!==void 0&&(d.detectedCountry=e.detectedCountry),Xt(e)&&(d.ageStepUp=!0),d}function pe(e,t=!0){let n=e?.source==="upload"||e?.source==="choice"?e.source:"camera",i=e?.sourcePick==="camera"||e?.sourcePick==="upload"?e.sourcePick:null;return{source:n,pick:i,uploadOffered:t&&e?.uploadOffered===!0}}function me(e,t){return t?{...e,cameraOnPhone:!0}:e}var Jt=10*1024*1024;function zt(e,t,n,i,r){let a=e.proofOfAddress,d=a?.pdf?.maxBytes,c=a?.phase==="holder_letter"?"holder_letter":"document";return{kind:"proof_of_address",key:"proof_of_address",context:n,section:L(t),phase:c,rule:a?.rule??{country:null,countryFrom:"global",source:"preset_global",kinds:[]},nameMatch:a?.nameMatch??"exact_person",photo:me(pe(a),r),maxPages:3,pdf:{maxBytes:typeof d=="number"&&d>0?d:Jt,maxPages:3},licenceAddressAccepted:c==="document"&&a?.licenceAddressAccepted===!0,...i}}function Xt(e){let t=Ce(e).find(i=>i.checkType==="age_estimation"),n=t?.reason;return t?.state==="failed"&&(n==="age_uncertain"||n==="age_unavailable")}function en(e){let t=$(e,"liveness");return t?.state==="passed"||t?.state==="review"}function Xe(e,t,n,i,r,a=!1){let d=t.icao?.report,c=e.portrait,p=r==="capture"?c?.pendingFix??null:null;p!==null&&(r="review");let S=rt(e);return{kind:"portrait",key:`portrait:${r}`,context:n,section:L(t),phase:r,report:Array.isArray(d)?d:null,review:t.state==="review",tuning:e.capture?.icao??null,tuningVersion:e.capture?.tuningVersion??null,icao:J(e),retakeOnly:r==="capture"&&t.state==="input_required"&&S===void 0&&e.capture?.livePhoto?.oneCapture===!0&&en(e),photo:me(pe(c,r==="capture"),a&&r==="capture"),pendingFix:p,...S!==void 0?{captureMode:S}:{},...c?.reuse?.pending===!0?{reuse:!0}:{},...i}}function rt(e){let t=e.portrait?.captureMode;return t==="self"||t==="assisted"||t==="choice"?t:void 0}var se={minLongSidePx:1280,jpegQuality:.95};function tn(e,t){let n=e.capture?.livePhoto;if(n?.oneCapture!==!0)return null;let i=$(e,"portrait_icao"),r=n.still??se;return{icao:t==="liveness"&&J(e)!==null&&rt(e)===void 0&&i!==void 0&&i.state==="pending"&&i.reason===void 0,still:{minLongSidePx:r.minLongSidePx??se.minLongSidePx,jpegQuality:r.jpegQuality??se.jpegQuality}}}function nn(e,t,n,i){let r=t.eid,a=L(t);if(r===void 0||r.challenge!=="app_code")return{kind:"unsupported",key:"unsupported:eid_auth",context:n,section:a,checkType:"eid_auth",reason:"update_required"};let d=tt(le(e)),c=d.length===1&&Ft.includes(d[0]?.service??"")?d[0]:void 0,p=c===void 0?void 0:q[c.service],S=p!==void 0,g={kind:"eid",key:"eid",context:n,section:a,provider:r.provider,providerName:r.providerName,country:r.country,challenge:"app_code",phase:r.awaiting==="code"?"code":"identifier",identifierBound:r.identifierBound===!0,canUseCamera:S,afterPass:r.afterPass==="continue"?"continue":"end",...i};return S&&(g.cameraMethod=p),r.expiresAt!==void 0&&(g.codeExpiresAt=r.expiresAt),r.resendAvailableAt!==void 0&&(g.resendAvailableAt=r.resendAvailableAt),r.resendsRemaining!==void 0&&(g.resendsRemaining=r.resendsRemaining),r.codeAttemptsRemaining!==void 0&&(g.codeAttemptsRemaining=r.codeAttemptsRemaining),g}function rn(e,t){if(t.checkType!=="face_match"||t.reason!==void 0)return null;let n=$(e,"portrait_icao");return n!==void 0&&(n.state==="passed"||n.state==="review")?n:null}var on={rejected:"rejected",inconclusive:"inconclusive",unavailable:"unavailable",abandoned:"expired",not_opened:"expired",cancelled:"expired",superseded:"expired",policy:"policy"};function sn(e){return e.reasonCode===ce?"platform_unsupported":e.status==="review_pending"?"review":e.status==="verified"?"verified":e.reasonCode==="device_cooldown"?"cooldown":e.reasonCode==="starter_credit_claimed"?"policy":(e.status==="not_verified"&&e.reason!==void 0?on[e.reason]:void 0)??"rejected"}function an(e,t){let n=sn(e),i=n==="platform_unsupported"?{sessionId:oe(e.sessionId),status:"unavailable",reasonCode:ce}:we(e,{autoRetry:!1}),r={kind:"result",key:"result",context:t,section:null,display:n,result:i};return e.status==="not_verified"&&e.reason!==void 0&&(r.reason=e.reason),e.reasonCode!==void 0&&(r.reasonCode=e.reasonCode),e.status==="not_verified"&&e.step!==void 0&&(r.step=e.step),e.retryAfter!==void 0&&(r.retryAfter=e.retryAfter),r}function un(e,t,n){let i=e.identitySummary;if(i==null)return null;let r={kind:"identity_summary",key:"identity_summary",context:t,section:n??"identity",summaryKind:i.kind==="partial"?"partial":i.kind??"full",source:i.source,portraitAvailable:i.portrait?.available===!0,retakeAvailable:i.retakeAvailable===!0};for(let d of cn){let c=i[d];typeof c=="string"&&c!==""&&(r[d]=c)}let a=Ue(i);return a!==void 0&&(r.idNumberMasked=a,r.nniMasked=a),r}var cn=["fullName","birthDate","birthYear","nationality","documentType","documentNumberMasked","expiryDate","retakeTarget"];function B(e,t,n,i){return{kind:"unsupported",key:`unsupported:${n}`,context:e,section:t,checkType:n,reason:i}}function dn(e){return e.kind==="contact"?"contact":(e.kind==="identity_method","identity")}function ln(e,t){let n=et[e.kind]??[...ae,...ue],i=dn(e),r=e.options.flatMap(d=>{if(d.available===!1||!n.includes(d.service))return[];let c={id:d.id,service:d.service};d.nationalEid!=null&&(c.nationalEid=d.nationalEid);let p=(d.channels??[]).filter(S=>S==="whatsapp"||S==="sms");return d.service==="phone_otp"&&p.length>0&&(c.channels=p),[c]});if(r.length===0){let d=e.options.length>0&&e.options.every(c=>c.service==="nfc");return B(t,i,"choice",d?"platform_unsupported":"update_required")}let a={nodeId:e.nodeId,kind:e.kind,selected:e.selected,options:r};if(e.kind==="identity_method"){let d={kind:"method",key:"method",context:t,section:i,options:r.map(p=>q[p.service]),choice:a},c=r.find(p=>p.nationalEid!==void 0)?.nationalEid;return c!==void 0&&(d.nationalEid=c),d}return e.kind==="contact"?{kind:"contact_choice",key:"contact_choice",context:t,section:i,options:r.map(d=>nt[d.service]),selected:null,locked:!1,choice:a}:{kind:"choice",key:`choice:${e.nodeId}`,context:t,section:i,choice:a}}function pn(e,t,n,i){let r=e.nativeApp,a=typeof r=="object"&&r!==null?r:{},d={sekyroApp:a.sekyroApp===!0};return typeof a.link=="string"&&a.link!==""&&(d.link=a.link),d.sekyroApp&&typeof a.sekyroAppLink=="string"&&a.sekyroAppLink.startsWith("sekyro://")&&(d.sekyroAppLink=a.sekyroAppLink),{kind:"native_app_required",key:`native_app_required:${i}`,context:t,section:n,checkType:i,nativeApp:d}}function ee(e,t={}){let n=Ut(e);if(re(e)||e.reasonCode===ce)return an(e,n);let i=e.plan;if(i===void 0||!Array.isArray(i.sections))return B(n,null,"plan","update_required");let r=Ae(e);if(r!==null)return ln(r,n);let a=i.current===null?void 0:i.steps.find(h=>h.id===i.current),d=h=>{let y={kind:"processing",key:"processing",context:n,section:h!==void 0?L(h):i.sections.find(O=>O.state==="current")?.id??null,stalled:!1};return typeof h?.service=="string"&&h.service!==""&&(y.service=h.service),y};if(i.current===null)return d(i.steps.find(h=>h.state==="processing"));if(a===void 0)return B(n,null,"step","update_required");if(!Lt.has(a.service))return a.interaction==="server"?d(a):B(n,L(a),a.service,"update_required");if(Vt.has(a.service)||!Re(a))return d(a);let c=a,p=Kt(c),S=c.checkType,g=L(c);if(c.requiresNativeApp===!0)return pn(e,n,g,S);let w=t.isMobile===!1?Ee(e,c):null;if(w==="phone")return{kind:"mobile_required",key:"mobile_required",context:n,section:g,checkType:S};switch(S){case"phone_otp":case"email_otp":return qt(e,c,n,p);case"population_registry":return Qt(e,c,n,p);case"eid_auth":return nn(e,c,n,p);case"doc_ocr":return $t(e,c,n,p,w==="upload_or_phone");case"identity_confirm":return un(e,n,g)??d(c);case"portrait_icao":return Xe(e,c,n,p,"capture",w==="upload_or_phone");case"liveness":case"face_match":{let h=rn(e,c);if(h!==null)return Xe(e,h,n,p,"match");let y=c.requiresMobile===!0,O=J(e);return{kind:"liveness",key:"biometric",context:n,section:g,mode:S==="face_match"?"selfie":"liveness",requiresMobile:y,instructions:O===null?"standard":"icao",icao:O,livePhoto:tn(e,S),...p}}case"poa":return zt(e,c,n,p,w==="upload_or_phone");case"form":{let h=Ye(c.form);return h===null?B(n,g,S,"update_required"):{kind:"form",key:"form",context:n,section:g,form:h,dir:qe(h.locale),...p}}case"nfc_chip":return B(n,g,S,"platform_unsupported");default:return B(n,g,S,"update_required")}}var mn=/^[A-Z0-9][A-Z0-9 -]{0,39}$/,fn=Object.freeze({normalize:e=>e.trim().toUpperCase().replace(/\s+/g," "),check:e=>mn.test(e),registrySources:Object.freeze([]),describe:"number must be 1 to 40 letters, digits, spaces or hyphens"}),hn=/^[A-Z0-9]{4,20}$/,fe=e=>e.trim().toUpperCase().replace(/[\s-]+/g,""),Sn=Object.freeze({normalize:fe,check:e=>hn.test(fe(e)),registrySources:Object.freeze([]),describe:"number must be 4 to 20 letters or digits"});function gn(e){return typeof e=="string"&&/^\d{10}$/.test(e)&&Number(e)%97===1}var yn={trim:e=>e.trim(),upper_single_space:e=>e.trim().toUpperCase().replace(/\s+/g," "),upper_no_space_or_hyphen:fe},_n={mr_nni_mod97:e=>gn(e)};function bn(e){let t=new RegExp(e.pattern,"u"),n=e.check===null?void 0:_n[e.check];return Object.freeze({normalize:yn[e.normalize],check:i=>t.test(i.trim())&&(n===void 0||n(i)),registrySources:Object.freeze([...e.registrySources]),describe:e.describe})}var kn=Object.freeze(Object.fromEntries(Object.entries(Te).map(([e,t])=>[e,bn(t)])));function he(e,t){return kn[`${e.toUpperCase()}:${t}`]??(t==="drivers_license"?Sn:fn)}var Cn=Object.freeze({MRT:"MR"});function ot(e,t){let n=e.trim().toUpperCase();return he(Cn[n]??n,t)}function it(e){let t=ot(e.issuingCountry,e.type);return t.check(t.normalize(e.number))}function st(e){return he("MR","national_id").check(e)}function Se(e){let t="";for(let n of e){let i=n.codePointAt(0)??0;i>=1632&&i<=1641?t+=String(i-1632):i>=1776&&i<=1785?t+=String(i-1776):n!==" "&&n!=="-"&&n!==" "&&(t+=n)}return t}var Pn=[1e3,2e3,4e3,8e3,15e3],An=3e4,Rn=/^\+[1-9]\d{6,14}$/,wn=/^\d{6}$/,xn=/^\d{6}$/,En=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,at=new Set(["session_not_active","check_not_found","check_already_finalized","check_out_of_order","identity_confirm_required","identity_confirm_locked","choice_locked","choice_option_unavailable","choice_not_found","step_not_on_path","check_not_active","native_app_required"]),In={simulatedCapture:!0},Mn=new Set(["network_error","timeout","upload_failed","unknown_error","rate_limit_exceeded"]);function pr(e){let t=!1,n=null,i="",r=!1,a=!1,d=!1,c={},p={},S=new Set,g=!1,w=!1,h=null,y="idle",O=new Map,E=new Map,I=(o,s,u)=>{let l=`${o}.${s}`,m=O.get(l);if(m!==void 0)return m;let _=E.get(o),P=(_===void 0?u():_.then(u)).finally(()=>{O.delete(l)});O.set(l,P);let b=P.then(()=>{},()=>{});return E.set(o,b),b.then(()=>{E.get(o)===b&&E.delete(o)}),P},v=async(o,s,u)=>{await e.ensureConsent();let l;try{l=await Me(e.runtime,s)}catch(_){if(_ instanceof j&&at.has(_.code)){await e.refreshView();return}throw _}if(u?.(l),e.destroyed())return;let m=l;m.plan!==void 0&&e.setView!==void 0?e.setView(m):await e.refreshView()},V=async o=>{await e.ensureConsent();let s;try{try{s=await o(e.runtime.client)}catch(u){if(!(u instanceof j)||u.code!=="consent_required")throw u;await e.runtime.ensureConsent({force:!0}),s=await o(e.runtime.client)}}catch(u){if(u instanceof j&&at.has(u.code)){await e.refreshView();return}throw u}e.destroyed()||(s!==void 0&&e.setView!==void 0?e.setView(s):await e.refreshView())},D=(o,s)=>I("choice",`${o}:${s}`,()=>V(u=>u.choose(o,s))),x=(o,s)=>o.options.some(u=>u.id===s)?D(o.nodeId,s):Promise.reject(new RangeError(`option ${String(s)} is not offered`)),U=(o,s)=>{let u=e.currentView(),l=u===null?void 0:de(u,o);return l===void 0?Promise.reject(new RangeError(`the ${s} is not offered`)):D(l.nodeId,l.option.id)},F=o=>I("identity",o,()=>V(s=>s.confirmIdentity===void 0?Promise.reject(new Error("identity confirmation is not available in this build")):s.confirmIdentity(o))),K=(o,s)=>{let u=X(o.form,s);if(u.length>0)return Promise.reject(new ie(u,"client"));let l={answers:{...s.answers},consents:{}};for(let m of o.form.consents)l.consents[m.id]=s.consents[m.id]===!0;return I("form","submit",()=>v("form",(m,_)=>m.submitCheck("form",l,{idempotencyKey:_})).catch(m=>{throw m instanceof j&&m.code===ve?new ie(Je(m.details,o.form,l),"server"):m}))},te=(o,s)=>{let u=o.kind,l=u==="phone_otp",m=l?"phone":"email",_={action:"send"};if(l?o.needsPhone:o.needsEmail){let P=s[m]??p[u],b=l?P?.replace(/[\s().-]/g,""):P?.trim();if(b!==void 0||o.phase!=="verify"){if(b===void 0||!(l?Rn:En).test(b))return Promise.reject(l?new N("phone","format"):new Y("email","format"));_[m]=b}}if(l){let P=o.channels,b=s.channel??(P.length===1?P[0]:void 0);if(P.length>0){if(b===void 0)return Promise.reject(new Y("channel","required"));if(!P.includes(b))return Promise.reject(new Y("channel","unavailable"))}b!==void 0&&(_.channel=b),_.phoneRules=1}return I(u,"send",()=>v(u,(P,b)=>P.submitCheck(u,_,{idempotencyKey:b}),P=>{vn(P,u)||(c[u]=e.now(),_[m]!==void 0&&(p[u]=_[m]))}))},Z=(o,s)=>wn.test(s)?I(o,"verify",()=>v(o,(u,l)=>u.submitCheck(o,{action:"verify",code:s},{idempotencyKey:l}))):Promise.reject(new N("code","format")),G=(o,s)=>I("eid_auth",o,()=>v("eid_auth",(u,l)=>u.submitCheck("eid_auth",s,{idempotencyKey:l}))),ne=(o,s)=>{if(o.identifierBound)return G("start",{action:"start"});let u=Se(s??"");if(o.country==="MR"){if(!/^\d{10}$/.test(u))return Promise.reject(new N("nni","format"));if(!st(u))return Promise.reject(new N("nni","check_digit"))}else if(u==="")return Promise.reject(new N("nni","format"));return G("start",{action:"start",identifier:u})},W=(o,s,u)=>{if(o.source!=="typed")return Promise.reject(new RangeError("this session already holds the ID number"));let l=Se(s);return/^\d{10}$/.test(l)?it({type:"national_id",issuingCountry:"MR",number:l})?I("population_registry","submitIdNumber",()=>v("population_registry",(m,_)=>m.submitCheck("population_registry",{idNumber:l,nni:l},{idempotencyKey:_}),()=>{h=`\u2022\u2022\u2022\u2022\u2022\u2022${l.slice(-4)}`})):Promise.reject(new N(u,"check_digit")):Promise.reject(new N(u,"format"))},Q=o=>(e.stopCameras?.(),I(o,"skipCapture",()=>v(o,(s,u)=>s.submitCheck(o,In,{idempotencyKey:u}),()=>{(o==="liveness"||o==="portrait_icao")&&(g=!0)}))),ge=o=>{if(o.kind==="result"||o.context.simulation?.skipCapture!==!0)return o;let s=On(o);return s===null?o:{...o,skipCapture:()=>Q(s)}},f=o=>((o.kind==="document"||o.kind==="portrait"||o.kind==="proof_of_address")&&o.photo?.cameraOnPhone===!0&&(o.refresh=async()=>{await e.refreshView()}),o),k=o=>{switch(o.kind){case"phone_otp":case"email_otp":{let s={...o,send:(l={})=>te(o,l),verify:l=>Z(o.kind,l),switchTo:()=>o.canSwitch&&o.switchChannel!==void 0?U([o.switchChannel==="email"?"email_otp":"phone_otp"],"other contact option"):Promise.reject(new RangeError("this session has no other contact option"))},u=c[o.kind];return s.resendAvailableAt===void 0&&u!==void 0&&(s.resendAvailableAt=new Date(u+An).toISOString()),s}case"eid":return{...o,start:s=>ne(o,s),verify:s=>xn.test(s)?G("verify",{action:"verify",code:s}):Promise.reject(new N("code","format")),resend:()=>o.resendsRemaining===0?Promise.reject(new RangeError("no new code can be sent for this session")):G("resend",{action:"resend"}),useCamera:()=>o.canUseCamera&&o.cameraMethod!==void 0?U(o.cameraMethod==="document_photo"?["document"]:["population_registry"],"camera path"):Promise.reject(new RangeError("the camera path is not offered"))};case"method":return{...o,select:s=>{let u=o.choice.options.find(l=>q[l.service]===s);return u!==void 0?x(o.choice,u.id):Promise.reject(new RangeError(`method ${String(s)} is not offered`))},choose:s=>x(o.choice,s)};case"choice":return{...o,choose:s=>x(o.choice,s)};case"registry":return{...o,submitIdNumber:s=>W(o,s,"idNumber"),submitNni:s=>W(o,s,"nni"),confirm:()=>I("population_registry","confirm",()=>v("population_registry",(s,u)=>s.submitCheck("population_registry",{},{idempotencyKey:u}))),useDocument:()=>o.canUseDocument?U(["document"],"document method"):Promise.reject(new RangeError("the document method is not offered"))};case"document":return e.bindDocument!==void 0?f(e.bindDocument(o,M)):{...o,issuer:null,documentType:null,captureSide:null,selectDocument:()=>{throw new Error("document capture is not available in this build")},capture:()=>{throw new Error("document capture is not available in this build")},uploadDocument:()=>Promise.reject(new Error("document upload is not available in this build"))};case"portrait":return e.bindPortrait!==void 0?f(e.bindPortrait(o,M)):{...o,uploadFailed:!1,resubmit:()=>Promise.resolve(),capture:()=>{throw new Error("portrait capture is not available in this build")},uploadPortrait:()=>Promise.reject(new Error("portrait upload is not available in this build")),confirmFix:()=>Promise.reject(new Error("portrait review is not available in this build"))};case"proof_of_address":return e.bindProofOfAddress!==void 0?f(e.bindProofOfAddress(o,M)):{...o,uploadPages:()=>Promise.reject(new Error("proof of address upload is not available in this build")),uploadHolderLetter:()=>Promise.reject(new Error("proof of address upload is not available in this build")),capturePage:()=>{throw new Error("proof of address capture is not available in this build")}};case"form":return{...o,validate:s=>X(o.form,s),submit:s=>K(o,s)};case"contact_choice":return{...o,select:s=>{let u=s==="phone"?"phone_otp":s==="email"?"email_otp":void 0,l=o.choice.options.find(m=>m.service===u);return l!==void 0?x(o.choice,l.id):Promise.reject(new RangeError(`contact ${String(s)} is not offered`))},choose:s=>x(o.choice,s)};case"identity_summary":return{...o,...o.idNumberMasked===void 0&&o.summaryKind==="partial"&&h!==null?{idNumberMasked:h,nniMasked:h}:{},portrait:async()=>{let s=e.runtime.client;if(!o.portraitAvailable||s.identityPortrait===void 0)return null;try{return await s.identityPortrait()}catch{return null}},confirm:()=>F("confirm"),retake:()=>o.retakeAvailable?F("retake"):Promise.reject(new RangeError("no retake is left"))};case"liveness":return{...o,capture:s=>e.liveness(s),onLivePhoto:s=>o.livePhoto?.icao===!0&&e.onLivePhoto!==void 0?e.onLivePhoto(s):()=>{}};case"mobile_required":case"native_app_required":case"processing":return{...o,refresh:async()=>{r=!1,await e.refreshView()}};case"unsupported":case"result":return{...o};default:{let s=o;throw new Error(`runner: unhandled step ${JSON.stringify(s)}`)}}},A=o=>ge(k(o)),T=async()=>{if(!a){a=!0;try{for(let o of Pn){if(await e.sleep(o),!t||e.destroyed())return;let s=await e.refreshView().catch(()=>null);if(s!==null&&ee(s,{isMobile:e.isMobile()}).kind!=="processing")return}r=!0,M()}finally{a=!1}}},H=o=>{if(o.kind!=="liveness"||o.mode!=="selfie")return null;let s={kind:"processing",key:"processing",context:o.context,section:o.section,stalled:!1};if(y==="inflight")return s;if(!w||y==="done")return null;let u=e.keptFaceKey?.()??null;return u===null?null:(y="inflight",v("face_match",(l,m)=>l.submitCheck("face_match",{imageKey:u},{idempotencyKey:m}),()=>{y="done"}).then(()=>{y==="inflight"&&(y="done",M())},()=>{y="done",M()}),s)},R=(o,s=!1)=>{if(!t||e.destroyed()||e.chainBusy())return;let u=ee(o,{isMobile:e.isMobile()});u.kind==="registry"&&u.recheck&&(w=!0,y="idle"),u=H(u)??u,u.kind==="processing"?u.stalled=r:r=!1;let l=A(u),m=u.kind==="result"?void 0:u.context.switchable,_=m===void 0?l:{...l,chooseOption:b=>x({nodeId:m.nodeId,kind:m.kind,selected:m.current,options:m.options},b)},P=JSON.stringify(_);u.kind==="registry"&&u.source==="document"&&u.state==="pending"&&!S.has("registry")&&(S.add("registry"),_.confirm().catch(b=>{(!(b instanceof j)||Mn.has(b.code))&&S.delete("registry")})),!(!s&&P===i)&&(i=P,n=_,e.emitStep(_),u.kind==="processing"&&!r&&y!=="inflight"&&T(),u.kind==="result"&&!d&&(d=!0,e.emitResult(u.result)))};function M(){let o=e.currentView();o!==null&&R(o,!0)}return{run:async()=>{if(e.destroyed())throw new Error("verification destroyed");t=!0;let o=await e.ensureView();return n===null&&R(o),n??A(ee(o,{isMobile:e.isMobile()}))},current:()=>n,onView:o=>R(o),onChainIdle:()=>{let o=e.currentView();o!==null&&R(o)},republish:M,submit:v,faceProbeSkipped:()=>g}}function On(e){switch(e.kind){case"document":return"doc_ocr";case"liveness":return e.mode==="selfie"?"face_match":"liveness";case"portrait":return e.phase==="capture"?"portrait_icao":null;case"proof_of_address":return"poa";case"mobile_required":case"native_app_required":return e.checkType;case"unsupported":return e.checkType==="nfc_chip"?"nfc_chip":null;default:return null}}function vn(e,t){let n=e,i=n?.plan?.steps??n?.steps;return Array.isArray(i)?i.some(r=>r.checkType===t&&typeof r.reason=="string"):!1}export{dt as a,Ln as b,Ve as c,Fe as d,Gn as e,rt as f,ee as g,Pn as h,An as i,pr as j};
1
+ import{C as Me,F as ve,G as ie,H as Te,I as N,J as Y,d as q,e as Ce,f as Pe,g as Ae,i as Re,j as re,l as $,m as oe,o as we,p as xe,q as Ee,u as Ie}from"./chunk-5QUJHFOH.js";import{c as _e,d as be,e as ke}from"./chunk-FPXL63KZ.js";import{c as j,h as J,i as Oe}from"./chunk-QPO6LOYB.js";var Ne=["AD","AE","AF","AG","AI","AL","AM","AO","AQ","AR","AS","AT","AU","AW","AX","AZ","BA","BB","BD","BE","BF","BG","BH","BI","BJ","BL","BM","BN","BO","BQ","BR","BS","BT","BV","BW","BY","BZ","CA","CC","CD","CF","CG","CH","CI","CK","CL","CM","CN","CO","CR","CU","CV","CW","CX","CY","CZ","DE","DJ","DK","DM","DO","DZ","EC","EE","EG","EH","ER","ES","ET","FI","FJ","FK","FM","FO","FR","GA","GB","GD","GE","GF","GG","GH","GI","GL","GM","GN","GP","GQ","GR","GS","GT","GU","GW","GY","HK","HM","HN","HR","HT","HU","ID","IE","IL","IM","IN","IO","IQ","IR","IS","IT","JE","JM","JO","JP","KE","KG","KH","KI","KM","KN","KP","KR","KW","KY","KZ","LA","LB","LC","LI","LK","LR","LS","LT","LU","LV","LY","MA","MC","MD","ME","MF","MG","MH","MK","ML","MM","MN","MO","MP","MQ","MR","MS","MT","MU","MV","MW","MX","MY","MZ","NA","NC","NE","NF","NG","NI","NL","NO","NP","NR","NU","NZ","OM","PA","PE","PF","PG","PH","PK","PL","PM","PN","PR","PS","PT","PW","PY","QA","RE","RO","RS","RU","RW","SA","SB","SC","SD","SE","SG","SH","SI","SJ","SK","SL","SM","SN","SO","SR","SS","ST","SV","SX","SY","SZ","TC","TD","TF","TG","TH","TJ","TK","TL","TM","TN","TO","TR","TT","TV","TW","TZ","UA","UG","UM","US","UY","UZ","VA","VC","VE","VG","VI","VN","VU","WF","WS","XK","YE","YT","ZA","ZM","ZW"];var ut=["carte_identite","passport","residence_permit","drivers_license"],ct=["carte_identite","passport","residence_permit"];function dt(e,t){let n=e.byIssuer?.[t]??e.default;return ut.filter(i=>n==="*"?ct.includes(i):n.includes(i))}function Ln(e,t=Ne){return[...new Set([...t,...Object.keys(e.byIssuer??{})])].filter(i=>dt(e,i).length>0).sort()}function Le(e){if(e.acceptedDocuments)return e.acceptedDocuments;let t=e.acceptedDocumentTypes?.length?[...e.acceptedDocumentTypes]:["carte_identite","passport"];return{default:[],byIssuer:{MR:t}}}var lt=640,pt=new Set(["network_error","timeout","upload_failed","unknown_error","rate_limit_exceeded"]),Ve=6,Fe=1500,He={sharpness:1,exposure:1,meanLuma:128},De=null;function mt(e,t){try{De??(De=document.createElement("canvas"));let n=De,i=96/Math.max(1,t.width);n.width=Math.max(1,Math.round(t.width*i)),n.height=Math.max(1,Math.round(t.height*i));let r=n.getContext("2d");if(r===null)return He;r.drawImage(e,t.x,t.y,t.width,t.height,0,0,n.width,n.height);let a=r.getImageData(0,0,n.width,n.height);return{sharpness:be(a),exposure:ke(a),meanLuma:_e(a)}}catch{return He}}async function ft(e,t){let n=e.source;return"convertToBlob"in n?n.convertToBlob({type:"image/jpeg",quality:t}):new Promise((i,r)=>{n.toBlob(a=>a===null?r(new Error("encode failed")):i(a),"image/jpeg",t)})}function Gn(e,t={}){let n=t.now??(()=>performance.now()),i=t.setTimer??((f,k)=>setTimeout(f,k)),r=t.clearTimer??(f=>clearTimeout(f)),a=t.encode??ft,d=t.quality??mt,c=e.tuningVersion??null,p=new Set,S=!1,g=e.video??null,w=null,h=t.grabFrame??null,y=null,O=1e3/Ve,E=null,I=null,v=!1,V=!1,D=Number.NEGATIVE_INFINITY,x=null,U=0,F=null,K=null,te=Promise.all([import("./icao-gate-T3BTOKFJ.js"),import("./icao-tuning-4ETMF53W.js"),import("./create-portrait-capture-5VGYZUOK.js"),import("./landmarker-KB7LVXAU.js"),import("./background-monitor-A7FKJOAG.js")]).then(async([f,k,A,T,H])=>{let R=k.resolveIcaoTuning(e.tuning,e.tuningVersion??void 0);R.background.required&&(I=H.createBackgroundMonitor({tuning:R.backgroundCheck,assetBaseUrl:e.assetBaseUrl??"/models-v3",...t.createSegmenter!==void 0?{createSegmenter:t.createSegmenter}:{},now:n})),w=f.createIcaoGate(R,{policy:e.policy??"reject"}),h??(h=A.defaultGrabber()),y=A.observe,O=1e3/Math.min(Ve,R.cadenceHz);let M=(t.createLandmarker??T.createFaceLandmarker)(e.assetBaseUrl??"/models-v3"),o=await new Promise((s,u)=>{let l=setTimeout(()=>{u(new Error("landmarker init timeout")),M.then(m=>m.close(),()=>{})},T.LANDMARKER_INIT_TIMEOUT_MS);M.then(m=>{clearTimeout(l),s(m)},m=>{clearTimeout(l),u(m)})});S?o.close():E=o}).catch(()=>{v=!0}),Z=f=>{for(let k of p)k({holding:V||v,update:f})},G=()=>{if(x=null,!(S||E===null||w===null||h===null||y===null||g===null)){if(n()-D>Fe){Z(null);return}try{let f=h(g,lt);if(f!==null){let k=Math.max(n(),U+1);U=k;let A=E.detect(f.source,k),T=g.videoWidth||f.width,H=g.videoHeight||f.height,R=y(A,f,T,H);R.geometry!==null&&I!==null&&(R.backgroundCheck=I.measure(f,R.geometry.box,T,H));let M=w.push(R,n());V=M.ready,Z(M)}}catch{}x=i(G,O)}},ne=()=>{let f=n()-D>Fe;D=n(),f&&(w?.reset(),V=!1,F=null,K=null),x===null&&E!==null&&!S&&(x=i(G,0))},W=()=>{let f=h===null||g===null?null:h(g,null);if(f===null||w===null||Math.max(f.width,f.height)<e.still.minLongSidePx)return Promise.resolve(null);let k=w.summary();return a(f,e.still.jpegQuality).then(A=>({image:A,width:f.width,height:f.height,gate:k}),()=>null)},Q=null;return{engineOptions:{measureQuality:(f,k)=>{g=f,ne();let A=d(f,k);return V||v?A:{...A,sharpness:0}},telemetry:f=>{if(f.type!=="fired"||S)return;F=W();let k=Q;k!==null&&F.then(A=>A===null?void 0:k(A).catch(()=>{})),V=!1,x!==null&&r(x),x=null,D=Number.NEGATIVE_INFINITY}},decorate:f=>{let k=new WeakMap,A=new Map,T=o=>{let s=k.get(o);return s===void 0&&(s=(async()=>{let u=await Ie(f,"image","image/jpeg",o.image.size,{engine:"portrait"});return await f.uploadToSpaces(u.uploadUrl,o.image,"image/jpeg"),(await f.completeMedia(u.key)).key})(),s.catch(()=>k.delete(o)),k.set(o,s)),s};Q=T;let H=async o=>{let s;try{s=await T(o)}catch(u){let l=u?.code;if(typeof l=="string"&&pt.has(l))throw u;return null}return{media:{portrait:s},gate:Oe(o.gate),...c!==null?{tuningVersion:c}:{}}},R=f.submitCheck.bind(f),M=(async(o,s,u)=>{if(o!=="liveness")return R(o,s,u);let l=u?.idempotencyKey,m=l===void 0?void 0:A.get(l);if(m===void 0){let b=F;m=b===null?Promise.resolve(null):b.then(ye=>ye===null?null:H(ye)),l!==void 0&&(A.set(l,m),m.catch(()=>A.delete(l)))}let _=await m;if(_===null)return R("liveness",s,u);let P=await R("liveness",{...s,portraitIcao:_},u);return K=_,P});return new Proxy(f,{get(o,s){if(s==="submitCheck")return M;let u=Reflect.get(o,s);return typeof u=="function"?u.bind(o):u}})},onGate:f=>(p.add(f),()=>p.delete(f)),lastPortraitInput:()=>K,destroy:()=>{S=!0,F=null,K=null,x!==null&&r(x),x=null,p.clear(),te.then(()=>{E?.close(),E=null,I?.close(),I=null})}}}function Ge(e){return e.idNumberBound??e.nniBound}function Be(e){return e===void 0?void 0:e.idNumberFromDocument??e.nniFromDocument}function Ue(e){let t=e.idNumberMasked??e.nniMasked;return typeof t=="string"&&t!==""?t:void 0}var Ke=Object.freeze({nni_invalid:"id_number_invalid",nni_not_found:"registry_record_not_found",nni_recheck:"id_number_recheck",document_nni_mismatch:"document_id_number_mismatch",nni_locked:"id_number_locked",nni_unbound:"id_number_unbound",missing_nni:"missing_id_number",registry_needs_nni_source:"registry_needs_id_number_source"}),ht=new Map(Object.entries(Ke)),Kn=new Map(Object.entries(Ke).map(([e,t])=>[t,e]));function je(e){return ht.get(e)??e}var C={fullNameMin:2,fullName:200,email:254,occupation:120,shortText:120,longText:1e3,addressLine:120,addressLines:4,city:80,postcode:16,number:1e12,dateMin:"1900-01-01",dateMax:"2100-12-31"},St=new Set(["full_name","birth_date","email","phone","address","country","occupation"]),gt=new Set(["short_text","long_text","single_choice","multiple_choice","yes_no","date","number"]),yt=new Set(["ar","fa","he","ur"]);function qe(e){return yt.has(e.split("-")[0]?.toLowerCase()??"")?"rtl":"ltr"}function Ye(e){if(typeof e!="object"||e===null)return null;let t=e;if(typeof t.locale!="string"||!Array.isArray(t.questions)||t.questions.length===0)return null;let n=t.consents??[];if(!Array.isArray(n))return null;for(let r of t.questions)if(!_t(r))return null;for(let r of n)if(!bt(r))return null;let i={locale:t.locale,questions:t.questions,consents:n};return typeof t.title=="string"&&t.title.trim()!==""&&(i.title=t.title),typeof t.intro=="string"&&t.intro.trim()!==""&&(i.intro=t.intro),typeof t.prefill=="object"&&t.prefill!==null&&!Array.isArray(t.prefill)&&(i.prefill=t.prefill),i}function _t(e){if(typeof e!="object"||e===null)return!1;let t=e;return typeof t.id!="string"||typeof t.required!="boolean"?!1:t.kind==="field"?typeof t.field=="string"&&St.has(t.field):t.kind!=="custom"||typeof t.type!="string"||!gt.has(t.type)||typeof t.label!="string"?!1:t.type==="single_choice"||t.type==="multiple_choice"?Array.isArray(t.choices)&&t.choices.length>=2&&t.choices.every(n=>typeof n=="object"&&n!==null&&typeof n.value=="string"&&typeof n.label=="string"):!0}function bt(e){if(typeof e!="object"||e===null)return!1;let t=e;if(typeof t.id!="string"||typeof t.required!="boolean"||typeof t.text!="string")return!1;if(t.link===void 0)return!0;let n=t.link;return typeof n=="object"&&n!==null&&typeof n.url=="string"&&/^https:\/\//.test(n.url)&&typeof n.label=="string"}var kt=/^(\d{4})-(\d{2})-(\d{2})$/;function Ct(e){if(typeof e!="string")return!1;let t=kt.exec(e);return t===null?!1:new Date(Date.UTC(Number(t[1]),Number(t[2])-1,Number(t[3]))).toISOString().slice(0,10)===e&&e>=C.dateMin&&e<=C.dateMax}function Pt(e){return typeof e=="number"&&Number.isFinite(e)&&Math.abs(e)<C.number&&Math.round(e*100)/100===e}function Ze(e){for(let t of e.matchAll(/\d[\d -]{11,}\d/g)){let n=t[0].replace(/[ -]/g,"");if(n.length>=13&&n.length<=19&&At(n))return!0}return!1}function At(e){let t=0;for(let n=0;n<e.length;n++){let i=Number(e[e.length-1-n]);n%2===1&&(i*=2,i>9&&(i-=9)),t+=i}return t%10===0}var Rt=/^[^\s@]+@[^\s@.]+(\.[^\s@.]+)+$/,wt=/^\+[1-9]\d{6,14}$/,We=/^[A-Z]{2}$/,xt=e=>e===void 0||typeof e=="string"&&e.trim()===""||Array.isArray(e)&&e.length===0;function Qe(e=Date.now()){return new Date(e).toISOString().slice(0,10)}function X(e,t,n=Qe()){let i=[];for(let r of e.questions){let a=t.answers[r.id];if(xt(a)){r.required&&i.push({id:r.id,code:"required"});continue}let d=r.kind==="field"?Et(r.field,a,n):Mt(r,a,n);d!==null&&i.push({id:r.id,...d})}for(let r of e.consents)r.required&&t.consents[r.id]!==!0&&i.push({id:r.id,code:"consent_required"});return i}function z(e,t,n=1){if(typeof e!="string")return{code:"required"};let i=e.trim();return[...i].length>t?{code:"too_long",params:{max:t}}:[...i].length<n?{code:"too_short",params:{min:n}}:Ze(i)?{code:"card_number"}:null}function $e(e,t,n={}){return Ct(e)?n.period==="past"&&e>=t?{code:"date_not_past"}:n.period==="future"&&e<=t?{code:"date_not_future"}:n.min!==void 0&&e<n.min?{code:"date_too_early",params:{date:n.min}}:n.max!==void 0&&e>n.max?{code:"date_too_late",params:{date:n.max}}:null:{code:"date_invalid"}}function Et(e,t,n){switch(e){case"full_name":return z(t,C.fullName,C.fullNameMin);case"occupation":return z(t,C.occupation);case"birth_date":return $e(t,n,{period:"past"});case"email":return typeof t=="string"&&t.trim().length<=C.email&&Rt.test(t.trim())?null:{code:"email_invalid"};case"phone":return typeof t=="string"&&wt.test(t)?null:{code:"phone_invalid"};case"country":return typeof t=="string"&&We.test(t)?null:{code:"choice_invalid"};case"address":return It(t)?null:{code:"address_invalid"};default:return null}}function It(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=e,n=Array.isArray(t.lines)?t.lines.filter(i=>typeof i=="string"&&i.trim()!==""):[];return typeof t.country=="string"&&We.test(t.country)&&typeof t.city=="string"&&t.city.trim()!==""&&t.city.trim().length<=C.city&&n.length>=1&&n.length<=C.addressLines&&n.every(i=>i.trim().length<=C.addressLine&&!Ze(i))&&(t.postcode===void 0||typeof t.postcode=="string"&&t.postcode.trim().length<=C.postcode)}function Mt(e,t,n){let i=new Set((e.choices??[]).map(r=>r.value));switch(e.type){case"short_text":return z(t,C.shortText);case"long_text":return z(t,C.longText);case"single_choice":return typeof t=="string"&&i.has(t)?null:{code:"choice_invalid"};case"multiple_choice":return Array.isArray(t)&&t.length>0&&new Set(t).size===t.length&&t.every(r=>i.has(r))?null:{code:"choice_invalid"};case"yes_no":return typeof t=="boolean"?null:{code:"choice_invalid"};case"date":{let r=e.options??{};return $e(t,n,{...typeof r.min=="string"?{min:r.min}:{},...typeof r.max=="string"?{max:r.max}:{},...r.period==="past"||r.period==="future"?{period:r.period}:{}})}case"number":{if(typeof t!="number"||!Number.isFinite(t)||Math.abs(t)>=C.number)return{code:"number_invalid"};let r=e.options??{};return r.integer===!0&&!Number.isInteger(t)?{code:"number_not_integer"}:Pt(t)?typeof r.min=="number"&&t<r.min?{code:"number_too_small",params:{min:r.min}}:typeof r.max=="number"&&t>r.max?{code:"number_too_large",params:{max:r.max}}:null:{code:"number_decimals"}}default:return null}}function Je(e,t,n,i=Qe()){let r=e?.errors;return Array.isArray(r)?r.flatMap(a=>{if(typeof a!="object"||a===null)return[];let{id:d,code:c}=a;return typeof d!="string"||typeof c!="string"?[]:[vt(d,c,t,n)]}):X(t,n,i)}var Ot={full_name:C.fullName,occupation:C.occupation,email:C.email,short_text:C.shortText,long_text:C.longText};function vt(e,t,n,i){let r=n.questions.find(p=>p.id===e),a=r===void 0?void 0:r.kind==="field"?r.field:r.type,d=i.answers[e],c=r!==void 0&&r.kind==="custom"?r.options??{}:{};switch(t){case"required":case"card_number":return{id:e,code:t};case"consent_required":return{id:e,code:"consent_required"};case"too_short":return{id:e,code:t,params:{min:a==="full_name"?C.fullNameMin:1}};case"too_long":{let p=a===void 0?void 0:Ot[a];return p===void 0?{id:e,code:t}:{id:e,code:t,params:{max:p}}}case"not_a_choice":return{id:e,code:"choice_invalid"};case"not_in_past":return{id:e,code:"date_not_past"};case"not_in_future":return{id:e,code:"date_not_future"};case"not_an_integer":return{id:e,code:"number_not_integer"};case"out_of_range":return Tt(e,a,d,c);case"invalid":return r===void 0?n.consents.some(p=>p.id===e)?{id:e,code:"consent_required"}:{id:e,code:t}:{id:e,code:Nt(a,d)};default:return{id:e,code:t}}}function Tt(e,t,n,i){if(t==="date"){let c=typeof i.min=="string"?i.min:void 0,p=typeof i.max=="string"?i.max:void 0;return p!==void 0&&(c===void 0||typeof n=="string"&&n>p)?{id:e,code:"date_too_late",params:{date:p}}:c!==void 0?{id:e,code:"date_too_early",params:{date:c}}:{id:e,code:"date_invalid"}}let r=typeof i.min=="number"?i.min:void 0,a=typeof i.max=="number"?i.max:void 0;return a!==void 0&&(r===void 0||typeof n=="number"&&n>a)?{id:e,code:"number_too_large",params:{max:a}}:r!==void 0?{id:e,code:"number_too_small",params:{min:r}}:{id:e,code:"number_invalid"}}function Nt(e,t){switch(e){case"email":return"email_invalid";case"phone":return"phone_invalid";case"birth_date":case"date":return"date_invalid";case"number":return typeof t=="number"&&Number.isFinite(t)&&Math.abs(t)<C.number?"number_decimals":"number_invalid";case"address":return"address_invalid";case"full_name":case"occupation":case"short_text":case"long_text":return"required";default:return"choice_invalid"}}var Lt=new Set(["phone_otp","email_otp","national_eid","document","nfc","population_registry","supplied_identity","summary_confirm","liveness","portrait","face_match","aml_screening","face_dedup","age_estimation","proof_of_address","form"]),Vt=new Set(["supplied_identity","aml_screening","face_dedup","age_estimation"]),ae=["document","population_registry","national_eid"],ue=["phone_otp","email_otp"],et={identity_method:ae,contact:ue},Ft=["population_registry","document"],ce="platform_unsupported",Ht=new Set(["prefilled","user_entered","prefilled_or_entered"]),Dt={phone_otp:"contact",email_otp:"contact",eid_auth:"identity",doc_ocr:"identity",nfc_chip:"identity",population_registry:"identity",liveness:"live_photo",portrait_icao:"live_photo",face_match:"live_photo",poa:"documents",form:"form"};function L(e){return e.section??Dt[e.checkType]??null}function de(e,t){let n=e.plan?.choice;if(n===void 0||n.locked)return;let i=n.options.find(r=>r.id!==n.selected&&r.available!==!1&&t.includes(r.service));return i===void 0?void 0:{nodeId:n.nodeId,option:i}}function le(e){let t=e.plan,n=t?.choice;if(t===void 0||n===void 0||n.locked||t.current===null||t.current===n.nodeId||re(e))return null;let i=et[n.kind]??[...ae,...ue],r=n.options.flatMap(c=>c.available===!1||!i.includes(c.service)?[]:[c.nationalEid!=null?{id:c.id,service:c.service,nationalEid:c.nationalEid}:{id:c.id,service:c.service}]),a=t.steps.find(c=>c.id===t.current)?.service,d=n.selected??r.find(c=>c.service===a)?.id??null;return r.some(c=>c.id!==d)?{nodeId:n.nodeId,kind:n.kind,current:d,options:r}:null}function tt(e){return e==null?[]:e.options.filter(t=>t.id!==e.current)}function Gt(e){let t=e.simulation;if(typeof t!="object"||t===null)return;let{otpCode:n,skipCapture:i}=t;if(typeof n!="string"||n===""||typeof i!="boolean")return;let r=xe(e);return r!==void 0?{otpCode:n,skipCapture:i,reason:r}:{otpCode:n,skipCapture:i}}function Bt(e){let t=e.levelTarget?.max;return typeof t=="number"&&t<=1?"contact":e.purpose??"identity"}function Ut(e){let t=(e.plan?.sections??[]).map(d=>({id:d.id,state:d.state})),n={sessionId:oe(e.sessionId),orgName:e.orgName,sandbox:e.sandbox===!0,returning:e.returning===!0,consentRecorded:e.consentRecorded,expiresAt:e.expiresAt,sections:t.map(d=>d.id),progress:t,purpose:e.purpose??"identity",levelName:Bt(e)};e.branding!==void 0&&(n.branding=e.branding),e.cameraUnavailableHandled===!0&&(n.cameraUnavailableHandled=!0);let i=Gt(e);i!==void 0&&(n.simulation=i);let r=e.testerGate;r?.offered===!0&&typeof r.attemptsLeft=="number"&&r.attemptsLeft>0&&(n.testerGate={attemptsLeft:r.attemptsLeft});let a=le(e);return a!==null&&(n.switchable=a),n}function Kt(e){let t={attemptsRemaining:Pe(e),attemptsExhausted:e.attempts.used>=e.attempts.max};return e.reason!==void 0&&(t.reason=e.reason),e.retakeHint!==void 0&&(t.retakeHint=e.retakeHint),t}var nt={phone_otp:"phone",email_otp:"email"};function jt(e,t){let n=de(e,[t==="phone_otp"?"email_otp":"phone_otp"]);return n===void 0?void 0:nt[n.option.service]}function qt(e,t,n,i){let r=t.checkType==="email_otp",a=(r?t.emailOtp:t.otp)??{},d=r?t.emailOtp?.emailSource:t.otp?.numberSource,c=d!==void 0&&Ht.has(d)?d:r?"prefilled_or_entered":"user_entered",p=typeof a.sentToMasked=="string"&&a.sentToMasked.length>0,S=a.prefilled===!0,g=jt(e,r?"email_otp":"phone_otp"),w={key:t.checkType,context:n,section:L(t),phase:p?"verify":"send",canSwitch:g!==void 0,...i},h=r?{kind:"email_otp",...w,emailSource:c,needsEmail:c!=="prefilled"&&!S}:{kind:"phone_otp",...w,numberSource:c,needsPhone:c!=="prefilled"&&!S,channels:(t.otp?.channels??[]).filter(y=>y==="whatsapp"||y==="sms")};if(g!==void 0&&(h.switchChannel=g),S&&(h.prefilled=!0),p&&(h.sentToMasked=a.sentToMasked),!r&&t.otp?.channel!==void 0&&(h.channel=t.otp.channel),!r&&Array.isArray(t.phoneCountries)&&(h.phoneCountries=t.phoneCountries.filter(y=>typeof y=="string"&&/^[A-Z]{2}$/.test(y))),!r&&Array.isArray(t.phoneRules)){let y=h.phoneCountries??[];h.phoneRules=t.phoneRules.flatMap(O=>{let E=Wt(O);return E!==void 0&&y.includes(E.code)?[E]:[]})}return!r&&t.phoneInternational===!0&&(h.phoneInternational=!0),a.expiresAt!==void 0&&(h.codeExpiresAt=a.expiresAt),a.resendAvailableAt!==void 0&&(h.resendAvailableAt=a.resendAvailableAt),h}var Yt=/^[\d[\]\-|()?:^]{1,64}$/;function Zt(e){try{return typeof e=="string"&&Yt.test(e)&&new RegExp(e)!==null}catch{return!1}}var ze=e=>typeof e=="number"&&Number.isInteger(e)&&e>=1&&e<=15;function Wt(e){let{code:t,dial:n,trunk:i,lengths:r,formats:a}=e??{};if(typeof t!="string"||typeof n!="string"||!/^\d{1,3}$/.test(n)||i!==void 0&&(typeof i!="string"||!/^\d{1,3}$/.test(i))||!Array.isArray(r)||r.length===0||!r.every(ze))return;let d={code:t,dial:n,lengths:[...r].sort((c,p)=>c-p)};if(i!==void 0&&(d.trunk=i),a!==void 0){if(!(Array.isArray(a)&&a.length<=8&&a.every(p=>Zt(p?.leading)&&Array.isArray(p.groups)&&p.groups.every(ze)&&r.includes(p.groups.reduce((S,g)=>S+g,0)))))return;d.formats=a.map(p=>({leading:p.leading,groups:[...p.groups]}))}return d}function Qt(e,t,n,i){let r=Ge(e)===!0?"bound":Be(t)===!0?"document":"typed",a=r==="typed"&&t.state==="input_required"&&t.reason!==void 0&&je(t.reason)==="id_number_recheck",d=tt(le(e)),c=!i.attemptsExhausted&&d.length===1&&d[0]?.service==="document";return{kind:"registry",key:"registry",context:n,section:L(t),state:t.state==="input_required"?"input_required":"pending",source:r,recheck:a,canUseDocument:c,...i}}function $t(e,t,n,i,r){let a=[...t.acceptedSides??[]],d={kind:"document",key:"document",context:n,section:L(t),side:a.includes("recto")?"verso":"recto",acceptedSides:a,documents:Le(e),photo:me(pe(e.documents),r),...i};return e.detectedCountry!==void 0&&(d.detectedCountry=e.detectedCountry),Xt(e)&&(d.ageStepUp=!0),d}function pe(e,t=!0){let n=e?.source==="upload"||e?.source==="choice"?e.source:"camera",i=e?.sourcePick==="camera"||e?.sourcePick==="upload"?e.sourcePick:null;return{source:n,pick:i,uploadOffered:t&&e?.uploadOffered===!0}}function me(e,t){return t?{...e,cameraOnPhone:!0}:e}var Jt=10*1024*1024;function zt(e,t,n,i,r){let a=e.proofOfAddress,d=a?.pdf?.maxBytes,c=a?.phase==="holder_letter"?"holder_letter":"document";return{kind:"proof_of_address",key:"proof_of_address",context:n,section:L(t),phase:c,rule:a?.rule??{country:null,countryFrom:"global",source:"preset_global",kinds:[]},nameMatch:a?.nameMatch??"exact_person",photo:me(pe(a),r),maxPages:3,pdf:{maxBytes:typeof d=="number"&&d>0?d:Jt,maxPages:3},licenceAddressAccepted:c==="document"&&a?.licenceAddressAccepted===!0,...i}}function Xt(e){let t=Ce(e).find(i=>i.checkType==="age_estimation"),n=t?.reason;return t?.state==="failed"&&(n==="age_uncertain"||n==="age_unavailable")}function en(e){let t=$(e,"liveness");return t?.state==="passed"||t?.state==="review"}function Xe(e,t,n,i,r,a=!1){let d=t.icao?.report,c=e.portrait,p=r==="capture"?c?.pendingFix??null:null;p!==null&&(r="review");let S=rt(e);return{kind:"portrait",key:`portrait:${r}`,context:n,section:L(t),phase:r,report:Array.isArray(d)?d:null,review:t.state==="review",tuning:e.capture?.icao??null,tuningVersion:e.capture?.tuningVersion??null,icao:J(e),retakeOnly:r==="capture"&&t.state==="input_required"&&S===void 0&&e.capture?.livePhoto?.oneCapture===!0&&en(e),photo:me(pe(c,r==="capture"),a&&r==="capture"),pendingFix:p,...S!==void 0?{captureMode:S}:{},...c?.reuse?.pending===!0?{reuse:!0}:{},...i}}function rt(e){let t=e.portrait?.captureMode;return t==="self"||t==="assisted"||t==="choice"?t:void 0}var se={minLongSidePx:1280,jpegQuality:.95};function tn(e,t){let n=e.capture?.livePhoto;if(n?.oneCapture!==!0)return null;let i=$(e,"portrait_icao"),r=n.still??se;return{icao:t==="liveness"&&J(e)!==null&&rt(e)===void 0&&i!==void 0&&i.state==="pending"&&i.reason===void 0,still:{minLongSidePx:r.minLongSidePx??se.minLongSidePx,jpegQuality:r.jpegQuality??se.jpegQuality}}}function nn(e,t,n,i){let r=t.eid,a=L(t);if(r===void 0||r.challenge!=="app_code")return{kind:"unsupported",key:"unsupported:eid_auth",context:n,section:a,checkType:"eid_auth",reason:"update_required"};let d=tt(le(e)),c=d.length===1&&Ft.includes(d[0]?.service??"")?d[0]:void 0,p=c===void 0?void 0:q[c.service],S=p!==void 0,g={kind:"eid",key:"eid",context:n,section:a,provider:r.provider,providerName:r.providerName,country:r.country,challenge:"app_code",phase:r.awaiting==="code"?"code":"identifier",identifierBound:r.identifierBound===!0,canUseCamera:S,afterPass:r.afterPass==="continue"?"continue":"end",...i};return S&&(g.cameraMethod=p),r.expiresAt!==void 0&&(g.codeExpiresAt=r.expiresAt),r.resendAvailableAt!==void 0&&(g.resendAvailableAt=r.resendAvailableAt),r.resendsRemaining!==void 0&&(g.resendsRemaining=r.resendsRemaining),r.codeAttemptsRemaining!==void 0&&(g.codeAttemptsRemaining=r.codeAttemptsRemaining),g}function rn(e,t){if(t.checkType!=="face_match"||t.reason!==void 0)return null;let n=$(e,"portrait_icao");return n!==void 0&&(n.state==="passed"||n.state==="review")?n:null}var on={rejected:"rejected",inconclusive:"inconclusive",unavailable:"unavailable",abandoned:"expired",not_opened:"expired",cancelled:"expired",superseded:"expired",policy:"policy"};function sn(e){return e.reasonCode===ce?"platform_unsupported":e.status==="review_pending"?"review":e.status==="verified"?"verified":e.reasonCode==="device_cooldown"?"cooldown":e.reasonCode==="starter_credit_claimed"?"policy":(e.status==="not_verified"&&e.reason!==void 0?on[e.reason]:void 0)??"rejected"}function an(e,t){let n=sn(e),i=n==="platform_unsupported"?{sessionId:oe(e.sessionId),status:"unavailable",reasonCode:ce}:we(e,{autoRetry:!1}),r={kind:"result",key:"result",context:t,section:null,display:n,result:i};return e.status==="not_verified"&&e.reason!==void 0&&(r.reason=e.reason),e.reasonCode!==void 0&&(r.reasonCode=e.reasonCode),e.status==="not_verified"&&e.step!==void 0&&(r.step=e.step),e.retryAfter!==void 0&&(r.retryAfter=e.retryAfter),r}function un(e,t,n){let i=e.identitySummary;if(i==null)return null;let r={kind:"identity_summary",key:"identity_summary",context:t,section:n??"identity",summaryKind:i.kind==="partial"?"partial":i.kind??"full",source:i.source,portraitAvailable:i.portrait?.available===!0,retakeAvailable:i.retakeAvailable===!0};for(let d of cn){let c=i[d];typeof c=="string"&&c!==""&&(r[d]=c)}let a=Ue(i);return a!==void 0&&(r.idNumberMasked=a,r.nniMasked=a),r}var cn=["fullName","birthDate","birthYear","nationality","documentType","documentNumberMasked","expiryDate","retakeTarget"];function B(e,t,n,i){return{kind:"unsupported",key:`unsupported:${n}`,context:e,section:t,checkType:n,reason:i}}function dn(e){return e.kind==="contact"?"contact":(e.kind==="identity_method","identity")}function ln(e,t){let n=et[e.kind]??[...ae,...ue],i=dn(e),r=e.options.flatMap(d=>{if(d.available===!1||!n.includes(d.service))return[];let c={id:d.id,service:d.service};d.nationalEid!=null&&(c.nationalEid=d.nationalEid);let p=(d.channels??[]).filter(S=>S==="whatsapp"||S==="sms");return d.service==="phone_otp"&&p.length>0&&(c.channels=p),[c]});if(r.length===0){let d=e.options.length>0&&e.options.every(c=>c.service==="nfc");return B(t,i,"choice",d?"platform_unsupported":"update_required")}let a={nodeId:e.nodeId,kind:e.kind,selected:e.selected,options:r};if(e.kind==="identity_method"){let d={kind:"method",key:"method",context:t,section:i,options:r.map(p=>q[p.service]),choice:a},c=r.find(p=>p.nationalEid!==void 0)?.nationalEid;return c!==void 0&&(d.nationalEid=c),d}return e.kind==="contact"?{kind:"contact_choice",key:"contact_choice",context:t,section:i,options:r.map(d=>nt[d.service]),selected:null,locked:!1,choice:a}:{kind:"choice",key:`choice:${e.nodeId}`,context:t,section:i,choice:a}}function pn(e,t,n,i){let r=e.nativeApp,a=typeof r=="object"&&r!==null?r:{},d={sekyroApp:a.sekyroApp===!0};return typeof a.link=="string"&&a.link!==""&&(d.link=a.link),d.sekyroApp&&typeof a.sekyroAppLink=="string"&&a.sekyroAppLink.startsWith("sekyro://")&&(d.sekyroAppLink=a.sekyroAppLink),{kind:"native_app_required",key:`native_app_required:${i}`,context:t,section:n,checkType:i,nativeApp:d}}function ee(e,t={}){let n=Ut(e);if(re(e)||e.reasonCode===ce)return an(e,n);let i=e.plan;if(i===void 0||!Array.isArray(i.sections))return B(n,null,"plan","update_required");let r=Ae(e);if(r!==null)return ln(r,n);let a=i.current===null?void 0:i.steps.find(h=>h.id===i.current),d=h=>{let y={kind:"processing",key:"processing",context:n,section:h!==void 0?L(h):i.sections.find(O=>O.state==="current")?.id??null,stalled:!1};return typeof h?.service=="string"&&h.service!==""&&(y.service=h.service),y};if(i.current===null)return d(i.steps.find(h=>h.state==="processing"));if(a===void 0)return B(n,null,"step","update_required");if(!Lt.has(a.service))return a.interaction==="server"?d(a):B(n,L(a),a.service,"update_required");if(Vt.has(a.service)||!Re(a))return d(a);let c=a,p=Kt(c),S=c.checkType,g=L(c);if(c.requiresNativeApp===!0)return pn(e,n,g,S);let w=t.isMobile===!1?Ee(e,c):null;if(w==="phone")return{kind:"mobile_required",key:"mobile_required",context:n,section:g,checkType:S};switch(S){case"phone_otp":case"email_otp":return qt(e,c,n,p);case"population_registry":return Qt(e,c,n,p);case"eid_auth":return nn(e,c,n,p);case"doc_ocr":return $t(e,c,n,p,w==="upload_or_phone");case"identity_confirm":return un(e,n,g)??d(c);case"portrait_icao":return Xe(e,c,n,p,"capture",w==="upload_or_phone");case"liveness":case"face_match":{let h=rn(e,c);if(h!==null)return Xe(e,h,n,p,"match");let y=c.requiresMobile===!0,O=J(e);return{kind:"liveness",key:"biometric",context:n,section:g,mode:S==="face_match"?"selfie":"liveness",requiresMobile:y,instructions:O===null?"standard":"icao",icao:O,livePhoto:tn(e,S),...p}}case"poa":return zt(e,c,n,p,w==="upload_or_phone");case"form":{let h=Ye(c.form);return h===null?B(n,g,S,"update_required"):{kind:"form",key:"form",context:n,section:g,form:h,dir:qe(h.locale),...p}}case"nfc_chip":return B(n,g,S,"platform_unsupported");default:return B(n,g,S,"update_required")}}var mn=/^[A-Z0-9][A-Z0-9 -]{0,39}$/,fn=Object.freeze({normalize:e=>e.trim().toUpperCase().replace(/\s+/g," "),check:e=>mn.test(e),registrySources:Object.freeze([]),describe:"number must be 1 to 40 letters, digits, spaces or hyphens"}),hn=/^[A-Z0-9]{4,20}$/,fe=e=>e.trim().toUpperCase().replace(/[\s-]+/g,""),Sn=Object.freeze({normalize:fe,check:e=>hn.test(fe(e)),registrySources:Object.freeze([]),describe:"number must be 4 to 20 letters or digits"});function gn(e){return typeof e=="string"&&/^\d{10}$/.test(e)&&Number(e)%97===1}var yn={trim:e=>e.trim(),upper_single_space:e=>e.trim().toUpperCase().replace(/\s+/g," "),upper_no_space_or_hyphen:fe},_n={mr_nni_mod97:e=>gn(e)};function bn(e){let t=new RegExp(e.pattern,"u"),n=e.check===null?void 0:_n[e.check];return Object.freeze({normalize:yn[e.normalize],check:i=>t.test(i.trim())&&(n===void 0||n(i)),registrySources:Object.freeze([...e.registrySources]),describe:e.describe})}var kn=Object.freeze(Object.fromEntries(Object.entries(Te).map(([e,t])=>[e,bn(t)])));function he(e,t){return kn[`${e.toUpperCase()}:${t}`]??(t==="drivers_license"?Sn:fn)}var Cn=Object.freeze({MRT:"MR"});function ot(e,t){let n=e.trim().toUpperCase();return he(Cn[n]??n,t)}function it(e){let t=ot(e.issuingCountry,e.type);return t.check(t.normalize(e.number))}function st(e){return he("MR","national_id").check(e)}function Se(e){let t="";for(let n of e){let i=n.codePointAt(0)??0;i>=1632&&i<=1641?t+=String(i-1632):i>=1776&&i<=1785?t+=String(i-1776):n!==" "&&n!=="-"&&n!==" "&&(t+=n)}return t}var Pn=[1e3,2e3,4e3,8e3,15e3],An=3e4,Rn=/^\+[1-9]\d{6,14}$/,wn=/^\d{6}$/,xn=/^\d{6}$/,En=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,at=new Set(["session_not_active","check_not_found","check_already_finalized","check_out_of_order","identity_confirm_required","identity_confirm_locked","choice_locked","choice_option_unavailable","choice_not_found","step_not_on_path","check_not_active","native_app_required"]),In={simulatedCapture:!0},Mn=new Set(["network_error","timeout","upload_failed","unknown_error","rate_limit_exceeded"]);function pr(e){let t=!1,n=null,i="",r=!1,a=!1,d=!1,c={},p={},S=new Set,g=!1,w=!1,h=null,y="idle",O=new Map,E=new Map,I=(o,s,u)=>{let l=`${o}.${s}`,m=O.get(l);if(m!==void 0)return m;let _=E.get(o),P=(_===void 0?u():_.then(u)).finally(()=>{O.delete(l)});O.set(l,P);let b=P.then(()=>{},()=>{});return E.set(o,b),b.then(()=>{E.get(o)===b&&E.delete(o)}),P},v=async(o,s,u)=>{await e.ensureConsent();let l;try{l=await Me(e.runtime,s)}catch(_){if(_ instanceof j&&at.has(_.code)){await e.refreshView();return}throw _}if(u?.(l),e.destroyed())return;let m=l;m.plan!==void 0&&e.setView!==void 0?e.setView(m):await e.refreshView()},V=async o=>{await e.ensureConsent();let s;try{try{s=await o(e.runtime.client)}catch(u){if(!(u instanceof j)||u.code!=="consent_required")throw u;await e.runtime.ensureConsent({force:!0}),s=await o(e.runtime.client)}}catch(u){if(u instanceof j&&at.has(u.code)){await e.refreshView();return}throw u}e.destroyed()||(s!==void 0&&e.setView!==void 0?e.setView(s):await e.refreshView())},D=(o,s)=>I("choice",`${o}:${s}`,()=>V(u=>u.choose(o,s))),x=(o,s)=>o.options.some(u=>u.id===s)?D(o.nodeId,s):Promise.reject(new RangeError(`option ${String(s)} is not offered`)),U=(o,s)=>{let u=e.currentView(),l=u===null?void 0:de(u,o);return l===void 0?Promise.reject(new RangeError(`the ${s} is not offered`)):D(l.nodeId,l.option.id)},F=o=>I("identity",o,()=>V(s=>s.confirmIdentity===void 0?Promise.reject(new Error("identity confirmation is not available in this build")):s.confirmIdentity(o))),K=(o,s)=>{let u=X(o.form,s);if(u.length>0)return Promise.reject(new ie(u,"client"));let l={answers:{...s.answers},consents:{}};for(let m of o.form.consents)l.consents[m.id]=s.consents[m.id]===!0;return I("form","submit",()=>v("form",(m,_)=>m.submitCheck("form",l,{idempotencyKey:_})).catch(m=>{throw m instanceof j&&m.code===ve?new ie(Je(m.details,o.form,l),"server"):m}))},te=(o,s)=>{let u=o.kind,l=u==="phone_otp",m=l?"phone":"email",_={action:"send"};if(l?o.needsPhone:o.needsEmail){let P=s[m]??p[u],b=l?P?.replace(/[\s().-]/g,""):P?.trim();if(b!==void 0||o.phase!=="verify"){if(b===void 0||!(l?Rn:En).test(b))return Promise.reject(l?new N("phone","format"):new Y("email","format"));_[m]=b}}if(l){let P=o.channels,b=s.channel??(P.length===1?P[0]:void 0);if(P.length>0){if(b===void 0)return Promise.reject(new Y("channel","required"));if(!P.includes(b))return Promise.reject(new Y("channel","unavailable"))}b!==void 0&&(_.channel=b),_.phoneRules=1}return I(u,"send",()=>v(u,(P,b)=>P.submitCheck(u,_,{idempotencyKey:b}),P=>{vn(P,u)||(c[u]=e.now(),_[m]!==void 0&&(p[u]=_[m]))}))},Z=(o,s)=>wn.test(s)?I(o,"verify",()=>v(o,(u,l)=>u.submitCheck(o,{action:"verify",code:s},{idempotencyKey:l}))):Promise.reject(new N("code","format")),G=(o,s)=>I("eid_auth",o,()=>v("eid_auth",(u,l)=>u.submitCheck("eid_auth",s,{idempotencyKey:l}))),ne=(o,s)=>{if(o.identifierBound)return G("start",{action:"start"});let u=Se(s??"");if(o.country==="MR"){if(!/^\d{10}$/.test(u))return Promise.reject(new N("nni","format"));if(!st(u))return Promise.reject(new N("nni","check_digit"))}else if(u==="")return Promise.reject(new N("nni","format"));return G("start",{action:"start",identifier:u})},W=(o,s,u)=>{if(o.source!=="typed")return Promise.reject(new RangeError("this session already holds the ID number"));let l=Se(s);return/^\d{10}$/.test(l)?it({type:"national_id",issuingCountry:"MR",number:l})?I("population_registry","submitIdNumber",()=>v("population_registry",(m,_)=>m.submitCheck("population_registry",{idNumber:l,nni:l},{idempotencyKey:_}),()=>{h=`\u2022\u2022\u2022\u2022\u2022\u2022${l.slice(-4)}`})):Promise.reject(new N(u,"check_digit")):Promise.reject(new N(u,"format"))},Q=o=>(e.stopCameras?.(),I(o,"skipCapture",()=>v(o,(s,u)=>s.submitCheck(o,In,{idempotencyKey:u}),()=>{(o==="liveness"||o==="portrait_icao")&&(g=!0)}))),ge=o=>{if(o.kind==="result"||o.context.simulation?.skipCapture!==!0)return o;let s=On(o);return s===null?o:{...o,skipCapture:()=>Q(s)}},f=o=>((o.kind==="document"||o.kind==="portrait"||o.kind==="proof_of_address")&&o.photo?.cameraOnPhone===!0&&(o.refresh=async()=>{await e.refreshView()}),o),k=o=>{switch(o.kind){case"phone_otp":case"email_otp":{let s={...o,send:(l={})=>te(o,l),verify:l=>Z(o.kind,l),switchTo:()=>o.canSwitch&&o.switchChannel!==void 0?U([o.switchChannel==="email"?"email_otp":"phone_otp"],"other contact option"):Promise.reject(new RangeError("this session has no other contact option"))},u=c[o.kind];return s.resendAvailableAt===void 0&&u!==void 0&&(s.resendAvailableAt=new Date(u+An).toISOString()),s}case"eid":return{...o,start:s=>ne(o,s),verify:s=>xn.test(s)?G("verify",{action:"verify",code:s}):Promise.reject(new N("code","format")),resend:()=>o.resendsRemaining===0?Promise.reject(new RangeError("no new code can be sent for this session")):G("resend",{action:"resend"}),useCamera:()=>o.canUseCamera&&o.cameraMethod!==void 0?U(o.cameraMethod==="document_photo"?["document"]:["population_registry"],"camera path"):Promise.reject(new RangeError("the camera path is not offered"))};case"method":return{...o,select:s=>{let u=o.choice.options.find(l=>q[l.service]===s);return u!==void 0?x(o.choice,u.id):Promise.reject(new RangeError(`method ${String(s)} is not offered`))},choose:s=>x(o.choice,s)};case"choice":return{...o,choose:s=>x(o.choice,s)};case"registry":return{...o,submitIdNumber:s=>W(o,s,"idNumber"),submitNni:s=>W(o,s,"nni"),confirm:()=>I("population_registry","confirm",()=>v("population_registry",(s,u)=>s.submitCheck("population_registry",{},{idempotencyKey:u}))),useDocument:()=>o.canUseDocument?U(["document"],"document method"):Promise.reject(new RangeError("the document method is not offered"))};case"document":return e.bindDocument!==void 0?f(e.bindDocument(o,M)):{...o,issuer:null,documentType:null,captureSide:null,selectDocument:()=>{throw new Error("document capture is not available in this build")},capture:()=>{throw new Error("document capture is not available in this build")},uploadDocument:()=>Promise.reject(new Error("document upload is not available in this build"))};case"portrait":return e.bindPortrait!==void 0?f(e.bindPortrait(o,M)):{...o,uploadFailed:!1,resubmit:()=>Promise.resolve(),capture:()=>{throw new Error("portrait capture is not available in this build")},uploadPortrait:()=>Promise.reject(new Error("portrait upload is not available in this build")),confirmFix:()=>Promise.reject(new Error("portrait review is not available in this build"))};case"proof_of_address":return e.bindProofOfAddress!==void 0?f(e.bindProofOfAddress(o,M)):{...o,uploadPages:()=>Promise.reject(new Error("proof of address upload is not available in this build")),uploadHolderLetter:()=>Promise.reject(new Error("proof of address upload is not available in this build")),capturePage:()=>{throw new Error("proof of address capture is not available in this build")}};case"form":return{...o,validate:s=>X(o.form,s),submit:s=>K(o,s)};case"contact_choice":return{...o,select:s=>{let u=s==="phone"?"phone_otp":s==="email"?"email_otp":void 0,l=o.choice.options.find(m=>m.service===u);return l!==void 0?x(o.choice,l.id):Promise.reject(new RangeError(`contact ${String(s)} is not offered`))},choose:s=>x(o.choice,s)};case"identity_summary":return{...o,...o.idNumberMasked===void 0&&o.summaryKind==="partial"&&h!==null?{idNumberMasked:h,nniMasked:h}:{},portrait:async()=>{let s=e.runtime.client;if(!o.portraitAvailable||s.identityPortrait===void 0)return null;try{return await s.identityPortrait()}catch{return null}},confirm:()=>F("confirm"),retake:()=>o.retakeAvailable?F("retake"):Promise.reject(new RangeError("no retake is left"))};case"liveness":return{...o,capture:s=>e.liveness(s),onLivePhoto:s=>o.livePhoto?.icao===!0&&e.onLivePhoto!==void 0?e.onLivePhoto(s):()=>{}};case"mobile_required":case"native_app_required":case"processing":return{...o,refresh:async()=>{r=!1,await e.refreshView()}};case"unsupported":case"result":return{...o};default:{let s=o;throw new Error(`runner: unhandled step ${JSON.stringify(s)}`)}}},A=o=>ge(k(o)),T=async()=>{if(!a){a=!0;try{for(let o of Pn){if(await e.sleep(o),!t||e.destroyed())return;let s=await e.refreshView().catch(()=>null);if(s!==null&&ee(s,{isMobile:e.isMobile()}).kind!=="processing")return}r=!0,M()}finally{a=!1}}},H=o=>{if(o.kind!=="liveness"||o.mode!=="selfie")return null;let s={kind:"processing",key:"processing",context:o.context,section:o.section,stalled:!1};if(y==="inflight")return s;if(!w||y==="done")return null;let u=e.keptFaceKey?.()??null;return u===null?null:(y="inflight",v("face_match",(l,m)=>l.submitCheck("face_match",{imageKey:u},{idempotencyKey:m}),()=>{y="done"}).then(()=>{y==="inflight"&&(y="done",M())},()=>{y="done",M()}),s)},R=(o,s=!1)=>{if(!t||e.destroyed()||e.chainBusy())return;let u=ee(o,{isMobile:e.isMobile()});u.kind==="registry"&&u.recheck&&(w=!0,y="idle"),u=H(u)??u,u.kind==="processing"?u.stalled=r:r=!1;let l=A(u),m=u.kind==="result"?void 0:u.context.switchable,_=m===void 0?l:{...l,chooseOption:b=>x({nodeId:m.nodeId,kind:m.kind,selected:m.current,options:m.options},b)},P=JSON.stringify(_);u.kind==="registry"&&u.source==="document"&&u.state==="pending"&&!S.has("registry")&&(S.add("registry"),_.confirm().catch(b=>{(!(b instanceof j)||Mn.has(b.code))&&S.delete("registry")})),!(!s&&P===i)&&(i=P,n=_,e.emitStep(_),u.kind==="processing"&&!r&&y!=="inflight"&&T(),u.kind==="result"&&!d&&(d=!0,e.emitResult(u.result)))};function M(){let o=e.currentView();o!==null&&R(o,!0)}return{run:async()=>{if(e.destroyed())throw new Error("verification destroyed");t=!0;let o=await e.ensureView();return n===null&&R(o),n??A(ee(o,{isMobile:e.isMobile()}))},current:()=>n,onView:o=>R(o),onChainIdle:()=>{let o=e.currentView();o!==null&&R(o)},republish:M,submit:v,faceProbeSkipped:()=>g}}function On(e){switch(e.kind){case"document":return"doc_ocr";case"liveness":return e.mode==="selfie"?"face_match":"liveness";case"portrait":return e.phase==="capture"?"portrait_icao":null;case"proof_of_address":return"poa";case"mobile_required":case"native_app_required":return e.checkType;case"unsupported":return e.checkType==="nfc_chip"?"nfc_chip":null;default:return null}}function vn(e,t){let n=e,i=n?.plan?.steps??n?.steps;return Array.isArray(i)?i.some(r=>r.checkType===t&&typeof r.reason=="string"):!1}export{dt as a,Ln as b,Ve as c,Fe as d,Gn as e,rt as f,ee as g,Pn as h,An as i,pr as j};
@@ -1,3 +1,3 @@
1
- import{B as ft,C as mt,D as ht,E as yt,a as ot,b as rt,c as it,d as Z,e as J,f as re,g as st,h as K,i as at,j as I,k as j,l as T,m as D,n as U,o as X,p as ut,q as z,r as ie,s as ct,t as dt,u as lt,v as pt}from"./chunk-K7ICBHSZ.js";import{n as et}from"./chunk-NMPMXAH3.js";import{a as ze}from"./chunk-7QZWBDI5.js";import{c as G,e as tt,g as nt,h as se}from"./chunk-VZGTOE22.js";import{c as Je,d as _e}from"./chunk-TSA6GHUG.js";import{b as Xe}from"./chunk-AIRC3HT7.js";function ae(e){return e.idNumberBound??e.nniBound}function ee(e){return e===void 0?void 0:e.idNumberFromDocument??e.nniFromDocument}function gt(e){let t=e.idNumberMasked??e.nniMasked;return typeof t=="string"&&t!==""?t:void 0}var Jt="https://api.sekyro.ai",Xt=5e3,zt=24e4,en=9e4,tn=25*6e4,nn=20*6e4,on=3,rn=3e3,sn=1500,an=10;function St(e){return e instanceof Error&&e.name==="ChallengeError"&&e.code||"challenge_failed"}var _t=new Set(["aborted","embedder_opaque","site_key_rejected"]);function un(e){return new Promise(t=>setTimeout(t,e))}function cn(){let e=globalThis.crypto;if(e!==void 0&&typeof e.randomUUID=="function")return e.randomUUID();let t=new Uint8Array(16);if(e!==void 0&&typeof e.getRandomValues=="function")e.getRandomValues(t);else for(let i=0;i<16;i+=1)t[i]=Math.floor(Math.random()*256);t[6]=(t[6]??0)&15|64,t[8]=(t[8]??0)&63|128;let n=[...t].map(i=>i.toString(16).padStart(2,"0")).join("");return`${n.slice(0,8)}-${n.slice(8,12)}-${n.slice(12,16)}-${n.slice(16,20)}-${n.slice(20)}`}function xo(e){return dn(e,{})}function dn(e,t){let n=e.apiOrigin??Jt,i=e.autoRetry??!0,r=e.rearm??"auto",u=t.client??new nt({apiOrigin:n,sessionToken:e.clientToken,fetch:e.fetch,locale:e.locale}),a=new Proxy(u,{get(o,s){if(s==="submitCheck")return Ut;let c=Reflect.get(o,s,o);return typeof c=="function"?c.bind(o):c}}),d=t.sleep??un,h=t.uuid??cn,_=t.getChallengeToken??((o,s)=>import("./challenge-frame-YBTLAQ5G.js").then(c=>c.executeChallenge({frameUrl:o.url,siteKey:o.siteKey,action:"liveness",subject:s.subject,signal:s.signal}))),S=ze(),P=null,g=null,m=!1,M=new AbortController,y=null,ce=null,te=null,ne=()=>te??ct(y),Re=()=>dt(ie(y),ne()),O=o=>{y=o,!I(o)&&(Be(nn)||Lt(o))&&Se(o),S.emit("view",o),P?.onView(o)},x=()=>y!==null?Promise.resolve(y):(ce??(ce=a.getSession().then(o=>(O(o),o)).finally(()=>{ce=null})),ce),E=async()=>{let o=await a.getSession();return O(o),o},de=async(o,s)=>{o.plan!==void 0?O(o):await E()},le=null,Ie=async o=>{let s=await x();if(o||!s.consentRecorded){let c=await a.recordConsent(e.locale);c.plan!==void 0?O(c):y!==null&&O({...y,consentRecorded:!0})}oe()&&Se(s)},F=o=>o?.force===!0?Ie(!0):(le??(le=Ie(!1).finally(()=>{le=null})),le),pe={client:a,ensureConsent:o=>F(o),sleep:d,uuid:h,...t.random!==void 0?{random:t.random}:{},onBusy:o=>{m||S.emit("busy",o)}},Me=!1,Oe=null,fe=o=>{if(o.status==="verified"||o.status==="not_verified"||o.status==="review"){if(Me)return;Me=!0}Oe=JSON.stringify(o),S.emit("result",o)},Ft=o=>{Oe!==JSON.stringify(o)&&fe(o)},Ee=async o=>{let s=y;o&&(s=await E().catch(()=>y));let c=s===null?null:K(s);return c!==null&&!m&&S.emit("method",c),c!==null},ve=null,Te=!1,Ve=!1,Fe=()=>mt(pe,(o,s)=>o.submitCheck("population_registry",{},{idempotencyKey:s})),Ne=o=>ae(o)===!0||ee(T(o,"population_registry"))===!0,Nt=async()=>{try{let o=await x();if(I(o)||K(o)!==null||j(o)?.checkType!=="population_registry")return;if(!Ne(o)&&ee(T(o,"population_registry"))===void 0&&(o=await E()),!Ne(o)){Ve=!0;return}await F(),await de(await Fe(),"population_registry");let s=y===null?void 0:T(y,"population_registry");if(s?.state==="input_required"&&s.reason==="registry_unavailable"&&re(s)>0){if(await d(Xt),m)return;await de(await Fe(),"population_registry")}}catch(o){if(o instanceof G&&(o.code==="check_not_active"||o.code==="step_not_on_path")){await E().catch(()=>{});return}Te=!0;return}y!==null&&I(y)&&fe(X(y,{autoRetry:i}))},He=()=>(ve??(ve=Nt()),ve),v=t.now??Date.now,q=null,Y,me,Ht=0,he=(o,s)=>`${o.url}
1
+ import{B as ft,C as mt,D as ht,E as yt,a as ot,b as rt,c as it,d as Z,e as J,f as re,g as st,h as K,i as at,j as I,k as j,l as T,m as D,n as U,o as X,p as ut,q as z,r as ie,s as ct,t as dt,u as lt,v as pt}from"./chunk-5QUJHFOH.js";import{n as et}from"./chunk-7GUHA2NM.js";import{a as ze}from"./chunk-7QZWBDI5.js";import{c as G,e as tt,g as nt,h as se}from"./chunk-QPO6LOYB.js";import{c as Je,d as _e}from"./chunk-TSA6GHUG.js";import{b as Xe}from"./chunk-KORZGQLS.js";function ae(e){return e.idNumberBound??e.nniBound}function ee(e){return e===void 0?void 0:e.idNumberFromDocument??e.nniFromDocument}function gt(e){let t=e.idNumberMasked??e.nniMasked;return typeof t=="string"&&t!==""?t:void 0}var Jt="https://api.sekyro.ai",Xt=5e3,zt=24e4,en=9e4,tn=25*6e4,nn=20*6e4,on=3,rn=3e3,sn=1500,an=10;function St(e){return e instanceof Error&&e.name==="ChallengeError"&&e.code||"challenge_failed"}var _t=new Set(["aborted","embedder_opaque","site_key_rejected"]);function un(e){return new Promise(t=>setTimeout(t,e))}function cn(){let e=globalThis.crypto;if(e!==void 0&&typeof e.randomUUID=="function")return e.randomUUID();let t=new Uint8Array(16);if(e!==void 0&&typeof e.getRandomValues=="function")e.getRandomValues(t);else for(let i=0;i<16;i+=1)t[i]=Math.floor(Math.random()*256);t[6]=(t[6]??0)&15|64,t[8]=(t[8]??0)&63|128;let n=[...t].map(i=>i.toString(16).padStart(2,"0")).join("");return`${n.slice(0,8)}-${n.slice(8,12)}-${n.slice(12,16)}-${n.slice(16,20)}-${n.slice(20)}`}function xo(e){return dn(e,{})}function dn(e,t){let n=e.apiOrigin??Jt,i=e.autoRetry??!0,r=e.rearm??"auto",u=t.client??new nt({apiOrigin:n,sessionToken:e.clientToken,fetch:e.fetch,locale:e.locale}),a=new Proxy(u,{get(o,s){if(s==="submitCheck")return Ut;let c=Reflect.get(o,s,o);return typeof c=="function"?c.bind(o):c}}),d=t.sleep??un,h=t.uuid??cn,_=t.getChallengeToken??((o,s)=>import("./challenge-frame-YBTLAQ5G.js").then(c=>c.executeChallenge({frameUrl:o.url,siteKey:o.siteKey,action:"liveness",subject:s.subject,signal:s.signal}))),S=ze(),P=null,g=null,m=!1,M=new AbortController,y=null,ce=null,te=null,ne=()=>te??ct(y),Re=()=>dt(ie(y),ne()),O=o=>{y=o,!I(o)&&(Be(nn)||Lt(o))&&Se(o),S.emit("view",o),P?.onView(o)},x=()=>y!==null?Promise.resolve(y):(ce??(ce=a.getSession().then(o=>(O(o),o)).finally(()=>{ce=null})),ce),E=async()=>{let o=await a.getSession();return O(o),o},de=async(o,s)=>{o.plan!==void 0?O(o):await E()},le=null,Ie=async o=>{let s=await x();if(o||!s.consentRecorded){let c=await a.recordConsent(e.locale);c.plan!==void 0?O(c):y!==null&&O({...y,consentRecorded:!0})}oe()&&Se(s)},F=o=>o?.force===!0?Ie(!0):(le??(le=Ie(!1).finally(()=>{le=null})),le),pe={client:a,ensureConsent:o=>F(o),sleep:d,uuid:h,...t.random!==void 0?{random:t.random}:{},onBusy:o=>{m||S.emit("busy",o)}},Me=!1,Oe=null,fe=o=>{if(o.status==="verified"||o.status==="not_verified"||o.status==="review"){if(Me)return;Me=!0}Oe=JSON.stringify(o),S.emit("result",o)},Ft=o=>{Oe!==JSON.stringify(o)&&fe(o)},Ee=async o=>{let s=y;o&&(s=await E().catch(()=>y));let c=s===null?null:K(s);return c!==null&&!m&&S.emit("method",c),c!==null},ve=null,Te=!1,Ve=!1,Fe=()=>mt(pe,(o,s)=>o.submitCheck("population_registry",{},{idempotencyKey:s})),Ne=o=>ae(o)===!0||ee(T(o,"population_registry"))===!0,Nt=async()=>{try{let o=await x();if(I(o)||K(o)!==null||j(o)?.checkType!=="population_registry")return;if(!Ne(o)&&ee(T(o,"population_registry"))===void 0&&(o=await E()),!Ne(o)){Ve=!0;return}await F(),await de(await Fe(),"population_registry");let s=y===null?void 0:T(y,"population_registry");if(s?.state==="input_required"&&s.reason==="registry_unavailable"&&re(s)>0){if(await d(Xt),m)return;await de(await Fe(),"population_registry")}}catch(o){if(o instanceof G&&(o.code==="check_not_active"||o.code==="step_not_on_path")){await E().catch(()=>{});return}Te=!0;return}y!==null&&I(y)&&fe(X(y,{autoRetry:i}))},He=()=>(ve??(ve=Nt()),ve),v=t.now??Date.now,q=null,Y,me,Ht=0,he=(o,s)=>`${o.url}
2
2
  ${o.siteKey}
3
- ${s}`,Le=0,ye,ge=(o,s)=>{Le+=1;let c=v(),f=_(o,{signal:M.signal,subject:s}),p={key:he(o,s),at:c,token:f};return f.then(()=>{p.issuedAt=v(),me=void 0},k=>{let C=St(k);if(p.failed=C,m||C==="aborted")return;me=C;let{detail:w,readyMs:l}=k;W({check:"attestation",kind:"unavailable",engineKind:C,attempt:Ht++,challengeMs:v()-c,readyMs:l,detail:w,inApp:Xe()})}),f.catch(()=>{}),p},De=(o,s)=>o!==null&&o.key===s&&(o.issuedAt===void 0||v()-o.issuedAt<zt),Se=(o,s={})=>{let c=o?.challenge??null;if(o===null||c===null||m)return;let f=D(o.sessionId),p=q;(s.replaceFailed===!0&&p?.failed!==void 0&&!_t.has(p.failed)||!De(p,he(c,f)))&&(q=ge(c,f))},Ue=async(o,s)=>{let c=he(o,s),f=q;q=null;let p=De(f,c)?f:ge(o,s),k=p===f?0:1,C,w=new Promise(l=>{C=setTimeout(()=>l("late"),en)});try{for(;;){let l=await Promise.race([p.token.then(A=>({token:A}),A=>({error:St(A)})),w]);if(l==="late")return!m&&q===null&&(q=p),{error:me??"timeout"};if("token"in l)return ye=Math.max(0,Math.round((p.issuedAt??v())-p.at)),l;if(m||_t.has(l.error)||k>=on||k>0&&await Promise.race([d(rn*k),w])==="late")return l;if(m)return{error:"aborted"};k+=1,p=ge(o,s)}}finally{clearTimeout(C)}},H=null,Lt=o=>J(o).some(s=>(s.checkType==="phone_otp"||s.checkType==="email_otp")&&s.state!=="passed"&&s.state!=="skipped"),Be=o=>H===null||v()-H>=o,oe=()=>Be(tn),Dt=o=>{let s=o.attestation;return typeof s?.turnstileToken=="string"&&s.turnstileToken.length>0},qe=new Map,Ge=async()=>{let o=await x(),s=o.challenge;if(s==null||o.simulation!==void 0)return;let c=await Ue(s,D(o.sessionId));if(!("token"in c))throw new G({status:400,code:"attestation_invalid",message:`browser check: ${c.error}`});return c.token},Ut=async(o,s,c={})=>{let f=s;if("attestation"in f)try{let l=await u.submitCheck(o,s,c);return Dt(f)&&(H=v()),l}catch(l){throw l instanceof G&&l.code==="attestation_invalid"&&(H=null),l}let p=(o==="phone_otp"||o==="email_otp")&&f.action!=="verify",k=c.idempotencyKey,C=k!==void 0?qe.get(k):void 0;C===void 0&&(p||oe())&&(C=await Ge(),k!==void 0&&C!==void 0&&qe.set(k,C));let w=(l,A)=>l!==void 0?{...A,browserCheckToken:l}:A;try{let l=await u.submitCheck(o,s,w(C,c));return C!==void 0&&(H=v()),l}catch(l){if(!(l instanceof G)||l.code!=="attestation_invalid"||(H=null,C!==void 0))throw l;let A=await Ge(),L=k!==void 0?{...c,idempotencyKey:h()}:c,N=await u.submitCheck(o,s,w(A,L));return A!==void 0&&(H=v()),N}},Ke=async(o={})=>{if(Y=void 0,o.always!==!0&&!oe())return{};let s=await x(),c=s.challenge;if(c==null)return{};let f=await Ue(c,D(s.sessionId));if("token"in f)return{channel:"hosted_web",turnstileToken:f.token};if(Y=f.error,s.simulation!==void 0)return{channel:"hosted_web"};throw new ft(f.error)},Bt=()=>Y,qt=()=>({checks:Math.min(50,Le),...ye!==void 0?{challengeMs:Math.min(6e5,ye)}:{}}),W=o=>{if(m)return;let s=a.reportCaptureIssue;if(s===void 0)return;let c=o.formFactor;try{c??(c=Je())}catch{}try{Promise.resolve(s.call(a,{...o,...c!==void 0?{formFactor:c}:{}})).catch(()=>{})}catch{}},R=null,$=null,je=new WeakMap,Ye=Promise.resolve(),Q=0,Gt=async()=>{let o=await x();for(let s=0;s<an&&!m&&!I(o)&&j(o)===void 0&&J(o).some(c=>c.state==="processing")&&(await d(sn),!m);s+=1)o=await E();return o},Kt=async(o,s,c)=>{let{capture:f}=o,p=()=>m,k=()=>o.alive&&o.attempt===c,C=l=>{k()&&f.setFlowState(l)},w=l=>{if(!p()&&(l.status==="unavailable"&&l.reasonCode!==void 0&&!ot(l.reasonCode)&&W({check:"liveness",kind:"unavailable",phase:"upload",engineKind:l.reasonCode,attempt:Math.max(0,o.issues.value)}),fe(l),!!k())){if(l.status==="retry"&&r==="auto"){f.handle.retry();return}f.setFlowState("done")}};if(s.degraded==="NO_RECORDER"){let l=y?.sessionId??(await x().catch(()=>null))?.sessionId??"";w(U(l,"no_recorder"));return}C("uploading");try{if(await He(),p())return;let l=await x(),A;if(!I(l)&&K(l)!==null){await Ee(!1),w(U(l.sessionId,"method_required"));return}if(!I(l)){if(j(l)?.checkType==="population_registry"){w(U(l.sessionId,Ve?"nni_unbound":Te?"network":"registry_unavailable"));return}if(await F(),p())return;A=y??l;let L=await ht({...pe,artifacts:s,getAttestation:Ke,attestationError:Bt,attestationFacts:qt,clipKeys:{get:()=>je.get(s)??null,set:N=>{je.set(s,N)}},getView:()=>y??l,refreshView:E,applySubmit:de,onPhase:C,isCancelled:p,onKeyframePromoted:N=>{g=N}});if(p())return;if(L.kind==="unavailable"){L.reason==="attestation"&&($={bound:o,artifacts:s});let N=U(l.sessionId,L.reason),Ze=L.reason==="attestation"?Y:void 0;w(Ze!==void 0?{...N,attestationError:Ze}:N);return}if(L.kind==="resync"&&await E(),y!==null&&K(y)!==null){await Ee(!1),w(U(l.sessionId,"method_required"));return}l=await Gt()}w(X(l,{autoRetry:i,previous:A}))}catch{if(p())return;w(U(y?.sessionId??"","network"))}},We=(o,s)=>{let c=o.attempt;Q>0&&o.alive&&o.capture.setFlowState("uploading"),Q+=1,Ye=Ye.then(()=>Kt(o,s,c)).finally(()=>{Q-=1,Q===0&&P?.onChainIdle()}).catch(()=>{})},$e=o=>{R?.capture.handle.destroy(),R!==null&&(R.alive=!1);let s=et(o,P?.captureInternals?.(o)??t.capture,()=>y?.capture?.liveness?.keyframe?.rank===!0,Re,()=>y?.capture?.liveness?.screenRamp,{session:()=>ie(y),onModeChange:p=>{te=p}}),c={capture:s,alive:!0,attempt:0,issues:it()};R=c,s.handle.on("error",p=>{W(rt("liveness",p,c.issues.value))}),s.handle.on("state",p=>{if(c.issues.note(p),p==="starting"){c.attempt+=1,$?.bound===c&&($=null),oe()&&Se(y,{replaceFailed:!0});let k=y===null?void 0:j(y)?.checkType;(k==="liveness"||k==="face_match")&&F().catch(()=>{})}}),s.handle.on("captured",p=>{Promise.resolve().then(()=>We(c,p))});let f=s.handle;return{get state(){return f.state},get captureMode(){return f.captureMode},get facingMode(){return f.facingMode},on:(p,k)=>f.on(p,k),start:async p=>{if(y===null&&await x().catch(()=>{}),!!c.alive)return f.start(p)},retry:()=>{let p=$;if(p!==null&&p.bound===c&&c.alive){$=null,We(c,p.artifacts);return}f.retry()},switchCamera:()=>f.switchCamera(),canSwitchCaptureMode:()=>f.canSwitchCaptureMode(),setCaptureMode:p=>f.setCaptureMode(p),destroy:()=>{c.alive=!1,R===c&&(R=null),f.destroy()}}},jt=async()=>{if(m)return null;try{let o=await x();return m?null:K(o)}catch{return null}},Yt=async()=>{if(m)return"self";try{let o=await x();if(m)return"self";let s=ie(o);return s==="choice"?ne()??s:s}catch{return"self"}},Wt=async()=>{if(m)return!1;try{let o=await x();return m||I(o)||_e()?!1:z(o,j(o))==="phone"||z(o,T(o,"liveness"))==="phone"}catch{return!1}},$t=async()=>{if(m)return!1;try{let o=await x();return!m&&o.returning===!0}catch{return!1}},Qt=async o=>{let s=(await x()).plan?.choice,c=s?.options.find(p=>Z[p.service]===o);if(!c)throw new RangeError(`method ${String(o)} is not offered`);let f=await a.choose(s.nodeId,c.id);m||O(f)},Qe=null,Zt=()=>(Qe??(Qe=import("./plan-runner-BZ7LODPB.js").then(o=>{let s=o.createPlanRunner({runtime:pe,currentView:()=>y,cameraMode:Re,captureModeSwitch:{pick:ne,choose:c=>{te=c}},ensureView:x,refreshView:E,ensureConsent:()=>F(),liveness:$e,stopLiveness:()=>{R!==null&&(R.alive=!1,R.capture.handle.destroy(),R=null)},chainBusy:()=>Q>0,destroyed:()=>m,sleep:d,isMobile:_e,now:t.now??Date.now,keptFaceKey:()=>g,setView:O,baseCapture:t.capture,emitStep:c=>{m||S.emit("step",c)},emitResult:Ft,reportCaptureIssue:W,documentInternals:t.document,documentFacts:t.documentFacts,portraitInternals:t.portrait,livePhotoInternals:t.livePhoto,uploadInternals:t.upload,pageCameraInternals:t.pageCamera});return P=s,s})),Qe);return{consent:()=>F(),startRegistry:He,methodChoice:jt,selectMethod:Qt,reportCameraUnavailable:async o=>{await F();let s=a.reportCameraUnavailable;if(s===void 0)throw new TypeError("this client cannot report a missing camera");let c=await s.call(a,o).catch(f=>{if(f instanceof G&&f.code==="check_out_of_order")return a.getSession();throw f});m||O(c)},reportCaptureIssue:W,testerGate:async o=>{let s=a.testerGate;if(s===void 0)throw new TypeError("this client cannot run the tester gate");let c=o.clip,f=tt(o.clipMime??"");if(c===void 0||!pt.includes(f))throw new TypeError("the capture has no clip");await F();let p=await lt(a,"clip",f,c.size,{engine:o.engine,durationMs:o.clipMs});await a.uploadToSpaces(p.uploadUrl,c,f);let{key:k}=await a.completeMedia(p.key),C=await Ke({always:!0}),w=await s.call(a,{clipKey:k,attestation:C,captureChannel:o.captureChannel,capture:{...yt(o),attestationError:Y}}),{bound:l,...A}=w;return m||(A.plan!==void 0?O(A):await E()),{bound:l===!0}},mobileRequired:Wt,captureMode:Yt,chooseCaptureMode:o=>{te=o},get captureChoice(){return ne()},returning:$t,liveness:$e,run:async()=>{if(m)throw new Error("verification destroyed");return(await Zt()).run()},currentStep:()=>P?.current()??null,voiceClips:async()=>{if(m)return null;try{let o=await x();return m?null:o.voice??null}catch{return null}},on:(o,s)=>S.on(o,s),destroy:()=>{m=!0,M.abort(),P?.destroy(),R!==null&&(R.alive=!1,R.capture.handle.destroy(),R=null),S.clear()}}}var kt=["AD","AE","AF","AG","AI","AL","AM","AO","AQ","AR","AS","AT","AU","AW","AX","AZ","BA","BB","BD","BE","BF","BG","BH","BI","BJ","BL","BM","BN","BO","BQ","BR","BS","BT","BV","BW","BY","BZ","CA","CC","CD","CF","CG","CH","CI","CK","CL","CM","CN","CO","CR","CU","CV","CW","CX","CY","CZ","DE","DJ","DK","DM","DO","DZ","EC","EE","EG","EH","ER","ES","ET","FI","FJ","FK","FM","FO","FR","GA","GB","GD","GE","GF","GG","GH","GI","GL","GM","GN","GP","GQ","GR","GS","GT","GU","GW","GY","HK","HM","HN","HR","HT","HU","ID","IE","IL","IM","IN","IO","IQ","IR","IS","IT","JE","JM","JO","JP","KE","KG","KH","KI","KM","KN","KP","KR","KW","KY","KZ","LA","LB","LC","LI","LK","LR","LS","LT","LU","LV","LY","MA","MC","MD","ME","MF","MG","MH","MK","ML","MM","MN","MO","MP","MQ","MR","MS","MT","MU","MV","MW","MX","MY","MZ","NA","NC","NE","NF","NG","NI","NL","NO","NP","NR","NU","NZ","OM","PA","PE","PF","PG","PH","PK","PL","PM","PN","PR","PS","PT","PW","PY","QA","RE","RO","RS","RU","RW","SA","SB","SC","SD","SE","SG","SH","SI","SJ","SK","SL","SM","SN","SO","SR","SS","ST","SV","SX","SY","SZ","TC","TD","TF","TG","TH","TJ","TK","TL","TM","TN","TO","TR","TT","TV","TW","TZ","UA","UG","UM","US","UY","UZ","VA","VC","VE","VG","VI","VN","VU","WF","WS","XK","YE","YT","ZA","ZM","ZW"];var ln=["carte_identite","passport","residence_permit","drivers_license"],pn=["carte_identite","passport","residence_permit"];function fn(e,t){let n=e.byIssuer?.[t]??e.default;return ln.filter(i=>n==="*"?pn.includes(i):n.includes(i))}function Io(e,t=kt){return[...new Set([...t,...Object.keys(e.byIssuer??{})])].filter(i=>fn(e,i).length>0).sort()}function Ct(e){if(e.acceptedDocuments)return e.acceptedDocuments;let t=e.acceptedDocumentTypes?.length?[...e.acceptedDocumentTypes]:["carte_identite","passport"];return{default:[],byIssuer:{MR:t}}}function Mo(e){return/^[A-Z]{2}$/.test(e)?String.fromCodePoint(...[...e].map(t=>127462+t.charCodeAt(0)-65)):""}var b={fullNameMin:2,fullName:200,email:254,occupation:120,shortText:120,longText:1e3,addressLine:120,addressLines:4,city:80,postcode:16,number:1e12,dateMin:"1900-01-01",dateMax:"2100-12-31"},mn=new Set(["full_name","birth_date","email","phone","address","country","occupation"]),hn=new Set(["short_text","long_text","single_choice","multiple_choice","yes_no","date","number"]),yn=new Set(["ar","fa","he","ur"]);function bt(e){return yn.has(e.split("-")[0]?.toLowerCase()??"")?"rtl":"ltr"}function wt(e){if(typeof e!="object"||e===null)return null;let t=e;if(typeof t.locale!="string"||!Array.isArray(t.questions)||t.questions.length===0)return null;let n=t.consents??[];if(!Array.isArray(n))return null;for(let r of t.questions)if(!gn(r))return null;for(let r of n)if(!Sn(r))return null;let i={locale:t.locale,questions:t.questions,consents:n};return typeof t.title=="string"&&t.title.trim()!==""&&(i.title=t.title),typeof t.intro=="string"&&t.intro.trim()!==""&&(i.intro=t.intro),typeof t.prefill=="object"&&t.prefill!==null&&!Array.isArray(t.prefill)&&(i.prefill=t.prefill),i}function gn(e){if(typeof e!="object"||e===null)return!1;let t=e;return typeof t.id!="string"||typeof t.required!="boolean"?!1:t.kind==="field"?typeof t.field=="string"&&mn.has(t.field):t.kind!=="custom"||typeof t.type!="string"||!hn.has(t.type)||typeof t.label!="string"?!1:t.type==="single_choice"||t.type==="multiple_choice"?Array.isArray(t.choices)&&t.choices.length>=2&&t.choices.every(n=>typeof n=="object"&&n!==null&&typeof n.value=="string"&&typeof n.label=="string"):!0}function Sn(e){if(typeof e!="object"||e===null)return!1;let t=e;if(typeof t.id!="string"||typeof t.required!="boolean"||typeof t.text!="string")return!1;if(t.link===void 0)return!0;let n=t.link;return typeof n=="object"&&n!==null&&typeof n.url=="string"&&/^https:\/\//.test(n.url)&&typeof n.label=="string"}var _n=/^(\d{4})-(\d{2})-(\d{2})$/;function kn(e){if(typeof e!="string")return!1;let t=_n.exec(e);return t===null?!1:new Date(Date.UTC(Number(t[1]),Number(t[2])-1,Number(t[3]))).toISOString().slice(0,10)===e&&e>=b.dateMin&&e<=b.dateMax}function Cn(e){return typeof e=="number"&&Number.isFinite(e)&&Math.abs(e)<b.number&&Math.round(e*100)/100===e}function xt(e){for(let t of e.matchAll(/\d[\d -]{11,}\d/g)){let n=t[0].replace(/[ -]/g,"");if(n.length>=13&&n.length<=19&&bn(n))return!0}return!1}function bn(e){let t=0;for(let n=0;n<e.length;n++){let i=Number(e[e.length-1-n]);n%2===1&&(i*=2,i>9&&(i-=9)),t+=i}return t%10===0}var wn=/^[^\s@]+@[^\s@.]+(\.[^\s@.]+)+$/,xn=/^\+[1-9]\d{6,14}$/,At=/^[A-Z]{2}$/,An=e=>e===void 0||typeof e=="string"&&e.trim()===""||Array.isArray(e)&&e.length===0;function Pn(e=Date.now()){return new Date(e).toISOString().slice(0,10)}function Eo(e,t,n=Pn()){let i=[];for(let r of e.questions){let u=t.answers[r.id];if(An(u)){r.required&&i.push({id:r.id,code:"required"});continue}let a=r.kind==="field"?Rn(r.field,u,n):Mn(r,u,n);a!==null&&i.push({id:r.id,...a})}for(let r of e.consents)r.required&&t.consents[r.id]!==!0&&i.push({id:r.id,code:"consent_required"});return i}function ue(e,t,n=1){if(typeof e!="string")return{code:"required"};let i=e.trim();return[...i].length>t?{code:"too_long",params:{max:t}}:[...i].length<n?{code:"too_short",params:{min:n}}:xt(i)?{code:"card_number"}:null}function Pt(e,t,n={}){return kn(e)?n.period==="past"&&e>=t?{code:"date_not_past"}:n.period==="future"&&e<=t?{code:"date_not_future"}:n.min!==void 0&&e<n.min?{code:"date_too_early",params:{date:n.min}}:n.max!==void 0&&e>n.max?{code:"date_too_late",params:{date:n.max}}:null:{code:"date_invalid"}}function Rn(e,t,n){switch(e){case"full_name":return ue(t,b.fullName,b.fullNameMin);case"occupation":return ue(t,b.occupation);case"birth_date":return Pt(t,n,{period:"past"});case"email":return typeof t=="string"&&t.trim().length<=b.email&&wn.test(t.trim())?null:{code:"email_invalid"};case"phone":return typeof t=="string"&&xn.test(t)?null:{code:"phone_invalid"};case"country":return typeof t=="string"&&At.test(t)?null:{code:"choice_invalid"};case"address":return In(t)?null:{code:"address_invalid"};default:return null}}function In(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=e,n=Array.isArray(t.lines)?t.lines.filter(i=>typeof i=="string"&&i.trim()!==""):[];return typeof t.country=="string"&&At.test(t.country)&&typeof t.city=="string"&&t.city.trim()!==""&&t.city.trim().length<=b.city&&n.length>=1&&n.length<=b.addressLines&&n.every(i=>i.trim().length<=b.addressLine&&!xt(i))&&(t.postcode===void 0||typeof t.postcode=="string"&&t.postcode.trim().length<=b.postcode)}function Mn(e,t,n){let i=new Set((e.choices??[]).map(r=>r.value));switch(e.type){case"short_text":return ue(t,b.shortText);case"long_text":return ue(t,b.longText);case"single_choice":return typeof t=="string"&&i.has(t)?null:{code:"choice_invalid"};case"multiple_choice":return Array.isArray(t)&&t.length>0&&new Set(t).size===t.length&&t.every(r=>i.has(r))?null:{code:"choice_invalid"};case"yes_no":return typeof t=="boolean"?null:{code:"choice_invalid"};case"date":{let r=e.options??{};return Pt(t,n,{...typeof r.min=="string"?{min:r.min}:{},...typeof r.max=="string"?{max:r.max}:{},...r.period==="past"||r.period==="future"?{period:r.period}:{}})}case"number":{if(typeof t!="number"||!Number.isFinite(t)||Math.abs(t)>=b.number)return{code:"number_invalid"};let r=e.options??{};return r.integer===!0&&!Number.isInteger(t)?{code:"number_not_integer"}:Cn(t)?typeof r.min=="number"&&t<r.min?{code:"number_too_small",params:{min:r.min}}:typeof r.max=="number"&&t>r.max?{code:"number_too_large",params:{max:r.max}}:null:{code:"number_decimals"}}default:return null}}var vo={full_name:b.fullName,occupation:b.occupation,email:b.email,short_text:b.shortText,long_text:b.longText};var Rt=Object.freeze({nni_invalid:"id_number_invalid",nni_not_found:"registry_record_not_found",nni_recheck:"id_number_recheck",document_nni_mismatch:"document_id_number_mismatch",nni_locked:"id_number_locked",nni_unbound:"id_number_unbound",missing_nni:"missing_id_number",registry_needs_nni_source:"registry_needs_id_number_source"}),On=new Map(Object.entries(Rt)),Vo=new Map(Object.entries(Rt).map(([e,t])=>[t,e]));function It(e){return On.get(e)??e}var Go=["national_number","document_photo","national_eid"],En=new Set(["phone_otp","email_otp","national_eid","document","nfc","population_registry","supplied_identity","summary_confirm","liveness","portrait","face_match","aml_screening","face_dedup","age_estimation","proof_of_address","form"]),vn=new Set(["supplied_identity","aml_screening","face_dedup","age_estimation"]),Ce=["document","population_registry","national_eid"],be=["phone_otp","email_otp"],Et={identity_method:Ce,contact:be},Tn=["population_registry","document"],we="platform_unsupported",Vn=new Set(["prefilled","user_entered","prefilled_or_entered"]),Fn={phone_otp:"contact",email_otp:"contact",eid_auth:"identity",doc_ocr:"identity",nfc_chip:"identity",population_registry:"identity",liveness:"live_photo",portrait_icao:"live_photo",face_match:"live_photo",poa:"documents",form:"form"};function V(e){return e.section??Fn[e.checkType]??null}function Nn(e,t){let n=e.plan?.choice;if(n===void 0||n.locked)return;let i=n.options.find(r=>r.id!==n.selected&&r.available!==!1&&t.includes(r.service));return i===void 0?void 0:{nodeId:n.nodeId,option:i}}function xe(e){let t=e.plan,n=t?.choice;if(t===void 0||n===void 0||n.locked||t.current===null||t.current===n.nodeId||I(e))return null;let i=Et[n.kind]??[...Ce,...be],r=n.options.flatMap(d=>d.available===!1||!i.includes(d.service)?[]:[d.nationalEid!=null?{id:d.id,service:d.service,nationalEid:d.nationalEid}:{id:d.id,service:d.service}]),u=t.steps.find(d=>d.id===t.current)?.service,a=n.selected??r.find(d=>d.service===u)?.id??null;return r.some(d=>d.id!==a)?{nodeId:n.nodeId,kind:n.kind,current:a,options:r}:null}function vt(e){return e==null?[]:e.options.filter(t=>t.id!==e.current)}function Hn(e){let t=e.simulation;if(typeof t!="object"||t===null)return;let{otpCode:n,skipCapture:i}=t;if(typeof n!="string"||n===""||typeof i!="boolean")return;let r=ut(e);return r!==void 0?{otpCode:n,skipCapture:i,reason:r}:{otpCode:n,skipCapture:i}}function Ln(e){let t=e.levelTarget?.max;return typeof t=="number"&&t<=1?"contact":e.purpose??"identity"}function Dn(e){let t=(e.plan?.sections??[]).map(a=>({id:a.id,state:a.state})),n={sessionId:D(e.sessionId),orgName:e.orgName,sandbox:e.sandbox===!0,returning:e.returning===!0,consentRecorded:e.consentRecorded,expiresAt:e.expiresAt,sections:t.map(a=>a.id),progress:t,purpose:e.purpose??"identity",levelName:Ln(e)};e.branding!==void 0&&(n.branding=e.branding),e.cameraUnavailableHandled===!0&&(n.cameraUnavailableHandled=!0);let i=Hn(e);i!==void 0&&(n.simulation=i);let r=e.testerGate;r?.offered===!0&&typeof r.attemptsLeft=="number"&&r.attemptsLeft>0&&(n.testerGate={attemptsLeft:r.attemptsLeft});let u=xe(e);return u!==null&&(n.switchable=u),n}function Un(e){let t={attemptsRemaining:re(e),attemptsExhausted:e.attempts.used>=e.attempts.max};return e.reason!==void 0&&(t.reason=e.reason),e.retakeHint!==void 0&&(t.retakeHint=e.retakeHint),t}var Tt={phone_otp:"phone",email_otp:"email"};function Bn(e,t){let n=Nn(e,[t==="phone_otp"?"email_otp":"phone_otp"]);return n===void 0?void 0:Tt[n.option.service]}function qn(e,t,n,i){let r=t.checkType==="email_otp",u=(r?t.emailOtp:t.otp)??{},a=r?t.emailOtp?.emailSource:t.otp?.numberSource,d=a!==void 0&&Vn.has(a)?a:r?"prefilled_or_entered":"user_entered",h=typeof u.sentToMasked=="string"&&u.sentToMasked.length>0,_=u.prefilled===!0,S=Bn(e,r?"email_otp":"phone_otp"),P={key:t.checkType,context:n,section:V(t),phase:h?"verify":"send",canSwitch:S!==void 0,...i},g=r?{kind:"email_otp",...P,emailSource:d,needsEmail:d!=="prefilled"&&!_}:{kind:"phone_otp",...P,numberSource:d,needsPhone:d!=="prefilled"&&!_,channels:(t.otp?.channels??[]).filter(m=>m==="whatsapp"||m==="sms")};if(S!==void 0&&(g.switchChannel=S),_&&(g.prefilled=!0),h&&(g.sentToMasked=u.sentToMasked),!r&&t.otp?.channel!==void 0&&(g.channel=t.otp.channel),!r&&Array.isArray(t.phoneCountries)&&(g.phoneCountries=t.phoneCountries.filter(m=>typeof m=="string"&&/^[A-Z]{2}$/.test(m))),!r&&Array.isArray(t.phoneRules)){let m=g.phoneCountries??[];g.phoneRules=t.phoneRules.flatMap(M=>{let y=jn(M);return y!==void 0&&m.includes(y.code)?[y]:[]})}return!r&&t.phoneInternational===!0&&(g.phoneInternational=!0),u.expiresAt!==void 0&&(g.codeExpiresAt=u.expiresAt),u.resendAvailableAt!==void 0&&(g.resendAvailableAt=u.resendAvailableAt),g}var Gn=/^[\d[\]\-|()?:^]{1,64}$/;function Kn(e){try{return typeof e=="string"&&Gn.test(e)&&new RegExp(e)!==null}catch{return!1}}var Mt=e=>typeof e=="number"&&Number.isInteger(e)&&e>=1&&e<=15;function jn(e){let{code:t,dial:n,trunk:i,lengths:r,formats:u}=e??{};if(typeof t!="string"||typeof n!="string"||!/^\d{1,3}$/.test(n)||i!==void 0&&(typeof i!="string"||!/^\d{1,3}$/.test(i))||!Array.isArray(r)||r.length===0||!r.every(Mt))return;let a={code:t,dial:n,lengths:[...r].sort((d,h)=>d-h)};if(i!==void 0&&(a.trunk=i),u!==void 0){if(!(Array.isArray(u)&&u.length<=8&&u.every(h=>Kn(h?.leading)&&Array.isArray(h.groups)&&h.groups.every(Mt)&&r.includes(h.groups.reduce((_,S)=>_+S,0)))))return;a.formats=u.map(h=>({leading:h.leading,groups:[...h.groups]}))}return a}function Yn(e,t,n,i){let r=ae(e)===!0?"bound":ee(t)===!0?"document":"typed",u=r==="typed"&&t.state==="input_required"&&t.reason!==void 0&&It(t.reason)==="id_number_recheck",a=vt(xe(e)),d=!i.attemptsExhausted&&a.length===1&&a[0]?.service==="document";return{kind:"registry",key:"registry",context:n,section:V(t),state:t.state==="input_required"?"input_required":"pending",source:r,recheck:u,canUseDocument:d,...i}}function Wn(e,t,n,i,r){let u=[...t.acceptedSides??[]],a={kind:"document",key:"document",context:n,section:V(t),side:u.includes("recto")?"verso":"recto",acceptedSides:u,documents:Ct(e),photo:Pe(Ae(e.documents),r),...i};return e.detectedCountry!==void 0&&(a.detectedCountry=e.detectedCountry),Zn(e)&&(a.ageStepUp=!0),a}function Ae(e,t=!0){let n=e?.source==="upload"||e?.source==="choice"?e.source:"camera",i=e?.sourcePick==="camera"||e?.sourcePick==="upload"?e.sourcePick:null;return{source:n,pick:i,uploadOffered:t&&e?.uploadOffered===!0}}function Pe(e,t){return t?{...e,cameraOnPhone:!0}:e}var $n=10*1024*1024;function Qn(e,t,n,i,r){let u=e.proofOfAddress,a=u?.pdf?.maxBytes,d=u?.phase==="holder_letter"?"holder_letter":"document";return{kind:"proof_of_address",key:"proof_of_address",context:n,section:V(t),phase:d,rule:u?.rule??{country:null,countryFrom:"global",source:"preset_global",kinds:[]},nameMatch:u?.nameMatch??"exact_person",photo:Pe(Ae(u),r),maxPages:3,pdf:{maxBytes:typeof a=="number"&&a>0?a:$n,maxPages:3},licenceAddressAccepted:d==="document"&&u?.licenceAddressAccepted===!0,...i}}function Zn(e){let t=J(e).find(i=>i.checkType==="age_estimation"),n=t?.reason;return t?.state==="failed"&&(n==="age_uncertain"||n==="age_unavailable")}function Jn(e){let t=T(e,"liveness");return t?.state==="passed"||t?.state==="review"}function Ot(e,t,n,i,r,u=!1){let a=t.icao?.report,d=e.portrait,h=r==="capture"?d?.pendingFix??null:null;h!==null&&(r="review");let _=Vt(e);return{kind:"portrait",key:`portrait:${r}`,context:n,section:V(t),phase:r,report:Array.isArray(a)?a:null,review:t.state==="review",tuning:e.capture?.icao??null,tuningVersion:e.capture?.tuningVersion??null,icao:se(e),retakeOnly:r==="capture"&&t.state==="input_required"&&_===void 0&&e.capture?.livePhoto?.oneCapture===!0&&Jn(e),photo:Pe(Ae(d,r==="capture"),u&&r==="capture"),pendingFix:h,..._!==void 0?{captureMode:_}:{},...d?.reuse?.pending===!0?{reuse:!0}:{},...i}}function Vt(e){let t=e.portrait?.captureMode;return t==="self"||t==="assisted"||t==="choice"?t:void 0}var ke={minLongSidePx:1280,jpegQuality:.95};function Xn(e,t){let n=e.capture?.livePhoto;if(n?.oneCapture!==!0)return null;let i=T(e,"portrait_icao"),r=n.still??ke;return{icao:t==="liveness"&&se(e)!==null&&Vt(e)===void 0&&i!==void 0&&i.state==="pending"&&i.reason===void 0,still:{minLongSidePx:r.minLongSidePx??ke.minLongSidePx,jpegQuality:r.jpegQuality??ke.jpegQuality}}}function zn(e,t,n,i){let r=t.eid,u=V(t);if(r===void 0||r.challenge!=="app_code")return{kind:"unsupported",key:"unsupported:eid_auth",context:n,section:u,checkType:"eid_auth",reason:"update_required"};let a=vt(xe(e)),d=a.length===1&&Tn.includes(a[0]?.service??"")?a[0]:void 0,h=d===void 0?void 0:Z[d.service],_=h!==void 0,S={kind:"eid",key:"eid",context:n,section:u,provider:r.provider,providerName:r.providerName,country:r.country,challenge:"app_code",phase:r.awaiting==="code"?"code":"identifier",identifierBound:r.identifierBound===!0,canUseCamera:_,afterPass:r.afterPass==="continue"?"continue":"end",...i};return _&&(S.cameraMethod=h),r.expiresAt!==void 0&&(S.codeExpiresAt=r.expiresAt),r.resendAvailableAt!==void 0&&(S.resendAvailableAt=r.resendAvailableAt),r.resendsRemaining!==void 0&&(S.resendsRemaining=r.resendsRemaining),r.codeAttemptsRemaining!==void 0&&(S.codeAttemptsRemaining=r.codeAttemptsRemaining),S}function eo(e,t){if(t.checkType!=="face_match"||t.reason!==void 0)return null;let n=T(e,"portrait_icao");return n!==void 0&&(n.state==="passed"||n.state==="review")?n:null}var to={rejected:"rejected",inconclusive:"inconclusive",unavailable:"unavailable",abandoned:"expired",not_opened:"expired",cancelled:"expired",superseded:"expired",policy:"policy"};function no(e){return e.reasonCode===we?"platform_unsupported":e.status==="review_pending"?"review":e.status==="verified"?"verified":e.reasonCode==="device_cooldown"?"cooldown":e.reasonCode==="starter_credit_claimed"?"policy":(e.status==="not_verified"&&e.reason!==void 0?to[e.reason]:void 0)??"rejected"}function oo(e,t){let n=no(e),i=n==="platform_unsupported"?{sessionId:D(e.sessionId),status:"unavailable",reasonCode:we}:X(e,{autoRetry:!1}),r={kind:"result",key:"result",context:t,section:null,display:n,result:i};return e.status==="not_verified"&&e.reason!==void 0&&(r.reason=e.reason),e.reasonCode!==void 0&&(r.reasonCode=e.reasonCode),e.status==="not_verified"&&e.step!==void 0&&(r.step=e.step),e.retryAfter!==void 0&&(r.retryAfter=e.retryAfter),r}function ro(e,t,n){let i=e.identitySummary;if(i==null)return null;let r={kind:"identity_summary",key:"identity_summary",context:t,section:n??"identity",summaryKind:i.kind==="partial"?"partial":i.kind??"full",source:i.source,portraitAvailable:i.portrait?.available===!0,retakeAvailable:i.retakeAvailable===!0};for(let a of io){let d=i[a];typeof d=="string"&&d!==""&&(r[a]=d)}let u=gt(i);return u!==void 0&&(r.idNumberMasked=u,r.nniMasked=u),r}var io=["fullName","birthDate","birthYear","nationality","documentType","documentNumberMasked","expiryDate","retakeTarget"];function B(e,t,n,i){return{kind:"unsupported",key:`unsupported:${n}`,context:e,section:t,checkType:n,reason:i}}function so(e){return e.kind==="contact"?"contact":(e.kind==="identity_method","identity")}function ao(e,t){let n=Et[e.kind]??[...Ce,...be],i=so(e),r=e.options.flatMap(a=>{if(a.available===!1||!n.includes(a.service))return[];let d={id:a.id,service:a.service};a.nationalEid!=null&&(d.nationalEid=a.nationalEid);let h=(a.channels??[]).filter(_=>_==="whatsapp"||_==="sms");return a.service==="phone_otp"&&h.length>0&&(d.channels=h),[d]});if(r.length===0){let a=e.options.length>0&&e.options.every(d=>d.service==="nfc");return B(t,i,"choice",a?"platform_unsupported":"update_required")}let u={nodeId:e.nodeId,kind:e.kind,selected:e.selected,options:r};if(e.kind==="identity_method"){let a={kind:"method",key:"method",context:t,section:i,options:r.map(h=>Z[h.service]),choice:u},d=r.find(h=>h.nationalEid!==void 0)?.nationalEid;return d!==void 0&&(a.nationalEid=d),a}return e.kind==="contact"?{kind:"contact_choice",key:"contact_choice",context:t,section:i,options:r.map(a=>Tt[a.service]),selected:null,locked:!1,choice:u}:{kind:"choice",key:`choice:${e.nodeId}`,context:t,section:i,choice:u}}function uo(e,t,n,i){let r=e.nativeApp,u=typeof r=="object"&&r!==null?r:{},a={sekyroApp:u.sekyroApp===!0};return typeof u.link=="string"&&u.link!==""&&(a.link=u.link),a.sekyroApp&&typeof u.sekyroAppLink=="string"&&u.sekyroAppLink.startsWith("sekyro://")&&(a.sekyroAppLink=u.sekyroAppLink),{kind:"native_app_required",key:`native_app_required:${i}`,context:t,section:n,checkType:i,nativeApp:a}}function Ko(e,t={}){let n=Dn(e);if(I(e)||e.reasonCode===we)return oo(e,n);let i=e.plan;if(i===void 0||!Array.isArray(i.sections))return B(n,null,"plan","update_required");let r=st(e);if(r!==null)return ao(r,n);let u=i.current===null?void 0:i.steps.find(g=>g.id===i.current),a=g=>{let m={kind:"processing",key:"processing",context:n,section:g!==void 0?V(g):i.sections.find(M=>M.state==="current")?.id??null,stalled:!1};return typeof g?.service=="string"&&g.service!==""&&(m.service=g.service),m};if(i.current===null)return a(i.steps.find(g=>g.state==="processing"));if(u===void 0)return B(n,null,"step","update_required");if(!En.has(u.service))return u.interaction==="server"?a(u):B(n,V(u),u.service,"update_required");if(vn.has(u.service)||!at(u))return a(u);let d=u,h=Un(d),_=d.checkType,S=V(d);if(d.requiresNativeApp===!0)return uo(e,n,S,_);let P=t.isMobile===!1?z(e,d):null;if(P==="phone")return{kind:"mobile_required",key:"mobile_required",context:n,section:S,checkType:_};switch(_){case"phone_otp":case"email_otp":return qn(e,d,n,h);case"population_registry":return Yn(e,d,n,h);case"eid_auth":return zn(e,d,n,h);case"doc_ocr":return Wn(e,d,n,h,P==="upload_or_phone");case"identity_confirm":return ro(e,n,S)??a(d);case"portrait_icao":return Ot(e,d,n,h,"capture",P==="upload_or_phone");case"liveness":case"face_match":{let g=eo(e,d);if(g!==null)return Ot(e,g,n,h,"match");let m=d.requiresMobile===!0,M=se(e);return{kind:"liveness",key:"biometric",context:n,section:S,mode:_==="face_match"?"selfie":"liveness",requiresMobile:m,instructions:M===null?"standard":"icao",icao:M,livePhoto:Xn(e,_),...h}}case"poa":return Qn(e,d,n,h,P==="upload_or_phone");case"form":{let g=wt(d.form);return g===null?B(n,S,_,"update_required"):{kind:"form",key:"form",context:n,section:S,form:g,dir:bt(g.locale),...h}}case"nfc_chip":return B(n,S,_,"platform_unsupported");default:return B(n,S,_,"update_required")}}export{Jt as a,Xt as b,sn as c,an as d,cn as e,xo as f,dn as g,kt as h,ln as i,fn as j,Io as k,Ct as l,Mo as m,b as n,bt as o,kn as p,Cn as q,xt as r,Pn as s,Eo as t,Go as u,we as v,V as w,xe as x,vt as y,eo as z,Ko as A};
3
+ ${s}`,Le=0,ye,ge=(o,s)=>{Le+=1;let c=v(),f=_(o,{signal:M.signal,subject:s}),p={key:he(o,s),at:c,token:f};return f.then(()=>{p.issuedAt=v(),me=void 0},k=>{let C=St(k);if(p.failed=C,m||C==="aborted")return;me=C;let{detail:w,readyMs:l}=k;W({check:"attestation",kind:"unavailable",engineKind:C,attempt:Ht++,challengeMs:v()-c,readyMs:l,detail:w,inApp:Xe()})}),f.catch(()=>{}),p},De=(o,s)=>o!==null&&o.key===s&&(o.issuedAt===void 0||v()-o.issuedAt<zt),Se=(o,s={})=>{let c=o?.challenge??null;if(o===null||c===null||m)return;let f=D(o.sessionId),p=q;(s.replaceFailed===!0&&p?.failed!==void 0&&!_t.has(p.failed)||!De(p,he(c,f)))&&(q=ge(c,f))},Ue=async(o,s)=>{let c=he(o,s),f=q;q=null;let p=De(f,c)?f:ge(o,s),k=p===f?0:1,C,w=new Promise(l=>{C=setTimeout(()=>l("late"),en)});try{for(;;){let l=await Promise.race([p.token.then(A=>({token:A}),A=>({error:St(A)})),w]);if(l==="late")return!m&&q===null&&(q=p),{error:me??"timeout"};if("token"in l)return ye=Math.max(0,Math.round((p.issuedAt??v())-p.at)),l;if(m||_t.has(l.error)||k>=on||k>0&&await Promise.race([d(rn*k),w])==="late")return l;if(m)return{error:"aborted"};k+=1,p=ge(o,s)}}finally{clearTimeout(C)}},H=null,Lt=o=>J(o).some(s=>(s.checkType==="phone_otp"||s.checkType==="email_otp")&&s.state!=="passed"&&s.state!=="skipped"),Be=o=>H===null||v()-H>=o,oe=()=>Be(tn),Dt=o=>{let s=o.attestation;return typeof s?.turnstileToken=="string"&&s.turnstileToken.length>0},qe=new Map,Ge=async()=>{let o=await x(),s=o.challenge;if(s==null||o.simulation!==void 0)return;let c=await Ue(s,D(o.sessionId));if(!("token"in c))throw new G({status:400,code:"attestation_invalid",message:`browser check: ${c.error}`});return c.token},Ut=async(o,s,c={})=>{let f=s;if("attestation"in f)try{let l=await u.submitCheck(o,s,c);return Dt(f)&&(H=v()),l}catch(l){throw l instanceof G&&l.code==="attestation_invalid"&&(H=null),l}let p=(o==="phone_otp"||o==="email_otp")&&f.action!=="verify",k=c.idempotencyKey,C=k!==void 0?qe.get(k):void 0;C===void 0&&(p||oe())&&(C=await Ge(),k!==void 0&&C!==void 0&&qe.set(k,C));let w=(l,A)=>l!==void 0?{...A,browserCheckToken:l}:A;try{let l=await u.submitCheck(o,s,w(C,c));return C!==void 0&&(H=v()),l}catch(l){if(!(l instanceof G)||l.code!=="attestation_invalid"||(H=null,C!==void 0))throw l;let A=await Ge(),L=k!==void 0?{...c,idempotencyKey:h()}:c,N=await u.submitCheck(o,s,w(A,L));return A!==void 0&&(H=v()),N}},Ke=async(o={})=>{if(Y=void 0,o.always!==!0&&!oe())return{};let s=await x(),c=s.challenge;if(c==null)return{};let f=await Ue(c,D(s.sessionId));if("token"in f)return{channel:"hosted_web",turnstileToken:f.token};if(Y=f.error,s.simulation!==void 0)return{channel:"hosted_web"};throw new ft(f.error)},Bt=()=>Y,qt=()=>({checks:Math.min(50,Le),...ye!==void 0?{challengeMs:Math.min(6e5,ye)}:{}}),W=o=>{if(m)return;let s=a.reportCaptureIssue;if(s===void 0)return;let c=o.formFactor;try{c??(c=Je())}catch{}try{Promise.resolve(s.call(a,{...o,...c!==void 0?{formFactor:c}:{}})).catch(()=>{})}catch{}},R=null,$=null,je=new WeakMap,Ye=Promise.resolve(),Q=0,Gt=async()=>{let o=await x();for(let s=0;s<an&&!m&&!I(o)&&j(o)===void 0&&J(o).some(c=>c.state==="processing")&&(await d(sn),!m);s+=1)o=await E();return o},Kt=async(o,s,c)=>{let{capture:f}=o,p=()=>m,k=()=>o.alive&&o.attempt===c,C=l=>{k()&&f.setFlowState(l)},w=l=>{if(!p()&&(l.status==="unavailable"&&l.reasonCode!==void 0&&!ot(l.reasonCode)&&W({check:"liveness",kind:"unavailable",phase:"upload",engineKind:l.reasonCode,attempt:Math.max(0,o.issues.value)}),fe(l),!!k())){if(l.status==="retry"&&r==="auto"){f.handle.retry();return}f.setFlowState("done")}};if(s.degraded==="NO_RECORDER"){let l=y?.sessionId??(await x().catch(()=>null))?.sessionId??"";w(U(l,"no_recorder"));return}C("uploading");try{if(await He(),p())return;let l=await x(),A;if(!I(l)&&K(l)!==null){await Ee(!1),w(U(l.sessionId,"method_required"));return}if(!I(l)){if(j(l)?.checkType==="population_registry"){w(U(l.sessionId,Ve?"nni_unbound":Te?"network":"registry_unavailable"));return}if(await F(),p())return;A=y??l;let L=await ht({...pe,artifacts:s,getAttestation:Ke,attestationError:Bt,attestationFacts:qt,clipKeys:{get:()=>je.get(s)??null,set:N=>{je.set(s,N)}},getView:()=>y??l,refreshView:E,applySubmit:de,onPhase:C,isCancelled:p,onKeyframePromoted:N=>{g=N}});if(p())return;if(L.kind==="unavailable"){L.reason==="attestation"&&($={bound:o,artifacts:s});let N=U(l.sessionId,L.reason),Ze=L.reason==="attestation"?Y:void 0;w(Ze!==void 0?{...N,attestationError:Ze}:N);return}if(L.kind==="resync"&&await E(),y!==null&&K(y)!==null){await Ee(!1),w(U(l.sessionId,"method_required"));return}l=await Gt()}w(X(l,{autoRetry:i,previous:A}))}catch{if(p())return;w(U(y?.sessionId??"","network"))}},We=(o,s)=>{let c=o.attempt;Q>0&&o.alive&&o.capture.setFlowState("uploading"),Q+=1,Ye=Ye.then(()=>Kt(o,s,c)).finally(()=>{Q-=1,Q===0&&P?.onChainIdle()}).catch(()=>{})},$e=o=>{R?.capture.handle.destroy(),R!==null&&(R.alive=!1);let s=et(o,P?.captureInternals?.(o)??t.capture,()=>y?.capture?.liveness?.keyframe?.rank===!0,Re,()=>y?.capture?.liveness?.screenRamp,{session:()=>ie(y),onModeChange:p=>{te=p}}),c={capture:s,alive:!0,attempt:0,issues:it()};R=c,s.handle.on("error",p=>{W(rt("liveness",p,c.issues.value))}),s.handle.on("state",p=>{if(c.issues.note(p),p==="starting"){c.attempt+=1,$?.bound===c&&($=null),oe()&&Se(y,{replaceFailed:!0});let k=y===null?void 0:j(y)?.checkType;(k==="liveness"||k==="face_match")&&F().catch(()=>{})}}),s.handle.on("captured",p=>{Promise.resolve().then(()=>We(c,p))});let f=s.handle;return{get state(){return f.state},get captureMode(){return f.captureMode},get facingMode(){return f.facingMode},on:(p,k)=>f.on(p,k),start:async p=>{if(y===null&&await x().catch(()=>{}),!!c.alive)return f.start(p)},retry:()=>{let p=$;if(p!==null&&p.bound===c&&c.alive){$=null,We(c,p.artifacts);return}f.retry()},switchCamera:()=>f.switchCamera(),canSwitchCaptureMode:()=>f.canSwitchCaptureMode(),setCaptureMode:p=>f.setCaptureMode(p),destroy:()=>{c.alive=!1,R===c&&(R=null),f.destroy()}}},jt=async()=>{if(m)return null;try{let o=await x();return m?null:K(o)}catch{return null}},Yt=async()=>{if(m)return"self";try{let o=await x();if(m)return"self";let s=ie(o);return s==="choice"?ne()??s:s}catch{return"self"}},Wt=async()=>{if(m)return!1;try{let o=await x();return m||I(o)||_e()?!1:z(o,j(o))==="phone"||z(o,T(o,"liveness"))==="phone"}catch{return!1}},$t=async()=>{if(m)return!1;try{let o=await x();return!m&&o.returning===!0}catch{return!1}},Qt=async o=>{let s=(await x()).plan?.choice,c=s?.options.find(p=>Z[p.service]===o);if(!c)throw new RangeError(`method ${String(o)} is not offered`);let f=await a.choose(s.nodeId,c.id);m||O(f)},Qe=null,Zt=()=>(Qe??(Qe=import("./plan-runner-7XZH4SBZ.js").then(o=>{let s=o.createPlanRunner({runtime:pe,currentView:()=>y,cameraMode:Re,captureModeSwitch:{pick:ne,choose:c=>{te=c}},ensureView:x,refreshView:E,ensureConsent:()=>F(),liveness:$e,stopLiveness:()=>{R!==null&&(R.alive=!1,R.capture.handle.destroy(),R=null)},chainBusy:()=>Q>0,destroyed:()=>m,sleep:d,isMobile:_e,now:t.now??Date.now,keptFaceKey:()=>g,setView:O,baseCapture:t.capture,emitStep:c=>{m||S.emit("step",c)},emitResult:Ft,reportCaptureIssue:W,documentInternals:t.document,documentFacts:t.documentFacts,portraitInternals:t.portrait,livePhotoInternals:t.livePhoto,uploadInternals:t.upload,pageCameraInternals:t.pageCamera});return P=s,s})),Qe);return{consent:()=>F(),startRegistry:He,methodChoice:jt,selectMethod:Qt,reportCameraUnavailable:async o=>{await F();let s=a.reportCameraUnavailable;if(s===void 0)throw new TypeError("this client cannot report a missing camera");let c=await s.call(a,o).catch(f=>{if(f instanceof G&&f.code==="check_out_of_order")return a.getSession();throw f});m||O(c)},reportCaptureIssue:W,testerGate:async o=>{let s=a.testerGate;if(s===void 0)throw new TypeError("this client cannot run the tester gate");let c=o.clip,f=tt(o.clipMime??"");if(c===void 0||!pt.includes(f))throw new TypeError("the capture has no clip");await F();let p=await lt(a,"clip",f,c.size,{engine:o.engine,durationMs:o.clipMs});await a.uploadToSpaces(p.uploadUrl,c,f);let{key:k}=await a.completeMedia(p.key),C=await Ke({always:!0}),w=await s.call(a,{clipKey:k,attestation:C,captureChannel:o.captureChannel,capture:{...yt(o),attestationError:Y}}),{bound:l,...A}=w;return m||(A.plan!==void 0?O(A):await E()),{bound:l===!0}},mobileRequired:Wt,captureMode:Yt,chooseCaptureMode:o=>{te=o},get captureChoice(){return ne()},returning:$t,liveness:$e,run:async()=>{if(m)throw new Error("verification destroyed");return(await Zt()).run()},currentStep:()=>P?.current()??null,voiceClips:async()=>{if(m)return null;try{let o=await x();return m?null:o.voice??null}catch{return null}},on:(o,s)=>S.on(o,s),destroy:()=>{m=!0,M.abort(),P?.destroy(),R!==null&&(R.alive=!1,R.capture.handle.destroy(),R=null),S.clear()}}}var kt=["AD","AE","AF","AG","AI","AL","AM","AO","AQ","AR","AS","AT","AU","AW","AX","AZ","BA","BB","BD","BE","BF","BG","BH","BI","BJ","BL","BM","BN","BO","BQ","BR","BS","BT","BV","BW","BY","BZ","CA","CC","CD","CF","CG","CH","CI","CK","CL","CM","CN","CO","CR","CU","CV","CW","CX","CY","CZ","DE","DJ","DK","DM","DO","DZ","EC","EE","EG","EH","ER","ES","ET","FI","FJ","FK","FM","FO","FR","GA","GB","GD","GE","GF","GG","GH","GI","GL","GM","GN","GP","GQ","GR","GS","GT","GU","GW","GY","HK","HM","HN","HR","HT","HU","ID","IE","IL","IM","IN","IO","IQ","IR","IS","IT","JE","JM","JO","JP","KE","KG","KH","KI","KM","KN","KP","KR","KW","KY","KZ","LA","LB","LC","LI","LK","LR","LS","LT","LU","LV","LY","MA","MC","MD","ME","MF","MG","MH","MK","ML","MM","MN","MO","MP","MQ","MR","MS","MT","MU","MV","MW","MX","MY","MZ","NA","NC","NE","NF","NG","NI","NL","NO","NP","NR","NU","NZ","OM","PA","PE","PF","PG","PH","PK","PL","PM","PN","PR","PS","PT","PW","PY","QA","RE","RO","RS","RU","RW","SA","SB","SC","SD","SE","SG","SH","SI","SJ","SK","SL","SM","SN","SO","SR","SS","ST","SV","SX","SY","SZ","TC","TD","TF","TG","TH","TJ","TK","TL","TM","TN","TO","TR","TT","TV","TW","TZ","UA","UG","UM","US","UY","UZ","VA","VC","VE","VG","VI","VN","VU","WF","WS","XK","YE","YT","ZA","ZM","ZW"];var ln=["carte_identite","passport","residence_permit","drivers_license"],pn=["carte_identite","passport","residence_permit"];function fn(e,t){let n=e.byIssuer?.[t]??e.default;return ln.filter(i=>n==="*"?pn.includes(i):n.includes(i))}function Io(e,t=kt){return[...new Set([...t,...Object.keys(e.byIssuer??{})])].filter(i=>fn(e,i).length>0).sort()}function Ct(e){if(e.acceptedDocuments)return e.acceptedDocuments;let t=e.acceptedDocumentTypes?.length?[...e.acceptedDocumentTypes]:["carte_identite","passport"];return{default:[],byIssuer:{MR:t}}}function Mo(e){return/^[A-Z]{2}$/.test(e)?String.fromCodePoint(...[...e].map(t=>127462+t.charCodeAt(0)-65)):""}var b={fullNameMin:2,fullName:200,email:254,occupation:120,shortText:120,longText:1e3,addressLine:120,addressLines:4,city:80,postcode:16,number:1e12,dateMin:"1900-01-01",dateMax:"2100-12-31"},mn=new Set(["full_name","birth_date","email","phone","address","country","occupation"]),hn=new Set(["short_text","long_text","single_choice","multiple_choice","yes_no","date","number"]),yn=new Set(["ar","fa","he","ur"]);function bt(e){return yn.has(e.split("-")[0]?.toLowerCase()??"")?"rtl":"ltr"}function wt(e){if(typeof e!="object"||e===null)return null;let t=e;if(typeof t.locale!="string"||!Array.isArray(t.questions)||t.questions.length===0)return null;let n=t.consents??[];if(!Array.isArray(n))return null;for(let r of t.questions)if(!gn(r))return null;for(let r of n)if(!Sn(r))return null;let i={locale:t.locale,questions:t.questions,consents:n};return typeof t.title=="string"&&t.title.trim()!==""&&(i.title=t.title),typeof t.intro=="string"&&t.intro.trim()!==""&&(i.intro=t.intro),typeof t.prefill=="object"&&t.prefill!==null&&!Array.isArray(t.prefill)&&(i.prefill=t.prefill),i}function gn(e){if(typeof e!="object"||e===null)return!1;let t=e;return typeof t.id!="string"||typeof t.required!="boolean"?!1:t.kind==="field"?typeof t.field=="string"&&mn.has(t.field):t.kind!=="custom"||typeof t.type!="string"||!hn.has(t.type)||typeof t.label!="string"?!1:t.type==="single_choice"||t.type==="multiple_choice"?Array.isArray(t.choices)&&t.choices.length>=2&&t.choices.every(n=>typeof n=="object"&&n!==null&&typeof n.value=="string"&&typeof n.label=="string"):!0}function Sn(e){if(typeof e!="object"||e===null)return!1;let t=e;if(typeof t.id!="string"||typeof t.required!="boolean"||typeof t.text!="string")return!1;if(t.link===void 0)return!0;let n=t.link;return typeof n=="object"&&n!==null&&typeof n.url=="string"&&/^https:\/\//.test(n.url)&&typeof n.label=="string"}var _n=/^(\d{4})-(\d{2})-(\d{2})$/;function kn(e){if(typeof e!="string")return!1;let t=_n.exec(e);return t===null?!1:new Date(Date.UTC(Number(t[1]),Number(t[2])-1,Number(t[3]))).toISOString().slice(0,10)===e&&e>=b.dateMin&&e<=b.dateMax}function Cn(e){return typeof e=="number"&&Number.isFinite(e)&&Math.abs(e)<b.number&&Math.round(e*100)/100===e}function xt(e){for(let t of e.matchAll(/\d[\d -]{11,}\d/g)){let n=t[0].replace(/[ -]/g,"");if(n.length>=13&&n.length<=19&&bn(n))return!0}return!1}function bn(e){let t=0;for(let n=0;n<e.length;n++){let i=Number(e[e.length-1-n]);n%2===1&&(i*=2,i>9&&(i-=9)),t+=i}return t%10===0}var wn=/^[^\s@]+@[^\s@.]+(\.[^\s@.]+)+$/,xn=/^\+[1-9]\d{6,14}$/,At=/^[A-Z]{2}$/,An=e=>e===void 0||typeof e=="string"&&e.trim()===""||Array.isArray(e)&&e.length===0;function Pn(e=Date.now()){return new Date(e).toISOString().slice(0,10)}function Eo(e,t,n=Pn()){let i=[];for(let r of e.questions){let u=t.answers[r.id];if(An(u)){r.required&&i.push({id:r.id,code:"required"});continue}let a=r.kind==="field"?Rn(r.field,u,n):Mn(r,u,n);a!==null&&i.push({id:r.id,...a})}for(let r of e.consents)r.required&&t.consents[r.id]!==!0&&i.push({id:r.id,code:"consent_required"});return i}function ue(e,t,n=1){if(typeof e!="string")return{code:"required"};let i=e.trim();return[...i].length>t?{code:"too_long",params:{max:t}}:[...i].length<n?{code:"too_short",params:{min:n}}:xt(i)?{code:"card_number"}:null}function Pt(e,t,n={}){return kn(e)?n.period==="past"&&e>=t?{code:"date_not_past"}:n.period==="future"&&e<=t?{code:"date_not_future"}:n.min!==void 0&&e<n.min?{code:"date_too_early",params:{date:n.min}}:n.max!==void 0&&e>n.max?{code:"date_too_late",params:{date:n.max}}:null:{code:"date_invalid"}}function Rn(e,t,n){switch(e){case"full_name":return ue(t,b.fullName,b.fullNameMin);case"occupation":return ue(t,b.occupation);case"birth_date":return Pt(t,n,{period:"past"});case"email":return typeof t=="string"&&t.trim().length<=b.email&&wn.test(t.trim())?null:{code:"email_invalid"};case"phone":return typeof t=="string"&&xn.test(t)?null:{code:"phone_invalid"};case"country":return typeof t=="string"&&At.test(t)?null:{code:"choice_invalid"};case"address":return In(t)?null:{code:"address_invalid"};default:return null}}function In(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=e,n=Array.isArray(t.lines)?t.lines.filter(i=>typeof i=="string"&&i.trim()!==""):[];return typeof t.country=="string"&&At.test(t.country)&&typeof t.city=="string"&&t.city.trim()!==""&&t.city.trim().length<=b.city&&n.length>=1&&n.length<=b.addressLines&&n.every(i=>i.trim().length<=b.addressLine&&!xt(i))&&(t.postcode===void 0||typeof t.postcode=="string"&&t.postcode.trim().length<=b.postcode)}function Mn(e,t,n){let i=new Set((e.choices??[]).map(r=>r.value));switch(e.type){case"short_text":return ue(t,b.shortText);case"long_text":return ue(t,b.longText);case"single_choice":return typeof t=="string"&&i.has(t)?null:{code:"choice_invalid"};case"multiple_choice":return Array.isArray(t)&&t.length>0&&new Set(t).size===t.length&&t.every(r=>i.has(r))?null:{code:"choice_invalid"};case"yes_no":return typeof t=="boolean"?null:{code:"choice_invalid"};case"date":{let r=e.options??{};return Pt(t,n,{...typeof r.min=="string"?{min:r.min}:{},...typeof r.max=="string"?{max:r.max}:{},...r.period==="past"||r.period==="future"?{period:r.period}:{}})}case"number":{if(typeof t!="number"||!Number.isFinite(t)||Math.abs(t)>=b.number)return{code:"number_invalid"};let r=e.options??{};return r.integer===!0&&!Number.isInteger(t)?{code:"number_not_integer"}:Cn(t)?typeof r.min=="number"&&t<r.min?{code:"number_too_small",params:{min:r.min}}:typeof r.max=="number"&&t>r.max?{code:"number_too_large",params:{max:r.max}}:null:{code:"number_decimals"}}default:return null}}var vo={full_name:b.fullName,occupation:b.occupation,email:b.email,short_text:b.shortText,long_text:b.longText};var Rt=Object.freeze({nni_invalid:"id_number_invalid",nni_not_found:"registry_record_not_found",nni_recheck:"id_number_recheck",document_nni_mismatch:"document_id_number_mismatch",nni_locked:"id_number_locked",nni_unbound:"id_number_unbound",missing_nni:"missing_id_number",registry_needs_nni_source:"registry_needs_id_number_source"}),On=new Map(Object.entries(Rt)),Vo=new Map(Object.entries(Rt).map(([e,t])=>[t,e]));function It(e){return On.get(e)??e}var Go=["national_number","document_photo","national_eid"],En=new Set(["phone_otp","email_otp","national_eid","document","nfc","population_registry","supplied_identity","summary_confirm","liveness","portrait","face_match","aml_screening","face_dedup","age_estimation","proof_of_address","form"]),vn=new Set(["supplied_identity","aml_screening","face_dedup","age_estimation"]),Ce=["document","population_registry","national_eid"],be=["phone_otp","email_otp"],Et={identity_method:Ce,contact:be},Tn=["population_registry","document"],we="platform_unsupported",Vn=new Set(["prefilled","user_entered","prefilled_or_entered"]),Fn={phone_otp:"contact",email_otp:"contact",eid_auth:"identity",doc_ocr:"identity",nfc_chip:"identity",population_registry:"identity",liveness:"live_photo",portrait_icao:"live_photo",face_match:"live_photo",poa:"documents",form:"form"};function V(e){return e.section??Fn[e.checkType]??null}function Nn(e,t){let n=e.plan?.choice;if(n===void 0||n.locked)return;let i=n.options.find(r=>r.id!==n.selected&&r.available!==!1&&t.includes(r.service));return i===void 0?void 0:{nodeId:n.nodeId,option:i}}function xe(e){let t=e.plan,n=t?.choice;if(t===void 0||n===void 0||n.locked||t.current===null||t.current===n.nodeId||I(e))return null;let i=Et[n.kind]??[...Ce,...be],r=n.options.flatMap(d=>d.available===!1||!i.includes(d.service)?[]:[d.nationalEid!=null?{id:d.id,service:d.service,nationalEid:d.nationalEid}:{id:d.id,service:d.service}]),u=t.steps.find(d=>d.id===t.current)?.service,a=n.selected??r.find(d=>d.service===u)?.id??null;return r.some(d=>d.id!==a)?{nodeId:n.nodeId,kind:n.kind,current:a,options:r}:null}function vt(e){return e==null?[]:e.options.filter(t=>t.id!==e.current)}function Hn(e){let t=e.simulation;if(typeof t!="object"||t===null)return;let{otpCode:n,skipCapture:i}=t;if(typeof n!="string"||n===""||typeof i!="boolean")return;let r=ut(e);return r!==void 0?{otpCode:n,skipCapture:i,reason:r}:{otpCode:n,skipCapture:i}}function Ln(e){let t=e.levelTarget?.max;return typeof t=="number"&&t<=1?"contact":e.purpose??"identity"}function Dn(e){let t=(e.plan?.sections??[]).map(a=>({id:a.id,state:a.state})),n={sessionId:D(e.sessionId),orgName:e.orgName,sandbox:e.sandbox===!0,returning:e.returning===!0,consentRecorded:e.consentRecorded,expiresAt:e.expiresAt,sections:t.map(a=>a.id),progress:t,purpose:e.purpose??"identity",levelName:Ln(e)};e.branding!==void 0&&(n.branding=e.branding),e.cameraUnavailableHandled===!0&&(n.cameraUnavailableHandled=!0);let i=Hn(e);i!==void 0&&(n.simulation=i);let r=e.testerGate;r?.offered===!0&&typeof r.attemptsLeft=="number"&&r.attemptsLeft>0&&(n.testerGate={attemptsLeft:r.attemptsLeft});let u=xe(e);return u!==null&&(n.switchable=u),n}function Un(e){let t={attemptsRemaining:re(e),attemptsExhausted:e.attempts.used>=e.attempts.max};return e.reason!==void 0&&(t.reason=e.reason),e.retakeHint!==void 0&&(t.retakeHint=e.retakeHint),t}var Tt={phone_otp:"phone",email_otp:"email"};function Bn(e,t){let n=Nn(e,[t==="phone_otp"?"email_otp":"phone_otp"]);return n===void 0?void 0:Tt[n.option.service]}function qn(e,t,n,i){let r=t.checkType==="email_otp",u=(r?t.emailOtp:t.otp)??{},a=r?t.emailOtp?.emailSource:t.otp?.numberSource,d=a!==void 0&&Vn.has(a)?a:r?"prefilled_or_entered":"user_entered",h=typeof u.sentToMasked=="string"&&u.sentToMasked.length>0,_=u.prefilled===!0,S=Bn(e,r?"email_otp":"phone_otp"),P={key:t.checkType,context:n,section:V(t),phase:h?"verify":"send",canSwitch:S!==void 0,...i},g=r?{kind:"email_otp",...P,emailSource:d,needsEmail:d!=="prefilled"&&!_}:{kind:"phone_otp",...P,numberSource:d,needsPhone:d!=="prefilled"&&!_,channels:(t.otp?.channels??[]).filter(m=>m==="whatsapp"||m==="sms")};if(S!==void 0&&(g.switchChannel=S),_&&(g.prefilled=!0),h&&(g.sentToMasked=u.sentToMasked),!r&&t.otp?.channel!==void 0&&(g.channel=t.otp.channel),!r&&Array.isArray(t.phoneCountries)&&(g.phoneCountries=t.phoneCountries.filter(m=>typeof m=="string"&&/^[A-Z]{2}$/.test(m))),!r&&Array.isArray(t.phoneRules)){let m=g.phoneCountries??[];g.phoneRules=t.phoneRules.flatMap(M=>{let y=jn(M);return y!==void 0&&m.includes(y.code)?[y]:[]})}return!r&&t.phoneInternational===!0&&(g.phoneInternational=!0),u.expiresAt!==void 0&&(g.codeExpiresAt=u.expiresAt),u.resendAvailableAt!==void 0&&(g.resendAvailableAt=u.resendAvailableAt),g}var Gn=/^[\d[\]\-|()?:^]{1,64}$/;function Kn(e){try{return typeof e=="string"&&Gn.test(e)&&new RegExp(e)!==null}catch{return!1}}var Mt=e=>typeof e=="number"&&Number.isInteger(e)&&e>=1&&e<=15;function jn(e){let{code:t,dial:n,trunk:i,lengths:r,formats:u}=e??{};if(typeof t!="string"||typeof n!="string"||!/^\d{1,3}$/.test(n)||i!==void 0&&(typeof i!="string"||!/^\d{1,3}$/.test(i))||!Array.isArray(r)||r.length===0||!r.every(Mt))return;let a={code:t,dial:n,lengths:[...r].sort((d,h)=>d-h)};if(i!==void 0&&(a.trunk=i),u!==void 0){if(!(Array.isArray(u)&&u.length<=8&&u.every(h=>Kn(h?.leading)&&Array.isArray(h.groups)&&h.groups.every(Mt)&&r.includes(h.groups.reduce((_,S)=>_+S,0)))))return;a.formats=u.map(h=>({leading:h.leading,groups:[...h.groups]}))}return a}function Yn(e,t,n,i){let r=ae(e)===!0?"bound":ee(t)===!0?"document":"typed",u=r==="typed"&&t.state==="input_required"&&t.reason!==void 0&&It(t.reason)==="id_number_recheck",a=vt(xe(e)),d=!i.attemptsExhausted&&a.length===1&&a[0]?.service==="document";return{kind:"registry",key:"registry",context:n,section:V(t),state:t.state==="input_required"?"input_required":"pending",source:r,recheck:u,canUseDocument:d,...i}}function Wn(e,t,n,i,r){let u=[...t.acceptedSides??[]],a={kind:"document",key:"document",context:n,section:V(t),side:u.includes("recto")?"verso":"recto",acceptedSides:u,documents:Ct(e),photo:Pe(Ae(e.documents),r),...i};return e.detectedCountry!==void 0&&(a.detectedCountry=e.detectedCountry),Zn(e)&&(a.ageStepUp=!0),a}function Ae(e,t=!0){let n=e?.source==="upload"||e?.source==="choice"?e.source:"camera",i=e?.sourcePick==="camera"||e?.sourcePick==="upload"?e.sourcePick:null;return{source:n,pick:i,uploadOffered:t&&e?.uploadOffered===!0}}function Pe(e,t){return t?{...e,cameraOnPhone:!0}:e}var $n=10*1024*1024;function Qn(e,t,n,i,r){let u=e.proofOfAddress,a=u?.pdf?.maxBytes,d=u?.phase==="holder_letter"?"holder_letter":"document";return{kind:"proof_of_address",key:"proof_of_address",context:n,section:V(t),phase:d,rule:u?.rule??{country:null,countryFrom:"global",source:"preset_global",kinds:[]},nameMatch:u?.nameMatch??"exact_person",photo:Pe(Ae(u),r),maxPages:3,pdf:{maxBytes:typeof a=="number"&&a>0?a:$n,maxPages:3},licenceAddressAccepted:d==="document"&&u?.licenceAddressAccepted===!0,...i}}function Zn(e){let t=J(e).find(i=>i.checkType==="age_estimation"),n=t?.reason;return t?.state==="failed"&&(n==="age_uncertain"||n==="age_unavailable")}function Jn(e){let t=T(e,"liveness");return t?.state==="passed"||t?.state==="review"}function Ot(e,t,n,i,r,u=!1){let a=t.icao?.report,d=e.portrait,h=r==="capture"?d?.pendingFix??null:null;h!==null&&(r="review");let _=Vt(e);return{kind:"portrait",key:`portrait:${r}`,context:n,section:V(t),phase:r,report:Array.isArray(a)?a:null,review:t.state==="review",tuning:e.capture?.icao??null,tuningVersion:e.capture?.tuningVersion??null,icao:se(e),retakeOnly:r==="capture"&&t.state==="input_required"&&_===void 0&&e.capture?.livePhoto?.oneCapture===!0&&Jn(e),photo:Pe(Ae(d,r==="capture"),u&&r==="capture"),pendingFix:h,..._!==void 0?{captureMode:_}:{},...d?.reuse?.pending===!0?{reuse:!0}:{},...i}}function Vt(e){let t=e.portrait?.captureMode;return t==="self"||t==="assisted"||t==="choice"?t:void 0}var ke={minLongSidePx:1280,jpegQuality:.95};function Xn(e,t){let n=e.capture?.livePhoto;if(n?.oneCapture!==!0)return null;let i=T(e,"portrait_icao"),r=n.still??ke;return{icao:t==="liveness"&&se(e)!==null&&Vt(e)===void 0&&i!==void 0&&i.state==="pending"&&i.reason===void 0,still:{minLongSidePx:r.minLongSidePx??ke.minLongSidePx,jpegQuality:r.jpegQuality??ke.jpegQuality}}}function zn(e,t,n,i){let r=t.eid,u=V(t);if(r===void 0||r.challenge!=="app_code")return{kind:"unsupported",key:"unsupported:eid_auth",context:n,section:u,checkType:"eid_auth",reason:"update_required"};let a=vt(xe(e)),d=a.length===1&&Tn.includes(a[0]?.service??"")?a[0]:void 0,h=d===void 0?void 0:Z[d.service],_=h!==void 0,S={kind:"eid",key:"eid",context:n,section:u,provider:r.provider,providerName:r.providerName,country:r.country,challenge:"app_code",phase:r.awaiting==="code"?"code":"identifier",identifierBound:r.identifierBound===!0,canUseCamera:_,afterPass:r.afterPass==="continue"?"continue":"end",...i};return _&&(S.cameraMethod=h),r.expiresAt!==void 0&&(S.codeExpiresAt=r.expiresAt),r.resendAvailableAt!==void 0&&(S.resendAvailableAt=r.resendAvailableAt),r.resendsRemaining!==void 0&&(S.resendsRemaining=r.resendsRemaining),r.codeAttemptsRemaining!==void 0&&(S.codeAttemptsRemaining=r.codeAttemptsRemaining),S}function eo(e,t){if(t.checkType!=="face_match"||t.reason!==void 0)return null;let n=T(e,"portrait_icao");return n!==void 0&&(n.state==="passed"||n.state==="review")?n:null}var to={rejected:"rejected",inconclusive:"inconclusive",unavailable:"unavailable",abandoned:"expired",not_opened:"expired",cancelled:"expired",superseded:"expired",policy:"policy"};function no(e){return e.reasonCode===we?"platform_unsupported":e.status==="review_pending"?"review":e.status==="verified"?"verified":e.reasonCode==="device_cooldown"?"cooldown":e.reasonCode==="starter_credit_claimed"?"policy":(e.status==="not_verified"&&e.reason!==void 0?to[e.reason]:void 0)??"rejected"}function oo(e,t){let n=no(e),i=n==="platform_unsupported"?{sessionId:D(e.sessionId),status:"unavailable",reasonCode:we}:X(e,{autoRetry:!1}),r={kind:"result",key:"result",context:t,section:null,display:n,result:i};return e.status==="not_verified"&&e.reason!==void 0&&(r.reason=e.reason),e.reasonCode!==void 0&&(r.reasonCode=e.reasonCode),e.status==="not_verified"&&e.step!==void 0&&(r.step=e.step),e.retryAfter!==void 0&&(r.retryAfter=e.retryAfter),r}function ro(e,t,n){let i=e.identitySummary;if(i==null)return null;let r={kind:"identity_summary",key:"identity_summary",context:t,section:n??"identity",summaryKind:i.kind==="partial"?"partial":i.kind??"full",source:i.source,portraitAvailable:i.portrait?.available===!0,retakeAvailable:i.retakeAvailable===!0};for(let a of io){let d=i[a];typeof d=="string"&&d!==""&&(r[a]=d)}let u=gt(i);return u!==void 0&&(r.idNumberMasked=u,r.nniMasked=u),r}var io=["fullName","birthDate","birthYear","nationality","documentType","documentNumberMasked","expiryDate","retakeTarget"];function B(e,t,n,i){return{kind:"unsupported",key:`unsupported:${n}`,context:e,section:t,checkType:n,reason:i}}function so(e){return e.kind==="contact"?"contact":(e.kind==="identity_method","identity")}function ao(e,t){let n=Et[e.kind]??[...Ce,...be],i=so(e),r=e.options.flatMap(a=>{if(a.available===!1||!n.includes(a.service))return[];let d={id:a.id,service:a.service};a.nationalEid!=null&&(d.nationalEid=a.nationalEid);let h=(a.channels??[]).filter(_=>_==="whatsapp"||_==="sms");return a.service==="phone_otp"&&h.length>0&&(d.channels=h),[d]});if(r.length===0){let a=e.options.length>0&&e.options.every(d=>d.service==="nfc");return B(t,i,"choice",a?"platform_unsupported":"update_required")}let u={nodeId:e.nodeId,kind:e.kind,selected:e.selected,options:r};if(e.kind==="identity_method"){let a={kind:"method",key:"method",context:t,section:i,options:r.map(h=>Z[h.service]),choice:u},d=r.find(h=>h.nationalEid!==void 0)?.nationalEid;return d!==void 0&&(a.nationalEid=d),a}return e.kind==="contact"?{kind:"contact_choice",key:"contact_choice",context:t,section:i,options:r.map(a=>Tt[a.service]),selected:null,locked:!1,choice:u}:{kind:"choice",key:`choice:${e.nodeId}`,context:t,section:i,choice:u}}function uo(e,t,n,i){let r=e.nativeApp,u=typeof r=="object"&&r!==null?r:{},a={sekyroApp:u.sekyroApp===!0};return typeof u.link=="string"&&u.link!==""&&(a.link=u.link),a.sekyroApp&&typeof u.sekyroAppLink=="string"&&u.sekyroAppLink.startsWith("sekyro://")&&(a.sekyroAppLink=u.sekyroAppLink),{kind:"native_app_required",key:`native_app_required:${i}`,context:t,section:n,checkType:i,nativeApp:a}}function Ko(e,t={}){let n=Dn(e);if(I(e)||e.reasonCode===we)return oo(e,n);let i=e.plan;if(i===void 0||!Array.isArray(i.sections))return B(n,null,"plan","update_required");let r=st(e);if(r!==null)return ao(r,n);let u=i.current===null?void 0:i.steps.find(g=>g.id===i.current),a=g=>{let m={kind:"processing",key:"processing",context:n,section:g!==void 0?V(g):i.sections.find(M=>M.state==="current")?.id??null,stalled:!1};return typeof g?.service=="string"&&g.service!==""&&(m.service=g.service),m};if(i.current===null)return a(i.steps.find(g=>g.state==="processing"));if(u===void 0)return B(n,null,"step","update_required");if(!En.has(u.service))return u.interaction==="server"?a(u):B(n,V(u),u.service,"update_required");if(vn.has(u.service)||!at(u))return a(u);let d=u,h=Un(d),_=d.checkType,S=V(d);if(d.requiresNativeApp===!0)return uo(e,n,S,_);let P=t.isMobile===!1?z(e,d):null;if(P==="phone")return{kind:"mobile_required",key:"mobile_required",context:n,section:S,checkType:_};switch(_){case"phone_otp":case"email_otp":return qn(e,d,n,h);case"population_registry":return Yn(e,d,n,h);case"eid_auth":return zn(e,d,n,h);case"doc_ocr":return Wn(e,d,n,h,P==="upload_or_phone");case"identity_confirm":return ro(e,n,S)??a(d);case"portrait_icao":return Ot(e,d,n,h,"capture",P==="upload_or_phone");case"liveness":case"face_match":{let g=eo(e,d);if(g!==null)return Ot(e,g,n,h,"match");let m=d.requiresMobile===!0,M=se(e);return{kind:"liveness",key:"biometric",context:n,section:S,mode:_==="face_match"?"selfie":"liveness",requiresMobile:m,instructions:M===null?"standard":"icao",icao:M,livePhoto:Xn(e,_),...h}}case"poa":return Qn(e,d,n,h,P==="upload_or_phone");case"form":{let g=wt(d.form);return g===null?B(n,S,_,"update_required"):{kind:"form",key:"form",context:n,section:S,form:g,dir:bt(g.locale),...h}}case"nfc_chip":return B(n,S,_,"platform_unsupported");default:return B(n,S,_,"update_required")}}export{Jt as a,Xt as b,sn as c,an as d,cn as e,xo as f,dn as g,kt as h,ln as i,fn as j,Io as k,Ct as l,Mo as m,b as n,bt as o,kn as p,Cn as q,xt as r,Pn as s,Eo as t,Go as u,we as v,V as w,xe as x,vt as y,eo as z,Ko as A};