@opensecret/react 1.3.2 → 1.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts
CHANGED
|
@@ -206,18 +206,18 @@ declare function changePlatformPassword(currentPassword: string, newPassword: st
|
|
|
206
206
|
|
|
207
207
|
/**
|
|
208
208
|
* Confirms and completes the account deletion process
|
|
209
|
-
* @param
|
|
209
|
+
* @param confirmationCode - The confirmation code from the verification email
|
|
210
210
|
* @param plaintextSecret - The plaintext secret that was hashed in the request step
|
|
211
211
|
* @returns A promise resolving to void
|
|
212
212
|
*
|
|
213
213
|
* @description
|
|
214
214
|
* This function:
|
|
215
215
|
* 1. Requires the user to be logged in (uses authenticatedApiCall)
|
|
216
|
-
* 2. Verifies both the
|
|
216
|
+
* 2. Verifies both the confirmation code from email and the secret known only to the client
|
|
217
217
|
* 3. Permanently deletes the user account and all associated data
|
|
218
218
|
* 4. After successful deletion, the client should clear all local storage and tokens
|
|
219
219
|
*/
|
|
220
|
-
declare function confirmAccountDeletion(
|
|
220
|
+
declare function confirmAccountDeletion(confirmationCode: string, plaintextSecret: string): Promise<void>;
|
|
221
221
|
|
|
222
222
|
declare function confirmPasswordReset(email: string, alphanumericCode: string, plaintextSecret: string, newPassword: string, client_id: string): Promise<void>;
|
|
223
223
|
|
|
@@ -812,24 +812,24 @@ export declare type OpenSecretContextType = {
|
|
|
812
812
|
* This function:
|
|
813
813
|
* 1. Requires the user to be logged in (uses authenticatedApiCall)
|
|
814
814
|
* 2. Sends a verification email to the user's email address
|
|
815
|
-
* 3. The email contains a
|
|
815
|
+
* 3. The email contains a confirmation code that will be needed for confirmation
|
|
816
816
|
* 4. The client must store the plaintext secret for confirmation
|
|
817
817
|
*/
|
|
818
818
|
requestAccountDeletion: (hashedSecret: string) => Promise<void>;
|
|
819
819
|
/**
|
|
820
820
|
* Confirms and completes the account deletion process
|
|
821
|
-
* @param
|
|
821
|
+
* @param confirmationCode - The confirmation code from the verification email
|
|
822
822
|
* @param plaintextSecret - The plaintext secret that was hashed in the request step
|
|
823
823
|
* @returns A promise resolving to void
|
|
824
824
|
* @throws {Error} If confirmation fails
|
|
825
825
|
*
|
|
826
826
|
* This function:
|
|
827
827
|
* 1. Requires the user to be logged in (uses authenticatedApiCall)
|
|
828
|
-
* 2. Verifies both the
|
|
828
|
+
* 2. Verifies both the confirmation code from email and the secret known only to the client
|
|
829
829
|
* 3. Permanently deletes the user account and all associated data
|
|
830
830
|
* 4. After successful deletion, the client should clear all local storage and tokens
|
|
831
831
|
*/
|
|
832
|
-
confirmAccountDeletion: (
|
|
832
|
+
confirmAccountDeletion: (confirmationCode: string, plaintextSecret: string) => Promise<void>;
|
|
833
833
|
initiateGitHubAuth: (inviteCode: string) => Promise<api.GithubAuthResponse>;
|
|
834
834
|
handleGitHubCallback: (code: string, state: string, inviteCode: string) => Promise<void>;
|
|
835
835
|
initiateGoogleAuth: (inviteCode: string) => Promise<api.GoogleAuthResponse>;
|
|
@@ -1712,7 +1712,7 @@ declare function removeMember(orgId: string, userId: string): Promise<void>;
|
|
|
1712
1712
|
* This function:
|
|
1713
1713
|
* 1. Requires the user to be logged in (uses authenticatedApiCall)
|
|
1714
1714
|
* 2. Sends a verification email to the user's email address
|
|
1715
|
-
* 3. The email contains a
|
|
1715
|
+
* 3. The email contains a confirmation code that will be needed for confirmation
|
|
1716
1716
|
* 4. The client must store the plaintext secret for confirmation
|
|
1717
1717
|
*/
|
|
1718
1718
|
declare function requestAccountDeletion(hashedSecret: string): Promise<void>;
|
|
@@ -14940,7 +14940,7 @@ async function aw(r) {
|
|
|
14940
14940
|
}
|
|
14941
14941
|
async function cw(r, e) {
|
|
14942
14942
|
const t = {
|
|
14943
|
-
|
|
14943
|
+
confirmation_code: r,
|
|
14944
14944
|
plaintext_secret: e
|
|
14945
14945
|
};
|
|
14946
14946
|
return $e(
|
|
@@ -122,7 +122,7 @@ ${e.join(`
|
|
|
122
122
|
`;return o+=l0(s,t),o}const u0=!Lv();function f0(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 Gn(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 Si(r){if(!(r instanceof Uint8Array))throw new Error(`Expected Uint8Array: ${r}`)}function h0(r){if(!Array.isArray(r))throw new Error(`Expected Array: ${r}`)}Rt(Map,(r,e,t)=>{const n=[...r.entries()].map(i=>[i[0],i[1],gc(i[0],t)]);if(t.rejectDuplicateKeys){const i=new Set;for(const[s,o,c]of n){const u=Gr(c);if(i.has(u))throw new Error(`Duplicate map key: 0x${u}`);i.add(u)}}t.sortKeys&&n.sort(t.sortKeys),uf(r,r.size,ge.MAP,e,t);for(const[i,s,o]of n)e.write(o),Ai(s,e,t)});function d0(r){return Gn(r.contents),new Date(r.contents)}d0.comment=r=>(Gn(r.contents),`(String Date) ${new Date(r.contents).toISOString()}`),We.registerDecoder(Et.DATE_STRING,d0);function p0(r){return f0(r.contents),new Date(r.contents*1e3)}p0.comment=r=>(f0(r.contents),`(Epoch Date) ${new Date(r.contents*1e3).toISOString()}`),We.registerDecoder(Et.DATE_EPOCH,p0),Rt(Date,r=>[Et.DATE_EPOCH,r.valueOf()/1e3]);function mc(r,e,t){if(Si(e.contents),t.rejectBigInts)throw new Error(`Decoding unwanted big integer: ${e}(h'${Gr(e.contents)}')`);if(t.requirePreferred&&e.contents[0]===0)throw new Error(`Decoding overly-large bigint: ${e.tag}(h'${Gr(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?Ys(n,e.contents):n}const y0=mc.bind(null,!1),g0=mc.bind(null,!0);y0.comment=(r,e)=>`(Positive BigInt) ${mc(!1,r,e)}n`,g0.comment=(r,e)=>`(Negative BigInt) ${mc(!0,r,e)}n`,We.registerDecoder(Et.POS_BIGINT,y0),We.registerDecoder(Et.NEG_BIGINT,g0);function df(r,e){return Si(r.contents),r}df.comment=(r,e,t)=>{Si(r.contents);const n={...e,initialDepth:t+2,noPrefixHex:!0},i=dc(r);let s=2**((i[0]&31)-24)+1;const o=i[s]&31;let c=Gr(i.subarray(s,++s));o>=24&&(c+=" ",c+=Gr(i.subarray(s,s+2**(o-24)))),n.minCol=Math.max(n.minCol,(t+1)*2+c.length);const u=lm(r.contents,n);let h=`Embedded CBOR
|
|
123
123
|
`;return h+=`${"".padStart((t+1)*2," ")}${c}`.padEnd(n.minCol+1," "),h+=`-- Bytes (Length: ${r.contents.length})
|
|
124
124
|
`,h+=u,h},df.noChildren=!0,We.registerDecoder(Et.CBOR,df),We.registerDecoder(Et.URI,r=>(Gn(r.contents),new URL(r.contents)),"URI"),Rt(URL,r=>[Et.URI,r.toString()]),We.registerDecoder(Et.BASE64URL,r=>(Gn(r.contents),Vv(r.contents)),"Base64url-encoded"),We.registerDecoder(Et.BASE64,r=>(Gn(r.contents),af(r.contents)),"Base64-encoded"),We.registerDecoder(35,r=>(Gn(r.contents),new RegExp(r.contents)),"RegExp"),We.registerDecoder(21065,r=>{Gn(r.contents);let e=r.contents.replace(new RegExp("(?<!\\\\)(?<!\\[(?:[^\\]]|\\\\\\])*)\\.","g"),`[^
|
|
125
|
-
\r]`);return e=`^(?:${e})$`,new RegExp(e,"u")},"I-RegExp"),We.registerDecoder(Et.REGEXP,r=>{if(h0(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"),Rt(RegExp,r=>[Et.REGEXP,[r.source,r.flags]]),We.registerDecoder(64,r=>(Si(r.contents),r.contents),"uint8 Typed Array");function nr(r,e,t){Si(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 qn(r,e,t,n,i){const s=i.forceEndian??u0;if(yc(s?e:t,r,i),qr(n.byteLength,r,ge.BYTE_STRING),u0===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)}}We.registerDecoder(65,r=>nr(r,Uint16Array,!1),"uint16, big endian, Typed Array"),We.registerDecoder(66,r=>nr(r,Uint32Array,!1),"uint32, big endian, Typed Array"),We.registerDecoder(67,r=>nr(r,BigUint64Array,!1),"uint64, big endian, Typed Array"),We.registerDecoder(68,r=>(Si(r.contents),new Uint8ClampedArray(r.contents)),"uint8 Typed Array, clamped arithmetic"),Rt(Uint8ClampedArray,r=>[68,new Uint8Array(r.buffer,r.byteOffset,r.byteLength)]),We.registerDecoder(69,r=>nr(r,Uint16Array,!0),"uint16, little endian, Typed Array"),Rt(Uint16Array,(r,e,t)=>qn(e,69,65,r,t)),We.registerDecoder(70,r=>nr(r,Uint32Array,!0),"uint32, little endian, Typed Array"),Rt(Uint32Array,(r,e,t)=>qn(e,70,66,r,t)),We.registerDecoder(71,r=>nr(r,BigUint64Array,!0),"uint64, little endian, Typed Array"),Rt(BigUint64Array,(r,e,t)=>qn(e,71,67,r,t)),We.registerDecoder(72,r=>(Si(r.contents),new Int8Array(r.contents)),"sint8 Typed Array"),Rt(Int8Array,r=>[72,new Uint8Array(r.buffer,r.byteOffset,r.byteLength)]),We.registerDecoder(73,r=>nr(r,Int16Array,!1),"sint16, big endian, Typed Array"),We.registerDecoder(74,r=>nr(r,Int32Array,!1),"sint32, big endian, Typed Array"),We.registerDecoder(75,r=>nr(r,BigInt64Array,!1),"sint64, big endian, Typed Array"),We.registerDecoder(77,r=>nr(r,Int16Array,!0),"sint16, little endian, Typed Array"),Rt(Int16Array,(r,e,t)=>qn(e,77,73,r,t)),We.registerDecoder(78,r=>nr(r,Int32Array,!0),"sint32, little endian, Typed Array"),Rt(Int32Array,(r,e,t)=>qn(e,78,74,r,t)),We.registerDecoder(79,r=>nr(r,BigInt64Array,!0),"sint64, little endian, Typed Array"),Rt(BigInt64Array,(r,e,t)=>qn(e,79,75,r,t)),We.registerDecoder(81,r=>nr(r,Float32Array,!1),"IEEE 754 binary32, big endian, Typed Array"),We.registerDecoder(82,r=>nr(r,Float64Array,!1),"IEEE 754 binary64, big endian, Typed Array"),We.registerDecoder(85,r=>nr(r,Float32Array,!0),"IEEE 754 binary32, little endian, Typed Array"),Rt(Float32Array,(r,e,t)=>qn(e,85,81,r,t)),We.registerDecoder(86,r=>nr(r,Float64Array,!0),"IEEE 754 binary64, big endian, Typed Array"),Rt(Float64Array,(r,e,t)=>qn(e,86,82,r,t)),We.registerDecoder(Et.SET,r=>(h0(r.contents),new Set(r.contents)),"Set"),Rt(Set,r=>[Et.SET,[...r]]),We.registerDecoder(Et.JSON,r=>(Gn(r.contents),JSON.parse(r.contents)),"JSON-encoded"),We.registerDecoder(Et.SELF_DESCRIBED,r=>r.contents,"Self-Described"),We.registerDecoder(Et.INVALID_16,()=>{throw new Error(`Tag always invalid: ${Et.INVALID_16}`)},"Invalid"),We.registerDecoder(Et.INVALID_32,()=>{throw new Error(`Tag always invalid: ${Et.INVALID_32}`)},"Invalid"),We.registerDecoder(Et.INVALID_64,()=>{throw new Error(`Tag always invalid: ${Et.INVALID_64}`)},"Invalid");function pf(r){throw new Error(`Encoding ${r.constructor.name} intentionally unimplmented. It is not concrete enough to interoperate. Convert to Uint8Array first.`)}Rt(ArrayBuffer,pf),Rt(DataView,pf),typeof SharedArrayBuffer<"u"&&Rt(SharedArrayBuffer,pf);function wc(r){return[NaN,r.valueOf()]}Rt(Boolean,wc),Rt(Number,wc),Rt(String,wc),Rt(BigInt,wc);function bc(r,e={}){const t={...zn.defaultDecodeOptions};if(e.dcbor?Object.assign(t,zn.dcborDecodeOptions):e.cde&&Object.assign(t,zn.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 Xs(r,t);let i,s;for(const o of n){if(s=zn.create(o,i,t,n),o[2]===Ir.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 zn&&(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 ot;(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})(ot||(ot={}));var yf;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(yf||(yf={}));const ie=ot.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Kn=r=>{switch(typeof r){case"undefined":return ie.undefined;case"string":return ie.string;case"number":return isNaN(r)?ie.nan:ie.number;case"boolean":return ie.boolean;case"function":return ie.function;case"bigint":return ie.bigint;case"symbol":return ie.symbol;case"object":return Array.isArray(r)?ie.array:r===null?ie.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?ie.promise:typeof Map<"u"&&r instanceof Map?ie.map:typeof Set<"u"&&r instanceof Set?ie.set:typeof Date<"u"&&r instanceof Date?ie.date:ie.object;default:return ie.unknown}},F=ot.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"]),um=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 h=o.path[u];u===o.path.length-1?(c[h]=c[h]||{_errors:[]},c[h]._errors.push(t(o))):c[h]=c[h]||{_errors:[]},c=c[h],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,ot.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 is=(r,e)=>{let t;switch(r.code){case F.invalid_type:r.received===ie.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case F.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,ot.jsonStringifyReplacer)}`;break;case F.unrecognized_keys:t=`Unrecognized key(s) in object: ${ot.joinValues(r.keys,", ")}`;break;case F.invalid_union:t="Invalid input";break;case F.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${ot.joinValues(r.options)}`;break;case F.invalid_enum_value:t=`Invalid enum value. Expected ${ot.joinValues(r.options)}, received '${r.received}'`;break;case F.invalid_arguments:t="Invalid function arguments";break;case F.invalid_return_type:t="Invalid function return type";break;case F.invalid_date:t="Invalid date";break;case F.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}"`:ot.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case F.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 F.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 F.custom:t="Invalid input";break;case F.invalid_intersection_types:t="Intersection results could not be merged";break;case F.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case F.not_finite:t="Number must be finite";break;default:t=e.defaultError,ot.assertNever(r)}return{message:t}};let v0=is;function fm(r){v0=r}function xc(){return v0}const Ac=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(h=>!!h).slice().reverse();for(const h of u)c=h(o,{data:e,defaultError:c}).message;return{...i,path:s,message:c}},hm=[];function X(r,e){const t=xc(),n=Ac({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===is?void 0:is].filter(i=>!!i)});r.common.issues.push(n)}class ir{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 ke;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 ir.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 ke;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 ke=Object.freeze({status:"aborted"}),ss=r=>({status:"dirty",value:r}),hr=r=>({status:"valid",value:r}),gf=r=>r.status==="aborted",vf=r=>r.status==="dirty",Qs=r=>r.status==="valid",eo=r=>typeof Promise<"u"&&r instanceof Promise;function Sc(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 m0(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 xe;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(xe||(xe={}));var to,ro;class an{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 w0=(r,e)=>{if(Qs(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 Ve(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,h;const{message:m}=r;return o.code==="invalid_enum_value"?{message:m??c.defaultError}:typeof c.data>"u"?{message:(u=m??n)!==null&&u!==void 0?u:c.defaultError}:o.code!=="invalid_type"?{message:c.defaultError}:{message:(h=m??t)!==null&&h!==void 0?h:c.defaultError}},description:i}}class qe{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 Kn(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Kn(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new ir,ctx:{common:e.parent.common,data:e.data,parsedType:Kn(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(eo(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:Kn(e)},s=this._parseSync({data:e,path:i.path,parent:i});return w0(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:Kn(e)},i=this._parse({data:e,path:n.path,parent:n}),s=await(eo(i)?i:Promise.resolve(i));return w0(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:F.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 Wr({schema:this,typeName:Ee.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return ln.create(this,this._def)}nullable(){return Jn.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Zr.create(this,this._def)}promise(){return ls.create(this,this._def)}or(e){return oo.create([this,e],this._def)}and(e){return ao.create(this,e,this._def)}transform(e){return new Wr({...Ve(this._def),schema:this,typeName:Ee.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new ho({...Ve(this._def),innerType:this,defaultValue:t,typeName:Ee.ZodDefault})}brand(){return new bf({typeName:Ee.ZodBranded,type:this,...Ve(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new po({...Ve(this._def),innerType:this,catchValue:t,typeName:Ee.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return yo.create(this,e)}readonly(){return go.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const dm=/^c[^\s-]{8,}$/i,pm=/^[0-9a-z]+$/,ym=/^[0-9A-HJKMNP-TV-Z]{26}$/,gm=/^[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,vm=/^[a-z0-9_-]{21}$/i,mm=/^[-+]?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)?)??$/,wm=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,bm="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let mf;const xm=/^(?:(?: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])$/,Am=/^(([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})))$/,Sm=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,b0="((\\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])))",_m=new RegExp(`^${b0}$`);function x0(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 Em(r){return new RegExp(`^${x0(r)}$`)}function A0(r){let e=`${b0}T${x0(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 Im(r,e){return!!((e==="v4"||!e)&&xm.test(r)||(e==="v6"||!e)&&Am.test(r))}class Kr extends qe{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==ie.string){const s=this._getOrReturnCtx(e);return X(s,{code:F.invalid_type,expected:ie.string,received:s.parsedType}),ke}const n=new ir;let i;for(const s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(i=this._getOrReturnCtx(e,i),X(i,{code:F.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),X(i,{code:F.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?X(i,{code:F.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):c&&X(i,{code:F.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),n.dirty())}else if(s.kind==="email")wm.test(e.data)||(i=this._getOrReturnCtx(e,i),X(i,{validation:"email",code:F.invalid_string,message:s.message}),n.dirty());else if(s.kind==="emoji")mf||(mf=new RegExp(bm,"u")),mf.test(e.data)||(i=this._getOrReturnCtx(e,i),X(i,{validation:"emoji",code:F.invalid_string,message:s.message}),n.dirty());else if(s.kind==="uuid")gm.test(e.data)||(i=this._getOrReturnCtx(e,i),X(i,{validation:"uuid",code:F.invalid_string,message:s.message}),n.dirty());else if(s.kind==="nanoid")vm.test(e.data)||(i=this._getOrReturnCtx(e,i),X(i,{validation:"nanoid",code:F.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid")dm.test(e.data)||(i=this._getOrReturnCtx(e,i),X(i,{validation:"cuid",code:F.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid2")pm.test(e.data)||(i=this._getOrReturnCtx(e,i),X(i,{validation:"cuid2",code:F.invalid_string,message:s.message}),n.dirty());else if(s.kind==="ulid")ym.test(e.data)||(i=this._getOrReturnCtx(e,i),X(i,{validation:"ulid",code:F.invalid_string,message:s.message}),n.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),X(i,{validation:"url",code:F.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),X(i,{validation:"regex",code:F.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),X(i,{code:F.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),X(i,{code:F.invalid_string,validation:{startsWith:s.value},message:s.message}),n.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(i=this._getOrReturnCtx(e,i),X(i,{code:F.invalid_string,validation:{endsWith:s.value},message:s.message}),n.dirty()):s.kind==="datetime"?A0(s).test(e.data)||(i=this._getOrReturnCtx(e,i),X(i,{code:F.invalid_string,validation:"datetime",message:s.message}),n.dirty()):s.kind==="date"?_m.test(e.data)||(i=this._getOrReturnCtx(e,i),X(i,{code:F.invalid_string,validation:"date",message:s.message}),n.dirty()):s.kind==="time"?Em(s).test(e.data)||(i=this._getOrReturnCtx(e,i),X(i,{code:F.invalid_string,validation:"time",message:s.message}),n.dirty()):s.kind==="duration"?mm.test(e.data)||(i=this._getOrReturnCtx(e,i),X(i,{validation:"duration",code:F.invalid_string,message:s.message}),n.dirty()):s.kind==="ip"?Im(e.data,s.version)||(i=this._getOrReturnCtx(e,i),X(i,{validation:"ip",code:F.invalid_string,message:s.message}),n.dirty()):s.kind==="base64"?Sm.test(e.data)||(i=this._getOrReturnCtx(e,i),X(i,{validation:"base64",code:F.invalid_string,message:s.message}),n.dirty()):ot.assertNever(s);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(i=>e.test(i),{validation:t,code:F.invalid_string,...xe.errToObj(n)})}_addCheck(e){return new Kr({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...xe.errToObj(e)})}url(e){return this._addCheck({kind:"url",...xe.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...xe.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...xe.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...xe.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...xe.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...xe.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...xe.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...xe.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...xe.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,...xe.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,...xe.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...xe.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...xe.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...xe.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...xe.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...xe.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...xe.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...xe.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...xe.errToObj(t)})}nonempty(e){return this.min(1,xe.errToObj(e))}trim(){return new Kr({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Kr({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Kr({...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}}Kr.create=r=>{var e;return new Kr({checks:[],typeName:Ee.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...Ve(r)})};function km(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 Zn extends qe{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)!==ie.number){const s=this._getOrReturnCtx(e);return X(s,{code:F.invalid_type,expected:ie.number,received:s.parsedType}),ke}let n;const i=new ir;for(const s of this._def.checks)s.kind==="int"?ot.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),X(n,{code:F.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),X(n,{code:F.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),X(n,{code:F.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="multipleOf"?km(e.data,s.value)!==0&&(n=this._getOrReturnCtx(e,n),X(n,{code:F.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),X(n,{code:F.not_finite,message:s.message}),i.dirty()):ot.assertNever(s);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,xe.toString(t))}gt(e,t){return this.setLimit("min",e,!1,xe.toString(t))}lte(e,t){return this.setLimit("max",e,!0,xe.toString(t))}lt(e,t){return this.setLimit("max",e,!1,xe.toString(t))}setLimit(e,t,n,i){return new Zn({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:xe.toString(i)}]})}_addCheck(e){return new Zn({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:xe.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:xe.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:xe.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:xe.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:xe.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:xe.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:xe.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:xe.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:xe.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"&&ot.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)}}Zn.create=r=>new Zn({checks:[],typeName:Ee.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...Ve(r)});class Wn extends qe{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)!==ie.bigint){const s=this._getOrReturnCtx(e);return X(s,{code:F.invalid_type,expected:ie.bigint,received:s.parsedType}),ke}let n;const i=new ir;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),X(n,{code:F.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),X(n,{code:F.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),X(n,{code:F.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):ot.assertNever(s);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,xe.toString(t))}gt(e,t){return this.setLimit("min",e,!1,xe.toString(t))}lte(e,t){return this.setLimit("max",e,!0,xe.toString(t))}lt(e,t){return this.setLimit("max",e,!1,xe.toString(t))}setLimit(e,t,n,i){return new Wn({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:xe.toString(i)}]})}_addCheck(e){return new Wn({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:xe.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:xe.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:xe.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:xe.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:xe.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}}Wn.create=r=>{var e;return new Wn({checks:[],typeName:Ee.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...Ve(r)})};class no extends qe{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==ie.boolean){const n=this._getOrReturnCtx(e);return X(n,{code:F.invalid_type,expected:ie.boolean,received:n.parsedType}),ke}return hr(e.data)}}no.create=r=>new no({typeName:Ee.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...Ve(r)});class _i extends qe{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==ie.date){const s=this._getOrReturnCtx(e);return X(s,{code:F.invalid_type,expected:ie.date,received:s.parsedType}),ke}if(isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return X(s,{code:F.invalid_date}),ke}const n=new ir;let i;for(const s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(i=this._getOrReturnCtx(e,i),X(i,{code:F.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),X(i,{code:F.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),n.dirty()):ot.assertNever(s);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new _i({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:xe.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:xe.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}}_i.create=r=>new _i({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:Ee.ZodDate,...Ve(r)});class _c extends qe{_parse(e){if(this._getType(e)!==ie.symbol){const n=this._getOrReturnCtx(e);return X(n,{code:F.invalid_type,expected:ie.symbol,received:n.parsedType}),ke}return hr(e.data)}}_c.create=r=>new _c({typeName:Ee.ZodSymbol,...Ve(r)});class io extends qe{_parse(e){if(this._getType(e)!==ie.undefined){const n=this._getOrReturnCtx(e);return X(n,{code:F.invalid_type,expected:ie.undefined,received:n.parsedType}),ke}return hr(e.data)}}io.create=r=>new io({typeName:Ee.ZodUndefined,...Ve(r)});class so extends qe{_parse(e){if(this._getType(e)!==ie.null){const n=this._getOrReturnCtx(e);return X(n,{code:F.invalid_type,expected:ie.null,received:n.parsedType}),ke}return hr(e.data)}}so.create=r=>new so({typeName:Ee.ZodNull,...Ve(r)});class os extends qe{constructor(){super(...arguments),this._any=!0}_parse(e){return hr(e.data)}}os.create=r=>new os({typeName:Ee.ZodAny,...Ve(r)});class Ei extends qe{constructor(){super(...arguments),this._unknown=!0}_parse(e){return hr(e.data)}}Ei.create=r=>new Ei({typeName:Ee.ZodUnknown,...Ve(r)});class Bn extends qe{_parse(e){const t=this._getOrReturnCtx(e);return X(t,{code:F.invalid_type,expected:ie.never,received:t.parsedType}),ke}}Bn.create=r=>new Bn({typeName:Ee.ZodNever,...Ve(r)});class Ec extends qe{_parse(e){if(this._getType(e)!==ie.undefined){const n=this._getOrReturnCtx(e);return X(n,{code:F.invalid_type,expected:ie.void,received:n.parsedType}),ke}return hr(e.data)}}Ec.create=r=>new Ec({typeName:Ee.ZodVoid,...Ve(r)});class Zr extends qe{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),i=this._def;if(t.parsedType!==ie.array)return X(t,{code:F.invalid_type,expected:ie.array,received:t.parsedType}),ke;if(i.exactLength!==null){const o=t.data.length>i.exactLength.value,c=t.data.length<i.exactLength.value;(o||c)&&(X(t,{code:o?F.too_big:F.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&&(X(t,{code:F.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&&(X(t,{code:F.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 an(t,o,t.path,c)))).then(o=>ir.mergeArray(n,o));const s=[...t.data].map((o,c)=>i.type._parseSync(new an(t,o,t.path,c)));return ir.mergeArray(n,s)}get element(){return this._def.type}min(e,t){return new Zr({...this._def,minLength:{value:e,message:xe.toString(t)}})}max(e,t){return new Zr({...this._def,maxLength:{value:e,message:xe.toString(t)}})}length(e,t){return new Zr({...this._def,exactLength:{value:e,message:xe.toString(t)}})}nonempty(e){return this.min(1,e)}}Zr.create=(r,e)=>new Zr({type:r,minLength:null,maxLength:null,exactLength:null,typeName:Ee.ZodArray,...Ve(e)});function as(r){if(r instanceof Ot){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=ln.create(as(n))}return new Ot({...r._def,shape:()=>e})}else return r instanceof Zr?new Zr({...r._def,type:as(r.element)}):r instanceof ln?ln.create(as(r.unwrap())):r instanceof Jn?Jn.create(as(r.unwrap())):r instanceof cn?cn.create(r.items.map(e=>as(e))):r}class Ot extends qe{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=ot.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==ie.object){const h=this._getOrReturnCtx(e);return X(h,{code:F.invalid_type,expected:ie.object,received:h.parsedType}),ke}const{status:n,ctx:i}=this._processInputParams(e),{shape:s,keys:o}=this._getCached(),c=[];if(!(this._def.catchall instanceof Bn&&this._def.unknownKeys==="strip"))for(const h in i.data)o.includes(h)||c.push(h);const u=[];for(const h of o){const m=s[h],x=i.data[h];u.push({key:{status:"valid",value:h},value:m._parse(new an(i,x,i.path,h)),alwaysSet:h in i.data})}if(this._def.catchall instanceof Bn){const h=this._def.unknownKeys;if(h==="passthrough")for(const m of c)u.push({key:{status:"valid",value:m},value:{status:"valid",value:i.data[m]}});else if(h==="strict")c.length>0&&(X(i,{code:F.unrecognized_keys,keys:c}),n.dirty());else if(h!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const h=this._def.catchall;for(const m of c){const x=i.data[m];u.push({key:{status:"valid",value:m},value:h._parse(new an(i,x,i.path,m)),alwaysSet:m in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const h=[];for(const m of u){const x=await m.key,G=await m.value;h.push({key:x,value:G,alwaysSet:m.alwaysSet})}return h}).then(h=>ir.mergeObjectSync(n,h)):ir.mergeObjectSync(n,u)}get shape(){return this._def.shape()}strict(e){return xe.errToObj,new Ot({...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=xe.errToObj(e).message)!==null&&c!==void 0?c:u}:{message:u}}}:{}})}strip(){return new Ot({...this._def,unknownKeys:"strip"})}passthrough(){return new Ot({...this._def,unknownKeys:"passthrough"})}extend(e){return new Ot({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Ot({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:Ee.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Ot({...this._def,catchall:e})}pick(e){const t={};return ot.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new Ot({...this._def,shape:()=>t})}omit(e){const t={};return ot.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new Ot({...this._def,shape:()=>t})}deepPartial(){return as(this)}partial(e){const t={};return ot.objectKeys(this.shape).forEach(n=>{const i=this.shape[n];e&&!e[n]?t[n]=i:t[n]=i.optional()}),new Ot({...this._def,shape:()=>t})}required(e){const t={};return ot.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let s=this.shape[n];for(;s instanceof ln;)s=s._def.innerType;t[n]=s}}),new Ot({...this._def,shape:()=>t})}keyof(){return S0(ot.objectKeys(this.shape))}}Ot.create=(r,e)=>new Ot({shape:()=>r,unknownKeys:"strip",catchall:Bn.create(),typeName:Ee.ZodObject,...Ve(e)}),Ot.strictCreate=(r,e)=>new Ot({shape:()=>r,unknownKeys:"strict",catchall:Bn.create(),typeName:Ee.ZodObject,...Ve(e)}),Ot.lazycreate=(r,e)=>new Ot({shape:r,unknownKeys:"strip",catchall:Bn.create(),typeName:Ee.ZodObject,...Ve(e)});class oo extends qe{_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 X(t,{code:F.invalid_union,unionErrors:o}),ke}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 h={...t,common:{...t.common,issues:[]},parent:null},m=u._parseSync({data:t.data,path:t.path,parent:h});if(m.status==="valid")return m;m.status==="dirty"&&!s&&(s={result:m,ctx:h}),h.common.issues.length&&o.push(h.common.issues)}if(s)return t.common.issues.push(...s.ctx.common.issues),s.result;const c=o.map(u=>new kr(u));return X(t,{code:F.invalid_union,unionErrors:c}),ke}}get options(){return this._def.options}}oo.create=(r,e)=>new oo({options:r,typeName:Ee.ZodUnion,...Ve(e)});const On=r=>r instanceof lo?On(r.schema):r instanceof Wr?On(r.innerType()):r instanceof uo?[r.value]:r instanceof Yn?r.options:r instanceof fo?ot.objectValues(r.enum):r instanceof ho?On(r._def.innerType):r instanceof io?[void 0]:r instanceof so?[null]:r instanceof ln?[void 0,...On(r.unwrap())]:r instanceof Jn?[null,...On(r.unwrap())]:r instanceof bf||r instanceof go?On(r.unwrap()):r instanceof po?On(r._def.innerType):[];class Ic extends qe{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==ie.object)return X(t,{code:F.invalid_type,expected:ie.object,received:t.parsedType}),ke;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}):(X(t,{code:F.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),ke)}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=On(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 Ic({typeName:Ee.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:i,...Ve(n)})}}function wf(r,e){const t=Kn(r),n=Kn(e);if(r===e)return{valid:!0,data:r};if(t===ie.object&&n===ie.object){const i=ot.objectKeys(e),s=ot.objectKeys(r).filter(c=>i.indexOf(c)!==-1),o={...r,...e};for(const c of s){const u=wf(r[c],e[c]);if(!u.valid)return{valid:!1};o[c]=u.data}return{valid:!0,data:o}}else if(t===ie.array&&n===ie.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=wf(o,c);if(!u.valid)return{valid:!1};i.push(u.data)}return{valid:!0,data:i}}else return t===ie.date&&n===ie.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class ao extends qe{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),i=(s,o)=>{if(gf(s)||gf(o))return ke;const c=wf(s.value,o.value);return c.valid?((vf(s)||vf(o))&&t.dirty(),{status:t.value,value:c.data}):(X(n,{code:F.invalid_intersection_types}),ke)};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}))}}ao.create=(r,e,t)=>new ao({left:r,right:e,typeName:Ee.ZodIntersection,...Ve(t)});class cn extends qe{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==ie.array)return X(n,{code:F.invalid_type,expected:ie.array,received:n.parsedType}),ke;if(n.data.length<this._def.items.length)return X(n,{code:F.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),ke;!this._def.rest&&n.data.length>this._def.items.length&&(X(n,{code:F.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 an(n,o,n.path,c)):null}).filter(o=>!!o);return n.common.async?Promise.all(s).then(o=>ir.mergeArray(t,o)):ir.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new cn({...this._def,rest:e})}}cn.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new cn({items:r,typeName:Ee.ZodTuple,rest:null,...Ve(e)})};class co extends qe{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!==ie.object)return X(n,{code:F.invalid_type,expected:ie.object,received:n.parsedType}),ke;const i=[],s=this._def.keyType,o=this._def.valueType;for(const c in n.data)i.push({key:s._parse(new an(n,c,n.path,c)),value:o._parse(new an(n,n.data[c],n.path,c)),alwaysSet:c in n.data});return n.common.async?ir.mergeObjectAsync(t,i):ir.mergeObjectSync(t,i)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof qe?new co({keyType:e,valueType:t,typeName:Ee.ZodRecord,...Ve(n)}):new co({keyType:Kr.create(),valueType:e,typeName:Ee.ZodRecord,...Ve(t)})}}class kc extends qe{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!==ie.map)return X(n,{code:F.invalid_type,expected:ie.map,received:n.parsedType}),ke;const i=this._def.keyType,s=this._def.valueType,o=[...n.data.entries()].map(([c,u],h)=>({key:i._parse(new an(n,c,n.path,[h,"key"])),value:s._parse(new an(n,u,n.path,[h,"value"]))}));if(n.common.async){const c=new Map;return Promise.resolve().then(async()=>{for(const u of o){const h=await u.key,m=await u.value;if(h.status==="aborted"||m.status==="aborted")return ke;(h.status==="dirty"||m.status==="dirty")&&t.dirty(),c.set(h.value,m.value)}return{status:t.value,value:c}})}else{const c=new Map;for(const u of o){const h=u.key,m=u.value;if(h.status==="aborted"||m.status==="aborted")return ke;(h.status==="dirty"||m.status==="dirty")&&t.dirty(),c.set(h.value,m.value)}return{status:t.value,value:c}}}}kc.create=(r,e,t)=>new kc({valueType:e,keyType:r,typeName:Ee.ZodMap,...Ve(t)});class Ii extends qe{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==ie.set)return X(n,{code:F.invalid_type,expected:ie.set,received:n.parsedType}),ke;const i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(X(n,{code:F.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&&(X(n,{code:F.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 h=new Set;for(const m of u){if(m.status==="aborted")return ke;m.status==="dirty"&&t.dirty(),h.add(m.value)}return{status:t.value,value:h}}const c=[...n.data.values()].map((u,h)=>s._parse(new an(n,u,n.path,h)));return n.common.async?Promise.all(c).then(u=>o(u)):o(c)}min(e,t){return new Ii({...this._def,minSize:{value:e,message:xe.toString(t)}})}max(e,t){return new Ii({...this._def,maxSize:{value:e,message:xe.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}Ii.create=(r,e)=>new Ii({valueType:r,minSize:null,maxSize:null,typeName:Ee.ZodSet,...Ve(e)});class cs extends qe{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==ie.function)return X(t,{code:F.invalid_type,expected:ie.function,received:t.parsedType}),ke;function n(c,u){return Ac({data:c,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,xc(),is].filter(h=>!!h),issueData:{code:F.invalid_arguments,argumentsError:u}})}function i(c,u){return Ac({data:c,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,xc(),is].filter(h=>!!h),issueData:{code:F.invalid_return_type,returnTypeError:u}})}const s={errorMap:t.common.contextualErrorMap},o=t.data;if(this._def.returns instanceof ls){const c=this;return hr(async function(...u){const h=new kr([]),m=await c._def.args.parseAsync(u,s).catch(N=>{throw h.addIssue(n(u,N)),h}),x=await Reflect.apply(o,this,m);return await c._def.returns._def.type.parseAsync(x,s).catch(N=>{throw h.addIssue(i(x,N)),h})})}else{const c=this;return hr(function(...u){const h=c._def.args.safeParse(u,s);if(!h.success)throw new kr([n(u,h.error)]);const m=Reflect.apply(o,this,h.data),x=c._def.returns.safeParse(m,s);if(!x.success)throw new kr([i(m,x.error)]);return x.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new cs({...this._def,args:cn.create(e).rest(Ei.create())})}returns(e){return new cs({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new cs({args:e||cn.create([]).rest(Ei.create()),returns:t||Ei.create(),typeName:Ee.ZodFunction,...Ve(n)})}}class lo extends qe{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})}}lo.create=(r,e)=>new lo({getter:r,typeName:Ee.ZodLazy,...Ve(e)});class uo extends qe{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return X(t,{received:t.data,code:F.invalid_literal,expected:this._def.value}),ke}return{status:"valid",value:e.data}}get value(){return this._def.value}}uo.create=(r,e)=>new uo({value:r,typeName:Ee.ZodLiteral,...Ve(e)});function S0(r,e){return new Yn({values:r,typeName:Ee.ZodEnum,...Ve(e)})}class Yn extends qe{constructor(){super(...arguments),to.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return X(t,{expected:ot.joinValues(n),received:t.parsedType,code:F.invalid_type}),ke}if(Sc(this,to)||m0(this,to,new Set(this._def.values)),!Sc(this,to).has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return X(t,{received:t.data,code:F.invalid_enum_value,options:n}),ke}return hr(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 Yn.create(e,{...this._def,...t})}exclude(e,t=this._def){return Yn.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}}to=new WeakMap,Yn.create=S0;class fo extends qe{constructor(){super(...arguments),ro.set(this,void 0)}_parse(e){const t=ot.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==ie.string&&n.parsedType!==ie.number){const i=ot.objectValues(t);return X(n,{expected:ot.joinValues(i),received:n.parsedType,code:F.invalid_type}),ke}if(Sc(this,ro)||m0(this,ro,new Set(ot.getValidEnumValues(this._def.values))),!Sc(this,ro).has(e.data)){const i=ot.objectValues(t);return X(n,{received:n.data,code:F.invalid_enum_value,options:i}),ke}return hr(e.data)}get enum(){return this._def.values}}ro=new WeakMap,fo.create=(r,e)=>new fo({values:r,typeName:Ee.ZodNativeEnum,...Ve(e)});class ls extends qe{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==ie.promise&&t.common.async===!1)return X(t,{code:F.invalid_type,expected:ie.promise,received:t.parsedType}),ke;const n=t.parsedType===ie.promise?t.data:Promise.resolve(t.data);return hr(n.then(i=>this._def.type.parseAsync(i,{path:t.path,errorMap:t.common.contextualErrorMap})))}}ls.create=(r,e)=>new ls({type:r,typeName:Ee.ZodPromise,...Ve(e)});class Wr extends qe{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Ee.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=>{X(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 ke;const u=await this._def.schema._parseAsync({data:c,path:n.path,parent:n});return u.status==="aborted"?ke:u.status==="dirty"||t.value==="dirty"?ss(u.value):u});{if(t.value==="aborted")return ke;const c=this._def.schema._parseSync({data:o,path:n.path,parent:n});return c.status==="aborted"?ke:c.status==="dirty"||t.value==="dirty"?ss(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"?ke:(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"?ke:(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(!Qs(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=>Qs(o)?Promise.resolve(i.transform(o.value,s)).then(c=>({status:t.value,value:c})):o);ot.assertNever(i)}}Wr.create=(r,e,t)=>new Wr({schema:r,typeName:Ee.ZodEffects,effect:e,...Ve(t)}),Wr.createWithPreprocess=(r,e,t)=>new Wr({schema:e,effect:{type:"preprocess",transform:r},typeName:Ee.ZodEffects,...Ve(t)});class ln extends qe{_parse(e){return this._getType(e)===ie.undefined?hr(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ln.create=(r,e)=>new ln({innerType:r,typeName:Ee.ZodOptional,...Ve(e)});class Jn extends qe{_parse(e){return this._getType(e)===ie.null?hr(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Jn.create=(r,e)=>new Jn({innerType:r,typeName:Ee.ZodNullable,...Ve(e)});class ho extends qe{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===ie.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}ho.create=(r,e)=>new ho({innerType:r,typeName:Ee.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...Ve(e)});class po extends qe{_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 eo(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}}po.create=(r,e)=>new po({innerType:r,typeName:Ee.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...Ve(e)});class Cc extends qe{_parse(e){if(this._getType(e)!==ie.nan){const n=this._getOrReturnCtx(e);return X(n,{code:F.invalid_type,expected:ie.nan,received:n.parsedType}),ke}return{status:"valid",value:e.data}}}Cc.create=r=>new Cc({typeName:Ee.ZodNaN,...Ve(r)});const Cm=Symbol("zod_brand");class bf extends qe{_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 yo extends qe{_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"?ke:s.status==="dirty"?(t.dirty(),ss(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"?ke: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 yo({in:e,out:t,typeName:Ee.ZodPipeline})}}class go extends qe{_parse(e){const t=this._def.innerType._parse(e),n=i=>(Qs(i)&&(i.value=Object.freeze(i.value)),i);return eo(t)?t.then(i=>n(i)):n(t)}unwrap(){return this._def.innerType}}go.create=(r,e)=>new go({innerType:r,typeName:Ee.ZodReadonly,...Ve(e)});function _0(r,e={},t){return r?os.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,h=typeof c=="string"?{message:c}:c;i.addIssue({code:"custom",...h,fatal:u})}}):os.create()}const Bm={object:Ot.lazycreate};var Ee;(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"})(Ee||(Ee={}));const Om=(r,e={message:`Input not instance of ${r.name}`})=>_0(t=>t instanceof r,e),E0=Kr.create,I0=Zn.create,Tm=Cc.create,Nm=Wn.create,k0=no.create,Pm=_i.create,jm=_c.create,Rm=io.create,Um=so.create,Dm=os.create,$m=Ei.create,Mm=Bn.create,Vm=Ec.create,Lm=Zr.create,Hm=Ot.create,Fm=Ot.strictCreate,zm=oo.create,Gm=Ic.create,qm=ao.create,Km=cn.create,Zm=co.create,Wm=kc.create,Ym=Ii.create,Jm=cs.create,Xm=lo.create,Qm=uo.create,e1=Yn.create,t1=fo.create,r1=ls.create,C0=Wr.create,n1=ln.create,i1=Jn.create,s1=Wr.createWithPreprocess,o1=yo.create;var Tt=Object.freeze({__proto__:null,defaultErrorMap:is,setErrorMap:fm,getErrorMap:xc,makeIssue:Ac,EMPTY_PATH:hm,addIssueToContext:X,ParseStatus:ir,INVALID:ke,DIRTY:ss,OK:hr,isAborted:gf,isDirty:vf,isValid:Qs,isAsync:eo,get util(){return ot},get objectUtil(){return yf},ZodParsedType:ie,getParsedType:Kn,ZodType:qe,datetimeRegex:A0,ZodString:Kr,ZodNumber:Zn,ZodBigInt:Wn,ZodBoolean:no,ZodDate:_i,ZodSymbol:_c,ZodUndefined:io,ZodNull:so,ZodAny:os,ZodUnknown:Ei,ZodNever:Bn,ZodVoid:Ec,ZodArray:Zr,ZodObject:Ot,ZodUnion:oo,ZodDiscriminatedUnion:Ic,ZodIntersection:ao,ZodTuple:cn,ZodRecord:co,ZodMap:kc,ZodSet:Ii,ZodFunction:cs,ZodLazy:lo,ZodLiteral:uo,ZodEnum:Yn,ZodNativeEnum:fo,ZodPromise:ls,ZodEffects:Wr,ZodTransformer:Wr,ZodOptional:ln,ZodNullable:Jn,ZodDefault:ho,ZodCatch:po,ZodNaN:Cc,BRAND:Cm,ZodBranded:bf,ZodPipeline:yo,ZodReadonly:go,custom:_0,Schema:qe,ZodSchema:qe,late:Bm,get ZodFirstPartyTypeKind(){return Ee},coerce:{string:r=>Kr.create({...r,coerce:!0}),number:r=>Zn.create({...r,coerce:!0}),boolean:r=>no.create({...r,coerce:!0}),bigint:r=>Wn.create({...r,coerce:!0}),date:r=>_i.create({...r,coerce:!0})},any:Dm,array:Lm,bigint:Nm,boolean:k0,date:Pm,discriminatedUnion:Gm,effect:C0,enum:e1,function:Jm,instanceof:Om,intersection:qm,lazy:Xm,literal:Qm,map:Wm,nan:Tm,nativeEnum:t1,never:Mm,null:Um,nullable:i1,number:I0,object:Hm,oboolean:()=>k0().optional(),onumber:()=>I0().optional(),optional:n1,ostring:()=>E0().optional(),pipeline:o1,preprocess:s1,promise:r1,record:Zm,set:Ym,strictObject:Fm,string:E0,symbol:jm,transformer:C0,tuple:Km,undefined:Rm,union:zm,unknown:$m,void:Vm,NEVER:ke,ZodIssueCode:F,quotelessJson:um,ZodError:kr});const Bc=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(!Bc||Bc.length===0)throw new Error("AWS root certificate is empty or not loaded correctly");const a1=Tt.object({module_id:Tt.string().min(1),digest:Tt.literal("SHA384"),timestamp:Tt.number().min(1677721600),pcrs:Tt.map(Tt.number(),Tt.instanceof(Uint8Array)),certificate:Tt.instanceof(Uint8Array),cabundle:Tt.array(Tt.instanceof(Uint8Array)),public_key:Tt.nullable(Tt.instanceof(Uint8Array)),user_data:Tt.nullable(Tt.instanceof(Uint8Array)),nonce:Tt.nullable(Tt.instanceof(Uint8Array))}),c1=Tt.object({protected:Tt.instanceof(Uint8Array),payload:Tt.instanceof(Uint8Array),signature:Tt.instanceof(Uint8Array)});async function l1(r){try{if(!r)throw new Error("Attestation document is empty.");const e=gs(r),t=bc(e),n=t[0],i=t[2],s=t[3];return c1.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 u1(r){try{const e=bc(r);return a1.parse(e)}catch(e){throw console.error("Error parsing document payload:",e),new Error("Failed to parse document payload.")}}function f1(r,e){const t=["Signature1",r,new Uint8Array(0),e];return gc(t)}async function h1(r,e){try{console.log("SIGNATURE:"),console.log($r(r.signature));const t=f1(r.protected,r.payload),n=await crypto.subtle.digest("SHA-384",t);return console.log("SIGNATURE STRUCTURE DIGEST:"),console.log($r(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 ki(r,e,t){try{const n=await l1(r),i=await u1(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=$r(i.cabundle[0]);if(u!==$r(e))throw console.error("Root cert doesn't match first cert"),console.log("First cert base64:",u),console.log("Trusted root cert base64:",$r(e)),new Error("Root cert does not match first cert in attestation document.");for(let I=0;I<i.cabundle.length;I++){const P=new xi(i.cabundle[I]);c.push(P)}const h=new xi(i.certificate),x=await new Uv({certificates:c}).build(h);console.log("Chain items:",x);const N=new Date().getTime();for(let I=0;I<x.length;I++){const P=x[I];if(console.log("CERT: ",I),console.log(P.subject),console.log("Not before:",P.notBefore),console.log("Not after:",P.notAfter),console.log(P.toString("pem")),P.notBefore.getTime()>N||P.notAfter.getTime()<N)throw new Error("Certificate is expired.");console.log(`Certificate ${I} is not expired.`)}if(x.length!==i.cabundle.length+1)throw new Error("Certificate chain length does not match length of cabundle.");const v=h.publicKey;console.log("PUBLIC KEY:"),console.log($r(new Uint8Array(v.rawData)));const A=await v.export(),O=await h1(n,A);if(console.log("Signature verified:",O),!O)throw new Error("Signature verification failed.");return i}catch(n){throw console.error("Error verifying attestation document:",n),n}}const d1=Tt.object({public_key:Tt.nullable(Tt.instanceof(Uint8Array))});async function p1(r){const e=gs(r),n=bc(e)[2],i=bc(n);return await d1.parse(i)}async function y1(r,e){try{const t=await R1(r,e),n=e||C1();return n&&(n==="http://127.0.0.1:3000"||n==="http://localhost:3000"||n==="http://0.0.0.0:3000")?(console.log("DEV MODE: Using fake attestation document"),await p1(t)):await ki(t,Bc,r)}catch(t){throw t instanceof Error?(console.error("Error verifying attestation document:",t),new Error(`Couldn't process attestation document: ${t.message}`)):(console.error("Error verifying attestation document:",t),new Error("Couldn't process attestation document."))}}function g1(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 B0={exports:{}};const v1=Hy(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));(function(r){(function(e){var t=function(l){var p,d=new Float64Array(16);if(l)for(p=0;p<l.length;p++)d[p]=l[p];return d},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]),h=t([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),m=t([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),x=t([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),G=t([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),N=t([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function v(l,p,d,a){l[p]=d>>24&255,l[p+1]=d>>16&255,l[p+2]=d>>8&255,l[p+3]=d&255,l[p+4]=a>>24&255,l[p+5]=a>>16&255,l[p+6]=a>>8&255,l[p+7]=a&255}function A(l,p,d,a,g){var S,E=0;for(S=0;S<g;S++)E|=l[p+S]^d[a+S];return(1&E-1>>>8)-1}function O(l,p,d,a){return A(l,p,d,a,16)}function I(l,p,d,a){return A(l,p,d,a,32)}function P(l,p,d,a){for(var g=a[0]&255|(a[1]&255)<<8|(a[2]&255)<<16|(a[3]&255)<<24,S=d[0]&255|(d[1]&255)<<8|(d[2]&255)<<16|(d[3]&255)<<24,E=d[4]&255|(d[5]&255)<<8|(d[6]&255)<<16|(d[7]&255)<<24,U=d[8]&255|(d[9]&255)<<8|(d[10]&255)<<16|(d[11]&255)<<24,z=d[12]&255|(d[13]&255)<<8|(d[14]&255)<<16|(d[15]&255)<<24,we=a[4]&255|(a[5]&255)<<8|(a[6]&255)<<16|(a[7]&255)<<24,Q=p[0]&255|(p[1]&255)<<8|(p[2]&255)<<16|(p[3]&255)<<24,ft=p[4]&255|(p[5]&255)<<8|(p[6]&255)<<16|(p[7]&255)<<24,le=p[8]&255|(p[9]&255)<<8|(p[10]&255)<<16|(p[11]&255)<<24,Ce=p[12]&255|(p[13]&255)<<8|(p[14]&255)<<16|(p[15]&255)<<24,Be=a[8]&255|(a[9]&255)<<8|(a[10]&255)<<16|(a[11]&255)<<24,Le=d[16]&255|(d[17]&255)<<8|(d[18]&255)<<16|(d[19]&255)<<24,$e=d[20]&255|(d[21]&255)<<8|(d[22]&255)<<16|(d[23]&255)<<24,Oe=d[24]&255|(d[25]&255)<<8|(d[26]&255)<<16|(d[27]&255)<<24,Ne=d[28]&255|(d[29]&255)<<8|(d[30]&255)<<16|(d[31]&255)<<24,Te=a[12]&255|(a[13]&255)<<8|(a[14]&255)<<16|(a[15]&255)<<24,pe=g,Se=S,re=E,ye=U,me=z,J=we,C=Q,B=ft,V=le,j=Ce,D=Be,L=Le,_e=$e,He=Oe,Ge=Ne,Fe=Te,w,Ye=0;Ye<20;Ye+=2)w=pe+_e|0,me^=w<<7|w>>>25,w=me+pe|0,V^=w<<9|w>>>23,w=V+me|0,_e^=w<<13|w>>>19,w=_e+V|0,pe^=w<<18|w>>>14,w=J+Se|0,j^=w<<7|w>>>25,w=j+J|0,He^=w<<9|w>>>23,w=He+j|0,Se^=w<<13|w>>>19,w=Se+He|0,J^=w<<18|w>>>14,w=D+C|0,Ge^=w<<7|w>>>25,w=Ge+D|0,re^=w<<9|w>>>23,w=re+Ge|0,C^=w<<13|w>>>19,w=C+re|0,D^=w<<18|w>>>14,w=Fe+L|0,ye^=w<<7|w>>>25,w=ye+Fe|0,B^=w<<9|w>>>23,w=B+ye|0,L^=w<<13|w>>>19,w=L+B|0,Fe^=w<<18|w>>>14,w=pe+ye|0,Se^=w<<7|w>>>25,w=Se+pe|0,re^=w<<9|w>>>23,w=re+Se|0,ye^=w<<13|w>>>19,w=ye+re|0,pe^=w<<18|w>>>14,w=J+me|0,C^=w<<7|w>>>25,w=C+J|0,B^=w<<9|w>>>23,w=B+C|0,me^=w<<13|w>>>19,w=me+B|0,J^=w<<18|w>>>14,w=D+j|0,L^=w<<7|w>>>25,w=L+D|0,V^=w<<9|w>>>23,w=V+L|0,j^=w<<13|w>>>19,w=j+V|0,D^=w<<18|w>>>14,w=Fe+Ge|0,_e^=w<<7|w>>>25,w=_e+Fe|0,He^=w<<9|w>>>23,w=He+_e|0,Ge^=w<<13|w>>>19,w=Ge+He|0,Fe^=w<<18|w>>>14;pe=pe+g|0,Se=Se+S|0,re=re+E|0,ye=ye+U|0,me=me+z|0,J=J+we|0,C=C+Q|0,B=B+ft|0,V=V+le|0,j=j+Ce|0,D=D+Be|0,L=L+Le|0,_e=_e+$e|0,He=He+Oe|0,Ge=Ge+Ne|0,Fe=Fe+Te|0,l[0]=pe>>>0&255,l[1]=pe>>>8&255,l[2]=pe>>>16&255,l[3]=pe>>>24&255,l[4]=Se>>>0&255,l[5]=Se>>>8&255,l[6]=Se>>>16&255,l[7]=Se>>>24&255,l[8]=re>>>0&255,l[9]=re>>>8&255,l[10]=re>>>16&255,l[11]=re>>>24&255,l[12]=ye>>>0&255,l[13]=ye>>>8&255,l[14]=ye>>>16&255,l[15]=ye>>>24&255,l[16]=me>>>0&255,l[17]=me>>>8&255,l[18]=me>>>16&255,l[19]=me>>>24&255,l[20]=J>>>0&255,l[21]=J>>>8&255,l[22]=J>>>16&255,l[23]=J>>>24&255,l[24]=C>>>0&255,l[25]=C>>>8&255,l[26]=C>>>16&255,l[27]=C>>>24&255,l[28]=B>>>0&255,l[29]=B>>>8&255,l[30]=B>>>16&255,l[31]=B>>>24&255,l[32]=V>>>0&255,l[33]=V>>>8&255,l[34]=V>>>16&255,l[35]=V>>>24&255,l[36]=j>>>0&255,l[37]=j>>>8&255,l[38]=j>>>16&255,l[39]=j>>>24&255,l[40]=D>>>0&255,l[41]=D>>>8&255,l[42]=D>>>16&255,l[43]=D>>>24&255,l[44]=L>>>0&255,l[45]=L>>>8&255,l[46]=L>>>16&255,l[47]=L>>>24&255,l[48]=_e>>>0&255,l[49]=_e>>>8&255,l[50]=_e>>>16&255,l[51]=_e>>>24&255,l[52]=He>>>0&255,l[53]=He>>>8&255,l[54]=He>>>16&255,l[55]=He>>>24&255,l[56]=Ge>>>0&255,l[57]=Ge>>>8&255,l[58]=Ge>>>16&255,l[59]=Ge>>>24&255,l[60]=Fe>>>0&255,l[61]=Fe>>>8&255,l[62]=Fe>>>16&255,l[63]=Fe>>>24&255}function R(l,p,d,a){for(var g=a[0]&255|(a[1]&255)<<8|(a[2]&255)<<16|(a[3]&255)<<24,S=d[0]&255|(d[1]&255)<<8|(d[2]&255)<<16|(d[3]&255)<<24,E=d[4]&255|(d[5]&255)<<8|(d[6]&255)<<16|(d[7]&255)<<24,U=d[8]&255|(d[9]&255)<<8|(d[10]&255)<<16|(d[11]&255)<<24,z=d[12]&255|(d[13]&255)<<8|(d[14]&255)<<16|(d[15]&255)<<24,we=a[4]&255|(a[5]&255)<<8|(a[6]&255)<<16|(a[7]&255)<<24,Q=p[0]&255|(p[1]&255)<<8|(p[2]&255)<<16|(p[3]&255)<<24,ft=p[4]&255|(p[5]&255)<<8|(p[6]&255)<<16|(p[7]&255)<<24,le=p[8]&255|(p[9]&255)<<8|(p[10]&255)<<16|(p[11]&255)<<24,Ce=p[12]&255|(p[13]&255)<<8|(p[14]&255)<<16|(p[15]&255)<<24,Be=a[8]&255|(a[9]&255)<<8|(a[10]&255)<<16|(a[11]&255)<<24,Le=d[16]&255|(d[17]&255)<<8|(d[18]&255)<<16|(d[19]&255)<<24,$e=d[20]&255|(d[21]&255)<<8|(d[22]&255)<<16|(d[23]&255)<<24,Oe=d[24]&255|(d[25]&255)<<8|(d[26]&255)<<16|(d[27]&255)<<24,Ne=d[28]&255|(d[29]&255)<<8|(d[30]&255)<<16|(d[31]&255)<<24,Te=a[12]&255|(a[13]&255)<<8|(a[14]&255)<<16|(a[15]&255)<<24,pe=g,Se=S,re=E,ye=U,me=z,J=we,C=Q,B=ft,V=le,j=Ce,D=Be,L=Le,_e=$e,He=Oe,Ge=Ne,Fe=Te,w,Ye=0;Ye<20;Ye+=2)w=pe+_e|0,me^=w<<7|w>>>25,w=me+pe|0,V^=w<<9|w>>>23,w=V+me|0,_e^=w<<13|w>>>19,w=_e+V|0,pe^=w<<18|w>>>14,w=J+Se|0,j^=w<<7|w>>>25,w=j+J|0,He^=w<<9|w>>>23,w=He+j|0,Se^=w<<13|w>>>19,w=Se+He|0,J^=w<<18|w>>>14,w=D+C|0,Ge^=w<<7|w>>>25,w=Ge+D|0,re^=w<<9|w>>>23,w=re+Ge|0,C^=w<<13|w>>>19,w=C+re|0,D^=w<<18|w>>>14,w=Fe+L|0,ye^=w<<7|w>>>25,w=ye+Fe|0,B^=w<<9|w>>>23,w=B+ye|0,L^=w<<13|w>>>19,w=L+B|0,Fe^=w<<18|w>>>14,w=pe+ye|0,Se^=w<<7|w>>>25,w=Se+pe|0,re^=w<<9|w>>>23,w=re+Se|0,ye^=w<<13|w>>>19,w=ye+re|0,pe^=w<<18|w>>>14,w=J+me|0,C^=w<<7|w>>>25,w=C+J|0,B^=w<<9|w>>>23,w=B+C|0,me^=w<<13|w>>>19,w=me+B|0,J^=w<<18|w>>>14,w=D+j|0,L^=w<<7|w>>>25,w=L+D|0,V^=w<<9|w>>>23,w=V+L|0,j^=w<<13|w>>>19,w=j+V|0,D^=w<<18|w>>>14,w=Fe+Ge|0,_e^=w<<7|w>>>25,w=_e+Fe|0,He^=w<<9|w>>>23,w=He+_e|0,Ge^=w<<13|w>>>19,w=Ge+He|0,Fe^=w<<18|w>>>14;l[0]=pe>>>0&255,l[1]=pe>>>8&255,l[2]=pe>>>16&255,l[3]=pe>>>24&255,l[4]=J>>>0&255,l[5]=J>>>8&255,l[6]=J>>>16&255,l[7]=J>>>24&255,l[8]=D>>>0&255,l[9]=D>>>8&255,l[10]=D>>>16&255,l[11]=D>>>24&255,l[12]=Fe>>>0&255,l[13]=Fe>>>8&255,l[14]=Fe>>>16&255,l[15]=Fe>>>24&255,l[16]=C>>>0&255,l[17]=C>>>8&255,l[18]=C>>>16&255,l[19]=C>>>24&255,l[20]=B>>>0&255,l[21]=B>>>8&255,l[22]=B>>>16&255,l[23]=B>>>24&255,l[24]=V>>>0&255,l[25]=V>>>8&255,l[26]=V>>>16&255,l[27]=V>>>24&255,l[28]=j>>>0&255,l[29]=j>>>8&255,l[30]=j>>>16&255,l[31]=j>>>24&255}function fe(l,p,d,a){P(l,p,d,a)}function Ke(l,p,d,a){R(l,p,d,a)}var Je=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function Ue(l,p,d,a,g,S,E){var U=new Uint8Array(16),z=new Uint8Array(64),we,Q;for(Q=0;Q<16;Q++)U[Q]=0;for(Q=0;Q<8;Q++)U[Q]=S[Q];for(;g>=64;){for(fe(z,U,E,Je),Q=0;Q<64;Q++)l[p+Q]=d[a+Q]^z[Q];for(we=1,Q=8;Q<16;Q++)we=we+(U[Q]&255)|0,U[Q]=we&255,we>>>=8;g-=64,p+=64,a+=64}if(g>0)for(fe(z,U,E,Je),Q=0;Q<g;Q++)l[p+Q]=d[a+Q]^z[Q];return 0}function W(l,p,d,a,g){var S=new Uint8Array(16),E=new Uint8Array(64),U,z;for(z=0;z<16;z++)S[z]=0;for(z=0;z<8;z++)S[z]=a[z];for(;d>=64;){for(fe(E,S,g,Je),z=0;z<64;z++)l[p+z]=E[z];for(U=1,z=8;z<16;z++)U=U+(S[z]&255)|0,S[z]=U&255,U>>>=8;d-=64,p+=64}if(d>0)for(fe(E,S,g,Je),z=0;z<d;z++)l[p+z]=E[z];return 0}function se(l,p,d,a,g){var S=new Uint8Array(32);Ke(S,a,g,Je);for(var E=new Uint8Array(8),U=0;U<8;U++)E[U]=a[U+16];return W(l,p,d,E,S)}function oe(l,p,d,a,g,S,E){var U=new Uint8Array(32);Ke(U,S,E,Je);for(var z=new Uint8Array(8),we=0;we<8;we++)z[we]=S[we+16];return Ue(l,p,d,a,g,z,U)}var Ae=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 p,d,a,g,S,E,U,z;p=l[0]&255|(l[1]&255)<<8,this.r[0]=p&8191,d=l[2]&255|(l[3]&255)<<8,this.r[1]=(p>>>13|d<<3)&8191,a=l[4]&255|(l[5]&255)<<8,this.r[2]=(d>>>10|a<<6)&7939,g=l[6]&255|(l[7]&255)<<8,this.r[3]=(a>>>7|g<<9)&8191,S=l[8]&255|(l[9]&255)<<8,this.r[4]=(g>>>4|S<<12)&255,this.r[5]=S>>>1&8190,E=l[10]&255|(l[11]&255)<<8,this.r[6]=(S>>>14|E<<2)&8191,U=l[12]&255|(l[13]&255)<<8,this.r[7]=(E>>>11|U<<5)&8065,z=l[14]&255|(l[15]&255)<<8,this.r[8]=(U>>>8|z<<8)&8191,this.r[9]=z>>>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};Ae.prototype.blocks=function(l,p,d){for(var a=this.fin?0:2048,g,S,E,U,z,we,Q,ft,le,Ce,Be,Le,$e,Oe,Ne,Te,pe,Se,re,ye=this.h[0],me=this.h[1],J=this.h[2],C=this.h[3],B=this.h[4],V=this.h[5],j=this.h[6],D=this.h[7],L=this.h[8],_e=this.h[9],He=this.r[0],Ge=this.r[1],Fe=this.r[2],w=this.r[3],Ye=this.r[4],ht=this.r[5],dt=this.r[6],Ze=this.r[7],lt=this.r[8],ut=this.r[9];d>=16;)g=l[p+0]&255|(l[p+1]&255)<<8,ye+=g&8191,S=l[p+2]&255|(l[p+3]&255)<<8,me+=(g>>>13|S<<3)&8191,E=l[p+4]&255|(l[p+5]&255)<<8,J+=(S>>>10|E<<6)&8191,U=l[p+6]&255|(l[p+7]&255)<<8,C+=(E>>>7|U<<9)&8191,z=l[p+8]&255|(l[p+9]&255)<<8,B+=(U>>>4|z<<12)&8191,V+=z>>>1&8191,we=l[p+10]&255|(l[p+11]&255)<<8,j+=(z>>>14|we<<2)&8191,Q=l[p+12]&255|(l[p+13]&255)<<8,D+=(we>>>11|Q<<5)&8191,ft=l[p+14]&255|(l[p+15]&255)<<8,L+=(Q>>>8|ft<<8)&8191,_e+=ft>>>5|a,le=0,Ce=le,Ce+=ye*He,Ce+=me*(5*ut),Ce+=J*(5*lt),Ce+=C*(5*Ze),Ce+=B*(5*dt),le=Ce>>>13,Ce&=8191,Ce+=V*(5*ht),Ce+=j*(5*Ye),Ce+=D*(5*w),Ce+=L*(5*Fe),Ce+=_e*(5*Ge),le+=Ce>>>13,Ce&=8191,Be=le,Be+=ye*Ge,Be+=me*He,Be+=J*(5*ut),Be+=C*(5*lt),Be+=B*(5*Ze),le=Be>>>13,Be&=8191,Be+=V*(5*dt),Be+=j*(5*ht),Be+=D*(5*Ye),Be+=L*(5*w),Be+=_e*(5*Fe),le+=Be>>>13,Be&=8191,Le=le,Le+=ye*Fe,Le+=me*Ge,Le+=J*He,Le+=C*(5*ut),Le+=B*(5*lt),le=Le>>>13,Le&=8191,Le+=V*(5*Ze),Le+=j*(5*dt),Le+=D*(5*ht),Le+=L*(5*Ye),Le+=_e*(5*w),le+=Le>>>13,Le&=8191,$e=le,$e+=ye*w,$e+=me*Fe,$e+=J*Ge,$e+=C*He,$e+=B*(5*ut),le=$e>>>13,$e&=8191,$e+=V*(5*lt),$e+=j*(5*Ze),$e+=D*(5*dt),$e+=L*(5*ht),$e+=_e*(5*Ye),le+=$e>>>13,$e&=8191,Oe=le,Oe+=ye*Ye,Oe+=me*w,Oe+=J*Fe,Oe+=C*Ge,Oe+=B*He,le=Oe>>>13,Oe&=8191,Oe+=V*(5*ut),Oe+=j*(5*lt),Oe+=D*(5*Ze),Oe+=L*(5*dt),Oe+=_e*(5*ht),le+=Oe>>>13,Oe&=8191,Ne=le,Ne+=ye*ht,Ne+=me*Ye,Ne+=J*w,Ne+=C*Fe,Ne+=B*Ge,le=Ne>>>13,Ne&=8191,Ne+=V*He,Ne+=j*(5*ut),Ne+=D*(5*lt),Ne+=L*(5*Ze),Ne+=_e*(5*dt),le+=Ne>>>13,Ne&=8191,Te=le,Te+=ye*dt,Te+=me*ht,Te+=J*Ye,Te+=C*w,Te+=B*Fe,le=Te>>>13,Te&=8191,Te+=V*Ge,Te+=j*He,Te+=D*(5*ut),Te+=L*(5*lt),Te+=_e*(5*Ze),le+=Te>>>13,Te&=8191,pe=le,pe+=ye*Ze,pe+=me*dt,pe+=J*ht,pe+=C*Ye,pe+=B*w,le=pe>>>13,pe&=8191,pe+=V*Fe,pe+=j*Ge,pe+=D*He,pe+=L*(5*ut),pe+=_e*(5*lt),le+=pe>>>13,pe&=8191,Se=le,Se+=ye*lt,Se+=me*Ze,Se+=J*dt,Se+=C*ht,Se+=B*Ye,le=Se>>>13,Se&=8191,Se+=V*w,Se+=j*Fe,Se+=D*Ge,Se+=L*He,Se+=_e*(5*ut),le+=Se>>>13,Se&=8191,re=le,re+=ye*ut,re+=me*lt,re+=J*Ze,re+=C*dt,re+=B*ht,le=re>>>13,re&=8191,re+=V*Ye,re+=j*w,re+=D*Fe,re+=L*Ge,re+=_e*He,le+=re>>>13,re&=8191,le=(le<<2)+le|0,le=le+Ce|0,Ce=le&8191,le=le>>>13,Be+=le,ye=Ce,me=Be,J=Le,C=$e,B=Oe,V=Ne,j=Te,D=pe,L=Se,_e=re,p+=16,d-=16;this.h[0]=ye,this.h[1]=me,this.h[2]=J,this.h[3]=C,this.h[4]=B,this.h[5]=V,this.h[6]=j,this.h[7]=D,this.h[8]=L,this.h[9]=_e},Ae.prototype.finish=function(l,p){var d=new Uint16Array(10),a,g,S,E;if(this.leftover){for(E=this.leftover,this.buffer[E++]=1;E<16;E++)this.buffer[E]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(a=this.h[1]>>>13,this.h[1]&=8191,E=2;E<10;E++)this.h[E]+=a,a=this.h[E]>>>13,this.h[E]&=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,d[0]=this.h[0]+5,a=d[0]>>>13,d[0]&=8191,E=1;E<10;E++)d[E]=this.h[E]+a,a=d[E]>>>13,d[E]&=8191;for(d[9]-=8192,g=(a^1)-1,E=0;E<10;E++)d[E]&=g;for(g=~g,E=0;E<10;E++)this.h[E]=this.h[E]&g|d[E];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,S=this.h[0]+this.pad[0],this.h[0]=S&65535,E=1;E<8;E++)S=(this.h[E]+this.pad[E]|0)+(S>>>16)|0,this.h[E]=S&65535;l[p+0]=this.h[0]>>>0&255,l[p+1]=this.h[0]>>>8&255,l[p+2]=this.h[1]>>>0&255,l[p+3]=this.h[1]>>>8&255,l[p+4]=this.h[2]>>>0&255,l[p+5]=this.h[2]>>>8&255,l[p+6]=this.h[3]>>>0&255,l[p+7]=this.h[3]>>>8&255,l[p+8]=this.h[4]>>>0&255,l[p+9]=this.h[4]>>>8&255,l[p+10]=this.h[5]>>>0&255,l[p+11]=this.h[5]>>>8&255,l[p+12]=this.h[6]>>>0&255,l[p+13]=this.h[6]>>>8&255,l[p+14]=this.h[7]>>>0&255,l[p+15]=this.h[7]>>>8&255},Ae.prototype.update=function(l,p,d){var a,g;if(this.leftover){for(g=16-this.leftover,g>d&&(g=d),a=0;a<g;a++)this.buffer[this.leftover+a]=l[p+a];if(d-=g,p+=g,this.leftover+=g,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(d>=16&&(g=d-d%16,this.blocks(l,p,g),p+=g,d-=g),d){for(a=0;a<d;a++)this.buffer[this.leftover+a]=l[p+a];this.leftover+=d}};function it(l,p,d,a,g,S){var E=new Ae(S);return E.update(d,a,g),E.finish(l,p),0}function It(l,p,d,a,g,S){var E=new Uint8Array(16);return it(E,0,d,a,g,S),O(l,p,E,0)}function Pt(l,p,d,a,g){var S;if(d<32)return-1;for(oe(l,0,p,0,d,a,g),it(l,16,l,32,d-32,l),S=0;S<16;S++)l[S]=0;return 0}function gt(l,p,d,a,g){var S,E=new Uint8Array(32);if(d<32||(se(E,0,32,a,g),It(p,16,p,32,d-32,E)!==0))return-1;for(oe(l,0,p,0,d,a,g),S=0;S<32;S++)l[S]=0;return 0}function et(l,p){var d;for(d=0;d<16;d++)l[d]=p[d]|0}function ce(l){var p,d,a=1;for(p=0;p<16;p++)d=l[p]+a+65535,a=Math.floor(d/65536),l[p]=d-a*65536;l[0]+=a-1+37*(a-1)}function Ie(l,p,d){for(var a,g=~(d-1),S=0;S<16;S++)a=g&(l[S]^p[S]),l[S]^=a,p[S]^=a}function wt(l,p){var d,a,g,S=t(),E=t();for(d=0;d<16;d++)E[d]=p[d];for(ce(E),ce(E),ce(E),a=0;a<2;a++){for(S[0]=E[0]-65517,d=1;d<15;d++)S[d]=E[d]-65535-(S[d-1]>>16&1),S[d-1]&=65535;S[15]=E[15]-32767-(S[14]>>16&1),g=S[15]>>16&1,S[14]&=65535,Ie(E,S,1-g)}for(d=0;d<16;d++)l[2*d]=E[d]&255,l[2*d+1]=E[d]>>8}function Vt(l,p){var d=new Uint8Array(32),a=new Uint8Array(32);return wt(d,l),wt(a,p),I(d,0,a,0)}function Lt(l){var p=new Uint8Array(32);return wt(p,l),p[0]&1}function he(l,p){var d;for(d=0;d<16;d++)l[d]=p[2*d]+(p[2*d+1]<<8);l[15]&=32767}function ct(l,p,d){for(var a=0;a<16;a++)l[a]=p[a]+d[a]}function bt(l,p,d){for(var a=0;a<16;a++)l[a]=p[a]-d[a]}function ee(l,p,d){var a,g,S=0,E=0,U=0,z=0,we=0,Q=0,ft=0,le=0,Ce=0,Be=0,Le=0,$e=0,Oe=0,Ne=0,Te=0,pe=0,Se=0,re=0,ye=0,me=0,J=0,C=0,B=0,V=0,j=0,D=0,L=0,_e=0,He=0,Ge=0,Fe=0,w=d[0],Ye=d[1],ht=d[2],dt=d[3],Ze=d[4],lt=d[5],ut=d[6],Ht=d[7],At=d[8],Ut=d[9],Dt=d[10],$t=d[11],qt=d[12],sr=d[13],or=d[14],ar=d[15];a=p[0],S+=a*w,E+=a*Ye,U+=a*ht,z+=a*dt,we+=a*Ze,Q+=a*lt,ft+=a*ut,le+=a*Ht,Ce+=a*At,Be+=a*Ut,Le+=a*Dt,$e+=a*$t,Oe+=a*qt,Ne+=a*sr,Te+=a*or,pe+=a*ar,a=p[1],E+=a*w,U+=a*Ye,z+=a*ht,we+=a*dt,Q+=a*Ze,ft+=a*lt,le+=a*ut,Ce+=a*Ht,Be+=a*At,Le+=a*Ut,$e+=a*Dt,Oe+=a*$t,Ne+=a*qt,Te+=a*sr,pe+=a*or,Se+=a*ar,a=p[2],U+=a*w,z+=a*Ye,we+=a*ht,Q+=a*dt,ft+=a*Ze,le+=a*lt,Ce+=a*ut,Be+=a*Ht,Le+=a*At,$e+=a*Ut,Oe+=a*Dt,Ne+=a*$t,Te+=a*qt,pe+=a*sr,Se+=a*or,re+=a*ar,a=p[3],z+=a*w,we+=a*Ye,Q+=a*ht,ft+=a*dt,le+=a*Ze,Ce+=a*lt,Be+=a*ut,Le+=a*Ht,$e+=a*At,Oe+=a*Ut,Ne+=a*Dt,Te+=a*$t,pe+=a*qt,Se+=a*sr,re+=a*or,ye+=a*ar,a=p[4],we+=a*w,Q+=a*Ye,ft+=a*ht,le+=a*dt,Ce+=a*Ze,Be+=a*lt,Le+=a*ut,$e+=a*Ht,Oe+=a*At,Ne+=a*Ut,Te+=a*Dt,pe+=a*$t,Se+=a*qt,re+=a*sr,ye+=a*or,me+=a*ar,a=p[5],Q+=a*w,ft+=a*Ye,le+=a*ht,Ce+=a*dt,Be+=a*Ze,Le+=a*lt,$e+=a*ut,Oe+=a*Ht,Ne+=a*At,Te+=a*Ut,pe+=a*Dt,Se+=a*$t,re+=a*qt,ye+=a*sr,me+=a*or,J+=a*ar,a=p[6],ft+=a*w,le+=a*Ye,Ce+=a*ht,Be+=a*dt,Le+=a*Ze,$e+=a*lt,Oe+=a*ut,Ne+=a*Ht,Te+=a*At,pe+=a*Ut,Se+=a*Dt,re+=a*$t,ye+=a*qt,me+=a*sr,J+=a*or,C+=a*ar,a=p[7],le+=a*w,Ce+=a*Ye,Be+=a*ht,Le+=a*dt,$e+=a*Ze,Oe+=a*lt,Ne+=a*ut,Te+=a*Ht,pe+=a*At,Se+=a*Ut,re+=a*Dt,ye+=a*$t,me+=a*qt,J+=a*sr,C+=a*or,B+=a*ar,a=p[8],Ce+=a*w,Be+=a*Ye,Le+=a*ht,$e+=a*dt,Oe+=a*Ze,Ne+=a*lt,Te+=a*ut,pe+=a*Ht,Se+=a*At,re+=a*Ut,ye+=a*Dt,me+=a*$t,J+=a*qt,C+=a*sr,B+=a*or,V+=a*ar,a=p[9],Be+=a*w,Le+=a*Ye,$e+=a*ht,Oe+=a*dt,Ne+=a*Ze,Te+=a*lt,pe+=a*ut,Se+=a*Ht,re+=a*At,ye+=a*Ut,me+=a*Dt,J+=a*$t,C+=a*qt,B+=a*sr,V+=a*or,j+=a*ar,a=p[10],Le+=a*w,$e+=a*Ye,Oe+=a*ht,Ne+=a*dt,Te+=a*Ze,pe+=a*lt,Se+=a*ut,re+=a*Ht,ye+=a*At,me+=a*Ut,J+=a*Dt,C+=a*$t,B+=a*qt,V+=a*sr,j+=a*or,D+=a*ar,a=p[11],$e+=a*w,Oe+=a*Ye,Ne+=a*ht,Te+=a*dt,pe+=a*Ze,Se+=a*lt,re+=a*ut,ye+=a*Ht,me+=a*At,J+=a*Ut,C+=a*Dt,B+=a*$t,V+=a*qt,j+=a*sr,D+=a*or,L+=a*ar,a=p[12],Oe+=a*w,Ne+=a*Ye,Te+=a*ht,pe+=a*dt,Se+=a*Ze,re+=a*lt,ye+=a*ut,me+=a*Ht,J+=a*At,C+=a*Ut,B+=a*Dt,V+=a*$t,j+=a*qt,D+=a*sr,L+=a*or,_e+=a*ar,a=p[13],Ne+=a*w,Te+=a*Ye,pe+=a*ht,Se+=a*dt,re+=a*Ze,ye+=a*lt,me+=a*ut,J+=a*Ht,C+=a*At,B+=a*Ut,V+=a*Dt,j+=a*$t,D+=a*qt,L+=a*sr,_e+=a*or,He+=a*ar,a=p[14],Te+=a*w,pe+=a*Ye,Se+=a*ht,re+=a*dt,ye+=a*Ze,me+=a*lt,J+=a*ut,C+=a*Ht,B+=a*At,V+=a*Ut,j+=a*Dt,D+=a*$t,L+=a*qt,_e+=a*sr,He+=a*or,Ge+=a*ar,a=p[15],pe+=a*w,Se+=a*Ye,re+=a*ht,ye+=a*dt,me+=a*Ze,J+=a*lt,C+=a*ut,B+=a*Ht,V+=a*At,j+=a*Ut,D+=a*Dt,L+=a*$t,_e+=a*qt,He+=a*sr,Ge+=a*or,Fe+=a*ar,S+=38*Se,E+=38*re,U+=38*ye,z+=38*me,we+=38*J,Q+=38*C,ft+=38*B,le+=38*V,Ce+=38*j,Be+=38*D,Le+=38*L,$e+=38*_e,Oe+=38*He,Ne+=38*Ge,Te+=38*Fe,g=1,a=S+g+65535,g=Math.floor(a/65536),S=a-g*65536,a=E+g+65535,g=Math.floor(a/65536),E=a-g*65536,a=U+g+65535,g=Math.floor(a/65536),U=a-g*65536,a=z+g+65535,g=Math.floor(a/65536),z=a-g*65536,a=we+g+65535,g=Math.floor(a/65536),we=a-g*65536,a=Q+g+65535,g=Math.floor(a/65536),Q=a-g*65536,a=ft+g+65535,g=Math.floor(a/65536),ft=a-g*65536,a=le+g+65535,g=Math.floor(a/65536),le=a-g*65536,a=Ce+g+65535,g=Math.floor(a/65536),Ce=a-g*65536,a=Be+g+65535,g=Math.floor(a/65536),Be=a-g*65536,a=Le+g+65535,g=Math.floor(a/65536),Le=a-g*65536,a=$e+g+65535,g=Math.floor(a/65536),$e=a-g*65536,a=Oe+g+65535,g=Math.floor(a/65536),Oe=a-g*65536,a=Ne+g+65535,g=Math.floor(a/65536),Ne=a-g*65536,a=Te+g+65535,g=Math.floor(a/65536),Te=a-g*65536,a=pe+g+65535,g=Math.floor(a/65536),pe=a-g*65536,S+=g-1+37*(g-1),g=1,a=S+g+65535,g=Math.floor(a/65536),S=a-g*65536,a=E+g+65535,g=Math.floor(a/65536),E=a-g*65536,a=U+g+65535,g=Math.floor(a/65536),U=a-g*65536,a=z+g+65535,g=Math.floor(a/65536),z=a-g*65536,a=we+g+65535,g=Math.floor(a/65536),we=a-g*65536,a=Q+g+65535,g=Math.floor(a/65536),Q=a-g*65536,a=ft+g+65535,g=Math.floor(a/65536),ft=a-g*65536,a=le+g+65535,g=Math.floor(a/65536),le=a-g*65536,a=Ce+g+65535,g=Math.floor(a/65536),Ce=a-g*65536,a=Be+g+65535,g=Math.floor(a/65536),Be=a-g*65536,a=Le+g+65535,g=Math.floor(a/65536),Le=a-g*65536,a=$e+g+65535,g=Math.floor(a/65536),$e=a-g*65536,a=Oe+g+65535,g=Math.floor(a/65536),Oe=a-g*65536,a=Ne+g+65535,g=Math.floor(a/65536),Ne=a-g*65536,a=Te+g+65535,g=Math.floor(a/65536),Te=a-g*65536,a=pe+g+65535,g=Math.floor(a/65536),pe=a-g*65536,S+=g-1+37*(g-1),l[0]=S,l[1]=E,l[2]=U,l[3]=z,l[4]=we,l[5]=Q,l[6]=ft,l[7]=le,l[8]=Ce,l[9]=Be,l[10]=Le,l[11]=$e,l[12]=Oe,l[13]=Ne,l[14]=Te,l[15]=pe}function mt(l,p){ee(l,p,p)}function Ft(l,p){var d=t(),a;for(a=0;a<16;a++)d[a]=p[a];for(a=253;a>=0;a--)mt(d,d),a!==2&&a!==4&&ee(d,d,p);for(a=0;a<16;a++)l[a]=d[a]}function mo(l,p){var d=t(),a;for(a=0;a<16;a++)d[a]=p[a];for(a=250;a>=0;a--)mt(d,d),a!==1&&ee(d,d,p);for(a=0;a<16;a++)l[a]=d[a]}function hs(l,p,d){var a=new Uint8Array(32),g=new Float64Array(80),S,E,U=t(),z=t(),we=t(),Q=t(),ft=t(),le=t();for(E=0;E<31;E++)a[E]=p[E];for(a[31]=p[31]&127|64,a[0]&=248,he(g,d),E=0;E<16;E++)z[E]=g[E],Q[E]=U[E]=we[E]=0;for(U[0]=Q[0]=1,E=254;E>=0;--E)S=a[E>>>3]>>>(E&7)&1,Ie(U,z,S),Ie(we,Q,S),ct(ft,U,we),bt(U,U,we),ct(we,z,Q),bt(z,z,Q),mt(Q,ft),mt(le,U),ee(U,we,U),ee(we,z,ft),ct(ft,U,we),bt(U,U,we),mt(z,U),bt(we,Q,le),ee(U,we,u),ct(U,U,Q),ee(we,we,U),ee(U,Q,le),ee(Q,z,g),mt(z,ft),Ie(U,z,S),Ie(we,Q,S);for(E=0;E<16;E++)g[E+16]=U[E],g[E+32]=we[E],g[E+48]=z[E],g[E+64]=Q[E];var Ce=g.subarray(32),Be=g.subarray(16);return Ft(Ce,Ce),ee(Be,Be,Ce),wt(l,Be),0}function pr(l,p){return hs(l,p,s)}function wo(l,p){return n(p,32),pr(l,p)}function Nn(l,p,d){var a=new Uint8Array(32);return hs(a,d,p),Ke(l,i,a,Je)}var bo=Pt,Sf=gt;function xo(l,p,d,a,g,S){var E=new Uint8Array(32);return Nn(E,g,S),bo(l,p,d,a,E)}function Dc(l,p,d,a,g,S){var E=new Uint8Array(32);return Nn(E,g,S),Sf(l,p,d,a,E)}var Ao=[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 So(l,p,d,a){for(var g=new Int32Array(16),S=new Int32Array(16),E,U,z,we,Q,ft,le,Ce,Be,Le,$e,Oe,Ne,Te,pe,Se,re,ye,me,J,C,B,V,j,D,L,_e=l[0],He=l[1],Ge=l[2],Fe=l[3],w=l[4],Ye=l[5],ht=l[6],dt=l[7],Ze=p[0],lt=p[1],ut=p[2],Ht=p[3],At=p[4],Ut=p[5],Dt=p[6],$t=p[7],qt=0;a>=128;){for(me=0;me<16;me++)J=8*me+qt,g[me]=d[J+0]<<24|d[J+1]<<16|d[J+2]<<8|d[J+3],S[me]=d[J+4]<<24|d[J+5]<<16|d[J+6]<<8|d[J+7];for(me=0;me<80;me++)if(E=_e,U=He,z=Ge,we=Fe,Q=w,ft=Ye,le=ht,Ce=dt,Be=Ze,Le=lt,$e=ut,Oe=Ht,Ne=At,Te=Ut,pe=Dt,Se=$t,C=dt,B=$t,V=B&65535,j=B>>>16,D=C&65535,L=C>>>16,C=(w>>>14|At<<18)^(w>>>18|At<<14)^(At>>>9|w<<23),B=(At>>>14|w<<18)^(At>>>18|w<<14)^(w>>>9|At<<23),V+=B&65535,j+=B>>>16,D+=C&65535,L+=C>>>16,C=w&Ye^~w&ht,B=At&Ut^~At&Dt,V+=B&65535,j+=B>>>16,D+=C&65535,L+=C>>>16,C=Ao[me*2],B=Ao[me*2+1],V+=B&65535,j+=B>>>16,D+=C&65535,L+=C>>>16,C=g[me%16],B=S[me%16],V+=B&65535,j+=B>>>16,D+=C&65535,L+=C>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,re=D&65535|L<<16,ye=V&65535|j<<16,C=re,B=ye,V=B&65535,j=B>>>16,D=C&65535,L=C>>>16,C=(_e>>>28|Ze<<4)^(Ze>>>2|_e<<30)^(Ze>>>7|_e<<25),B=(Ze>>>28|_e<<4)^(_e>>>2|Ze<<30)^(_e>>>7|Ze<<25),V+=B&65535,j+=B>>>16,D+=C&65535,L+=C>>>16,C=_e&He^_e&Ge^He&Ge,B=Ze<^Ze&ut^lt&ut,V+=B&65535,j+=B>>>16,D+=C&65535,L+=C>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,Ce=D&65535|L<<16,Se=V&65535|j<<16,C=we,B=Oe,V=B&65535,j=B>>>16,D=C&65535,L=C>>>16,C=re,B=ye,V+=B&65535,j+=B>>>16,D+=C&65535,L+=C>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,we=D&65535|L<<16,Oe=V&65535|j<<16,He=E,Ge=U,Fe=z,w=we,Ye=Q,ht=ft,dt=le,_e=Ce,lt=Be,ut=Le,Ht=$e,At=Oe,Ut=Ne,Dt=Te,$t=pe,Ze=Se,me%16===15)for(J=0;J<16;J++)C=g[J],B=S[J],V=B&65535,j=B>>>16,D=C&65535,L=C>>>16,C=g[(J+9)%16],B=S[(J+9)%16],V+=B&65535,j+=B>>>16,D+=C&65535,L+=C>>>16,re=g[(J+1)%16],ye=S[(J+1)%16],C=(re>>>1|ye<<31)^(re>>>8|ye<<24)^re>>>7,B=(ye>>>1|re<<31)^(ye>>>8|re<<24)^(ye>>>7|re<<25),V+=B&65535,j+=B>>>16,D+=C&65535,L+=C>>>16,re=g[(J+14)%16],ye=S[(J+14)%16],C=(re>>>19|ye<<13)^(ye>>>29|re<<3)^re>>>6,B=(ye>>>19|re<<13)^(re>>>29|ye<<3)^(ye>>>6|re<<26),V+=B&65535,j+=B>>>16,D+=C&65535,L+=C>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,g[J]=D&65535|L<<16,S[J]=V&65535|j<<16;C=_e,B=Ze,V=B&65535,j=B>>>16,D=C&65535,L=C>>>16,C=l[0],B=p[0],V+=B&65535,j+=B>>>16,D+=C&65535,L+=C>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,l[0]=_e=D&65535|L<<16,p[0]=Ze=V&65535|j<<16,C=He,B=lt,V=B&65535,j=B>>>16,D=C&65535,L=C>>>16,C=l[1],B=p[1],V+=B&65535,j+=B>>>16,D+=C&65535,L+=C>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,l[1]=He=D&65535|L<<16,p[1]=lt=V&65535|j<<16,C=Ge,B=ut,V=B&65535,j=B>>>16,D=C&65535,L=C>>>16,C=l[2],B=p[2],V+=B&65535,j+=B>>>16,D+=C&65535,L+=C>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,l[2]=Ge=D&65535|L<<16,p[2]=ut=V&65535|j<<16,C=Fe,B=Ht,V=B&65535,j=B>>>16,D=C&65535,L=C>>>16,C=l[3],B=p[3],V+=B&65535,j+=B>>>16,D+=C&65535,L+=C>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,l[3]=Fe=D&65535|L<<16,p[3]=Ht=V&65535|j<<16,C=w,B=At,V=B&65535,j=B>>>16,D=C&65535,L=C>>>16,C=l[4],B=p[4],V+=B&65535,j+=B>>>16,D+=C&65535,L+=C>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,l[4]=w=D&65535|L<<16,p[4]=At=V&65535|j<<16,C=Ye,B=Ut,V=B&65535,j=B>>>16,D=C&65535,L=C>>>16,C=l[5],B=p[5],V+=B&65535,j+=B>>>16,D+=C&65535,L+=C>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,l[5]=Ye=D&65535|L<<16,p[5]=Ut=V&65535|j<<16,C=ht,B=Dt,V=B&65535,j=B>>>16,D=C&65535,L=C>>>16,C=l[6],B=p[6],V+=B&65535,j+=B>>>16,D+=C&65535,L+=C>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,l[6]=ht=D&65535|L<<16,p[6]=Dt=V&65535|j<<16,C=dt,B=$t,V=B&65535,j=B>>>16,D=C&65535,L=C>>>16,C=l[7],B=p[7],V+=B&65535,j+=B>>>16,D+=C&65535,L+=C>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,l[7]=dt=D&65535|L<<16,p[7]=$t=V&65535|j<<16,qt+=128,a-=128}return a}function dn(l,p,d){var a=new Int32Array(8),g=new Int32Array(8),S=new Uint8Array(256),E,U=d;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,g[0]=4089235720,g[1]=2227873595,g[2]=4271175723,g[3]=1595750129,g[4]=2917565137,g[5]=725511199,g[6]=4215389547,g[7]=327033209,So(a,g,p,d),d%=128,E=0;E<d;E++)S[E]=p[U-d+E];for(S[d]=128,d=256-128*(d<112?1:0),S[d-9]=0,v(S,d-8,U/536870912|0,U<<3),So(a,g,S,d),E=0;E<8;E++)v(l,8*E,a[E],g[E]);return 0}function Bi(l,p){var d=t(),a=t(),g=t(),S=t(),E=t(),U=t(),z=t(),we=t(),Q=t();bt(d,l[1],l[0]),bt(Q,p[1],p[0]),ee(d,d,Q),ct(a,l[0],l[1]),ct(Q,p[0],p[1]),ee(a,a,Q),ee(g,l[3],p[3]),ee(g,g,m),ee(S,l[2],p[2]),ct(S,S,S),bt(E,a,d),bt(U,S,g),ct(z,S,g),ct(we,a,d),ee(l[0],E,U),ee(l[1],we,z),ee(l[2],z,U),ee(l[3],E,we)}function ds(l,p,d){var a;for(a=0;a<4;a++)Ie(l[a],p[a],d)}function _o(l,p){var d=t(),a=t(),g=t();Ft(g,p[2]),ee(d,p[0],g),ee(a,p[1],g),wt(l,a),l[31]^=Lt(d)<<7}function Eo(l,p,d){var a,g;for(et(l[0],o),et(l[1],c),et(l[2],c),et(l[3],o),g=255;g>=0;--g)a=d[g/8|0]>>(g&7)&1,ds(l,p,a),Bi(p,l),Bi(l,l),ds(l,p,a)}function ps(l,p){var d=[t(),t(),t(),t()];et(d[0],x),et(d[1],G),et(d[2],c),ee(d[3],x,G),Eo(l,d,p)}function Io(l,p,d){var a=new Uint8Array(64),g=[t(),t(),t(),t()],S;for(d||n(p,32),dn(a,p,32),a[0]&=248,a[31]&=127,a[31]|=64,ps(g,a),_o(l,g),S=0;S<32;S++)p[S+32]=l[S];return 0}var pn=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 ko(l,p){var d,a,g,S;for(a=63;a>=32;--a){for(d=0,g=a-32,S=a-12;g<S;++g)p[g]+=d-16*p[a]*pn[g-(a-32)],d=Math.floor((p[g]+128)/256),p[g]-=d*256;p[g]+=d,p[a]=0}for(d=0,g=0;g<32;g++)p[g]+=d-(p[31]>>4)*pn[g],d=p[g]>>8,p[g]&=255;for(g=0;g<32;g++)p[g]-=d*pn[g];for(a=0;a<32;a++)p[a+1]+=p[a]>>8,l[a]=p[a]&255}function Co(l){var p=new Float64Array(64),d;for(d=0;d<64;d++)p[d]=l[d];for(d=0;d<64;d++)l[d]=0;ko(l,p)}function $c(l,p,d,a){var g=new Uint8Array(64),S=new Uint8Array(64),E=new Uint8Array(64),U,z,we=new Float64Array(64),Q=[t(),t(),t(),t()];dn(g,a,32),g[0]&=248,g[31]&=127,g[31]|=64;var ft=d+64;for(U=0;U<d;U++)l[64+U]=p[U];for(U=0;U<32;U++)l[32+U]=g[32+U];for(dn(E,l.subarray(32),d+32),Co(E),ps(Q,E),_o(l,Q),U=32;U<64;U++)l[U]=a[U];for(dn(S,l,d+64),Co(S),U=0;U<64;U++)we[U]=0;for(U=0;U<32;U++)we[U]=E[U];for(U=0;U<32;U++)for(z=0;z<32;z++)we[U+z]+=S[U]*g[z];return ko(l.subarray(32),we),ft}function Bo(l,p){var d=t(),a=t(),g=t(),S=t(),E=t(),U=t(),z=t();return et(l[2],c),he(l[1],p),mt(g,l[1]),ee(S,g,h),bt(g,g,l[2]),ct(S,l[2],S),mt(E,S),mt(U,E),ee(z,U,E),ee(d,z,g),ee(d,d,S),mo(d,d),ee(d,d,g),ee(d,d,S),ee(d,d,S),ee(l[0],d,S),mt(a,l[0]),ee(a,a,S),Vt(a,g)&&ee(l[0],l[0],N),mt(a,l[0]),ee(a,a,S),Vt(a,g)?-1:(Lt(l[0])===p[31]>>7&&bt(l[0],o,l[0]),ee(l[3],l[0],l[1]),0)}function _(l,p,d,a){var g,S=new Uint8Array(32),E=new Uint8Array(64),U=[t(),t(),t(),t()],z=[t(),t(),t(),t()];if(d<64||Bo(z,a))return-1;for(g=0;g<d;g++)l[g]=p[g];for(g=0;g<32;g++)l[g+32]=a[g];if(dn(E,l,d),Co(E),Eo(U,z,E),ps(z,p.subarray(32)),Bi(U,z),_o(S,U),d-=64,I(p,0,S,0)){for(g=0;g<d;g++)l[g]=0;return-1}for(g=0;g<d;g++)l[g]=p[g+64];return d}var k=32,T=24,q=32,be=16,kt=32,Ct=32,De=32,Z=32,te=32,de=T,ve=q,Xe=be,st=64,xt=32,Zt=64,ys=32,Oo=64;e.lowlevel={crypto_core_hsalsa20:Ke,crypto_stream_xor:oe,crypto_stream:se,crypto_stream_salsa20_xor:Ue,crypto_stream_salsa20:W,crypto_onetimeauth:it,crypto_onetimeauth_verify:It,crypto_verify_16:O,crypto_verify_32:I,crypto_secretbox:Pt,crypto_secretbox_open:gt,crypto_scalarmult:hs,crypto_scalarmult_base:pr,crypto_box_beforenm:Nn,crypto_box_afternm:bo,crypto_box:xo,crypto_box_open:Dc,crypto_box_keypair:wo,crypto_hash:dn,crypto_sign:$c,crypto_sign_keypair:Io,crypto_sign_open:_,crypto_secretbox_KEYBYTES:k,crypto_secretbox_NONCEBYTES:T,crypto_secretbox_ZEROBYTES:q,crypto_secretbox_BOXZEROBYTES:be,crypto_scalarmult_BYTES:kt,crypto_scalarmult_SCALARBYTES:Ct,crypto_box_PUBLICKEYBYTES:De,crypto_box_SECRETKEYBYTES:Z,crypto_box_BEFORENMBYTES:te,crypto_box_NONCEBYTES:de,crypto_box_ZEROBYTES:ve,crypto_box_BOXZEROBYTES:Xe,crypto_sign_BYTES:st,crypto_sign_PUBLICKEYBYTES:xt,crypto_sign_SECRETKEYBYTES:Zt,crypto_sign_SEEDBYTES:ys,crypto_hash_BYTES:Oo,gf:t,D:h,L:pn,pack25519:wt,unpack25519:he,M:ee,A:ct,S:mt,Z:bt,pow2523:mo,add:Bi,set25519:et,modL:ko,scalarmult:Eo,scalarbase:ps};function Mc(l,p){if(l.length!==k)throw new Error("bad key size");if(p.length!==T)throw new Error("bad nonce size")}function dw(l,p){if(l.length!==De)throw new Error("bad public key size");if(p.length!==Z)throw new Error("bad secret key size")}function Br(){for(var l=0;l<arguments.length;l++)if(!(arguments[l]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}function xy(l){for(var p=0;p<l.length;p++)l[p]=0}e.randomBytes=function(l){var p=new Uint8Array(l);return n(p,l),p},e.secretbox=function(l,p,d){Br(l,p,d),Mc(d,p);for(var a=new Uint8Array(q+l.length),g=new Uint8Array(a.length),S=0;S<l.length;S++)a[S+q]=l[S];return Pt(g,a,a.length,p,d),g.subarray(be)},e.secretbox.open=function(l,p,d){Br(l,p,d),Mc(d,p);for(var a=new Uint8Array(be+l.length),g=new Uint8Array(a.length),S=0;S<l.length;S++)a[S+be]=l[S];return a.length<32||gt(g,a,a.length,p,d)!==0?null:g.subarray(q)},e.secretbox.keyLength=k,e.secretbox.nonceLength=T,e.secretbox.overheadLength=be,e.scalarMult=function(l,p){if(Br(l,p),l.length!==Ct)throw new Error("bad n size");if(p.length!==kt)throw new Error("bad p size");var d=new Uint8Array(kt);return hs(d,l,p),d},e.scalarMult.base=function(l){if(Br(l),l.length!==Ct)throw new Error("bad n size");var p=new Uint8Array(kt);return pr(p,l),p},e.scalarMult.scalarLength=Ct,e.scalarMult.groupElementLength=kt,e.box=function(l,p,d,a){var g=e.box.before(d,a);return e.secretbox(l,p,g)},e.box.before=function(l,p){Br(l,p),dw(l,p);var d=new Uint8Array(te);return Nn(d,l,p),d},e.box.after=e.secretbox,e.box.open=function(l,p,d,a){var g=e.box.before(d,a);return e.secretbox.open(l,p,g)},e.box.open.after=e.secretbox.open,e.box.keyPair=function(){var l=new Uint8Array(De),p=new Uint8Array(Z);return wo(l,p),{publicKey:l,secretKey:p}},e.box.keyPair.fromSecretKey=function(l){if(Br(l),l.length!==Z)throw new Error("bad secret key size");var p=new Uint8Array(De);return pr(p,l),{publicKey:p,secretKey:new Uint8Array(l)}},e.box.publicKeyLength=De,e.box.secretKeyLength=Z,e.box.sharedKeyLength=te,e.box.nonceLength=de,e.box.overheadLength=e.secretbox.overheadLength,e.sign=function(l,p){if(Br(l,p),p.length!==Zt)throw new Error("bad secret key size");var d=new Uint8Array(st+l.length);return $c(d,l,l.length,p),d},e.sign.open=function(l,p){if(Br(l,p),p.length!==xt)throw new Error("bad public key size");var d=new Uint8Array(l.length),a=_(d,l,l.length,p);if(a<0)return null;for(var g=new Uint8Array(a),S=0;S<g.length;S++)g[S]=d[S];return g},e.sign.detached=function(l,p){for(var d=e.sign(l,p),a=new Uint8Array(st),g=0;g<a.length;g++)a[g]=d[g];return a},e.sign.detached.verify=function(l,p,d){if(Br(l,p,d),p.length!==st)throw new Error("bad signature size");if(d.length!==xt)throw new Error("bad public key size");var a=new Uint8Array(st+l.length),g=new Uint8Array(st+l.length),S;for(S=0;S<st;S++)a[S]=p[S];for(S=0;S<l.length;S++)a[S+st]=l[S];return _(g,a,a.length,d)>=0},e.sign.keyPair=function(){var l=new Uint8Array(xt),p=new Uint8Array(Zt);return Io(l,p),{publicKey:l,secretKey:p}},e.sign.keyPair.fromSecretKey=function(l){if(Br(l),l.length!==Zt)throw new Error("bad secret key size");for(var p=new Uint8Array(xt),d=0;d<p.length;d++)p[d]=l[32+d];return{publicKey:p,secretKey:new Uint8Array(l)}},e.sign.keyPair.fromSeed=function(l){if(Br(l),l.length!==ys)throw new Error("bad seed size");for(var p=new Uint8Array(xt),d=new Uint8Array(Zt),a=0;a<32;a++)d[a]=l[a];return Io(p,d,!0),{publicKey:p,secretKey:d}},e.sign.publicKeyLength=xt,e.sign.secretKeyLength=Zt,e.sign.seedLength=ys,e.sign.signatureLength=st,e.hash=function(l){Br(l);var p=new Uint8Array(Oo);return dn(p,l,l.length),p},e.hash.hashLength=Oo,e.verify=function(l,p){return Br(l,p),l.length===0||p.length===0||l.length!==p.length?!1:A(l,0,p,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 p=65536;e.setPRNG(function(d,a){var g,S=new Uint8Array(a);for(g=0;g<a;g+=p)l.getRandomValues(S.subarray(g,g+Math.min(a-g,p)));for(g=0;g<a;g++)d[g]=S[g];xy(S)})}else typeof g1<"u"&&(l=v1,l&&l.randomBytes&&e.setPRNG(function(d,a){var g,S=l.randomBytes(a);for(g=0;g<a;g++)d[g]=S[g];xy(S)}))}()})(r.exports?r.exports:self.nacl=self.nacl||{})})(B0);var m1=B0.exports;const O0=Ly(m1);function w1(){return O0.box.keyPair()}async function Ci(r,e){const t=sessionStorage.getItem("sessionKey"),n=sessionStorage.getItem("sessionId");console.groupCollapsed("Attestation");try{if(t&&n&&!r){const o=gs(t);return console.log("Using existing attestation from session storage."),{sessionKey:o,sessionId:n}}const i=window.crypto.randomUUID();console.log("Generated attestation nonce:",i);const s=await y1(i,e);if(s&&s.public_key){console.log("Attestation document verification succeeded");const o=w1();console.log("Generated client key pair");const c=new Uint8Array(s.public_key),{encrypted_session_key:u,session_id:h}=await U1($r(o.publicKey),i,e);console.log("Key exchange completed.");const m=O0.scalarMult(o.secretKey,c),x=gs(u),G=12,N=x.slice(0,G),v=x.slice(G),O=new Hc(m).open(N,v);if(O)return console.log("Session key decrypted successfully"),window.sessionStorage.setItem("sessionKey",$r(O)),window.sessionStorage.setItem("sessionId",h),{sessionKey:O,sessionId:h};throw new Error("Failed to decrypt session key")}else throw new Error("Invalid attestation document")}catch(i){throw console.error("Error verifying attestation:",i),i}finally{console.groupEnd()}}let at="";function b1(r){at=r}async function x1(r,e){return Nt(`${at}/platform/login`,"POST",{email:r,password:e},void 0,"Failed to login")}async function A1(r,e,t,n){return Nt(`${at}/platform/register`,"POST",{email:r,password:e,invite_code:t,name:n},void 0,"Failed to register")}async function S1(r){return Nt(`${at}/platform/logout`,"POST",{refresh_token:r},void 0,"Failed to logout")}async function _1(){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 Nt(`${at}/platform/refresh`,"POST",e,void 0,"Failed to refresh platform 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 platform token:",t),t}}async function T0(r){return Re(`${at}/platform/orgs`,"POST",{name:r})}async function N0(){return Re(`${at}/platform/orgs`,"GET",void 0)}async function P0(r){return Re(`${at}/platform/orgs/${r}`,"DELETE",void 0)}async function j0(r,e,t){return Re(`${at}/platform/orgs/${r}/projects`,"POST",{name:e,description:t})}async function R0(r){return Re(`${at}/platform/orgs/${r}/projects`,"GET",void 0)}async function U0(r,e){return Re(`${at}/platform/orgs/${r}/projects/${e}`,"GET",void 0)}async function D0(r,e,t){return Re(`${at}/platform/orgs/${r}/projects/${e}`,"PATCH",t)}async function $0(r,e){return Re(`${at}/platform/orgs/${r}/projects/${e}`,"DELETE",void 0)}function E1(r){const e=/^[A-Za-z0-9+/]*[=]{0,2}$/,t=r.length%4===0,n=e.test(r);return t&&n}async function M0(r,e,t,n){if(!E1(n))throw new Error("Secret must be base64 encoded. Use @stablelib/base64's encode function to encode your data.");return Re(`${at}/platform/orgs/${r}/projects/${e}/secrets`,"POST",{key_name:t,secret:n})}async function V0(r,e){return Re(`${at}/platform/orgs/${r}/projects/${e}/secrets`,"GET",void 0)}async function L0(r,e,t){return Re(`${at}/platform/orgs/${r}/projects/${e}/secrets/${t}`,"DELETE",void 0)}async function H0(r,e){return Re(`${at}/platform/orgs/${r}/projects/${e}/settings/email`,"GET",void 0)}async function F0(r,e,t){return Re(`${at}/platform/orgs/${r}/projects/${e}/settings/email`,"PUT",t)}async function z0(r,e){return Re(`${at}/platform/orgs/${r}/projects/${e}/settings/oauth`,"GET",void 0)}async function G0(r,e,t){return Re(`${at}/platform/orgs/${r}/projects/${e}/settings/oauth`,"PUT",t)}async function q0(r,e,t){if(!e||e.trim()==="")throw new Error("Email is required");return Re(`${at}/platform/orgs/${r}/invites`,"POST",{email:e,role:t})}async function K0(r){return Re(`${at}/platform/orgs/${r}/invites`,"GET",void 0)}async function Z0(r,e){return Re(`${at}/platform/orgs/${r}/invites/${e}`,"GET",void 0)}async function W0(r,e){return Re(`${at}/platform/orgs/${r}/invites/${e}`,"DELETE",void 0)}async function Y0(r){return Re(`${at}/platform/orgs/${r}/memberships`,"GET",void 0)}async function J0(r,e,t){return Re(`${at}/platform/orgs/${r}/memberships/${e}`,"PATCH",{role:t})}async function X0(r,e){return Re(`${at}/platform/orgs/${r}/memberships/${e}`,"DELETE",void 0)}async function Q0(r){return Re(`${at}/platform/accept_invite/${r}`,"POST",void 0)}async function I1(){return Re(`${at}/platform/me`,"GET",void 0)}async function ey(r){return Nt(`${at}/platform/verify-email/${r}`,"GET",void 0,void 0,"Failed to verify email")}async function Oc(){return Re(`${at}/platform/request_verification`,"POST",void 0,"Failed to request new verification code")}async function ty(r,e){const t={email:r,hashed_secret:e};return Nt(`${at}/platform/password-reset/request`,"POST",t,void 0,"Failed to request platform password reset")}async function ry(r,e,t,n){const i={email:r,alphanumeric_code:e,plaintext_secret:t,new_password:n};return Nt(`${at}/platform/password-reset/confirm`,"POST",i,void 0,"Failed to confirm platform password reset")}async function ny(r,e){const t={current_password:r,new_password:e};return Re(`${at}/platform/change-password`,"POST",t,"Failed to change platform password")}async function Re(r,e,t,n){const i=async(s=!1)=>{try{if(s){console.log("Refreshing access token");const u=ti.getRefreshFunction(r);console.log(`Using ${u}`),u==="platformRefreshToken"?await _1():await Tc()}const o=window.localStorage.getItem("access_token");if(!o)throw new Error("No access token available");const c=await iy(r,e,t,o,n);if(c.status===401&&!s)return console.log(`Received 401 for URL ${r}, 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 iy(r,e,t,n,i){const o=ti.resolveEndpoint(r).context==="platform"?ti.platformApiUrl:void 0;let{sessionKey:c,sessionId:u}=await Ci(!1,o);const h=async(x,G=!1)=>{if(G||!c||!u){const P=await Ci(!0,o);c=P.sessionKey,u=P.sessionId}if(!c||!u)throw new Error("Failed to make encrypted API call, no attestation available.");const N=t?JSON.stringify(t):void 0,v=N?Pf(c,N):void 0,A={"Content-Type":"application/json","x-session-id":u};x&&(A.Authorization=`Bearer ${x}`);const O=await fetch(r,{method:e,headers:A,body:v?JSON.stringify({encrypted:v}):void 0}),I={status:O.status};if(O.ok)try{const P=await O.json(),R=jf(c,P.encrypted);I.data=JSON.parse(R)}catch(P){console.error("Error decrypting or parsing response:",P),I.status=500,I.error="Failed to decrypt or parse the response"}else try{const P=await O.json();I.error=P.message||i||`HTTP error! Status: ${O.status}`}catch{I.error=i||`HTTP error! Status: ${O.status}`}return I},m=async(x,G=!1)=>{var N;try{const v=await h(x,G);return(v.status===400||(N=v.error)!=null&&N.includes("Encryption error"))&&!G?(console.log("Encryption error or Bad Request, attempting to renew attestation"),m(x,!0)):v}catch(v){return{status:500,error:v instanceof Error?v.message:"Unknown error occurred"}}};return m(n)}async function Nt(r,e,t,n,i){const s=await iy(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 Qe="";function k1(r){Qe=r}function C1(){return Qe}async function B1(r,e,t){return Nt(`${Qe}/login`,"POST",{email:r,password:e,client_id:t})}async function O1(r,e,t){return Nt(`${Qe}/login`,"POST",{id:r,password:e,client_id:t})}async function T1(r,e,t,n,i){return Nt(`${Qe}/register`,"POST",{email:r,password:e,inviteCode:t.toLowerCase(),client_id:n,name:i})}async function N1(r,e,t){return Nt(`${Qe}/register`,"POST",{password:r,inviteCode:e.toLowerCase(),client_id:t})}async function Tc(){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 Nt(`${Qe}/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 P1(){return Re(`${Qe}/protected/user`,"GET",void 0,"Failed to fetch user")}async function sy(r,e){return Re(`${Qe}/protected/kv/${r}`,"PUT",e,"Failed to put key-value pair")}async function oy(r){return Re(`${Qe}/protected/kv/${r}`,"DELETE",void 0,"Failed to delete key-value pair")}async function ay(r){try{return await Re(`${Qe}/protected/kv/${r}`,"GET",void 0,"Failed to get key-value pair")}catch(e){console.error(`Error fetching key "${r}":`,e);return}}async function cy(){return Re(`${Qe}/protected/kv`,"GET",void 0,"Failed to list key-value pairs")}async function j1(r){const e={refresh_token:r};return Nt(`${Qe}/logout`,"POST",e)}async function ly(r){return Nt(`${Qe}/verify-email/${r}`,"GET",void 0,void 0,"Failed to verify email")}async function Nc(){return Re(`${Qe}/protected/request_verification`,"POST",void 0,"Failed to request new verification code")}async function R1(r,e){const n=await fetch(`${e||Qe}/attestation/${r}`);if(!n.ok)throw new Error(`Request failed with status ${n.status}`);return(await n.json()).attestation_document}async function U1(r,e,t){const i=await fetch(`${t||Qe}/key_exchange`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_public_key:r,nonce:e})});if(!i.ok)throw new Error("Key exchange failed");return i.json()}async function D1(r,e,t){const n={email:r,hashed_secret:e,client_id:t};return Nt(`${Qe}/password-reset/request`,"POST",n,void 0,"Failed to request password reset")}async function $1(r,e,t,n,i){const s={email:r,alphanumeric_code:e,plaintext_secret:t,new_password:n,client_id:i};return Nt(`${Qe}/password-reset/confirm`,"POST",s,void 0,"Failed to confirm password reset")}async function uy(r,e){const t={current_password:r,new_password:e};return Re(`${Qe}/protected/change_password`,"POST",t,"Failed to change password")}async function M1(r,e){try{return await Nt(`${Qe}/auth/github`,"POST",e?{invite_code:e,client_id:r}:{client_id:r},void 0,"Failed to initiate GitHub auth")}catch(t){throw t instanceof Error&&t.message.includes("Invalid invite code")?new Error("Invalid invite code. Please check and try again."):t}}async function V1(r,e,t){const n={code:r,state:e,invite_code:t};try{return await Nt(`${Qe}/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 L1(r,e){try{return await Nt(`${Qe}/auth/google`,"POST",e?{invite_code:e,client_id:r}:{client_id:r},void 0,"Failed to initiate Google auth")}catch(t){throw t instanceof Error&&t.message.includes("Invalid invite code")?new Error("Invalid invite code. Please check and try again."):t}}async function H1(r,e,t){const n={code:r,state:e,invite_code:t};try{return await Nt(`${Qe}/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 F1(r,e){try{return await Nt(`${Qe}/auth/apple`,"POST",e?{invite_code:e,client_id:r}:{client_id:r},void 0,"Failed to initiate Apple auth")}catch(t){throw t instanceof Error&&t.message.includes("Invalid invite code")?new Error("Invalid invite code. Please check and try again."):t}}async function z1(r,e,t){const n={code:r,state:e,invite_code:t};try{return await Nt(`${Qe}/auth/apple/callback`,"POST",n,void 0,"Apple callback failed")}catch(i){throw console.error("Detailed Apple 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 Apple."):new Error("Failed to authenticate with Apple. Please try again."):i}}async function G1(r,e,t){const n={...r,client_id:e,...t?{invite_code:t}:{}};try{return await Nt(`${Qe}/auth/apple/native`,"POST",n,void 0,"Apple Sign-In failed")}catch(i){throw console.error("Detailed Apple Sign-In 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 Apple."):i.message.includes("No email found")?new Error("Unable to retrieve email from Apple. Please try another sign-in method."):new Error("Failed to authenticate with Apple. Please try again."):i}}async function fy(r){let e=`${Qe}/protected/private_key`;const t=[];return r!=null&&r.seed_phrase_derivation_path&&t.push(`seed_phrase_derivation_path=${encodeURIComponent(r.seed_phrase_derivation_path)}`),r!=null&&r.private_key_derivation_path&&t.push(`private_key_derivation_path=${encodeURIComponent(r.private_key_derivation_path)}`),t.length>0&&(e+=`?${t.join("&")}`),Re(e,"GET",void 0,"Failed to fetch private key")}async function hy(r){let e=`${Qe}/protected/private_key_bytes`;const t=[];return r!=null&&r.seed_phrase_derivation_path&&t.push(`seed_phrase_derivation_path=${encodeURIComponent(r.seed_phrase_derivation_path)}`),r!=null&&r.private_key_derivation_path&&t.push(`private_key_derivation_path=${encodeURIComponent(r.private_key_derivation_path)}`),t.length>0&&(e+=`?${t.join("&")}`),Re(e,"GET",void 0,"Failed to fetch private key bytes")}async function dy(r,e,t){const i={message_base64:$r(r),algorithm:e,...t&&Object.keys(t).length>0&&{key_options:t}};return Re(`${Qe}/protected/sign_message`,"POST",i,"Failed to sign message")}async function py(r,e){let t=`${Qe}/protected/public_key?algorithm=${r}`;return e!=null&&e.seed_phrase_derivation_path&&(t+=`&seed_phrase_derivation_path=${encodeURIComponent(e.seed_phrase_derivation_path)}`),e!=null&&e.private_key_derivation_path&&(t+=`&private_key_derivation_path=${encodeURIComponent(e.private_key_derivation_path)}`),Re(t,"GET",void 0,"Failed to fetch public key")}async function q1(r,e,t){const n={email:r,password:e,...t!==void 0&&{name:t}};return Re(`${Qe}/protected/convert_guest`,"POST",n,"Failed to convert guest account")}async function K1(r){return Re(`${Qe}/protected/third_party_token`,"POST",r?{audience:r}:{},"Failed to generate third party token")}async function yy(r,e){const t={data:r,...e&&Object.keys(e).length>0&&{key_options:e}};return Re(`${Qe}/protected/encrypt`,"POST",t,"Failed to encrypt data")}async function gy(r,e){const t={encrypted_data:r,...e&&Object.keys(e).length>0&&{key_options:e}};return Re(`${Qe}/protected/decrypt`,"POST",t,"Failed to decrypt data")}async function Z1(r){const e={hashed_secret:r};return Re(`${Qe}/protected/delete-account/request`,"POST",e,"Failed to request account deletion")}async function W1(r,e){const t={uuid:r,plaintext_secret:e};return Re(`${Qe}/protected/delete-account/confirm`,"POST",t,"Failed to confirm account deletion")}function Y1(){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 Ci();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 m=Pf(o,e.body);u.body=JSON.stringify({encrypted:m}),s.set("Content-Type","application/json")}let h=await fetch(r,u);if(h.status===401&&(console.warn("Unauthorized, refreshing access token"),await Tc(),s.set("Authorization",t()),u.headers=s,h=await fetch(r,u)),!h.ok){const m=await h.text();throw console.error("Request failed with response status:",h.status," and message:",m),new Error(`Request failed with status ${h.status}: ${m}`)}if((n=h.headers.get("content-type"))!=null&&n.includes("text/event-stream")){const m=(i=h.body)==null?void 0:i.getReader(),x=new TextDecoder;let G="";const N=new ReadableStream({async start(v){for(;;){const{done:A,value:O}=await m.read();if(A)break;const I=x.decode(O);G+=I;let P;for(;P=J1(G);)if(G=G.slice(P.length),P.trim().startsWith("data: ")){const R=P.slice(6).trim();if(R==="[DONE]")v.enqueue(`data: [DONE]
|
|
125
|
+
\r]`);return e=`^(?:${e})$`,new RegExp(e,"u")},"I-RegExp"),We.registerDecoder(Et.REGEXP,r=>{if(h0(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"),Rt(RegExp,r=>[Et.REGEXP,[r.source,r.flags]]),We.registerDecoder(64,r=>(Si(r.contents),r.contents),"uint8 Typed Array");function nr(r,e,t){Si(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 qn(r,e,t,n,i){const s=i.forceEndian??u0;if(yc(s?e:t,r,i),qr(n.byteLength,r,ge.BYTE_STRING),u0===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)}}We.registerDecoder(65,r=>nr(r,Uint16Array,!1),"uint16, big endian, Typed Array"),We.registerDecoder(66,r=>nr(r,Uint32Array,!1),"uint32, big endian, Typed Array"),We.registerDecoder(67,r=>nr(r,BigUint64Array,!1),"uint64, big endian, Typed Array"),We.registerDecoder(68,r=>(Si(r.contents),new Uint8ClampedArray(r.contents)),"uint8 Typed Array, clamped arithmetic"),Rt(Uint8ClampedArray,r=>[68,new Uint8Array(r.buffer,r.byteOffset,r.byteLength)]),We.registerDecoder(69,r=>nr(r,Uint16Array,!0),"uint16, little endian, Typed Array"),Rt(Uint16Array,(r,e,t)=>qn(e,69,65,r,t)),We.registerDecoder(70,r=>nr(r,Uint32Array,!0),"uint32, little endian, Typed Array"),Rt(Uint32Array,(r,e,t)=>qn(e,70,66,r,t)),We.registerDecoder(71,r=>nr(r,BigUint64Array,!0),"uint64, little endian, Typed Array"),Rt(BigUint64Array,(r,e,t)=>qn(e,71,67,r,t)),We.registerDecoder(72,r=>(Si(r.contents),new Int8Array(r.contents)),"sint8 Typed Array"),Rt(Int8Array,r=>[72,new Uint8Array(r.buffer,r.byteOffset,r.byteLength)]),We.registerDecoder(73,r=>nr(r,Int16Array,!1),"sint16, big endian, Typed Array"),We.registerDecoder(74,r=>nr(r,Int32Array,!1),"sint32, big endian, Typed Array"),We.registerDecoder(75,r=>nr(r,BigInt64Array,!1),"sint64, big endian, Typed Array"),We.registerDecoder(77,r=>nr(r,Int16Array,!0),"sint16, little endian, Typed Array"),Rt(Int16Array,(r,e,t)=>qn(e,77,73,r,t)),We.registerDecoder(78,r=>nr(r,Int32Array,!0),"sint32, little endian, Typed Array"),Rt(Int32Array,(r,e,t)=>qn(e,78,74,r,t)),We.registerDecoder(79,r=>nr(r,BigInt64Array,!0),"sint64, little endian, Typed Array"),Rt(BigInt64Array,(r,e,t)=>qn(e,79,75,r,t)),We.registerDecoder(81,r=>nr(r,Float32Array,!1),"IEEE 754 binary32, big endian, Typed Array"),We.registerDecoder(82,r=>nr(r,Float64Array,!1),"IEEE 754 binary64, big endian, Typed Array"),We.registerDecoder(85,r=>nr(r,Float32Array,!0),"IEEE 754 binary32, little endian, Typed Array"),Rt(Float32Array,(r,e,t)=>qn(e,85,81,r,t)),We.registerDecoder(86,r=>nr(r,Float64Array,!0),"IEEE 754 binary64, big endian, Typed Array"),Rt(Float64Array,(r,e,t)=>qn(e,86,82,r,t)),We.registerDecoder(Et.SET,r=>(h0(r.contents),new Set(r.contents)),"Set"),Rt(Set,r=>[Et.SET,[...r]]),We.registerDecoder(Et.JSON,r=>(Gn(r.contents),JSON.parse(r.contents)),"JSON-encoded"),We.registerDecoder(Et.SELF_DESCRIBED,r=>r.contents,"Self-Described"),We.registerDecoder(Et.INVALID_16,()=>{throw new Error(`Tag always invalid: ${Et.INVALID_16}`)},"Invalid"),We.registerDecoder(Et.INVALID_32,()=>{throw new Error(`Tag always invalid: ${Et.INVALID_32}`)},"Invalid"),We.registerDecoder(Et.INVALID_64,()=>{throw new Error(`Tag always invalid: ${Et.INVALID_64}`)},"Invalid");function pf(r){throw new Error(`Encoding ${r.constructor.name} intentionally unimplmented. It is not concrete enough to interoperate. Convert to Uint8Array first.`)}Rt(ArrayBuffer,pf),Rt(DataView,pf),typeof SharedArrayBuffer<"u"&&Rt(SharedArrayBuffer,pf);function wc(r){return[NaN,r.valueOf()]}Rt(Boolean,wc),Rt(Number,wc),Rt(String,wc),Rt(BigInt,wc);function bc(r,e={}){const t={...zn.defaultDecodeOptions};if(e.dcbor?Object.assign(t,zn.dcborDecodeOptions):e.cde&&Object.assign(t,zn.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 Xs(r,t);let i,s;for(const o of n){if(s=zn.create(o,i,t,n),o[2]===Ir.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 zn&&(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 ot;(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})(ot||(ot={}));var yf;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(yf||(yf={}));const ie=ot.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Kn=r=>{switch(typeof r){case"undefined":return ie.undefined;case"string":return ie.string;case"number":return isNaN(r)?ie.nan:ie.number;case"boolean":return ie.boolean;case"function":return ie.function;case"bigint":return ie.bigint;case"symbol":return ie.symbol;case"object":return Array.isArray(r)?ie.array:r===null?ie.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?ie.promise:typeof Map<"u"&&r instanceof Map?ie.map:typeof Set<"u"&&r instanceof Set?ie.set:typeof Date<"u"&&r instanceof Date?ie.date:ie.object;default:return ie.unknown}},F=ot.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"]),um=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 h=o.path[u];u===o.path.length-1?(c[h]=c[h]||{_errors:[]},c[h]._errors.push(t(o))):c[h]=c[h]||{_errors:[]},c=c[h],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,ot.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 is=(r,e)=>{let t;switch(r.code){case F.invalid_type:r.received===ie.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case F.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,ot.jsonStringifyReplacer)}`;break;case F.unrecognized_keys:t=`Unrecognized key(s) in object: ${ot.joinValues(r.keys,", ")}`;break;case F.invalid_union:t="Invalid input";break;case F.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${ot.joinValues(r.options)}`;break;case F.invalid_enum_value:t=`Invalid enum value. Expected ${ot.joinValues(r.options)}, received '${r.received}'`;break;case F.invalid_arguments:t="Invalid function arguments";break;case F.invalid_return_type:t="Invalid function return type";break;case F.invalid_date:t="Invalid date";break;case F.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}"`:ot.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case F.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 F.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 F.custom:t="Invalid input";break;case F.invalid_intersection_types:t="Intersection results could not be merged";break;case F.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case F.not_finite:t="Number must be finite";break;default:t=e.defaultError,ot.assertNever(r)}return{message:t}};let v0=is;function fm(r){v0=r}function xc(){return v0}const Ac=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(h=>!!h).slice().reverse();for(const h of u)c=h(o,{data:e,defaultError:c}).message;return{...i,path:s,message:c}},hm=[];function X(r,e){const t=xc(),n=Ac({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===is?void 0:is].filter(i=>!!i)});r.common.issues.push(n)}class ir{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 ke;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 ir.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 ke;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 ke=Object.freeze({status:"aborted"}),ss=r=>({status:"dirty",value:r}),hr=r=>({status:"valid",value:r}),gf=r=>r.status==="aborted",vf=r=>r.status==="dirty",Qs=r=>r.status==="valid",eo=r=>typeof Promise<"u"&&r instanceof Promise;function Sc(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 m0(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 xe;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(xe||(xe={}));var to,ro;class an{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 w0=(r,e)=>{if(Qs(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 Ve(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,h;const{message:m}=r;return o.code==="invalid_enum_value"?{message:m??c.defaultError}:typeof c.data>"u"?{message:(u=m??n)!==null&&u!==void 0?u:c.defaultError}:o.code!=="invalid_type"?{message:c.defaultError}:{message:(h=m??t)!==null&&h!==void 0?h:c.defaultError}},description:i}}class qe{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 Kn(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Kn(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new ir,ctx:{common:e.parent.common,data:e.data,parsedType:Kn(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(eo(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:Kn(e)},s=this._parseSync({data:e,path:i.path,parent:i});return w0(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:Kn(e)},i=this._parse({data:e,path:n.path,parent:n}),s=await(eo(i)?i:Promise.resolve(i));return w0(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:F.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 Wr({schema:this,typeName:Ee.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return ln.create(this,this._def)}nullable(){return Jn.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Zr.create(this,this._def)}promise(){return ls.create(this,this._def)}or(e){return oo.create([this,e],this._def)}and(e){return ao.create(this,e,this._def)}transform(e){return new Wr({...Ve(this._def),schema:this,typeName:Ee.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new ho({...Ve(this._def),innerType:this,defaultValue:t,typeName:Ee.ZodDefault})}brand(){return new bf({typeName:Ee.ZodBranded,type:this,...Ve(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new po({...Ve(this._def),innerType:this,catchValue:t,typeName:Ee.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return yo.create(this,e)}readonly(){return go.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const dm=/^c[^\s-]{8,}$/i,pm=/^[0-9a-z]+$/,ym=/^[0-9A-HJKMNP-TV-Z]{26}$/,gm=/^[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,vm=/^[a-z0-9_-]{21}$/i,mm=/^[-+]?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)?)??$/,wm=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,bm="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let mf;const xm=/^(?:(?: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])$/,Am=/^(([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})))$/,Sm=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,b0="((\\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])))",_m=new RegExp(`^${b0}$`);function x0(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 Em(r){return new RegExp(`^${x0(r)}$`)}function A0(r){let e=`${b0}T${x0(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 Im(r,e){return!!((e==="v4"||!e)&&xm.test(r)||(e==="v6"||!e)&&Am.test(r))}class Kr extends qe{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==ie.string){const s=this._getOrReturnCtx(e);return X(s,{code:F.invalid_type,expected:ie.string,received:s.parsedType}),ke}const n=new ir;let i;for(const s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(i=this._getOrReturnCtx(e,i),X(i,{code:F.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),X(i,{code:F.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?X(i,{code:F.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):c&&X(i,{code:F.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),n.dirty())}else if(s.kind==="email")wm.test(e.data)||(i=this._getOrReturnCtx(e,i),X(i,{validation:"email",code:F.invalid_string,message:s.message}),n.dirty());else if(s.kind==="emoji")mf||(mf=new RegExp(bm,"u")),mf.test(e.data)||(i=this._getOrReturnCtx(e,i),X(i,{validation:"emoji",code:F.invalid_string,message:s.message}),n.dirty());else if(s.kind==="uuid")gm.test(e.data)||(i=this._getOrReturnCtx(e,i),X(i,{validation:"uuid",code:F.invalid_string,message:s.message}),n.dirty());else if(s.kind==="nanoid")vm.test(e.data)||(i=this._getOrReturnCtx(e,i),X(i,{validation:"nanoid",code:F.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid")dm.test(e.data)||(i=this._getOrReturnCtx(e,i),X(i,{validation:"cuid",code:F.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid2")pm.test(e.data)||(i=this._getOrReturnCtx(e,i),X(i,{validation:"cuid2",code:F.invalid_string,message:s.message}),n.dirty());else if(s.kind==="ulid")ym.test(e.data)||(i=this._getOrReturnCtx(e,i),X(i,{validation:"ulid",code:F.invalid_string,message:s.message}),n.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),X(i,{validation:"url",code:F.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),X(i,{validation:"regex",code:F.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),X(i,{code:F.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),X(i,{code:F.invalid_string,validation:{startsWith:s.value},message:s.message}),n.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(i=this._getOrReturnCtx(e,i),X(i,{code:F.invalid_string,validation:{endsWith:s.value},message:s.message}),n.dirty()):s.kind==="datetime"?A0(s).test(e.data)||(i=this._getOrReturnCtx(e,i),X(i,{code:F.invalid_string,validation:"datetime",message:s.message}),n.dirty()):s.kind==="date"?_m.test(e.data)||(i=this._getOrReturnCtx(e,i),X(i,{code:F.invalid_string,validation:"date",message:s.message}),n.dirty()):s.kind==="time"?Em(s).test(e.data)||(i=this._getOrReturnCtx(e,i),X(i,{code:F.invalid_string,validation:"time",message:s.message}),n.dirty()):s.kind==="duration"?mm.test(e.data)||(i=this._getOrReturnCtx(e,i),X(i,{validation:"duration",code:F.invalid_string,message:s.message}),n.dirty()):s.kind==="ip"?Im(e.data,s.version)||(i=this._getOrReturnCtx(e,i),X(i,{validation:"ip",code:F.invalid_string,message:s.message}),n.dirty()):s.kind==="base64"?Sm.test(e.data)||(i=this._getOrReturnCtx(e,i),X(i,{validation:"base64",code:F.invalid_string,message:s.message}),n.dirty()):ot.assertNever(s);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(i=>e.test(i),{validation:t,code:F.invalid_string,...xe.errToObj(n)})}_addCheck(e){return new Kr({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...xe.errToObj(e)})}url(e){return this._addCheck({kind:"url",...xe.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...xe.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...xe.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...xe.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...xe.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...xe.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...xe.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...xe.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...xe.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,...xe.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,...xe.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...xe.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...xe.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...xe.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...xe.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...xe.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...xe.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...xe.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...xe.errToObj(t)})}nonempty(e){return this.min(1,xe.errToObj(e))}trim(){return new Kr({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Kr({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Kr({...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}}Kr.create=r=>{var e;return new Kr({checks:[],typeName:Ee.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...Ve(r)})};function km(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 Zn extends qe{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)!==ie.number){const s=this._getOrReturnCtx(e);return X(s,{code:F.invalid_type,expected:ie.number,received:s.parsedType}),ke}let n;const i=new ir;for(const s of this._def.checks)s.kind==="int"?ot.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),X(n,{code:F.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),X(n,{code:F.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),X(n,{code:F.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="multipleOf"?km(e.data,s.value)!==0&&(n=this._getOrReturnCtx(e,n),X(n,{code:F.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),X(n,{code:F.not_finite,message:s.message}),i.dirty()):ot.assertNever(s);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,xe.toString(t))}gt(e,t){return this.setLimit("min",e,!1,xe.toString(t))}lte(e,t){return this.setLimit("max",e,!0,xe.toString(t))}lt(e,t){return this.setLimit("max",e,!1,xe.toString(t))}setLimit(e,t,n,i){return new Zn({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:xe.toString(i)}]})}_addCheck(e){return new Zn({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:xe.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:xe.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:xe.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:xe.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:xe.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:xe.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:xe.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:xe.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:xe.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"&&ot.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)}}Zn.create=r=>new Zn({checks:[],typeName:Ee.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...Ve(r)});class Wn extends qe{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)!==ie.bigint){const s=this._getOrReturnCtx(e);return X(s,{code:F.invalid_type,expected:ie.bigint,received:s.parsedType}),ke}let n;const i=new ir;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),X(n,{code:F.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),X(n,{code:F.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),X(n,{code:F.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):ot.assertNever(s);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,xe.toString(t))}gt(e,t){return this.setLimit("min",e,!1,xe.toString(t))}lte(e,t){return this.setLimit("max",e,!0,xe.toString(t))}lt(e,t){return this.setLimit("max",e,!1,xe.toString(t))}setLimit(e,t,n,i){return new Wn({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:xe.toString(i)}]})}_addCheck(e){return new Wn({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:xe.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:xe.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:xe.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:xe.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:xe.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}}Wn.create=r=>{var e;return new Wn({checks:[],typeName:Ee.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...Ve(r)})};class no extends qe{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==ie.boolean){const n=this._getOrReturnCtx(e);return X(n,{code:F.invalid_type,expected:ie.boolean,received:n.parsedType}),ke}return hr(e.data)}}no.create=r=>new no({typeName:Ee.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...Ve(r)});class _i extends qe{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==ie.date){const s=this._getOrReturnCtx(e);return X(s,{code:F.invalid_type,expected:ie.date,received:s.parsedType}),ke}if(isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return X(s,{code:F.invalid_date}),ke}const n=new ir;let i;for(const s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(i=this._getOrReturnCtx(e,i),X(i,{code:F.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),X(i,{code:F.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),n.dirty()):ot.assertNever(s);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new _i({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:xe.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:xe.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}}_i.create=r=>new _i({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:Ee.ZodDate,...Ve(r)});class _c extends qe{_parse(e){if(this._getType(e)!==ie.symbol){const n=this._getOrReturnCtx(e);return X(n,{code:F.invalid_type,expected:ie.symbol,received:n.parsedType}),ke}return hr(e.data)}}_c.create=r=>new _c({typeName:Ee.ZodSymbol,...Ve(r)});class io extends qe{_parse(e){if(this._getType(e)!==ie.undefined){const n=this._getOrReturnCtx(e);return X(n,{code:F.invalid_type,expected:ie.undefined,received:n.parsedType}),ke}return hr(e.data)}}io.create=r=>new io({typeName:Ee.ZodUndefined,...Ve(r)});class so extends qe{_parse(e){if(this._getType(e)!==ie.null){const n=this._getOrReturnCtx(e);return X(n,{code:F.invalid_type,expected:ie.null,received:n.parsedType}),ke}return hr(e.data)}}so.create=r=>new so({typeName:Ee.ZodNull,...Ve(r)});class os extends qe{constructor(){super(...arguments),this._any=!0}_parse(e){return hr(e.data)}}os.create=r=>new os({typeName:Ee.ZodAny,...Ve(r)});class Ei extends qe{constructor(){super(...arguments),this._unknown=!0}_parse(e){return hr(e.data)}}Ei.create=r=>new Ei({typeName:Ee.ZodUnknown,...Ve(r)});class Bn extends qe{_parse(e){const t=this._getOrReturnCtx(e);return X(t,{code:F.invalid_type,expected:ie.never,received:t.parsedType}),ke}}Bn.create=r=>new Bn({typeName:Ee.ZodNever,...Ve(r)});class Ec extends qe{_parse(e){if(this._getType(e)!==ie.undefined){const n=this._getOrReturnCtx(e);return X(n,{code:F.invalid_type,expected:ie.void,received:n.parsedType}),ke}return hr(e.data)}}Ec.create=r=>new Ec({typeName:Ee.ZodVoid,...Ve(r)});class Zr extends qe{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),i=this._def;if(t.parsedType!==ie.array)return X(t,{code:F.invalid_type,expected:ie.array,received:t.parsedType}),ke;if(i.exactLength!==null){const o=t.data.length>i.exactLength.value,c=t.data.length<i.exactLength.value;(o||c)&&(X(t,{code:o?F.too_big:F.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&&(X(t,{code:F.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&&(X(t,{code:F.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 an(t,o,t.path,c)))).then(o=>ir.mergeArray(n,o));const s=[...t.data].map((o,c)=>i.type._parseSync(new an(t,o,t.path,c)));return ir.mergeArray(n,s)}get element(){return this._def.type}min(e,t){return new Zr({...this._def,minLength:{value:e,message:xe.toString(t)}})}max(e,t){return new Zr({...this._def,maxLength:{value:e,message:xe.toString(t)}})}length(e,t){return new Zr({...this._def,exactLength:{value:e,message:xe.toString(t)}})}nonempty(e){return this.min(1,e)}}Zr.create=(r,e)=>new Zr({type:r,minLength:null,maxLength:null,exactLength:null,typeName:Ee.ZodArray,...Ve(e)});function as(r){if(r instanceof Ot){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=ln.create(as(n))}return new Ot({...r._def,shape:()=>e})}else return r instanceof Zr?new Zr({...r._def,type:as(r.element)}):r instanceof ln?ln.create(as(r.unwrap())):r instanceof Jn?Jn.create(as(r.unwrap())):r instanceof cn?cn.create(r.items.map(e=>as(e))):r}class Ot extends qe{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=ot.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==ie.object){const h=this._getOrReturnCtx(e);return X(h,{code:F.invalid_type,expected:ie.object,received:h.parsedType}),ke}const{status:n,ctx:i}=this._processInputParams(e),{shape:s,keys:o}=this._getCached(),c=[];if(!(this._def.catchall instanceof Bn&&this._def.unknownKeys==="strip"))for(const h in i.data)o.includes(h)||c.push(h);const u=[];for(const h of o){const m=s[h],x=i.data[h];u.push({key:{status:"valid",value:h},value:m._parse(new an(i,x,i.path,h)),alwaysSet:h in i.data})}if(this._def.catchall instanceof Bn){const h=this._def.unknownKeys;if(h==="passthrough")for(const m of c)u.push({key:{status:"valid",value:m},value:{status:"valid",value:i.data[m]}});else if(h==="strict")c.length>0&&(X(i,{code:F.unrecognized_keys,keys:c}),n.dirty());else if(h!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const h=this._def.catchall;for(const m of c){const x=i.data[m];u.push({key:{status:"valid",value:m},value:h._parse(new an(i,x,i.path,m)),alwaysSet:m in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const h=[];for(const m of u){const x=await m.key,G=await m.value;h.push({key:x,value:G,alwaysSet:m.alwaysSet})}return h}).then(h=>ir.mergeObjectSync(n,h)):ir.mergeObjectSync(n,u)}get shape(){return this._def.shape()}strict(e){return xe.errToObj,new Ot({...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=xe.errToObj(e).message)!==null&&c!==void 0?c:u}:{message:u}}}:{}})}strip(){return new Ot({...this._def,unknownKeys:"strip"})}passthrough(){return new Ot({...this._def,unknownKeys:"passthrough"})}extend(e){return new Ot({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Ot({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:Ee.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Ot({...this._def,catchall:e})}pick(e){const t={};return ot.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new Ot({...this._def,shape:()=>t})}omit(e){const t={};return ot.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new Ot({...this._def,shape:()=>t})}deepPartial(){return as(this)}partial(e){const t={};return ot.objectKeys(this.shape).forEach(n=>{const i=this.shape[n];e&&!e[n]?t[n]=i:t[n]=i.optional()}),new Ot({...this._def,shape:()=>t})}required(e){const t={};return ot.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let s=this.shape[n];for(;s instanceof ln;)s=s._def.innerType;t[n]=s}}),new Ot({...this._def,shape:()=>t})}keyof(){return S0(ot.objectKeys(this.shape))}}Ot.create=(r,e)=>new Ot({shape:()=>r,unknownKeys:"strip",catchall:Bn.create(),typeName:Ee.ZodObject,...Ve(e)}),Ot.strictCreate=(r,e)=>new Ot({shape:()=>r,unknownKeys:"strict",catchall:Bn.create(),typeName:Ee.ZodObject,...Ve(e)}),Ot.lazycreate=(r,e)=>new Ot({shape:r,unknownKeys:"strip",catchall:Bn.create(),typeName:Ee.ZodObject,...Ve(e)});class oo extends qe{_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 X(t,{code:F.invalid_union,unionErrors:o}),ke}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 h={...t,common:{...t.common,issues:[]},parent:null},m=u._parseSync({data:t.data,path:t.path,parent:h});if(m.status==="valid")return m;m.status==="dirty"&&!s&&(s={result:m,ctx:h}),h.common.issues.length&&o.push(h.common.issues)}if(s)return t.common.issues.push(...s.ctx.common.issues),s.result;const c=o.map(u=>new kr(u));return X(t,{code:F.invalid_union,unionErrors:c}),ke}}get options(){return this._def.options}}oo.create=(r,e)=>new oo({options:r,typeName:Ee.ZodUnion,...Ve(e)});const On=r=>r instanceof lo?On(r.schema):r instanceof Wr?On(r.innerType()):r instanceof uo?[r.value]:r instanceof Yn?r.options:r instanceof fo?ot.objectValues(r.enum):r instanceof ho?On(r._def.innerType):r instanceof io?[void 0]:r instanceof so?[null]:r instanceof ln?[void 0,...On(r.unwrap())]:r instanceof Jn?[null,...On(r.unwrap())]:r instanceof bf||r instanceof go?On(r.unwrap()):r instanceof po?On(r._def.innerType):[];class Ic extends qe{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==ie.object)return X(t,{code:F.invalid_type,expected:ie.object,received:t.parsedType}),ke;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}):(X(t,{code:F.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),ke)}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=On(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 Ic({typeName:Ee.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:i,...Ve(n)})}}function wf(r,e){const t=Kn(r),n=Kn(e);if(r===e)return{valid:!0,data:r};if(t===ie.object&&n===ie.object){const i=ot.objectKeys(e),s=ot.objectKeys(r).filter(c=>i.indexOf(c)!==-1),o={...r,...e};for(const c of s){const u=wf(r[c],e[c]);if(!u.valid)return{valid:!1};o[c]=u.data}return{valid:!0,data:o}}else if(t===ie.array&&n===ie.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=wf(o,c);if(!u.valid)return{valid:!1};i.push(u.data)}return{valid:!0,data:i}}else return t===ie.date&&n===ie.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class ao extends qe{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),i=(s,o)=>{if(gf(s)||gf(o))return ke;const c=wf(s.value,o.value);return c.valid?((vf(s)||vf(o))&&t.dirty(),{status:t.value,value:c.data}):(X(n,{code:F.invalid_intersection_types}),ke)};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}))}}ao.create=(r,e,t)=>new ao({left:r,right:e,typeName:Ee.ZodIntersection,...Ve(t)});class cn extends qe{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==ie.array)return X(n,{code:F.invalid_type,expected:ie.array,received:n.parsedType}),ke;if(n.data.length<this._def.items.length)return X(n,{code:F.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),ke;!this._def.rest&&n.data.length>this._def.items.length&&(X(n,{code:F.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 an(n,o,n.path,c)):null}).filter(o=>!!o);return n.common.async?Promise.all(s).then(o=>ir.mergeArray(t,o)):ir.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new cn({...this._def,rest:e})}}cn.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new cn({items:r,typeName:Ee.ZodTuple,rest:null,...Ve(e)})};class co extends qe{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!==ie.object)return X(n,{code:F.invalid_type,expected:ie.object,received:n.parsedType}),ke;const i=[],s=this._def.keyType,o=this._def.valueType;for(const c in n.data)i.push({key:s._parse(new an(n,c,n.path,c)),value:o._parse(new an(n,n.data[c],n.path,c)),alwaysSet:c in n.data});return n.common.async?ir.mergeObjectAsync(t,i):ir.mergeObjectSync(t,i)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof qe?new co({keyType:e,valueType:t,typeName:Ee.ZodRecord,...Ve(n)}):new co({keyType:Kr.create(),valueType:e,typeName:Ee.ZodRecord,...Ve(t)})}}class kc extends qe{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!==ie.map)return X(n,{code:F.invalid_type,expected:ie.map,received:n.parsedType}),ke;const i=this._def.keyType,s=this._def.valueType,o=[...n.data.entries()].map(([c,u],h)=>({key:i._parse(new an(n,c,n.path,[h,"key"])),value:s._parse(new an(n,u,n.path,[h,"value"]))}));if(n.common.async){const c=new Map;return Promise.resolve().then(async()=>{for(const u of o){const h=await u.key,m=await u.value;if(h.status==="aborted"||m.status==="aborted")return ke;(h.status==="dirty"||m.status==="dirty")&&t.dirty(),c.set(h.value,m.value)}return{status:t.value,value:c}})}else{const c=new Map;for(const u of o){const h=u.key,m=u.value;if(h.status==="aborted"||m.status==="aborted")return ke;(h.status==="dirty"||m.status==="dirty")&&t.dirty(),c.set(h.value,m.value)}return{status:t.value,value:c}}}}kc.create=(r,e,t)=>new kc({valueType:e,keyType:r,typeName:Ee.ZodMap,...Ve(t)});class Ii extends qe{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==ie.set)return X(n,{code:F.invalid_type,expected:ie.set,received:n.parsedType}),ke;const i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(X(n,{code:F.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&&(X(n,{code:F.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 h=new Set;for(const m of u){if(m.status==="aborted")return ke;m.status==="dirty"&&t.dirty(),h.add(m.value)}return{status:t.value,value:h}}const c=[...n.data.values()].map((u,h)=>s._parse(new an(n,u,n.path,h)));return n.common.async?Promise.all(c).then(u=>o(u)):o(c)}min(e,t){return new Ii({...this._def,minSize:{value:e,message:xe.toString(t)}})}max(e,t){return new Ii({...this._def,maxSize:{value:e,message:xe.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}Ii.create=(r,e)=>new Ii({valueType:r,minSize:null,maxSize:null,typeName:Ee.ZodSet,...Ve(e)});class cs extends qe{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==ie.function)return X(t,{code:F.invalid_type,expected:ie.function,received:t.parsedType}),ke;function n(c,u){return Ac({data:c,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,xc(),is].filter(h=>!!h),issueData:{code:F.invalid_arguments,argumentsError:u}})}function i(c,u){return Ac({data:c,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,xc(),is].filter(h=>!!h),issueData:{code:F.invalid_return_type,returnTypeError:u}})}const s={errorMap:t.common.contextualErrorMap},o=t.data;if(this._def.returns instanceof ls){const c=this;return hr(async function(...u){const h=new kr([]),m=await c._def.args.parseAsync(u,s).catch(N=>{throw h.addIssue(n(u,N)),h}),x=await Reflect.apply(o,this,m);return await c._def.returns._def.type.parseAsync(x,s).catch(N=>{throw h.addIssue(i(x,N)),h})})}else{const c=this;return hr(function(...u){const h=c._def.args.safeParse(u,s);if(!h.success)throw new kr([n(u,h.error)]);const m=Reflect.apply(o,this,h.data),x=c._def.returns.safeParse(m,s);if(!x.success)throw new kr([i(m,x.error)]);return x.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new cs({...this._def,args:cn.create(e).rest(Ei.create())})}returns(e){return new cs({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new cs({args:e||cn.create([]).rest(Ei.create()),returns:t||Ei.create(),typeName:Ee.ZodFunction,...Ve(n)})}}class lo extends qe{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})}}lo.create=(r,e)=>new lo({getter:r,typeName:Ee.ZodLazy,...Ve(e)});class uo extends qe{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return X(t,{received:t.data,code:F.invalid_literal,expected:this._def.value}),ke}return{status:"valid",value:e.data}}get value(){return this._def.value}}uo.create=(r,e)=>new uo({value:r,typeName:Ee.ZodLiteral,...Ve(e)});function S0(r,e){return new Yn({values:r,typeName:Ee.ZodEnum,...Ve(e)})}class Yn extends qe{constructor(){super(...arguments),to.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return X(t,{expected:ot.joinValues(n),received:t.parsedType,code:F.invalid_type}),ke}if(Sc(this,to)||m0(this,to,new Set(this._def.values)),!Sc(this,to).has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return X(t,{received:t.data,code:F.invalid_enum_value,options:n}),ke}return hr(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 Yn.create(e,{...this._def,...t})}exclude(e,t=this._def){return Yn.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}}to=new WeakMap,Yn.create=S0;class fo extends qe{constructor(){super(...arguments),ro.set(this,void 0)}_parse(e){const t=ot.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==ie.string&&n.parsedType!==ie.number){const i=ot.objectValues(t);return X(n,{expected:ot.joinValues(i),received:n.parsedType,code:F.invalid_type}),ke}if(Sc(this,ro)||m0(this,ro,new Set(ot.getValidEnumValues(this._def.values))),!Sc(this,ro).has(e.data)){const i=ot.objectValues(t);return X(n,{received:n.data,code:F.invalid_enum_value,options:i}),ke}return hr(e.data)}get enum(){return this._def.values}}ro=new WeakMap,fo.create=(r,e)=>new fo({values:r,typeName:Ee.ZodNativeEnum,...Ve(e)});class ls extends qe{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==ie.promise&&t.common.async===!1)return X(t,{code:F.invalid_type,expected:ie.promise,received:t.parsedType}),ke;const n=t.parsedType===ie.promise?t.data:Promise.resolve(t.data);return hr(n.then(i=>this._def.type.parseAsync(i,{path:t.path,errorMap:t.common.contextualErrorMap})))}}ls.create=(r,e)=>new ls({type:r,typeName:Ee.ZodPromise,...Ve(e)});class Wr extends qe{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Ee.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=>{X(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 ke;const u=await this._def.schema._parseAsync({data:c,path:n.path,parent:n});return u.status==="aborted"?ke:u.status==="dirty"||t.value==="dirty"?ss(u.value):u});{if(t.value==="aborted")return ke;const c=this._def.schema._parseSync({data:o,path:n.path,parent:n});return c.status==="aborted"?ke:c.status==="dirty"||t.value==="dirty"?ss(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"?ke:(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"?ke:(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(!Qs(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=>Qs(o)?Promise.resolve(i.transform(o.value,s)).then(c=>({status:t.value,value:c})):o);ot.assertNever(i)}}Wr.create=(r,e,t)=>new Wr({schema:r,typeName:Ee.ZodEffects,effect:e,...Ve(t)}),Wr.createWithPreprocess=(r,e,t)=>new Wr({schema:e,effect:{type:"preprocess",transform:r},typeName:Ee.ZodEffects,...Ve(t)});class ln extends qe{_parse(e){return this._getType(e)===ie.undefined?hr(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ln.create=(r,e)=>new ln({innerType:r,typeName:Ee.ZodOptional,...Ve(e)});class Jn extends qe{_parse(e){return this._getType(e)===ie.null?hr(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Jn.create=(r,e)=>new Jn({innerType:r,typeName:Ee.ZodNullable,...Ve(e)});class ho extends qe{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===ie.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}ho.create=(r,e)=>new ho({innerType:r,typeName:Ee.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...Ve(e)});class po extends qe{_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 eo(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}}po.create=(r,e)=>new po({innerType:r,typeName:Ee.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...Ve(e)});class Cc extends qe{_parse(e){if(this._getType(e)!==ie.nan){const n=this._getOrReturnCtx(e);return X(n,{code:F.invalid_type,expected:ie.nan,received:n.parsedType}),ke}return{status:"valid",value:e.data}}}Cc.create=r=>new Cc({typeName:Ee.ZodNaN,...Ve(r)});const Cm=Symbol("zod_brand");class bf extends qe{_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 yo extends qe{_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"?ke:s.status==="dirty"?(t.dirty(),ss(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"?ke: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 yo({in:e,out:t,typeName:Ee.ZodPipeline})}}class go extends qe{_parse(e){const t=this._def.innerType._parse(e),n=i=>(Qs(i)&&(i.value=Object.freeze(i.value)),i);return eo(t)?t.then(i=>n(i)):n(t)}unwrap(){return this._def.innerType}}go.create=(r,e)=>new go({innerType:r,typeName:Ee.ZodReadonly,...Ve(e)});function _0(r,e={},t){return r?os.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,h=typeof c=="string"?{message:c}:c;i.addIssue({code:"custom",...h,fatal:u})}}):os.create()}const Bm={object:Ot.lazycreate};var Ee;(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"})(Ee||(Ee={}));const Om=(r,e={message:`Input not instance of ${r.name}`})=>_0(t=>t instanceof r,e),E0=Kr.create,I0=Zn.create,Tm=Cc.create,Nm=Wn.create,k0=no.create,Pm=_i.create,jm=_c.create,Rm=io.create,Um=so.create,Dm=os.create,$m=Ei.create,Mm=Bn.create,Vm=Ec.create,Lm=Zr.create,Hm=Ot.create,Fm=Ot.strictCreate,zm=oo.create,Gm=Ic.create,qm=ao.create,Km=cn.create,Zm=co.create,Wm=kc.create,Ym=Ii.create,Jm=cs.create,Xm=lo.create,Qm=uo.create,e1=Yn.create,t1=fo.create,r1=ls.create,C0=Wr.create,n1=ln.create,i1=Jn.create,s1=Wr.createWithPreprocess,o1=yo.create;var Tt=Object.freeze({__proto__:null,defaultErrorMap:is,setErrorMap:fm,getErrorMap:xc,makeIssue:Ac,EMPTY_PATH:hm,addIssueToContext:X,ParseStatus:ir,INVALID:ke,DIRTY:ss,OK:hr,isAborted:gf,isDirty:vf,isValid:Qs,isAsync:eo,get util(){return ot},get objectUtil(){return yf},ZodParsedType:ie,getParsedType:Kn,ZodType:qe,datetimeRegex:A0,ZodString:Kr,ZodNumber:Zn,ZodBigInt:Wn,ZodBoolean:no,ZodDate:_i,ZodSymbol:_c,ZodUndefined:io,ZodNull:so,ZodAny:os,ZodUnknown:Ei,ZodNever:Bn,ZodVoid:Ec,ZodArray:Zr,ZodObject:Ot,ZodUnion:oo,ZodDiscriminatedUnion:Ic,ZodIntersection:ao,ZodTuple:cn,ZodRecord:co,ZodMap:kc,ZodSet:Ii,ZodFunction:cs,ZodLazy:lo,ZodLiteral:uo,ZodEnum:Yn,ZodNativeEnum:fo,ZodPromise:ls,ZodEffects:Wr,ZodTransformer:Wr,ZodOptional:ln,ZodNullable:Jn,ZodDefault:ho,ZodCatch:po,ZodNaN:Cc,BRAND:Cm,ZodBranded:bf,ZodPipeline:yo,ZodReadonly:go,custom:_0,Schema:qe,ZodSchema:qe,late:Bm,get ZodFirstPartyTypeKind(){return Ee},coerce:{string:r=>Kr.create({...r,coerce:!0}),number:r=>Zn.create({...r,coerce:!0}),boolean:r=>no.create({...r,coerce:!0}),bigint:r=>Wn.create({...r,coerce:!0}),date:r=>_i.create({...r,coerce:!0})},any:Dm,array:Lm,bigint:Nm,boolean:k0,date:Pm,discriminatedUnion:Gm,effect:C0,enum:e1,function:Jm,instanceof:Om,intersection:qm,lazy:Xm,literal:Qm,map:Wm,nan:Tm,nativeEnum:t1,never:Mm,null:Um,nullable:i1,number:I0,object:Hm,oboolean:()=>k0().optional(),onumber:()=>I0().optional(),optional:n1,ostring:()=>E0().optional(),pipeline:o1,preprocess:s1,promise:r1,record:Zm,set:Ym,strictObject:Fm,string:E0,symbol:jm,transformer:C0,tuple:Km,undefined:Rm,union:zm,unknown:$m,void:Vm,NEVER:ke,ZodIssueCode:F,quotelessJson:um,ZodError:kr});const Bc=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(!Bc||Bc.length===0)throw new Error("AWS root certificate is empty or not loaded correctly");const a1=Tt.object({module_id:Tt.string().min(1),digest:Tt.literal("SHA384"),timestamp:Tt.number().min(1677721600),pcrs:Tt.map(Tt.number(),Tt.instanceof(Uint8Array)),certificate:Tt.instanceof(Uint8Array),cabundle:Tt.array(Tt.instanceof(Uint8Array)),public_key:Tt.nullable(Tt.instanceof(Uint8Array)),user_data:Tt.nullable(Tt.instanceof(Uint8Array)),nonce:Tt.nullable(Tt.instanceof(Uint8Array))}),c1=Tt.object({protected:Tt.instanceof(Uint8Array),payload:Tt.instanceof(Uint8Array),signature:Tt.instanceof(Uint8Array)});async function l1(r){try{if(!r)throw new Error("Attestation document is empty.");const e=gs(r),t=bc(e),n=t[0],i=t[2],s=t[3];return c1.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 u1(r){try{const e=bc(r);return a1.parse(e)}catch(e){throw console.error("Error parsing document payload:",e),new Error("Failed to parse document payload.")}}function f1(r,e){const t=["Signature1",r,new Uint8Array(0),e];return gc(t)}async function h1(r,e){try{console.log("SIGNATURE:"),console.log($r(r.signature));const t=f1(r.protected,r.payload),n=await crypto.subtle.digest("SHA-384",t);return console.log("SIGNATURE STRUCTURE DIGEST:"),console.log($r(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 ki(r,e,t){try{const n=await l1(r),i=await u1(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=$r(i.cabundle[0]);if(u!==$r(e))throw console.error("Root cert doesn't match first cert"),console.log("First cert base64:",u),console.log("Trusted root cert base64:",$r(e)),new Error("Root cert does not match first cert in attestation document.");for(let I=0;I<i.cabundle.length;I++){const P=new xi(i.cabundle[I]);c.push(P)}const h=new xi(i.certificate),x=await new Uv({certificates:c}).build(h);console.log("Chain items:",x);const N=new Date().getTime();for(let I=0;I<x.length;I++){const P=x[I];if(console.log("CERT: ",I),console.log(P.subject),console.log("Not before:",P.notBefore),console.log("Not after:",P.notAfter),console.log(P.toString("pem")),P.notBefore.getTime()>N||P.notAfter.getTime()<N)throw new Error("Certificate is expired.");console.log(`Certificate ${I} is not expired.`)}if(x.length!==i.cabundle.length+1)throw new Error("Certificate chain length does not match length of cabundle.");const v=h.publicKey;console.log("PUBLIC KEY:"),console.log($r(new Uint8Array(v.rawData)));const A=await v.export(),O=await h1(n,A);if(console.log("Signature verified:",O),!O)throw new Error("Signature verification failed.");return i}catch(n){throw console.error("Error verifying attestation document:",n),n}}const d1=Tt.object({public_key:Tt.nullable(Tt.instanceof(Uint8Array))});async function p1(r){const e=gs(r),n=bc(e)[2],i=bc(n);return await d1.parse(i)}async function y1(r,e){try{const t=await R1(r,e),n=e||C1();return n&&(n==="http://127.0.0.1:3000"||n==="http://localhost:3000"||n==="http://0.0.0.0:3000")?(console.log("DEV MODE: Using fake attestation document"),await p1(t)):await ki(t,Bc,r)}catch(t){throw t instanceof Error?(console.error("Error verifying attestation document:",t),new Error(`Couldn't process attestation document: ${t.message}`)):(console.error("Error verifying attestation document:",t),new Error("Couldn't process attestation document."))}}function g1(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 B0={exports:{}};const v1=Hy(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));(function(r){(function(e){var t=function(l){var p,d=new Float64Array(16);if(l)for(p=0;p<l.length;p++)d[p]=l[p];return d},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]),h=t([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),m=t([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),x=t([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),G=t([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),N=t([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function v(l,p,d,a){l[p]=d>>24&255,l[p+1]=d>>16&255,l[p+2]=d>>8&255,l[p+3]=d&255,l[p+4]=a>>24&255,l[p+5]=a>>16&255,l[p+6]=a>>8&255,l[p+7]=a&255}function A(l,p,d,a,g){var S,E=0;for(S=0;S<g;S++)E|=l[p+S]^d[a+S];return(1&E-1>>>8)-1}function O(l,p,d,a){return A(l,p,d,a,16)}function I(l,p,d,a){return A(l,p,d,a,32)}function P(l,p,d,a){for(var g=a[0]&255|(a[1]&255)<<8|(a[2]&255)<<16|(a[3]&255)<<24,S=d[0]&255|(d[1]&255)<<8|(d[2]&255)<<16|(d[3]&255)<<24,E=d[4]&255|(d[5]&255)<<8|(d[6]&255)<<16|(d[7]&255)<<24,U=d[8]&255|(d[9]&255)<<8|(d[10]&255)<<16|(d[11]&255)<<24,z=d[12]&255|(d[13]&255)<<8|(d[14]&255)<<16|(d[15]&255)<<24,we=a[4]&255|(a[5]&255)<<8|(a[6]&255)<<16|(a[7]&255)<<24,Q=p[0]&255|(p[1]&255)<<8|(p[2]&255)<<16|(p[3]&255)<<24,ft=p[4]&255|(p[5]&255)<<8|(p[6]&255)<<16|(p[7]&255)<<24,le=p[8]&255|(p[9]&255)<<8|(p[10]&255)<<16|(p[11]&255)<<24,Ce=p[12]&255|(p[13]&255)<<8|(p[14]&255)<<16|(p[15]&255)<<24,Be=a[8]&255|(a[9]&255)<<8|(a[10]&255)<<16|(a[11]&255)<<24,Le=d[16]&255|(d[17]&255)<<8|(d[18]&255)<<16|(d[19]&255)<<24,$e=d[20]&255|(d[21]&255)<<8|(d[22]&255)<<16|(d[23]&255)<<24,Oe=d[24]&255|(d[25]&255)<<8|(d[26]&255)<<16|(d[27]&255)<<24,Ne=d[28]&255|(d[29]&255)<<8|(d[30]&255)<<16|(d[31]&255)<<24,Te=a[12]&255|(a[13]&255)<<8|(a[14]&255)<<16|(a[15]&255)<<24,pe=g,Se=S,re=E,ye=U,me=z,J=we,C=Q,B=ft,V=le,j=Ce,D=Be,L=Le,_e=$e,He=Oe,Ge=Ne,Fe=Te,w,Ye=0;Ye<20;Ye+=2)w=pe+_e|0,me^=w<<7|w>>>25,w=me+pe|0,V^=w<<9|w>>>23,w=V+me|0,_e^=w<<13|w>>>19,w=_e+V|0,pe^=w<<18|w>>>14,w=J+Se|0,j^=w<<7|w>>>25,w=j+J|0,He^=w<<9|w>>>23,w=He+j|0,Se^=w<<13|w>>>19,w=Se+He|0,J^=w<<18|w>>>14,w=D+C|0,Ge^=w<<7|w>>>25,w=Ge+D|0,re^=w<<9|w>>>23,w=re+Ge|0,C^=w<<13|w>>>19,w=C+re|0,D^=w<<18|w>>>14,w=Fe+L|0,ye^=w<<7|w>>>25,w=ye+Fe|0,B^=w<<9|w>>>23,w=B+ye|0,L^=w<<13|w>>>19,w=L+B|0,Fe^=w<<18|w>>>14,w=pe+ye|0,Se^=w<<7|w>>>25,w=Se+pe|0,re^=w<<9|w>>>23,w=re+Se|0,ye^=w<<13|w>>>19,w=ye+re|0,pe^=w<<18|w>>>14,w=J+me|0,C^=w<<7|w>>>25,w=C+J|0,B^=w<<9|w>>>23,w=B+C|0,me^=w<<13|w>>>19,w=me+B|0,J^=w<<18|w>>>14,w=D+j|0,L^=w<<7|w>>>25,w=L+D|0,V^=w<<9|w>>>23,w=V+L|0,j^=w<<13|w>>>19,w=j+V|0,D^=w<<18|w>>>14,w=Fe+Ge|0,_e^=w<<7|w>>>25,w=_e+Fe|0,He^=w<<9|w>>>23,w=He+_e|0,Ge^=w<<13|w>>>19,w=Ge+He|0,Fe^=w<<18|w>>>14;pe=pe+g|0,Se=Se+S|0,re=re+E|0,ye=ye+U|0,me=me+z|0,J=J+we|0,C=C+Q|0,B=B+ft|0,V=V+le|0,j=j+Ce|0,D=D+Be|0,L=L+Le|0,_e=_e+$e|0,He=He+Oe|0,Ge=Ge+Ne|0,Fe=Fe+Te|0,l[0]=pe>>>0&255,l[1]=pe>>>8&255,l[2]=pe>>>16&255,l[3]=pe>>>24&255,l[4]=Se>>>0&255,l[5]=Se>>>8&255,l[6]=Se>>>16&255,l[7]=Se>>>24&255,l[8]=re>>>0&255,l[9]=re>>>8&255,l[10]=re>>>16&255,l[11]=re>>>24&255,l[12]=ye>>>0&255,l[13]=ye>>>8&255,l[14]=ye>>>16&255,l[15]=ye>>>24&255,l[16]=me>>>0&255,l[17]=me>>>8&255,l[18]=me>>>16&255,l[19]=me>>>24&255,l[20]=J>>>0&255,l[21]=J>>>8&255,l[22]=J>>>16&255,l[23]=J>>>24&255,l[24]=C>>>0&255,l[25]=C>>>8&255,l[26]=C>>>16&255,l[27]=C>>>24&255,l[28]=B>>>0&255,l[29]=B>>>8&255,l[30]=B>>>16&255,l[31]=B>>>24&255,l[32]=V>>>0&255,l[33]=V>>>8&255,l[34]=V>>>16&255,l[35]=V>>>24&255,l[36]=j>>>0&255,l[37]=j>>>8&255,l[38]=j>>>16&255,l[39]=j>>>24&255,l[40]=D>>>0&255,l[41]=D>>>8&255,l[42]=D>>>16&255,l[43]=D>>>24&255,l[44]=L>>>0&255,l[45]=L>>>8&255,l[46]=L>>>16&255,l[47]=L>>>24&255,l[48]=_e>>>0&255,l[49]=_e>>>8&255,l[50]=_e>>>16&255,l[51]=_e>>>24&255,l[52]=He>>>0&255,l[53]=He>>>8&255,l[54]=He>>>16&255,l[55]=He>>>24&255,l[56]=Ge>>>0&255,l[57]=Ge>>>8&255,l[58]=Ge>>>16&255,l[59]=Ge>>>24&255,l[60]=Fe>>>0&255,l[61]=Fe>>>8&255,l[62]=Fe>>>16&255,l[63]=Fe>>>24&255}function R(l,p,d,a){for(var g=a[0]&255|(a[1]&255)<<8|(a[2]&255)<<16|(a[3]&255)<<24,S=d[0]&255|(d[1]&255)<<8|(d[2]&255)<<16|(d[3]&255)<<24,E=d[4]&255|(d[5]&255)<<8|(d[6]&255)<<16|(d[7]&255)<<24,U=d[8]&255|(d[9]&255)<<8|(d[10]&255)<<16|(d[11]&255)<<24,z=d[12]&255|(d[13]&255)<<8|(d[14]&255)<<16|(d[15]&255)<<24,we=a[4]&255|(a[5]&255)<<8|(a[6]&255)<<16|(a[7]&255)<<24,Q=p[0]&255|(p[1]&255)<<8|(p[2]&255)<<16|(p[3]&255)<<24,ft=p[4]&255|(p[5]&255)<<8|(p[6]&255)<<16|(p[7]&255)<<24,le=p[8]&255|(p[9]&255)<<8|(p[10]&255)<<16|(p[11]&255)<<24,Ce=p[12]&255|(p[13]&255)<<8|(p[14]&255)<<16|(p[15]&255)<<24,Be=a[8]&255|(a[9]&255)<<8|(a[10]&255)<<16|(a[11]&255)<<24,Le=d[16]&255|(d[17]&255)<<8|(d[18]&255)<<16|(d[19]&255)<<24,$e=d[20]&255|(d[21]&255)<<8|(d[22]&255)<<16|(d[23]&255)<<24,Oe=d[24]&255|(d[25]&255)<<8|(d[26]&255)<<16|(d[27]&255)<<24,Ne=d[28]&255|(d[29]&255)<<8|(d[30]&255)<<16|(d[31]&255)<<24,Te=a[12]&255|(a[13]&255)<<8|(a[14]&255)<<16|(a[15]&255)<<24,pe=g,Se=S,re=E,ye=U,me=z,J=we,C=Q,B=ft,V=le,j=Ce,D=Be,L=Le,_e=$e,He=Oe,Ge=Ne,Fe=Te,w,Ye=0;Ye<20;Ye+=2)w=pe+_e|0,me^=w<<7|w>>>25,w=me+pe|0,V^=w<<9|w>>>23,w=V+me|0,_e^=w<<13|w>>>19,w=_e+V|0,pe^=w<<18|w>>>14,w=J+Se|0,j^=w<<7|w>>>25,w=j+J|0,He^=w<<9|w>>>23,w=He+j|0,Se^=w<<13|w>>>19,w=Se+He|0,J^=w<<18|w>>>14,w=D+C|0,Ge^=w<<7|w>>>25,w=Ge+D|0,re^=w<<9|w>>>23,w=re+Ge|0,C^=w<<13|w>>>19,w=C+re|0,D^=w<<18|w>>>14,w=Fe+L|0,ye^=w<<7|w>>>25,w=ye+Fe|0,B^=w<<9|w>>>23,w=B+ye|0,L^=w<<13|w>>>19,w=L+B|0,Fe^=w<<18|w>>>14,w=pe+ye|0,Se^=w<<7|w>>>25,w=Se+pe|0,re^=w<<9|w>>>23,w=re+Se|0,ye^=w<<13|w>>>19,w=ye+re|0,pe^=w<<18|w>>>14,w=J+me|0,C^=w<<7|w>>>25,w=C+J|0,B^=w<<9|w>>>23,w=B+C|0,me^=w<<13|w>>>19,w=me+B|0,J^=w<<18|w>>>14,w=D+j|0,L^=w<<7|w>>>25,w=L+D|0,V^=w<<9|w>>>23,w=V+L|0,j^=w<<13|w>>>19,w=j+V|0,D^=w<<18|w>>>14,w=Fe+Ge|0,_e^=w<<7|w>>>25,w=_e+Fe|0,He^=w<<9|w>>>23,w=He+_e|0,Ge^=w<<13|w>>>19,w=Ge+He|0,Fe^=w<<18|w>>>14;l[0]=pe>>>0&255,l[1]=pe>>>8&255,l[2]=pe>>>16&255,l[3]=pe>>>24&255,l[4]=J>>>0&255,l[5]=J>>>8&255,l[6]=J>>>16&255,l[7]=J>>>24&255,l[8]=D>>>0&255,l[9]=D>>>8&255,l[10]=D>>>16&255,l[11]=D>>>24&255,l[12]=Fe>>>0&255,l[13]=Fe>>>8&255,l[14]=Fe>>>16&255,l[15]=Fe>>>24&255,l[16]=C>>>0&255,l[17]=C>>>8&255,l[18]=C>>>16&255,l[19]=C>>>24&255,l[20]=B>>>0&255,l[21]=B>>>8&255,l[22]=B>>>16&255,l[23]=B>>>24&255,l[24]=V>>>0&255,l[25]=V>>>8&255,l[26]=V>>>16&255,l[27]=V>>>24&255,l[28]=j>>>0&255,l[29]=j>>>8&255,l[30]=j>>>16&255,l[31]=j>>>24&255}function fe(l,p,d,a){P(l,p,d,a)}function Ke(l,p,d,a){R(l,p,d,a)}var Je=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function Ue(l,p,d,a,g,S,E){var U=new Uint8Array(16),z=new Uint8Array(64),we,Q;for(Q=0;Q<16;Q++)U[Q]=0;for(Q=0;Q<8;Q++)U[Q]=S[Q];for(;g>=64;){for(fe(z,U,E,Je),Q=0;Q<64;Q++)l[p+Q]=d[a+Q]^z[Q];for(we=1,Q=8;Q<16;Q++)we=we+(U[Q]&255)|0,U[Q]=we&255,we>>>=8;g-=64,p+=64,a+=64}if(g>0)for(fe(z,U,E,Je),Q=0;Q<g;Q++)l[p+Q]=d[a+Q]^z[Q];return 0}function W(l,p,d,a,g){var S=new Uint8Array(16),E=new Uint8Array(64),U,z;for(z=0;z<16;z++)S[z]=0;for(z=0;z<8;z++)S[z]=a[z];for(;d>=64;){for(fe(E,S,g,Je),z=0;z<64;z++)l[p+z]=E[z];for(U=1,z=8;z<16;z++)U=U+(S[z]&255)|0,S[z]=U&255,U>>>=8;d-=64,p+=64}if(d>0)for(fe(E,S,g,Je),z=0;z<d;z++)l[p+z]=E[z];return 0}function se(l,p,d,a,g){var S=new Uint8Array(32);Ke(S,a,g,Je);for(var E=new Uint8Array(8),U=0;U<8;U++)E[U]=a[U+16];return W(l,p,d,E,S)}function oe(l,p,d,a,g,S,E){var U=new Uint8Array(32);Ke(U,S,E,Je);for(var z=new Uint8Array(8),we=0;we<8;we++)z[we]=S[we+16];return Ue(l,p,d,a,g,z,U)}var Ae=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 p,d,a,g,S,E,U,z;p=l[0]&255|(l[1]&255)<<8,this.r[0]=p&8191,d=l[2]&255|(l[3]&255)<<8,this.r[1]=(p>>>13|d<<3)&8191,a=l[4]&255|(l[5]&255)<<8,this.r[2]=(d>>>10|a<<6)&7939,g=l[6]&255|(l[7]&255)<<8,this.r[3]=(a>>>7|g<<9)&8191,S=l[8]&255|(l[9]&255)<<8,this.r[4]=(g>>>4|S<<12)&255,this.r[5]=S>>>1&8190,E=l[10]&255|(l[11]&255)<<8,this.r[6]=(S>>>14|E<<2)&8191,U=l[12]&255|(l[13]&255)<<8,this.r[7]=(E>>>11|U<<5)&8065,z=l[14]&255|(l[15]&255)<<8,this.r[8]=(U>>>8|z<<8)&8191,this.r[9]=z>>>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};Ae.prototype.blocks=function(l,p,d){for(var a=this.fin?0:2048,g,S,E,U,z,we,Q,ft,le,Ce,Be,Le,$e,Oe,Ne,Te,pe,Se,re,ye=this.h[0],me=this.h[1],J=this.h[2],C=this.h[3],B=this.h[4],V=this.h[5],j=this.h[6],D=this.h[7],L=this.h[8],_e=this.h[9],He=this.r[0],Ge=this.r[1],Fe=this.r[2],w=this.r[3],Ye=this.r[4],ht=this.r[5],dt=this.r[6],Ze=this.r[7],lt=this.r[8],ut=this.r[9];d>=16;)g=l[p+0]&255|(l[p+1]&255)<<8,ye+=g&8191,S=l[p+2]&255|(l[p+3]&255)<<8,me+=(g>>>13|S<<3)&8191,E=l[p+4]&255|(l[p+5]&255)<<8,J+=(S>>>10|E<<6)&8191,U=l[p+6]&255|(l[p+7]&255)<<8,C+=(E>>>7|U<<9)&8191,z=l[p+8]&255|(l[p+9]&255)<<8,B+=(U>>>4|z<<12)&8191,V+=z>>>1&8191,we=l[p+10]&255|(l[p+11]&255)<<8,j+=(z>>>14|we<<2)&8191,Q=l[p+12]&255|(l[p+13]&255)<<8,D+=(we>>>11|Q<<5)&8191,ft=l[p+14]&255|(l[p+15]&255)<<8,L+=(Q>>>8|ft<<8)&8191,_e+=ft>>>5|a,le=0,Ce=le,Ce+=ye*He,Ce+=me*(5*ut),Ce+=J*(5*lt),Ce+=C*(5*Ze),Ce+=B*(5*dt),le=Ce>>>13,Ce&=8191,Ce+=V*(5*ht),Ce+=j*(5*Ye),Ce+=D*(5*w),Ce+=L*(5*Fe),Ce+=_e*(5*Ge),le+=Ce>>>13,Ce&=8191,Be=le,Be+=ye*Ge,Be+=me*He,Be+=J*(5*ut),Be+=C*(5*lt),Be+=B*(5*Ze),le=Be>>>13,Be&=8191,Be+=V*(5*dt),Be+=j*(5*ht),Be+=D*(5*Ye),Be+=L*(5*w),Be+=_e*(5*Fe),le+=Be>>>13,Be&=8191,Le=le,Le+=ye*Fe,Le+=me*Ge,Le+=J*He,Le+=C*(5*ut),Le+=B*(5*lt),le=Le>>>13,Le&=8191,Le+=V*(5*Ze),Le+=j*(5*dt),Le+=D*(5*ht),Le+=L*(5*Ye),Le+=_e*(5*w),le+=Le>>>13,Le&=8191,$e=le,$e+=ye*w,$e+=me*Fe,$e+=J*Ge,$e+=C*He,$e+=B*(5*ut),le=$e>>>13,$e&=8191,$e+=V*(5*lt),$e+=j*(5*Ze),$e+=D*(5*dt),$e+=L*(5*ht),$e+=_e*(5*Ye),le+=$e>>>13,$e&=8191,Oe=le,Oe+=ye*Ye,Oe+=me*w,Oe+=J*Fe,Oe+=C*Ge,Oe+=B*He,le=Oe>>>13,Oe&=8191,Oe+=V*(5*ut),Oe+=j*(5*lt),Oe+=D*(5*Ze),Oe+=L*(5*dt),Oe+=_e*(5*ht),le+=Oe>>>13,Oe&=8191,Ne=le,Ne+=ye*ht,Ne+=me*Ye,Ne+=J*w,Ne+=C*Fe,Ne+=B*Ge,le=Ne>>>13,Ne&=8191,Ne+=V*He,Ne+=j*(5*ut),Ne+=D*(5*lt),Ne+=L*(5*Ze),Ne+=_e*(5*dt),le+=Ne>>>13,Ne&=8191,Te=le,Te+=ye*dt,Te+=me*ht,Te+=J*Ye,Te+=C*w,Te+=B*Fe,le=Te>>>13,Te&=8191,Te+=V*Ge,Te+=j*He,Te+=D*(5*ut),Te+=L*(5*lt),Te+=_e*(5*Ze),le+=Te>>>13,Te&=8191,pe=le,pe+=ye*Ze,pe+=me*dt,pe+=J*ht,pe+=C*Ye,pe+=B*w,le=pe>>>13,pe&=8191,pe+=V*Fe,pe+=j*Ge,pe+=D*He,pe+=L*(5*ut),pe+=_e*(5*lt),le+=pe>>>13,pe&=8191,Se=le,Se+=ye*lt,Se+=me*Ze,Se+=J*dt,Se+=C*ht,Se+=B*Ye,le=Se>>>13,Se&=8191,Se+=V*w,Se+=j*Fe,Se+=D*Ge,Se+=L*He,Se+=_e*(5*ut),le+=Se>>>13,Se&=8191,re=le,re+=ye*ut,re+=me*lt,re+=J*Ze,re+=C*dt,re+=B*ht,le=re>>>13,re&=8191,re+=V*Ye,re+=j*w,re+=D*Fe,re+=L*Ge,re+=_e*He,le+=re>>>13,re&=8191,le=(le<<2)+le|0,le=le+Ce|0,Ce=le&8191,le=le>>>13,Be+=le,ye=Ce,me=Be,J=Le,C=$e,B=Oe,V=Ne,j=Te,D=pe,L=Se,_e=re,p+=16,d-=16;this.h[0]=ye,this.h[1]=me,this.h[2]=J,this.h[3]=C,this.h[4]=B,this.h[5]=V,this.h[6]=j,this.h[7]=D,this.h[8]=L,this.h[9]=_e},Ae.prototype.finish=function(l,p){var d=new Uint16Array(10),a,g,S,E;if(this.leftover){for(E=this.leftover,this.buffer[E++]=1;E<16;E++)this.buffer[E]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(a=this.h[1]>>>13,this.h[1]&=8191,E=2;E<10;E++)this.h[E]+=a,a=this.h[E]>>>13,this.h[E]&=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,d[0]=this.h[0]+5,a=d[0]>>>13,d[0]&=8191,E=1;E<10;E++)d[E]=this.h[E]+a,a=d[E]>>>13,d[E]&=8191;for(d[9]-=8192,g=(a^1)-1,E=0;E<10;E++)d[E]&=g;for(g=~g,E=0;E<10;E++)this.h[E]=this.h[E]&g|d[E];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,S=this.h[0]+this.pad[0],this.h[0]=S&65535,E=1;E<8;E++)S=(this.h[E]+this.pad[E]|0)+(S>>>16)|0,this.h[E]=S&65535;l[p+0]=this.h[0]>>>0&255,l[p+1]=this.h[0]>>>8&255,l[p+2]=this.h[1]>>>0&255,l[p+3]=this.h[1]>>>8&255,l[p+4]=this.h[2]>>>0&255,l[p+5]=this.h[2]>>>8&255,l[p+6]=this.h[3]>>>0&255,l[p+7]=this.h[3]>>>8&255,l[p+8]=this.h[4]>>>0&255,l[p+9]=this.h[4]>>>8&255,l[p+10]=this.h[5]>>>0&255,l[p+11]=this.h[5]>>>8&255,l[p+12]=this.h[6]>>>0&255,l[p+13]=this.h[6]>>>8&255,l[p+14]=this.h[7]>>>0&255,l[p+15]=this.h[7]>>>8&255},Ae.prototype.update=function(l,p,d){var a,g;if(this.leftover){for(g=16-this.leftover,g>d&&(g=d),a=0;a<g;a++)this.buffer[this.leftover+a]=l[p+a];if(d-=g,p+=g,this.leftover+=g,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(d>=16&&(g=d-d%16,this.blocks(l,p,g),p+=g,d-=g),d){for(a=0;a<d;a++)this.buffer[this.leftover+a]=l[p+a];this.leftover+=d}};function it(l,p,d,a,g,S){var E=new Ae(S);return E.update(d,a,g),E.finish(l,p),0}function It(l,p,d,a,g,S){var E=new Uint8Array(16);return it(E,0,d,a,g,S),O(l,p,E,0)}function Pt(l,p,d,a,g){var S;if(d<32)return-1;for(oe(l,0,p,0,d,a,g),it(l,16,l,32,d-32,l),S=0;S<16;S++)l[S]=0;return 0}function gt(l,p,d,a,g){var S,E=new Uint8Array(32);if(d<32||(se(E,0,32,a,g),It(p,16,p,32,d-32,E)!==0))return-1;for(oe(l,0,p,0,d,a,g),S=0;S<32;S++)l[S]=0;return 0}function et(l,p){var d;for(d=0;d<16;d++)l[d]=p[d]|0}function ce(l){var p,d,a=1;for(p=0;p<16;p++)d=l[p]+a+65535,a=Math.floor(d/65536),l[p]=d-a*65536;l[0]+=a-1+37*(a-1)}function Ie(l,p,d){for(var a,g=~(d-1),S=0;S<16;S++)a=g&(l[S]^p[S]),l[S]^=a,p[S]^=a}function wt(l,p){var d,a,g,S=t(),E=t();for(d=0;d<16;d++)E[d]=p[d];for(ce(E),ce(E),ce(E),a=0;a<2;a++){for(S[0]=E[0]-65517,d=1;d<15;d++)S[d]=E[d]-65535-(S[d-1]>>16&1),S[d-1]&=65535;S[15]=E[15]-32767-(S[14]>>16&1),g=S[15]>>16&1,S[14]&=65535,Ie(E,S,1-g)}for(d=0;d<16;d++)l[2*d]=E[d]&255,l[2*d+1]=E[d]>>8}function Vt(l,p){var d=new Uint8Array(32),a=new Uint8Array(32);return wt(d,l),wt(a,p),I(d,0,a,0)}function Lt(l){var p=new Uint8Array(32);return wt(p,l),p[0]&1}function he(l,p){var d;for(d=0;d<16;d++)l[d]=p[2*d]+(p[2*d+1]<<8);l[15]&=32767}function ct(l,p,d){for(var a=0;a<16;a++)l[a]=p[a]+d[a]}function bt(l,p,d){for(var a=0;a<16;a++)l[a]=p[a]-d[a]}function ee(l,p,d){var a,g,S=0,E=0,U=0,z=0,we=0,Q=0,ft=0,le=0,Ce=0,Be=0,Le=0,$e=0,Oe=0,Ne=0,Te=0,pe=0,Se=0,re=0,ye=0,me=0,J=0,C=0,B=0,V=0,j=0,D=0,L=0,_e=0,He=0,Ge=0,Fe=0,w=d[0],Ye=d[1],ht=d[2],dt=d[3],Ze=d[4],lt=d[5],ut=d[6],Ht=d[7],At=d[8],Ut=d[9],Dt=d[10],$t=d[11],qt=d[12],sr=d[13],or=d[14],ar=d[15];a=p[0],S+=a*w,E+=a*Ye,U+=a*ht,z+=a*dt,we+=a*Ze,Q+=a*lt,ft+=a*ut,le+=a*Ht,Ce+=a*At,Be+=a*Ut,Le+=a*Dt,$e+=a*$t,Oe+=a*qt,Ne+=a*sr,Te+=a*or,pe+=a*ar,a=p[1],E+=a*w,U+=a*Ye,z+=a*ht,we+=a*dt,Q+=a*Ze,ft+=a*lt,le+=a*ut,Ce+=a*Ht,Be+=a*At,Le+=a*Ut,$e+=a*Dt,Oe+=a*$t,Ne+=a*qt,Te+=a*sr,pe+=a*or,Se+=a*ar,a=p[2],U+=a*w,z+=a*Ye,we+=a*ht,Q+=a*dt,ft+=a*Ze,le+=a*lt,Ce+=a*ut,Be+=a*Ht,Le+=a*At,$e+=a*Ut,Oe+=a*Dt,Ne+=a*$t,Te+=a*qt,pe+=a*sr,Se+=a*or,re+=a*ar,a=p[3],z+=a*w,we+=a*Ye,Q+=a*ht,ft+=a*dt,le+=a*Ze,Ce+=a*lt,Be+=a*ut,Le+=a*Ht,$e+=a*At,Oe+=a*Ut,Ne+=a*Dt,Te+=a*$t,pe+=a*qt,Se+=a*sr,re+=a*or,ye+=a*ar,a=p[4],we+=a*w,Q+=a*Ye,ft+=a*ht,le+=a*dt,Ce+=a*Ze,Be+=a*lt,Le+=a*ut,$e+=a*Ht,Oe+=a*At,Ne+=a*Ut,Te+=a*Dt,pe+=a*$t,Se+=a*qt,re+=a*sr,ye+=a*or,me+=a*ar,a=p[5],Q+=a*w,ft+=a*Ye,le+=a*ht,Ce+=a*dt,Be+=a*Ze,Le+=a*lt,$e+=a*ut,Oe+=a*Ht,Ne+=a*At,Te+=a*Ut,pe+=a*Dt,Se+=a*$t,re+=a*qt,ye+=a*sr,me+=a*or,J+=a*ar,a=p[6],ft+=a*w,le+=a*Ye,Ce+=a*ht,Be+=a*dt,Le+=a*Ze,$e+=a*lt,Oe+=a*ut,Ne+=a*Ht,Te+=a*At,pe+=a*Ut,Se+=a*Dt,re+=a*$t,ye+=a*qt,me+=a*sr,J+=a*or,C+=a*ar,a=p[7],le+=a*w,Ce+=a*Ye,Be+=a*ht,Le+=a*dt,$e+=a*Ze,Oe+=a*lt,Ne+=a*ut,Te+=a*Ht,pe+=a*At,Se+=a*Ut,re+=a*Dt,ye+=a*$t,me+=a*qt,J+=a*sr,C+=a*or,B+=a*ar,a=p[8],Ce+=a*w,Be+=a*Ye,Le+=a*ht,$e+=a*dt,Oe+=a*Ze,Ne+=a*lt,Te+=a*ut,pe+=a*Ht,Se+=a*At,re+=a*Ut,ye+=a*Dt,me+=a*$t,J+=a*qt,C+=a*sr,B+=a*or,V+=a*ar,a=p[9],Be+=a*w,Le+=a*Ye,$e+=a*ht,Oe+=a*dt,Ne+=a*Ze,Te+=a*lt,pe+=a*ut,Se+=a*Ht,re+=a*At,ye+=a*Ut,me+=a*Dt,J+=a*$t,C+=a*qt,B+=a*sr,V+=a*or,j+=a*ar,a=p[10],Le+=a*w,$e+=a*Ye,Oe+=a*ht,Ne+=a*dt,Te+=a*Ze,pe+=a*lt,Se+=a*ut,re+=a*Ht,ye+=a*At,me+=a*Ut,J+=a*Dt,C+=a*$t,B+=a*qt,V+=a*sr,j+=a*or,D+=a*ar,a=p[11],$e+=a*w,Oe+=a*Ye,Ne+=a*ht,Te+=a*dt,pe+=a*Ze,Se+=a*lt,re+=a*ut,ye+=a*Ht,me+=a*At,J+=a*Ut,C+=a*Dt,B+=a*$t,V+=a*qt,j+=a*sr,D+=a*or,L+=a*ar,a=p[12],Oe+=a*w,Ne+=a*Ye,Te+=a*ht,pe+=a*dt,Se+=a*Ze,re+=a*lt,ye+=a*ut,me+=a*Ht,J+=a*At,C+=a*Ut,B+=a*Dt,V+=a*$t,j+=a*qt,D+=a*sr,L+=a*or,_e+=a*ar,a=p[13],Ne+=a*w,Te+=a*Ye,pe+=a*ht,Se+=a*dt,re+=a*Ze,ye+=a*lt,me+=a*ut,J+=a*Ht,C+=a*At,B+=a*Ut,V+=a*Dt,j+=a*$t,D+=a*qt,L+=a*sr,_e+=a*or,He+=a*ar,a=p[14],Te+=a*w,pe+=a*Ye,Se+=a*ht,re+=a*dt,ye+=a*Ze,me+=a*lt,J+=a*ut,C+=a*Ht,B+=a*At,V+=a*Ut,j+=a*Dt,D+=a*$t,L+=a*qt,_e+=a*sr,He+=a*or,Ge+=a*ar,a=p[15],pe+=a*w,Se+=a*Ye,re+=a*ht,ye+=a*dt,me+=a*Ze,J+=a*lt,C+=a*ut,B+=a*Ht,V+=a*At,j+=a*Ut,D+=a*Dt,L+=a*$t,_e+=a*qt,He+=a*sr,Ge+=a*or,Fe+=a*ar,S+=38*Se,E+=38*re,U+=38*ye,z+=38*me,we+=38*J,Q+=38*C,ft+=38*B,le+=38*V,Ce+=38*j,Be+=38*D,Le+=38*L,$e+=38*_e,Oe+=38*He,Ne+=38*Ge,Te+=38*Fe,g=1,a=S+g+65535,g=Math.floor(a/65536),S=a-g*65536,a=E+g+65535,g=Math.floor(a/65536),E=a-g*65536,a=U+g+65535,g=Math.floor(a/65536),U=a-g*65536,a=z+g+65535,g=Math.floor(a/65536),z=a-g*65536,a=we+g+65535,g=Math.floor(a/65536),we=a-g*65536,a=Q+g+65535,g=Math.floor(a/65536),Q=a-g*65536,a=ft+g+65535,g=Math.floor(a/65536),ft=a-g*65536,a=le+g+65535,g=Math.floor(a/65536),le=a-g*65536,a=Ce+g+65535,g=Math.floor(a/65536),Ce=a-g*65536,a=Be+g+65535,g=Math.floor(a/65536),Be=a-g*65536,a=Le+g+65535,g=Math.floor(a/65536),Le=a-g*65536,a=$e+g+65535,g=Math.floor(a/65536),$e=a-g*65536,a=Oe+g+65535,g=Math.floor(a/65536),Oe=a-g*65536,a=Ne+g+65535,g=Math.floor(a/65536),Ne=a-g*65536,a=Te+g+65535,g=Math.floor(a/65536),Te=a-g*65536,a=pe+g+65535,g=Math.floor(a/65536),pe=a-g*65536,S+=g-1+37*(g-1),g=1,a=S+g+65535,g=Math.floor(a/65536),S=a-g*65536,a=E+g+65535,g=Math.floor(a/65536),E=a-g*65536,a=U+g+65535,g=Math.floor(a/65536),U=a-g*65536,a=z+g+65535,g=Math.floor(a/65536),z=a-g*65536,a=we+g+65535,g=Math.floor(a/65536),we=a-g*65536,a=Q+g+65535,g=Math.floor(a/65536),Q=a-g*65536,a=ft+g+65535,g=Math.floor(a/65536),ft=a-g*65536,a=le+g+65535,g=Math.floor(a/65536),le=a-g*65536,a=Ce+g+65535,g=Math.floor(a/65536),Ce=a-g*65536,a=Be+g+65535,g=Math.floor(a/65536),Be=a-g*65536,a=Le+g+65535,g=Math.floor(a/65536),Le=a-g*65536,a=$e+g+65535,g=Math.floor(a/65536),$e=a-g*65536,a=Oe+g+65535,g=Math.floor(a/65536),Oe=a-g*65536,a=Ne+g+65535,g=Math.floor(a/65536),Ne=a-g*65536,a=Te+g+65535,g=Math.floor(a/65536),Te=a-g*65536,a=pe+g+65535,g=Math.floor(a/65536),pe=a-g*65536,S+=g-1+37*(g-1),l[0]=S,l[1]=E,l[2]=U,l[3]=z,l[4]=we,l[5]=Q,l[6]=ft,l[7]=le,l[8]=Ce,l[9]=Be,l[10]=Le,l[11]=$e,l[12]=Oe,l[13]=Ne,l[14]=Te,l[15]=pe}function mt(l,p){ee(l,p,p)}function Ft(l,p){var d=t(),a;for(a=0;a<16;a++)d[a]=p[a];for(a=253;a>=0;a--)mt(d,d),a!==2&&a!==4&&ee(d,d,p);for(a=0;a<16;a++)l[a]=d[a]}function mo(l,p){var d=t(),a;for(a=0;a<16;a++)d[a]=p[a];for(a=250;a>=0;a--)mt(d,d),a!==1&&ee(d,d,p);for(a=0;a<16;a++)l[a]=d[a]}function hs(l,p,d){var a=new Uint8Array(32),g=new Float64Array(80),S,E,U=t(),z=t(),we=t(),Q=t(),ft=t(),le=t();for(E=0;E<31;E++)a[E]=p[E];for(a[31]=p[31]&127|64,a[0]&=248,he(g,d),E=0;E<16;E++)z[E]=g[E],Q[E]=U[E]=we[E]=0;for(U[0]=Q[0]=1,E=254;E>=0;--E)S=a[E>>>3]>>>(E&7)&1,Ie(U,z,S),Ie(we,Q,S),ct(ft,U,we),bt(U,U,we),ct(we,z,Q),bt(z,z,Q),mt(Q,ft),mt(le,U),ee(U,we,U),ee(we,z,ft),ct(ft,U,we),bt(U,U,we),mt(z,U),bt(we,Q,le),ee(U,we,u),ct(U,U,Q),ee(we,we,U),ee(U,Q,le),ee(Q,z,g),mt(z,ft),Ie(U,z,S),Ie(we,Q,S);for(E=0;E<16;E++)g[E+16]=U[E],g[E+32]=we[E],g[E+48]=z[E],g[E+64]=Q[E];var Ce=g.subarray(32),Be=g.subarray(16);return Ft(Ce,Ce),ee(Be,Be,Ce),wt(l,Be),0}function pr(l,p){return hs(l,p,s)}function wo(l,p){return n(p,32),pr(l,p)}function Nn(l,p,d){var a=new Uint8Array(32);return hs(a,d,p),Ke(l,i,a,Je)}var bo=Pt,Sf=gt;function xo(l,p,d,a,g,S){var E=new Uint8Array(32);return Nn(E,g,S),bo(l,p,d,a,E)}function Dc(l,p,d,a,g,S){var E=new Uint8Array(32);return Nn(E,g,S),Sf(l,p,d,a,E)}var Ao=[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 So(l,p,d,a){for(var g=new Int32Array(16),S=new Int32Array(16),E,U,z,we,Q,ft,le,Ce,Be,Le,$e,Oe,Ne,Te,pe,Se,re,ye,me,J,C,B,V,j,D,L,_e=l[0],He=l[1],Ge=l[2],Fe=l[3],w=l[4],Ye=l[5],ht=l[6],dt=l[7],Ze=p[0],lt=p[1],ut=p[2],Ht=p[3],At=p[4],Ut=p[5],Dt=p[6],$t=p[7],qt=0;a>=128;){for(me=0;me<16;me++)J=8*me+qt,g[me]=d[J+0]<<24|d[J+1]<<16|d[J+2]<<8|d[J+3],S[me]=d[J+4]<<24|d[J+5]<<16|d[J+6]<<8|d[J+7];for(me=0;me<80;me++)if(E=_e,U=He,z=Ge,we=Fe,Q=w,ft=Ye,le=ht,Ce=dt,Be=Ze,Le=lt,$e=ut,Oe=Ht,Ne=At,Te=Ut,pe=Dt,Se=$t,C=dt,B=$t,V=B&65535,j=B>>>16,D=C&65535,L=C>>>16,C=(w>>>14|At<<18)^(w>>>18|At<<14)^(At>>>9|w<<23),B=(At>>>14|w<<18)^(At>>>18|w<<14)^(w>>>9|At<<23),V+=B&65535,j+=B>>>16,D+=C&65535,L+=C>>>16,C=w&Ye^~w&ht,B=At&Ut^~At&Dt,V+=B&65535,j+=B>>>16,D+=C&65535,L+=C>>>16,C=Ao[me*2],B=Ao[me*2+1],V+=B&65535,j+=B>>>16,D+=C&65535,L+=C>>>16,C=g[me%16],B=S[me%16],V+=B&65535,j+=B>>>16,D+=C&65535,L+=C>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,re=D&65535|L<<16,ye=V&65535|j<<16,C=re,B=ye,V=B&65535,j=B>>>16,D=C&65535,L=C>>>16,C=(_e>>>28|Ze<<4)^(Ze>>>2|_e<<30)^(Ze>>>7|_e<<25),B=(Ze>>>28|_e<<4)^(_e>>>2|Ze<<30)^(_e>>>7|Ze<<25),V+=B&65535,j+=B>>>16,D+=C&65535,L+=C>>>16,C=_e&He^_e&Ge^He&Ge,B=Ze<^Ze&ut^lt&ut,V+=B&65535,j+=B>>>16,D+=C&65535,L+=C>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,Ce=D&65535|L<<16,Se=V&65535|j<<16,C=we,B=Oe,V=B&65535,j=B>>>16,D=C&65535,L=C>>>16,C=re,B=ye,V+=B&65535,j+=B>>>16,D+=C&65535,L+=C>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,we=D&65535|L<<16,Oe=V&65535|j<<16,He=E,Ge=U,Fe=z,w=we,Ye=Q,ht=ft,dt=le,_e=Ce,lt=Be,ut=Le,Ht=$e,At=Oe,Ut=Ne,Dt=Te,$t=pe,Ze=Se,me%16===15)for(J=0;J<16;J++)C=g[J],B=S[J],V=B&65535,j=B>>>16,D=C&65535,L=C>>>16,C=g[(J+9)%16],B=S[(J+9)%16],V+=B&65535,j+=B>>>16,D+=C&65535,L+=C>>>16,re=g[(J+1)%16],ye=S[(J+1)%16],C=(re>>>1|ye<<31)^(re>>>8|ye<<24)^re>>>7,B=(ye>>>1|re<<31)^(ye>>>8|re<<24)^(ye>>>7|re<<25),V+=B&65535,j+=B>>>16,D+=C&65535,L+=C>>>16,re=g[(J+14)%16],ye=S[(J+14)%16],C=(re>>>19|ye<<13)^(ye>>>29|re<<3)^re>>>6,B=(ye>>>19|re<<13)^(re>>>29|ye<<3)^(ye>>>6|re<<26),V+=B&65535,j+=B>>>16,D+=C&65535,L+=C>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,g[J]=D&65535|L<<16,S[J]=V&65535|j<<16;C=_e,B=Ze,V=B&65535,j=B>>>16,D=C&65535,L=C>>>16,C=l[0],B=p[0],V+=B&65535,j+=B>>>16,D+=C&65535,L+=C>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,l[0]=_e=D&65535|L<<16,p[0]=Ze=V&65535|j<<16,C=He,B=lt,V=B&65535,j=B>>>16,D=C&65535,L=C>>>16,C=l[1],B=p[1],V+=B&65535,j+=B>>>16,D+=C&65535,L+=C>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,l[1]=He=D&65535|L<<16,p[1]=lt=V&65535|j<<16,C=Ge,B=ut,V=B&65535,j=B>>>16,D=C&65535,L=C>>>16,C=l[2],B=p[2],V+=B&65535,j+=B>>>16,D+=C&65535,L+=C>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,l[2]=Ge=D&65535|L<<16,p[2]=ut=V&65535|j<<16,C=Fe,B=Ht,V=B&65535,j=B>>>16,D=C&65535,L=C>>>16,C=l[3],B=p[3],V+=B&65535,j+=B>>>16,D+=C&65535,L+=C>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,l[3]=Fe=D&65535|L<<16,p[3]=Ht=V&65535|j<<16,C=w,B=At,V=B&65535,j=B>>>16,D=C&65535,L=C>>>16,C=l[4],B=p[4],V+=B&65535,j+=B>>>16,D+=C&65535,L+=C>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,l[4]=w=D&65535|L<<16,p[4]=At=V&65535|j<<16,C=Ye,B=Ut,V=B&65535,j=B>>>16,D=C&65535,L=C>>>16,C=l[5],B=p[5],V+=B&65535,j+=B>>>16,D+=C&65535,L+=C>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,l[5]=Ye=D&65535|L<<16,p[5]=Ut=V&65535|j<<16,C=ht,B=Dt,V=B&65535,j=B>>>16,D=C&65535,L=C>>>16,C=l[6],B=p[6],V+=B&65535,j+=B>>>16,D+=C&65535,L+=C>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,l[6]=ht=D&65535|L<<16,p[6]=Dt=V&65535|j<<16,C=dt,B=$t,V=B&65535,j=B>>>16,D=C&65535,L=C>>>16,C=l[7],B=p[7],V+=B&65535,j+=B>>>16,D+=C&65535,L+=C>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,l[7]=dt=D&65535|L<<16,p[7]=$t=V&65535|j<<16,qt+=128,a-=128}return a}function dn(l,p,d){var a=new Int32Array(8),g=new Int32Array(8),S=new Uint8Array(256),E,U=d;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,g[0]=4089235720,g[1]=2227873595,g[2]=4271175723,g[3]=1595750129,g[4]=2917565137,g[5]=725511199,g[6]=4215389547,g[7]=327033209,So(a,g,p,d),d%=128,E=0;E<d;E++)S[E]=p[U-d+E];for(S[d]=128,d=256-128*(d<112?1:0),S[d-9]=0,v(S,d-8,U/536870912|0,U<<3),So(a,g,S,d),E=0;E<8;E++)v(l,8*E,a[E],g[E]);return 0}function Bi(l,p){var d=t(),a=t(),g=t(),S=t(),E=t(),U=t(),z=t(),we=t(),Q=t();bt(d,l[1],l[0]),bt(Q,p[1],p[0]),ee(d,d,Q),ct(a,l[0],l[1]),ct(Q,p[0],p[1]),ee(a,a,Q),ee(g,l[3],p[3]),ee(g,g,m),ee(S,l[2],p[2]),ct(S,S,S),bt(E,a,d),bt(U,S,g),ct(z,S,g),ct(we,a,d),ee(l[0],E,U),ee(l[1],we,z),ee(l[2],z,U),ee(l[3],E,we)}function ds(l,p,d){var a;for(a=0;a<4;a++)Ie(l[a],p[a],d)}function _o(l,p){var d=t(),a=t(),g=t();Ft(g,p[2]),ee(d,p[0],g),ee(a,p[1],g),wt(l,a),l[31]^=Lt(d)<<7}function Eo(l,p,d){var a,g;for(et(l[0],o),et(l[1],c),et(l[2],c),et(l[3],o),g=255;g>=0;--g)a=d[g/8|0]>>(g&7)&1,ds(l,p,a),Bi(p,l),Bi(l,l),ds(l,p,a)}function ps(l,p){var d=[t(),t(),t(),t()];et(d[0],x),et(d[1],G),et(d[2],c),ee(d[3],x,G),Eo(l,d,p)}function Io(l,p,d){var a=new Uint8Array(64),g=[t(),t(),t(),t()],S;for(d||n(p,32),dn(a,p,32),a[0]&=248,a[31]&=127,a[31]|=64,ps(g,a),_o(l,g),S=0;S<32;S++)p[S+32]=l[S];return 0}var pn=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 ko(l,p){var d,a,g,S;for(a=63;a>=32;--a){for(d=0,g=a-32,S=a-12;g<S;++g)p[g]+=d-16*p[a]*pn[g-(a-32)],d=Math.floor((p[g]+128)/256),p[g]-=d*256;p[g]+=d,p[a]=0}for(d=0,g=0;g<32;g++)p[g]+=d-(p[31]>>4)*pn[g],d=p[g]>>8,p[g]&=255;for(g=0;g<32;g++)p[g]-=d*pn[g];for(a=0;a<32;a++)p[a+1]+=p[a]>>8,l[a]=p[a]&255}function Co(l){var p=new Float64Array(64),d;for(d=0;d<64;d++)p[d]=l[d];for(d=0;d<64;d++)l[d]=0;ko(l,p)}function $c(l,p,d,a){var g=new Uint8Array(64),S=new Uint8Array(64),E=new Uint8Array(64),U,z,we=new Float64Array(64),Q=[t(),t(),t(),t()];dn(g,a,32),g[0]&=248,g[31]&=127,g[31]|=64;var ft=d+64;for(U=0;U<d;U++)l[64+U]=p[U];for(U=0;U<32;U++)l[32+U]=g[32+U];for(dn(E,l.subarray(32),d+32),Co(E),ps(Q,E),_o(l,Q),U=32;U<64;U++)l[U]=a[U];for(dn(S,l,d+64),Co(S),U=0;U<64;U++)we[U]=0;for(U=0;U<32;U++)we[U]=E[U];for(U=0;U<32;U++)for(z=0;z<32;z++)we[U+z]+=S[U]*g[z];return ko(l.subarray(32),we),ft}function Bo(l,p){var d=t(),a=t(),g=t(),S=t(),E=t(),U=t(),z=t();return et(l[2],c),he(l[1],p),mt(g,l[1]),ee(S,g,h),bt(g,g,l[2]),ct(S,l[2],S),mt(E,S),mt(U,E),ee(z,U,E),ee(d,z,g),ee(d,d,S),mo(d,d),ee(d,d,g),ee(d,d,S),ee(d,d,S),ee(l[0],d,S),mt(a,l[0]),ee(a,a,S),Vt(a,g)&&ee(l[0],l[0],N),mt(a,l[0]),ee(a,a,S),Vt(a,g)?-1:(Lt(l[0])===p[31]>>7&&bt(l[0],o,l[0]),ee(l[3],l[0],l[1]),0)}function _(l,p,d,a){var g,S=new Uint8Array(32),E=new Uint8Array(64),U=[t(),t(),t(),t()],z=[t(),t(),t(),t()];if(d<64||Bo(z,a))return-1;for(g=0;g<d;g++)l[g]=p[g];for(g=0;g<32;g++)l[g+32]=a[g];if(dn(E,l,d),Co(E),Eo(U,z,E),ps(z,p.subarray(32)),Bi(U,z),_o(S,U),d-=64,I(p,0,S,0)){for(g=0;g<d;g++)l[g]=0;return-1}for(g=0;g<d;g++)l[g]=p[g+64];return d}var k=32,T=24,q=32,be=16,kt=32,Ct=32,De=32,Z=32,te=32,de=T,ve=q,Xe=be,st=64,xt=32,Zt=64,ys=32,Oo=64;e.lowlevel={crypto_core_hsalsa20:Ke,crypto_stream_xor:oe,crypto_stream:se,crypto_stream_salsa20_xor:Ue,crypto_stream_salsa20:W,crypto_onetimeauth:it,crypto_onetimeauth_verify:It,crypto_verify_16:O,crypto_verify_32:I,crypto_secretbox:Pt,crypto_secretbox_open:gt,crypto_scalarmult:hs,crypto_scalarmult_base:pr,crypto_box_beforenm:Nn,crypto_box_afternm:bo,crypto_box:xo,crypto_box_open:Dc,crypto_box_keypair:wo,crypto_hash:dn,crypto_sign:$c,crypto_sign_keypair:Io,crypto_sign_open:_,crypto_secretbox_KEYBYTES:k,crypto_secretbox_NONCEBYTES:T,crypto_secretbox_ZEROBYTES:q,crypto_secretbox_BOXZEROBYTES:be,crypto_scalarmult_BYTES:kt,crypto_scalarmult_SCALARBYTES:Ct,crypto_box_PUBLICKEYBYTES:De,crypto_box_SECRETKEYBYTES:Z,crypto_box_BEFORENMBYTES:te,crypto_box_NONCEBYTES:de,crypto_box_ZEROBYTES:ve,crypto_box_BOXZEROBYTES:Xe,crypto_sign_BYTES:st,crypto_sign_PUBLICKEYBYTES:xt,crypto_sign_SECRETKEYBYTES:Zt,crypto_sign_SEEDBYTES:ys,crypto_hash_BYTES:Oo,gf:t,D:h,L:pn,pack25519:wt,unpack25519:he,M:ee,A:ct,S:mt,Z:bt,pow2523:mo,add:Bi,set25519:et,modL:ko,scalarmult:Eo,scalarbase:ps};function Mc(l,p){if(l.length!==k)throw new Error("bad key size");if(p.length!==T)throw new Error("bad nonce size")}function dw(l,p){if(l.length!==De)throw new Error("bad public key size");if(p.length!==Z)throw new Error("bad secret key size")}function Br(){for(var l=0;l<arguments.length;l++)if(!(arguments[l]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}function xy(l){for(var p=0;p<l.length;p++)l[p]=0}e.randomBytes=function(l){var p=new Uint8Array(l);return n(p,l),p},e.secretbox=function(l,p,d){Br(l,p,d),Mc(d,p);for(var a=new Uint8Array(q+l.length),g=new Uint8Array(a.length),S=0;S<l.length;S++)a[S+q]=l[S];return Pt(g,a,a.length,p,d),g.subarray(be)},e.secretbox.open=function(l,p,d){Br(l,p,d),Mc(d,p);for(var a=new Uint8Array(be+l.length),g=new Uint8Array(a.length),S=0;S<l.length;S++)a[S+be]=l[S];return a.length<32||gt(g,a,a.length,p,d)!==0?null:g.subarray(q)},e.secretbox.keyLength=k,e.secretbox.nonceLength=T,e.secretbox.overheadLength=be,e.scalarMult=function(l,p){if(Br(l,p),l.length!==Ct)throw new Error("bad n size");if(p.length!==kt)throw new Error("bad p size");var d=new Uint8Array(kt);return hs(d,l,p),d},e.scalarMult.base=function(l){if(Br(l),l.length!==Ct)throw new Error("bad n size");var p=new Uint8Array(kt);return pr(p,l),p},e.scalarMult.scalarLength=Ct,e.scalarMult.groupElementLength=kt,e.box=function(l,p,d,a){var g=e.box.before(d,a);return e.secretbox(l,p,g)},e.box.before=function(l,p){Br(l,p),dw(l,p);var d=new Uint8Array(te);return Nn(d,l,p),d},e.box.after=e.secretbox,e.box.open=function(l,p,d,a){var g=e.box.before(d,a);return e.secretbox.open(l,p,g)},e.box.open.after=e.secretbox.open,e.box.keyPair=function(){var l=new Uint8Array(De),p=new Uint8Array(Z);return wo(l,p),{publicKey:l,secretKey:p}},e.box.keyPair.fromSecretKey=function(l){if(Br(l),l.length!==Z)throw new Error("bad secret key size");var p=new Uint8Array(De);return pr(p,l),{publicKey:p,secretKey:new Uint8Array(l)}},e.box.publicKeyLength=De,e.box.secretKeyLength=Z,e.box.sharedKeyLength=te,e.box.nonceLength=de,e.box.overheadLength=e.secretbox.overheadLength,e.sign=function(l,p){if(Br(l,p),p.length!==Zt)throw new Error("bad secret key size");var d=new Uint8Array(st+l.length);return $c(d,l,l.length,p),d},e.sign.open=function(l,p){if(Br(l,p),p.length!==xt)throw new Error("bad public key size");var d=new Uint8Array(l.length),a=_(d,l,l.length,p);if(a<0)return null;for(var g=new Uint8Array(a),S=0;S<g.length;S++)g[S]=d[S];return g},e.sign.detached=function(l,p){for(var d=e.sign(l,p),a=new Uint8Array(st),g=0;g<a.length;g++)a[g]=d[g];return a},e.sign.detached.verify=function(l,p,d){if(Br(l,p,d),p.length!==st)throw new Error("bad signature size");if(d.length!==xt)throw new Error("bad public key size");var a=new Uint8Array(st+l.length),g=new Uint8Array(st+l.length),S;for(S=0;S<st;S++)a[S]=p[S];for(S=0;S<l.length;S++)a[S+st]=l[S];return _(g,a,a.length,d)>=0},e.sign.keyPair=function(){var l=new Uint8Array(xt),p=new Uint8Array(Zt);return Io(l,p),{publicKey:l,secretKey:p}},e.sign.keyPair.fromSecretKey=function(l){if(Br(l),l.length!==Zt)throw new Error("bad secret key size");for(var p=new Uint8Array(xt),d=0;d<p.length;d++)p[d]=l[32+d];return{publicKey:p,secretKey:new Uint8Array(l)}},e.sign.keyPair.fromSeed=function(l){if(Br(l),l.length!==ys)throw new Error("bad seed size");for(var p=new Uint8Array(xt),d=new Uint8Array(Zt),a=0;a<32;a++)d[a]=l[a];return Io(p,d,!0),{publicKey:p,secretKey:d}},e.sign.publicKeyLength=xt,e.sign.secretKeyLength=Zt,e.sign.seedLength=ys,e.sign.signatureLength=st,e.hash=function(l){Br(l);var p=new Uint8Array(Oo);return dn(p,l,l.length),p},e.hash.hashLength=Oo,e.verify=function(l,p){return Br(l,p),l.length===0||p.length===0||l.length!==p.length?!1:A(l,0,p,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 p=65536;e.setPRNG(function(d,a){var g,S=new Uint8Array(a);for(g=0;g<a;g+=p)l.getRandomValues(S.subarray(g,g+Math.min(a-g,p)));for(g=0;g<a;g++)d[g]=S[g];xy(S)})}else typeof g1<"u"&&(l=v1,l&&l.randomBytes&&e.setPRNG(function(d,a){var g,S=l.randomBytes(a);for(g=0;g<a;g++)d[g]=S[g];xy(S)}))}()})(r.exports?r.exports:self.nacl=self.nacl||{})})(B0);var m1=B0.exports;const O0=Ly(m1);function w1(){return O0.box.keyPair()}async function Ci(r,e){const t=sessionStorage.getItem("sessionKey"),n=sessionStorage.getItem("sessionId");console.groupCollapsed("Attestation");try{if(t&&n&&!r){const o=gs(t);return console.log("Using existing attestation from session storage."),{sessionKey:o,sessionId:n}}const i=window.crypto.randomUUID();console.log("Generated attestation nonce:",i);const s=await y1(i,e);if(s&&s.public_key){console.log("Attestation document verification succeeded");const o=w1();console.log("Generated client key pair");const c=new Uint8Array(s.public_key),{encrypted_session_key:u,session_id:h}=await U1($r(o.publicKey),i,e);console.log("Key exchange completed.");const m=O0.scalarMult(o.secretKey,c),x=gs(u),G=12,N=x.slice(0,G),v=x.slice(G),O=new Hc(m).open(N,v);if(O)return console.log("Session key decrypted successfully"),window.sessionStorage.setItem("sessionKey",$r(O)),window.sessionStorage.setItem("sessionId",h),{sessionKey:O,sessionId:h};throw new Error("Failed to decrypt session key")}else throw new Error("Invalid attestation document")}catch(i){throw console.error("Error verifying attestation:",i),i}finally{console.groupEnd()}}let at="";function b1(r){at=r}async function x1(r,e){return Nt(`${at}/platform/login`,"POST",{email:r,password:e},void 0,"Failed to login")}async function A1(r,e,t,n){return Nt(`${at}/platform/register`,"POST",{email:r,password:e,invite_code:t,name:n},void 0,"Failed to register")}async function S1(r){return Nt(`${at}/platform/logout`,"POST",{refresh_token:r},void 0,"Failed to logout")}async function _1(){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 Nt(`${at}/platform/refresh`,"POST",e,void 0,"Failed to refresh platform 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 platform token:",t),t}}async function T0(r){return Re(`${at}/platform/orgs`,"POST",{name:r})}async function N0(){return Re(`${at}/platform/orgs`,"GET",void 0)}async function P0(r){return Re(`${at}/platform/orgs/${r}`,"DELETE",void 0)}async function j0(r,e,t){return Re(`${at}/platform/orgs/${r}/projects`,"POST",{name:e,description:t})}async function R0(r){return Re(`${at}/platform/orgs/${r}/projects`,"GET",void 0)}async function U0(r,e){return Re(`${at}/platform/orgs/${r}/projects/${e}`,"GET",void 0)}async function D0(r,e,t){return Re(`${at}/platform/orgs/${r}/projects/${e}`,"PATCH",t)}async function $0(r,e){return Re(`${at}/platform/orgs/${r}/projects/${e}`,"DELETE",void 0)}function E1(r){const e=/^[A-Za-z0-9+/]*[=]{0,2}$/,t=r.length%4===0,n=e.test(r);return t&&n}async function M0(r,e,t,n){if(!E1(n))throw new Error("Secret must be base64 encoded. Use @stablelib/base64's encode function to encode your data.");return Re(`${at}/platform/orgs/${r}/projects/${e}/secrets`,"POST",{key_name:t,secret:n})}async function V0(r,e){return Re(`${at}/platform/orgs/${r}/projects/${e}/secrets`,"GET",void 0)}async function L0(r,e,t){return Re(`${at}/platform/orgs/${r}/projects/${e}/secrets/${t}`,"DELETE",void 0)}async function H0(r,e){return Re(`${at}/platform/orgs/${r}/projects/${e}/settings/email`,"GET",void 0)}async function F0(r,e,t){return Re(`${at}/platform/orgs/${r}/projects/${e}/settings/email`,"PUT",t)}async function z0(r,e){return Re(`${at}/platform/orgs/${r}/projects/${e}/settings/oauth`,"GET",void 0)}async function G0(r,e,t){return Re(`${at}/platform/orgs/${r}/projects/${e}/settings/oauth`,"PUT",t)}async function q0(r,e,t){if(!e||e.trim()==="")throw new Error("Email is required");return Re(`${at}/platform/orgs/${r}/invites`,"POST",{email:e,role:t})}async function K0(r){return Re(`${at}/platform/orgs/${r}/invites`,"GET",void 0)}async function Z0(r,e){return Re(`${at}/platform/orgs/${r}/invites/${e}`,"GET",void 0)}async function W0(r,e){return Re(`${at}/platform/orgs/${r}/invites/${e}`,"DELETE",void 0)}async function Y0(r){return Re(`${at}/platform/orgs/${r}/memberships`,"GET",void 0)}async function J0(r,e,t){return Re(`${at}/platform/orgs/${r}/memberships/${e}`,"PATCH",{role:t})}async function X0(r,e){return Re(`${at}/platform/orgs/${r}/memberships/${e}`,"DELETE",void 0)}async function Q0(r){return Re(`${at}/platform/accept_invite/${r}`,"POST",void 0)}async function I1(){return Re(`${at}/platform/me`,"GET",void 0)}async function ey(r){return Nt(`${at}/platform/verify-email/${r}`,"GET",void 0,void 0,"Failed to verify email")}async function Oc(){return Re(`${at}/platform/request_verification`,"POST",void 0,"Failed to request new verification code")}async function ty(r,e){const t={email:r,hashed_secret:e};return Nt(`${at}/platform/password-reset/request`,"POST",t,void 0,"Failed to request platform password reset")}async function ry(r,e,t,n){const i={email:r,alphanumeric_code:e,plaintext_secret:t,new_password:n};return Nt(`${at}/platform/password-reset/confirm`,"POST",i,void 0,"Failed to confirm platform password reset")}async function ny(r,e){const t={current_password:r,new_password:e};return Re(`${at}/platform/change-password`,"POST",t,"Failed to change platform password")}async function Re(r,e,t,n){const i=async(s=!1)=>{try{if(s){console.log("Refreshing access token");const u=ti.getRefreshFunction(r);console.log(`Using ${u}`),u==="platformRefreshToken"?await _1():await Tc()}const o=window.localStorage.getItem("access_token");if(!o)throw new Error("No access token available");const c=await iy(r,e,t,o,n);if(c.status===401&&!s)return console.log(`Received 401 for URL ${r}, 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 iy(r,e,t,n,i){const o=ti.resolveEndpoint(r).context==="platform"?ti.platformApiUrl:void 0;let{sessionKey:c,sessionId:u}=await Ci(!1,o);const h=async(x,G=!1)=>{if(G||!c||!u){const P=await Ci(!0,o);c=P.sessionKey,u=P.sessionId}if(!c||!u)throw new Error("Failed to make encrypted API call, no attestation available.");const N=t?JSON.stringify(t):void 0,v=N?Pf(c,N):void 0,A={"Content-Type":"application/json","x-session-id":u};x&&(A.Authorization=`Bearer ${x}`);const O=await fetch(r,{method:e,headers:A,body:v?JSON.stringify({encrypted:v}):void 0}),I={status:O.status};if(O.ok)try{const P=await O.json(),R=jf(c,P.encrypted);I.data=JSON.parse(R)}catch(P){console.error("Error decrypting or parsing response:",P),I.status=500,I.error="Failed to decrypt or parse the response"}else try{const P=await O.json();I.error=P.message||i||`HTTP error! Status: ${O.status}`}catch{I.error=i||`HTTP error! Status: ${O.status}`}return I},m=async(x,G=!1)=>{var N;try{const v=await h(x,G);return(v.status===400||(N=v.error)!=null&&N.includes("Encryption error"))&&!G?(console.log("Encryption error or Bad Request, attempting to renew attestation"),m(x,!0)):v}catch(v){return{status:500,error:v instanceof Error?v.message:"Unknown error occurred"}}};return m(n)}async function Nt(r,e,t,n,i){const s=await iy(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 Qe="";function k1(r){Qe=r}function C1(){return Qe}async function B1(r,e,t){return Nt(`${Qe}/login`,"POST",{email:r,password:e,client_id:t})}async function O1(r,e,t){return Nt(`${Qe}/login`,"POST",{id:r,password:e,client_id:t})}async function T1(r,e,t,n,i){return Nt(`${Qe}/register`,"POST",{email:r,password:e,inviteCode:t.toLowerCase(),client_id:n,name:i})}async function N1(r,e,t){return Nt(`${Qe}/register`,"POST",{password:r,inviteCode:e.toLowerCase(),client_id:t})}async function Tc(){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 Nt(`${Qe}/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 P1(){return Re(`${Qe}/protected/user`,"GET",void 0,"Failed to fetch user")}async function sy(r,e){return Re(`${Qe}/protected/kv/${r}`,"PUT",e,"Failed to put key-value pair")}async function oy(r){return Re(`${Qe}/protected/kv/${r}`,"DELETE",void 0,"Failed to delete key-value pair")}async function ay(r){try{return await Re(`${Qe}/protected/kv/${r}`,"GET",void 0,"Failed to get key-value pair")}catch(e){console.error(`Error fetching key "${r}":`,e);return}}async function cy(){return Re(`${Qe}/protected/kv`,"GET",void 0,"Failed to list key-value pairs")}async function j1(r){const e={refresh_token:r};return Nt(`${Qe}/logout`,"POST",e)}async function ly(r){return Nt(`${Qe}/verify-email/${r}`,"GET",void 0,void 0,"Failed to verify email")}async function Nc(){return Re(`${Qe}/protected/request_verification`,"POST",void 0,"Failed to request new verification code")}async function R1(r,e){const n=await fetch(`${e||Qe}/attestation/${r}`);if(!n.ok)throw new Error(`Request failed with status ${n.status}`);return(await n.json()).attestation_document}async function U1(r,e,t){const i=await fetch(`${t||Qe}/key_exchange`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_public_key:r,nonce:e})});if(!i.ok)throw new Error("Key exchange failed");return i.json()}async function D1(r,e,t){const n={email:r,hashed_secret:e,client_id:t};return Nt(`${Qe}/password-reset/request`,"POST",n,void 0,"Failed to request password reset")}async function $1(r,e,t,n,i){const s={email:r,alphanumeric_code:e,plaintext_secret:t,new_password:n,client_id:i};return Nt(`${Qe}/password-reset/confirm`,"POST",s,void 0,"Failed to confirm password reset")}async function uy(r,e){const t={current_password:r,new_password:e};return Re(`${Qe}/protected/change_password`,"POST",t,"Failed to change password")}async function M1(r,e){try{return await Nt(`${Qe}/auth/github`,"POST",e?{invite_code:e,client_id:r}:{client_id:r},void 0,"Failed to initiate GitHub auth")}catch(t){throw t instanceof Error&&t.message.includes("Invalid invite code")?new Error("Invalid invite code. Please check and try again."):t}}async function V1(r,e,t){const n={code:r,state:e,invite_code:t};try{return await Nt(`${Qe}/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 L1(r,e){try{return await Nt(`${Qe}/auth/google`,"POST",e?{invite_code:e,client_id:r}:{client_id:r},void 0,"Failed to initiate Google auth")}catch(t){throw t instanceof Error&&t.message.includes("Invalid invite code")?new Error("Invalid invite code. Please check and try again."):t}}async function H1(r,e,t){const n={code:r,state:e,invite_code:t};try{return await Nt(`${Qe}/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 F1(r,e){try{return await Nt(`${Qe}/auth/apple`,"POST",e?{invite_code:e,client_id:r}:{client_id:r},void 0,"Failed to initiate Apple auth")}catch(t){throw t instanceof Error&&t.message.includes("Invalid invite code")?new Error("Invalid invite code. Please check and try again."):t}}async function z1(r,e,t){const n={code:r,state:e,invite_code:t};try{return await Nt(`${Qe}/auth/apple/callback`,"POST",n,void 0,"Apple callback failed")}catch(i){throw console.error("Detailed Apple 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 Apple."):new Error("Failed to authenticate with Apple. Please try again."):i}}async function G1(r,e,t){const n={...r,client_id:e,...t?{invite_code:t}:{}};try{return await Nt(`${Qe}/auth/apple/native`,"POST",n,void 0,"Apple Sign-In failed")}catch(i){throw console.error("Detailed Apple Sign-In 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 Apple."):i.message.includes("No email found")?new Error("Unable to retrieve email from Apple. Please try another sign-in method."):new Error("Failed to authenticate with Apple. Please try again."):i}}async function fy(r){let e=`${Qe}/protected/private_key`;const t=[];return r!=null&&r.seed_phrase_derivation_path&&t.push(`seed_phrase_derivation_path=${encodeURIComponent(r.seed_phrase_derivation_path)}`),r!=null&&r.private_key_derivation_path&&t.push(`private_key_derivation_path=${encodeURIComponent(r.private_key_derivation_path)}`),t.length>0&&(e+=`?${t.join("&")}`),Re(e,"GET",void 0,"Failed to fetch private key")}async function hy(r){let e=`${Qe}/protected/private_key_bytes`;const t=[];return r!=null&&r.seed_phrase_derivation_path&&t.push(`seed_phrase_derivation_path=${encodeURIComponent(r.seed_phrase_derivation_path)}`),r!=null&&r.private_key_derivation_path&&t.push(`private_key_derivation_path=${encodeURIComponent(r.private_key_derivation_path)}`),t.length>0&&(e+=`?${t.join("&")}`),Re(e,"GET",void 0,"Failed to fetch private key bytes")}async function dy(r,e,t){const i={message_base64:$r(r),algorithm:e,...t&&Object.keys(t).length>0&&{key_options:t}};return Re(`${Qe}/protected/sign_message`,"POST",i,"Failed to sign message")}async function py(r,e){let t=`${Qe}/protected/public_key?algorithm=${r}`;return e!=null&&e.seed_phrase_derivation_path&&(t+=`&seed_phrase_derivation_path=${encodeURIComponent(e.seed_phrase_derivation_path)}`),e!=null&&e.private_key_derivation_path&&(t+=`&private_key_derivation_path=${encodeURIComponent(e.private_key_derivation_path)}`),Re(t,"GET",void 0,"Failed to fetch public key")}async function q1(r,e,t){const n={email:r,password:e,...t!==void 0&&{name:t}};return Re(`${Qe}/protected/convert_guest`,"POST",n,"Failed to convert guest account")}async function K1(r){return Re(`${Qe}/protected/third_party_token`,"POST",r?{audience:r}:{},"Failed to generate third party token")}async function yy(r,e){const t={data:r,...e&&Object.keys(e).length>0&&{key_options:e}};return Re(`${Qe}/protected/encrypt`,"POST",t,"Failed to encrypt data")}async function gy(r,e){const t={encrypted_data:r,...e&&Object.keys(e).length>0&&{key_options:e}};return Re(`${Qe}/protected/decrypt`,"POST",t,"Failed to decrypt data")}async function Z1(r){const e={hashed_secret:r};return Re(`${Qe}/protected/delete-account/request`,"POST",e,"Failed to request account deletion")}async function W1(r,e){const t={confirmation_code:r,plaintext_secret:e};return Re(`${Qe}/protected/delete-account/confirm`,"POST",t,"Failed to confirm account deletion")}function Y1(){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 Ci();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 m=Pf(o,e.body);u.body=JSON.stringify({encrypted:m}),s.set("Content-Type","application/json")}let h=await fetch(r,u);if(h.status===401&&(console.warn("Unauthorized, refreshing access token"),await Tc(),s.set("Authorization",t()),u.headers=s,h=await fetch(r,u)),!h.ok){const m=await h.text();throw console.error("Request failed with response status:",h.status," and message:",m),new Error(`Request failed with status ${h.status}: ${m}`)}if((n=h.headers.get("content-type"))!=null&&n.includes("text/event-stream")){const m=(i=h.body)==null?void 0:i.getReader(),x=new TextDecoder;let G="";const N=new ReadableStream({async start(v){for(;;){const{done:A,value:O}=await m.read();if(A)break;const I=x.decode(O);G+=I;let P;for(;P=J1(G);)if(G=G.slice(P.length),P.trim().startsWith("data: ")){const R=P.slice(6).trim();if(R==="[DONE]")v.enqueue(`data: [DONE]
|
|
126
126
|
|
|
127
127
|
`);else try{console.groupCollapsed("Decrypting chunk"),console.log("Attempting to decrypt, data length:",R.length);const fe=jf(o,R);console.log("Decrypted data length:",fe.length),console.log("Decrypted data:",fe);try{const Ke=JSON.parse(fe);console.log("Parsed JSON:",Ke),v.enqueue(`data: ${JSON.stringify(Ke)}
|
|
128
128
|
|