@starfish-codes/hellgate 3.6.0 → 3.8.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/ui/typings.d.ts +1 -0
- package/dist/hellgate-sdk.mjs +3940 -3793
- package/dist/hellgate-sdk.umd.js +6 -6
- package/dist/hellgate.d.ts +2 -1
- package/package.json +17 -13
package/dist/hellgate-sdk.umd.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
(function(v,ae){typeof exports=="object"&&typeof module<"u"?ae(exports):typeof define=="function"&&define.amd?define(["exports"],ae):(v=typeof globalThis<"u"?globalThis:v||self,ae(v.HellgateSDK={}))})(this,function(v){"use strict";function ae(e){return Array.isArray(e)?e.filter(Boolean):Object.fromEntries(Object.entries(e).map(([t,r])=>[t,typeof r=="object"&&r&&!Array.isArray(r)?ae(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},n=Object.keys(r);for(const s of n){const i=e[s],a=t[s];typeof i=="object"&&!Array.isArray(i)&&i&&typeof a=="object"&&!Array.isArray(a)&&a&&(r[s]=oe(i,a))}return r}function bt(e){if(!e.ok)throw e;return e.json()}const os=2e3;class hr{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: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 s,i;switch(n.next_action){case"3ds_check":{this.initCheck3DSIframes(n.data.threeds_server_callback_url,n.data.mon_url);break}case"3ds_challenge":{(s=this.onStartHandler)==null||s.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(),(i=this.onFinishHandler)==null||i.call(this);break}}}}),this.domContainer=r.domContainer??_t(),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 n=_t();n.insertAdjacentHTML("beforeend",`<iframe id="check_3ds_${this.iframeId}" width="0" height="0" style="border:0;visibility: hidden;" src="${t}"></iframe>`);const s=n.querySelector(`#check_3ds_${this.iframeId}`);if(s){const i=a=>{a.source===s.contentWindow&&this.session.completeAction({action:"3ds_check",result:a.data})};window.addEventListener("message",i),this.check3dsIframeDisposers.push(()=>window.removeEventListener("message",i),()=>s.remove())}if(r){n.insertAdjacentHTML("beforeend",`<iframe id="mon_${this.iframeId}" width="0" height="0" style="border:0;visibility: hidden;" src="${r}"></iframe>`);const i=n.querySelector(`#mon_${this.iframeId}`);i&&this.disposers.push(()=>i.remove())}}disposeCheck3DSIframe(){this.check3dsIframeDisposers.forEach(t=>t()),this.check3dsIframeDisposers=[]}startChallenge(t,r){const n=_t(),s=`<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="${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===n?`<div id="cha_${this.iframeId}_wrap" style="background: #fff; position: fixed; left: 0; top: 0; width: 100%; height: 100%; z-index: 10000;">${s}</div>`:s);const i=this.domContainer.querySelector(`#cha_${this.iframeId}`),a=this.domContainer.querySelector(`#cha_${this.iframeId}_wrap`);if(!i)throw new Error("3DS Challenge Iframe initialization failed");this.disposers.push(()=>{i.remove(),a==null||a.remove()});const o=new Promise(u=>{const l=f=>{f.source!==i.contentWindow||f.data.event!=="AuthResultReady"||u(f.data)};window.addEventListener("message",l),this.disposers.push(()=>window.removeEventListener("message",l))}),d=new Promise(u=>{const l=this.startAuthResultPolling(r,f=>{f.event==="AuthResultReady"&&(l(),u({requestor_trans_id:f.threeDSRequestorTransID,event:f.event}))})});Promise.any([o,d]).then(u=>{this.session.completeAction({action:"3ds_challenge",result:u})})}startDecoupledAuth(t,r,n){this.transactionId||(this.transactionId=n),this.decoupledAuthHandlers.forEach(i=>i(t));const s=this.startAuthResultPolling(r,i=>{i.event==="AuthResultReady"&&(this.session.completeAction({action:"3ds_challenge_decoupled",result:{...i,event:i.event}}),s())})}startAuthResultPolling(t,r){return window.clearTimeout(this.resultPollingTimer),this.resultPollingTimer=window.setTimeout(()=>fetch(t).then(n=>bt(n)).then(n=>{this.startAuthResultPolling(t,r),r(n)}).catch(()=>{}),os),()=>window.clearTimeout(this.resultPollingTimer)}}function _t(){return document.body}var cs=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function us(e){if(e.__esModule)return e;var t=e.default;if(typeof t=="function"){var r=function n(){return this instanceof n?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(n){var s=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(r,n,s.get?s:{enumerable:!0,get:function(){return e[n]}})}),r}var pr={},ve={},ce={};Object.defineProperty(ce,"__esModule",{value:!0}),ce.makeRequestWithoutElementsPayloadCheck=ce.makeRequestWithElementsPayloadCheck=void 0;function ls(e){function t(){var r=Reflect.construct(e,Array.from(arguments));return Object.setPrototypeOf(r,Object.getPrototypeOf(this)),r}return t.prototype=Object.create(e.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e,t}class mr extends ls(Error){constructor(t){super(t),this.name="NoElementsError"}}const ds=(e,t,r,n,s={})=>{if(e!=null&&e.hasElement(n))return e.client[t](r,n,s);let i="Elements not initialized.";throw e&&(i="Element not found in payload."),new mr(`${i} Use a regular HTTP client if no elements are needed.`)};ce.makeRequestWithElementsPayloadCheck=ds;const fs=(e,t,r,n={})=>{if(e)return e.client[t](r,n);throw new mr("Elements not initialized. Use a regular HTTP client if no elements are needed.")};ce.makeRequestWithoutElementsPayloadCheck=fs;var Er={},Ce={},D={},_={};Object.defineProperty(_,"__esModule",{value:!0}),_.USER_AGENT_HEADER=_.USER_AGENT_CLIENT=_.MERGE_CONTENT_TYPE=_.DEFAULT_ELEMENTS_BASE_URL=_.DEFAULT_BASE_URL=_.CONTENT_TYPE_HEADER=_.CLIENT_USER_AGENT_HEADER=_.CLIENT_BASE_PATHS=_.BT_TRANSACTION_ID_HEADER=_.BT_TRACE_ID_HEADER=_.BT_IDEMPOTENCY_KEY_HEADER=_.BT_EXPOSE_PROXY_RESPONSE_HEADER=_.BROWSER_LIST=_.API_KEY_HEADER=void 0;const hs="BT-API-KEY";_.API_KEY_HEADER=hs;const ps="bt-trace-id";_.BT_TRACE_ID_HEADER=ps;const ms="bt-idempotency-key";_.BT_IDEMPOTENCY_KEY_HEADER=ms;const Es="BT-EXPOSE-RAW-PROXY-RESPONSE";_.BT_EXPOSE_PROXY_RESPONSE_HEADER=Es;const ys="BT-TRANSACTION-ID";_.BT_TRANSACTION_ID_HEADER=ys;const bs="Content-Type";_.CONTENT_TYPE_HEADER=bs;const _s="application/merge-patch+json";_.MERGE_CONTENT_TYPE=_s;const gs="User-Agent";_.USER_AGENT_HEADER=gs;const ws="BT-CLIENT-USER-AGENT";_.CLIENT_USER_AGENT_HEADER=ws;const Ss="BasisTheoryJS";_.USER_AGENT_CLIENT=Ss;const Ts="https://api.basistheory.com";_.DEFAULT_BASE_URL=Ts;const Rs="https://js.basistheory.com/hosted-elements";_.DEFAULT_ELEMENTS_BASE_URL=Rs;const As={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"};_.CLIENT_BASE_PATHS=As;const vs=[{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"}];_.BROWSER_LIST=vs;var m={};/*! Axios v1.8.2 Copyright (c) 2025 Matt Zabriskie and contributors */function yr(e,t){return function(){return e.apply(t,arguments)}}const{toString:Cs}=Object.prototype,{getPrototypeOf:gt}=Object,Oe=(e=>t=>{const r=Cs.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),M=e=>(e=e.toLowerCase(),t=>Oe(t)===e),Pe=e=>t=>typeof t===e,{isArray:ue}=Array,Ee=Pe("undefined");function Os(e){return e!==null&&!Ee(e)&&e.constructor!==null&&!Ee(e.constructor)&&U(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const br=M("ArrayBuffer");function Ps(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&br(e.buffer),t}const Bs=Pe("string"),U=Pe("function"),_r=Pe("number"),Be=e=>e!==null&&typeof e=="object",xs=e=>e===!0||e===!1,xe=e=>{if(Oe(e)!=="object")return!1;const t=gt(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},Ns=M("Date"),js=M("File"),Ds=M("Blob"),Us=M("FileList"),Hs=e=>Be(e)&&U(e.pipe),Ls=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||U(e.append)&&((t=Oe(e))==="formdata"||t==="object"&&U(e.toString)&&e.toString()==="[object FormData]"))},Ms=M("URLSearchParams"),[Is,$s,qs,Ks]=["ReadableStream","Request","Response","Headers"].map(M),Fs=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function ye(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let n,s;if(typeof e!="object"&&(e=[e]),ue(e))for(n=0,s=e.length;n<s;n++)t.call(null,e[n],n,e);else{const i=r?Object.getOwnPropertyNames(e):Object.keys(e),a=i.length;let o;for(n=0;n<a;n++)o=i[n],t.call(null,e[o],o,e)}}function gr(e,t){t=t.toLowerCase();const r=Object.keys(e);let n=r.length,s;for(;n-- >0;)if(s=r[n],t===s.toLowerCase())return s;return null}const Q=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:cs,wr=e=>!Ee(e)&&e!==Q;function wt(){const{caseless:e}=wr(this)&&this||{},t={},r=(n,s)=>{const i=e&&gr(t,s)||s;xe(t[i])&&xe(n)?t[i]=wt(t[i],n):xe(n)?t[i]=wt({},n):ue(n)?t[i]=n.slice():t[i]=n};for(let n=0,s=arguments.length;n<s;n++)arguments[n]&&ye(arguments[n],r);return t}const zs=(e,t,r,{allOwnKeys:n}={})=>(ye(t,(s,i)=>{r&&U(s)?e[i]=yr(s,r):e[i]=s},{allOwnKeys:n}),e),Ws=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),ks=(e,t,r,n)=>{e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},Vs=(e,t,r,n)=>{let s,i,a;const o={};if(t=t||{},e==null)return t;do{for(s=Object.getOwnPropertyNames(e),i=s.length;i-- >0;)a=s[i],(!n||n(a,e,t))&&!o[a]&&(t[a]=e[a],o[a]=!0);e=r!==!1&>(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},Gs=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;const n=e.indexOf(t,r);return n!==-1&&n===r},Js=e=>{if(!e)return null;if(ue(e))return e;let t=e.length;if(!_r(t))return null;const r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},Xs=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&>(Uint8Array)),Ys=(e,t)=>{const n=(e&&e[Symbol.iterator]).call(e);let s;for(;(s=n.next())&&!s.done;){const i=s.value;t.call(e,i[0],i[1])}},Zs=(e,t)=>{let r;const n=[];for(;(r=e.exec(t))!==null;)n.push(r);return n},Qs=M("HTMLFormElement"),ei=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,n,s){return n.toUpperCase()+s}),Sr=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),ti=M("RegExp"),Tr=(e,t)=>{const r=Object.getOwnPropertyDescriptors(e),n={};ye(r,(s,i)=>{let a;(a=t(s,i,e))!==!1&&(n[i]=a||s)}),Object.defineProperties(e,n)},ri=e=>{Tr(e,(t,r)=>{if(U(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;const n=e[r];if(U(n)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},ni=(e,t)=>{const r={},n=s=>{s.forEach(i=>{r[i]=!0})};return ue(e)?n(e):n(String(e).split(t)),r},si=()=>{},ii=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function ai(e){return!!(e&&U(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator])}const oi=e=>{const t=new Array(10),r=(n,s)=>{if(Be(n)){if(t.indexOf(n)>=0)return;if(!("toJSON"in n)){t[s]=n;const i=ue(n)?[]:{};return ye(n,(a,o)=>{const d=r(a,s+1);!Ee(d)&&(i[o]=d)}),t[s]=void 0,i}}return n};return r(e,0)},ci=M("AsyncFunction"),ui=e=>e&&(Be(e)||U(e))&&U(e.then)&&U(e.catch),Rr=((e,t)=>e?setImmediate:t?((r,n)=>(Q.addEventListener("message",({source:s,data:i})=>{s===Q&&i===r&&n.length&&n.shift()()},!1),s=>{n.push(s),Q.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",U(Q.postMessage)),li=typeof queueMicrotask<"u"?queueMicrotask.bind(Q):typeof process<"u"&&process.nextTick||Rr;var c={isArray:ue,isArrayBuffer:br,isBuffer:Os,isFormData:Ls,isArrayBufferView:Ps,isString:Bs,isNumber:_r,isBoolean:xs,isObject:Be,isPlainObject:xe,isReadableStream:Is,isRequest:$s,isResponse:qs,isHeaders:Ks,isUndefined:Ee,isDate:Ns,isFile:js,isBlob:Ds,isRegExp:ti,isFunction:U,isStream:Hs,isURLSearchParams:Ms,isTypedArray:Xs,isFileList:Us,forEach:ye,merge:wt,extend:zs,trim:Fs,stripBOM:Ws,inherits:ks,toFlatObject:Vs,kindOf:Oe,kindOfTest:M,endsWith:Gs,toArray:Js,forEachEntry:Ys,matchAll:Zs,isHTMLForm:Qs,hasOwnProperty:Sr,hasOwnProp:Sr,reduceDescriptors:Tr,freezeMethods:ri,toObjectSet:ni,toCamelCase:ei,noop:si,toFiniteNumber:ii,findKey:gr,global:Q,isContextDefined:wr,isSpecCompliantForm:ai,toJSONObject:oi,isAsyncFn:ci,isThenable:ui,setImmediate:Rr,asap:li};function y(e,t,r,n,s){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),n&&(this.request=n),s&&(this.response=s,this.status=s.status?s.status:null)}c.inherits(y,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:c.toJSONObject(this.config),code:this.code,status:this.status}}});const Ar=y.prototype,vr={};["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(e=>{vr[e]={value:e}}),Object.defineProperties(y,vr),Object.defineProperty(Ar,"isAxiosError",{value:!0}),y.from=(e,t,r,n,s,i)=>{const a=Object.create(Ar);return c.toFlatObject(e,a,function(d){return d!==Error.prototype},o=>o!=="isAxiosError"),y.call(a,e.message,t,r,n,s),a.cause=e,a.name=e.name,i&&Object.assign(a,i),a};var di=null;function St(e){return c.isPlainObject(e)||c.isArray(e)}function Cr(e){return c.endsWith(e,"[]")?e.slice(0,-2):e}function Or(e,t,r){return e?e.concat(t).map(function(s,i){return s=Cr(s),!r&&i?"["+s+"]":s}).join(r?".":""):t}function fi(e){return c.isArray(e)&&!e.some(St)}const hi=c.toFlatObject(c,{},null,function(t){return/^is[A-Z]/.test(t)});function Ne(e,t,r){if(!c.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,r=c.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(E,p){return!c.isUndefined(p[E])});const n=r.metaTokens,s=r.visitor||l,i=r.dots,a=r.indexes,d=(r.Blob||typeof Blob<"u"&&Blob)&&c.isSpecCompliantForm(t);if(!c.isFunction(s))throw new TypeError("visitor must be a function");function u(h){if(h===null)return"";if(c.isDate(h))return h.toISOString();if(!d&&c.isBlob(h))throw new y("Blob is not supported. Use a Buffer instead.");return c.isArrayBuffer(h)||c.isTypedArray(h)?d&&typeof Blob=="function"?new Blob([h]):Buffer.from(h):h}function l(h,E,p){let S=h;if(h&&!p&&typeof h=="object"){if(c.endsWith(E,"{}"))E=n?E:E.slice(0,-2),h=JSON.stringify(h);else if(c.isArray(h)&&fi(h)||(c.isFileList(h)||c.endsWith(E,"[]"))&&(S=c.toArray(h)))return E=Cr(E),S.forEach(function(O,G){!(c.isUndefined(O)||O===null)&&t.append(a===!0?Or([E],G,i):a===null?E:E+"[]",u(O))}),!1}return St(h)?!0:(t.append(Or(p,E,i),u(h)),!1)}const f=[],b=Object.assign(hi,{defaultVisitor:l,convertValue:u,isVisitable:St});function w(h,E){if(!c.isUndefined(h)){if(f.indexOf(h)!==-1)throw Error("Circular reference detected in "+E.join("."));f.push(h),c.forEach(h,function(S,C){(!(c.isUndefined(S)||S===null)&&s.call(t,S,c.isString(C)?C.trim():C,E,b))===!0&&w(S,E?E.concat(C):[C])}),f.pop()}}if(!c.isObject(e))throw new TypeError("data must be an object");return w(e),t}function Pr(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(n){return t[n]})}function Tt(e,t){this._pairs=[],e&&Ne(e,this,t)}const Br=Tt.prototype;Br.append=function(t,r){this._pairs.push([t,r])},Br.toString=function(t){const r=t?function(n){return t.call(this,n,Pr)}:Pr;return this._pairs.map(function(s){return r(s[0])+"="+r(s[1])},"").join("&")};function pi(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function xr(e,t,r){if(!t)return e;const n=r&&r.encode||pi;c.isFunction(r)&&(r={serialize:r});const s=r&&r.serialize;let i;if(s?i=s(t,r):i=c.isURLSearchParams(t)?t.toString():new Tt(t,r).toString(n),i){const a=e.indexOf("#");a!==-1&&(e=e.slice(0,a)),e+=(e.indexOf("?")===-1?"?":"&")+i}return e}class mi{constructor(){this.handlers=[]}use(t,r,n){return this.handlers.push({fulfilled:t,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){c.forEach(this.handlers,function(n){n!==null&&t(n)})}}var Nr=mi,jr={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Ei=typeof URLSearchParams<"u"?URLSearchParams:Tt,yi=typeof FormData<"u"?FormData:null,bi=typeof Blob<"u"?Blob:null,_i={isBrowser:!0,classes:{URLSearchParams:Ei,FormData:yi,Blob:bi},protocols:["http","https","file","blob","url","data"]};const Rt=typeof window<"u"&&typeof document<"u",At=typeof navigator=="object"&&navigator||void 0,gi=Rt&&(!At||["ReactNative","NativeScript","NS"].indexOf(At.product)<0),wi=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Si=Rt&&window.location.href||"http://localhost";var Ti=Object.freeze({__proto__:null,hasBrowserEnv:Rt,hasStandardBrowserWebWorkerEnv:wi,hasStandardBrowserEnv:gi,navigator:At,origin:Si}),B={...Ti,..._i};function Ri(e,t){return Ne(e,new B.classes.URLSearchParams,Object.assign({visitor:function(r,n,s,i){return B.isNode&&c.isBuffer(r)?(this.append(n,r.toString("base64")),!1):i.defaultVisitor.apply(this,arguments)}},t))}function Ai(e){return c.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function vi(e){const t={},r=Object.keys(e);let n;const s=r.length;let i;for(n=0;n<s;n++)i=r[n],t[i]=e[i];return t}function Dr(e){function t(r,n,s,i){let a=r[i++];if(a==="__proto__")return!0;const o=Number.isFinite(+a),d=i>=r.length;return a=!a&&c.isArray(s)?s.length:a,d?(c.hasOwnProp(s,a)?s[a]=[s[a],n]:s[a]=n,!o):((!s[a]||!c.isObject(s[a]))&&(s[a]=[]),t(r,n,s[a],i)&&c.isArray(s[a])&&(s[a]=vi(s[a])),!o)}if(c.isFormData(e)&&c.isFunction(e.entries)){const r={};return c.forEachEntry(e,(n,s)=>{t(Ai(n),s,r,0)}),r}return null}function Ci(e,t,r){if(c.isString(e))try{return(t||JSON.parse)(e),c.trim(e)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(e)}const vt={transitional:jr,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){const n=r.getContentType()||"",s=n.indexOf("application/json")>-1,i=c.isObject(t);if(i&&c.isHTMLForm(t)&&(t=new FormData(t)),c.isFormData(t))return s?JSON.stringify(Dr(t)):t;if(c.isArrayBuffer(t)||c.isBuffer(t)||c.isStream(t)||c.isFile(t)||c.isBlob(t)||c.isReadableStream(t))return t;if(c.isArrayBufferView(t))return t.buffer;if(c.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let o;if(i){if(n.indexOf("application/x-www-form-urlencoded")>-1)return Ri(t,this.formSerializer).toString();if((o=c.isFileList(t))||n.indexOf("multipart/form-data")>-1){const d=this.env&&this.env.FormData;return Ne(o?{"files[]":t}:t,d&&new d,this.formSerializer)}}return i||s?(r.setContentType("application/json",!1),Ci(t)):t}],transformResponse:[function(t){const r=this.transitional||vt.transitional,n=r&&r.forcedJSONParsing,s=this.responseType==="json";if(c.isResponse(t)||c.isReadableStream(t))return t;if(t&&c.isString(t)&&(n&&!this.responseType||s)){const a=!(r&&r.silentJSONParsing)&&s;try{return JSON.parse(t)}catch(o){if(a)throw o.name==="SyntaxError"?y.from(o,y.ERR_BAD_RESPONSE,this,null,this.response):o}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:B.classes.FormData,Blob:B.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};c.forEach(["delete","get","head","post","put","patch"],e=>{vt.headers[e]={}});var Ct=vt;const Oi=c.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 Pi=e=>{const t={};let r,n,s;return e&&e.split(`
|
|
2
|
-
`).forEach(function(
|
|
3
|
-
`)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...r){const n=new this(t);return r.forEach(s=>n.set(s)),n}static accessor(t){const n=(this[Ur]=this[Ur]={accessors:{}}).accessors,s=this.prototype;function i(a){const o=be(a);n[o]||(ji(s,a),n[o]=!0)}return c.isArray(t)?t.forEach(i):i(t),this}}De.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),c.reduceDescriptors(De.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(n){this[r]=n}}}),c.freezeMethods(De);var I=De;function Pt(e,t){const r=this||Ct,n=t||r,s=I.from(n.headers);let i=n.data;return c.forEach(e,function(o){i=o.call(r,i,s.normalize(),t?t.status:void 0)}),s.normalize(),i}function Hr(e){return!!(e&&e.__CANCEL__)}function le(e,t,r){y.call(this,e??"canceled",y.ERR_CANCELED,t,r),this.name="CanceledError"}c.inherits(le,y,{__CANCEL__:!0});function Lr(e,t,r){const n=r.config.validateStatus;!r.status||!n||n(r.status)?e(r):t(new y("Request failed with status code "+r.status,[y.ERR_BAD_REQUEST,y.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function Di(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Ui(e,t){e=e||10;const r=new Array(e),n=new Array(e);let s=0,i=0,a;return t=t!==void 0?t:1e3,function(d){const u=Date.now(),l=n[i];a||(a=u),r[s]=d,n[s]=u;let f=i,b=0;for(;f!==s;)b+=r[f++],f=f%e;if(s=(s+1)%e,s===i&&(i=(i+1)%e),u-a<t)return;const w=l&&u-l;return w?Math.round(b*1e3/w):void 0}}function Hi(e,t){let r=0,n=1e3/t,s,i;const a=(u,l=Date.now())=>{r=l,s=null,i&&(clearTimeout(i),i=null),e.apply(null,u)};return[(...u)=>{const l=Date.now(),f=l-r;f>=n?a(u,l):(s=u,i||(i=setTimeout(()=>{i=null,a(s)},n-f)))},()=>s&&a(s)]}const Ue=(e,t,r=3)=>{let n=0;const s=Ui(50,250);return Hi(i=>{const a=i.loaded,o=i.lengthComputable?i.total:void 0,d=a-n,u=s(d),l=a<=o;n=a;const f={loaded:a,total:o,progress:o?a/o:void 0,bytes:d,rate:u||void 0,estimated:u&&o&&l?(o-a)/u:void 0,event:i,lengthComputable:o!=null,[t?"download":"upload"]:!0};e(f)},r)},Mr=(e,t)=>{const r=e!=null;return[n=>t[0]({lengthComputable:r,total:e,loaded:n}),t[1]]},Ir=e=>(...t)=>c.asap(()=>e(...t));var Li=B.hasStandardBrowserEnv?((e,t)=>r=>(r=new URL(r,B.origin),e.protocol===r.protocol&&e.host===r.host&&(t||e.port===r.port)))(new URL(B.origin),B.navigator&&/(msie|trident)/i.test(B.navigator.userAgent)):()=>!0,Mi=B.hasStandardBrowserEnv?{write(e,t,r,n,s,i){const a=[e+"="+encodeURIComponent(t)];c.isNumber(r)&&a.push("expires="+new Date(r).toGMTString()),c.isString(n)&&a.push("path="+n),c.isString(s)&&a.push("domain="+s),i===!0&&a.push("secure"),document.cookie=a.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function Ii(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function $i(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function $r(e,t,r){let n=!Ii(t);return e&&n||r==!1?$i(e,t):t}const qr=e=>e instanceof I?{...e}:e;function ee(e,t){t=t||{};const r={};function n(u,l,f,b){return c.isPlainObject(u)&&c.isPlainObject(l)?c.merge.call({caseless:b},u,l):c.isPlainObject(l)?c.merge({},l):c.isArray(l)?l.slice():l}function s(u,l,f,b){if(c.isUndefined(l)){if(!c.isUndefined(u))return n(void 0,u,f,b)}else return n(u,l,f,b)}function i(u,l){if(!c.isUndefined(l))return n(void 0,l)}function a(u,l){if(c.isUndefined(l)){if(!c.isUndefined(u))return n(void 0,u)}else return n(void 0,l)}function o(u,l,f){if(f in t)return n(u,l);if(f in e)return n(void 0,u)}const d={url:i,method:i,data:i,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,withXSRFToken:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,beforeRedirect:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:o,headers:(u,l,f)=>s(qr(u),qr(l),f,!0)};return c.forEach(Object.keys(Object.assign({},e,t)),function(l){const f=d[l]||s,b=f(e[l],t[l],l);c.isUndefined(b)&&f!==o||(r[l]=b)}),r}var Kr=e=>{const t=ee({},e);let{data:r,withXSRFToken:n,xsrfHeaderName:s,xsrfCookieName:i,headers:a,auth:o}=t;t.headers=a=I.from(a),t.url=xr($r(t.baseURL,t.url),e.params,e.paramsSerializer),o&&a.set("Authorization","Basic "+btoa((o.username||"")+":"+(o.password?unescape(encodeURIComponent(o.password)):"")));let d;if(c.isFormData(r)){if(B.hasStandardBrowserEnv||B.hasStandardBrowserWebWorkerEnv)a.setContentType(void 0);else if((d=a.getContentType())!==!1){const[u,...l]=d?d.split(";").map(f=>f.trim()).filter(Boolean):[];a.setContentType([u||"multipart/form-data",...l].join("; "))}}if(B.hasStandardBrowserEnv&&(n&&c.isFunction(n)&&(n=n(t)),n||n!==!1&&Li(t.url))){const u=s&&i&&Mi.read(i);u&&a.set(s,u)}return t},qi=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(r,n){const s=Kr(e);let i=s.data;const a=I.from(s.headers).normalize();let{responseType:o,onUploadProgress:d,onDownloadProgress:u}=s,l,f,b,w,h;function E(){w&&w(),h&&h(),s.cancelToken&&s.cancelToken.unsubscribe(l),s.signal&&s.signal.removeEventListener("abort",l)}let p=new XMLHttpRequest;p.open(s.method.toUpperCase(),s.url,!0),p.timeout=s.timeout;function S(){if(!p)return;const O=I.from("getAllResponseHeaders"in p&&p.getAllResponseHeaders()),j={data:!o||o==="text"||o==="json"?p.responseText:p.response,status:p.status,statusText:p.statusText,headers:O,config:e,request:p};Lr(function(ie){r(ie),E()},function(ie){n(ie),E()},j),p=null}"onloadend"in p?p.onloadend=S:p.onreadystatechange=function(){!p||p.readyState!==4||p.status===0&&!(p.responseURL&&p.responseURL.indexOf("file:")===0)||setTimeout(S)},p.onabort=function(){p&&(n(new y("Request aborted",y.ECONNABORTED,e,p)),p=null)},p.onerror=function(){n(new y("Network Error",y.ERR_NETWORK,e,p)),p=null},p.ontimeout=function(){let G=s.timeout?"timeout of "+s.timeout+"ms exceeded":"timeout exceeded";const j=s.transitional||jr;s.timeoutErrorMessage&&(G=s.timeoutErrorMessage),n(new y(G,j.clarifyTimeoutError?y.ETIMEDOUT:y.ECONNABORTED,e,p)),p=null},i===void 0&&a.setContentType(null),"setRequestHeader"in p&&c.forEach(a.toJSON(),function(G,j){p.setRequestHeader(j,G)}),c.isUndefined(s.withCredentials)||(p.withCredentials=!!s.withCredentials),o&&o!=="json"&&(p.responseType=s.responseType),u&&([b,h]=Ue(u,!0),p.addEventListener("progress",b)),d&&p.upload&&([f,w]=Ue(d),p.upload.addEventListener("progress",f),p.upload.addEventListener("loadend",w)),(s.cancelToken||s.signal)&&(l=O=>{p&&(n(!O||O.type?new le(null,e,p):O),p.abort(),p=null)},s.cancelToken&&s.cancelToken.subscribe(l),s.signal&&(s.signal.aborted?l():s.signal.addEventListener("abort",l)));const C=Di(s.url);if(C&&B.protocols.indexOf(C)===-1){n(new y("Unsupported protocol "+C+":",y.ERR_BAD_REQUEST,e));return}p.send(i||null)})},Ki=(e,t)=>{const{length:r}=e=e?e.filter(Boolean):[];if(t||r){let n=new AbortController,s;const i=function(u){if(!s){s=!0,o();const l=u instanceof Error?u:this.reason;n.abort(l instanceof y?l:new le(l instanceof Error?l.message:l))}};let a=t&&setTimeout(()=>{a=null,i(new y(`timeout ${t} of ms exceeded`,y.ETIMEDOUT))},t);const o=()=>{e&&(a&&clearTimeout(a),a=null,e.forEach(u=>{u.unsubscribe?u.unsubscribe(i):u.removeEventListener("abort",i)}),e=null)};e.forEach(u=>u.addEventListener("abort",i));const{signal:d}=n;return d.unsubscribe=()=>c.asap(o),d}};const Fi=function*(e,t){let r=e.byteLength;if(r<t){yield e;return}let n=0,s;for(;n<r;)s=n+t,yield e.slice(n,s),n=s},zi=async function*(e,t){for await(const r of Wi(e))yield*Fi(r,t)},Wi=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:r,value:n}=await t.read();if(r)break;yield n}}finally{await t.cancel()}},Fr=(e,t,r,n)=>{const s=zi(e,t);let i=0,a,o=d=>{a||(a=!0,n&&n(d))};return new ReadableStream({async pull(d){try{const{done:u,value:l}=await s.next();if(u){o(),d.close();return}let f=l.byteLength;if(r){let b=i+=f;r(b)}d.enqueue(new Uint8Array(l))}catch(u){throw o(u),u}},cancel(d){return o(d),s.return()}},{highWaterMark:2})},He=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",zr=He&&typeof ReadableStream=="function",ki=He&&(typeof TextEncoder=="function"?(e=>t=>e.encode(t))(new TextEncoder):async e=>new Uint8Array(await new Response(e).arrayBuffer())),Wr=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Vi=zr&&Wr(()=>{let e=!1;const t=new Request(B.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),kr=64*1024,Bt=zr&&Wr(()=>c.isReadableStream(new Response("").body)),Le={stream:Bt&&(e=>e.body)};He&&(e=>{["text","arrayBuffer","blob","formData","stream"].forEach(t=>{!Le[t]&&(Le[t]=c.isFunction(e[t])?r=>r[t]():(r,n)=>{throw new y(`Response type '${t}' is not supported`,y.ERR_NOT_SUPPORT,n)})})})(new Response);const Gi=async e=>{if(e==null)return 0;if(c.isBlob(e))return e.size;if(c.isSpecCompliantForm(e))return(await new Request(B.origin,{method:"POST",body:e}).arrayBuffer()).byteLength;if(c.isArrayBufferView(e)||c.isArrayBuffer(e))return e.byteLength;if(c.isURLSearchParams(e)&&(e=e+""),c.isString(e))return(await ki(e)).byteLength},Ji=async(e,t)=>{const r=c.toFiniteNumber(e.getContentLength());return r??Gi(t)};var Xi=He&&(async e=>{let{url:t,method:r,data:n,signal:s,cancelToken:i,timeout:a,onDownloadProgress:o,onUploadProgress:d,responseType:u,headers:l,withCredentials:f="same-origin",fetchOptions:b}=Kr(e);u=u?(u+"").toLowerCase():"text";let w=Ki([s,i&&i.toAbortSignal()],a),h;const E=w&&w.unsubscribe&&(()=>{w.unsubscribe()});let p;try{if(d&&Vi&&r!=="get"&&r!=="head"&&(p=await Ji(l,n))!==0){let j=new Request(t,{method:"POST",body:n,duplex:"half"}),Z;if(c.isFormData(n)&&(Z=j.headers.get("content-type"))&&l.setContentType(Z),j.body){const[ie,yt]=Mr(p,Ue(Ir(d)));n=Fr(j.body,kr,ie,yt)}}c.isString(f)||(f=f?"include":"omit");const S="credentials"in Request.prototype;h=new Request(t,{...b,signal:w,method:r.toUpperCase(),headers:l.normalize().toJSON(),body:n,duplex:"half",credentials:S?f:void 0});let C=await fetch(h);const O=Bt&&(u==="stream"||u==="response");if(Bt&&(o||O&&E)){const j={};["status","statusText","headers"].forEach(as=>{j[as]=C[as]});const Z=c.toFiniteNumber(C.headers.get("content-length")),[ie,yt]=o&&Mr(Z,Ue(Ir(o),!0))||[];C=new Response(Fr(C.body,kr,ie,()=>{yt&&yt(),E&&E()}),j)}u=u||"text";let G=await Le[c.findKey(Le,u)||"text"](C,e);return!O&&E&&E(),await new Promise((j,Z)=>{Lr(j,Z,{data:G,headers:I.from(C.headers),status:C.status,statusText:C.statusText,config:e,request:h})})}catch(S){throw E&&E(),S&&S.name==="TypeError"&&/fetch/i.test(S.message)?Object.assign(new y("Network Error",y.ERR_NETWORK,e,h),{cause:S.cause||S}):y.from(S,S&&S.code,e,h)}});const xt={http:di,xhr:qi,fetch:Xi};c.forEach(xt,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Vr=e=>`- ${e}`,Yi=e=>c.isFunction(e)||e===null||e===!1;var Gr={getAdapter:e=>{e=c.isArray(e)?e:[e];const{length:t}=e;let r,n;const s={};for(let i=0;i<t;i++){r=e[i];let a;if(n=r,!Yi(r)&&(n=xt[(a=String(r)).toLowerCase()],n===void 0))throw new y(`Unknown adapter '${a}'`);if(n)break;s[a||"#"+i]=n}if(!n){const i=Object.entries(s).map(([o,d])=>`adapter ${o} `+(d===!1?"is not supported by the environment":"is not available in the build"));let a=t?i.length>1?`since :
|
|
4
|
-
`+
|
|
5
|
-
`):" "+
|
|
6
|
-
`+i):n.stack=i}catch{}}throw n}}_request(t,r){typeof t=="string"?(r=r||{},r.url=t):r=t||{},r=ee(this.defaults,r);const{transitional:n,paramsSerializer:s,headers:i}=r;n!==void 0&&Ie.assertOptions(n,{silentJSONParsing:q.transitional(q.boolean),forcedJSONParsing:q.transitional(q.boolean),clarifyTimeoutError:q.transitional(q.boolean)},!1),s!=null&&(c.isFunction(s)?r.paramsSerializer={serialize:s}:Ie.assertOptions(s,{encode:q.function,serialize:q.function},!0)),r.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?r.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:r.allowAbsoluteUrls=!0),Ie.assertOptions(r,{baseUrl:q.spelling("baseURL"),withXsrfToken:q.spelling("withXSRFToken")},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let a=i&&c.merge(i.common,i[r.method]);i&&c.forEach(["delete","get","head","post","put","patch","common"],h=>{delete i[h]}),r.headers=I.concat(a,i);const o=[];let d=!0;this.interceptors.request.forEach(function(E){typeof E.runWhen=="function"&&E.runWhen(r)===!1||(d=d&&E.synchronous,o.unshift(E.fulfilled,E.rejected))});const u=[];this.interceptors.response.forEach(function(E){u.push(E.fulfilled,E.rejected)});let l,f=0,b;if(!d){const h=[Jr.bind(this),void 0];for(h.unshift.apply(h,o),h.push.apply(h,u),b=h.length,l=Promise.resolve(r);f<b;)l=l.then(h[f++],h[f++]);return l}b=o.length;let w=r;for(f=0;f<b;){const h=o[f++],E=o[f++];try{w=h(w)}catch(p){E.call(this,p);break}}try{l=Jr.call(this,w)}catch(h){return Promise.reject(h)}for(f=0,b=u.length;f<b;)l=l.then(u[f++],u[f++]);return l}getUri(t){t=ee(this.defaults,t);const r=$r(t.baseURL,t.url,t.allowAbsoluteUrls);return xr(r,t.params,t.paramsSerializer)}}c.forEach(["delete","get","head","options"],function(t){$e.prototype[t]=function(r,n){return this.request(ee(n||{},{method:t,url:r,data:(n||{}).data}))}}),c.forEach(["post","put","patch"],function(t){function r(n){return function(i,a,o){return this.request(ee(o||{},{method:t,headers:n?{"Content-Type":"multipart/form-data"}:{},url:i,data:a}))}}$e.prototype[t]=r(),$e.prototype[t+"Form"]=r(!0)});var qe=$e;class jt{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(i){r=i});const n=this;this.promise.then(s=>{if(!n._listeners)return;let i=n._listeners.length;for(;i-- >0;)n._listeners[i](s);n._listeners=null}),this.promise.then=s=>{let i;const a=new Promise(o=>{n.subscribe(o),i=o}).then(s);return a.cancel=function(){n.unsubscribe(i)},a},t(function(i,a,o){n.reason||(n.reason=new le(i,a,o),r(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const r=this._listeners.indexOf(t);r!==-1&&this._listeners.splice(r,1)}toAbortSignal(){const t=new AbortController,r=n=>{t.abort(n)};return this.subscribe(r),t.signal.unsubscribe=()=>this.unsubscribe(r),t.signal}static source(){let t;return{token:new jt(function(s){t=s}),cancel:t}}}var Qi=jt;function ea(e){return function(r){return e.apply(null,r)}}function ta(e){return c.isObject(e)&&e.isAxiosError===!0}const Dt={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(Dt).forEach(([e,t])=>{Dt[t]=e});var ra=Dt;function Zr(e){const t=new qe(e),r=yr(qe.prototype.request,t);return c.extend(r,qe.prototype,t,{allOwnKeys:!0}),c.extend(r,t,null,{allOwnKeys:!0}),r.create=function(s){return Zr(ee(e,s))},r}const A=Zr(Ct);A.Axios=qe,A.CanceledError=le,A.CancelToken=Qi,A.isCancel=Hr,A.VERSION=Xr,A.toFormData=Ne,A.AxiosError=y,A.Cancel=A.CanceledError,A.all=function(t){return Promise.all(t)},A.spread=ea,A.isAxiosError=ta,A.mergeConfig=ee,A.AxiosHeaders=I,A.formToJSON=e=>Dr(c.isHTMLForm(e)?new FormData(e):e),A.getAdapter=Gr.getAdapter,A.HttpStatusCode=ra,A.default=A;var Qr=A,Ut={exports:{}};const en=e=>typeof e=="object"&&e!==null,tn=Symbol("skip"),rn=e=>en(e)&&!(e instanceof RegExp)&&!(e instanceof Error)&&!(e instanceof Date),Ht=(e,t,r,n=new WeakMap)=>{if(r={deep:!1,target:{},...r},n.has(e))return n.get(e);n.set(e,r.target);const{target:s}=r;delete r.target;const i=a=>a.map(o=>rn(o)?Ht(o,t,r,n):o);if(Array.isArray(e))return i(e);for(const[a,o]of Object.entries(e)){const d=t(a,o,e);if(d===tn)continue;let[u,l,{shouldRecurse:f=!0}={}]=d;u!=="__proto__"&&(r.deep&&f&&rn(l)&&(l=Array.isArray(l)?i(l):Ht(l,t,r,n)),s[u]=l)}return s};Ut.exports=(e,t,r)=>{if(!en(e))throw new TypeError(`Expected an object, got \`${e}\` (${typeof e})`);return Ht(e,t,r)},Ut.exports.mapObjectSkip=tn;var nn=Ut.exports,Lt={exports:{}};const na=e=>{let t=!1,r=!1,n=!1;for(let s=0;s<e.length;s++){const i=e[s];t&&/[a-zA-Z]/.test(i)&&i.toUpperCase()===i?(e=e.slice(0,s)+"-"+e.slice(s),t=!1,n=r,r=!0,s++):r&&n&&/[a-zA-Z]/.test(i)&&i.toLowerCase()===i?(e=e.slice(0,s-1)+"-"+e.slice(s-1),n=r,r=!1,t=!0):(t=i.toLowerCase()===i&&i.toUpperCase()!==i,n=r,r=i.toUpperCase()===i&&i.toLowerCase()!==i)}return e},sn=(e,t)=>{if(!(typeof e=="string"||Array.isArray(e)))throw new TypeError("Expected the input to be `string | string[]`");t=Object.assign({pascalCase:!1},t);const r=s=>t.pascalCase?s.charAt(0).toUpperCase()+s.slice(1):s;return Array.isArray(e)?e=e.map(s=>s.trim()).filter(s=>s.length).join("-"):e=e.trim(),e.length===0?"":e.length===1?t.pascalCase?e.toUpperCase():e.toLowerCase():(e!==e.toLowerCase()&&(e=na(e)),e=e.replace(/^[_.\- ]+/,"").toLowerCase().replace(/[_.\- ]+(\w|$)/g,(s,i)=>i.toUpperCase()).replace(/\d+(\w|$)/g,s=>s.toUpperCase()),r(e))};Lt.exports=sn,Lt.exports.default=sn;var sa=Lt.exports;class ia{constructor(t={}){if(!(t.maxSize&&t.maxSize>0))throw new TypeError("`maxSize` must be a number greater than 0");this.maxSize=t.maxSize,this.cache=new Map,this.oldCache=new Map,this._size=0}_set(t,r){this.cache.set(t,r),this._size++,this._size>=this.maxSize&&(this._size=0,this.oldCache=this.cache,this.cache=new Map)}get(t){if(this.cache.has(t))return this.cache.get(t);if(this.oldCache.has(t)){const r=this.oldCache.get(t);return this.oldCache.delete(t),this._set(t,r),r}}set(t,r){return this.cache.has(t)?this.cache.set(t,r):this._set(t,r),this}has(t){return this.cache.has(t)||this.oldCache.has(t)}peek(t){if(this.cache.has(t))return this.cache.get(t);if(this.oldCache.has(t))return this.oldCache.get(t)}delete(t){const r=this.cache.delete(t);return r&&this._size--,this.oldCache.delete(t)||r}clear(){this.cache.clear(),this.oldCache.clear(),this._size=0}*keys(){for(const[t]of this)yield t}*values(){for(const[,t]of this)yield t}*[Symbol.iterator](){for(const t of this.cache)yield t;for(const t of this.oldCache){const[r]=t;this.cache.has(r)||(yield t)}}get size(){let t=0;for(const r of this.oldCache.keys())this.cache.has(r)||t++;return this._size+t}}var aa=ia;const an=nn,oa=sa,ca=aa,ua=(e,t)=>e.some(r=>typeof r=="string"?r===t:(r.lastIndex=0,r.test(t))),Mt=new ca({maxSize:1e5}),on=e=>typeof e=="object"&&e!==null&&!(e instanceof RegExp)&&!(e instanceof Error)&&!(e instanceof Date),cn=(e,t)=>{if(!on(e))return e;t={deep:!1,pascalCase:!1,...t};const{exclude:r,pascalCase:n,stopPaths:s,deep:i}=t,a=new Set(s),o=d=>(u,l)=>{if(i&&on(l)){const f=d===void 0?u:`${d}.${u}`;a.has(f)||(l=an(l,o(f)))}if(!(r&&ua(r,u))){const f=n?`${u}_`:u;if(Mt.has(f))u=Mt.get(f);else{const b=oa(u,{pascalCase:n});u.length<100&&Mt.set(f,b),u=b}}return[u,l]};return an(e,o(void 0))};var la=(e,t)=>Array.isArray(e)?Object.keys(e).map(r=>cn(e[r],t)):cn(e,t),It,un;function ln(){return un||(un=1,It=ln()),It}var Ke=function(){return Ke=Object.assign||function(t){for(var r,n=1,s=arguments.length;n<s;n++){r=arguments[n];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])}return t},Ke.apply(this,arguments)};typeof SuppressedError=="function"&&SuppressedError;function da(e){return e.toLowerCase()}var fa=[/([a-z0-9])([A-Z])/g,/([A-Z])([A-Z][a-z])/g],ha=/[^A-Z0-9]+/gi;function pa(e,t){t===void 0&&(t={});for(var r=t.splitRegexp,n=r===void 0?fa:r,s=t.stripRegexp,i=s===void 0?ha:s,a=t.transform,o=a===void 0?da:a,d=t.delimiter,u=d===void 0?" ":d,l=dn(dn(e,n,"$1\0$2"),i,"\0"),f=0,b=l.length;l.charAt(f)==="\0";)f++;for(;l.charAt(b-1)==="\0";)b--;return l.slice(f,b).split("\0").map(o).join(u)}function dn(e,t,r){return t instanceof RegExp?e.replace(t,r):t.reduce(function(n,s){return n.replace(s,r)},e)}function ma(e,t){return t===void 0&&(t={}),pa(e,Ke({delimiter:"."},t))}function Ea(e,t){return t===void 0&&(t={}),ma(e,Ke({delimiter:"_"},t))}const ya=us(Object.freeze(Object.defineProperty({__proto__:null,snakeCase:Ea},Symbol.toStringTag,{value:"Module"})));var ba=Sa,_a=/\s/,ga=/(_|-|\.|:)/,wa=/([a-z][A-Z]|[A-Z][a-z])/;function Sa(e){return _a.test(e)?e.toLowerCase():ga.test(e)?(Ra(e)||e).toLowerCase():wa.test(e)?va(e).toLowerCase():e.toLowerCase()}var Ta=/[\W_]+(.|$)/g;function Ra(e){return e.replace(Ta,function(t,r){return r?" "+r:""})}var Aa=/(.)([A-Z]+)/g;function va(e){return e.replace(Aa,function(t,r,n){return r+" "+n.toLowerCase().split("").join(" ")})}var Ca=ba,Oa=Pa;function Pa(e){return Ca(e).replace(/[\W_]+(.|$)/g,function(t,r){return r?" "+r:""}).trim()}var Ba=Oa,xa=Na;function Na(e){return Ba(e).replace(/\s/g,"_")}const ja=nn,Da=xa;var Ua=function(e,t){return t=Object.assign({deep:!0,exclude:[]},t),ja(e,function(r,n){return[Ha(t.exclude,r)?r:Da(r),n]},t)};function Ha(e,t){return e.some(function(r){return typeof r=="string"?r===t:r.test(t)})}var _e={};Object.defineProperty(_e,"__esModule",{value:!0}),_e.BasisTheoryApiError=void 0;function La(e){function t(){var r=Reflect.construct(e,Array.from(arguments));return Object.setPrototypeOf(r,Object.getPrototypeOf(this)),r}return t.prototype=Object.create(e.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e,t}class $t extends La(Error){constructor(t,r,n){super(t),this.status=r,this.data=n,this.name="BasisTheoryApiError",Object.setPrototypeOf(this,$t.prototype)}}_e.BasisTheoryApiError=$t,Object.defineProperty(m,"__esModule",{value:!0}),m.transformTokenResponseCamelCase=m.transformTokenRequestSnakeCase=m.transformResponseCamelCase=m.transformRequestSnakeCase=m.transformReactorResponseCamelCase=m.transformReactorRequestSnakeCase=m.transformProxyResponseCamelCase=m.transformProxyRequestSnakeCase=m.proxyRaw=m.getRuntime=m.getQueryParams=m.getOSVersion=m.getBrowser=m.errorInterceptor=m.dataExtractor=m.dataAndHeadersExtractor=m.createRequestConfig=m.concatResponseTransformerWithDefault=m.concatRequestTransformerWithDefault=m.buildUserAgentString=m.buildClientUserAgentString=m.assertInit=void 0;var fn=Fe(Qr),K=Fe(la),hn=Fe(ln()),Ma=ya,ge=Fe(Ua),Ia=_e,te=_;function Fe(e){return e&&e.__esModule?e:{default:e}}const $a=e=>{if(e==null)throw new Error("BasisTheory has not yet been properly initialized.");return e};m.assertInit=$a;const qa=e=>{if(!(typeof e>"u"))return(0,ge.default)(e,{deep:!0})};m.transformRequestSnakeCase=qa;const Ka=e=>e;m.proxyRaw=Ka;const Fa=e=>{if(!(typeof e>"u"))return{...(0,ge.default)(e,{deep:!0}),...e.configuration!==void 0?{configuration:e.configuration}:{}}};m.transformReactorRequestSnakeCase=Fa;const za=e=>{if(!(typeof e>"u"))return{...(0,ge.default)(e,{deep:!0}),...e.configuration!==void 0?{configuration:e.configuration}:{}}};m.transformProxyRequestSnakeCase=za;const Wa=e=>{if(!(typeof e>"u"))return{...(0,ge.default)(e,{deep:!0}),...e.data!==void 0?{data:e.data}:{},...e.metadata!==void 0?{metadata:e.metadata}:{}}};m.transformTokenRequestSnakeCase=Wa;const qt=e=>e&&(e==null?void 0:e.pagination)!==void 0&&(e==null?void 0:e.data)!==void 0,ka=e=>{if(!(typeof e>"u"))return qt(e)?{data:e.data.map(n=>({...(0,K.default)(n,{deep:!0}),...n.data!==void 0?{data:n.data}:{},...n.metadata!==void 0?{metadata:n.metadata}:{}})),pagination:(0,K.default)(e.pagination,{deep:!0})}:{...(0,K.default)(e,{deep:!0}),...e.data!==void 0?{data:e.data}:{},...e.metadata!==void 0?{metadata:e.metadata}:{}}};m.transformTokenResponseCamelCase=ka;const Va=e=>{if(!(typeof e>"u"))return qt(e)?{data:e.data.map(n=>({...(0,K.default)(n,{deep:!0}),...n.configuration!==void 0?{configuration:n.configuration}:{}})),pagination:(0,K.default)(e.pagination,{deep:!0})}:{...(0,K.default)(e,{deep:!0}),...e.configuration!==void 0?{configuration:e.configuration}:{}}};m.transformReactorResponseCamelCase=Va;const Ga=e=>{if(!(typeof e>"u"))return qt(e)?{data:e.data.map(n=>({...(0,K.default)(n,{deep:!0}),...n.configuration!==void 0?{configuration:n.configuration}:{}})),pagination:(0,K.default)(e.pagination,{deep:!0})}:{...(0,K.default)(e,{deep:!0}),...e.configuration!==void 0?{configuration:e.configuration}:{}}};m.transformProxyResponseCamelCase=Ga;const Ja=e=>{if(!(typeof e>"u"))return(0,K.default)(e,{deep:!0})};m.transformResponseCamelCase=Ja;const Xa=e=>e==null?void 0:e.data;m.dataExtractor=Xa;const Ya=e=>({data:e==null?void 0:e.data,headers:e==null?void 0:e.headers});m.dataAndHeadersExtractor=Ya;const Kt=e=>[e,...fn.default.defaults.transformRequest];m.concatRequestTransformerWithDefault=Kt;const Ft=e=>[...fn.default.defaults.transformResponse,e];m.concatResponseTransformerWithDefault=Ft;const Za=(e,t)=>{if(!e)return t?{...t.transformRequest!==void 0?{transformRequest:Kt(t.transformRequest)}:{},...t.transformResponse!==void 0?{transformResponse:Ft(t.transformResponse)}:{}}:void 0;const{apiKey:r,correlationId:n,idempotencyKey:s,transactionId:i,query:a,headers:o}=e,d=r?{[te.API_KEY_HEADER]:r}:{},u=n?{[te.BT_TRACE_ID_HEADER]:n}:{},l=s?{[te.BT_IDEMPOTENCY_KEY_HEADER]:s}:{},f=i?{[te.BT_TRANSACTION_ID_HEADER]:i}:{};return{headers:{...d,...u,...l,...f,...typeof o<"u"&&{...o}},...typeof a<"u"&&{params:a},...(t==null?void 0:t.transformRequest)!==void 0?{transformRequest:Kt(t.transformRequest)}:{},...(t==null?void 0:t.transformResponse)!==void 0?{transformResponse:Ft(t.transformResponse)}:{}}};m.createRequestConfig=Za;const Qa=e=>{var t,r;const n=((t=e.response)===null||t===void 0?void 0:t.status)||-1,s=(r=e.response)===null||r===void 0?void 0:r.data;throw new Ia.BasisTheoryApiError(e.message,n,s)};m.errorInterceptor=Qa;const eo=(e={})=>{const t=Object.keys(e);if(t.length){const r=new URLSearchParams,n=(s,i,a=!1)=>{const o=typeof i,d=a?s:(0,Ma.snakeCase)(s);(i===null||["boolean","number","string"].includes(o))&&r.append(d,i)};return t.forEach(s=>{const i=e[s];Array.isArray(i)?i.forEach(a=>{n(String(s),a)}):i&&typeof i=="object"?Object.keys(i).forEach(o=>{n(`${String(s)}.${o}`,i[o],!0)}):n(String(s),i)}),`?${r.toString()}`}return""};m.getQueryParams=eo;const to=e=>`(${e.name||""}; ${e.version||""}; ${e.url||""})`,ro=e=>{let t=`${te.USER_AGENT_CLIENT}/unknown`;return e&&Object.keys(e||{}).length&&(t+=` ${to(e)}`),t};m.buildUserAgentString=ro;const pn=()=>{const{userAgent:e}=window.navigator;let t="unknown";const r=te.BROWSER_LIST.find(n=>e.includes(n.browserUA));if(r)try{t=e.split(`${r.browserUA}/`)[1]}catch{t="unknown"}return`${(r==null?void 0:r.browserName)||"unknown"}/${t}`};m.getBrowser=pn;const mn=()=>typeof window=="object"&&window.navigator.product==="ReactNative",En=()=>{if(mn())return"ReactNative";if(typeof window>"u")try{return`${hn.default.type()}/${hn.default.version()}`}catch{return"unknown"}try{const t=window.navigator.appVersion.match(/\(([^)]+)\)/u);return t&&t.length>1?t[1]:"unknown"}catch{return"unknown"}};m.getOSVersion=En;const yn=()=>mn()?"ReactNative":typeof window>"u"?`NodeJS/${process.version}`:pn();m.getRuntime=yn;const no=e=>{const t={client:te.USER_AGENT_CLIENT,clientVersion:"unknown",osVersion:En(),runtimeVersion:yn(),application:{}};return e&&(t.application=e),JSON.stringify((0,ge.default)(t))};m.buildClientUserAgentString=no;var ze={};Object.defineProperty(ze,"__esModule",{value:!0}),ze.BasisTheoryValidationError=void 0;function so(e){function t(){var r=Reflect.construct(e,Array.from(arguments));return Object.setPrototypeOf(r,Object.getPrototypeOf(this)),r}return t.prototype=Object.create(e.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e,t}class zt extends so(Error){constructor(t,r,n){super(t),this.details=r,this.validation=n,this.name="BasisTheoryValidationError",Object.setPrototypeOf(this,zt.prototype)}}ze.BasisTheoryValidationError=zt;var We={};Object.defineProperty(We,"__esModule",{value:!0}),We.HttpClientError=void 0;function io(e){function t(){var r=Reflect.construct(e,Array.from(arguments));return Object.setPrototypeOf(r,Object.getPrototypeOf(this)),r}return t.prototype=Object.create(e.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e,t}class Wt extends io(Error){constructor(t,r,n,s){super(t),this.name="HttpClientError",this.status=r,this.data=n,this.headers=s,Object.setPrototypeOf(this,Wt.prototype)}}We.HttpClientError=Wt,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 s.BasisTheoryApiError}}),Object.defineProperty(e,"BasisTheoryValidationError",{enumerable:!0,get:function(){return i.BasisTheoryValidationError}}),Object.defineProperty(e,"HttpClientError",{enumerable:!0,get:function(){return a.HttpClientError}});var r=_;Object.keys(r).forEach(function(o){o==="default"||o==="__esModule"||Object.prototype.hasOwnProperty.call(t,o)||o in e&&e[o]===r[o]||Object.defineProperty(e,o,{enumerable:!0,get:function(){return r[o]}})});var n=m;Object.keys(n).forEach(function(o){o==="default"||o==="__esModule"||Object.prototype.hasOwnProperty.call(t,o)||o in e&&e[o]===n[o]||Object.defineProperty(e,o,{enumerable:!0,get:function(){return n[o]}})});var s=_e,i=ze,a=We}(D);var H={},ao={},ke={};Object.defineProperty(ke,"__esModule",{value:!0}),ke.BasisTheoryService=void 0;var Ve=oo(Qr),J=D;function oo(e){return e&&e.__esModule?e:{default:e}}class co{constructor(t){const{apiKey:r,baseURL:n,transformRequest:s,transformResponse:i,appInfo:a}=t;if(typeof Ve.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=Ve.default.create({baseURL:n,headers:{[J.API_KEY_HEADER]:r,[J.CLIENT_USER_AGENT_HEADER]:(0,J.buildClientUserAgentString)(a),...typeof window>"u"&&{[J.USER_AGENT_HEADER]:(0,J.buildUserAgentString)(a)}},transformRequest:[].concat(s||J.transformRequestSnakeCase,Ve.default.defaults.transformRequest),transformResponse:Ve.default.defaults.transformResponse.concat(i||J.transformResponseCamelCase)}),this.client.interceptors.response.use(void 0,J.errorInterceptor)}}ke.BasisTheoryService=co,function(e){Object.defineProperty(e,"__esModule",{value:!0});var t=ao;Object.keys(t).forEach(function(n){n==="default"||n==="__esModule"||n in e&&e[n]===t[n]||Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[n]}})});var r=ke;Object.keys(r).forEach(function(n){n==="default"||n==="__esModule"||n in e&&e[n]===r[n]||Object.defineProperty(e,n,{enumerable:!0,get:function(){return r[n]}})})}(H),Object.defineProperty(Ce,"__esModule",{value:!0}),Ce.BasisTheoryTransactions=void 0;var kt=D,we=m,uo=H;class lo extends uo.BasisTheoryService{constructor(t){const r={...t};r.transformRequest=[].concat(we.transformProxyRequestSnakeCase,t.transformRequest||[]),r.transformResponse=[].concat(we.transformProxyResponseCamelCase,t.transformResponse||[]),super(r)}create(t={}){return this.client.post("/",void 0,(0,kt.createRequestConfig)(t)).then(we.dataExtractor)}commit(t,r={}){const n=`/${t}/commit`;return this.client.post(n,void 0,(0,kt.createRequestConfig)(r)).then(we.dataExtractor)}rollback(t,r={}){const n=`/${t}/rollback`;return this.client.post(n,void 0,(0,kt.createRequestConfig)(r)).then(we.dataExtractor)}}Ce.BasisTheoryTransactions=lo,function(e){Object.defineProperty(e,"__esModule",{value:!0});var t=Ce;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]}})})}(Er);var Vt={},Ge={},F={};Object.defineProperty(F,"__esModule",{value:!0}),F.CrudBuilder=void 0;var x=D;const fo=e=>class extends e{create(r,n){return this.client.post("/",r,(0,x.createRequestConfig)(n)).then(x.dataExtractor)}},ho=e=>class extends e{retrieve(r,n){return this.client.get(r,(0,x.createRequestConfig)(n)).then(x.dataExtractor)}},po=e=>class extends e{update(r,n,s){return this.client.put(r,n,(0,x.createRequestConfig)(s)).then(x.dataExtractor)}},mo=e=>class extends e{patch(r,n,s){const i=(0,x.createRequestConfig)(s);return this.client.patch(r,n,{...i,headers:{...(i==null?void 0:i.headers)||{},[x.CONTENT_TYPE_HEADER]:x.MERGE_CONTENT_TYPE}}).then(x.dataExtractor)}},Eo=e=>class extends e{async delete(r,n){await this.client.delete(r,(0,x.createRequestConfig)(n))}},yo=e=>class extends e{list(r={},n={}){const s=`/${(0,x.getQueryParams)(r)}`;return this.client.get(s,(0,x.createRequestConfig)(n)).then(x.dataExtractor)}};class bo{constructor(t){this.BaseService=t}create(){return this.BaseService=fo(this.BaseService),this}retrieve(){return this.BaseService=ho(this.BaseService),this}update(){return this.BaseService=po(this.BaseService),this}patch(){return this.BaseService=mo(this.BaseService),this}delete(){return this.BaseService=Eo(this.BaseService),this}list(){return this.BaseService=yo(this.BaseService),this}build(){return this.BaseService}}F.CrudBuilder=bo,Object.defineProperty(Ge,"__esModule",{value:!0}),Ge.BasisTheoryApplications=void 0;var Je=D,_o=H,go=F;const wo=new go.CrudBuilder(class extends _o.BasisTheoryService{getApplicationByKey(){return this.retrieveByKey()}retrieveByKey(t){return this.client.get("/key",(0,Je.createRequestConfig)(t)).then(Je.dataExtractor)}regenerateKey(t,r){return this.client.post(`${t}/regenerate`,void 0,(0,Je.createRequestConfig)(r)).then(Je.dataExtractor)}}).create().retrieve().update().delete().list().build();Ge.BasisTheoryApplications=wo,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"BasisTheoryApplications",{enumerable:!0,get:function(){return t.BasisTheoryApplications}});var t=Ge}(Vt);var bn={},_n={},Xe={},gn={},Ye={};Object.defineProperty(Ye,"__esModule",{value:!0}),Ye.BasisTheoryTokenize=void 0;var Ze=D,So=H;class To extends So.BasisTheoryService{tokenize(t,r={}){return this.client.post("/",t,(0,Ze.createRequestConfig)(r,{transformRequest:Ze.proxyRaw,transformResponse:Ze.proxyRaw})).then(Ze.dataExtractor)}}Ye.BasisTheoryTokenize=To,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"BasisTheoryTokenize",{enumerable:!0,get:function(){return t.BasisTheoryTokenize}});var t=Ye}(gn),Object.defineProperty(Xe,"__esModule",{value:!0}),Xe.delegateTokenize=void 0;var Ro=gn;const Ao=e=>class extends Ro.BasisTheoryTokenize{tokenize(r,n){return e!=null&&e.hasElement(r)?e.tokenize(r,n):super.tokenize(r,n)}};Xe.delegateTokenize=Ao;var Qe={},Gt={},et={};Object.defineProperty(et,"__esModule",{value:!0}),et.BasisTheoryTokens=void 0;var z=D,re=m,vo=H,Co=F;const Oo=new Co.CrudBuilder(class extends vo.BasisTheoryService{constructor(t){const r=t;r.transformRequest=[].concat(re.transformTokenRequestSnakeCase,t.transformRequest||[]),r.transformResponse=[].concat(re.transformTokenResponseCamelCase,t.transformResponse||[]),super(r)}retrieve(t,r={}){const n=`/${t}`;return this.client.get(n,(0,z.createRequestConfig)(r)).then(re.dataExtractor)}update(t,r,n={}){const s=`/${t}`,i=(0,z.createRequestConfig)(n);return this.client.patch(s,r,{...i,headers:{...(i==null?void 0:i.headers)||{},[z.CONTENT_TYPE_HEADER]:z.MERGE_CONTENT_TYPE}}).then(re.dataExtractor)}async createAssociation(t,r,n){const s=`/${t}/children/${r}`;await this.client.post(s,{},(0,z.createRequestConfig)(n))}async deleteAssociation(t,r,n){const s=`/${t}/children/${r}`;await this.client.delete(s,(0,z.createRequestConfig)(n))}createChild(t,r,n){const s=`/${t}/children`;return this.client.post(s,r,(0,z.createRequestConfig)(n)).then(re.dataExtractor)}listChildren(t,r={},n={}){const s=`/${t}/children${(0,z.getQueryParams)(r)}`;return this.client.get(s,(0,z.createRequestConfig)(n)).then(re.dataExtractor)}search(t,r){return this.client.post("/search",t,(0,z.createRequestConfig)(r)).then(re.dataExtractor)}}).create().delete().list().build();et.BasisTheoryTokens=Oo,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"BasisTheoryTokens",{enumerable:!0,get:function(){return t.BasisTheoryTokens}});var t=et}(Gt),Object.defineProperty(Qe,"__esModule",{value:!0}),Qe.delegateTokens=void 0;var Po=Gt;const Bo=e=>class extends Po.BasisTheoryTokens{create(r,n){return e!=null&&e.hasElement(r)?e.tokens.create(r,n):super.create(r,n)}update(r,n,s){return e!=null&&e.hasElement(n)?e.tokens.update(r,n,s):super.update(r,n,s)}retrieve(r,n){return e!==void 0?e.tokens.retrieve(r,n):super.retrieve(r,n)}};Qe.delegateTokens=Bo;var tt={},wn={},rt={};Object.defineProperty(rt,"__esModule",{value:!0}),rt.BasisTheoryProxy=void 0;var V=D,xo=H;class No extends xo.BasisTheoryService{get(t){return this.proxyRequest("get",t)}post(t){return this.proxyRequest("post",t)}put(t){return this.proxyRequest("put",t)}patch(t){return this.proxyRequest("patch",t)}delete(t){return this.proxyRequest("delete",t)}proxyRequest(t,r){var n;if(t==="post"||t==="put"||t==="patch"){var s,i;const a=r!=null&&r.includeResponseHeaders&&t==="post"?V.dataAndHeadersExtractor:V.dataExtractor;return this.client[t]((s=r==null?void 0:r.path)!==null&&s!==void 0?s:"",(i=r==null?void 0:r.body)!==null&&i!==void 0?i:void 0,(0,V.createRequestConfig)(r,{transformRequest:V.proxyRaw,transformResponse:V.proxyRaw})).then(a)}return this.client[t]((n=r==null?void 0:r.path)!==null&&n!==void 0?n:"/",(0,V.createRequestConfig)(r,{transformRequest:V.proxyRaw,transformResponse:V.proxyRaw})).then(V.dataExtractor)}}rt.BasisTheoryProxy=No,function(e){Object.defineProperty(e,"__esModule",{value:!0});var t=rt;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]}})})}(wn),Object.defineProperty(tt,"__esModule",{value:!0}),tt.delegateProxy=void 0;var jo=wn;const Do=e=>class extends jo.BasisTheoryProxy{get(r){return e!==void 0?e.proxy.get(r):super.get(r)}post(r){return e!==void 0?e.proxy.post(r):super.post(r)}put(r){return e!==void 0?e.proxy.put(r):super.put(r)}patch(r){return e!==void 0?e.proxy.patch(r):super.patch(r)}delete(r){return e!==void 0?e.proxy.delete(r):super.delete(r)}};tt.delegateProxy=Do,function(e){Object.defineProperty(e,"__esModule",{value:!0});var t=Xe;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=Qe;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]}})});var n=tt;Object.keys(n).forEach(function(s){s==="default"||s==="__esModule"||s in e&&e[s]===n[s]||Object.defineProperty(e,s,{enumerable:!0,get:function(){return n[s]}})})}(_n);var ne={};Object.defineProperty(ne,"__esModule",{value:!0}),ne.injectScript=ne.findScript=void 0;const Uo=e=>document.querySelector(`script[src^="${e}"]`);ne.findScript=Uo;const Ho=e=>{const t=document.createElement("script");t.src=e;const r=document.head||document.body;if(!r)throw new Error("No <head> or <body> elements found in document.");return r.append(t),t};ne.injectScript=Ho;var nt={},P={};Object.defineProperty(P,"__esModule",{value:!0}),P.ELEMENTS_SCRIPT_UNKNOWN_ERROR_MESSAGE=P.ELEMENTS_SCRIPT_LOAD_ERROR_MESSAGE=P.ELEMENTS_NOM_DOM_ERROR_MESSAGE=P.ELEMENTS_INIT_ERROR_MESSAGE=P.CARD_ICON_POSITIONS=P.CARD_BRANDS=P.AUTOCOMPLETE_VALUES=void 0;const Lo="BasisTheory Elements was not properly initialized.";P.ELEMENTS_INIT_ERROR_MESSAGE=Lo;const Mo="Tried to load BasisTheoryElements in a non-DOM environment.";P.ELEMENTS_NOM_DOM_ERROR_MESSAGE=Mo;const Io="Basis Theory Elements did not load properly.";P.ELEMENTS_SCRIPT_LOAD_ERROR_MESSAGE=Io;const $o="There was an unknown error when loading Basis Theory Elements. Check the console for details.";P.ELEMENTS_SCRIPT_UNKNOWN_ERROR_MESSAGE=$o;const qo=["visa","mastercard","american-express","discover","diners-club","jcb","unionpay","maestro","elo","hiper","hipercard","mir","unknown"];P.CARD_BRANDS=qo;const Ko=["left","right","none"];P.CARD_ICON_POSITIONS=Ko;const Fo=["off","on"];P.AUTOCOMPLETE_VALUES=Fo,Object.defineProperty(nt,"__esModule",{value:!0}),nt.loadElements=void 0;var Jt=P,Sn=ne;let Xt;const zo=e=>(Xt||(Xt=new Promise((t,r)=>{if(typeof window!="object"){r(new Error(Jt.ELEMENTS_NOM_DOM_ERROR_MESSAGE));return}if(window.BasisTheoryElements){t(window.BasisTheoryElements);return}try{let n="https://js.basistheory.com/elements";if(typeof e<"u")try{n=new URL(e).toString().replace(/\/$/u,"")}catch{throw new Error("Invalid format for the given Elements client url.")}let s=(0,Sn.findScript)(n);s||(s=(0,Sn.injectScript)(n)),s.addEventListener("load",()=>{window.BasisTheoryElements?t(window.BasisTheoryElements):r(new Error(Jt.ELEMENTS_SCRIPT_LOAD_ERROR_MESSAGE))}),s.addEventListener("error",i=>{r((i==null?void 0:i.error)||new Error(Jt.ELEMENTS_SCRIPT_UNKNOWN_ERROR_MESSAGE))})}catch(n){r(n);return}})),Xt);nt.loadElements=zo,function(e){Object.defineProperty(e,"__esModule",{value:!0});var t=_n;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=ne;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]}})});var n=nt;Object.keys(n).forEach(function(s){s==="default"||s==="__esModule"||s in e&&e[s]===n[s]||Object.defineProperty(e,s,{enumerable:!0,get:function(){return n[s]}})})}(bn);var Tn={},st={};Object.defineProperty(st,"__esModule",{value:!0}),st.BasisTheoryLogs=void 0;var Wo=H,ko=F;const Vo=new ko.CrudBuilder(class extends Wo.BasisTheoryService{}).list().build();st.BasisTheoryLogs=Vo,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"BasisTheoryLogs",{enumerable:!0,get:function(){return t.BasisTheoryLogs}});var t=st}(Tn);var Rn={},it={};Object.defineProperty(it,"__esModule",{value:!0}),it.BasisTheoryPermissions=void 0;var An=D,Go=H;class Jo extends Go.BasisTheoryService{list(t){return this.client.get("/",(0,An.createRequestConfig)(t)).then(An.dataExtractor)}}it.BasisTheoryPermissions=Jo,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"BasisTheoryPermissions",{enumerable:!0,get:function(){return t.BasisTheoryPermissions}});var t=it}(Rn);var vn={},at={};Object.defineProperty(at,"__esModule",{value:!0}),at.BasisTheoryProxies=void 0;var Cn=m,Xo=H,Yo=F;const Zo=new Yo.CrudBuilder(class extends Xo.BasisTheoryService{constructor(t){const r={...t};r.transformRequest=[].concat(Cn.transformProxyRequestSnakeCase,t.transformRequest||[]),r.transformResponse=[].concat(Cn.transformProxyResponseCamelCase,t.transformResponse||[]),super(r)}}).create().retrieve().update().patch().delete().list().build();at.BasisTheoryProxies=Zo,function(e){Object.defineProperty(e,"__esModule",{value:!0});var t=at;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]}})})}(vn);var On={},ot={};Object.defineProperty(ot,"__esModule",{value:!0}),ot.BasisTheoryReactorFormulas=void 0;var Qo=H,ec=F;const tc=new ec.CrudBuilder(class extends Qo.BasisTheoryService{}).create().retrieve().update().delete().list().build();ot.BasisTheoryReactorFormulas=tc,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"BasisTheoryReactorFormulas",{enumerable:!0,get:function(){return t.BasisTheoryReactorFormulas}});var t=ot}(On);var Pn={},ct={};Object.defineProperty(ct,"__esModule",{value:!0}),ct.BasisTheoryReactors=void 0;var ut=D,Bn=m,rc=H,nc=F;const sc=new nc.CrudBuilder(class extends rc.BasisTheoryService{constructor(t){const r={...t};r.transformRequest=[].concat(Bn.transformReactorRequestSnakeCase,t.transformRequest||[]),r.transformResponse=[].concat(Bn.transformReactorResponseCamelCase,t.transformResponse||[]),super(r)}react(t,r,n){return this.client.post(`/${t}/react`,r,(0,ut.createRequestConfig)(n,{transformRequest:ut.proxyRaw,transformResponse:ut.proxyRaw})).then(ut.dataExtractor)}}).create().retrieve().update().patch().delete().list().build();ct.BasisTheoryReactors=sc,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"BasisTheoryReactors",{enumerable:!0,get:function(){return t.BasisTheoryReactors}});var t=ct}(Pn);var xn={},lt={};Object.defineProperty(lt,"__esModule",{value:!0}),lt.BasisTheorySessions=void 0;var Nn=D,dt=m,ic=H;class ac extends ic.BasisTheoryService{constructor(t){const r={...t};r.transformRequest=[].concat(dt.transformProxyRequestSnakeCase,t.transformRequest||[]),r.transformResponse=[].concat(dt.transformProxyResponseCamelCase,t.transformResponse||[]),super(r)}create(t={}){return this.client.post("/",void 0,(0,Nn.createRequestConfig)(t)).then(dt.dataExtractor)}authorize(t,r={}){return this.client.post("/authorize",t,(0,Nn.createRequestConfig)(r)).then(dt.dataExtractor)}}lt.BasisTheorySessions=ac,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"BasisTheorySessions",{enumerable:!0,get:function(){return t.BasisTheorySessions}});var t=lt}(xn);var jn={},ft={};Object.defineProperty(ft,"__esModule",{value:!0}),ft.BasisTheoryTenants=void 0;var R=D,oc=H,cc=F;const uc=new cc.CrudBuilder(class extends oc.BasisTheoryService{retrieve(t){return this.client.get("/",(0,R.createRequestConfig)(t)).then(R.dataExtractor)}update(t,r){return this.client.put("/",t,(0,R.createRequestConfig)(r)).then(R.dataExtractor)}async delete(t){await this.client.delete("/",(0,R.createRequestConfig)(t))}retrieveUsageReport(t){return this.client.get("/reports/usage",(0,R.createRequestConfig)(t)).then(R.dataExtractor)}createInvitation(t,r){return this.client.post("/invitations",t,(0,R.createRequestConfig)(r)).then(R.dataExtractor)}resendInvitation(t,r){return this.client.post(`/invitations/${t}/resend`,{},(0,R.createRequestConfig)(r)).then(R.dataExtractor)}listInvitations(t,r){const n=`/invitations${(0,R.getQueryParams)(t)}`;return this.client.get(n,(0,R.createRequestConfig)(r)).then(R.dataExtractor)}retrieveInvitation(t,r){return this.client.get(`/invitations/${t}`,(0,R.createRequestConfig)(r)).then(R.dataExtractor)}async deleteInvitation(t,r){await this.client.delete(`/invitations/${t}`,(0,R.createRequestConfig)(r))}listMembers(t,r){const n=`/members${(0,R.getQueryParams)(t)}`;return this.client.get(n,(0,R.createRequestConfig)(r)).then(R.dataExtractor)}async deleteMember(t,r){await this.client.delete(`/members/${t}`,(0,R.createRequestConfig)(r))}}).build();ft.BasisTheoryTenants=uc,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"BasisTheoryTenants",{enumerable:!0,get:function(){return t.BasisTheoryTenants}});var t=ft}(jn),Object.defineProperty(ve,"__esModule",{value:!0}),ve.BasisTheory=void 0;var Se=ce,lc=Er,dc=Vt,g=D,ht=bn,fc=P,hc=Tn,pc=Rn,mc=vn,Ec=On,yc=Pn,bc=xn,_c=jn;function gc(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const wc={apiBaseUrl:g.DEFAULT_BASE_URL,elements:!1,appInfo:{}};class Sc{constructor(){gc(this,"_initStatus","not-started")}async init(t,r={}){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({...wc,...r});let n=this._initOptions.apiBaseUrl;try{const i=new URL(this.initOptions.apiBaseUrl);i.hostname==="localhost"?i.protocol="http":i.protocol="https",n=i.toString().replace(/\/$/u,"")}catch{throw new Error("Invalid format for the given API base url.")}const s=this._initOptions.appInfo;this._initOptions.elements&&await this.loadElements(t),this._tokens=new((0,ht.delegateTokens)(this._elements))({apiKey:t,baseURL:new URL(g.CLIENT_BASE_PATHS.tokens,n).toString(),appInfo:s}),this._tokenize=new((0,ht.delegateTokenize)(this._elements))({apiKey:t,baseURL:new URL(g.CLIENT_BASE_PATHS.tokenize,n).toString(),appInfo:s}),this._applications=new dc.BasisTheoryApplications({apiKey:t,baseURL:new URL(g.CLIENT_BASE_PATHS.applications,n).toString(),appInfo:s}),this._tenants=new _c.BasisTheoryTenants({apiKey:t,baseURL:new URL(g.CLIENT_BASE_PATHS.tenants,n).toString(),appInfo:s}),this._logs=new hc.BasisTheoryLogs({apiKey:t,baseURL:new URL(g.CLIENT_BASE_PATHS.logs,n).toString(),appInfo:s}),this._reactorFormulas=new Ec.BasisTheoryReactorFormulas({apiKey:t,baseURL:new URL(g.CLIENT_BASE_PATHS.reactorFormulas,n).toString(),appInfo:s}),this._reactors=new yc.BasisTheoryReactors({apiKey:t,baseURL:new URL(g.CLIENT_BASE_PATHS.reactors,n).toString(),appInfo:s}),this._permissions=new pc.BasisTheoryPermissions({apiKey:t,baseURL:new URL(g.CLIENT_BASE_PATHS.permissions,n).toString(),appInfo:s}),this._proxies=new mc.BasisTheoryProxies({apiKey:t,baseURL:new URL(g.CLIENT_BASE_PATHS.proxies,n).toString(),appInfo:s}),this._proxy=new((0,ht.delegateProxy)(this._elements))({apiKey:t,baseURL:new URL(g.CLIENT_BASE_PATHS.proxy,n).toString(),appInfo:s}),this._sessions=new bc.BasisTheorySessions({apiKey:t,baseURL:new URL(g.CLIENT_BASE_PATHS.sessions,n).toString(),appInfo:s}),this._transactions=new lc.BasisTheoryTransactions({apiKey:t,baseURL:new URL(g.CLIENT_BASE_PATHS.transactions,n).toString(),appInfo:s}),this._initStatus="done"}catch(n){throw this._initStatus="error",n}return this}createElement(t,r){if(!this._elements)throw new Error(fc.ELEMENTS_INIT_ERROR_MESSAGE);return this._elements.createElement(t,r)}tokenize(t,r){return(0,g.assertInit)(this._tokenize).tokenize(t,r)}post(t,r,n){return(0,Se.makeRequestWithElementsPayloadCheck)(this._elements,"post",t,r,n)}put(t,r,n){return(0,Se.makeRequestWithElementsPayloadCheck)(this._elements,"put",t,r,n)}patch(t,r,n){return(0,Se.makeRequestWithElementsPayloadCheck)(this._elements,"patch",t,r,n)}get(t,r){return(0,Se.makeRequestWithoutElementsPayloadCheck)(this._elements,"get",t,r)}delete(t,r){return(0,Se.makeRequestWithoutElementsPayloadCheck)(this._elements,"delete",t,r)}async loadElements(t){let r;try{r=new URL(this.initOptions.elementsBaseUrl||g.DEFAULT_ELEMENTS_BASE_URL)}catch{throw new Error("Invalid format for the given Elements base url.")}const n=await(0,ht.loadElements)(this.initOptions.elementsClientUrl);await n.init(t,r.toString().replace(/\/$/u,"")),this.elements=n}get initOptions(){return(0,g.assertInit)(this._initOptions)}get tokens(){return(0,g.assertInit)(this._tokens)}get applications(){return(0,g.assertInit)(this._applications)}get tenants(){return(0,g.assertInit)(this._tenants)}get logs(){return(0,g.assertInit)(this._logs)}get reactorFormulas(){return(0,g.assertInit)(this._reactorFormulas)}get reactors(){return(0,g.assertInit)(this._reactors)}get permissions(){return(0,g.assertInit)(this._permissions)}get proxies(){return(0,g.assertInit)(this._proxies)}get proxy(){return(0,g.assertInit)(this._proxy)}get sessions(){return(0,g.assertInit)(this._sessions)}get transactions(){return(0,g.assertInit)(this._transactions)}get elements(){return(0,g.assertInit)(this._elements)}set elements(t){this._elements=t}}ve.BasisTheory=Sc,function(e){Object.defineProperty(e,"__esModule",{value:!0});var t={_instance:!0};e._instance=void 0;var r=ve;Object.keys(r).forEach(function(a){a==="default"||a==="__esModule"||Object.prototype.hasOwnProperty.call(t,a)||a in e&&e[a]===r[a]||Object.defineProperty(e,a,{enumerable:!0,get:function(){return r[a]}})});var n=Vt;Object.keys(n).forEach(function(a){a==="default"||a==="__esModule"||Object.prototype.hasOwnProperty.call(t,a)||a in e&&e[a]===n[a]||Object.defineProperty(e,a,{enumerable:!0,get:function(){return n[a]}})});var s=Gt;Object.keys(s).forEach(function(a){a==="default"||a==="__esModule"||Object.prototype.hasOwnProperty.call(t,a)||a in e&&e[a]===s[a]||Object.defineProperty(e,a,{enumerable:!0,get:function(){return s[a]}})});const i=new r.BasisTheory;e._instance=i}(pr);const T=crypto,W=e=>e instanceof CryptoKey,Tc=async(e,t)=>{const r=`SHA-${e.slice(-3)}`;return new Uint8Array(await T.subtle.digest(r,t))},se=new TextEncoder,Dn=new TextDecoder,pt=2**32;function Te(...e){const t=e.reduce((s,{length:i})=>s+i,0),r=new Uint8Array(t);let n=0;for(const s of e)r.set(s,n),n+=s.length;return r}function Rc(e,t){return Te(se.encode(e),new Uint8Array([0]),t)}function Yt(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 Ac(e){const t=Math.floor(e/pt),r=e%pt,n=new Uint8Array(8);return Yt(n,t,0),Yt(n,r,4),n}function Zt(e){const t=new Uint8Array(4);return Yt(t,e),t}function Qt(e){return Te(Zt(e.length),e)}async function vc(e,t,r){const n=Math.ceil((t>>3)/32),s=new Uint8Array(n*32);for(let i=0;i<n;i++){const a=new Uint8Array(4+e.length+r.length);a.set(Zt(i+1)),a.set(e,4),a.set(r,4+e.length),s.set(await Tc("sha256",a),i*32)}return s.slice(0,t>>3)}const Cc=e=>{let t=e;typeof t=="string"&&(t=se.encode(t));const r=32768,n=[];for(let s=0;s<t.length;s+=r)n.push(String.fromCharCode.apply(null,t.subarray(s,s+r)));return btoa(n.join(""))},L=e=>Cc(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_"),Oc=e=>{const t=atob(e),r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r},Un=e=>{let t=e;t instanceof Uint8Array&&(t=Dn.decode(t)),t=t.replace(/-/g,"+").replace(/_/g,"/").replace(/\s/g,"");try{return Oc(t)}catch{throw new TypeError("The input to be decoded is not correctly encoded.")}};class Hn 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 N extends Hn{constructor(){super(...arguments),this.code="ERR_JOSE_NOT_SUPPORTED"}static get code(){return"ERR_JOSE_NOT_SUPPORTED"}}class X extends Hn{constructor(){super(...arguments),this.code="ERR_JWE_INVALID"}static get code(){return"ERR_JWE_INVALID"}}const er=T.getRandomValues.bind(T);function Ln(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 N(`Unsupported JWE Algorithm: ${e}`)}}const Pc=e=>er(new Uint8Array(Ln(e)>>3)),Bc=(e,t)=>{if(t.length<<3!==Ln(e))throw new X("Invalid Initialization Vector length")},Mn=(e,t)=>{const r=e.byteLength<<3;if(r!==t)throw new X(`Invalid Content Encryption Key length. Expected ${t} bits, got ${r} bits`)};function Y(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 xc(e){return parseInt(e.name.slice(4),10)}function Nc(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 n=t.pop();r+=`one of ${t.join(", ")}, or ${n}.`}else t.length===2?r+=`one of ${t[0]} or ${t[1]}.`:r+=`${t[0]}.`;throw new TypeError(r)}}function de(e,t,...r){switch(t){case"A128GCM":case"A192GCM":case"A256GCM":{if(!mt(e.algorithm,"AES-GCM"))throw Y("AES-GCM");const n=parseInt(t.slice(1,4),10);if(e.algorithm.length!==n)throw Y(n,"algorithm.length");break}case"A128KW":case"A192KW":case"A256KW":{if(!mt(e.algorithm,"AES-KW"))throw Y("AES-KW");const n=parseInt(t.slice(1,4),10);if(e.algorithm.length!==n)throw Y(n,"algorithm.length");break}case"ECDH":{switch(e.algorithm.name){case"ECDH":case"X25519":case"X448":break;default:throw Y("ECDH, X25519, or X448")}break}case"PBES2-HS256+A128KW":case"PBES2-HS384+A192KW":case"PBES2-HS512+A256KW":if(!mt(e.algorithm,"PBKDF2"))throw Y("PBKDF2");break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":{if(!mt(e.algorithm,"RSA-OAEP"))throw Y("RSA-OAEP");const n=parseInt(t.slice(9),10)||1;if(xc(e.algorithm.hash)!==n)throw Y(`SHA-${n}`,"algorithm.hash");break}default:throw new TypeError("CryptoKey does not support this operation")}Nc(e,r)}function In(e,t,...r){var n;if(r.length>2){const s=r.pop();e+=`one of type ${r.join(", ")}, or ${s}.`}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&&(n=t.constructor)!=null&&n.name&&(e+=` Received an instance of ${t.constructor.name}`),e}const k=(e,...t)=>In("Key must be ",e,...t);function $n(e,t,...r){return In(`Key for the ${e} algorithm must be `,t,...r)}const qn=e=>W(e)?!0:(e==null?void 0:e[Symbol.toStringTag])==="KeyObject",$=["CryptoKey"],jc=(...e)=>{const t=e.filter(Boolean);if(t.length===0||t.length===1)return!0;let r;for(const n of t){const s=Object.keys(n);if(!r||r.size===0){r=new Set(s);continue}for(const i of s){if(r.has(i))return!1;r.add(i)}}return!0};function Dc(e){return typeof e=="object"&&e!==null}function Uc(e){if(!Dc(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 Kn=[{hash:"SHA-256",name:"HMAC"},!0,["sign"]];function Hc(e,t){if(e.algorithm.length!==parseInt(t.slice(1,4),10))throw new TypeError(`Invalid key size for alg: ${t}`)}function Lc(e,t,r){if(W(e))return de(e,t,r),e;if(e instanceof Uint8Array)return T.subtle.importKey("raw",e,"AES-KW",!0,[r]);throw new TypeError(k(e,...$,"Uint8Array"))}const tr=async(e,t,r)=>{const n=await Lc(t,e,"wrapKey");Hc(n,e);const s=await T.subtle.importKey("raw",r,...Kn);return new Uint8Array(await T.subtle.wrapKey("raw",s,n,"AES-KW"))};async function Mc(e,t,r,n,s=new Uint8Array(0),i=new Uint8Array(0)){if(!W(e))throw new TypeError(k(e,...$));if(de(e,"ECDH"),!W(t))throw new TypeError(k(t,...$));de(t,"ECDH","deriveBits");const a=Te(Qt(se.encode(r)),Qt(s),Qt(i),Zt(n));let o;e.algorithm.name==="X25519"?o=256:e.algorithm.name==="X448"?o=448:o=Math.ceil(parseInt(e.algorithm.namedCurve.substr(-3),10)/8)<<3;const d=new Uint8Array(await T.subtle.deriveBits({name:e.algorithm.name,public:e},t,o));return vc(d,n,a)}async function Ic(e){if(!W(e))throw new TypeError(k(e,...$));return T.subtle.generateKey(e.algorithm,!0,["deriveBits"])}function $c(e){if(!W(e))throw new TypeError(k(e,...$));return["P-256","P-384","P-521"].includes(e.algorithm.namedCurve)||e.algorithm.name==="X25519"||e.algorithm.name==="X448"}function qc(e){if(!(e instanceof Uint8Array)||e.length<8)throw new X("PBES2 Salt Input must be 8 or more octets")}function Kc(e,t){if(e instanceof Uint8Array)return T.subtle.importKey("raw",e,"PBKDF2",!1,["deriveBits"]);if(W(e))return de(e,t,"deriveBits","deriveKey"),e;throw new TypeError(k(e,...$,"Uint8Array"))}async function Fc(e,t,r,n){qc(e);const s=Rc(t,e),i=parseInt(t.slice(13,16),10),a={hash:`SHA-${t.slice(8,11)}`,iterations:r,name:"PBKDF2",salt:s},o={length:i,name:"AES-KW"},d=await Kc(n,t);if(d.usages.includes("deriveBits"))return new Uint8Array(await T.subtle.deriveBits(a,d,i));if(d.usages.includes("deriveKey"))return T.subtle.deriveKey(a,d,o,!1,["wrapKey","unwrapKey"]);throw new TypeError('PBKDF2 key "usages" must include "deriveBits" or "deriveKey"')}const zc=async(e,t,r,n=2048,s=er(new Uint8Array(16)))=>{const i=await Fc(s,e,n,t);return{encryptedKey:await tr(e.slice(-6),i,r),p2c:n,p2s:L(s)}};function Fn(e){switch(e){case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":return"RSA-OAEP";default:throw new N(`alg ${e} is not supported either by JOSE or your javascript runtime`)}}const Wc=(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`)}},kc=async(e,t,r)=>{if(!W(t))throw new TypeError(k(t,...$));if(de(t,e,"encrypt","wrapKey"),Wc(e,t),t.usages.includes("encrypt"))return new Uint8Array(await T.subtle.encrypt(Fn(e),t,r));if(t.usages.includes("wrapKey")){const n=await T.subtle.importKey("raw",r,...Kn);return new Uint8Array(await T.subtle.wrapKey("raw",n,t,Fn(e)))}throw new TypeError('RSA-OAEP key "usages" must include "encrypt" or "wrapKey" for this operation')};function Vc(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 N('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 N('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 N('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break}default:throw new N('Invalid or unsupported JWK "kty" (Key Type) Parameter value')}return{algorithm:t,keyUsages:r}}const zn=async e=>{if(!e.alg)throw new TypeError('"alg" argument is required when "jwk.alg" is not present');const{algorithm:t,keyUsages:r}=Vc(e),n=[t,e.ext??!1,e.key_ops??r],s={...e};return delete s.alg,delete s.use,T.subtle.importKey("jwk",s,...n)},Wn=e=>Un(e);let rr,nr;const kn=e=>(e==null?void 0:e[Symbol.toStringTag])==="KeyObject",Vn=async(e,t,r,n)=>{let s=e.get(t);if(s!=null&&s[n])return s[n];const i=await zn({...r,alg:n});return s?s[n]=i:e.set(t,{[n]:i}),i},sr={normalizePublicKey:(e,t)=>{if(kn(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?Wn(r.k):(nr||(nr=new WeakMap),Vn(nr,e,r,t))}return e},normalizePrivateKey:(e,t)=>{if(kn(e)){let r=e.export({format:"jwk"});return r.k?Wn(r.k):(rr||(rr=new WeakMap),Vn(rr,e,r,t))}return e}};function Gn(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 N(`Unsupported JWE Algorithm: ${e}`)}}const Re=e=>er(new Uint8Array(Gn(e)>>3));async function Gc(e,t){if(!Uc(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 Un(e.k);case"RSA":if(e.oth!==void 0)throw new N('RSA JWK "oth" (Other Primes Info) Parameter value is not supported');case"EC":case"OKP":return zn({...e,alg:t});default:throw new N('Unsupported "kty" (Key Type) Parameter value')}}const ir=e=>e==null?void 0:e[Symbol.toStringTag],Jc=(e,t)=>{if(!(t instanceof Uint8Array)){if(!qn(t))throw new TypeError($n(e,t,...$,"Uint8Array"));if(t.type!=="secret")throw new TypeError(`${ir(t)} instances for symmetric algorithms must be of type "secret"`)}},Xc=(e,t,r)=>{if(!qn(t))throw new TypeError($n(e,t,...$));if(t.type==="secret")throw new TypeError(`${ir(t)} instances for asymmetric algorithms must not be of type "secret"`);if(t.algorithm,t.algorithm&&r==="encrypt"&&t.type==="private")throw new TypeError(`${ir(t)} instances for asymmetric algorithm encryption must be of type "public"`)},Yc=(e,t,r)=>{e.startsWith("HS")||e==="dir"||e.startsWith("PBES2")||/^A\d{3}(?:GCM)?KW$/.test(e)?Jc(e,t):Xc(e,t,r)};async function Zc(e,t,r,n,s){if(!(r instanceof Uint8Array))throw new TypeError(k(r,"Uint8Array"));const i=parseInt(e.slice(1,4),10),a=await T.subtle.importKey("raw",r.subarray(i>>3),"AES-CBC",!1,["encrypt"]),o=await T.subtle.importKey("raw",r.subarray(0,i>>3),{hash:`SHA-${i<<1}`,name:"HMAC"},!1,["sign"]),d=new Uint8Array(await T.subtle.encrypt({iv:n,name:"AES-CBC"},a,t)),u=Te(s,n,d,Ac(s.length<<3)),l=new Uint8Array((await T.subtle.sign("HMAC",o,u)).slice(0,i>>3));return{ciphertext:d,tag:l,iv:n}}async function Qc(e,t,r,n,s){let i;r instanceof Uint8Array?i=await T.subtle.importKey("raw",r,"AES-GCM",!1,["encrypt"]):(de(r,e,"encrypt"),i=r);const a=new Uint8Array(await T.subtle.encrypt({additionalData:s,iv:n,name:"AES-GCM",tagLength:128},i,t)),o=a.slice(-16);return{ciphertext:a.slice(0,-16),tag:o,iv:n}}const Jn=async(e,t,r,n,s)=>{if(!W(r)&&!(r instanceof Uint8Array))throw new TypeError(k(r,...$,"Uint8Array"));switch(n?Bc(e,n):n=Pc(e),e){case"A128CBC-HS256":case"A192CBC-HS384":case"A256CBC-HS512":return r instanceof Uint8Array&&Mn(r,parseInt(e.slice(-3),10)),Zc(e,t,r,n,s);case"A128GCM":case"A192GCM":case"A256GCM":return r instanceof Uint8Array&&Mn(r,parseInt(e.slice(1,4),10)),Qc(e,t,r,n,s);default:throw new N("Unsupported JWE Content Encryption Algorithm")}};async function eu(e,t,r,n){const s=e.slice(0,7),i=await Jn(s,r,t,n,new Uint8Array(0));return{encryptedKey:i.ciphertext,iv:L(i.iv),tag:L(i.tag)}}function tu(e,t,r,n,s){if(s.crit!==void 0&&(n==null?void 0:n.crit)===void 0)throw new e('"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(a=>typeof a!="string"||a.length===0))throw new e('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present');let i;r!==void 0?i=new Map([...Object.entries(r),...t.entries()]):i=t;for(const a of n.crit){if(!i.has(a))throw new N(`Extension Header Parameter "${a}" is not recognized`);if(s[a]===void 0)throw new e(`Extension Header Parameter "${a}" is missing`);if(i.get(a)&&n[a]===void 0)throw new e(`Extension Header Parameter "${a}" MUST be integrity protected`)}return new Set(n.crit)}const ru=async e=>{if(e instanceof Uint8Array)return{kty:"oct",k:L(e)};if(!W(e))throw new TypeError(k(e,...$,"Uint8Array"));if(!e.extractable)throw new TypeError("non-extractable CryptoKey cannot be exported as a JWK");const{ext:t,key_ops:r,alg:n,use:s,...i}=await T.subtle.exportKey("jwk",e);return i};async function nu(e){return ru(e)}async function su(e,t,r,n,s={}){var d;let i,a,o;switch(Yc(e,r,"encrypt"),r=await((d=sr.normalizePublicKey)==null?void 0:d.call(sr,r,e))||r,e){case"dir":{o=r;break}case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":{if(!$c(r))throw new N("ECDH with the provided key is not allowed or not supported by your javascript runtime");const{apu:u,apv:l}=s;let{epk:f}=s;f||(f=(await Ic(r)).privateKey);const{x:b,y:w,crv:h,kty:E}=await nu(f),p=await Mc(r,f,e==="ECDH-ES"?t:e,e==="ECDH-ES"?Gn(t):parseInt(e.slice(-5,-2),10),u,l);if(a={epk:{x:b,crv:h,kty:E}},E==="EC"&&(a.epk.y=w),u&&(a.apu=L(u)),l&&(a.apv=L(l)),e==="ECDH-ES"){o=p;break}o=n||Re(t);const S=e.slice(-6);i=await tr(S,p,o);break}case"RSA1_5":case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":{o=n||Re(t),i=await kc(e,r,o);break}case"PBES2-HS256+A128KW":case"PBES2-HS384+A192KW":case"PBES2-HS512+A256KW":{o=n||Re(t);const{p2c:u,p2s:l}=s;({encryptedKey:i,...a}=await zc(e,r,o,u,l));break}case"A128KW":case"A192KW":case"A256KW":{o=n||Re(t),i=await tr(e,r,o);break}case"A128GCMKW":case"A192GCMKW":case"A256GCMKW":{o=n||Re(t);const{iv:u}=s;({encryptedKey:i,...a}=await eu(e,r,o,u));break}default:throw new N('Invalid or unsupported "alg" (JWE Algorithm) header value')}return{cek:o,encryptedKey:i,parameters:a}}const iu=Symbol();class au{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 X("either setProtectedHeader, setUnprotectedHeader, or sharedUnprotectedHeader must be called before #encrypt()");if(!jc(this._protectedHeader,this._unprotectedHeader,this._sharedUnprotectedHeader))throw new X("JWE Protected, JWE Shared Unprotected and JWE Per-Recipient Header Parameter names must be disjoint");const n={...this._protectedHeader,...this._unprotectedHeader,...this._sharedUnprotectedHeader};if(tu(X,new Map,r==null?void 0:r.crit,this._protectedHeader,n),n.zip!==void 0)throw new N('JWE "zip" (Compression Algorithm) Header Parameter is not supported.');const{alg:s,enc:i}=n;if(typeof s!="string"||!s)throw new X('JWE "alg" (Algorithm) Header Parameter missing or invalid');if(typeof i!="string"||!i)throw new X('JWE "enc" (Encryption Algorithm) Header Parameter missing or invalid');let a;if(this._cek&&(s==="dir"||s==="ECDH-ES"))throw new TypeError(`setContentEncryptionKey cannot be called with JWE "alg" (Algorithm) Header ${s}`);let o;{let E;({cek:o,encryptedKey:a,parameters:E}=await su(s,i,t,this._cek,this._keyManagementParameters)),E&&(r&&iu in r?this._unprotectedHeader?this._unprotectedHeader={...this._unprotectedHeader,...E}:this.setUnprotectedHeader(E):this._protectedHeader?this._protectedHeader={...this._protectedHeader,...E}:this.setProtectedHeader(E))}let d,u,l;this._protectedHeader?u=se.encode(L(JSON.stringify(this._protectedHeader))):u=se.encode(""),this._aad?(l=L(this._aad),d=Te(u,se.encode("."),se.encode(l))):d=u;const{ciphertext:f,tag:b,iv:w}=await Jn(i,this._plaintext,o,this._iv,d),h={ciphertext:L(f)};return w&&(h.iv=L(w)),b&&(h.tag=L(b)),a&&(h.encrypted_key=L(a)),l&&(h.aad=l),this._protectedHeader&&(h.protected=Dn.decode(u)),this._sharedUnprotectedHeader&&(h.unprotected=this._sharedUnprotectedHeader),this._unprotectedHeader&&(h.header=this._unprotectedHeader),h}}class ou{constructor(t){this._flattened=new au(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 n=await this._flattened.encrypt(t,r);return[n.protected,n.encrypted_key,n.iv,n.ciphertext,n.tag].join(".")}}const ar={base:{":disabled":{backgroundColor:"transparent"}}},cu={mask:{number:"{{ data.number | card_mask: 'true', 'true' }}",expiration_month:"{{ data.expiration_month }}",expiration_year:"{{ data.expiration_year }}"}},uu="DOM Element was not found";var Xn;(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"})(Xn||(Xn={}));const Yn=e=>e!=null,lu="v3.6.0";class Ae{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({...n})=>{this.iframe&&Yn(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=du(lu),!this.IFRAME_BASE_URL)throw new Error("IFRAME_BASE_URL not found");r&&or.set(this,{key:r})}mount(t){const r=typeof t=="string"?document.querySelector(t):t;if(!r)throw new Error(uu);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=s=>{var i;if(!(s.source!==((i=this.iframe)==null?void 0:i.contentWindow)||s.data.element!==this.type))if(s.data.type==="change"){const a=this.extractValue(s.data.data.value),o={...s.data.data};delete o.value;const d=or.get(this);d&&(d.value=a),this.emitEvent({...s.data,data:o})}else this.emitEvent(s.data)};return window.addEventListener("message",n),new Promise(s=>{this.on("ready",()=>{this.update(this.options),s()})})}on(t,r){return this.subscriptions[t].push(r),{unsubscribe:()=>this.subscriptions[t].splice(this.subscriptions[t].indexOf(r),1)}}secureValue(t){const r=or.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(n=>n(t.data))}iframePostMessage(t){var r,n;(n=(r=this.iframe)==null?void 0:r.contentWindow)==null||n.postMessage(t,this.IFRAME_BASE_URL)}}function du(e){return`https://${window.HG_IFRAME_HOST??"sdk.hellgate.io"}/web/${e}/iframe/`}const or=new Map;function cr(e){const[t=null,r=null]=(e??"").split("/").map(n=>Number(n.trim()));return{month:t,year:r&&r>10?+`20${r}`:null}}function ur(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(Yn).join(" / ")}class Zn extends Ae{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:cr}),Object.defineProperty(this,"putValue",{enumerable:!0,configurable:!0,writable:!0,value:ur})}}function lr(e){return(e==null?void 0:e.replaceAll(" ",""))??null}function Qn(e){return e}class es extends Ae{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:lr}),Object.defineProperty(this,"putValue",{enumerable:!0,configurable:!0,writable:!0,value:Qn})}}class ts extends Ae{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?lr(t.cardNumber):null,expiry_date:t.cardExpirationDate?cr(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?ur(t.expiry_date):null,cardVerificationCode:t.cvc??null}:null})}}class rs extends Ae{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 dr extends Ae{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 fe(e,t,r){switch(e){case"card":return new ts(t,r);case"cardNumber":return new es(t,r);case"cardExpirationDate":return new Zn(t,r);case"cardVerificationCode":return new rs(t,r);case"text":return new dr(t,r);default:ASSERT_EXHAUSTIVE(e)}}function ns(){return Date.now().toString(36)+Math.random().toString(36).slice(2)}function ss(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 Et{static async init(t){var n;const r=t.isNextAction("tokenize_card")&&((n=t.state)==null?void 0:n.data.provider)==="basis_theory"?await new pr.BasisTheory().init(t.state.data.api_key,{elements:!1}):void 0;return new Et(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:(n={})=>{var o;if(this.hasFormElements())throw new Error("Form elements can't be initialized twice. You can call `reset()` method or create new Hellgate client.");const s=he.get(this);if(!s)throw new Error("Secure key not found");const i=oe({disabled:!1,autocomplete:"on",style:{...ar}},n);if(this.session.isNextAction("refresh_security_code")&&((o=this.session.state)!=null&&o.data)){const d=this.session.state.data;i.cvcOnly=!0,i.value={number:ss(d),expiry_date:{month:(d==null?void 0:d.expiry_month)??null,year:(d==null?void 0:d.expiry_year)??null},cvc:null}}const a=fe("card",i,s);return this.cardElements.card={element:a,state:this.createFieldDefaultState()},this.addElementStateListener("card"),a}}),Object.defineProperty(this,"createFormFields",{enumerable:!0,configurable:!0,writable:!0,value:(n={})=>{var w,h;if(this.hasFormElements())throw new Error("Form elements can't be initialized twice. You can call `reset()` method or create new Hellgate client.");const s=he.get(this);if(!s)throw new Error("Secure key not found");const i={disabled:this.cvcOnlyEnabled,autocomplete:"on",style:{...ar}},{cardNumber:a={},expiryDate:o={},securityCode:d={},...u}=n,l=fe("cardNumber",{...oe(i,{...u,...a,cvcOnly:this.cvcOnlyEnabled,value:this.session.isNextAction("refresh_security_code")&&((w=this.session.state)!=null&&w.data)?ss(this.session.state.data):null})},s),f=fe("cardExpirationDate",{...oe(i,{...u,...o,value:this.session.isNextAction("refresh_security_code")&&((h=this.session.state)!=null&&h.data)?{month:this.session.state.data.expiry_month,year:this.session.state.data.expiry_year}:null})},s),b=fe("cardVerificationCode",{...oe({...i,disabled:!1,autofocus:this.cvcOnlyEnabled},{...u,...d})},s);return this.cardElements={cardNumber:{element:l,state:this.createFieldDefaultState()},cardExpirationDate:{element:f,state:this.createFieldDefaultState()},cardVerificationCode:{element:b,state:this.createFieldDefaultState()}},this.addElementStateListener("cardNumber"),this.addElementStateListener("cardExpirationDate"),this.addElementStateListener("cardVerificationCode"),{cardNumber:l,expiryDate:f,securityCode:b}}}),Object.defineProperty(this,"createTextField",{enumerable:!0,configurable:!0,writable:!0,value:(n={})=>{const s=he.get(this);if(!s)throw new Error("Secure key not found");const i={disabled:!1,autocomplete:"on",style:{...ar}},a=fe("text",{...oe(i,{...n})},s);return this.textElements.push(a),a}}),Object.defineProperty(this,"tokenize",{enumerable:!0,configurable:!0,writable:!0,value:async n=>{var d,u;if(((d=this.session.state)==null?void 0:d.next_action)!=="tokenize_card")throw new Error(`The session's next_action='${(u=this.session.state)==null?void 0:u.next_action}'. tokenize() is available only if next_action='tokenize_card'`);const s=this.getFormValue(),i=this.extractAdditionalData(n);if(!s)throw new Error("Form elements must be initialized before tokenization");const a=this.getCardDataValidationError();if(a)throw a;if(!s.number||!s.expiration_month||!s.expiration_year||!s.cvc)throw new Error("Card data is not complete");const o=this.session.state.data;switch(o.provider){case"basis_theory":{if(!this.bt)throw new Error("basis_theory SDK not found");return this.bt.tokenize({type:"card",data:s,...cu}).then(l=>Array.isArray(l)?null:{token_id:l.id,additional_data:i})}case"guardian":return this.encryptCardData({account_number:s.number,expiry_month:s.expiration_month,expiry_year:s.expiration_year,security_code:s.cvc,additional_data:i},o.jwk);default:ASSERT_EXHAUSTIVE(o)}}}),Object.defineProperty(this,"onStateChange",{enumerable:!0,configurable:!0,writable:!0,value:n=>{this.stateChangeHandlers.push(n),n(this.state)}}),Object.defineProperty(this,"clear",{enumerable:!0,configurable:!0,writable:!0,value:()=>{Object.values(this.cardElements).forEach(n=>n==null?void 0:n.element.clear()),this.textElements.forEach(n=>n==null?void 0:n.clear())}}),Object.defineProperty(this,"reset",{enumerable:!0,configurable:!0,writable:!0,value:()=>{Object.values(this.cardElements).forEach(n=>n==null?void 0:n.element.unmount()),this.textElements.forEach(n=>n==null?void 0:n.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(n={})=>{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 s=await this.tokenize(n);if(!s)throw new Error("Tokenization failed");return await this.session.completeAction({action:"tokenize_card",result:s})}catch(s){throw this.disableFormElements(!1),s}}}),he.set(this,ns()),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(n=>{if(this.disableFormElements(!1),n instanceof Error)throw n;return{status:"failure",data:n}})}getFormValue(){var a,o,d,u,l;const{card:t,cardNumber:r,cardExpirationDate:n,cardVerificationCode:s}=this.cardElements;let i;if(t){const f=pe(this,t.element);i={number:(f==null?void 0:f.number)??null,expiration_month:((a=f==null?void 0:f.expiry_date)==null?void 0:a.month)??null,expiration_year:((o=f==null?void 0:f.expiry_date)==null?void 0:o.year)??null,cvc:(f==null?void 0:f.cvc)??null}}return r&&n&&s&&(i={number:((d=pe(this,r.element))==null?void 0:d.replaceAll(" ",""))??null,expiration_month:((u=pe(this,n.element))==null?void 0:u.month)??null,expiration_year:((l=pe(this,n.element))==null?void 0:l.year)??null,cvc:pe(this,s.element)}),i}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 ae({cardholder_name:me(this,t),billing_address:{line1:me(this,r.line1),line2:me(this,r.line2),line3:me(this,r.line3),city:me(this,r.city),postal_code:me(this,r.postal_code)}})}async encryptCardData(t,r){const n=await Gc(r,"RSA-OAEP"),s=JSON.stringify(t),i=new TextEncoder().encode(s);return{enc_payload:await new ou(i).setProtectedHeader({alg:"RSA-OAEP",enc:"A256GCM"}).encrypt(n)}}addElementStateListener(t){const r=this.cardElements[t];r&&r.element.on("change",n=>{r.state=n,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: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 he=new Map;function pe(e,t){const r=he.get(e);return r?t.secureValue(r):null}function me(e,t){const r=he.get(e);return t instanceof dr&&r?pe(e,t)??void 0:t}class fu{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(n=>bt(n))}cancelAll(){this.abortCtrl.abort()}}const hu=2e3;class pu{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((n,s)=>{const i=this.onStateChange(a=>{a.next_action!=="wait"&&(n(a),i())});this.updateSessionState().catch(a=>{a instanceof Response&&a.status===404&&s(new Error(`Session ${this.id} doesn't exist or has expired`)),s(a)})})}),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(s=>s!==n))}),Object.defineProperty(this,"onClose",{enumerable:!0,configurable:!0,writable:!0,value:n=>{var s;return((s=this.state)==null?void 0:s.next_action)===null?(n(this.state),()=>{}):(this.onCloseHandlers.push(n),()=>this.onCloseHandlers=this.onCloseHandlers.filter(i=>i!==n))}}),Object.defineProperty(this,"completeAction",{enumerable:!0,configurable:!0,writable:!0,value:async n=>{const s=this.state;return new Promise((i,a)=>{const o=this.onStateChange(d=>{d.next_action!==(s==null?void 0:s.next_action)&&d.next_action===null&&(i(is(d)),o())});this.api.completeAction(this.id,n).then(d=>this.newStateHandle(d,a)).catch(async d=>a(await mu(d)))})}}),Object.defineProperty(this,"completeSession",{enumerable:!0,configurable:!0,writable:!0,value:n=>{this.onCloseHandlers.forEach(s=>s(n)),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 n;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(s=>{s instanceof Response&&s.status===404&&(r==null||r(new Error(`Session ${this.id} has expired`)))}),hu);break}}t.next_action!==((n=this.state)==null?void 0:n.next_action)&&this.stateChangeHandlers.forEach(s=>s(t)),t.next_action===null&&this.completeSession(is(t)),this.state=t}}async function mu(e){return!e.ok&&e.status>=400&&e.status<=500?e.json():e}function is(e){const t={...e};return delete t.next_action,t}const Eu={base_url:"https://api.hellgate.io"};class fr{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(n=>n==null?void 0:n.dispose())}})}use(t){return this.paymentFlowHandlers[t]}static async init(t,r={}){const{session:n,cardHandler:s,handler3DS:i}=await this.initHandlers(t,r);return new fr(n,{CARD:s,"3DS":i})}static async initHandlers(t,r){const n={...Eu,...r},s=new fu(n.base_url,n.abortCtrl),i=new pu(t,s);await i.init();const a=i.isNextAction("tokenize_card")||i.isNextAction("refresh_security_code")?await this.createCardHandler(i):void 0,o=this.create3DSHandler(i,r);return{session:i,cardHandler:a,handler3DS:o}}static createCardHandler(t){return Et.init(t)}static create3DSHandler(t,r){return new hr(t,{domContainer:r.challenge_3ds_container,labelText:r.challenge_3ds_label_text})}}v.CardElement=ts,v.CardExpirationDateElement=Zn,v.CardNumberElement=es,v.CardVerificationCodeElement=rs,v.Hellgate=fr,v.Hellgate3DSHandler=hr,v.HellgateCardHandler=Et,v.TextElement=dr,v.createElement=fe,v.extractCardNumberValue=lr,v.extractExpiryDateValue=cr,v.putCardNumberValue=Qn,v.putExpiryDateValue=ur,v.uid=ns,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})});globalThis.HellgateSDK&&(globalThis.Hellgate=globalThis.HellgateSDK.Hellgate,delete globalThis.HellgateSDK);
|
|
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);
|