Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@onefootprint/footprint-js

Package Overview
Dependencies
Maintainers
0
Versions
75
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.15.2 to 3.15.3

6

dist/footprint-js.js

@@ -1,5 +0,3 @@

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

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

"type": "module",
"version": "3.15.2",
"version": "3.15.3",
"main": "./dist/footprint-js.cjs",

@@ -33,5 +33,3 @@ "module": "./dist/footprint-js.js",

},
"dependencies": {
"@onefootprint/postmate": "2.1.2"
},
"dependencies": {},
"devDependencies": {

@@ -38,0 +36,0 @@ "bun-types": "^1.0.25",

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