@opensecret/react 1.5.3 → 1.5.4
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 +1 -0
- package/dist/opensecret-react.es.js +1 -1
- package/dist/opensecret-react.umd.js +1 -1
- package/package.json +1 -1
- package/LICENSE.md +0 -7
package/dist/index.d.ts
CHANGED
|
@@ -15214,7 +15214,7 @@ function Rw(r) {
|
|
|
15214
15214
|
try {
|
|
15215
15215
|
const o = new Headers(t == null ? void 0 : t.headers);
|
|
15216
15216
|
o.set("Authorization", n());
|
|
15217
|
-
const { sessionKey: c, sessionId: u } = await _i();
|
|
15217
|
+
const { sessionKey: c, sessionId: u } = await _i(!1, r == null ? void 0 : r.apiUrl);
|
|
15218
15218
|
if (!c || !u)
|
|
15219
15219
|
throw new Error("No session key or ID available");
|
|
15220
15220
|
o.set("x-session-id", u);
|
|
@@ -122,7 +122,7 @@ ${e.join(`
|
|
|
122
122
|
`;return o+=p0(s,t),o}const y0=!hm();function g0(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 xi(r){if(!(r instanceof Uint8Array))throw new Error(`Expected Uint8Array: ${r}`)}function v0(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],yc(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),ff(r,r.size,ye.MAP,e,t);for(const[i,s,o]of n)e.write(o),bi(s,e,t)});function m0(r){return Gn(r.contents),new Date(r.contents)}m0.comment=r=>(Gn(r.contents),`(String Date) ${new Date(r.contents).toISOString()}`),Xe.registerDecoder(kt.DATE_STRING,m0);function w0(r){return g0(r.contents),new Date(r.contents*1e3)}w0.comment=r=>(g0(r.contents),`(Epoch Date) ${new Date(r.contents*1e3).toISOString()}`),Xe.registerDecoder(kt.DATE_EPOCH,w0),Rt(Date,r=>[kt.DATE_EPOCH,r.valueOf()/1e3]);function vc(r,e,t){if(xi(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?Zs(n,e.contents):n}const b0=vc.bind(null,!1),x0=vc.bind(null,!0);b0.comment=(r,e)=>`(Positive BigInt) ${vc(!1,r,e)}n`,x0.comment=(r,e)=>`(Negative BigInt) ${vc(!0,r,e)}n`,Xe.registerDecoder(kt.POS_BIGINT,b0),Xe.registerDecoder(kt.NEG_BIGINT,x0);function pf(r,e){return xi(r.contents),r}pf.comment=(r,e,t)=>{xi(r.contents);const n={...e,initialDepth:t+2,noPrefixHex:!0},i=hc(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=jm(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},pf.noChildren=!0,Xe.registerDecoder(kt.CBOR,pf),Xe.registerDecoder(kt.URI,r=>(Gn(r.contents),new URL(r.contents)),"URI"),Rt(URL,r=>[kt.URI,r.toString()]),Xe.registerDecoder(kt.BASE64URL,r=>(Gn(r.contents),fm(r.contents)),"Base64url-encoded"),Xe.registerDecoder(kt.BASE64,r=>(Gn(r.contents),cf(r.contents)),"Base64-encoded"),Xe.registerDecoder(35,r=>(Gn(r.contents),new RegExp(r.contents)),"RegExp"),Xe.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"),Xe.registerDecoder(kt.REGEXP,r=>{if(v0(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=>[kt.REGEXP,[r.source,r.flags]]),Xe.registerDecoder(64,r=>(xi(r.contents),r.contents),"uint8 Typed Array");function nr(r,e,t){xi(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 zn(r,e,t,n,i){const s=i.forceEndian??y0;if(pc(s?e:t,r,i),zr(n.byteLength,r,ye.BYTE_STRING),y0===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)}}Xe.registerDecoder(65,r=>nr(r,Uint16Array,!1),"uint16, big endian, Typed Array"),Xe.registerDecoder(66,r=>nr(r,Uint32Array,!1),"uint32, big endian, Typed Array"),Xe.registerDecoder(67,r=>nr(r,BigUint64Array,!1),"uint64, big endian, Typed Array"),Xe.registerDecoder(68,r=>(xi(r.contents),new Uint8ClampedArray(r.contents)),"uint8 Typed Array, clamped arithmetic"),Rt(Uint8ClampedArray,r=>[68,new Uint8Array(r.buffer,r.byteOffset,r.byteLength)]),Xe.registerDecoder(69,r=>nr(r,Uint16Array,!0),"uint16, little endian, Typed Array"),Rt(Uint16Array,(r,e,t)=>zn(e,69,65,r,t)),Xe.registerDecoder(70,r=>nr(r,Uint32Array,!0),"uint32, little endian, Typed Array"),Rt(Uint32Array,(r,e,t)=>zn(e,70,66,r,t)),Xe.registerDecoder(71,r=>nr(r,BigUint64Array,!0),"uint64, little endian, Typed Array"),Rt(BigUint64Array,(r,e,t)=>zn(e,71,67,r,t)),Xe.registerDecoder(72,r=>(xi(r.contents),new Int8Array(r.contents)),"sint8 Typed Array"),Rt(Int8Array,r=>[72,new Uint8Array(r.buffer,r.byteOffset,r.byteLength)]),Xe.registerDecoder(73,r=>nr(r,Int16Array,!1),"sint16, big endian, Typed Array"),Xe.registerDecoder(74,r=>nr(r,Int32Array,!1),"sint32, big endian, Typed Array"),Xe.registerDecoder(75,r=>nr(r,BigInt64Array,!1),"sint64, big endian, Typed Array"),Xe.registerDecoder(77,r=>nr(r,Int16Array,!0),"sint16, little endian, Typed Array"),Rt(Int16Array,(r,e,t)=>zn(e,77,73,r,t)),Xe.registerDecoder(78,r=>nr(r,Int32Array,!0),"sint32, little endian, Typed Array"),Rt(Int32Array,(r,e,t)=>zn(e,78,74,r,t)),Xe.registerDecoder(79,r=>nr(r,BigInt64Array,!0),"sint64, little endian, Typed Array"),Rt(BigInt64Array,(r,e,t)=>zn(e,79,75,r,t)),Xe.registerDecoder(81,r=>nr(r,Float32Array,!1),"IEEE 754 binary32, big endian, Typed Array"),Xe.registerDecoder(82,r=>nr(r,Float64Array,!1),"IEEE 754 binary64, big endian, Typed Array"),Xe.registerDecoder(85,r=>nr(r,Float32Array,!0),"IEEE 754 binary32, little endian, Typed Array"),Rt(Float32Array,(r,e,t)=>zn(e,85,81,r,t)),Xe.registerDecoder(86,r=>nr(r,Float64Array,!0),"IEEE 754 binary64, big endian, Typed Array"),Rt(Float64Array,(r,e,t)=>zn(e,86,82,r,t)),Xe.registerDecoder(kt.SET,r=>(v0(r.contents),new Set(r.contents)),"Set"),Rt(Set,r=>[kt.SET,[...r]]),Xe.registerDecoder(kt.JSON,r=>(Gn(r.contents),JSON.parse(r.contents)),"JSON-encoded"),Xe.registerDecoder(kt.SELF_DESCRIBED,r=>r.contents,"Self-Described"),Xe.registerDecoder(kt.INVALID_16,()=>{throw new Error(`Tag always invalid: ${kt.INVALID_16}`)},"Invalid"),Xe.registerDecoder(kt.INVALID_32,()=>{throw new Error(`Tag always invalid: ${kt.INVALID_32}`)},"Invalid"),Xe.registerDecoder(kt.INVALID_64,()=>{throw new Error(`Tag always invalid: ${kt.INVALID_64}`)},"Invalid");function yf(r){throw new Error(`Encoding ${r.constructor.name} intentionally unimplmented. It is not concrete enough to interoperate. Convert to Uint8Array first.`)}Rt(ArrayBuffer,yf),Rt(DataView,yf),typeof SharedArrayBuffer<"u"&&Rt(SharedArrayBuffer,yf);function mc(r){return[NaN,r.valueOf()]}Rt(Boolean,mc),Rt(Number,mc),Rt(String,mc),Rt(BigInt,mc);function wc(r,e={}){const t={...Fn.defaultDecodeOptions};if(e.dcbor?Object.assign(t,Fn.dcborDecodeOptions):e.cde&&Object.assign(t,Fn.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 Ys(r,t);let i,s;for(const o of n){if(s=Fn.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 Fn&&(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 at;(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})(at||(at={}));var gf;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(gf||(gf={}));const ne=at.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 ne.undefined;case"string":return ne.string;case"number":return isNaN(r)?ne.nan:ne.number;case"boolean":return ne.boolean;case"function":return ne.function;case"bigint":return ne.bigint;case"symbol":return ne.symbol;case"object":return Array.isArray(r)?ne.array:r===null?ne.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?ne.promise:typeof Map<"u"&&r instanceof Map?ne.map:typeof Set<"u"&&r instanceof Set?ne.set:typeof Date<"u"&&r instanceof Date?ne.date:ne.object;default:return ne.unknown}},G=at.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"]),Rm=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,at.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 ts=(r,e)=>{let t;switch(r.code){case G.invalid_type:r.received===ne.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case G.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,at.jsonStringifyReplacer)}`;break;case G.unrecognized_keys:t=`Unrecognized key(s) in object: ${at.joinValues(r.keys,", ")}`;break;case G.invalid_union:t="Invalid input";break;case G.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${at.joinValues(r.options)}`;break;case G.invalid_enum_value:t=`Invalid enum value. Expected ${at.joinValues(r.options)}, received '${r.received}'`;break;case G.invalid_arguments:t="Invalid function arguments";break;case G.invalid_return_type:t="Invalid function return type";break;case G.invalid_date:t="Invalid date";break;case G.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}"`:at.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case G.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 G.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 G.custom:t="Invalid input";break;case G.invalid_intersection_types:t="Intersection results could not be merged";break;case G.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case G.not_finite:t="Number must be finite";break;default:t=e.defaultError,at.assertNever(r)}return{message:t}};let A0=ts;function Dm(r){A0=r}function bc(){return A0}const xc=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}},Um=[];function J(r,e){const t=bc(),n=xc({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===ts?void 0:ts].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 Be;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 Be;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 Be=Object.freeze({status:"aborted"}),rs=r=>({status:"dirty",value:r}),hr=r=>({status:"valid",value:r}),vf=r=>r.status==="aborted",mf=r=>r.status==="dirty",Js=r=>r.status==="valid",Xs=r=>typeof Promise<"u"&&r instanceof Promise;function Ac(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 S0(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 Se;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(Se||(Se={}));var Qs,eo;class on{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 _0=(r,e)=>{if(Js(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 Fe(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:v}=r;return o.code==="invalid_enum_value"?{message:v??c.defaultError}:typeof c.data>"u"?{message:(u=v??n)!==null&&u!==void 0?u:c.defaultError}:o.code!=="invalid_type"?{message:c.defaultError}:{message:(h=v??t)!==null&&h!==void 0?h:c.defaultError}},description:i}}class Ye{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(Xs(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 _0(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(Xs(i)?i:Promise.resolve(i));return _0(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:G.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 Zr({schema:this,typeName:ke.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return cn.create(this,this._def)}nullable(){return Yn.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return qr.create(this,this._def)}promise(){return os.create(this,this._def)}or(e){return io.create([this,e],this._def)}and(e){return so.create(this,e,this._def)}transform(e){return new Zr({...Fe(this._def),schema:this,typeName:ke.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new uo({...Fe(this._def),innerType:this,defaultValue:t,typeName:ke.ZodDefault})}brand(){return new xf({typeName:ke.ZodBranded,type:this,...Fe(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new fo({...Fe(this._def),innerType:this,catchValue:t,typeName:ke.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return ho.create(this,e)}readonly(){return po.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const $m=/^c[^\s-]{8,}$/i,Mm=/^[0-9a-z]+$/,Vm=/^[0-9A-HJKMNP-TV-Z]{26}$/,Lm=/^[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,Hm=/^[a-z0-9_-]{21}$/i,Fm=/^[-+]?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)?)??$/,Gm=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,zm="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let wf;const Km=/^(?:(?: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])$/,qm=/^(([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})))$/,Zm=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,E0="((\\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])))",Wm=new RegExp(`^${E0}$`);function I0(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 Ym(r){return new RegExp(`^${I0(r)}$`)}function k0(r){let e=`${E0}T${I0(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 Jm(r,e){return!!((e==="v4"||!e)&&Km.test(r)||(e==="v6"||!e)&&qm.test(r))}class Kr extends Ye{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==ne.string){const s=this._getOrReturnCtx(e);return J(s,{code:G.invalid_type,expected:ne.string,received:s.parsedType}),Be}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),J(i,{code:G.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),J(i,{code:G.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?J(i,{code:G.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):c&&J(i,{code:G.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),n.dirty())}else if(s.kind==="email")Gm.test(e.data)||(i=this._getOrReturnCtx(e,i),J(i,{validation:"email",code:G.invalid_string,message:s.message}),n.dirty());else if(s.kind==="emoji")wf||(wf=new RegExp(zm,"u")),wf.test(e.data)||(i=this._getOrReturnCtx(e,i),J(i,{validation:"emoji",code:G.invalid_string,message:s.message}),n.dirty());else if(s.kind==="uuid")Lm.test(e.data)||(i=this._getOrReturnCtx(e,i),J(i,{validation:"uuid",code:G.invalid_string,message:s.message}),n.dirty());else if(s.kind==="nanoid")Hm.test(e.data)||(i=this._getOrReturnCtx(e,i),J(i,{validation:"nanoid",code:G.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid")$m.test(e.data)||(i=this._getOrReturnCtx(e,i),J(i,{validation:"cuid",code:G.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid2")Mm.test(e.data)||(i=this._getOrReturnCtx(e,i),J(i,{validation:"cuid2",code:G.invalid_string,message:s.message}),n.dirty());else if(s.kind==="ulid")Vm.test(e.data)||(i=this._getOrReturnCtx(e,i),J(i,{validation:"ulid",code:G.invalid_string,message:s.message}),n.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),J(i,{validation:"url",code:G.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),J(i,{validation:"regex",code:G.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),J(i,{code:G.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),J(i,{code:G.invalid_string,validation:{startsWith:s.value},message:s.message}),n.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(i=this._getOrReturnCtx(e,i),J(i,{code:G.invalid_string,validation:{endsWith:s.value},message:s.message}),n.dirty()):s.kind==="datetime"?k0(s).test(e.data)||(i=this._getOrReturnCtx(e,i),J(i,{code:G.invalid_string,validation:"datetime",message:s.message}),n.dirty()):s.kind==="date"?Wm.test(e.data)||(i=this._getOrReturnCtx(e,i),J(i,{code:G.invalid_string,validation:"date",message:s.message}),n.dirty()):s.kind==="time"?Ym(s).test(e.data)||(i=this._getOrReturnCtx(e,i),J(i,{code:G.invalid_string,validation:"time",message:s.message}),n.dirty()):s.kind==="duration"?Fm.test(e.data)||(i=this._getOrReturnCtx(e,i),J(i,{validation:"duration",code:G.invalid_string,message:s.message}),n.dirty()):s.kind==="ip"?Jm(e.data,s.version)||(i=this._getOrReturnCtx(e,i),J(i,{validation:"ip",code:G.invalid_string,message:s.message}),n.dirty()):s.kind==="base64"?Zm.test(e.data)||(i=this._getOrReturnCtx(e,i),J(i,{validation:"base64",code:G.invalid_string,message:s.message}),n.dirty()):at.assertNever(s);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(i=>e.test(i),{validation:t,code:G.invalid_string,...Se.errToObj(n)})}_addCheck(e){return new Kr({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Se.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Se.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Se.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Se.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...Se.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Se.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Se.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Se.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...Se.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Se.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,...Se.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,...Se.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...Se.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...Se.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...Se.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...Se.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...Se.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...Se.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...Se.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...Se.errToObj(t)})}nonempty(e){return this.min(1,Se.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:ke.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...Fe(r)})};function Xm(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 qn extends Ye{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)!==ne.number){const s=this._getOrReturnCtx(e);return J(s,{code:G.invalid_type,expected:ne.number,received:s.parsedType}),Be}let n;const i=new ir;for(const s of this._def.checks)s.kind==="int"?at.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),J(n,{code:G.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),J(n,{code:G.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),J(n,{code:G.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="multipleOf"?Xm(e.data,s.value)!==0&&(n=this._getOrReturnCtx(e,n),J(n,{code:G.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),J(n,{code:G.not_finite,message:s.message}),i.dirty()):at.assertNever(s);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Se.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Se.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Se.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Se.toString(t))}setLimit(e,t,n,i){return new qn({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:Se.toString(i)}]})}_addCheck(e){return new qn({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Se.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Se.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Se.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Se.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Se.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Se.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:Se.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Se.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Se.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"&&at.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)}}qn.create=r=>new qn({checks:[],typeName:ke.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...Fe(r)});class Zn extends Ye{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)!==ne.bigint){const s=this._getOrReturnCtx(e);return J(s,{code:G.invalid_type,expected:ne.bigint,received:s.parsedType}),Be}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),J(n,{code:G.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),J(n,{code:G.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),J(n,{code:G.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):at.assertNever(s);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Se.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Se.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Se.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Se.toString(t))}setLimit(e,t,n,i){return new Zn({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:Se.toString(i)}]})}_addCheck(e){return new Zn({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Se.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Se.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Se.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Se.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Se.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}}Zn.create=r=>{var e;return new Zn({checks:[],typeName:ke.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...Fe(r)})};class to extends Ye{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==ne.boolean){const n=this._getOrReturnCtx(e);return J(n,{code:G.invalid_type,expected:ne.boolean,received:n.parsedType}),Be}return hr(e.data)}}to.create=r=>new to({typeName:ke.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...Fe(r)});class Ai extends Ye{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==ne.date){const s=this._getOrReturnCtx(e);return J(s,{code:G.invalid_type,expected:ne.date,received:s.parsedType}),Be}if(isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return J(s,{code:G.invalid_date}),Be}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),J(i,{code:G.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),J(i,{code:G.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),n.dirty()):at.assertNever(s);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Ai({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:Se.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:Se.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}}Ai.create=r=>new Ai({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:ke.ZodDate,...Fe(r)});class Sc extends Ye{_parse(e){if(this._getType(e)!==ne.symbol){const n=this._getOrReturnCtx(e);return J(n,{code:G.invalid_type,expected:ne.symbol,received:n.parsedType}),Be}return hr(e.data)}}Sc.create=r=>new Sc({typeName:ke.ZodSymbol,...Fe(r)});class ro extends Ye{_parse(e){if(this._getType(e)!==ne.undefined){const n=this._getOrReturnCtx(e);return J(n,{code:G.invalid_type,expected:ne.undefined,received:n.parsedType}),Be}return hr(e.data)}}ro.create=r=>new ro({typeName:ke.ZodUndefined,...Fe(r)});class no extends Ye{_parse(e){if(this._getType(e)!==ne.null){const n=this._getOrReturnCtx(e);return J(n,{code:G.invalid_type,expected:ne.null,received:n.parsedType}),Be}return hr(e.data)}}no.create=r=>new no({typeName:ke.ZodNull,...Fe(r)});class ns extends Ye{constructor(){super(...arguments),this._any=!0}_parse(e){return hr(e.data)}}ns.create=r=>new ns({typeName:ke.ZodAny,...Fe(r)});class Si extends Ye{constructor(){super(...arguments),this._unknown=!0}_parse(e){return hr(e.data)}}Si.create=r=>new Si({typeName:ke.ZodUnknown,...Fe(r)});class Cn extends Ye{_parse(e){const t=this._getOrReturnCtx(e);return J(t,{code:G.invalid_type,expected:ne.never,received:t.parsedType}),Be}}Cn.create=r=>new Cn({typeName:ke.ZodNever,...Fe(r)});class _c extends Ye{_parse(e){if(this._getType(e)!==ne.undefined){const n=this._getOrReturnCtx(e);return J(n,{code:G.invalid_type,expected:ne.void,received:n.parsedType}),Be}return hr(e.data)}}_c.create=r=>new _c({typeName:ke.ZodVoid,...Fe(r)});class qr extends Ye{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),i=this._def;if(t.parsedType!==ne.array)return J(t,{code:G.invalid_type,expected:ne.array,received:t.parsedType}),Be;if(i.exactLength!==null){const o=t.data.length>i.exactLength.value,c=t.data.length<i.exactLength.value;(o||c)&&(J(t,{code:o?G.too_big:G.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&&(J(t,{code:G.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&&(J(t,{code:G.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 on(t,o,t.path,c)))).then(o=>ir.mergeArray(n,o));const s=[...t.data].map((o,c)=>i.type._parseSync(new on(t,o,t.path,c)));return ir.mergeArray(n,s)}get element(){return this._def.type}min(e,t){return new qr({...this._def,minLength:{value:e,message:Se.toString(t)}})}max(e,t){return new qr({...this._def,maxLength:{value:e,message:Se.toString(t)}})}length(e,t){return new qr({...this._def,exactLength:{value:e,message:Se.toString(t)}})}nonempty(e){return this.min(1,e)}}qr.create=(r,e)=>new qr({type:r,minLength:null,maxLength:null,exactLength:null,typeName:ke.ZodArray,...Fe(e)});function is(r){if(r instanceof Ot){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=cn.create(is(n))}return new Ot({...r._def,shape:()=>e})}else return r instanceof qr?new qr({...r._def,type:is(r.element)}):r instanceof cn?cn.create(is(r.unwrap())):r instanceof Yn?Yn.create(is(r.unwrap())):r instanceof an?an.create(r.items.map(e=>is(e))):r}class Ot extends Ye{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=at.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==ne.object){const h=this._getOrReturnCtx(e);return J(h,{code:G.invalid_type,expected:ne.object,received:h.parsedType}),Be}const{status:n,ctx:i}=this._processInputParams(e),{shape:s,keys:o}=this._getCached(),c=[];if(!(this._def.catchall instanceof Cn&&this._def.unknownKeys==="strip"))for(const h in i.data)o.includes(h)||c.push(h);const u=[];for(const h of o){const v=s[h],b=i.data[h];u.push({key:{status:"valid",value:h},value:v._parse(new on(i,b,i.path,h)),alwaysSet:h in i.data})}if(this._def.catchall instanceof Cn){const h=this._def.unknownKeys;if(h==="passthrough")for(const v of c)u.push({key:{status:"valid",value:v},value:{status:"valid",value:i.data[v]}});else if(h==="strict")c.length>0&&(J(i,{code:G.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 v of c){const b=i.data[v];u.push({key:{status:"valid",value:v},value:h._parse(new on(i,b,i.path,v)),alwaysSet:v in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const h=[];for(const v of u){const b=await v.key,F=await v.value;h.push({key:b,value:F,alwaysSet:v.alwaysSet})}return h}).then(h=>ir.mergeObjectSync(n,h)):ir.mergeObjectSync(n,u)}get shape(){return this._def.shape()}strict(e){return Se.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=Se.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:ke.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Ot({...this._def,catchall:e})}pick(e){const t={};return at.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 at.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new Ot({...this._def,shape:()=>t})}deepPartial(){return is(this)}partial(e){const t={};return at.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 at.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let s=this.shape[n];for(;s instanceof cn;)s=s._def.innerType;t[n]=s}}),new Ot({...this._def,shape:()=>t})}keyof(){return C0(at.objectKeys(this.shape))}}Ot.create=(r,e)=>new Ot({shape:()=>r,unknownKeys:"strip",catchall:Cn.create(),typeName:ke.ZodObject,...Fe(e)}),Ot.strictCreate=(r,e)=>new Ot({shape:()=>r,unknownKeys:"strict",catchall:Cn.create(),typeName:ke.ZodObject,...Fe(e)}),Ot.lazycreate=(r,e)=>new Ot({shape:r,unknownKeys:"strip",catchall:Cn.create(),typeName:ke.ZodObject,...Fe(e)});class io extends Ye{_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 J(t,{code:G.invalid_union,unionErrors:o}),Be}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},v=u._parseSync({data:t.data,path:t.path,parent:h});if(v.status==="valid")return v;v.status==="dirty"&&!s&&(s={result:v,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 J(t,{code:G.invalid_union,unionErrors:c}),Be}}get options(){return this._def.options}}io.create=(r,e)=>new io({options:r,typeName:ke.ZodUnion,...Fe(e)});const Bn=r=>r instanceof ao?Bn(r.schema):r instanceof Zr?Bn(r.innerType()):r instanceof co?[r.value]:r instanceof Wn?r.options:r instanceof lo?at.objectValues(r.enum):r instanceof uo?Bn(r._def.innerType):r instanceof ro?[void 0]:r instanceof no?[null]:r instanceof cn?[void 0,...Bn(r.unwrap())]:r instanceof Yn?[null,...Bn(r.unwrap())]:r instanceof xf||r instanceof po?Bn(r.unwrap()):r instanceof fo?Bn(r._def.innerType):[];class Ec extends Ye{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==ne.object)return J(t,{code:G.invalid_type,expected:ne.object,received:t.parsedType}),Be;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}):(J(t,{code:G.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),Be)}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=Bn(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 Ec({typeName:ke.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:i,...Fe(n)})}}function bf(r,e){const t=Kn(r),n=Kn(e);if(r===e)return{valid:!0,data:r};if(t===ne.object&&n===ne.object){const i=at.objectKeys(e),s=at.objectKeys(r).filter(c=>i.indexOf(c)!==-1),o={...r,...e};for(const c of s){const u=bf(r[c],e[c]);if(!u.valid)return{valid:!1};o[c]=u.data}return{valid:!0,data:o}}else if(t===ne.array&&n===ne.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=bf(o,c);if(!u.valid)return{valid:!1};i.push(u.data)}return{valid:!0,data:i}}else return t===ne.date&&n===ne.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class so extends Ye{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),i=(s,o)=>{if(vf(s)||vf(o))return Be;const c=bf(s.value,o.value);return c.valid?((mf(s)||mf(o))&&t.dirty(),{status:t.value,value:c.data}):(J(n,{code:G.invalid_intersection_types}),Be)};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}))}}so.create=(r,e,t)=>new so({left:r,right:e,typeName:ke.ZodIntersection,...Fe(t)});class an extends Ye{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==ne.array)return J(n,{code:G.invalid_type,expected:ne.array,received:n.parsedType}),Be;if(n.data.length<this._def.items.length)return J(n,{code:G.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Be;!this._def.rest&&n.data.length>this._def.items.length&&(J(n,{code:G.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 on(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 an({...this._def,rest:e})}}an.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new an({items:r,typeName:ke.ZodTuple,rest:null,...Fe(e)})};class oo extends Ye{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!==ne.object)return J(n,{code:G.invalid_type,expected:ne.object,received:n.parsedType}),Be;const i=[],s=this._def.keyType,o=this._def.valueType;for(const c in n.data)i.push({key:s._parse(new on(n,c,n.path,c)),value:o._parse(new on(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 Ye?new oo({keyType:e,valueType:t,typeName:ke.ZodRecord,...Fe(n)}):new oo({keyType:Kr.create(),valueType:e,typeName:ke.ZodRecord,...Fe(t)})}}class Ic extends Ye{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!==ne.map)return J(n,{code:G.invalid_type,expected:ne.map,received:n.parsedType}),Be;const i=this._def.keyType,s=this._def.valueType,o=[...n.data.entries()].map(([c,u],h)=>({key:i._parse(new on(n,c,n.path,[h,"key"])),value:s._parse(new on(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,v=await u.value;if(h.status==="aborted"||v.status==="aborted")return Be;(h.status==="dirty"||v.status==="dirty")&&t.dirty(),c.set(h.value,v.value)}return{status:t.value,value:c}})}else{const c=new Map;for(const u of o){const h=u.key,v=u.value;if(h.status==="aborted"||v.status==="aborted")return Be;(h.status==="dirty"||v.status==="dirty")&&t.dirty(),c.set(h.value,v.value)}return{status:t.value,value:c}}}}Ic.create=(r,e,t)=>new Ic({valueType:e,keyType:r,typeName:ke.ZodMap,...Fe(t)});class _i extends Ye{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==ne.set)return J(n,{code:G.invalid_type,expected:ne.set,received:n.parsedType}),Be;const i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(J(n,{code:G.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&&(J(n,{code:G.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 v of u){if(v.status==="aborted")return Be;v.status==="dirty"&&t.dirty(),h.add(v.value)}return{status:t.value,value:h}}const c=[...n.data.values()].map((u,h)=>s._parse(new on(n,u,n.path,h)));return n.common.async?Promise.all(c).then(u=>o(u)):o(c)}min(e,t){return new _i({...this._def,minSize:{value:e,message:Se.toString(t)}})}max(e,t){return new _i({...this._def,maxSize:{value:e,message:Se.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}_i.create=(r,e)=>new _i({valueType:r,minSize:null,maxSize:null,typeName:ke.ZodSet,...Fe(e)});class ss extends Ye{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==ne.function)return J(t,{code:G.invalid_type,expected:ne.function,received:t.parsedType}),Be;function n(c,u){return xc({data:c,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,bc(),ts].filter(h=>!!h),issueData:{code:G.invalid_arguments,argumentsError:u}})}function i(c,u){return xc({data:c,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,bc(),ts].filter(h=>!!h),issueData:{code:G.invalid_return_type,returnTypeError:u}})}const s={errorMap:t.common.contextualErrorMap},o=t.data;if(this._def.returns instanceof os){const c=this;return hr(async function(...u){const h=new kr([]),v=await c._def.args.parseAsync(u,s).catch(O=>{throw h.addIssue(n(u,O)),h}),b=await Reflect.apply(o,this,v);return await c._def.returns._def.type.parseAsync(b,s).catch(O=>{throw h.addIssue(i(b,O)),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 v=Reflect.apply(o,this,h.data),b=c._def.returns.safeParse(v,s);if(!b.success)throw new kr([i(v,b.error)]);return b.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new ss({...this._def,args:an.create(e).rest(Si.create())})}returns(e){return new ss({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new ss({args:e||an.create([]).rest(Si.create()),returns:t||Si.create(),typeName:ke.ZodFunction,...Fe(n)})}}class ao extends Ye{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}ao.create=(r,e)=>new ao({getter:r,typeName:ke.ZodLazy,...Fe(e)});class co extends Ye{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return J(t,{received:t.data,code:G.invalid_literal,expected:this._def.value}),Be}return{status:"valid",value:e.data}}get value(){return this._def.value}}co.create=(r,e)=>new co({value:r,typeName:ke.ZodLiteral,...Fe(e)});function C0(r,e){return new Wn({values:r,typeName:ke.ZodEnum,...Fe(e)})}class Wn extends Ye{constructor(){super(...arguments),Qs.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return J(t,{expected:at.joinValues(n),received:t.parsedType,code:G.invalid_type}),Be}if(Ac(this,Qs)||S0(this,Qs,new Set(this._def.values)),!Ac(this,Qs).has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return J(t,{received:t.data,code:G.invalid_enum_value,options:n}),Be}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 Wn.create(e,{...this._def,...t})}exclude(e,t=this._def){return Wn.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}}Qs=new WeakMap,Wn.create=C0;class lo extends Ye{constructor(){super(...arguments),eo.set(this,void 0)}_parse(e){const t=at.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==ne.string&&n.parsedType!==ne.number){const i=at.objectValues(t);return J(n,{expected:at.joinValues(i),received:n.parsedType,code:G.invalid_type}),Be}if(Ac(this,eo)||S0(this,eo,new Set(at.getValidEnumValues(this._def.values))),!Ac(this,eo).has(e.data)){const i=at.objectValues(t);return J(n,{received:n.data,code:G.invalid_enum_value,options:i}),Be}return hr(e.data)}get enum(){return this._def.values}}eo=new WeakMap,lo.create=(r,e)=>new lo({values:r,typeName:ke.ZodNativeEnum,...Fe(e)});class os extends Ye{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==ne.promise&&t.common.async===!1)return J(t,{code:G.invalid_type,expected:ne.promise,received:t.parsedType}),Be;const n=t.parsedType===ne.promise?t.data:Promise.resolve(t.data);return hr(n.then(i=>this._def.type.parseAsync(i,{path:t.path,errorMap:t.common.contextualErrorMap})))}}os.create=(r,e)=>new os({type:r,typeName:ke.ZodPromise,...Fe(e)});class Zr extends Ye{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===ke.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=>{J(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 Be;const u=await this._def.schema._parseAsync({data:c,path:n.path,parent:n});return u.status==="aborted"?Be:u.status==="dirty"||t.value==="dirty"?rs(u.value):u});{if(t.value==="aborted")return Be;const c=this._def.schema._parseSync({data:o,path:n.path,parent:n});return c.status==="aborted"?Be:c.status==="dirty"||t.value==="dirty"?rs(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"?Be:(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"?Be:(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(!Js(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=>Js(o)?Promise.resolve(i.transform(o.value,s)).then(c=>({status:t.value,value:c})):o);at.assertNever(i)}}Zr.create=(r,e,t)=>new Zr({schema:r,typeName:ke.ZodEffects,effect:e,...Fe(t)}),Zr.createWithPreprocess=(r,e,t)=>new Zr({schema:e,effect:{type:"preprocess",transform:r},typeName:ke.ZodEffects,...Fe(t)});class cn extends Ye{_parse(e){return this._getType(e)===ne.undefined?hr(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}cn.create=(r,e)=>new cn({innerType:r,typeName:ke.ZodOptional,...Fe(e)});class Yn extends Ye{_parse(e){return this._getType(e)===ne.null?hr(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Yn.create=(r,e)=>new Yn({innerType:r,typeName:ke.ZodNullable,...Fe(e)});class uo extends Ye{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===ne.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}uo.create=(r,e)=>new uo({innerType:r,typeName:ke.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...Fe(e)});class fo extends Ye{_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 Xs(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}}fo.create=(r,e)=>new fo({innerType:r,typeName:ke.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...Fe(e)});class kc extends Ye{_parse(e){if(this._getType(e)!==ne.nan){const n=this._getOrReturnCtx(e);return J(n,{code:G.invalid_type,expected:ne.nan,received:n.parsedType}),Be}return{status:"valid",value:e.data}}}kc.create=r=>new kc({typeName:ke.ZodNaN,...Fe(r)});const Qm=Symbol("zod_brand");class xf extends Ye{_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 ho extends Ye{_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"?Be:s.status==="dirty"?(t.dirty(),rs(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"?Be: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 ho({in:e,out:t,typeName:ke.ZodPipeline})}}class po extends Ye{_parse(e){const t=this._def.innerType._parse(e),n=i=>(Js(i)&&(i.value=Object.freeze(i.value)),i);return Xs(t)?t.then(i=>n(i)):n(t)}unwrap(){return this._def.innerType}}po.create=(r,e)=>new po({innerType:r,typeName:ke.ZodReadonly,...Fe(e)});function B0(r,e={},t){return r?ns.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})}}):ns.create()}const e1={object:Ot.lazycreate};var ke;(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"})(ke||(ke={}));const t1=(r,e={message:`Input not instance of ${r.name}`})=>B0(t=>t instanceof r,e),T0=Kr.create,O0=qn.create,r1=kc.create,n1=Zn.create,N0=to.create,i1=Ai.create,s1=Sc.create,o1=ro.create,a1=no.create,c1=ns.create,l1=Si.create,u1=Cn.create,f1=_c.create,h1=qr.create,d1=Ot.create,p1=Ot.strictCreate,y1=io.create,g1=Ec.create,v1=so.create,m1=an.create,w1=oo.create,b1=Ic.create,x1=_i.create,A1=ss.create,S1=ao.create,_1=co.create,E1=Wn.create,I1=lo.create,k1=os.create,P0=Zr.create,C1=cn.create,B1=Yn.create,T1=Zr.createWithPreprocess,O1=ho.create;var Nt=Object.freeze({__proto__:null,defaultErrorMap:ts,setErrorMap:Dm,getErrorMap:bc,makeIssue:xc,EMPTY_PATH:Um,addIssueToContext:J,ParseStatus:ir,INVALID:Be,DIRTY:rs,OK:hr,isAborted:vf,isDirty:mf,isValid:Js,isAsync:Xs,get util(){return at},get objectUtil(){return gf},ZodParsedType:ne,getParsedType:Kn,ZodType:Ye,datetimeRegex:k0,ZodString:Kr,ZodNumber:qn,ZodBigInt:Zn,ZodBoolean:to,ZodDate:Ai,ZodSymbol:Sc,ZodUndefined:ro,ZodNull:no,ZodAny:ns,ZodUnknown:Si,ZodNever:Cn,ZodVoid:_c,ZodArray:qr,ZodObject:Ot,ZodUnion:io,ZodDiscriminatedUnion:Ec,ZodIntersection:so,ZodTuple:an,ZodRecord:oo,ZodMap:Ic,ZodSet:_i,ZodFunction:ss,ZodLazy:ao,ZodLiteral:co,ZodEnum:Wn,ZodNativeEnum:lo,ZodPromise:os,ZodEffects:Zr,ZodTransformer:Zr,ZodOptional:cn,ZodNullable:Yn,ZodDefault:uo,ZodCatch:fo,ZodNaN:kc,BRAND:Qm,ZodBranded:xf,ZodPipeline:ho,ZodReadonly:po,custom:B0,Schema:Ye,ZodSchema:Ye,late:e1,get ZodFirstPartyTypeKind(){return ke},coerce:{string:r=>Kr.create({...r,coerce:!0}),number:r=>qn.create({...r,coerce:!0}),boolean:r=>to.create({...r,coerce:!0}),bigint:r=>Zn.create({...r,coerce:!0}),date:r=>Ai.create({...r,coerce:!0})},any:c1,array:h1,bigint:n1,boolean:N0,date:i1,discriminatedUnion:g1,effect:P0,enum:E1,function:A1,instanceof:t1,intersection:v1,lazy:S1,literal:_1,map:b1,nan:r1,nativeEnum:I1,never:u1,null:a1,nullable:B1,number:O0,object:d1,oboolean:()=>N0().optional(),onumber:()=>O0().optional(),optional:C1,ostring:()=>T0().optional(),pipeline:O1,preprocess:T1,promise:k1,record:w1,set:x1,strictObject:p1,string:T0,symbol:s1,transformer:P0,tuple:m1,undefined:o1,union:y1,unknown:l1,void:f1,NEVER:Be,ZodIssueCode:G,quotelessJson:Rm,ZodError:kr});const Cc=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(!Cc||Cc.length===0)throw new Error("AWS root certificate is empty or not loaded correctly");const N1=Nt.object({module_id:Nt.string().min(1),digest:Nt.literal("SHA384"),timestamp:Nt.number().min(1677721600),pcrs:Nt.map(Nt.number(),Nt.instanceof(Uint8Array)),certificate:Nt.instanceof(Uint8Array),cabundle:Nt.array(Nt.instanceof(Uint8Array)),public_key:Nt.nullable(Nt.instanceof(Uint8Array)),user_data:Nt.nullable(Nt.instanceof(Uint8Array)),nonce:Nt.nullable(Nt.instanceof(Uint8Array))}),P1=Nt.object({protected:Nt.instanceof(Uint8Array),payload:Nt.instanceof(Uint8Array),signature:Nt.instanceof(Uint8Array)});async function j1(r){try{if(!r)throw new Error("Attestation document is empty.");const e=ps(r),t=wc(e),n=t[0],i=t[2],s=t[3];return P1.parse({protected:n,payload:i,signature:s})}catch(e){throw console.error("Error parsing document data:",e),new Error("Failed to parse document data.")}}async function R1(r){try{const e=wc(r);return N1.parse(e)}catch(e){throw console.error("Error parsing document payload:",e),new Error("Failed to parse document payload.")}}function D1(r,e){const t=["Signature1",r,new Uint8Array(0),e];return yc(t)}async function U1(r,e){try{console.log("SIGNATURE:"),console.log(Sr(r.signature));const t=D1(r.protected,r.payload),n=await crypto.subtle.digest("SHA-384",t);return console.log("SIGNATURE STRUCTURE DIGEST:"),console.log(Sr(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 Ei(r,e,t){try{const n=await j1(r),i=await R1(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=Sr(i.cabundle[0]);if(u!==Sr(e))throw console.error("Root cert doesn't match first cert"),console.log("First cert base64:",u),console.log("Trusted root cert base64:",Sr(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 wi(i.cabundle[I]);c.push(P)}const h=new wi(i.certificate),b=await new am({certificates:c}).build(h);console.log("Chain items:",b);const O=new Date().getTime();for(let I=0;I<b.length;I++){const P=b[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()>O||P.notAfter.getTime()<O)throw new Error("Certificate is expired.");console.log(`Certificate ${I} is not expired.`)}if(b.length!==i.cabundle.length+1)throw new Error("Certificate chain length does not match length of cabundle.");const m=h.publicKey;console.log("PUBLIC KEY:"),console.log(Sr(new Uint8Array(m.rawData)));const A=await m.export(),k=await U1(n,A);if(console.log("Signature verified:",k),!k)throw new Error("Signature verification failed.");return i}catch(n){throw console.error("Error verifying attestation document:",n),n}}const $1=Nt.object({public_key:Nt.nullable(Nt.instanceof(Uint8Array))});async function M1(r){const e=ps(r),n=wc(e)[2],i=wc(n);return await $1.parse(i)}async function V1(r,e){try{const t=await aw(r,e),n=e||ew();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 M1(t)):await Ei(t,Cc,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 L1(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 j0={exports:{}};const H1=dg(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]),v=t([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),b=t([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),F=t([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),O=t([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function m(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 k(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,R=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,be=a[4]&255|(a[5]&255)<<8|(a[6]&255)<<16|(a[7]&255)<<24,X=p[0]&255|(p[1]&255)<<8|(p[2]&255)<<16|(p[3]&255)<<24,dt=p[4]&255|(p[5]&255)<<8|(p[6]&255)<<16|(p[7]&255)<<24,oe=p[8]&255|(p[9]&255)<<8|(p[10]&255)<<16|(p[11]&255)<<24,Oe=p[12]&255|(p[13]&255)<<8|(p[14]&255)<<16|(p[15]&255)<<24,Pe=a[8]&255|(a[9]&255)<<8|(a[10]&255)<<16|(a[11]&255)<<24,ze=d[16]&255|(d[17]&255)<<8|(d[18]&255)<<16|(d[19]&255)<<24,Le=d[20]&255|(d[21]&255)<<8|(d[22]&255)<<16|(d[23]&255)<<24,je=d[24]&255|(d[25]&255)<<8|(d[26]&255)<<16|(d[27]&255)<<24,Ue=d[28]&255|(d[29]&255)<<8|(d[30]&255)<<16|(d[31]&255)<<24,Re=a[12]&255|(a[13]&255)<<8|(a[14]&255)<<16|(a[15]&255)<<24,he=g,Ee=S,te=E,pe=R,we=z,Y=be,B=X,T=dt,V=oe,j=Oe,D=Pe,L=ze,Ie=Le,Ke=je,We=Ue,qe=Re,w,et=0;et<20;et+=2)w=he+Ie|0,we^=w<<7|w>>>25,w=we+he|0,V^=w<<9|w>>>23,w=V+we|0,Ie^=w<<13|w>>>19,w=Ie+V|0,he^=w<<18|w>>>14,w=Y+Ee|0,j^=w<<7|w>>>25,w=j+Y|0,Ke^=w<<9|w>>>23,w=Ke+j|0,Ee^=w<<13|w>>>19,w=Ee+Ke|0,Y^=w<<18|w>>>14,w=D+B|0,We^=w<<7|w>>>25,w=We+D|0,te^=w<<9|w>>>23,w=te+We|0,B^=w<<13|w>>>19,w=B+te|0,D^=w<<18|w>>>14,w=qe+L|0,pe^=w<<7|w>>>25,w=pe+qe|0,T^=w<<9|w>>>23,w=T+pe|0,L^=w<<13|w>>>19,w=L+T|0,qe^=w<<18|w>>>14,w=he+pe|0,Ee^=w<<7|w>>>25,w=Ee+he|0,te^=w<<9|w>>>23,w=te+Ee|0,pe^=w<<13|w>>>19,w=pe+te|0,he^=w<<18|w>>>14,w=Y+we|0,B^=w<<7|w>>>25,w=B+Y|0,T^=w<<9|w>>>23,w=T+B|0,we^=w<<13|w>>>19,w=we+T|0,Y^=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=qe+We|0,Ie^=w<<7|w>>>25,w=Ie+qe|0,Ke^=w<<9|w>>>23,w=Ke+Ie|0,We^=w<<13|w>>>19,w=We+Ke|0,qe^=w<<18|w>>>14;he=he+g|0,Ee=Ee+S|0,te=te+E|0,pe=pe+R|0,we=we+z|0,Y=Y+be|0,B=B+X|0,T=T+dt|0,V=V+oe|0,j=j+Oe|0,D=D+Pe|0,L=L+ze|0,Ie=Ie+Le|0,Ke=Ke+je|0,We=We+Ue|0,qe=qe+Re|0,l[0]=he>>>0&255,l[1]=he>>>8&255,l[2]=he>>>16&255,l[3]=he>>>24&255,l[4]=Ee>>>0&255,l[5]=Ee>>>8&255,l[6]=Ee>>>16&255,l[7]=Ee>>>24&255,l[8]=te>>>0&255,l[9]=te>>>8&255,l[10]=te>>>16&255,l[11]=te>>>24&255,l[12]=pe>>>0&255,l[13]=pe>>>8&255,l[14]=pe>>>16&255,l[15]=pe>>>24&255,l[16]=we>>>0&255,l[17]=we>>>8&255,l[18]=we>>>16&255,l[19]=we>>>24&255,l[20]=Y>>>0&255,l[21]=Y>>>8&255,l[22]=Y>>>16&255,l[23]=Y>>>24&255,l[24]=B>>>0&255,l[25]=B>>>8&255,l[26]=B>>>16&255,l[27]=B>>>24&255,l[28]=T>>>0&255,l[29]=T>>>8&255,l[30]=T>>>16&255,l[31]=T>>>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]=Ie>>>0&255,l[49]=Ie>>>8&255,l[50]=Ie>>>16&255,l[51]=Ie>>>24&255,l[52]=Ke>>>0&255,l[53]=Ke>>>8&255,l[54]=Ke>>>16&255,l[55]=Ke>>>24&255,l[56]=We>>>0&255,l[57]=We>>>8&255,l[58]=We>>>16&255,l[59]=We>>>24&255,l[60]=qe>>>0&255,l[61]=qe>>>8&255,l[62]=qe>>>16&255,l[63]=qe>>>24&255}function U(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,R=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,be=a[4]&255|(a[5]&255)<<8|(a[6]&255)<<16|(a[7]&255)<<24,X=p[0]&255|(p[1]&255)<<8|(p[2]&255)<<16|(p[3]&255)<<24,dt=p[4]&255|(p[5]&255)<<8|(p[6]&255)<<16|(p[7]&255)<<24,oe=p[8]&255|(p[9]&255)<<8|(p[10]&255)<<16|(p[11]&255)<<24,Oe=p[12]&255|(p[13]&255)<<8|(p[14]&255)<<16|(p[15]&255)<<24,Pe=a[8]&255|(a[9]&255)<<8|(a[10]&255)<<16|(a[11]&255)<<24,ze=d[16]&255|(d[17]&255)<<8|(d[18]&255)<<16|(d[19]&255)<<24,Le=d[20]&255|(d[21]&255)<<8|(d[22]&255)<<16|(d[23]&255)<<24,je=d[24]&255|(d[25]&255)<<8|(d[26]&255)<<16|(d[27]&255)<<24,Ue=d[28]&255|(d[29]&255)<<8|(d[30]&255)<<16|(d[31]&255)<<24,Re=a[12]&255|(a[13]&255)<<8|(a[14]&255)<<16|(a[15]&255)<<24,he=g,Ee=S,te=E,pe=R,we=z,Y=be,B=X,T=dt,V=oe,j=Oe,D=Pe,L=ze,Ie=Le,Ke=je,We=Ue,qe=Re,w,et=0;et<20;et+=2)w=he+Ie|0,we^=w<<7|w>>>25,w=we+he|0,V^=w<<9|w>>>23,w=V+we|0,Ie^=w<<13|w>>>19,w=Ie+V|0,he^=w<<18|w>>>14,w=Y+Ee|0,j^=w<<7|w>>>25,w=j+Y|0,Ke^=w<<9|w>>>23,w=Ke+j|0,Ee^=w<<13|w>>>19,w=Ee+Ke|0,Y^=w<<18|w>>>14,w=D+B|0,We^=w<<7|w>>>25,w=We+D|0,te^=w<<9|w>>>23,w=te+We|0,B^=w<<13|w>>>19,w=B+te|0,D^=w<<18|w>>>14,w=qe+L|0,pe^=w<<7|w>>>25,w=pe+qe|0,T^=w<<9|w>>>23,w=T+pe|0,L^=w<<13|w>>>19,w=L+T|0,qe^=w<<18|w>>>14,w=he+pe|0,Ee^=w<<7|w>>>25,w=Ee+he|0,te^=w<<9|w>>>23,w=te+Ee|0,pe^=w<<13|w>>>19,w=pe+te|0,he^=w<<18|w>>>14,w=Y+we|0,B^=w<<7|w>>>25,w=B+Y|0,T^=w<<9|w>>>23,w=T+B|0,we^=w<<13|w>>>19,w=we+T|0,Y^=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=qe+We|0,Ie^=w<<7|w>>>25,w=Ie+qe|0,Ke^=w<<9|w>>>23,w=Ke+Ie|0,We^=w<<13|w>>>19,w=We+Ke|0,qe^=w<<18|w>>>14;l[0]=he>>>0&255,l[1]=he>>>8&255,l[2]=he>>>16&255,l[3]=he>>>24&255,l[4]=Y>>>0&255,l[5]=Y>>>8&255,l[6]=Y>>>16&255,l[7]=Y>>>24&255,l[8]=D>>>0&255,l[9]=D>>>8&255,l[10]=D>>>16&255,l[11]=D>>>24&255,l[12]=qe>>>0&255,l[13]=qe>>>8&255,l[14]=qe>>>16&255,l[15]=qe>>>24&255,l[16]=B>>>0&255,l[17]=B>>>8&255,l[18]=B>>>16&255,l[19]=B>>>24&255,l[20]=T>>>0&255,l[21]=T>>>8&255,l[22]=T>>>16&255,l[23]=T>>>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 ge(l,p,d,a){P(l,p,d,a)}function rt(l,p,d,a){U(l,p,d,a)}var $e=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function Ne(l,p,d,a,g,S,E){var R=new Uint8Array(16),z=new Uint8Array(64),be,X;for(X=0;X<16;X++)R[X]=0;for(X=0;X<8;X++)R[X]=S[X];for(;g>=64;){for(ge(z,R,E,$e),X=0;X<64;X++)l[p+X]=d[a+X]^z[X];for(be=1,X=8;X<16;X++)be=be+(R[X]&255)|0,R[X]=be&255,be>>>=8;g-=64,p+=64,a+=64}if(g>0)for(ge(z,R,E,$e),X=0;X<g;X++)l[p+X]=d[a+X]^z[X];return 0}function Ge(l,p,d,a,g){var S=new Uint8Array(16),E=new Uint8Array(64),R,z;for(z=0;z<16;z++)S[z]=0;for(z=0;z<8;z++)S[z]=a[z];for(;d>=64;){for(ge(E,S,g,$e),z=0;z<64;z++)l[p+z]=E[z];for(R=1,z=8;z<16;z++)R=R+(S[z]&255)|0,S[z]=R&255,R>>>=8;d-=64,p+=64}if(d>0)for(ge(E,S,g,$e),z=0;z<d;z++)l[p+z]=E[z];return 0}function wt(l,p,d,a,g){var S=new Uint8Array(32);rt(S,a,g,$e);for(var E=new Uint8Array(8),R=0;R<8;R++)E[R]=a[R+16];return Ge(l,p,d,E,S)}function vt(l,p,d,a,g,S,E){var R=new Uint8Array(32);rt(R,S,E,$e);for(var z=new Uint8Array(8),be=0;be<8;be++)z[be]=S[be+16];return Ne(l,p,d,a,g,z,R)}var ue=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,R,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,R=l[12]&255|(l[13]&255)<<8,this.r[7]=(E>>>11|R<<5)&8065,z=l[14]&255|(l[15]&255)<<8,this.r[8]=(R>>>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};ue.prototype.blocks=function(l,p,d){for(var a=this.fin?0:2048,g,S,E,R,z,be,X,dt,oe,Oe,Pe,ze,Le,je,Ue,Re,he,Ee,te,pe=this.h[0],we=this.h[1],Y=this.h[2],B=this.h[3],T=this.h[4],V=this.h[5],j=this.h[6],D=this.h[7],L=this.h[8],Ie=this.h[9],Ke=this.r[0],We=this.r[1],qe=this.r[2],w=this.r[3],et=this.r[4],pt=this.r[5],yt=this.r[6],Je=this.r[7],ut=this.r[8],ft=this.r[9];d>=16;)g=l[p+0]&255|(l[p+1]&255)<<8,pe+=g&8191,S=l[p+2]&255|(l[p+3]&255)<<8,we+=(g>>>13|S<<3)&8191,E=l[p+4]&255|(l[p+5]&255)<<8,Y+=(S>>>10|E<<6)&8191,R=l[p+6]&255|(l[p+7]&255)<<8,B+=(E>>>7|R<<9)&8191,z=l[p+8]&255|(l[p+9]&255)<<8,T+=(R>>>4|z<<12)&8191,V+=z>>>1&8191,be=l[p+10]&255|(l[p+11]&255)<<8,j+=(z>>>14|be<<2)&8191,X=l[p+12]&255|(l[p+13]&255)<<8,D+=(be>>>11|X<<5)&8191,dt=l[p+14]&255|(l[p+15]&255)<<8,L+=(X>>>8|dt<<8)&8191,Ie+=dt>>>5|a,oe=0,Oe=oe,Oe+=pe*Ke,Oe+=we*(5*ft),Oe+=Y*(5*ut),Oe+=B*(5*Je),Oe+=T*(5*yt),oe=Oe>>>13,Oe&=8191,Oe+=V*(5*pt),Oe+=j*(5*et),Oe+=D*(5*w),Oe+=L*(5*qe),Oe+=Ie*(5*We),oe+=Oe>>>13,Oe&=8191,Pe=oe,Pe+=pe*We,Pe+=we*Ke,Pe+=Y*(5*ft),Pe+=B*(5*ut),Pe+=T*(5*Je),oe=Pe>>>13,Pe&=8191,Pe+=V*(5*yt),Pe+=j*(5*pt),Pe+=D*(5*et),Pe+=L*(5*w),Pe+=Ie*(5*qe),oe+=Pe>>>13,Pe&=8191,ze=oe,ze+=pe*qe,ze+=we*We,ze+=Y*Ke,ze+=B*(5*ft),ze+=T*(5*ut),oe=ze>>>13,ze&=8191,ze+=V*(5*Je),ze+=j*(5*yt),ze+=D*(5*pt),ze+=L*(5*et),ze+=Ie*(5*w),oe+=ze>>>13,ze&=8191,Le=oe,Le+=pe*w,Le+=we*qe,Le+=Y*We,Le+=B*Ke,Le+=T*(5*ft),oe=Le>>>13,Le&=8191,Le+=V*(5*ut),Le+=j*(5*Je),Le+=D*(5*yt),Le+=L*(5*pt),Le+=Ie*(5*et),oe+=Le>>>13,Le&=8191,je=oe,je+=pe*et,je+=we*w,je+=Y*qe,je+=B*We,je+=T*Ke,oe=je>>>13,je&=8191,je+=V*(5*ft),je+=j*(5*ut),je+=D*(5*Je),je+=L*(5*yt),je+=Ie*(5*pt),oe+=je>>>13,je&=8191,Ue=oe,Ue+=pe*pt,Ue+=we*et,Ue+=Y*w,Ue+=B*qe,Ue+=T*We,oe=Ue>>>13,Ue&=8191,Ue+=V*Ke,Ue+=j*(5*ft),Ue+=D*(5*ut),Ue+=L*(5*Je),Ue+=Ie*(5*yt),oe+=Ue>>>13,Ue&=8191,Re=oe,Re+=pe*yt,Re+=we*pt,Re+=Y*et,Re+=B*w,Re+=T*qe,oe=Re>>>13,Re&=8191,Re+=V*We,Re+=j*Ke,Re+=D*(5*ft),Re+=L*(5*ut),Re+=Ie*(5*Je),oe+=Re>>>13,Re&=8191,he=oe,he+=pe*Je,he+=we*yt,he+=Y*pt,he+=B*et,he+=T*w,oe=he>>>13,he&=8191,he+=V*qe,he+=j*We,he+=D*Ke,he+=L*(5*ft),he+=Ie*(5*ut),oe+=he>>>13,he&=8191,Ee=oe,Ee+=pe*ut,Ee+=we*Je,Ee+=Y*yt,Ee+=B*pt,Ee+=T*et,oe=Ee>>>13,Ee&=8191,Ee+=V*w,Ee+=j*qe,Ee+=D*We,Ee+=L*Ke,Ee+=Ie*(5*ft),oe+=Ee>>>13,Ee&=8191,te=oe,te+=pe*ft,te+=we*ut,te+=Y*Je,te+=B*yt,te+=T*pt,oe=te>>>13,te&=8191,te+=V*et,te+=j*w,te+=D*qe,te+=L*We,te+=Ie*Ke,oe+=te>>>13,te&=8191,oe=(oe<<2)+oe|0,oe=oe+Oe|0,Oe=oe&8191,oe=oe>>>13,Pe+=oe,pe=Oe,we=Pe,Y=ze,B=Le,T=je,V=Ue,j=Re,D=he,L=Ee,Ie=te,p+=16,d-=16;this.h[0]=pe,this.h[1]=we,this.h[2]=Y,this.h[3]=B,this.h[4]=T,this.h[5]=V,this.h[6]=j,this.h[7]=D,this.h[8]=L,this.h[9]=Ie},ue.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},ue.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 fe(l,p,d,a,g,S){var E=new ue(S);return E.update(d,a,g),E.finish(l,p),0}function ve(l,p,d,a,g,S){var E=new Uint8Array(16);return fe(E,0,d,a,g,S),k(l,p,E,0)}function _e(l,p,d,a,g){var S;if(d<32)return-1;for(vt(l,0,p,0,d,a,g),fe(l,16,l,32,d-32,l),S=0;S<16;S++)l[S]=0;return 0}function De(l,p,d,a,g){var S,E=new Uint8Array(32);if(d<32||(wt(E,0,32,a,g),ve(p,16,p,32,d-32,E)!==0))return-1;for(vt(l,0,p,0,d,a,g),S=0;S<32;S++)l[S]=0;return 0}function Qe(l,p){var d;for(d=0;d<16;d++)l[d]=p[d]|0}function se(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 Ce(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 xt(l,p){var d,a,g,S=t(),E=t();for(d=0;d<16;d++)E[d]=p[d];for(se(E),se(E),se(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,Ce(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 xt(d,l),xt(a,p),I(d,0,a,0)}function Lt(l){var p=new Uint8Array(32);return xt(p,l),p[0]&1}function ce(l,p){var d;for(d=0;d<16;d++)l[d]=p[2*d]+(p[2*d+1]<<8);l[15]&=32767}function lt(l,p,d){for(var a=0;a<16;a++)l[a]=p[a]+d[a]}function At(l,p,d){for(var a=0;a<16;a++)l[a]=p[a]-d[a]}function Q(l,p,d){var a,g,S=0,E=0,R=0,z=0,be=0,X=0,dt=0,oe=0,Oe=0,Pe=0,ze=0,Le=0,je=0,Ue=0,Re=0,he=0,Ee=0,te=0,pe=0,we=0,Y=0,B=0,T=0,V=0,j=0,D=0,L=0,Ie=0,Ke=0,We=0,qe=0,w=d[0],et=d[1],pt=d[2],yt=d[3],Je=d[4],ut=d[5],ft=d[6],Ht=d[7],_t=d[8],Dt=d[9],Ut=d[10],$t=d[11],Kt=d[12],sr=d[13],or=d[14],ar=d[15];a=p[0],S+=a*w,E+=a*et,R+=a*pt,z+=a*yt,be+=a*Je,X+=a*ut,dt+=a*ft,oe+=a*Ht,Oe+=a*_t,Pe+=a*Dt,ze+=a*Ut,Le+=a*$t,je+=a*Kt,Ue+=a*sr,Re+=a*or,he+=a*ar,a=p[1],E+=a*w,R+=a*et,z+=a*pt,be+=a*yt,X+=a*Je,dt+=a*ut,oe+=a*ft,Oe+=a*Ht,Pe+=a*_t,ze+=a*Dt,Le+=a*Ut,je+=a*$t,Ue+=a*Kt,Re+=a*sr,he+=a*or,Ee+=a*ar,a=p[2],R+=a*w,z+=a*et,be+=a*pt,X+=a*yt,dt+=a*Je,oe+=a*ut,Oe+=a*ft,Pe+=a*Ht,ze+=a*_t,Le+=a*Dt,je+=a*Ut,Ue+=a*$t,Re+=a*Kt,he+=a*sr,Ee+=a*or,te+=a*ar,a=p[3],z+=a*w,be+=a*et,X+=a*pt,dt+=a*yt,oe+=a*Je,Oe+=a*ut,Pe+=a*ft,ze+=a*Ht,Le+=a*_t,je+=a*Dt,Ue+=a*Ut,Re+=a*$t,he+=a*Kt,Ee+=a*sr,te+=a*or,pe+=a*ar,a=p[4],be+=a*w,X+=a*et,dt+=a*pt,oe+=a*yt,Oe+=a*Je,Pe+=a*ut,ze+=a*ft,Le+=a*Ht,je+=a*_t,Ue+=a*Dt,Re+=a*Ut,he+=a*$t,Ee+=a*Kt,te+=a*sr,pe+=a*or,we+=a*ar,a=p[5],X+=a*w,dt+=a*et,oe+=a*pt,Oe+=a*yt,Pe+=a*Je,ze+=a*ut,Le+=a*ft,je+=a*Ht,Ue+=a*_t,Re+=a*Dt,he+=a*Ut,Ee+=a*$t,te+=a*Kt,pe+=a*sr,we+=a*or,Y+=a*ar,a=p[6],dt+=a*w,oe+=a*et,Oe+=a*pt,Pe+=a*yt,ze+=a*Je,Le+=a*ut,je+=a*ft,Ue+=a*Ht,Re+=a*_t,he+=a*Dt,Ee+=a*Ut,te+=a*$t,pe+=a*Kt,we+=a*sr,Y+=a*or,B+=a*ar,a=p[7],oe+=a*w,Oe+=a*et,Pe+=a*pt,ze+=a*yt,Le+=a*Je,je+=a*ut,Ue+=a*ft,Re+=a*Ht,he+=a*_t,Ee+=a*Dt,te+=a*Ut,pe+=a*$t,we+=a*Kt,Y+=a*sr,B+=a*or,T+=a*ar,a=p[8],Oe+=a*w,Pe+=a*et,ze+=a*pt,Le+=a*yt,je+=a*Je,Ue+=a*ut,Re+=a*ft,he+=a*Ht,Ee+=a*_t,te+=a*Dt,pe+=a*Ut,we+=a*$t,Y+=a*Kt,B+=a*sr,T+=a*or,V+=a*ar,a=p[9],Pe+=a*w,ze+=a*et,Le+=a*pt,je+=a*yt,Ue+=a*Je,Re+=a*ut,he+=a*ft,Ee+=a*Ht,te+=a*_t,pe+=a*Dt,we+=a*Ut,Y+=a*$t,B+=a*Kt,T+=a*sr,V+=a*or,j+=a*ar,a=p[10],ze+=a*w,Le+=a*et,je+=a*pt,Ue+=a*yt,Re+=a*Je,he+=a*ut,Ee+=a*ft,te+=a*Ht,pe+=a*_t,we+=a*Dt,Y+=a*Ut,B+=a*$t,T+=a*Kt,V+=a*sr,j+=a*or,D+=a*ar,a=p[11],Le+=a*w,je+=a*et,Ue+=a*pt,Re+=a*yt,he+=a*Je,Ee+=a*ut,te+=a*ft,pe+=a*Ht,we+=a*_t,Y+=a*Dt,B+=a*Ut,T+=a*$t,V+=a*Kt,j+=a*sr,D+=a*or,L+=a*ar,a=p[12],je+=a*w,Ue+=a*et,Re+=a*pt,he+=a*yt,Ee+=a*Je,te+=a*ut,pe+=a*ft,we+=a*Ht,Y+=a*_t,B+=a*Dt,T+=a*Ut,V+=a*$t,j+=a*Kt,D+=a*sr,L+=a*or,Ie+=a*ar,a=p[13],Ue+=a*w,Re+=a*et,he+=a*pt,Ee+=a*yt,te+=a*Je,pe+=a*ut,we+=a*ft,Y+=a*Ht,B+=a*_t,T+=a*Dt,V+=a*Ut,j+=a*$t,D+=a*Kt,L+=a*sr,Ie+=a*or,Ke+=a*ar,a=p[14],Re+=a*w,he+=a*et,Ee+=a*pt,te+=a*yt,pe+=a*Je,we+=a*ut,Y+=a*ft,B+=a*Ht,T+=a*_t,V+=a*Dt,j+=a*Ut,D+=a*$t,L+=a*Kt,Ie+=a*sr,Ke+=a*or,We+=a*ar,a=p[15],he+=a*w,Ee+=a*et,te+=a*pt,pe+=a*yt,we+=a*Je,Y+=a*ut,B+=a*ft,T+=a*Ht,V+=a*_t,j+=a*Dt,D+=a*Ut,L+=a*$t,Ie+=a*Kt,Ke+=a*sr,We+=a*or,qe+=a*ar,S+=38*Ee,E+=38*te,R+=38*pe,z+=38*we,be+=38*Y,X+=38*B,dt+=38*T,oe+=38*V,Oe+=38*j,Pe+=38*D,ze+=38*L,Le+=38*Ie,je+=38*Ke,Ue+=38*We,Re+=38*qe,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=R+g+65535,g=Math.floor(a/65536),R=a-g*65536,a=z+g+65535,g=Math.floor(a/65536),z=a-g*65536,a=be+g+65535,g=Math.floor(a/65536),be=a-g*65536,a=X+g+65535,g=Math.floor(a/65536),X=a-g*65536,a=dt+g+65535,g=Math.floor(a/65536),dt=a-g*65536,a=oe+g+65535,g=Math.floor(a/65536),oe=a-g*65536,a=Oe+g+65535,g=Math.floor(a/65536),Oe=a-g*65536,a=Pe+g+65535,g=Math.floor(a/65536),Pe=a-g*65536,a=ze+g+65535,g=Math.floor(a/65536),ze=a-g*65536,a=Le+g+65535,g=Math.floor(a/65536),Le=a-g*65536,a=je+g+65535,g=Math.floor(a/65536),je=a-g*65536,a=Ue+g+65535,g=Math.floor(a/65536),Ue=a-g*65536,a=Re+g+65535,g=Math.floor(a/65536),Re=a-g*65536,a=he+g+65535,g=Math.floor(a/65536),he=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=R+g+65535,g=Math.floor(a/65536),R=a-g*65536,a=z+g+65535,g=Math.floor(a/65536),z=a-g*65536,a=be+g+65535,g=Math.floor(a/65536),be=a-g*65536,a=X+g+65535,g=Math.floor(a/65536),X=a-g*65536,a=dt+g+65535,g=Math.floor(a/65536),dt=a-g*65536,a=oe+g+65535,g=Math.floor(a/65536),oe=a-g*65536,a=Oe+g+65535,g=Math.floor(a/65536),Oe=a-g*65536,a=Pe+g+65535,g=Math.floor(a/65536),Pe=a-g*65536,a=ze+g+65535,g=Math.floor(a/65536),ze=a-g*65536,a=Le+g+65535,g=Math.floor(a/65536),Le=a-g*65536,a=je+g+65535,g=Math.floor(a/65536),je=a-g*65536,a=Ue+g+65535,g=Math.floor(a/65536),Ue=a-g*65536,a=Re+g+65535,g=Math.floor(a/65536),Re=a-g*65536,a=he+g+65535,g=Math.floor(a/65536),he=a-g*65536,S+=g-1+37*(g-1),l[0]=S,l[1]=E,l[2]=R,l[3]=z,l[4]=be,l[5]=X,l[6]=dt,l[7]=oe,l[8]=Oe,l[9]=Pe,l[10]=ze,l[11]=Le,l[12]=je,l[13]=Ue,l[14]=Re,l[15]=he}function bt(l,p){Q(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--)bt(d,d),a!==2&&a!==4&&Q(d,d,p);for(a=0;a<16;a++)l[a]=d[a]}function vo(l,p){var d=t(),a;for(a=0;a<16;a++)d[a]=p[a];for(a=250;a>=0;a--)bt(d,d),a!==1&&Q(d,d,p);for(a=0;a<16;a++)l[a]=d[a]}function ls(l,p,d){var a=new Uint8Array(32),g=new Float64Array(80),S,E,R=t(),z=t(),be=t(),X=t(),dt=t(),oe=t();for(E=0;E<31;E++)a[E]=p[E];for(a[31]=p[31]&127|64,a[0]&=248,ce(g,d),E=0;E<16;E++)z[E]=g[E],X[E]=R[E]=be[E]=0;for(R[0]=X[0]=1,E=254;E>=0;--E)S=a[E>>>3]>>>(E&7)&1,Ce(R,z,S),Ce(be,X,S),lt(dt,R,be),At(R,R,be),lt(be,z,X),At(z,z,X),bt(X,dt),bt(oe,R),Q(R,be,R),Q(be,z,dt),lt(dt,R,be),At(R,R,be),bt(z,R),At(be,X,oe),Q(R,be,u),lt(R,R,X),Q(be,be,R),Q(R,X,oe),Q(X,z,g),bt(z,dt),Ce(R,z,S),Ce(be,X,S);for(E=0;E<16;E++)g[E+16]=R[E],g[E+32]=be[E],g[E+48]=z[E],g[E+64]=X[E];var Oe=g.subarray(32),Pe=g.subarray(16);return Ft(Oe,Oe),Q(Pe,Pe,Oe),xt(l,Pe),0}function pr(l,p){return ls(l,p,s)}function mo(l,p){return n(p,32),pr(l,p)}function On(l,p,d){var a=new Uint8Array(32);return ls(a,d,p),rt(l,i,a,$e)}var wo=_e,Tf=De;function bo(l,p,d,a,g,S){var E=new Uint8Array(32);return On(E,g,S),wo(l,p,d,a,E)}function Dc(l,p,d,a,g,S){var E=new Uint8Array(32);return On(E,g,S),Tf(l,p,d,a,E)}var xo=[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 Ao(l,p,d,a){for(var g=new Int32Array(16),S=new Int32Array(16),E,R,z,be,X,dt,oe,Oe,Pe,ze,Le,je,Ue,Re,he,Ee,te,pe,we,Y,B,T,V,j,D,L,Ie=l[0],Ke=l[1],We=l[2],qe=l[3],w=l[4],et=l[5],pt=l[6],yt=l[7],Je=p[0],ut=p[1],ft=p[2],Ht=p[3],_t=p[4],Dt=p[5],Ut=p[6],$t=p[7],Kt=0;a>=128;){for(we=0;we<16;we++)Y=8*we+Kt,g[we]=d[Y+0]<<24|d[Y+1]<<16|d[Y+2]<<8|d[Y+3],S[we]=d[Y+4]<<24|d[Y+5]<<16|d[Y+6]<<8|d[Y+7];for(we=0;we<80;we++)if(E=Ie,R=Ke,z=We,be=qe,X=w,dt=et,oe=pt,Oe=yt,Pe=Je,ze=ut,Le=ft,je=Ht,Ue=_t,Re=Dt,he=Ut,Ee=$t,B=yt,T=$t,V=T&65535,j=T>>>16,D=B&65535,L=B>>>16,B=(w>>>14|_t<<18)^(w>>>18|_t<<14)^(_t>>>9|w<<23),T=(_t>>>14|w<<18)^(_t>>>18|w<<14)^(w>>>9|_t<<23),V+=T&65535,j+=T>>>16,D+=B&65535,L+=B>>>16,B=w&et^~w&pt,T=_t&Dt^~_t&Ut,V+=T&65535,j+=T>>>16,D+=B&65535,L+=B>>>16,B=xo[we*2],T=xo[we*2+1],V+=T&65535,j+=T>>>16,D+=B&65535,L+=B>>>16,B=g[we%16],T=S[we%16],V+=T&65535,j+=T>>>16,D+=B&65535,L+=B>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,te=D&65535|L<<16,pe=V&65535|j<<16,B=te,T=pe,V=T&65535,j=T>>>16,D=B&65535,L=B>>>16,B=(Ie>>>28|Je<<4)^(Je>>>2|Ie<<30)^(Je>>>7|Ie<<25),T=(Je>>>28|Ie<<4)^(Ie>>>2|Je<<30)^(Ie>>>7|Je<<25),V+=T&65535,j+=T>>>16,D+=B&65535,L+=B>>>16,B=Ie&Ke^Ie&We^Ke&We,T=Je&ut^Je&ft^ut&ft,V+=T&65535,j+=T>>>16,D+=B&65535,L+=B>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,Oe=D&65535|L<<16,Ee=V&65535|j<<16,B=be,T=je,V=T&65535,j=T>>>16,D=B&65535,L=B>>>16,B=te,T=pe,V+=T&65535,j+=T>>>16,D+=B&65535,L+=B>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,be=D&65535|L<<16,je=V&65535|j<<16,Ke=E,We=R,qe=z,w=be,et=X,pt=dt,yt=oe,Ie=Oe,ut=Pe,ft=ze,Ht=Le,_t=je,Dt=Ue,Ut=Re,$t=he,Je=Ee,we%16===15)for(Y=0;Y<16;Y++)B=g[Y],T=S[Y],V=T&65535,j=T>>>16,D=B&65535,L=B>>>16,B=g[(Y+9)%16],T=S[(Y+9)%16],V+=T&65535,j+=T>>>16,D+=B&65535,L+=B>>>16,te=g[(Y+1)%16],pe=S[(Y+1)%16],B=(te>>>1|pe<<31)^(te>>>8|pe<<24)^te>>>7,T=(pe>>>1|te<<31)^(pe>>>8|te<<24)^(pe>>>7|te<<25),V+=T&65535,j+=T>>>16,D+=B&65535,L+=B>>>16,te=g[(Y+14)%16],pe=S[(Y+14)%16],B=(te>>>19|pe<<13)^(pe>>>29|te<<3)^te>>>6,T=(pe>>>19|te<<13)^(te>>>29|pe<<3)^(pe>>>6|te<<26),V+=T&65535,j+=T>>>16,D+=B&65535,L+=B>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,g[Y]=D&65535|L<<16,S[Y]=V&65535|j<<16;B=Ie,T=Je,V=T&65535,j=T>>>16,D=B&65535,L=B>>>16,B=l[0],T=p[0],V+=T&65535,j+=T>>>16,D+=B&65535,L+=B>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,l[0]=Ie=D&65535|L<<16,p[0]=Je=V&65535|j<<16,B=Ke,T=ut,V=T&65535,j=T>>>16,D=B&65535,L=B>>>16,B=l[1],T=p[1],V+=T&65535,j+=T>>>16,D+=B&65535,L+=B>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,l[1]=Ke=D&65535|L<<16,p[1]=ut=V&65535|j<<16,B=We,T=ft,V=T&65535,j=T>>>16,D=B&65535,L=B>>>16,B=l[2],T=p[2],V+=T&65535,j+=T>>>16,D+=B&65535,L+=B>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,l[2]=We=D&65535|L<<16,p[2]=ft=V&65535|j<<16,B=qe,T=Ht,V=T&65535,j=T>>>16,D=B&65535,L=B>>>16,B=l[3],T=p[3],V+=T&65535,j+=T>>>16,D+=B&65535,L+=B>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,l[3]=qe=D&65535|L<<16,p[3]=Ht=V&65535|j<<16,B=w,T=_t,V=T&65535,j=T>>>16,D=B&65535,L=B>>>16,B=l[4],T=p[4],V+=T&65535,j+=T>>>16,D+=B&65535,L+=B>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,l[4]=w=D&65535|L<<16,p[4]=_t=V&65535|j<<16,B=et,T=Dt,V=T&65535,j=T>>>16,D=B&65535,L=B>>>16,B=l[5],T=p[5],V+=T&65535,j+=T>>>16,D+=B&65535,L+=B>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,l[5]=et=D&65535|L<<16,p[5]=Dt=V&65535|j<<16,B=pt,T=Ut,V=T&65535,j=T>>>16,D=B&65535,L=B>>>16,B=l[6],T=p[6],V+=T&65535,j+=T>>>16,D+=B&65535,L+=B>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,l[6]=pt=D&65535|L<<16,p[6]=Ut=V&65535|j<<16,B=yt,T=$t,V=T&65535,j=T>>>16,D=B&65535,L=B>>>16,B=l[7],T=p[7],V+=T&65535,j+=T>>>16,D+=B&65535,L+=B>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,l[7]=yt=D&65535|L<<16,p[7]=$t=V&65535|j<<16,Kt+=128,a-=128}return a}function hn(l,p,d){var a=new Int32Array(8),g=new Int32Array(8),S=new Uint8Array(256),E,R=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,Ao(a,g,p,d),d%=128,E=0;E<d;E++)S[E]=p[R-d+E];for(S[d]=128,d=256-128*(d<112?1:0),S[d-9]=0,m(S,d-8,R/536870912|0,R<<3),Ao(a,g,S,d),E=0;E<8;E++)m(l,8*E,a[E],g[E]);return 0}function ki(l,p){var d=t(),a=t(),g=t(),S=t(),E=t(),R=t(),z=t(),be=t(),X=t();At(d,l[1],l[0]),At(X,p[1],p[0]),Q(d,d,X),lt(a,l[0],l[1]),lt(X,p[0],p[1]),Q(a,a,X),Q(g,l[3],p[3]),Q(g,g,v),Q(S,l[2],p[2]),lt(S,S,S),At(E,a,d),At(R,S,g),lt(z,S,g),lt(be,a,d),Q(l[0],E,R),Q(l[1],be,z),Q(l[2],z,R),Q(l[3],E,be)}function us(l,p,d){var a;for(a=0;a<4;a++)Ce(l[a],p[a],d)}function So(l,p){var d=t(),a=t(),g=t();Ft(g,p[2]),Q(d,p[0],g),Q(a,p[1],g),xt(l,a),l[31]^=Lt(d)<<7}function _o(l,p,d){var a,g;for(Qe(l[0],o),Qe(l[1],c),Qe(l[2],c),Qe(l[3],o),g=255;g>=0;--g)a=d[g/8|0]>>(g&7)&1,us(l,p,a),ki(p,l),ki(l,l),us(l,p,a)}function fs(l,p){var d=[t(),t(),t(),t()];Qe(d[0],b),Qe(d[1],F),Qe(d[2],c),Q(d[3],b,F),_o(l,d,p)}function Eo(l,p,d){var a=new Uint8Array(64),g=[t(),t(),t(),t()],S;for(d||n(p,32),hn(a,p,32),a[0]&=248,a[31]&=127,a[31]|=64,fs(g,a),So(l,g),S=0;S<32;S++)p[S+32]=l[S];return 0}var dn=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 Io(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]*dn[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)*dn[g],d=p[g]>>8,p[g]&=255;for(g=0;g<32;g++)p[g]-=d*dn[g];for(a=0;a<32;a++)p[a+1]+=p[a]>>8,l[a]=p[a]&255}function ko(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;Io(l,p)}function Uc(l,p,d,a){var g=new Uint8Array(64),S=new Uint8Array(64),E=new Uint8Array(64),R,z,be=new Float64Array(64),X=[t(),t(),t(),t()];hn(g,a,32),g[0]&=248,g[31]&=127,g[31]|=64;var dt=d+64;for(R=0;R<d;R++)l[64+R]=p[R];for(R=0;R<32;R++)l[32+R]=g[32+R];for(hn(E,l.subarray(32),d+32),ko(E),fs(X,E),So(l,X),R=32;R<64;R++)l[R]=a[R];for(hn(S,l,d+64),ko(S),R=0;R<64;R++)be[R]=0;for(R=0;R<32;R++)be[R]=E[R];for(R=0;R<32;R++)for(z=0;z<32;z++)be[R+z]+=S[R]*g[z];return Io(l.subarray(32),be),dt}function Co(l,p){var d=t(),a=t(),g=t(),S=t(),E=t(),R=t(),z=t();return Qe(l[2],c),ce(l[1],p),bt(g,l[1]),Q(S,g,h),At(g,g,l[2]),lt(S,l[2],S),bt(E,S),bt(R,E),Q(z,R,E),Q(d,z,g),Q(d,d,S),vo(d,d),Q(d,d,g),Q(d,d,S),Q(d,d,S),Q(l[0],d,S),bt(a,l[0]),Q(a,a,S),Vt(a,g)&&Q(l[0],l[0],O),bt(a,l[0]),Q(a,a,S),Vt(a,g)?-1:(Lt(l[0])===p[31]>>7&&At(l[0],o,l[0]),Q(l[3],l[0],l[1]),0)}function _(l,p,d,a){var g,S=new Uint8Array(32),E=new Uint8Array(64),R=[t(),t(),t(),t()],z=[t(),t(),t(),t()];if(d<64||Co(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(hn(E,l,d),ko(E),_o(R,z,E),fs(z,p.subarray(32)),ki(R,z),So(S,R),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 C=32,N=24,K=32,Ae=16,Ct=32,Bt=32,Ve=32,Z=32,ee=32,le=N,me=K,tt=Ae,ot=64,St=32,Zt=64,hs=32,Bo=64;e.lowlevel={crypto_core_hsalsa20:rt,crypto_stream_xor:vt,crypto_stream:wt,crypto_stream_salsa20_xor:Ne,crypto_stream_salsa20:Ge,crypto_onetimeauth:fe,crypto_onetimeauth_verify:ve,crypto_verify_16:k,crypto_verify_32:I,crypto_secretbox:_e,crypto_secretbox_open:De,crypto_scalarmult:ls,crypto_scalarmult_base:pr,crypto_box_beforenm:On,crypto_box_afternm:wo,crypto_box:bo,crypto_box_open:Dc,crypto_box_keypair:mo,crypto_hash:hn,crypto_sign:Uc,crypto_sign_keypair:Eo,crypto_sign_open:_,crypto_secretbox_KEYBYTES:C,crypto_secretbox_NONCEBYTES:N,crypto_secretbox_ZEROBYTES:K,crypto_secretbox_BOXZEROBYTES:Ae,crypto_scalarmult_BYTES:Ct,crypto_scalarmult_SCALARBYTES:Bt,crypto_box_PUBLICKEYBYTES:Ve,crypto_box_SECRETKEYBYTES:Z,crypto_box_BEFORENMBYTES:ee,crypto_box_NONCEBYTES:le,crypto_box_ZEROBYTES:me,crypto_box_BOXZEROBYTES:tt,crypto_sign_BYTES:ot,crypto_sign_PUBLICKEYBYTES:St,crypto_sign_SECRETKEYBYTES:Zt,crypto_sign_SEEDBYTES:hs,crypto_hash_BYTES:Bo,gf:t,D:h,L:dn,pack25519:xt,unpack25519:ce,M:Q,A:lt,S:bt,Z:At,pow2523:vo,add:ki,set25519:Qe,modL:Io,scalarmult:_o,scalarbase:fs};function $c(l,p){if(l.length!==C)throw new Error("bad key size");if(p.length!==N)throw new Error("bad nonce size")}function Mw(l,p){if(l.length!==Ve)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 qy(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),$c(d,p);for(var a=new Uint8Array(K+l.length),g=new Uint8Array(a.length),S=0;S<l.length;S++)a[S+K]=l[S];return _e(g,a,a.length,p,d),g.subarray(Ae)},e.secretbox.open=function(l,p,d){Br(l,p,d),$c(d,p);for(var a=new Uint8Array(Ae+l.length),g=new Uint8Array(a.length),S=0;S<l.length;S++)a[S+Ae]=l[S];return a.length<32||De(g,a,a.length,p,d)!==0?null:g.subarray(K)},e.secretbox.keyLength=C,e.secretbox.nonceLength=N,e.secretbox.overheadLength=Ae,e.scalarMult=function(l,p){if(Br(l,p),l.length!==Bt)throw new Error("bad n size");if(p.length!==Ct)throw new Error("bad p size");var d=new Uint8Array(Ct);return ls(d,l,p),d},e.scalarMult.base=function(l){if(Br(l),l.length!==Bt)throw new Error("bad n size");var p=new Uint8Array(Ct);return pr(p,l),p},e.scalarMult.scalarLength=Bt,e.scalarMult.groupElementLength=Ct,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),Mw(l,p);var d=new Uint8Array(ee);return On(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(Ve),p=new Uint8Array(Z);return mo(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(Ve);return pr(p,l),{publicKey:p,secretKey:new Uint8Array(l)}},e.box.publicKeyLength=Ve,e.box.secretKeyLength=Z,e.box.sharedKeyLength=ee,e.box.nonceLength=le,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(ot+l.length);return Uc(d,l,l.length,p),d},e.sign.open=function(l,p){if(Br(l,p),p.length!==St)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(ot),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!==ot)throw new Error("bad signature size");if(d.length!==St)throw new Error("bad public key size");var a=new Uint8Array(ot+l.length),g=new Uint8Array(ot+l.length),S;for(S=0;S<ot;S++)a[S]=p[S];for(S=0;S<l.length;S++)a[S+ot]=l[S];return _(g,a,a.length,d)>=0},e.sign.keyPair=function(){var l=new Uint8Array(St),p=new Uint8Array(Zt);return Eo(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(St),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!==hs)throw new Error("bad seed size");for(var p=new Uint8Array(St),d=new Uint8Array(Zt),a=0;a<32;a++)d[a]=l[a];return Eo(p,d,!0),{publicKey:p,secretKey:d}},e.sign.publicKeyLength=St,e.sign.secretKeyLength=Zt,e.sign.seedLength=hs,e.sign.signatureLength=ot,e.hash=function(l){Br(l);var p=new Uint8Array(Bo);return hn(p,l,l.length),p},e.hash.hashLength=Bo,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];qy(S)})}else typeof L1<"u"&&(l=H1,l&&l.randomBytes&&e.setPRNG(function(d,a){var g,S=l.randomBytes(a);for(g=0;g<a;g++)d[g]=S[g];qy(S)}))}()})(r.exports?r.exports:self.nacl=self.nacl||{})})(j0);var F1=j0.exports;const R0=hg(F1);function G1(){return R0.box.keyPair()}async function Ii(r,e){const t=sessionStorage.getItem("sessionKey"),n=sessionStorage.getItem("sessionId");console.groupCollapsed("Attestation");try{if(t&&n&&!r){const o=ps(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 V1(i,e);if(s&&s.public_key){console.log("Attestation document verification succeeded");const o=G1();console.log("Generated client key pair");const c=new Uint8Array(s.public_key),{encrypted_session_key:u,session_id:h}=await cw(Sr(o.publicKey),i,e);console.log("Key exchange completed.");const v=R0.scalarMult(o.secretKey,c),b=ps(u),F=12,O=b.slice(0,F),m=b.slice(F),k=new Hc(v).open(O,m);if(k)return console.log("Session key decrypted successfully"),window.sessionStorage.setItem("sessionKey",Sr(k)),window.sessionStorage.setItem("sessionId",h),{sessionKey:k,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 ct="";function z1(r){ct=r}async function K1(r,e){return Pt(`${ct}/platform/login`,"POST",{email:r,password:e},void 0,"Failed to login")}async function q1(r,e,t,n){return Pt(`${ct}/platform/register`,"POST",{email:r,password:e,invite_code:t,name:n},void 0,"Failed to register")}async function Z1(r){return Pt(`${ct}/platform/logout`,"POST",{refresh_token:r},void 0,"Failed to logout")}async function W1(){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 Pt(`${ct}/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 D0(r){return de(`${ct}/platform/orgs`,"POST",{name:r})}async function U0(){return de(`${ct}/platform/orgs`,"GET",void 0)}async function $0(r){return de(`${ct}/platform/orgs/${r}`,"DELETE",void 0)}async function M0(r,e,t){return de(`${ct}/platform/orgs/${r}/projects`,"POST",{name:e,description:t})}async function V0(r){return de(`${ct}/platform/orgs/${r}/projects`,"GET",void 0)}async function L0(r,e){return de(`${ct}/platform/orgs/${r}/projects/${e}`,"GET",void 0)}async function H0(r,e,t){return de(`${ct}/platform/orgs/${r}/projects/${e}`,"PATCH",t)}async function F0(r,e){return de(`${ct}/platform/orgs/${r}/projects/${e}`,"DELETE",void 0)}function Y1(r){const e=/^[A-Za-z0-9+/]*[=]{0,2}$/,t=r.length%4===0,n=e.test(r);return t&&n}async function G0(r,e,t,n){if(!Y1(n))throw new Error("Secret must be base64 encoded. Use @stablelib/base64's encode function to encode your data.");return de(`${ct}/platform/orgs/${r}/projects/${e}/secrets`,"POST",{key_name:t,secret:n})}async function z0(r,e){return de(`${ct}/platform/orgs/${r}/projects/${e}/secrets`,"GET",void 0)}async function K0(r,e,t){return de(`${ct}/platform/orgs/${r}/projects/${e}/secrets/${t}`,"DELETE",void 0)}async function q0(r,e){return de(`${ct}/platform/orgs/${r}/projects/${e}/settings/email`,"GET",void 0)}async function Z0(r,e,t){return de(`${ct}/platform/orgs/${r}/projects/${e}/settings/email`,"PUT",t)}async function W0(r,e){return de(`${ct}/platform/orgs/${r}/projects/${e}/settings/oauth`,"GET",void 0)}async function Y0(r,e,t){return de(`${ct}/platform/orgs/${r}/projects/${e}/settings/oauth`,"PUT",t)}async function J0(r,e,t){if(!e||e.trim()==="")throw new Error("Email is required");return de(`${ct}/platform/orgs/${r}/invites`,"POST",{email:e,role:t})}async function X0(r){return de(`${ct}/platform/orgs/${r}/invites`,"GET",void 0)}async function Q0(r,e){return de(`${ct}/platform/orgs/${r}/invites/${e}`,"GET",void 0)}async function ey(r,e){return de(`${ct}/platform/orgs/${r}/invites/${e}`,"DELETE",void 0)}async function ty(r){return de(`${ct}/platform/orgs/${r}/memberships`,"GET",void 0)}async function ry(r,e,t){return de(`${ct}/platform/orgs/${r}/memberships/${e}`,"PATCH",{role:t})}async function ny(r,e){return de(`${ct}/platform/orgs/${r}/memberships/${e}`,"DELETE",void 0)}async function iy(r){return de(`${ct}/platform/accept_invite/${r}`,"POST",void 0)}async function J1(){return de(`${ct}/platform/me`,"GET",void 0)}async function sy(r){return Pt(`${ct}/platform/verify-email/${r}`,"GET",void 0,void 0,"Failed to verify email")}async function Bc(){return de(`${ct}/platform/request_verification`,"POST",void 0,"Failed to request new verification code")}async function oy(r,e){const t={email:r,hashed_secret:e};return Pt(`${ct}/platform/password-reset/request`,"POST",t,void 0,"Failed to request platform password reset")}async function ay(r,e,t,n){const i={email:r,alphanumeric_code:e,plaintext_secret:t,new_password:n};return Pt(`${ct}/platform/password-reset/confirm`,"POST",i,void 0,"Failed to confirm platform password reset")}async function cy(r,e){const t={current_password:r,new_password:e};return de(`${ct}/platform/change-password`,"POST",t,"Failed to change platform password")}class X1{constructor(){Ze(this,"_appApiUrl","");Ze(this,"_platformApiUrl","")}configure(e,t){this._appApiUrl=e,this._platformApiUrl=t}get platformApiUrl(){return this._platformApiUrl}get appApiUrl(){return this._appApiUrl}isPlatformPath(e){return e.includes("/platform/")}resolveEndpoint(e){const t=this.isPlatformPath(e);return{baseUrl:t?this._platformApiUrl:this._appApiUrl,context:t?"platform":"app"}}buildUrl(e){if(e.startsWith("http"))return e;const t=this.resolveEndpoint(e),n=t.baseUrl.endsWith("/")?t.baseUrl.slice(0,-1):t.baseUrl,i=e.startsWith("/")?e:`/${e}`;return`${n}${i}`}getRefreshFunction(e){return this.isPlatformPath(e)?"platformRefreshToken":"refreshToken"}}const yo=new X1,ly=Object.freeze(Object.defineProperty({__proto__:null,apiConfig:yo},Symbol.toStringTag,{value:"Module"}));async function de(r,e,t,n){const i=async(s=!1)=>{try{if(s){console.log("Refreshing access token");const u=yo.getRefreshFunction(r);console.log(`Using ${u}`),u==="platformRefreshToken"?await W1():await Tc()}const o=window.localStorage.getItem("access_token");if(!o)throw new Error("No access token available");const c=await Af(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 uy(r,e,t,n,i){if(!i)return de(r,e,t,n);const s=await Af(r,e,t,i,n);if(s.error)throw new Error(s.error);if(!s.data)throw new Error(n||`Request to ${r} failed`);return s.data}async function Af(r,e,t,n,i){const o=yo.resolveEndpoint(r).context==="platform"?yo.platformApiUrl:void 0;let{sessionKey:c,sessionId:u}=await Ii(!1,o);const h=async(b,F=!1)=>{if(F||!c||!u){const P=await Ii(!0,o);c=P.sessionKey,u=P.sessionId}if(!c||!u)throw new Error("Failed to make encrypted API call, no attestation available.");const O=t?JSON.stringify(t):void 0,m=O?Mf(c,O):void 0,A={"Content-Type":"application/json","x-session-id":u};b&&(A.Authorization=`Bearer ${b}`);const k=await fetch(r,{method:e,headers:A,body:m?JSON.stringify({encrypted:m}):void 0}),I={status:k.status};if(k.ok)try{const P=await k.json(),U=Fc(c,P.encrypted);I.data=JSON.parse(U)}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 k.json();I.error=P.message||i||`HTTP error! Status: ${k.status}`}catch{I.error=i||`HTTP error! Status: ${k.status}`}return I},v=async(b,F=!1)=>{var O;try{const m=await h(b,F);return(m.status===400||(O=m.error)!=null&&O.includes("Encryption error"))&&!F?(console.log("Encryption error or Bad Request, attempting to renew attestation"),v(b,!0)):m}catch(m){return{status:500,error:m instanceof Error?m.message:"Unknown error occurred"}}};return v(n)}async function Pt(r,e,t,n,i){const s=await Af(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 xe="";function Q1(r){xe=r}function ew(){return xe}async function tw(r,e,t){return Pt(`${xe}/login`,"POST",{email:r,password:e,client_id:t})}async function rw(r,e,t){return Pt(`${xe}/login`,"POST",{id:r,password:e,client_id:t})}async function nw(r,e,t,n,i){return Pt(`${xe}/register`,"POST",{email:r,password:e,inviteCode:t.toLowerCase(),client_id:n,name:i})}async function iw(r,e,t){return Pt(`${xe}/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 Pt(`${xe}/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 sw(){return de(`${xe}/protected/user`,"GET",void 0,"Failed to fetch user")}async function fy(r,e){return de(`${xe}/protected/kv/${r}`,"PUT",e,"Failed to put key-value pair")}async function hy(r){return de(`${xe}/protected/kv/${r}`,"DELETE",void 0,"Failed to delete key-value pair")}async function dy(){return de(`${xe}/protected/kv`,"DELETE",void 0,"Failed to delete all key-value pairs")}async function py(r){try{return await de(`${xe}/protected/kv/${r}`,"GET",void 0,"Failed to get key-value pair")}catch(e){console.error(`Error fetching key "${r}":`,e);return}}async function yy(){return de(`${xe}/protected/kv`,"GET",void 0,"Failed to list key-value pairs")}async function ow(r){const e={refresh_token:r};return Pt(`${xe}/logout`,"POST",e)}async function gy(r){return Pt(`${xe}/verify-email/${r}`,"GET",void 0,void 0,"Failed to verify email")}async function Oc(){return de(`${xe}/protected/request_verification`,"POST",void 0,"Failed to request new verification code")}async function aw(r,e){const n=await fetch(`${e||xe}/attestation/${r}`);if(!n.ok)throw new Error(`Request failed with status ${n.status}`);return(await n.json()).attestation_document}async function cw(r,e,t){const i=await fetch(`${t||xe}/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 lw(r,e,t){const n={email:r,hashed_secret:e,client_id:t};return Pt(`${xe}/password-reset/request`,"POST",n,void 0,"Failed to request password reset")}async function uw(r,e,t,n,i){const s={email:r,alphanumeric_code:e,plaintext_secret:t,new_password:n,client_id:i};return Pt(`${xe}/password-reset/confirm`,"POST",s,void 0,"Failed to confirm password reset")}async function vy(r,e){const t={current_password:r,new_password:e};return de(`${xe}/protected/change_password`,"POST",t,"Failed to change password")}async function fw(r,e){try{return await Pt(`${xe}/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 hw(r,e,t){const n={code:r,state:e,invite_code:t};try{return await Pt(`${xe}/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 dw(r,e){try{return await Pt(`${xe}/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 pw(r,e,t){const n={code:r,state:e,invite_code:t};try{return await Pt(`${xe}/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 yw(r,e){try{return await Pt(`${xe}/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 gw(r,e,t){const n={code:r,state:e,invite_code:t};try{return await Pt(`${xe}/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 vw(r,e,t){const n={...r,client_id:e,...t?{invite_code:t}:{}};try{return await Pt(`${xe}/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 my(r){let e=`${xe}/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("&")}`),de(e,"GET",void 0,"Failed to fetch private key")}async function wy(r){let e=`${xe}/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("&")}`),de(e,"GET",void 0,"Failed to fetch private key bytes")}async function by(r,e,t){const i={message_base64:Sr(r),algorithm:e,...t&&Object.keys(t).length>0&&{key_options:t}};return de(`${xe}/protected/sign_message`,"POST",i,"Failed to sign message")}async function xy(r,e){let t=`${xe}/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)}`),de(t,"GET",void 0,"Failed to fetch public key")}async function mw(r,e,t){const n={email:r,password:e,...t!==void 0&&{name:t}};return de(`${xe}/protected/convert_guest`,"POST",n,"Failed to convert guest account")}async function ww(r){return de(`${xe}/protected/third_party_token`,"POST",r?{audience:r}:{},"Failed to generate third party token")}async function Ay(r,e){const t={data:r,...e&&Object.keys(e).length>0&&{key_options:e}};return de(`${xe}/protected/encrypt`,"POST",t,"Failed to encrypt data")}async function Sy(r,e){const t={encrypted_data:r,...e&&Object.keys(e).length>0&&{key_options:e}};return de(`${xe}/protected/decrypt`,"POST",t,"Failed to decrypt data")}async function bw(r){const e={hashed_secret:r};return de(`${xe}/protected/delete-account/request`,"POST",e,"Failed to request account deletion")}async function xw(r,e){const t={confirmation_code:r,plaintext_secret:e};return de(`${xe}/protected/delete-account/confirm`,"POST",t,"Failed to confirm account deletion")}async function _y(r){try{const e=await uy(`${xe}/v1/models`,"GET",void 0,"Failed to fetch models",r);if(!e||typeof e!="object")throw new Error("Invalid response from models endpoint");if(e.object!=="list"||!Array.isArray(e.data))throw new Error("Models response missing expected 'object' or 'data' fields");return e.data}catch(e){throw console.error("Error fetching models:",e),e}}const Ey=10*1024*1024;function Aw(r){return new Promise(e=>setTimeout(e,r))}async function Sf(r){return de(`${xe}/protected/api-keys`,"POST",{name:r},"Failed to create API key")}async function _f(){const r=await de(`${xe}/protected/api-keys`,"GET",void 0,"Failed to list API keys");return r.keys.sort((e,t)=>new Date(t.created_at).getTime()-new Date(e.created_at).getTime()),r}async function Ef(r){const e=encodeURIComponent(r);return de(`${xe}/protected/api-keys/${e}`,"DELETE",void 0,"Failed to delete API key")}async function If(r){if(r.size>Ey)throw new Error(`File size exceeds maximum limit of ${Ey/1024/1024}MB`);const e=await r.arrayBuffer(),t=new Uint8Array(e),n=Sr(t),s={filename:r instanceof File?r.name:"document",content_base64:n};return de(`${xe}/v1/documents/upload`,"POST",s,"Failed to upload document")}async function kf(r){const e={task_id:r};return de(`${xe}/v1/documents/status`,"POST",e,"Failed to check document status")}async function Iy(r,e){const{pollInterval:t=2e3,maxAttempts:n=150,onProgress:i}=e||{},s=await If(r);let o=0;for(;o<n;){const c=await kf(s.task_id);switch(i&&i(c.status,c.progress),c.status){case"success":if(!c.document)throw new Error("Document processing succeeded but no document returned");return c.document;case"failure":throw new Error(c.error||"Document processing failed");case"pending":case"started":await Aw(t),o++;break;default:throw new Error(`Unknown document status: ${c.status}`)}}throw new Error("Document processing timed out")}async function ky(r,e,t,n,i,s){const o=await r.arrayBuffer(),c=new Uint8Array(o),u=Sr(c),h=r instanceof File?r.name:"audio",v=r.type||"audio/mpeg",b={file:u,filename:h,content_type:v,model:e||"whisper-large-v3",...t&&{language:t},...n&&{prompt:n},...i!==void 0&&{temperature:i}};return uy(`${xe}/v1/audio/transcriptions`,"POST",b,"Failed to transcribe audio",s)}async function Cy(r){let e=`${xe}/v1/responses`;const t=[];return(r==null?void 0:r.limit)!==void 0&&t.push(`limit=${r.limit}`),r!=null&&r.after&&t.push(`after=${encodeURIComponent(r.after)}`),r!=null&&r.before&&t.push(`before=${encodeURIComponent(r.before)}`),r!=null&&r.order&&t.push(`order=${encodeURIComponent(r.order)}`),t.length>0&&(e+=`?${t.join("&")}`),de(e,"GET",void 0,"Failed to list responses")}async function By(r){return de(`${xe}/v1/responses/${encodeURIComponent(r)}`,"GET",void 0,"Failed to retrieve response")}async function Ty(r){return de(`${xe}/v1/responses/${encodeURIComponent(r)}/cancel`,"POST",void 0,"Failed to cancel response")}async function Oy(){return de(`${xe}/v1/conversations`,"DELETE",void 0,"Failed to delete conversations")}async function Ny(r){return de(`${xe}/v1/conversations/batch-delete`,"POST",{ids:r},"Failed to batch delete conversations")}async function Py(r){let e=`${xe}/v1/conversations`;const t=[];return(r==null?void 0:r.limit)!==void 0&&t.push(`limit=${r.limit}`),r!=null&&r.after&&t.push(`after=${encodeURIComponent(r.after)}`),r!=null&&r.before&&t.push(`before=${encodeURIComponent(r.before)}`),t.length>0&&(e+=`?${t.join("&")}`),de(e,"GET",void 0,"Failed to list conversations")}async function jy(r){return de(`${xe}/v1/responses`,"POST",r,"Failed to create response")}async function Ry(r){return de(`${xe}/v1/responses/${encodeURIComponent(r)}`,"DELETE",void 0,"Failed to delete response")}async function Dy(r){return de(`${xe}/v1/instructions`,"POST",r,"Failed to create instruction")}async function Uy(r){let e=`${xe}/v1/instructions`;const t=[];return(r==null?void 0:r.limit)!==void 0&&t.push(`limit=${r.limit}`),r!=null&&r.after&&t.push(`after=${encodeURIComponent(r.after)}`),r!=null&&r.before&&t.push(`before=${encodeURIComponent(r.before)}`),r!=null&&r.order&&t.push(`order=${encodeURIComponent(r.order)}`),t.length>0&&(e+=`?${t.join("&")}`),de(e,"GET",void 0,"Failed to list instructions")}async function $y(r){return de(`${xe}/v1/instructions/${encodeURIComponent(r)}`,"GET",void 0,"Failed to retrieve instruction")}async function My(r,e){return de(`${xe}/v1/instructions/${encodeURIComponent(r)}`,"POST",e,"Failed to update instruction")}async function Vy(r){return de(`${xe}/v1/instructions/${encodeURIComponent(r)}`,"DELETE",void 0,"Failed to delete instruction")}async function Ly(r){return de(`${xe}/v1/instructions/${encodeURIComponent(r)}/set-default`,"POST",void 0,"Failed to set default instruction")}function Hy(r){return async(e,t)=>{var i,s;const n=()=>{if(r!=null&&r.apiKey)return`Bearer ${r.apiKey}`;const o=window.localStorage.getItem("access_token");if(!o)throw new Error("No access token or API key available");return`Bearer ${o}`};try{const o=new Headers(t==null?void 0:t.headers);o.set("Authorization",n());const{sessionKey:c,sessionId:u}=await Ii();if(!c||!u)throw new Error("No session key or ID available");o.set("x-session-id",u);const h={...t,headers:o};if(t!=null&&t.body){const F=Mf(c,t.body);h.body=JSON.stringify({encrypted:F}),o.set("Content-Type","application/json")}let v=await fetch(e,h);if(v.status===401&&!(r!=null&&r.apiKey)&&(console.warn("Unauthorized, refreshing access token"),await Tc(),o.set("Authorization",n()),h.headers=o,v=await fetch(e,h)),!v.ok){const F=await v.text();throw console.error("Request failed with response status:",v.status," and message:",F),new Error(`Request failed with status ${v.status}: ${F}`)}if((i=v.headers.get("content-type"))!=null&&i.includes("text/event-stream")){const F=(s=v.body)==null?void 0:s.getReader(),O=new TextDecoder;let m="";const A=new ReadableStream({async start(k){for(;;){const{done:I,value:P}=await F.read();if(I)break;const U=O.decode(P);m+=U;let ge;for(;ge=Sw(m);){m=m.slice(ge.length);const rt=ge.split(`
|
|
125
|
+
\r]`);return e=`^(?:${e})$`,new RegExp(e,"u")},"I-RegExp"),Xe.registerDecoder(kt.REGEXP,r=>{if(v0(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=>[kt.REGEXP,[r.source,r.flags]]),Xe.registerDecoder(64,r=>(xi(r.contents),r.contents),"uint8 Typed Array");function nr(r,e,t){xi(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 zn(r,e,t,n,i){const s=i.forceEndian??y0;if(pc(s?e:t,r,i),zr(n.byteLength,r,ye.BYTE_STRING),y0===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)}}Xe.registerDecoder(65,r=>nr(r,Uint16Array,!1),"uint16, big endian, Typed Array"),Xe.registerDecoder(66,r=>nr(r,Uint32Array,!1),"uint32, big endian, Typed Array"),Xe.registerDecoder(67,r=>nr(r,BigUint64Array,!1),"uint64, big endian, Typed Array"),Xe.registerDecoder(68,r=>(xi(r.contents),new Uint8ClampedArray(r.contents)),"uint8 Typed Array, clamped arithmetic"),Rt(Uint8ClampedArray,r=>[68,new Uint8Array(r.buffer,r.byteOffset,r.byteLength)]),Xe.registerDecoder(69,r=>nr(r,Uint16Array,!0),"uint16, little endian, Typed Array"),Rt(Uint16Array,(r,e,t)=>zn(e,69,65,r,t)),Xe.registerDecoder(70,r=>nr(r,Uint32Array,!0),"uint32, little endian, Typed Array"),Rt(Uint32Array,(r,e,t)=>zn(e,70,66,r,t)),Xe.registerDecoder(71,r=>nr(r,BigUint64Array,!0),"uint64, little endian, Typed Array"),Rt(BigUint64Array,(r,e,t)=>zn(e,71,67,r,t)),Xe.registerDecoder(72,r=>(xi(r.contents),new Int8Array(r.contents)),"sint8 Typed Array"),Rt(Int8Array,r=>[72,new Uint8Array(r.buffer,r.byteOffset,r.byteLength)]),Xe.registerDecoder(73,r=>nr(r,Int16Array,!1),"sint16, big endian, Typed Array"),Xe.registerDecoder(74,r=>nr(r,Int32Array,!1),"sint32, big endian, Typed Array"),Xe.registerDecoder(75,r=>nr(r,BigInt64Array,!1),"sint64, big endian, Typed Array"),Xe.registerDecoder(77,r=>nr(r,Int16Array,!0),"sint16, little endian, Typed Array"),Rt(Int16Array,(r,e,t)=>zn(e,77,73,r,t)),Xe.registerDecoder(78,r=>nr(r,Int32Array,!0),"sint32, little endian, Typed Array"),Rt(Int32Array,(r,e,t)=>zn(e,78,74,r,t)),Xe.registerDecoder(79,r=>nr(r,BigInt64Array,!0),"sint64, little endian, Typed Array"),Rt(BigInt64Array,(r,e,t)=>zn(e,79,75,r,t)),Xe.registerDecoder(81,r=>nr(r,Float32Array,!1),"IEEE 754 binary32, big endian, Typed Array"),Xe.registerDecoder(82,r=>nr(r,Float64Array,!1),"IEEE 754 binary64, big endian, Typed Array"),Xe.registerDecoder(85,r=>nr(r,Float32Array,!0),"IEEE 754 binary32, little endian, Typed Array"),Rt(Float32Array,(r,e,t)=>zn(e,85,81,r,t)),Xe.registerDecoder(86,r=>nr(r,Float64Array,!0),"IEEE 754 binary64, big endian, Typed Array"),Rt(Float64Array,(r,e,t)=>zn(e,86,82,r,t)),Xe.registerDecoder(kt.SET,r=>(v0(r.contents),new Set(r.contents)),"Set"),Rt(Set,r=>[kt.SET,[...r]]),Xe.registerDecoder(kt.JSON,r=>(Gn(r.contents),JSON.parse(r.contents)),"JSON-encoded"),Xe.registerDecoder(kt.SELF_DESCRIBED,r=>r.contents,"Self-Described"),Xe.registerDecoder(kt.INVALID_16,()=>{throw new Error(`Tag always invalid: ${kt.INVALID_16}`)},"Invalid"),Xe.registerDecoder(kt.INVALID_32,()=>{throw new Error(`Tag always invalid: ${kt.INVALID_32}`)},"Invalid"),Xe.registerDecoder(kt.INVALID_64,()=>{throw new Error(`Tag always invalid: ${kt.INVALID_64}`)},"Invalid");function yf(r){throw new Error(`Encoding ${r.constructor.name} intentionally unimplmented. It is not concrete enough to interoperate. Convert to Uint8Array first.`)}Rt(ArrayBuffer,yf),Rt(DataView,yf),typeof SharedArrayBuffer<"u"&&Rt(SharedArrayBuffer,yf);function mc(r){return[NaN,r.valueOf()]}Rt(Boolean,mc),Rt(Number,mc),Rt(String,mc),Rt(BigInt,mc);function wc(r,e={}){const t={...Fn.defaultDecodeOptions};if(e.dcbor?Object.assign(t,Fn.dcborDecodeOptions):e.cde&&Object.assign(t,Fn.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 Ys(r,t);let i,s;for(const o of n){if(s=Fn.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 Fn&&(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 at;(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})(at||(at={}));var gf;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(gf||(gf={}));const ne=at.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 ne.undefined;case"string":return ne.string;case"number":return isNaN(r)?ne.nan:ne.number;case"boolean":return ne.boolean;case"function":return ne.function;case"bigint":return ne.bigint;case"symbol":return ne.symbol;case"object":return Array.isArray(r)?ne.array:r===null?ne.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?ne.promise:typeof Map<"u"&&r instanceof Map?ne.map:typeof Set<"u"&&r instanceof Set?ne.set:typeof Date<"u"&&r instanceof Date?ne.date:ne.object;default:return ne.unknown}},G=at.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"]),Rm=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,at.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 ts=(r,e)=>{let t;switch(r.code){case G.invalid_type:r.received===ne.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case G.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,at.jsonStringifyReplacer)}`;break;case G.unrecognized_keys:t=`Unrecognized key(s) in object: ${at.joinValues(r.keys,", ")}`;break;case G.invalid_union:t="Invalid input";break;case G.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${at.joinValues(r.options)}`;break;case G.invalid_enum_value:t=`Invalid enum value. Expected ${at.joinValues(r.options)}, received '${r.received}'`;break;case G.invalid_arguments:t="Invalid function arguments";break;case G.invalid_return_type:t="Invalid function return type";break;case G.invalid_date:t="Invalid date";break;case G.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}"`:at.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case G.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 G.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 G.custom:t="Invalid input";break;case G.invalid_intersection_types:t="Intersection results could not be merged";break;case G.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case G.not_finite:t="Number must be finite";break;default:t=e.defaultError,at.assertNever(r)}return{message:t}};let A0=ts;function Dm(r){A0=r}function bc(){return A0}const xc=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}},Um=[];function J(r,e){const t=bc(),n=xc({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===ts?void 0:ts].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 Be;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 Be;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 Be=Object.freeze({status:"aborted"}),rs=r=>({status:"dirty",value:r}),hr=r=>({status:"valid",value:r}),vf=r=>r.status==="aborted",mf=r=>r.status==="dirty",Js=r=>r.status==="valid",Xs=r=>typeof Promise<"u"&&r instanceof Promise;function Ac(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 S0(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 Se;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(Se||(Se={}));var Qs,eo;class on{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 _0=(r,e)=>{if(Js(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 Fe(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:v}=r;return o.code==="invalid_enum_value"?{message:v??c.defaultError}:typeof c.data>"u"?{message:(u=v??n)!==null&&u!==void 0?u:c.defaultError}:o.code!=="invalid_type"?{message:c.defaultError}:{message:(h=v??t)!==null&&h!==void 0?h:c.defaultError}},description:i}}class Ye{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(Xs(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 _0(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(Xs(i)?i:Promise.resolve(i));return _0(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:G.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 Zr({schema:this,typeName:ke.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return cn.create(this,this._def)}nullable(){return Yn.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return qr.create(this,this._def)}promise(){return os.create(this,this._def)}or(e){return io.create([this,e],this._def)}and(e){return so.create(this,e,this._def)}transform(e){return new Zr({...Fe(this._def),schema:this,typeName:ke.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new uo({...Fe(this._def),innerType:this,defaultValue:t,typeName:ke.ZodDefault})}brand(){return new xf({typeName:ke.ZodBranded,type:this,...Fe(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new fo({...Fe(this._def),innerType:this,catchValue:t,typeName:ke.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return ho.create(this,e)}readonly(){return po.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const $m=/^c[^\s-]{8,}$/i,Mm=/^[0-9a-z]+$/,Vm=/^[0-9A-HJKMNP-TV-Z]{26}$/,Lm=/^[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,Hm=/^[a-z0-9_-]{21}$/i,Fm=/^[-+]?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)?)??$/,Gm=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,zm="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let wf;const Km=/^(?:(?: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])$/,qm=/^(([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})))$/,Zm=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,E0="((\\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])))",Wm=new RegExp(`^${E0}$`);function I0(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 Ym(r){return new RegExp(`^${I0(r)}$`)}function k0(r){let e=`${E0}T${I0(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 Jm(r,e){return!!((e==="v4"||!e)&&Km.test(r)||(e==="v6"||!e)&&qm.test(r))}class Kr extends Ye{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==ne.string){const s=this._getOrReturnCtx(e);return J(s,{code:G.invalid_type,expected:ne.string,received:s.parsedType}),Be}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),J(i,{code:G.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),J(i,{code:G.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?J(i,{code:G.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):c&&J(i,{code:G.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),n.dirty())}else if(s.kind==="email")Gm.test(e.data)||(i=this._getOrReturnCtx(e,i),J(i,{validation:"email",code:G.invalid_string,message:s.message}),n.dirty());else if(s.kind==="emoji")wf||(wf=new RegExp(zm,"u")),wf.test(e.data)||(i=this._getOrReturnCtx(e,i),J(i,{validation:"emoji",code:G.invalid_string,message:s.message}),n.dirty());else if(s.kind==="uuid")Lm.test(e.data)||(i=this._getOrReturnCtx(e,i),J(i,{validation:"uuid",code:G.invalid_string,message:s.message}),n.dirty());else if(s.kind==="nanoid")Hm.test(e.data)||(i=this._getOrReturnCtx(e,i),J(i,{validation:"nanoid",code:G.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid")$m.test(e.data)||(i=this._getOrReturnCtx(e,i),J(i,{validation:"cuid",code:G.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid2")Mm.test(e.data)||(i=this._getOrReturnCtx(e,i),J(i,{validation:"cuid2",code:G.invalid_string,message:s.message}),n.dirty());else if(s.kind==="ulid")Vm.test(e.data)||(i=this._getOrReturnCtx(e,i),J(i,{validation:"ulid",code:G.invalid_string,message:s.message}),n.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),J(i,{validation:"url",code:G.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),J(i,{validation:"regex",code:G.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),J(i,{code:G.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),J(i,{code:G.invalid_string,validation:{startsWith:s.value},message:s.message}),n.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(i=this._getOrReturnCtx(e,i),J(i,{code:G.invalid_string,validation:{endsWith:s.value},message:s.message}),n.dirty()):s.kind==="datetime"?k0(s).test(e.data)||(i=this._getOrReturnCtx(e,i),J(i,{code:G.invalid_string,validation:"datetime",message:s.message}),n.dirty()):s.kind==="date"?Wm.test(e.data)||(i=this._getOrReturnCtx(e,i),J(i,{code:G.invalid_string,validation:"date",message:s.message}),n.dirty()):s.kind==="time"?Ym(s).test(e.data)||(i=this._getOrReturnCtx(e,i),J(i,{code:G.invalid_string,validation:"time",message:s.message}),n.dirty()):s.kind==="duration"?Fm.test(e.data)||(i=this._getOrReturnCtx(e,i),J(i,{validation:"duration",code:G.invalid_string,message:s.message}),n.dirty()):s.kind==="ip"?Jm(e.data,s.version)||(i=this._getOrReturnCtx(e,i),J(i,{validation:"ip",code:G.invalid_string,message:s.message}),n.dirty()):s.kind==="base64"?Zm.test(e.data)||(i=this._getOrReturnCtx(e,i),J(i,{validation:"base64",code:G.invalid_string,message:s.message}),n.dirty()):at.assertNever(s);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(i=>e.test(i),{validation:t,code:G.invalid_string,...Se.errToObj(n)})}_addCheck(e){return new Kr({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Se.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Se.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Se.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Se.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...Se.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Se.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Se.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Se.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...Se.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Se.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,...Se.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,...Se.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...Se.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...Se.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...Se.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...Se.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...Se.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...Se.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...Se.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...Se.errToObj(t)})}nonempty(e){return this.min(1,Se.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:ke.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...Fe(r)})};function Xm(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 qn extends Ye{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)!==ne.number){const s=this._getOrReturnCtx(e);return J(s,{code:G.invalid_type,expected:ne.number,received:s.parsedType}),Be}let n;const i=new ir;for(const s of this._def.checks)s.kind==="int"?at.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),J(n,{code:G.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),J(n,{code:G.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),J(n,{code:G.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="multipleOf"?Xm(e.data,s.value)!==0&&(n=this._getOrReturnCtx(e,n),J(n,{code:G.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),J(n,{code:G.not_finite,message:s.message}),i.dirty()):at.assertNever(s);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Se.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Se.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Se.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Se.toString(t))}setLimit(e,t,n,i){return new qn({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:Se.toString(i)}]})}_addCheck(e){return new qn({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Se.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Se.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Se.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Se.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Se.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Se.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:Se.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Se.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Se.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"&&at.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)}}qn.create=r=>new qn({checks:[],typeName:ke.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...Fe(r)});class Zn extends Ye{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)!==ne.bigint){const s=this._getOrReturnCtx(e);return J(s,{code:G.invalid_type,expected:ne.bigint,received:s.parsedType}),Be}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),J(n,{code:G.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),J(n,{code:G.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),J(n,{code:G.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):at.assertNever(s);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Se.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Se.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Se.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Se.toString(t))}setLimit(e,t,n,i){return new Zn({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:Se.toString(i)}]})}_addCheck(e){return new Zn({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Se.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Se.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Se.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Se.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Se.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}}Zn.create=r=>{var e;return new Zn({checks:[],typeName:ke.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...Fe(r)})};class to extends Ye{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==ne.boolean){const n=this._getOrReturnCtx(e);return J(n,{code:G.invalid_type,expected:ne.boolean,received:n.parsedType}),Be}return hr(e.data)}}to.create=r=>new to({typeName:ke.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...Fe(r)});class Ai extends Ye{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==ne.date){const s=this._getOrReturnCtx(e);return J(s,{code:G.invalid_type,expected:ne.date,received:s.parsedType}),Be}if(isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return J(s,{code:G.invalid_date}),Be}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),J(i,{code:G.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),J(i,{code:G.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),n.dirty()):at.assertNever(s);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Ai({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:Se.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:Se.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}}Ai.create=r=>new Ai({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:ke.ZodDate,...Fe(r)});class Sc extends Ye{_parse(e){if(this._getType(e)!==ne.symbol){const n=this._getOrReturnCtx(e);return J(n,{code:G.invalid_type,expected:ne.symbol,received:n.parsedType}),Be}return hr(e.data)}}Sc.create=r=>new Sc({typeName:ke.ZodSymbol,...Fe(r)});class ro extends Ye{_parse(e){if(this._getType(e)!==ne.undefined){const n=this._getOrReturnCtx(e);return J(n,{code:G.invalid_type,expected:ne.undefined,received:n.parsedType}),Be}return hr(e.data)}}ro.create=r=>new ro({typeName:ke.ZodUndefined,...Fe(r)});class no extends Ye{_parse(e){if(this._getType(e)!==ne.null){const n=this._getOrReturnCtx(e);return J(n,{code:G.invalid_type,expected:ne.null,received:n.parsedType}),Be}return hr(e.data)}}no.create=r=>new no({typeName:ke.ZodNull,...Fe(r)});class ns extends Ye{constructor(){super(...arguments),this._any=!0}_parse(e){return hr(e.data)}}ns.create=r=>new ns({typeName:ke.ZodAny,...Fe(r)});class Si extends Ye{constructor(){super(...arguments),this._unknown=!0}_parse(e){return hr(e.data)}}Si.create=r=>new Si({typeName:ke.ZodUnknown,...Fe(r)});class Cn extends Ye{_parse(e){const t=this._getOrReturnCtx(e);return J(t,{code:G.invalid_type,expected:ne.never,received:t.parsedType}),Be}}Cn.create=r=>new Cn({typeName:ke.ZodNever,...Fe(r)});class _c extends Ye{_parse(e){if(this._getType(e)!==ne.undefined){const n=this._getOrReturnCtx(e);return J(n,{code:G.invalid_type,expected:ne.void,received:n.parsedType}),Be}return hr(e.data)}}_c.create=r=>new _c({typeName:ke.ZodVoid,...Fe(r)});class qr extends Ye{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),i=this._def;if(t.parsedType!==ne.array)return J(t,{code:G.invalid_type,expected:ne.array,received:t.parsedType}),Be;if(i.exactLength!==null){const o=t.data.length>i.exactLength.value,c=t.data.length<i.exactLength.value;(o||c)&&(J(t,{code:o?G.too_big:G.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&&(J(t,{code:G.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&&(J(t,{code:G.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 on(t,o,t.path,c)))).then(o=>ir.mergeArray(n,o));const s=[...t.data].map((o,c)=>i.type._parseSync(new on(t,o,t.path,c)));return ir.mergeArray(n,s)}get element(){return this._def.type}min(e,t){return new qr({...this._def,minLength:{value:e,message:Se.toString(t)}})}max(e,t){return new qr({...this._def,maxLength:{value:e,message:Se.toString(t)}})}length(e,t){return new qr({...this._def,exactLength:{value:e,message:Se.toString(t)}})}nonempty(e){return this.min(1,e)}}qr.create=(r,e)=>new qr({type:r,minLength:null,maxLength:null,exactLength:null,typeName:ke.ZodArray,...Fe(e)});function is(r){if(r instanceof Ot){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=cn.create(is(n))}return new Ot({...r._def,shape:()=>e})}else return r instanceof qr?new qr({...r._def,type:is(r.element)}):r instanceof cn?cn.create(is(r.unwrap())):r instanceof Yn?Yn.create(is(r.unwrap())):r instanceof an?an.create(r.items.map(e=>is(e))):r}class Ot extends Ye{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=at.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==ne.object){const h=this._getOrReturnCtx(e);return J(h,{code:G.invalid_type,expected:ne.object,received:h.parsedType}),Be}const{status:n,ctx:i}=this._processInputParams(e),{shape:s,keys:o}=this._getCached(),c=[];if(!(this._def.catchall instanceof Cn&&this._def.unknownKeys==="strip"))for(const h in i.data)o.includes(h)||c.push(h);const u=[];for(const h of o){const v=s[h],b=i.data[h];u.push({key:{status:"valid",value:h},value:v._parse(new on(i,b,i.path,h)),alwaysSet:h in i.data})}if(this._def.catchall instanceof Cn){const h=this._def.unknownKeys;if(h==="passthrough")for(const v of c)u.push({key:{status:"valid",value:v},value:{status:"valid",value:i.data[v]}});else if(h==="strict")c.length>0&&(J(i,{code:G.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 v of c){const b=i.data[v];u.push({key:{status:"valid",value:v},value:h._parse(new on(i,b,i.path,v)),alwaysSet:v in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const h=[];for(const v of u){const b=await v.key,F=await v.value;h.push({key:b,value:F,alwaysSet:v.alwaysSet})}return h}).then(h=>ir.mergeObjectSync(n,h)):ir.mergeObjectSync(n,u)}get shape(){return this._def.shape()}strict(e){return Se.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=Se.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:ke.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Ot({...this._def,catchall:e})}pick(e){const t={};return at.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 at.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new Ot({...this._def,shape:()=>t})}deepPartial(){return is(this)}partial(e){const t={};return at.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 at.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let s=this.shape[n];for(;s instanceof cn;)s=s._def.innerType;t[n]=s}}),new Ot({...this._def,shape:()=>t})}keyof(){return C0(at.objectKeys(this.shape))}}Ot.create=(r,e)=>new Ot({shape:()=>r,unknownKeys:"strip",catchall:Cn.create(),typeName:ke.ZodObject,...Fe(e)}),Ot.strictCreate=(r,e)=>new Ot({shape:()=>r,unknownKeys:"strict",catchall:Cn.create(),typeName:ke.ZodObject,...Fe(e)}),Ot.lazycreate=(r,e)=>new Ot({shape:r,unknownKeys:"strip",catchall:Cn.create(),typeName:ke.ZodObject,...Fe(e)});class io extends Ye{_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 J(t,{code:G.invalid_union,unionErrors:o}),Be}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},v=u._parseSync({data:t.data,path:t.path,parent:h});if(v.status==="valid")return v;v.status==="dirty"&&!s&&(s={result:v,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 J(t,{code:G.invalid_union,unionErrors:c}),Be}}get options(){return this._def.options}}io.create=(r,e)=>new io({options:r,typeName:ke.ZodUnion,...Fe(e)});const Bn=r=>r instanceof ao?Bn(r.schema):r instanceof Zr?Bn(r.innerType()):r instanceof co?[r.value]:r instanceof Wn?r.options:r instanceof lo?at.objectValues(r.enum):r instanceof uo?Bn(r._def.innerType):r instanceof ro?[void 0]:r instanceof no?[null]:r instanceof cn?[void 0,...Bn(r.unwrap())]:r instanceof Yn?[null,...Bn(r.unwrap())]:r instanceof xf||r instanceof po?Bn(r.unwrap()):r instanceof fo?Bn(r._def.innerType):[];class Ec extends Ye{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==ne.object)return J(t,{code:G.invalid_type,expected:ne.object,received:t.parsedType}),Be;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}):(J(t,{code:G.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),Be)}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=Bn(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 Ec({typeName:ke.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:i,...Fe(n)})}}function bf(r,e){const t=Kn(r),n=Kn(e);if(r===e)return{valid:!0,data:r};if(t===ne.object&&n===ne.object){const i=at.objectKeys(e),s=at.objectKeys(r).filter(c=>i.indexOf(c)!==-1),o={...r,...e};for(const c of s){const u=bf(r[c],e[c]);if(!u.valid)return{valid:!1};o[c]=u.data}return{valid:!0,data:o}}else if(t===ne.array&&n===ne.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=bf(o,c);if(!u.valid)return{valid:!1};i.push(u.data)}return{valid:!0,data:i}}else return t===ne.date&&n===ne.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class so extends Ye{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),i=(s,o)=>{if(vf(s)||vf(o))return Be;const c=bf(s.value,o.value);return c.valid?((mf(s)||mf(o))&&t.dirty(),{status:t.value,value:c.data}):(J(n,{code:G.invalid_intersection_types}),Be)};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}))}}so.create=(r,e,t)=>new so({left:r,right:e,typeName:ke.ZodIntersection,...Fe(t)});class an extends Ye{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==ne.array)return J(n,{code:G.invalid_type,expected:ne.array,received:n.parsedType}),Be;if(n.data.length<this._def.items.length)return J(n,{code:G.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Be;!this._def.rest&&n.data.length>this._def.items.length&&(J(n,{code:G.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 on(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 an({...this._def,rest:e})}}an.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new an({items:r,typeName:ke.ZodTuple,rest:null,...Fe(e)})};class oo extends Ye{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!==ne.object)return J(n,{code:G.invalid_type,expected:ne.object,received:n.parsedType}),Be;const i=[],s=this._def.keyType,o=this._def.valueType;for(const c in n.data)i.push({key:s._parse(new on(n,c,n.path,c)),value:o._parse(new on(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 Ye?new oo({keyType:e,valueType:t,typeName:ke.ZodRecord,...Fe(n)}):new oo({keyType:Kr.create(),valueType:e,typeName:ke.ZodRecord,...Fe(t)})}}class Ic extends Ye{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!==ne.map)return J(n,{code:G.invalid_type,expected:ne.map,received:n.parsedType}),Be;const i=this._def.keyType,s=this._def.valueType,o=[...n.data.entries()].map(([c,u],h)=>({key:i._parse(new on(n,c,n.path,[h,"key"])),value:s._parse(new on(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,v=await u.value;if(h.status==="aborted"||v.status==="aborted")return Be;(h.status==="dirty"||v.status==="dirty")&&t.dirty(),c.set(h.value,v.value)}return{status:t.value,value:c}})}else{const c=new Map;for(const u of o){const h=u.key,v=u.value;if(h.status==="aborted"||v.status==="aborted")return Be;(h.status==="dirty"||v.status==="dirty")&&t.dirty(),c.set(h.value,v.value)}return{status:t.value,value:c}}}}Ic.create=(r,e,t)=>new Ic({valueType:e,keyType:r,typeName:ke.ZodMap,...Fe(t)});class _i extends Ye{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==ne.set)return J(n,{code:G.invalid_type,expected:ne.set,received:n.parsedType}),Be;const i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(J(n,{code:G.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&&(J(n,{code:G.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 v of u){if(v.status==="aborted")return Be;v.status==="dirty"&&t.dirty(),h.add(v.value)}return{status:t.value,value:h}}const c=[...n.data.values()].map((u,h)=>s._parse(new on(n,u,n.path,h)));return n.common.async?Promise.all(c).then(u=>o(u)):o(c)}min(e,t){return new _i({...this._def,minSize:{value:e,message:Se.toString(t)}})}max(e,t){return new _i({...this._def,maxSize:{value:e,message:Se.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}_i.create=(r,e)=>new _i({valueType:r,minSize:null,maxSize:null,typeName:ke.ZodSet,...Fe(e)});class ss extends Ye{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==ne.function)return J(t,{code:G.invalid_type,expected:ne.function,received:t.parsedType}),Be;function n(c,u){return xc({data:c,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,bc(),ts].filter(h=>!!h),issueData:{code:G.invalid_arguments,argumentsError:u}})}function i(c,u){return xc({data:c,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,bc(),ts].filter(h=>!!h),issueData:{code:G.invalid_return_type,returnTypeError:u}})}const s={errorMap:t.common.contextualErrorMap},o=t.data;if(this._def.returns instanceof os){const c=this;return hr(async function(...u){const h=new kr([]),v=await c._def.args.parseAsync(u,s).catch(O=>{throw h.addIssue(n(u,O)),h}),b=await Reflect.apply(o,this,v);return await c._def.returns._def.type.parseAsync(b,s).catch(O=>{throw h.addIssue(i(b,O)),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 v=Reflect.apply(o,this,h.data),b=c._def.returns.safeParse(v,s);if(!b.success)throw new kr([i(v,b.error)]);return b.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new ss({...this._def,args:an.create(e).rest(Si.create())})}returns(e){return new ss({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new ss({args:e||an.create([]).rest(Si.create()),returns:t||Si.create(),typeName:ke.ZodFunction,...Fe(n)})}}class ao extends Ye{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}ao.create=(r,e)=>new ao({getter:r,typeName:ke.ZodLazy,...Fe(e)});class co extends Ye{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return J(t,{received:t.data,code:G.invalid_literal,expected:this._def.value}),Be}return{status:"valid",value:e.data}}get value(){return this._def.value}}co.create=(r,e)=>new co({value:r,typeName:ke.ZodLiteral,...Fe(e)});function C0(r,e){return new Wn({values:r,typeName:ke.ZodEnum,...Fe(e)})}class Wn extends Ye{constructor(){super(...arguments),Qs.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return J(t,{expected:at.joinValues(n),received:t.parsedType,code:G.invalid_type}),Be}if(Ac(this,Qs)||S0(this,Qs,new Set(this._def.values)),!Ac(this,Qs).has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return J(t,{received:t.data,code:G.invalid_enum_value,options:n}),Be}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 Wn.create(e,{...this._def,...t})}exclude(e,t=this._def){return Wn.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}}Qs=new WeakMap,Wn.create=C0;class lo extends Ye{constructor(){super(...arguments),eo.set(this,void 0)}_parse(e){const t=at.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==ne.string&&n.parsedType!==ne.number){const i=at.objectValues(t);return J(n,{expected:at.joinValues(i),received:n.parsedType,code:G.invalid_type}),Be}if(Ac(this,eo)||S0(this,eo,new Set(at.getValidEnumValues(this._def.values))),!Ac(this,eo).has(e.data)){const i=at.objectValues(t);return J(n,{received:n.data,code:G.invalid_enum_value,options:i}),Be}return hr(e.data)}get enum(){return this._def.values}}eo=new WeakMap,lo.create=(r,e)=>new lo({values:r,typeName:ke.ZodNativeEnum,...Fe(e)});class os extends Ye{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==ne.promise&&t.common.async===!1)return J(t,{code:G.invalid_type,expected:ne.promise,received:t.parsedType}),Be;const n=t.parsedType===ne.promise?t.data:Promise.resolve(t.data);return hr(n.then(i=>this._def.type.parseAsync(i,{path:t.path,errorMap:t.common.contextualErrorMap})))}}os.create=(r,e)=>new os({type:r,typeName:ke.ZodPromise,...Fe(e)});class Zr extends Ye{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===ke.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=>{J(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 Be;const u=await this._def.schema._parseAsync({data:c,path:n.path,parent:n});return u.status==="aborted"?Be:u.status==="dirty"||t.value==="dirty"?rs(u.value):u});{if(t.value==="aborted")return Be;const c=this._def.schema._parseSync({data:o,path:n.path,parent:n});return c.status==="aborted"?Be:c.status==="dirty"||t.value==="dirty"?rs(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"?Be:(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"?Be:(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(!Js(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=>Js(o)?Promise.resolve(i.transform(o.value,s)).then(c=>({status:t.value,value:c})):o);at.assertNever(i)}}Zr.create=(r,e,t)=>new Zr({schema:r,typeName:ke.ZodEffects,effect:e,...Fe(t)}),Zr.createWithPreprocess=(r,e,t)=>new Zr({schema:e,effect:{type:"preprocess",transform:r},typeName:ke.ZodEffects,...Fe(t)});class cn extends Ye{_parse(e){return this._getType(e)===ne.undefined?hr(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}cn.create=(r,e)=>new cn({innerType:r,typeName:ke.ZodOptional,...Fe(e)});class Yn extends Ye{_parse(e){return this._getType(e)===ne.null?hr(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Yn.create=(r,e)=>new Yn({innerType:r,typeName:ke.ZodNullable,...Fe(e)});class uo extends Ye{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===ne.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}uo.create=(r,e)=>new uo({innerType:r,typeName:ke.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...Fe(e)});class fo extends Ye{_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 Xs(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}}fo.create=(r,e)=>new fo({innerType:r,typeName:ke.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...Fe(e)});class kc extends Ye{_parse(e){if(this._getType(e)!==ne.nan){const n=this._getOrReturnCtx(e);return J(n,{code:G.invalid_type,expected:ne.nan,received:n.parsedType}),Be}return{status:"valid",value:e.data}}}kc.create=r=>new kc({typeName:ke.ZodNaN,...Fe(r)});const Qm=Symbol("zod_brand");class xf extends Ye{_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 ho extends Ye{_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"?Be:s.status==="dirty"?(t.dirty(),rs(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"?Be: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 ho({in:e,out:t,typeName:ke.ZodPipeline})}}class po extends Ye{_parse(e){const t=this._def.innerType._parse(e),n=i=>(Js(i)&&(i.value=Object.freeze(i.value)),i);return Xs(t)?t.then(i=>n(i)):n(t)}unwrap(){return this._def.innerType}}po.create=(r,e)=>new po({innerType:r,typeName:ke.ZodReadonly,...Fe(e)});function B0(r,e={},t){return r?ns.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})}}):ns.create()}const e1={object:Ot.lazycreate};var ke;(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"})(ke||(ke={}));const t1=(r,e={message:`Input not instance of ${r.name}`})=>B0(t=>t instanceof r,e),T0=Kr.create,O0=qn.create,r1=kc.create,n1=Zn.create,N0=to.create,i1=Ai.create,s1=Sc.create,o1=ro.create,a1=no.create,c1=ns.create,l1=Si.create,u1=Cn.create,f1=_c.create,h1=qr.create,d1=Ot.create,p1=Ot.strictCreate,y1=io.create,g1=Ec.create,v1=so.create,m1=an.create,w1=oo.create,b1=Ic.create,x1=_i.create,A1=ss.create,S1=ao.create,_1=co.create,E1=Wn.create,I1=lo.create,k1=os.create,P0=Zr.create,C1=cn.create,B1=Yn.create,T1=Zr.createWithPreprocess,O1=ho.create;var Nt=Object.freeze({__proto__:null,defaultErrorMap:ts,setErrorMap:Dm,getErrorMap:bc,makeIssue:xc,EMPTY_PATH:Um,addIssueToContext:J,ParseStatus:ir,INVALID:Be,DIRTY:rs,OK:hr,isAborted:vf,isDirty:mf,isValid:Js,isAsync:Xs,get util(){return at},get objectUtil(){return gf},ZodParsedType:ne,getParsedType:Kn,ZodType:Ye,datetimeRegex:k0,ZodString:Kr,ZodNumber:qn,ZodBigInt:Zn,ZodBoolean:to,ZodDate:Ai,ZodSymbol:Sc,ZodUndefined:ro,ZodNull:no,ZodAny:ns,ZodUnknown:Si,ZodNever:Cn,ZodVoid:_c,ZodArray:qr,ZodObject:Ot,ZodUnion:io,ZodDiscriminatedUnion:Ec,ZodIntersection:so,ZodTuple:an,ZodRecord:oo,ZodMap:Ic,ZodSet:_i,ZodFunction:ss,ZodLazy:ao,ZodLiteral:co,ZodEnum:Wn,ZodNativeEnum:lo,ZodPromise:os,ZodEffects:Zr,ZodTransformer:Zr,ZodOptional:cn,ZodNullable:Yn,ZodDefault:uo,ZodCatch:fo,ZodNaN:kc,BRAND:Qm,ZodBranded:xf,ZodPipeline:ho,ZodReadonly:po,custom:B0,Schema:Ye,ZodSchema:Ye,late:e1,get ZodFirstPartyTypeKind(){return ke},coerce:{string:r=>Kr.create({...r,coerce:!0}),number:r=>qn.create({...r,coerce:!0}),boolean:r=>to.create({...r,coerce:!0}),bigint:r=>Zn.create({...r,coerce:!0}),date:r=>Ai.create({...r,coerce:!0})},any:c1,array:h1,bigint:n1,boolean:N0,date:i1,discriminatedUnion:g1,effect:P0,enum:E1,function:A1,instanceof:t1,intersection:v1,lazy:S1,literal:_1,map:b1,nan:r1,nativeEnum:I1,never:u1,null:a1,nullable:B1,number:O0,object:d1,oboolean:()=>N0().optional(),onumber:()=>O0().optional(),optional:C1,ostring:()=>T0().optional(),pipeline:O1,preprocess:T1,promise:k1,record:w1,set:x1,strictObject:p1,string:T0,symbol:s1,transformer:P0,tuple:m1,undefined:o1,union:y1,unknown:l1,void:f1,NEVER:Be,ZodIssueCode:G,quotelessJson:Rm,ZodError:kr});const Cc=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(!Cc||Cc.length===0)throw new Error("AWS root certificate is empty or not loaded correctly");const N1=Nt.object({module_id:Nt.string().min(1),digest:Nt.literal("SHA384"),timestamp:Nt.number().min(1677721600),pcrs:Nt.map(Nt.number(),Nt.instanceof(Uint8Array)),certificate:Nt.instanceof(Uint8Array),cabundle:Nt.array(Nt.instanceof(Uint8Array)),public_key:Nt.nullable(Nt.instanceof(Uint8Array)),user_data:Nt.nullable(Nt.instanceof(Uint8Array)),nonce:Nt.nullable(Nt.instanceof(Uint8Array))}),P1=Nt.object({protected:Nt.instanceof(Uint8Array),payload:Nt.instanceof(Uint8Array),signature:Nt.instanceof(Uint8Array)});async function j1(r){try{if(!r)throw new Error("Attestation document is empty.");const e=ps(r),t=wc(e),n=t[0],i=t[2],s=t[3];return P1.parse({protected:n,payload:i,signature:s})}catch(e){throw console.error("Error parsing document data:",e),new Error("Failed to parse document data.")}}async function R1(r){try{const e=wc(r);return N1.parse(e)}catch(e){throw console.error("Error parsing document payload:",e),new Error("Failed to parse document payload.")}}function D1(r,e){const t=["Signature1",r,new Uint8Array(0),e];return yc(t)}async function U1(r,e){try{console.log("SIGNATURE:"),console.log(Sr(r.signature));const t=D1(r.protected,r.payload),n=await crypto.subtle.digest("SHA-384",t);return console.log("SIGNATURE STRUCTURE DIGEST:"),console.log(Sr(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 Ei(r,e,t){try{const n=await j1(r),i=await R1(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=Sr(i.cabundle[0]);if(u!==Sr(e))throw console.error("Root cert doesn't match first cert"),console.log("First cert base64:",u),console.log("Trusted root cert base64:",Sr(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 wi(i.cabundle[I]);c.push(P)}const h=new wi(i.certificate),b=await new am({certificates:c}).build(h);console.log("Chain items:",b);const O=new Date().getTime();for(let I=0;I<b.length;I++){const P=b[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()>O||P.notAfter.getTime()<O)throw new Error("Certificate is expired.");console.log(`Certificate ${I} is not expired.`)}if(b.length!==i.cabundle.length+1)throw new Error("Certificate chain length does not match length of cabundle.");const m=h.publicKey;console.log("PUBLIC KEY:"),console.log(Sr(new Uint8Array(m.rawData)));const A=await m.export(),k=await U1(n,A);if(console.log("Signature verified:",k),!k)throw new Error("Signature verification failed.");return i}catch(n){throw console.error("Error verifying attestation document:",n),n}}const $1=Nt.object({public_key:Nt.nullable(Nt.instanceof(Uint8Array))});async function M1(r){const e=ps(r),n=wc(e)[2],i=wc(n);return await $1.parse(i)}async function V1(r,e){try{const t=await aw(r,e),n=e||ew();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 M1(t)):await Ei(t,Cc,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 L1(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 j0={exports:{}};const H1=dg(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]),v=t([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),b=t([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),F=t([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),O=t([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function m(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 k(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,R=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,be=a[4]&255|(a[5]&255)<<8|(a[6]&255)<<16|(a[7]&255)<<24,X=p[0]&255|(p[1]&255)<<8|(p[2]&255)<<16|(p[3]&255)<<24,dt=p[4]&255|(p[5]&255)<<8|(p[6]&255)<<16|(p[7]&255)<<24,oe=p[8]&255|(p[9]&255)<<8|(p[10]&255)<<16|(p[11]&255)<<24,Oe=p[12]&255|(p[13]&255)<<8|(p[14]&255)<<16|(p[15]&255)<<24,Pe=a[8]&255|(a[9]&255)<<8|(a[10]&255)<<16|(a[11]&255)<<24,ze=d[16]&255|(d[17]&255)<<8|(d[18]&255)<<16|(d[19]&255)<<24,Le=d[20]&255|(d[21]&255)<<8|(d[22]&255)<<16|(d[23]&255)<<24,je=d[24]&255|(d[25]&255)<<8|(d[26]&255)<<16|(d[27]&255)<<24,Ue=d[28]&255|(d[29]&255)<<8|(d[30]&255)<<16|(d[31]&255)<<24,Re=a[12]&255|(a[13]&255)<<8|(a[14]&255)<<16|(a[15]&255)<<24,he=g,Ee=S,te=E,pe=R,we=z,Y=be,B=X,T=dt,V=oe,j=Oe,D=Pe,L=ze,Ie=Le,Ke=je,We=Ue,qe=Re,w,et=0;et<20;et+=2)w=he+Ie|0,we^=w<<7|w>>>25,w=we+he|0,V^=w<<9|w>>>23,w=V+we|0,Ie^=w<<13|w>>>19,w=Ie+V|0,he^=w<<18|w>>>14,w=Y+Ee|0,j^=w<<7|w>>>25,w=j+Y|0,Ke^=w<<9|w>>>23,w=Ke+j|0,Ee^=w<<13|w>>>19,w=Ee+Ke|0,Y^=w<<18|w>>>14,w=D+B|0,We^=w<<7|w>>>25,w=We+D|0,te^=w<<9|w>>>23,w=te+We|0,B^=w<<13|w>>>19,w=B+te|0,D^=w<<18|w>>>14,w=qe+L|0,pe^=w<<7|w>>>25,w=pe+qe|0,T^=w<<9|w>>>23,w=T+pe|0,L^=w<<13|w>>>19,w=L+T|0,qe^=w<<18|w>>>14,w=he+pe|0,Ee^=w<<7|w>>>25,w=Ee+he|0,te^=w<<9|w>>>23,w=te+Ee|0,pe^=w<<13|w>>>19,w=pe+te|0,he^=w<<18|w>>>14,w=Y+we|0,B^=w<<7|w>>>25,w=B+Y|0,T^=w<<9|w>>>23,w=T+B|0,we^=w<<13|w>>>19,w=we+T|0,Y^=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=qe+We|0,Ie^=w<<7|w>>>25,w=Ie+qe|0,Ke^=w<<9|w>>>23,w=Ke+Ie|0,We^=w<<13|w>>>19,w=We+Ke|0,qe^=w<<18|w>>>14;he=he+g|0,Ee=Ee+S|0,te=te+E|0,pe=pe+R|0,we=we+z|0,Y=Y+be|0,B=B+X|0,T=T+dt|0,V=V+oe|0,j=j+Oe|0,D=D+Pe|0,L=L+ze|0,Ie=Ie+Le|0,Ke=Ke+je|0,We=We+Ue|0,qe=qe+Re|0,l[0]=he>>>0&255,l[1]=he>>>8&255,l[2]=he>>>16&255,l[3]=he>>>24&255,l[4]=Ee>>>0&255,l[5]=Ee>>>8&255,l[6]=Ee>>>16&255,l[7]=Ee>>>24&255,l[8]=te>>>0&255,l[9]=te>>>8&255,l[10]=te>>>16&255,l[11]=te>>>24&255,l[12]=pe>>>0&255,l[13]=pe>>>8&255,l[14]=pe>>>16&255,l[15]=pe>>>24&255,l[16]=we>>>0&255,l[17]=we>>>8&255,l[18]=we>>>16&255,l[19]=we>>>24&255,l[20]=Y>>>0&255,l[21]=Y>>>8&255,l[22]=Y>>>16&255,l[23]=Y>>>24&255,l[24]=B>>>0&255,l[25]=B>>>8&255,l[26]=B>>>16&255,l[27]=B>>>24&255,l[28]=T>>>0&255,l[29]=T>>>8&255,l[30]=T>>>16&255,l[31]=T>>>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]=Ie>>>0&255,l[49]=Ie>>>8&255,l[50]=Ie>>>16&255,l[51]=Ie>>>24&255,l[52]=Ke>>>0&255,l[53]=Ke>>>8&255,l[54]=Ke>>>16&255,l[55]=Ke>>>24&255,l[56]=We>>>0&255,l[57]=We>>>8&255,l[58]=We>>>16&255,l[59]=We>>>24&255,l[60]=qe>>>0&255,l[61]=qe>>>8&255,l[62]=qe>>>16&255,l[63]=qe>>>24&255}function U(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,R=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,be=a[4]&255|(a[5]&255)<<8|(a[6]&255)<<16|(a[7]&255)<<24,X=p[0]&255|(p[1]&255)<<8|(p[2]&255)<<16|(p[3]&255)<<24,dt=p[4]&255|(p[5]&255)<<8|(p[6]&255)<<16|(p[7]&255)<<24,oe=p[8]&255|(p[9]&255)<<8|(p[10]&255)<<16|(p[11]&255)<<24,Oe=p[12]&255|(p[13]&255)<<8|(p[14]&255)<<16|(p[15]&255)<<24,Pe=a[8]&255|(a[9]&255)<<8|(a[10]&255)<<16|(a[11]&255)<<24,ze=d[16]&255|(d[17]&255)<<8|(d[18]&255)<<16|(d[19]&255)<<24,Le=d[20]&255|(d[21]&255)<<8|(d[22]&255)<<16|(d[23]&255)<<24,je=d[24]&255|(d[25]&255)<<8|(d[26]&255)<<16|(d[27]&255)<<24,Ue=d[28]&255|(d[29]&255)<<8|(d[30]&255)<<16|(d[31]&255)<<24,Re=a[12]&255|(a[13]&255)<<8|(a[14]&255)<<16|(a[15]&255)<<24,he=g,Ee=S,te=E,pe=R,we=z,Y=be,B=X,T=dt,V=oe,j=Oe,D=Pe,L=ze,Ie=Le,Ke=je,We=Ue,qe=Re,w,et=0;et<20;et+=2)w=he+Ie|0,we^=w<<7|w>>>25,w=we+he|0,V^=w<<9|w>>>23,w=V+we|0,Ie^=w<<13|w>>>19,w=Ie+V|0,he^=w<<18|w>>>14,w=Y+Ee|0,j^=w<<7|w>>>25,w=j+Y|0,Ke^=w<<9|w>>>23,w=Ke+j|0,Ee^=w<<13|w>>>19,w=Ee+Ke|0,Y^=w<<18|w>>>14,w=D+B|0,We^=w<<7|w>>>25,w=We+D|0,te^=w<<9|w>>>23,w=te+We|0,B^=w<<13|w>>>19,w=B+te|0,D^=w<<18|w>>>14,w=qe+L|0,pe^=w<<7|w>>>25,w=pe+qe|0,T^=w<<9|w>>>23,w=T+pe|0,L^=w<<13|w>>>19,w=L+T|0,qe^=w<<18|w>>>14,w=he+pe|0,Ee^=w<<7|w>>>25,w=Ee+he|0,te^=w<<9|w>>>23,w=te+Ee|0,pe^=w<<13|w>>>19,w=pe+te|0,he^=w<<18|w>>>14,w=Y+we|0,B^=w<<7|w>>>25,w=B+Y|0,T^=w<<9|w>>>23,w=T+B|0,we^=w<<13|w>>>19,w=we+T|0,Y^=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=qe+We|0,Ie^=w<<7|w>>>25,w=Ie+qe|0,Ke^=w<<9|w>>>23,w=Ke+Ie|0,We^=w<<13|w>>>19,w=We+Ke|0,qe^=w<<18|w>>>14;l[0]=he>>>0&255,l[1]=he>>>8&255,l[2]=he>>>16&255,l[3]=he>>>24&255,l[4]=Y>>>0&255,l[5]=Y>>>8&255,l[6]=Y>>>16&255,l[7]=Y>>>24&255,l[8]=D>>>0&255,l[9]=D>>>8&255,l[10]=D>>>16&255,l[11]=D>>>24&255,l[12]=qe>>>0&255,l[13]=qe>>>8&255,l[14]=qe>>>16&255,l[15]=qe>>>24&255,l[16]=B>>>0&255,l[17]=B>>>8&255,l[18]=B>>>16&255,l[19]=B>>>24&255,l[20]=T>>>0&255,l[21]=T>>>8&255,l[22]=T>>>16&255,l[23]=T>>>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 ge(l,p,d,a){P(l,p,d,a)}function rt(l,p,d,a){U(l,p,d,a)}var $e=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function Ne(l,p,d,a,g,S,E){var R=new Uint8Array(16),z=new Uint8Array(64),be,X;for(X=0;X<16;X++)R[X]=0;for(X=0;X<8;X++)R[X]=S[X];for(;g>=64;){for(ge(z,R,E,$e),X=0;X<64;X++)l[p+X]=d[a+X]^z[X];for(be=1,X=8;X<16;X++)be=be+(R[X]&255)|0,R[X]=be&255,be>>>=8;g-=64,p+=64,a+=64}if(g>0)for(ge(z,R,E,$e),X=0;X<g;X++)l[p+X]=d[a+X]^z[X];return 0}function Ge(l,p,d,a,g){var S=new Uint8Array(16),E=new Uint8Array(64),R,z;for(z=0;z<16;z++)S[z]=0;for(z=0;z<8;z++)S[z]=a[z];for(;d>=64;){for(ge(E,S,g,$e),z=0;z<64;z++)l[p+z]=E[z];for(R=1,z=8;z<16;z++)R=R+(S[z]&255)|0,S[z]=R&255,R>>>=8;d-=64,p+=64}if(d>0)for(ge(E,S,g,$e),z=0;z<d;z++)l[p+z]=E[z];return 0}function wt(l,p,d,a,g){var S=new Uint8Array(32);rt(S,a,g,$e);for(var E=new Uint8Array(8),R=0;R<8;R++)E[R]=a[R+16];return Ge(l,p,d,E,S)}function vt(l,p,d,a,g,S,E){var R=new Uint8Array(32);rt(R,S,E,$e);for(var z=new Uint8Array(8),be=0;be<8;be++)z[be]=S[be+16];return Ne(l,p,d,a,g,z,R)}var ue=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,R,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,R=l[12]&255|(l[13]&255)<<8,this.r[7]=(E>>>11|R<<5)&8065,z=l[14]&255|(l[15]&255)<<8,this.r[8]=(R>>>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};ue.prototype.blocks=function(l,p,d){for(var a=this.fin?0:2048,g,S,E,R,z,be,X,dt,oe,Oe,Pe,ze,Le,je,Ue,Re,he,Ee,te,pe=this.h[0],we=this.h[1],Y=this.h[2],B=this.h[3],T=this.h[4],V=this.h[5],j=this.h[6],D=this.h[7],L=this.h[8],Ie=this.h[9],Ke=this.r[0],We=this.r[1],qe=this.r[2],w=this.r[3],et=this.r[4],pt=this.r[5],yt=this.r[6],Je=this.r[7],ut=this.r[8],ft=this.r[9];d>=16;)g=l[p+0]&255|(l[p+1]&255)<<8,pe+=g&8191,S=l[p+2]&255|(l[p+3]&255)<<8,we+=(g>>>13|S<<3)&8191,E=l[p+4]&255|(l[p+5]&255)<<8,Y+=(S>>>10|E<<6)&8191,R=l[p+6]&255|(l[p+7]&255)<<8,B+=(E>>>7|R<<9)&8191,z=l[p+8]&255|(l[p+9]&255)<<8,T+=(R>>>4|z<<12)&8191,V+=z>>>1&8191,be=l[p+10]&255|(l[p+11]&255)<<8,j+=(z>>>14|be<<2)&8191,X=l[p+12]&255|(l[p+13]&255)<<8,D+=(be>>>11|X<<5)&8191,dt=l[p+14]&255|(l[p+15]&255)<<8,L+=(X>>>8|dt<<8)&8191,Ie+=dt>>>5|a,oe=0,Oe=oe,Oe+=pe*Ke,Oe+=we*(5*ft),Oe+=Y*(5*ut),Oe+=B*(5*Je),Oe+=T*(5*yt),oe=Oe>>>13,Oe&=8191,Oe+=V*(5*pt),Oe+=j*(5*et),Oe+=D*(5*w),Oe+=L*(5*qe),Oe+=Ie*(5*We),oe+=Oe>>>13,Oe&=8191,Pe=oe,Pe+=pe*We,Pe+=we*Ke,Pe+=Y*(5*ft),Pe+=B*(5*ut),Pe+=T*(5*Je),oe=Pe>>>13,Pe&=8191,Pe+=V*(5*yt),Pe+=j*(5*pt),Pe+=D*(5*et),Pe+=L*(5*w),Pe+=Ie*(5*qe),oe+=Pe>>>13,Pe&=8191,ze=oe,ze+=pe*qe,ze+=we*We,ze+=Y*Ke,ze+=B*(5*ft),ze+=T*(5*ut),oe=ze>>>13,ze&=8191,ze+=V*(5*Je),ze+=j*(5*yt),ze+=D*(5*pt),ze+=L*(5*et),ze+=Ie*(5*w),oe+=ze>>>13,ze&=8191,Le=oe,Le+=pe*w,Le+=we*qe,Le+=Y*We,Le+=B*Ke,Le+=T*(5*ft),oe=Le>>>13,Le&=8191,Le+=V*(5*ut),Le+=j*(5*Je),Le+=D*(5*yt),Le+=L*(5*pt),Le+=Ie*(5*et),oe+=Le>>>13,Le&=8191,je=oe,je+=pe*et,je+=we*w,je+=Y*qe,je+=B*We,je+=T*Ke,oe=je>>>13,je&=8191,je+=V*(5*ft),je+=j*(5*ut),je+=D*(5*Je),je+=L*(5*yt),je+=Ie*(5*pt),oe+=je>>>13,je&=8191,Ue=oe,Ue+=pe*pt,Ue+=we*et,Ue+=Y*w,Ue+=B*qe,Ue+=T*We,oe=Ue>>>13,Ue&=8191,Ue+=V*Ke,Ue+=j*(5*ft),Ue+=D*(5*ut),Ue+=L*(5*Je),Ue+=Ie*(5*yt),oe+=Ue>>>13,Ue&=8191,Re=oe,Re+=pe*yt,Re+=we*pt,Re+=Y*et,Re+=B*w,Re+=T*qe,oe=Re>>>13,Re&=8191,Re+=V*We,Re+=j*Ke,Re+=D*(5*ft),Re+=L*(5*ut),Re+=Ie*(5*Je),oe+=Re>>>13,Re&=8191,he=oe,he+=pe*Je,he+=we*yt,he+=Y*pt,he+=B*et,he+=T*w,oe=he>>>13,he&=8191,he+=V*qe,he+=j*We,he+=D*Ke,he+=L*(5*ft),he+=Ie*(5*ut),oe+=he>>>13,he&=8191,Ee=oe,Ee+=pe*ut,Ee+=we*Je,Ee+=Y*yt,Ee+=B*pt,Ee+=T*et,oe=Ee>>>13,Ee&=8191,Ee+=V*w,Ee+=j*qe,Ee+=D*We,Ee+=L*Ke,Ee+=Ie*(5*ft),oe+=Ee>>>13,Ee&=8191,te=oe,te+=pe*ft,te+=we*ut,te+=Y*Je,te+=B*yt,te+=T*pt,oe=te>>>13,te&=8191,te+=V*et,te+=j*w,te+=D*qe,te+=L*We,te+=Ie*Ke,oe+=te>>>13,te&=8191,oe=(oe<<2)+oe|0,oe=oe+Oe|0,Oe=oe&8191,oe=oe>>>13,Pe+=oe,pe=Oe,we=Pe,Y=ze,B=Le,T=je,V=Ue,j=Re,D=he,L=Ee,Ie=te,p+=16,d-=16;this.h[0]=pe,this.h[1]=we,this.h[2]=Y,this.h[3]=B,this.h[4]=T,this.h[5]=V,this.h[6]=j,this.h[7]=D,this.h[8]=L,this.h[9]=Ie},ue.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},ue.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 fe(l,p,d,a,g,S){var E=new ue(S);return E.update(d,a,g),E.finish(l,p),0}function ve(l,p,d,a,g,S){var E=new Uint8Array(16);return fe(E,0,d,a,g,S),k(l,p,E,0)}function _e(l,p,d,a,g){var S;if(d<32)return-1;for(vt(l,0,p,0,d,a,g),fe(l,16,l,32,d-32,l),S=0;S<16;S++)l[S]=0;return 0}function De(l,p,d,a,g){var S,E=new Uint8Array(32);if(d<32||(wt(E,0,32,a,g),ve(p,16,p,32,d-32,E)!==0))return-1;for(vt(l,0,p,0,d,a,g),S=0;S<32;S++)l[S]=0;return 0}function Qe(l,p){var d;for(d=0;d<16;d++)l[d]=p[d]|0}function se(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 Ce(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 xt(l,p){var d,a,g,S=t(),E=t();for(d=0;d<16;d++)E[d]=p[d];for(se(E),se(E),se(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,Ce(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 xt(d,l),xt(a,p),I(d,0,a,0)}function Lt(l){var p=new Uint8Array(32);return xt(p,l),p[0]&1}function ce(l,p){var d;for(d=0;d<16;d++)l[d]=p[2*d]+(p[2*d+1]<<8);l[15]&=32767}function lt(l,p,d){for(var a=0;a<16;a++)l[a]=p[a]+d[a]}function At(l,p,d){for(var a=0;a<16;a++)l[a]=p[a]-d[a]}function Q(l,p,d){var a,g,S=0,E=0,R=0,z=0,be=0,X=0,dt=0,oe=0,Oe=0,Pe=0,ze=0,Le=0,je=0,Ue=0,Re=0,he=0,Ee=0,te=0,pe=0,we=0,Y=0,B=0,T=0,V=0,j=0,D=0,L=0,Ie=0,Ke=0,We=0,qe=0,w=d[0],et=d[1],pt=d[2],yt=d[3],Je=d[4],ut=d[5],ft=d[6],Ht=d[7],_t=d[8],Dt=d[9],Ut=d[10],$t=d[11],Kt=d[12],sr=d[13],or=d[14],ar=d[15];a=p[0],S+=a*w,E+=a*et,R+=a*pt,z+=a*yt,be+=a*Je,X+=a*ut,dt+=a*ft,oe+=a*Ht,Oe+=a*_t,Pe+=a*Dt,ze+=a*Ut,Le+=a*$t,je+=a*Kt,Ue+=a*sr,Re+=a*or,he+=a*ar,a=p[1],E+=a*w,R+=a*et,z+=a*pt,be+=a*yt,X+=a*Je,dt+=a*ut,oe+=a*ft,Oe+=a*Ht,Pe+=a*_t,ze+=a*Dt,Le+=a*Ut,je+=a*$t,Ue+=a*Kt,Re+=a*sr,he+=a*or,Ee+=a*ar,a=p[2],R+=a*w,z+=a*et,be+=a*pt,X+=a*yt,dt+=a*Je,oe+=a*ut,Oe+=a*ft,Pe+=a*Ht,ze+=a*_t,Le+=a*Dt,je+=a*Ut,Ue+=a*$t,Re+=a*Kt,he+=a*sr,Ee+=a*or,te+=a*ar,a=p[3],z+=a*w,be+=a*et,X+=a*pt,dt+=a*yt,oe+=a*Je,Oe+=a*ut,Pe+=a*ft,ze+=a*Ht,Le+=a*_t,je+=a*Dt,Ue+=a*Ut,Re+=a*$t,he+=a*Kt,Ee+=a*sr,te+=a*or,pe+=a*ar,a=p[4],be+=a*w,X+=a*et,dt+=a*pt,oe+=a*yt,Oe+=a*Je,Pe+=a*ut,ze+=a*ft,Le+=a*Ht,je+=a*_t,Ue+=a*Dt,Re+=a*Ut,he+=a*$t,Ee+=a*Kt,te+=a*sr,pe+=a*or,we+=a*ar,a=p[5],X+=a*w,dt+=a*et,oe+=a*pt,Oe+=a*yt,Pe+=a*Je,ze+=a*ut,Le+=a*ft,je+=a*Ht,Ue+=a*_t,Re+=a*Dt,he+=a*Ut,Ee+=a*$t,te+=a*Kt,pe+=a*sr,we+=a*or,Y+=a*ar,a=p[6],dt+=a*w,oe+=a*et,Oe+=a*pt,Pe+=a*yt,ze+=a*Je,Le+=a*ut,je+=a*ft,Ue+=a*Ht,Re+=a*_t,he+=a*Dt,Ee+=a*Ut,te+=a*$t,pe+=a*Kt,we+=a*sr,Y+=a*or,B+=a*ar,a=p[7],oe+=a*w,Oe+=a*et,Pe+=a*pt,ze+=a*yt,Le+=a*Je,je+=a*ut,Ue+=a*ft,Re+=a*Ht,he+=a*_t,Ee+=a*Dt,te+=a*Ut,pe+=a*$t,we+=a*Kt,Y+=a*sr,B+=a*or,T+=a*ar,a=p[8],Oe+=a*w,Pe+=a*et,ze+=a*pt,Le+=a*yt,je+=a*Je,Ue+=a*ut,Re+=a*ft,he+=a*Ht,Ee+=a*_t,te+=a*Dt,pe+=a*Ut,we+=a*$t,Y+=a*Kt,B+=a*sr,T+=a*or,V+=a*ar,a=p[9],Pe+=a*w,ze+=a*et,Le+=a*pt,je+=a*yt,Ue+=a*Je,Re+=a*ut,he+=a*ft,Ee+=a*Ht,te+=a*_t,pe+=a*Dt,we+=a*Ut,Y+=a*$t,B+=a*Kt,T+=a*sr,V+=a*or,j+=a*ar,a=p[10],ze+=a*w,Le+=a*et,je+=a*pt,Ue+=a*yt,Re+=a*Je,he+=a*ut,Ee+=a*ft,te+=a*Ht,pe+=a*_t,we+=a*Dt,Y+=a*Ut,B+=a*$t,T+=a*Kt,V+=a*sr,j+=a*or,D+=a*ar,a=p[11],Le+=a*w,je+=a*et,Ue+=a*pt,Re+=a*yt,he+=a*Je,Ee+=a*ut,te+=a*ft,pe+=a*Ht,we+=a*_t,Y+=a*Dt,B+=a*Ut,T+=a*$t,V+=a*Kt,j+=a*sr,D+=a*or,L+=a*ar,a=p[12],je+=a*w,Ue+=a*et,Re+=a*pt,he+=a*yt,Ee+=a*Je,te+=a*ut,pe+=a*ft,we+=a*Ht,Y+=a*_t,B+=a*Dt,T+=a*Ut,V+=a*$t,j+=a*Kt,D+=a*sr,L+=a*or,Ie+=a*ar,a=p[13],Ue+=a*w,Re+=a*et,he+=a*pt,Ee+=a*yt,te+=a*Je,pe+=a*ut,we+=a*ft,Y+=a*Ht,B+=a*_t,T+=a*Dt,V+=a*Ut,j+=a*$t,D+=a*Kt,L+=a*sr,Ie+=a*or,Ke+=a*ar,a=p[14],Re+=a*w,he+=a*et,Ee+=a*pt,te+=a*yt,pe+=a*Je,we+=a*ut,Y+=a*ft,B+=a*Ht,T+=a*_t,V+=a*Dt,j+=a*Ut,D+=a*$t,L+=a*Kt,Ie+=a*sr,Ke+=a*or,We+=a*ar,a=p[15],he+=a*w,Ee+=a*et,te+=a*pt,pe+=a*yt,we+=a*Je,Y+=a*ut,B+=a*ft,T+=a*Ht,V+=a*_t,j+=a*Dt,D+=a*Ut,L+=a*$t,Ie+=a*Kt,Ke+=a*sr,We+=a*or,qe+=a*ar,S+=38*Ee,E+=38*te,R+=38*pe,z+=38*we,be+=38*Y,X+=38*B,dt+=38*T,oe+=38*V,Oe+=38*j,Pe+=38*D,ze+=38*L,Le+=38*Ie,je+=38*Ke,Ue+=38*We,Re+=38*qe,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=R+g+65535,g=Math.floor(a/65536),R=a-g*65536,a=z+g+65535,g=Math.floor(a/65536),z=a-g*65536,a=be+g+65535,g=Math.floor(a/65536),be=a-g*65536,a=X+g+65535,g=Math.floor(a/65536),X=a-g*65536,a=dt+g+65535,g=Math.floor(a/65536),dt=a-g*65536,a=oe+g+65535,g=Math.floor(a/65536),oe=a-g*65536,a=Oe+g+65535,g=Math.floor(a/65536),Oe=a-g*65536,a=Pe+g+65535,g=Math.floor(a/65536),Pe=a-g*65536,a=ze+g+65535,g=Math.floor(a/65536),ze=a-g*65536,a=Le+g+65535,g=Math.floor(a/65536),Le=a-g*65536,a=je+g+65535,g=Math.floor(a/65536),je=a-g*65536,a=Ue+g+65535,g=Math.floor(a/65536),Ue=a-g*65536,a=Re+g+65535,g=Math.floor(a/65536),Re=a-g*65536,a=he+g+65535,g=Math.floor(a/65536),he=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=R+g+65535,g=Math.floor(a/65536),R=a-g*65536,a=z+g+65535,g=Math.floor(a/65536),z=a-g*65536,a=be+g+65535,g=Math.floor(a/65536),be=a-g*65536,a=X+g+65535,g=Math.floor(a/65536),X=a-g*65536,a=dt+g+65535,g=Math.floor(a/65536),dt=a-g*65536,a=oe+g+65535,g=Math.floor(a/65536),oe=a-g*65536,a=Oe+g+65535,g=Math.floor(a/65536),Oe=a-g*65536,a=Pe+g+65535,g=Math.floor(a/65536),Pe=a-g*65536,a=ze+g+65535,g=Math.floor(a/65536),ze=a-g*65536,a=Le+g+65535,g=Math.floor(a/65536),Le=a-g*65536,a=je+g+65535,g=Math.floor(a/65536),je=a-g*65536,a=Ue+g+65535,g=Math.floor(a/65536),Ue=a-g*65536,a=Re+g+65535,g=Math.floor(a/65536),Re=a-g*65536,a=he+g+65535,g=Math.floor(a/65536),he=a-g*65536,S+=g-1+37*(g-1),l[0]=S,l[1]=E,l[2]=R,l[3]=z,l[4]=be,l[5]=X,l[6]=dt,l[7]=oe,l[8]=Oe,l[9]=Pe,l[10]=ze,l[11]=Le,l[12]=je,l[13]=Ue,l[14]=Re,l[15]=he}function bt(l,p){Q(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--)bt(d,d),a!==2&&a!==4&&Q(d,d,p);for(a=0;a<16;a++)l[a]=d[a]}function vo(l,p){var d=t(),a;for(a=0;a<16;a++)d[a]=p[a];for(a=250;a>=0;a--)bt(d,d),a!==1&&Q(d,d,p);for(a=0;a<16;a++)l[a]=d[a]}function ls(l,p,d){var a=new Uint8Array(32),g=new Float64Array(80),S,E,R=t(),z=t(),be=t(),X=t(),dt=t(),oe=t();for(E=0;E<31;E++)a[E]=p[E];for(a[31]=p[31]&127|64,a[0]&=248,ce(g,d),E=0;E<16;E++)z[E]=g[E],X[E]=R[E]=be[E]=0;for(R[0]=X[0]=1,E=254;E>=0;--E)S=a[E>>>3]>>>(E&7)&1,Ce(R,z,S),Ce(be,X,S),lt(dt,R,be),At(R,R,be),lt(be,z,X),At(z,z,X),bt(X,dt),bt(oe,R),Q(R,be,R),Q(be,z,dt),lt(dt,R,be),At(R,R,be),bt(z,R),At(be,X,oe),Q(R,be,u),lt(R,R,X),Q(be,be,R),Q(R,X,oe),Q(X,z,g),bt(z,dt),Ce(R,z,S),Ce(be,X,S);for(E=0;E<16;E++)g[E+16]=R[E],g[E+32]=be[E],g[E+48]=z[E],g[E+64]=X[E];var Oe=g.subarray(32),Pe=g.subarray(16);return Ft(Oe,Oe),Q(Pe,Pe,Oe),xt(l,Pe),0}function pr(l,p){return ls(l,p,s)}function mo(l,p){return n(p,32),pr(l,p)}function On(l,p,d){var a=new Uint8Array(32);return ls(a,d,p),rt(l,i,a,$e)}var wo=_e,Tf=De;function bo(l,p,d,a,g,S){var E=new Uint8Array(32);return On(E,g,S),wo(l,p,d,a,E)}function Dc(l,p,d,a,g,S){var E=new Uint8Array(32);return On(E,g,S),Tf(l,p,d,a,E)}var xo=[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 Ao(l,p,d,a){for(var g=new Int32Array(16),S=new Int32Array(16),E,R,z,be,X,dt,oe,Oe,Pe,ze,Le,je,Ue,Re,he,Ee,te,pe,we,Y,B,T,V,j,D,L,Ie=l[0],Ke=l[1],We=l[2],qe=l[3],w=l[4],et=l[5],pt=l[6],yt=l[7],Je=p[0],ut=p[1],ft=p[2],Ht=p[3],_t=p[4],Dt=p[5],Ut=p[6],$t=p[7],Kt=0;a>=128;){for(we=0;we<16;we++)Y=8*we+Kt,g[we]=d[Y+0]<<24|d[Y+1]<<16|d[Y+2]<<8|d[Y+3],S[we]=d[Y+4]<<24|d[Y+5]<<16|d[Y+6]<<8|d[Y+7];for(we=0;we<80;we++)if(E=Ie,R=Ke,z=We,be=qe,X=w,dt=et,oe=pt,Oe=yt,Pe=Je,ze=ut,Le=ft,je=Ht,Ue=_t,Re=Dt,he=Ut,Ee=$t,B=yt,T=$t,V=T&65535,j=T>>>16,D=B&65535,L=B>>>16,B=(w>>>14|_t<<18)^(w>>>18|_t<<14)^(_t>>>9|w<<23),T=(_t>>>14|w<<18)^(_t>>>18|w<<14)^(w>>>9|_t<<23),V+=T&65535,j+=T>>>16,D+=B&65535,L+=B>>>16,B=w&et^~w&pt,T=_t&Dt^~_t&Ut,V+=T&65535,j+=T>>>16,D+=B&65535,L+=B>>>16,B=xo[we*2],T=xo[we*2+1],V+=T&65535,j+=T>>>16,D+=B&65535,L+=B>>>16,B=g[we%16],T=S[we%16],V+=T&65535,j+=T>>>16,D+=B&65535,L+=B>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,te=D&65535|L<<16,pe=V&65535|j<<16,B=te,T=pe,V=T&65535,j=T>>>16,D=B&65535,L=B>>>16,B=(Ie>>>28|Je<<4)^(Je>>>2|Ie<<30)^(Je>>>7|Ie<<25),T=(Je>>>28|Ie<<4)^(Ie>>>2|Je<<30)^(Ie>>>7|Je<<25),V+=T&65535,j+=T>>>16,D+=B&65535,L+=B>>>16,B=Ie&Ke^Ie&We^Ke&We,T=Je&ut^Je&ft^ut&ft,V+=T&65535,j+=T>>>16,D+=B&65535,L+=B>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,Oe=D&65535|L<<16,Ee=V&65535|j<<16,B=be,T=je,V=T&65535,j=T>>>16,D=B&65535,L=B>>>16,B=te,T=pe,V+=T&65535,j+=T>>>16,D+=B&65535,L+=B>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,be=D&65535|L<<16,je=V&65535|j<<16,Ke=E,We=R,qe=z,w=be,et=X,pt=dt,yt=oe,Ie=Oe,ut=Pe,ft=ze,Ht=Le,_t=je,Dt=Ue,Ut=Re,$t=he,Je=Ee,we%16===15)for(Y=0;Y<16;Y++)B=g[Y],T=S[Y],V=T&65535,j=T>>>16,D=B&65535,L=B>>>16,B=g[(Y+9)%16],T=S[(Y+9)%16],V+=T&65535,j+=T>>>16,D+=B&65535,L+=B>>>16,te=g[(Y+1)%16],pe=S[(Y+1)%16],B=(te>>>1|pe<<31)^(te>>>8|pe<<24)^te>>>7,T=(pe>>>1|te<<31)^(pe>>>8|te<<24)^(pe>>>7|te<<25),V+=T&65535,j+=T>>>16,D+=B&65535,L+=B>>>16,te=g[(Y+14)%16],pe=S[(Y+14)%16],B=(te>>>19|pe<<13)^(pe>>>29|te<<3)^te>>>6,T=(pe>>>19|te<<13)^(te>>>29|pe<<3)^(pe>>>6|te<<26),V+=T&65535,j+=T>>>16,D+=B&65535,L+=B>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,g[Y]=D&65535|L<<16,S[Y]=V&65535|j<<16;B=Ie,T=Je,V=T&65535,j=T>>>16,D=B&65535,L=B>>>16,B=l[0],T=p[0],V+=T&65535,j+=T>>>16,D+=B&65535,L+=B>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,l[0]=Ie=D&65535|L<<16,p[0]=Je=V&65535|j<<16,B=Ke,T=ut,V=T&65535,j=T>>>16,D=B&65535,L=B>>>16,B=l[1],T=p[1],V+=T&65535,j+=T>>>16,D+=B&65535,L+=B>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,l[1]=Ke=D&65535|L<<16,p[1]=ut=V&65535|j<<16,B=We,T=ft,V=T&65535,j=T>>>16,D=B&65535,L=B>>>16,B=l[2],T=p[2],V+=T&65535,j+=T>>>16,D+=B&65535,L+=B>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,l[2]=We=D&65535|L<<16,p[2]=ft=V&65535|j<<16,B=qe,T=Ht,V=T&65535,j=T>>>16,D=B&65535,L=B>>>16,B=l[3],T=p[3],V+=T&65535,j+=T>>>16,D+=B&65535,L+=B>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,l[3]=qe=D&65535|L<<16,p[3]=Ht=V&65535|j<<16,B=w,T=_t,V=T&65535,j=T>>>16,D=B&65535,L=B>>>16,B=l[4],T=p[4],V+=T&65535,j+=T>>>16,D+=B&65535,L+=B>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,l[4]=w=D&65535|L<<16,p[4]=_t=V&65535|j<<16,B=et,T=Dt,V=T&65535,j=T>>>16,D=B&65535,L=B>>>16,B=l[5],T=p[5],V+=T&65535,j+=T>>>16,D+=B&65535,L+=B>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,l[5]=et=D&65535|L<<16,p[5]=Dt=V&65535|j<<16,B=pt,T=Ut,V=T&65535,j=T>>>16,D=B&65535,L=B>>>16,B=l[6],T=p[6],V+=T&65535,j+=T>>>16,D+=B&65535,L+=B>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,l[6]=pt=D&65535|L<<16,p[6]=Ut=V&65535|j<<16,B=yt,T=$t,V=T&65535,j=T>>>16,D=B&65535,L=B>>>16,B=l[7],T=p[7],V+=T&65535,j+=T>>>16,D+=B&65535,L+=B>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,l[7]=yt=D&65535|L<<16,p[7]=$t=V&65535|j<<16,Kt+=128,a-=128}return a}function hn(l,p,d){var a=new Int32Array(8),g=new Int32Array(8),S=new Uint8Array(256),E,R=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,Ao(a,g,p,d),d%=128,E=0;E<d;E++)S[E]=p[R-d+E];for(S[d]=128,d=256-128*(d<112?1:0),S[d-9]=0,m(S,d-8,R/536870912|0,R<<3),Ao(a,g,S,d),E=0;E<8;E++)m(l,8*E,a[E],g[E]);return 0}function ki(l,p){var d=t(),a=t(),g=t(),S=t(),E=t(),R=t(),z=t(),be=t(),X=t();At(d,l[1],l[0]),At(X,p[1],p[0]),Q(d,d,X),lt(a,l[0],l[1]),lt(X,p[0],p[1]),Q(a,a,X),Q(g,l[3],p[3]),Q(g,g,v),Q(S,l[2],p[2]),lt(S,S,S),At(E,a,d),At(R,S,g),lt(z,S,g),lt(be,a,d),Q(l[0],E,R),Q(l[1],be,z),Q(l[2],z,R),Q(l[3],E,be)}function us(l,p,d){var a;for(a=0;a<4;a++)Ce(l[a],p[a],d)}function So(l,p){var d=t(),a=t(),g=t();Ft(g,p[2]),Q(d,p[0],g),Q(a,p[1],g),xt(l,a),l[31]^=Lt(d)<<7}function _o(l,p,d){var a,g;for(Qe(l[0],o),Qe(l[1],c),Qe(l[2],c),Qe(l[3],o),g=255;g>=0;--g)a=d[g/8|0]>>(g&7)&1,us(l,p,a),ki(p,l),ki(l,l),us(l,p,a)}function fs(l,p){var d=[t(),t(),t(),t()];Qe(d[0],b),Qe(d[1],F),Qe(d[2],c),Q(d[3],b,F),_o(l,d,p)}function Eo(l,p,d){var a=new Uint8Array(64),g=[t(),t(),t(),t()],S;for(d||n(p,32),hn(a,p,32),a[0]&=248,a[31]&=127,a[31]|=64,fs(g,a),So(l,g),S=0;S<32;S++)p[S+32]=l[S];return 0}var dn=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 Io(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]*dn[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)*dn[g],d=p[g]>>8,p[g]&=255;for(g=0;g<32;g++)p[g]-=d*dn[g];for(a=0;a<32;a++)p[a+1]+=p[a]>>8,l[a]=p[a]&255}function ko(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;Io(l,p)}function Uc(l,p,d,a){var g=new Uint8Array(64),S=new Uint8Array(64),E=new Uint8Array(64),R,z,be=new Float64Array(64),X=[t(),t(),t(),t()];hn(g,a,32),g[0]&=248,g[31]&=127,g[31]|=64;var dt=d+64;for(R=0;R<d;R++)l[64+R]=p[R];for(R=0;R<32;R++)l[32+R]=g[32+R];for(hn(E,l.subarray(32),d+32),ko(E),fs(X,E),So(l,X),R=32;R<64;R++)l[R]=a[R];for(hn(S,l,d+64),ko(S),R=0;R<64;R++)be[R]=0;for(R=0;R<32;R++)be[R]=E[R];for(R=0;R<32;R++)for(z=0;z<32;z++)be[R+z]+=S[R]*g[z];return Io(l.subarray(32),be),dt}function Co(l,p){var d=t(),a=t(),g=t(),S=t(),E=t(),R=t(),z=t();return Qe(l[2],c),ce(l[1],p),bt(g,l[1]),Q(S,g,h),At(g,g,l[2]),lt(S,l[2],S),bt(E,S),bt(R,E),Q(z,R,E),Q(d,z,g),Q(d,d,S),vo(d,d),Q(d,d,g),Q(d,d,S),Q(d,d,S),Q(l[0],d,S),bt(a,l[0]),Q(a,a,S),Vt(a,g)&&Q(l[0],l[0],O),bt(a,l[0]),Q(a,a,S),Vt(a,g)?-1:(Lt(l[0])===p[31]>>7&&At(l[0],o,l[0]),Q(l[3],l[0],l[1]),0)}function _(l,p,d,a){var g,S=new Uint8Array(32),E=new Uint8Array(64),R=[t(),t(),t(),t()],z=[t(),t(),t(),t()];if(d<64||Co(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(hn(E,l,d),ko(E),_o(R,z,E),fs(z,p.subarray(32)),ki(R,z),So(S,R),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 C=32,N=24,K=32,Ae=16,Ct=32,Bt=32,Ve=32,Z=32,ee=32,le=N,me=K,tt=Ae,ot=64,St=32,Zt=64,hs=32,Bo=64;e.lowlevel={crypto_core_hsalsa20:rt,crypto_stream_xor:vt,crypto_stream:wt,crypto_stream_salsa20_xor:Ne,crypto_stream_salsa20:Ge,crypto_onetimeauth:fe,crypto_onetimeauth_verify:ve,crypto_verify_16:k,crypto_verify_32:I,crypto_secretbox:_e,crypto_secretbox_open:De,crypto_scalarmult:ls,crypto_scalarmult_base:pr,crypto_box_beforenm:On,crypto_box_afternm:wo,crypto_box:bo,crypto_box_open:Dc,crypto_box_keypair:mo,crypto_hash:hn,crypto_sign:Uc,crypto_sign_keypair:Eo,crypto_sign_open:_,crypto_secretbox_KEYBYTES:C,crypto_secretbox_NONCEBYTES:N,crypto_secretbox_ZEROBYTES:K,crypto_secretbox_BOXZEROBYTES:Ae,crypto_scalarmult_BYTES:Ct,crypto_scalarmult_SCALARBYTES:Bt,crypto_box_PUBLICKEYBYTES:Ve,crypto_box_SECRETKEYBYTES:Z,crypto_box_BEFORENMBYTES:ee,crypto_box_NONCEBYTES:le,crypto_box_ZEROBYTES:me,crypto_box_BOXZEROBYTES:tt,crypto_sign_BYTES:ot,crypto_sign_PUBLICKEYBYTES:St,crypto_sign_SECRETKEYBYTES:Zt,crypto_sign_SEEDBYTES:hs,crypto_hash_BYTES:Bo,gf:t,D:h,L:dn,pack25519:xt,unpack25519:ce,M:Q,A:lt,S:bt,Z:At,pow2523:vo,add:ki,set25519:Qe,modL:Io,scalarmult:_o,scalarbase:fs};function $c(l,p){if(l.length!==C)throw new Error("bad key size");if(p.length!==N)throw new Error("bad nonce size")}function Mw(l,p){if(l.length!==Ve)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 qy(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),$c(d,p);for(var a=new Uint8Array(K+l.length),g=new Uint8Array(a.length),S=0;S<l.length;S++)a[S+K]=l[S];return _e(g,a,a.length,p,d),g.subarray(Ae)},e.secretbox.open=function(l,p,d){Br(l,p,d),$c(d,p);for(var a=new Uint8Array(Ae+l.length),g=new Uint8Array(a.length),S=0;S<l.length;S++)a[S+Ae]=l[S];return a.length<32||De(g,a,a.length,p,d)!==0?null:g.subarray(K)},e.secretbox.keyLength=C,e.secretbox.nonceLength=N,e.secretbox.overheadLength=Ae,e.scalarMult=function(l,p){if(Br(l,p),l.length!==Bt)throw new Error("bad n size");if(p.length!==Ct)throw new Error("bad p size");var d=new Uint8Array(Ct);return ls(d,l,p),d},e.scalarMult.base=function(l){if(Br(l),l.length!==Bt)throw new Error("bad n size");var p=new Uint8Array(Ct);return pr(p,l),p},e.scalarMult.scalarLength=Bt,e.scalarMult.groupElementLength=Ct,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),Mw(l,p);var d=new Uint8Array(ee);return On(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(Ve),p=new Uint8Array(Z);return mo(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(Ve);return pr(p,l),{publicKey:p,secretKey:new Uint8Array(l)}},e.box.publicKeyLength=Ve,e.box.secretKeyLength=Z,e.box.sharedKeyLength=ee,e.box.nonceLength=le,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(ot+l.length);return Uc(d,l,l.length,p),d},e.sign.open=function(l,p){if(Br(l,p),p.length!==St)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(ot),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!==ot)throw new Error("bad signature size");if(d.length!==St)throw new Error("bad public key size");var a=new Uint8Array(ot+l.length),g=new Uint8Array(ot+l.length),S;for(S=0;S<ot;S++)a[S]=p[S];for(S=0;S<l.length;S++)a[S+ot]=l[S];return _(g,a,a.length,d)>=0},e.sign.keyPair=function(){var l=new Uint8Array(St),p=new Uint8Array(Zt);return Eo(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(St),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!==hs)throw new Error("bad seed size");for(var p=new Uint8Array(St),d=new Uint8Array(Zt),a=0;a<32;a++)d[a]=l[a];return Eo(p,d,!0),{publicKey:p,secretKey:d}},e.sign.publicKeyLength=St,e.sign.secretKeyLength=Zt,e.sign.seedLength=hs,e.sign.signatureLength=ot,e.hash=function(l){Br(l);var p=new Uint8Array(Bo);return hn(p,l,l.length),p},e.hash.hashLength=Bo,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];qy(S)})}else typeof L1<"u"&&(l=H1,l&&l.randomBytes&&e.setPRNG(function(d,a){var g,S=l.randomBytes(a);for(g=0;g<a;g++)d[g]=S[g];qy(S)}))}()})(r.exports?r.exports:self.nacl=self.nacl||{})})(j0);var F1=j0.exports;const R0=hg(F1);function G1(){return R0.box.keyPair()}async function Ii(r,e){const t=sessionStorage.getItem("sessionKey"),n=sessionStorage.getItem("sessionId");console.groupCollapsed("Attestation");try{if(t&&n&&!r){const o=ps(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 V1(i,e);if(s&&s.public_key){console.log("Attestation document verification succeeded");const o=G1();console.log("Generated client key pair");const c=new Uint8Array(s.public_key),{encrypted_session_key:u,session_id:h}=await cw(Sr(o.publicKey),i,e);console.log("Key exchange completed.");const v=R0.scalarMult(o.secretKey,c),b=ps(u),F=12,O=b.slice(0,F),m=b.slice(F),k=new Hc(v).open(O,m);if(k)return console.log("Session key decrypted successfully"),window.sessionStorage.setItem("sessionKey",Sr(k)),window.sessionStorage.setItem("sessionId",h),{sessionKey:k,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 ct="";function z1(r){ct=r}async function K1(r,e){return Pt(`${ct}/platform/login`,"POST",{email:r,password:e},void 0,"Failed to login")}async function q1(r,e,t,n){return Pt(`${ct}/platform/register`,"POST",{email:r,password:e,invite_code:t,name:n},void 0,"Failed to register")}async function Z1(r){return Pt(`${ct}/platform/logout`,"POST",{refresh_token:r},void 0,"Failed to logout")}async function W1(){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 Pt(`${ct}/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 D0(r){return de(`${ct}/platform/orgs`,"POST",{name:r})}async function U0(){return de(`${ct}/platform/orgs`,"GET",void 0)}async function $0(r){return de(`${ct}/platform/orgs/${r}`,"DELETE",void 0)}async function M0(r,e,t){return de(`${ct}/platform/orgs/${r}/projects`,"POST",{name:e,description:t})}async function V0(r){return de(`${ct}/platform/orgs/${r}/projects`,"GET",void 0)}async function L0(r,e){return de(`${ct}/platform/orgs/${r}/projects/${e}`,"GET",void 0)}async function H0(r,e,t){return de(`${ct}/platform/orgs/${r}/projects/${e}`,"PATCH",t)}async function F0(r,e){return de(`${ct}/platform/orgs/${r}/projects/${e}`,"DELETE",void 0)}function Y1(r){const e=/^[A-Za-z0-9+/]*[=]{0,2}$/,t=r.length%4===0,n=e.test(r);return t&&n}async function G0(r,e,t,n){if(!Y1(n))throw new Error("Secret must be base64 encoded. Use @stablelib/base64's encode function to encode your data.");return de(`${ct}/platform/orgs/${r}/projects/${e}/secrets`,"POST",{key_name:t,secret:n})}async function z0(r,e){return de(`${ct}/platform/orgs/${r}/projects/${e}/secrets`,"GET",void 0)}async function K0(r,e,t){return de(`${ct}/platform/orgs/${r}/projects/${e}/secrets/${t}`,"DELETE",void 0)}async function q0(r,e){return de(`${ct}/platform/orgs/${r}/projects/${e}/settings/email`,"GET",void 0)}async function Z0(r,e,t){return de(`${ct}/platform/orgs/${r}/projects/${e}/settings/email`,"PUT",t)}async function W0(r,e){return de(`${ct}/platform/orgs/${r}/projects/${e}/settings/oauth`,"GET",void 0)}async function Y0(r,e,t){return de(`${ct}/platform/orgs/${r}/projects/${e}/settings/oauth`,"PUT",t)}async function J0(r,e,t){if(!e||e.trim()==="")throw new Error("Email is required");return de(`${ct}/platform/orgs/${r}/invites`,"POST",{email:e,role:t})}async function X0(r){return de(`${ct}/platform/orgs/${r}/invites`,"GET",void 0)}async function Q0(r,e){return de(`${ct}/platform/orgs/${r}/invites/${e}`,"GET",void 0)}async function ey(r,e){return de(`${ct}/platform/orgs/${r}/invites/${e}`,"DELETE",void 0)}async function ty(r){return de(`${ct}/platform/orgs/${r}/memberships`,"GET",void 0)}async function ry(r,e,t){return de(`${ct}/platform/orgs/${r}/memberships/${e}`,"PATCH",{role:t})}async function ny(r,e){return de(`${ct}/platform/orgs/${r}/memberships/${e}`,"DELETE",void 0)}async function iy(r){return de(`${ct}/platform/accept_invite/${r}`,"POST",void 0)}async function J1(){return de(`${ct}/platform/me`,"GET",void 0)}async function sy(r){return Pt(`${ct}/platform/verify-email/${r}`,"GET",void 0,void 0,"Failed to verify email")}async function Bc(){return de(`${ct}/platform/request_verification`,"POST",void 0,"Failed to request new verification code")}async function oy(r,e){const t={email:r,hashed_secret:e};return Pt(`${ct}/platform/password-reset/request`,"POST",t,void 0,"Failed to request platform password reset")}async function ay(r,e,t,n){const i={email:r,alphanumeric_code:e,plaintext_secret:t,new_password:n};return Pt(`${ct}/platform/password-reset/confirm`,"POST",i,void 0,"Failed to confirm platform password reset")}async function cy(r,e){const t={current_password:r,new_password:e};return de(`${ct}/platform/change-password`,"POST",t,"Failed to change platform password")}class X1{constructor(){Ze(this,"_appApiUrl","");Ze(this,"_platformApiUrl","")}configure(e,t){this._appApiUrl=e,this._platformApiUrl=t}get platformApiUrl(){return this._platformApiUrl}get appApiUrl(){return this._appApiUrl}isPlatformPath(e){return e.includes("/platform/")}resolveEndpoint(e){const t=this.isPlatformPath(e);return{baseUrl:t?this._platformApiUrl:this._appApiUrl,context:t?"platform":"app"}}buildUrl(e){if(e.startsWith("http"))return e;const t=this.resolveEndpoint(e),n=t.baseUrl.endsWith("/")?t.baseUrl.slice(0,-1):t.baseUrl,i=e.startsWith("/")?e:`/${e}`;return`${n}${i}`}getRefreshFunction(e){return this.isPlatformPath(e)?"platformRefreshToken":"refreshToken"}}const yo=new X1,ly=Object.freeze(Object.defineProperty({__proto__:null,apiConfig:yo},Symbol.toStringTag,{value:"Module"}));async function de(r,e,t,n){const i=async(s=!1)=>{try{if(s){console.log("Refreshing access token");const u=yo.getRefreshFunction(r);console.log(`Using ${u}`),u==="platformRefreshToken"?await W1():await Tc()}const o=window.localStorage.getItem("access_token");if(!o)throw new Error("No access token available");const c=await Af(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 uy(r,e,t,n,i){if(!i)return de(r,e,t,n);const s=await Af(r,e,t,i,n);if(s.error)throw new Error(s.error);if(!s.data)throw new Error(n||`Request to ${r} failed`);return s.data}async function Af(r,e,t,n,i){const o=yo.resolveEndpoint(r).context==="platform"?yo.platformApiUrl:void 0;let{sessionKey:c,sessionId:u}=await Ii(!1,o);const h=async(b,F=!1)=>{if(F||!c||!u){const P=await Ii(!0,o);c=P.sessionKey,u=P.sessionId}if(!c||!u)throw new Error("Failed to make encrypted API call, no attestation available.");const O=t?JSON.stringify(t):void 0,m=O?Mf(c,O):void 0,A={"Content-Type":"application/json","x-session-id":u};b&&(A.Authorization=`Bearer ${b}`);const k=await fetch(r,{method:e,headers:A,body:m?JSON.stringify({encrypted:m}):void 0}),I={status:k.status};if(k.ok)try{const P=await k.json(),U=Fc(c,P.encrypted);I.data=JSON.parse(U)}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 k.json();I.error=P.message||i||`HTTP error! Status: ${k.status}`}catch{I.error=i||`HTTP error! Status: ${k.status}`}return I},v=async(b,F=!1)=>{var O;try{const m=await h(b,F);return(m.status===400||(O=m.error)!=null&&O.includes("Encryption error"))&&!F?(console.log("Encryption error or Bad Request, attempting to renew attestation"),v(b,!0)):m}catch(m){return{status:500,error:m instanceof Error?m.message:"Unknown error occurred"}}};return v(n)}async function Pt(r,e,t,n,i){const s=await Af(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 xe="";function Q1(r){xe=r}function ew(){return xe}async function tw(r,e,t){return Pt(`${xe}/login`,"POST",{email:r,password:e,client_id:t})}async function rw(r,e,t){return Pt(`${xe}/login`,"POST",{id:r,password:e,client_id:t})}async function nw(r,e,t,n,i){return Pt(`${xe}/register`,"POST",{email:r,password:e,inviteCode:t.toLowerCase(),client_id:n,name:i})}async function iw(r,e,t){return Pt(`${xe}/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 Pt(`${xe}/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 sw(){return de(`${xe}/protected/user`,"GET",void 0,"Failed to fetch user")}async function fy(r,e){return de(`${xe}/protected/kv/${r}`,"PUT",e,"Failed to put key-value pair")}async function hy(r){return de(`${xe}/protected/kv/${r}`,"DELETE",void 0,"Failed to delete key-value pair")}async function dy(){return de(`${xe}/protected/kv`,"DELETE",void 0,"Failed to delete all key-value pairs")}async function py(r){try{return await de(`${xe}/protected/kv/${r}`,"GET",void 0,"Failed to get key-value pair")}catch(e){console.error(`Error fetching key "${r}":`,e);return}}async function yy(){return de(`${xe}/protected/kv`,"GET",void 0,"Failed to list key-value pairs")}async function ow(r){const e={refresh_token:r};return Pt(`${xe}/logout`,"POST",e)}async function gy(r){return Pt(`${xe}/verify-email/${r}`,"GET",void 0,void 0,"Failed to verify email")}async function Oc(){return de(`${xe}/protected/request_verification`,"POST",void 0,"Failed to request new verification code")}async function aw(r,e){const n=await fetch(`${e||xe}/attestation/${r}`);if(!n.ok)throw new Error(`Request failed with status ${n.status}`);return(await n.json()).attestation_document}async function cw(r,e,t){const i=await fetch(`${t||xe}/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 lw(r,e,t){const n={email:r,hashed_secret:e,client_id:t};return Pt(`${xe}/password-reset/request`,"POST",n,void 0,"Failed to request password reset")}async function uw(r,e,t,n,i){const s={email:r,alphanumeric_code:e,plaintext_secret:t,new_password:n,client_id:i};return Pt(`${xe}/password-reset/confirm`,"POST",s,void 0,"Failed to confirm password reset")}async function vy(r,e){const t={current_password:r,new_password:e};return de(`${xe}/protected/change_password`,"POST",t,"Failed to change password")}async function fw(r,e){try{return await Pt(`${xe}/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 hw(r,e,t){const n={code:r,state:e,invite_code:t};try{return await Pt(`${xe}/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 dw(r,e){try{return await Pt(`${xe}/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 pw(r,e,t){const n={code:r,state:e,invite_code:t};try{return await Pt(`${xe}/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 yw(r,e){try{return await Pt(`${xe}/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 gw(r,e,t){const n={code:r,state:e,invite_code:t};try{return await Pt(`${xe}/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 vw(r,e,t){const n={...r,client_id:e,...t?{invite_code:t}:{}};try{return await Pt(`${xe}/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 my(r){let e=`${xe}/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("&")}`),de(e,"GET",void 0,"Failed to fetch private key")}async function wy(r){let e=`${xe}/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("&")}`),de(e,"GET",void 0,"Failed to fetch private key bytes")}async function by(r,e,t){const i={message_base64:Sr(r),algorithm:e,...t&&Object.keys(t).length>0&&{key_options:t}};return de(`${xe}/protected/sign_message`,"POST",i,"Failed to sign message")}async function xy(r,e){let t=`${xe}/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)}`),de(t,"GET",void 0,"Failed to fetch public key")}async function mw(r,e,t){const n={email:r,password:e,...t!==void 0&&{name:t}};return de(`${xe}/protected/convert_guest`,"POST",n,"Failed to convert guest account")}async function ww(r){return de(`${xe}/protected/third_party_token`,"POST",r?{audience:r}:{},"Failed to generate third party token")}async function Ay(r,e){const t={data:r,...e&&Object.keys(e).length>0&&{key_options:e}};return de(`${xe}/protected/encrypt`,"POST",t,"Failed to encrypt data")}async function Sy(r,e){const t={encrypted_data:r,...e&&Object.keys(e).length>0&&{key_options:e}};return de(`${xe}/protected/decrypt`,"POST",t,"Failed to decrypt data")}async function bw(r){const e={hashed_secret:r};return de(`${xe}/protected/delete-account/request`,"POST",e,"Failed to request account deletion")}async function xw(r,e){const t={confirmation_code:r,plaintext_secret:e};return de(`${xe}/protected/delete-account/confirm`,"POST",t,"Failed to confirm account deletion")}async function _y(r){try{const e=await uy(`${xe}/v1/models`,"GET",void 0,"Failed to fetch models",r);if(!e||typeof e!="object")throw new Error("Invalid response from models endpoint");if(e.object!=="list"||!Array.isArray(e.data))throw new Error("Models response missing expected 'object' or 'data' fields");return e.data}catch(e){throw console.error("Error fetching models:",e),e}}const Ey=10*1024*1024;function Aw(r){return new Promise(e=>setTimeout(e,r))}async function Sf(r){return de(`${xe}/protected/api-keys`,"POST",{name:r},"Failed to create API key")}async function _f(){const r=await de(`${xe}/protected/api-keys`,"GET",void 0,"Failed to list API keys");return r.keys.sort((e,t)=>new Date(t.created_at).getTime()-new Date(e.created_at).getTime()),r}async function Ef(r){const e=encodeURIComponent(r);return de(`${xe}/protected/api-keys/${e}`,"DELETE",void 0,"Failed to delete API key")}async function If(r){if(r.size>Ey)throw new Error(`File size exceeds maximum limit of ${Ey/1024/1024}MB`);const e=await r.arrayBuffer(),t=new Uint8Array(e),n=Sr(t),s={filename:r instanceof File?r.name:"document",content_base64:n};return de(`${xe}/v1/documents/upload`,"POST",s,"Failed to upload document")}async function kf(r){const e={task_id:r};return de(`${xe}/v1/documents/status`,"POST",e,"Failed to check document status")}async function Iy(r,e){const{pollInterval:t=2e3,maxAttempts:n=150,onProgress:i}=e||{},s=await If(r);let o=0;for(;o<n;){const c=await kf(s.task_id);switch(i&&i(c.status,c.progress),c.status){case"success":if(!c.document)throw new Error("Document processing succeeded but no document returned");return c.document;case"failure":throw new Error(c.error||"Document processing failed");case"pending":case"started":await Aw(t),o++;break;default:throw new Error(`Unknown document status: ${c.status}`)}}throw new Error("Document processing timed out")}async function ky(r,e,t,n,i,s){const o=await r.arrayBuffer(),c=new Uint8Array(o),u=Sr(c),h=r instanceof File?r.name:"audio",v=r.type||"audio/mpeg",b={file:u,filename:h,content_type:v,model:e||"whisper-large-v3",...t&&{language:t},...n&&{prompt:n},...i!==void 0&&{temperature:i}};return uy(`${xe}/v1/audio/transcriptions`,"POST",b,"Failed to transcribe audio",s)}async function Cy(r){let e=`${xe}/v1/responses`;const t=[];return(r==null?void 0:r.limit)!==void 0&&t.push(`limit=${r.limit}`),r!=null&&r.after&&t.push(`after=${encodeURIComponent(r.after)}`),r!=null&&r.before&&t.push(`before=${encodeURIComponent(r.before)}`),r!=null&&r.order&&t.push(`order=${encodeURIComponent(r.order)}`),t.length>0&&(e+=`?${t.join("&")}`),de(e,"GET",void 0,"Failed to list responses")}async function By(r){return de(`${xe}/v1/responses/${encodeURIComponent(r)}`,"GET",void 0,"Failed to retrieve response")}async function Ty(r){return de(`${xe}/v1/responses/${encodeURIComponent(r)}/cancel`,"POST",void 0,"Failed to cancel response")}async function Oy(){return de(`${xe}/v1/conversations`,"DELETE",void 0,"Failed to delete conversations")}async function Ny(r){return de(`${xe}/v1/conversations/batch-delete`,"POST",{ids:r},"Failed to batch delete conversations")}async function Py(r){let e=`${xe}/v1/conversations`;const t=[];return(r==null?void 0:r.limit)!==void 0&&t.push(`limit=${r.limit}`),r!=null&&r.after&&t.push(`after=${encodeURIComponent(r.after)}`),r!=null&&r.before&&t.push(`before=${encodeURIComponent(r.before)}`),t.length>0&&(e+=`?${t.join("&")}`),de(e,"GET",void 0,"Failed to list conversations")}async function jy(r){return de(`${xe}/v1/responses`,"POST",r,"Failed to create response")}async function Ry(r){return de(`${xe}/v1/responses/${encodeURIComponent(r)}`,"DELETE",void 0,"Failed to delete response")}async function Dy(r){return de(`${xe}/v1/instructions`,"POST",r,"Failed to create instruction")}async function Uy(r){let e=`${xe}/v1/instructions`;const t=[];return(r==null?void 0:r.limit)!==void 0&&t.push(`limit=${r.limit}`),r!=null&&r.after&&t.push(`after=${encodeURIComponent(r.after)}`),r!=null&&r.before&&t.push(`before=${encodeURIComponent(r.before)}`),r!=null&&r.order&&t.push(`order=${encodeURIComponent(r.order)}`),t.length>0&&(e+=`?${t.join("&")}`),de(e,"GET",void 0,"Failed to list instructions")}async function $y(r){return de(`${xe}/v1/instructions/${encodeURIComponent(r)}`,"GET",void 0,"Failed to retrieve instruction")}async function My(r,e){return de(`${xe}/v1/instructions/${encodeURIComponent(r)}`,"POST",e,"Failed to update instruction")}async function Vy(r){return de(`${xe}/v1/instructions/${encodeURIComponent(r)}`,"DELETE",void 0,"Failed to delete instruction")}async function Ly(r){return de(`${xe}/v1/instructions/${encodeURIComponent(r)}/set-default`,"POST",void 0,"Failed to set default instruction")}function Hy(r){return async(e,t)=>{var i,s;const n=()=>{if(r!=null&&r.apiKey)return`Bearer ${r.apiKey}`;const o=window.localStorage.getItem("access_token");if(!o)throw new Error("No access token or API key available");return`Bearer ${o}`};try{const o=new Headers(t==null?void 0:t.headers);o.set("Authorization",n());const{sessionKey:c,sessionId:u}=await Ii(!1,r==null?void 0:r.apiUrl);if(!c||!u)throw new Error("No session key or ID available");o.set("x-session-id",u);const h={...t,headers:o};if(t!=null&&t.body){const F=Mf(c,t.body);h.body=JSON.stringify({encrypted:F}),o.set("Content-Type","application/json")}let v=await fetch(e,h);if(v.status===401&&!(r!=null&&r.apiKey)&&(console.warn("Unauthorized, refreshing access token"),await Tc(),o.set("Authorization",n()),h.headers=o,v=await fetch(e,h)),!v.ok){const F=await v.text();throw console.error("Request failed with response status:",v.status," and message:",F),new Error(`Request failed with status ${v.status}: ${F}`)}if((i=v.headers.get("content-type"))!=null&&i.includes("text/event-stream")){const F=(s=v.body)==null?void 0:s.getReader(),O=new TextDecoder;let m="";const A=new ReadableStream({async start(k){for(;;){const{done:I,value:P}=await F.read();if(I)break;const U=O.decode(P);m+=U;let ge;for(;ge=Sw(m);){m=m.slice(ge.length);const rt=ge.split(`
|
|
126
126
|
`);for(const $e of rt)if($e.trim().startsWith("event: "))k.enqueue($e+`
|
|
127
127
|
`);else if($e.trim().startsWith("data: ")){const Ne=$e.slice(6).trim();if(Ne==="[DONE]")k.enqueue(`data: [DONE]
|
|
128
128
|
|
package/package.json
CHANGED
package/LICENSE.md
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
Copyright (c) 2024 OpenSecret
|
|
2
|
-
|
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
-
|
|
5
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
-
|
|
7
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|