1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,66013,30088,e=>{"use strict";let t,r,n,i,o,a,s;var l,c,u,h,f,d=e.i(4144),p=e.i(15675),g=Object.defineProperty,m=e=>"object"==typeof e&&!!e,y=e=>m(e)&&!(e instanceof RegExp)&&!(e instanceof Error)&&!(e instanceof Date);let w=Symbol("mapObjectSkip");var b=(e,t,r,n=new WeakMap)=>{if(r={deep:!1,target:{},...r},n.has(e))return n.get(e);n.set(e,r.target);let{target:i}=r;delete r.target;let o=e=>e.map(e=>y(e)?b(e,t,r,n):e);if(Array.isArray(e))return o(e);for(let[a,s]of Object.entries(e)){let l=t(a,s,e);if(l===w)continue;let[c,u,{shouldRecurse:h=!0}={}]=l;"__proto__"!==c&&(r.deep&&h&&y(u)&&(u=Array.isArray(u)?o(u):b(u,t,r,n)),i[c]=u)}return i};function v(e,t,r){if(!m(e))throw TypeError(`Expected an object, got \`${e}\` (${typeof e})`);return b(e,t,r)}var S=/[\p{Lu}]/u,E=/[\p{Ll}]/u,_=/^[\p{Lu}](?![\p{Lu}])/gu,k=/([\p{Alpha}\p{N}_]|$)/u,A=/[_.\- ]+/,T=RegExp("^"+A.source),R=RegExp(A.source+k.source,"gu"),O=RegExp("\\d+"+k.source,"gu"),C=new class extends Map{constructor(e={}){if(super(),!(e.maxSize&&e.maxSize>0))throw TypeError("`maxSize` must be a number greater than 0");if("number"==typeof e.maxAge&&0===e.maxAge)throw TypeError("`maxAge` must be a number greater than 0");this.maxSize=e.maxSize,this.maxAge=e.maxAge||1/0,this.onEviction=e.onEviction,this.cache=new Map,this.oldCache=new Map,this._size=0}_emitEvictions(e){if("function"==typeof this.onEviction)for(let[t,r]of e)this.onEviction(t,r.value)}_deleteIfExpired(e,t){return!!("number"==typeof t.expiry&&t.expiry<=Date.now())&&("function"==typeof this.onEviction&&this.onEviction(e,t.value),this.delete(e))}_getOrDeleteIfExpired(e,t){if(!1===this._deleteIfExpired(e,t))return t.value}_getItemValue(e,t){return t.expiry?this._getOrDeleteIfExpired(e,t):t.value}_peek(e,t){let r=t.get(e);return this._getItemValue(e,r)}_set(e,t){this.cache.set(e,t),this._size++,this._size>=this.maxSize&&(this._size=0,this._emitEvictions(this.oldCache),this.oldCache=this.cache,this.cache=new Map)}_moveToRecent(e,t){this.oldCache.delete(e),this._set(e,t)}*_entriesAscending(){for(let e of this.oldCache){let[t,r]=e;this.cache.has(t)||!1===this._deleteIfExpired(t,r)&&(yield e)}for(let e of this.cache){let[t,r]=e;!1===this._deleteIfExpired(t,r)&&(yield e)}}get(e){if(this.cache.has(e)){let t=this.cache.get(e);return this._getItemValue(e,t)}if(this.oldCache.has(e)){let t=this.oldCache.get(e);if(!1===this._deleteIfExpired(e,t))return this._moveToRecent(e,t),t.value}}set(e,t,{maxAge:r=this.maxAge}={}){let n="number"==typeof r&&r!==1/0?Date.now()+r:void 0;return this.cache.has(e)?this.cache.set(e,{value:t,expiry:n}):this._set(e,{value:t,expiry:n}),this}has(e){return this.cache.has(e)?!this._deleteIfExpired(e,this.cache.get(e)):!!this.oldCache.has(e)&&!this._deleteIfExpired(e,this.oldCache.get(e))}peek(e){return this.cache.has(e)?this._peek(e,this.cache):this.oldCache.has(e)?this._peek(e,this.oldCache):void 0}delete(e){let t=this.cache.delete(e);return t&&this._size--,this.oldCache.delete(e)||t}clear(){this.cache.clear(),this.oldCache.clear(),this._size=0}resize(e){if(!(e&&e>0))throw TypeError("`maxSize` must be a number greater than 0");let t=[...this._entriesAscending()],r=t.length-e;r<0?(this.cache=new Map(t),this.oldCache=new Map,this._size=t.length):(r>0&&this._emitEvictions(t.slice(0,r)),this.oldCache=new Map(t.slice(r)),this.cache=new Map,this._size=0),this.maxSize=e}*keys(){for(let[e]of this)yield e}*values(){for(let[,e]of this)yield e}*[Symbol.iterator](){for(let e of this.cache){let[t,r]=e;!1===this._deleteIfExpired(t,r)&&(yield[t,r.value])}for(let e of this.oldCache){let[t,r]=e;this.cache.has(t)||!1===this._deleteIfExpired(t,r)&&(yield[t,r.value])}}*entriesDescending(){let e=[...this.cache];for(let t=e.length-1;t>=0;--t){let[r,n]=e[t];!1===this._deleteIfExpired(r,n)&&(yield[r,n.value])}e=[...this.oldCache];for(let t=e.length-1;t>=0;--t){let[r,n]=e[t];this.cache.has(r)||!1===this._deleteIfExpired(r,n)&&(yield[r,n.value])}}*entriesAscending(){for(let[e,t]of this._entriesAscending())yield[e,t.value]}get size(){if(!this._size)return this.oldCache.size;let e=0;for(let t of this.oldCache.keys())this.cache.has(t)||e++;return Math.min(this._size+e,this.maxSize)}entries(){return this.entriesAscending()}forEach(e,t=this){for(let[r,n]of this.entriesAscending())e.call(t,n,r,this)}get[Symbol.toStringTag](){return JSON.stringify([...this.entriesAscending()])}}({maxSize:1e5}),I=e=>"object"==typeof e&&!!e&&!(e instanceof RegExp)&&!(e instanceof Error)&&!(e instanceof Date),x=(e,t={})=>
1{if(!I(e))return e;let{exclude:r,pascalCase:n=!1,stopPaths:i,deep:o=!1,preserveConsecutiveUppercase:a=!1}=t,s=new Set(i),l=e=>(t,i)=>{let c;if(o&&I(i)){let r=void 0===e?t:`${e}.${t}`;s.has(r)||(i=v(i,l(r)))}if(!(r&&(c=t,r.some(e=>"string"==typeof e?e===c:(e.lastIndex=0,e.test(c)))))){let e=n?`${t}_`:t;if(C.has(e))t=C.get(e);else{let r=function(e,t){let r,n;if(!("string"==typeof e||Array.isArray(e)))throw TypeError("Expected the input to be `string | string[]`");if(t={pascalCase:!1,preserveConsecutiveUppercase:!1,...t},0===(e=Array.isArray(e)?e.map(e=>e.trim()).filter(e=>e.length).join("-"):e.trim()).length)return"";let i=!1===t.locale?e=>e.toLowerCase():e=>e.toLocaleLowerCase(t.locale),o=!1===t.locale?e=>e.toUpperCase():e=>e.toLocaleUpperCase(t.locale);return 1===e.length?A.test(e)?"":t.pascalCase?o(e):i(e):(e!==i(e)&&(e=((e,t,r,n)=>{let i=!1,o=!1,a=!1,s=!1;for(let l=0;l<e.length;l++){let c=e[l];s=!(l>2)||"-"===e[l-3],i&&S.test(c)?(e=e.slice(0,l)+"-"+e.slice(l),i=!1,a=o,o=!0,l++):o&&a&&E.test(c)&&(!s||n)?(e=e.slice(0,l-1)+"-"+e.slice(l-1),a=o,o=!1,i=!0):(i=t(c)===c&&r(c)!==c,a=o,o=r(c)===c&&t(c)!==c)}return e})(e,i,o,t.preserveConsecutiveUppercase)),e=e.replace(T,""),e=t.preserveConsecutiveUppercase?(r=e,_.lastIndex=0,r.replaceAll(_,e=>i(e))):i(e),t.pascalCase&&(e=o(e.charAt(0))+e.slice(1)),n=e,R.lastIndex=0,O.lastIndex=0,n.replaceAll(O,(e,t,r)=>["_","-"].includes(n.charAt(r+e.length))?e:o(e)).replaceAll(R,(e,t)=>o(t)))}(t,{pascalCase:n,locale:!1,preserveConsecutiveUppercase:a});t.length<100&&C.set(e,r),t=r}}return[t,i]};return v(e,l(void 0))};function U(e,t){return Array.isArray(e)?Object.keys(e).map(r=>x(e[r],t)):x(e,t)}(L=D||={}).OpenId="openid",L.OfflineAccess="offline_access",($||={}).Organization="urn:logto:resource:organizations",(N=M||={}).Profile="profile",N.Email="email",N.Phone="phone",N.Address="address",N.CustomData="custom_data",N.Identities="identities",N.Roles="roles",N.Organizations="urn:logto:scope:organizations",N.OrganizationRoles="urn:logto:scope:organization_roles";var P=Object.freeze({[M.Profile]:["name","picture","username"],[M.Email]:["email","email_verified"],[M.Phone]:["phone_number","phone_number_verified"],[M.Address]:[],[M.Roles]:["roles"],[M.Organizations]:["organizations"],[M.OrganizationRoles]:["organization_roles"],[M.CustomData]:[],[M.Identities]:[]}),j=Object.freeze({[M.Profile]:[],[M.Email]:[],[M.Phone]:[],[M.Address]:[],[M.Roles]:[],[M.Organizations]:[],[M.OrganizationRoles]:[],[M.CustomData]:["custom_data"],[M.Identities]:["identities"]});Object.freeze(Object.fromEntries(Object.values(M).map(e=>[e,[...P[e],...j[e]]])));var L,N,D,$,M,B,z={"Content-Type":"application/x-www-form-urlencoded"};(eR=B||={}).AuthorizationCode="authorization_code",eR.RefreshToken="refresh_token",(eO=eI||={}).ClientId="client_id",eO.Code="code",eO.CodeChallenge="code_challenge",eO.CodeChallengeMethod="code_challenge_method",eO.CodeVerifier="code_verifier",eO.Error="error",eO.ErrorDescription="error_description",eO.GrantType="grant_type",eO.IdToken="id_token",eO.IdTokenHint="id_token_hint",eO.LoginHint="login_hint",eO.PostLogoutRedirectUri="post_logout_redirect_uri",eO.Prompt="prompt",eO.RedirectUri="redirect_uri",eO.RefreshToken="refresh_token",eO.Resource="resource",eO.ResponseType="response_type",eO.Scope="scope",eO.State="state",eO.Token="token",eO.InteractionMode="interaction_mode",eO.OrganizationId="organization_id",eO.FirstScreen="first_screen",eO.Identifier="identifier",eO.DirectSignIn="direct_sign_in",eO.OneTimeToken="one_time_token",(eC=ex||={}).None="none",eC.Consent="consent",eC.Login="login";var K=async({clientId:e,tokenEndpoint:t,redirectUri:r,codeVerifier:n,code:i,resource:o},a)=>{let s=new URLSearchParams;return s.append(eI.ClientId,e),s.append(eI.Code,i),s.append(eI.CodeVerifier,n),s.append(eI.RedirectUri,r),s.append(eI.GrantType,B.AuthorizationCode),o&&s.append(eI.Resource,o),U(await a(t,{method:"POST",headers:z,body:s.toString()}))},F=async(e,t)=>{let{clientId:r,tokenEndpoint:n,refreshToken:i,resource:o,organizationId:a,scopes:s}=e,l=new URLSearchParams;return l.append(eI.ClientId,r),l.append(eI.RefreshToken,i),l.append(eI.GrantType,B.RefreshToken),o&&l.a
1ppend(eI.Resource,o),a&&l.append(eI.OrganizationId,a),s?.length&&l.append(eI.Scope,s.join(" ")),U(await t(n,{method:"POST",headers:z,body:l.toString()}))},J=async(e,t)=>U(await t(e)),W=async(e,t,r,n)=>n(e,{method:"POST",headers:z,body:new URLSearchParams({[eI.ClientId]:t,[eI.Token]:r}).toString()}),H=e=>Array.from(new Set([...Object.values(D),M.Profile,...e??[]])).join(" "),q=async(e,t,r)=>r(e,{headers:{Authorization:`Bearer ${t}`}}),V=e=>decodeURIComponent(escape(atob(e.replaceAll("-","+").replaceAll("_","/")))),G=e=>"object"==typeof e&&!!e,X=Object.freeze({"id_token.invalid_iat":"Invalid issued at time in the ID token","id_token.invalid_token":"Invalid ID token","callback_uri_verification.redirect_uri_mismatched":"The callback URI mismatches the redirect URI.","callback_uri_verification.error_found":"Error found in the callback URI","callback_uri_verification.missing_state":"Missing state in the callback URI","callback_uri_verification.state_mismatched":"State mismatched in the callback URI","callback_uri_verification.missing_code":"Missing code in the callback URI",crypto_subtle_unavailable:"Crypto.subtle is unavailable in insecure contexts (non-HTTPS).",unexpected_response_error:"Unexpected response error from the server."}),Y=class extends Error{constructor(e,t){super(X[e]),this.code=e,this.data=t,this.name="LogtoError"}},Q=class extends Error{constructor(e,t,r){super(t),this.code=e,this.cause=r,this.name="LogtoRequestError"}},Z=class{constructor(e,t){this.error=e,this.errorDescription=t,this.name="OidcError"}},ee=e=>{let{1:t}=e.split(".");if(!t)return{};let r=JSON.parse(V(t));return function(e){if(!G(e))throw TypeError("AccessToken is expected to be an object");for(let t of["jti","iss","sub","aud","client_id","scope"])if(void 0!==e[t]&&"string"!=typeof e[t]&&null!==e[t])throw TypeError(`At path: AccessToken.${t}: expected null or a string`);for(let t of["exp","iat"])if(void 0!==e[t]&&"number"!=typeof e[t]&&null!==e[t])throw TypeError(`At path: AccessToken.${t}: expected null or a number`)}(r),r},et=crypto;let er=new TextEncoder,en=new TextDecoder,ei=e=>{let t=e;t instanceof Uint8Array&&(t=en.decode(t)),t=t.replace(/-/g,"+").replace(/_/g,"/").replace(/\s/g,"");try{var r=t;let e=atob(r),n=new Uint8Array(e.length);for(let t=0;t<e.length;t++)n[t]=e.charCodeAt(t);return n}catch{throw TypeError("The input to be decoded is not correctly encoded.")}};var eo=class extends Error{constructor(e,t){super(e,t),this.code="ERR_JOSE_GENERIC",this.name=this.constructor.name,Error.captureStackTrace?.(this,this.constructor)}};eo.code="ERR_JOSE_GENERIC";var ea=class extends eo{constructor(e,t,r="unspecified",n="unspecified"){super(e,{cause:{claim:r,reason:n,payload:t}}),this.code="ERR_JWT_CLAIM_VALIDATION_FAILED",this.claim=r,this.reason=n,this.payload=t}};ea.code="ERR_JWT_CLAIM_VALIDATION_FAILED";var es=class extends eo{constructor(e,t,r="unspecified",n="unspecified"){super(e,{cause:{claim:r,reason:n,payload:t}}),this.code="ERR_JWT_EXPIRED",this.claim=r,this.reason=n,this.payload=t}};es.code="ERR_JWT_EXPIRED";var el=class extends eo{constructor(){super(...arguments),this.code="ERR_JOSE_ALG_NOT_ALLOWED"}};el.code="ERR_JOSE_ALG_NOT_ALLOWED";var ec=class extends eo{constructor(){super(...arguments),this.code="ERR_JOSE_NOT_SUPPORTED"}};ec.code="ERR_JOSE_NOT_SUPPORTED";var eu=class extends eo{constructor(){super(...arguments),this.code="ERR_JWS_INVALID"}};eu.code="ERR_JWS_INVALID";var eh=class extends eo{constructor(){super(...arguments),this.code="ERR_JWT_INVALID"}};eh.code="ERR_JWT_INVALID";var ef=class extends eo{constructor(){super(...arguments),this.code="ERR_JWKS_INVALID"}};ef.code="ERR_JWKS_INVALID";var ed=class extends eo{constructor(e="no applicable key found in the JSON Web Key Set",t){super(e,t),this.code="ERR_JWKS_NO_MATCHING_KEY"}};ed.code="ERR_JWKS_NO_MATCHING_KEY";var ep=class extends eo{constructor(e="multiple matching keys found in the JSON Web Key Set",t){super(e,t),this.code="ERR_JWKS_MULTIPLE_MATCHING_KEYS"}};ep.code="ERR_JWKS_MULTIPLE_MATCHING_KEYS";var eg=class extends eo{constructor(e="request timed out",t){super(e,t),this.code="ERR_JWKS_TIMEOUT"}};eg.code="ERR_JWKS_TIMEOUT";var em=class extends eo{constructor(e="signature verification failed",t){super(e,t),this.code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED"}};function ey(e,t="algorithm.name"){return TypeError(`CryptoKey does not support this operation, its ${t} must be ${e}`)}function ew(e,t){return e.name===t}function eb(e){return parseInt(e.name.slice(4),10)}function ev(e,t,...r){if((r=r.filter(Boolean)).length>2){let t=r.pop();e+=`one of type ${r.join(", ")}, or ${t}.`}else 2===r.length?e+=`one of type ${r[0]} or ${r[1]}.`:e+=`of type ${r[0]}.`;return null==t?e+=` Received ${t}`:"function"==typeof t&&t.name?e+=` Received function ${t.name}`:"object"==typeof t&&t&&t.constructor?.name&&(e+=` Received an instance of ${t.constructor.name}`),e}em.code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED";var eS=(e,...t)=>ev("Key must be ",e,...t);function eE(e,t,...r){return ev(`Key for the ${e} algorithm must be `,t,...r)}var e_=e=>e instanceof CryptoKey||e?.[Symbol.toStringTag]==="KeyObject";let ek=["CryptoKey"];function eA(e){if(!("object"==typeof e&&e)||"[object Object]"!==Object.prototype.toString.call(e))return!1;if(null===Object.getPrototypeOf(e))return!0;let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function eT(e){return eA(e)&&"string"==typeof e.kty}var eR,eO,eC,eI,ex,eU,eP,ej=async e=>{if(!e.alg)throw TypeError('"alg" argument is required when "jwk.alg" is not present');let{algorithm:t,keyUsages:r}=function(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;
1default:throw new ec('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 ec('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break;case"OKP":switch(e.alg){case"Ed25519":t={name:"Ed25519"},r=e.d?["sign"]:["verify"];break;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 ec('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break;default:throw new ec('Invalid or unsupported JWK "kty" (Key Type) Parameter value')}return{algorithm:t,keyUsages:r}}(e),n=[t,e.ext??!1,e.key_ops??r],i={...e};return delete i.alg,delete i.use,et.subtle.importKey("jwk",i,...n)},eL=e=>e?.[Symbol.toStringTag]==="KeyObject",eN=async(e,t,r,n,i=!1)=>{let o=e.get(t);if(o?.[n])return o[n];let a=await ej({...r,alg:n});return i&&Object.freeze(t),o?o[n]=a:e.set(t,{[n]:a}),a};async function eD(e,t){if(!eA(e))throw TypeError("JWK must be an object");switch(t||=e.alg,e.kty){case"oct":if("string"!=typeof e.k||!e.k)throw TypeError('missing "k" (Key Value) Parameter value');return ei(e.k);case"RSA":if("oth"in e&&void 0!==e.oth)throw new ec('RSA JWK "oth" (Other Primes Info) Parameter value is not supported');case"EC":case"OKP":return ej({...e,alg:t});default:throw new ec('Unsupported "kty" (Key Type) Parameter value')}}var e$=e=>e?.[Symbol.toStringTag],eM=(e,t,r)=>{if(void 0!==t.use&&"sig"!==t.use)throw TypeError("Invalid key for this operation, when present its use must be sig");if(void 0!==t.key_ops&&t.key_ops.includes?.(r)!==!0)throw TypeError(`Invalid key for this operation, when present its key_ops must include ${r}`);if(void 0!==t.alg&&t.alg!==e)throw TypeError(`Invalid key for this operation, when present its alg must be ${e}`);return!0};function eB(e,t,r,n){t.startsWith("HS")||"dir"===t||t.startsWith("PBES2")||/^A\d{3}(?:GCM)?KW$/.test(t)?((e,t,r,n)=>{if(!(t instanceof Uint8Array)){if(n&&eT(t)){if(eT(t)&&"oct"===t.kty&&"string"==typeof t.k&&eM(e,t,r))return;throw TypeError('JSON Web Key for symmetric algorithms must have JWK "kty" (Key Type) equal to "oct" and the JWK "k" (Key Value) present')}if(!e_(t))throw TypeError(eE(e,t,...ek,"Uint8Array",n?"JSON Web Key":null));if("secret"!==t.type)throw TypeError(`${e$(t)} instances for symmetric algorithms must be of type "secret"`)}})(t,r,n,e):((e,t,r,n)=>{if(n&&eT(t))switch(r){case"sign":if("oct"!==t.kty&&"string"==typeof t.d&&eM(e,t,r))return;throw TypeError("JSON Web Key for this operation be a private JWK");case"verify":if("oct"!==t.kty&&void 0===t.d&&eM(e,t,r))return;throw TypeError("JSON Web Key for this operation be a public JWK")}if(!e_(t))throw TypeError(eE(e,t,...ek,n?"JSON Web Key":null));if("secret"===t.type)throw TypeError(`${e$(t)} instances for asymmetric algorithms must not be of type "secret"`);if("sign"===r&&"public"===t.type)throw TypeError(`${e$(t)} instances for asymmetric algorithm signing must be of type "private"`);if("decrypt"===r&&"public"===t.type)throw TypeError(`${e$(t)} instances for asymmetric algorithm decryption must be of type "private"`);if(t.algorithm&&"verify"===r&&"private"===t.type)throw TypeError(`${e$(t)} instances for asymmetric algorithm verifying must be of type "public"`);if(t.algorithm&&"encrypt"===r&&"private"===t.type)throw TypeError(`${e$(t)} instances for asymmetric algorithm encryption must be of type "public"`)})(t,r,n,e)}eB.bind(void 0,!1);let ez=eB.bind(void 0,!0);var eK=function(e,t,r,n,i){let o;if(void 0!==i.crit&&n?.crit===void 0)throw new e('"crit" (Critical) Header Parameter MUST be integrity protected');if(!n||void 0===n.crit)return new Set;if(!Array.isArray(n.crit)||0===n.crit.length||n.crit.some(e=>"string"!=typeof e||0===e.length))throw new e('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present');for(let a of(o=void 0===r?t:new Map([...Object.entries(r),...t.entries()]),n.crit)){if(!o.has(a))throw new e
1c(`Extension Header Parameter "${a}" is not recognized`);if(void 0===i[a])throw new e(`Extension Header Parameter "${a}" is missing`);if(o.get(a)&&void 0===n[a])throw new e(`Extension Header Parameter "${a}" MUST be integrity protected`)}return new Set(n.crit)};async function eF(e,t,r){if("sign"===r&&(t=await ((e,t)=>{if(eL(e)){let r=e.export({format:"jwk"});return r.k?ei(r.k):eN(eU||=new WeakMap,e,r,t)}return eT(e)?e.k?ei(e.k):eN(eU||=new WeakMap,e,e,t,!0):e})(t,e)),"verify"===r&&(t=await ((e,t)=>{if(eL(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?ei(r.k):eN(eP||=new WeakMap,e,r,t)}return eT(e)?e.k?ei(e.k):eN(eP||=new WeakMap,e,e,t,!0):e})(t,e)),t instanceof CryptoKey)return function(e,t,...r){switch(t){case"HS256":case"HS384":case"HS512":{if(!ew(e.algorithm,"HMAC"))throw ey("HMAC");let r=parseInt(t.slice(2),10);if(eb(e.algorithm.hash)!==r)throw ey(`SHA-${r}`,"algorithm.hash");break}case"RS256":case"RS384":case"RS512":{if(!ew(e.algorithm,"RSASSA-PKCS1-v1_5"))throw ey("RSASSA-PKCS1-v1_5");let r=parseInt(t.slice(2),10);if(eb(e.algorithm.hash)!==r)throw ey(`SHA-${r}`,"algorithm.hash");break}
1case"PS256":case"PS384":case"PS512":{if(!ew(e.algorithm,"RSA-PSS"))throw ey("RSA-PSS");let r=parseInt(t.slice(2),10);if(eb(e.algorithm.hash)!==r)throw ey(`SHA-${r}`,"algorithm.hash");break}case"EdDSA":if("Ed25519"!==e.algorithm.name&&"Ed448"!==e.algorithm.name)throw ey("Ed25519 or Ed448");break;case"Ed25519":if(!ew(e.algorithm,"Ed25519"))throw ey("Ed25519");break;case"ES256":case"ES384":case"ES512":{if(!ew(e.algorithm,"ECDSA"))throw ey("ECDSA");let r=function(e){switch(e){case"ES256":return"P-256";case"ES384":return"P-384";case"ES512":return"P-521";default:throw Error("unreachable")}}(t);if(e.algorithm.namedCurve!==r)throw ey(r,"algorithm.namedCurve");break}default:throw TypeError("CryptoKey does not support this operation")}if(r.length&&!r.some(t=>e.usages.includes(t))){let e="CryptoKey does not support this operation, its usages must include ";if(r.length>2){let t=r.pop();e+=`one of ${r.join(", ")}, or ${t}.`}else 2===r.length?e+=`one of ${r[0]} or ${r[1]}.`:e+=`${r[0]}.`;throw TypeError(e)}}(t,e,r),t;if(t instanceof Uint8Array){if(!e.startsWith("HS"))throw TypeError(eS(t,...ek));return et.subtle.importKey("raw",t,{hash:`SHA-${e.slice(-3)}`,name:"HMAC"},!1,[r])}throw TypeError(eS(t,...ek,"Uint8Array","JSON Web Key"))}var eJ=async(e,t,r,n)=>{let i=await eF(e,t,"verify");((e,t)=>{if(e.startsWith("RS")||e.startsWith("PS")){let{modulusLength:r}=t.algorithm;if("number"!=typeof r||r<2048)throw TypeError(`${e} requires key modulusLength to be 2048 bits or larger`)}})(e,i);let o=function(e,t){let r=`SHA-${e.slice(-3)}`;switch(e){case"HS256":case"HS384":case"HS512":return{hash:r,name:"HMAC"};case"PS256":case"PS384":case"PS512":return{hash:r,name:"RSA-PSS",saltLength:e.slice(-3)>>3};case"RS256":case"RS384":case"RS512":return{hash:r,name:"RSASSA-PKCS1-v1_5"};case"ES256":case"ES384":case"ES512":return{hash:r,name:"ECDSA",namedCurve:t.namedCurve};case"Ed25519":return{name:"Ed25519"};case"EdDSA":return{name:t.name};default:throw new ec(`alg ${e} is not supported either by JOSE or your javascript runtime`)}}(e,i.algorithm);try{return await et.subtle.verify(o,i,r,n)}catch{return!1}};async function eW(e,t,r){let n;if(!eA(e))throw new eu("Flattened JWS must be an object");if(void 0===e.protected&&void 0===e.header)throw new eu('Flattened JWS must have either of the "protected" or "header" members');if(void 0!==e.protected&&"string"!=typeof e.protected)throw new eu("JWS Protected Header incorrect type");if(void 0===e.payload)throw new eu("JWS Payload missing");if("string"!=typeof e.signature)throw new eu("JWS Signature missing or incorrect type");if(void 0!==e.header&&!eA(e.header))throw new eu("JWS Unprotected Header incorrect type");let i={};if(e.protected)try{let t=ei(e.protected);i=JSON.parse(en.decode(t))}catch{throw new eu("JWS Protected Header is invalid")}if(!((...e)=>{let t,r=e.filter(Boolean);if(0===r.length||1===r.length)return!0;for(let e of r){let r=Object.keys(e);if(!t||0===t.size){t=new Set(r);continue}for(let e of r){if(t.has(e))return!1;t.add(e)}}return!0})(i,e.header))throw new eu("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");let o={...i,...e.header},a=eK(eu,new Map([["b64",!0]]),r?.crit,i,o),s=!0;if(a.has("b64")&&"boolean"!=typeof(s=i.b64))throw new eu('The "b64" (base64url-encode payload) Header Parameter must be a boolean');let{alg:l}=o;if("string"!=typeof l||!l)throw new eu('JWS "alg" (Algorithm) Header Parameter missing or invalid');let c=r&&((e,t)=>{if(void 0!==t&&(!Array.isArray(t)||t.some(e=>"string"!=typeof e)))throw TypeError(`"${e}" option must be an array of strings`);if(t)return new Set(t)})("algorithms",r.algorithms);if(c&&!c.has(l))throw new el('"alg" (Algorithm) Header Parameter value not allowed');if(s){if("string"!=typeof e.payload)throw new eu("JWS Payload must be a string")}else if("string"!=typeof e.payload&&!(e.payload instanceof Uint8Array))throw new eu("JWS Payload must be a string or an Uint8Array instance");let u=!1;"function"==typeof t?(t=await t(i,e),u=!0,ez(l,t,"verify"),eT(t)&&(t=await eD(t,l))):ez(l,t,"verify");let h=function(...e){let t=new Uint8Array(e.reduce((e,{length:t})=>e+t,0)),r=0;for(let n of e)t.set(n,r),r+=n.length;return t}(er.encode(e.protected??""),er.encode("."),"string"==typeof e.payload?er.encode(e.payload):e.payload),f;try{f=ei(e.signature)}catch{throw new eu("Failed to base64url decode the signature")}if(!await eJ(l,t,f,h))throw new em;if(s)try{n=ei(e.payload)}catch{throw new eu("Failed to base64url decode the payload")}else n="string"==typeof e.payload?er.encode(e.payload):e.payload;let d={payload:n};
1return void 0!==e.protected&&(d.protectedHeader=i),void 0!==e.header&&(d.unprotectedHeader=e.header),u?{...d,key:t}:d}async function eH(e,t,r){if(e instanceof Uint8Array&&(e=en.decode(e)),"string"!=typeof e)throw new eu("Compact JWS must be a string or Uint8Array");let{0:n,1:i,2:o,length:a}=e.split(".");if(3!==a)throw new eu("Invalid Compact JWS");let s=await eW({payload:i,protected:n,signature:o},t,r),l={payload:s.payload,protectedHeader:s.protectedHeader};return"function"==typeof t?{...l,key:s.key}:l}var eq=/^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i,eV=e=>{let t=eq.exec(e);if(!t||t[4]&&t[1])throw TypeError("Invalid time period format");let r=parseFloat(t[2]),n;switch(t[3].toLowerCase()){case"sec":case"secs":case"second":case"seconds":case"s":n=Math.round(r);break;case"minute":case"minutes":case"min":case"mins":case"m":n=Math.round(60*r);break;case"hour":case"hours":case"hr":case"hrs":case"h":n=Math.round(3600*r);break;case"day":case"days":case"d":n=Math.round(86400*r);break;case"week":case"weeks":case"w":n=Math.round(604800*r);break;default:n=Math.round(0x1e187e0*r)}return"-"===t[1]||"ago"===t[4]?-n:n},eG=e=>e.toLowerCase().replace(/^application\//,"");async function eX(e,t,r){let n=await eH(e,t,r);if(n.protectedHeader.crit?.includes("b64")&&!1===n.protectedHeader.b64)throw new eh("JWTs MUST NOT use unencoded payload");let i={payload:((e,t,r={})=>{let n,i,o,a;try{n=JSON.parse(en.decode(t))}catch{}if(!eA(n))throw new eh("JWT Claims Set must be a top-level JSON object");let{typ:s}=r;if(s&&("string"!=typeof e.typ||eG(e.typ)!==eG(s)))throw new ea('unexpected "typ" JWT header value',n,"typ","check_failed");let{requiredClaims:l=[],issuer:c,subject:u,audience:h,maxTokenAge:f}=r,d=[...l];for(let e of(void 0!==f&&d.push("iat"),void 0!==h&&d.push("aud"),void 0!==u&&d.push("sub"),void 0!==c&&d.push("iss"),new Set(d.reverse())))if(!(e in n))throw new ea(`missing required "${e}" claim`,n,e,"missing");if(c&&!(Array.isArray(c)?c:[c]).includes(n.iss))throw new ea('unexpected "iss" claim value',n,"iss","check_failed");if(u&&n.sub!==u)throw new ea('unexpected "sub" claim value',n,"sub","check_failed");if(h&&(o=n.aud,a="string"==typeof h?[h]:h,"string"==typeof o?!a.includes(o):!(Array.isArray(o)&&a.some(Set.prototype.has.bind(new Set(o))))))throw new ea('unexpected "aud" claim value',n,"aud","check_failed");switch(typeof r.clockTolerance){case"string":i=eV(r.clockTolerance);break;case"number":i=r.clockTolerance;break;case"undefined":i=0;break;default:throw TypeError("Invalid clockTolerance option type")}let{currentDate:p}=r,g=Math.floor((p||new Date).getTime()/1e3);if((void 0!==n.iat||f)&&"number"!=typeof n.iat)throw new ea('"iat" claim must be a number',n,"iat","invalid");if(void 0!==n.nbf){if("number"!=typeof n.nbf)throw new ea('"nbf" claim must be a number',n,"nbf","invalid");if(n.nbf>g+i)throw new ea('"nbf" claim timestamp check failed',n,"nbf","check_failed")}if(void 0!==n.exp){if("number"!=typeof n.exp)throw new ea('"exp" claim must be a number',n,"exp","invalid");if(n.exp<=g-i)throw new es('"exp" claim timestamp check failed',n,"exp","check_failed")}if(f){let e=g-n.iat;if(e-i>("number"==typeof f?f:eV(f)))throw new es('"iat" claim timestamp check failed (too far in the past)',n,"iat","check_failed");if(e<0-i)throw new ea('"iat" claim timestamp check failed (it should be in the past)',n,"iat","check_failed")}return n})(n.protectedHeader,n.payload,r),protectedHeader:n.protectedHeader};return"function"==typeof t?{...i,key:n.key}:i}function eY(e){return eA(e)}function eQ(e){return"function"==typeof structuredClone?structuredClone(e):JSON.parse(JSON.stringify(e))}var eZ=class{constructor(e){if(this._cached=new WeakMap,!function(e){return e&&"object"==typeof e&&Array.isArray(e.keys)&&e.keys.every(eY)}(e))throw new ef("JSON Web Key Set malformed");this._jwks=eQ(e)}async getKey(e,t){let{alg:r,kid:n}={...e,...t?.header},i=function(e){switch("string"==typeof e&&e.slice(0,2)){case"RS":case"PS":return"RSA";case"ES":return"EC";case"Ed":return"OKP";
1default:throw new ec('Unsupported "alg" value for a JSON Web Key Set')}}(r),o=this._jwks.keys.filter(e=>{let t=i===e.kty;if(t&&"string"==typeof n&&(t=n===e.kid),t&&"string"==typeof e.alg&&(t=r===e.alg),t&&"string"==typeof e.use&&(t="sig"===e.use),t&&Array.isArray(e.key_ops)&&(t=e.key_ops.includes("verify")),t)switch(r){case"ES256":t="P-256"===e.crv;break;case"ES256K":t="secp256k1"===e.crv;break;case"ES384":t="P-384"===e.crv;break;case"ES512":t="P-521"===e.crv;break;case"Ed25519":t="Ed25519"===e.crv;break;case"EdDSA":t="Ed25519"===e.crv||"Ed448"===e.crv}return t}),{0:a,length:s}=o;if(0===s)throw new ed;if(1!==s){let e=new ep,{_cached:t}=this;throw e[Symbol.asyncIterator]=async function*(){for(let e of o)try{yield await e0(t,e,r)}catch{}},e}return e0(this._cached,a,r)}};async function e0(e,t,r){let n=e.get(t)||e.set(t,{}).get(t);if(void 0===n[r]){let e=await eD({...t,ext:!0},r);if(e instanceof Uint8Array||"public"!==e.type)throw new ef("JSON Web Key Set members must be public keys");n[r]=e}return n[r]}function e1(e){let t=new eZ(e),r=async(e,r)=>t.getKey(e,r);return Object.defineProperties(r,{jwks:{value:()=>eQ(t._jwks),enumerable:!0,configurable:!1,writable:!1}}),r}var e2=async(e,t,r)=>{let n,i,o=!1;"function"==typeof AbortController&&(n=new AbortController,i=setTimeout(()=>{o=!0,n.abort()},t));let a=await fetch(e.href,{signal:n?n.signal:void 0,redirect:"manual",headers:r.headers}).catch(e=>{throw o?new eg:e});if(void 0!==i&&clearTimeout(i),200!==a.status)throw new eo("Expected 200 OK from the JSON Web Key Set HTTP response");try{return await a.json()}catch{throw new eo("Failed to parse the JSON Web Key Set HTTP response as JSON")}};(typeof navigator>"u"||!navigator.userAgent?.startsWith?.("Mozilla/5.0 "))&&(e8="jose/v5.10.0");let e5=Symbol();var e8,e6,e3=class{constructor(e,t){if(!(e instanceof URL))throw TypeError("url must be an instance of URL");this._url=new URL(e.href),this._options={agent:t?.agent,headers:t?.headers},this._timeoutDuration="number"==typeof t?.timeoutDuration?t?.timeoutDuration:5e3,this._cooldownDuration="number"==typeof t?.cooldownDuration?t?.cooldownDuration:3e4,this._cacheMaxAge="number"==typeof t?.cacheMaxAge?t?.cacheMaxAge:6e5,t?.[e5]!==void 0&&(this._cache=t?.[e5],function(e,t){return!("object"!=typeof e||!e||!("uat"in e)||"number"!=typeof e.uat||Date.now()-e.uat>=t||!("jwks"in e)||!eA(e.jwks)||!Array.isArray(e.jwks.keys)||!Array.prototype.every.call(e.jwks.keys,eA))}(t?.[e5],this._cacheMaxAge)&&(this._jwksTimestamp=this._cache.uat,this._local=e1(this._cache.jwks)))}coolingDown(){return"number"==typeof this._jwksTimestamp&&Date.now()<this._jwksTimestamp+this._cooldownDuration}fresh(){return"number"==typeof this._jwksTimestamp&&Date.now()<this._jwksTimestamp+this._cacheMaxAge}async getKey(e,t){this._local&&this.fresh()||await this.reload();try{return await this._local(e,t)}catch(r){if(r instanceof ed&&!1===this.coolingDown())return await this.reload(),this._local(e,t);throw r}}async reload(){this._pendingFetch&&("u">typeof WebSocketPair||"u">typeof navigator&&"Cloudflare-Workers"===navigator.userAgent||"u">typeof EdgeRuntime&&"vercel"===EdgeRuntime)&&(this._pendingFetch=void 0);let e=new Headers(this._options.headers);e8&&!e.has("User-Agent")&&(e.set("User-Agent",e8),this._options.headers=Object.fromEntries(e.entries())),this._pendingFetch||=e2(this._url,this._timeoutDuration,this._options).then(e=>{this._local=e1(e),this._cache&&(this._cache.uat=Date.now(),this._cache.jwks=e),this._jwksTimestamp=Date.now(),this._pendingFetch=void 0}).catch(e=>{throw this._pendingFetch=void 0,e}),await this._pendingFetch}},e4=async(e,t,r,n,i=300)=>{if(Math.abs(((await eX(e,n,{audience:t,issuer:r,clockTolerance:i})).payload.iat??0)-Date.now()/1e3)>i)throw new Y("id_token.invalid_iat")},e9=class{constructor(e,t=300){this.client=e,this.clockTolerance=t}async verifyIdToken(e){let t,r,{appId:n}=this.client.logtoConfig,{issuer:i,jwksUri:o}=await this.client.getOidcConfig();this.getJwtVerifyGetKey||=(t=new e3(new URL(o),void 0),Object.defineProperties(r=async(e,r)=>t.getKey(e,r),{coolingDown:{get:()=>t.coolingDown(),enumerable:!0,configurable:!1},fresh:{get:()=>t.fresh(),enumerable:!0,configurable:!1},reload:{value:()=>t.reload(),enumerable:!0,configurable:!1,writable:!1},reloading:{get:()=>!!t._pendingFetch,enumerable:!0,configurable:!1},jwks:{value:()=>t._local?.jwks(),enumerable:!0,configurable:!1,writable:!1}}),r),await e4(e,n,i,this.getJwtVerifyGetKey,this.clockTolerance)}};(l=e6||={}).IdToken="idToken",l.RefreshToken="refreshToken",l.AccessToken="accessToken",l.SignInSession="sign
1InSession",(c=f||={}).OpenidConfig="openidConfiguration",c.Jwks="jwks";var e7=class{constructor(e){Object.assign(this,e)}async setStorageItem(e,t){t?await this.storage.setItem(e,t):await this.storage.removeItem(e)}async getCachedObject(e){let t=await (e=>{try{let t="function"==typeof e?e():e;return null!==t&&("object"==typeof t||"function"==typeof t)&&"then"in t&&"function"==typeof t.then?t.catch(e=>{}):t}catch(e){}})(async()=>{let t,r=await this.unstable_cache?.getItem(e);return(t=r&&JSON.parse(r))||void 0});if(t&&"object"==typeof t)return t}async getWithCache(e,t){let r=await this.getCachedObject(e);if(r)return r;let n=await t();return await this.unstable_cache?.setItem(e,JSON.stringify(n)),n}},te=Object.freeze({"sign_in_session.invalid":"Invalid sign-in session.","sign_in_session.not_found":"Sign-in session not found.",not_authenticated:"Not authenticated.",fetch_user_info_failed:"Unable to fetch user info. The access token may be invalid.",user_cancelled:"The user cancelled the action.",missing_scope_organizations:`The \`${M.Organizations}\` scope is required`}),tt=class extends Error{constructor(e,t){super(te[e]),this.name="LogtoClientError",this.code=e,this.data=t}},tr=(e="",t,r=[])=>{let n;return`${r.slice().sort().join(" ")}@${e}${(n=t&&`#${t}`)?String(n):""}`};function tn(e){let t=new Map;return async function(...r){let n=JSON.stringify(r),i=t.get(n);if(i)return i;let o=(async()=>{try{return await e.apply(this,r)}finally{t.delete(n)}})();return t.set(n,o),o}}var ti=class{get jwtVerifier(){return this.jwtVerifierInstance}constructor(e,t,r){this.getOidcConfig=function(e){let t=!1,r;return function(...n){return t||(t=!0,r=e.apply(this,n)),r}}(this.#e),this.getAccessToken=tn(this.#t),this.getOrganizationToken=tn(this.#r),this.clearAccessToken=tn(this.#n),this.clearAllTokens=tn(this.#i),this.handleSignInCallback=tn(this.#o),this.accessTokenMap=new Map,this.logtoConfig=(e=>{let{prompt:t=ex.Consent,scopes:r=[],resources:n,...i}=e,o=e.includeReservedScopes??!0;return{...i,prompt:t,scopes:o?H(r).split(" "):r,resources:r.includes(M.Organizations)?[...new Set([...n??[],$.Organization])]:n}})(e),this.adapter=new e7(t),this.jwtVerifierInstance=r(this),this.loadAccessTokenMap()}setJwtVerifier(e){this.jwtVerifierInstance="function"==typeof e?e(this):e}async isAuthenticated(){return!!await this.getIdToken()}async getRefreshToken(){return this.adapter.storage.getItem("refreshToken")}async getIdToken(){return this.adapter.storage.getItem("idToken")}async getIdTokenClaims(){let e=await this.getIdToken();if(!e)throw new tt("not_authenticated","ID token not found");return(e=>{let{1:t}=e.split(".");if(!t)throw new Y("id_token.invalid_token");let r=JSON.parse(V(t));return function(e){if(!G(e))throw TypeError("IdToken is expected to be an object");for(let t of["iss","sub","aud"])if("string"!=typeof e[t])throw TypeError(`At path: IdToken.${t}: expected a string`);for(let t of["exp","iat"])if("number"!=typeof e[t])throw TypeError(`At path: IdToken.${t}: expected a number`);for(let t of["at_hash","name","username","picture","email","phone_number"])if(void 0!==e[t]&&"string"!=typeof e[t]&&null!==e[t])throw TypeError(`At path: IdToken.${t}: expected null or a string`);for(let t of["email_verified","phone_number_verified"])if(void 0!==e[t]&&"boolean"!=typeof e[t])throw TypeError(`At path: IdToken.${t}: expected a boolean`)}(r),r})(e)}async getAccessTokenClaims(e){return ee(await this.getAccessToken(e))}async getOrganizationTokenClaims(e){return ee(await this.getOrganizationToken(e))}async fetchUserInfo(){let{userinfoEndpoint:e}=await this.getOidcConfig(),t=await this.getAccessToken();if(!t)throw new tt("fetch_user_info_failed");return q(e,t,this.adapter.requester)}async signIn(e,t,r){let{redirectUri:n,postRedirectUri:i,firstScreen:o,identifiers:a,interactionMode:s,loginHint:l,directSignIn:c,extraParams:u,prompt:h,clearTokens:f}="string"==typeof e||e instanceof URL?{redirectUri:e,postRedirectUri:void 0,firstScreen:void 0,identifiers:void 0,interactionMode:t,loginHint:r,directSignIn:void 0,extraParams:void 0,prompt:void 0,clearTokens:!0}:e,d=n.toString(),p=i?.toString(),{appId:g,prompt:m,resources:y,scopes:w}=this.logtoConfig,{authorizationEndpoint:b}=await this.getOidcConfig(),[v,S]=await Promise.all([this.adapter.generateCodeVerifier(),this.adapter.generateState()]),E=await this.adapter.generateCodeChallenge(v),_=(({authorizationEndpoint:e,clientId:t,redirectUri:r,codeChallenge:n,state:i,scopes:o,resources:a,prompt:s,firstScreen:l,identifiers:c,interactionMode:u,loginHint:h,directSignIn:f,oneTimeToken:d,extraParams:p,includeReservedScopes:g=!0})=>{let m=new URLSearchParams({[eI.ClientId]:t,[eI.RedirectUri]:r,[eI.C
1odeChallenge]:n,[eI.CodeChallengeMethod]:"S256",[eI.State]:i,[eI.ResponseType]:"code",[eI.Prompt]:Array.isArray(s)?s.join(" "):s??ex.Consent}),y=g?H(o):o?.join(" ");for(let e of(y&&m.append(eI.Scope,y),h&&m.append(eI.LoginHint,h),f&&m.append(eI.DirectSignIn,`${f.method}:${f.target}`),a??[]))m.append(eI.Resource,e);if(l?m.append(eI.FirstScreen,l):u&&m.append(eI.InteractionMode,u),c&&c.length>0&&m.append(eI.Identifier,c.join(" ")),d&&m.append(eI.OneTimeToken,d),p)for(let[e,t]of Object.entries(p))m.append(e,t);return`${e}?${m.toString()}`})({authorizationEndpoint:b,clientId:g,redirectUri:d.toString(),codeChallenge:E,state:S,scopes:w,resources:y,prompt:h??m,firstScreen:o,identifiers:a,interactionMode:s,loginHint:l,directSignIn:c,extraParams:u});await Promise.all([this.setSignInSession({redirectUri:d,postRedirectUri:p,codeVerifier:v,state:S}),!1===f?void 0:this.clearAllTokens()]),await this.adapter.navigate(_,{redirectUri:d,for:"sign-in"})}async isSignInRedirected(e){let t=await this.getSignInSession();if(!t)return!1;let{redirectUri:r}=t,{origin:n,pathname:i}=new URL(e);return`${n}${i}`===r}async signOut(e){let{appId:t}=this.logtoConfig,{endSessionEndpoint:r,revocationEndpoint:n}=await this.getOidcConfig(),i=await this.getRefreshToken();if(i)try{await W(n,t,i,this.adapter.requester)}catch{}let o=(({endSessionEndpoint:e,clientId:t,postLogoutRedirectUri:r})=>{let n=new URLSearchParams({[eI.ClientId]:t});return r&&n.append(eI.PostLogoutRedirectUri,r),`${e}?${n.toString()}`})({endSessionEndpoint:r,postLogoutRedirectUri:e,clientId:t});await this.clearAllTokens(),await this.adapter.navigate(o,{redirectUri:e,for:"sign-out"})}async getSignInSession(){let e=await this.adapter.storage.getItem("signInSession");if(!e)return null;let t=JSON.parse(e);if(!(G(t)&&["redirectUri","codeVerifier","state"].every(e=>"string"==typeof t[e])))throw new tt("sign_in_session.invalid");return t}async setSignInSession(e){return this.adapter.setStorageItem(e6.SignInSession,e&&JSON.stringify(e))}async setIdToken(e){return this.adapter.setStorageItem(e6.IdToken,e)}async setRefreshToken(e){return this.adapter.setStorageItem(e6.RefreshToken,e)}async getAccessTokenByRefreshToken(e,t){let r=await this.getRefreshToken();if(!r)throw new tt("not_authenticated","Refresh token not found");let n=tr(e,t),{appId:i}=this.logtoConfig,{tokenEndpoint:o}=await this.getOidcConfig(),a=Math.round(Date.now()/1e3),{accessToken:s,refreshToken:l,idToken:c,scope:u,expiresIn:h}=await F({clientId:i,tokenEndpoint:o,refreshToken:r,resource:e,organizationId:t},this.adapter.requester);return this.accessTokenMap.set(n,{token:s,scope:u,expiresAt:a+h}),await this.saveAccessTokenMap(),l&&await this.setRefreshToken(l),c&&(await this.jwtVerifier.verifyIdToken(c),await this.setIdToken(c)),s}async saveAccessTokenMap(){let e={};for(let[t,r]of this.accessTokenMap.entries())e[t]=r;await this.adapter.storage.setItem("accessToken",JSON.stringify(e))}async loadAccessTokenMap(){let e=await this.adapter.storage.getItem("accessToken");if(e)try{let t=JSON.parse(e);if(!(G(t)&&Object.values(t).every(e=>!!G(e)&&"string"==typeof e.token&&"string"==typeof e.scope&&"number"==typeof e.expiresAt)))return;for(let[e,r]of(this.accessTokenMap.clear(),Object.entries(t)))this.accessTokenMap.set(e,r)}catch(e){console.warn(e)}}async #e(){return this.adapter.getWithCache(f.OpenidConfig,async()=>J(new URL("/oidc/.well-known/openid-configuration",this.logtoConfig.endpoint).toString(),this.adapter.requester))}async #t(e,t){if(!await this.isAuthenticated())throw new tt("not_authenticated");let r=tr(e,t),n=this.accessTokenMap.get(r);return n&&n.expiresAt>Date.now()/1e3?n.token:(n&&this.accessTokenMap.delete(r),this.getAccessTokenByRefreshToken(e,t))}async #r(e){if(!this.logtoConfig.scopes?.includes(M.Organizations))throw new tt("missing_scope_organizations");return this.getAccessToken(void 0,e)}async #n(){this.accessTokenMap.clear(),await this.adapter.storage.removeItem("accessToken")}async #i(){await Promise.all([this.setRefreshToken(null),this.setIdToken(null),this.clearAccessToken()])}
1async #o(e){let t=await this.getSignInSession();if(!t)throw new tt("sign_in_session.not_found");let{redirectUri:r,postRedirectUri:n,state:i,codeVerifier:o}=t,a=((e,t,r)=>{let n,i;if(!e.startsWith(t))throw new Y("callback_uri_verification.redirect_uri_mismatched");let o=(e=>{let[,t=""]=e.split("?");return new URLSearchParams(t)})(e),a=(n=o.get(eI.Error))||void 0,s=(i=o.get(eI.ErrorDescription))||void 0;if(a)throw new Y("callback_uri_verification.error_found",new Z(a,s));let l=o.get(eI.State);if(!l)throw new Y("callback_uri_verification.missing_state");if(l!==r)throw new Y("callback_uri_verification.state_mismatched");let c=o.get(eI.Code);if(!c)throw new Y("callback_uri_verification.missing_code");return c})(e,r,i),s=tr(),{appId:l}=this.logtoConfig,{tokenEndpoint:c}=await this.getOidcConfig(),u=Math.round(Date.now()/1e3),{idToken:h,refreshToken:f,accessToken:d,scope:p,expiresIn:g}=await K({clientId:l,tokenEndpoint:c,redirectUri:r,codeVerifier:o,code:a},this.adapter.requester);await this.jwtVerifier.verifyIdToken(h),await this.setRefreshToken(f??null),await this.setIdToken(h),this.accessTokenMap.set(s,{token:d,scope:p,expiresAt:u+g}),await this.saveAccessTokenMap(),await this.setSignInSession(null),n&&await this.adapter.navigate(n,{for:"post-sign-in"})}},to=class extends ti{constructor(e,t,r){super(e,t,r??(e=>new e9(e)))}},ta="logto_cache",ts=class{constructor(e){this.appId=e}getKey(e){return void 0===e?`${ta}:${this.appId}`:`${ta}:${this.appId}:${e}`}async getItem(e){return sessionStorage.getItem(this.getKey(e))}async setItem(e,t){sessionStorage.setItem(this.getKey(e),t)}async removeItem(e){sessionStorage.removeItem(`${this.getKey(e)}`)}},tl="logto",tc=class{constructor(e){this.appId=e}getKey(e){return void 0===e?`${tl}:${this.appId}`:`${tl}:${this.appId}:${e}`}async getItem(e){return typeof window>"u"?null:"signInSession"===e?sessionStorage.getItem(this.getKey(e))??sessionStorage.getItem(this.getKey()):localStorage.getItem(this.getKey(e))}async setItem(e,t){if(!(typeof window>"u")){if("signInSession"===e)return void sessionStorage.setItem(this.getKey(e),t);localStorage.setItem(this.getKey(e),t)}}async removeItem(e){if(!(typeof window>"u")){if("signInSession"===e)return void sessionStorage.removeItem(this.getKey(e));localStorage.removeItem(this.getKey(e))}}},tu="function"==typeof p.Buffer;"function"==typeof TextDecoder&&new TextDecoder,"function"==typeof TextEncoder&&new TextEncoder;var th=Array.prototype.slice.call("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=");t={},th.forEach((e,r)=>t[e]=r);var tf=String.fromCharCode.bind(String);"function"==typeof Uint8Array.from&&Uint8Array.from.bind(Uint8Array);var td="function"==typeof btoa?e=>btoa(e):tu?e=>p.Buffer.from(e,"binary").toString("base64"):e=>{let t,r,n,i,o="",a=e.length%3;for(let a=0;a<e.length;){if((r=e.charCodeAt(a++))>255||(n=e.charCodeAt(a++))>255||(i=e.charCodeAt(a++))>255)throw TypeError("invalid character found");o+=th[(t=r<<16|n<<8|i)>>18&63]+th[t>>12&63]+th[t>>6&63]+th[63&t]}return a?o.slice(0,a-3)+"===".substring(a):o},tp=tu?e=>p.Buffer.from(e).toString("base64"):e=>{let t=[];for(let r=0,n=e.length;r<n;r+=4096)t.push(tf.apply(null,e.subarray(r,r+4096)));return td(t.join(""))},tg=(e,t=!1)=>t?tp(e).replace(/=/g,"").replace(/[+\/]/g,e=>"+"==e?"-":"_"):tp(e),tm=(e=64)=>tg(crypto.getRandomValues(new Uint8Array(e)),!0),ty=()=>tm(),tw=()=>tm(),tb=async e=>{if(void 0===crypto.subtle)throw new Y("crypto_subtle_unavailable");let t=new TextEncoder().encode(e);return tg(new Uint8Array(await crypto.subtle.digest("SHA-256",t)),!0)},tv=e=>{window.location.assign(e)},tS=class extends to{constructor(e,t=!1){super(e,{requester:(e=>async(...t)=>{let r=await e(...t);if(!r.ok){let e=r.clone(),t=await r.json();if(console.error(`Logto requester error: [status=${r.status}]`,t),!(G(t)&&"string"==typeof t.code&&"string"==typeof t.message))throw new Y("unexpected_response_error",t);let{code:n,message:i}=t;throw new Q(n,i,e)}return r.json()})(fetch),navigate:tv,storage:new tc(e.appId),unstable_cache:(e=>e||void 0)(t&&new ts(e.appId)),generateCodeChallenge:tb,generateCodeVerifier:tw,generateState:ty})}};function tE(e,t){return function(){return e.apply(t,arguments)}}var{toString:t_}=Object.prototype,{getPrototypeOf:tk}=Object,{iterator:tA,toStringTag:tT}=Symbol,tR=(r=Object.create(null),e=>{let t=t_.call(e);return r[t]||(r[t]=t.slice(8,-1).toLowerCase())}),tO=e=>(e=e.toLowerCase(),t=>tR(t)===e),tC=e=>t=>typeof t===e,{isArray:tI}=Array,tx=tC("undefined");function tU(e){return null!==e&&!tx(e)&&null!==e.constructor&&!tx(e.constructor)&&tL(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var tP=tO("ArrayBuffer"),tj=tC("string"),tL=tC("function"),tN=tC("number"),tD=e=>"object"==typeof e&&!!e,t$=e=>{if("object"!==tR(e))return!1;let t=tk(e);return(null===t||t===Object.prototype||null===Object.getPrototypeOf(t))&&!(tT in e)&&!(tA in e)},tM=tO("Date"),tB=tO("File"),tz=tO("Blob"),tK=tO("FileList"),tF="u">typeof globalThis?globalThis:"u">typeof self?self:"u">typeof window?window:e.g,tJ=void 0===tF.FormData?void 0:tF.FormData,tW=tO("URLSearchParams"),[tH,tq,tV,tG]=["ReadableStream","Request","Response","Headers"].map(tO);function tX(e,t,{allOwnKeys:r=!1}={}){let n,i;if(null!=e)if("object"!=typeof e&&(e=[e]),tI(e))for(n=0,i=e.length;n<i;n++)t.call(null,e[n],n,e);else{if(tU(e))return;let i=r?Object.getOwnPropertyNames(e):Object.keys(e),o=i.length,a;for(n=0;n<o;n++)a=i[n],t.call(null,e[a],a,e)}}function tY(e,t){if(tU(e))return null;t=t.toLowerCase();let r=Object.keys(e),n=r.length,i;for(;n-- >0;)if(t===(i=r[n]).toLowerCase())return i;return null}var tQ="u">typeof globalThis?globalThis:"u">typeof self?self:"u">typeof window?window:e.g,tZ=e=>!tx(e)&&e!==tQ,t0=(n="u">typeof Uint8Array&&tk(Uint8Array),e=>n&&e instanceof n),t1=tO("HTMLFormElement"),t2=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),t5=tO("RegExp"),t8=(e,t)=>
1{let r=Object.getOwnPropertyDescriptors(e),n={};tX(r,(r,i)=>{let o;!1!==(o=t(r,i,e))&&(n[i]=o||r)}),Object.defineProperties(e,n)},t6=tO("AsyncFunction"),t3=(u="function"==typeof setImmediate,h=tL(tQ.postMessage),u?setImmediate:h?(i=`axios@${Math.random()}`,o=[],tQ.addEventListener("message",({source:e,data:t})=>{e===tQ&&t===i&&o.length&&o.shift()()},!1),e=>{o.push(e),tQ.postMessage(i,"*")}):e=>setTimeout(e)),t4={isArray:tI,isArrayBuffer:tP,isBuffer:tU,isFormData:e=>{let t;return e&&(tJ&&e instanceof tJ||tL(e.append)&&("formdata"===(t=tR(e))||"object"===t&&tL(e.toString)&&"[object FormData]"===e.toString()))},isArrayBufferView:function(e){return"u">typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&tP(e.buffer)},isString:tj,isNumber:tN,isBoolean:e=>!0===e||!1===e,isObject:tD,isPlainObject:t$,isEmptyObject:e=>{if(!tD(e)||tU(e))return!1;try{return 0===Object.keys(e).length&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},isReadableStream:tH,isRequest:tq,isResponse:tV,isHeaders:tG,isUndefined:tx,isDate:tM,isFile:tB,isReactNativeBlob:e=>!!(e&&void 0!==e.uri),isReactNative:e=>e&&void 0!==e.getParts,isBlob:tz,isRegExp:t5,isFunction:tL,isStream:e=>tD(e)&&tL(e.pipe),isURLSearchParams:tW,isTypedArray:t0,isFileList:tK,forEach:tX,merge:function e(){let{caseless:t,skipUndefined:r}=tZ(this)&&this||{},n={},i=(i,o)=>{if("__proto__"===o||"constructor"===o||"prototype"===o)return;let a=t&&tY(n,o)||o;t$(n[a])&&t$(i)?n[a]=e(n[a],i):t$(i)?n[a]=e({},i):tI(i)?n[a]=i.slice():r&&tx(i)||(n[a]=i)};for(let e=0,t=arguments.length;e<t;e++)arguments[e]&&tX(arguments[e],i);return n},extend:(e,t,r,{allOwnKeys:n}={})=>(tX(t,(t,n)=>{r&&tL(t)?Object.defineProperty(e,n,{value:tE(t,r),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(e,n,{value:t,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:n}),e),trim:e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:e=>(65279===e.charCodeAt(0)&&(e=e.slice(1)),e),inherits:(e,t,r,n)=>{e.prototype=Object.create(t.prototype,n),Object.defineProperty(e.prototype,"constructor",{value:e,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},toFlatObject:(e,t,r,n)=>{let i,o,a,s={};if(t||={},null==e)return t;do{for(o=(i=Object.getOwnPropertyNames(e)).length;o-- >0;)a=i[o],(!n||n(a,e,t))&&!s[a]&&(t[a]=e[a],s[a]=!0);e=!1!==r&&tk(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype)return t},kindOf:tR,kindOfTest:tO,endsWith:(e,t,r)=>{e=String(e),(void 0===r||r>e.length)&&(r=e.length),r-=t.length;let n=e.indexOf(t,r);return -1!==n&&n===r},toArray:e=>{if(!e)return null;if(tI(e))return e;let t=e.length;if(!tN(t))return null;let r=Array(t);for(;t-- >0;)r[t]=e[t];return r},forEachEntry:(e,t)=>{let r=(e&&e[tA]).call(e),n;for(;(n=r.next())&&!n.done;){let r=n.value;t.call(e,r[0],r[1])}},matchAll:(e,t)=>{let r,n=[];for(;null!==(r=e.exec(t));)n.push(r);return n},isHTMLForm:t1,hasOwnProperty:t2,hasOwnProp:t2,reduceDescriptors:t8,freezeMethods:e=>{t8(e,(t,r)=>{if(tL(e)&&-1!==["arguments","caller","callee"].indexOf(r))return!1;if(tL(e[r])){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||=()=>{throw Error("Can not rewrite read-only method '"+r+"'")}}})},toObjectSet:(e,t)=>{let r={};return(tI(e)?e:String(e).split(t)).forEach(e=>{r[e]=!0}),r},toCamelCase:e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(e,t,r){return t.toUpperCase()+r}),noop:()=>{},toFiniteNumber:(e,t)=>null!=e&&Number.isFinite(e*=1)?e:t,findKey:tY,global:tQ,isContextDefined:tZ,isSpecCompliantForm:function(e){return!!(e&&tL(e.append)&&"FormData"===e[tT]&&e[tA])},toJSONObject:e=>{let t=Array(10),r=(e,n)=>{if(tD(e)){if(t.indexOf(e)>=0)return;if(tU(e))return e;if(!("toJSON"in e)){t[n]=e;let i=tI(e)?[]:{};return tX(e,(e,t)=>{let o=r(e,n+1);tx(o)||(i[t]=o)}),t[n]=void 0,i}}return e};return r(e,0)},isAsyncFn:t6,isThenable:e=>e&&(tD(e)||tL(e))&&tL(e.then)&&tL(e.catch),setImmediate:t3,asap:"u">typeof queueMicrotask?queueMicrotask.bind(tQ):"u">typeof d.default&&d.default.nextTick||t3,isIterable:e=>null!=e&&tL(e[tA])}
1,t9=class e extends Error{static from(t,r,n,i,o,a){let s=new e(t.message,r||t.code,n,i,o);return s.cause=t,s.name=t.name,null!=t.status&&null==s.status&&(s.status=t.status),a&&Object.assign(s,a),s}constructor(e,t,r,n,i){super(e),Object.defineProperty(this,"message",{value:e,enumerable:!0,writable:!0,configurable:!0}),this.name="AxiosError",this.isAxiosError=!0,t&&(this.code=t),r&&(this.config=r),n&&(this.request=n),i&&(this.response=i,this.status=i.status)}toJSON(){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:t4.toJSONObject(this.config),code:this.code,status:this.status}}};t9.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE",t9.ERR_BAD_OPTION="ERR_BAD_OPTION",t9.ECONNABORTED="ECONNABORTED",t9.ETIMEDOUT="ETIMEDOUT",t9.ERR_NETWORK="ERR_NETWORK",t9.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS",t9.ERR_DEPRECATED="ERR_DEPRECATED",t9.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE",t9.ERR_BAD_REQUEST="ERR_BAD_REQUEST",t9.ERR_CANCELED="ERR_CANCELED",t9.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT",t9.ERR_INVALID_URL="ERR_INVALID_URL";var t7=t9;function re(e){return t4.isPlainObject(e)||t4.isArray(e)}function rt(e){return t4.endsWith(e,"[]")?e.slice(0,-2):e}function rr(e,t,r){return e?e.concat(t).map(function(e,t){return e=rt(e),!r&&t?"["+e+"]":e}).join(r?".":""):t}var rn=t4.toFlatObject(t4,{},null,function(e){return/^is[A-Z]/.test(e)}),ri=function(e,t,r){if(!t4.isObject(e))throw TypeError("target must be an object");t||=new FormData;let n=(r=t4.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(e,t){return!t4.isUndefined(t[e])})).metaTokens,i=r.visitor||c,o=r.dots,a=r.indexes,s=(r.Blob||"u">typeof Blob&&Blob)&&t4.isSpecCompliantForm(t);if(!t4.isFunction(i))throw TypeError("visitor must be a function");function l(e){if(null===e)return"";if(t4.isDate(e))return e.toISOString();if(t4.isBoolean(e))return e.toString();if(!s&&t4.isBlob(e))throw new t7("Blob is not supported. Use a Buffer instead.");return t4.isArrayBuffer(e)||t4.isTypedArray(e)?s&&"function"==typeof Blob?new Blob([e]):p.Buffer.from(e):e}function c(e,r,i){let s=e;if(t4.isReactNative(t)&&t4.isReactNativeBlob(e))return t.append(rr(i,r,o),l(e)),!1;if(e&&!i&&"object"==typeof e)if(t4.endsWith(r,"{}"))r=n?r:r.slice(0,-2),e=JSON.stringify(e);else{var c;if(t4.isArray(e)&&(c=e,t4.isArray(c)&&!c.some(re))||(t4.isFileList(e)||t4.endsWith(r,"[]"))&&(s=t4.toArray(e)))return r=rt(r),s.forEach(function(e,n){t4.isUndefined(e)||null===e||t.append(!0===a?rr([r],n,o):null===a?r:r+"[]",l(e))}),!1}return!!re(e)||(t.append(rr(i,r,o),l(e)),!1)}let u=[],h=Object.assign(rn,{defaultVisitor:c,convertValue:l,isVisitable:re});if(!t4.isObject(e))throw TypeError("data must be an object");return function e(r,n){if(!t4.isUndefined(r)){if(-1!==u.indexOf(r))throw Error("Circular reference detected in "+n.join("."));u.push(r),t4.forEach(r,function(r,o){(!(t4.isUndefined(r)||null===r)&&i.call(t,r,t4.isString(o)?o.trim():o,n,h))===!0&&e(r,n?n.concat(o):[o])}),u.pop()}}(e),t};function ro(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(e){return t[e]})}function ra(e,t){this._pairs=[],e&&ri(e,this,t)}var rs=ra.prototype;function rl(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function rc(e,t,r){if(!t)return e;let n=r&&r.encode||rl,i=t4.isFunction(r)?{serialize:r}:r,o=i&&i.serialize,a;if(a=o?o(t,i):t4.isURLSearchParams(t)?t.toString():new ra(t,i).toString(n)){let t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+a}return e}rs.append=function(e,t){this._pairs.push([e,t])},rs.toString=function(e){let t=e?function(t){return e.call(this,t,ro)}:ro;return this._pairs.map(function(e){return t(e[0])+"="+t(e[1])},"").join("&")};var ru=class{constructor(){this.handlers=[]}use(e,t,r){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!r&&r.synchronous,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&=[]}forEach(e){t4.forEach(this.handlers,function(t){null!==t&&e(t)})}},rh={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0}
1,rf={isBrowser:!0,classes:{URLSearchParams:"u">typeof URLSearchParams?URLSearchParams:ra,FormData:"u">typeof FormData?FormData:null,Blob:"u">typeof Blob?Blob:null},protocols:["http","https","file","blob","url","data"]},rd=(e=>{let t={};for(var r in e)g(t,r,{get:e[r],enumerable:!0});return t})({hasBrowserEnv:()=>rp,hasStandardBrowserEnv:()=>rm,hasStandardBrowserWebWorkerEnv:()=>ry,navigator:()=>rg,origin:()=>rw}),rp="u">typeof window&&"u">typeof document,rg="object"==typeof navigator&&navigator||void 0,rm=rp&&(!rg||0>["ReactNative","NativeScript","NS"].indexOf(rg.product)),ry="u">typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,rw=rp&&window.location.href||"http://localhost",rb={...rd,...rf},rv=function(e){if(t4.isFormData(e)&&t4.isFunction(e.entries)){let t={};return t4.forEachEntry(e,(e,r)=>{!function e(t,r,n,i){let o=t[i++];if("__proto__"===o)return!0;let a=Number.isFinite(+o),s=i>=t.length;return o=!o&&t4.isArray(n)?n.length:o,s?t4.hasOwnProp(n,o)?n[o]=[n[o],r]:n[o]=r:(n[o]&&t4.isObject(n[o])||(n[o]=[]),e(t,r,n[o],i)&&t4.isArray(n[o])&&(n[o]=function(e){let t={},r=Object.keys(e),n,i=r.length,o;for(n=0;n<i;n++)t[o=r[n]]=e[o];return t}(n[o]))),!a}(t4.matchAll(/\w+|\[(\w*)]/g,e).map(e=>"[]"===e[0]?"":e[1]||e[0]),r,t,0)}),t}return null},rS={transitional:rh,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){let r,n=t.getContentType()||"",i=n.indexOf("application/json")>-1,o=t4.isObject(e);if(o&&t4.isHTMLForm(e)&&(e=new FormData(e)),t4.isFormData(e))return i?JSON.stringify(rv(e)):e;if(t4.isArrayBuffer(e)||t4.isBuffer(e)||t4.isStream(e)||t4.isFile(e)||t4.isBlob(e)||t4.isReadableStream(e))return e;if(t4.isArrayBufferView(e))return e.buffer;if(t4.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();if(o){if(n.indexOf("application/x-www-form-urlencoded")>-1){var a,s;return(a=e,s=this.formSerializer,ri(a,new rb.classes.URLSearchParams,{visitor:function(e,t,r,n){return rb.isNode&&t4.isBuffer(e)?(this.append(t,e.toString("base64")),!1):n.defaultVisitor.apply(this,arguments)},...s})).toString()}if((r=t4.isFileList(e))||n.indexOf("multipart/form-data")>-1){let t=this.env&&this.env.FormData;return ri(r?{"files[]":e}:e,t&&new t,this.formSerializer)}}return o||i?(t.setContentType("application/json",!1),function(e){if(t4.isString(e))try{return(0,JSON.parse)(e),t4.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(0,JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){let t=this.transitional||rS.transitional,r=t&&t.forcedJSONParsing,n="json"===this.responseType;if(t4.isResponse(e)||t4.isReadableStream(e))return e;if(e&&t4.isString(e)&&(r&&!this.responseType||n)){let r=!(t&&t.silentJSONParsing)&&n;try{return JSON.parse(e,this.parseReviver)}catch(e){if(r)throw"SyntaxError"===e.name?t7.from(e,t7.ERR_BAD_RESPONSE,this,null,this.response):e}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:rb.classes.FormData,Blob:rb.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};t4.forEach(["delete","get","head","post","put","patch"],e=>{rS.headers[e]={}});var rE=t4.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"]),r_=Symbol("internals");function rk(e){return e&&String(e).trim().toLowerCase()}function rA(e){return!1===e||null==e?e:t4.isArray(e)?e.map(rA):function(e){let t=e.length;for(;t>0;){let r=e.charCodeAt(t-1);if(10!==r&&13!==r)break;--t}return t===e.length?e:e.slice(0,t)}(String(e))}function rT(e,t,r,n,i){if(t4.isFunction(n))return n.call(this,t,r);if(i&&(t=r),t4.isString(t)){if(t4.isString(n))return -1!==t.indexOf(n);if(t4.isRegExp(n))return n.test(t)}}var rR=class{constructor(e){e&&this.set(e)}set(e,t,r){let n=this;function i(e,t,r){let i=rk(t);if(!i)throw Error("header name must be a non-empty string");let o=t4.findKey(n,i);o&&void 0!==n[o]&&!0!==r&&(void 0!==r||!1===n[o])||(function e(t,r){if(!1!==t&&null!=t){let n;if(t4.isArray(t))return void t.forEach(t=>e(t,r));if(n=String(t),/[\r\n]/.test(n))throw Error(`Invalid character in header content ["${r}"]`)}}(e,t),n[o||t]=rA(e))}let o=(e,t)=>t4.forEach(e,(e,r)=>i(e,r,t));if(t4.isPlainObject(e)||e instanceof this.constructor)o(e,t);else{let n;if(t4.isString(e)&&(e=e.trim())&&(n=e,!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(n.trim()))){var a;let r,n,i,s;o((r={},(a=e)&&a.split("\n").forEach(function(e){s=e.indexOf(":"),n=e.substring(0,s).trim().toLowerCase(),i=e.substring(s+1).trim(),!n||r[n]&&rE[n]||("set-cookie"===n?r[n]?r[n].push(i):r[n]=[i]:r[n]=r[n]?r[n]+", "+i:i)}),r),t)}else if(t4.isObject(e)&&t4.isIterable(e)){let r={},n,i;for(let t of e){if(!t4.isArray(t))throw TypeError("Object iterator must return a key-value pair");r[i=t[0]]=(n=r[i])?t4.isArray(n)?[...n,t[1]]:[n,t[1]]:t[1]}o(r,t)}else null!=e&&i(t,e,r)}return this}get(e,t){if(e=rk(e)){let r=t4.findKey(this,e);if(r){let e=this[r];if(!t)return e;if(!0===t){let t=Object.create(null),r=/([^\s,;
1=]+)\s*(?:=\s*([^,;]+))?/g,n;for(;n=r.exec(e);)t[n[1]]=n[2];return t}if(t4.isFunction(t))return t.call(this,e,r);if(t4.isRegExp(t))return t.exec(e);throw TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=rk(e)){let r=t4.findKey(this,e);return!!(r&&void 0!==this[r]&&(!t||rT(this,this[r],r,t)))}return!1}delete(e,t){let r=this,n=!1;function i(e){if(e=rk(e)){let i=t4.findKey(r,e);i&&(!t||rT(r,r[i],i,t))&&(delete r[i],n=!0)}}return t4.isArray(e)?e.forEach(i):i(e),n}clear(e){let t=Object.keys(this),r=t.length,n=!1;for(;r--;){let i=t[r];(!e||rT(this,this[i],i,e,!0))&&(delete this[i],n=!0)}return n}normalize(e){let t=this,r={};return t4.forEach(this,(n,i)=>{let o=t4.findKey(r,i);if(o){t[o]=rA(n),delete t[i];return}let a=e?i.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,r)=>t.toUpperCase()+r):String(i).trim();a!==i&&delete t[i],t[a]=rA(n),r[a]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){let t=Object.create(null);return t4.forEach(this,(r,n)=>{null!=r&&!1!==r&&(t[n]=e&&t4.isArray(r)?r.join(", "):r)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,t])=>e+": "+t).join("\n")}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){let r=new this(e);return t.forEach(e=>r.set(e)),r}static accessor(e){let t=(this[r_]=this[r_]={accessors:{}}).accessors,r=this.prototype;function n(e){let n,i=rk(e);t[i]||(n=t4.toCamelCase(" "+e),["get","set","has"].forEach(t=>{Object.defineProperty(r,t+n,{value:function(r,n,i){return this[t].call(this,e,r,n,i)},configurable:!0})}),t[i]=!0)}return t4.isArray(e)?e.forEach(n):n(e),this}};function rO(e,t){let r=this||rS,n=t||r,i=rR.from(n.headers),o=n.data;return t4.forEach(e,function(e){o=e.call(r,o,i.normalize(),t?t.status:void 0)}),i.normalize(),o}function rC(e){return!!(e&&e.__CANCEL__)}rR.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),t4.reduceDescriptors(rR.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[r]=e}}}),t4.freezeMethods(rR);var rI=class extends t7{constructor(e,t,r){super(e??"canceled",t7.ERR_CANCELED,t,r),this.name="CanceledError",this.__CANCEL__=!0}};function rx(e,t,r){let n=r.config.validateStatus;!r.status||!n||n(r.status)?e(r):t(new t7("Request failed with status code "+r.status,[t7.ERR_BAD_REQUEST,t7.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}var rU=function(e,t){let r=Array(e||=10),n=Array(e),i=0,o=0,a;return t=void 0===t?1e3:t,function(s){let l=Date.now(),c=n[o];a||=l,r[i]=s,n[i]=l;let u=o,h=0;for(;u!==i;)h+=r[u++],u%=e;if((i=(i+1)%e)===o&&(o=(o+1)%e),l-a<t)return;let f=c&&l-c;return f?Math.round(1e3*h/f):void 0}},rP=function(e,t){let r=0,n=1e3/t,i,o,a=(t,n=Date.now())=>{r=n,i=null,o&&=(clearTimeout(o),null),e(...t)};return[(...e)=>{let t=Date.now(),s=t-r;s>=n?a(e,t):(i=e,o||=setTimeout(()=>{o=null,a(i)},n-s))},()=>i&&a(i)]};let rj=(e,t,r=3)=>{let n=0,i=rU(50,250);return rP(r=>{let o=r.loaded,a=r.lengthComputable?r.total:void 0,s=o-n,l=i(s),c=o<=a;n=o,e({loaded:o,total:a,progress:a?o/a:void 0,bytes:s,rate:l||void 0,estimated:l&&a&&c?(a-o)/l:void 0,event:r,lengthComputable:null!=a,[t?"download":"upload"]:!0})},r)},rL=(e,t)=>{let r=null!=e;return[n=>t[0]({lengthComputable:r,total:e,loaded:n}),t[1]]},rN=e=>(...t)=>t4.asap(()=>e(...t));var rD=rb.hasStandardBrowserEnv?(a=new URL(rb.origin),s=rb.navigator&&/(msie|trident)/i.test(rb.navigator.userAgent),e=>(e=new URL(e,rb.origin),a.protocol===e.protocol&&a.host===e.host&&(s||a.port===e.port))):()=>!0,r$=rb.hasStandardBrowserEnv?{write(e,t,r,n,i,o,a){if(typeof document>"u")return;let s=[`${e}=${encodeURIComponent(t)}`];t4.isNumber(r)&&s.push(`expires=${new Date(r).toUTCString()}`),t4.isString(n)&&s.push(`path=${n}`),t4.isString(i)&&s.push(`domain=${i}`),!0===o&&s.push("secure"),t4.isString(a)&&s.push(`SameSite=${a}`),document.cookie=s.join("; ")},read(e){if(typeof document>"u")return null;let t=document.cookie.match(RegExp("(?:^|; )"+e+"=([^;]*)"));return t?decodeURIComponent(t[1]):null},remove(e){this.write(e,"",Date.now()-864e5,"/")}}:{write(){},read:()=>null,remove(){}};function rM(e,t,r){let n=!("string"==typeof t&&/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t));return e&&(n||0==r)?t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e:t}var rB=e=>e instanceof rR?{...e}:e;function rz(e,t){t||={};let r={};function n(e,t,r,n){return t4.isPlainObject(e)&&t4.isPlainObject(t)?t4.merge.call({caseless:n},e,t):t4.isPlainObject(t)?t4.merge({},t):t4.isArray(t)?t.slice():t}function i(e,t,r,i){return t4.isUndefined(t)?t4.isUndefined(e)?void 0:n(void 0,e,r,i):n(e,t,r,i)}function o(e,t){if(!t4.isUndefined(t))return n(void 0,t)}function a(e,t){return t4.isUndefined(t)?t4.isUndefined(e)?void 0:n(void 0,e):n(void 0,t)}function s(r,i,o){return o in t?n(r,i):o in e?n(void 0,r):void 0}let l={url:o,method:o,data:o,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,maxBo
1dyLength:a,beforeRedirect:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:s,headers:(e,t,r)=>i(rB(e),rB(t),r,!0)};return t4.forEach(Object.keys({...e,...t}),function(n){if("__proto__"===n||"constructor"===n||"prototype"===n)return;let o=t4.hasOwnProp(l,n)?l[n]:i,a=o(e[n],t[n],n);t4.isUndefined(a)&&o!==s||(r[n]=a)}),r}var rK=e=>{let t=rz({},e),{data:r,withXSRFToken:n,xsrfHeaderName:i,xsrfCookieName:o,headers:a,auth:s}=t;if(t.headers=a=rR.from(a),t.url=rc(rM(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),s&&a.set("Authorization","Basic "+btoa((s.username||"")+":"+(s.password?unescape(encodeURIComponent(s.password)):""))),t4.isFormData(r)){if(rb.hasStandardBrowserEnv||rb.hasStandardBrowserWebWorkerEnv)a.setContentType(void 0);else if(t4.isFunction(r.getHeaders)){let e=r.getHeaders(),t=["content-type","content-length"];Object.entries(e).forEach(([e,r])=>{t.includes(e.toLowerCase())&&a.set(e,r)})}}if(rb.hasStandardBrowserEnv&&(n&&t4.isFunction(n)&&(n=n(t)),n||!1!==n&&rD(t.url))){let e=i&&o&&r$.read(o);e&&a.set(i,e)}return t},rF="u">typeof XMLHttpRequest&&function(e){return new Promise(function(t,r){var n;let i,o=rK(e),a=o.data,s=rR.from(o.headers).normalize(),{responseType:l,onUploadProgress:c,onDownloadProgress:u}=o,h,f,d,p,g;function m(){p&&p(),g&&g(),o.cancelToken&&o.cancelToken.unsubscribe(h),o.signal&&o.signal.removeEventListener("abort",h)}let y=new XMLHttpRequest;function w(){if(!y)return;let n=rR.from("getAllResponseHeaders"in y&&y.getAllResponseHeaders());rx(function(e){t(e),m()},function(e){r(e),m()},{data:l&&"text"!==l&&"json"!==l?y.response:y.responseText,status:y.status,statusText:y.statusText,headers:n,config:e,request:y}),y=null}y.open(o.method.toUpperCase(),o.url,!0),y.timeout=o.timeout,"onloadend"in y?y.onloadend=w:y.onreadystatechange=function(){y&&4===y.readyState&&(0!==y.status||y.responseURL&&0===y.responseURL.indexOf("file:"))&&setTimeout(w)},y.onabort=function(){y&&=(r(new t7("Request aborted",t7.ECONNABORTED,e,y)),null)},y.onerror=function(t){let n=new t7(t&&t.message?t.message:"Network Error",t7.ERR_NETWORK,e,y);n.event=t||null,r(n),y=null},y.ontimeout=function(){let t=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded",n=o.transitional||rh;o.timeoutErrorMessage&&(t=o.timeoutErrorMessage),r(new t7(t,n.clarifyTimeoutError?t7.ETIMEDOUT:t7.ECONNABORTED,e,y)),y=null},void 0===a&&s.setContentType(null),"setRequestHeader"in y&&t4.forEach(s.toJSON(),function(e,t){y.setRequestHeader(t,e)}),t4.isUndefined(o.withCredentials)||(y.withCredentials=!!o.withCredentials),l&&"json"!==l&&(y.responseType=o.responseType),u&&([d,g]=rj(u,!0),y.addEventListener("progress",d)),c&&y.upload&&([f,p]=rj(c),y.upload.addEventListener("progress",f),y.upload.addEventListener("loadend",p)),(o.cancelToken||o.signal)&&(h=t=>{y&&=(r(!t||t.type?new rI(null,e,y):t),y.abort(),null)},o.cancelToken&&o.cancelToken.subscribe(h),o.signal&&(o.signal.aborted?h():o.signal.addEventListener("abort",h)));let b=(n=o.url,(i=/^([-+\w]{1,25})(:?\/\/|:)/.exec(n))&&i[1]||"");b&&-1===rb.protocols.indexOf(b)?r(new t7("Unsupported protocol "+b+":",t7.ERR_BAD_REQUEST,e)):y.send(a||null)})};let rJ=function*(e,t){let r=e.byteLength;if(!t||r<t)return void(yield e);let n=0,i;for(;n<r;)i=n+t,yield e.slice(n,i),n=i},rW=async function*(e,t){for await(let r of rH(e))yield*rJ(r,t)};var rH=async function*(e){if(e[Symbol.asyncIterator])return void(yield*e);let t=e.getReader();try{for(;;){let{done:e,value:r}=await t.read();if(e)break;yield r}}finally{await t.cancel()}};let rq=(e,t,r,n)=>{let i=rW(e,t),o=0,a,s=e=>{a||(a=!0,n&&n(e))};return new ReadableStream({async pull(e){try{let{done:t,value:n}=await i.next();if(t){s(),e.close();return}let a=n.byteLength;r&&r(o+=a),e.enqueue(new Uint8Array(n))}catch(e){throw s(e),e}},cancel:e=>(s(e),i.return())},{highWaterMark:2})};var{isFunction:rV}=t4,rG=(({Request:e,Response:t})=>({Request:e,Response:t}))(t4.global),{ReadableStream:rX,TextEncoder:rY}=t4.global,rQ=(e,...t)=>{try{return!!e(...t)}catch{return!1}},rZ=e=>{let t,{fetch:r,Request:n,Response:i}=e=t4.merge.call({skipUndefined:!0},rG,e),o=r?rV(r):"function"==typeof fetch,a=rV(n),s=rV(i);if(!o)return!1;let l=o&&rV(rX),c=o&&("function"==typeof rY?(t=new rY,e=>t.encode(e)):async e=>new Uint8Array(await new n(e).arrayBuffer())),u=a&&l&&rQ(()=>{let e=!1,t=new rX,r=new n(rb.origin,{body:t,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return t.cancel(),e&&!r}),h=s&&l&&rQ(()=>
1t4.isReadableStream(new i("").body)),f={stream:h&&(e=>e.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(e=>{f[e]||(f[e]=(t,r)=>{let n=t&&t[e];if(n)return n.call(t);throw new t7(`Response type '${e}' is not supported`,t7.ERR_NOT_SUPPORT,r)})});let d=async e=>null==e?0:t4.isBlob(e)?e.size:t4.isSpecCompliantForm(e)?(await new n(rb.origin,{method:"POST",body:e}).arrayBuffer()).byteLength:t4.isArrayBufferView(e)||t4.isArrayBuffer(e)?e.byteLength:(t4.isURLSearchParams(e)&&(e+=""),t4.isString(e))?(await c(e)).byteLength:void 0,p=async(e,t)=>t4.toFiniteNumber(e.getContentLength())??d(t);return async e=>{let{url:t,method:o,data:s,signal:l,cancelToken:c,timeout:d,onDownloadProgress:g,onUploadProgress:m,responseType:y,headers:w,withCredentials:b="same-origin",fetchOptions:v}=rK(e),S=r||fetch;y=y?(y+"").toLowerCase():"text";let E=((e,t)=>{let{length:r}=e=e?e.filter(Boolean):[];if(t||r){let r=new AbortController,n,i=function(e){if(!n){n=!0,a();let t=e instanceof Error?e:this.reason;r.abort(t instanceof t7?t:new rI(t instanceof Error?t.message:t))}},o=t&&setTimeout(()=>{o=null,i(new t7(`timeout of ${t}ms exceeded`,t7.ETIMEDOUT))},t),a=()=>{e&&=(o&&clearTimeout(o),o=null,e.forEach(e=>{e.unsubscribe?e.unsubscribe(i):e.removeEventListener("abort",i)}),null)};e.forEach(e=>e.addEventListener("abort",i));let{signal:s}=r;return s.unsubscribe=()=>t4.asap(a),s}})([l,c&&c.toAbortSignal()],d),_=null,k=E&&E.unsubscribe&&(()=>{E.unsubscribe()}),A;try{if(m&&u&&"get"!==o&&"head"!==o&&0!==(A=await p(w,s))){let e=new n(t,{method:"POST",body:s,duplex:"half"}),r;if(t4.isFormData(s)&&(r=e.headers.get("content-type"))&&w.setContentType(r),e.body){let[t,r]=rL(A,rj(rN(m)));s=rq(e.body,65536,t,r)}}t4.isString(b)||(b=b?"include":"omit");let r=a&&"credentials"in n.prototype,l={...v,signal:E,method:o.toUpperCase(),headers:w.normalize().toJSON(),body:s,duplex:"half",credentials:r?b:void 0};_=a&&new n(t,l);let c=await (a?S(_,v):S(t,l)),d=h&&("stream"===y||"response"===y);if(h&&(g||d&&k)){let e={};["status","statusText","headers"].forEach(t=>{e[t]=c[t]});let t=t4.toFiniteNumber(c.headers.get("content-length")),[r,n]=g&&rL(t,rj(rN(g),!0))||[];c=new i(rq(c.body,65536,r,()=>{n&&n(),k&&k()}),e)}y||="text";let T=await f[t4.findKey(f,y)||"text"](c,e);return!d&&k&&k(),await new Promise((t,r)=>{rx(t,r,{data:T,headers:rR.from(c.headers),status:c.status,statusText:c.statusText,config:e,request:_})})}catch(t){throw k&&k(),t&&"TypeError"===t.name&&/Load failed|fetch/i.test(t.message)?Object.assign(new t7("Network Error",t7.ERR_NETWORK,e,_,t&&t.response),{cause:t.cause||t}):t7.from(t,t&&t.code,e,_,t&&t.response)}}},r0=new Map;let r1=e=>{let t=e&&e.env||{},{fetch:r,Request:n,Response:i}=t,o=[n,i,r],a=o.length,s,l,c=r0;for(;a--;)s=o[a],void 0===(l=c.get(s))&&c.set(s,l=a?new Map:rZ(t)),c=l;return l};r1();var r2={http:null,xhr:rF,fetch:{get:r1}};t4.forEach(r2,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});var r5=e=>`- ${e}`,r8=e=>t4.isFunction(e)||null===e||!1===e,r6=function(e,t){let{length:r}=e=t4.isArray(e)?e:[e],n,i,o={};for(let a=0;a<r;a++){let r;if(i=n=e[a],!r8(n)&&void 0===(i=r2[(r=String(n)).toLowerCase()]))throw new t7(`Unknown adapter '${r}'`);if(i&&(t4.isFunction(i)||(i=i.get(t))))break;o[r||"#"+a]=i}if(!i){let e=Object.entries(o).map(([e,t])=>`adapter ${e} `+(!1===t?"is not supported by the environment":"is not available in the build"));throw new t7("There is no suitable adapter to dispatch the request "+(r?e.length>1?"since :\n"+e.map(r5).join("\n"):" "+r5(e[0]):"as no adapter specified"),"ERR_NOT_SUPPORT")}return i};function r3(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new rI(null,e)}function r4(e){return r3(e),e.headers=rR.from(e.headers),e.data=rO.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1),r6(e.adapter||rS.adapter,e)(e).then(function(t){return r3(e),t.data=rO.call(e,e.transformResponse,t),t.headers=rR.from(t.headers),t},function(t){return rC(t)||(r3(e),t&&t.response&&(t.response.data=rO.call(e,e.transformResponse,t.response),t.response.headers=rR.from(t.response.headers))),Promise.reject(t)})}let r9="1.15.0";var r7={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{r7[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});var ne={};r7.transitional=function(e,t,r){function n(e,t){return"[Axios v"+r9+"] Transitional option '"+e+"'"+t+(r?". "+r:"")}return(r,i,o)=>
1{if(!1===e)throw new t7(n(i," has been removed"+(t?" in "+t:"")),t7.ERR_DEPRECATED);return t&&!ne[i]&&(ne[i]=!0,console.warn(n(i," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(r,i,o)}},r7.spelling=function(e){return(t,r)=>(console.warn(`${r} is likely a misspelling of ${e}`),!0)};var nt=function(e,t,r){if("object"!=typeof e)throw new t7("options must be an object",t7.ERR_BAD_OPTION_VALUE);let n=Object.keys(e),i=n.length;for(;i-- >0;){let o=n[i],a=t[o];if(a){let t=e[o],r=void 0===t||a(t,o,e);if(!0!==r)throw new t7("option "+o+" must be "+r,t7.ERR_BAD_OPTION_VALUE);continue}if(!0!==r)throw new t7("Unknown option "+o,t7.ERR_BAD_OPTION)}},nr=class{constructor(e){this.defaults=e||{},this.interceptors={request:new ru,response:new ru}}async request(e,t){try{return await this._request(e,t)}catch(e){if(e instanceof Error){let t={};Error.captureStackTrace?Error.captureStackTrace(t):t=Error();let r=(()=>{if(!t.stack)return"";let e=t.stack.indexOf("\n");return -1===e?"":t.stack.slice(e+1)})();try{if(e.stack){if(r){let t=r.indexOf("\n"),n=-1===t?-1:r.indexOf("\n",t+1),i=-1===n?"":r.slice(n+1);String(e.stack).endsWith(i)||(e.stack+="\n"+r)}}else e.stack=r}catch{}}throw e}}_request(e,t){"string"==typeof e?(t||={}).url=e:t=e||{};let{transitional:r,paramsSerializer:n,headers:i}=t=rz(this.defaults,t);void 0!==r&&nt(r,{silentJSONParsing:r7.transitional(r7.boolean),forcedJSONParsing:r7.transitional(r7.boolean),clarifyTimeoutError:r7.transitional(r7.boolean),legacyInterceptorReqResOrdering:r7.transitional(r7.boolean)},!1),null!=n&&(t4.isFunction(n)?t.paramsSerializer={serialize:n}:nt(n,{encode:r7.function,serialize:r7.function},!0)),void 0!==t.allowAbsoluteUrls||(void 0===this.defaults.allowAbsoluteUrls?t.allowAbsoluteUrls=!0:t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls),nt(t,{baseUrl:r7.spelling("baseURL"),withXsrfToken:r7.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let o=i&&t4.merge(i.common,i[t.method]);i&&t4.forEach(["delete","get","head","post","put","patch","common"],e=>{delete i[e]}),t.headers=rR.concat(o,i);let a=[],s=!0;this.interceptors.request.forEach(function(e){if("function"==typeof e.runWhen&&!1===e.runWhen(t))return;s&&=e.synchronous;let r=t.transitional||rh;r&&r.legacyInterceptorReqResOrdering?a.unshift(e.fulfilled,e.rejected):a.push(e.fulfilled,e.rejected)});let l=[];this.interceptors.response.forEach(function(e){l.push(e.fulfilled,e.rejected)});let c,u=0,h;if(!s){let e=[r4.bind(this),void 0];for(e.unshift(...a),e.push(...l),h=e.length,c=Promise.resolve(t);u<h;)c=c.then(e[u++],e[u++]);return c}h=a.length;let f=t;for(;u<h;){let e=a[u++],t=a[u++];try{f=e(f)}catch(e){t.call(this,e);break}}try{c=r4.call(this,f)}catch(e){return Promise.reject(e)}for(u=0,h=l.length;u<h;)c=c.then(l[u++],l[u++]);return c}getUri(e){return rc(rM((e=rz(this.defaults,e)).baseURL,e.url,e.allowAbsoluteUrls),e.params,e.paramsSerializer)}};t4.forEach(["delete","get","head","options"],function(e){nr.prototype[e]=function(t,r){return this.request(rz(r||{},{method:e,url:t,data:(r||{}).data}))}}),t4.forEach(["post","put","patch"],function(e){function t(t){return function(r,n,i){return this.request(rz(i||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:r,data:n}))}}nr.prototype[e]=t(),nr.prototype[e+"Form"]=t(!0)});var nn=class e{constructor(e){let t;if("function"!=typeof e)throw TypeError("executor must be a function.");this.promise=new Promise(function(e){t=e});let r=this;this.promise.then(e=>{if(!r._listeners)return;let t=r._listeners.length;for(;t-- >0;)r._listeners[t](e);r._listeners=null}),this.promise.then=e=>{let t,n=new Promise(e=>{r.subscribe(e),t=e}).then(e);return n.cancel=function(){r.unsubscribe(t)},n},e(function(e,n,i){r.reason||(r.reason=new rI(e,n,i),t(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;let t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}toAbortSignal(){let e=new AbortController,t=t=>{e.abort(t)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let t;return{token:new e(function(e){t=e}),cancel:t}}},ni={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,Re
1setContent: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,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(ni).forEach(([e,t])=>{ni[t]=e});var no=function e(t){let r=new nr(t),n=tE(nr.prototype.request,r);return t4.extend(n,nr.prototype,r,{allOwnKeys:!0}),t4.extend(n,r,null,{allOwnKeys:!0}),n.create=function(r){return e(rz(t,r))},n}(rS);no.Axios=nr,no.CanceledError=rI,no.CancelToken=nn,no.isCancel=rC,no.VERSION=r9,no.toFormData=ri,no.AxiosError=t7,no.Cancel=no.CanceledError,no.all=function(e){return Promise.all(e)},no.spread=function(e){return function(t){return e.apply(null,t)}},no.isAxiosError=function(e){return t4.isObject(e)&&!0===e.isAxiosError},no.mergeConfig=rz,no.AxiosHeaders=rR,no.formToJSON=e=>rv(t4.isHTMLForm(e)?new FormData(e):e),no.getAdapter=r6,no.HttpStatusCode=ni,no.default=no;let na=[M.Profile,M.Email,M.Phone,M.Address,M.CustomData,M.Identities];var ns="https://files-one.thaipbs.th/sdk-assets/v1/profile-completion-modal";let nl={th:{desktop:`${ns}/desktop.webp`,mobile:`${ns}/mobile.webp`},en:{desktop:`${ns}/desktop-en.webp`,mobile:`${ns}/mobile-en.webp`}},nc={th:{signOutTitle:"à¸à¹à¸à¸à¸à¸²à¸£à¸à¸à¸à¸à¸²à¸à¸£à¸°à¸à¸à¸«à¸£à¸·à¸à¹à¸¡à¹?",signOutText:"à¹à¸¡à¸·à¹à¸à¸¥à¸à¸à¸·à¹à¸à¸à¸à¸ à¸à¸¸à¸à¸à¸°à¸à¸à¸à¸à¸²à¸à¸£à¸°à¸à¸à¸à¸¸à¸à¸à¸£à¸´à¸à¸²à¸£à¸à¸µà¹à¹à¸à¸·à¹à¸à¸¡à¸à¹à¸à¸à¹à¸§à¸¢à¸à¸±à¸à¸à¸µ OneMember",signOutConfirm:"à¸à¸à¸¥à¸",signOutCancel:"ยà¸à¹à¸¥à¸´à¸",editProfile:"à¹à¸à¹à¹à¸à¹à¸à¸£à¹à¸à¸¥à¹",later:"à¹à¸§à¹à¸ ายหลัà¸"},en:{signOutTitle:"Do you want to sign out?",signOutText:"When you sign out, you will be signed out from all services connected with your OneMember account",signOutConfirm:"OK",signOutCancel:"Cancel",editProfile:"Edit Profile",later:"Later"}};var nu="onemember-profile-completion-modal",nh="onemember-font",nf=class{config;modalElement=null;fontStyleElement=null;constructor(e){this.config=e}show(){this.isOpen()||(this.loadFont(),this.createModal(),this.attachEventListeners())}close(){this.modalElement&&=(document.body.removeChild(this.modalElement),null),this.fontStyleElement&&=(document.head.removeChild(this.fontStyleElement),null)}isOpen(){return null!==document.getElementById(nu)}loadFont(){if(document.getElementById(nh))return;let e=document.createElement("link");e.id=nh,e.rel="stylesheet",e.href="https://fonts.googleapis.com/css2?family=Prompt:wght@400;500;600;700&display=swap",document.head.appendChild(e),this.fontStyleElement=e}createModal(){this.modalElement=document.createElement("div"),this.modalElement.id=nu,this.modalElement.innerHTML=this.getModalHTML(),document.body.appendChild(this.modalElement)}isCardModal(){return!!(this.config.title||this.config.text||this.config.image)}getModalHTML(){let e=this.isCardModal();return` 2 <style> 3 #${nu} { 4 --om-font-sans: 'Prompt', -apple-system, system-ui, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif; 5 --om-color-brand: #fe5000; 6 --om-color-brand-hover: #e54800; 7 --om-color-grey-1: #333333; 8 --om-color-grey-2: #4f4f4f; 9 --om-color-grey-3: #828282; 10 --om-color-grey-4: #bdbdbd; 11 --om-color-grey-5: #e0e0e0; 12 --om-shadow-modal: 0 386px 154px 0 rgba(0, 0, 0, 0.01), 0 217px 130px 0 rgba(0, 0, 0, 0.05), 0 96px 96px 0 rgba(0, 0, 0, 0.09), 0 24px 53px 0 rgba(0, 0, 0, 0.10); 13 14 position: fixed; 15 top: 0; 16 left: 0; 17 width: 100%; 18 height: 100%; 19 z-index: 999999; 20 isolation: isolate; 21 transform: translateZ(0); 22 font-family: var(--om-font-sans); 23 font-synthesis: none; 24 text-rendering: optimizeLegibility; 25 -webkit-font-smoothing: antialiased; 26 -moz-osx-font-smoothing: grayscale; 27 } 28 29 #${nu} * { 30 box-sizing: border-box; 31 } 32 33 #${nu} .onemember-modal__overlay { 34 position: absolute; 35 top: 0; 36 left: 0; 37 width: 100%; 38 height: 100%; 39 background: rgba(0, 0, 0, 0.1); 40 z-index: 1; 41 } 42 43 #${nu} .onemember-modal__container { 44 position: absolute; 45 ${"bottom-right"===this.config.position?"\n bottom: 20px;\n right: 20px;\n width: 400px;\n max-width: calc(100vw - 40px);\n ":` 46 top: 50%; 47 left: 50%; 48 transform: translate(-50%, -50%); 49 width: calc(100% - 32px); 50 max-width: ${e?"380px":"800px"}; 51 `} 52 z-index: 2; 53 animation: onemember-modal-fade-in 150ms ease; 54 } 55 56 @keyframes onemember-modal-fade-in { 57 from { 58 opacity: 0; 59 transform: translate(-50%, -50%) scale(0.95); 60 } 61 to { 62 opacity: 1; 63 transform: translate(-50%, -50%) scale(1); 64 } 65 } 66 67 #${nu} .onemember-modal__content-wrapper { 68 position: relative; 69 border-radius: ${e?"16px":"24px"}; 70 overflow: hidden; 71 box-shadow: var(--om-shadow-modal); 72 ${e?"background: white;":""} 73 max-height: 90vh; 74 overflow-y: auto; 75 } 76 77 #${nu} .onemember-modal__card-content { 78 padding: 32px 24px 0; 79 text-align: center; 80 } 81 82 #${nu} .onemember-modal__card-image { 83 width: 180px; 84 height: auto; 85 margin: 0 auto 16px; 86 display: block; 87 } 88 89 #${nu} .onemember-modal__title { 90 font-size: 18px; 91 font-weight: 600; 92 color: var(--om-color-grey-1); 93 margin: 0 0 8px; 94 line-height: 1.4; 95 } 96 97 #${nu} .onemember-modal__text { 98 font-size: 14px; 99 font-weight: 400; 100 color: var(--om-color-grey-3); 101 margin: 0; 102 line-height: 1.5; 103 } 104 105 #${nu} .onemember-modal__image { 106 width: 100%; 107 height: auto; 108 display: block; 109 object-fit: contain; 110 } 111 112 #${nu} .onemember-modal__buttons { 113 ${e?"\n display: flex;\n flex-direction: column;\n gap: 8px;\n padding: 20px 24px 24px;\n ":"\n position: absolute;\n bottom: 20px;\n left: 40px;\n right: 40px;\n display: flex;\n flex-direction: column;\n align-items: center;\n "} 114 } 115 116 #${nu} .onemember-modal__btn { 117 width: 100%; 118 padding: 12px 20px; 119 border-radius: 12px; 120 font-family: inherit; 121 font-size: 14px; 122 font-weight: 500; 123 cursor: pointer; 124 transition: all 150ms ease; 125 outline: none; 126 } 127 128 #${nu} .onemember-modal__btn:disabled { 129 opacity: 0.5; 130 pointer-events: none; 131 } 132 133 #${nu} .onemember-modal__btn--primary { 134 ${e?"\n background: var(--om-color-brand);\n color: white;\n border: none;\n ":"\n background: white;\n color: #8E3D26;\n border: none;\n "} 135 } 136 137 #${nu} .onemember-modal__btn--primary:hover { 138 ${e?"background: var(--om-color-brand-hover);":"background: #f5f5f5;"} 139 } 140 141 #${nu} .onemember-modal__btn--secondary { 142 ${e?"\n background: white;\n color: var(--om-color-grey-2);\n border: 1px solid var(--om-color-grey-5);\n ":"\n background: transparent;\n color: white;\n border: none;\n text-decoration: underline;\n "} 143 } 144 145 #${nu} .onemember-modal__btn--secondary:hover { 146 ${e?"background: #f8f8f8; border-color: var(--om-color-grey-4);":""} 147 } 148 149 @media (max-width: 640px) { 150 #${nu} .onemember-modal__container { 151 ${"bottom-right"===this.config.position?"\n bottom: auto;\n right: auto;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n width: calc(100% - 32px);\n max-width: 380px;\n ":""} 152 } 153 154 #${nu} .onemember-modal__card-image { 155 width: 140px; 156 } 157 158 #${nu} .onemember-modal__title { 159 font-size: 16px; 160 } 161 162 #${nu} .onemember-modal__text { 163 font-size: 12px; 164 } 165 166 #${nu} .onemember-modal__buttons { 167 ${e?"":"\n bottom: 30px;\n left: 24px;\n right: 24px;\n gap: 6px;\n "} 168 } 169 170 #${nu} .onemember-modal__btn { 171 padding: 10px 16px; 172 font-size: 14px; 173 } 174 } 175 </style> 176 <div class="onemember-modal__overlay"></div> 177 <div class="onemember-modal__container"> 178 <div class="onemember-modal__content-wrapper"> 179 ${this.getContentHTML()} 180 <div class="onemember-modal__buttons"> 181 ${this.config.buttons.map((e,t)=>this.getButtonHTML(e,t)).join("")} 182 </div> 183 </div> 184 </div> 185 `}getContentHTML(){if(this.isCardModal()){let e='<div class="onemember-modal__card-content">';return this.config.image&&(e+=`<img src="${this.config.image}" alt="${this.config.imageAlt||""}" class="onemember-modal__card-image" />`),this.config.title&&(e+=`<h2 class="onemember-modal__title">${this.config.title}</h2>`),this.config.text&&(e+=`<p class="onemember-modal__text">${this.config.text}</p>`),e+="</div>"}return this.config.images?` 186 <picture> 187 <source media="(max-width: 640px)" srcset="${this.config.images.mobile}"> 188 <img 189 src="${this.config.images.desktop}" 190 alt="${this.config.imageAlt||"Modal"}" 191 class="onemember-modal__image" 192 /> 193 </picture> 194 `:""}getButtonHTML(e,t){return`<button class="${e.primary?"onemember-modal__btn onemember-modal__btn--primary":"onemember-modal__btn onemember-modal__btn--secondary"}" data-button-index="${t}">${e.text}</button>`}attachEventListeners(){if(!this.modalElement)return;let e=this.modalElement.querySelector(".onemember-modal__overlay");e&&e.addEventListener("click",()=>{this.handleClose()}),this.modalElement.querySelectorAll("[data-button-index]").forEach(e
194=>{e.addEventListener("click",e=>{let t=parseInt(e.currentTarget.getAttribute("data-button-index")||"0"),r=this.config.buttons[t];r&&r.onClick()})})}handleClose(){this.config.onClose&&this.config.onClose(),this.close()}},nd=class e extends Error{cause;constructor(t,r){super(t),this.name="OneMemberAuthError",this.cause=r,Object.setPrototypeOf(this,e.prototype)}},np=class e extends Error{constructor(t){super(t),this.name="OneMemberConfigError",Object.setPrototypeOf(this,e.prototype)}},ng=class e extends nd{constructor(){super("User is not authenticated"),this.name="OneMemberNotAuthenticatedError",Object.setPrototypeOf(this,e.prototype)}};function nm(e,t){return e instanceof nd?e:e instanceof Error?new nd(t||e.message,e):new nd(t||`An unknown error occurred: ${String(e)}`)}var ny="onemember_auth_return_url",nw="onemember_silent_auth_attempted",nb="onemember_consent_retry_attempted",nv=class e{static version="1.1.4";logtoClient;config;modal=null;appConfig=null;get t(){return nc[this.config.language||"th"]}setLanguage(e){this.config={...this.config,language:e}}constructor(t){(function(e){if(!e.appId||""===e.appId.trim())throw new np("appId is required in configuration")})(t),this.config=t,console.log(`[OneMemberSDK] v${e.version}`),"u">typeof window&&(window.__oneMemberSDK={version:e.version}),this.logtoClient=new tS({appId:t.appId,endpoint:t.authenticationEndpoint||"https://auth.thaipbs-one-member.develop.poring.arkcube.com",scopes:na,resources:["https://default.logto.app/api"]})}async fetchAppConfig(){if(this.appConfig)return this.appConfig;let e=`${this.config.endpoint||"https://thaipbs-one-member.develop.poring.arkcube.com"}/api/applications/${this.config.appId}/config`;return this.appConfig=(await no.get(e)).data,this.appConfig}async isEnabled(){try{return(await this.fetchAppConfig()).isEnabled||!1}catch{return!1}}async signIn(e,t){try{this.saveReturnUrl(window.location.href),await this.logtoClient.signIn({redirectUri:e,postRedirectUri:t,extraParams:{ui_locales:this.config.language||"th"}})}catch(e){throw nm(e,"Sign in failed")}}async autoSignIn(e,t){if(!(typeof window>"u")){if(this.hasSilentAuthBeenAttempted()){this.isSilentAuthError(window.location.href)&&this.cleanSilentAuthErrorUrl();return}if(this.isSilentAuthError(window.location.href)){this.markSilentAuthAttempted(),this.cleanSilentAuthErrorUrl();return}
194if(!await this.isAuthenticated()&&await this.checkBackendSession()){this.markSilentAuthAttempted();try{this.saveReturnUrl(window.location.href),await this.logtoClient.signIn({redirectUri:e,postRedirectUri:t,prompt:ex.None,extraParams:{ui_locales:this.config.language||"th"}})}catch{}}}}async hasActiveSSOSession(){try{if(await this.logtoClient.isAuthenticated())return!0}catch{}return this.config.signInRedirectUri?(await this.autoSignIn(this.config.signInRedirectUri),!1):this.checkBackendSession()}async checkBackendSession(){try{let e=this.config.endpoint||"https://thaipbs-one-member.develop.poring.arkcube.com";return(await no.get(`${e}/api/sessions/check`,{withCredentials:!0})).data.hasActiveSession||!1}catch{return!1}}hasSilentAuthBeenAttempted(){try{return"true"===sessionStorage.getItem(nw)}catch{return!1}}markSilentAuthAttempted(){try{sessionStorage.setItem(nw,"true")}catch{}}clearSilentAuthFlag(){try{sessionStorage.removeItem(nw)}catch{}}isConsentRequiredError(e){try{return"consent_required"===new URL(e).searchParams.get("error")}catch{return!1}}hasConsentRetryBeenAttempted(){try{return"true"===sessionStorage.getItem(nb)}catch{return!1}}markConsentRetryAttempted(){try{sessionStorage.setItem(nb,"true")}catch{}}clearConsentRetryFlag(){try{sessionStorage.removeItem(nb)}catch{}}cleanSilentAuthErrorUrl(){let e=new URL(window.location.href);["error","error_description","state","iss"].forEach(t=>e.searchParams.delete(t));let t=e.searchParams.toString()?`${e.pathname}?${e.searchParams}`:e.pathname;window.history.replaceState({},document.title,t)}async signOut(e){try{this.saveReturnUrl(window.location.href),this.clearSilentAuthFlag(),this.clearConsentRetryFlag();try{let e=this.config.endpoint||"https://thaipbs-one-member.develop.poring.arkcube.com";await no.delete(`${e}/api/sessions`,{withCredentials:!0})}catch{}await this.logtoClient.signOut(e)}catch(e){throw nm(e,"Sign out failed")}}async signOutWithConfirmation(e){return!!await this.showSignOutConfirmation()&&(await this.signOut(e),!0)}showSignOutConfirmation(){return new Promise(e=>{this.modal?.isOpen()?e(!1):(this.modal=new nf({title:this.t.signOutTitle,text:this.t.signOutText,buttons:[{text:this.t.signOutConfirm,primary:!0,onClick:()=>{this.modal?.close(),e(!0)}},{text:this.t.signOutCancel,primary:!1,onClick:()=>{this.modal?.close(),e(!1)}}],onClose:()=>{this.modal=null,e(!1)},position:"center"}),this.modal.show())})}isSilentAuthError(e){try{let t=new URL(e).searchParams.get("error");return"login_required"===t||"interaction_required"===t||"consent_required"===t}catch{return!1}}async handleSignInCallback(e){let t=e||window.location.href;if(this.isSilentAuthError(t)){if(this.isConsentRequiredError(t)&&!this.hasConsentRetryBeenAttempted()){this.markConsentRetryAttempted();try{let e=new URL(t);return e.search="",e.hash="",await this.logtoClient.signIn({redirectUri:e.toString(),extraParams:{ui_locales:this.config.language||"th"}}),new Promise(()=>{})}catch{}}this.markSilentAuthAttempted(),this.cleanSilentAuthErrorUrl();return}try{await this.logtoClient.handleSignInCallback(t),this.clearSilentAuthFlag(),this.clearConsentRetryFlag();try{let e=await this.logtoClient.getIdToken();if(e){let t=this.config.endpoint||"https://thaipbs-one-member.develop.poring.arkcube.com";await no.post(`${t}/api/sessions/register`,null,{headers:{Authorization:`Bearer ${e}`},withCredentials:!0})}}catch{}}catch(e){throw nm(e,"Failed to handle sign-in callback")}}redirectToSavedLocation(e="/"){let t=this.getStoredReturnUrl();this.clearReturnUrl();let r=t&&this.isValidReturnUrl(t)?t:e;return window.location.href=r,r}getStoredReturnUrl(){try{return sessionStorage.getItem(ny)}catch{return null}}clearReturnUrl(){try{sessionStorage.removeItem(ny)}catch{}}saveReturnUrl(e){try{sessionStorage.setItem(ny,e)}catch{}}isValidReturnUrl(e){try{let t=new URL(e);return"http:"===t.protocol||"https:"===t.protocol}catch{return!1}}async getProfileCompletionDismissedKey(){return`onemember_profile_completion_dismissed_${(await this.logtoClient.getIdTokenClaims()).sub}`}async isProfileCompletionDismissed(e){try{let t=await this.getProfileCompletionDismissedKey(),r=localStorage.getItem(t);if(!r)return!1;let n=Number(r);return Date.now()-n<24*e*36e5}catch{return!1}}async dismissProfileCompletion(){try{let e=await this.getProfileCompletionDismissedKey();localStorage.setItem(e,String(Date.now()))}catch{}}async clearProfileCompletionDismissal(){try{let e=await this.getProfileCompletionDismissedKey();localStorage.removeItem(e)}catch{}}getProfileUrl(){let e=new URL(this.config.endpoint||"https://thaipbs-one-member.develop.poring.arkcube.com");return e.searchParams.set("lang",this.config.language||"th"),e.toString()}getProfileCompletionUrl(){let e=this.config.endpoint||"https://thaipbs-one-member.develop.poring.arkcube.com",t=new
194URL(`${e}/welcome`);return t.searchParams.set("lang",this.config.language||"th"),t.toString()}async checkBackchannelLogout(){try{let e=await this.logtoClient.getIdTokenClaims(),t="string"==typeof e.sub?e.sub:void 0;if(!t)return!1;let r=e.iat;if(!r||"number"!=typeof r)return!1;let n=`${this.config.endpoint||"https://thaipbs-one-member.develop.poring.arkcube.com"}/api/check-logout`;return(await no.get(n,{params:{userId:t,tokenIssuedAt:r}})).data.loggedOut||!1}catch{return!1}}async isAuthenticated(){try{return!!await this.logtoClient.isAuthenticated()&&(!await this.checkBackchannelLogout()||(await this.logtoClient.clearAllTokens(),this.clearSilentAuthFlag(),!1))}catch{return!1}}async getUser(){try{if(!await this.isAuthenticated())throw new ng;return await this.logtoClient.fetchUserInfo()}catch(e){throw e instanceof nd?e:nm(e,"Failed to fetch user information")}}async getAccessToken(){try{if(!await this.isAuthenticated())throw new ng;let e=await this.logtoClient.getIdToken();if(!e)throw new ng;return e}catch(e){throw e instanceof nd?e:nm(e,"Failed to get access token")}}showProfile(e){let t=this.getProfileUrl();if(e)window.open(t,"_blank");else{let e=new URL(t);e.searchParams.set("returnUrl",window.location.href),window.location.href=e.toString()}}async showProfileCompletion(e){try{let t=14;try{t=(await this.fetchAppConfig()).profileCompletionCooldownDays??14}catch{}if(await this.isProfileCompletionDismissed(t))return;if(await this.checkProfileCompletion())return void await this.clearProfileCompletionDismissal();if(this.modal?.isOpen())return;let r=nl[this.config.language||"th"];this.modal=new nf({images:{desktop:this.config.profileModalImages?.desktop??r.desktop,mobile:this.config.profileModalImages?.mobile??r.mobile},imageAlt:"Profile Completion",buttons:[{text:this.t.editProfile,primary:!0,onClick:()=>{this.modal?.close();let t=this.getProfileCompletionUrl();if(e)window.open(t,"_blank");else{let e=new URL(t);e.searchParams.set("returnUrl",window.location.href),window.location.href=e.toString()}}},{text:this.t.later,primary:!1,onClick:()=>{this.dismissProfileCompletion(),this.modal?.close()}}],onClose:()=>{this.modal=null},position:"bottom-right"}),this.modal.show()}catch{this.modal&&=(this.modal.close(),null)}}async checkProfileCompletion(){try{if(!await this.isAuthenticated())throw new ng;let e=await this.getAccessToken(),t=`${this.config.endpoint||"https://thaipbs-one-member.develop.poring.arkcube.com"}/api/users/profile-completion`;return(await no.get(t,{headers:{Authorization:`Bearer ${e}`}})).data.isComplete}catch{return!1}}},nS=e.i(53723);let nE="vsc0pw3bbymt1zgayvbod",n_=null,nk=!1;function nA(){n_=null}e.s(["ONE_MEMBER_APP_ID",0,nE,"claimOneMemberSignIn",0,function(){return!nk&&(nk=!0,!0)},"getOneMemberAuth",0,function(){return n_||(n_=new nv({appId:nE,authenticationEndpoint:"https://auth-one.thaipbs.th",endpoint:"https://one.thaipbs.th",signInRedirectUri:`${window.location.origin}/one-member/callback`,language:"en"}))},"isOneMemberOriginRegistered",0,function(){return 0===nS.ONE_MEMBER_ORIGINS.length||nS.ONE_MEMBER_ORIGINS.includes(window.location.origin)},"releaseOneMemberSignIn",0,function(){nk=!1},"resetOneMemberAuth",0,nA],66013);let nT="logto";function nR(e){return void 0===e?`${nT}:${nE}`:`${nT}:${nE}:${e}`}function nO(){sessionStorage.removeItem(nR("signInSession")),sessionStorage.removeItem(nR())}async function nC(e){let t=await fetch("/api/one-member/token",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),r=await t.json().catch(()=>null);if(!t.ok){let e="object"==typeof r&&null!==r?r.description??r.error:void 0;throw Error(`token exchange failed: ${String(e??t.status)}`)}return r}function nI(e){let t=Math.round(Date.now()/1e3)+e.expiresIn;localStorage.setItem(nR("idToken"),e.idToken),e.refreshToken&&localStorage.setItem(nR("refreshToken"),e.refreshToken),localStorage.setItem(nR("accessToken"),JSON.stringify({"@":{token:e.accessToken,scope:e.scope,expiresAt:t}})),nA()}function nx(){localStorage.removeItem(nR("idToken")),localStorage.removeItem(nR("refreshToken")),localStorage.removeItem(nR("accessToken")),nA()}async function nU(e){let t=new URL(e);if(t.searchParams.get("error"))return nO(),"no-session";let r=t.searchParams.get("code"),n=t.searchParams.get("state");if(!r)return"no-session";
194let i=function(){let e=sessionStorage.getItem(nR("signInSession"))??sessionStorage.getItem(nR());if(!e)return null;try{let t=JSON.parse(e);if("object"!=typeof t||null===t)return null;let{redirectUri:r,codeVerifier:n,state:i}=t;if("string"!=typeof r||"string"!=typeof n||"string"!=typeof i)return null;return{redirectUri:r,codeVerifier:n,state:i}}catch{return null}}();if(!i)throw Error("sign-in session not found");if(n!==i.state)throw Error("state mismatch in callback URI");return nI(await nC({grant:"authorization_code",code:r,codeVerifier:i.codeVerifier,redirectUri:i.redirectUri})),nO(),"signed-in"}async function nP(){let e=localStorage.getItem(nR("refreshToken"));if(!e)return;let t=0,r=localStorage.getItem(nR("accessToken"));if(r)try{let e=JSON.parse(r),n="object"==typeof e&&null!==e?e["@"]:void 0;"number"==typeof n?.expiresAt&&(t=n.expiresAt)}catch{}if(!(t-60>Date.now()/1e3))try{nI(await nC({grant:"refresh_token",refreshToken:e}))}catch(e){console.error("[one-member] token refresh failed:",e),nx()}}async function nj(e){let t,r=[],n=(e,t,n)=>r.push({gate:e,state:t,detail:n}),i=14;try{let e=await fetch(`https://one.thaipbs.th/api/applications/${nE}/config`),t=await e.json();"number"==typeof t.profileCompletionCooldownDays&&(i=t.profileCompletionCooldownDays),n("server isEnabled (not enforced)","info",`server returns isEnabled: ${String(t.isEnabled)}. This app ignores it â the modal depends only on being signed in with an incomplete profile.`)}catch(r){let e="https://one.thaipbs.th",t=/(^|\/\/)auth[.-]/.test(e);n("server isEnabled (not enforced)","info",`app config request to ${e||"(unset)"} failed: ${String(r)}.`+(t?" NEXT_PUBLIC_ONE_MEMBER_ENDPOINT looks like the auth host â the two endpoints are probably swapped.":" Check NEXT_PUBLIC_ONE_MEMBER_ENDPOINT, and that this app ID exists in that environment."))}let o=localStorage.getItem(nR("idToken")),a=!1;try{a=await e.isAuthenticated()}catch{}if(n("signed in",a?"pass":"blocked",a?"ID token present and session valid":`no valid session (idToken stored: ${!!o})`),a)try{let t=await e.checkProfileCompletion();n("profile incomplete",t?"blocked":"pass",t?"profile is already complete, so there is nothing to nudge":"profile is incomplete")}catch(e){n("profile incomplete","unknown",`check failed: ${String(e)}`)}else n("profile incomplete","unknown","not evaluated â needs a signed-in user");if(o)try{let e=JSON.parse(new TextDecoder().decode(Uint8Array.from(atob(o.split(".")[1].replace(/-/g,"+").replace(/_/g,"/")),e=>e.charCodeAt(0))));if("object"==typeof e&&null!==e){let r=e.sub;"string"==typeof r&&(t=r)}}catch{}if(t){let e=`onemember_profile_completion_dismissed_${t}`,r=localStorage.getItem(e);if(r){let t=Date.now()-Number(r),o=24*i*36e5,a=t<o;n("not dismissed",a?"blocked":"pass",a?`user chose "Later" on ${new Date(Number(r)).toISOString()}; ${Math.ceil((o-t)/864e5)} of ${i} day(s) left. Clear ${e} to reset.`:`dismissal from ${new Date(Number(r)).toISOString()} has expired`)}else n("not dismissed","pass",`no dismissal recorded (key: ${e})`)}else n("not dismissed","unknown","not evaluated â could not read `sub` from the ID token");n("modal not already open","unknown","SDK-internal state, not observable");let s=r.find(e=>"blocked"===e.state),l=r.find(e=>"unknown"===e.state&&"modal not already open"!==e.gate);return{gates:r,verdict:s?`BLOCKED at "${s.gate}" â ${s.detail}`:l?`INCONCLUSIVE at "${l.gate}" â ${l.detail}`:"every observable gate passes â the modal should render"}}function nL(){let e=localStorage.getItem(nR("idToken"));if(!e)return null;try{let t=JSON.parse(new TextDecoder().decode(Uint8Array.from(atob(e.split(".")[1].replace(/-/g,"+").replace(/_/g,"/")),e=>e.charCodeAt(0))));return"object"==typeof t&&null!==t?t:null}catch{return null}}e.s(["clearOneMemberSession",0,function(){nx()},"clearProfileCompletionDismissal",0,function(){let e=nL()?.sub;if("string"!=typeof e)return!1;let t=`onemember_profile_completion_dismissed_${e}`,r=null!==localStorage.getItem(t);return localStorage.removeItem(t),r},"completeOneMemberSignIn",0,nU,"describeOneMemberTokens",0,function(){let e=nL(),t=localStorage.getItem(nR("accessToken")),r="none stored";if(t)try{let e=JSON.parse(t),n=e["@"]?.expiresAt;if("number"==typeof n){let e=Math.round(n-Date.now()/1e3);r=e>0?`valid for ${Math.floor(e/60)}m ${e%60}s`:`expired ${-e}s ago â will be refreshed on next check`}}catch{r="stored but unreadable"}let n=e?.exp;return{"ID token stored":!!e,"Refresh token stored":!!localStorage.getItem(nR("refreshToken")),"Access token":r,"User (sub)":e?.sub??"â","ID token expires":"number"==typeof n?new Date(1e3*n).toISOString():"â"}},"describeProfileCompletionGates",0,nj,"ensureOneMemberTokensFresh",0,nP,"readOneMemberIdTokenProfile",0,function(){let e=nL();if(!e)return null;let t=e=>"string"==typeof e&&e?e:null;return{name:t(e.name)??t(e.username)??null,email:t(e.email),picture:t(e.picture)}},"seedDevOneMemberSession",0,function(){throw Error("seedDevOneMemberSession() is for local development only")}],30088)},15675,(e,t,r)=>{var n={872:function(e,t){"use strict";t.byteLength=function(e){var t=l(e),r=t[0],n=t[1];return(r+n)*3/4-n},t.toByteArray=function(e){var t,r,o=l(e),a=o[0],s=o[1],c=new i((a+s)*3/4-s),u=0,h=s>
1940?a-4:a;for(r=0;r<h;r+=4)t=n[e.charCodeAt(r)]<<18|n[e.charCodeAt(r+1)]<<12|n[e.charCodeAt(r+2)]<<6|n[e.charCodeAt(r+3)],c[u++]=t>>16&255,c[u++]=t>>8&255,c[u++]=255&t;return 2===s&&(t=n[e.charCodeAt(r)]<<2|n[e.charCodeAt(r+1)]>>4,c[u++]=255&t),1===s&&(t=n[e.charCodeAt(r)]<<10|n[e.charCodeAt(r+1)]<<4|n[e.charCodeAt(r+2)]>>2,c[u++]=t>>8&255,c[u++]=255&t),c},t.fromByteArray=function(e){for(var t,n=e.length,i=n%3,o=[],a=0,s=n-i;a<s;a+=16383)o.push(function(e,t,n){for(var i,o=[],a=t;a<n;a+=3)i=(e[a]<<16&0xff0000)+(e[a+1]<<8&65280)+(255&e[a+2]),o.push(r[i>>18&63]+r[i>>12&63]+r[i>>6&63]+r[63&i]);return o.join("")}(e,a,a+16383>s?s:a+16383));return 1===i?o.push(r[(t=e[n-1])>>2]+r[t<<4&63]+"=="):2===i&&o.push(r[(t=(e[n-2]<<8)+e[n-1])>>10]+r[t>>4&63]+r[t<<2&63]+"="),o.join("")};for(var r=[],n=[],i="u">typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,s=o.length;a<s;++a)r[a]=o[a],n[o.charCodeAt(a)]=a;function l(e){var t=e.length;if(t%4>0)throw Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");-1===r&&(r=t);var n=r===t?0:4-r%4;return[r,n]}n[45]=62,n[95]=63},230:function(e,t,r){"use strict";var n=r(872),i=r(321),o="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;function a(e){if(e>0x7fffffff)throw RangeError('The value "'+e+'" is invalid for option "size"');var t=new Uint8Array(e);return Object.setPrototypeOf(t,s.prototype),t}function s(e,t,r){if("number"==typeof e){if("string"==typeof t)throw TypeError('The "string" argument must be of type string. Received type number');return u(e)}return l(e,t,r)}function l(e,t,r){if("string"==typeof e){var n=e,i=t;if(("string"!=typeof i||""===i)&&(i="utf8"),!s.isEncoding(i))throw TypeError("Unknown encoding: "+i);var o=0|d(n,i),l=a(o),c=l.write(n,i);return c!==o&&(l=l.slice(0,c)),l}if(ArrayBuffer.isView(e))return h(e);if(null==e)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(C(e,ArrayBuffer)||e&&C(e.buffer,ArrayBuffer)||"u">typeof SharedArrayBuffer&&(C(e,SharedArrayBuffer)||e&&C(e.buffer,SharedArrayBuffer)))return function(e,t,r){var n;if(t<0||e.byteLength<t)throw RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(r||0))throw RangeError('"length" is outside of buffer bounds');return Object.setPrototypeOf(n=void 0===t&&void 0===r?new Uint8Array(e):void 0===r?new Uint8Array(e,t):new Uint8Array(e,t,r),s.prototype),n}(e,t,r);if("number"==typeof e)throw TypeError('The "value" argument must not be of type number. Received type number');var u=e.valueOf&&e.valueOf();if(null!=u&&u!==e)return s.from(u,t,r);var p=function(e){if(s.isBuffer(e)){var t=0|f(e.length),r=a(t);return 0===r.length||e.copy(r,0,0,t),r}return void 0!==e.length?"number"!=typeof e.length||function(e){return e!=e}(e.length)?a(0):h(e):"Buffer"===e.type&&Array.isArray(e.data)?h(e.data):void 0}(e);if(p)return p;if("u">typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return s.from(e[Symbol.toPrimitive]("string"),t,r);throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function c(e){if("number"!=typeof e)throw TypeError('"size" argument must be of type number');if(e<0)throw RangeError('The value "'+e+'" is invalid for option "size"')}function u(e){return c(e),a(e<0?0:0|f(e))}function h(e){for(var t=e.length<0?0:0|f(e.length),r=a(t),n=0;n<t;n+=1)r[n]=255&e[n];return r}t.Buffer=s,t.SlowBuffer=function(e){return+e!=e&&(e=0),s.alloc(+e)},t.INSPECT_MAX_BYTES=50,t.kMaxLength=0x7fffffff,s.TYPED_ARRAY_SUPPORT=function(){try{var e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),42===e.foo()}catch(e){return!1}}(),!s.TYPED_ARRAY_SUPPORT&&"u">typeof console&&"function"==typeof console.error&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(s.prototype,"parent",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.buffer}}),Object.defineProperty(s.prototype,"offset",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.byteOffset}}),s.poolSize=8192,s.from=function(e,t,r){return l(e,t,r)},Object.setPrototypeOf(s.prototype,Uint8Array.prototype),Object.setPrototypeOf(s,Uint8Array),s.alloc=function(e,t,r){return(c(e),e<=0)?a(e):void 0!==t?"string"==typeof r?a(e).fill(t,r):a(e).fill(t):a(e)},s.allocUnsafe=function(e){return u(e)},s.allocUnsafeSlow=function(e){return u(e)};function f(e){if(e>=0x7fffffff)throw RangeError("Attempt to allocate Buffer larger than maximum size: 0x7fffffff bytes");return 0|e}function d(e,t){if(s.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||C(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);var r=e.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var i=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return A(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return R(e).length;default:if(i)return n?-1:A(e).length;t=(""+t).toLowerCase(),i=!0}}function p(e,t,r){var i,o,a,s=!1;if((void 0===t||t<0)&&(t=0),t>this.length||((void 0===r||r>this.length)&&(r=this.length),r<=0||(r>>>=0)<=(t>>>=0)))return"";for(e||(e="utf8");;)switch(e){case"hex":return function(e,t,r){var n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);for(var i="",o=t;o<r;++o)i+=I[e[o]];return i}(this,t,r);case"utf8":case"utf-8":return w(this,t,r);case"ascii":return function(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(127&e[i]);return n}(this,t,r);case"latin1":case"binary":return function(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(e[i]);return n}(this,t,r);case"base64":return i=this,o=t,a=r,0===o&&a===i.length?n.fromByteArray(i):n.fromByteArray(i.slice(o,a));case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return function(e,t,r){for(var n=e.slice(t,r),i="",o=0;o<n.length;o+=2)i+=String.fromCharCode(n[o]+256*n[o+1]);return i}(this,t,r);default:if(s)throw TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),s=!0}}function g(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function m(e,t,r,n,i){var o;if(0===e.length)return -1;if("string"==typeof r?(n=r,r=0):r>0x7fffffff?r=0x7fffffff:r<-0x80000000&&(r=-0x80000000),(o=r*=1)!=o&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length)if(i)return -1;else r=e.length-1;else if(r<0)if(!i)return -1;else r=0;if("string"==typeof t&&(t=s.from(t,n)),s.isBuffer(t))return 0===t.length?-1:y(e,t,r,n,i);if("number"==typeof t){if(t&=255,"function"==typeof Uint8Array.prototype.indexOf)if(i)return Uint8Array.prototype.indexOf.call(e,t,r);else return Uint8Array.prototype.lastIndexOf.call(e,t,r);return y(e,[t],r,n,i)}throw TypeError("val must be string, number or Buffer")}function y(e,t,r,n,i){var o,a=1,s=e.length,l=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return -1;a=2,s/=2,l/=2,r/=2}function c(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}if(i){var u=-1;for(o=r;o<s;
vendor: 12,407 bytes, line 194
194o++)if(c(e,o)===c(t,-1===u?0:o-u)){if(-1===u&&(u=o),o-u+1===l)return u*a}else -1!==u&&(o-=o-u),u=-1}else for(r+l>s&&(r=s-l),o=r;o>=0;o--){for(var h=!0,f=0;f<l;f++)if(c(e,o+f)!==c(t,f)){h=!1;break}if(h)return o}return -1}s.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==s.prototype},s.compare=function(e,t){if(C(e,Uint8Array)&&(e=s.from(e,e.offset,e.byteLength)),C(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(e)||!s.isBuffer(t))throw TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;for(var r=e.length,n=t.length,i=0,o=Math.min(r,n);i<o;++i)if(e[i]!==t[i]){r=e[i],n=t[i];break}return r<n?-1:+(n<r)},s.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},s.concat=function(e,t){if(!Array.isArray(e))throw TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return s.alloc(0);if(void 0===t)for(r=0,t=0;r<e.length;++r)t+=e[r].length;var r,n=s.allocUnsafe(t),i=0;for(r=0;r<e.length;++r){var o=e[r];if(C(o,Uint8Array)&&(o=s.from(o)),!s.isBuffer(o))throw TypeError('"list" argument must be an Array of Buffers');o.copy(n,i),i+=o.length}return n},s.byteLength=d,s.prototype._isBuffer=!0,s.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)g(this,t,t+1);return this},s.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)g(this,t,t+3),g(this,t+1,t+2);return this},s.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)g(this,t,t+7),g(this,t+1,t+6),g(this,t+2,t+5),g(this,t+3,t+4);return this},s.prototype.toString=function(){var e=this.length;return 0===e?"":0==arguments.length?w(this,0,e):p.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(e){if(!s.isBuffer(e))throw TypeError("Argument must be a Buffer");return this===e||0===s.compare(this,e)},s.prototype.inspect=function(){var e="",r=t.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"},o&&(s.prototype[o]=s.prototype.inspect),s.prototype.compare=function(e,t,r,n,i){if(C(e,Uint8Array)&&(e=s.from(e,e.offset,e.byteLength)),!s.isBuffer(e))throw TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return -1;if(t>=r)return 1;if(t>>>=0,r>>>=0,n>>>=0,i>>>=0,this===e)return 0;for(var o=i-n,a=r-t,l=Math.min(o,a),c=this.slice(n,i),u=e.slice(t,r),h=0;h<l;++h)if(c[h]!==u[h]){o=c[h],a=u[h];break}return o<a?-1:+(a<o)},s.prototype.includes=function(e,t,r){return -1!==this.indexOf(e,t,r)},s.prototype.indexOf=function(e,t,r){return m(this,e,t,r,!0)},s.prototype.lastIndexOf=function(e,t,r){return m(this,e,t,r,!1)};function w(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i<r;){var o,a,s,l,c=e[i],u=null,h=c>239?4:c>223?3:c>191?2:1;if(i+h<=r)switch(h){case 1:c<128&&(u=c);break;case 2:(192&(o=e[i+1]))==128&&(l=(31&c)<<6|63&o)>127&&(u=l);break;case 3:o=e[i+1],a=e[i+2],(192&o)==128&&(192&a)==128&&(l=(15&c)<<12|(63&o)<<6|63&a)>2047&&(l<55296||l>57343)&&(u=l);break;case 4:o=e[i+1],a=e[i+2],s=e[i+3],(192&o)==128&&(192&a)==128&&(192&s)==128&&(l=(15&c)<<18|(63&o)<<12|(63&a)<<6|63&s)>65535&&l<1114112&&(u=l)}null===u?(u=65533,h=1):u>65535&&(u-=65536,n.push(u>>>10&1023|55296),u=56320|1023&u),n.push(u),i+=h}var f=n,d=f.length;if(d<=4096)return String.fromCharCode.apply(String,f);for(var p="",g=0;g<d;)p+=String.fromCharCode.apply(String,f.slice(g,g+=4096));return p}function b(e,t,r){if(e%1!=0||e<0)throw RangeError("offset is not uint");if(e+t>r)throw RangeError("Trying to access beyond buffer length")}function v(e,t,r,n,i,o){if(!s.isBuffer(e))throw TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<o)throw RangeError('"value" argument is out of bounds');if(r+n>e.length)throw RangeError("Index out of range")}function S(e,t,r,n,i,o){if(r+n>e.length||r<0)throw RangeError("Index out of range")}function E(e,t,r,n,o){return t*=1,r>>>=0,o||S(e,t,r,4,34028234663852886e22,-34028234663852886e22),i.write(e,t,r,n,23,4),r+4}function _(e,t,r,n,o){return t*=1,r>>>=0,o||S(e,t,r,8,17976931348623157e292,-17976931348623157e292),i.write(e,t,r,n,52,8),r+8}s.prototype.write=function(e,t,r,n){if(void 0===t)n="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)n=t,r=this.length,t=0;else if(isFinite(t))t>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0);else throw Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var i,o,a,s,l,c,u,h,f=this.length-t;if((void 0===r||r>f)&&(r=f),e.length>0&&(r<0||t<0)||t>this.length)throw RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var d=!1;;)switch(n){case"hex":return function(e,t,r,n){r=Number(r)||0;var i=e.length-r;n?(n=Number(n))>i&&(n=i):n=i;var o=t.length;n>o/2&&(n=o/2);for(var a=0;a<n;++a){var s,l=parseInt(t.substr(2*a,2),16);if((s=l)!=s)break;e[r+a]=l}return a}(this,e,t,r);case"utf8":case"utf-8":return i=t,o=r,O(A(e,this.length-i),this,i,o);case"ascii":return a=t,s=r,O(T(e),this,a,s);case"latin1":case"binary":return function(e,t,r,n){return O(T(t),e,r,n)}(this,e,t,r);case"base64":return l=t,c=r,O(R(e),this,l,c);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return u=t,h=r,O(function(e,t){for(var r,n,i=[],o=0;o<e.length&&!((t-=2)<0);++o)n=(r=e.charCodeAt(o))>>8,i.push(r%256),i.push(n);return i}(e,this.length-u),this,u,h);default:if(d)throw TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),d=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},s.prototype.slice=function(e,t){var r=this.length;e=~~e,t=void 0===t?r:~~t,e<0?(e+=r)<0&&(e=0):e>r&&(e=r),t<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e);var n=this.subarray(e,t);return Object.setPrototypeOf(n,s.prototype),n},s.prototype.readUIntLE=function(e,t,r){e>>>=0,t>>>=0,r||b(e,t,this.length);for(var n=this[e],i=1,o=0;++o<t&&(i*=256);)n+=this[e+o]*i;return n},s.prototype.readUIntBE=function(e,t,r){e>>>=0,t>>>=0,r||b(e,t,this.length);for(var n=this[e+--t],i=1;t>0&&(i*=256);)n+=this[e+--t]*i;return n},s.prototype.readUInt8=function(e,t){return e>>>=0,t||b(e,1,this.length),this[e]},s.prototype.readUInt16LE=function(e,t){return e>>>=0,t||b(e,2,this.length),this[e]|this[e+1]<<8},s.prototype.readUInt16BE=function(e,t){return e>>>=0,t||b(e,2,this.length),this[e]<<8|this[e+1]},s.prototype.readUInt32LE=function(e,t){return e>>>=0,t||b(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+0x1000000*this[e+3]},s.prototype.readUInt32BE=function(e,t){return e>>>=0,t||b(e,4,this.length),0x1000000*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},s.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||b(e,t,this.length);for(var n=this[e],i=1,o=0;++o<t&&(i*=256);)n+=this[e+o]*i;return n>=(i*=128)&&(n-=Math.pow(2,8*t)),n},s.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||b(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},s.prototype.readInt8=function(e,t){return(e>>>=0,t||b(e,1,this.length),128&this[e])?-((255-this[e]+1)*1):this[e]},s.prototype.readInt16LE=function(e,t){e>>>=0,t||b(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?0xffff0000|r:r},s.prototype.readInt16BE=function(e,t){e>>>=0,t||b(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?0xffff0000|r:r},s.prototype.readInt32LE=function(e,t){return e>>>=0,t||b(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},s.prototype.readInt32BE=function(e,t){return e>>>=0,t||b(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},s.prototype.readFloatLE=function(e,t){return e>>>=0,t||b(e,4,this.length),i.read(this,e,!0,23,4)},s.prototype.readFloatBE=function(e,t){return e>>>=0,t||b(e,4,this.length),i.read(this,e,!1,23,4)},s.prototype.readDoubleLE=function(e,t){return e>>>=0,t||b(e,8,this.length),i.read(this,e,!0,52,8)},s.prototype.readDoubleBE=function(e,t){return e>>>=0,t||b(e,8,this.length),i.read(this,e,!1,52,8)},s.prototype.writeUIntLE=function(e,t,r,n){if(e*=1,t>>>=0,r>>>=0,!n){var i=Math.pow(2,8*r)-1;v(this,e,t,r,i,0)}var o=1,a=0;for(this[t]=255&e;++a<r&&(o*=256);)this[t+a]=e/o&255;return t+r},s.prototype.writeUIntBE=function(e,t,r,n){if(e*=1,t>>>=0,r>>>=0,!n){var i=Math.pow(2,8*r)-1;v(this,e,t,r,i,0)}var o=r-1,a=1;for(this[t+o]=255&e;--o>=0&&(a*=256);)this[t+o]=e/a&255;return t+r},s.prototype.writeUInt8=function(e,t,r){return e*=1,t>>>=0,r||v(this,e,t,1,255,0),this[t]=255&e,t+1},s.prototype.writeUInt16LE=function(e,t,r){return e*=1,t>>>=0,r||v(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},s.prototype.writeUInt16BE=function(e,t,r){return e*=1,t>>>=0,r||v(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},s.prototype.writeUInt32LE=function(e,t,r){return e*=1,t>>>=0,r||v(this,e,t,4,0xffffffff,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},s.prototype.writeUInt32BE=function(e,t,r){return e*=1,t>>>=0,r||v(this,e,t,4,0xffffffff,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},s.prototype.writeIntLE=function(e,t,r,n){if(e*=1,t>>>=0,!n){var i=Math.pow(2,8*r-1);v(this,e,t,r,i-1,-i)}var o=0,a=1,s=0;for(this[t]=255&e;++o<r&&(a*=256);)e<0&&0===s&&0!==this[t+o-1]&&(s=1),this[t+o]=(e/a|0)-s&255;return t+r},s.prototype.writeIntBE=function(e,t,r,n){if(e*=1,t>>>=0,!n){var i=Math.pow(2,8*r-1);v(this,e,t,r,i-1,-i)}var o=r-1,a=1,s=0;for(this[t+o]=255&e;--o>=0&&(a*=256);)e<0&&0===s&&0!==this[t+o+1]&&(s=1),this[t+o]=(e/a|0)-s&255;return t+r},s.prototype.writeInt8=function(e,t,r){return e*=1,t>>>=0,r||v(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},s.prototype.writeInt16LE=function(e,t,r){return e*=1,t>>>=0,r||v(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},s.prototype.writeInt16BE=function(e,t,r){return e*=1,t>>>=0,r||v(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},s.prototype.writeInt32LE=function(e,t,r){return e*=1,t>>>=0,r||v(this,e,t,4,0x7fffffff,-0x80000000),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},s.prototype.writeInt32BE=function(e,t,r){return e*=1,t>>>=0,r||v(this,e,t,4,0x7fffffff,-0x80000000),e<0&&(e=0xffffffff+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},s.prototype.writeFloatLE=function(e,t,r){return E(this,e,t,!0,r)},s.prototype.writeFloatBE=function(e,t,r){return E(this,e,t,!1,r)},s.prototype.writeDoubleLE=function(e,t,r){return _(this,e,t,!0,r)},s.prototype.writeDoubleBE=function(e,t,r){return _(this,e,t,!1,r)},s.prototype.copy=function(e,t,r,n){if(!s.isBuffer(e))throw TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n<r&&(n=r),n===r||0===e.length||0===this.length)return 0;if(t<0)throw RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw RangeError("Index out of range");if(n<0)throw RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t<n-r&&(n=e.length-t+r);var i=n-r;if(this===e&&"function"==typeof Uint8Array.prototype.copyWithin)this.copyWithin(t,r,n);else if(this===e&&r<t&&t<n)for(var o=i-1;o>=0;--o)e[o+t]=this[o+r];else Uint8Array.prototype.set.call(e,this.subarray(r,n),t);return i},s.prototype.fill=function(e,t,r,n){if("string"==typeof e){if("string"==typeof t?(n=t,t=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw TypeError("encoding must be a string");if("string"==typeof n&&!s.isEncoding(n))throw TypeError("Unknown encoding: "+n);if(1===e.length){var i,o=e.charCodeAt(0);("utf8"===n&&o<128||"latin1"===n)&&(e=o)}}else"number"==typeof e?e&=255:"boolean"==typeof e&&(e=Number(e));if(t<0||this.length<t||this.length<r)throw RangeError("Out of range index");if(r<=t)return this;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(i=t;i<r;++i)this[i]=e;else{var a=s.isBuffer(e)?e:s.from(e,n),l=a.length;
194if(0===l)throw TypeError('The value "'+e+'" is invalid for argument "value"');for(i=0;i<r-t;++i)this[i+t]=a[i%l]}return this};var k=/[^+/0-9A-Za-z-_]/g;function A(e,t){t=t||1/0;for(var r,n=e.length,i=null,o=[],a=0;a<n;++a){if((r=e.charCodeAt(a))>55295&&r<57344){if(!i){if(r>56319||a+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else if(r<1114112){if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}else throw Error("Invalid code point")}return o}function T(e){for(var t=[],r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}function R(e){return n.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(k,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function O(e,t,r,n){for(var i=0;i<n&&!(i+r>=t.length)&&!(i>=e.length);++i)t[i+r]=e[i];return i}function C(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}var I=function(){for(var e="0123456789abcdef",t=Array(256),r=0;r<16;++r)for(var n=16*r,i=0;i<16;++i)t[n+i]=e[r]+e[i];return t}()},321:function(e,t){t.read=function(e,t,r,n,i){var o,a,s=8*i-n-1,l=(1<<s)-1,c=l>>1,u=-7,h=r?i-1:0,f=r?-1:1,d=e[t+h];for(h+=f,o=d&(1<<-u)-1,d>>=-u,u+=s;u>0;o=256*o+e[t+h],h+=f,u-=8);for(a=o&(1<<-u)-1,o>>=-u,u+=n;u>0;a=256*a+e[t+h],h+=f,u-=8);if(0===o)o=1-c;else{if(o===l)return a?NaN:1/0*(d?-1:1);a+=Math.pow(2,n),o-=c}return(d?-1:1)*a*Math.pow(2,o-n)},t.write=function(e,t,r,n,i,o){var a,s,l,c=8*o-i-1,u=(1<<c)-1,h=u>>1,f=5960464477539062e-23*(23===i),d=n?0:o-1,p=n?1:-1,g=+(t<0||0===t&&1/t<0);for(isNaN(t=Math.abs(t))||t===1/0?(s=+!!isNaN(t),a=u):(a=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-a))<1&&(a--,l*=2),a+h>=1?t+=f/l:t+=f*Math.pow(2,1-h),t*l>=2&&(a++,l/=2),a+h>=u?(s=0,a=u):a+h>=1?(s=(t*l-1)*Math.pow(2,i),a+=h):(s=t*Math.pow(2,h-1)*Math.pow(2,i),a=0));i>=8;e[r+d]=255&s,d+=p,s/=256,i-=8);for(a=a<<i|s,c+=i;c>0;e[r+d]=255&a,d+=p,a/=256,c-=8);e[r+d-p]|=128*g}}},i={};function o(e){var t=i[e];if(void 0!==t)return t.exports;var r=i[e]={exports:{}},a=!0;try{n[e](r,r.exports,o),a=!1}finally{a&&delete i[e]}return r.exports}o.ab="/ROOT/node_modules/.pnpm/[email protected]_@[email protected][email protected]__@[email protected][email protected][email protected][email protected]/node_modules/next/dist/compiled/buffer/",t.exports=o(230)}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.