@starfish-codes/hellgate 3.8.0 → 3.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/card/card-handler.d.ts +10 -4
- package/dist/card/typings.d.ts +10 -6
- package/dist/card/ui/elements/card-expiration-month.d.ts +9 -0
- package/dist/card/ui/elements/card-expiration-year.d.ts +9 -0
- package/dist/card/ui/elements/utils.d.ts +4 -0
- package/dist/card/ui/iframe/elements/card-expiration-month.d.ts +10 -0
- package/dist/card/ui/iframe/elements/card-expiration-year.d.ts +9 -0
- package/dist/card/ui/typings.d.ts +2 -1
- package/dist/hellgate-sdk.mjs +1012 -4468
- package/dist/hellgate-sdk.umd.js +1 -6
- package/dist/session/__tests__/mocks.d.ts +1 -1
- package/package.json +2 -3
package/dist/hellgate-sdk.umd.js
CHANGED
|
@@ -1,6 +1 @@
|
|
|
1
|
-
(function(V,Ce){typeof exports=="object"&&typeof module<"u"?Ce(exports):typeof define=="function"&&define.amd?define(["exports"],Ce):(V=typeof globalThis<"u"?globalThis:V||self,Ce(V.HellgateSDK={}))})(this,function(V){"use strict";function Ce(e){return Array.isArray(e)?e.filter(Boolean):Object.fromEntries(Object.entries(e).map(([t,r])=>[t,typeof r=="object"&&r&&!Array.isArray(r)?Ce(r):r]).filter(([t,r])=>typeof r=="object"&&r&&!Array.isArray(r)?!!Object.keys(r).length:r!=null&&r!=null))}function Oe(e,t){const r={...e,...t},s=Object.keys(r);for(const a of s){const u=e[a],l=t[a];typeof u=="object"&&!Array.isArray(u)&&u&&typeof l=="object"&&!Array.isArray(l)&&l&&(r[a]=Oe(u,l))}return r}function Bt(e){if(!e.ok)throw e;return e.json()}const oi=2e3;class $r{constructor(t,r){Object.defineProperty(this,"session",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"iframeId",{enumerable:!0,configurable:!0,writable:!0,value:String(Math.floor(1e5+Math.random()*9e5))}),Object.defineProperty(this,"resultPollingTimer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"transactionId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"decoupledAuthHandlers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"disposers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"check3dsIframeDisposers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"domContainer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"labelText",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onStartHandler",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onFinishHandler",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onDecoupledAuth",{enumerable:!0,configurable:!0,writable:!0,value:s=>{this.decoupledAuthHandlers.push(s)}}),Object.defineProperty(this,"onStartChallenge",{enumerable:!0,configurable:!0,writable:!0,value:s=>{this.onStartHandler=s}}),Object.defineProperty(this,"onChallengeFinished",{enumerable:!0,configurable:!0,writable:!0,value:s=>{this.onFinishHandler=s}}),Object.defineProperty(this,"sessionStateHandle",{enumerable:!0,configurable:!0,writable:!0,value:s=>{var a,u;switch(s.next_action){case"3ds_check":{this.initCheck3DSIframes(s.data.threeds_server_callback_url,s.data.mon_url);break}case"3ds_challenge":{(a=this.onStartHandler)==null||a.call(this),this.disposeCheck3DSIframe(),this.startChallenge(s.data.challenge_url,s.data.result_mon_url);break}case"3ds_challenge_decoupled":{this.startDecoupledAuth(s.data.cardholder_info,s.data.result_mon_url,s.data.transaction_id);break}case null:{this.dispose(),(u=this.onFinishHandler)==null||u.call(this);break}}}}),this.domContainer=r.domContainer??xt(),this.disposers.push(this.session.onStateChange(this.sessionStateHandle)),this.labelText=r.labelText}dispose(){this.disposers.forEach(t=>t()),this.check3dsIframeDisposers.forEach(t=>t())}initCheck3DSIframes(t,r){const s=xt();s.insertAdjacentHTML("beforeend",`<iframe id="check_3ds_${this.iframeId}" width="0" height="0" style="border:0;visibility: hidden;" src="${t}"></iframe>`);const a=s.querySelector(`#check_3ds_${this.iframeId}`);if(a){const u=l=>{l.source===a.contentWindow&&this.session.completeAction({action:"3ds_check",result:l.data})};window.addEventListener("message",u),this.check3dsIframeDisposers.push(()=>window.removeEventListener("message",u),()=>a.remove())}if(r){s.insertAdjacentHTML("beforeend",`<iframe id="mon_${this.iframeId}" width="0" height="0" style="border:0;visibility: hidden;" src="${r}"></iframe>`);const u=s.querySelector(`#mon_${this.iframeId}`);u&&this.disposers.push(()=>u.remove())}}disposeCheck3DSIframe(){this.check3dsIframeDisposers.forEach(t=>t()),this.check3dsIframeDisposers=[]}startChallenge(t,r){const s=xt(),a=`<div style="display: flex; flex-direction: column; gap: 10px; align-items: center; ${this.domContainer===s?'border:0; max-width: 800px; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width:100% " ':'border:0;" width="100%" height="100%"'}><iframe id="cha_${this.iframeId}" src="${t}" width="100%" height="500"></iframe>${this.labelText?'<span id="tds_label_text" style="font-size: large;">'+this.labelText+"</span>":""}<div>`;this.domContainer.insertAdjacentHTML("beforeend",this.domContainer===s?`<div id="cha_${this.iframeId}_wrap" style="background: #fff; position: fixed; left: 0; top: 0; width: 100%; height: 100%; z-index: 10000;">${a}</div>`:a);const u=this.domContainer.querySelector(`#cha_${this.iframeId}`),l=this.domContainer.querySelector(`#cha_${this.iframeId}_wrap`);if(!u)throw new Error("3DS Challenge Iframe initialization failed");this.disposers.push(()=>{u.remove(),l==null||l.remove()});const f=new Promise(_=>{const T=S=>{S.source!==u.contentWindow||S.data.event!=="AuthResultReady"||_(S.data)};window.addEventListener("message",T),this.disposers.push(()=>window.removeEventListener("message",T))}),y=new Promise(_=>{const T=this.startAuthResultPolling(r,S=>{S.event==="AuthResultReady"&&(T(),_({requestor_trans_id:S.threeDSRequestorTransID,event:S.event}))})});Promise.any([f,y]).then(_=>{this.session.completeAction({action:"3ds_challenge",result:_})})}startDecoupledAuth(t,r,s){this.transactionId||(this.transactionId=s),this.decoupledAuthHandlers.forEach(u=>u(t));const a=this.startAuthResultPolling(r,u=>{u.event==="AuthResultReady"&&(this.session.completeAction({action:"3ds_challenge_decoupled",result:{...u,event:u.event}}),a())})}startAuthResultPolling(t,r){return window.clearTimeout(this.resultPollingTimer),this.resultPollingTimer=window.setTimeout(()=>fetch(t).then(s=>Bt(s)).then(s=>{this.startAuthResultPolling(t,r),r(s)}).catch(()=>{}),oi),()=>window.clearTimeout(this.resultPollingTimer)}}function xt(){return document.body}var ci=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ui(e){if(Object.prototype.hasOwnProperty.call(e,"__esModule"))return e;var t=e.default;if(typeof t=="function"){var r=function s(){return this instanceof s?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach(function(s){var a=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(r,s,a.get?a:{enumerable:!0,get:function(){return e[s]}})}),r}var Nt={},Le={},we={},Kr;function li(){if(Kr)return we;Kr=1,Object.defineProperty(we,"__esModule",{value:!0}),we.makeRequestWithoutElementsPayloadCheck=we.makeRequestWithElementsPayloadCheck=void 0;function e(a){function u(){var l=Reflect.construct(a,Array.from(arguments));return Object.setPrototypeOf(l,Object.getPrototypeOf(this)),l}return u.prototype=Object.create(a.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),Object.setPrototypeOf?Object.setPrototypeOf(u,a):u.__proto__=a,u}class t extends e(Error){constructor(u){super(u),this.name="NoElementsError"}}const r=(a,u,l,f,y={})=>{if(a!=null&&a.hasElement(f))return a.client[u](l,f,y);let _="Elements not initialized.";throw a&&(_="Element not found in payload."),new t(`${_} Use a regular HTTP client if no elements are needed.`)};we.makeRequestWithElementsPayloadCheck=r;const s=(a,u,l,f={})=>{if(a)return a.client[u](l,f);throw new t("Elements not initialized. Use a regular HTTP client if no elements are needed.")};return we.makeRequestWithoutElementsPayloadCheck=s,we}var jt={},He={},Ut={},L={},Fr;function zr(){if(Fr)return L;Fr=1,Object.defineProperty(L,"__esModule",{value:!0}),L.USER_AGENT_HEADER=L.USER_AGENT_CLIENT=L.MERGE_CONTENT_TYPE=L.DEFAULT_ELEMENTS_BASE_URL=L.DEFAULT_BASE_URL=L.CONTENT_TYPE_HEADER=L.CLIENT_USER_AGENT_HEADER=L.CLIENT_BASE_PATHS=L.BT_TRANSACTION_ID_HEADER=L.BT_TRACE_ID_HEADER=L.BT_IDEMPOTENCY_KEY_HEADER=L.BT_EXPOSE_PROXY_RESPONSE_HEADER=L.BROWSER_LIST=L.API_KEY_HEADER=void 0;const e="BT-API-KEY";L.API_KEY_HEADER=e;const t="bt-trace-id";L.BT_TRACE_ID_HEADER=t;const r="bt-idempotency-key";L.BT_IDEMPOTENCY_KEY_HEADER=r;const s="BT-EXPOSE-RAW-PROXY-RESPONSE";L.BT_EXPOSE_PROXY_RESPONSE_HEADER=s;const a="BT-TRANSACTION-ID";L.BT_TRANSACTION_ID_HEADER=a;const u="Content-Type";L.CONTENT_TYPE_HEADER=u;const l="application/merge-patch+json";L.MERGE_CONTENT_TYPE=l;const f="User-Agent";L.USER_AGENT_HEADER=f;const y="BT-CLIENT-USER-AGENT";L.CLIENT_USER_AGENT_HEADER=y;const _="BasisTheoryJS";L.USER_AGENT_CLIENT=_;const T="https://api.basistheory.com";L.DEFAULT_BASE_URL=T;const S="https://js.basistheory.com/hosted-elements";L.DEFAULT_ELEMENTS_BASE_URL=S;const B={tokens:"tokens",tokenize:"tokenize",applications:"applications",tenants:"tenants/self",logs:"logs",reactorFormulas:"reactor-formulas",reactors:"reactors",permissions:"permissions",proxies:"proxies",proxy:"proxy",sessions:"sessions",transactions:"transactions"};L.CLIENT_BASE_PATHS=B;const M=[{browserName:"Firefox",browserUA:"Firefox"},{browserName:"SamsungBrowser",browserUA:"SamsungBrowser"},{browserName:"Opera",browserUA:"Opera"},{browserName:"Opera",browserUA:"OPR"},{browserName:"Microsoft Internet Explorer",browserUA:"Trident"},{browserName:"Microsoft Edge (Legacy)",browserUA:"Edge"},{browserName:"Microsoft Edge (Chromium)",browserUA:"Edg"},{browserName:"Google Chrome/Chromium",browserUA:"Chrome"},{browserName:"Safari",browserUA:"Safari"}];return L.BROWSER_LIST=M,L}var O={};/*! Axios v1.8.2 Copyright (c) 2025 Matt Zabriskie and contributors */var Dt,kr;function Wr(){if(kr)return Dt;kr=1;function e(n,i){return function(){return n.apply(i,arguments)}}const{toString:t}=Object.prototype,{getPrototypeOf:r}=Object,s=(n=>i=>{const o=t.call(i);return n[o]||(n[o]=o.slice(8,-1).toLowerCase())})(Object.create(null)),a=n=>(n=n.toLowerCase(),i=>s(i)===n),u=n=>i=>typeof i===n,{isArray:l}=Array,f=u("undefined");function y(n){return n!==null&&!f(n)&&n.constructor!==null&&!f(n.constructor)&&B(n.constructor.isBuffer)&&n.constructor.isBuffer(n)}const _=a("ArrayBuffer");function T(n){let i;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?i=ArrayBuffer.isView(n):i=n&&n.buffer&&_(n.buffer),i}const S=u("string"),B=u("function"),M=u("number"),U=n=>n!==null&&typeof n=="object",F=n=>n===!0||n===!1,q=n=>{if(s(n)!=="object")return!1;const i=r(n);return(i===null||i===Object.prototype||Object.getPrototypeOf(i)===null)&&!(Symbol.toStringTag in n)&&!(Symbol.iterator in n)},P=a("Date"),D=a("File"),H=a("Blob"),Z=a("FileList"),de=n=>U(n)&&B(n.pipe),ot=n=>{let i;return n&&(typeof FormData=="function"&&n instanceof FormData||B(n.append)&&((i=s(n))==="formdata"||i==="object"&&B(n.toString)&&n.toString()==="[object FormData]"))},gr=a("URLSearchParams"),[wr,Tr,Sr,Rr]=["ReadableStream","Request","Response","Headers"].map(a),Et=n=>n.trim?n.trim():n.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function _e(n,i,{allOwnKeys:o=!1}={}){if(n===null||typeof n>"u")return;let c,d;if(typeof n!="object"&&(n=[n]),l(n))for(c=0,d=n.length;c<d;c++)i.call(null,n[c],c,n);else{const h=o?Object.getOwnPropertyNames(n):Object.keys(n),p=h.length;let b;for(c=0;c<p;c++)b=h[c],i.call(null,n[b],b,n)}}function ct(n,i){i=i.toLowerCase();const o=Object.keys(n);let c=o.length,d;for(;c-- >0;)if(d=o[c],i===d.toLowerCase())return d;return null}const fe=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:ci,bt=n=>!f(n)&&n!==fe;function E(){const{caseless:n}=bt(this)&&this||{},i={},o=(c,d)=>{const h=n&&ct(i,d)||d;q(i[h])&&q(c)?i[h]=E(i[h],c):q(c)?i[h]=E({},c):l(c)?i[h]=c.slice():i[h]=c};for(let c=0,d=arguments.length;c<d;c++)arguments[c]&&_e(arguments[c],o);return i}const j=(n,i,o,{allOwnKeys:c}={})=>(_e(i,(d,h)=>{o&&B(d)?n[h]=e(d,o):n[h]=d},{allOwnKeys:c}),n),k=n=>(n.charCodeAt(0)===65279&&(n=n.slice(1)),n),I=(n,i,o,c)=>{n.prototype=Object.create(i.prototype,c),n.prototype.constructor=n,Object.defineProperty(n,"super",{value:i.prototype}),o&&Object.assign(n.prototype,o)},re=(n,i,o,c)=>{let d,h,p;const b={};if(i=i||{},n==null)return i;do{for(d=Object.getOwnPropertyNames(n),h=d.length;h-- >0;)p=d[h],(!c||c(p,n,i))&&!b[p]&&(i[p]=n[p],b[p]=!0);n=o!==!1&&r(n)}while(n&&(!o||o(n,i))&&n!==Object.prototype);return i},Q=(n,i,o)=>{n=String(n),(o===void 0||o>n.length)&&(o=n.length),o-=i.length;const c=n.indexOf(i,o);return c!==-1&&c===o},pe=n=>{if(!n)return null;if(l(n))return n;let i=n.length;if(!M(i))return null;const o=new Array(i);for(;i-- >0;)o[i]=n[i];return o},me=(n=>i=>n&&i instanceof n)(typeof Uint8Array<"u"&&r(Uint8Array)),ut=(n,i)=>{const c=(n&&n[Symbol.iterator]).call(n);let d;for(;(d=c.next())&&!d.done;){const h=d.value;i.call(n,h[0],h[1])}},vr=(n,i)=>{let o;const c=[];for(;(o=n.exec(i))!==null;)c.push(o);return c},Ar=a("HTMLFormElement"),Cr=n=>n.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(o,c,d){return c.toUpperCase()+d}),As=(({hasOwnProperty:n})=>(i,o)=>n.call(i,o))(Object.prototype),eo=a("RegExp"),Cs=(n,i)=>{const o=Object.getOwnPropertyDescriptors(n),c={};_e(o,(d,h)=>{let p;(p=i(d,h,n))!==!1&&(c[h]=p||d)}),Object.defineProperties(n,c)},to=n=>{Cs(n,(i,o)=>{if(B(n)&&["arguments","caller","callee"].indexOf(o)!==-1)return!1;const c=n[o];if(B(c)){if(i.enumerable=!1,"writable"in i){i.writable=!1;return}i.set||(i.set=()=>{throw Error("Can not rewrite read-only method '"+o+"'")})}})},ro=(n,i)=>{const o={},c=d=>{d.forEach(h=>{o[h]=!0})};return l(n)?c(n):c(String(n).split(i)),o},no=()=>{},so=(n,i)=>n!=null&&Number.isFinite(n=+n)?n:i;function io(n){return!!(n&&B(n.append)&&n[Symbol.toStringTag]==="FormData"&&n[Symbol.iterator])}const ao=n=>{const i=new Array(10),o=(c,d)=>{if(U(c)){if(i.indexOf(c)>=0)return;if(!("toJSON"in c)){i[d]=c;const h=l(c)?[]:{};return _e(c,(p,b)=>{const R=o(p,d+1);!f(R)&&(h[b]=R)}),i[d]=void 0,h}}return c};return o(n,0)},oo=a("AsyncFunction"),co=n=>n&&(U(n)||B(n))&&B(n.then)&&B(n.catch),Os=((n,i)=>n?setImmediate:i?((o,c)=>(fe.addEventListener("message",({source:d,data:h})=>{d===fe&&h===o&&c.length&&c.shift()()},!1),d=>{c.push(d),fe.postMessage(o,"*")}))(`axios@${Math.random()}`,[]):o=>setTimeout(o))(typeof setImmediate=="function",B(fe.postMessage)),uo=typeof queueMicrotask<"u"?queueMicrotask.bind(fe):typeof process<"u"&&process.nextTick||Os;var m={isArray:l,isArrayBuffer:_,isBuffer:y,isFormData:ot,isArrayBufferView:T,isString:S,isNumber:M,isBoolean:F,isObject:U,isPlainObject:q,isReadableStream:wr,isRequest:Tr,isResponse:Sr,isHeaders:Rr,isUndefined:f,isDate:P,isFile:D,isBlob:H,isRegExp:eo,isFunction:B,isStream:de,isURLSearchParams:gr,isTypedArray:me,isFileList:Z,forEach:_e,merge:E,extend:j,trim:Et,stripBOM:k,inherits:I,toFlatObject:re,kindOf:s,kindOfTest:a,endsWith:Q,toArray:pe,forEachEntry:ut,matchAll:vr,isHTMLForm:Ar,hasOwnProperty:As,hasOwnProp:As,reduceDescriptors:Cs,freezeMethods:to,toObjectSet:ro,toCamelCase:Cr,noop:no,toFiniteNumber:so,findKey:ct,global:fe,isContextDefined:bt,isSpecCompliantForm:io,toJSONObject:ao,isAsyncFn:oo,isThenable:co,setImmediate:Os,asap:uo};function x(n,i,o,c,d){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=n,this.name="AxiosError",i&&(this.code=i),o&&(this.config=o),c&&(this.request=c),d&&(this.response=d,this.status=d.status?d.status:null)}m.inherits(x,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:m.toJSONObject(this.config),code:this.code,status:this.status}}});const Ps=x.prototype,Bs={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(n=>{Bs[n]={value:n}}),Object.defineProperties(x,Bs),Object.defineProperty(Ps,"isAxiosError",{value:!0}),x.from=(n,i,o,c,d,h)=>{const p=Object.create(Ps);return m.toFlatObject(n,p,function(R){return R!==Error.prototype},b=>b!=="isAxiosError"),x.call(p,n.message,i,o,c,d),p.cause=n,p.name=n.name,h&&Object.assign(p,h),p};var lo=null;function Or(n){return m.isPlainObject(n)||m.isArray(n)}function xs(n){return m.endsWith(n,"[]")?n.slice(0,-2):n}function Ns(n,i,o){return n?n.concat(i).map(function(d,h){return d=xs(d),!o&&h?"["+d+"]":d}).join(o?".":""):i}function fo(n){return m.isArray(n)&&!n.some(Or)}const ho=m.toFlatObject(m,{},null,function(i){return/^is[A-Z]/.test(i)});function _t(n,i,o){if(!m.isObject(n))throw new TypeError("target must be an object");i=i||new FormData,o=m.toFlatObject(o,{metaTokens:!0,dots:!1,indexes:!1},!1,function(N,C){return!m.isUndefined(C[N])});const c=o.metaTokens,d=o.visitor||w,h=o.dots,p=o.indexes,R=(o.Blob||typeof Blob<"u"&&Blob)&&m.isSpecCompliantForm(i);if(!m.isFunction(d))throw new TypeError("visitor must be a function");function g(A){if(A===null)return"";if(m.isDate(A))return A.toISOString();if(!R&&m.isBlob(A))throw new x("Blob is not supported. Use a Buffer instead.");return m.isArrayBuffer(A)||m.isTypedArray(A)?R&&typeof Blob=="function"?new Blob([A]):Buffer.from(A):A}function w(A,N,C){let z=A;if(A&&!C&&typeof A=="object"){if(m.endsWith(N,"{}"))N=c?N:N.slice(0,-2),A=JSON.stringify(A);else if(m.isArray(A)&&fo(A)||(m.isFileList(A)||m.endsWith(N,"[]"))&&(z=m.toArray(A)))return N=xs(N),z.forEach(function(X,ye){!(m.isUndefined(X)||X===null)&&i.append(p===!0?Ns([N],ye,h):p===null?N:N+"[]",g(X))}),!1}return Or(A)?!0:(i.append(Ns(C,N,h),g(A)),!1)}const v=[],$=Object.assign(ho,{defaultVisitor:w,convertValue:g,isVisitable:Or});function G(A,N){if(!m.isUndefined(A)){if(v.indexOf(A)!==-1)throw Error("Circular reference detected in "+N.join("."));v.push(A),m.forEach(A,function(z,J){(!(m.isUndefined(z)||z===null)&&d.call(i,z,m.isString(J)?J.trim():J,N,$))===!0&&G(z,N?N.concat(J):[J])}),v.pop()}}if(!m.isObject(n))throw new TypeError("data must be an object");return G(n),i}function js(n){const i={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(n).replace(/[!'()~]|%20|%00/g,function(c){return i[c]})}function Pr(n,i){this._pairs=[],n&&_t(n,this,i)}const Us=Pr.prototype;Us.append=function(i,o){this._pairs.push([i,o])},Us.toString=function(i){const o=i?function(c){return i.call(this,c,js)}:js;return this._pairs.map(function(d){return o(d[0])+"="+o(d[1])},"").join("&")};function po(n){return encodeURIComponent(n).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function Ds(n,i,o){if(!i)return n;const c=o&&o.encode||po;m.isFunction(o)&&(o={serialize:o});const d=o&&o.serialize;let h;if(d?h=d(i,o):h=m.isURLSearchParams(i)?i.toString():new Pr(i,o).toString(c),h){const p=n.indexOf("#");p!==-1&&(n=n.slice(0,p)),n+=(n.indexOf("?")===-1?"?":"&")+h}return n}class mo{constructor(){this.handlers=[]}use(i,o,c){return this.handlers.push({fulfilled:i,rejected:o,synchronous:c?c.synchronous:!1,runWhen:c?c.runWhen:null}),this.handlers.length-1}eject(i){this.handlers[i]&&(this.handlers[i]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(i){m.forEach(this.handlers,function(c){c!==null&&i(c)})}}var Ls=mo,Hs={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},yo=typeof URLSearchParams<"u"?URLSearchParams:Pr,Eo=typeof FormData<"u"?FormData:null,bo=typeof Blob<"u"?Blob:null,_o={isBrowser:!0,classes:{URLSearchParams:yo,FormData:Eo,Blob:bo},protocols:["http","https","file","blob","url","data"]};const Br=typeof window<"u"&&typeof document<"u",xr=typeof navigator=="object"&&navigator||void 0,go=Br&&(!xr||["ReactNative","NativeScript","NS"].indexOf(xr.product)<0),wo=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",To=Br&&window.location.href||"http://localhost";var So=Object.freeze({__proto__:null,hasBrowserEnv:Br,hasStandardBrowserWebWorkerEnv:wo,hasStandardBrowserEnv:go,navigator:xr,origin:To}),ee={...So,..._o};function Ro(n,i){return _t(n,new ee.classes.URLSearchParams,Object.assign({visitor:function(o,c,d,h){return ee.isNode&&m.isBuffer(o)?(this.append(c,o.toString("base64")),!1):h.defaultVisitor.apply(this,arguments)}},i))}function vo(n){return m.matchAll(/\w+|\[(\w*)]/g,n).map(i=>i[0]==="[]"?"":i[1]||i[0])}function Ao(n){const i={},o=Object.keys(n);let c;const d=o.length;let h;for(c=0;c<d;c++)h=o[c],i[h]=n[h];return i}function qs(n){function i(o,c,d,h){let p=o[h++];if(p==="__proto__")return!0;const b=Number.isFinite(+p),R=h>=o.length;return p=!p&&m.isArray(d)?d.length:p,R?(m.hasOwnProp(d,p)?d[p]=[d[p],c]:d[p]=c,!b):((!d[p]||!m.isObject(d[p]))&&(d[p]=[]),i(o,c,d[p],h)&&m.isArray(d[p])&&(d[p]=Ao(d[p])),!b)}if(m.isFormData(n)&&m.isFunction(n.entries)){const o={};return m.forEachEntry(n,(c,d)=>{i(vo(c),d,o,0)}),o}return null}function Co(n,i,o){if(m.isString(n))try{return(i||JSON.parse)(n),m.trim(n)}catch(c){if(c.name!=="SyntaxError")throw c}return(o||JSON.stringify)(n)}const Nr={transitional:Hs,adapter:["xhr","http","fetch"],transformRequest:[function(i,o){const c=o.getContentType()||"",d=c.indexOf("application/json")>-1,h=m.isObject(i);if(h&&m.isHTMLForm(i)&&(i=new FormData(i)),m.isFormData(i))return d?JSON.stringify(qs(i)):i;if(m.isArrayBuffer(i)||m.isBuffer(i)||m.isStream(i)||m.isFile(i)||m.isBlob(i)||m.isReadableStream(i))return i;if(m.isArrayBufferView(i))return i.buffer;if(m.isURLSearchParams(i))return o.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),i.toString();let b;if(h){if(c.indexOf("application/x-www-form-urlencoded")>-1)return Ro(i,this.formSerializer).toString();if((b=m.isFileList(i))||c.indexOf("multipart/form-data")>-1){const R=this.env&&this.env.FormData;return _t(b?{"files[]":i}:i,R&&new R,this.formSerializer)}}return h||d?(o.setContentType("application/json",!1),Co(i)):i}],transformResponse:[function(i){const o=this.transitional||Nr.transitional,c=o&&o.forcedJSONParsing,d=this.responseType==="json";if(m.isResponse(i)||m.isReadableStream(i))return i;if(i&&m.isString(i)&&(c&&!this.responseType||d)){const p=!(o&&o.silentJSONParsing)&&d;try{return JSON.parse(i)}catch(b){if(p)throw b.name==="SyntaxError"?x.from(b,x.ERR_BAD_RESPONSE,this,null,this.response):b}}return i}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:ee.classes.FormData,Blob:ee.classes.Blob},validateStatus:function(i){return i>=200&&i<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};m.forEach(["delete","get","head","post","put","patch"],n=>{Nr.headers[n]={}});var jr=Nr;const Oo=m.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]);var Po=n=>{const i={};let o,c,d;return n&&n.split(`
|
|
2
|
-
`).forEach(function(p){d=p.indexOf(":"),o=p.substring(0,d).trim().toLowerCase(),c=p.substring(d+1).trim(),!(!o||i[o]&&Oo[o])&&(o==="set-cookie"?i[o]?i[o].push(c):i[o]=[c]:i[o]=i[o]?i[o]+", "+c:c)}),i};const Ms=Symbol("internals");function lt(n){return n&&String(n).trim().toLowerCase()}function gt(n){return n===!1||n==null?n:m.isArray(n)?n.map(gt):String(n)}function Bo(n){const i=Object.create(null),o=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let c;for(;c=o.exec(n);)i[c[1]]=c[2];return i}const xo=n=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(n.trim());function Ur(n,i,o,c,d){if(m.isFunction(c))return c.call(this,i,o);if(d&&(i=o),!!m.isString(i)){if(m.isString(c))return i.indexOf(c)!==-1;if(m.isRegExp(c))return c.test(i)}}function No(n){return n.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(i,o,c)=>o.toUpperCase()+c)}function jo(n,i){const o=m.toCamelCase(" "+i);["get","set","has"].forEach(c=>{Object.defineProperty(n,c+o,{value:function(d,h,p){return this[c].call(this,i,d,h,p)},configurable:!0})})}class wt{constructor(i){i&&this.set(i)}set(i,o,c){const d=this;function h(b,R,g){const w=lt(R);if(!w)throw new Error("header name must be a non-empty string");const v=m.findKey(d,w);(!v||d[v]===void 0||g===!0||g===void 0&&d[v]!==!1)&&(d[v||R]=gt(b))}const p=(b,R)=>m.forEach(b,(g,w)=>h(g,w,R));if(m.isPlainObject(i)||i instanceof this.constructor)p(i,o);else if(m.isString(i)&&(i=i.trim())&&!xo(i))p(Po(i),o);else if(m.isHeaders(i))for(const[b,R]of i.entries())h(R,b,c);else i!=null&&h(o,i,c);return this}get(i,o){if(i=lt(i),i){const c=m.findKey(this,i);if(c){const d=this[c];if(!o)return d;if(o===!0)return Bo(d);if(m.isFunction(o))return o.call(this,d,c);if(m.isRegExp(o))return o.exec(d);throw new TypeError("parser must be boolean|regexp|function")}}}has(i,o){if(i=lt(i),i){const c=m.findKey(this,i);return!!(c&&this[c]!==void 0&&(!o||Ur(this,this[c],c,o)))}return!1}delete(i,o){const c=this;let d=!1;function h(p){if(p=lt(p),p){const b=m.findKey(c,p);b&&(!o||Ur(c,c[b],b,o))&&(delete c[b],d=!0)}}return m.isArray(i)?i.forEach(h):h(i),d}clear(i){const o=Object.keys(this);let c=o.length,d=!1;for(;c--;){const h=o[c];(!i||Ur(this,this[h],h,i,!0))&&(delete this[h],d=!0)}return d}normalize(i){const o=this,c={};return m.forEach(this,(d,h)=>{const p=m.findKey(c,h);if(p){o[p]=gt(d),delete o[h];return}const b=i?No(h):String(h).trim();b!==h&&delete o[h],o[b]=gt(d),c[b]=!0}),this}concat(...i){return this.constructor.concat(this,...i)}toJSON(i){const o=Object.create(null);return m.forEach(this,(c,d)=>{c!=null&&c!==!1&&(o[d]=i&&m.isArray(c)?c.join(", "):c)}),o}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([i,o])=>i+": "+o).join(`
|
|
3
|
-
`)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(i){return i instanceof this?i:new this(i)}static concat(i,...o){const c=new this(i);return o.forEach(d=>c.set(d)),c}static accessor(i){const c=(this[Ms]=this[Ms]={accessors:{}}).accessors,d=this.prototype;function h(p){const b=lt(p);c[b]||(jo(d,p),c[b]=!0)}return m.isArray(i)?i.forEach(h):h(i),this}}wt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),m.reduceDescriptors(wt.prototype,({value:n},i)=>{let o=i[0].toUpperCase()+i.slice(1);return{get:()=>n,set(c){this[o]=c}}}),m.freezeMethods(wt);var ce=wt;function Dr(n,i){const o=this||jr,c=i||o,d=ce.from(c.headers);let h=c.data;return m.forEach(n,function(b){h=b.call(o,h,d.normalize(),i?i.status:void 0)}),d.normalize(),h}function Is(n){return!!(n&&n.__CANCEL__)}function De(n,i,o){x.call(this,n??"canceled",x.ERR_CANCELED,i,o),this.name="CanceledError"}m.inherits(De,x,{__CANCEL__:!0});function $s(n,i,o){const c=o.config.validateStatus;!o.status||!c||c(o.status)?n(o):i(new x("Request failed with status code "+o.status,[x.ERR_BAD_REQUEST,x.ERR_BAD_RESPONSE][Math.floor(o.status/100)-4],o.config,o.request,o))}function Uo(n){const i=/^([-+\w]{1,25})(:?\/\/|:)/.exec(n);return i&&i[1]||""}function Do(n,i){n=n||10;const o=new Array(n),c=new Array(n);let d=0,h=0,p;return i=i!==void 0?i:1e3,function(R){const g=Date.now(),w=c[h];p||(p=g),o[d]=R,c[d]=g;let v=h,$=0;for(;v!==d;)$+=o[v++],v=v%n;if(d=(d+1)%n,d===h&&(h=(h+1)%n),g-p<i)return;const G=w&&g-w;return G?Math.round($*1e3/G):void 0}}function Lo(n,i){let o=0,c=1e3/i,d,h;const p=(g,w=Date.now())=>{o=w,d=null,h&&(clearTimeout(h),h=null),n.apply(null,g)};return[(...g)=>{const w=Date.now(),v=w-o;v>=c?p(g,w):(d=g,h||(h=setTimeout(()=>{h=null,p(d)},c-v)))},()=>d&&p(d)]}const Tt=(n,i,o=3)=>{let c=0;const d=Do(50,250);return Lo(h=>{const p=h.loaded,b=h.lengthComputable?h.total:void 0,R=p-c,g=d(R),w=p<=b;c=p;const v={loaded:p,total:b,progress:b?p/b:void 0,bytes:R,rate:g||void 0,estimated:g&&b&&w?(b-p)/g:void 0,event:h,lengthComputable:b!=null,[i?"download":"upload"]:!0};n(v)},o)},Ks=(n,i)=>{const o=n!=null;return[c=>i[0]({lengthComputable:o,total:n,loaded:c}),i[1]]},Fs=n=>(...i)=>m.asap(()=>n(...i));var Ho=ee.hasStandardBrowserEnv?((n,i)=>o=>(o=new URL(o,ee.origin),n.protocol===o.protocol&&n.host===o.host&&(i||n.port===o.port)))(new URL(ee.origin),ee.navigator&&/(msie|trident)/i.test(ee.navigator.userAgent)):()=>!0,qo=ee.hasStandardBrowserEnv?{write(n,i,o,c,d,h){const p=[n+"="+encodeURIComponent(i)];m.isNumber(o)&&p.push("expires="+new Date(o).toGMTString()),m.isString(c)&&p.push("path="+c),m.isString(d)&&p.push("domain="+d),h===!0&&p.push("secure"),document.cookie=p.join("; ")},read(n){const i=document.cookie.match(new RegExp("(^|;\\s*)("+n+")=([^;]*)"));return i?decodeURIComponent(i[3]):null},remove(n){this.write(n,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function Mo(n){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(n)}function Io(n,i){return i?n.replace(/\/?\/$/,"")+"/"+i.replace(/^\/+/,""):n}function zs(n,i,o){let c=!Mo(i);return n&&c||o==!1?Io(n,i):i}const ks=n=>n instanceof ce?{...n}:n;function ve(n,i){i=i||{};const o={};function c(g,w,v,$){return m.isPlainObject(g)&&m.isPlainObject(w)?m.merge.call({caseless:$},g,w):m.isPlainObject(w)?m.merge({},w):m.isArray(w)?w.slice():w}function d(g,w,v,$){if(m.isUndefined(w)){if(!m.isUndefined(g))return c(void 0,g,v,$)}else return c(g,w,v,$)}function h(g,w){if(!m.isUndefined(w))return c(void 0,w)}function p(g,w){if(m.isUndefined(w)){if(!m.isUndefined(g))return c(void 0,g)}else return c(void 0,w)}function b(g,w,v){if(v in i)return c(g,w);if(v in n)return c(void 0,g)}const R={url:h,method:h,data:h,baseURL:p,transformRequest:p,transformResponse:p,paramsSerializer:p,timeout:p,timeoutMessage:p,withCredentials:p,withXSRFToken:p,adapter:p,responseType:p,xsrfCookieName:p,xsrfHeaderName:p,onUploadProgress:p,onDownloadProgress:p,decompress:p,maxContentLength:p,maxBodyLength:p,beforeRedirect:p,transport:p,httpAgent:p,httpsAgent:p,cancelToken:p,socketPath:p,responseEncoding:p,validateStatus:b,headers:(g,w,v)=>d(ks(g),ks(w),v,!0)};return m.forEach(Object.keys(Object.assign({},n,i)),function(w){const v=R[w]||d,$=v(n[w],i[w],w);m.isUndefined($)&&v!==b||(o[w]=$)}),o}var Ws=n=>{const i=ve({},n);let{data:o,withXSRFToken:c,xsrfHeaderName:d,xsrfCookieName:h,headers:p,auth:b}=i;i.headers=p=ce.from(p),i.url=Ds(zs(i.baseURL,i.url),n.params,n.paramsSerializer),b&&p.set("Authorization","Basic "+btoa((b.username||"")+":"+(b.password?unescape(encodeURIComponent(b.password)):"")));let R;if(m.isFormData(o)){if(ee.hasStandardBrowserEnv||ee.hasStandardBrowserWebWorkerEnv)p.setContentType(void 0);else if((R=p.getContentType())!==!1){const[g,...w]=R?R.split(";").map(v=>v.trim()).filter(Boolean):[];p.setContentType([g||"multipart/form-data",...w].join("; "))}}if(ee.hasStandardBrowserEnv&&(c&&m.isFunction(c)&&(c=c(i)),c||c!==!1&&Ho(i.url))){const g=d&&h&&qo.read(h);g&&p.set(d,g)}return i},$o=typeof XMLHttpRequest<"u"&&function(n){return new Promise(function(o,c){const d=Ws(n);let h=d.data;const p=ce.from(d.headers).normalize();let{responseType:b,onUploadProgress:R,onDownloadProgress:g}=d,w,v,$,G,A;function N(){G&&G(),A&&A(),d.cancelToken&&d.cancelToken.unsubscribe(w),d.signal&&d.signal.removeEventListener("abort",w)}let C=new XMLHttpRequest;C.open(d.method.toUpperCase(),d.url,!0),C.timeout=d.timeout;function z(){if(!C)return;const X=ce.from("getAllResponseHeaders"in C&&C.getAllResponseHeaders()),ne={data:!b||b==="text"||b==="json"?C.responseText:C.response,status:C.status,statusText:C.statusText,headers:X,config:n,request:C};$s(function(Ae){o(Ae),N()},function(Ae){c(Ae),N()},ne),C=null}"onloadend"in C?C.onloadend=z:C.onreadystatechange=function(){!C||C.readyState!==4||C.status===0&&!(C.responseURL&&C.responseURL.indexOf("file:")===0)||setTimeout(z)},C.onabort=function(){C&&(c(new x("Request aborted",x.ECONNABORTED,n,C)),C=null)},C.onerror=function(){c(new x("Network Error",x.ERR_NETWORK,n,C)),C=null},C.ontimeout=function(){let ye=d.timeout?"timeout of "+d.timeout+"ms exceeded":"timeout exceeded";const ne=d.transitional||Hs;d.timeoutErrorMessage&&(ye=d.timeoutErrorMessage),c(new x(ye,ne.clarifyTimeoutError?x.ETIMEDOUT:x.ECONNABORTED,n,C)),C=null},h===void 0&&p.setContentType(null),"setRequestHeader"in C&&m.forEach(p.toJSON(),function(ye,ne){C.setRequestHeader(ne,ye)}),m.isUndefined(d.withCredentials)||(C.withCredentials=!!d.withCredentials),b&&b!=="json"&&(C.responseType=d.responseType),g&&([$,A]=Tt(g,!0),C.addEventListener("progress",$)),R&&C.upload&&([v,G]=Tt(R),C.upload.addEventListener("progress",v),C.upload.addEventListener("loadend",G)),(d.cancelToken||d.signal)&&(w=X=>{C&&(c(!X||X.type?new De(null,n,C):X),C.abort(),C=null)},d.cancelToken&&d.cancelToken.subscribe(w),d.signal&&(d.signal.aborted?w():d.signal.addEventListener("abort",w)));const J=Uo(d.url);if(J&&ee.protocols.indexOf(J)===-1){c(new x("Unsupported protocol "+J+":",x.ERR_BAD_REQUEST,n));return}C.send(h||null)})},Ko=(n,i)=>{const{length:o}=n=n?n.filter(Boolean):[];if(i||o){let c=new AbortController,d;const h=function(g){if(!d){d=!0,b();const w=g instanceof Error?g:this.reason;c.abort(w instanceof x?w:new De(w instanceof Error?w.message:w))}};let p=i&&setTimeout(()=>{p=null,h(new x(`timeout ${i} of ms exceeded`,x.ETIMEDOUT))},i);const b=()=>{n&&(p&&clearTimeout(p),p=null,n.forEach(g=>{g.unsubscribe?g.unsubscribe(h):g.removeEventListener("abort",h)}),n=null)};n.forEach(g=>g.addEventListener("abort",h));const{signal:R}=c;return R.unsubscribe=()=>m.asap(b),R}};const Fo=function*(n,i){let o=n.byteLength;if(o<i){yield n;return}let c=0,d;for(;c<o;)d=c+i,yield n.slice(c,d),c=d},zo=async function*(n,i){for await(const o of ko(n))yield*Fo(o,i)},ko=async function*(n){if(n[Symbol.asyncIterator]){yield*n;return}const i=n.getReader();try{for(;;){const{done:o,value:c}=await i.read();if(o)break;yield c}}finally{await i.cancel()}},Vs=(n,i,o,c)=>{const d=zo(n,i);let h=0,p,b=R=>{p||(p=!0,c&&c(R))};return new ReadableStream({async pull(R){try{const{done:g,value:w}=await d.next();if(g){b(),R.close();return}let v=w.byteLength;if(o){let $=h+=v;o($)}R.enqueue(new Uint8Array(w))}catch(g){throw b(g),g}},cancel(R){return b(R),d.return()}},{highWaterMark:2})},St=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",Gs=St&&typeof ReadableStream=="function",Wo=St&&(typeof TextEncoder=="function"?(n=>i=>n.encode(i))(new TextEncoder):async n=>new Uint8Array(await new Response(n).arrayBuffer())),Js=(n,...i)=>{try{return!!n(...i)}catch{return!1}},Vo=Gs&&Js(()=>{let n=!1;const i=new Request(ee.origin,{body:new ReadableStream,method:"POST",get duplex(){return n=!0,"half"}}).headers.has("Content-Type");return n&&!i}),Xs=64*1024,Lr=Gs&&Js(()=>m.isReadableStream(new Response("").body)),Rt={stream:Lr&&(n=>n.body)};St&&(n=>{["text","arrayBuffer","blob","formData","stream"].forEach(i=>{!Rt[i]&&(Rt[i]=m.isFunction(n[i])?o=>o[i]():(o,c)=>{throw new x(`Response type '${i}' is not supported`,x.ERR_NOT_SUPPORT,c)})})})(new Response);const Go=async n=>{if(n==null)return 0;if(m.isBlob(n))return n.size;if(m.isSpecCompliantForm(n))return(await new Request(ee.origin,{method:"POST",body:n}).arrayBuffer()).byteLength;if(m.isArrayBufferView(n)||m.isArrayBuffer(n))return n.byteLength;if(m.isURLSearchParams(n)&&(n=n+""),m.isString(n))return(await Wo(n)).byteLength},Jo=async(n,i)=>{const o=m.toFiniteNumber(n.getContentLength());return o??Go(i)};var Xo=St&&(async n=>{let{url:i,method:o,data:c,signal:d,cancelToken:h,timeout:p,onDownloadProgress:b,onUploadProgress:R,responseType:g,headers:w,withCredentials:v="same-origin",fetchOptions:$}=Ws(n);g=g?(g+"").toLowerCase():"text";let G=Ko([d,h&&h.toAbortSignal()],p),A;const N=G&&G.unsubscribe&&(()=>{G.unsubscribe()});let C;try{if(R&&Vo&&o!=="get"&&o!=="head"&&(C=await Jo(w,c))!==0){let ne=new Request(i,{method:"POST",body:c,duplex:"half"}),ge;if(m.isFormData(c)&&(ge=ne.headers.get("content-type"))&&w.setContentType(ge),ne.body){const[Ae,Pt]=Ks(C,Tt(Fs(R)));c=Vs(ne.body,Xs,Ae,Pt)}}m.isString(v)||(v=v?"include":"omit");const z="credentials"in Request.prototype;A=new Request(i,{...$,signal:G,method:o.toUpperCase(),headers:w.normalize().toJSON(),body:c,duplex:"half",credentials:z?v:void 0});let J=await fetch(A);const X=Lr&&(g==="stream"||g==="response");if(Lr&&(b||X&&N)){const ne={};["status","statusText","headers"].forEach(ni=>{ne[ni]=J[ni]});const ge=m.toFiniteNumber(J.headers.get("content-length")),[Ae,Pt]=b&&Ks(ge,Tt(Fs(b),!0))||[];J=new Response(Vs(J.body,Xs,Ae,()=>{Pt&&Pt(),N&&N()}),ne)}g=g||"text";let ye=await Rt[m.findKey(Rt,g)||"text"](J,n);return!X&&N&&N(),await new Promise((ne,ge)=>{$s(ne,ge,{data:ye,headers:ce.from(J.headers),status:J.status,statusText:J.statusText,config:n,request:A})})}catch(z){throw N&&N(),z&&z.name==="TypeError"&&/fetch/i.test(z.message)?Object.assign(new x("Network Error",x.ERR_NETWORK,n,A),{cause:z.cause||z}):x.from(z,z&&z.code,n,A)}});const Hr={http:lo,xhr:$o,fetch:Xo};m.forEach(Hr,(n,i)=>{if(n){try{Object.defineProperty(n,"name",{value:i})}catch{}Object.defineProperty(n,"adapterName",{value:i})}});const Ys=n=>`- ${n}`,Yo=n=>m.isFunction(n)||n===null||n===!1;var Zs={getAdapter:n=>{n=m.isArray(n)?n:[n];const{length:i}=n;let o,c;const d={};for(let h=0;h<i;h++){o=n[h];let p;if(c=o,!Yo(o)&&(c=Hr[(p=String(o)).toLowerCase()],c===void 0))throw new x(`Unknown adapter '${p}'`);if(c)break;d[p||"#"+h]=c}if(!c){const h=Object.entries(d).map(([b,R])=>`adapter ${b} `+(R===!1?"is not supported by the environment":"is not available in the build"));let p=i?h.length>1?`since :
|
|
4
|
-
`+h.map(Ys).join(`
|
|
5
|
-
`):" "+Ys(h[0]):"as no adapter specified";throw new x("There is no suitable adapter to dispatch the request "+p,"ERR_NOT_SUPPORT")}return c},adapters:Hr};function qr(n){if(n.cancelToken&&n.cancelToken.throwIfRequested(),n.signal&&n.signal.aborted)throw new De(null,n)}function Qs(n){return qr(n),n.headers=ce.from(n.headers),n.data=Dr.call(n,n.transformRequest),["post","put","patch"].indexOf(n.method)!==-1&&n.headers.setContentType("application/x-www-form-urlencoded",!1),Zs.getAdapter(n.adapter||jr.adapter)(n).then(function(c){return qr(n),c.data=Dr.call(n,n.transformResponse,c),c.headers=ce.from(c.headers),c},function(c){return Is(c)||(qr(n),c&&c.response&&(c.response.data=Dr.call(n,n.transformResponse,c.response),c.response.headers=ce.from(c.response.headers))),Promise.reject(c)})}const ei="1.8.2",vt={};["object","boolean","number","function","string","symbol"].forEach((n,i)=>{vt[n]=function(c){return typeof c===n||"a"+(i<1?"n ":" ")+n}});const ti={};vt.transitional=function(i,o,c){function d(h,p){return"[Axios v"+ei+"] Transitional option '"+h+"'"+p+(c?". "+c:"")}return(h,p,b)=>{if(i===!1)throw new x(d(p," has been removed"+(o?" in "+o:"")),x.ERR_DEPRECATED);return o&&!ti[p]&&(ti[p]=!0,console.warn(d(p," has been deprecated since v"+o+" and will be removed in the near future"))),i?i(h,p,b):!0}},vt.spelling=function(i){return(o,c)=>(console.warn(`${c} is likely a misspelling of ${i}`),!0)};function Zo(n,i,o){if(typeof n!="object")throw new x("options must be an object",x.ERR_BAD_OPTION_VALUE);const c=Object.keys(n);let d=c.length;for(;d-- >0;){const h=c[d],p=i[h];if(p){const b=n[h],R=b===void 0||p(b,h,n);if(R!==!0)throw new x("option "+h+" must be "+R,x.ERR_BAD_OPTION_VALUE);continue}if(o!==!0)throw new x("Unknown option "+h,x.ERR_BAD_OPTION)}}var At={assertOptions:Zo,validators:vt};const he=At.validators;class Ct{constructor(i){this.defaults=i,this.interceptors={request:new Ls,response:new Ls}}async request(i,o){try{return await this._request(i,o)}catch(c){if(c instanceof Error){let d={};Error.captureStackTrace?Error.captureStackTrace(d):d=new Error;const h=d.stack?d.stack.replace(/^.+\n/,""):"";try{c.stack?h&&!String(c.stack).endsWith(h.replace(/^.+\n.+\n/,""))&&(c.stack+=`
|
|
6
|
-
`+h):c.stack=h}catch{}}throw c}}_request(i,o){typeof i=="string"?(o=o||{},o.url=i):o=i||{},o=ve(this.defaults,o);const{transitional:c,paramsSerializer:d,headers:h}=o;c!==void 0&&At.assertOptions(c,{silentJSONParsing:he.transitional(he.boolean),forcedJSONParsing:he.transitional(he.boolean),clarifyTimeoutError:he.transitional(he.boolean)},!1),d!=null&&(m.isFunction(d)?o.paramsSerializer={serialize:d}:At.assertOptions(d,{encode:he.function,serialize:he.function},!0)),o.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?o.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:o.allowAbsoluteUrls=!0),At.assertOptions(o,{baseUrl:he.spelling("baseURL"),withXsrfToken:he.spelling("withXSRFToken")},!0),o.method=(o.method||this.defaults.method||"get").toLowerCase();let p=h&&m.merge(h.common,h[o.method]);h&&m.forEach(["delete","get","head","post","put","patch","common"],A=>{delete h[A]}),o.headers=ce.concat(p,h);const b=[];let R=!0;this.interceptors.request.forEach(function(N){typeof N.runWhen=="function"&&N.runWhen(o)===!1||(R=R&&N.synchronous,b.unshift(N.fulfilled,N.rejected))});const g=[];this.interceptors.response.forEach(function(N){g.push(N.fulfilled,N.rejected)});let w,v=0,$;if(!R){const A=[Qs.bind(this),void 0];for(A.unshift.apply(A,b),A.push.apply(A,g),$=A.length,w=Promise.resolve(o);v<$;)w=w.then(A[v++],A[v++]);return w}$=b.length;let G=o;for(v=0;v<$;){const A=b[v++],N=b[v++];try{G=A(G)}catch(C){N.call(this,C);break}}try{w=Qs.call(this,G)}catch(A){return Promise.reject(A)}for(v=0,$=g.length;v<$;)w=w.then(g[v++],g[v++]);return w}getUri(i){i=ve(this.defaults,i);const o=zs(i.baseURL,i.url,i.allowAbsoluteUrls);return Ds(o,i.params,i.paramsSerializer)}}m.forEach(["delete","get","head","options"],function(i){Ct.prototype[i]=function(o,c){return this.request(ve(c||{},{method:i,url:o,data:(c||{}).data}))}}),m.forEach(["post","put","patch"],function(i){function o(c){return function(h,p,b){return this.request(ve(b||{},{method:i,headers:c?{"Content-Type":"multipart/form-data"}:{},url:h,data:p}))}}Ct.prototype[i]=o(),Ct.prototype[i+"Form"]=o(!0)});var Ot=Ct;class Mr{constructor(i){if(typeof i!="function")throw new TypeError("executor must be a function.");let o;this.promise=new Promise(function(h){o=h});const c=this;this.promise.then(d=>{if(!c._listeners)return;let h=c._listeners.length;for(;h-- >0;)c._listeners[h](d);c._listeners=null}),this.promise.then=d=>{let h;const p=new Promise(b=>{c.subscribe(b),h=b}).then(d);return p.cancel=function(){c.unsubscribe(h)},p},i(function(h,p,b){c.reason||(c.reason=new De(h,p,b),o(c.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(i){if(this.reason){i(this.reason);return}this._listeners?this._listeners.push(i):this._listeners=[i]}unsubscribe(i){if(!this._listeners)return;const o=this._listeners.indexOf(i);o!==-1&&this._listeners.splice(o,1)}toAbortSignal(){const i=new AbortController,o=c=>{i.abort(c)};return this.subscribe(o),i.signal.unsubscribe=()=>this.unsubscribe(o),i.signal}static source(){let i;return{token:new Mr(function(d){i=d}),cancel:i}}}var Qo=Mr;function ec(n){return function(o){return n.apply(null,o)}}function tc(n){return m.isObject(n)&&n.isAxiosError===!0}const Ir={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Ir).forEach(([n,i])=>{Ir[i]=n});var rc=Ir;function ri(n){const i=new Ot(n),o=e(Ot.prototype.request,i);return m.extend(o,Ot.prototype,i,{allOwnKeys:!0}),m.extend(o,i,null,{allOwnKeys:!0}),o.create=function(d){return ri(ve(n,d))},o}const W=ri(jr);return W.Axios=Ot,W.CanceledError=De,W.CancelToken=Qo,W.isCancel=Is,W.VERSION=ei,W.toFormData=_t,W.AxiosError=x,W.Cancel=W.CanceledError,W.all=function(i){return Promise.all(i)},W.spread=ec,W.isAxiosError=tc,W.mergeConfig=ve,W.AxiosHeaders=ce,W.formToJSON=n=>qs(m.isHTMLForm(n)?new FormData(n):n),W.getAdapter=Zs.getAdapter,W.HttpStatusCode=rc,W.default=W,Dt=W,Dt}var dt={exports:{}},Vr;function Gr(){if(Vr)return dt.exports;Vr=1;const e=a=>typeof a=="object"&&a!==null,t=Symbol("skip"),r=a=>e(a)&&!(a instanceof RegExp)&&!(a instanceof Error)&&!(a instanceof Date),s=(a,u,l,f=new WeakMap)=>{if(l={deep:!1,target:{},...l},f.has(a))return f.get(a);f.set(a,l.target);const{target:y}=l;delete l.target;const _=T=>T.map(S=>r(S)?s(S,u,l,f):S);if(Array.isArray(a))return _(a);for(const[T,S]of Object.entries(a)){const B=u(T,S,a);if(B===t)continue;let[M,U,{shouldRecurse:F=!0}={}]=B;M!=="__proto__"&&(l.deep&&F&&r(U)&&(U=Array.isArray(U)?_(U):s(U,u,l,f)),y[M]=U)}return y};return dt.exports=(a,u,l)=>{if(!e(a))throw new TypeError(`Expected an object, got \`${a}\` (${typeof a})`);return s(a,u,l)},dt.exports.mapObjectSkip=t,dt.exports}var ft={exports:{}},Jr;function di(){if(Jr)return ft.exports;Jr=1;const e=r=>{let s=!1,a=!1,u=!1;for(let l=0;l<r.length;l++){const f=r[l];s&&/[a-zA-Z]/.test(f)&&f.toUpperCase()===f?(r=r.slice(0,l)+"-"+r.slice(l),s=!1,u=a,a=!0,l++):a&&u&&/[a-zA-Z]/.test(f)&&f.toLowerCase()===f?(r=r.slice(0,l-1)+"-"+r.slice(l-1),u=a,a=!1,s=!0):(s=f.toLowerCase()===f&&f.toUpperCase()!==f,u=a,a=f.toUpperCase()===f&&f.toLowerCase()!==f)}return r},t=(r,s)=>{if(!(typeof r=="string"||Array.isArray(r)))throw new TypeError("Expected the input to be `string | string[]`");s=Object.assign({pascalCase:!1},s);const a=l=>s.pascalCase?l.charAt(0).toUpperCase()+l.slice(1):l;return Array.isArray(r)?r=r.map(l=>l.trim()).filter(l=>l.length).join("-"):r=r.trim(),r.length===0?"":r.length===1?s.pascalCase?r.toUpperCase():r.toLowerCase():(r!==r.toLowerCase()&&(r=e(r)),r=r.replace(/^[_.\- ]+/,"").toLowerCase().replace(/[_.\- ]+(\w|$)/g,(l,f)=>f.toUpperCase()).replace(/\d+(\w|$)/g,l=>l.toUpperCase()),a(r))};return ft.exports=t,ft.exports.default=t,ft.exports}var Lt,Xr;function fi(){if(Xr)return Lt;Xr=1;class e{constructor(r={}){if(!(r.maxSize&&r.maxSize>0))throw new TypeError("`maxSize` must be a number greater than 0");this.maxSize=r.maxSize,this.cache=new Map,this.oldCache=new Map,this._size=0}_set(r,s){this.cache.set(r,s),this._size++,this._size>=this.maxSize&&(this._size=0,this.oldCache=this.cache,this.cache=new Map)}get(r){if(this.cache.has(r))return this.cache.get(r);if(this.oldCache.has(r)){const s=this.oldCache.get(r);return this.oldCache.delete(r),this._set(r,s),s}}set(r,s){return this.cache.has(r)?this.cache.set(r,s):this._set(r,s),this}has(r){return this.cache.has(r)||this.oldCache.has(r)}peek(r){if(this.cache.has(r))return this.cache.get(r);if(this.oldCache.has(r))return this.oldCache.get(r)}delete(r){const s=this.cache.delete(r);return s&&this._size--,this.oldCache.delete(r)||s}clear(){this.cache.clear(),this.oldCache.clear(),this._size=0}*keys(){for(const[r]of this)yield r}*values(){for(const[,r]of this)yield r}*[Symbol.iterator](){for(const r of this.cache)yield r;for(const r of this.oldCache){const[s]=r;this.cache.has(s)||(yield r)}}get size(){let r=0;for(const s of this.oldCache.keys())this.cache.has(s)||r++;return this._size+r}}return Lt=e,Lt}var Ht,Yr;function hi(){if(Yr)return Ht;Yr=1;const e=Gr(),t=di(),r=fi(),s=(f,y)=>f.some(_=>typeof _=="string"?_===y:(_.lastIndex=0,_.test(y))),a=new r({maxSize:1e5}),u=f=>typeof f=="object"&&f!==null&&!(f instanceof RegExp)&&!(f instanceof Error)&&!(f instanceof Date),l=(f,y)=>{if(!u(f))return f;y={deep:!1,pascalCase:!1,...y};const{exclude:_,pascalCase:T,stopPaths:S,deep:B}=y,M=new Set(S),U=F=>(q,P)=>{if(B&&u(P)){const D=F===void 0?q:`${F}.${q}`;M.has(D)||(P=e(P,U(D)))}if(!(_&&s(_,q))){const D=T?`${q}_`:q;if(a.has(D))q=a.get(D);else{const H=t(q,{pascalCase:T});q.length<100&&a.set(D,H),q=H}}return[q,P]};return e(f,U(void 0))};return Ht=(f,y)=>Array.isArray(f)?Object.keys(f).map(_=>l(f[_],y)):l(f,y),Ht}var qt,Zr;function Qr(){return Zr||(Zr=1,qt=Qr()),qt}var ht=function(){return ht=Object.assign||function(t){for(var r,s=1,a=arguments.length;s<a;s++){r=arguments[s];for(var u in r)Object.prototype.hasOwnProperty.call(r,u)&&(t[u]=r[u])}return t},ht.apply(this,arguments)};typeof SuppressedError=="function"&&SuppressedError;function pi(e){return e.toLowerCase()}var mi=[/([a-z0-9])([A-Z])/g,/([A-Z])([A-Z][a-z])/g],yi=/[^A-Z0-9]+/gi;function Ei(e,t){t===void 0&&(t={});for(var r=t.splitRegexp,s=r===void 0?mi:r,a=t.stripRegexp,u=a===void 0?yi:a,l=t.transform,f=l===void 0?pi:l,y=t.delimiter,_=y===void 0?" ":y,T=en(en(e,s,"$1\0$2"),u,"\0"),S=0,B=T.length;T.charAt(S)==="\0";)S++;for(;T.charAt(B-1)==="\0";)B--;return T.slice(S,B).split("\0").map(f).join(_)}function en(e,t,r){return t instanceof RegExp?e.replace(t,r):t.reduce(function(s,a){return s.replace(a,r)},e)}function bi(e,t){return t===void 0&&(t={}),Ei(e,ht({delimiter:"."},t))}function _i(e,t){return t===void 0&&(t={}),bi(e,ht({delimiter:"_"},t))}const gi=ui(Object.freeze(Object.defineProperty({__proto__:null,snakeCase:_i},Symbol.toStringTag,{value:"Module"})));var Mt,tn;function wi(){if(tn)return Mt;tn=1,Mt=s;var e=/\s/,t=/(_|-|\.|:)/,r=/([a-z][A-Z]|[A-Z][a-z])/;function s(y){return e.test(y)?y.toLowerCase():t.test(y)?(u(y)||y).toLowerCase():r.test(y)?f(y).toLowerCase():y.toLowerCase()}var a=/[\W_]+(.|$)/g;function u(y){return y.replace(a,function(_,T){return T?" "+T:""})}var l=/(.)([A-Z]+)/g;function f(y){return y.replace(l,function(_,T,S){return T+" "+S.toLowerCase().split("").join(" ")})}return Mt}var It,rn;function Ti(){if(rn)return It;rn=1;var e=wi();It=t;function t(r){return e(r).replace(/[\W_]+(.|$)/g,function(s,a){return a?" "+a:""}).trim()}return It}var $t,nn;function Si(){if(nn)return $t;nn=1;var e=Ti();$t=t;function t(r){return e(r).replace(/\s/g,"_")}return $t}var Kt,sn;function Ri(){if(sn)return Kt;sn=1;const e=Gr(),t=Si();Kt=function(s,a){return a=Object.assign({deep:!0,exclude:[]},a),e(s,function(u,l){return[r(a.exclude,u)?u:t(u),l]},a)};function r(s,a){return s.some(function(u){return typeof u=="string"?u===a:u.test(a)})}return Kt}var qe={},an;function on(){if(an)return qe;an=1,Object.defineProperty(qe,"__esModule",{value:!0}),qe.BasisTheoryApiError=void 0;function e(r){function s(){var a=Reflect.construct(r,Array.from(arguments));return Object.setPrototypeOf(a,Object.getPrototypeOf(this)),a}return s.prototype=Object.create(r.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),Object.setPrototypeOf?Object.setPrototypeOf(s,r):s.__proto__=r,s}let t=class si extends e(Error){constructor(s,a,u){super(s),this.status=a,this.data=u,this.name="BasisTheoryApiError",Object.setPrototypeOf(this,si.prototype)}};return qe.BasisTheoryApiError=t,qe}var cn;function Pe(){if(cn)return O;cn=1,Object.defineProperty(O,"__esModule",{value:!0}),O.transformTokenResponseCamelCase=O.transformTokenRequestSnakeCase=O.transformResponseCamelCase=O.transformRequestSnakeCase=O.transformReactorResponseCamelCase=O.transformReactorRequestSnakeCase=O.transformProxyResponseCamelCase=O.transformProxyRequestSnakeCase=O.proxyRaw=O.getRuntime=O.getQueryParams=O.getOSVersion=O.getBrowser=O.errorInterceptor=O.dataExtractor=O.dataAndHeadersExtractor=O.createRequestConfig=O.concatResponseTransformerWithDefault=O.concatRequestTransformerWithDefault=O.buildUserAgentString=O.buildClientUserAgentString=O.assertInit=void 0;var e=f(Wr()),t=f(hi()),r=f(Qr()),s=gi,a=f(Ri()),u=on(),l=zr();function f(E){return E&&E.__esModule?E:{default:E}}const y=E=>{if(E==null)throw new Error("BasisTheory has not yet been properly initialized.");return E};O.assertInit=y;const _=E=>{if(!(typeof E>"u"))return(0,a.default)(E,{deep:!0})};O.transformRequestSnakeCase=_;const T=E=>E;O.proxyRaw=T;const S=E=>{if(!(typeof E>"u"))return{...(0,a.default)(E,{deep:!0}),...E.configuration!==void 0?{configuration:E.configuration}:{}}};O.transformReactorRequestSnakeCase=S;const B=E=>{if(!(typeof E>"u"))return{...(0,a.default)(E,{deep:!0}),...E.configuration!==void 0?{configuration:E.configuration}:{}}};O.transformProxyRequestSnakeCase=B;const M=E=>{if(!(typeof E>"u"))return{...(0,a.default)(E,{deep:!0}),...E.data!==void 0?{data:E.data}:{},...E.metadata!==void 0?{metadata:E.metadata}:{}}};O.transformTokenRequestSnakeCase=M;const U=E=>E&&(E==null?void 0:E.pagination)!==void 0&&(E==null?void 0:E.data)!==void 0,F=E=>{if(!(typeof E>"u"))return U(E)?{data:E.data.map(I=>({...(0,t.default)(I,{deep:!0}),...I.data!==void 0?{data:I.data}:{},...I.metadata!==void 0?{metadata:I.metadata}:{}})),pagination:(0,t.default)(E.pagination,{deep:!0})}:{...(0,t.default)(E,{deep:!0}),...E.data!==void 0?{data:E.data}:{},...E.metadata!==void 0?{metadata:E.metadata}:{}}};O.transformTokenResponseCamelCase=F;const q=E=>{if(!(typeof E>"u"))return U(E)?{data:E.data.map(I=>({...(0,t.default)(I,{deep:!0}),...I.configuration!==void 0?{configuration:I.configuration}:{}})),pagination:(0,t.default)(E.pagination,{deep:!0})}:{...(0,t.default)(E,{deep:!0}),...E.configuration!==void 0?{configuration:E.configuration}:{}}};O.transformReactorResponseCamelCase=q;const P=E=>{if(!(typeof E>"u"))return U(E)?{data:E.data.map(I=>({...(0,t.default)(I,{deep:!0}),...I.configuration!==void 0?{configuration:I.configuration}:{}})),pagination:(0,t.default)(E.pagination,{deep:!0})}:{...(0,t.default)(E,{deep:!0}),...E.configuration!==void 0?{configuration:E.configuration}:{}}};O.transformProxyResponseCamelCase=P;const D=E=>{if(!(typeof E>"u"))return(0,t.default)(E,{deep:!0})};O.transformResponseCamelCase=D;const H=E=>E==null?void 0:E.data;O.dataExtractor=H;const Z=E=>({data:E==null?void 0:E.data,headers:E==null?void 0:E.headers});O.dataAndHeadersExtractor=Z;const de=E=>[E,...e.default.defaults.transformRequest];O.concatRequestTransformerWithDefault=de;const ot=E=>[...e.default.defaults.transformResponse,E];O.concatResponseTransformerWithDefault=ot;const gr=(E,j)=>{if(!E)return j?{...j.transformRequest!==void 0?{transformRequest:de(j.transformRequest)}:{},...j.transformResponse!==void 0?{transformResponse:ot(j.transformResponse)}:{}}:void 0;const{apiKey:k,correlationId:I,idempotencyKey:re,transactionId:Q,query:pe,headers:me}=E,ut=k?{[l.API_KEY_HEADER]:k}:{},vr=I?{[l.BT_TRACE_ID_HEADER]:I}:{},Ar=re?{[l.BT_IDEMPOTENCY_KEY_HEADER]:re}:{},Cr=Q?{[l.BT_TRANSACTION_ID_HEADER]:Q}:{};return{headers:{...ut,...vr,...Ar,...Cr,...typeof me<"u"&&{...me}},...typeof pe<"u"&&{params:pe},...(j==null?void 0:j.transformRequest)!==void 0?{transformRequest:de(j.transformRequest)}:{},...(j==null?void 0:j.transformResponse)!==void 0?{transformResponse:ot(j.transformResponse)}:{}}};O.createRequestConfig=gr;const wr=E=>{var j,k;const I=((j=E.response)===null||j===void 0?void 0:j.status)||-1,re=(k=E.response)===null||k===void 0?void 0:k.data;throw new u.BasisTheoryApiError(E.message,I,re)};O.errorInterceptor=wr;const Tr=(E={})=>{const j=Object.keys(E);if(j.length){const k=new URLSearchParams,I=(re,Q,pe=!1)=>{const me=typeof Q,ut=pe?re:(0,s.snakeCase)(re);(Q===null||["boolean","number","string"].includes(me))&&k.append(ut,Q)};return j.forEach(re=>{const Q=E[re];Array.isArray(Q)?Q.forEach(pe=>{I(String(re),pe)}):Q&&typeof Q=="object"?Object.keys(Q).forEach(me=>{I(`${String(re)}.${me}`,Q[me],!0)}):I(String(re),Q)}),`?${k.toString()}`}return""};O.getQueryParams=Tr;const Sr=E=>`(${E.name||""}; ${E.version||""}; ${E.url||""})`,Rr=E=>{let j=`${l.USER_AGENT_CLIENT}/unknown`;return E&&Object.keys(E||{}).length&&(j+=` ${Sr(E)}`),j};O.buildUserAgentString=Rr;const Et=()=>{const{userAgent:E}=window.navigator;let j="unknown";const k=l.BROWSER_LIST.find(I=>E.includes(I.browserUA));if(k)try{j=E.split(`${k.browserUA}/`)[1]}catch{j="unknown"}return`${(k==null?void 0:k.browserName)||"unknown"}/${j}`};O.getBrowser=Et;const _e=()=>typeof window=="object"&&window.navigator.product==="ReactNative",ct=()=>{if(_e())return"ReactNative";if(typeof window>"u")try{return`${r.default.type()}/${r.default.version()}`}catch{return"unknown"}try{const j=window.navigator.appVersion.match(/\(([^)]+)\)/u);return j&&j.length>1?j[1]:"unknown"}catch{return"unknown"}};O.getOSVersion=ct;const fe=()=>_e()?"ReactNative":typeof window>"u"?`NodeJS/${process.version}`:Et();O.getRuntime=fe;const bt=E=>{const j={client:l.USER_AGENT_CLIENT,clientVersion:"unknown",osVersion:ct(),runtimeVersion:fe(),application:{}};return E&&(j.application=E),JSON.stringify((0,a.default)(j))};return O.buildClientUserAgentString=bt,O}var Me={},un;function vi(){if(un)return Me;un=1,Object.defineProperty(Me,"__esModule",{value:!0}),Me.BasisTheoryValidationError=void 0;function e(r){function s(){var a=Reflect.construct(r,Array.from(arguments));return Object.setPrototypeOf(a,Object.getPrototypeOf(this)),a}return s.prototype=Object.create(r.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),Object.setPrototypeOf?Object.setPrototypeOf(s,r):s.__proto__=r,s}let t=class ii extends e(Error){constructor(s,a,u){super(s),this.details=a,this.validation=u,this.name="BasisTheoryValidationError",Object.setPrototypeOf(this,ii.prototype)}};return Me.BasisTheoryValidationError=t,Me}var Ie={},ln;function Ai(){if(ln)return Ie;ln=1,Object.defineProperty(Ie,"__esModule",{value:!0}),Ie.HttpClientError=void 0;function e(r){function s(){var a=Reflect.construct(r,Array.from(arguments));return Object.setPrototypeOf(a,Object.getPrototypeOf(this)),a}return s.prototype=Object.create(r.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),Object.setPrototypeOf?Object.setPrototypeOf(s,r):s.__proto__=r,s}let t=class ai extends e(Error){constructor(s,a,u,l){super(s),this.name="HttpClientError",this.status=a,this.data=u,this.headers=l,Object.setPrototypeOf(this,ai.prototype)}};return Ie.HttpClientError=t,Ie}var dn;function se(){return dn||(dn=1,function(e){Object.defineProperty(e,"__esModule",{value:!0});var t={BasisTheoryApiError:!0,BasisTheoryValidationError:!0,HttpClientError:!0};Object.defineProperty(e,"BasisTheoryApiError",{enumerable:!0,get:function(){return a.BasisTheoryApiError}}),Object.defineProperty(e,"BasisTheoryValidationError",{enumerable:!0,get:function(){return u.BasisTheoryValidationError}}),Object.defineProperty(e,"HttpClientError",{enumerable:!0,get:function(){return l.HttpClientError}});var r=zr();Object.keys(r).forEach(function(f){f==="default"||f==="__esModule"||Object.prototype.hasOwnProperty.call(t,f)||f in e&&e[f]===r[f]||Object.defineProperty(e,f,{enumerable:!0,get:function(){return r[f]}})});var s=Pe();Object.keys(s).forEach(function(f){f==="default"||f==="__esModule"||Object.prototype.hasOwnProperty.call(t,f)||f in e&&e[f]===s[f]||Object.defineProperty(e,f,{enumerable:!0,get:function(){return s[f]}})});var a=on(),u=vi(),l=Ai()}(Ut)),Ut}var Ft={},fn={},hn;function Ci(){return hn||(hn=1),fn}var $e={},pn;function Oi(){if(pn)return $e;pn=1,Object.defineProperty($e,"__esModule",{value:!0}),$e.BasisTheoryService=void 0;var e=r(Wr()),t=se();function r(a){return a&&a.__esModule?a:{default:a}}let s=class{constructor(u){const{apiKey:l,baseURL:f,transformRequest:y,transformResponse:_,appInfo:T}=u;if(typeof e.default=="string")throw new Error("basis-theory-js@1.77.0+ and basis-theory-react@1.12.1+ are not supported with CRA 5, go to https://github.com/Basis-Theory/basis-theory-js/issues/365#issuecomment-1662883062 for workarounds.");this.client=e.default.create({baseURL:f,headers:{[t.API_KEY_HEADER]:l,[t.CLIENT_USER_AGENT_HEADER]:(0,t.buildClientUserAgentString)(T),...typeof window>"u"&&{[t.USER_AGENT_HEADER]:(0,t.buildUserAgentString)(T)}},transformRequest:[].concat(y||t.transformRequestSnakeCase,e.default.defaults.transformRequest),transformResponse:e.default.defaults.transformResponse.concat(_||t.transformResponseCamelCase)}),this.client.interceptors.response.use(void 0,t.errorInterceptor)}};return $e.BasisTheoryService=s,$e}var mn;function ie(){return mn||(mn=1,function(e){Object.defineProperty(e,"__esModule",{value:!0});var t=Ci();Object.keys(t).forEach(function(s){s==="default"||s==="__esModule"||s in e&&e[s]===t[s]||Object.defineProperty(e,s,{enumerable:!0,get:function(){return t[s]}})});var r=Oi();Object.keys(r).forEach(function(s){s==="default"||s==="__esModule"||s in e&&e[s]===r[s]||Object.defineProperty(e,s,{enumerable:!0,get:function(){return r[s]}})})}(Ft)),Ft}var yn;function Pi(){if(yn)return He;yn=1,Object.defineProperty(He,"__esModule",{value:!0}),He.BasisTheoryTransactions=void 0;var e=se(),t=Pe(),r=ie();let s=class extends r.BasisTheoryService{constructor(u){const l={...u};l.transformRequest=[].concat(t.transformProxyRequestSnakeCase,u.transformRequest||[]),l.transformResponse=[].concat(t.transformProxyResponseCamelCase,u.transformResponse||[]),super(l)}create(u={}){return this.client.post("/",void 0,(0,e.createRequestConfig)(u)).then(t.dataExtractor)}commit(u,l={}){const f=`/${u}/commit`;return this.client.post(f,void 0,(0,e.createRequestConfig)(l)).then(t.dataExtractor)}rollback(u,l={}){const f=`/${u}/rollback`;return this.client.post(f,void 0,(0,e.createRequestConfig)(l)).then(t.dataExtractor)}};return He.BasisTheoryTransactions=s,He}var En;function Bi(){return En||(En=1,function(e){Object.defineProperty(e,"__esModule",{value:!0});var t=Pi();Object.keys(t).forEach(function(r){r==="default"||r==="__esModule"||r in e&&e[r]===t[r]||Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[r]}})})}(jt)),jt}var zt={},Ke={},Fe={},bn;function Te(){if(bn)return Fe;bn=1,Object.defineProperty(Fe,"__esModule",{value:!0}),Fe.CrudBuilder=void 0;var e=se();const t=y=>class extends y{create(T,S){return this.client.post("/",T,(0,e.createRequestConfig)(S)).then(e.dataExtractor)}},r=y=>class extends y{retrieve(T,S){return this.client.get(T,(0,e.createRequestConfig)(S)).then(e.dataExtractor)}},s=y=>class extends y{update(T,S,B){return this.client.put(T,S,(0,e.createRequestConfig)(B)).then(e.dataExtractor)}},a=y=>class extends y{patch(T,S,B){const M=(0,e.createRequestConfig)(B);return this.client.patch(T,S,{...M,headers:{...(M==null?void 0:M.headers)||{},[e.CONTENT_TYPE_HEADER]:e.MERGE_CONTENT_TYPE}}).then(e.dataExtractor)}},u=y=>class extends y{async delete(T,S){await this.client.delete(T,(0,e.createRequestConfig)(S))}},l=y=>class extends y{list(T={},S={}){const B=`/${(0,e.getQueryParams)(T)}`;return this.client.get(B,(0,e.createRequestConfig)(S)).then(e.dataExtractor)}};let f=class{constructor(_){this.BaseService=_}create(){return this.BaseService=t(this.BaseService),this}retrieve(){return this.BaseService=r(this.BaseService),this}update(){return this.BaseService=s(this.BaseService),this}patch(){return this.BaseService=a(this.BaseService),this}delete(){return this.BaseService=u(this.BaseService),this}list(){return this.BaseService=l(this.BaseService),this}build(){return this.BaseService}};return Fe.CrudBuilder=f,Fe}var _n;function xi(){if(_n)return Ke;_n=1,Object.defineProperty(Ke,"__esModule",{value:!0}),Ke.BasisTheoryApplications=void 0;var e=se(),t=ie(),r=Te();const s=new r.CrudBuilder(class extends t.BasisTheoryService{getApplicationByKey(){return this.retrieveByKey()}retrieveByKey(u){return this.client.get("/key",(0,e.createRequestConfig)(u)).then(e.dataExtractor)}regenerateKey(u,l){return this.client.post(`${u}/regenerate`,void 0,(0,e.createRequestConfig)(l)).then(e.dataExtractor)}}).create().retrieve().update().delete().list().build();return Ke.BasisTheoryApplications=s,Ke}var gn;function wn(){return gn||(gn=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"BasisTheoryApplications",{enumerable:!0,get:function(){return t.BasisTheoryApplications}});var t=xi()}(zt)),zt}var kt={},Wt={},ze={},Vt={},ke={},Tn;function Ni(){if(Tn)return ke;Tn=1,Object.defineProperty(ke,"__esModule",{value:!0}),ke.BasisTheoryTokenize=void 0;var e=se(),t=ie();let r=class extends t.BasisTheoryService{tokenize(a,u={}){return this.client.post("/",a,(0,e.createRequestConfig)(u,{transformRequest:e.proxyRaw,transformResponse:e.proxyRaw})).then(e.dataExtractor)}};return ke.BasisTheoryTokenize=r,ke}var Sn;function ji(){return Sn||(Sn=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"BasisTheoryTokenize",{enumerable:!0,get:function(){return t.BasisTheoryTokenize}});var t=Ni()}(Vt)),Vt}var Rn;function Ui(){if(Rn)return ze;Rn=1,Object.defineProperty(ze,"__esModule",{value:!0}),ze.delegateTokenize=void 0;var e=ji();const t=r=>class extends e.BasisTheoryTokenize{tokenize(a,u){return r!=null&&r.hasElement(a)?r.tokenize(a,u):super.tokenize(a,u)}};return ze.delegateTokenize=t,ze}var We={},Gt={},Ve={},vn;function Di(){if(vn)return Ve;vn=1,Object.defineProperty(Ve,"__esModule",{value:!0}),Ve.BasisTheoryTokens=void 0;var e=se(),t=Pe(),r=ie(),s=Te();const a=new s.CrudBuilder(class extends r.BasisTheoryService{constructor(l){const f=l;f.transformRequest=[].concat(t.transformTokenRequestSnakeCase,l.transformRequest||[]),f.transformResponse=[].concat(t.transformTokenResponseCamelCase,l.transformResponse||[]),super(f)}retrieve(l,f={}){const y=`/${l}`;return this.client.get(y,(0,e.createRequestConfig)(f)).then(t.dataExtractor)}update(l,f,y={}){const _=`/${l}`,T=(0,e.createRequestConfig)(y);return this.client.patch(_,f,{...T,headers:{...(T==null?void 0:T.headers)||{},[e.CONTENT_TYPE_HEADER]:e.MERGE_CONTENT_TYPE}}).then(t.dataExtractor)}async createAssociation(l,f,y){const _=`/${l}/children/${f}`;await this.client.post(_,{},(0,e.createRequestConfig)(y))}async deleteAssociation(l,f,y){const _=`/${l}/children/${f}`;await this.client.delete(_,(0,e.createRequestConfig)(y))}createChild(l,f,y){const _=`/${l}/children`;return this.client.post(_,f,(0,e.createRequestConfig)(y)).then(t.dataExtractor)}listChildren(l,f={},y={}){const _=`/${l}/children${(0,e.getQueryParams)(f)}`;return this.client.get(_,(0,e.createRequestConfig)(y)).then(t.dataExtractor)}search(l,f){return this.client.post("/search",l,(0,e.createRequestConfig)(f)).then(t.dataExtractor)}}).create().delete().list().build();return Ve.BasisTheoryTokens=a,Ve}var An;function Cn(){return An||(An=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"BasisTheoryTokens",{enumerable:!0,get:function(){return t.BasisTheoryTokens}});var t=Di()}(Gt)),Gt}var On;function Li(){if(On)return We;On=1,Object.defineProperty(We,"__esModule",{value:!0}),We.delegateTokens=void 0;var e=Cn();const t=r=>class extends e.BasisTheoryTokens{create(a,u){return r!=null&&r.hasElement(a)?r.tokens.create(a,u):super.create(a,u)}update(a,u,l){return r!=null&&r.hasElement(u)?r.tokens.update(a,u,l):super.update(a,u,l)}retrieve(a,u){return r!==void 0?r.tokens.retrieve(a,u):super.retrieve(a,u)}};return We.delegateTokens=t,We}var Ge={},Jt={},Je={},Pn;function Hi(){if(Pn)return Je;Pn=1,Object.defineProperty(Je,"__esModule",{value:!0}),Je.BasisTheoryProxy=void 0;var e=se(),t=ie();let r=class extends t.BasisTheoryService{get(a){return this.proxyRequest("get",a)}post(a){return this.proxyRequest("post",a)}put(a){return this.proxyRequest("put",a)}patch(a){return this.proxyRequest("patch",a)}delete(a){return this.proxyRequest("delete",a)}proxyRequest(a,u){var l;if(a==="post"||a==="put"||a==="patch"){var f,y;const _=u!=null&&u.includeResponseHeaders&&a==="post"?e.dataAndHeadersExtractor:e.dataExtractor;return this.client[a]((f=u==null?void 0:u.path)!==null&&f!==void 0?f:"",(y=u==null?void 0:u.body)!==null&&y!==void 0?y:void 0,(0,e.createRequestConfig)(u,{transformRequest:e.proxyRaw,transformResponse:e.proxyRaw})).then(_)}return this.client[a]((l=u==null?void 0:u.path)!==null&&l!==void 0?l:"/",(0,e.createRequestConfig)(u,{transformRequest:e.proxyRaw,transformResponse:e.proxyRaw})).then(e.dataExtractor)}};return Je.BasisTheoryProxy=r,Je}var Bn;function qi(){return Bn||(Bn=1,function(e){Object.defineProperty(e,"__esModule",{value:!0});var t=Hi();Object.keys(t).forEach(function(r){r==="default"||r==="__esModule"||r in e&&e[r]===t[r]||Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[r]}})})}(Jt)),Jt}var xn;function Mi(){if(xn)return Ge;xn=1,Object.defineProperty(Ge,"__esModule",{value:!0}),Ge.delegateProxy=void 0;var e=qi();const t=r=>class extends e.BasisTheoryProxy{get(a){return r!==void 0?r.proxy.get(a):super.get(a)}post(a){return r!==void 0?r.proxy.post(a):super.post(a)}put(a){return r!==void 0?r.proxy.put(a):super.put(a)}patch(a){return r!==void 0?r.proxy.patch(a):super.patch(a)}delete(a){return r!==void 0?r.proxy.delete(a):super.delete(a)}};return Ge.delegateProxy=t,Ge}var Nn;function Ii(){return Nn||(Nn=1,function(e){Object.defineProperty(e,"__esModule",{value:!0});var t=Ui();Object.keys(t).forEach(function(a){a==="default"||a==="__esModule"||a in e&&e[a]===t[a]||Object.defineProperty(e,a,{enumerable:!0,get:function(){return t[a]}})});var r=Li();Object.keys(r).forEach(function(a){a==="default"||a==="__esModule"||a in e&&e[a]===r[a]||Object.defineProperty(e,a,{enumerable:!0,get:function(){return r[a]}})});var s=Mi();Object.keys(s).forEach(function(a){a==="default"||a==="__esModule"||a in e&&e[a]===s[a]||Object.defineProperty(e,a,{enumerable:!0,get:function(){return s[a]}})})}(Wt)),Wt}var Se={},jn;function Un(){if(jn)return Se;jn=1,Object.defineProperty(Se,"__esModule",{value:!0}),Se.injectScript=Se.findScript=void 0;const e=r=>document.querySelector(`script[src^="${r}"]`);Se.findScript=e;const t=r=>{const s=document.createElement("script");s.src=r;const a=document.head||document.body;if(!a)throw new Error("No <head> or <body> elements found in document.");return a.append(s),s};return Se.injectScript=t,Se}var Xe={},Y={},Dn;function Ln(){if(Dn)return Y;Dn=1,Object.defineProperty(Y,"__esModule",{value:!0}),Y.ELEMENTS_SCRIPT_UNKNOWN_ERROR_MESSAGE=Y.ELEMENTS_SCRIPT_LOAD_ERROR_MESSAGE=Y.ELEMENTS_NOM_DOM_ERROR_MESSAGE=Y.ELEMENTS_INIT_ERROR_MESSAGE=Y.CARD_ICON_POSITIONS=Y.CARD_BRANDS=Y.AUTOCOMPLETE_VALUES=void 0;const e="BasisTheory Elements was not properly initialized.";Y.ELEMENTS_INIT_ERROR_MESSAGE=e;const t="Tried to load BasisTheoryElements in a non-DOM environment.";Y.ELEMENTS_NOM_DOM_ERROR_MESSAGE=t;const r="Basis Theory Elements did not load properly.";Y.ELEMENTS_SCRIPT_LOAD_ERROR_MESSAGE=r;const s="There was an unknown error when loading Basis Theory Elements. Check the console for details.";Y.ELEMENTS_SCRIPT_UNKNOWN_ERROR_MESSAGE=s;const a=["visa","mastercard","american-express","discover","diners-club","jcb","unionpay","maestro","elo","hiper","hipercard","mir","unknown"];Y.CARD_BRANDS=a;const u=["left","right","none"];Y.CARD_ICON_POSITIONS=u;const l=["off","on"];return Y.AUTOCOMPLETE_VALUES=l,Y}var Hn;function $i(){if(Hn)return Xe;Hn=1,Object.defineProperty(Xe,"__esModule",{value:!0}),Xe.loadElements=void 0;var e=Ln(),t=Un();let r;const s=a=>(r||(r=new Promise((u,l)=>{if(typeof window!="object"){l(new Error(e.ELEMENTS_NOM_DOM_ERROR_MESSAGE));return}if(window.BasisTheoryElements){u(window.BasisTheoryElements);return}try{let f="https://js.basistheory.com/elements";if(typeof a<"u")try{f=new URL(a).toString().replace(/\/$/u,"")}catch{throw new Error("Invalid format for the given Elements client url.")}let y=(0,t.findScript)(f);y||(y=(0,t.injectScript)(f)),y.addEventListener("load",()=>{window.BasisTheoryElements?u(window.BasisTheoryElements):l(new Error(e.ELEMENTS_SCRIPT_LOAD_ERROR_MESSAGE))}),y.addEventListener("error",_=>{l((_==null?void 0:_.error)||new Error(e.ELEMENTS_SCRIPT_UNKNOWN_ERROR_MESSAGE))})}catch(f){l(f);return}})),r);return Xe.loadElements=s,Xe}var qn;function Ki(){return qn||(qn=1,function(e){Object.defineProperty(e,"__esModule",{value:!0});var t=Ii();Object.keys(t).forEach(function(a){a==="default"||a==="__esModule"||a in e&&e[a]===t[a]||Object.defineProperty(e,a,{enumerable:!0,get:function(){return t[a]}})});var r=Un();Object.keys(r).forEach(function(a){a==="default"||a==="__esModule"||a in e&&e[a]===r[a]||Object.defineProperty(e,a,{enumerable:!0,get:function(){return r[a]}})});var s=$i();Object.keys(s).forEach(function(a){a==="default"||a==="__esModule"||a in e&&e[a]===s[a]||Object.defineProperty(e,a,{enumerable:!0,get:function(){return s[a]}})})}(kt)),kt}var Xt={},Ye={},Mn;function Fi(){if(Mn)return Ye;Mn=1,Object.defineProperty(Ye,"__esModule",{value:!0}),Ye.BasisTheoryLogs=void 0;var e=ie(),t=Te();const r=new t.CrudBuilder(class extends e.BasisTheoryService{}).list().build();return Ye.BasisTheoryLogs=r,Ye}var In;function zi(){return In||(In=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"BasisTheoryLogs",{enumerable:!0,get:function(){return t.BasisTheoryLogs}});var t=Fi()}(Xt)),Xt}var Yt={},Ze={},$n;function ki(){if($n)return Ze;$n=1,Object.defineProperty(Ze,"__esModule",{value:!0}),Ze.BasisTheoryPermissions=void 0;var e=se(),t=ie();let r=class extends t.BasisTheoryService{list(a){return this.client.get("/",(0,e.createRequestConfig)(a)).then(e.dataExtractor)}};return Ze.BasisTheoryPermissions=r,Ze}var Kn;function Wi(){return Kn||(Kn=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"BasisTheoryPermissions",{enumerable:!0,get:function(){return t.BasisTheoryPermissions}});var t=ki()}(Yt)),Yt}var Zt={},Qe={},Fn;function Vi(){if(Fn)return Qe;Fn=1,Object.defineProperty(Qe,"__esModule",{value:!0}),Qe.BasisTheoryProxies=void 0;var e=Pe(),t=ie(),r=Te();const s=new r.CrudBuilder(class extends t.BasisTheoryService{constructor(u){const l={...u};l.transformRequest=[].concat(e.transformProxyRequestSnakeCase,u.transformRequest||[]),l.transformResponse=[].concat(e.transformProxyResponseCamelCase,u.transformResponse||[]),super(l)}}).create().retrieve().update().patch().delete().list().build();return Qe.BasisTheoryProxies=s,Qe}var zn;function Gi(){return zn||(zn=1,function(e){Object.defineProperty(e,"__esModule",{value:!0});var t=Vi();Object.keys(t).forEach(function(r){r==="default"||r==="__esModule"||r in e&&e[r]===t[r]||Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[r]}})})}(Zt)),Zt}var Qt={},et={},kn;function Ji(){if(kn)return et;kn=1,Object.defineProperty(et,"__esModule",{value:!0}),et.BasisTheoryReactorFormulas=void 0;var e=ie(),t=Te();const r=new t.CrudBuilder(class extends e.BasisTheoryService{}).create().retrieve().update().delete().list().build();return et.BasisTheoryReactorFormulas=r,et}var Wn;function Xi(){return Wn||(Wn=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"BasisTheoryReactorFormulas",{enumerable:!0,get:function(){return t.BasisTheoryReactorFormulas}});var t=Ji()}(Qt)),Qt}var er={},tt={},Vn;function Yi(){if(Vn)return tt;Vn=1,Object.defineProperty(tt,"__esModule",{value:!0}),tt.BasisTheoryReactors=void 0;var e=se(),t=Pe(),r=ie(),s=Te();const a=new s.CrudBuilder(class extends r.BasisTheoryService{constructor(l){const f={...l};f.transformRequest=[].concat(t.transformReactorRequestSnakeCase,l.transformRequest||[]),f.transformResponse=[].concat(t.transformReactorResponseCamelCase,l.transformResponse||[]),super(f)}react(l,f,y){return this.client.post(`/${l}/react`,f,(0,e.createRequestConfig)(y,{transformRequest:e.proxyRaw,transformResponse:e.proxyRaw})).then(e.dataExtractor)}}).create().retrieve().update().patch().delete().list().build();return tt.BasisTheoryReactors=a,tt}var Gn;function Zi(){return Gn||(Gn=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"BasisTheoryReactors",{enumerable:!0,get:function(){return t.BasisTheoryReactors}});var t=Yi()}(er)),er}var tr={},rt={},Jn;function Qi(){if(Jn)return rt;Jn=1,Object.defineProperty(rt,"__esModule",{value:!0}),rt.BasisTheorySessions=void 0;var e=se(),t=Pe(),r=ie();let s=class extends r.BasisTheoryService{constructor(u){const l={...u};l.transformRequest=[].concat(t.transformProxyRequestSnakeCase,u.transformRequest||[]),l.transformResponse=[].concat(t.transformProxyResponseCamelCase,u.transformResponse||[]),super(l)}create(u={}){return this.client.post("/",void 0,(0,e.createRequestConfig)(u)).then(t.dataExtractor)}authorize(u,l={}){return this.client.post("/authorize",u,(0,e.createRequestConfig)(l)).then(t.dataExtractor)}};return rt.BasisTheorySessions=s,rt}var Xn;function ea(){return Xn||(Xn=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"BasisTheorySessions",{enumerable:!0,get:function(){return t.BasisTheorySessions}});var t=Qi()}(tr)),tr}var rr={},nt={},Yn;function ta(){if(Yn)return nt;Yn=1,Object.defineProperty(nt,"__esModule",{value:!0}),nt.BasisTheoryTenants=void 0;var e=se(),t=ie(),r=Te();const s=new r.CrudBuilder(class extends t.BasisTheoryService{retrieve(u){return this.client.get("/",(0,e.createRequestConfig)(u)).then(e.dataExtractor)}update(u,l){return this.client.put("/",u,(0,e.createRequestConfig)(l)).then(e.dataExtractor)}async delete(u){await this.client.delete("/",(0,e.createRequestConfig)(u))}retrieveUsageReport(u){return this.client.get("/reports/usage",(0,e.createRequestConfig)(u)).then(e.dataExtractor)}createInvitation(u,l){return this.client.post("/invitations",u,(0,e.createRequestConfig)(l)).then(e.dataExtractor)}resendInvitation(u,l){return this.client.post(`/invitations/${u}/resend`,{},(0,e.createRequestConfig)(l)).then(e.dataExtractor)}listInvitations(u,l){const f=`/invitations${(0,e.getQueryParams)(u)}`;return this.client.get(f,(0,e.createRequestConfig)(l)).then(e.dataExtractor)}retrieveInvitation(u,l){return this.client.get(`/invitations/${u}`,(0,e.createRequestConfig)(l)).then(e.dataExtractor)}async deleteInvitation(u,l){await this.client.delete(`/invitations/${u}`,(0,e.createRequestConfig)(l))}listMembers(u,l){const f=`/members${(0,e.getQueryParams)(u)}`;return this.client.get(f,(0,e.createRequestConfig)(l)).then(e.dataExtractor)}async deleteMember(u,l){await this.client.delete(`/members/${u}`,(0,e.createRequestConfig)(l))}}).build();return nt.BasisTheoryTenants=s,nt}var Zn;function ra(){return Zn||(Zn=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"BasisTheoryTenants",{enumerable:!0,get:function(){return t.BasisTheoryTenants}});var t=ta()}(rr)),rr}var Qn;function na(){if(Qn)return Le;Qn=1,Object.defineProperty(Le,"__esModule",{value:!0}),Le.BasisTheory=void 0;var e=li(),t=Bi(),r=wn(),s=se(),a=Ki(),u=Ln(),l=zi(),f=Wi(),y=Gi(),_=Xi(),T=Zi(),S=ea(),B=ra();function M(q,P,D){return P in q?Object.defineProperty(q,P,{value:D,enumerable:!0,configurable:!0,writable:!0}):q[P]=D,q}const U={apiBaseUrl:s.DEFAULT_BASE_URL,elements:!1,appInfo:{}};let F=class{constructor(){M(this,"_initStatus","not-started")}async init(P,D={}){if(this._initStatus!=="not-started"&&this._initStatus!=="error")throw new Error("This BasisTheory instance has been already initialized.");this._initStatus="in-progress";try{this._initOptions=Object.freeze({...U,...D});let H=this._initOptions.apiBaseUrl;try{const de=new URL(this.initOptions.apiBaseUrl);de.hostname==="localhost"?de.protocol="http":de.protocol="https",H=de.toString().replace(/\/$/u,"")}catch{throw new Error("Invalid format for the given API base url.")}const Z=this._initOptions.appInfo;this._initOptions.elements&&await this.loadElements(P),this._tokens=new((0,a.delegateTokens)(this._elements))({apiKey:P,baseURL:new URL(s.CLIENT_BASE_PATHS.tokens,H).toString(),appInfo:Z}),this._tokenize=new((0,a.delegateTokenize)(this._elements))({apiKey:P,baseURL:new URL(s.CLIENT_BASE_PATHS.tokenize,H).toString(),appInfo:Z}),this._applications=new r.BasisTheoryApplications({apiKey:P,baseURL:new URL(s.CLIENT_BASE_PATHS.applications,H).toString(),appInfo:Z}),this._tenants=new B.BasisTheoryTenants({apiKey:P,baseURL:new URL(s.CLIENT_BASE_PATHS.tenants,H).toString(),appInfo:Z}),this._logs=new l.BasisTheoryLogs({apiKey:P,baseURL:new URL(s.CLIENT_BASE_PATHS.logs,H).toString(),appInfo:Z}),this._reactorFormulas=new _.BasisTheoryReactorFormulas({apiKey:P,baseURL:new URL(s.CLIENT_BASE_PATHS.reactorFormulas,H).toString(),appInfo:Z}),this._reactors=new T.BasisTheoryReactors({apiKey:P,baseURL:new URL(s.CLIENT_BASE_PATHS.reactors,H).toString(),appInfo:Z}),this._permissions=new f.BasisTheoryPermissions({apiKey:P,baseURL:new URL(s.CLIENT_BASE_PATHS.permissions,H).toString(),appInfo:Z}),this._proxies=new y.BasisTheoryProxies({apiKey:P,baseURL:new URL(s.CLIENT_BASE_PATHS.proxies,H).toString(),appInfo:Z}),this._proxy=new((0,a.delegateProxy)(this._elements))({apiKey:P,baseURL:new URL(s.CLIENT_BASE_PATHS.proxy,H).toString(),appInfo:Z}),this._sessions=new S.BasisTheorySessions({apiKey:P,baseURL:new URL(s.CLIENT_BASE_PATHS.sessions,H).toString(),appInfo:Z}),this._transactions=new t.BasisTheoryTransactions({apiKey:P,baseURL:new URL(s.CLIENT_BASE_PATHS.transactions,H).toString(),appInfo:Z}),this._initStatus="done"}catch(H){throw this._initStatus="error",H}return this}createElement(P,D){if(!this._elements)throw new Error(u.ELEMENTS_INIT_ERROR_MESSAGE);return this._elements.createElement(P,D)}tokenize(P,D){return(0,s.assertInit)(this._tokenize).tokenize(P,D)}post(P,D,H){return(0,e.makeRequestWithElementsPayloadCheck)(this._elements,"post",P,D,H)}put(P,D,H){return(0,e.makeRequestWithElementsPayloadCheck)(this._elements,"put",P,D,H)}patch(P,D,H){return(0,e.makeRequestWithElementsPayloadCheck)(this._elements,"patch",P,D,H)}get(P,D){return(0,e.makeRequestWithoutElementsPayloadCheck)(this._elements,"get",P,D)}delete(P,D){return(0,e.makeRequestWithoutElementsPayloadCheck)(this._elements,"delete",P,D)}async loadElements(P){let D;try{D=new URL(this.initOptions.elementsBaseUrl||s.DEFAULT_ELEMENTS_BASE_URL)}catch{throw new Error("Invalid format for the given Elements base url.")}const H=await(0,a.loadElements)(this.initOptions.elementsClientUrl);await H.init(P,D.toString().replace(/\/$/u,"")),this.elements=H}get initOptions(){return(0,s.assertInit)(this._initOptions)}get tokens(){return(0,s.assertInit)(this._tokens)}get applications(){return(0,s.assertInit)(this._applications)}get tenants(){return(0,s.assertInit)(this._tenants)}get logs(){return(0,s.assertInit)(this._logs)}get reactorFormulas(){return(0,s.assertInit)(this._reactorFormulas)}get reactors(){return(0,s.assertInit)(this._reactors)}get permissions(){return(0,s.assertInit)(this._permissions)}get proxies(){return(0,s.assertInit)(this._proxies)}get proxy(){return(0,s.assertInit)(this._proxy)}get sessions(){return(0,s.assertInit)(this._sessions)}get transactions(){return(0,s.assertInit)(this._transactions)}get elements(){return(0,s.assertInit)(this._elements)}set elements(P){this._elements=P}};return Le.BasisTheory=F,Le}var es;function sa(){return es||(es=1,function(e){Object.defineProperty(e,"__esModule",{value:!0});var t={_instance:!0};e._instance=void 0;var r=na();Object.keys(r).forEach(function(l){l==="default"||l==="__esModule"||Object.prototype.hasOwnProperty.call(t,l)||l in e&&e[l]===r[l]||Object.defineProperty(e,l,{enumerable:!0,get:function(){return r[l]}})});var s=wn();Object.keys(s).forEach(function(l){l==="default"||l==="__esModule"||Object.prototype.hasOwnProperty.call(t,l)||l in e&&e[l]===s[l]||Object.defineProperty(e,l,{enumerable:!0,get:function(){return s[l]}})});var a=Cn();Object.keys(a).forEach(function(l){l==="default"||l==="__esModule"||Object.prototype.hasOwnProperty.call(t,l)||l in e&&e[l]===a[l]||Object.defineProperty(e,l,{enumerable:!0,get:function(){return a[l]}})});const u=new r.BasisTheory;e._instance=u}(Nt)),Nt}var ia=sa();const K=crypto,ue=e=>e instanceof CryptoKey,aa=async(e,t)=>{const r=`SHA-${e.slice(-3)}`;return new Uint8Array(await K.subtle.digest(r,t))},Re=new TextEncoder,ts=new TextDecoder,pt=2**32;function st(...e){const t=e.reduce((a,{length:u})=>a+u,0),r=new Uint8Array(t);let s=0;for(const a of e)r.set(a,s),s+=a.length;return r}function oa(e,t){return st(Re.encode(e),new Uint8Array([0]),t)}function nr(e,t,r){if(t<0||t>=pt)throw new RangeError(`value must be >= 0 and <= ${pt-1}. Received ${t}`);e.set([t>>>24,t>>>16,t>>>8,t&255],r)}function ca(e){const t=Math.floor(e/pt),r=e%pt,s=new Uint8Array(8);return nr(s,t,0),nr(s,r,4),s}function sr(e){const t=new Uint8Array(4);return nr(t,e),t}function ir(e){return st(sr(e.length),e)}async function ua(e,t,r){const s=Math.ceil((t>>3)/32),a=new Uint8Array(s*32);for(let u=0;u<s;u++){const l=new Uint8Array(4+e.length+r.length);l.set(sr(u+1)),l.set(e,4),l.set(r,4+e.length),a.set(await aa("sha256",l),u*32)}return a.slice(0,t>>3)}const la=e=>{let t=e;typeof t=="string"&&(t=Re.encode(t));const r=32768,s=[];for(let a=0;a<t.length;a+=r)s.push(String.fromCharCode.apply(null,t.subarray(a,a+r)));return btoa(s.join(""))},ae=e=>la(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_"),da=e=>{const t=atob(e),r=new Uint8Array(t.length);for(let s=0;s<t.length;s++)r[s]=t.charCodeAt(s);return r},rs=e=>{let t=e;t instanceof Uint8Array&&(t=ts.decode(t)),t=t.replace(/-/g,"+").replace(/_/g,"/").replace(/\s/g,"");try{return da(t)}catch{throw new TypeError("The input to be decoded is not correctly encoded.")}};class ns extends Error{static get code(){return"ERR_JOSE_GENERIC"}constructor(t){var r;super(t),this.code="ERR_JOSE_GENERIC",this.name=this.constructor.name,(r=Error.captureStackTrace)==null||r.call(Error,this,this.constructor)}}class te extends ns{constructor(){super(...arguments),this.code="ERR_JOSE_NOT_SUPPORTED"}static get code(){return"ERR_JOSE_NOT_SUPPORTED"}}class Ee extends ns{constructor(){super(...arguments),this.code="ERR_JWE_INVALID"}static get code(){return"ERR_JWE_INVALID"}}const ar=K.getRandomValues.bind(K);function ss(e){switch(e){case"A128GCM":case"A128GCMKW":case"A192GCM":case"A192GCMKW":case"A256GCM":case"A256GCMKW":return 96;case"A128CBC-HS256":case"A192CBC-HS384":case"A256CBC-HS512":return 128;default:throw new te(`Unsupported JWE Algorithm: ${e}`)}}const fa=e=>ar(new Uint8Array(ss(e)>>3)),ha=(e,t)=>{if(t.length<<3!==ss(e))throw new Ee("Invalid Initialization Vector length")},is=(e,t)=>{const r=e.byteLength<<3;if(r!==t)throw new Ee(`Invalid Content Encryption Key length. Expected ${t} bits, got ${r} bits`)};function be(e,t="algorithm.name"){return new TypeError(`CryptoKey does not support this operation, its ${t} must be ${e}`)}function mt(e,t){return e.name===t}function pa(e){return parseInt(e.name.slice(4),10)}function ma(e,t){if(t.length&&!t.some(r=>e.usages.includes(r))){let r="CryptoKey does not support this operation, its usages must include ";if(t.length>2){const s=t.pop();r+=`one of ${t.join(", ")}, or ${s}.`}else t.length===2?r+=`one of ${t[0]} or ${t[1]}.`:r+=`${t[0]}.`;throw new TypeError(r)}}function Be(e,t,...r){switch(t){case"A128GCM":case"A192GCM":case"A256GCM":{if(!mt(e.algorithm,"AES-GCM"))throw be("AES-GCM");const s=parseInt(t.slice(1,4),10);if(e.algorithm.length!==s)throw be(s,"algorithm.length");break}case"A128KW":case"A192KW":case"A256KW":{if(!mt(e.algorithm,"AES-KW"))throw be("AES-KW");const s=parseInt(t.slice(1,4),10);if(e.algorithm.length!==s)throw be(s,"algorithm.length");break}case"ECDH":{switch(e.algorithm.name){case"ECDH":case"X25519":case"X448":break;default:throw be("ECDH, X25519, or X448")}break}case"PBES2-HS256+A128KW":case"PBES2-HS384+A192KW":case"PBES2-HS512+A256KW":if(!mt(e.algorithm,"PBKDF2"))throw be("PBKDF2");break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":{if(!mt(e.algorithm,"RSA-OAEP"))throw be("RSA-OAEP");const s=parseInt(t.slice(9),10)||1;if(pa(e.algorithm.hash)!==s)throw be(`SHA-${s}`,"algorithm.hash");break}default:throw new TypeError("CryptoKey does not support this operation")}ma(e,r)}function as(e,t,...r){var s;if(r.length>2){const a=r.pop();e+=`one of type ${r.join(", ")}, or ${a}.`}else r.length===2?e+=`one of type ${r[0]} or ${r[1]}.`:e+=`of type ${r[0]}.`;return t==null?e+=` Received ${t}`:typeof t=="function"&&t.name?e+=` Received function ${t.name}`:typeof t=="object"&&t!=null&&(s=t.constructor)!=null&&s.name&&(e+=` Received an instance of ${t.constructor.name}`),e}const le=(e,...t)=>as("Key must be ",e,...t);function os(e,t,...r){return as(`Key for the ${e} algorithm must be `,t,...r)}const cs=e=>ue(e)?!0:(e==null?void 0:e[Symbol.toStringTag])==="KeyObject",oe=["CryptoKey"],ya=(...e)=>{const t=e.filter(Boolean);if(t.length===0||t.length===1)return!0;let r;for(const s of t){const a=Object.keys(s);if(!r||r.size===0){r=new Set(a);continue}for(const u of a){if(r.has(u))return!1;r.add(u)}}return!0};function Ea(e){return typeof e=="object"&&e!==null}function ba(e){if(!Ea(e)||Object.prototype.toString.call(e)!=="[object Object]")return!1;if(Object.getPrototypeOf(e)===null)return!0;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}const us=[{hash:"SHA-256",name:"HMAC"},!0,["sign"]];function _a(e,t){if(e.algorithm.length!==parseInt(t.slice(1,4),10))throw new TypeError(`Invalid key size for alg: ${t}`)}function ga(e,t,r){if(ue(e))return Be(e,t,r),e;if(e instanceof Uint8Array)return K.subtle.importKey("raw",e,"AES-KW",!0,[r]);throw new TypeError(le(e,...oe,"Uint8Array"))}const or=async(e,t,r)=>{const s=await ga(t,e,"wrapKey");_a(s,e);const a=await K.subtle.importKey("raw",r,...us);return new Uint8Array(await K.subtle.wrapKey("raw",a,s,"AES-KW"))};async function wa(e,t,r,s,a=new Uint8Array(0),u=new Uint8Array(0)){if(!ue(e))throw new TypeError(le(e,...oe));if(Be(e,"ECDH"),!ue(t))throw new TypeError(le(t,...oe));Be(t,"ECDH","deriveBits");const l=st(ir(Re.encode(r)),ir(a),ir(u),sr(s));let f;e.algorithm.name==="X25519"?f=256:e.algorithm.name==="X448"?f=448:f=Math.ceil(parseInt(e.algorithm.namedCurve.substr(-3),10)/8)<<3;const y=new Uint8Array(await K.subtle.deriveBits({name:e.algorithm.name,public:e},t,f));return ua(y,s,l)}async function Ta(e){if(!ue(e))throw new TypeError(le(e,...oe));return K.subtle.generateKey(e.algorithm,!0,["deriveBits"])}function Sa(e){if(!ue(e))throw new TypeError(le(e,...oe));return["P-256","P-384","P-521"].includes(e.algorithm.namedCurve)||e.algorithm.name==="X25519"||e.algorithm.name==="X448"}function Ra(e){if(!(e instanceof Uint8Array)||e.length<8)throw new Ee("PBES2 Salt Input must be 8 or more octets")}function va(e,t){if(e instanceof Uint8Array)return K.subtle.importKey("raw",e,"PBKDF2",!1,["deriveBits"]);if(ue(e))return Be(e,t,"deriveBits","deriveKey"),e;throw new TypeError(le(e,...oe,"Uint8Array"))}async function Aa(e,t,r,s){Ra(e);const a=oa(t,e),u=parseInt(t.slice(13,16),10),l={hash:`SHA-${t.slice(8,11)}`,iterations:r,name:"PBKDF2",salt:a},f={length:u,name:"AES-KW"},y=await va(s,t);if(y.usages.includes("deriveBits"))return new Uint8Array(await K.subtle.deriveBits(l,y,u));if(y.usages.includes("deriveKey"))return K.subtle.deriveKey(l,y,f,!1,["wrapKey","unwrapKey"]);throw new TypeError('PBKDF2 key "usages" must include "deriveBits" or "deriveKey"')}const Ca=async(e,t,r,s=2048,a=ar(new Uint8Array(16)))=>{const u=await Aa(a,e,s,t);return{encryptedKey:await or(e.slice(-6),u,r),p2c:s,p2s:ae(a)}};function ls(e){switch(e){case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":return"RSA-OAEP";default:throw new te(`alg ${e} is not supported either by JOSE or your javascript runtime`)}}const Oa=(e,t)=>{if(e.startsWith("RS")||e.startsWith("PS")){const{modulusLength:r}=t.algorithm;if(typeof r!="number"||r<2048)throw new TypeError(`${e} requires key modulusLength to be 2048 bits or larger`)}},Pa=async(e,t,r)=>{if(!ue(t))throw new TypeError(le(t,...oe));if(Be(t,e,"encrypt","wrapKey"),Oa(e,t),t.usages.includes("encrypt"))return new Uint8Array(await K.subtle.encrypt(ls(e),t,r));if(t.usages.includes("wrapKey")){const s=await K.subtle.importKey("raw",r,...us);return new Uint8Array(await K.subtle.wrapKey("raw",s,t,ls(e)))}throw new TypeError('RSA-OAEP key "usages" must include "encrypt" or "wrapKey" for this operation')};function Ba(e){let t,r;switch(e.kty){case"RSA":{switch(e.alg){case"PS256":case"PS384":case"PS512":t={name:"RSA-PSS",hash:`SHA-${e.alg.slice(-3)}`},r=e.d?["sign"]:["verify"];break;case"RS256":case"RS384":case"RS512":t={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${e.alg.slice(-3)}`},r=e.d?["sign"]:["verify"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":t={name:"RSA-OAEP",hash:`SHA-${parseInt(e.alg.slice(-3),10)||1}`},r=e.d?["decrypt","unwrapKey"]:["encrypt","wrapKey"];break;default:throw new te('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break}case"EC":{switch(e.alg){case"ES256":t={name:"ECDSA",namedCurve:"P-256"},r=e.d?["sign"]:["verify"];break;case"ES384":t={name:"ECDSA",namedCurve:"P-384"},r=e.d?["sign"]:["verify"];break;case"ES512":t={name:"ECDSA",namedCurve:"P-521"},r=e.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":t={name:"ECDH",namedCurve:e.crv},r=e.d?["deriveBits"]:[];break;default:throw new te('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break}case"OKP":{switch(e.alg){case"EdDSA":t={name:e.crv},r=e.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":t={name:e.crv},r=e.d?["deriveBits"]:[];break;default:throw new te('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break}default:throw new te('Invalid or unsupported JWK "kty" (Key Type) Parameter value')}return{algorithm:t,keyUsages:r}}const ds=async e=>{if(!e.alg)throw new TypeError('"alg" argument is required when "jwk.alg" is not present');const{algorithm:t,keyUsages:r}=Ba(e),s=[t,e.ext??!1,e.key_ops??r],a={...e};return delete a.alg,delete a.use,K.subtle.importKey("jwk",a,...s)},fs=e=>rs(e);let cr,ur;const hs=e=>(e==null?void 0:e[Symbol.toStringTag])==="KeyObject",ps=async(e,t,r,s)=>{let a=e.get(t);if(a!=null&&a[s])return a[s];const u=await ds({...r,alg:s});return a?a[s]=u:e.set(t,{[s]:u}),u},lr={normalizePublicKey:(e,t)=>{if(hs(e)){let r=e.export({format:"jwk"});return delete r.d,delete r.dp,delete r.dq,delete r.p,delete r.q,delete r.qi,r.k?fs(r.k):(ur||(ur=new WeakMap),ps(ur,e,r,t))}return e},normalizePrivateKey:(e,t)=>{if(hs(e)){let r=e.export({format:"jwk"});return r.k?fs(r.k):(cr||(cr=new WeakMap),ps(cr,e,r,t))}return e}};function ms(e){switch(e){case"A128GCM":return 128;case"A192GCM":return 192;case"A256GCM":case"A128CBC-HS256":return 256;case"A192CBC-HS384":return 384;case"A256CBC-HS512":return 512;default:throw new te(`Unsupported JWE Algorithm: ${e}`)}}const it=e=>ar(new Uint8Array(ms(e)>>3));async function xa(e,t){if(!ba(e))throw new TypeError("JWK must be an object");switch(e.kty){case"oct":if(typeof e.k!="string"||!e.k)throw new TypeError('missing "k" (Key Value) Parameter value');return rs(e.k);case"RSA":if(e.oth!==void 0)throw new te('RSA JWK "oth" (Other Primes Info) Parameter value is not supported');case"EC":case"OKP":return ds({...e,alg:t});default:throw new te('Unsupported "kty" (Key Type) Parameter value')}}const dr=e=>e==null?void 0:e[Symbol.toStringTag],Na=(e,t)=>{if(!(t instanceof Uint8Array)){if(!cs(t))throw new TypeError(os(e,t,...oe,"Uint8Array"));if(t.type!=="secret")throw new TypeError(`${dr(t)} instances for symmetric algorithms must be of type "secret"`)}},ja=(e,t,r)=>{if(!cs(t))throw new TypeError(os(e,t,...oe));if(t.type==="secret")throw new TypeError(`${dr(t)} instances for asymmetric algorithms must not be of type "secret"`);if(t.algorithm,t.algorithm&&r==="encrypt"&&t.type==="private")throw new TypeError(`${dr(t)} instances for asymmetric algorithm encryption must be of type "public"`)},Ua=(e,t,r)=>{e.startsWith("HS")||e==="dir"||e.startsWith("PBES2")||/^A\d{3}(?:GCM)?KW$/.test(e)?Na(e,t):ja(e,t,r)};async function Da(e,t,r,s,a){if(!(r instanceof Uint8Array))throw new TypeError(le(r,"Uint8Array"));const u=parseInt(e.slice(1,4),10),l=await K.subtle.importKey("raw",r.subarray(u>>3),"AES-CBC",!1,["encrypt"]),f=await K.subtle.importKey("raw",r.subarray(0,u>>3),{hash:`SHA-${u<<1}`,name:"HMAC"},!1,["sign"]),y=new Uint8Array(await K.subtle.encrypt({iv:s,name:"AES-CBC"},l,t)),_=st(a,s,y,ca(a.length<<3)),T=new Uint8Array((await K.subtle.sign("HMAC",f,_)).slice(0,u>>3));return{ciphertext:y,tag:T,iv:s}}async function La(e,t,r,s,a){let u;r instanceof Uint8Array?u=await K.subtle.importKey("raw",r,"AES-GCM",!1,["encrypt"]):(Be(r,e,"encrypt"),u=r);const l=new Uint8Array(await K.subtle.encrypt({additionalData:a,iv:s,name:"AES-GCM",tagLength:128},u,t)),f=l.slice(-16);return{ciphertext:l.slice(0,-16),tag:f,iv:s}}const ys=async(e,t,r,s,a)=>{if(!ue(r)&&!(r instanceof Uint8Array))throw new TypeError(le(r,...oe,"Uint8Array"));switch(s?ha(e,s):s=fa(e),e){case"A128CBC-HS256":case"A192CBC-HS384":case"A256CBC-HS512":return r instanceof Uint8Array&&is(r,parseInt(e.slice(-3),10)),Da(e,t,r,s,a);case"A128GCM":case"A192GCM":case"A256GCM":return r instanceof Uint8Array&&is(r,parseInt(e.slice(1,4),10)),La(e,t,r,s,a);default:throw new te("Unsupported JWE Content Encryption Algorithm")}};async function Ha(e,t,r,s){const a=e.slice(0,7),u=await ys(a,r,t,s,new Uint8Array(0));return{encryptedKey:u.ciphertext,iv:ae(u.iv),tag:ae(u.tag)}}function qa(e,t,r,s,a){if(a.crit!==void 0&&(s==null?void 0:s.crit)===void 0)throw new e('"crit" (Critical) Header Parameter MUST be integrity protected');if(!s||s.crit===void 0)return new Set;if(!Array.isArray(s.crit)||s.crit.length===0||s.crit.some(l=>typeof l!="string"||l.length===0))throw new e('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present');let u;r!==void 0?u=new Map([...Object.entries(r),...t.entries()]):u=t;for(const l of s.crit){if(!u.has(l))throw new te(`Extension Header Parameter "${l}" is not recognized`);if(a[l]===void 0)throw new e(`Extension Header Parameter "${l}" is missing`);if(u.get(l)&&s[l]===void 0)throw new e(`Extension Header Parameter "${l}" MUST be integrity protected`)}return new Set(s.crit)}const Ma=async e=>{if(e instanceof Uint8Array)return{kty:"oct",k:ae(e)};if(!ue(e))throw new TypeError(le(e,...oe,"Uint8Array"));if(!e.extractable)throw new TypeError("non-extractable CryptoKey cannot be exported as a JWK");const{ext:t,key_ops:r,alg:s,use:a,...u}=await K.subtle.exportKey("jwk",e);return u};async function Ia(e){return Ma(e)}async function $a(e,t,r,s,a={}){var y;let u,l,f;switch(Ua(e,r,"encrypt"),r=await((y=lr.normalizePublicKey)==null?void 0:y.call(lr,r,e))||r,e){case"dir":{f=r;break}case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":{if(!Sa(r))throw new te("ECDH with the provided key is not allowed or not supported by your javascript runtime");const{apu:_,apv:T}=a;let{epk:S}=a;S||(S=(await Ta(r)).privateKey);const{x:B,y:M,crv:U,kty:F}=await Ia(S),q=await wa(r,S,e==="ECDH-ES"?t:e,e==="ECDH-ES"?ms(t):parseInt(e.slice(-5,-2),10),_,T);if(l={epk:{x:B,crv:U,kty:F}},F==="EC"&&(l.epk.y=M),_&&(l.apu=ae(_)),T&&(l.apv=ae(T)),e==="ECDH-ES"){f=q;break}f=s||it(t);const P=e.slice(-6);u=await or(P,q,f);break}case"RSA1_5":case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":{f=s||it(t),u=await Pa(e,r,f);break}case"PBES2-HS256+A128KW":case"PBES2-HS384+A192KW":case"PBES2-HS512+A256KW":{f=s||it(t);const{p2c:_,p2s:T}=a;({encryptedKey:u,...l}=await Ca(e,r,f,_,T));break}case"A128KW":case"A192KW":case"A256KW":{f=s||it(t),u=await or(e,r,f);break}case"A128GCMKW":case"A192GCMKW":case"A256GCMKW":{f=s||it(t);const{iv:_}=a;({encryptedKey:u,...l}=await Ha(e,r,f,_));break}default:throw new te('Invalid or unsupported "alg" (JWE Algorithm) header value')}return{cek:f,encryptedKey:u,parameters:l}}const Ka=Symbol();class Fa{constructor(t){if(!(t instanceof Uint8Array))throw new TypeError("plaintext must be an instance of Uint8Array");this._plaintext=t}setKeyManagementParameters(t){if(this._keyManagementParameters)throw new TypeError("setKeyManagementParameters can only be called once");return this._keyManagementParameters=t,this}setProtectedHeader(t){if(this._protectedHeader)throw new TypeError("setProtectedHeader can only be called once");return this._protectedHeader=t,this}setSharedUnprotectedHeader(t){if(this._sharedUnprotectedHeader)throw new TypeError("setSharedUnprotectedHeader can only be called once");return this._sharedUnprotectedHeader=t,this}setUnprotectedHeader(t){if(this._unprotectedHeader)throw new TypeError("setUnprotectedHeader can only be called once");return this._unprotectedHeader=t,this}setAdditionalAuthenticatedData(t){return this._aad=t,this}setContentEncryptionKey(t){if(this._cek)throw new TypeError("setContentEncryptionKey can only be called once");return this._cek=t,this}setInitializationVector(t){if(this._iv)throw new TypeError("setInitializationVector can only be called once");return this._iv=t,this}async encrypt(t,r){if(!this._protectedHeader&&!this._unprotectedHeader&&!this._sharedUnprotectedHeader)throw new Ee("either setProtectedHeader, setUnprotectedHeader, or sharedUnprotectedHeader must be called before #encrypt()");if(!ya(this._protectedHeader,this._unprotectedHeader,this._sharedUnprotectedHeader))throw new Ee("JWE Protected, JWE Shared Unprotected and JWE Per-Recipient Header Parameter names must be disjoint");const s={...this._protectedHeader,...this._unprotectedHeader,...this._sharedUnprotectedHeader};if(qa(Ee,new Map,r==null?void 0:r.crit,this._protectedHeader,s),s.zip!==void 0)throw new te('JWE "zip" (Compression Algorithm) Header Parameter is not supported.');const{alg:a,enc:u}=s;if(typeof a!="string"||!a)throw new Ee('JWE "alg" (Algorithm) Header Parameter missing or invalid');if(typeof u!="string"||!u)throw new Ee('JWE "enc" (Encryption Algorithm) Header Parameter missing or invalid');let l;if(this._cek&&(a==="dir"||a==="ECDH-ES"))throw new TypeError(`setContentEncryptionKey cannot be called with JWE "alg" (Algorithm) Header ${a}`);let f;{let F;({cek:f,encryptedKey:l,parameters:F}=await $a(a,u,t,this._cek,this._keyManagementParameters)),F&&(r&&Ka in r?this._unprotectedHeader?this._unprotectedHeader={...this._unprotectedHeader,...F}:this.setUnprotectedHeader(F):this._protectedHeader?this._protectedHeader={...this._protectedHeader,...F}:this.setProtectedHeader(F))}let y,_,T;this._protectedHeader?_=Re.encode(ae(JSON.stringify(this._protectedHeader))):_=Re.encode(""),this._aad?(T=ae(this._aad),y=st(_,Re.encode("."),Re.encode(T))):y=_;const{ciphertext:S,tag:B,iv:M}=await ys(u,this._plaintext,f,this._iv,y),U={ciphertext:ae(S)};return M&&(U.iv=ae(M)),B&&(U.tag=ae(B)),l&&(U.encrypted_key=ae(l)),T&&(U.aad=T),this._protectedHeader&&(U.protected=ts.decode(_)),this._sharedUnprotectedHeader&&(U.unprotected=this._sharedUnprotectedHeader),this._unprotectedHeader&&(U.header=this._unprotectedHeader),U}}class za{constructor(t){this._flattened=new Fa(t)}setContentEncryptionKey(t){return this._flattened.setContentEncryptionKey(t),this}setInitializationVector(t){return this._flattened.setInitializationVector(t),this}setProtectedHeader(t){return this._flattened.setProtectedHeader(t),this}setKeyManagementParameters(t){return this._flattened.setKeyManagementParameters(t),this}async encrypt(t,r){const s=await this._flattened.encrypt(t,r);return[s.protected,s.encrypted_key,s.iv,s.ciphertext,s.tag].join(".")}}const fr={base:{":disabled":{backgroundColor:"transparent"}}},ka={mask:{number:"{{ data.number | card_mask: 'true', 'true' }}",expiration_month:"{{ data.expiration_month }}",expiration_year:"{{ data.expiration_year }}"}},Wa="DOM Element was not found";var Es;(function(e){e.NOT_COMPLETE="NOT_COMPLETE",e.SCHEME_NOT_SUPPORTED="SCHEME_NOT_SUPPORTED",e.LUHN_CHECK_FAILED="LUHN_CHECK_FAILED",e.INVALID_EXPIRY_DATE="INVALID_EXPIRY_DATE"})(Es||(Es={}));const bs=e=>e!=null,Va="v3.8.0";class at{constructor(t,r){if(Object.defineProperty(this,"options",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"IFRAME_BASE_URL",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"iframe",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"subscriptions",{enumerable:!0,configurable:!0,writable:!0,value:{ready:[],blur:[],focus:[],keydown:[],change:[]}}),Object.defineProperty(this,"update",{enumerable:!0,configurable:!0,writable:!0,value:async({...s})=>{this.iframe&&bs(s.height)&&(this.iframe.height=s.height),this.iframePostMessage({type:"update",data:{...s,value:s.value?this.putValue(s.value)??void 0:void 0}})}}),Object.defineProperty(this,"clear",{enumerable:!0,configurable:!0,writable:!0,value:()=>{this.iframePostMessage({type:"clear"})}}),Object.defineProperty(this,"focus",{enumerable:!0,configurable:!0,writable:!0,value:()=>{this.iframePostMessage({type:"focus"})}}),Object.defineProperty(this,"blur",{enumerable:!0,configurable:!0,writable:!0,value:()=>{this.iframePostMessage({type:"blur"})}}),Object.defineProperty(this,"unmount",{enumerable:!0,configurable:!0,writable:!0,value:()=>{var s;(s=this.iframe)==null||s.remove(),this.iframe=null}}),this.IFRAME_BASE_URL=Ga(Va),!this.IFRAME_BASE_URL)throw new Error("IFRAME_BASE_URL not found");r&&hr.set(this,{key:r})}mount(t){const r=typeof t=="string"?document.querySelector(t):t;if(!r)throw new Error(Wa);r.innerHTML=`<iframe width="100%" height="29" src="${this.IFRAME_BASE_URL}?field=${this.type}&origin=${location.origin}"></iframe>`,this.iframe=r.querySelector("iframe");const s=a=>{var u;if(!(a.source!==((u=this.iframe)==null?void 0:u.contentWindow)||a.data.element!==this.type))if(a.data.type==="change"){const l=this.extractValue(a.data.data.value),f={...a.data.data};delete f.value;const y=hr.get(this);y&&(y.value=l),this.emitEvent({...a.data,data:f})}else this.emitEvent(a.data)};return window.addEventListener("message",s),new Promise(a=>{this.on("ready",()=>{this.update(this.options),a()})})}on(t,r){return this.subscriptions[t].push(r),{unsubscribe:()=>this.subscriptions[t].splice(this.subscriptions[t].indexOf(r),1)}}secureValue(t){const r=hr.get(this);return(r==null?void 0:r.key)!==t?null:(r==null?void 0:r.value)??null}emitEvent(t){var r;(r=this.subscriptions[t.type])==null||r.forEach(s=>s(t.data))}iframePostMessage(t){var r,s;(s=(r=this.iframe)==null?void 0:r.contentWindow)==null||s.postMessage(t,this.IFRAME_BASE_URL)}}function Ga(e){return`https://${window.HG_IFRAME_HOST??"sdk.hellgate.io"}/web/${e}/iframe/`}const hr=new Map;function pr(e){const[t=null,r=null]=(e??"").split("/").map(s=>Number(s.trim()));return{month:t,year:r&&r>10?+`20${r}`:null}}function mr(e){if(!e)return null;const{month:t,year:r}=e;return[t&&t<10?`0${t}`:t,r&&r>=100?String(r).slice(-2):r].filter(bs).join(" / ")}class _s extends at{constructor(){super(...arguments),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:"cardExpirationDate"}),Object.defineProperty(this,"extractValue",{enumerable:!0,configurable:!0,writable:!0,value:pr}),Object.defineProperty(this,"putValue",{enumerable:!0,configurable:!0,writable:!0,value:mr})}}function yr(e){return(e==null?void 0:e.replaceAll(" ",""))??null}function gs(e){return e}class ws extends at{constructor(){super(...arguments),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:"cardNumber"}),Object.defineProperty(this,"extractValue",{enumerable:!0,configurable:!0,writable:!0,value:yr}),Object.defineProperty(this,"putValue",{enumerable:!0,configurable:!0,writable:!0,value:gs})}}class Ts extends at{constructor(){super(...arguments),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:"card"}),Object.defineProperty(this,"extractValue",{enumerable:!0,configurable:!0,writable:!0,value:t=>t?{number:t.cardNumber?yr(t.cardNumber):null,expiry_date:t.cardExpirationDate?pr(t.cardExpirationDate):null,cvc:t.cardVerificationCode??null}:null}),Object.defineProperty(this,"putValue",{enumerable:!0,configurable:!0,writable:!0,value:t=>t?{cardNumber:t.number?t.number:null,cardExpirationDate:t.expiry_date?mr(t.expiry_date):null,cardVerificationCode:t.cvc??null}:null})}}class Ss extends at{constructor(){super(...arguments),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:"cardVerificationCode"}),Object.defineProperty(this,"extractValue",{enumerable:!0,configurable:!0,writable:!0,value:t=>t}),Object.defineProperty(this,"putValue",{enumerable:!0,configurable:!0,writable:!0,value:t=>t})}}class Er extends at{constructor(){super(...arguments),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:"text"}),Object.defineProperty(this,"extractValue",{enumerable:!0,configurable:!0,writable:!0,value:t=>t}),Object.defineProperty(this,"putValue",{enumerable:!0,configurable:!0,writable:!0,value:t=>t})}}function xe(e,t,r){switch(e){case"card":return new Ts(t,r);case"cardNumber":return new ws(t,r);case"cardExpirationDate":return new _s(t,r);case"cardVerificationCode":return new Ss(t,r);case"text":return new Er(t,r);default:ASSERT_EXHAUSTIVE(e)}}function Rs(){return Date.now().toString(36)+Math.random().toString(36).slice(2)}function vs(e){return[e.issuer_identification_number,"".padEnd(e.account_number_length-e.issuer_identification_number.length-e.account_number_last_four.length,"*"),e.account_number_last_four].join(" ")}class yt{static async init(t){var s;const r=t.isNextAction("tokenize_card")&&((s=t.state)==null?void 0:s.data.provider)==="basis_theory"?await new ia.BasisTheory().init(t.state.data.api_key,{elements:!1}):void 0;return new yt(t,r)}constructor(t,r){Object.defineProperty(this,"session",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"bt",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"state",{enumerable:!0,configurable:!0,writable:!0,value:this.createFieldDefaultState()}),Object.defineProperty(this,"cardElements",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"textElements",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"stateChangeHandlers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"cvcOnlyEnabled",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"createForm",{enumerable:!0,configurable:!0,writable:!0,value:(s={})=>{var f;if(this.hasFormElements())throw new Error("Form elements can't be initialized twice. You can call `reset()` method or create new Hellgate client.");const a=Ne.get(this);if(!a)throw new Error("Secure key not found");const u=Oe({disabled:!1,autocomplete:"on",style:{...fr}},s);if(this.session.isNextAction("refresh_security_code")&&((f=this.session.state)!=null&&f.data)){const y=this.session.state.data;u.cvcOnly=!0,u.value={number:vs(y),expiry_date:{month:(y==null?void 0:y.expiry_month)??null,year:(y==null?void 0:y.expiry_year)??null},cvc:null}}const l=xe("card",u,a);return this.cardElements.card={element:l,state:this.createFieldDefaultState()},this.addElementStateListener("card"),l}}),Object.defineProperty(this,"createFormFields",{enumerable:!0,configurable:!0,writable:!0,value:(s={})=>{var M,U;if(this.hasFormElements())throw new Error("Form elements can't be initialized twice. You can call `reset()` method or create new Hellgate client.");const a=Ne.get(this);if(!a)throw new Error("Secure key not found");const u={disabled:this.cvcOnlyEnabled,autocomplete:"on",style:{...fr}},{cardNumber:l={},expiryDate:f={},securityCode:y={},..._}=s,T=xe("cardNumber",{...Oe(u,{..._,...l,cvcOnly:this.cvcOnlyEnabled,value:this.session.isNextAction("refresh_security_code")&&((M=this.session.state)!=null&&M.data)?vs(this.session.state.data):null})},a),S=xe("cardExpirationDate",{...Oe(u,{..._,...f,value:this.session.isNextAction("refresh_security_code")&&((U=this.session.state)!=null&&U.data)?{month:this.session.state.data.expiry_month,year:this.session.state.data.expiry_year}:null})},a),B=xe("cardVerificationCode",{...Oe({...u,disabled:!1,autofocus:this.cvcOnlyEnabled},{..._,...y})},a);return T.on("change",F=>{const q=F.cardBrand;B.update({cardType:q})}),this.cardElements={cardNumber:{element:T,state:this.createFieldDefaultState()},cardExpirationDate:{element:S,state:this.createFieldDefaultState()},cardVerificationCode:{element:B,state:this.createFieldDefaultState()}},this.addElementStateListener("cardNumber"),this.addElementStateListener("cardExpirationDate"),this.addElementStateListener("cardVerificationCode"),{cardNumber:T,expiryDate:S,securityCode:B}}}),Object.defineProperty(this,"createTextField",{enumerable:!0,configurable:!0,writable:!0,value:(s={})=>{const a=Ne.get(this);if(!a)throw new Error("Secure key not found");const u={disabled:!1,autocomplete:"on",style:{...fr}},l=xe("text",{...Oe(u,{...s})},a);return this.textElements.push(l),l}}),Object.defineProperty(this,"tokenize",{enumerable:!0,configurable:!0,writable:!0,value:async s=>{var y,_;if(((y=this.session.state)==null?void 0:y.next_action)!=="tokenize_card")throw new Error(`The session's next_action='${(_=this.session.state)==null?void 0:_.next_action}'. tokenize() is available only if next_action='tokenize_card'`);const a=this.getFormValue(),u=this.extractAdditionalData(s);if(!a)throw new Error("Form elements must be initialized before tokenization");const l=this.getCardDataValidationError();if(l)throw l;if(!a.number||!a.expiration_month||!a.expiration_year||!a.cvc)throw new Error("Card data is not complete");const f=this.session.state.data;switch(f.provider){case"basis_theory":{if(!this.bt)throw new Error("basis_theory SDK not found");return this.bt.tokenize({type:"card",data:a,...ka}).then(T=>Array.isArray(T)?null:{token_id:T.id,additional_data:u})}case"guardian":return this.encryptCardData({account_number:a.number,expiry_month:a.expiration_month,expiry_year:a.expiration_year,security_code:a.cvc,additional_data:u},f.jwk);default:ASSERT_EXHAUSTIVE(f)}}}),Object.defineProperty(this,"onStateChange",{enumerable:!0,configurable:!0,writable:!0,value:s=>{this.stateChangeHandlers.push(s),s(this.state)}}),Object.defineProperty(this,"clear",{enumerable:!0,configurable:!0,writable:!0,value:()=>{Object.values(this.cardElements).forEach(s=>s==null?void 0:s.element.clear()),this.textElements.forEach(s=>s==null?void 0:s.clear())}}),Object.defineProperty(this,"reset",{enumerable:!0,configurable:!0,writable:!0,value:()=>{Object.values(this.cardElements).forEach(s=>s==null?void 0:s.element.unmount()),this.textElements.forEach(s=>s==null?void 0:s.unmount()),this.cardElements={},this.textElements=[]}}),Object.defineProperty(this,"dispose",{enumerable:!0,configurable:!0,writable:!0,value:()=>{this.reset()}}),Object.defineProperty(this,"process",{enumerable:!0,configurable:!0,writable:!0,value:async(s={})=>{if(!this.hasFormElements())throw new Error("Card form must be initialized and completed before processing");if(this.session.isNextAction("refresh_security_code"))return this.refreshSecurityCode();this.disableFormElements(!0);try{const a=await this.tokenize(s);if(!a)throw new Error("Tokenization failed");return await this.session.completeAction({action:"tokenize_card",result:a})}catch(a){throw this.disableFormElements(!1),a}}}),Ne.set(this,Rs()),this.cvcOnlyEnabled=this.session.isNextAction("refresh_security_code")}async refreshSecurityCode(){const t=this.getFormValue();if(!(t!=null&&t.cvc))throw new Error("cvc field was not filled");if(!this.session.isNextAction("refresh_security_code")||!this.session.state)throw new Error("refreshSecurityCode() is available only if next_action=refresh_security_code");this.disableFormElements(!0);const r=await this.encryptCardData({security_code:t.cvc},this.session.state.data.jwk);return this.session.completeAction({action:"refresh_security_code",result:{...r}}).catch(s=>{if(this.disableFormElements(!1),s instanceof Error)throw s;return{status:"failure",data:s}})}getFormValue(){var l,f,y,_,T;const{card:t,cardNumber:r,cardExpirationDate:s,cardVerificationCode:a}=this.cardElements;let u;if(t){const S=je(this,t.element);u={number:(S==null?void 0:S.number)??null,expiration_month:((l=S==null?void 0:S.expiry_date)==null?void 0:l.month)??null,expiration_year:((f=S==null?void 0:S.expiry_date)==null?void 0:f.year)??null,cvc:(S==null?void 0:S.cvc)??null}}return r&&s&&a&&(u={number:((y=je(this,r.element))==null?void 0:y.replaceAll(" ",""))??null,expiration_month:((_=je(this,s.element))==null?void 0:_.month)??null,expiration_year:((T=je(this,s.element))==null?void 0:T.year)??null,cvc:je(this,a.element)}),u}hasFormElements(){return!!Object.keys(this.cardElements).length}disableFormElements(t){Object.values(this.cardElements).forEach(({element:r})=>{r.update({disabled:t})})}extractAdditionalData({cardholder_name:t,billing_address:r={}}){return Ce({cardholder_name:Ue(this,t),billing_address:{line1:Ue(this,r.line1),line2:Ue(this,r.line2),line3:Ue(this,r.line3),city:Ue(this,r.city),postal_code:Ue(this,r.postal_code)}})}async encryptCardData(t,r){const s=await xa(r,"RSA-OAEP"),a=JSON.stringify(t),u=new TextEncoder().encode(a);return{enc_payload:await new za(u).setProtectedHeader({alg:"RSA-OAEP",enc:"A256GCM"}).encrypt(s)}}addElementStateListener(t){const r=this.cardElements[t];r&&r.element.on("change",s=>{r.state=s,this.updateFormState()})}updateFormState(){const t=this.cvcOnlyEnabled&&this.cardElements.cardVerificationCode?[this.cardElements.cardVerificationCode]:Object.values(this.cardElements);t.length?this.state=t.reduce((r,{state:s})=>(r.valid=!!r.valid&&!!s.valid,r.complete=!!r.complete&&!!s.complete,r.empty=!!r.empty&&!!s.empty,r.error=r.error||s.error,r.errorCode=r.errorCode||s.errorCode,r),{valid:!0,complete:!0,empty:!0}):this.state=this.createFieldDefaultState(),this.stateChangeHandlers.forEach(r=>r(this.state))}createFieldDefaultState(){return{empty:!0,complete:!1,valid:!1}}getCardDataValidationError(){if(!this.state.complete)return new Error(this.state.error??"Card data is not complete");if(!this.state.valid)return new Error(`Card data is not valid. ${this.state.error}`)}}const Ne=new Map;function je(e,t){const r=Ne.get(e);return r?t.secureValue(r):null}function Ue(e,t){const r=Ne.get(e);return t instanceof Er&&r?je(e,t)??void 0:t}class Ja{constructor(t="https://api.hellgate.io",r=new AbortController){Object.defineProperty(this,"abortCtrl",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"baseUrl",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.baseUrl=t.endsWith("/")?t.substring(0,t.length-1):t}getSession(t){return fetch(`${this.baseUrl}/sessions/${t}`,{signal:this.abortCtrl.signal}).then(r=>Bt(r))}completeAction(t,r){return fetch(`${this.baseUrl}/sessions/${t}/complete-action`,{method:"POST",headers:{"Content-Type":"application/json"},mode:"cors",body:JSON.stringify(r),signal:this.abortCtrl.signal}).then(s=>Bt(s))}cancelAll(){this.abortCtrl.abort()}}const Xa=2e3;class Ya{constructor(t,r){Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"api",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"state",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"stateChangeHandlers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"onCloseHandlers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"pollingTimer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"init",{enumerable:!0,configurable:!0,writable:!0,value:async()=>new Promise((s,a)=>{const u=this.onStateChange(l=>{l.next_action!=="wait"&&(s(l),u())});this.updateSessionState().catch(l=>{l instanceof Response&&l.status===404&&a(new Error(`Session ${this.id} doesn't exist or has expired`)),a(l)})})}),Object.defineProperty(this,"onStateChange",{enumerable:!0,configurable:!0,writable:!0,value:s=>(this.stateChangeHandlers.push(s),this.state&&s(this.state),()=>this.stateChangeHandlers=this.stateChangeHandlers.filter(a=>a!==s))}),Object.defineProperty(this,"onClose",{enumerable:!0,configurable:!0,writable:!0,value:s=>{var a;return((a=this.state)==null?void 0:a.next_action)===null?(s(br(this.state)),()=>{}):(this.onCloseHandlers.push(s),()=>this.onCloseHandlers=this.onCloseHandlers.filter(u=>u!==s))}}),Object.defineProperty(this,"completeAction",{enumerable:!0,configurable:!0,writable:!0,value:async s=>{const a=this.state;return new Promise((u,l)=>{const f=this.onStateChange(y=>{y.next_action!==(a==null?void 0:a.next_action)&&y.next_action===null&&(u(br(y)),f())});this.api.completeAction(this.id,s).then(y=>this.newStateHandle(y,l)).catch(async y=>l(await Za(y)))})}}),Object.defineProperty(this,"completeSession",{enumerable:!0,configurable:!0,writable:!0,value:s=>{this.onCloseHandlers.forEach(a=>a(s)),this.stop()}}),Object.defineProperty(this,"dispose",{enumerable:!0,configurable:!0,writable:!0,value:()=>{this.stop(),this.api.cancelAll()}})}isNextAction(t){var r;return((r=this.state)==null?void 0:r.next_action)===t}stop(){window.clearTimeout(this.pollingTimer),this.stateChangeHandlers=[],this.onCloseHandlers=[]}async updateSessionState(t){const r=await this.api.getSession(this.id);this.newStateHandle(r,t)}newStateHandle(t,r){var s;switch(!t.next_action&&t.status&&(t.next_action=null),t.next_action){case"wait":{window.clearTimeout(this.pollingTimer),this.pollingTimer=window.setTimeout(()=>this.updateSessionState(r).catch(a=>{a instanceof Response&&a.status===404&&(r==null||r(new Error(`Session ${this.id} has expired`)))}),Xa);break}}t.next_action!==((s=this.state)==null?void 0:s.next_action)&&this.stateChangeHandlers.forEach(a=>a(t)),t.next_action===null&&this.completeSession(br(t)),this.state=t}}async function Za(e){return!e.ok&&e.status>=400&&e.status<=500?e.json():e}function br(e){const t={...e};return delete t.next_action,t}const Qa={base_url:"https://api.hellgate.io"};class _r{constructor(t,r){Object.defineProperty(this,"session",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"paymentFlowHandlers",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"dispose",{enumerable:!0,configurable:!0,writable:!0,value:()=>{this.session.dispose(),Object.values(this.paymentFlowHandlers).forEach(s=>s==null?void 0:s.dispose())}}),Object.defineProperty(this,"onSessionComplete",{enumerable:!0,configurable:!0,writable:!0,value:s=>{this.session.onClose(s)}})}use(t){return this.paymentFlowHandlers[t]}static async init(t,r={}){const{session:s,cardHandler:a,handler3DS:u}=await this.initHandlers(t,r);return new _r(s,{CARD:a,"3DS":u})}static async initHandlers(t,r){const s={...Qa,...r},a=new Ja(s.base_url,s.abortCtrl),u=new Ya(t,a);await u.init();const l=u.isNextAction("tokenize_card")||u.isNextAction("refresh_security_code")?await this.createCardHandler(u):void 0,f=this.create3DSHandler(u,r);return{session:u,cardHandler:l,handler3DS:f}}static createCardHandler(t){return yt.init(t)}static create3DSHandler(t,r){return new $r(t,{domContainer:r.challenge_3ds_container,labelText:r.challenge_3ds_label_text})}}V.CardElement=Ts,V.CardExpirationDateElement=_s,V.CardNumberElement=ws,V.CardVerificationCodeElement=Ss,V.Hellgate=_r,V.Hellgate3DSHandler=$r,V.HellgateCardHandler=yt,V.TextElement=Er,V.createElement=xe,V.extractCardNumberValue=yr,V.extractExpiryDateValue=pr,V.putCardNumberValue=gs,V.putExpiryDateValue=mr,V.uid=Rs,Object.defineProperty(V,Symbol.toStringTag,{value:"Module"})});globalThis.HellgateSDK&&(globalThis.Hellgate=globalThis.HellgateSDK.Hellgate,delete globalThis.HellgateSDK);
|
|
1
|
+
(function(p,K){typeof exports=="object"&&typeof module<"u"?K(exports):typeof define=="function"&&define.amd?define(["exports"],K):(p=typeof globalThis<"u"?globalThis:p||self,K(p.HellgateSDK={}))})(this,function(p){"use strict";function K(t){return Array.isArray(t)?t.filter(Boolean):Object.fromEntries(Object.entries(t).map(([e,r])=>[e,typeof r=="object"&&r&&!Array.isArray(r)?K(r):r]).filter(([e,r])=>typeof r=="object"&&r&&!Array.isArray(r)?!!Object.keys(r).length:r!=null&&r!=null))}function C(t,e){const r={...t,...e},n=Object.keys(r);for(const i of n){const a=t[i],s=e[i];typeof a=="object"&&!Array.isArray(a)&&a&&typeof s=="object"&&!Array.isArray(s)&&s&&(r[i]=C(a,s))}return r}function W(t){if(!t.ok)throw t;return t.json()}const Re=2e3;class ie{constructor(e,r){Object.defineProperty(this,"session",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"iframeId",{enumerable:!0,configurable:!0,writable:!0,value:String(Math.floor(1e5+Math.random()*9e5))}),Object.defineProperty(this,"resultPollingTimer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"transactionId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"decoupledAuthHandlers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"disposers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"check3dsIframeDisposers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"domContainer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"labelText",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onStartHandler",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onFinishHandler",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onDecoupledAuth",{enumerable:!0,configurable:!0,writable:!0,value:n=>{this.decoupledAuthHandlers.push(n)}}),Object.defineProperty(this,"onStartChallenge",{enumerable:!0,configurable:!0,writable:!0,value:n=>{this.onStartHandler=n}}),Object.defineProperty(this,"onChallengeFinished",{enumerable:!0,configurable:!0,writable:!0,value:n=>{this.onFinishHandler=n}}),Object.defineProperty(this,"sessionStateHandle",{enumerable:!0,configurable:!0,writable:!0,value:n=>{var i,a;switch(n.next_action){case"3ds_check":{this.initCheck3DSIframes(n.data.threeds_server_callback_url,n.data.mon_url);break}case"3ds_challenge":{(i=this.onStartHandler)==null||i.call(this),this.disposeCheck3DSIframe(),this.startChallenge(n.data.challenge_url,n.data.result_mon_url);break}case"3ds_challenge_decoupled":{this.startDecoupledAuth(n.data.cardholder_info,n.data.result_mon_url,n.data.transaction_id);break}case null:{this.dispose(),(a=this.onFinishHandler)==null||a.call(this);break}}}}),this.domContainer=r.domContainer??N(),this.disposers.push(this.session.onStateChange(this.sessionStateHandle)),this.labelText=r.labelText}dispose(){this.disposers.forEach(e=>e()),this.check3dsIframeDisposers.forEach(e=>e())}initCheck3DSIframes(e,r){const n=N();n.insertAdjacentHTML("beforeend",`<iframe id="check_3ds_${this.iframeId}" width="0" height="0" style="border:0;visibility: hidden;" src="${e}"></iframe>`);const i=n.querySelector(`#check_3ds_${this.iframeId}`);if(i){const a=s=>{s.source===i.contentWindow&&this.session.completeAction({action:"3ds_check",result:s.data})};window.addEventListener("message",a),this.check3dsIframeDisposers.push(()=>window.removeEventListener("message",a),()=>i.remove())}if(r){n.insertAdjacentHTML("beforeend",`<iframe id="mon_${this.iframeId}" width="0" height="0" style="border:0;visibility: hidden;" src="${r}"></iframe>`);const a=n.querySelector(`#mon_${this.iframeId}`);a&&this.disposers.push(()=>a.remove())}}disposeCheck3DSIframe(){this.check3dsIframeDisposers.forEach(e=>e()),this.check3dsIframeDisposers=[]}startChallenge(e,r){const n=N(),i=`<div style="display: flex; flex-direction: column; gap: 10px; align-items: center; ${this.domContainer===n?'border:0; max-width: 800px; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width:100% " ':'border:0;" width="100%" height="100%"'}><iframe id="cha_${this.iframeId}" src="${e}" width="100%" height="500"></iframe>${this.labelText?'<span id="tds_label_text" style="font-size: large;">'+this.labelText+"</span>":""}<div>`;this.domContainer.insertAdjacentHTML("beforeend",this.domContainer===n?`<div id="cha_${this.iframeId}_wrap" style="background: #fff; position: fixed; left: 0; top: 0; width: 100%; height: 100%; z-index: 10000;">${i}</div>`:i);const a=this.domContainer.querySelector(`#cha_${this.iframeId}`),s=this.domContainer.querySelector(`#cha_${this.iframeId}_wrap`);if(!a)throw new Error("3DS Challenge Iframe initialization failed");this.disposers.push(()=>{a.remove(),s==null||s.remove()});const o=new Promise(u=>{const d=h=>{h.source!==a.contentWindow||h.data.event!=="AuthResultReady"||u(h.data)};window.addEventListener("message",d),this.disposers.push(()=>window.removeEventListener("message",d))}),c=new Promise(u=>{const d=this.startAuthResultPolling(r,h=>{h.event==="AuthResultReady"&&(d(),u({requestor_trans_id:h.threeDSRequestorTransID,event:h.event}))})});Promise.any([o,c]).then(u=>{this.session.completeAction({action:"3ds_challenge",result:u})})}startDecoupledAuth(e,r,n){this.transactionId||(this.transactionId=n),this.decoupledAuthHandlers.forEach(a=>a(e));const i=this.startAuthResultPolling(r,a=>{a.event==="AuthResultReady"&&(this.session.completeAction({action:"3ds_challenge_decoupled",result:{...a,event:a.event}}),i())})}startAuthResultPolling(e,r){return window.clearTimeout(this.resultPollingTimer),this.resultPollingTimer=window.setTimeout(()=>fetch(e).then(n=>W(n)).then(n=>{this.startAuthResultPolling(e,r),r(n)}).catch(()=>{}),Re),()=>window.clearTimeout(this.resultPollingTimer)}}function N(){return document.body}const f=crypto,S=t=>t instanceof CryptoKey,Ie=async(t,e)=>{const r=`SHA-${t.slice(-3)}`;return new Uint8Array(await f.subtle.digest(r,e))},H=new TextEncoder,ae=new TextDecoder,I=2**32;function j(...t){const e=t.reduce((i,{length:a})=>i+a,0),r=new Uint8Array(e);let n=0;for(const i of t)r.set(i,n),n+=i.length;return r}function Ue(t,e){return j(H.encode(t),new Uint8Array([0]),e)}function L(t,e,r){if(e<0||e>=I)throw new RangeError(`value must be >= 0 and <= ${I-1}. Received ${e}`);t.set([e>>>24,e>>>16,e>>>8,e&255],r)}function $e(t){const e=Math.floor(t/I),r=t%I,n=new Uint8Array(8);return L(n,e,0),L(n,r,4),n}function F(t){const e=new Uint8Array(4);return L(e,t),e}function B(t){return j(F(t.length),t)}async function We(t,e,r){const n=Math.ceil((e>>3)/32),i=new Uint8Array(n*32);for(let a=0;a<n;a++){const s=new Uint8Array(4+t.length+r.length);s.set(F(a+1)),s.set(t,4),s.set(r,4+t.length),i.set(await Ie("sha256",s),a*32)}return i.slice(0,e>>3)}const Ne=t=>{let e=t;typeof e=="string"&&(e=H.encode(e));const r=32768,n=[];for(let i=0;i<e.length;i+=r)n.push(String.fromCharCode.apply(null,e.subarray(i,i+r)));return btoa(n.join(""))},w=t=>Ne(t).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_"),Le=t=>{const e=atob(t),r=new Uint8Array(e.length);for(let n=0;n<e.length;n++)r[n]=e.charCodeAt(n);return r},se=t=>{let e=t;e instanceof Uint8Array&&(e=ae.decode(e)),e=e.replace(/-/g,"+").replace(/_/g,"/").replace(/\s/g,"");try{return Le(e)}catch{throw new TypeError("The input to be decoded is not correctly encoded.")}};class oe extends Error{static get code(){return"ERR_JOSE_GENERIC"}constructor(e){var r;super(e),this.code="ERR_JOSE_GENERIC",this.name=this.constructor.name,(r=Error.captureStackTrace)==null||r.call(Error,this,this.constructor)}}class m extends oe{constructor(){super(...arguments),this.code="ERR_JOSE_NOT_SUPPORTED"}static get code(){return"ERR_JOSE_NOT_SUPPORTED"}}class P extends oe{constructor(){super(...arguments),this.code="ERR_JWE_INVALID"}static get code(){return"ERR_JWE_INVALID"}}const V=f.getRandomValues.bind(f);function ce(t){switch(t){case"A128GCM":case"A128GCMKW":case"A192GCM":case"A192GCMKW":case"A256GCM":case"A256GCMKW":return 96;case"A128CBC-HS256":case"A192CBC-HS384":case"A256CBC-HS512":return 128;default:throw new m(`Unsupported JWE Algorithm: ${t}`)}}const Fe=t=>V(new Uint8Array(ce(t)>>3)),Be=(t,e)=>{if(e.length<<3!==ce(t))throw new P("Invalid Initialization Vector length")},le=(t,e)=>{const r=t.byteLength<<3;if(r!==e)throw new P(`Invalid Content Encryption Key length. Expected ${e} bits, got ${r} bits`)};function v(t,e="algorithm.name"){return new TypeError(`CryptoKey does not support this operation, its ${e} must be ${t}`)}function U(t,e){return t.name===e}function Ve(t){return parseInt(t.name.slice(4),10)}function ze(t,e){if(e.length&&!e.some(r=>t.usages.includes(r))){let r="CryptoKey does not support this operation, its usages must include ";if(e.length>2){const n=e.pop();r+=`one of ${e.join(", ")}, or ${n}.`}else e.length===2?r+=`one of ${e[0]} or ${e[1]}.`:r+=`${e[0]}.`;throw new TypeError(r)}}function T(t,e,...r){switch(e){case"A128GCM":case"A192GCM":case"A256GCM":{if(!U(t.algorithm,"AES-GCM"))throw v("AES-GCM");const n=parseInt(e.slice(1,4),10);if(t.algorithm.length!==n)throw v(n,"algorithm.length");break}case"A128KW":case"A192KW":case"A256KW":{if(!U(t.algorithm,"AES-KW"))throw v("AES-KW");const n=parseInt(e.slice(1,4),10);if(t.algorithm.length!==n)throw v(n,"algorithm.length");break}case"ECDH":{switch(t.algorithm.name){case"ECDH":case"X25519":case"X448":break;default:throw v("ECDH, X25519, or X448")}break}case"PBES2-HS256+A128KW":case"PBES2-HS384+A192KW":case"PBES2-HS512+A256KW":if(!U(t.algorithm,"PBKDF2"))throw v("PBKDF2");break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":{if(!U(t.algorithm,"RSA-OAEP"))throw v("RSA-OAEP");const n=parseInt(e.slice(9),10)||1;if(Ve(t.algorithm.hash)!==n)throw v(`SHA-${n}`,"algorithm.hash");break}default:throw new TypeError("CryptoKey does not support this operation")}ze(t,r)}function ue(t,e,...r){var n;if(r.length>2){const i=r.pop();t+=`one of type ${r.join(", ")}, or ${i}.`}else r.length===2?t+=`one of type ${r[0]} or ${r[1]}.`:t+=`of type ${r[0]}.`;return e==null?t+=` Received ${e}`:typeof e=="function"&&e.name?t+=` Received function ${e.name}`:typeof e=="object"&&e!=null&&(n=e.constructor)!=null&&n.name&&(t+=` Received an instance of ${e.constructor.name}`),t}const _=(t,...e)=>ue("Key must be ",t,...e);function de(t,e,...r){return ue(`Key for the ${t} algorithm must be `,e,...r)}const he=t=>S(t)?!0:(t==null?void 0:t[Symbol.toStringTag])==="KeyObject",g=["CryptoKey"],Je=(...t)=>{const e=t.filter(Boolean);if(e.length===0||e.length===1)return!0;let r;for(const n of e){const i=Object.keys(n);if(!r||r.size===0){r=new Set(i);continue}for(const a of i){if(r.has(a))return!1;r.add(a)}}return!0};function Ge(t){return typeof t=="object"&&t!==null}function Ye(t){if(!Ge(t)||Object.prototype.toString.call(t)!=="[object Object]")return!1;if(Object.getPrototypeOf(t)===null)return!0;let e=t;for(;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}const fe=[{hash:"SHA-256",name:"HMAC"},!0,["sign"]];function ke(t,e){if(t.algorithm.length!==parseInt(e.slice(1,4),10))throw new TypeError(`Invalid key size for alg: ${e}`)}function qe(t,e,r){if(S(t))return T(t,e,r),t;if(t instanceof Uint8Array)return f.subtle.importKey("raw",t,"AES-KW",!0,[r]);throw new TypeError(_(t,...g,"Uint8Array"))}const z=async(t,e,r)=>{const n=await qe(e,t,"wrapKey");ke(n,t);const i=await f.subtle.importKey("raw",r,...fe);return new Uint8Array(await f.subtle.wrapKey("raw",i,n,"AES-KW"))};async function Xe(t,e,r,n,i=new Uint8Array(0),a=new Uint8Array(0)){if(!S(t))throw new TypeError(_(t,...g));if(T(t,"ECDH"),!S(e))throw new TypeError(_(e,...g));T(e,"ECDH","deriveBits");const s=j(B(H.encode(r)),B(i),B(a),F(n));let o;t.algorithm.name==="X25519"?o=256:t.algorithm.name==="X448"?o=448:o=Math.ceil(parseInt(t.algorithm.namedCurve.substr(-3),10)/8)<<3;const c=new Uint8Array(await f.subtle.deriveBits({name:t.algorithm.name,public:t},e,o));return We(c,n,s)}async function Ze(t){if(!S(t))throw new TypeError(_(t,...g));return f.subtle.generateKey(t.algorithm,!0,["deriveBits"])}function Qe(t){if(!S(t))throw new TypeError(_(t,...g));return["P-256","P-384","P-521"].includes(t.algorithm.namedCurve)||t.algorithm.name==="X25519"||t.algorithm.name==="X448"}function et(t){if(!(t instanceof Uint8Array)||t.length<8)throw new P("PBES2 Salt Input must be 8 or more octets")}function tt(t,e){if(t instanceof Uint8Array)return f.subtle.importKey("raw",t,"PBKDF2",!1,["deriveBits"]);if(S(t))return T(t,e,"deriveBits","deriveKey"),t;throw new TypeError(_(t,...g,"Uint8Array"))}async function rt(t,e,r,n){et(t);const i=Ue(e,t),a=parseInt(e.slice(13,16),10),s={hash:`SHA-${e.slice(8,11)}`,iterations:r,name:"PBKDF2",salt:i},o={length:a,name:"AES-KW"},c=await tt(n,e);if(c.usages.includes("deriveBits"))return new Uint8Array(await f.subtle.deriveBits(s,c,a));if(c.usages.includes("deriveKey"))return f.subtle.deriveKey(s,c,o,!1,["wrapKey","unwrapKey"]);throw new TypeError('PBKDF2 key "usages" must include "deriveBits" or "deriveKey"')}const nt=async(t,e,r,n=2048,i=V(new Uint8Array(16)))=>{const a=await rt(i,t,n,e);return{encryptedKey:await z(t.slice(-6),a,r),p2c:n,p2s:w(i)}};function pe(t){switch(t){case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":return"RSA-OAEP";default:throw new m(`alg ${t} is not supported either by JOSE or your javascript runtime`)}}const it=(t,e)=>{if(t.startsWith("RS")||t.startsWith("PS")){const{modulusLength:r}=e.algorithm;if(typeof r!="number"||r<2048)throw new TypeError(`${t} requires key modulusLength to be 2048 bits or larger`)}},at=async(t,e,r)=>{if(!S(e))throw new TypeError(_(e,...g));if(T(e,t,"encrypt","wrapKey"),it(t,e),e.usages.includes("encrypt"))return new Uint8Array(await f.subtle.encrypt(pe(t),e,r));if(e.usages.includes("wrapKey")){const n=await f.subtle.importKey("raw",r,...fe);return new Uint8Array(await f.subtle.wrapKey("raw",n,e,pe(t)))}throw new TypeError('RSA-OAEP key "usages" must include "encrypt" or "wrapKey" for this operation')};function st(t){let e,r;switch(t.kty){case"RSA":{switch(t.alg){case"PS256":case"PS384":case"PS512":e={name:"RSA-PSS",hash:`SHA-${t.alg.slice(-3)}`},r=t.d?["sign"]:["verify"];break;case"RS256":case"RS384":case"RS512":e={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${t.alg.slice(-3)}`},r=t.d?["sign"]:["verify"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":e={name:"RSA-OAEP",hash:`SHA-${parseInt(t.alg.slice(-3),10)||1}`},r=t.d?["decrypt","unwrapKey"]:["encrypt","wrapKey"];break;default:throw new m('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break}case"EC":{switch(t.alg){case"ES256":e={name:"ECDSA",namedCurve:"P-256"},r=t.d?["sign"]:["verify"];break;case"ES384":e={name:"ECDSA",namedCurve:"P-384"},r=t.d?["sign"]:["verify"];break;case"ES512":e={name:"ECDSA",namedCurve:"P-521"},r=t.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":e={name:"ECDH",namedCurve:t.crv},r=t.d?["deriveBits"]:[];break;default:throw new m('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break}case"OKP":{switch(t.alg){case"EdDSA":e={name:t.crv},r=t.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":e={name:t.crv},r=t.d?["deriveBits"]:[];break;default:throw new m('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break}default:throw new m('Invalid or unsupported JWK "kty" (Key Type) Parameter value')}return{algorithm:e,keyUsages:r}}const me=async t=>{if(!t.alg)throw new TypeError('"alg" argument is required when "jwk.alg" is not present');const{algorithm:e,keyUsages:r}=st(t),n=[e,t.ext??!1,t.key_ops??r],i={...t};return delete i.alg,delete i.use,f.subtle.importKey("jwk",i,...n)},be=t=>se(t);let J,G;const ye=t=>(t==null?void 0:t[Symbol.toStringTag])==="KeyObject",we=async(t,e,r,n)=>{let i=t.get(e);if(i!=null&&i[n])return i[n];const a=await me({...r,alg:n});return i?i[n]=a:t.set(e,{[n]:a}),a},Y={normalizePublicKey:(t,e)=>{if(ye(t)){let r=t.export({format:"jwk"});return delete r.d,delete r.dp,delete r.dq,delete r.p,delete r.q,delete r.qi,r.k?be(r.k):(G||(G=new WeakMap),we(G,t,r,e))}return t},normalizePrivateKey:(t,e)=>{if(ye(t)){let r=t.export({format:"jwk"});return r.k?be(r.k):(J||(J=new WeakMap),we(J,t,r,e))}return t}};function Ee(t){switch(t){case"A128GCM":return 128;case"A192GCM":return 192;case"A256GCM":case"A128CBC-HS256":return 256;case"A192CBC-HS384":return 384;case"A256CBC-HS512":return 512;default:throw new m(`Unsupported JWE Algorithm: ${t}`)}}const R=t=>V(new Uint8Array(Ee(t)>>3));async function ot(t,e){if(!Ye(t))throw new TypeError("JWK must be an object");switch(t.kty){case"oct":if(typeof t.k!="string"||!t.k)throw new TypeError('missing "k" (Key Value) Parameter value');return se(t.k);case"RSA":if(t.oth!==void 0)throw new m('RSA JWK "oth" (Other Primes Info) Parameter value is not supported');case"EC":case"OKP":return me({...t,alg:e});default:throw new m('Unsupported "kty" (Key Type) Parameter value')}}const k=t=>t==null?void 0:t[Symbol.toStringTag],ct=(t,e)=>{if(!(e instanceof Uint8Array)){if(!he(e))throw new TypeError(de(t,e,...g,"Uint8Array"));if(e.type!=="secret")throw new TypeError(`${k(e)} instances for symmetric algorithms must be of type "secret"`)}},lt=(t,e,r)=>{if(!he(e))throw new TypeError(de(t,e,...g));if(e.type==="secret")throw new TypeError(`${k(e)} instances for asymmetric algorithms must not be of type "secret"`);if(e.algorithm,e.algorithm&&r==="encrypt"&&e.type==="private")throw new TypeError(`${k(e)} instances for asymmetric algorithm encryption must be of type "public"`)},ut=(t,e,r)=>{t.startsWith("HS")||t==="dir"||t.startsWith("PBES2")||/^A\d{3}(?:GCM)?KW$/.test(t)?ct(t,e):lt(t,e,r)};async function dt(t,e,r,n,i){if(!(r instanceof Uint8Array))throw new TypeError(_(r,"Uint8Array"));const a=parseInt(t.slice(1,4),10),s=await f.subtle.importKey("raw",r.subarray(a>>3),"AES-CBC",!1,["encrypt"]),o=await f.subtle.importKey("raw",r.subarray(0,a>>3),{hash:`SHA-${a<<1}`,name:"HMAC"},!1,["sign"]),c=new Uint8Array(await f.subtle.encrypt({iv:n,name:"AES-CBC"},s,e)),u=j(i,n,c,$e(i.length<<3)),d=new Uint8Array((await f.subtle.sign("HMAC",o,u)).slice(0,a>>3));return{ciphertext:c,tag:d,iv:n}}async function ht(t,e,r,n,i){let a;r instanceof Uint8Array?a=await f.subtle.importKey("raw",r,"AES-GCM",!1,["encrypt"]):(T(r,t,"encrypt"),a=r);const s=new Uint8Array(await f.subtle.encrypt({additionalData:i,iv:n,name:"AES-GCM",tagLength:128},a,e)),o=s.slice(-16);return{ciphertext:s.slice(0,-16),tag:o,iv:n}}const ge=async(t,e,r,n,i)=>{if(!S(r)&&!(r instanceof Uint8Array))throw new TypeError(_(r,...g,"Uint8Array"));switch(n?Be(t,n):n=Fe(t),t){case"A128CBC-HS256":case"A192CBC-HS384":case"A256CBC-HS512":return r instanceof Uint8Array&&le(r,parseInt(t.slice(-3),10)),dt(t,e,r,n,i);case"A128GCM":case"A192GCM":case"A256GCM":return r instanceof Uint8Array&&le(r,parseInt(t.slice(1,4),10)),ht(t,e,r,n,i);default:throw new m("Unsupported JWE Content Encryption Algorithm")}};async function ft(t,e,r,n){const i=t.slice(0,7),a=await ge(i,r,e,n,new Uint8Array(0));return{encryptedKey:a.ciphertext,iv:w(a.iv),tag:w(a.tag)}}function pt(t,e,r,n,i){if(i.crit!==void 0&&(n==null?void 0:n.crit)===void 0)throw new t('"crit" (Critical) Header Parameter MUST be integrity protected');if(!n||n.crit===void 0)return new Set;if(!Array.isArray(n.crit)||n.crit.length===0||n.crit.some(s=>typeof s!="string"||s.length===0))throw new t('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present');let a;r!==void 0?a=new Map([...Object.entries(r),...e.entries()]):a=e;for(const s of n.crit){if(!a.has(s))throw new m(`Extension Header Parameter "${s}" is not recognized`);if(i[s]===void 0)throw new t(`Extension Header Parameter "${s}" is missing`);if(a.get(s)&&n[s]===void 0)throw new t(`Extension Header Parameter "${s}" MUST be integrity protected`)}return new Set(n.crit)}const mt=async t=>{if(t instanceof Uint8Array)return{kty:"oct",k:w(t)};if(!S(t))throw new TypeError(_(t,...g,"Uint8Array"));if(!t.extractable)throw new TypeError("non-extractable CryptoKey cannot be exported as a JWK");const{ext:e,key_ops:r,alg:n,use:i,...a}=await f.subtle.exportKey("jwk",t);return a};async function bt(t){return mt(t)}async function yt(t,e,r,n,i={}){var c;let a,s,o;switch(ut(t,r,"encrypt"),r=await((c=Y.normalizePublicKey)==null?void 0:c.call(Y,r,t))||r,t){case"dir":{o=r;break}case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":{if(!Qe(r))throw new m("ECDH with the provided key is not allowed or not supported by your javascript runtime");const{apu:u,apv:d}=i;let{epk:h}=i;h||(h=(await Ze(r)).privateKey);const{x:b,y:A,crv:l,kty:y}=await bt(h),je=await Xe(r,h,t==="ECDH-ES"?e:t,t==="ECDH-ES"?Ee(e):parseInt(t.slice(-5,-2),10),u,d);if(s={epk:{x:b,crv:l,kty:y}},y==="EC"&&(s.epk.y=A),u&&(s.apu=w(u)),d&&(s.apv=w(d)),t==="ECDH-ES"){o=je;break}o=n||R(e);const Tt=t.slice(-6);a=await z(Tt,je,o);break}case"RSA1_5":case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":{o=n||R(e),a=await at(t,r,o);break}case"PBES2-HS256+A128KW":case"PBES2-HS384+A192KW":case"PBES2-HS512+A256KW":{o=n||R(e);const{p2c:u,p2s:d}=i;({encryptedKey:a,...s}=await nt(t,r,o,u,d));break}case"A128KW":case"A192KW":case"A256KW":{o=n||R(e),a=await z(t,r,o);break}case"A128GCMKW":case"A192GCMKW":case"A256GCMKW":{o=n||R(e);const{iv:u}=i;({encryptedKey:a,...s}=await ft(t,r,o,u));break}default:throw new m('Invalid or unsupported "alg" (JWE Algorithm) header value')}return{cek:o,encryptedKey:a,parameters:s}}const wt=Symbol();class Et{constructor(e){if(!(e instanceof Uint8Array))throw new TypeError("plaintext must be an instance of Uint8Array");this._plaintext=e}setKeyManagementParameters(e){if(this._keyManagementParameters)throw new TypeError("setKeyManagementParameters can only be called once");return this._keyManagementParameters=e,this}setProtectedHeader(e){if(this._protectedHeader)throw new TypeError("setProtectedHeader can only be called once");return this._protectedHeader=e,this}setSharedUnprotectedHeader(e){if(this._sharedUnprotectedHeader)throw new TypeError("setSharedUnprotectedHeader can only be called once");return this._sharedUnprotectedHeader=e,this}setUnprotectedHeader(e){if(this._unprotectedHeader)throw new TypeError("setUnprotectedHeader can only be called once");return this._unprotectedHeader=e,this}setAdditionalAuthenticatedData(e){return this._aad=e,this}setContentEncryptionKey(e){if(this._cek)throw new TypeError("setContentEncryptionKey can only be called once");return this._cek=e,this}setInitializationVector(e){if(this._iv)throw new TypeError("setInitializationVector can only be called once");return this._iv=e,this}async encrypt(e,r){if(!this._protectedHeader&&!this._unprotectedHeader&&!this._sharedUnprotectedHeader)throw new P("either setProtectedHeader, setUnprotectedHeader, or sharedUnprotectedHeader must be called before #encrypt()");if(!Je(this._protectedHeader,this._unprotectedHeader,this._sharedUnprotectedHeader))throw new P("JWE Protected, JWE Shared Unprotected and JWE Per-Recipient Header Parameter names must be disjoint");const n={...this._protectedHeader,...this._unprotectedHeader,...this._sharedUnprotectedHeader};if(pt(P,new Map,r==null?void 0:r.crit,this._protectedHeader,n),n.zip!==void 0)throw new m('JWE "zip" (Compression Algorithm) Header Parameter is not supported.');const{alg:i,enc:a}=n;if(typeof i!="string"||!i)throw new P('JWE "alg" (Algorithm) Header Parameter missing or invalid');if(typeof a!="string"||!a)throw new P('JWE "enc" (Encryption Algorithm) Header Parameter missing or invalid');let s;if(this._cek&&(i==="dir"||i==="ECDH-ES"))throw new TypeError(`setContentEncryptionKey cannot be called with JWE "alg" (Algorithm) Header ${i}`);let o;{let y;({cek:o,encryptedKey:s,parameters:y}=await yt(i,a,e,this._cek,this._keyManagementParameters)),y&&(r&&wt in r?this._unprotectedHeader?this._unprotectedHeader={...this._unprotectedHeader,...y}:this.setUnprotectedHeader(y):this._protectedHeader?this._protectedHeader={...this._protectedHeader,...y}:this.setProtectedHeader(y))}let c,u,d;this._protectedHeader?u=H.encode(w(JSON.stringify(this._protectedHeader))):u=H.encode(""),this._aad?(d=w(this._aad),c=j(u,H.encode("."),H.encode(d))):c=u;const{ciphertext:h,tag:b,iv:A}=await ge(a,this._plaintext,o,this._iv,c),l={ciphertext:w(h)};return A&&(l.iv=w(A)),b&&(l.tag=w(b)),s&&(l.encrypted_key=w(s)),d&&(l.aad=d),this._protectedHeader&&(l.protected=ae.decode(u)),this._sharedUnprotectedHeader&&(l.unprotected=this._sharedUnprotectedHeader),this._unprotectedHeader&&(l.header=this._unprotectedHeader),l}}class gt{constructor(e){this._flattened=new Et(e)}setContentEncryptionKey(e){return this._flattened.setContentEncryptionKey(e),this}setInitializationVector(e){return this._flattened.setInitializationVector(e),this}setProtectedHeader(e){return this._flattened.setProtectedHeader(e),this}setKeyManagementParameters(e){return this._flattened.setKeyManagementParameters(e),this}async encrypt(e,r){const n=await this._flattened.encrypt(e,r);return[n.protected,n.encrypted_key,n.iv,n.ciphertext,n.tag].join(".")}}const q={base:{":disabled":{backgroundColor:"transparent"}}},At="DOM Element was not found";var Ae;(function(t){t.NOT_COMPLETE="NOT_COMPLETE",t.SCHEME_NOT_SUPPORTED="SCHEME_NOT_SUPPORTED",t.LUHN_CHECK_FAILED="LUHN_CHECK_FAILED",t.INVALID_EXPIRY_DATE="INVALID_EXPIRY_DATE"})(Ae||(Ae={}));const Se=t=>t!=null,St="v3.9.0";class x{constructor(e,r){if(Object.defineProperty(this,"options",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"IFRAME_BASE_URL",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"iframe",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"subscriptions",{enumerable:!0,configurable:!0,writable:!0,value:{ready:[],blur:[],focus:[],keydown:[],change:[]}}),Object.defineProperty(this,"update",{enumerable:!0,configurable:!0,writable:!0,value:async({...n})=>{this.iframe&&Se(n.height)&&(this.iframe.height=n.height),this.iframePostMessage({type:"update",data:{...n,value:n.value?this.putValue(n.value)??void 0:void 0}})}}),Object.defineProperty(this,"clear",{enumerable:!0,configurable:!0,writable:!0,value:()=>{this.iframePostMessage({type:"clear"})}}),Object.defineProperty(this,"focus",{enumerable:!0,configurable:!0,writable:!0,value:()=>{this.iframePostMessage({type:"focus"})}}),Object.defineProperty(this,"blur",{enumerable:!0,configurable:!0,writable:!0,value:()=>{this.iframePostMessage({type:"blur"})}}),Object.defineProperty(this,"unmount",{enumerable:!0,configurable:!0,writable:!0,value:()=>{var n;(n=this.iframe)==null||n.remove(),this.iframe=null}}),this.IFRAME_BASE_URL=_t(St),!this.IFRAME_BASE_URL)throw new Error("IFRAME_BASE_URL not found");r&&X.set(this,{key:r})}mount(e){const r=typeof e=="string"?document.querySelector(e):e;if(!r)throw new Error(`${At}: ${e}`);r.innerHTML=`<iframe width="100%" height="29" src="${this.IFRAME_BASE_URL}?field=${this.type}&origin=${location.origin}"></iframe>`,this.iframe=r.querySelector("iframe");const n=i=>{var a;if(!(i.source!==((a=this.iframe)==null?void 0:a.contentWindow)||i.data.element!==this.type))if(i.data.type==="change"){const s=this.extractValue(i.data.data.value),o={...i.data.data};delete o.value;const c=X.get(this);c&&(c.value=s),this.emitEvent({...i.data,data:o})}else this.emitEvent(i.data)};return window.addEventListener("message",n),new Promise(i=>{this.on("ready",()=>{this.update(this.options),i()})})}on(e,r){return this.subscriptions[e].push(r),{unsubscribe:()=>this.subscriptions[e].splice(this.subscriptions[e].indexOf(r),1)}}secureValue(e){const r=X.get(this);return(r==null?void 0:r.key)!==e?null:(r==null?void 0:r.value)??null}emitEvent(e){var r;(r=this.subscriptions[e.type])==null||r.forEach(n=>n(e.data))}iframePostMessage(e){var r,n;(n=(r=this.iframe)==null?void 0:r.contentWindow)==null||n.postMessage(e,this.IFRAME_BASE_URL)}}function _t(t){return`https://${window.HG_IFRAME_HOST??"sdk.hellgate.io"}/web/${t}/iframe/`}const X=new Map;class Ct extends x{constructor(){super(...arguments),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:"cardExpirationMonth"}),Object.defineProperty(this,"extractValue",{enumerable:!0,configurable:!0,writable:!0,value:_e}),Object.defineProperty(this,"putValue",{enumerable:!0,configurable:!0,writable:!0,value:Ce})}}function _e(t){return t?Number(t):null}function Ce(t){return t?t<10?`0${t}`:String(t):null}class Pt extends x{constructor(){super(...arguments),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:"cardExpirationYear"}),Object.defineProperty(this,"extractValue",{enumerable:!0,configurable:!0,writable:!0,value:Pe}),Object.defineProperty(this,"putValue",{enumerable:!0,configurable:!0,writable:!0,value:ve})}}function Pe(t){if(!t)return null;const e=Number(t);return e>10?+`20${e}`:null}function ve(t){return t?t>=100?String(t).slice(-2):String(t):null}function Z(t){const[e=null,r=null]=(t??"").split("/").map(n=>n.trim());return{month:_e(e),year:Pe(r)}}function Q(t){if(!t)return null;const{month:e,year:r}=t;return[Ce(e),ve(r)].filter(Se).join(" / ")}class Oe extends x{constructor(){super(...arguments),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:"cardExpirationDate"}),Object.defineProperty(this,"extractValue",{enumerable:!0,configurable:!0,writable:!0,value:Z}),Object.defineProperty(this,"putValue",{enumerable:!0,configurable:!0,writable:!0,value:Q})}}function ee(t){return(t==null?void 0:t.replaceAll(" ",""))??null}function He(t){return t}class xe extends x{constructor(){super(...arguments),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:"cardNumber"}),Object.defineProperty(this,"extractValue",{enumerable:!0,configurable:!0,writable:!0,value:ee}),Object.defineProperty(this,"putValue",{enumerable:!0,configurable:!0,writable:!0,value:He})}}class Ke extends x{constructor(){super(...arguments),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:"card"}),Object.defineProperty(this,"extractValue",{enumerable:!0,configurable:!0,writable:!0,value:e=>e?{number:e.cardNumber?ee(e.cardNumber):null,expiry_date:e.cardExpirationDate?Z(e.cardExpirationDate):null,cvc:e.cardVerificationCode??null}:null}),Object.defineProperty(this,"putValue",{enumerable:!0,configurable:!0,writable:!0,value:e=>e?{cardNumber:e.number?e.number:null,cardExpirationDate:e.expiry_date?Q(e.expiry_date):null,cardVerificationCode:e.cvc??null}:null})}}class Te extends x{constructor(){super(...arguments),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:"cardVerificationCode"}),Object.defineProperty(this,"extractValue",{enumerable:!0,configurable:!0,writable:!0,value:e=>e}),Object.defineProperty(this,"putValue",{enumerable:!0,configurable:!0,writable:!0,value:e=>e})}}class te extends x{constructor(){super(...arguments),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:"text"}),Object.defineProperty(this,"extractValue",{enumerable:!0,configurable:!0,writable:!0,value:e=>e}),Object.defineProperty(this,"putValue",{enumerable:!0,configurable:!0,writable:!0,value:e=>e})}}function O(t,e,r){switch(t){case"card":return new Ke(e,r);case"cardNumber":return new xe(e,r);case"cardExpirationDate":return new Oe(e,r);case"cardExpirationMonth":return new Ct(e,r);case"cardExpirationYear":return new Pt(e,r);case"cardVerificationCode":return new Te(e,r);case"text":return new te(e,r);default:ASSERT_EXHAUSTIVE(t)}}function De(){return Date.now().toString(36)+Math.random().toString(36).slice(2)}function Me(t){return[t.issuer_identification_number,"".padEnd(t.account_number_length-t.issuer_identification_number.length-t.account_number_last_four.length,"*"),t.account_number_last_four].join(" ")}class ${static async init(e){return new $(e)}constructor(e){Object.defineProperty(this,"session",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"state",{enumerable:!0,configurable:!0,writable:!0,value:this.createFieldDefaultState()}),Object.defineProperty(this,"cardElements",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"textElements",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"stateChangeHandlers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"cvcOnlyEnabled",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"createForm",{enumerable:!0,configurable:!0,writable:!0,value:(r={})=>{var s;if(this.hasFormElements())throw new Error("Form elements can't be initialized twice. You can call `reset()` method or create new Hellgate client.");const n=D.get(this);if(!n)throw new Error("Secure key not found");const i=C({disabled:!1,autocomplete:"on",style:{...q}},r);if(this.session.isNextAction("refresh_security_code")&&((s=this.session.state)!=null&&s.data)){const o=this.session.state.data;i.cvcOnly=!0,i.value={number:Me(o),expiry_date:{month:(o==null?void 0:o.expiry_month)??null,year:(o==null?void 0:o.expiry_year)??null},cvc:null}}const a=O("card",i,n);return this.cardElements.card={element:a,state:this.createFieldDefaultState()},this.addElementStateListener("card"),a}}),Object.defineProperty(this,"createTextField",{enumerable:!0,configurable:!0,writable:!0,value:(r={})=>{const n=D.get(this);if(!n)throw new Error("Secure key not found");const i={disabled:!1,autocomplete:"on",style:{...q}},a=O("text",{...C(i,{...r})},n);return this.textElements.push(a),a}}),Object.defineProperty(this,"tokenize",{enumerable:!0,configurable:!0,writable:!0,value:async r=>{var o,c;if(((o=this.session.state)==null?void 0:o.next_action)!=="tokenize_card")throw new Error(`The session's next_action='${(c=this.session.state)==null?void 0:c.next_action}'. tokenize() is available only if next_action='tokenize_card'`);const n=this.getFormValue(),i=this.extractAdditionalData(r);if(!n)throw new Error("Form elements must be initialized before tokenization");const a=this.getCardDataValidationError();if(a)throw a;if(!n.number||!n.expiration_month||!n.expiration_year||!n.cvc)throw new Error("Card data is not complete");const s=this.session.state.data;return this.encryptCardData({account_number:n.number,expiry_month:n.expiration_month,expiry_year:n.expiration_year,security_code:n.cvc,additional_data:i},s.jwk)}}),Object.defineProperty(this,"onStateChange",{enumerable:!0,configurable:!0,writable:!0,value:r=>{this.stateChangeHandlers.push(r),r(this.state)}}),Object.defineProperty(this,"clear",{enumerable:!0,configurable:!0,writable:!0,value:()=>{Object.values(this.cardElements).forEach(r=>r==null?void 0:r.element.clear()),this.textElements.forEach(r=>r==null?void 0:r.clear())}}),Object.defineProperty(this,"reset",{enumerable:!0,configurable:!0,writable:!0,value:()=>{Object.values(this.cardElements).forEach(r=>r==null?void 0:r.element.unmount()),this.textElements.forEach(r=>r==null?void 0:r.unmount()),this.cardElements={},this.textElements=[]}}),Object.defineProperty(this,"dispose",{enumerable:!0,configurable:!0,writable:!0,value:()=>{this.reset()}}),Object.defineProperty(this,"process",{enumerable:!0,configurable:!0,writable:!0,value:async(r={})=>{if(!this.hasFormElements())throw new Error("Card form must be initialized and completed before processing");if(this.session.isNextAction("refresh_security_code"))return this.refreshSecurityCode();this.disableFormElements(!0);try{const n=await this.tokenize(r);if(!n)throw new Error("Tokenization failed");return await this.session.completeAction({action:"tokenize_card",result:n})}catch(n){throw this.disableFormElements(!1),n}}}),D.set(this,De()),this.cvcOnlyEnabled=this.session.isNextAction("refresh_security_code")}createFormFields(e={}){var u,d;if(this.hasFormElements())throw new Error("Form elements can't be initialized twice. You can call `reset()` method or create new Hellgate client.");const r=D.get(this);if(!r)throw new Error("Secure key not found");const n={disabled:this.cvcOnlyEnabled,autocomplete:"on",style:{...q}},{cardNumber:i={},securityCode:a={},...s}=e,o=O("cardNumber",{...C(n,{...s,...i,cvcOnly:this.cvcOnlyEnabled,value:this.session.isNextAction("refresh_security_code")&&((u=this.session.state)!=null&&u.data)?Me(this.session.state.data):null})},r),c=O("cardVerificationCode",{...C({...n,disabled:!1,autofocus:this.cvcOnlyEnabled},{...s,...a})},r);if(o.on("change",h=>{const b=h.cardBrand;c.update({cardType:b})}),this.cardElements={cardNumber:{element:o,state:this.createFieldDefaultState()},cardVerificationCode:{element:c,state:this.createFieldDefaultState()}},this.addElementStateListener("cardNumber"),this.addElementStateListener("cardVerificationCode"),e.expiryDateElement==="separate"){const{expiryMonth:h={},expiryYear:b={}}=e,A=O("cardExpirationMonth",{...C(n,{...s,...h})},r),l=O("cardExpirationYear",{...C(n,{...s,...b})},r);return l.on("change",()=>{const y=E(this,l);A.update({expiryYear:y?String(E(this,l)):void 0})}),this.cardElements.cardExpirationMonth={element:A,state:this.createFieldDefaultState()},this.cardElements.cardExpirationYear={element:l,state:this.createFieldDefaultState()},this.addElementStateListener("cardExpirationMonth"),this.addElementStateListener("cardExpirationYear"),{cardNumber:o,expiryMonth:A,expiryYear:l,securityCode:c}}else{const{expiryDate:h={}}=e,b=O("cardExpirationDate",{...C(n,{...s,...h,value:this.session.isNextAction("refresh_security_code")&&((d=this.session.state)!=null&&d.data)?{month:this.session.state.data.expiry_month,year:this.session.state.data.expiry_year}:null})},r);return this.cardElements.cardExpirationDate={element:b,state:this.createFieldDefaultState()},this.addElementStateListener("cardExpirationDate"),{cardNumber:o,expiryDate:b,securityCode:c}}}async refreshSecurityCode(){const e=this.getFormValue();if(!(e!=null&&e.cvc))throw new Error("cvc field was not filled");if(!this.session.isNextAction("refresh_security_code")||!this.session.state)throw new Error("refreshSecurityCode() is available only if next_action=refresh_security_code");this.disableFormElements(!0);const r=await this.encryptCardData({security_code:e.cvc},this.session.state.data.jwk);return this.session.completeAction({action:"refresh_security_code",result:{...r}}).catch(n=>{if(this.disableFormElements(!1),n instanceof Error)throw n;return{status:"failure",data:n}})}getFormValue(){var c,u,d,h,b,A;const{card:e,cardNumber:r,cardExpirationDate:n,cardExpirationMonth:i,cardExpirationYear:a,cardVerificationCode:s}=this.cardElements;let o;if(e){const l=E(this,e.element);o={number:(l==null?void 0:l.number)??null,expiration_month:((c=l==null?void 0:l.expiry_date)==null?void 0:c.month)??null,expiration_year:((u=l==null?void 0:l.expiry_date)==null?void 0:u.year)??null,cvc:(l==null?void 0:l.cvc)??null}}if(r&&s&&(n&&(o={number:((d=E(this,r.element))==null?void 0:d.replaceAll(" ",""))??null,expiration_month:((h=E(this,n.element))==null?void 0:h.month)??null,expiration_year:((b=E(this,n.element))==null?void 0:b.year)??null,cvc:E(this,s.element)}),i&&a)){const l=E(this,i.element),y=E(this,a.element);o={number:((A=E(this,r.element))==null?void 0:A.replaceAll(" ",""))??null,expiration_month:l?Number(l):null,expiration_year:y?Number(y):null,cvc:E(this,s.element)}}return o}hasFormElements(){return!!Object.keys(this.cardElements).length}disableFormElements(e){Object.values(this.cardElements).forEach(({element:r})=>{r.update({disabled:e})})}extractAdditionalData({cardholder_name:e,billing_address:r={}}){return K({cardholder_name:M(this,e),billing_address:{line1:M(this,r.line1),line2:M(this,r.line2),line3:M(this,r.line3),city:M(this,r.city),postal_code:M(this,r.postal_code)}})}async encryptCardData(e,r){const n=await ot(r,"RSA-OAEP"),i=JSON.stringify(e),a=new TextEncoder().encode(i);return{enc_payload:await new gt(a).setProtectedHeader({alg:"RSA-OAEP",enc:"A256GCM"}).encrypt(n)}}addElementStateListener(e){const r=this.cardElements[e];r&&r.element.on("change",n=>{r.state=n,this.updateFormState()})}updateFormState(){const e=this.cvcOnlyEnabled&&this.cardElements.cardVerificationCode?[this.cardElements.cardVerificationCode]:Object.values(this.cardElements);e.length?this.state=e.reduce((r,{state:n})=>(r.valid=!!r.valid&&!!n.valid,r.complete=!!r.complete&&!!n.complete,r.empty=!!r.empty&&!!n.empty,r.error=r.error||n.error,r.errorCode=r.errorCode||n.errorCode,r),{valid:!0,complete:!0,empty:!0}):this.state=this.createFieldDefaultState(),this.stateChangeHandlers.forEach(r=>r(this.state))}createFieldDefaultState(){return{empty:!0,complete:!1,valid:!1}}getCardDataValidationError(){if(!this.state.complete)return new Error(this.state.error??"Card data is not complete");if(!this.state.valid)return new Error(`Card data is not valid. ${this.state.error}`)}}const D=new Map;function E(t,e){const r=D.get(t);return r?e.secureValue(r):null}function M(t,e){const r=D.get(t);return e instanceof te&&r?E(t,e)??void 0:e}class vt{constructor(e="https://api.hellgate.io",r=new AbortController){Object.defineProperty(this,"abortCtrl",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"baseUrl",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.baseUrl=e.endsWith("/")?e.substring(0,e.length-1):e}getSession(e){return fetch(`${this.baseUrl}/sessions/${e}`,{signal:this.abortCtrl.signal}).then(r=>W(r))}completeAction(e,r){return fetch(`${this.baseUrl}/sessions/${e}/complete-action`,{method:"POST",headers:{"Content-Type":"application/json"},mode:"cors",body:JSON.stringify(r),signal:this.abortCtrl.signal}).then(n=>W(n))}cancelAll(){this.abortCtrl.abort()}}const Ot=2e3;class Ht{constructor(e,r){Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"api",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"state",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"stateChangeHandlers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"onCloseHandlers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"pollingTimer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"init",{enumerable:!0,configurable:!0,writable:!0,value:async()=>new Promise((n,i)=>{const a=this.onStateChange(s=>{s.next_action!=="wait"&&(n(s),a())});this.updateSessionState().catch(s=>{s instanceof Response&&s.status===404&&i(new Error(`Session ${this.id} doesn't exist or has expired`)),i(s)})})}),Object.defineProperty(this,"onStateChange",{enumerable:!0,configurable:!0,writable:!0,value:n=>(this.stateChangeHandlers.push(n),this.state&&n(this.state),()=>this.stateChangeHandlers=this.stateChangeHandlers.filter(i=>i!==n))}),Object.defineProperty(this,"onClose",{enumerable:!0,configurable:!0,writable:!0,value:n=>{var i;return((i=this.state)==null?void 0:i.next_action)===null?(n(re(this.state)),()=>{}):(this.onCloseHandlers.push(n),()=>this.onCloseHandlers=this.onCloseHandlers.filter(a=>a!==n))}}),Object.defineProperty(this,"completeAction",{enumerable:!0,configurable:!0,writable:!0,value:async n=>{const i=this.state;return new Promise((a,s)=>{const o=this.onStateChange(c=>{c.next_action!==(i==null?void 0:i.next_action)&&c.next_action===null&&(a(re(c)),o())});this.api.completeAction(this.id,n).then(c=>this.newStateHandle(c,s)).catch(async c=>s(await xt(c)))})}}),Object.defineProperty(this,"completeSession",{enumerable:!0,configurable:!0,writable:!0,value:n=>{this.onCloseHandlers.forEach(i=>i(n)),this.stop()}}),Object.defineProperty(this,"dispose",{enumerable:!0,configurable:!0,writable:!0,value:()=>{this.stop(),this.api.cancelAll()}})}isNextAction(e){var r;return((r=this.state)==null?void 0:r.next_action)===e}stop(){window.clearTimeout(this.pollingTimer),this.stateChangeHandlers=[],this.onCloseHandlers=[]}async updateSessionState(e){const r=await this.api.getSession(this.id);this.newStateHandle(r,e)}newStateHandle(e,r){var n;switch(!e.next_action&&e.status&&(e.next_action=null),e.next_action){case"wait":{window.clearTimeout(this.pollingTimer),this.pollingTimer=window.setTimeout(()=>this.updateSessionState(r).catch(i=>{i instanceof Response&&i.status===404&&(r==null||r(new Error(`Session ${this.id} has expired`)))}),Ot);break}}e.next_action!==((n=this.state)==null?void 0:n.next_action)&&this.stateChangeHandlers.forEach(i=>i(e)),e.next_action===null&&this.completeSession(re(e)),this.state=e}}async function xt(t){return!t.ok&&t.status>=400&&t.status<=500?t.json():t}function re(t){const e={...t};return delete e.next_action,e}const Kt={base_url:"https://api.hellgate.io"};class ne{constructor(e,r){Object.defineProperty(this,"session",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"paymentFlowHandlers",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"dispose",{enumerable:!0,configurable:!0,writable:!0,value:()=>{this.session.dispose(),Object.values(this.paymentFlowHandlers).forEach(n=>n==null?void 0:n.dispose())}}),Object.defineProperty(this,"onSessionComplete",{enumerable:!0,configurable:!0,writable:!0,value:n=>{this.session.onClose(n)}})}use(e){return this.paymentFlowHandlers[e]}static async init(e,r={}){const{session:n,cardHandler:i,handler3DS:a}=await this.initHandlers(e,r);return new ne(n,{CARD:i,"3DS":a})}static async initHandlers(e,r){const n={...Kt,...r},i=new vt(n.base_url,n.abortCtrl),a=new Ht(e,i);await a.init();const s=a.isNextAction("tokenize_card")||a.isNextAction("refresh_security_code")?await this.createCardHandler(a):void 0,o=this.create3DSHandler(a,r);return{session:a,cardHandler:s,handler3DS:o}}static createCardHandler(e){return $.init(e)}static create3DSHandler(e,r){return new ie(e,{domContainer:r.challenge_3ds_container,labelText:r.challenge_3ds_label_text})}}p.CardElement=Ke,p.CardExpirationDateElement=Oe,p.CardNumberElement=xe,p.CardVerificationCodeElement=Te,p.Hellgate=ne,p.Hellgate3DSHandler=ie,p.HellgateCardHandler=$,p.TextElement=te,p.createElement=O,p.extractCardNumberValue=ee,p.extractExpiryDateValue=Z,p.putCardNumberValue=He,p.putExpiryDateValue=Q,p.uid=De,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})});globalThis.HellgateSDK&&(globalThis.Hellgate=globalThis.HellgateSDK.Hellgate,delete globalThis.HellgateSDK);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SessionStateDTO } from '../typings';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const sessionGuardianTokenizeCardActionStateDTOMock: SessionStateDTO;
|
|
3
3
|
export declare const sessionWaitActionStateDTOMock: SessionStateDTO;
|
|
4
4
|
export declare const sessionPendingResultStateDTOMock: SessionStateDTO;
|
|
5
5
|
export declare const sessionSuccessResultStateDTOMock: SessionStateDTO;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@starfish-codes/hellgate",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.9.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Starfish GmbH & Co. KG",
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"tailwindcss": "^3.4.1",
|
|
74
74
|
"tailwindcss-animate": "^1.0.7",
|
|
75
75
|
"typescript": "^5.4.2",
|
|
76
|
-
"vite": "^6.
|
|
76
|
+
"vite": "^6.4.1",
|
|
77
77
|
"vite-plugin-checker": "^0.9.3",
|
|
78
78
|
"vite-plugin-svg-icons-ng": "^1.4.0",
|
|
79
79
|
"vite-plugin-top-level-await": "^1.5.0",
|
|
@@ -82,7 +82,6 @@
|
|
|
82
82
|
"webdriverio": "^9.12.7"
|
|
83
83
|
},
|
|
84
84
|
"dependencies": {
|
|
85
|
-
"@basis-theory/basis-theory-js": "^1.79.2",
|
|
86
85
|
"credit-card-type": "^10.0.0",
|
|
87
86
|
"fast-luhn": "^2.0.2",
|
|
88
87
|
"imask": "^7.5.0",
|