autogram-sdk
Version:
SDK for Autogram signer
2 lines • 102 kB
JavaScript
var AutogramSDK=(()=>{var xn=Object.create;var Ve=Object.defineProperty,wn=Object.defineProperties,Sn=Object.getOwnPropertyDescriptor,En=Object.getOwnPropertyDescriptors,Tn=Object.getOwnPropertyNames,fr=Object.getOwnPropertySymbols,An=Object.getPrototypeOf,pr=Object.prototype.hasOwnProperty,Cn=Object.prototype.propertyIsEnumerable;var mr=Math.pow,hr=(t,e,r)=>e in t?Ve(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,c=(t,e)=>{for(var r in e||(e={}))pr.call(e,r)&&hr(t,r,e[r]);if(fr)for(var r of fr(e))Cn.call(e,r)&&hr(t,r,e[r]);return t},y=(t,e)=>wn(t,En(e));var kn=(t=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(t,{get:(e,r)=>(typeof require!="undefined"?require:e)[r]}):t)(function(t){if(typeof require!="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var Rn=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),In=(t,e)=>{for(var r in e)Ve(t,r,{get:e[r],enumerable:!0})},yr=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Tn(e))!pr.call(t,s)&&s!==r&&Ve(t,s,{get:()=>e[s],enumerable:!(n=Sn(e,s))||n.enumerable});return t};var Pt=(t,e,r)=>(r=t!=null?xn(An(t)):{},yr(e||!t||!t.__esModule?Ve(r,"default",{value:t,enumerable:!0}):r,t)),Pn=t=>yr(Ve({},"__esModule",{value:!0}),t);var b=(t,e,r)=>new Promise((n,s)=>{var a=l=>{try{o(r.next(l))}catch(f){s(f)}},i=l=>{try{o(r.throw(l))}catch(f){s(f)}},o=l=>l.done?n(l.value):Promise.resolve(l.value).then(a,i);o((r=r.apply(t,e)).next())});var Dt=Rn((te,gr)=>{var ot=typeof globalThis!="undefined"&&globalThis||typeof self!="undefined"&&self||typeof global!="undefined"&&global,ct=function(){function t(){this.fetch=!1,this.DOMException=ot.DOMException}return t.prototype=ot,new t}();(function(t){var e=function(r){var n=typeof t!="undefined"&&t||typeof self!="undefined"&&self||typeof n!="undefined"&&n,s={searchParams:"URLSearchParams"in n,iterable:"Symbol"in n&&"iterator"in Symbol,blob:"FileReader"in n&&"Blob"in n&&function(){try{return new Blob,!0}catch(u){return!1}}(),formData:"FormData"in n,arrayBuffer:"ArrayBuffer"in n};function a(u){return u&&DataView.prototype.isPrototypeOf(u)}if(s.arrayBuffer)var i=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],o=ArrayBuffer.isView||function(u){return u&&i.indexOf(Object.prototype.toString.call(u))>-1};function l(u){if(typeof u!="string"&&(u=String(u)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(u)||u==="")throw new TypeError('Invalid character in header field name: "'+u+'"');return u.toLowerCase()}function f(u){return typeof u!="string"&&(u=String(u)),u}function g(u){var h={next:function(){var T=u.shift();return{done:T===void 0,value:T}}};return s.iterable&&(h[Symbol.iterator]=function(){return h}),h}function w(u){this.map={},u instanceof w?u.forEach(function(h,T){this.append(T,h)},this):Array.isArray(u)?u.forEach(function(h){this.append(h[0],h[1])},this):u&&Object.getOwnPropertyNames(u).forEach(function(h){this.append(h,u[h])},this)}w.prototype.append=function(u,h){u=l(u),h=f(h);var T=this.map[u];this.map[u]=T?T+", "+h:h},w.prototype.delete=function(u){delete this.map[l(u)]},w.prototype.get=function(u){return u=l(u),this.has(u)?this.map[u]:null},w.prototype.has=function(u){return this.map.hasOwnProperty(l(u))},w.prototype.set=function(u,h){this.map[l(u)]=f(h)},w.prototype.forEach=function(u,h){for(var T in this.map)this.map.hasOwnProperty(T)&&u.call(h,this.map[T],T,this)},w.prototype.keys=function(){var u=[];return this.forEach(function(h,T){u.push(T)}),g(u)},w.prototype.values=function(){var u=[];return this.forEach(function(h){u.push(h)}),g(u)},w.prototype.entries=function(){var u=[];return this.forEach(function(h,T){u.push([T,h])}),g(u)},s.iterable&&(w.prototype[Symbol.iterator]=w.prototype.entries);function W(u){if(u.bodyUsed)return Promise.reject(new TypeError("Already read"));u.bodyUsed=!0}function z(u){return new Promise(function(h,T){u.onload=function(){h(u.result)},u.onerror=function(){T(u.error)}})}function Te(u){var h=new FileReader,T=z(h);return h.readAsArrayBuffer(u),T}function Rt(u){var h=new FileReader,T=z(h);return h.readAsText(u),T}function st(u){for(var h=new Uint8Array(u),T=new Array(h.length),R=0;R<h.length;R++)T[R]=String.fromCharCode(h[R]);return T.join("")}function oe(u){if(u.slice)return u.slice(0);var h=new Uint8Array(u.byteLength);return h.set(new Uint8Array(u)),h.buffer}function lr(){return this.bodyUsed=!1,this._initBody=function(u){this.bodyUsed=this.bodyUsed,this._bodyInit=u,u?typeof u=="string"?this._bodyText=u:s.blob&&Blob.prototype.isPrototypeOf(u)?this._bodyBlob=u:s.formData&&FormData.prototype.isPrototypeOf(u)?this._bodyFormData=u:s.searchParams&&URLSearchParams.prototype.isPrototypeOf(u)?this._bodyText=u.toString():s.arrayBuffer&&s.blob&&a(u)?(this._bodyArrayBuffer=oe(u.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):s.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(u)||o(u))?this._bodyArrayBuffer=oe(u):this._bodyText=u=Object.prototype.toString.call(u):this._bodyText="",this.headers.get("content-type")||(typeof u=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):s.searchParams&&URLSearchParams.prototype.isPrototypeOf(u)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},s.blob&&(this.blob=function(){var u=W(this);if(u)return u;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){if(this._bodyArrayBuffer){var u=W(this);return u||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}else return this.blob().then(Te)}),this.text=function(){var u=W(this);if(u)return u;if(this._bodyBlob)return Rt(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(st(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},s.formData&&(this.formData=function(){return this.text().then(gn)}),this.json=function(){return this.text().then(JSON.parse)},this}var mn=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function yn(u){var h=u.toUpperCase();return mn.indexOf(h)>-1?h:u}function ee(u,h){if(!(this instanceof ee))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');h=h||{};var T=h.body;if(u instanceof ee){if(u.bodyUsed)throw new TypeError("Already read");this.url=u.url,this.credentials=u.credentials,h.headers||(this.headers=new w(u.headers)),this.method=u.method,this.mode=u.mode,this.signal=u.signal,!T&&u._bodyInit!=null&&(T=u._bodyInit,u.bodyUsed=!0)}else this.url=String(u);if(this.credentials=h.credentials||this.credentials||"same-origin",(h.headers||!this.headers)&&(this.headers=new w(h.headers)),this.method=yn(h.method||this.method||"GET"),this.mode=h.mode||this.mode||null,this.signal=h.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&T)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(T),(this.method==="GET"||this.method==="HEAD")&&(h.cache==="no-store"||h.cache==="no-cache")){var R=/([?&])_=[^&]*/;if(R.test(this.url))this.url=this.url.replace(R,"$1_="+new Date().getTime());else{var I=/\?/;this.url+=(I.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}ee.prototype.clone=function(){return new ee(this,{body:this._bodyInit})};function gn(u){var h=new FormData;return u.trim().split("&").forEach(function(T){if(T){var R=T.split("="),I=R.shift().replace(/\+/g," "),k=R.join("=").replace(/\+/g," ");h.append(decodeURIComponent(I),decodeURIComponent(k))}}),h}function _n(u){var h=new w,T=u.replace(/\r?\n[\t ]+/g," ");return T.split("\r").map(function(R){return R.indexOf(`
`)===0?R.substr(1,R.length):R}).forEach(function(R){var I=R.split(":"),k=I.shift().trim();if(k){var at=I.join(":").trim();h.append(k,at)}}),h}lr.call(ee.prototype);function L(u,h){if(!(this instanceof L))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');h||(h={}),this.type="default",this.status=h.status===void 0?200:h.status,this.ok=this.status>=200&&this.status<300,this.statusText=h.statusText===void 0?"":""+h.statusText,this.headers=new w(h.headers),this.url=h.url||"",this._initBody(u)}lr.call(L.prototype),L.prototype.clone=function(){return new L(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new w(this.headers),url:this.url})},L.error=function(){var u=new L(null,{status:0,statusText:""});return u.type="error",u};var vn=[301,302,303,307,308];L.redirect=function(u,h){if(vn.indexOf(h)===-1)throw new RangeError("Invalid status code");return new L(null,{status:h,headers:{location:u}})},r.DOMException=n.DOMException;try{new r.DOMException}catch(u){r.DOMException=function(h,T){this.message=h,this.name=T;var R=Error(h);this.stack=R.stack},r.DOMException.prototype=Object.create(Error.prototype),r.DOMException.prototype.constructor=r.DOMException}function It(u,h){return new Promise(function(T,R){var I=new ee(u,h);if(I.signal&&I.signal.aborted)return R(new r.DOMException("Aborted","AbortError"));var k=new XMLHttpRequest;function at(){k.abort()}k.onload=function(){var B={status:k.status,statusText:k.statusText,headers:_n(k.getAllResponseHeaders()||"")};B.url="responseURL"in k?k.responseURL:B.headers.get("X-Request-URL");var it="response"in k?k.response:k.responseText;setTimeout(function(){T(new L(it,B))},0)},k.onerror=function(){setTimeout(function(){R(new TypeError("Network request failed"))},0)},k.ontimeout=function(){setTimeout(function(){R(new TypeError("Network request failed"))},0)},k.onabort=function(){setTimeout(function(){R(new r.DOMException("Aborted","AbortError"))},0)};function bn(B){try{return B===""&&n.location.href?n.location.href:B}catch(it){return B}}k.open(I.method,bn(I.url),!0),I.credentials==="include"?k.withCredentials=!0:I.credentials==="omit"&&(k.withCredentials=!1),"responseType"in k&&(s.blob?k.responseType="blob":s.arrayBuffer&&I.headers.get("Content-Type")&&I.headers.get("Content-Type").indexOf("application/octet-stream")!==-1&&(k.responseType="arraybuffer")),h&&typeof h.headers=="object"&&!(h.headers instanceof w)?Object.getOwnPropertyNames(h.headers).forEach(function(B){k.setRequestHeader(B,f(h.headers[B]))}):I.headers.forEach(function(B,it){k.setRequestHeader(it,B)}),I.signal&&(I.signal.addEventListener("abort",at),k.onreadystatechange=function(){k.readyState===4&&I.signal.removeEventListener("abort",at)}),k.send(typeof I._bodyInit=="undefined"?null:I._bodyInit)})}return It.polyfill=!0,n.fetch||(n.fetch=It,n.Headers=w,n.Request=ee,n.Response=L),r.Headers=w,r.Request=ee,r.Response=L,r.fetch=It,r}({})})(ct);ct.fetch.ponyfill=!0;delete ct.fetch.polyfill;var Ae=ot.fetch?ot:ct;te=Ae.fetch;te.default=Ae.fetch;te.fetch=Ae.fetch;te.Headers=Ae.Headers;te.Request=Ae.Request;te.Response=Ae.Response;gr.exports=te});var pa={};In(pa,{AVMGetDocumentsResponse:()=>Ct,AutogramVMobileIntegration:()=>tt,AutogramVMobileSimulation:()=>nt,DesktopUserCancelledSigningException:()=>Ce,desktopApiClient:()=>jt,randomUUID:()=>kt});var ut=Pt(Dt());var Dn=Array.from(Array(256).keys()).map(t=>t.toString(16).padStart(2,"0"));function _r(t){return Array.prototype.map.call(t,e=>Dn[e]).join("")}function vr(t){return new DataView(t.buffer,0).getUint32(0)}function Ot(t){return crypto.getRandomValues(new Uint8Array(t))}function jt(t){let e={serverProtocol:"http",serverHost:"localhost",serverPort:37200,customProtocol:"autogram",disableSecurity:!1,requestsOrigin:typeof location!="undefined"?location.origin:"*",secretKey:_r(Ot(32)),secretInitialNonce:vr(Ot(4)),language:"sk"},r=c(c({},e),t),n=new URL(`${r.serverProtocol}://${r.serverHost}:${r.serverPort}`);return{getLaunchURL(s="listen"){let a=new URLSearchParams;return a.set("protocol",r.serverProtocol),a.set("port",r.serverPort.toString()),a.set("host",r.serverHost),a.set("origin",r.requestsOrigin),r.language&&a.set("language",r.language),r.disableSecurity||(r.secretKey&&a.set("key",r.secretKey),r.secretInitialNonce&&a.set("nonce",r.secretInitialNonce.toString())),`${r.customProtocol}://${s}?${a}`},info(){let s=new URL("info",n),a={cache:"no-store"};return(0,ut.default)(s.toString(),a).then(i=>i.json())},waitForStatus(s,a=60,i=4,o){let l=new URL("info",n);return new Promise((f,g)=>b(this,null,function*(){let w,W,z=new Error("No request ever finished"),Te=!1;o&&o.signal.addEventListener("abort",()=>{w.signal.aborted||w.abort(),Te=!0,g(new Error("Aborted"))});let Rt=setTimeout(()=>{w.signal.aborted||w.abort(),Te=!0,g(z)},a*1e3);for(;!Te;){w=new AbortController;let st=setTimeout(()=>{w.signal.aborted||w.abort()},(i+1)*1e3);try{if(W=yield(yield(0,ut.default)(l.toString(),{cache:"no-store",signal:w.signal})).json(),W.status===s){Te=!0,clearTimeout(Rt),clearTimeout(st),f(W);break}}catch(oe){clearTimeout(st),oe.name!=="AbortError"&&(z=oe)}yield new Promise(oe=>setTimeout(oe,i*1e3))}}))},sign(s,a={level:"XAdES_BASELINE_B",checkPDFACompliance:!0},i="application/xml"){let o=new URL("sign",n),f={method:"POST",headers:{"Content-Type":"text/plain"},cache:"no-store",body:JSON.stringify({document:s,parameters:a,payloadMimeType:i})};return(0,ut.default)(o.toString(),f).then(g=>{if(g.status==204)throw new Ce;return g.json()})}}}var Ce=class{};var ke=crypto,dt=t=>t instanceof CryptoKey;var q=new TextEncoder,We=new TextDecoder,ka=mr(2,32);function br(...t){let e=t.reduce((s,{length:a})=>s+a,0),r=new Uint8Array(e),n=0;for(let s of t)r.set(s,n),n+=s.length;return r}var On=t=>{let e=t;typeof e=="string"&&(e=q.encode(e));let r=32768,n=[];for(let s=0;s<e.length;s+=r)n.push(String.fromCharCode.apply(null,e.subarray(s,s+r)));return btoa(n.join(""))},lt=t=>On(t).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_"),jn=t=>{let e=atob(t),r=new Uint8Array(e.length);for(let n=0;n<e.length;n++)r[n]=e.charCodeAt(n);return r},ft=t=>{let e=t;e instanceof Uint8Array&&(e=We.decode(e)),e=e.replace(/-/g,"+").replace(/_/g,"/").replace(/\s/g,"");try{return jn(e)}catch(r){throw new TypeError("The input to be decoded is not correctly encoded.")}};var P=class extends Error{constructor(e,r){var n;super(e,r),this.code="ERR_JOSE_GENERIC",this.name=this.constructor.name,(n=Error.captureStackTrace)==null||n.call(Error,this,this.constructor)}};P.code="ERR_JOSE_GENERIC";var Nt=class extends P{constructor(e,r,n="unspecified",s="unspecified"){super(e,{cause:{claim:n,reason:s,payload:r}}),this.code="ERR_JWT_CLAIM_VALIDATION_FAILED",this.claim=n,this.reason=s,this.payload=r}};Nt.code="ERR_JWT_CLAIM_VALIDATION_FAILED";var Ut=class extends P{constructor(e,r,n="unspecified",s="unspecified"){super(e,{cause:{claim:n,reason:s,payload:r}}),this.code="ERR_JWT_EXPIRED",this.claim=n,this.reason=s,this.payload=r}};Ut.code="ERR_JWT_EXPIRED";var Kt=class extends P{constructor(){super(...arguments),this.code="ERR_JOSE_ALG_NOT_ALLOWED"}};Kt.code="ERR_JOSE_ALG_NOT_ALLOWED";var M=class extends P{constructor(){super(...arguments),this.code="ERR_JOSE_NOT_SUPPORTED"}};M.code="ERR_JOSE_NOT_SUPPORTED";var Bt=class extends P{constructor(e="decryption operation failed",r){super(e,r),this.code="ERR_JWE_DECRYPTION_FAILED"}};Bt.code="ERR_JWE_DECRYPTION_FAILED";var Mt=class extends P{constructor(){super(...arguments),this.code="ERR_JWE_INVALID"}};Mt.code="ERR_JWE_INVALID";var G=class extends P{constructor(){super(...arguments),this.code="ERR_JWS_INVALID"}};G.code="ERR_JWS_INVALID";var He=class extends P{constructor(){super(...arguments),this.code="ERR_JWT_INVALID"}};He.code="ERR_JWT_INVALID";var $t=class extends P{constructor(){super(...arguments),this.code="ERR_JWK_INVALID"}};$t.code="ERR_JWK_INVALID";var Zt=class extends P{constructor(){super(...arguments),this.code="ERR_JWKS_INVALID"}};Zt.code="ERR_JWKS_INVALID";var Lt=class extends P{constructor(e="no applicable key found in the JSON Web Key Set",r){super(e,r),this.code="ERR_JWKS_NO_MATCHING_KEY"}};Lt.code="ERR_JWKS_NO_MATCHING_KEY";var Vt=class extends P{constructor(e="multiple matching keys found in the JSON Web Key Set",r){super(e,r),this.code="ERR_JWKS_MULTIPLE_MATCHING_KEYS"}};Vt.code="ERR_JWKS_MULTIPLE_MATCHING_KEYS";var Wt=class extends P{constructor(e="request timed out",r){super(e,r),this.code="ERR_JWKS_TIMEOUT"}};Wt.code="ERR_JWKS_TIMEOUT";var Ht=class extends P{constructor(e="signature verification failed",r){super(e,r),this.code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED"}};Ht.code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED";function F(t,e="algorithm.name"){return new TypeError(`CryptoKey does not support this operation, its ${e} must be ${t}`)}function ht(t,e){return t.name===e}function Jt(t){return parseInt(t.name.slice(4),10)}function Nn(t){switch(t){case"ES256":return"P-256";case"ES384":return"P-384";case"ES512":return"P-521";default:throw new Error("unreachable")}}function Un(t,e){if(e.length&&!e.some(r=>t.usages.includes(r))){let r="CryptoKey does not support this operation, its usages must include ";if(e.length>2){let n=e.pop();r+=`one of ${e.join(", ")}, or ${n}.`}else e.length===2?r+=`one of ${e[0]} or ${e[1]}.`:r+=`${e[0]}.`;throw new TypeError(r)}}function xr(t,e,...r){switch(e){case"HS256":case"HS384":case"HS512":{if(!ht(t.algorithm,"HMAC"))throw F("HMAC");let n=parseInt(e.slice(2),10);if(Jt(t.algorithm.hash)!==n)throw F(`SHA-${n}`,"algorithm.hash");break}case"RS256":case"RS384":case"RS512":{if(!ht(t.algorithm,"RSASSA-PKCS1-v1_5"))throw F("RSASSA-PKCS1-v1_5");let n=parseInt(e.slice(2),10);if(Jt(t.algorithm.hash)!==n)throw F(`SHA-${n}`,"algorithm.hash");break}case"PS256":case"PS384":case"PS512":{if(!ht(t.algorithm,"RSA-PSS"))throw F("RSA-PSS");let n=parseInt(e.slice(2),10);if(Jt(t.algorithm.hash)!==n)throw F(`SHA-${n}`,"algorithm.hash");break}case"EdDSA":{if(t.algorithm.name!=="Ed25519"&&t.algorithm.name!=="Ed448")throw F("Ed25519 or Ed448");break}case"ES256":case"ES384":case"ES512":{if(!ht(t.algorithm,"ECDSA"))throw F("ECDSA");let n=Nn(e);if(t.algorithm.namedCurve!==n)throw F(n,"algorithm.namedCurve");break}default:throw new TypeError("CryptoKey does not support this operation")}Un(t,r)}function wr(t,e,...r){var n;if(r=r.filter(Boolean),r.length>2){let s=r.pop();t+=`one of type ${r.join(", ")}, or ${s}.`}else r.length===2?t+=`one of type ${r[0]} or ${r[1]}.`:t+=`of type ${r[0]}.`;return e==null?t+=` Received ${e}`:typeof e=="function"&&e.name?t+=` Received function ${e.name}`:typeof e=="object"&&e!=null&&(n=e.constructor)!=null&&n.name&&(t+=` Received an instance of ${e.constructor.name}`),t}var zt=(t,...e)=>wr("Key must be ",t,...e);function qt(t,e,...r){return wr(`Key for the ${t} algorithm must be `,e,...r)}var Gt=t=>dt(t)?!0:(t==null?void 0:t[Symbol.toStringTag])==="KeyObject",Re=["CryptoKey"];var Kn=(...t)=>{let e=t.filter(Boolean);if(e.length===0||e.length===1)return!0;let r;for(let n of e){let s=Object.keys(n);if(!r||r.size===0){r=new Set(s);continue}for(let a of s){if(r.has(a))return!1;r.add(a)}}return!0},Sr=Kn;function Bn(t){return typeof t=="object"&&t!==null}function Je(t){if(!Bn(t)||Object.prototype.toString.call(t)!=="[object Object]")return!1;if(Object.getPrototypeOf(t)===null)return!0;let e=t;for(;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}var Er=(t,e)=>{if(t.startsWith("RS")||t.startsWith("PS")){let{modulusLength:r}=e.algorithm;if(typeof r!="number"||r<2048)throw new TypeError(`${t} requires key modulusLength to be 2048 bits or larger`)}};function ce(t){return Je(t)&&typeof t.kty=="string"}function Tr(t){return t.kty!=="oct"&&typeof t.d=="string"}function Ar(t){return t.kty!=="oct"&&typeof t.d=="undefined"}function Cr(t){return ce(t)&&t.kty==="oct"&&typeof t.k=="string"}function $n(t){let e,r;switch(t.kty){case"RSA":{switch(t.alg){case"PS256":case"PS384":case"PS512":e={name:"RSA-PSS",hash:`SHA-${t.alg.slice(-3)}`},r=t.d?["sign"]:["verify"];break;case"RS256":case"RS384":case"RS512":e={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${t.alg.slice(-3)}`},r=t.d?["sign"]:["verify"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":e={name:"RSA-OAEP",hash:`SHA-${parseInt(t.alg.slice(-3),10)||1}`},r=t.d?["decrypt","unwrapKey"]:["encrypt","wrapKey"];break;default:throw new M('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break}case"EC":{switch(t.alg){case"ES256":e={name:"ECDSA",namedCurve:"P-256"},r=t.d?["sign"]:["verify"];break;case"ES384":e={name:"ECDSA",namedCurve:"P-384"},r=t.d?["sign"]:["verify"];break;case"ES512":e={name:"ECDSA",namedCurve:"P-521"},r=t.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":e={name:"ECDH",namedCurve:t.crv},r=t.d?["deriveBits"]:[];break;default:throw new M('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break}case"OKP":{switch(t.alg){case"EdDSA":e={name:t.crv},r=t.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":e={name:t.crv},r=t.d?["deriveBits"]:[];break;default:throw new M('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break}default:throw new M('Invalid or unsupported JWK "kty" (Key Type) Parameter value')}return{algorithm:e,keyUsages:r}}var Zn=t=>b(void 0,null,function*(){var a,i;if(!t.alg)throw new TypeError('"alg" argument is required when "jwk.alg" is not present');let{algorithm:e,keyUsages:r}=$n(t),n=[e,(a=t.ext)!=null?a:!1,(i=t.key_ops)!=null?i:r],s=c({},t);return delete s.alg,delete s.use,ke.subtle.importKey("jwk",s,...n)}),kr=Zn;var Rr=t=>ft(t),Ie,Pe,Ir=t=>(t==null?void 0:t[Symbol.toStringTag])==="KeyObject",pt=(t,e,r,n,s=!1)=>b(void 0,null,function*(){let a=t.get(e);if(a!=null&&a[n])return a[n];let i=yield kr(y(c({},r),{alg:n}));return s&&Object.freeze(e),a?a[n]=i:t.set(e,{[n]:i}),i}),Ln=(t,e)=>{if(Ir(t)){let r=t.export({format:"jwk"});return delete r.d,delete r.dp,delete r.dq,delete r.p,delete r.q,delete r.qi,r.k?Rr(r.k):(Pe||(Pe=new WeakMap),pt(Pe,t,r,e))}return ce(t)?t.k?ft(t.k):(Pe||(Pe=new WeakMap),pt(Pe,t,t,e,!0)):t},Vn=(t,e)=>{if(Ir(t)){let r=t.export({format:"jwk"});return r.k?Rr(r.k):(Ie||(Ie=new WeakMap),pt(Ie,t,r,e))}return ce(t)?t.k?ft(t.k):(Ie||(Ie=new WeakMap),pt(Ie,t,t,e,!0)):t},Ft={normalizePublicKey:Ln,normalizePrivateKey:Vn};var De=t=>t==null?void 0:t[Symbol.toStringTag],Xt=(t,e,r)=>{var n,s;if(e.use!==void 0&&e.use!=="sig")throw new TypeError("Invalid key for this operation, when present its use must be sig");if(e.key_ops!==void 0&&((s=(n=e.key_ops).includes)==null?void 0:s.call(n,r))!==!0)throw new TypeError(`Invalid key for this operation, when present its key_ops must include ${r}`);if(e.alg!==void 0&&e.alg!==t)throw new TypeError(`Invalid key for this operation, when present its alg must be ${t}`);return!0},Wn=(t,e,r,n)=>{if(!(e instanceof Uint8Array)){if(n&&ce(e)){if(Cr(e)&&Xt(t,e,r))return;throw new TypeError('JSON Web Key for symmetric algorithms must have JWK "kty" (Key Type) equal to "oct" and the JWK "k" (Key Value) present')}if(!Gt(e))throw new TypeError(qt(t,e,...Re,"Uint8Array",n?"JSON Web Key":null));if(e.type!=="secret")throw new TypeError(`${De(e)} instances for symmetric algorithms must be of type "secret"`)}},Hn=(t,e,r,n)=>{if(n&&ce(e))switch(r){case"sign":if(Tr(e)&&Xt(t,e,r))return;throw new TypeError("JSON Web Key for this operation be a private JWK");case"verify":if(Ar(e)&&Xt(t,e,r))return;throw new TypeError("JSON Web Key for this operation be a public JWK")}if(!Gt(e))throw new TypeError(qt(t,e,...Re,n?"JSON Web Key":null));if(e.type==="secret")throw new TypeError(`${De(e)} instances for asymmetric algorithms must not be of type "secret"`);if(r==="sign"&&e.type==="public")throw new TypeError(`${De(e)} instances for asymmetric algorithm signing must be of type "private"`);if(r==="decrypt"&&e.type==="public")throw new TypeError(`${De(e)} instances for asymmetric algorithm decryption must be of type "private"`);if(e.algorithm&&r==="verify"&&e.type==="private")throw new TypeError(`${De(e)} instances for asymmetric algorithm verifying must be of type "public"`);if(e.algorithm&&r==="encrypt"&&e.type==="private")throw new TypeError(`${De(e)} instances for asymmetric algorithm encryption must be of type "public"`)};function Pr(t,e,r,n){e.startsWith("HS")||e==="dir"||e.startsWith("PBES2")||/^A\d{3}(?:GCM)?KW$/.test(e)?Wn(e,r,n,t):Hn(e,r,n,t)}var Qa=Pr.bind(void 0,!1),Dr=Pr.bind(void 0,!0);function Jn(t,e,r,n,s){if(s.crit!==void 0&&(n==null?void 0:n.crit)===void 0)throw new t('"crit" (Critical) Header Parameter MUST be integrity protected');if(!n||n.crit===void 0)return new Set;if(!Array.isArray(n.crit)||n.crit.length===0||n.crit.some(i=>typeof i!="string"||i.length===0))throw new t('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present');let a;r!==void 0?a=new Map([...Object.entries(r),...e.entries()]):a=e;for(let i of n.crit){if(!a.has(i))throw new M(`Extension Header Parameter "${i}" is not recognized`);if(s[i]===void 0)throw new t(`Extension Header Parameter "${i}" is missing`);if(a.get(i)&&n[i]===void 0)throw new t(`Extension Header Parameter "${i}" MUST be integrity protected`)}return new Set(n.crit)}var Or=Jn;function Yt(t,e){let r=`SHA-${t.slice(-3)}`;switch(t){case"HS256":case"HS384":case"HS512":return{hash:r,name:"HMAC"};case"PS256":case"PS384":case"PS512":return{hash:r,name:"RSA-PSS",saltLength:t.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:e.namedCurve};case"EdDSA":return{name:e.name};default:throw new M(`alg ${t} is not supported either by JOSE or your javascript runtime`)}}function Qt(t,e,r){return b(this,null,function*(){if(r==="sign"&&(e=yield Ft.normalizePrivateKey(e,t)),r==="verify"&&(e=yield Ft.normalizePublicKey(e,t)),dt(e))return xr(e,t,r),e;if(e instanceof Uint8Array){if(!t.startsWith("HS"))throw new TypeError(zt(e,...Re));return ke.subtle.importKey("raw",e,{hash:`SHA-${t.slice(-3)}`,name:"HMAC"},!1,[r])}throw new TypeError(zt(e,...Re,"Uint8Array","JSON Web Key"))})}var re=t=>Math.floor(t.getTime()/1e3);var zn=/^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i,mt=t=>{let e=zn.exec(t);if(!e||e[4]&&e[1])throw new TypeError("Invalid time period format");let r=parseFloat(e[2]),n=e[3].toLowerCase(),s;switch(n){case"sec":case"secs":case"second":case"seconds":case"s":s=Math.round(r);break;case"minute":case"minutes":case"min":case"mins":case"m":s=Math.round(r*60);break;case"hour":case"hours":case"hr":case"hrs":case"h":s=Math.round(r*3600);break;case"day":case"days":case"d":s=Math.round(r*86400);break;case"week":case"weeks":case"w":s=Math.round(r*604800);break;default:s=Math.round(r*31557600);break}return e[1]==="-"||e[4]==="ago"?-s:s};var qn=(t,e,r)=>b(void 0,null,function*(){let n=yield Qt(t,e,"sign");Er(t,n);let s=yield ke.subtle.sign(Yt(t,n.algorithm),n,r);return new Uint8Array(s)}),jr=qn;var yt=class{constructor(e){if(!(e instanceof Uint8Array))throw new TypeError("payload must be an instance of Uint8Array");this._payload=e}setProtectedHeader(e){if(this._protectedHeader)throw new TypeError("setProtectedHeader can only be called once");return this._protectedHeader=e,this}setUnprotectedHeader(e){if(this._unprotectedHeader)throw new TypeError("setUnprotectedHeader can only be called once");return this._unprotectedHeader=e,this}sign(e,r){return b(this,null,function*(){if(!this._protectedHeader&&!this._unprotectedHeader)throw new G("either setProtectedHeader or setUnprotectedHeader must be called before #sign()");if(!Sr(this._protectedHeader,this._unprotectedHeader))throw new G("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");let n=c(c({},this._protectedHeader),this._unprotectedHeader),s=Or(G,new Map([["b64",!0]]),r==null?void 0:r.crit,this._protectedHeader,n),a=!0;if(s.has("b64")&&(a=this._protectedHeader.b64,typeof a!="boolean"))throw new G('The "b64" (base64url-encode payload) Header Parameter must be a boolean');let{alg:i}=n;if(typeof i!="string"||!i)throw new G('JWS "alg" (Algorithm) Header Parameter missing or invalid');Dr(i,e,"sign");let o=this._payload;a&&(o=q.encode(lt(o)));let l;this._protectedHeader?l=q.encode(lt(JSON.stringify(this._protectedHeader))):l=q.encode("");let f=br(l,q.encode("."),o),g=yield jr(i,e,f),w={signature:lt(g),payload:""};return a&&(w.payload=We.decode(o)),this._unprotectedHeader&&(w.header=this._unprotectedHeader),this._protectedHeader&&(w.protected=We.decode(l)),w})}};var gt=class{constructor(e){this._flattened=new yt(e)}setProtectedHeader(e){return this._flattened.setProtectedHeader(e),this}sign(e,r){return b(this,null,function*(){let n=yield this._flattened.sign(e,r);if(n.payload===void 0)throw new TypeError("use the flattened module for creating JWS with b64: false");return`${n.protected}.${n.payload}.${n.signature}`})}};function ue(t,e){if(!Number.isFinite(e))throw new TypeError(`Invalid ${t} input`);return e}var _t=class{constructor(e={}){if(!Je(e))throw new TypeError("JWT Claims Set MUST be an object");this._payload=e}setIssuer(e){return this._payload=y(c({},this._payload),{iss:e}),this}setSubject(e){return this._payload=y(c({},this._payload),{sub:e}),this}setAudience(e){return this._payload=y(c({},this._payload),{aud:e}),this}setJti(e){return this._payload=y(c({},this._payload),{jti:e}),this}setNotBefore(e){return typeof e=="number"?this._payload=y(c({},this._payload),{nbf:ue("setNotBefore",e)}):e instanceof Date?this._payload=y(c({},this._payload),{nbf:ue("setNotBefore",re(e))}):this._payload=y(c({},this._payload),{nbf:re(new Date)+mt(e)}),this}setExpirationTime(e){return typeof e=="number"?this._payload=y(c({},this._payload),{exp:ue("setExpirationTime",e)}):e instanceof Date?this._payload=y(c({},this._payload),{exp:ue("setExpirationTime",re(e))}):this._payload=y(c({},this._payload),{exp:re(new Date)+mt(e)}),this}setIssuedAt(e){return typeof e=="undefined"?this._payload=y(c({},this._payload),{iat:re(new Date)}):e instanceof Date?this._payload=y(c({},this._payload),{iat:ue("setIssuedAt",re(e))}):typeof e=="string"?this._payload=y(c({},this._payload),{iat:ue("setIssuedAt",re(new Date)+mt(e))}):this._payload=y(c({},this._payload),{iat:ue("setIssuedAt",e)}),this}};var ze=class extends _t{setProtectedHeader(e){return this._protectedHeader=e,this}sign(e,r){return b(this,null,function*(){var s;let n=new gt(q.encode(JSON.stringify(this._payload)));if(n.setProtectedHeader(this._protectedHeader),Array.isArray((s=this._protectedHeader)==null?void 0:s.crit)&&this._protectedHeader.crit.includes("b64")&&this._protectedHeader.b64===!1)throw new He("JWTs MUST NOT use unencoded payload");return n.sign(e,r)})}};var C;(function(t){t.assertEqual=s=>s;function e(s){}t.assertIs=e;function r(s){throw new Error}t.assertNever=r,t.arrayToEnum=s=>{let a={};for(let i of s)a[i]=i;return a},t.getValidEnumValues=s=>{let a=t.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),i={};for(let o of a)i[o]=s[o];return t.objectValues(i)},t.objectValues=s=>t.objectKeys(s).map(function(a){return s[a]}),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{let a=[];for(let i in s)Object.prototype.hasOwnProperty.call(s,i)&&a.push(i);return a},t.find=(s,a)=>{for(let i of s)if(a(i))return i},t.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function n(s,a=" | "){return s.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}t.joinValues=n,t.jsonStringifyReplacer=(s,a)=>typeof a=="bigint"?a.toString():a})(C||(C={}));var tr;(function(t){t.mergeShapes=(e,r)=>c(c({},e),r)})(tr||(tr={}));var m=C.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ne=t=>{switch(typeof t){case"undefined":return m.undefined;case"string":return m.string;case"number":return isNaN(t)?m.nan:m.number;case"boolean":return m.boolean;case"function":return m.function;case"bigint":return m.bigint;case"symbol":return m.symbol;case"object":return Array.isArray(t)?m.array:t===null?m.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?m.promise:typeof Map!="undefined"&&t instanceof Map?m.map:typeof Set!="undefined"&&t instanceof Set?m.set:typeof Date!="undefined"&&t instanceof Date?m.date:m.object;default:return m.unknown}},d=C.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),Gn=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),U=class t extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){let r=e||function(a){return a.message},n={_errors:[]},s=a=>{for(let i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(s);else if(i.code==="invalid_return_type")s(i.returnTypeError);else if(i.code==="invalid_arguments")s(i.argumentsError);else if(i.path.length===0)n._errors.push(r(i));else{let o=n,l=0;for(;l<i.path.length;){let f=i.path[l];l===i.path.length-1?(o[f]=o[f]||{_errors:[]},o[f]._errors.push(r(i))):o[f]=o[f]||{_errors:[]},o=o[f],l++}}};return s(this),n}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,C.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){let r={},n=[];for(let s of this.issues)s.path.length>0?(r[s.path[0]]=r[s.path[0]]||[],r[s.path[0]].push(e(s))):n.push(e(s));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};U.create=t=>new U(t);var Ne=(t,e)=>{let r;switch(t.code){case d.invalid_type:t.received===m.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case d.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,C.jsonStringifyReplacer)}`;break;case d.unrecognized_keys:r=`Unrecognized key(s) in object: ${C.joinValues(t.keys,", ")}`;break;case d.invalid_union:r="Invalid input";break;case d.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${C.joinValues(t.options)}`;break;case d.invalid_enum_value:r=`Invalid enum value. Expected ${C.joinValues(t.options)}, received '${t.received}'`;break;case d.invalid_arguments:r="Invalid function arguments";break;case d.invalid_return_type:r="Invalid function return type";break;case d.invalid_date:r="Invalid date";break;case d.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:C.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case d.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case d.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case d.custom:r="Invalid input";break;case d.invalid_intersection_types:r="Intersection results could not be merged";break;case d.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case d.not_finite:r="Number must be finite";break;default:r=e.defaultError,C.assertNever(t)}return{message:r}},Kr=Ne;function Fn(t){Kr=t}function vt(){return Kr}var bt=t=>{let{data:e,path:r,errorMaps:n,issueData:s}=t,a=[...r,...s.path||[]],i=y(c({},s),{path:a});if(s.message!==void 0)return y(c({},s),{path:a,message:s.message});let o="",l=n.filter(f=>!!f).slice().reverse();for(let f of l)o=f(i,{data:e,defaultError:o}).message;return y(c({},s),{path:a,message:o})},Xn=[];function p(t,e){let r=vt(),n=bt({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===Ne?void 0:Ne].filter(s=>!!s)});t.common.issues.push(n)}var O=class t{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){let n=[];for(let s of r){if(s.status==="aborted")return x;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static mergeObjectAsync(e,r){return b(this,null,function*(){let n=[];for(let s of r){let a=yield s.key,i=yield s.value;n.push({key:a,value:i})}return t.mergeObjectSync(e,n)})}static mergeObjectSync(e,r){let n={};for(let s of r){let{key:a,value:i}=s;if(a.status==="aborted"||i.status==="aborted")return x;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value!="undefined"||s.alwaysSet)&&(n[a.value]=i.value)}return{status:e.value,value:n}}},x=Object.freeze({status:"aborted"}),je=t=>({status:"dirty",value:t}),j=t=>({status:"valid",value:t}),rr=t=>t.status==="aborted",nr=t=>t.status==="dirty",Fe=t=>t.status==="valid",Xe=t=>typeof Promise!="undefined"&&t instanceof Promise;function xt(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)}function Br(t,e,r,n,s){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r}var _;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(_||(_={}));var qe,Ge,Z=class{constructor(e,r,n,s){this._cachedPath=[],this.parent=e,this.data=r,this._path=n,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},Nr=(t,e)=>{if(Fe(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new U(t.common.issues);return this._error=r,this._error}}};function S(t){if(!t)return{};let{errorMap:e,invalid_type_error:r,required_error:n,description:s}=t;if(e&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(i,o)=>{var l,f;let{message:g}=t;return i.code==="invalid_enum_value"?{message:g!=null?g:o.defaultError}:typeof o.data=="undefined"?{message:(l=g!=null?g:n)!==null&&l!==void 0?l:o.defaultError}:i.code!=="invalid_type"?{message:o.defaultError}:{message:(f=g!=null?g:r)!==null&&f!==void 0?f:o.defaultError}},description:s}}var E=class{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return ne(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:ne(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new O,ctx:{common:e.parent.common,data:e.data,parsedType:ne(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let r=this._parse(e);if(Xe(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){let r=this._parse(e);return Promise.resolve(r)}parse(e,r){let n=this.safeParse(e,r);if(n.success)return n.data;throw n.error}safeParse(e,r){var n;let s={common:{issues:[],async:(n=r==null?void 0:r.async)!==null&&n!==void 0?n:!1,contextualErrorMap:r==null?void 0:r.errorMap},path:(r==null?void 0:r.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ne(e)},a=this._parseSync({data:e,path:s.path,parent:s});return Nr(s,a)}parseAsync(e,r){return b(this,null,function*(){let n=yield this.safeParseAsync(e,r);if(n.success)return n.data;throw n.error})}safeParseAsync(e,r){return b(this,null,function*(){let n={common:{issues:[],contextualErrorMap:r==null?void 0:r.errorMap,async:!0},path:(r==null?void 0:r.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ne(e)},s=this._parse({data:e,path:n.path,parent:n}),a=yield Xe(s)?s:Promise.resolve(s);return Nr(n,a)})}refine(e,r){let n=s=>typeof r=="string"||typeof r=="undefined"?{message:r}:typeof r=="function"?r(s):r;return this._refinement((s,a)=>{let i=e(s),o=()=>a.addIssue(c({code:d.custom},n(s)));return typeof Promise!="undefined"&&i instanceof Promise?i.then(l=>l?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,r){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof r=="function"?r(n,s):r),!1))}_refinement(e){return new K({schema:this,typeName:v.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return $.create(this,this._def)}nullable(){return J.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Q.create(this,this._def)}promise(){return ie.create(this,this._def)}or(e){return ye.create([this,e],this._def)}and(e){return ge.create(this,e,this._def)}transform(e){return new K(y(c({},S(this._def)),{schema:this,typeName:v.ZodEffects,effect:{type:"transform",transform:e}}))}default(e){let r=typeof e=="function"?e:()=>e;return new we(y(c({},S(this._def)),{innerType:this,defaultValue:r,typeName:v.ZodDefault}))}brand(){return new Ye(c({typeName:v.ZodBranded,type:this},S(this._def)))}catch(e){let r=typeof e=="function"?e:()=>e;return new Se(y(c({},S(this._def)),{innerType:this,catchValue:r,typeName:v.ZodCatch}))}describe(e){let r=this.constructor;return new r(y(c({},this._def),{description:e}))}pipe(e){return Qe.create(this,e)}readonly(){return Ee.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Yn=/^c[^\s-]{8,}$/i,Qn=/^[0-9a-z]+$/,es=/^[0-9A-HJKMNP-TV-Z]{26}$/,ts=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,rs=/^[a-z0-9_-]{21}$/i,ns=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,ss=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,as="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",er,is=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,os=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,cs=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Mr="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",us=new RegExp(`^${Mr}$`);function $r(t){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`),e}function ds(t){return new RegExp(`^${$r(t)}$`)}function Zr(t){let e=`${Mr}T${$r(t)}`,r=[];return r.push(t.local?"Z?":"Z"),t.offset&&r.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${r.join("|")})`,new RegExp(`^${e}$`)}function ls(t,e){return!!((e==="v4"||!e)&&is.test(t)||(e==="v6"||!e)&&os.test(t))}var se=class t extends E{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==m.string){let a=this._getOrReturnCtx(e);return p(a,{code:d.invalid_type,expected:m.string,received:a.parsedType}),x}let n=new O,s;for(let a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(s=this._getOrReturnCtx(e,s),p(s,{code:d.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="max")e.data.length>a.value&&(s=this._getOrReturnCtx(e,s),p(s,{code:d.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="length"){let i=e.data.length>a.value,o=e.data.length<a.value;(i||o)&&(s=this._getOrReturnCtx(e,s),i?p(s,{code:d.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):o&&p(s,{code:d.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),n.dirty())}else if(a.kind==="email")ss.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"email",code:d.invalid_string,message:a.message}),n.dirty());else if(a.kind==="emoji")er||(er=new RegExp(as,"u")),er.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"emoji",code:d.invalid_string,message:a.message}),n.dirty());else if(a.kind==="uuid")ts.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"uuid",code:d.invalid_string,message:a.message}),n.dirty());else if(a.kind==="nanoid")rs.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"nanoid",code:d.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid")Yn.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"cuid",code:d.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid2")Qn.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"cuid2",code:d.invalid_string,message:a.message}),n.dirty());else if(a.kind==="ulid")es.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"ulid",code:d.invalid_string,message:a.message}),n.dirty());else if(a.kind==="url")try{new URL(e.data)}catch(i){s=this._getOrReturnCtx(e,s),p(s,{validation:"url",code:d.invalid_string,message:a.message}),n.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"regex",code:d.invalid_string,message:a.message}),n.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(s=this._getOrReturnCtx(e,s),p(s,{code:d.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),n.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(s=this._getOrReturnCtx(e,s),p(s,{code:d.invalid_string,validation:{startsWith:a.value},message:a.message}),n.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(s=this._getOrReturnCtx(e,s),p(s,{code:d.invalid_string,validation:{endsWith:a.value},message:a.message}),n.dirty()):a.kind==="datetime"?Zr(a).test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{code:d.invalid_string,validation:"datetime",message:a.message}),n.dirty()):a.kind==="date"?us.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{code:d.invalid_string,validation:"date",message:a.message}),n.dirty()