@opensecret/react 0.3.1 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- (function(Je,We){typeof exports=="object"&&typeof module<"u"?We(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],We):(Je=typeof globalThis<"u"?globalThis:Je||self,We(Je.OpenSecretReact={},Je.React))})(this,function(Je,We){"use strict";var gm=Object.defineProperty;var W0=Je=>{throw TypeError(Je)};var vm=(Je,We,Ot)=>We in Je?gm(Je,We,{enumerable:!0,configurable:!0,writable:!0,value:Ot}):Je[We]=Ot;var Ze=(Je,We,Ot)=>vm(Je,typeof We!="symbol"?We+"":We,Ot),_f=(Je,We,Ot)=>We.has(Je)||W0("Cannot "+Ot);var M=(Je,We,Ot)=>(_f(Je,We,"read from private field"),Ot?Ot.call(Je):We.get(Je)),or=(Je,We,Ot)=>We.has(Je)?W0("Cannot add the same private member more than once"):We instanceof WeakSet?We.add(Je):We.set(Je,Ot),jt=(Je,We,Ot,Wi)=>(_f(Je,We,"write to private field"),Wi?Wi.call(Je,Ot):We.set(Je,Ot),Ot),$e=(Je,We,Ot)=>(_f(Je,We,"access private method"),Ot);var q0=(Je,We,Ot,Wi)=>({set _(Mc){jt(Je,We,Mc,Ot)},get _(){return M(Je,We,Wi)}});var Oo,Un,dn,ii,Jt,Ar,Mt,si,tt,Ki,$c,Ef,bn,xn,Cr,Xr,Xt,$r,Qt,Zi,kf,Ro,pn,fr,yn,Dc,X0,K0,Z0;var Ot=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Wi(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function Mc(r){if(r.__esModule)return r;var e=r.default;if(typeof e=="function"){var t=function n(){return this instanceof n?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(r).forEach(function(n){var i=Object.getOwnPropertyDescriptor(r,n);Object.defineProperty(t,n,i.get?i:{enumerable:!0,get:function(){return r[n]}})}),t}var Vc={exports:{}},ks={};/**
1
+ (function(Je,We){typeof exports=="object"&&typeof module<"u"?We(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],We):(Je=typeof globalThis<"u"?globalThis:Je||self,We(Je.OpenSecretReact={},Je.React))})(this,function(Je,We){"use strict";var vm=Object.defineProperty;var W0=Je=>{throw TypeError(Je)};var mm=(Je,We,Ot)=>We in Je?vm(Je,We,{enumerable:!0,configurable:!0,writable:!0,value:Ot}):Je[We]=Ot;var Ze=(Je,We,Ot)=>mm(Je,typeof We!="symbol"?We+"":We,Ot),_f=(Je,We,Ot)=>We.has(Je)||W0("Cannot "+Ot);var M=(Je,We,Ot)=>(_f(Je,We,"read from private field"),Ot?Ot.call(Je):We.get(Je)),or=(Je,We,Ot)=>We.has(Je)?W0("Cannot add the same private member more than once"):We instanceof WeakSet?We.add(Je):We.set(Je,Ot),jt=(Je,We,Ot,Wi)=>(_f(Je,We,"write to private field"),Wi?Wi.call(Je,Ot):We.set(Je,Ot),Ot),$e=(Je,We,Ot)=>(_f(Je,We,"access private method"),Ot);var q0=(Je,We,Ot,Wi)=>({set _(Mc){jt(Je,We,Mc,Ot)},get _(){return M(Je,We,Wi)}});var Oo,Un,dn,ii,Jt,Ar,Mt,si,tt,Ki,$c,Ef,bn,xn,Cr,Xr,Xt,$r,Qt,Zi,kf,Ro,pn,fr,yn,Dc,X0,K0,Z0;var Ot=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Wi(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function Mc(r){if(r.__esModule)return r;var e=r.default;if(typeof e=="function"){var t=function n(){return this instanceof n?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(r).forEach(function(n){var i=Object.getOwnPropertyDescriptor(r,n);Object.defineProperty(t,n,i.get?i:{enumerable:!0,get:function(){return r[n]}})}),t}var Vc={exports:{}},ks={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.min.js
4
4
  *
@@ -151,12 +151,12 @@ ${e.join(`
151
151
  `;return o+=u0(s,t),o}const f0=!pv();function h0(r){if(typeof r=="object"&&r){if(r.constructor!==Number)throw new Error(`Expected number: ${r}`)}else if(typeof r!="number")throw new Error(`Expected number: ${r}`)}function Jn(r){if(typeof r=="object"&&r){if(r.constructor!==String)throw new Error(`Expected string: ${r}`)}else if(typeof r!="string")throw new Error(`Expected string: ${r}`)}function Ui(r){if(!(r instanceof Uint8Array))throw new Error(`Expected Uint8Array: ${r}`)}function d0(r){if(!Array.isArray(r))throw new Error(`Expected Array: ${r}`)}Pt(Map,(r,e,t)=>{const n=[...r.entries()].map(i=>[i[0],i[1],mc(i[0],t)]);if(t.rejectDuplicateKeys){const i=new Set;for(const[s,o,c]of n){const u=Zr(c);if(i.has(u))throw new Error(`Duplicate map key: 0x${u}`);i.add(u)}}t.sortKeys&&n.sort(t.sortKeys),lf(r,r.size,Ae.MAP,e,t);for(const[i,s,o]of n)e.write(o),Pi(s,e,t)});function p0(r){return Jn(r.contents),new Date(r.contents)}p0.comment=r=>(Jn(r.contents),`(String Date) ${new Date(r.contents).toISOString()}`),qe.registerDecoder(kt.DATE_STRING,p0);function y0(r){return h0(r.contents),new Date(r.contents*1e3)}y0.comment=r=>(h0(r.contents),`(Epoch Date) ${new Date(r.contents*1e3).toISOString()}`),qe.registerDecoder(kt.DATE_EPOCH,y0),Pt(Date,r=>[kt.DATE_EPOCH,r.valueOf()/1e3]);function bc(r,e,t){if(Ui(e.contents),t.rejectBigInts)throw new Error(`Decoding unwanted big integer: ${e}(h'${Zr(e.contents)}')`);if(t.requirePreferred&&e.contents[0]===0)throw new Error(`Decoding overly-large bigint: ${e.tag}(h'${Zr(e.contents)})`);let n=e.contents.reduce((i,s)=>i<<8n|BigInt(s),0n);if(r&&(n=-1n-n),t.requirePreferred&&n>=Number.MIN_SAFE_INTEGER&&n<=Number.MAX_SAFE_INTEGER)throw new Error(`Decoding bigint that could have been int: ${n}n`);return t.boxed?co(n,e.contents):n}const g0=bc.bind(null,!1),v0=bc.bind(null,!0);g0.comment=(r,e)=>`(Positive BigInt) ${bc(!1,r,e)}n`,v0.comment=(r,e)=>`(Negative BigInt) ${bc(!0,r,e)}n`,qe.registerDecoder(kt.POS_BIGINT,g0),qe.registerDecoder(kt.NEG_BIGINT,v0);function hf(r,e){return Ui(r.contents),r}hf.comment=(r,e,t)=>{Ui(r.contents);const n={...e,initialDepth:t+2,noPrefixHex:!0},i=yc(r);let s=2**((i[0]&31)-24)+1;const o=i[s]&31;let c=Zr(i.subarray(s,++s));o>=24&&(c+=" ",c+=Zr(i.subarray(s,s+2**(o-24)))),n.minCol=Math.max(n.minCol,(t+1)*2+c.length);const u=Uv(r.contents,n);let d=`Embedded CBOR
152
152
  `;return d+=`${"".padStart((t+1)*2," ")}${c}`.padEnd(n.minCol+1," "),d+=`-- Bytes (Length: ${r.contents.length})
153
153
  `,d+=u,d},hf.noChildren=!0,qe.registerDecoder(kt.CBOR,hf),qe.registerDecoder(kt.URI,r=>(Jn(r.contents),new URL(r.contents)),"URI"),Pt(URL,r=>[kt.URI,r.toString()]),qe.registerDecoder(kt.BASE64URL,r=>(Jn(r.contents),dv(r.contents)),"Base64url-encoded"),qe.registerDecoder(kt.BASE64,r=>(Jn(r.contents),of(r.contents)),"Base64-encoded"),qe.registerDecoder(35,r=>(Jn(r.contents),new RegExp(r.contents)),"RegExp"),qe.registerDecoder(21065,r=>{Jn(r.contents);let e=r.contents.replace(new RegExp("(?<!\\\\)(?<!\\[(?:[^\\]]|\\\\\\])*)\\.","g"),`[^
154
- \r]`);return e=`^(?:${e})$`,new RegExp(e,"u")},"I-RegExp"),qe.registerDecoder(kt.REGEXP,r=>{if(d0(r.contents),r.contents.length<1||r.contents.length>2)throw new Error(`Invalid RegExp Array: ${r.contents}`);return new RegExp(r.contents[0],r.contents[1])},"RegExp"),Pt(RegExp,r=>[kt.REGEXP,[r.source,r.flags]]),qe.registerDecoder(64,r=>(Ui(r.contents),r.contents),"uint8 Typed Array");function tr(r,e,t){Ui(r.contents);let n=r.contents.length;if(n%e.BYTES_PER_ELEMENT!==0)throw new Error(`Number of bytes must be divisible by ${e.BYTES_PER_ELEMENT}, got: ${n}`);n/=e.BYTES_PER_ELEMENT;const i=new e(n),s=new DataView(r.contents.buffer,r.contents.byteOffset,r.contents.byteLength),o=s[`get${e.name.replace(/Array/,"")}`].bind(s);for(let c=0;c<n;c++)i[c]=o(c*e.BYTES_PER_ELEMENT,t);return i}function Xn(r,e,t,n,i){const s=i.forceEndian??f0;if(vc(s?e:t,r,i),Wr(n.byteLength,r,Ae.BYTE_STRING),f0===s)r.write(new Uint8Array(n.buffer,n.byteOffset,n.byteLength));else{const o=`write${n.constructor.name.replace(/Array/,"")}`,c=r[o].bind(r);for(const u of n)c(u,s)}}qe.registerDecoder(65,r=>tr(r,Uint16Array,!1),"uint16, big endian, Typed Array"),qe.registerDecoder(66,r=>tr(r,Uint32Array,!1),"uint32, big endian, Typed Array"),qe.registerDecoder(67,r=>tr(r,BigUint64Array,!1),"uint64, big endian, Typed Array"),qe.registerDecoder(68,r=>(Ui(r.contents),new Uint8ClampedArray(r.contents)),"uint8 Typed Array, clamped arithmetic"),Pt(Uint8ClampedArray,r=>[68,new Uint8Array(r.buffer,r.byteOffset,r.byteLength)]),qe.registerDecoder(69,r=>tr(r,Uint16Array,!0),"uint16, little endian, Typed Array"),Pt(Uint16Array,(r,e,t)=>Xn(e,69,65,r,t)),qe.registerDecoder(70,r=>tr(r,Uint32Array,!0),"uint32, little endian, Typed Array"),Pt(Uint32Array,(r,e,t)=>Xn(e,70,66,r,t)),qe.registerDecoder(71,r=>tr(r,BigUint64Array,!0),"uint64, little endian, Typed Array"),Pt(BigUint64Array,(r,e,t)=>Xn(e,71,67,r,t)),qe.registerDecoder(72,r=>(Ui(r.contents),new Int8Array(r.contents)),"sint8 Typed Array"),Pt(Int8Array,r=>[72,new Uint8Array(r.buffer,r.byteOffset,r.byteLength)]),qe.registerDecoder(73,r=>tr(r,Int16Array,!1),"sint16, big endian, Typed Array"),qe.registerDecoder(74,r=>tr(r,Int32Array,!1),"sint32, big endian, Typed Array"),qe.registerDecoder(75,r=>tr(r,BigInt64Array,!1),"sint64, big endian, Typed Array"),qe.registerDecoder(77,r=>tr(r,Int16Array,!0),"sint16, little endian, Typed Array"),Pt(Int16Array,(r,e,t)=>Xn(e,77,73,r,t)),qe.registerDecoder(78,r=>tr(r,Int32Array,!0),"sint32, little endian, Typed Array"),Pt(Int32Array,(r,e,t)=>Xn(e,78,74,r,t)),qe.registerDecoder(79,r=>tr(r,BigInt64Array,!0),"sint64, little endian, Typed Array"),Pt(BigInt64Array,(r,e,t)=>Xn(e,79,75,r,t)),qe.registerDecoder(81,r=>tr(r,Float32Array,!1),"IEEE 754 binary32, big endian, Typed Array"),qe.registerDecoder(82,r=>tr(r,Float64Array,!1),"IEEE 754 binary64, big endian, Typed Array"),qe.registerDecoder(85,r=>tr(r,Float32Array,!0),"IEEE 754 binary32, little endian, Typed Array"),Pt(Float32Array,(r,e,t)=>Xn(e,85,81,r,t)),qe.registerDecoder(86,r=>tr(r,Float64Array,!0),"IEEE 754 binary64, big endian, Typed Array"),Pt(Float64Array,(r,e,t)=>Xn(e,86,82,r,t)),qe.registerDecoder(kt.SET,r=>(d0(r.contents),new Set(r.contents)),"Set"),Pt(Set,r=>[kt.SET,[...r]]),qe.registerDecoder(kt.JSON,r=>(Jn(r.contents),JSON.parse(r.contents)),"JSON-encoded"),qe.registerDecoder(kt.SELF_DESCRIBED,r=>r.contents,"Self-Described"),qe.registerDecoder(kt.INVALID_16,()=>{throw new Error(`Tag always invalid: ${kt.INVALID_16}`)},"Invalid"),qe.registerDecoder(kt.INVALID_32,()=>{throw new Error(`Tag always invalid: ${kt.INVALID_32}`)},"Invalid"),qe.registerDecoder(kt.INVALID_64,()=>{throw new Error(`Tag always invalid: ${kt.INVALID_64}`)},"Invalid");function df(r){throw new Error(`Encoding ${r.constructor.name} intentionally unimplmented. It is not concrete enough to interoperate. Convert to Uint8Array first.`)}Pt(ArrayBuffer,df),Pt(DataView,df),typeof SharedArrayBuffer<"u"&&Pt(SharedArrayBuffer,df);function xc(r){return[NaN,r.valueOf()]}Pt(Boolean,xc),Pt(Number,xc),Pt(String,xc),Pt(BigInt,xc);function Ac(r,e={}){const t={...Yn.defaultDecodeOptions};if(e.dcbor?Object.assign(t,Yn.dcborDecodeOptions):e.cde&&Object.assign(t,Yn.cdeDecodeOptions),Object.assign(t,e),Object.hasOwn(t,"rejectLongNumbers"))throw new TypeError("rejectLongNumbers has changed to requirePreferred");t.boxed&&(t.saveOriginal=!0);const n=new uo(r,t);let i,s;for(const o of n){if(s=Yn.create(o,i,t,n),o[2]===Er.BREAK)if(i!=null&&i.isStreaming)i.left=0;else throw new Error("Unexpected BREAK");else i&&i.push(s,n,o[3]);for(s instanceof Yn&&(i=s);i!=null&&i.done;){s=i.convert(n);const c=i.parent;c==null||c.replaceLast(s,i,n),i=c}}return s}new TextEncoder;var it;(function(r){r.assertEqual=i=>i;function e(i){}r.assertIs=e;function t(i){throw new Error}r.assertNever=t,r.arrayToEnum=i=>{const s={};for(const o of i)s[o]=o;return s},r.getValidEnumValues=i=>{const s=r.objectKeys(i).filter(c=>typeof i[i[c]]!="number"),o={};for(const c of s)o[c]=i[c];return r.objectValues(o)},r.objectValues=i=>r.objectKeys(i).map(function(s){return i[s]}),r.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const s=[];for(const o in i)Object.prototype.hasOwnProperty.call(i,o)&&s.push(o);return s},r.find=(i,s)=>{for(const o of i)if(s(o))return o},r.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&isFinite(i)&&Math.floor(i)===i;function n(i,s=" | "){return i.map(o=>typeof o=="string"?`'${o}'`:o).join(s)}r.joinValues=n,r.jsonStringifyReplacer=(i,s)=>typeof s=="bigint"?s.toString():s})(it||(it={}));var pf;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(pf||(pf={}));const ce=it.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Qn=r=>{switch(typeof r){case"undefined":return ce.undefined;case"string":return ce.string;case"number":return isNaN(r)?ce.nan:ce.number;case"boolean":return ce.boolean;case"function":return ce.function;case"bigint":return ce.bigint;case"symbol":return ce.symbol;case"object":return Array.isArray(r)?ce.array:r===null?ce.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?ce.promise:typeof Map<"u"&&r instanceof Map?ce.map:typeof Set<"u"&&r instanceof Set?ce.set:typeof Date<"u"&&r instanceof Date?ce.date:ce.object;default:return ce.unknown}},Z=it.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"]),Dv=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");class kr extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(s){return s.message},n={_errors:[]},i=s=>{for(const o of s.issues)if(o.code==="invalid_union")o.unionErrors.map(i);else if(o.code==="invalid_return_type")i(o.returnTypeError);else if(o.code==="invalid_arguments")i(o.argumentsError);else if(o.path.length===0)n._errors.push(t(o));else{let c=n,u=0;for(;u<o.path.length;){const d=o.path[u];u===o.path.length-1?(c[d]=c[d]||{_errors:[]},c[d]._errors.push(t(o))):c[d]=c[d]||{_errors:[]},c=c[d],u++}}};return i(this),n}static assert(e){if(!(e instanceof kr))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,it.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const i of this.issues)i.path.length>0?(t[i.path[0]]=t[i.path[0]]||[],t[i.path[0]].push(e(i))):n.push(e(i));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}kr.create=r=>new kr(r);const bs=(r,e)=>{let t;switch(r.code){case Z.invalid_type:r.received===ce.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case Z.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,it.jsonStringifyReplacer)}`;break;case Z.unrecognized_keys:t=`Unrecognized key(s) in object: ${it.joinValues(r.keys,", ")}`;break;case Z.invalid_union:t="Invalid input";break;case Z.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${it.joinValues(r.options)}`;break;case Z.invalid_enum_value:t=`Invalid enum value. Expected ${it.joinValues(r.options)}, received '${r.received}'`;break;case Z.invalid_arguments:t="Invalid function arguments";break;case Z.invalid_return_type:t="Invalid function return type";break;case Z.invalid_date:t="Invalid date";break;case Z.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:it.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case Z.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case Z.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case Z.custom:t="Invalid input";break;case Z.invalid_intersection_types:t="Intersection results could not be merged";break;case Z.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case Z.not_finite:t="Number must be finite";break;default:t=e.defaultError,it.assertNever(r)}return{message:t}};let m0=bs;function $v(r){m0=r}function Sc(){return m0}const _c=r=>{const{data:e,path:t,errorMaps:n,issueData:i}=r,s=[...t,...i.path||[]],o={...i,path:s};if(i.message!==void 0)return{...i,path:s,message:i.message};let c="";const u=n.filter(d=>!!d).slice().reverse();for(const d of u)c=d(o,{data:e,defaultError:c}).message;return{...i,path:s,message:c}},Mv=[];function ie(r,e){const t=Sc(),n=_c({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===bs?void 0:bs].filter(i=>!!i)});r.common.issues.push(n)}class rr{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const i of t){if(i.status==="aborted")return Pe;i.status==="dirty"&&e.dirty(),n.push(i.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const i of t){const s=await i.key,o=await i.value;n.push({key:s,value:o})}return rr.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const i of t){const{key:s,value:o}=i;if(s.status==="aborted"||o.status==="aborted")return Pe;s.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof o.value<"u"||i.alwaysSet)&&(n[s.value]=o.value)}return{status:e.value,value:n}}}const Pe=Object.freeze({status:"aborted"}),xs=r=>({status:"dirty",value:r}),ur=r=>({status:"valid",value:r}),yf=r=>r.status==="aborted",gf=r=>r.status==="dirty",fo=r=>r.status==="valid",ho=r=>typeof Promise<"u"&&r instanceof Promise;function Ec(r,e,t,n){if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(r)}function w0(r,e,t,n,i){if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(r,t),t}typeof SuppressedError=="function"&&SuppressedError;var Ie;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(Ie||(Ie={}));var po,yo;class un{constructor(e,t,n,i){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=i}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}}const b0=(r,e)=>{if(fo(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new kr(r.common.issues);return this._error=t,this._error}}};function Me(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:i}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:i}:{errorMap:(o,c)=>{var u,d;const{message:b}=r;return o.code==="invalid_enum_value"?{message:b??c.defaultError}:typeof c.data>"u"?{message:(u=b??n)!==null&&u!==void 0?u:c.defaultError}:o.code!=="invalid_type"?{message:c.defaultError}:{message:(d=b??t)!==null&&d!==void 0?d:c.defaultError}},description:i}}class Ge{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 Qn(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Qn(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new rr,ctx:{common:e.parent.common,data:e.data,parsedType:Qn(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(ho(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){var n;const i={common:{issues:[],async:(n=t==null?void 0:t.async)!==null&&n!==void 0?n:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Qn(e)},s=this._parseSync({data:e,path:i.path,parent:i});return b0(i,s)}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Qn(e)},i=this._parse({data:e,path:n.path,parent:n}),s=await(ho(i)?i:Promise.resolve(i));return b0(n,s)}refine(e,t){const n=i=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(i):t;return this._refinement((i,s)=>{const o=e(i),c=()=>s.addIssue({code:Z.custom,...n(i)});return typeof Promise<"u"&&o instanceof Promise?o.then(u=>u?!0:(c(),!1)):o?!0:(c(),!1)})}refinement(e,t){return this._refinement((n,i)=>e(n)?!0:(i.addIssue(typeof t=="function"?t(n,i):t),!1))}_refinement(e){return new Jr({schema:this,typeName:je.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return hn.create(this,this._def)}nullable(){return ni.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Yr.create(this,this._def)}promise(){return Es.create(this,this._def)}or(e){return wo.create([this,e],this._def)}and(e){return bo.create(this,e,this._def)}transform(e){return new Jr({...Me(this._def),schema:this,typeName:je.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new Eo({...Me(this._def),innerType:this,defaultValue:t,typeName:je.ZodDefault})}brand(){return new wf({typeName:je.ZodBranded,type:this,...Me(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new ko({...Me(this._def),innerType:this,catchValue:t,typeName:je.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Io.create(this,e)}readonly(){return Co.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Vv=/^c[^\s-]{8,}$/i,Lv=/^[0-9a-z]+$/,Hv=/^[0-9A-HJKMNP-TV-Z]{26}$/,Fv=/^[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,Gv=/^[a-z0-9_-]{21}$/i,zv=/^[-+]?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)?)??$/,Kv=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Zv="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let vf;const Wv=/^(?:(?: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])$/,qv=/^(([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})))$/,Yv=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,x0="((\\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])))",Jv=new RegExp(`^${x0}$`);function A0(r){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`),e}function Xv(r){return new RegExp(`^${A0(r)}$`)}function S0(r){let e=`${x0}T${A0(r)}`;const t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Qv(r,e){return!!((e==="v4"||!e)&&Wv.test(r)||(e==="v6"||!e)&&qv.test(r))}class qr extends Ge{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==ce.string){const s=this._getOrReturnCtx(e);return ie(s,{code:Z.invalid_type,expected:ce.string,received:s.parsedType}),Pe}const n=new rr;let i;for(const s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(i=this._getOrReturnCtx(e,i),ie(i,{code:Z.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="max")e.data.length>s.value&&(i=this._getOrReturnCtx(e,i),ie(i,{code:Z.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="length"){const o=e.data.length>s.value,c=e.data.length<s.value;(o||c)&&(i=this._getOrReturnCtx(e,i),o?ie(i,{code:Z.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):c&&ie(i,{code:Z.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),n.dirty())}else if(s.kind==="email")Kv.test(e.data)||(i=this._getOrReturnCtx(e,i),ie(i,{validation:"email",code:Z.invalid_string,message:s.message}),n.dirty());else if(s.kind==="emoji")vf||(vf=new RegExp(Zv,"u")),vf.test(e.data)||(i=this._getOrReturnCtx(e,i),ie(i,{validation:"emoji",code:Z.invalid_string,message:s.message}),n.dirty());else if(s.kind==="uuid")Fv.test(e.data)||(i=this._getOrReturnCtx(e,i),ie(i,{validation:"uuid",code:Z.invalid_string,message:s.message}),n.dirty());else if(s.kind==="nanoid")Gv.test(e.data)||(i=this._getOrReturnCtx(e,i),ie(i,{validation:"nanoid",code:Z.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid")Vv.test(e.data)||(i=this._getOrReturnCtx(e,i),ie(i,{validation:"cuid",code:Z.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid2")Lv.test(e.data)||(i=this._getOrReturnCtx(e,i),ie(i,{validation:"cuid2",code:Z.invalid_string,message:s.message}),n.dirty());else if(s.kind==="ulid")Hv.test(e.data)||(i=this._getOrReturnCtx(e,i),ie(i,{validation:"ulid",code:Z.invalid_string,message:s.message}),n.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),ie(i,{validation:"url",code:Z.invalid_string,message:s.message}),n.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(i=this._getOrReturnCtx(e,i),ie(i,{validation:"regex",code:Z.invalid_string,message:s.message}),n.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(i=this._getOrReturnCtx(e,i),ie(i,{code:Z.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),n.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(i=this._getOrReturnCtx(e,i),ie(i,{code:Z.invalid_string,validation:{startsWith:s.value},message:s.message}),n.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(i=this._getOrReturnCtx(e,i),ie(i,{code:Z.invalid_string,validation:{endsWith:s.value},message:s.message}),n.dirty()):s.kind==="datetime"?S0(s).test(e.data)||(i=this._getOrReturnCtx(e,i),ie(i,{code:Z.invalid_string,validation:"datetime",message:s.message}),n.dirty()):s.kind==="date"?Jv.test(e.data)||(i=this._getOrReturnCtx(e,i),ie(i,{code:Z.invalid_string,validation:"date",message:s.message}),n.dirty()):s.kind==="time"?Xv(s).test(e.data)||(i=this._getOrReturnCtx(e,i),ie(i,{code:Z.invalid_string,validation:"time",message:s.message}),n.dirty()):s.kind==="duration"?zv.test(e.data)||(i=this._getOrReturnCtx(e,i),ie(i,{validation:"duration",code:Z.invalid_string,message:s.message}),n.dirty()):s.kind==="ip"?Qv(e.data,s.version)||(i=this._getOrReturnCtx(e,i),ie(i,{validation:"ip",code:Z.invalid_string,message:s.message}),n.dirty()):s.kind==="base64"?Yv.test(e.data)||(i=this._getOrReturnCtx(e,i),ie(i,{validation:"base64",code:Z.invalid_string,message:s.message}),n.dirty()):it.assertNever(s);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(i=>e.test(i),{validation:t,code:Z.invalid_string,...Ie.errToObj(n)})}_addCheck(e){return new qr({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Ie.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Ie.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Ie.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Ie.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...Ie.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Ie.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Ie.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Ie.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...Ie.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Ie.errToObj(e)})}datetime(e){var t,n;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,local:(n=e==null?void 0:e.local)!==null&&n!==void 0?n:!1,...Ie.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...Ie.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...Ie.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...Ie.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...Ie.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...Ie.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...Ie.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...Ie.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...Ie.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...Ie.errToObj(t)})}nonempty(e){return this.min(1,Ie.errToObj(e))}trim(){return new qr({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new qr({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new qr({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}qr.create=r=>{var e;return new qr({checks:[],typeName:je.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...Me(r)})};function e1(r,e){const t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,i=t>n?t:n,s=parseInt(r.toFixed(i).replace(".","")),o=parseInt(e.toFixed(i).replace(".",""));return s%o/Math.pow(10,i)}class ei extends Ge{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==ce.number){const s=this._getOrReturnCtx(e);return ie(s,{code:Z.invalid_type,expected:ce.number,received:s.parsedType}),Pe}let n;const i=new rr;for(const s of this._def.checks)s.kind==="int"?it.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),ie(n,{code:Z.invalid_type,expected:"integer",received:"float",message:s.message}),i.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),ie(n,{code:Z.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),ie(n,{code:Z.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="multipleOf"?e1(e.data,s.value)!==0&&(n=this._getOrReturnCtx(e,n),ie(n,{code:Z.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),ie(n,{code:Z.not_finite,message:s.message}),i.dirty()):it.assertNever(s);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Ie.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Ie.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Ie.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Ie.toString(t))}setLimit(e,t,n,i){return new ei({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:Ie.toString(i)}]})}_addCheck(e){return new ei({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Ie.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Ie.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Ie.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Ie.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Ie.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Ie.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:Ie.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Ie.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Ie.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&it.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}}ei.create=r=>new ei({checks:[],typeName:je.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...Me(r)});class ti extends Ge{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==ce.bigint){const s=this._getOrReturnCtx(e);return ie(s,{code:Z.invalid_type,expected:ce.bigint,received:s.parsedType}),Pe}let n;const i=new rr;for(const s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),ie(n,{code:Z.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),ie(n,{code:Z.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),ie(n,{code:Z.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):it.assertNever(s);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Ie.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Ie.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Ie.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Ie.toString(t))}setLimit(e,t,n,i){return new ti({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:Ie.toString(i)}]})}_addCheck(e){return new ti({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Ie.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Ie.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Ie.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Ie.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Ie.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}ti.create=r=>{var e;return new ti({checks:[],typeName:je.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...Me(r)})};class go extends Ge{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==ce.boolean){const n=this._getOrReturnCtx(e);return ie(n,{code:Z.invalid_type,expected:ce.boolean,received:n.parsedType}),Pe}return ur(e.data)}}go.create=r=>new go({typeName:je.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...Me(r)});class Di extends Ge{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==ce.date){const s=this._getOrReturnCtx(e);return ie(s,{code:Z.invalid_type,expected:ce.date,received:s.parsedType}),Pe}if(isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return ie(s,{code:Z.invalid_date}),Pe}const n=new rr;let i;for(const s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(i=this._getOrReturnCtx(e,i),ie(i,{code:Z.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),n.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(i=this._getOrReturnCtx(e,i),ie(i,{code:Z.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),n.dirty()):it.assertNever(s);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Di({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:Ie.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:Ie.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}Di.create=r=>new Di({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:je.ZodDate,...Me(r)});class kc extends Ge{_parse(e){if(this._getType(e)!==ce.symbol){const n=this._getOrReturnCtx(e);return ie(n,{code:Z.invalid_type,expected:ce.symbol,received:n.parsedType}),Pe}return ur(e.data)}}kc.create=r=>new kc({typeName:je.ZodSymbol,...Me(r)});class vo extends Ge{_parse(e){if(this._getType(e)!==ce.undefined){const n=this._getOrReturnCtx(e);return ie(n,{code:Z.invalid_type,expected:ce.undefined,received:n.parsedType}),Pe}return ur(e.data)}}vo.create=r=>new vo({typeName:je.ZodUndefined,...Me(r)});class mo extends Ge{_parse(e){if(this._getType(e)!==ce.null){const n=this._getOrReturnCtx(e);return ie(n,{code:Z.invalid_type,expected:ce.null,received:n.parsedType}),Pe}return ur(e.data)}}mo.create=r=>new mo({typeName:je.ZodNull,...Me(r)});class As extends Ge{constructor(){super(...arguments),this._any=!0}_parse(e){return ur(e.data)}}As.create=r=>new As({typeName:je.ZodAny,...Me(r)});class $i extends Ge{constructor(){super(...arguments),this._unknown=!0}_parse(e){return ur(e.data)}}$i.create=r=>new $i({typeName:je.ZodUnknown,...Me(r)});class jn extends Ge{_parse(e){const t=this._getOrReturnCtx(e);return ie(t,{code:Z.invalid_type,expected:ce.never,received:t.parsedType}),Pe}}jn.create=r=>new jn({typeName:je.ZodNever,...Me(r)});class Ic extends Ge{_parse(e){if(this._getType(e)!==ce.undefined){const n=this._getOrReturnCtx(e);return ie(n,{code:Z.invalid_type,expected:ce.void,received:n.parsedType}),Pe}return ur(e.data)}}Ic.create=r=>new Ic({typeName:je.ZodVoid,...Me(r)});class Yr extends Ge{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),i=this._def;if(t.parsedType!==ce.array)return ie(t,{code:Z.invalid_type,expected:ce.array,received:t.parsedType}),Pe;if(i.exactLength!==null){const o=t.data.length>i.exactLength.value,c=t.data.length<i.exactLength.value;(o||c)&&(ie(t,{code:o?Z.too_big:Z.too_small,minimum:c?i.exactLength.value:void 0,maximum:o?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(i.minLength!==null&&t.data.length<i.minLength.value&&(ie(t,{code:Z.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),i.maxLength!==null&&t.data.length>i.maxLength.value&&(ie(t,{code:Z.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((o,c)=>i.type._parseAsync(new un(t,o,t.path,c)))).then(o=>rr.mergeArray(n,o));const s=[...t.data].map((o,c)=>i.type._parseSync(new un(t,o,t.path,c)));return rr.mergeArray(n,s)}get element(){return this._def.type}min(e,t){return new Yr({...this._def,minLength:{value:e,message:Ie.toString(t)}})}max(e,t){return new Yr({...this._def,maxLength:{value:e,message:Ie.toString(t)}})}length(e,t){return new Yr({...this._def,exactLength:{value:e,message:Ie.toString(t)}})}nonempty(e){return this.min(1,e)}}Yr.create=(r,e)=>new Yr({type:r,minLength:null,maxLength:null,exactLength:null,typeName:je.ZodArray,...Me(e)});function Ss(r){if(r instanceof Nt){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=hn.create(Ss(n))}return new Nt({...r._def,shape:()=>e})}else return r instanceof Yr?new Yr({...r._def,type:Ss(r.element)}):r instanceof hn?hn.create(Ss(r.unwrap())):r instanceof ni?ni.create(Ss(r.unwrap())):r instanceof fn?fn.create(r.items.map(e=>Ss(e))):r}class Nt extends Ge{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=it.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==ce.object){const d=this._getOrReturnCtx(e);return ie(d,{code:Z.invalid_type,expected:ce.object,received:d.parsedType}),Pe}const{status:n,ctx:i}=this._processInputParams(e),{shape:s,keys:o}=this._getCached(),c=[];if(!(this._def.catchall instanceof jn&&this._def.unknownKeys==="strip"))for(const d in i.data)o.includes(d)||c.push(d);const u=[];for(const d of o){const b=s[d],E=i.data[d];u.push({key:{status:"valid",value:d},value:b._parse(new un(i,E,i.path,d)),alwaysSet:d in i.data})}if(this._def.catchall instanceof jn){const d=this._def.unknownKeys;if(d==="passthrough")for(const b of c)u.push({key:{status:"valid",value:b},value:{status:"valid",value:i.data[b]}});else if(d==="strict")c.length>0&&(ie(i,{code:Z.unrecognized_keys,keys:c}),n.dirty());else if(d!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const d=this._def.catchall;for(const b of c){const E=i.data[b];u.push({key:{status:"valid",value:b},value:d._parse(new un(i,E,i.path,b)),alwaysSet:b in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const d=[];for(const b of u){const E=await b.key,Y=await b.value;d.push({key:E,value:Y,alwaysSet:b.alwaysSet})}return d}).then(d=>rr.mergeObjectSync(n,d)):rr.mergeObjectSync(n,u)}get shape(){return this._def.shape()}strict(e){return Ie.errToObj,new Nt({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var i,s,o,c;const u=(o=(s=(i=this._def).errorMap)===null||s===void 0?void 0:s.call(i,t,n).message)!==null&&o!==void 0?o:n.defaultError;return t.code==="unrecognized_keys"?{message:(c=Ie.errToObj(e).message)!==null&&c!==void 0?c:u}:{message:u}}}:{}})}strip(){return new Nt({...this._def,unknownKeys:"strip"})}passthrough(){return new Nt({...this._def,unknownKeys:"passthrough"})}extend(e){return new Nt({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Nt({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:je.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Nt({...this._def,catchall:e})}pick(e){const t={};return it.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new Nt({...this._def,shape:()=>t})}omit(e){const t={};return it.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new Nt({...this._def,shape:()=>t})}deepPartial(){return Ss(this)}partial(e){const t={};return it.objectKeys(this.shape).forEach(n=>{const i=this.shape[n];e&&!e[n]?t[n]=i:t[n]=i.optional()}),new Nt({...this._def,shape:()=>t})}required(e){const t={};return it.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let s=this.shape[n];for(;s instanceof hn;)s=s._def.innerType;t[n]=s}}),new Nt({...this._def,shape:()=>t})}keyof(){return _0(it.objectKeys(this.shape))}}Nt.create=(r,e)=>new Nt({shape:()=>r,unknownKeys:"strip",catchall:jn.create(),typeName:je.ZodObject,...Me(e)}),Nt.strictCreate=(r,e)=>new Nt({shape:()=>r,unknownKeys:"strict",catchall:jn.create(),typeName:je.ZodObject,...Me(e)}),Nt.lazycreate=(r,e)=>new Nt({shape:r,unknownKeys:"strip",catchall:jn.create(),typeName:je.ZodObject,...Me(e)});class wo extends Ge{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function i(s){for(const c of s)if(c.result.status==="valid")return c.result;for(const c of s)if(c.result.status==="dirty")return t.common.issues.push(...c.ctx.common.issues),c.result;const o=s.map(c=>new kr(c.ctx.common.issues));return ie(t,{code:Z.invalid_union,unionErrors:o}),Pe}if(t.common.async)return Promise.all(n.map(async s=>{const o={...t,common:{...t.common,issues:[]},parent:null};return{result:await s._parseAsync({data:t.data,path:t.path,parent:o}),ctx:o}})).then(i);{let s;const o=[];for(const u of n){const d={...t,common:{...t.common,issues:[]},parent:null},b=u._parseSync({data:t.data,path:t.path,parent:d});if(b.status==="valid")return b;b.status==="dirty"&&!s&&(s={result:b,ctx:d}),d.common.issues.length&&o.push(d.common.issues)}if(s)return t.common.issues.push(...s.ctx.common.issues),s.result;const c=o.map(u=>new kr(u));return ie(t,{code:Z.invalid_union,unionErrors:c}),Pe}}get options(){return this._def.options}}wo.create=(r,e)=>new wo({options:r,typeName:je.ZodUnion,...Me(e)});const Pn=r=>r instanceof Ao?Pn(r.schema):r instanceof Jr?Pn(r.innerType()):r instanceof So?[r.value]:r instanceof ri?r.options:r instanceof _o?it.objectValues(r.enum):r instanceof Eo?Pn(r._def.innerType):r instanceof vo?[void 0]:r instanceof mo?[null]:r instanceof hn?[void 0,...Pn(r.unwrap())]:r instanceof ni?[null,...Pn(r.unwrap())]:r instanceof wf||r instanceof Co?Pn(r.unwrap()):r instanceof ko?Pn(r._def.innerType):[];class Cc extends Ge{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==ce.object)return ie(t,{code:Z.invalid_type,expected:ce.object,received:t.parsedType}),Pe;const n=this.discriminator,i=t.data[n],s=this.optionsMap.get(i);return s?t.common.async?s._parseAsync({data:t.data,path:t.path,parent:t}):s._parseSync({data:t.data,path:t.path,parent:t}):(ie(t,{code:Z.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),Pe)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const i=new Map;for(const s of t){const o=Pn(s.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const c of o){if(i.has(c))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(c)}`);i.set(c,s)}}return new Cc({typeName:je.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:i,...Me(n)})}}function mf(r,e){const t=Qn(r),n=Qn(e);if(r===e)return{valid:!0,data:r};if(t===ce.object&&n===ce.object){const i=it.objectKeys(e),s=it.objectKeys(r).filter(c=>i.indexOf(c)!==-1),o={...r,...e};for(const c of s){const u=mf(r[c],e[c]);if(!u.valid)return{valid:!1};o[c]=u.data}return{valid:!0,data:o}}else if(t===ce.array&&n===ce.array){if(r.length!==e.length)return{valid:!1};const i=[];for(let s=0;s<r.length;s++){const o=r[s],c=e[s],u=mf(o,c);if(!u.valid)return{valid:!1};i.push(u.data)}return{valid:!0,data:i}}else return t===ce.date&&n===ce.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class bo extends Ge{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),i=(s,o)=>{if(yf(s)||yf(o))return Pe;const c=mf(s.value,o.value);return c.valid?((gf(s)||gf(o))&&t.dirty(),{status:t.value,value:c.data}):(ie(n,{code:Z.invalid_intersection_types}),Pe)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([s,o])=>i(s,o)):i(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}bo.create=(r,e,t)=>new bo({left:r,right:e,typeName:je.ZodIntersection,...Me(t)});class fn extends Ge{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==ce.array)return ie(n,{code:Z.invalid_type,expected:ce.array,received:n.parsedType}),Pe;if(n.data.length<this._def.items.length)return ie(n,{code:Z.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Pe;!this._def.rest&&n.data.length>this._def.items.length&&(ie(n,{code:Z.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const s=[...n.data].map((o,c)=>{const u=this._def.items[c]||this._def.rest;return u?u._parse(new un(n,o,n.path,c)):null}).filter(o=>!!o);return n.common.async?Promise.all(s).then(o=>rr.mergeArray(t,o)):rr.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new fn({...this._def,rest:e})}}fn.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new fn({items:r,typeName:je.ZodTuple,rest:null,...Me(e)})};class xo extends Ge{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==ce.object)return ie(n,{code:Z.invalid_type,expected:ce.object,received:n.parsedType}),Pe;const i=[],s=this._def.keyType,o=this._def.valueType;for(const c in n.data)i.push({key:s._parse(new un(n,c,n.path,c)),value:o._parse(new un(n,n.data[c],n.path,c)),alwaysSet:c in n.data});return n.common.async?rr.mergeObjectAsync(t,i):rr.mergeObjectSync(t,i)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof Ge?new xo({keyType:e,valueType:t,typeName:je.ZodRecord,...Me(n)}):new xo({keyType:qr.create(),valueType:e,typeName:je.ZodRecord,...Me(t)})}}class Bc extends Ge{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==ce.map)return ie(n,{code:Z.invalid_type,expected:ce.map,received:n.parsedType}),Pe;const i=this._def.keyType,s=this._def.valueType,o=[...n.data.entries()].map(([c,u],d)=>({key:i._parse(new un(n,c,n.path,[d,"key"])),value:s._parse(new un(n,u,n.path,[d,"value"]))}));if(n.common.async){const c=new Map;return Promise.resolve().then(async()=>{for(const u of o){const d=await u.key,b=await u.value;if(d.status==="aborted"||b.status==="aborted")return Pe;(d.status==="dirty"||b.status==="dirty")&&t.dirty(),c.set(d.value,b.value)}return{status:t.value,value:c}})}else{const c=new Map;for(const u of o){const d=u.key,b=u.value;if(d.status==="aborted"||b.status==="aborted")return Pe;(d.status==="dirty"||b.status==="dirty")&&t.dirty(),c.set(d.value,b.value)}return{status:t.value,value:c}}}}Bc.create=(r,e,t)=>new Bc({valueType:e,keyType:r,typeName:je.ZodMap,...Me(t)});class Mi extends Ge{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==ce.set)return ie(n,{code:Z.invalid_type,expected:ce.set,received:n.parsedType}),Pe;const i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(ie(n,{code:Z.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),t.dirty()),i.maxSize!==null&&n.data.size>i.maxSize.value&&(ie(n,{code:Z.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),t.dirty());const s=this._def.valueType;function o(u){const d=new Set;for(const b of u){if(b.status==="aborted")return Pe;b.status==="dirty"&&t.dirty(),d.add(b.value)}return{status:t.value,value:d}}const c=[...n.data.values()].map((u,d)=>s._parse(new un(n,u,n.path,d)));return n.common.async?Promise.all(c).then(u=>o(u)):o(c)}min(e,t){return new Mi({...this._def,minSize:{value:e,message:Ie.toString(t)}})}max(e,t){return new Mi({...this._def,maxSize:{value:e,message:Ie.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}Mi.create=(r,e)=>new Mi({valueType:r,minSize:null,maxSize:null,typeName:je.ZodSet,...Me(e)});class _s extends Ge{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==ce.function)return ie(t,{code:Z.invalid_type,expected:ce.function,received:t.parsedType}),Pe;function n(c,u){return _c({data:c,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Sc(),bs].filter(d=>!!d),issueData:{code:Z.invalid_arguments,argumentsError:u}})}function i(c,u){return _c({data:c,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Sc(),bs].filter(d=>!!d),issueData:{code:Z.invalid_return_type,returnTypeError:u}})}const s={errorMap:t.common.contextualErrorMap},o=t.data;if(this._def.returns instanceof Es){const c=this;return ur(async function(...u){const d=new kr([]),b=await c._def.args.parseAsync(u,s).catch($=>{throw d.addIssue(n(u,$)),d}),E=await Reflect.apply(o,this,b);return await c._def.returns._def.type.parseAsync(E,s).catch($=>{throw d.addIssue(i(E,$)),d})})}else{const c=this;return ur(function(...u){const d=c._def.args.safeParse(u,s);if(!d.success)throw new kr([n(u,d.error)]);const b=Reflect.apply(o,this,d.data),E=c._def.returns.safeParse(b,s);if(!E.success)throw new kr([i(b,E.error)]);return E.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new _s({...this._def,args:fn.create(e).rest($i.create())})}returns(e){return new _s({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new _s({args:e||fn.create([]).rest($i.create()),returns:t||$i.create(),typeName:je.ZodFunction,...Me(n)})}}class Ao extends Ge{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}Ao.create=(r,e)=>new Ao({getter:r,typeName:je.ZodLazy,...Me(e)});class So extends Ge{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return ie(t,{received:t.data,code:Z.invalid_literal,expected:this._def.value}),Pe}return{status:"valid",value:e.data}}get value(){return this._def.value}}So.create=(r,e)=>new So({value:r,typeName:je.ZodLiteral,...Me(e)});function _0(r,e){return new ri({values:r,typeName:je.ZodEnum,...Me(e)})}class ri extends Ge{constructor(){super(...arguments),po.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return ie(t,{expected:it.joinValues(n),received:t.parsedType,code:Z.invalid_type}),Pe}if(Ec(this,po)||w0(this,po,new Set(this._def.values)),!Ec(this,po).has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return ie(t,{received:t.data,code:Z.invalid_enum_value,options:n}),Pe}return ur(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return ri.create(e,{...this._def,...t})}exclude(e,t=this._def){return ri.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}}po=new WeakMap,ri.create=_0;class _o extends Ge{constructor(){super(...arguments),yo.set(this,void 0)}_parse(e){const t=it.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==ce.string&&n.parsedType!==ce.number){const i=it.objectValues(t);return ie(n,{expected:it.joinValues(i),received:n.parsedType,code:Z.invalid_type}),Pe}if(Ec(this,yo)||w0(this,yo,new Set(it.getValidEnumValues(this._def.values))),!Ec(this,yo).has(e.data)){const i=it.objectValues(t);return ie(n,{received:n.data,code:Z.invalid_enum_value,options:i}),Pe}return ur(e.data)}get enum(){return this._def.values}}yo=new WeakMap,_o.create=(r,e)=>new _o({values:r,typeName:je.ZodNativeEnum,...Me(e)});class Es extends Ge{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==ce.promise&&t.common.async===!1)return ie(t,{code:Z.invalid_type,expected:ce.promise,received:t.parsedType}),Pe;const n=t.parsedType===ce.promise?t.data:Promise.resolve(t.data);return ur(n.then(i=>this._def.type.parseAsync(i,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Es.create=(r,e)=>new Es({type:r,typeName:je.ZodPromise,...Me(e)});class Jr extends Ge{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===je.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),i=this._def.effect||null,s={addIssue:o=>{ie(n,o),o.fatal?t.abort():t.dirty()},get path(){return n.path}};if(s.addIssue=s.addIssue.bind(s),i.type==="preprocess"){const o=i.transform(n.data,s);if(n.common.async)return Promise.resolve(o).then(async c=>{if(t.value==="aborted")return Pe;const u=await this._def.schema._parseAsync({data:c,path:n.path,parent:n});return u.status==="aborted"?Pe:u.status==="dirty"||t.value==="dirty"?xs(u.value):u});{if(t.value==="aborted")return Pe;const c=this._def.schema._parseSync({data:o,path:n.path,parent:n});return c.status==="aborted"?Pe:c.status==="dirty"||t.value==="dirty"?xs(c.value):c}}if(i.type==="refinement"){const o=c=>{const u=i.refinement(c,s);if(n.common.async)return Promise.resolve(u);if(u instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return c};if(n.common.async===!1){const c=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return c.status==="aborted"?Pe:(c.status==="dirty"&&t.dirty(),o(c.value),{status:t.value,value:c.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(c=>c.status==="aborted"?Pe:(c.status==="dirty"&&t.dirty(),o(c.value).then(()=>({status:t.value,value:c.value}))))}if(i.type==="transform")if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!fo(o))return o;const c=i.transform(o.value,s);if(c instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:c}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>fo(o)?Promise.resolve(i.transform(o.value,s)).then(c=>({status:t.value,value:c})):o);it.assertNever(i)}}Jr.create=(r,e,t)=>new Jr({schema:r,typeName:je.ZodEffects,effect:e,...Me(t)}),Jr.createWithPreprocess=(r,e,t)=>new Jr({schema:e,effect:{type:"preprocess",transform:r},typeName:je.ZodEffects,...Me(t)});class hn extends Ge{_parse(e){return this._getType(e)===ce.undefined?ur(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}hn.create=(r,e)=>new hn({innerType:r,typeName:je.ZodOptional,...Me(e)});class ni extends Ge{_parse(e){return this._getType(e)===ce.null?ur(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ni.create=(r,e)=>new ni({innerType:r,typeName:je.ZodNullable,...Me(e)});class Eo extends Ge{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===ce.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}Eo.create=(r,e)=>new Eo({innerType:r,typeName:je.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...Me(e)});class ko extends Ge{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},i=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return ho(i)?i.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new kr(n.common.issues)},input:n.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new kr(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}ko.create=(r,e)=>new ko({innerType:r,typeName:je.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...Me(e)});class Oc extends Ge{_parse(e){if(this._getType(e)!==ce.nan){const n=this._getOrReturnCtx(e);return ie(n,{code:Z.invalid_type,expected:ce.nan,received:n.parsedType}),Pe}return{status:"valid",value:e.data}}}Oc.create=r=>new Oc({typeName:je.ZodNaN,...Me(r)});const t1=Symbol("zod_brand");class wf extends Ge{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}}class Io extends Ge{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const s=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?Pe:s.status==="dirty"?(t.dirty(),xs(s.value)):this._def.out._parseAsync({data:s.value,path:n.path,parent:n})})();{const i=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?Pe:i.status==="dirty"?(t.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:n.path,parent:n})}}static create(e,t){return new Io({in:e,out:t,typeName:je.ZodPipeline})}}class Co extends Ge{_parse(e){const t=this._def.innerType._parse(e),n=i=>(fo(i)&&(i.value=Object.freeze(i.value)),i);return ho(t)?t.then(i=>n(i)):n(t)}unwrap(){return this._def.innerType}}Co.create=(r,e)=>new Co({innerType:r,typeName:je.ZodReadonly,...Me(e)});function E0(r,e={},t){return r?As.create().superRefine((n,i)=>{var s,o;if(!r(n)){const c=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,u=(o=(s=c.fatal)!==null&&s!==void 0?s:t)!==null&&o!==void 0?o:!0,d=typeof c=="string"?{message:c}:c;i.addIssue({code:"custom",...d,fatal:u})}}):As.create()}const r1={object:Nt.lazycreate};var je;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(je||(je={}));const n1=(r,e={message:`Input not instance of ${r.name}`})=>E0(t=>t instanceof r,e),k0=qr.create,I0=ei.create,i1=Oc.create,s1=ti.create,C0=go.create,o1=Di.create,a1=kc.create,c1=vo.create,l1=mo.create,u1=As.create,f1=$i.create,h1=jn.create,d1=Ic.create,p1=Yr.create,y1=Nt.create,g1=Nt.strictCreate,v1=wo.create,m1=Cc.create,w1=bo.create,b1=fn.create,x1=xo.create,A1=Bc.create,S1=Mi.create,_1=_s.create,E1=Ao.create,k1=So.create,I1=ri.create,C1=_o.create,B1=Es.create,B0=Jr.create,O1=hn.create,T1=ni.create,N1=Jr.createWithPreprocess,R1=Io.create;var Rt=Object.freeze({__proto__:null,defaultErrorMap:bs,setErrorMap:$v,getErrorMap:Sc,makeIssue:_c,EMPTY_PATH:Mv,addIssueToContext:ie,ParseStatus:rr,INVALID:Pe,DIRTY:xs,OK:ur,isAborted:yf,isDirty:gf,isValid:fo,isAsync:ho,get util(){return it},get objectUtil(){return pf},ZodParsedType:ce,getParsedType:Qn,ZodType:Ge,datetimeRegex:S0,ZodString:qr,ZodNumber:ei,ZodBigInt:ti,ZodBoolean:go,ZodDate:Di,ZodSymbol:kc,ZodUndefined:vo,ZodNull:mo,ZodAny:As,ZodUnknown:$i,ZodNever:jn,ZodVoid:Ic,ZodArray:Yr,ZodObject:Nt,ZodUnion:wo,ZodDiscriminatedUnion:Cc,ZodIntersection:bo,ZodTuple:fn,ZodRecord:xo,ZodMap:Bc,ZodSet:Mi,ZodFunction:_s,ZodLazy:Ao,ZodLiteral:So,ZodEnum:ri,ZodNativeEnum:_o,ZodPromise:Es,ZodEffects:Jr,ZodTransformer:Jr,ZodOptional:hn,ZodNullable:ni,ZodDefault:Eo,ZodCatch:ko,ZodNaN:Oc,BRAND:t1,ZodBranded:wf,ZodPipeline:Io,ZodReadonly:Co,custom:E0,Schema:Ge,ZodSchema:Ge,late:r1,get ZodFirstPartyTypeKind(){return je},coerce:{string:r=>qr.create({...r,coerce:!0}),number:r=>ei.create({...r,coerce:!0}),boolean:r=>go.create({...r,coerce:!0}),bigint:r=>ti.create({...r,coerce:!0}),date:r=>Di.create({...r,coerce:!0})},any:u1,array:p1,bigint:s1,boolean:C0,date:o1,discriminatedUnion:m1,effect:B0,enum:I1,function:_1,instanceof:n1,intersection:w1,lazy:E1,literal:k1,map:A1,nan:i1,nativeEnum:C1,never:h1,null:l1,nullable:T1,number:I0,object:y1,oboolean:()=>C0().optional(),onumber:()=>I0().optional(),optional:O1,ostring:()=>k0().optional(),pipeline:R1,preprocess:N1,promise:B1,record:x1,set:S1,strictObject:g1,string:k0,symbol:a1,transformer:B0,tuple:b1,undefined:c1,union:v1,unknown:f1,void:d1,NEVER:Pe,ZodIssueCode:Z,quotelessJson:Dv,ZodError:kr});const Tc=new Uint8Array([48,130,2,17,48,130,1,150,160,3,2,1,2,2,17,0,249,49,117,104,27,144,175,225,29,70,204,180,228,231,248,86,48,10,6,8,42,134,72,206,61,4,3,3,48,73,49,11,48,9,6,3,85,4,6,19,2,85,83,49,15,48,13,6,3,85,4,10,12,6,65,109,97,122,111,110,49,12,48,10,6,3,85,4,11,12,3,65,87,83,49,27,48,25,6,3,85,4,3,12,18,97,119,115,46,110,105,116,114,111,45,101,110,99,108,97,118,101,115,48,30,23,13,49,57,49,48,50,56,49,51,50,56,48,53,90,23,13,52,57,49,48,50,56,49,52,50,56,48,53,90,48,73,49,11,48,9,6,3,85,4,6,19,2,85,83,49,15,48,13,6,3,85,4,10,12,6,65,109,97,122,111,110,49,12,48,10,6,3,85,4,11,12,3,65,87,83,49,27,48,25,6,3,85,4,3,12,18,97,119,115,46,110,105,116,114,111,45,101,110,99,108,97,118,101,115,48,118,48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,34,3,98,0,4,252,2,84,235,166,8,193,243,104,112,226,154,218,144,190,70,56,50,146,115,110,137,75,255,246,114,217,137,68,75,80,81,229,52,164,177,246,219,227,192,188,88,26,50,183,177,118,7,14,222,18,214,154,63,234,33,27,102,231,82,207,125,209,221,9,95,111,19,112,244,23,8,67,217,220,16,1,33,228,207,99,1,40,9,102,68,135,201,121,98,132,48,77,197,63,244,163,66,48,64,48,15,6,3,85,29,19,1,1,255,4,5,48,3,1,1,255,48,29,6,3,85,29,14,4,22,4,20,144,37,181,13,217,5,71,231,150,195,150,250,114,157,207,153,169,223,75,150,48,14,6,3,85,29,15,1,1,255,4,4,3,2,1,134,48,10,6,8,42,134,72,206,61,4,3,3,3,105,0,48,102,2,49,0,163,127,47,145,161,201,189,94,231,184,98,124,22,152,210,85,3,142,31,3,67,249,91,99,169,98,140,61,57,128,149,69,161,30,188,191,46,59,85,216,174,238,113,180,195,214,173,243,2,49,0,162,243,155,22,5,178,112,40,165,221,75,160,105,181,1,110,101,180,251,222,143,224,6,29,106,83,25,127,156,218,245,217,67,188,97,252,43,235,3,203,111,238,141,35,2,243,223,246]);if(!Tc||Tc.length===0)throw new Error("AWS root certificate is empty or not loaded correctly");const j1=Rt.object({module_id:Rt.string().min(1),digest:Rt.literal("SHA384"),timestamp:Rt.number().min(1677721600),pcrs:Rt.map(Rt.number(),Rt.instanceof(Uint8Array)),certificate:Rt.instanceof(Uint8Array),cabundle:Rt.array(Rt.instanceof(Uint8Array)),public_key:Rt.nullable(Rt.instanceof(Uint8Array)),user_data:Rt.nullable(Rt.instanceof(Uint8Array)),nonce:Rt.nullable(Rt.instanceof(Uint8Array))}),P1=Rt.object({protected:Rt.instanceof(Uint8Array),payload:Rt.instanceof(Uint8Array),signature:Rt.instanceof(Uint8Array)});async function U1(r){try{if(!r)throw new Error("Attestation document is empty.");const e=Cs(r),t=Ac(e),n=t[0],i=t[2],s=t[3];return P1.parse({protected:n,payload:i,signature:s})}catch(e){throw console.error("Error parsing document data:",e),new Error("Failed to parse document data.")}}async function D1(r){try{const e=Ac(r);return j1.parse(e)}catch(e){throw console.error("Error parsing document payload:",e),new Error("Failed to parse document payload.")}}function $1(r,e){const t=["Signature1",r,new Uint8Array(0),e];return mc(t)}async function M1(r,e){try{console.log("SIGNATURE:"),console.log(Vr(r.signature));const t=$1(r.protected,r.payload),n=await crypto.subtle.digest("SHA-384",t);return console.log("SIGNATURE STRUCTURE DIGEST:"),console.log(Vr(new Uint8Array(n))),await crypto.subtle.verify({name:"ECDSA",hash:"SHA-384"},e,r.signature,t)}catch(t){throw console.error("Error verifying signature:",t),t instanceof Error?new Error(`Signature verification failed: ${t.message}`):new Error(`Signature verification failed: ${t}`)}}async function Nc(r,e,t){try{const n=await U1(r),i=await D1(n.payload);if(!i.nonce)throw new Error("Attestation document does not have a nonce.");const o=new TextDecoder("utf-8").decode(i.nonce);if(t!==o)throw console.log("Nonce mismatch"),console.log("Provided nonce:",t),console.log("Attestation document nonce:",o),new Error("Attestation document's nonce does not match the provided nonce.");const c=[],u=Vr(i.cabundle[0]);if(u!==Vr(e))throw console.error("Root cert doesn't match first cert"),console.log("First cert base64:",u),console.log("Trusted root cert base64:",Vr(e)),new Error("Root cert does not match first cert in attestation document.");for(let I=0;I<i.cabundle.length;I++){const R=new ji(i.cabundle[I]);c.push(R)}const d=new ji(i.certificate),E=await new lv({certificates:c}).build(d);console.log("Chain items:",E);const $=new Date().getTime();for(let I=0;I<E.length;I++){const R=E[I];if(console.log("CERT: ",I),console.log(R.subject),console.log("Not before:",R.notBefore),console.log("Not after:",R.notAfter),console.log(R.toString("pem")),R.notBefore.getTime()>$||R.notAfter.getTime()<$)throw new Error("Certificate is expired.");console.log(`Certificate ${I} is not expired.`)}if(E.length!==i.cabundle.length+1)throw new Error("Certificate chain length does not match length of cabundle.");const w=d.publicKey;console.log("PUBLIC KEY:"),console.log(Vr(new Uint8Array(w.rawData)));const _=await w.export(),T=await M1(n,_);if(console.log("Signature verified:",T),!T)throw new Error("Signature verification failed.");return i}catch(n){throw console.error("Error verifying attestation document:",n),n}}const V1=Rt.object({public_key:Rt.nullable(Rt.instanceof(Uint8Array))});async function _m(r){const e=Cs(r),n=Ac(e)[2],i=Ac(n);return await V1.parse(i)}async function L1(r){try{const e=await X1(r),t="https://enclave.secretgpt.ai";return await Nc(e,Tc,r)}catch(e){throw e instanceof Error?(console.error("Error verifying attestation document:",e),new Error(`Couldn't process attestation document: ${e.message}`)):(console.error("Error verifying attestation document:",e),new Error("Couldn't process attestation document."))}}function H1(r){throw new Error('Could not dynamically require "'+r+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var O0={exports:{}};const F1=Mc(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));(function(r){(function(e){var t=function(l){var y,p=new Float64Array(16);if(l)for(y=0;y<l.length;y++)p[y]=l[y];return p},n=function(){throw new Error("no PRNG")},i=new Uint8Array(16),s=new Uint8Array(32);s[0]=9;var o=t(),c=t([1]),u=t([56129,1]),d=t([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),b=t([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),E=t([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),Y=t([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),$=t([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function w(l,y,p,a){l[y]=p>>24&255,l[y+1]=p>>16&255,l[y+2]=p>>8&255,l[y+3]=p&255,l[y+4]=a>>24&255,l[y+5]=a>>16&255,l[y+6]=a>>8&255,l[y+7]=a&255}function _(l,y,p,a,v){var h,m=0;for(h=0;h<v;h++)m|=l[y+h]^p[a+h];return(1&m-1>>>8)-1}function T(l,y,p,a){return _(l,y,p,a,16)}function I(l,y,p,a){return _(l,y,p,a,32)}function R(l,y,p,a){for(var v=a[0]&255|(a[1]&255)<<8|(a[2]&255)<<16|(a[3]&255)<<24,h=p[0]&255|(p[1]&255)<<8|(p[2]&255)<<16|(p[3]&255)<<24,m=p[4]&255|(p[5]&255)<<8|(p[6]&255)<<16|(p[7]&255)<<24,S=p[8]&255|(p[9]&255)<<8|(p[10]&255)<<16|(p[11]&255)<<24,N=p[12]&255|(p[13]&255)<<8|(p[14]&255)<<16|(p[15]&255)<<24,W=a[4]&255|(a[5]&255)<<8|(a[6]&255)<<16|(a[7]&255)<<24,F=y[0]&255|(y[1]&255)<<8|(y[2]&255)<<16|(y[3]&255)<<24,ye=y[4]&255|(y[5]&255)<<8|(y[6]&255)<<16|(y[7]&255)<<24,L=y[8]&255|(y[9]&255)<<8|(y[10]&255)<<16|(y[11]&255)<<24,be=y[12]&255|(y[13]&255)<<8|(y[14]&255)<<16|(y[15]&255)<<24,ge=a[8]&255|(a[9]&255)<<8|(a[10]&255)<<16|(a[11]&255)<<24,xe=p[16]&255|(p[17]&255)<<8|(p[18]&255)<<16|(p[19]&255)<<24,Ce=p[20]&255|(p[21]&255)<<8|(p[22]&255)<<16|(p[23]&255)<<24,Be=p[24]&255|(p[25]&255)<<8|(p[26]&255)<<16|(p[27]&255)<<24,Oe=p[28]&255|(p[29]&255)<<8|(p[30]&255)<<16|(p[31]&255)<<24,_e=a[12]&255|(a[13]&255)<<8|(a[14]&255)<<16|(a[15]&255)<<24,fe=v,ke=h,se=m,we=S,Se=N,ne=W,B=F,O=ye,H=L,U=be,D=ge,G=xe,Ne=Ce,Le=Be,Fe=Oe,He=_e,x,Ye=0;Ye<20;Ye+=2)x=fe+Ne|0,Se^=x<<7|x>>>25,x=Se+fe|0,H^=x<<9|x>>>23,x=H+Se|0,Ne^=x<<13|x>>>19,x=Ne+H|0,fe^=x<<18|x>>>14,x=ne+ke|0,U^=x<<7|x>>>25,x=U+ne|0,Le^=x<<9|x>>>23,x=Le+U|0,ke^=x<<13|x>>>19,x=ke+Le|0,ne^=x<<18|x>>>14,x=D+B|0,Fe^=x<<7|x>>>25,x=Fe+D|0,se^=x<<9|x>>>23,x=se+Fe|0,B^=x<<13|x>>>19,x=B+se|0,D^=x<<18|x>>>14,x=He+G|0,we^=x<<7|x>>>25,x=we+He|0,O^=x<<9|x>>>23,x=O+we|0,G^=x<<13|x>>>19,x=G+O|0,He^=x<<18|x>>>14,x=fe+we|0,ke^=x<<7|x>>>25,x=ke+fe|0,se^=x<<9|x>>>23,x=se+ke|0,we^=x<<13|x>>>19,x=we+se|0,fe^=x<<18|x>>>14,x=ne+Se|0,B^=x<<7|x>>>25,x=B+ne|0,O^=x<<9|x>>>23,x=O+B|0,Se^=x<<13|x>>>19,x=Se+O|0,ne^=x<<18|x>>>14,x=D+U|0,G^=x<<7|x>>>25,x=G+D|0,H^=x<<9|x>>>23,x=H+G|0,U^=x<<13|x>>>19,x=U+H|0,D^=x<<18|x>>>14,x=He+Fe|0,Ne^=x<<7|x>>>25,x=Ne+He|0,Le^=x<<9|x>>>23,x=Le+Ne|0,Fe^=x<<13|x>>>19,x=Fe+Le|0,He^=x<<18|x>>>14;fe=fe+v|0,ke=ke+h|0,se=se+m|0,we=we+S|0,Se=Se+N|0,ne=ne+W|0,B=B+F|0,O=O+ye|0,H=H+L|0,U=U+be|0,D=D+ge|0,G=G+xe|0,Ne=Ne+Ce|0,Le=Le+Be|0,Fe=Fe+Oe|0,He=He+_e|0,l[0]=fe>>>0&255,l[1]=fe>>>8&255,l[2]=fe>>>16&255,l[3]=fe>>>24&255,l[4]=ke>>>0&255,l[5]=ke>>>8&255,l[6]=ke>>>16&255,l[7]=ke>>>24&255,l[8]=se>>>0&255,l[9]=se>>>8&255,l[10]=se>>>16&255,l[11]=se>>>24&255,l[12]=we>>>0&255,l[13]=we>>>8&255,l[14]=we>>>16&255,l[15]=we>>>24&255,l[16]=Se>>>0&255,l[17]=Se>>>8&255,l[18]=Se>>>16&255,l[19]=Se>>>24&255,l[20]=ne>>>0&255,l[21]=ne>>>8&255,l[22]=ne>>>16&255,l[23]=ne>>>24&255,l[24]=B>>>0&255,l[25]=B>>>8&255,l[26]=B>>>16&255,l[27]=B>>>24&255,l[28]=O>>>0&255,l[29]=O>>>8&255,l[30]=O>>>16&255,l[31]=O>>>24&255,l[32]=H>>>0&255,l[33]=H>>>8&255,l[34]=H>>>16&255,l[35]=H>>>24&255,l[36]=U>>>0&255,l[37]=U>>>8&255,l[38]=U>>>16&255,l[39]=U>>>24&255,l[40]=D>>>0&255,l[41]=D>>>8&255,l[42]=D>>>16&255,l[43]=D>>>24&255,l[44]=G>>>0&255,l[45]=G>>>8&255,l[46]=G>>>16&255,l[47]=G>>>24&255,l[48]=Ne>>>0&255,l[49]=Ne>>>8&255,l[50]=Ne>>>16&255,l[51]=Ne>>>24&255,l[52]=Le>>>0&255,l[53]=Le>>>8&255,l[54]=Le>>>16&255,l[55]=Le>>>24&255,l[56]=Fe>>>0&255,l[57]=Fe>>>8&255,l[58]=Fe>>>16&255,l[59]=Fe>>>24&255,l[60]=He>>>0&255,l[61]=He>>>8&255,l[62]=He>>>16&255,l[63]=He>>>24&255}function P(l,y,p,a){for(var v=a[0]&255|(a[1]&255)<<8|(a[2]&255)<<16|(a[3]&255)<<24,h=p[0]&255|(p[1]&255)<<8|(p[2]&255)<<16|(p[3]&255)<<24,m=p[4]&255|(p[5]&255)<<8|(p[6]&255)<<16|(p[7]&255)<<24,S=p[8]&255|(p[9]&255)<<8|(p[10]&255)<<16|(p[11]&255)<<24,N=p[12]&255|(p[13]&255)<<8|(p[14]&255)<<16|(p[15]&255)<<24,W=a[4]&255|(a[5]&255)<<8|(a[6]&255)<<16|(a[7]&255)<<24,F=y[0]&255|(y[1]&255)<<8|(y[2]&255)<<16|(y[3]&255)<<24,ye=y[4]&255|(y[5]&255)<<8|(y[6]&255)<<16|(y[7]&255)<<24,L=y[8]&255|(y[9]&255)<<8|(y[10]&255)<<16|(y[11]&255)<<24,be=y[12]&255|(y[13]&255)<<8|(y[14]&255)<<16|(y[15]&255)<<24,ge=a[8]&255|(a[9]&255)<<8|(a[10]&255)<<16|(a[11]&255)<<24,xe=p[16]&255|(p[17]&255)<<8|(p[18]&255)<<16|(p[19]&255)<<24,Ce=p[20]&255|(p[21]&255)<<8|(p[22]&255)<<16|(p[23]&255)<<24,Be=p[24]&255|(p[25]&255)<<8|(p[26]&255)<<16|(p[27]&255)<<24,Oe=p[28]&255|(p[29]&255)<<8|(p[30]&255)<<16|(p[31]&255)<<24,_e=a[12]&255|(a[13]&255)<<8|(a[14]&255)<<16|(a[15]&255)<<24,fe=v,ke=h,se=m,we=S,Se=N,ne=W,B=F,O=ye,H=L,U=be,D=ge,G=xe,Ne=Ce,Le=Be,Fe=Oe,He=_e,x,Ye=0;Ye<20;Ye+=2)x=fe+Ne|0,Se^=x<<7|x>>>25,x=Se+fe|0,H^=x<<9|x>>>23,x=H+Se|0,Ne^=x<<13|x>>>19,x=Ne+H|0,fe^=x<<18|x>>>14,x=ne+ke|0,U^=x<<7|x>>>25,x=U+ne|0,Le^=x<<9|x>>>23,x=Le+U|0,ke^=x<<13|x>>>19,x=ke+Le|0,ne^=x<<18|x>>>14,x=D+B|0,Fe^=x<<7|x>>>25,x=Fe+D|0,se^=x<<9|x>>>23,x=se+Fe|0,B^=x<<13|x>>>19,x=B+se|0,D^=x<<18|x>>>14,x=He+G|0,we^=x<<7|x>>>25,x=we+He|0,O^=x<<9|x>>>23,x=O+we|0,G^=x<<13|x>>>19,x=G+O|0,He^=x<<18|x>>>14,x=fe+we|0,ke^=x<<7|x>>>25,x=ke+fe|0,se^=x<<9|x>>>23,x=se+ke|0,we^=x<<13|x>>>19,x=we+se|0,fe^=x<<18|x>>>14,x=ne+Se|0,B^=x<<7|x>>>25,x=B+ne|0,O^=x<<9|x>>>23,x=O+B|0,Se^=x<<13|x>>>19,x=Se+O|0,ne^=x<<18|x>>>14,x=D+U|0,G^=x<<7|x>>>25,x=G+D|0,H^=x<<9|x>>>23,x=H+G|0,U^=x<<13|x>>>19,x=U+H|0,D^=x<<18|x>>>14,x=He+Fe|0,Ne^=x<<7|x>>>25,x=Ne+He|0,Le^=x<<9|x>>>23,x=Le+Ne|0,Fe^=x<<13|x>>>19,x=Fe+Le|0,He^=x<<18|x>>>14;l[0]=fe>>>0&255,l[1]=fe>>>8&255,l[2]=fe>>>16&255,l[3]=fe>>>24&255,l[4]=ne>>>0&255,l[5]=ne>>>8&255,l[6]=ne>>>16&255,l[7]=ne>>>24&255,l[8]=D>>>0&255,l[9]=D>>>8&255,l[10]=D>>>16&255,l[11]=D>>>24&255,l[12]=He>>>0&255,l[13]=He>>>8&255,l[14]=He>>>16&255,l[15]=He>>>24&255,l[16]=B>>>0&255,l[17]=B>>>8&255,l[18]=B>>>16&255,l[19]=B>>>24&255,l[20]=O>>>0&255,l[21]=O>>>8&255,l[22]=O>>>16&255,l[23]=O>>>24&255,l[24]=H>>>0&255,l[25]=H>>>8&255,l[26]=H>>>16&255,l[27]=H>>>24&255,l[28]=U>>>0&255,l[29]=U>>>8&255,l[30]=U>>>16&255,l[31]=U>>>24&255}function K(l,y,p,a){R(l,y,p,a)}function de(l,y,p,a){P(l,y,p,a)}var le=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function pe(l,y,p,a,v,h,m){var S=new Uint8Array(16),N=new Uint8Array(64),W,F;for(F=0;F<16;F++)S[F]=0;for(F=0;F<8;F++)S[F]=h[F];for(;v>=64;){for(K(N,S,m,le),F=0;F<64;F++)l[y+F]=p[a+F]^N[F];for(W=1,F=8;F<16;F++)W=W+(S[F]&255)|0,S[F]=W&255,W>>>=8;v-=64,y+=64,a+=64}if(v>0)for(K(N,S,m,le),F=0;F<v;F++)l[y+F]=p[a+F]^N[F];return 0}function Re(l,y,p,a,v){var h=new Uint8Array(16),m=new Uint8Array(64),S,N;for(N=0;N<16;N++)h[N]=0;for(N=0;N<8;N++)h[N]=a[N];for(;p>=64;){for(K(m,h,v,le),N=0;N<64;N++)l[y+N]=m[N];for(S=1,N=8;N<16;N++)S=S+(h[N]&255)|0,h[N]=S&255,S>>>=8;p-=64,y+=64}if(p>0)for(K(m,h,v,le),N=0;N<p;N++)l[y+N]=m[N];return 0}function st(l,y,p,a,v){var h=new Uint8Array(32);de(h,a,v,le);for(var m=new Uint8Array(8),S=0;S<8;S++)m[S]=a[S+16];return Re(l,y,p,m,h)}function ht(l,y,p,a,v,h,m){var S=new Uint8Array(32);de(S,h,m,le);for(var N=new Uint8Array(8),W=0;W<8;W++)N[W]=h[W+16];return pe(l,y,p,a,v,N,S)}var _t=function(l){this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.leftover=0,this.fin=0;var y,p,a,v,h,m,S,N;y=l[0]&255|(l[1]&255)<<8,this.r[0]=y&8191,p=l[2]&255|(l[3]&255)<<8,this.r[1]=(y>>>13|p<<3)&8191,a=l[4]&255|(l[5]&255)<<8,this.r[2]=(p>>>10|a<<6)&7939,v=l[6]&255|(l[7]&255)<<8,this.r[3]=(a>>>7|v<<9)&8191,h=l[8]&255|(l[9]&255)<<8,this.r[4]=(v>>>4|h<<12)&255,this.r[5]=h>>>1&8190,m=l[10]&255|(l[11]&255)<<8,this.r[6]=(h>>>14|m<<2)&8191,S=l[12]&255|(l[13]&255)<<8,this.r[7]=(m>>>11|S<<5)&8065,N=l[14]&255|(l[15]&255)<<8,this.r[8]=(S>>>8|N<<8)&8191,this.r[9]=N>>>5&127,this.pad[0]=l[16]&255|(l[17]&255)<<8,this.pad[1]=l[18]&255|(l[19]&255)<<8,this.pad[2]=l[20]&255|(l[21]&255)<<8,this.pad[3]=l[22]&255|(l[23]&255)<<8,this.pad[4]=l[24]&255|(l[25]&255)<<8,this.pad[5]=l[26]&255|(l[27]&255)<<8,this.pad[6]=l[28]&255|(l[29]&255)<<8,this.pad[7]=l[30]&255|(l[31]&255)<<8};_t.prototype.blocks=function(l,y,p){for(var a=this.fin?0:2048,v,h,m,S,N,W,F,ye,L,be,ge,xe,Ce,Be,Oe,_e,fe,ke,se,we=this.h[0],Se=this.h[1],ne=this.h[2],B=this.h[3],O=this.h[4],H=this.h[5],U=this.h[6],D=this.h[7],G=this.h[8],Ne=this.h[9],Le=this.r[0],Fe=this.r[1],He=this.r[2],x=this.r[3],Ye=this.r[4],ut=this.r[5],ft=this.r[6],Ke=this.r[7],at=this.r[8],ct=this.r[9];p>=16;)v=l[y+0]&255|(l[y+1]&255)<<8,we+=v&8191,h=l[y+2]&255|(l[y+3]&255)<<8,Se+=(v>>>13|h<<3)&8191,m=l[y+4]&255|(l[y+5]&255)<<8,ne+=(h>>>10|m<<6)&8191,S=l[y+6]&255|(l[y+7]&255)<<8,B+=(m>>>7|S<<9)&8191,N=l[y+8]&255|(l[y+9]&255)<<8,O+=(S>>>4|N<<12)&8191,H+=N>>>1&8191,W=l[y+10]&255|(l[y+11]&255)<<8,U+=(N>>>14|W<<2)&8191,F=l[y+12]&255|(l[y+13]&255)<<8,D+=(W>>>11|F<<5)&8191,ye=l[y+14]&255|(l[y+15]&255)<<8,G+=(F>>>8|ye<<8)&8191,Ne+=ye>>>5|a,L=0,be=L,be+=we*Le,be+=Se*(5*ct),be+=ne*(5*at),be+=B*(5*Ke),be+=O*(5*ft),L=be>>>13,be&=8191,be+=H*(5*ut),be+=U*(5*Ye),be+=D*(5*x),be+=G*(5*He),be+=Ne*(5*Fe),L+=be>>>13,be&=8191,ge=L,ge+=we*Fe,ge+=Se*Le,ge+=ne*(5*ct),ge+=B*(5*at),ge+=O*(5*Ke),L=ge>>>13,ge&=8191,ge+=H*(5*ft),ge+=U*(5*ut),ge+=D*(5*Ye),ge+=G*(5*x),ge+=Ne*(5*He),L+=ge>>>13,ge&=8191,xe=L,xe+=we*He,xe+=Se*Fe,xe+=ne*Le,xe+=B*(5*ct),xe+=O*(5*at),L=xe>>>13,xe&=8191,xe+=H*(5*Ke),xe+=U*(5*ft),xe+=D*(5*ut),xe+=G*(5*Ye),xe+=Ne*(5*x),L+=xe>>>13,xe&=8191,Ce=L,Ce+=we*x,Ce+=Se*He,Ce+=ne*Fe,Ce+=B*Le,Ce+=O*(5*ct),L=Ce>>>13,Ce&=8191,Ce+=H*(5*at),Ce+=U*(5*Ke),Ce+=D*(5*ft),Ce+=G*(5*ut),Ce+=Ne*(5*Ye),L+=Ce>>>13,Ce&=8191,Be=L,Be+=we*Ye,Be+=Se*x,Be+=ne*He,Be+=B*Fe,Be+=O*Le,L=Be>>>13,Be&=8191,Be+=H*(5*ct),Be+=U*(5*at),Be+=D*(5*Ke),Be+=G*(5*ft),Be+=Ne*(5*ut),L+=Be>>>13,Be&=8191,Oe=L,Oe+=we*ut,Oe+=Se*Ye,Oe+=ne*x,Oe+=B*He,Oe+=O*Fe,L=Oe>>>13,Oe&=8191,Oe+=H*Le,Oe+=U*(5*ct),Oe+=D*(5*at),Oe+=G*(5*Ke),Oe+=Ne*(5*ft),L+=Oe>>>13,Oe&=8191,_e=L,_e+=we*ft,_e+=Se*ut,_e+=ne*Ye,_e+=B*x,_e+=O*He,L=_e>>>13,_e&=8191,_e+=H*Fe,_e+=U*Le,_e+=D*(5*ct),_e+=G*(5*at),_e+=Ne*(5*Ke),L+=_e>>>13,_e&=8191,fe=L,fe+=we*Ke,fe+=Se*ft,fe+=ne*ut,fe+=B*Ye,fe+=O*x,L=fe>>>13,fe&=8191,fe+=H*He,fe+=U*Fe,fe+=D*Le,fe+=G*(5*ct),fe+=Ne*(5*at),L+=fe>>>13,fe&=8191,ke=L,ke+=we*at,ke+=Se*Ke,ke+=ne*ft,ke+=B*ut,ke+=O*Ye,L=ke>>>13,ke&=8191,ke+=H*x,ke+=U*He,ke+=D*Fe,ke+=G*Le,ke+=Ne*(5*ct),L+=ke>>>13,ke&=8191,se=L,se+=we*ct,se+=Se*at,se+=ne*Ke,se+=B*ft,se+=O*ut,L=se>>>13,se&=8191,se+=H*Ye,se+=U*x,se+=D*He,se+=G*Fe,se+=Ne*Le,L+=se>>>13,se&=8191,L=(L<<2)+L|0,L=L+be|0,be=L&8191,L=L>>>13,ge+=L,we=be,Se=ge,ne=xe,B=Ce,O=Be,H=Oe,U=_e,D=fe,G=ke,Ne=se,y+=16,p-=16;this.h[0]=we,this.h[1]=Se,this.h[2]=ne,this.h[3]=B,this.h[4]=O,this.h[5]=H,this.h[6]=U,this.h[7]=D,this.h[8]=G,this.h[9]=Ne},_t.prototype.finish=function(l,y){var p=new Uint16Array(10),a,v,h,m;if(this.leftover){for(m=this.leftover,this.buffer[m++]=1;m<16;m++)this.buffer[m]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(a=this.h[1]>>>13,this.h[1]&=8191,m=2;m<10;m++)this.h[m]+=a,a=this.h[m]>>>13,this.h[m]&=8191;for(this.h[0]+=a*5,a=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=a,a=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=a,p[0]=this.h[0]+5,a=p[0]>>>13,p[0]&=8191,m=1;m<10;m++)p[m]=this.h[m]+a,a=p[m]>>>13,p[m]&=8191;for(p[9]-=8192,v=(a^1)-1,m=0;m<10;m++)p[m]&=v;for(v=~v,m=0;m<10;m++)this.h[m]=this.h[m]&v|p[m];for(this.h[0]=(this.h[0]|this.h[1]<<13)&65535,this.h[1]=(this.h[1]>>>3|this.h[2]<<10)&65535,this.h[2]=(this.h[2]>>>6|this.h[3]<<7)&65535,this.h[3]=(this.h[3]>>>9|this.h[4]<<4)&65535,this.h[4]=(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14)&65535,this.h[5]=(this.h[6]>>>2|this.h[7]<<11)&65535,this.h[6]=(this.h[7]>>>5|this.h[8]<<8)&65535,this.h[7]=(this.h[8]>>>8|this.h[9]<<5)&65535,h=this.h[0]+this.pad[0],this.h[0]=h&65535,m=1;m<8;m++)h=(this.h[m]+this.pad[m]|0)+(h>>>16)|0,this.h[m]=h&65535;l[y+0]=this.h[0]>>>0&255,l[y+1]=this.h[0]>>>8&255,l[y+2]=this.h[1]>>>0&255,l[y+3]=this.h[1]>>>8&255,l[y+4]=this.h[2]>>>0&255,l[y+5]=this.h[2]>>>8&255,l[y+6]=this.h[3]>>>0&255,l[y+7]=this.h[3]>>>8&255,l[y+8]=this.h[4]>>>0&255,l[y+9]=this.h[4]>>>8&255,l[y+10]=this.h[5]>>>0&255,l[y+11]=this.h[5]>>>8&255,l[y+12]=this.h[6]>>>0&255,l[y+13]=this.h[6]>>>8&255,l[y+14]=this.h[7]>>>0&255,l[y+15]=this.h[7]>>>8&255},_t.prototype.update=function(l,y,p){var a,v;if(this.leftover){for(v=16-this.leftover,v>p&&(v=p),a=0;a<v;a++)this.buffer[this.leftover+a]=l[y+a];if(p-=v,y+=v,this.leftover+=v,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(p>=16&&(v=p-p%16,this.blocks(l,y,v),y+=v,p-=v),p){for(a=0;a<p;a++)this.buffer[this.leftover+a]=l[y+a];this.leftover+=p}};function Et(l,y,p,a,v,h){var m=new _t(h);return m.update(p,a,v),m.finish(l,y),0}function lt(l,y,p,a,v,h){var m=new Uint8Array(16);return Et(m,0,p,a,v,h),T(l,y,m,0)}function pt(l,y,p,a,v){var h;if(p<32)return-1;for(ht(l,0,y,0,p,a,v),Et(l,16,l,32,p-32,l),h=0;h<16;h++)l[h]=0;return 0}function Xe(l,y,p,a,v){var h,m=new Uint8Array(32);if(p<32||(st(m,0,32,a,v),lt(y,16,y,32,p-32,m)!==0))return-1;for(ht(l,0,y,0,p,a,v),h=0;h<32;h++)l[h]=0;return 0}function ze(l,y){var p;for(p=0;p<16;p++)l[p]=y[p]|0}function oe(l){var y,p,a=1;for(y=0;y<16;y++)p=l[y]+a+65535,a=Math.floor(p/65536),l[y]=p-a*65536;l[0]+=a-1+37*(a-1)}function Te(l,y,p){for(var a,v=~(p-1),h=0;h<16;h++)a=v&(l[h]^y[h]),l[h]^=a,y[h]^=a}function dt(l,y){var p,a,v,h=t(),m=t();for(p=0;p<16;p++)m[p]=y[p];for(oe(m),oe(m),oe(m),a=0;a<2;a++){for(h[0]=m[0]-65517,p=1;p<15;p++)h[p]=m[p]-65535-(h[p-1]>>16&1),h[p-1]&=65535;h[15]=m[15]-32767-(h[14]>>16&1),v=h[15]>>16&1,h[14]&=65535,Te(m,h,1-v)}for(p=0;p<16;p++)l[2*p]=m[p]&255,l[2*p+1]=m[p]>>8}function It(l,y){var p=new Uint8Array(32),a=new Uint8Array(32);return dt(p,l),dt(a,y),I(p,0,a,0)}function Ct(l){var y=new Uint8Array(32);return dt(y,l),y[0]&1}function ue(l,y){var p;for(p=0;p<16;p++)l[p]=y[2*p]+(y[2*p+1]<<8);l[15]&=32767}function et(l,y,p){for(var a=0;a<16;a++)l[a]=y[a]+p[a]}function yt(l,y,p){for(var a=0;a<16;a++)l[a]=y[a]-p[a]}function ee(l,y,p){var a,v,h=0,m=0,S=0,N=0,W=0,F=0,ye=0,L=0,be=0,ge=0,xe=0,Ce=0,Be=0,Oe=0,_e=0,fe=0,ke=0,se=0,we=0,Se=0,ne=0,B=0,O=0,H=0,U=0,D=0,G=0,Ne=0,Le=0,Fe=0,He=0,x=p[0],Ye=p[1],ut=p[2],ft=p[3],Ke=p[4],at=p[5],ct=p[6],Lt=p[7],wt=p[8],Ut=p[9],Dt=p[10],$t=p[11],zt=p[12],nr=p[13],ir=p[14],sr=p[15];a=y[0],h+=a*x,m+=a*Ye,S+=a*ut,N+=a*ft,W+=a*Ke,F+=a*at,ye+=a*ct,L+=a*Lt,be+=a*wt,ge+=a*Ut,xe+=a*Dt,Ce+=a*$t,Be+=a*zt,Oe+=a*nr,_e+=a*ir,fe+=a*sr,a=y[1],m+=a*x,S+=a*Ye,N+=a*ut,W+=a*ft,F+=a*Ke,ye+=a*at,L+=a*ct,be+=a*Lt,ge+=a*wt,xe+=a*Ut,Ce+=a*Dt,Be+=a*$t,Oe+=a*zt,_e+=a*nr,fe+=a*ir,ke+=a*sr,a=y[2],S+=a*x,N+=a*Ye,W+=a*ut,F+=a*ft,ye+=a*Ke,L+=a*at,be+=a*ct,ge+=a*Lt,xe+=a*wt,Ce+=a*Ut,Be+=a*Dt,Oe+=a*$t,_e+=a*zt,fe+=a*nr,ke+=a*ir,se+=a*sr,a=y[3],N+=a*x,W+=a*Ye,F+=a*ut,ye+=a*ft,L+=a*Ke,be+=a*at,ge+=a*ct,xe+=a*Lt,Ce+=a*wt,Be+=a*Ut,Oe+=a*Dt,_e+=a*$t,fe+=a*zt,ke+=a*nr,se+=a*ir,we+=a*sr,a=y[4],W+=a*x,F+=a*Ye,ye+=a*ut,L+=a*ft,be+=a*Ke,ge+=a*at,xe+=a*ct,Ce+=a*Lt,Be+=a*wt,Oe+=a*Ut,_e+=a*Dt,fe+=a*$t,ke+=a*zt,se+=a*nr,we+=a*ir,Se+=a*sr,a=y[5],F+=a*x,ye+=a*Ye,L+=a*ut,be+=a*ft,ge+=a*Ke,xe+=a*at,Ce+=a*ct,Be+=a*Lt,Oe+=a*wt,_e+=a*Ut,fe+=a*Dt,ke+=a*$t,se+=a*zt,we+=a*nr,Se+=a*ir,ne+=a*sr,a=y[6],ye+=a*x,L+=a*Ye,be+=a*ut,ge+=a*ft,xe+=a*Ke,Ce+=a*at,Be+=a*ct,Oe+=a*Lt,_e+=a*wt,fe+=a*Ut,ke+=a*Dt,se+=a*$t,we+=a*zt,Se+=a*nr,ne+=a*ir,B+=a*sr,a=y[7],L+=a*x,be+=a*Ye,ge+=a*ut,xe+=a*ft,Ce+=a*Ke,Be+=a*at,Oe+=a*ct,_e+=a*Lt,fe+=a*wt,ke+=a*Ut,se+=a*Dt,we+=a*$t,Se+=a*zt,ne+=a*nr,B+=a*ir,O+=a*sr,a=y[8],be+=a*x,ge+=a*Ye,xe+=a*ut,Ce+=a*ft,Be+=a*Ke,Oe+=a*at,_e+=a*ct,fe+=a*Lt,ke+=a*wt,se+=a*Ut,we+=a*Dt,Se+=a*$t,ne+=a*zt,B+=a*nr,O+=a*ir,H+=a*sr,a=y[9],ge+=a*x,xe+=a*Ye,Ce+=a*ut,Be+=a*ft,Oe+=a*Ke,_e+=a*at,fe+=a*ct,ke+=a*Lt,se+=a*wt,we+=a*Ut,Se+=a*Dt,ne+=a*$t,B+=a*zt,O+=a*nr,H+=a*ir,U+=a*sr,a=y[10],xe+=a*x,Ce+=a*Ye,Be+=a*ut,Oe+=a*ft,_e+=a*Ke,fe+=a*at,ke+=a*ct,se+=a*Lt,we+=a*wt,Se+=a*Ut,ne+=a*Dt,B+=a*$t,O+=a*zt,H+=a*nr,U+=a*ir,D+=a*sr,a=y[11],Ce+=a*x,Be+=a*Ye,Oe+=a*ut,_e+=a*ft,fe+=a*Ke,ke+=a*at,se+=a*ct,we+=a*Lt,Se+=a*wt,ne+=a*Ut,B+=a*Dt,O+=a*$t,H+=a*zt,U+=a*nr,D+=a*ir,G+=a*sr,a=y[12],Be+=a*x,Oe+=a*Ye,_e+=a*ut,fe+=a*ft,ke+=a*Ke,se+=a*at,we+=a*ct,Se+=a*Lt,ne+=a*wt,B+=a*Ut,O+=a*Dt,H+=a*$t,U+=a*zt,D+=a*nr,G+=a*ir,Ne+=a*sr,a=y[13],Oe+=a*x,_e+=a*Ye,fe+=a*ut,ke+=a*ft,se+=a*Ke,we+=a*at,Se+=a*ct,ne+=a*Lt,B+=a*wt,O+=a*Ut,H+=a*Dt,U+=a*$t,D+=a*zt,G+=a*nr,Ne+=a*ir,Le+=a*sr,a=y[14],_e+=a*x,fe+=a*Ye,ke+=a*ut,se+=a*ft,we+=a*Ke,Se+=a*at,ne+=a*ct,B+=a*Lt,O+=a*wt,H+=a*Ut,U+=a*Dt,D+=a*$t,G+=a*zt,Ne+=a*nr,Le+=a*ir,Fe+=a*sr,a=y[15],fe+=a*x,ke+=a*Ye,se+=a*ut,we+=a*ft,Se+=a*Ke,ne+=a*at,B+=a*ct,O+=a*Lt,H+=a*wt,U+=a*Ut,D+=a*Dt,G+=a*$t,Ne+=a*zt,Le+=a*nr,Fe+=a*ir,He+=a*sr,h+=38*ke,m+=38*se,S+=38*we,N+=38*Se,W+=38*ne,F+=38*B,ye+=38*O,L+=38*H,be+=38*U,ge+=38*D,xe+=38*G,Ce+=38*Ne,Be+=38*Le,Oe+=38*Fe,_e+=38*He,v=1,a=h+v+65535,v=Math.floor(a/65536),h=a-v*65536,a=m+v+65535,v=Math.floor(a/65536),m=a-v*65536,a=S+v+65535,v=Math.floor(a/65536),S=a-v*65536,a=N+v+65535,v=Math.floor(a/65536),N=a-v*65536,a=W+v+65535,v=Math.floor(a/65536),W=a-v*65536,a=F+v+65535,v=Math.floor(a/65536),F=a-v*65536,a=ye+v+65535,v=Math.floor(a/65536),ye=a-v*65536,a=L+v+65535,v=Math.floor(a/65536),L=a-v*65536,a=be+v+65535,v=Math.floor(a/65536),be=a-v*65536,a=ge+v+65535,v=Math.floor(a/65536),ge=a-v*65536,a=xe+v+65535,v=Math.floor(a/65536),xe=a-v*65536,a=Ce+v+65535,v=Math.floor(a/65536),Ce=a-v*65536,a=Be+v+65535,v=Math.floor(a/65536),Be=a-v*65536,a=Oe+v+65535,v=Math.floor(a/65536),Oe=a-v*65536,a=_e+v+65535,v=Math.floor(a/65536),_e=a-v*65536,a=fe+v+65535,v=Math.floor(a/65536),fe=a-v*65536,h+=v-1+37*(v-1),v=1,a=h+v+65535,v=Math.floor(a/65536),h=a-v*65536,a=m+v+65535,v=Math.floor(a/65536),m=a-v*65536,a=S+v+65535,v=Math.floor(a/65536),S=a-v*65536,a=N+v+65535,v=Math.floor(a/65536),N=a-v*65536,a=W+v+65535,v=Math.floor(a/65536),W=a-v*65536,a=F+v+65535,v=Math.floor(a/65536),F=a-v*65536,a=ye+v+65535,v=Math.floor(a/65536),ye=a-v*65536,a=L+v+65535,v=Math.floor(a/65536),L=a-v*65536,a=be+v+65535,v=Math.floor(a/65536),be=a-v*65536,a=ge+v+65535,v=Math.floor(a/65536),ge=a-v*65536,a=xe+v+65535,v=Math.floor(a/65536),xe=a-v*65536,a=Ce+v+65535,v=Math.floor(a/65536),Ce=a-v*65536,a=Be+v+65535,v=Math.floor(a/65536),Be=a-v*65536,a=Oe+v+65535,v=Math.floor(a/65536),Oe=a-v*65536,a=_e+v+65535,v=Math.floor(a/65536),_e=a-v*65536,a=fe+v+65535,v=Math.floor(a/65536),fe=a-v*65536,h+=v-1+37*(v-1),l[0]=h,l[1]=m,l[2]=S,l[3]=N,l[4]=W,l[5]=F,l[6]=ye,l[7]=L,l[8]=be,l[9]=ge,l[10]=xe,l[11]=Ce,l[12]=Be,l[13]=Oe,l[14]=_e,l[15]=fe}function ot(l,y){ee(l,y,y)}function Bt(l,y){var p=t(),a;for(a=0;a<16;a++)p[a]=y[a];for(a=253;a>=0;a--)ot(p,p),a!==2&&a!==4&&ee(p,p,y);for(a=0;a<16;a++)l[a]=p[a]}function gn(l,y){var p=t(),a;for(a=0;a<16;a++)p[a]=y[a];for(a=250;a>=0;a--)ot(p,p),a!==1&&ee(p,p,y);for(a=0;a<16;a++)l[a]=p[a]}function vn(l,y,p){var a=new Uint8Array(32),v=new Float64Array(80),h,m,S=t(),N=t(),W=t(),F=t(),ye=t(),L=t();for(m=0;m<31;m++)a[m]=y[m];for(a[31]=y[31]&127|64,a[0]&=248,ue(v,p),m=0;m<16;m++)N[m]=v[m],F[m]=S[m]=W[m]=0;for(S[0]=F[0]=1,m=254;m>=0;--m)h=a[m>>>3]>>>(m&7)&1,Te(S,N,h),Te(W,F,h),et(ye,S,W),yt(S,S,W),et(W,N,F),yt(N,N,F),ot(F,ye),ot(L,S),ee(S,W,S),ee(W,N,ye),et(ye,S,W),yt(S,S,W),ot(N,S),yt(W,F,L),ee(S,W,u),et(S,S,F),ee(W,W,S),ee(S,F,L),ee(F,N,v),ot(N,ye),Te(S,N,h),Te(W,F,h);for(m=0;m<16;m++)v[m+16]=S[m],v[m+32]=W[m],v[m+48]=N[m],v[m+64]=F[m];var be=v.subarray(32),ge=v.subarray(16);return Bt(be,be),ee(ge,ge,be),dt(l,ge),0}function Ht(l,y){return vn(l,y,s)}function Vi(l,y){return n(y,32),Ht(l,y)}function Mr(l,y,p){var a=new Uint8Array(32);return vn(a,p,y),de(l,i,a,le)}var Li=pt,To=Xe;function mn(l,y,p,a,v,h){var m=new Uint8Array(32);return Mr(m,v,h),Li(l,y,p,a,m)}function wn(l,y,p,a,v,h){var m=new Uint8Array(32);return Mr(m,v,h),To(l,y,p,a,m)}var ai=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function ci(l,y,p,a){for(var v=new Int32Array(16),h=new Int32Array(16),m,S,N,W,F,ye,L,be,ge,xe,Ce,Be,Oe,_e,fe,ke,se,we,Se,ne,B,O,H,U,D,G,Ne=l[0],Le=l[1],Fe=l[2],He=l[3],x=l[4],Ye=l[5],ut=l[6],ft=l[7],Ke=y[0],at=y[1],ct=y[2],Lt=y[3],wt=y[4],Ut=y[5],Dt=y[6],$t=y[7],zt=0;a>=128;){for(Se=0;Se<16;Se++)ne=8*Se+zt,v[Se]=p[ne+0]<<24|p[ne+1]<<16|p[ne+2]<<8|p[ne+3],h[Se]=p[ne+4]<<24|p[ne+5]<<16|p[ne+6]<<8|p[ne+7];for(Se=0;Se<80;Se++)if(m=Ne,S=Le,N=Fe,W=He,F=x,ye=Ye,L=ut,be=ft,ge=Ke,xe=at,Ce=ct,Be=Lt,Oe=wt,_e=Ut,fe=Dt,ke=$t,B=ft,O=$t,H=O&65535,U=O>>>16,D=B&65535,G=B>>>16,B=(x>>>14|wt<<18)^(x>>>18|wt<<14)^(wt>>>9|x<<23),O=(wt>>>14|x<<18)^(wt>>>18|x<<14)^(x>>>9|wt<<23),H+=O&65535,U+=O>>>16,D+=B&65535,G+=B>>>16,B=x&Ye^~x&ut,O=wt&Ut^~wt&Dt,H+=O&65535,U+=O>>>16,D+=B&65535,G+=B>>>16,B=ai[Se*2],O=ai[Se*2+1],H+=O&65535,U+=O>>>16,D+=B&65535,G+=B>>>16,B=v[Se%16],O=h[Se%16],H+=O&65535,U+=O>>>16,D+=B&65535,G+=B>>>16,U+=H>>>16,D+=U>>>16,G+=D>>>16,se=D&65535|G<<16,we=H&65535|U<<16,B=se,O=we,H=O&65535,U=O>>>16,D=B&65535,G=B>>>16,B=(Ne>>>28|Ke<<4)^(Ke>>>2|Ne<<30)^(Ke>>>7|Ne<<25),O=(Ke>>>28|Ne<<4)^(Ne>>>2|Ke<<30)^(Ne>>>7|Ke<<25),H+=O&65535,U+=O>>>16,D+=B&65535,G+=B>>>16,B=Ne&Le^Ne&Fe^Le&Fe,O=Ke&at^Ke&ct^at&ct,H+=O&65535,U+=O>>>16,D+=B&65535,G+=B>>>16,U+=H>>>16,D+=U>>>16,G+=D>>>16,be=D&65535|G<<16,ke=H&65535|U<<16,B=W,O=Be,H=O&65535,U=O>>>16,D=B&65535,G=B>>>16,B=se,O=we,H+=O&65535,U+=O>>>16,D+=B&65535,G+=B>>>16,U+=H>>>16,D+=U>>>16,G+=D>>>16,W=D&65535|G<<16,Be=H&65535|U<<16,Le=m,Fe=S,He=N,x=W,Ye=F,ut=ye,ft=L,Ne=be,at=ge,ct=xe,Lt=Ce,wt=Be,Ut=Oe,Dt=_e,$t=fe,Ke=ke,Se%16===15)for(ne=0;ne<16;ne++)B=v[ne],O=h[ne],H=O&65535,U=O>>>16,D=B&65535,G=B>>>16,B=v[(ne+9)%16],O=h[(ne+9)%16],H+=O&65535,U+=O>>>16,D+=B&65535,G+=B>>>16,se=v[(ne+1)%16],we=h[(ne+1)%16],B=(se>>>1|we<<31)^(se>>>8|we<<24)^se>>>7,O=(we>>>1|se<<31)^(we>>>8|se<<24)^(we>>>7|se<<25),H+=O&65535,U+=O>>>16,D+=B&65535,G+=B>>>16,se=v[(ne+14)%16],we=h[(ne+14)%16],B=(se>>>19|we<<13)^(we>>>29|se<<3)^se>>>6,O=(we>>>19|se<<13)^(se>>>29|we<<3)^(we>>>6|se<<26),H+=O&65535,U+=O>>>16,D+=B&65535,G+=B>>>16,U+=H>>>16,D+=U>>>16,G+=D>>>16,v[ne]=D&65535|G<<16,h[ne]=H&65535|U<<16;B=Ne,O=Ke,H=O&65535,U=O>>>16,D=B&65535,G=B>>>16,B=l[0],O=y[0],H+=O&65535,U+=O>>>16,D+=B&65535,G+=B>>>16,U+=H>>>16,D+=U>>>16,G+=D>>>16,l[0]=Ne=D&65535|G<<16,y[0]=Ke=H&65535|U<<16,B=Le,O=at,H=O&65535,U=O>>>16,D=B&65535,G=B>>>16,B=l[1],O=y[1],H+=O&65535,U+=O>>>16,D+=B&65535,G+=B>>>16,U+=H>>>16,D+=U>>>16,G+=D>>>16,l[1]=Le=D&65535|G<<16,y[1]=at=H&65535|U<<16,B=Fe,O=ct,H=O&65535,U=O>>>16,D=B&65535,G=B>>>16,B=l[2],O=y[2],H+=O&65535,U+=O>>>16,D+=B&65535,G+=B>>>16,U+=H>>>16,D+=U>>>16,G+=D>>>16,l[2]=Fe=D&65535|G<<16,y[2]=ct=H&65535|U<<16,B=He,O=Lt,H=O&65535,U=O>>>16,D=B&65535,G=B>>>16,B=l[3],O=y[3],H+=O&65535,U+=O>>>16,D+=B&65535,G+=B>>>16,U+=H>>>16,D+=U>>>16,G+=D>>>16,l[3]=He=D&65535|G<<16,y[3]=Lt=H&65535|U<<16,B=x,O=wt,H=O&65535,U=O>>>16,D=B&65535,G=B>>>16,B=l[4],O=y[4],H+=O&65535,U+=O>>>16,D+=B&65535,G+=B>>>16,U+=H>>>16,D+=U>>>16,G+=D>>>16,l[4]=x=D&65535|G<<16,y[4]=wt=H&65535|U<<16,B=Ye,O=Ut,H=O&65535,U=O>>>16,D=B&65535,G=B>>>16,B=l[5],O=y[5],H+=O&65535,U+=O>>>16,D+=B&65535,G+=B>>>16,U+=H>>>16,D+=U>>>16,G+=D>>>16,l[5]=Ye=D&65535|G<<16,y[5]=Ut=H&65535|U<<16,B=ut,O=Dt,H=O&65535,U=O>>>16,D=B&65535,G=B>>>16,B=l[6],O=y[6],H+=O&65535,U+=O>>>16,D+=B&65535,G+=B>>>16,U+=H>>>16,D+=U>>>16,G+=D>>>16,l[6]=ut=D&65535|G<<16,y[6]=Dt=H&65535|U<<16,B=ft,O=$t,H=O&65535,U=O>>>16,D=B&65535,G=B>>>16,B=l[7],O=y[7],H+=O&65535,U+=O>>>16,D+=B&65535,G+=B>>>16,U+=H>>>16,D+=U>>>16,G+=D>>>16,l[7]=ft=D&65535|G<<16,y[7]=$t=H&65535|U<<16,zt+=128,a-=128}return a}function hr(l,y,p){var a=new Int32Array(8),v=new Int32Array(8),h=new Uint8Array(256),m,S=p;for(a[0]=1779033703,a[1]=3144134277,a[2]=1013904242,a[3]=2773480762,a[4]=1359893119,a[5]=2600822924,a[6]=528734635,a[7]=1541459225,v[0]=4089235720,v[1]=2227873595,v[2]=4271175723,v[3]=1595750129,v[4]=2917565137,v[5]=725511199,v[6]=4215389547,v[7]=327033209,ci(a,v,y,p),p%=128,m=0;m<p;m++)h[m]=y[S-p+m];for(h[p]=128,p=256-128*(p<112?1:0),h[p-9]=0,w(h,p-8,S/536870912|0,S<<3),ci(a,v,h,p),m=0;m<8;m++)w(l,8*m,a[m],v[m]);return 0}function Dn(l,y){var p=t(),a=t(),v=t(),h=t(),m=t(),S=t(),N=t(),W=t(),F=t();yt(p,l[1],l[0]),yt(F,y[1],y[0]),ee(p,p,F),et(a,l[0],l[1]),et(F,y[0],y[1]),ee(a,a,F),ee(v,l[3],y[3]),ee(v,v,b),ee(h,l[2],y[2]),et(h,h,h),yt(m,a,p),yt(S,h,v),et(N,h,v),et(W,a,p),ee(l[0],m,S),ee(l[1],W,N),ee(l[2],N,S),ee(l[3],m,W)}function li(l,y,p){var a;for(a=0;a<4;a++)Te(l[a],y[a],p)}function $n(l,y){var p=t(),a=t(),v=t();Bt(v,y[2]),ee(p,y[0],v),ee(a,y[1],v),dt(l,a),l[31]^=Ct(p)<<7}function Hi(l,y,p){var a,v;for(ze(l[0],o),ze(l[1],c),ze(l[2],c),ze(l[3],o),v=255;v>=0;--v)a=p[v/8|0]>>(v&7)&1,li(l,y,a),Dn(y,l),Dn(l,l),li(l,y,a)}function ui(l,y){var p=[t(),t(),t(),t()];ze(p[0],E),ze(p[1],Y),ze(p[2],c),ee(p[3],E,Y),Hi(l,p,y)}function fi(l,y,p){var a=new Uint8Array(64),v=[t(),t(),t(),t()],h;for(p||n(y,32),hr(a,y,32),a[0]&=248,a[31]&=127,a[31]|=64,ui(v,a),$n(l,v),h=0;h<32;h++)y[h+32]=l[h];return 0}var Br=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function Qr(l,y){var p,a,v,h;for(a=63;a>=32;--a){for(p=0,v=a-32,h=a-12;v<h;++v)y[v]+=p-16*y[a]*Br[v-(a-32)],p=Math.floor((y[v]+128)/256),y[v]-=p*256;y[v]+=p,y[a]=0}for(p=0,v=0;v<32;v++)y[v]+=p-(y[31]>>4)*Br[v],p=y[v]>>8,y[v]&=255;for(v=0;v<32;v++)y[v]-=p*Br[v];for(a=0;a<32;a++)y[a+1]+=y[a]>>8,l[a]=y[a]&255}function Fi(l){var y=new Float64Array(64),p;for(p=0;p<64;p++)y[p]=l[p];for(p=0;p<64;p++)l[p]=0;Qr(l,y)}function Gi(l,y,p,a){var v=new Uint8Array(64),h=new Uint8Array(64),m=new Uint8Array(64),S,N,W=new Float64Array(64),F=[t(),t(),t(),t()];hr(v,a,32),v[0]&=248,v[31]&=127,v[31]|=64;var ye=p+64;for(S=0;S<p;S++)l[64+S]=y[S];for(S=0;S<32;S++)l[32+S]=v[32+S];for(hr(m,l.subarray(32),p+32),Fi(m),ui(F,m),$n(l,F),S=32;S<64;S++)l[S]=a[S];for(hr(h,l,p+64),Fi(h),S=0;S<64;S++)W[S]=0;for(S=0;S<32;S++)W[S]=m[S];for(S=0;S<32;S++)for(N=0;N<32;N++)W[S+N]+=h[S]*v[N];return Qr(l.subarray(32),W),ye}function hi(l,y){var p=t(),a=t(),v=t(),h=t(),m=t(),S=t(),N=t();return ze(l[2],c),ue(l[1],y),ot(v,l[1]),ee(h,v,d),yt(v,v,l[2]),et(h,l[2],h),ot(m,h),ot(S,m),ee(N,S,m),ee(p,N,v),ee(p,p,h),gn(p,p),ee(p,p,v),ee(p,p,h),ee(p,p,h),ee(l[0],p,h),ot(a,l[0]),ee(a,a,h),It(a,v)&&ee(l[0],l[0],$),ot(a,l[0]),ee(a,a,h),It(a,v)?-1:(Ct(l[0])===y[31]>>7&&yt(l[0],o,l[0]),ee(l[3],l[0],l[1]),0)}function k(l,y,p,a){var v,h=new Uint8Array(32),m=new Uint8Array(64),S=[t(),t(),t(),t()],N=[t(),t(),t(),t()];if(p<64||hi(N,a))return-1;for(v=0;v<p;v++)l[v]=y[v];for(v=0;v<32;v++)l[v+32]=a[v];if(hr(m,l,p),Fi(m),Hi(S,N,m),ui(N,y.subarray(32)),Dn(S,N),$n(h,S),p-=64,I(y,0,h,0)){for(v=0;v<p;v++)l[v]=0;return-1}for(v=0;v<p;v++)l[v]=y[v+64];return p}var C=32,j=24,q=32,Ee=16,xt=32,At=32,Ue=32,X=32,te=32,re=j,me=q,Ve=Ee,Qe=64,gt=32,Vt=64,di=32,pi=64;e.lowlevel={crypto_core_hsalsa20:de,crypto_stream_xor:ht,crypto_stream:st,crypto_stream_salsa20_xor:pe,crypto_stream_salsa20:Re,crypto_onetimeauth:Et,crypto_onetimeauth_verify:lt,crypto_verify_16:T,crypto_verify_32:I,crypto_secretbox:pt,crypto_secretbox_open:Xe,crypto_scalarmult:vn,crypto_scalarmult_base:Ht,crypto_box_beforenm:Mr,crypto_box_afternm:Li,crypto_box:mn,crypto_box_open:wn,crypto_box_keypair:Vi,crypto_hash:hr,crypto_sign:Gi,crypto_sign_keypair:fi,crypto_sign_open:k,crypto_secretbox_KEYBYTES:C,crypto_secretbox_NONCEBYTES:j,crypto_secretbox_ZEROBYTES:q,crypto_secretbox_BOXZEROBYTES:Ee,crypto_scalarmult_BYTES:xt,crypto_scalarmult_SCALARBYTES:At,crypto_box_PUBLICKEYBYTES:Ue,crypto_box_SECRETKEYBYTES:X,crypto_box_BEFORENMBYTES:te,crypto_box_NONCEBYTES:re,crypto_box_ZEROBYTES:me,crypto_box_BOXZEROBYTES:Ve,crypto_sign_BYTES:Qe,crypto_sign_PUBLICKEYBYTES:gt,crypto_sign_SECRETKEYBYTES:Vt,crypto_sign_SEEDBYTES:di,crypto_hash_BYTES:pi,gf:t,D:d,L:Br,pack25519:dt,unpack25519:ue,M:ee,A:et,S:ot,Z:yt,pow2523:gn,add:Dn,set25519:ze,modL:Qr,scalarmult:Hi,scalarbase:ui};function zi(l,y){if(l.length!==C)throw new Error("bad key size");if(y.length!==j)throw new Error("bad nonce size")}function Sf(l,y){if(l.length!==Ue)throw new Error("bad public key size");if(y.length!==X)throw new Error("bad secret key size")}function dr(){for(var l=0;l<arguments.length;l++)if(!(arguments[l]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}function No(l){for(var y=0;y<l.length;y++)l[y]=0}e.randomBytes=function(l){var y=new Uint8Array(l);return n(y,l),y},e.secretbox=function(l,y,p){dr(l,y,p),zi(p,y);for(var a=new Uint8Array(q+l.length),v=new Uint8Array(a.length),h=0;h<l.length;h++)a[h+q]=l[h];return pt(v,a,a.length,y,p),v.subarray(Ee)},e.secretbox.open=function(l,y,p){dr(l,y,p),zi(p,y);for(var a=new Uint8Array(Ee+l.length),v=new Uint8Array(a.length),h=0;h<l.length;h++)a[h+Ee]=l[h];return a.length<32||Xe(v,a,a.length,y,p)!==0?null:v.subarray(q)},e.secretbox.keyLength=C,e.secretbox.nonceLength=j,e.secretbox.overheadLength=Ee,e.scalarMult=function(l,y){if(dr(l,y),l.length!==At)throw new Error("bad n size");if(y.length!==xt)throw new Error("bad p size");var p=new Uint8Array(xt);return vn(p,l,y),p},e.scalarMult.base=function(l){if(dr(l),l.length!==At)throw new Error("bad n size");var y=new Uint8Array(xt);return Ht(y,l),y},e.scalarMult.scalarLength=At,e.scalarMult.groupElementLength=xt,e.box=function(l,y,p,a){var v=e.box.before(p,a);return e.secretbox(l,y,v)},e.box.before=function(l,y){dr(l,y),Sf(l,y);var p=new Uint8Array(te);return Mr(p,l,y),p},e.box.after=e.secretbox,e.box.open=function(l,y,p,a){var v=e.box.before(p,a);return e.secretbox.open(l,y,v)},e.box.open.after=e.secretbox.open,e.box.keyPair=function(){var l=new Uint8Array(Ue),y=new Uint8Array(X);return Vi(l,y),{publicKey:l,secretKey:y}},e.box.keyPair.fromSecretKey=function(l){if(dr(l),l.length!==X)throw new Error("bad secret key size");var y=new Uint8Array(Ue);return Ht(y,l),{publicKey:y,secretKey:new Uint8Array(l)}},e.box.publicKeyLength=Ue,e.box.secretKeyLength=X,e.box.sharedKeyLength=te,e.box.nonceLength=re,e.box.overheadLength=e.secretbox.overheadLength,e.sign=function(l,y){if(dr(l,y),y.length!==Vt)throw new Error("bad secret key size");var p=new Uint8Array(Qe+l.length);return Gi(p,l,l.length,y),p},e.sign.open=function(l,y){if(dr(l,y),y.length!==gt)throw new Error("bad public key size");var p=new Uint8Array(l.length),a=k(p,l,l.length,y);if(a<0)return null;for(var v=new Uint8Array(a),h=0;h<v.length;h++)v[h]=p[h];return v},e.sign.detached=function(l,y){for(var p=e.sign(l,y),a=new Uint8Array(Qe),v=0;v<a.length;v++)a[v]=p[v];return a},e.sign.detached.verify=function(l,y,p){if(dr(l,y,p),y.length!==Qe)throw new Error("bad signature size");if(p.length!==gt)throw new Error("bad public key size");var a=new Uint8Array(Qe+l.length),v=new Uint8Array(Qe+l.length),h;for(h=0;h<Qe;h++)a[h]=y[h];for(h=0;h<l.length;h++)a[h+Qe]=l[h];return k(v,a,a.length,p)>=0},e.sign.keyPair=function(){var l=new Uint8Array(gt),y=new Uint8Array(Vt);return fi(l,y),{publicKey:l,secretKey:y}},e.sign.keyPair.fromSecretKey=function(l){if(dr(l),l.length!==Vt)throw new Error("bad secret key size");for(var y=new Uint8Array(gt),p=0;p<y.length;p++)y[p]=l[32+p];return{publicKey:y,secretKey:new Uint8Array(l)}},e.sign.keyPair.fromSeed=function(l){if(dr(l),l.length!==di)throw new Error("bad seed size");for(var y=new Uint8Array(gt),p=new Uint8Array(Vt),a=0;a<32;a++)p[a]=l[a];return fi(y,p,!0),{publicKey:y,secretKey:p}},e.sign.publicKeyLength=gt,e.sign.secretKeyLength=Vt,e.sign.seedLength=di,e.sign.signatureLength=Qe,e.hash=function(l){dr(l);var y=new Uint8Array(pi);return hr(y,l,l.length),y},e.hash.hashLength=pi,e.verify=function(l,y){return dr(l,y),l.length===0||y.length===0||l.length!==y.length?!1:_(l,0,y,0,l.length)===0},e.setPRNG=function(l){n=l},function(){var l=typeof self<"u"?self.crypto||self.msCrypto:null;if(l&&l.getRandomValues){var y=65536;e.setPRNG(function(p,a){var v,h=new Uint8Array(a);for(v=0;v<a;v+=y)l.getRandomValues(h.subarray(v,v+Math.min(a-v,y)));for(v=0;v<a;v++)p[v]=h[v];No(h)})}else typeof H1<"u"&&(l=F1,l&&l.randomBytes&&e.setPRNG(function(p,a){var v,h=l.randomBytes(a);for(v=0;v<a;v++)p[v]=h[v];No(h)}))}()})(r.exports?r.exports:self.nacl=self.nacl||{})})(O0);var G1=O0.exports;const T0=Wi(G1);async function Bo(r){const e=sessionStorage.getItem("sessionKey"),t=sessionStorage.getItem("sessionId");console.groupCollapsed("Attestation");try{if(e&&t&&!r){const s=Cs(e);return console.log("Using existing attestation from session storage."),{sessionKey:s,sessionId:t}}const n=window.crypto.randomUUID();console.log("Generated attestation nonce:",n);const i=await L1(n);if(i&&i.public_key){console.log("Attestation document verification succeeded");const s=T0.box.keyPair();console.log("Generated client key pair");const o=new Uint8Array(i.public_key),{encrypted_session_key:c,session_id:u}=await Q1(Vr(s.publicKey),n);console.log("Key exchange completed.");const d=T0.scalarMult(s.secretKey,o),b=Cs(c),E=12,Y=b.slice(0,E),$=b.slice(E),_=new Hc(d).open(Y,$);if(_)return console.log("Session key decrypted successfully"),window.sessionStorage.setItem("sessionKey",Vr(_)),window.sessionStorage.setItem("sessionId",u),{sessionKey:_,sessionId:u};throw new Error("Failed to decrypt session key")}else throw new Error("Invalid attestation document")}catch(n){throw console.error("Error verifying attestation:",n),n}finally{console.groupEnd()}}async function Dr(r,e,t,n){const i=async(s=!1)=>{try{s&&(console.log("Refreshing access token"),await Rc());const o=window.localStorage.getItem("access_token");if(!o)throw new Error("No access token available");const c=await N0(r,e,t,o,n);if(c.status===401&&!s)return console.log("Received 401, attempting to refresh token"),i(!0);if(c.error)throw new Error(c.error);if(!c.data)throw new Error("No data received from the server");return c.data}catch(o){throw console.error(o),o}};return i()}async function N0(r,e,t,n,i){let{sessionKey:s,sessionId:o}=await Bo();const c=async(d,b=!1)=>{if(b||!s||!o){const T=await Bo(!0);s=T.sessionKey,o=T.sessionId}if(!s||!o)throw new Error("Failed to make encrypted API call, no attestation available.");const E=t?JSON.stringify(t):void 0,Y=E?jf(s,E):void 0,$={"Content-Type":"application/json","x-session-id":o};d&&($.Authorization=`Bearer ${d}`);const w=await fetch(r,{method:e,headers:$,body:Y?JSON.stringify({encrypted:Y}):void 0}),_={status:w.status};if(w.ok)try{const T=await w.json(),I=Pf(s,T.encrypted);_.data=JSON.parse(I)}catch(T){console.error("Error decrypting or parsing response:",T),_.status=500,_.error="Failed to decrypt or parse the response"}else try{const T=await w.json();_.error=T.message||i||`HTTP error! Status: ${w.status}`}catch{_.error=i||`HTTP error! Status: ${w.status}`}return _},u=async(d,b=!1)=>{var E;try{const Y=await c(d,b);return(Y.status===400||(E=Y.error)!=null&&E.includes("Encryption error"))&&!b?(console.log("Encryption error or Bad Request, attempting to renew attestation"),u(d,!0)):Y}catch(Y){return{status:500,error:Y instanceof Error?Y.message:"Unknown error occurred"}}};return u(n)}async function Ir(r,e,t,n,i){const s=await N0(r,e,t,n,i);if(s.error)throw new Error(s.error);if(!s.data)throw new Error("No data received from the server");return s.data}let mt="http://localhost:3000";console.log("API_URL:",mt);function z1(r){mt=r}async function K1(r,e){return Ir(`${mt}/login`,"POST",{email:r,password:e})}async function Z1(r,e){return Ir(`${mt}/login`,"POST",{id:r,password:e})}async function W1(r,e,t,n){return Ir(`${mt}/register`,"POST",{email:r,password:e,inviteCode:t.toLowerCase(),name:n})}async function q1(r,e){return Ir(`${mt}/register`,"POST",{password:r,inviteCode:e.toLowerCase()})}async function Rc(){const r=window.localStorage.getItem("refresh_token");if(!r)throw new Error("No refresh token available");const e={refresh_token:r};try{const t=await Ir(`${mt}/refresh`,"POST",e,void 0,"Failed to refresh token");return window.localStorage.setItem("access_token",t.access_token),window.localStorage.setItem("refresh_token",t.refresh_token),t}catch(t){throw console.error("Error refreshing token:",t),t}}async function Y1(){return Dr(`${mt}/protected/user`,"GET",void 0,"Failed to fetch user")}async function R0(r,e){return Dr(`${mt}/protected/kv/${r}`,"PUT",e,"Failed to put key-value pair")}async function j0(r){return Dr(`${mt}/protected/kv/${r}`,"DELETE",void 0,"Failed to delete key-value pair")}async function P0(r){try{return await Dr(`${mt}/protected/kv/${r}`,"GET",void 0,"Failed to get key-value pair")}catch(e){console.error(`Error fetching key "${r}":`,e);return}}async function U0(){return Dr(`${mt}/protected/kv`,"GET",void 0,"Failed to list key-value pairs")}async function J1(r){const e={refresh_token:r};return Ir(`${mt}/logout`,"POST",e)}async function D0(r){return Ir(`${mt}/verify-email/${r}`,"GET",void 0,void 0,"Failed to verify email")}async function jc(){return Dr(`${mt}/protected/request_verification`,"POST",void 0,"Failed to request new verification code")}async function X1(r){const e=await fetch(`${mt}/attestation/${r}`);if(!e.ok)throw new Error(`Request failed with status ${e.status}`);return(await e.json()).attestation_document}async function Q1(r,e){const t=await fetch(`${mt}/key_exchange`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_public_key:r,nonce:e})});if(!t.ok)throw new Error("Key exchange failed");return t.json()}async function $0(r,e){const t={email:r,hashed_secret:e};return Ir(`${mt}/password-reset/request`,"POST",t,void 0,"Failed to request password reset")}async function M0(r,e,t,n){const i={email:r,alphanumeric_code:e,plaintext_secret:t,new_password:n};return Ir(`${mt}/password-reset/confirm`,"POST",i,void 0,"Failed to confirm password reset")}async function V0(r,e){const t={current_password:r,new_password:e};return Dr(`${mt}/protected/change_password`,"POST",t,"Failed to change password")}async function em(r){try{return await Ir(`${mt}/auth/github`,"POST",r?{invite_code:r}:{},void 0,"Failed to initiate GitHub auth")}catch(e){throw e instanceof Error&&e.message.includes("Invalid invite code")?new Error("Invalid invite code. Please check and try again."):e}}async function tm(r,e,t){const n={code:r,state:e,invite_code:t};try{return await Ir(`${mt}/auth/github/callback`,"POST",n,void 0,"GitHub callback failed")}catch(i){throw console.error("Detailed GitHub callback error:",i),i instanceof Error?i.message.includes("User exists")||i.message.includes("Email already registered")?new Error("An account with this email already exists. Please sign in using your existing account."):i.message.includes("Invalid invite code")?new Error("Invalid invite code. Please try signing up with a valid invite code."):i.message.includes("User not found")?new Error("User not found. Please sign up first before attempting to log in with GitHub."):new Error("Failed to authenticate with GitHub. Please try again."):i}}async function rm(r){try{return await Ir(`${mt}/auth/google`,"POST",r?{invite_code:r}:{},void 0,"Failed to initiate Google auth")}catch(e){throw e instanceof Error&&e.message.includes("Invalid invite code")?new Error("Invalid invite code. Please check and try again."):e}}async function nm(r,e,t){const n={code:r,state:e,invite_code:t};try{return await Ir(`${mt}/auth/google/callback`,"POST",n,void 0,"Google callback failed")}catch(i){throw console.error("Detailed Google callback error:",i),i instanceof Error?i.message.includes("User exists")||i.message.includes("Email already registered")?new Error("An account with this email already exists. Please sign in using your existing account."):i.message.includes("Invalid invite code")?new Error("Invalid invite code. Please try signing up with a valid invite code."):i.message.includes("User not found")?new Error("User not found. Please sign up first before attempting to log in with Google."):new Error("Failed to authenticate with Google. Please try again."):i}}async function L0(){return Dr(`${mt}/protected/private_key`,"GET",void 0,"Failed to fetch private key")}async function H0(r,e){const t=Vr(r);return Dr(`${mt}/protected/sign_message`,"POST",{message_base64:t,algorithm:e},"Failed to sign message")}async function F0(r){return Dr(`${mt}/protected/public_key?algorithm=${r}`,"GET",void 0,"Failed to fetch public key")}async function im(r,e,t){const n={email:r,password:e,name:t};return Dr(`${mt}/protected/convert_guest`,"POST",n,"Failed to convert guest account")}async function sm(r){return Dr(`${mt}/protected/third_party_token`,"POST",{audience:r},"Failed to generate third party token")}function om(){return async(r,e)=>{var n,i;const t=()=>{const s=window.localStorage.getItem("access_token");if(!s)throw new Error("No access token available");return`Bearer ${s}`};try{const s=new Headers(e==null?void 0:e.headers);s.set("Authorization",t());const{sessionKey:o,sessionId:c}=await Bo();if(!o||!c)throw new Error("No session key or ID available");s.set("x-session-id",c);const u={...e,headers:s};if(e!=null&&e.body){const b=jf(o,e.body);u.body=JSON.stringify({encrypted:b}),s.set("Content-Type","application/json")}let d=await fetch(r,u);if(d.status===401&&(console.warn("Unauthorized, refreshing access token"),await Rc(),s.set("Authorization",t()),u.headers=s,d=await fetch(r,u)),!d.ok){const b=await d.text();throw console.error("Request failed with response status:",d.status," and message:",b),new Error(`Request failed with status ${d.status}: ${b}`)}if((n=d.headers.get("content-type"))!=null&&n.includes("text/event-stream")){const b=(i=d.body)==null?void 0:i.getReader(),E=new TextDecoder;let Y="";const $=new ReadableStream({async start(w){for(;;){const{done:_,value:T}=await b.read();if(_)break;const I=E.decode(T);Y+=I;let R;for(;R=am(Y);)if(Y=Y.slice(R.length),R.trim().startsWith("data: ")){const P=R.slice(6).trim();if(P==="[DONE]")w.enqueue(`data: [DONE]
154
+ \r]`);return e=`^(?:${e})$`,new RegExp(e,"u")},"I-RegExp"),qe.registerDecoder(kt.REGEXP,r=>{if(d0(r.contents),r.contents.length<1||r.contents.length>2)throw new Error(`Invalid RegExp Array: ${r.contents}`);return new RegExp(r.contents[0],r.contents[1])},"RegExp"),Pt(RegExp,r=>[kt.REGEXP,[r.source,r.flags]]),qe.registerDecoder(64,r=>(Ui(r.contents),r.contents),"uint8 Typed Array");function tr(r,e,t){Ui(r.contents);let n=r.contents.length;if(n%e.BYTES_PER_ELEMENT!==0)throw new Error(`Number of bytes must be divisible by ${e.BYTES_PER_ELEMENT}, got: ${n}`);n/=e.BYTES_PER_ELEMENT;const i=new e(n),s=new DataView(r.contents.buffer,r.contents.byteOffset,r.contents.byteLength),o=s[`get${e.name.replace(/Array/,"")}`].bind(s);for(let c=0;c<n;c++)i[c]=o(c*e.BYTES_PER_ELEMENT,t);return i}function Xn(r,e,t,n,i){const s=i.forceEndian??f0;if(vc(s?e:t,r,i),Wr(n.byteLength,r,Ae.BYTE_STRING),f0===s)r.write(new Uint8Array(n.buffer,n.byteOffset,n.byteLength));else{const o=`write${n.constructor.name.replace(/Array/,"")}`,c=r[o].bind(r);for(const u of n)c(u,s)}}qe.registerDecoder(65,r=>tr(r,Uint16Array,!1),"uint16, big endian, Typed Array"),qe.registerDecoder(66,r=>tr(r,Uint32Array,!1),"uint32, big endian, Typed Array"),qe.registerDecoder(67,r=>tr(r,BigUint64Array,!1),"uint64, big endian, Typed Array"),qe.registerDecoder(68,r=>(Ui(r.contents),new Uint8ClampedArray(r.contents)),"uint8 Typed Array, clamped arithmetic"),Pt(Uint8ClampedArray,r=>[68,new Uint8Array(r.buffer,r.byteOffset,r.byteLength)]),qe.registerDecoder(69,r=>tr(r,Uint16Array,!0),"uint16, little endian, Typed Array"),Pt(Uint16Array,(r,e,t)=>Xn(e,69,65,r,t)),qe.registerDecoder(70,r=>tr(r,Uint32Array,!0),"uint32, little endian, Typed Array"),Pt(Uint32Array,(r,e,t)=>Xn(e,70,66,r,t)),qe.registerDecoder(71,r=>tr(r,BigUint64Array,!0),"uint64, little endian, Typed Array"),Pt(BigUint64Array,(r,e,t)=>Xn(e,71,67,r,t)),qe.registerDecoder(72,r=>(Ui(r.contents),new Int8Array(r.contents)),"sint8 Typed Array"),Pt(Int8Array,r=>[72,new Uint8Array(r.buffer,r.byteOffset,r.byteLength)]),qe.registerDecoder(73,r=>tr(r,Int16Array,!1),"sint16, big endian, Typed Array"),qe.registerDecoder(74,r=>tr(r,Int32Array,!1),"sint32, big endian, Typed Array"),qe.registerDecoder(75,r=>tr(r,BigInt64Array,!1),"sint64, big endian, Typed Array"),qe.registerDecoder(77,r=>tr(r,Int16Array,!0),"sint16, little endian, Typed Array"),Pt(Int16Array,(r,e,t)=>Xn(e,77,73,r,t)),qe.registerDecoder(78,r=>tr(r,Int32Array,!0),"sint32, little endian, Typed Array"),Pt(Int32Array,(r,e,t)=>Xn(e,78,74,r,t)),qe.registerDecoder(79,r=>tr(r,BigInt64Array,!0),"sint64, little endian, Typed Array"),Pt(BigInt64Array,(r,e,t)=>Xn(e,79,75,r,t)),qe.registerDecoder(81,r=>tr(r,Float32Array,!1),"IEEE 754 binary32, big endian, Typed Array"),qe.registerDecoder(82,r=>tr(r,Float64Array,!1),"IEEE 754 binary64, big endian, Typed Array"),qe.registerDecoder(85,r=>tr(r,Float32Array,!0),"IEEE 754 binary32, little endian, Typed Array"),Pt(Float32Array,(r,e,t)=>Xn(e,85,81,r,t)),qe.registerDecoder(86,r=>tr(r,Float64Array,!0),"IEEE 754 binary64, big endian, Typed Array"),Pt(Float64Array,(r,e,t)=>Xn(e,86,82,r,t)),qe.registerDecoder(kt.SET,r=>(d0(r.contents),new Set(r.contents)),"Set"),Pt(Set,r=>[kt.SET,[...r]]),qe.registerDecoder(kt.JSON,r=>(Jn(r.contents),JSON.parse(r.contents)),"JSON-encoded"),qe.registerDecoder(kt.SELF_DESCRIBED,r=>r.contents,"Self-Described"),qe.registerDecoder(kt.INVALID_16,()=>{throw new Error(`Tag always invalid: ${kt.INVALID_16}`)},"Invalid"),qe.registerDecoder(kt.INVALID_32,()=>{throw new Error(`Tag always invalid: ${kt.INVALID_32}`)},"Invalid"),qe.registerDecoder(kt.INVALID_64,()=>{throw new Error(`Tag always invalid: ${kt.INVALID_64}`)},"Invalid");function df(r){throw new Error(`Encoding ${r.constructor.name} intentionally unimplmented. It is not concrete enough to interoperate. Convert to Uint8Array first.`)}Pt(ArrayBuffer,df),Pt(DataView,df),typeof SharedArrayBuffer<"u"&&Pt(SharedArrayBuffer,df);function xc(r){return[NaN,r.valueOf()]}Pt(Boolean,xc),Pt(Number,xc),Pt(String,xc),Pt(BigInt,xc);function Ac(r,e={}){const t={...Yn.defaultDecodeOptions};if(e.dcbor?Object.assign(t,Yn.dcborDecodeOptions):e.cde&&Object.assign(t,Yn.cdeDecodeOptions),Object.assign(t,e),Object.hasOwn(t,"rejectLongNumbers"))throw new TypeError("rejectLongNumbers has changed to requirePreferred");t.boxed&&(t.saveOriginal=!0);const n=new uo(r,t);let i,s;for(const o of n){if(s=Yn.create(o,i,t,n),o[2]===Er.BREAK)if(i!=null&&i.isStreaming)i.left=0;else throw new Error("Unexpected BREAK");else i&&i.push(s,n,o[3]);for(s instanceof Yn&&(i=s);i!=null&&i.done;){s=i.convert(n);const c=i.parent;c==null||c.replaceLast(s,i,n),i=c}}return s}new TextEncoder;var it;(function(r){r.assertEqual=i=>i;function e(i){}r.assertIs=e;function t(i){throw new Error}r.assertNever=t,r.arrayToEnum=i=>{const s={};for(const o of i)s[o]=o;return s},r.getValidEnumValues=i=>{const s=r.objectKeys(i).filter(c=>typeof i[i[c]]!="number"),o={};for(const c of s)o[c]=i[c];return r.objectValues(o)},r.objectValues=i=>r.objectKeys(i).map(function(s){return i[s]}),r.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const s=[];for(const o in i)Object.prototype.hasOwnProperty.call(i,o)&&s.push(o);return s},r.find=(i,s)=>{for(const o of i)if(s(o))return o},r.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&isFinite(i)&&Math.floor(i)===i;function n(i,s=" | "){return i.map(o=>typeof o=="string"?`'${o}'`:o).join(s)}r.joinValues=n,r.jsonStringifyReplacer=(i,s)=>typeof s=="bigint"?s.toString():s})(it||(it={}));var pf;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(pf||(pf={}));const ce=it.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Qn=r=>{switch(typeof r){case"undefined":return ce.undefined;case"string":return ce.string;case"number":return isNaN(r)?ce.nan:ce.number;case"boolean":return ce.boolean;case"function":return ce.function;case"bigint":return ce.bigint;case"symbol":return ce.symbol;case"object":return Array.isArray(r)?ce.array:r===null?ce.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?ce.promise:typeof Map<"u"&&r instanceof Map?ce.map:typeof Set<"u"&&r instanceof Set?ce.set:typeof Date<"u"&&r instanceof Date?ce.date:ce.object;default:return ce.unknown}},Z=it.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"]),Dv=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");class kr extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(s){return s.message},n={_errors:[]},i=s=>{for(const o of s.issues)if(o.code==="invalid_union")o.unionErrors.map(i);else if(o.code==="invalid_return_type")i(o.returnTypeError);else if(o.code==="invalid_arguments")i(o.argumentsError);else if(o.path.length===0)n._errors.push(t(o));else{let c=n,u=0;for(;u<o.path.length;){const d=o.path[u];u===o.path.length-1?(c[d]=c[d]||{_errors:[]},c[d]._errors.push(t(o))):c[d]=c[d]||{_errors:[]},c=c[d],u++}}};return i(this),n}static assert(e){if(!(e instanceof kr))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,it.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const i of this.issues)i.path.length>0?(t[i.path[0]]=t[i.path[0]]||[],t[i.path[0]].push(e(i))):n.push(e(i));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}kr.create=r=>new kr(r);const bs=(r,e)=>{let t;switch(r.code){case Z.invalid_type:r.received===ce.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case Z.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,it.jsonStringifyReplacer)}`;break;case Z.unrecognized_keys:t=`Unrecognized key(s) in object: ${it.joinValues(r.keys,", ")}`;break;case Z.invalid_union:t="Invalid input";break;case Z.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${it.joinValues(r.options)}`;break;case Z.invalid_enum_value:t=`Invalid enum value. Expected ${it.joinValues(r.options)}, received '${r.received}'`;break;case Z.invalid_arguments:t="Invalid function arguments";break;case Z.invalid_return_type:t="Invalid function return type";break;case Z.invalid_date:t="Invalid date";break;case Z.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:it.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case Z.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case Z.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case Z.custom:t="Invalid input";break;case Z.invalid_intersection_types:t="Intersection results could not be merged";break;case Z.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case Z.not_finite:t="Number must be finite";break;default:t=e.defaultError,it.assertNever(r)}return{message:t}};let m0=bs;function $v(r){m0=r}function Sc(){return m0}const _c=r=>{const{data:e,path:t,errorMaps:n,issueData:i}=r,s=[...t,...i.path||[]],o={...i,path:s};if(i.message!==void 0)return{...i,path:s,message:i.message};let c="";const u=n.filter(d=>!!d).slice().reverse();for(const d of u)c=d(o,{data:e,defaultError:c}).message;return{...i,path:s,message:c}},Mv=[];function ie(r,e){const t=Sc(),n=_c({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===bs?void 0:bs].filter(i=>!!i)});r.common.issues.push(n)}class rr{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const i of t){if(i.status==="aborted")return Pe;i.status==="dirty"&&e.dirty(),n.push(i.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const i of t){const s=await i.key,o=await i.value;n.push({key:s,value:o})}return rr.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const i of t){const{key:s,value:o}=i;if(s.status==="aborted"||o.status==="aborted")return Pe;s.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof o.value<"u"||i.alwaysSet)&&(n[s.value]=o.value)}return{status:e.value,value:n}}}const Pe=Object.freeze({status:"aborted"}),xs=r=>({status:"dirty",value:r}),ur=r=>({status:"valid",value:r}),yf=r=>r.status==="aborted",gf=r=>r.status==="dirty",fo=r=>r.status==="valid",ho=r=>typeof Promise<"u"&&r instanceof Promise;function Ec(r,e,t,n){if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(r)}function w0(r,e,t,n,i){if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(r,t),t}typeof SuppressedError=="function"&&SuppressedError;var Ie;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(Ie||(Ie={}));var po,yo;class un{constructor(e,t,n,i){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=i}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}}const b0=(r,e)=>{if(fo(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new kr(r.common.issues);return this._error=t,this._error}}};function Me(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:i}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:i}:{errorMap:(o,c)=>{var u,d;const{message:b}=r;return o.code==="invalid_enum_value"?{message:b??c.defaultError}:typeof c.data>"u"?{message:(u=b??n)!==null&&u!==void 0?u:c.defaultError}:o.code!=="invalid_type"?{message:c.defaultError}:{message:(d=b??t)!==null&&d!==void 0?d:c.defaultError}},description:i}}class Ge{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 Qn(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Qn(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new rr,ctx:{common:e.parent.common,data:e.data,parsedType:Qn(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(ho(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){var n;const i={common:{issues:[],async:(n=t==null?void 0:t.async)!==null&&n!==void 0?n:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Qn(e)},s=this._parseSync({data:e,path:i.path,parent:i});return b0(i,s)}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Qn(e)},i=this._parse({data:e,path:n.path,parent:n}),s=await(ho(i)?i:Promise.resolve(i));return b0(n,s)}refine(e,t){const n=i=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(i):t;return this._refinement((i,s)=>{const o=e(i),c=()=>s.addIssue({code:Z.custom,...n(i)});return typeof Promise<"u"&&o instanceof Promise?o.then(u=>u?!0:(c(),!1)):o?!0:(c(),!1)})}refinement(e,t){return this._refinement((n,i)=>e(n)?!0:(i.addIssue(typeof t=="function"?t(n,i):t),!1))}_refinement(e){return new Jr({schema:this,typeName:je.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return hn.create(this,this._def)}nullable(){return ni.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Yr.create(this,this._def)}promise(){return Es.create(this,this._def)}or(e){return wo.create([this,e],this._def)}and(e){return bo.create(this,e,this._def)}transform(e){return new Jr({...Me(this._def),schema:this,typeName:je.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new Eo({...Me(this._def),innerType:this,defaultValue:t,typeName:je.ZodDefault})}brand(){return new wf({typeName:je.ZodBranded,type:this,...Me(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new ko({...Me(this._def),innerType:this,catchValue:t,typeName:je.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Io.create(this,e)}readonly(){return Co.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Vv=/^c[^\s-]{8,}$/i,Lv=/^[0-9a-z]+$/,Hv=/^[0-9A-HJKMNP-TV-Z]{26}$/,Fv=/^[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,Gv=/^[a-z0-9_-]{21}$/i,zv=/^[-+]?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)?)??$/,Kv=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Zv="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let vf;const Wv=/^(?:(?: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])$/,qv=/^(([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})))$/,Yv=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,x0="((\\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])))",Jv=new RegExp(`^${x0}$`);function A0(r){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`),e}function Xv(r){return new RegExp(`^${A0(r)}$`)}function S0(r){let e=`${x0}T${A0(r)}`;const t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Qv(r,e){return!!((e==="v4"||!e)&&Wv.test(r)||(e==="v6"||!e)&&qv.test(r))}class qr extends Ge{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==ce.string){const s=this._getOrReturnCtx(e);return ie(s,{code:Z.invalid_type,expected:ce.string,received:s.parsedType}),Pe}const n=new rr;let i;for(const s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(i=this._getOrReturnCtx(e,i),ie(i,{code:Z.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="max")e.data.length>s.value&&(i=this._getOrReturnCtx(e,i),ie(i,{code:Z.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="length"){const o=e.data.length>s.value,c=e.data.length<s.value;(o||c)&&(i=this._getOrReturnCtx(e,i),o?ie(i,{code:Z.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):c&&ie(i,{code:Z.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),n.dirty())}else if(s.kind==="email")Kv.test(e.data)||(i=this._getOrReturnCtx(e,i),ie(i,{validation:"email",code:Z.invalid_string,message:s.message}),n.dirty());else if(s.kind==="emoji")vf||(vf=new RegExp(Zv,"u")),vf.test(e.data)||(i=this._getOrReturnCtx(e,i),ie(i,{validation:"emoji",code:Z.invalid_string,message:s.message}),n.dirty());else if(s.kind==="uuid")Fv.test(e.data)||(i=this._getOrReturnCtx(e,i),ie(i,{validation:"uuid",code:Z.invalid_string,message:s.message}),n.dirty());else if(s.kind==="nanoid")Gv.test(e.data)||(i=this._getOrReturnCtx(e,i),ie(i,{validation:"nanoid",code:Z.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid")Vv.test(e.data)||(i=this._getOrReturnCtx(e,i),ie(i,{validation:"cuid",code:Z.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid2")Lv.test(e.data)||(i=this._getOrReturnCtx(e,i),ie(i,{validation:"cuid2",code:Z.invalid_string,message:s.message}),n.dirty());else if(s.kind==="ulid")Hv.test(e.data)||(i=this._getOrReturnCtx(e,i),ie(i,{validation:"ulid",code:Z.invalid_string,message:s.message}),n.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),ie(i,{validation:"url",code:Z.invalid_string,message:s.message}),n.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(i=this._getOrReturnCtx(e,i),ie(i,{validation:"regex",code:Z.invalid_string,message:s.message}),n.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(i=this._getOrReturnCtx(e,i),ie(i,{code:Z.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),n.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(i=this._getOrReturnCtx(e,i),ie(i,{code:Z.invalid_string,validation:{startsWith:s.value},message:s.message}),n.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(i=this._getOrReturnCtx(e,i),ie(i,{code:Z.invalid_string,validation:{endsWith:s.value},message:s.message}),n.dirty()):s.kind==="datetime"?S0(s).test(e.data)||(i=this._getOrReturnCtx(e,i),ie(i,{code:Z.invalid_string,validation:"datetime",message:s.message}),n.dirty()):s.kind==="date"?Jv.test(e.data)||(i=this._getOrReturnCtx(e,i),ie(i,{code:Z.invalid_string,validation:"date",message:s.message}),n.dirty()):s.kind==="time"?Xv(s).test(e.data)||(i=this._getOrReturnCtx(e,i),ie(i,{code:Z.invalid_string,validation:"time",message:s.message}),n.dirty()):s.kind==="duration"?zv.test(e.data)||(i=this._getOrReturnCtx(e,i),ie(i,{validation:"duration",code:Z.invalid_string,message:s.message}),n.dirty()):s.kind==="ip"?Qv(e.data,s.version)||(i=this._getOrReturnCtx(e,i),ie(i,{validation:"ip",code:Z.invalid_string,message:s.message}),n.dirty()):s.kind==="base64"?Yv.test(e.data)||(i=this._getOrReturnCtx(e,i),ie(i,{validation:"base64",code:Z.invalid_string,message:s.message}),n.dirty()):it.assertNever(s);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(i=>e.test(i),{validation:t,code:Z.invalid_string,...Ie.errToObj(n)})}_addCheck(e){return new qr({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Ie.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Ie.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Ie.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Ie.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...Ie.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Ie.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Ie.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Ie.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...Ie.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Ie.errToObj(e)})}datetime(e){var t,n;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,local:(n=e==null?void 0:e.local)!==null&&n!==void 0?n:!1,...Ie.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...Ie.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...Ie.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...Ie.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...Ie.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...Ie.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...Ie.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...Ie.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...Ie.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...Ie.errToObj(t)})}nonempty(e){return this.min(1,Ie.errToObj(e))}trim(){return new qr({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new qr({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new qr({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}qr.create=r=>{var e;return new qr({checks:[],typeName:je.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...Me(r)})};function e1(r,e){const t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,i=t>n?t:n,s=parseInt(r.toFixed(i).replace(".","")),o=parseInt(e.toFixed(i).replace(".",""));return s%o/Math.pow(10,i)}class ei extends Ge{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==ce.number){const s=this._getOrReturnCtx(e);return ie(s,{code:Z.invalid_type,expected:ce.number,received:s.parsedType}),Pe}let n;const i=new rr;for(const s of this._def.checks)s.kind==="int"?it.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),ie(n,{code:Z.invalid_type,expected:"integer",received:"float",message:s.message}),i.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),ie(n,{code:Z.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),ie(n,{code:Z.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="multipleOf"?e1(e.data,s.value)!==0&&(n=this._getOrReturnCtx(e,n),ie(n,{code:Z.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),ie(n,{code:Z.not_finite,message:s.message}),i.dirty()):it.assertNever(s);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Ie.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Ie.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Ie.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Ie.toString(t))}setLimit(e,t,n,i){return new ei({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:Ie.toString(i)}]})}_addCheck(e){return new ei({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Ie.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Ie.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Ie.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Ie.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Ie.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Ie.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:Ie.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Ie.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Ie.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&it.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}}ei.create=r=>new ei({checks:[],typeName:je.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...Me(r)});class ti extends Ge{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==ce.bigint){const s=this._getOrReturnCtx(e);return ie(s,{code:Z.invalid_type,expected:ce.bigint,received:s.parsedType}),Pe}let n;const i=new rr;for(const s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),ie(n,{code:Z.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),ie(n,{code:Z.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),ie(n,{code:Z.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):it.assertNever(s);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Ie.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Ie.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Ie.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Ie.toString(t))}setLimit(e,t,n,i){return new ti({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:Ie.toString(i)}]})}_addCheck(e){return new ti({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Ie.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Ie.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Ie.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Ie.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Ie.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}ti.create=r=>{var e;return new ti({checks:[],typeName:je.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...Me(r)})};class go extends Ge{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==ce.boolean){const n=this._getOrReturnCtx(e);return ie(n,{code:Z.invalid_type,expected:ce.boolean,received:n.parsedType}),Pe}return ur(e.data)}}go.create=r=>new go({typeName:je.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...Me(r)});class Di extends Ge{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==ce.date){const s=this._getOrReturnCtx(e);return ie(s,{code:Z.invalid_type,expected:ce.date,received:s.parsedType}),Pe}if(isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return ie(s,{code:Z.invalid_date}),Pe}const n=new rr;let i;for(const s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(i=this._getOrReturnCtx(e,i),ie(i,{code:Z.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),n.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(i=this._getOrReturnCtx(e,i),ie(i,{code:Z.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),n.dirty()):it.assertNever(s);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Di({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:Ie.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:Ie.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}Di.create=r=>new Di({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:je.ZodDate,...Me(r)});class kc extends Ge{_parse(e){if(this._getType(e)!==ce.symbol){const n=this._getOrReturnCtx(e);return ie(n,{code:Z.invalid_type,expected:ce.symbol,received:n.parsedType}),Pe}return ur(e.data)}}kc.create=r=>new kc({typeName:je.ZodSymbol,...Me(r)});class vo extends Ge{_parse(e){if(this._getType(e)!==ce.undefined){const n=this._getOrReturnCtx(e);return ie(n,{code:Z.invalid_type,expected:ce.undefined,received:n.parsedType}),Pe}return ur(e.data)}}vo.create=r=>new vo({typeName:je.ZodUndefined,...Me(r)});class mo extends Ge{_parse(e){if(this._getType(e)!==ce.null){const n=this._getOrReturnCtx(e);return ie(n,{code:Z.invalid_type,expected:ce.null,received:n.parsedType}),Pe}return ur(e.data)}}mo.create=r=>new mo({typeName:je.ZodNull,...Me(r)});class As extends Ge{constructor(){super(...arguments),this._any=!0}_parse(e){return ur(e.data)}}As.create=r=>new As({typeName:je.ZodAny,...Me(r)});class $i extends Ge{constructor(){super(...arguments),this._unknown=!0}_parse(e){return ur(e.data)}}$i.create=r=>new $i({typeName:je.ZodUnknown,...Me(r)});class jn extends Ge{_parse(e){const t=this._getOrReturnCtx(e);return ie(t,{code:Z.invalid_type,expected:ce.never,received:t.parsedType}),Pe}}jn.create=r=>new jn({typeName:je.ZodNever,...Me(r)});class Ic extends Ge{_parse(e){if(this._getType(e)!==ce.undefined){const n=this._getOrReturnCtx(e);return ie(n,{code:Z.invalid_type,expected:ce.void,received:n.parsedType}),Pe}return ur(e.data)}}Ic.create=r=>new Ic({typeName:je.ZodVoid,...Me(r)});class Yr extends Ge{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),i=this._def;if(t.parsedType!==ce.array)return ie(t,{code:Z.invalid_type,expected:ce.array,received:t.parsedType}),Pe;if(i.exactLength!==null){const o=t.data.length>i.exactLength.value,c=t.data.length<i.exactLength.value;(o||c)&&(ie(t,{code:o?Z.too_big:Z.too_small,minimum:c?i.exactLength.value:void 0,maximum:o?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(i.minLength!==null&&t.data.length<i.minLength.value&&(ie(t,{code:Z.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),i.maxLength!==null&&t.data.length>i.maxLength.value&&(ie(t,{code:Z.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((o,c)=>i.type._parseAsync(new un(t,o,t.path,c)))).then(o=>rr.mergeArray(n,o));const s=[...t.data].map((o,c)=>i.type._parseSync(new un(t,o,t.path,c)));return rr.mergeArray(n,s)}get element(){return this._def.type}min(e,t){return new Yr({...this._def,minLength:{value:e,message:Ie.toString(t)}})}max(e,t){return new Yr({...this._def,maxLength:{value:e,message:Ie.toString(t)}})}length(e,t){return new Yr({...this._def,exactLength:{value:e,message:Ie.toString(t)}})}nonempty(e){return this.min(1,e)}}Yr.create=(r,e)=>new Yr({type:r,minLength:null,maxLength:null,exactLength:null,typeName:je.ZodArray,...Me(e)});function Ss(r){if(r instanceof Nt){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=hn.create(Ss(n))}return new Nt({...r._def,shape:()=>e})}else return r instanceof Yr?new Yr({...r._def,type:Ss(r.element)}):r instanceof hn?hn.create(Ss(r.unwrap())):r instanceof ni?ni.create(Ss(r.unwrap())):r instanceof fn?fn.create(r.items.map(e=>Ss(e))):r}class Nt extends Ge{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=it.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==ce.object){const d=this._getOrReturnCtx(e);return ie(d,{code:Z.invalid_type,expected:ce.object,received:d.parsedType}),Pe}const{status:n,ctx:i}=this._processInputParams(e),{shape:s,keys:o}=this._getCached(),c=[];if(!(this._def.catchall instanceof jn&&this._def.unknownKeys==="strip"))for(const d in i.data)o.includes(d)||c.push(d);const u=[];for(const d of o){const b=s[d],E=i.data[d];u.push({key:{status:"valid",value:d},value:b._parse(new un(i,E,i.path,d)),alwaysSet:d in i.data})}if(this._def.catchall instanceof jn){const d=this._def.unknownKeys;if(d==="passthrough")for(const b of c)u.push({key:{status:"valid",value:b},value:{status:"valid",value:i.data[b]}});else if(d==="strict")c.length>0&&(ie(i,{code:Z.unrecognized_keys,keys:c}),n.dirty());else if(d!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const d=this._def.catchall;for(const b of c){const E=i.data[b];u.push({key:{status:"valid",value:b},value:d._parse(new un(i,E,i.path,b)),alwaysSet:b in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const d=[];for(const b of u){const E=await b.key,Y=await b.value;d.push({key:E,value:Y,alwaysSet:b.alwaysSet})}return d}).then(d=>rr.mergeObjectSync(n,d)):rr.mergeObjectSync(n,u)}get shape(){return this._def.shape()}strict(e){return Ie.errToObj,new Nt({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var i,s,o,c;const u=(o=(s=(i=this._def).errorMap)===null||s===void 0?void 0:s.call(i,t,n).message)!==null&&o!==void 0?o:n.defaultError;return t.code==="unrecognized_keys"?{message:(c=Ie.errToObj(e).message)!==null&&c!==void 0?c:u}:{message:u}}}:{}})}strip(){return new Nt({...this._def,unknownKeys:"strip"})}passthrough(){return new Nt({...this._def,unknownKeys:"passthrough"})}extend(e){return new Nt({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Nt({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:je.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Nt({...this._def,catchall:e})}pick(e){const t={};return it.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new Nt({...this._def,shape:()=>t})}omit(e){const t={};return it.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new Nt({...this._def,shape:()=>t})}deepPartial(){return Ss(this)}partial(e){const t={};return it.objectKeys(this.shape).forEach(n=>{const i=this.shape[n];e&&!e[n]?t[n]=i:t[n]=i.optional()}),new Nt({...this._def,shape:()=>t})}required(e){const t={};return it.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let s=this.shape[n];for(;s instanceof hn;)s=s._def.innerType;t[n]=s}}),new Nt({...this._def,shape:()=>t})}keyof(){return _0(it.objectKeys(this.shape))}}Nt.create=(r,e)=>new Nt({shape:()=>r,unknownKeys:"strip",catchall:jn.create(),typeName:je.ZodObject,...Me(e)}),Nt.strictCreate=(r,e)=>new Nt({shape:()=>r,unknownKeys:"strict",catchall:jn.create(),typeName:je.ZodObject,...Me(e)}),Nt.lazycreate=(r,e)=>new Nt({shape:r,unknownKeys:"strip",catchall:jn.create(),typeName:je.ZodObject,...Me(e)});class wo extends Ge{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function i(s){for(const c of s)if(c.result.status==="valid")return c.result;for(const c of s)if(c.result.status==="dirty")return t.common.issues.push(...c.ctx.common.issues),c.result;const o=s.map(c=>new kr(c.ctx.common.issues));return ie(t,{code:Z.invalid_union,unionErrors:o}),Pe}if(t.common.async)return Promise.all(n.map(async s=>{const o={...t,common:{...t.common,issues:[]},parent:null};return{result:await s._parseAsync({data:t.data,path:t.path,parent:o}),ctx:o}})).then(i);{let s;const o=[];for(const u of n){const d={...t,common:{...t.common,issues:[]},parent:null},b=u._parseSync({data:t.data,path:t.path,parent:d});if(b.status==="valid")return b;b.status==="dirty"&&!s&&(s={result:b,ctx:d}),d.common.issues.length&&o.push(d.common.issues)}if(s)return t.common.issues.push(...s.ctx.common.issues),s.result;const c=o.map(u=>new kr(u));return ie(t,{code:Z.invalid_union,unionErrors:c}),Pe}}get options(){return this._def.options}}wo.create=(r,e)=>new wo({options:r,typeName:je.ZodUnion,...Me(e)});const Pn=r=>r instanceof Ao?Pn(r.schema):r instanceof Jr?Pn(r.innerType()):r instanceof So?[r.value]:r instanceof ri?r.options:r instanceof _o?it.objectValues(r.enum):r instanceof Eo?Pn(r._def.innerType):r instanceof vo?[void 0]:r instanceof mo?[null]:r instanceof hn?[void 0,...Pn(r.unwrap())]:r instanceof ni?[null,...Pn(r.unwrap())]:r instanceof wf||r instanceof Co?Pn(r.unwrap()):r instanceof ko?Pn(r._def.innerType):[];class Cc extends Ge{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==ce.object)return ie(t,{code:Z.invalid_type,expected:ce.object,received:t.parsedType}),Pe;const n=this.discriminator,i=t.data[n],s=this.optionsMap.get(i);return s?t.common.async?s._parseAsync({data:t.data,path:t.path,parent:t}):s._parseSync({data:t.data,path:t.path,parent:t}):(ie(t,{code:Z.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),Pe)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const i=new Map;for(const s of t){const o=Pn(s.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const c of o){if(i.has(c))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(c)}`);i.set(c,s)}}return new Cc({typeName:je.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:i,...Me(n)})}}function mf(r,e){const t=Qn(r),n=Qn(e);if(r===e)return{valid:!0,data:r};if(t===ce.object&&n===ce.object){const i=it.objectKeys(e),s=it.objectKeys(r).filter(c=>i.indexOf(c)!==-1),o={...r,...e};for(const c of s){const u=mf(r[c],e[c]);if(!u.valid)return{valid:!1};o[c]=u.data}return{valid:!0,data:o}}else if(t===ce.array&&n===ce.array){if(r.length!==e.length)return{valid:!1};const i=[];for(let s=0;s<r.length;s++){const o=r[s],c=e[s],u=mf(o,c);if(!u.valid)return{valid:!1};i.push(u.data)}return{valid:!0,data:i}}else return t===ce.date&&n===ce.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class bo extends Ge{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),i=(s,o)=>{if(yf(s)||yf(o))return Pe;const c=mf(s.value,o.value);return c.valid?((gf(s)||gf(o))&&t.dirty(),{status:t.value,value:c.data}):(ie(n,{code:Z.invalid_intersection_types}),Pe)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([s,o])=>i(s,o)):i(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}bo.create=(r,e,t)=>new bo({left:r,right:e,typeName:je.ZodIntersection,...Me(t)});class fn extends Ge{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==ce.array)return ie(n,{code:Z.invalid_type,expected:ce.array,received:n.parsedType}),Pe;if(n.data.length<this._def.items.length)return ie(n,{code:Z.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Pe;!this._def.rest&&n.data.length>this._def.items.length&&(ie(n,{code:Z.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const s=[...n.data].map((o,c)=>{const u=this._def.items[c]||this._def.rest;return u?u._parse(new un(n,o,n.path,c)):null}).filter(o=>!!o);return n.common.async?Promise.all(s).then(o=>rr.mergeArray(t,o)):rr.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new fn({...this._def,rest:e})}}fn.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new fn({items:r,typeName:je.ZodTuple,rest:null,...Me(e)})};class xo extends Ge{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==ce.object)return ie(n,{code:Z.invalid_type,expected:ce.object,received:n.parsedType}),Pe;const i=[],s=this._def.keyType,o=this._def.valueType;for(const c in n.data)i.push({key:s._parse(new un(n,c,n.path,c)),value:o._parse(new un(n,n.data[c],n.path,c)),alwaysSet:c in n.data});return n.common.async?rr.mergeObjectAsync(t,i):rr.mergeObjectSync(t,i)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof Ge?new xo({keyType:e,valueType:t,typeName:je.ZodRecord,...Me(n)}):new xo({keyType:qr.create(),valueType:e,typeName:je.ZodRecord,...Me(t)})}}class Bc extends Ge{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==ce.map)return ie(n,{code:Z.invalid_type,expected:ce.map,received:n.parsedType}),Pe;const i=this._def.keyType,s=this._def.valueType,o=[...n.data.entries()].map(([c,u],d)=>({key:i._parse(new un(n,c,n.path,[d,"key"])),value:s._parse(new un(n,u,n.path,[d,"value"]))}));if(n.common.async){const c=new Map;return Promise.resolve().then(async()=>{for(const u of o){const d=await u.key,b=await u.value;if(d.status==="aborted"||b.status==="aborted")return Pe;(d.status==="dirty"||b.status==="dirty")&&t.dirty(),c.set(d.value,b.value)}return{status:t.value,value:c}})}else{const c=new Map;for(const u of o){const d=u.key,b=u.value;if(d.status==="aborted"||b.status==="aborted")return Pe;(d.status==="dirty"||b.status==="dirty")&&t.dirty(),c.set(d.value,b.value)}return{status:t.value,value:c}}}}Bc.create=(r,e,t)=>new Bc({valueType:e,keyType:r,typeName:je.ZodMap,...Me(t)});class Mi extends Ge{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==ce.set)return ie(n,{code:Z.invalid_type,expected:ce.set,received:n.parsedType}),Pe;const i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(ie(n,{code:Z.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),t.dirty()),i.maxSize!==null&&n.data.size>i.maxSize.value&&(ie(n,{code:Z.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),t.dirty());const s=this._def.valueType;function o(u){const d=new Set;for(const b of u){if(b.status==="aborted")return Pe;b.status==="dirty"&&t.dirty(),d.add(b.value)}return{status:t.value,value:d}}const c=[...n.data.values()].map((u,d)=>s._parse(new un(n,u,n.path,d)));return n.common.async?Promise.all(c).then(u=>o(u)):o(c)}min(e,t){return new Mi({...this._def,minSize:{value:e,message:Ie.toString(t)}})}max(e,t){return new Mi({...this._def,maxSize:{value:e,message:Ie.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}Mi.create=(r,e)=>new Mi({valueType:r,minSize:null,maxSize:null,typeName:je.ZodSet,...Me(e)});class _s extends Ge{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==ce.function)return ie(t,{code:Z.invalid_type,expected:ce.function,received:t.parsedType}),Pe;function n(c,u){return _c({data:c,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Sc(),bs].filter(d=>!!d),issueData:{code:Z.invalid_arguments,argumentsError:u}})}function i(c,u){return _c({data:c,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Sc(),bs].filter(d=>!!d),issueData:{code:Z.invalid_return_type,returnTypeError:u}})}const s={errorMap:t.common.contextualErrorMap},o=t.data;if(this._def.returns instanceof Es){const c=this;return ur(async function(...u){const d=new kr([]),b=await c._def.args.parseAsync(u,s).catch($=>{throw d.addIssue(n(u,$)),d}),E=await Reflect.apply(o,this,b);return await c._def.returns._def.type.parseAsync(E,s).catch($=>{throw d.addIssue(i(E,$)),d})})}else{const c=this;return ur(function(...u){const d=c._def.args.safeParse(u,s);if(!d.success)throw new kr([n(u,d.error)]);const b=Reflect.apply(o,this,d.data),E=c._def.returns.safeParse(b,s);if(!E.success)throw new kr([i(b,E.error)]);return E.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new _s({...this._def,args:fn.create(e).rest($i.create())})}returns(e){return new _s({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new _s({args:e||fn.create([]).rest($i.create()),returns:t||$i.create(),typeName:je.ZodFunction,...Me(n)})}}class Ao extends Ge{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}Ao.create=(r,e)=>new Ao({getter:r,typeName:je.ZodLazy,...Me(e)});class So extends Ge{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return ie(t,{received:t.data,code:Z.invalid_literal,expected:this._def.value}),Pe}return{status:"valid",value:e.data}}get value(){return this._def.value}}So.create=(r,e)=>new So({value:r,typeName:je.ZodLiteral,...Me(e)});function _0(r,e){return new ri({values:r,typeName:je.ZodEnum,...Me(e)})}class ri extends Ge{constructor(){super(...arguments),po.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return ie(t,{expected:it.joinValues(n),received:t.parsedType,code:Z.invalid_type}),Pe}if(Ec(this,po)||w0(this,po,new Set(this._def.values)),!Ec(this,po).has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return ie(t,{received:t.data,code:Z.invalid_enum_value,options:n}),Pe}return ur(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return ri.create(e,{...this._def,...t})}exclude(e,t=this._def){return ri.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}}po=new WeakMap,ri.create=_0;class _o extends Ge{constructor(){super(...arguments),yo.set(this,void 0)}_parse(e){const t=it.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==ce.string&&n.parsedType!==ce.number){const i=it.objectValues(t);return ie(n,{expected:it.joinValues(i),received:n.parsedType,code:Z.invalid_type}),Pe}if(Ec(this,yo)||w0(this,yo,new Set(it.getValidEnumValues(this._def.values))),!Ec(this,yo).has(e.data)){const i=it.objectValues(t);return ie(n,{received:n.data,code:Z.invalid_enum_value,options:i}),Pe}return ur(e.data)}get enum(){return this._def.values}}yo=new WeakMap,_o.create=(r,e)=>new _o({values:r,typeName:je.ZodNativeEnum,...Me(e)});class Es extends Ge{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==ce.promise&&t.common.async===!1)return ie(t,{code:Z.invalid_type,expected:ce.promise,received:t.parsedType}),Pe;const n=t.parsedType===ce.promise?t.data:Promise.resolve(t.data);return ur(n.then(i=>this._def.type.parseAsync(i,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Es.create=(r,e)=>new Es({type:r,typeName:je.ZodPromise,...Me(e)});class Jr extends Ge{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===je.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),i=this._def.effect||null,s={addIssue:o=>{ie(n,o),o.fatal?t.abort():t.dirty()},get path(){return n.path}};if(s.addIssue=s.addIssue.bind(s),i.type==="preprocess"){const o=i.transform(n.data,s);if(n.common.async)return Promise.resolve(o).then(async c=>{if(t.value==="aborted")return Pe;const u=await this._def.schema._parseAsync({data:c,path:n.path,parent:n});return u.status==="aborted"?Pe:u.status==="dirty"||t.value==="dirty"?xs(u.value):u});{if(t.value==="aborted")return Pe;const c=this._def.schema._parseSync({data:o,path:n.path,parent:n});return c.status==="aborted"?Pe:c.status==="dirty"||t.value==="dirty"?xs(c.value):c}}if(i.type==="refinement"){const o=c=>{const u=i.refinement(c,s);if(n.common.async)return Promise.resolve(u);if(u instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return c};if(n.common.async===!1){const c=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return c.status==="aborted"?Pe:(c.status==="dirty"&&t.dirty(),o(c.value),{status:t.value,value:c.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(c=>c.status==="aborted"?Pe:(c.status==="dirty"&&t.dirty(),o(c.value).then(()=>({status:t.value,value:c.value}))))}if(i.type==="transform")if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!fo(o))return o;const c=i.transform(o.value,s);if(c instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:c}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>fo(o)?Promise.resolve(i.transform(o.value,s)).then(c=>({status:t.value,value:c})):o);it.assertNever(i)}}Jr.create=(r,e,t)=>new Jr({schema:r,typeName:je.ZodEffects,effect:e,...Me(t)}),Jr.createWithPreprocess=(r,e,t)=>new Jr({schema:e,effect:{type:"preprocess",transform:r},typeName:je.ZodEffects,...Me(t)});class hn extends Ge{_parse(e){return this._getType(e)===ce.undefined?ur(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}hn.create=(r,e)=>new hn({innerType:r,typeName:je.ZodOptional,...Me(e)});class ni extends Ge{_parse(e){return this._getType(e)===ce.null?ur(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ni.create=(r,e)=>new ni({innerType:r,typeName:je.ZodNullable,...Me(e)});class Eo extends Ge{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===ce.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}Eo.create=(r,e)=>new Eo({innerType:r,typeName:je.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...Me(e)});class ko extends Ge{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},i=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return ho(i)?i.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new kr(n.common.issues)},input:n.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new kr(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}ko.create=(r,e)=>new ko({innerType:r,typeName:je.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...Me(e)});class Oc extends Ge{_parse(e){if(this._getType(e)!==ce.nan){const n=this._getOrReturnCtx(e);return ie(n,{code:Z.invalid_type,expected:ce.nan,received:n.parsedType}),Pe}return{status:"valid",value:e.data}}}Oc.create=r=>new Oc({typeName:je.ZodNaN,...Me(r)});const t1=Symbol("zod_brand");class wf extends Ge{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}}class Io extends Ge{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const s=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?Pe:s.status==="dirty"?(t.dirty(),xs(s.value)):this._def.out._parseAsync({data:s.value,path:n.path,parent:n})})();{const i=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?Pe:i.status==="dirty"?(t.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:n.path,parent:n})}}static create(e,t){return new Io({in:e,out:t,typeName:je.ZodPipeline})}}class Co extends Ge{_parse(e){const t=this._def.innerType._parse(e),n=i=>(fo(i)&&(i.value=Object.freeze(i.value)),i);return ho(t)?t.then(i=>n(i)):n(t)}unwrap(){return this._def.innerType}}Co.create=(r,e)=>new Co({innerType:r,typeName:je.ZodReadonly,...Me(e)});function E0(r,e={},t){return r?As.create().superRefine((n,i)=>{var s,o;if(!r(n)){const c=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,u=(o=(s=c.fatal)!==null&&s!==void 0?s:t)!==null&&o!==void 0?o:!0,d=typeof c=="string"?{message:c}:c;i.addIssue({code:"custom",...d,fatal:u})}}):As.create()}const r1={object:Nt.lazycreate};var je;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(je||(je={}));const n1=(r,e={message:`Input not instance of ${r.name}`})=>E0(t=>t instanceof r,e),k0=qr.create,I0=ei.create,i1=Oc.create,s1=ti.create,C0=go.create,o1=Di.create,a1=kc.create,c1=vo.create,l1=mo.create,u1=As.create,f1=$i.create,h1=jn.create,d1=Ic.create,p1=Yr.create,y1=Nt.create,g1=Nt.strictCreate,v1=wo.create,m1=Cc.create,w1=bo.create,b1=fn.create,x1=xo.create,A1=Bc.create,S1=Mi.create,_1=_s.create,E1=Ao.create,k1=So.create,I1=ri.create,C1=_o.create,B1=Es.create,B0=Jr.create,O1=hn.create,T1=ni.create,N1=Jr.createWithPreprocess,R1=Io.create;var Rt=Object.freeze({__proto__:null,defaultErrorMap:bs,setErrorMap:$v,getErrorMap:Sc,makeIssue:_c,EMPTY_PATH:Mv,addIssueToContext:ie,ParseStatus:rr,INVALID:Pe,DIRTY:xs,OK:ur,isAborted:yf,isDirty:gf,isValid:fo,isAsync:ho,get util(){return it},get objectUtil(){return pf},ZodParsedType:ce,getParsedType:Qn,ZodType:Ge,datetimeRegex:S0,ZodString:qr,ZodNumber:ei,ZodBigInt:ti,ZodBoolean:go,ZodDate:Di,ZodSymbol:kc,ZodUndefined:vo,ZodNull:mo,ZodAny:As,ZodUnknown:$i,ZodNever:jn,ZodVoid:Ic,ZodArray:Yr,ZodObject:Nt,ZodUnion:wo,ZodDiscriminatedUnion:Cc,ZodIntersection:bo,ZodTuple:fn,ZodRecord:xo,ZodMap:Bc,ZodSet:Mi,ZodFunction:_s,ZodLazy:Ao,ZodLiteral:So,ZodEnum:ri,ZodNativeEnum:_o,ZodPromise:Es,ZodEffects:Jr,ZodTransformer:Jr,ZodOptional:hn,ZodNullable:ni,ZodDefault:Eo,ZodCatch:ko,ZodNaN:Oc,BRAND:t1,ZodBranded:wf,ZodPipeline:Io,ZodReadonly:Co,custom:E0,Schema:Ge,ZodSchema:Ge,late:r1,get ZodFirstPartyTypeKind(){return je},coerce:{string:r=>qr.create({...r,coerce:!0}),number:r=>ei.create({...r,coerce:!0}),boolean:r=>go.create({...r,coerce:!0}),bigint:r=>ti.create({...r,coerce:!0}),date:r=>Di.create({...r,coerce:!0})},any:u1,array:p1,bigint:s1,boolean:C0,date:o1,discriminatedUnion:m1,effect:B0,enum:I1,function:_1,instanceof:n1,intersection:w1,lazy:E1,literal:k1,map:A1,nan:i1,nativeEnum:C1,never:h1,null:l1,nullable:T1,number:I0,object:y1,oboolean:()=>C0().optional(),onumber:()=>I0().optional(),optional:O1,ostring:()=>k0().optional(),pipeline:R1,preprocess:N1,promise:B1,record:x1,set:S1,strictObject:g1,string:k0,symbol:a1,transformer:B0,tuple:b1,undefined:c1,union:v1,unknown:f1,void:d1,NEVER:Pe,ZodIssueCode:Z,quotelessJson:Dv,ZodError:kr});const Tc=new Uint8Array([48,130,2,17,48,130,1,150,160,3,2,1,2,2,17,0,249,49,117,104,27,144,175,225,29,70,204,180,228,231,248,86,48,10,6,8,42,134,72,206,61,4,3,3,48,73,49,11,48,9,6,3,85,4,6,19,2,85,83,49,15,48,13,6,3,85,4,10,12,6,65,109,97,122,111,110,49,12,48,10,6,3,85,4,11,12,3,65,87,83,49,27,48,25,6,3,85,4,3,12,18,97,119,115,46,110,105,116,114,111,45,101,110,99,108,97,118,101,115,48,30,23,13,49,57,49,48,50,56,49,51,50,56,48,53,90,23,13,52,57,49,48,50,56,49,52,50,56,48,53,90,48,73,49,11,48,9,6,3,85,4,6,19,2,85,83,49,15,48,13,6,3,85,4,10,12,6,65,109,97,122,111,110,49,12,48,10,6,3,85,4,11,12,3,65,87,83,49,27,48,25,6,3,85,4,3,12,18,97,119,115,46,110,105,116,114,111,45,101,110,99,108,97,118,101,115,48,118,48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,34,3,98,0,4,252,2,84,235,166,8,193,243,104,112,226,154,218,144,190,70,56,50,146,115,110,137,75,255,246,114,217,137,68,75,80,81,229,52,164,177,246,219,227,192,188,88,26,50,183,177,118,7,14,222,18,214,154,63,234,33,27,102,231,82,207,125,209,221,9,95,111,19,112,244,23,8,67,217,220,16,1,33,228,207,99,1,40,9,102,68,135,201,121,98,132,48,77,197,63,244,163,66,48,64,48,15,6,3,85,29,19,1,1,255,4,5,48,3,1,1,255,48,29,6,3,85,29,14,4,22,4,20,144,37,181,13,217,5,71,231,150,195,150,250,114,157,207,153,169,223,75,150,48,14,6,3,85,29,15,1,1,255,4,4,3,2,1,134,48,10,6,8,42,134,72,206,61,4,3,3,3,105,0,48,102,2,49,0,163,127,47,145,161,201,189,94,231,184,98,124,22,152,210,85,3,142,31,3,67,249,91,99,169,98,140,61,57,128,149,69,161,30,188,191,46,59,85,216,174,238,113,180,195,214,173,243,2,49,0,162,243,155,22,5,178,112,40,165,221,75,160,105,181,1,110,101,180,251,222,143,224,6,29,106,83,25,127,156,218,245,217,67,188,97,252,43,235,3,203,111,238,141,35,2,243,223,246]);if(!Tc||Tc.length===0)throw new Error("AWS root certificate is empty or not loaded correctly");const j1=Rt.object({module_id:Rt.string().min(1),digest:Rt.literal("SHA384"),timestamp:Rt.number().min(1677721600),pcrs:Rt.map(Rt.number(),Rt.instanceof(Uint8Array)),certificate:Rt.instanceof(Uint8Array),cabundle:Rt.array(Rt.instanceof(Uint8Array)),public_key:Rt.nullable(Rt.instanceof(Uint8Array)),user_data:Rt.nullable(Rt.instanceof(Uint8Array)),nonce:Rt.nullable(Rt.instanceof(Uint8Array))}),P1=Rt.object({protected:Rt.instanceof(Uint8Array),payload:Rt.instanceof(Uint8Array),signature:Rt.instanceof(Uint8Array)});async function U1(r){try{if(!r)throw new Error("Attestation document is empty.");const e=Cs(r),t=Ac(e),n=t[0],i=t[2],s=t[3];return P1.parse({protected:n,payload:i,signature:s})}catch(e){throw console.error("Error parsing document data:",e),new Error("Failed to parse document data.")}}async function D1(r){try{const e=Ac(r);return j1.parse(e)}catch(e){throw console.error("Error parsing document payload:",e),new Error("Failed to parse document payload.")}}function $1(r,e){const t=["Signature1",r,new Uint8Array(0),e];return mc(t)}async function M1(r,e){try{console.log("SIGNATURE:"),console.log(Vr(r.signature));const t=$1(r.protected,r.payload),n=await crypto.subtle.digest("SHA-384",t);return console.log("SIGNATURE STRUCTURE DIGEST:"),console.log(Vr(new Uint8Array(n))),await crypto.subtle.verify({name:"ECDSA",hash:"SHA-384"},e,r.signature,t)}catch(t){throw console.error("Error verifying signature:",t),t instanceof Error?new Error(`Signature verification failed: ${t.message}`):new Error(`Signature verification failed: ${t}`)}}async function Nc(r,e,t){try{const n=await U1(r),i=await D1(n.payload);if(!i.nonce)throw new Error("Attestation document does not have a nonce.");const o=new TextDecoder("utf-8").decode(i.nonce);if(t!==o)throw console.log("Nonce mismatch"),console.log("Provided nonce:",t),console.log("Attestation document nonce:",o),new Error("Attestation document's nonce does not match the provided nonce.");const c=[],u=Vr(i.cabundle[0]);if(u!==Vr(e))throw console.error("Root cert doesn't match first cert"),console.log("First cert base64:",u),console.log("Trusted root cert base64:",Vr(e)),new Error("Root cert does not match first cert in attestation document.");for(let I=0;I<i.cabundle.length;I++){const R=new ji(i.cabundle[I]);c.push(R)}const d=new ji(i.certificate),E=await new lv({certificates:c}).build(d);console.log("Chain items:",E);const $=new Date().getTime();for(let I=0;I<E.length;I++){const R=E[I];if(console.log("CERT: ",I),console.log(R.subject),console.log("Not before:",R.notBefore),console.log("Not after:",R.notAfter),console.log(R.toString("pem")),R.notBefore.getTime()>$||R.notAfter.getTime()<$)throw new Error("Certificate is expired.");console.log(`Certificate ${I} is not expired.`)}if(E.length!==i.cabundle.length+1)throw new Error("Certificate chain length does not match length of cabundle.");const w=d.publicKey;console.log("PUBLIC KEY:"),console.log(Vr(new Uint8Array(w.rawData)));const _=await w.export(),T=await M1(n,_);if(console.log("Signature verified:",T),!T)throw new Error("Signature verification failed.");return i}catch(n){throw console.error("Error verifying attestation document:",n),n}}const V1=Rt.object({public_key:Rt.nullable(Rt.instanceof(Uint8Array))});async function Em(r){const e=Cs(r),n=Ac(e)[2],i=Ac(n);return await V1.parse(i)}async function L1(r){try{const e=await Q1(r),t="https://enclave.secretgpt.ai";return await Nc(e,Tc,r)}catch(e){throw e instanceof Error?(console.error("Error verifying attestation document:",e),new Error(`Couldn't process attestation document: ${e.message}`)):(console.error("Error verifying attestation document:",e),new Error("Couldn't process attestation document."))}}function H1(r){throw new Error('Could not dynamically require "'+r+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var O0={exports:{}};const F1=Mc(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));(function(r){(function(e){var t=function(l){var y,p=new Float64Array(16);if(l)for(y=0;y<l.length;y++)p[y]=l[y];return p},n=function(){throw new Error("no PRNG")},i=new Uint8Array(16),s=new Uint8Array(32);s[0]=9;var o=t(),c=t([1]),u=t([56129,1]),d=t([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),b=t([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),E=t([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),Y=t([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),$=t([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function w(l,y,p,a){l[y]=p>>24&255,l[y+1]=p>>16&255,l[y+2]=p>>8&255,l[y+3]=p&255,l[y+4]=a>>24&255,l[y+5]=a>>16&255,l[y+6]=a>>8&255,l[y+7]=a&255}function _(l,y,p,a,v){var h,m=0;for(h=0;h<v;h++)m|=l[y+h]^p[a+h];return(1&m-1>>>8)-1}function T(l,y,p,a){return _(l,y,p,a,16)}function I(l,y,p,a){return _(l,y,p,a,32)}function R(l,y,p,a){for(var v=a[0]&255|(a[1]&255)<<8|(a[2]&255)<<16|(a[3]&255)<<24,h=p[0]&255|(p[1]&255)<<8|(p[2]&255)<<16|(p[3]&255)<<24,m=p[4]&255|(p[5]&255)<<8|(p[6]&255)<<16|(p[7]&255)<<24,S=p[8]&255|(p[9]&255)<<8|(p[10]&255)<<16|(p[11]&255)<<24,N=p[12]&255|(p[13]&255)<<8|(p[14]&255)<<16|(p[15]&255)<<24,W=a[4]&255|(a[5]&255)<<8|(a[6]&255)<<16|(a[7]&255)<<24,F=y[0]&255|(y[1]&255)<<8|(y[2]&255)<<16|(y[3]&255)<<24,ye=y[4]&255|(y[5]&255)<<8|(y[6]&255)<<16|(y[7]&255)<<24,L=y[8]&255|(y[9]&255)<<8|(y[10]&255)<<16|(y[11]&255)<<24,be=y[12]&255|(y[13]&255)<<8|(y[14]&255)<<16|(y[15]&255)<<24,ge=a[8]&255|(a[9]&255)<<8|(a[10]&255)<<16|(a[11]&255)<<24,xe=p[16]&255|(p[17]&255)<<8|(p[18]&255)<<16|(p[19]&255)<<24,Ce=p[20]&255|(p[21]&255)<<8|(p[22]&255)<<16|(p[23]&255)<<24,Be=p[24]&255|(p[25]&255)<<8|(p[26]&255)<<16|(p[27]&255)<<24,Oe=p[28]&255|(p[29]&255)<<8|(p[30]&255)<<16|(p[31]&255)<<24,_e=a[12]&255|(a[13]&255)<<8|(a[14]&255)<<16|(a[15]&255)<<24,fe=v,ke=h,se=m,we=S,Se=N,ne=W,B=F,O=ye,H=L,U=be,D=ge,G=xe,Ne=Ce,Le=Be,Fe=Oe,He=_e,x,Ye=0;Ye<20;Ye+=2)x=fe+Ne|0,Se^=x<<7|x>>>25,x=Se+fe|0,H^=x<<9|x>>>23,x=H+Se|0,Ne^=x<<13|x>>>19,x=Ne+H|0,fe^=x<<18|x>>>14,x=ne+ke|0,U^=x<<7|x>>>25,x=U+ne|0,Le^=x<<9|x>>>23,x=Le+U|0,ke^=x<<13|x>>>19,x=ke+Le|0,ne^=x<<18|x>>>14,x=D+B|0,Fe^=x<<7|x>>>25,x=Fe+D|0,se^=x<<9|x>>>23,x=se+Fe|0,B^=x<<13|x>>>19,x=B+se|0,D^=x<<18|x>>>14,x=He+G|0,we^=x<<7|x>>>25,x=we+He|0,O^=x<<9|x>>>23,x=O+we|0,G^=x<<13|x>>>19,x=G+O|0,He^=x<<18|x>>>14,x=fe+we|0,ke^=x<<7|x>>>25,x=ke+fe|0,se^=x<<9|x>>>23,x=se+ke|0,we^=x<<13|x>>>19,x=we+se|0,fe^=x<<18|x>>>14,x=ne+Se|0,B^=x<<7|x>>>25,x=B+ne|0,O^=x<<9|x>>>23,x=O+B|0,Se^=x<<13|x>>>19,x=Se+O|0,ne^=x<<18|x>>>14,x=D+U|0,G^=x<<7|x>>>25,x=G+D|0,H^=x<<9|x>>>23,x=H+G|0,U^=x<<13|x>>>19,x=U+H|0,D^=x<<18|x>>>14,x=He+Fe|0,Ne^=x<<7|x>>>25,x=Ne+He|0,Le^=x<<9|x>>>23,x=Le+Ne|0,Fe^=x<<13|x>>>19,x=Fe+Le|0,He^=x<<18|x>>>14;fe=fe+v|0,ke=ke+h|0,se=se+m|0,we=we+S|0,Se=Se+N|0,ne=ne+W|0,B=B+F|0,O=O+ye|0,H=H+L|0,U=U+be|0,D=D+ge|0,G=G+xe|0,Ne=Ne+Ce|0,Le=Le+Be|0,Fe=Fe+Oe|0,He=He+_e|0,l[0]=fe>>>0&255,l[1]=fe>>>8&255,l[2]=fe>>>16&255,l[3]=fe>>>24&255,l[4]=ke>>>0&255,l[5]=ke>>>8&255,l[6]=ke>>>16&255,l[7]=ke>>>24&255,l[8]=se>>>0&255,l[9]=se>>>8&255,l[10]=se>>>16&255,l[11]=se>>>24&255,l[12]=we>>>0&255,l[13]=we>>>8&255,l[14]=we>>>16&255,l[15]=we>>>24&255,l[16]=Se>>>0&255,l[17]=Se>>>8&255,l[18]=Se>>>16&255,l[19]=Se>>>24&255,l[20]=ne>>>0&255,l[21]=ne>>>8&255,l[22]=ne>>>16&255,l[23]=ne>>>24&255,l[24]=B>>>0&255,l[25]=B>>>8&255,l[26]=B>>>16&255,l[27]=B>>>24&255,l[28]=O>>>0&255,l[29]=O>>>8&255,l[30]=O>>>16&255,l[31]=O>>>24&255,l[32]=H>>>0&255,l[33]=H>>>8&255,l[34]=H>>>16&255,l[35]=H>>>24&255,l[36]=U>>>0&255,l[37]=U>>>8&255,l[38]=U>>>16&255,l[39]=U>>>24&255,l[40]=D>>>0&255,l[41]=D>>>8&255,l[42]=D>>>16&255,l[43]=D>>>24&255,l[44]=G>>>0&255,l[45]=G>>>8&255,l[46]=G>>>16&255,l[47]=G>>>24&255,l[48]=Ne>>>0&255,l[49]=Ne>>>8&255,l[50]=Ne>>>16&255,l[51]=Ne>>>24&255,l[52]=Le>>>0&255,l[53]=Le>>>8&255,l[54]=Le>>>16&255,l[55]=Le>>>24&255,l[56]=Fe>>>0&255,l[57]=Fe>>>8&255,l[58]=Fe>>>16&255,l[59]=Fe>>>24&255,l[60]=He>>>0&255,l[61]=He>>>8&255,l[62]=He>>>16&255,l[63]=He>>>24&255}function P(l,y,p,a){for(var v=a[0]&255|(a[1]&255)<<8|(a[2]&255)<<16|(a[3]&255)<<24,h=p[0]&255|(p[1]&255)<<8|(p[2]&255)<<16|(p[3]&255)<<24,m=p[4]&255|(p[5]&255)<<8|(p[6]&255)<<16|(p[7]&255)<<24,S=p[8]&255|(p[9]&255)<<8|(p[10]&255)<<16|(p[11]&255)<<24,N=p[12]&255|(p[13]&255)<<8|(p[14]&255)<<16|(p[15]&255)<<24,W=a[4]&255|(a[5]&255)<<8|(a[6]&255)<<16|(a[7]&255)<<24,F=y[0]&255|(y[1]&255)<<8|(y[2]&255)<<16|(y[3]&255)<<24,ye=y[4]&255|(y[5]&255)<<8|(y[6]&255)<<16|(y[7]&255)<<24,L=y[8]&255|(y[9]&255)<<8|(y[10]&255)<<16|(y[11]&255)<<24,be=y[12]&255|(y[13]&255)<<8|(y[14]&255)<<16|(y[15]&255)<<24,ge=a[8]&255|(a[9]&255)<<8|(a[10]&255)<<16|(a[11]&255)<<24,xe=p[16]&255|(p[17]&255)<<8|(p[18]&255)<<16|(p[19]&255)<<24,Ce=p[20]&255|(p[21]&255)<<8|(p[22]&255)<<16|(p[23]&255)<<24,Be=p[24]&255|(p[25]&255)<<8|(p[26]&255)<<16|(p[27]&255)<<24,Oe=p[28]&255|(p[29]&255)<<8|(p[30]&255)<<16|(p[31]&255)<<24,_e=a[12]&255|(a[13]&255)<<8|(a[14]&255)<<16|(a[15]&255)<<24,fe=v,ke=h,se=m,we=S,Se=N,ne=W,B=F,O=ye,H=L,U=be,D=ge,G=xe,Ne=Ce,Le=Be,Fe=Oe,He=_e,x,Ye=0;Ye<20;Ye+=2)x=fe+Ne|0,Se^=x<<7|x>>>25,x=Se+fe|0,H^=x<<9|x>>>23,x=H+Se|0,Ne^=x<<13|x>>>19,x=Ne+H|0,fe^=x<<18|x>>>14,x=ne+ke|0,U^=x<<7|x>>>25,x=U+ne|0,Le^=x<<9|x>>>23,x=Le+U|0,ke^=x<<13|x>>>19,x=ke+Le|0,ne^=x<<18|x>>>14,x=D+B|0,Fe^=x<<7|x>>>25,x=Fe+D|0,se^=x<<9|x>>>23,x=se+Fe|0,B^=x<<13|x>>>19,x=B+se|0,D^=x<<18|x>>>14,x=He+G|0,we^=x<<7|x>>>25,x=we+He|0,O^=x<<9|x>>>23,x=O+we|0,G^=x<<13|x>>>19,x=G+O|0,He^=x<<18|x>>>14,x=fe+we|0,ke^=x<<7|x>>>25,x=ke+fe|0,se^=x<<9|x>>>23,x=se+ke|0,we^=x<<13|x>>>19,x=we+se|0,fe^=x<<18|x>>>14,x=ne+Se|0,B^=x<<7|x>>>25,x=B+ne|0,O^=x<<9|x>>>23,x=O+B|0,Se^=x<<13|x>>>19,x=Se+O|0,ne^=x<<18|x>>>14,x=D+U|0,G^=x<<7|x>>>25,x=G+D|0,H^=x<<9|x>>>23,x=H+G|0,U^=x<<13|x>>>19,x=U+H|0,D^=x<<18|x>>>14,x=He+Fe|0,Ne^=x<<7|x>>>25,x=Ne+He|0,Le^=x<<9|x>>>23,x=Le+Ne|0,Fe^=x<<13|x>>>19,x=Fe+Le|0,He^=x<<18|x>>>14;l[0]=fe>>>0&255,l[1]=fe>>>8&255,l[2]=fe>>>16&255,l[3]=fe>>>24&255,l[4]=ne>>>0&255,l[5]=ne>>>8&255,l[6]=ne>>>16&255,l[7]=ne>>>24&255,l[8]=D>>>0&255,l[9]=D>>>8&255,l[10]=D>>>16&255,l[11]=D>>>24&255,l[12]=He>>>0&255,l[13]=He>>>8&255,l[14]=He>>>16&255,l[15]=He>>>24&255,l[16]=B>>>0&255,l[17]=B>>>8&255,l[18]=B>>>16&255,l[19]=B>>>24&255,l[20]=O>>>0&255,l[21]=O>>>8&255,l[22]=O>>>16&255,l[23]=O>>>24&255,l[24]=H>>>0&255,l[25]=H>>>8&255,l[26]=H>>>16&255,l[27]=H>>>24&255,l[28]=U>>>0&255,l[29]=U>>>8&255,l[30]=U>>>16&255,l[31]=U>>>24&255}function K(l,y,p,a){R(l,y,p,a)}function de(l,y,p,a){P(l,y,p,a)}var le=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function pe(l,y,p,a,v,h,m){var S=new Uint8Array(16),N=new Uint8Array(64),W,F;for(F=0;F<16;F++)S[F]=0;for(F=0;F<8;F++)S[F]=h[F];for(;v>=64;){for(K(N,S,m,le),F=0;F<64;F++)l[y+F]=p[a+F]^N[F];for(W=1,F=8;F<16;F++)W=W+(S[F]&255)|0,S[F]=W&255,W>>>=8;v-=64,y+=64,a+=64}if(v>0)for(K(N,S,m,le),F=0;F<v;F++)l[y+F]=p[a+F]^N[F];return 0}function Re(l,y,p,a,v){var h=new Uint8Array(16),m=new Uint8Array(64),S,N;for(N=0;N<16;N++)h[N]=0;for(N=0;N<8;N++)h[N]=a[N];for(;p>=64;){for(K(m,h,v,le),N=0;N<64;N++)l[y+N]=m[N];for(S=1,N=8;N<16;N++)S=S+(h[N]&255)|0,h[N]=S&255,S>>>=8;p-=64,y+=64}if(p>0)for(K(m,h,v,le),N=0;N<p;N++)l[y+N]=m[N];return 0}function st(l,y,p,a,v){var h=new Uint8Array(32);de(h,a,v,le);for(var m=new Uint8Array(8),S=0;S<8;S++)m[S]=a[S+16];return Re(l,y,p,m,h)}function ht(l,y,p,a,v,h,m){var S=new Uint8Array(32);de(S,h,m,le);for(var N=new Uint8Array(8),W=0;W<8;W++)N[W]=h[W+16];return pe(l,y,p,a,v,N,S)}var _t=function(l){this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.leftover=0,this.fin=0;var y,p,a,v,h,m,S,N;y=l[0]&255|(l[1]&255)<<8,this.r[0]=y&8191,p=l[2]&255|(l[3]&255)<<8,this.r[1]=(y>>>13|p<<3)&8191,a=l[4]&255|(l[5]&255)<<8,this.r[2]=(p>>>10|a<<6)&7939,v=l[6]&255|(l[7]&255)<<8,this.r[3]=(a>>>7|v<<9)&8191,h=l[8]&255|(l[9]&255)<<8,this.r[4]=(v>>>4|h<<12)&255,this.r[5]=h>>>1&8190,m=l[10]&255|(l[11]&255)<<8,this.r[6]=(h>>>14|m<<2)&8191,S=l[12]&255|(l[13]&255)<<8,this.r[7]=(m>>>11|S<<5)&8065,N=l[14]&255|(l[15]&255)<<8,this.r[8]=(S>>>8|N<<8)&8191,this.r[9]=N>>>5&127,this.pad[0]=l[16]&255|(l[17]&255)<<8,this.pad[1]=l[18]&255|(l[19]&255)<<8,this.pad[2]=l[20]&255|(l[21]&255)<<8,this.pad[3]=l[22]&255|(l[23]&255)<<8,this.pad[4]=l[24]&255|(l[25]&255)<<8,this.pad[5]=l[26]&255|(l[27]&255)<<8,this.pad[6]=l[28]&255|(l[29]&255)<<8,this.pad[7]=l[30]&255|(l[31]&255)<<8};_t.prototype.blocks=function(l,y,p){for(var a=this.fin?0:2048,v,h,m,S,N,W,F,ye,L,be,ge,xe,Ce,Be,Oe,_e,fe,ke,se,we=this.h[0],Se=this.h[1],ne=this.h[2],B=this.h[3],O=this.h[4],H=this.h[5],U=this.h[6],D=this.h[7],G=this.h[8],Ne=this.h[9],Le=this.r[0],Fe=this.r[1],He=this.r[2],x=this.r[3],Ye=this.r[4],ut=this.r[5],ft=this.r[6],Ke=this.r[7],at=this.r[8],ct=this.r[9];p>=16;)v=l[y+0]&255|(l[y+1]&255)<<8,we+=v&8191,h=l[y+2]&255|(l[y+3]&255)<<8,Se+=(v>>>13|h<<3)&8191,m=l[y+4]&255|(l[y+5]&255)<<8,ne+=(h>>>10|m<<6)&8191,S=l[y+6]&255|(l[y+7]&255)<<8,B+=(m>>>7|S<<9)&8191,N=l[y+8]&255|(l[y+9]&255)<<8,O+=(S>>>4|N<<12)&8191,H+=N>>>1&8191,W=l[y+10]&255|(l[y+11]&255)<<8,U+=(N>>>14|W<<2)&8191,F=l[y+12]&255|(l[y+13]&255)<<8,D+=(W>>>11|F<<5)&8191,ye=l[y+14]&255|(l[y+15]&255)<<8,G+=(F>>>8|ye<<8)&8191,Ne+=ye>>>5|a,L=0,be=L,be+=we*Le,be+=Se*(5*ct),be+=ne*(5*at),be+=B*(5*Ke),be+=O*(5*ft),L=be>>>13,be&=8191,be+=H*(5*ut),be+=U*(5*Ye),be+=D*(5*x),be+=G*(5*He),be+=Ne*(5*Fe),L+=be>>>13,be&=8191,ge=L,ge+=we*Fe,ge+=Se*Le,ge+=ne*(5*ct),ge+=B*(5*at),ge+=O*(5*Ke),L=ge>>>13,ge&=8191,ge+=H*(5*ft),ge+=U*(5*ut),ge+=D*(5*Ye),ge+=G*(5*x),ge+=Ne*(5*He),L+=ge>>>13,ge&=8191,xe=L,xe+=we*He,xe+=Se*Fe,xe+=ne*Le,xe+=B*(5*ct),xe+=O*(5*at),L=xe>>>13,xe&=8191,xe+=H*(5*Ke),xe+=U*(5*ft),xe+=D*(5*ut),xe+=G*(5*Ye),xe+=Ne*(5*x),L+=xe>>>13,xe&=8191,Ce=L,Ce+=we*x,Ce+=Se*He,Ce+=ne*Fe,Ce+=B*Le,Ce+=O*(5*ct),L=Ce>>>13,Ce&=8191,Ce+=H*(5*at),Ce+=U*(5*Ke),Ce+=D*(5*ft),Ce+=G*(5*ut),Ce+=Ne*(5*Ye),L+=Ce>>>13,Ce&=8191,Be=L,Be+=we*Ye,Be+=Se*x,Be+=ne*He,Be+=B*Fe,Be+=O*Le,L=Be>>>13,Be&=8191,Be+=H*(5*ct),Be+=U*(5*at),Be+=D*(5*Ke),Be+=G*(5*ft),Be+=Ne*(5*ut),L+=Be>>>13,Be&=8191,Oe=L,Oe+=we*ut,Oe+=Se*Ye,Oe+=ne*x,Oe+=B*He,Oe+=O*Fe,L=Oe>>>13,Oe&=8191,Oe+=H*Le,Oe+=U*(5*ct),Oe+=D*(5*at),Oe+=G*(5*Ke),Oe+=Ne*(5*ft),L+=Oe>>>13,Oe&=8191,_e=L,_e+=we*ft,_e+=Se*ut,_e+=ne*Ye,_e+=B*x,_e+=O*He,L=_e>>>13,_e&=8191,_e+=H*Fe,_e+=U*Le,_e+=D*(5*ct),_e+=G*(5*at),_e+=Ne*(5*Ke),L+=_e>>>13,_e&=8191,fe=L,fe+=we*Ke,fe+=Se*ft,fe+=ne*ut,fe+=B*Ye,fe+=O*x,L=fe>>>13,fe&=8191,fe+=H*He,fe+=U*Fe,fe+=D*Le,fe+=G*(5*ct),fe+=Ne*(5*at),L+=fe>>>13,fe&=8191,ke=L,ke+=we*at,ke+=Se*Ke,ke+=ne*ft,ke+=B*ut,ke+=O*Ye,L=ke>>>13,ke&=8191,ke+=H*x,ke+=U*He,ke+=D*Fe,ke+=G*Le,ke+=Ne*(5*ct),L+=ke>>>13,ke&=8191,se=L,se+=we*ct,se+=Se*at,se+=ne*Ke,se+=B*ft,se+=O*ut,L=se>>>13,se&=8191,se+=H*Ye,se+=U*x,se+=D*He,se+=G*Fe,se+=Ne*Le,L+=se>>>13,se&=8191,L=(L<<2)+L|0,L=L+be|0,be=L&8191,L=L>>>13,ge+=L,we=be,Se=ge,ne=xe,B=Ce,O=Be,H=Oe,U=_e,D=fe,G=ke,Ne=se,y+=16,p-=16;this.h[0]=we,this.h[1]=Se,this.h[2]=ne,this.h[3]=B,this.h[4]=O,this.h[5]=H,this.h[6]=U,this.h[7]=D,this.h[8]=G,this.h[9]=Ne},_t.prototype.finish=function(l,y){var p=new Uint16Array(10),a,v,h,m;if(this.leftover){for(m=this.leftover,this.buffer[m++]=1;m<16;m++)this.buffer[m]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(a=this.h[1]>>>13,this.h[1]&=8191,m=2;m<10;m++)this.h[m]+=a,a=this.h[m]>>>13,this.h[m]&=8191;for(this.h[0]+=a*5,a=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=a,a=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=a,p[0]=this.h[0]+5,a=p[0]>>>13,p[0]&=8191,m=1;m<10;m++)p[m]=this.h[m]+a,a=p[m]>>>13,p[m]&=8191;for(p[9]-=8192,v=(a^1)-1,m=0;m<10;m++)p[m]&=v;for(v=~v,m=0;m<10;m++)this.h[m]=this.h[m]&v|p[m];for(this.h[0]=(this.h[0]|this.h[1]<<13)&65535,this.h[1]=(this.h[1]>>>3|this.h[2]<<10)&65535,this.h[2]=(this.h[2]>>>6|this.h[3]<<7)&65535,this.h[3]=(this.h[3]>>>9|this.h[4]<<4)&65535,this.h[4]=(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14)&65535,this.h[5]=(this.h[6]>>>2|this.h[7]<<11)&65535,this.h[6]=(this.h[7]>>>5|this.h[8]<<8)&65535,this.h[7]=(this.h[8]>>>8|this.h[9]<<5)&65535,h=this.h[0]+this.pad[0],this.h[0]=h&65535,m=1;m<8;m++)h=(this.h[m]+this.pad[m]|0)+(h>>>16)|0,this.h[m]=h&65535;l[y+0]=this.h[0]>>>0&255,l[y+1]=this.h[0]>>>8&255,l[y+2]=this.h[1]>>>0&255,l[y+3]=this.h[1]>>>8&255,l[y+4]=this.h[2]>>>0&255,l[y+5]=this.h[2]>>>8&255,l[y+6]=this.h[3]>>>0&255,l[y+7]=this.h[3]>>>8&255,l[y+8]=this.h[4]>>>0&255,l[y+9]=this.h[4]>>>8&255,l[y+10]=this.h[5]>>>0&255,l[y+11]=this.h[5]>>>8&255,l[y+12]=this.h[6]>>>0&255,l[y+13]=this.h[6]>>>8&255,l[y+14]=this.h[7]>>>0&255,l[y+15]=this.h[7]>>>8&255},_t.prototype.update=function(l,y,p){var a,v;if(this.leftover){for(v=16-this.leftover,v>p&&(v=p),a=0;a<v;a++)this.buffer[this.leftover+a]=l[y+a];if(p-=v,y+=v,this.leftover+=v,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(p>=16&&(v=p-p%16,this.blocks(l,y,v),y+=v,p-=v),p){for(a=0;a<p;a++)this.buffer[this.leftover+a]=l[y+a];this.leftover+=p}};function Et(l,y,p,a,v,h){var m=new _t(h);return m.update(p,a,v),m.finish(l,y),0}function lt(l,y,p,a,v,h){var m=new Uint8Array(16);return Et(m,0,p,a,v,h),T(l,y,m,0)}function pt(l,y,p,a,v){var h;if(p<32)return-1;for(ht(l,0,y,0,p,a,v),Et(l,16,l,32,p-32,l),h=0;h<16;h++)l[h]=0;return 0}function Xe(l,y,p,a,v){var h,m=new Uint8Array(32);if(p<32||(st(m,0,32,a,v),lt(y,16,y,32,p-32,m)!==0))return-1;for(ht(l,0,y,0,p,a,v),h=0;h<32;h++)l[h]=0;return 0}function ze(l,y){var p;for(p=0;p<16;p++)l[p]=y[p]|0}function oe(l){var y,p,a=1;for(y=0;y<16;y++)p=l[y]+a+65535,a=Math.floor(p/65536),l[y]=p-a*65536;l[0]+=a-1+37*(a-1)}function Te(l,y,p){for(var a,v=~(p-1),h=0;h<16;h++)a=v&(l[h]^y[h]),l[h]^=a,y[h]^=a}function dt(l,y){var p,a,v,h=t(),m=t();for(p=0;p<16;p++)m[p]=y[p];for(oe(m),oe(m),oe(m),a=0;a<2;a++){for(h[0]=m[0]-65517,p=1;p<15;p++)h[p]=m[p]-65535-(h[p-1]>>16&1),h[p-1]&=65535;h[15]=m[15]-32767-(h[14]>>16&1),v=h[15]>>16&1,h[14]&=65535,Te(m,h,1-v)}for(p=0;p<16;p++)l[2*p]=m[p]&255,l[2*p+1]=m[p]>>8}function It(l,y){var p=new Uint8Array(32),a=new Uint8Array(32);return dt(p,l),dt(a,y),I(p,0,a,0)}function Ct(l){var y=new Uint8Array(32);return dt(y,l),y[0]&1}function ue(l,y){var p;for(p=0;p<16;p++)l[p]=y[2*p]+(y[2*p+1]<<8);l[15]&=32767}function et(l,y,p){for(var a=0;a<16;a++)l[a]=y[a]+p[a]}function yt(l,y,p){for(var a=0;a<16;a++)l[a]=y[a]-p[a]}function ee(l,y,p){var a,v,h=0,m=0,S=0,N=0,W=0,F=0,ye=0,L=0,be=0,ge=0,xe=0,Ce=0,Be=0,Oe=0,_e=0,fe=0,ke=0,se=0,we=0,Se=0,ne=0,B=0,O=0,H=0,U=0,D=0,G=0,Ne=0,Le=0,Fe=0,He=0,x=p[0],Ye=p[1],ut=p[2],ft=p[3],Ke=p[4],at=p[5],ct=p[6],Lt=p[7],wt=p[8],Ut=p[9],Dt=p[10],$t=p[11],zt=p[12],nr=p[13],ir=p[14],sr=p[15];a=y[0],h+=a*x,m+=a*Ye,S+=a*ut,N+=a*ft,W+=a*Ke,F+=a*at,ye+=a*ct,L+=a*Lt,be+=a*wt,ge+=a*Ut,xe+=a*Dt,Ce+=a*$t,Be+=a*zt,Oe+=a*nr,_e+=a*ir,fe+=a*sr,a=y[1],m+=a*x,S+=a*Ye,N+=a*ut,W+=a*ft,F+=a*Ke,ye+=a*at,L+=a*ct,be+=a*Lt,ge+=a*wt,xe+=a*Ut,Ce+=a*Dt,Be+=a*$t,Oe+=a*zt,_e+=a*nr,fe+=a*ir,ke+=a*sr,a=y[2],S+=a*x,N+=a*Ye,W+=a*ut,F+=a*ft,ye+=a*Ke,L+=a*at,be+=a*ct,ge+=a*Lt,xe+=a*wt,Ce+=a*Ut,Be+=a*Dt,Oe+=a*$t,_e+=a*zt,fe+=a*nr,ke+=a*ir,se+=a*sr,a=y[3],N+=a*x,W+=a*Ye,F+=a*ut,ye+=a*ft,L+=a*Ke,be+=a*at,ge+=a*ct,xe+=a*Lt,Ce+=a*wt,Be+=a*Ut,Oe+=a*Dt,_e+=a*$t,fe+=a*zt,ke+=a*nr,se+=a*ir,we+=a*sr,a=y[4],W+=a*x,F+=a*Ye,ye+=a*ut,L+=a*ft,be+=a*Ke,ge+=a*at,xe+=a*ct,Ce+=a*Lt,Be+=a*wt,Oe+=a*Ut,_e+=a*Dt,fe+=a*$t,ke+=a*zt,se+=a*nr,we+=a*ir,Se+=a*sr,a=y[5],F+=a*x,ye+=a*Ye,L+=a*ut,be+=a*ft,ge+=a*Ke,xe+=a*at,Ce+=a*ct,Be+=a*Lt,Oe+=a*wt,_e+=a*Ut,fe+=a*Dt,ke+=a*$t,se+=a*zt,we+=a*nr,Se+=a*ir,ne+=a*sr,a=y[6],ye+=a*x,L+=a*Ye,be+=a*ut,ge+=a*ft,xe+=a*Ke,Ce+=a*at,Be+=a*ct,Oe+=a*Lt,_e+=a*wt,fe+=a*Ut,ke+=a*Dt,se+=a*$t,we+=a*zt,Se+=a*nr,ne+=a*ir,B+=a*sr,a=y[7],L+=a*x,be+=a*Ye,ge+=a*ut,xe+=a*ft,Ce+=a*Ke,Be+=a*at,Oe+=a*ct,_e+=a*Lt,fe+=a*wt,ke+=a*Ut,se+=a*Dt,we+=a*$t,Se+=a*zt,ne+=a*nr,B+=a*ir,O+=a*sr,a=y[8],be+=a*x,ge+=a*Ye,xe+=a*ut,Ce+=a*ft,Be+=a*Ke,Oe+=a*at,_e+=a*ct,fe+=a*Lt,ke+=a*wt,se+=a*Ut,we+=a*Dt,Se+=a*$t,ne+=a*zt,B+=a*nr,O+=a*ir,H+=a*sr,a=y[9],ge+=a*x,xe+=a*Ye,Ce+=a*ut,Be+=a*ft,Oe+=a*Ke,_e+=a*at,fe+=a*ct,ke+=a*Lt,se+=a*wt,we+=a*Ut,Se+=a*Dt,ne+=a*$t,B+=a*zt,O+=a*nr,H+=a*ir,U+=a*sr,a=y[10],xe+=a*x,Ce+=a*Ye,Be+=a*ut,Oe+=a*ft,_e+=a*Ke,fe+=a*at,ke+=a*ct,se+=a*Lt,we+=a*wt,Se+=a*Ut,ne+=a*Dt,B+=a*$t,O+=a*zt,H+=a*nr,U+=a*ir,D+=a*sr,a=y[11],Ce+=a*x,Be+=a*Ye,Oe+=a*ut,_e+=a*ft,fe+=a*Ke,ke+=a*at,se+=a*ct,we+=a*Lt,Se+=a*wt,ne+=a*Ut,B+=a*Dt,O+=a*$t,H+=a*zt,U+=a*nr,D+=a*ir,G+=a*sr,a=y[12],Be+=a*x,Oe+=a*Ye,_e+=a*ut,fe+=a*ft,ke+=a*Ke,se+=a*at,we+=a*ct,Se+=a*Lt,ne+=a*wt,B+=a*Ut,O+=a*Dt,H+=a*$t,U+=a*zt,D+=a*nr,G+=a*ir,Ne+=a*sr,a=y[13],Oe+=a*x,_e+=a*Ye,fe+=a*ut,ke+=a*ft,se+=a*Ke,we+=a*at,Se+=a*ct,ne+=a*Lt,B+=a*wt,O+=a*Ut,H+=a*Dt,U+=a*$t,D+=a*zt,G+=a*nr,Ne+=a*ir,Le+=a*sr,a=y[14],_e+=a*x,fe+=a*Ye,ke+=a*ut,se+=a*ft,we+=a*Ke,Se+=a*at,ne+=a*ct,B+=a*Lt,O+=a*wt,H+=a*Ut,U+=a*Dt,D+=a*$t,G+=a*zt,Ne+=a*nr,Le+=a*ir,Fe+=a*sr,a=y[15],fe+=a*x,ke+=a*Ye,se+=a*ut,we+=a*ft,Se+=a*Ke,ne+=a*at,B+=a*ct,O+=a*Lt,H+=a*wt,U+=a*Ut,D+=a*Dt,G+=a*$t,Ne+=a*zt,Le+=a*nr,Fe+=a*ir,He+=a*sr,h+=38*ke,m+=38*se,S+=38*we,N+=38*Se,W+=38*ne,F+=38*B,ye+=38*O,L+=38*H,be+=38*U,ge+=38*D,xe+=38*G,Ce+=38*Ne,Be+=38*Le,Oe+=38*Fe,_e+=38*He,v=1,a=h+v+65535,v=Math.floor(a/65536),h=a-v*65536,a=m+v+65535,v=Math.floor(a/65536),m=a-v*65536,a=S+v+65535,v=Math.floor(a/65536),S=a-v*65536,a=N+v+65535,v=Math.floor(a/65536),N=a-v*65536,a=W+v+65535,v=Math.floor(a/65536),W=a-v*65536,a=F+v+65535,v=Math.floor(a/65536),F=a-v*65536,a=ye+v+65535,v=Math.floor(a/65536),ye=a-v*65536,a=L+v+65535,v=Math.floor(a/65536),L=a-v*65536,a=be+v+65535,v=Math.floor(a/65536),be=a-v*65536,a=ge+v+65535,v=Math.floor(a/65536),ge=a-v*65536,a=xe+v+65535,v=Math.floor(a/65536),xe=a-v*65536,a=Ce+v+65535,v=Math.floor(a/65536),Ce=a-v*65536,a=Be+v+65535,v=Math.floor(a/65536),Be=a-v*65536,a=Oe+v+65535,v=Math.floor(a/65536),Oe=a-v*65536,a=_e+v+65535,v=Math.floor(a/65536),_e=a-v*65536,a=fe+v+65535,v=Math.floor(a/65536),fe=a-v*65536,h+=v-1+37*(v-1),v=1,a=h+v+65535,v=Math.floor(a/65536),h=a-v*65536,a=m+v+65535,v=Math.floor(a/65536),m=a-v*65536,a=S+v+65535,v=Math.floor(a/65536),S=a-v*65536,a=N+v+65535,v=Math.floor(a/65536),N=a-v*65536,a=W+v+65535,v=Math.floor(a/65536),W=a-v*65536,a=F+v+65535,v=Math.floor(a/65536),F=a-v*65536,a=ye+v+65535,v=Math.floor(a/65536),ye=a-v*65536,a=L+v+65535,v=Math.floor(a/65536),L=a-v*65536,a=be+v+65535,v=Math.floor(a/65536),be=a-v*65536,a=ge+v+65535,v=Math.floor(a/65536),ge=a-v*65536,a=xe+v+65535,v=Math.floor(a/65536),xe=a-v*65536,a=Ce+v+65535,v=Math.floor(a/65536),Ce=a-v*65536,a=Be+v+65535,v=Math.floor(a/65536),Be=a-v*65536,a=Oe+v+65535,v=Math.floor(a/65536),Oe=a-v*65536,a=_e+v+65535,v=Math.floor(a/65536),_e=a-v*65536,a=fe+v+65535,v=Math.floor(a/65536),fe=a-v*65536,h+=v-1+37*(v-1),l[0]=h,l[1]=m,l[2]=S,l[3]=N,l[4]=W,l[5]=F,l[6]=ye,l[7]=L,l[8]=be,l[9]=ge,l[10]=xe,l[11]=Ce,l[12]=Be,l[13]=Oe,l[14]=_e,l[15]=fe}function ot(l,y){ee(l,y,y)}function Bt(l,y){var p=t(),a;for(a=0;a<16;a++)p[a]=y[a];for(a=253;a>=0;a--)ot(p,p),a!==2&&a!==4&&ee(p,p,y);for(a=0;a<16;a++)l[a]=p[a]}function gn(l,y){var p=t(),a;for(a=0;a<16;a++)p[a]=y[a];for(a=250;a>=0;a--)ot(p,p),a!==1&&ee(p,p,y);for(a=0;a<16;a++)l[a]=p[a]}function vn(l,y,p){var a=new Uint8Array(32),v=new Float64Array(80),h,m,S=t(),N=t(),W=t(),F=t(),ye=t(),L=t();for(m=0;m<31;m++)a[m]=y[m];for(a[31]=y[31]&127|64,a[0]&=248,ue(v,p),m=0;m<16;m++)N[m]=v[m],F[m]=S[m]=W[m]=0;for(S[0]=F[0]=1,m=254;m>=0;--m)h=a[m>>>3]>>>(m&7)&1,Te(S,N,h),Te(W,F,h),et(ye,S,W),yt(S,S,W),et(W,N,F),yt(N,N,F),ot(F,ye),ot(L,S),ee(S,W,S),ee(W,N,ye),et(ye,S,W),yt(S,S,W),ot(N,S),yt(W,F,L),ee(S,W,u),et(S,S,F),ee(W,W,S),ee(S,F,L),ee(F,N,v),ot(N,ye),Te(S,N,h),Te(W,F,h);for(m=0;m<16;m++)v[m+16]=S[m],v[m+32]=W[m],v[m+48]=N[m],v[m+64]=F[m];var be=v.subarray(32),ge=v.subarray(16);return Bt(be,be),ee(ge,ge,be),dt(l,ge),0}function Ht(l,y){return vn(l,y,s)}function Vi(l,y){return n(y,32),Ht(l,y)}function Mr(l,y,p){var a=new Uint8Array(32);return vn(a,p,y),de(l,i,a,le)}var Li=pt,To=Xe;function mn(l,y,p,a,v,h){var m=new Uint8Array(32);return Mr(m,v,h),Li(l,y,p,a,m)}function wn(l,y,p,a,v,h){var m=new Uint8Array(32);return Mr(m,v,h),To(l,y,p,a,m)}var ai=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function ci(l,y,p,a){for(var v=new Int32Array(16),h=new Int32Array(16),m,S,N,W,F,ye,L,be,ge,xe,Ce,Be,Oe,_e,fe,ke,se,we,Se,ne,B,O,H,U,D,G,Ne=l[0],Le=l[1],Fe=l[2],He=l[3],x=l[4],Ye=l[5],ut=l[6],ft=l[7],Ke=y[0],at=y[1],ct=y[2],Lt=y[3],wt=y[4],Ut=y[5],Dt=y[6],$t=y[7],zt=0;a>=128;){for(Se=0;Se<16;Se++)ne=8*Se+zt,v[Se]=p[ne+0]<<24|p[ne+1]<<16|p[ne+2]<<8|p[ne+3],h[Se]=p[ne+4]<<24|p[ne+5]<<16|p[ne+6]<<8|p[ne+7];for(Se=0;Se<80;Se++)if(m=Ne,S=Le,N=Fe,W=He,F=x,ye=Ye,L=ut,be=ft,ge=Ke,xe=at,Ce=ct,Be=Lt,Oe=wt,_e=Ut,fe=Dt,ke=$t,B=ft,O=$t,H=O&65535,U=O>>>16,D=B&65535,G=B>>>16,B=(x>>>14|wt<<18)^(x>>>18|wt<<14)^(wt>>>9|x<<23),O=(wt>>>14|x<<18)^(wt>>>18|x<<14)^(x>>>9|wt<<23),H+=O&65535,U+=O>>>16,D+=B&65535,G+=B>>>16,B=x&Ye^~x&ut,O=wt&Ut^~wt&Dt,H+=O&65535,U+=O>>>16,D+=B&65535,G+=B>>>16,B=ai[Se*2],O=ai[Se*2+1],H+=O&65535,U+=O>>>16,D+=B&65535,G+=B>>>16,B=v[Se%16],O=h[Se%16],H+=O&65535,U+=O>>>16,D+=B&65535,G+=B>>>16,U+=H>>>16,D+=U>>>16,G+=D>>>16,se=D&65535|G<<16,we=H&65535|U<<16,B=se,O=we,H=O&65535,U=O>>>16,D=B&65535,G=B>>>16,B=(Ne>>>28|Ke<<4)^(Ke>>>2|Ne<<30)^(Ke>>>7|Ne<<25),O=(Ke>>>28|Ne<<4)^(Ne>>>2|Ke<<30)^(Ne>>>7|Ke<<25),H+=O&65535,U+=O>>>16,D+=B&65535,G+=B>>>16,B=Ne&Le^Ne&Fe^Le&Fe,O=Ke&at^Ke&ct^at&ct,H+=O&65535,U+=O>>>16,D+=B&65535,G+=B>>>16,U+=H>>>16,D+=U>>>16,G+=D>>>16,be=D&65535|G<<16,ke=H&65535|U<<16,B=W,O=Be,H=O&65535,U=O>>>16,D=B&65535,G=B>>>16,B=se,O=we,H+=O&65535,U+=O>>>16,D+=B&65535,G+=B>>>16,U+=H>>>16,D+=U>>>16,G+=D>>>16,W=D&65535|G<<16,Be=H&65535|U<<16,Le=m,Fe=S,He=N,x=W,Ye=F,ut=ye,ft=L,Ne=be,at=ge,ct=xe,Lt=Ce,wt=Be,Ut=Oe,Dt=_e,$t=fe,Ke=ke,Se%16===15)for(ne=0;ne<16;ne++)B=v[ne],O=h[ne],H=O&65535,U=O>>>16,D=B&65535,G=B>>>16,B=v[(ne+9)%16],O=h[(ne+9)%16],H+=O&65535,U+=O>>>16,D+=B&65535,G+=B>>>16,se=v[(ne+1)%16],we=h[(ne+1)%16],B=(se>>>1|we<<31)^(se>>>8|we<<24)^se>>>7,O=(we>>>1|se<<31)^(we>>>8|se<<24)^(we>>>7|se<<25),H+=O&65535,U+=O>>>16,D+=B&65535,G+=B>>>16,se=v[(ne+14)%16],we=h[(ne+14)%16],B=(se>>>19|we<<13)^(we>>>29|se<<3)^se>>>6,O=(we>>>19|se<<13)^(se>>>29|we<<3)^(we>>>6|se<<26),H+=O&65535,U+=O>>>16,D+=B&65535,G+=B>>>16,U+=H>>>16,D+=U>>>16,G+=D>>>16,v[ne]=D&65535|G<<16,h[ne]=H&65535|U<<16;B=Ne,O=Ke,H=O&65535,U=O>>>16,D=B&65535,G=B>>>16,B=l[0],O=y[0],H+=O&65535,U+=O>>>16,D+=B&65535,G+=B>>>16,U+=H>>>16,D+=U>>>16,G+=D>>>16,l[0]=Ne=D&65535|G<<16,y[0]=Ke=H&65535|U<<16,B=Le,O=at,H=O&65535,U=O>>>16,D=B&65535,G=B>>>16,B=l[1],O=y[1],H+=O&65535,U+=O>>>16,D+=B&65535,G+=B>>>16,U+=H>>>16,D+=U>>>16,G+=D>>>16,l[1]=Le=D&65535|G<<16,y[1]=at=H&65535|U<<16,B=Fe,O=ct,H=O&65535,U=O>>>16,D=B&65535,G=B>>>16,B=l[2],O=y[2],H+=O&65535,U+=O>>>16,D+=B&65535,G+=B>>>16,U+=H>>>16,D+=U>>>16,G+=D>>>16,l[2]=Fe=D&65535|G<<16,y[2]=ct=H&65535|U<<16,B=He,O=Lt,H=O&65535,U=O>>>16,D=B&65535,G=B>>>16,B=l[3],O=y[3],H+=O&65535,U+=O>>>16,D+=B&65535,G+=B>>>16,U+=H>>>16,D+=U>>>16,G+=D>>>16,l[3]=He=D&65535|G<<16,y[3]=Lt=H&65535|U<<16,B=x,O=wt,H=O&65535,U=O>>>16,D=B&65535,G=B>>>16,B=l[4],O=y[4],H+=O&65535,U+=O>>>16,D+=B&65535,G+=B>>>16,U+=H>>>16,D+=U>>>16,G+=D>>>16,l[4]=x=D&65535|G<<16,y[4]=wt=H&65535|U<<16,B=Ye,O=Ut,H=O&65535,U=O>>>16,D=B&65535,G=B>>>16,B=l[5],O=y[5],H+=O&65535,U+=O>>>16,D+=B&65535,G+=B>>>16,U+=H>>>16,D+=U>>>16,G+=D>>>16,l[5]=Ye=D&65535|G<<16,y[5]=Ut=H&65535|U<<16,B=ut,O=Dt,H=O&65535,U=O>>>16,D=B&65535,G=B>>>16,B=l[6],O=y[6],H+=O&65535,U+=O>>>16,D+=B&65535,G+=B>>>16,U+=H>>>16,D+=U>>>16,G+=D>>>16,l[6]=ut=D&65535|G<<16,y[6]=Dt=H&65535|U<<16,B=ft,O=$t,H=O&65535,U=O>>>16,D=B&65535,G=B>>>16,B=l[7],O=y[7],H+=O&65535,U+=O>>>16,D+=B&65535,G+=B>>>16,U+=H>>>16,D+=U>>>16,G+=D>>>16,l[7]=ft=D&65535|G<<16,y[7]=$t=H&65535|U<<16,zt+=128,a-=128}return a}function hr(l,y,p){var a=new Int32Array(8),v=new Int32Array(8),h=new Uint8Array(256),m,S=p;for(a[0]=1779033703,a[1]=3144134277,a[2]=1013904242,a[3]=2773480762,a[4]=1359893119,a[5]=2600822924,a[6]=528734635,a[7]=1541459225,v[0]=4089235720,v[1]=2227873595,v[2]=4271175723,v[3]=1595750129,v[4]=2917565137,v[5]=725511199,v[6]=4215389547,v[7]=327033209,ci(a,v,y,p),p%=128,m=0;m<p;m++)h[m]=y[S-p+m];for(h[p]=128,p=256-128*(p<112?1:0),h[p-9]=0,w(h,p-8,S/536870912|0,S<<3),ci(a,v,h,p),m=0;m<8;m++)w(l,8*m,a[m],v[m]);return 0}function Dn(l,y){var p=t(),a=t(),v=t(),h=t(),m=t(),S=t(),N=t(),W=t(),F=t();yt(p,l[1],l[0]),yt(F,y[1],y[0]),ee(p,p,F),et(a,l[0],l[1]),et(F,y[0],y[1]),ee(a,a,F),ee(v,l[3],y[3]),ee(v,v,b),ee(h,l[2],y[2]),et(h,h,h),yt(m,a,p),yt(S,h,v),et(N,h,v),et(W,a,p),ee(l[0],m,S),ee(l[1],W,N),ee(l[2],N,S),ee(l[3],m,W)}function li(l,y,p){var a;for(a=0;a<4;a++)Te(l[a],y[a],p)}function $n(l,y){var p=t(),a=t(),v=t();Bt(v,y[2]),ee(p,y[0],v),ee(a,y[1],v),dt(l,a),l[31]^=Ct(p)<<7}function Hi(l,y,p){var a,v;for(ze(l[0],o),ze(l[1],c),ze(l[2],c),ze(l[3],o),v=255;v>=0;--v)a=p[v/8|0]>>(v&7)&1,li(l,y,a),Dn(y,l),Dn(l,l),li(l,y,a)}function ui(l,y){var p=[t(),t(),t(),t()];ze(p[0],E),ze(p[1],Y),ze(p[2],c),ee(p[3],E,Y),Hi(l,p,y)}function fi(l,y,p){var a=new Uint8Array(64),v=[t(),t(),t(),t()],h;for(p||n(y,32),hr(a,y,32),a[0]&=248,a[31]&=127,a[31]|=64,ui(v,a),$n(l,v),h=0;h<32;h++)y[h+32]=l[h];return 0}var Br=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function Qr(l,y){var p,a,v,h;for(a=63;a>=32;--a){for(p=0,v=a-32,h=a-12;v<h;++v)y[v]+=p-16*y[a]*Br[v-(a-32)],p=Math.floor((y[v]+128)/256),y[v]-=p*256;y[v]+=p,y[a]=0}for(p=0,v=0;v<32;v++)y[v]+=p-(y[31]>>4)*Br[v],p=y[v]>>8,y[v]&=255;for(v=0;v<32;v++)y[v]-=p*Br[v];for(a=0;a<32;a++)y[a+1]+=y[a]>>8,l[a]=y[a]&255}function Fi(l){var y=new Float64Array(64),p;for(p=0;p<64;p++)y[p]=l[p];for(p=0;p<64;p++)l[p]=0;Qr(l,y)}function Gi(l,y,p,a){var v=new Uint8Array(64),h=new Uint8Array(64),m=new Uint8Array(64),S,N,W=new Float64Array(64),F=[t(),t(),t(),t()];hr(v,a,32),v[0]&=248,v[31]&=127,v[31]|=64;var ye=p+64;for(S=0;S<p;S++)l[64+S]=y[S];for(S=0;S<32;S++)l[32+S]=v[32+S];for(hr(m,l.subarray(32),p+32),Fi(m),ui(F,m),$n(l,F),S=32;S<64;S++)l[S]=a[S];for(hr(h,l,p+64),Fi(h),S=0;S<64;S++)W[S]=0;for(S=0;S<32;S++)W[S]=m[S];for(S=0;S<32;S++)for(N=0;N<32;N++)W[S+N]+=h[S]*v[N];return Qr(l.subarray(32),W),ye}function hi(l,y){var p=t(),a=t(),v=t(),h=t(),m=t(),S=t(),N=t();return ze(l[2],c),ue(l[1],y),ot(v,l[1]),ee(h,v,d),yt(v,v,l[2]),et(h,l[2],h),ot(m,h),ot(S,m),ee(N,S,m),ee(p,N,v),ee(p,p,h),gn(p,p),ee(p,p,v),ee(p,p,h),ee(p,p,h),ee(l[0],p,h),ot(a,l[0]),ee(a,a,h),It(a,v)&&ee(l[0],l[0],$),ot(a,l[0]),ee(a,a,h),It(a,v)?-1:(Ct(l[0])===y[31]>>7&&yt(l[0],o,l[0]),ee(l[3],l[0],l[1]),0)}function k(l,y,p,a){var v,h=new Uint8Array(32),m=new Uint8Array(64),S=[t(),t(),t(),t()],N=[t(),t(),t(),t()];if(p<64||hi(N,a))return-1;for(v=0;v<p;v++)l[v]=y[v];for(v=0;v<32;v++)l[v+32]=a[v];if(hr(m,l,p),Fi(m),Hi(S,N,m),ui(N,y.subarray(32)),Dn(S,N),$n(h,S),p-=64,I(y,0,h,0)){for(v=0;v<p;v++)l[v]=0;return-1}for(v=0;v<p;v++)l[v]=y[v+64];return p}var C=32,j=24,q=32,Ee=16,xt=32,At=32,Ue=32,X=32,te=32,re=j,me=q,Ve=Ee,Qe=64,gt=32,Vt=64,di=32,pi=64;e.lowlevel={crypto_core_hsalsa20:de,crypto_stream_xor:ht,crypto_stream:st,crypto_stream_salsa20_xor:pe,crypto_stream_salsa20:Re,crypto_onetimeauth:Et,crypto_onetimeauth_verify:lt,crypto_verify_16:T,crypto_verify_32:I,crypto_secretbox:pt,crypto_secretbox_open:Xe,crypto_scalarmult:vn,crypto_scalarmult_base:Ht,crypto_box_beforenm:Mr,crypto_box_afternm:Li,crypto_box:mn,crypto_box_open:wn,crypto_box_keypair:Vi,crypto_hash:hr,crypto_sign:Gi,crypto_sign_keypair:fi,crypto_sign_open:k,crypto_secretbox_KEYBYTES:C,crypto_secretbox_NONCEBYTES:j,crypto_secretbox_ZEROBYTES:q,crypto_secretbox_BOXZEROBYTES:Ee,crypto_scalarmult_BYTES:xt,crypto_scalarmult_SCALARBYTES:At,crypto_box_PUBLICKEYBYTES:Ue,crypto_box_SECRETKEYBYTES:X,crypto_box_BEFORENMBYTES:te,crypto_box_NONCEBYTES:re,crypto_box_ZEROBYTES:me,crypto_box_BOXZEROBYTES:Ve,crypto_sign_BYTES:Qe,crypto_sign_PUBLICKEYBYTES:gt,crypto_sign_SECRETKEYBYTES:Vt,crypto_sign_SEEDBYTES:di,crypto_hash_BYTES:pi,gf:t,D:d,L:Br,pack25519:dt,unpack25519:ue,M:ee,A:et,S:ot,Z:yt,pow2523:gn,add:Dn,set25519:ze,modL:Qr,scalarmult:Hi,scalarbase:ui};function zi(l,y){if(l.length!==C)throw new Error("bad key size");if(y.length!==j)throw new Error("bad nonce size")}function Sf(l,y){if(l.length!==Ue)throw new Error("bad public key size");if(y.length!==X)throw new Error("bad secret key size")}function dr(){for(var l=0;l<arguments.length;l++)if(!(arguments[l]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}function No(l){for(var y=0;y<l.length;y++)l[y]=0}e.randomBytes=function(l){var y=new Uint8Array(l);return n(y,l),y},e.secretbox=function(l,y,p){dr(l,y,p),zi(p,y);for(var a=new Uint8Array(q+l.length),v=new Uint8Array(a.length),h=0;h<l.length;h++)a[h+q]=l[h];return pt(v,a,a.length,y,p),v.subarray(Ee)},e.secretbox.open=function(l,y,p){dr(l,y,p),zi(p,y);for(var a=new Uint8Array(Ee+l.length),v=new Uint8Array(a.length),h=0;h<l.length;h++)a[h+Ee]=l[h];return a.length<32||Xe(v,a,a.length,y,p)!==0?null:v.subarray(q)},e.secretbox.keyLength=C,e.secretbox.nonceLength=j,e.secretbox.overheadLength=Ee,e.scalarMult=function(l,y){if(dr(l,y),l.length!==At)throw new Error("bad n size");if(y.length!==xt)throw new Error("bad p size");var p=new Uint8Array(xt);return vn(p,l,y),p},e.scalarMult.base=function(l){if(dr(l),l.length!==At)throw new Error("bad n size");var y=new Uint8Array(xt);return Ht(y,l),y},e.scalarMult.scalarLength=At,e.scalarMult.groupElementLength=xt,e.box=function(l,y,p,a){var v=e.box.before(p,a);return e.secretbox(l,y,v)},e.box.before=function(l,y){dr(l,y),Sf(l,y);var p=new Uint8Array(te);return Mr(p,l,y),p},e.box.after=e.secretbox,e.box.open=function(l,y,p,a){var v=e.box.before(p,a);return e.secretbox.open(l,y,v)},e.box.open.after=e.secretbox.open,e.box.keyPair=function(){var l=new Uint8Array(Ue),y=new Uint8Array(X);return Vi(l,y),{publicKey:l,secretKey:y}},e.box.keyPair.fromSecretKey=function(l){if(dr(l),l.length!==X)throw new Error("bad secret key size");var y=new Uint8Array(Ue);return Ht(y,l),{publicKey:y,secretKey:new Uint8Array(l)}},e.box.publicKeyLength=Ue,e.box.secretKeyLength=X,e.box.sharedKeyLength=te,e.box.nonceLength=re,e.box.overheadLength=e.secretbox.overheadLength,e.sign=function(l,y){if(dr(l,y),y.length!==Vt)throw new Error("bad secret key size");var p=new Uint8Array(Qe+l.length);return Gi(p,l,l.length,y),p},e.sign.open=function(l,y){if(dr(l,y),y.length!==gt)throw new Error("bad public key size");var p=new Uint8Array(l.length),a=k(p,l,l.length,y);if(a<0)return null;for(var v=new Uint8Array(a),h=0;h<v.length;h++)v[h]=p[h];return v},e.sign.detached=function(l,y){for(var p=e.sign(l,y),a=new Uint8Array(Qe),v=0;v<a.length;v++)a[v]=p[v];return a},e.sign.detached.verify=function(l,y,p){if(dr(l,y,p),y.length!==Qe)throw new Error("bad signature size");if(p.length!==gt)throw new Error("bad public key size");var a=new Uint8Array(Qe+l.length),v=new Uint8Array(Qe+l.length),h;for(h=0;h<Qe;h++)a[h]=y[h];for(h=0;h<l.length;h++)a[h+Qe]=l[h];return k(v,a,a.length,p)>=0},e.sign.keyPair=function(){var l=new Uint8Array(gt),y=new Uint8Array(Vt);return fi(l,y),{publicKey:l,secretKey:y}},e.sign.keyPair.fromSecretKey=function(l){if(dr(l),l.length!==Vt)throw new Error("bad secret key size");for(var y=new Uint8Array(gt),p=0;p<y.length;p++)y[p]=l[32+p];return{publicKey:y,secretKey:new Uint8Array(l)}},e.sign.keyPair.fromSeed=function(l){if(dr(l),l.length!==di)throw new Error("bad seed size");for(var y=new Uint8Array(gt),p=new Uint8Array(Vt),a=0;a<32;a++)p[a]=l[a];return fi(y,p,!0),{publicKey:y,secretKey:p}},e.sign.publicKeyLength=gt,e.sign.secretKeyLength=Vt,e.sign.seedLength=di,e.sign.signatureLength=Qe,e.hash=function(l){dr(l);var y=new Uint8Array(pi);return hr(y,l,l.length),y},e.hash.hashLength=pi,e.verify=function(l,y){return dr(l,y),l.length===0||y.length===0||l.length!==y.length?!1:_(l,0,y,0,l.length)===0},e.setPRNG=function(l){n=l},function(){var l=typeof self<"u"?self.crypto||self.msCrypto:null;if(l&&l.getRandomValues){var y=65536;e.setPRNG(function(p,a){var v,h=new Uint8Array(a);for(v=0;v<a;v+=y)l.getRandomValues(h.subarray(v,v+Math.min(a-v,y)));for(v=0;v<a;v++)p[v]=h[v];No(h)})}else typeof H1<"u"&&(l=F1,l&&l.randomBytes&&e.setPRNG(function(p,a){var v,h=l.randomBytes(a);for(v=0;v<a;v++)p[v]=h[v];No(h)}))}()})(r.exports?r.exports:self.nacl=self.nacl||{})})(O0);var G1=O0.exports;const T0=Wi(G1);function z1(){return T0.box.keyPair()}async function Bo(r){const e=sessionStorage.getItem("sessionKey"),t=sessionStorage.getItem("sessionId");console.groupCollapsed("Attestation");try{if(e&&t&&!r){const s=Cs(e);return console.log("Using existing attestation from session storage."),{sessionKey:s,sessionId:t}}const n=window.crypto.randomUUID();console.log("Generated attestation nonce:",n);const i=await L1(n);if(i&&i.public_key){console.log("Attestation document verification succeeded");const s=z1();console.log("Generated client key pair");const o=new Uint8Array(i.public_key),{encrypted_session_key:c,session_id:u}=await em(Vr(s.publicKey),n);console.log("Key exchange completed.");const d=T0.scalarMult(s.secretKey,o),b=Cs(c),E=12,Y=b.slice(0,E),$=b.slice(E),_=new Hc(d).open(Y,$);if(_)return console.log("Session key decrypted successfully"),window.sessionStorage.setItem("sessionKey",Vr(_)),window.sessionStorage.setItem("sessionId",u),{sessionKey:_,sessionId:u};throw new Error("Failed to decrypt session key")}else throw new Error("Invalid attestation document")}catch(n){throw console.error("Error verifying attestation:",n),n}finally{console.groupEnd()}}async function Dr(r,e,t,n){const i=async(s=!1)=>{try{s&&(console.log("Refreshing access token"),await Rc());const o=window.localStorage.getItem("access_token");if(!o)throw new Error("No access token available");const c=await N0(r,e,t,o,n);if(c.status===401&&!s)return console.log("Received 401, attempting to refresh token"),i(!0);if(c.error)throw new Error(c.error);if(!c.data)throw new Error("No data received from the server");return c.data}catch(o){throw console.error(o),o}};return i()}async function N0(r,e,t,n,i){let{sessionKey:s,sessionId:o}=await Bo();const c=async(d,b=!1)=>{if(b||!s||!o){const T=await Bo(!0);s=T.sessionKey,o=T.sessionId}if(!s||!o)throw new Error("Failed to make encrypted API call, no attestation available.");const E=t?JSON.stringify(t):void 0,Y=E?jf(s,E):void 0,$={"Content-Type":"application/json","x-session-id":o};d&&($.Authorization=`Bearer ${d}`);const w=await fetch(r,{method:e,headers:$,body:Y?JSON.stringify({encrypted:Y}):void 0}),_={status:w.status};if(w.ok)try{const T=await w.json(),I=Pf(s,T.encrypted);_.data=JSON.parse(I)}catch(T){console.error("Error decrypting or parsing response:",T),_.status=500,_.error="Failed to decrypt or parse the response"}else try{const T=await w.json();_.error=T.message||i||`HTTP error! Status: ${w.status}`}catch{_.error=i||`HTTP error! Status: ${w.status}`}return _},u=async(d,b=!1)=>{var E;try{const Y=await c(d,b);return(Y.status===400||(E=Y.error)!=null&&E.includes("Encryption error"))&&!b?(console.log("Encryption error or Bad Request, attempting to renew attestation"),u(d,!0)):Y}catch(Y){return{status:500,error:Y instanceof Error?Y.message:"Unknown error occurred"}}};return u(n)}async function Ir(r,e,t,n,i){const s=await N0(r,e,t,n,i);if(s.error)throw new Error(s.error);if(!s.data)throw new Error("No data received from the server");return s.data}let mt="http://localhost:3000";console.log("API_URL:",mt);function K1(r){mt=r}async function Z1(r,e){return Ir(`${mt}/login`,"POST",{email:r,password:e})}async function W1(r,e){return Ir(`${mt}/login`,"POST",{id:r,password:e})}async function q1(r,e,t,n){return Ir(`${mt}/register`,"POST",{email:r,password:e,inviteCode:t.toLowerCase(),name:n})}async function Y1(r,e){return Ir(`${mt}/register`,"POST",{password:r,inviteCode:e.toLowerCase()})}async function Rc(){const r=window.localStorage.getItem("refresh_token");if(!r)throw new Error("No refresh token available");const e={refresh_token:r};try{const t=await Ir(`${mt}/refresh`,"POST",e,void 0,"Failed to refresh token");return window.localStorage.setItem("access_token",t.access_token),window.localStorage.setItem("refresh_token",t.refresh_token),t}catch(t){throw console.error("Error refreshing token:",t),t}}async function J1(){return Dr(`${mt}/protected/user`,"GET",void 0,"Failed to fetch user")}async function R0(r,e){return Dr(`${mt}/protected/kv/${r}`,"PUT",e,"Failed to put key-value pair")}async function j0(r){return Dr(`${mt}/protected/kv/${r}`,"DELETE",void 0,"Failed to delete key-value pair")}async function P0(r){try{return await Dr(`${mt}/protected/kv/${r}`,"GET",void 0,"Failed to get key-value pair")}catch(e){console.error(`Error fetching key "${r}":`,e);return}}async function U0(){return Dr(`${mt}/protected/kv`,"GET",void 0,"Failed to list key-value pairs")}async function X1(r){const e={refresh_token:r};return Ir(`${mt}/logout`,"POST",e)}async function D0(r){return Ir(`${mt}/verify-email/${r}`,"GET",void 0,void 0,"Failed to verify email")}async function jc(){return Dr(`${mt}/protected/request_verification`,"POST",void 0,"Failed to request new verification code")}async function Q1(r){const e=await fetch(`${mt}/attestation/${r}`);if(!e.ok)throw new Error(`Request failed with status ${e.status}`);return(await e.json()).attestation_document}async function em(r,e){const t=await fetch(`${mt}/key_exchange`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_public_key:r,nonce:e})});if(!t.ok)throw new Error("Key exchange failed");return t.json()}async function $0(r,e){const t={email:r,hashed_secret:e};return Ir(`${mt}/password-reset/request`,"POST",t,void 0,"Failed to request password reset")}async function M0(r,e,t,n){const i={email:r,alphanumeric_code:e,plaintext_secret:t,new_password:n};return Ir(`${mt}/password-reset/confirm`,"POST",i,void 0,"Failed to confirm password reset")}async function V0(r,e){const t={current_password:r,new_password:e};return Dr(`${mt}/protected/change_password`,"POST",t,"Failed to change password")}async function tm(r){try{return await Ir(`${mt}/auth/github`,"POST",r?{invite_code:r}:{},void 0,"Failed to initiate GitHub auth")}catch(e){throw e instanceof Error&&e.message.includes("Invalid invite code")?new Error("Invalid invite code. Please check and try again."):e}}async function rm(r,e,t){const n={code:r,state:e,invite_code:t};try{return await Ir(`${mt}/auth/github/callback`,"POST",n,void 0,"GitHub callback failed")}catch(i){throw console.error("Detailed GitHub callback error:",i),i instanceof Error?i.message.includes("User exists")||i.message.includes("Email already registered")?new Error("An account with this email already exists. Please sign in using your existing account."):i.message.includes("Invalid invite code")?new Error("Invalid invite code. Please try signing up with a valid invite code."):i.message.includes("User not found")?new Error("User not found. Please sign up first before attempting to log in with GitHub."):new Error("Failed to authenticate with GitHub. Please try again."):i}}async function nm(r){try{return await Ir(`${mt}/auth/google`,"POST",r?{invite_code:r}:{},void 0,"Failed to initiate Google auth")}catch(e){throw e instanceof Error&&e.message.includes("Invalid invite code")?new Error("Invalid invite code. Please check and try again."):e}}async function im(r,e,t){const n={code:r,state:e,invite_code:t};try{return await Ir(`${mt}/auth/google/callback`,"POST",n,void 0,"Google callback failed")}catch(i){throw console.error("Detailed Google callback error:",i),i instanceof Error?i.message.includes("User exists")||i.message.includes("Email already registered")?new Error("An account with this email already exists. Please sign in using your existing account."):i.message.includes("Invalid invite code")?new Error("Invalid invite code. Please try signing up with a valid invite code."):i.message.includes("User not found")?new Error("User not found. Please sign up first before attempting to log in with Google."):new Error("Failed to authenticate with Google. Please try again."):i}}async function L0(){return Dr(`${mt}/protected/private_key`,"GET",void 0,"Failed to fetch private key")}async function H0(r,e){const t=Vr(r);return Dr(`${mt}/protected/sign_message`,"POST",{message_base64:t,algorithm:e},"Failed to sign message")}async function F0(r){return Dr(`${mt}/protected/public_key?algorithm=${r}`,"GET",void 0,"Failed to fetch public key")}async function sm(r,e,t){const n={email:r,password:e,name:t};return Dr(`${mt}/protected/convert_guest`,"POST",n,"Failed to convert guest account")}async function om(r){return Dr(`${mt}/protected/third_party_token`,"POST",{audience:r},"Failed to generate third party token")}function am(){return async(r,e)=>{var n,i;const t=()=>{const s=window.localStorage.getItem("access_token");if(!s)throw new Error("No access token available");return`Bearer ${s}`};try{const s=new Headers(e==null?void 0:e.headers);s.set("Authorization",t());const{sessionKey:o,sessionId:c}=await Bo();if(!o||!c)throw new Error("No session key or ID available");s.set("x-session-id",c);const u={...e,headers:s};if(e!=null&&e.body){const b=jf(o,e.body);u.body=JSON.stringify({encrypted:b}),s.set("Content-Type","application/json")}let d=await fetch(r,u);if(d.status===401&&(console.warn("Unauthorized, refreshing access token"),await Rc(),s.set("Authorization",t()),u.headers=s,d=await fetch(r,u)),!d.ok){const b=await d.text();throw console.error("Request failed with response status:",d.status," and message:",b),new Error(`Request failed with status ${d.status}: ${b}`)}if((n=d.headers.get("content-type"))!=null&&n.includes("text/event-stream")){const b=(i=d.body)==null?void 0:i.getReader(),E=new TextDecoder;let Y="";const $=new ReadableStream({async start(w){for(;;){const{done:_,value:T}=await b.read();if(_)break;const I=E.decode(T);Y+=I;let R;for(;R=cm(Y);)if(Y=Y.slice(R.length),R.trim().startsWith("data: ")){const P=R.slice(6).trim();if(P==="[DONE]")w.enqueue(`data: [DONE]
155
155
 
156
156
  `);else try{console.groupCollapsed("Decrypting chunk"),console.log("Attempting to decrypt, data length:",P.length);const K=Pf(o,P);console.log("Decrypted data length:",K.length),console.log("Decrypted data:",K);try{const de=JSON.parse(K);console.log("Parsed JSON:",de),w.enqueue(`data: ${JSON.stringify(de)}
157
157
 
158
158
  `)}catch(de){de instanceof SyntaxError&&(console.log("Failed to parse JSON:",K),w.enqueue(`data: ${K}
159
159
 
160
- `))}}catch(K){console.error("Decryption error:",K,"Data:",P),console.log("Skipping corrupted chunk")}finally{console.groupEnd()}}}w.close()}});return new Response($,{headers:d.headers,status:d.status,statusText:d.statusText})}return d}catch(s){throw console.error("Error during fetch process:",s),s}}}function am(r){const e=r.indexOf(`
160
+ `))}}catch(K){console.error("Decryption error:",K,"Data:",P),console.log("Skipping corrupted chunk")}finally{console.groupEnd()}}}w.close()}});return new Response($,{headers:d.headers,status:d.status,statusText:d.statusText})}return d}catch(s){throw console.error("Error during fetch process:",s),s}}}function cm(r){const e=r.indexOf(`
161
161
 
162
- `);return e===-1?null:r.slice(0,e+2)}const cm=["eeddbb58f57c38894d6d5af5e575fbe791c5bf3bbcfb5df8da8cfcf0c2e1da1913108e6a762112444740b88c163d7f4b","74ed417f88cb0ca76c4a3d10f278bd010f1d3f95eafb254d4732511bb50e404507a4049b779c5230137e4091a5582271","9043fcab93b972d3c14ad2dc8fa78ca7ad374fc937c02435681772a003f7a72876bc4d578089b5c4cf3fe9b480f1aabb","52c3595b151d93d8b159c257301bfd5aa6f49210de0c55a6cd6df5ebeee44e4206cab950500f5d188f7fa14e6d900b75","91cb67311e910cce68cd5b7d0de77aa40610d87c6681439b44c46c3ff786ae643956ab2c812478a1da8745b259f07a45","859065ac81b81d3735130ba08b8af72a7256b603fefb74faabae25ed28cca6edcaa7c10ea32b5948d675c18a9b0f2b1d","acd82a7d3943e23e95a9dc3ce0b0107ea358d6287f9e3afa245622f7c7e3e0a66142a928b6efcc02f594a95366d3a99d"],lm=["62c0407056217a4c10764ed9045694c29fa93255d3cc04c2f989cdd9a1f8050c8b169714c71f1118ebce2fcc9951d1a9","cb95519905443f9f66f05f63c548b61ad1561a27fd5717b69285861aaea3c3063fe12a2571773b67fea3c6c11b4d8ec6","deb5895831b5e4286f5a2dcf5e9c27383821446f8df2b465f141d10743599be20ba3bb381ce063bf7139cc89f7f61d4c","70ba26c6af1ec3b57ce80e1adcc0ee96d70224d4c7a078f427895cdf68e1c30f09b5ac4c456588d872f3f21ff77c036b","669404ea71435b8f498b48db7816a5c2ab1d258b1a77685b11d84d15a73189504d79c4dee13a658de9f4a0cbfc39cfe8","a791bf92c25ffdfd372660e460a0e238c6778c090672df6509ae4bc065cf8668b6baac6b6a11d554af53ee0ff0172ad5","c4285443b87b9b12a6cea3bef1064ec060f652b235a297095975af8f134e5ed65f92d70d4616fdec80af9dff48bb9f35"];function um(r,e){const t=[...(e==null?void 0:e.pcr0Values)||[],...cm],n=[...(e==null?void 0:e.pcr0DevValues)||[],...lm];return t.includes(r)?{isMatch:!0,text:"PCR0 matches a known good value"}:n.includes(r)?{isMatch:!0,text:"PCR0 matches development enclave"}:{isMatch:!1,text:"PCR0 does not match a known good value"}}const bf=Tc,G0="641a0321a3e244efe456463195d606317ed7cdcc3c1756e09893f3c68f79bb5b";function z0(r){return Array.from(r).map(e=>e.toString(16).padStart(2,"0")).join("")}async function fm(r){const e=await crypto.subtle.digest("SHA-256",r);return z0(new Uint8Array(e))}async function xf(r,e,t){console.log("Raw timestamp:",r.timestamp),console.log("Date object:",new Date(r.timestamp));const n=Array.from(r.pcrs.entries()).map(([b,E])=>({id:b,value:z0(E)})).filter(b=>!b.value.match(/^0+$/)),i=n.find(b=>b.id===0),s=i?um(i.value,t):null,o=[...e,r.certificate].map(b=>{const E=new ji(b);return{subject:E.subject,notBefore:E.notBefore.toLocaleString(),notAfter:E.notAfter.toLocaleString(),pem:E.toString("pem"),isRoot:E.subject==="C=US, O=Amazon, OU=AWS, CN=aws.nitro-enclaves"}}),c=new TextDecoder,u=new ji(e[0]),d=await fm(u.rawData);return{moduleId:r.module_id,publicKey:r.public_key?Vr(r.public_key):null,timestamp:new Date(r.timestamp).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZoneName:"short"}),digest:r.digest,pcrs:n,certificates:o,userData:r.user_data?c.decode(r.user_data):null,nonce:r.nonce?c.decode(r.nonce):null,cert0hash:d,validatedPcr0Hash:s}}const Af=We.createContext({auth:{loading:!0,user:void 0},signIn:async()=>{},signUp:async()=>{},signInGuest:async()=>{},signUpGuest:async()=>({id:"",email:void 0,access_token:"",refresh_token:""}),convertGuestToUserAccount:async()=>{},signOut:async()=>{},get:P0,put:R0,list:U0,del:j0,verifyEmail:D0,requestNewVerificationCode:jc,requestNewVerificationEmail:jc,refetchUser:async()=>{},changePassword:V0,refreshAccessToken:Rc,requestPasswordReset:$0,confirmPasswordReset:M0,initiateGitHubAuth:async()=>({auth_url:"",csrf_token:""}),handleGitHubCallback:async()=>{},initiateGoogleAuth:async()=>({auth_url:"",csrf_token:""}),handleGoogleCallback:async()=>{},getPrivateKey:L0,getPublicKey:F0,signMessage:H0,aiCustomFetch:async()=>new Response,apiUrl:"",pcrConfig:{},getAttestation:Bo,authenticate:Nc,parseAttestationForView:xf,awsRootCertDer:bf,expectedRootCertHash:G0,getAttestationDocument:async()=>{throw new Error("getAttestationDocument called outside of OpenSecretProvider")},generateThirdPartyToken:async()=>({token:""})});function hm({children:r,apiUrl:e,pcrConfig:t={}}){const[n,i]=We.useState({loading:!0,user:void 0}),[s,o]=We.useState();We.useEffect(()=>{if(!e||e.trim()==="")throw new Error("OpenSecretProvider requires a non-empty apiUrl. Please provide a valid API endpoint URL.");z1(e)},[e]),We.useEffect(()=>{n.user?o(()=>om()):o(void 0)},[n.user]);async function c(){const K=window.localStorage.getItem("access_token"),de=window.localStorage.getItem("refresh_token");if(!K||!de){i({loading:!1,user:void 0});return}try{const le=await Y1();i({loading:!1,user:le})}catch(le){console.error("Failed to fetch user:",le),i({loading:!1,user:void 0})}}We.useEffect(()=>{c()},[]);async function u(K,de){console.log("Signing in");try{const{access_token:le,refresh_token:pe}=await K1(K,de);window.localStorage.setItem("access_token",le),window.localStorage.setItem("refresh_token",pe),await c()}catch(le){throw console.error(le),le}}async function d(K,de,le,pe){try{const{access_token:Re,refresh_token:st}=await W1(K,de,le,pe);window.localStorage.setItem("access_token",Re),window.localStorage.setItem("refresh_token",st),await c()}catch(Re){throw console.error(Re),Re}}async function b(K,de){console.log("Signing in Guest");try{const{access_token:le,refresh_token:pe}=await Z1(K,de);window.localStorage.setItem("access_token",le),window.localStorage.setItem("refresh_token",pe),await c()}catch(le){throw console.error(le),le}}async function E(K,de){try{const{access_token:le,refresh_token:pe,id:Re}=await q1(K,de);return window.localStorage.setItem("access_token",le),window.localStorage.setItem("refresh_token",pe),await c(),{access_token:le,refresh_token:pe,id:Re}}catch(le){throw console.error(le),le}}async function Y(K,de,le){try{await im(K,de,le),await c()}catch(pe){throw console.error(pe),pe}}async function $(){const K=window.localStorage.getItem("refresh_token");if(K)try{await J1(K)}catch(de){console.error("Error during logout:",de)}localStorage.removeItem("access_token"),localStorage.removeItem("refresh_token"),sessionStorage.removeItem("sessionKey"),sessionStorage.removeItem("sessionId"),i({loading:!1,user:void 0})}const P={auth:n,signIn:u,signInGuest:b,signOut:$,signUp:d,signUpGuest:E,convertGuestToUserAccount:Y,get:P0,put:R0,list:U0,del:j0,refetchUser:c,verifyEmail:D0,requestNewVerificationCode:jc,requestNewVerificationEmail:jc,changePassword:V0,refreshAccessToken:Rc,requestPasswordReset:$0,confirmPasswordReset:M0,initiateGitHubAuth:async K=>{try{return await em(K)}catch(de){throw console.error("Failed to initiate GitHub auth:",de),de}},handleGitHubCallback:async(K,de,le)=>{try{const{access_token:pe,refresh_token:Re}=await tm(K,de,le);window.localStorage.setItem("access_token",pe),window.localStorage.setItem("refresh_token",Re),await c()}catch(pe){throw console.error("GitHub callback error:",pe),pe}},initiateGoogleAuth:async K=>{try{return await rm(K)}catch(de){throw console.error("Failed to initiate Google auth:",de),de}},handleGoogleCallback:async(K,de,le)=>{try{const{access_token:pe,refresh_token:Re}=await nm(K,de,le);window.localStorage.setItem("access_token",pe),window.localStorage.setItem("refresh_token",Re),await c()}catch(pe){throw console.error("Google callback error:",pe),pe}},getPrivateKey:L0,getPublicKey:F0,signMessage:H0,aiCustomFetch:s||(async()=>new Response),apiUrl:e,pcrConfig:t,getAttestation:Bo,authenticate:Nc,parseAttestationForView:xf,awsRootCertDer:bf,expectedRootCertHash:G0,getAttestationDocument:async()=>{const K=window.crypto.randomUUID(),de=await fetch(`${e}/attestation/${K}`);if(!de.ok)throw new Error("Failed to fetch attestation document");const le=await de.json(),pe=await Nc(le.attestation_document,bf,K);return xf(pe,pe.cabundle,t)},generateThirdPartyToken:sm};return ty.jsx(Af.Provider,{value:P,children:r})}function dm(){const r=We.useContext(Af);if(!r)throw new Error("useOpenSecret must be used within an OpenSecretProvider");return r}function pm(){const r=new Uint8Array(32);return crypto.getRandomValues(r),Array.from(r,e=>e.toString(16).padStart(2,"0")).join("")}async function ym(r){const t=new TextEncoder().encode(r),n=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(n)).map(s=>s.toString(16).padStart(2,"0")).join("")}Je.OpenSecretContext=Af,Je.OpenSecretProvider=hm,Je.generateSecureSecret=pm,Je.hashSecret=ym,Je.useOpenSecret=dm,Object.defineProperty(Je,Symbol.toStringTag,{value:"Module"})});
162
+ `);return e===-1?null:r.slice(0,e+2)}const lm=["eeddbb58f57c38894d6d5af5e575fbe791c5bf3bbcfb5df8da8cfcf0c2e1da1913108e6a762112444740b88c163d7f4b","74ed417f88cb0ca76c4a3d10f278bd010f1d3f95eafb254d4732511bb50e404507a4049b779c5230137e4091a5582271","9043fcab93b972d3c14ad2dc8fa78ca7ad374fc937c02435681772a003f7a72876bc4d578089b5c4cf3fe9b480f1aabb","52c3595b151d93d8b159c257301bfd5aa6f49210de0c55a6cd6df5ebeee44e4206cab950500f5d188f7fa14e6d900b75","91cb67311e910cce68cd5b7d0de77aa40610d87c6681439b44c46c3ff786ae643956ab2c812478a1da8745b259f07a45","859065ac81b81d3735130ba08b8af72a7256b603fefb74faabae25ed28cca6edcaa7c10ea32b5948d675c18a9b0f2b1d","acd82a7d3943e23e95a9dc3ce0b0107ea358d6287f9e3afa245622f7c7e3e0a66142a928b6efcc02f594a95366d3a99d"],um=["62c0407056217a4c10764ed9045694c29fa93255d3cc04c2f989cdd9a1f8050c8b169714c71f1118ebce2fcc9951d1a9","cb95519905443f9f66f05f63c548b61ad1561a27fd5717b69285861aaea3c3063fe12a2571773b67fea3c6c11b4d8ec6","deb5895831b5e4286f5a2dcf5e9c27383821446f8df2b465f141d10743599be20ba3bb381ce063bf7139cc89f7f61d4c","70ba26c6af1ec3b57ce80e1adcc0ee96d70224d4c7a078f427895cdf68e1c30f09b5ac4c456588d872f3f21ff77c036b","669404ea71435b8f498b48db7816a5c2ab1d258b1a77685b11d84d15a73189504d79c4dee13a658de9f4a0cbfc39cfe8","a791bf92c25ffdfd372660e460a0e238c6778c090672df6509ae4bc065cf8668b6baac6b6a11d554af53ee0ff0172ad5","c4285443b87b9b12a6cea3bef1064ec060f652b235a297095975af8f134e5ed65f92d70d4616fdec80af9dff48bb9f35"];function fm(r,e){const t=[...(e==null?void 0:e.pcr0Values)||[],...lm],n=[...(e==null?void 0:e.pcr0DevValues)||[],...um];return t.includes(r)?{isMatch:!0,text:"PCR0 matches a known good value"}:n.includes(r)?{isMatch:!0,text:"PCR0 matches development enclave"}:{isMatch:!1,text:"PCR0 does not match a known good value"}}const bf=Tc,G0="641a0321a3e244efe456463195d606317ed7cdcc3c1756e09893f3c68f79bb5b";function z0(r){return Array.from(r).map(e=>e.toString(16).padStart(2,"0")).join("")}async function hm(r){const e=await crypto.subtle.digest("SHA-256",r);return z0(new Uint8Array(e))}async function xf(r,e,t){console.log("Raw timestamp:",r.timestamp),console.log("Date object:",new Date(r.timestamp));const n=Array.from(r.pcrs.entries()).map(([b,E])=>({id:b,value:z0(E)})).filter(b=>!b.value.match(/^0+$/)),i=n.find(b=>b.id===0),s=i?fm(i.value,t):null,o=[...e,r.certificate].map(b=>{const E=new ji(b);return{subject:E.subject,notBefore:E.notBefore.toLocaleString(),notAfter:E.notAfter.toLocaleString(),pem:E.toString("pem"),isRoot:E.subject==="C=US, O=Amazon, OU=AWS, CN=aws.nitro-enclaves"}}),c=new TextDecoder,u=new ji(e[0]),d=await hm(u.rawData);return{moduleId:r.module_id,publicKey:r.public_key?Vr(r.public_key):null,timestamp:new Date(r.timestamp).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZoneName:"short"}),digest:r.digest,pcrs:n,certificates:o,userData:r.user_data?c.decode(r.user_data):null,nonce:r.nonce?c.decode(r.nonce):null,cert0hash:d,validatedPcr0Hash:s}}const Af=We.createContext({auth:{loading:!0,user:void 0},signIn:async()=>{},signUp:async()=>{},signInGuest:async()=>{},signUpGuest:async()=>({id:"",email:void 0,access_token:"",refresh_token:""}),convertGuestToUserAccount:async()=>{},signOut:async()=>{},get:P0,put:R0,list:U0,del:j0,verifyEmail:D0,requestNewVerificationCode:jc,requestNewVerificationEmail:jc,refetchUser:async()=>{},changePassword:V0,refreshAccessToken:Rc,requestPasswordReset:$0,confirmPasswordReset:M0,initiateGitHubAuth:async()=>({auth_url:"",csrf_token:""}),handleGitHubCallback:async()=>{},initiateGoogleAuth:async()=>({auth_url:"",csrf_token:""}),handleGoogleCallback:async()=>{},getPrivateKey:L0,getPublicKey:F0,signMessage:H0,aiCustomFetch:async()=>new Response,apiUrl:"",pcrConfig:{},getAttestation:Bo,authenticate:Nc,parseAttestationForView:xf,awsRootCertDer:bf,expectedRootCertHash:G0,getAttestationDocument:async()=>{throw new Error("getAttestationDocument called outside of OpenSecretProvider")},generateThirdPartyToken:async()=>({token:""})});function dm({children:r,apiUrl:e,pcrConfig:t={}}){const[n,i]=We.useState({loading:!0,user:void 0}),[s,o]=We.useState();We.useEffect(()=>{if(!e||e.trim()==="")throw new Error("OpenSecretProvider requires a non-empty apiUrl. Please provide a valid API endpoint URL.");K1(e)},[e]),We.useEffect(()=>{n.user?o(()=>am()):o(void 0)},[n.user]);async function c(){const K=window.localStorage.getItem("access_token"),de=window.localStorage.getItem("refresh_token");if(!K||!de){i({loading:!1,user:void 0});return}try{const le=await J1();i({loading:!1,user:le})}catch(le){console.error("Failed to fetch user:",le),i({loading:!1,user:void 0})}}We.useEffect(()=>{c()},[]);async function u(K,de){console.log("Signing in");try{const{access_token:le,refresh_token:pe}=await Z1(K,de);window.localStorage.setItem("access_token",le),window.localStorage.setItem("refresh_token",pe),await c()}catch(le){throw console.error(le),le}}async function d(K,de,le,pe){try{const{access_token:Re,refresh_token:st}=await q1(K,de,le,pe);window.localStorage.setItem("access_token",Re),window.localStorage.setItem("refresh_token",st),await c()}catch(Re){throw console.error(Re),Re}}async function b(K,de){console.log("Signing in Guest");try{const{access_token:le,refresh_token:pe}=await W1(K,de);window.localStorage.setItem("access_token",le),window.localStorage.setItem("refresh_token",pe),await c()}catch(le){throw console.error(le),le}}async function E(K,de){try{const{access_token:le,refresh_token:pe,id:Re}=await Y1(K,de);return window.localStorage.setItem("access_token",le),window.localStorage.setItem("refresh_token",pe),await c(),{access_token:le,refresh_token:pe,id:Re}}catch(le){throw console.error(le),le}}async function Y(K,de,le){try{await sm(K,de,le),await c()}catch(pe){throw console.error(pe),pe}}async function $(){const K=window.localStorage.getItem("refresh_token");if(K)try{await X1(K)}catch(de){console.error("Error during logout:",de)}localStorage.removeItem("access_token"),localStorage.removeItem("refresh_token"),sessionStorage.removeItem("sessionKey"),sessionStorage.removeItem("sessionId"),i({loading:!1,user:void 0})}const P={auth:n,signIn:u,signInGuest:b,signOut:$,signUp:d,signUpGuest:E,convertGuestToUserAccount:Y,get:P0,put:R0,list:U0,del:j0,refetchUser:c,verifyEmail:D0,requestNewVerificationCode:jc,requestNewVerificationEmail:jc,changePassword:V0,refreshAccessToken:Rc,requestPasswordReset:$0,confirmPasswordReset:M0,initiateGitHubAuth:async K=>{try{return await tm(K)}catch(de){throw console.error("Failed to initiate GitHub auth:",de),de}},handleGitHubCallback:async(K,de,le)=>{try{const{access_token:pe,refresh_token:Re}=await rm(K,de,le);window.localStorage.setItem("access_token",pe),window.localStorage.setItem("refresh_token",Re),await c()}catch(pe){throw console.error("GitHub callback error:",pe),pe}},initiateGoogleAuth:async K=>{try{return await nm(K)}catch(de){throw console.error("Failed to initiate Google auth:",de),de}},handleGoogleCallback:async(K,de,le)=>{try{const{access_token:pe,refresh_token:Re}=await im(K,de,le);window.localStorage.setItem("access_token",pe),window.localStorage.setItem("refresh_token",Re),await c()}catch(pe){throw console.error("Google callback error:",pe),pe}},getPrivateKey:L0,getPublicKey:F0,signMessage:H0,aiCustomFetch:s||(async()=>new Response),apiUrl:e,pcrConfig:t,getAttestation:Bo,authenticate:Nc,parseAttestationForView:xf,awsRootCertDer:bf,expectedRootCertHash:G0,getAttestationDocument:async()=>{const K=window.crypto.randomUUID(),de=await fetch(`${e}/attestation/${K}`);if(!de.ok)throw new Error("Failed to fetch attestation document");const le=await de.json(),pe=await Nc(le.attestation_document,bf,K);return xf(pe,pe.cabundle,t)},generateThirdPartyToken:om};return ty.jsx(Af.Provider,{value:P,children:r})}function pm(){const r=We.useContext(Af);if(!r)throw new Error("useOpenSecret must be used within an OpenSecretProvider");return r}function ym(){const r=new Uint8Array(32);return crypto.getRandomValues(r),Array.from(r,e=>e.toString(16).padStart(2,"0")).join("")}async function gm(r){const t=new TextEncoder().encode(r),n=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(n)).map(s=>s.toString(16).padStart(2,"0")).join("")}Je.OpenSecretContext=Af,Je.OpenSecretProvider=dm,Je.generateSecureSecret=ym,Je.hashSecret=gm,Je.useOpenSecret=pm,Object.defineProperty(Je,Symbol.toStringTag,{value:"Module"})});