New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@onefootprint/footprint-js

Package Overview
Dependencies
Maintainers
0
Versions
76
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@onefootprint/footprint-js - npm Package Compare versions

Comparing version 3.14.2 to 3.15.0

4

dist/footprint-js.d.ts

@@ -271,5 +271,6 @@ import * as CSS from 'csstype';

isComponentsSdk?: boolean;
shouldRelayToComponents?: boolean;
fixtureResult?: OverallOutcome;
documentFixtureResult?: IdDocOutcome;
readonly sandboxId?: string;
sandboxId?: string;
};

@@ -281,2 +282,3 @@ /** Components SDK. Just a subset of Verify */

readonly variant?: VerifyVariant;
readonly shouldRelayToComponents?: boolean;
};

@@ -283,0 +285,0 @@ /** verify-button */

import Lt from '@onefootprint/postmate';
var et=Object.defineProperty,tt=Object.defineProperties;var ot=Object.getOwnPropertyDescriptors;var R=Object.getOwnPropertySymbols;var fe=Object.prototype.hasOwnProperty,ye=Object.prototype.propertyIsEnumerable;var ue=(e,t,o)=>t in e?et(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,g=(e,t)=>{for(var o in t||(t={}))fe.call(t,o)&&ue(e,o,t[o]);if(R)for(var o of R(t))ye.call(t,o)&&ue(e,o,t[o]);return e},k=(e,t)=>tt(e,ot(t));var ge=(e,t)=>{var o={};for(var n in e)fe.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&R)for(var n of R(e))t.indexOf(n)<0&&ye.call(e,n)&&(o[n]=e[n]);return o};var u=(e,t,o)=>new Promise((n,r)=>{var a=p=>{try{i(o.next(p));}catch(d){r(d);}},s=p=>{try{i(o.throw(p));}catch(d){r(d);}},i=p=>p.done?n(p.value):Promise.resolve(p.value).then(a,s);i((o=o.apply(e,t)).next());});var he="fp-session-id",ke=typeof window!="undefined",Q="xfpsessionid",rt=()=>"10000000-1000-4000-8000-100000000000".replace(/[018]/g,e=>(+e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+e/4).toString(16)),Ce=(e,t)=>new URL(t).searchParams.get(e),at=e=>{var t,o;try{let n=(o=(t=window==null?void 0:window.top)==null?void 0:t.location)==null?void 0:o.href;return n?Ce(e,n):null}catch(n){return null}},Pe=e=>ke?Ce(e,window.location.href)||at(e):null,be=()=>{if((!ke||!window.sessionStorage))return !1;try{let e="test";return sessionStorage.setItem(e,e),sessionStorage.removeItem(e),!0}catch(e){return !1}},st=()=>{let e=Pe(Q)||rt();if(be())try{sessionStorage.setItem(he,e);}catch(t){console.error("Failed to create session id",t);}return e},it=()=>{let e=Pe(Q);return e||(be()?sessionStorage.getItem(he):null)},ve=()=>it()||st(),x=(e,t=ve())=>{let o=new URL(e);return o.searchParams.set(Q,t),o.toString()};var E=ve;var D="3.14.2";var K=(i=>(i.Auth="auth",i.Components="components",i.Form="form",i.Render="render",i.UpdateLoginMethods="update_login_methods",i.Verify="verify",i.VerifyButton="verify-button",i))(K||{});var O=(s=>(s.auth="auth",s.canceled="canceled",s.clicked="clicked",s.closed="closed",s.completed="completed",s.relayToComponents="relayToComponents",s))(O||{}),T=(s=>(s.formSaveComplete="formSaveComplete",s.formSaveFailed="formSaveFailed",s.formSaved="formSaved",s.propsReceived="propsReceived",s.started="started",s.relayFromComponents="relayFromComponents",s))(T||{});var we="footprint-inline-container",Se="footprint-body-locked",Ve="footprint-overlay",lt="footprint-overlay-container",Ae=we,Ie=Ve,xe="footprint-loading-indicator",B=e=>`${lt}-${e}`,V=(e,t)=>`${e}-${t}`,Oe=e=>u(void 0,null,function*(){X(e),mt(e),yield ct(e);}),Fe=e=>{let t=B(e),o=document.getElementById(t);if(o)return o;let n=document.createElement("div");return n.setAttribute("id",t),document.body.appendChild(n),n},ct=e=>u(void 0,null,function*(){let t=B(e),o=document.getElementById(t);if(!o)return;let n=o.querySelector("iframe.footprint-drawer");n&&(n==null||n.classList.add("footprint-drawer-closing"),yield new Promise(i=>{setTimeout(i,300);}));let r=o.querySelector("iframe.footprint-modal");r&&(r==null||r.classList.add("footprint-modal-closing"),yield new Promise(i=>{setTimeout(i,100);}));let a=V(Ie,e),s=document.getElementById(a);s&&(s.classList.add("footprint-overlay-fading"),yield new Promise(i=>{setTimeout(i,200);}),o.remove(),s.remove(),document.body.classList.remove(Se));}),Le=(e,t)=>{let o=V(Ae,e),n=document.createElement("div");return n.classList.add(we),n.setAttribute("id",o),t.appendChild(n),n},mt=e=>{let t=V(Ae,e),o=document.getElementById(t);o&&o.remove();},X=e=>{let t=V(xe,e),o=document.getElementById(t);o&&o.remove();},Y=(e,t)=>{let o=V(xe,t),n=ut(o);e.appendChild(n);},Re=(e,t)=>{document.body.classList.add(Se);let o=document.createElement("div"),n=V(Ie,t);return o.setAttribute("id",n),o.classList.add(Ve),e.appendChild(o),o},ut=e=>{let t=document.createElement("div");t.setAttribute("id",e),t.classList.add("footprint-loading-indicator");let o=document.createElement("div");o.classList.add("footprint-loading-spin");let n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.setAttribute("width","24px"),n.setAttribute("height","24px"),n.setAttribute("fill","none"),n.setAttribute("aria-hidden","true");let r=document.createElementNS("http://www.w3.org/2000/svg","path");return r.setAttribute("d","M12 2a10 10 0 0 1 10 10h-2a7.999 7.999 0 0 0-8-8V2Z"),n.appendChild(r),o.appendChild(n),t.appendChild(o),t},Ee=e=>{let t=document.getElementById(B(e));t&&(t.style.opacity="1",t.style.display="block");},De=e=>{let t=document.getElementById(B(e));t&&(t.style.opacity="0",t.style.display="none");},Ke=e=>{let t=document.createElement("div");t.classList.add("modal-error-container"),t.setAttribute("role","dialog"),t.setAttribute("aria-modal","true"),t.setAttribute("aria-label","Oops! Something\u2019s not quite right.");let o=document.createElement("div");o.classList.add("modal-error");let n=document.createElement("button");n.setAttribute("aria-label","Close"),n.classList.add("modal-error-close-button"),n.addEventListener("click",()=>{e.remove();});let r=document.createElementNS("http://www.w3.org/2000/svg","svg");r.setAttribute("xmlns","http://www.w3.org/2000/svg"),r.setAttribute("width","20"),r.setAttribute("height","20"),r.setAttribute("viewBox","0 0 20 20"),r.setAttribute("fill","none");let a=document.createElementNS("http://www.w3.org/2000/svg","path");a.setAttribute("d","M5 5L15 15M15 5L5 15"),a.setAttribute("stroke","black"),a.setAttribute("stroke-width","1.5"),a.setAttribute("stroke-linecap","round"),r.appendChild(a),n.appendChild(r);let s=document.createElementNS("http://www.w3.org/2000/svg","svg");s.setAttribute("xmlns","http://www.w3.org/2000/svg"),s.setAttribute("width","40"),s.setAttribute("height","40"),s.setAttribute("viewBox","0 0 40 40"),s.setAttribute("fill","none"),s.setAttribute("class","error-icon");let i=document.createElementNS("http://www.w3.org/2000/svg","path");i.setAttribute("d","M25 15L15 25M25 25L15 15M35 20C35 28.2843 28.2843 35 20 35C11.7157 35 5 28.2843 5 20C5 11.7157 11.7157 5 20 5C28.2843 5 35 11.7157 35 20Z"),i.setAttribute("stroke","black"),i.setAttribute("stroke-width","3.33333"),i.setAttribute("stroke-linecap","round"),i.setAttribute("stroke-linejoin","round"),s.appendChild(i);let p=document.createElement("h2");p.textContent="Oops! Something\u2019s not quite right.";let d=document.createElement("p");d.textContent="It looks like there was an issue loading the page. Try reloading and we\u2019ll get things back on track.",o.appendChild(n),o.appendChild(s),o.appendChild(p),o.appendChild(d),t.appendChild(o),e.appendChild(t);};var ft=()=>Math.random().toString(36).substring(2),U=ft;var _="https://api.onefootprint.com",M=D,$="footprint-js";var P={["auth"]:"auth_v1",["form"]:"form_v1",["render"]:"render_v1",["update_login_methods"]:"update_auth_methods_v1",["verify"]:"verify_v1",["verify-button"]:"verify_button_v1",["components"]:"verify_v1"};var yt=e=>e.replace(/[A-Z]/g,t=>`_${t.toLowerCase()}`),Z=e=>t=>{if(!t||typeof t!="object")return t;let o=Object.entries(t).map(([n,r])=>{let a;return Array.isArray(r)?a=r.map(Z(e)):Object(r)===r?a=Z(e)(r):a=r,[e(n),a]});return Object.fromEntries(o)},gt=Z(yt),N=gt;var ht=(e,t,o,n)=>{let r={tenantDomain:n,sdkKind:e,sdkName:$,sdkVersion:M,logLevel:o,logMessage:t,sessionId:E()};try{fetch(`${_}/org/sdk_telemetry`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(N(r))});}catch(a){}},j=ht;var F=(e,t)=>{let o=`@onefootprint/footprint-js: ${t}`;{let n;try{n=window.location.href;}catch(r){}j(e,t,"info",n);}return o},ee=(e,t)=>{let o=`@onefootprint/footprint-js: ${t}`;{let n;try{n=window.location.href;}catch(r){}j(e,t,"warn",n);}return o},H=(e,t)=>{let o=`@onefootprint/footprint-js: ${t}`;{let n;try{n=window.location.href;}catch(r){}j(e,t,"error",n);}return o};var Te={["auth"]:{["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete"},["update_login_methods"]:{["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete"},["form"]:{["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete"},["verify"]:{["auth"]:"onAuth",["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete"},["components"]:{["auth"]:"onAuth",["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete",["relayToComponents"]:"onRelayToComponents"},["verify-button"]:{["auth"]:"onAuth",["canceled"]:"onCancel",["clicked"]:"onClick",["closed"]:"onClose",["completed"]:"onComplete"},["render"]:{}},Be={["auth"]:[],["form"]:[],["render"]:[],["update_login_methods"]:[],["verify"]:[],["components"]:[],["verify-button"]:[]};var Ue={["auth"]:["modal","drawer"],["components"]:["modal"],["form"]:["inline","modal","drawer"],["render"]:["inline"],["update_login_methods"]:["modal","drawer"],["verify"]:["modal","drawer"],["verify-button"]:["inline"]},kt=Object.values(O),Ct=(...e)=>{},b=e=>e!=null&&typeof e=="object"&&!Array.isArray(e),te=e=>b(e)&&Object.keys(e).length>0,Pt=(e,t)=>{if(e==="inline"&&!t)throw new Error(`Inline component requires a containerId. Received ${t}`)},q=(e,t)=>{var r;if(!t)return;let o=(r=Ue[e])!=null?r:[];if(!o.includes(t))throw new Error(`Invalid variant: ${JSON.stringify(t)}. Valid variants for ${e} are ${o.join(", ")}`)},A=e=>{var o;let t=(o=Ue[e])!=null?o:[];if(!t.length)throw new Error(`Invalid kind: ${e}`);return t[0]},z=e=>{if(!e)throw new Error("Kind is required");let t=Object.values(K);if(!t.includes(e))throw new Error(`Invalid kind: ${e}. Valid kinds are: ${t.join(", ")}`)},_e=e=>{if(e.kind==="verify-button"){let t=e,{kind:o,appearance:n,variant:r,dialogVariant:a,onClick:s,label:i,containerId:p}=t,d=ge(t,["kind","appearance","variant","dialogVariant","onClick","label","containerId"]);return k(g({},d),{variant:a,kind:"verify"})}};var Me=(e,t)=>(Object.prototype.hasOwnProperty.call(e,t)&&typeof e[t]=="function"?e[t]:void 0)||Ct,oe=(e,t,o)=>{var i;let{kind:n}=e,r=(i=Te[n])!=null?i:{},a={},s=_e(e);return Object.entries(r).forEach(([p,d])=>{let c=p;if(!kt.includes(c))return;let C=Me(e,d),I=c==="closed"||c==="canceled",m=n==="verify-button"&&c==="clicked";a[c]=h=>{C(h),I&&(t==null||t()),m&&s&&(o==null||o(s));};}),a},L=e=>{let{kind:t,variant:o,containerId:n}=e,r=o||A(t);return z(t),q(t,o),Pt(r,n),te(e==null?void 0:e.userData)&&console.warn("userData is deprecated and will be removed in the next major version. Please use bootstrapData instead."),k(g({},e),{variant:r})},v=e=>te(e==null?void 0:e.bootstrapData)?{userData:e.bootstrapData}:te(e==null?void 0:e.userData)?{userData:e.userData}:void 0;var bt=e=>e==="auth";var vt=e=>e==="update_login_methods";var ne=e=>e.kind==="components";var re=e=>typeof e=="string"&&e.length>0,J=e=>bt(e.kind)&&!!("updateLoginMethods"in e&&e.updateLoginMethods)&&!!e.authToken&&/tok_/.test(e.authToken),wt=e=>vt(e.kind)&&!!e.authToken&&/tok_/.test(e.authToken),ae=e=>[J,wt].some(t=>t(e));var St=3,Vt=!1,At=e=>ae(e)?"update_auth_methods_v1":P[e.kind],It=e=>{var o,n;let{kind:t}=e;if(t==="verify"||t==="components")return k(g({},v(e)),{publicKey:e.publicKey,authToken:e.authToken,options:e.options,l10n:e.l10n,fixtureResult:(o=e.sandboxOutcome)==null?void 0:o.overallOutcome,documentFixtureResult:(n=e.sandboxOutcome)==null?void 0:n.documentOutcome,sandboxId:e.sandboxId,isComponentsSdk:t==="components"});if(t==="update_login_methods")return k(g({},v(e)),{authToken:e.authToken,options:e.options,l10n:e.l10n});if(t==="auth")return J(e)?k(g({},v(e)),{authToken:e.authToken,updateLoginMethods:e.updateLoginMethods,options:e.options,l10n:e.l10n}):e.authToken&&Vt?k(g({},v(e)),{authToken:e.authToken,options:e.options,l10n:e.l10n}):k(g({},v(e)),{publicKey:e.publicKey,options:e.options,l10n:e.l10n});if(t==="form")return {authToken:e.authToken,options:e.options,title:e.title,l10n:e.l10n};if(t==="render")return {authToken:e.authToken,canCopy:e.canCopy,defaultHidden:e.defaultHidden,id:e.id,label:e.label,showHiddenToggle:e.showHiddenToggle,l10n:e.l10n};if(t==="verify-button")return k(g({},v(e)),{publicKey:e.publicKey,options:e.options,authToken:e.authToken,label:e.label,l10n:e.l10n});H(t,"Invalid kind provided");},$e=(e,t)=>u(void 0,null,function*(){return fetch(`${_}/org/sdk_args`,{method:"POST",headers:{"x-fp-client-version":`${$} ${M} ${e.kind}`.trim(),"Content-Type":"application/json"},body:JSON.stringify(e)}).then(o=>{if(o.ok)return o.json();if(t>0)return $e(e,t-1)})}),xt=e=>u(void 0,null,function*(){F(P[e.kind],"Sending SDK args");let t=It(e);if(!t)return;let o=yield $e({data:N(t),kind:At(e)},St);return o?o.token:void 0}),Ne=xt;var je=({fontSrc:e,variables:t={},rules:o={},variant:n}={})=>{let r=()=>Object.keys(t).length?encodeURIComponent(JSON.stringify(t)):void 0,a=()=>Object.keys(o).length?encodeURIComponent(JSON.stringify(o)):void 0;return {fontSrc:e,variables:r(),rules:a(),variant:n}},He=()=>{let e=window.footprintAppearance;return !e||!b(e)?{}:{fontSrc:e.fontSrc,rules:e.rules,variables:e.variables}};var qe=()=>{var e;return typeof window!="undefined"?((e=window.location)==null?void 0:e.href)||window.location.toString():""},Ot=(e,t)=>{let{appearance:o,kind:n,l10n:r,variant:a}=e,{fontSrc:s,rules:i,variables:p}=je(o),d=new URLSearchParams;return p&&d.append("variables",p),i&&d.append("rules",i),s&&d.append("font_src",s),r!=null&&r.language&&d.append("lng",r.language),d.append("variant",a||A(n)),`${d.toString()}#${t}`},Ft=(e,t)=>{let{kind:o}=e,n=Ot(e,t),r=`https://components.onefootprint.com/${o}`,a=`https://components2.onefootprint.com/${o}`;if(o==="update_login_methods"&&(r="https://auth.onefootprint.com/user",a="https://auth2.onefootprint.com/user"),o==="auth"&&(r="https://auth.onefootprint.com",a="https://auth2.onefootprint.com"),(o==="verify"||o==="verify-button"||o==="components")&&(r="https://id.onefootprint.com",a="https://id2.onefootprint.com"),!re(r))throw new Error(`${o}_URL environment variable is not defined.`);return r+=`?${n}`.trim(),a+=`?${n}`.trim(),{url:r,fallbackUrl:a}},ze=Ft;var Rt=e=>{let t=null,o=!1,n,r,{formSaveComplete:a,formSaved:s,formSaveFailed:i,started:p}=T,d=L(e),{variant:c,containerId:C}=d,I=c==="modal"||c==="drawer",m=U(),h=(l,f)=>{var S;let y=H(P[d.kind],l);(S=d.onError)==null||S.call(d,y),o&&f&&(n(),o=!1);},Ye=()=>{if(!t){h("Footprint should be initialized in order to register callback props");return}let l=oe(d,n,r);Object.entries(l).forEach(([f,y])=>{t==null||t.on(f,y),t==null||t.on(`${m}:${f}`,y);});},Ze=()=>{if(I)return Fe(m);if(!C){h("containerId is required when rendering inline");return}let l=document.getElementById(C);if(!l){h(`Could not find container with id ${C} while rendering footprint`);return}return Le(m,l)},W=(l,f)=>{if(!f){X(m),t==null||t.frame.classList.remove("fp-hide"),t==null||t.frame.classList.remove(`footprint-${c}-loading`),t==null||t.frame.classList.add(`footprint-${c}-loaded`);return}if(I){let y=Re(l,m);Y(y,m);}else Y(l,m);},de=()=>{var f;if(!t){h("Footprint should be initialized in order to set up refs");return}if(d.kind!=="form"||!d.getRef)return;let l={save:()=>(t||h("Footprint should be initialized to call ref methods"),new Promise((y,S)=>{t==null||t.on(a,()=>{y();}),t==null||t.on(i,le=>{S(le);}),t==null||t.on(`${m}:${a}`,y),t==null||t.on(`${m}:${i}`,S),t==null||t.call(s);}))};(f=d.getRef)==null||f.call(d,l);},pe=(l,f)=>u(void 0,null,function*(){try{return t=yield new Lt({classListArray:[`footprint-${c}`,`footprint-${c}-loading`,"fp-hide"],container:l,name:`footprint-iframe-${m}`,url:f,allow:"otp-credentials; publickey-credentials-get *; camera *; clipboard-write;",model:{authToken:d.authToken,initId:m,sdkUrl:qe(),sdkVersion:D||""}}),{success:!0,parentApi:t}}catch(y){return h(`Initializing iframe with ${new URL(f).host} failed with error ${y}`),{success:!1}}}),Ge=(S,le)=>u(void 0,[S,le],function*(l,{url:f,fallbackUrl:y}){F(P[d.kind],`Initializing iframe with ${new URL(f).host}`);let ce=yield pe(l,f);if(ce.success)return ce.parentApi;F(P[d.kind],`Initializing iframe with ${new URL(y).host} as fallback`);let me=yield pe(l,y);if(!me.success)throw new Error("Failed to initialize iframe");return me.parentApi});return {relayFromComponents:()=>{t&&(t.call("relayFromComponents"),Ee(m));},props:d,isRendered:o,render:()=>u(void 0,null,function*(){if(o){ee(P[d.kind],"Footprint component is already rendered");return}o=!0;let l=Ze();if(!l){ee(P[d.kind],"Unable to create container for Footprint component");return}l.hasChildNodes()&&(l.innerHTML=""),W(l,!0);let f=yield Ne(d);if(!f){h("Unable to get SDK args token.",!0),W(l,!1);return}let{url:y,fallbackUrl:S}=ze(d,f||"");try{yield Ge(l,{url:x(y),fallbackUrl:x(S)}),Ye();}catch(le){Ke(l),o=!1;}W(l,!1),t==null||t.on(p,()=>de()),t==null||t.on(`${m}:${p}`,de),d.kind==="components"&&(t==null||t.on(`${m}:${"relayToComponents"}`,()=>{De(m);}));}),destroy:()=>u(void 0,null,function*(){o&&(o=!1,yield Oe(m),t&&(t.destroy(),t=null));}),registerOnDestroy:l=>{!l||typeof l!="function"||(n=l);},registerOnRenderSecondary:l=>{!l||typeof l!="function"||(r=l);}}},se=Rt;var w=e=>{let t=L(e);return JSON.stringify(t)},Et=()=>{let e=Object.create(null);return {getOrCreate:a=>{let s=w(a.props),i=Object.values(e).find(p=>w(p.iframe.props)===s);return i?i.iframe:(e[s]={iframe:a,secondaryIframes:{}},a)},getOrCreateSecondary:(a,s)=>{let i=w(a.props),p=w(s.props);if(!e[i])throw new Error("iframe manager: primary iframe does not exist while adding secondary");let{secondaryIframes:d}=e[i],c=Object.values(d).find(C=>w(C.props)===p);return c||(d[p]=s,s)},remove:a=>{let s=w(a.props),i=e[s];i&&(Object.keys(i.secondaryIframes).forEach(p=>{i.secondaryIframes[p].destroy();}),delete e[s]);},removeSecondary:(a,s)=>{let i=w(a.props),p=w(s.props);if(!e[i])throw new Error("iframe manager: primary iframe does not exist while removing secondary");let{secondaryIframes:d}=e[i],c=d[p];c&&(c.destroy(),delete d[p]);}}},Je=Et;var Dt=()=>{let e=Je();return {init:o=>{let n=se(o),r=()=>u(void 0,null,function*(){e.remove(n),yield n.destroy();}),a=d=>u(void 0,null,function*(){e.removeSecondary(n,d),yield d.destroy();}),s=d=>u(void 0,null,function*(){let c=se(d);c=e.getOrCreateSecondary(n,c),c.registerOnDestroy(()=>{a(c);}),c.render();}),i=()=>u(void 0,null,function*(){n=e.getOrCreate(n),n.registerOnDestroy(r),n.registerOnRenderSecondary(s),yield n.render();}),p={};return ne(o)&&(p={relayFromComponents:()=>{n.relayFromComponents();}}),g({render:i,destroy:r},p)}}},Kt=Dt(),ie=Kt;var Tt=e=>{window.setTimeout(e,0);},Bt=e=>{if(typeof window=="undefined")return;let t=r=>{var i;let a=(i=window.footprintCallbacks)!=null?i:{};if(!b(a))throw Error("`window.footprintCallbacks` must be a valid mapping from callback names to functions.");return Be[r].forEach(p=>{if(!a[p])throw Error(`Callback '${p}' must be defined in window.footprintCallbacks`)}),a},o=r=>{var m;let a=r.getAttribute("data-kind");z(a);let s=(m=r.getAttribute("data-variant"))!=null?m:A(a);q(a,s);let i=He(),p=t(a),d=r.getAttribute("data-props")||"",c;try{c=JSON.parse(d);}catch(h){throw Error("Could not parse `data-props` for footprint.")}if(!b(c))throw Error("`data-props` on the footprint element has to be a valid JSON object stringified.");let C=U();r.setAttribute("id",C),e.init(g(g({kind:a,variant:s,appearance:i,containerId:r.id},p),c)).render();},n=()=>{let r=document.querySelectorAll("[data-footprint]");r.length&&r.forEach(a=>{o(a);});};document.addEventListener("DOMContentLoaded",()=>Tt(n));},We=Bt;var Ut="http://test",Qe=e=>u(void 0,null,function*(){let t=yield fetch(`${Ut}/hosted/identify/lite`,{method:"POST",body:JSON.stringify(e)});if(!t.ok)throw Error(t.statusText);return (yield t.json()).user_found}),_t=e=>u(void 0,null,function*(){if(!b(e))throw new Error("User data must be passed in order to identify an user");let t=e["id.email"],o=e["id.phone_number"];return t&&(yield Qe({email:t}))?!0:o?yield Qe({phone_number:o}):!1}),Xe=_t;var Vn=ie;We(ie);
var et=Object.defineProperty,tt=Object.defineProperties;var ot=Object.getOwnPropertyDescriptors;var R=Object.getOwnPropertySymbols;var fe=Object.prototype.hasOwnProperty,ye=Object.prototype.propertyIsEnumerable;var ue=(e,t,o)=>t in e?et(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,g=(e,t)=>{for(var o in t||(t={}))fe.call(t,o)&&ue(e,o,t[o]);if(R)for(var o of R(t))ye.call(t,o)&&ue(e,o,t[o]);return e},k=(e,t)=>tt(e,ot(t));var ge=(e,t)=>{var o={};for(var n in e)fe.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&R)for(var n of R(e))t.indexOf(n)<0&&ye.call(e,n)&&(o[n]=e[n]);return o};var u=(e,t,o)=>new Promise((n,r)=>{var a=p=>{try{i(o.next(p));}catch(d){r(d);}},s=p=>{try{i(o.throw(p));}catch(d){r(d);}},i=p=>p.done?n(p.value):Promise.resolve(p.value).then(a,s);i((o=o.apply(e,t)).next());});var he="fp-session-id",ke=typeof window!="undefined",Q="xfpsessionid",rt=()=>"10000000-1000-4000-8000-100000000000".replace(/[018]/g,e=>(+e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+e/4).toString(16)),Ce=(e,t)=>new URL(t).searchParams.get(e),at=e=>{var t,o;try{let n=(o=(t=window==null?void 0:window.top)==null?void 0:t.location)==null?void 0:o.href;return n?Ce(e,n):null}catch(n){return null}},Pe=e=>ke?Ce(e,window.location.href)||at(e):null,be=()=>{if((!ke||!window.sessionStorage))return !1;try{let e="test";return sessionStorage.setItem(e,e),sessionStorage.removeItem(e),!0}catch(e){return !1}},st=()=>{let e=Pe(Q)||rt();if(be())try{sessionStorage.setItem(he,e);}catch(t){console.error("Failed to create session id",t);}return e},it=()=>{let e=Pe(Q);return e||(be()?sessionStorage.getItem(he):null)},ve=()=>it()||st(),x=(e,t=ve())=>{let o=new URL(e);return o.searchParams.set(Q,t),o.toString()};var E=ve;var D="3.15.0";var K=(i=>(i.Auth="auth",i.Components="components",i.Form="form",i.Render="render",i.UpdateLoginMethods="update_login_methods",i.Verify="verify",i.VerifyButton="verify-button",i))(K||{});var O=(s=>(s.auth="auth",s.canceled="canceled",s.clicked="clicked",s.closed="closed",s.completed="completed",s.relayToComponents="relayToComponents",s))(O||{}),T=(s=>(s.formSaveComplete="formSaveComplete",s.formSaveFailed="formSaveFailed",s.formSaved="formSaved",s.propsReceived="propsReceived",s.started="started",s.relayFromComponents="relayFromComponents",s))(T||{});var we="footprint-inline-container",Se="footprint-body-locked",Ve="footprint-overlay",lt="footprint-overlay-container",Ae=we,Ie=Ve,xe="footprint-loading-indicator",B=e=>`${lt}-${e}`,V=(e,t)=>`${e}-${t}`,Oe=e=>u(void 0,null,function*(){X(e),mt(e),yield ct(e);}),Fe=e=>{let t=B(e),o=document.getElementById(t);if(o)return o;let n=document.createElement("div");return n.setAttribute("id",t),document.body.appendChild(n),n},ct=e=>u(void 0,null,function*(){let t=B(e),o=document.getElementById(t);if(!o)return;let n=o.querySelector("iframe.footprint-drawer");n&&(n==null||n.classList.add("footprint-drawer-closing"),yield new Promise(i=>{setTimeout(i,300);}));let r=o.querySelector("iframe.footprint-modal");r&&(r==null||r.classList.add("footprint-modal-closing"),yield new Promise(i=>{setTimeout(i,100);}));let a=V(Ie,e),s=document.getElementById(a);s&&(s.classList.add("footprint-overlay-fading"),yield new Promise(i=>{setTimeout(i,200);}),o.remove(),s.remove(),document.body.classList.remove(Se));}),Le=(e,t)=>{let o=V(Ae,e),n=document.createElement("div");return n.classList.add(we),n.setAttribute("id",o),t.appendChild(n),n},mt=e=>{let t=V(Ae,e),o=document.getElementById(t);o&&o.remove();},X=e=>{let t=V(xe,e),o=document.getElementById(t);o&&o.remove();},Y=(e,t)=>{let o=V(xe,t),n=ut(o);e.appendChild(n);},Re=(e,t)=>{document.body.classList.add(Se);let o=document.createElement("div"),n=V(Ie,t);return o.setAttribute("id",n),o.classList.add(Ve),e.appendChild(o),o},ut=e=>{let t=document.createElement("div");t.setAttribute("id",e),t.classList.add("footprint-loading-indicator");let o=document.createElement("div");o.classList.add("footprint-loading-spin");let n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.setAttribute("width","24px"),n.setAttribute("height","24px"),n.setAttribute("fill","none"),n.setAttribute("aria-hidden","true");let r=document.createElementNS("http://www.w3.org/2000/svg","path");return r.setAttribute("d","M12 2a10 10 0 0 1 10 10h-2a7.999 7.999 0 0 0-8-8V2Z"),n.appendChild(r),o.appendChild(n),t.appendChild(o),t},Ee=e=>{let t=document.getElementById(B(e));t&&(t.style.opacity="1",t.style.display="block");},De=e=>{let t=document.getElementById(B(e));t&&(t.style.opacity="0",t.style.display="none");},Ke=e=>{let t=document.createElement("div");t.classList.add("modal-error-container"),t.setAttribute("role","dialog"),t.setAttribute("aria-modal","true"),t.setAttribute("aria-label","Oops! Something\u2019s not quite right.");let o=document.createElement("div");o.classList.add("modal-error");let n=document.createElement("button");n.setAttribute("aria-label","Close"),n.classList.add("modal-error-close-button"),n.addEventListener("click",()=>{e.remove();});let r=document.createElementNS("http://www.w3.org/2000/svg","svg");r.setAttribute("xmlns","http://www.w3.org/2000/svg"),r.setAttribute("width","20"),r.setAttribute("height","20"),r.setAttribute("viewBox","0 0 20 20"),r.setAttribute("fill","none");let a=document.createElementNS("http://www.w3.org/2000/svg","path");a.setAttribute("d","M5 5L15 15M15 5L5 15"),a.setAttribute("stroke","black"),a.setAttribute("stroke-width","1.5"),a.setAttribute("stroke-linecap","round"),r.appendChild(a),n.appendChild(r);let s=document.createElementNS("http://www.w3.org/2000/svg","svg");s.setAttribute("xmlns","http://www.w3.org/2000/svg"),s.setAttribute("width","40"),s.setAttribute("height","40"),s.setAttribute("viewBox","0 0 40 40"),s.setAttribute("fill","none"),s.setAttribute("class","error-icon");let i=document.createElementNS("http://www.w3.org/2000/svg","path");i.setAttribute("d","M25 15L15 25M25 25L15 15M35 20C35 28.2843 28.2843 35 20 35C11.7157 35 5 28.2843 5 20C5 11.7157 11.7157 5 20 5C28.2843 5 35 11.7157 35 20Z"),i.setAttribute("stroke","black"),i.setAttribute("stroke-width","3.33333"),i.setAttribute("stroke-linecap","round"),i.setAttribute("stroke-linejoin","round"),s.appendChild(i);let p=document.createElement("h2");p.textContent="Oops! Something\u2019s not quite right.";let d=document.createElement("p");d.textContent="It looks like there was an issue loading the page. Try reloading and we\u2019ll get things back on track.",o.appendChild(n),o.appendChild(s),o.appendChild(p),o.appendChild(d),t.appendChild(o),e.appendChild(t);};var ft=()=>Math.random().toString(36).substring(2),U=ft;var _="https://api.onefootprint.com",M=D,$="footprint-js";var P={["auth"]:"auth_v1",["form"]:"form_v1",["render"]:"render_v1",["update_login_methods"]:"update_auth_methods_v1",["verify"]:"verify_v1",["verify-button"]:"verify_button_v1",["components"]:"verify_v1"};var yt=e=>e.replace(/[A-Z]/g,t=>`_${t.toLowerCase()}`),Z=e=>t=>{if(!t||typeof t!="object")return t;let o=Object.entries(t).map(([n,r])=>{let a;return Array.isArray(r)?a=r.map(Z(e)):Object(r)===r?a=Z(e)(r):a=r,[e(n),a]});return Object.fromEntries(o)},gt=Z(yt),N=gt;var ht=(e,t,o,n)=>{let r={tenantDomain:n,sdkKind:e,sdkName:$,sdkVersion:M,logLevel:o,logMessage:t,sessionId:E()};try{fetch(`${_}/org/sdk_telemetry`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(N(r))});}catch(a){}},j=ht;var F=(e,t)=>{let o=`@onefootprint/footprint-js: ${t}`;{let n;try{n=window.location.href;}catch(r){}j(e,t,"info",n);}return o},ee=(e,t)=>{let o=`@onefootprint/footprint-js: ${t}`;{let n;try{n=window.location.href;}catch(r){}j(e,t,"warn",n);}return o},H=(e,t)=>{let o=`@onefootprint/footprint-js: ${t}`;{let n;try{n=window.location.href;}catch(r){}j(e,t,"error",n);}return o};var Te={["auth"]:{["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete"},["update_login_methods"]:{["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete"},["form"]:{["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete"},["verify"]:{["auth"]:"onAuth",["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete"},["components"]:{["auth"]:"onAuth",["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete",["relayToComponents"]:"onRelayToComponents"},["verify-button"]:{["auth"]:"onAuth",["canceled"]:"onCancel",["clicked"]:"onClick",["closed"]:"onClose",["completed"]:"onComplete"},["render"]:{}},Be={["auth"]:[],["form"]:[],["render"]:[],["update_login_methods"]:[],["verify"]:[],["components"]:[],["verify-button"]:[]};var Ue={["auth"]:["modal","drawer"],["components"]:["modal"],["form"]:["inline","modal","drawer"],["render"]:["inline"],["update_login_methods"]:["modal","drawer"],["verify"]:["modal","drawer"],["verify-button"]:["inline"]},kt=Object.values(O),Ct=(...e)=>{},b=e=>e!=null&&typeof e=="object"&&!Array.isArray(e),te=e=>b(e)&&Object.keys(e).length>0,Pt=(e,t)=>{if(e==="inline"&&!t)throw new Error(`Inline component requires a containerId. Received ${t}`)},q=(e,t)=>{var r;if(!t)return;let o=(r=Ue[e])!=null?r:[];if(!o.includes(t))throw new Error(`Invalid variant: ${JSON.stringify(t)}. Valid variants for ${e} are ${o.join(", ")}`)},A=e=>{var o;let t=(o=Ue[e])!=null?o:[];if(!t.length)throw new Error(`Invalid kind: ${e}`);return t[0]},z=e=>{if(!e)throw new Error("Kind is required");let t=Object.values(K);if(!t.includes(e))throw new Error(`Invalid kind: ${e}. Valid kinds are: ${t.join(", ")}`)},_e=e=>{if(e.kind==="verify-button"){let t=e,{kind:o,appearance:n,variant:r,dialogVariant:a,onClick:s,label:i,containerId:p}=t,d=ge(t,["kind","appearance","variant","dialogVariant","onClick","label","containerId"]);return k(g({},d),{variant:a,kind:"verify"})}};var Me=(e,t)=>(Object.prototype.hasOwnProperty.call(e,t)&&typeof e[t]=="function"?e[t]:void 0)||Ct,oe=(e,t,o)=>{var i;let{kind:n}=e,r=(i=Te[n])!=null?i:{},a={},s=_e(e);return Object.entries(r).forEach(([p,d])=>{let c=p;if(!kt.includes(c))return;let C=Me(e,d),I=c==="closed"||c==="canceled",m=n==="verify-button"&&c==="clicked";a[c]=h=>{C(h),I&&(t==null||t()),m&&s&&(o==null||o(s));};}),a},L=e=>{let{kind:t,variant:o,containerId:n}=e,r=o||A(t);return z(t),q(t,o),Pt(r,n),te(e==null?void 0:e.userData)&&console.warn("userData is deprecated and will be removed in the next major version. Please use bootstrapData instead."),k(g({},e),{variant:r})},v=e=>te(e==null?void 0:e.bootstrapData)?{userData:e.bootstrapData}:te(e==null?void 0:e.userData)?{userData:e.userData}:void 0;var bt=e=>e==="auth";var vt=e=>e==="update_login_methods";var ne=e=>e.kind==="components";var re=e=>typeof e=="string"&&e.length>0,J=e=>bt(e.kind)&&!!("updateLoginMethods"in e&&e.updateLoginMethods)&&!!e.authToken&&/tok_/.test(e.authToken),wt=e=>vt(e.kind)&&!!e.authToken&&/tok_/.test(e.authToken),ae=e=>[J,wt].some(t=>t(e));var St=3,Vt=!1,At=e=>ae(e)?"update_auth_methods_v1":P[e.kind],It=e=>{var o,n;let{kind:t}=e;if(t==="verify"||t==="components")return k(g({},v(e)),{publicKey:e.publicKey,authToken:e.authToken,options:e.options,l10n:e.l10n,fixtureResult:(o=e.sandboxOutcome)==null?void 0:o.overallOutcome,documentFixtureResult:(n=e.sandboxOutcome)==null?void 0:n.documentOutcome,sandboxId:e.sandboxId,isComponentsSdk:t==="components",shouldRelayToComponents:t==="components"?e.shouldRelayToComponents:void 0});if(t==="update_login_methods")return k(g({},v(e)),{authToken:e.authToken,options:e.options,l10n:e.l10n});if(t==="auth")return J(e)?k(g({},v(e)),{authToken:e.authToken,updateLoginMethods:e.updateLoginMethods,options:e.options,l10n:e.l10n}):e.authToken&&Vt?k(g({},v(e)),{authToken:e.authToken,options:e.options,l10n:e.l10n}):k(g({},v(e)),{publicKey:e.publicKey,options:e.options,l10n:e.l10n});if(t==="form")return {authToken:e.authToken,options:e.options,title:e.title,l10n:e.l10n};if(t==="render")return {authToken:e.authToken,canCopy:e.canCopy,defaultHidden:e.defaultHidden,id:e.id,label:e.label,showHiddenToggle:e.showHiddenToggle,l10n:e.l10n};if(t==="verify-button")return k(g({},v(e)),{publicKey:e.publicKey,options:e.options,authToken:e.authToken,label:e.label,l10n:e.l10n});H(t,"Invalid kind provided");},$e=(e,t)=>u(void 0,null,function*(){return fetch(`${_}/org/sdk_args`,{method:"POST",headers:{"x-fp-client-version":`${$} ${M} ${e.kind}`.trim(),"Content-Type":"application/json"},body:JSON.stringify(e)}).then(o=>{if(o.ok)return o.json();if(t>0)return $e(e,t-1)})}),xt=e=>u(void 0,null,function*(){F(P[e.kind],"Sending SDK args");let t=It(e);if(!t)return;let o=yield $e({data:N(t),kind:At(e)},St);return o?o.token:void 0}),Ne=xt;var je=({fontSrc:e,variables:t={},rules:o={},variant:n}={})=>{let r=()=>Object.keys(t).length?encodeURIComponent(JSON.stringify(t)):void 0,a=()=>Object.keys(o).length?encodeURIComponent(JSON.stringify(o)):void 0;return {fontSrc:e,variables:r(),rules:a(),variant:n}},He=()=>{let e=window.footprintAppearance;return !e||!b(e)?{}:{fontSrc:e.fontSrc,rules:e.rules,variables:e.variables}};var qe=()=>{var e;return typeof window!="undefined"?((e=window.location)==null?void 0:e.href)||window.location.toString():""},Ot=(e,t)=>{let{appearance:o,kind:n,l10n:r,variant:a}=e,{fontSrc:s,rules:i,variables:p}=je(o),d=new URLSearchParams;return p&&d.append("variables",p),i&&d.append("rules",i),s&&d.append("font_src",s),r!=null&&r.language&&d.append("lng",r.language),d.append("variant",a||A(n)),`${d.toString()}#${t}`},Ft=(e,t)=>{let{kind:o}=e,n=Ot(e,t),r=`https://components.onefootprint.com/${o}`,a=`https://components2.onefootprint.com/${o}`;if(o==="update_login_methods"&&(r="https://auth.onefootprint.com/user",a="https://auth2.onefootprint.com/user"),o==="auth"&&(r="https://auth.onefootprint.com",a="https://auth2.onefootprint.com"),(o==="verify"||o==="verify-button"||o==="components")&&(r="https://id.onefootprint.com",a="https://id2.onefootprint.com"),!re(r))throw new Error(`${o}_URL environment variable is not defined.`);return r+=`?${n}`.trim(),a+=`?${n}`.trim(),{url:r,fallbackUrl:a}},ze=Ft;var Rt=e=>{let t=null,o=!1,n,r,{formSaveComplete:a,formSaved:s,formSaveFailed:i,started:p}=T,d=L(e),{variant:c,containerId:C}=d,I=c==="modal"||c==="drawer",m=U(),h=(l,f)=>{var S;let y=H(P[d.kind],l);(S=d.onError)==null||S.call(d,y),o&&f&&(n(),o=!1);},Ye=()=>{if(!t){h("Footprint should be initialized in order to register callback props");return}let l=oe(d,n,r);Object.entries(l).forEach(([f,y])=>{t==null||t.on(f,y),t==null||t.on(`${m}:${f}`,y);});},Ze=()=>{if(I)return Fe(m);if(!C){h("containerId is required when rendering inline");return}let l=document.getElementById(C);if(!l){h(`Could not find container with id ${C} while rendering footprint`);return}return Le(m,l)},W=(l,f)=>{if(!f){X(m),t==null||t.frame.classList.remove("fp-hide"),t==null||t.frame.classList.remove(`footprint-${c}-loading`),t==null||t.frame.classList.add(`footprint-${c}-loaded`);return}if(I){let y=Re(l,m);Y(y,m);}else Y(l,m);},de=()=>{var f;if(!t){h("Footprint should be initialized in order to set up refs");return}if(d.kind!=="form"||!d.getRef)return;let l={save:()=>(t||h("Footprint should be initialized to call ref methods"),new Promise((y,S)=>{t==null||t.on(a,()=>{y();}),t==null||t.on(i,le=>{S(le);}),t==null||t.on(`${m}:${a}`,y),t==null||t.on(`${m}:${i}`,S),t==null||t.call(s);}))};(f=d.getRef)==null||f.call(d,l);},pe=(l,f)=>u(void 0,null,function*(){try{return t=yield new Lt({classListArray:[`footprint-${c}`,`footprint-${c}-loading`,"fp-hide"],container:l,name:`footprint-iframe-${m}`,url:f,allow:"otp-credentials; publickey-credentials-get *; camera *; clipboard-write;",model:{authToken:d.authToken,initId:m,sdkUrl:qe(),sdkVersion:D||""}}),{success:!0,parentApi:t}}catch(y){return h(`Initializing iframe with ${new URL(f).host} failed with error ${y}`),{success:!1}}}),Ge=(S,le)=>u(void 0,[S,le],function*(l,{url:f,fallbackUrl:y}){F(P[d.kind],`Initializing iframe with ${new URL(f).host}`);let ce=yield pe(l,f);if(ce.success)return ce.parentApi;F(P[d.kind],`Initializing iframe with ${new URL(y).host} as fallback`);let me=yield pe(l,y);if(!me.success)throw new Error("Failed to initialize iframe");return me.parentApi});return {relayFromComponents:()=>{t&&(t.call("relayFromComponents"),Ee(m));},props:d,isRendered:o,render:()=>u(void 0,null,function*(){if(o){ee(P[d.kind],"Footprint component is already rendered");return}o=!0;let l=Ze();if(!l){ee(P[d.kind],"Unable to create container for Footprint component");return}l.hasChildNodes()&&(l.innerHTML=""),W(l,!0);let f=yield Ne(d);if(!f){h("Unable to get SDK args token.",!0),W(l,!1);return}let{url:y,fallbackUrl:S}=ze(d,f||"");try{yield Ge(l,{url:x(y),fallbackUrl:x(S)}),Ye();}catch(le){Ke(l),o=!1;}W(l,!1),t==null||t.on(p,()=>de()),t==null||t.on(`${m}:${p}`,de),d.kind==="components"&&(t==null||t.on(`${m}:${"relayToComponents"}`,()=>{De(m);}));}),destroy:()=>u(void 0,null,function*(){o&&(o=!1,yield Oe(m),t&&(t.destroy(),t=null));}),registerOnDestroy:l=>{!l||typeof l!="function"||(n=l);},registerOnRenderSecondary:l=>{!l||typeof l!="function"||(r=l);}}},se=Rt;var w=e=>{let t=L(e);return JSON.stringify(t)},Et=()=>{let e=Object.create(null);return {getOrCreate:a=>{let s=w(a.props),i=Object.values(e).find(p=>w(p.iframe.props)===s);return i?i.iframe:(e[s]={iframe:a,secondaryIframes:{}},a)},getOrCreateSecondary:(a,s)=>{let i=w(a.props),p=w(s.props);if(!e[i])throw new Error("iframe manager: primary iframe does not exist while adding secondary");let{secondaryIframes:d}=e[i],c=Object.values(d).find(C=>w(C.props)===p);return c||(d[p]=s,s)},remove:a=>{let s=w(a.props),i=e[s];i&&(Object.keys(i.secondaryIframes).forEach(p=>{i.secondaryIframes[p].destroy();}),delete e[s]);},removeSecondary:(a,s)=>{let i=w(a.props),p=w(s.props);if(!e[i])throw new Error("iframe manager: primary iframe does not exist while removing secondary");let{secondaryIframes:d}=e[i],c=d[p];c&&(c.destroy(),delete d[p]);}}},Je=Et;var Dt=()=>{let e=Je();return {init:o=>{let n=se(o),r=()=>u(void 0,null,function*(){e.remove(n),yield n.destroy();}),a=d=>u(void 0,null,function*(){e.removeSecondary(n,d),yield d.destroy();}),s=d=>u(void 0,null,function*(){let c=se(d);c=e.getOrCreateSecondary(n,c),c.registerOnDestroy(()=>{a(c);}),c.render();}),i=()=>u(void 0,null,function*(){n=e.getOrCreate(n),n.registerOnDestroy(r),n.registerOnRenderSecondary(s),yield n.render();}),p={};return ne(o)&&(p={relayFromComponents:()=>{n.relayFromComponents();}}),g({render:i,destroy:r},p)}}},Kt=Dt(),ie=Kt;var Tt=e=>{window.setTimeout(e,0);},Bt=e=>{if(typeof window=="undefined")return;let t=r=>{var i;let a=(i=window.footprintCallbacks)!=null?i:{};if(!b(a))throw Error("`window.footprintCallbacks` must be a valid mapping from callback names to functions.");return Be[r].forEach(p=>{if(!a[p])throw Error(`Callback '${p}' must be defined in window.footprintCallbacks`)}),a},o=r=>{var m;let a=r.getAttribute("data-kind");z(a);let s=(m=r.getAttribute("data-variant"))!=null?m:A(a);q(a,s);let i=He(),p=t(a),d=r.getAttribute("data-props")||"",c;try{c=JSON.parse(d);}catch(h){throw Error("Could not parse `data-props` for footprint.")}if(!b(c))throw Error("`data-props` on the footprint element has to be a valid JSON object stringified.");let C=U();r.setAttribute("id",C),e.init(g(g({kind:a,variant:s,appearance:i,containerId:r.id},p),c)).render();},n=()=>{let r=document.querySelectorAll("[data-footprint]");r.length&&r.forEach(a=>{o(a);});};document.addEventListener("DOMContentLoaded",()=>Tt(n));},We=Bt;var Ut="http://test",Qe=e=>u(void 0,null,function*(){let t=yield fetch(`${Ut}/hosted/identify/lite`,{method:"POST",body:JSON.stringify(e)});if(!t.ok)throw Error(t.statusText);return (yield t.json()).user_found}),_t=e=>u(void 0,null,function*(){if(!b(e))throw new Error("User data must be passed in order to identify an user");let t=e["id.email"],o=e["id.phone_number"];return t&&(yield Qe({email:t}))?!0:o?yield Qe({phone_number:o}):!1}),Xe=_t;var Vn=ie;We(ie);
export { K as FootprintComponentKind, T as FootprintPrivateEvent, O as FootprintPublicEvent, Vn as default, Xe as identifyFootprintUser };
(function (exports) {
'use strict';
var rt=Object.defineProperty,at=Object.defineProperties;var it=Object.getOwnPropertyDescriptors;var D=Object.getOwnPropertySymbols;var he=Object.prototype.hasOwnProperty,ve=Object.prototype.propertyIsEnumerable;var ge=(e,t,o)=>t in e?rt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,h=(e,t)=>{for(var o in t||(t={}))he.call(t,o)&&ge(e,o,t[o]);if(D)for(var o of D(t))ve.call(t,o)&&ge(e,o,t[o]);return e},k=(e,t)=>at(e,it(t));var Pe=(e,t)=>{var o={};for(var n in e)he.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&D)for(var n of D(e))t.indexOf(n)<0&&ve.call(e,n)&&(o[n]=e[n]);return o};var u=(e,t,o)=>new Promise((n,r)=>{var i=p=>{try{s(o.next(p));}catch(d){r(d);}},a=p=>{try{s(o.throw(p));}catch(d){r(d);}},s=p=>p.done?n(p.value):Promise.resolve(p.value).then(i,a);s((o=o.apply(e,t)).next());});var ke="fp-session-id",Ce=typeof window!="undefined",Y="xfpsessionid",dt=()=>"10000000-1000-4000-8000-100000000000".replace(/[018]/g,e=>(+e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+e/4).toString(16)),we=(e,t)=>new URL(t).searchParams.get(e),pt=e=>{var t,o;try{let n=(o=(t=window==null?void 0:window.top)==null?void 0:t.location)==null?void 0:o.href;return n?we(e,n):null}catch(n){return null}},be=e=>Ce?we(e,window.location.href)||pt(e):null,Ve=()=>{if((!Ce||!window.sessionStorage))return !1;try{let e="test";return sessionStorage.setItem(e,e),sessionStorage.removeItem(e),!0}catch(e){return !1}},lt=()=>{let e=be(Y)||dt();if(Ve())try{sessionStorage.setItem(ke,e);}catch(t){console.error("Failed to create session id",t);}return e},ct=()=>{let e=be(Y);return e||(Ve()?sessionStorage.getItem(ke):null)},Se=()=>ct()||lt(),x=(e,t=Se())=>{let o=new URL(e);return o.searchParams.set(Y,t),o.toString()};var K=Se;var E="application/x-postmate-v1+json",ut=5,ft=0,yt=function(){return ++ft};var gt=function(t){var o=document.createElement("a");o.href=t;var n=o.protocol.length>4?o.protocol:window.location.protocol,r=o.host.length?o.port==="80"||o.port==="443"?o.hostname:o.host:window.location.host;return o.origin||n+"//"+r},ht={handshake:1,"handshake-reply":1,call:1,emit:1,reply:1,request:1},Z=function(t,o){return !(typeof o=="string"&&t.origin!==o||!t.data||typeof t.data=="object"&&!("postmate"in t.data)||t.data.type!==E||!ht[t.data.postmate])},vt=function(t,o){var n=typeof t[o]=="function"?t[o]():t[o];return O.Promise.resolve(n)},Pt=function(){function e(o){var n=this;this.parent=o.parent,this.frame=o.frame,this.child=o.child,this.childOrigin=o.childOrigin,this.events={},this.listener=function(r){if(!Z(r,n.childOrigin))return !1;var i=((r||{}).data||{}).value||{},a=i.data,s=i.name;r.data.postmate==="emit"&&s in n.events&&n.events[s].forEach(function(p){p.call(n,a);});},this.parent.addEventListener("message",this.listener,!1);}var t=e.prototype;return t.get=function(n){var r=this;return new O.Promise(function(i){var a=yt(),s=function p(d){d.data.uid===a&&d.data.postmate==="reply"&&(r.parent.removeEventListener("message",p,!1),i(d.data.value));};r.parent.addEventListener("message",s,!1),r.child.postMessage({postmate:"request",type:E,property:n,uid:a},r.childOrigin);})},t.call=function(n,r){this.child.postMessage({postmate:"call",type:E,property:n,data:r},this.childOrigin);},t.on=function(n,r){this.events[n]||(this.events[n]=[]),this.events[n].push(r);},t.destroy=function(){window.removeEventListener("message",this.listener,!1),this.frame.parentNode.removeChild(this.frame);},e}(),kt=function(){function e(o){var n=this;this.model=o.model,this.parent=o.parent,this.parentOrigin=o.parentOrigin,this.child=o.child,this.child.addEventListener("message",function(r){if(Z(r,n.parentOrigin)){var i=r.data,a=i.property,s=i.uid,p=i.data;if(r.data.postmate==="call"){a in n.model&&typeof n.model[a]=="function"&&n.model[a](p);return}vt(n.model,a).then(function(d){return r.source.postMessage({property:a,postmate:"reply",type:E,uid:s,value:d},r.origin)});}});}var t=e.prototype;return t.emit=function(n,r){this.parent.postMessage({postmate:"emit",type:E,value:{name:n,data:r}},this.parentOrigin);},e}(),O=function(){function e(o){var n=o.container,r=n===void 0?typeof r!="undefined"?r:document.body:n,i=o.model,a=o.url,s=o.name,p=s===void 0?"":s,d=o.allow,l=o.id,g=o.classListArray,P=g===void 0?[]:g;return this.parent=window,this.frame=document.createElement("iframe"),this.frame.name=p||"",this.frame.classList.add.apply(this.frame.classList,P),d&&(this.frame.allow=d),l&&(this.frame.id=l),r.appendChild(this.frame),this.child=this.frame.contentWindow||this.frame.contentDocument.parentWindow,this.model=i||{},this.sendHandshake(a)}var t=e.prototype;return t.sendHandshake=function(n){var r=this,i=gt(n),a=0,s;return new e.Promise(function(p,d){var l=function m(v){return Z(v,i)?v.data.postmate==="handshake-reply"?(clearInterval(s),r.parent.removeEventListener("message",m,!1),r.childOrigin=v.origin,p(new Pt(r))):d("Failed handshake"):!1};r.parent.addEventListener("message",l,!1);var g=function(){if(a++,r.child.postMessage({postmate:"handshake",type:E,model:r.model},i),a===ut)return clearInterval(s),d("Failed to handshake")},P=function(){g(),s=setInterval(g,500);};r.frame.attachEvent?r.frame.attachEvent("onload",P):r.frame.addEventListener("load",P),r.frame.src=n;})},e}();O.debug=!1;O.Promise=function(){try{return window?window.Promise:Promise}catch(e){return null}}();O.Model=function(){function e(o){return this.child=window,this.model=o,this.parent=this.child.parent,this.sendHandshakeReply()}var t=e.prototype;return t.sendHandshakeReply=function(){var n=this;return new O.Promise(function(r,i){var a=function s(p){if(p.data.postmate){if(p.data.postmate==="handshake"){n.child.removeEventListener("message",s,!1),p.source.postMessage({postmate:"handshake-reply",type:E},p.origin),n.parentOrigin=p.origin;var d=p.data.model;return d&&Object.keys(d).forEach(function(l){n.model[l]=d[l];}),r(new kt(n))}return i("Handshake Reply Failed")}};n.child.addEventListener("message",a,!1);})},e}();var Ee=O;var _="3.14.2";var T=(s=>(s.Auth="auth",s.Components="components",s.Form="form",s.Render="render",s.UpdateLoginMethods="update_login_methods",s.Verify="verify",s.VerifyButton="verify-button",s))(T||{});var L=(a=>(a.auth="auth",a.canceled="canceled",a.clicked="clicked",a.closed="closed",a.completed="completed",a.relayToComponents="relayToComponents",a))(L||{}),B=(a=>(a.formSaveComplete="formSaveComplete",a.formSaveFailed="formSaveFailed",a.formSaved="formSaved",a.propsReceived="propsReceived",a.started="started",a.relayFromComponents="relayFromComponents",a))(B||{});var Oe="footprint-inline-container",Ae="footprint-body-locked",Ie="footprint-overlay",wt="footprint-overlay-container",xe=Oe,Le=Ie,Fe="footprint-loading-indicator",U=e=>`${wt}-${e}`,A=(e,t)=>`${e}-${t}`,Re=e=>u(void 0,null,function*(){G(e),Vt(e),yield bt(e);}),De=e=>{let t=U(e),o=document.getElementById(t);if(o)return o;let n=document.createElement("div");return n.setAttribute("id",t),document.body.appendChild(n),n},bt=e=>u(void 0,null,function*(){let t=U(e),o=document.getElementById(t);if(!o)return;let n=o.querySelector("iframe.footprint-drawer");n&&(n==null||n.classList.add("footprint-drawer-closing"),yield new Promise(s=>{setTimeout(s,300);}));let r=o.querySelector("iframe.footprint-modal");r&&(r==null||r.classList.add("footprint-modal-closing"),yield new Promise(s=>{setTimeout(s,100);}));let i=A(Le,e),a=document.getElementById(i);a&&(a.classList.add("footprint-overlay-fading"),yield new Promise(s=>{setTimeout(s,200);}),o.remove(),a.remove(),document.body.classList.remove(Ae));}),Ke=(e,t)=>{let o=A(xe,e),n=document.createElement("div");return n.classList.add(Oe),n.setAttribute("id",o),t.appendChild(n),n},Vt=e=>{let t=A(xe,e),o=document.getElementById(t);o&&o.remove();},G=e=>{let t=A(Fe,e),o=document.getElementById(t);o&&o.remove();},ee=(e,t)=>{let o=A(Fe,t),n=St(o);e.appendChild(n);},_e=(e,t)=>{document.body.classList.add(Ae);let o=document.createElement("div"),n=A(Le,t);return o.setAttribute("id",n),o.classList.add(Ie),e.appendChild(o),o},St=e=>{let t=document.createElement("div");t.setAttribute("id",e),t.classList.add("footprint-loading-indicator");let o=document.createElement("div");o.classList.add("footprint-loading-spin");let n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.setAttribute("width","24px"),n.setAttribute("height","24px"),n.setAttribute("fill","none"),n.setAttribute("aria-hidden","true");let r=document.createElementNS("http://www.w3.org/2000/svg","path");return r.setAttribute("d","M12 2a10 10 0 0 1 10 10h-2a7.999 7.999 0 0 0-8-8V2Z"),n.appendChild(r),o.appendChild(n),t.appendChild(o),t},Te=e=>{let t=document.getElementById(U(e));t&&(t.style.opacity="1",t.style.display="block");},Be=e=>{let t=document.getElementById(U(e));t&&(t.style.opacity="0",t.style.display="none");},Ue=e=>{let t=document.createElement("div");t.classList.add("modal-error-container"),t.setAttribute("role","dialog"),t.setAttribute("aria-modal","true"),t.setAttribute("aria-label","Oops! Something\u2019s not quite right.");let o=document.createElement("div");o.classList.add("modal-error");let n=document.createElement("button");n.setAttribute("aria-label","Close"),n.classList.add("modal-error-close-button"),n.addEventListener("click",()=>{e.remove();});let r=document.createElementNS("http://www.w3.org/2000/svg","svg");r.setAttribute("xmlns","http://www.w3.org/2000/svg"),r.setAttribute("width","20"),r.setAttribute("height","20"),r.setAttribute("viewBox","0 0 20 20"),r.setAttribute("fill","none");let i=document.createElementNS("http://www.w3.org/2000/svg","path");i.setAttribute("d","M5 5L15 15M15 5L5 15"),i.setAttribute("stroke","black"),i.setAttribute("stroke-width","1.5"),i.setAttribute("stroke-linecap","round"),r.appendChild(i),n.appendChild(r);let a=document.createElementNS("http://www.w3.org/2000/svg","svg");a.setAttribute("xmlns","http://www.w3.org/2000/svg"),a.setAttribute("width","40"),a.setAttribute("height","40"),a.setAttribute("viewBox","0 0 40 40"),a.setAttribute("fill","none"),a.setAttribute("class","error-icon");let s=document.createElementNS("http://www.w3.org/2000/svg","path");s.setAttribute("d","M25 15L15 25M25 25L15 15M35 20C35 28.2843 28.2843 35 20 35C11.7157 35 5 28.2843 5 20C5 11.7157 11.7157 5 20 5C28.2843 5 35 11.7157 35 20Z"),s.setAttribute("stroke","black"),s.setAttribute("stroke-width","3.33333"),s.setAttribute("stroke-linecap","round"),s.setAttribute("stroke-linejoin","round"),a.appendChild(s);let p=document.createElement("h2");p.textContent="Oops! Something\u2019s not quite right.";let d=document.createElement("p");d.textContent="It looks like there was an issue loading the page. Try reloading and we\u2019ll get things back on track.",o.appendChild(n),o.appendChild(a),o.appendChild(p),o.appendChild(d),t.appendChild(o),e.appendChild(t);};var Et=()=>Math.random().toString(36).substring(2),M=Et;var N="https://api.onefootprint.com",$=_,H="footprint-js";var C={["auth"]:"auth_v1",["form"]:"form_v1",["render"]:"render_v1",["update_login_methods"]:"update_auth_methods_v1",["verify"]:"verify_v1",["verify-button"]:"verify_button_v1",["components"]:"verify_v1"};var Ot=e=>e.replace(/[A-Z]/g,t=>`_${t.toLowerCase()}`),te=e=>t=>{if(!t||typeof t!="object")return t;let o=Object.entries(t).map(([n,r])=>{let i;return Array.isArray(r)?i=r.map(te(e)):Object(r)===r?i=te(e)(r):i=r,[e(n),i]});return Object.fromEntries(o)},At=te(Ot),j=At;var It=(e,t,o,n)=>{let r={tenantDomain:n,sdkKind:e,sdkName:H,sdkVersion:$,logLevel:o,logMessage:t,sessionId:K()};try{fetch(`${N}/org/sdk_telemetry`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(j(r))});}catch(i){}},q=It;var F=(e,t)=>{let o=`@onefootprint/footprint-js: ${t}`;{let n;try{n=window.location.href;}catch(r){}q(e,t,"info",n);}return o},ne=(e,t)=>{let o=`@onefootprint/footprint-js: ${t}`;{let n;try{n=window.location.href;}catch(r){}q(e,t,"warn",n);}return o},z=(e,t)=>{let o=`@onefootprint/footprint-js: ${t}`;{let n;try{n=window.location.href;}catch(r){}q(e,t,"error",n);}return o};var Me={["auth"]:{["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete"},["update_login_methods"]:{["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete"},["form"]:{["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete"},["verify"]:{["auth"]:"onAuth",["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete"},["components"]:{["auth"]:"onAuth",["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete",["relayToComponents"]:"onRelayToComponents"},["verify-button"]:{["auth"]:"onAuth",["canceled"]:"onCancel",["clicked"]:"onClick",["closed"]:"onClose",["completed"]:"onComplete"},["render"]:{}},Ne={["auth"]:[],["form"]:[],["render"]:[],["update_login_methods"]:[],["verify"]:[],["components"]:[],["verify-button"]:[]};var $e={["auth"]:["modal","drawer"],["components"]:["modal"],["form"]:["inline","modal","drawer"],["render"]:["inline"],["update_login_methods"]:["modal","drawer"],["verify"]:["modal","drawer"],["verify-button"]:["inline"]},xt=Object.values(L),Lt=(...e)=>{},w=e=>e!=null&&typeof e=="object"&&!Array.isArray(e),re=e=>w(e)&&Object.keys(e).length>0,Ft=(e,t)=>{if(e==="inline"&&!t)throw new Error(`Inline component requires a containerId. Received ${t}`)},W=(e,t)=>{var r;if(!t)return;let o=(r=$e[e])!=null?r:[];if(!o.includes(t))throw new Error(`Invalid variant: ${JSON.stringify(t)}. Valid variants for ${e} are ${o.join(", ")}`)},I=e=>{var o;let t=(o=$e[e])!=null?o:[];if(!t.length)throw new Error(`Invalid kind: ${e}`);return t[0]},J=e=>{if(!e)throw new Error("Kind is required");let t=Object.values(T);if(!t.includes(e))throw new Error(`Invalid kind: ${e}. Valid kinds are: ${t.join(", ")}`)},He=e=>{if(e.kind==="verify-button"){let t=e,{kind:o,appearance:n,variant:r,dialogVariant:i,onClick:a,label:s,containerId:p}=t,d=Pe(t,["kind","appearance","variant","dialogVariant","onClick","label","containerId"]);return k(h({},d),{variant:i,kind:"verify"})}};var je=(e,t)=>(Object.prototype.hasOwnProperty.call(e,t)&&typeof e[t]=="function"?e[t]:void 0)||Lt,ae=(e,t,o)=>{var s;let{kind:n}=e,r=(s=Me[n])!=null?s:{},i={},a=He(e);return Object.entries(r).forEach(([p,d])=>{let l=p;if(!xt.includes(l))return;let g=je(e,d),P=l==="closed"||l==="canceled",m=n==="verify-button"&&l==="clicked";i[l]=v=>{g(v),P&&(t==null||t()),m&&a&&(o==null||o(a));};}),i},R=e=>{let{kind:t,variant:o,containerId:n}=e,r=o||I(t);return J(t),W(t,o),Ft(r,n),re(e==null?void 0:e.userData)&&console.warn("userData is deprecated and will be removed in the next major version. Please use bootstrapData instead."),k(h({},e),{variant:r})},b=e=>re(e==null?void 0:e.bootstrapData)?{userData:e.bootstrapData}:re(e==null?void 0:e.userData)?{userData:e.userData}:void 0;var Rt=e=>e==="auth";var Dt=e=>e==="update_login_methods";var ie=e=>e.kind==="components";var se=e=>typeof e=="string"&&e.length>0,Q=e=>Rt(e.kind)&&!!("updateLoginMethods"in e&&e.updateLoginMethods)&&!!e.authToken&&/tok_/.test(e.authToken),Kt=e=>Dt(e.kind)&&!!e.authToken&&/tok_/.test(e.authToken),de=e=>[Q,Kt].some(t=>t(e));var _t=3,Tt=!1,Bt=e=>de(e)?"update_auth_methods_v1":C[e.kind],Ut=e=>{var o,n;let{kind:t}=e;if(t==="verify"||t==="components")return k(h({},b(e)),{publicKey:e.publicKey,authToken:e.authToken,options:e.options,l10n:e.l10n,fixtureResult:(o=e.sandboxOutcome)==null?void 0:o.overallOutcome,documentFixtureResult:(n=e.sandboxOutcome)==null?void 0:n.documentOutcome,sandboxId:e.sandboxId,isComponentsSdk:t==="components"});if(t==="update_login_methods")return k(h({},b(e)),{authToken:e.authToken,options:e.options,l10n:e.l10n});if(t==="auth")return Q(e)?k(h({},b(e)),{authToken:e.authToken,updateLoginMethods:e.updateLoginMethods,options:e.options,l10n:e.l10n}):e.authToken&&Tt?k(h({},b(e)),{authToken:e.authToken,options:e.options,l10n:e.l10n}):k(h({},b(e)),{publicKey:e.publicKey,options:e.options,l10n:e.l10n});if(t==="form")return {authToken:e.authToken,options:e.options,title:e.title,l10n:e.l10n};if(t==="render")return {authToken:e.authToken,canCopy:e.canCopy,defaultHidden:e.defaultHidden,id:e.id,label:e.label,showHiddenToggle:e.showHiddenToggle,l10n:e.l10n};if(t==="verify-button")return k(h({},b(e)),{publicKey:e.publicKey,options:e.options,authToken:e.authToken,label:e.label,l10n:e.l10n});z(t,"Invalid kind provided");},qe=(e,t)=>u(void 0,null,function*(){return fetch(`${N}/org/sdk_args`,{method:"POST",headers:{"x-fp-client-version":`${H} ${$} ${e.kind}`.trim(),"Content-Type":"application/json"},body:JSON.stringify(e)}).then(o=>{if(o.ok)return o.json();if(t>0)return qe(e,t-1)})}),Mt=e=>u(void 0,null,function*(){F(C[e.kind],"Sending SDK args");let t=Ut(e);if(!t)return;let o=yield qe({data:j(t),kind:Bt(e)},_t);return o?o.token:void 0}),ze=Mt;var We=({fontSrc:e,variables:t={},rules:o={},variant:n}={})=>{let r=()=>Object.keys(t).length?encodeURIComponent(JSON.stringify(t)):void 0,i=()=>Object.keys(o).length?encodeURIComponent(JSON.stringify(o)):void 0;return {fontSrc:e,variables:r(),rules:i(),variant:n}},Je=()=>{let e=window.footprintAppearance;return !e||!w(e)?{}:{fontSrc:e.fontSrc,rules:e.rules,variables:e.variables}};var Qe=()=>{var e;return typeof window!="undefined"?((e=window.location)==null?void 0:e.href)||window.location.toString():""},Nt=(e,t)=>{let{appearance:o,kind:n,l10n:r,variant:i}=e,{fontSrc:a,rules:s,variables:p}=We(o),d=new URLSearchParams;return p&&d.append("variables",p),s&&d.append("rules",s),a&&d.append("font_src",a),r!=null&&r.language&&d.append("lng",r.language),d.append("variant",i||I(n)),`${d.toString()}#${t}`},$t=(e,t)=>{let{kind:o}=e,n=Nt(e,t),r=`https://components.onefootprint.com/${o}`,i=`https://components2.onefootprint.com/${o}`;if(o==="update_login_methods"&&(r="https://auth.onefootprint.com/user",i="https://auth2.onefootprint.com/user"),o==="auth"&&(r="https://auth.onefootprint.com",i="https://auth2.onefootprint.com"),(o==="verify"||o==="verify-button"||o==="components")&&(r="https://id.onefootprint.com",i="https://id2.onefootprint.com"),!se(r))throw new Error(`${o}_URL environment variable is not defined.`);return r+=`?${n}`.trim(),i+=`?${n}`.trim(),{url:r,fallbackUrl:i}},Xe=$t;var Ht=e=>{let t=null,o=!1,n,r,{formSaveComplete:i,formSaved:a,formSaveFailed:s,started:p}=B,d=R(e),{variant:l,containerId:g}=d,P=l==="modal"||l==="drawer",m=M(),v=(c,f)=>{var S;let y=z(C[d.kind],c);(S=d.onError)==null||S.call(d,y),o&&f&&(n(),o=!1);},tt=()=>{if(!t){v("Footprint should be initialized in order to register callback props");return}let c=ae(d,n,r);Object.entries(c).forEach(([f,y])=>{t==null||t.on(f,y),t==null||t.on(`${m}:${f}`,y);});},ot=()=>{if(P)return De(m);if(!g){v("containerId is required when rendering inline");return}let c=document.getElementById(g);if(!c){v(`Could not find container with id ${g} while rendering footprint`);return}return Ke(m,c)},X=(c,f)=>{if(!f){G(m),t==null||t.frame.classList.remove("fp-hide"),t==null||t.frame.classList.remove(`footprint-${l}-loading`),t==null||t.frame.classList.add(`footprint-${l}-loaded`);return}if(P){let y=_e(c,m);ee(y,m);}else ee(c,m);},ce=()=>{var f;if(!t){v("Footprint should be initialized in order to set up refs");return}if(d.kind!=="form"||!d.getRef)return;let c={save:()=>(t||v("Footprint should be initialized to call ref methods"),new Promise((y,S)=>{t==null||t.on(i,()=>{y();}),t==null||t.on(s,ue=>{S(ue);}),t==null||t.on(`${m}:${i}`,y),t==null||t.on(`${m}:${s}`,S),t==null||t.call(a);}))};(f=d.getRef)==null||f.call(d,c);},me=(c,f)=>u(void 0,null,function*(){try{return t=yield new Ee({classListArray:[`footprint-${l}`,`footprint-${l}-loading`,"fp-hide"],container:c,name:`footprint-iframe-${m}`,url:f,allow:"otp-credentials; publickey-credentials-get *; camera *; clipboard-write;",model:{authToken:d.authToken,initId:m,sdkUrl:Qe(),sdkVersion:_||""}}),{success:!0,parentApi:t}}catch(y){return v(`Initializing iframe with ${new URL(f).host} failed with error ${y}`),{success:!1}}}),nt=(S,ue)=>u(void 0,[S,ue],function*(c,{url:f,fallbackUrl:y}){F(C[d.kind],`Initializing iframe with ${new URL(f).host}`);let fe=yield me(c,f);if(fe.success)return fe.parentApi;F(C[d.kind],`Initializing iframe with ${new URL(y).host} as fallback`);let ye=yield me(c,y);if(!ye.success)throw new Error("Failed to initialize iframe");return ye.parentApi});return {relayFromComponents:()=>{t&&(t.call("relayFromComponents"),Te(m));},props:d,isRendered:o,render:()=>u(void 0,null,function*(){if(o){ne(C[d.kind],"Footprint component is already rendered");return}o=!0;let c=ot();if(!c){ne(C[d.kind],"Unable to create container for Footprint component");return}c.hasChildNodes()&&(c.innerHTML=""),X(c,!0);let f=yield ze(d);if(!f){v("Unable to get SDK args token.",!0),X(c,!1);return}let{url:y,fallbackUrl:S}=Xe(d,f||"");try{yield nt(c,{url:x(y),fallbackUrl:x(S)}),tt();}catch(ue){Ue(c),o=!1;}X(c,!1),t==null||t.on(p,()=>ce()),t==null||t.on(`${m}:${p}`,ce),d.kind==="components"&&(t==null||t.on(`${m}:${"relayToComponents"}`,()=>{Be(m);}));}),destroy:()=>u(void 0,null,function*(){o&&(o=!1,yield Re(m),t&&(t.destroy(),t=null));}),registerOnDestroy:c=>{!c||typeof c!="function"||(n=c);},registerOnRenderSecondary:c=>{!c||typeof c!="function"||(r=c);}}},pe=Ht;var V=e=>{let t=R(e);return JSON.stringify(t)},jt=()=>{let e=Object.create(null);return {getOrCreate:i=>{let a=V(i.props),s=Object.values(e).find(p=>V(p.iframe.props)===a);return s?s.iframe:(e[a]={iframe:i,secondaryIframes:{}},i)},getOrCreateSecondary:(i,a)=>{let s=V(i.props),p=V(a.props);if(!e[s])throw new Error("iframe manager: primary iframe does not exist while adding secondary");let{secondaryIframes:d}=e[s],l=Object.values(d).find(g=>V(g.props)===p);return l||(d[p]=a,a)},remove:i=>{let a=V(i.props),s=e[a];s&&(Object.keys(s.secondaryIframes).forEach(p=>{s.secondaryIframes[p].destroy();}),delete e[a]);},removeSecondary:(i,a)=>{let s=V(i.props),p=V(a.props);if(!e[s])throw new Error("iframe manager: primary iframe does not exist while removing secondary");let{secondaryIframes:d}=e[s],l=d[p];l&&(l.destroy(),delete d[p]);}}},Ye=jt;var qt=()=>{let e=Ye();return {init:o=>{let n=pe(o),r=()=>u(void 0,null,function*(){e.remove(n),yield n.destroy();}),i=d=>u(void 0,null,function*(){e.removeSecondary(n,d),yield d.destroy();}),a=d=>u(void 0,null,function*(){let l=pe(d);l=e.getOrCreateSecondary(n,l),l.registerOnDestroy(()=>{i(l);}),l.render();}),s=()=>u(void 0,null,function*(){n=e.getOrCreate(n),n.registerOnDestroy(r),n.registerOnRenderSecondary(a),yield n.render();}),p={};return ie(o)&&(p={relayFromComponents:()=>{n.relayFromComponents();}}),h({render:s,destroy:r},p)}}},zt=qt(),le=zt;var Wt=e=>{window.setTimeout(e,0);},Jt=e=>{if(typeof window=="undefined")return;let t=r=>{var s;let i=(s=window.footprintCallbacks)!=null?s:{};if(!w(i))throw Error("`window.footprintCallbacks` must be a valid mapping from callback names to functions.");return Ne[r].forEach(p=>{if(!i[p])throw Error(`Callback '${p}' must be defined in window.footprintCallbacks`)}),i},o=r=>{var m;let i=r.getAttribute("data-kind");J(i);let a=(m=r.getAttribute("data-variant"))!=null?m:I(i);W(i,a);let s=Je(),p=t(i),d=r.getAttribute("data-props")||"",l;try{l=JSON.parse(d);}catch(v){throw Error("Could not parse `data-props` for footprint.")}if(!w(l))throw Error("`data-props` on the footprint element has to be a valid JSON object stringified.");let g=M();r.setAttribute("id",g),e.init(h(h({kind:i,variant:a,appearance:s,containerId:r.id},p),l)).render();},n=()=>{let r=document.querySelectorAll("[data-footprint]");r.length&&r.forEach(i=>{o(i);});};document.addEventListener("DOMContentLoaded",()=>Wt(n));},Ze=Jt;var Qt="http://test",Ge=e=>u(void 0,null,function*(){let t=yield fetch(`${Qt}/hosted/identify/lite`,{method:"POST",body:JSON.stringify(e)});if(!t.ok)throw Error(t.statusText);return (yield t.json()).user_found}),Xt=e=>u(void 0,null,function*(){if(!w(e))throw new Error("User data must be passed in order to identify an user");let t=e["id.email"],o=e["id.phone_number"];return t&&(yield Ge({email:t}))?!0:o?yield Ge({phone_number:o}):!1}),et=Xt;var Tn=le;Ze(le);/*! Bundled license information:
var rt=Object.defineProperty,at=Object.defineProperties;var it=Object.getOwnPropertyDescriptors;var D=Object.getOwnPropertySymbols;var he=Object.prototype.hasOwnProperty,ve=Object.prototype.propertyIsEnumerable;var ge=(e,t,o)=>t in e?rt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,h=(e,t)=>{for(var o in t||(t={}))he.call(t,o)&&ge(e,o,t[o]);if(D)for(var o of D(t))ve.call(t,o)&&ge(e,o,t[o]);return e},k=(e,t)=>at(e,it(t));var Pe=(e,t)=>{var o={};for(var n in e)he.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&D)for(var n of D(e))t.indexOf(n)<0&&ve.call(e,n)&&(o[n]=e[n]);return o};var u=(e,t,o)=>new Promise((n,r)=>{var i=p=>{try{s(o.next(p));}catch(d){r(d);}},a=p=>{try{s(o.throw(p));}catch(d){r(d);}},s=p=>p.done?n(p.value):Promise.resolve(p.value).then(i,a);s((o=o.apply(e,t)).next());});var ke="fp-session-id",Ce=typeof window!="undefined",Y="xfpsessionid",dt=()=>"10000000-1000-4000-8000-100000000000".replace(/[018]/g,e=>(+e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+e/4).toString(16)),we=(e,t)=>new URL(t).searchParams.get(e),pt=e=>{var t,o;try{let n=(o=(t=window==null?void 0:window.top)==null?void 0:t.location)==null?void 0:o.href;return n?we(e,n):null}catch(n){return null}},be=e=>Ce?we(e,window.location.href)||pt(e):null,Ve=()=>{if((!Ce||!window.sessionStorage))return !1;try{let e="test";return sessionStorage.setItem(e,e),sessionStorage.removeItem(e),!0}catch(e){return !1}},lt=()=>{let e=be(Y)||dt();if(Ve())try{sessionStorage.setItem(ke,e);}catch(t){console.error("Failed to create session id",t);}return e},ct=()=>{let e=be(Y);return e||(Ve()?sessionStorage.getItem(ke):null)},Se=()=>ct()||lt(),x=(e,t=Se())=>{let o=new URL(e);return o.searchParams.set(Y,t),o.toString()};var K=Se;var E="application/x-postmate-v1+json",ut=5,ft=0,yt=function(){return ++ft};var gt=function(t){var o=document.createElement("a");o.href=t;var n=o.protocol.length>4?o.protocol:window.location.protocol,r=o.host.length?o.port==="80"||o.port==="443"?o.hostname:o.host:window.location.host;return o.origin||n+"//"+r},ht={handshake:1,"handshake-reply":1,call:1,emit:1,reply:1,request:1},Z=function(t,o){return !(typeof o=="string"&&t.origin!==o||!t.data||typeof t.data=="object"&&!("postmate"in t.data)||t.data.type!==E||!ht[t.data.postmate])},vt=function(t,o){var n=typeof t[o]=="function"?t[o]():t[o];return O.Promise.resolve(n)},Pt=function(){function e(o){var n=this;this.parent=o.parent,this.frame=o.frame,this.child=o.child,this.childOrigin=o.childOrigin,this.events={},this.listener=function(r){if(!Z(r,n.childOrigin))return !1;var i=((r||{}).data||{}).value||{},a=i.data,s=i.name;r.data.postmate==="emit"&&s in n.events&&n.events[s].forEach(function(p){p.call(n,a);});},this.parent.addEventListener("message",this.listener,!1);}var t=e.prototype;return t.get=function(n){var r=this;return new O.Promise(function(i){var a=yt(),s=function p(d){d.data.uid===a&&d.data.postmate==="reply"&&(r.parent.removeEventListener("message",p,!1),i(d.data.value));};r.parent.addEventListener("message",s,!1),r.child.postMessage({postmate:"request",type:E,property:n,uid:a},r.childOrigin);})},t.call=function(n,r){this.child.postMessage({postmate:"call",type:E,property:n,data:r},this.childOrigin);},t.on=function(n,r){this.events[n]||(this.events[n]=[]),this.events[n].push(r);},t.destroy=function(){window.removeEventListener("message",this.listener,!1),this.frame.parentNode.removeChild(this.frame);},e}(),kt=function(){function e(o){var n=this;this.model=o.model,this.parent=o.parent,this.parentOrigin=o.parentOrigin,this.child=o.child,this.child.addEventListener("message",function(r){if(Z(r,n.parentOrigin)){var i=r.data,a=i.property,s=i.uid,p=i.data;if(r.data.postmate==="call"){a in n.model&&typeof n.model[a]=="function"&&n.model[a](p);return}vt(n.model,a).then(function(d){return r.source.postMessage({property:a,postmate:"reply",type:E,uid:s,value:d},r.origin)});}});}var t=e.prototype;return t.emit=function(n,r){this.parent.postMessage({postmate:"emit",type:E,value:{name:n,data:r}},this.parentOrigin);},e}(),O=function(){function e(o){var n=o.container,r=n===void 0?typeof r!="undefined"?r:document.body:n,i=o.model,a=o.url,s=o.name,p=s===void 0?"":s,d=o.allow,l=o.id,g=o.classListArray,P=g===void 0?[]:g;return this.parent=window,this.frame=document.createElement("iframe"),this.frame.name=p||"",this.frame.classList.add.apply(this.frame.classList,P),d&&(this.frame.allow=d),l&&(this.frame.id=l),r.appendChild(this.frame),this.child=this.frame.contentWindow||this.frame.contentDocument.parentWindow,this.model=i||{},this.sendHandshake(a)}var t=e.prototype;return t.sendHandshake=function(n){var r=this,i=gt(n),a=0,s;return new e.Promise(function(p,d){var l=function m(v){return Z(v,i)?v.data.postmate==="handshake-reply"?(clearInterval(s),r.parent.removeEventListener("message",m,!1),r.childOrigin=v.origin,p(new Pt(r))):d("Failed handshake"):!1};r.parent.addEventListener("message",l,!1);var g=function(){if(a++,r.child.postMessage({postmate:"handshake",type:E,model:r.model},i),a===ut)return clearInterval(s),d("Failed to handshake")},P=function(){g(),s=setInterval(g,500);};r.frame.attachEvent?r.frame.attachEvent("onload",P):r.frame.addEventListener("load",P),r.frame.src=n;})},e}();O.debug=!1;O.Promise=function(){try{return window?window.Promise:Promise}catch(e){return null}}();O.Model=function(){function e(o){return this.child=window,this.model=o,this.parent=this.child.parent,this.sendHandshakeReply()}var t=e.prototype;return t.sendHandshakeReply=function(){var n=this;return new O.Promise(function(r,i){var a=function s(p){if(p.data.postmate){if(p.data.postmate==="handshake"){n.child.removeEventListener("message",s,!1),p.source.postMessage({postmate:"handshake-reply",type:E},p.origin),n.parentOrigin=p.origin;var d=p.data.model;return d&&Object.keys(d).forEach(function(l){n.model[l]=d[l];}),r(new kt(n))}return i("Handshake Reply Failed")}};n.child.addEventListener("message",a,!1);})},e}();var Ee=O;var T="3.15.0";var _=(s=>(s.Auth="auth",s.Components="components",s.Form="form",s.Render="render",s.UpdateLoginMethods="update_login_methods",s.Verify="verify",s.VerifyButton="verify-button",s))(_||{});var L=(a=>(a.auth="auth",a.canceled="canceled",a.clicked="clicked",a.closed="closed",a.completed="completed",a.relayToComponents="relayToComponents",a))(L||{}),B=(a=>(a.formSaveComplete="formSaveComplete",a.formSaveFailed="formSaveFailed",a.formSaved="formSaved",a.propsReceived="propsReceived",a.started="started",a.relayFromComponents="relayFromComponents",a))(B||{});var Oe="footprint-inline-container",Ae="footprint-body-locked",Ie="footprint-overlay",wt="footprint-overlay-container",xe=Oe,Le=Ie,Re="footprint-loading-indicator",U=e=>`${wt}-${e}`,A=(e,t)=>`${e}-${t}`,Fe=e=>u(void 0,null,function*(){G(e),Vt(e),yield bt(e);}),De=e=>{let t=U(e),o=document.getElementById(t);if(o)return o;let n=document.createElement("div");return n.setAttribute("id",t),document.body.appendChild(n),n},bt=e=>u(void 0,null,function*(){let t=U(e),o=document.getElementById(t);if(!o)return;let n=o.querySelector("iframe.footprint-drawer");n&&(n==null||n.classList.add("footprint-drawer-closing"),yield new Promise(s=>{setTimeout(s,300);}));let r=o.querySelector("iframe.footprint-modal");r&&(r==null||r.classList.add("footprint-modal-closing"),yield new Promise(s=>{setTimeout(s,100);}));let i=A(Le,e),a=document.getElementById(i);a&&(a.classList.add("footprint-overlay-fading"),yield new Promise(s=>{setTimeout(s,200);}),o.remove(),a.remove(),document.body.classList.remove(Ae));}),Ke=(e,t)=>{let o=A(xe,e),n=document.createElement("div");return n.classList.add(Oe),n.setAttribute("id",o),t.appendChild(n),n},Vt=e=>{let t=A(xe,e),o=document.getElementById(t);o&&o.remove();},G=e=>{let t=A(Re,e),o=document.getElementById(t);o&&o.remove();},ee=(e,t)=>{let o=A(Re,t),n=St(o);e.appendChild(n);},Te=(e,t)=>{document.body.classList.add(Ae);let o=document.createElement("div"),n=A(Le,t);return o.setAttribute("id",n),o.classList.add(Ie),e.appendChild(o),o},St=e=>{let t=document.createElement("div");t.setAttribute("id",e),t.classList.add("footprint-loading-indicator");let o=document.createElement("div");o.classList.add("footprint-loading-spin");let n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.setAttribute("width","24px"),n.setAttribute("height","24px"),n.setAttribute("fill","none"),n.setAttribute("aria-hidden","true");let r=document.createElementNS("http://www.w3.org/2000/svg","path");return r.setAttribute("d","M12 2a10 10 0 0 1 10 10h-2a7.999 7.999 0 0 0-8-8V2Z"),n.appendChild(r),o.appendChild(n),t.appendChild(o),t},_e=e=>{let t=document.getElementById(U(e));t&&(t.style.opacity="1",t.style.display="block");},Be=e=>{let t=document.getElementById(U(e));t&&(t.style.opacity="0",t.style.display="none");},Ue=e=>{let t=document.createElement("div");t.classList.add("modal-error-container"),t.setAttribute("role","dialog"),t.setAttribute("aria-modal","true"),t.setAttribute("aria-label","Oops! Something\u2019s not quite right.");let o=document.createElement("div");o.classList.add("modal-error");let n=document.createElement("button");n.setAttribute("aria-label","Close"),n.classList.add("modal-error-close-button"),n.addEventListener("click",()=>{e.remove();});let r=document.createElementNS("http://www.w3.org/2000/svg","svg");r.setAttribute("xmlns","http://www.w3.org/2000/svg"),r.setAttribute("width","20"),r.setAttribute("height","20"),r.setAttribute("viewBox","0 0 20 20"),r.setAttribute("fill","none");let i=document.createElementNS("http://www.w3.org/2000/svg","path");i.setAttribute("d","M5 5L15 15M15 5L5 15"),i.setAttribute("stroke","black"),i.setAttribute("stroke-width","1.5"),i.setAttribute("stroke-linecap","round"),r.appendChild(i),n.appendChild(r);let a=document.createElementNS("http://www.w3.org/2000/svg","svg");a.setAttribute("xmlns","http://www.w3.org/2000/svg"),a.setAttribute("width","40"),a.setAttribute("height","40"),a.setAttribute("viewBox","0 0 40 40"),a.setAttribute("fill","none"),a.setAttribute("class","error-icon");let s=document.createElementNS("http://www.w3.org/2000/svg","path");s.setAttribute("d","M25 15L15 25M25 25L15 15M35 20C35 28.2843 28.2843 35 20 35C11.7157 35 5 28.2843 5 20C5 11.7157 11.7157 5 20 5C28.2843 5 35 11.7157 35 20Z"),s.setAttribute("stroke","black"),s.setAttribute("stroke-width","3.33333"),s.setAttribute("stroke-linecap","round"),s.setAttribute("stroke-linejoin","round"),a.appendChild(s);let p=document.createElement("h2");p.textContent="Oops! Something\u2019s not quite right.";let d=document.createElement("p");d.textContent="It looks like there was an issue loading the page. Try reloading and we\u2019ll get things back on track.",o.appendChild(n),o.appendChild(a),o.appendChild(p),o.appendChild(d),t.appendChild(o),e.appendChild(t);};var Et=()=>Math.random().toString(36).substring(2),M=Et;var N="https://api.onefootprint.com",$=T,H="footprint-js";var C={["auth"]:"auth_v1",["form"]:"form_v1",["render"]:"render_v1",["update_login_methods"]:"update_auth_methods_v1",["verify"]:"verify_v1",["verify-button"]:"verify_button_v1",["components"]:"verify_v1"};var Ot=e=>e.replace(/[A-Z]/g,t=>`_${t.toLowerCase()}`),te=e=>t=>{if(!t||typeof t!="object")return t;let o=Object.entries(t).map(([n,r])=>{let i;return Array.isArray(r)?i=r.map(te(e)):Object(r)===r?i=te(e)(r):i=r,[e(n),i]});return Object.fromEntries(o)},At=te(Ot),j=At;var It=(e,t,o,n)=>{let r={tenantDomain:n,sdkKind:e,sdkName:H,sdkVersion:$,logLevel:o,logMessage:t,sessionId:K()};try{fetch(`${N}/org/sdk_telemetry`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(j(r))});}catch(i){}},q=It;var R=(e,t)=>{let o=`@onefootprint/footprint-js: ${t}`;{let n;try{n=window.location.href;}catch(r){}q(e,t,"info",n);}return o},ne=(e,t)=>{let o=`@onefootprint/footprint-js: ${t}`;{let n;try{n=window.location.href;}catch(r){}q(e,t,"warn",n);}return o},z=(e,t)=>{let o=`@onefootprint/footprint-js: ${t}`;{let n;try{n=window.location.href;}catch(r){}q(e,t,"error",n);}return o};var Me={["auth"]:{["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete"},["update_login_methods"]:{["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete"},["form"]:{["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete"},["verify"]:{["auth"]:"onAuth",["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete"},["components"]:{["auth"]:"onAuth",["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete",["relayToComponents"]:"onRelayToComponents"},["verify-button"]:{["auth"]:"onAuth",["canceled"]:"onCancel",["clicked"]:"onClick",["closed"]:"onClose",["completed"]:"onComplete"},["render"]:{}},Ne={["auth"]:[],["form"]:[],["render"]:[],["update_login_methods"]:[],["verify"]:[],["components"]:[],["verify-button"]:[]};var $e={["auth"]:["modal","drawer"],["components"]:["modal"],["form"]:["inline","modal","drawer"],["render"]:["inline"],["update_login_methods"]:["modal","drawer"],["verify"]:["modal","drawer"],["verify-button"]:["inline"]},xt=Object.values(L),Lt=(...e)=>{},w=e=>e!=null&&typeof e=="object"&&!Array.isArray(e),re=e=>w(e)&&Object.keys(e).length>0,Rt=(e,t)=>{if(e==="inline"&&!t)throw new Error(`Inline component requires a containerId. Received ${t}`)},W=(e,t)=>{var r;if(!t)return;let o=(r=$e[e])!=null?r:[];if(!o.includes(t))throw new Error(`Invalid variant: ${JSON.stringify(t)}. Valid variants for ${e} are ${o.join(", ")}`)},I=e=>{var o;let t=(o=$e[e])!=null?o:[];if(!t.length)throw new Error(`Invalid kind: ${e}`);return t[0]},J=e=>{if(!e)throw new Error("Kind is required");let t=Object.values(_);if(!t.includes(e))throw new Error(`Invalid kind: ${e}. Valid kinds are: ${t.join(", ")}`)},He=e=>{if(e.kind==="verify-button"){let t=e,{kind:o,appearance:n,variant:r,dialogVariant:i,onClick:a,label:s,containerId:p}=t,d=Pe(t,["kind","appearance","variant","dialogVariant","onClick","label","containerId"]);return k(h({},d),{variant:i,kind:"verify"})}};var je=(e,t)=>(Object.prototype.hasOwnProperty.call(e,t)&&typeof e[t]=="function"?e[t]:void 0)||Lt,ae=(e,t,o)=>{var s;let{kind:n}=e,r=(s=Me[n])!=null?s:{},i={},a=He(e);return Object.entries(r).forEach(([p,d])=>{let l=p;if(!xt.includes(l))return;let g=je(e,d),P=l==="closed"||l==="canceled",m=n==="verify-button"&&l==="clicked";i[l]=v=>{g(v),P&&(t==null||t()),m&&a&&(o==null||o(a));};}),i},F=e=>{let{kind:t,variant:o,containerId:n}=e,r=o||I(t);return J(t),W(t,o),Rt(r,n),re(e==null?void 0:e.userData)&&console.warn("userData is deprecated and will be removed in the next major version. Please use bootstrapData instead."),k(h({},e),{variant:r})},b=e=>re(e==null?void 0:e.bootstrapData)?{userData:e.bootstrapData}:re(e==null?void 0:e.userData)?{userData:e.userData}:void 0;var Ft=e=>e==="auth";var Dt=e=>e==="update_login_methods";var ie=e=>e.kind==="components";var se=e=>typeof e=="string"&&e.length>0,Q=e=>Ft(e.kind)&&!!("updateLoginMethods"in e&&e.updateLoginMethods)&&!!e.authToken&&/tok_/.test(e.authToken),Kt=e=>Dt(e.kind)&&!!e.authToken&&/tok_/.test(e.authToken),de=e=>[Q,Kt].some(t=>t(e));var Tt=3,_t=!1,Bt=e=>de(e)?"update_auth_methods_v1":C[e.kind],Ut=e=>{var o,n;let{kind:t}=e;if(t==="verify"||t==="components")return k(h({},b(e)),{publicKey:e.publicKey,authToken:e.authToken,options:e.options,l10n:e.l10n,fixtureResult:(o=e.sandboxOutcome)==null?void 0:o.overallOutcome,documentFixtureResult:(n=e.sandboxOutcome)==null?void 0:n.documentOutcome,sandboxId:e.sandboxId,isComponentsSdk:t==="components",shouldRelayToComponents:t==="components"?e.shouldRelayToComponents:void 0});if(t==="update_login_methods")return k(h({},b(e)),{authToken:e.authToken,options:e.options,l10n:e.l10n});if(t==="auth")return Q(e)?k(h({},b(e)),{authToken:e.authToken,updateLoginMethods:e.updateLoginMethods,options:e.options,l10n:e.l10n}):e.authToken&&_t?k(h({},b(e)),{authToken:e.authToken,options:e.options,l10n:e.l10n}):k(h({},b(e)),{publicKey:e.publicKey,options:e.options,l10n:e.l10n});if(t==="form")return {authToken:e.authToken,options:e.options,title:e.title,l10n:e.l10n};if(t==="render")return {authToken:e.authToken,canCopy:e.canCopy,defaultHidden:e.defaultHidden,id:e.id,label:e.label,showHiddenToggle:e.showHiddenToggle,l10n:e.l10n};if(t==="verify-button")return k(h({},b(e)),{publicKey:e.publicKey,options:e.options,authToken:e.authToken,label:e.label,l10n:e.l10n});z(t,"Invalid kind provided");},qe=(e,t)=>u(void 0,null,function*(){return fetch(`${N}/org/sdk_args`,{method:"POST",headers:{"x-fp-client-version":`${H} ${$} ${e.kind}`.trim(),"Content-Type":"application/json"},body:JSON.stringify(e)}).then(o=>{if(o.ok)return o.json();if(t>0)return qe(e,t-1)})}),Mt=e=>u(void 0,null,function*(){R(C[e.kind],"Sending SDK args");let t=Ut(e);if(!t)return;let o=yield qe({data:j(t),kind:Bt(e)},Tt);return o?o.token:void 0}),ze=Mt;var We=({fontSrc:e,variables:t={},rules:o={},variant:n}={})=>{let r=()=>Object.keys(t).length?encodeURIComponent(JSON.stringify(t)):void 0,i=()=>Object.keys(o).length?encodeURIComponent(JSON.stringify(o)):void 0;return {fontSrc:e,variables:r(),rules:i(),variant:n}},Je=()=>{let e=window.footprintAppearance;return !e||!w(e)?{}:{fontSrc:e.fontSrc,rules:e.rules,variables:e.variables}};var Qe=()=>{var e;return typeof window!="undefined"?((e=window.location)==null?void 0:e.href)||window.location.toString():""},Nt=(e,t)=>{let{appearance:o,kind:n,l10n:r,variant:i}=e,{fontSrc:a,rules:s,variables:p}=We(o),d=new URLSearchParams;return p&&d.append("variables",p),s&&d.append("rules",s),a&&d.append("font_src",a),r!=null&&r.language&&d.append("lng",r.language),d.append("variant",i||I(n)),`${d.toString()}#${t}`},$t=(e,t)=>{let{kind:o}=e,n=Nt(e,t),r=`https://components.onefootprint.com/${o}`,i=`https://components2.onefootprint.com/${o}`;if(o==="update_login_methods"&&(r="https://auth.onefootprint.com/user",i="https://auth2.onefootprint.com/user"),o==="auth"&&(r="https://auth.onefootprint.com",i="https://auth2.onefootprint.com"),(o==="verify"||o==="verify-button"||o==="components")&&(r="https://id.onefootprint.com",i="https://id2.onefootprint.com"),!se(r))throw new Error(`${o}_URL environment variable is not defined.`);return r+=`?${n}`.trim(),i+=`?${n}`.trim(),{url:r,fallbackUrl:i}},Xe=$t;var Ht=e=>{let t=null,o=!1,n,r,{formSaveComplete:i,formSaved:a,formSaveFailed:s,started:p}=B,d=F(e),{variant:l,containerId:g}=d,P=l==="modal"||l==="drawer",m=M(),v=(c,f)=>{var S;let y=z(C[d.kind],c);(S=d.onError)==null||S.call(d,y),o&&f&&(n(),o=!1);},tt=()=>{if(!t){v("Footprint should be initialized in order to register callback props");return}let c=ae(d,n,r);Object.entries(c).forEach(([f,y])=>{t==null||t.on(f,y),t==null||t.on(`${m}:${f}`,y);});},ot=()=>{if(P)return De(m);if(!g){v("containerId is required when rendering inline");return}let c=document.getElementById(g);if(!c){v(`Could not find container with id ${g} while rendering footprint`);return}return Ke(m,c)},X=(c,f)=>{if(!f){G(m),t==null||t.frame.classList.remove("fp-hide"),t==null||t.frame.classList.remove(`footprint-${l}-loading`),t==null||t.frame.classList.add(`footprint-${l}-loaded`);return}if(P){let y=Te(c,m);ee(y,m);}else ee(c,m);},ce=()=>{var f;if(!t){v("Footprint should be initialized in order to set up refs");return}if(d.kind!=="form"||!d.getRef)return;let c={save:()=>(t||v("Footprint should be initialized to call ref methods"),new Promise((y,S)=>{t==null||t.on(i,()=>{y();}),t==null||t.on(s,ue=>{S(ue);}),t==null||t.on(`${m}:${i}`,y),t==null||t.on(`${m}:${s}`,S),t==null||t.call(a);}))};(f=d.getRef)==null||f.call(d,c);},me=(c,f)=>u(void 0,null,function*(){try{return t=yield new Ee({classListArray:[`footprint-${l}`,`footprint-${l}-loading`,"fp-hide"],container:c,name:`footprint-iframe-${m}`,url:f,allow:"otp-credentials; publickey-credentials-get *; camera *; clipboard-write;",model:{authToken:d.authToken,initId:m,sdkUrl:Qe(),sdkVersion:T||""}}),{success:!0,parentApi:t}}catch(y){return v(`Initializing iframe with ${new URL(f).host} failed with error ${y}`),{success:!1}}}),nt=(S,ue)=>u(void 0,[S,ue],function*(c,{url:f,fallbackUrl:y}){R(C[d.kind],`Initializing iframe with ${new URL(f).host}`);let fe=yield me(c,f);if(fe.success)return fe.parentApi;R(C[d.kind],`Initializing iframe with ${new URL(y).host} as fallback`);let ye=yield me(c,y);if(!ye.success)throw new Error("Failed to initialize iframe");return ye.parentApi});return {relayFromComponents:()=>{t&&(t.call("relayFromComponents"),_e(m));},props:d,isRendered:o,render:()=>u(void 0,null,function*(){if(o){ne(C[d.kind],"Footprint component is already rendered");return}o=!0;let c=ot();if(!c){ne(C[d.kind],"Unable to create container for Footprint component");return}c.hasChildNodes()&&(c.innerHTML=""),X(c,!0);let f=yield ze(d);if(!f){v("Unable to get SDK args token.",!0),X(c,!1);return}let{url:y,fallbackUrl:S}=Xe(d,f||"");try{yield nt(c,{url:x(y),fallbackUrl:x(S)}),tt();}catch(ue){Ue(c),o=!1;}X(c,!1),t==null||t.on(p,()=>ce()),t==null||t.on(`${m}:${p}`,ce),d.kind==="components"&&(t==null||t.on(`${m}:${"relayToComponents"}`,()=>{Be(m);}));}),destroy:()=>u(void 0,null,function*(){o&&(o=!1,yield Fe(m),t&&(t.destroy(),t=null));}),registerOnDestroy:c=>{!c||typeof c!="function"||(n=c);},registerOnRenderSecondary:c=>{!c||typeof c!="function"||(r=c);}}},pe=Ht;var V=e=>{let t=F(e);return JSON.stringify(t)},jt=()=>{let e=Object.create(null);return {getOrCreate:i=>{let a=V(i.props),s=Object.values(e).find(p=>V(p.iframe.props)===a);return s?s.iframe:(e[a]={iframe:i,secondaryIframes:{}},i)},getOrCreateSecondary:(i,a)=>{let s=V(i.props),p=V(a.props);if(!e[s])throw new Error("iframe manager: primary iframe does not exist while adding secondary");let{secondaryIframes:d}=e[s],l=Object.values(d).find(g=>V(g.props)===p);return l||(d[p]=a,a)},remove:i=>{let a=V(i.props),s=e[a];s&&(Object.keys(s.secondaryIframes).forEach(p=>{s.secondaryIframes[p].destroy();}),delete e[a]);},removeSecondary:(i,a)=>{let s=V(i.props),p=V(a.props);if(!e[s])throw new Error("iframe manager: primary iframe does not exist while removing secondary");let{secondaryIframes:d}=e[s],l=d[p];l&&(l.destroy(),delete d[p]);}}},Ye=jt;var qt=()=>{let e=Ye();return {init:o=>{let n=pe(o),r=()=>u(void 0,null,function*(){e.remove(n),yield n.destroy();}),i=d=>u(void 0,null,function*(){e.removeSecondary(n,d),yield d.destroy();}),a=d=>u(void 0,null,function*(){let l=pe(d);l=e.getOrCreateSecondary(n,l),l.registerOnDestroy(()=>{i(l);}),l.render();}),s=()=>u(void 0,null,function*(){n=e.getOrCreate(n),n.registerOnDestroy(r),n.registerOnRenderSecondary(a),yield n.render();}),p={};return ie(o)&&(p={relayFromComponents:()=>{n.relayFromComponents();}}),h({render:s,destroy:r},p)}}},zt=qt(),le=zt;var Wt=e=>{window.setTimeout(e,0);},Jt=e=>{if(typeof window=="undefined")return;let t=r=>{var s;let i=(s=window.footprintCallbacks)!=null?s:{};if(!w(i))throw Error("`window.footprintCallbacks` must be a valid mapping from callback names to functions.");return Ne[r].forEach(p=>{if(!i[p])throw Error(`Callback '${p}' must be defined in window.footprintCallbacks`)}),i},o=r=>{var m;let i=r.getAttribute("data-kind");J(i);let a=(m=r.getAttribute("data-variant"))!=null?m:I(i);W(i,a);let s=Je(),p=t(i),d=r.getAttribute("data-props")||"",l;try{l=JSON.parse(d);}catch(v){throw Error("Could not parse `data-props` for footprint.")}if(!w(l))throw Error("`data-props` on the footprint element has to be a valid JSON object stringified.");let g=M();r.setAttribute("id",g),e.init(h(h({kind:i,variant:a,appearance:s,containerId:r.id},p),l)).render();},n=()=>{let r=document.querySelectorAll("[data-footprint]");r.length&&r.forEach(i=>{o(i);});};document.addEventListener("DOMContentLoaded",()=>Wt(n));},Ze=Jt;var Qt="http://test",Ge=e=>u(void 0,null,function*(){let t=yield fetch(`${Qt}/hosted/identify/lite`,{method:"POST",body:JSON.stringify(e)});if(!t.ok)throw Error(t.statusText);return (yield t.json()).user_found}),Xt=e=>u(void 0,null,function*(){if(!w(e))throw new Error("User data must be passed in order to identify an user");let t=e["id.email"],o=e["id.phone_number"];return t&&(yield Ge({email:t}))?!0:o?yield Ge({phone_number:o}):!1}),et=Xt;var _n=le;Ze(le);/*! Bundled license information:

@@ -16,6 +16,6 @@ @onefootprint/postmate/build/postmate.es.js:

exports.FootprintComponentKind = T;
exports.FootprintComponentKind = _;
exports.FootprintPrivateEvent = B;
exports.FootprintPublicEvent = L;
exports.default = Tn;
exports.default = _n;
exports.identifyFootprintUser = et;

@@ -22,0 +22,0 @@

@@ -5,3 +5,3 @@ {

"type": "module",
"version": "3.14.2",
"version": "3.15.0",
"main": "./dist/footprint-js.cjs",

@@ -8,0 +8,0 @@ "module": "./dist/footprint-js.js",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc