@rizom/ops 0.2.0-alpha.690 → 0.2.0-alpha.692
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/brains-ops.js +79 -79
- package/dist/deploy.js +2 -2
- package/dist/index.js +83 -83
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -120,7 +120,7 @@ IFS=',' read -ra HOSTS <<< "$KAMAL_HOSTS"
|
|
|
120
120
|
for host in "\${HOSTS[@]}"; do
|
|
121
121
|
scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null "$BRAIN_FILE" "\${SSH_USER}@\${host}:/opt/brain.yaml"
|
|
122
122
|
done
|
|
123
|
-
`}import{appendFileSync as
|
|
123
|
+
`}import{appendFileSync as dge,readFileSync as TK}from"fs";function Ub(e,t){let r=[],o=new Set,n=t?.skipSections??new Set,i=!1,s=!1,a=!1;for(let c of e.split(/\r?\n/)){let u=c.trim();if(RK.test(u)){i=n.has(u),s=!1,a=!1;continue}if(i)continue;if(u.startsWith("#")){if(u.includes("@required"))s=!0;if(u.includes("@sensitive"))a=!0;continue}let d=u.match(/^([A-Z][A-Z0-9_]*)=/);if(!d?.[1]){s=!1,a=!1;continue}let p=d[1];if(!o.has(p))o.add(p),r.push({key:p,required:s,sensitive:a});s=!1,a=!1}return r}function Mb(e,t){return Ub(TK(e,"utf8"),t)}var RK;var hO=v(()=>{RK=/^# ---- .+ ----$/});import{existsSync as $K,readFileSync as OK}from"fs";import{homedir as CK}from"os";import{isAbsolute as PK,join as qb,resolve as zK}from"path";function Or(e){let t={};for(let r of[qb(e,".env"),qb(e,".env.local")]){if(!$K(r))continue;let o=NK(OK(r,"utf8"));for(let[n,i]of Object.entries(o))t[n]=i}return t}function Bt(e,t,r){return t[e]??r[e]}function Go(e,t){if(e.startsWith("~/"))return qb(process.env.HOME??CK(),e.slice(2));if(PK(e))return e;return zK(t,e)}function NK(e){let t={};for(let r of e.split(/\r?\n/)){let o=r.trim();if(o.length===0||o.startsWith("#"))continue;let n=r.match(/^\s*(?:export\s+)?([A-Z][A-Z0-9_]*)\s*=\s*(.*)\s*$/),i=n?.[1],s=n?.[2];if(!i||s===void 0)continue;t[i]=DK(s)}return t}function DK(e){if(e.length>=2&&e.startsWith("'")&&e.endsWith("'"))return e.slice(1,-1);if(e.length>=2&&e.startsWith('"')&&e.endsWith('"'))return e.slice(1,-1).replace(/\\n/g,`
|
|
124
124
|
`).replace(/\\r/g,"\r").replace(/\\t/g,"\t").replace(/\\"/g,'"').replace(/\\\\/g,"\\");return e}var Fb=()=>{};function bO(e,t,r){if(t===r)return!1;return t.includes(UK[e])}function SO(){return cf}function vO(e){if(e.includes('LABEL ai.rizom.brain.watchdog="true"')&&e.includes("http://127.0.0.1:8080/health/live")&&e.includes('ENTRYPOINT ["/usr/bin/tini", "--"]')&&e.includes("BUN_CHROME_PATH=/usr/bin/chromium-headless-shell")&&e.includes('CMD ["bun", "--no-orphans", "./node_modules/@rizom/brain/dist/brain.js", "start"]')){let i=cf.indexOf("# --- fleet:");return e===cf.slice(0,i)+`# --- fleet: install published brain at pinned version (ops deploy) ---
|
|
125
125
|
FROM runtime AS fleet
|
|
126
126
|
ARG BRAIN_VERSION
|
|
@@ -230,8 +230,8 @@ volumes:
|
|
|
230
230
|
|
|
231
231
|
`)}h.write("payload.value = newResult;"),h.write("return payload;");let _=h.compile();return(A,O)=>_(m,A,O)},i,s=ys,a=!ms.jitless,u=a&&vS.value,d=t.catchall,p;e._zod.parse=(m,h)=>{p??(p=o.value);let b=m.value;if(!s(b))return m.issues.push({expected:"object",code:"invalid_type",input:b,inst:e}),m;if(a&&u&&h?.async===!1&&h.jitless!==!0){if(!i)i=n(t.shape);if(m=i(m,h),!d)return m;return MC([],b,m,h,p,e)}return r(m,h)}});su=Z("$ZodUnion",(e,t)=>{Ne.init(e,t),Ze(e._zod,"optin",()=>t.options.some((o)=>o._zod.optin==="optional")?"optional":void 0),Ze(e._zod,"optout",()=>t.options.some((o)=>o._zod.optout==="optional")?"optional":void 0),Ze(e._zod,"values",()=>{if(t.options.every((o)=>o._zod.values))return new Set(t.options.flatMap((o)=>Array.from(o._zod.values)));return}),Ze(e._zod,"pattern",()=>{if(t.options.every((o)=>o._zod.pattern)){let o=t.options.map((n)=>n._zod.pattern);return new RegExp(`^(${o.map((n)=>Wl(n.source)).join("|")})$`)}return});let r=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(o,n)=>{if(r)return r(o,n);let i=!1,s=[];for(let a of t.options){let c=a._zod.run({value:o.value,issues:[]},n);if(c instanceof Promise)s.push(c),i=!0;else{if(c.issues.length===0)return c;s.push(c)}}if(!i)return IC(s,o,e,n);return Promise.all(s).then((a)=>IC(a,o,e,n))}});fw=Z("$ZodXor",(e,t)=>{su.init(e,t),t.inclusive=!1;let r=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(o,n)=>{if(r)return r(o,n);let i=!1,s=[];for(let a of t.options){let c=a._zod.run({value:o.value,issues:[]},n);if(c instanceof Promise)s.push(c),i=!0;else s.push(c)}if(!i)return AC(s,o,e,n);return Promise.all(s).then((a)=>AC(a,o,e,n))}}),mw=Z("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,su.init(e,t);let r=e._zod.parse;Ze(e._zod,"propValues",()=>{let n={};for(let i of t.options){let s=i._zod.propValues;if(!s||Object.keys(s).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(i)}"`);for(let[a,c]of Object.entries(s)){if(!n[a])n[a]=new Set;for(let u of c)n[a].add(u)}}return n});let o=Oa(()=>{let n=t.options,i=new Map;for(let s of n){let a=s._zod.propValues?.[t.discriminator];if(!a||a.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);for(let c of a){if(i.has(c))throw Error(`Duplicate discriminator value "${String(c)}"`);i.set(c,s)}}return i});e._zod.parse=(n,i)=>{let s=n.value;if(!ys(s))return n.issues.push({code:"invalid_type",expected:"object",input:s,inst:e}),n;let a=o.value.get(s?.[t.discriminator]);if(a)return a._zod.run(n,i);if(t.unionFallback||i.direction==="backward")return r(n,i);return n.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(o.value.keys()),input:s,path:[t.discriminator],inst:e}),n}}),hw=Z("$ZodIntersection",(e,t)=>{Ne.init(e,t),e._zod.parse=(r,o)=>{let n=r.value,i=t.left._zod.run({value:n,issues:[]},o),s=t.right._zod.run({value:n,issues:[]},o);if(i instanceof Promise||s instanceof Promise)return Promise.all([i,s]).then(([c,u])=>TC(r,c,u));return TC(r,i,s)}});Bf=Z("$ZodTuple",(e,t)=>{Ne.init(e,t);let r=t.items;e._zod.parse=(o,n)=>{let i=o.value;if(!Array.isArray(i))return o.issues.push({input:i,inst:e,expected:"tuple",code:"invalid_type"}),o;o.value=[];let s=[],a=RC(r,"optin"),c=RC(r,"optout");if(!t.rest){if(i.length<a)return o.issues.push({code:"too_small",minimum:a,inclusive:!0,input:i,inst:e,origin:"array"}),o;if(i.length>r.length)o.issues.push({code:"too_big",maximum:r.length,inclusive:!0,input:i,inst:e,origin:"array"})}let u=Array(r.length);for(let d=0;d<r.length;d++){let p=r[d]._zod.run({value:i[d],issues:[]},n);if(p instanceof Promise)s.push(p.then((m)=>{u[d]=m}));else u[d]=p}if(t.rest){let d=r.length-1,p=i.slice(r.length);for(let m of p){d++;let h=t.rest._zod.run({value:m,issues:[]},n);if(h instanceof Promise)s.push(h.then((b)=>$C(b,o,d)));else $C(h,o,d)}}if(s.length)return Promise.all(s).then(()=>OC(u,o,r,i,c));return OC(u,o,r,i,c)}});gw=Z("$ZodRecord",(e,t)=>{Ne.init(e,t),e._zod.parse=(r,o)=>{let n=r.value;if(!ti(n))return r.issues.push({expected:"record",code:"invalid_type",input:n,inst:e}),r;let i=[],s=t.keyType._zod.values;if(s){r.value={};let a=new Set;for(let u of s)if(typeof u==="string"||typeof u==="number"||typeof u==="symbol"){a.add(typeof u==="number"?u.toString():u);let d=t.keyType._zod.run({value:u,issues:[]},o);if(d instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(d.issues.length){r.issues.push({code:"invalid_key",origin:"record",issues:d.issues.map((h)=>dr(h,o,gt())),input:u,path:[u],inst:e});continue}let p=d.value,m=t.valueType._zod.run({value:n[u],issues:[]},o);if(m instanceof Promise)i.push(m.then((h)=>{if(h.issues.length)r.issues.push(...wr(u,h.issues));r.value[p]=h.value}));else{if(m.issues.length)r.issues.push(...wr(u,m.issues));r.value[p]=m.value}}let c;for(let u in n)if(!a.has(u))c=c??[],c.push(u);if(c&&c.length>0)r.issues.push({code:"unrecognized_keys",input:n,inst:e,keys:c})}else{r.value={};for(let a of Reflect.ownKeys(n)){if(a==="__proto__")continue;if(!Object.prototype.propertyIsEnumerable.call(n,a))continue;let c=t.keyType._zod.run({value:a,issues:[]},o);if(c instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof a==="string"&&ru.test(a)&&c.issues.length){let p=t.keyType._zod.run({value:Number(a),issues:[]},o);if(p instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(p.issues.length===0)c=p}if(c.issues.length){if(t.mode==="loose")r.value[a]=n[a];else r.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map((p)=>dr(p,o,gt())),input:a,path:[a],inst:e});continue}let d=t.valueType._zod.run({value:n[a],issues:[]},o);if(d instanceof Promise)i.push(d.then((p)=>{if(p.issues.length)r.issues.push(...wr(a,p.issues));r.value[c.value]=p.value}));else{if(d.issues.length)r.issues.push(...wr(a,d.issues));r.value[c.value]=d.value}}}if(i.length)return Promise.all(i).then(()=>r);return r}}),yw=Z("$ZodMap",(e,t)=>{Ne.init(e,t),e._zod.parse=(r,o)=>{let n=r.value;if(!(n instanceof Map))return r.issues.push({expected:"map",code:"invalid_type",input:n,inst:e}),r;let i=[];r.value=new Map;for(let[s,a]of n){let c=t.keyType._zod.run({value:s,issues:[]},o),u=t.valueType._zod.run({value:a,issues:[]},o);if(c instanceof Promise||u instanceof Promise)i.push(Promise.all([c,u]).then(([d,p])=>{CC(d,p,r,s,n,e,o)}));else CC(c,u,r,s,n,e,o)}if(i.length)return Promise.all(i).then(()=>r);return r}});bw=Z("$ZodSet",(e,t)=>{Ne.init(e,t),e._zod.parse=(r,o)=>{let n=r.value;if(!(n instanceof Set))return r.issues.push({input:n,inst:e,expected:"set",code:"invalid_type"}),r;let i=[];r.value=new Set;for(let s of n){let a=t.valueType._zod.run({value:s,issues:[]},o);if(a instanceof Promise)i.push(a.then((c)=>PC(c,r)));else PC(a,r)}if(i.length)return Promise.all(i).then(()=>r);return r}});Sw=Z("$ZodEnum",(e,t)=>{Ne.init(e,t);let r=Vl(t.entries),o=new Set(r);e._zod.values=o,e._zod.pattern=new RegExp(`^(${r.filter((n)=>Gl.has(typeof n)).map((n)=>typeof n==="string"?Fr(n):n.toString()).join("|")})$`),e._zod.parse=(n,i)=>{let s=n.value;if(o.has(s))return n;return n.issues.push({code:"invalid_value",values:r,input:s,inst:e}),n}}),vw=Z("$ZodLiteral",(e,t)=>{if(Ne.init(e,t),t.values.length===0)throw Error("Cannot create literal schema with no valid values");let r=new Set(t.values);e._zod.values=r,e._zod.pattern=new RegExp(`^(${t.values.map((o)=>typeof o==="string"?Fr(o):o?Fr(o.toString()):String(o)).join("|")})$`),e._zod.parse=(o,n)=>{let i=o.value;if(r.has(i))return o;return o.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),o}}),ww=Z("$ZodFile",(e,t)=>{Ne.init(e,t),e._zod.parse=(r,o)=>{let n=r.value;if(n instanceof File)return r;return r.issues.push({expected:"file",code:"invalid_type",input:n,inst:e}),r}}),xw=Z("$ZodTransform",(e,t)=>{Ne.init(e,t),e._zod.optin="optional",e._zod.parse=(r,o)=>{if(o.direction==="backward")throw new hs(e.constructor.name);let n=t.transform(r.value,r);if(o.async)return(n instanceof Promise?n:Promise.resolve(n)).then((s)=>(r.value=s,r.fallback=!0,r));if(n instanceof Promise)throw new Pn;return r.value=n,r.fallback=!0,r}});jf=Z("$ZodOptional",(e,t)=>{Ne.init(e,t),e._zod.optin="optional",e._zod.optout="optional",Ze(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),Ze(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${Wl(r.source)})?$`):void 0}),e._zod.parse=(r,o)=>{if(t.innerType._zod.optin==="optional"){let n=r.value,i=t.innerType._zod.run(r,o);if(i instanceof Promise)return i.then((s)=>zC(s,n));return zC(i,n)}if(r.value===void 0)return r;return t.innerType._zod.run(r,o)}}),_w=Z("$ZodExactOptional",(e,t)=>{jf.init(e,t),Ze(e._zod,"values",()=>t.innerType._zod.values),Ze(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(r,o)=>t.innerType._zod.run(r,o)}),Ew=Z("$ZodNullable",(e,t)=>{Ne.init(e,t),Ze(e._zod,"optin",()=>t.innerType._zod.optin),Ze(e._zod,"optout",()=>t.innerType._zod.optout),Ze(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${Wl(r.source)}|null)$`):void 0}),Ze(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(r,o)=>{if(r.value===null)return r;return t.innerType._zod.run(r,o)}}),kw=Z("$ZodDefault",(e,t)=>{Ne.init(e,t),e._zod.optin="optional",Ze(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,o)=>{if(o.direction==="backward")return t.innerType._zod.run(r,o);if(r.value===void 0)return r.value=t.defaultValue,r;let n=t.innerType._zod.run(r,o);if(n instanceof Promise)return n.then((i)=>NC(i,t));return NC(n,t)}});Iw=Z("$ZodPrefault",(e,t)=>{Ne.init(e,t),e._zod.optin="optional",Ze(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,o)=>{if(o.direction==="backward")return t.innerType._zod.run(r,o);if(r.value===void 0)r.value=t.defaultValue;return t.innerType._zod.run(r,o)}}),Aw=Z("$ZodNonOptional",(e,t)=>{Ne.init(e,t),Ze(e._zod,"values",()=>{let r=t.innerType._zod.values;return r?new Set([...r].filter((o)=>o!==void 0)):void 0}),e._zod.parse=(r,o)=>{let n=t.innerType._zod.run(r,o);if(n instanceof Promise)return n.then((i)=>DC(i,e));return DC(n,e)}});Tw=Z("$ZodSuccess",(e,t)=>{Ne.init(e,t),e._zod.parse=(r,o)=>{if(o.direction==="backward")throw new hs("ZodSuccess");let n=t.innerType._zod.run(r,o);if(n instanceof Promise)return n.then((i)=>(r.value=i.issues.length===0,r));return r.value=n.issues.length===0,r}}),Rw=Z("$ZodCatch",(e,t)=>{Ne.init(e,t),e._zod.optin="optional",Ze(e._zod,"optout",()=>t.innerType._zod.optout),Ze(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,o)=>{if(o.direction==="backward")return t.innerType._zod.run(r,o);let n=t.innerType._zod.run(r,o);if(n instanceof Promise)return n.then((i)=>{if(r.value=i.value,i.issues.length)r.value=t.catchValue({...r,error:{issues:i.issues.map((s)=>dr(s,o,gt()))},input:r.value}),r.issues=[],r.fallback=!0;return r});if(r.value=n.value,n.issues.length)r.value=t.catchValue({...r,error:{issues:n.issues.map((i)=>dr(i,o,gt()))},input:r.value}),r.issues=[],r.fallback=!0;return r}}),$w=Z("$ZodNaN",(e,t)=>{Ne.init(e,t),e._zod.parse=(r,o)=>{if(typeof r.value!=="number"||!Number.isNaN(r.value))return r.issues.push({input:r.value,inst:e,expected:"nan",code:"invalid_type"}),r;return r}}),Zf=Z("$ZodPipe",(e,t)=>{Ne.init(e,t),Ze(e._zod,"values",()=>t.in._zod.values),Ze(e._zod,"optin",()=>t.in._zod.optin),Ze(e._zod,"optout",()=>t.out._zod.optout),Ze(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(r,o)=>{if(o.direction==="backward"){let i=t.out._zod.run(r,o);if(i instanceof Promise)return i.then((s)=>Cf(s,t.in,o));return Cf(i,t.in,o)}let n=t.in._zod.run(r,o);if(n instanceof Promise)return n.then((i)=>Cf(i,t.out,o));return Cf(n,t.out,o)}});au=Z("$ZodCodec",(e,t)=>{Ne.init(e,t),Ze(e._zod,"values",()=>t.in._zod.values),Ze(e._zod,"optin",()=>t.in._zod.optin),Ze(e._zod,"optout",()=>t.out._zod.optout),Ze(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(r,o)=>{if((o.direction||"forward")==="forward"){let i=t.in._zod.run(r,o);if(i instanceof Promise)return i.then((s)=>Pf(s,t,o));return Pf(i,t,o)}else{let i=t.out._zod.run(r,o);if(i instanceof Promise)return i.then((s)=>Pf(s,t,o));return Pf(i,t,o)}}});Ow=Z("$ZodPreprocess",(e,t)=>{Zf.init(e,t)}),Cw=Z("$ZodReadonly",(e,t)=>{Ne.init(e,t),Ze(e._zod,"propValues",()=>t.innerType._zod.propValues),Ze(e._zod,"values",()=>t.innerType._zod.values),Ze(e._zod,"optin",()=>t.innerType?._zod?.optin),Ze(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(r,o)=>{if(o.direction==="backward")return t.innerType._zod.run(r,o);let n=t.innerType._zod.run(r,o);if(n instanceof Promise)return n.then(LC);return LC(n)}});Pw=Z("$ZodTemplateLiteral",(e,t)=>{Ne.init(e,t);let r=[];for(let o of t.parts)if(typeof o==="object"&&o!==null){if(!o._zod.pattern)throw Error(`Invalid template literal part, no pattern found: ${[...o._zod.traits].shift()}`);let n=o._zod.pattern instanceof RegExp?o._zod.pattern.source:o._zod.pattern;if(!n)throw Error(`Invalid template literal part: ${o._zod.traits}`);let i=n.startsWith("^")?1:0,s=n.endsWith("$")?n.length-1:n.length;r.push(n.slice(i,s))}else if(o===null||xS.has(typeof o))r.push(Fr(`${o}`));else throw Error(`Invalid template literal part: ${o}`);e._zod.pattern=new RegExp(`^${r.join("")}$`),e._zod.parse=(o,n)=>{if(typeof o.value!=="string")return o.issues.push({input:o.value,inst:e,expected:"string",code:"invalid_type"}),o;if(e._zod.pattern.lastIndex=0,!e._zod.pattern.test(o.value))return o.issues.push({input:o.value,inst:e,code:"invalid_format",format:t.format??"template_literal",pattern:e._zod.pattern.source}),o;return o}}),zw=Z("$ZodFunction",(e,t)=>(Ne.init(e,t),e._def=t,e._zod.def=t,e.implement=(r)=>{if(typeof r!=="function")throw Error("implement() must be called with a function");return function(...o){let n=e._def.input?gf(e._def.input,o):o,i=Reflect.apply(r,this,n);if(e._def.output)return gf(e._def.output,i);return i}},e.implementAsync=(r)=>{if(typeof r!=="function")throw Error("implementAsync() must be called with a function");return async function(...o){let n=e._def.input?await yf(e._def.input,o):o,i=await Reflect.apply(r,this,n);if(e._def.output)return await yf(e._def.output,i);return i}},e._zod.parse=(r,o)=>{if(typeof r.value!=="function")return r.issues.push({code:"invalid_type",expected:"function",input:r.value,inst:e}),r;if(e._def.output&&e._def.output._zod.def.type==="promise")r.value=e.implementAsync(r.value);else r.value=e.implement(r.value);return r},e.input=(...r)=>{let o=e.constructor;if(Array.isArray(r[0]))return new o({type:"function",input:new Bf({type:"tuple",items:r[0],rest:r[1]}),output:e._def.output});return new o({type:"function",input:r[0],output:e._def.output})},e.output=(r)=>new e.constructor({type:"function",input:e._def.input,output:r}),e)),Nw=Z("$ZodPromise",(e,t)=>{Ne.init(e,t),e._zod.parse=(r,o)=>Promise.resolve(r.value).then((n)=>t.innerType._zod.run({value:n,issues:[]},o))}),Dw=Z("$ZodLazy",(e,t)=>{Ne.init(e,t),Ze(e._zod,"innerType",()=>{let r=t;if(!r._cachedInner)r._cachedInner=t.getter();return r._cachedInner}),Ze(e._zod,"pattern",()=>e._zod.innerType?._zod?.pattern),Ze(e._zod,"propValues",()=>e._zod.innerType?._zod?.propValues),Ze(e._zod,"optin",()=>e._zod.innerType?._zod?.optin??void 0),Ze(e._zod,"optout",()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(r,o)=>e._zod.innerType._zod.run(r,o)}),Lw=Z("$ZodCustom",(e,t)=>{rt.init(e,t),Ne.init(e,t),e._zod.parse=(r,o)=>r,e._zod.check=(r)=>{let o=r.value,n=t.fn(o);if(n instanceof Promise)return n.then((i)=>BC(i,r,o,e));BC(n,r,o,e);return}})});function jw(){return{localeError:mJ()}}var mJ=()=>{let e={string:{unit:"\u062D\u0631\u0641",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"},file:{unit:"\u0628\u0627\u064A\u062A",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"},array:{unit:"\u0639\u0646\u0635\u0631",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"},set:{unit:"\u0639\u0646\u0635\u0631",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"}};function t(n){return e[n]??null}let r={regex:"\u0645\u062F\u062E\u0644",email:"\u0628\u0631\u064A\u062F \u0625\u0644\u0643\u062A\u0631\u0648\u0646\u064A",url:"\u0631\u0627\u0628\u0637",emoji:"\u0625\u064A\u0645\u0648\u062C\u064A",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u062A\u0627\u0631\u064A\u062E \u0648\u0648\u0642\u062A \u0628\u0645\u0639\u064A\u0627\u0631 ISO",date:"\u062A\u0627\u0631\u064A\u062E \u0628\u0645\u0639\u064A\u0627\u0631 ISO",time:"\u0648\u0642\u062A \u0628\u0645\u0639\u064A\u0627\u0631 ISO",duration:"\u0645\u062F\u0629 \u0628\u0645\u0639\u064A\u0627\u0631 ISO",ipv4:"\u0639\u0646\u0648\u0627\u0646 IPv4",ipv6:"\u0639\u0646\u0648\u0627\u0646 IPv6",cidrv4:"\u0645\u062F\u0649 \u0639\u0646\u0627\u0648\u064A\u0646 \u0628\u0635\u064A\u063A\u0629 IPv4",cidrv6:"\u0645\u062F\u0649 \u0639\u0646\u0627\u0648\u064A\u0646 \u0628\u0635\u064A\u063A\u0629 IPv6",base64:"\u0646\u064E\u0635 \u0628\u062A\u0631\u0645\u064A\u0632 base64-encoded",base64url:"\u0646\u064E\u0635 \u0628\u062A\u0631\u0645\u064A\u0632 base64url-encoded",json_string:"\u0646\u064E\u0635 \u0639\u0644\u0649 \u0647\u064A\u0626\u0629 JSON",e164:"\u0631\u0642\u0645 \u0647\u0627\u062A\u0641 \u0628\u0645\u0639\u064A\u0627\u0631 E.164",jwt:"JWT",template_literal:"\u0645\u062F\u062E\u0644"},o={nan:"NaN"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`\u0645\u062F\u062E\u0644\u0627\u062A \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644\u0629: \u064A\u0641\u062A\u0631\u0636 \u0625\u062F\u062E\u0627\u0644 instanceof ${n.expected}\u060C \u0648\u0644\u0643\u0646 \u062A\u0645 \u0625\u062F\u062E\u0627\u0644 ${a}`;return`\u0645\u062F\u062E\u0644\u0627\u062A \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644\u0629: \u064A\u0641\u062A\u0631\u0636 \u0625\u062F\u062E\u0627\u0644 ${i}\u060C \u0648\u0644\u0643\u0646 \u062A\u0645 \u0625\u062F\u062E\u0627\u0644 ${a}`}case"invalid_value":if(n.values.length===1)return`\u0645\u062F\u062E\u0644\u0627\u062A \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644\u0629: \u064A\u0641\u062A\u0631\u0636 \u0625\u062F\u062E\u0627\u0644 ${ce(n.values[0])}`;return`\u0627\u062E\u062A\u064A\u0627\u0631 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062A\u0648\u0642\u0639 \u0627\u0646\u062A\u0642\u0627\u0621 \u0623\u062D\u062F \u0647\u0630\u0647 \u0627\u0644\u062E\u064A\u0627\u0631\u0627\u062A: ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return` \u0623\u0643\u0628\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0623\u0646 \u062A\u0643\u0648\u0646 ${n.origin??"\u0627\u0644\u0642\u064A\u0645\u0629"} ${i} ${n.maximum.toString()} ${s.unit??"\u0639\u0646\u0635\u0631"}`;return`\u0623\u0643\u0628\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0623\u0646 \u062A\u0643\u0648\u0646 ${n.origin??"\u0627\u0644\u0642\u064A\u0645\u0629"} ${i} ${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`\u0623\u0635\u063A\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0644\u0640 ${n.origin} \u0623\u0646 \u064A\u0643\u0648\u0646 ${i} ${n.minimum.toString()} ${s.unit}`;return`\u0623\u0635\u063A\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0644\u0640 ${n.origin} \u0623\u0646 \u064A\u0643\u0648\u0646 ${i} ${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0628\u062F\u0623 \u0628\u0640 "${n.prefix}"`;if(i.format==="ends_with")return`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0646\u062A\u0647\u064A \u0628\u0640 "${i.suffix}"`;if(i.format==="includes")return`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u062A\u0636\u0645\u0651\u064E\u0646 "${i.includes}"`;if(i.format==="regex")return`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0637\u0627\u0628\u0642 \u0627\u0644\u0646\u0645\u0637 ${i.pattern}`;return`${r[i.format]??n.format} \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644`}case"not_multiple_of":return`\u0631\u0642\u0645 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u0645\u0646 \u0645\u0636\u0627\u0639\u0641\u0627\u062A ${n.divisor}`;case"unrecognized_keys":return`\u0645\u0639\u0631\u0641${n.keys.length>1?"\u0627\u062A":""} \u063A\u0631\u064A\u0628${n.keys.length>1?"\u0629":""}: ${Q(n.keys,"\u060C ")}`;case"invalid_key":return`\u0645\u0639\u0631\u0641 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644 \u0641\u064A ${n.origin}`;case"invalid_union":return"\u0645\u062F\u062E\u0644 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644";case"invalid_element":return`\u0645\u062F\u062E\u0644 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644 \u0641\u064A ${n.origin}`;default:return"\u0645\u062F\u062E\u0644 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644"}}};var FC=v(()=>{ke()});function Zw(){return{localeError:hJ()}}var hJ=()=>{let e={string:{unit:"simvol",verb:"olmal\u0131d\u0131r"},file:{unit:"bayt",verb:"olmal\u0131d\u0131r"},array:{unit:"element",verb:"olmal\u0131d\u0131r"},set:{unit:"element",verb:"olmal\u0131d\u0131r"}};function t(n){return e[n]??null}let r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"},o={nan:"NaN"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n instanceof ${n.expected}, daxil olan ${a}`;return`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n ${i}, daxil olan ${a}`}case"invalid_value":if(n.values.length===1)return`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n ${ce(n.values[0])}`;return`Yanl\u0131\u015F se\xE7im: a\u015Fa\u011F\u0131dak\u0131lardan biri olmal\u0131d\u0131r: ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`\xC7ox b\xF6y\xFCk: g\xF6zl\u0259nil\u0259n ${n.origin??"d\u0259y\u0259r"} ${i}${n.maximum.toString()} ${s.unit??"element"}`;return`\xC7ox b\xF6y\xFCk: g\xF6zl\u0259nil\u0259n ${n.origin??"d\u0259y\u0259r"} ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`\xC7ox ki\xE7ik: g\xF6zl\u0259nil\u0259n ${n.origin} ${i}${n.minimum.toString()} ${s.unit}`;return`\xC7ox ki\xE7ik: g\xF6zl\u0259nil\u0259n ${n.origin} ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`Yanl\u0131\u015F m\u0259tn: "${i.prefix}" il\u0259 ba\u015Flamal\u0131d\u0131r`;if(i.format==="ends_with")return`Yanl\u0131\u015F m\u0259tn: "${i.suffix}" il\u0259 bitm\u0259lidir`;if(i.format==="includes")return`Yanl\u0131\u015F m\u0259tn: "${i.includes}" daxil olmal\u0131d\u0131r`;if(i.format==="regex")return`Yanl\u0131\u015F m\u0259tn: ${i.pattern} \u015Fablonuna uy\u011Fun olmal\u0131d\u0131r`;return`Yanl\u0131\u015F ${r[i.format]??n.format}`}case"not_multiple_of":return`Yanl\u0131\u015F \u0259d\u0259d: ${n.divisor} il\u0259 b\xF6l\xFCn\u0259 bil\u0259n olmal\u0131d\u0131r`;case"unrecognized_keys":return`Tan\u0131nmayan a\xE7ar${n.keys.length>1?"lar":""}: ${Q(n.keys,", ")}`;case"invalid_key":return`${n.origin} daxilind\u0259 yanl\u0131\u015F a\xE7ar`;case"invalid_union":return"Yanl\u0131\u015F d\u0259y\u0259r";case"invalid_element":return`${n.origin} daxilind\u0259 yanl\u0131\u015F d\u0259y\u0259r`;default:return"Yanl\u0131\u015F d\u0259y\u0259r"}}};var KC=v(()=>{ke()});function HC(e,t,r,o){let n=Math.abs(e),i=n%10,s=n%100;if(s>=11&&s<=19)return o;if(i===1)return t;if(i>=2&&i<=4)return r;return o}function Uw(){return{localeError:gJ()}}var gJ=()=>{let e={string:{unit:{one:"\u0441\u0456\u043C\u0432\u0430\u043B",few:"\u0441\u0456\u043C\u0432\u0430\u043B\u044B",many:"\u0441\u0456\u043C\u0432\u0430\u043B\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"},array:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u044B",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"},set:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u044B",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"},file:{unit:{one:"\u0431\u0430\u0439\u0442",few:"\u0431\u0430\u0439\u0442\u044B",many:"\u0431\u0430\u0439\u0442\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"}};function t(n){return e[n]??null}let r={regex:"\u0443\u0432\u043E\u0434",email:"email \u0430\u0434\u0440\u0430\u0441",url:"URL",emoji:"\u044D\u043C\u043E\u0434\u0437\u0456",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0434\u0430\u0442\u0430 \u0456 \u0447\u0430\u0441",date:"ISO \u0434\u0430\u0442\u0430",time:"ISO \u0447\u0430\u0441",duration:"ISO \u043F\u0440\u0430\u0446\u044F\u0433\u043B\u0430\u0441\u0446\u044C",ipv4:"IPv4 \u0430\u0434\u0440\u0430\u0441",ipv6:"IPv6 \u0430\u0434\u0440\u0430\u0441",cidrv4:"IPv4 \u0434\u044B\u044F\u043F\u0430\u0437\u043E\u043D",cidrv6:"IPv6 \u0434\u044B\u044F\u043F\u0430\u0437\u043E\u043D",base64:"\u0440\u0430\u0434\u043E\u043A \u0443 \u0444\u0430\u0440\u043C\u0430\u0446\u0435 base64",base64url:"\u0440\u0430\u0434\u043E\u043A \u0443 \u0444\u0430\u0440\u043C\u0430\u0446\u0435 base64url",json_string:"JSON \u0440\u0430\u0434\u043E\u043A",e164:"\u043D\u0443\u043C\u0430\u0440 E.164",jwt:"JWT",template_literal:"\u0443\u0432\u043E\u0434"},o={nan:"NaN",number:"\u043B\u0456\u043A",array:"\u043C\u0430\u0441\u0456\u045E"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434: \u0447\u0430\u043A\u0430\u045E\u0441\u044F instanceof ${n.expected}, \u0430\u0442\u0440\u044B\u043C\u0430\u043D\u0430 ${a}`;return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434: \u0447\u0430\u043A\u0430\u045E\u0441\u044F ${i}, \u0430\u0442\u0440\u044B\u043C\u0430\u043D\u0430 ${a}`}case"invalid_value":if(n.values.length===1)return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F ${ce(n.values[0])}`;return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0432\u0430\u0440\u044B\u044F\u043D\u0442: \u0447\u0430\u043A\u0430\u045E\u0441\u044F \u0430\u0434\u0437\u0456\u043D \u0437 ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s){let a=Number(n.maximum),c=HC(a,s.unit.one,s.unit.few,s.unit.many);return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u0432\u044F\u043B\u0456\u043A\u0456: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${n.origin??"\u0437\u043D\u0430\u0447\u044D\u043D\u043D\u0435"} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 ${s.verb} ${i}${n.maximum.toString()} ${c}`}return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u0432\u044F\u043B\u0456\u043A\u0456: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${n.origin??"\u0437\u043D\u0430\u0447\u044D\u043D\u043D\u0435"} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 \u0431\u044B\u0446\u044C ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s){let a=Number(n.minimum),c=HC(a,s.unit.one,s.unit.few,s.unit.many);return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u043C\u0430\u043B\u044B: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${n.origin} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 ${s.verb} ${i}${n.minimum.toString()} ${c}`}return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u043C\u0430\u043B\u044B: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${n.origin} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 \u0431\u044B\u0446\u044C ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u043F\u0430\u0447\u044B\u043D\u0430\u0446\u0446\u0430 \u0437 "${i.prefix}"`;if(i.format==="ends_with")return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0437\u0430\u043A\u0430\u043D\u0447\u0432\u0430\u0446\u0446\u0430 \u043D\u0430 "${i.suffix}"`;if(i.format==="includes")return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0437\u043C\u044F\u0448\u0447\u0430\u0446\u044C "${i.includes}"`;if(i.format==="regex")return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0430\u0434\u043F\u0430\u0432\u044F\u0434\u0430\u0446\u044C \u0448\u0430\u0431\u043B\u043E\u043D\u0443 ${i.pattern}`;return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B ${r[i.format]??n.format}`}case"not_multiple_of":return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u043B\u0456\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0431\u044B\u0446\u044C \u043A\u0440\u0430\u0442\u043D\u044B\u043C ${n.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u0430\u0441\u043F\u0430\u0437\u043D\u0430\u043D\u044B ${n.keys.length>1?"\u043A\u043B\u044E\u0447\u044B":"\u043A\u043B\u044E\u0447"}: ${Q(n.keys,", ")}`;case"invalid_key":return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u043A\u043B\u044E\u0447 \u0443 ${n.origin}`;case"invalid_union":return"\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434";case"invalid_element":return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u0430\u0435 \u0437\u043D\u0430\u0447\u044D\u043D\u043D\u0435 \u045E ${n.origin}`;default:return"\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434"}}};var JC=v(()=>{ke()});function Mw(){return{localeError:yJ()}}var yJ=()=>{let e={string:{unit:"\u0441\u0438\u043C\u0432\u043E\u043B\u0430",verb:"\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430"},file:{unit:"\u0431\u0430\u0439\u0442\u0430",verb:"\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430"},array:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0430",verb:"\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430"},set:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0430",verb:"\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430"}};function t(n){return e[n]??null}let r={regex:"\u0432\u0445\u043E\u0434",email:"\u0438\u043C\u0435\u0439\u043B \u0430\u0434\u0440\u0435\u0441",url:"URL",emoji:"\u0435\u043C\u043E\u0434\u0436\u0438",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0432\u0440\u0435\u043C\u0435",date:"ISO \u0434\u0430\u0442\u0430",time:"ISO \u0432\u0440\u0435\u043C\u0435",duration:"ISO \u043F\u0440\u043E\u0434\u044A\u043B\u0436\u0438\u0442\u0435\u043B\u043D\u043E\u0441\u0442",ipv4:"IPv4 \u0430\u0434\u0440\u0435\u0441",ipv6:"IPv6 \u0430\u0434\u0440\u0435\u0441",cidrv4:"IPv4 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D",cidrv6:"IPv6 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D",base64:"base64-\u043A\u043E\u0434\u0438\u0440\u0430\u043D \u043D\u0438\u0437",base64url:"base64url-\u043A\u043E\u0434\u0438\u0440\u0430\u043D \u043D\u0438\u0437",json_string:"JSON \u043D\u0438\u0437",e164:"E.164 \u043D\u043E\u043C\u0435\u0440",jwt:"JWT",template_literal:"\u0432\u0445\u043E\u0434"},o={nan:"NaN",number:"\u0447\u0438\u0441\u043B\u043E",array:"\u043C\u0430\u0441\u0438\u0432"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434: \u043E\u0447\u0430\u043A\u0432\u0430\u043D instanceof ${n.expected}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D ${a}`;return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434: \u043E\u0447\u0430\u043A\u0432\u0430\u043D ${i}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D ${a}`}case"invalid_value":if(n.values.length===1)return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434: \u043E\u0447\u0430\u043A\u0432\u0430\u043D ${ce(n.values[0])}`;return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430 \u043E\u043F\u0446\u0438\u044F: \u043E\u0447\u0430\u043A\u0432\u0430\u043D\u043E \u0435\u0434\u043D\u043E \u043E\u0442 ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`\u0422\u0432\u044A\u0440\u0434\u0435 \u0433\u043E\u043B\u044F\u043C\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${n.origin??"\u0441\u0442\u043E\u0439\u043D\u043E\u0441\u0442"} \u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430 ${i}${n.maximum.toString()} ${s.unit??"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0430"}`;return`\u0422\u0432\u044A\u0440\u0434\u0435 \u0433\u043E\u043B\u044F\u043C\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${n.origin??"\u0441\u0442\u043E\u0439\u043D\u043E\u0441\u0442"} \u0434\u0430 \u0431\u044A\u0434\u0435 ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`\u0422\u0432\u044A\u0440\u0434\u0435 \u043C\u0430\u043B\u043A\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${n.origin} \u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430 ${i}${n.minimum.toString()} ${s.unit}`;return`\u0422\u0432\u044A\u0440\u0434\u0435 \u043C\u0430\u043B\u043A\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${n.origin} \u0434\u0430 \u0431\u044A\u0434\u0435 ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043D\u0438\u0437: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0437\u0430\u043F\u043E\u0447\u0432\u0430 \u0441 "${i.prefix}"`;if(i.format==="ends_with")return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043D\u0438\u0437: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0437\u0430\u0432\u044A\u0440\u0448\u0432\u0430 \u0441 "${i.suffix}"`;if(i.format==="includes")return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043D\u0438\u0437: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0432\u043A\u043B\u044E\u0447\u0432\u0430 "${i.includes}"`;if(i.format==="regex")return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043D\u0438\u0437: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0441\u044A\u0432\u043F\u0430\u0434\u0430 \u0441 ${i.pattern}`;let s="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D";if(i.format==="emoji")s="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E";if(i.format==="datetime")s="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E";if(i.format==="date")s="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430";if(i.format==="time")s="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E";if(i.format==="duration")s="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430";return`${s} ${r[i.format]??n.format}`}case"not_multiple_of":return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E \u0447\u0438\u0441\u043B\u043E: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0431\u044A\u0434\u0435 \u043A\u0440\u0430\u0442\u043D\u043E \u043D\u0430 ${n.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u0430\u0437\u043F\u043E\u0437\u043D\u0430\u0442${n.keys.length>1?"\u0438":""} \u043A\u043B\u044E\u0447${n.keys.length>1?"\u043E\u0432\u0435":""}: ${Q(n.keys,", ")}`;case"invalid_key":return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043A\u043B\u044E\u0447 \u0432 ${n.origin}`;case"invalid_union":return"\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434";case"invalid_element":return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430 \u0441\u0442\u043E\u0439\u043D\u043E\u0441\u0442 \u0432 ${n.origin}`;default:return"\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434"}}};var VC=v(()=>{ke()});function qw(){return{localeError:bJ()}}var bJ=()=>{let e={string:{unit:"car\xE0cters",verb:"contenir"},file:{unit:"bytes",verb:"contenir"},array:{unit:"elements",verb:"contenir"},set:{unit:"elements",verb:"contenir"}};function t(n){return e[n]??null}let r={regex:"entrada",email:"adre\xE7a electr\xF2nica",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data i hora ISO",date:"data ISO",time:"hora ISO",duration:"durada ISO",ipv4:"adre\xE7a IPv4",ipv6:"adre\xE7a IPv6",cidrv4:"rang IPv4",cidrv6:"rang IPv6",base64:"cadena codificada en base64",base64url:"cadena codificada en base64url",json_string:"cadena JSON",e164:"n\xFAmero E.164",jwt:"JWT",template_literal:"entrada"},o={nan:"NaN"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`Tipus inv\xE0lid: s'esperava instanceof ${n.expected}, s'ha rebut ${a}`;return`Tipus inv\xE0lid: s'esperava ${i}, s'ha rebut ${a}`}case"invalid_value":if(n.values.length===1)return`Valor inv\xE0lid: s'esperava ${ce(n.values[0])}`;return`Opci\xF3 inv\xE0lida: s'esperava una de ${Q(n.values," o ")}`;case"too_big":{let i=n.inclusive?"com a m\xE0xim":"menys de",s=t(n.origin);if(s)return`Massa gran: s'esperava que ${n.origin??"el valor"} contingu\xE9s ${i} ${n.maximum.toString()} ${s.unit??"elements"}`;return`Massa gran: s'esperava que ${n.origin??"el valor"} fos ${i} ${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?"com a m\xEDnim":"m\xE9s de",s=t(n.origin);if(s)return`Massa petit: s'esperava que ${n.origin} contingu\xE9s ${i} ${n.minimum.toString()} ${s.unit}`;return`Massa petit: s'esperava que ${n.origin} fos ${i} ${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`Format inv\xE0lid: ha de comen\xE7ar amb "${i.prefix}"`;if(i.format==="ends_with")return`Format inv\xE0lid: ha d'acabar amb "${i.suffix}"`;if(i.format==="includes")return`Format inv\xE0lid: ha d'incloure "${i.includes}"`;if(i.format==="regex")return`Format inv\xE0lid: ha de coincidir amb el patr\xF3 ${i.pattern}`;return`Format inv\xE0lid per a ${r[i.format]??n.format}`}case"not_multiple_of":return`N\xFAmero inv\xE0lid: ha de ser m\xFAltiple de ${n.divisor}`;case"unrecognized_keys":return`Clau${n.keys.length>1?"s":""} no reconeguda${n.keys.length>1?"s":""}: ${Q(n.keys,", ")}`;case"invalid_key":return`Clau inv\xE0lida a ${n.origin}`;case"invalid_union":return"Entrada inv\xE0lida";case"invalid_element":return`Element inv\xE0lid a ${n.origin}`;default:return"Entrada inv\xE0lida"}}};var WC=v(()=>{ke()});function Fw(){return{localeError:SJ()}}var SJ=()=>{let e={string:{unit:"znak\u016F",verb:"m\xEDt"},file:{unit:"bajt\u016F",verb:"m\xEDt"},array:{unit:"prvk\u016F",verb:"m\xEDt"},set:{unit:"prvk\u016F",verb:"m\xEDt"}};function t(n){return e[n]??null}let r={regex:"regul\xE1rn\xED v\xFDraz",email:"e-mailov\xE1 adresa",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"datum a \u010Das ve form\xE1tu ISO",date:"datum ve form\xE1tu ISO",time:"\u010Das ve form\xE1tu ISO",duration:"doba trv\xE1n\xED ISO",ipv4:"IPv4 adresa",ipv6:"IPv6 adresa",cidrv4:"rozsah IPv4",cidrv6:"rozsah IPv6",base64:"\u0159et\u011Bzec zak\xF3dovan\xFD ve form\xE1tu base64",base64url:"\u0159et\u011Bzec zak\xF3dovan\xFD ve form\xE1tu base64url",json_string:"\u0159et\u011Bzec ve form\xE1tu JSON",e164:"\u010D\xEDslo E.164",jwt:"JWT",template_literal:"vstup"},o={nan:"NaN",number:"\u010D\xEDslo",string:"\u0159et\u011Bzec",function:"funkce",array:"pole"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no instanceof ${n.expected}, obdr\u017Eeno ${a}`;return`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no ${i}, obdr\u017Eeno ${a}`}case"invalid_value":if(n.values.length===1)return`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no ${ce(n.values[0])}`;return`Neplatn\xE1 mo\u017Enost: o\u010Dek\xE1v\xE1na jedna z hodnot ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`Hodnota je p\u0159\xEDli\u0161 velk\xE1: ${n.origin??"hodnota"} mus\xED m\xEDt ${i}${n.maximum.toString()} ${s.unit??"prvk\u016F"}`;return`Hodnota je p\u0159\xEDli\u0161 velk\xE1: ${n.origin??"hodnota"} mus\xED b\xFDt ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`Hodnota je p\u0159\xEDli\u0161 mal\xE1: ${n.origin??"hodnota"} mus\xED m\xEDt ${i}${n.minimum.toString()} ${s.unit??"prvk\u016F"}`;return`Hodnota je p\u0159\xEDli\u0161 mal\xE1: ${n.origin??"hodnota"} mus\xED b\xFDt ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`Neplatn\xFD \u0159et\u011Bzec: mus\xED za\u010D\xEDnat na "${i.prefix}"`;if(i.format==="ends_with")return`Neplatn\xFD \u0159et\u011Bzec: mus\xED kon\u010Dit na "${i.suffix}"`;if(i.format==="includes")return`Neplatn\xFD \u0159et\u011Bzec: mus\xED obsahovat "${i.includes}"`;if(i.format==="regex")return`Neplatn\xFD \u0159et\u011Bzec: mus\xED odpov\xEDdat vzoru ${i.pattern}`;return`Neplatn\xFD form\xE1t ${r[i.format]??n.format}`}case"not_multiple_of":return`Neplatn\xE9 \u010D\xEDslo: mus\xED b\xFDt n\xE1sobkem ${n.divisor}`;case"unrecognized_keys":return`Nezn\xE1m\xE9 kl\xED\u010De: ${Q(n.keys,", ")}`;case"invalid_key":return`Neplatn\xFD kl\xED\u010D v ${n.origin}`;case"invalid_union":return"Neplatn\xFD vstup";case"invalid_element":return`Neplatn\xE1 hodnota v ${n.origin}`;default:return"Neplatn\xFD vstup"}}};var GC=v(()=>{ke()});function Kw(){return{localeError:vJ()}}var vJ=()=>{let e={string:{unit:"tegn",verb:"havde"},file:{unit:"bytes",verb:"havde"},array:{unit:"elementer",verb:"indeholdt"},set:{unit:"elementer",verb:"indeholdt"}};function t(n){return e[n]??null}let r={regex:"input",email:"e-mailadresse",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO dato- og klokkesl\xE6t",date:"ISO-dato",time:"ISO-klokkesl\xE6t",duration:"ISO-varighed",ipv4:"IPv4-omr\xE5de",ipv6:"IPv6-omr\xE5de",cidrv4:"IPv4-spektrum",cidrv6:"IPv6-spektrum",base64:"base64-kodet streng",base64url:"base64url-kodet streng",json_string:"JSON-streng",e164:"E.164-nummer",jwt:"JWT",template_literal:"input"},o={nan:"NaN",string:"streng",number:"tal",boolean:"boolean",array:"liste",object:"objekt",set:"s\xE6t",file:"fil"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`Ugyldigt input: forventede instanceof ${n.expected}, fik ${a}`;return`Ugyldigt input: forventede ${i}, fik ${a}`}case"invalid_value":if(n.values.length===1)return`Ugyldig v\xE6rdi: forventede ${ce(n.values[0])}`;return`Ugyldigt valg: forventede en af f\xF8lgende ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin),a=o[n.origin]??n.origin;if(s)return`For stor: forventede ${a??"value"} ${s.verb} ${i} ${n.maximum.toString()} ${s.unit??"elementer"}`;return`For stor: forventede ${a??"value"} havde ${i} ${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin),a=o[n.origin]??n.origin;if(s)return`For lille: forventede ${a} ${s.verb} ${i} ${n.minimum.toString()} ${s.unit}`;return`For lille: forventede ${a} havde ${i} ${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`Ugyldig streng: skal starte med "${i.prefix}"`;if(i.format==="ends_with")return`Ugyldig streng: skal ende med "${i.suffix}"`;if(i.format==="includes")return`Ugyldig streng: skal indeholde "${i.includes}"`;if(i.format==="regex")return`Ugyldig streng: skal matche m\xF8nsteret ${i.pattern}`;return`Ugyldig ${r[i.format]??n.format}`}case"not_multiple_of":return`Ugyldigt tal: skal v\xE6re deleligt med ${n.divisor}`;case"unrecognized_keys":return`${n.keys.length>1?"Ukendte n\xF8gler":"Ukendt n\xF8gle"}: ${Q(n.keys,", ")}`;case"invalid_key":return`Ugyldig n\xF8gle i ${n.origin}`;case"invalid_union":return"Ugyldigt input: matcher ingen af de tilladte typer";case"invalid_element":return`Ugyldig v\xE6rdi i ${n.origin}`;default:return"Ugyldigt input"}}};var QC=v(()=>{ke()});function Hw(){return{localeError:wJ()}}var wJ=()=>{let e={string:{unit:"Zeichen",verb:"zu haben"},file:{unit:"Bytes",verb:"zu haben"},array:{unit:"Elemente",verb:"zu haben"},set:{unit:"Elemente",verb:"zu haben"}};function t(n){return e[n]??null}let r={regex:"Eingabe",email:"E-Mail-Adresse",url:"URL",emoji:"Emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-Datum und -Uhrzeit",date:"ISO-Datum",time:"ISO-Uhrzeit",duration:"ISO-Dauer",ipv4:"IPv4-Adresse",ipv6:"IPv6-Adresse",cidrv4:"IPv4-Bereich",cidrv6:"IPv6-Bereich",base64:"Base64-codierter String",base64url:"Base64-URL-codierter String",json_string:"JSON-String",e164:"E.164-Nummer",jwt:"JWT",template_literal:"Eingabe"},o={nan:"NaN",number:"Zahl",array:"Array"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`Ung\xFCltige Eingabe: erwartet instanceof ${n.expected}, erhalten ${a}`;return`Ung\xFCltige Eingabe: erwartet ${i}, erhalten ${a}`}case"invalid_value":if(n.values.length===1)return`Ung\xFCltige Eingabe: erwartet ${ce(n.values[0])}`;return`Ung\xFCltige Option: erwartet eine von ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`Zu gro\xDF: erwartet, dass ${n.origin??"Wert"} ${i}${n.maximum.toString()} ${s.unit??"Elemente"} hat`;return`Zu gro\xDF: erwartet, dass ${n.origin??"Wert"} ${i}${n.maximum.toString()} ist`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`Zu klein: erwartet, dass ${n.origin} ${i}${n.minimum.toString()} ${s.unit} hat`;return`Zu klein: erwartet, dass ${n.origin} ${i}${n.minimum.toString()} ist`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`Ung\xFCltiger String: muss mit "${i.prefix}" beginnen`;if(i.format==="ends_with")return`Ung\xFCltiger String: muss mit "${i.suffix}" enden`;if(i.format==="includes")return`Ung\xFCltiger String: muss "${i.includes}" enthalten`;if(i.format==="regex")return`Ung\xFCltiger String: muss dem Muster ${i.pattern} entsprechen`;return`Ung\xFCltig: ${r[i.format]??n.format}`}case"not_multiple_of":return`Ung\xFCltige Zahl: muss ein Vielfaches von ${n.divisor} sein`;case"unrecognized_keys":return`${n.keys.length>1?"Unbekannte Schl\xFCssel":"Unbekannter Schl\xFCssel"}: ${Q(n.keys,", ")}`;case"invalid_key":return`Ung\xFCltiger Schl\xFCssel in ${n.origin}`;case"invalid_union":return"Ung\xFCltige Eingabe";case"invalid_element":return`Ung\xFCltiger Wert in ${n.origin}`;default:return"Ung\xFCltige Eingabe"}}};var YC=v(()=>{ke()});function Jw(){return{localeError:xJ()}}var xJ=()=>{let e={string:{unit:"\u03C7\u03B1\u03C1\u03B1\u03BA\u03C4\u03AE\u03C1\u03B5\u03C2",verb:"\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9"},file:{unit:"bytes",verb:"\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9"},array:{unit:"\u03C3\u03C4\u03BF\u03B9\u03C7\u03B5\u03AF\u03B1",verb:"\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9"},set:{unit:"\u03C3\u03C4\u03BF\u03B9\u03C7\u03B5\u03AF\u03B1",verb:"\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9"},map:{unit:"\u03BA\u03B1\u03C4\u03B1\u03C7\u03C9\u03C1\u03AE\u03C3\u03B5\u03B9\u03C2",verb:"\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9"}};function t(n){return e[n]??null}let r={regex:"\u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2",email:"\u03B4\u03B9\u03B5\u03CD\u03B8\u03C5\u03BD\u03C3\u03B7 email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u03B7\u03BC\u03B5\u03C1\u03BF\u03BC\u03B7\u03BD\u03AF\u03B1 \u03BA\u03B1\u03B9 \u03CE\u03C1\u03B1",date:"ISO \u03B7\u03BC\u03B5\u03C1\u03BF\u03BC\u03B7\u03BD\u03AF\u03B1",time:"ISO \u03CE\u03C1\u03B1",duration:"ISO \u03B4\u03B9\u03AC\u03C1\u03BA\u03B5\u03B9\u03B1",ipv4:"\u03B4\u03B9\u03B5\u03CD\u03B8\u03C5\u03BD\u03C3\u03B7 IPv4",ipv6:"\u03B4\u03B9\u03B5\u03CD\u03B8\u03C5\u03BD\u03C3\u03B7 IPv6",mac:"\u03B4\u03B9\u03B5\u03CD\u03B8\u03C5\u03BD\u03C3\u03B7 MAC",cidrv4:"\u03B5\u03CD\u03C1\u03BF\u03C2 IPv4",cidrv6:"\u03B5\u03CD\u03C1\u03BF\u03C2 IPv6",base64:"\u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC \u03BA\u03C9\u03B4\u03B9\u03BA\u03BF\u03C0\u03BF\u03B9\u03B7\u03BC\u03AD\u03BD\u03B7 \u03C3\u03B5 base64",base64url:"\u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC \u03BA\u03C9\u03B4\u03B9\u03BA\u03BF\u03C0\u03BF\u03B9\u03B7\u03BC\u03AD\u03BD\u03B7 \u03C3\u03B5 base64url",json_string:"\u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC JSON",e164:"\u03B1\u03C1\u03B9\u03B8\u03BC\u03CC\u03C2 E.164",jwt:"JWT",template_literal:"\u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2"},o={nan:"NaN"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(typeof n.expected==="string"&&/^[A-Z]/.test(n.expected))return`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD instanceof ${n.expected}, \u03BB\u03AE\u03C6\u03B8\u03B7\u03BA\u03B5 ${a}`;return`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${i}, \u03BB\u03AE\u03C6\u03B8\u03B7\u03BA\u03B5 ${a}`}case"invalid_value":if(n.values.length===1)return`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${ce(n.values[0])}`;return`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03C0\u03B9\u03BB\u03BF\u03B3\u03AE: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD \u03AD\u03BD\u03B1 \u03B1\u03C0\u03CC ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`\u03A0\u03BF\u03BB\u03CD \u03BC\u03B5\u03B3\u03AC\u03BB\u03BF: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${n.origin??"\u03C4\u03B9\u03BC\u03AE"} \u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9 ${i}${n.maximum.toString()} ${s.unit??"\u03C3\u03C4\u03BF\u03B9\u03C7\u03B5\u03AF\u03B1"}`;return`\u03A0\u03BF\u03BB\u03CD \u03BC\u03B5\u03B3\u03AC\u03BB\u03BF: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${n.origin??"\u03C4\u03B9\u03BC\u03AE"} \u03BD\u03B1 \u03B5\u03AF\u03BD\u03B1\u03B9 ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`\u03A0\u03BF\u03BB\u03CD \u03BC\u03B9\u03BA\u03C1\u03CC: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${n.origin} \u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9 ${i}${n.minimum.toString()} ${s.unit}`;return`\u03A0\u03BF\u03BB\u03CD \u03BC\u03B9\u03BA\u03C1\u03CC: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${n.origin} \u03BD\u03B1 \u03B5\u03AF\u03BD\u03B1\u03B9 ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC: \u03C0\u03C1\u03AD\u03C0\u03B5\u03B9 \u03BD\u03B1 \u03BE\u03B5\u03BA\u03B9\u03BD\u03AC \u03BC\u03B5 "${i.prefix}"`;if(i.format==="ends_with")return`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC: \u03C0\u03C1\u03AD\u03C0\u03B5\u03B9 \u03BD\u03B1 \u03C4\u03B5\u03BB\u03B5\u03B9\u03CE\u03BD\u03B5\u03B9 \u03BC\u03B5 "${i.suffix}"`;if(i.format==="includes")return`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC: \u03C0\u03C1\u03AD\u03C0\u03B5\u03B9 \u03BD\u03B1 \u03C0\u03B5\u03C1\u03B9\u03AD\u03C7\u03B5\u03B9 "${i.includes}"`;if(i.format==="regex")return`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC: \u03C0\u03C1\u03AD\u03C0\u03B5\u03B9 \u03BD\u03B1 \u03C4\u03B1\u03B9\u03C1\u03B9\u03AC\u03B6\u03B5\u03B9 \u03BC\u03B5 \u03C4\u03BF \u03BC\u03BF\u03C4\u03AF\u03B2\u03BF ${i.pattern}`;return`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03BF: ${r[i.format]??n.format}`}case"not_multiple_of":return`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03BF\u03C2 \u03B1\u03C1\u03B9\u03B8\u03BC\u03CC\u03C2: \u03C0\u03C1\u03AD\u03C0\u03B5\u03B9 \u03BD\u03B1 \u03B5\u03AF\u03BD\u03B1\u03B9 \u03C0\u03BF\u03BB\u03BB\u03B1\u03C0\u03BB\u03AC\u03C3\u03B9\u03BF \u03C4\u03BF\u03C5 ${n.divisor}`;case"unrecognized_keys":return`\u0386\u03B3\u03BD\u03C9\u03C3\u03C4${n.keys.length>1?"\u03B1":"\u03BF"} \u03BA\u03BB\u03B5\u03B9\u03B4${n.keys.length>1?"\u03B9\u03AC":"\u03AF"}: ${Q(n.keys,", ")}`;case"invalid_key":return`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03BF \u03BA\u03BB\u03B5\u03B9\u03B4\u03AF \u03C3\u03C4\u03BF ${n.origin}`;case"invalid_union":return"\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2";case"invalid_element":return`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03C4\u03B9\u03BC\u03AE \u03C3\u03C4\u03BF ${n.origin}`;default:return"\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2"}}};var XC=v(()=>{ke()});function cu(){return{localeError:_J()}}var _J=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(n){return e[n]??null}let r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"},o={nan:"NaN"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;return`Invalid input: expected ${i}, received ${a}`}case"invalid_value":if(n.values.length===1)return`Invalid input: expected ${ce(n.values[0])}`;return`Invalid option: expected one of ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`Too big: expected ${n.origin??"value"} to have ${i}${n.maximum.toString()} ${s.unit??"elements"}`;return`Too big: expected ${n.origin??"value"} to be ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`Too small: expected ${n.origin} to have ${i}${n.minimum.toString()} ${s.unit}`;return`Too small: expected ${n.origin} to be ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`Invalid string: must start with "${i.prefix}"`;if(i.format==="ends_with")return`Invalid string: must end with "${i.suffix}"`;if(i.format==="includes")return`Invalid string: must include "${i.includes}"`;if(i.format==="regex")return`Invalid string: must match pattern ${i.pattern}`;return`Invalid ${r[i.format]??n.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${n.divisor}`;case"unrecognized_keys":return`Unrecognized key${n.keys.length>1?"s":""}: ${Q(n.keys,", ")}`;case"invalid_key":return`Invalid key in ${n.origin}`;case"invalid_union":if(n.options&&Array.isArray(n.options)&&n.options.length>0)return`Invalid discriminator value. Expected ${n.options.map((s)=>`'${s}'`).join(" | ")}`;return"Invalid input";case"invalid_element":return`Invalid value in ${n.origin}`;default:return"Invalid input"}}};var Vw=v(()=>{ke()});function Ww(){return{localeError:EJ()}}var EJ=()=>{let e={string:{unit:"karaktrojn",verb:"havi"},file:{unit:"bajtojn",verb:"havi"},array:{unit:"elementojn",verb:"havi"},set:{unit:"elementojn",verb:"havi"}};function t(n){return e[n]??null}let r={regex:"enigo",email:"retadreso",url:"URL",emoji:"emo\u011Dio",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-datotempo",date:"ISO-dato",time:"ISO-tempo",duration:"ISO-da\u016Dro",ipv4:"IPv4-adreso",ipv6:"IPv6-adreso",cidrv4:"IPv4-rango",cidrv6:"IPv6-rango",base64:"64-ume kodita karaktraro",base64url:"URL-64-ume kodita karaktraro",json_string:"JSON-karaktraro",e164:"E.164-nombro",jwt:"JWT",template_literal:"enigo"},o={nan:"NaN",number:"nombro",array:"tabelo",null:"senvalora"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`Nevalida enigo: atendi\u011Dis instanceof ${n.expected}, ricevi\u011Dis ${a}`;return`Nevalida enigo: atendi\u011Dis ${i}, ricevi\u011Dis ${a}`}case"invalid_value":if(n.values.length===1)return`Nevalida enigo: atendi\u011Dis ${ce(n.values[0])}`;return`Nevalida opcio: atendi\u011Dis unu el ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`Tro granda: atendi\u011Dis ke ${n.origin??"valoro"} havu ${i}${n.maximum.toString()} ${s.unit??"elementojn"}`;return`Tro granda: atendi\u011Dis ke ${n.origin??"valoro"} havu ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`Tro malgranda: atendi\u011Dis ke ${n.origin} havu ${i}${n.minimum.toString()} ${s.unit}`;return`Tro malgranda: atendi\u011Dis ke ${n.origin} estu ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`Nevalida karaktraro: devas komenci\u011Di per "${i.prefix}"`;if(i.format==="ends_with")return`Nevalida karaktraro: devas fini\u011Di per "${i.suffix}"`;if(i.format==="includes")return`Nevalida karaktraro: devas inkluzivi "${i.includes}"`;if(i.format==="regex")return`Nevalida karaktraro: devas kongrui kun la modelo ${i.pattern}`;return`Nevalida ${r[i.format]??n.format}`}case"not_multiple_of":return`Nevalida nombro: devas esti oblo de ${n.divisor}`;case"unrecognized_keys":return`Nekonata${n.keys.length>1?"j":""} \u015Dlosilo${n.keys.length>1?"j":""}: ${Q(n.keys,", ")}`;case"invalid_key":return`Nevalida \u015Dlosilo en ${n.origin}`;case"invalid_union":return"Nevalida enigo";case"invalid_element":return`Nevalida valoro en ${n.origin}`;default:return"Nevalida enigo"}}};var e1=v(()=>{ke()});function Gw(){return{localeError:kJ()}}var kJ=()=>{let e={string:{unit:"caracteres",verb:"tener"},file:{unit:"bytes",verb:"tener"},array:{unit:"elementos",verb:"tener"},set:{unit:"elementos",verb:"tener"}};function t(n){return e[n]??null}let r={regex:"entrada",email:"direcci\xF3n de correo electr\xF3nico",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"fecha y hora ISO",date:"fecha ISO",time:"hora ISO",duration:"duraci\xF3n ISO",ipv4:"direcci\xF3n IPv4",ipv6:"direcci\xF3n IPv6",cidrv4:"rango IPv4",cidrv6:"rango IPv6",base64:"cadena codificada en base64",base64url:"URL codificada en base64",json_string:"cadena JSON",e164:"n\xFAmero E.164",jwt:"JWT",template_literal:"entrada"},o={nan:"NaN",string:"texto",number:"n\xFAmero",boolean:"booleano",array:"arreglo",object:"objeto",set:"conjunto",file:"archivo",date:"fecha",bigint:"n\xFAmero grande",symbol:"s\xEDmbolo",undefined:"indefinido",null:"nulo",function:"funci\xF3n",map:"mapa",record:"registro",tuple:"tupla",enum:"enumeraci\xF3n",union:"uni\xF3n",literal:"literal",promise:"promesa",void:"vac\xEDo",never:"nunca",unknown:"desconocido",any:"cualquiera"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`Entrada inv\xE1lida: se esperaba instanceof ${n.expected}, recibido ${a}`;return`Entrada inv\xE1lida: se esperaba ${i}, recibido ${a}`}case"invalid_value":if(n.values.length===1)return`Entrada inv\xE1lida: se esperaba ${ce(n.values[0])}`;return`Opci\xF3n inv\xE1lida: se esperaba una de ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin),a=o[n.origin]??n.origin;if(s)return`Demasiado grande: se esperaba que ${a??"valor"} tuviera ${i}${n.maximum.toString()} ${s.unit??"elementos"}`;return`Demasiado grande: se esperaba que ${a??"valor"} fuera ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin),a=o[n.origin]??n.origin;if(s)return`Demasiado peque\xF1o: se esperaba que ${a} tuviera ${i}${n.minimum.toString()} ${s.unit}`;return`Demasiado peque\xF1o: se esperaba que ${a} fuera ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`Cadena inv\xE1lida: debe comenzar con "${i.prefix}"`;if(i.format==="ends_with")return`Cadena inv\xE1lida: debe terminar en "${i.suffix}"`;if(i.format==="includes")return`Cadena inv\xE1lida: debe incluir "${i.includes}"`;if(i.format==="regex")return`Cadena inv\xE1lida: debe coincidir con el patr\xF3n ${i.pattern}`;return`Inv\xE1lido ${r[i.format]??n.format}`}case"not_multiple_of":return`N\xFAmero inv\xE1lido: debe ser m\xFAltiplo de ${n.divisor}`;case"unrecognized_keys":return`Llave${n.keys.length>1?"s":""} desconocida${n.keys.length>1?"s":""}: ${Q(n.keys,", ")}`;case"invalid_key":return`Llave inv\xE1lida en ${o[n.origin]??n.origin}`;case"invalid_union":return"Entrada inv\xE1lida";case"invalid_element":return`Valor inv\xE1lido en ${o[n.origin]??n.origin}`;default:return"Entrada inv\xE1lida"}}};var t1=v(()=>{ke()});function Qw(){return{localeError:IJ()}}var IJ=()=>{let e={string:{unit:"\u06A9\u0627\u0631\u0627\u06A9\u062A\u0631",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"},file:{unit:"\u0628\u0627\u06CC\u062A",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"},array:{unit:"\u0622\u06CC\u062A\u0645",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"},set:{unit:"\u0622\u06CC\u062A\u0645",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"}};function t(n){return e[n]??null}let r={regex:"\u0648\u0631\u0648\u062F\u06CC",email:"\u0622\u062F\u0631\u0633 \u0627\u06CC\u0645\u06CC\u0644",url:"URL",emoji:"\u0627\u06CC\u0645\u0648\u062C\u06CC",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u062A\u0627\u0631\u06CC\u062E \u0648 \u0632\u0645\u0627\u0646 \u0627\u06CC\u0632\u0648",date:"\u062A\u0627\u0631\u06CC\u062E \u0627\u06CC\u0632\u0648",time:"\u0632\u0645\u0627\u0646 \u0627\u06CC\u0632\u0648",duration:"\u0645\u062F\u062A \u0632\u0645\u0627\u0646 \u0627\u06CC\u0632\u0648",ipv4:"IPv4 \u0622\u062F\u0631\u0633",ipv6:"IPv6 \u0622\u062F\u0631\u0633",cidrv4:"IPv4 \u062F\u0627\u0645\u0646\u0647",cidrv6:"IPv6 \u062F\u0627\u0645\u0646\u0647",base64:"base64-encoded \u0631\u0634\u062A\u0647",base64url:"base64url-encoded \u0631\u0634\u062A\u0647",json_string:"JSON \u0631\u0634\u062A\u0647",e164:"E.164 \u0639\u062F\u062F",jwt:"JWT",template_literal:"\u0648\u0631\u0648\u062F\u06CC"},o={nan:"NaN",number:"\u0639\u062F\u062F",array:"\u0622\u0631\u0627\u06CC\u0647"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A instanceof ${n.expected} \u0645\u06CC\u200C\u0628\u0648\u062F\u060C ${a} \u062F\u0631\u06CC\u0627\u0641\u062A \u0634\u062F`;return`\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A ${i} \u0645\u06CC\u200C\u0628\u0648\u062F\u060C ${a} \u062F\u0631\u06CC\u0627\u0641\u062A \u0634\u062F`}case"invalid_value":if(n.values.length===1)return`\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A ${ce(n.values[0])} \u0645\u06CC\u200C\u0628\u0648\u062F`;return`\u06AF\u0632\u06CC\u0646\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A \u06CC\u06A9\u06CC \u0627\u0632 ${Q(n.values,"|")} \u0645\u06CC\u200C\u0628\u0648\u062F`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`\u062E\u06CC\u0644\u06CC \u0628\u0632\u0631\u06AF: ${n.origin??"\u0645\u0642\u062F\u0627\u0631"} \u0628\u0627\u06CC\u062F ${i}${n.maximum.toString()} ${s.unit??"\u0639\u0646\u0635\u0631"} \u0628\u0627\u0634\u062F`;return`\u062E\u06CC\u0644\u06CC \u0628\u0632\u0631\u06AF: ${n.origin??"\u0645\u0642\u062F\u0627\u0631"} \u0628\u0627\u06CC\u062F ${i}${n.maximum.toString()} \u0628\u0627\u0634\u062F`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`\u062E\u06CC\u0644\u06CC \u06A9\u0648\u0686\u06A9: ${n.origin} \u0628\u0627\u06CC\u062F ${i}${n.minimum.toString()} ${s.unit} \u0628\u0627\u0634\u062F`;return`\u062E\u06CC\u0644\u06CC \u06A9\u0648\u0686\u06A9: ${n.origin} \u0628\u0627\u06CC\u062F ${i}${n.minimum.toString()} \u0628\u0627\u0634\u062F`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 "${i.prefix}" \u0634\u0631\u0648\u0639 \u0634\u0648\u062F`;if(i.format==="ends_with")return`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 "${i.suffix}" \u062A\u0645\u0627\u0645 \u0634\u0648\u062F`;if(i.format==="includes")return`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0634\u0627\u0645\u0644 "${i.includes}" \u0628\u0627\u0634\u062F`;if(i.format==="regex")return`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 \u0627\u0644\u06AF\u0648\u06CC ${i.pattern} \u0645\u0637\u0627\u0628\u0642\u062A \u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F`;return`${r[i.format]??n.format} \u0646\u0627\u0645\u0639\u062A\u0628\u0631`}case"not_multiple_of":return`\u0639\u062F\u062F \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0645\u0636\u0631\u0628 ${n.divisor} \u0628\u0627\u0634\u062F`;case"unrecognized_keys":return`\u06A9\u0644\u06CC\u062F${n.keys.length>1?"\u0647\u0627\u06CC":""} \u0646\u0627\u0634\u0646\u0627\u0633: ${Q(n.keys,", ")}`;case"invalid_key":return`\u06A9\u0644\u06CC\u062F \u0646\u0627\u0634\u0646\u0627\u0633 \u062F\u0631 ${n.origin}`;case"invalid_union":return"\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631";case"invalid_element":return`\u0645\u0642\u062F\u0627\u0631 \u0646\u0627\u0645\u0639\u062A\u0628\u0631 \u062F\u0631 ${n.origin}`;default:return"\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631"}}};var r1=v(()=>{ke()});function Yw(){return{localeError:AJ()}}var AJ=()=>{let e={string:{unit:"merkki\xE4",subject:"merkkijonon"},file:{unit:"tavua",subject:"tiedoston"},array:{unit:"alkiota",subject:"listan"},set:{unit:"alkiota",subject:"joukon"},number:{unit:"",subject:"luvun"},bigint:{unit:"",subject:"suuren kokonaisluvun"},int:{unit:"",subject:"kokonaisluvun"},date:{unit:"",subject:"p\xE4iv\xE4m\xE4\xE4r\xE4n"}};function t(n){return e[n]??null}let r={regex:"s\xE4\xE4nn\xF6llinen lauseke",email:"s\xE4hk\xF6postiosoite",url:"URL-osoite",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-aikaleima",date:"ISO-p\xE4iv\xE4m\xE4\xE4r\xE4",time:"ISO-aika",duration:"ISO-kesto",ipv4:"IPv4-osoite",ipv6:"IPv6-osoite",cidrv4:"IPv4-alue",cidrv6:"IPv6-alue",base64:"base64-koodattu merkkijono",base64url:"base64url-koodattu merkkijono",json_string:"JSON-merkkijono",e164:"E.164-luku",jwt:"JWT",template_literal:"templaattimerkkijono"},o={nan:"NaN"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`Virheellinen tyyppi: odotettiin instanceof ${n.expected}, oli ${a}`;return`Virheellinen tyyppi: odotettiin ${i}, oli ${a}`}case"invalid_value":if(n.values.length===1)return`Virheellinen sy\xF6te: t\xE4ytyy olla ${ce(n.values[0])}`;return`Virheellinen valinta: t\xE4ytyy olla yksi seuraavista: ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`Liian suuri: ${s.subject} t\xE4ytyy olla ${i}${n.maximum.toString()} ${s.unit}`.trim();return`Liian suuri: arvon t\xE4ytyy olla ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`Liian pieni: ${s.subject} t\xE4ytyy olla ${i}${n.minimum.toString()} ${s.unit}`.trim();return`Liian pieni: arvon t\xE4ytyy olla ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`Virheellinen sy\xF6te: t\xE4ytyy alkaa "${i.prefix}"`;if(i.format==="ends_with")return`Virheellinen sy\xF6te: t\xE4ytyy loppua "${i.suffix}"`;if(i.format==="includes")return`Virheellinen sy\xF6te: t\xE4ytyy sis\xE4lt\xE4\xE4 "${i.includes}"`;if(i.format==="regex")return`Virheellinen sy\xF6te: t\xE4ytyy vastata s\xE4\xE4nn\xF6llist\xE4 lauseketta ${i.pattern}`;return`Virheellinen ${r[i.format]??n.format}`}case"not_multiple_of":return`Virheellinen luku: t\xE4ytyy olla luvun ${n.divisor} monikerta`;case"unrecognized_keys":return`${n.keys.length>1?"Tuntemattomat avaimet":"Tuntematon avain"}: ${Q(n.keys,", ")}`;case"invalid_key":return"Virheellinen avain tietueessa";case"invalid_union":return"Virheellinen unioni";case"invalid_element":return"Virheellinen arvo joukossa";default:return"Virheellinen sy\xF6te"}}};var n1=v(()=>{ke()});function Xw(){return{localeError:TJ()}}var TJ=()=>{let e={string:{unit:"caract\xE8res",verb:"avoir"},file:{unit:"octets",verb:"avoir"},array:{unit:"\xE9l\xE9ments",verb:"avoir"},set:{unit:"\xE9l\xE9ments",verb:"avoir"}};function t(n){return e[n]??null}let r={regex:"entr\xE9e",email:"adresse e-mail",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"date et heure ISO",date:"date ISO",time:"heure ISO",duration:"dur\xE9e ISO",ipv4:"adresse IPv4",ipv6:"adresse IPv6",cidrv4:"plage IPv4",cidrv6:"plage IPv6",base64:"cha\xEEne encod\xE9e en base64",base64url:"cha\xEEne encod\xE9e en base64url",json_string:"cha\xEEne JSON",e164:"num\xE9ro E.164",jwt:"JWT",template_literal:"entr\xE9e"},o={string:"cha\xEEne",number:"nombre",int:"entier",boolean:"bool\xE9en",bigint:"grand entier",symbol:"symbole",undefined:"ind\xE9fini",null:"null",never:"jamais",void:"vide",date:"date",array:"tableau",object:"objet",tuple:"tuple",record:"enregistrement",map:"carte",set:"ensemble",file:"fichier",nonoptional:"non-optionnel",nan:"NaN",function:"fonction"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`Entr\xE9e invalide : instanceof ${n.expected} attendu, ${a} re\xE7u`;return`Entr\xE9e invalide : ${i} attendu, ${a} re\xE7u`}case"invalid_value":if(n.values.length===1)return`Entr\xE9e invalide : ${ce(n.values[0])} attendu`;return`Option invalide : une valeur parmi ${Q(n.values,"|")} attendue`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`Trop grand : ${o[n.origin]??"valeur"} doit ${s.verb} ${i}${n.maximum.toString()} ${s.unit??"\xE9l\xE9ment(s)"}`;return`Trop grand : ${o[n.origin]??"valeur"} doit \xEAtre ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`Trop petit : ${o[n.origin]??"valeur"} doit ${s.verb} ${i}${n.minimum.toString()} ${s.unit}`;return`Trop petit : ${o[n.origin]??"valeur"} doit \xEAtre ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`Cha\xEEne invalide : doit commencer par "${i.prefix}"`;if(i.format==="ends_with")return`Cha\xEEne invalide : doit se terminer par "${i.suffix}"`;if(i.format==="includes")return`Cha\xEEne invalide : doit inclure "${i.includes}"`;if(i.format==="regex")return`Cha\xEEne invalide : doit correspondre au mod\xE8le ${i.pattern}`;return`${r[i.format]??n.format} invalide`}case"not_multiple_of":return`Nombre invalide : doit \xEAtre un multiple de ${n.divisor}`;case"unrecognized_keys":return`Cl\xE9${n.keys.length>1?"s":""} non reconnue${n.keys.length>1?"s":""} : ${Q(n.keys,", ")}`;case"invalid_key":return`Cl\xE9 invalide dans ${n.origin}`;case"invalid_union":return"Entr\xE9e invalide";case"invalid_element":return`Valeur invalide dans ${n.origin}`;default:return"Entr\xE9e invalide"}}};var o1=v(()=>{ke()});function ex(){return{localeError:RJ()}}var RJ=()=>{let e={string:{unit:"caract\xE8res",verb:"avoir"},file:{unit:"octets",verb:"avoir"},array:{unit:"\xE9l\xE9ments",verb:"avoir"},set:{unit:"\xE9l\xE9ments",verb:"avoir"}};function t(n){return e[n]??null}let r={regex:"entr\xE9e",email:"adresse courriel",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"date-heure ISO",date:"date ISO",time:"heure ISO",duration:"dur\xE9e ISO",ipv4:"adresse IPv4",ipv6:"adresse IPv6",cidrv4:"plage IPv4",cidrv6:"plage IPv6",base64:"cha\xEEne encod\xE9e en base64",base64url:"cha\xEEne encod\xE9e en base64url",json_string:"cha\xEEne JSON",e164:"num\xE9ro E.164",jwt:"JWT",template_literal:"entr\xE9e"},o={nan:"NaN"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`Entr\xE9e invalide : attendu instanceof ${n.expected}, re\xE7u ${a}`;return`Entr\xE9e invalide : attendu ${i}, re\xE7u ${a}`}case"invalid_value":if(n.values.length===1)return`Entr\xE9e invalide : attendu ${ce(n.values[0])}`;return`Option invalide : attendu l'une des valeurs suivantes ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"\u2264":"<",s=t(n.origin);if(s)return`Trop grand : attendu que ${n.origin??"la valeur"} ait ${i}${n.maximum.toString()} ${s.unit}`;return`Trop grand : attendu que ${n.origin??"la valeur"} soit ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?"\u2265":">",s=t(n.origin);if(s)return`Trop petit : attendu que ${n.origin} ait ${i}${n.minimum.toString()} ${s.unit}`;return`Trop petit : attendu que ${n.origin} soit ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`Cha\xEEne invalide : doit commencer par "${i.prefix}"`;if(i.format==="ends_with")return`Cha\xEEne invalide : doit se terminer par "${i.suffix}"`;if(i.format==="includes")return`Cha\xEEne invalide : doit inclure "${i.includes}"`;if(i.format==="regex")return`Cha\xEEne invalide : doit correspondre au motif ${i.pattern}`;return`${r[i.format]??n.format} invalide`}case"not_multiple_of":return`Nombre invalide : doit \xEAtre un multiple de ${n.divisor}`;case"unrecognized_keys":return`Cl\xE9${n.keys.length>1?"s":""} non reconnue${n.keys.length>1?"s":""} : ${Q(n.keys,", ")}`;case"invalid_key":return`Cl\xE9 invalide dans ${n.origin}`;case"invalid_union":return"Entr\xE9e invalide";case"invalid_element":return`Valeur invalide dans ${n.origin}`;default:return"Entr\xE9e invalide"}}};var i1=v(()=>{ke()});function tx(){return{localeError:$J()}}var $J=()=>{let e={string:{label:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA",gender:"f"},number:{label:"\u05DE\u05E1\u05E4\u05E8",gender:"m"},boolean:{label:"\u05E2\u05E8\u05DA \u05D1\u05D5\u05DC\u05D9\u05D0\u05E0\u05D9",gender:"m"},bigint:{label:"BigInt",gender:"m"},date:{label:"\u05EA\u05D0\u05E8\u05D9\u05DA",gender:"m"},array:{label:"\u05DE\u05E2\u05E8\u05DA",gender:"m"},object:{label:"\u05D0\u05D5\u05D1\u05D9\u05D9\u05E7\u05D8",gender:"m"},null:{label:"\u05E2\u05E8\u05DA \u05E8\u05D9\u05E7 (null)",gender:"m"},undefined:{label:"\u05E2\u05E8\u05DA \u05DC\u05D0 \u05DE\u05D5\u05D2\u05D3\u05E8 (undefined)",gender:"m"},symbol:{label:"\u05E1\u05D9\u05DE\u05D1\u05D5\u05DC (Symbol)",gender:"m"},function:{label:"\u05E4\u05D5\u05E0\u05E7\u05E6\u05D9\u05D4",gender:"f"},map:{label:"\u05DE\u05E4\u05D4 (Map)",gender:"f"},set:{label:"\u05E7\u05D1\u05D5\u05E6\u05D4 (Set)",gender:"f"},file:{label:"\u05E7\u05D5\u05D1\u05E5",gender:"m"},promise:{label:"Promise",gender:"m"},NaN:{label:"NaN",gender:"m"},unknown:{label:"\u05E2\u05E8\u05DA \u05DC\u05D0 \u05D9\u05D3\u05D5\u05E2",gender:"m"},value:{label:"\u05E2\u05E8\u05DA",gender:"m"}},t={string:{unit:"\u05EA\u05D5\u05D5\u05D9\u05DD",shortLabel:"\u05E7\u05E6\u05E8",longLabel:"\u05D0\u05E8\u05D5\u05DA"},file:{unit:"\u05D1\u05D9\u05D9\u05D8\u05D9\u05DD",shortLabel:"\u05E7\u05D8\u05DF",longLabel:"\u05D2\u05D3\u05D5\u05DC"},array:{unit:"\u05E4\u05E8\u05D9\u05D8\u05D9\u05DD",shortLabel:"\u05E7\u05D8\u05DF",longLabel:"\u05D2\u05D3\u05D5\u05DC"},set:{unit:"\u05E4\u05E8\u05D9\u05D8\u05D9\u05DD",shortLabel:"\u05E7\u05D8\u05DF",longLabel:"\u05D2\u05D3\u05D5\u05DC"},number:{unit:"",shortLabel:"\u05E7\u05D8\u05DF",longLabel:"\u05D2\u05D3\u05D5\u05DC"}},r=(u)=>u?e[u]:void 0,o=(u)=>{let d=r(u);if(d)return d.label;return u??e.unknown.label},n=(u)=>`\u05D4${o(u)}`,i=(u)=>(r(u)?.gender??"m")==="f"?"\u05E6\u05E8\u05D9\u05DB\u05D4 \u05DC\u05D4\u05D9\u05D5\u05EA":"\u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA",s=(u)=>{if(!u)return null;return t[u]??null},a={regex:{label:"\u05E7\u05DC\u05D8",gender:"m"},email:{label:"\u05DB\u05EA\u05D5\u05D1\u05EA \u05D0\u05D9\u05DE\u05D9\u05D9\u05DC",gender:"f"},url:{label:"\u05DB\u05EA\u05D5\u05D1\u05EA \u05E8\u05E9\u05EA",gender:"f"},emoji:{label:"\u05D0\u05D9\u05DE\u05D5\u05D2'\u05D9",gender:"m"},uuid:{label:"UUID",gender:"m"},nanoid:{label:"nanoid",gender:"m"},guid:{label:"GUID",gender:"m"},cuid:{label:"cuid",gender:"m"},cuid2:{label:"cuid2",gender:"m"},ulid:{label:"ULID",gender:"m"},xid:{label:"XID",gender:"m"},ksuid:{label:"KSUID",gender:"m"},datetime:{label:"\u05EA\u05D0\u05E8\u05D9\u05DA \u05D5\u05D6\u05DE\u05DF ISO",gender:"m"},date:{label:"\u05EA\u05D0\u05E8\u05D9\u05DA ISO",gender:"m"},time:{label:"\u05D6\u05DE\u05DF ISO",gender:"m"},duration:{label:"\u05DE\u05E9\u05DA \u05D6\u05DE\u05DF ISO",gender:"m"},ipv4:{label:"\u05DB\u05EA\u05D5\u05D1\u05EA IPv4",gender:"f"},ipv6:{label:"\u05DB\u05EA\u05D5\u05D1\u05EA IPv6",gender:"f"},cidrv4:{label:"\u05D8\u05D5\u05D5\u05D7 IPv4",gender:"m"},cidrv6:{label:"\u05D8\u05D5\u05D5\u05D7 IPv6",gender:"m"},base64:{label:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D1\u05D1\u05E1\u05D9\u05E1 64",gender:"f"},base64url:{label:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D1\u05D1\u05E1\u05D9\u05E1 64 \u05DC\u05DB\u05EA\u05D5\u05D1\u05D5\u05EA \u05E8\u05E9\u05EA",gender:"f"},json_string:{label:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA JSON",gender:"f"},e164:{label:"\u05DE\u05E1\u05E4\u05E8 E.164",gender:"m"},jwt:{label:"JWT",gender:"m"},ends_with:{label:"\u05E7\u05DC\u05D8",gender:"m"},includes:{label:"\u05E7\u05DC\u05D8",gender:"m"},lowercase:{label:"\u05E7\u05DC\u05D8",gender:"m"},starts_with:{label:"\u05E7\u05DC\u05D8",gender:"m"},uppercase:{label:"\u05E7\u05DC\u05D8",gender:"m"}},c={nan:"NaN"};return(u)=>{switch(u.code){case"invalid_type":{let d=u.expected,p=c[d??""]??o(d),m=le(u.input),h=c[m]??e[m]?.label??m;if(/^[A-Z]/.test(u.expected))return`\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA instanceof ${u.expected}, \u05D4\u05EA\u05E7\u05D1\u05DC ${h}`;return`\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${p}, \u05D4\u05EA\u05E7\u05D1\u05DC ${h}`}case"invalid_value":{if(u.values.length===1)return`\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D4\u05E2\u05E8\u05DA \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA ${ce(u.values[0])}`;let d=u.values.map((h)=>ce(h));if(u.values.length===2)return`\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D4\u05D0\u05E4\u05E9\u05E8\u05D5\u05D9\u05D5\u05EA \u05D4\u05DE\u05EA\u05D0\u05D9\u05DE\u05D5\u05EA \u05D4\u05DF ${d[0]} \u05D0\u05D5 ${d[1]}`;let p=d[d.length-1];return`\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D4\u05D0\u05E4\u05E9\u05E8\u05D5\u05D9\u05D5\u05EA \u05D4\u05DE\u05EA\u05D0\u05D9\u05DE\u05D5\u05EA \u05D4\u05DF ${d.slice(0,-1).join(", ")} \u05D0\u05D5 ${p}`}case"too_big":{let d=s(u.origin),p=n(u.origin??"value");if(u.origin==="string")return`${d?.longLabel??"\u05D0\u05E8\u05D5\u05DA"} \u05DE\u05D3\u05D9: ${p} \u05E6\u05E8\u05D9\u05DB\u05D4 \u05DC\u05D4\u05DB\u05D9\u05DC ${u.maximum.toString()} ${d?.unit??""} ${u.inclusive?"\u05D0\u05D5 \u05E4\u05D7\u05D5\u05EA":"\u05DC\u05DB\u05DC \u05D4\u05D9\u05D5\u05EA\u05E8"}`.trim();if(u.origin==="number"){let b=u.inclusive?`\u05E7\u05D8\u05DF \u05D0\u05D5 \u05E9\u05D5\u05D5\u05D4 \u05DC-${u.maximum}`:`\u05E7\u05D8\u05DF \u05DE-${u.maximum}`;return`\u05D2\u05D3\u05D5\u05DC \u05DE\u05D3\u05D9: ${p} \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${b}`}if(u.origin==="array"||u.origin==="set"){let b=u.origin==="set"?"\u05E6\u05E8\u05D9\u05DB\u05D4":"\u05E6\u05E8\u05D9\u05DA",y=u.inclusive?`${u.maximum} ${d?.unit??""} \u05D0\u05D5 \u05E4\u05D7\u05D5\u05EA`:`\u05E4\u05D7\u05D5\u05EA \u05DE-${u.maximum} ${d?.unit??""}`;return`\u05D2\u05D3\u05D5\u05DC \u05DE\u05D3\u05D9: ${p} ${b} \u05DC\u05D4\u05DB\u05D9\u05DC ${y}`.trim()}let m=u.inclusive?"<=":"<",h=i(u.origin??"value");if(d?.unit)return`${d.longLabel} \u05DE\u05D3\u05D9: ${p} ${h} ${m}${u.maximum.toString()} ${d.unit}`;return`${d?.longLabel??"\u05D2\u05D3\u05D5\u05DC"} \u05DE\u05D3\u05D9: ${p} ${h} ${m}${u.maximum.toString()}`}case"too_small":{let d=s(u.origin),p=n(u.origin??"value");if(u.origin==="string")return`${d?.shortLabel??"\u05E7\u05E6\u05E8"} \u05DE\u05D3\u05D9: ${p} \u05E6\u05E8\u05D9\u05DB\u05D4 \u05DC\u05D4\u05DB\u05D9\u05DC ${u.minimum.toString()} ${d?.unit??""} ${u.inclusive?"\u05D0\u05D5 \u05D9\u05D5\u05EA\u05E8":"\u05DC\u05E4\u05D7\u05D5\u05EA"}`.trim();if(u.origin==="number"){let b=u.inclusive?`\u05D2\u05D3\u05D5\u05DC \u05D0\u05D5 \u05E9\u05D5\u05D5\u05D4 \u05DC-${u.minimum}`:`\u05D2\u05D3\u05D5\u05DC \u05DE-${u.minimum}`;return`\u05E7\u05D8\u05DF \u05DE\u05D3\u05D9: ${p} \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${b}`}if(u.origin==="array"||u.origin==="set"){let b=u.origin==="set"?"\u05E6\u05E8\u05D9\u05DB\u05D4":"\u05E6\u05E8\u05D9\u05DA";if(u.minimum===1&&u.inclusive){let S=u.origin==="set"?"\u05DC\u05E4\u05D7\u05D5\u05EA \u05E4\u05E8\u05D9\u05D8 \u05D0\u05D7\u05D3":"\u05DC\u05E4\u05D7\u05D5\u05EA \u05E4\u05E8\u05D9\u05D8 \u05D0\u05D7\u05D3";return`\u05E7\u05D8\u05DF \u05DE\u05D3\u05D9: ${p} ${b} \u05DC\u05D4\u05DB\u05D9\u05DC ${S}`}let y=u.inclusive?`${u.minimum} ${d?.unit??""} \u05D0\u05D5 \u05D9\u05D5\u05EA\u05E8`:`\u05D9\u05D5\u05EA\u05E8 \u05DE-${u.minimum} ${d?.unit??""}`;return`\u05E7\u05D8\u05DF \u05DE\u05D3\u05D9: ${p} ${b} \u05DC\u05D4\u05DB\u05D9\u05DC ${y}`.trim()}let m=u.inclusive?">=":">",h=i(u.origin??"value");if(d?.unit)return`${d.shortLabel} \u05DE\u05D3\u05D9: ${p} ${h} ${m}${u.minimum.toString()} ${d.unit}`;return`${d?.shortLabel??"\u05E7\u05D8\u05DF"} \u05DE\u05D3\u05D9: ${p} ${h} ${m}${u.minimum.toString()}`}case"invalid_format":{let d=u;if(d.format==="starts_with")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05EA\u05D7\u05D9\u05DC \u05D1 "${d.prefix}"`;if(d.format==="ends_with")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05E1\u05EA\u05D9\u05D9\u05DD \u05D1 "${d.suffix}"`;if(d.format==="includes")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05DB\u05DC\u05D5\u05DC "${d.includes}"`;if(d.format==="regex")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05EA\u05D0\u05D9\u05DD \u05DC\u05EA\u05D1\u05E0\u05D9\u05EA ${d.pattern}`;let p=a[d.format],m=p?.label??d.format,b=(p?.gender??"m")==="f"?"\u05EA\u05E7\u05D9\u05E0\u05D4":"\u05EA\u05E7\u05D9\u05DF";return`${m} \u05DC\u05D0 ${b}`}case"not_multiple_of":return`\u05DE\u05E1\u05E4\u05E8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05DE\u05DB\u05E4\u05DC\u05D4 \u05E9\u05DC ${u.divisor}`;case"unrecognized_keys":return`\u05DE\u05E4\u05EA\u05D7${u.keys.length>1?"\u05D5\u05EA":""} \u05DC\u05D0 \u05DE\u05D6\u05D5\u05D4${u.keys.length>1?"\u05D9\u05DD":"\u05D4"}: ${Q(u.keys,", ")}`;case"invalid_key":return"\u05E9\u05D3\u05D4 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF \u05D1\u05D0\u05D5\u05D1\u05D9\u05D9\u05E7\u05D8";case"invalid_union":return"\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF";case"invalid_element":return`\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF \u05D1${n(u.origin??"array")}`;default:return"\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF"}}};var s1=v(()=>{ke()});function rx(){return{localeError:OJ()}}var OJ=()=>{let e={string:{unit:"znakova",verb:"imati"},file:{unit:"bajtova",verb:"imati"},array:{unit:"stavki",verb:"imati"},set:{unit:"stavki",verb:"imati"}};function t(n){return e[n]??null}let r={regex:"unos",email:"email adresa",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datum i vrijeme",date:"ISO datum",time:"ISO vrijeme",duration:"ISO trajanje",ipv4:"IPv4 adresa",ipv6:"IPv6 adresa",cidrv4:"IPv4 raspon",cidrv6:"IPv6 raspon",base64:"base64 kodirani tekst",base64url:"base64url kodirani tekst",json_string:"JSON tekst",e164:"E.164 broj",jwt:"JWT",template_literal:"unos"},o={nan:"NaN",string:"tekst",number:"broj",boolean:"boolean",array:"niz",object:"objekt",set:"skup",file:"datoteka",date:"datum",bigint:"bigint",symbol:"simbol",undefined:"undefined",null:"null",function:"funkcija",map:"mapa"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`Neispravan unos: o\u010Dekuje se instanceof ${n.expected}, a primljeno je ${a}`;return`Neispravan unos: o\u010Dekuje se ${i}, a primljeno je ${a}`}case"invalid_value":if(n.values.length===1)return`Neispravna vrijednost: o\u010Dekivano ${ce(n.values[0])}`;return`Neispravna opcija: o\u010Dekivano jedno od ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin),a=o[n.origin]??n.origin;if(s)return`Preveliko: o\u010Dekivano da ${a??"vrijednost"} ima ${i}${n.maximum.toString()} ${s.unit??"elemenata"}`;return`Preveliko: o\u010Dekivano da ${a??"vrijednost"} bude ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin),a=o[n.origin]??n.origin;if(s)return`Premalo: o\u010Dekivano da ${a} ima ${i}${n.minimum.toString()} ${s.unit}`;return`Premalo: o\u010Dekivano da ${a} bude ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`Neispravan tekst: mora zapo\u010Dinjati s "${i.prefix}"`;if(i.format==="ends_with")return`Neispravan tekst: mora zavr\u0161avati s "${i.suffix}"`;if(i.format==="includes")return`Neispravan tekst: mora sadr\u017Eavati "${i.includes}"`;if(i.format==="regex")return`Neispravan tekst: mora odgovarati uzorku ${i.pattern}`;return`Neispravna ${r[i.format]??n.format}`}case"not_multiple_of":return`Neispravan broj: mora biti vi\u0161ekratnik od ${n.divisor}`;case"unrecognized_keys":return`Neprepoznat${n.keys.length>1?"i klju\u010Devi":" klju\u010D"}: ${Q(n.keys,", ")}`;case"invalid_key":return`Neispravan klju\u010D u ${o[n.origin]??n.origin}`;case"invalid_union":return"Neispravan unos";case"invalid_element":return`Neispravna vrijednost u ${o[n.origin]??n.origin}`;default:return"Neispravan unos"}}};var a1=v(()=>{ke()});function nx(){return{localeError:CJ()}}var CJ=()=>{let e={string:{unit:"karakter",verb:"legyen"},file:{unit:"byte",verb:"legyen"},array:{unit:"elem",verb:"legyen"},set:{unit:"elem",verb:"legyen"}};function t(n){return e[n]??null}let r={regex:"bemenet",email:"email c\xEDm",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO id\u0151b\xE9lyeg",date:"ISO d\xE1tum",time:"ISO id\u0151",duration:"ISO id\u0151intervallum",ipv4:"IPv4 c\xEDm",ipv6:"IPv6 c\xEDm",cidrv4:"IPv4 tartom\xE1ny",cidrv6:"IPv6 tartom\xE1ny",base64:"base64-k\xF3dolt string",base64url:"base64url-k\xF3dolt string",json_string:"JSON string",e164:"E.164 sz\xE1m",jwt:"JWT",template_literal:"bemenet"},o={nan:"NaN",number:"sz\xE1m",array:"t\xF6mb"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k instanceof ${n.expected}, a kapott \xE9rt\xE9k ${a}`;return`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k ${i}, a kapott \xE9rt\xE9k ${a}`}case"invalid_value":if(n.values.length===1)return`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k ${ce(n.values[0])}`;return`\xC9rv\xE9nytelen opci\xF3: valamelyik \xE9rt\xE9k v\xE1rt ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`T\xFAl nagy: ${n.origin??"\xE9rt\xE9k"} m\xE9rete t\xFAl nagy ${i}${n.maximum.toString()} ${s.unit??"elem"}`;return`T\xFAl nagy: a bemeneti \xE9rt\xE9k ${n.origin??"\xE9rt\xE9k"} t\xFAl nagy: ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`T\xFAl kicsi: a bemeneti \xE9rt\xE9k ${n.origin} m\xE9rete t\xFAl kicsi ${i}${n.minimum.toString()} ${s.unit}`;return`T\xFAl kicsi: a bemeneti \xE9rt\xE9k ${n.origin} t\xFAl kicsi ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`\xC9rv\xE9nytelen string: "${i.prefix}" \xE9rt\xE9kkel kell kezd\u0151dnie`;if(i.format==="ends_with")return`\xC9rv\xE9nytelen string: "${i.suffix}" \xE9rt\xE9kkel kell v\xE9gz\u0151dnie`;if(i.format==="includes")return`\xC9rv\xE9nytelen string: "${i.includes}" \xE9rt\xE9ket kell tartalmaznia`;if(i.format==="regex")return`\xC9rv\xE9nytelen string: ${i.pattern} mint\xE1nak kell megfelelnie`;return`\xC9rv\xE9nytelen ${r[i.format]??n.format}`}case"not_multiple_of":return`\xC9rv\xE9nytelen sz\xE1m: ${n.divisor} t\xF6bbsz\xF6r\xF6s\xE9nek kell lennie`;case"unrecognized_keys":return`Ismeretlen kulcs${n.keys.length>1?"s":""}: ${Q(n.keys,", ")}`;case"invalid_key":return`\xC9rv\xE9nytelen kulcs ${n.origin}`;case"invalid_union":return"\xC9rv\xE9nytelen bemenet";case"invalid_element":return`\xC9rv\xE9nytelen \xE9rt\xE9k: ${n.origin}`;default:return"\xC9rv\xE9nytelen bemenet"}}};var c1=v(()=>{ke()});function l1(e,t,r){return Math.abs(e)===1?t:r}function Ba(e){if(!e)return"";let t=["\u0561","\u0565","\u0568","\u056B","\u0578","\u0578\u0582","\u0585"],r=e[e.length-1];return e+(t.includes(r)?"\u0576":"\u0568")}function ox(){return{localeError:PJ()}}var PJ=()=>{let e={string:{unit:{one:"\u0576\u0577\u0561\u0576",many:"\u0576\u0577\u0561\u0576\u0576\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"},file:{unit:{one:"\u0562\u0561\u0575\u0569",many:"\u0562\u0561\u0575\u0569\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"},array:{unit:{one:"\u057F\u0561\u0580\u0580",many:"\u057F\u0561\u0580\u0580\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"},set:{unit:{one:"\u057F\u0561\u0580\u0580",many:"\u057F\u0561\u0580\u0580\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"}};function t(n){return e[n]??null}let r={regex:"\u0574\u0578\u0582\u057F\u0584",email:"\u0567\u056C. \u0570\u0561\u057D\u0581\u0565",url:"URL",emoji:"\u0567\u0574\u0578\u057B\u056B",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0561\u0574\u057D\u0561\u0569\u056B\u057E \u0587 \u056A\u0561\u0574",date:"ISO \u0561\u0574\u057D\u0561\u0569\u056B\u057E",time:"ISO \u056A\u0561\u0574",duration:"ISO \u057F\u0587\u0578\u0572\u0578\u0582\u0569\u0575\u0578\u0582\u0576",ipv4:"IPv4 \u0570\u0561\u057D\u0581\u0565",ipv6:"IPv6 \u0570\u0561\u057D\u0581\u0565",cidrv4:"IPv4 \u0574\u056B\u057B\u0561\u056F\u0561\u0575\u0584",cidrv6:"IPv6 \u0574\u056B\u057B\u0561\u056F\u0561\u0575\u0584",base64:"base64 \u0571\u0587\u0561\u0579\u0561\u0583\u0578\u057E \u057F\u0578\u0572",base64url:"base64url \u0571\u0587\u0561\u0579\u0561\u0583\u0578\u057E \u057F\u0578\u0572",json_string:"JSON \u057F\u0578\u0572",e164:"E.164 \u0570\u0561\u0574\u0561\u0580",jwt:"JWT",template_literal:"\u0574\u0578\u0582\u057F\u0584"},o={nan:"NaN",number:"\u0569\u056B\u057E",array:"\u0566\u0561\u0576\u0563\u057E\u0561\u056E"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567\u0580 instanceof ${n.expected}, \u057D\u057F\u0561\u0581\u057E\u0565\u056C \u0567 ${a}`;return`\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567\u0580 ${i}, \u057D\u057F\u0561\u0581\u057E\u0565\u056C \u0567 ${a}`}case"invalid_value":if(n.values.length===1)return`\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567\u0580 ${ce(n.values[1])}`;return`\u054D\u056D\u0561\u056C \u057F\u0561\u0580\u0562\u0565\u0580\u0561\u056F\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567\u0580 \u0570\u0565\u057F\u0587\u0575\u0561\u056C\u0576\u0565\u0580\u056B\u0581 \u0574\u0565\u056F\u0568\u055D ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s){let a=Number(n.maximum),c=l1(a,s.unit.one,s.unit.many);return`\u0549\u0561\u0583\u0561\u0566\u0561\u0576\u0581 \u0574\u0565\u056E \u0561\u0580\u056A\u0565\u0584\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567, \u0578\u0580 ${Ba(n.origin??"\u0561\u0580\u056A\u0565\u0584")} \u056F\u0578\u0582\u0576\u0565\u0576\u0561 ${i}${n.maximum.toString()} ${c}`}return`\u0549\u0561\u0583\u0561\u0566\u0561\u0576\u0581 \u0574\u0565\u056E \u0561\u0580\u056A\u0565\u0584\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567, \u0578\u0580 ${Ba(n.origin??"\u0561\u0580\u056A\u0565\u0584")} \u056C\u056B\u0576\u056B ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s){let a=Number(n.minimum),c=l1(a,s.unit.one,s.unit.many);return`\u0549\u0561\u0583\u0561\u0566\u0561\u0576\u0581 \u0583\u0578\u0584\u0580 \u0561\u0580\u056A\u0565\u0584\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567, \u0578\u0580 ${Ba(n.origin)} \u056F\u0578\u0582\u0576\u0565\u0576\u0561 ${i}${n.minimum.toString()} ${c}`}return`\u0549\u0561\u0583\u0561\u0566\u0561\u0576\u0581 \u0583\u0578\u0584\u0580 \u0561\u0580\u056A\u0565\u0584\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567, \u0578\u0580 ${Ba(n.origin)} \u056C\u056B\u0576\u056B ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u057D\u056F\u057D\u057E\u056B "${i.prefix}"-\u0578\u057E`;if(i.format==="ends_with")return`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u0561\u057E\u0561\u0580\u057F\u057E\u056B "${i.suffix}"-\u0578\u057E`;if(i.format==="includes")return`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u057A\u0561\u0580\u0578\u0582\u0576\u0561\u056F\u056B "${i.includes}"`;if(i.format==="regex")return`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u0570\u0561\u0574\u0561\u057A\u0561\u057F\u0561\u057D\u056D\u0561\u0576\u056B ${i.pattern} \u0571\u0587\u0561\u0579\u0561\u0583\u056B\u0576`;return`\u054D\u056D\u0561\u056C ${r[i.format]??n.format}`}case"not_multiple_of":return`\u054D\u056D\u0561\u056C \u0569\u056B\u057E\u2024 \u057A\u0565\u057F\u0584 \u0567 \u0562\u0561\u0566\u0574\u0561\u057A\u0561\u057F\u056B\u056F \u056C\u056B\u0576\u056B ${n.divisor}-\u056B`;case"unrecognized_keys":return`\u0549\u0573\u0561\u0576\u0561\u0579\u057E\u0561\u056E \u0562\u0561\u0576\u0561\u056C\u056B${n.keys.length>1?"\u0576\u0565\u0580":""}. ${Q(n.keys,", ")}`;case"invalid_key":return`\u054D\u056D\u0561\u056C \u0562\u0561\u0576\u0561\u056C\u056B ${Ba(n.origin)}-\u0578\u0582\u0574`;case"invalid_union":return"\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574";case"invalid_element":return`\u054D\u056D\u0561\u056C \u0561\u0580\u056A\u0565\u0584 ${Ba(n.origin)}-\u0578\u0582\u0574`;default:return"\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574"}}};var u1=v(()=>{ke()});function ix(){return{localeError:zJ()}}var zJ=()=>{let e={string:{unit:"karakter",verb:"memiliki"},file:{unit:"byte",verb:"memiliki"},array:{unit:"item",verb:"memiliki"},set:{unit:"item",verb:"memiliki"}};function t(n){return e[n]??null}let r={regex:"input",email:"alamat email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"tanggal dan waktu format ISO",date:"tanggal format ISO",time:"jam format ISO",duration:"durasi format ISO",ipv4:"alamat IPv4",ipv6:"alamat IPv6",cidrv4:"rentang alamat IPv4",cidrv6:"rentang alamat IPv6",base64:"string dengan enkode base64",base64url:"string dengan enkode base64url",json_string:"string JSON",e164:"angka E.164",jwt:"JWT",template_literal:"input"},o={nan:"NaN"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`Input tidak valid: diharapkan instanceof ${n.expected}, diterima ${a}`;return`Input tidak valid: diharapkan ${i}, diterima ${a}`}case"invalid_value":if(n.values.length===1)return`Input tidak valid: diharapkan ${ce(n.values[0])}`;return`Pilihan tidak valid: diharapkan salah satu dari ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`Terlalu besar: diharapkan ${n.origin??"value"} memiliki ${i}${n.maximum.toString()} ${s.unit??"elemen"}`;return`Terlalu besar: diharapkan ${n.origin??"value"} menjadi ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`Terlalu kecil: diharapkan ${n.origin} memiliki ${i}${n.minimum.toString()} ${s.unit}`;return`Terlalu kecil: diharapkan ${n.origin} menjadi ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`String tidak valid: harus dimulai dengan "${i.prefix}"`;if(i.format==="ends_with")return`String tidak valid: harus berakhir dengan "${i.suffix}"`;if(i.format==="includes")return`String tidak valid: harus menyertakan "${i.includes}"`;if(i.format==="regex")return`String tidak valid: harus sesuai pola ${i.pattern}`;return`${r[i.format]??n.format} tidak valid`}case"not_multiple_of":return`Angka tidak valid: harus kelipatan dari ${n.divisor}`;case"unrecognized_keys":return`Kunci tidak dikenali ${n.keys.length>1?"s":""}: ${Q(n.keys,", ")}`;case"invalid_key":return`Kunci tidak valid di ${n.origin}`;case"invalid_union":return"Input tidak valid";case"invalid_element":return`Nilai tidak valid di ${n.origin}`;default:return"Input tidak valid"}}};var d1=v(()=>{ke()});function sx(){return{localeError:NJ()}}var NJ=()=>{let e={string:{unit:"stafi",verb:"a\xF0 hafa"},file:{unit:"b\xE6ti",verb:"a\xF0 hafa"},array:{unit:"hluti",verb:"a\xF0 hafa"},set:{unit:"hluti",verb:"a\xF0 hafa"}};function t(n){return e[n]??null}let r={regex:"gildi",email:"netfang",url:"vefsl\xF3\xF0",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO dagsetning og t\xEDmi",date:"ISO dagsetning",time:"ISO t\xEDmi",duration:"ISO t\xEDmalengd",ipv4:"IPv4 address",ipv6:"IPv6 address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded strengur",base64url:"base64url-encoded strengur",json_string:"JSON strengur",e164:"E.164 t\xF6lugildi",jwt:"JWT",template_literal:"gildi"},o={nan:"NaN",number:"n\xFAmer",array:"fylki"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`Rangt gildi: \xDE\xFA sl\xF3st inn ${a} \xFEar sem \xE1 a\xF0 vera instanceof ${n.expected}`;return`Rangt gildi: \xDE\xFA sl\xF3st inn ${a} \xFEar sem \xE1 a\xF0 vera ${i}`}case"invalid_value":if(n.values.length===1)return`Rangt gildi: gert r\xE1\xF0 fyrir ${ce(n.values[0])}`;return`\xD3gilt val: m\xE1 vera eitt af eftirfarandi ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`Of st\xF3rt: gert er r\xE1\xF0 fyrir a\xF0 ${n.origin??"gildi"} hafi ${i}${n.maximum.toString()} ${s.unit??"hluti"}`;return`Of st\xF3rt: gert er r\xE1\xF0 fyrir a\xF0 ${n.origin??"gildi"} s\xE9 ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`Of l\xEDti\xF0: gert er r\xE1\xF0 fyrir a\xF0 ${n.origin} hafi ${i}${n.minimum.toString()} ${s.unit}`;return`Of l\xEDti\xF0: gert er r\xE1\xF0 fyrir a\xF0 ${n.origin} s\xE9 ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`\xD3gildur strengur: ver\xF0ur a\xF0 byrja \xE1 "${i.prefix}"`;if(i.format==="ends_with")return`\xD3gildur strengur: ver\xF0ur a\xF0 enda \xE1 "${i.suffix}"`;if(i.format==="includes")return`\xD3gildur strengur: ver\xF0ur a\xF0 innihalda "${i.includes}"`;if(i.format==="regex")return`\xD3gildur strengur: ver\xF0ur a\xF0 fylgja mynstri ${i.pattern}`;return`Rangt ${r[i.format]??n.format}`}case"not_multiple_of":return`R\xF6ng tala: ver\xF0ur a\xF0 vera margfeldi af ${n.divisor}`;case"unrecognized_keys":return`\xD3\xFEekkt ${n.keys.length>1?"ir lyklar":"ur lykill"}: ${Q(n.keys,", ")}`;case"invalid_key":return`Rangur lykill \xED ${n.origin}`;case"invalid_union":return"Rangt gildi";case"invalid_element":return`Rangt gildi \xED ${n.origin}`;default:return"Rangt gildi"}}};var p1=v(()=>{ke()});function ax(){return{localeError:DJ()}}var DJ=()=>{let e={string:{unit:"caratteri",verb:"avere"},file:{unit:"byte",verb:"avere"},array:{unit:"elementi",verb:"avere"},set:{unit:"elementi",verb:"avere"}};function t(n){return e[n]??null}let r={regex:"input",email:"indirizzo email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data e ora ISO",date:"data ISO",time:"ora ISO",duration:"durata ISO",ipv4:"indirizzo IPv4",ipv6:"indirizzo IPv6",cidrv4:"intervallo IPv4",cidrv6:"intervallo IPv6",base64:"stringa codificata in base64",base64url:"URL codificata in base64",json_string:"stringa JSON",e164:"numero E.164",jwt:"JWT",template_literal:"input"},o={nan:"NaN",number:"numero",array:"vettore"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`Input non valido: atteso instanceof ${n.expected}, ricevuto ${a}`;return`Input non valido: atteso ${i}, ricevuto ${a}`}case"invalid_value":if(n.values.length===1)return`Input non valido: atteso ${ce(n.values[0])}`;return`Opzione non valida: atteso uno tra ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`Troppo grande: ${n.origin??"valore"} deve avere ${i}${n.maximum.toString()} ${s.unit??"elementi"}`;return`Troppo grande: ${n.origin??"valore"} deve essere ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`Troppo piccolo: ${n.origin} deve avere ${i}${n.minimum.toString()} ${s.unit}`;return`Troppo piccolo: ${n.origin} deve essere ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`Stringa non valida: deve iniziare con "${i.prefix}"`;if(i.format==="ends_with")return`Stringa non valida: deve terminare con "${i.suffix}"`;if(i.format==="includes")return`Stringa non valida: deve includere "${i.includes}"`;if(i.format==="regex")return`Stringa non valida: deve corrispondere al pattern ${i.pattern}`;return`Input non valido: ${r[i.format]??n.format}`}case"not_multiple_of":return`Numero non valido: deve essere un multiplo di ${n.divisor}`;case"unrecognized_keys":return`Chiav${n.keys.length>1?"i":"e"} non riconosciut${n.keys.length>1?"e":"a"}: ${Q(n.keys,", ")}`;case"invalid_key":return`Chiave non valida in ${n.origin}`;case"invalid_union":return"Input non valido";case"invalid_element":return`Valore non valido in ${n.origin}`;default:return"Input non valido"}}};var f1=v(()=>{ke()});function cx(){return{localeError:LJ()}}var LJ=()=>{let e={string:{unit:"\u6587\u5B57",verb:"\u3067\u3042\u308B"},file:{unit:"\u30D0\u30A4\u30C8",verb:"\u3067\u3042\u308B"},array:{unit:"\u8981\u7D20",verb:"\u3067\u3042\u308B"},set:{unit:"\u8981\u7D20",verb:"\u3067\u3042\u308B"}};function t(n){return e[n]??null}let r={regex:"\u5165\u529B\u5024",email:"\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9",url:"URL",emoji:"\u7D75\u6587\u5B57",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO\u65E5\u6642",date:"ISO\u65E5\u4ED8",time:"ISO\u6642\u523B",duration:"ISO\u671F\u9593",ipv4:"IPv4\u30A2\u30C9\u30EC\u30B9",ipv6:"IPv6\u30A2\u30C9\u30EC\u30B9",cidrv4:"IPv4\u7BC4\u56F2",cidrv6:"IPv6\u7BC4\u56F2",base64:"base64\u30A8\u30F3\u30B3\u30FC\u30C9\u6587\u5B57\u5217",base64url:"base64url\u30A8\u30F3\u30B3\u30FC\u30C9\u6587\u5B57\u5217",json_string:"JSON\u6587\u5B57\u5217",e164:"E.164\u756A\u53F7",jwt:"JWT",template_literal:"\u5165\u529B\u5024"},o={nan:"NaN",number:"\u6570\u5024",array:"\u914D\u5217"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`\u7121\u52B9\u306A\u5165\u529B: instanceof ${n.expected}\u304C\u671F\u5F85\u3055\u308C\u307E\u3057\u305F\u304C\u3001${a}\u304C\u5165\u529B\u3055\u308C\u307E\u3057\u305F`;return`\u7121\u52B9\u306A\u5165\u529B: ${i}\u304C\u671F\u5F85\u3055\u308C\u307E\u3057\u305F\u304C\u3001${a}\u304C\u5165\u529B\u3055\u308C\u307E\u3057\u305F`}case"invalid_value":if(n.values.length===1)return`\u7121\u52B9\u306A\u5165\u529B: ${ce(n.values[0])}\u304C\u671F\u5F85\u3055\u308C\u307E\u3057\u305F`;return`\u7121\u52B9\u306A\u9078\u629E: ${Q(n.values,"\u3001")}\u306E\u3044\u305A\u308C\u304B\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;case"too_big":{let i=n.inclusive?"\u4EE5\u4E0B\u3067\u3042\u308B":"\u3088\u308A\u5C0F\u3055\u3044",s=t(n.origin);if(s)return`\u5927\u304D\u3059\u304E\u308B\u5024: ${n.origin??"\u5024"}\u306F${n.maximum.toString()}${s.unit??"\u8981\u7D20"}${i}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;return`\u5927\u304D\u3059\u304E\u308B\u5024: ${n.origin??"\u5024"}\u306F${n.maximum.toString()}${i}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`}case"too_small":{let i=n.inclusive?"\u4EE5\u4E0A\u3067\u3042\u308B":"\u3088\u308A\u5927\u304D\u3044",s=t(n.origin);if(s)return`\u5C0F\u3055\u3059\u304E\u308B\u5024: ${n.origin}\u306F${n.minimum.toString()}${s.unit}${i}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;return`\u5C0F\u3055\u3059\u304E\u308B\u5024: ${n.origin}\u306F${n.minimum.toString()}${i}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${i.prefix}"\u3067\u59CB\u307E\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;if(i.format==="ends_with")return`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${i.suffix}"\u3067\u7D42\u308F\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;if(i.format==="includes")return`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${i.includes}"\u3092\u542B\u3080\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;if(i.format==="regex")return`\u7121\u52B9\u306A\u6587\u5B57\u5217: \u30D1\u30BF\u30FC\u30F3${i.pattern}\u306B\u4E00\u81F4\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;return`\u7121\u52B9\u306A${r[i.format]??n.format}`}case"not_multiple_of":return`\u7121\u52B9\u306A\u6570\u5024: ${n.divisor}\u306E\u500D\u6570\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;case"unrecognized_keys":return`\u8A8D\u8B58\u3055\u308C\u3066\u3044\u306A\u3044\u30AD\u30FC${n.keys.length>1?"\u7FA4":""}: ${Q(n.keys,"\u3001")}`;case"invalid_key":return`${n.origin}\u5185\u306E\u7121\u52B9\u306A\u30AD\u30FC`;case"invalid_union":return"\u7121\u52B9\u306A\u5165\u529B";case"invalid_element":return`${n.origin}\u5185\u306E\u7121\u52B9\u306A\u5024`;default:return"\u7121\u52B9\u306A\u5165\u529B"}}};var m1=v(()=>{ke()});function lx(){return{localeError:BJ()}}var BJ=()=>{let e={string:{unit:"\u10E1\u10D8\u10DB\u10D1\u10DD\u10DA\u10DD",verb:"\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1"},file:{unit:"\u10D1\u10D0\u10D8\u10E2\u10D8",verb:"\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1"},array:{unit:"\u10D4\u10DA\u10D4\u10DB\u10D4\u10DC\u10E2\u10D8",verb:"\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1"},set:{unit:"\u10D4\u10DA\u10D4\u10DB\u10D4\u10DC\u10E2\u10D8",verb:"\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1"}};function t(n){return e[n]??null}let r={regex:"\u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0",email:"\u10D4\u10DA-\u10E4\u10DD\u10E1\u10E2\u10D8\u10E1 \u10DB\u10D8\u10E1\u10D0\u10DB\u10D0\u10E0\u10D7\u10D8",url:"URL",emoji:"\u10D4\u10DB\u10DD\u10EF\u10D8",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u10D7\u10D0\u10E0\u10D8\u10E6\u10D8-\u10D3\u10E0\u10DD",date:"\u10D7\u10D0\u10E0\u10D8\u10E6\u10D8",time:"\u10D3\u10E0\u10DD",duration:"\u10EE\u10D0\u10DC\u10D2\u10E0\u10EB\u10DA\u10D8\u10D5\u10DD\u10D1\u10D0",ipv4:"IPv4 \u10DB\u10D8\u10E1\u10D0\u10DB\u10D0\u10E0\u10D7\u10D8",ipv6:"IPv6 \u10DB\u10D8\u10E1\u10D0\u10DB\u10D0\u10E0\u10D7\u10D8",cidrv4:"IPv4 \u10D3\u10D8\u10D0\u10DE\u10D0\u10D6\u10DD\u10DC\u10D8",cidrv6:"IPv6 \u10D3\u10D8\u10D0\u10DE\u10D0\u10D6\u10DD\u10DC\u10D8",base64:"base64-\u10D9\u10DD\u10D3\u10D8\u10E0\u10D4\u10D1\u10E3\u10DA\u10D8 \u10D5\u10D4\u10DA\u10D8",base64url:"base64url-\u10D9\u10DD\u10D3\u10D8\u10E0\u10D4\u10D1\u10E3\u10DA\u10D8 \u10D5\u10D4\u10DA\u10D8",json_string:"JSON \u10D5\u10D4\u10DA\u10D8",e164:"E.164 \u10DC\u10DD\u10DB\u10D4\u10E0\u10D8",jwt:"JWT",template_literal:"\u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0"},o={nan:"NaN",number:"\u10E0\u10D8\u10EA\u10EE\u10D5\u10D8",string:"\u10D5\u10D4\u10DA\u10D8",boolean:"\u10D1\u10E3\u10DA\u10D4\u10D0\u10DC\u10D8",function:"\u10E4\u10E3\u10DC\u10E5\u10EA\u10D8\u10D0",array:"\u10DB\u10D0\u10E1\u10D8\u10D5\u10D8"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 instanceof ${n.expected}, \u10DB\u10D8\u10E6\u10D4\u10D1\u10E3\u10DA\u10D8 ${a}`;return`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${i}, \u10DB\u10D8\u10E6\u10D4\u10D1\u10E3\u10DA\u10D8 ${a}`}case"invalid_value":if(n.values.length===1)return`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${ce(n.values[0])}`;return`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D5\u10D0\u10E0\u10D8\u10D0\u10DC\u10E2\u10D8: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8\u10D0 \u10D4\u10E0\u10D7-\u10D4\u10E0\u10D7\u10D8 ${Q(n.values,"|")}-\u10D3\u10D0\u10DC`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`\u10D6\u10D4\u10D3\u10DB\u10D4\u10E2\u10D0\u10D3 \u10D3\u10D8\u10D3\u10D8: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${n.origin??"\u10DB\u10DC\u10D8\u10E8\u10D5\u10DC\u10D4\u10DA\u10DD\u10D1\u10D0"} ${s.verb} ${i}${n.maximum.toString()} ${s.unit}`;return`\u10D6\u10D4\u10D3\u10DB\u10D4\u10E2\u10D0\u10D3 \u10D3\u10D8\u10D3\u10D8: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${n.origin??"\u10DB\u10DC\u10D8\u10E8\u10D5\u10DC\u10D4\u10DA\u10DD\u10D1\u10D0"} \u10D8\u10E7\u10DD\u10E1 ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`\u10D6\u10D4\u10D3\u10DB\u10D4\u10E2\u10D0\u10D3 \u10DE\u10D0\u10E2\u10D0\u10E0\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${n.origin} ${s.verb} ${i}${n.minimum.toString()} ${s.unit}`;return`\u10D6\u10D4\u10D3\u10DB\u10D4\u10E2\u10D0\u10D3 \u10DE\u10D0\u10E2\u10D0\u10E0\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${n.origin} \u10D8\u10E7\u10DD\u10E1 ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D5\u10D4\u10DA\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10D8\u10EC\u10E7\u10D4\u10D1\u10DD\u10D3\u10D4\u10E1 "${i.prefix}"-\u10D8\u10D7`;if(i.format==="ends_with")return`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D5\u10D4\u10DA\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10DB\u10D7\u10D0\u10D5\u10E0\u10D3\u10D4\u10D1\u10DD\u10D3\u10D4\u10E1 "${i.suffix}"-\u10D8\u10D7`;if(i.format==="includes")return`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D5\u10D4\u10DA\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1 "${i.includes}"-\u10E1`;if(i.format==="regex")return`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D5\u10D4\u10DA\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D4\u10E1\u10D0\u10D1\u10D0\u10DB\u10D4\u10D1\u10DD\u10D3\u10D4\u10E1 \u10E8\u10D0\u10D1\u10DA\u10DD\u10DC\u10E1 ${i.pattern}`;return`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 ${r[i.format]??n.format}`}case"not_multiple_of":return`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E0\u10D8\u10EA\u10EE\u10D5\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10D8\u10E7\u10DD\u10E1 ${n.divisor}-\u10D8\u10E1 \u10EF\u10D4\u10E0\u10D0\u10D3\u10D8`;case"unrecognized_keys":return`\u10E3\u10EA\u10DC\u10DD\u10D1\u10D8 \u10D2\u10D0\u10E1\u10D0\u10E6\u10D4\u10D1${n.keys.length>1?"\u10D4\u10D1\u10D8":"\u10D8"}: ${Q(n.keys,", ")}`;case"invalid_key":return`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D2\u10D0\u10E1\u10D0\u10E6\u10D4\u10D1\u10D8 ${n.origin}-\u10E8\u10D8`;case"invalid_union":return"\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0";case"invalid_element":return`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10DB\u10DC\u10D8\u10E8\u10D5\u10DC\u10D4\u10DA\u10DD\u10D1\u10D0 ${n.origin}-\u10E8\u10D8`;default:return"\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0"}}};var h1=v(()=>{ke()});function lu(){return{localeError:jJ()}}var jJ=()=>{let e={string:{unit:"\u178F\u17BD\u17A2\u1780\u17D2\u179F\u179A",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"},file:{unit:"\u1794\u17C3",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"},array:{unit:"\u1792\u17B6\u178F\u17BB",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"},set:{unit:"\u1792\u17B6\u178F\u17BB",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"}};function t(n){return e[n]??null}let r={regex:"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B",email:"\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793\u17A2\u17CA\u17B8\u1798\u17C2\u179B",url:"URL",emoji:"\u179F\u1789\u17D2\u1789\u17B6\u17A2\u17B6\u179A\u1798\u17D2\u1798\u178E\u17CD",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u1780\u17B6\u179B\u1794\u179A\u17B7\u1785\u17D2\u1786\u17C1\u1791 \u1793\u17B7\u1784\u1798\u17C9\u17C4\u1784 ISO",date:"\u1780\u17B6\u179B\u1794\u179A\u17B7\u1785\u17D2\u1786\u17C1\u1791 ISO",time:"\u1798\u17C9\u17C4\u1784 ISO",duration:"\u179A\u1799\u17C8\u1796\u17C1\u179B ISO",ipv4:"\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv4",ipv6:"\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv6",cidrv4:"\u178A\u17C2\u1793\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv4",cidrv6:"\u178A\u17C2\u1793\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv6",base64:"\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u17A2\u17CA\u17B7\u1780\u17BC\u178A base64",base64url:"\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u17A2\u17CA\u17B7\u1780\u17BC\u178A base64url",json_string:"\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A JSON",e164:"\u179B\u17C1\u1781 E.164",jwt:"JWT",template_literal:"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B"},o={nan:"NaN",number:"\u179B\u17C1\u1781",array:"\u17A2\u17B6\u179A\u17C1 (Array)",null:"\u1782\u17D2\u1798\u17B6\u1793\u178F\u1798\u17D2\u179B\u17C3 (null)"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A instanceof ${n.expected} \u1794\u17C9\u17BB\u1793\u17D2\u178F\u17C2\u1791\u1791\u17BD\u179B\u1794\u17B6\u1793 ${a}`;return`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${i} \u1794\u17C9\u17BB\u1793\u17D2\u178F\u17C2\u1791\u1791\u17BD\u179B\u1794\u17B6\u1793 ${a}`}case"invalid_value":if(n.values.length===1)return`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${ce(n.values[0])}`;return`\u1787\u1798\u17D2\u179A\u17BE\u179F\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1787\u17B6\u1798\u17BD\u1799\u1780\u17D2\u1793\u17BB\u1784\u1785\u17C6\u178E\u17C4\u1798 ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`\u1792\u17C6\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${n.origin??"\u178F\u1798\u17D2\u179B\u17C3"} ${i} ${n.maximum.toString()} ${s.unit??"\u1792\u17B6\u178F\u17BB"}`;return`\u1792\u17C6\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${n.origin??"\u178F\u1798\u17D2\u179B\u17C3"} ${i} ${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`\u178F\u17BC\u1785\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${n.origin} ${i} ${n.minimum.toString()} ${s.unit}`;return`\u178F\u17BC\u1785\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${n.origin} ${i} ${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1785\u17B6\u1794\u17CB\u1795\u17D2\u178F\u17BE\u1798\u178A\u17C4\u1799 "${i.prefix}"`;if(i.format==="ends_with")return`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1794\u1789\u17D2\u1785\u1794\u17CB\u178A\u17C4\u1799 "${i.suffix}"`;if(i.format==="includes")return`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1798\u17B6\u1793 "${i.includes}"`;if(i.format==="regex")return`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u178F\u17C2\u1795\u17D2\u1782\u17BC\u1795\u17D2\u1782\u1784\u1793\u17B9\u1784\u1791\u1798\u17D2\u179A\u1784\u17CB\u178A\u17C2\u179B\u1794\u17B6\u1793\u1780\u17C6\u178E\u178F\u17CB ${i.pattern}`;return`\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 ${r[i.format]??n.format}`}case"not_multiple_of":return`\u179B\u17C1\u1781\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u178F\u17C2\u1787\u17B6\u1796\u17A0\u17BB\u1782\u17BB\u178E\u1793\u17C3 ${n.divisor}`;case"unrecognized_keys":return`\u179A\u1780\u1783\u17BE\u1789\u179F\u17C4\u1798\u17B7\u1793\u179F\u17D2\u1782\u17B6\u179B\u17CB\u17D6 ${Q(n.keys,", ")}`;case"invalid_key":return`\u179F\u17C4\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u1793\u17C5\u1780\u17D2\u1793\u17BB\u1784 ${n.origin}`;case"invalid_union":return"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C";case"invalid_element":return`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u1793\u17C5\u1780\u17D2\u1793\u17BB\u1784 ${n.origin}`;default:return"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C"}}};var ux=v(()=>{ke()});function dx(){return lu()}var g1=v(()=>{ux()});function px(){return{localeError:ZJ()}}var ZJ=()=>{let e={string:{unit:"\uBB38\uC790",verb:"to have"},file:{unit:"\uBC14\uC774\uD2B8",verb:"to have"},array:{unit:"\uAC1C",verb:"to have"},set:{unit:"\uAC1C",verb:"to have"}};function t(n){return e[n]??null}let r={regex:"\uC785\uB825",email:"\uC774\uBA54\uC77C \uC8FC\uC18C",url:"URL",emoji:"\uC774\uBAA8\uC9C0",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \uB0A0\uC9DC\uC2DC\uAC04",date:"ISO \uB0A0\uC9DC",time:"ISO \uC2DC\uAC04",duration:"ISO \uAE30\uAC04",ipv4:"IPv4 \uC8FC\uC18C",ipv6:"IPv6 \uC8FC\uC18C",cidrv4:"IPv4 \uBC94\uC704",cidrv6:"IPv6 \uBC94\uC704",base64:"base64 \uC778\uCF54\uB529 \uBB38\uC790\uC5F4",base64url:"base64url \uC778\uCF54\uB529 \uBB38\uC790\uC5F4",json_string:"JSON \uBB38\uC790\uC5F4",e164:"E.164 \uBC88\uD638",jwt:"JWT",template_literal:"\uC785\uB825"},o={nan:"NaN"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`\uC798\uBABB\uB41C \uC785\uB825: \uC608\uC0C1 \uD0C0\uC785\uC740 instanceof ${n.expected}, \uBC1B\uC740 \uD0C0\uC785\uC740 ${a}\uC785\uB2C8\uB2E4`;return`\uC798\uBABB\uB41C \uC785\uB825: \uC608\uC0C1 \uD0C0\uC785\uC740 ${i}, \uBC1B\uC740 \uD0C0\uC785\uC740 ${a}\uC785\uB2C8\uB2E4`}case"invalid_value":if(n.values.length===1)return`\uC798\uBABB\uB41C \uC785\uB825: \uAC12\uC740 ${ce(n.values[0])} \uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4`;return`\uC798\uBABB\uB41C \uC635\uC158: ${Q(n.values,"\uB610\uB294 ")} \uC911 \uD558\uB098\uC5EC\uC57C \uD569\uB2C8\uB2E4`;case"too_big":{let i=n.inclusive?"\uC774\uD558":"\uBBF8\uB9CC",s=i==="\uBBF8\uB9CC"?"\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4":"\uC5EC\uC57C \uD569\uB2C8\uB2E4",a=t(n.origin),c=a?.unit??"\uC694\uC18C";if(a)return`${n.origin??"\uAC12"}\uC774 \uB108\uBB34 \uD07D\uB2C8\uB2E4: ${n.maximum.toString()}${c} ${i}${s}`;return`${n.origin??"\uAC12"}\uC774 \uB108\uBB34 \uD07D\uB2C8\uB2E4: ${n.maximum.toString()} ${i}${s}`}case"too_small":{let i=n.inclusive?"\uC774\uC0C1":"\uCD08\uACFC",s=i==="\uC774\uC0C1"?"\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4":"\uC5EC\uC57C \uD569\uB2C8\uB2E4",a=t(n.origin),c=a?.unit??"\uC694\uC18C";if(a)return`${n.origin??"\uAC12"}\uC774 \uB108\uBB34 \uC791\uC2B5\uB2C8\uB2E4: ${n.minimum.toString()}${c} ${i}${s}`;return`${n.origin??"\uAC12"}\uC774 \uB108\uBB34 \uC791\uC2B5\uB2C8\uB2E4: ${n.minimum.toString()} ${i}${s}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${i.prefix}"(\uC73C)\uB85C \uC2DC\uC791\uD574\uC57C \uD569\uB2C8\uB2E4`;if(i.format==="ends_with")return`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${i.suffix}"(\uC73C)\uB85C \uB05D\uB098\uC57C \uD569\uB2C8\uB2E4`;if(i.format==="includes")return`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${i.includes}"\uC744(\uB97C) \uD3EC\uD568\uD574\uC57C \uD569\uB2C8\uB2E4`;if(i.format==="regex")return`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: \uC815\uADDC\uC2DD ${i.pattern} \uD328\uD134\uACFC \uC77C\uCE58\uD574\uC57C \uD569\uB2C8\uB2E4`;return`\uC798\uBABB\uB41C ${r[i.format]??n.format}`}case"not_multiple_of":return`\uC798\uBABB\uB41C \uC22B\uC790: ${n.divisor}\uC758 \uBC30\uC218\uC5EC\uC57C \uD569\uB2C8\uB2E4`;case"unrecognized_keys":return`\uC778\uC2DD\uD560 \uC218 \uC5C6\uB294 \uD0A4: ${Q(n.keys,", ")}`;case"invalid_key":return`\uC798\uBABB\uB41C \uD0A4: ${n.origin}`;case"invalid_union":return"\uC798\uBABB\uB41C \uC785\uB825";case"invalid_element":return`\uC798\uBABB\uB41C \uAC12: ${n.origin}`;default:return"\uC798\uBABB\uB41C \uC785\uB825"}}};var y1=v(()=>{ke()});function b1(e){let t=Math.abs(e),r=t%10,o=t%100;if(o>=11&&o<=19||r===0)return"many";if(r===1)return"one";return"few"}function fx(){return{localeError:UJ()}}var uu=(e)=>e.charAt(0).toUpperCase()+e.slice(1),UJ=()=>{let e={string:{unit:{one:"simbolis",few:"simboliai",many:"simboli\u0173"},verb:{smaller:{inclusive:"turi b\u016Bti ne ilgesn\u0117 kaip",notInclusive:"turi b\u016Bti trumpesn\u0117 kaip"},bigger:{inclusive:"turi b\u016Bti ne trumpesn\u0117 kaip",notInclusive:"turi b\u016Bti ilgesn\u0117 kaip"}}},file:{unit:{one:"baitas",few:"baitai",many:"bait\u0173"},verb:{smaller:{inclusive:"turi b\u016Bti ne didesnis kaip",notInclusive:"turi b\u016Bti ma\u017Eesnis kaip"},bigger:{inclusive:"turi b\u016Bti ne ma\u017Eesnis kaip",notInclusive:"turi b\u016Bti didesnis kaip"}}},array:{unit:{one:"element\u0105",few:"elementus",many:"element\u0173"},verb:{smaller:{inclusive:"turi tur\u0117ti ne daugiau kaip",notInclusive:"turi tur\u0117ti ma\u017Eiau kaip"},bigger:{inclusive:"turi tur\u0117ti ne ma\u017Eiau kaip",notInclusive:"turi tur\u0117ti daugiau kaip"}}},set:{unit:{one:"element\u0105",few:"elementus",many:"element\u0173"},verb:{smaller:{inclusive:"turi tur\u0117ti ne daugiau kaip",notInclusive:"turi tur\u0117ti ma\u017Eiau kaip"},bigger:{inclusive:"turi tur\u0117ti ne ma\u017Eiau kaip",notInclusive:"turi tur\u0117ti daugiau kaip"}}}};function t(n,i,s,a){let c=e[n]??null;if(c===null)return c;return{unit:c.unit[i],verb:c.verb[a][s?"inclusive":"notInclusive"]}}let r={regex:"\u012Fvestis",email:"el. pa\u0161to adresas",url:"URL",emoji:"jaustukas",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO data ir laikas",date:"ISO data",time:"ISO laikas",duration:"ISO trukm\u0117",ipv4:"IPv4 adresas",ipv6:"IPv6 adresas",cidrv4:"IPv4 tinklo prefiksas (CIDR)",cidrv6:"IPv6 tinklo prefiksas (CIDR)",base64:"base64 u\u017Ekoduota eilut\u0117",base64url:"base64url u\u017Ekoduota eilut\u0117",json_string:"JSON eilut\u0117",e164:"E.164 numeris",jwt:"JWT",template_literal:"\u012Fvestis"},o={nan:"NaN",number:"skai\u010Dius",bigint:"sveikasis skai\u010Dius",string:"eilut\u0117",boolean:"login\u0117 reik\u0161m\u0117",undefined:"neapibr\u0117\u017Eta reik\u0161m\u0117",function:"funkcija",symbol:"simbolis",array:"masyvas",object:"objektas",null:"nulin\u0117 reik\u0161m\u0117"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`Gautas tipas ${a}, o tik\u0117tasi - instanceof ${n.expected}`;return`Gautas tipas ${a}, o tik\u0117tasi - ${i}`}case"invalid_value":if(n.values.length===1)return`Privalo b\u016Bti ${ce(n.values[0])}`;return`Privalo b\u016Bti vienas i\u0161 ${Q(n.values,"|")} pasirinkim\u0173`;case"too_big":{let i=o[n.origin]??n.origin,s=t(n.origin,b1(Number(n.maximum)),n.inclusive??!1,"smaller");if(s?.verb)return`${uu(i??n.origin??"reik\u0161m\u0117")} ${s.verb} ${n.maximum.toString()} ${s.unit??"element\u0173"}`;let a=n.inclusive?"ne didesnis kaip":"ma\u017Eesnis kaip";return`${uu(i??n.origin??"reik\u0161m\u0117")} turi b\u016Bti ${a} ${n.maximum.toString()} ${s?.unit}`}case"too_small":{let i=o[n.origin]??n.origin,s=t(n.origin,b1(Number(n.minimum)),n.inclusive??!1,"bigger");if(s?.verb)return`${uu(i??n.origin??"reik\u0161m\u0117")} ${s.verb} ${n.minimum.toString()} ${s.unit??"element\u0173"}`;let a=n.inclusive?"ne ma\u017Eesnis kaip":"didesnis kaip";return`${uu(i??n.origin??"reik\u0161m\u0117")} turi b\u016Bti ${a} ${n.minimum.toString()} ${s?.unit}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`Eilut\u0117 privalo prasid\u0117ti "${i.prefix}"`;if(i.format==="ends_with")return`Eilut\u0117 privalo pasibaigti "${i.suffix}"`;if(i.format==="includes")return`Eilut\u0117 privalo \u012Ftraukti "${i.includes}"`;if(i.format==="regex")return`Eilut\u0117 privalo atitikti ${i.pattern}`;return`Neteisingas ${r[i.format]??n.format}`}case"not_multiple_of":return`Skai\u010Dius privalo b\u016Bti ${n.divisor} kartotinis.`;case"unrecognized_keys":return`Neatpa\u017Eint${n.keys.length>1?"i":"as"} rakt${n.keys.length>1?"ai":"as"}: ${Q(n.keys,", ")}`;case"invalid_key":return"Rastas klaidingas raktas";case"invalid_union":return"Klaidinga \u012Fvestis";case"invalid_element":{let i=o[n.origin]??n.origin;return`${uu(i??n.origin??"reik\u0161m\u0117")} turi klaiding\u0105 \u012Fvest\u012F`}default:return"Klaidinga \u012Fvestis"}}};var S1=v(()=>{ke()});function mx(){return{localeError:MJ()}}var MJ=()=>{let e={string:{unit:"\u0437\u043D\u0430\u0446\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"},file:{unit:"\u0431\u0430\u0458\u0442\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"},array:{unit:"\u0441\u0442\u0430\u0432\u043A\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"},set:{unit:"\u0441\u0442\u0430\u0432\u043A\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"}};function t(n){return e[n]??null}let r={regex:"\u0432\u043D\u0435\u0441",email:"\u0430\u0434\u0440\u0435\u0441\u0430 \u043D\u0430 \u0435-\u043F\u043E\u0448\u0442\u0430",url:"URL",emoji:"\u0435\u043C\u043E\u045F\u0438",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0434\u0430\u0442\u0443\u043C \u0438 \u0432\u0440\u0435\u043C\u0435",date:"ISO \u0434\u0430\u0442\u0443\u043C",time:"ISO \u0432\u0440\u0435\u043C\u0435",duration:"ISO \u0432\u0440\u0435\u043C\u0435\u0442\u0440\u0430\u0435\u045A\u0435",ipv4:"IPv4 \u0430\u0434\u0440\u0435\u0441\u0430",ipv6:"IPv6 \u0430\u0434\u0440\u0435\u0441\u0430",cidrv4:"IPv4 \u043E\u043F\u0441\u0435\u0433",cidrv6:"IPv6 \u043E\u043F\u0441\u0435\u0433",base64:"base64-\u0435\u043D\u043A\u043E\u0434\u0438\u0440\u0430\u043D\u0430 \u043D\u0438\u0437\u0430",base64url:"base64url-\u0435\u043D\u043A\u043E\u0434\u0438\u0440\u0430\u043D\u0430 \u043D\u0438\u0437\u0430",json_string:"JSON \u043D\u0438\u0437\u0430",e164:"E.164 \u0431\u0440\u043E\u0458",jwt:"JWT",template_literal:"\u0432\u043D\u0435\u0441"},o={nan:"NaN",number:"\u0431\u0440\u043E\u0458",array:"\u043D\u0438\u0437\u0430"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 instanceof ${n.expected}, \u043F\u0440\u0438\u043C\u0435\u043D\u043E ${a}`;return`\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${i}, \u043F\u0440\u0438\u043C\u0435\u043D\u043E ${a}`}case"invalid_value":if(n.values.length===1)return`Invalid input: expected ${ce(n.values[0])}`;return`\u0413\u0440\u0435\u0448\u0430\u043D\u0430 \u043E\u043F\u0446\u0438\u0458\u0430: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 \u0435\u0434\u043D\u0430 ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u0433\u043E\u043B\u0435\u043C: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${n.origin??"\u0432\u0440\u0435\u0434\u043D\u043E\u0441\u0442\u0430"} \u0434\u0430 \u0438\u043C\u0430 ${i}${n.maximum.toString()} ${s.unit??"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0438"}`;return`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u0433\u043E\u043B\u0435\u043C: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${n.origin??"\u0432\u0440\u0435\u0434\u043D\u043E\u0441\u0442\u0430"} \u0434\u0430 \u0431\u0438\u0434\u0435 ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u043C\u0430\u043B: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${n.origin} \u0434\u0430 \u0438\u043C\u0430 ${i}${n.minimum.toString()} ${s.unit}`;return`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u043C\u0430\u043B: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${n.origin} \u0434\u0430 \u0431\u0438\u0434\u0435 ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0437\u0430\u043F\u043E\u0447\u043D\u0443\u0432\u0430 \u0441\u043E "${i.prefix}"`;if(i.format==="ends_with")return`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0437\u0430\u0432\u0440\u0448\u0443\u0432\u0430 \u0441\u043E "${i.suffix}"`;if(i.format==="includes")return`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0432\u043A\u043B\u0443\u0447\u0443\u0432\u0430 "${i.includes}"`;if(i.format==="regex")return`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u043E\u0434\u0433\u043E\u0430\u0440\u0430 \u043D\u0430 \u043F\u0430\u0442\u0435\u0440\u043D\u043E\u0442 ${i.pattern}`;return`Invalid ${r[i.format]??n.format}`}case"not_multiple_of":return`\u0413\u0440\u0435\u0448\u0435\u043D \u0431\u0440\u043E\u0458: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0431\u0438\u0434\u0435 \u0434\u0435\u043B\u0438\u0432 \u0441\u043E ${n.divisor}`;case"unrecognized_keys":return`${n.keys.length>1?"\u041D\u0435\u043F\u0440\u0435\u043F\u043E\u0437\u043D\u0430\u0435\u043D\u0438 \u043A\u043B\u0443\u0447\u0435\u0432\u0438":"\u041D\u0435\u043F\u0440\u0435\u043F\u043E\u0437\u043D\u0430\u0435\u043D \u043A\u043B\u0443\u0447"}: ${Q(n.keys,", ")}`;case"invalid_key":return`\u0413\u0440\u0435\u0448\u0435\u043D \u043A\u043B\u0443\u0447 \u0432\u043E ${n.origin}`;case"invalid_union":return"\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441";case"invalid_element":return`\u0413\u0440\u0435\u0448\u043D\u0430 \u0432\u0440\u0435\u0434\u043D\u043E\u0441\u0442 \u0432\u043E ${n.origin}`;default:return"\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441"}}};var v1=v(()=>{ke()});function hx(){return{localeError:qJ()}}var qJ=()=>{let e={string:{unit:"aksara",verb:"mempunyai"},file:{unit:"bait",verb:"mempunyai"},array:{unit:"elemen",verb:"mempunyai"},set:{unit:"elemen",verb:"mempunyai"}};function t(n){return e[n]??null}let r={regex:"input",email:"alamat e-mel",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"tarikh masa ISO",date:"tarikh ISO",time:"masa ISO",duration:"tempoh ISO",ipv4:"alamat IPv4",ipv6:"alamat IPv6",cidrv4:"julat IPv4",cidrv6:"julat IPv6",base64:"string dikodkan base64",base64url:"string dikodkan base64url",json_string:"string JSON",e164:"nombor E.164",jwt:"JWT",template_literal:"input"},o={nan:"NaN",number:"nombor"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`Input tidak sah: dijangka instanceof ${n.expected}, diterima ${a}`;return`Input tidak sah: dijangka ${i}, diterima ${a}`}case"invalid_value":if(n.values.length===1)return`Input tidak sah: dijangka ${ce(n.values[0])}`;return`Pilihan tidak sah: dijangka salah satu daripada ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`Terlalu besar: dijangka ${n.origin??"nilai"} ${s.verb} ${i}${n.maximum.toString()} ${s.unit??"elemen"}`;return`Terlalu besar: dijangka ${n.origin??"nilai"} adalah ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`Terlalu kecil: dijangka ${n.origin} ${s.verb} ${i}${n.minimum.toString()} ${s.unit}`;return`Terlalu kecil: dijangka ${n.origin} adalah ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`String tidak sah: mesti bermula dengan "${i.prefix}"`;if(i.format==="ends_with")return`String tidak sah: mesti berakhir dengan "${i.suffix}"`;if(i.format==="includes")return`String tidak sah: mesti mengandungi "${i.includes}"`;if(i.format==="regex")return`String tidak sah: mesti sepadan dengan corak ${i.pattern}`;return`${r[i.format]??n.format} tidak sah`}case"not_multiple_of":return`Nombor tidak sah: perlu gandaan ${n.divisor}`;case"unrecognized_keys":return`Kunci tidak dikenali: ${Q(n.keys,", ")}`;case"invalid_key":return`Kunci tidak sah dalam ${n.origin}`;case"invalid_union":return"Input tidak sah";case"invalid_element":return`Nilai tidak sah dalam ${n.origin}`;default:return"Input tidak sah"}}};var w1=v(()=>{ke()});function gx(){return{localeError:FJ()}}var FJ=()=>{let e={string:{unit:"tekens",verb:"heeft"},file:{unit:"bytes",verb:"heeft"},array:{unit:"elementen",verb:"heeft"},set:{unit:"elementen",verb:"heeft"}};function t(n){return e[n]??null}let r={regex:"invoer",email:"emailadres",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datum en tijd",date:"ISO datum",time:"ISO tijd",duration:"ISO duur",ipv4:"IPv4-adres",ipv6:"IPv6-adres",cidrv4:"IPv4-bereik",cidrv6:"IPv6-bereik",base64:"base64-gecodeerde tekst",base64url:"base64 URL-gecodeerde tekst",json_string:"JSON string",e164:"E.164-nummer",jwt:"JWT",template_literal:"invoer"},o={nan:"NaN",number:"getal"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`Ongeldige invoer: verwacht instanceof ${n.expected}, ontving ${a}`;return`Ongeldige invoer: verwacht ${i}, ontving ${a}`}case"invalid_value":if(n.values.length===1)return`Ongeldige invoer: verwacht ${ce(n.values[0])}`;return`Ongeldige optie: verwacht \xE9\xE9n van ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin),a=n.origin==="date"?"laat":n.origin==="string"?"lang":"groot";if(s)return`Te ${a}: verwacht dat ${n.origin??"waarde"} ${i}${n.maximum.toString()} ${s.unit??"elementen"} ${s.verb}`;return`Te ${a}: verwacht dat ${n.origin??"waarde"} ${i}${n.maximum.toString()} is`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin),a=n.origin==="date"?"vroeg":n.origin==="string"?"kort":"klein";if(s)return`Te ${a}: verwacht dat ${n.origin} ${i}${n.minimum.toString()} ${s.unit} ${s.verb}`;return`Te ${a}: verwacht dat ${n.origin} ${i}${n.minimum.toString()} is`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`Ongeldige tekst: moet met "${i.prefix}" beginnen`;if(i.format==="ends_with")return`Ongeldige tekst: moet op "${i.suffix}" eindigen`;if(i.format==="includes")return`Ongeldige tekst: moet "${i.includes}" bevatten`;if(i.format==="regex")return`Ongeldige tekst: moet overeenkomen met patroon ${i.pattern}`;return`Ongeldig: ${r[i.format]??n.format}`}case"not_multiple_of":return`Ongeldig getal: moet een veelvoud van ${n.divisor} zijn`;case"unrecognized_keys":return`Onbekende key${n.keys.length>1?"s":""}: ${Q(n.keys,", ")}`;case"invalid_key":return`Ongeldige key in ${n.origin}`;case"invalid_union":return"Ongeldige invoer";case"invalid_element":return`Ongeldige waarde in ${n.origin}`;default:return"Ongeldige invoer"}}};var x1=v(()=>{ke()});function yx(){return{localeError:KJ()}}var KJ=()=>{let e={string:{unit:"tegn",verb:"\xE5 ha"},file:{unit:"bytes",verb:"\xE5 ha"},array:{unit:"elementer",verb:"\xE5 inneholde"},set:{unit:"elementer",verb:"\xE5 inneholde"}};function t(n){return e[n]??null}let r={regex:"input",email:"e-postadresse",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO dato- og klokkeslett",date:"ISO-dato",time:"ISO-klokkeslett",duration:"ISO-varighet",ipv4:"IPv4-omr\xE5de",ipv6:"IPv6-omr\xE5de",cidrv4:"IPv4-spekter",cidrv6:"IPv6-spekter",base64:"base64-enkodet streng",base64url:"base64url-enkodet streng",json_string:"JSON-streng",e164:"E.164-nummer",jwt:"JWT",template_literal:"input"},o={nan:"NaN",number:"tall",array:"liste"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`Ugyldig input: forventet instanceof ${n.expected}, fikk ${a}`;return`Ugyldig input: forventet ${i}, fikk ${a}`}case"invalid_value":if(n.values.length===1)return`Ugyldig verdi: forventet ${ce(n.values[0])}`;return`Ugyldig valg: forventet en av ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`For stor(t): forventet ${n.origin??"value"} til \xE5 ha ${i}${n.maximum.toString()} ${s.unit??"elementer"}`;return`For stor(t): forventet ${n.origin??"value"} til \xE5 ha ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`For lite(n): forventet ${n.origin} til \xE5 ha ${i}${n.minimum.toString()} ${s.unit}`;return`For lite(n): forventet ${n.origin} til \xE5 ha ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`Ugyldig streng: m\xE5 starte med "${i.prefix}"`;if(i.format==="ends_with")return`Ugyldig streng: m\xE5 ende med "${i.suffix}"`;if(i.format==="includes")return`Ugyldig streng: m\xE5 inneholde "${i.includes}"`;if(i.format==="regex")return`Ugyldig streng: m\xE5 matche m\xF8nsteret ${i.pattern}`;return`Ugyldig ${r[i.format]??n.format}`}case"not_multiple_of":return`Ugyldig tall: m\xE5 v\xE6re et multiplum av ${n.divisor}`;case"unrecognized_keys":return`${n.keys.length>1?"Ukjente n\xF8kler":"Ukjent n\xF8kkel"}: ${Q(n.keys,", ")}`;case"invalid_key":return`Ugyldig n\xF8kkel i ${n.origin}`;case"invalid_union":return"Ugyldig input";case"invalid_element":return`Ugyldig verdi i ${n.origin}`;default:return"Ugyldig input"}}};var _1=v(()=>{ke()});function bx(){return{localeError:HJ()}}var HJ=()=>{let e={string:{unit:"harf",verb:"olmal\u0131d\u0131r"},file:{unit:"bayt",verb:"olmal\u0131d\u0131r"},array:{unit:"unsur",verb:"olmal\u0131d\u0131r"},set:{unit:"unsur",verb:"olmal\u0131d\u0131r"}};function t(n){return e[n]??null}let r={regex:"giren",email:"epostag\xE2h",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO heng\xE2m\u0131",date:"ISO tarihi",time:"ISO zaman\u0131",duration:"ISO m\xFCddeti",ipv4:"IPv4 ni\u015F\xE2n\u0131",ipv6:"IPv6 ni\u015F\xE2n\u0131",cidrv4:"IPv4 menzili",cidrv6:"IPv6 menzili",base64:"base64-\u015Fifreli metin",base64url:"base64url-\u015Fifreli metin",json_string:"JSON metin",e164:"E.164 say\u0131s\u0131",jwt:"JWT",template_literal:"giren"},o={nan:"NaN",number:"numara",array:"saf",null:"gayb"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`F\xE2sit giren: umulan instanceof ${n.expected}, al\u0131nan ${a}`;return`F\xE2sit giren: umulan ${i}, al\u0131nan ${a}`}case"invalid_value":if(n.values.length===1)return`F\xE2sit giren: umulan ${ce(n.values[0])}`;return`F\xE2sit tercih: m\xFBteberler ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`Fazla b\xFCy\xFCk: ${n.origin??"value"}, ${i}${n.maximum.toString()} ${s.unit??"elements"} sahip olmal\u0131yd\u0131.`;return`Fazla b\xFCy\xFCk: ${n.origin??"value"}, ${i}${n.maximum.toString()} olmal\u0131yd\u0131.`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`Fazla k\xFC\xE7\xFCk: ${n.origin}, ${i}${n.minimum.toString()} ${s.unit} sahip olmal\u0131yd\u0131.`;return`Fazla k\xFC\xE7\xFCk: ${n.origin}, ${i}${n.minimum.toString()} olmal\u0131yd\u0131.`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`F\xE2sit metin: "${i.prefix}" ile ba\u015Flamal\u0131.`;if(i.format==="ends_with")return`F\xE2sit metin: "${i.suffix}" ile bitmeli.`;if(i.format==="includes")return`F\xE2sit metin: "${i.includes}" ihtiv\xE2 etmeli.`;if(i.format==="regex")return`F\xE2sit metin: ${i.pattern} nak\u015F\u0131na uymal\u0131.`;return`F\xE2sit ${r[i.format]??n.format}`}case"not_multiple_of":return`F\xE2sit say\u0131: ${n.divisor} kat\u0131 olmal\u0131yd\u0131.`;case"unrecognized_keys":return`Tan\u0131nmayan anahtar ${n.keys.length>1?"s":""}: ${Q(n.keys,", ")}`;case"invalid_key":return`${n.origin} i\xE7in tan\u0131nmayan anahtar var.`;case"invalid_union":return"Giren tan\u0131namad\u0131.";case"invalid_element":return`${n.origin} i\xE7in tan\u0131nmayan k\u0131ymet var.`;default:return"K\u0131ymet tan\u0131namad\u0131."}}};var E1=v(()=>{ke()});function Sx(){return{localeError:JJ()}}var JJ=()=>{let e={string:{unit:"\u062A\u0648\u06A9\u064A",verb:"\u0648\u0644\u0631\u064A"},file:{unit:"\u0628\u0627\u06CC\u067C\u0633",verb:"\u0648\u0644\u0631\u064A"},array:{unit:"\u062A\u0648\u06A9\u064A",verb:"\u0648\u0644\u0631\u064A"},set:{unit:"\u062A\u0648\u06A9\u064A",verb:"\u0648\u0644\u0631\u064A"}};function t(n){return e[n]??null}let r={regex:"\u0648\u0631\u0648\u062F\u064A",email:"\u0628\u0631\u06CC\u069A\u0646\u0627\u0644\u06CC\u06A9",url:"\u06CC\u0648 \u0622\u0631 \u0627\u0644",emoji:"\u0627\u06CC\u0645\u0648\u062C\u064A",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u0646\u06CC\u067C\u0647 \u0627\u0648 \u0648\u062E\u062A",date:"\u0646\u06D0\u067C\u0647",time:"\u0648\u062E\u062A",duration:"\u0645\u0648\u062F\u0647",ipv4:"\u062F IPv4 \u067E\u062A\u0647",ipv6:"\u062F IPv6 \u067E\u062A\u0647",cidrv4:"\u062F IPv4 \u0633\u0627\u062D\u0647",cidrv6:"\u062F IPv6 \u0633\u0627\u062D\u0647",base64:"base64-encoded \u0645\u062A\u0646",base64url:"base64url-encoded \u0645\u062A\u0646",json_string:"JSON \u0645\u062A\u0646",e164:"\u062F E.164 \u0634\u0645\u06D0\u0631\u0647",jwt:"JWT",template_literal:"\u0648\u0631\u0648\u062F\u064A"},o={nan:"NaN",number:"\u0639\u062F\u062F",array:"\u0627\u0631\u06D0"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`\u0646\u0627\u0633\u0645 \u0648\u0631\u0648\u062F\u064A: \u0628\u0627\u06CC\u062F instanceof ${n.expected} \u0648\u0627\u06CC, \u0645\u06AB\u0631 ${a} \u062A\u0631\u0644\u0627\u0633\u0647 \u0634\u0648`;return`\u0646\u0627\u0633\u0645 \u0648\u0631\u0648\u062F\u064A: \u0628\u0627\u06CC\u062F ${i} \u0648\u0627\u06CC, \u0645\u06AB\u0631 ${a} \u062A\u0631\u0644\u0627\u0633\u0647 \u0634\u0648`}case"invalid_value":if(n.values.length===1)return`\u0646\u0627\u0633\u0645 \u0648\u0631\u0648\u062F\u064A: \u0628\u0627\u06CC\u062F ${ce(n.values[0])} \u0648\u0627\u06CC`;return`\u0646\u0627\u0633\u0645 \u0627\u0646\u062A\u062E\u0627\u0628: \u0628\u0627\u06CC\u062F \u06CC\u0648 \u0644\u0647 ${Q(n.values,"|")} \u0685\u062E\u0647 \u0648\u0627\u06CC`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`\u0689\u06CC\u0631 \u0644\u0648\u06CC: ${n.origin??"\u0627\u0631\u0632\u069A\u062A"} \u0628\u0627\u06CC\u062F ${i}${n.maximum.toString()} ${s.unit??"\u0639\u0646\u0635\u0631\u0648\u0646\u0647"} \u0648\u0644\u0631\u064A`;return`\u0689\u06CC\u0631 \u0644\u0648\u06CC: ${n.origin??"\u0627\u0631\u0632\u069A\u062A"} \u0628\u0627\u06CC\u062F ${i}${n.maximum.toString()} \u0648\u064A`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`\u0689\u06CC\u0631 \u06A9\u0648\u0686\u0646\u06CC: ${n.origin} \u0628\u0627\u06CC\u062F ${i}${n.minimum.toString()} ${s.unit} \u0648\u0644\u0631\u064A`;return`\u0689\u06CC\u0631 \u06A9\u0648\u0686\u0646\u06CC: ${n.origin} \u0628\u0627\u06CC\u062F ${i}${n.minimum.toString()} \u0648\u064A`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F \u062F "${i.prefix}" \u0633\u0631\u0647 \u067E\u06CC\u0644 \u0634\u064A`;if(i.format==="ends_with")return`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F \u062F "${i.suffix}" \u0633\u0631\u0647 \u067E\u0627\u06CC \u062A\u0647 \u0648\u0631\u0633\u064A\u0696\u064A`;if(i.format==="includes")return`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F "${i.includes}" \u0648\u0644\u0631\u064A`;if(i.format==="regex")return`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F \u062F ${i.pattern} \u0633\u0631\u0647 \u0645\u0637\u0627\u0628\u0642\u062A \u0648\u0644\u0631\u064A`;return`${r[i.format]??n.format} \u0646\u0627\u0633\u0645 \u062F\u06CC`}case"not_multiple_of":return`\u0646\u0627\u0633\u0645 \u0639\u062F\u062F: \u0628\u0627\u06CC\u062F \u062F ${n.divisor} \u0645\u0636\u0631\u0628 \u0648\u064A`;case"unrecognized_keys":return`\u0646\u0627\u0633\u0645 ${n.keys.length>1?"\u06A9\u0644\u06CC\u0689\u0648\u0646\u0647":"\u06A9\u0644\u06CC\u0689"}: ${Q(n.keys,", ")}`;case"invalid_key":return`\u0646\u0627\u0633\u0645 \u06A9\u0644\u06CC\u0689 \u067E\u0647 ${n.origin} \u06A9\u06D0`;case"invalid_union":return"\u0646\u0627\u0633\u0645\u0647 \u0648\u0631\u0648\u062F\u064A";case"invalid_element":return`\u0646\u0627\u0633\u0645 \u0639\u0646\u0635\u0631 \u067E\u0647 ${n.origin} \u06A9\u06D0`;default:return"\u0646\u0627\u0633\u0645\u0647 \u0648\u0631\u0648\u062F\u064A"}}};var k1=v(()=>{ke()});function vx(){return{localeError:VJ()}}var VJ=()=>{let e={string:{unit:"znak\xF3w",verb:"mie\u0107"},file:{unit:"bajt\xF3w",verb:"mie\u0107"},array:{unit:"element\xF3w",verb:"mie\u0107"},set:{unit:"element\xF3w",verb:"mie\u0107"}};function t(n){return e[n]??null}let r={regex:"wyra\u017Cenie",email:"adres email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data i godzina w formacie ISO",date:"data w formacie ISO",time:"godzina w formacie ISO",duration:"czas trwania ISO",ipv4:"adres IPv4",ipv6:"adres IPv6",cidrv4:"zakres IPv4",cidrv6:"zakres IPv6",base64:"ci\u0105g znak\xF3w zakodowany w formacie base64",base64url:"ci\u0105g znak\xF3w zakodowany w formacie base64url",json_string:"ci\u0105g znak\xF3w w formacie JSON",e164:"liczba E.164",jwt:"JWT",template_literal:"wej\u015Bcie"},o={nan:"NaN",number:"liczba",array:"tablica"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano instanceof ${n.expected}, otrzymano ${a}`;return`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano ${i}, otrzymano ${a}`}case"invalid_value":if(n.values.length===1)return`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano ${ce(n.values[0])}`;return`Nieprawid\u0142owa opcja: oczekiwano jednej z warto\u015Bci ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`Za du\u017Ca warto\u015B\u0107: oczekiwano, \u017Ce ${n.origin??"warto\u015B\u0107"} b\u0119dzie mie\u0107 ${i}${n.maximum.toString()} ${s.unit??"element\xF3w"}`;return`Zbyt du\u017C(y/a/e): oczekiwano, \u017Ce ${n.origin??"warto\u015B\u0107"} b\u0119dzie wynosi\u0107 ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`Za ma\u0142a warto\u015B\u0107: oczekiwano, \u017Ce ${n.origin??"warto\u015B\u0107"} b\u0119dzie mie\u0107 ${i}${n.minimum.toString()} ${s.unit??"element\xF3w"}`;return`Zbyt ma\u0142(y/a/e): oczekiwano, \u017Ce ${n.origin??"warto\u015B\u0107"} b\u0119dzie wynosi\u0107 ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi zaczyna\u0107 si\u0119 od "${i.prefix}"`;if(i.format==="ends_with")return`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi ko\u0144czy\u0107 si\u0119 na "${i.suffix}"`;if(i.format==="includes")return`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi zawiera\u0107 "${i.includes}"`;if(i.format==="regex")return`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi odpowiada\u0107 wzorcowi ${i.pattern}`;return`Nieprawid\u0142ow(y/a/e) ${r[i.format]??n.format}`}case"not_multiple_of":return`Nieprawid\u0142owa liczba: musi by\u0107 wielokrotno\u015Bci\u0105 ${n.divisor}`;case"unrecognized_keys":return`Nierozpoznane klucze${n.keys.length>1?"s":""}: ${Q(n.keys,", ")}`;case"invalid_key":return`Nieprawid\u0142owy klucz w ${n.origin}`;case"invalid_union":return"Nieprawid\u0142owe dane wej\u015Bciowe";case"invalid_element":return`Nieprawid\u0142owa warto\u015B\u0107 w ${n.origin}`;default:return"Nieprawid\u0142owe dane wej\u015Bciowe"}}};var I1=v(()=>{ke()});function wx(){return{localeError:WJ()}}var WJ=()=>{let e={string:{unit:"caracteres",verb:"ter"},file:{unit:"bytes",verb:"ter"},array:{unit:"itens",verb:"ter"},set:{unit:"itens",verb:"ter"}};function t(n){return e[n]??null}let r={regex:"padr\xE3o",email:"endere\xE7o de e-mail",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data e hora ISO",date:"data ISO",time:"hora ISO",duration:"dura\xE7\xE3o ISO",ipv4:"endere\xE7o IPv4",ipv6:"endere\xE7o IPv6",cidrv4:"faixa de IPv4",cidrv6:"faixa de IPv6",base64:"texto codificado em base64",base64url:"URL codificada em base64",json_string:"texto JSON",e164:"n\xFAmero E.164",jwt:"JWT",template_literal:"entrada"},o={nan:"NaN",number:"n\xFAmero",null:"nulo"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`Tipo inv\xE1lido: esperado instanceof ${n.expected}, recebido ${a}`;return`Tipo inv\xE1lido: esperado ${i}, recebido ${a}`}case"invalid_value":if(n.values.length===1)return`Entrada inv\xE1lida: esperado ${ce(n.values[0])}`;return`Op\xE7\xE3o inv\xE1lida: esperada uma das ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`Muito grande: esperado que ${n.origin??"valor"} tivesse ${i}${n.maximum.toString()} ${s.unit??"elementos"}`;return`Muito grande: esperado que ${n.origin??"valor"} fosse ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`Muito pequeno: esperado que ${n.origin} tivesse ${i}${n.minimum.toString()} ${s.unit}`;return`Muito pequeno: esperado que ${n.origin} fosse ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`Texto inv\xE1lido: deve come\xE7ar com "${i.prefix}"`;if(i.format==="ends_with")return`Texto inv\xE1lido: deve terminar com "${i.suffix}"`;if(i.format==="includes")return`Texto inv\xE1lido: deve incluir "${i.includes}"`;if(i.format==="regex")return`Texto inv\xE1lido: deve corresponder ao padr\xE3o ${i.pattern}`;return`${r[i.format]??n.format} inv\xE1lido`}case"not_multiple_of":return`N\xFAmero inv\xE1lido: deve ser m\xFAltiplo de ${n.divisor}`;case"unrecognized_keys":return`Chave${n.keys.length>1?"s":""} desconhecida${n.keys.length>1?"s":""}: ${Q(n.keys,", ")}`;case"invalid_key":return`Chave inv\xE1lida em ${n.origin}`;case"invalid_union":return"Entrada inv\xE1lida";case"invalid_element":return`Valor inv\xE1lido em ${n.origin}`;default:return"Campo inv\xE1lido"}}};var A1=v(()=>{ke()});function xx(){return{localeError:GJ()}}var GJ=()=>{let e={string:{unit:"caractere",verb:"s\u0103 aib\u0103"},file:{unit:"octe\u021Bi",verb:"s\u0103 aib\u0103"},array:{unit:"elemente",verb:"s\u0103 aib\u0103"},set:{unit:"elemente",verb:"s\u0103 aib\u0103"},map:{unit:"intr\u0103ri",verb:"s\u0103 aib\u0103"}};function t(n){return e[n]??null}let r={regex:"intrare",email:"adres\u0103 de email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"dat\u0103 \u0219i or\u0103 ISO",date:"dat\u0103 ISO",time:"or\u0103 ISO",duration:"durat\u0103 ISO",ipv4:"adres\u0103 IPv4",ipv6:"adres\u0103 IPv6",mac:"adres\u0103 MAC",cidrv4:"interval IPv4",cidrv6:"interval IPv6",base64:"\u0219ir codat base64",base64url:"\u0219ir codat base64url",json_string:"\u0219ir JSON",e164:"num\u0103r E.164",jwt:"JWT",template_literal:"intrare"},o={nan:"NaN",string:"\u0219ir",number:"num\u0103r",boolean:"boolean",function:"func\u021Bie",array:"matrice",object:"obiect",undefined:"nedefinit",symbol:"simbol",bigint:"num\u0103r mare",void:"void",never:"never",map:"hart\u0103",set:"set"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;return`Intrare invalid\u0103: a\u0219teptat ${i}, primit ${a}`}case"invalid_value":if(n.values.length===1)return`Intrare invalid\u0103: a\u0219teptat ${ce(n.values[0])}`;return`Op\u021Biune invalid\u0103: a\u0219teptat una dintre ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`Prea mare: a\u0219teptat ca ${n.origin??"valoarea"} ${s.verb} ${i}${n.maximum.toString()} ${s.unit??"elemente"}`;return`Prea mare: a\u0219teptat ca ${n.origin??"valoarea"} s\u0103 fie ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`Prea mic: a\u0219teptat ca ${n.origin} ${s.verb} ${i}${n.minimum.toString()} ${s.unit}`;return`Prea mic: a\u0219teptat ca ${n.origin} s\u0103 fie ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`\u0218ir invalid: trebuie s\u0103 \xEEnceap\u0103 cu "${i.prefix}"`;if(i.format==="ends_with")return`\u0218ir invalid: trebuie s\u0103 se termine cu "${i.suffix}"`;if(i.format==="includes")return`\u0218ir invalid: trebuie s\u0103 includ\u0103 "${i.includes}"`;if(i.format==="regex")return`\u0218ir invalid: trebuie s\u0103 se potriveasc\u0103 cu modelul ${i.pattern}`;return`Format invalid: ${r[i.format]??n.format}`}case"not_multiple_of":return`Num\u0103r invalid: trebuie s\u0103 fie multiplu de ${n.divisor}`;case"unrecognized_keys":return`Chei nerecunoscute: ${Q(n.keys,", ")}`;case"invalid_key":return`Cheie invalid\u0103 \xEEn ${n.origin}`;case"invalid_union":return"Intrare invalid\u0103";case"invalid_element":return`Valoare invalid\u0103 \xEEn ${n.origin}`;default:return"Intrare invalid\u0103"}}};var T1=v(()=>{ke()});function R1(e,t,r,o){let n=Math.abs(e),i=n%10,s=n%100;if(s>=11&&s<=19)return o;if(i===1)return t;if(i>=2&&i<=4)return r;return o}function _x(){return{localeError:QJ()}}var QJ=()=>{let e={string:{unit:{one:"\u0441\u0438\u043C\u0432\u043E\u043B",few:"\u0441\u0438\u043C\u0432\u043E\u043B\u0430",many:"\u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432"},verb:"\u0438\u043C\u0435\u0442\u044C"},file:{unit:{one:"\u0431\u0430\u0439\u0442",few:"\u0431\u0430\u0439\u0442\u0430",many:"\u0431\u0430\u0439\u0442"},verb:"\u0438\u043C\u0435\u0442\u044C"},array:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432"},verb:"\u0438\u043C\u0435\u0442\u044C"},set:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432"},verb:"\u0438\u043C\u0435\u0442\u044C"}};function t(n){return e[n]??null}let r={regex:"\u0432\u0432\u043E\u0434",email:"email \u0430\u0434\u0440\u0435\u0441",url:"URL",emoji:"\u044D\u043C\u043E\u0434\u0437\u0438",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0434\u0430\u0442\u0430 \u0438 \u0432\u0440\u0435\u043C\u044F",date:"ISO \u0434\u0430\u0442\u0430",time:"ISO \u0432\u0440\u0435\u043C\u044F",duration:"ISO \u0434\u043B\u0438\u0442\u0435\u043B\u044C\u043D\u043E\u0441\u0442\u044C",ipv4:"IPv4 \u0430\u0434\u0440\u0435\u0441",ipv6:"IPv6 \u0430\u0434\u0440\u0435\u0441",cidrv4:"IPv4 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D",cidrv6:"IPv6 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D",base64:"\u0441\u0442\u0440\u043E\u043A\u0430 \u0432 \u0444\u043E\u0440\u043C\u0430\u0442\u0435 base64",base64url:"\u0441\u0442\u0440\u043E\u043A\u0430 \u0432 \u0444\u043E\u0440\u043C\u0430\u0442\u0435 base64url",json_string:"JSON \u0441\u0442\u0440\u043E\u043A\u0430",e164:"\u043D\u043E\u043C\u0435\u0440 E.164",jwt:"JWT",template_literal:"\u0432\u0432\u043E\u0434"},o={nan:"NaN",number:"\u0447\u0438\u0441\u043B\u043E",array:"\u043C\u0430\u0441\u0441\u0438\u0432"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0432\u043E\u0434: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C instanceof ${n.expected}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D\u043E ${a}`;return`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0432\u043E\u0434: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C ${i}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D\u043E ${a}`}case"invalid_value":if(n.values.length===1)return`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0432\u043E\u0434: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C ${ce(n.values[0])}`;return`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0430\u0440\u0438\u0430\u043D\u0442: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C \u043E\u0434\u043D\u043E \u0438\u0437 ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s){let a=Number(n.maximum),c=R1(a,s.unit.one,s.unit.few,s.unit.many);return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u0431\u043E\u043B\u044C\u0448\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${n.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435"} \u0431\u0443\u0434\u0435\u0442 \u0438\u043C\u0435\u0442\u044C ${i}${n.maximum.toString()} ${c}`}return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u0431\u043E\u043B\u044C\u0448\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${n.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435"} \u0431\u0443\u0434\u0435\u0442 ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s){let a=Number(n.minimum),c=R1(a,s.unit.one,s.unit.few,s.unit.many);return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u043C\u0430\u043B\u0435\u043D\u044C\u043A\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${n.origin} \u0431\u0443\u0434\u0435\u0442 \u0438\u043C\u0435\u0442\u044C ${i}${n.minimum.toString()} ${c}`}return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u043C\u0430\u043B\u0435\u043D\u044C\u043A\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${n.origin} \u0431\u0443\u0434\u0435\u0442 ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u043D\u0430\u0447\u0438\u043D\u0430\u0442\u044C\u0441\u044F \u0441 "${i.prefix}"`;if(i.format==="ends_with")return`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u0437\u0430\u043A\u0430\u043D\u0447\u0438\u0432\u0430\u0442\u044C\u0441\u044F \u043D\u0430 "${i.suffix}"`;if(i.format==="includes")return`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u0441\u043E\u0434\u0435\u0440\u0436\u0430\u0442\u044C "${i.includes}"`;if(i.format==="regex")return`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u0441\u043E\u043E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043E\u0432\u0430\u0442\u044C \u0448\u0430\u0431\u043B\u043E\u043D\u0443 ${i.pattern}`;return`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 ${r[i.format]??n.format}`}case"not_multiple_of":return`\u041D\u0435\u0432\u0435\u0440\u043D\u043E\u0435 \u0447\u0438\u0441\u043B\u043E: \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u043A\u0440\u0430\u0442\u043D\u044B\u043C ${n.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u0430\u0441\u043F\u043E\u0437\u043D\u0430\u043D\u043D${n.keys.length>1?"\u044B\u0435":"\u044B\u0439"} \u043A\u043B\u044E\u0447${n.keys.length>1?"\u0438":""}: ${Q(n.keys,", ")}`;case"invalid_key":return`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u043A\u043B\u044E\u0447 \u0432 ${n.origin}`;case"invalid_union":return"\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0435 \u0432\u0445\u043E\u0434\u043D\u044B\u0435 \u0434\u0430\u043D\u043D\u044B\u0435";case"invalid_element":return`\u041D\u0435\u0432\u0435\u0440\u043D\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u0432 ${n.origin}`;default:return"\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0435 \u0432\u0445\u043E\u0434\u043D\u044B\u0435 \u0434\u0430\u043D\u043D\u044B\u0435"}}};var $1=v(()=>{ke()});function Ex(){return{localeError:YJ()}}var YJ=()=>{let e={string:{unit:"znakov",verb:"imeti"},file:{unit:"bajtov",verb:"imeti"},array:{unit:"elementov",verb:"imeti"},set:{unit:"elementov",verb:"imeti"}};function t(n){return e[n]??null}let r={regex:"vnos",email:"e-po\u0161tni naslov",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datum in \u010Das",date:"ISO datum",time:"ISO \u010Das",duration:"ISO trajanje",ipv4:"IPv4 naslov",ipv6:"IPv6 naslov",cidrv4:"obseg IPv4",cidrv6:"obseg IPv6",base64:"base64 kodiran niz",base64url:"base64url kodiran niz",json_string:"JSON niz",e164:"E.164 \u0161tevilka",jwt:"JWT",template_literal:"vnos"},o={nan:"NaN",number:"\u0161tevilo",array:"tabela"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`Neveljaven vnos: pri\u010Dakovano instanceof ${n.expected}, prejeto ${a}`;return`Neveljaven vnos: pri\u010Dakovano ${i}, prejeto ${a}`}case"invalid_value":if(n.values.length===1)return`Neveljaven vnos: pri\u010Dakovano ${ce(n.values[0])}`;return`Neveljavna mo\u017Enost: pri\u010Dakovano eno izmed ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`Preveliko: pri\u010Dakovano, da bo ${n.origin??"vrednost"} imelo ${i}${n.maximum.toString()} ${s.unit??"elementov"}`;return`Preveliko: pri\u010Dakovano, da bo ${n.origin??"vrednost"} ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`Premajhno: pri\u010Dakovano, da bo ${n.origin} imelo ${i}${n.minimum.toString()} ${s.unit}`;return`Premajhno: pri\u010Dakovano, da bo ${n.origin} ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`Neveljaven niz: mora se za\u010Deti z "${i.prefix}"`;if(i.format==="ends_with")return`Neveljaven niz: mora se kon\u010Dati z "${i.suffix}"`;if(i.format==="includes")return`Neveljaven niz: mora vsebovati "${i.includes}"`;if(i.format==="regex")return`Neveljaven niz: mora ustrezati vzorcu ${i.pattern}`;return`Neveljaven ${r[i.format]??n.format}`}case"not_multiple_of":return`Neveljavno \u0161tevilo: mora biti ve\u010Dkratnik ${n.divisor}`;case"unrecognized_keys":return`Neprepoznan${n.keys.length>1?"i klju\u010Di":" klju\u010D"}: ${Q(n.keys,", ")}`;case"invalid_key":return`Neveljaven klju\u010D v ${n.origin}`;case"invalid_union":return"Neveljaven vnos";case"invalid_element":return`Neveljavna vrednost v ${n.origin}`;default:return"Neveljaven vnos"}}};var O1=v(()=>{ke()});function kx(){return{localeError:XJ()}}var XJ=()=>{let e={string:{unit:"tecken",verb:"att ha"},file:{unit:"bytes",verb:"att ha"},array:{unit:"objekt",verb:"att inneh\xE5lla"},set:{unit:"objekt",verb:"att inneh\xE5lla"}};function t(n){return e[n]??null}let r={regex:"regulj\xE4rt uttryck",email:"e-postadress",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-datum och tid",date:"ISO-datum",time:"ISO-tid",duration:"ISO-varaktighet",ipv4:"IPv4-intervall",ipv6:"IPv6-intervall",cidrv4:"IPv4-spektrum",cidrv6:"IPv6-spektrum",base64:"base64-kodad str\xE4ng",base64url:"base64url-kodad str\xE4ng",json_string:"JSON-str\xE4ng",e164:"E.164-nummer",jwt:"JWT",template_literal:"mall-literal"},o={nan:"NaN",number:"antal",array:"lista"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`Ogiltig inmatning: f\xF6rv\xE4ntat instanceof ${n.expected}, fick ${a}`;return`Ogiltig inmatning: f\xF6rv\xE4ntat ${i}, fick ${a}`}case"invalid_value":if(n.values.length===1)return`Ogiltig inmatning: f\xF6rv\xE4ntat ${ce(n.values[0])}`;return`Ogiltigt val: f\xF6rv\xE4ntade en av ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`F\xF6r stor(t): f\xF6rv\xE4ntade ${n.origin??"v\xE4rdet"} att ha ${i}${n.maximum.toString()} ${s.unit??"element"}`;return`F\xF6r stor(t): f\xF6rv\xE4ntat ${n.origin??"v\xE4rdet"} att ha ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`F\xF6r lite(t): f\xF6rv\xE4ntade ${n.origin??"v\xE4rdet"} att ha ${i}${n.minimum.toString()} ${s.unit}`;return`F\xF6r lite(t): f\xF6rv\xE4ntade ${n.origin??"v\xE4rdet"} att ha ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`Ogiltig str\xE4ng: m\xE5ste b\xF6rja med "${i.prefix}"`;if(i.format==="ends_with")return`Ogiltig str\xE4ng: m\xE5ste sluta med "${i.suffix}"`;if(i.format==="includes")return`Ogiltig str\xE4ng: m\xE5ste inneh\xE5lla "${i.includes}"`;if(i.format==="regex")return`Ogiltig str\xE4ng: m\xE5ste matcha m\xF6nstret "${i.pattern}"`;return`Ogiltig(t) ${r[i.format]??n.format}`}case"not_multiple_of":return`Ogiltigt tal: m\xE5ste vara en multipel av ${n.divisor}`;case"unrecognized_keys":return`${n.keys.length>1?"Ok\xE4nda nycklar":"Ok\xE4nd nyckel"}: ${Q(n.keys,", ")}`;case"invalid_key":return`Ogiltig nyckel i ${n.origin??"v\xE4rdet"}`;case"invalid_union":return"Ogiltig input";case"invalid_element":return`Ogiltigt v\xE4rde i ${n.origin??"v\xE4rdet"}`;default:return"Ogiltig input"}}};var C1=v(()=>{ke()});function Ix(){return{localeError:eV()}}var eV=()=>{let e={string:{unit:"\u0B8E\u0BB4\u0BC1\u0BA4\u0BCD\u0BA4\u0BC1\u0B95\u0BCD\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"},file:{unit:"\u0BAA\u0BC8\u0B9F\u0BCD\u0B9F\u0BC1\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"},array:{unit:"\u0B89\u0BB1\u0BC1\u0BAA\u0BCD\u0BAA\u0BC1\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"},set:{unit:"\u0B89\u0BB1\u0BC1\u0BAA\u0BCD\u0BAA\u0BC1\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"}};function t(n){return e[n]??null}let r={regex:"\u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1",email:"\u0BAE\u0BBF\u0BA9\u0BCD\u0BA9\u0B9E\u0BCD\u0B9A\u0BB2\u0BCD \u0BAE\u0BC1\u0B95\u0BB5\u0BB0\u0BBF",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0BA4\u0BC7\u0BA4\u0BBF \u0BA8\u0BC7\u0BB0\u0BAE\u0BCD",date:"ISO \u0BA4\u0BC7\u0BA4\u0BBF",time:"ISO \u0BA8\u0BC7\u0BB0\u0BAE\u0BCD",duration:"ISO \u0B95\u0BBE\u0BB2 \u0B85\u0BB3\u0BB5\u0BC1",ipv4:"IPv4 \u0BAE\u0BC1\u0B95\u0BB5\u0BB0\u0BBF",ipv6:"IPv6 \u0BAE\u0BC1\u0B95\u0BB5\u0BB0\u0BBF",cidrv4:"IPv4 \u0BB5\u0BB0\u0BAE\u0BCD\u0BAA\u0BC1",cidrv6:"IPv6 \u0BB5\u0BB0\u0BAE\u0BCD\u0BAA\u0BC1",base64:"base64-encoded \u0B9A\u0BB0\u0BAE\u0BCD",base64url:"base64url-encoded \u0B9A\u0BB0\u0BAE\u0BCD",json_string:"JSON \u0B9A\u0BB0\u0BAE\u0BCD",e164:"E.164 \u0B8E\u0BA3\u0BCD",jwt:"JWT",template_literal:"input"},o={nan:"NaN",number:"\u0B8E\u0BA3\u0BCD",array:"\u0B85\u0BA3\u0BBF",null:"\u0BB5\u0BC6\u0BB1\u0BC1\u0BAE\u0BC8"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 instanceof ${n.expected}, \u0BAA\u0BC6\u0BB1\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${a}`;return`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${i}, \u0BAA\u0BC6\u0BB1\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${a}`}case"invalid_value":if(n.values.length===1)return`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${ce(n.values[0])}`;return`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0BB5\u0BBF\u0BB0\u0BC1\u0BAA\u0BCD\u0BAA\u0BAE\u0BCD: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${Q(n.values,"|")} \u0B87\u0BB2\u0BCD \u0B92\u0BA9\u0BCD\u0BB1\u0BC1`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`\u0BAE\u0BBF\u0B95 \u0BAA\u0BC6\u0BB0\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${n.origin??"\u0BAE\u0BA4\u0BBF\u0BAA\u0BCD\u0BAA\u0BC1"} ${i}${n.maximum.toString()} ${s.unit??"\u0B89\u0BB1\u0BC1\u0BAA\u0BCD\u0BAA\u0BC1\u0B95\u0BB3\u0BCD"} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`;return`\u0BAE\u0BBF\u0B95 \u0BAA\u0BC6\u0BB0\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${n.origin??"\u0BAE\u0BA4\u0BBF\u0BAA\u0BCD\u0BAA\u0BC1"} ${i}${n.maximum.toString()} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`\u0BAE\u0BBF\u0B95\u0B9A\u0BCD \u0B9A\u0BBF\u0BB1\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${n.origin} ${i}${n.minimum.toString()} ${s.unit} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`;return`\u0BAE\u0BBF\u0B95\u0B9A\u0BCD \u0B9A\u0BBF\u0BB1\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${n.origin} ${i}${n.minimum.toString()} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${i.prefix}" \u0B87\u0BB2\u0BCD \u0BA4\u0BCA\u0B9F\u0B99\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`;if(i.format==="ends_with")return`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${i.suffix}" \u0B87\u0BB2\u0BCD \u0BAE\u0BC1\u0B9F\u0BBF\u0BB5\u0B9F\u0BC8\u0BAF \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`;if(i.format==="includes")return`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${i.includes}" \u0B90 \u0B89\u0BB3\u0BCD\u0BB3\u0B9F\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`;if(i.format==="regex")return`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: ${i.pattern} \u0BAE\u0BC1\u0BB1\u0BC8\u0BAA\u0BBE\u0B9F\u0BCD\u0B9F\u0BC1\u0B9F\u0BA9\u0BCD \u0BAA\u0BCA\u0BB0\u0BC1\u0BA8\u0BCD\u0BA4 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`;return`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 ${r[i.format]??n.format}`}case"not_multiple_of":return`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B8E\u0BA3\u0BCD: ${n.divisor} \u0B87\u0BA9\u0BCD \u0BAA\u0BB2\u0BAE\u0BBE\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`;case"unrecognized_keys":return`\u0B85\u0B9F\u0BC8\u0BAF\u0BBE\u0BB3\u0BAE\u0BCD \u0BA4\u0BC6\u0BB0\u0BBF\u0BAF\u0BBE\u0BA4 \u0BB5\u0BBF\u0B9A\u0BC8${n.keys.length>1?"\u0B95\u0BB3\u0BCD":""}: ${Q(n.keys,", ")}`;case"invalid_key":return`${n.origin} \u0B87\u0BB2\u0BCD \u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0BB5\u0BBF\u0B9A\u0BC8`;case"invalid_union":return"\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1";case"invalid_element":return`${n.origin} \u0B87\u0BB2\u0BCD \u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0BAE\u0BA4\u0BBF\u0BAA\u0BCD\u0BAA\u0BC1`;default:return"\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1"}}};var P1=v(()=>{ke()});function Ax(){return{localeError:tV()}}var tV=()=>{let e={string:{unit:"\u0E15\u0E31\u0E27\u0E2D\u0E31\u0E01\u0E29\u0E23",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"},file:{unit:"\u0E44\u0E1A\u0E15\u0E4C",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"},array:{unit:"\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"},set:{unit:"\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"}};function t(n){return e[n]??null}let r={regex:"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E17\u0E35\u0E48\u0E1B\u0E49\u0E2D\u0E19",email:"\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48\u0E2D\u0E35\u0E40\u0E21\u0E25",url:"URL",emoji:"\u0E2D\u0E34\u0E42\u0E21\u0E08\u0E34",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u0E27\u0E31\u0E19\u0E17\u0E35\u0E48\u0E40\u0E27\u0E25\u0E32\u0E41\u0E1A\u0E1A ISO",date:"\u0E27\u0E31\u0E19\u0E17\u0E35\u0E48\u0E41\u0E1A\u0E1A ISO",time:"\u0E40\u0E27\u0E25\u0E32\u0E41\u0E1A\u0E1A ISO",duration:"\u0E0A\u0E48\u0E27\u0E07\u0E40\u0E27\u0E25\u0E32\u0E41\u0E1A\u0E1A ISO",ipv4:"\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48 IPv4",ipv6:"\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48 IPv6",cidrv4:"\u0E0A\u0E48\u0E27\u0E07 IP \u0E41\u0E1A\u0E1A IPv4",cidrv6:"\u0E0A\u0E48\u0E27\u0E07 IP \u0E41\u0E1A\u0E1A IPv6",base64:"\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E41\u0E1A\u0E1A Base64",base64url:"\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E41\u0E1A\u0E1A Base64 \u0E2A\u0E33\u0E2B\u0E23\u0E31\u0E1A URL",json_string:"\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E41\u0E1A\u0E1A JSON",e164:"\u0E40\u0E1A\u0E2D\u0E23\u0E4C\u0E42\u0E17\u0E23\u0E28\u0E31\u0E1E\u0E17\u0E4C\u0E23\u0E30\u0E2B\u0E27\u0E48\u0E32\u0E07\u0E1B\u0E23\u0E30\u0E40\u0E17\u0E28 (E.164)",jwt:"\u0E42\u0E17\u0E40\u0E04\u0E19 JWT",template_literal:"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E17\u0E35\u0E48\u0E1B\u0E49\u0E2D\u0E19"},o={nan:"NaN",number:"\u0E15\u0E31\u0E27\u0E40\u0E25\u0E02",array:"\u0E2D\u0E32\u0E23\u0E4C\u0E40\u0E23\u0E22\u0E4C (Array)",null:"\u0E44\u0E21\u0E48\u0E21\u0E35\u0E04\u0E48\u0E32 (null)"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`\u0E1B\u0E23\u0E30\u0E40\u0E20\u0E17\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19 instanceof ${n.expected} \u0E41\u0E15\u0E48\u0E44\u0E14\u0E49\u0E23\u0E31\u0E1A ${a}`;return`\u0E1B\u0E23\u0E30\u0E40\u0E20\u0E17\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19 ${i} \u0E41\u0E15\u0E48\u0E44\u0E14\u0E49\u0E23\u0E31\u0E1A ${a}`}case"invalid_value":if(n.values.length===1)return`\u0E04\u0E48\u0E32\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19 ${ce(n.values[0])}`;return`\u0E15\u0E31\u0E27\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19\u0E2B\u0E19\u0E36\u0E48\u0E07\u0E43\u0E19 ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"\u0E44\u0E21\u0E48\u0E40\u0E01\u0E34\u0E19":"\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32",s=t(n.origin);if(s)return`\u0E40\u0E01\u0E34\u0E19\u0E01\u0E33\u0E2B\u0E19\u0E14: ${n.origin??"\u0E04\u0E48\u0E32"} \u0E04\u0E27\u0E23\u0E21\u0E35${i} ${n.maximum.toString()} ${s.unit??"\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23"}`;return`\u0E40\u0E01\u0E34\u0E19\u0E01\u0E33\u0E2B\u0E19\u0E14: ${n.origin??"\u0E04\u0E48\u0E32"} \u0E04\u0E27\u0E23\u0E21\u0E35${i} ${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?"\u0E2D\u0E22\u0E48\u0E32\u0E07\u0E19\u0E49\u0E2D\u0E22":"\u0E21\u0E32\u0E01\u0E01\u0E27\u0E48\u0E32",s=t(n.origin);if(s)return`\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32\u0E01\u0E33\u0E2B\u0E19\u0E14: ${n.origin} \u0E04\u0E27\u0E23\u0E21\u0E35${i} ${n.minimum.toString()} ${s.unit}`;return`\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32\u0E01\u0E33\u0E2B\u0E19\u0E14: ${n.origin} \u0E04\u0E27\u0E23\u0E21\u0E35${i} ${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E15\u0E49\u0E2D\u0E07\u0E02\u0E36\u0E49\u0E19\u0E15\u0E49\u0E19\u0E14\u0E49\u0E27\u0E22 "${i.prefix}"`;if(i.format==="ends_with")return`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E15\u0E49\u0E2D\u0E07\u0E25\u0E07\u0E17\u0E49\u0E32\u0E22\u0E14\u0E49\u0E27\u0E22 "${i.suffix}"`;if(i.format==="includes")return`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E15\u0E49\u0E2D\u0E07\u0E21\u0E35 "${i.includes}" \u0E2D\u0E22\u0E39\u0E48\u0E43\u0E19\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21`;if(i.format==="regex")return`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E15\u0E49\u0E2D\u0E07\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E17\u0E35\u0E48\u0E01\u0E33\u0E2B\u0E19\u0E14 ${i.pattern}`;return`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: ${r[i.format]??n.format}`}case"not_multiple_of":return`\u0E15\u0E31\u0E27\u0E40\u0E25\u0E02\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E15\u0E49\u0E2D\u0E07\u0E40\u0E1B\u0E47\u0E19\u0E08\u0E33\u0E19\u0E27\u0E19\u0E17\u0E35\u0E48\u0E2B\u0E32\u0E23\u0E14\u0E49\u0E27\u0E22 ${n.divisor} \u0E44\u0E14\u0E49\u0E25\u0E07\u0E15\u0E31\u0E27`;case"unrecognized_keys":return`\u0E1E\u0E1A\u0E04\u0E35\u0E22\u0E4C\u0E17\u0E35\u0E48\u0E44\u0E21\u0E48\u0E23\u0E39\u0E49\u0E08\u0E31\u0E01: ${Q(n.keys,", ")}`;case"invalid_key":return`\u0E04\u0E35\u0E22\u0E4C\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07\u0E43\u0E19 ${n.origin}`;case"invalid_union":return"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E44\u0E21\u0E48\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E22\u0E39\u0E40\u0E19\u0E35\u0E22\u0E19\u0E17\u0E35\u0E48\u0E01\u0E33\u0E2B\u0E19\u0E14\u0E44\u0E27\u0E49";case"invalid_element":return`\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07\u0E43\u0E19 ${n.origin}`;default:return"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07"}}};var z1=v(()=>{ke()});function Tx(){return{localeError:rV()}}var rV=()=>{let e={string:{unit:"karakter",verb:"olmal\u0131"},file:{unit:"bayt",verb:"olmal\u0131"},array:{unit:"\xF6\u011Fe",verb:"olmal\u0131"},set:{unit:"\xF6\u011Fe",verb:"olmal\u0131"}};function t(n){return e[n]??null}let r={regex:"girdi",email:"e-posta adresi",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO tarih ve saat",date:"ISO tarih",time:"ISO saat",duration:"ISO s\xFCre",ipv4:"IPv4 adresi",ipv6:"IPv6 adresi",cidrv4:"IPv4 aral\u0131\u011F\u0131",cidrv6:"IPv6 aral\u0131\u011F\u0131",base64:"base64 ile \u015Fifrelenmi\u015F metin",base64url:"base64url ile \u015Fifrelenmi\u015F metin",json_string:"JSON dizesi",e164:"E.164 say\u0131s\u0131",jwt:"JWT",template_literal:"\u015Eablon dizesi"},o={nan:"NaN"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`Ge\xE7ersiz de\u011Fer: beklenen instanceof ${n.expected}, al\u0131nan ${a}`;return`Ge\xE7ersiz de\u011Fer: beklenen ${i}, al\u0131nan ${a}`}case"invalid_value":if(n.values.length===1)return`Ge\xE7ersiz de\u011Fer: beklenen ${ce(n.values[0])}`;return`Ge\xE7ersiz se\xE7enek: a\u015Fa\u011F\u0131dakilerden biri olmal\u0131: ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`\xC7ok b\xFCy\xFCk: beklenen ${n.origin??"de\u011Fer"} ${i}${n.maximum.toString()} ${s.unit??"\xF6\u011Fe"}`;return`\xC7ok b\xFCy\xFCk: beklenen ${n.origin??"de\u011Fer"} ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`\xC7ok k\xFC\xE7\xFCk: beklenen ${n.origin} ${i}${n.minimum.toString()} ${s.unit}`;return`\xC7ok k\xFC\xE7\xFCk: beklenen ${n.origin} ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`Ge\xE7ersiz metin: "${i.prefix}" ile ba\u015Flamal\u0131`;if(i.format==="ends_with")return`Ge\xE7ersiz metin: "${i.suffix}" ile bitmeli`;if(i.format==="includes")return`Ge\xE7ersiz metin: "${i.includes}" i\xE7ermeli`;if(i.format==="regex")return`Ge\xE7ersiz metin: ${i.pattern} desenine uymal\u0131`;return`Ge\xE7ersiz ${r[i.format]??n.format}`}case"not_multiple_of":return`Ge\xE7ersiz say\u0131: ${n.divisor} ile tam b\xF6l\xFCnebilmeli`;case"unrecognized_keys":return`Tan\u0131nmayan anahtar${n.keys.length>1?"lar":""}: ${Q(n.keys,", ")}`;case"invalid_key":return`${n.origin} i\xE7inde ge\xE7ersiz anahtar`;case"invalid_union":return"Ge\xE7ersiz de\u011Fer";case"invalid_element":return`${n.origin} i\xE7inde ge\xE7ersiz de\u011Fer`;default:return"Ge\xE7ersiz de\u011Fer"}}};var N1=v(()=>{ke()});function du(){return{localeError:nV()}}var nV=()=>{let e={string:{unit:"\u0441\u0438\u043C\u0432\u043E\u043B\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"},file:{unit:"\u0431\u0430\u0439\u0442\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"},array:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"},set:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"}};function t(n){return e[n]??null}let r={regex:"\u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456",email:"\u0430\u0434\u0440\u0435\u0441\u0430 \u0435\u043B\u0435\u043A\u0442\u0440\u043E\u043D\u043D\u043E\u0457 \u043F\u043E\u0448\u0442\u0438",url:"URL",emoji:"\u0435\u043C\u043E\u0434\u0437\u0456",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u0434\u0430\u0442\u0430 \u0442\u0430 \u0447\u0430\u0441 ISO",date:"\u0434\u0430\u0442\u0430 ISO",time:"\u0447\u0430\u0441 ISO",duration:"\u0442\u0440\u0438\u0432\u0430\u043B\u0456\u0441\u0442\u044C ISO",ipv4:"\u0430\u0434\u0440\u0435\u0441\u0430 IPv4",ipv6:"\u0430\u0434\u0440\u0435\u0441\u0430 IPv6",cidrv4:"\u0434\u0456\u0430\u043F\u0430\u0437\u043E\u043D IPv4",cidrv6:"\u0434\u0456\u0430\u043F\u0430\u0437\u043E\u043D IPv6",base64:"\u0440\u044F\u0434\u043E\u043A \u0443 \u043A\u043E\u0434\u0443\u0432\u0430\u043D\u043D\u0456 base64",base64url:"\u0440\u044F\u0434\u043E\u043A \u0443 \u043A\u043E\u0434\u0443\u0432\u0430\u043D\u043D\u0456 base64url",json_string:"\u0440\u044F\u0434\u043E\u043A JSON",e164:"\u043D\u043E\u043C\u0435\u0440 E.164",jwt:"JWT",template_literal:"\u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456"},o={nan:"NaN",number:"\u0447\u0438\u0441\u043B\u043E",array:"\u043C\u0430\u0441\u0438\u0432"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F instanceof ${n.expected}, \u043E\u0442\u0440\u0438\u043C\u0430\u043D\u043E ${a}`;return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F ${i}, \u043E\u0442\u0440\u0438\u043C\u0430\u043D\u043E ${a}`}case"invalid_value":if(n.values.length===1)return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F ${ce(n.values[0])}`;return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0430 \u043E\u043F\u0446\u0456\u044F: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F \u043E\u0434\u043D\u0435 \u0437 ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u0432\u0435\u043B\u0438\u043A\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${n.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F"} ${s.verb} ${i}${n.maximum.toString()} ${s.unit??"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0456\u0432"}`;return`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u0432\u0435\u043B\u0438\u043A\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${n.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F"} \u0431\u0443\u0434\u0435 ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u043C\u0430\u043B\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${n.origin} ${s.verb} ${i}${n.minimum.toString()} ${s.unit}`;return`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u043C\u0430\u043B\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${n.origin} \u0431\u0443\u0434\u0435 ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u043F\u043E\u0447\u0438\u043D\u0430\u0442\u0438\u0441\u044F \u0437 "${i.prefix}"`;if(i.format==="ends_with")return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u0437\u0430\u043A\u0456\u043D\u0447\u0443\u0432\u0430\u0442\u0438\u0441\u044F \u043D\u0430 "${i.suffix}"`;if(i.format==="includes")return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u043C\u0456\u0441\u0442\u0438\u0442\u0438 "${i.includes}"`;if(i.format==="regex")return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0430\u0442\u0438 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 ${i.pattern}`;return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 ${r[i.format]??n.format}`}case"not_multiple_of":return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0435 \u0447\u0438\u0441\u043B\u043E: \u043F\u043E\u0432\u0438\u043D\u043D\u043E \u0431\u0443\u0442\u0438 \u043A\u0440\u0430\u0442\u043D\u0438\u043C ${n.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u043E\u0437\u043F\u0456\u0437\u043D\u0430\u043D\u0438\u0439 \u043A\u043B\u044E\u0447${n.keys.length>1?"\u0456":""}: ${Q(n.keys,", ")}`;case"invalid_key":return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u043A\u043B\u044E\u0447 \u0443 ${n.origin}`;case"invalid_union":return"\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456";case"invalid_element":return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F \u0443 ${n.origin}`;default:return"\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456"}}};var Rx=v(()=>{ke()});function $x(){return du()}var D1=v(()=>{Rx()});function Ox(){return{localeError:oV()}}var oV=()=>{let e={string:{unit:"\u062D\u0631\u0648\u0641",verb:"\u06C1\u0648\u0646\u0627"},file:{unit:"\u0628\u0627\u0626\u0679\u0633",verb:"\u06C1\u0648\u0646\u0627"},array:{unit:"\u0622\u0626\u0679\u0645\u0632",verb:"\u06C1\u0648\u0646\u0627"},set:{unit:"\u0622\u0626\u0679\u0645\u0632",verb:"\u06C1\u0648\u0646\u0627"}};function t(n){return e[n]??null}let r={regex:"\u0627\u0646 \u067E\u0679",email:"\u0627\u06CC \u0645\u06CC\u0644 \u0627\u06CC\u0688\u0631\u06CC\u0633",url:"\u06CC\u0648 \u0622\u0631 \u0627\u06CC\u0644",emoji:"\u0627\u06CC\u0645\u0648\u062C\u06CC",uuid:"\u06CC\u0648 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",uuidv4:"\u06CC\u0648 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC \u0648\u06CC 4",uuidv6:"\u06CC\u0648 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC \u0648\u06CC 6",nanoid:"\u0646\u06CC\u0646\u0648 \u0622\u0626\u06CC \u0688\u06CC",guid:"\u062C\u06CC \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",cuid:"\u0633\u06CC \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",cuid2:"\u0633\u06CC \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC 2",ulid:"\u06CC\u0648 \u0627\u06CC\u0644 \u0622\u0626\u06CC \u0688\u06CC",xid:"\u0627\u06CC\u06A9\u0633 \u0622\u0626\u06CC \u0688\u06CC",ksuid:"\u06A9\u06D2 \u0627\u06CC\u0633 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",datetime:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u0688\u06CC\u0679 \u0679\u0627\u0626\u0645",date:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u062A\u0627\u0631\u06CC\u062E",time:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u0648\u0642\u062A",duration:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u0645\u062F\u062A",ipv4:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 4 \u0627\u06CC\u0688\u0631\u06CC\u0633",ipv6:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 6 \u0627\u06CC\u0688\u0631\u06CC\u0633",cidrv4:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 4 \u0631\u06CC\u0646\u062C",cidrv6:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 6 \u0631\u06CC\u0646\u062C",base64:"\u0628\u06CC\u0633 64 \u0627\u0646 \u06A9\u0648\u0688\u0688 \u0633\u0679\u0631\u0646\u06AF",base64url:"\u0628\u06CC\u0633 64 \u06CC\u0648 \u0622\u0631 \u0627\u06CC\u0644 \u0627\u0646 \u06A9\u0648\u0688\u0688 \u0633\u0679\u0631\u0646\u06AF",json_string:"\u062C\u06D2 \u0627\u06CC\u0633 \u0627\u0648 \u0627\u06CC\u0646 \u0633\u0679\u0631\u0646\u06AF",e164:"\u0627\u06CC 164 \u0646\u0645\u0628\u0631",jwt:"\u062C\u06D2 \u0688\u0628\u0644\u06CC\u0648 \u0679\u06CC",template_literal:"\u0627\u0646 \u067E\u0679"},o={nan:"NaN",number:"\u0646\u0645\u0628\u0631",array:"\u0622\u0631\u06D2",null:"\u0646\u0644"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679: instanceof ${n.expected} \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627\u060C ${a} \u0645\u0648\u0635\u0648\u0644 \u06C1\u0648\u0627`;return`\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679: ${i} \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627\u060C ${a} \u0645\u0648\u0635\u0648\u0644 \u06C1\u0648\u0627`}case"invalid_value":if(n.values.length===1)return`\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679: ${ce(n.values[0])} \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`;return`\u063A\u0644\u0637 \u0622\u067E\u0634\u0646: ${Q(n.values,"|")} \u0645\u06CC\u06BA \u0633\u06D2 \u0627\u06CC\u06A9 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`\u0628\u06C1\u062A \u0628\u0691\u0627: ${n.origin??"\u0648\u06CC\u0644\u06CC\u0648"} \u06A9\u06D2 ${i}${n.maximum.toString()} ${s.unit??"\u0639\u0646\u0627\u0635\u0631"} \u06C1\u0648\u0646\u06D2 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u06D2`;return`\u0628\u06C1\u062A \u0628\u0691\u0627: ${n.origin??"\u0648\u06CC\u0644\u06CC\u0648"} \u06A9\u0627 ${i}${n.maximum.toString()} \u06C1\u0648\u0646\u0627 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`\u0628\u06C1\u062A \u0686\u06BE\u0648\u0679\u0627: ${n.origin} \u06A9\u06D2 ${i}${n.minimum.toString()} ${s.unit} \u06C1\u0648\u0646\u06D2 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u06D2`;return`\u0628\u06C1\u062A \u0686\u06BE\u0648\u0679\u0627: ${n.origin} \u06A9\u0627 ${i}${n.minimum.toString()} \u06C1\u0648\u0646\u0627 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${i.prefix}" \u0633\u06D2 \u0634\u0631\u0648\u0639 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`;if(i.format==="ends_with")return`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${i.suffix}" \u067E\u0631 \u062E\u062A\u0645 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`;if(i.format==="includes")return`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${i.includes}" \u0634\u0627\u0645\u0644 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`;if(i.format==="regex")return`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: \u067E\u06CC\u0679\u0631\u0646 ${i.pattern} \u0633\u06D2 \u0645\u06CC\u0686 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`;return`\u063A\u0644\u0637 ${r[i.format]??n.format}`}case"not_multiple_of":return`\u063A\u0644\u0637 \u0646\u0645\u0628\u0631: ${n.divisor} \u06A9\u0627 \u0645\u0636\u0627\u0639\u0641 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`;case"unrecognized_keys":return`\u063A\u06CC\u0631 \u062A\u0633\u0644\u06CC\u0645 \u0634\u062F\u06C1 \u06A9\u06CC${n.keys.length>1?"\u0632":""}: ${Q(n.keys,"\u060C ")}`;case"invalid_key":return`${n.origin} \u0645\u06CC\u06BA \u063A\u0644\u0637 \u06A9\u06CC`;case"invalid_union":return"\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679";case"invalid_element":return`${n.origin} \u0645\u06CC\u06BA \u063A\u0644\u0637 \u0648\u06CC\u0644\u06CC\u0648`;default:return"\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679"}}};var L1=v(()=>{ke()});function Cx(){return{localeError:iV()}}var iV=()=>{let e={string:{unit:"belgi",verb:"bo\u2018lishi kerak"},file:{unit:"bayt",verb:"bo\u2018lishi kerak"},array:{unit:"element",verb:"bo\u2018lishi kerak"},set:{unit:"element",verb:"bo\u2018lishi kerak"},map:{unit:"yozuv",verb:"bo\u2018lishi kerak"}};function t(n){return e[n]??null}let r={regex:"kirish",email:"elektron pochta manzili",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO sana va vaqti",date:"ISO sana",time:"ISO vaqt",duration:"ISO davomiylik",ipv4:"IPv4 manzil",ipv6:"IPv6 manzil",mac:"MAC manzil",cidrv4:"IPv4 diapazon",cidrv6:"IPv6 diapazon",base64:"base64 kodlangan satr",base64url:"base64url kodlangan satr",json_string:"JSON satr",e164:"E.164 raqam",jwt:"JWT",template_literal:"kirish"},o={nan:"NaN",number:"raqam",array:"massiv"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`Noto\u2018g\u2018ri kirish: kutilgan instanceof ${n.expected}, qabul qilingan ${a}`;return`Noto\u2018g\u2018ri kirish: kutilgan ${i}, qabul qilingan ${a}`}case"invalid_value":if(n.values.length===1)return`Noto\u2018g\u2018ri kirish: kutilgan ${ce(n.values[0])}`;return`Noto\u2018g\u2018ri variant: quyidagilardan biri kutilgan ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`Juda katta: kutilgan ${n.origin??"qiymat"} ${i}${n.maximum.toString()} ${s.unit} ${s.verb}`;return`Juda katta: kutilgan ${n.origin??"qiymat"} ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`Juda kichik: kutilgan ${n.origin} ${i}${n.minimum.toString()} ${s.unit} ${s.verb}`;return`Juda kichik: kutilgan ${n.origin} ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`Noto\u2018g\u2018ri satr: "${i.prefix}" bilan boshlanishi kerak`;if(i.format==="ends_with")return`Noto\u2018g\u2018ri satr: "${i.suffix}" bilan tugashi kerak`;if(i.format==="includes")return`Noto\u2018g\u2018ri satr: "${i.includes}" ni o\u2018z ichiga olishi kerak`;if(i.format==="regex")return`Noto\u2018g\u2018ri satr: ${i.pattern} shabloniga mos kelishi kerak`;return`Noto\u2018g\u2018ri ${r[i.format]??n.format}`}case"not_multiple_of":return`Noto\u2018g\u2018ri raqam: ${n.divisor} ning karralisi bo\u2018lishi kerak`;case"unrecognized_keys":return`Noma\u2019lum kalit${n.keys.length>1?"lar":""}: ${Q(n.keys,", ")}`;case"invalid_key":return`${n.origin} dagi kalit noto\u2018g\u2018ri`;case"invalid_union":return"Noto\u2018g\u2018ri kirish";case"invalid_element":return`${n.origin} da noto\u2018g\u2018ri qiymat`;default:return"Noto\u2018g\u2018ri kirish"}}};var B1=v(()=>{ke()});function Px(){return{localeError:sV()}}var sV=()=>{let e={string:{unit:"k\xFD t\u1EF1",verb:"c\xF3"},file:{unit:"byte",verb:"c\xF3"},array:{unit:"ph\u1EA7n t\u1EED",verb:"c\xF3"},set:{unit:"ph\u1EA7n t\u1EED",verb:"c\xF3"}};function t(n){return e[n]??null}let r={regex:"\u0111\u1EA7u v\xE0o",email:"\u0111\u1ECBa ch\u1EC9 email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ng\xE0y gi\u1EDD ISO",date:"ng\xE0y ISO",time:"gi\u1EDD ISO",duration:"kho\u1EA3ng th\u1EDDi gian ISO",ipv4:"\u0111\u1ECBa ch\u1EC9 IPv4",ipv6:"\u0111\u1ECBa ch\u1EC9 IPv6",cidrv4:"d\u1EA3i IPv4",cidrv6:"d\u1EA3i IPv6",base64:"chu\u1ED7i m\xE3 h\xF3a base64",base64url:"chu\u1ED7i m\xE3 h\xF3a base64url",json_string:"chu\u1ED7i JSON",e164:"s\u1ED1 E.164",jwt:"JWT",template_literal:"\u0111\u1EA7u v\xE0o"},o={nan:"NaN",number:"s\u1ED1",array:"m\u1EA3ng"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i instanceof ${n.expected}, nh\u1EADn \u0111\u01B0\u1EE3c ${a}`;return`\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i ${i}, nh\u1EADn \u0111\u01B0\u1EE3c ${a}`}case"invalid_value":if(n.values.length===1)return`\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i ${ce(n.values[0])}`;return`T\xF9y ch\u1ECDn kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i m\u1ED9t trong c\xE1c gi\xE1 tr\u1ECB ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`Qu\xE1 l\u1EDBn: mong \u0111\u1EE3i ${n.origin??"gi\xE1 tr\u1ECB"} ${s.verb} ${i}${n.maximum.toString()} ${s.unit??"ph\u1EA7n t\u1EED"}`;return`Qu\xE1 l\u1EDBn: mong \u0111\u1EE3i ${n.origin??"gi\xE1 tr\u1ECB"} ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`Qu\xE1 nh\u1ECF: mong \u0111\u1EE3i ${n.origin} ${s.verb} ${i}${n.minimum.toString()} ${s.unit}`;return`Qu\xE1 nh\u1ECF: mong \u0111\u1EE3i ${n.origin} ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i b\u1EAFt \u0111\u1EA7u b\u1EB1ng "${i.prefix}"`;if(i.format==="ends_with")return`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i k\u1EBFt th\xFAc b\u1EB1ng "${i.suffix}"`;if(i.format==="includes")return`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i bao g\u1ED3m "${i.includes}"`;if(i.format==="regex")return`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i kh\u1EDBp v\u1EDBi m\u1EABu ${i.pattern}`;return`${r[i.format]??n.format} kh\xF4ng h\u1EE3p l\u1EC7`}case"not_multiple_of":return`S\u1ED1 kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i l\xE0 b\u1ED9i s\u1ED1 c\u1EE7a ${n.divisor}`;case"unrecognized_keys":return`Kh\xF3a kh\xF4ng \u0111\u01B0\u1EE3c nh\u1EADn d\u1EA1ng: ${Q(n.keys,", ")}`;case"invalid_key":return`Kh\xF3a kh\xF4ng h\u1EE3p l\u1EC7 trong ${n.origin}`;case"invalid_union":return"\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7";case"invalid_element":return`Gi\xE1 tr\u1ECB kh\xF4ng h\u1EE3p l\u1EC7 trong ${n.origin}`;default:return"\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7"}}};var j1=v(()=>{ke()});function zx(){return{localeError:aV()}}var aV=()=>{let e={string:{unit:"\u5B57\u7B26",verb:"\u5305\u542B"},file:{unit:"\u5B57\u8282",verb:"\u5305\u542B"},array:{unit:"\u9879",verb:"\u5305\u542B"},set:{unit:"\u9879",verb:"\u5305\u542B"}};function t(n){return e[n]??null}let r={regex:"\u8F93\u5165",email:"\u7535\u5B50\u90AE\u4EF6",url:"URL",emoji:"\u8868\u60C5\u7B26\u53F7",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO\u65E5\u671F\u65F6\u95F4",date:"ISO\u65E5\u671F",time:"ISO\u65F6\u95F4",duration:"ISO\u65F6\u957F",ipv4:"IPv4\u5730\u5740",ipv6:"IPv6\u5730\u5740",cidrv4:"IPv4\u7F51\u6BB5",cidrv6:"IPv6\u7F51\u6BB5",base64:"base64\u7F16\u7801\u5B57\u7B26\u4E32",base64url:"base64url\u7F16\u7801\u5B57\u7B26\u4E32",json_string:"JSON\u5B57\u7B26\u4E32",e164:"E.164\u53F7\u7801",jwt:"JWT",template_literal:"\u8F93\u5165"},o={nan:"NaN",number:"\u6570\u5B57",array:"\u6570\u7EC4",null:"\u7A7A\u503C(null)"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B instanceof ${n.expected}\uFF0C\u5B9E\u9645\u63A5\u6536 ${a}`;return`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B ${i}\uFF0C\u5B9E\u9645\u63A5\u6536 ${a}`}case"invalid_value":if(n.values.length===1)return`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B ${ce(n.values[0])}`;return`\u65E0\u6548\u9009\u9879\uFF1A\u671F\u671B\u4EE5\u4E0B\u4E4B\u4E00 ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`\u6570\u503C\u8FC7\u5927\uFF1A\u671F\u671B ${n.origin??"\u503C"} ${i}${n.maximum.toString()} ${s.unit??"\u4E2A\u5143\u7D20"}`;return`\u6570\u503C\u8FC7\u5927\uFF1A\u671F\u671B ${n.origin??"\u503C"} ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`\u6570\u503C\u8FC7\u5C0F\uFF1A\u671F\u671B ${n.origin} ${i}${n.minimum.toString()} ${s.unit}`;return`\u6570\u503C\u8FC7\u5C0F\uFF1A\u671F\u671B ${n.origin} ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u4EE5 "${i.prefix}" \u5F00\u5934`;if(i.format==="ends_with")return`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u4EE5 "${i.suffix}" \u7ED3\u5C3E`;if(i.format==="includes")return`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u5305\u542B "${i.includes}"`;if(i.format==="regex")return`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u6EE1\u8DB3\u6B63\u5219\u8868\u8FBE\u5F0F ${i.pattern}`;return`\u65E0\u6548${r[i.format]??n.format}`}case"not_multiple_of":return`\u65E0\u6548\u6570\u5B57\uFF1A\u5FC5\u987B\u662F ${n.divisor} \u7684\u500D\u6570`;case"unrecognized_keys":return`\u51FA\u73B0\u672A\u77E5\u7684\u952E(key): ${Q(n.keys,", ")}`;case"invalid_key":return`${n.origin} \u4E2D\u7684\u952E(key)\u65E0\u6548`;case"invalid_union":return"\u65E0\u6548\u8F93\u5165";case"invalid_element":return`${n.origin} \u4E2D\u5305\u542B\u65E0\u6548\u503C(value)`;default:return"\u65E0\u6548\u8F93\u5165"}}};var Z1=v(()=>{ke()});function Nx(){return{localeError:cV()}}var cV=()=>{let e={string:{unit:"\u5B57\u5143",verb:"\u64C1\u6709"},file:{unit:"\u4F4D\u5143\u7D44",verb:"\u64C1\u6709"},array:{unit:"\u9805\u76EE",verb:"\u64C1\u6709"},set:{unit:"\u9805\u76EE",verb:"\u64C1\u6709"}};function t(n){return e[n]??null}let r={regex:"\u8F38\u5165",email:"\u90F5\u4EF6\u5730\u5740",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u65E5\u671F\u6642\u9593",date:"ISO \u65E5\u671F",time:"ISO \u6642\u9593",duration:"ISO \u671F\u9593",ipv4:"IPv4 \u4F4D\u5740",ipv6:"IPv6 \u4F4D\u5740",cidrv4:"IPv4 \u7BC4\u570D",cidrv6:"IPv6 \u7BC4\u570D",base64:"base64 \u7DE8\u78BC\u5B57\u4E32",base64url:"base64url \u7DE8\u78BC\u5B57\u4E32",json_string:"JSON \u5B57\u4E32",e164:"E.164 \u6578\u503C",jwt:"JWT",template_literal:"\u8F38\u5165"},o={nan:"NaN"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`\u7121\u6548\u7684\u8F38\u5165\u503C\uFF1A\u9810\u671F\u70BA instanceof ${n.expected}\uFF0C\u4F46\u6536\u5230 ${a}`;return`\u7121\u6548\u7684\u8F38\u5165\u503C\uFF1A\u9810\u671F\u70BA ${i}\uFF0C\u4F46\u6536\u5230 ${a}`}case"invalid_value":if(n.values.length===1)return`\u7121\u6548\u7684\u8F38\u5165\u503C\uFF1A\u9810\u671F\u70BA ${ce(n.values[0])}`;return`\u7121\u6548\u7684\u9078\u9805\uFF1A\u9810\u671F\u70BA\u4EE5\u4E0B\u5176\u4E2D\u4E4B\u4E00 ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`\u6578\u503C\u904E\u5927\uFF1A\u9810\u671F ${n.origin??"\u503C"} \u61C9\u70BA ${i}${n.maximum.toString()} ${s.unit??"\u500B\u5143\u7D20"}`;return`\u6578\u503C\u904E\u5927\uFF1A\u9810\u671F ${n.origin??"\u503C"} \u61C9\u70BA ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`\u6578\u503C\u904E\u5C0F\uFF1A\u9810\u671F ${n.origin} \u61C9\u70BA ${i}${n.minimum.toString()} ${s.unit}`;return`\u6578\u503C\u904E\u5C0F\uFF1A\u9810\u671F ${n.origin} \u61C9\u70BA ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u4EE5 "${i.prefix}" \u958B\u982D`;if(i.format==="ends_with")return`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u4EE5 "${i.suffix}" \u7D50\u5C3E`;if(i.format==="includes")return`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u5305\u542B "${i.includes}"`;if(i.format==="regex")return`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u7B26\u5408\u683C\u5F0F ${i.pattern}`;return`\u7121\u6548\u7684 ${r[i.format]??n.format}`}case"not_multiple_of":return`\u7121\u6548\u7684\u6578\u5B57\uFF1A\u5FC5\u9808\u70BA ${n.divisor} \u7684\u500D\u6578`;case"unrecognized_keys":return`\u7121\u6CD5\u8B58\u5225\u7684\u9375\u503C${n.keys.length>1?"\u5011":""}\uFF1A${Q(n.keys,"\u3001")}`;case"invalid_key":return`${n.origin} \u4E2D\u6709\u7121\u6548\u7684\u9375\u503C`;case"invalid_union":return"\u7121\u6548\u7684\u8F38\u5165\u503C";case"invalid_element":return`${n.origin} \u4E2D\u6709\u7121\u6548\u7684\u503C`;default:return"\u7121\u6548\u7684\u8F38\u5165\u503C"}}};var U1=v(()=>{ke()});function Dx(){return{localeError:lV()}}var lV=()=>{let e={string:{unit:"\xE0mi",verb:"n\xED"},file:{unit:"bytes",verb:"n\xED"},array:{unit:"nkan",verb:"n\xED"},set:{unit:"nkan",verb:"n\xED"}};function t(n){return e[n]??null}let r={regex:"\u1EB9\u0300r\u1ECD \xECb\xE1w\u1ECDl\xE9",email:"\xE0d\xEDr\u1EB9\u0301s\xEC \xECm\u1EB9\u0301l\xEC",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\xE0k\xF3k\xF2 ISO",date:"\u1ECDj\u1ECD\u0301 ISO",time:"\xE0k\xF3k\xF2 ISO",duration:"\xE0k\xF3k\xF2 t\xF3 p\xE9 ISO",ipv4:"\xE0d\xEDr\u1EB9\u0301s\xEC IPv4",ipv6:"\xE0d\xEDr\u1EB9\u0301s\xEC IPv6",cidrv4:"\xE0gb\xE8gb\xE8 IPv4",cidrv6:"\xE0gb\xE8gb\xE8 IPv6",base64:"\u1ECD\u0300r\u1ECD\u0300 t\xED a k\u1ECD\u0301 n\xED base64",base64url:"\u1ECD\u0300r\u1ECD\u0300 base64url",json_string:"\u1ECD\u0300r\u1ECD\u0300 JSON",e164:"n\u1ECD\u0301mb\xE0 E.164",jwt:"JWT",template_literal:"\u1EB9\u0300r\u1ECD \xECb\xE1w\u1ECDl\xE9"},o={nan:"NaN",number:"n\u1ECD\u0301mb\xE0",array:"akop\u1ECD"};return(n)=>{switch(n.code){case"invalid_type":{let i=o[n.expected]??n.expected,s=le(n.input),a=o[s]??s;if(/^[A-Z]/.test(n.expected))return`\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e: a n\xED l\xE1ti fi instanceof ${n.expected}, \xE0m\u1ECD\u0300 a r\xED ${a}`;return`\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e: a n\xED l\xE1ti fi ${i}, \xE0m\u1ECD\u0300 a r\xED ${a}`}case"invalid_value":if(n.values.length===1)return`\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e: a n\xED l\xE1ti fi ${ce(n.values[0])}`;return`\xC0\u1E63\xE0y\xE0n a\u1E63\xEC\u1E63e: yan \u1ECD\u0300kan l\xE1ra ${Q(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",s=t(n.origin);if(s)return`T\xF3 p\u1ECD\u0300 j\xF9: a n\xED l\xE1ti j\u1EB9\u0301 p\xE9 ${n.origin??"iye"} ${s.verb} ${i}${n.maximum} ${s.unit}`;return`T\xF3 p\u1ECD\u0300 j\xF9: a n\xED l\xE1ti j\u1EB9\u0301 ${i}${n.maximum}`}case"too_small":{let i=n.inclusive?">=":">",s=t(n.origin);if(s)return`K\xE9r\xE9 ju: a n\xED l\xE1ti j\u1EB9\u0301 p\xE9 ${n.origin} ${s.verb} ${i}${n.minimum} ${s.unit}`;return`K\xE9r\xE9 ju: a n\xED l\xE1ti j\u1EB9\u0301 ${i}${n.minimum}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 b\u1EB9\u0300r\u1EB9\u0300 p\u1EB9\u0300l\xFA "${i.prefix}"`;if(i.format==="ends_with")return`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 par\xED p\u1EB9\u0300l\xFA "${i.suffix}"`;if(i.format==="includes")return`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 n\xED "${i.includes}"`;if(i.format==="regex")return`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 b\xE1 \xE0p\u1EB9\u1EB9r\u1EB9 mu ${i.pattern}`;return`A\u1E63\xEC\u1E63e: ${r[i.format]??n.format}`}case"not_multiple_of":return`N\u1ECD\u0301mb\xE0 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 j\u1EB9\u0301 \xE8y\xE0 p\xEDp\xEDn ti ${n.divisor}`;case"unrecognized_keys":return`B\u1ECDt\xECn\xEC \xE0\xECm\u1ECD\u0300: ${Q(n.keys,", ")}`;case"invalid_key":return`B\u1ECDt\xECn\xEC a\u1E63\xEC\u1E63e n\xEDn\xFA ${n.origin}`;case"invalid_union":return"\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e";case"invalid_element":return`Iye a\u1E63\xEC\u1E63e n\xEDn\xFA ${n.origin}`;default:return"\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e"}}};var M1=v(()=>{ke()});var pu={};Lt(pu,{ar:()=>jw,az:()=>Zw,be:()=>Uw,bg:()=>Mw,ca:()=>qw,cs:()=>Fw,da:()=>Kw,de:()=>Hw,el:()=>Jw,en:()=>cu,eo:()=>Ww,es:()=>Gw,fa:()=>Qw,fi:()=>Yw,fr:()=>Xw,frCA:()=>ex,he:()=>tx,hr:()=>rx,hu:()=>nx,hy:()=>ox,id:()=>ix,is:()=>sx,it:()=>ax,ja:()=>cx,ka:()=>lx,kh:()=>dx,km:()=>lu,ko:()=>px,lt:()=>fx,mk:()=>mx,ms:()=>hx,nl:()=>gx,no:()=>yx,ota:()=>bx,pl:()=>vx,ps:()=>Sx,pt:()=>wx,ro:()=>xx,ru:()=>_x,sl:()=>Ex,sv:()=>kx,ta:()=>Ix,th:()=>Ax,tr:()=>Tx,ua:()=>$x,uk:()=>du,ur:()=>Ox,uz:()=>Cx,vi:()=>Px,yo:()=>Dx,zhCN:()=>zx,zhTW:()=>Nx});var Lx=v(()=>{FC();KC();JC();VC();WC();GC();QC();YC();XC();Vw();e1();t1();r1();n1();o1();i1();s1();a1();c1();u1();d1();p1();f1();m1();h1();g1();ux();y1();S1();v1();w1();x1();_1();E1();k1();I1();A1();T1();$1();O1();C1();P1();z1();N1();D1();Rx();L1();B1();j1();Z1();U1();M1()});class Zx{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let r=t[0];if(this._map.set(e,r),r&&typeof r==="object"&&"id"in r)this._idmap.set(r.id,e);return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);if(t&&typeof t==="object"&&"id"in t)this._idmap.delete(t.id);return this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let r={...this.get(t)??{}};delete r.id;let o={...r,...this._map.get(e)};return Object.keys(o).length?o:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function Uf(){return new Zx}var q1,Bx,jx,qt;var fu=v(()=>{Bx=Symbol("ZodOutput"),jx=Symbol("ZodInput");(q1=globalThis).__zod_globalRegistry??(q1.__zod_globalRegistry=Uf());qt=globalThis.__zod_globalRegistry});function Ux(e,t){return new e({type:"string",...de(t)})}function Mx(e,t){return new e({type:"string",coerce:!0,...de(t)})}function Mf(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...de(t)})}function mu(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...de(t)})}function qf(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...de(t)})}function Ff(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...de(t)})}function Kf(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...de(t)})}function Hf(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...de(t)})}function hu(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...de(t)})}function Jf(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...de(t)})}function Vf(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...de(t)})}function Wf(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...de(t)})}function Gf(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...de(t)})}function Qf(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...de(t)})}function Yf(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...de(t)})}function Xf(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...de(t)})}function em(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...de(t)})}function tm(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...de(t)})}function qx(e,t){return new e({type:"string",format:"mac",check:"string_format",abort:!1,...de(t)})}function rm(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...de(t)})}function nm(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...de(t)})}function om(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...de(t)})}function im(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...de(t)})}function sm(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...de(t)})}function am(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...de(t)})}function Kx(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...de(t)})}function Hx(e,t){return new e({type:"string",format:"date",check:"string_format",...de(t)})}function Jx(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...de(t)})}function Vx(e,t){return new e({type:"string",format:"duration",check:"string_format",...de(t)})}function Wx(e,t){return new e({type:"number",checks:[],...de(t)})}function Gx(e,t){return new e({type:"number",coerce:!0,checks:[],...de(t)})}function Qx(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...de(t)})}function Yx(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float32",...de(t)})}function Xx(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float64",...de(t)})}function e0(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"int32",...de(t)})}function t0(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"uint32",...de(t)})}function r0(e,t){return new e({type:"boolean",...de(t)})}function n0(e,t){return new e({type:"boolean",coerce:!0,...de(t)})}function o0(e,t){return new e({type:"bigint",...de(t)})}function i0(e,t){return new e({type:"bigint",coerce:!0,...de(t)})}function s0(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"int64",...de(t)})}function a0(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",...de(t)})}function c0(e,t){return new e({type:"symbol",...de(t)})}function l0(e,t){return new e({type:"undefined",...de(t)})}function u0(e,t){return new e({type:"null",...de(t)})}function d0(e){return new e({type:"any"})}function p0(e){return new e({type:"unknown"})}function f0(e,t){return new e({type:"never",...de(t)})}function m0(e,t){return new e({type:"void",...de(t)})}function h0(e,t){return new e({type:"date",...de(t)})}function g0(e,t){return new e({type:"date",coerce:!0,...de(t)})}function y0(e,t){return new e({type:"nan",...de(t)})}function zn(e,t){return new Tf({check:"less_than",...de(t),value:e,inclusive:!1})}function Pr(e,t){return new Tf({check:"less_than",...de(t),value:e,inclusive:!0})}function Nn(e,t){return new Rf({check:"greater_than",...de(t),value:e,inclusive:!1})}function pr(e,t){return new Rf({check:"greater_than",...de(t),value:e,inclusive:!0})}function cm(e){return Nn(0,e)}function lm(e){return zn(0,e)}function um(e){return Pr(0,e)}function dm(e){return pr(0,e)}function ni(e,t){return new cv({check:"multiple_of",...de(t),value:e})}function oi(e,t){return new dv({check:"max_size",...de(t),maximum:e})}function Dn(e,t){return new pv({check:"min_size",...de(t),minimum:e})}function vs(e,t){return new fv({check:"size_equals",...de(t),size:e})}function ws(e,t){return new mv({check:"max_length",...de(t),maximum:e})}function co(e,t){return new hv({check:"min_length",...de(t),minimum:e})}function xs(e,t){return new gv({check:"length_equals",...de(t),length:e})}function ja(e,t){return new yv({check:"string_format",format:"regex",...de(t),pattern:e})}function Za(e){return new bv({check:"string_format",format:"lowercase",...de(e)})}function Ua(e){return new Sv({check:"string_format",format:"uppercase",...de(e)})}function Ma(e,t){return new vv({check:"string_format",format:"includes",...de(t),includes:e})}function qa(e,t){return new wv({check:"string_format",format:"starts_with",...de(t),prefix:e})}function Fa(e,t){return new xv({check:"string_format",format:"ends_with",...de(t),suffix:e})}function pm(e,t,r){return new _v({check:"property",property:e,schema:t,...de(r)})}function Ka(e,t){return new Ev({check:"mime_type",mime:e,...de(t)})}function un(e){return new kv({check:"overwrite",tx:e})}function Ha(e){return un((t)=>t.normalize(e))}function Ja(){return un((e)=>e.trim())}function Va(){return un((e)=>e.toLowerCase())}function Wa(){return un((e)=>e.toUpperCase())}function Ga(){return un((e)=>SS(e))}function b0(e,t,r){return new e({type:"array",element:t,...de(r)})}function dV(e,t,r){return new e({type:"union",options:t,...de(r)})}function pV(e,t,r){return new e({type:"union",options:t,inclusive:!1,...de(r)})}function fV(e,t,r,o){return new e({type:"union",options:r,discriminator:t,...de(o)})}function mV(e,t,r){return new e({type:"intersection",left:t,right:r})}function hV(e,t,r,o){let n=r instanceof Ne;return new e({type:"tuple",items:t,rest:n?r:null,...de(n?o:r)})}function gV(e,t,r,o){return new e({type:"record",keyType:t,valueType:r,...de(o)})}function yV(e,t,r,o){return new e({type:"map",keyType:t,valueType:r,...de(o)})}function bV(e,t,r){return new e({type:"set",valueType:t,...de(r)})}function SV(e,t,r){let o=Array.isArray(t)?Object.fromEntries(t.map((n)=>[n,n])):t;return new e({type:"enum",entries:o,...de(r)})}function vV(e,t,r){return new e({type:"enum",entries:t,...de(r)})}function wV(e,t,r){return new e({type:"literal",values:Array.isArray(t)?t:[t],...de(r)})}function S0(e,t){return new e({type:"file",...de(t)})}function xV(e,t){return new e({type:"transform",transform:t})}function _V(e,t){return new e({type:"optional",innerType:t})}function EV(e,t){return new e({type:"nullable",innerType:t})}function kV(e,t,r){return new e({type:"default",innerType:t,get defaultValue(){return typeof r==="function"?r():wS(r)}})}function IV(e,t,r){return new e({type:"nonoptional",innerType:t,...de(r)})}function AV(e,t){return new e({type:"success",innerType:t})}function TV(e,t,r){return new e({type:"catch",innerType:t,catchValue:typeof r==="function"?r:()=>r})}function RV(e,t,r){return new e({type:"pipe",in:t,out:r})}function $V(e,t){return new e({type:"readonly",innerType:t})}function OV(e,t,r){return new e({type:"template_literal",parts:t,...de(r)})}function CV(e,t){return new e({type:"lazy",getter:t})}function PV(e,t){return new e({type:"promise",innerType:t})}function v0(e,t,r){let o=de(r);return o.abort??(o.abort=!0),new e({type:"custom",check:"custom",fn:t,...o})}function w0(e,t,r){return new e({type:"custom",check:"custom",fn:t,...de(r)})}function x0(e,t){let r=F1((o)=>(o.addIssue=(n)=>{if(typeof n==="string")o.issues.push(Ca(n,o.value,r._zod.def));else{let i=n;if(i.fatal)i.continue=!1;i.code??(i.code="custom"),i.input??(i.input=o.value),i.inst??(i.inst=r),i.continue??(i.continue=!r._zod.def.abort),o.issues.push(Ca(i))}},e(o.value,o)),t);return r}function F1(e,t){let r=new rt({check:"custom",...de(t)});return r._zod.check=e,r}function _0(e){let t=new rt({check:"describe"});return t._zod.onattach=[(r)=>{let o=qt.get(r)??{};qt.add(r,{...o,description:e})}],t._zod.check=()=>{},t}function E0(e){let t=new rt({check:"meta"});return t._zod.onattach=[(r)=>{let o=qt.get(r)??{};qt.add(r,{...o,...e})}],t._zod.check=()=>{},t}function k0(e,t){let r=de(t),o=r.truthy??["true","1","yes","on","y","enabled"],n=r.falsy??["false","0","no","off","n","disabled"];if(r.case!=="sensitive")o=o.map((h)=>typeof h==="string"?h.toLowerCase():h),n=n.map((h)=>typeof h==="string"?h.toLowerCase():h);let i=new Set(o),s=new Set(n),a=e.Codec??au,c=e.Boolean??iu,d=new(e.String??Ss)({type:"string",error:r.error}),p=new c({type:"boolean",error:r.error}),m=new a({type:"pipe",in:d,out:p,transform:(h,b)=>{let y=h;if(r.case!=="sensitive")y=y.toLowerCase();if(i.has(y))return!0;else if(s.has(y))return!1;else return b.issues.push({code:"invalid_value",expected:"stringbool",values:[...i,...s],input:b.value,inst:m,continue:!1}),{}},reverseTransform:(h,b)=>{if(h===!0)return o[0]||"true";else return n[0]||"false"},error:r.error});return m}function Qa(e,t,r,o={}){let n=de(o),i={...de(o),check:"string_format",type:"string",format:t,fn:typeof r==="function"?r:(a)=>r.test(a),...n};if(r instanceof RegExp)i.pattern=r;return new e(i)}var Fx;var K1=v(()=>{$f();fu();Bw();ke();Fx={Any:null,Minute:-1,Second:0,Millisecond:3,Microsecond:6}});function ii(e){let t=e?.target??"draft-2020-12";if(t==="draft-4")t="draft-04";if(t==="draft-7")t="draft-07";return{processors:e.processors??{},metadataRegistry:e?.metadata??qt,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function We(e,t,r={path:[],schemaPath:[]}){var o;let n=e._zod.def,i=t.seen.get(e);if(i){if(i.count++,r.schemaPath.includes(e))i.cycle=r.path;return i.schema}let s={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,s);let a=e._zod.toJSONSchema?.();if(a)s.schema=a;else{let d={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,s.schema,d);else{let m=s.schema,h=t.processors[n.type];if(!h)throw Error(`[toJSONSchema]: Non-representable type encountered: ${n.type}`);h(e,t,m,d)}let p=e._zod.parent;if(p){if(!s.ref)s.ref=p;We(p,t,d),t.seen.get(p).isParent=!0}}let c=t.metadataRegistry.get(e);if(c)Object.assign(s.schema,c);if(t.io==="input"&&fr(e))delete s.schema.examples,delete s.schema.default;if(t.io==="input"&&"_prefault"in s.schema)(o=s.schema).default??(o.default=s.schema._prefault);return delete s.schema._prefault,t.seen.get(e).schema}function si(e,t){let r=e.seen.get(t);if(!r)throw Error("Unprocessed schema. This is a bug in Zod.");let o=new Map;for(let s of e.seen.entries()){let a=e.metadataRegistry.get(s[0])?.id;if(a){let c=o.get(a);if(c&&c!==s[0])throw Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);o.set(a,s[0])}}let n=(s)=>{let a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let p=e.external.registry.get(s[0])?.id,m=e.external.uri??((b)=>b);if(p)return{ref:m(p)};let h=s[1].defId??s[1].schema.id??`schema${e.counter++}`;return s[1].defId=h,{defId:h,ref:`${m("__shared")}#/${a}/${h}`}}if(s[1]===r)return{ref:"#"};let u=`${"#"}/${a}/`,d=s[1].schema.id??`__schema${e.counter++}`;return{defId:d,ref:u+d}},i=(s)=>{if(s[1].schema.$ref)return;let a=s[1],{ref:c,defId:u}=n(s);if(a.def={...a.schema},u)a.defId=u;let d=a.schema;for(let p in d)delete d[p];d.$ref=c};if(e.cycles==="throw")for(let s of e.seen.entries()){let a=s[1];if(a.cycle)throw Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
|
|
232
232
|
|
|
233
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let s of e.seen.entries()){let a=s[1];if(t===s[0]){i(s);continue}if(e.external){let u=e.external.registry.get(s[0])?.id;if(t!==s[0]&&u){i(s);continue}}if(e.metadataRegistry.get(s[0])?.id){i(s);continue}if(a.cycle){i(s);continue}if(a.count>1){if(e.reused==="ref"){i(s);continue}}}}function ai(e,t){let r=e.seen.get(t);if(!r)throw Error("Unprocessed schema. This is a bug in Zod.");let o=(a)=>{let c=e.seen.get(a);if(c.ref===null)return;let u=c.def??c.schema,d={...u},p=c.ref;if(c.ref=null,p){o(p);let h=e.seen.get(p),b=h.schema;if(b.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"))u.allOf=u.allOf??[],u.allOf.push(b);else Object.assign(u,b);if(Object.assign(u,d),a._zod.parent===p)for(let S in u){if(S==="$ref"||S==="allOf")continue;if(!(S in d))delete u[S]}if(b.$ref&&h.def)for(let S in u){if(S==="$ref"||S==="allOf")continue;if(S in h.def&&JSON.stringify(u[S])===JSON.stringify(h.def[S]))delete u[S]}}let m=a._zod.parent;if(m&&m!==p){o(m);let h=e.seen.get(m);if(h?.schema.$ref){if(u.$ref=h.schema.$ref,h.def)for(let b in u){if(b==="$ref"||b==="allOf")continue;if(b in h.def&&JSON.stringify(u[b])===JSON.stringify(h.def[b]))delete u[b]}}}e.override({zodSchema:a,jsonSchema:u,path:c.path??[]})};for(let a of[...e.seen.entries()].reverse())o(a[0]);let n={};if(e.target==="draft-2020-12")n.$schema="https://json-schema.org/draft/2020-12/schema";else if(e.target==="draft-07")n.$schema="http://json-schema.org/draft-07/schema#";else if(e.target==="draft-04")n.$schema="http://json-schema.org/draft-04/schema#";else if(e.target==="openapi-3.0");if(e.external?.uri){let a=e.external.registry.get(t)?.id;if(!a)throw Error("Schema is missing an `id` property");n.$id=e.external.uri(a)}Object.assign(n,r.def??r.schema);let i=e.metadataRegistry.get(t)?.id;if(i!==void 0&&n.id===i)delete n.id;let s=e.external?.defs??{};for(let a of e.seen.entries()){let c=a[1];if(c.def&&c.defId){if(c.def.id===c.defId)delete c.def.id;s[c.defId]=c.def}}if(e.external);else if(Object.keys(s).length>0)if(e.target==="draft-2020-12")n.$defs=s;else n.definitions=s;try{let a=JSON.parse(JSON.stringify(n));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:Ya(t,"input",e.processors),output:Ya(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch(a){throw Error("Error converting schema to JSON.")}}function fr(e,t){let r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);let o=e._zod.def;if(o.type==="transform")return!0;if(o.type==="array")return fr(o.element,r);if(o.type==="set")return fr(o.valueType,r);if(o.type==="lazy")return fr(o.getter(),r);if(o.type==="promise"||o.type==="optional"||o.type==="nonoptional"||o.type==="nullable"||o.type==="readonly"||o.type==="default"||o.type==="prefault")return fr(o.innerType,r);if(o.type==="intersection")return fr(o.left,r)||fr(o.right,r);if(o.type==="record"||o.type==="map")return fr(o.keyType,r)||fr(o.valueType,r);if(o.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return fr(o.in,r)||fr(o.out,r)}if(o.type==="object"){for(let n in o.shape)if(fr(o.shape[n],r))return!0;return!1}if(o.type==="union"){for(let n of o.options)if(fr(n,r))return!0;return!1}if(o.type==="tuple"){for(let n of o.items)if(fr(n,r))return!0;if(o.rest&&fr(o.rest,r))return!0;return!1}return!1}var I0=(e,t={})=>(r)=>{let o=ii({...r,processors:t});return We(e,o),si(o,e),ai(o,e)},Ya=(e,t,r={})=>(o)=>{let{libraryOptions:n,target:i}=o??{},s=ii({...n??{},target:i,io:t,processors:r});return We(e,s),si(s,e),ai(s,e)};var gu=v(()=>{fu()});function gm(e,t){if("_idmap"in e){let o=e,n=ii({...t,processors:fm}),i={};for(let c of o._idmap.entries()){let[u,d]=c;We(d,n)}let s={},a={registry:o,uri:t?.uri,defs:i};n.external=a;for(let c of o._idmap.entries()){let[u,d]=c;si(n,d),s[u]=ai(n,d)}if(Object.keys(i).length>0){let c=n.target==="draft-2020-12"?"$defs":"definitions";s.__shared={[c]:i}}return{schemas:s}}let r=ii({...t,processors:fm});return We(e,r),si(r,e),ai(r,e)}var zV,A0=(e,t,r,o)=>{let n=r;n.type="string";let{minimum:i,maximum:s,format:a,patterns:c,contentEncoding:u}=e._zod.bag;if(typeof i==="number")n.minLength=i;if(typeof s==="number")n.maxLength=s;if(a){if(n.format=zV[a]??a,n.format==="")delete n.format;if(a==="time")delete n.format}if(u)n.contentEncoding=u;if(c&&c.size>0){let d=[...c];if(d.length===1)n.pattern=d[0].source;else if(d.length>1)n.allOf=[...d.map((p)=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:p.source}))]}},T0=(e,t,r,o)=>{let n=r,{minimum:i,maximum:s,format:a,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:d}=e._zod.bag;if(typeof a==="string"&&a.includes("int"))n.type="integer";else n.type="number";let p=typeof d==="number"&&d>=(i??Number.NEGATIVE_INFINITY),m=typeof u==="number"&&u<=(s??Number.POSITIVE_INFINITY),h=t.target==="draft-04"||t.target==="openapi-3.0";if(p)if(h)n.minimum=d,n.exclusiveMinimum=!0;else n.exclusiveMinimum=d;else if(typeof i==="number")n.minimum=i;if(m)if(h)n.maximum=u,n.exclusiveMaximum=!0;else n.exclusiveMaximum=u;else if(typeof s==="number")n.maximum=s;if(typeof c==="number")n.multipleOf=c},R0=(e,t,r,o)=>{r.type="boolean"},$0=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("BigInt cannot be represented in JSON Schema")},O0=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("Symbols cannot be represented in JSON Schema")},C0=(e,t,r,o)=>{if(t.target==="openapi-3.0")r.type="string",r.nullable=!0,r.enum=[null];else r.type="null"},P0=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("Undefined cannot be represented in JSON Schema")},z0=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("Void cannot be represented in JSON Schema")},N0=(e,t,r,o)=>{r.not={}},D0=(e,t,r,o)=>{},L0=(e,t,r,o)=>{},B0=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("Date cannot be represented in JSON Schema")},j0=(e,t,r,o)=>{let n=e._zod.def,i=Vl(n.entries);if(i.every((s)=>typeof s==="number"))r.type="number";if(i.every((s)=>typeof s==="string"))r.type="string";r.enum=i},Z0=(e,t,r,o)=>{let n=e._zod.def,i=[];for(let s of n.values)if(s===void 0){if(t.unrepresentable==="throw")throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof s==="bigint")if(t.unrepresentable==="throw")throw Error("BigInt literals cannot be represented in JSON Schema");else i.push(Number(s));else i.push(s);if(i.length===0);else if(i.length===1){let s=i[0];if(r.type=s===null?"null":typeof s,t.target==="draft-04"||t.target==="openapi-3.0")r.enum=[s];else r.const=s}else{if(i.every((s)=>typeof s==="number"))r.type="number";if(i.every((s)=>typeof s==="string"))r.type="string";if(i.every((s)=>typeof s==="boolean"))r.type="boolean";if(i.every((s)=>s===null))r.type="null";r.enum=i}},U0=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("NaN cannot be represented in JSON Schema")},M0=(e,t,r,o)=>{let n=r,i=e._zod.pattern;if(!i)throw Error("Pattern not found in template literal");n.type="string",n.pattern=i.source},q0=(e,t,r,o)=>{let n=r,i={type:"string",format:"binary",contentEncoding:"binary"},{minimum:s,maximum:a,mime:c}=e._zod.bag;if(s!==void 0)i.minLength=s;if(a!==void 0)i.maxLength=a;if(c)if(c.length===1)i.contentMediaType=c[0],Object.assign(n,i);else Object.assign(n,i),n.anyOf=c.map((u)=>({contentMediaType:u}));else Object.assign(n,i)},F0=(e,t,r,o)=>{r.type="boolean"},K0=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("Custom types cannot be represented in JSON Schema")},H0=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("Function types cannot be represented in JSON Schema")},J0=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("Transforms cannot be represented in JSON Schema")},V0=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("Map cannot be represented in JSON Schema")},W0=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("Set cannot be represented in JSON Schema")},G0=(e,t,r,o)=>{let n=r,i=e._zod.def,{minimum:s,maximum:a}=e._zod.bag;if(typeof s==="number")n.minItems=s;if(typeof a==="number")n.maxItems=a;n.type="array",n.items=We(i.element,t,{...o,path:[...o.path,"items"]})},Q0=(e,t,r,o)=>{let n=r,i=e._zod.def;n.type="object",n.properties={};let s=i.shape;for(let u in s)n.properties[u]=We(s[u],t,{...o,path:[...o.path,"properties",u]});let a=new Set(Object.keys(s)),c=new Set([...a].filter((u)=>{let d=i.shape[u]._zod;if(t.io==="input")return d.optin===void 0;else return d.optout===void 0}));if(c.size>0)n.required=Array.from(c);if(i.catchall?._zod.def.type==="never")n.additionalProperties=!1;else if(!i.catchall){if(t.io==="output")n.additionalProperties=!1}else if(i.catchall)n.additionalProperties=We(i.catchall,t,{...o,path:[...o.path,"additionalProperties"]})},mm=(e,t,r,o)=>{let n=e._zod.def,i=n.inclusive===!1,s=n.options.map((a,c)=>We(a,t,{...o,path:[...o.path,i?"oneOf":"anyOf",c]}));if(i)r.oneOf=s;else r.anyOf=s},Y0=(e,t,r,o)=>{let n=e._zod.def,i=We(n.left,t,{...o,path:[...o.path,"allOf",0]}),s=We(n.right,t,{...o,path:[...o.path,"allOf",1]}),a=(u)=>("allOf"in u)&&Object.keys(u).length===1,c=[...a(i)?i.allOf:[i],...a(s)?s.allOf:[s]];r.allOf=c},X0=(e,t,r,o)=>{let n=r,i=e._zod.def;n.type="array";let s=t.target==="draft-2020-12"?"prefixItems":"items",a=t.target==="draft-2020-12"?"items":t.target==="openapi-3.0"?"items":"additionalItems",c=i.items.map((m,h)=>We(m,t,{...o,path:[...o.path,s,h]})),u=i.rest?We(i.rest,t,{...o,path:[...o.path,a,...t.target==="openapi-3.0"?[i.items.length]:[]]}):null;if(t.target==="draft-2020-12"){if(n.prefixItems=c,u)n.items=u}else if(t.target==="openapi-3.0"){if(n.items={anyOf:c},u)n.items.anyOf.push(u);if(n.minItems=c.length,!u)n.maxItems=c.length}else if(n.items=c,u)n.additionalItems=u;let{minimum:d,maximum:p}=e._zod.bag;if(typeof d==="number")n.minItems=d;if(typeof p==="number")n.maxItems=p},e_=(e,t,r,o)=>{let n=r,i=e._zod.def;n.type="object";let s=i.keyType,c=s._zod.bag?.patterns;if(i.mode==="loose"&&c&&c.size>0){let d=We(i.valueType,t,{...o,path:[...o.path,"patternProperties","*"]});n.patternProperties={};for(let p of c)n.patternProperties[p.source]=d}else{if(t.target==="draft-07"||t.target==="draft-2020-12")n.propertyNames=We(i.keyType,t,{...o,path:[...o.path,"propertyNames"]});n.additionalProperties=We(i.valueType,t,{...o,path:[...o.path,"additionalProperties"]})}let u=s._zod.values;if(u){let d=[...u].filter((p)=>typeof p==="string"||typeof p==="number");if(d.length>0)n.required=d}},t_=(e,t,r,o)=>{let n=e._zod.def,i=We(n.innerType,t,o),s=t.seen.get(e);if(t.target==="openapi-3.0")s.ref=n.innerType,r.nullable=!0;else r.anyOf=[i,{type:"null"}]},r_=(e,t,r,o)=>{let n=e._zod.def;We(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType},n_=(e,t,r,o)=>{let n=e._zod.def;We(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType,r.default=JSON.parse(JSON.stringify(n.defaultValue))},o_=(e,t,r,o)=>{let n=e._zod.def;We(n.innerType,t,o);let i=t.seen.get(e);if(i.ref=n.innerType,t.io==="input")r._prefault=JSON.parse(JSON.stringify(n.defaultValue))},i_=(e,t,r,o)=>{let n=e._zod.def;We(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType;let s;try{s=n.catchValue(void 0)}catch{throw Error("Dynamic catch values are not supported in JSON Schema")}r.default=s},s_=(e,t,r,o)=>{let n=e._zod.def,i=n.in._zod.traits.has("$ZodTransform"),s=t.io==="input"?i?n.out:n.in:n.out;We(s,t,o);let a=t.seen.get(e);a.ref=s},a_=(e,t,r,o)=>{let n=e._zod.def;We(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType,r.readOnly=!0},c_=(e,t,r,o)=>{let n=e._zod.def;We(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType},hm=(e,t,r,o)=>{let n=e._zod.def;We(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType},l_=(e,t,r,o)=>{let n=e._zod.innerType;We(n,t,o);let i=t.seen.get(e);i.ref=n},fm;var yu=v(()=>{gu();ke();zV={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},fm={string:A0,number:T0,boolean:R0,bigint:$0,symbol:O0,null:C0,undefined:P0,void:z0,never:N0,any:D0,unknown:L0,date:B0,enum:j0,literal:Z0,nan:U0,template_literal:M0,file:q0,success:F0,custom:K0,function:H0,transform:J0,map:V0,set:W0,array:G0,object:Q0,union:mm,intersection:Y0,tuple:X0,record:e_,nullable:t_,nonoptional:r_,default:n_,prefault:o_,catch:i_,pipe:s_,readonly:a_,promise:c_,optional:hm,lazy:l_}});class u_{get metadataRegistry(){return this.ctx.metadataRegistry}get target(){return this.ctx.target}get unrepresentable(){return this.ctx.unrepresentable}get override(){return this.ctx.override}get io(){return this.ctx.io}get counter(){return this.ctx.counter}set counter(e){this.ctx.counter=e}get seen(){return this.ctx.seen}constructor(e){let t=e?.target??"draft-2020-12";if(t==="draft-4")t="draft-04";if(t==="draft-7")t="draft-07";this.ctx=ii({processors:fm,target:t,...e?.metadata&&{metadata:e.metadata},...e?.unrepresentable&&{unrepresentable:e.unrepresentable},...e?.override&&{override:e.override},...e?.io&&{io:e.io}})}process(e,t={path:[],schemaPath:[]}){return We(e,this.ctx,t)}emit(e,t){if(t){if(t.cycles)this.ctx.cycles=t.cycles;if(t.reused)this.ctx.reused=t.reused;if(t.external)this.ctx.external=t.external}si(this.ctx,e);let r=ai(this.ctx,e),{"~standard":o,...n}=r;return n}}var H1=v(()=>{yu();gu()});var J1={};var V1=()=>{};var lo={};Lt(lo,{$ZodAny:()=>sw,$ZodArray:()=>dw,$ZodAsyncError:()=>Pn,$ZodBase64:()=>Gv,$ZodBase64URL:()=>Qv,$ZodBigInt:()=>Lf,$ZodBigIntFormat:()=>rw,$ZodBoolean:()=>iu,$ZodCIDRv4:()=>Jv,$ZodCIDRv6:()=>Vv,$ZodCUID:()=>Nv,$ZodCUID2:()=>Dv,$ZodCatch:()=>Rw,$ZodCheck:()=>rt,$ZodCheckBigIntFormat:()=>uv,$ZodCheckEndsWith:()=>xv,$ZodCheckGreaterThan:()=>Rf,$ZodCheckIncludes:()=>vv,$ZodCheckLengthEquals:()=>gv,$ZodCheckLessThan:()=>Tf,$ZodCheckLowerCase:()=>bv,$ZodCheckMaxLength:()=>mv,$ZodCheckMaxSize:()=>dv,$ZodCheckMimeType:()=>Ev,$ZodCheckMinLength:()=>hv,$ZodCheckMinSize:()=>pv,$ZodCheckMultipleOf:()=>cv,$ZodCheckNumberFormat:()=>lv,$ZodCheckOverwrite:()=>kv,$ZodCheckProperty:()=>_v,$ZodCheckRegex:()=>yv,$ZodCheckSizeEquals:()=>fv,$ZodCheckStartsWith:()=>wv,$ZodCheckStringFormat:()=>La,$ZodCheckUpperCase:()=>Sv,$ZodCodec:()=>au,$ZodCustom:()=>Lw,$ZodCustomStringFormat:()=>ew,$ZodDate:()=>uw,$ZodDefault:()=>kw,$ZodDiscriminatedUnion:()=>mw,$ZodE164:()=>Yv,$ZodEmail:()=>Ov,$ZodEmoji:()=>Pv,$ZodEncodeError:()=>hs,$ZodEnum:()=>Sw,$ZodError:()=>Xl,$ZodExactOptional:()=>_w,$ZodFile:()=>ww,$ZodFunction:()=>zw,$ZodGUID:()=>Rv,$ZodIPv4:()=>Fv,$ZodIPv6:()=>Kv,$ZodISODate:()=>Uv,$ZodISODateTime:()=>Zv,$ZodISODuration:()=>qv,$ZodISOTime:()=>Mv,$ZodIntersection:()=>hw,$ZodJWT:()=>Xv,$ZodKSUID:()=>jv,$ZodLazy:()=>Dw,$ZodLiteral:()=>vw,$ZodMAC:()=>Hv,$ZodMap:()=>yw,$ZodNaN:()=>$w,$ZodNanoID:()=>zv,$ZodNever:()=>cw,$ZodNonOptional:()=>Aw,$ZodNull:()=>iw,$ZodNullable:()=>Ew,$ZodNumber:()=>Df,$ZodNumberFormat:()=>tw,$ZodObject:()=>qC,$ZodObjectJIT:()=>pw,$ZodOptional:()=>jf,$ZodPipe:()=>Zf,$ZodPrefault:()=>Iw,$ZodPreprocess:()=>Ow,$ZodPromise:()=>Nw,$ZodReadonly:()=>Cw,$ZodRealError:()=>xr,$ZodRecord:()=>gw,$ZodRegistry:()=>Zx,$ZodSet:()=>bw,$ZodString:()=>Ss,$ZodStringFormat:()=>Ye,$ZodSuccess:()=>Tw,$ZodSymbol:()=>nw,$ZodTemplateLiteral:()=>Pw,$ZodTransform:()=>xw,$ZodTuple:()=>Bf,$ZodType:()=>Ne,$ZodULID:()=>Lv,$ZodURL:()=>Cv,$ZodUUID:()=>$v,$ZodUndefined:()=>ow,$ZodUnion:()=>su,$ZodUnknown:()=>aw,$ZodVoid:()=>lw,$ZodXID:()=>Bv,$ZodXor:()=>fw,$brand:()=>gS,$constructor:()=>Z,$input:()=>jx,$output:()=>Bx,Doc:()=>Of,JSONSchema:()=>J1,JSONSchemaGenerator:()=>u_,NEVER:()=>hS,TimePrecision:()=>Fx,_any:()=>d0,_array:()=>b0,_base64:()=>om,_base64url:()=>im,_bigint:()=>o0,_boolean:()=>r0,_catch:()=>TV,_check:()=>F1,_cidrv4:()=>rm,_cidrv6:()=>nm,_coercedBigint:()=>i0,_coercedBoolean:()=>n0,_coercedDate:()=>g0,_coercedNumber:()=>Gx,_coercedString:()=>Mx,_cuid:()=>Wf,_cuid2:()=>Gf,_custom:()=>v0,_date:()=>h0,_decode:()=>Sf,_decodeAsync:()=>wf,_default:()=>kV,_discriminatedUnion:()=>fV,_e164:()=>sm,_email:()=>Mf,_emoji:()=>Jf,_encode:()=>bf,_encodeAsync:()=>vf,_endsWith:()=>Fa,_enum:()=>SV,_file:()=>S0,_float32:()=>Yx,_float64:()=>Xx,_gt:()=>Nn,_gte:()=>pr,_guid:()=>mu,_includes:()=>Ma,_int:()=>Qx,_int32:()=>e0,_int64:()=>s0,_intersection:()=>mV,_ipv4:()=>em,_ipv6:()=>tm,_isoDate:()=>Hx,_isoDateTime:()=>Kx,_isoDuration:()=>Vx,_isoTime:()=>Jx,_jwt:()=>am,_ksuid:()=>Xf,_lazy:()=>CV,_length:()=>xs,_literal:()=>wV,_lowercase:()=>Za,_lt:()=>zn,_lte:()=>Pr,_mac:()=>qx,_map:()=>yV,_max:()=>Pr,_maxLength:()=>ws,_maxSize:()=>oi,_mime:()=>Ka,_min:()=>pr,_minLength:()=>co,_minSize:()=>Dn,_multipleOf:()=>ni,_nan:()=>y0,_nanoid:()=>Vf,_nativeEnum:()=>vV,_negative:()=>lm,_never:()=>f0,_nonnegative:()=>dm,_nonoptional:()=>IV,_nonpositive:()=>um,_normalize:()=>Ha,_null:()=>u0,_nullable:()=>EV,_number:()=>Wx,_optional:()=>_V,_overwrite:()=>un,_parse:()=>Pa,_parseAsync:()=>za,_pipe:()=>RV,_positive:()=>cm,_promise:()=>PV,_property:()=>pm,_readonly:()=>$V,_record:()=>gV,_refine:()=>w0,_regex:()=>ja,_safeDecode:()=>_f,_safeDecodeAsync:()=>kf,_safeEncode:()=>xf,_safeEncodeAsync:()=>Ef,_safeParse:()=>Na,_safeParseAsync:()=>Da,_set:()=>bV,_size:()=>vs,_slugify:()=>Ga,_startsWith:()=>qa,_string:()=>Ux,_stringFormat:()=>Qa,_stringbool:()=>k0,_success:()=>AV,_superRefine:()=>x0,_symbol:()=>c0,_templateLiteral:()=>OV,_toLowerCase:()=>Va,_toUpperCase:()=>Wa,_transform:()=>xV,_trim:()=>Ja,_tuple:()=>hV,_uint32:()=>t0,_uint64:()=>a0,_ulid:()=>Qf,_undefined:()=>l0,_union:()=>dV,_unknown:()=>p0,_uppercase:()=>Ua,_url:()=>hu,_uuid:()=>qf,_uuidv4:()=>Ff,_uuidv6:()=>Kf,_uuidv7:()=>Hf,_void:()=>m0,_xid:()=>Yf,_xor:()=>pV,clone:()=>ur,config:()=>gt,createStandardJSONSchemaMethod:()=>Ya,createToJSONSchemaMethod:()=>I0,decode:()=>PH,decodeAsync:()=>NH,describe:()=>_0,encode:()=>CH,encodeAsync:()=>zH,extractDefs:()=>si,finalize:()=>ai,flattenError:()=>eu,formatError:()=>tu,globalConfig:()=>ms,globalRegistry:()=>qt,initializeContext:()=>ii,isValidBase64:()=>Wv,isValidBase64URL:()=>jC,isValidJWT:()=>ZC,locales:()=>pu,meta:()=>E0,parse:()=>gf,parseAsync:()=>yf,prettifyError:()=>TS,process:()=>We,regexes:()=>Cr,registry:()=>Uf,safeDecode:()=>LH,safeDecodeAsync:()=>jH,safeEncode:()=>DH,safeEncodeAsync:()=>BH,safeParse:()=>$S,safeParseAsync:()=>OS,toDotPath:()=>bC,toJSONSchema:()=>gm,treeifyError:()=>AS,util:()=>ue,version:()=>Iv});var zr=v(()=>{ke();Af();Lx();yu();H1();V1();gs();CS();RS();Bw();$f();Av();fu();K1();gu()});var ym={};Lt(ym,{endsWith:()=>Fa,gt:()=>Nn,gte:()=>pr,includes:()=>Ma,length:()=>xs,lowercase:()=>Za,lt:()=>zn,lte:()=>Pr,maxLength:()=>ws,maxSize:()=>oi,mime:()=>Ka,minLength:()=>co,minSize:()=>Dn,multipleOf:()=>ni,negative:()=>lm,nonnegative:()=>dm,nonpositive:()=>um,normalize:()=>Ha,overwrite:()=>un,positive:()=>cm,property:()=>pm,regex:()=>ja,size:()=>vs,slugify:()=>Ga,startsWith:()=>qa,toLowerCase:()=>Va,toUpperCase:()=>Wa,trim:()=>Ja,uppercase:()=>Ua});var bm=v(()=>{zr()});var Xa={};Lt(Xa,{ZodISODate:()=>vm,ZodISODateTime:()=>Sm,ZodISODuration:()=>xm,ZodISOTime:()=>wm,date:()=>p_,datetime:()=>d_,duration:()=>m_,time:()=>f_});function d_(e){return Kx(Sm,e)}function p_(e){return Hx(vm,e)}function f_(e){return Jx(wm,e)}function m_(e){return Vx(xm,e)}var Sm,vm,wm,xm;var bu=v(()=>{zr();vu();Sm=Z("ZodISODateTime",(e,t)=>{Zv.init(e,t),Xe.init(e,t)});vm=Z("ZodISODate",(e,t)=>{Uv.init(e,t),Xe.init(e,t)});wm=Z("ZodISOTime",(e,t)=>{Mv.init(e,t),Xe.init(e,t)});xm=Z("ZodISODuration",(e,t)=>{qv.init(e,t),Xe.init(e,t)})});var W1=(e,t)=>{Xl.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:(r)=>tu(e,r)},flatten:{value:(r)=>eu(e,r)},addIssue:{value:(r)=>{e.issues.push(r),e.message=JSON.stringify(e.issues,$a,2)}},addIssues:{value:(r)=>{e.issues.push(...r),e.message=JSON.stringify(e.issues,$a,2)}},isEmpty:{get(){return e.issues.length===0}}})},G1,_r;var h_=v(()=>{zr();zr();ke();G1=Z("ZodError",W1),_r=Z("ZodError",W1,{Parent:Error})});var g_,y_,b_,S_,v_,w_,x_,__,E_,k_,I_,A_;var T_=v(()=>{zr();h_();g_=Pa(_r),y_=za(_r),b_=Na(_r),S_=Da(_r),v_=bf(_r),w_=Sf(_r),x_=vf(_r),__=wf(_r),E_=xf(_r),k_=_f(_r),I_=Ef(_r),A_=kf(_r)});var Su={};Lt(Su,{ZodAny:()=>D_,ZodArray:()=>Z_,ZodBase64:()=>Bm,ZodBase64URL:()=>jm,ZodBigInt:()=>sc,ZodBigIntFormat:()=>Mm,ZodBoolean:()=>ic,ZodCIDRv4:()=>Dm,ZodCIDRv6:()=>Lm,ZodCUID:()=>Rm,ZodCUID2:()=>$m,ZodCatch:()=>cE,ZodCodec:()=>Cu,ZodCustom:()=>Pu,ZodCustomStringFormat:()=>nc,ZodDate:()=>Au,ZodDefault:()=>rE,ZodDiscriminatedUnion:()=>M_,ZodE164:()=>Zm,ZodEmail:()=>Im,ZodEmoji:()=>Am,ZodEnum:()=>tc,ZodExactOptional:()=>X_,ZodFile:()=>Q_,ZodFunction:()=>bE,ZodGUID:()=>xu,ZodIPv4:()=>zm,ZodIPv6:()=>Nm,ZodIntersection:()=>q_,ZodJWT:()=>Um,ZodKSUID:()=>Pm,ZodLazy:()=>hE,ZodLiteral:()=>G_,ZodMAC:()=>R_,ZodMap:()=>V_,ZodNaN:()=>uE,ZodNanoID:()=>Tm,ZodNever:()=>B_,ZodNonOptional:()=>Vm,ZodNull:()=>z_,ZodNullable:()=>tE,ZodNumber:()=>oc,ZodNumberFormat:()=>Es,ZodObject:()=>Ru,ZodOptional:()=>Jm,ZodPipe:()=>Ou,ZodPrefault:()=>oE,ZodPreprocess:()=>dE,ZodPromise:()=>yE,ZodReadonly:()=>pE,ZodRecord:()=>ec,ZodSet:()=>W_,ZodString:()=>rc,ZodStringFormat:()=>Xe,ZodSuccess:()=>aE,ZodSymbol:()=>C_,ZodTemplateLiteral:()=>mE,ZodTransform:()=>Y_,ZodTuple:()=>K_,ZodType:()=>Be,ZodULID:()=>Om,ZodURL:()=>Iu,ZodUUID:()=>Ln,ZodUndefined:()=>P_,ZodUnion:()=>$u,ZodUnknown:()=>L_,ZodVoid:()=>j_,ZodXID:()=>Cm,ZodXor:()=>U_,_ZodString:()=>km,_default:()=>nE,_function:()=>oz,any:()=>NP,array:()=>Tu,base64:()=>bP,base64url:()=>SP,bigint:()=>$P,boolean:()=>O_,catch:()=>lE,check:()=>iz,cidrv4:()=>gP,cidrv6:()=>yP,codec:()=>ez,cuid:()=>cP,cuid2:()=>lP,custom:()=>sz,date:()=>LP,describe:()=>az,discriminatedUnion:()=>qP,e164:()=>vP,email:()=>Y1,emoji:()=>sP,enum:()=>Km,exactOptional:()=>eE,file:()=>GP,float32:()=>IP,float64:()=>AP,function:()=>oz,guid:()=>X1,hash:()=>kP,hex:()=>EP,hostname:()=>_P,httpUrl:()=>iP,instanceof:()=>lz,int:()=>_m,int32:()=>TP,int64:()=>OP,intersection:()=>F_,invertCodec:()=>tz,ipv4:()=>fP,ipv6:()=>hP,json:()=>dz,jwt:()=>wP,keyof:()=>BP,ksuid:()=>pP,lazy:()=>gE,literal:()=>WP,looseObject:()=>UP,looseRecord:()=>KP,mac:()=>mP,map:()=>HP,meta:()=>cz,nan:()=>XP,nanoid:()=>aP,nativeEnum:()=>VP,never:()=>qm,nonoptional:()=>sE,null:()=>N_,nullable:()=>Eu,nullish:()=>QP,number:()=>$_,object:()=>jP,optional:()=>_u,partialRecord:()=>FP,pipe:()=>Em,prefault:()=>iE,preprocess:()=>pz,promise:()=>nz,readonly:()=>fE,record:()=>J_,refine:()=>SE,set:()=>JP,strictObject:()=>ZP,string:()=>wu,stringFormat:()=>xP,stringbool:()=>uz,success:()=>YP,superRefine:()=>vE,symbol:()=>PP,templateLiteral:()=>rz,transform:()=>Hm,tuple:()=>H_,uint32:()=>RP,uint64:()=>CP,ulid:()=>uP,undefined:()=>zP,union:()=>Fm,unknown:()=>_s,url:()=>oP,uuid:()=>eP,uuidv4:()=>tP,uuidv6:()=>rP,uuidv7:()=>nP,void:()=>DP,xid:()=>dP,xor:()=>MP});function ku(e,t,r){let o=Object.getPrototypeOf(e),n=Q1.get(o);if(!n)n=new Set,Q1.set(o,n);if(n.has(t))return;n.add(t);for(let i in r){let s=r[i];Object.defineProperty(o,i,{configurable:!0,enumerable:!1,get(){let a=s.bind(this);return Object.defineProperty(this,i,{configurable:!0,writable:!0,enumerable:!0,value:a}),a},set(a){Object.defineProperty(this,i,{configurable:!0,writable:!0,enumerable:!0,value:a})}})}}function wu(e){return Ux(rc,e)}function Y1(e){return Mf(Im,e)}function X1(e){return mu(xu,e)}function eP(e){return qf(Ln,e)}function tP(e){return Ff(Ln,e)}function rP(e){return Kf(Ln,e)}function nP(e){return Hf(Ln,e)}function oP(e){return hu(Iu,e)}function iP(e){return hu(Iu,{protocol:Cr.httpProtocol,hostname:Cr.domain,...ue.normalizeParams(e)})}function sP(e){return Jf(Am,e)}function aP(e){return Vf(Tm,e)}function cP(e){return Wf(Rm,e)}function lP(e){return Gf($m,e)}function uP(e){return Qf(Om,e)}function dP(e){return Yf(Cm,e)}function pP(e){return Xf(Pm,e)}function fP(e){return em(zm,e)}function mP(e){return qx(R_,e)}function hP(e){return tm(Nm,e)}function gP(e){return rm(Dm,e)}function yP(e){return nm(Lm,e)}function bP(e){return om(Bm,e)}function SP(e){return im(jm,e)}function vP(e){return sm(Zm,e)}function wP(e){return am(Um,e)}function xP(e,t,r={}){return Qa(nc,e,t,r)}function _P(e){return Qa(nc,"hostname",Cr.hostname,e)}function EP(e){return Qa(nc,"hex",Cr.hex,e)}function kP(e,t){let r=t?.enc??"hex",o=`${e}_${r}`,n=Cr[o];if(!n)throw Error(`Unrecognized hash format: ${o}`);return Qa(nc,o,n,t)}function $_(e){return Wx(oc,e)}function _m(e){return Qx(Es,e)}function IP(e){return Yx(Es,e)}function AP(e){return Xx(Es,e)}function TP(e){return e0(Es,e)}function RP(e){return t0(Es,e)}function O_(e){return r0(ic,e)}function $P(e){return o0(sc,e)}function OP(e){return s0(Mm,e)}function CP(e){return a0(Mm,e)}function PP(e){return c0(C_,e)}function zP(e){return l0(P_,e)}function N_(e){return u0(z_,e)}function NP(){return d0(D_)}function _s(){return p0(L_)}function qm(e){return f0(B_,e)}function DP(e){return m0(j_,e)}function LP(e){return h0(Au,e)}function Tu(e,t){return b0(Z_,e,t)}function BP(e){let t=e._zod.def.shape;return Km(Object.keys(t))}function jP(e,t){let r={type:"object",shape:e??{},...ue.normalizeParams(t)};return new Ru(r)}function ZP(e,t){return new Ru({type:"object",shape:e,catchall:qm(),...ue.normalizeParams(t)})}function UP(e,t){return new Ru({type:"object",shape:e,catchall:_s(),...ue.normalizeParams(t)})}function Fm(e,t){return new $u({type:"union",options:e,...ue.normalizeParams(t)})}function MP(e,t){return new U_({type:"union",options:e,inclusive:!1,...ue.normalizeParams(t)})}function qP(e,t,r){return new M_({type:"union",options:t,discriminator:e,...ue.normalizeParams(r)})}function F_(e,t){return new q_({type:"intersection",left:e,right:t})}function H_(e,t,r){let o=t instanceof Ne,n=o?r:t;return new K_({type:"tuple",items:e,rest:o?t:null,...ue.normalizeParams(n)})}function J_(e,t,r){if(!t||!t._zod)return new ec({type:"record",keyType:wu(),valueType:e,...ue.normalizeParams(t)});return new ec({type:"record",keyType:e,valueType:t,...ue.normalizeParams(r)})}function FP(e,t,r){let o=ur(e);return o._zod.values=void 0,new ec({type:"record",keyType:o,valueType:t,...ue.normalizeParams(r)})}function KP(e,t,r){return new ec({type:"record",keyType:e,valueType:t,mode:"loose",...ue.normalizeParams(r)})}function HP(e,t,r){return new V_({type:"map",keyType:e,valueType:t,...ue.normalizeParams(r)})}function JP(e,t){return new W_({type:"set",valueType:e,...ue.normalizeParams(t)})}function Km(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map((o)=>[o,o])):e;return new tc({type:"enum",entries:r,...ue.normalizeParams(t)})}function VP(e,t){return new tc({type:"enum",entries:e,...ue.normalizeParams(t)})}function WP(e,t){return new G_({type:"literal",values:Array.isArray(e)?e:[e],...ue.normalizeParams(t)})}function GP(e){return S0(Q_,e)}function Hm(e){return new Y_({type:"transform",transform:e})}function _u(e){return new Jm({type:"optional",innerType:e})}function eE(e){return new X_({type:"optional",innerType:e})}function Eu(e){return new tE({type:"nullable",innerType:e})}function QP(e){return _u(Eu(e))}function nE(e,t){return new rE({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():ue.shallowClone(t)}})}function iE(e,t){return new oE({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():ue.shallowClone(t)}})}function sE(e,t){return new Vm({type:"nonoptional",innerType:e,...ue.normalizeParams(t)})}function YP(e){return new aE({type:"success",innerType:e})}function lE(e,t){return new cE({type:"catch",innerType:e,catchValue:typeof t==="function"?t:()=>t})}function XP(e){return y0(uE,e)}function Em(e,t){return new Ou({type:"pipe",in:e,out:t})}function ez(e,t,r){return new Cu({type:"pipe",in:e,out:t,transform:r.decode,reverseTransform:r.encode})}function tz(e){let t=e._zod.def;return new Cu({type:"pipe",in:t.out,out:t.in,transform:t.reverseTransform,reverseTransform:t.transform})}function fE(e){return new pE({type:"readonly",innerType:e})}function rz(e,t){return new mE({type:"template_literal",parts:e,...ue.normalizeParams(t)})}function gE(e){return new hE({type:"lazy",getter:e})}function nz(e){return new yE({type:"promise",innerType:e})}function oz(e){return new bE({type:"function",input:Array.isArray(e?.input)?H_(e?.input):e?.input??Tu(_s()),output:e?.output??_s()})}function iz(e){let t=new rt({check:"custom"});return t._zod.check=e,t}function sz(e,t){return v0(Pu,e??(()=>!0),t)}function SE(e,t={}){return w0(Pu,e,t)}function vE(e,t){return x0(e,t)}function lz(e,t={}){let r=new Pu({type:"custom",check:"custom",fn:(o)=>o instanceof e,abort:!0,...ue.normalizeParams(t)});return r._zod.bag.Class=e,r._zod.check=(o)=>{if(!(o.value instanceof e))o.issues.push({code:"invalid_type",expected:e.name,input:o.value,inst:r,path:[...r._zod.def.path??[]]})},r}function dz(e){let t=gE(()=>Fm([wu(e),$_(),O_(),N_(),Tu(t),J_(wu(),t)]));return t}function pz(e,t){return new dE({type:"pipe",in:Hm(e),out:t})}var Q1,Be,km,rc,Xe,Im,xu,Ln,Iu,Am,Tm,Rm,$m,Om,Cm,Pm,zm,R_,Nm,Dm,Lm,Bm,jm,Zm,Um,nc,oc,Es,ic,sc,Mm,C_,P_,z_,D_,L_,B_,j_,Au,Z_,Ru,$u,U_,M_,q_,K_,ec,V_,W_,tc,G_,Q_,Y_,Jm,X_,tE,rE,oE,Vm,aE,cE,uE,Ou,Cu,dE,pE,mE,hE,yE,bE,Pu,az,cz,uz=(...e)=>k0({Codec:Cu,Boolean:ic,String:rc},...e);var vu=v(()=>{zr();zr();yu();gu();bm();bu();T_();Q1=new WeakMap;Be=Z("ZodType",(e,t)=>(Ne.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Ya(e,"input"),output:Ya(e,"output")}}),e.toJSONSchema=I0(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(r,o)=>g_(e,r,o,{callee:e.parse}),e.safeParse=(r,o)=>b_(e,r,o),e.parseAsync=async(r,o)=>y_(e,r,o,{callee:e.parseAsync}),e.safeParseAsync=async(r,o)=>S_(e,r,o),e.spa=e.safeParseAsync,e.encode=(r,o)=>v_(e,r,o),e.decode=(r,o)=>w_(e,r,o),e.encodeAsync=async(r,o)=>x_(e,r,o),e.decodeAsync=async(r,o)=>__(e,r,o),e.safeEncode=(r,o)=>E_(e,r,o),e.safeDecode=(r,o)=>k_(e,r,o),e.safeEncodeAsync=async(r,o)=>I_(e,r,o),e.safeDecodeAsync=async(r,o)=>A_(e,r,o),ku(e,"ZodType",{check(...r){let o=this.def;return this.clone(ue.mergeDefs(o,{checks:[...o.checks??[],...r.map((n)=>typeof n==="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0})},with(...r){return this.check(...r)},clone(r,o){return ur(this,r,o)},brand(){return this},register(r,o){return r.add(this,o),this},refine(r,o){return this.check(SE(r,o))},superRefine(r,o){return this.check(vE(r,o))},overwrite(r){return this.check(un(r))},optional(){return _u(this)},exactOptional(){return eE(this)},nullable(){return Eu(this)},nullish(){return _u(Eu(this))},nonoptional(r){return sE(this,r)},array(){return Tu(this)},or(r){return Fm([this,r])},and(r){return F_(this,r)},transform(r){return Em(this,Hm(r))},default(r){return nE(this,r)},prefault(r){return iE(this,r)},catch(r){return lE(this,r)},pipe(r){return Em(this,r)},readonly(){return fE(this)},describe(r){let o=this.clone();return qt.add(o,{description:r}),o},meta(...r){if(r.length===0)return qt.get(this);let o=this.clone();return qt.add(o,r[0]),o},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(r){return r(this)}}),Object.defineProperty(e,"description",{get(){return qt.get(e)?.description},configurable:!0}),e)),km=Z("_ZodString",(e,t)=>{Ss.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(o,n,i)=>A0(e,o,n,i);let r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,ku(e,"_ZodString",{regex(...o){return this.check(ja(...o))},includes(...o){return this.check(Ma(...o))},startsWith(...o){return this.check(qa(...o))},endsWith(...o){return this.check(Fa(...o))},min(...o){return this.check(co(...o))},max(...o){return this.check(ws(...o))},length(...o){return this.check(xs(...o))},nonempty(...o){return this.check(co(1,...o))},lowercase(o){return this.check(Za(o))},uppercase(o){return this.check(Ua(o))},trim(){return this.check(Ja())},normalize(...o){return this.check(Ha(...o))},toLowerCase(){return this.check(Va())},toUpperCase(){return this.check(Wa())},slugify(){return this.check(Ga())}})}),rc=Z("ZodString",(e,t)=>{Ss.init(e,t),km.init(e,t),e.email=(r)=>e.check(Mf(Im,r)),e.url=(r)=>e.check(hu(Iu,r)),e.jwt=(r)=>e.check(am(Um,r)),e.emoji=(r)=>e.check(Jf(Am,r)),e.guid=(r)=>e.check(mu(xu,r)),e.uuid=(r)=>e.check(qf(Ln,r)),e.uuidv4=(r)=>e.check(Ff(Ln,r)),e.uuidv6=(r)=>e.check(Kf(Ln,r)),e.uuidv7=(r)=>e.check(Hf(Ln,r)),e.nanoid=(r)=>e.check(Vf(Tm,r)),e.guid=(r)=>e.check(mu(xu,r)),e.cuid=(r)=>e.check(Wf(Rm,r)),e.cuid2=(r)=>e.check(Gf($m,r)),e.ulid=(r)=>e.check(Qf(Om,r)),e.base64=(r)=>e.check(om(Bm,r)),e.base64url=(r)=>e.check(im(jm,r)),e.xid=(r)=>e.check(Yf(Cm,r)),e.ksuid=(r)=>e.check(Xf(Pm,r)),e.ipv4=(r)=>e.check(em(zm,r)),e.ipv6=(r)=>e.check(tm(Nm,r)),e.cidrv4=(r)=>e.check(rm(Dm,r)),e.cidrv6=(r)=>e.check(nm(Lm,r)),e.e164=(r)=>e.check(sm(Zm,r)),e.datetime=(r)=>e.check(d_(r)),e.date=(r)=>e.check(p_(r)),e.time=(r)=>e.check(f_(r)),e.duration=(r)=>e.check(m_(r))});Xe=Z("ZodStringFormat",(e,t)=>{Ye.init(e,t),km.init(e,t)}),Im=Z("ZodEmail",(e,t)=>{Ov.init(e,t),Xe.init(e,t)});xu=Z("ZodGUID",(e,t)=>{Rv.init(e,t),Xe.init(e,t)});Ln=Z("ZodUUID",(e,t)=>{$v.init(e,t),Xe.init(e,t)});Iu=Z("ZodURL",(e,t)=>{Cv.init(e,t),Xe.init(e,t)});Am=Z("ZodEmoji",(e,t)=>{Pv.init(e,t),Xe.init(e,t)});Tm=Z("ZodNanoID",(e,t)=>{zv.init(e,t),Xe.init(e,t)});Rm=Z("ZodCUID",(e,t)=>{Nv.init(e,t),Xe.init(e,t)});$m=Z("ZodCUID2",(e,t)=>{Dv.init(e,t),Xe.init(e,t)});Om=Z("ZodULID",(e,t)=>{Lv.init(e,t),Xe.init(e,t)});Cm=Z("ZodXID",(e,t)=>{Bv.init(e,t),Xe.init(e,t)});Pm=Z("ZodKSUID",(e,t)=>{jv.init(e,t),Xe.init(e,t)});zm=Z("ZodIPv4",(e,t)=>{Fv.init(e,t),Xe.init(e,t)});R_=Z("ZodMAC",(e,t)=>{Hv.init(e,t),Xe.init(e,t)});Nm=Z("ZodIPv6",(e,t)=>{Kv.init(e,t),Xe.init(e,t)});Dm=Z("ZodCIDRv4",(e,t)=>{Jv.init(e,t),Xe.init(e,t)});Lm=Z("ZodCIDRv6",(e,t)=>{Vv.init(e,t),Xe.init(e,t)});Bm=Z("ZodBase64",(e,t)=>{Gv.init(e,t),Xe.init(e,t)});jm=Z("ZodBase64URL",(e,t)=>{Qv.init(e,t),Xe.init(e,t)});Zm=Z("ZodE164",(e,t)=>{Yv.init(e,t),Xe.init(e,t)});Um=Z("ZodJWT",(e,t)=>{Xv.init(e,t),Xe.init(e,t)});nc=Z("ZodCustomStringFormat",(e,t)=>{ew.init(e,t),Xe.init(e,t)});oc=Z("ZodNumber",(e,t)=>{Df.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(o,n,i)=>T0(e,o,n,i),ku(e,"ZodNumber",{gt(o,n){return this.check(Nn(o,n))},gte(o,n){return this.check(pr(o,n))},min(o,n){return this.check(pr(o,n))},lt(o,n){return this.check(zn(o,n))},lte(o,n){return this.check(Pr(o,n))},max(o,n){return this.check(Pr(o,n))},int(o){return this.check(_m(o))},safe(o){return this.check(_m(o))},positive(o){return this.check(Nn(0,o))},nonnegative(o){return this.check(pr(0,o))},negative(o){return this.check(zn(0,o))},nonpositive(o){return this.check(Pr(0,o))},multipleOf(o,n){return this.check(ni(o,n))},step(o,n){return this.check(ni(o,n))},finite(){return this}});let r=e._zod.bag;e.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??0.5),e.isFinite=!0,e.format=r.format??null});Es=Z("ZodNumberFormat",(e,t)=>{tw.init(e,t),oc.init(e,t)});ic=Z("ZodBoolean",(e,t)=>{iu.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>R0(e,r,o,n)});sc=Z("ZodBigInt",(e,t)=>{Lf.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(o,n,i)=>$0(e,o,n,i),e.gte=(o,n)=>e.check(pr(o,n)),e.min=(o,n)=>e.check(pr(o,n)),e.gt=(o,n)=>e.check(Nn(o,n)),e.gte=(o,n)=>e.check(pr(o,n)),e.min=(o,n)=>e.check(pr(o,n)),e.lt=(o,n)=>e.check(zn(o,n)),e.lte=(o,n)=>e.check(Pr(o,n)),e.max=(o,n)=>e.check(Pr(o,n)),e.positive=(o)=>e.check(Nn(BigInt(0),o)),e.negative=(o)=>e.check(zn(BigInt(0),o)),e.nonpositive=(o)=>e.check(Pr(BigInt(0),o)),e.nonnegative=(o)=>e.check(pr(BigInt(0),o)),e.multipleOf=(o,n)=>e.check(ni(o,n));let r=e._zod.bag;e.minValue=r.minimum??null,e.maxValue=r.maximum??null,e.format=r.format??null});Mm=Z("ZodBigIntFormat",(e,t)=>{rw.init(e,t),sc.init(e,t)});C_=Z("ZodSymbol",(e,t)=>{nw.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>O0(e,r,o,n)});P_=Z("ZodUndefined",(e,t)=>{ow.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>P0(e,r,o,n)});z_=Z("ZodNull",(e,t)=>{iw.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>C0(e,r,o,n)});D_=Z("ZodAny",(e,t)=>{sw.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>D0(e,r,o,n)});L_=Z("ZodUnknown",(e,t)=>{aw.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>L0(e,r,o,n)});B_=Z("ZodNever",(e,t)=>{cw.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>N0(e,r,o,n)});j_=Z("ZodVoid",(e,t)=>{lw.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>z0(e,r,o,n)});Au=Z("ZodDate",(e,t)=>{uw.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(o,n,i)=>B0(e,o,n,i),e.min=(o,n)=>e.check(pr(o,n)),e.max=(o,n)=>e.check(Pr(o,n));let r=e._zod.bag;e.minDate=r.minimum?new Date(r.minimum):null,e.maxDate=r.maximum?new Date(r.maximum):null});Z_=Z("ZodArray",(e,t)=>{dw.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>G0(e,r,o,n),e.element=t.element,ku(e,"ZodArray",{min(r,o){return this.check(co(r,o))},nonempty(r){return this.check(co(1,r))},max(r,o){return this.check(ws(r,o))},length(r,o){return this.check(xs(r,o))},unwrap(){return this.element}})});Ru=Z("ZodObject",(e,t)=>{pw.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Q0(e,r,o,n),ue.defineLazy(e,"shape",()=>t.shape),ku(e,"ZodObject",{keyof(){return Km(Object.keys(this._zod.def.shape))},catchall(r){return this.clone({...this._zod.def,catchall:r})},passthrough(){return this.clone({...this._zod.def,catchall:_s()})},loose(){return this.clone({...this._zod.def,catchall:_s()})},strict(){return this.clone({...this._zod.def,catchall:qm()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(r){return ue.extend(this,r)},safeExtend(r){return ue.safeExtend(this,r)},merge(r){return ue.merge(this,r)},pick(r){return ue.pick(this,r)},omit(r){return ue.omit(this,r)},partial(...r){return ue.partial(Jm,this,r[0])},required(...r){return ue.required(Vm,this,r[0])}})});$u=Z("ZodUnion",(e,t)=>{su.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>mm(e,r,o,n),e.options=t.options});U_=Z("ZodXor",(e,t)=>{$u.init(e,t),fw.init(e,t),e._zod.processJSONSchema=(r,o,n)=>mm(e,r,o,n),e.options=t.options});M_=Z("ZodDiscriminatedUnion",(e,t)=>{$u.init(e,t),mw.init(e,t)});q_=Z("ZodIntersection",(e,t)=>{hw.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Y0(e,r,o,n)});K_=Z("ZodTuple",(e,t)=>{Bf.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>X0(e,r,o,n),e.rest=(r)=>e.clone({...e._zod.def,rest:r})});ec=Z("ZodRecord",(e,t)=>{gw.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>e_(e,r,o,n),e.keyType=t.keyType,e.valueType=t.valueType});V_=Z("ZodMap",(e,t)=>{yw.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>V0(e,r,o,n),e.keyType=t.keyType,e.valueType=t.valueType,e.min=(...r)=>e.check(Dn(...r)),e.nonempty=(r)=>e.check(Dn(1,r)),e.max=(...r)=>e.check(oi(...r)),e.size=(...r)=>e.check(vs(...r))});W_=Z("ZodSet",(e,t)=>{bw.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>W0(e,r,o,n),e.min=(...r)=>e.check(Dn(...r)),e.nonempty=(r)=>e.check(Dn(1,r)),e.max=(...r)=>e.check(oi(...r)),e.size=(...r)=>e.check(vs(...r))});tc=Z("ZodEnum",(e,t)=>{Sw.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(o,n,i)=>j0(e,o,n,i),e.enum=t.entries,e.options=Object.values(t.entries);let r=new Set(Object.keys(t.entries));e.extract=(o,n)=>{let i={};for(let s of o)if(r.has(s))i[s]=t.entries[s];else throw Error(`Key ${s} not found in enum`);return new tc({...t,checks:[],...ue.normalizeParams(n),entries:i})},e.exclude=(o,n)=>{let i={...t.entries};for(let s of o)if(r.has(s))delete i[s];else throw Error(`Key ${s} not found in enum`);return new tc({...t,checks:[],...ue.normalizeParams(n),entries:i})}});G_=Z("ZodLiteral",(e,t)=>{vw.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Z0(e,r,o,n),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});Q_=Z("ZodFile",(e,t)=>{ww.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>q0(e,r,o,n),e.min=(r,o)=>e.check(Dn(r,o)),e.max=(r,o)=>e.check(oi(r,o)),e.mime=(r,o)=>e.check(Ka(Array.isArray(r)?r:[r],o))});Y_=Z("ZodTransform",(e,t)=>{xw.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>J0(e,r,o,n),e._zod.parse=(r,o)=>{if(o.direction==="backward")throw new hs(e.constructor.name);r.addIssue=(i)=>{if(typeof i==="string")r.issues.push(ue.issue(i,r.value,t));else{let s=i;if(s.fatal)s.continue=!1;s.code??(s.code="custom"),s.input??(s.input=r.value),s.inst??(s.inst=e),r.issues.push(ue.issue(s))}};let n=t.transform(r.value,r);if(n instanceof Promise)return n.then((i)=>(r.value=i,r.fallback=!0,r));return r.value=n,r.fallback=!0,r}});Jm=Z("ZodOptional",(e,t)=>{jf.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>hm(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});X_=Z("ZodExactOptional",(e,t)=>{_w.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>hm(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});tE=Z("ZodNullable",(e,t)=>{Ew.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>t_(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});rE=Z("ZodDefault",(e,t)=>{kw.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>n_(e,r,o,n),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});oE=Z("ZodPrefault",(e,t)=>{Iw.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>o_(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});Vm=Z("ZodNonOptional",(e,t)=>{Aw.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>r_(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});aE=Z("ZodSuccess",(e,t)=>{Tw.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>F0(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});cE=Z("ZodCatch",(e,t)=>{Rw.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>i_(e,r,o,n),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});uE=Z("ZodNaN",(e,t)=>{$w.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>U0(e,r,o,n)});Ou=Z("ZodPipe",(e,t)=>{Zf.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>s_(e,r,o,n),e.in=t.in,e.out=t.out});Cu=Z("ZodCodec",(e,t)=>{Ou.init(e,t),au.init(e,t)});dE=Z("ZodPreprocess",(e,t)=>{Ou.init(e,t),Ow.init(e,t)}),pE=Z("ZodReadonly",(e,t)=>{Cw.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>a_(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});mE=Z("ZodTemplateLiteral",(e,t)=>{Pw.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>M0(e,r,o,n)});hE=Z("ZodLazy",(e,t)=>{Dw.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>l_(e,r,o,n),e.unwrap=()=>e._zod.def.getter()});yE=Z("ZodPromise",(e,t)=>{Nw.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>c_(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});bE=Z("ZodFunction",(e,t)=>{zw.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>H0(e,r,o,n)});Pu=Z("ZodCustom",(e,t)=>{Lw.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>K0(e,r,o,n)});az=_0,cz=E0});function BV(e){gt({customError:e})}function jV(){return gt().customError}var LV,wE;var fz=v(()=>{zr();LV={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};(function(e){})(wE||(wE={}))});function UV(e,t){let r=e.$schema;if(r==="https://json-schema.org/draft/2020-12/schema")return"draft-2020-12";if(r==="http://json-schema.org/draft-07/schema#")return"draft-7";if(r==="http://json-schema.org/draft-04/schema#")return"draft-4";return t??"draft-2020-12"}function MV(e,t){if(!e.startsWith("#"))throw Error("External $ref is not supported, only local refs (#/...) are allowed");let r=e.slice(1).split("/").filter(Boolean);if(r.length===0)return t.rootSchema;let o=t.version==="draft-2020-12"?"$defs":"definitions";if(r[0]===o){let n=r[1];if(!n||!t.defs[n])throw Error(`Reference not found: ${e}`);return t.defs[n]}throw Error(`Reference not found: ${e}`)}function mz(e,t){if(e.not!==void 0){if(typeof e.not==="object"&&Object.keys(e.not).length===0)return Se.never();throw Error("not is not supported in Zod (except { not: {} } for never)")}if(e.unevaluatedItems!==void 0)throw Error("unevaluatedItems is not supported");if(e.unevaluatedProperties!==void 0)throw Error("unevaluatedProperties is not supported");if(e.if!==void 0||e.then!==void 0||e.else!==void 0)throw Error("Conditional schemas (if/then/else) are not supported");if(e.dependentSchemas!==void 0||e.dependentRequired!==void 0)throw Error("dependentSchemas and dependentRequired are not supported");if(e.$ref){let n=e.$ref;if(t.refs.has(n))return t.refs.get(n);if(t.processing.has(n))return Se.lazy(()=>{if(!t.refs.has(n))throw Error(`Circular reference not resolved: ${n}`);return t.refs.get(n)});t.processing.add(n);let i=MV(n,t),s=er(i,t);return t.refs.set(n,s),t.processing.delete(n),s}if(e.enum!==void 0){let n=e.enum;if(t.version==="openapi-3.0"&&e.nullable===!0&&n.length===1&&n[0]===null)return Se.null();if(n.length===0)return Se.never();if(n.length===1)return Se.literal(n[0]);if(n.every((s)=>typeof s==="string"))return Se.enum(n);let i=n.map((s)=>Se.literal(s));if(i.length<2)return i[0];return Se.union([i[0],i[1],...i.slice(2)])}if(e.const!==void 0)return Se.literal(e.const);let r=e.type;if(Array.isArray(r)){let n=r.map((i)=>{let s={...e,type:i};return mz(s,t)});if(n.length===0)return Se.never();if(n.length===1)return n[0];return Se.union(n)}if(!r)return Se.any();let o;switch(r){case"string":{let n=Se.string();if(e.format){let i=e.format;if(i==="email")n=n.check(Se.email());else if(i==="uri"||i==="uri-reference")n=n.check(Se.url());else if(i==="uuid"||i==="guid")n=n.check(Se.uuid());else if(i==="date-time")n=n.check(Se.iso.datetime());else if(i==="date")n=n.check(Se.iso.date());else if(i==="time")n=n.check(Se.iso.time());else if(i==="duration")n=n.check(Se.iso.duration());else if(i==="ipv4")n=n.check(Se.ipv4());else if(i==="ipv6")n=n.check(Se.ipv6());else if(i==="mac")n=n.check(Se.mac());else if(i==="cidr")n=n.check(Se.cidrv4());else if(i==="cidr-v6")n=n.check(Se.cidrv6());else if(i==="base64")n=n.check(Se.base64());else if(i==="base64url")n=n.check(Se.base64url());else if(i==="e164")n=n.check(Se.e164());else if(i==="jwt")n=n.check(Se.jwt());else if(i==="emoji")n=n.check(Se.emoji());else if(i==="nanoid")n=n.check(Se.nanoid());else if(i==="cuid")n=n.check(Se.cuid());else if(i==="cuid2")n=n.check(Se.cuid2());else if(i==="ulid")n=n.check(Se.ulid());else if(i==="xid")n=n.check(Se.xid());else if(i==="ksuid")n=n.check(Se.ksuid())}if(typeof e.minLength==="number")n=n.min(e.minLength);if(typeof e.maxLength==="number")n=n.max(e.maxLength);if(e.pattern)n=n.regex(new RegExp(e.pattern));o=n;break}case"number":case"integer":{let n=r==="integer"?Se.number().int():Se.number();if(typeof e.minimum==="number")n=n.min(e.minimum);if(typeof e.maximum==="number")n=n.max(e.maximum);if(typeof e.exclusiveMinimum==="number")n=n.gt(e.exclusiveMinimum);else if(e.exclusiveMinimum===!0&&typeof e.minimum==="number")n=n.gt(e.minimum);if(typeof e.exclusiveMaximum==="number")n=n.lt(e.exclusiveMaximum);else if(e.exclusiveMaximum===!0&&typeof e.maximum==="number")n=n.lt(e.maximum);if(typeof e.multipleOf==="number")n=n.multipleOf(e.multipleOf);o=n;break}case"boolean":{o=Se.boolean();break}case"null":{o=Se.null();break}case"object":{let n={},i=e.properties||{},s=new Set(e.required||[]);for(let[c,u]of Object.entries(i)){let d=er(u,t);n[c]=s.has(c)?d:d.optional()}if(e.propertyNames){let c=er(e.propertyNames,t),u=e.additionalProperties&&typeof e.additionalProperties==="object"?er(e.additionalProperties,t):Se.any();if(Object.keys(n).length===0){o=Se.record(c,u);break}let d=Se.object(n).passthrough(),p=Se.looseRecord(c,u);o=Se.intersection(d,p);break}if(e.patternProperties){let c=e.patternProperties,u=Object.keys(c),d=[];for(let m of u){let h=er(c[m],t),b=Se.string().regex(new RegExp(m));d.push(Se.looseRecord(b,h))}let p=[];if(Object.keys(n).length>0)p.push(Se.object(n).passthrough());if(p.push(...d),p.length===0)o=Se.object({}).passthrough();else if(p.length===1)o=p[0];else{let m=Se.intersection(p[0],p[1]);for(let h=2;h<p.length;h++)m=Se.intersection(m,p[h]);o=m}break}let a=Se.object(n);if(e.additionalProperties===!1)o=a.strict();else if(typeof e.additionalProperties==="object")o=a.catchall(er(e.additionalProperties,t));else o=a.passthrough();break}case"array":{let{prefixItems:n,items:i}=e;if(n&&Array.isArray(n)){let s=n.map((c)=>er(c,t)),a=i&&typeof i==="object"&&!Array.isArray(i)?er(i,t):void 0;if(a)o=Se.tuple(s).rest(a);else o=Se.tuple(s);if(typeof e.minItems==="number")o=o.check(Se.minLength(e.minItems));if(typeof e.maxItems==="number")o=o.check(Se.maxLength(e.maxItems))}else if(Array.isArray(i)){let s=i.map((c)=>er(c,t)),a=e.additionalItems&&typeof e.additionalItems==="object"?er(e.additionalItems,t):void 0;if(a)o=Se.tuple(s).rest(a);else o=Se.tuple(s);if(typeof e.minItems==="number")o=o.check(Se.minLength(e.minItems));if(typeof e.maxItems==="number")o=o.check(Se.maxLength(e.maxItems))}else if(i!==void 0){let s=er(i,t),a=Se.array(s);if(typeof e.minItems==="number")a=a.min(e.minItems);if(typeof e.maxItems==="number")a=a.max(e.maxItems);o=a}else o=Se.array(Se.any());break}default:throw Error(`Unsupported type: ${r}`)}return o}function er(e,t){if(typeof e==="boolean")return e?Se.any():Se.never();let r=mz(e,t),o=e.type||e.enum!==void 0||e.const!==void 0;if(e.anyOf&&Array.isArray(e.anyOf)){let a=e.anyOf.map((u)=>er(u,t)),c=Se.union(a);r=o?Se.intersection(r,c):c}if(e.oneOf&&Array.isArray(e.oneOf)){let a=e.oneOf.map((u)=>er(u,t)),c=Se.xor(a);r=o?Se.intersection(r,c):c}if(e.allOf&&Array.isArray(e.allOf))if(e.allOf.length===0)r=o?r:Se.any();else{let a=o?r:er(e.allOf[0],t),c=o?0:1;for(let u=c;u<e.allOf.length;u++)a=Se.intersection(a,er(e.allOf[u],t));r=a}if(e.nullable===!0&&t.version==="openapi-3.0")r=Se.nullable(r);if(e.readOnly===!0)r=Se.readonly(r);if(e.default!==void 0)r=r.default(e.default);let n={},i=["$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor"];for(let a of i)if(a in e)n[a]=e[a];let s=["contentEncoding","contentMediaType","contentSchema"];for(let a of s)if(a in e)n[a]=e[a];for(let a of Object.keys(e))if(!ZV.has(a))n[a]=e[a];if(Object.keys(n).length>0)t.registry.add(r,n);if(e.description)r=r.describe(e.description);return r}function hz(e,t){if(typeof e==="boolean")return e?Se.any():Se.never();let r;try{r=JSON.parse(JSON.stringify(e))}catch{throw Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas")}let o=UV(r,t?.defaultTarget),n=r.$defs||r.definitions||{},i={version:o,defs:n,refs:new Map,processing:new Set,rootSchema:r,registry:t?.registry??qt};return er(r,i)}var Se,ZV;var gz=v(()=>{fu();bm();bu();vu();Se={...Su,...ym,iso:Xa},ZV=new Set(["$schema","$ref","$defs","definitions","$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor","type","enum","const","anyOf","oneOf","allOf","not","properties","required","additionalProperties","patternProperties","propertyNames","minProperties","maxProperties","items","prefixItems","additionalItems","minItems","maxItems","uniqueItems","contains","minContains","maxContains","minLength","maxLength","pattern","format","minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","description","default","contentEncoding","contentMediaType","contentSchema","unevaluatedItems","unevaluatedProperties","if","then","else","dependentSchemas","dependentRequired","nullable","readOnly"])});var xE={};Lt(xE,{bigint:()=>HV,boolean:()=>KV,date:()=>JV,number:()=>FV,string:()=>qV});function qV(e){return Mx(rc,e)}function FV(e){return Gx(oc,e)}function KV(e){return n0(ic,e)}function HV(e){return i0(sc,e)}function JV(e){return g0(Au,e)}var yz=v(()=>{zr();vu()});var l={};Lt(l,{$brand:()=>gS,$input:()=>jx,$output:()=>Bx,NEVER:()=>hS,TimePrecision:()=>Fx,ZodAny:()=>D_,ZodArray:()=>Z_,ZodBase64:()=>Bm,ZodBase64URL:()=>jm,ZodBigInt:()=>sc,ZodBigIntFormat:()=>Mm,ZodBoolean:()=>ic,ZodCIDRv4:()=>Dm,ZodCIDRv6:()=>Lm,ZodCUID:()=>Rm,ZodCUID2:()=>$m,ZodCatch:()=>cE,ZodCodec:()=>Cu,ZodCustom:()=>Pu,ZodCustomStringFormat:()=>nc,ZodDate:()=>Au,ZodDefault:()=>rE,ZodDiscriminatedUnion:()=>M_,ZodE164:()=>Zm,ZodEmail:()=>Im,ZodEmoji:()=>Am,ZodEnum:()=>tc,ZodError:()=>G1,ZodExactOptional:()=>X_,ZodFile:()=>Q_,ZodFirstPartyTypeKind:()=>wE,ZodFunction:()=>bE,ZodGUID:()=>xu,ZodIPv4:()=>zm,ZodIPv6:()=>Nm,ZodISODate:()=>vm,ZodISODateTime:()=>Sm,ZodISODuration:()=>xm,ZodISOTime:()=>wm,ZodIntersection:()=>q_,ZodIssueCode:()=>LV,ZodJWT:()=>Um,ZodKSUID:()=>Pm,ZodLazy:()=>hE,ZodLiteral:()=>G_,ZodMAC:()=>R_,ZodMap:()=>V_,ZodNaN:()=>uE,ZodNanoID:()=>Tm,ZodNever:()=>B_,ZodNonOptional:()=>Vm,ZodNull:()=>z_,ZodNullable:()=>tE,ZodNumber:()=>oc,ZodNumberFormat:()=>Es,ZodObject:()=>Ru,ZodOptional:()=>Jm,ZodPipe:()=>Ou,ZodPrefault:()=>oE,ZodPreprocess:()=>dE,ZodPromise:()=>yE,ZodReadonly:()=>pE,ZodRealError:()=>_r,ZodRecord:()=>ec,ZodSet:()=>W_,ZodString:()=>rc,ZodStringFormat:()=>Xe,ZodSuccess:()=>aE,ZodSymbol:()=>C_,ZodTemplateLiteral:()=>mE,ZodTransform:()=>Y_,ZodTuple:()=>K_,ZodType:()=>Be,ZodULID:()=>Om,ZodURL:()=>Iu,ZodUUID:()=>Ln,ZodUndefined:()=>P_,ZodUnion:()=>$u,ZodUnknown:()=>L_,ZodVoid:()=>j_,ZodXID:()=>Cm,ZodXor:()=>U_,_ZodString:()=>km,_default:()=>nE,_function:()=>oz,any:()=>NP,array:()=>Tu,base64:()=>bP,base64url:()=>SP,bigint:()=>$P,boolean:()=>O_,catch:()=>lE,check:()=>iz,cidrv4:()=>gP,cidrv6:()=>yP,clone:()=>ur,codec:()=>ez,coerce:()=>xE,config:()=>gt,core:()=>lo,cuid:()=>cP,cuid2:()=>lP,custom:()=>sz,date:()=>LP,decode:()=>w_,decodeAsync:()=>__,describe:()=>az,discriminatedUnion:()=>qP,e164:()=>vP,email:()=>Y1,emoji:()=>sP,encode:()=>v_,encodeAsync:()=>x_,endsWith:()=>Fa,enum:()=>Km,exactOptional:()=>eE,file:()=>GP,flattenError:()=>eu,float32:()=>IP,float64:()=>AP,formatError:()=>tu,fromJSONSchema:()=>hz,function:()=>oz,getErrorMap:()=>jV,globalRegistry:()=>qt,gt:()=>Nn,gte:()=>pr,guid:()=>X1,hash:()=>kP,hex:()=>EP,hostname:()=>_P,httpUrl:()=>iP,includes:()=>Ma,instanceof:()=>lz,int:()=>_m,int32:()=>TP,int64:()=>OP,intersection:()=>F_,invertCodec:()=>tz,ipv4:()=>fP,ipv6:()=>hP,iso:()=>Xa,json:()=>dz,jwt:()=>wP,keyof:()=>BP,ksuid:()=>pP,lazy:()=>gE,length:()=>xs,literal:()=>WP,locales:()=>pu,looseObject:()=>UP,looseRecord:()=>KP,lowercase:()=>Za,lt:()=>zn,lte:()=>Pr,mac:()=>mP,map:()=>HP,maxLength:()=>ws,maxSize:()=>oi,meta:()=>cz,mime:()=>Ka,minLength:()=>co,minSize:()=>Dn,multipleOf:()=>ni,nan:()=>XP,nanoid:()=>aP,nativeEnum:()=>VP,negative:()=>lm,never:()=>qm,nonnegative:()=>dm,nonoptional:()=>sE,nonpositive:()=>um,normalize:()=>Ha,null:()=>N_,nullable:()=>Eu,nullish:()=>QP,number:()=>$_,object:()=>jP,optional:()=>_u,overwrite:()=>un,parse:()=>g_,parseAsync:()=>y_,partialRecord:()=>FP,pipe:()=>Em,positive:()=>cm,prefault:()=>iE,preprocess:()=>pz,prettifyError:()=>TS,promise:()=>nz,property:()=>pm,readonly:()=>fE,record:()=>J_,refine:()=>SE,regex:()=>ja,regexes:()=>Cr,registry:()=>Uf,safeDecode:()=>k_,safeDecodeAsync:()=>A_,safeEncode:()=>E_,safeEncodeAsync:()=>I_,safeParse:()=>b_,safeParseAsync:()=>S_,set:()=>JP,setErrorMap:()=>BV,size:()=>vs,slugify:()=>Ga,startsWith:()=>qa,strictObject:()=>ZP,string:()=>wu,stringFormat:()=>xP,stringbool:()=>uz,success:()=>YP,superRefine:()=>vE,symbol:()=>PP,templateLiteral:()=>rz,toJSONSchema:()=>gm,toLowerCase:()=>Va,toUpperCase:()=>Wa,transform:()=>Hm,treeifyError:()=>AS,trim:()=>Ja,tuple:()=>H_,uint32:()=>RP,uint64:()=>CP,ulid:()=>uP,undefined:()=>zP,union:()=>Fm,unknown:()=>_s,uppercase:()=>Ua,url:()=>oP,util:()=>ue,uuid:()=>eP,uuidv4:()=>tP,uuidv6:()=>rP,uuidv7:()=>nP,void:()=>DP,xid:()=>dP,xor:()=>MP});var _E=v(()=>{zr();zr();Vw();zr();yu();gz();Lx();bu();bu();yz();vu();bm();h_();T_();fz();gt(cu())});var bz=v(()=>{_E();_E()});var EE=v(()=>{bz()});var fe=v(()=>{EE()});var kE,Sz;var IE=v(()=>{fe();kE=l.object({title:l.string().trim().min(1).max(500).optional(),introduction:l.string().trim().min(1).max(4000).optional(),topics:l.array(l.string().trim().min(1).max(500)).max(20).optional(),topicsHeading:l.string().trim().min(1).max(120).optional(),contactLabel:l.string().trim().min(1).max(80).optional(),contactNote:l.string().trim().min(1).max(240).optional(),mapCaption:l.string().trim().min(1).max(160).optional(),refusal:l.string().trim().min(1).max(500).optional(),faqHeading:l.string().trim().min(1).max(120).optional()}),Sz=kE.omit({introduction:!0})});function ks(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function wz(e){let t=Reflect.get(fs,"types"),r=ks(t)?t[e]:void 0;if(!(r instanceof Ia))throw Error(`Required YAML type is unavailable: ${e}`);return r}function GV(e,t){let r=0,o=1;for(let n of e.split(":").reverse())r+=(t?Number.parseFloat(n):Number.parseInt(n,10))*o,o*=60;return r}function vz(e){let t=wz(e);return new Ia(`tag:yaml.org,2002:${e}`,{kind:"scalar",resolve:(r)=>typeof r==="string"&&(e==="int"?VV:WV).test(r)&&!r.endsWith("_"),construct:(r)=>{let o=r.replace(/_/g,""),n=o.startsWith("-")?-1:1,i=o.replace(/^[+-]/,"");if(i.includes(":"))return n*GV(i,e==="float");if(e==="int"&&i==="0")return 0;if(e==="int"&&/^0[0-7]+$/.test(i))return n*Number.parseInt(i,8);return t.construct(o)},predicate:t.predicate??void 0,represent:t.represent??void 0,defaultStyle:t.defaultStyle??void 0})}var VV,WV,AE,QV,YV,XV;var xz=v(()=>{Ta();VV=/^[+-]?(?:0|0b[01_]*[01]|0x[\da-fA-F_]*[\da-fA-F]|0[0-7_]*[0-7]|[1-9](?:[\d_]*\d)?|[1-9][\d_]*(?::[0-5]?\d)+)$/,WV=/^(?:[-+]?(?:0|[1-9][\d_]*)(?:\.[\d_]*)?(?:[eE][-+]?\d+)?|\.[\d_]+(?:[eE][-+]?\d+)?|[-+]?\d[\d_]*(?::[0-5]?\d)+\.[\d_]*|[-+]?\.(?:inf|Inf|INF)|\.(?:nan|NaN|NAN))$/;AE=wz("binary"),QV=new Ia("tag:yaml.org,2002:binary",{kind:"scalar",resolve:(e)=>AE.resolve(e),construct:(e)=>{let t=AE.construct(e);if(!(t instanceof Uint8Array))throw Error("Invalid YAML binary result");return typeof Buffer>"u"?Array.from(t):Buffer.from(t)},predicate:(e)=>typeof Buffer<"u"&&Buffer.isBuffer(e),represent:AE.represent??void 0}),YV=new Ia("tag:yaml.org,2002:str",{kind:"scalar",resolve:(e)=>typeof e==="string"&&e.includes(":"),construct:(e)=>e}),XV=mS.extend({implicit:[vz("int"),vz("float"),YV],explicit:[QV]})});var TE=v(()=>{Ta();xz()});var _z,Ez,kz,t9;var RE=v(()=>{TE();fe();_z=l.object({audiences:l.array(l.string()).optional(),positioning:l.string().optional()}),Ez=l.object({summary:l.string().optional(),traits:l.array(l.string()).optional(),principles:l.array(l.string()).optional(),preferredTerms:l.array(l.string()).optional(),avoid:l.array(l.string()).optional()}),kz=l.object({artDirection:l.string().optional(),palette:l.array(l.string()).optional(),composition:l.string().optional(),mood:l.string().optional(),preferred:l.array(l.string()).optional(),avoid:l.array(l.string()).optional()}),t9=l.object({name:l.string().describe("Style guide name"),messaging:_z.optional(),voice:Ez.optional(),visual:kz.optional()})});var Az=v(()=>{TE();IE();RE()});var r9,Wm,qSe,$E="data-ask-sheet",n9;var OE=v(()=>{fe();r9=l.object({public:l.boolean(),preview:l.boolean()}),Wm=l.object({name:l.string().trim().min(1).max(200),url:l.string().url().optional()}),qSe=l.object({sources:l.array(l.object({id:l.string(),title:l.string(),brain:Wm.optional()}))}),n9=`body *:not([${$E}], [${$E}] *) { -webkit-backdrop-filter: none !important; backdrop-filter: none !important; }`});var ci;var Gm=v(()=>{fe();ci=l.discriminatedUnion("kind",[l.object({kind:l.literal("user"),userId:l.string().min(1),canonicalId:l.string().min(1).optional()}),l.object({kind:l.literal("external"),externalActorId:l.string().min(1)}),l.object({kind:l.literal("agent"),agentId:l.string().min(1)}),l.object({kind:l.literal("service"),serviceId:l.string().min(1)})])});var o9,VSe,ac,i9,s9,Tz,WSe,a9,c9,Rz;var $z=v(()=>{fe();o9=l.strictObject({messageCharacters:l.number().int().positive(),requestTimeoutSeconds:l.number().int().positive().max(2147483)}),VSe=l.strictObject({limits:o9,maxCostMicroUsd:l.number().int().positive()}),ac=l.number().int().nonnegative(),i9=l.strictObject({modelCalls:ac,inputTokens:ac,cachedInputTokens:ac,outputTokens:ac,reasoningTokens:ac,embeddingTokens:ac}),s9=l.discriminatedUnion("state",[l.strictObject({state:l.literal("known"),microUsd:l.number().int().nonnegative(),pricing:l.string().trim().min(1).max(120)}),l.strictObject({state:l.literal("unknown"),reason:l.enum(["missing-usage","unsupported-pricing"])})]),Tz=l.strictObject({usage:i9,cost:s9}),WSe=l.strictObject({topics:l.array(l.string().trim().min(1).max(500)).max(20),introduction:l.string().trim().min(1).max(4000).optional(),refusal:l.string().trim().min(1).max(500).optional()}),a9=l.enum(["in-scope","off-topic","abusive","injection","harmful"]),c9=a9.exclude(["in-scope"]),Rz=l.discriminatedUnion("outcome",[l.strictObject({outcome:l.literal("answered")}),l.strictObject({outcome:l.literal("refused"),category:c9}),l.strictObject({outcome:l.literal("unscreened")})])});function u9(e){let t=l9.safeParse(e);if(!t.success)return e;return{...t.data,cards:t.data.cards.filter((r)=>CE.safeParse(r).success)}}var Oz,Cz,Pz,zz,Nz,Dz,cc,Lz,Bz,jz,Zz,Uz,CE,Mz,qz,Fz,l9,Kz;var zu=v(()=>{fe();OE();$z();Oz=l.object({id:l.string(),toolCallId:l.string().optional(),toolName:l.string(),summary:l.string(),completionSummary:l.string().optional(),preview:l.string().optional(),args:l.unknown()}),Cz=l.enum(["approval-requested","approval-responded","output-available","output-denied","output-error"]),Pz=l.object({kind:l.literal("tool-approval"),id:l.string(),toolCallId:l.string().optional(),toolName:l.string(),input:l.record(l.string(),l.unknown()).optional(),summary:l.string(),completionSummary:l.string().optional(),preview:l.string().optional(),state:Cz,output:l.unknown().optional(),error:l.string().optional()}),zz=l.object({entityType:l.string().optional(),entityId:l.string().optional(),attachmentType:l.string().optional()}),Nz=l.object({mediaType:l.string().min(1),url:l.string().min(1),downloadUrl:l.string().min(1).optional(),previewUrl:l.string().min(1).optional(),filename:l.string().min(1).optional(),sizeBytes:l.number().nonnegative().optional(),source:zz.optional()}),Dz=l.object({kind:l.literal("attachment"),id:l.string(),jobId:l.string().optional(),title:l.string(),description:l.string().optional(),attachment:Nz}),cc=l.object({id:l.string().min(1),title:l.string().min(1).optional(),source:l.string().min(1),url:l.string().min(1).optional(),entityType:l.string().min(1).optional(),entityId:l.string().min(1).optional(),excerpt:l.string().min(1).optional(),provenance:l.record(l.string(),l.unknown()).optional(),brain:Wm.optional()}),Lz=l.object({kind:l.literal("sources"),id:l.string().min(1),title:l.string().min(1).optional(),sources:l.array(cc).min(1)}),Bz=l.object({type:l.literal("prompt"),id:l.string().min(1),label:l.string().min(1),prompt:l.string().min(1),description:l.string().min(1).optional()}),jz=l.object({type:l.literal("event"),id:l.string().min(1),label:l.string().min(1),event:l.string().min(1),fromState:l.string().min(1).optional(),description:l.string().min(1).optional()}),Zz=l.discriminatedUnion("type",[Bz,jz]),Uz=l.object({kind:l.literal("actions"),id:l.string().min(1),title:l.string().min(1).optional(),defaultOpen:l.boolean().optional(),actions:l.array(Zz).min(1)}),CE=l.discriminatedUnion("kind",[Pz,Dz,Lz,Uz]),Mz=l.object({toolName:l.string(),args:l.record(l.string(),l.unknown()).optional(),jobId:l.string().optional(),data:l.unknown().optional(),error:l.object({message:l.string(),code:l.string().optional()}).optional()}),qz=l.object({faqId:l.string().min(1)}),Fz=l.object({text:l.string(),error:l.string().optional(),toolResults:l.array(Mz).optional(),cards:l.array(CE).optional(),pendingConfirmations:l.array(Oz).optional(),usage:l.object({promptTokens:l.number(),completionTokens:l.number(),totalTokens:l.number()}),guestSettlement:Tz.optional(),guestScreening:Rz.optional(),askedBefore:qz.optional()}),l9=l.looseObject({cards:l.array(l.unknown())});Kz=l.preprocess((e)=>u9(pf(e)),Fz)});function Ee(e){return Object.freeze({name:e.channel,schema:e.request,response:e.response,delivery:e.delivery})}var PE,d9,p9,Hz,f9,m9,h9,g9;var Jz=v(()=>{fe();Gm();zu();PE=l.object({state:l.string(),response:l.string(),sources:l.array(cc)}),d9=l.object({agent:l.string().trim().min(1).max(253),question:l.string().trim().min(1).max(4000)}),p9=Ee({channel:"a2a:ask:request",request:d9,response:PE,delivery:"request"}),Hz=l.object({entityType:l.string().optional(),entityId:l.string().optional(),actor:ci.optional(),interfaceType:l.string().optional(),userPermissionLevel:l.enum(["admin","trusted","public"])}),f9=l.object({agent:l.string().trim().min(1).max(253),instruction:l.string().trim().min(1).max(2000),selection:l.string().min(1).max(8000),...Hz.shape}),m9=Ee({channel:"a2a:call:request",request:f9,response:PE,delivery:"request"}),h9=l.object({agents:l.array(l.object({id:l.string(),label:l.string()}))}),g9=Ee({channel:"a2a:call:agents",request:Hz,response:h9,delivery:"request"})});var y9,Vz,b9,S9;var Wz=v(()=>{fe();zu();y9=l.object({type:l.literal("event"),event:l.string().min(1),fromState:l.string().min(1).optional()}),Vz=l.object({conversationId:l.string().min(1),interfaceType:l.string().min(1),channelId:l.string().min(1).optional(),channelName:l.string().min(1),userPermissionLevel:l.enum(["admin","trusted","public"]),isAnchor:l.boolean(),action:y9}),b9=Kz.nullable(),S9=Ee({channel:"agent:action:request",request:Vz,response:b9,delivery:"request"})});var Gz,v9,Qz,w9;var Yz=v(()=>{fe();zu();Gz=l.object({question:l.string().trim().min(1)}),v9=l.object({faqId:l.string().min(1),faqQuestion:l.string().min(1),answer:l.string().trim().min(1),sources:l.array(cc).default([])}),Qz=l.object({hit:v9.optional()}),w9=Ee({channel:"guest:asked-before",request:Gz,response:Qz,delivery:"collect"})});var x9,Xz,eN,bve,_9,E9;var tN=v(()=>{fe();x9=l.enum(["admin","trusted","public"]),Xz=l.object({conversationId:l.string().min(1),message:l.string(),interfaceType:l.string().min(1),channelId:l.string().optional(),channelName:l.string().optional(),userPermissionLevel:x9}),eN=l.object({id:l.string().min(1),source:l.string().min(1),title:l.string().optional(),content:l.string().min(1),provenance:l.record(l.string(),l.unknown()).optional()}),bve=l.object({items:l.array(eN).default([])}),_9=l.object({items:l.array(l.unknown()).default([]).transform((e)=>e.flatMap((t)=>{let r=eN.safeParse(t);return r.success?[r.data]:[]}))}),E9=Ee({channel:"agent:context:request",request:Xz,response:_9,delivery:"collect"})});var k9,I9;var rN=v(()=>{fe();k9=l.strictObject({entityType:l.string().min(1),entityId:l.string().min(1)}),I9=l.strictObject({startedAt:l.string().datetime(),retrieved:l.array(k9).max(50)})});var nN,A9,oN,T9;var iN=v(()=>{fe();Gm();nN=l.object({actor:ci}),A9=l.object({userId:l.string().min(1),personId:l.string().min(1),canonicalId:l.string().min(1).optional(),displayName:l.string().min(1),permissionLevel:l.enum(["admin","trusted","public"])}),oN=l.object({principal:A9.nullable()}),T9=Ee({channel:"auth:principal:resolve",request:nN,response:oN,delivery:"request"})});var sN=()=>{};var aN=()=>{};var zE,R9,cN,$9,O9;var lN=v(()=>{fe();zE=l.strictObject({name:l.string().min(1).optional(),address:l.email()}),R9=l.strictObject({personId:l.string().min(1).max(200),displayName:l.string().trim().min(1).max(200),permissionLevel:l.enum(["admin","trusted","public"])}),cN=l.strictObject({messageId:l.string().min(1),sourceRef:l.string().min(1),threadId:l.string().min(1).optional(),from:zE,replyTo:zE.optional(),to:l.array(zE),subject:l.string(),receivedAt:l.iso.datetime(),text:l.string(),html:l.string().min(1).optional(),headers:l.strictObject({listUnsubscribe:l.string().min(1).optional(),autoSubmitted:l.string().min(1).optional(),precedence:l.string().min(1).optional(),inReplyTo:l.string().min(1).optional(),references:l.array(l.string().min(1)).optional()}),sender:R9.optional()}),$9=l.strictObject({}),O9=Ee({channel:"email:inbound",request:cN,response:$9,delivery:"request"})});var C9,P9,uN,NE,z9,dN,N9;var pN=v(()=>{fe();C9=l.strictObject({permissionLevel:l.enum(["admin","trusted","public"])}),P9=l.custom((e)=>typeof AbortSignal<"u"&&e instanceof AbortSignal),uN=l.strictObject({sourceRef:l.string().regex(/^imap:[a-f0-9]{64}$/),actor:C9,signal:P9.optional()}),NE=l.strictObject({name:l.string().trim().min(1).max(300).optional(),address:l.email().max(320)}),z9=l.strictObject({messageId:l.string().trim().min(1).max(2000),from:NE,replyTo:NE.optional(),to:l.array(NE).max(100),subject:l.string().max(1000),receivedAt:l.iso.datetime(),text:l.string().max(1e5),inReplyTo:l.string().trim().min(1).max(2000).optional(),references:l.array(l.string().trim().min(1).max(2000)).max(100),truncated:l.boolean()}),dN=l.discriminatedUnion("kind",[l.strictObject({kind:l.literal("available"),message:z9}),l.strictObject({kind:l.literal("unavailable")})]),N9=Ee({channel:"email:source-read",request:uN,response:dN,delivery:"request"})});var fN=()=>{};var mN=v(()=>{fN()});var D9;var hN=v(()=>{fe();D9=l.object({url:l.string(),authToken:l.string().optional()})});var L9;var gN=v(()=>{fe();L9=l.object({success:l.boolean(),entityId:l.string().optional(),error:l.string().optional()})});var yN=()=>{};function Qm(e,t="handler_failed"){let r=t,o;try{if(e!==null&&typeof e==="object"){let n=Nu.safeParse(Reflect.get(e,"code"));if(n.success)r=n.data,o=Du.shape.message.safeParse(Reflect.get(e,"publicMessage")).data;else{let i=Reflect.get(e,"name");if(i==="AbortError")r="cancelled";if(i==="TimeoutError")r="deadline_exceeded"}}}catch{}return new li(r,{cause:e,...o!==void 0?{publicMessage:o}:{}})}var Nu,SN=1024,Du,bN,li;var vN=v(()=>{fe();Nu=l.enum(["no_handler","handler_failed","invalid_input","invalid_response","unauthenticated","permission_denied","not_found","conflict","cancelled","deadline_exceeded"]),Du=l.object({code:Nu,message:l.string().max(SN)}),bN={no_handler:"No handler is available for this capability",handler_failed:"The operation failed",invalid_input:"Invalid input",invalid_response:"Invalid response",unauthenticated:"Authentication required",permission_denied:"Permission denied",not_found:"Not found",conflict:"The operation conflicts with the current state",cancelled:"The operation was cancelled",deadline_exceeded:"The execution deadline was exceeded"};li=class li extends Error{code;publicMessage;constructor(e,t={}){let r=Nu.parse(e),o=Du.shape.message.parse(t.publicMessage??bN[r]);super(t.message??o,{cause:t.cause});this.name="SdkError",this.code=r,this.publicMessage=o}toJSON(){let e=Nu.safeParse(this.code),t=e.data??"handler_failed",r=e.success?Du.shape.message.safeParse(this.publicMessage).data:void 0;return{code:t,message:r??bN[t]}}}});var Ym,Xm;var DE=v(()=>{fe();Ym=l.lazy(()=>l.union([l.null(),l.boolean(),l.number().finite().refine((e)=>!Number.isInteger(e)||Number.isSafeInteger(e),{message:"integer exceeds the JSON-safe range"}),l.string(),l.array(Ym),l.record(l.string(),Ym)])),Xm=l.record(l.string(),Ym)});var B9;var wN=v(()=>{fe();B9=l.enum(["user","assistant"])});var j9,uo;var xN=v(()=>{fe();j9=l.object({entityType:l.string().min(1),entityId:l.string().min(1),contentHash:l.string().min(1).optional()}),uo=l.object({rootJobId:l.string().min(1),causationId:l.string().min(1),projectionId:l.string().min(1).optional(),projectionLineage:l.array(l.string().min(1)),sourceEntity:j9.optional(),derivationDepth:l.number().int().nonnegative()}).superRefine((e,t)=>{if(e.derivationDepth!==e.projectionLineage.length)t.addIssue({code:"custom",path:["derivationDepth"],message:"Derivation depth must equal projection lineage length"});let r=e.projectionLineage.at(-1);if(e.projectionId!==r)t.addIssue({code:"custom",path:["projectionId"],message:"Current projection must equal the final projection lineage entry"})})});var LE=10,_N=82,BE,Z9,U9,M9,q9,F9,K9;var EN=v(()=>{fe();BE=l.object({title:l.string().min(1).max(200),lines:l.array(l.string().min(1)).min(1).max(LE),actions:l.array(l.object({label:l.string().min(1).max(80),value:l.string().min(1).max(_N)})).max(LE)}),Z9=BE.extend({channelId:l.string().min(1),interfaceType:l.string().min(1),reactions:l.array(l.object({messageId:l.string().min(1),emoji:l.string().min(1)}))}),U9=l.object({messageId:l.string().min(1)}),M9=l.object({conversationId:l.string().min(1),noticeMessageId:l.string().min(1),value:l.string().min(1),by:l.string().min(1)}),q9=Ee({channel:"chat:space-notice",request:Z9,response:U9,delivery:"request"}),F9=BE.nullable(),K9=Ee({channel:"chat:space-notice-action",request:M9,response:F9,delivery:"collect"})});function ui(e,t){return Object.freeze({name:e,schema:t})}var nwe;var jE=v(()=>{fe();nwe=l.object({name:l.string(),schema:l.custom((e)=>typeof e==="object"&&e!==null&&("safeParse"in e))})});var ZE,UE,H9,J9,V9,W9;var kN=v(()=>{fe();jE();ZE={progress:"job-progress"},UE={completed:"publish:completed",failed:"publish:failed"},H9=l.object({entityType:l.string().min(1),entityId:l.string().min(1),result:l.object({id:l.string(),url:l.string().optional()})}),J9=l.object({entityType:l.string().min(1),entityId:l.string().min(1),error:l.string(),retryCount:l.number(),willRetry:l.boolean()}),V9=ui(UE.completed,H9),W9=ui(UE.failed,J9)});var IN,AN,G9;var TN=v(()=>{fe();IN=l.object({entityType:l.string().min(1),entityId:l.string(),metadata:l.record(l.string(),l.unknown()).default({}),content:l.string().default("")}),AN=l.object({relativePath:l.string(),leaf:l.object({start:l.number().int().nonnegative(),end:l.number().int().nonnegative()}).nullable(),owner:l.object({entityType:l.string(),id:l.string()}).optional(),writable:l.boolean().optional()}),G9=Ee({channel:"sync:path:request",request:IN,response:AN,delivery:"request"})});var Q9,Y9,X9,e7;var RN=v(()=>{fe();Q9=l.strictObject({}),Y9=l.object({branch:l.string(),hasChanges:l.boolean(),ahead:l.number(),behind:l.number(),lastCommit:l.string().nullable(),remote:l.string().nullable()}),X9=l.object({syncPath:l.string(),isInitialized:l.boolean(),watchEnabled:l.boolean(),lastSync:l.string().nullable(),totalFiles:l.number(),byEntityType:l.record(l.string(),l.number()),git:Y9.nullable(),managementUrl:l.string().optional()}),e7=Ee({channel:"sync:status:request",request:Q9,response:X9,delivery:"request"})});var $N=()=>{};var ON,t7,r7;var CN=v(()=>{fe();ON=l.strictObject({waveId:l.string().trim().min(1),sourceTypes:l.array(l.string().trim().min(1)),changedTargetTypes:l.array(l.string().trim().min(1))}),t7=l.strictObject({}),r7=Ee({channel:"projection:wave-ready",request:ON,response:t7,delivery:"collect"})});var n7,o7,i7;var PN=v(()=>{fe();n7=l.strictObject({}),o7=l.string(),i7=Ee({channel:"plugin:site-builder:head-scripts",request:n7,response:o7,delivery:"collect"})});function zN(e){return typeof e==="function"}var NN=".site-build-manifest.json",s7,a7,c7;var DN=v(()=>{fe();s7=`/${NN}`;a7=l.object({outputDir:l.string(),environment:l.enum(["preview","production"]),routesBuilt:l.number(),siteConfig:l.object({title:l.string().optional(),description:l.string().optional(),url:l.string().optional(),copyright:l.string().optional(),themeMode:l.enum(["light","dark"]).optional()}),generateEntityUrl:l.custom(zN),reportFailure:l.custom(zN)}),c7=Ee({channel:"site:build:staging",request:a7,response:l.void(),delivery:"command"})});var l7,u7,d7;var LN=v(()=>{fe();l7=l.object({id:l.string().min(1),trigger:l.string().min(1),playbookId:l.string().min(1),once:l.boolean().default(!0),starterText:l.string().min(1),description:l.string().min(1).optional(),starterPrompt:l.string().min(1)}).strict(),u7=l.object({registered:l.boolean(),id:l.string(),ignored:l.boolean().optional(),reason:l.string().optional()}),d7=Ee({channel:"playbooks:register-lifecycle-starter",request:l7,response:u7,delivery:"request"})});var p7,f7,m7;var BN=v(()=>{fe();p7=l.object({id:l.string().min(1),markdown:l.string().min(1)}).strict(),f7=l.object({created:l.boolean()}),m7=Ee({channel:"playbooks:seed",request:p7,response:f7,delivery:"request"})});var jN,eh,ME,ZN,UN,h7,g7;var MN=v(()=>{fe();jN=["name","headline","industry","location","website","story"],eh=l.enum(jN),ME=l.object({name:l.string().optional(),headline:l.string().optional(),industry:l.string().optional(),location:l.string().optional(),website:l.string().optional(),story:l.string().optional()}),ZN=l.enum(["fill","preserve","unchanged"]),UN=l.object({field:eh,current:l.string().nullable(),imported:l.string(),outcome:ZN}),h7=Ee({channel:"@brains/profile:import-preview",request:l.object({fields:ME}),response:l.object({fields:l.array(UN),changed:l.boolean(),revision:l.string()}),delivery:"request"}),g7=Ee({channel:"@brains/profile:import-apply",request:l.object({fields:ME,revision:l.string()}),response:l.object({filled:l.array(eh),kept:l.array(eh)}),delivery:"request"})});function S7(e){return typeof e==="object"&&e!==null&&"name"in e&&typeof e.name==="string"&&"publish"in e&&typeof e.publish==="function"}var y7,b7,v7,w7,x7,_7,qN,E7;var FN=v(()=>{fe();y7=l.enum(["provider"]),b7=l.object({executionMode:y7.optional(),publishResultIdField:l.string().min(1).optional(),publishTimestampField:l.string().min(1).optional(),enabled:l.boolean().optional()}).strict();v7=l.custom(S7),w7=l.object({entityType:l.string(),provider:v7.optional(),config:b7.optional()}),x7=Ee({channel:"publish:register",request:w7,response:l.void(),delivery:"command"}),_7=l.union([l.string().min(1),l.object({location:l.enum(["metadata","frontmatter"]),field:l.string().min(1)})]),qN=l.object({entityType:l.string().min(1),attachmentType:l.string().min(1),mediaEntityType:l.enum(["image"]),targetEntityField:_7.optional(),requiredWhen:l.object({status:l.string().min(1).optional(),visibility:l.string().min(1).optional()}).optional(),autoGenerate:l.boolean().optional(),requiredForPublish:l.boolean().optional()}),E7=Ee({channel:"publish-assets:register",request:qN,response:l.void(),delivery:"command"})});var k7,I7,A7,T7,R7,$7;var KN=v(()=>{fe();k7=l.object({entityType:l.string()}),I7=Ee({channel:"generate:execute",request:k7,response:l.void(),delivery:"command"}),A7=l.object({entityType:l.string(),entityId:l.string()}),T7=Ee({channel:"generate:report:success",request:A7,response:l.void(),delivery:"command"}),R7=l.object({entityType:l.string(),error:l.string()}),$7=Ee({channel:"generate:report:failure",request:R7,response:l.void(),delivery:"command"})});var O7,HN,JN,VN;var WN=v(()=>{fe();O7=l.object({message:l.string().describe("Natural language response to the query"),summary:l.string().optional().describe("Brief summary if applicable"),topics:l.array(l.string()).optional().describe("Related topics mentioned"),sources:l.array(l.object({id:l.string(),type:l.string(),excerpt:l.string().optional(),relevance:l.number().min(0).max(1).optional()})).optional().describe("Source entities used to answer the query"),metadata:l.record(l.string(),l.unknown()).optional()}).describe("defaultQueryResponse"),HN=l.object({message:l.string()}).describe("simpleTextResponse"),JN=l.object({success:l.boolean(),entityId:l.string().optional(),message:l.string()}).describe("createEntityResponse"),VN=l.object({success:l.boolean(),entityId:l.string(),changes:l.array(l.string()).optional(),message:l.string()}).describe("updateEntityResponse")});var GN,QN,C7,YN,XN,P7;var e2=v(()=>{fe();GN=l.discriminatedUnion("type",[l.strictObject({type:l.literal("email"),address:l.email()})]),QN=l.strictObject({recipient:GN.optional(),title:l.string().min(1),body:l.string().min(1),html:l.string().min(1).optional(),sensitivity:l.enum(["normal","secret"]).default("normal"),idempotencyKey:l.string().trim().min(1).max(200).optional(),replyTo:l.email().optional()}),C7=l.enum(["recipient-missing","transport-missing","delivery-failed"]),YN=l.string().regex(/^[a-z0-9_:.-]{1,80}$/u),XN=l.discriminatedUnion("status",[l.strictObject({status:l.literal("sent"),deliveryId:l.string().optional()}),l.strictObject({status:l.literal("failed"),failure:C7,transportCode:YN.optional()})]),P7=Ee({channel:"notifications:send",request:QN,response:XN,delivery:"request"})});var z7,t2,N7;var r2=v(()=>{fe();z7=l.strictObject({}),t2=l.strictObject({titles:l.array(l.string().trim().min(1).max(500)).max(20)}),N7=Ee({channel:"topics:public-titles",request:z7,response:t2,delivery:"request"})});var D7,L7,B7;var n2=v(()=>{fe();D7=l.strictObject({}),L7=l.strictObject({types:l.array(l.string().trim().min(1))}),B7=Ee({channel:"topics:source-types",request:D7,response:L7,delivery:"request"})});var o2,i2,j7;var s2=v(()=>{fe();o2=l.strictObject({id:l.string().regex(/^[a-z0-9][a-z0-9-]{0,79}$/),title:l.string().trim().min(1).max(200),body:l.string().trim().min(1).max(20000)}),i2=l.strictObject({noteId:l.string(),created:l.boolean()}),j7=Ee({channel:"note:capture",request:o2,response:i2,delivery:"request"})});var lc,Lu,Z7,U7,M7,q7,F7,K7;var a2=v(()=>{fe();DE();lc=l.string().regex(/^[a-z][a-z0-9-]{0,63}$/),Lu=l.string().min(32).max(512),Z7=l.strictObject({provider:lc,brainState:Lu}),U7=l.strictObject({authorizationUrl:l.url({protocol:/^https?$/})}),M7=l.strictObject({provider:lc,grant:Lu}),q7=l.strictObject({provider:lc,credential:Xm}),F7=l.enum(["provider_denied","authorization_incomplete","credential_exchange_failed"]),K7=l.union([l.strictObject({provider:lc,state:Lu,grant:Lu}),l.strictObject({provider:lc,state:Lu,error:F7})])});var H7,J7,V7,W7;var c2=v(()=>{fe();H7=l.object({permissionLevel:l.enum(["public","trusted","admin"])}),J7=l.object({id:l.string().min(1),title:l.string().min(1),sub:l.string().optional(),href:l.string().min(1),primary:l.boolean().optional(),keywords:l.array(l.string()).optional()}),V7=l.array(J7),W7=Ee({channel:"console:jump-destinations",request:H7,response:V7,delivery:"collect"})});var th,qE;var l2=v(()=>{fe();th=l.enum(["github","instagram","linkedin","podcast","email","website"]),qE=l.object({platform:th.describe("Social media platform"),url:l.string().describe("Profile or contact URL"),label:l.string().optional().describe("Optional display label")})});function rh(e){if(!e.type.includes(":"))throw Error(`Job contract type "${e.type}" must name its owner, as "owner:job"`);return Object.freeze({type:e.type,input:e.input})}var u2,d2,G7,p2,Q7;var f2=v(()=>{fe();u2=l.enum(["1:1","16:9","9:16","4:3","3:4"]),d2=l.object({prompt:l.string(),title:l.string().optional(),aspectRatio:u2.optional(),targetEntityType:l.string().optional(),targetEntityId:l.string().optional(),entityTitle:l.string().optional(),entityContent:l.string().optional()}),G7=rh({type:"image:image-generate",input:d2}),p2=l.object({sourceEntityType:l.string().min(1),sourceEntityId:l.string().min(1),attachmentType:l.string().min(1),imageId:l.string().min(1),dedupKey:l.string().min(1).optional(),replace:l.boolean().optional(),targetEntityType:l.string().min(1).optional(),targetEntityId:l.string().min(1).optional(),targetImageField:l.enum(["coverImageId","ogImageId"]).optional()}),Q7=rh({type:"image:image-render-source",input:p2})});var Y7;var m2=v(()=>{fe();Y7=l.enum(["none","low","medium","high","xhigh","max"])});var Rt=v(()=>{IE();Az();OE();Jz();Wz();zu();Yz();tN();rN();Gm();iN();sN();aN();lN();pN();mN();hN();gN();yN();vN();DE();wN();xN();EN();kN();jE();TN();RN();$N();CN();RE();PN();DN();LN();BN();MN();FN();KN();WN();e2();r2();n2();s2();a2();c2();l2();f2();m2()});var rW,nW,$t,mr,Is,oW,di="capability-bundles-v1",oh,iW,sW,aW,cW,h2,nh,pi,Kr,lW,uW,dW,pW,fW,FE,mW,hW,ih;var Bn=v(()=>{Rt();fe();rW=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/,nW=/^[a-z0-9]+(?:-[a-z0-9]+)*$/,$t=l.string().regex(rW,"expected exact pinned version"),mr=l.string().regex(nW,"expected lowercase handle slug"),Is=l.string().min(1),oW=l.string().startsWith("age1").min(1),oh=l.enum(["core","media","automation","web","chat","site","publishing","federation","team"]),iW=["professional","team","organization"],sW=l.enum(iW),aW=["person","team","organization"],cW=l.enum(aW),h2=l.array(oh).min(1),nh=l.array(l.string().min(1)),pi=l.strictObject({brainVersion:$t,bundleContract:l.literal(di),bundles:h2,add:nh.optional(),remove:nh.optional(),githubOrg:l.string().min(1),contentRepoPrefix:l.string().min(1),domainSuffix:l.string().min(1),openaiApiKey:Is,gitSyncToken:Is,contentRepoAdminToken:Is,agePublicKey:oW}).superRefine((e,t)=>{if(new Set(e.bundles).size!==e.bundles.length)t.addIssue({code:l.ZodIssueCode.custom,path:["bundles"],message:"canonical bundles must be unique"})}),Kr=l.strictObject({members:l.array(mr).min(1),brainVersionOverride:$t.optional(),bundlesOverride:h2.optional(),addOverride:nh.optional(),removeOverride:nh.optional(),openaiApiKeyOverride:Is.optional(),gitSyncTokenOverride:Is.optional()}).superRefine((e,t)=>{if(new Set(e.members).size!==e.members.length)t.addIssue({code:l.ZodIssueCode.custom,path:["members"],message:"cohort members must be unique"});if(e.bundlesOverride&&new Set(e.bundlesOverride).size!==e.bundlesOverride.length)t.addIssue({code:l.ZodIssueCode.custom,path:["bundlesOverride"],message:"canonical bundle overrides must be unique"})}),lW=l.strictObject({platform:th,url:l.string().min(1),label:l.string().min(1).optional()}),uW=l.strictObject({name:l.string().min(1).optional(),description:l.string().min(1).optional(),website:l.string().min(1).optional(),email:l.string().min(1).optional(),story:l.string().min(1).optional(),socialLinks:l.array(lW).optional()}),dW=l.strictObject({delivery:l.literal("email"),email:l.string().email()}),pW=l.strictObject({enabled:l.boolean().optional(),endpoint:l.string().url().refine((e)=>new URL(e).protocol==="wss:",{message:"Jetstream endpoint must use wss"}).optional(),replayWindowSeconds:l.number().int().min(60).optional(),denyDids:l.array(l.string().startsWith("did:plc:")).optional(),denyDomains:l.array(l.string().min(1)).optional(),skillKeywords:l.array(l.string().min(1)).optional(),queueLimit:l.number().int().min(1).max(1e4).optional(),concurrency:l.number().int().min(1).max(32).optional(),perDidCooldownSeconds:l.number().int().nonnegative().optional(),fetchBudgetPerMinute:l.number().int().min(1).optional(),newAgentsPerHour:l.number().int().min(1).optional(),pendingCandidateCeiling:l.number().int().min(1).optional(),staleCandidateRetentionDays:l.number().int().min(1).optional(),requestTimeoutMs:l.number().int().min(100).optional(),maxResponseBytes:l.number().int().min(1024).optional(),maxRedirects:l.number().int().nonnegative().optional(),retryAttempts:l.number().int().min(1).optional(),heartbeatIntervalHours:l.number().min(1).optional()}),fW=l.strictObject({identifier:l.string().min(1),accountDid:l.string().min(1).optional(),lexiconAuthority:l.boolean().optional(),jetstream:pW.optional()}),FE=l.strictObject({package:l.string().min(1),version:$t.optional(),theme:l.string().min(1).optional(),themeVersion:$t.optional()}).superRefine((e,t)=>{let r=e.package.startsWith("@rizom/");if(r&&e.version===void 0)t.addIssue({code:l.ZodIssueCode.custom,path:["version"],message:"external @rizom site packages require an exact version pin"});if(!r&&e.version!==void 0)t.addIssue({code:l.ZodIssueCode.custom,path:["version"],message:"version is valid only for external @rizom site packages"});let o=e.theme?.startsWith("@rizom/")===!0;if(o&&e.themeVersion===void 0)t.addIssue({code:l.ZodIssueCode.custom,path:["themeVersion"],message:"external @rizom themes require an exact version pin"});if(!o&&e.themeVersion!==void 0)t.addIssue({code:l.ZodIssueCode.custom,path:["themeVersion"],message:"themeVersion is valid only for external @rizom themes"})}),mW=l.strictObject({onboarding:l.boolean().optional()}),hW=l.record(l.string().min(1),l.record(l.string(),l.unknown())),ih=l.strictObject({handle:mr,discord:l.strictObject({enabled:l.boolean(),anchorUserId:l.string().min(1).optional()}),openaiApiKeyOverride:Is.optional(),gitSyncTokenOverride:Is.optional(),domainOverride:l.string().min(1).optional(),cloudflareZoneId:l.string().min(1).optional(),contentRepoOverride:l.string().min(1).optional(),profileKind:sW.optional(),anchorKind:cW.optional(),plugins:hW.optional(),spaces:l.array(l.string().min(1)).optional(),embeddingEnabled:l.boolean().optional(),embeddingModel:l.string().optional(),topicExtractionEnabled:l.boolean().optional(),skillDerivationEnabled:l.boolean().optional(),swotDerivationEnabled:l.boolean().optional(),addOverride:l.array(l.string().min(1)).optional(),removeOverride:l.array(l.string().min(1)).optional(),siteOverride:FE.optional(),setup:dW.optional(),atproto:fW.optional(),playbooks:mW.optional(),anchorProfile:uW.optional()})});import{access as gW,readdir as yW,readFile as bW}from"fs/promises";import{basename as KE,join as Bu,relative as SW}from"path";async function ut(e,t={}){let[r,o,n]=await Promise.all([HE(Bu(e,"pilot.yaml"),pi),wW(e),xW(e)]),i=_W(o,n),s=n.map((c)=>({id:c.id,members:[...c.data.members].sort(),...ka({brainVersionOverride:c.data.brainVersionOverride,bundlesOverride:c.data.bundlesOverride,addOverride:c.data.addOverride,removeOverride:c.data.removeOverride,openaiApiKeyOverride:c.data.openaiApiKeyOverride,gitSyncTokenOverride:c.data.gitSyncTokenOverride})})).sort((c,u)=>c.id.localeCompare(u.id)),a=await Promise.all(o.map(async(c)=>{let u=i.get(c.data.handle);if(!u)throw new As(`User ${c.data.handle} must belong to exactly one cohort`);let d={...vW(c.data,u,r),snapshotStatus:await IW(e,c.data.handle)},p=await t.resolveStatus?.(d);return{...d,serverStatus:p?.serverStatus??"unknown",deployStatus:p?.deployStatus??"unknown",dnsStatus:p?.dnsStatus??"unknown",mcpStatus:p?.mcpStatus??"unknown"}}));return a.sort((c,u)=>c.handle.localeCompare(u.handle)),{pilot:r,cohorts:s,users:a}}function vW(e,t,r){let o=t.data.bundlesOverride===void 0;return{handle:e.handle,cohort:t.id,brainVersion:t.data.brainVersionOverride??r.brainVersion,bundleContract:r.bundleContract,bundles:[...t.data.bundlesOverride??r.bundles],add:g2(t.data.addOverride??(o?r.add:void 0),e.addOverride),remove:g2(t.data.removeOverride??(o?r.remove:void 0),e.removeOverride),domain:e.domainOverride??`${e.handle}${r.domainSuffix}`,...ka({cloudflareZoneId:e.cloudflareZoneId}),contentRepo:e.contentRepoOverride??`${r.contentRepoPrefix}${e.handle}-content`,...ka({profileKind:e.profileKind,anchorKind:e.anchorKind,embeddingEnabled:e.embeddingEnabled,embeddingModel:e.embeddingModel,spaces:e.spaces,plugins:e.plugins,topicExtractionEnabled:e.topicExtractionEnabled,skillDerivationEnabled:e.skillDerivationEnabled,swotDerivationEnabled:e.swotDerivationEnabled,siteOverride:e.siteOverride&&{...e.siteOverride}}),discordEnabled:e.discord.enabled,...ka({discordAnchorUserId:e.discord.anchorUserId}),effectiveOpenaiApiKey:e.openaiApiKeyOverride??t.data.openaiApiKeyOverride??r.openaiApiKey,effectiveGitSyncToken:e.gitSyncTokenOverride??t.data.gitSyncTokenOverride??r.gitSyncToken,...ka({setup:e.setup,atproto:e.atproto,playbooks:e.playbooks}),anchorProfile:EW(e.handle,e.anchorProfile)}}function g2(e,t){return AW([...e??[],...t??[]])}async function wW(e){let t=Bu(e,"users"),r=(await y2(t)).filter((n)=>!KE(n).endsWith(".secrets.yaml"));return(await Promise.all(r.map(async(n)=>{let i=b2(KE(n)),s=await HE(n,ih);if(s.handle!==i){let a=S2(SW(e,n));throw new As(`${a} must declare handle: ${i}`)}return{id:i,data:s}}))).sort((n,i)=>n.id.localeCompare(i.id))}async function xW(e){let t=Bu(e,"cohorts"),r=await y2(t);return(await Promise.all(r.map(async(n)=>({id:b2(KE(n)),data:await HE(n,Kr)})))).sort((n,i)=>n.id.localeCompare(i.id))}function _W(e,t){let r=new Map(e.map((n)=>[n.data.handle,n])),o=new Map;for(let n of t)for(let i of n.data.members){if(!r.has(i))throw new As(`Cohort ${n.id} references unknown user ${i}`);if(o.has(i))throw new As(`User ${i} must belong to exactly one cohort`);o.set(i,n)}for(let n of e)if(!o.has(n.data.handle))throw new As(`User ${n.data.handle} must belong to exactly one cohort`);return o}function EW(e,t){return{name:t?.name??kW(e),...t?.description?{description:t.description}:{},...t?.website?{website:t.website}:{},...t?.email?{email:t.email}:{},...t?.story?{story:t.story}:{},...t?.socialLinks?{socialLinks:t.socialLinks.map((r)=>({platform:r.platform,url:r.url,...r.label?{label:r.label}:{}}))}:{}}}function kW(e){return e.split("-").filter((t)=>t.length>0).map((t)=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}async function IW(e,t){let r=Bu(e,"users",t,"brain.yaml");try{return await gW(r),"present"}catch{return"missing"}}async function y2(e){return(await yW(e,{withFileTypes:!0})).filter((r)=>r.isFile()&&r.name.endsWith(".yaml")).map((r)=>Bu(e,r.name)).sort((r,o)=>r.localeCompare(o))}async function HE(e,t){let r=await bW(e,"utf8"),o=lr(r,t);if(!o.ok)throw new As(`${S2(e)}: ${o.error}`);return o.data}function AW(e){return[...new Set(e)]}function b2(e){return e.replace(/\.ya?ml$/,"")}function S2(e){return e.replaceAll("\\","/")}var As;var Hr=v(()=>{Cn();Bn();As=class As extends Error{}});import{mkdir as TW,writeFile as RW}from"fs/promises";import{join as v2}from"path";async function po(e,t={}){let o=(t.registry??await ut(e,t)).users.map((i)=>{let s=i.discordEnabled?"on":"off";return[i.handle,i.cohort,i.bundles.join(","),i.add.join(","),i.remove.join(","),i.brainVersion,i.domain,i.contentRepo,s,i.serverStatus,i.deployStatus,i.dnsStatus,i.mcpStatus]}),n=["<!-- generated by brains-ops; do not edit -->","",$W,OW,...o.map((i)=>`| ${i.join(" | ")} |`),""].join(`
|
|
234
|
-
`);await
|
|
233
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let s of e.seen.entries()){let a=s[1];if(t===s[0]){i(s);continue}if(e.external){let u=e.external.registry.get(s[0])?.id;if(t!==s[0]&&u){i(s);continue}}if(e.metadataRegistry.get(s[0])?.id){i(s);continue}if(a.cycle){i(s);continue}if(a.count>1){if(e.reused==="ref"){i(s);continue}}}}function ai(e,t){let r=e.seen.get(t);if(!r)throw Error("Unprocessed schema. This is a bug in Zod.");let o=(a)=>{let c=e.seen.get(a);if(c.ref===null)return;let u=c.def??c.schema,d={...u},p=c.ref;if(c.ref=null,p){o(p);let h=e.seen.get(p),b=h.schema;if(b.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"))u.allOf=u.allOf??[],u.allOf.push(b);else Object.assign(u,b);if(Object.assign(u,d),a._zod.parent===p)for(let S in u){if(S==="$ref"||S==="allOf")continue;if(!(S in d))delete u[S]}if(b.$ref&&h.def)for(let S in u){if(S==="$ref"||S==="allOf")continue;if(S in h.def&&JSON.stringify(u[S])===JSON.stringify(h.def[S]))delete u[S]}}let m=a._zod.parent;if(m&&m!==p){o(m);let h=e.seen.get(m);if(h?.schema.$ref){if(u.$ref=h.schema.$ref,h.def)for(let b in u){if(b==="$ref"||b==="allOf")continue;if(b in h.def&&JSON.stringify(u[b])===JSON.stringify(h.def[b]))delete u[b]}}}e.override({zodSchema:a,jsonSchema:u,path:c.path??[]})};for(let a of[...e.seen.entries()].reverse())o(a[0]);let n={};if(e.target==="draft-2020-12")n.$schema="https://json-schema.org/draft/2020-12/schema";else if(e.target==="draft-07")n.$schema="http://json-schema.org/draft-07/schema#";else if(e.target==="draft-04")n.$schema="http://json-schema.org/draft-04/schema#";else if(e.target==="openapi-3.0");if(e.external?.uri){let a=e.external.registry.get(t)?.id;if(!a)throw Error("Schema is missing an `id` property");n.$id=e.external.uri(a)}Object.assign(n,r.def??r.schema);let i=e.metadataRegistry.get(t)?.id;if(i!==void 0&&n.id===i)delete n.id;let s=e.external?.defs??{};for(let a of e.seen.entries()){let c=a[1];if(c.def&&c.defId){if(c.def.id===c.defId)delete c.def.id;s[c.defId]=c.def}}if(e.external);else if(Object.keys(s).length>0)if(e.target==="draft-2020-12")n.$defs=s;else n.definitions=s;try{let a=JSON.parse(JSON.stringify(n));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:Ya(t,"input",e.processors),output:Ya(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch(a){throw Error("Error converting schema to JSON.")}}function fr(e,t){let r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);let o=e._zod.def;if(o.type==="transform")return!0;if(o.type==="array")return fr(o.element,r);if(o.type==="set")return fr(o.valueType,r);if(o.type==="lazy")return fr(o.getter(),r);if(o.type==="promise"||o.type==="optional"||o.type==="nonoptional"||o.type==="nullable"||o.type==="readonly"||o.type==="default"||o.type==="prefault")return fr(o.innerType,r);if(o.type==="intersection")return fr(o.left,r)||fr(o.right,r);if(o.type==="record"||o.type==="map")return fr(o.keyType,r)||fr(o.valueType,r);if(o.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return fr(o.in,r)||fr(o.out,r)}if(o.type==="object"){for(let n in o.shape)if(fr(o.shape[n],r))return!0;return!1}if(o.type==="union"){for(let n of o.options)if(fr(n,r))return!0;return!1}if(o.type==="tuple"){for(let n of o.items)if(fr(n,r))return!0;if(o.rest&&fr(o.rest,r))return!0;return!1}return!1}var I0=(e,t={})=>(r)=>{let o=ii({...r,processors:t});return We(e,o),si(o,e),ai(o,e)},Ya=(e,t,r={})=>(o)=>{let{libraryOptions:n,target:i}=o??{},s=ii({...n??{},target:i,io:t,processors:r});return We(e,s),si(s,e),ai(s,e)};var gu=v(()=>{fu()});function gm(e,t){if("_idmap"in e){let o=e,n=ii({...t,processors:fm}),i={};for(let c of o._idmap.entries()){let[u,d]=c;We(d,n)}let s={},a={registry:o,uri:t?.uri,defs:i};n.external=a;for(let c of o._idmap.entries()){let[u,d]=c;si(n,d),s[u]=ai(n,d)}if(Object.keys(i).length>0){let c=n.target==="draft-2020-12"?"$defs":"definitions";s.__shared={[c]:i}}return{schemas:s}}let r=ii({...t,processors:fm});return We(e,r),si(r,e),ai(r,e)}var zV,A0=(e,t,r,o)=>{let n=r;n.type="string";let{minimum:i,maximum:s,format:a,patterns:c,contentEncoding:u}=e._zod.bag;if(typeof i==="number")n.minLength=i;if(typeof s==="number")n.maxLength=s;if(a){if(n.format=zV[a]??a,n.format==="")delete n.format;if(a==="time")delete n.format}if(u)n.contentEncoding=u;if(c&&c.size>0){let d=[...c];if(d.length===1)n.pattern=d[0].source;else if(d.length>1)n.allOf=[...d.map((p)=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:p.source}))]}},T0=(e,t,r,o)=>{let n=r,{minimum:i,maximum:s,format:a,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:d}=e._zod.bag;if(typeof a==="string"&&a.includes("int"))n.type="integer";else n.type="number";let p=typeof d==="number"&&d>=(i??Number.NEGATIVE_INFINITY),m=typeof u==="number"&&u<=(s??Number.POSITIVE_INFINITY),h=t.target==="draft-04"||t.target==="openapi-3.0";if(p)if(h)n.minimum=d,n.exclusiveMinimum=!0;else n.exclusiveMinimum=d;else if(typeof i==="number")n.minimum=i;if(m)if(h)n.maximum=u,n.exclusiveMaximum=!0;else n.exclusiveMaximum=u;else if(typeof s==="number")n.maximum=s;if(typeof c==="number")n.multipleOf=c},R0=(e,t,r,o)=>{r.type="boolean"},$0=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("BigInt cannot be represented in JSON Schema")},O0=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("Symbols cannot be represented in JSON Schema")},C0=(e,t,r,o)=>{if(t.target==="openapi-3.0")r.type="string",r.nullable=!0,r.enum=[null];else r.type="null"},P0=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("Undefined cannot be represented in JSON Schema")},z0=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("Void cannot be represented in JSON Schema")},N0=(e,t,r,o)=>{r.not={}},D0=(e,t,r,o)=>{},L0=(e,t,r,o)=>{},B0=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("Date cannot be represented in JSON Schema")},j0=(e,t,r,o)=>{let n=e._zod.def,i=Vl(n.entries);if(i.every((s)=>typeof s==="number"))r.type="number";if(i.every((s)=>typeof s==="string"))r.type="string";r.enum=i},Z0=(e,t,r,o)=>{let n=e._zod.def,i=[];for(let s of n.values)if(s===void 0){if(t.unrepresentable==="throw")throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof s==="bigint")if(t.unrepresentable==="throw")throw Error("BigInt literals cannot be represented in JSON Schema");else i.push(Number(s));else i.push(s);if(i.length===0);else if(i.length===1){let s=i[0];if(r.type=s===null?"null":typeof s,t.target==="draft-04"||t.target==="openapi-3.0")r.enum=[s];else r.const=s}else{if(i.every((s)=>typeof s==="number"))r.type="number";if(i.every((s)=>typeof s==="string"))r.type="string";if(i.every((s)=>typeof s==="boolean"))r.type="boolean";if(i.every((s)=>s===null))r.type="null";r.enum=i}},U0=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("NaN cannot be represented in JSON Schema")},M0=(e,t,r,o)=>{let n=r,i=e._zod.pattern;if(!i)throw Error("Pattern not found in template literal");n.type="string",n.pattern=i.source},q0=(e,t,r,o)=>{let n=r,i={type:"string",format:"binary",contentEncoding:"binary"},{minimum:s,maximum:a,mime:c}=e._zod.bag;if(s!==void 0)i.minLength=s;if(a!==void 0)i.maxLength=a;if(c)if(c.length===1)i.contentMediaType=c[0],Object.assign(n,i);else Object.assign(n,i),n.anyOf=c.map((u)=>({contentMediaType:u}));else Object.assign(n,i)},F0=(e,t,r,o)=>{r.type="boolean"},K0=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("Custom types cannot be represented in JSON Schema")},H0=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("Function types cannot be represented in JSON Schema")},J0=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("Transforms cannot be represented in JSON Schema")},V0=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("Map cannot be represented in JSON Schema")},W0=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw Error("Set cannot be represented in JSON Schema")},G0=(e,t,r,o)=>{let n=r,i=e._zod.def,{minimum:s,maximum:a}=e._zod.bag;if(typeof s==="number")n.minItems=s;if(typeof a==="number")n.maxItems=a;n.type="array",n.items=We(i.element,t,{...o,path:[...o.path,"items"]})},Q0=(e,t,r,o)=>{let n=r,i=e._zod.def;n.type="object",n.properties={};let s=i.shape;for(let u in s)n.properties[u]=We(s[u],t,{...o,path:[...o.path,"properties",u]});let a=new Set(Object.keys(s)),c=new Set([...a].filter((u)=>{let d=i.shape[u]._zod;if(t.io==="input")return d.optin===void 0;else return d.optout===void 0}));if(c.size>0)n.required=Array.from(c);if(i.catchall?._zod.def.type==="never")n.additionalProperties=!1;else if(!i.catchall){if(t.io==="output")n.additionalProperties=!1}else if(i.catchall)n.additionalProperties=We(i.catchall,t,{...o,path:[...o.path,"additionalProperties"]})},mm=(e,t,r,o)=>{let n=e._zod.def,i=n.inclusive===!1,s=n.options.map((a,c)=>We(a,t,{...o,path:[...o.path,i?"oneOf":"anyOf",c]}));if(i)r.oneOf=s;else r.anyOf=s},Y0=(e,t,r,o)=>{let n=e._zod.def,i=We(n.left,t,{...o,path:[...o.path,"allOf",0]}),s=We(n.right,t,{...o,path:[...o.path,"allOf",1]}),a=(u)=>("allOf"in u)&&Object.keys(u).length===1,c=[...a(i)?i.allOf:[i],...a(s)?s.allOf:[s]];r.allOf=c},X0=(e,t,r,o)=>{let n=r,i=e._zod.def;n.type="array";let s=t.target==="draft-2020-12"?"prefixItems":"items",a=t.target==="draft-2020-12"?"items":t.target==="openapi-3.0"?"items":"additionalItems",c=i.items.map((m,h)=>We(m,t,{...o,path:[...o.path,s,h]})),u=i.rest?We(i.rest,t,{...o,path:[...o.path,a,...t.target==="openapi-3.0"?[i.items.length]:[]]}):null;if(t.target==="draft-2020-12"){if(n.prefixItems=c,u)n.items=u}else if(t.target==="openapi-3.0"){if(n.items={anyOf:c},u)n.items.anyOf.push(u);if(n.minItems=c.length,!u)n.maxItems=c.length}else if(n.items=c,u)n.additionalItems=u;let{minimum:d,maximum:p}=e._zod.bag;if(typeof d==="number")n.minItems=d;if(typeof p==="number")n.maxItems=p},e_=(e,t,r,o)=>{let n=r,i=e._zod.def;n.type="object";let s=i.keyType,c=s._zod.bag?.patterns;if(i.mode==="loose"&&c&&c.size>0){let d=We(i.valueType,t,{...o,path:[...o.path,"patternProperties","*"]});n.patternProperties={};for(let p of c)n.patternProperties[p.source]=d}else{if(t.target==="draft-07"||t.target==="draft-2020-12")n.propertyNames=We(i.keyType,t,{...o,path:[...o.path,"propertyNames"]});n.additionalProperties=We(i.valueType,t,{...o,path:[...o.path,"additionalProperties"]})}let u=s._zod.values;if(u){let d=[...u].filter((p)=>typeof p==="string"||typeof p==="number");if(d.length>0)n.required=d}},t_=(e,t,r,o)=>{let n=e._zod.def,i=We(n.innerType,t,o),s=t.seen.get(e);if(t.target==="openapi-3.0")s.ref=n.innerType,r.nullable=!0;else r.anyOf=[i,{type:"null"}]},r_=(e,t,r,o)=>{let n=e._zod.def;We(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType},n_=(e,t,r,o)=>{let n=e._zod.def;We(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType,r.default=JSON.parse(JSON.stringify(n.defaultValue))},o_=(e,t,r,o)=>{let n=e._zod.def;We(n.innerType,t,o);let i=t.seen.get(e);if(i.ref=n.innerType,t.io==="input")r._prefault=JSON.parse(JSON.stringify(n.defaultValue))},i_=(e,t,r,o)=>{let n=e._zod.def;We(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType;let s;try{s=n.catchValue(void 0)}catch{throw Error("Dynamic catch values are not supported in JSON Schema")}r.default=s},s_=(e,t,r,o)=>{let n=e._zod.def,i=n.in._zod.traits.has("$ZodTransform"),s=t.io==="input"?i?n.out:n.in:n.out;We(s,t,o);let a=t.seen.get(e);a.ref=s},a_=(e,t,r,o)=>{let n=e._zod.def;We(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType,r.readOnly=!0},c_=(e,t,r,o)=>{let n=e._zod.def;We(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType},hm=(e,t,r,o)=>{let n=e._zod.def;We(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType},l_=(e,t,r,o)=>{let n=e._zod.innerType;We(n,t,o);let i=t.seen.get(e);i.ref=n},fm;var yu=v(()=>{gu();ke();zV={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},fm={string:A0,number:T0,boolean:R0,bigint:$0,symbol:O0,null:C0,undefined:P0,void:z0,never:N0,any:D0,unknown:L0,date:B0,enum:j0,literal:Z0,nan:U0,template_literal:M0,file:q0,success:F0,custom:K0,function:H0,transform:J0,map:V0,set:W0,array:G0,object:Q0,union:mm,intersection:Y0,tuple:X0,record:e_,nullable:t_,nonoptional:r_,default:n_,prefault:o_,catch:i_,pipe:s_,readonly:a_,promise:c_,optional:hm,lazy:l_}});class u_{get metadataRegistry(){return this.ctx.metadataRegistry}get target(){return this.ctx.target}get unrepresentable(){return this.ctx.unrepresentable}get override(){return this.ctx.override}get io(){return this.ctx.io}get counter(){return this.ctx.counter}set counter(e){this.ctx.counter=e}get seen(){return this.ctx.seen}constructor(e){let t=e?.target??"draft-2020-12";if(t==="draft-4")t="draft-04";if(t==="draft-7")t="draft-07";this.ctx=ii({processors:fm,target:t,...e?.metadata&&{metadata:e.metadata},...e?.unrepresentable&&{unrepresentable:e.unrepresentable},...e?.override&&{override:e.override},...e?.io&&{io:e.io}})}process(e,t={path:[],schemaPath:[]}){return We(e,this.ctx,t)}emit(e,t){if(t){if(t.cycles)this.ctx.cycles=t.cycles;if(t.reused)this.ctx.reused=t.reused;if(t.external)this.ctx.external=t.external}si(this.ctx,e);let r=ai(this.ctx,e),{"~standard":o,...n}=r;return n}}var H1=v(()=>{yu();gu()});var J1={};var V1=()=>{};var lo={};Lt(lo,{$ZodAny:()=>sw,$ZodArray:()=>dw,$ZodAsyncError:()=>Pn,$ZodBase64:()=>Gv,$ZodBase64URL:()=>Qv,$ZodBigInt:()=>Lf,$ZodBigIntFormat:()=>rw,$ZodBoolean:()=>iu,$ZodCIDRv4:()=>Jv,$ZodCIDRv6:()=>Vv,$ZodCUID:()=>Nv,$ZodCUID2:()=>Dv,$ZodCatch:()=>Rw,$ZodCheck:()=>rt,$ZodCheckBigIntFormat:()=>uv,$ZodCheckEndsWith:()=>xv,$ZodCheckGreaterThan:()=>Rf,$ZodCheckIncludes:()=>vv,$ZodCheckLengthEquals:()=>gv,$ZodCheckLessThan:()=>Tf,$ZodCheckLowerCase:()=>bv,$ZodCheckMaxLength:()=>mv,$ZodCheckMaxSize:()=>dv,$ZodCheckMimeType:()=>Ev,$ZodCheckMinLength:()=>hv,$ZodCheckMinSize:()=>pv,$ZodCheckMultipleOf:()=>cv,$ZodCheckNumberFormat:()=>lv,$ZodCheckOverwrite:()=>kv,$ZodCheckProperty:()=>_v,$ZodCheckRegex:()=>yv,$ZodCheckSizeEquals:()=>fv,$ZodCheckStartsWith:()=>wv,$ZodCheckStringFormat:()=>La,$ZodCheckUpperCase:()=>Sv,$ZodCodec:()=>au,$ZodCustom:()=>Lw,$ZodCustomStringFormat:()=>ew,$ZodDate:()=>uw,$ZodDefault:()=>kw,$ZodDiscriminatedUnion:()=>mw,$ZodE164:()=>Yv,$ZodEmail:()=>Ov,$ZodEmoji:()=>Pv,$ZodEncodeError:()=>hs,$ZodEnum:()=>Sw,$ZodError:()=>Xl,$ZodExactOptional:()=>_w,$ZodFile:()=>ww,$ZodFunction:()=>zw,$ZodGUID:()=>Rv,$ZodIPv4:()=>Fv,$ZodIPv6:()=>Kv,$ZodISODate:()=>Uv,$ZodISODateTime:()=>Zv,$ZodISODuration:()=>qv,$ZodISOTime:()=>Mv,$ZodIntersection:()=>hw,$ZodJWT:()=>Xv,$ZodKSUID:()=>jv,$ZodLazy:()=>Dw,$ZodLiteral:()=>vw,$ZodMAC:()=>Hv,$ZodMap:()=>yw,$ZodNaN:()=>$w,$ZodNanoID:()=>zv,$ZodNever:()=>cw,$ZodNonOptional:()=>Aw,$ZodNull:()=>iw,$ZodNullable:()=>Ew,$ZodNumber:()=>Df,$ZodNumberFormat:()=>tw,$ZodObject:()=>qC,$ZodObjectJIT:()=>pw,$ZodOptional:()=>jf,$ZodPipe:()=>Zf,$ZodPrefault:()=>Iw,$ZodPreprocess:()=>Ow,$ZodPromise:()=>Nw,$ZodReadonly:()=>Cw,$ZodRealError:()=>xr,$ZodRecord:()=>gw,$ZodRegistry:()=>Zx,$ZodSet:()=>bw,$ZodString:()=>Ss,$ZodStringFormat:()=>Ye,$ZodSuccess:()=>Tw,$ZodSymbol:()=>nw,$ZodTemplateLiteral:()=>Pw,$ZodTransform:()=>xw,$ZodTuple:()=>Bf,$ZodType:()=>Ne,$ZodULID:()=>Lv,$ZodURL:()=>Cv,$ZodUUID:()=>$v,$ZodUndefined:()=>ow,$ZodUnion:()=>su,$ZodUnknown:()=>aw,$ZodVoid:()=>lw,$ZodXID:()=>Bv,$ZodXor:()=>fw,$brand:()=>gS,$constructor:()=>Z,$input:()=>jx,$output:()=>Bx,Doc:()=>Of,JSONSchema:()=>J1,JSONSchemaGenerator:()=>u_,NEVER:()=>hS,TimePrecision:()=>Fx,_any:()=>d0,_array:()=>b0,_base64:()=>om,_base64url:()=>im,_bigint:()=>o0,_boolean:()=>r0,_catch:()=>TV,_check:()=>F1,_cidrv4:()=>rm,_cidrv6:()=>nm,_coercedBigint:()=>i0,_coercedBoolean:()=>n0,_coercedDate:()=>g0,_coercedNumber:()=>Gx,_coercedString:()=>Mx,_cuid:()=>Wf,_cuid2:()=>Gf,_custom:()=>v0,_date:()=>h0,_decode:()=>Sf,_decodeAsync:()=>wf,_default:()=>kV,_discriminatedUnion:()=>fV,_e164:()=>sm,_email:()=>Mf,_emoji:()=>Jf,_encode:()=>bf,_encodeAsync:()=>vf,_endsWith:()=>Fa,_enum:()=>SV,_file:()=>S0,_float32:()=>Yx,_float64:()=>Xx,_gt:()=>Nn,_gte:()=>pr,_guid:()=>mu,_includes:()=>Ma,_int:()=>Qx,_int32:()=>e0,_int64:()=>s0,_intersection:()=>mV,_ipv4:()=>em,_ipv6:()=>tm,_isoDate:()=>Hx,_isoDateTime:()=>Kx,_isoDuration:()=>Vx,_isoTime:()=>Jx,_jwt:()=>am,_ksuid:()=>Xf,_lazy:()=>CV,_length:()=>xs,_literal:()=>wV,_lowercase:()=>Za,_lt:()=>zn,_lte:()=>Pr,_mac:()=>qx,_map:()=>yV,_max:()=>Pr,_maxLength:()=>ws,_maxSize:()=>oi,_mime:()=>Ka,_min:()=>pr,_minLength:()=>co,_minSize:()=>Dn,_multipleOf:()=>ni,_nan:()=>y0,_nanoid:()=>Vf,_nativeEnum:()=>vV,_negative:()=>lm,_never:()=>f0,_nonnegative:()=>dm,_nonoptional:()=>IV,_nonpositive:()=>um,_normalize:()=>Ha,_null:()=>u0,_nullable:()=>EV,_number:()=>Wx,_optional:()=>_V,_overwrite:()=>un,_parse:()=>Pa,_parseAsync:()=>za,_pipe:()=>RV,_positive:()=>cm,_promise:()=>PV,_property:()=>pm,_readonly:()=>$V,_record:()=>gV,_refine:()=>w0,_regex:()=>ja,_safeDecode:()=>_f,_safeDecodeAsync:()=>kf,_safeEncode:()=>xf,_safeEncodeAsync:()=>Ef,_safeParse:()=>Na,_safeParseAsync:()=>Da,_set:()=>bV,_size:()=>vs,_slugify:()=>Ga,_startsWith:()=>qa,_string:()=>Ux,_stringFormat:()=>Qa,_stringbool:()=>k0,_success:()=>AV,_superRefine:()=>x0,_symbol:()=>c0,_templateLiteral:()=>OV,_toLowerCase:()=>Va,_toUpperCase:()=>Wa,_transform:()=>xV,_trim:()=>Ja,_tuple:()=>hV,_uint32:()=>t0,_uint64:()=>a0,_ulid:()=>Qf,_undefined:()=>l0,_union:()=>dV,_unknown:()=>p0,_uppercase:()=>Ua,_url:()=>hu,_uuid:()=>qf,_uuidv4:()=>Ff,_uuidv6:()=>Kf,_uuidv7:()=>Hf,_void:()=>m0,_xid:()=>Yf,_xor:()=>pV,clone:()=>ur,config:()=>gt,createStandardJSONSchemaMethod:()=>Ya,createToJSONSchemaMethod:()=>I0,decode:()=>PH,decodeAsync:()=>NH,describe:()=>_0,encode:()=>CH,encodeAsync:()=>zH,extractDefs:()=>si,finalize:()=>ai,flattenError:()=>eu,formatError:()=>tu,globalConfig:()=>ms,globalRegistry:()=>qt,initializeContext:()=>ii,isValidBase64:()=>Wv,isValidBase64URL:()=>jC,isValidJWT:()=>ZC,locales:()=>pu,meta:()=>E0,parse:()=>gf,parseAsync:()=>yf,prettifyError:()=>TS,process:()=>We,regexes:()=>Cr,registry:()=>Uf,safeDecode:()=>LH,safeDecodeAsync:()=>jH,safeEncode:()=>DH,safeEncodeAsync:()=>BH,safeParse:()=>$S,safeParseAsync:()=>OS,toDotPath:()=>bC,toJSONSchema:()=>gm,treeifyError:()=>AS,util:()=>ue,version:()=>Iv});var zr=v(()=>{ke();Af();Lx();yu();H1();V1();gs();CS();RS();Bw();$f();Av();fu();K1();gu()});var ym={};Lt(ym,{endsWith:()=>Fa,gt:()=>Nn,gte:()=>pr,includes:()=>Ma,length:()=>xs,lowercase:()=>Za,lt:()=>zn,lte:()=>Pr,maxLength:()=>ws,maxSize:()=>oi,mime:()=>Ka,minLength:()=>co,minSize:()=>Dn,multipleOf:()=>ni,negative:()=>lm,nonnegative:()=>dm,nonpositive:()=>um,normalize:()=>Ha,overwrite:()=>un,positive:()=>cm,property:()=>pm,regex:()=>ja,size:()=>vs,slugify:()=>Ga,startsWith:()=>qa,toLowerCase:()=>Va,toUpperCase:()=>Wa,trim:()=>Ja,uppercase:()=>Ua});var bm=v(()=>{zr()});var Xa={};Lt(Xa,{ZodISODate:()=>vm,ZodISODateTime:()=>Sm,ZodISODuration:()=>xm,ZodISOTime:()=>wm,date:()=>p_,datetime:()=>d_,duration:()=>m_,time:()=>f_});function d_(e){return Kx(Sm,e)}function p_(e){return Hx(vm,e)}function f_(e){return Jx(wm,e)}function m_(e){return Vx(xm,e)}var Sm,vm,wm,xm;var bu=v(()=>{zr();vu();Sm=Z("ZodISODateTime",(e,t)=>{Zv.init(e,t),Xe.init(e,t)});vm=Z("ZodISODate",(e,t)=>{Uv.init(e,t),Xe.init(e,t)});wm=Z("ZodISOTime",(e,t)=>{Mv.init(e,t),Xe.init(e,t)});xm=Z("ZodISODuration",(e,t)=>{qv.init(e,t),Xe.init(e,t)})});var W1=(e,t)=>{Xl.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:(r)=>tu(e,r)},flatten:{value:(r)=>eu(e,r)},addIssue:{value:(r)=>{e.issues.push(r),e.message=JSON.stringify(e.issues,$a,2)}},addIssues:{value:(r)=>{e.issues.push(...r),e.message=JSON.stringify(e.issues,$a,2)}},isEmpty:{get(){return e.issues.length===0}}})},G1,_r;var h_=v(()=>{zr();zr();ke();G1=Z("ZodError",W1),_r=Z("ZodError",W1,{Parent:Error})});var g_,y_,b_,S_,v_,w_,x_,__,E_,k_,I_,A_;var T_=v(()=>{zr();h_();g_=Pa(_r),y_=za(_r),b_=Na(_r),S_=Da(_r),v_=bf(_r),w_=Sf(_r),x_=vf(_r),__=wf(_r),E_=xf(_r),k_=_f(_r),I_=Ef(_r),A_=kf(_r)});var Su={};Lt(Su,{ZodAny:()=>D_,ZodArray:()=>Z_,ZodBase64:()=>Bm,ZodBase64URL:()=>jm,ZodBigInt:()=>sc,ZodBigIntFormat:()=>Mm,ZodBoolean:()=>ic,ZodCIDRv4:()=>Dm,ZodCIDRv6:()=>Lm,ZodCUID:()=>Rm,ZodCUID2:()=>$m,ZodCatch:()=>cE,ZodCodec:()=>Cu,ZodCustom:()=>Pu,ZodCustomStringFormat:()=>nc,ZodDate:()=>Au,ZodDefault:()=>rE,ZodDiscriminatedUnion:()=>M_,ZodE164:()=>Zm,ZodEmail:()=>Im,ZodEmoji:()=>Am,ZodEnum:()=>tc,ZodExactOptional:()=>X_,ZodFile:()=>Q_,ZodFunction:()=>bE,ZodGUID:()=>xu,ZodIPv4:()=>zm,ZodIPv6:()=>Nm,ZodIntersection:()=>q_,ZodJWT:()=>Um,ZodKSUID:()=>Pm,ZodLazy:()=>hE,ZodLiteral:()=>G_,ZodMAC:()=>R_,ZodMap:()=>V_,ZodNaN:()=>uE,ZodNanoID:()=>Tm,ZodNever:()=>B_,ZodNonOptional:()=>Vm,ZodNull:()=>z_,ZodNullable:()=>tE,ZodNumber:()=>oc,ZodNumberFormat:()=>Es,ZodObject:()=>Ru,ZodOptional:()=>Jm,ZodPipe:()=>Ou,ZodPrefault:()=>oE,ZodPreprocess:()=>dE,ZodPromise:()=>yE,ZodReadonly:()=>pE,ZodRecord:()=>ec,ZodSet:()=>W_,ZodString:()=>rc,ZodStringFormat:()=>Xe,ZodSuccess:()=>aE,ZodSymbol:()=>C_,ZodTemplateLiteral:()=>mE,ZodTransform:()=>Y_,ZodTuple:()=>K_,ZodType:()=>Be,ZodULID:()=>Om,ZodURL:()=>Iu,ZodUUID:()=>Ln,ZodUndefined:()=>P_,ZodUnion:()=>$u,ZodUnknown:()=>L_,ZodVoid:()=>j_,ZodXID:()=>Cm,ZodXor:()=>U_,_ZodString:()=>km,_default:()=>nE,_function:()=>oz,any:()=>NP,array:()=>Tu,base64:()=>bP,base64url:()=>SP,bigint:()=>$P,boolean:()=>O_,catch:()=>lE,check:()=>iz,cidrv4:()=>gP,cidrv6:()=>yP,codec:()=>ez,cuid:()=>cP,cuid2:()=>lP,custom:()=>sz,date:()=>LP,describe:()=>az,discriminatedUnion:()=>qP,e164:()=>vP,email:()=>Y1,emoji:()=>sP,enum:()=>Km,exactOptional:()=>eE,file:()=>GP,float32:()=>IP,float64:()=>AP,function:()=>oz,guid:()=>X1,hash:()=>kP,hex:()=>EP,hostname:()=>_P,httpUrl:()=>iP,instanceof:()=>lz,int:()=>_m,int32:()=>TP,int64:()=>OP,intersection:()=>F_,invertCodec:()=>tz,ipv4:()=>fP,ipv6:()=>hP,json:()=>dz,jwt:()=>wP,keyof:()=>BP,ksuid:()=>pP,lazy:()=>gE,literal:()=>WP,looseObject:()=>UP,looseRecord:()=>KP,mac:()=>mP,map:()=>HP,meta:()=>cz,nan:()=>XP,nanoid:()=>aP,nativeEnum:()=>VP,never:()=>qm,nonoptional:()=>sE,null:()=>N_,nullable:()=>Eu,nullish:()=>QP,number:()=>$_,object:()=>jP,optional:()=>_u,partialRecord:()=>FP,pipe:()=>Em,prefault:()=>iE,preprocess:()=>pz,promise:()=>nz,readonly:()=>fE,record:()=>J_,refine:()=>SE,set:()=>JP,strictObject:()=>ZP,string:()=>wu,stringFormat:()=>xP,stringbool:()=>uz,success:()=>YP,superRefine:()=>vE,symbol:()=>PP,templateLiteral:()=>rz,transform:()=>Hm,tuple:()=>H_,uint32:()=>RP,uint64:()=>CP,ulid:()=>uP,undefined:()=>zP,union:()=>Fm,unknown:()=>_s,url:()=>oP,uuid:()=>eP,uuidv4:()=>tP,uuidv6:()=>rP,uuidv7:()=>nP,void:()=>DP,xid:()=>dP,xor:()=>MP});function ku(e,t,r){let o=Object.getPrototypeOf(e),n=Q1.get(o);if(!n)n=new Set,Q1.set(o,n);if(n.has(t))return;n.add(t);for(let i in r){let s=r[i];Object.defineProperty(o,i,{configurable:!0,enumerable:!1,get(){let a=s.bind(this);return Object.defineProperty(this,i,{configurable:!0,writable:!0,enumerable:!0,value:a}),a},set(a){Object.defineProperty(this,i,{configurable:!0,writable:!0,enumerable:!0,value:a})}})}}function wu(e){return Ux(rc,e)}function Y1(e){return Mf(Im,e)}function X1(e){return mu(xu,e)}function eP(e){return qf(Ln,e)}function tP(e){return Ff(Ln,e)}function rP(e){return Kf(Ln,e)}function nP(e){return Hf(Ln,e)}function oP(e){return hu(Iu,e)}function iP(e){return hu(Iu,{protocol:Cr.httpProtocol,hostname:Cr.domain,...ue.normalizeParams(e)})}function sP(e){return Jf(Am,e)}function aP(e){return Vf(Tm,e)}function cP(e){return Wf(Rm,e)}function lP(e){return Gf($m,e)}function uP(e){return Qf(Om,e)}function dP(e){return Yf(Cm,e)}function pP(e){return Xf(Pm,e)}function fP(e){return em(zm,e)}function mP(e){return qx(R_,e)}function hP(e){return tm(Nm,e)}function gP(e){return rm(Dm,e)}function yP(e){return nm(Lm,e)}function bP(e){return om(Bm,e)}function SP(e){return im(jm,e)}function vP(e){return sm(Zm,e)}function wP(e){return am(Um,e)}function xP(e,t,r={}){return Qa(nc,e,t,r)}function _P(e){return Qa(nc,"hostname",Cr.hostname,e)}function EP(e){return Qa(nc,"hex",Cr.hex,e)}function kP(e,t){let r=t?.enc??"hex",o=`${e}_${r}`,n=Cr[o];if(!n)throw Error(`Unrecognized hash format: ${o}`);return Qa(nc,o,n,t)}function $_(e){return Wx(oc,e)}function _m(e){return Qx(Es,e)}function IP(e){return Yx(Es,e)}function AP(e){return Xx(Es,e)}function TP(e){return e0(Es,e)}function RP(e){return t0(Es,e)}function O_(e){return r0(ic,e)}function $P(e){return o0(sc,e)}function OP(e){return s0(Mm,e)}function CP(e){return a0(Mm,e)}function PP(e){return c0(C_,e)}function zP(e){return l0(P_,e)}function N_(e){return u0(z_,e)}function NP(){return d0(D_)}function _s(){return p0(L_)}function qm(e){return f0(B_,e)}function DP(e){return m0(j_,e)}function LP(e){return h0(Au,e)}function Tu(e,t){return b0(Z_,e,t)}function BP(e){let t=e._zod.def.shape;return Km(Object.keys(t))}function jP(e,t){let r={type:"object",shape:e??{},...ue.normalizeParams(t)};return new Ru(r)}function ZP(e,t){return new Ru({type:"object",shape:e,catchall:qm(),...ue.normalizeParams(t)})}function UP(e,t){return new Ru({type:"object",shape:e,catchall:_s(),...ue.normalizeParams(t)})}function Fm(e,t){return new $u({type:"union",options:e,...ue.normalizeParams(t)})}function MP(e,t){return new U_({type:"union",options:e,inclusive:!1,...ue.normalizeParams(t)})}function qP(e,t,r){return new M_({type:"union",options:t,discriminator:e,...ue.normalizeParams(r)})}function F_(e,t){return new q_({type:"intersection",left:e,right:t})}function H_(e,t,r){let o=t instanceof Ne,n=o?r:t;return new K_({type:"tuple",items:e,rest:o?t:null,...ue.normalizeParams(n)})}function J_(e,t,r){if(!t||!t._zod)return new ec({type:"record",keyType:wu(),valueType:e,...ue.normalizeParams(t)});return new ec({type:"record",keyType:e,valueType:t,...ue.normalizeParams(r)})}function FP(e,t,r){let o=ur(e);return o._zod.values=void 0,new ec({type:"record",keyType:o,valueType:t,...ue.normalizeParams(r)})}function KP(e,t,r){return new ec({type:"record",keyType:e,valueType:t,mode:"loose",...ue.normalizeParams(r)})}function HP(e,t,r){return new V_({type:"map",keyType:e,valueType:t,...ue.normalizeParams(r)})}function JP(e,t){return new W_({type:"set",valueType:e,...ue.normalizeParams(t)})}function Km(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map((o)=>[o,o])):e;return new tc({type:"enum",entries:r,...ue.normalizeParams(t)})}function VP(e,t){return new tc({type:"enum",entries:e,...ue.normalizeParams(t)})}function WP(e,t){return new G_({type:"literal",values:Array.isArray(e)?e:[e],...ue.normalizeParams(t)})}function GP(e){return S0(Q_,e)}function Hm(e){return new Y_({type:"transform",transform:e})}function _u(e){return new Jm({type:"optional",innerType:e})}function eE(e){return new X_({type:"optional",innerType:e})}function Eu(e){return new tE({type:"nullable",innerType:e})}function QP(e){return _u(Eu(e))}function nE(e,t){return new rE({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():ue.shallowClone(t)}})}function iE(e,t){return new oE({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():ue.shallowClone(t)}})}function sE(e,t){return new Vm({type:"nonoptional",innerType:e,...ue.normalizeParams(t)})}function YP(e){return new aE({type:"success",innerType:e})}function lE(e,t){return new cE({type:"catch",innerType:e,catchValue:typeof t==="function"?t:()=>t})}function XP(e){return y0(uE,e)}function Em(e,t){return new Ou({type:"pipe",in:e,out:t})}function ez(e,t,r){return new Cu({type:"pipe",in:e,out:t,transform:r.decode,reverseTransform:r.encode})}function tz(e){let t=e._zod.def;return new Cu({type:"pipe",in:t.out,out:t.in,transform:t.reverseTransform,reverseTransform:t.transform})}function fE(e){return new pE({type:"readonly",innerType:e})}function rz(e,t){return new mE({type:"template_literal",parts:e,...ue.normalizeParams(t)})}function gE(e){return new hE({type:"lazy",getter:e})}function nz(e){return new yE({type:"promise",innerType:e})}function oz(e){return new bE({type:"function",input:Array.isArray(e?.input)?H_(e?.input):e?.input??Tu(_s()),output:e?.output??_s()})}function iz(e){let t=new rt({check:"custom"});return t._zod.check=e,t}function sz(e,t){return v0(Pu,e??(()=>!0),t)}function SE(e,t={}){return w0(Pu,e,t)}function vE(e,t){return x0(e,t)}function lz(e,t={}){let r=new Pu({type:"custom",check:"custom",fn:(o)=>o instanceof e,abort:!0,...ue.normalizeParams(t)});return r._zod.bag.Class=e,r._zod.check=(o)=>{if(!(o.value instanceof e))o.issues.push({code:"invalid_type",expected:e.name,input:o.value,inst:r,path:[...r._zod.def.path??[]]})},r}function dz(e){let t=gE(()=>Fm([wu(e),$_(),O_(),N_(),Tu(t),J_(wu(),t)]));return t}function pz(e,t){return new dE({type:"pipe",in:Hm(e),out:t})}var Q1,Be,km,rc,Xe,Im,xu,Ln,Iu,Am,Tm,Rm,$m,Om,Cm,Pm,zm,R_,Nm,Dm,Lm,Bm,jm,Zm,Um,nc,oc,Es,ic,sc,Mm,C_,P_,z_,D_,L_,B_,j_,Au,Z_,Ru,$u,U_,M_,q_,K_,ec,V_,W_,tc,G_,Q_,Y_,Jm,X_,tE,rE,oE,Vm,aE,cE,uE,Ou,Cu,dE,pE,mE,hE,yE,bE,Pu,az,cz,uz=(...e)=>k0({Codec:Cu,Boolean:ic,String:rc},...e);var vu=v(()=>{zr();zr();yu();gu();bm();bu();T_();Q1=new WeakMap;Be=Z("ZodType",(e,t)=>(Ne.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Ya(e,"input"),output:Ya(e,"output")}}),e.toJSONSchema=I0(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(r,o)=>g_(e,r,o,{callee:e.parse}),e.safeParse=(r,o)=>b_(e,r,o),e.parseAsync=async(r,o)=>y_(e,r,o,{callee:e.parseAsync}),e.safeParseAsync=async(r,o)=>S_(e,r,o),e.spa=e.safeParseAsync,e.encode=(r,o)=>v_(e,r,o),e.decode=(r,o)=>w_(e,r,o),e.encodeAsync=async(r,o)=>x_(e,r,o),e.decodeAsync=async(r,o)=>__(e,r,o),e.safeEncode=(r,o)=>E_(e,r,o),e.safeDecode=(r,o)=>k_(e,r,o),e.safeEncodeAsync=async(r,o)=>I_(e,r,o),e.safeDecodeAsync=async(r,o)=>A_(e,r,o),ku(e,"ZodType",{check(...r){let o=this.def;return this.clone(ue.mergeDefs(o,{checks:[...o.checks??[],...r.map((n)=>typeof n==="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0})},with(...r){return this.check(...r)},clone(r,o){return ur(this,r,o)},brand(){return this},register(r,o){return r.add(this,o),this},refine(r,o){return this.check(SE(r,o))},superRefine(r,o){return this.check(vE(r,o))},overwrite(r){return this.check(un(r))},optional(){return _u(this)},exactOptional(){return eE(this)},nullable(){return Eu(this)},nullish(){return _u(Eu(this))},nonoptional(r){return sE(this,r)},array(){return Tu(this)},or(r){return Fm([this,r])},and(r){return F_(this,r)},transform(r){return Em(this,Hm(r))},default(r){return nE(this,r)},prefault(r){return iE(this,r)},catch(r){return lE(this,r)},pipe(r){return Em(this,r)},readonly(){return fE(this)},describe(r){let o=this.clone();return qt.add(o,{description:r}),o},meta(...r){if(r.length===0)return qt.get(this);let o=this.clone();return qt.add(o,r[0]),o},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(r){return r(this)}}),Object.defineProperty(e,"description",{get(){return qt.get(e)?.description},configurable:!0}),e)),km=Z("_ZodString",(e,t)=>{Ss.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(o,n,i)=>A0(e,o,n,i);let r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,ku(e,"_ZodString",{regex(...o){return this.check(ja(...o))},includes(...o){return this.check(Ma(...o))},startsWith(...o){return this.check(qa(...o))},endsWith(...o){return this.check(Fa(...o))},min(...o){return this.check(co(...o))},max(...o){return this.check(ws(...o))},length(...o){return this.check(xs(...o))},nonempty(...o){return this.check(co(1,...o))},lowercase(o){return this.check(Za(o))},uppercase(o){return this.check(Ua(o))},trim(){return this.check(Ja())},normalize(...o){return this.check(Ha(...o))},toLowerCase(){return this.check(Va())},toUpperCase(){return this.check(Wa())},slugify(){return this.check(Ga())}})}),rc=Z("ZodString",(e,t)=>{Ss.init(e,t),km.init(e,t),e.email=(r)=>e.check(Mf(Im,r)),e.url=(r)=>e.check(hu(Iu,r)),e.jwt=(r)=>e.check(am(Um,r)),e.emoji=(r)=>e.check(Jf(Am,r)),e.guid=(r)=>e.check(mu(xu,r)),e.uuid=(r)=>e.check(qf(Ln,r)),e.uuidv4=(r)=>e.check(Ff(Ln,r)),e.uuidv6=(r)=>e.check(Kf(Ln,r)),e.uuidv7=(r)=>e.check(Hf(Ln,r)),e.nanoid=(r)=>e.check(Vf(Tm,r)),e.guid=(r)=>e.check(mu(xu,r)),e.cuid=(r)=>e.check(Wf(Rm,r)),e.cuid2=(r)=>e.check(Gf($m,r)),e.ulid=(r)=>e.check(Qf(Om,r)),e.base64=(r)=>e.check(om(Bm,r)),e.base64url=(r)=>e.check(im(jm,r)),e.xid=(r)=>e.check(Yf(Cm,r)),e.ksuid=(r)=>e.check(Xf(Pm,r)),e.ipv4=(r)=>e.check(em(zm,r)),e.ipv6=(r)=>e.check(tm(Nm,r)),e.cidrv4=(r)=>e.check(rm(Dm,r)),e.cidrv6=(r)=>e.check(nm(Lm,r)),e.e164=(r)=>e.check(sm(Zm,r)),e.datetime=(r)=>e.check(d_(r)),e.date=(r)=>e.check(p_(r)),e.time=(r)=>e.check(f_(r)),e.duration=(r)=>e.check(m_(r))});Xe=Z("ZodStringFormat",(e,t)=>{Ye.init(e,t),km.init(e,t)}),Im=Z("ZodEmail",(e,t)=>{Ov.init(e,t),Xe.init(e,t)});xu=Z("ZodGUID",(e,t)=>{Rv.init(e,t),Xe.init(e,t)});Ln=Z("ZodUUID",(e,t)=>{$v.init(e,t),Xe.init(e,t)});Iu=Z("ZodURL",(e,t)=>{Cv.init(e,t),Xe.init(e,t)});Am=Z("ZodEmoji",(e,t)=>{Pv.init(e,t),Xe.init(e,t)});Tm=Z("ZodNanoID",(e,t)=>{zv.init(e,t),Xe.init(e,t)});Rm=Z("ZodCUID",(e,t)=>{Nv.init(e,t),Xe.init(e,t)});$m=Z("ZodCUID2",(e,t)=>{Dv.init(e,t),Xe.init(e,t)});Om=Z("ZodULID",(e,t)=>{Lv.init(e,t),Xe.init(e,t)});Cm=Z("ZodXID",(e,t)=>{Bv.init(e,t),Xe.init(e,t)});Pm=Z("ZodKSUID",(e,t)=>{jv.init(e,t),Xe.init(e,t)});zm=Z("ZodIPv4",(e,t)=>{Fv.init(e,t),Xe.init(e,t)});R_=Z("ZodMAC",(e,t)=>{Hv.init(e,t),Xe.init(e,t)});Nm=Z("ZodIPv6",(e,t)=>{Kv.init(e,t),Xe.init(e,t)});Dm=Z("ZodCIDRv4",(e,t)=>{Jv.init(e,t),Xe.init(e,t)});Lm=Z("ZodCIDRv6",(e,t)=>{Vv.init(e,t),Xe.init(e,t)});Bm=Z("ZodBase64",(e,t)=>{Gv.init(e,t),Xe.init(e,t)});jm=Z("ZodBase64URL",(e,t)=>{Qv.init(e,t),Xe.init(e,t)});Zm=Z("ZodE164",(e,t)=>{Yv.init(e,t),Xe.init(e,t)});Um=Z("ZodJWT",(e,t)=>{Xv.init(e,t),Xe.init(e,t)});nc=Z("ZodCustomStringFormat",(e,t)=>{ew.init(e,t),Xe.init(e,t)});oc=Z("ZodNumber",(e,t)=>{Df.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(o,n,i)=>T0(e,o,n,i),ku(e,"ZodNumber",{gt(o,n){return this.check(Nn(o,n))},gte(o,n){return this.check(pr(o,n))},min(o,n){return this.check(pr(o,n))},lt(o,n){return this.check(zn(o,n))},lte(o,n){return this.check(Pr(o,n))},max(o,n){return this.check(Pr(o,n))},int(o){return this.check(_m(o))},safe(o){return this.check(_m(o))},positive(o){return this.check(Nn(0,o))},nonnegative(o){return this.check(pr(0,o))},negative(o){return this.check(zn(0,o))},nonpositive(o){return this.check(Pr(0,o))},multipleOf(o,n){return this.check(ni(o,n))},step(o,n){return this.check(ni(o,n))},finite(){return this}});let r=e._zod.bag;e.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??0.5),e.isFinite=!0,e.format=r.format??null});Es=Z("ZodNumberFormat",(e,t)=>{tw.init(e,t),oc.init(e,t)});ic=Z("ZodBoolean",(e,t)=>{iu.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>R0(e,r,o,n)});sc=Z("ZodBigInt",(e,t)=>{Lf.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(o,n,i)=>$0(e,o,n,i),e.gte=(o,n)=>e.check(pr(o,n)),e.min=(o,n)=>e.check(pr(o,n)),e.gt=(o,n)=>e.check(Nn(o,n)),e.gte=(o,n)=>e.check(pr(o,n)),e.min=(o,n)=>e.check(pr(o,n)),e.lt=(o,n)=>e.check(zn(o,n)),e.lte=(o,n)=>e.check(Pr(o,n)),e.max=(o,n)=>e.check(Pr(o,n)),e.positive=(o)=>e.check(Nn(BigInt(0),o)),e.negative=(o)=>e.check(zn(BigInt(0),o)),e.nonpositive=(o)=>e.check(Pr(BigInt(0),o)),e.nonnegative=(o)=>e.check(pr(BigInt(0),o)),e.multipleOf=(o,n)=>e.check(ni(o,n));let r=e._zod.bag;e.minValue=r.minimum??null,e.maxValue=r.maximum??null,e.format=r.format??null});Mm=Z("ZodBigIntFormat",(e,t)=>{rw.init(e,t),sc.init(e,t)});C_=Z("ZodSymbol",(e,t)=>{nw.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>O0(e,r,o,n)});P_=Z("ZodUndefined",(e,t)=>{ow.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>P0(e,r,o,n)});z_=Z("ZodNull",(e,t)=>{iw.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>C0(e,r,o,n)});D_=Z("ZodAny",(e,t)=>{sw.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>D0(e,r,o,n)});L_=Z("ZodUnknown",(e,t)=>{aw.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>L0(e,r,o,n)});B_=Z("ZodNever",(e,t)=>{cw.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>N0(e,r,o,n)});j_=Z("ZodVoid",(e,t)=>{lw.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>z0(e,r,o,n)});Au=Z("ZodDate",(e,t)=>{uw.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(o,n,i)=>B0(e,o,n,i),e.min=(o,n)=>e.check(pr(o,n)),e.max=(o,n)=>e.check(Pr(o,n));let r=e._zod.bag;e.minDate=r.minimum?new Date(r.minimum):null,e.maxDate=r.maximum?new Date(r.maximum):null});Z_=Z("ZodArray",(e,t)=>{dw.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>G0(e,r,o,n),e.element=t.element,ku(e,"ZodArray",{min(r,o){return this.check(co(r,o))},nonempty(r){return this.check(co(1,r))},max(r,o){return this.check(ws(r,o))},length(r,o){return this.check(xs(r,o))},unwrap(){return this.element}})});Ru=Z("ZodObject",(e,t)=>{pw.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Q0(e,r,o,n),ue.defineLazy(e,"shape",()=>t.shape),ku(e,"ZodObject",{keyof(){return Km(Object.keys(this._zod.def.shape))},catchall(r){return this.clone({...this._zod.def,catchall:r})},passthrough(){return this.clone({...this._zod.def,catchall:_s()})},loose(){return this.clone({...this._zod.def,catchall:_s()})},strict(){return this.clone({...this._zod.def,catchall:qm()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(r){return ue.extend(this,r)},safeExtend(r){return ue.safeExtend(this,r)},merge(r){return ue.merge(this,r)},pick(r){return ue.pick(this,r)},omit(r){return ue.omit(this,r)},partial(...r){return ue.partial(Jm,this,r[0])},required(...r){return ue.required(Vm,this,r[0])}})});$u=Z("ZodUnion",(e,t)=>{su.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>mm(e,r,o,n),e.options=t.options});U_=Z("ZodXor",(e,t)=>{$u.init(e,t),fw.init(e,t),e._zod.processJSONSchema=(r,o,n)=>mm(e,r,o,n),e.options=t.options});M_=Z("ZodDiscriminatedUnion",(e,t)=>{$u.init(e,t),mw.init(e,t)});q_=Z("ZodIntersection",(e,t)=>{hw.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Y0(e,r,o,n)});K_=Z("ZodTuple",(e,t)=>{Bf.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>X0(e,r,o,n),e.rest=(r)=>e.clone({...e._zod.def,rest:r})});ec=Z("ZodRecord",(e,t)=>{gw.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>e_(e,r,o,n),e.keyType=t.keyType,e.valueType=t.valueType});V_=Z("ZodMap",(e,t)=>{yw.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>V0(e,r,o,n),e.keyType=t.keyType,e.valueType=t.valueType,e.min=(...r)=>e.check(Dn(...r)),e.nonempty=(r)=>e.check(Dn(1,r)),e.max=(...r)=>e.check(oi(...r)),e.size=(...r)=>e.check(vs(...r))});W_=Z("ZodSet",(e,t)=>{bw.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>W0(e,r,o,n),e.min=(...r)=>e.check(Dn(...r)),e.nonempty=(r)=>e.check(Dn(1,r)),e.max=(...r)=>e.check(oi(...r)),e.size=(...r)=>e.check(vs(...r))});tc=Z("ZodEnum",(e,t)=>{Sw.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(o,n,i)=>j0(e,o,n,i),e.enum=t.entries,e.options=Object.values(t.entries);let r=new Set(Object.keys(t.entries));e.extract=(o,n)=>{let i={};for(let s of o)if(r.has(s))i[s]=t.entries[s];else throw Error(`Key ${s} not found in enum`);return new tc({...t,checks:[],...ue.normalizeParams(n),entries:i})},e.exclude=(o,n)=>{let i={...t.entries};for(let s of o)if(r.has(s))delete i[s];else throw Error(`Key ${s} not found in enum`);return new tc({...t,checks:[],...ue.normalizeParams(n),entries:i})}});G_=Z("ZodLiteral",(e,t)=>{vw.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Z0(e,r,o,n),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});Q_=Z("ZodFile",(e,t)=>{ww.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>q0(e,r,o,n),e.min=(r,o)=>e.check(Dn(r,o)),e.max=(r,o)=>e.check(oi(r,o)),e.mime=(r,o)=>e.check(Ka(Array.isArray(r)?r:[r],o))});Y_=Z("ZodTransform",(e,t)=>{xw.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>J0(e,r,o,n),e._zod.parse=(r,o)=>{if(o.direction==="backward")throw new hs(e.constructor.name);r.addIssue=(i)=>{if(typeof i==="string")r.issues.push(ue.issue(i,r.value,t));else{let s=i;if(s.fatal)s.continue=!1;s.code??(s.code="custom"),s.input??(s.input=r.value),s.inst??(s.inst=e),r.issues.push(ue.issue(s))}};let n=t.transform(r.value,r);if(n instanceof Promise)return n.then((i)=>(r.value=i,r.fallback=!0,r));return r.value=n,r.fallback=!0,r}});Jm=Z("ZodOptional",(e,t)=>{jf.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>hm(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});X_=Z("ZodExactOptional",(e,t)=>{_w.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>hm(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});tE=Z("ZodNullable",(e,t)=>{Ew.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>t_(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});rE=Z("ZodDefault",(e,t)=>{kw.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>n_(e,r,o,n),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});oE=Z("ZodPrefault",(e,t)=>{Iw.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>o_(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});Vm=Z("ZodNonOptional",(e,t)=>{Aw.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>r_(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});aE=Z("ZodSuccess",(e,t)=>{Tw.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>F0(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});cE=Z("ZodCatch",(e,t)=>{Rw.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>i_(e,r,o,n),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});uE=Z("ZodNaN",(e,t)=>{$w.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>U0(e,r,o,n)});Ou=Z("ZodPipe",(e,t)=>{Zf.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>s_(e,r,o,n),e.in=t.in,e.out=t.out});Cu=Z("ZodCodec",(e,t)=>{Ou.init(e,t),au.init(e,t)});dE=Z("ZodPreprocess",(e,t)=>{Ou.init(e,t),Ow.init(e,t)}),pE=Z("ZodReadonly",(e,t)=>{Cw.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>a_(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});mE=Z("ZodTemplateLiteral",(e,t)=>{Pw.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>M0(e,r,o,n)});hE=Z("ZodLazy",(e,t)=>{Dw.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>l_(e,r,o,n),e.unwrap=()=>e._zod.def.getter()});yE=Z("ZodPromise",(e,t)=>{Nw.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>c_(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});bE=Z("ZodFunction",(e,t)=>{zw.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>H0(e,r,o,n)});Pu=Z("ZodCustom",(e,t)=>{Lw.init(e,t),Be.init(e,t),e._zod.processJSONSchema=(r,o,n)=>K0(e,r,o,n)});az=_0,cz=E0});function BV(e){gt({customError:e})}function jV(){return gt().customError}var LV,wE;var fz=v(()=>{zr();LV={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};(function(e){})(wE||(wE={}))});function UV(e,t){let r=e.$schema;if(r==="https://json-schema.org/draft/2020-12/schema")return"draft-2020-12";if(r==="http://json-schema.org/draft-07/schema#")return"draft-7";if(r==="http://json-schema.org/draft-04/schema#")return"draft-4";return t??"draft-2020-12"}function MV(e,t){if(!e.startsWith("#"))throw Error("External $ref is not supported, only local refs (#/...) are allowed");let r=e.slice(1).split("/").filter(Boolean);if(r.length===0)return t.rootSchema;let o=t.version==="draft-2020-12"?"$defs":"definitions";if(r[0]===o){let n=r[1];if(!n||!t.defs[n])throw Error(`Reference not found: ${e}`);return t.defs[n]}throw Error(`Reference not found: ${e}`)}function mz(e,t){if(e.not!==void 0){if(typeof e.not==="object"&&Object.keys(e.not).length===0)return Se.never();throw Error("not is not supported in Zod (except { not: {} } for never)")}if(e.unevaluatedItems!==void 0)throw Error("unevaluatedItems is not supported");if(e.unevaluatedProperties!==void 0)throw Error("unevaluatedProperties is not supported");if(e.if!==void 0||e.then!==void 0||e.else!==void 0)throw Error("Conditional schemas (if/then/else) are not supported");if(e.dependentSchemas!==void 0||e.dependentRequired!==void 0)throw Error("dependentSchemas and dependentRequired are not supported");if(e.$ref){let n=e.$ref;if(t.refs.has(n))return t.refs.get(n);if(t.processing.has(n))return Se.lazy(()=>{if(!t.refs.has(n))throw Error(`Circular reference not resolved: ${n}`);return t.refs.get(n)});t.processing.add(n);let i=MV(n,t),s=er(i,t);return t.refs.set(n,s),t.processing.delete(n),s}if(e.enum!==void 0){let n=e.enum;if(t.version==="openapi-3.0"&&e.nullable===!0&&n.length===1&&n[0]===null)return Se.null();if(n.length===0)return Se.never();if(n.length===1)return Se.literal(n[0]);if(n.every((s)=>typeof s==="string"))return Se.enum(n);let i=n.map((s)=>Se.literal(s));if(i.length<2)return i[0];return Se.union([i[0],i[1],...i.slice(2)])}if(e.const!==void 0)return Se.literal(e.const);let r=e.type;if(Array.isArray(r)){let n=r.map((i)=>{let s={...e,type:i};return mz(s,t)});if(n.length===0)return Se.never();if(n.length===1)return n[0];return Se.union(n)}if(!r)return Se.any();let o;switch(r){case"string":{let n=Se.string();if(e.format){let i=e.format;if(i==="email")n=n.check(Se.email());else if(i==="uri"||i==="uri-reference")n=n.check(Se.url());else if(i==="uuid"||i==="guid")n=n.check(Se.uuid());else if(i==="date-time")n=n.check(Se.iso.datetime());else if(i==="date")n=n.check(Se.iso.date());else if(i==="time")n=n.check(Se.iso.time());else if(i==="duration")n=n.check(Se.iso.duration());else if(i==="ipv4")n=n.check(Se.ipv4());else if(i==="ipv6")n=n.check(Se.ipv6());else if(i==="mac")n=n.check(Se.mac());else if(i==="cidr")n=n.check(Se.cidrv4());else if(i==="cidr-v6")n=n.check(Se.cidrv6());else if(i==="base64")n=n.check(Se.base64());else if(i==="base64url")n=n.check(Se.base64url());else if(i==="e164")n=n.check(Se.e164());else if(i==="jwt")n=n.check(Se.jwt());else if(i==="emoji")n=n.check(Se.emoji());else if(i==="nanoid")n=n.check(Se.nanoid());else if(i==="cuid")n=n.check(Se.cuid());else if(i==="cuid2")n=n.check(Se.cuid2());else if(i==="ulid")n=n.check(Se.ulid());else if(i==="xid")n=n.check(Se.xid());else if(i==="ksuid")n=n.check(Se.ksuid())}if(typeof e.minLength==="number")n=n.min(e.minLength);if(typeof e.maxLength==="number")n=n.max(e.maxLength);if(e.pattern)n=n.regex(new RegExp(e.pattern));o=n;break}case"number":case"integer":{let n=r==="integer"?Se.number().int():Se.number();if(typeof e.minimum==="number")n=n.min(e.minimum);if(typeof e.maximum==="number")n=n.max(e.maximum);if(typeof e.exclusiveMinimum==="number")n=n.gt(e.exclusiveMinimum);else if(e.exclusiveMinimum===!0&&typeof e.minimum==="number")n=n.gt(e.minimum);if(typeof e.exclusiveMaximum==="number")n=n.lt(e.exclusiveMaximum);else if(e.exclusiveMaximum===!0&&typeof e.maximum==="number")n=n.lt(e.maximum);if(typeof e.multipleOf==="number")n=n.multipleOf(e.multipleOf);o=n;break}case"boolean":{o=Se.boolean();break}case"null":{o=Se.null();break}case"object":{let n={},i=e.properties||{},s=new Set(e.required||[]);for(let[c,u]of Object.entries(i)){let d=er(u,t);n[c]=s.has(c)?d:d.optional()}if(e.propertyNames){let c=er(e.propertyNames,t),u=e.additionalProperties&&typeof e.additionalProperties==="object"?er(e.additionalProperties,t):Se.any();if(Object.keys(n).length===0){o=Se.record(c,u);break}let d=Se.object(n).passthrough(),p=Se.looseRecord(c,u);o=Se.intersection(d,p);break}if(e.patternProperties){let c=e.patternProperties,u=Object.keys(c),d=[];for(let m of u){let h=er(c[m],t),b=Se.string().regex(new RegExp(m));d.push(Se.looseRecord(b,h))}let p=[];if(Object.keys(n).length>0)p.push(Se.object(n).passthrough());if(p.push(...d),p.length===0)o=Se.object({}).passthrough();else if(p.length===1)o=p[0];else{let m=Se.intersection(p[0],p[1]);for(let h=2;h<p.length;h++)m=Se.intersection(m,p[h]);o=m}break}let a=Se.object(n);if(e.additionalProperties===!1)o=a.strict();else if(typeof e.additionalProperties==="object")o=a.catchall(er(e.additionalProperties,t));else o=a.passthrough();break}case"array":{let{prefixItems:n,items:i}=e;if(n&&Array.isArray(n)){let s=n.map((c)=>er(c,t)),a=i&&typeof i==="object"&&!Array.isArray(i)?er(i,t):void 0;if(a)o=Se.tuple(s).rest(a);else o=Se.tuple(s);if(typeof e.minItems==="number")o=o.check(Se.minLength(e.minItems));if(typeof e.maxItems==="number")o=o.check(Se.maxLength(e.maxItems))}else if(Array.isArray(i)){let s=i.map((c)=>er(c,t)),a=e.additionalItems&&typeof e.additionalItems==="object"?er(e.additionalItems,t):void 0;if(a)o=Se.tuple(s).rest(a);else o=Se.tuple(s);if(typeof e.minItems==="number")o=o.check(Se.minLength(e.minItems));if(typeof e.maxItems==="number")o=o.check(Se.maxLength(e.maxItems))}else if(i!==void 0){let s=er(i,t),a=Se.array(s);if(typeof e.minItems==="number")a=a.min(e.minItems);if(typeof e.maxItems==="number")a=a.max(e.maxItems);o=a}else o=Se.array(Se.any());break}default:throw Error(`Unsupported type: ${r}`)}return o}function er(e,t){if(typeof e==="boolean")return e?Se.any():Se.never();let r=mz(e,t),o=e.type||e.enum!==void 0||e.const!==void 0;if(e.anyOf&&Array.isArray(e.anyOf)){let a=e.anyOf.map((u)=>er(u,t)),c=Se.union(a);r=o?Se.intersection(r,c):c}if(e.oneOf&&Array.isArray(e.oneOf)){let a=e.oneOf.map((u)=>er(u,t)),c=Se.xor(a);r=o?Se.intersection(r,c):c}if(e.allOf&&Array.isArray(e.allOf))if(e.allOf.length===0)r=o?r:Se.any();else{let a=o?r:er(e.allOf[0],t),c=o?0:1;for(let u=c;u<e.allOf.length;u++)a=Se.intersection(a,er(e.allOf[u],t));r=a}if(e.nullable===!0&&t.version==="openapi-3.0")r=Se.nullable(r);if(e.readOnly===!0)r=Se.readonly(r);if(e.default!==void 0)r=r.default(e.default);let n={},i=["$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor"];for(let a of i)if(a in e)n[a]=e[a];let s=["contentEncoding","contentMediaType","contentSchema"];for(let a of s)if(a in e)n[a]=e[a];for(let a of Object.keys(e))if(!ZV.has(a))n[a]=e[a];if(Object.keys(n).length>0)t.registry.add(r,n);if(e.description)r=r.describe(e.description);return r}function hz(e,t){if(typeof e==="boolean")return e?Se.any():Se.never();let r;try{r=JSON.parse(JSON.stringify(e))}catch{throw Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas")}let o=UV(r,t?.defaultTarget),n=r.$defs||r.definitions||{},i={version:o,defs:n,refs:new Map,processing:new Set,rootSchema:r,registry:t?.registry??qt};return er(r,i)}var Se,ZV;var gz=v(()=>{fu();bm();bu();vu();Se={...Su,...ym,iso:Xa},ZV=new Set(["$schema","$ref","$defs","definitions","$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor","type","enum","const","anyOf","oneOf","allOf","not","properties","required","additionalProperties","patternProperties","propertyNames","minProperties","maxProperties","items","prefixItems","additionalItems","minItems","maxItems","uniqueItems","contains","minContains","maxContains","minLength","maxLength","pattern","format","minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","description","default","contentEncoding","contentMediaType","contentSchema","unevaluatedItems","unevaluatedProperties","if","then","else","dependentSchemas","dependentRequired","nullable","readOnly"])});var xE={};Lt(xE,{bigint:()=>HV,boolean:()=>KV,date:()=>JV,number:()=>FV,string:()=>qV});function qV(e){return Mx(rc,e)}function FV(e){return Gx(oc,e)}function KV(e){return n0(ic,e)}function HV(e){return i0(sc,e)}function JV(e){return g0(Au,e)}var yz=v(()=>{zr();vu()});var l={};Lt(l,{$brand:()=>gS,$input:()=>jx,$output:()=>Bx,NEVER:()=>hS,TimePrecision:()=>Fx,ZodAny:()=>D_,ZodArray:()=>Z_,ZodBase64:()=>Bm,ZodBase64URL:()=>jm,ZodBigInt:()=>sc,ZodBigIntFormat:()=>Mm,ZodBoolean:()=>ic,ZodCIDRv4:()=>Dm,ZodCIDRv6:()=>Lm,ZodCUID:()=>Rm,ZodCUID2:()=>$m,ZodCatch:()=>cE,ZodCodec:()=>Cu,ZodCustom:()=>Pu,ZodCustomStringFormat:()=>nc,ZodDate:()=>Au,ZodDefault:()=>rE,ZodDiscriminatedUnion:()=>M_,ZodE164:()=>Zm,ZodEmail:()=>Im,ZodEmoji:()=>Am,ZodEnum:()=>tc,ZodError:()=>G1,ZodExactOptional:()=>X_,ZodFile:()=>Q_,ZodFirstPartyTypeKind:()=>wE,ZodFunction:()=>bE,ZodGUID:()=>xu,ZodIPv4:()=>zm,ZodIPv6:()=>Nm,ZodISODate:()=>vm,ZodISODateTime:()=>Sm,ZodISODuration:()=>xm,ZodISOTime:()=>wm,ZodIntersection:()=>q_,ZodIssueCode:()=>LV,ZodJWT:()=>Um,ZodKSUID:()=>Pm,ZodLazy:()=>hE,ZodLiteral:()=>G_,ZodMAC:()=>R_,ZodMap:()=>V_,ZodNaN:()=>uE,ZodNanoID:()=>Tm,ZodNever:()=>B_,ZodNonOptional:()=>Vm,ZodNull:()=>z_,ZodNullable:()=>tE,ZodNumber:()=>oc,ZodNumberFormat:()=>Es,ZodObject:()=>Ru,ZodOptional:()=>Jm,ZodPipe:()=>Ou,ZodPrefault:()=>oE,ZodPreprocess:()=>dE,ZodPromise:()=>yE,ZodReadonly:()=>pE,ZodRealError:()=>_r,ZodRecord:()=>ec,ZodSet:()=>W_,ZodString:()=>rc,ZodStringFormat:()=>Xe,ZodSuccess:()=>aE,ZodSymbol:()=>C_,ZodTemplateLiteral:()=>mE,ZodTransform:()=>Y_,ZodTuple:()=>K_,ZodType:()=>Be,ZodULID:()=>Om,ZodURL:()=>Iu,ZodUUID:()=>Ln,ZodUndefined:()=>P_,ZodUnion:()=>$u,ZodUnknown:()=>L_,ZodVoid:()=>j_,ZodXID:()=>Cm,ZodXor:()=>U_,_ZodString:()=>km,_default:()=>nE,_function:()=>oz,any:()=>NP,array:()=>Tu,base64:()=>bP,base64url:()=>SP,bigint:()=>$P,boolean:()=>O_,catch:()=>lE,check:()=>iz,cidrv4:()=>gP,cidrv6:()=>yP,clone:()=>ur,codec:()=>ez,coerce:()=>xE,config:()=>gt,core:()=>lo,cuid:()=>cP,cuid2:()=>lP,custom:()=>sz,date:()=>LP,decode:()=>w_,decodeAsync:()=>__,describe:()=>az,discriminatedUnion:()=>qP,e164:()=>vP,email:()=>Y1,emoji:()=>sP,encode:()=>v_,encodeAsync:()=>x_,endsWith:()=>Fa,enum:()=>Km,exactOptional:()=>eE,file:()=>GP,flattenError:()=>eu,float32:()=>IP,float64:()=>AP,formatError:()=>tu,fromJSONSchema:()=>hz,function:()=>oz,getErrorMap:()=>jV,globalRegistry:()=>qt,gt:()=>Nn,gte:()=>pr,guid:()=>X1,hash:()=>kP,hex:()=>EP,hostname:()=>_P,httpUrl:()=>iP,includes:()=>Ma,instanceof:()=>lz,int:()=>_m,int32:()=>TP,int64:()=>OP,intersection:()=>F_,invertCodec:()=>tz,ipv4:()=>fP,ipv6:()=>hP,iso:()=>Xa,json:()=>dz,jwt:()=>wP,keyof:()=>BP,ksuid:()=>pP,lazy:()=>gE,length:()=>xs,literal:()=>WP,locales:()=>pu,looseObject:()=>UP,looseRecord:()=>KP,lowercase:()=>Za,lt:()=>zn,lte:()=>Pr,mac:()=>mP,map:()=>HP,maxLength:()=>ws,maxSize:()=>oi,meta:()=>cz,mime:()=>Ka,minLength:()=>co,minSize:()=>Dn,multipleOf:()=>ni,nan:()=>XP,nanoid:()=>aP,nativeEnum:()=>VP,negative:()=>lm,never:()=>qm,nonnegative:()=>dm,nonoptional:()=>sE,nonpositive:()=>um,normalize:()=>Ha,null:()=>N_,nullable:()=>Eu,nullish:()=>QP,number:()=>$_,object:()=>jP,optional:()=>_u,overwrite:()=>un,parse:()=>g_,parseAsync:()=>y_,partialRecord:()=>FP,pipe:()=>Em,positive:()=>cm,prefault:()=>iE,preprocess:()=>pz,prettifyError:()=>TS,promise:()=>nz,property:()=>pm,readonly:()=>fE,record:()=>J_,refine:()=>SE,regex:()=>ja,regexes:()=>Cr,registry:()=>Uf,safeDecode:()=>k_,safeDecodeAsync:()=>A_,safeEncode:()=>E_,safeEncodeAsync:()=>I_,safeParse:()=>b_,safeParseAsync:()=>S_,set:()=>JP,setErrorMap:()=>BV,size:()=>vs,slugify:()=>Ga,startsWith:()=>qa,strictObject:()=>ZP,string:()=>wu,stringFormat:()=>xP,stringbool:()=>uz,success:()=>YP,superRefine:()=>vE,symbol:()=>PP,templateLiteral:()=>rz,toJSONSchema:()=>gm,toLowerCase:()=>Va,toUpperCase:()=>Wa,transform:()=>Hm,treeifyError:()=>AS,trim:()=>Ja,tuple:()=>H_,uint32:()=>RP,uint64:()=>CP,ulid:()=>uP,undefined:()=>zP,union:()=>Fm,unknown:()=>_s,uppercase:()=>Ua,url:()=>oP,util:()=>ue,uuid:()=>eP,uuidv4:()=>tP,uuidv6:()=>rP,uuidv7:()=>nP,void:()=>DP,xid:()=>dP,xor:()=>MP});var _E=v(()=>{zr();zr();Vw();zr();yu();gz();Lx();bu();bu();yz();vu();bm();h_();T_();fz();gt(cu())});var bz=v(()=>{_E();_E()});var EE=v(()=>{bz()});var fe=v(()=>{EE()});var kE,Sz;var IE=v(()=>{fe();kE=l.object({title:l.string().trim().min(1).max(500).optional(),introduction:l.string().trim().min(1).max(4000).optional(),topics:l.array(l.string().trim().min(1).max(500)).max(20).optional(),topicsHeading:l.string().trim().min(1).max(120).optional(),contactLabel:l.string().trim().min(1).max(80).optional(),contactNote:l.string().trim().min(1).max(240).optional(),mapCaption:l.string().trim().min(1).max(160).optional(),refusal:l.string().trim().min(1).max(500).optional(),faqHeading:l.string().trim().min(1).max(120).optional()}),Sz=kE.omit({introduction:!0})});function ks(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function wz(e){let t=Reflect.get(fs,"types"),r=ks(t)?t[e]:void 0;if(!(r instanceof Ia))throw Error(`Required YAML type is unavailable: ${e}`);return r}function GV(e,t){let r=0,o=1;for(let n of e.split(":").reverse())r+=(t?Number.parseFloat(n):Number.parseInt(n,10))*o,o*=60;return r}function vz(e){let t=wz(e);return new Ia(`tag:yaml.org,2002:${e}`,{kind:"scalar",resolve:(r)=>typeof r==="string"&&(e==="int"?VV:WV).test(r)&&!r.endsWith("_"),construct:(r)=>{let o=r.replace(/_/g,""),n=o.startsWith("-")?-1:1,i=o.replace(/^[+-]/,"");if(i.includes(":"))return n*GV(i,e==="float");if(e==="int"&&i==="0")return 0;if(e==="int"&&/^0[0-7]+$/.test(i))return n*Number.parseInt(i,8);return t.construct(o)},predicate:t.predicate??void 0,represent:t.represent??void 0,defaultStyle:t.defaultStyle??void 0})}var VV,WV,AE,QV,YV,XV;var xz=v(()=>{Ta();VV=/^[+-]?(?:0|0b[01_]*[01]|0x[\da-fA-F_]*[\da-fA-F]|0[0-7_]*[0-7]|[1-9](?:[\d_]*\d)?|[1-9][\d_]*(?::[0-5]?\d)+)$/,WV=/^(?:[-+]?(?:0|[1-9][\d_]*)(?:\.[\d_]*)?(?:[eE][-+]?\d+)?|\.[\d_]+(?:[eE][-+]?\d+)?|[-+]?\d[\d_]*(?::[0-5]?\d)+\.[\d_]*|[-+]?\.(?:inf|Inf|INF)|\.(?:nan|NaN|NAN))$/;AE=wz("binary"),QV=new Ia("tag:yaml.org,2002:binary",{kind:"scalar",resolve:(e)=>AE.resolve(e),construct:(e)=>{let t=AE.construct(e);if(!(t instanceof Uint8Array))throw Error("Invalid YAML binary result");return typeof Buffer>"u"?Array.from(t):Buffer.from(t)},predicate:(e)=>typeof Buffer<"u"&&Buffer.isBuffer(e),represent:AE.represent??void 0}),YV=new Ia("tag:yaml.org,2002:str",{kind:"scalar",resolve:(e)=>typeof e==="string"&&e.includes(":"),construct:(e)=>e}),XV=mS.extend({implicit:[vz("int"),vz("float"),YV],explicit:[QV]})});var TE=v(()=>{Ta();xz()});var _z,Ez,kz,t9;var RE=v(()=>{TE();fe();_z=l.object({audiences:l.array(l.string()).optional(),positioning:l.string().optional()}),Ez=l.object({summary:l.string().optional(),traits:l.array(l.string()).optional(),principles:l.array(l.string()).optional(),preferredTerms:l.array(l.string()).optional(),avoid:l.array(l.string()).optional()}),kz=l.object({artDirection:l.string().optional(),palette:l.array(l.string()).optional(),composition:l.string().optional(),mood:l.string().optional(),preferred:l.array(l.string()).optional(),avoid:l.array(l.string()).optional()}),t9=l.object({name:l.string().describe("Style guide name"),messaging:_z.optional(),voice:Ez.optional(),visual:kz.optional()})});var Az=v(()=>{TE();IE();RE()});var r9,Wm,FSe,$E="data-ask-sheet",n9;var OE=v(()=>{fe();r9=l.object({public:l.boolean(),preview:l.boolean()}),Wm=l.object({name:l.string().trim().min(1).max(200),url:l.string().url().optional()}),FSe=l.object({sources:l.array(l.object({id:l.string(),title:l.string(),brain:Wm.optional()}))}),n9=`body *:not([${$E}], [${$E}] *) { -webkit-backdrop-filter: none !important; backdrop-filter: none !important; }`});var ci;var Gm=v(()=>{fe();ci=l.discriminatedUnion("kind",[l.object({kind:l.literal("user"),userId:l.string().min(1),canonicalId:l.string().min(1).optional()}),l.object({kind:l.literal("external"),externalActorId:l.string().min(1)}),l.object({kind:l.literal("agent"),agentId:l.string().min(1)}),l.object({kind:l.literal("service"),serviceId:l.string().min(1)})])});var o9,WSe,ac,i9,s9,Tz,GSe,a9,c9,Rz;var $z=v(()=>{fe();o9=l.strictObject({messageCharacters:l.number().int().positive(),requestTimeoutSeconds:l.number().int().positive().max(2147483)}),WSe=l.strictObject({limits:o9,maxCostMicroUsd:l.number().int().positive()}),ac=l.number().int().nonnegative(),i9=l.strictObject({modelCalls:ac,inputTokens:ac,cachedInputTokens:ac,outputTokens:ac,reasoningTokens:ac,embeddingTokens:ac}),s9=l.discriminatedUnion("state",[l.strictObject({state:l.literal("known"),microUsd:l.number().int().nonnegative(),pricing:l.string().trim().min(1).max(120)}),l.strictObject({state:l.literal("unknown"),reason:l.enum(["missing-usage","unsupported-pricing"])})]),Tz=l.strictObject({usage:i9,cost:s9}),GSe=l.strictObject({topics:l.array(l.string().trim().min(1).max(500)).max(20),introduction:l.string().trim().min(1).max(4000).optional(),refusal:l.string().trim().min(1).max(500).optional()}),a9=l.enum(["in-scope","off-topic","abusive","injection","harmful"]),c9=a9.exclude(["in-scope"]),Rz=l.discriminatedUnion("outcome",[l.strictObject({outcome:l.literal("answered")}),l.strictObject({outcome:l.literal("refused"),category:c9}),l.strictObject({outcome:l.literal("unscreened")})])});function u9(e){let t=l9.safeParse(e);if(!t.success)return e;return{...t.data,cards:t.data.cards.filter((r)=>CE.safeParse(r).success)}}var Oz,Cz,Pz,zz,Nz,Dz,cc,Lz,Bz,jz,Zz,Uz,CE,Mz,qz,Fz,l9,Kz;var zu=v(()=>{fe();OE();$z();Oz=l.object({id:l.string(),toolCallId:l.string().optional(),toolName:l.string(),summary:l.string(),completionSummary:l.string().optional(),preview:l.string().optional(),args:l.unknown()}),Cz=l.enum(["approval-requested","approval-responded","output-available","output-denied","output-error"]),Pz=l.object({kind:l.literal("tool-approval"),id:l.string(),toolCallId:l.string().optional(),toolName:l.string(),input:l.record(l.string(),l.unknown()).optional(),summary:l.string(),completionSummary:l.string().optional(),preview:l.string().optional(),state:Cz,output:l.unknown().optional(),error:l.string().optional()}),zz=l.object({entityType:l.string().optional(),entityId:l.string().optional(),attachmentType:l.string().optional()}),Nz=l.object({mediaType:l.string().min(1),url:l.string().min(1),downloadUrl:l.string().min(1).optional(),previewUrl:l.string().min(1).optional(),filename:l.string().min(1).optional(),sizeBytes:l.number().nonnegative().optional(),source:zz.optional()}),Dz=l.object({kind:l.literal("attachment"),id:l.string(),jobId:l.string().optional(),title:l.string(),description:l.string().optional(),attachment:Nz}),cc=l.object({id:l.string().min(1),title:l.string().min(1).optional(),source:l.string().min(1),url:l.string().min(1).optional(),entityType:l.string().min(1).optional(),entityId:l.string().min(1).optional(),excerpt:l.string().min(1).optional(),provenance:l.record(l.string(),l.unknown()).optional(),brain:Wm.optional()}),Lz=l.object({kind:l.literal("sources"),id:l.string().min(1),title:l.string().min(1).optional(),sources:l.array(cc).min(1)}),Bz=l.object({type:l.literal("prompt"),id:l.string().min(1),label:l.string().min(1),prompt:l.string().min(1),description:l.string().min(1).optional()}),jz=l.object({type:l.literal("event"),id:l.string().min(1),label:l.string().min(1),event:l.string().min(1),fromState:l.string().min(1).optional(),description:l.string().min(1).optional()}),Zz=l.discriminatedUnion("type",[Bz,jz]),Uz=l.object({kind:l.literal("actions"),id:l.string().min(1),title:l.string().min(1).optional(),defaultOpen:l.boolean().optional(),actions:l.array(Zz).min(1)}),CE=l.discriminatedUnion("kind",[Pz,Dz,Lz,Uz]),Mz=l.object({toolName:l.string(),args:l.record(l.string(),l.unknown()).optional(),jobId:l.string().optional(),data:l.unknown().optional(),error:l.object({message:l.string(),code:l.string().optional()}).optional()}),qz=l.object({faqId:l.string().min(1)}),Fz=l.object({text:l.string(),error:l.string().optional(),toolResults:l.array(Mz).optional(),cards:l.array(CE).optional(),pendingConfirmations:l.array(Oz).optional(),usage:l.object({promptTokens:l.number(),completionTokens:l.number(),totalTokens:l.number()}),guestSettlement:Tz.optional(),guestScreening:Rz.optional(),askedBefore:qz.optional()}),l9=l.looseObject({cards:l.array(l.unknown())});Kz=l.preprocess((e)=>u9(pf(e)),Fz)});function Ee(e){return Object.freeze({name:e.channel,schema:e.request,response:e.response,delivery:e.delivery})}var PE,d9,p9,Hz,f9,m9,h9,g9;var Jz=v(()=>{fe();Gm();zu();PE=l.object({state:l.string(),response:l.string(),sources:l.array(cc)}),d9=l.object({agent:l.string().trim().min(1).max(253),question:l.string().trim().min(1).max(4000)}),p9=Ee({channel:"a2a:ask:request",request:d9,response:PE,delivery:"request"}),Hz=l.object({entityType:l.string().optional(),entityId:l.string().optional(),actor:ci.optional(),interfaceType:l.string().optional(),userPermissionLevel:l.enum(["admin","trusted","public"])}),f9=l.object({agent:l.string().trim().min(1).max(253),instruction:l.string().trim().min(1).max(2000),selection:l.string().min(1).max(8000),...Hz.shape}),m9=Ee({channel:"a2a:call:request",request:f9,response:PE,delivery:"request"}),h9=l.object({agents:l.array(l.object({id:l.string(),label:l.string()}))}),g9=Ee({channel:"a2a:call:agents",request:Hz,response:h9,delivery:"request"})});var y9,Vz,b9,S9;var Wz=v(()=>{fe();zu();y9=l.object({type:l.literal("event"),event:l.string().min(1),fromState:l.string().min(1).optional()}),Vz=l.object({conversationId:l.string().min(1),interfaceType:l.string().min(1),channelId:l.string().min(1).optional(),channelName:l.string().min(1),userPermissionLevel:l.enum(["admin","trusted","public"]),isAnchor:l.boolean(),action:y9}),b9=Kz.nullable(),S9=Ee({channel:"agent:action:request",request:Vz,response:b9,delivery:"request"})});var Gz,v9,Qz,w9;var Yz=v(()=>{fe();zu();Gz=l.object({question:l.string().trim().min(1)}),v9=l.object({faqId:l.string().min(1),faqQuestion:l.string().min(1),answer:l.string().trim().min(1),sources:l.array(cc).default([])}),Qz=l.object({hit:v9.optional()}),w9=Ee({channel:"guest:asked-before",request:Gz,response:Qz,delivery:"collect"})});var x9,Xz,eN,Sve,_9,E9;var tN=v(()=>{fe();x9=l.enum(["admin","trusted","public"]),Xz=l.object({conversationId:l.string().min(1),message:l.string(),interfaceType:l.string().min(1),channelId:l.string().optional(),channelName:l.string().optional(),userPermissionLevel:x9}),eN=l.object({id:l.string().min(1),source:l.string().min(1),title:l.string().optional(),content:l.string().min(1),provenance:l.record(l.string(),l.unknown()).optional()}),Sve=l.object({items:l.array(eN).default([])}),_9=l.object({items:l.array(l.unknown()).default([]).transform((e)=>e.flatMap((t)=>{let r=eN.safeParse(t);return r.success?[r.data]:[]}))}),E9=Ee({channel:"agent:context:request",request:Xz,response:_9,delivery:"collect"})});var k9,I9;var rN=v(()=>{fe();k9=l.strictObject({entityType:l.string().min(1),entityId:l.string().min(1)}),I9=l.strictObject({startedAt:l.string().datetime(),retrieved:l.array(k9).max(50)})});var nN,A9,oN,T9;var iN=v(()=>{fe();Gm();nN=l.object({actor:ci}),A9=l.object({userId:l.string().min(1),personId:l.string().min(1),canonicalId:l.string().min(1).optional(),displayName:l.string().min(1),permissionLevel:l.enum(["admin","trusted","public"])}),oN=l.object({principal:A9.nullable()}),T9=Ee({channel:"auth:principal:resolve",request:nN,response:oN,delivery:"request"})});var sN=()=>{};var aN=()=>{};var zE,R9,cN,$9,O9;var lN=v(()=>{fe();zE=l.strictObject({name:l.string().min(1).optional(),address:l.email()}),R9=l.strictObject({personId:l.string().min(1).max(200),displayName:l.string().trim().min(1).max(200),permissionLevel:l.enum(["admin","trusted","public"])}),cN=l.strictObject({messageId:l.string().min(1),sourceRef:l.string().min(1),threadId:l.string().min(1).optional(),from:zE,replyTo:zE.optional(),to:l.array(zE),subject:l.string(),receivedAt:l.iso.datetime(),text:l.string(),html:l.string().min(1).optional(),headers:l.strictObject({listUnsubscribe:l.string().min(1).optional(),autoSubmitted:l.string().min(1).optional(),precedence:l.string().min(1).optional(),inReplyTo:l.string().min(1).optional(),references:l.array(l.string().min(1)).optional()}),sender:R9.optional()}),$9=l.strictObject({}),O9=Ee({channel:"email:inbound",request:cN,response:$9,delivery:"request"})});var C9,P9,uN,NE,z9,dN,N9;var pN=v(()=>{fe();C9=l.strictObject({permissionLevel:l.enum(["admin","trusted","public"])}),P9=l.custom((e)=>typeof AbortSignal<"u"&&e instanceof AbortSignal),uN=l.strictObject({sourceRef:l.string().regex(/^imap:[a-f0-9]{64}$/),actor:C9,signal:P9.optional()}),NE=l.strictObject({name:l.string().trim().min(1).max(300).optional(),address:l.email().max(320)}),z9=l.strictObject({messageId:l.string().trim().min(1).max(2000),from:NE,replyTo:NE.optional(),to:l.array(NE).max(100),subject:l.string().max(1000),receivedAt:l.iso.datetime(),text:l.string().max(1e5),inReplyTo:l.string().trim().min(1).max(2000).optional(),references:l.array(l.string().trim().min(1).max(2000)).max(100),truncated:l.boolean()}),dN=l.discriminatedUnion("kind",[l.strictObject({kind:l.literal("available"),message:z9}),l.strictObject({kind:l.literal("unavailable")})]),N9=Ee({channel:"email:source-read",request:uN,response:dN,delivery:"request"})});var fN=()=>{};var mN=v(()=>{fN()});var D9;var hN=v(()=>{fe();D9=l.object({url:l.string(),authToken:l.string().optional()})});var L9;var gN=v(()=>{fe();L9=l.object({success:l.boolean(),entityId:l.string().optional(),error:l.string().optional()})});var yN=()=>{};function Qm(e,t="handler_failed"){let r=t,o;try{if(e!==null&&typeof e==="object"){let n=Nu.safeParse(Reflect.get(e,"code"));if(n.success)r=n.data,o=Du.shape.message.safeParse(Reflect.get(e,"publicMessage")).data;else{let i=Reflect.get(e,"name");if(i==="AbortError")r="cancelled";if(i==="TimeoutError")r="deadline_exceeded"}}}catch{}return new li(r,{cause:e,...o!==void 0?{publicMessage:o}:{}})}var Nu,SN=1024,Du,bN,li;var vN=v(()=>{fe();Nu=l.enum(["no_handler","handler_failed","invalid_input","invalid_response","unauthenticated","permission_denied","not_found","conflict","cancelled","deadline_exceeded"]),Du=l.object({code:Nu,message:l.string().max(SN)}),bN={no_handler:"No handler is available for this capability",handler_failed:"The operation failed",invalid_input:"Invalid input",invalid_response:"Invalid response",unauthenticated:"Authentication required",permission_denied:"Permission denied",not_found:"Not found",conflict:"The operation conflicts with the current state",cancelled:"The operation was cancelled",deadline_exceeded:"The execution deadline was exceeded"};li=class li extends Error{code;publicMessage;constructor(e,t={}){let r=Nu.parse(e),o=Du.shape.message.parse(t.publicMessage??bN[r]);super(t.message??o,{cause:t.cause});this.name="SdkError",this.code=r,this.publicMessage=o}toJSON(){let e=Nu.safeParse(this.code),t=e.data??"handler_failed",r=e.success?Du.shape.message.safeParse(this.publicMessage).data:void 0;return{code:t,message:r??bN[t]}}}});var Ym,Xm;var DE=v(()=>{fe();Ym=l.lazy(()=>l.union([l.null(),l.boolean(),l.number().finite().refine((e)=>!Number.isInteger(e)||Number.isSafeInteger(e),{message:"integer exceeds the JSON-safe range"}),l.string(),l.array(Ym),l.record(l.string(),Ym)])),Xm=l.record(l.string(),Ym)});var B9;var wN=v(()=>{fe();B9=l.enum(["user","assistant"])});var j9,uo;var xN=v(()=>{fe();j9=l.object({entityType:l.string().min(1),entityId:l.string().min(1),contentHash:l.string().min(1).optional()}),uo=l.object({rootJobId:l.string().min(1),causationId:l.string().min(1),projectionId:l.string().min(1).optional(),projectionLineage:l.array(l.string().min(1)),sourceEntity:j9.optional(),derivationDepth:l.number().int().nonnegative()}).superRefine((e,t)=>{if(e.derivationDepth!==e.projectionLineage.length)t.addIssue({code:"custom",path:["derivationDepth"],message:"Derivation depth must equal projection lineage length"});let r=e.projectionLineage.at(-1);if(e.projectionId!==r)t.addIssue({code:"custom",path:["projectionId"],message:"Current projection must equal the final projection lineage entry"})})});var LE=10,_N=82,BE,Z9,U9,M9,q9,F9,K9;var EN=v(()=>{fe();BE=l.object({title:l.string().min(1).max(200),lines:l.array(l.string().min(1)).min(1).max(LE),actions:l.array(l.object({label:l.string().min(1).max(80),value:l.string().min(1).max(_N)})).max(LE)}),Z9=BE.extend({channelId:l.string().min(1),interfaceType:l.string().min(1),reactions:l.array(l.object({messageId:l.string().min(1),emoji:l.string().min(1)}))}),U9=l.object({messageId:l.string().min(1)}),M9=l.object({conversationId:l.string().min(1),noticeMessageId:l.string().min(1),value:l.string().min(1),by:l.string().min(1)}),q9=Ee({channel:"chat:space-notice",request:Z9,response:U9,delivery:"request"}),F9=BE.nullable(),K9=Ee({channel:"chat:space-notice-action",request:M9,response:F9,delivery:"collect"})});function ui(e,t){return Object.freeze({name:e,schema:t})}var owe;var jE=v(()=>{fe();owe=l.object({name:l.string(),schema:l.custom((e)=>typeof e==="object"&&e!==null&&("safeParse"in e))})});var ZE,UE,H9,J9,V9,W9;var kN=v(()=>{fe();jE();ZE={progress:"job-progress"},UE={completed:"publish:completed",failed:"publish:failed"},H9=l.object({entityType:l.string().min(1),entityId:l.string().min(1),result:l.object({id:l.string(),url:l.string().optional()})}),J9=l.object({entityType:l.string().min(1),entityId:l.string().min(1),error:l.string(),retryCount:l.number(),willRetry:l.boolean()}),V9=ui(UE.completed,H9),W9=ui(UE.failed,J9)});var IN,AN,G9;var TN=v(()=>{fe();IN=l.object({entityType:l.string().min(1),entityId:l.string(),metadata:l.record(l.string(),l.unknown()).default({}),content:l.string().default("")}),AN=l.object({relativePath:l.string(),leaf:l.object({start:l.number().int().nonnegative(),end:l.number().int().nonnegative()}).nullable(),owner:l.object({entityType:l.string(),id:l.string()}).optional(),writable:l.boolean().optional()}),G9=Ee({channel:"sync:path:request",request:IN,response:AN,delivery:"request"})});var Q9,Y9,X9,e7;var RN=v(()=>{fe();Q9=l.strictObject({}),Y9=l.object({branch:l.string(),hasChanges:l.boolean(),ahead:l.number(),behind:l.number(),lastCommit:l.string().nullable(),remote:l.string().nullable()}),X9=l.object({syncPath:l.string(),isInitialized:l.boolean(),watchEnabled:l.boolean(),lastSync:l.string().nullable(),totalFiles:l.number(),byEntityType:l.record(l.string(),l.number()),git:Y9.nullable(),managementUrl:l.string().optional()}),e7=Ee({channel:"sync:status:request",request:Q9,response:X9,delivery:"request"})});var $N=()=>{};var ON,t7,r7;var CN=v(()=>{fe();ON=l.strictObject({waveId:l.string().trim().min(1),sourceTypes:l.array(l.string().trim().min(1)),changedTargetTypes:l.array(l.string().trim().min(1))}),t7=l.strictObject({}),r7=Ee({channel:"projection:wave-ready",request:ON,response:t7,delivery:"collect"})});var n7,o7,i7;var PN=v(()=>{fe();n7=l.strictObject({}),o7=l.string(),i7=Ee({channel:"plugin:site-builder:head-scripts",request:n7,response:o7,delivery:"collect"})});function zN(e){return typeof e==="function"}var NN=".site-build-manifest.json",s7,a7,c7,l7;var DN=v(()=>{fe();s7=`/${NN}`,a7=Ee({channel:"site:build:requested",request:l.object({reason:l.string().min(1)}),response:l.void(),delivery:"command"});c7=l.object({outputDir:l.string(),environment:l.enum(["preview","production"]),routesBuilt:l.number(),siteConfig:l.object({title:l.string().optional(),description:l.string().optional(),url:l.string().optional(),copyright:l.string().optional(),themeMode:l.enum(["light","dark"]).optional()}),generateEntityUrl:l.custom(zN),reportFailure:l.custom(zN)}),l7=Ee({channel:"site:build:staging",request:c7,response:l.void(),delivery:"command"})});var u7,d7,p7;var LN=v(()=>{fe();u7=l.object({id:l.string().min(1),trigger:l.string().min(1),playbookId:l.string().min(1),once:l.boolean().default(!0),starterText:l.string().min(1),description:l.string().min(1).optional(),starterPrompt:l.string().min(1)}).strict(),d7=l.object({registered:l.boolean(),id:l.string(),ignored:l.boolean().optional(),reason:l.string().optional()}),p7=Ee({channel:"playbooks:register-lifecycle-starter",request:u7,response:d7,delivery:"request"})});var f7,m7,h7;var BN=v(()=>{fe();f7=l.object({id:l.string().min(1),markdown:l.string().min(1)}).strict(),m7=l.object({created:l.boolean()}),h7=Ee({channel:"playbooks:seed",request:f7,response:m7,delivery:"request"})});var jN,eh,ME,ZN,UN,g7,y7;var MN=v(()=>{fe();jN=["name","headline","industry","location","website","story"],eh=l.enum(jN),ME=l.object({name:l.string().optional(),headline:l.string().optional(),industry:l.string().optional(),location:l.string().optional(),website:l.string().optional(),story:l.string().optional()}),ZN=l.enum(["fill","preserve","unchanged"]),UN=l.object({field:eh,current:l.string().nullable(),imported:l.string(),outcome:ZN}),g7=Ee({channel:"@brains/profile:import-preview",request:l.object({fields:ME}),response:l.object({fields:l.array(UN),changed:l.boolean(),revision:l.string()}),delivery:"request"}),y7=Ee({channel:"@brains/profile:import-apply",request:l.object({fields:ME,revision:l.string()}),response:l.object({filled:l.array(eh),kept:l.array(eh)}),delivery:"request"})});function v7(e){return typeof e==="object"&&e!==null&&"name"in e&&typeof e.name==="string"&&"publish"in e&&typeof e.publish==="function"}var b7,S7,w7,x7,_7,E7,qN,k7;var FN=v(()=>{fe();b7=l.enum(["provider"]),S7=l.object({executionMode:b7.optional(),publishResultIdField:l.string().min(1).optional(),publishTimestampField:l.string().min(1).optional(),enabled:l.boolean().optional()}).strict();w7=l.custom(v7),x7=l.object({entityType:l.string(),provider:w7.optional(),config:S7.optional()}),_7=Ee({channel:"publish:register",request:x7,response:l.void(),delivery:"command"}),E7=l.union([l.string().min(1),l.object({location:l.enum(["metadata","frontmatter"]),field:l.string().min(1)})]),qN=l.object({entityType:l.string().min(1),attachmentType:l.string().min(1),mediaEntityType:l.enum(["image"]),targetEntityField:E7.optional(),requiredWhen:l.object({status:l.string().min(1).optional(),visibility:l.string().min(1).optional()}).optional(),autoGenerate:l.boolean().optional(),requiredForPublish:l.boolean().optional()}),k7=Ee({channel:"publish-assets:register",request:qN,response:l.void(),delivery:"command"})});var I7,A7,T7,R7,$7,O7;var KN=v(()=>{fe();I7=l.object({entityType:l.string()}),A7=Ee({channel:"generate:execute",request:I7,response:l.void(),delivery:"command"}),T7=l.object({entityType:l.string(),entityId:l.string()}),R7=Ee({channel:"generate:report:success",request:T7,response:l.void(),delivery:"command"}),$7=l.object({entityType:l.string(),error:l.string()}),O7=Ee({channel:"generate:report:failure",request:$7,response:l.void(),delivery:"command"})});var C7,HN,JN,VN;var WN=v(()=>{fe();C7=l.object({message:l.string().describe("Natural language response to the query"),summary:l.string().optional().describe("Brief summary if applicable"),topics:l.array(l.string()).optional().describe("Related topics mentioned"),sources:l.array(l.object({id:l.string(),type:l.string(),excerpt:l.string().optional(),relevance:l.number().min(0).max(1).optional()})).optional().describe("Source entities used to answer the query"),metadata:l.record(l.string(),l.unknown()).optional()}).describe("defaultQueryResponse"),HN=l.object({message:l.string()}).describe("simpleTextResponse"),JN=l.object({success:l.boolean(),entityId:l.string().optional(),message:l.string()}).describe("createEntityResponse"),VN=l.object({success:l.boolean(),entityId:l.string(),changes:l.array(l.string()).optional(),message:l.string()}).describe("updateEntityResponse")});var GN,QN,P7,YN,XN,z7;var e2=v(()=>{fe();GN=l.discriminatedUnion("type",[l.strictObject({type:l.literal("email"),address:l.email()})]),QN=l.strictObject({recipient:GN.optional(),title:l.string().min(1),body:l.string().min(1),html:l.string().min(1).optional(),sensitivity:l.enum(["normal","secret"]).default("normal"),idempotencyKey:l.string().trim().min(1).max(200).optional(),replyTo:l.email().optional()}),P7=l.enum(["recipient-missing","transport-missing","delivery-failed"]),YN=l.string().regex(/^[a-z0-9_:.-]{1,80}$/u),XN=l.discriminatedUnion("status",[l.strictObject({status:l.literal("sent"),deliveryId:l.string().optional()}),l.strictObject({status:l.literal("failed"),failure:P7,transportCode:YN.optional()})]),z7=Ee({channel:"notifications:send",request:QN,response:XN,delivery:"request"})});var N7,t2,D7;var r2=v(()=>{fe();N7=l.strictObject({}),t2=l.strictObject({titles:l.array(l.string().trim().min(1).max(500)).max(20)}),D7=Ee({channel:"topics:public-titles",request:N7,response:t2,delivery:"request"})});var L7,B7,j7;var n2=v(()=>{fe();L7=l.strictObject({}),B7=l.strictObject({types:l.array(l.string().trim().min(1))}),j7=Ee({channel:"topics:source-types",request:L7,response:B7,delivery:"request"})});var o2,i2,Z7;var s2=v(()=>{fe();o2=l.strictObject({id:l.string().regex(/^[a-z0-9][a-z0-9-]{0,79}$/),title:l.string().trim().min(1).max(200),body:l.string().trim().min(1).max(20000)}),i2=l.strictObject({noteId:l.string(),created:l.boolean()}),Z7=Ee({channel:"note:capture",request:o2,response:i2,delivery:"request"})});var lc,Lu,U7,M7,q7,F7,K7,H7;var a2=v(()=>{fe();DE();lc=l.string().regex(/^[a-z][a-z0-9-]{0,63}$/),Lu=l.string().min(32).max(512),U7=l.strictObject({provider:lc,brainState:Lu}),M7=l.strictObject({authorizationUrl:l.url({protocol:/^https?$/})}),q7=l.strictObject({provider:lc,grant:Lu}),F7=l.strictObject({provider:lc,credential:Xm}),K7=l.enum(["provider_denied","authorization_incomplete","credential_exchange_failed"]),H7=l.union([l.strictObject({provider:lc,state:Lu,grant:Lu}),l.strictObject({provider:lc,state:Lu,error:K7})])});var J7,V7,W7,G7;var c2=v(()=>{fe();J7=l.object({permissionLevel:l.enum(["public","trusted","admin"])}),V7=l.object({id:l.string().min(1),title:l.string().min(1),sub:l.string().optional(),href:l.string().min(1),primary:l.boolean().optional(),keywords:l.array(l.string()).optional()}),W7=l.array(V7),G7=Ee({channel:"console:jump-destinations",request:J7,response:W7,delivery:"collect"})});var th,qE;var l2=v(()=>{fe();th=l.enum(["github","instagram","linkedin","podcast","email","website"]),qE=l.object({platform:th.describe("Social media platform"),url:l.string().describe("Profile or contact URL"),label:l.string().optional().describe("Optional display label")})});function rh(e){if(!e.type.includes(":"))throw Error(`Job contract type "${e.type}" must name its owner, as "owner:job"`);return Object.freeze({type:e.type,input:e.input})}var u2,d2,Q7,p2,Y7;var f2=v(()=>{fe();u2=l.enum(["1:1","16:9","9:16","4:3","3:4"]),d2=l.object({prompt:l.string(),title:l.string().optional(),aspectRatio:u2.optional(),targetEntityType:l.string().optional(),targetEntityId:l.string().optional(),entityTitle:l.string().optional(),entityContent:l.string().optional()}),Q7=rh({type:"image:image-generate",input:d2}),p2=l.object({sourceEntityType:l.string().min(1),sourceEntityId:l.string().min(1),attachmentType:l.string().min(1),imageId:l.string().min(1),dedupKey:l.string().min(1).optional(),replace:l.boolean().optional(),targetEntityType:l.string().min(1).optional(),targetEntityId:l.string().min(1).optional(),targetImageField:l.enum(["coverImageId","ogImageId"]).optional()}),Y7=rh({type:"image:image-render-source",input:p2})});var X7;var m2=v(()=>{fe();X7=l.enum(["none","low","medium","high","xhigh","max"])});var Rt=v(()=>{IE();Az();OE();Jz();Wz();zu();Yz();tN();rN();Gm();iN();sN();aN();lN();pN();mN();hN();gN();yN();vN();DE();wN();xN();EN();kN();jE();TN();RN();$N();CN();RE();PN();DN();LN();BN();MN();FN();KN();WN();e2();r2();n2();s2();a2();c2();l2();f2();m2()});var nW,oW,$t,mr,Is,iW,di="capability-bundles-v1",oh,sW,aW,cW,lW,h2,nh,pi,Kr,uW,dW,pW,fW,mW,FE,hW,gW,ih;var Bn=v(()=>{Rt();fe();nW=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/,oW=/^[a-z0-9]+(?:-[a-z0-9]+)*$/,$t=l.string().regex(nW,"expected exact pinned version"),mr=l.string().regex(oW,"expected lowercase handle slug"),Is=l.string().min(1),iW=l.string().startsWith("age1").min(1),oh=l.enum(["core","media","automation","web","chat","site","publishing","federation","team"]),sW=["professional","team","organization"],aW=l.enum(sW),cW=["person","team","organization"],lW=l.enum(cW),h2=l.array(oh).min(1),nh=l.array(l.string().min(1)),pi=l.strictObject({brainVersion:$t,bundleContract:l.literal(di),bundles:h2,add:nh.optional(),remove:nh.optional(),githubOrg:l.string().min(1),contentRepoPrefix:l.string().min(1),domainSuffix:l.string().min(1),openaiApiKey:Is,gitSyncToken:Is,contentRepoAdminToken:Is,agePublicKey:iW}).superRefine((e,t)=>{if(new Set(e.bundles).size!==e.bundles.length)t.addIssue({code:l.ZodIssueCode.custom,path:["bundles"],message:"canonical bundles must be unique"})}),Kr=l.strictObject({members:l.array(mr).min(1),brainVersionOverride:$t.optional(),bundlesOverride:h2.optional(),addOverride:nh.optional(),removeOverride:nh.optional(),openaiApiKeyOverride:Is.optional(),gitSyncTokenOverride:Is.optional()}).superRefine((e,t)=>{if(new Set(e.members).size!==e.members.length)t.addIssue({code:l.ZodIssueCode.custom,path:["members"],message:"cohort members must be unique"});if(e.bundlesOverride&&new Set(e.bundlesOverride).size!==e.bundlesOverride.length)t.addIssue({code:l.ZodIssueCode.custom,path:["bundlesOverride"],message:"canonical bundle overrides must be unique"})}),uW=l.strictObject({platform:th,url:l.string().min(1),label:l.string().min(1).optional()}),dW=l.strictObject({name:l.string().min(1).optional(),description:l.string().min(1).optional(),website:l.string().min(1).optional(),email:l.string().min(1).optional(),story:l.string().min(1).optional(),socialLinks:l.array(uW).optional()}),pW=l.strictObject({delivery:l.literal("email"),email:l.string().email()}),fW=l.strictObject({enabled:l.boolean().optional(),endpoint:l.string().url().refine((e)=>new URL(e).protocol==="wss:",{message:"Jetstream endpoint must use wss"}).optional(),replayWindowSeconds:l.number().int().min(60).optional(),denyDids:l.array(l.string().startsWith("did:plc:")).optional(),denyDomains:l.array(l.string().min(1)).optional(),skillKeywords:l.array(l.string().min(1)).optional(),queueLimit:l.number().int().min(1).max(1e4).optional(),concurrency:l.number().int().min(1).max(32).optional(),perDidCooldownSeconds:l.number().int().nonnegative().optional(),fetchBudgetPerMinute:l.number().int().min(1).optional(),newAgentsPerHour:l.number().int().min(1).optional(),pendingCandidateCeiling:l.number().int().min(1).optional(),staleCandidateRetentionDays:l.number().int().min(1).optional(),requestTimeoutMs:l.number().int().min(100).optional(),maxResponseBytes:l.number().int().min(1024).optional(),maxRedirects:l.number().int().nonnegative().optional(),retryAttempts:l.number().int().min(1).optional(),heartbeatIntervalHours:l.number().min(1).optional()}),mW=l.strictObject({identifier:l.string().min(1),accountDid:l.string().min(1).optional(),lexiconAuthority:l.boolean().optional(),jetstream:fW.optional()}),FE=l.strictObject({package:l.string().min(1),version:$t.optional(),theme:l.string().min(1).optional(),themeVersion:$t.optional()}).superRefine((e,t)=>{let r=e.package.startsWith("@rizom/");if(r&&e.version===void 0)t.addIssue({code:l.ZodIssueCode.custom,path:["version"],message:"external @rizom site packages require an exact version pin"});if(!r&&e.version!==void 0)t.addIssue({code:l.ZodIssueCode.custom,path:["version"],message:"version is valid only for external @rizom site packages"});let o=e.theme?.startsWith("@rizom/")===!0;if(o&&e.themeVersion===void 0)t.addIssue({code:l.ZodIssueCode.custom,path:["themeVersion"],message:"external @rizom themes require an exact version pin"});if(!o&&e.themeVersion!==void 0)t.addIssue({code:l.ZodIssueCode.custom,path:["themeVersion"],message:"themeVersion is valid only for external @rizom themes"})}),hW=l.strictObject({onboarding:l.boolean().optional()}),gW=l.record(l.string().min(1),l.record(l.string(),l.unknown())),ih=l.strictObject({handle:mr,discord:l.strictObject({enabled:l.boolean(),anchorUserId:l.string().min(1).optional()}),openaiApiKeyOverride:Is.optional(),gitSyncTokenOverride:Is.optional(),domainOverride:l.string().min(1).optional(),cloudflareZoneId:l.string().min(1).optional(),contentRepoOverride:l.string().min(1).optional(),profileKind:aW.optional(),anchorKind:lW.optional(),plugins:gW.optional(),spaces:l.array(l.string().min(1)).optional(),embeddingEnabled:l.boolean().optional(),embeddingModel:l.string().optional(),topicExtractionEnabled:l.boolean().optional(),skillDerivationEnabled:l.boolean().optional(),swotDerivationEnabled:l.boolean().optional(),addOverride:l.array(l.string().min(1)).optional(),removeOverride:l.array(l.string().min(1)).optional(),siteOverride:FE.optional(),setup:pW.optional(),atproto:mW.optional(),playbooks:hW.optional(),anchorProfile:dW.optional()})});import{access as yW,readdir as bW,readFile as SW}from"fs/promises";import{basename as KE,join as Bu,relative as vW}from"path";async function ut(e,t={}){let[r,o,n]=await Promise.all([HE(Bu(e,"pilot.yaml"),pi),xW(e),_W(e)]),i=EW(o,n),s=n.map((c)=>({id:c.id,members:[...c.data.members].sort(),...ka({brainVersionOverride:c.data.brainVersionOverride,bundlesOverride:c.data.bundlesOverride,addOverride:c.data.addOverride,removeOverride:c.data.removeOverride,openaiApiKeyOverride:c.data.openaiApiKeyOverride,gitSyncTokenOverride:c.data.gitSyncTokenOverride})})).sort((c,u)=>c.id.localeCompare(u.id)),a=await Promise.all(o.map(async(c)=>{let u=i.get(c.data.handle);if(!u)throw new As(`User ${c.data.handle} must belong to exactly one cohort`);let d={...wW(c.data,u,r),snapshotStatus:await AW(e,c.data.handle)},p=await t.resolveStatus?.(d);return{...d,serverStatus:p?.serverStatus??"unknown",deployStatus:p?.deployStatus??"unknown",dnsStatus:p?.dnsStatus??"unknown",mcpStatus:p?.mcpStatus??"unknown"}}));return a.sort((c,u)=>c.handle.localeCompare(u.handle)),{pilot:r,cohorts:s,users:a}}function wW(e,t,r){let o=t.data.bundlesOverride===void 0;return{handle:e.handle,cohort:t.id,brainVersion:t.data.brainVersionOverride??r.brainVersion,bundleContract:r.bundleContract,bundles:[...t.data.bundlesOverride??r.bundles],add:g2(t.data.addOverride??(o?r.add:void 0),e.addOverride),remove:g2(t.data.removeOverride??(o?r.remove:void 0),e.removeOverride),domain:e.domainOverride??`${e.handle}${r.domainSuffix}`,...ka({cloudflareZoneId:e.cloudflareZoneId}),contentRepo:e.contentRepoOverride??`${r.contentRepoPrefix}${e.handle}-content`,...ka({profileKind:e.profileKind,anchorKind:e.anchorKind,embeddingEnabled:e.embeddingEnabled,embeddingModel:e.embeddingModel,spaces:e.spaces,plugins:e.plugins,topicExtractionEnabled:e.topicExtractionEnabled,skillDerivationEnabled:e.skillDerivationEnabled,swotDerivationEnabled:e.swotDerivationEnabled,siteOverride:e.siteOverride&&{...e.siteOverride}}),discordEnabled:e.discord.enabled,...ka({discordAnchorUserId:e.discord.anchorUserId}),effectiveOpenaiApiKey:e.openaiApiKeyOverride??t.data.openaiApiKeyOverride??r.openaiApiKey,effectiveGitSyncToken:e.gitSyncTokenOverride??t.data.gitSyncTokenOverride??r.gitSyncToken,...ka({setup:e.setup,atproto:e.atproto,playbooks:e.playbooks}),anchorProfile:kW(e.handle,e.anchorProfile)}}function g2(e,t){return TW([...e??[],...t??[]])}async function xW(e){let t=Bu(e,"users"),r=(await y2(t)).filter((n)=>!KE(n).endsWith(".secrets.yaml"));return(await Promise.all(r.map(async(n)=>{let i=b2(KE(n)),s=await HE(n,ih);if(s.handle!==i){let a=S2(vW(e,n));throw new As(`${a} must declare handle: ${i}`)}return{id:i,data:s}}))).sort((n,i)=>n.id.localeCompare(i.id))}async function _W(e){let t=Bu(e,"cohorts"),r=await y2(t);return(await Promise.all(r.map(async(n)=>({id:b2(KE(n)),data:await HE(n,Kr)})))).sort((n,i)=>n.id.localeCompare(i.id))}function EW(e,t){let r=new Map(e.map((n)=>[n.data.handle,n])),o=new Map;for(let n of t)for(let i of n.data.members){if(!r.has(i))throw new As(`Cohort ${n.id} references unknown user ${i}`);if(o.has(i))throw new As(`User ${i} must belong to exactly one cohort`);o.set(i,n)}for(let n of e)if(!o.has(n.data.handle))throw new As(`User ${n.data.handle} must belong to exactly one cohort`);return o}function kW(e,t){return{name:t?.name??IW(e),...t?.description?{description:t.description}:{},...t?.website?{website:t.website}:{},...t?.email?{email:t.email}:{},...t?.story?{story:t.story}:{},...t?.socialLinks?{socialLinks:t.socialLinks.map((r)=>({platform:r.platform,url:r.url,...r.label?{label:r.label}:{}}))}:{}}}function IW(e){return e.split("-").filter((t)=>t.length>0).map((t)=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}async function AW(e,t){let r=Bu(e,"users",t,"brain.yaml");try{return await yW(r),"present"}catch{return"missing"}}async function y2(e){return(await bW(e,{withFileTypes:!0})).filter((r)=>r.isFile()&&r.name.endsWith(".yaml")).map((r)=>Bu(e,r.name)).sort((r,o)=>r.localeCompare(o))}async function HE(e,t){let r=await SW(e,"utf8"),o=lr(r,t);if(!o.ok)throw new As(`${S2(e)}: ${o.error}`);return o.data}function TW(e){return[...new Set(e)]}function b2(e){return e.replace(/\.ya?ml$/,"")}function S2(e){return e.replaceAll("\\","/")}var As;var Hr=v(()=>{Cn();Bn();As=class As extends Error{}});import{mkdir as RW,writeFile as $W}from"fs/promises";import{join as v2}from"path";async function po(e,t={}){let o=(t.registry??await ut(e,t)).users.map((i)=>{let s=i.discordEnabled?"on":"off";return[i.handle,i.cohort,i.bundles.join(","),i.add.join(","),i.remove.join(","),i.brainVersion,i.domain,i.contentRepo,s,i.serverStatus,i.deployStatus,i.dnsStatus,i.mcpStatus]}),n=["<!-- generated by brains-ops; do not edit -->","",OW,CW,...o.map((i)=>`| ${i.join(" | ")} |`),""].join(`
|
|
234
|
+
`);await RW(v2(e,"views"),{recursive:!0}),await $W(v2(e,"views","users.md"),n)}var OW="| handle | cohort | bundles | add | remove | brainVersion | domain | contentRepo | discord | serverStatus | deployStatus | dnsStatus | mcpStatus |",CW="| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |";var uc=v(()=>{Hr()});import{spawn as eG}from"child_process";var jt=async(e,t,r={})=>new Promise((o,n)=>{let i=eG(e,t,{stdio:["pipe","inherit","inherit"],env:r.env?{...process.env,...r.env}:process.env,cwd:r.cwd});if(i.on("error",n),i.on("close",(s)=>{if(s===0){o();return}n(Error(`${e} ${t.join(" ")} exited with code ${s??1}`))}),r.stdin)i.stdin.end(r.stdin);else i.stdin.end()});var jn=()=>{};async function E2(e,t,r=jt){let o=`${e}:${t.tag}`;try{await r("docker",["run","--rm","--pull","always","--network","none","--read-only","--user","65534:65534","--cap-drop","ALL","--security-opt","no-new-privileges","--entrypoint","bun",o,"-e",tG,"--",JSON.stringify([`@rizom/brain@${t.brainVersion}`,...t.sitePackages])])}catch(n){throw Error(`Cannot verify required packages in ${o}; refusing image reuse. Do not overwrite a deployed tag. Inspect the image inventory and rollout plan.`,{cause:n})}}var tG=`
|
|
235
235
|
const specs = JSON.parse(process.argv.at(-1));
|
|
236
236
|
for (const spec of specs) {
|
|
237
237
|
const separator = spec.lastIndexOf("@");
|
|
@@ -243,9 +243,9 @@ for (const spec of specs) {
|
|
|
243
243
|
throw new Error("Image requires " + spec + "; found " + manifest.name + "@" + manifest.version);
|
|
244
244
|
}
|
|
245
245
|
}
|
|
246
|
-
`;var k2=v(()=>{jn()});function ju(e){if(e===null||typeof e!=="object"||Array.isArray(e))return!1;let t=
|
|
246
|
+
`;var k2=v(()=>{jn()});function ju(e){if(e===null||typeof e!=="object"||Array.isArray(e))return!1;let t=rG(e);return t===Object.prototype||t===null}function nG(e){return e instanceof Error&&"code"in e&&typeof e.code==="string"}function ah(e){return nG(e)&&e.code==="ENOENT"}var rG;var Zu=v(()=>{rG=Object.getPrototypeOf});import{lstat as YE,mkdir as I2,readFile as A2,unlink as oG,writeFile as T2}from"fs/promises";import{join as dn}from"path";import{isDeepStrictEqual as iG}from"util";function C2(e){return dn("deploy","runtime",sG.parse(e.tag))}function P2(e){let t={"@rizom/brain":$t.parse(e.brainVersion)};for(let r of[...e.sitePackages].sort()){let o=r.lastIndexOf("@"),n=$2.parse(r.slice(0,o)),i=$t.parse(r.slice(o+1));if(t[n]!==void 0&&t[n]!==i)throw Error(`Conflicting runtime dependency pin: ${r}`);t[n]=i}return O2.parse({name:"rover-pilot-runtime",private:!0,packageManager:"bun@1.4.0",dependencies:t,overrides:{"postcss-selector-parser":"7.1.6"}})}async function XE(e){try{return await YE(e),!0}catch(t){if(ah(t))return!1;throw t}}async function R2(e){if(!(await YE(e)).isFile())throw Error(`Runtime lock input must be a regular file: ${e}`)}async function z2(e){if(!(await YE(e)).isDirectory())throw Error(`Runtime lock input must be a directory: ${e}`)}async function N2(e){for(let t of["deploy",dn("deploy","runtime")]){let r=dn(e,t);if(await XE(r))await z2(r)}}async function QE(e,t){let r=dn(e,"package.json"),o=dn(e,"bun.lock");await R2(r),await R2(o);let n=O2.parse(JSON.parse(await A2(r,"utf8")));if(!iG(n,P2(t)))throw Error(`Runtime dependency manifest does not match ${t.tag}`);if(!(await A2(o,"utf8")).trim())throw Error(`Empty runtime dependency lock: ${o}`)}async function ek(e,t){await N2(e);let r=dn(e,C2(t));if(await z2(r),await XE(dn(r,".incomplete")))throw Error(`Incomplete runtime dependency lock: ${r}`);await QE(r,t)}async function D2(e,t,r=jt){if(Bun.version!=="1.4.0")throw Error("Runtime dependency locks must be generated with Bun 1.4.0");let o=P2(t);await N2(e);let n=dn(e,C2(t));if(await XE(n))return await ek(e,t),"existing";await I2(dn(e,"deploy","runtime"),{recursive:!0}),await I2(n);let i=dn(n,".incomplete");return await T2(i,`Runtime dependency resolution has not completed.
|
|
247
247
|
`,{flag:"wx"}),await T2(dn(n,"package.json"),`${JSON.stringify(o,null,2)}
|
|
248
|
-
`,{flag:"wx"}),await r(process.execPath,["install","--lockfile-only","--ignore-scripts"],{cwd:n}),await QE(n,t),await r(process.execPath,["install","--frozen-lockfile","--ignore-scripts","--dry-run"],{cwd:n}),await QE(n,t),await nG(i),"created"}var iG,$2,O2;var tk=v(()=>{Zu();fe();Bn();jn();iG=l.string().regex(/^[a-zA-Z0-9_][a-zA-Z0-9_.-]{0,127}$/),$2=l.string().regex(/^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/),O2=l.strictObject({name:l.literal("rover-pilot-runtime"),private:l.literal(!0),packageManager:l.literal("bun@1.4.0"),dependencies:l.record($2,$t),overrides:l.strictObject({"postcss-selector-parser":l.literal("7.1.6")})})});import{createHash as sG}from"crypto";function Uu(e,t=[]){let r=`brain-${e}`,o=[...new Set(t)].sort();if(o.length===0)return r;let n=`${r}--${o.map((a)=>a.replace(/^@/,"").replace("/","-").replace(/@(?=[^@]*$)/,"-")).join("--")}`,s=`--s${sG("sha256").update(JSON.stringify([e,...o])).digest("hex").slice(0,12)}`;return`${n.length+s.length<=aG?n:r}${s}`}function ch(e){if(!e)return[];return[L2(e.package,e.version),L2(e.theme,e.themeVersion)].filter((t)=>t!==void 0)}function L2(e,t){if(!e?.startsWith("@rizom/"))return;if(t===void 0)throw Error(`Package ${e} has no explicit version pin`);return`${e}@${t}`}function B2(e){let t=new Map;for(let r of e){let o=[...new Set(ch(r.siteOverride))].sort(),n=Uu(r.brainVersion,o),i=t.get(n);if(i&&(i.brainVersion!==r.brainVersion||!Bun.deepEquals(i.sitePackages,o)))throw Error(`Image tag collision for distinct runtime requirements: ${n}`);t.set(n,{tag:n,brainVersion:r.brainVersion,sitePackages:o})}return[...t.values()].sort((r,o)=>r.tag.localeCompare(o.tag))}function cG(e,t){let r=new Map;for(let o of[...e,...t]){let n=o.lastIndexOf("@"),i=n>0?o.slice(0,n):o,s=r.get(i);if(s&&s!==o)throw Error(`Fleet shared images have conflicting pins for ${i}: ${s} and ${o}`);r.set(i,o)}return[...r.values()].sort()}async function lh(e){let t=e.brainVersionInput?.trim()??"";if(t){let o=cG([],(e.sitePackagesInput??"").split(/\s+/).filter(Boolean)),n=Uu(t,o);if(!e.allowTagOverwrite&&await e.imageExists(n))throw Error(`Image tag ${n} already exists; published tags are immutable. Pick a new version, or pass overwrite=true only when replacing a tag whose containers were never deployed.`);return[{tag:n,brainVersion:t,sitePackages:o}]}let r=[];for(let o of B2(e.users))if(!await e.imageExists(o.tag))r.push(o);else await e.verifyImage(o);return r}async function lG(e,t,r){try{return await e("docker",["manifest","inspect",`${t}:${r}`]),!0}catch(o){if(o instanceof Error&&/exited with code/.test(o.message))return!1;throw o}}async function uG(e){let t=e.env??process.env,r=e.runCommand??jt,o=e.log??console.log,n=t.BRAIN_VERSION_INPUT?.trim()??"",i=t.SITE_PACKAGES_INPUT?.trim()??"",s=t.ALLOW_TAG_OVERWRITE?.trim()==="true",{users:a}=await ut(e.rootDir),c=await lh({users:a,brainVersionInput:n,sitePackagesInput:i,allowTagOverwrite:s,imageExists:(u)=>lG(r,e.imageRepository,u),verifyImage:(u)=>E2(e.imageRepository,u,r)});for(let u of c){try{await ek(e.rootDir,u)}catch(d){throw Error(`Missing or invalid runtime lock for ${u.tag}; run brains-ops images:lock and commit its reviewed package.json and bun.lock before building.`,{cause:d})}o(`build needed: ${u.tag} (brain ${u.brainVersion}${u.sitePackages.length>0?`, sites ${u.sitePackages.join(" ")}`:""})`)}if(c.length===0)o("All declared images already exist; nothing to build.");return e.writeOutput("images_json",JSON.stringify(c.map((u)=>({tag:u.tag,brain_version:u.brainVersion,site_packages:u.sitePackages.join(" ")})))),c}var aG=128;var uh=v(()=>{k2();tk();Hr();jn()});var Z2,dG,pG,fG,mo,Mu,mG,rk,hG,j2,gG,yG,U2,$Ee,M2;var dh=v(()=>{EE();Z2=["primary","secondary"],dG=l.custom((e)=>typeof e==="function","Expected a React component"),pG=l.strictObject({show:l.boolean().optional(),label:l.string().min(1).optional(),slot:l.enum(Z2).optional(),priority:l.number().optional()}),fG=l.strictObject({id:l.string().min(1),template:l.string().min(1),content:l.unknown().optional(),dataQuery:l.looseObject({entityType:l.string().optional(),template:l.string().optional(),query:l.record(l.string(),l.unknown()).optional()}).optional(),order:l.number().optional()}),mo=l.string().regex(/^[A-Za-z]{2,3}(-[A-Za-z0-9]{2,8})*$/,{message:"must be a language tag such as en or zh-TW"}),Mu=l.strictObject({title:l.string().optional(),description:l.string().optional(),navigationLabel:l.string().optional()}),mG=l.strictObject({id:l.string().min(1),path:l.string().startsWith("/"),title:l.string().optional(),pageLabel:l.string().optional(),description:l.string().optional(),sections:l.array(fG).optional(),layout:l.string().min(1).optional(),fullscreen:l.boolean().optional(),pluginId:l.string().optional(),sourceEntityType:l.string().optional(),external:l.boolean().optional(),navigation:pG.optional(),translations:l.record(mo,Mu).optional()}),rk=l.strictObject({label:l.string().min(1),pluralName:l.string().min(1).optional(),layout:l.string().min(1).optional(),detailTemplate:l.string().min(1).optional(),paginate:l.boolean().optional(),pageSize:l.number().int().positive().optional(),citable:l.boolean().optional(),navigation:l.strictObject({show:l.boolean().optional(),slot:l.enum(Z2).optional(),priority:l.number().optional()}).optional()}),hG=l.strictObject({schema:l.custom((e)=>e instanceof l.ZodType,"Expected a Zod schema"),component:l.custom((e)=>typeof e==="function","Expected a React component"),title:l.string().min(1),description:l.string(),requiredPermission:l.enum(["admin","trusted","public"]).optional(),fullscreen:l.boolean().optional()}),j2=l.strictObject({namespace:l.string().min(1),sections:l.record(l.string(),hG)}),gG=l.record(l.string(),l.json()),yG=l.record(l.string(),l.record(l.string(),gG)),U2={layouts:l.record(l.string(),dG).refine((e)=>typeof e.default==="function",{message:'Site layouts must include a "default" component'}),routes:l.array(mG),content:yG.optional(),sections:l.union([j2,l.array(j2)]).optional(),themeOverride:l.string().optional(),headScripts:l.array(l.string()).optional(),entityDisplay:l.record(l.string(),rk),staticAssets:l.record(l.string(),l.string()).optional(),languages:l.array(mo).min(1).optional()},$Ee=l.strictObject(U2).partial(),M2=l.strictObject(U2).superRefine((e,t)=>{let r=e.languages??[],o=new Set;for(let[c,u]of r.entries()){let d=u.toLowerCase();if(o.has(d))t.addIssue({code:"custom",path:["languages",c],message:`Language "${u}" is declared twice`});o.add(d)}let n=r.slice(1).map((c)=>`/${c.toLowerCase()}`),i=new Set;for(let[c,u]of e.routes.entries()){if(i.has(u.id))t.addIssue({code:"custom",path:["routes",c,"id"],message:`Duplicate route id "${u.id}"`});i.add(u.id);let d=u.path.toLowerCase(),p=n.find((h)=>d===h||d.startsWith(`${h}/`));if(p)t.addIssue({code:"custom",path:["routes",c,"path"],message:`Route path "${u.path}" is under ${p}, where another language's pages are built`});let m=u.layout??"default";if(!e.layouts[m])t.addIssue({code:"custom",path:["routes",c,"layout"],message:`Unknown layout "${m}"`});for(let[h,b]of(u.sections??[]).entries()){let y=/^([^:.\s]+)\.([^:.\s]+)$/.exec(b.template);if(y)t.addIssue({code:"custom",path:["routes",c,"sections",h,"template"],message:`Section template "${b.template}" is written "${y[1]}:${y[2]}"`})}}let s=Array.isArray(e.sections)?e.sections:e.sections?[e.sections]:[],a=new Map(s.map((c)=>[c.namespace,c]));if(a.size!==s.length)t.addIssue({code:"custom",path:["sections"],message:"Section group namespaces must be unique"});for(let[c,u]of Object.entries(e.content??{})){let d=a.get(c);if(!d){t.addIssue({code:"custom",path:["content",c],message:`Content namespace "${c}" has no section group`});continue}for(let[p,m]of Object.entries(u)){let h=d.sections[p];if(!h){t.addIssue({code:"custom",path:["content",c,p],message:`Content section "${c}:${p}" is not defined`});continue}let b=h.schema.safeParse(m);if(!b.success)t.addIssue({code:"custom",path:["content",c,p],message:`Content does not satisfy the "${c}:${p}" schema: ${l.prettifyError(b.error)}`})}}})});var q2,F2,K2,ph,H2,SG,J2,V2,vG,W2,G2,wG,fh;var nk=v(()=>{Rt();fe();dh();dh();q2=l.object({id:l.string(),template:l.string(),content:l.unknown().optional(),dataQuery:l.looseObject({entityType:l.string().optional(),template:l.string().optional(),query:l.looseObject({id:l.string().optional(),limit:l.number().optional(),offset:l.number().optional()}).optional()}).optional(),order:l.number().optional()}),F2=["primary","secondary"],K2=l.object({show:l.boolean().default(!1),label:l.string().optional(),slot:l.enum(F2).default("primary"),priority:l.number().min(0).max(100).default(50)}).optional(),ph=l.object({id:l.string(),path:l.string(),title:l.string().default(""),pageLabel:l.string().optional(),description:l.string().default(""),sections:l.array(q2).default([]),layout:l.string().default("default"),fullscreen:l.boolean().optional(),pluginId:l.string().optional(),sourceEntityType:l.string().optional(),external:l.boolean().optional(),navigation:K2,translations:l.record(mo,Mu).optional(),languages:l.array(mo).optional()}),H2=l.object({routes:l.array(ph),pluginId:l.string()}),SG=Ee({channel:"plugin:site-builder:route:register",request:H2,response:l.void(),delivery:"command"}),J2=l.strictObject({}),V2=l.array(ph),vG=Ee({channel:"site-builder:routes:list",request:J2,response:V2,delivery:"request"}),W2=l.strictObject({}),G2=l.array(ph),wG=Ee({channel:"plugin:site-builder:pages",request:W2,response:G2,delivery:"collect"}),fh=l.object({label:l.string(),href:l.string(),priority:l.number()})});var Q2,Y2,X2,xG;var eD=v(()=>{Rt();fe();Q2=l.object({pluginId:l.string(),slotName:l.string(),render:l.custom((e)=>typeof e==="function"),priority:l.number().optional()}),Y2=l.strictObject({}),X2=l.array(Q2),xG=Ee({channel:"plugin:site-builder:slots",request:Y2,response:X2,delivery:"collect"})});var tD="site:metadata:updated",mh,rD,nD,pc,oD,_G,EG,kG;var ok=v(()=>{Rt();fe();nk();mh=l.object({heading:l.string().describe("Main CTA heading text"),buttonText:l.string().describe("Call-to-action button text"),buttonLink:l.string().describe("URL or anchor for the CTA button")}),rD=l.object({title:l.string().optional(),description:l.string().optional(),copyright:l.string().optional(),cta:mh.optional()}),nD=l.object({blurb:l.string().optional().describe("Short italic subtitle under the section title")}),pc=l.object({represents:l.enum(["brain","anchor"]).default("anchor").describe("Identity represented by the site"),title:l.string().describe("The site's title"),description:l.string().describe("The site's description"),url:l.string().optional().describe("Canonical site URL"),copyright:l.string().optional().describe("Copyright notice text"),logo:l.boolean().optional().describe("Whether to display logo instead of title text in header"),themeMode:l.enum(["light","dark"]).optional().describe("Default theme mode"),analyticsScript:l.string().optional().describe("Analytics script HTML"),cta:mh.optional().describe("Call-to-action configuration"),sections:l.record(l.string(),nD).optional().describe("Optional per-section blurbs, keyed by section id (e.g. 'essays', 'presentations', 'about'). Used by homepage templates that render editorial section headers."),translations:l.record(mo,rD).optional().describe("The site's title, description, copyright and call to action in its other languages, keyed by language tag. A site is built in a language only once it has one.")}),oD=l.strictObject({}),_G=Ee({channel:"site:metadata:get",request:oD,response:pc,delivery:"request"}),EG=ui(tD,pc),kG=pc.extend({copyright:l.string(),navigation:l.object({primary:l.array(fh),secondary:l.array(fh)}),socialLinks:l.array(qE).optional().describe("Social media links from profile metadata"),photo:l.string().optional().describe("The anchor's photo, as ")})});var KEe;var ik=v(()=>{fe();KEe=l.record(l.string(),l.unknown())});var qu=v(()=>{ik()});var iD=v(()=>{Rt();qu()});var sD=v(()=>{qu();Rt()});var aD=v(()=>{qu();Rt()});var ake;var cD=v(()=>{fe();ake=l.record(l.string(),l.unknown())});var uke;var lD=v(()=>{fe();Ta();uke=l.record(l.string(),l.unknown())});var uD=v(()=>{Ta()});var dD=v(()=>{qu();iD();sD();aD();cD();lD();uD();ik()});var NG;var pD=v(()=>{fe();NG=l.object({slug:l.string(),title:l.string(),type:l.string(),entityId:l.string(),contentHash:l.string()})});var ak=v(()=>{dD();pD()});var fD=v(()=>{ak();fe()});var DG,LG,BG;var gh=v(()=>{fe();Rt();DG={url:l.string(),typeLabel:l.string(),listUrl:l.string(),listLabel:l.string()},LG={url:l.string().nullable().default(null),typeLabel:l.string().nullable().default(null),listUrl:l.string().nullable().default(null),listLabel:l.string().nullable().default(null)},BG=l.object({name:l.string(),description:l.string(),schema:l.unknown(),basePrompt:l.string().optional(),useKnowledgeContext:l.boolean().optional(),requiredPermission:l.enum(["admin","trusted","public"]),formatter:l.unknown().optional(),overlayFormatter:l.unknown().optional(),layout:l.object({component:l.unknown().optional(),fullscreen:l.boolean().optional(),formats:l.unknown().optional()}).optional(),dataSourceId:l.string().optional()})});var yh=v(()=>{gh()});var gD=v(()=>{yh()});var ck=()=>{};var ZG,UG,fc,yD,MG;var bD=v(()=>{Rt();fe();ck();ZG=l.enum(["admin","trusted","public"]),UG=l.enum(["create","update","delete","extract","publish"]),fc=l.enum(["never","admin","trusted","public"]),yD=l.strictObject({create:fc.optional(),update:fc.optional(),delete:fc.optional(),extract:fc.optional(),publish:fc.optional()}),MG=l.record(l.string(),yD)});var SD=v(()=>{yh();gh()});var qG,FG,bh,KG,HG,JG;var vD=v(()=>{fe();qG=l.enum(["site-content-preview","site-content-production"]),FG=l.enum(["web","image","pdf","epub"]),bh=l.custom((e)=>typeof e==="function"),KG=l.object({name:l.string(),schema:l.unknown(),description:l.string().optional(),pluginId:l.string(),renderers:l.object({web:l.union([bh,l.string()]).optional(),image:l.union([bh,l.string()]).optional(),pdf:l.union([bh,l.string()]).optional(),epub:l.union([bh,l.string()]).optional()})}),HG=l.object({enableContentGeneration:l.boolean().default(!1),outputDir:l.string(),workingDir:l.string().optional(),environment:l.enum(["preview","production"]).default("preview"),siteConfig:l.object({title:l.string(),description:l.string(),url:l.string().optional()}).optional()}),JG=l.object({success:l.boolean(),routesBuilt:l.number(),errors:l.array(l.string()).optional(),warnings:l.array(l.string()).optional()})});var wD=v(()=>{gh();gD();yh();bD();ck();SD();vD()});var lk=ge(function(WG,Sh){(function(){function e(g,E){Object.defineProperty(o.prototype,g,{get:function(){console.warn("%s(...) is deprecated in plain JavaScript React classes. %s",E[0],E[1])}})}function t(g){if(g===null||typeof g!=="object")return null;return g=De&&g[De]||g["@@iterator"],typeof g==="function"?g:null}function r(g,E){g=(g=g.constructor)&&(g.displayName||g.name)||"ReactClass";var D=g+"."+E;Qe[D]||(console.error("Can't call %s on a component that is not yet mounted. This is a no-op, but it might indicate a bug in your application. Instead, assign to `this.state` directly or define a `state = {};` class property with the desired state in the %s component.",E,g),Qe[D]=!0)}function o(g,E,D){this.props=g,this.context=E,this.refs=Dt,this.updater=D||St}function n(){}function i(g,E,D){this.props=g,this.context=E,this.refs=Dt,this.updater=D||St}function s(){}function a(g){return""+g}function c(g){try{a(g);var E=!1}catch(M){E=!0}if(E){E=console;var D=E.error,K=typeof Symbol==="function"&&Symbol.toStringTag&&g[Symbol.toStringTag]||g.constructor.name||"Object";return D.call(E,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",K),a(g)}}function u(g){if(g==null)return null;if(typeof g==="function")return g.$$typeof===Rn?null:g.displayName||g.name||null;if(typeof g==="string")return g;switch(g){case J:return"Fragment";case re:return"Profiler";case G:return"StrictMode";case ve:return"Suspense";case Ae:return"SuspenseList";case Ue:return"Activity"}if(typeof g==="object")switch(typeof g.tag==="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),g.$$typeof){case N:return"Portal";case me:return g.displayName||"Context";case ae:return(g._context.displayName||"Context")+".Consumer";case be:var E=g.render;return g=g.displayName,g||(g=E.displayName||E.name||"",g=g!==""?"ForwardRef("+g+")":"ForwardRef"),g;case Ie:return E=g.displayName||null,E!==null?E:u(g.type)||"Memo";case we:E=g._payload,g=g._init;try{return u(g(E))}catch(D){}}return null}function d(g){if(g===J)return"<>";if(typeof g==="object"&&g!==null&&g.$$typeof===we)return"<...>";try{var E=u(g);return E?"<"+E+">":"<...>"}catch(D){return"<...>"}}function p(){var g=Le.A;return g===null?null:g.getOwner()}function m(){return Error("react-stack-top-frame")}function h(g){if(so.call(g,"key")){var E=Object.getOwnPropertyDescriptor(g,"key").get;if(E&&E.isReactWarning)return!1}return g.key!==void 0}function b(g,E){function D(){us||(us=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",E))}D.isReactWarning=!0,Object.defineProperty(g,"key",{get:D,configurable:!0})}function y(){var g=u(this.type);return ds[g]||(ds[g]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),g=this.props.ref,g!==void 0?g:null}function S(g,E,D,K,M,te){var se=D.ref;return g={$$typeof:q,type:g,key:E,props:D,_owner:K},(se!==void 0?se:null)!==null?Object.defineProperty(g,"ref",{enumerable:!1,get:y}):Object.defineProperty(g,"ref",{enumerable:!1,value:null}),g._store={},Object.defineProperty(g._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(g,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(g,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:M}),Object.defineProperty(g,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:te}),Object.freeze&&(Object.freeze(g.props),Object.freeze(g)),g}function x(g,E){return E=S(g.type,E,g.props,g._owner,g._debugStack,g._debugTask),g._store&&(E._store.validated=g._store.validated),E}function _(g){A(g)?g._store&&(g._store.validated=1):typeof g==="object"&&g!==null&&g.$$typeof===we&&(g._payload.status==="fulfilled"?A(g._payload.value)&&g._payload.value._store&&(g._payload.value._store.validated=1):g._store&&(g._store.validated=1))}function A(g){return typeof g==="object"&&g!==null&&g.$$typeof===q}function O(g){var E={"=":"=0",":":"=2"};return"$"+g.replace(/[=:]/g,function(D){return E[D]})}function L(g,E){return typeof g==="object"&&g!==null&&g.key!=null?(c(g.key),O(""+g.key)):E.toString(36)}function z(g){switch(g.status){case"fulfilled":return g.value;case"rejected":throw g.reason;default:switch(typeof g.status==="string"?g.then(s,s):(g.status="pending",g.then(function(E){g.status==="pending"&&(g.status="fulfilled",g.value=E)},function(E){g.status==="pending"&&(g.status="rejected",g.reason=E)})),g.status){case"fulfilled":return g.value;case"rejected":throw g.reason}}throw g}function H(g,E,D,K,M){var te=typeof g;if(te==="undefined"||te==="boolean")g=null;var se=!1;if(g===null)se=!0;else switch(te){case"bigint":case"string":case"number":se=!0;break;case"object":switch(g.$$typeof){case q:case N:se=!0;break;case we:return se=g._init,H(se(g._payload),E,D,K,M)}}if(se){se=g,M=M(se);var ye=K===""?"."+L(se,0):K;return $r(M)?(D="",ye!=null&&(D=ye.replace(xa,"$&/")+"/"),H(M,E,D,"",function(Re){return Re})):M!=null&&(A(M)&&(M.key!=null&&(se&&se.key===M.key||c(M.key)),D=x(M,D+(M.key==null||se&&se.key===M.key?"":(""+M.key).replace(xa,"$&/")+"/")+ye),K!==""&&se!=null&&A(se)&&se.key==null&&se._store&&!se._store.validated&&(D._store.validated=2),M=D),E.push(M)),1}if(se=0,ye=K===""?".":K+":",$r(g))for(var pe=0;pe<g.length;pe++)K=g[pe],te=ye+L(K,pe),se+=H(K,E,D,te,M);else if(pe=t(g),typeof pe==="function")for(pe===g.entries&&(Wo||console.warn("Using Maps as children is not supported. Use an array of keyed ReactElements instead."),Wo=!0),g=pe.call(g),pe=0;!(K=g.next()).done;)K=K.value,te=ye+L(K,pe++),se+=H(K,E,D,te,M);else if(te==="object"){if(typeof g.then==="function")return H(z(g),E,D,K,M);throw E=String(g),Error("Objects are not valid as a React child (found: "+(E==="[object Object]"?"object with keys {"+Object.keys(g).join(", ")+"}":E)+"). If you meant to render a collection of children, use an array instead.")}return se}function P(g,E,D){if(g==null)return g;var K=[],M=0;return H(g,K,"","",function(te){return E.call(D,te,M++)}),K}function W(g){if(g._status===-1){var E=g._ioInfo;E!=null&&(E.start=E.end=performance.now()),E=g._result;var D=E();if(D.then(function(M){if(g._status===0||g._status===-1){g._status=1,g._result=M;var te=g._ioInfo;te!=null&&(te.end=performance.now()),D.status===void 0&&(D.status="fulfilled",D.value=M)}},function(M){if(g._status===0||g._status===-1){g._status=2,g._result=M;var te=g._ioInfo;te!=null&&(te.end=performance.now()),D.status===void 0&&(D.status="rejected",D.reason=M)}}),E=g._ioInfo,E!=null){E.value=D;var K=D.displayName;typeof K==="string"&&(E.name=K)}g._status===-1&&(g._status=0,g._result=D)}if(g._status===1)return E=g._result,E===void 0&&console.error(`lazy: Expected the result of a dynamic import() call. Instead received: %s
|
|
248
|
+
`,{flag:"wx"}),await r(process.execPath,["install","--lockfile-only","--ignore-scripts"],{cwd:n}),await QE(n,t),await r(process.execPath,["install","--frozen-lockfile","--ignore-scripts","--dry-run"],{cwd:n}),await QE(n,t),await oG(i),"created"}var sG,$2,O2;var tk=v(()=>{Zu();fe();Bn();jn();sG=l.string().regex(/^[a-zA-Z0-9_][a-zA-Z0-9_.-]{0,127}$/),$2=l.string().regex(/^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/),O2=l.strictObject({name:l.literal("rover-pilot-runtime"),private:l.literal(!0),packageManager:l.literal("bun@1.4.0"),dependencies:l.record($2,$t),overrides:l.strictObject({"postcss-selector-parser":l.literal("7.1.6")})})});import{createHash as aG}from"crypto";function Uu(e,t=[]){let r=`brain-${e}`,o=[...new Set(t)].sort();if(o.length===0)return r;let n=`${r}--${o.map((a)=>a.replace(/^@/,"").replace("/","-").replace(/@(?=[^@]*$)/,"-")).join("--")}`,s=`--s${aG("sha256").update(JSON.stringify([e,...o])).digest("hex").slice(0,12)}`;return`${n.length+s.length<=cG?n:r}${s}`}function ch(e){if(!e)return[];return[L2(e.package,e.version),L2(e.theme,e.themeVersion)].filter((t)=>t!==void 0)}function L2(e,t){if(!e?.startsWith("@rizom/"))return;if(t===void 0)throw Error(`Package ${e} has no explicit version pin`);return`${e}@${t}`}function B2(e){let t=new Map;for(let r of e){let o=[...new Set(ch(r.siteOverride))].sort(),n=Uu(r.brainVersion,o),i=t.get(n);if(i&&(i.brainVersion!==r.brainVersion||!Bun.deepEquals(i.sitePackages,o)))throw Error(`Image tag collision for distinct runtime requirements: ${n}`);t.set(n,{tag:n,brainVersion:r.brainVersion,sitePackages:o})}return[...t.values()].sort((r,o)=>r.tag.localeCompare(o.tag))}function lG(e,t){let r=new Map;for(let o of[...e,...t]){let n=o.lastIndexOf("@"),i=n>0?o.slice(0,n):o,s=r.get(i);if(s&&s!==o)throw Error(`Fleet shared images have conflicting pins for ${i}: ${s} and ${o}`);r.set(i,o)}return[...r.values()].sort()}async function lh(e){let t=e.brainVersionInput?.trim()??"";if(t){let o=lG([],(e.sitePackagesInput??"").split(/\s+/).filter(Boolean)),n=Uu(t,o);if(!e.allowTagOverwrite&&await e.imageExists(n))throw Error(`Image tag ${n} already exists; published tags are immutable. Pick a new version, or pass overwrite=true only when replacing a tag whose containers were never deployed.`);return[{tag:n,brainVersion:t,sitePackages:o}]}let r=[];for(let o of B2(e.users))if(!await e.imageExists(o.tag))r.push(o);else await e.verifyImage(o);return r}async function uG(e,t,r){try{return await e("docker",["manifest","inspect",`${t}:${r}`]),!0}catch(o){if(o instanceof Error&&/exited with code/.test(o.message))return!1;throw o}}async function dG(e){let t=e.env??process.env,r=e.runCommand??jt,o=e.log??console.log,n=t.BRAIN_VERSION_INPUT?.trim()??"",i=t.SITE_PACKAGES_INPUT?.trim()??"",s=t.ALLOW_TAG_OVERWRITE?.trim()==="true",{users:a}=await ut(e.rootDir),c=await lh({users:a,brainVersionInput:n,sitePackagesInput:i,allowTagOverwrite:s,imageExists:(u)=>uG(r,e.imageRepository,u),verifyImage:(u)=>E2(e.imageRepository,u,r)});for(let u of c){try{await ek(e.rootDir,u)}catch(d){throw Error(`Missing or invalid runtime lock for ${u.tag}; run brains-ops images:lock and commit its reviewed package.json and bun.lock before building.`,{cause:d})}o(`build needed: ${u.tag} (brain ${u.brainVersion}${u.sitePackages.length>0?`, sites ${u.sitePackages.join(" ")}`:""})`)}if(c.length===0)o("All declared images already exist; nothing to build.");return e.writeOutput("images_json",JSON.stringify(c.map((u)=>({tag:u.tag,brain_version:u.brainVersion,site_packages:u.sitePackages.join(" ")})))),c}var cG=128;var uh=v(()=>{k2();tk();Hr();jn()});var Z2,pG,fG,mG,mo,Mu,hG,rk,gG,j2,yG,bG,U2,OEe,M2;var dh=v(()=>{EE();Z2=["primary","secondary"],pG=l.custom((e)=>typeof e==="function","Expected a React component"),fG=l.strictObject({show:l.boolean().optional(),label:l.string().min(1).optional(),slot:l.enum(Z2).optional(),priority:l.number().optional()}),mG=l.strictObject({id:l.string().min(1),template:l.string().min(1),content:l.unknown().optional(),dataQuery:l.looseObject({entityType:l.string().optional(),template:l.string().optional(),query:l.record(l.string(),l.unknown()).optional()}).optional(),order:l.number().optional()}),mo=l.string().regex(/^[A-Za-z]{2,3}(-[A-Za-z0-9]{2,8})*$/,{message:"must be a language tag such as en or zh-TW"}),Mu=l.strictObject({title:l.string().optional(),description:l.string().optional(),navigationLabel:l.string().optional()}),hG=l.strictObject({id:l.string().min(1),path:l.string().startsWith("/"),title:l.string().optional(),pageLabel:l.string().optional(),description:l.string().optional(),sections:l.array(mG).optional(),layout:l.string().min(1).optional(),fullscreen:l.boolean().optional(),pluginId:l.string().optional(),sourceEntityType:l.string().optional(),external:l.boolean().optional(),navigation:fG.optional(),translations:l.record(mo,Mu).optional()}),rk=l.strictObject({label:l.string().min(1),pluralName:l.string().min(1).optional(),layout:l.string().min(1).optional(),detailTemplate:l.string().min(1).optional(),paginate:l.boolean().optional(),pageSize:l.number().int().positive().optional(),citable:l.boolean().optional(),navigation:l.strictObject({show:l.boolean().optional(),slot:l.enum(Z2).optional(),priority:l.number().optional()}).optional()}),gG=l.strictObject({schema:l.custom((e)=>e instanceof l.ZodType,"Expected a Zod schema"),component:l.custom((e)=>typeof e==="function","Expected a React component"),title:l.string().min(1),description:l.string(),requiredPermission:l.enum(["admin","trusted","public"]).optional(),fullscreen:l.boolean().optional()}),j2=l.strictObject({namespace:l.string().min(1),sections:l.record(l.string(),gG)}),yG=l.record(l.string(),l.json()),bG=l.record(l.string(),l.record(l.string(),yG)),U2={layouts:l.record(l.string(),pG).refine((e)=>typeof e.default==="function",{message:'Site layouts must include a "default" component'}),routes:l.array(hG),content:bG.optional(),sections:l.union([j2,l.array(j2)]).optional(),themeOverride:l.string().optional(),headScripts:l.array(l.string()).optional(),entityDisplay:l.record(l.string(),rk),staticAssets:l.record(l.string(),l.string()).optional(),languages:l.array(mo).min(1).optional()},OEe=l.strictObject(U2).partial(),M2=l.strictObject(U2).superRefine((e,t)=>{let r=e.languages??[],o=new Set;for(let[c,u]of r.entries()){let d=u.toLowerCase();if(o.has(d))t.addIssue({code:"custom",path:["languages",c],message:`Language "${u}" is declared twice`});o.add(d)}let n=r.slice(1).map((c)=>`/${c.toLowerCase()}`),i=new Set;for(let[c,u]of e.routes.entries()){if(i.has(u.id))t.addIssue({code:"custom",path:["routes",c,"id"],message:`Duplicate route id "${u.id}"`});i.add(u.id);let d=u.path.toLowerCase(),p=n.find((h)=>d===h||d.startsWith(`${h}/`));if(p)t.addIssue({code:"custom",path:["routes",c,"path"],message:`Route path "${u.path}" is under ${p}, where another language's pages are built`});let m=u.layout??"default";if(!e.layouts[m])t.addIssue({code:"custom",path:["routes",c,"layout"],message:`Unknown layout "${m}"`});for(let[h,b]of(u.sections??[]).entries()){let y=/^([^:.\s]+)\.([^:.\s]+)$/.exec(b.template);if(y)t.addIssue({code:"custom",path:["routes",c,"sections",h,"template"],message:`Section template "${b.template}" is written "${y[1]}:${y[2]}"`})}}let s=Array.isArray(e.sections)?e.sections:e.sections?[e.sections]:[],a=new Map(s.map((c)=>[c.namespace,c]));if(a.size!==s.length)t.addIssue({code:"custom",path:["sections"],message:"Section group namespaces must be unique"});for(let[c,u]of Object.entries(e.content??{})){let d=a.get(c);if(!d){t.addIssue({code:"custom",path:["content",c],message:`Content namespace "${c}" has no section group`});continue}for(let[p,m]of Object.entries(u)){let h=d.sections[p];if(!h){t.addIssue({code:"custom",path:["content",c,p],message:`Content section "${c}:${p}" is not defined`});continue}let b=h.schema.safeParse(m);if(!b.success)t.addIssue({code:"custom",path:["content",c,p],message:`Content does not satisfy the "${c}:${p}" schema: ${l.prettifyError(b.error)}`})}}})});var q2,F2,K2,ph,H2,vG,J2,V2,wG,W2,G2,xG,fh;var nk=v(()=>{Rt();fe();dh();dh();q2=l.object({id:l.string(),template:l.string(),content:l.unknown().optional(),dataQuery:l.looseObject({entityType:l.string().optional(),template:l.string().optional(),query:l.looseObject({id:l.string().optional(),limit:l.number().optional(),offset:l.number().optional()}).optional()}).optional(),order:l.number().optional()}),F2=["primary","secondary"],K2=l.object({show:l.boolean().default(!1),label:l.string().optional(),slot:l.enum(F2).default("primary"),priority:l.number().min(0).max(100).default(50)}).optional(),ph=l.object({id:l.string(),path:l.string(),title:l.string().default(""),pageLabel:l.string().optional(),description:l.string().default(""),sections:l.array(q2).default([]),layout:l.string().default("default"),fullscreen:l.boolean().optional(),pluginId:l.string().optional(),sourceEntityType:l.string().optional(),external:l.boolean().optional(),navigation:K2,translations:l.record(mo,Mu).optional(),languages:l.array(mo).optional()}),H2=l.object({routes:l.array(ph),pluginId:l.string()}),vG=Ee({channel:"plugin:site-builder:route:register",request:H2,response:l.void(),delivery:"command"}),J2=l.strictObject({}),V2=l.array(ph),wG=Ee({channel:"site-builder:routes:list",request:J2,response:V2,delivery:"request"}),W2=l.strictObject({}),G2=l.array(ph),xG=Ee({channel:"plugin:site-builder:pages",request:W2,response:G2,delivery:"collect"}),fh=l.object({label:l.string(),href:l.string(),priority:l.number()})});var Q2,Y2,X2,_G;var eD=v(()=>{Rt();fe();Q2=l.object({pluginId:l.string(),slotName:l.string(),render:l.custom((e)=>typeof e==="function"),priority:l.number().optional()}),Y2=l.strictObject({}),X2=l.array(Q2),_G=Ee({channel:"plugin:site-builder:slots",request:Y2,response:X2,delivery:"collect"})});var tD="site:metadata:updated",mh,rD,nD,pc,oD,EG,kG,IG;var ok=v(()=>{Rt();fe();nk();mh=l.object({heading:l.string().describe("Main CTA heading text"),buttonText:l.string().describe("Call-to-action button text"),buttonLink:l.string().describe("URL or anchor for the CTA button")}),rD=l.object({title:l.string().optional(),description:l.string().optional(),copyright:l.string().optional(),cta:mh.optional()}),nD=l.object({blurb:l.string().optional().describe("Short italic subtitle under the section title")}),pc=l.object({represents:l.enum(["brain","anchor"]).default("anchor").describe("Identity represented by the site"),title:l.string().describe("The site's title"),description:l.string().describe("The site's description"),url:l.string().optional().describe("Canonical site URL"),copyright:l.string().optional().describe("Copyright notice text"),logo:l.boolean().optional().describe("Whether to display logo instead of title text in header"),themeMode:l.enum(["light","dark"]).optional().describe("Default theme mode"),analyticsScript:l.string().optional().describe("Analytics script HTML"),cta:mh.optional().describe("Call-to-action configuration"),sections:l.record(l.string(),nD).optional().describe("Optional per-section blurbs, keyed by section id (e.g. 'essays', 'presentations', 'about'). Used by homepage templates that render editorial section headers."),translations:l.record(mo,rD).optional().describe("The site's title, description, copyright and call to action in its other languages, keyed by language tag. A site is built in a language only once it has one.")}),oD=l.strictObject({}),EG=Ee({channel:"site:metadata:get",request:oD,response:pc,delivery:"request"}),kG=ui(tD,pc),IG=pc.extend({copyright:l.string(),navigation:l.object({primary:l.array(fh),secondary:l.array(fh)}),socialLinks:l.array(qE).optional().describe("Social media links from profile metadata"),photo:l.string().optional().describe("The anchor's photo, as ")})});var HEe;var ik=v(()=>{fe();HEe=l.record(l.string(),l.unknown())});var qu=v(()=>{ik()});var iD=v(()=>{Rt();qu()});var sD=v(()=>{qu();Rt()});var aD=v(()=>{qu();Rt()});var cke;var cD=v(()=>{fe();cke=l.record(l.string(),l.unknown())});var dke;var lD=v(()=>{fe();Ta();dke=l.record(l.string(),l.unknown())});var uD=v(()=>{Ta()});var dD=v(()=>{qu();iD();sD();aD();cD();lD();uD();ik()});var DG;var pD=v(()=>{fe();DG=l.object({slug:l.string(),title:l.string(),type:l.string(),entityId:l.string(),contentHash:l.string()})});var ak=v(()=>{dD();pD()});var fD=v(()=>{ak();fe()});var LG,BG,jG;var gh=v(()=>{fe();Rt();LG={url:l.string(),typeLabel:l.string(),listUrl:l.string(),listLabel:l.string()},BG={url:l.string().nullable().default(null),typeLabel:l.string().nullable().default(null),listUrl:l.string().nullable().default(null),listLabel:l.string().nullable().default(null)},jG=l.object({name:l.string(),description:l.string(),schema:l.unknown(),basePrompt:l.string().optional(),useKnowledgeContext:l.boolean().optional(),requiredPermission:l.enum(["admin","trusted","public"]),formatter:l.unknown().optional(),overlayFormatter:l.unknown().optional(),layout:l.object({component:l.unknown().optional(),fullscreen:l.boolean().optional(),formats:l.unknown().optional()}).optional(),dataSourceId:l.string().optional()})});var yh=v(()=>{gh()});var gD=v(()=>{yh()});var ck=()=>{};var UG,MG,fc,yD,qG;var bD=v(()=>{Rt();fe();ck();UG=l.enum(["admin","trusted","public"]),MG=l.enum(["create","update","delete","extract","publish"]),fc=l.enum(["never","admin","trusted","public"]),yD=l.strictObject({create:fc.optional(),update:fc.optional(),delete:fc.optional(),extract:fc.optional(),publish:fc.optional()}),qG=l.record(l.string(),yD)});var SD=v(()=>{yh();gh()});var FG,KG,bh,HG,JG,VG;var vD=v(()=>{fe();FG=l.enum(["site-content-preview","site-content-production"]),KG=l.enum(["web","image","pdf","epub"]),bh=l.custom((e)=>typeof e==="function"),HG=l.object({name:l.string(),schema:l.unknown(),description:l.string().optional(),pluginId:l.string(),renderers:l.object({web:l.union([bh,l.string()]).optional(),image:l.union([bh,l.string()]).optional(),pdf:l.union([bh,l.string()]).optional(),epub:l.union([bh,l.string()]).optional()})}),JG=l.object({enableContentGeneration:l.boolean().default(!1),outputDir:l.string(),workingDir:l.string().optional(),environment:l.enum(["preview","production"]).default("preview"),siteConfig:l.object({title:l.string(),description:l.string(),url:l.string().optional()}).optional()}),VG=l.object({success:l.boolean(),routesBuilt:l.number(),errors:l.array(l.string()).optional(),warnings:l.array(l.string()).optional()})});var wD=v(()=>{gh();gD();yh();bD();ck();SD();vD()});var lk=ge(function(GG,Sh){(function(){function e(g,E){Object.defineProperty(o.prototype,g,{get:function(){console.warn("%s(...) is deprecated in plain JavaScript React classes. %s",E[0],E[1])}})}function t(g){if(g===null||typeof g!=="object")return null;return g=De&&g[De]||g["@@iterator"],typeof g==="function"?g:null}function r(g,E){g=(g=g.constructor)&&(g.displayName||g.name)||"ReactClass";var D=g+"."+E;Qe[D]||(console.error("Can't call %s on a component that is not yet mounted. This is a no-op, but it might indicate a bug in your application. Instead, assign to `this.state` directly or define a `state = {};` class property with the desired state in the %s component.",E,g),Qe[D]=!0)}function o(g,E,D){this.props=g,this.context=E,this.refs=Dt,this.updater=D||St}function n(){}function i(g,E,D){this.props=g,this.context=E,this.refs=Dt,this.updater=D||St}function s(){}function a(g){return""+g}function c(g){try{a(g);var E=!1}catch(M){E=!0}if(E){E=console;var D=E.error,K=typeof Symbol==="function"&&Symbol.toStringTag&&g[Symbol.toStringTag]||g.constructor.name||"Object";return D.call(E,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",K),a(g)}}function u(g){if(g==null)return null;if(typeof g==="function")return g.$$typeof===Rn?null:g.displayName||g.name||null;if(typeof g==="string")return g;switch(g){case J:return"Fragment";case re:return"Profiler";case G:return"StrictMode";case ve:return"Suspense";case Ae:return"SuspenseList";case Ue:return"Activity"}if(typeof g==="object")switch(typeof g.tag==="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),g.$$typeof){case N:return"Portal";case me:return g.displayName||"Context";case ae:return(g._context.displayName||"Context")+".Consumer";case be:var E=g.render;return g=g.displayName,g||(g=E.displayName||E.name||"",g=g!==""?"ForwardRef("+g+")":"ForwardRef"),g;case Ie:return E=g.displayName||null,E!==null?E:u(g.type)||"Memo";case we:E=g._payload,g=g._init;try{return u(g(E))}catch(D){}}return null}function d(g){if(g===J)return"<>";if(typeof g==="object"&&g!==null&&g.$$typeof===we)return"<...>";try{var E=u(g);return E?"<"+E+">":"<...>"}catch(D){return"<...>"}}function p(){var g=Le.A;return g===null?null:g.getOwner()}function m(){return Error("react-stack-top-frame")}function h(g){if(so.call(g,"key")){var E=Object.getOwnPropertyDescriptor(g,"key").get;if(E&&E.isReactWarning)return!1}return g.key!==void 0}function b(g,E){function D(){us||(us=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",E))}D.isReactWarning=!0,Object.defineProperty(g,"key",{get:D,configurable:!0})}function y(){var g=u(this.type);return ds[g]||(ds[g]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),g=this.props.ref,g!==void 0?g:null}function S(g,E,D,K,M,te){var se=D.ref;return g={$$typeof:q,type:g,key:E,props:D,_owner:K},(se!==void 0?se:null)!==null?Object.defineProperty(g,"ref",{enumerable:!1,get:y}):Object.defineProperty(g,"ref",{enumerable:!1,value:null}),g._store={},Object.defineProperty(g._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(g,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(g,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:M}),Object.defineProperty(g,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:te}),Object.freeze&&(Object.freeze(g.props),Object.freeze(g)),g}function x(g,E){return E=S(g.type,E,g.props,g._owner,g._debugStack,g._debugTask),g._store&&(E._store.validated=g._store.validated),E}function _(g){A(g)?g._store&&(g._store.validated=1):typeof g==="object"&&g!==null&&g.$$typeof===we&&(g._payload.status==="fulfilled"?A(g._payload.value)&&g._payload.value._store&&(g._payload.value._store.validated=1):g._store&&(g._store.validated=1))}function A(g){return typeof g==="object"&&g!==null&&g.$$typeof===q}function O(g){var E={"=":"=0",":":"=2"};return"$"+g.replace(/[=:]/g,function(D){return E[D]})}function L(g,E){return typeof g==="object"&&g!==null&&g.key!=null?(c(g.key),O(""+g.key)):E.toString(36)}function z(g){switch(g.status){case"fulfilled":return g.value;case"rejected":throw g.reason;default:switch(typeof g.status==="string"?g.then(s,s):(g.status="pending",g.then(function(E){g.status==="pending"&&(g.status="fulfilled",g.value=E)},function(E){g.status==="pending"&&(g.status="rejected",g.reason=E)})),g.status){case"fulfilled":return g.value;case"rejected":throw g.reason}}throw g}function H(g,E,D,K,M){var te=typeof g;if(te==="undefined"||te==="boolean")g=null;var se=!1;if(g===null)se=!0;else switch(te){case"bigint":case"string":case"number":se=!0;break;case"object":switch(g.$$typeof){case q:case N:se=!0;break;case we:return se=g._init,H(se(g._payload),E,D,K,M)}}if(se){se=g,M=M(se);var ye=K===""?"."+L(se,0):K;return $r(M)?(D="",ye!=null&&(D=ye.replace(xa,"$&/")+"/"),H(M,E,D,"",function(Re){return Re})):M!=null&&(A(M)&&(M.key!=null&&(se&&se.key===M.key||c(M.key)),D=x(M,D+(M.key==null||se&&se.key===M.key?"":(""+M.key).replace(xa,"$&/")+"/")+ye),K!==""&&se!=null&&A(se)&&se.key==null&&se._store&&!se._store.validated&&(D._store.validated=2),M=D),E.push(M)),1}if(se=0,ye=K===""?".":K+":",$r(g))for(var pe=0;pe<g.length;pe++)K=g[pe],te=ye+L(K,pe),se+=H(K,E,D,te,M);else if(pe=t(g),typeof pe==="function")for(pe===g.entries&&(Wo||console.warn("Using Maps as children is not supported. Use an array of keyed ReactElements instead."),Wo=!0),g=pe.call(g),pe=0;!(K=g.next()).done;)K=K.value,te=ye+L(K,pe++),se+=H(K,E,D,te,M);else if(te==="object"){if(typeof g.then==="function")return H(z(g),E,D,K,M);throw E=String(g),Error("Objects are not valid as a React child (found: "+(E==="[object Object]"?"object with keys {"+Object.keys(g).join(", ")+"}":E)+"). If you meant to render a collection of children, use an array instead.")}return se}function P(g,E,D){if(g==null)return g;var K=[],M=0;return H(g,K,"","",function(te){return E.call(D,te,M++)}),K}function W(g){if(g._status===-1){var E=g._ioInfo;E!=null&&(E.start=E.end=performance.now()),E=g._result;var D=E();if(D.then(function(M){if(g._status===0||g._status===-1){g._status=1,g._result=M;var te=g._ioInfo;te!=null&&(te.end=performance.now()),D.status===void 0&&(D.status="fulfilled",D.value=M)}},function(M){if(g._status===0||g._status===-1){g._status=2,g._result=M;var te=g._ioInfo;te!=null&&(te.end=performance.now()),D.status===void 0&&(D.status="rejected",D.reason=M)}}),E=g._ioInfo,E!=null){E.value=D;var K=D.displayName;typeof K==="string"&&(E.name=K)}g._status===-1&&(g._status=0,g._result=D)}if(g._status===1)return E=g._result,E===void 0&&console.error(`lazy: Expected the result of a dynamic import() call. Instead received: %s
|
|
249
249
|
|
|
250
250
|
Your code should look like:
|
|
251
251
|
const MyComponent = lazy(() => import('./MyComponent'))
|
|
@@ -257,23 +257,23 @@ Your code should look like:
|
|
|
257
257
|
1. You might have mismatching versions of React and the renderer (such as React DOM)
|
|
258
258
|
2. You might be breaking the Rules of Hooks
|
|
259
259
|
3. You might have more than one copy of React in the same app
|
|
260
|
-
See https://react.dev/link/invalid-hook-call for tips about how to debug and fix this problem.`),g}function j(){Le.asyncTransitions--}function R(g){if(U===null)try{var E=("require"+Math.random()).slice(0,7);U=(Sh&&Sh[E]).call(Sh,"timers").setImmediate}catch(D){U=function(K){f===!1&&(f=!0,typeof MessageChannel>"u"&&console.error("This browser does not have a MessageChannel implementation, so enqueuing tasks via await act(async () => ...) will fail. Please file an issue at https://github.com/facebook/react/issues if you encounter this warning."));var M=new MessageChannel;M.port1.onmessage=K,M.port2.postMessage(void 0)}}return U(g)}function B(g){return 1<g.length&&typeof AggregateError==="function"?AggregateError(g):g[0]}function k(g,E){E!==ne-1&&console.error("You seem to have overlapping act() calls, this is not supported. Be sure to await previous act() calls before making a new one. "),ne=E}function T(g,E,D){var K=Le.actQueue;if(K!==null)if(K.length!==0)try{I(K),R(function(){return T(g,E,D)});return}catch(M){Le.thrownErrors.push(M)}else Le.actQueue=null;0<Le.thrownErrors.length?(K=B(Le.thrownErrors),Le.thrownErrors.length=0,D(K)):E(g)}function I(g){if(!X){X=!0;var E=0;try{for(;E<g.length;E++){var D=g[E];do{Le.didUsePromise=!1;var K=D(!1);if(K!==null){if(Le.didUsePromise){g[E]=D,g.splice(0,E);return}D=K}else break}while(1)}g.length=0}catch(M){g.splice(0,E+1),Le.thrownErrors.push(M)}finally{X=!1}}}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart==="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var q=Symbol.for("react.transitional.element"),N=Symbol.for("react.portal"),J=Symbol.for("react.fragment"),G=Symbol.for("react.strict_mode"),re=Symbol.for("react.profiler"),ae=Symbol.for("react.consumer"),me=Symbol.for("react.context"),be=Symbol.for("react.forward_ref"),ve=Symbol.for("react.suspense"),Ae=Symbol.for("react.suspense_list"),Ie=Symbol.for("react.memo"),we=Symbol.for("react.lazy"),Ue=Symbol.for("react.activity"),De=Symbol.iterator,Qe={},St={isMounted:function(){return!1},enqueueForceUpdate:function(g){r(g,"forceUpdate")},enqueueReplaceState:function(g){r(g,"replaceState")},enqueueSetState:function(g){r(g,"setState")}},Tt=Object.assign,Dt={};Object.freeze(Dt),o.prototype.isReactComponent={},o.prototype.setState=function(g,E){if(typeof g!=="object"&&typeof g!=="function"&&g!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,g,E,"setState")},o.prototype.forceUpdate=function(g){this.updater.enqueueForceUpdate(this,g,"forceUpdate")};var lt={isMounted:["isMounted","Instead, make sure to clean up subscriptions and pending requests in componentWillUnmount to prevent memory leaks."],replaceState:["replaceState","Refactor your code to use setState instead (see https://github.com/facebook/react/issues/3236)."]};for(V in lt)lt.hasOwnProperty(V)&&e(V,lt[V]);n.prototype=o.prototype,lt=i.prototype=new n,lt.constructor=i,Tt(lt,o.prototype),lt.isPureReactComponent=!0;var $r=Array.isArray,Rn=Symbol.for("react.client.reference"),Le={H:null,A:null,T:null,S:null,actQueue:null,asyncTransitions:0,isBatchingLegacy:!1,didScheduleLegacyUpdate:!1,didUsePromise:!1,thrownErrors:[],getCurrentStack:null,recentlyCreatedOwnerStacks:0},so=Object.prototype.hasOwnProperty,ls=console.createTask?console.createTask:function(){return null};lt={react_stack_bottom_frame:function(g){return g()}};var us,wa,ds={},$n=lt.react_stack_bottom_frame.bind(lt,m)(),Ul=ls(d(m)),Wo=!1,xa=/\/+/g,_a=typeof reportError==="function"?reportError:function(g){if(typeof window==="object"&&typeof window.ErrorEvent==="function"){var E=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof g==="object"&&g!==null&&typeof g.message==="string"?String(g.message):String(g),error:g});if(!window.dispatchEvent(E))return}else if(typeof process==="object"&&typeof process.emit==="function"){process.emit("uncaughtException",g);return}console.error(g)},f=!1,U=null,ne=0,ie=!1,X=!1,w=typeof queueMicrotask==="function"?function(g){queueMicrotask(function(){return queueMicrotask(g)})}:R;lt=Object.freeze({__proto__:null,c:function(g){return ee().useMemoCache(g)}});var V={map:P,forEach:function(g,E,D){P(g,function(){E.apply(this,arguments)},D)},count:function(g){var E=0;return P(g,function(){E++}),E},toArray:function(g){return P(g,function(E){return E})||[]},only:function(g){if(!A(g))throw Error("React.Children.only expected to receive a single React element child.");return g}};WG.Activity=Ue,WG.Children=V,WG.Component=o,WG.Fragment=J,WG.Profiler=re,WG.PureComponent=i,WG.StrictMode=G,WG.Suspense=ve,WG.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=Le,WG.__COMPILER_RUNTIME=lt,WG.act=function(g){var E=Le.actQueue,D=ne;ne++;var K=Le.actQueue=E!==null?E:[],M=!1;try{var te=g()}catch(pe){Le.thrownErrors.push(pe)}if(0<Le.thrownErrors.length)throw k(E,D),g=B(Le.thrownErrors),Le.thrownErrors.length=0,g;if(te!==null&&typeof te==="object"&&typeof te.then==="function"){var se=te;return w(function(){M||ie||(ie=!0,console.error("You called act(async () => ...) without await. This could lead to unexpected testing behaviour, interleaving multiple act calls and mixing their scopes. You should - await act(async () => ...);"))}),{then:function(pe,Re){M=!0,se.then(function(ze){if(k(E,D),D===0){try{I(K),R(function(){return T(ze,pe,Re)})}catch(ps){Le.thrownErrors.push(ps)}if(0<Le.thrownErrors.length){var On=B(Le.thrownErrors);Le.thrownErrors.length=0,Re(On)}}else pe(ze)},function(ze){k(E,D),0<Le.thrownErrors.length?(ze=B(Le.thrownErrors),Le.thrownErrors.length=0,Re(ze)):Re(ze)})}}}var ye=te;if(k(E,D),D===0&&(I(K),K.length!==0&&w(function(){M||ie||(ie=!0,console.error("A component suspended inside an `act` scope, but the `act` call was not awaited. When testing React components that depend on asynchronous data, you must await the result:\n\nawait act(() => ...)"))}),Le.actQueue=null),0<Le.thrownErrors.length)throw g=B(Le.thrownErrors),Le.thrownErrors.length=0,g;return{then:function(pe,Re){M=!0,D===0?(Le.actQueue=K,R(function(){return T(ye,pe,Re)})):pe(ye)}}},WG.cache=function(g){return function(){return g.apply(null,arguments)}},WG.cacheSignal=function(){return null},WG.captureOwnerStack=function(){var g=Le.getCurrentStack;return g===null?null:g()},WG.cloneElement=function(g,E,D){if(g===null||g===void 0)throw Error("The argument must be a React element, but you passed "+g+".");var K=Tt({},g.props),M=g.key,te=g._owner;if(E!=null){var se;e:{if(so.call(E,"ref")&&(se=Object.getOwnPropertyDescriptor(E,"ref").get)&&se.isReactWarning){se=!1;break e}se=E.ref!==void 0}se&&(te=p()),h(E)&&(c(E.key),M=""+E.key);for(ye in E)!so.call(E,ye)||ye==="key"||ye==="__self"||ye==="__source"||ye==="ref"&&E.ref===void 0||(K[ye]=E[ye])}var ye=arguments.length-2;if(ye===1)K.children=D;else if(1<ye){se=Array(ye);for(var pe=0;pe<ye;pe++)se[pe]=arguments[pe+2];K.children=se}K=S(g.type,M,K,te,g._debugStack,g._debugTask);for(M=2;M<arguments.length;M++)_(arguments[M]);return K},WG.createContext=function(g){return g={$$typeof:me,_currentValue:g,_currentValue2:g,_threadCount:0,Provider:null,Consumer:null},g.Provider=g,g.Consumer={$$typeof:ae,_context:g},g._currentRenderer=null,g._currentRenderer2=null,g},WG.createElement=function(g,E,D){for(var K=2;K<arguments.length;K++)_(arguments[K]);K={};var M=null;if(E!=null)for(pe in wa||!("__self"in E)||"key"in E||(wa=!0,console.warn("Your app (or one of its dependencies) is using an outdated JSX transform. Update to the modern JSX transform for faster performance: https://react.dev/link/new-jsx-transform")),h(E)&&(c(E.key),M=""+E.key),E)so.call(E,pe)&&pe!=="key"&&pe!=="__self"&&pe!=="__source"&&(K[pe]=E[pe]);var te=arguments.length-2;if(te===1)K.children=D;else if(1<te){for(var se=Array(te),ye=0;ye<te;ye++)se[ye]=arguments[ye+2];Object.freeze&&Object.freeze(se),K.children=se}if(g&&g.defaultProps)for(pe in te=g.defaultProps,te)K[pe]===void 0&&(K[pe]=te[pe]);M&&b(K,typeof g==="function"?g.displayName||g.name||"Unknown":g);var pe=1e4>Le.recentlyCreatedOwnerStacks++;return S(g,M,K,p(),pe?Error("react-stack-top-frame"):$n,pe?ls(d(g)):Ul)},WG.createRef=function(){var g={current:null};return Object.seal(g),g},WG.forwardRef=function(g){g!=null&&g.$$typeof===Ie?console.error("forwardRef requires a render function but received a `memo` component. Instead of forwardRef(memo(...)), use memo(forwardRef(...))."):typeof g!=="function"?console.error("forwardRef requires a render function but was given %s.",g===null?"null":typeof g):g.length!==0&&g.length!==2&&console.error("forwardRef render functions accept exactly two parameters: props and ref. %s",g.length===1?"Did you forget to use the ref parameter?":"Any additional parameter will be undefined."),g!=null&&g.defaultProps!=null&&console.error("forwardRef render functions do not support defaultProps. Did you accidentally pass a React component?");var E={$$typeof:be,render:g},D;return Object.defineProperty(E,"displayName",{enumerable:!1,configurable:!0,get:function(){return D},set:function(K){D=K,g.name||g.displayName||(Object.defineProperty(g,"name",{value:K}),g.displayName=K)}}),E},WG.isValidElement=A,WG.lazy=function(g){g={_status:-1,_result:g};var E={$$typeof:we,_payload:g,_init:W},D={name:"lazy",start:-1,end:-1,value:null,owner:null,debugStack:Error("react-stack-top-frame"),debugTask:console.createTask?console.createTask("lazy()"):null};return g._ioInfo=D,E._debugInfo=[{awaited:D}],E},WG.memo=function(g,E){g==null&&console.error("memo: The first argument must be a component. Instead received: %s",g===null?"null":typeof g),E={$$typeof:Ie,type:g,compare:E===void 0?null:E};var D;return Object.defineProperty(E,"displayName",{enumerable:!1,configurable:!0,get:function(){return D},set:function(K){D=K,g.name||g.displayName||(Object.defineProperty(g,"name",{value:K}),g.displayName=K)}}),E},WG.startTransition=function(g){var E=Le.T,D={};D._updatedFibers=new Set,Le.T=D;try{var K=g(),M=Le.S;M!==null&&M(D,K),typeof K==="object"&&K!==null&&typeof K.then==="function"&&(Le.asyncTransitions++,K.then(j,j),K.then(s,_a))}catch(te){_a(te)}finally{E===null&&D._updatedFibers&&(g=D._updatedFibers.size,D._updatedFibers.clear(),10<g&&console.warn("Detected a large number of updates inside startTransition. If this is due to a subscription please re-write it to use React provided hooks. Otherwise concurrent mode guarantees are off the table.")),E!==null&&D.types!==null&&(E.types!==null&&E.types!==D.types&&console.error("We expected inner Transitions to have transferred the outer types set and that you cannot add to the outer Transition while inside the inner.This is a bug in React."),E.types=D.types),Le.T=E}},WG.unstable_useCacheRefresh=function(){return ee().useCacheRefresh()},WG.use=function(g){return ee().use(g)},WG.useActionState=function(g,E,D){return ee().useActionState(g,E,D)},WG.useCallback=function(g,E){return ee().useCallback(g,E)},WG.useContext=function(g){var E=ee();return g.$$typeof===ae&&console.error("Calling useContext(Context.Consumer) is not supported and will cause bugs. Did you mean to call useContext(Context) instead?"),E.useContext(g)},WG.useDebugValue=function(g,E){return ee().useDebugValue(g,E)},WG.useDeferredValue=function(g,E){return ee().useDeferredValue(g,E)},WG.useEffect=function(g,E){return g==null&&console.warn("React Hook useEffect requires an effect callback. Did you forget to pass a callback to the hook?"),ee().useEffect(g,E)},WG.useEffectEvent=function(g){return ee().useEffectEvent(g)},WG.useId=function(){return ee().useId()},WG.useImperativeHandle=function(g,E,D){return ee().useImperativeHandle(g,E,D)},WG.useInsertionEffect=function(g,E){return g==null&&console.warn("React Hook useInsertionEffect requires an effect callback. Did you forget to pass a callback to the hook?"),ee().useInsertionEffect(g,E)},WG.useLayoutEffect=function(g,E){return g==null&&console.warn("React Hook useLayoutEffect requires an effect callback. Did you forget to pass a callback to the hook?"),ee().useLayoutEffect(g,E)},WG.useMemo=function(g,E){return ee().useMemo(g,E)},WG.useOptimistic=function(g,E){return ee().useOptimistic(g,E)},WG.useReducer=function(g,E,D){return ee().useReducer(g,E,D)},WG.useRef=function(g){return ee().useRef(g)},WG.useState=function(g){return ee().useState(g)},WG.useSyncExternalStore=function(g,E,D){return ee().useSyncExternalStore(g,E,D)},WG.useTransition=function(){return ee().useTransition()},WG.version="19.2.7",typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop==="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()});var xD,_D;var uk=v(()=>{xD=ql(lk(),1),_D=xD.createContext(void 0)});var GG;var ED=v(()=>{ak();wD();uk();fe();GG=ql(lk(),1)});var QG,YG;var kD=v(()=>{Rt();fe();ok();QG=pc.omit({url:!0,analyticsScript:!0}),YG=QG.extend({title:l.string().optional().describe("Optional site title override"),description:l.string().optional().describe("Optional site description override")})});function dk(e,t={}){let r=ID(e),o=ID(t.sharedDomain??"rizom.ai").replace(/^\./,""),n=`.${o}`;if(r.endsWith(n)){let i=r.slice(0,-n.length);if(i.length>0&&!i.includes("."))return`${i}-preview.${o}`}return`preview.${r}`}function ID(e){return e.trim().replace(/^https?:\/\//i,"").replace(/\/$/,"").toLowerCase()}function AD(e){return`${e.slice(0,1).toUpperCase()}${e.slice(1)}`}var vh=()=>{};var TD=v(()=>{vh()});var XG,eQ;var RD=v(()=>{fe();dh();XG=l.string(),eQ=l.custom((e)=>{if(!ks(e))return!1;let{plugin:t,...r}=e;if(t!==void 0&&typeof t!=="function")return!1;return M2.safeParse(r).success})});var tQ;var $D=v(()=>{vh();fe();tQ=l.object({title:l.string().min(1),slug:l.string().min(1),description:l.string(),content:l.string(),author:l.string(),publishedAt:l.iso.datetime({offset:!0}),category:l.string().min(1).optional()})});var OD=v(()=>{nk();eD();ok();fD();ED();kD();TD();RD();uk();$D()});function pk(e,t={}){return dk(e,t)}var fk=v(()=>{OD()});function mk(e,t){let r=e.indexOf("/");if(r===-1)return{org:t,name:e};return{org:e.slice(0,r),name:e.slice(r+1)}}function CD(e,t){let{org:r,name:o}=mk(e,t);return`${r}/${o}`}import{mkdtemp as rQ,mkdir as nQ,readFile as oQ,rm as iQ,writeFile as sQ}from"fs/promises";import{tmpdir as aQ}from"os";import{dirname as cQ,join as ND}from"path";async function DD(e,t,r,o,n={}){if(o.length===0)return;let i=n.env??process.env,s=Or(e),a=PD(i,s,r.effectiveGitSyncToken),c=n.contentRepoAdminTokenSelector?PD(i,s,n.contentRepoAdminTokenSelector):void 0,u=mk(r.contentRepo,t),d=n.contentRepoRemoteResolver?.(r,t,a)??pQ(u,a);if(!d)return;let p=await rQ(ND(aQ(),`brains-ops-content-sync-${r.handle}-`)),m=n.runCommand??jt,h=n.fetchImpl??fetch;try{if(!n.contentRepoRemoteResolver){if(!c)throw Error(`${n.contentRepoAdminTokenSelector??"CONTENT_REPO_ADMIN_TOKEN"} is required to check or create content repos`);await fQ(u,c,h)}await m("git",["clone",d,p]),await mQ(p,m),await m("git",["config","user.name","brains-ops[bot]"],{cwd:p}),await m("git",["config","user.email","41898282+github-actions[bot]@users.noreply.github.com"],{cwd:p});let b=!1;for(let y of o)if(await uQ(p,y))b=!0;if(!b)return;await m("git",["add","."],{cwd:p}),await m("git",["commit","-m",`chore(content): seed ${r.handle} anchor profile`],{cwd:p}),await m("git",["push","origin","HEAD:main"],{cwd:p})}finally{await iQ(p,{recursive:!0,force:!0})}}async function uQ(e,t){let r=ND(e,t.path),o=await oQ(r,"utf8").catch(()=>{return});if(o===t.content)return!1;if(o!==void 0&&!dQ(o))return!1;return await nQ(cQ(r),{recursive:!0}),await sQ(r,t.content),!0}function dQ(e){return lQ.some((t)=>e.includes(t))}function PD(e,t,r){return Bt(r,e,t)}function pQ(e,t){if(!t)return;return`https://x-access-token:${encodeURIComponent(t)}@github.com/${e.org}/${e.name}.git`}async function fQ(e,t,r){let{org:o,name:n}=e,s=`https://api.github.com/repos/${`${encodeURIComponent(o)}/${encodeURIComponent(n)}`}`,a={Accept:"application/vnd.github+json",Authorization:`Bearer ${t}`,"User-Agent":"brains-ops","X-GitHub-Api-Version":"2022-11-28"},c=await r(s,{headers:a});if(c.ok)return;if(c.status!==404)throw Error(`Failed to check GitHub repo ${o}/${n}: ${c.status} ${await zD(c)}`);let u=await r(`https://api.github.com/orgs/${encodeURIComponent(o)}/repos`,{method:"POST",headers:a,body:JSON.stringify({name:n,private:!0,auto_init:!1})});if(u.ok){console.log(`Created missing content repo ${o}/${n}`);return}if(u.status===422){if((await r(s,{headers:a})).ok)return}throw Error(`Failed to create GitHub repo ${o}/${n}: ${u.status} ${await zD(u)}`)}async function zD(e){let t=await e.text();return t.trim().length===0?e.statusText:t}async function mQ(e,t){try{await t("git",["checkout","-B","main","origin/main"],{cwd:e})}catch{await t("git",["checkout","-B","main"],{cwd:e})}}var lQ;var LD=v(()=>{Qo();jn();lQ=["name: Your Name Here","Delete this and write your own"]});function hk(e,t,r={}){let o={...e};for(let n of Object.keys(t)){let i=t[n];if(i===null&&r.nulls!=="preserve")delete o[n];else if(ju(o[n])&&ju(i))o[n]=hk(o[n],i,r);else o[n]=i}return o}var BD=v(()=>{Zu()});function wh(e){return async(t)=>({brainYaml:hQ(t,e),envFile:bQ(t,e),contentRepoFiles:gQ(t)})}function hQ(e,t){let r={...e.setup?.delivery==="email"?{"auth-service":{setupEmail:e.setup.email},notifications:{defaultRecipient:{type:"email",address:e.setup.email}},email:{transport:"resend",apiKey:"${SETUP_EMAIL_API_KEY}",from:"${SETUP_EMAIL_FROM}"}}:{},...e.playbooks?.onboarding?{onboarding:{enabled:!0}}:{},...e.topicExtractionEnabled!==void 0?{topics:{enableAutoExtraction:e.topicExtractionEnabled}}:{},...e.skillDerivationEnabled!==void 0?{agents:{enableSkillDerivation:e.skillDerivationEnabled}}:{},...e.swotDerivationEnabled!==void 0?{assessment:{enableSwotDerivation:e.swotDerivationEnabled}}:{},"directory-sync":{git:{repo:jD(e,t),authToken:"${GIT_SYNC_TOKEN}"}},...e.atproto?{atproto:{...e.atproto,appPassword:"${ATPROTO_APP_PASSWORD}"}}:{}};return Ra({brain:"brain",bundleContract:e.bundleContract,kind:e.profileKind??"professional",domain:e.domain,bundles:e.bundles,...e.anchorKind?{anchor:e.anchorKind}:{},...e.embeddingEnabled!==void 0?{embedding:{enabled:e.embeddingEnabled}}:{},...e.embeddingModel?{embeddingModel:e.embeddingModel}:{},...e.add.length>0?{add:e.add}:{},...e.remove.length>0?{remove:e.remove}:{},...e.siteOverride?{site:{package:e.siteOverride.package,...e.siteOverride.theme?{theme:e.siteOverride.theme}:{}}}:{},...e.spaces&&e.spaces.length>0?{spaces:e.spaces}:{},anchors:e.discordEnabled&&e.discordAnchorUserId?[`discord:${e.discordAnchorUserId}`]:[],plugins:hk(r,e.plugins??{},{nulls:"preserve"})})}function jD(e,t){return CD(e.contentRepo,t)}function gQ(e){return[{path:"anchor-profile/anchor-profile.md",content:yQ(e)}]}function yQ(e){let t={name:e.anchorProfile.name,...e.anchorProfile.description?{description:e.anchorProfile.description}:{},...e.anchorProfile.website?{website:e.anchorProfile.website}:{},...e.anchorProfile.email?{email:e.anchorProfile.email}:{},...e.anchorProfile.socialLinks?{socialLinks:e.anchorProfile.socialLinks}:{}},r=e.anchorProfile.story??"This profile was initialized by brains-ops. Edit it in your content repo.";return`---
|
|
260
|
+
See https://react.dev/link/invalid-hook-call for tips about how to debug and fix this problem.`),g}function j(){Le.asyncTransitions--}function R(g){if(U===null)try{var E=("require"+Math.random()).slice(0,7);U=(Sh&&Sh[E]).call(Sh,"timers").setImmediate}catch(D){U=function(K){f===!1&&(f=!0,typeof MessageChannel>"u"&&console.error("This browser does not have a MessageChannel implementation, so enqueuing tasks via await act(async () => ...) will fail. Please file an issue at https://github.com/facebook/react/issues if you encounter this warning."));var M=new MessageChannel;M.port1.onmessage=K,M.port2.postMessage(void 0)}}return U(g)}function B(g){return 1<g.length&&typeof AggregateError==="function"?AggregateError(g):g[0]}function k(g,E){E!==ne-1&&console.error("You seem to have overlapping act() calls, this is not supported. Be sure to await previous act() calls before making a new one. "),ne=E}function T(g,E,D){var K=Le.actQueue;if(K!==null)if(K.length!==0)try{I(K),R(function(){return T(g,E,D)});return}catch(M){Le.thrownErrors.push(M)}else Le.actQueue=null;0<Le.thrownErrors.length?(K=B(Le.thrownErrors),Le.thrownErrors.length=0,D(K)):E(g)}function I(g){if(!X){X=!0;var E=0;try{for(;E<g.length;E++){var D=g[E];do{Le.didUsePromise=!1;var K=D(!1);if(K!==null){if(Le.didUsePromise){g[E]=D,g.splice(0,E);return}D=K}else break}while(1)}g.length=0}catch(M){g.splice(0,E+1),Le.thrownErrors.push(M)}finally{X=!1}}}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart==="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var q=Symbol.for("react.transitional.element"),N=Symbol.for("react.portal"),J=Symbol.for("react.fragment"),G=Symbol.for("react.strict_mode"),re=Symbol.for("react.profiler"),ae=Symbol.for("react.consumer"),me=Symbol.for("react.context"),be=Symbol.for("react.forward_ref"),ve=Symbol.for("react.suspense"),Ae=Symbol.for("react.suspense_list"),Ie=Symbol.for("react.memo"),we=Symbol.for("react.lazy"),Ue=Symbol.for("react.activity"),De=Symbol.iterator,Qe={},St={isMounted:function(){return!1},enqueueForceUpdate:function(g){r(g,"forceUpdate")},enqueueReplaceState:function(g){r(g,"replaceState")},enqueueSetState:function(g){r(g,"setState")}},Tt=Object.assign,Dt={};Object.freeze(Dt),o.prototype.isReactComponent={},o.prototype.setState=function(g,E){if(typeof g!=="object"&&typeof g!=="function"&&g!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,g,E,"setState")},o.prototype.forceUpdate=function(g){this.updater.enqueueForceUpdate(this,g,"forceUpdate")};var lt={isMounted:["isMounted","Instead, make sure to clean up subscriptions and pending requests in componentWillUnmount to prevent memory leaks."],replaceState:["replaceState","Refactor your code to use setState instead (see https://github.com/facebook/react/issues/3236)."]};for(V in lt)lt.hasOwnProperty(V)&&e(V,lt[V]);n.prototype=o.prototype,lt=i.prototype=new n,lt.constructor=i,Tt(lt,o.prototype),lt.isPureReactComponent=!0;var $r=Array.isArray,Rn=Symbol.for("react.client.reference"),Le={H:null,A:null,T:null,S:null,actQueue:null,asyncTransitions:0,isBatchingLegacy:!1,didScheduleLegacyUpdate:!1,didUsePromise:!1,thrownErrors:[],getCurrentStack:null,recentlyCreatedOwnerStacks:0},so=Object.prototype.hasOwnProperty,ls=console.createTask?console.createTask:function(){return null};lt={react_stack_bottom_frame:function(g){return g()}};var us,wa,ds={},$n=lt.react_stack_bottom_frame.bind(lt,m)(),Ul=ls(d(m)),Wo=!1,xa=/\/+/g,_a=typeof reportError==="function"?reportError:function(g){if(typeof window==="object"&&typeof window.ErrorEvent==="function"){var E=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof g==="object"&&g!==null&&typeof g.message==="string"?String(g.message):String(g),error:g});if(!window.dispatchEvent(E))return}else if(typeof process==="object"&&typeof process.emit==="function"){process.emit("uncaughtException",g);return}console.error(g)},f=!1,U=null,ne=0,ie=!1,X=!1,w=typeof queueMicrotask==="function"?function(g){queueMicrotask(function(){return queueMicrotask(g)})}:R;lt=Object.freeze({__proto__:null,c:function(g){return ee().useMemoCache(g)}});var V={map:P,forEach:function(g,E,D){P(g,function(){E.apply(this,arguments)},D)},count:function(g){var E=0;return P(g,function(){E++}),E},toArray:function(g){return P(g,function(E){return E})||[]},only:function(g){if(!A(g))throw Error("React.Children.only expected to receive a single React element child.");return g}};GG.Activity=Ue,GG.Children=V,GG.Component=o,GG.Fragment=J,GG.Profiler=re,GG.PureComponent=i,GG.StrictMode=G,GG.Suspense=ve,GG.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=Le,GG.__COMPILER_RUNTIME=lt,GG.act=function(g){var E=Le.actQueue,D=ne;ne++;var K=Le.actQueue=E!==null?E:[],M=!1;try{var te=g()}catch(pe){Le.thrownErrors.push(pe)}if(0<Le.thrownErrors.length)throw k(E,D),g=B(Le.thrownErrors),Le.thrownErrors.length=0,g;if(te!==null&&typeof te==="object"&&typeof te.then==="function"){var se=te;return w(function(){M||ie||(ie=!0,console.error("You called act(async () => ...) without await. This could lead to unexpected testing behaviour, interleaving multiple act calls and mixing their scopes. You should - await act(async () => ...);"))}),{then:function(pe,Re){M=!0,se.then(function(ze){if(k(E,D),D===0){try{I(K),R(function(){return T(ze,pe,Re)})}catch(ps){Le.thrownErrors.push(ps)}if(0<Le.thrownErrors.length){var On=B(Le.thrownErrors);Le.thrownErrors.length=0,Re(On)}}else pe(ze)},function(ze){k(E,D),0<Le.thrownErrors.length?(ze=B(Le.thrownErrors),Le.thrownErrors.length=0,Re(ze)):Re(ze)})}}}var ye=te;if(k(E,D),D===0&&(I(K),K.length!==0&&w(function(){M||ie||(ie=!0,console.error("A component suspended inside an `act` scope, but the `act` call was not awaited. When testing React components that depend on asynchronous data, you must await the result:\n\nawait act(() => ...)"))}),Le.actQueue=null),0<Le.thrownErrors.length)throw g=B(Le.thrownErrors),Le.thrownErrors.length=0,g;return{then:function(pe,Re){M=!0,D===0?(Le.actQueue=K,R(function(){return T(ye,pe,Re)})):pe(ye)}}},GG.cache=function(g){return function(){return g.apply(null,arguments)}},GG.cacheSignal=function(){return null},GG.captureOwnerStack=function(){var g=Le.getCurrentStack;return g===null?null:g()},GG.cloneElement=function(g,E,D){if(g===null||g===void 0)throw Error("The argument must be a React element, but you passed "+g+".");var K=Tt({},g.props),M=g.key,te=g._owner;if(E!=null){var se;e:{if(so.call(E,"ref")&&(se=Object.getOwnPropertyDescriptor(E,"ref").get)&&se.isReactWarning){se=!1;break e}se=E.ref!==void 0}se&&(te=p()),h(E)&&(c(E.key),M=""+E.key);for(ye in E)!so.call(E,ye)||ye==="key"||ye==="__self"||ye==="__source"||ye==="ref"&&E.ref===void 0||(K[ye]=E[ye])}var ye=arguments.length-2;if(ye===1)K.children=D;else if(1<ye){se=Array(ye);for(var pe=0;pe<ye;pe++)se[pe]=arguments[pe+2];K.children=se}K=S(g.type,M,K,te,g._debugStack,g._debugTask);for(M=2;M<arguments.length;M++)_(arguments[M]);return K},GG.createContext=function(g){return g={$$typeof:me,_currentValue:g,_currentValue2:g,_threadCount:0,Provider:null,Consumer:null},g.Provider=g,g.Consumer={$$typeof:ae,_context:g},g._currentRenderer=null,g._currentRenderer2=null,g},GG.createElement=function(g,E,D){for(var K=2;K<arguments.length;K++)_(arguments[K]);K={};var M=null;if(E!=null)for(pe in wa||!("__self"in E)||"key"in E||(wa=!0,console.warn("Your app (or one of its dependencies) is using an outdated JSX transform. Update to the modern JSX transform for faster performance: https://react.dev/link/new-jsx-transform")),h(E)&&(c(E.key),M=""+E.key),E)so.call(E,pe)&&pe!=="key"&&pe!=="__self"&&pe!=="__source"&&(K[pe]=E[pe]);var te=arguments.length-2;if(te===1)K.children=D;else if(1<te){for(var se=Array(te),ye=0;ye<te;ye++)se[ye]=arguments[ye+2];Object.freeze&&Object.freeze(se),K.children=se}if(g&&g.defaultProps)for(pe in te=g.defaultProps,te)K[pe]===void 0&&(K[pe]=te[pe]);M&&b(K,typeof g==="function"?g.displayName||g.name||"Unknown":g);var pe=1e4>Le.recentlyCreatedOwnerStacks++;return S(g,M,K,p(),pe?Error("react-stack-top-frame"):$n,pe?ls(d(g)):Ul)},GG.createRef=function(){var g={current:null};return Object.seal(g),g},GG.forwardRef=function(g){g!=null&&g.$$typeof===Ie?console.error("forwardRef requires a render function but received a `memo` component. Instead of forwardRef(memo(...)), use memo(forwardRef(...))."):typeof g!=="function"?console.error("forwardRef requires a render function but was given %s.",g===null?"null":typeof g):g.length!==0&&g.length!==2&&console.error("forwardRef render functions accept exactly two parameters: props and ref. %s",g.length===1?"Did you forget to use the ref parameter?":"Any additional parameter will be undefined."),g!=null&&g.defaultProps!=null&&console.error("forwardRef render functions do not support defaultProps. Did you accidentally pass a React component?");var E={$$typeof:be,render:g},D;return Object.defineProperty(E,"displayName",{enumerable:!1,configurable:!0,get:function(){return D},set:function(K){D=K,g.name||g.displayName||(Object.defineProperty(g,"name",{value:K}),g.displayName=K)}}),E},GG.isValidElement=A,GG.lazy=function(g){g={_status:-1,_result:g};var E={$$typeof:we,_payload:g,_init:W},D={name:"lazy",start:-1,end:-1,value:null,owner:null,debugStack:Error("react-stack-top-frame"),debugTask:console.createTask?console.createTask("lazy()"):null};return g._ioInfo=D,E._debugInfo=[{awaited:D}],E},GG.memo=function(g,E){g==null&&console.error("memo: The first argument must be a component. Instead received: %s",g===null?"null":typeof g),E={$$typeof:Ie,type:g,compare:E===void 0?null:E};var D;return Object.defineProperty(E,"displayName",{enumerable:!1,configurable:!0,get:function(){return D},set:function(K){D=K,g.name||g.displayName||(Object.defineProperty(g,"name",{value:K}),g.displayName=K)}}),E},GG.startTransition=function(g){var E=Le.T,D={};D._updatedFibers=new Set,Le.T=D;try{var K=g(),M=Le.S;M!==null&&M(D,K),typeof K==="object"&&K!==null&&typeof K.then==="function"&&(Le.asyncTransitions++,K.then(j,j),K.then(s,_a))}catch(te){_a(te)}finally{E===null&&D._updatedFibers&&(g=D._updatedFibers.size,D._updatedFibers.clear(),10<g&&console.warn("Detected a large number of updates inside startTransition. If this is due to a subscription please re-write it to use React provided hooks. Otherwise concurrent mode guarantees are off the table.")),E!==null&&D.types!==null&&(E.types!==null&&E.types!==D.types&&console.error("We expected inner Transitions to have transferred the outer types set and that you cannot add to the outer Transition while inside the inner.This is a bug in React."),E.types=D.types),Le.T=E}},GG.unstable_useCacheRefresh=function(){return ee().useCacheRefresh()},GG.use=function(g){return ee().use(g)},GG.useActionState=function(g,E,D){return ee().useActionState(g,E,D)},GG.useCallback=function(g,E){return ee().useCallback(g,E)},GG.useContext=function(g){var E=ee();return g.$$typeof===ae&&console.error("Calling useContext(Context.Consumer) is not supported and will cause bugs. Did you mean to call useContext(Context) instead?"),E.useContext(g)},GG.useDebugValue=function(g,E){return ee().useDebugValue(g,E)},GG.useDeferredValue=function(g,E){return ee().useDeferredValue(g,E)},GG.useEffect=function(g,E){return g==null&&console.warn("React Hook useEffect requires an effect callback. Did you forget to pass a callback to the hook?"),ee().useEffect(g,E)},GG.useEffectEvent=function(g){return ee().useEffectEvent(g)},GG.useId=function(){return ee().useId()},GG.useImperativeHandle=function(g,E,D){return ee().useImperativeHandle(g,E,D)},GG.useInsertionEffect=function(g,E){return g==null&&console.warn("React Hook useInsertionEffect requires an effect callback. Did you forget to pass a callback to the hook?"),ee().useInsertionEffect(g,E)},GG.useLayoutEffect=function(g,E){return g==null&&console.warn("React Hook useLayoutEffect requires an effect callback. Did you forget to pass a callback to the hook?"),ee().useLayoutEffect(g,E)},GG.useMemo=function(g,E){return ee().useMemo(g,E)},GG.useOptimistic=function(g,E){return ee().useOptimistic(g,E)},GG.useReducer=function(g,E,D){return ee().useReducer(g,E,D)},GG.useRef=function(g){return ee().useRef(g)},GG.useState=function(g){return ee().useState(g)},GG.useSyncExternalStore=function(g,E,D){return ee().useSyncExternalStore(g,E,D)},GG.useTransition=function(){return ee().useTransition()},GG.version="19.2.7",typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop==="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()});var xD,_D;var uk=v(()=>{xD=ql(lk(),1),_D=xD.createContext(void 0)});var QG;var ED=v(()=>{ak();wD();uk();fe();QG=ql(lk(),1)});var YG,XG;var kD=v(()=>{Rt();fe();ok();YG=pc.omit({url:!0,analyticsScript:!0}),XG=YG.extend({title:l.string().optional().describe("Optional site title override"),description:l.string().optional().describe("Optional site description override")})});function dk(e,t={}){let r=ID(e),o=ID(t.sharedDomain??"rizom.ai").replace(/^\./,""),n=`.${o}`;if(r.endsWith(n)){let i=r.slice(0,-n.length);if(i.length>0&&!i.includes("."))return`${i}-preview.${o}`}return`preview.${r}`}function ID(e){return e.trim().replace(/^https?:\/\//i,"").replace(/\/$/,"").toLowerCase()}function AD(e){return`${e.slice(0,1).toUpperCase()}${e.slice(1)}`}var vh=()=>{};var TD=v(()=>{vh()});var eQ,tQ;var RD=v(()=>{fe();dh();eQ=l.string(),tQ=l.custom((e)=>{if(!ks(e))return!1;let{plugin:t,...r}=e;if(t!==void 0&&typeof t!=="function")return!1;return M2.safeParse(r).success})});var rQ;var $D=v(()=>{vh();fe();rQ=l.object({title:l.string().min(1),slug:l.string().min(1),description:l.string(),content:l.string(),author:l.string(),publishedAt:l.iso.datetime({offset:!0}),category:l.string().min(1).optional()})});var OD=v(()=>{nk();eD();ok();fD();ED();kD();TD();RD();uk();$D()});function pk(e,t={}){return dk(e,t)}var fk=v(()=>{OD()});function mk(e,t){let r=e.indexOf("/");if(r===-1)return{org:t,name:e};return{org:e.slice(0,r),name:e.slice(r+1)}}function CD(e,t){let{org:r,name:o}=mk(e,t);return`${r}/${o}`}import{mkdtemp as nQ,mkdir as oQ,readFile as iQ,rm as sQ,writeFile as aQ}from"fs/promises";import{tmpdir as cQ}from"os";import{dirname as lQ,join as ND}from"path";async function DD(e,t,r,o,n={}){if(o.length===0)return;let i=n.env??process.env,s=Or(e),a=PD(i,s,r.effectiveGitSyncToken),c=n.contentRepoAdminTokenSelector?PD(i,s,n.contentRepoAdminTokenSelector):void 0,u=mk(r.contentRepo,t),d=n.contentRepoRemoteResolver?.(r,t,a)??fQ(u,a);if(!d)return;let p=await nQ(ND(cQ(),`brains-ops-content-sync-${r.handle}-`)),m=n.runCommand??jt,h=n.fetchImpl??fetch;try{if(!n.contentRepoRemoteResolver){if(!c)throw Error(`${n.contentRepoAdminTokenSelector??"CONTENT_REPO_ADMIN_TOKEN"} is required to check or create content repos`);await mQ(u,c,h)}await m("git",["clone",d,p]),await hQ(p,m),await m("git",["config","user.name","brains-ops[bot]"],{cwd:p}),await m("git",["config","user.email","41898282+github-actions[bot]@users.noreply.github.com"],{cwd:p});let b=!1;for(let y of o)if(await dQ(p,y))b=!0;if(!b)return;await m("git",["add","."],{cwd:p}),await m("git",["commit","-m",`chore(content): seed ${r.handle} anchor profile`],{cwd:p}),await m("git",["push","origin","HEAD:main"],{cwd:p})}finally{await sQ(p,{recursive:!0,force:!0})}}async function dQ(e,t){let r=ND(e,t.path),o=await iQ(r,"utf8").catch(()=>{return});if(o===t.content)return!1;if(o!==void 0&&!pQ(o))return!1;return await oQ(lQ(r),{recursive:!0}),await aQ(r,t.content),!0}function pQ(e){return uQ.some((t)=>e.includes(t))}function PD(e,t,r){return Bt(r,e,t)}function fQ(e,t){if(!t)return;return`https://x-access-token:${encodeURIComponent(t)}@github.com/${e.org}/${e.name}.git`}async function mQ(e,t,r){let{org:o,name:n}=e,s=`https://api.github.com/repos/${`${encodeURIComponent(o)}/${encodeURIComponent(n)}`}`,a={Accept:"application/vnd.github+json",Authorization:`Bearer ${t}`,"User-Agent":"brains-ops","X-GitHub-Api-Version":"2022-11-28"},c=await r(s,{headers:a});if(c.ok)return;if(c.status!==404)throw Error(`Failed to check GitHub repo ${o}/${n}: ${c.status} ${await zD(c)}`);let u=await r(`https://api.github.com/orgs/${encodeURIComponent(o)}/repos`,{method:"POST",headers:a,body:JSON.stringify({name:n,private:!0,auto_init:!1})});if(u.ok){console.log(`Created missing content repo ${o}/${n}`);return}if(u.status===422){if((await r(s,{headers:a})).ok)return}throw Error(`Failed to create GitHub repo ${o}/${n}: ${u.status} ${await zD(u)}`)}async function zD(e){let t=await e.text();return t.trim().length===0?e.statusText:t}async function hQ(e,t){try{await t("git",["checkout","-B","main","origin/main"],{cwd:e})}catch{await t("git",["checkout","-B","main"],{cwd:e})}}var uQ;var LD=v(()=>{Qo();jn();uQ=["name: Your Name Here","Delete this and write your own"]});function hk(e,t,r={}){let o={...e};for(let n of Object.keys(t)){let i=t[n];if(i===null&&r.nulls!=="preserve")delete o[n];else if(ju(o[n])&&ju(i))o[n]=hk(o[n],i,r);else o[n]=i}return o}var BD=v(()=>{Zu()});function wh(e){return async(t)=>({brainYaml:gQ(t,e),envFile:SQ(t,e),contentRepoFiles:yQ(t)})}function gQ(e,t){let r={...e.setup?.delivery==="email"?{"auth-service":{setupEmail:e.setup.email},notifications:{defaultRecipient:{type:"email",address:e.setup.email}},email:{transport:"resend",apiKey:"${SETUP_EMAIL_API_KEY}",from:"${SETUP_EMAIL_FROM}"}}:{},...e.playbooks?.onboarding?{onboarding:{enabled:!0}}:{},...e.topicExtractionEnabled!==void 0?{topics:{enableAutoExtraction:e.topicExtractionEnabled}}:{},...e.skillDerivationEnabled!==void 0?{agents:{enableSkillDerivation:e.skillDerivationEnabled}}:{},...e.swotDerivationEnabled!==void 0?{assessment:{enableSwotDerivation:e.swotDerivationEnabled}}:{},"directory-sync":{git:{repo:jD(e,t),authToken:"${GIT_SYNC_TOKEN}"}},...e.atproto?{atproto:{...e.atproto,appPassword:"${ATPROTO_APP_PASSWORD}"}}:{}};return Ra({brain:"brain",bundleContract:e.bundleContract,kind:e.profileKind??"professional",domain:e.domain,bundles:e.bundles,...e.anchorKind?{anchor:e.anchorKind}:{},...e.embeddingEnabled!==void 0?{embedding:{enabled:e.embeddingEnabled}}:{},...e.embeddingModel?{embeddingModel:e.embeddingModel}:{},...e.add.length>0?{add:e.add}:{},...e.remove.length>0?{remove:e.remove}:{},...e.siteOverride?{site:{package:e.siteOverride.package,...e.siteOverride.theme?{theme:e.siteOverride.theme}:{}}}:{},...e.spaces&&e.spaces.length>0?{spaces:e.spaces}:{},anchors:e.discordEnabled&&e.discordAnchorUserId?[`discord:${e.discordAnchorUserId}`]:[],plugins:hk(r,e.plugins??{},{nulls:"preserve"})})}function jD(e,t){return CD(e.contentRepo,t)}function yQ(e){return[{path:"anchor-profile/anchor-profile.md",content:bQ(e)}]}function bQ(e){let t={name:e.anchorProfile.name,...e.anchorProfile.description?{description:e.anchorProfile.description}:{},...e.anchorProfile.website?{website:e.anchorProfile.website}:{},...e.anchorProfile.email?{email:e.anchorProfile.email}:{},...e.anchorProfile.socialLinks?{socialLinks:e.anchorProfile.socialLinks}:{}},r=e.anchorProfile.story??"This profile was initialized by brains-ops. Edit it in your content repo.";return`---
|
|
261
261
|
${Ra(t).trimEnd()}
|
|
262
262
|
---
|
|
263
263
|
|
|
264
264
|
${r}
|
|
265
|
-
`}function
|
|
266
|
-
`)}var gk=v(()=>{BD();uh();Cn()});import{mkdir as
|
|
267
|
-
`)}}Jr.defaultYaml={explicit:!1,version:"1.2"};Jr.defaultTags={"!!":"tag:yaml.org,2002:"};
|
|
265
|
+
`}function SQ(e,t){let r=ch(e.siteOverride);return[`BRAIN_VERSION=${e.brainVersion}`,...r.length>0?[`IMAGE_TAG=${Uu(e.brainVersion,r)}`]:[],`CONTENT_REPO=${jD(e,t)}`,""].join(`
|
|
266
|
+
`)}var gk=v(()=>{BD();uh();Cn()});import{mkdir as vQ,writeFile as wQ}from"fs/promises";import{dirname as xQ,join as ZD}from"path";import{isDeepStrictEqual as _Q}from"util";async function mc(e,t,r,o,n={}){let i=wh(t.pilot.githubOrg);for(let s of r){let a={};if(o){let m=await o(s);if(m!==void 0)a=m}let c=await i(s),u=a.brainYaml??c.brainYaml,d=a.envFile??c.envFile,p=a.contentRepoFiles??c.contentRepoFiles??[];if(d)await yk(e,s.handle,".env",d);if(u)await yk(e,s.handle,"brain.yaml",u);await DD(e,t.pilot.githubOrg,s,p,{contentRepoAdminTokenSelector:t.pilot.contentRepoAdminToken,...n});for(let m of p)await yk(e,s.handle,ZD("content",m.path),m.content)}}async function yk(e,t,r,o){let n=ZD(e,"users",t,r),i=Bun.file(n);if(r==="brain.yaml"&&await i.exists()){let s=lr(await i.text()),a=lr(o);if(s.ok&&a.ok&&_Q(s.data,a.data))return}await vQ(xQ(n),{recursive:!0}),await wQ(n,o)}async function xh(e,t){let r=await ut(e),o=r.users.find((n)=>n.handle===t);if(!o)throw Error(`Unknown user handle: ${t}`);return{registry:r,user:o}}async function UD(e,t){let r=await ut(e),o=r.cohorts.find((n)=>n.id===t);if(!o)throw Error(`Unknown cohort: ${t}`);return{registry:r,users:r.users.filter((n)=>n.cohort===o.id)}}async function MD(e){let t=await ut(e);return{registry:t,users:t.users}}var Fu=v(()=>{Cn();LD();gk();Hr()});var qe=ge(function(qQ){var vk=Symbol.for("yaml.alias"),HD=Symbol.for("yaml.document"),_h=Symbol.for("yaml.map"),JD=Symbol.for("yaml.pair"),wk=Symbol.for("yaml.scalar"),Eh=Symbol.for("yaml.seq"),ho=Symbol.for("yaml.node.type"),DQ=(e)=>!!e&&typeof e==="object"&&e[ho]===vk,LQ=(e)=>!!e&&typeof e==="object"&&e[ho]===HD,BQ=(e)=>!!e&&typeof e==="object"&&e[ho]===_h,jQ=(e)=>!!e&&typeof e==="object"&&e[ho]===JD,VD=(e)=>!!e&&typeof e==="object"&&e[ho]===wk,ZQ=(e)=>!!e&&typeof e==="object"&&e[ho]===Eh;function WD(e){if(e&&typeof e==="object")switch(e[ho]){case _h:case Eh:return!0}return!1}function UQ(e){if(e&&typeof e==="object")switch(e[ho]){case vk:case _h:case wk:case Eh:return!0}return!1}var MQ=(e)=>(VD(e)||WD(e))&&!!e.anchor;qQ.ALIAS=vk;qQ.DOC=HD;qQ.MAP=_h;qQ.NODE_TYPE=ho;qQ.PAIR=JD;qQ.SCALAR=wk;qQ.SEQ=Eh;qQ.hasAnchor=MQ;qQ.isAlias=DQ;qQ.isCollection=WD;qQ.isDocument=LQ;qQ.isMap=BQ;qQ.isNode=UQ;qQ.isPair=jQ;qQ.isScalar=VD;qQ.isSeq=ZQ});var Ku=ge(function(sY){var Ot=qe(),Er=Symbol("break visit"),GD=Symbol("skip children"),Zn=Symbol("remove node");function kh(e,t){let r=QD(t);if(Ot.isDocument(e)){if(gc(null,e.contents,r,Object.freeze([e]))===Zn)e.contents=null}else gc(null,e,r,Object.freeze([]))}kh.BREAK=Er;kh.SKIP=GD;kh.REMOVE=Zn;function gc(e,t,r,o){let n=YD(e,t,r,o);if(Ot.isNode(n)||Ot.isPair(n))return XD(e,o,n),gc(e,n,r,o);if(typeof n!=="symbol"){if(Ot.isCollection(t)){o=Object.freeze(o.concat(t));for(let i=0;i<t.items.length;++i){let s=gc(i,t.items[i],r,o);if(typeof s==="number")i=s-1;else if(s===Er)return Er;else if(s===Zn)t.items.splice(i,1),i-=1}}else if(Ot.isPair(t)){o=Object.freeze(o.concat(t));let i=gc("key",t.key,r,o);if(i===Er)return Er;else if(i===Zn)t.key=null;let s=gc("value",t.value,r,o);if(s===Er)return Er;else if(s===Zn)t.value=null}}return n}async function Ih(e,t){let r=QD(t);if(Ot.isDocument(e)){if(await yc(null,e.contents,r,Object.freeze([e]))===Zn)e.contents=null}else await yc(null,e,r,Object.freeze([]))}Ih.BREAK=Er;Ih.SKIP=GD;Ih.REMOVE=Zn;async function yc(e,t,r,o){let n=await YD(e,t,r,o);if(Ot.isNode(n)||Ot.isPair(n))return XD(e,o,n),yc(e,n,r,o);if(typeof n!=="symbol"){if(Ot.isCollection(t)){o=Object.freeze(o.concat(t));for(let i=0;i<t.items.length;++i){let s=await yc(i,t.items[i],r,o);if(typeof s==="number")i=s-1;else if(s===Er)return Er;else if(s===Zn)t.items.splice(i,1),i-=1}}else if(Ot.isPair(t)){o=Object.freeze(o.concat(t));let i=await yc("key",t.key,r,o);if(i===Er)return Er;else if(i===Zn)t.key=null;let s=await yc("value",t.value,r,o);if(s===Er)return Er;else if(s===Zn)t.value=null}}return n}function QD(e){if(typeof e==="object"&&(e.Collection||e.Node||e.Value))return Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e);return e}function YD(e,t,r,o){if(typeof r==="function")return r(e,t,o);if(Ot.isMap(t))return r.Map?.(e,t,o);if(Ot.isSeq(t))return r.Seq?.(e,t,o);if(Ot.isPair(t))return r.Pair?.(e,t,o);if(Ot.isScalar(t))return r.Scalar?.(e,t,o);if(Ot.isAlias(t))return r.Alias?.(e,t,o);return}function XD(e,t,r){let o=t[t.length-1];if(Ot.isCollection(o))o.items[e]=r;else if(Ot.isPair(o))if(e==="key")o.key=r;else o.value=r;else if(Ot.isDocument(o))o.contents=r;else{let n=Ot.isAlias(o)?"alias":"scalar";throw Error(`Cannot replace node with ${n} parent`)}}sY.visit=kh;sY.visitAsync=Ih});var xk=ge(function(pY){var eL=qe(),lY=Ku(),uY={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},dY=(e)=>e.replace(/[!,[\]{}]/g,(t)=>uY[t]);class Jr{constructor(e,t){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},Jr.defaultYaml,e),this.tags=Object.assign({},Jr.defaultTags,t)}clone(){let e=new Jr(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){let e=new Jr(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:Jr.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},Jr.defaultTags);break}return e}add(e,t){if(this.atNextDocument)this.yaml={explicit:Jr.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},Jr.defaultTags),this.atNextDocument=!1;let r=e.trim().split(/[ \t]+/),o=r.shift();switch(o){case"%TAG":{if(r.length!==2){if(t(0,"%TAG directive should contain exactly two parts"),r.length<2)return!1}let[n,i]=r;return this.tags[n]=i,!0}case"%YAML":{if(this.yaml.explicit=!0,r.length!==1)return t(0,"%YAML directive should contain exactly one part"),!1;let[n]=r;if(n==="1.1"||n==="1.2")return this.yaml.version=n,!0;else{let i=/^\d+\.\d+$/.test(n);return t(6,`Unsupported YAML version ${n}`,i),!1}}default:return t(0,`Unknown directive ${o}`,!0),!1}}tagName(e,t){if(e==="!")return"!";if(e[0]!=="!")return t(`Not a valid tag: ${e}`),null;if(e[1]==="<"){let i=e.slice(2,-1);if(i==="!"||i==="!!")return t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null;if(e[e.length-1]!==">")t("Verbatim tags must end with a >");return i}let[,r,o]=e.match(/^(.*!)([^!]*)$/s);if(!o)t(`The ${e} tag has no suffix`);let n=this.tags[r];if(n)try{return n+decodeURIComponent(o)}catch(i){return t(String(i)),null}if(r==="!")return e;return t(`Could not resolve tag: ${e}`),null}tagString(e){for(let[t,r]of Object.entries(this.tags))if(e.startsWith(r))return t+dY(e.substring(r.length));return e[0]==="!"?e:`!<${e}>`}toString(e){let t=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],r=Object.entries(this.tags),o;if(e&&r.length>0&&eL.isNode(e.contents)){let n={};lY.visit(e.contents,(i,s)=>{if(eL.isNode(s)&&s.tag)n[s.tag]=!0}),o=Object.keys(n)}else o=[];for(let[n,i]of r){if(n==="!!"&&i==="tag:yaml.org,2002:")continue;if(!e||o.some((s)=>s.startsWith(i)))t.push(`%TAG ${n} ${i}`)}return t.join(`
|
|
267
|
+
`)}}Jr.defaultYaml={explicit:!1,version:"1.2"};Jr.defaultTags={"!!":"tag:yaml.org,2002:"};pY.Directives=Jr});var Ah=ge(function(yY){var tL=qe(),mY=Ku();function hY(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let r=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw Error(r)}return!0}function rL(e){let t=new Set;return mY.visit(e,{Value(r,o){if(o.anchor)t.add(o.anchor)}}),t}function nL(e,t){for(let r=1;;++r){let o=`${e}${r}`;if(!t.has(o))return o}}function gY(e,t){let r=[],o=new Map,n=null;return{onAnchor:(i)=>{r.push(i),n??(n=rL(e));let s=nL(t,n);return n.add(s),s},setAnchors:()=>{for(let i of r){let s=o.get(i);if(typeof s==="object"&&s.anchor&&(tL.isScalar(s.node)||tL.isCollection(s.node)))s.node.anchor=s.anchor;else{let a=Error("Failed to resolve repeated object (this should not happen)");throw a.source=i,a}}},sourceObjects:o}}yY.anchorIsValid=hY;yY.anchorNames=rL;yY.createNodeAnchors=gY;yY.findNewAnchor=nL});var _k=ge(function(xY){function Hu(e,t,r,o){if(o&&typeof o==="object")if(Array.isArray(o))for(let n=0,i=o.length;n<i;++n){let s=o[n],a=Hu(e,o,String(n),s);if(a===void 0)delete o[n];else if(a!==s)o[n]=a}else if(o instanceof Map)for(let n of Array.from(o.keys())){let i=o.get(n),s=Hu(e,o,n,i);if(s===void 0)o.delete(n);else if(s!==i)o.set(n,s)}else if(o instanceof Set)for(let n of Array.from(o)){let i=Hu(e,o,n,n);if(i===void 0)o.delete(n);else if(i!==n)o.delete(n),o.add(i)}else for(let[n,i]of Object.entries(o)){let s=Hu(e,o,n,i);if(s===void 0)delete o[n];else if(s!==i)o[n]=s}return e.call(t,r,o)}xY.applyReviver=Hu});var fi=ge(function(kY){var EY=qe();function oL(e,t,r){if(Array.isArray(e))return e.map((o,n)=>oL(o,String(n),r));if(e&&typeof e.toJSON==="function"){if(!r||!EY.hasAnchor(e))return e.toJSON(t,r);let o={aliasCount:0,count:1,res:void 0};r.anchors.set(e,o),r.onCreate=(i)=>{o.res=i,delete r.onCreate};let n=e.toJSON(t,r);if(r.onCreate)r.onCreate(n);return n}if(typeof e==="bigint"&&!r?.keep)return Number(e);return e}kY.toJS=oL});var Th=ge(function(RY){var AY=_k(),iL=qe(),TY=fi();class sL{constructor(e){Object.defineProperty(this,iL.NODE_TYPE,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));if(this.range)e.range=this.range.slice();return e}toJS(e,{mapAsMap:t,maxAliasCount:r,onAnchor:o,reviver:n}={}){if(!iL.isDocument(e))throw TypeError("A document argument is required");let i={anchors:new Map,doc:e,keep:!0,mapAsMap:t===!0,mapKeyWarned:!1,maxAliasCount:typeof r==="number"?r:100},s=TY.toJS(this,"",i);if(typeof o==="function")for(let{count:a,res:c}of i.anchors.values())o(c,a);return typeof n==="function"?AY.applyReviver(n,{"":s},"",s):s}}RY.NodeBase=sL});var Ju=ge(function(NY){var OY=Ah(),CY=Ku(),bc=qe(),PY=Th(),zY=fi();class aL extends PY.NodeBase{constructor(e){super(bc.ALIAS);this.source=e,Object.defineProperty(this,"tag",{set(){throw Error("Alias nodes cannot have tags")}})}resolve(e,t){if(t?.maxAliasCount===0)throw ReferenceError("Alias resolution is disabled");let r;if(t?.aliasResolveCache)r=t.aliasResolveCache;else if(r=[],CY.visit(e,{Node:(n,i)=>{if(bc.isAlias(i)||bc.hasAnchor(i))r.push(i)}}),t)t.aliasResolveCache=r;let o=void 0;for(let n of r){if(n===this)break;if(n.anchor===this.source)o=n}return o}toJSON(e,t){if(!t)return{source:this.source};let{anchors:r,doc:o,maxAliasCount:n}=t,i=this.resolve(o,t);if(!i){let a=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(a)}let s=r.get(i);if(!s)zY.toJS(i,null,t),s=r.get(i);if(s?.res===void 0)throw ReferenceError("This should not happen: Alias anchor was not resolved?");if(n>=0){if(s.count+=1,s.aliasCount===0)s.aliasCount=Rh(o,i,r);if(s.count*s.aliasCount>n)throw ReferenceError("Excessive alias count indicates a resource exhaustion attack")}return s.res}toString(e,t,r){let o=`*${this.source}`;if(e){if(OY.anchorIsValid(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let n=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw Error(n)}if(e.implicitKey)return`${o} `}return o}}function Rh(e,t,r){if(bc.isAlias(t)){let o=t.resolve(e),n=r&&o&&r.get(o);return n?n.count*n.aliasCount:0}else if(bc.isCollection(t)){let o=0;for(let n of t.items){let i=Rh(e,n,r);if(i>o)o=i}return o}else if(bc.isPair(t)){let o=Rh(e,t.key,r),n=Rh(e,t.value,r);return Math.max(o,n)}return 1}NY.Alias=aL});var Et=ge(function(UY){var LY=qe(),BY=Th(),jY=fi(),ZY=(e)=>!e||typeof e!=="function"&&typeof e!=="object";class Ts extends BY.NodeBase{constructor(e){super(LY.SCALAR);this.value=e}toJSON(e,t){return t?.keep?this.value:jY.toJS(this.value,e,t)}toString(){return String(this.value)}}Ts.BLOCK_FOLDED="BLOCK_FOLDED";Ts.BLOCK_LITERAL="BLOCK_LITERAL";Ts.PLAIN="PLAIN";Ts.QUOTE_DOUBLE="QUOTE_DOUBLE";Ts.QUOTE_SINGLE="QUOTE_SINGLE";UY.Scalar=Ts;UY.isScalarValue=ZY});var Vu=ge(function(VY){var FY=Ju(),Rs=qe(),cL=Et(),KY="tag:yaml.org,2002:";function HY(e,t,r){if(t){let o=r.filter((i)=>i.tag===t),n=o.find((i)=>!i.format)??o[0];if(!n)throw Error(`Tag ${t} not found`);return n}return r.find((o)=>o.identify?.(e)&&!o.format)}function JY(e,t,r){if(Rs.isDocument(e))e=e.contents;if(Rs.isNode(e))return e;if(Rs.isPair(e)){let p=r.schema[Rs.MAP].createNode?.(r.schema,null,r);return p.items.push(e),p}if(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<"u"&&e instanceof BigInt)e=e.valueOf();let{aliasDuplicateObjects:o,onAnchor:n,onTagObj:i,schema:s,sourceObjects:a}=r,c=void 0;if(o&&e&&typeof e==="object")if(c=a.get(e),c)return c.anchor??(c.anchor=n(e)),new FY.Alias(c.anchor);else c={anchor:null,node:null},a.set(e,c);if(t?.startsWith("!!"))t=KY+t.slice(2);let u=HY(e,t,s.tags);if(!u){if(e&&typeof e.toJSON==="function")e=e.toJSON();if(!e||typeof e!=="object"){let p=new cL.Scalar(e);if(c)c.node=p;return p}u=e instanceof Map?s[Rs.MAP]:(Symbol.iterator in Object(e))?s[Rs.SEQ]:s[Rs.MAP]}if(i)i(u),delete r.onTagObj;let d=u?.createNode?u.createNode(r.schema,e,r):typeof u?.nodeClass?.from==="function"?u.nodeClass.from(r.schema,e,r):new cL.Scalar(e);if(t)d.tag=t;else if(!u.default)d.tag=u.tag;if(c)c.node=d;return d}VY.createNode=JY});var $h=ge(function(YY){var GY=Vu(),Un=qe(),QY=Th();function Ek(e,t,r){let o=r;for(let n=t.length-1;n>=0;--n){let i=t[n];if(typeof i==="number"&&Number.isInteger(i)&&i>=0){let s=[];s[i]=o,o=s}else o=new Map([[i,o]])}return GY.createNode(o,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw Error("This should not happen, please report a bug.")},schema:e,sourceObjects:new Map})}var lL=(e)=>e==null||typeof e==="object"&&!!e[Symbol.iterator]().next().done;class uL extends QY.NodeBase{constructor(e,t){super(e);Object.defineProperty(this,"schema",{value:t,configurable:!0,enumerable:!1,writable:!0})}clone(e){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));if(e)t.schema=e;if(t.items=t.items.map((r)=>Un.isNode(r)||Un.isPair(r)?r.clone(e):r),this.range)t.range=this.range.slice();return t}addIn(e,t){if(lL(e))this.add(t);else{let[r,...o]=e,n=this.get(r,!0);if(Un.isCollection(n))n.addIn(o,t);else if(n===void 0&&this.schema)this.set(r,Ek(this.schema,o,t));else throw Error(`Expected YAML collection at ${r}. Remaining path: ${o}`)}}deleteIn(e){let[t,...r]=e;if(r.length===0)return this.delete(t);let o=this.get(t,!0);if(Un.isCollection(o))return o.deleteIn(r);else throw Error(`Expected YAML collection at ${t}. Remaining path: ${r}`)}getIn(e,t){let[r,...o]=e,n=this.get(r,!0);if(o.length===0)return!t&&Un.isScalar(n)?n.value:n;else return Un.isCollection(n)?n.getIn(o,t):void 0}hasAllNullValues(e){return this.items.every((t)=>{if(!Un.isPair(t))return!1;let r=t.value;return r==null||e&&Un.isScalar(r)&&r.value==null&&!r.commentBefore&&!r.comment&&!r.tag})}hasIn(e){let[t,...r]=e;if(r.length===0)return this.has(t);let o=this.get(t,!0);return Un.isCollection(o)?o.hasIn(r):!1}setIn(e,t){let[r,...o]=e;if(o.length===0)this.set(r,t);else{let n=this.get(r,!0);if(Un.isCollection(n))n.setIn(o,t);else if(n===void 0&&this.schema)this.set(r,Ek(this.schema,o,t));else throw Error(`Expected YAML collection at ${r}. Remaining path: ${o}`)}}}YY.Collection=uL;YY.collectionFromPath=Ek;YY.isEmptyPath=lL});var Wu=ge(function(oX){var rX=(e)=>e.replace(/^(?!$)(?: $)?/gm,"#");function kk(e,t){if(/^\n+$/.test(e))return e.substring(1);return t?e.replace(/^(?! *$)/gm,t):e}var nX=(e,t,r)=>e.endsWith(`
|
|
268
268
|
`)?kk(r,t):r.includes(`
|
|
269
269
|
`)?`
|
|
270
|
-
`+kk(r,t):(e.endsWith(" ")?"":" ")+r;
|
|
270
|
+
`+kk(r,t):(e.endsWith(" ")?"":" ")+r;oX.indentComment=kk;oX.lineComment=nX;oX.stringifyComment=rX});var pL=ge(function(lX){function cX(e,t,r="flow",{indentAtStart:o,lineWidth:n=80,minContentWidth:i=20,onFold:s,onOverflow:a}={}){if(!n||n<0)return e;if(n<i)i=0;let c=Math.max(1+i,1+n-t.length);if(e.length<=c)return e;let u=[],d={},p=n-t.length;if(typeof o==="number")if(o>n-Math.max(2,i))u.push(0);else p=n-o;let m=void 0,h=void 0,b=!1,y=-1,S=-1,x=-1;if(r==="block"){if(y=dL(e,y,t.length),y!==-1)p=y+c}for(let A;A=e[y+=1];){if(r==="quoted"&&A==="\\"){switch(S=y,e[y+1]){case"x":y+=3;break;case"u":y+=5;break;case"U":y+=9;break;default:y+=1}x=y}if(A===`
|
|
271
271
|
`){if(r==="block")y=dL(e,y,t.length);p=y+t.length+c,m=void 0}else{if(A===" "&&h&&h!==" "&&h!==`
|
|
272
272
|
`&&h!=="\t"){let O=e[y+1];if(O&&O!==" "&&O!==`
|
|
273
273
|
`&&O!=="\t")m=y}if(y>=p)if(m)u.push(m),p=m+c,m=void 0;else if(r==="quoted"){while(h===" "||h==="\t")h=A,A=e[y+=1],b=!0;let O=y>x+1?y-2:S-1;if(d[O])return e;u.push(O),d[O]=!0,p=O+c,m=void 0}else b=!0}h=A}if(b&&a)a();if(u.length===0)return e;if(s)s();let _=e.slice(0,u[0]);for(let A=0;A<u.length;++A){let O=u[A],L=u[A+1]||e.length;if(O===0)_=`
|
|
274
274
|
${t}${e.slice(0,L)}`;else{if(r==="quoted"&&d[O])_+=`${e[O]}\\`;_+=`
|
|
275
275
|
${t}${e.slice(O+1,L)}`}}return _}function dL(e,t,r){let o=t,n=t+1,i=e[n];while(i===" "||i==="\t")if(t<n+r)i=e[++t];else{do i=e[++t];while(i&&i!==`
|
|
276
|
-
`);o=t,n=t+1,i=e[n]}return o}
|
|
276
|
+
`);o=t,n=t+1,i=e[n]}return o}lX.FOLD_BLOCK="block";lX.FOLD_FLOW="flow";lX.FOLD_QUOTED="quoted";lX.foldFlowLines=cX});var Qu=ge(function(yX){var pn=Et(),mi=pL(),Ch=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),Ph=(e)=>/^(%|---|\.\.\.)/m.test(e);function mX(e,t,r){if(!t||t<0)return!1;let o=t-r,n=e.length;if(n<=o)return!1;for(let i=0,s=0;i<n;++i)if(e[i]===`
|
|
277
277
|
`){if(i-s>o)return!0;if(s=i+1,n-s<=o)return!1}return!0}function Gu(e,t){let r=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return r;let{implicitKey:o}=t,n=t.options.doubleQuotedMinMultiLineLength,i=t.indent||(Ph(e)?" ":""),s="",a=0;for(let c=0,u=r[c];u;u=r[++c]){if(u===" "&&r[c+1]==="\\"&&r[c+2]==="n")s+=r.slice(a,c)+"\\ ",c+=1,a=c,u="\\";if(u==="\\")switch(r[c+1]){case"u":{s+=r.slice(a,c);let d=r.substr(c+2,4);switch(d){case"0000":s+="\\0";break;case"0007":s+="\\a";break;case"000b":s+="\\v";break;case"001b":s+="\\e";break;case"0085":s+="\\N";break;case"00a0":s+="\\_";break;case"2028":s+="\\L";break;case"2029":s+="\\P";break;default:if(d.substr(0,2)==="00")s+="\\x"+d.substr(2);else s+=r.substr(c,6)}c+=5,a=c+1}break;case"n":if(o||r[c+2]==='"'||r.length<n)c+=1;else{s+=r.slice(a,c)+`
|
|
278
278
|
|
|
279
279
|
`;while(r[c+2]==="\\"&&r[c+3]==="n"&&r[c+4]!=='"')s+=`
|
|
@@ -282,7 +282,7 @@ ${t}${e.slice(O+1,L)}`}}return _}function dL(e,t,r){let o=t,n=t+1,i=e[n];while(i
|
|
|
282
282
|
${r}`)+"'";return t.implicitKey?o:mi.foldFlowLines(o,r,mi.FOLD_FLOW,Ch(t,!1))}function Sc(e,t){let{singleQuote:r}=t.options,o;if(r===!1)o=Gu;else{let n=e.includes('"'),i=e.includes("'");if(n&&!i)o=Ik;else if(i&&!n)o=Gu;else o=r?Ik:Gu}return o(e,t)}var Ak;try{Ak=new RegExp(`(^|(?<!
|
|
283
283
|
))
|
|
284
284
|
+(?!
|
|
285
|
-
|$)`,"g")}catch{Ak=/\n+(?!\n|$)/g}function Oh({comment:e,type:t,value:r},o,n,i){let{blockQuote:s,commentString:a,lineWidth:c}=o.options;if(!s||/\n[\t ]+$/.test(r))return Sc(r,o);let u=o.indent||(o.forceBlockIndent||Ph(r)?" ":""),d=s==="literal"?!0:s==="folded"||t===pn.Scalar.BLOCK_FOLDED?!1:t===pn.Scalar.BLOCK_LITERAL?!0:!
|
|
285
|
+
|$)`,"g")}catch{Ak=/\n+(?!\n|$)/g}function Oh({comment:e,type:t,value:r},o,n,i){let{blockQuote:s,commentString:a,lineWidth:c}=o.options;if(!s||/\n[\t ]+$/.test(r))return Sc(r,o);let u=o.indent||(o.forceBlockIndent||Ph(r)?" ":""),d=s==="literal"?!0:s==="folded"||t===pn.Scalar.BLOCK_FOLDED?!1:t===pn.Scalar.BLOCK_LITERAL?!0:!mX(r,c,u.length);if(!r)return d?`|
|
|
286
286
|
`:`>
|
|
287
287
|
`;let p,m;for(m=r.length;m>0;--m){let L=r[m-1];if(L!==`
|
|
288
288
|
`&&L!=="\t"&&L!==" ")break}let h=r.substring(m),b=h.indexOf(`
|
|
@@ -291,12 +291,12 @@ ${r}`)+"'";return t.implicitKey?o:mi.foldFlowLines(o,r,mi.FOLD_FLOW,Ch(t,!1))}fu
|
|
|
291
291
|
`)x=S;else break}let _=r.substring(0,x<S?x+1:S);if(_)r=r.substring(_.length),_=_.replace(/\n+/g,`$&${u}`);let O=(y?u?"2":"1":"")+p;if(e){if(O+=" "+a(e.replace(/ ?[\r\n]+/g," ")),n)n()}if(!d){let L=r.replace(/\n+/g,`
|
|
292
292
|
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${u}`),z=!1,H=Ch(o,!0);if(s!=="folded"&&t!==pn.Scalar.BLOCK_FOLDED)H.onOverflow=()=>{z=!0};let P=mi.foldFlowLines(`${_}${L}${h}`,u,mi.FOLD_BLOCK,H);if(!z)return`>${O}
|
|
293
293
|
${u}${P}`}return r=r.replace(/\n+/g,`$&${u}`),`|${O}
|
|
294
|
-
${u}${_}${r}${h}`}function
|
|
294
|
+
${u}${_}${r}${h}`}function hX(e,t,r,o){let{type:n,value:i}=e,{actualString:s,implicitKey:a,indent:c,indentStep:u,inFlow:d}=t;if(a&&i.includes(`
|
|
295
295
|
`)||d&&/[[\]{},]/.test(i))return Sc(i,t);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(i))return a||d||!i.includes(`
|
|
296
296
|
`)?Sc(i,t):Oh(e,t,r,o);if(!a&&!d&&n!==pn.Scalar.PLAIN&&i.includes(`
|
|
297
297
|
`))return Oh(e,t,r,o);if(Ph(i)){if(c==="")return t.forceBlockIndent=!0,Oh(e,t,r,o);else if(a&&c===u)return Sc(i,t)}let p=i.replace(/\n+/g,`$&
|
|
298
|
-
${c}`);if(s){let m=(y)=>y.default&&y.tag!=="tag:yaml.org,2002:str"&&y.test?.test(p),{compat:h,tags:b}=t.doc.schema;if(b.some(m)||h?.some(m))return Sc(i,t)}return a?p:mi.foldFlowLines(p,c,mi.FOLD_FLOW,Ch(t,!1))}function
|
|
299
|
-
${t.indent}${a}`}
|
|
298
|
+
${c}`);if(s){let m=(y)=>y.default&&y.tag!=="tag:yaml.org,2002:str"&&y.test?.test(p),{compat:h,tags:b}=t.doc.schema;if(b.some(m)||h?.some(m))return Sc(i,t)}return a?p:mi.foldFlowLines(p,c,mi.FOLD_FLOW,Ch(t,!1))}function gX(e,t,r,o){let{implicitKey:n,inFlow:i}=t,s=typeof e.value==="string"?e:Object.assign({},e,{value:String(e.value)}),{type:a}=e;if(a!==pn.Scalar.QUOTE_DOUBLE){if(/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(s.value))a=pn.Scalar.QUOTE_DOUBLE}let c=(d)=>{switch(d){case pn.Scalar.BLOCK_FOLDED:case pn.Scalar.BLOCK_LITERAL:return n||i?Sc(s.value,t):Oh(s,t,r,o);case pn.Scalar.QUOTE_DOUBLE:return Gu(s.value,t);case pn.Scalar.QUOTE_SINGLE:return Ik(s.value,t);case pn.Scalar.PLAIN:return hX(s,t,r,o);default:return null}},u=c(a);if(u===null){let{defaultKeyType:d,defaultStringType:p}=t.options,m=n&&d||p;if(u=c(m),u===null)throw Error(`Unsupported default string type ${m}`)}return u}yX.stringifyString=gX});var Yu=ge(function(IX){var SX=Ah(),hi=qe(),vX=Wu(),wX=Qu();function xX(e,t){let r=Object.assign({blockQuote:!0,commentString:vX.stringifyComment,defaultKeyType:null,defaultStringType:"PLAIN",directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:"false",flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:"null",simpleKeys:!1,singleQuote:null,trailingComma:!1,trueStr:"true",verifyAliasOrder:!0},e.schema.toStringOptions,t),o;switch(r.collectionStyle){case"block":o=!1;break;case"flow":o=!0;break;default:o=null}return{anchors:new Set,doc:e,flowCollectionPadding:r.flowCollectionPadding?" ":"",indent:"",indentStep:typeof r.indent==="number"?" ".repeat(r.indent):" ",inFlow:o,options:r}}function _X(e,t){if(t.tag){let n=e.filter((i)=>i.tag===t.tag);if(n.length>0)return n.find((i)=>i.format===t.format)??n[0]}let r=void 0,o;if(hi.isScalar(t)){o=t.value;let n=e.filter((i)=>i.identify?.(o));if(n.length>1){let i=n.filter((s)=>s.test);if(i.length>0)n=i}r=n.find((i)=>i.format===t.format)??n.find((i)=>!i.format)}else o=t,r=e.find((n)=>n.nodeClass&&o instanceof n.nodeClass);if(!r){let n=o?.constructor?.name??(o===null?"null":typeof o);throw Error(`Tag not resolved for ${n} value`)}return r}function EX(e,t,{anchors:r,doc:o}){if(!o.directives)return"";let n=[],i=(hi.isScalar(e)||hi.isCollection(e))&&e.anchor;if(i&&SX.anchorIsValid(i))r.add(i),n.push(`&${i}`);let s=e.tag??(t.default?null:t.tag);if(s)n.push(o.directives.tagString(s));return n.join(" ")}function kX(e,t,r,o){if(hi.isPair(e))return e.toString(t,r,o);if(hi.isAlias(e)){if(t.doc.directives)return e.toString(t);if(t.resolvedAliases?.has(e))throw TypeError("Cannot stringify circular structure without alias nodes");else{if(t.resolvedAliases)t.resolvedAliases.add(e);else t.resolvedAliases=new Set([e]);e=e.resolve(t.doc)}}let n=void 0,i=hi.isNode(e)?e:t.doc.createNode(e,{onTagObj:(c)=>n=c});n??(n=_X(t.doc.schema.tags,i));let s=EX(i,n,t);if(s.length>0)t.indentAtStart=(t.indentAtStart??0)+s.length+1;let a=typeof n.stringify==="function"?n.stringify(i,t,r,o):hi.isScalar(i)?wX.stringifyString(i,t,r,o):i.toString(t,r,o);if(!s)return a;return hi.isScalar(i)||a[0]==="{"||a[0]==="["?`${s} ${a}`:`${s}
|
|
299
|
+
${t.indent}${a}`}IX.createStringifyContext=xX;IX.stringify=kX});var hL=ge(function($X){var go=qe(),fL=Et(),mL=Yu(),Xu=Wu();function RX({key:e,value:t},r,o,n){let{allNullValues:i,doc:s,indent:a,indentStep:c,options:{commentString:u,indentSeq:d,simpleKeys:p}}=r,m=go.isNode(e)&&e.comment||null;if(p){if(m)throw Error("With simple keys, key nodes cannot have comments");if(go.isCollection(e)||!go.isNode(e)&&typeof e==="object")throw Error("With simple keys, collection cannot be used as a key value")}let h=!p&&(!e||m&&t==null&&!r.inFlow||go.isCollection(e)||(go.isScalar(e)?e.type===fL.Scalar.BLOCK_FOLDED||e.type===fL.Scalar.BLOCK_LITERAL:typeof e==="object"));r=Object.assign({},r,{allNullValues:!1,implicitKey:!h&&(p||!i),indent:a+c});let b=!1,y=!1,S=mL.stringify(e,r,()=>b=!0,()=>y=!0);if(!h&&!r.inFlow&&S.length>1024){if(p)throw Error("With simple keys, single line scalar must not span more than 1024 characters");h=!0}if(r.inFlow){if(i||t==null){if(b&&o)o();return S===""?"?":h?`? ${S}`:S}}else if(i&&!p||t==null&&h){if(S=`? ${S}`,m&&!b)S+=Xu.lineComment(S,r.indent,u(m));else if(y&&n)n();return S}if(b)m=null;if(h){if(m)S+=Xu.lineComment(S,r.indent,u(m));S=`? ${S}
|
|
300
300
|
${a}:`}else if(S=`${S}:`,m)S+=Xu.lineComment(S,r.indent,u(m));let x,_,A;if(go.isNode(t))x=!!t.spaceBefore,_=t.commentBefore,A=t.comment;else if(x=!1,_=null,A=null,t&&typeof t==="object")t=s.createNode(t);if(r.implicitKey=!1,!h&&!m&&go.isScalar(t))r.indentAtStart=S.length+1;if(y=!1,!d&&c.length>=2&&!r.inFlow&&!h&&go.isSeq(t)&&!t.flow&&!t.tag&&!t.anchor)r.indent=r.indent.substring(2);let O=!1,L=mL.stringify(t,r,()=>O=!0,()=>y=!0),z=" ";if(m||x||_){if(z=x?`
|
|
301
301
|
`:"",_){let H=u(_);z+=`
|
|
302
302
|
${Xu.indentComment(H,r.indent)}`}if(L===""&&!r.inFlow){if(z===`
|
|
@@ -306,32 +306,32 @@ ${Xu.indentComment(H,r.indent)}`}if(L===""&&!r.inFlow){if(z===`
|
|
|
306
306
|
${r.indent}`}else if(!h&&go.isCollection(t)){let H=L[0],P=L.indexOf(`
|
|
307
307
|
`),W=P!==-1,ee=r.inFlow??t.flow??t.items.length===0;if(W||!ee){let j=!1;if(W&&(H==="&"||H==="!")){let R=L.indexOf(" ");if(H==="&"&&R!==-1&&R<P&&L[R+1]==="!")R=L.indexOf(" ",R+1);if(R===-1||P<R)j=!0}if(!j)z=`
|
|
308
308
|
${r.indent}`}}else if(L===""||L[0]===`
|
|
309
|
-
`)z="";if(S+=z+L,r.inFlow){if(O&&o)o()}else if(A&&!O)S+=Xu.lineComment(S,r.indent,u(A));else if(y&&n)n();return S}
|
|
309
|
+
`)z="";if(S+=z+L,r.inFlow){if(O&&o)o()}else if(A&&!O)S+=Xu.lineComment(S,r.indent,u(A));else if(y&&n)n();return S}$X.stringifyPair=RX});var Tk=ge(function(zX){var gL=qr("process");function CX(e,...t){if(e==="debug")console.log(...t)}function PX(e,t){if(e==="debug"||e==="warn")if(typeof gL.emitWarning==="function")gL.emitWarning(t);else console.warn(t)}zX.debug=CX;zX.warn=PX});var Lh=ge(function(BX){var Dh=qe(),yL=Et(),zh="<<",Nh={identify:(e)=>e===zh||typeof e==="symbol"&&e.description===zh,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new yL.Scalar(Symbol(zh)),{addToJSMap:bL}),stringify:()=>zh},LX=(e,t)=>(Nh.identify(t)||Dh.isScalar(t)&&(!t.type||t.type===yL.Scalar.PLAIN)&&Nh.identify(t.value))&&e?.doc.schema.tags.some((r)=>r.tag===Nh.tag&&r.default);function bL(e,t,r){let o=SL(e,r);if(Dh.isSeq(o))for(let n of o.items)Rk(e,t,n);else if(Array.isArray(o))for(let n of o)Rk(e,t,n);else Rk(e,t,o)}function Rk(e,t,r){let o=SL(e,r);if(!Dh.isMap(o))throw Error("Merge sources must be maps or map aliases");let n=o.toJSON(null,e,Map);for(let[i,s]of n)if(t instanceof Map){if(!t.has(i))t.set(i,s)}else if(t instanceof Set)t.add(i);else if(!Object.prototype.hasOwnProperty.call(t,i))Object.defineProperty(t,i,{value:s,writable:!0,enumerable:!0,configurable:!0});return t}function SL(e,t){return e&&Dh.isAlias(t)?t.resolve(e.doc,e):t}BX.addMergeToJSMap=bL;BX.isMergeKey=LX;BX.merge=Nh});var Ok=ge(function(HX){var MX=Tk(),vL=Lh(),qX=Yu(),wL=qe(),$k=fi();function FX(e,t,{key:r,value:o}){if(wL.isNode(r)&&r.addToJSMap)r.addToJSMap(e,t,o);else if(vL.isMergeKey(e,r))vL.addMergeToJSMap(e,t,o);else{let n=$k.toJS(r,"",e);if(t instanceof Map)t.set(n,$k.toJS(o,n,e));else if(t instanceof Set)t.add(n);else{let i=KX(r,n,e),s=$k.toJS(o,i,e);if(i in t)Object.defineProperty(t,i,{value:s,writable:!0,enumerable:!0,configurable:!0});else t[i]=s}}return t}function KX(e,t,r){if(t===null)return"";if(typeof t!=="object")return String(t);if(wL.isNode(e)&&r?.doc){let o=qX.createStringifyContext(r.doc,{});o.anchors=new Set;for(let i of r.anchors.keys())o.anchors.add(i.anchor);o.inFlow=!0,o.inStringifyKey=!0;let n=e.toString(o);if(!r.mapKeyWarned){let i=JSON.stringify(n);if(i.length>40)i=i.substring(0,36)+'..."';MX.warn(r.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${i}. Set mapAsMap: true to use object keys.`),r.mapKeyWarned=!0}return n}return JSON.stringify(t)}HX.addPairToJSMap=FX});var gi=ge(function(QX){var xL=Vu(),VX=hL(),WX=Ok(),Bh=qe();function GX(e,t,r){let o=xL.createNode(e,void 0,r),n=xL.createNode(t,void 0,r);return new jh(o,n)}class jh{constructor(e,t=null){Object.defineProperty(this,Bh.NODE_TYPE,{value:Bh.PAIR}),this.key=e,this.value=t}clone(e){let{key:t,value:r}=this;if(Bh.isNode(t))t=t.clone(e);if(Bh.isNode(r))r=r.clone(e);return new jh(t,r)}toJSON(e,t){let r=t?.mapAsMap?new Map:{};return WX.addPairToJSMap(t,r,this)}toString(e,t,r){return e?.doc?VX.stringifyPair(this,e,t,r):JSON.stringify(this)}}QX.Pair=jh;QX.createPair=GX});var Ck=ge(function(nee){var $s=qe(),_L=Yu(),Zh=Wu();function eee(e,t,r){return(t.inFlow??e.flow?ree:tee)(e,t,r)}function tee({comment:e,items:t},r,{blockItemPrefix:o,flowChars:n,itemIndent:i,onChompKeep:s,onComment:a}){let{indent:c,options:{commentString:u}}=r,d=Object.assign({},r,{indent:i,type:null}),p=!1,m=[];for(let b=0;b<t.length;++b){let y=t[b],S=null;if($s.isNode(y)){if(!p&&y.spaceBefore)m.push("");if(Uh(r,m,y.commentBefore,p),y.comment)S=y.comment}else if($s.isPair(y)){let _=$s.isNode(y.key)?y.key:null;if(_){if(!p&&_.spaceBefore)m.push("");Uh(r,m,_.commentBefore,p)}}p=!1;let x=_L.stringify(y,d,()=>S=null,()=>p=!0);if(S)x+=Zh.lineComment(x,i,u(S));if(p&&S)p=!1;m.push(o+x)}let h;if(m.length===0)h=n.start+n.end;else{h=m[0];for(let b=1;b<m.length;++b){let y=m[b];h+=y?`
|
|
310
310
|
${c}${y}`:`
|
|
311
311
|
`}}if(e){if(h+=`
|
|
312
|
-
`+Zh.indentComment(u(e),c),a)a()}else if(p&&s)s();return h}function
|
|
312
|
+
`+Zh.indentComment(u(e),c),a)a()}else if(p&&s)s();return h}function ree({items:e},t,{flowChars:r,itemIndent:o}){let{indent:n,indentStep:i,flowCollectionPadding:s,options:{commentString:a}}=t;o+=i;let c=Object.assign({},t,{indent:o,inFlow:!0,type:null}),u=!1,d=0,p=[];for(let b=0;b<e.length;++b){let y=e[b],S=null;if($s.isNode(y)){if(y.spaceBefore)p.push("");if(Uh(t,p,y.commentBefore,!1),y.comment)S=y.comment}else if($s.isPair(y)){let _=$s.isNode(y.key)?y.key:null;if(_){if(_.spaceBefore)p.push("");if(Uh(t,p,_.commentBefore,!1),_.comment)u=!0}let A=$s.isNode(y.value)?y.value:null;if(A){if(A.comment)S=A.comment;if(A.commentBefore)u=!0}else if(y.value==null&&_?.comment)S=_.comment}if(S)u=!0;let x=_L.stringify(y,c,()=>S=null);if(u||(u=p.length>d||x.includes(`
|
|
313
313
|
`)),b<e.length-1)x+=",";else if(t.options.trailingComma){if(t.options.lineWidth>0)u||(u=p.reduce((_,A)=>_+A.length+2,2)+(x.length+2)>t.options.lineWidth);if(u)x+=","}if(S)x+=Zh.lineComment(x,o,a(S));p.push(x),d=p.length}let{start:m,end:h}=r;if(p.length===0)return m+h;else{if(!u){let b=p.reduce((y,S)=>y+S.length+2,2);u=t.options.lineWidth>0&&b>t.options.lineWidth}if(u){let b=m;for(let y of p)b+=y?`
|
|
314
314
|
${i}${n}${y}`:`
|
|
315
315
|
`;return`${b}
|
|
316
|
-
${n}${h}`}else return`${m}${s}${p.join(" ")}${s}${h}`}}function Uh({indent:e,options:{commentString:t}},r,o,n){if(o&&n)o=o.replace(/^\n+/,"");if(o){let i=Zh.indentComment(t(o),e);r.push(i.trimStart())}}
|
|
317
|
-
`:" ")}return
|
|
316
|
+
${n}${h}`}else return`${m}${s}${p.join(" ")}${s}${h}`}}function Uh({indent:e,options:{commentString:t}},r,o,n){if(o&&n)o=o.replace(/^\n+/,"");if(o){let i=Zh.indentComment(t(o),e);r.push(i.trimStart())}}nee.stringifyCollection=eee});var bi=ge(function(lee){var iee=Ck(),see=Ok(),aee=$h(),yi=qe(),Mh=gi(),cee=Et();function ed(e,t){let r=yi.isScalar(t)?t.value:t;for(let o of e)if(yi.isPair(o)){if(o.key===t||o.key===r)return o;if(yi.isScalar(o.key)&&o.key.value===r)return o}return}class EL extends aee.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(yi.MAP,e);this.items=[]}static from(e,t,r){let{keepUndefined:o,replacer:n}=r,i=new this(e),s=(a,c)=>{if(typeof n==="function")c=n.call(t,a,c);else if(Array.isArray(n)&&!n.includes(a))return;if(c!==void 0||o)i.items.push(Mh.createPair(a,c,r))};if(t instanceof Map)for(let[a,c]of t)s(a,c);else if(t&&typeof t==="object")for(let a of Object.keys(t))s(a,t[a]);if(typeof e.sortMapEntries==="function")i.items.sort(e.sortMapEntries);return i}add(e,t){let r;if(yi.isPair(e))r=e;else if(!e||typeof e!=="object"||!("key"in e))r=new Mh.Pair(e,e?.value);else r=new Mh.Pair(e.key,e.value);let o=ed(this.items,r.key),n=this.schema?.sortMapEntries;if(o){if(!t)throw Error(`Key ${r.key} already set`);if(yi.isScalar(o.value)&&cee.isScalarValue(r.value))o.value.value=r.value;else o.value=r.value}else if(n){let i=this.items.findIndex((s)=>n(r,s)<0);if(i===-1)this.items.push(r);else this.items.splice(i,0,r)}else this.items.push(r)}delete(e){let t=ed(this.items,e);if(!t)return!1;return this.items.splice(this.items.indexOf(t),1).length>0}get(e,t){let o=ed(this.items,e)?.value;return(!t&&yi.isScalar(o)?o.value:o)??void 0}has(e){return!!ed(this.items,e)}set(e,t){this.add(new Mh.Pair(e,t),!0)}toJSON(e,t,r){let o=r?new r:t?.mapAsMap?new Map:{};if(t?.onCreate)t.onCreate(o);for(let n of this.items)see.addPairToJSMap(t,o,n);return o}toString(e,t,r){if(!e)return JSON.stringify(this);for(let o of this.items)if(!yi.isPair(o))throw Error(`Map items must all be pairs; found ${JSON.stringify(o)} instead`);if(!e.allNullValues&&this.hasAllNullValues(!1))e=Object.assign({},e,{allNullValues:!0});return iee.stringifyCollection(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:r,onComment:t})}}lee.YAMLMap=EL;lee.findPair=ed});var vc=ge(function(mee){var pee=qe(),kL=bi(),fee={collection:"map",default:!0,nodeClass:kL.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(e,t){if(!pee.isMap(e))t("Expected a mapping for this tag");return e},createNode:(e,t,r)=>kL.YAMLMap.from(e,t,r)};mee.map=fee});var Si=ge(function(wee){var gee=Vu(),yee=Ck(),bee=$h(),Fh=qe(),See=Et(),vee=fi();class IL extends bee.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(Fh.SEQ,e);this.items=[]}add(e){this.items.push(e)}delete(e){let t=qh(e);if(typeof t!=="number")return!1;return this.items.splice(t,1).length>0}get(e,t){let r=qh(e);if(typeof r!=="number")return;let o=this.items[r];return!t&&Fh.isScalar(o)?o.value:o}has(e){let t=qh(e);return typeof t==="number"&&t<this.items.length}set(e,t){let r=qh(e);if(typeof r!=="number")throw Error(`Expected a valid index, not ${e}.`);let o=this.items[r];if(Fh.isScalar(o)&&See.isScalarValue(t))o.value=t;else this.items[r]=t}toJSON(e,t){let r=[];if(t?.onCreate)t.onCreate(r);let o=0;for(let n of this.items)r.push(vee.toJS(n,String(o++),t));return r}toString(e,t,r){if(!e)return JSON.stringify(this);return yee.stringifyCollection(this,e,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(e.indent||"")+" ",onChompKeep:r,onComment:t})}static from(e,t,r){let{replacer:o}=r,n=new this(e);if(t&&Symbol.iterator in Object(t)){let i=0;for(let s of t){if(typeof o==="function"){let a=t instanceof Set?s:String(i++);s=o.call(t,a,s)}n.items.push(gee.createNode(s,void 0,r))}}return n}}function qh(e){let t=Fh.isScalar(e)?e.value:e;if(t&&typeof t==="string")t=Number(t);return typeof t==="number"&&Number.isInteger(t)&&t>=0?t:null}wee.YAMLSeq=IL});var wc=ge(function(kee){var _ee=qe(),AL=Si(),Eee={collection:"seq",default:!0,nodeClass:AL.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(e,t){if(!_ee.isSeq(e))t("Expected a sequence for this tag");return e},createNode:(e,t,r)=>AL.YAMLSeq.from(e,t,r)};kee.seq=Eee});var td=ge(function(Ree){var Aee=Qu(),Tee={identify:(e)=>typeof e==="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:(e)=>e,stringify(e,t,r,o){return t=Object.assign({actualString:!0},t),Aee.stringifyString(e,t,r,o)}};Ree.string=Tee});var Kh=ge(function(Oee){var TL=Et(),RL={identify:(e)=>e==null,createNode:()=>new TL.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new TL.Scalar(null),stringify:({source:e},t)=>typeof e==="string"&&RL.test.test(e)?e:t.options.nullStr};Oee.nullTag=RL});var Pk=ge(function(zee){var Pee=Et(),$L={identify:(e)=>typeof e==="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:(e)=>new Pee.Scalar(e[0]==="t"||e[0]==="T"),stringify({source:e,value:t},r){if(e&&$L.test.test(e)){let o=e[0]==="t"||e[0]==="T";if(t===o)return e}return t?r.options.trueStr:r.options.falseStr}};zee.boolTag=$L});var xc=ge(function(Lee){function Dee({format:e,minFractionDigits:t,tag:r,value:o}){if(typeof o==="bigint")return String(o);let n=typeof o==="number"?o:Number(o);if(!isFinite(n))return isNaN(n)?".nan":n<0?"-.inf":".inf";let i=Object.is(o,-0)?"-0":JSON.stringify(o);if(!e&&t&&(!r||r==="tag:yaml.org,2002:float")&&/^-?\d/.test(i)&&!i.includes("e")){let s=i.indexOf(".");if(s<0)s=i.length,i+=".";let a=t-(i.length-s-1);while(a-- >0)i+="0"}return i}Lee.stringifyNumber=Dee});var Nk=ge(function(qee){var jee=Et(),zk=xc(),Zee={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:(e)=>e.slice(-3).toLowerCase()==="nan"?NaN:e[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:zk.stringifyNumber},Uee={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:(e)=>parseFloat(e),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():zk.stringifyNumber(e)}},Mee={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(e){let t=new jee.Scalar(parseFloat(e)),r=e.indexOf(".");if(r!==-1&&e[e.length-1]==="0")t.minFractionDigits=e.length-r-1;return t},stringify:zk.stringifyNumber};qee.float=Mee;qee.floatExp=Uee;qee.floatNaN=Zee});var Lk=ge(function(Gee){var OL=xc(),Hh=(e)=>typeof e==="bigint"||Number.isInteger(e),Dk=(e,t,r,{intAsBigInt:o})=>o?BigInt(e):parseInt(e.substring(t),r);function CL(e,t,r){let{value:o}=e;if(Hh(o)&&o>=0)return r+o.toString(t);return OL.stringifyNumber(e)}var Jee={identify:(e)=>Hh(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(e,t,r)=>Dk(e,2,8,r),stringify:(e)=>CL(e,8,"0o")},Vee={identify:Hh,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(e,t,r)=>Dk(e,0,10,r),stringify:OL.stringifyNumber},Wee={identify:(e)=>Hh(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(e,t,r)=>Dk(e,2,16,r),stringify:(e)=>CL(e,16,"0x")};Gee.int=Vee;Gee.intHex=Wee;Gee.intOct=Jee});var PL=ge(function(ste){var ete=vc(),tte=Kh(),rte=wc(),nte=td(),ote=Pk(),Bk=Nk(),jk=Lk(),ite=[ete.map,rte.seq,nte.string,tte.nullTag,ote.boolTag,jk.intOct,jk.int,jk.intHex,Bk.floatNaN,Bk.floatExp,Bk.float];ste.schema=ite});var NL=ge(function(mte){var cte=Et(),lte=vc(),ute=wc();function zL(e){return typeof e==="bigint"||Number.isInteger(e)}var Jh=({value:e})=>JSON.stringify(e),dte=[{identify:(e)=>typeof e==="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:(e)=>e,stringify:Jh},{identify:(e)=>e==null,createNode:()=>new cte.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:Jh},{identify:(e)=>typeof e==="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:(e)=>e==="true",stringify:Jh},{identify:zL,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(e,t,{intAsBigInt:r})=>r?BigInt(e):parseInt(e,10),stringify:({value:e})=>zL(e)?e.toString():JSON.stringify(e)},{identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:(e)=>parseFloat(e),stringify:Jh}],pte={default:!0,tag:"",test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}},fte=[lte.map,ute.seq].concat(dte,pte);mte.schema=fte});var Uk=ge(function(bte){var rd=qr("buffer"),Zk=Et(),gte=Qu(),yte={identify:(e)=>e instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(e,t){if(typeof rd.Buffer==="function")return rd.Buffer.from(e,"base64");else if(typeof atob==="function"){let r=atob(e.replace(/[\n\r]/g,"")),o=new Uint8Array(r.length);for(let n=0;n<r.length;++n)o[n]=r.charCodeAt(n);return o}else return t("This environment does not support reading binary tags; either Buffer or atob is required"),e},stringify({comment:e,type:t,value:r},o,n,i){if(!r)return"";let s=r,a;if(typeof rd.Buffer==="function")a=s instanceof rd.Buffer?s.toString("base64"):rd.Buffer.from(s.buffer).toString("base64");else if(typeof btoa==="function"){let c="";for(let u=0;u<s.length;++u)c+=String.fromCharCode(s[u]);a=btoa(c)}else throw Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(t??(t=Zk.Scalar.BLOCK_LITERAL),t!==Zk.Scalar.QUOTE_DOUBLE){let c=Math.max(o.options.lineWidth-o.indent.length,o.options.minContentWidth),u=Math.ceil(a.length/c),d=Array(u);for(let p=0,m=0;p<u;++p,m+=c)d[p]=a.substr(m,c);a=d.join(t===Zk.Scalar.BLOCK_LITERAL?`
|
|
317
|
+
`:" ")}return gte.stringifyString({comment:e,type:t,value:a},o,n,i)}};bte.binary=yte});var Wh=ge(function(_te){var Vh=qe(),Mk=gi(),vte=Et(),wte=Si();function DL(e,t){if(Vh.isSeq(e))for(let r=0;r<e.items.length;++r){let o=e.items[r];if(Vh.isPair(o))continue;else if(Vh.isMap(o)){if(o.items.length>1)t("Each pair must have its own sequence indicator");let n=o.items[0]||new Mk.Pair(new vte.Scalar(null));if(o.commentBefore)n.key.commentBefore=n.key.commentBefore?`${o.commentBefore}
|
|
318
318
|
${n.key.commentBefore}`:o.commentBefore;if(o.comment){let i=n.value??n.key;i.comment=i.comment?`${o.comment}
|
|
319
|
-
${i.comment}`:o.comment}o=n}e.items[r]=Vh.isPair(o)?o:new Mk.Pair(o)}else t("Expected a sequence for this tag");return e}function LL(e,t,r){let{replacer:o}=r,n=new vte.YAMLSeq(e);n.tag="tag:yaml.org,2002:pairs";let i=0;if(t&&Symbol.iterator in Object(t))for(let s of t){if(typeof o==="function")s=o.call(t,String(i++),s);let a,c;if(Array.isArray(s))if(s.length===2)a=s[0],c=s[1];else throw TypeError(`Expected [key, value] tuple: ${s}`);else if(s&&s instanceof Object){let u=Object.keys(s);if(u.length===1)a=u[0],c=s[a];else throw TypeError(`Expected tuple with one key, not ${u.length} keys`)}else a=s;n.items.push(Mk.createPair(a,c,r))}return n}var wte={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:DL,createNode:LL};xte.createPairs=LL;xte.pairs=wte;xte.resolvePairs=DL});var Fk=ge(function(Tte){var BL=qe(),qk=fi(),nd=bi(),Ite=Si(),jL=Wh();class Os extends Ite.YAMLSeq{constructor(){super();this.add=nd.YAMLMap.prototype.add.bind(this),this.delete=nd.YAMLMap.prototype.delete.bind(this),this.get=nd.YAMLMap.prototype.get.bind(this),this.has=nd.YAMLMap.prototype.has.bind(this),this.set=nd.YAMLMap.prototype.set.bind(this),this.tag=Os.tag}toJSON(e,t){if(!t)return super.toJSON(e);let r=new Map;if(t?.onCreate)t.onCreate(r);for(let o of this.items){let n,i;if(BL.isPair(o))n=qk.toJS(o.key,"",t),i=qk.toJS(o.value,n,t);else n=qk.toJS(o,"",t);if(r.has(n))throw Error("Ordered maps must not include duplicate keys");r.set(n,i)}return r}static from(e,t,r){let o=jL.createPairs(e,t,r),n=new this;return n.items=o.items,n}}Os.tag="tag:yaml.org,2002:omap";var Ate={collection:"seq",identify:(e)=>e instanceof Map,nodeClass:Os,default:!1,tag:"tag:yaml.org,2002:omap",resolve(e,t){let r=jL.resolvePairs(e,t),o=[];for(let{key:n}of r.items)if(BL.isScalar(n))if(o.includes(n.value))t(`Ordered maps must not include duplicate keys: ${n.value}`);else o.push(n.value);return Object.assign(new Os,r)},createNode:(e,t,r)=>Os.from(e,t,r)};Tte.YAMLOMap=Os;Tte.omap=Ate});var FL=ge(function(Ote){var ZL=Et();function UL({value:e,source:t},r){if(t&&(e?ML:qL).test.test(t))return t;return e?r.options.trueStr:r.options.falseStr}var ML={identify:(e)=>e===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new ZL.Scalar(!0),stringify:UL},qL={identify:(e)=>e===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new ZL.Scalar(!1),stringify:UL};Ote.falseTag=qL;Ote.trueTag=ML});var KL=ge(function(Bte){var zte=Et(),Kk=xc(),Nte={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:(e)=>e.slice(-3).toLowerCase()==="nan"?NaN:e[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:Kk.stringifyNumber},Dte={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:(e)=>parseFloat(e.replace(/_/g,"")),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():Kk.stringifyNumber(e)}},Lte={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){let t=new zte.Scalar(parseFloat(e.replace(/_/g,""))),r=e.indexOf(".");if(r!==-1){let o=e.substring(r+1).replace(/_/g,"");if(o[o.length-1]==="0")t.minFractionDigits=o.length}return t},stringify:Kk.stringifyNumber};Bte.float=Lte;Bte.floatExp=Dte;Bte.floatNaN=Nte});var JL=ge(function(Hte){var HL=xc(),od=(e)=>typeof e==="bigint"||Number.isInteger(e);function Gh(e,t,r,{intAsBigInt:o}){let n=e[0];if(n==="-"||n==="+")t+=1;if(e=e.substring(t).replace(/_/g,""),o){switch(r){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`;break}let s=BigInt(e);return n==="-"?BigInt(-1)*s:s}let i=parseInt(e,r);return n==="-"?-1*i:i}function Hk(e,t,r){let{value:o}=e;if(od(o)){let n=o.toString(t);return o<0?"-"+r+n.substr(1):r+n}return HL.stringifyNumber(e)}var Mte={identify:od,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,r)=>Gh(e,2,2,r),stringify:(e)=>Hk(e,2,"0b")},qte={identify:od,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(e,t,r)=>Gh(e,1,8,r),stringify:(e)=>Hk(e,8,"0")},Fte={identify:od,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,r)=>Gh(e,0,10,r),stringify:HL.stringifyNumber},Kte={identify:od,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,r)=>Gh(e,2,16,r),stringify:(e)=>Hk(e,16,"0x")};Hte.int=Fte;Hte.intBin=Mte;Hte.intHex=Kte;Hte.intOct=qte});var Jk=ge(function(Yte){var Xh=qe(),Qh=gi(),Yh=bi();class Cs extends Yh.YAMLMap{constructor(e){super(e);this.tag=Cs.tag}add(e){let t;if(Xh.isPair(e))t=e;else if(e&&typeof e==="object"&&"key"in e&&"value"in e&&e.value===null)t=new Qh.Pair(e.key,null);else t=new Qh.Pair(e,null);if(!Yh.findPair(this.items,t.key))this.items.push(t)}get(e,t){let r=Yh.findPair(this.items,e);return!t&&Xh.isPair(r)?Xh.isScalar(r.key)?r.key.value:r.key:r}set(e,t){if(typeof t!=="boolean")throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let r=Yh.findPair(this.items,e);if(r&&!t)this.items.splice(this.items.indexOf(r),1);else if(!r&&t)this.items.push(new Qh.Pair(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,r){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,r);else throw Error("Set items must all have null values")}static from(e,t,r){let{replacer:o}=r,n=new this(e);if(t&&Symbol.iterator in Object(t))for(let i of t){if(typeof o==="function")i=o.call(t,i,i);n.items.push(Qh.createPair(i,null,r))}return n}}Cs.tag="tag:yaml.org,2002:set";var Qte={collection:"map",identify:(e)=>e instanceof Set,nodeClass:Cs,default:!1,tag:"tag:yaml.org,2002:set",createNode:(e,t,r)=>Cs.from(e,t,r),resolve(e,t){if(Xh.isMap(e))if(e.hasAllNullValues(!0))return Object.assign(new Cs,e);else t("Set items must all have null values");else t("Expected a mapping for this tag");return e}};Yte.YAMLSet=Cs;Yte.set=Qte});var Wk=ge(function(ore){var tre=xc();function Vk(e,t){let r=e[0],o=r==="-"||r==="+"?e.substring(1):e,n=(s)=>t?BigInt(s):Number(s),i=o.replace(/_/g,"").split(":").reduce((s,a)=>s*n(60)+n(a),n(0));return r==="-"?n(-1)*i:i}function VL(e){let{value:t}=e,r=(s)=>s;if(typeof t==="bigint")r=(s)=>BigInt(s);else if(isNaN(t)||!isFinite(t))return tre.stringifyNumber(e);let o="";if(t<0)o="-",t*=r(-1);let n=r(60),i=[t%n];if(t<60)i.unshift(0);else if(t=(t-i[0])/n,i.unshift(t%n),t>=60)t=(t-i[0])/n,i.unshift(t);return o+i.map((s)=>String(s).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var rre={identify:(e)=>typeof e==="bigint"||Number.isInteger(e),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(e,t,{intAsBigInt:r})=>Vk(e,r),stringify:VL},nre={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:(e)=>Vk(e,!1),stringify:VL},WL={identify:(e)=>e instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(e){let t=e.match(WL.test);if(!t)throw Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,r,o,n,i,s,a]=t.map(Number),c=t[7]?Number((t[7]+"00").substr(1,3)):0,u=Date.UTC(r,o-1,n,i||0,s||0,a||0,c),d=t[8];if(d&&d!=="Z"){let p=Vk(d,!1);if(Math.abs(p)<30)p*=60;u-=60000*p}return new Date(u)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};ore.floatTime=nre;ore.intTime=rre;ore.timestamp=WL});var QL=ge(function(bre){var cre=vc(),lre=Kh(),ure=wc(),dre=td(),pre=Uk(),GL=FL(),Gk=KL(),eg=JL(),fre=Lh(),mre=Fk(),hre=Wh(),gre=Jk(),Qk=Wk(),yre=[cre.map,ure.seq,dre.string,lre.nullTag,GL.trueTag,GL.falseTag,eg.intBin,eg.intOct,eg.int,eg.intHex,Gk.floatNaN,Gk.floatExp,Gk.float,pre.binary,fre.merge,mre.omap,hre.pairs,gre.set,Qk.intTime,Qk.floatTime,Qk.timestamp];bre.schema=yre});var aB=ge(function(Are){var tB=vc(),vre=Kh(),rB=wc(),wre=td(),xre=Pk(),Yk=Nk(),Xk=Lk(),_re=PL(),Ere=NL(),nB=Uk(),id=Lh(),oB=Fk(),iB=Wh(),YL=QL(),sB=Jk(),tg=Wk(),XL=new Map([["core",_re.schema],["failsafe",[tB.map,rB.seq,wre.string]],["json",Ere.schema],["yaml11",YL.schema],["yaml-1.1",YL.schema]]),eB={binary:nB.binary,bool:xre.boolTag,float:Yk.float,floatExp:Yk.floatExp,floatNaN:Yk.floatNaN,floatTime:tg.floatTime,int:Xk.int,intHex:Xk.intHex,intOct:Xk.intOct,intTime:tg.intTime,map:tB.map,merge:id.merge,null:vre.nullTag,omap:oB.omap,pairs:iB.pairs,seq:rB.seq,set:sB.set,timestamp:tg.timestamp},kre={"tag:yaml.org,2002:binary":nB.binary,"tag:yaml.org,2002:merge":id.merge,"tag:yaml.org,2002:omap":oB.omap,"tag:yaml.org,2002:pairs":iB.pairs,"tag:yaml.org,2002:set":sB.set,"tag:yaml.org,2002:timestamp":tg.timestamp};function Ire(e,t,r){let o=XL.get(t);if(o&&!e)return r&&!o.includes(id.merge)?o.concat(id.merge):o.slice();let n=o;if(!n)if(Array.isArray(e))n=[];else{let i=Array.from(XL.keys()).filter((s)=>s!=="yaml11").map((s)=>JSON.stringify(s)).join(", ");throw Error(`Unknown schema "${t}"; use one of ${i} or define customTags array`)}if(Array.isArray(e))for(let i of e)n=n.concat(i);else if(typeof e==="function")n=e(n.slice());if(r)n=n.concat(id.merge);return n.reduce((i,s)=>{let a=typeof s==="string"?eB[s]:s;if(!a){let c=JSON.stringify(s),u=Object.keys(eB).map((d)=>JSON.stringify(d)).join(", ");throw Error(`Unknown custom tag ${c}; use one of ${u}`)}if(!i.includes(a))i.push(a);return i},[])}Are.coreKnownTags=kre;Are.getTags=Ire});var rI=ge(function(zre){var eI=qe(),$re=vc(),Ore=wc(),Cre=td(),rg=aB(),Pre=(e,t)=>e.key<t.key?-1:e.key>t.key?1:0;class tI{constructor({compat:e,customTags:t,merge:r,resolveKnownTags:o,schema:n,sortMapEntries:i,toStringDefaults:s}){this.compat=Array.isArray(e)?rg.getTags(e,"compat"):e?rg.getTags(null,e):null,this.name=typeof n==="string"&&n||"core",this.knownTags=o?rg.coreKnownTags:{},this.tags=rg.getTags(t,this.name,r),this.toStringOptions=s??null,Object.defineProperty(this,eI.MAP,{value:$re.map}),Object.defineProperty(this,eI.SCALAR,{value:Cre.string}),Object.defineProperty(this,eI.SEQ,{value:Ore.seq}),this.sortMapEntries=typeof i==="function"?i:i===!0?Pre:null}clone(){let e=Object.create(tI.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}}zre.Schema=tI});var cB=ge(function(Bre){var Dre=qe(),nI=Yu(),sd=Wu();function Lre(e,t){let r=[],o=t.directives===!0;if(t.directives!==!1&&e.directives){let c=e.directives.toString(e);if(c)r.push(c),o=!0;else if(e.directives.docStart)o=!0}if(o)r.push("---");let n=nI.createStringifyContext(e,t),{commentString:i}=n.options;if(e.commentBefore){if(r.length!==1)r.unshift("");let c=i(e.commentBefore);r.unshift(sd.indentComment(c,""))}let s=!1,a=null;if(e.contents){if(Dre.isNode(e.contents)){if(e.contents.spaceBefore&&o)r.push("");if(e.contents.commentBefore){let d=i(e.contents.commentBefore);r.push(sd.indentComment(d,""))}n.forceBlockIndent=!!e.comment,a=e.contents.comment}let c=a?void 0:()=>s=!0,u=nI.stringify(e.contents,n,()=>a=null,c);if(a)u+=sd.lineComment(u,"",i(a));if((u[0]==="|"||u[0]===">")&&r[r.length-1]==="---")r[r.length-1]=`--- ${u}`;else r.push(u)}else r.push(nI.stringify(e.contents,n));if(e.directives?.docEnd)if(e.comment){let c=i(e.comment);if(c.includes(`
|
|
319
|
+
${i.comment}`:o.comment}o=n}e.items[r]=Vh.isPair(o)?o:new Mk.Pair(o)}else t("Expected a sequence for this tag");return e}function LL(e,t,r){let{replacer:o}=r,n=new wte.YAMLSeq(e);n.tag="tag:yaml.org,2002:pairs";let i=0;if(t&&Symbol.iterator in Object(t))for(let s of t){if(typeof o==="function")s=o.call(t,String(i++),s);let a,c;if(Array.isArray(s))if(s.length===2)a=s[0],c=s[1];else throw TypeError(`Expected [key, value] tuple: ${s}`);else if(s&&s instanceof Object){let u=Object.keys(s);if(u.length===1)a=u[0],c=s[a];else throw TypeError(`Expected tuple with one key, not ${u.length} keys`)}else a=s;n.items.push(Mk.createPair(a,c,r))}return n}var xte={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:DL,createNode:LL};_te.createPairs=LL;_te.pairs=xte;_te.resolvePairs=DL});var Fk=ge(function(Rte){var BL=qe(),qk=fi(),nd=bi(),Ate=Si(),jL=Wh();class Os extends Ate.YAMLSeq{constructor(){super();this.add=nd.YAMLMap.prototype.add.bind(this),this.delete=nd.YAMLMap.prototype.delete.bind(this),this.get=nd.YAMLMap.prototype.get.bind(this),this.has=nd.YAMLMap.prototype.has.bind(this),this.set=nd.YAMLMap.prototype.set.bind(this),this.tag=Os.tag}toJSON(e,t){if(!t)return super.toJSON(e);let r=new Map;if(t?.onCreate)t.onCreate(r);for(let o of this.items){let n,i;if(BL.isPair(o))n=qk.toJS(o.key,"",t),i=qk.toJS(o.value,n,t);else n=qk.toJS(o,"",t);if(r.has(n))throw Error("Ordered maps must not include duplicate keys");r.set(n,i)}return r}static from(e,t,r){let o=jL.createPairs(e,t,r),n=new this;return n.items=o.items,n}}Os.tag="tag:yaml.org,2002:omap";var Tte={collection:"seq",identify:(e)=>e instanceof Map,nodeClass:Os,default:!1,tag:"tag:yaml.org,2002:omap",resolve(e,t){let r=jL.resolvePairs(e,t),o=[];for(let{key:n}of r.items)if(BL.isScalar(n))if(o.includes(n.value))t(`Ordered maps must not include duplicate keys: ${n.value}`);else o.push(n.value);return Object.assign(new Os,r)},createNode:(e,t,r)=>Os.from(e,t,r)};Rte.YAMLOMap=Os;Rte.omap=Tte});var FL=ge(function(Cte){var ZL=Et();function UL({value:e,source:t},r){if(t&&(e?ML:qL).test.test(t))return t;return e?r.options.trueStr:r.options.falseStr}var ML={identify:(e)=>e===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new ZL.Scalar(!0),stringify:UL},qL={identify:(e)=>e===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new ZL.Scalar(!1),stringify:UL};Cte.falseTag=qL;Cte.trueTag=ML});var KL=ge(function(jte){var Nte=Et(),Kk=xc(),Dte={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:(e)=>e.slice(-3).toLowerCase()==="nan"?NaN:e[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:Kk.stringifyNumber},Lte={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:(e)=>parseFloat(e.replace(/_/g,"")),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():Kk.stringifyNumber(e)}},Bte={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){let t=new Nte.Scalar(parseFloat(e.replace(/_/g,""))),r=e.indexOf(".");if(r!==-1){let o=e.substring(r+1).replace(/_/g,"");if(o[o.length-1]==="0")t.minFractionDigits=o.length}return t},stringify:Kk.stringifyNumber};jte.float=Bte;jte.floatExp=Lte;jte.floatNaN=Dte});var JL=ge(function(Jte){var HL=xc(),od=(e)=>typeof e==="bigint"||Number.isInteger(e);function Gh(e,t,r,{intAsBigInt:o}){let n=e[0];if(n==="-"||n==="+")t+=1;if(e=e.substring(t).replace(/_/g,""),o){switch(r){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`;break}let s=BigInt(e);return n==="-"?BigInt(-1)*s:s}let i=parseInt(e,r);return n==="-"?-1*i:i}function Hk(e,t,r){let{value:o}=e;if(od(o)){let n=o.toString(t);return o<0?"-"+r+n.substr(1):r+n}return HL.stringifyNumber(e)}var qte={identify:od,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,r)=>Gh(e,2,2,r),stringify:(e)=>Hk(e,2,"0b")},Fte={identify:od,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(e,t,r)=>Gh(e,1,8,r),stringify:(e)=>Hk(e,8,"0")},Kte={identify:od,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,r)=>Gh(e,0,10,r),stringify:HL.stringifyNumber},Hte={identify:od,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,r)=>Gh(e,2,16,r),stringify:(e)=>Hk(e,16,"0x")};Jte.int=Kte;Jte.intBin=qte;Jte.intHex=Hte;Jte.intOct=Fte});var Jk=ge(function(Xte){var Xh=qe(),Qh=gi(),Yh=bi();class Cs extends Yh.YAMLMap{constructor(e){super(e);this.tag=Cs.tag}add(e){let t;if(Xh.isPair(e))t=e;else if(e&&typeof e==="object"&&"key"in e&&"value"in e&&e.value===null)t=new Qh.Pair(e.key,null);else t=new Qh.Pair(e,null);if(!Yh.findPair(this.items,t.key))this.items.push(t)}get(e,t){let r=Yh.findPair(this.items,e);return!t&&Xh.isPair(r)?Xh.isScalar(r.key)?r.key.value:r.key:r}set(e,t){if(typeof t!=="boolean")throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let r=Yh.findPair(this.items,e);if(r&&!t)this.items.splice(this.items.indexOf(r),1);else if(!r&&t)this.items.push(new Qh.Pair(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,r){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,r);else throw Error("Set items must all have null values")}static from(e,t,r){let{replacer:o}=r,n=new this(e);if(t&&Symbol.iterator in Object(t))for(let i of t){if(typeof o==="function")i=o.call(t,i,i);n.items.push(Qh.createPair(i,null,r))}return n}}Cs.tag="tag:yaml.org,2002:set";var Yte={collection:"map",identify:(e)=>e instanceof Set,nodeClass:Cs,default:!1,tag:"tag:yaml.org,2002:set",createNode:(e,t,r)=>Cs.from(e,t,r),resolve(e,t){if(Xh.isMap(e))if(e.hasAllNullValues(!0))return Object.assign(new Cs,e);else t("Set items must all have null values");else t("Expected a mapping for this tag");return e}};Xte.YAMLSet=Cs;Xte.set=Yte});var Wk=ge(function(ire){var rre=xc();function Vk(e,t){let r=e[0],o=r==="-"||r==="+"?e.substring(1):e,n=(s)=>t?BigInt(s):Number(s),i=o.replace(/_/g,"").split(":").reduce((s,a)=>s*n(60)+n(a),n(0));return r==="-"?n(-1)*i:i}function VL(e){let{value:t}=e,r=(s)=>s;if(typeof t==="bigint")r=(s)=>BigInt(s);else if(isNaN(t)||!isFinite(t))return rre.stringifyNumber(e);let o="";if(t<0)o="-",t*=r(-1);let n=r(60),i=[t%n];if(t<60)i.unshift(0);else if(t=(t-i[0])/n,i.unshift(t%n),t>=60)t=(t-i[0])/n,i.unshift(t);return o+i.map((s)=>String(s).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var nre={identify:(e)=>typeof e==="bigint"||Number.isInteger(e),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(e,t,{intAsBigInt:r})=>Vk(e,r),stringify:VL},ore={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:(e)=>Vk(e,!1),stringify:VL},WL={identify:(e)=>e instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(e){let t=e.match(WL.test);if(!t)throw Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,r,o,n,i,s,a]=t.map(Number),c=t[7]?Number((t[7]+"00").substr(1,3)):0,u=Date.UTC(r,o-1,n,i||0,s||0,a||0,c),d=t[8];if(d&&d!=="Z"){let p=Vk(d,!1);if(Math.abs(p)<30)p*=60;u-=60000*p}return new Date(u)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};ire.floatTime=ore;ire.intTime=nre;ire.timestamp=WL});var QL=ge(function(Sre){var lre=vc(),ure=Kh(),dre=wc(),pre=td(),fre=Uk(),GL=FL(),Gk=KL(),eg=JL(),mre=Lh(),hre=Fk(),gre=Wh(),yre=Jk(),Qk=Wk(),bre=[lre.map,dre.seq,pre.string,ure.nullTag,GL.trueTag,GL.falseTag,eg.intBin,eg.intOct,eg.int,eg.intHex,Gk.floatNaN,Gk.floatExp,Gk.float,fre.binary,mre.merge,hre.omap,gre.pairs,yre.set,Qk.intTime,Qk.floatTime,Qk.timestamp];Sre.schema=bre});var aB=ge(function(Tre){var tB=vc(),wre=Kh(),rB=wc(),xre=td(),_re=Pk(),Yk=Nk(),Xk=Lk(),Ere=PL(),kre=NL(),nB=Uk(),id=Lh(),oB=Fk(),iB=Wh(),YL=QL(),sB=Jk(),tg=Wk(),XL=new Map([["core",Ere.schema],["failsafe",[tB.map,rB.seq,xre.string]],["json",kre.schema],["yaml11",YL.schema],["yaml-1.1",YL.schema]]),eB={binary:nB.binary,bool:_re.boolTag,float:Yk.float,floatExp:Yk.floatExp,floatNaN:Yk.floatNaN,floatTime:tg.floatTime,int:Xk.int,intHex:Xk.intHex,intOct:Xk.intOct,intTime:tg.intTime,map:tB.map,merge:id.merge,null:wre.nullTag,omap:oB.omap,pairs:iB.pairs,seq:rB.seq,set:sB.set,timestamp:tg.timestamp},Ire={"tag:yaml.org,2002:binary":nB.binary,"tag:yaml.org,2002:merge":id.merge,"tag:yaml.org,2002:omap":oB.omap,"tag:yaml.org,2002:pairs":iB.pairs,"tag:yaml.org,2002:set":sB.set,"tag:yaml.org,2002:timestamp":tg.timestamp};function Are(e,t,r){let o=XL.get(t);if(o&&!e)return r&&!o.includes(id.merge)?o.concat(id.merge):o.slice();let n=o;if(!n)if(Array.isArray(e))n=[];else{let i=Array.from(XL.keys()).filter((s)=>s!=="yaml11").map((s)=>JSON.stringify(s)).join(", ");throw Error(`Unknown schema "${t}"; use one of ${i} or define customTags array`)}if(Array.isArray(e))for(let i of e)n=n.concat(i);else if(typeof e==="function")n=e(n.slice());if(r)n=n.concat(id.merge);return n.reduce((i,s)=>{let a=typeof s==="string"?eB[s]:s;if(!a){let c=JSON.stringify(s),u=Object.keys(eB).map((d)=>JSON.stringify(d)).join(", ");throw Error(`Unknown custom tag ${c}; use one of ${u}`)}if(!i.includes(a))i.push(a);return i},[])}Tre.coreKnownTags=Ire;Tre.getTags=Are});var rI=ge(function(Nre){var eI=qe(),Ore=vc(),Cre=wc(),Pre=td(),rg=aB(),zre=(e,t)=>e.key<t.key?-1:e.key>t.key?1:0;class tI{constructor({compat:e,customTags:t,merge:r,resolveKnownTags:o,schema:n,sortMapEntries:i,toStringDefaults:s}){this.compat=Array.isArray(e)?rg.getTags(e,"compat"):e?rg.getTags(null,e):null,this.name=typeof n==="string"&&n||"core",this.knownTags=o?rg.coreKnownTags:{},this.tags=rg.getTags(t,this.name,r),this.toStringOptions=s??null,Object.defineProperty(this,eI.MAP,{value:Ore.map}),Object.defineProperty(this,eI.SCALAR,{value:Pre.string}),Object.defineProperty(this,eI.SEQ,{value:Cre.seq}),this.sortMapEntries=typeof i==="function"?i:i===!0?zre:null}clone(){let e=Object.create(tI.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}}Nre.Schema=tI});var cB=ge(function(jre){var Lre=qe(),nI=Yu(),sd=Wu();function Bre(e,t){let r=[],o=t.directives===!0;if(t.directives!==!1&&e.directives){let c=e.directives.toString(e);if(c)r.push(c),o=!0;else if(e.directives.docStart)o=!0}if(o)r.push("---");let n=nI.createStringifyContext(e,t),{commentString:i}=n.options;if(e.commentBefore){if(r.length!==1)r.unshift("");let c=i(e.commentBefore);r.unshift(sd.indentComment(c,""))}let s=!1,a=null;if(e.contents){if(Lre.isNode(e.contents)){if(e.contents.spaceBefore&&o)r.push("");if(e.contents.commentBefore){let d=i(e.contents.commentBefore);r.push(sd.indentComment(d,""))}n.forceBlockIndent=!!e.comment,a=e.contents.comment}let c=a?void 0:()=>s=!0,u=nI.stringify(e.contents,n,()=>a=null,c);if(a)u+=sd.lineComment(u,"",i(a));if((u[0]==="|"||u[0]===">")&&r[r.length-1]==="---")r[r.length-1]=`--- ${u}`;else r.push(u)}else r.push(nI.stringify(e.contents,n));if(e.directives?.docEnd)if(e.comment){let c=i(e.comment);if(c.includes(`
|
|
320
320
|
`))r.push("..."),r.push(sd.indentComment(c,""));else r.push(`... ${c}`)}else r.push("...");else{let c=e.comment;if(c&&s)c=c.replace(/^\n+/,"");if(c){if((!s||a)&&r[r.length-1]!=="")r.push("");r.push(sd.indentComment(i(c),""))}}return r.join(`
|
|
321
321
|
`)+`
|
|
322
|
-
`}
|
|
322
|
+
`}jre.stringifyDocument=Bre});var ad=ge(function(Vre){var Ure=Ju(),_c=$h(),Vr=qe(),Mre=gi(),qre=fi(),Fre=rI(),Kre=cB(),oI=Ah(),Hre=_k(),Jre=Vu(),iI=xk();class sI{constructor(e,t,r){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,Vr.NODE_TYPE,{value:Vr.DOC});let o=null;if(typeof t==="function"||Array.isArray(t))o=t;else if(r===void 0&&t)r=t,t=void 0;let n=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},r);this.options=n;let{version:i}=n;if(r?._directives){if(this.directives=r._directives.atDocument(),this.directives.yaml.explicit)i=this.directives.yaml.version}else this.directives=new iI.Directives({version:i});this.setSchema(i,r),this.contents=e===void 0?null:this.createNode(e,o,r)}clone(){let e=Object.create(sI.prototype,{[Vr.NODE_TYPE]:{value:Vr.DOC}});if(e.commentBefore=this.commentBefore,e.comment=this.comment,e.errors=this.errors.slice(),e.warnings=this.warnings.slice(),e.options=Object.assign({},this.options),this.directives)e.directives=this.directives.clone();if(e.schema=this.schema.clone(),e.contents=Vr.isNode(this.contents)?this.contents.clone(e.schema):this.contents,this.range)e.range=this.range.slice();return e}add(e){if(Ec(this.contents))this.contents.add(e)}addIn(e,t){if(Ec(this.contents))this.contents.addIn(e,t)}createAlias(e,t){if(!e.anchor){let r=oI.anchorNames(this);e.anchor=!t||r.has(t)?oI.findNewAnchor(t||"a",r):t}return new Ure.Alias(e.anchor)}createNode(e,t,r){let o=void 0;if(typeof t==="function")e=t.call({"":e},"",e),o=t;else if(Array.isArray(t)){let y=(x)=>typeof x==="number"||x instanceof String||x instanceof Number,S=t.filter(y).map(String);if(S.length>0)t=t.concat(S);o=t}else if(r===void 0&&t)r=t,t=void 0;let{aliasDuplicateObjects:n,anchorPrefix:i,flow:s,keepUndefined:a,onTagObj:c,tag:u}=r??{},{onAnchor:d,setAnchors:p,sourceObjects:m}=oI.createNodeAnchors(this,i||"a"),h={aliasDuplicateObjects:n??!0,keepUndefined:a??!1,onAnchor:d,onTagObj:c,replacer:o,schema:this.schema,sourceObjects:m},b=Jre.createNode(e,u,h);if(s&&Vr.isCollection(b))b.flow=!0;return p(),b}createPair(e,t,r={}){let o=this.createNode(e,null,r),n=this.createNode(t,null,r);return new Mre.Pair(o,n)}delete(e){return Ec(this.contents)?this.contents.delete(e):!1}deleteIn(e){if(_c.isEmptyPath(e)){if(this.contents==null)return!1;return this.contents=null,!0}return Ec(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return Vr.isCollection(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){if(_c.isEmptyPath(e))return!t&&Vr.isScalar(this.contents)?this.contents.value:this.contents;return Vr.isCollection(this.contents)?this.contents.getIn(e,t):void 0}has(e){return Vr.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){if(_c.isEmptyPath(e))return this.contents!==void 0;return Vr.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,t){if(this.contents==null)this.contents=_c.collectionFromPath(this.schema,[e],t);else if(Ec(this.contents))this.contents.set(e,t)}setIn(e,t){if(_c.isEmptyPath(e))this.contents=t;else if(this.contents==null)this.contents=_c.collectionFromPath(this.schema,Array.from(e),t);else if(Ec(this.contents))this.contents.setIn(e,t)}setSchema(e,t={}){if(typeof e==="number")e=String(e);let r;switch(e){case"1.1":if(this.directives)this.directives.yaml.version="1.1";else this.directives=new iI.Directives({version:"1.1"});r={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":if(this.directives)this.directives.yaml.version=e;else this.directives=new iI.Directives({version:e});r={resolveKnownTags:!0,schema:"core"};break;case null:if(this.directives)delete this.directives;r=null;break;default:{let o=JSON.stringify(e);throw Error(`Expected '1.1', '1.2' or null as first argument, but found: ${o}`)}}if(t.schema instanceof Object)this.schema=t.schema;else if(r)this.schema=new Fre.Schema(Object.assign(r,t));else throw Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:e,jsonArg:t,mapAsMap:r,maxAliasCount:o,onAnchor:n,reviver:i}={}){let s={anchors:new Map,doc:this,keep:!e,mapAsMap:r===!0,mapKeyWarned:!1,maxAliasCount:typeof o==="number"?o:100},a=qre.toJS(this.contents,t??"",s);if(typeof n==="function")for(let{count:c,res:u}of s.anchors.values())n(u,c);return typeof i==="function"?Hre.applyReviver(i,{"":a},"",a):a}toJSON(e,t){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:t})}toString(e={}){if(this.errors.length>0)throw Error("Document with errors cannot be stringified");if("indent"in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){let t=JSON.stringify(e.indent);throw Error(`"indent" option must be a positive integer, not ${t}`)}return Kre.stringifyDocument(this,e)}}function Ec(e){if(Vr.isCollection(e))return!0;throw Error("Expected a YAML collection as document contents")}Vre.Document=sI});var cd=ge(function(Qre){class ng extends Error{constructor(e,t,r,o){super();this.name=e,this.code=r,this.message=o,this.pos=t}}class lB extends ng{constructor(e,t,r){super("YAMLParseError",e,t,r)}}class uB extends ng{constructor(e,t,r){super("YAMLWarning",e,t,r)}}var Gre=(e,t)=>(r)=>{if(r.pos[0]===-1)return;r.linePos=r.pos.map((a)=>t.linePos(a));let{line:o,col:n}=r.linePos[0];r.message+=` at line ${o}, column ${n}`;let i=n-1,s=e.substring(t.lineStarts[o-1],t.lineStarts[o]).replace(/[\n\r]+$/,"");if(i>=60&&s.length>80){let a=Math.min(i-39,s.length-79);s="\u2026"+s.substring(a),i-=a-1}if(s.length>80)s=s.substring(0,79)+"\u2026";if(o>1&&/^ *$/.test(s.substring(0,i))){let a=e.substring(t.lineStarts[o-2],t.lineStarts[o-1]);if(a.length>80)a=a.substring(0,79)+`\u2026
|
|
323
323
|
`;s=a+s}if(/[^ ]/.test(s)){let a=1,c=r.linePos[1];if(c?.line===o&&c.col>n)a=Math.max(1,Math.min(c.col-n,80-i));let u=" ".repeat(i)+"^".repeat(a);r.message+=`:
|
|
324
324
|
|
|
325
325
|
${s}
|
|
326
326
|
${u}
|
|
327
|
-
`}};
|
|
328
|
-
`))return!0;if(e.end){for(let t of e.end)if(t.type==="newline")return!0}return!1;case"flow-collection":for(let t of e.items){for(let r of t.start)if(r.type==="newline")return!0;if(t.sep){for(let r of t.sep)if(r.type==="newline")return!0}if(aI(t.key)||aI(t.value))return!0}return!1;default:return!0}}
|
|
329
|
-
`+y.comment;else a.comment=y.comment;continue}if(y.newlineAfterProp||
|
|
330
|
-
`+A.comment;else _.comment=A.comment;let O=new pB.Pair(_);if(r.options.keepSourceTokens)O.srcToken=d;a.items.push(O)}}if(u&&u<c)n(u,"IMPOSSIBLE","Map comment with trailing content");return a.range=[o.offset,c,u??c],a}
|
|
331
|
-
`+z.comment;else u.comment=z.comment;p=z.end;continue}if(!s&&r.options.strict&&
|
|
327
|
+
`}};Qre.YAMLError=ng;Qre.YAMLParseError=lB;Qre.YAMLWarning=uB;Qre.prettifyError=Gre});var ld=ge(function(nne){function rne(e,{flow:t,indicator:r,next:o,offset:n,onError:i,parentIndent:s,startOnNewline:a}){let c=!1,u=a,d=a,p="",m="",h=!1,b=!1,y=null,S=null,x=null,_=null,A=null,O=null,L=null;for(let P of e){if(b){if(P.type!=="space"&&P.type!=="newline"&&P.type!=="comma")i(P.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space");b=!1}if(y){if(u&&P.type!=="comment"&&P.type!=="newline")i(y,"TAB_AS_INDENT","Tabs are not allowed as indentation");y=null}switch(P.type){case"space":if(!t&&(r!=="doc-start"||o?.type!=="flow-collection")&&P.source.includes("\t"))y=P;d=!0;break;case"comment":{if(!d)i(P,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let W=P.source.substring(1)||" ";if(!p)p=W;else p+=m+W;m="",u=!1;break}case"newline":if(u){if(p)p+=P.source;else if(!O||r!=="seq-item-ind")c=!0}else m+=P.source;if(u=!0,h=!0,S||x)_=P;d=!0;break;case"anchor":if(S)i(P,"MULTIPLE_ANCHORS","A node can have at most one anchor");if(P.source.endsWith(":"))i(P.offset+P.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0);S=P,L??(L=P.offset),u=!1,d=!1,b=!0;break;case"tag":{if(x)i(P,"MULTIPLE_TAGS","A node can have at most one tag");x=P,L??(L=P.offset),u=!1,d=!1,b=!0;break}case r:if(S||x)i(P,"BAD_PROP_ORDER",`Anchors and tags must be after the ${P.source} indicator`);if(O)i(P,"UNEXPECTED_TOKEN",`Unexpected ${P.source} in ${t??"collection"}`);O=P,u=r==="seq-item-ind"||r==="explicit-key-ind",d=!1;break;case"comma":if(t){if(A)i(P,"UNEXPECTED_TOKEN",`Unexpected , in ${t}`);A=P,u=!1,d=!1;break}default:i(P,"UNEXPECTED_TOKEN",`Unexpected ${P.type} token`),u=!1,d=!1}}let z=e[e.length-1],H=z?z.offset+z.source.length:n;if(b&&o&&o.type!=="space"&&o.type!=="newline"&&o.type!=="comma"&&(o.type!=="scalar"||o.source!==""))i(o.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space");if(y&&(u&&y.indent<=s||o?.type==="block-map"||o?.type==="block-seq"))i(y,"TAB_AS_INDENT","Tabs are not allowed as indentation");return{comma:A,found:O,spaceBefore:c,comment:p,hasNewline:h,anchor:S,tag:x,newlineAfterProp:_,end:H,start:L??H}}nne.resolveProps=rne});var og=ge(function(ine){function aI(e){if(!e)return null;switch(e.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(e.source.includes(`
|
|
328
|
+
`))return!0;if(e.end){for(let t of e.end)if(t.type==="newline")return!0}return!1;case"flow-collection":for(let t of e.items){for(let r of t.start)if(r.type==="newline")return!0;if(t.sep){for(let r of t.sep)if(r.type==="newline")return!0}if(aI(t.key)||aI(t.value))return!0}return!1;default:return!0}}ine.containsNewline=aI});var cI=ge(function(lne){var ane=og();function cne(e,t,r){if(t?.type==="flow-collection"){let o=t.end[0];if(o.indent===e&&(o.source==="]"||o.source==="}")&&ane.containsNewline(t))r(o,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}lne.flowIndentCheck=cne});var lI=ge(function(pne){var dB=qe();function dne(e,t,r){let{uniqueKeys:o}=e.options;if(o===!1)return!1;let n=typeof o==="function"?o:(i,s)=>i===s||dB.isScalar(i)&&dB.isScalar(s)&&i.value===s.value;return t.some((i)=>n(i.key,r))}pne.mapIncludes=dne});var gB=ge(function(bne){var pB=gi(),mne=bi(),fB=ld(),hne=og(),mB=cI(),gne=lI(),hB="All mapping items must start at the same column";function yne({composeNode:e,composeEmptyNode:t},r,o,n,i){let a=new(i?.nodeClass??mne.YAMLMap)(r.schema);if(r.atRoot)r.atRoot=!1;let c=o.offset,u=null;for(let d of o.items){let{start:p,key:m,sep:h,value:b}=d,y=fB.resolveProps(p,{indicator:"explicit-key-ind",next:m??h?.[0],offset:c,onError:n,parentIndent:o.indent,startOnNewline:!0}),S=!y.found;if(S){if(m){if(m.type==="block-seq")n(c,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key");else if("indent"in m&&m.indent!==o.indent)n(c,"BAD_INDENT",hB)}if(!y.anchor&&!y.tag&&!h){if(u=y.end,y.comment)if(a.comment)a.comment+=`
|
|
329
|
+
`+y.comment;else a.comment=y.comment;continue}if(y.newlineAfterProp||hne.containsNewline(m))n(m??p[p.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else if(y.found?.indent!==o.indent)n(c,"BAD_INDENT",hB);r.atKey=!0;let x=y.end,_=m?e(r,m,y,n):t(r,x,p,null,y,n);if(r.schema.compat)mB.flowIndentCheck(o.indent,m,n);if(r.atKey=!1,gne.mapIncludes(r,a.items,_))n(x,"DUPLICATE_KEY","Map keys must be unique");let A=fB.resolveProps(h??[],{indicator:"map-value-ind",next:b,offset:_.range[2],onError:n,parentIndent:o.indent,startOnNewline:!m||m.type==="block-scalar"});if(c=A.end,A.found){if(S){if(b?.type==="block-map"&&!A.hasNewline)n(c,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings");if(r.options.strict&&y.start<A.found.offset-1024)n(_.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key")}let O=b?e(r,b,A,n):t(r,c,h,null,A,n);if(r.schema.compat)mB.flowIndentCheck(o.indent,b,n);c=O.range[2];let L=new pB.Pair(_,O);if(r.options.keepSourceTokens)L.srcToken=d;a.items.push(L)}else{if(S)n(_.range,"MISSING_CHAR","Implicit map keys need to be followed by map values");if(A.comment)if(_.comment)_.comment+=`
|
|
330
|
+
`+A.comment;else _.comment=A.comment;let O=new pB.Pair(_);if(r.options.keepSourceTokens)O.srcToken=d;a.items.push(O)}}if(u&&u<c)n(u,"IMPOSSIBLE","Map comment with trailing content");return a.range=[o.offset,c,u??c],a}bne.resolveBlockMap=yne});var yB=ge(function(Ene){var vne=Si(),wne=ld(),xne=cI();function _ne({composeNode:e,composeEmptyNode:t},r,o,n,i){let a=new(i?.nodeClass??vne.YAMLSeq)(r.schema);if(r.atRoot)r.atRoot=!1;if(r.atKey)r.atKey=!1;let c=o.offset,u=null;for(let{start:d,value:p}of o.items){let m=wne.resolveProps(d,{indicator:"seq-item-ind",next:p,offset:c,onError:n,parentIndent:o.indent,startOnNewline:!0});if(!m.found)if(m.anchor||m.tag||p)if(p?.type==="block-seq")n(m.end,"BAD_INDENT","All sequence items must start at the same column");else n(c,"MISSING_CHAR","Sequence item without - indicator");else{if(u=m.end,m.comment)a.comment=m.comment;continue}let h=p?e(r,p,m,n):t(r,m.end,d,null,m,n);if(r.schema.compat)xne.flowIndentCheck(o.indent,p,n);c=h.range[2],a.items.push(h)}return a.range=[o.offset,c,u??c],a}Ene.resolveBlockSeq=_ne});var kc=ge(function(Ane){function Ine(e,t,r,o){let n="";if(e){let i=!1,s="";for(let a of e){let{source:c,type:u}=a;switch(u){case"space":i=!0;break;case"comment":{if(r&&!i)o(a,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let d=c.substring(1)||" ";if(!n)n=d;else n+=s+d;s="";break}case"newline":if(n)s+=c;i=!0;break;default:o(a,"UNEXPECTED_TOKEN",`Unexpected ${u} at node end`)}t+=c.length}}return{comment:n,offset:t}}Ane.resolveEnd=Ine});var vB=ge(function(Dne){var Rne=qe(),$ne=gi(),bB=bi(),One=Si(),Cne=kc(),SB=ld(),Pne=og(),zne=lI(),uI="Block collections are not allowed within flow collections",dI=(e)=>e&&(e.type==="block-map"||e.type==="block-seq");function Nne({composeNode:e,composeEmptyNode:t},r,o,n,i){let s=o.start.source==="{",a=s?"flow map":"flow sequence",u=new(i?.nodeClass??(s?bB.YAMLMap:One.YAMLSeq))(r.schema);u.flow=!0;let d=r.atRoot;if(d)r.atRoot=!1;if(r.atKey)r.atKey=!1;let p=o.offset+o.start.source.length;for(let S=0;S<o.items.length;++S){let x=o.items[S],{start:_,key:A,sep:O,value:L}=x,z=SB.resolveProps(_,{flow:a,indicator:"explicit-key-ind",next:A??O?.[0],offset:p,onError:n,parentIndent:o.indent,startOnNewline:!1});if(!z.found){if(!z.anchor&&!z.tag&&!O&&!L){if(S===0&&z.comma)n(z.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`);else if(S<o.items.length-1)n(z.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${a}`);if(z.comment)if(u.comment)u.comment+=`
|
|
331
|
+
`+z.comment;else u.comment=z.comment;p=z.end;continue}if(!s&&r.options.strict&&Pne.containsNewline(A))n(A,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(S===0){if(z.comma)n(z.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`)}else{if(!z.comma)n(z.start,"MISSING_CHAR",`Missing , between ${a} items`);if(z.comment){let H="";e:for(let P of _)switch(P.type){case"comma":case"space":break;case"comment":H=P.source.substring(1);break e;default:break e}if(H){let P=u.items[u.items.length-1];if(Rne.isPair(P))P=P.value??P.key;if(P.comment)P.comment+=`
|
|
332
332
|
`+H;else P.comment=H;z.comment=z.comment.substring(H.length+1)}}}if(!s&&!O&&!z.found){let H=L?e(r,L,z,n):t(r,z.end,O,null,z,n);if(u.items.push(H),p=H.range[2],dI(L))n(H.range,"BLOCK_IN_FLOW",uI)}else{r.atKey=!0;let H=z.end,P=A?e(r,A,z,n):t(r,H,_,null,z,n);if(dI(A))n(P.range,"BLOCK_IN_FLOW",uI);r.atKey=!1;let W=SB.resolveProps(O??[],{flow:a,indicator:"map-value-ind",next:L,offset:P.range[2],onError:n,parentIndent:o.indent,startOnNewline:!1});if(W.found){if(!s&&!z.found&&r.options.strict){if(O)for(let R of O){if(R===W.found)break;if(R.type==="newline"){n(R,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}if(z.start<W.found.offset-1024)n(W.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else if(L)if("source"in L&&L.source?.[0]===":")n(L,"MISSING_CHAR",`Missing space after : in ${a}`);else n(W.start,"MISSING_CHAR",`Missing , or : between ${a} items`);let ee=L?e(r,L,W,n):W.found?t(r,W.end,O,null,W,n):null;if(ee){if(dI(L))n(ee.range,"BLOCK_IN_FLOW",uI)}else if(W.comment)if(P.comment)P.comment+=`
|
|
333
|
-
`+W.comment;else P.comment=W.comment;let j=new
|
|
334
|
-
`+S.comment;else u.comment=S.comment;u.range=[o.offset,y,S.offset]}else u.range=[o.offset,y,y];return u}
|
|
333
|
+
`+W.comment;else P.comment=W.comment;let j=new $ne.Pair(P,ee);if(r.options.keepSourceTokens)j.srcToken=x;if(s){let R=u;if(zne.mapIncludes(r,R.items,P))n(H,"DUPLICATE_KEY","Map keys must be unique");R.items.push(j)}else{let R=new bB.YAMLMap(r.schema);R.flow=!0,R.items.push(j);let B=(ee??P).range;R.range=[P.range[0],B[1],B[2]],u.items.push(R)}p=ee?ee.range[2]:W.end}}let m=s?"}":"]",[h,...b]=o.end,y=p;if(h?.source===m)y=h.offset+h.source.length;else{let S=a[0].toUpperCase()+a.substring(1),x=d?`${S} must end with a ${m}`:`${S} in block collection must be sufficiently indented and end with a ${m}`;if(n(p,d?"MISSING_CHAR":"BAD_INDENT",x),h&&h.source.length!==1)b.unshift(h)}if(b.length>0){let S=Cne.resolveEnd(b,y,r.options.strict,n);if(S.comment)if(u.comment)u.comment+=`
|
|
334
|
+
`+S.comment;else u.comment=S.comment;u.range=[o.offset,y,S.offset]}else u.range=[o.offset,y,y];return u}Dne.resolveFlowCollection=Nne});var wB=ge(function(Hne){var Bne=qe(),jne=Et(),Zne=bi(),Une=Si(),Mne=gB(),qne=yB(),Fne=vB();function pI(e,t,r,o,n,i){let s=r.type==="block-map"?Mne.resolveBlockMap(e,t,r,o,i):r.type==="block-seq"?qne.resolveBlockSeq(e,t,r,o,i):Fne.resolveFlowCollection(e,t,r,o,i),a=s.constructor;if(n==="!"||n===a.tagName)return s.tag=a.tagName,s;if(n)s.tag=n;return s}function Kne(e,t,r,o,n){let i=o.tag,s=!i?null:t.directives.tagName(i.source,(m)=>n(i,"TAG_RESOLVE_FAILED",m));if(r.type==="block-seq"){let{anchor:m,newlineAfterProp:h}=o,b=m&&i?m.offset>i.offset?m:i:m??i;if(b&&(!h||h.offset<b.offset))n(b,"MISSING_CHAR","Missing newline after block sequence props")}let a=r.type==="block-map"?"map":r.type==="block-seq"?"seq":r.start.source==="{"?"map":"seq";if(!i||!s||s==="!"||s===Zne.YAMLMap.tagName&&a==="map"||s===Une.YAMLSeq.tagName&&a==="seq")return pI(e,t,r,n,s);let c=t.schema.tags.find((m)=>m.tag===s&&m.collection===a);if(!c){let m=t.schema.knownTags[s];if(m?.collection===a)t.schema.tags.push(Object.assign({},m,{default:!1})),c=m;else{if(m)n(i,"BAD_COLLECTION_TYPE",`${m.tag} used for ${a} collection, but expects ${m.collection??"scalar"}`,!0);else n(i,"TAG_RESOLVE_FAILED",`Unresolved tag: ${s}`,!0);return pI(e,t,r,n,s)}}let u=pI(e,t,r,n,s,c),d=c.resolve?.(u,(m)=>n(i,"TAG_RESOLVE_FAILED",m),t.options)??u,p=Bne.isNode(d)?d:new jne.Scalar(d);if(p.range=u.range,p.tag=s,c?.format)p.format=c.format;return p}Hne.composeCollection=Kne});var mI=ge(function(Qne){var fI=Et();function Vne(e,t,r){let o=t.offset,n=Wne(t,e.options.strict,r);if(!n)return{value:"",type:null,comment:"",range:[o,o,o]};let i=n.mode===">"?fI.Scalar.BLOCK_FOLDED:fI.Scalar.BLOCK_LITERAL,s=t.source?Gne(t.source):[],a=s.length;for(let y=s.length-1;y>=0;--y){let S=s[y][1];if(S===""||S==="\r")a=y;else break}if(a===0){let y=n.chomp==="+"&&s.length>0?`
|
|
335
335
|
`.repeat(Math.max(1,s.length-1)):"",S=o+n.length;if(t.source)S+=t.source.length;return{value:y,type:i,comment:n.comment,range:[o,S,S]}}let c=t.indent+n.indent,u=t.offset+n.length,d=0;for(let y=0;y<a;++y){let[S,x]=s[y];if(x===""||x==="\r"){if(n.indent===0&&S.length>c)c=S.length}else{if(S.length<c)r(u+S.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator");if(n.indent===0)c=S.length;if(d=y,c===0&&!e.atRoot)r(u,"BAD_INDENT","Block scalar values in collections must be indented");break}u+=S.length+x.length+1}for(let y=s.length-1;y>=a;--y)if(s[y][0].length>c)a=y+1;let p="",m="",h=!1;for(let y=0;y<d;++y)p+=s[y][0].slice(c)+`
|
|
336
336
|
`;for(let y=d;y<a;++y){let[S,x]=s[y];u+=S.length+x.length+1;let _=x[x.length-1]==="\r";if(_)x=x.slice(0,-1);if(x&&S.length<c){let O=`Block scalar lines must not be less indented than their ${n.indent?"explicit indentation indicator":"first line"}`;r(u-x.length-(_?2:1),"BAD_INDENT",O),S=""}if(i===fI.Scalar.BLOCK_LITERAL)p+=m+S.slice(c)+x,m=`
|
|
337
337
|
`;else if(S.length>c||x[0]==="\t"){if(m===" ")m=`
|
|
@@ -346,41 +346,41 @@ ${u}
|
|
|
346
346
|
`+s[y][0].slice(c);if(p[p.length-1]!==`
|
|
347
347
|
`)p+=`
|
|
348
348
|
`;break;default:p+=`
|
|
349
|
-
`}let b=o+n.length+t.source.length;return{value:p,type:i,comment:n.comment,range:[o,b,b]}}function
|
|
349
|
+
`}let b=o+n.length+t.source.length;return{value:p,type:i,comment:n.comment,range:[o,b,b]}}function Wne({offset:e,props:t},r,o){if(t[0].type!=="block-scalar-header")return o(t[0],"IMPOSSIBLE","Block scalar header not found"),null;let{source:n}=t[0],i=n[0],s=0,a="",c=-1;for(let m=1;m<n.length;++m){let h=n[m];if(!a&&(h==="-"||h==="+"))a=h;else{let b=Number(h);if(!s&&b)s=b;else if(c===-1)c=e+m}}if(c!==-1)o(c,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${n}`);let u=!1,d="",p=n.length;for(let m=1;m<t.length;++m){let h=t[m];switch(h.type){case"space":u=!0;case"newline":p+=h.source.length;break;case"comment":if(r&&!u)o(h,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");p+=h.source.length,d=h.source.substring(1);break;case"error":o(h,"UNEXPECTED_TOKEN",h.message),p+=h.source.length;break;default:{let b=`Unexpected token in block scalar header: ${h.type}`;o(h,"UNEXPECTED_TOKEN",b);let y=h.source;if(y&&typeof y==="string")p+=y.length}}}return{mode:i,indent:s,chomp:a,comment:d,length:p}}function Gne(e){let t=e.split(/\n( *)/),r=t[0],o=r.match(/^( *)/),i=[o?.[1]?[o[1],r.slice(o[1].length)]:["",r]];for(let s=1;s<t.length;s+=2)i.push([t[s],t[s+1]]);return i}Qne.resolveBlockScalar=Vne});var gI=ge(function(aoe){var hI=Et(),Xne=kc();function eoe(e,t,r){let{offset:o,type:n,source:i,end:s}=e,a,c,u=(m,h,b)=>r(o+m,h,b);switch(n){case"scalar":a=hI.Scalar.PLAIN,c=toe(i,u);break;case"single-quoted-scalar":a=hI.Scalar.QUOTE_SINGLE,c=roe(i,u);break;case"double-quoted-scalar":a=hI.Scalar.QUOTE_DOUBLE,c=noe(i,u);break;default:return r(e,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${n}`),{value:"",type:null,comment:"",range:[o,o+i.length,o+i.length]}}let d=o+i.length,p=Xne.resolveEnd(s,d,t,r);return{value:c,type:a,comment:p.comment,range:[o,d,p.offset]}}function toe(e,t){let r="";switch(e[0]){case"\t":r="a tab character";break;case",":r="flow indicator character ,";break;case"%":r="directive indicator character %";break;case"|":case">":{r=`block scalar indicator ${e[0]}`;break}case"@":case"`":{r=`reserved character ${e[0]}`;break}}if(r)t(0,"BAD_SCALAR_START",`Plain value cannot start with ${r}`);return xB(e)}function roe(e,t){if(e[e.length-1]!=="'"||e.length===1)t(e.length,"MISSING_CHAR","Missing closing 'quote");return xB(e.slice(1,-1)).replace(/''/g,"'")}function xB(e){let t,r;try{t=new RegExp(`(.*?)(?<![ ])[ ]*\r?
|
|
350
350
|
`,"sy"),r=new RegExp(`[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?
|
|
351
351
|
`,"sy")}catch{t=/(.*?)[ \t]*\r?\n/sy,r=/[ \t]*(.*?)[ \t]*\r?\n/sy}let o=t.exec(e);if(!o)return e;let n=o[1],i=" ",s=t.lastIndex;r.lastIndex=s;while(o=r.exec(e)){if(o[1]==="")if(i===`
|
|
352
352
|
`)n+=i;else i=`
|
|
353
|
-
`;else n+=i+o[1],i=" ";s=r.lastIndex}let a=/[ \t]*(.*)/sy;return a.lastIndex=s,o=a.exec(e),n+i+(o?.[1]??"")}function
|
|
353
|
+
`;else n+=i+o[1],i=" ";s=r.lastIndex}let a=/[ \t]*(.*)/sy;return a.lastIndex=s,o=a.exec(e),n+i+(o?.[1]??"")}function noe(e,t){let r="";for(let o=1;o<e.length-1;++o){let n=e[o];if(n==="\r"&&e[o+1]===`
|
|
354
354
|
`)continue;if(n===`
|
|
355
|
-
`){let{fold:i,offset:s}=
|
|
355
|
+
`){let{fold:i,offset:s}=ooe(e,o);r+=i,o=s}else if(n==="\\"){let i=e[++o],s=ioe[i];if(s)r+=s;else if(i===`
|
|
356
356
|
`){i=e[o+1];while(i===" "||i==="\t")i=e[++o+1]}else if(i==="\r"&&e[o+1]===`
|
|
357
|
-
`){i=e[++o+1];while(i===" "||i==="\t")i=e[++o+1]}else if(i==="x"||i==="u"||i==="U"){let a=i==="x"?2:i==="u"?4:8;r+=
|
|
357
|
+
`){i=e[++o+1];while(i===" "||i==="\t")i=e[++o+1]}else if(i==="x"||i==="u"||i==="U"){let a=i==="x"?2:i==="u"?4:8;r+=soe(e,o+1,a,t),o+=a}else{let a=e.substr(o-1,2);t(o-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),r+=a}}else if(n===" "||n==="\t"){let i=o,s=e[o+1];while(s===" "||s==="\t")s=e[++o+1];if(s!==`
|
|
358
358
|
`&&!(s==="\r"&&e[o+2]===`
|
|
359
|
-
`))r+=o>i?e.slice(i,o+1):n}else r+=n}if(e[e.length-1]!=='"'||e.length===1)t(e.length,"MISSING_CHAR",'Missing closing "quote');return r}function
|
|
359
|
+
`))r+=o>i?e.slice(i,o+1):n}else r+=n}if(e[e.length-1]!=='"'||e.length===1)t(e.length,"MISSING_CHAR",'Missing closing "quote');return r}function ooe(e,t){let r="",o=e[t+1];while(o===" "||o==="\t"||o===`
|
|
360
360
|
`||o==="\r"){if(o==="\r"&&e[t+2]!==`
|
|
361
361
|
`)break;if(o===`
|
|
362
362
|
`)r+=`
|
|
363
|
-
`;t+=1,o=e[t+1]}if(!r)r=" ";return{fold:r,offset:t}}var
|
|
364
|
-
`,r:"\r",t:"\t",v:"\v",N:"\x85",_:"\xA0",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\","\t":"\t"};function
|
|
363
|
+
`;t+=1,o=e[t+1]}if(!r)r=" ";return{fold:r,offset:t}}var ioe={"0":"\x00",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
|
|
364
|
+
`,r:"\r",t:"\t",v:"\v",N:"\x85",_:"\xA0",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\","\t":"\t"};function soe(e,t,r,o){let n=e.substr(t,r),s=n.length===r&&/^[0-9a-fA-F]+$/.test(n)?parseInt(n,16):NaN;try{return String.fromCodePoint(s)}catch{let a=e.substr(t-2,r+2);return o(t-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),a}}aoe.resolveFlowScalar=eoe});var EB=ge(function(moe){var Ps=qe(),_B=Et(),loe=mI(),uoe=gI();function doe(e,t,r,o){let{value:n,type:i,comment:s,range:a}=t.type==="block-scalar"?loe.resolveBlockScalar(e,t,o):uoe.resolveFlowScalar(t,e.options.strict,o),c=r?e.directives.tagName(r.source,(p)=>o(r,"TAG_RESOLVE_FAILED",p)):null,u;if(e.options.stringKeys&&e.atKey)u=e.schema[Ps.SCALAR];else if(c)u=poe(e.schema,n,c,r,o);else if(t.type==="scalar")u=foe(e,n,t,o);else u=e.schema[Ps.SCALAR];let d;try{let p=u.resolve(n,(m)=>o(r??t,"TAG_RESOLVE_FAILED",m),e.options);d=Ps.isScalar(p)?p:new _B.Scalar(p)}catch(p){let m=p instanceof Error?p.message:String(p);o(r??t,"TAG_RESOLVE_FAILED",m),d=new _B.Scalar(n)}if(d.range=a,d.source=n,i)d.type=i;if(c)d.tag=c;if(u.format)d.format=u.format;if(s)d.comment=s;return d}function poe(e,t,r,o,n){if(r==="!")return e[Ps.SCALAR];let i=[];for(let a of e.tags)if(!a.collection&&a.tag===r)if(a.default&&a.test)i.push(a);else return a;for(let a of i)if(a.test?.test(t))return a;let s=e.knownTags[r];if(s&&!s.collection)return e.tags.push(Object.assign({},s,{default:!1,test:void 0})),s;return n(o,"TAG_RESOLVE_FAILED",`Unresolved tag: ${r}`,r!=="tag:yaml.org,2002:str"),e[Ps.SCALAR]}function foe({atKey:e,directives:t,schema:r},o,n,i){let s=r.tags.find((a)=>(a.default===!0||e&&a.default==="key")&&a.test?.test(o))||r[Ps.SCALAR];if(r.compat){let a=r.compat.find((c)=>c.default&&c.test?.test(o))??r[Ps.SCALAR];if(s.tag!==a.tag){let c=t.tagString(s.tag),u=t.tagString(a.tag),d=`Value may be parsed as either ${c} or ${u}`;i(n,"TAG_RESOLVE_FAILED",d,!0)}}return s}moe.composeScalar=doe});var kB=ge(function(yoe){function goe(e,t,r){if(t){r??(r=t.length);for(let o=r-1;o>=0;--o){let n=t[o];switch(n.type){case"space":case"comment":case"newline":e-=n.source.length;continue}n=t[++o];while(n?.type==="space")e+=n.source.length,n=t[++o];break}}return e}yoe.emptyScalarPosition=goe});var TB=ge(function(Ioe){var Soe=Ju(),voe=qe(),woe=wB(),IB=EB(),xoe=kc(),_oe=kB(),Eoe={composeNode:AB,composeEmptyNode:yI};function AB(e,t,r,o){let n=e.atKey,{spaceBefore:i,comment:s,anchor:a,tag:c}=r,u,d=!0;switch(t.type){case"alias":if(u=koe(e,t,o),a||c)o(t,"ALIAS_PROPS","An alias node must not specify any properties");break;case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"block-scalar":if(u=IB.composeScalar(e,t,c,o),a)u.anchor=a.source.substring(1);break;case"block-map":case"block-seq":case"flow-collection":try{if(u=woe.composeCollection(Eoe,e,t,r,o),a)u.anchor=a.source.substring(1)}catch(p){let m=p instanceof Error?p.message:String(p);o(t,"RESOURCE_EXHAUSTION",m)}break;default:{let p=t.type==="error"?t.message:`Unsupported token (type: ${t.type})`;o(t,"UNEXPECTED_TOKEN",p),d=!1}}if(u??(u=yI(e,t.offset,void 0,null,r,o)),a&&u.anchor==="")o(a,"BAD_ALIAS","Anchor cannot be an empty string");if(n&&e.options.stringKeys&&(!voe.isScalar(u)||typeof u.value!=="string"||u.tag&&u.tag!=="tag:yaml.org,2002:str"))o(c??t,"NON_STRING_KEY","With stringKeys, all keys must be strings");if(i)u.spaceBefore=!0;if(s)if(t.type==="scalar"&&t.source==="")u.comment=s;else u.commentBefore=s;if(e.options.keepSourceTokens&&d)u.srcToken=t;return u}function yI(e,t,r,o,{spaceBefore:n,comment:i,anchor:s,tag:a,end:c},u){let d={type:"scalar",offset:_oe.emptyScalarPosition(t,r,o),indent:-1,source:""},p=IB.composeScalar(e,d,a,u);if(s){if(p.anchor=s.source.substring(1),p.anchor==="")u(s,"BAD_ALIAS","Anchor cannot be an empty string")}if(n)p.spaceBefore=!0;if(i)p.comment=i,p.range[2]=c;return p}function koe({options:e},{offset:t,source:r,end:o},n){let i=new Soe.Alias(r.substring(1));if(i.source==="")n(t,"BAD_ALIAS","Alias cannot be an empty string");if(i.source.endsWith(":"))n(t+r.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let s=t+r.length,a=xoe.resolveEnd(o,s,e.strict,n);if(i.range=[t,s,a.offset],a.comment)i.comment=a.comment;return i}Ioe.composeEmptyNode=yI;Ioe.composeNode=AB});var $B=ge(function(Poe){var Roe=ad(),RB=TB(),$oe=kc(),Ooe=ld();function Coe(e,t,{offset:r,start:o,value:n,end:i},s){let a=Object.assign({_directives:t},e),c=new Roe.Document(void 0,a),u={atKey:!1,atRoot:!0,directives:c.directives,options:c.options,schema:c.schema},d=Ooe.resolveProps(o,{indicator:"doc-start",next:n??i?.[0],offset:r,onError:s,parentIndent:0,startOnNewline:!0});if(d.found){if(c.directives.docStart=!0,n&&(n.type==="block-map"||n.type==="block-seq")&&!d.hasNewline)s(d.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")}c.contents=n?RB.composeNode(u,n,d,s):RB.composeEmptyNode(u,d.end,o,null,d,s);let p=c.contents.range[2],m=$oe.resolveEnd(i,p,!1,s);if(m.comment)c.comment=m.comment;return c.range=[r,p,m.offset],c}Poe.composeDoc=Coe});var bI=ge(function(Zoe){var Noe=qr("process"),Doe=xk(),Loe=ad(),ud=cd(),OB=qe(),Boe=$B(),joe=kc();function dd(e){if(typeof e==="number")return[e,e+1];if(Array.isArray(e))return e.length===2?e:[e[0],e[1]];let{offset:t,source:r}=e;return[t,t+(typeof r==="string"?r.length:1)]}function CB(e){let t="",r=!1,o=!1;for(let n=0;n<e.length;++n){let i=e[n];switch(i[0]){case"#":t+=(t===""?"":o?`
|
|
365
365
|
|
|
366
366
|
`:`
|
|
367
|
-
`)+(i.substring(1)||" "),r=!0,o=!1;break;case"%":if(e[n+1]?.[0]!=="#")n+=1;r=!1;break;default:if(!r)o=!0;r=!1}}return{comment:t,afterEmptyLine:o}}class PB{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(t,r,o,n)=>{let i=dd(t);if(n)this.warnings.push(new ud.YAMLWarning(i,r,o));else this.errors.push(new ud.YAMLParseError(i,r,o))},this.directives=new
|
|
367
|
+
`)+(i.substring(1)||" "),r=!0,o=!1;break;case"%":if(e[n+1]?.[0]!=="#")n+=1;r=!1;break;default:if(!r)o=!0;r=!1}}return{comment:t,afterEmptyLine:o}}class PB{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(t,r,o,n)=>{let i=dd(t);if(n)this.warnings.push(new ud.YAMLWarning(i,r,o));else this.errors.push(new ud.YAMLParseError(i,r,o))},this.directives=new Doe.Directives({version:e.version||"1.2"}),this.options=e}decorate(e,t){let{comment:r,afterEmptyLine:o}=CB(this.prelude);if(r){let n=e.contents;if(t)e.comment=e.comment?`${e.comment}
|
|
368
368
|
${r}`:r;else if(o||e.directives.docStart||!n)e.commentBefore=r;else if(OB.isCollection(n)&&!n.flow&&n.items.length>0){let i=n.items[0];if(OB.isPair(i))i=i.key;let s=i.commentBefore;i.commentBefore=s?`${r}
|
|
369
369
|
${s}`:r}else{let i=n.commentBefore;n.commentBefore=i?`${r}
|
|
370
|
-
${i}`:r}}if(t){for(let n=0;n<this.errors.length;++n)e.errors.push(this.errors[n]);for(let n=0;n<this.warnings.length;++n)e.warnings.push(this.warnings[n])}else e.errors=this.errors,e.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:CB(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,r=-1){for(let o of e)yield*this.next(o);yield*this.end(t,r)}*next(e){if(
|
|
371
|
-
${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new ud.YAMLParseError(dd(e),"UNEXPECTED_TOKEN",`Unsupported token ${e.type}`))}}*end(e=!1,t=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let r=Object.assign({_directives:this.directives},this.options),o=new
|
|
370
|
+
${i}`:r}}if(t){for(let n=0;n<this.errors.length;++n)e.errors.push(this.errors[n]);for(let n=0;n<this.warnings.length;++n)e.warnings.push(this.warnings[n])}else e.errors=this.errors,e.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:CB(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,r=-1){for(let o of e)yield*this.next(o);yield*this.end(t,r)}*next(e){if(Noe.env.LOG_STREAM)console.dir(e,{depth:null});switch(e.type){case"directive":this.directives.add(e.source,(t,r,o)=>{let n=dd(e);n[0]+=t,this.onError(n,"BAD_DIRECTIVE",r,o)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let t=Boe.composeDoc(this.options,this.directives,e,this.onError);if(this.atDirectives&&!t.directives.docStart)this.onError(e,"MISSING_CHAR","Missing directives-end/doc-start indicator line");if(this.decorate(t,!1),this.doc)yield this.doc;this.doc=t,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push(e.source);break;case"error":{let t=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,r=new ud.YAMLParseError(dd(e),"UNEXPECTED_TOKEN",t);if(this.atDirectives||!this.doc)this.errors.push(r);else this.doc.errors.push(r);break}case"doc-end":{if(!this.doc){this.errors.push(new ud.YAMLParseError(dd(e),"UNEXPECTED_TOKEN","Unexpected doc-end without preceding document"));break}this.doc.directives.docEnd=!0;let t=joe.resolveEnd(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),t.comment){let r=this.doc.comment;this.doc.comment=r?`${r}
|
|
371
|
+
${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new ud.YAMLParseError(dd(e),"UNEXPECTED_TOKEN",`Unsupported token ${e.type}`))}}*end(e=!1,t=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let r=Object.assign({_directives:this.directives},this.options),o=new Loe.Document(void 0,r);if(this.atDirectives)this.onError(t,"MISSING_CHAR","Missing directives-end indicator line");o.range=[0,t,t],this.decorate(o,!1),yield o}}}Zoe.Composer=PB});var DB=ge(function(Woe){var Moe=mI(),qoe=gI(),Foe=cd(),zB=Qu();function Koe(e,t=!0,r){if(e){let o=(n,i,s)=>{let a=typeof n==="number"?n:Array.isArray(n)?n[0]:n.offset;if(r)r(a,i,s);else throw new Foe.YAMLParseError([a,a+1],i,s)};switch(e.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return qoe.resolveFlowScalar(e,t,o);case"block-scalar":return Moe.resolveBlockScalar({options:{strict:t}},e,o)}}return null}function Hoe(e,t){let{implicitKey:r=!1,indent:o,inFlow:n=!1,offset:i=-1,type:s="PLAIN"}=t,a=zB.stringifyString({type:s,value:e},{implicitKey:r,indent:o>0?" ".repeat(o):"",inFlow:n,options:{blockQuote:!0,lineWidth:-1}}),c=t.end??[{type:"newline",offset:-1,indent:o,source:`
|
|
372
372
|
`}];switch(a[0]){case"|":case">":{let u=a.indexOf(`
|
|
373
373
|
`),d=a.substring(0,u),p=a.substring(u+1)+`
|
|
374
374
|
`,m=[{type:"block-scalar-header",offset:i,indent:o,source:d}];if(!NB(m,c))m.push({type:"newline",offset:-1,indent:o,source:`
|
|
375
|
-
`});return{type:"block-scalar",offset:i,indent:o,props:m,source:p}}case'"':return{type:"double-quoted-scalar",offset:i,indent:o,source:a,end:c};case"'":return{type:"single-quoted-scalar",offset:i,indent:o,source:a,end:c};default:return{type:"scalar",offset:i,indent:o,source:a,end:c}}}function
|
|
375
|
+
`});return{type:"block-scalar",offset:i,indent:o,props:m,source:p}}case'"':return{type:"double-quoted-scalar",offset:i,indent:o,source:a,end:c};case"'":return{type:"single-quoted-scalar",offset:i,indent:o,source:a,end:c};default:return{type:"scalar",offset:i,indent:o,source:a,end:c}}}function Joe(e,t,r={}){let{afterKey:o=!1,implicitKey:n=!1,inFlow:i=!1,type:s}=r,a="indent"in e?e.indent:null;if(o&&typeof a==="number")a+=2;if(!s)switch(e.type){case"single-quoted-scalar":s="QUOTE_SINGLE";break;case"double-quoted-scalar":s="QUOTE_DOUBLE";break;case"block-scalar":{let u=e.props[0];if(u.type!=="block-scalar-header")throw Error("Invalid block scalar header");s=u.source[0]===">"?"BLOCK_FOLDED":"BLOCK_LITERAL";break}default:s="PLAIN"}let c=zB.stringifyString({type:s,value:t},{implicitKey:n||a===null,indent:a!==null&&a>0?" ".repeat(a):"",inFlow:i,options:{blockQuote:!0,lineWidth:-1}});switch(c[0]){case"|":case">":Voe(e,c);break;case'"':SI(e,c,"double-quoted-scalar");break;case"'":SI(e,c,"single-quoted-scalar");break;default:SI(e,c,"scalar")}}function Voe(e,t){let r=t.indexOf(`
|
|
376
376
|
`),o=t.substring(0,r),n=t.substring(r+1)+`
|
|
377
377
|
`;if(e.type==="block-scalar"){let i=e.props[0];if(i.type!=="block-scalar-header")throw Error("Invalid block scalar header");i.source=o,e.source=n}else{let{offset:i}=e,s="indent"in e?e.indent:-1,a=[{type:"block-scalar-header",offset:i,indent:s,source:o}];if(!NB(a,"end"in e?e.end:void 0))a.push({type:"newline",offset:-1,indent:s,source:`
|
|
378
378
|
`});for(let c of Object.keys(e))if(c!=="type"&&c!=="offset")delete e[c];Object.assign(e,{type:"block-scalar",indent:s,props:a,source:n})}}function NB(e,t){if(t)for(let r of t)switch(r.type){case"space":case"comment":e.push(r);break;case"newline":return e.push(r),!0}return!1}function SI(e,t,r){switch(e.type){case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":e.type=r,e.source=t;break;case"block-scalar":{let o=e.props.slice(1),n=t.length;if(e.props[0].type==="block-scalar-header")n-=e.props[0].source.length;for(let i of o)i.offset+=n;delete e.props,Object.assign(e,{type:r,source:t,end:o});break}case"block-map":case"block-seq":{let n={type:"newline",offset:e.offset+t.length,indent:e.indent,source:`
|
|
379
|
-
`};delete e.items,Object.assign(e,{type:r,source:t,end:[n]});break}default:{let o="indent"in e?e.indent:-1,n="end"in e&&Array.isArray(e.end)?e.end.filter((i)=>i.type==="space"||i.type==="comment"||i.type==="newline"):[];for(let i of Object.keys(e))if(i!=="type"&&i!=="offset")delete e[i];Object.assign(e,{type:r,indent:o,source:t,end:n})}}}
|
|
379
|
+
`};delete e.items,Object.assign(e,{type:r,source:t,end:[n]});break}default:{let o="indent"in e?e.indent:-1,n="end"in e&&Array.isArray(e.end)?e.end.filter((i)=>i.type==="space"||i.type==="comment"||i.type==="newline"):[];for(let i of Object.keys(e))if(i!=="type"&&i!=="offset")delete e[i];Object.assign(e,{type:r,indent:o,source:t,end:n})}}}Woe.createScalarToken=Hoe;Woe.resolveAsScalar=Koe;Woe.setScalarValue=Joe});var LB=ge(function(eie){var Xoe=(e)=>("type"in e)?sg(e):ig(e);function sg(e){switch(e.type){case"block-scalar":{let t="";for(let r of e.props)t+=sg(r);return t+e.source}case"block-map":case"block-seq":{let t="";for(let r of e.items)t+=ig(r);return t}case"flow-collection":{let t=e.start.source;for(let r of e.items)t+=ig(r);for(let r of e.end)t+=r.source;return t}case"document":{let t=ig(e);if(e.end)for(let r of e.end)t+=r.source;return t}default:{let t=e.source;if("end"in e&&e.end)for(let r of e.end)t+=r.source;return t}}}function ig({start:e,key:t,sep:r,value:o}){let n="";for(let i of e)n+=i.source;if(t)n+=sg(t);if(r)for(let i of r)n+=i.source;if(o)n+=sg(o);return n}eie.stringify=Xoe});var ZB=ge(function(nie){var vI=Symbol("break visit"),rie=Symbol("skip children"),BB=Symbol("remove item");function zs(e,t){if("type"in e&&e.type==="document")e={start:e.start,value:e.value};jB(Object.freeze([]),e,t)}zs.BREAK=vI;zs.SKIP=rie;zs.REMOVE=BB;zs.itemAtPath=(e,t)=>{let r=e;for(let[o,n]of t){let i=r?.[o];if(i&&"items"in i)r=i.items[n];else return}return r};zs.parentCollection=(e,t)=>{let r=zs.itemAtPath(e,t.slice(0,-1)),o=t[t.length-1][0],n=r?.[o];if(n&&"items"in n)return n;throw Error("Parent collection not found")};function jB(e,t,r){let o=r(t,e);if(typeof o==="symbol")return o;for(let n of["key","value"]){let i=t[n];if(i&&"items"in i){for(let s=0;s<i.items.length;++s){let a=jB(Object.freeze(e.concat([[n,s]])),i.items[s],r);if(typeof a==="number")s=a-1;else if(a===vI)return vI;else if(a===BB)i.items.splice(s,1),s-=1}if(typeof o==="function"&&n==="key")o=o(t,e)}}return typeof o==="function"?o(t,e):o}nie.visit=zs});var ag=ge(function(die){var wI=DB(),iie=LB(),sie=ZB(),xI="\uFEFF",_I="\x02",EI="\x18",kI="\x1F",aie=(e)=>!!e&&("items"in e),cie=(e)=>!!e&&(e.type==="scalar"||e.type==="single-quoted-scalar"||e.type==="double-quoted-scalar"||e.type==="block-scalar");function lie(e){switch(e){case xI:return"<BOM>";case _I:return"<DOC>";case EI:return"<FLOW_END>";case kI:return"<SCALAR>";default:return JSON.stringify(e)}}function uie(e){switch(e){case xI:return"byte-order-mark";case _I:return"doc-mode";case EI:return"flow-error-end";case kI:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
|
|
380
380
|
`:case`\r
|
|
381
|
-
`:return"newline";case"-":return"seq-item-ind";case"?":return"explicit-key-ind";case":":return"map-value-ind";case"{":return"flow-map-start";case"}":return"flow-map-end";case"[":return"flow-seq-start";case"]":return"flow-seq-end";case",":return"comma"}switch(e[0]){case" ":case"\t":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"'":return"single-quoted-scalar";case'"':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}
|
|
382
|
-
`:case"\r":case"\t":return!0;default:return!1}}var UB=new Set("0123456789ABCDEFabcdef"),
|
|
383
|
-
\r `),II=(e)=>!e||
|
|
381
|
+
`:return"newline";case"-":return"seq-item-ind";case"?":return"explicit-key-ind";case":":return"map-value-ind";case"{":return"flow-map-start";case"}":return"flow-map-end";case"[":return"flow-seq-start";case"]":return"flow-seq-end";case",":return"comma"}switch(e[0]){case" ":case"\t":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"'":return"single-quoted-scalar";case'"':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}die.createScalarToken=wI.createScalarToken;die.resolveAsScalar=wI.resolveAsScalar;die.setScalarValue=wI.setScalarValue;die.stringify=iie.stringify;die.visit=sie.visit;die.BOM=xI;die.DOCUMENT=_I;die.FLOW_END=EI;die.SCALAR=kI;die.isCollection=aie;die.isScalar=cie;die.prettyToken=lie;die.tokenType=uie});var AI=ge(function(Aie){var pd=ag();function fn(e){switch(e){case void 0:case" ":case`
|
|
382
|
+
`:case"\r":case"\t":return!0;default:return!1}}var UB=new Set("0123456789ABCDEFabcdef"),kie=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),cg=new Set(",[]{}"),Iie=new Set(` ,[]{}
|
|
383
|
+
\r `),II=(e)=>!e||Iie.has(e);class MB{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer="",this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(e,t=!1){if(e){if(typeof e!=="string")throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!t;let r=this.next??"stream";while(r&&(t||this.hasChars(1)))r=yield*this.parseNext(r)}atLineEnd(){let e=this.pos,t=this.buffer[e];while(t===" "||t==="\t")t=this.buffer[++e];if(!t||t==="#"||t===`
|
|
384
384
|
`)return!0;if(t==="\r")return this.buffer[e+1]===`
|
|
385
385
|
`;return!1}charAt(e){return this.buffer[this.pos+e]}continueScalar(e){let t=this.buffer[e];if(this.indentNext>0){let r=0;while(t===" ")t=this.buffer[++r+e];if(t==="\r"){let o=this.buffer[r+e+1];if(o===`
|
|
386
386
|
`||!o&&!this.atEnd)return e+r+1}return t===`
|
|
@@ -395,33 +395,33 @@ ${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.pus
|
|
|
395
395
|
`&&n>=this.pos&&n+1+t>s)e=n;else break}while(!0);return yield pd.SCALAR,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e=this.flowLevel>0,t=this.pos-1,r=this.pos-1,o;while(o=this.buffer[++r])if(o===":"){let n=this.buffer[r+1];if(fn(n)||e&&cg.has(n))break;t=r}else if(fn(o)){let n=this.buffer[r+1];if(o==="\r")if(n===`
|
|
396
396
|
`)r+=1,o=`
|
|
397
397
|
`,n=this.buffer[r+1];else t=r;if(n==="#"||e&&cg.has(n))break;if(o===`
|
|
398
|
-
`){let i=this.continueScalar(r+1);if(i===-1)break;r=Math.max(r,i-2)}}else{if(e&&cg.has(o))break;t=r}if(!o&&!this.atEnd)return this.setNext("plain-scalar");return yield pd.SCALAR,yield*this.pushToIndex(t+1,!0),e?"flow":"doc"}*pushCount(e){if(e>0)return yield this.buffer.substr(this.pos,e),this.pos+=e,e;return 0}*pushToIndex(e,t){let r=this.buffer.slice(this.pos,e);if(r)return yield r,this.pos+=r.length,r.length;else if(t)yield"";return 0}*pushIndicators(){let e=0;e:while(!0){switch(this.charAt(0)){case"!":e+=yield*this.pushTag(),e+=yield*this.pushSpaces(!0);continue e;case"&":e+=yield*this.pushUntil(II),e+=yield*this.pushSpaces(!0);continue e;case"-":case"?":case":":{let t=this.flowLevel>0,r=this.charAt(1);if(fn(r)||t&&cg.has(r)){if(!t)this.indentNext=this.indentValue+1;else if(this.flowKey)this.flowKey=!1;e+=yield*this.pushCount(1),e+=yield*this.pushSpaces(!0);continue e}}}break e}return e}*pushTag(){if(this.charAt(1)==="<"){let e=this.pos+2,t=this.buffer[e];while(!fn(t)&&t!==">")t=this.buffer[++e];return yield*this.pushToIndex(t===">"?e+1:e,!1)}else{let e=this.pos+1,t=this.buffer[e];while(t)if(
|
|
398
|
+
`){let i=this.continueScalar(r+1);if(i===-1)break;r=Math.max(r,i-2)}}else{if(e&&cg.has(o))break;t=r}if(!o&&!this.atEnd)return this.setNext("plain-scalar");return yield pd.SCALAR,yield*this.pushToIndex(t+1,!0),e?"flow":"doc"}*pushCount(e){if(e>0)return yield this.buffer.substr(this.pos,e),this.pos+=e,e;return 0}*pushToIndex(e,t){let r=this.buffer.slice(this.pos,e);if(r)return yield r,this.pos+=r.length,r.length;else if(t)yield"";return 0}*pushIndicators(){let e=0;e:while(!0){switch(this.charAt(0)){case"!":e+=yield*this.pushTag(),e+=yield*this.pushSpaces(!0);continue e;case"&":e+=yield*this.pushUntil(II),e+=yield*this.pushSpaces(!0);continue e;case"-":case"?":case":":{let t=this.flowLevel>0,r=this.charAt(1);if(fn(r)||t&&cg.has(r)){if(!t)this.indentNext=this.indentValue+1;else if(this.flowKey)this.flowKey=!1;e+=yield*this.pushCount(1),e+=yield*this.pushSpaces(!0);continue e}}}break e}return e}*pushTag(){if(this.charAt(1)==="<"){let e=this.pos+2,t=this.buffer[e];while(!fn(t)&&t!==">")t=this.buffer[++e];return yield*this.pushToIndex(t===">"?e+1:e,!1)}else{let e=this.pos+1,t=this.buffer[e];while(t)if(kie.has(t))t=this.buffer[++e];else if(t==="%"&&UB.has(this.buffer[e+1])&&UB.has(this.buffer[e+2]))t=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];if(e===`
|
|
399
399
|
`)return yield*this.pushCount(1);else if(e==="\r"&&this.charAt(1)===`
|
|
400
|
-
`)return yield*this.pushCount(2);else return 0}*pushSpaces(e){let t=this.pos-1,r;do r=this.buffer[++t];while(r===" "||e&&r==="\t");let o=t-this.pos;if(o>0)yield this.buffer.substr(this.pos,o),this.pos=t;return o}*pushUntil(e){let t=this.pos,r=this.buffer[t];while(!e(r))r=this.buffer[++t];return yield*this.pushToIndex(t,!1)}}
|
|
400
|
+
`)return yield*this.pushCount(2);else return 0}*pushSpaces(e){let t=this.pos-1,r;do r=this.buffer[++t];while(r===" "||e&&r==="\t");let o=t-this.pos;if(o>0)yield this.buffer.substr(this.pos,o),this.pos=t;return o}*pushUntil(e){let t=this.pos,r=this.buffer[t];while(!e(r))r=this.buffer[++t];return yield*this.pushToIndex(t,!1)}}Aie.Lexer=MB});var TI=ge(function(Rie){class qB{constructor(){this.lineStarts=[],this.addNewLine=(e)=>this.lineStarts.push(e),this.linePos=(e)=>{let t=0,r=this.lineStarts.length;while(t<r){let n=t+r>>1;if(this.lineStarts[n]<e)t=n+1;else r=n}if(this.lineStarts[t]===e)return{line:t+1,col:1};if(t===0)return{line:0,col:e};let o=this.lineStarts[t-1];return{line:t,col:e-o+1}}}}Rie.LineCounter=qB});var RI=ge(function(Pie){var Oie=qr("process"),FB=ag(),Cie=AI();function vi(e,t){for(let r=0;r<e.length;++r)if(e[r].type===t)return!0;return!1}function KB(e){for(let t=0;t<e.length;++t)switch(e[t].type){case"space":case"comment":case"newline":break;default:return t}return-1}function JB(e){switch(e?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function lg(e){switch(e.type){case"document":return e.start;case"block-map":{let t=e.items[e.items.length-1];return t.sep??t.start}case"block-seq":return e.items[e.items.length-1].start;default:return[]}}function Ic(e){if(e.length===0)return[];let t=e.length;e:while(--t>=0)switch(e[t].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}while(e[++t]?.type==="space");return e.splice(t,e.length)}function ug(e,t){if(t.length<1e5)Array.prototype.push.apply(e,t);else for(let r=0;r<t.length;++r)e.push(t[r])}function HB(e){if(e.start.type==="flow-seq-start"){for(let t of e.items)if(t.sep&&!t.value&&!vi(t.start,"explicit-key-ind")&&!vi(t.sep,"map-value-ind")){if(t.key)t.value=t.key;if(delete t.key,JB(t.value))if(t.value.end)ug(t.value.end,t.sep);else t.value.end=t.sep;else ug(t.start,t.sep);delete t.sep}}}class VB{constructor(e){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source="",this.type="",this.lexer=new Cie.Lexer,this.onNewLine=e}*parse(e,t=!1){if(this.onNewLine&&this.offset===0)this.onNewLine(0);for(let r of this.lexer.lex(e,t))yield*this.next(r);if(!t)yield*this.end()}*next(e){if(this.source=e,Oie.env.LOG_TOKENS)console.log("|",FB.prettyToken(e));if(this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let t=FB.tokenType(e);if(!t){let r=`Not a YAML token: ${e}`;yield*this.pop({type:"error",offset:this.offset,message:r,source:e}),this.offset+=e.length}else if(t==="scalar")this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=t,yield*this.step(),t){case"newline":if(this.atNewLine=!0,this.indent=0,this.onNewLine)this.onNewLine(this.offset+e.length);break;case"space":if(this.atNewLine&&e[0]===" ")this.indent+=e.length;break;case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":if(this.atNewLine)this.indent+=e.length;break;case"doc-mode":case"flow-error-end":return;default:this.atNewLine=!1}this.offset+=e.length}}*end(){while(this.stack.length>0)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let e=this.peek(1);if(this.type==="doc-end"&&e?.type!=="doc-end"){while(this.stack.length>0)yield*this.pop();this.stack.push({type:"doc-end",offset:this.offset,source:this.source});return}if(!e)return yield*this.stream();switch(e.type){case"document":return yield*this.document(e);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return yield*this.scalar(e);case"block-scalar":return yield*this.blockScalar(e);case"block-map":return yield*this.blockMap(e);case"block-seq":return yield*this.blockSequence(e);case"flow-collection":return yield*this.flowCollection(e);case"doc-end":return yield*this.documentEnd(e)}yield*this.pop()}peek(e){return this.stack[this.stack.length-e]}*pop(e){let t=e??this.stack.pop();if(!t)yield{type:"error",offset:this.offset,source:"",message:"Tried to pop an empty stack"};else if(this.stack.length===0)yield t;else{let r=this.peek(1);if(t.type==="block-scalar")t.indent="indent"in r?r.indent:0;else if(t.type==="flow-collection"&&r.type==="document")t.indent=0;if(t.type==="flow-collection")HB(t);switch(r.type){case"document":r.value=t;break;case"block-scalar":r.props.push(t);break;case"block-map":{let o=r.items[r.items.length-1];if(o.value){r.items.push({start:[],key:t,sep:[]}),this.onKeyLine=!0;return}else if(o.sep)o.value=t;else{Object.assign(o,{key:t,sep:[]}),this.onKeyLine=!o.explicitKey;return}break}case"block-seq":{let o=r.items[r.items.length-1];if(o.value)r.items.push({start:[],value:t});else o.value=t;break}case"flow-collection":{let o=r.items[r.items.length-1];if(!o||o.value)r.items.push({start:[],key:t,sep:[]});else if(o.sep)o.value=t;else Object.assign(o,{key:t,sep:[]});return}default:yield*this.pop(),yield*this.pop(t)}if((r.type==="document"||r.type==="block-map"||r.type==="block-seq")&&(t.type==="block-map"||t.type==="block-seq")){let o=t.items[t.items.length-1];if(o&&!o.sep&&!o.value&&o.start.length>0&&KB(o.start)===-1&&(t.indent===0||o.start.every((n)=>n.type!=="comment"||n.indent<t.indent))){if(r.type==="document")r.end=o.start;else r.items.push({start:o.start});t.items.splice(-1,1)}}}}*stream(){switch(this.type){case"directive-line":yield{type:"directive",offset:this.offset,source:this.source};return;case"byte-order-mark":case"space":case"comment":case"newline":yield this.sourceToken;return;case"doc-mode":case"doc-start":{let e={type:"document",offset:this.offset,start:[]};if(this.type==="doc-start")e.start.push(this.sourceToken);this.stack.push(e);return}}yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(e){if(e.value)return yield*this.lineEnd(e);switch(this.type){case"doc-start":{if(KB(e.start)!==-1)yield*this.pop(),yield*this.step();else e.start.push(this.sourceToken);return}case"anchor":case"tag":case"space":case"comment":case"newline":e.start.push(this.sourceToken);return}let t=this.startBlockValue(e);if(t)this.stack.push(t);else yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(e){if(this.type==="map-value-ind"){let t=lg(this.peek(2)),r=Ic(t),o;if(e.end)o=e.end,o.push(this.sourceToken),delete e.end;else o=[this.sourceToken];let n={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:r,key:e,sep:o}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=n}else yield*this.lineEnd(e)}*blockScalar(e){switch(this.type){case"space":case"comment":case"newline":e.props.push(this.sourceToken);return;case"scalar":if(e.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let t=this.source.indexOf(`
|
|
401
401
|
`)+1;while(t!==0)this.onNewLine(this.offset+t),t=this.source.indexOf(`
|
|
402
402
|
`,t)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let t=e.items[e.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,t.value){let r="end"in t.value?t.value.end:void 0;if((Array.isArray(r)?r[r.length-1]:void 0)?.type==="comment")r?.push(this.sourceToken);else e.items.push({start:[this.sourceToken]})}else if(t.sep)t.sep.push(this.sourceToken);else t.start.push(this.sourceToken);return;case"space":case"comment":if(t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else{if(this.atIndentedComment(t.start,e.indent)){let o=e.items[e.items.length-2]?.value?.end;if(Array.isArray(o)){ug(o,t.start),o.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let r=!this.onKeyLine&&this.indent===e.indent,o=r&&(t.sep||t.explicitKey)&&this.type!=="seq-item-ind",n=[];if(o&&t.sep&&!t.value){let i=[];for(let s=0;s<t.sep.length;++s){let a=t.sep[s];switch(a.type){case"newline":i.push(s);break;case"space":break;case"comment":if(a.indent>e.indent)i.length=0;break;default:i.length=0}}if(i.length>=2)n=t.sep.splice(i[1])}switch(this.type){case"anchor":case"tag":if(o||t.value)n.push(this.sourceToken),e.items.push({start:n}),this.onKeyLine=!0;else if(t.sep)t.sep.push(this.sourceToken);else t.start.push(this.sourceToken);return;case"explicit-key-ind":if(!t.sep&&!t.explicitKey)t.start.push(this.sourceToken),t.explicitKey=!0;else if(o||t.value)n.push(this.sourceToken),e.items.push({start:n,explicitKey:!0});else this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]});this.onKeyLine=!0;return;case"map-value-ind":if(t.explicitKey)if(!t.sep)if(vi(t.start,"newline"))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let i=Ic(t.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]})}else if(t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(vi(t.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:n,key:null,sep:[this.sourceToken]}]});else if(JB(t.key)&&!vi(t.sep,"newline")){let i=Ic(t.start),s=t.key,a=t.sep;a.push(this.sourceToken),delete t.key,delete t.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:s,sep:a}]})}else if(n.length>0)t.sep=t.sep.concat(n,this.sourceToken);else t.sep.push(this.sourceToken);else if(!t.sep)Object.assign(t,{key:null,sep:[this.sourceToken]});else if(t.value||o)e.items.push({start:n,key:null,sep:[this.sourceToken]});else if(vi(t.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]});else t.sep.push(this.sourceToken);this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let i=this.flowScalar(this.type);if(o||t.value)e.items.push({start:n,key:i,sep:[]}),this.onKeyLine=!0;else if(t.sep)this.stack.push(i);else Object.assign(t,{key:i,sep:[]}),this.onKeyLine=!0;return}default:{let i=this.startBlockValue(e);if(i){if(i.type==="block-seq"){if(!t.explicitKey&&t.sep&&!vi(t.sep,"newline")){yield*this.pop({type:"error",offset:this.offset,message:"Unexpected block-seq-ind on same line with key",source:this.source});return}}else if(r)e.items.push({start:n});this.stack.push(i);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let t=e.items[e.items.length-1];switch(this.type){case"newline":if(t.value){let r="end"in t.value?t.value.end:void 0;if((Array.isArray(r)?r[r.length-1]:void 0)?.type==="comment")r?.push(this.sourceToken);else e.items.push({start:[this.sourceToken]})}else t.start.push(this.sourceToken);return;case"space":case"comment":if(t.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(t.start,e.indent)){let o=e.items[e.items.length-2]?.value?.end;if(Array.isArray(o)){ug(o,t.start),o.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return;case"anchor":case"tag":if(t.value||this.indent<=e.indent)break;t.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==e.indent)break;if(t.value||vi(t.start,"seq-item-ind"))e.items.push({start:[this.sourceToken]});else t.start.push(this.sourceToken);return}if(this.indent>e.indent){let r=this.startBlockValue(e);if(r){this.stack.push(r);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let t=e.items[e.items.length-1];if(this.type==="flow-error-end"){let r;do yield*this.pop(),r=this.peek(1);while(r?.type==="flow-collection")}else if(e.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":if(!t||t.sep)e.items.push({start:[this.sourceToken]});else t.start.push(this.sourceToken);return;case"map-value-ind":if(!t||t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else Object.assign(t,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":if(!t||t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else t.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let o=this.flowScalar(this.type);if(!t||t.value)e.items.push({start:[],key:o,sep:[]});else if(t.sep)this.stack.push(o);else Object.assign(t,{key:o,sep:[]});return}case"flow-map-end":case"flow-seq-end":e.end.push(this.sourceToken);return}let r=this.startBlockValue(e);if(r)this.stack.push(r);else yield*this.pop(),yield*this.step()}else{let r=this.peek(2);if(r.type==="block-map"&&(this.type==="map-value-ind"&&r.indent===e.indent||this.type==="newline"&&!r.items[r.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&r.type!=="flow-collection"){let o=lg(r),n=Ic(o);HB(e);let i=e.end.splice(1,e.end.length);i.push(this.sourceToken);let s={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:n,key:e,sep:i}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=s}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let t=this.source.indexOf(`
|
|
403
403
|
`)+1;while(t!==0)this.onNewLine(this.offset+t),t=this.source.indexOf(`
|
|
404
|
-
`,t)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let t=lg(e),r=Ic(t);return r.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let t=lg(e),r=Ic(t);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){if(this.type!=="comment")return!1;if(this.indent<=t)return!1;return e.every((r)=>r.type==="newline"||r.type==="space")}*documentEnd(e){if(this.type!=="doc-mode"){if(e.end)e.end.push(this.sourceToken);else e.end=[this.sourceToken];if(this.type==="newline")yield*this.pop()}}*lineEnd(e){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;case"space":case"comment":default:if(e.end)e.end.push(this.sourceToken);else e.end=[this.sourceToken];if(this.type==="newline")yield*this.pop()}}}Cie.Parser=VB});var XB=ge(function(Uie){var WB=bI(),zie=ad(),fd=cd(),Nie=Tk(),Die=qe(),Lie=TI(),GB=RI();function QB(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new Lie.LineCounter||null,prettyErrors:t}}function Bie(e,t={}){let{lineCounter:r,prettyErrors:o}=QB(t),n=new GB.Parser(r?.addNewLine),i=new WB.Composer(t),s=Array.from(i.compose(n.parse(e)));if(o&&r)for(let a of s)a.errors.forEach(fd.prettifyError(e,r)),a.warnings.forEach(fd.prettifyError(e,r));if(s.length>0)return s;return Object.assign([],{empty:!0},i.streamInfo())}function YB(e,t={}){let{lineCounter:r,prettyErrors:o}=QB(t),n=new GB.Parser(r?.addNewLine),i=new WB.Composer(t),s=null;for(let a of i.compose(n.parse(e),!0,e.length))if(!s)s=a;else if(s.options.logLevel!=="silent"){s.errors.push(new fd.YAMLParseError(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}if(o&&r)s.errors.forEach(fd.prettifyError(e,r)),s.warnings.forEach(fd.prettifyError(e,r));return s}function jie(e,t,r){let o=void 0;if(typeof t==="function")o=t;else if(r===void 0&&t&&typeof t==="object")r=t;let n=YB(e,r);if(!n)return null;if(n.warnings.forEach((i)=>Nie.warn(n.options.logLevel,i)),n.errors.length>0)if(n.options.logLevel!=="silent")throw n.errors[0];else n.errors=[];return n.toJS(Object.assign({reviver:o},r))}function Zie(e,t,r){let o=null;if(typeof t==="function"||Array.isArray(t))o=t;else if(r===void 0&&t)r=t;if(typeof r==="string")r=r.length;if(typeof r==="number"){let n=Math.round(r);r=n<1?void 0:n>8?{indent:8}:{indent:n}}if(e===void 0){let{keepUndefined:n}=r??t??{};if(!n)return}if(Die.isDocument(e)&&!o)return e.toString(r);return new zie.Document(e,o,r).toString(r)}Uie.parse=jie;Uie.parseAllDocuments=Bie;Uie.parseDocument=YB;Uie.stringify=Zie});var Hie,Jie,Vie,$I,Wie,wi,Gie,Qie,Yie,Xie,e$e,ese,tse,rse,dg,ej,nse,ose,ise,sse,ase,cse,lse,use,dse,pse,mn,yo,fse,bo,OI,mse,hse,gse,yse,bse,Sse,vse,wse,xse,Wr,_se,Ese,kse;var Ac=v(()=>{Hie=bI(),Jie=ad(),Vie=rI(),$I=cd(),Wie=Ju(),wi=qe(),Gie=gi(),Qie=Et(),Yie=bi(),Xie=Si(),e$e=ag(),ese=AI(),tse=TI(),rse=RI(),dg=XB(),ej=Ku();nse=Hie.Composer,ose=Jie.Document,ise=Vie.Schema,sse=$I.YAMLError,ase=$I.YAMLParseError,cse=$I.YAMLWarning,lse=Wie.Alias,use=wi.isAlias,dse=wi.isCollection,pse=wi.isDocument,mn=wi.isMap,yo=wi.isNode,fse=wi.isPair,bo=wi.isScalar,OI=wi.isSeq,mse=Gie.Pair,hse=Qie.Scalar,gse=Yie.YAMLMap,yse=Xie.YAMLSeq,bse=ese.Lexer,Sse=tse.LineCounter,vse=rse.Parser,wse=dg.parse,xse=dg.parseAllDocuments,Wr=dg.parseDocument,_se=dg.stringify,Ese=ej.visit,kse=ej.visitAsync});var ij={};Lt(ij,{assertPilotUsersRemoved:()=>PI,createPilotOffboardDriver:()=>CI,offboardPilotUsers:()=>rj});import{access as Ise,readdir as Ase,readFile as Tse,rm as md,writeFile as Rse}from"fs/promises";import{basename as $se,join as So}from"path";async function rj(e,t){let r=[...new Set(t.handles.map((p)=>mr.parse(p)))].sort((p,m)=>p.localeCompare(m));if(r.length===0)throw Error("At least one pilot handle is required");let o=t.dryRun??!0,n=`sunset:${r.join(",")}`;if(!o&&t.confirmation!==n)throw Error(`Exact confirmation required: ${n}`);let i=t.env??process.env,s=t.logger??console.info,a=await ut(e),c=r.map((p)=>Ose(a,p,i)),u=t.driver??CI({env:i,fetchImpl:t.fetchImpl,contentRepoTokenName:a.pilot.contentRepoAdminToken}),d=await Promise.all(c.map(async(p)=>({target:p,inspection:await u.inspect(p)})));if(Pse(d),zse(d,o,s),!o){for(let p of d)if(!p.inspection.contentRepoArchived)await u.archiveContentRepo(p.target),s(`[${p.target.handle}] archived ${p.target.contentRepo}`);for(let p of d)for(let m of p.inspection.dnsRecords)await u.deleteDnsRecord(p.target,m),s(`[${p.target.handle}] deleted DNS ${m.name}`);for(let p of d)if(p.inspection.server)await u.deleteServer(p.target,p.inspection.server),s(`[${p.target.handle}] deleted ${p.target.instanceName}`);await Cse(c,u,t.sleep??((p)=>new Promise((m)=>setTimeout(m,p)))),await Nse(e,r),await po(e),await PI(e,r),s(`Removed desired state for ${r.length} pilot user(s)`)}return{dryRun:o,handles:r,confirmation:n,plans:d}}function Ose(e,t,r){let o=e.users.find((d)=>d.handle===t),n=`${t}${e.pilot.domainSuffix}`,i=o?.domain??n,s=pk(i,{sharedDomain:e.pilot.domainSuffix}),a=o?.cloudflareZoneId??pg(r,"CF_ZONE_ID"),c=o?.contentRepo??`${e.pilot.contentRepoPrefix}${t}-content`,u=c.includes("/")?c:`${e.pilot.githubOrg}/${c}`;return{handle:t,instanceName:`rover-${t}`,domain:i,previewDomain:s,...i===n?{}:{wwwDomain:`www.${i}`},contentRepo:u,cloudflareZoneId:a}}async function Cse(e,t,r){for(let o of e)for(let n=1;n<=20;n+=1){let i=await t.inspect(o);if(!i.server&&i.dnsRecords.length===0&&i.contentRepoArchived)break;if(n===20)throw Error(`[${o.handle}] provider cleanup did not converge`);await r(1500)}}function Pse(e){for(let{target:t,inspection:r}of e){if(r.server&&r.server.name!==t.instanceName)throw Error(`[${t.handle}] unexpected server name: ${r.server.name}`);let o=new Set([t.domain,t.previewDomain,...t.wwwDomain?[t.wwwDomain]:[]]);for(let n of r.dnsRecords){if(!o.has(n.name))throw Error(`[${t.handle}] refusing unexpected DNS record ${n.name}`);if(n.type==="A"&&r.server?.ip&&n.content!==r.server.ip)throw Error(`[${t.handle}] ${n.name} does not point to the retiring server`)}}}function zse(e,t,r){r(`${t?"Dry run":"Apply"}: ${e.map(({target:o})=>o.handle).join(", ")}`);for(let{target:o,inspection:n}of e){let i=n.server?`delete ${o.instanceName}`:"already absent",s=n.dnsRecords.length>0?n.dnsRecords.map((c)=>`${c.type} ${c.name}`).join(", "):"already absent",a=n.contentRepoArchived?"already archived":`archive ${o.contentRepo}`;r(`[${o.handle}] server: ${i}; DNS: ${s}; repo: ${a}`)}r("Runtime backups: none")}async function Nse(e,t){let r=new Set(t),o=So(e,"cohorts");for(let n of(await Ase(o)).filter((i)=>i.endsWith(".yaml"))){let i=So(o,n),s=await Tse(i,"utf8"),a=Wr(s);if(a.errors.length>0)throw Error(`${n}: ${a.errors[0]?.message??"invalid YAML"}`);let c=a.get("members",!0);if(!OI(c))throw Error(`${n}: members must be a sequence`);let u=c.items.filter((d)=>!bo(d)||typeof d.value!=="string"||!r.has(d.value));if(u.length===c.items.length)continue;if(u.length===0){await md(i);continue}c.items=u,Kr.parse(a.toJS()),await Rse(i,a.toString())}for(let n of t)await Promise.all([md(So(e,"users",`${n}.yaml`),{force:!0}),md(So(e,"users",`${n}.secrets.yaml`),{force:!0}),md(So(e,"users",`${n}.secrets.yaml.age`),{force:!0}),md(So(e,"users",n),{recursive:!0,force:!0})])}function CI(e){let t=e.fetchImpl??fetch,r=pg(e.env,"HCLOUD_TOKEN"),o=pg(e.env,"CF_API_TOKEN"),n=pg(e.env,e.contentRepoTokenName);return{async inspect(i){let[s,a,c]=await Promise.all([Dse(t,r,i.instanceName),Promise.all([i.domain,i.previewDomain,...i.wwwDomain?[i.wwwDomain]:[]].map((u)=>Lse(t,o,i.cloudflareZoneId,u))).then((u)=>u.flat()),Bse(t,n,i.contentRepo)]);if(s.length>1)throw Error(`[${i.handle}] expected at most one server, found ${s.length}`);return{...s[0]?{server:s[0]}:{},dnsRecords:a,contentRepoArchived:c.archived}},async archiveContentRepo(i){await Tc(t,`https://api.github.com/repos/${i.contentRepo}`,{method:"PATCH",headers:nj(n),body:JSON.stringify({archived:!0})},"GitHub repository archive")},async deleteDnsRecord(i,s){if(Rc(await Tc(t,`https://api.cloudflare.com/client/v4/zones/${i.cloudflareZoneId}/dns_records/${s.id}`,{method:"DELETE",headers:oj(o)},"Cloudflare DNS delete")).success!==!0)throw Error(`Cloudflare DNS delete failed for ${s.name}`)},async deleteServer(i,s){await Tc(t,`https://api.hetzner.cloud/v1/servers/${s.id}`,{method:"DELETE",headers:{Authorization:`Bearer ${r}`}},"Hetzner server delete",!0)}}}async function Dse(e,t,r){let o=new URL("https://api.hetzner.cloud/v1/servers");o.searchParams.set("label_selector",`brain=${r}`);let i=Rc(await Tc(e,o.toString(),{headers:{Authorization:`Bearer ${t}`}},"Hetzner server lookup")).servers;if(!Array.isArray(i))throw Error("Hetzner server lookup returned an invalid payload");return i.map((s)=>{let a=Rc(s),c=tj(a.public_net),u=tj(c?.ipv4);return{id:jse(a.id,"Hetzner server id"),name:hd(a.name,"Hetzner server name"),...typeof u?.ip==="string"?{ip:u.ip}:{}}})}async function Lse(e,t,r,o){let n=new URL(`https://api.cloudflare.com/client/v4/zones/${r}/dns_records`);n.searchParams.set("name",o);let i=Rc(await Tc(e,n.toString(),{headers:oj(t)},"Cloudflare DNS lookup")),s=i.result;if(i.success!==!0||!Array.isArray(s))throw Error(`Cloudflare DNS lookup failed for ${o}`);return s.map((a)=>{let c=Rc(a),u=hd(c.type,"Cloudflare record type");if(u!=="A"&&u!=="CNAME")throw Error(`Unsupported Cloudflare record type ${u} for ${o}`);return{id:hd(c.id,"Cloudflare record id"),name:hd(c.name,"Cloudflare record name"),type:u,content:hd(c.content,"Cloudflare record content")}})}async function Bse(e,t,r){let o=Rc(await Tc(e,`https://api.github.com/repos/${r}`,{headers:nj(t)},"GitHub repository lookup"));if(typeof o.archived!=="boolean")throw Error(`Invalid repository archive state for ${r}`);return{archived:o.archived}}async function Tc(e,t,r,o,n=!1){let i=await e(t,r),s=await i.text();if(!i.ok)throw Error(`${o} failed (${i.status}): ${s}`);if(!s&&n)return{};try{return JSON.parse(s)}catch{throw Error(`${o} returned an invalid JSON response`)}}function nj(e){return{Accept:"application/vnd.github+json",Authorization:`Bearer ${e}`,"Content-Type":"application/json","X-GitHub-Api-Version":"2022-11-28"}}function oj(e){return{Authorization:`Bearer ${e}`}}function pg(e,t){let r=e[t];if(!r)throw Error(`Missing required environment variable: ${t}`);return r}function Rc(e){if(!ks(e))throw Error("Provider returned an unexpected payload");return e}function tj(e){return ks(e)?e:void 0}function hd(e,t){if(typeof e!=="string"||e.length===0)throw Error(`Missing ${t}`);return e}function jse(e,t){if(typeof e!=="number")throw Error(`Missing ${t}`);return e}async function Zse(e){try{return await Ise(e),!0}catch{return!1}}async function PI(e,t){for(let r of t)for(let o of[So(e,"users",`${r}.yaml`),So(e,"users",`${r}.secrets.yaml.age`),So(e,"users",r)])if(await Zse(o))throw Error(`Offboarded user state remains: ${$se(o)}`)}var zI=v(()=>{Ac();Hr();fk();uc();Bn()});function DI(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function vt(e,t=""){if(typeof e!=="number"){let r=t&&`"${t}" `;throw TypeError(`${r}expected number, got ${typeof e}`)}if(!Number.isSafeInteger(e)||e<0){let r=t&&`"${t}" `;throw RangeError(`${r}expected integer >= 0, got ${e}`)}}function Ft(e,t,r=""){let o=DI(e),n=e?.length,i=t!==void 0;if(!o||i&&n!==t){let s=r&&`"${r}" `,a=i?` of length ${t}`:"",c=o?`length=${n}`:`type=${typeof e}`,u=s+"expected Uint8Array"+a+", got "+c;if(!o)throw TypeError(u);throw RangeError(u)}return e}function wo(e){if(typeof e!=="function"||typeof e.create!=="function")throw TypeError("Hash must wrapped by utils.createHasher");if(vt(e.outputLen),vt(e.blockLen),e.outputLen<1)throw Error('"outputLen" must be >= 1');if(e.blockLen<1)throw Error('"blockLen" must be >= 1')}function $c(e,t=!0){if(e.destroyed)throw Error("Hash instance has been destroyed");if(t&&e.finished)throw Error("Hash#digest() has already been called")}function fg(e,t){Ft(e,void 0,"digestInto() output");let r=t.outputLen;if(e.length<r)throw RangeError('"digestInto() output" expected to be of length >='+r)}function mg(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function hr(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Oc(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function hn(e,t){return e<<32-t|e>>>t}function Fe(e,t){return e<<t|e>>>32-t>>>0}function Gse(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function Qse(e){for(let t=0;t<e.length;t++)e[t]=Gse(e[t]);return e}function hg(e){if(Ft(e),mj)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=Yse[e[r]];return t}function fj(e){if(e>=vo._0&&e<=vo._9)return e-vo._0;if(e>=vo.A&&e<=vo.F)return e-(vo.A-10);if(e>=vo.a&&e<=vo.f)return e-(vo.a-10);return}function yd(e){if(typeof e!=="string")throw TypeError("hex string expected, got "+typeof e);if(mj)try{return Uint8Array.fromHex(e)}catch(n){if(n instanceof SyntaxError)throw RangeError(n.message);throw n}let t=e.length,r=t/2;if(t%2)throw RangeError("hex string expected, got unpadded hex of length "+t);let o=new Uint8Array(r);for(let n=0,i=0;n<r;n++,i+=2){let s=fj(e.charCodeAt(i)),a=fj(e.charCodeAt(i+1));if(s===void 0||a===void 0){let c=e[i]+e[i+1];throw RangeError('hex string expected, got non-hex character "'+c+'" at index '+i)}o[n]=s*16+a}return o}function Xse(e){if(typeof e!=="string")throw TypeError("string expected");return new Uint8Array(new TextEncoder().encode(e))}function BI(e,t=""){if(typeof e==="string")return Xse(e);return Ft(e,void 0,t)}function jI(...e){let t=0;for(let o=0;o<e.length;o++){let n=e[o];Ft(n),t+=n.length}let r=new Uint8Array(t);for(let o=0,n=0;o<e.length;o++){let i=e[o];r.set(i,n),n+=i.length}return r}function gg(e,t){if(t!==void 0&&{}.toString.call(t)!=="[object Object]")throw TypeError("options must be object or undefined");return Object.assign(e,t)}function ZI(e,t={}){let r=(n,i)=>e(i).update(n).digest(),o=e(void 0);return r.outputLen=o.outputLen,r.blockLen=o.blockLen,r.canXOF=o.canXOF,r.create=(n)=>e(n),Object.assign(r,t),Object.freeze(r)}function xo(e=32){vt(e,"bytesLength");let t=typeof globalThis==="object"?globalThis.crypto:null;if(typeof t?.getRandomValues!=="function")throw Error("crypto.getRandomValues must be defined");if(e>65536)throw RangeError(`"bytesLength" expected <= 65536, got ${e}`);return t.getRandomValues(new Uint8Array(e))}var Wse,LI,mj,Yse,vo,UI=(e)=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});var Gr=v(()=>{Wse=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)();LI=Wse?(e)=>e:Qse,mj=(()=>typeof Uint8Array.from([]).toHex==="function"&&typeof Uint8Array.fromHex==="function")(),Yse=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));vo={_0:48,_9:57,A:65,F:70,a:97,f:102}});class MI{oHash;iHash;blockLen;outputLen;canXOF=!1;finished=!1;destroyed=!1;constructor(e,t){if(wo(e),Ft(t,void 0,"key"),this.iHash=e.create(),typeof this.iHash.update!=="function")throw Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let r=this.blockLen,o=new Uint8Array(r);o.set(t.length>r?e.create().update(t).digest():t);for(let n=0;n<o.length;n++)o[n]^=54;this.iHash.update(o),this.oHash=e.create();for(let n=0;n<o.length;n++)o[n]^=106;this.oHash.update(o),hr(o)}update(e){return $c(this),this.iHash.update(e),this}digestInto(e){$c(this),fg(e,this),this.finished=!0;let t=e.subarray(0,this.outputLen);this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||=Object.create(Object.getPrototypeOf(this),{});let{oHash:t,iHash:r,finished:o,destroyed:n,blockLen:i,outputLen:s}=this;return e=e,e.finished=o,e.destroyed=n,e.blockLen=i,e.outputLen=s,e.oHash=t._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}var Mn;var bd=v(()=>{Gr();Mn=(()=>{let e=(t,r,o)=>new MI(t,r).update(o).digest();return e.create=(t,r)=>new MI(t,r),e})()});function Sd(e,t,r){if(wo(e),r===void 0)r=new Uint8Array(e.outputLen);return Mn(e,r,t)}function FI(e,t,r,o=32){wo(e),vt(o,"length"),Ft(t,void 0,"prk");let n=e.outputLen;if(t.length<n)throw Error('"prk" must be at least HashLen octets');if(o>255*n)throw Error("Length must be <= 255*HashLen");let i=Math.ceil(o/n);if(r===void 0)r=hj;else Ft(r,void 0,"info");let s=new Uint8Array(i*n),a=Mn.create(e,t),c=a._cloneInto(),u=new Uint8Array(a.outputLen);for(let d=0;d<i;d++)qI[0]=d+1,c.update(d===0?hj:u).update(r).update(qI).digestInto(u),s.set(u,n*d),a._cloneInto(c);return a.destroy(),c.destroy(),hr(u,qI),s.slice(0,o)}var qI,hj,xi=(e,t,r,o,n)=>FI(e,Sd(e,t,r),o,n);var KI=v(()=>{bd();Gr();qI=Uint8Array.of(0),hj=Uint8Array.of()});function gj(e,t,r){return e&t^~e&r}function yj(e,t,r){return e&t^e&r^t&r}class yg{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,t,r,o){this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=o,this.buffer=new Uint8Array(e),this.view=Oc(this.buffer)}update(e){$c(this),Ft(e);let{view:t,buffer:r,blockLen:o}=this,n=e.length;for(let i=0;i<n;){let s=Math.min(o-this.pos,n-i);if(s===o){let a=Oc(e);for(;o<=n-i;i+=o)this.process(a,i);continue}if(r.set(e.subarray(i,i+s),this.pos),this.pos+=s,i+=s,this.pos===o)this.process(t,0),this.pos=0}return this.length+=e.length,this.roundClean(),this}digestInto(e){$c(this),fg(e,this),this.finished=!0;let{buffer:t,view:r,blockLen:o,isLE:n}=this,{pos:i}=this;if(t[i++]=128,hr(this.buffer.subarray(i)),this.padOffset>o-i)this.process(r,0),i=0;for(let d=i;d<o;d++)t[d]=0;r.setBigUint64(o-8,BigInt(this.length*8),n),this.process(r,0);let s=Oc(e),a=this.outputLen;if(a%4)throw Error("_sha2: outputLen must be aligned to 32bit");let c=a/4,u=this.get();if(c>u.length)throw Error("_sha2: outputLen bigger than state");for(let d=0;d<c;d++)s.setUint32(4*d,u[d],n)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){e||=new this.constructor,e.set(...this.get());let{blockLen:t,buffer:r,length:o,finished:n,destroyed:i,pos:s}=this;if(e.destroyed=i,e.finished=n,e.length=o,e.pos=s,o%t)e.buffer.set(r);return e}clone(){return this._cloneInto()}}var _o,Kt;var bj=v(()=>{Gr();_o=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Kt=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209])});function eae(e,t=!1){if(t)return{h:Number(e&bg),l:Number(e>>Sj&bg)};return{h:Number(e>>Sj&bg)|0,l:Number(e&bg)|0}}function vj(e,t=!1){let r=e.length,o=new Uint32Array(r),n=new Uint32Array(r);for(let i=0;i<r;i++){let{h:s,l:a}=eae(e[i],t);[o[i],n[i]]=[s,a]}return[o,n]}function qn(e,t,r,o){let n=(t>>>0)+(o>>>0);return{h:e+r+(n/4294967296|0)|0,l:n|0}}var bg,Sj,HI=(e,t,r)=>e>>>r,JI=(e,t,r)=>e<<32-r|t>>>r,Ds=(e,t,r)=>e>>>r|t<<32-r,Ls=(e,t,r)=>e<<32-r|t>>>r,vd=(e,t,r)=>e<<64-r|t>>>r-32,wd=(e,t,r)=>e>>>r-32|t<<64-r,wj=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),xj=(e,t,r,o)=>t+r+o+(e/4294967296|0)|0,_j=(e,t,r,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(o>>>0),Ej=(e,t,r,o,n)=>t+r+o+n+(e/4294967296|0)|0,kj=(e,t,r,o,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(o>>>0)+(n>>>0),Ij=(e,t,r,o,n,i)=>t+r+o+n+i+(e/4294967296|0)|0;var Aj=v(()=>{bg=BigInt(4294967295),Sj=BigInt(32)});var rae,_i,Tj,Rj,$j,nae,oae,Ei,ki,Oj,Cj,wt,Sg;var Cc=v(()=>{bj();Aj();Gr();rae=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),_i=new Uint32Array(64);Tj=class Tj extends yg{constructor(e){super(64,e,8,!1)}get(){let{A:e,B:t,C:r,D:o,E:n,F:i,G:s,H:a}=this;return[e,t,r,o,n,i,s,a]}set(e,t,r,o,n,i,s,a){this.A=e|0,this.B=t|0,this.C=r|0,this.D=o|0,this.E=n|0,this.F=i|0,this.G=s|0,this.H=a|0}process(e,t){for(let d=0;d<16;d++,t+=4)_i[d]=e.getUint32(t,!1);for(let d=16;d<64;d++){let p=_i[d-15],m=_i[d-2],h=hn(p,7)^hn(p,18)^p>>>3,b=hn(m,17)^hn(m,19)^m>>>10;_i[d]=b+_i[d-7]+h+_i[d-16]|0}let{A:r,B:o,C:n,D:i,E:s,F:a,G:c,H:u}=this;for(let d=0;d<64;d++){let p=hn(s,6)^hn(s,11)^hn(s,25),m=u+p+gj(s,a,c)+rae[d]+_i[d]|0,b=(hn(r,2)^hn(r,13)^hn(r,22))+yj(r,o,n)|0;u=c,c=a,a=s,s=i+m|0,i=n,n=o,o=r,r=m+b|0}r=r+this.A|0,o=o+this.B|0,n=n+this.C|0,i=i+this.D|0,s=s+this.E|0,a=a+this.F|0,c=c+this.G|0,u=u+this.H|0,this.set(r,o,n,i,s,a,c,u)}roundClean(){hr(_i)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),hr(this.buffer)}};Rj=class Rj extends Tj{A=_o[0]|0;B=_o[1]|0;C=_o[2]|0;D=_o[3]|0;E=_o[4]|0;F=_o[5]|0;G=_o[6]|0;H=_o[7]|0;constructor(){super(32)}};$j=(()=>vj(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map((e)=>BigInt(e))))(),nae=(()=>$j[0])(),oae=(()=>$j[1])(),Ei=new Uint32Array(80),ki=new Uint32Array(80);Oj=class Oj extends yg{constructor(e){super(128,e,16,!1)}get(){let{Ah:e,Al:t,Bh:r,Bl:o,Ch:n,Cl:i,Dh:s,Dl:a,Eh:c,El:u,Fh:d,Fl:p,Gh:m,Gl:h,Hh:b,Hl:y}=this;return[e,t,r,o,n,i,s,a,c,u,d,p,m,h,b,y]}set(e,t,r,o,n,i,s,a,c,u,d,p,m,h,b,y){this.Ah=e|0,this.Al=t|0,this.Bh=r|0,this.Bl=o|0,this.Ch=n|0,this.Cl=i|0,this.Dh=s|0,this.Dl=a|0,this.Eh=c|0,this.El=u|0,this.Fh=d|0,this.Fl=p|0,this.Gh=m|0,this.Gl=h|0,this.Hh=b|0,this.Hl=y|0}process(e,t){for(let _=0;_<16;_++,t+=4)Ei[_]=e.getUint32(t),ki[_]=e.getUint32(t+=4);for(let _=16;_<80;_++){let A=Ei[_-15]|0,O=ki[_-15]|0,L=Ds(A,O,1)^Ds(A,O,8)^HI(A,O,7),z=Ls(A,O,1)^Ls(A,O,8)^JI(A,O,7),H=Ei[_-2]|0,P=ki[_-2]|0,W=Ds(H,P,19)^vd(H,P,61)^HI(H,P,6),ee=Ls(H,P,19)^wd(H,P,61)^JI(H,P,6),j=_j(z,ee,ki[_-7],ki[_-16]),R=Ej(j,L,W,Ei[_-7],Ei[_-16]);Ei[_]=R|0,ki[_]=j|0}let{Ah:r,Al:o,Bh:n,Bl:i,Ch:s,Cl:a,Dh:c,Dl:u,Eh:d,El:p,Fh:m,Fl:h,Gh:b,Gl:y,Hh:S,Hl:x}=this;for(let _=0;_<80;_++){let A=Ds(d,p,14)^Ds(d,p,18)^vd(d,p,41),O=Ls(d,p,14)^Ls(d,p,18)^wd(d,p,41),L=d&m^~d&b,z=p&h^~p&y,H=kj(x,O,z,oae[_],ki[_]),P=Ij(H,S,A,L,nae[_],Ei[_]),W=H|0,ee=Ds(r,o,28)^vd(r,o,34)^vd(r,o,39),j=Ls(r,o,28)^wd(r,o,34)^wd(r,o,39),R=r&n^r&s^n&s,B=o&i^o&a^i&a;S=b|0,x=y|0,b=m|0,y=h|0,m=d|0,h=p|0,{h:d,l:p}=qn(c|0,u|0,P|0,W|0),c=s|0,u=a|0,s=n|0,a=i|0,n=r|0,i=o|0;let k=wj(W,j,B);r=xj(k,P,ee,R),o=k|0}({h:r,l:o}=qn(this.Ah|0,this.Al|0,r|0,o|0)),{h:n,l:i}=qn(this.Bh|0,this.Bl|0,n|0,i|0),{h:s,l:a}=qn(this.Ch|0,this.Cl|0,s|0,a|0),{h:c,l:u}=qn(this.Dh|0,this.Dl|0,c|0,u|0),{h:d,l:p}=qn(this.Eh|0,this.El|0,d|0,p|0),{h:m,l:h}=qn(this.Fh|0,this.Fl|0,m|0,h|0),{h:b,l:y}=qn(this.Gh|0,this.Gl|0,b|0,y|0),{h:S,l:x}=qn(this.Hh|0,this.Hl|0,S|0,x|0),this.set(r,o,n,i,s,a,c,u,d,p,m,h,b,y,S,x)}roundClean(){hr(Ei,ki)}destroy(){this.destroyed=!0,hr(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};Cj=class Cj extends Oj{Ah=Kt[0]|0;Al=Kt[1]|0;Bh=Kt[2]|0;Bl=Kt[3]|0;Ch=Kt[4]|0;Cl=Kt[5]|0;Dh=Kt[6]|0;Dl=Kt[7]|0;Eh=Kt[8]|0;El=Kt[9]|0;Fh=Kt[10]|0;Fl=Kt[11]|0;Gh=Kt[12]|0;Gl=Kt[13]|0;Hh=Kt[14]|0;Hl=Kt[15]|0;constructor(){super(64)}};wt=ZI(()=>new Rj,UI(1)),Sg=ZI(()=>new Cj,UI(3))});function Eg(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function GI(e){if(!Eg(e))throw TypeError("Uint8Array expected")}function Lj(e,t){if(!Array.isArray(t))return!1;if(t.length===0)return!0;if(e)return t.every((r)=>typeof r==="string");else return t.every((r)=>Number.isSafeInteger(r))}function Bj(e){if(typeof e!=="function")throw TypeError("function expected");return!0}function Ii(e,t){if(typeof t!=="string")throw TypeError(`${e}: string expected`);return!0}function _d(e){if(typeof e!=="number")throw TypeError(`number expected, got ${typeof e}`);if(!Number.isSafeInteger(e))throw RangeError(`invalid integer: ${e}`)}function wg(e){if(!Array.isArray(e))throw TypeError("array expected")}function xg(e,t){if(!Lj(!0,t))throw TypeError(`${e}: array of strings expected`)}function QI(e,t){if(!Lj(!1,t))throw TypeError(`${e}: array of numbers expected`)}function Nr(...e){let t=(i)=>i,r=(i,s)=>(a)=>i(s(a)),o=e.map((i)=>i.encode).reduceRight(r,t),n=e.map((i)=>i.decode).reduce(r,t);return{encode:o,decode:n}}function Dr(e){let t=typeof e==="string"?e.split(""):e,r=t.length;xg("alphabet",t);let o=new Map(t.map((n,i)=>[n,i]));return{encode:(n)=>(wg(n),n.map((i)=>{if(!Number.isSafeInteger(i)||i<0||i>=r)throw Error(`alphabet.encode: digit index outside alphabet "${i}". Allowed: ${e}`);return t[i]})),decode:(n)=>(wg(n),n.map((i)=>{Ii("alphabet.decode",i);let s=o.get(i);if(s===void 0)throw Error(`Unknown letter: "${i}". Allowed: ${e}`);return s}))}}function Lr(e=""){return Ii("join",e),{encode:(t)=>(xg("join.decode",t),t.join(e)),decode:(t)=>(Ii("join.decode",t),t.split(e))}}function kg(e,t="="){return _d(e),Ii("padding",t),{encode(r){xg("padding.encode",r);while(r.length*e%8)r.push(t);return r},decode(r){xg("padding.decode",r);let o=r.length;if(o*e%8)throw Error("padding: invalid, string should have whole number of bytes");for(;o>0&&r[o-1]===t;o--)if((o-1)*e%8===0)throw Error("padding: invalid, string has too much padding");return r.slice(0,o)}}}function jj(e){return Bj(e),{encode:(t)=>t,decode:(t)=>e(t)}}function Pj(e,t,r){if(t<2)throw RangeError(`convertRadix: invalid from=${t}, base cannot be less than 2`);if(r<2)throw RangeError(`convertRadix: invalid to=${r}, base cannot be less than 2`);if(wg(e),!e.length)return[];let o=0,n=[],i=Array.from(e,(a)=>{if(_d(a),a<0||a>=t)throw Error(`invalid integer: ${a}`);return a}),s=i.length;while(!0){let a=0,c=!0;for(let u=o;u<s;u++){let d=i[u],p=t*a,m=p+d;if(!Number.isSafeInteger(m)||p/t!==a||m-d!==p)throw Error("convertRadix: carry overflow");let h=m/r;a=m%r;let b=Math.floor(h);if(i[u]=b,!Number.isSafeInteger(b)||b*r+a!==m)throw Error("convertRadix: carry overflow");if(!c)continue;else if(!b)o=u;else c=!1}if(n.push(a),c)break}for(let a=0;a<e.length-1&&e[a]===0;a++)n.push(0);return n.reverse()}function VI(e,t,r,o){if(wg(e),t<=0||t>32)throw RangeError(`convertRadix2: wrong from=${t}`);if(r<=0||r>32)throw RangeError(`convertRadix2: wrong to=${r}`);if(_g(t,r)>32)throw Error(`convertRadix2: carry overflow from=${t} to=${r} carryBits=${_g(t,r)}`);let n=0,i=0,s=vg[t],a=vg[r]-1,c=[];for(let u of e){if(_d(u),u>=s)throw Error(`convertRadix2: invalid data word=${u} from=${t}`);if(n=n<<t|u,i+t>32)throw Error(`convertRadix2: carry overflow pos=${i} from=${t}`);i+=t;for(;i>=r;i-=r)c.push((n>>i-r&a)>>>0);let d=vg[i];if(d===void 0)throw Error("invalid carry");n&=d-1}if(n=n<<r-i&a,!o&&i>=t)throw Error("Excess padding");if(!o&&n>0)throw Error(`Non-zero padding: ${n}`);if(o&&i>0)c.push(n>>>0);return c}function iae(e){_d(e);let t=256;return{encode:(r)=>{if(!Eg(r))throw TypeError("radix.encode input should be Uint8Array");return Pj(Array.from(r),t,e)},decode:(r)=>(QI("radix.decode",r),Uint8Array.from(Pj(r,e,t)))}}function Qr(e,t=!1){if(_d(e),e<=0||e>32)throw RangeError("radix2: bits should be in (0..32]");if(_g(8,e)>32||_g(e,8)>32)throw RangeError("radix2: carry overflow");return{encode:(r)=>{if(!Eg(r))throw TypeError("radix2.encode input should be Uint8Array");return VI(Array.from(r),8,e,!t)},decode:(r)=>(QI("radix2.decode",r),Uint8Array.from(VI(r,e,8,t)))}}function zj(e){return Bj(e),function(...t){try{return e.apply(null,t)}catch(r){}}}function xd(e){let t=e>>25,r=(e&33554431)<<5;for(let o=0;o<Nj.length;o++)if((t>>o&1)===1)r^=Nj[o];return r}function Dj(e,t,r=1){let o=e.length,n=1;for(let i=0;i<o;i++){let s=e.charCodeAt(i);if(s<33||s>126)throw Error(`Invalid prefix (${e})`);n=xd(n)^s>>5}n=xd(n);for(let i=0;i<o;i++)n=xd(n)^e.charCodeAt(i)&31;for(let i of t)n=xd(n)^i;for(let i=0;i<6;i++)n=xd(n);return n^=r,WI.encode(VI([n%vg[30]],30,5,!1))}function qj(e){let t=e==="bech32"?1:734539939,r=Qr(5),o=r.decode,n=r.encode,i=zj(o);function s(p,m,h=90){if(Ii("bech32.encode prefix",p),Eg(m))m=Array.from(m);QI("bech32.encode",m);let b=p.length;if(b===0)throw TypeError(`Invalid prefix length ${b}`);let y=b+7+m.length;if(h!==!1&&y>h)throw TypeError(`Length ${y} exceeds limit ${h}`);let S=p.toLowerCase(),x=Dj(S,m,t);return`${S}1${WI.encode(m)}${x}`}function a(p,m=90){Ii("bech32.decode input",p);let h=p.length;if(h<8||m!==!1&&h>m)throw TypeError(`invalid string length: ${h} (${p}). Expected (8..${m})`);let b=p.toLowerCase();if(p!==b&&p!==p.toUpperCase())throw Error("String must be lowercase or uppercase");let y=b.lastIndexOf("1");if(y===0||y===-1)throw Error('Letter "1" must be present between prefix and data only');let S=b.slice(0,y),x=b.slice(y+1);if(x.length<6)throw Error("Data must be at least 6 characters long");let _=WI.decode(x).slice(0,-6),A=Dj(S,_,t);if(!x.endsWith(A))throw Error(`Invalid checksum in ${p}: expected "${A}"`);return{prefix:S,words:_}}let c=zj(a);function u(p){let{prefix:m,words:h}=a(p,!1);return{prefix:m,words:h,bytes:o(h)}}function d(p,m){return s(p,n(m))}return{encode:s,decode:a,encodeFromBytes:d,decodeToBytes:u,decodeUnsafe:c,fromWords:o,fromWordsUnsafe:i,toWords:n}}var Zj=(e,t)=>t===0?e:Zj(t,e%t),_g=(e,t)=>e+(t-Zj(e,t)),vg,R$e,$$e,O$e,C$e,P$e,z$e,Uj,sae,Mj=(e,t)=>{Ii("base64",e);let r=t?"base64url":"base64";if(e.length>0&&sae.test(e))throw Error("invalid base64");return Uint8Array.fromBase64(e,{alphabet:r,lastChunkHandling:"strict"})},YI,tr,N$e,D$e,XI=(e)=>Nr(iae(58),Dr(e),Lr("")),L$e,B$e,j$e,WI,Nj,Br,Z$e,aae,cae,U$e;var Ed=v(()=>{/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */vg=(()=>{let e=[];for(let t=0;t<40;t++)e.push(2**t);return e})();R$e=Object.freeze(Nr(Qr(4),Dr("0123456789ABCDEF"),Lr(""))),$$e=Object.freeze(Nr(Qr(5),Dr("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),kg(5),Lr(""))),O$e=Object.freeze(Nr(Qr(5),Dr("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),Lr(""))),C$e=Object.freeze(Nr(Qr(5),Dr("0123456789ABCDEFGHIJKLMNOPQRSTUV"),kg(5),Lr(""))),P$e=Object.freeze(Nr(Qr(5),Dr("0123456789ABCDEFGHIJKLMNOPQRSTUV"),Lr(""))),z$e=Object.freeze(Nr(Qr(5),Dr("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),Lr(""),jj((e)=>e.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1")))),Uj=(()=>typeof Uint8Array.from([]).toBase64==="function"&&typeof Uint8Array.fromBase64==="function")(),sae=/[\t\n\f\r ]/,YI=Object.freeze(Uj?{encode(e){return GI(e),e.toBase64()},decode(e){return Mj(e,!1)}}:Nr(Qr(6),Dr("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),kg(6),Lr(""))),tr=Object.freeze(Nr(Qr(6),Dr("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),Lr(""))),N$e=Object.freeze(Uj?{encode(e){return GI(e),e.toBase64({alphabet:"base64url"})},decode(e){return Mj(e,!0)}}:Nr(Qr(6),Dr("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),kg(6),Lr(""))),D$e=Object.freeze(Nr(Qr(6),Dr("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),Lr(""))),L$e=Object.freeze(XI("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")),B$e=Object.freeze(XI("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ")),j$e=Object.freeze(XI("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz")),WI=Nr(Dr("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),Lr("")),Nj=[996825010,642813549,513874426,1027748829,705979059];Br=Object.freeze(qj("bech32")),Z$e=Object.freeze(qj("bech32m")),aae=(()=>typeof Uint8Array.from([]).toHex==="function"&&typeof Uint8Array.fromHex==="function")(),cae={encode(e){return GI(e),e.toHex()},decode(e){return Ii("hex",e),Uint8Array.fromHex(e)}},U$e=Object.freeze(aae?cae:Nr(Qr(4),Dr("0123456789abcdef"),Lr(""),jj((e)=>{if(typeof e!=="string"||e.length%2!==0)throw TypeError(`hex.decode: expected string, got ${typeof e} with length ${e.length}`);return e.toLowerCase()})))});function uae(e,t,r,o){wo(e);let n=gg({dkLen:32,asyncTick:10},o),{c:i,dkLen:s,asyncTick:a}=n;if(vt(i,"c"),vt(s,"dkLen"),vt(a,"asyncTick"),i<1)throw Error("iterations (c) must be >= 1");if(s<1)throw Error('"dkLen" must be >= 1');if(s>4294967295*e.outputLen)throw Error("derived key too long");let c=BI(t,"password"),u=BI(r,"salt"),d=new Uint8Array(s),p=Mn.create(e,c),m=p._cloneInto().update(u);return{c:i,dkLen:s,asyncTick:a,DK:d,PRF:p,PRFSalt:m}}function dae(e,t,r,o,n){if(e.destroy(),t.destroy(),o)o.destroy();return hr(n),r}function eA(e,t,r,o){let{c:n,dkLen:i,DK:s,PRF:a,PRFSalt:c}=uae(e,t,r,o),u,d=new Uint8Array(4),p=Oc(d),m=new Uint8Array(a.outputLen);for(let h=1,b=0;b<i;h++,b+=a.outputLen){let y=s.subarray(b,b+a.outputLen);p.setInt32(0,h,!1),(u=c._cloneInto(u)).update(d).digestInto(m),y.set(m.subarray(0,y.length));for(let S=1;S<n;S++){a._cloneInto(u).update(m).digestInto(m);for(let x=0;x<y.length;x++)y[x]^=m[x]}}return dae(a,c,s,u,m)}var Fj=v(()=>{bd();Gr()});function Kj(e,t,r,o,n,i){let s=e[t++]^r[o++],a=e[t++]^r[o++],c=e[t++]^r[o++],u=e[t++]^r[o++],d=e[t++]^r[o++],p=e[t++]^r[o++],m=e[t++]^r[o++],h=e[t++]^r[o++],b=e[t++]^r[o++],y=e[t++]^r[o++],S=e[t++]^r[o++],x=e[t++]^r[o++],_=e[t++]^r[o++],A=e[t++]^r[o++],O=e[t++]^r[o++],L=e[t++]^r[o++],z=s,H=a,P=c,W=u,ee=d,j=p,R=m,B=h,k=b,T=y,I=S,q=x,N=_,J=A,G=O,re=L;for(let ae=0;ae<8;ae+=2)ee^=Fe(z+N|0,7),k^=Fe(ee+z|0,9),N^=Fe(k+ee|0,13),z^=Fe(N+k|0,18),T^=Fe(j+H|0,7),J^=Fe(T+j|0,9),H^=Fe(J+T|0,13),j^=Fe(H+J|0,18),G^=Fe(I+R|0,7),P^=Fe(G+I|0,9),R^=Fe(P+G|0,13),I^=Fe(R+P|0,18),W^=Fe(re+q|0,7),B^=Fe(W+re|0,9),q^=Fe(B+W|0,13),re^=Fe(q+B|0,18),H^=Fe(z+W|0,7),P^=Fe(H+z|0,9),W^=Fe(P+H|0,13),z^=Fe(W+P|0,18),R^=Fe(j+ee|0,7),B^=Fe(R+j|0,9),ee^=Fe(B+R|0,13),j^=Fe(ee+B|0,18),q^=Fe(I+T|0,7),k^=Fe(q+I|0,9),T^=Fe(k+q|0,13),I^=Fe(T+k|0,18),N^=Fe(re+G|0,7),J^=Fe(N+re|0,9),G^=Fe(J+N|0,13),re^=Fe(G+J|0,18);n[i++]=s+z|0,n[i++]=a+H|0,n[i++]=c+P|0,n[i++]=u+W|0,n[i++]=d+ee|0,n[i++]=p+j|0,n[i++]=m+R|0,n[i++]=h+B|0,n[i++]=b+k|0,n[i++]=y+T|0,n[i++]=S+I|0,n[i++]=x+q|0,n[i++]=_+N|0,n[i++]=A+J|0,n[i++]=O+G|0,n[i++]=L+re|0}function tA(e,t,r,o,n){let i=o+0,s=o+16*n;for(let a=0;a<16;a++)r[s+a]=e[t+(2*n-1)*16+a];for(let a=0;a<n;a++,i+=16,t+=16){if(Kj(r,s,e,t,r,i),a>0)s+=16;Kj(r,i,e,t+=16,r,s)}}function pae(e,t,r){let o=gg({dkLen:32,asyncTick:10,maxmem:1073742848},r),{N:n,r:i,p:s,dkLen:a,asyncTick:c,maxmem:u,onProgress:d}=o;if(vt(n,"N"),vt(i,"r"),vt(s,"p"),vt(a,"dkLen"),vt(c,"asyncTick"),vt(u,"maxmem"),d!==void 0&&typeof d!=="function")throw Error("progressCb must be a function");let p=128*i,m=p/4,h=Math.pow(2,32);if(n<=1||(n&n-1)!==0||n>h)throw Error('"N" expected a power of 2, and 2^1 <= N <= 2^32');if(s<1||s>(h-1)*32/p)throw Error('"p" expected integer 1..((2^32 - 1) * 32) / (128 * r)');if(a<1||a>(h-1)*32)throw Error('"dkLen" expected integer 1..(2^32 - 1) * 32');let b=p*(n+s+1);if(b>u)throw Error('"maxmem" limit was hit: memUsed(128*r*(N+p+1))='+b+", maxmem="+u);let y=eA(wt,e,t,{c:1,dkLen:p*s}),S=mg(y),x=mg(new Uint8Array(p*n)),_=mg(new Uint8Array(p)),A=()=>{};if(d){let O=2*n*s,L=Math.max(Math.floor(O/1e4),1),z=0;A=()=>{if(z++,d&&(!(z%L)||z===O))d(z/O)}}return{N:n,r:i,p:s,dkLen:a,blockSize32:m,V:x,B32:S,B:y,tmp:_,blockMixCb:A,asyncTick:c}}function fae(e,t,r,o,n){let i=eA(wt,e,r,{c:1,dkLen:t});return hr(r,o,n),i}function rA(e,t,r){let{N:o,r:n,p:i,dkLen:s,blockSize32:a,V:c,B32:u,B:d,tmp:p,blockMixCb:m}=pae(e,t,r);LI(u);for(let h=0;h<i;h++){let b=a*h;for(let y=0;y<a;y++)c[y]=u[b+y];for(let y=0,S=0;y<o-1;y++)tA(c,S,c,S+=a,n),m();tA(c,(o-1)*a,u,b,n),m();for(let y=0;y<o;y++){let S=(u[b+a-16]&o-1)>>>0;for(let x=0;x<a;x++)p[x]=u[b+x]^c[S*a+x];tA(p,0,u,b,n),m()}}return LI(u),fae(e,s,d,c,p)}var Hj=v(()=>{Fj();Cc();Gr()});function mae(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function Ig(e){if(typeof e!=="boolean")throw TypeError(`boolean expected, not ${e}`)}function Pc(e){if(typeof e!=="number")throw TypeError("number expected, got "+typeof e);if(!Number.isSafeInteger(e)||e<0)throw RangeError("positive integer expected, got "+e)}function Ct(e,t,r=""){let o=mae(e),n=e?.length,i=t!==void 0;if(!o||i&&n!==t){let s=r&&`"${r}" `,a=i?` of length ${t}`:"",c=o?`length=${n}`:`type=${typeof e}`,u=s+"expected Uint8Array"+a+", got "+c;if(!o)throw TypeError(u);throw RangeError(u)}return e}function nA(e,t=!0){if(e.destroyed)throw Error("Hash instance has been destroyed");if(t&&e.finished)throw Error("Hash#digest() has already been called")}function Jj(e,t,r=!1){Ct(e,void 0,"output");let o=t.outputLen;if(e.length<o)throw RangeError("digestInto() expects output buffer of length at least "+o);if(r&&!zc(e))throw Error("invalid output, must be aligned")}function Fn(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function gn(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function hae(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Vj(e,t){if(t==null||typeof t!=="object")throw Error("options must be defined");return Object.assign(e,t)}function Wj(e,t){if(e.length!==t.length)return!1;let r=0;for(let o=0;o<e.length;o++)r|=e[o]^t[o];return r===0}function Gj(e,t,r){let o=t,n=r||(()=>[]),i=(a,c)=>o(c,...n(a)).update(a).digest(),s=o(new Uint8Array(e),...n(new Uint8Array(0)));return i.outputLen=s.outputLen,i.blockLen=s.blockLen,i.create=(a,...c)=>o(a,...c),i}function kd(e,t,r=!0){if(t===void 0)return new Uint8Array(e);if(Ct(t,void 0,"output"),t.length!==e)throw Error('"output" expected Uint8Array of length '+e+", got: "+t.length);if(r&&!zc(t))throw Error("invalid output, must be aligned");return t}function Yj(e,t,r){Pc(e),Pc(t),Ig(r);let o=new Uint8Array(16),n=hae(o);return n.setBigUint64(0,BigInt(t),r),n.setBigUint64(8,BigInt(e),r),o}function zc(e){return e.byteOffset%4===0}function Nc(e){return Uint8Array.from(Ct(e))}var Bs,gae=(e)=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255,yae=(e)=>{for(let t=0;t<e.length;t++)e[t]=gae(e[t]);return e},Eo,Qj=(e,t)=>{function r(o,...n){if(Ct(o,void 0,"key"),e.nonceLength!==void 0){let d=n[0];Ct(d,e.varSizeNonce?void 0:e.nonceLength,"nonce")}let i=e.tagLength;if(i&&n[1]!==void 0)Ct(n[1],void 0,"AAD");let s=t(o,...n),a=(d,p)=>{if(p!==void 0){if(d!==2)throw Error("cipher output not supported");Ct(p,void 0,"output")}},c=!1;return{encrypt(d,p){if(c)throw Error("cannot encrypt() twice with same key + nonce");return c=!0,Ct(d),a(s.encrypt.length,p),s.encrypt(d,p)},decrypt(d,p){if(Ct(d),i&&d.length<i)throw Error('"ciphertext" expected length bigger than tagLength='+i);return a(s.decrypt.length,p),s.decrypt(d,p)}}}return Object.assign(r,e),r};var Ag=v(()=>{/*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */Bs=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)(),Eo=Bs?(e)=>e:yae});function Ke(e,t){return e<<t|e>>>32-t}function wae(e,t,r,o,n,i,s,a){let c=n.length,u=new Uint8Array(Id),d=Fn(u),p=Bs&&zc(n)&&zc(i),m=p?Fn(n):Xj,h=p?Fn(i):Xj;if(!Bs){for(let b=0;b<c;s++){if(e(t,r,o,d,s,a),Eo(d),s>=oA)throw Error("arx: counter overflow");let y=Math.min(Id,c-b);for(let S=0,x;S<y;S++)x=b+S,i[x]=n[x]^u[S];b+=y}return}for(let b=0;b<c;s++){if(e(t,r,o,d,s,a),s>=oA)throw Error("arx: counter overflow");let y=Math.min(Id,c-b);if(p&&y===Id){let S=b/4;if(b%4!==0)throw Error("arx: invalid block position");for(let x=0,_;x<vae;x++)_=S+x,h[_]=m[_]^d[x];b+=Id;continue}for(let S=0,x;S<y;S++)x=b+S,i[x]=n[x]^u[S];b+=y}}function tZ(e,t){let{allowShortKeys:r,extendNonceFn:o,counterLength:n,counterRight:i,rounds:s}=Vj({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},t);if(typeof e!=="function")throw Error("core must be a function");return Pc(n),Pc(s),Ig(i),Ig(r),(a,c,u,d,p=0)=>{Ct(a,void 0,"key"),Ct(c,void 0,"nonce"),Ct(u,void 0,"data");let m=u.length;if(d=kd(m,d,!1),Pc(p),p<0||p>=oA)throw Error("arx: counter overflow");let h=[],b=a.length,y,S;if(b===32)h.push(y=Nc(a)),S=Sae;else if(b===16&&r)y=new Uint8Array(32),y.set(a),y.set(a,16),S=bae,h.push(y);else throw Ct(a,32,"arx key"),Error("invalid key size");if(!Bs||!zc(c))h.push(c=Nc(c));let x=Fn(y);if(o){if(c.length!==24)throw Error("arx: extended nonce must be 24 bytes");let O=c.subarray(0,16);if(Bs)o(S,x,Fn(O),x);else{let L=Eo(Uint32Array.from(S));o(L,x,Fn(O),x),gn(L),Eo(x)}c=c.subarray(16)}else if(!Bs)Eo(x);let _=16-n;if(_!==c.length)throw Error(`arx: nonce must be ${_} or 16 bytes`);if(_!==12){let O=new Uint8Array(12);O.set(c,i?0:12-c.length),c=O,h.push(c)}let A=Eo(Fn(c));try{return wae(e,S,x,A,u,d,p,s),d}finally{gn(...h)}}}var eZ=(e)=>Uint8Array.from(e.split(""),(t)=>t.charCodeAt(0)),bae,Sae,Id=64,vae=16,oA,Xj;var rZ=v(()=>{Ag();bae=(()=>Eo(Fn(eZ("expand 16-byte k"))))(),Sae=(()=>Eo(Fn(eZ("expand 32-byte k"))))();oA=(()=>4294967295)(),Xj=Uint32Array.of()});function Ht(e,t){return e[t++]&255|(e[t++]&255)<<8}class nZ{blockLen=16;outputLen=16;buffer=new Uint8Array(16);r=new Uint16Array(10);h=new Uint16Array(10);pad=new Uint16Array(8);pos=0;finished=!1;destroyed=!1;constructor(e){e=Nc(Ct(e,32,"key"));let t=Ht(e,0),r=Ht(e,2),o=Ht(e,4),n=Ht(e,6),i=Ht(e,8),s=Ht(e,10),a=Ht(e,12),c=Ht(e,14);this.r[0]=t&8191,this.r[1]=(t>>>13|r<<3)&8191,this.r[2]=(r>>>10|o<<6)&7939,this.r[3]=(o>>>7|n<<9)&8191,this.r[4]=(n>>>4|i<<12)&255,this.r[5]=i>>>1&8190,this.r[6]=(i>>>14|s<<2)&8191,this.r[7]=(s>>>11|a<<5)&8065,this.r[8]=(a>>>8|c<<8)&8191,this.r[9]=c>>>5&127;for(let u=0;u<8;u++)this.pad[u]=Ht(e,16+2*u)}process(e,t,r=!1){let o=r?0:2048,{h:n,r:i}=this,s=i[0],a=i[1],c=i[2],u=i[3],d=i[4],p=i[5],m=i[6],h=i[7],b=i[8],y=i[9],S=Ht(e,t+0),x=Ht(e,t+2),_=Ht(e,t+4),A=Ht(e,t+6),O=Ht(e,t+8),L=Ht(e,t+10),z=Ht(e,t+12),H=Ht(e,t+14),P=n[0]+(S&8191),W=n[1]+((S>>>13|x<<3)&8191),ee=n[2]+((x>>>10|_<<6)&8191),j=n[3]+((_>>>7|A<<9)&8191),R=n[4]+((A>>>4|O<<12)&8191),B=n[5]+(O>>>1&8191),k=n[6]+((O>>>14|L<<2)&8191),T=n[7]+((L>>>11|z<<5)&8191),I=n[8]+((z>>>8|H<<8)&8191),q=n[9]+(H>>>5|o),N=0,J=N+P*s+W*(5*y)+ee*(5*b)+j*(5*h)+R*(5*m);N=J>>>13,J&=8191,J+=B*(5*p)+k*(5*d)+T*(5*u)+I*(5*c)+q*(5*a),N+=J>>>13,J&=8191;let G=N+P*a+W*s+ee*(5*y)+j*(5*b)+R*(5*h);N=G>>>13,G&=8191,G+=B*(5*m)+k*(5*p)+T*(5*d)+I*(5*u)+q*(5*c),N+=G>>>13,G&=8191;let re=N+P*c+W*a+ee*s+j*(5*y)+R*(5*b);N=re>>>13,re&=8191,re+=B*(5*h)+k*(5*m)+T*(5*p)+I*(5*d)+q*(5*u),N+=re>>>13,re&=8191;let ae=N+P*u+W*c+ee*a+j*s+R*(5*y);N=ae>>>13,ae&=8191,ae+=B*(5*b)+k*(5*h)+T*(5*m)+I*(5*p)+q*(5*d),N+=ae>>>13,ae&=8191;let me=N+P*d+W*u+ee*c+j*a+R*s;N=me>>>13,me&=8191,me+=B*(5*y)+k*(5*b)+T*(5*h)+I*(5*m)+q*(5*p),N+=me>>>13,me&=8191;let be=N+P*p+W*d+ee*u+j*c+R*a;N=be>>>13,be&=8191,be+=B*s+k*(5*y)+T*(5*b)+I*(5*h)+q*(5*m),N+=be>>>13,be&=8191;let ve=N+P*m+W*p+ee*d+j*u+R*c;N=ve>>>13,ve&=8191,ve+=B*a+k*s+T*(5*y)+I*(5*b)+q*(5*h),N+=ve>>>13,ve&=8191;let Ae=N+P*h+W*m+ee*p+j*d+R*u;N=Ae>>>13,Ae&=8191,Ae+=B*c+k*a+T*s+I*(5*y)+q*(5*b),N+=Ae>>>13,Ae&=8191;let Ie=N+P*b+W*h+ee*m+j*p+R*d;N=Ie>>>13,Ie&=8191,Ie+=B*u+k*c+T*a+I*s+q*(5*y),N+=Ie>>>13,Ie&=8191;let we=N+P*y+W*b+ee*h+j*m+R*p;N=we>>>13,we&=8191,we+=B*d+k*u+T*c+I*a+q*s,N+=we>>>13,we&=8191,N=(N<<2)+N|0,N=N+J|0,J=N&8191,N=N>>>13,G+=N,n[0]=J,n[1]=G,n[2]=re,n[3]=ae,n[4]=me,n[5]=be,n[6]=ve,n[7]=Ae,n[8]=Ie,n[9]=we}finalize(){let{h:e,pad:t}=this,r=new Uint16Array(10),o=e[1]>>>13;e[1]&=8191;for(let s=2;s<10;s++)e[s]+=o,o=e[s]>>>13,e[s]&=8191;e[0]+=o*5,o=e[0]>>>13,e[0]&=8191,e[1]+=o,o=e[1]>>>13,e[1]&=8191,e[2]+=o,r[0]=e[0]+5,o=r[0]>>>13,r[0]&=8191;for(let s=1;s<10;s++)r[s]=e[s]+o,o=r[s]>>>13,r[s]&=8191;r[9]-=8192;let n=(o^1)-1;for(let s=0;s<10;s++)r[s]&=n;n=~n;for(let s=0;s<10;s++)e[s]=e[s]&n|r[s];e[0]=(e[0]|e[1]<<13)&65535,e[1]=(e[1]>>>3|e[2]<<10)&65535,e[2]=(e[2]>>>6|e[3]<<7)&65535,e[3]=(e[3]>>>9|e[4]<<4)&65535,e[4]=(e[4]>>>12|e[5]<<1|e[6]<<14)&65535,e[5]=(e[6]>>>2|e[7]<<11)&65535,e[6]=(e[7]>>>5|e[8]<<8)&65535,e[7]=(e[8]>>>8|e[9]<<5)&65535;let i=e[0]+t[0];e[0]=i&65535;for(let s=1;s<8;s++)i=(e[s]+t[s]|0)+(i>>>16)|0,e[s]=i&65535;gn(r)}update(e){nA(this),Ct(e),e=Nc(e);let{buffer:t,blockLen:r}=this,o=e.length;for(let n=0;n<o;){let i=Math.min(r-this.pos,o-n);if(i===r){for(;r<=o-n;n+=r)this.process(e,n);continue}if(t.set(e.subarray(n,n+i),this.pos),this.pos+=i,n+=i,this.pos===r)this.process(t,0,!1),this.pos=0}return this}destroy(){this.destroyed=!0,gn(this.h,this.r,this.buffer,this.pad)}digestInto(e){nA(this),Jj(e,this),this.finished=!0;let{buffer:t,h:r}=this,{pos:o}=this;if(o){t[o++]=1;for(;o<16;o++)t[o]=0;this.process(t,0,!0)}this.finalize();let n=0;for(let i=0;i<8;i++)e[n++]=r[i]>>>0,e[n++]=r[i]>>>8}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let r=e.slice(0,t);return this.destroy(),r}}var oZ;var iZ=v(()=>{Ag();oZ=Gj(32,(e)=>new nZ(e))});function xae(e,t,r,o,n,i=20){let s=e[0],a=e[1],c=e[2],u=e[3],d=t[0],p=t[1],m=t[2],h=t[3],b=t[4],y=t[5],S=t[6],x=t[7],_=n,A=r[0],O=r[1],L=r[2],z=s,H=a,P=c,W=u,ee=d,j=p,R=m,B=h,k=b,T=y,I=S,q=x,N=_,J=A,G=O,re=L;for(let me=0;me<i;me+=2)z=z+ee|0,N=Ke(N^z,16),k=k+N|0,ee=Ke(ee^k,12),z=z+ee|0,N=Ke(N^z,8),k=k+N|0,ee=Ke(ee^k,7),H=H+j|0,J=Ke(J^H,16),T=T+J|0,j=Ke(j^T,12),H=H+j|0,J=Ke(J^H,8),T=T+J|0,j=Ke(j^T,7),P=P+R|0,G=Ke(G^P,16),I=I+G|0,R=Ke(R^I,12),P=P+R|0,G=Ke(G^P,8),I=I+G|0,R=Ke(R^I,7),W=W+B|0,re=Ke(re^W,16),q=q+re|0,B=Ke(B^q,12),W=W+B|0,re=Ke(re^W,8),q=q+re|0,B=Ke(B^q,7),z=z+j|0,re=Ke(re^z,16),I=I+re|0,j=Ke(j^I,12),z=z+j|0,re=Ke(re^z,8),I=I+re|0,j=Ke(j^I,7),H=H+R|0,N=Ke(N^H,16),q=q+N|0,R=Ke(R^q,12),H=H+R|0,N=Ke(N^H,8),q=q+N|0,R=Ke(R^q,7),P=P+B|0,J=Ke(J^P,16),k=k+J|0,B=Ke(B^k,12),P=P+B|0,J=Ke(J^P,8),k=k+J|0,B=Ke(B^k,7),W=W+ee|0,G=Ke(G^W,16),T=T+G|0,ee=Ke(ee^T,12),W=W+ee|0,G=Ke(G^W,8),T=T+G|0,ee=Ke(ee^T,7);let ae=0;o[ae++]=s+z|0,o[ae++]=a+H|0,o[ae++]=c+P|0,o[ae++]=u+W|0,o[ae++]=d+ee|0,o[ae++]=p+j|0,o[ae++]=m+R|0,o[ae++]=h+B|0,o[ae++]=b+k|0,o[ae++]=y+T|0,o[ae++]=S+I|0,o[ae++]=x+q|0,o[ae++]=_+N|0,o[ae++]=A+J|0,o[ae++]=O+G|0,o[ae++]=L+re|0}function aZ(e,t,r,o,n){if(n!==void 0)Ct(n,void 0,"AAD");let i=e(t,r,kae),s=Yj(o.length,n?n.length:0,!0),a=oZ.create(i);if(n)sZ(a,n);sZ(a,o),a.update(s);let c=a.digest();return gn(i,s),c}var _ae,Eae,sZ=(e,t)=>{e.update(t);let r=t.length%16;if(r)e.update(Eae.subarray(r))},kae,Iae=(e)=>(t,r,o)=>({encrypt(i,s){let a=i.length;s=kd(a+16,s,!1),s.set(i);let c=s.subarray(0,-16);e(t,r,c,c,1);let u=aZ(e,t,r,c,o);return s.set(u,a),gn(u),s},decrypt(i,s){s=kd(i.length-16,s,!1);let a=i.subarray(0,-16),c=i.subarray(-16),u=aZ(e,t,r,a,o);if(!Wj(c,u))throw gn(u),Error("invalid tag");return s.set(i.subarray(0,-16)),e(t,r,s,s,1),gn(u),s}}),Yr;var iA=v(()=>{rZ();iZ();Ag();_ae=tZ(xae,{counterRight:!1,counterLength:4,allowShortKeys:!1}),Eae=new Uint8Array(16),kae=new Uint8Array(32);Yr=Qj({blockSize:64,nonceLength:12,tagLength:16},Iae(_ae))});function Dc(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Zt(e,t=""){if(!Number.isSafeInteger(e)||e<0){let r=t&&`"${t}" `;throw Error(`${r}expected integer >= 0, got ${e}`)}}function Te(e,t,r=""){let o=Dc(e),n=e?.length,i=t!==void 0;if(!o||i&&n!==t){let s=r&&`"${r}" `,a=i?` of length ${t}`:"",c=o?`length=${n}`:`type=${typeof e}`;throw Error(s+"expected Uint8Array"+a+", got "+c)}return e}function Xr(e){if(typeof e!=="function"||typeof e.create!=="function")throw Error("Hash must wrapped by utils.createHasher");Zt(e.outputLen),Zt(e.blockLen)}function Io(e,t=!0){if(e.destroyed)throw Error("Hash instance has been destroyed");if(t&&e.finished)throw Error("Hash#digest() has already been called")}function Tg(e,t){Te(e,void 0,"digestInto() output");let r=t.outputLen;if(e.length<r)throw Error('"digestInto() output" expected to be of length >='+r)}function Rg(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function kr(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function $g(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function yn(e,t){return e<<32-t|e>>>t}function Tae(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function Rae(e){for(let t=0;t<e.length;t++)e[t]=Tae(e[t]);return e}function js(e){if(Te(e),lZ)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=$ae[e[r]];return t}function cZ(e){if(e>=ko._0&&e<=ko._9)return e-ko._0;if(e>=ko.A&&e<=ko.F)return e-(ko.A-10);if(e>=ko.a&&e<=ko.f)return e-(ko.a-10);return}function Zs(e){if(typeof e!=="string")throw Error("hex string expected, got "+typeof e);if(lZ)return Uint8Array.fromHex(e);let t=e.length,r=t/2;if(t%2)throw Error("hex string expected, got unpadded hex of length "+t);let o=new Uint8Array(r);for(let n=0,i=0;n<r;n++,i+=2){let s=cZ(e.charCodeAt(i)),a=cZ(e.charCodeAt(i+1));if(s===void 0||a===void 0){let c=e[i]+e[i+1];throw Error('hex string expected, got non-hex character "'+c+'" at index '+i)}o[n]=s*16+a}return o}function kt(...e){let t=0;for(let o=0;o<e.length;o++){let n=e[o];Te(n),t+=n.length}let r=new Uint8Array(t);for(let o=0,n=0;o<e.length;o++){let i=e[o];r.set(i,n),n+=i.length}return r}function Lc(e,t={}){let r=(n,i)=>e(i).update(n).digest(),o=e(void 0);return r.outputLen=o.outputLen,r.blockLen=o.blockLen,r.create=(n)=>e(n),Object.assign(r,t),Object.freeze(r)}function Ai(e=32){let t=typeof globalThis==="object"?globalThis.crypto:null;if(typeof t?.getRandomValues!=="function")throw Error("crypto.getRandomValues must be defined");return t.getRandomValues(new Uint8Array(e))}var Aae,sA,lZ,$ae,ko,Ti=(e)=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});var jr=v(()=>{/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */Aae=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)();sA=Aae?(e)=>e:Rae,lZ=(()=>typeof Uint8Array.from([]).toHex==="function"&&typeof Uint8Array.fromHex==="function")(),$ae=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));ko={_0:48,_9:57,A:65,F:70,a:97,f:102}});function Ad(e,t=""){if(typeof e!=="boolean"){let r=t&&`"${t}" `;throw Error(r+"expected boolean, got type="+typeof e)}return e}function uZ(e){if(typeof e==="bigint"){if(!Og(e))throw Error("positive bigint expected, got "+e)}else Zt(e);return e}function Td(e){let t=uZ(e).toString(16);return t.length&1?"0"+t:t}function dZ(e){if(typeof e!=="string")throw Error("hex string expected, got "+typeof e);return e===""?cA:BigInt("0x"+e)}function Ri(e){return dZ(js(e))}function $i(e){return dZ(js(Cg(Te(e)).reverse()))}function Bc(e,t){Zt(t),e=uZ(e);let r=Zs(e.toString(16).padStart(t*2,"0"));if(r.length!==t)throw Error("number too large");return r}function Rd(e,t){return Bc(e,t).reverse()}function Cg(e){return Uint8Array.from(e)}function Oi(e){return Uint8Array.from(e,(t,r)=>{let o=t.charCodeAt(0);if(t.length!==1||o>127)throw Error(`string contains non-ASCII character "${e[r]}" with code ${o} at position ${r}`);return o})}function Oae(e,t,r){return Og(e)&&Og(t)&&Og(r)&&t<=e&&e<r}function $d(e,t,r,o){if(!Oae(t,r,o))throw Error("expected valid "+e+": "+r+" <= n < "+o+", got "+t)}function lA(e){let t;for(t=0;e>cA;e>>=aA,t+=1);return t}function pZ(e,t,r){if(Zt(e,"hashLen"),Zt(t,"qByteLen"),typeof r!=="function")throw Error("hmacFn must be a function");let o=(S)=>new Uint8Array(S),n=Uint8Array.of(),i=Uint8Array.of(0),s=Uint8Array.of(1),a=1000,c=o(e),u=o(e),d=0,p=()=>{c.fill(1),u.fill(0),d=0},m=(...S)=>r(u,kt(c,...S)),h=(S=n)=>{if(u=m(i,S),c=m(),S.length===0)return;u=m(s,S),c=m()},b=()=>{if(d++>=a)throw Error("drbg: tried max amount of iterations");let S=0,x=[];while(S<t){c=m();let _=c.slice();x.push(_),S+=c.length}return kt(...x)};return(S,x)=>{p(),h(S);let _=void 0;while(!(_=x(b())))h();return p(),_}}function Us(e,t={},r={}){if(!e||typeof e!=="object")throw Error("expected valid options object");function o(i,s,a){let c=e[i];if(a&&c===void 0)return;let u=typeof c;if(u!==s||c===null)throw Error(`param "${i}" is invalid: expected ${s}, got ${u}`)}let n=(i,s)=>Object.entries(i).forEach(([a,c])=>o(a,c,s));n(t,!1),n(r,!0)}function uA(e){let t=new WeakMap;return(r,...o)=>{let n=t.get(r);if(n!==void 0)return n;let i=e(r,...o);return t.set(r,i),i}}var cA,aA,Og=(e)=>typeof e==="bigint"&&cA<=e,Od=(e)=>(aA<<BigInt(e))-aA;var jc=v(()=>{jr();jr();/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */cA=BigInt(0),aA=BigInt(1)});function gr(e,t){let r=e%t;return r>=yr?r:t+r}function en(e,t,r){let o=e;while(t-- >yr)o*=o,o%=r;return o}function fZ(e,t){if(e===yr)throw Error("invert: expected non-zero number");if(t<=yr)throw Error("invert: expected positive modulus, got "+t);let r=gr(e,t),o=t,n=yr,i=rr,s=rr,a=yr;while(r!==yr){let u=o/r,d=o%r,p=n-s*u,m=i-a*u;o=r,r=d,n=s,i=a,s=p,a=m}if(o!==rr)throw Error("invert: does not exist");return gr(n,t)}function dA(e,t,r){if(!e.eql(e.sqr(t),r))throw Error("Cannot find square root")}function vZ(e,t){let r=(e.ORDER+rr)/gZ,o=e.pow(t,r);return dA(e,o,t),o}function zae(e,t){let r=(e.ORDER-yZ)/bZ,o=e.mul(t,Ms),n=e.pow(o,r),i=e.mul(t,n),s=e.mul(e.mul(i,Ms),n),a=e.mul(i,e.sub(s,e.ONE));return dA(e,a,t),a}function Nae(e){let t=Pg(e),r=wZ(e),o=r(t,t.neg(t.ONE)),n=r(t,o),i=r(t,t.neg(o)),s=(e+Cae)/SZ;return(a,c)=>{let u=a.pow(c,s),d=a.mul(u,o),p=a.mul(u,n),m=a.mul(u,i),h=a.eql(a.sqr(d),c),b=a.eql(a.sqr(p),c);u=a.cmov(u,d,h),d=a.cmov(m,p,b);let y=a.eql(a.sqr(d),c),S=a.cmov(u,d,y);return dA(a,S,c),S}}function wZ(e){if(e<hZ)throw Error("sqrt is not defined for small field");let t=e-rr,r=0;while(t%Ms===yr)t/=Ms,r++;let o=Ms,n=Pg(e);while(mZ(n,o)===1)if(o++>1000)throw Error("Cannot find square root: probably non-prime P");if(r===1)return vZ;let i=n.pow(o,t),s=(t+rr)/Ms;return function(c,u){if(c.is0(u))return u;if(mZ(c,u)!==1)throw Error("Cannot find square root");let d=r,p=c.mul(c.ONE,i),m=c.pow(u,t),h=c.pow(u,s);while(!c.eql(m,c.ONE)){if(c.is0(m))return c.ZERO;let b=1,y=c.sqr(m);while(!c.eql(y,c.ONE))if(b++,y=c.sqr(y),b===d)throw Error("Cannot find square root");let S=rr<<BigInt(d-b-1),x=c.pow(p,S);d=b,p=c.sqr(x),m=c.mul(m,p),h=c.mul(h,x)}return h}}function Dae(e){if(e%gZ===hZ)return vZ;if(e%bZ===yZ)return zae;if(e%SZ===Pae)return Nae(e);return wZ(e)}function pA(e){let t={ORDER:"bigint",BYTES:"number",BITS:"number"},r=Lae.reduce((o,n)=>(o[n]="function",o),t);return Us(e,r),e}function Bae(e,t,r){if(r<yr)throw Error("invalid exponent, negatives unsupported");if(r===yr)return e.ONE;if(r===rr)return t;let o=e.ONE,n=t;while(r>yr){if(r&rr)o=e.mul(o,n);n=e.sqr(n),r>>=rr}return o}function Cd(e,t,r=!1){let o=Array(t.length).fill(r?e.ZERO:void 0),n=t.reduce((s,a,c)=>{if(e.is0(a))return s;return o[c]=s,e.mul(s,a)},e.ONE),i=e.inv(n);return t.reduceRight((s,a,c)=>{if(e.is0(a))return s;return o[c]=e.mul(s,o[c]),e.mul(s,a)},i),o}function mZ(e,t){let r=(e.ORDER-rr)/Ms,o=e.pow(t,r),n=e.eql(o,e.ONE),i=e.eql(o,e.ZERO),s=e.eql(o,e.neg(e.ONE));if(!n&&!i&&!s)throw Error("invalid Legendre symbol result");return n?1:i?0:-1}function jae(e,t){if(t!==void 0)Zt(t);let r=t!==void 0?t:e.toString(2).length,o=Math.ceil(r/8);return{nBitLength:r,nByteLength:o}}class xZ{ORDER;BITS;BYTES;isLE;ZERO=yr;ONE=rr;_lengths;_sqrt;_mod;constructor(e,t={}){if(e<=yr)throw Error("invalid field: expected ORDER > 0, got "+e);let r=void 0;if(this.isLE=!1,t!=null&&typeof t==="object"){if(typeof t.BITS==="number")r=t.BITS;if(typeof t.sqrt==="function")this.sqrt=t.sqrt;if(typeof t.isLE==="boolean")this.isLE=t.isLE;if(t.allowedLengths)this._lengths=t.allowedLengths?.slice();if(typeof t.modFromBytes==="boolean")this._mod=t.modFromBytes}let{nBitLength:o,nByteLength:n}=jae(e,r);if(n>2048)throw Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=e,this.BITS=o,this.BYTES=n,this._sqrt=void 0,Object.preventExtensions(this)}create(e){return gr(e,this.ORDER)}isValid(e){if(typeof e!=="bigint")throw Error("invalid field element: expected bigint, got "+typeof e);return yr<=e&&e<this.ORDER}is0(e){return e===yr}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&rr)===rr}neg(e){return gr(-e,this.ORDER)}eql(e,t){return e===t}sqr(e){return gr(e*e,this.ORDER)}add(e,t){return gr(e+t,this.ORDER)}sub(e,t){return gr(e-t,this.ORDER)}mul(e,t){return gr(e*t,this.ORDER)}pow(e,t){return Bae(this,e,t)}div(e,t){return gr(e*fZ(t,this.ORDER),this.ORDER)}sqrN(e){return e*e}addN(e,t){return e+t}subN(e,t){return e-t}mulN(e,t){return e*t}inv(e){return fZ(e,this.ORDER)}sqrt(e){if(!this._sqrt)this._sqrt=Dae(this.ORDER);return this._sqrt(this,e)}toBytes(e){return this.isLE?Rd(e,this.BYTES):Bc(e,this.BYTES)}fromBytes(e,t=!1){Te(e);let{_lengths:r,BYTES:o,isLE:n,ORDER:i,_mod:s}=this;if(r){if(!r.includes(e.length)||e.length>o)throw Error("Field.fromBytes: expected "+r+" bytes, got "+e.length);let c=new Uint8Array(o);c.set(e,n?0:c.length-e.length),e=c}if(e.length!==o)throw Error("Field.fromBytes: expected "+o+" bytes, got "+e.length);let a=n?$i(e):Ri(e);if(s)a=gr(a,i);if(!t){if(!this.isValid(a))throw Error("invalid field element: outside of range 0..ORDER")}return a}invertBatch(e){return Cd(this,e)}cmov(e,t,r){return r?t:e}}function Pg(e,t={}){return new xZ(e,t)}function _Z(e){if(typeof e!=="bigint")throw Error("field order must be bigint");let t=e.toString(2).length;return Math.ceil(t/8)}function fA(e){let t=_Z(e);return t+Math.ceil(t/2)}function EZ(e,t,r=!1){Te(e);let o=e.length,n=_Z(t),i=fA(t);if(o<16||o<i||o>1024)throw Error("expected "+i+"-1024 bytes of input, got "+o);let s=r?$i(e):Ri(e),a=gr(s,t-rr)+rr;return r?Rd(a,n):Bc(a,n)}var yr,rr,Ms,hZ,gZ,yZ,Cae,bZ,Pae,SZ,Lae;var Pd=v(()=>{jc();/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */yr=BigInt(0),rr=BigInt(1),Ms=BigInt(2),hZ=BigInt(3),gZ=BigInt(4),yZ=BigInt(5),Cae=BigInt(7),bZ=BigInt(8),Pae=BigInt(9),SZ=BigInt(16);Lae=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"]});function zd(e,t){let r=t.negate();return e?r:t}function yA(e,t){let r=Cd(e.Fp,t.map((o)=>o.Z));return t.map((o,n)=>e.fromAffine(o.toAffine(r[n])))}function TZ(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw Error("invalid window size, expected [1.."+t+"], got W="+e)}function mA(e,t){TZ(e,t);let r=Math.ceil(t/e)+1,o=2**(e-1),n=2**e,i=Od(e),s=BigInt(e);return{windows:r,windowSize:o,mask:i,maxNumber:n,shiftBy:s}}function kZ(e,t,r){let{windowSize:o,mask:n,maxNumber:i,shiftBy:s}=r,a=Number(e&n),c=e>>s;if(a>o)a-=i,c+=qs;let u=t*o,d=u+Math.abs(a)-1,p=a===0,m=a<0,h=t%2!==0;return{nextN:c,offset:d,isZero:p,isNeg:m,isNegF:h,offsetF:u}}function gA(e){return RZ.get(e)||1}function IZ(e){if(e!==Zc)throw Error("invalid wNAF")}class bA{BASE;ZERO;Fn;bits;constructor(e,t){this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=t}_unsafeLadder(e,t,r=this.ZERO){let o=e;while(t>Zc){if(t&qs)r=r.add(o);o=o.double(),t>>=qs}return r}precomputeWindow(e,t){let{windows:r,windowSize:o}=mA(t,this.bits),n=[],i=e,s=i;for(let a=0;a<r;a++){s=i,n.push(s);for(let c=1;c<o;c++)s=s.add(i),n.push(s);i=s.double()}return n}wNAF(e,t,r){if(!this.Fn.isValid(r))throw Error("invalid scalar");let o=this.ZERO,n=this.BASE,i=mA(e,this.bits);for(let s=0;s<i.windows;s++){let{nextN:a,offset:c,isZero:u,isNeg:d,isNegF:p,offsetF:m}=kZ(r,s,i);if(r=a,u)n=n.add(zd(p,t[m]));else o=o.add(zd(d,t[c]))}return IZ(r),{p:o,f:n}}wNAFUnsafe(e,t,r,o=this.ZERO){let n=mA(e,this.bits);for(let i=0;i<n.windows;i++){if(r===Zc)break;let{nextN:s,offset:a,isZero:c,isNeg:u}=kZ(r,i,n);if(r=s,c)continue;else{let d=t[a];o=o.add(u?d.negate():d)}}return IZ(r),o}getPrecomputes(e,t,r){let o=hA.get(t);if(!o){if(o=this.precomputeWindow(t,e),e!==1){if(typeof r==="function")o=r(o);hA.set(t,o)}}return o}cached(e,t,r){let o=gA(e);return this.wNAF(o,this.getPrecomputes(o,e,r),t)}unsafe(e,t,r,o){let n=gA(e);if(n===1)return this._unsafeLadder(e,t,o);return this.wNAFUnsafe(n,this.getPrecomputes(n,e,r),t,o)}createCache(e,t){TZ(t,this.bits),RZ.set(e,t),hA.delete(e)}hasCache(e){return gA(e)!==1}}function $Z(e,t,r,o){let n=t,i=e.ZERO,s=e.ZERO;while(r>Zc||o>Zc){if(r&qs)i=i.add(n);if(o&qs)s=s.add(n);n=n.double(),r>>=qs,o>>=qs}return{p1:i,p2:s}}function AZ(e,t,r){if(t){if(t.ORDER!==e)throw Error("Field.ORDER must match order: Fp == p, Fn == n");return pA(t),t}else return Pg(e,{isLE:r})}function OZ(e,t,r={},o){if(o===void 0)o=e==="edwards";if(!t||typeof t!=="object")throw Error(`expected valid ${e} CURVE object`);for(let c of["p","n","h"]){let u=t[c];if(!(typeof u==="bigint"&&u>Zc))throw Error(`CURVE.${c} must be positive bigint`)}let n=AZ(t.p,r.Fp,o),i=AZ(t.n,r.Fn,o),a=["Gx","Gy","a",e==="weierstrass"?"b":"d"];for(let c of a)if(!n.isValid(t[c]))throw Error(`CURVE.${c} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:n,Fn:i}}function zg(e,t){return function(o){let n=e(o);return{secretKey:n,publicKey:t(n)}}}var Zc,qs,hA,RZ;var SA=v(()=>{jc();Pd();/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */Zc=BigInt(0),qs=BigInt(1);hA=new WeakMap,RZ=new WeakMap});function Zae(e){return Us(e,{adjustScalarBytes:"function",powPminus2:"function"}),Object.freeze({...e})}function CZ(e){let t=Zae(e),{P:r,type:o,adjustScalarBytes:n,powPminus2:i,randomBytes:s}=t,a=o==="x25519";if(!a&&o!=="x448")throw Error("invalid type");let c=s||Ai,u=a?255:448,d=a?32:56,p=a?BigInt(9):BigInt(5),m=a?BigInt(121665):BigInt(39081),h=a?Ng**BigInt(254):Ng**BigInt(447),b=a?BigInt(8)*Ng**BigInt(251)-Uc:BigInt(4)*Ng**BigInt(445)-Uc,y=h+b+Uc,S=(k)=>gr(k,r),x=_(p);function _(k){return Rd(S(k),d)}function A(k){let T=Cg(Te(k,d,"uCoordinate"));if(a)T[31]&=127;return S($i(T))}function O(k){return $i(n(Cg(Te(k,d,"scalar"))))}function L(k,T){let I=ee(A(T),O(k));if(I===Nd)throw Error("invalid private or public key received");return _(I)}function z(k){return L(k,x)}let H=z,P=L;function W(k,T,I){let q=S(k*(T-I));return T=S(T-q),I=S(I+q),{x_2:T,x_3:I}}function ee(k,T){$d("u",k,Nd,r),$d("scalar",T,h,y);let I=T,q=k,N=Uc,J=Nd,G=k,re=Uc,ae=Nd;for(let be=BigInt(u-1);be>=Nd;be--){let ve=I>>be&Uc;ae^=ve,{x_2:N,x_3:G}=W(ae,N,G),{x_2:J,x_3:re}=W(ae,J,re),ae=ve;let Ae=N+J,Ie=S(Ae*Ae),we=N-J,Ue=S(we*we),De=Ie-Ue,Qe=G+re,St=G-re,Tt=S(St*Ae),Dt=S(Qe*we),lt=Tt+Dt,$r=Tt-Dt;G=S(lt*lt),re=S(q*S($r*$r)),N=S(Ie*Ue),J=S(De*(Ie+S(m*De)))}({x_2:N,x_3:G}=W(ae,N,G)),{x_2:J,x_3:re}=W(ae,J,re);let me=i(J);return S(N*me)}let j={secretKey:d,publicKey:d,seed:d},R=(k=c(d))=>(Te(k,j.seed,"seed"),k),B={randomSecretKey:R};return Object.freeze({keygen:zg(R,H),getSharedSecret:P,getPublicKey:H,scalarMult:L,scalarMultBase:z,utils:B,GuBytes:x.slice(),lengths:j})}var Nd,Uc,Ng;var PZ=v(()=>{jc();SA();Pd();/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */Nd=BigInt(0),Uc=BigInt(1),Ng=BigInt(2)});class vA{oHash;iHash;blockLen;outputLen;finished=!1;destroyed=!1;constructor(e,t){if(Xr(e),Te(t,void 0,"key"),this.iHash=e.create(),typeof this.iHash.update!=="function")throw Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let r=this.blockLen,o=new Uint8Array(r);o.set(t.length>r?e.create().update(t).digest():t);for(let n=0;n<o.length;n++)o[n]^=54;this.iHash.update(o),this.oHash=e.create();for(let n=0;n<o.length;n++)o[n]^=106;this.oHash.update(o),kr(o)}update(e){return Io(this),this.iHash.update(e),this}digestInto(e){Io(this),Te(e,this.outputLen,"output"),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||=Object.create(Object.getPrototypeOf(this),{});let{oHash:t,iHash:r,finished:o,destroyed:n,blockLen:i,outputLen:s}=this;return e=e,e.finished=o,e.destroyed=n,e.blockLen=i,e.outputLen=s,e.oHash=t._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}var Mc=(e,t,r)=>new vA(e,t).update(r).digest();var wA=v(()=>{jr();Mc.create=(e,t)=>new vA(e,t)});function Uae(e,t,r){let[[o,n],[i,s]]=t,a=zZ(s*e,r),c=zZ(-n*e,r),u=e-a*o-c*i,d=-a*n-c*s,p=u<Ao,m=d<Ao;if(p)u=-u;if(m)d=-d;let h=Od(Math.ceil(lA(r)/2))+qc;if(u<Ao||u>=h||d<Ao||d>=h)throw Error("splitScalar (endomorphism): failed, k="+e);return{k1neg:p,k1:u,k2neg:m,k2:d}}function _A(e){if(!["compact","recovered","der"].includes(e))throw Error('Signature format must be "compact", "recovered", or "der"');return e}function xA(e,t){let r={};for(let o of Object.keys(t))r[o]=e[o]===void 0?t[o]:e[o];if(Ad(r.lowS,"lowS"),Ad(r.prehash,"prehash"),r.format!==void 0)_A(r.format);return r}function EA(e,t={}){let r=OZ("weierstrass",e,t),{Fp:o,Fn:n}=r,i=r.CURVE,{h:s,n:a}=i;Us(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});let{endo:c}=t;if(c){if(!o.is0(i.a)||typeof c.beta!=="bigint"||!Array.isArray(c.basises))throw Error('invalid endo: expected "beta": bigint and "basises": array')}let u=BZ(o,n);function d(){if(!o.isOdd)throw Error("compression is not supported: Field does not have .isOdd()")}function p(R,B,k){let{x:T,y:I}=B.toAffine(),q=o.toBytes(T);if(Ad(k,"isCompressed"),k){d();let N=!o.isOdd(I);return kt(LZ(N),q)}else return kt(Uint8Array.of(4),q,o.toBytes(I))}function m(R){Te(R,void 0,"Point");let{publicKey:B,publicKeyUncompressed:k}=u,T=R.length,I=R[0],q=R.subarray(1);if(T===B&&(I===2||I===3)){let N=o.fromBytes(q);if(!o.isValid(N))throw Error("bad point: is not on curve, wrong x");let J=y(N),G;try{G=o.sqrt(J)}catch(me){let be=me instanceof Error?": "+me.message:"";throw Error("bad point: is not on curve, sqrt error"+be)}d();let re=o.isOdd(G);if((I&1)===1!==re)G=o.neg(G);return{x:N,y:G}}else if(T===k&&I===4){let N=o.BYTES,J=o.fromBytes(q.subarray(0,N)),G=o.fromBytes(q.subarray(N,N*2));if(!S(J,G))throw Error("bad point: is not on curve");return{x:J,y:G}}else throw Error(`bad point: got length ${T}, expected compressed=${B} or uncompressed=${k}`)}let h=t.toBytes||p,b=t.fromBytes||m;function y(R){let B=o.sqr(R),k=o.mul(B,R);return o.add(o.add(k,o.mul(R,i.a)),i.b)}function S(R,B){let k=o.sqr(B),T=y(R);return o.eql(k,T)}if(!S(i.Gx,i.Gy))throw Error("bad curve params: generator point");let x=o.mul(o.pow(i.a,Dg),Mae),_=o.mul(o.sqr(i.b),BigInt(27));if(o.is0(o.add(x,_)))throw Error("bad curve params: a or b");function A(R,B,k=!1){if(!o.isValid(B)||k&&o.is0(B))throw Error(`bad point coordinate ${R}`);return B}function O(R){if(!(R instanceof W))throw Error("Weierstrass Point expected")}function L(R){if(!c||!c.basises)throw Error("no endo");return Uae(R,c.basises,n.ORDER)}let z=uA((R,B)=>{let{X:k,Y:T,Z:I}=R;if(o.eql(I,o.ONE))return{x:k,y:T};let q=R.is0();if(B==null)B=q?o.ONE:o.inv(I);let N=o.mul(k,B),J=o.mul(T,B),G=o.mul(I,B);if(q)return{x:o.ZERO,y:o.ZERO};if(!o.eql(G,o.ONE))throw Error("invZ was invalid");return{x:N,y:J}}),H=uA((R)=>{if(R.is0()){if(t.allowInfinityPoint&&!o.is0(R.Y))return;throw Error("bad point: ZERO")}let{x:B,y:k}=R.toAffine();if(!o.isValid(B)||!o.isValid(k))throw Error("bad point: x or y not field elements");if(!S(B,k))throw Error("bad point: equation left != right");if(!R.isTorsionFree())throw Error("bad point: not in prime-order subgroup");return!0});function P(R,B,k,T,I){return k=new W(o.mul(k.X,R),k.Y,k.Z),B=zd(T,B),k=zd(I,k),B.add(k)}class W{static BASE=new W(i.Gx,i.Gy,o.ONE);static ZERO=new W(o.ZERO,o.ONE,o.ZERO);static Fp=o;static Fn=n;X;Y;Z;constructor(R,B,k){this.X=A("x",R),this.Y=A("y",B,!0),this.Z=A("z",k),Object.freeze(this)}static CURVE(){return i}static fromAffine(R){let{x:B,y:k}=R||{};if(!R||!o.isValid(B)||!o.isValid(k))throw Error("invalid affine point");if(R instanceof W)throw Error("projective point not allowed");if(o.is0(B)&&o.is0(k))return W.ZERO;return new W(B,k,o.ONE)}static fromBytes(R){let B=W.fromAffine(b(Te(R,void 0,"point")));return B.assertValidity(),B}static fromHex(R){return W.fromBytes(Zs(R))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(R=8,B=!0){if(j.createCache(this,R),!B)this.multiply(Dg);return this}assertValidity(){H(this)}hasEvenY(){let{y:R}=this.toAffine();if(!o.isOdd)throw Error("Field doesn't support isOdd");return!o.isOdd(R)}equals(R){O(R);let{X:B,Y:k,Z:T}=this,{X:I,Y:q,Z:N}=R,J=o.eql(o.mul(B,N),o.mul(I,T)),G=o.eql(o.mul(k,N),o.mul(q,T));return J&&G}negate(){return new W(this.X,o.neg(this.Y),this.Z)}double(){let{a:R,b:B}=i,k=o.mul(B,Dg),{X:T,Y:I,Z:q}=this,N=o.ZERO,J=o.ZERO,G=o.ZERO,re=o.mul(T,T),ae=o.mul(I,I),me=o.mul(q,q),be=o.mul(T,I);return be=o.add(be,be),G=o.mul(T,q),G=o.add(G,G),N=o.mul(R,G),J=o.mul(k,me),J=o.add(N,J),N=o.sub(ae,J),J=o.add(ae,J),J=o.mul(N,J),N=o.mul(be,N),G=o.mul(k,G),me=o.mul(R,me),be=o.sub(re,me),be=o.mul(R,be),be=o.add(be,G),G=o.add(re,re),re=o.add(G,re),re=o.add(re,me),re=o.mul(re,be),J=o.add(J,re),me=o.mul(I,q),me=o.add(me,me),re=o.mul(me,be),N=o.sub(N,re),G=o.mul(me,ae),G=o.add(G,G),G=o.add(G,G),new W(N,J,G)}add(R){O(R);let{X:B,Y:k,Z:T}=this,{X:I,Y:q,Z:N}=R,J=o.ZERO,G=o.ZERO,re=o.ZERO,ae=i.a,me=o.mul(i.b,Dg),be=o.mul(B,I),ve=o.mul(k,q),Ae=o.mul(T,N),Ie=o.add(B,k),we=o.add(I,q);Ie=o.mul(Ie,we),we=o.add(be,ve),Ie=o.sub(Ie,we),we=o.add(B,T);let Ue=o.add(I,N);return we=o.mul(we,Ue),Ue=o.add(be,Ae),we=o.sub(we,Ue),Ue=o.add(k,T),J=o.add(q,N),Ue=o.mul(Ue,J),J=o.add(ve,Ae),Ue=o.sub(Ue,J),re=o.mul(ae,we),J=o.mul(me,Ae),re=o.add(J,re),J=o.sub(ve,re),re=o.add(ve,re),G=o.mul(J,re),ve=o.add(be,be),ve=o.add(ve,be),Ae=o.mul(ae,Ae),we=o.mul(me,we),ve=o.add(ve,Ae),Ae=o.sub(be,Ae),Ae=o.mul(ae,Ae),we=o.add(we,Ae),be=o.mul(ve,we),G=o.add(G,be),be=o.mul(Ue,we),J=o.mul(Ie,J),J=o.sub(J,be),be=o.mul(Ie,ve),re=o.mul(Ue,re),re=o.add(re,be),new W(J,G,re)}subtract(R){return this.add(R.negate())}is0(){return this.equals(W.ZERO)}multiply(R){let{endo:B}=t;if(!n.isValidNot0(R))throw Error("invalid scalar: out of range");let k,T,I=(q)=>j.cached(this,q,(N)=>yA(W,N));if(B){let{k1neg:q,k1:N,k2neg:J,k2:G}=L(R),{p:re,f:ae}=I(N),{p:me,f:be}=I(G);T=ae.add(be),k=P(B.beta,re,me,q,J)}else{let{p:q,f:N}=I(R);k=q,T=N}return yA(W,[k,T])[0]}multiplyUnsafe(R){let{endo:B}=t,k=this;if(!n.isValid(R))throw Error("invalid scalar: out of range");if(R===Ao||k.is0())return W.ZERO;if(R===qc)return k;if(j.hasCache(this))return this.multiply(R);if(B){let{k1neg:T,k1:I,k2neg:q,k2:N}=L(R),{p1:J,p2:G}=$Z(W,k,I,N);return P(B.beta,J,G,T,q)}else return j.unsafe(k,R)}toAffine(R){return z(this,R)}isTorsionFree(){let{isTorsionFree:R}=t;if(s===qc)return!0;if(R)return R(W,this);return j.unsafe(this,a).is0()}clearCofactor(){let{clearCofactor:R}=t;if(s===qc)return this;if(R)return R(W,this);return this.multiplyUnsafe(s)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}toBytes(R=!0){return Ad(R,"isCompressed"),this.assertValidity(),h(W,this,R)}toHex(R=!0){return js(this.toBytes(R))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let ee=n.BITS,j=new bA(W,t.endo?Math.ceil(ee/2):ee);return W.BASE.precompute(8),W}function LZ(e){return Uint8Array.of(e?2:3)}function BZ(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function qae(e,t={}){let{Fn:r}=e,o=t.randomBytes||Ai,n=Object.assign(BZ(e.Fp,r),{seed:fA(r.ORDER)});function i(h){try{let b=r.fromBytes(h);return r.isValidNot0(b)}catch(b){return!1}}function s(h,b){let{publicKey:y,publicKeyUncompressed:S}=n;try{let x=h.length;if(b===!0&&x!==y)return!1;if(b===!1&&x!==S)return!1;return!!e.fromBytes(h)}catch(x){return!1}}function a(h=o(n.seed)){return EZ(Te(h,n.seed,"seed"),r.ORDER)}function c(h,b=!0){return e.BASE.multiply(r.fromBytes(h)).toBytes(b)}function u(h){let{secretKey:b,publicKey:y,publicKeyUncompressed:S}=n;if(!Dc(h))return;if("_lengths"in r&&r._lengths||b===y)return;let x=Te(h,void 0,"key").length;return x===y||x===S}function d(h,b,y=!0){if(u(h)===!0)throw Error("first arg must be private key");if(u(b)===!1)throw Error("second arg must be public key");let S=r.fromBytes(h);return e.fromBytes(b).multiply(S).toBytes(y)}let p={isValidSecretKey:i,isValidPublicKey:s,randomSecretKey:a},m=zg(a,c);return Object.freeze({getPublicKey:c,getSharedSecret:d,keygen:m,Point:e,utils:p,lengths:n})}function kA(e,t,r={}){Xr(t),Us(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),r=Object.assign({},r);let o=r.randomBytes||Ai,n=r.hmac||((k,T)=>Mc(t,k,T)),{Fp:i,Fn:s}=e,{ORDER:a,BITS:c}=s,{keygen:u,getPublicKey:d,getSharedSecret:p,utils:m,lengths:h}=qae(e,r),b={prehash:!0,lowS:typeof r.lowS==="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},y=a*DZ<i.ORDER;function S(k){let T=a>>qc;return k>T}function x(k,T){if(!s.isValidNot0(T))throw Error(`invalid signature ${k}: out of range 1..Point.Fn.ORDER`);return T}function _(){if(y)throw Error('"recovered" sig type is not supported for cofactor >2 curves')}function A(k,T){_A(T);let I=h.signature,q=T==="compact"?I:T==="recovered"?I+1:void 0;return Te(k,q)}class O{r;s;recovery;constructor(k,T,I){if(this.r=x("r",k),this.s=x("s",T),I!=null){if(_(),![0,1,2,3].includes(I))throw Error("invalid recovery id");this.recovery=I}Object.freeze(this)}static fromBytes(k,T=b.format){A(k,T);let I;if(T==="der"){let{r:G,s:re}=Ci.toSig(Te(k));return new O(G,re)}if(T==="recovered")I=k[0],T="compact",k=k.subarray(1);let q=h.signature/2,N=k.subarray(0,q),J=k.subarray(q,q*2);return new O(s.fromBytes(N),s.fromBytes(J),I)}static fromHex(k,T){return this.fromBytes(Zs(k),T)}assertRecovery(){let{recovery:k}=this;if(k==null)throw Error("invalid recovery id: must be present");return k}addRecoveryBit(k){return new O(this.r,this.s,k)}recoverPublicKey(k){let{r:T,s:I}=this,q=this.assertRecovery(),N=q===2||q===3?T+a:T;if(!i.isValid(N))throw Error("invalid recovery id: sig.r+curve.n != R.x");let J=i.toBytes(N),G=e.fromBytes(kt(LZ((q&1)===0),J)),re=s.inv(N),ae=z(Te(k,void 0,"msgHash")),me=s.create(-ae*re),be=s.create(I*re),ve=e.BASE.multiplyUnsafe(me).add(G.multiplyUnsafe(be));if(ve.is0())throw Error("invalid recovery: point at infinify");return ve.assertValidity(),ve}hasHighS(){return S(this.s)}toBytes(k=b.format){if(_A(k),k==="der")return Zs(Ci.hexFromSig(this));let{r:T,s:I}=this,q=s.toBytes(T),N=s.toBytes(I);if(k==="recovered")return _(),kt(Uint8Array.of(this.assertRecovery()),q,N);return kt(q,N)}toHex(k){return js(this.toBytes(k))}}let L=r.bits2int||function(T){if(T.length>8192)throw Error("input is too large");let I=Ri(T),q=T.length*8-c;return q>0?I>>BigInt(q):I},z=r.bits2int_modN||function(T){return s.create(L(T))},H=Od(c);function P(k){return $d("num < 2^"+c,k,Ao,H),s.toBytes(k)}function W(k,T){return Te(k,void 0,"message"),T?Te(t(k),void 0,"prehashed message"):k}function ee(k,T,I){let{lowS:q,prehash:N,extraEntropy:J}=xA(I,b);k=W(k,N);let G=z(k),re=s.fromBytes(T);if(!s.isValidNot0(re))throw Error("invalid private key");let ae=[P(re),P(G)];if(J!=null&&J!==!1){let Ae=J===!0?o(h.secretKey):J;ae.push(Te(Ae,void 0,"extraEntropy"))}let me=kt(...ae),be=G;function ve(Ae){let Ie=L(Ae);if(!s.isValidNot0(Ie))return;let we=s.inv(Ie),Ue=e.BASE.multiply(Ie).toAffine(),De=s.create(Ue.x);if(De===Ao)return;let Qe=s.create(we*s.create(be+De*re));if(Qe===Ao)return;let St=(Ue.x===De?0:2)|Number(Ue.y&qc),Tt=Qe;if(q&&S(Qe))Tt=s.neg(Qe),St^=1;return new O(De,Tt,y?void 0:St)}return{seed:me,k2sig:ve}}function j(k,T,I={}){let{seed:q,k2sig:N}=ee(k,T,I);return pZ(t.outputLen,s.BYTES,n)(q,N).toBytes(I.format)}function R(k,T,I,q={}){let{lowS:N,prehash:J,format:G}=xA(q,b);if(I=Te(I,void 0,"publicKey"),T=W(T,J),!Dc(k)){let re=k instanceof O?", use sig.toBytes()":"";throw Error("verify expects Uint8Array signature"+re)}A(k,G);try{let re=O.fromBytes(k,G),ae=e.fromBytes(I);if(N&&re.hasHighS())return!1;let{r:me,s:be}=re,ve=z(T),Ae=s.inv(be),Ie=s.create(ve*Ae),we=s.create(me*Ae),Ue=e.BASE.multiplyUnsafe(Ie).add(ae.multiplyUnsafe(we));if(Ue.is0())return!1;return s.create(Ue.x)===me}catch(re){return!1}}function B(k,T,I={}){let{prehash:q}=xA(I,b);return T=W(T,q),O.fromBytes(k,"recovered").recoverPublicKey(T).toBytes()}return Object.freeze({keygen:u,getPublicKey:d,getSharedSecret:p,utils:m,lengths:h,Point:e,sign:j,verify:R,recoverPublicKey:B,Signature:O,hash:t})}var zZ=(e,t)=>(e+(e>=0?t:-t)/DZ)/t,NZ,Ci,Ao,qc,DZ,Dg,Mae;var jZ=v(()=>{wA();jr();jc();SA();Pd();/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */NZ=class NZ extends Error{constructor(e=""){super(e)}};Ci={Err:NZ,_tlv:{encode:(e,t)=>{let{Err:r}=Ci;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length&1)throw new r("tlv.encode: unpadded data");let o=t.length/2,n=Td(o);if(n.length/2&128)throw new r("tlv.encode: long form length too big");let i=o>127?Td(n.length/2|128):"";return Td(e)+i+n+t},decode(e,t){let{Err:r}=Ci,o=0;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length<2||t[o++]!==e)throw new r("tlv.decode: wrong tlv");let n=t[o++],i=!!(n&128),s=0;if(!i)s=n;else{let c=n&127;if(!c)throw new r("tlv.decode(long): indefinite length not supported");if(c>4)throw new r("tlv.decode(long): byte length is too big");let u=t.subarray(o,o+c);if(u.length!==c)throw new r("tlv.decode: length bytes not complete");if(u[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let d of u)s=s<<8|d;if(o+=c,s<128)throw new r("tlv.decode(long): not minimal encoding")}let a=t.subarray(o,o+s);if(a.length!==s)throw new r("tlv.decode: wrong value length");return{v:a,l:t.subarray(o+s)}}},_int:{encode(e){let{Err:t}=Ci;if(e<Ao)throw new t("integer: negative integers are not allowed");let r=Td(e);if(Number.parseInt(r[0],16)&8)r="00"+r;if(r.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return r},decode(e){let{Err:t}=Ci;if(e[0]&128)throw new t("invalid signature integer: negative");if(e[0]===0&&!(e[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return Ri(e)}},toSig(e){let{Err:t,_int:r,_tlv:o}=Ci,n=Te(e,void 0,"signature"),{v:i,l:s}=o.decode(48,n);if(s.length)throw new t("invalid signature: left bytes after parsing");let{v:a,l:c}=o.decode(2,i),{v:u,l:d}=o.decode(2,c);if(d.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(u)}},hexFromSig(e){let{_tlv:t,_int:r}=Ci,o=t.encode(2,r.encode(e.r)),n=t.encode(2,r.encode(e.s)),i=o+n;return t.encode(48,i)}},Ao=BigInt(0),qc=BigInt(1),DZ=BigInt(2),Dg=BigInt(3),Mae=BigInt(4)});function ZZ(e,t,r){return e&t^~e&r}function UZ(e,t,r){return e&t^e&r^t&r}class Lg{blockLen;outputLen;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,t,r,o){this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=o,this.buffer=new Uint8Array(e),this.view=$g(this.buffer)}update(e){Io(this),Te(e);let{view:t,buffer:r,blockLen:o}=this,n=e.length;for(let i=0;i<n;){let s=Math.min(o-this.pos,n-i);if(s===o){let a=$g(e);for(;o<=n-i;i+=o)this.process(a,i);continue}if(r.set(e.subarray(i,i+s),this.pos),this.pos+=s,i+=s,this.pos===o)this.process(t,0),this.pos=0}return this.length+=e.length,this.roundClean(),this}digestInto(e){Io(this),Tg(e,this),this.finished=!0;let{buffer:t,view:r,blockLen:o,isLE:n}=this,{pos:i}=this;if(t[i++]=128,kr(this.buffer.subarray(i)),this.padOffset>o-i)this.process(r,0),i=0;for(let d=i;d<o;d++)t[d]=0;r.setBigUint64(o-8,BigInt(this.length*8),n),this.process(r,0);let s=$g(e),a=this.outputLen;if(a%4)throw Error("_sha2: outputLen must be aligned to 32bit");let c=a/4,u=this.get();if(c>u.length)throw Error("_sha2: outputLen bigger than state");for(let d=0;d<c;d++)s.setUint32(4*d,u[d],n)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){e||=new this.constructor,e.set(...this.get());let{blockLen:t,buffer:r,length:o,finished:n,destroyed:i,pos:s}=this;if(e.destroyed=i,e.finished=n,e.length=o,e.pos=s,o%t)e.buffer.set(r);return e}clone(){return this._cloneInto()}}var To,Jt;var MZ=v(()=>{jr();To=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Jt=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428])});function Fae(e,t=!1){if(t)return{h:Number(e&Bg),l:Number(e>>qZ&Bg)};return{h:Number(e>>qZ&Bg)|0,l:Number(e&Bg)|0}}function jg(e,t=!1){let r=e.length,o=new Uint32Array(r),n=new Uint32Array(r);for(let i=0;i<r;i++){let{h:s,l:a}=Fae(e[i],t);[o[i],n[i]]=[s,a]}return[o,n]}function Kn(e,t,r,o){let n=(t>>>0)+(o>>>0);return{h:e+r+(n/4294967296|0)|0,l:n|0}}var Bg,qZ,IA=(e,t,r)=>e>>>r,AA=(e,t,r)=>e<<32-r|t>>>r,Fs=(e,t,r)=>e>>>r|t<<32-r,Ks=(e,t,r)=>e<<32-r|t>>>r,Dd=(e,t,r)=>e<<64-r|t>>>r-32,Ld=(e,t,r)=>e>>>r-32|t<<64-r,FZ=(e,t,r)=>e<<r|t>>>32-r,KZ=(e,t,r)=>t<<r|e>>>32-r,HZ=(e,t,r)=>t<<r-32|e>>>64-r,JZ=(e,t,r)=>e<<r-32|t>>>64-r,VZ=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),WZ=(e,t,r,o)=>t+r+o+(e/4294967296|0)|0,GZ=(e,t,r,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(o>>>0),QZ=(e,t,r,o,n)=>t+r+o+n+(e/4294967296|0)|0,YZ=(e,t,r,o,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(o>>>0)+(n>>>0),XZ=(e,t,r,o,n,i)=>t+r+o+n+i+(e/4294967296|0)|0;var TA=v(()=>{Bg=BigInt(4294967295),qZ=BigInt(32)});var Hae,Pi,eU,tU,rU,Jae,Vae,zi,Ni,nU,oU,Zg,iU;var RA=v(()=>{MZ();TA();jr();Hae=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Pi=new Uint32Array(64);eU=class eU extends Lg{constructor(e){super(64,e,8,!1)}get(){let{A:e,B:t,C:r,D:o,E:n,F:i,G:s,H:a}=this;return[e,t,r,o,n,i,s,a]}set(e,t,r,o,n,i,s,a){this.A=e|0,this.B=t|0,this.C=r|0,this.D=o|0,this.E=n|0,this.F=i|0,this.G=s|0,this.H=a|0}process(e,t){for(let d=0;d<16;d++,t+=4)Pi[d]=e.getUint32(t,!1);for(let d=16;d<64;d++){let p=Pi[d-15],m=Pi[d-2],h=yn(p,7)^yn(p,18)^p>>>3,b=yn(m,17)^yn(m,19)^m>>>10;Pi[d]=b+Pi[d-7]+h+Pi[d-16]|0}let{A:r,B:o,C:n,D:i,E:s,F:a,G:c,H:u}=this;for(let d=0;d<64;d++){let p=yn(s,6)^yn(s,11)^yn(s,25),m=u+p+ZZ(s,a,c)+Hae[d]+Pi[d]|0,b=(yn(r,2)^yn(r,13)^yn(r,22))+UZ(r,o,n)|0;u=c,c=a,a=s,s=i+m|0,i=n,n=o,o=r,r=m+b|0}r=r+this.A|0,o=o+this.B|0,n=n+this.C|0,i=i+this.D|0,s=s+this.E|0,a=a+this.F|0,c=c+this.G|0,u=u+this.H|0,this.set(r,o,n,i,s,a,c,u)}roundClean(){kr(Pi)}destroy(){this.set(0,0,0,0,0,0,0,0),kr(this.buffer)}};tU=class tU extends eU{A=To[0]|0;B=To[1]|0;C=To[2]|0;D=To[3]|0;E=To[4]|0;F=To[5]|0;G=To[6]|0;H=To[7]|0;constructor(){super(32)}};rU=(()=>jg(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map((e)=>BigInt(e))))(),Jae=(()=>rU[0])(),Vae=(()=>rU[1])(),zi=new Uint32Array(80),Ni=new Uint32Array(80);nU=class nU extends Lg{constructor(e){super(128,e,16,!1)}get(){let{Ah:e,Al:t,Bh:r,Bl:o,Ch:n,Cl:i,Dh:s,Dl:a,Eh:c,El:u,Fh:d,Fl:p,Gh:m,Gl:h,Hh:b,Hl:y}=this;return[e,t,r,o,n,i,s,a,c,u,d,p,m,h,b,y]}set(e,t,r,o,n,i,s,a,c,u,d,p,m,h,b,y){this.Ah=e|0,this.Al=t|0,this.Bh=r|0,this.Bl=o|0,this.Ch=n|0,this.Cl=i|0,this.Dh=s|0,this.Dl=a|0,this.Eh=c|0,this.El=u|0,this.Fh=d|0,this.Fl=p|0,this.Gh=m|0,this.Gl=h|0,this.Hh=b|0,this.Hl=y|0}process(e,t){for(let _=0;_<16;_++,t+=4)zi[_]=e.getUint32(t),Ni[_]=e.getUint32(t+=4);for(let _=16;_<80;_++){let A=zi[_-15]|0,O=Ni[_-15]|0,L=Fs(A,O,1)^Fs(A,O,8)^IA(A,O,7),z=Ks(A,O,1)^Ks(A,O,8)^AA(A,O,7),H=zi[_-2]|0,P=Ni[_-2]|0,W=Fs(H,P,19)^Dd(H,P,61)^IA(H,P,6),ee=Ks(H,P,19)^Ld(H,P,61)^AA(H,P,6),j=GZ(z,ee,Ni[_-7],Ni[_-16]),R=QZ(j,L,W,zi[_-7],zi[_-16]);zi[_]=R|0,Ni[_]=j|0}let{Ah:r,Al:o,Bh:n,Bl:i,Ch:s,Cl:a,Dh:c,Dl:u,Eh:d,El:p,Fh:m,Fl:h,Gh:b,Gl:y,Hh:S,Hl:x}=this;for(let _=0;_<80;_++){let A=Fs(d,p,14)^Fs(d,p,18)^Dd(d,p,41),O=Ks(d,p,14)^Ks(d,p,18)^Ld(d,p,41),L=d&m^~d&b,z=p&h^~p&y,H=YZ(x,O,z,Vae[_],Ni[_]),P=XZ(H,S,A,L,Jae[_],zi[_]),W=H|0,ee=Fs(r,o,28)^Dd(r,o,34)^Dd(r,o,39),j=Ks(r,o,28)^Ld(r,o,34)^Ld(r,o,39),R=r&n^r&s^n&s,B=o&i^o&a^i&a;S=b|0,x=y|0,b=m|0,y=h|0,m=d|0,h=p|0,{h:d,l:p}=Kn(c|0,u|0,P|0,W|0),c=s|0,u=a|0,s=n|0,a=i|0,n=r|0,i=o|0;let k=VZ(W,j,B);r=WZ(k,P,ee,R),o=k|0}({h:r,l:o}=Kn(this.Ah|0,this.Al|0,r|0,o|0)),{h:n,l:i}=Kn(this.Bh|0,this.Bl|0,n|0,i|0),{h:s,l:a}=Kn(this.Ch|0,this.Cl|0,s|0,a|0),{h:c,l:u}=Kn(this.Dh|0,this.Dl|0,c|0,u|0),{h:d,l:p}=Kn(this.Eh|0,this.El|0,d|0,p|0),{h:m,l:h}=Kn(this.Fh|0,this.Fl|0,m|0,h|0),{h:b,l:y}=Kn(this.Gh|0,this.Gl|0,b|0,y|0),{h:S,l:x}=Kn(this.Hh|0,this.Hl|0,S|0,x|0),this.set(r,o,n,i,s,a,c,u,d,p,m,h,b,y,S,x)}roundClean(){kr(zi,Ni)}destroy(){kr(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};oU=class oU extends nU{Ah=Jt[0]|0;Al=Jt[1]|0;Bh=Jt[2]|0;Bl=Jt[3]|0;Ch=Jt[4]|0;Cl=Jt[5]|0;Dh=Jt[6]|0;Dl=Jt[7]|0;Eh=Jt[8]|0;El=Jt[9]|0;Fh=Jt[10]|0;Fl=Jt[11]|0;Gh=Jt[12]|0;Gl=Jt[13]|0;Hh=Jt[14]|0;Hl=Jt[15]|0;constructor(){super(48)}};Zg=Lc(()=>new tU,Ti(1)),iU=Lc(()=>new oU,Ti(2))});function Yae(e){let t=BigInt(10),r=BigInt(20),o=BigInt(40),n=BigInt(80),i=aU,a=e*e%i*e%i,c=en(a,sU,i)*a%i,u=en(c,Wae,i)*e%i,d=en(u,Qae,i)*u%i,p=en(d,t,i)*d%i,m=en(p,r,i)*p%i,h=en(m,o,i)*m%i,b=en(h,n,i)*h%i,y=en(b,n,i)*h%i,S=en(y,t,i)*d%i;return{pow_p_5_8:en(S,sU,i)*e%i,b2:a}}function Xae(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var Wae,sU,Gae,Qae,FOe,aU,cU;var lU=v(()=>{Pd();PZ();/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */Wae=BigInt(1),sU=BigInt(2),Gae=BigInt(3),Qae=BigInt(5),FOe=BigInt(8),aU=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed");cU=(()=>{let e=aU;return CZ({P:e,type:"x25519",powPminus2:(t)=>{let{pow_p_5_8:r,b2:o}=Yae(t);return gr(en(r,Gae,e)*o,e)},adjustScalarBytes:Xae})})()});var ece,tce,rce,$A,nce,uU;var dU=v(()=>{RA();jZ();/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ece=(()=>({p:BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),h:BigInt(1),a:BigInt("0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc"),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")}))(),tce=(()=>({p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff"),n:BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973"),h:BigInt(1),a:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000fffffffc"),b:BigInt("0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef"),Gx:BigInt("0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7"),Gy:BigInt("0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f")}))(),rce=EA(ece),$A=kA(rce,Zg),nce=EA(tce),uU=kA(nce,iU)});function fU(e,t,r){if(Xr(e),r===void 0)r=new Uint8Array(e.outputLen);return Mc(e,r,t)}function mU(e,t,r,o=32){Xr(e),Zt(o,"length");let n=e.outputLen;if(o>255*n)throw Error("Length must be <= 255*HashLen");let i=Math.ceil(o/n);if(r===void 0)r=pU;else Te(r,void 0,"info");let s=new Uint8Array(i*n),a=Mc.create(e,t),c=a._cloneInto(),u=new Uint8Array(a.outputLen);for(let d=0;d<i;d++)OA[0]=d+1,c.update(d===0?pU:u).update(r).update(OA).digestInto(u),s.set(u,n*d),a._cloneInto(c);return a.destroy(),c.destroy(),kr(u,OA),s.slice(0,o)}var OA,pU;var hU=v(()=>{wA();jr();OA=Uint8Array.of(0),pU=Uint8Array.of()});function dce(e,t=24){let r=new Uint32Array(10);for(let o=24-t;o<24;o++){for(let s=0;s<10;s++)r[s]=e[s]^e[s+10]^e[s+20]^e[s+30]^e[s+40];for(let s=0;s<10;s+=2){let a=(s+8)%10,c=(s+2)%10,u=r[c],d=r[c+1],p=gU(u,d,1)^r[a],m=yU(u,d,1)^r[a+1];for(let h=0;h<50;h+=10)e[s+h]^=p,e[s+h+1]^=m}let n=e[2],i=e[3];for(let s=0;s<24;s++){let a=SU[s],c=gU(n,i,a),u=yU(n,i,a),d=bU[s];n=e[d],i=e[d+1],e[d]=c,e[d+1]=u}for(let s=0;s<50;s+=10){for(let a=0;a<10;a++)r[a]=e[s+a];for(let a=0;a<10;a++)e[s+a]^=~r[(a+2)%10]&r[(a+4)%10]}e[0]^=lce[o],e[1]^=uce[o]}kr(r)}class Ug{state;pos=0;posOut=0;finished=!1;state32;destroyed=!1;blockLen;suffix;outputLen;enableXOF=!1;rounds;constructor(e,t,r,o=!1,n=24){if(this.blockLen=e,this.suffix=t,this.outputLen=r,this.enableXOF=o,this.rounds=n,Zt(r,"outputLen"),!(0<e&&e<200))throw Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=Rg(this.state)}clone(){return this._cloneInto()}keccak(){sA(this.state32),dce(this.state32,this.rounds),sA(this.state32),this.posOut=0,this.pos=0}update(e){Io(this),Te(e);let{blockLen:t,state:r}=this,o=e.length;for(let n=0;n<o;){let i=Math.min(t-this.pos,o-n);for(let s=0;s<i;s++)r[this.pos++]^=e[n++];if(this.pos===t)this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:e,suffix:t,pos:r,blockLen:o}=this;if(e[r]^=t,(t&128)!==0&&r===o-1)this.keccak();e[o-1]^=128,this.keccak()}writeInto(e){Io(this,!1),Te(e),this.finish();let t=this.state,{blockLen:r}=this;for(let o=0,n=e.length;o<n;){if(this.posOut>=r)this.keccak();let i=Math.min(r-this.posOut,n-o);e.set(t.subarray(this.posOut,this.posOut+i),o),this.posOut+=i,o+=i}return e}xofInto(e){if(!this.enableXOF)throw Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return Zt(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Tg(e,this),this.finished)throw Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,kr(this.state)}_cloneInto(e){let{blockLen:t,suffix:r,outputLen:o,rounds:n,enableXOF:i}=this;return e||=new Ug(t,r,o,i,n),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=n,e.suffix=r,e.outputLen=o,e.enableXOF=i,e.destroyed=this.destroyed,e}}var oce,Bd,ice,sce,ace,cce,bU,SU,vU,wU,lce,uce,gU=(e,t,r)=>r>32?HZ(e,t,r):FZ(e,t,r),yU=(e,t,r)=>r>32?JZ(e,t,r):KZ(e,t,r),xU=(e,t,r,o={})=>Lc(()=>new Ug(t,e,r),o),Hs,_U,EU=(e,t,r,o={})=>Lc((n={})=>new Ug(t,e,n.dkLen===void 0?r:n.dkLen,!0),o),kU,Hn;var Mg=v(()=>{TA();jr();oce=BigInt(0),Bd=BigInt(1),ice=BigInt(2),sce=BigInt(7),ace=BigInt(256),cce=BigInt(113),bU=[],SU=[],vU=[];for(let e=0,t=Bd,r=1,o=0;e<24;e++){[r,o]=[o,(2*r+3*o)%5],bU.push(2*(5*o+r)),SU.push((e+1)*(e+2)/2%64);let n=oce;for(let i=0;i<7;i++)if(t=(t<<Bd^(t>>sce)*cce)%ace,t&ice)n^=Bd<<(Bd<<BigInt(i))-Bd;vU.push(n)}wU=jg(vU,!0),lce=wU[0],uce=wU[1];Hs=xU(6,136,32,Ti(8)),_U=xU(6,72,64,Ti(10)),kU=EU(31,168,16,Ti(11)),Hn=EU(31,136,32,Ti(12))});function CA(e){if(!Number.isSafeInteger(e)||e<0||e>4294967295)throw Error("wrong u32 integer:"+e);return e}function AU(e){return CA(e),(e&e-1)===0&&e!==0}function PA(e,t){CA(e);let r=0;for(let o=0;o<t;o++,e>>>=1)r=r<<1|e&1;return r}function TU(e){return CA(e),31-Math.clz32(e)}function IU(e){let t=e.length;if(t<2||!AU(t))throw Error("n must be a power of 2 and greater than 1. Got "+t);let r=TU(t);for(let o=0;o<t;o++){let n=PA(o,r);if(o<n){let i=e[o];e[o]=e[n],e[n]=i}}return e}var zA=(e,t)=>{let{N:r,roots:o,dit:n,invertButterflies:i=!1,skipStages:s=0,brp:a=!0}=t,c=TU(r);if(!AU(r))throw Error("FFT: Polynomial size should be power of two");let u=n!==i;return(d)=>{if(d.length!==r)throw Error("FFT: wrong Polynomial length");if(n&&a)IU(d);for(let p=0,m=1;p<c-s;p++){let h=n?p+1+s:c-p,b=1<<h,y=b>>1,S=r>>h;for(let x=0;x<r;x+=b)for(let _=0,A=m++;_<y;_++){let O=i?n?r-A:A:_*S,L=x+_,z=x+_+y,H=o[O],P=d[z],W=d[L];if(u){let ee=e.mul(P,H);d[L]=e.add(W,ee),d[z]=e.sub(W,ee)}else if(i)d[L]=e.add(P,W),d[z]=e.mul(e.sub(P,W),H);else d[L]=e.add(W,P),d[z]=e.mul(e.sub(W,P),H)}}if(!n&&a)IU(d);return d}};var RU=()=>{};function qg(e,t){if(e.length!==t.length)return!1;let r=0;for(let o=0;o<e.length;o++)r|=e[o]^t[o];return r===0}function $U(e){return Uint8Array.from(e)}function Js(e,...t){let r=(n)=>typeof n==="number"?n:n.bytesLen,o=t.reduce((n,i)=>n+r(i),0);return{bytesLen:o,encode:(n)=>{let i=new Uint8Array(o);for(let s=0,a=0;s<t.length;s++){let c=t[s],u=r(c),d=typeof c==="number"?n[s]:c.encode(n[s]);if(Te(d,u,e),i.set(d,a),typeof c!=="number")d.fill(0);a+=u}return i},decode:(n)=>{Te(n,o,e);let i=[];for(let s of t){let a=r(s),c=n.subarray(0,a);i.push(typeof s==="number"?c:s.decode(c)),n=n.subarray(a)}return i}}}function Fg(e,t){let r=t*e.bytesLen;return{bytesLen:r,encode:(o)=>{if(o.length!==t)throw Error(`vecCoder.encode: wrong length=${o.length}. Expected: ${t}`);let n=new Uint8Array(r);for(let i=0,s=0;i<o.length;i++){let a=e.encode(o[i]);n.set(a,s),a.fill(0),s+=a.length}return n},decode:(o)=>{Te(o,r);let n=[];for(let i=0;i<o.length;i+=e.bytesLen)n.push(e.decode(o.subarray(i,i+e.bytesLen)));return n}}}function Pt(...e){for(let t of e)if(Array.isArray(t))for(let r of t)r.fill(0);else t.fill(0)}function NA(e){return(1<<e)-1}var Jn,iCe;var Kg=v(()=>{jr();jr();/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */Jn=Ai;iCe=Uint8Array.of()});var OU=(e)=>{let{newPoly:t,N:r,Q:o,F:n,ROOT_OF_UNITY:i,brvBits:s,isKyber:a}=e,c=(_,A=o)=>{let O=_%A|0;return(O>=0?O|0:A+O|0)|0},u=(_,A=o)=>{let O=c(_,A)|0;return(O>A>>1?O-A|0:O)|0};function d(){let _=t(r);for(let A=0;A<r;A++){let O=PA(A,s),L=BigInt(i)**BigInt(O)%BigInt(o);_[A]=Number(L)|0}return _}let p=d(),m={add:(_,A)=>c((_|0)+(A|0))|0,sub:(_,A)=>c((_|0)-(A|0))|0,mul:(_,A)=>c((_|0)*(A|0))|0,inv:(_)=>{throw Error("not implemented")}},h={N:r,roots:p,invertButterflies:!0,skipStages:a?1:0,brp:!1},b=zA(m,{dit:!1,...h}),y=zA(m,{dit:!0,...h});return{mod:c,smod:u,nttZetas:p,NTT:{encode:(_)=>b(_),decode:(_)=>{y(_);for(let A=0;A<_.length;A++)_[A]=c(n*_[A]);return _}},bitsCoder:(_,A)=>{let O=NA(_),L=_*(r/8);return{bytesLen:L,encode:(z)=>{let H=new Uint8Array(L);for(let P=0,W=0,ee=0,j=0;P<z.length;P++){W|=(A.encode(z[P])&O)<<ee,ee+=_;for(;ee>=8;ee-=8,W>>=8)H[j++]=W&NA(ee)}return H},decode:(z)=>{let H=t(r);for(let P=0,W=0,ee=0,j=0;P<z.length;P++){W|=z[P]<<ee,ee+=8;for(;ee>=_;ee-=_,W>>=_)H[j++]=A.decode(W&O)}return H}}}}},pce=(e)=>(t,r)=>{if(!r)r=e.blockLen;let o=new Uint8Array(t.length+2);o.set(t);let n=t.length,i=new Uint8Array(r),s=e.create({}),a=0,c=0;return{stats:()=>({calls:a,xofs:c}),get:(u,d)=>(o[n+0]=u,o[n+1]=d,s.destroy(),s=e.create({}).update(o),a++,()=>(c++,s.xofInto(i))),clean:()=>{s.destroy(),Pt(i,o)}}},CU;var PU=v(()=>{RU();Mg();Kg();/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */CU=pce(kU)});function Ws(e,t){for(let r=0;r<nr;r++)e[r]=Ud(e[r]+t[r])}function bce(e,t){for(let r=0;r<nr;r++)e[r]=Ud(e[r]-t[r])}function Sce(e,t,r,o,n){let i=Ud(t*o*n+e*r),s=Ud(e*o+t*r);return{c0:i,c1:s}}function Hg(e,t){for(let r=0;r<nr/2;r++){let o=hce[64+(r>>1)];if(r&1)o=-o;let{c0:n,c1:i}=Sce(e[2*r+0],e[2*r+1],t[2*r+0],t[2*r+1],o);e[2*r+0]=n,e[2*r+1]=i}return e}function zU(e){let t=new Uint16Array(nr);for(let r=0;r<nr;){let o=e();if(o.length%3)throw Error("SampleNTT: unaligned block");for(let n=0;r<nr&&n+3<=o.length;n+=3){let i=(o[n+0]>>0|o[n+1]<<8)&4095,s=(o[n+1]>>4|o[n+2]<<4)&4095;if(i<Ro)t[r++]=i;if(r<nr&&s<Ro)t[r++]=s}}return t}function Zd(e,t,r,o){let n=e(o*nr/4,t,r),i=new Uint16Array(nr),s=Rg(n),a=0;for(let c=0,u=0,d=0,p=0;c<s.length;c++){let m=s[c];for(let h=0;h<32;h++)if(d+=m&1,m>>=1,a+=1,a===o)p=d,d=0;else if(a===2*o)i[u++]=Ud(p-d),d=0,a=0}if(a)throw Error(`sampleCBD: leftover bits: ${a}`);return i}function LA(e){let t=vce(e),{HASH256:r,HASH512:o,KDF:n}=e,{secretCoder:i,lengths:s}=t,a=Js("secretKey",s.secretKey,s.publicKey,32,32),c=32,u=64;return{info:{type:"ml-kem"},lengths:{...s,seed:64,msg:32,msgRand:32,secretKey:a.bytesLen},keygen:(d=Jn(64))=>{Te(d,64,"seed");let{publicKey:p,secretKey:m}=t.keygen(d.subarray(0,32)),h=r(p),b=a.encode([m,p,h,d.subarray(32)]);return Pt(m,h),{publicKey:p,secretKey:b}},getPublicKey:(d)=>{let[p,m,h,b]=a.decode(d);return Uint8Array.from(m)},encapsulate:(d,p=Jn(32))=>{Te(d,s.publicKey,"publicKey"),Te(p,32,"message");let m=d.subarray(0,384*e.K),h=i.encode(i.decode($U(m)));if(!qg(h,m))throw Pt(h),Error("ML-KEM.encapsulate: wrong publicKey modulus");Pt(h);let b=o.create().update(p).update(r(d)).digest(),y=t.encrypt(d,p,b.subarray(32,64));return Pt(b.subarray(32)),{cipherText:y,sharedSecret:b.subarray(0,32)}},decapsulate:(d,p)=>{Te(p,a.bytesLen,"secretKey"),Te(d,s.cipherText,"cipherText");let m=a.bytesLen-96,h=m+32,b=r(p.subarray(m/2,h));if(!qg(b,p.subarray(h,h+32)))throw Error("invalid secretKey: hash check failed");let[y,S,x,_]=a.decode(p),A=t.decrypt(d,y),O=o.create().update(A).update(x).digest(),L=O.subarray(0,32),z=t.encrypt(S,A,O.subarray(32,64)),H=qg(d,z),P=n.create({dkLen:32}).update(_).update(d).digest();return Pt(A,z,!H?L:P),H?L:P}}}function wce(e,t,r){return Hn.create({dkLen:e}).update(t).update(new Uint8Array([r])).digest()}var nr=256,Ro=3329,fce=3303,mce=17,Ud,hce,Vs,gce,DA,yce=(e)=>{if(e>=12)return{encode:(r)=>r,decode:(r)=>r};let t=2**(e-1);return{encode:(r)=>((r<<e)+Ro/2)/Ro,decode:(r)=>r*Ro+t>>>e}},jd=(e)=>gce(e,yce(e)),vce=(e)=>{let{K:t,PRF:r,XOF:o,HASH512:n,ETA1:i,ETA2:s,du:a,dv:c}=e,u=jd(1),d=jd(c),p=jd(a),m=Js("publicKey",Fg(jd(12),t),32),h=Fg(jd(12),t),b=Js("ciphertext",Fg(p,t),d),y=Js("seed",32,32);return{secretCoder:h,lengths:{secretKey:h.bytesLen,publicKey:m.bytesLen,cipherText:b.bytesLen},keygen:(S)=>{Te(S,32,"seed");let x=new Uint8Array(33);x.set(S),x[32]=t;let _=n(x),[A,O]=y.decode(_),L=[],z=[];for(let W=0;W<t;W++)L.push(Vs.encode(Zd(r,O,W,i)));let H=o(A);for(let W=0;W<t;W++){let ee=Vs.encode(Zd(r,O,t+W,i));for(let j=0;j<t;j++){let R=zU(H.get(j,W));Ws(ee,Hg(R,L[j]))}z.push(ee)}H.clean();let P={publicKey:m.encode([z,A]),secretKey:h.encode(L)};return Pt(A,O,L,z,x,_),P},encrypt:(S,x,_)=>{let[A,O]=m.decode(S),L=[];for(let j=0;j<t;j++)L.push(Vs.encode(Zd(r,_,j,i)));let z=o(O),H=new Uint16Array(nr),P=[];for(let j=0;j<t;j++){let R=Zd(r,_,t+j,s),B=new Uint16Array(nr);for(let k=0;k<t;k++){let T=zU(z.get(j,k));Ws(B,Hg(T,L[k]))}Ws(R,Vs.decode(B)),P.push(R),Ws(H,Hg(A[j],L[j])),Pt(B)}z.clean();let W=Zd(r,_,2*t,s);Ws(W,Vs.decode(H));let ee=u.decode(x);return Ws(ee,W),Pt(A,L,H,W),b.encode([P,ee])},decrypt:(S,x)=>{let[_,A]=b.decode(S),O=h.decode(x),L=new Uint16Array(nr);for(let z=0;z<t;z++)Ws(L,Hg(O[z],Vs.encode(_[z])));return bce(A,Vs.decode(L)),Pt(L,O,_),u.encode(A)}}},BA,gCe,Md,NU;var DU=v(()=>{Mg();jr();PU();Kg();/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */({mod:Ud,nttZetas:hce,NTT:Vs,bitsCoder:gce}=OU({N:nr,Q:Ro,F:fce,ROOT_OF_UNITY:mce,newPoly:(e)=>new Uint16Array(e),brvBits:7,isKyber:!0})),DA={512:{N:nr,Q:Ro,K:2,ETA1:3,ETA2:2,du:10,dv:4,RBGstrength:128},768:{N:nr,Q:Ro,K:3,ETA1:2,ETA2:2,du:10,dv:4,RBGstrength:192},1024:{N:nr,Q:Ro,K:4,ETA1:2,ETA2:2,du:11,dv:5,RBGstrength:256}};BA={HASH256:Hs,HASH512:_U,KDF:Hn,XOF:CU,PRF:wce},gCe=LA({...BA,...DA[512]}),Md=LA({...BA,...DA[768]}),NU=LA({...BA,...DA[1024]})});function xce(e,t=!1){let{lengths:r,keygen:o}=e;if(t){let i=e.Point.Fn;if(!i)throw Error("No Point.Fn");o=(s=Jn(r.seed))=>{Te(s,r.seed,"seed");let a=i.isLE?$i(s):Ri(s),c=i.toBytes(i.create(a));return{secretKey:c,publicKey:e.getPublicKey(c)}}}return{lengths:{secretKey:r.secretKey,publicKey:r.publicKey,seed:r.seed},keygen:o,getPublicKey:(n)=>e.getPublicKey(n)}}function jA(e,t=!1){let r=xce(e,t);if(!e.getSharedSecret)throw Error("wrong curve");return{lengths:{...r.lengths,msg:r.lengths.seed,cipherText:r.lengths.publicKey},keygen:r.keygen,getPublicKey:r.getPublicKey,encapsulate(o,n=Jn(e.lengths.seed)){let i=this.keygen(n).secretKey,s=this.decapsulate(o,i),a=e.getPublicKey(i);return Pt(i),{sharedSecret:s,cipherText:a}},decapsulate(o,n){let i=e.getSharedSecret(n,o);return e.lengths.publicKeyHasPrefix?i.subarray(1):i}}}function qd(e,t){return Js(t,...e.map((r)=>{if(typeof r.lengths[t]!=="number")throw Error("wrong length: "+t);return r.lengths[t]}))}function ZA(e){return(t,r)=>e(t,{dkLen:r})}function _ce(e,t,...r){let o=qd(r,"seed"),n=qd(r,"publicKey");if(e===void 0)e=o.bytesLen;Zt(e);function i(s){Te(s,e);let a=o.decode(t(s,o.bytesLen)),c=r.map((p,m)=>p.keygen(a[m])),u=c.map((p)=>p.secretKey),d=c.map((p)=>p.publicKey);return{secretKey:u,publicKey:d}}return{info:{lengths:{seed:e,publicKey:n.bytesLen,secretKey:e}},getPublicKey(s){return this.keygen(s).publicKey},keygen(s=Jn(e)){let{publicKey:a,secretKey:c}=i(s),u=n.encode(a);return Pt(a),Pt(c),{secretKey:s,publicKey:u}},expandDecapsulationKey:i,realSeedLen:e}}function Jg(e,t,r,o,...n){let i=_ce(e,r,...n),s=qd(n,"cipherText"),a=qd(n,"publicKey"),c=qd(n,"msg");if(t===void 0)t=c.bytesLen;return Zt(t),{lengths:{...i.info.lengths,msg:t,msgRand:c.bytesLen,cipherText:s.bytesLen},getPublicKey:i.getPublicKey,keygen:i.keygen,encapsulate(u,d=Jn(c.bytesLen)){let p=a.decode(u),m=c.decode(d),h=n.map((x,_)=>x.encapsulate(p[_],m[_])),b=h.map((x)=>x.sharedSecret),y=h.map((x)=>x.cipherText),S={sharedSecret:o(p,y,b),cipherText:s.encode(y)};return Pt(b,y),S},decapsulate(u,d){let p=s.decode(u),{publicKey:m,secretKey:h}=i.expandDecapsulationKey(d),b=n.map((y,S)=>y.decapsulate(p[S],h[S]));return o(m,p,b)}}}function LU(e,t,r,o,n){return Xr(o),Xr(n),Jg(32,32,ZA(o),(i,s,a)=>n(kt(a[0],a[1],s[1],i[1],Oi(e))),t,r)}function Ece(e,t,r,o,n){return Xr(o),Xr(n),Jg(32,32,ZA(o),(i,s,a)=>{let c=kt(a[0],a[1],s[0],i[0],s[1],i[1],Oi(e)),u=32,d=kt(Oi("hybrid_prk"),c),p=fU(n,d),m=kt(Bc(32,2),Oi("shared_secret"),Oi("")),h=mU(n,p,m,32);return Pt(p,m,d,c),h},t,r)}function Ice(e,t,r,o){let n=e.Point.Fn;if(!n)throw Error("no Point.Fn");function i(s){let a;for(let d=0,p=t;;d=p,p+=t){if(p>s.length)throw Error("rejection sampling failed");if(a=n.fromBytes(s.subarray(d,p),!0),n.isValidNot0(a))break}let c=n.toBytes(n.create(a)),u=e.getPublicKey(c,!1);return{secretKey:c,publicKey:u}}return{lengths:{secretKey:t,publicKey:r,seed:o,msg:o,cipherText:r},keygen(s=Jn(o)){return Te(s,o,"seed"),i(s)},getPublicKey(s){return e.getPublicKey(s,!1)},encapsulate(s,a=Jn(o)){Te(a,o,"rand");let{secretKey:c}=i(a),u=this.decapsulate(s,c),d=e.getPublicKey(c,!1);return Pt(c),{sharedSecret:u,cipherText:d}},decapsulate(s,a){return e.getSharedSecret(a,s).subarray(1)}}}function Ace(e,t,r,o){let{secretKey:n,publicKeyUncompressed:i}=r.lengths;if(!n||!i)throw Error("wrong curve");let s=Ice(r,n,i,o),a=64,c=a+o;return Jg(32,32,(u)=>{Te(u,32);let d=Hn(u,{dkLen:c}),p=d.subarray(0,a),m=d.subarray(a,c);return kt(p,m)},(u,d,p)=>Hs(kt(p[0],p[1],d[1],u[1],Oi(e))),t,s)}var ACe,TCe,BU,RCe,kce,Tce,Vg,jU;var ZU=v(()=>{lU();dU();jc();hU();RA();Mg();jr();DU();Kg();/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */ACe=LU("QSF-KEM(ML-KEM-768,P-256)-XOF(SHAKE256)-KDF(SHA3-256)",Md,jA($A,!0),Hn,Hs),TCe=LU("QSF-KEM(ML-KEM-1024,P-384)-XOF(SHAKE256)-KDF(SHA3-256)",NU,jA(uU,!0),Hn,Hs);BU=jA(cU),RCe=Ece("KitchenSink-KEM(ML-KEM-768,X25519)-XOF(SHAKE256)-KDF(HKDF-SHA-256)",Md,BU,Hn,Zg),kce=(()=>Jg(32,32,ZA(Hn),(e,t,r)=>Hs(kt(r[0],r[1],t[1],e[1],Oi("\\.//^\\"))),Md,BU))();Tce=(()=>Ace("MLKEM768-P256",Md,$A,128))(),Vg=kce,jU=Tce});function $o(e,t=""){if(typeof e!=="boolean"){let r=t&&`"${t}" `;throw TypeError(r+"expected boolean, got type="+typeof e)}return e}function Qg(e){if(typeof e==="bigint"){if(!Wg(e))throw RangeError("positive bigint expected, got "+e)}else MA(e);return e}function Vn(e,t=""){if(typeof e!=="number"){let r=t&&`"${t}" `;throw TypeError(r+"expected number, got type="+typeof e)}if(!Number.isSafeInteger(e)){let r=t&&`"${t}" `;throw RangeError(r+"expected safe integer, got "+e)}}function Fd(e){let t=Qg(e).toString(16);return t.length&1?"0"+t:t}function UU(e){if(typeof e!=="string")throw TypeError("hex string expected, got "+typeof e);return e===""?Gg:BigInt("0x"+e)}function Gs(e){return UU(hg(e))}function bn(e){return UU(hg(Di(Ft(e)).reverse()))}function Yg(e,t){if(vt(t),t===0)throw RangeError("zero length");e=Qg(e);let r=e.toString(16);if(r.length>t*2)throw RangeError("number too large");return yd(r.padStart(t*2,"0"))}function Kd(e,t){return Yg(e,t).reverse()}function MU(e,t){if(e=et(e),t=et(t),e.length!==t.length)return!1;let r=0;for(let o=0;o<e.length;o++)r|=e[o]^t[o];return r===0}function Di(e){return Uint8Array.from(et(e))}function Xg(e){if(typeof e!=="string")throw TypeError("ascii string expected, got "+typeof e);return Uint8Array.from(e,(t,r)=>{let o=t.charCodeAt(0);if(t.length!==1||o>127)throw RangeError(`string contains non-ASCII character "${e[r]}" with code ${o} at position ${r}`);return o})}function Rce(e,t,r){return Wg(e)&&Wg(t)&&Wg(r)&&t<=e&&e<r}function Oo(e,t,r,o){if(!Rce(t,r,o))throw RangeError("expected valid "+e+": "+r+" <= n < "+o+", got "+t)}function Vc(e){if(e<Gg)throw Error("expected non-negative bigint, got "+e);let t;for(t=0;e>Gg;e>>=UA,t+=1);return t}function qU(e,t,r){if(vt(e,"hashLen"),vt(t,"qByteLen"),typeof r!=="function")throw TypeError("hmacFn must be a function");let o=(S)=>new Uint8Array(S),n=Uint8Array.of(),i=Uint8Array.of(0),s=Uint8Array.of(1),a=1000,c=o(e),u=o(e),d=0,p=()=>{c.fill(1),u.fill(0),d=0},m=(...S)=>r(u,Vt(c,...S)),h=(S=n)=>{if(u=m(i,S),c=m(),S.length===0)return;u=m(s,S),c=m()},b=()=>{if(d++>=a)throw Error("drbg: tried max amount of iterations");let S=0,x=[];while(S<t){c=m();let _=c.slice();x.push(_),S+=c.length}return Vt(...x)};return(S,x)=>{p(),h(S);let _=void 0;while((_=x(b()))===void 0)h();return p(),_}}function tn(e,t={},r={}){if(Object.prototype.toString.call(e)!=="[object Object]")throw TypeError("expected valid options object");function o(i,s,a){if(!a&&s!=="function"&&!Object.hasOwn(e,i))throw TypeError(`param "${i}" is invalid: expected own property`);let c=e[i];if(a&&c===void 0)return;let u=typeof c;if(u!==s||c===null)throw TypeError(`param "${i}" is invalid: expected ${s}, got ${u}`)}let n=(i,s)=>Object.entries(i).forEach(([a,c])=>o(a,c,s));n(t,!1),n(r,!0)}var et=(e,t,r)=>Ft(e,t,r),MA,Fc,Vt=(...e)=>jI(...e),Kc=(e)=>yd(e),Hc,Jc=(e)=>xo(e),Gg,UA,Wg=(e)=>typeof e==="bigint"&&Gg<=e,Hd=(e)=>(UA<<BigInt(e))-UA,qA=()=>{throw Error("not implemented")};var Li=v(()=>{Gr();/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */MA=vt,Fc=hg,Hc=DI,Gg=BigInt(0),UA=BigInt(1)});function it(e,t){if(t<=Wt)throw Error("mod: expected positive modulus, got "+t);let r=e%t;return r>=Wt?r:t+r}function rn(e,t,r){if(t<Wt)throw Error("pow2: expected non-negative exponent, got "+t);let o=e;while(t-- >Wt)o*=o,o%=r;return o}function FU(e,t){if(e===Wt)throw Error("invert: expected non-zero number");if(t<=Wt)throw Error("invert: expected positive modulus, got "+t);let r=it(e,t),o=t,n=Wt,i=yt,s=yt,a=Wt;while(r!==Wt){let u=o/r,d=o-r*u,p=n-s*u,m=i-a*u;o=r,r=d,n=s,i=a,s=p,a=m}if(o!==yt)throw Error("invert: does not exist");return it(n,t)}function FA(e,t,r){let o=e;if(!o.eql(o.sqr(t),r))throw Error("Cannot find square root")}function YU(e,t){let r=e,o=(r.ORDER+yt)/VU,n=r.pow(t,o);return FA(r,n,t),n}function Cce(e,t){let r=e,o=(r.ORDER-WU)/GU,n=r.mul(t,Qs),i=r.pow(n,o),s=r.mul(t,i),a=r.mul(r.mul(s,Qs),i),c=r.mul(s,r.sub(a,r.ONE));return FA(r,c,t),c}function Pce(e){let t=ey(e),r=XU(e),o=r(t,t.neg(t.ONE)),n=r(t,o),i=r(t,t.neg(o)),s=(e+$ce)/QU;return(a,c)=>{let u=a,d=u.pow(c,s),p=u.mul(d,o),m=u.mul(d,n),h=u.mul(d,i),b=u.eql(u.sqr(p),c),y=u.eql(u.sqr(m),c);d=u.cmov(d,p,b),p=u.cmov(h,m,y);let S=u.eql(u.sqr(p),c),x=u.cmov(d,p,S);return FA(u,x,c),x}}function XU(e){if(e<JU)throw Error("sqrt is not defined for small field");let t=e-yt,r=0;while(t%Qs===Wt)t/=Qs,r++;let o=Qs,n=ey(e);while(KU(n,o)===1)if(o++>1000)throw Error("Cannot find square root: probably non-prime P");if(r===1)return YU;let i=n.pow(o,t),s=(t+yt)/Qs;return function(c,u){let d=c;if(d.is0(u))return u;if(KU(d,u)!==1)throw Error("Cannot find square root");let p=r,m=d.mul(d.ONE,i),h=d.pow(u,t),b=d.pow(u,s);while(!d.eql(h,d.ONE)){if(d.is0(h))return d.ZERO;let y=1,S=d.sqr(h);while(!d.eql(S,d.ONE))if(y++,S=d.sqr(S),y===p)throw Error("Cannot find square root");let x=yt<<BigInt(p-y-1),_=d.pow(m,x);p=y,m=d.sqr(_),h=d.mul(h,m),b=d.mul(b,_)}return b}}function zce(e){if(e%VU===JU)return YU;if(e%GU===WU)return Cce;if(e%QU===Oce)return Pce(e);return XU(e)}function KA(e){let t={ORDER:"bigint",BYTES:"number",BITS:"number"},r=Nce.reduce((o,n)=>(o[n]="function",o),t);if(tn(e,r),Vn(e.BYTES,"BYTES"),Vn(e.BITS,"BITS"),e.BYTES<1||e.BITS<1)throw Error("invalid field: expected BYTES/BITS > 0");if(e.ORDER<=yt)throw Error("invalid field: expected ORDER > 1, got "+e.ORDER);return e}function Dce(e,t,r){let o=e;if(r<Wt)throw Error("invalid exponent, negatives unsupported");if(r===Wt)return o.ONE;if(r===yt)return t;let n=o.ONE,i=t;while(r>Wt){if(r&yt)n=o.mul(n,i);i=o.sqr(i),r>>=yt}return n}function Jd(e,t,r=!1){let o=e,n=Array(t.length).fill(r?o.ZERO:void 0),i=t.reduce((a,c,u)=>{if(o.is0(c))return a;return n[u]=a,o.mul(a,c)},o.ONE),s=o.inv(i);return t.reduceRight((a,c,u)=>{if(o.is0(c))return a;return n[u]=o.mul(a,n[u]),o.mul(a,c)},s),n}function KU(e,t){let r=e,o=(r.ORDER-yt)/Qs,n=r.pow(t,o),i=r.eql(n,r.ONE),s=r.eql(n,r.ZERO),a=r.eql(n,r.neg(r.ONE));if(!i&&!s&&!a)throw Error("invalid Legendre symbol result");return i?1:s?0:-1}function Lce(e,t){if(t!==void 0)MA(t);if(e<=Wt)throw Error("invalid n length: expected positive n, got "+e);if(t!==void 0&&t<1)throw Error("invalid n length: expected positive bit length, got "+t);let r=Vc(e);if(t!==void 0&&t<r)throw Error(`invalid n length: expected bit length (${r}) >= n.length (${t})`);let o=t!==void 0?t:r,n=Math.ceil(o/8);return{nBitLength:o,nByteLength:n}}class HA{ORDER;BITS;BYTES;isLE;ZERO=Wt;ONE=yt;_lengths;_mod;constructor(e,t={}){if(e<=yt)throw Error("invalid field: expected ORDER > 1, got "+e);let r=void 0;if(this.isLE=!1,t!=null&&typeof t==="object"){if(typeof t.BITS==="number")r=t.BITS;if(typeof t.sqrt==="function")Object.defineProperty(this,"sqrt",{value:t.sqrt,enumerable:!0});if(typeof t.isLE==="boolean")this.isLE=t.isLE;if(t.allowedLengths)this._lengths=Object.freeze(t.allowedLengths.slice());if(typeof t.modFromBytes==="boolean")this._mod=t.modFromBytes}let{nBitLength:o,nByteLength:n}=Lce(e,r);if(n>2048)throw Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=e,this.BITS=o,this.BYTES=n,Object.freeze(this)}create(e){return it(e,this.ORDER)}isValid(e){if(typeof e!=="bigint")throw TypeError("invalid field element: expected bigint, got "+typeof e);return Wt<=e&&e<this.ORDER}is0(e){return e===Wt}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&yt)===yt}neg(e){return it(-e,this.ORDER)}eql(e,t){return e===t}sqr(e){return it(e*e,this.ORDER)}add(e,t){return it(e+t,this.ORDER)}sub(e,t){return it(e-t,this.ORDER)}mul(e,t){return it(e*t,this.ORDER)}pow(e,t){return Dce(this,e,t)}div(e,t){return it(e*FU(t,this.ORDER),this.ORDER)}sqrN(e){return e*e}addN(e,t){return e+t}subN(e,t){return e-t}mulN(e,t){return e*t}inv(e){return FU(e,this.ORDER)}sqrt(e){let t=HU.get(this);if(!t)HU.set(this,t=zce(this.ORDER));return t(this,e)}toBytes(e){return this.isLE?Kd(e,this.BYTES):Yg(e,this.BYTES)}fromBytes(e,t=!1){et(e);let{_lengths:r,BYTES:o,isLE:n,ORDER:i,_mod:s}=this;if(r){if(e.length<1||!r.includes(e.length)||e.length>o)throw Error("Field.fromBytes: expected "+r+" bytes, got "+e.length);let c=new Uint8Array(o);c.set(e,n?0:c.length-e.length),e=c}if(e.length!==o)throw Error("Field.fromBytes: expected "+o+" bytes, got "+e.length);let a=n?bn(e):Gs(e);if(s)a=it(a,i);if(!t){if(!this.isValid(a))throw Error("invalid field element: outside of range 0..ORDER")}return a}invertBatch(e){return Jd(this,e)}cmov(e,t,r){return $o(r,"condition"),r?t:e}}function ey(e,t={}){return new HA(e,t)}function e6(e){if(typeof e!=="bigint")throw Error("field order must be bigint");if(e<=yt)throw Error("field order must be greater than 1");let t=Vc(e-yt);return Math.ceil(t/8)}function JA(e){let t=e6(e);return t+Math.ceil(t/2)}function t6(e,t,r=!1){et(e);let o=e.length,n=e6(t),i=Math.max(JA(t),16);if(o<i||o>1024)throw Error("expected "+i+"-1024 bytes of input, got "+o);let s=r?bn(e):Gs(e),a=it(s,t-yt)+yt;return r?Kd(a,n):Yg(a,n)}var Wt,yt,Qs,JU,VU,WU,$ce,GU,Oce,QU,Co=(e,t)=>(it(e,t)&yt)===yt,Nce,HU;var Vd=v(()=>{Li();/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */Wt=BigInt(0),yt=BigInt(1),Qs=BigInt(2),JU=BigInt(3),VU=BigInt(4),WU=BigInt(5),$ce=BigInt(7),GU=BigInt(8),Oce=BigInt(9),QU=BigInt(16);Nce=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];HU=new WeakMap;Object.freeze(HA.prototype)});function Wd(e,t){let r=t.negate();return e?r:t}function Xs(e,t){let r=Jd(e.Fp,t.map((o)=>o.Z));return t.map((o,n)=>e.fromAffine(o.toAffine(r[n])))}function i6(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw Error("invalid window size, expected [1.."+t+"], got W="+e)}function VA(e,t){i6(e,t);let r=Math.ceil(t/e)+1,o=2**(e-1),n=2**e,i=Hd(e),s=BigInt(e);return{windows:r,windowSize:o,mask:i,maxNumber:n,shiftBy:s}}function r6(e,t,r){let{windowSize:o,mask:n,maxNumber:i,shiftBy:s}=r,a=Number(e&n),c=e>>s;if(a>o)a-=i,c+=Ys;let u=t*o,d=u+Math.abs(a)-1,p=a===0,m=a<0,h=t%2!==0;return{nextN:c,offset:d,isZero:p,isNeg:m,isNegF:h,offsetF:u}}function GA(e){return s6.get(e)||1}function n6(e){if(e!==Wc)throw Error("invalid wNAF")}class Gd{BASE;ZERO;Fn;bits;constructor(e,t){this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=t}_unsafeLadder(e,t,r=this.ZERO){let o=e;while(t>Wc){if(t&Ys)r=r.add(o);o=o.double(),t>>=Ys}return r}precomputeWindow(e,t){let{windows:r,windowSize:o}=VA(t,this.bits),n=[],i=e,s=i;for(let a=0;a<r;a++){s=i,n.push(s);for(let c=1;c<o;c++)s=s.add(i),n.push(s);i=s.double()}return n}wNAF(e,t,r){if(!this.Fn.isValid(r))throw Error("invalid scalar");let o=this.ZERO,n=this.BASE,i=VA(e,this.bits);for(let s=0;s<i.windows;s++){let{nextN:a,offset:c,isZero:u,isNeg:d,isNegF:p,offsetF:m}=r6(r,s,i);if(r=a,u)n=n.add(Wd(p,t[m]));else o=o.add(Wd(d,t[c]))}return n6(r),{p:o,f:n}}wNAFUnsafe(e,t,r,o=this.ZERO){let n=VA(e,this.bits);for(let i=0;i<n.windows;i++){if(r===Wc)break;let{nextN:s,offset:a,isZero:c,isNeg:u}=r6(r,i,n);if(r=s,c)continue;else{let d=t[a];o=o.add(u?d.negate():d)}}return n6(r),o}getPrecomputes(e,t,r){let o=WA.get(t);if(!o){if(o=this.precomputeWindow(t,e),e!==1){if(typeof r==="function")o=r(o);WA.set(t,o)}}return o}cached(e,t,r){let o=GA(e);return this.wNAF(o,this.getPrecomputes(o,e,r),t)}unsafe(e,t,r,o){let n=GA(e);if(n===1)return this._unsafeLadder(e,t,o);return this.wNAFUnsafe(n,this.getPrecomputes(n,e,r),t,o)}createCache(e,t){i6(t,this.bits),s6.set(e,t),WA.delete(e)}hasCache(e){return GA(e)!==1}}function a6(e,t,r,o){let n=t,i=e.ZERO,s=e.ZERO;while(r>Wc||o>Wc){if(r&Ys)i=i.add(n);if(o&Ys)s=s.add(n);n=n.double(),r>>=Ys,o>>=Ys}return{p1:i,p2:s}}function o6(e,t,r){if(t){if(t.ORDER!==e)throw Error("Field.ORDER must match order: Fp == p, Fn == n");return KA(t),t}else return ey(e,{isLE:r})}function ty(e,t,r={},o){if(o===void 0)o=e==="edwards";if(!t||typeof t!=="object")throw Error(`expected valid ${e} CURVE object`);for(let c of["p","n","h"]){let u=t[c];if(!(typeof u==="bigint"&&u>Wc))throw Error(`CURVE.${c} must be positive bigint`)}let n=o6(t.p,r.Fp,o),i=o6(t.n,r.Fn,o),a=["Gx","Gy","a",e==="weierstrass"?"b":"d"];for(let c of a)if(!n.isValid(t[c]))throw Error(`CURVE.${c} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:n,Fn:i}}function Qd(e,t){return function(o){let n=e(o);return{secretKey:n,publicKey:t(n)}}}var Wc,Ys,WA,s6;var ry=v(()=>{Li();Vd();/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */Wc=BigInt(0),Ys=BigInt(1);WA=new WeakMap,s6=new WeakMap});function Yd(e,t){if(Vn(e),Vn(t),t<0||t>4)throw Error("invalid I2OSP length: "+t);if(e<0||e>2**(8*t)-1)throw Error("invalid I2OSP input: "+e);let r=Array.from({length:t}).fill(0);for(let o=t-1;o>=0;o--)r[o]=e&255,e>>>=8;return new Uint8Array(r)}function Bce(e,t){let r=new Uint8Array(e.length);for(let o=0;o<e.length;o++)r[o]=e[o]^t[o];return r}function jce(e){if(!Hc(e)&&typeof e!=="string")throw Error("DST must be Uint8Array or ascii string");let t=typeof e==="string"?Xg(e):e;if(t.length===0)throw Error("DST must be non-empty");return t}function QA(e,t,r,o){if(et(e),Vn(r),t=jce(t),t.length>255)t=o(Vt(Xg("H2C-OVERSIZE-DST-"),t));let{outputLen:n,blockLen:i}=o,s=Math.ceil(r/n);if(r>65535||s>255)throw Error("expand_message_xmd: invalid lenInBytes");let a=Vt(t,Yd(t.length,1)),c=new Uint8Array(i),u=Yd(r,2),d=Array(s),p=o(Vt(c,e,u,Yd(0,1),a));d[0]=o(Vt(p,Yd(1,1),a));for(let h=1;h<s;h++){let b=[Bce(p,d[h-1]),Yd(h+1,1),a];d[h]=o(Vt(...b))}return Vt(...d).slice(0,r)}var c6="HashToScalar-";var l6=v(()=>{Li()});function Zce(e,t,r){Oo("scalar",e,Wn,r);let[[o,n],[i,s]]=t,a=u6(s*e,r),c=u6(-n*e,r),u=e-a*o-c*i,d=-a*n-c*s,p=u<Wn,m=d<Wn;if(p)u=-u;if(m)d=-d;let h=Hd(Math.ceil(Vc(r)/2))+Bi;if(u<Wn||u>=h||d<Wn||d>=h)throw Error("splitScalar (endomorphism): failed for k");return{k1neg:p,k1:u,k2neg:m,k2:d}}function XA(e){if(!["compact","recovered","der"].includes(e))throw Error('Signature format must be "compact", "recovered", or "der"');return e}function YA(e,t){tn(e);let r={};for(let o of Object.keys(t))r[o]=e[o]===void 0?t[o]:e[o];if($o(r.lowS,"lowS"),$o(r.prehash,"prehash"),r.format!==void 0)XA(r.format);return r}function f6(e,t={}){let r=ty("weierstrass",e,t),o=r.Fp,n=r.Fn,i=r.CURVE,{h:s,n:a}=i;tn(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});let{endo:c,allowInfinityPoint:u}=t;if(c){if(!o.is0(i.a)||typeof c.beta!=="bigint"||!Array.isArray(c.basises))throw Error('invalid endo: expected "beta": bigint and "basises": array')}let d=h6(o,n);function p(){if(!o.isOdd)throw Error("compression is not supported: Field does not have .isOdd()")}function m(j,R,B){if(u&&R.is0())return Uint8Array.of(0);let{x:k,y:T}=R.toAffine(),I=o.toBytes(k);if($o(B,"isCompressed"),B){p();let q=!o.isOdd(T);return Vt(m6(q),I)}else return Vt(Uint8Array.of(4),I,o.toBytes(T))}function h(j){et(j,void 0,"Point");let{publicKey:R,publicKeyUncompressed:B}=d,k=j.length,T=j[0],I=j.subarray(1);if(u&&k===1&&T===0)return{x:o.ZERO,y:o.ZERO};if(k===R&&(T===2||T===3)){let q=o.fromBytes(I);if(!o.isValid(q))throw Error("bad point: is not on curve, wrong x");let N=S(q),J;try{J=o.sqrt(N)}catch(ae){let me=ae instanceof Error?": "+ae.message:"";throw Error("bad point: is not on curve, sqrt error"+me)}p();let G=o.isOdd(J);if((T&1)===1!==G)J=o.neg(J);return{x:q,y:J}}else if(k===B&&T===4){let q=o.BYTES,N=o.fromBytes(I.subarray(0,q)),J=o.fromBytes(I.subarray(q,q*2));if(!x(N,J))throw Error("bad point: is not on curve");return{x:N,y:J}}else throw Error(`bad point: got length ${k}, expected compressed=${R} or uncompressed=${B}`)}let b=t.toBytes===void 0?m:t.toBytes,y=t.fromBytes===void 0?h:t.fromBytes;function S(j){let R=o.sqr(j),B=o.mul(R,j);return o.add(o.add(B,o.mul(j,i.a)),i.b)}function x(j,R){let B=o.sqr(R),k=S(j);return o.eql(B,k)}if(!x(i.Gx,i.Gy))throw Error("bad curve params: generator point");let _=o.mul(o.pow(i.a,ny),Uce),A=o.mul(o.sqr(i.b),BigInt(27));if(o.is0(o.add(_,A)))throw Error("bad curve params: a or b");function O(j,R,B=!1){if(!o.isValid(R)||B&&o.is0(R))throw Error(`bad point coordinate ${j}`);return R}function L(j){if(!(j instanceof P))throw Error("Weierstrass Point expected")}function z(j){if(!c||!c.basises)throw Error("no endo");return Zce(j,c.basises,n.ORDER)}function H(j,R,B,k,T){return B=new P(o.mul(B.X,j),B.Y,B.Z),R=Wd(k,R),B=Wd(T,B),R.add(B)}class P{static BASE=new P(i.Gx,i.Gy,o.ONE);static ZERO=new P(o.ZERO,o.ONE,o.ZERO);static Fp=o;static Fn=n;X;Y;Z;constructor(j,R,B){this.X=O("x",j),this.Y=O("y",R,!0),this.Z=O("z",B),Object.freeze(this)}static CURVE(){return i}static fromAffine(j){let{x:R,y:B}=j||{};if(!j||!o.isValid(R)||!o.isValid(B))throw Error("invalid affine point");if(j instanceof P)throw Error("projective point not allowed");if(o.is0(R)&&o.is0(B))return P.ZERO;return new P(R,B,o.ONE)}static fromBytes(j){let R=P.fromAffine(y(et(j,void 0,"point")));return R.assertValidity(),R}static fromHex(j){return P.fromBytes(Kc(j))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(j=8,R=!0){if(ee.createCache(this,j),!R)this.multiply(ny);return this}assertValidity(){let j=this;if(j.is0()){if(t.allowInfinityPoint&&o.is0(j.X)&&o.eql(j.Y,o.ONE)&&o.is0(j.Z))return;throw Error("bad point: ZERO")}let{x:R,y:B}=j.toAffine();if(!o.isValid(R)||!o.isValid(B))throw Error("bad point: x or y not field elements");if(!x(R,B))throw Error("bad point: equation left != right");if(!j.isTorsionFree())throw Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y:j}=this.toAffine();if(!o.isOdd)throw Error("Field doesn't support isOdd");return!o.isOdd(j)}equals(j){L(j);let{X:R,Y:B,Z:k}=this,{X:T,Y:I,Z:q}=j,N=o.eql(o.mul(R,q),o.mul(T,k)),J=o.eql(o.mul(B,q),o.mul(I,k));return N&&J}negate(){return new P(this.X,o.neg(this.Y),this.Z)}double(){let{a:j,b:R}=i,B=o.mul(R,ny),{X:k,Y:T,Z:I}=this,q=o.ZERO,N=o.ZERO,J=o.ZERO,G=o.mul(k,k),re=o.mul(T,T),ae=o.mul(I,I),me=o.mul(k,T);return me=o.add(me,me),J=o.mul(k,I),J=o.add(J,J),q=o.mul(j,J),N=o.mul(B,ae),N=o.add(q,N),q=o.sub(re,N),N=o.add(re,N),N=o.mul(q,N),q=o.mul(me,q),J=o.mul(B,J),ae=o.mul(j,ae),me=o.sub(G,ae),me=o.mul(j,me),me=o.add(me,J),J=o.add(G,G),G=o.add(J,G),G=o.add(G,ae),G=o.mul(G,me),N=o.add(N,G),ae=o.mul(T,I),ae=o.add(ae,ae),G=o.mul(ae,me),q=o.sub(q,G),J=o.mul(ae,re),J=o.add(J,J),J=o.add(J,J),new P(q,N,J)}add(j){L(j);let{X:R,Y:B,Z:k}=this,{X:T,Y:I,Z:q}=j,N=o.ZERO,J=o.ZERO,G=o.ZERO,re=i.a,ae=o.mul(i.b,ny),me=o.mul(R,T),be=o.mul(B,I),ve=o.mul(k,q),Ae=o.add(R,B),Ie=o.add(T,I);Ae=o.mul(Ae,Ie),Ie=o.add(me,be),Ae=o.sub(Ae,Ie),Ie=o.add(R,k);let we=o.add(T,q);return Ie=o.mul(Ie,we),we=o.add(me,ve),Ie=o.sub(Ie,we),we=o.add(B,k),N=o.add(I,q),we=o.mul(we,N),N=o.add(be,ve),we=o.sub(we,N),G=o.mul(re,Ie),N=o.mul(ae,ve),G=o.add(N,G),N=o.sub(be,G),G=o.add(be,G),J=o.mul(N,G),be=o.add(me,me),be=o.add(be,me),ve=o.mul(re,ve),Ie=o.mul(ae,Ie),be=o.add(be,ve),ve=o.sub(me,ve),ve=o.mul(re,ve),Ie=o.add(Ie,ve),me=o.mul(be,Ie),J=o.add(J,me),me=o.mul(we,Ie),N=o.mul(Ae,N),N=o.sub(N,me),me=o.mul(Ae,be),G=o.mul(we,G),G=o.add(G,me),new P(N,J,G)}subtract(j){return L(j),this.add(j.negate())}is0(){return this.equals(P.ZERO)}multiply(j){let{endo:R}=t;if(!n.isValidNot0(j))throw RangeError("invalid scalar: out of range");let B,k,T=(I)=>ee.cached(this,I,(q)=>Xs(P,q));if(R){let{k1neg:I,k1:q,k2neg:N,k2:J}=z(j),{p:G,f:re}=T(q),{p:ae,f:me}=T(J);k=re.add(me),B=H(R.beta,G,ae,I,N)}else{let{p:I,f:q}=T(j);B=I,k=q}return Xs(P,[B,k])[0]}multiplyUnsafe(j){let{endo:R}=t,B=this,k=j;if(!n.isValid(k))throw RangeError("invalid scalar: out of range");if(k===Wn||B.is0())return P.ZERO;if(k===Bi)return B;if(ee.hasCache(this))return this.multiply(k);if(R){let{k1neg:T,k1:I,k2neg:q,k2:N}=z(k),{p1:J,p2:G}=a6(P,B,I,N);return H(R.beta,J,G,T,q)}else return ee.unsafe(B,k)}toAffine(j){let R=this,B=j,{X:k,Y:T,Z:I}=R;if(o.eql(I,o.ONE))return{x:k,y:T};let q=R.is0();if(B==null)B=q?o.ONE:o.inv(I);let N=o.mul(k,B),J=o.mul(T,B),G=o.mul(I,B);if(q)return{x:o.ZERO,y:o.ZERO};if(!o.eql(G,o.ONE))throw Error("invZ was invalid");return{x:N,y:J}}isTorsionFree(){let{isTorsionFree:j}=t;if(s===Bi)return!0;if(j)return j(P,this);return ee.unsafe(this,a).is0()}clearCofactor(){let{clearCofactor:j}=t;if(s===Bi)return this;if(j)return j(P,this);return this.multiplyUnsafe(s)}isSmallOrder(){if(s===Bi)return this.is0();return this.clearCofactor().is0()}toBytes(j=!0){return $o(j,"isCompressed"),this.assertValidity(),b(P,this,j)}toHex(j=!0){return Fc(this.toBytes(j))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let W=n.BITS,ee=new Gd(P,t.endo?Math.ceil(W/2):W);if(W>=8)P.BASE.precompute(8);return Object.freeze(P.prototype),Object.freeze(P),P}function m6(e){return Uint8Array.of(e?2:3)}function h6(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function Mce(e,t={}){let{Fn:r}=e,o=t.randomBytes===void 0?Jc:t.randomBytes,n=Object.assign(h6(e.Fp,r),{seed:Math.max(JA(r.ORDER),16)});function i(h){try{let b=r.fromBytes(h);return r.isValidNot0(b)}catch(b){return!1}}function s(h,b){let{publicKey:y,publicKeyUncompressed:S}=n;try{let x=h.length;if(b===!0&&x!==y)return!1;if(b===!1&&x!==S)return!1;return!!e.fromBytes(h)}catch(x){return!1}}function a(h){return h=h===void 0?o(n.seed):h,t6(et(h,n.seed,"seed"),r.ORDER)}function c(h,b=!0){return e.BASE.multiply(r.fromBytes(h)).toBytes(b)}function u(h){let{secretKey:b,publicKey:y,publicKeyUncompressed:S}=n,x=r._lengths;if(!Hc(h))return;let _=et(h,void 0,"key").length,A=_===y||_===S,O=_===b||!!x?.includes(_);if(A&&O)return;return A}function d(h,b,y=!0){if(u(h)===!0)throw Error("first arg must be private key");if(u(b)===!1)throw Error("second arg must be public key");let S=r.fromBytes(h);return e.fromBytes(b).multiply(S).toBytes(y)}let p={isValidSecretKey:i,isValidPublicKey:s,randomSecretKey:a},m=Qd(a,c);return Object.freeze(p),Object.freeze(n),Object.freeze({getPublicKey:c,getSharedSecret:d,keygen:m,Point:e,utils:p,lengths:n})}function g6(e,t,r={}){let o=t;wo(o),tn(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),r=Object.assign({},r);let n=r.randomBytes===void 0?Jc:r.randomBytes,i=r.hmac===void 0?(T,I)=>Mn(o,T,I):r.hmac,{Fp:s,Fn:a}=e,{ORDER:c,BITS:u}=a,{keygen:d,getPublicKey:p,getSharedSecret:m,utils:h,lengths:b}=Mce(e,r),y={prehash:!0,lowS:typeof r.lowS==="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},S=c*p6+Bi<s.ORDER;function x(T){let I=c>>Bi;return T>I}function _(T,I){if(!a.isValidNot0(I))throw Error(`invalid signature ${T}: out of range 1..Point.Fn.ORDER`);return I}function A(){if(S)throw Error('"recovered" sig type is not supported for cofactor >2 curves')}function O(T,I){XA(I);let q=b.signature,N=I==="compact"?q:I==="recovered"?q+1:void 0;return et(T,N)}class L{r;s;recovery;constructor(T,I,q){if(this.r=_("r",T),this.s=_("s",I),q!=null){if(A(),![0,1,2,3].includes(q))throw Error("invalid recovery id");this.recovery=q}Object.freeze(this)}static fromBytes(T,I=y.format){O(T,I);let q;if(I==="der"){let{r:re,s:ae}=Sn.toSig(et(T));return new L(re,ae)}if(I==="recovered")q=T[0],I="compact",T=T.subarray(1);let N=b.signature/2,J=T.subarray(0,N),G=T.subarray(N,N*2);return new L(a.fromBytes(J),a.fromBytes(G),q)}static fromHex(T,I){return this.fromBytes(Kc(T),I)}assertRecovery(){let{recovery:T}=this;if(T==null)throw Error("invalid recovery id: must be present");return T}addRecoveryBit(T){return new L(this.r,this.s,T)}recoverPublicKey(T){let{r:I,s:q}=this,N=this.assertRecovery(),J=N===2||N===3?I+c:I;if(!s.isValid(J))throw Error("invalid recovery id: sig.r+curve.n != R.x");let G=s.toBytes(J),re=e.fromBytes(Vt(m6((N&1)===0),G)),ae=a.inv(J),me=H(et(T,void 0,"msgHash")),be=a.create(-me*ae),ve=a.create(q*ae),Ae=e.BASE.multiplyUnsafe(be).add(re.multiplyUnsafe(ve));if(Ae.is0())throw Error("invalid recovery: point at infinify");return Ae.assertValidity(),Ae}hasHighS(){return x(this.s)}toBytes(T=y.format){if(XA(T),T==="der")return Kc(Sn.hexFromSig(this));let{r:I,s:q}=this,N=a.toBytes(I),J=a.toBytes(q);if(T==="recovered")return A(),Vt(Uint8Array.of(this.assertRecovery()),N,J);return Vt(N,J)}toHex(T){return Fc(this.toBytes(T))}}Object.freeze(L.prototype),Object.freeze(L);let z=r.bits2int===void 0?function(I){if(I.length>8192)throw Error("input is too large");let q=Gs(I),N=I.length*8-u;return N>0?q>>BigInt(N):q}:r.bits2int,H=r.bits2int_modN===void 0?function(I){return a.create(z(I))}:r.bits2int_modN,P=Hd(u);function W(T){return Oo("num < 2^"+u,T,Wn,P),a.toBytes(T)}function ee(T,I){return et(T,void 0,"message"),I?et(o(T),void 0,"prehashed message"):T}function j(T,I,q){let{lowS:N,prehash:J,extraEntropy:G}=YA(q,y);T=ee(T,J);let re=H(T),ae=a.fromBytes(I);if(!a.isValidNot0(ae))throw Error("invalid private key");let me=[W(ae),W(re)];if(G!=null&&G!==!1){let Ie=G===!0?n(b.secretKey):G;me.push(et(Ie,void 0,"extraEntropy"))}let be=Vt(...me),ve=re;function Ae(Ie){let we=z(Ie);if(!a.isValidNot0(we))return;let Ue=a.inv(we),De=e.BASE.multiply(we).toAffine(),Qe=a.create(De.x);if(Qe===Wn)return;let St=a.create(Ue*a.create(ve+Qe*ae));if(St===Wn)return;let Tt=(De.x===Qe?0:2)|Number(De.y&Bi),Dt=St;if(N&&x(St))Dt=a.neg(St),Tt^=1;return new L(Qe,Dt,S?void 0:Tt)}return{seed:be,k2sig:Ae}}function R(T,I,q={}){let{seed:N,k2sig:J}=j(T,I,q);return qU(o.outputLen,a.BYTES,i)(N,J).toBytes(q.format)}function B(T,I,q,N={}){let{lowS:J,prehash:G,format:re}=YA(N,y);if(q=et(q,void 0,"publicKey"),I=ee(I,G),!Hc(T)){let ae=T instanceof L?", use sig.toBytes()":"";throw Error("verify expects Uint8Array signature"+ae)}O(T,re);try{let ae=L.fromBytes(T,re),me=e.fromBytes(q);if(J&&ae.hasHighS())return!1;let{r:be,s:ve}=ae,Ae=H(I),Ie=a.inv(ve),we=a.create(Ae*Ie),Ue=a.create(be*Ie),De=e.BASE.multiplyUnsafe(we).add(me.multiplyUnsafe(Ue));if(De.is0())return!1;return a.create(De.x)===be}catch(ae){return!1}}function k(T,I,q={}){let{prehash:N}=YA(q,y);return I=ee(I,N),L.fromBytes(T,"recovered").recoverPublicKey(I).toBytes()}return Object.freeze({keygen:d,getPublicKey:p,getSharedSecret:m,utils:h,lengths:b,Point:e,sign:R,verify:B,recoverPublicKey:k,Signature:L,hash:o})}var u6=(e,t)=>(e+(e>=0?t:-t)/p6)/t,d6,Sn,Wn,Bi,p6,ny,Uce;var y6=v(()=>{bd();Gr();Li();ry();Vd();/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */d6=class d6 extends Error{constructor(e=""){super(e)}};Sn={Err:d6,_tlv:{encode:(e,t)=>{let{Err:r}=Sn;if(Vn(e,"tag"),e<0||e>255)throw new r("tlv.encode: wrong tag");if(typeof t!=="string")throw TypeError('"data" expected string, got type='+typeof t);if(t.length&1)throw new r("tlv.encode: unpadded data");let o=t.length/2,n=Fd(o);if(n.length/2&128)throw new r("tlv.encode: long form length too big");let i=o>127?Fd(n.length/2|128):"";return Fd(e)+i+n+t},decode(e,t){let{Err:r}=Sn;t=et(t,void 0,"DER data");let o=0;if(e<0||e>255)throw new r("tlv.encode: wrong tag");if(t.length<2||t[o++]!==e)throw new r("tlv.decode: wrong tlv");let n=t[o++],i=!!(n&128),s=0;if(!i)s=n;else{let c=n&127;if(!c)throw new r("tlv.decode(long): indefinite length not supported");if(c>4)throw new r("tlv.decode(long): byte length is too big");let u=t.subarray(o,o+c);if(u.length!==c)throw new r("tlv.decode: length bytes not complete");if(u[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let d of u)s=s<<8|d;if(o+=c,s<128)throw new r("tlv.decode(long): not minimal encoding")}let a=t.subarray(o,o+s);if(a.length!==s)throw new r("tlv.decode: wrong value length");return{v:a,l:t.subarray(o+s)}}},_int:{encode(e){let{Err:t}=Sn;if(Qg(e),e<Wn)throw new t("integer: negative integers are not allowed");let r=Fd(e);if(Number.parseInt(r[0],16)&8)r="00"+r;if(r.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return r},decode(e){let{Err:t}=Sn;if(e.length<1)throw new t("invalid signature integer: empty");if(e[0]&128)throw new t("invalid signature integer: negative");if(e.length>1&&e[0]===0&&!(e[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return Gs(e)}},toSig(e){let{Err:t,_int:r,_tlv:o}=Sn,n=et(e,void 0,"signature"),{v:i,l:s}=o.decode(48,n);if(s.length)throw new t("invalid signature: left bytes after parsing");let{v:a,l:c}=o.decode(2,i),{v:u,l:d}=o.decode(2,c);if(d.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(u)}},hexFromSig(e){let{_tlv:t,_int:r}=Sn,o=t.encode(2,r.encode(e.r)),n=t.encode(2,r.encode(e.s)),i=o+n;return t.encode(48,i)}};Object.freeze(Sn._tlv);Object.freeze(Sn._int);Object.freeze(Sn);Wn=BigInt(0),Bi=BigInt(1),p6=BigInt(2),ny=BigInt(3),Uce=BigInt(4)});var qce,Fce,Gc;var b6=v(()=>{Cc();y6();/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */qce=(()=>({p:BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),h:BigInt(1),a:BigInt("0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc"),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")}))(),Fce=f6(qce),Gc=g6(Fce,wt)});function Hce(e,t,r,o){let n=e.sqr(r),i=e.sqr(o),s=e.add(e.mul(t.a,n),i),a=e.add(e.ONE,e.mul(t.d,e.mul(n,i)));return e.eql(s,a)}function S6(e,t={}){let r=t,o=ty("edwards",e,r,r.FpFnLE),{Fp:n,Fn:i}=o,s=o.CURVE,{h:a}=s;tn(r,{},{uvRatio:"function"});let c=eT<<BigInt(i.BYTES*8)-Ir,u=(y)=>n.create(y),d=r.uvRatio===void 0?(y,S)=>{try{return{isValid:!0,value:n.sqrt(n.div(y,S))}}catch(x){return{isValid:!1,value:ji}}}:r.uvRatio;if(!Hce(n,s,s.Gx,s.Gy))throw Error("bad curve params: generator point");function p(y,S,x=!1){let _=x?Ir:ji;return Oo("coordinate "+y,S,_,c),S}function m(y){if(!(y instanceof h))throw Error("EdwardsPoint expected")}class h{static BASE=new h(s.Gx,s.Gy,Ir,u(s.Gx*s.Gy));static ZERO=new h(ji,Ir,Ir,ji);static Fp=n;static Fn=i;X;Y;Z;T;constructor(y,S,x,_){this.X=p("x",y),this.Y=p("y",S),this.Z=p("z",x,!0),this.T=p("t",_),Object.freeze(this)}static CURVE(){return s}static fromAffine(y){if(y instanceof h)throw Error("extended point not allowed");let{x:S,y:x}=y||{};return p("x",S),p("y",x),new h(S,x,Ir,u(S*x))}static fromBytes(y,S=!1){let x=n.BYTES,{a:_,d:A}=s;y=Di(et(y,x,"point")),$o(S,"zip215");let O=Di(y),L=y[x-1];O[x-1]=L&-129;let z=bn(O),H=S?c:n.ORDER;Oo("point.y",z,ji,H);let P=u(z*z),W=u(P-Ir),ee=u(A*P-_),{isValid:j,value:R}=d(W,ee);if(!j)throw Error("bad point: invalid y coordinate");let B=(R&Ir)===Ir,k=(L&128)!==0;if(!S&&R===ji&&k)throw Error("bad point: x=0 and x_0=1");if(k!==B)R=u(-R);return h.fromAffine({x:R,y:z})}static fromHex(y,S=!1){return h.fromBytes(Kc(y),S)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(y=8,S=!0){if(b.createCache(this,y),!S)this.multiply(eT);return this}assertValidity(){let y=this,{a:S,d:x}=s;if(y.is0())throw Error("bad point: ZERO");let{X:_,Y:A,Z:O,T:L}=y,z=u(_*_),H=u(A*A),P=u(O*O),W=u(P*P),ee=u(z*S),j=u(P*u(ee+H)),R=u(W+u(x*u(z*H)));if(j!==R)throw Error("bad point: equation left != right (1)");let B=u(_*A),k=u(O*L);if(B!==k)throw Error("bad point: equation left != right (2)")}equals(y){m(y);let{X:S,Y:x,Z:_}=this,{X:A,Y:O,Z:L}=y,z=u(S*L),H=u(A*_),P=u(x*L),W=u(O*_);return z===H&&P===W}is0(){return this.equals(h.ZERO)}negate(){return new h(u(-this.X),this.Y,this.Z,u(-this.T))}double(){let{a:y}=s,{X:S,Y:x,Z:_}=this,A=u(S*S),O=u(x*x),L=u(eT*u(_*_)),z=u(y*A),H=S+x,P=u(u(H*H)-A-O),W=z+O,ee=W-L,j=z-O,R=u(P*ee),B=u(W*j),k=u(P*j),T=u(ee*W);return new h(R,B,T,k)}add(y){m(y);let{a:S,d:x}=s,{X:_,Y:A,Z:O,T:L}=this,{X:z,Y:H,Z:P,T:W}=y,ee=u(_*z),j=u(A*H),R=u(L*x*W),B=u(O*P),k=u((_+A)*(z+H)-ee-j),T=B-R,I=B+R,q=u(j-S*ee),N=u(k*T),J=u(I*q),G=u(k*q),re=u(T*I);return new h(N,J,re,G)}subtract(y){return m(y),this.add(y.negate())}multiply(y){if(!i.isValidNot0(y))throw RangeError("invalid scalar: expected 1 <= sc < curve.n");let{p:S,f:x}=b.cached(this,y,(_)=>Xs(h,_));return Xs(h,[S,x])[0]}multiplyUnsafe(y){if(!i.isValid(y))throw RangeError("invalid scalar: expected 0 <= sc < curve.n");if(y===ji)return h.ZERO;if(this.is0()||y===Ir)return this;return b.unsafe(this,y,(S)=>Xs(h,S))}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){return b.unsafe(this,s.n).is0()}toAffine(y){let S=this,x=y,{X:_,Y:A,Z:O}=S,L=S.is0();if(x==null)x=L?Kce:n.inv(O);let z=u(_*x),H=u(A*x),P=n.mul(O,x);if(L)return{x:ji,y:Ir};if(P!==Ir)throw Error("invZ was invalid");return{x:z,y:H}}clearCofactor(){if(a===Ir)return this;return this.multiplyUnsafe(a)}toBytes(){let{x:y,y:S}=this.toAffine(),x=n.toBytes(S);return x[x.length-1]|=y&Ir?128:0,x}toHex(){return Fc(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let b=new Gd(h,i.BITS);if(i.BITS>=8)h.BASE.precompute(8);return Object.freeze(h.prototype),Object.freeze(h),h}class tT{static BASE;static ZERO;static Fp;static Fn;ep;constructor(e){this.ep=e}static fromBytes(e){qA()}static fromHex(e){qA()}get x(){return this.toAffine().x}get y(){return this.toAffine().y}clearCofactor(){return this}assertValidity(){this.ep.assertValidity()}toAffine(e){return this.ep.toAffine(e)}toHex(){return Fc(this.toBytes())}toString(){return this.toHex()}isTorsionFree(){return!0}isSmallOrder(){return!1}add(e){return this.assertSame(e),this.init(this.ep.add(e.ep))}subtract(e){return this.assertSame(e),this.init(this.ep.subtract(e.ep))}multiply(e){return this.init(this.ep.multiply(e))}multiplyUnsafe(e){return this.init(this.ep.multiplyUnsafe(e))}double(){return this.init(this.ep.double())}negate(){return this.init(this.ep.negate())}precompute(e,t){return this.ep.precompute(e,t),this}}var ji,Ir,eT,Kce;var v6=v(()=>{Li();ry();/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ji=BigInt(0),Ir=BigInt(1),eT=BigInt(2),Kce=BigInt(8)});function Jce(e){return tn(e,{P:"bigint",type:"string",adjustScalarBytes:"function",powPminus2:"function"},{randomBytes:"function"}),Object.freeze({...e})}function w6(e){let t=Jce(e),{P:r,type:o,adjustScalarBytes:n,powPminus2:i,randomBytes:s}=t,a=o==="x25519";if(!a&&o!=="x448")throw Error("invalid type");let c=s===void 0?Jc:s,u=a?255:448,d=a?32:56,p=a?BigInt(9):BigInt(5),m=a?BigInt(121665):BigInt(39081),h=a?oy**BigInt(254):oy**BigInt(447),b=a?BigInt(8)*oy**BigInt(251)-Qc:BigInt(4)*oy**BigInt(445)-Qc,y=h+b+Qc,S=(k)=>it(k,r),x=_(p);function _(k){return Kd(S(k),d)}function A(k){let T=Di(et(k,d,"uCoordinate"));if(a)T[31]&=127;return S(bn(T))}function O(k){return bn(n(Di(et(k,d,"scalar"))))}function L(k,T){let I=ee(A(T),O(k));if(I===Xd)throw Error("invalid private or public key received");return _(I)}function z(k){return L(k,x)}let H=z,P=L;function W(k,T,I){let q=S(k*(T-I));return T=S(T-q),I=S(I+q),{x_2:T,x_3:I}}function ee(k,T){Oo("u",k,Xd,r),Oo("scalar",T,h,y);let I=T,q=k,N=Qc,J=Xd,G=k,re=Qc,ae=Xd;for(let be=BigInt(u-1);be>=Xd;be--){let ve=I>>be&Qc;ae^=ve,{x_2:N,x_3:G}=W(ae,N,G),{x_2:J,x_3:re}=W(ae,J,re),ae=ve;let Ae=N+J,Ie=S(Ae*Ae),we=N-J,Ue=S(we*we),De=Ie-Ue,Qe=G+re,St=G-re,Tt=S(St*Ae),Dt=S(Qe*we),lt=Tt+Dt,$r=Tt-Dt;G=S(lt*lt),re=S(q*S($r*$r)),N=S(Ie*Ue),J=S(De*(Ie+S(m*De)))}({x_2:N,x_3:G}=W(ae,N,G)),{x_2:J,x_3:re}=W(ae,J,re);let me=i(J);return S(N*me)}let j={secretKey:d,publicKey:d,seed:d},R=(k)=>(k=k===void 0?c(d):k,et(k,j.seed,"seed"),k),B={randomSecretKey:R};return Object.freeze(j),Object.freeze(B),Object.freeze({keygen:Qd(R,H),getSharedSecret:P,getPublicKey:H,scalarMult:L,scalarMultBase:z,utils:B,GuBytes:x.slice(),lengths:j})}var Xd,Qc,oy;var x6=v(()=>{Li();ry();Vd();/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */Xd=BigInt(0),Qc=BigInt(1),oy=BigInt(2)});function I6(e){let t=BigInt(10),r=BigInt(20),o=BigInt(40),n=BigInt(80),i=ta,a=e*e%i*e%i,c=rn(a,_6,i)*a%i,u=rn(c,Po,i)*e%i,d=rn(u,Gce,i)*u%i,p=rn(d,t,i)*d%i,m=rn(p,r,i)*p%i,h=rn(m,o,i)*m%i,b=rn(h,n,i)*h%i,y=rn(b,n,i)*h%i,S=rn(y,t,i)*d%i;return{pow_p_5_8:rn(S,_6,i)*e%i,b2:a}}function Yce(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}function sT(e,t){let r=ta,o=it(t*t*t,r),n=it(o*o*t,r),i=I6(e*n).pow_p_5_8,s=it(e*o*i,r),a=it(t*s*s,r),c=s,u=it(s*rT,r),d=a===e,p=a===it(-e,r),m=a===it(-e*rT,r);if(d)s=c;if(p||m)s=u;if(Co(s,r))s=it(-s,r);return{isValid:d||p,value:s}}function k6(e){let{d:t}=iT,r=ta,o=(x)=>Zi.create(x),n=o(nT*e*e),i=o((n+Po)*tle),s=BigInt(-1),a=o((s-t*n)*o(n+t)),{isValid:c,value:u}=sT(i,a),d=o(u*e);if(!Co(d,r))d=o(-d);if(!c)u=d;if(!c)s=n;let p=o(s*(n-Po)*rle-a),m=u*u,h=o((u+u)*a),b=o(p*Xce),y=o(Po-m),S=o(Po+m);return new ea(o(h*S),o(y*b),o(b*S),o(h*y))}var Vce,Po,_6,Wce,Gce,Qce,ta,iT,rT,ea,Zi,A6,iy,nT,Xce,ele,tle,rle,E6=(e)=>sT(Po,e),nle,oT=(e)=>Zi.create(bn(e)&nle),br,ole;var T6=v(()=>{Cc();Gr();v6();l6();Vd();x6();Li();/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */Vce=BigInt(0),Po=BigInt(1),_6=BigInt(2),Wce=BigInt(3),Gce=BigInt(5),Qce=BigInt(8),ta=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),iT=(()=>({p:ta,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:Qce,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")}))();rT=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");ea=S6(iT,{uvRatio:sT}),Zi=(()=>ea.Fp)(),A6=(()=>ea.Fn)(),iy=(()=>{let e=ta;return w6({P:e,type:"x25519",powPminus2:(t)=>{let{pow_p_5_8:r,b2:o}=I6(t);return it(rn(r,Wce,e)*o,e)},adjustScalarBytes:Yce})})(),nT=rT,Xce=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),ele=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),tle=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),rle=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),nle=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");br=class br extends tT{static BASE=(()=>new br(ea.BASE))();static ZERO=(()=>new br(ea.ZERO))();static Fp=(()=>Zi)();static Fn=(()=>A6)();constructor(e){super(e)}static fromAffine(e){return new br(ea.fromAffine(e))}assertSame(e){if(!(e instanceof br))throw Error("RistrettoPoint expected")}init(e){return new br(e)}static fromBytes(e){Ft(e,32);let{a:t,d:r}=iT,o=ta,n=(A)=>Zi.create(A),i=oT(e);if(!MU(Zi.toBytes(i),e)||Co(i,o))throw Error("invalid ristretto255 encoding 1");let s=n(i*i),a=n(Po+t*s),c=n(Po-t*s),u=n(a*a),d=n(c*c),p=n(t*r*u-d),{isValid:m,value:h}=E6(n(p*d)),b=n(h*c),y=n(h*b*p),S=n((i+i)*b);if(Co(S,o))S=n(-S);let x=n(a*y),_=n(S*x);if(!m||Co(_,o)||x===Vce)throw Error("invalid ristretto255 encoding 2");return new br(new ea(S,x,Po,_))}static fromHex(e){return br.fromBytes(yd(e))}toBytes(){let{X:e,Y:t,Z:r,T:o}=this.ep,n=ta,i=(y)=>Zi.create(y),s=i(i(r+t)*i(r-t)),a=i(e*t),c=i(a*a),{value:u}=E6(i(s*c)),d=i(u*s),p=i(u*a),m=i(d*p*o),h;if(Co(o*m,n)){let y=i(t*nT),S=i(e*nT);e=y,t=S,h=i(d*ele)}else h=p;if(Co(e*m,n))t=i(-t);let b=i((r-t)*h);if(Co(b,n))b=i(-b);return Zi.toBytes(b)}equals(e){this.assertSame(e);let{X:t,Y:r}=this.ep,{X:o,Y:n}=e.ep,i=(c)=>Zi.create(c),s=i(t*n)===i(r*o),a=i(r*n)===i(t*o);return s||a}is0(){return this.equals(br.ZERO)}};Object.freeze(br.BASE);Object.freeze(br.ZERO);Object.freeze(br.prototype);Object.freeze(br);ole=Object.freeze({Point:br,hashToCurve(e,t){let r=t?.DST===void 0?"ristretto255_XMD:SHA-512_R255MAP_RO_":t.DST,o=QA(e,r,64,Sg);return ole.deriveToCurve(o)},hashToScalar(e,t={DST:c6}){let r=QA(e,t.DST,64,Sg);return A6.create(bn(r))},deriveToCurve(e){Ft(e,64);let t=oT(e.subarray(0,32)),r=k6(t),o=oT(e.subarray(32,64)),n=k6(o);return new br(r.add(n))}})});async function $6(e,t){if(ile)return await t();try{return await e()}catch(r){if(r instanceof ReferenceError||r instanceof DOMException&&r.name==="NotSupportedError")return await t();else throw r}}async function sy(e,t){return await $6(async()=>{let r=aT(e)?e:await ale(e),o=await crypto.subtle.importKey("raw",cle(t),{name:"X25519"},R6,[]);return new Uint8Array(await crypto.subtle.deriveBits({name:"X25519",public:o},r,256))},()=>{if(aT(e))throw Error("CryptoKey provided but X25519 WebCrypto is not supported");return iy.scalarMult(e,t)})}async function ep(e){return await $6(async()=>sy(e,iy.GuBytes),()=>{if(aT(e))throw Error("CryptoKey provided but X25519 WebCrypto is not supported");return iy.scalarMultBase(e)})}async function ale(e){if(e.length!==32)throw Error("X25519 private key must be 32 bytes");let t=new Uint8Array([...sle,...e]);return crypto.subtle.importKey("pkcs8",t,{name:"X25519"},R6,["deriveBits"])}function aT(e){return typeof CryptoKey<"u"&&e instanceof CryptoKey}function cle(e){return e}var R6=!1,ile=!1,sle;var O6=v(()=>{T6();sle=new Uint8Array([48,46,2,1,0,48,5,6,3,43,101,110,4,34,4,32])});class cT{s;transcript=[];buf=new Uint8Array(0);constructor(e){this.s=e.getReader()}async readLine(){let e=[];while(!0){let t=this.buf.indexOf(10);if(t>=0)return e.push(this.buf.subarray(0,t)),this.transcript.push(this.buf.subarray(0,t+1)),this.buf=this.buf.subarray(t+1),ule(ra(e));if(this.buf.length>0)e.push(this.buf),this.transcript.push(this.buf);let r=await this.s.read();if(r.done)return this.buf=ra(e),null;this.buf=r.value}}close(){return this.s.releaseLock(),{rest:this.buf,transcript:ra(this.transcript)}}}function ule(e){return e.forEach((t)=>{if(t<32||t>126)throw Error("invalid non-ASCII byte in header")}),new TextDecoder().decode(e)}function ra(e){let t=e.reduce((n,i)=>n+i.length,0),r=new Uint8Array(t),o=0;for(let n of e)r.set(n,o),o+=n.length;return r}function Yc(e,...t){return e.pipeThrough(new TransformStream({start(r){for(let o of t)r.enqueue(o)}}))}function ay(e){return new ReadableStream({start(t){t.enqueue(e),t.close()}})}async function lT(e){if(!(e instanceof ReadableStream))throw Error("readAll expects a ReadableStream<Uint8Array>");return new Uint8Array(await new Response(e).arrayBuffer())}async function C6(e){if(!(e instanceof ReadableStream))throw Error("readAllString expects a ReadableStream<Uint8Array>");return await new Response(e).text()}async function P6(e,t){let r=e.getReader(),o=[],n=0;while(n<t){let{done:c,value:u}=await r.read();if(c)throw Error("stream ended before reading "+t.toString()+" bytes");o.push(u),n+=u.length}r.releaseLock();let i=ra(o),s=i.subarray(0,t),a=Yc(e,i.subarray(t));return{data:s,rest:a}}var uT=()=>{};class Gn{args;body;constructor(e,t){this.args=e,this.body=t}}async function dle(e){let t=await e.readLine();if(t===null)throw Error("invalid stanza");let r=t.split(" ");if(r.length<2||r.shift()!=="->")return{next:t};for(let i of r)if(i.length===0)throw Error("invalid stanza");let o=[];for(;;){let i=await e.readLine();if(i===null)throw Error("invalid stanza");let s=tr.decode(i);if(s.length>48)throw Error("invalid stanza");if(o.push(s),s.length<48)break}let n=ra(o);return{s:new Gn(r,n)}}async function z6(e){let t=new cT(e),r=await t.readLine();if(r!=="age-encryption.org/v1")throw Error("invalid version "+(r??"line"));let o=[];for(;;){let{s:n,next:i}=await dle(t);if(n!==void 0){o.push(n);continue}if(!i.startsWith("--- "))throw Error("invalid header");let s=tr.decode(i.slice(4)),{rest:a,transcript:c}=t.close(),u=c.slice(0,c.length-1-i.length+3);return{stanzas:o,headerNoMAC:u,MAC:s,headerSize:c.length,rest:Yc(e,a)}}}function dT(e){let t=[];t.push(`age-encryption.org/v1
|
|
404
|
+
`,t)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let t=lg(e),r=Ic(t);return r.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let t=lg(e),r=Ic(t);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){if(this.type!=="comment")return!1;if(this.indent<=t)return!1;return e.every((r)=>r.type==="newline"||r.type==="space")}*documentEnd(e){if(this.type!=="doc-mode"){if(e.end)e.end.push(this.sourceToken);else e.end=[this.sourceToken];if(this.type==="newline")yield*this.pop()}}*lineEnd(e){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;case"space":case"comment":default:if(e.end)e.end.push(this.sourceToken);else e.end=[this.sourceToken];if(this.type==="newline")yield*this.pop()}}}Pie.Parser=VB});var XB=ge(function(Mie){var WB=bI(),Nie=ad(),fd=cd(),Die=Tk(),Lie=qe(),Bie=TI(),GB=RI();function QB(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new Bie.LineCounter||null,prettyErrors:t}}function jie(e,t={}){let{lineCounter:r,prettyErrors:o}=QB(t),n=new GB.Parser(r?.addNewLine),i=new WB.Composer(t),s=Array.from(i.compose(n.parse(e)));if(o&&r)for(let a of s)a.errors.forEach(fd.prettifyError(e,r)),a.warnings.forEach(fd.prettifyError(e,r));if(s.length>0)return s;return Object.assign([],{empty:!0},i.streamInfo())}function YB(e,t={}){let{lineCounter:r,prettyErrors:o}=QB(t),n=new GB.Parser(r?.addNewLine),i=new WB.Composer(t),s=null;for(let a of i.compose(n.parse(e),!0,e.length))if(!s)s=a;else if(s.options.logLevel!=="silent"){s.errors.push(new fd.YAMLParseError(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}if(o&&r)s.errors.forEach(fd.prettifyError(e,r)),s.warnings.forEach(fd.prettifyError(e,r));return s}function Zie(e,t,r){let o=void 0;if(typeof t==="function")o=t;else if(r===void 0&&t&&typeof t==="object")r=t;let n=YB(e,r);if(!n)return null;if(n.warnings.forEach((i)=>Die.warn(n.options.logLevel,i)),n.errors.length>0)if(n.options.logLevel!=="silent")throw n.errors[0];else n.errors=[];return n.toJS(Object.assign({reviver:o},r))}function Uie(e,t,r){let o=null;if(typeof t==="function"||Array.isArray(t))o=t;else if(r===void 0&&t)r=t;if(typeof r==="string")r=r.length;if(typeof r==="number"){let n=Math.round(r);r=n<1?void 0:n>8?{indent:8}:{indent:n}}if(e===void 0){let{keepUndefined:n}=r??t??{};if(!n)return}if(Lie.isDocument(e)&&!o)return e.toString(r);return new Nie.Document(e,o,r).toString(r)}Mie.parse=Zie;Mie.parseAllDocuments=jie;Mie.parseDocument=YB;Mie.stringify=Uie});var Jie,Vie,Wie,$I,Gie,wi,Qie,Yie,Xie,ese,t$e,tse,rse,nse,dg,ej,ose,ise,sse,ase,cse,lse,use,dse,pse,fse,mn,yo,mse,bo,OI,hse,gse,yse,bse,Sse,vse,wse,xse,_se,Wr,Ese,kse,Ise;var Ac=v(()=>{Jie=bI(),Vie=ad(),Wie=rI(),$I=cd(),Gie=Ju(),wi=qe(),Qie=gi(),Yie=Et(),Xie=bi(),ese=Si(),t$e=ag(),tse=AI(),rse=TI(),nse=RI(),dg=XB(),ej=Ku();ose=Jie.Composer,ise=Vie.Document,sse=Wie.Schema,ase=$I.YAMLError,cse=$I.YAMLParseError,lse=$I.YAMLWarning,use=Gie.Alias,dse=wi.isAlias,pse=wi.isCollection,fse=wi.isDocument,mn=wi.isMap,yo=wi.isNode,mse=wi.isPair,bo=wi.isScalar,OI=wi.isSeq,hse=Qie.Pair,gse=Yie.Scalar,yse=Xie.YAMLMap,bse=ese.YAMLSeq,Sse=tse.Lexer,vse=rse.LineCounter,wse=nse.Parser,xse=dg.parse,_se=dg.parseAllDocuments,Wr=dg.parseDocument,Ese=dg.stringify,kse=ej.visit,Ise=ej.visitAsync});var ij={};Lt(ij,{assertPilotUsersRemoved:()=>PI,createPilotOffboardDriver:()=>CI,offboardPilotUsers:()=>rj});import{access as Ase,readdir as Tse,readFile as Rse,rm as md,writeFile as $se}from"fs/promises";import{basename as Ose,join as So}from"path";async function rj(e,t){let r=[...new Set(t.handles.map((p)=>mr.parse(p)))].sort((p,m)=>p.localeCompare(m));if(r.length===0)throw Error("At least one pilot handle is required");let o=t.dryRun??!0,n=`sunset:${r.join(",")}`;if(!o&&t.confirmation!==n)throw Error(`Exact confirmation required: ${n}`);let i=t.env??process.env,s=t.logger??console.info,a=await ut(e),c=r.map((p)=>Cse(a,p,i)),u=t.driver??CI({env:i,fetchImpl:t.fetchImpl,contentRepoTokenName:a.pilot.contentRepoAdminToken}),d=await Promise.all(c.map(async(p)=>({target:p,inspection:await u.inspect(p)})));if(zse(d),Nse(d,o,s),!o){for(let p of d)if(!p.inspection.contentRepoArchived)await u.archiveContentRepo(p.target),s(`[${p.target.handle}] archived ${p.target.contentRepo}`);for(let p of d)for(let m of p.inspection.dnsRecords)await u.deleteDnsRecord(p.target,m),s(`[${p.target.handle}] deleted DNS ${m.name}`);for(let p of d)if(p.inspection.server)await u.deleteServer(p.target,p.inspection.server),s(`[${p.target.handle}] deleted ${p.target.instanceName}`);await Pse(c,u,t.sleep??((p)=>new Promise((m)=>setTimeout(m,p)))),await Dse(e,r),await po(e),await PI(e,r),s(`Removed desired state for ${r.length} pilot user(s)`)}return{dryRun:o,handles:r,confirmation:n,plans:d}}function Cse(e,t,r){let o=e.users.find((d)=>d.handle===t),n=`${t}${e.pilot.domainSuffix}`,i=o?.domain??n,s=pk(i,{sharedDomain:e.pilot.domainSuffix}),a=o?.cloudflareZoneId??pg(r,"CF_ZONE_ID"),c=o?.contentRepo??`${e.pilot.contentRepoPrefix}${t}-content`,u=c.includes("/")?c:`${e.pilot.githubOrg}/${c}`;return{handle:t,instanceName:`rover-${t}`,domain:i,previewDomain:s,...i===n?{}:{wwwDomain:`www.${i}`},contentRepo:u,cloudflareZoneId:a}}async function Pse(e,t,r){for(let o of e)for(let n=1;n<=20;n+=1){let i=await t.inspect(o);if(!i.server&&i.dnsRecords.length===0&&i.contentRepoArchived)break;if(n===20)throw Error(`[${o.handle}] provider cleanup did not converge`);await r(1500)}}function zse(e){for(let{target:t,inspection:r}of e){if(r.server&&r.server.name!==t.instanceName)throw Error(`[${t.handle}] unexpected server name: ${r.server.name}`);let o=new Set([t.domain,t.previewDomain,...t.wwwDomain?[t.wwwDomain]:[]]);for(let n of r.dnsRecords){if(!o.has(n.name))throw Error(`[${t.handle}] refusing unexpected DNS record ${n.name}`);if(n.type==="A"&&r.server?.ip&&n.content!==r.server.ip)throw Error(`[${t.handle}] ${n.name} does not point to the retiring server`)}}}function Nse(e,t,r){r(`${t?"Dry run":"Apply"}: ${e.map(({target:o})=>o.handle).join(", ")}`);for(let{target:o,inspection:n}of e){let i=n.server?`delete ${o.instanceName}`:"already absent",s=n.dnsRecords.length>0?n.dnsRecords.map((c)=>`${c.type} ${c.name}`).join(", "):"already absent",a=n.contentRepoArchived?"already archived":`archive ${o.contentRepo}`;r(`[${o.handle}] server: ${i}; DNS: ${s}; repo: ${a}`)}r("Runtime backups: none")}async function Dse(e,t){let r=new Set(t),o=So(e,"cohorts");for(let n of(await Tse(o)).filter((i)=>i.endsWith(".yaml"))){let i=So(o,n),s=await Rse(i,"utf8"),a=Wr(s);if(a.errors.length>0)throw Error(`${n}: ${a.errors[0]?.message??"invalid YAML"}`);let c=a.get("members",!0);if(!OI(c))throw Error(`${n}: members must be a sequence`);let u=c.items.filter((d)=>!bo(d)||typeof d.value!=="string"||!r.has(d.value));if(u.length===c.items.length)continue;if(u.length===0){await md(i);continue}c.items=u,Kr.parse(a.toJS()),await $se(i,a.toString())}for(let n of t)await Promise.all([md(So(e,"users",`${n}.yaml`),{force:!0}),md(So(e,"users",`${n}.secrets.yaml`),{force:!0}),md(So(e,"users",`${n}.secrets.yaml.age`),{force:!0}),md(So(e,"users",n),{recursive:!0,force:!0})])}function CI(e){let t=e.fetchImpl??fetch,r=pg(e.env,"HCLOUD_TOKEN"),o=pg(e.env,"CF_API_TOKEN"),n=pg(e.env,e.contentRepoTokenName);return{async inspect(i){let[s,a,c]=await Promise.all([Lse(t,r,i.instanceName),Promise.all([i.domain,i.previewDomain,...i.wwwDomain?[i.wwwDomain]:[]].map((u)=>Bse(t,o,i.cloudflareZoneId,u))).then((u)=>u.flat()),jse(t,n,i.contentRepo)]);if(s.length>1)throw Error(`[${i.handle}] expected at most one server, found ${s.length}`);return{...s[0]?{server:s[0]}:{},dnsRecords:a,contentRepoArchived:c.archived}},async archiveContentRepo(i){await Tc(t,`https://api.github.com/repos/${i.contentRepo}`,{method:"PATCH",headers:nj(n),body:JSON.stringify({archived:!0})},"GitHub repository archive")},async deleteDnsRecord(i,s){if(Rc(await Tc(t,`https://api.cloudflare.com/client/v4/zones/${i.cloudflareZoneId}/dns_records/${s.id}`,{method:"DELETE",headers:oj(o)},"Cloudflare DNS delete")).success!==!0)throw Error(`Cloudflare DNS delete failed for ${s.name}`)},async deleteServer(i,s){await Tc(t,`https://api.hetzner.cloud/v1/servers/${s.id}`,{method:"DELETE",headers:{Authorization:`Bearer ${r}`}},"Hetzner server delete",!0)}}}async function Lse(e,t,r){let o=new URL("https://api.hetzner.cloud/v1/servers");o.searchParams.set("label_selector",`brain=${r}`);let i=Rc(await Tc(e,o.toString(),{headers:{Authorization:`Bearer ${t}`}},"Hetzner server lookup")).servers;if(!Array.isArray(i))throw Error("Hetzner server lookup returned an invalid payload");return i.map((s)=>{let a=Rc(s),c=tj(a.public_net),u=tj(c?.ipv4);return{id:Zse(a.id,"Hetzner server id"),name:hd(a.name,"Hetzner server name"),...typeof u?.ip==="string"?{ip:u.ip}:{}}})}async function Bse(e,t,r,o){let n=new URL(`https://api.cloudflare.com/client/v4/zones/${r}/dns_records`);n.searchParams.set("name",o);let i=Rc(await Tc(e,n.toString(),{headers:oj(t)},"Cloudflare DNS lookup")),s=i.result;if(i.success!==!0||!Array.isArray(s))throw Error(`Cloudflare DNS lookup failed for ${o}`);return s.map((a)=>{let c=Rc(a),u=hd(c.type,"Cloudflare record type");if(u!=="A"&&u!=="CNAME")throw Error(`Unsupported Cloudflare record type ${u} for ${o}`);return{id:hd(c.id,"Cloudflare record id"),name:hd(c.name,"Cloudflare record name"),type:u,content:hd(c.content,"Cloudflare record content")}})}async function jse(e,t,r){let o=Rc(await Tc(e,`https://api.github.com/repos/${r}`,{headers:nj(t)},"GitHub repository lookup"));if(typeof o.archived!=="boolean")throw Error(`Invalid repository archive state for ${r}`);return{archived:o.archived}}async function Tc(e,t,r,o,n=!1){let i=await e(t,r),s=await i.text();if(!i.ok)throw Error(`${o} failed (${i.status}): ${s}`);if(!s&&n)return{};try{return JSON.parse(s)}catch{throw Error(`${o} returned an invalid JSON response`)}}function nj(e){return{Accept:"application/vnd.github+json",Authorization:`Bearer ${e}`,"Content-Type":"application/json","X-GitHub-Api-Version":"2022-11-28"}}function oj(e){return{Authorization:`Bearer ${e}`}}function pg(e,t){let r=e[t];if(!r)throw Error(`Missing required environment variable: ${t}`);return r}function Rc(e){if(!ks(e))throw Error("Provider returned an unexpected payload");return e}function tj(e){return ks(e)?e:void 0}function hd(e,t){if(typeof e!=="string"||e.length===0)throw Error(`Missing ${t}`);return e}function Zse(e,t){if(typeof e!=="number")throw Error(`Missing ${t}`);return e}async function Use(e){try{return await Ase(e),!0}catch{return!1}}async function PI(e,t){for(let r of t)for(let o of[So(e,"users",`${r}.yaml`),So(e,"users",`${r}.secrets.yaml.age`),So(e,"users",r)])if(await Use(o))throw Error(`Offboarded user state remains: ${Ose(o)}`)}var zI=v(()=>{Ac();Hr();fk();uc();Bn()});function DI(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function vt(e,t=""){if(typeof e!=="number"){let r=t&&`"${t}" `;throw TypeError(`${r}expected number, got ${typeof e}`)}if(!Number.isSafeInteger(e)||e<0){let r=t&&`"${t}" `;throw RangeError(`${r}expected integer >= 0, got ${e}`)}}function Ft(e,t,r=""){let o=DI(e),n=e?.length,i=t!==void 0;if(!o||i&&n!==t){let s=r&&`"${r}" `,a=i?` of length ${t}`:"",c=o?`length=${n}`:`type=${typeof e}`,u=s+"expected Uint8Array"+a+", got "+c;if(!o)throw TypeError(u);throw RangeError(u)}return e}function wo(e){if(typeof e!=="function"||typeof e.create!=="function")throw TypeError("Hash must wrapped by utils.createHasher");if(vt(e.outputLen),vt(e.blockLen),e.outputLen<1)throw Error('"outputLen" must be >= 1');if(e.blockLen<1)throw Error('"blockLen" must be >= 1')}function $c(e,t=!0){if(e.destroyed)throw Error("Hash instance has been destroyed");if(t&&e.finished)throw Error("Hash#digest() has already been called")}function fg(e,t){Ft(e,void 0,"digestInto() output");let r=t.outputLen;if(e.length<r)throw RangeError('"digestInto() output" expected to be of length >='+r)}function mg(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function hr(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Oc(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function hn(e,t){return e<<32-t|e>>>t}function Fe(e,t){return e<<t|e>>>32-t>>>0}function Qse(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function Yse(e){for(let t=0;t<e.length;t++)e[t]=Qse(e[t]);return e}function hg(e){if(Ft(e),mj)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=Xse[e[r]];return t}function fj(e){if(e>=vo._0&&e<=vo._9)return e-vo._0;if(e>=vo.A&&e<=vo.F)return e-(vo.A-10);if(e>=vo.a&&e<=vo.f)return e-(vo.a-10);return}function yd(e){if(typeof e!=="string")throw TypeError("hex string expected, got "+typeof e);if(mj)try{return Uint8Array.fromHex(e)}catch(n){if(n instanceof SyntaxError)throw RangeError(n.message);throw n}let t=e.length,r=t/2;if(t%2)throw RangeError("hex string expected, got unpadded hex of length "+t);let o=new Uint8Array(r);for(let n=0,i=0;n<r;n++,i+=2){let s=fj(e.charCodeAt(i)),a=fj(e.charCodeAt(i+1));if(s===void 0||a===void 0){let c=e[i]+e[i+1];throw RangeError('hex string expected, got non-hex character "'+c+'" at index '+i)}o[n]=s*16+a}return o}function eae(e){if(typeof e!=="string")throw TypeError("string expected");return new Uint8Array(new TextEncoder().encode(e))}function BI(e,t=""){if(typeof e==="string")return eae(e);return Ft(e,void 0,t)}function jI(...e){let t=0;for(let o=0;o<e.length;o++){let n=e[o];Ft(n),t+=n.length}let r=new Uint8Array(t);for(let o=0,n=0;o<e.length;o++){let i=e[o];r.set(i,n),n+=i.length}return r}function gg(e,t){if(t!==void 0&&{}.toString.call(t)!=="[object Object]")throw TypeError("options must be object or undefined");return Object.assign(e,t)}function ZI(e,t={}){let r=(n,i)=>e(i).update(n).digest(),o=e(void 0);return r.outputLen=o.outputLen,r.blockLen=o.blockLen,r.canXOF=o.canXOF,r.create=(n)=>e(n),Object.assign(r,t),Object.freeze(r)}function xo(e=32){vt(e,"bytesLength");let t=typeof globalThis==="object"?globalThis.crypto:null;if(typeof t?.getRandomValues!=="function")throw Error("crypto.getRandomValues must be defined");if(e>65536)throw RangeError(`"bytesLength" expected <= 65536, got ${e}`);return t.getRandomValues(new Uint8Array(e))}var Gse,LI,mj,Xse,vo,UI=(e)=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});var Gr=v(()=>{Gse=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)();LI=Gse?(e)=>e:Yse,mj=(()=>typeof Uint8Array.from([]).toHex==="function"&&typeof Uint8Array.fromHex==="function")(),Xse=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));vo={_0:48,_9:57,A:65,F:70,a:97,f:102}});class MI{oHash;iHash;blockLen;outputLen;canXOF=!1;finished=!1;destroyed=!1;constructor(e,t){if(wo(e),Ft(t,void 0,"key"),this.iHash=e.create(),typeof this.iHash.update!=="function")throw Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let r=this.blockLen,o=new Uint8Array(r);o.set(t.length>r?e.create().update(t).digest():t);for(let n=0;n<o.length;n++)o[n]^=54;this.iHash.update(o),this.oHash=e.create();for(let n=0;n<o.length;n++)o[n]^=106;this.oHash.update(o),hr(o)}update(e){return $c(this),this.iHash.update(e),this}digestInto(e){$c(this),fg(e,this),this.finished=!0;let t=e.subarray(0,this.outputLen);this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||=Object.create(Object.getPrototypeOf(this),{});let{oHash:t,iHash:r,finished:o,destroyed:n,blockLen:i,outputLen:s}=this;return e=e,e.finished=o,e.destroyed=n,e.blockLen=i,e.outputLen=s,e.oHash=t._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}var Mn;var bd=v(()=>{Gr();Mn=(()=>{let e=(t,r,o)=>new MI(t,r).update(o).digest();return e.create=(t,r)=>new MI(t,r),e})()});function Sd(e,t,r){if(wo(e),r===void 0)r=new Uint8Array(e.outputLen);return Mn(e,r,t)}function FI(e,t,r,o=32){wo(e),vt(o,"length"),Ft(t,void 0,"prk");let n=e.outputLen;if(t.length<n)throw Error('"prk" must be at least HashLen octets');if(o>255*n)throw Error("Length must be <= 255*HashLen");let i=Math.ceil(o/n);if(r===void 0)r=hj;else Ft(r,void 0,"info");let s=new Uint8Array(i*n),a=Mn.create(e,t),c=a._cloneInto(),u=new Uint8Array(a.outputLen);for(let d=0;d<i;d++)qI[0]=d+1,c.update(d===0?hj:u).update(r).update(qI).digestInto(u),s.set(u,n*d),a._cloneInto(c);return a.destroy(),c.destroy(),hr(u,qI),s.slice(0,o)}var qI,hj,xi=(e,t,r,o,n)=>FI(e,Sd(e,t,r),o,n);var KI=v(()=>{bd();Gr();qI=Uint8Array.of(0),hj=Uint8Array.of()});function gj(e,t,r){return e&t^~e&r}function yj(e,t,r){return e&t^e&r^t&r}class yg{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,t,r,o){this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=o,this.buffer=new Uint8Array(e),this.view=Oc(this.buffer)}update(e){$c(this),Ft(e);let{view:t,buffer:r,blockLen:o}=this,n=e.length;for(let i=0;i<n;){let s=Math.min(o-this.pos,n-i);if(s===o){let a=Oc(e);for(;o<=n-i;i+=o)this.process(a,i);continue}if(r.set(e.subarray(i,i+s),this.pos),this.pos+=s,i+=s,this.pos===o)this.process(t,0),this.pos=0}return this.length+=e.length,this.roundClean(),this}digestInto(e){$c(this),fg(e,this),this.finished=!0;let{buffer:t,view:r,blockLen:o,isLE:n}=this,{pos:i}=this;if(t[i++]=128,hr(this.buffer.subarray(i)),this.padOffset>o-i)this.process(r,0),i=0;for(let d=i;d<o;d++)t[d]=0;r.setBigUint64(o-8,BigInt(this.length*8),n),this.process(r,0);let s=Oc(e),a=this.outputLen;if(a%4)throw Error("_sha2: outputLen must be aligned to 32bit");let c=a/4,u=this.get();if(c>u.length)throw Error("_sha2: outputLen bigger than state");for(let d=0;d<c;d++)s.setUint32(4*d,u[d],n)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){e||=new this.constructor,e.set(...this.get());let{blockLen:t,buffer:r,length:o,finished:n,destroyed:i,pos:s}=this;if(e.destroyed=i,e.finished=n,e.length=o,e.pos=s,o%t)e.buffer.set(r);return e}clone(){return this._cloneInto()}}var _o,Kt;var bj=v(()=>{Gr();_o=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Kt=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209])});function tae(e,t=!1){if(t)return{h:Number(e&bg),l:Number(e>>Sj&bg)};return{h:Number(e>>Sj&bg)|0,l:Number(e&bg)|0}}function vj(e,t=!1){let r=e.length,o=new Uint32Array(r),n=new Uint32Array(r);for(let i=0;i<r;i++){let{h:s,l:a}=tae(e[i],t);[o[i],n[i]]=[s,a]}return[o,n]}function qn(e,t,r,o){let n=(t>>>0)+(o>>>0);return{h:e+r+(n/4294967296|0)|0,l:n|0}}var bg,Sj,HI=(e,t,r)=>e>>>r,JI=(e,t,r)=>e<<32-r|t>>>r,Ds=(e,t,r)=>e>>>r|t<<32-r,Ls=(e,t,r)=>e<<32-r|t>>>r,vd=(e,t,r)=>e<<64-r|t>>>r-32,wd=(e,t,r)=>e>>>r-32|t<<64-r,wj=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),xj=(e,t,r,o)=>t+r+o+(e/4294967296|0)|0,_j=(e,t,r,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(o>>>0),Ej=(e,t,r,o,n)=>t+r+o+n+(e/4294967296|0)|0,kj=(e,t,r,o,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(o>>>0)+(n>>>0),Ij=(e,t,r,o,n,i)=>t+r+o+n+i+(e/4294967296|0)|0;var Aj=v(()=>{bg=BigInt(4294967295),Sj=BigInt(32)});var nae,_i,Tj,Rj,$j,oae,iae,Ei,ki,Oj,Cj,wt,Sg;var Cc=v(()=>{bj();Aj();Gr();nae=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),_i=new Uint32Array(64);Tj=class Tj extends yg{constructor(e){super(64,e,8,!1)}get(){let{A:e,B:t,C:r,D:o,E:n,F:i,G:s,H:a}=this;return[e,t,r,o,n,i,s,a]}set(e,t,r,o,n,i,s,a){this.A=e|0,this.B=t|0,this.C=r|0,this.D=o|0,this.E=n|0,this.F=i|0,this.G=s|0,this.H=a|0}process(e,t){for(let d=0;d<16;d++,t+=4)_i[d]=e.getUint32(t,!1);for(let d=16;d<64;d++){let p=_i[d-15],m=_i[d-2],h=hn(p,7)^hn(p,18)^p>>>3,b=hn(m,17)^hn(m,19)^m>>>10;_i[d]=b+_i[d-7]+h+_i[d-16]|0}let{A:r,B:o,C:n,D:i,E:s,F:a,G:c,H:u}=this;for(let d=0;d<64;d++){let p=hn(s,6)^hn(s,11)^hn(s,25),m=u+p+gj(s,a,c)+nae[d]+_i[d]|0,b=(hn(r,2)^hn(r,13)^hn(r,22))+yj(r,o,n)|0;u=c,c=a,a=s,s=i+m|0,i=n,n=o,o=r,r=m+b|0}r=r+this.A|0,o=o+this.B|0,n=n+this.C|0,i=i+this.D|0,s=s+this.E|0,a=a+this.F|0,c=c+this.G|0,u=u+this.H|0,this.set(r,o,n,i,s,a,c,u)}roundClean(){hr(_i)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),hr(this.buffer)}};Rj=class Rj extends Tj{A=_o[0]|0;B=_o[1]|0;C=_o[2]|0;D=_o[3]|0;E=_o[4]|0;F=_o[5]|0;G=_o[6]|0;H=_o[7]|0;constructor(){super(32)}};$j=(()=>vj(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map((e)=>BigInt(e))))(),oae=(()=>$j[0])(),iae=(()=>$j[1])(),Ei=new Uint32Array(80),ki=new Uint32Array(80);Oj=class Oj extends yg{constructor(e){super(128,e,16,!1)}get(){let{Ah:e,Al:t,Bh:r,Bl:o,Ch:n,Cl:i,Dh:s,Dl:a,Eh:c,El:u,Fh:d,Fl:p,Gh:m,Gl:h,Hh:b,Hl:y}=this;return[e,t,r,o,n,i,s,a,c,u,d,p,m,h,b,y]}set(e,t,r,o,n,i,s,a,c,u,d,p,m,h,b,y){this.Ah=e|0,this.Al=t|0,this.Bh=r|0,this.Bl=o|0,this.Ch=n|0,this.Cl=i|0,this.Dh=s|0,this.Dl=a|0,this.Eh=c|0,this.El=u|0,this.Fh=d|0,this.Fl=p|0,this.Gh=m|0,this.Gl=h|0,this.Hh=b|0,this.Hl=y|0}process(e,t){for(let _=0;_<16;_++,t+=4)Ei[_]=e.getUint32(t),ki[_]=e.getUint32(t+=4);for(let _=16;_<80;_++){let A=Ei[_-15]|0,O=ki[_-15]|0,L=Ds(A,O,1)^Ds(A,O,8)^HI(A,O,7),z=Ls(A,O,1)^Ls(A,O,8)^JI(A,O,7),H=Ei[_-2]|0,P=ki[_-2]|0,W=Ds(H,P,19)^vd(H,P,61)^HI(H,P,6),ee=Ls(H,P,19)^wd(H,P,61)^JI(H,P,6),j=_j(z,ee,ki[_-7],ki[_-16]),R=Ej(j,L,W,Ei[_-7],Ei[_-16]);Ei[_]=R|0,ki[_]=j|0}let{Ah:r,Al:o,Bh:n,Bl:i,Ch:s,Cl:a,Dh:c,Dl:u,Eh:d,El:p,Fh:m,Fl:h,Gh:b,Gl:y,Hh:S,Hl:x}=this;for(let _=0;_<80;_++){let A=Ds(d,p,14)^Ds(d,p,18)^vd(d,p,41),O=Ls(d,p,14)^Ls(d,p,18)^wd(d,p,41),L=d&m^~d&b,z=p&h^~p&y,H=kj(x,O,z,iae[_],ki[_]),P=Ij(H,S,A,L,oae[_],Ei[_]),W=H|0,ee=Ds(r,o,28)^vd(r,o,34)^vd(r,o,39),j=Ls(r,o,28)^wd(r,o,34)^wd(r,o,39),R=r&n^r&s^n&s,B=o&i^o&a^i&a;S=b|0,x=y|0,b=m|0,y=h|0,m=d|0,h=p|0,{h:d,l:p}=qn(c|0,u|0,P|0,W|0),c=s|0,u=a|0,s=n|0,a=i|0,n=r|0,i=o|0;let k=wj(W,j,B);r=xj(k,P,ee,R),o=k|0}({h:r,l:o}=qn(this.Ah|0,this.Al|0,r|0,o|0)),{h:n,l:i}=qn(this.Bh|0,this.Bl|0,n|0,i|0),{h:s,l:a}=qn(this.Ch|0,this.Cl|0,s|0,a|0),{h:c,l:u}=qn(this.Dh|0,this.Dl|0,c|0,u|0),{h:d,l:p}=qn(this.Eh|0,this.El|0,d|0,p|0),{h:m,l:h}=qn(this.Fh|0,this.Fl|0,m|0,h|0),{h:b,l:y}=qn(this.Gh|0,this.Gl|0,b|0,y|0),{h:S,l:x}=qn(this.Hh|0,this.Hl|0,S|0,x|0),this.set(r,o,n,i,s,a,c,u,d,p,m,h,b,y,S,x)}roundClean(){hr(Ei,ki)}destroy(){this.destroyed=!0,hr(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};Cj=class Cj extends Oj{Ah=Kt[0]|0;Al=Kt[1]|0;Bh=Kt[2]|0;Bl=Kt[3]|0;Ch=Kt[4]|0;Cl=Kt[5]|0;Dh=Kt[6]|0;Dl=Kt[7]|0;Eh=Kt[8]|0;El=Kt[9]|0;Fh=Kt[10]|0;Fl=Kt[11]|0;Gh=Kt[12]|0;Gl=Kt[13]|0;Hh=Kt[14]|0;Hl=Kt[15]|0;constructor(){super(64)}};wt=ZI(()=>new Rj,UI(1)),Sg=ZI(()=>new Cj,UI(3))});function Eg(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function GI(e){if(!Eg(e))throw TypeError("Uint8Array expected")}function Lj(e,t){if(!Array.isArray(t))return!1;if(t.length===0)return!0;if(e)return t.every((r)=>typeof r==="string");else return t.every((r)=>Number.isSafeInteger(r))}function Bj(e){if(typeof e!=="function")throw TypeError("function expected");return!0}function Ii(e,t){if(typeof t!=="string")throw TypeError(`${e}: string expected`);return!0}function _d(e){if(typeof e!=="number")throw TypeError(`number expected, got ${typeof e}`);if(!Number.isSafeInteger(e))throw RangeError(`invalid integer: ${e}`)}function wg(e){if(!Array.isArray(e))throw TypeError("array expected")}function xg(e,t){if(!Lj(!0,t))throw TypeError(`${e}: array of strings expected`)}function QI(e,t){if(!Lj(!1,t))throw TypeError(`${e}: array of numbers expected`)}function Nr(...e){let t=(i)=>i,r=(i,s)=>(a)=>i(s(a)),o=e.map((i)=>i.encode).reduceRight(r,t),n=e.map((i)=>i.decode).reduce(r,t);return{encode:o,decode:n}}function Dr(e){let t=typeof e==="string"?e.split(""):e,r=t.length;xg("alphabet",t);let o=new Map(t.map((n,i)=>[n,i]));return{encode:(n)=>(wg(n),n.map((i)=>{if(!Number.isSafeInteger(i)||i<0||i>=r)throw Error(`alphabet.encode: digit index outside alphabet "${i}". Allowed: ${e}`);return t[i]})),decode:(n)=>(wg(n),n.map((i)=>{Ii("alphabet.decode",i);let s=o.get(i);if(s===void 0)throw Error(`Unknown letter: "${i}". Allowed: ${e}`);return s}))}}function Lr(e=""){return Ii("join",e),{encode:(t)=>(xg("join.decode",t),t.join(e)),decode:(t)=>(Ii("join.decode",t),t.split(e))}}function kg(e,t="="){return _d(e),Ii("padding",t),{encode(r){xg("padding.encode",r);while(r.length*e%8)r.push(t);return r},decode(r){xg("padding.decode",r);let o=r.length;if(o*e%8)throw Error("padding: invalid, string should have whole number of bytes");for(;o>0&&r[o-1]===t;o--)if((o-1)*e%8===0)throw Error("padding: invalid, string has too much padding");return r.slice(0,o)}}}function jj(e){return Bj(e),{encode:(t)=>t,decode:(t)=>e(t)}}function Pj(e,t,r){if(t<2)throw RangeError(`convertRadix: invalid from=${t}, base cannot be less than 2`);if(r<2)throw RangeError(`convertRadix: invalid to=${r}, base cannot be less than 2`);if(wg(e),!e.length)return[];let o=0,n=[],i=Array.from(e,(a)=>{if(_d(a),a<0||a>=t)throw Error(`invalid integer: ${a}`);return a}),s=i.length;while(!0){let a=0,c=!0;for(let u=o;u<s;u++){let d=i[u],p=t*a,m=p+d;if(!Number.isSafeInteger(m)||p/t!==a||m-d!==p)throw Error("convertRadix: carry overflow");let h=m/r;a=m%r;let b=Math.floor(h);if(i[u]=b,!Number.isSafeInteger(b)||b*r+a!==m)throw Error("convertRadix: carry overflow");if(!c)continue;else if(!b)o=u;else c=!1}if(n.push(a),c)break}for(let a=0;a<e.length-1&&e[a]===0;a++)n.push(0);return n.reverse()}function VI(e,t,r,o){if(wg(e),t<=0||t>32)throw RangeError(`convertRadix2: wrong from=${t}`);if(r<=0||r>32)throw RangeError(`convertRadix2: wrong to=${r}`);if(_g(t,r)>32)throw Error(`convertRadix2: carry overflow from=${t} to=${r} carryBits=${_g(t,r)}`);let n=0,i=0,s=vg[t],a=vg[r]-1,c=[];for(let u of e){if(_d(u),u>=s)throw Error(`convertRadix2: invalid data word=${u} from=${t}`);if(n=n<<t|u,i+t>32)throw Error(`convertRadix2: carry overflow pos=${i} from=${t}`);i+=t;for(;i>=r;i-=r)c.push((n>>i-r&a)>>>0);let d=vg[i];if(d===void 0)throw Error("invalid carry");n&=d-1}if(n=n<<r-i&a,!o&&i>=t)throw Error("Excess padding");if(!o&&n>0)throw Error(`Non-zero padding: ${n}`);if(o&&i>0)c.push(n>>>0);return c}function sae(e){_d(e);let t=256;return{encode:(r)=>{if(!Eg(r))throw TypeError("radix.encode input should be Uint8Array");return Pj(Array.from(r),t,e)},decode:(r)=>(QI("radix.decode",r),Uint8Array.from(Pj(r,e,t)))}}function Qr(e,t=!1){if(_d(e),e<=0||e>32)throw RangeError("radix2: bits should be in (0..32]");if(_g(8,e)>32||_g(e,8)>32)throw RangeError("radix2: carry overflow");return{encode:(r)=>{if(!Eg(r))throw TypeError("radix2.encode input should be Uint8Array");return VI(Array.from(r),8,e,!t)},decode:(r)=>(QI("radix2.decode",r),Uint8Array.from(VI(r,e,8,t)))}}function zj(e){return Bj(e),function(...t){try{return e.apply(null,t)}catch(r){}}}function xd(e){let t=e>>25,r=(e&33554431)<<5;for(let o=0;o<Nj.length;o++)if((t>>o&1)===1)r^=Nj[o];return r}function Dj(e,t,r=1){let o=e.length,n=1;for(let i=0;i<o;i++){let s=e.charCodeAt(i);if(s<33||s>126)throw Error(`Invalid prefix (${e})`);n=xd(n)^s>>5}n=xd(n);for(let i=0;i<o;i++)n=xd(n)^e.charCodeAt(i)&31;for(let i of t)n=xd(n)^i;for(let i=0;i<6;i++)n=xd(n);return n^=r,WI.encode(VI([n%vg[30]],30,5,!1))}function qj(e){let t=e==="bech32"?1:734539939,r=Qr(5),o=r.decode,n=r.encode,i=zj(o);function s(p,m,h=90){if(Ii("bech32.encode prefix",p),Eg(m))m=Array.from(m);QI("bech32.encode",m);let b=p.length;if(b===0)throw TypeError(`Invalid prefix length ${b}`);let y=b+7+m.length;if(h!==!1&&y>h)throw TypeError(`Length ${y} exceeds limit ${h}`);let S=p.toLowerCase(),x=Dj(S,m,t);return`${S}1${WI.encode(m)}${x}`}function a(p,m=90){Ii("bech32.decode input",p);let h=p.length;if(h<8||m!==!1&&h>m)throw TypeError(`invalid string length: ${h} (${p}). Expected (8..${m})`);let b=p.toLowerCase();if(p!==b&&p!==p.toUpperCase())throw Error("String must be lowercase or uppercase");let y=b.lastIndexOf("1");if(y===0||y===-1)throw Error('Letter "1" must be present between prefix and data only');let S=b.slice(0,y),x=b.slice(y+1);if(x.length<6)throw Error("Data must be at least 6 characters long");let _=WI.decode(x).slice(0,-6),A=Dj(S,_,t);if(!x.endsWith(A))throw Error(`Invalid checksum in ${p}: expected "${A}"`);return{prefix:S,words:_}}let c=zj(a);function u(p){let{prefix:m,words:h}=a(p,!1);return{prefix:m,words:h,bytes:o(h)}}function d(p,m){return s(p,n(m))}return{encode:s,decode:a,encodeFromBytes:d,decodeToBytes:u,decodeUnsafe:c,fromWords:o,fromWordsUnsafe:i,toWords:n}}var Zj=(e,t)=>t===0?e:Zj(t,e%t),_g=(e,t)=>e+(t-Zj(e,t)),vg,$$e,O$e,C$e,P$e,z$e,N$e,Uj,aae,Mj=(e,t)=>{Ii("base64",e);let r=t?"base64url":"base64";if(e.length>0&&aae.test(e))throw Error("invalid base64");return Uint8Array.fromBase64(e,{alphabet:r,lastChunkHandling:"strict"})},YI,tr,D$e,L$e,XI=(e)=>Nr(sae(58),Dr(e),Lr("")),B$e,j$e,Z$e,WI,Nj,Br,U$e,cae,lae,M$e;var Ed=v(()=>{/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */vg=(()=>{let e=[];for(let t=0;t<40;t++)e.push(2**t);return e})();$$e=Object.freeze(Nr(Qr(4),Dr("0123456789ABCDEF"),Lr(""))),O$e=Object.freeze(Nr(Qr(5),Dr("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),kg(5),Lr(""))),C$e=Object.freeze(Nr(Qr(5),Dr("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),Lr(""))),P$e=Object.freeze(Nr(Qr(5),Dr("0123456789ABCDEFGHIJKLMNOPQRSTUV"),kg(5),Lr(""))),z$e=Object.freeze(Nr(Qr(5),Dr("0123456789ABCDEFGHIJKLMNOPQRSTUV"),Lr(""))),N$e=Object.freeze(Nr(Qr(5),Dr("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),Lr(""),jj((e)=>e.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1")))),Uj=(()=>typeof Uint8Array.from([]).toBase64==="function"&&typeof Uint8Array.fromBase64==="function")(),aae=/[\t\n\f\r ]/,YI=Object.freeze(Uj?{encode(e){return GI(e),e.toBase64()},decode(e){return Mj(e,!1)}}:Nr(Qr(6),Dr("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),kg(6),Lr(""))),tr=Object.freeze(Nr(Qr(6),Dr("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),Lr(""))),D$e=Object.freeze(Uj?{encode(e){return GI(e),e.toBase64({alphabet:"base64url"})},decode(e){return Mj(e,!0)}}:Nr(Qr(6),Dr("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),kg(6),Lr(""))),L$e=Object.freeze(Nr(Qr(6),Dr("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),Lr(""))),B$e=Object.freeze(XI("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")),j$e=Object.freeze(XI("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ")),Z$e=Object.freeze(XI("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz")),WI=Nr(Dr("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),Lr("")),Nj=[996825010,642813549,513874426,1027748829,705979059];Br=Object.freeze(qj("bech32")),U$e=Object.freeze(qj("bech32m")),cae=(()=>typeof Uint8Array.from([]).toHex==="function"&&typeof Uint8Array.fromHex==="function")(),lae={encode(e){return GI(e),e.toHex()},decode(e){return Ii("hex",e),Uint8Array.fromHex(e)}},M$e=Object.freeze(cae?lae:Nr(Qr(4),Dr("0123456789abcdef"),Lr(""),jj((e)=>{if(typeof e!=="string"||e.length%2!==0)throw TypeError(`hex.decode: expected string, got ${typeof e} with length ${e.length}`);return e.toLowerCase()})))});function dae(e,t,r,o){wo(e);let n=gg({dkLen:32,asyncTick:10},o),{c:i,dkLen:s,asyncTick:a}=n;if(vt(i,"c"),vt(s,"dkLen"),vt(a,"asyncTick"),i<1)throw Error("iterations (c) must be >= 1");if(s<1)throw Error('"dkLen" must be >= 1');if(s>4294967295*e.outputLen)throw Error("derived key too long");let c=BI(t,"password"),u=BI(r,"salt"),d=new Uint8Array(s),p=Mn.create(e,c),m=p._cloneInto().update(u);return{c:i,dkLen:s,asyncTick:a,DK:d,PRF:p,PRFSalt:m}}function pae(e,t,r,o,n){if(e.destroy(),t.destroy(),o)o.destroy();return hr(n),r}function eA(e,t,r,o){let{c:n,dkLen:i,DK:s,PRF:a,PRFSalt:c}=dae(e,t,r,o),u,d=new Uint8Array(4),p=Oc(d),m=new Uint8Array(a.outputLen);for(let h=1,b=0;b<i;h++,b+=a.outputLen){let y=s.subarray(b,b+a.outputLen);p.setInt32(0,h,!1),(u=c._cloneInto(u)).update(d).digestInto(m),y.set(m.subarray(0,y.length));for(let S=1;S<n;S++){a._cloneInto(u).update(m).digestInto(m);for(let x=0;x<y.length;x++)y[x]^=m[x]}}return pae(a,c,s,u,m)}var Fj=v(()=>{bd();Gr()});function Kj(e,t,r,o,n,i){let s=e[t++]^r[o++],a=e[t++]^r[o++],c=e[t++]^r[o++],u=e[t++]^r[o++],d=e[t++]^r[o++],p=e[t++]^r[o++],m=e[t++]^r[o++],h=e[t++]^r[o++],b=e[t++]^r[o++],y=e[t++]^r[o++],S=e[t++]^r[o++],x=e[t++]^r[o++],_=e[t++]^r[o++],A=e[t++]^r[o++],O=e[t++]^r[o++],L=e[t++]^r[o++],z=s,H=a,P=c,W=u,ee=d,j=p,R=m,B=h,k=b,T=y,I=S,q=x,N=_,J=A,G=O,re=L;for(let ae=0;ae<8;ae+=2)ee^=Fe(z+N|0,7),k^=Fe(ee+z|0,9),N^=Fe(k+ee|0,13),z^=Fe(N+k|0,18),T^=Fe(j+H|0,7),J^=Fe(T+j|0,9),H^=Fe(J+T|0,13),j^=Fe(H+J|0,18),G^=Fe(I+R|0,7),P^=Fe(G+I|0,9),R^=Fe(P+G|0,13),I^=Fe(R+P|0,18),W^=Fe(re+q|0,7),B^=Fe(W+re|0,9),q^=Fe(B+W|0,13),re^=Fe(q+B|0,18),H^=Fe(z+W|0,7),P^=Fe(H+z|0,9),W^=Fe(P+H|0,13),z^=Fe(W+P|0,18),R^=Fe(j+ee|0,7),B^=Fe(R+j|0,9),ee^=Fe(B+R|0,13),j^=Fe(ee+B|0,18),q^=Fe(I+T|0,7),k^=Fe(q+I|0,9),T^=Fe(k+q|0,13),I^=Fe(T+k|0,18),N^=Fe(re+G|0,7),J^=Fe(N+re|0,9),G^=Fe(J+N|0,13),re^=Fe(G+J|0,18);n[i++]=s+z|0,n[i++]=a+H|0,n[i++]=c+P|0,n[i++]=u+W|0,n[i++]=d+ee|0,n[i++]=p+j|0,n[i++]=m+R|0,n[i++]=h+B|0,n[i++]=b+k|0,n[i++]=y+T|0,n[i++]=S+I|0,n[i++]=x+q|0,n[i++]=_+N|0,n[i++]=A+J|0,n[i++]=O+G|0,n[i++]=L+re|0}function tA(e,t,r,o,n){let i=o+0,s=o+16*n;for(let a=0;a<16;a++)r[s+a]=e[t+(2*n-1)*16+a];for(let a=0;a<n;a++,i+=16,t+=16){if(Kj(r,s,e,t,r,i),a>0)s+=16;Kj(r,i,e,t+=16,r,s)}}function fae(e,t,r){let o=gg({dkLen:32,asyncTick:10,maxmem:1073742848},r),{N:n,r:i,p:s,dkLen:a,asyncTick:c,maxmem:u,onProgress:d}=o;if(vt(n,"N"),vt(i,"r"),vt(s,"p"),vt(a,"dkLen"),vt(c,"asyncTick"),vt(u,"maxmem"),d!==void 0&&typeof d!=="function")throw Error("progressCb must be a function");let p=128*i,m=p/4,h=Math.pow(2,32);if(n<=1||(n&n-1)!==0||n>h)throw Error('"N" expected a power of 2, and 2^1 <= N <= 2^32');if(s<1||s>(h-1)*32/p)throw Error('"p" expected integer 1..((2^32 - 1) * 32) / (128 * r)');if(a<1||a>(h-1)*32)throw Error('"dkLen" expected integer 1..(2^32 - 1) * 32');let b=p*(n+s+1);if(b>u)throw Error('"maxmem" limit was hit: memUsed(128*r*(N+p+1))='+b+", maxmem="+u);let y=eA(wt,e,t,{c:1,dkLen:p*s}),S=mg(y),x=mg(new Uint8Array(p*n)),_=mg(new Uint8Array(p)),A=()=>{};if(d){let O=2*n*s,L=Math.max(Math.floor(O/1e4),1),z=0;A=()=>{if(z++,d&&(!(z%L)||z===O))d(z/O)}}return{N:n,r:i,p:s,dkLen:a,blockSize32:m,V:x,B32:S,B:y,tmp:_,blockMixCb:A,asyncTick:c}}function mae(e,t,r,o,n){let i=eA(wt,e,r,{c:1,dkLen:t});return hr(r,o,n),i}function rA(e,t,r){let{N:o,r:n,p:i,dkLen:s,blockSize32:a,V:c,B32:u,B:d,tmp:p,blockMixCb:m}=fae(e,t,r);LI(u);for(let h=0;h<i;h++){let b=a*h;for(let y=0;y<a;y++)c[y]=u[b+y];for(let y=0,S=0;y<o-1;y++)tA(c,S,c,S+=a,n),m();tA(c,(o-1)*a,u,b,n),m();for(let y=0;y<o;y++){let S=(u[b+a-16]&o-1)>>>0;for(let x=0;x<a;x++)p[x]=u[b+x]^c[S*a+x];tA(p,0,u,b,n),m()}}return LI(u),mae(e,s,d,c,p)}var Hj=v(()=>{Fj();Cc();Gr()});function hae(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function Ig(e){if(typeof e!=="boolean")throw TypeError(`boolean expected, not ${e}`)}function Pc(e){if(typeof e!=="number")throw TypeError("number expected, got "+typeof e);if(!Number.isSafeInteger(e)||e<0)throw RangeError("positive integer expected, got "+e)}function Ct(e,t,r=""){let o=hae(e),n=e?.length,i=t!==void 0;if(!o||i&&n!==t){let s=r&&`"${r}" `,a=i?` of length ${t}`:"",c=o?`length=${n}`:`type=${typeof e}`,u=s+"expected Uint8Array"+a+", got "+c;if(!o)throw TypeError(u);throw RangeError(u)}return e}function nA(e,t=!0){if(e.destroyed)throw Error("Hash instance has been destroyed");if(t&&e.finished)throw Error("Hash#digest() has already been called")}function Jj(e,t,r=!1){Ct(e,void 0,"output");let o=t.outputLen;if(e.length<o)throw RangeError("digestInto() expects output buffer of length at least "+o);if(r&&!zc(e))throw Error("invalid output, must be aligned")}function Fn(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function gn(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function gae(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Vj(e,t){if(t==null||typeof t!=="object")throw Error("options must be defined");return Object.assign(e,t)}function Wj(e,t){if(e.length!==t.length)return!1;let r=0;for(let o=0;o<e.length;o++)r|=e[o]^t[o];return r===0}function Gj(e,t,r){let o=t,n=r||(()=>[]),i=(a,c)=>o(c,...n(a)).update(a).digest(),s=o(new Uint8Array(e),...n(new Uint8Array(0)));return i.outputLen=s.outputLen,i.blockLen=s.blockLen,i.create=(a,...c)=>o(a,...c),i}function kd(e,t,r=!0){if(t===void 0)return new Uint8Array(e);if(Ct(t,void 0,"output"),t.length!==e)throw Error('"output" expected Uint8Array of length '+e+", got: "+t.length);if(r&&!zc(t))throw Error("invalid output, must be aligned");return t}function Yj(e,t,r){Pc(e),Pc(t),Ig(r);let o=new Uint8Array(16),n=gae(o);return n.setBigUint64(0,BigInt(t),r),n.setBigUint64(8,BigInt(e),r),o}function zc(e){return e.byteOffset%4===0}function Nc(e){return Uint8Array.from(Ct(e))}var Bs,yae=(e)=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255,bae=(e)=>{for(let t=0;t<e.length;t++)e[t]=yae(e[t]);return e},Eo,Qj=(e,t)=>{function r(o,...n){if(Ct(o,void 0,"key"),e.nonceLength!==void 0){let d=n[0];Ct(d,e.varSizeNonce?void 0:e.nonceLength,"nonce")}let i=e.tagLength;if(i&&n[1]!==void 0)Ct(n[1],void 0,"AAD");let s=t(o,...n),a=(d,p)=>{if(p!==void 0){if(d!==2)throw Error("cipher output not supported");Ct(p,void 0,"output")}},c=!1;return{encrypt(d,p){if(c)throw Error("cannot encrypt() twice with same key + nonce");return c=!0,Ct(d),a(s.encrypt.length,p),s.encrypt(d,p)},decrypt(d,p){if(Ct(d),i&&d.length<i)throw Error('"ciphertext" expected length bigger than tagLength='+i);return a(s.decrypt.length,p),s.decrypt(d,p)}}}return Object.assign(r,e),r};var Ag=v(()=>{/*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */Bs=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)(),Eo=Bs?(e)=>e:bae});function Ke(e,t){return e<<t|e>>>32-t}function xae(e,t,r,o,n,i,s,a){let c=n.length,u=new Uint8Array(Id),d=Fn(u),p=Bs&&zc(n)&&zc(i),m=p?Fn(n):Xj,h=p?Fn(i):Xj;if(!Bs){for(let b=0;b<c;s++){if(e(t,r,o,d,s,a),Eo(d),s>=oA)throw Error("arx: counter overflow");let y=Math.min(Id,c-b);for(let S=0,x;S<y;S++)x=b+S,i[x]=n[x]^u[S];b+=y}return}for(let b=0;b<c;s++){if(e(t,r,o,d,s,a),s>=oA)throw Error("arx: counter overflow");let y=Math.min(Id,c-b);if(p&&y===Id){let S=b/4;if(b%4!==0)throw Error("arx: invalid block position");for(let x=0,_;x<wae;x++)_=S+x,h[_]=m[_]^d[x];b+=Id;continue}for(let S=0,x;S<y;S++)x=b+S,i[x]=n[x]^u[S];b+=y}}function tZ(e,t){let{allowShortKeys:r,extendNonceFn:o,counterLength:n,counterRight:i,rounds:s}=Vj({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},t);if(typeof e!=="function")throw Error("core must be a function");return Pc(n),Pc(s),Ig(i),Ig(r),(a,c,u,d,p=0)=>{Ct(a,void 0,"key"),Ct(c,void 0,"nonce"),Ct(u,void 0,"data");let m=u.length;if(d=kd(m,d,!1),Pc(p),p<0||p>=oA)throw Error("arx: counter overflow");let h=[],b=a.length,y,S;if(b===32)h.push(y=Nc(a)),S=vae;else if(b===16&&r)y=new Uint8Array(32),y.set(a),y.set(a,16),S=Sae,h.push(y);else throw Ct(a,32,"arx key"),Error("invalid key size");if(!Bs||!zc(c))h.push(c=Nc(c));let x=Fn(y);if(o){if(c.length!==24)throw Error("arx: extended nonce must be 24 bytes");let O=c.subarray(0,16);if(Bs)o(S,x,Fn(O),x);else{let L=Eo(Uint32Array.from(S));o(L,x,Fn(O),x),gn(L),Eo(x)}c=c.subarray(16)}else if(!Bs)Eo(x);let _=16-n;if(_!==c.length)throw Error(`arx: nonce must be ${_} or 16 bytes`);if(_!==12){let O=new Uint8Array(12);O.set(c,i?0:12-c.length),c=O,h.push(c)}let A=Eo(Fn(c));try{return xae(e,S,x,A,u,d,p,s),d}finally{gn(...h)}}}var eZ=(e)=>Uint8Array.from(e.split(""),(t)=>t.charCodeAt(0)),Sae,vae,Id=64,wae=16,oA,Xj;var rZ=v(()=>{Ag();Sae=(()=>Eo(Fn(eZ("expand 16-byte k"))))(),vae=(()=>Eo(Fn(eZ("expand 32-byte k"))))();oA=(()=>4294967295)(),Xj=Uint32Array.of()});function Ht(e,t){return e[t++]&255|(e[t++]&255)<<8}class nZ{blockLen=16;outputLen=16;buffer=new Uint8Array(16);r=new Uint16Array(10);h=new Uint16Array(10);pad=new Uint16Array(8);pos=0;finished=!1;destroyed=!1;constructor(e){e=Nc(Ct(e,32,"key"));let t=Ht(e,0),r=Ht(e,2),o=Ht(e,4),n=Ht(e,6),i=Ht(e,8),s=Ht(e,10),a=Ht(e,12),c=Ht(e,14);this.r[0]=t&8191,this.r[1]=(t>>>13|r<<3)&8191,this.r[2]=(r>>>10|o<<6)&7939,this.r[3]=(o>>>7|n<<9)&8191,this.r[4]=(n>>>4|i<<12)&255,this.r[5]=i>>>1&8190,this.r[6]=(i>>>14|s<<2)&8191,this.r[7]=(s>>>11|a<<5)&8065,this.r[8]=(a>>>8|c<<8)&8191,this.r[9]=c>>>5&127;for(let u=0;u<8;u++)this.pad[u]=Ht(e,16+2*u)}process(e,t,r=!1){let o=r?0:2048,{h:n,r:i}=this,s=i[0],a=i[1],c=i[2],u=i[3],d=i[4],p=i[5],m=i[6],h=i[7],b=i[8],y=i[9],S=Ht(e,t+0),x=Ht(e,t+2),_=Ht(e,t+4),A=Ht(e,t+6),O=Ht(e,t+8),L=Ht(e,t+10),z=Ht(e,t+12),H=Ht(e,t+14),P=n[0]+(S&8191),W=n[1]+((S>>>13|x<<3)&8191),ee=n[2]+((x>>>10|_<<6)&8191),j=n[3]+((_>>>7|A<<9)&8191),R=n[4]+((A>>>4|O<<12)&8191),B=n[5]+(O>>>1&8191),k=n[6]+((O>>>14|L<<2)&8191),T=n[7]+((L>>>11|z<<5)&8191),I=n[8]+((z>>>8|H<<8)&8191),q=n[9]+(H>>>5|o),N=0,J=N+P*s+W*(5*y)+ee*(5*b)+j*(5*h)+R*(5*m);N=J>>>13,J&=8191,J+=B*(5*p)+k*(5*d)+T*(5*u)+I*(5*c)+q*(5*a),N+=J>>>13,J&=8191;let G=N+P*a+W*s+ee*(5*y)+j*(5*b)+R*(5*h);N=G>>>13,G&=8191,G+=B*(5*m)+k*(5*p)+T*(5*d)+I*(5*u)+q*(5*c),N+=G>>>13,G&=8191;let re=N+P*c+W*a+ee*s+j*(5*y)+R*(5*b);N=re>>>13,re&=8191,re+=B*(5*h)+k*(5*m)+T*(5*p)+I*(5*d)+q*(5*u),N+=re>>>13,re&=8191;let ae=N+P*u+W*c+ee*a+j*s+R*(5*y);N=ae>>>13,ae&=8191,ae+=B*(5*b)+k*(5*h)+T*(5*m)+I*(5*p)+q*(5*d),N+=ae>>>13,ae&=8191;let me=N+P*d+W*u+ee*c+j*a+R*s;N=me>>>13,me&=8191,me+=B*(5*y)+k*(5*b)+T*(5*h)+I*(5*m)+q*(5*p),N+=me>>>13,me&=8191;let be=N+P*p+W*d+ee*u+j*c+R*a;N=be>>>13,be&=8191,be+=B*s+k*(5*y)+T*(5*b)+I*(5*h)+q*(5*m),N+=be>>>13,be&=8191;let ve=N+P*m+W*p+ee*d+j*u+R*c;N=ve>>>13,ve&=8191,ve+=B*a+k*s+T*(5*y)+I*(5*b)+q*(5*h),N+=ve>>>13,ve&=8191;let Ae=N+P*h+W*m+ee*p+j*d+R*u;N=Ae>>>13,Ae&=8191,Ae+=B*c+k*a+T*s+I*(5*y)+q*(5*b),N+=Ae>>>13,Ae&=8191;let Ie=N+P*b+W*h+ee*m+j*p+R*d;N=Ie>>>13,Ie&=8191,Ie+=B*u+k*c+T*a+I*s+q*(5*y),N+=Ie>>>13,Ie&=8191;let we=N+P*y+W*b+ee*h+j*m+R*p;N=we>>>13,we&=8191,we+=B*d+k*u+T*c+I*a+q*s,N+=we>>>13,we&=8191,N=(N<<2)+N|0,N=N+J|0,J=N&8191,N=N>>>13,G+=N,n[0]=J,n[1]=G,n[2]=re,n[3]=ae,n[4]=me,n[5]=be,n[6]=ve,n[7]=Ae,n[8]=Ie,n[9]=we}finalize(){let{h:e,pad:t}=this,r=new Uint16Array(10),o=e[1]>>>13;e[1]&=8191;for(let s=2;s<10;s++)e[s]+=o,o=e[s]>>>13,e[s]&=8191;e[0]+=o*5,o=e[0]>>>13,e[0]&=8191,e[1]+=o,o=e[1]>>>13,e[1]&=8191,e[2]+=o,r[0]=e[0]+5,o=r[0]>>>13,r[0]&=8191;for(let s=1;s<10;s++)r[s]=e[s]+o,o=r[s]>>>13,r[s]&=8191;r[9]-=8192;let n=(o^1)-1;for(let s=0;s<10;s++)r[s]&=n;n=~n;for(let s=0;s<10;s++)e[s]=e[s]&n|r[s];e[0]=(e[0]|e[1]<<13)&65535,e[1]=(e[1]>>>3|e[2]<<10)&65535,e[2]=(e[2]>>>6|e[3]<<7)&65535,e[3]=(e[3]>>>9|e[4]<<4)&65535,e[4]=(e[4]>>>12|e[5]<<1|e[6]<<14)&65535,e[5]=(e[6]>>>2|e[7]<<11)&65535,e[6]=(e[7]>>>5|e[8]<<8)&65535,e[7]=(e[8]>>>8|e[9]<<5)&65535;let i=e[0]+t[0];e[0]=i&65535;for(let s=1;s<8;s++)i=(e[s]+t[s]|0)+(i>>>16)|0,e[s]=i&65535;gn(r)}update(e){nA(this),Ct(e),e=Nc(e);let{buffer:t,blockLen:r}=this,o=e.length;for(let n=0;n<o;){let i=Math.min(r-this.pos,o-n);if(i===r){for(;r<=o-n;n+=r)this.process(e,n);continue}if(t.set(e.subarray(n,n+i),this.pos),this.pos+=i,n+=i,this.pos===r)this.process(t,0,!1),this.pos=0}return this}destroy(){this.destroyed=!0,gn(this.h,this.r,this.buffer,this.pad)}digestInto(e){nA(this),Jj(e,this),this.finished=!0;let{buffer:t,h:r}=this,{pos:o}=this;if(o){t[o++]=1;for(;o<16;o++)t[o]=0;this.process(t,0,!0)}this.finalize();let n=0;for(let i=0;i<8;i++)e[n++]=r[i]>>>0,e[n++]=r[i]>>>8}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let r=e.slice(0,t);return this.destroy(),r}}var oZ;var iZ=v(()=>{Ag();oZ=Gj(32,(e)=>new nZ(e))});function _ae(e,t,r,o,n,i=20){let s=e[0],a=e[1],c=e[2],u=e[3],d=t[0],p=t[1],m=t[2],h=t[3],b=t[4],y=t[5],S=t[6],x=t[7],_=n,A=r[0],O=r[1],L=r[2],z=s,H=a,P=c,W=u,ee=d,j=p,R=m,B=h,k=b,T=y,I=S,q=x,N=_,J=A,G=O,re=L;for(let me=0;me<i;me+=2)z=z+ee|0,N=Ke(N^z,16),k=k+N|0,ee=Ke(ee^k,12),z=z+ee|0,N=Ke(N^z,8),k=k+N|0,ee=Ke(ee^k,7),H=H+j|0,J=Ke(J^H,16),T=T+J|0,j=Ke(j^T,12),H=H+j|0,J=Ke(J^H,8),T=T+J|0,j=Ke(j^T,7),P=P+R|0,G=Ke(G^P,16),I=I+G|0,R=Ke(R^I,12),P=P+R|0,G=Ke(G^P,8),I=I+G|0,R=Ke(R^I,7),W=W+B|0,re=Ke(re^W,16),q=q+re|0,B=Ke(B^q,12),W=W+B|0,re=Ke(re^W,8),q=q+re|0,B=Ke(B^q,7),z=z+j|0,re=Ke(re^z,16),I=I+re|0,j=Ke(j^I,12),z=z+j|0,re=Ke(re^z,8),I=I+re|0,j=Ke(j^I,7),H=H+R|0,N=Ke(N^H,16),q=q+N|0,R=Ke(R^q,12),H=H+R|0,N=Ke(N^H,8),q=q+N|0,R=Ke(R^q,7),P=P+B|0,J=Ke(J^P,16),k=k+J|0,B=Ke(B^k,12),P=P+B|0,J=Ke(J^P,8),k=k+J|0,B=Ke(B^k,7),W=W+ee|0,G=Ke(G^W,16),T=T+G|0,ee=Ke(ee^T,12),W=W+ee|0,G=Ke(G^W,8),T=T+G|0,ee=Ke(ee^T,7);let ae=0;o[ae++]=s+z|0,o[ae++]=a+H|0,o[ae++]=c+P|0,o[ae++]=u+W|0,o[ae++]=d+ee|0,o[ae++]=p+j|0,o[ae++]=m+R|0,o[ae++]=h+B|0,o[ae++]=b+k|0,o[ae++]=y+T|0,o[ae++]=S+I|0,o[ae++]=x+q|0,o[ae++]=_+N|0,o[ae++]=A+J|0,o[ae++]=O+G|0,o[ae++]=L+re|0}function aZ(e,t,r,o,n){if(n!==void 0)Ct(n,void 0,"AAD");let i=e(t,r,Iae),s=Yj(o.length,n?n.length:0,!0),a=oZ.create(i);if(n)sZ(a,n);sZ(a,o),a.update(s);let c=a.digest();return gn(i,s),c}var Eae,kae,sZ=(e,t)=>{e.update(t);let r=t.length%16;if(r)e.update(kae.subarray(r))},Iae,Aae=(e)=>(t,r,o)=>({encrypt(i,s){let a=i.length;s=kd(a+16,s,!1),s.set(i);let c=s.subarray(0,-16);e(t,r,c,c,1);let u=aZ(e,t,r,c,o);return s.set(u,a),gn(u),s},decrypt(i,s){s=kd(i.length-16,s,!1);let a=i.subarray(0,-16),c=i.subarray(-16),u=aZ(e,t,r,a,o);if(!Wj(c,u))throw gn(u),Error("invalid tag");return s.set(i.subarray(0,-16)),e(t,r,s,s,1),gn(u),s}}),Yr;var iA=v(()=>{rZ();iZ();Ag();Eae=tZ(_ae,{counterRight:!1,counterLength:4,allowShortKeys:!1}),kae=new Uint8Array(16),Iae=new Uint8Array(32);Yr=Qj({blockSize:64,nonceLength:12,tagLength:16},Aae(Eae))});function Dc(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Zt(e,t=""){if(!Number.isSafeInteger(e)||e<0){let r=t&&`"${t}" `;throw Error(`${r}expected integer >= 0, got ${e}`)}}function Te(e,t,r=""){let o=Dc(e),n=e?.length,i=t!==void 0;if(!o||i&&n!==t){let s=r&&`"${r}" `,a=i?` of length ${t}`:"",c=o?`length=${n}`:`type=${typeof e}`;throw Error(s+"expected Uint8Array"+a+", got "+c)}return e}function Xr(e){if(typeof e!=="function"||typeof e.create!=="function")throw Error("Hash must wrapped by utils.createHasher");Zt(e.outputLen),Zt(e.blockLen)}function Io(e,t=!0){if(e.destroyed)throw Error("Hash instance has been destroyed");if(t&&e.finished)throw Error("Hash#digest() has already been called")}function Tg(e,t){Te(e,void 0,"digestInto() output");let r=t.outputLen;if(e.length<r)throw Error('"digestInto() output" expected to be of length >='+r)}function Rg(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function kr(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function $g(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function yn(e,t){return e<<32-t|e>>>t}function Rae(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function $ae(e){for(let t=0;t<e.length;t++)e[t]=Rae(e[t]);return e}function js(e){if(Te(e),lZ)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=Oae[e[r]];return t}function cZ(e){if(e>=ko._0&&e<=ko._9)return e-ko._0;if(e>=ko.A&&e<=ko.F)return e-(ko.A-10);if(e>=ko.a&&e<=ko.f)return e-(ko.a-10);return}function Zs(e){if(typeof e!=="string")throw Error("hex string expected, got "+typeof e);if(lZ)return Uint8Array.fromHex(e);let t=e.length,r=t/2;if(t%2)throw Error("hex string expected, got unpadded hex of length "+t);let o=new Uint8Array(r);for(let n=0,i=0;n<r;n++,i+=2){let s=cZ(e.charCodeAt(i)),a=cZ(e.charCodeAt(i+1));if(s===void 0||a===void 0){let c=e[i]+e[i+1];throw Error('hex string expected, got non-hex character "'+c+'" at index '+i)}o[n]=s*16+a}return o}function kt(...e){let t=0;for(let o=0;o<e.length;o++){let n=e[o];Te(n),t+=n.length}let r=new Uint8Array(t);for(let o=0,n=0;o<e.length;o++){let i=e[o];r.set(i,n),n+=i.length}return r}function Lc(e,t={}){let r=(n,i)=>e(i).update(n).digest(),o=e(void 0);return r.outputLen=o.outputLen,r.blockLen=o.blockLen,r.create=(n)=>e(n),Object.assign(r,t),Object.freeze(r)}function Ai(e=32){let t=typeof globalThis==="object"?globalThis.crypto:null;if(typeof t?.getRandomValues!=="function")throw Error("crypto.getRandomValues must be defined");return t.getRandomValues(new Uint8Array(e))}var Tae,sA,lZ,Oae,ko,Ti=(e)=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});var jr=v(()=>{/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */Tae=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)();sA=Tae?(e)=>e:$ae,lZ=(()=>typeof Uint8Array.from([]).toHex==="function"&&typeof Uint8Array.fromHex==="function")(),Oae=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));ko={_0:48,_9:57,A:65,F:70,a:97,f:102}});function Ad(e,t=""){if(typeof e!=="boolean"){let r=t&&`"${t}" `;throw Error(r+"expected boolean, got type="+typeof e)}return e}function uZ(e){if(typeof e==="bigint"){if(!Og(e))throw Error("positive bigint expected, got "+e)}else Zt(e);return e}function Td(e){let t=uZ(e).toString(16);return t.length&1?"0"+t:t}function dZ(e){if(typeof e!=="string")throw Error("hex string expected, got "+typeof e);return e===""?cA:BigInt("0x"+e)}function Ri(e){return dZ(js(e))}function $i(e){return dZ(js(Cg(Te(e)).reverse()))}function Bc(e,t){Zt(t),e=uZ(e);let r=Zs(e.toString(16).padStart(t*2,"0"));if(r.length!==t)throw Error("number too large");return r}function Rd(e,t){return Bc(e,t).reverse()}function Cg(e){return Uint8Array.from(e)}function Oi(e){return Uint8Array.from(e,(t,r)=>{let o=t.charCodeAt(0);if(t.length!==1||o>127)throw Error(`string contains non-ASCII character "${e[r]}" with code ${o} at position ${r}`);return o})}function Cae(e,t,r){return Og(e)&&Og(t)&&Og(r)&&t<=e&&e<r}function $d(e,t,r,o){if(!Cae(t,r,o))throw Error("expected valid "+e+": "+r+" <= n < "+o+", got "+t)}function lA(e){let t;for(t=0;e>cA;e>>=aA,t+=1);return t}function pZ(e,t,r){if(Zt(e,"hashLen"),Zt(t,"qByteLen"),typeof r!=="function")throw Error("hmacFn must be a function");let o=(S)=>new Uint8Array(S),n=Uint8Array.of(),i=Uint8Array.of(0),s=Uint8Array.of(1),a=1000,c=o(e),u=o(e),d=0,p=()=>{c.fill(1),u.fill(0),d=0},m=(...S)=>r(u,kt(c,...S)),h=(S=n)=>{if(u=m(i,S),c=m(),S.length===0)return;u=m(s,S),c=m()},b=()=>{if(d++>=a)throw Error("drbg: tried max amount of iterations");let S=0,x=[];while(S<t){c=m();let _=c.slice();x.push(_),S+=c.length}return kt(...x)};return(S,x)=>{p(),h(S);let _=void 0;while(!(_=x(b())))h();return p(),_}}function Us(e,t={},r={}){if(!e||typeof e!=="object")throw Error("expected valid options object");function o(i,s,a){let c=e[i];if(a&&c===void 0)return;let u=typeof c;if(u!==s||c===null)throw Error(`param "${i}" is invalid: expected ${s}, got ${u}`)}let n=(i,s)=>Object.entries(i).forEach(([a,c])=>o(a,c,s));n(t,!1),n(r,!0)}function uA(e){let t=new WeakMap;return(r,...o)=>{let n=t.get(r);if(n!==void 0)return n;let i=e(r,...o);return t.set(r,i),i}}var cA,aA,Og=(e)=>typeof e==="bigint"&&cA<=e,Od=(e)=>(aA<<BigInt(e))-aA;var jc=v(()=>{jr();jr();/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */cA=BigInt(0),aA=BigInt(1)});function gr(e,t){let r=e%t;return r>=yr?r:t+r}function en(e,t,r){let o=e;while(t-- >yr)o*=o,o%=r;return o}function fZ(e,t){if(e===yr)throw Error("invert: expected non-zero number");if(t<=yr)throw Error("invert: expected positive modulus, got "+t);let r=gr(e,t),o=t,n=yr,i=rr,s=rr,a=yr;while(r!==yr){let u=o/r,d=o%r,p=n-s*u,m=i-a*u;o=r,r=d,n=s,i=a,s=p,a=m}if(o!==rr)throw Error("invert: does not exist");return gr(n,t)}function dA(e,t,r){if(!e.eql(e.sqr(t),r))throw Error("Cannot find square root")}function vZ(e,t){let r=(e.ORDER+rr)/gZ,o=e.pow(t,r);return dA(e,o,t),o}function Nae(e,t){let r=(e.ORDER-yZ)/bZ,o=e.mul(t,Ms),n=e.pow(o,r),i=e.mul(t,n),s=e.mul(e.mul(i,Ms),n),a=e.mul(i,e.sub(s,e.ONE));return dA(e,a,t),a}function Dae(e){let t=Pg(e),r=wZ(e),o=r(t,t.neg(t.ONE)),n=r(t,o),i=r(t,t.neg(o)),s=(e+Pae)/SZ;return(a,c)=>{let u=a.pow(c,s),d=a.mul(u,o),p=a.mul(u,n),m=a.mul(u,i),h=a.eql(a.sqr(d),c),b=a.eql(a.sqr(p),c);u=a.cmov(u,d,h),d=a.cmov(m,p,b);let y=a.eql(a.sqr(d),c),S=a.cmov(u,d,y);return dA(a,S,c),S}}function wZ(e){if(e<hZ)throw Error("sqrt is not defined for small field");let t=e-rr,r=0;while(t%Ms===yr)t/=Ms,r++;let o=Ms,n=Pg(e);while(mZ(n,o)===1)if(o++>1000)throw Error("Cannot find square root: probably non-prime P");if(r===1)return vZ;let i=n.pow(o,t),s=(t+rr)/Ms;return function(c,u){if(c.is0(u))return u;if(mZ(c,u)!==1)throw Error("Cannot find square root");let d=r,p=c.mul(c.ONE,i),m=c.pow(u,t),h=c.pow(u,s);while(!c.eql(m,c.ONE)){if(c.is0(m))return c.ZERO;let b=1,y=c.sqr(m);while(!c.eql(y,c.ONE))if(b++,y=c.sqr(y),b===d)throw Error("Cannot find square root");let S=rr<<BigInt(d-b-1),x=c.pow(p,S);d=b,p=c.sqr(x),m=c.mul(m,p),h=c.mul(h,x)}return h}}function Lae(e){if(e%gZ===hZ)return vZ;if(e%bZ===yZ)return Nae;if(e%SZ===zae)return Dae(e);return wZ(e)}function pA(e){let t={ORDER:"bigint",BYTES:"number",BITS:"number"},r=Bae.reduce((o,n)=>(o[n]="function",o),t);return Us(e,r),e}function jae(e,t,r){if(r<yr)throw Error("invalid exponent, negatives unsupported");if(r===yr)return e.ONE;if(r===rr)return t;let o=e.ONE,n=t;while(r>yr){if(r&rr)o=e.mul(o,n);n=e.sqr(n),r>>=rr}return o}function Cd(e,t,r=!1){let o=Array(t.length).fill(r?e.ZERO:void 0),n=t.reduce((s,a,c)=>{if(e.is0(a))return s;return o[c]=s,e.mul(s,a)},e.ONE),i=e.inv(n);return t.reduceRight((s,a,c)=>{if(e.is0(a))return s;return o[c]=e.mul(s,o[c]),e.mul(s,a)},i),o}function mZ(e,t){let r=(e.ORDER-rr)/Ms,o=e.pow(t,r),n=e.eql(o,e.ONE),i=e.eql(o,e.ZERO),s=e.eql(o,e.neg(e.ONE));if(!n&&!i&&!s)throw Error("invalid Legendre symbol result");return n?1:i?0:-1}function Zae(e,t){if(t!==void 0)Zt(t);let r=t!==void 0?t:e.toString(2).length,o=Math.ceil(r/8);return{nBitLength:r,nByteLength:o}}class xZ{ORDER;BITS;BYTES;isLE;ZERO=yr;ONE=rr;_lengths;_sqrt;_mod;constructor(e,t={}){if(e<=yr)throw Error("invalid field: expected ORDER > 0, got "+e);let r=void 0;if(this.isLE=!1,t!=null&&typeof t==="object"){if(typeof t.BITS==="number")r=t.BITS;if(typeof t.sqrt==="function")this.sqrt=t.sqrt;if(typeof t.isLE==="boolean")this.isLE=t.isLE;if(t.allowedLengths)this._lengths=t.allowedLengths?.slice();if(typeof t.modFromBytes==="boolean")this._mod=t.modFromBytes}let{nBitLength:o,nByteLength:n}=Zae(e,r);if(n>2048)throw Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=e,this.BITS=o,this.BYTES=n,this._sqrt=void 0,Object.preventExtensions(this)}create(e){return gr(e,this.ORDER)}isValid(e){if(typeof e!=="bigint")throw Error("invalid field element: expected bigint, got "+typeof e);return yr<=e&&e<this.ORDER}is0(e){return e===yr}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&rr)===rr}neg(e){return gr(-e,this.ORDER)}eql(e,t){return e===t}sqr(e){return gr(e*e,this.ORDER)}add(e,t){return gr(e+t,this.ORDER)}sub(e,t){return gr(e-t,this.ORDER)}mul(e,t){return gr(e*t,this.ORDER)}pow(e,t){return jae(this,e,t)}div(e,t){return gr(e*fZ(t,this.ORDER),this.ORDER)}sqrN(e){return e*e}addN(e,t){return e+t}subN(e,t){return e-t}mulN(e,t){return e*t}inv(e){return fZ(e,this.ORDER)}sqrt(e){if(!this._sqrt)this._sqrt=Lae(this.ORDER);return this._sqrt(this,e)}toBytes(e){return this.isLE?Rd(e,this.BYTES):Bc(e,this.BYTES)}fromBytes(e,t=!1){Te(e);let{_lengths:r,BYTES:o,isLE:n,ORDER:i,_mod:s}=this;if(r){if(!r.includes(e.length)||e.length>o)throw Error("Field.fromBytes: expected "+r+" bytes, got "+e.length);let c=new Uint8Array(o);c.set(e,n?0:c.length-e.length),e=c}if(e.length!==o)throw Error("Field.fromBytes: expected "+o+" bytes, got "+e.length);let a=n?$i(e):Ri(e);if(s)a=gr(a,i);if(!t){if(!this.isValid(a))throw Error("invalid field element: outside of range 0..ORDER")}return a}invertBatch(e){return Cd(this,e)}cmov(e,t,r){return r?t:e}}function Pg(e,t={}){return new xZ(e,t)}function _Z(e){if(typeof e!=="bigint")throw Error("field order must be bigint");let t=e.toString(2).length;return Math.ceil(t/8)}function fA(e){let t=_Z(e);return t+Math.ceil(t/2)}function EZ(e,t,r=!1){Te(e);let o=e.length,n=_Z(t),i=fA(t);if(o<16||o<i||o>1024)throw Error("expected "+i+"-1024 bytes of input, got "+o);let s=r?$i(e):Ri(e),a=gr(s,t-rr)+rr;return r?Rd(a,n):Bc(a,n)}var yr,rr,Ms,hZ,gZ,yZ,Pae,bZ,zae,SZ,Bae;var Pd=v(()=>{jc();/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */yr=BigInt(0),rr=BigInt(1),Ms=BigInt(2),hZ=BigInt(3),gZ=BigInt(4),yZ=BigInt(5),Pae=BigInt(7),bZ=BigInt(8),zae=BigInt(9),SZ=BigInt(16);Bae=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"]});function zd(e,t){let r=t.negate();return e?r:t}function yA(e,t){let r=Cd(e.Fp,t.map((o)=>o.Z));return t.map((o,n)=>e.fromAffine(o.toAffine(r[n])))}function TZ(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw Error("invalid window size, expected [1.."+t+"], got W="+e)}function mA(e,t){TZ(e,t);let r=Math.ceil(t/e)+1,o=2**(e-1),n=2**e,i=Od(e),s=BigInt(e);return{windows:r,windowSize:o,mask:i,maxNumber:n,shiftBy:s}}function kZ(e,t,r){let{windowSize:o,mask:n,maxNumber:i,shiftBy:s}=r,a=Number(e&n),c=e>>s;if(a>o)a-=i,c+=qs;let u=t*o,d=u+Math.abs(a)-1,p=a===0,m=a<0,h=t%2!==0;return{nextN:c,offset:d,isZero:p,isNeg:m,isNegF:h,offsetF:u}}function gA(e){return RZ.get(e)||1}function IZ(e){if(e!==Zc)throw Error("invalid wNAF")}class bA{BASE;ZERO;Fn;bits;constructor(e,t){this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=t}_unsafeLadder(e,t,r=this.ZERO){let o=e;while(t>Zc){if(t&qs)r=r.add(o);o=o.double(),t>>=qs}return r}precomputeWindow(e,t){let{windows:r,windowSize:o}=mA(t,this.bits),n=[],i=e,s=i;for(let a=0;a<r;a++){s=i,n.push(s);for(let c=1;c<o;c++)s=s.add(i),n.push(s);i=s.double()}return n}wNAF(e,t,r){if(!this.Fn.isValid(r))throw Error("invalid scalar");let o=this.ZERO,n=this.BASE,i=mA(e,this.bits);for(let s=0;s<i.windows;s++){let{nextN:a,offset:c,isZero:u,isNeg:d,isNegF:p,offsetF:m}=kZ(r,s,i);if(r=a,u)n=n.add(zd(p,t[m]));else o=o.add(zd(d,t[c]))}return IZ(r),{p:o,f:n}}wNAFUnsafe(e,t,r,o=this.ZERO){let n=mA(e,this.bits);for(let i=0;i<n.windows;i++){if(r===Zc)break;let{nextN:s,offset:a,isZero:c,isNeg:u}=kZ(r,i,n);if(r=s,c)continue;else{let d=t[a];o=o.add(u?d.negate():d)}}return IZ(r),o}getPrecomputes(e,t,r){let o=hA.get(t);if(!o){if(o=this.precomputeWindow(t,e),e!==1){if(typeof r==="function")o=r(o);hA.set(t,o)}}return o}cached(e,t,r){let o=gA(e);return this.wNAF(o,this.getPrecomputes(o,e,r),t)}unsafe(e,t,r,o){let n=gA(e);if(n===1)return this._unsafeLadder(e,t,o);return this.wNAFUnsafe(n,this.getPrecomputes(n,e,r),t,o)}createCache(e,t){TZ(t,this.bits),RZ.set(e,t),hA.delete(e)}hasCache(e){return gA(e)!==1}}function $Z(e,t,r,o){let n=t,i=e.ZERO,s=e.ZERO;while(r>Zc||o>Zc){if(r&qs)i=i.add(n);if(o&qs)s=s.add(n);n=n.double(),r>>=qs,o>>=qs}return{p1:i,p2:s}}function AZ(e,t,r){if(t){if(t.ORDER!==e)throw Error("Field.ORDER must match order: Fp == p, Fn == n");return pA(t),t}else return Pg(e,{isLE:r})}function OZ(e,t,r={},o){if(o===void 0)o=e==="edwards";if(!t||typeof t!=="object")throw Error(`expected valid ${e} CURVE object`);for(let c of["p","n","h"]){let u=t[c];if(!(typeof u==="bigint"&&u>Zc))throw Error(`CURVE.${c} must be positive bigint`)}let n=AZ(t.p,r.Fp,o),i=AZ(t.n,r.Fn,o),a=["Gx","Gy","a",e==="weierstrass"?"b":"d"];for(let c of a)if(!n.isValid(t[c]))throw Error(`CURVE.${c} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:n,Fn:i}}function zg(e,t){return function(o){let n=e(o);return{secretKey:n,publicKey:t(n)}}}var Zc,qs,hA,RZ;var SA=v(()=>{jc();Pd();/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */Zc=BigInt(0),qs=BigInt(1);hA=new WeakMap,RZ=new WeakMap});function Uae(e){return Us(e,{adjustScalarBytes:"function",powPminus2:"function"}),Object.freeze({...e})}function CZ(e){let t=Uae(e),{P:r,type:o,adjustScalarBytes:n,powPminus2:i,randomBytes:s}=t,a=o==="x25519";if(!a&&o!=="x448")throw Error("invalid type");let c=s||Ai,u=a?255:448,d=a?32:56,p=a?BigInt(9):BigInt(5),m=a?BigInt(121665):BigInt(39081),h=a?Ng**BigInt(254):Ng**BigInt(447),b=a?BigInt(8)*Ng**BigInt(251)-Uc:BigInt(4)*Ng**BigInt(445)-Uc,y=h+b+Uc,S=(k)=>gr(k,r),x=_(p);function _(k){return Rd(S(k),d)}function A(k){let T=Cg(Te(k,d,"uCoordinate"));if(a)T[31]&=127;return S($i(T))}function O(k){return $i(n(Cg(Te(k,d,"scalar"))))}function L(k,T){let I=ee(A(T),O(k));if(I===Nd)throw Error("invalid private or public key received");return _(I)}function z(k){return L(k,x)}let H=z,P=L;function W(k,T,I){let q=S(k*(T-I));return T=S(T-q),I=S(I+q),{x_2:T,x_3:I}}function ee(k,T){$d("u",k,Nd,r),$d("scalar",T,h,y);let I=T,q=k,N=Uc,J=Nd,G=k,re=Uc,ae=Nd;for(let be=BigInt(u-1);be>=Nd;be--){let ve=I>>be&Uc;ae^=ve,{x_2:N,x_3:G}=W(ae,N,G),{x_2:J,x_3:re}=W(ae,J,re),ae=ve;let Ae=N+J,Ie=S(Ae*Ae),we=N-J,Ue=S(we*we),De=Ie-Ue,Qe=G+re,St=G-re,Tt=S(St*Ae),Dt=S(Qe*we),lt=Tt+Dt,$r=Tt-Dt;G=S(lt*lt),re=S(q*S($r*$r)),N=S(Ie*Ue),J=S(De*(Ie+S(m*De)))}({x_2:N,x_3:G}=W(ae,N,G)),{x_2:J,x_3:re}=W(ae,J,re);let me=i(J);return S(N*me)}let j={secretKey:d,publicKey:d,seed:d},R=(k=c(d))=>(Te(k,j.seed,"seed"),k),B={randomSecretKey:R};return Object.freeze({keygen:zg(R,H),getSharedSecret:P,getPublicKey:H,scalarMult:L,scalarMultBase:z,utils:B,GuBytes:x.slice(),lengths:j})}var Nd,Uc,Ng;var PZ=v(()=>{jc();SA();Pd();/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */Nd=BigInt(0),Uc=BigInt(1),Ng=BigInt(2)});class vA{oHash;iHash;blockLen;outputLen;finished=!1;destroyed=!1;constructor(e,t){if(Xr(e),Te(t,void 0,"key"),this.iHash=e.create(),typeof this.iHash.update!=="function")throw Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let r=this.blockLen,o=new Uint8Array(r);o.set(t.length>r?e.create().update(t).digest():t);for(let n=0;n<o.length;n++)o[n]^=54;this.iHash.update(o),this.oHash=e.create();for(let n=0;n<o.length;n++)o[n]^=106;this.oHash.update(o),kr(o)}update(e){return Io(this),this.iHash.update(e),this}digestInto(e){Io(this),Te(e,this.outputLen,"output"),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||=Object.create(Object.getPrototypeOf(this),{});let{oHash:t,iHash:r,finished:o,destroyed:n,blockLen:i,outputLen:s}=this;return e=e,e.finished=o,e.destroyed=n,e.blockLen=i,e.outputLen=s,e.oHash=t._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}var Mc=(e,t,r)=>new vA(e,t).update(r).digest();var wA=v(()=>{jr();Mc.create=(e,t)=>new vA(e,t)});function Mae(e,t,r){let[[o,n],[i,s]]=t,a=zZ(s*e,r),c=zZ(-n*e,r),u=e-a*o-c*i,d=-a*n-c*s,p=u<Ao,m=d<Ao;if(p)u=-u;if(m)d=-d;let h=Od(Math.ceil(lA(r)/2))+qc;if(u<Ao||u>=h||d<Ao||d>=h)throw Error("splitScalar (endomorphism): failed, k="+e);return{k1neg:p,k1:u,k2neg:m,k2:d}}function _A(e){if(!["compact","recovered","der"].includes(e))throw Error('Signature format must be "compact", "recovered", or "der"');return e}function xA(e,t){let r={};for(let o of Object.keys(t))r[o]=e[o]===void 0?t[o]:e[o];if(Ad(r.lowS,"lowS"),Ad(r.prehash,"prehash"),r.format!==void 0)_A(r.format);return r}function EA(e,t={}){let r=OZ("weierstrass",e,t),{Fp:o,Fn:n}=r,i=r.CURVE,{h:s,n:a}=i;Us(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});let{endo:c}=t;if(c){if(!o.is0(i.a)||typeof c.beta!=="bigint"||!Array.isArray(c.basises))throw Error('invalid endo: expected "beta": bigint and "basises": array')}let u=BZ(o,n);function d(){if(!o.isOdd)throw Error("compression is not supported: Field does not have .isOdd()")}function p(R,B,k){let{x:T,y:I}=B.toAffine(),q=o.toBytes(T);if(Ad(k,"isCompressed"),k){d();let N=!o.isOdd(I);return kt(LZ(N),q)}else return kt(Uint8Array.of(4),q,o.toBytes(I))}function m(R){Te(R,void 0,"Point");let{publicKey:B,publicKeyUncompressed:k}=u,T=R.length,I=R[0],q=R.subarray(1);if(T===B&&(I===2||I===3)){let N=o.fromBytes(q);if(!o.isValid(N))throw Error("bad point: is not on curve, wrong x");let J=y(N),G;try{G=o.sqrt(J)}catch(me){let be=me instanceof Error?": "+me.message:"";throw Error("bad point: is not on curve, sqrt error"+be)}d();let re=o.isOdd(G);if((I&1)===1!==re)G=o.neg(G);return{x:N,y:G}}else if(T===k&&I===4){let N=o.BYTES,J=o.fromBytes(q.subarray(0,N)),G=o.fromBytes(q.subarray(N,N*2));if(!S(J,G))throw Error("bad point: is not on curve");return{x:J,y:G}}else throw Error(`bad point: got length ${T}, expected compressed=${B} or uncompressed=${k}`)}let h=t.toBytes||p,b=t.fromBytes||m;function y(R){let B=o.sqr(R),k=o.mul(B,R);return o.add(o.add(k,o.mul(R,i.a)),i.b)}function S(R,B){let k=o.sqr(B),T=y(R);return o.eql(k,T)}if(!S(i.Gx,i.Gy))throw Error("bad curve params: generator point");let x=o.mul(o.pow(i.a,Dg),qae),_=o.mul(o.sqr(i.b),BigInt(27));if(o.is0(o.add(x,_)))throw Error("bad curve params: a or b");function A(R,B,k=!1){if(!o.isValid(B)||k&&o.is0(B))throw Error(`bad point coordinate ${R}`);return B}function O(R){if(!(R instanceof W))throw Error("Weierstrass Point expected")}function L(R){if(!c||!c.basises)throw Error("no endo");return Mae(R,c.basises,n.ORDER)}let z=uA((R,B)=>{let{X:k,Y:T,Z:I}=R;if(o.eql(I,o.ONE))return{x:k,y:T};let q=R.is0();if(B==null)B=q?o.ONE:o.inv(I);let N=o.mul(k,B),J=o.mul(T,B),G=o.mul(I,B);if(q)return{x:o.ZERO,y:o.ZERO};if(!o.eql(G,o.ONE))throw Error("invZ was invalid");return{x:N,y:J}}),H=uA((R)=>{if(R.is0()){if(t.allowInfinityPoint&&!o.is0(R.Y))return;throw Error("bad point: ZERO")}let{x:B,y:k}=R.toAffine();if(!o.isValid(B)||!o.isValid(k))throw Error("bad point: x or y not field elements");if(!S(B,k))throw Error("bad point: equation left != right");if(!R.isTorsionFree())throw Error("bad point: not in prime-order subgroup");return!0});function P(R,B,k,T,I){return k=new W(o.mul(k.X,R),k.Y,k.Z),B=zd(T,B),k=zd(I,k),B.add(k)}class W{static BASE=new W(i.Gx,i.Gy,o.ONE);static ZERO=new W(o.ZERO,o.ONE,o.ZERO);static Fp=o;static Fn=n;X;Y;Z;constructor(R,B,k){this.X=A("x",R),this.Y=A("y",B,!0),this.Z=A("z",k),Object.freeze(this)}static CURVE(){return i}static fromAffine(R){let{x:B,y:k}=R||{};if(!R||!o.isValid(B)||!o.isValid(k))throw Error("invalid affine point");if(R instanceof W)throw Error("projective point not allowed");if(o.is0(B)&&o.is0(k))return W.ZERO;return new W(B,k,o.ONE)}static fromBytes(R){let B=W.fromAffine(b(Te(R,void 0,"point")));return B.assertValidity(),B}static fromHex(R){return W.fromBytes(Zs(R))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(R=8,B=!0){if(j.createCache(this,R),!B)this.multiply(Dg);return this}assertValidity(){H(this)}hasEvenY(){let{y:R}=this.toAffine();if(!o.isOdd)throw Error("Field doesn't support isOdd");return!o.isOdd(R)}equals(R){O(R);let{X:B,Y:k,Z:T}=this,{X:I,Y:q,Z:N}=R,J=o.eql(o.mul(B,N),o.mul(I,T)),G=o.eql(o.mul(k,N),o.mul(q,T));return J&&G}negate(){return new W(this.X,o.neg(this.Y),this.Z)}double(){let{a:R,b:B}=i,k=o.mul(B,Dg),{X:T,Y:I,Z:q}=this,N=o.ZERO,J=o.ZERO,G=o.ZERO,re=o.mul(T,T),ae=o.mul(I,I),me=o.mul(q,q),be=o.mul(T,I);return be=o.add(be,be),G=o.mul(T,q),G=o.add(G,G),N=o.mul(R,G),J=o.mul(k,me),J=o.add(N,J),N=o.sub(ae,J),J=o.add(ae,J),J=o.mul(N,J),N=o.mul(be,N),G=o.mul(k,G),me=o.mul(R,me),be=o.sub(re,me),be=o.mul(R,be),be=o.add(be,G),G=o.add(re,re),re=o.add(G,re),re=o.add(re,me),re=o.mul(re,be),J=o.add(J,re),me=o.mul(I,q),me=o.add(me,me),re=o.mul(me,be),N=o.sub(N,re),G=o.mul(me,ae),G=o.add(G,G),G=o.add(G,G),new W(N,J,G)}add(R){O(R);let{X:B,Y:k,Z:T}=this,{X:I,Y:q,Z:N}=R,J=o.ZERO,G=o.ZERO,re=o.ZERO,ae=i.a,me=o.mul(i.b,Dg),be=o.mul(B,I),ve=o.mul(k,q),Ae=o.mul(T,N),Ie=o.add(B,k),we=o.add(I,q);Ie=o.mul(Ie,we),we=o.add(be,ve),Ie=o.sub(Ie,we),we=o.add(B,T);let Ue=o.add(I,N);return we=o.mul(we,Ue),Ue=o.add(be,Ae),we=o.sub(we,Ue),Ue=o.add(k,T),J=o.add(q,N),Ue=o.mul(Ue,J),J=o.add(ve,Ae),Ue=o.sub(Ue,J),re=o.mul(ae,we),J=o.mul(me,Ae),re=o.add(J,re),J=o.sub(ve,re),re=o.add(ve,re),G=o.mul(J,re),ve=o.add(be,be),ve=o.add(ve,be),Ae=o.mul(ae,Ae),we=o.mul(me,we),ve=o.add(ve,Ae),Ae=o.sub(be,Ae),Ae=o.mul(ae,Ae),we=o.add(we,Ae),be=o.mul(ve,we),G=o.add(G,be),be=o.mul(Ue,we),J=o.mul(Ie,J),J=o.sub(J,be),be=o.mul(Ie,ve),re=o.mul(Ue,re),re=o.add(re,be),new W(J,G,re)}subtract(R){return this.add(R.negate())}is0(){return this.equals(W.ZERO)}multiply(R){let{endo:B}=t;if(!n.isValidNot0(R))throw Error("invalid scalar: out of range");let k,T,I=(q)=>j.cached(this,q,(N)=>yA(W,N));if(B){let{k1neg:q,k1:N,k2neg:J,k2:G}=L(R),{p:re,f:ae}=I(N),{p:me,f:be}=I(G);T=ae.add(be),k=P(B.beta,re,me,q,J)}else{let{p:q,f:N}=I(R);k=q,T=N}return yA(W,[k,T])[0]}multiplyUnsafe(R){let{endo:B}=t,k=this;if(!n.isValid(R))throw Error("invalid scalar: out of range");if(R===Ao||k.is0())return W.ZERO;if(R===qc)return k;if(j.hasCache(this))return this.multiply(R);if(B){let{k1neg:T,k1:I,k2neg:q,k2:N}=L(R),{p1:J,p2:G}=$Z(W,k,I,N);return P(B.beta,J,G,T,q)}else return j.unsafe(k,R)}toAffine(R){return z(this,R)}isTorsionFree(){let{isTorsionFree:R}=t;if(s===qc)return!0;if(R)return R(W,this);return j.unsafe(this,a).is0()}clearCofactor(){let{clearCofactor:R}=t;if(s===qc)return this;if(R)return R(W,this);return this.multiplyUnsafe(s)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}toBytes(R=!0){return Ad(R,"isCompressed"),this.assertValidity(),h(W,this,R)}toHex(R=!0){return js(this.toBytes(R))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let ee=n.BITS,j=new bA(W,t.endo?Math.ceil(ee/2):ee);return W.BASE.precompute(8),W}function LZ(e){return Uint8Array.of(e?2:3)}function BZ(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function Fae(e,t={}){let{Fn:r}=e,o=t.randomBytes||Ai,n=Object.assign(BZ(e.Fp,r),{seed:fA(r.ORDER)});function i(h){try{let b=r.fromBytes(h);return r.isValidNot0(b)}catch(b){return!1}}function s(h,b){let{publicKey:y,publicKeyUncompressed:S}=n;try{let x=h.length;if(b===!0&&x!==y)return!1;if(b===!1&&x!==S)return!1;return!!e.fromBytes(h)}catch(x){return!1}}function a(h=o(n.seed)){return EZ(Te(h,n.seed,"seed"),r.ORDER)}function c(h,b=!0){return e.BASE.multiply(r.fromBytes(h)).toBytes(b)}function u(h){let{secretKey:b,publicKey:y,publicKeyUncompressed:S}=n;if(!Dc(h))return;if("_lengths"in r&&r._lengths||b===y)return;let x=Te(h,void 0,"key").length;return x===y||x===S}function d(h,b,y=!0){if(u(h)===!0)throw Error("first arg must be private key");if(u(b)===!1)throw Error("second arg must be public key");let S=r.fromBytes(h);return e.fromBytes(b).multiply(S).toBytes(y)}let p={isValidSecretKey:i,isValidPublicKey:s,randomSecretKey:a},m=zg(a,c);return Object.freeze({getPublicKey:c,getSharedSecret:d,keygen:m,Point:e,utils:p,lengths:n})}function kA(e,t,r={}){Xr(t),Us(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),r=Object.assign({},r);let o=r.randomBytes||Ai,n=r.hmac||((k,T)=>Mc(t,k,T)),{Fp:i,Fn:s}=e,{ORDER:a,BITS:c}=s,{keygen:u,getPublicKey:d,getSharedSecret:p,utils:m,lengths:h}=Fae(e,r),b={prehash:!0,lowS:typeof r.lowS==="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},y=a*DZ<i.ORDER;function S(k){let T=a>>qc;return k>T}function x(k,T){if(!s.isValidNot0(T))throw Error(`invalid signature ${k}: out of range 1..Point.Fn.ORDER`);return T}function _(){if(y)throw Error('"recovered" sig type is not supported for cofactor >2 curves')}function A(k,T){_A(T);let I=h.signature,q=T==="compact"?I:T==="recovered"?I+1:void 0;return Te(k,q)}class O{r;s;recovery;constructor(k,T,I){if(this.r=x("r",k),this.s=x("s",T),I!=null){if(_(),![0,1,2,3].includes(I))throw Error("invalid recovery id");this.recovery=I}Object.freeze(this)}static fromBytes(k,T=b.format){A(k,T);let I;if(T==="der"){let{r:G,s:re}=Ci.toSig(Te(k));return new O(G,re)}if(T==="recovered")I=k[0],T="compact",k=k.subarray(1);let q=h.signature/2,N=k.subarray(0,q),J=k.subarray(q,q*2);return new O(s.fromBytes(N),s.fromBytes(J),I)}static fromHex(k,T){return this.fromBytes(Zs(k),T)}assertRecovery(){let{recovery:k}=this;if(k==null)throw Error("invalid recovery id: must be present");return k}addRecoveryBit(k){return new O(this.r,this.s,k)}recoverPublicKey(k){let{r:T,s:I}=this,q=this.assertRecovery(),N=q===2||q===3?T+a:T;if(!i.isValid(N))throw Error("invalid recovery id: sig.r+curve.n != R.x");let J=i.toBytes(N),G=e.fromBytes(kt(LZ((q&1)===0),J)),re=s.inv(N),ae=z(Te(k,void 0,"msgHash")),me=s.create(-ae*re),be=s.create(I*re),ve=e.BASE.multiplyUnsafe(me).add(G.multiplyUnsafe(be));if(ve.is0())throw Error("invalid recovery: point at infinify");return ve.assertValidity(),ve}hasHighS(){return S(this.s)}toBytes(k=b.format){if(_A(k),k==="der")return Zs(Ci.hexFromSig(this));let{r:T,s:I}=this,q=s.toBytes(T),N=s.toBytes(I);if(k==="recovered")return _(),kt(Uint8Array.of(this.assertRecovery()),q,N);return kt(q,N)}toHex(k){return js(this.toBytes(k))}}let L=r.bits2int||function(T){if(T.length>8192)throw Error("input is too large");let I=Ri(T),q=T.length*8-c;return q>0?I>>BigInt(q):I},z=r.bits2int_modN||function(T){return s.create(L(T))},H=Od(c);function P(k){return $d("num < 2^"+c,k,Ao,H),s.toBytes(k)}function W(k,T){return Te(k,void 0,"message"),T?Te(t(k),void 0,"prehashed message"):k}function ee(k,T,I){let{lowS:q,prehash:N,extraEntropy:J}=xA(I,b);k=W(k,N);let G=z(k),re=s.fromBytes(T);if(!s.isValidNot0(re))throw Error("invalid private key");let ae=[P(re),P(G)];if(J!=null&&J!==!1){let Ae=J===!0?o(h.secretKey):J;ae.push(Te(Ae,void 0,"extraEntropy"))}let me=kt(...ae),be=G;function ve(Ae){let Ie=L(Ae);if(!s.isValidNot0(Ie))return;let we=s.inv(Ie),Ue=e.BASE.multiply(Ie).toAffine(),De=s.create(Ue.x);if(De===Ao)return;let Qe=s.create(we*s.create(be+De*re));if(Qe===Ao)return;let St=(Ue.x===De?0:2)|Number(Ue.y&qc),Tt=Qe;if(q&&S(Qe))Tt=s.neg(Qe),St^=1;return new O(De,Tt,y?void 0:St)}return{seed:me,k2sig:ve}}function j(k,T,I={}){let{seed:q,k2sig:N}=ee(k,T,I);return pZ(t.outputLen,s.BYTES,n)(q,N).toBytes(I.format)}function R(k,T,I,q={}){let{lowS:N,prehash:J,format:G}=xA(q,b);if(I=Te(I,void 0,"publicKey"),T=W(T,J),!Dc(k)){let re=k instanceof O?", use sig.toBytes()":"";throw Error("verify expects Uint8Array signature"+re)}A(k,G);try{let re=O.fromBytes(k,G),ae=e.fromBytes(I);if(N&&re.hasHighS())return!1;let{r:me,s:be}=re,ve=z(T),Ae=s.inv(be),Ie=s.create(ve*Ae),we=s.create(me*Ae),Ue=e.BASE.multiplyUnsafe(Ie).add(ae.multiplyUnsafe(we));if(Ue.is0())return!1;return s.create(Ue.x)===me}catch(re){return!1}}function B(k,T,I={}){let{prehash:q}=xA(I,b);return T=W(T,q),O.fromBytes(k,"recovered").recoverPublicKey(T).toBytes()}return Object.freeze({keygen:u,getPublicKey:d,getSharedSecret:p,utils:m,lengths:h,Point:e,sign:j,verify:R,recoverPublicKey:B,Signature:O,hash:t})}var zZ=(e,t)=>(e+(e>=0?t:-t)/DZ)/t,NZ,Ci,Ao,qc,DZ,Dg,qae;var jZ=v(()=>{wA();jr();jc();SA();Pd();/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */NZ=class NZ extends Error{constructor(e=""){super(e)}};Ci={Err:NZ,_tlv:{encode:(e,t)=>{let{Err:r}=Ci;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length&1)throw new r("tlv.encode: unpadded data");let o=t.length/2,n=Td(o);if(n.length/2&128)throw new r("tlv.encode: long form length too big");let i=o>127?Td(n.length/2|128):"";return Td(e)+i+n+t},decode(e,t){let{Err:r}=Ci,o=0;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length<2||t[o++]!==e)throw new r("tlv.decode: wrong tlv");let n=t[o++],i=!!(n&128),s=0;if(!i)s=n;else{let c=n&127;if(!c)throw new r("tlv.decode(long): indefinite length not supported");if(c>4)throw new r("tlv.decode(long): byte length is too big");let u=t.subarray(o,o+c);if(u.length!==c)throw new r("tlv.decode: length bytes not complete");if(u[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let d of u)s=s<<8|d;if(o+=c,s<128)throw new r("tlv.decode(long): not minimal encoding")}let a=t.subarray(o,o+s);if(a.length!==s)throw new r("tlv.decode: wrong value length");return{v:a,l:t.subarray(o+s)}}},_int:{encode(e){let{Err:t}=Ci;if(e<Ao)throw new t("integer: negative integers are not allowed");let r=Td(e);if(Number.parseInt(r[0],16)&8)r="00"+r;if(r.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return r},decode(e){let{Err:t}=Ci;if(e[0]&128)throw new t("invalid signature integer: negative");if(e[0]===0&&!(e[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return Ri(e)}},toSig(e){let{Err:t,_int:r,_tlv:o}=Ci,n=Te(e,void 0,"signature"),{v:i,l:s}=o.decode(48,n);if(s.length)throw new t("invalid signature: left bytes after parsing");let{v:a,l:c}=o.decode(2,i),{v:u,l:d}=o.decode(2,c);if(d.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(u)}},hexFromSig(e){let{_tlv:t,_int:r}=Ci,o=t.encode(2,r.encode(e.r)),n=t.encode(2,r.encode(e.s)),i=o+n;return t.encode(48,i)}},Ao=BigInt(0),qc=BigInt(1),DZ=BigInt(2),Dg=BigInt(3),qae=BigInt(4)});function ZZ(e,t,r){return e&t^~e&r}function UZ(e,t,r){return e&t^e&r^t&r}class Lg{blockLen;outputLen;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,t,r,o){this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=o,this.buffer=new Uint8Array(e),this.view=$g(this.buffer)}update(e){Io(this),Te(e);let{view:t,buffer:r,blockLen:o}=this,n=e.length;for(let i=0;i<n;){let s=Math.min(o-this.pos,n-i);if(s===o){let a=$g(e);for(;o<=n-i;i+=o)this.process(a,i);continue}if(r.set(e.subarray(i,i+s),this.pos),this.pos+=s,i+=s,this.pos===o)this.process(t,0),this.pos=0}return this.length+=e.length,this.roundClean(),this}digestInto(e){Io(this),Tg(e,this),this.finished=!0;let{buffer:t,view:r,blockLen:o,isLE:n}=this,{pos:i}=this;if(t[i++]=128,kr(this.buffer.subarray(i)),this.padOffset>o-i)this.process(r,0),i=0;for(let d=i;d<o;d++)t[d]=0;r.setBigUint64(o-8,BigInt(this.length*8),n),this.process(r,0);let s=$g(e),a=this.outputLen;if(a%4)throw Error("_sha2: outputLen must be aligned to 32bit");let c=a/4,u=this.get();if(c>u.length)throw Error("_sha2: outputLen bigger than state");for(let d=0;d<c;d++)s.setUint32(4*d,u[d],n)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){e||=new this.constructor,e.set(...this.get());let{blockLen:t,buffer:r,length:o,finished:n,destroyed:i,pos:s}=this;if(e.destroyed=i,e.finished=n,e.length=o,e.pos=s,o%t)e.buffer.set(r);return e}clone(){return this._cloneInto()}}var To,Jt;var MZ=v(()=>{jr();To=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Jt=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428])});function Kae(e,t=!1){if(t)return{h:Number(e&Bg),l:Number(e>>qZ&Bg)};return{h:Number(e>>qZ&Bg)|0,l:Number(e&Bg)|0}}function jg(e,t=!1){let r=e.length,o=new Uint32Array(r),n=new Uint32Array(r);for(let i=0;i<r;i++){let{h:s,l:a}=Kae(e[i],t);[o[i],n[i]]=[s,a]}return[o,n]}function Kn(e,t,r,o){let n=(t>>>0)+(o>>>0);return{h:e+r+(n/4294967296|0)|0,l:n|0}}var Bg,qZ,IA=(e,t,r)=>e>>>r,AA=(e,t,r)=>e<<32-r|t>>>r,Fs=(e,t,r)=>e>>>r|t<<32-r,Ks=(e,t,r)=>e<<32-r|t>>>r,Dd=(e,t,r)=>e<<64-r|t>>>r-32,Ld=(e,t,r)=>e>>>r-32|t<<64-r,FZ=(e,t,r)=>e<<r|t>>>32-r,KZ=(e,t,r)=>t<<r|e>>>32-r,HZ=(e,t,r)=>t<<r-32|e>>>64-r,JZ=(e,t,r)=>e<<r-32|t>>>64-r,VZ=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),WZ=(e,t,r,o)=>t+r+o+(e/4294967296|0)|0,GZ=(e,t,r,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(o>>>0),QZ=(e,t,r,o,n)=>t+r+o+n+(e/4294967296|0)|0,YZ=(e,t,r,o,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(o>>>0)+(n>>>0),XZ=(e,t,r,o,n,i)=>t+r+o+n+i+(e/4294967296|0)|0;var TA=v(()=>{Bg=BigInt(4294967295),qZ=BigInt(32)});var Jae,Pi,eU,tU,rU,Vae,Wae,zi,Ni,nU,oU,Zg,iU;var RA=v(()=>{MZ();TA();jr();Jae=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Pi=new Uint32Array(64);eU=class eU extends Lg{constructor(e){super(64,e,8,!1)}get(){let{A:e,B:t,C:r,D:o,E:n,F:i,G:s,H:a}=this;return[e,t,r,o,n,i,s,a]}set(e,t,r,o,n,i,s,a){this.A=e|0,this.B=t|0,this.C=r|0,this.D=o|0,this.E=n|0,this.F=i|0,this.G=s|0,this.H=a|0}process(e,t){for(let d=0;d<16;d++,t+=4)Pi[d]=e.getUint32(t,!1);for(let d=16;d<64;d++){let p=Pi[d-15],m=Pi[d-2],h=yn(p,7)^yn(p,18)^p>>>3,b=yn(m,17)^yn(m,19)^m>>>10;Pi[d]=b+Pi[d-7]+h+Pi[d-16]|0}let{A:r,B:o,C:n,D:i,E:s,F:a,G:c,H:u}=this;for(let d=0;d<64;d++){let p=yn(s,6)^yn(s,11)^yn(s,25),m=u+p+ZZ(s,a,c)+Jae[d]+Pi[d]|0,b=(yn(r,2)^yn(r,13)^yn(r,22))+UZ(r,o,n)|0;u=c,c=a,a=s,s=i+m|0,i=n,n=o,o=r,r=m+b|0}r=r+this.A|0,o=o+this.B|0,n=n+this.C|0,i=i+this.D|0,s=s+this.E|0,a=a+this.F|0,c=c+this.G|0,u=u+this.H|0,this.set(r,o,n,i,s,a,c,u)}roundClean(){kr(Pi)}destroy(){this.set(0,0,0,0,0,0,0,0),kr(this.buffer)}};tU=class tU extends eU{A=To[0]|0;B=To[1]|0;C=To[2]|0;D=To[3]|0;E=To[4]|0;F=To[5]|0;G=To[6]|0;H=To[7]|0;constructor(){super(32)}};rU=(()=>jg(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map((e)=>BigInt(e))))(),Vae=(()=>rU[0])(),Wae=(()=>rU[1])(),zi=new Uint32Array(80),Ni=new Uint32Array(80);nU=class nU extends Lg{constructor(e){super(128,e,16,!1)}get(){let{Ah:e,Al:t,Bh:r,Bl:o,Ch:n,Cl:i,Dh:s,Dl:a,Eh:c,El:u,Fh:d,Fl:p,Gh:m,Gl:h,Hh:b,Hl:y}=this;return[e,t,r,o,n,i,s,a,c,u,d,p,m,h,b,y]}set(e,t,r,o,n,i,s,a,c,u,d,p,m,h,b,y){this.Ah=e|0,this.Al=t|0,this.Bh=r|0,this.Bl=o|0,this.Ch=n|0,this.Cl=i|0,this.Dh=s|0,this.Dl=a|0,this.Eh=c|0,this.El=u|0,this.Fh=d|0,this.Fl=p|0,this.Gh=m|0,this.Gl=h|0,this.Hh=b|0,this.Hl=y|0}process(e,t){for(let _=0;_<16;_++,t+=4)zi[_]=e.getUint32(t),Ni[_]=e.getUint32(t+=4);for(let _=16;_<80;_++){let A=zi[_-15]|0,O=Ni[_-15]|0,L=Fs(A,O,1)^Fs(A,O,8)^IA(A,O,7),z=Ks(A,O,1)^Ks(A,O,8)^AA(A,O,7),H=zi[_-2]|0,P=Ni[_-2]|0,W=Fs(H,P,19)^Dd(H,P,61)^IA(H,P,6),ee=Ks(H,P,19)^Ld(H,P,61)^AA(H,P,6),j=GZ(z,ee,Ni[_-7],Ni[_-16]),R=QZ(j,L,W,zi[_-7],zi[_-16]);zi[_]=R|0,Ni[_]=j|0}let{Ah:r,Al:o,Bh:n,Bl:i,Ch:s,Cl:a,Dh:c,Dl:u,Eh:d,El:p,Fh:m,Fl:h,Gh:b,Gl:y,Hh:S,Hl:x}=this;for(let _=0;_<80;_++){let A=Fs(d,p,14)^Fs(d,p,18)^Dd(d,p,41),O=Ks(d,p,14)^Ks(d,p,18)^Ld(d,p,41),L=d&m^~d&b,z=p&h^~p&y,H=YZ(x,O,z,Wae[_],Ni[_]),P=XZ(H,S,A,L,Vae[_],zi[_]),W=H|0,ee=Fs(r,o,28)^Dd(r,o,34)^Dd(r,o,39),j=Ks(r,o,28)^Ld(r,o,34)^Ld(r,o,39),R=r&n^r&s^n&s,B=o&i^o&a^i&a;S=b|0,x=y|0,b=m|0,y=h|0,m=d|0,h=p|0,{h:d,l:p}=Kn(c|0,u|0,P|0,W|0),c=s|0,u=a|0,s=n|0,a=i|0,n=r|0,i=o|0;let k=VZ(W,j,B);r=WZ(k,P,ee,R),o=k|0}({h:r,l:o}=Kn(this.Ah|0,this.Al|0,r|0,o|0)),{h:n,l:i}=Kn(this.Bh|0,this.Bl|0,n|0,i|0),{h:s,l:a}=Kn(this.Ch|0,this.Cl|0,s|0,a|0),{h:c,l:u}=Kn(this.Dh|0,this.Dl|0,c|0,u|0),{h:d,l:p}=Kn(this.Eh|0,this.El|0,d|0,p|0),{h:m,l:h}=Kn(this.Fh|0,this.Fl|0,m|0,h|0),{h:b,l:y}=Kn(this.Gh|0,this.Gl|0,b|0,y|0),{h:S,l:x}=Kn(this.Hh|0,this.Hl|0,S|0,x|0),this.set(r,o,n,i,s,a,c,u,d,p,m,h,b,y,S,x)}roundClean(){kr(zi,Ni)}destroy(){kr(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};oU=class oU extends nU{Ah=Jt[0]|0;Al=Jt[1]|0;Bh=Jt[2]|0;Bl=Jt[3]|0;Ch=Jt[4]|0;Cl=Jt[5]|0;Dh=Jt[6]|0;Dl=Jt[7]|0;Eh=Jt[8]|0;El=Jt[9]|0;Fh=Jt[10]|0;Fl=Jt[11]|0;Gh=Jt[12]|0;Gl=Jt[13]|0;Hh=Jt[14]|0;Hl=Jt[15]|0;constructor(){super(48)}};Zg=Lc(()=>new tU,Ti(1)),iU=Lc(()=>new oU,Ti(2))});function Xae(e){let t=BigInt(10),r=BigInt(20),o=BigInt(40),n=BigInt(80),i=aU,a=e*e%i*e%i,c=en(a,sU,i)*a%i,u=en(c,Gae,i)*e%i,d=en(u,Yae,i)*u%i,p=en(d,t,i)*d%i,m=en(p,r,i)*p%i,h=en(m,o,i)*m%i,b=en(h,n,i)*h%i,y=en(b,n,i)*h%i,S=en(y,t,i)*d%i;return{pow_p_5_8:en(S,sU,i)*e%i,b2:a}}function ece(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var Gae,sU,Qae,Yae,KOe,aU,cU;var lU=v(()=>{Pd();PZ();/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */Gae=BigInt(1),sU=BigInt(2),Qae=BigInt(3),Yae=BigInt(5),KOe=BigInt(8),aU=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed");cU=(()=>{let e=aU;return CZ({P:e,type:"x25519",powPminus2:(t)=>{let{pow_p_5_8:r,b2:o}=Xae(t);return gr(en(r,Qae,e)*o,e)},adjustScalarBytes:ece})})()});var tce,rce,nce,$A,oce,uU;var dU=v(()=>{RA();jZ();/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */tce=(()=>({p:BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),h:BigInt(1),a:BigInt("0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc"),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")}))(),rce=(()=>({p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff"),n:BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973"),h:BigInt(1),a:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000fffffffc"),b:BigInt("0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef"),Gx:BigInt("0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7"),Gy:BigInt("0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f")}))(),nce=EA(tce),$A=kA(nce,Zg),oce=EA(rce),uU=kA(oce,iU)});function fU(e,t,r){if(Xr(e),r===void 0)r=new Uint8Array(e.outputLen);return Mc(e,r,t)}function mU(e,t,r,o=32){Xr(e),Zt(o,"length");let n=e.outputLen;if(o>255*n)throw Error("Length must be <= 255*HashLen");let i=Math.ceil(o/n);if(r===void 0)r=pU;else Te(r,void 0,"info");let s=new Uint8Array(i*n),a=Mc.create(e,t),c=a._cloneInto(),u=new Uint8Array(a.outputLen);for(let d=0;d<i;d++)OA[0]=d+1,c.update(d===0?pU:u).update(r).update(OA).digestInto(u),s.set(u,n*d),a._cloneInto(c);return a.destroy(),c.destroy(),kr(u,OA),s.slice(0,o)}var OA,pU;var hU=v(()=>{wA();jr();OA=Uint8Array.of(0),pU=Uint8Array.of()});function pce(e,t=24){let r=new Uint32Array(10);for(let o=24-t;o<24;o++){for(let s=0;s<10;s++)r[s]=e[s]^e[s+10]^e[s+20]^e[s+30]^e[s+40];for(let s=0;s<10;s+=2){let a=(s+8)%10,c=(s+2)%10,u=r[c],d=r[c+1],p=gU(u,d,1)^r[a],m=yU(u,d,1)^r[a+1];for(let h=0;h<50;h+=10)e[s+h]^=p,e[s+h+1]^=m}let n=e[2],i=e[3];for(let s=0;s<24;s++){let a=SU[s],c=gU(n,i,a),u=yU(n,i,a),d=bU[s];n=e[d],i=e[d+1],e[d]=c,e[d+1]=u}for(let s=0;s<50;s+=10){for(let a=0;a<10;a++)r[a]=e[s+a];for(let a=0;a<10;a++)e[s+a]^=~r[(a+2)%10]&r[(a+4)%10]}e[0]^=uce[o],e[1]^=dce[o]}kr(r)}class Ug{state;pos=0;posOut=0;finished=!1;state32;destroyed=!1;blockLen;suffix;outputLen;enableXOF=!1;rounds;constructor(e,t,r,o=!1,n=24){if(this.blockLen=e,this.suffix=t,this.outputLen=r,this.enableXOF=o,this.rounds=n,Zt(r,"outputLen"),!(0<e&&e<200))throw Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=Rg(this.state)}clone(){return this._cloneInto()}keccak(){sA(this.state32),pce(this.state32,this.rounds),sA(this.state32),this.posOut=0,this.pos=0}update(e){Io(this),Te(e);let{blockLen:t,state:r}=this,o=e.length;for(let n=0;n<o;){let i=Math.min(t-this.pos,o-n);for(let s=0;s<i;s++)r[this.pos++]^=e[n++];if(this.pos===t)this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:e,suffix:t,pos:r,blockLen:o}=this;if(e[r]^=t,(t&128)!==0&&r===o-1)this.keccak();e[o-1]^=128,this.keccak()}writeInto(e){Io(this,!1),Te(e),this.finish();let t=this.state,{blockLen:r}=this;for(let o=0,n=e.length;o<n;){if(this.posOut>=r)this.keccak();let i=Math.min(r-this.posOut,n-o);e.set(t.subarray(this.posOut,this.posOut+i),o),this.posOut+=i,o+=i}return e}xofInto(e){if(!this.enableXOF)throw Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return Zt(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Tg(e,this),this.finished)throw Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,kr(this.state)}_cloneInto(e){let{blockLen:t,suffix:r,outputLen:o,rounds:n,enableXOF:i}=this;return e||=new Ug(t,r,o,i,n),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=n,e.suffix=r,e.outputLen=o,e.enableXOF=i,e.destroyed=this.destroyed,e}}var ice,Bd,sce,ace,cce,lce,bU,SU,vU,wU,uce,dce,gU=(e,t,r)=>r>32?HZ(e,t,r):FZ(e,t,r),yU=(e,t,r)=>r>32?JZ(e,t,r):KZ(e,t,r),xU=(e,t,r,o={})=>Lc(()=>new Ug(t,e,r),o),Hs,_U,EU=(e,t,r,o={})=>Lc((n={})=>new Ug(t,e,n.dkLen===void 0?r:n.dkLen,!0),o),kU,Hn;var Mg=v(()=>{TA();jr();ice=BigInt(0),Bd=BigInt(1),sce=BigInt(2),ace=BigInt(7),cce=BigInt(256),lce=BigInt(113),bU=[],SU=[],vU=[];for(let e=0,t=Bd,r=1,o=0;e<24;e++){[r,o]=[o,(2*r+3*o)%5],bU.push(2*(5*o+r)),SU.push((e+1)*(e+2)/2%64);let n=ice;for(let i=0;i<7;i++)if(t=(t<<Bd^(t>>ace)*lce)%cce,t&sce)n^=Bd<<(Bd<<BigInt(i))-Bd;vU.push(n)}wU=jg(vU,!0),uce=wU[0],dce=wU[1];Hs=xU(6,136,32,Ti(8)),_U=xU(6,72,64,Ti(10)),kU=EU(31,168,16,Ti(11)),Hn=EU(31,136,32,Ti(12))});function CA(e){if(!Number.isSafeInteger(e)||e<0||e>4294967295)throw Error("wrong u32 integer:"+e);return e}function AU(e){return CA(e),(e&e-1)===0&&e!==0}function PA(e,t){CA(e);let r=0;for(let o=0;o<t;o++,e>>>=1)r=r<<1|e&1;return r}function TU(e){return CA(e),31-Math.clz32(e)}function IU(e){let t=e.length;if(t<2||!AU(t))throw Error("n must be a power of 2 and greater than 1. Got "+t);let r=TU(t);for(let o=0;o<t;o++){let n=PA(o,r);if(o<n){let i=e[o];e[o]=e[n],e[n]=i}}return e}var zA=(e,t)=>{let{N:r,roots:o,dit:n,invertButterflies:i=!1,skipStages:s=0,brp:a=!0}=t,c=TU(r);if(!AU(r))throw Error("FFT: Polynomial size should be power of two");let u=n!==i;return(d)=>{if(d.length!==r)throw Error("FFT: wrong Polynomial length");if(n&&a)IU(d);for(let p=0,m=1;p<c-s;p++){let h=n?p+1+s:c-p,b=1<<h,y=b>>1,S=r>>h;for(let x=0;x<r;x+=b)for(let _=0,A=m++;_<y;_++){let O=i?n?r-A:A:_*S,L=x+_,z=x+_+y,H=o[O],P=d[z],W=d[L];if(u){let ee=e.mul(P,H);d[L]=e.add(W,ee),d[z]=e.sub(W,ee)}else if(i)d[L]=e.add(P,W),d[z]=e.mul(e.sub(P,W),H);else d[L]=e.add(W,P),d[z]=e.mul(e.sub(W,P),H)}}if(!n&&a)IU(d);return d}};var RU=()=>{};function qg(e,t){if(e.length!==t.length)return!1;let r=0;for(let o=0;o<e.length;o++)r|=e[o]^t[o];return r===0}function $U(e){return Uint8Array.from(e)}function Js(e,...t){let r=(n)=>typeof n==="number"?n:n.bytesLen,o=t.reduce((n,i)=>n+r(i),0);return{bytesLen:o,encode:(n)=>{let i=new Uint8Array(o);for(let s=0,a=0;s<t.length;s++){let c=t[s],u=r(c),d=typeof c==="number"?n[s]:c.encode(n[s]);if(Te(d,u,e),i.set(d,a),typeof c!=="number")d.fill(0);a+=u}return i},decode:(n)=>{Te(n,o,e);let i=[];for(let s of t){let a=r(s),c=n.subarray(0,a);i.push(typeof s==="number"?c:s.decode(c)),n=n.subarray(a)}return i}}}function Fg(e,t){let r=t*e.bytesLen;return{bytesLen:r,encode:(o)=>{if(o.length!==t)throw Error(`vecCoder.encode: wrong length=${o.length}. Expected: ${t}`);let n=new Uint8Array(r);for(let i=0,s=0;i<o.length;i++){let a=e.encode(o[i]);n.set(a,s),a.fill(0),s+=a.length}return n},decode:(o)=>{Te(o,r);let n=[];for(let i=0;i<o.length;i+=e.bytesLen)n.push(e.decode(o.subarray(i,i+e.bytesLen)));return n}}}function Pt(...e){for(let t of e)if(Array.isArray(t))for(let r of t)r.fill(0);else t.fill(0)}function NA(e){return(1<<e)-1}var Jn,sCe;var Kg=v(()=>{jr();jr();/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */Jn=Ai;sCe=Uint8Array.of()});var OU=(e)=>{let{newPoly:t,N:r,Q:o,F:n,ROOT_OF_UNITY:i,brvBits:s,isKyber:a}=e,c=(_,A=o)=>{let O=_%A|0;return(O>=0?O|0:A+O|0)|0},u=(_,A=o)=>{let O=c(_,A)|0;return(O>A>>1?O-A|0:O)|0};function d(){let _=t(r);for(let A=0;A<r;A++){let O=PA(A,s),L=BigInt(i)**BigInt(O)%BigInt(o);_[A]=Number(L)|0}return _}let p=d(),m={add:(_,A)=>c((_|0)+(A|0))|0,sub:(_,A)=>c((_|0)-(A|0))|0,mul:(_,A)=>c((_|0)*(A|0))|0,inv:(_)=>{throw Error("not implemented")}},h={N:r,roots:p,invertButterflies:!0,skipStages:a?1:0,brp:!1},b=zA(m,{dit:!1,...h}),y=zA(m,{dit:!0,...h});return{mod:c,smod:u,nttZetas:p,NTT:{encode:(_)=>b(_),decode:(_)=>{y(_);for(let A=0;A<_.length;A++)_[A]=c(n*_[A]);return _}},bitsCoder:(_,A)=>{let O=NA(_),L=_*(r/8);return{bytesLen:L,encode:(z)=>{let H=new Uint8Array(L);for(let P=0,W=0,ee=0,j=0;P<z.length;P++){W|=(A.encode(z[P])&O)<<ee,ee+=_;for(;ee>=8;ee-=8,W>>=8)H[j++]=W&NA(ee)}return H},decode:(z)=>{let H=t(r);for(let P=0,W=0,ee=0,j=0;P<z.length;P++){W|=z[P]<<ee,ee+=8;for(;ee>=_;ee-=_,W>>=_)H[j++]=A.decode(W&O)}return H}}}}},fce=(e)=>(t,r)=>{if(!r)r=e.blockLen;let o=new Uint8Array(t.length+2);o.set(t);let n=t.length,i=new Uint8Array(r),s=e.create({}),a=0,c=0;return{stats:()=>({calls:a,xofs:c}),get:(u,d)=>(o[n+0]=u,o[n+1]=d,s.destroy(),s=e.create({}).update(o),a++,()=>(c++,s.xofInto(i))),clean:()=>{s.destroy(),Pt(i,o)}}},CU;var PU=v(()=>{RU();Mg();Kg();/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */CU=fce(kU)});function Ws(e,t){for(let r=0;r<nr;r++)e[r]=Ud(e[r]+t[r])}function Sce(e,t){for(let r=0;r<nr;r++)e[r]=Ud(e[r]-t[r])}function vce(e,t,r,o,n){let i=Ud(t*o*n+e*r),s=Ud(e*o+t*r);return{c0:i,c1:s}}function Hg(e,t){for(let r=0;r<nr/2;r++){let o=gce[64+(r>>1)];if(r&1)o=-o;let{c0:n,c1:i}=vce(e[2*r+0],e[2*r+1],t[2*r+0],t[2*r+1],o);e[2*r+0]=n,e[2*r+1]=i}return e}function zU(e){let t=new Uint16Array(nr);for(let r=0;r<nr;){let o=e();if(o.length%3)throw Error("SampleNTT: unaligned block");for(let n=0;r<nr&&n+3<=o.length;n+=3){let i=(o[n+0]>>0|o[n+1]<<8)&4095,s=(o[n+1]>>4|o[n+2]<<4)&4095;if(i<Ro)t[r++]=i;if(r<nr&&s<Ro)t[r++]=s}}return t}function Zd(e,t,r,o){let n=e(o*nr/4,t,r),i=new Uint16Array(nr),s=Rg(n),a=0;for(let c=0,u=0,d=0,p=0;c<s.length;c++){let m=s[c];for(let h=0;h<32;h++)if(d+=m&1,m>>=1,a+=1,a===o)p=d,d=0;else if(a===2*o)i[u++]=Ud(p-d),d=0,a=0}if(a)throw Error(`sampleCBD: leftover bits: ${a}`);return i}function LA(e){let t=wce(e),{HASH256:r,HASH512:o,KDF:n}=e,{secretCoder:i,lengths:s}=t,a=Js("secretKey",s.secretKey,s.publicKey,32,32),c=32,u=64;return{info:{type:"ml-kem"},lengths:{...s,seed:64,msg:32,msgRand:32,secretKey:a.bytesLen},keygen:(d=Jn(64))=>{Te(d,64,"seed");let{publicKey:p,secretKey:m}=t.keygen(d.subarray(0,32)),h=r(p),b=a.encode([m,p,h,d.subarray(32)]);return Pt(m,h),{publicKey:p,secretKey:b}},getPublicKey:(d)=>{let[p,m,h,b]=a.decode(d);return Uint8Array.from(m)},encapsulate:(d,p=Jn(32))=>{Te(d,s.publicKey,"publicKey"),Te(p,32,"message");let m=d.subarray(0,384*e.K),h=i.encode(i.decode($U(m)));if(!qg(h,m))throw Pt(h),Error("ML-KEM.encapsulate: wrong publicKey modulus");Pt(h);let b=o.create().update(p).update(r(d)).digest(),y=t.encrypt(d,p,b.subarray(32,64));return Pt(b.subarray(32)),{cipherText:y,sharedSecret:b.subarray(0,32)}},decapsulate:(d,p)=>{Te(p,a.bytesLen,"secretKey"),Te(d,s.cipherText,"cipherText");let m=a.bytesLen-96,h=m+32,b=r(p.subarray(m/2,h));if(!qg(b,p.subarray(h,h+32)))throw Error("invalid secretKey: hash check failed");let[y,S,x,_]=a.decode(p),A=t.decrypt(d,y),O=o.create().update(A).update(x).digest(),L=O.subarray(0,32),z=t.encrypt(S,A,O.subarray(32,64)),H=qg(d,z),P=n.create({dkLen:32}).update(_).update(d).digest();return Pt(A,z,!H?L:P),H?L:P}}}function xce(e,t,r){return Hn.create({dkLen:e}).update(t).update(new Uint8Array([r])).digest()}var nr=256,Ro=3329,mce=3303,hce=17,Ud,gce,Vs,yce,DA,bce=(e)=>{if(e>=12)return{encode:(r)=>r,decode:(r)=>r};let t=2**(e-1);return{encode:(r)=>((r<<e)+Ro/2)/Ro,decode:(r)=>r*Ro+t>>>e}},jd=(e)=>yce(e,bce(e)),wce=(e)=>{let{K:t,PRF:r,XOF:o,HASH512:n,ETA1:i,ETA2:s,du:a,dv:c}=e,u=jd(1),d=jd(c),p=jd(a),m=Js("publicKey",Fg(jd(12),t),32),h=Fg(jd(12),t),b=Js("ciphertext",Fg(p,t),d),y=Js("seed",32,32);return{secretCoder:h,lengths:{secretKey:h.bytesLen,publicKey:m.bytesLen,cipherText:b.bytesLen},keygen:(S)=>{Te(S,32,"seed");let x=new Uint8Array(33);x.set(S),x[32]=t;let _=n(x),[A,O]=y.decode(_),L=[],z=[];for(let W=0;W<t;W++)L.push(Vs.encode(Zd(r,O,W,i)));let H=o(A);for(let W=0;W<t;W++){let ee=Vs.encode(Zd(r,O,t+W,i));for(let j=0;j<t;j++){let R=zU(H.get(j,W));Ws(ee,Hg(R,L[j]))}z.push(ee)}H.clean();let P={publicKey:m.encode([z,A]),secretKey:h.encode(L)};return Pt(A,O,L,z,x,_),P},encrypt:(S,x,_)=>{let[A,O]=m.decode(S),L=[];for(let j=0;j<t;j++)L.push(Vs.encode(Zd(r,_,j,i)));let z=o(O),H=new Uint16Array(nr),P=[];for(let j=0;j<t;j++){let R=Zd(r,_,t+j,s),B=new Uint16Array(nr);for(let k=0;k<t;k++){let T=zU(z.get(j,k));Ws(B,Hg(T,L[k]))}Ws(R,Vs.decode(B)),P.push(R),Ws(H,Hg(A[j],L[j])),Pt(B)}z.clean();let W=Zd(r,_,2*t,s);Ws(W,Vs.decode(H));let ee=u.decode(x);return Ws(ee,W),Pt(A,L,H,W),b.encode([P,ee])},decrypt:(S,x)=>{let[_,A]=b.decode(S),O=h.decode(x),L=new Uint16Array(nr);for(let z=0;z<t;z++)Ws(L,Hg(O[z],Vs.encode(_[z])));return Sce(A,Vs.decode(L)),Pt(L,O,_),u.encode(A)}}},BA,yCe,Md,NU;var DU=v(()=>{Mg();jr();PU();Kg();/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */({mod:Ud,nttZetas:gce,NTT:Vs,bitsCoder:yce}=OU({N:nr,Q:Ro,F:mce,ROOT_OF_UNITY:hce,newPoly:(e)=>new Uint16Array(e),brvBits:7,isKyber:!0})),DA={512:{N:nr,Q:Ro,K:2,ETA1:3,ETA2:2,du:10,dv:4,RBGstrength:128},768:{N:nr,Q:Ro,K:3,ETA1:2,ETA2:2,du:10,dv:4,RBGstrength:192},1024:{N:nr,Q:Ro,K:4,ETA1:2,ETA2:2,du:11,dv:5,RBGstrength:256}};BA={HASH256:Hs,HASH512:_U,KDF:Hn,XOF:CU,PRF:xce},yCe=LA({...BA,...DA[512]}),Md=LA({...BA,...DA[768]}),NU=LA({...BA,...DA[1024]})});function _ce(e,t=!1){let{lengths:r,keygen:o}=e;if(t){let i=e.Point.Fn;if(!i)throw Error("No Point.Fn");o=(s=Jn(r.seed))=>{Te(s,r.seed,"seed");let a=i.isLE?$i(s):Ri(s),c=i.toBytes(i.create(a));return{secretKey:c,publicKey:e.getPublicKey(c)}}}return{lengths:{secretKey:r.secretKey,publicKey:r.publicKey,seed:r.seed},keygen:o,getPublicKey:(n)=>e.getPublicKey(n)}}function jA(e,t=!1){let r=_ce(e,t);if(!e.getSharedSecret)throw Error("wrong curve");return{lengths:{...r.lengths,msg:r.lengths.seed,cipherText:r.lengths.publicKey},keygen:r.keygen,getPublicKey:r.getPublicKey,encapsulate(o,n=Jn(e.lengths.seed)){let i=this.keygen(n).secretKey,s=this.decapsulate(o,i),a=e.getPublicKey(i);return Pt(i),{sharedSecret:s,cipherText:a}},decapsulate(o,n){let i=e.getSharedSecret(n,o);return e.lengths.publicKeyHasPrefix?i.subarray(1):i}}}function qd(e,t){return Js(t,...e.map((r)=>{if(typeof r.lengths[t]!=="number")throw Error("wrong length: "+t);return r.lengths[t]}))}function ZA(e){return(t,r)=>e(t,{dkLen:r})}function Ece(e,t,...r){let o=qd(r,"seed"),n=qd(r,"publicKey");if(e===void 0)e=o.bytesLen;Zt(e);function i(s){Te(s,e);let a=o.decode(t(s,o.bytesLen)),c=r.map((p,m)=>p.keygen(a[m])),u=c.map((p)=>p.secretKey),d=c.map((p)=>p.publicKey);return{secretKey:u,publicKey:d}}return{info:{lengths:{seed:e,publicKey:n.bytesLen,secretKey:e}},getPublicKey(s){return this.keygen(s).publicKey},keygen(s=Jn(e)){let{publicKey:a,secretKey:c}=i(s),u=n.encode(a);return Pt(a),Pt(c),{secretKey:s,publicKey:u}},expandDecapsulationKey:i,realSeedLen:e}}function Jg(e,t,r,o,...n){let i=Ece(e,r,...n),s=qd(n,"cipherText"),a=qd(n,"publicKey"),c=qd(n,"msg");if(t===void 0)t=c.bytesLen;return Zt(t),{lengths:{...i.info.lengths,msg:t,msgRand:c.bytesLen,cipherText:s.bytesLen},getPublicKey:i.getPublicKey,keygen:i.keygen,encapsulate(u,d=Jn(c.bytesLen)){let p=a.decode(u),m=c.decode(d),h=n.map((x,_)=>x.encapsulate(p[_],m[_])),b=h.map((x)=>x.sharedSecret),y=h.map((x)=>x.cipherText),S={sharedSecret:o(p,y,b),cipherText:s.encode(y)};return Pt(b,y),S},decapsulate(u,d){let p=s.decode(u),{publicKey:m,secretKey:h}=i.expandDecapsulationKey(d),b=n.map((y,S)=>y.decapsulate(p[S],h[S]));return o(m,p,b)}}}function LU(e,t,r,o,n){return Xr(o),Xr(n),Jg(32,32,ZA(o),(i,s,a)=>n(kt(a[0],a[1],s[1],i[1],Oi(e))),t,r)}function kce(e,t,r,o,n){return Xr(o),Xr(n),Jg(32,32,ZA(o),(i,s,a)=>{let c=kt(a[0],a[1],s[0],i[0],s[1],i[1],Oi(e)),u=32,d=kt(Oi("hybrid_prk"),c),p=fU(n,d),m=kt(Bc(32,2),Oi("shared_secret"),Oi("")),h=mU(n,p,m,32);return Pt(p,m,d,c),h},t,r)}function Ace(e,t,r,o){let n=e.Point.Fn;if(!n)throw Error("no Point.Fn");function i(s){let a;for(let d=0,p=t;;d=p,p+=t){if(p>s.length)throw Error("rejection sampling failed");if(a=n.fromBytes(s.subarray(d,p),!0),n.isValidNot0(a))break}let c=n.toBytes(n.create(a)),u=e.getPublicKey(c,!1);return{secretKey:c,publicKey:u}}return{lengths:{secretKey:t,publicKey:r,seed:o,msg:o,cipherText:r},keygen(s=Jn(o)){return Te(s,o,"seed"),i(s)},getPublicKey(s){return e.getPublicKey(s,!1)},encapsulate(s,a=Jn(o)){Te(a,o,"rand");let{secretKey:c}=i(a),u=this.decapsulate(s,c),d=e.getPublicKey(c,!1);return Pt(c),{sharedSecret:u,cipherText:d}},decapsulate(s,a){return e.getSharedSecret(a,s).subarray(1)}}}function Tce(e,t,r,o){let{secretKey:n,publicKeyUncompressed:i}=r.lengths;if(!n||!i)throw Error("wrong curve");let s=Ace(r,n,i,o),a=64,c=a+o;return Jg(32,32,(u)=>{Te(u,32);let d=Hn(u,{dkLen:c}),p=d.subarray(0,a),m=d.subarray(a,c);return kt(p,m)},(u,d,p)=>Hs(kt(p[0],p[1],d[1],u[1],Oi(e))),t,s)}var TCe,RCe,BU,$Ce,Ice,Rce,Vg,jU;var ZU=v(()=>{lU();dU();jc();hU();RA();Mg();jr();DU();Kg();/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */TCe=LU("QSF-KEM(ML-KEM-768,P-256)-XOF(SHAKE256)-KDF(SHA3-256)",Md,jA($A,!0),Hn,Hs),RCe=LU("QSF-KEM(ML-KEM-1024,P-384)-XOF(SHAKE256)-KDF(SHA3-256)",NU,jA(uU,!0),Hn,Hs);BU=jA(cU),$Ce=kce("KitchenSink-KEM(ML-KEM-768,X25519)-XOF(SHAKE256)-KDF(HKDF-SHA-256)",Md,BU,Hn,Zg),Ice=(()=>Jg(32,32,ZA(Hn),(e,t,r)=>Hs(kt(r[0],r[1],t[1],e[1],Oi("\\.//^\\"))),Md,BU))();Rce=(()=>Tce("MLKEM768-P256",Md,$A,128))(),Vg=Ice,jU=Rce});function $o(e,t=""){if(typeof e!=="boolean"){let r=t&&`"${t}" `;throw TypeError(r+"expected boolean, got type="+typeof e)}return e}function Qg(e){if(typeof e==="bigint"){if(!Wg(e))throw RangeError("positive bigint expected, got "+e)}else MA(e);return e}function Vn(e,t=""){if(typeof e!=="number"){let r=t&&`"${t}" `;throw TypeError(r+"expected number, got type="+typeof e)}if(!Number.isSafeInteger(e)){let r=t&&`"${t}" `;throw RangeError(r+"expected safe integer, got "+e)}}function Fd(e){let t=Qg(e).toString(16);return t.length&1?"0"+t:t}function UU(e){if(typeof e!=="string")throw TypeError("hex string expected, got "+typeof e);return e===""?Gg:BigInt("0x"+e)}function Gs(e){return UU(hg(e))}function bn(e){return UU(hg(Di(Ft(e)).reverse()))}function Yg(e,t){if(vt(t),t===0)throw RangeError("zero length");e=Qg(e);let r=e.toString(16);if(r.length>t*2)throw RangeError("number too large");return yd(r.padStart(t*2,"0"))}function Kd(e,t){return Yg(e,t).reverse()}function MU(e,t){if(e=et(e),t=et(t),e.length!==t.length)return!1;let r=0;for(let o=0;o<e.length;o++)r|=e[o]^t[o];return r===0}function Di(e){return Uint8Array.from(et(e))}function Xg(e){if(typeof e!=="string")throw TypeError("ascii string expected, got "+typeof e);return Uint8Array.from(e,(t,r)=>{let o=t.charCodeAt(0);if(t.length!==1||o>127)throw RangeError(`string contains non-ASCII character "${e[r]}" with code ${o} at position ${r}`);return o})}function $ce(e,t,r){return Wg(e)&&Wg(t)&&Wg(r)&&t<=e&&e<r}function Oo(e,t,r,o){if(!$ce(t,r,o))throw RangeError("expected valid "+e+": "+r+" <= n < "+o+", got "+t)}function Vc(e){if(e<Gg)throw Error("expected non-negative bigint, got "+e);let t;for(t=0;e>Gg;e>>=UA,t+=1);return t}function qU(e,t,r){if(vt(e,"hashLen"),vt(t,"qByteLen"),typeof r!=="function")throw TypeError("hmacFn must be a function");let o=(S)=>new Uint8Array(S),n=Uint8Array.of(),i=Uint8Array.of(0),s=Uint8Array.of(1),a=1000,c=o(e),u=o(e),d=0,p=()=>{c.fill(1),u.fill(0),d=0},m=(...S)=>r(u,Vt(c,...S)),h=(S=n)=>{if(u=m(i,S),c=m(),S.length===0)return;u=m(s,S),c=m()},b=()=>{if(d++>=a)throw Error("drbg: tried max amount of iterations");let S=0,x=[];while(S<t){c=m();let _=c.slice();x.push(_),S+=c.length}return Vt(...x)};return(S,x)=>{p(),h(S);let _=void 0;while((_=x(b()))===void 0)h();return p(),_}}function tn(e,t={},r={}){if(Object.prototype.toString.call(e)!=="[object Object]")throw TypeError("expected valid options object");function o(i,s,a){if(!a&&s!=="function"&&!Object.hasOwn(e,i))throw TypeError(`param "${i}" is invalid: expected own property`);let c=e[i];if(a&&c===void 0)return;let u=typeof c;if(u!==s||c===null)throw TypeError(`param "${i}" is invalid: expected ${s}, got ${u}`)}let n=(i,s)=>Object.entries(i).forEach(([a,c])=>o(a,c,s));n(t,!1),n(r,!0)}var et=(e,t,r)=>Ft(e,t,r),MA,Fc,Vt=(...e)=>jI(...e),Kc=(e)=>yd(e),Hc,Jc=(e)=>xo(e),Gg,UA,Wg=(e)=>typeof e==="bigint"&&Gg<=e,Hd=(e)=>(UA<<BigInt(e))-UA,qA=()=>{throw Error("not implemented")};var Li=v(()=>{Gr();/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */MA=vt,Fc=hg,Hc=DI,Gg=BigInt(0),UA=BigInt(1)});function it(e,t){if(t<=Wt)throw Error("mod: expected positive modulus, got "+t);let r=e%t;return r>=Wt?r:t+r}function rn(e,t,r){if(t<Wt)throw Error("pow2: expected non-negative exponent, got "+t);let o=e;while(t-- >Wt)o*=o,o%=r;return o}function FU(e,t){if(e===Wt)throw Error("invert: expected non-zero number");if(t<=Wt)throw Error("invert: expected positive modulus, got "+t);let r=it(e,t),o=t,n=Wt,i=yt,s=yt,a=Wt;while(r!==Wt){let u=o/r,d=o-r*u,p=n-s*u,m=i-a*u;o=r,r=d,n=s,i=a,s=p,a=m}if(o!==yt)throw Error("invert: does not exist");return it(n,t)}function FA(e,t,r){let o=e;if(!o.eql(o.sqr(t),r))throw Error("Cannot find square root")}function YU(e,t){let r=e,o=(r.ORDER+yt)/VU,n=r.pow(t,o);return FA(r,n,t),n}function Pce(e,t){let r=e,o=(r.ORDER-WU)/GU,n=r.mul(t,Qs),i=r.pow(n,o),s=r.mul(t,i),a=r.mul(r.mul(s,Qs),i),c=r.mul(s,r.sub(a,r.ONE));return FA(r,c,t),c}function zce(e){let t=ey(e),r=XU(e),o=r(t,t.neg(t.ONE)),n=r(t,o),i=r(t,t.neg(o)),s=(e+Oce)/QU;return(a,c)=>{let u=a,d=u.pow(c,s),p=u.mul(d,o),m=u.mul(d,n),h=u.mul(d,i),b=u.eql(u.sqr(p),c),y=u.eql(u.sqr(m),c);d=u.cmov(d,p,b),p=u.cmov(h,m,y);let S=u.eql(u.sqr(p),c),x=u.cmov(d,p,S);return FA(u,x,c),x}}function XU(e){if(e<JU)throw Error("sqrt is not defined for small field");let t=e-yt,r=0;while(t%Qs===Wt)t/=Qs,r++;let o=Qs,n=ey(e);while(KU(n,o)===1)if(o++>1000)throw Error("Cannot find square root: probably non-prime P");if(r===1)return YU;let i=n.pow(o,t),s=(t+yt)/Qs;return function(c,u){let d=c;if(d.is0(u))return u;if(KU(d,u)!==1)throw Error("Cannot find square root");let p=r,m=d.mul(d.ONE,i),h=d.pow(u,t),b=d.pow(u,s);while(!d.eql(h,d.ONE)){if(d.is0(h))return d.ZERO;let y=1,S=d.sqr(h);while(!d.eql(S,d.ONE))if(y++,S=d.sqr(S),y===p)throw Error("Cannot find square root");let x=yt<<BigInt(p-y-1),_=d.pow(m,x);p=y,m=d.sqr(_),h=d.mul(h,m),b=d.mul(b,_)}return b}}function Nce(e){if(e%VU===JU)return YU;if(e%GU===WU)return Pce;if(e%QU===Cce)return zce(e);return XU(e)}function KA(e){let t={ORDER:"bigint",BYTES:"number",BITS:"number"},r=Dce.reduce((o,n)=>(o[n]="function",o),t);if(tn(e,r),Vn(e.BYTES,"BYTES"),Vn(e.BITS,"BITS"),e.BYTES<1||e.BITS<1)throw Error("invalid field: expected BYTES/BITS > 0");if(e.ORDER<=yt)throw Error("invalid field: expected ORDER > 1, got "+e.ORDER);return e}function Lce(e,t,r){let o=e;if(r<Wt)throw Error("invalid exponent, negatives unsupported");if(r===Wt)return o.ONE;if(r===yt)return t;let n=o.ONE,i=t;while(r>Wt){if(r&yt)n=o.mul(n,i);i=o.sqr(i),r>>=yt}return n}function Jd(e,t,r=!1){let o=e,n=Array(t.length).fill(r?o.ZERO:void 0),i=t.reduce((a,c,u)=>{if(o.is0(c))return a;return n[u]=a,o.mul(a,c)},o.ONE),s=o.inv(i);return t.reduceRight((a,c,u)=>{if(o.is0(c))return a;return n[u]=o.mul(a,n[u]),o.mul(a,c)},s),n}function KU(e,t){let r=e,o=(r.ORDER-yt)/Qs,n=r.pow(t,o),i=r.eql(n,r.ONE),s=r.eql(n,r.ZERO),a=r.eql(n,r.neg(r.ONE));if(!i&&!s&&!a)throw Error("invalid Legendre symbol result");return i?1:s?0:-1}function Bce(e,t){if(t!==void 0)MA(t);if(e<=Wt)throw Error("invalid n length: expected positive n, got "+e);if(t!==void 0&&t<1)throw Error("invalid n length: expected positive bit length, got "+t);let r=Vc(e);if(t!==void 0&&t<r)throw Error(`invalid n length: expected bit length (${r}) >= n.length (${t})`);let o=t!==void 0?t:r,n=Math.ceil(o/8);return{nBitLength:o,nByteLength:n}}class HA{ORDER;BITS;BYTES;isLE;ZERO=Wt;ONE=yt;_lengths;_mod;constructor(e,t={}){if(e<=yt)throw Error("invalid field: expected ORDER > 1, got "+e);let r=void 0;if(this.isLE=!1,t!=null&&typeof t==="object"){if(typeof t.BITS==="number")r=t.BITS;if(typeof t.sqrt==="function")Object.defineProperty(this,"sqrt",{value:t.sqrt,enumerable:!0});if(typeof t.isLE==="boolean")this.isLE=t.isLE;if(t.allowedLengths)this._lengths=Object.freeze(t.allowedLengths.slice());if(typeof t.modFromBytes==="boolean")this._mod=t.modFromBytes}let{nBitLength:o,nByteLength:n}=Bce(e,r);if(n>2048)throw Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=e,this.BITS=o,this.BYTES=n,Object.freeze(this)}create(e){return it(e,this.ORDER)}isValid(e){if(typeof e!=="bigint")throw TypeError("invalid field element: expected bigint, got "+typeof e);return Wt<=e&&e<this.ORDER}is0(e){return e===Wt}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&yt)===yt}neg(e){return it(-e,this.ORDER)}eql(e,t){return e===t}sqr(e){return it(e*e,this.ORDER)}add(e,t){return it(e+t,this.ORDER)}sub(e,t){return it(e-t,this.ORDER)}mul(e,t){return it(e*t,this.ORDER)}pow(e,t){return Lce(this,e,t)}div(e,t){return it(e*FU(t,this.ORDER),this.ORDER)}sqrN(e){return e*e}addN(e,t){return e+t}subN(e,t){return e-t}mulN(e,t){return e*t}inv(e){return FU(e,this.ORDER)}sqrt(e){let t=HU.get(this);if(!t)HU.set(this,t=Nce(this.ORDER));return t(this,e)}toBytes(e){return this.isLE?Kd(e,this.BYTES):Yg(e,this.BYTES)}fromBytes(e,t=!1){et(e);let{_lengths:r,BYTES:o,isLE:n,ORDER:i,_mod:s}=this;if(r){if(e.length<1||!r.includes(e.length)||e.length>o)throw Error("Field.fromBytes: expected "+r+" bytes, got "+e.length);let c=new Uint8Array(o);c.set(e,n?0:c.length-e.length),e=c}if(e.length!==o)throw Error("Field.fromBytes: expected "+o+" bytes, got "+e.length);let a=n?bn(e):Gs(e);if(s)a=it(a,i);if(!t){if(!this.isValid(a))throw Error("invalid field element: outside of range 0..ORDER")}return a}invertBatch(e){return Jd(this,e)}cmov(e,t,r){return $o(r,"condition"),r?t:e}}function ey(e,t={}){return new HA(e,t)}function e6(e){if(typeof e!=="bigint")throw Error("field order must be bigint");if(e<=yt)throw Error("field order must be greater than 1");let t=Vc(e-yt);return Math.ceil(t/8)}function JA(e){let t=e6(e);return t+Math.ceil(t/2)}function t6(e,t,r=!1){et(e);let o=e.length,n=e6(t),i=Math.max(JA(t),16);if(o<i||o>1024)throw Error("expected "+i+"-1024 bytes of input, got "+o);let s=r?bn(e):Gs(e),a=it(s,t-yt)+yt;return r?Kd(a,n):Yg(a,n)}var Wt,yt,Qs,JU,VU,WU,Oce,GU,Cce,QU,Co=(e,t)=>(it(e,t)&yt)===yt,Dce,HU;var Vd=v(()=>{Li();/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */Wt=BigInt(0),yt=BigInt(1),Qs=BigInt(2),JU=BigInt(3),VU=BigInt(4),WU=BigInt(5),Oce=BigInt(7),GU=BigInt(8),Cce=BigInt(9),QU=BigInt(16);Dce=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];HU=new WeakMap;Object.freeze(HA.prototype)});function Wd(e,t){let r=t.negate();return e?r:t}function Xs(e,t){let r=Jd(e.Fp,t.map((o)=>o.Z));return t.map((o,n)=>e.fromAffine(o.toAffine(r[n])))}function i6(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw Error("invalid window size, expected [1.."+t+"], got W="+e)}function VA(e,t){i6(e,t);let r=Math.ceil(t/e)+1,o=2**(e-1),n=2**e,i=Hd(e),s=BigInt(e);return{windows:r,windowSize:o,mask:i,maxNumber:n,shiftBy:s}}function r6(e,t,r){let{windowSize:o,mask:n,maxNumber:i,shiftBy:s}=r,a=Number(e&n),c=e>>s;if(a>o)a-=i,c+=Ys;let u=t*o,d=u+Math.abs(a)-1,p=a===0,m=a<0,h=t%2!==0;return{nextN:c,offset:d,isZero:p,isNeg:m,isNegF:h,offsetF:u}}function GA(e){return s6.get(e)||1}function n6(e){if(e!==Wc)throw Error("invalid wNAF")}class Gd{BASE;ZERO;Fn;bits;constructor(e,t){this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=t}_unsafeLadder(e,t,r=this.ZERO){let o=e;while(t>Wc){if(t&Ys)r=r.add(o);o=o.double(),t>>=Ys}return r}precomputeWindow(e,t){let{windows:r,windowSize:o}=VA(t,this.bits),n=[],i=e,s=i;for(let a=0;a<r;a++){s=i,n.push(s);for(let c=1;c<o;c++)s=s.add(i),n.push(s);i=s.double()}return n}wNAF(e,t,r){if(!this.Fn.isValid(r))throw Error("invalid scalar");let o=this.ZERO,n=this.BASE,i=VA(e,this.bits);for(let s=0;s<i.windows;s++){let{nextN:a,offset:c,isZero:u,isNeg:d,isNegF:p,offsetF:m}=r6(r,s,i);if(r=a,u)n=n.add(Wd(p,t[m]));else o=o.add(Wd(d,t[c]))}return n6(r),{p:o,f:n}}wNAFUnsafe(e,t,r,o=this.ZERO){let n=VA(e,this.bits);for(let i=0;i<n.windows;i++){if(r===Wc)break;let{nextN:s,offset:a,isZero:c,isNeg:u}=r6(r,i,n);if(r=s,c)continue;else{let d=t[a];o=o.add(u?d.negate():d)}}return n6(r),o}getPrecomputes(e,t,r){let o=WA.get(t);if(!o){if(o=this.precomputeWindow(t,e),e!==1){if(typeof r==="function")o=r(o);WA.set(t,o)}}return o}cached(e,t,r){let o=GA(e);return this.wNAF(o,this.getPrecomputes(o,e,r),t)}unsafe(e,t,r,o){let n=GA(e);if(n===1)return this._unsafeLadder(e,t,o);return this.wNAFUnsafe(n,this.getPrecomputes(n,e,r),t,o)}createCache(e,t){i6(t,this.bits),s6.set(e,t),WA.delete(e)}hasCache(e){return GA(e)!==1}}function a6(e,t,r,o){let n=t,i=e.ZERO,s=e.ZERO;while(r>Wc||o>Wc){if(r&Ys)i=i.add(n);if(o&Ys)s=s.add(n);n=n.double(),r>>=Ys,o>>=Ys}return{p1:i,p2:s}}function o6(e,t,r){if(t){if(t.ORDER!==e)throw Error("Field.ORDER must match order: Fp == p, Fn == n");return KA(t),t}else return ey(e,{isLE:r})}function ty(e,t,r={},o){if(o===void 0)o=e==="edwards";if(!t||typeof t!=="object")throw Error(`expected valid ${e} CURVE object`);for(let c of["p","n","h"]){let u=t[c];if(!(typeof u==="bigint"&&u>Wc))throw Error(`CURVE.${c} must be positive bigint`)}let n=o6(t.p,r.Fp,o),i=o6(t.n,r.Fn,o),a=["Gx","Gy","a",e==="weierstrass"?"b":"d"];for(let c of a)if(!n.isValid(t[c]))throw Error(`CURVE.${c} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:n,Fn:i}}function Qd(e,t){return function(o){let n=e(o);return{secretKey:n,publicKey:t(n)}}}var Wc,Ys,WA,s6;var ry=v(()=>{Li();Vd();/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */Wc=BigInt(0),Ys=BigInt(1);WA=new WeakMap,s6=new WeakMap});function Yd(e,t){if(Vn(e),Vn(t),t<0||t>4)throw Error("invalid I2OSP length: "+t);if(e<0||e>2**(8*t)-1)throw Error("invalid I2OSP input: "+e);let r=Array.from({length:t}).fill(0);for(let o=t-1;o>=0;o--)r[o]=e&255,e>>>=8;return new Uint8Array(r)}function jce(e,t){let r=new Uint8Array(e.length);for(let o=0;o<e.length;o++)r[o]=e[o]^t[o];return r}function Zce(e){if(!Hc(e)&&typeof e!=="string")throw Error("DST must be Uint8Array or ascii string");let t=typeof e==="string"?Xg(e):e;if(t.length===0)throw Error("DST must be non-empty");return t}function QA(e,t,r,o){if(et(e),Vn(r),t=Zce(t),t.length>255)t=o(Vt(Xg("H2C-OVERSIZE-DST-"),t));let{outputLen:n,blockLen:i}=o,s=Math.ceil(r/n);if(r>65535||s>255)throw Error("expand_message_xmd: invalid lenInBytes");let a=Vt(t,Yd(t.length,1)),c=new Uint8Array(i),u=Yd(r,2),d=Array(s),p=o(Vt(c,e,u,Yd(0,1),a));d[0]=o(Vt(p,Yd(1,1),a));for(let h=1;h<s;h++){let b=[jce(p,d[h-1]),Yd(h+1,1),a];d[h]=o(Vt(...b))}return Vt(...d).slice(0,r)}var c6="HashToScalar-";var l6=v(()=>{Li()});function Uce(e,t,r){Oo("scalar",e,Wn,r);let[[o,n],[i,s]]=t,a=u6(s*e,r),c=u6(-n*e,r),u=e-a*o-c*i,d=-a*n-c*s,p=u<Wn,m=d<Wn;if(p)u=-u;if(m)d=-d;let h=Hd(Math.ceil(Vc(r)/2))+Bi;if(u<Wn||u>=h||d<Wn||d>=h)throw Error("splitScalar (endomorphism): failed for k");return{k1neg:p,k1:u,k2neg:m,k2:d}}function XA(e){if(!["compact","recovered","der"].includes(e))throw Error('Signature format must be "compact", "recovered", or "der"');return e}function YA(e,t){tn(e);let r={};for(let o of Object.keys(t))r[o]=e[o]===void 0?t[o]:e[o];if($o(r.lowS,"lowS"),$o(r.prehash,"prehash"),r.format!==void 0)XA(r.format);return r}function f6(e,t={}){let r=ty("weierstrass",e,t),o=r.Fp,n=r.Fn,i=r.CURVE,{h:s,n:a}=i;tn(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});let{endo:c,allowInfinityPoint:u}=t;if(c){if(!o.is0(i.a)||typeof c.beta!=="bigint"||!Array.isArray(c.basises))throw Error('invalid endo: expected "beta": bigint and "basises": array')}let d=h6(o,n);function p(){if(!o.isOdd)throw Error("compression is not supported: Field does not have .isOdd()")}function m(j,R,B){if(u&&R.is0())return Uint8Array.of(0);let{x:k,y:T}=R.toAffine(),I=o.toBytes(k);if($o(B,"isCompressed"),B){p();let q=!o.isOdd(T);return Vt(m6(q),I)}else return Vt(Uint8Array.of(4),I,o.toBytes(T))}function h(j){et(j,void 0,"Point");let{publicKey:R,publicKeyUncompressed:B}=d,k=j.length,T=j[0],I=j.subarray(1);if(u&&k===1&&T===0)return{x:o.ZERO,y:o.ZERO};if(k===R&&(T===2||T===3)){let q=o.fromBytes(I);if(!o.isValid(q))throw Error("bad point: is not on curve, wrong x");let N=S(q),J;try{J=o.sqrt(N)}catch(ae){let me=ae instanceof Error?": "+ae.message:"";throw Error("bad point: is not on curve, sqrt error"+me)}p();let G=o.isOdd(J);if((T&1)===1!==G)J=o.neg(J);return{x:q,y:J}}else if(k===B&&T===4){let q=o.BYTES,N=o.fromBytes(I.subarray(0,q)),J=o.fromBytes(I.subarray(q,q*2));if(!x(N,J))throw Error("bad point: is not on curve");return{x:N,y:J}}else throw Error(`bad point: got length ${k}, expected compressed=${R} or uncompressed=${B}`)}let b=t.toBytes===void 0?m:t.toBytes,y=t.fromBytes===void 0?h:t.fromBytes;function S(j){let R=o.sqr(j),B=o.mul(R,j);return o.add(o.add(B,o.mul(j,i.a)),i.b)}function x(j,R){let B=o.sqr(R),k=S(j);return o.eql(B,k)}if(!x(i.Gx,i.Gy))throw Error("bad curve params: generator point");let _=o.mul(o.pow(i.a,ny),Mce),A=o.mul(o.sqr(i.b),BigInt(27));if(o.is0(o.add(_,A)))throw Error("bad curve params: a or b");function O(j,R,B=!1){if(!o.isValid(R)||B&&o.is0(R))throw Error(`bad point coordinate ${j}`);return R}function L(j){if(!(j instanceof P))throw Error("Weierstrass Point expected")}function z(j){if(!c||!c.basises)throw Error("no endo");return Uce(j,c.basises,n.ORDER)}function H(j,R,B,k,T){return B=new P(o.mul(B.X,j),B.Y,B.Z),R=Wd(k,R),B=Wd(T,B),R.add(B)}class P{static BASE=new P(i.Gx,i.Gy,o.ONE);static ZERO=new P(o.ZERO,o.ONE,o.ZERO);static Fp=o;static Fn=n;X;Y;Z;constructor(j,R,B){this.X=O("x",j),this.Y=O("y",R,!0),this.Z=O("z",B),Object.freeze(this)}static CURVE(){return i}static fromAffine(j){let{x:R,y:B}=j||{};if(!j||!o.isValid(R)||!o.isValid(B))throw Error("invalid affine point");if(j instanceof P)throw Error("projective point not allowed");if(o.is0(R)&&o.is0(B))return P.ZERO;return new P(R,B,o.ONE)}static fromBytes(j){let R=P.fromAffine(y(et(j,void 0,"point")));return R.assertValidity(),R}static fromHex(j){return P.fromBytes(Kc(j))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(j=8,R=!0){if(ee.createCache(this,j),!R)this.multiply(ny);return this}assertValidity(){let j=this;if(j.is0()){if(t.allowInfinityPoint&&o.is0(j.X)&&o.eql(j.Y,o.ONE)&&o.is0(j.Z))return;throw Error("bad point: ZERO")}let{x:R,y:B}=j.toAffine();if(!o.isValid(R)||!o.isValid(B))throw Error("bad point: x or y not field elements");if(!x(R,B))throw Error("bad point: equation left != right");if(!j.isTorsionFree())throw Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y:j}=this.toAffine();if(!o.isOdd)throw Error("Field doesn't support isOdd");return!o.isOdd(j)}equals(j){L(j);let{X:R,Y:B,Z:k}=this,{X:T,Y:I,Z:q}=j,N=o.eql(o.mul(R,q),o.mul(T,k)),J=o.eql(o.mul(B,q),o.mul(I,k));return N&&J}negate(){return new P(this.X,o.neg(this.Y),this.Z)}double(){let{a:j,b:R}=i,B=o.mul(R,ny),{X:k,Y:T,Z:I}=this,q=o.ZERO,N=o.ZERO,J=o.ZERO,G=o.mul(k,k),re=o.mul(T,T),ae=o.mul(I,I),me=o.mul(k,T);return me=o.add(me,me),J=o.mul(k,I),J=o.add(J,J),q=o.mul(j,J),N=o.mul(B,ae),N=o.add(q,N),q=o.sub(re,N),N=o.add(re,N),N=o.mul(q,N),q=o.mul(me,q),J=o.mul(B,J),ae=o.mul(j,ae),me=o.sub(G,ae),me=o.mul(j,me),me=o.add(me,J),J=o.add(G,G),G=o.add(J,G),G=o.add(G,ae),G=o.mul(G,me),N=o.add(N,G),ae=o.mul(T,I),ae=o.add(ae,ae),G=o.mul(ae,me),q=o.sub(q,G),J=o.mul(ae,re),J=o.add(J,J),J=o.add(J,J),new P(q,N,J)}add(j){L(j);let{X:R,Y:B,Z:k}=this,{X:T,Y:I,Z:q}=j,N=o.ZERO,J=o.ZERO,G=o.ZERO,re=i.a,ae=o.mul(i.b,ny),me=o.mul(R,T),be=o.mul(B,I),ve=o.mul(k,q),Ae=o.add(R,B),Ie=o.add(T,I);Ae=o.mul(Ae,Ie),Ie=o.add(me,be),Ae=o.sub(Ae,Ie),Ie=o.add(R,k);let we=o.add(T,q);return Ie=o.mul(Ie,we),we=o.add(me,ve),Ie=o.sub(Ie,we),we=o.add(B,k),N=o.add(I,q),we=o.mul(we,N),N=o.add(be,ve),we=o.sub(we,N),G=o.mul(re,Ie),N=o.mul(ae,ve),G=o.add(N,G),N=o.sub(be,G),G=o.add(be,G),J=o.mul(N,G),be=o.add(me,me),be=o.add(be,me),ve=o.mul(re,ve),Ie=o.mul(ae,Ie),be=o.add(be,ve),ve=o.sub(me,ve),ve=o.mul(re,ve),Ie=o.add(Ie,ve),me=o.mul(be,Ie),J=o.add(J,me),me=o.mul(we,Ie),N=o.mul(Ae,N),N=o.sub(N,me),me=o.mul(Ae,be),G=o.mul(we,G),G=o.add(G,me),new P(N,J,G)}subtract(j){return L(j),this.add(j.negate())}is0(){return this.equals(P.ZERO)}multiply(j){let{endo:R}=t;if(!n.isValidNot0(j))throw RangeError("invalid scalar: out of range");let B,k,T=(I)=>ee.cached(this,I,(q)=>Xs(P,q));if(R){let{k1neg:I,k1:q,k2neg:N,k2:J}=z(j),{p:G,f:re}=T(q),{p:ae,f:me}=T(J);k=re.add(me),B=H(R.beta,G,ae,I,N)}else{let{p:I,f:q}=T(j);B=I,k=q}return Xs(P,[B,k])[0]}multiplyUnsafe(j){let{endo:R}=t,B=this,k=j;if(!n.isValid(k))throw RangeError("invalid scalar: out of range");if(k===Wn||B.is0())return P.ZERO;if(k===Bi)return B;if(ee.hasCache(this))return this.multiply(k);if(R){let{k1neg:T,k1:I,k2neg:q,k2:N}=z(k),{p1:J,p2:G}=a6(P,B,I,N);return H(R.beta,J,G,T,q)}else return ee.unsafe(B,k)}toAffine(j){let R=this,B=j,{X:k,Y:T,Z:I}=R;if(o.eql(I,o.ONE))return{x:k,y:T};let q=R.is0();if(B==null)B=q?o.ONE:o.inv(I);let N=o.mul(k,B),J=o.mul(T,B),G=o.mul(I,B);if(q)return{x:o.ZERO,y:o.ZERO};if(!o.eql(G,o.ONE))throw Error("invZ was invalid");return{x:N,y:J}}isTorsionFree(){let{isTorsionFree:j}=t;if(s===Bi)return!0;if(j)return j(P,this);return ee.unsafe(this,a).is0()}clearCofactor(){let{clearCofactor:j}=t;if(s===Bi)return this;if(j)return j(P,this);return this.multiplyUnsafe(s)}isSmallOrder(){if(s===Bi)return this.is0();return this.clearCofactor().is0()}toBytes(j=!0){return $o(j,"isCompressed"),this.assertValidity(),b(P,this,j)}toHex(j=!0){return Fc(this.toBytes(j))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let W=n.BITS,ee=new Gd(P,t.endo?Math.ceil(W/2):W);if(W>=8)P.BASE.precompute(8);return Object.freeze(P.prototype),Object.freeze(P),P}function m6(e){return Uint8Array.of(e?2:3)}function h6(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function qce(e,t={}){let{Fn:r}=e,o=t.randomBytes===void 0?Jc:t.randomBytes,n=Object.assign(h6(e.Fp,r),{seed:Math.max(JA(r.ORDER),16)});function i(h){try{let b=r.fromBytes(h);return r.isValidNot0(b)}catch(b){return!1}}function s(h,b){let{publicKey:y,publicKeyUncompressed:S}=n;try{let x=h.length;if(b===!0&&x!==y)return!1;if(b===!1&&x!==S)return!1;return!!e.fromBytes(h)}catch(x){return!1}}function a(h){return h=h===void 0?o(n.seed):h,t6(et(h,n.seed,"seed"),r.ORDER)}function c(h,b=!0){return e.BASE.multiply(r.fromBytes(h)).toBytes(b)}function u(h){let{secretKey:b,publicKey:y,publicKeyUncompressed:S}=n,x=r._lengths;if(!Hc(h))return;let _=et(h,void 0,"key").length,A=_===y||_===S,O=_===b||!!x?.includes(_);if(A&&O)return;return A}function d(h,b,y=!0){if(u(h)===!0)throw Error("first arg must be private key");if(u(b)===!1)throw Error("second arg must be public key");let S=r.fromBytes(h);return e.fromBytes(b).multiply(S).toBytes(y)}let p={isValidSecretKey:i,isValidPublicKey:s,randomSecretKey:a},m=Qd(a,c);return Object.freeze(p),Object.freeze(n),Object.freeze({getPublicKey:c,getSharedSecret:d,keygen:m,Point:e,utils:p,lengths:n})}function g6(e,t,r={}){let o=t;wo(o),tn(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),r=Object.assign({},r);let n=r.randomBytes===void 0?Jc:r.randomBytes,i=r.hmac===void 0?(T,I)=>Mn(o,T,I):r.hmac,{Fp:s,Fn:a}=e,{ORDER:c,BITS:u}=a,{keygen:d,getPublicKey:p,getSharedSecret:m,utils:h,lengths:b}=qce(e,r),y={prehash:!0,lowS:typeof r.lowS==="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},S=c*p6+Bi<s.ORDER;function x(T){let I=c>>Bi;return T>I}function _(T,I){if(!a.isValidNot0(I))throw Error(`invalid signature ${T}: out of range 1..Point.Fn.ORDER`);return I}function A(){if(S)throw Error('"recovered" sig type is not supported for cofactor >2 curves')}function O(T,I){XA(I);let q=b.signature,N=I==="compact"?q:I==="recovered"?q+1:void 0;return et(T,N)}class L{r;s;recovery;constructor(T,I,q){if(this.r=_("r",T),this.s=_("s",I),q!=null){if(A(),![0,1,2,3].includes(q))throw Error("invalid recovery id");this.recovery=q}Object.freeze(this)}static fromBytes(T,I=y.format){O(T,I);let q;if(I==="der"){let{r:re,s:ae}=Sn.toSig(et(T));return new L(re,ae)}if(I==="recovered")q=T[0],I="compact",T=T.subarray(1);let N=b.signature/2,J=T.subarray(0,N),G=T.subarray(N,N*2);return new L(a.fromBytes(J),a.fromBytes(G),q)}static fromHex(T,I){return this.fromBytes(Kc(T),I)}assertRecovery(){let{recovery:T}=this;if(T==null)throw Error("invalid recovery id: must be present");return T}addRecoveryBit(T){return new L(this.r,this.s,T)}recoverPublicKey(T){let{r:I,s:q}=this,N=this.assertRecovery(),J=N===2||N===3?I+c:I;if(!s.isValid(J))throw Error("invalid recovery id: sig.r+curve.n != R.x");let G=s.toBytes(J),re=e.fromBytes(Vt(m6((N&1)===0),G)),ae=a.inv(J),me=H(et(T,void 0,"msgHash")),be=a.create(-me*ae),ve=a.create(q*ae),Ae=e.BASE.multiplyUnsafe(be).add(re.multiplyUnsafe(ve));if(Ae.is0())throw Error("invalid recovery: point at infinify");return Ae.assertValidity(),Ae}hasHighS(){return x(this.s)}toBytes(T=y.format){if(XA(T),T==="der")return Kc(Sn.hexFromSig(this));let{r:I,s:q}=this,N=a.toBytes(I),J=a.toBytes(q);if(T==="recovered")return A(),Vt(Uint8Array.of(this.assertRecovery()),N,J);return Vt(N,J)}toHex(T){return Fc(this.toBytes(T))}}Object.freeze(L.prototype),Object.freeze(L);let z=r.bits2int===void 0?function(I){if(I.length>8192)throw Error("input is too large");let q=Gs(I),N=I.length*8-u;return N>0?q>>BigInt(N):q}:r.bits2int,H=r.bits2int_modN===void 0?function(I){return a.create(z(I))}:r.bits2int_modN,P=Hd(u);function W(T){return Oo("num < 2^"+u,T,Wn,P),a.toBytes(T)}function ee(T,I){return et(T,void 0,"message"),I?et(o(T),void 0,"prehashed message"):T}function j(T,I,q){let{lowS:N,prehash:J,extraEntropy:G}=YA(q,y);T=ee(T,J);let re=H(T),ae=a.fromBytes(I);if(!a.isValidNot0(ae))throw Error("invalid private key");let me=[W(ae),W(re)];if(G!=null&&G!==!1){let Ie=G===!0?n(b.secretKey):G;me.push(et(Ie,void 0,"extraEntropy"))}let be=Vt(...me),ve=re;function Ae(Ie){let we=z(Ie);if(!a.isValidNot0(we))return;let Ue=a.inv(we),De=e.BASE.multiply(we).toAffine(),Qe=a.create(De.x);if(Qe===Wn)return;let St=a.create(Ue*a.create(ve+Qe*ae));if(St===Wn)return;let Tt=(De.x===Qe?0:2)|Number(De.y&Bi),Dt=St;if(N&&x(St))Dt=a.neg(St),Tt^=1;return new L(Qe,Dt,S?void 0:Tt)}return{seed:be,k2sig:Ae}}function R(T,I,q={}){let{seed:N,k2sig:J}=j(T,I,q);return qU(o.outputLen,a.BYTES,i)(N,J).toBytes(q.format)}function B(T,I,q,N={}){let{lowS:J,prehash:G,format:re}=YA(N,y);if(q=et(q,void 0,"publicKey"),I=ee(I,G),!Hc(T)){let ae=T instanceof L?", use sig.toBytes()":"";throw Error("verify expects Uint8Array signature"+ae)}O(T,re);try{let ae=L.fromBytes(T,re),me=e.fromBytes(q);if(J&&ae.hasHighS())return!1;let{r:be,s:ve}=ae,Ae=H(I),Ie=a.inv(ve),we=a.create(Ae*Ie),Ue=a.create(be*Ie),De=e.BASE.multiplyUnsafe(we).add(me.multiplyUnsafe(Ue));if(De.is0())return!1;return a.create(De.x)===be}catch(ae){return!1}}function k(T,I,q={}){let{prehash:N}=YA(q,y);return I=ee(I,N),L.fromBytes(T,"recovered").recoverPublicKey(I).toBytes()}return Object.freeze({keygen:d,getPublicKey:p,getSharedSecret:m,utils:h,lengths:b,Point:e,sign:R,verify:B,recoverPublicKey:k,Signature:L,hash:o})}var u6=(e,t)=>(e+(e>=0?t:-t)/p6)/t,d6,Sn,Wn,Bi,p6,ny,Mce;var y6=v(()=>{bd();Gr();Li();ry();Vd();/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */d6=class d6 extends Error{constructor(e=""){super(e)}};Sn={Err:d6,_tlv:{encode:(e,t)=>{let{Err:r}=Sn;if(Vn(e,"tag"),e<0||e>255)throw new r("tlv.encode: wrong tag");if(typeof t!=="string")throw TypeError('"data" expected string, got type='+typeof t);if(t.length&1)throw new r("tlv.encode: unpadded data");let o=t.length/2,n=Fd(o);if(n.length/2&128)throw new r("tlv.encode: long form length too big");let i=o>127?Fd(n.length/2|128):"";return Fd(e)+i+n+t},decode(e,t){let{Err:r}=Sn;t=et(t,void 0,"DER data");let o=0;if(e<0||e>255)throw new r("tlv.encode: wrong tag");if(t.length<2||t[o++]!==e)throw new r("tlv.decode: wrong tlv");let n=t[o++],i=!!(n&128),s=0;if(!i)s=n;else{let c=n&127;if(!c)throw new r("tlv.decode(long): indefinite length not supported");if(c>4)throw new r("tlv.decode(long): byte length is too big");let u=t.subarray(o,o+c);if(u.length!==c)throw new r("tlv.decode: length bytes not complete");if(u[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let d of u)s=s<<8|d;if(o+=c,s<128)throw new r("tlv.decode(long): not minimal encoding")}let a=t.subarray(o,o+s);if(a.length!==s)throw new r("tlv.decode: wrong value length");return{v:a,l:t.subarray(o+s)}}},_int:{encode(e){let{Err:t}=Sn;if(Qg(e),e<Wn)throw new t("integer: negative integers are not allowed");let r=Fd(e);if(Number.parseInt(r[0],16)&8)r="00"+r;if(r.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return r},decode(e){let{Err:t}=Sn;if(e.length<1)throw new t("invalid signature integer: empty");if(e[0]&128)throw new t("invalid signature integer: negative");if(e.length>1&&e[0]===0&&!(e[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return Gs(e)}},toSig(e){let{Err:t,_int:r,_tlv:o}=Sn,n=et(e,void 0,"signature"),{v:i,l:s}=o.decode(48,n);if(s.length)throw new t("invalid signature: left bytes after parsing");let{v:a,l:c}=o.decode(2,i),{v:u,l:d}=o.decode(2,c);if(d.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(u)}},hexFromSig(e){let{_tlv:t,_int:r}=Sn,o=t.encode(2,r.encode(e.r)),n=t.encode(2,r.encode(e.s)),i=o+n;return t.encode(48,i)}};Object.freeze(Sn._tlv);Object.freeze(Sn._int);Object.freeze(Sn);Wn=BigInt(0),Bi=BigInt(1),p6=BigInt(2),ny=BigInt(3),Mce=BigInt(4)});var Fce,Kce,Gc;var b6=v(()=>{Cc();y6();/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */Fce=(()=>({p:BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),h:BigInt(1),a:BigInt("0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc"),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")}))(),Kce=f6(Fce),Gc=g6(Kce,wt)});function Jce(e,t,r,o){let n=e.sqr(r),i=e.sqr(o),s=e.add(e.mul(t.a,n),i),a=e.add(e.ONE,e.mul(t.d,e.mul(n,i)));return e.eql(s,a)}function S6(e,t={}){let r=t,o=ty("edwards",e,r,r.FpFnLE),{Fp:n,Fn:i}=o,s=o.CURVE,{h:a}=s;tn(r,{},{uvRatio:"function"});let c=eT<<BigInt(i.BYTES*8)-Ir,u=(y)=>n.create(y),d=r.uvRatio===void 0?(y,S)=>{try{return{isValid:!0,value:n.sqrt(n.div(y,S))}}catch(x){return{isValid:!1,value:ji}}}:r.uvRatio;if(!Jce(n,s,s.Gx,s.Gy))throw Error("bad curve params: generator point");function p(y,S,x=!1){let _=x?Ir:ji;return Oo("coordinate "+y,S,_,c),S}function m(y){if(!(y instanceof h))throw Error("EdwardsPoint expected")}class h{static BASE=new h(s.Gx,s.Gy,Ir,u(s.Gx*s.Gy));static ZERO=new h(ji,Ir,Ir,ji);static Fp=n;static Fn=i;X;Y;Z;T;constructor(y,S,x,_){this.X=p("x",y),this.Y=p("y",S),this.Z=p("z",x,!0),this.T=p("t",_),Object.freeze(this)}static CURVE(){return s}static fromAffine(y){if(y instanceof h)throw Error("extended point not allowed");let{x:S,y:x}=y||{};return p("x",S),p("y",x),new h(S,x,Ir,u(S*x))}static fromBytes(y,S=!1){let x=n.BYTES,{a:_,d:A}=s;y=Di(et(y,x,"point")),$o(S,"zip215");let O=Di(y),L=y[x-1];O[x-1]=L&-129;let z=bn(O),H=S?c:n.ORDER;Oo("point.y",z,ji,H);let P=u(z*z),W=u(P-Ir),ee=u(A*P-_),{isValid:j,value:R}=d(W,ee);if(!j)throw Error("bad point: invalid y coordinate");let B=(R&Ir)===Ir,k=(L&128)!==0;if(!S&&R===ji&&k)throw Error("bad point: x=0 and x_0=1");if(k!==B)R=u(-R);return h.fromAffine({x:R,y:z})}static fromHex(y,S=!1){return h.fromBytes(Kc(y),S)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(y=8,S=!0){if(b.createCache(this,y),!S)this.multiply(eT);return this}assertValidity(){let y=this,{a:S,d:x}=s;if(y.is0())throw Error("bad point: ZERO");let{X:_,Y:A,Z:O,T:L}=y,z=u(_*_),H=u(A*A),P=u(O*O),W=u(P*P),ee=u(z*S),j=u(P*u(ee+H)),R=u(W+u(x*u(z*H)));if(j!==R)throw Error("bad point: equation left != right (1)");let B=u(_*A),k=u(O*L);if(B!==k)throw Error("bad point: equation left != right (2)")}equals(y){m(y);let{X:S,Y:x,Z:_}=this,{X:A,Y:O,Z:L}=y,z=u(S*L),H=u(A*_),P=u(x*L),W=u(O*_);return z===H&&P===W}is0(){return this.equals(h.ZERO)}negate(){return new h(u(-this.X),this.Y,this.Z,u(-this.T))}double(){let{a:y}=s,{X:S,Y:x,Z:_}=this,A=u(S*S),O=u(x*x),L=u(eT*u(_*_)),z=u(y*A),H=S+x,P=u(u(H*H)-A-O),W=z+O,ee=W-L,j=z-O,R=u(P*ee),B=u(W*j),k=u(P*j),T=u(ee*W);return new h(R,B,T,k)}add(y){m(y);let{a:S,d:x}=s,{X:_,Y:A,Z:O,T:L}=this,{X:z,Y:H,Z:P,T:W}=y,ee=u(_*z),j=u(A*H),R=u(L*x*W),B=u(O*P),k=u((_+A)*(z+H)-ee-j),T=B-R,I=B+R,q=u(j-S*ee),N=u(k*T),J=u(I*q),G=u(k*q),re=u(T*I);return new h(N,J,re,G)}subtract(y){return m(y),this.add(y.negate())}multiply(y){if(!i.isValidNot0(y))throw RangeError("invalid scalar: expected 1 <= sc < curve.n");let{p:S,f:x}=b.cached(this,y,(_)=>Xs(h,_));return Xs(h,[S,x])[0]}multiplyUnsafe(y){if(!i.isValid(y))throw RangeError("invalid scalar: expected 0 <= sc < curve.n");if(y===ji)return h.ZERO;if(this.is0()||y===Ir)return this;return b.unsafe(this,y,(S)=>Xs(h,S))}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){return b.unsafe(this,s.n).is0()}toAffine(y){let S=this,x=y,{X:_,Y:A,Z:O}=S,L=S.is0();if(x==null)x=L?Hce:n.inv(O);let z=u(_*x),H=u(A*x),P=n.mul(O,x);if(L)return{x:ji,y:Ir};if(P!==Ir)throw Error("invZ was invalid");return{x:z,y:H}}clearCofactor(){if(a===Ir)return this;return this.multiplyUnsafe(a)}toBytes(){let{x:y,y:S}=this.toAffine(),x=n.toBytes(S);return x[x.length-1]|=y&Ir?128:0,x}toHex(){return Fc(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let b=new Gd(h,i.BITS);if(i.BITS>=8)h.BASE.precompute(8);return Object.freeze(h.prototype),Object.freeze(h),h}class tT{static BASE;static ZERO;static Fp;static Fn;ep;constructor(e){this.ep=e}static fromBytes(e){qA()}static fromHex(e){qA()}get x(){return this.toAffine().x}get y(){return this.toAffine().y}clearCofactor(){return this}assertValidity(){this.ep.assertValidity()}toAffine(e){return this.ep.toAffine(e)}toHex(){return Fc(this.toBytes())}toString(){return this.toHex()}isTorsionFree(){return!0}isSmallOrder(){return!1}add(e){return this.assertSame(e),this.init(this.ep.add(e.ep))}subtract(e){return this.assertSame(e),this.init(this.ep.subtract(e.ep))}multiply(e){return this.init(this.ep.multiply(e))}multiplyUnsafe(e){return this.init(this.ep.multiplyUnsafe(e))}double(){return this.init(this.ep.double())}negate(){return this.init(this.ep.negate())}precompute(e,t){return this.ep.precompute(e,t),this}}var ji,Ir,eT,Hce;var v6=v(()=>{Li();ry();/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ji=BigInt(0),Ir=BigInt(1),eT=BigInt(2),Hce=BigInt(8)});function Vce(e){return tn(e,{P:"bigint",type:"string",adjustScalarBytes:"function",powPminus2:"function"},{randomBytes:"function"}),Object.freeze({...e})}function w6(e){let t=Vce(e),{P:r,type:o,adjustScalarBytes:n,powPminus2:i,randomBytes:s}=t,a=o==="x25519";if(!a&&o!=="x448")throw Error("invalid type");let c=s===void 0?Jc:s,u=a?255:448,d=a?32:56,p=a?BigInt(9):BigInt(5),m=a?BigInt(121665):BigInt(39081),h=a?oy**BigInt(254):oy**BigInt(447),b=a?BigInt(8)*oy**BigInt(251)-Qc:BigInt(4)*oy**BigInt(445)-Qc,y=h+b+Qc,S=(k)=>it(k,r),x=_(p);function _(k){return Kd(S(k),d)}function A(k){let T=Di(et(k,d,"uCoordinate"));if(a)T[31]&=127;return S(bn(T))}function O(k){return bn(n(Di(et(k,d,"scalar"))))}function L(k,T){let I=ee(A(T),O(k));if(I===Xd)throw Error("invalid private or public key received");return _(I)}function z(k){return L(k,x)}let H=z,P=L;function W(k,T,I){let q=S(k*(T-I));return T=S(T-q),I=S(I+q),{x_2:T,x_3:I}}function ee(k,T){Oo("u",k,Xd,r),Oo("scalar",T,h,y);let I=T,q=k,N=Qc,J=Xd,G=k,re=Qc,ae=Xd;for(let be=BigInt(u-1);be>=Xd;be--){let ve=I>>be&Qc;ae^=ve,{x_2:N,x_3:G}=W(ae,N,G),{x_2:J,x_3:re}=W(ae,J,re),ae=ve;let Ae=N+J,Ie=S(Ae*Ae),we=N-J,Ue=S(we*we),De=Ie-Ue,Qe=G+re,St=G-re,Tt=S(St*Ae),Dt=S(Qe*we),lt=Tt+Dt,$r=Tt-Dt;G=S(lt*lt),re=S(q*S($r*$r)),N=S(Ie*Ue),J=S(De*(Ie+S(m*De)))}({x_2:N,x_3:G}=W(ae,N,G)),{x_2:J,x_3:re}=W(ae,J,re);let me=i(J);return S(N*me)}let j={secretKey:d,publicKey:d,seed:d},R=(k)=>(k=k===void 0?c(d):k,et(k,j.seed,"seed"),k),B={randomSecretKey:R};return Object.freeze(j),Object.freeze(B),Object.freeze({keygen:Qd(R,H),getSharedSecret:P,getPublicKey:H,scalarMult:L,scalarMultBase:z,utils:B,GuBytes:x.slice(),lengths:j})}var Xd,Qc,oy;var x6=v(()=>{Li();ry();Vd();/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */Xd=BigInt(0),Qc=BigInt(1),oy=BigInt(2)});function I6(e){let t=BigInt(10),r=BigInt(20),o=BigInt(40),n=BigInt(80),i=ta,a=e*e%i*e%i,c=rn(a,_6,i)*a%i,u=rn(c,Po,i)*e%i,d=rn(u,Qce,i)*u%i,p=rn(d,t,i)*d%i,m=rn(p,r,i)*p%i,h=rn(m,o,i)*m%i,b=rn(h,n,i)*h%i,y=rn(b,n,i)*h%i,S=rn(y,t,i)*d%i;return{pow_p_5_8:rn(S,_6,i)*e%i,b2:a}}function Xce(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}function sT(e,t){let r=ta,o=it(t*t*t,r),n=it(o*o*t,r),i=I6(e*n).pow_p_5_8,s=it(e*o*i,r),a=it(t*s*s,r),c=s,u=it(s*rT,r),d=a===e,p=a===it(-e,r),m=a===it(-e*rT,r);if(d)s=c;if(p||m)s=u;if(Co(s,r))s=it(-s,r);return{isValid:d||p,value:s}}function k6(e){let{d:t}=iT,r=ta,o=(x)=>Zi.create(x),n=o(nT*e*e),i=o((n+Po)*rle),s=BigInt(-1),a=o((s-t*n)*o(n+t)),{isValid:c,value:u}=sT(i,a),d=o(u*e);if(!Co(d,r))d=o(-d);if(!c)u=d;if(!c)s=n;let p=o(s*(n-Po)*nle-a),m=u*u,h=o((u+u)*a),b=o(p*ele),y=o(Po-m),S=o(Po+m);return new ea(o(h*S),o(y*b),o(b*S),o(h*y))}var Wce,Po,_6,Gce,Qce,Yce,ta,iT,rT,ea,Zi,A6,iy,nT,ele,tle,rle,nle,E6=(e)=>sT(Po,e),ole,oT=(e)=>Zi.create(bn(e)&ole),br,ile;var T6=v(()=>{Cc();Gr();v6();l6();Vd();x6();Li();/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */Wce=BigInt(0),Po=BigInt(1),_6=BigInt(2),Gce=BigInt(3),Qce=BigInt(5),Yce=BigInt(8),ta=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),iT=(()=>({p:ta,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:Yce,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")}))();rT=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");ea=S6(iT,{uvRatio:sT}),Zi=(()=>ea.Fp)(),A6=(()=>ea.Fn)(),iy=(()=>{let e=ta;return w6({P:e,type:"x25519",powPminus2:(t)=>{let{pow_p_5_8:r,b2:o}=I6(t);return it(rn(r,Gce,e)*o,e)},adjustScalarBytes:Xce})})(),nT=rT,ele=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),tle=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),rle=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),nle=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),ole=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");br=class br extends tT{static BASE=(()=>new br(ea.BASE))();static ZERO=(()=>new br(ea.ZERO))();static Fp=(()=>Zi)();static Fn=(()=>A6)();constructor(e){super(e)}static fromAffine(e){return new br(ea.fromAffine(e))}assertSame(e){if(!(e instanceof br))throw Error("RistrettoPoint expected")}init(e){return new br(e)}static fromBytes(e){Ft(e,32);let{a:t,d:r}=iT,o=ta,n=(A)=>Zi.create(A),i=oT(e);if(!MU(Zi.toBytes(i),e)||Co(i,o))throw Error("invalid ristretto255 encoding 1");let s=n(i*i),a=n(Po+t*s),c=n(Po-t*s),u=n(a*a),d=n(c*c),p=n(t*r*u-d),{isValid:m,value:h}=E6(n(p*d)),b=n(h*c),y=n(h*b*p),S=n((i+i)*b);if(Co(S,o))S=n(-S);let x=n(a*y),_=n(S*x);if(!m||Co(_,o)||x===Wce)throw Error("invalid ristretto255 encoding 2");return new br(new ea(S,x,Po,_))}static fromHex(e){return br.fromBytes(yd(e))}toBytes(){let{X:e,Y:t,Z:r,T:o}=this.ep,n=ta,i=(y)=>Zi.create(y),s=i(i(r+t)*i(r-t)),a=i(e*t),c=i(a*a),{value:u}=E6(i(s*c)),d=i(u*s),p=i(u*a),m=i(d*p*o),h;if(Co(o*m,n)){let y=i(t*nT),S=i(e*nT);e=y,t=S,h=i(d*tle)}else h=p;if(Co(e*m,n))t=i(-t);let b=i((r-t)*h);if(Co(b,n))b=i(-b);return Zi.toBytes(b)}equals(e){this.assertSame(e);let{X:t,Y:r}=this.ep,{X:o,Y:n}=e.ep,i=(c)=>Zi.create(c),s=i(t*n)===i(r*o),a=i(r*n)===i(t*o);return s||a}is0(){return this.equals(br.ZERO)}};Object.freeze(br.BASE);Object.freeze(br.ZERO);Object.freeze(br.prototype);Object.freeze(br);ile=Object.freeze({Point:br,hashToCurve(e,t){let r=t?.DST===void 0?"ristretto255_XMD:SHA-512_R255MAP_RO_":t.DST,o=QA(e,r,64,Sg);return ile.deriveToCurve(o)},hashToScalar(e,t={DST:c6}){let r=QA(e,t.DST,64,Sg);return A6.create(bn(r))},deriveToCurve(e){Ft(e,64);let t=oT(e.subarray(0,32)),r=k6(t),o=oT(e.subarray(32,64)),n=k6(o);return new br(r.add(n))}})});async function $6(e,t){if(sle)return await t();try{return await e()}catch(r){if(r instanceof ReferenceError||r instanceof DOMException&&r.name==="NotSupportedError")return await t();else throw r}}async function sy(e,t){return await $6(async()=>{let r=aT(e)?e:await cle(e),o=await crypto.subtle.importKey("raw",lle(t),{name:"X25519"},R6,[]);return new Uint8Array(await crypto.subtle.deriveBits({name:"X25519",public:o},r,256))},()=>{if(aT(e))throw Error("CryptoKey provided but X25519 WebCrypto is not supported");return iy.scalarMult(e,t)})}async function ep(e){return await $6(async()=>sy(e,iy.GuBytes),()=>{if(aT(e))throw Error("CryptoKey provided but X25519 WebCrypto is not supported");return iy.scalarMultBase(e)})}async function cle(e){if(e.length!==32)throw Error("X25519 private key must be 32 bytes");let t=new Uint8Array([...ale,...e]);return crypto.subtle.importKey("pkcs8",t,{name:"X25519"},R6,["deriveBits"])}function aT(e){return typeof CryptoKey<"u"&&e instanceof CryptoKey}function lle(e){return e}var R6=!1,sle=!1,ale;var O6=v(()=>{T6();ale=new Uint8Array([48,46,2,1,0,48,5,6,3,43,101,110,4,34,4,32])});class cT{s;transcript=[];buf=new Uint8Array(0);constructor(e){this.s=e.getReader()}async readLine(){let e=[];while(!0){let t=this.buf.indexOf(10);if(t>=0)return e.push(this.buf.subarray(0,t)),this.transcript.push(this.buf.subarray(0,t+1)),this.buf=this.buf.subarray(t+1),dle(ra(e));if(this.buf.length>0)e.push(this.buf),this.transcript.push(this.buf);let r=await this.s.read();if(r.done)return this.buf=ra(e),null;this.buf=r.value}}close(){return this.s.releaseLock(),{rest:this.buf,transcript:ra(this.transcript)}}}function dle(e){return e.forEach((t)=>{if(t<32||t>126)throw Error("invalid non-ASCII byte in header")}),new TextDecoder().decode(e)}function ra(e){let t=e.reduce((n,i)=>n+i.length,0),r=new Uint8Array(t),o=0;for(let n of e)r.set(n,o),o+=n.length;return r}function Yc(e,...t){return e.pipeThrough(new TransformStream({start(r){for(let o of t)r.enqueue(o)}}))}function ay(e){return new ReadableStream({start(t){t.enqueue(e),t.close()}})}async function lT(e){if(!(e instanceof ReadableStream))throw Error("readAll expects a ReadableStream<Uint8Array>");return new Uint8Array(await new Response(e).arrayBuffer())}async function C6(e){if(!(e instanceof ReadableStream))throw Error("readAllString expects a ReadableStream<Uint8Array>");return await new Response(e).text()}async function P6(e,t){let r=e.getReader(),o=[],n=0;while(n<t){let{done:c,value:u}=await r.read();if(c)throw Error("stream ended before reading "+t.toString()+" bytes");o.push(u),n+=u.length}r.releaseLock();let i=ra(o),s=i.subarray(0,t),a=Yc(e,i.subarray(t));return{data:s,rest:a}}var uT=()=>{};class Gn{args;body;constructor(e,t){this.args=e,this.body=t}}async function ple(e){let t=await e.readLine();if(t===null)throw Error("invalid stanza");let r=t.split(" ");if(r.length<2||r.shift()!=="->")return{next:t};for(let i of r)if(i.length===0)throw Error("invalid stanza");let o=[];for(;;){let i=await e.readLine();if(i===null)throw Error("invalid stanza");let s=tr.decode(i);if(s.length>48)throw Error("invalid stanza");if(o.push(s),s.length<48)break}let n=ra(o);return{s:new Gn(r,n)}}async function z6(e){let t=new cT(e),r=await t.readLine();if(r!=="age-encryption.org/v1")throw Error("invalid version "+(r??"line"));let o=[];for(;;){let{s:n,next:i}=await ple(t);if(n!==void 0){o.push(n);continue}if(!i.startsWith("--- "))throw Error("invalid header");let s=tr.decode(i.slice(4)),{rest:a,transcript:c}=t.close(),u=c.slice(0,c.length-1-i.length+3);return{stanzas:o,headerNoMAC:u,MAC:s,headerSize:c.length,rest:Yc(e,a)}}}function dT(e){let t=[];t.push(`age-encryption.org/v1
|
|
405
405
|
`);for(let r of e){t.push("-> "+r.args.join(" ")+`
|
|
406
406
|
`);for(let o=0;o<r.body.length;o+=48){let n=o+48;if(n>r.body.length)n=r.body.length;t.push(tr.encode(r.body.subarray(o,n))+`
|
|
407
407
|
`)}if(r.body.length%48===0)t.push(`
|
|
408
408
|
`)}return t.push("---"),new TextEncoder().encode(t.join(""))}function N6(e,t){return ra([dT(e),new TextEncoder().encode(" "+tr.encode(t)+`
|
|
409
|
-
`)])}var cy=v(()=>{Ed();uT()});function mT(){return D6()}function D6(){let e=xo(32),t=Br.encodeFromBytes("AGE-SECRET-KEY-",e).toUpperCase();return Promise.resolve(t)}async function uy(e){let t;if(B6(e))t=e;else if(e.startsWith("AGE-SECRET-KEY-PQ-1")){let o=Br.decodeToBytes(e);if(o.prefix.toUpperCase()!=="AGE-SECRET-KEY-PQ-"||o.bytes.length!==32)throw Error("invalid identity");let n=Vg.getPublicKey(o.bytes);return Br.encode("age1pq",Br.toWords(n),!1)}else{let o=Br.decodeToBytes(e);if(!e.startsWith("AGE-SECRET-KEY-1")||o.prefix.toUpperCase()!=="AGE-SECRET-KEY-"||o.bytes.length!==32)throw Error("invalid identity");t=o.bytes}let r=await ep(t);return Br.encodeFromBytes("age",r)}class hT{recipient;constructor(e){let t=Br.decodeToBytes(e);if(!e.startsWith("age1pq1")||t.prefix.toLowerCase()!=="age1pq"||t.bytes.length!==1216)throw Error("invalid recipient");this.recipient=t.bytes}wrapFileKey(e){let{cipherText:t,sharedSecret:r}=Vg.encapsulate(this.recipient),o=new TextEncoder().encode("age-encryption.org/mlkem768x25519"),{key:n,nonce:i}=dy(L6,r,o),s=Yr(n,i).encrypt(e);return[new Gn(["mlkem768x25519",tr.encode(t)],s)]}}class gT{identity;constructor(e){let t=Br.decodeToBytes(e);if(!e.startsWith("AGE-SECRET-KEY-PQ-1")||t.prefix.toUpperCase()!=="AGE-SECRET-KEY-PQ-"||t.bytes.length!==32)throw Error("invalid identity");this.identity=t.bytes}unwrapFileKey(e){for(let t of e){if(t.args.length<1||t.args[0]!=="mlkem768x25519")continue;if(t.args.length!==2)throw Error("invalid mlkem768x25519 stanza");let r=tr.decode(t.args[1]);if(r.length!==1120)throw Error("invalid mlkem768x25519 stanza");if(t.body.length!==32)throw Error("invalid mlkem768x25519 stanza");let o=Vg.decapsulate(r,this.identity),n=new TextEncoder().encode("age-encryption.org/mlkem768x25519"),{key:i,nonce:s}=dy(L6,o,n);try{return Yr(i,s).decrypt(t.body)}catch{continue}}return null}}function dy(e,t,r){let o=
|
|
409
|
+
`)])}var cy=v(()=>{Ed();uT()});function mT(){return D6()}function D6(){let e=xo(32),t=Br.encodeFromBytes("AGE-SECRET-KEY-",e).toUpperCase();return Promise.resolve(t)}async function uy(e){let t;if(B6(e))t=e;else if(e.startsWith("AGE-SECRET-KEY-PQ-1")){let o=Br.decodeToBytes(e);if(o.prefix.toUpperCase()!=="AGE-SECRET-KEY-PQ-"||o.bytes.length!==32)throw Error("invalid identity");let n=Vg.getPublicKey(o.bytes);return Br.encode("age1pq",Br.toWords(n),!1)}else{let o=Br.decodeToBytes(e);if(!e.startsWith("AGE-SECRET-KEY-1")||o.prefix.toUpperCase()!=="AGE-SECRET-KEY-"||o.bytes.length!==32)throw Error("invalid identity");t=o.bytes}let r=await ep(t);return Br.encodeFromBytes("age",r)}class hT{recipient;constructor(e){let t=Br.decodeToBytes(e);if(!e.startsWith("age1pq1")||t.prefix.toLowerCase()!=="age1pq"||t.bytes.length!==1216)throw Error("invalid recipient");this.recipient=t.bytes}wrapFileKey(e){let{cipherText:t,sharedSecret:r}=Vg.encapsulate(this.recipient),o=new TextEncoder().encode("age-encryption.org/mlkem768x25519"),{key:n,nonce:i}=dy(L6,r,o),s=Yr(n,i).encrypt(e);return[new Gn(["mlkem768x25519",tr.encode(t)],s)]}}class gT{identity;constructor(e){let t=Br.decodeToBytes(e);if(!e.startsWith("AGE-SECRET-KEY-PQ-1")||t.prefix.toUpperCase()!=="AGE-SECRET-KEY-PQ-"||t.bytes.length!==32)throw Error("invalid identity");this.identity=t.bytes}unwrapFileKey(e){for(let t of e){if(t.args.length<1||t.args[0]!=="mlkem768x25519")continue;if(t.args.length!==2)throw Error("invalid mlkem768x25519 stanza");let r=tr.decode(t.args[1]);if(r.length!==1120)throw Error("invalid mlkem768x25519 stanza");if(t.body.length!==32)throw Error("invalid mlkem768x25519 stanza");let o=Vg.decapsulate(r,this.identity),n=new TextEncoder().encode("age-encryption.org/mlkem768x25519"),{key:i,nonce:s}=dy(L6,o,n);try{return Yr(i,s).decrypt(t.body)}catch{continue}}return null}}function dy(e,t,r){let o=mle(e),n=ly(o,void 0,"psk_id_hash",new Uint8Array(0)),i=ly(o,void 0,"info_hash",r),s=new Uint8Array(1+n.length+i.length);s[0]=0,s.set(n,1),s.set(i,1+n.length);let a=ly(o,t,"secret",new Uint8Array(0)),c=fT(o,a,"key",s,32),u=fT(o,a,"base_nonce",s,12);return{key:c,nonce:u}}function mle(e){let t=new Uint8Array(10);return t.set(new TextEncoder().encode("HPKE"),0),t[4]=e>>8&255,t[5]=e&255,t[6]=0,t[7]=1,t[8]=0,t[9]=3,t}function ly(e,t,r,o){let n=new Uint8Array(7+e.length+r.length+o.length),i=0;return n.set(new TextEncoder().encode("HPKE-v1"),i),i+=7,n.set(e,i),i+=e.length,n.set(new TextEncoder().encode(r),i),i+=r.length,n.set(o,i),Sd(wt,n,t)}function fT(e,t,r,o,n){let i=new Uint8Array(9+e.length+r.length+o.length),s=0;return i[s]=n>>8&255,i[s+1]=n&255,s+=2,i.set(new TextEncoder().encode("HPKE-v1"),s),s+=7,i.set(e,s),s+=e.length,i.set(new TextEncoder().encode(r),s),s+=r.length,i.set(o,s),FI(wt,t,i,n)}function hle(e){if(e.length!==Gc.lengths.publicKeyUncompressed)e=Gc.Point.fromBytes(e).toBytes(!1);let t=Gc.utils.randomSecretKey(),r=Gc.getPublicKey(t,!1),o=Gc.getSharedSecret(t,e,!0).subarray(1),n=new Uint8Array(r.length+e.length);n.set(r,0),n.set(e,r.length);let i=new Uint8Array(5);i.set(new TextEncoder().encode("KEM"),0),i[3]=pT>>8,i[4]=pT&255;let s=ly(i,void 0,"eae_prk",o),a=fT(i,s,"shared_secret",n,32);return{encapsulatedKey:r,sharedSecret:a}}class yT{recipient;constructor(e){let t=Br.decodeToBytes(e);if(!e.startsWith("age1tag1")||t.prefix.toLowerCase()!=="age1tag"||t.bytes.length!==33)throw Error("invalid recipient");this.recipient=t.bytes}wrapFileKey(e){let{encapsulatedKey:t,sharedSecret:r}=hle(this.recipient),o=new TextEncoder().encode("age-encryption.org/p256tag"),n=(()=>{let c=wt(this.recipient).subarray(0,4),u=new Uint8Array(t.length+c.length);return u.set(t,0),u.set(c,t.length),Sd(wt,u,o).subarray(0,4)})(),{key:i,nonce:s}=dy(pT,r,o),a=Yr(i,s).encrypt(e);return[new Gn(["p256tag",tr.encode(n),tr.encode(t)],a)]}}class bT{recipient;constructor(e){let t=Br.decodeToBytes(e);if(!e.startsWith("age1tagpq1")||t.prefix.toLowerCase()!=="age1tagpq"||t.bytes.length!==1249)throw Error("invalid recipient");this.recipient=t.bytes}wrapFileKey(e){let{cipherText:t,sharedSecret:r}=jU.encapsulate(this.recipient),o=new TextEncoder().encode("age-encryption.org/mlkem768p256tag"),n=(()=>{let c=wt(this.recipient.subarray(1184)).subarray(0,4),u=new Uint8Array(t.length+c.length);return u.set(t,0),u.set(c,t.length),Sd(wt,u,o).subarray(0,4)})(),{key:i,nonce:s}=dy(fle,r,o),a=Yr(i,s).encrypt(e);return[new Gn(["mlkem768p256tag",tr.encode(n),tr.encode(t)],a)]}}class ST{recipient;constructor(e){let t=Br.decodeToBytes(e);if(!e.startsWith("age1")||t.prefix.toLowerCase()!=="age"||t.bytes.length!==32)throw Error("invalid recipient");this.recipient=t.bytes}async wrapFileKey(e){let t=xo(32),r=await ep(t),o=await sy(t,this.recipient),n=new Uint8Array(r.length+this.recipient.length);n.set(r),n.set(this.recipient,r.length);let i=new TextEncoder().encode("age-encryption.org/v1/X25519"),s=xi(wt,o,n,i,32);return[new Gn(["X25519",tr.encode(r)],xT(e,s))]}}class py{identity;recipient;constructor(e){if(B6(e)){this.identity=e,this.recipient=ep(e);return}let t=Br.decodeToBytes(e);if(!e.startsWith("AGE-SECRET-KEY-1")||t.prefix.toUpperCase()!=="AGE-SECRET-KEY-"||t.bytes.length!==32)throw Error("invalid identity");this.identity=t.bytes,this.recipient=ep(t.bytes)}async unwrapFileKey(e){for(let t of e){if(t.args.length<1||t.args[0]!=="X25519")continue;if(t.args.length!==2)throw Error("invalid X25519 stanza");let r=tr.decode(t.args[1]);if(r.length!==32)throw Error("invalid X25519 stanza");let o=await sy(this.identity,r),n=await this.recipient,i=new Uint8Array(r.length+n.length);i.set(r),i.set(n,r.length);let s=new TextEncoder().encode("age-encryption.org/v1/X25519"),a=xi(wt,o,i,s,32),c=_T(t.body,a);if(c!==null)return c}return null}}class vT{passphrase;logN;constructor(e,t){this.passphrase=e,this.logN=t}wrapFileKey(e){let t=xo(16),r="age-encryption.org/v1/scrypt",o=new Uint8Array(44);o.set(new TextEncoder().encode("age-encryption.org/v1/scrypt")),o.set(t,28);let n=rA(this.passphrase,o,{N:2**this.logN,r:8,p:1,dkLen:32});return[new Gn(["scrypt",tr.encode(t),this.logN.toString()],xT(e,n))]}}class wT{passphrase;constructor(e){this.passphrase=e}unwrapFileKey(e){for(let t of e){if(t.args.length<1||t.args[0]!=="scrypt")continue;if(e.length!==1)throw Error("scrypt recipient is not the only one in the header");if(t.args.length!==3)throw Error("invalid scrypt stanza");if(!/^[1-9][0-9]*$/.test(t.args[2]))throw Error("invalid scrypt stanza");let r=tr.decode(t.args[1]);if(r.length!==16)throw Error("invalid scrypt stanza");let o=Number(t.args[2]);if(o>20)throw Error("scrypt work factor is too high");let n="age-encryption.org/v1/scrypt",i=new Uint8Array(n.length+16);i.set(new TextEncoder().encode(n)),i.set(r,n.length);let s=rA(this.passphrase,i,{N:2**o,r:8,p:1,dkLen:32}),a=_T(t.body,s);if(a!==null)return a}return null}}function xT(e,t){let r=new Uint8Array(12);return Yr(t,r).encrypt(e)}function _T(e,t){if(e.length!==32)throw Error("invalid stanza");let r=new Uint8Array(12);try{return Yr(t,r).decrypt(e)}catch{return null}}function B6(e){return typeof CryptoKey<"u"&&e instanceof CryptoKey}var L6=25722,fle=80,pT=16;var na=v(()=>{Ed();KI();Cc();Hj();iA();ZU();b6();Gr();Ed();O6();cy();Ui()});function j6(e){let t=new Uint8Array(12),r=()=>{for(let s=t.length-2;s>=0;s--)if(t[s]++,t[s]!==0)break},o=!0,n=new Uint8Array(ET),i=0;return new TransformStream({transform(s,a){while(s.length>0){if(i===n.length){let u=Yr(e,t).decrypt(n);a.enqueue(u),r(),i=0,o=!1}let c=Math.min(n.length-i,s.length);n.set(s.subarray(0,c),i),i+=c,s=s.subarray(c)}},flush(s){t[11]=1;let a=Yr(e,t).decrypt(n.subarray(0,i));if(!o&&a.length===0)throw Error("final chunk is empty");s.enqueue(a)}})}function Z6(e){if(e<oa)throw Error("ciphertext is too small");if(e===oa)return 0;let t=Math.floor(e/ET),r=e%ET;if(0<r&&r<=oa)throw Error("ciphertext size is invalid");let o=e;return o-=t*oa,o-=r>0?oa:0,o}function U6(e){let t=new Uint8Array(12),r=()=>{for(let i=t.length-2;i>=0;i--)if(t[i]++,t[i]!==0)break},o=new Uint8Array(kT),n=0;return new TransformStream({transform(i,s){while(i.length>0){if(n===o.length){let c=Yr(e,t).encrypt(o);s.enqueue(c),r(),n=0}let a=Math.min(o.length-n,i.length);o.set(i.subarray(0,a),n),n+=a,i=i.subarray(a)}},flush(i){t[11]=1;let s=Yr(e,t).encrypt(o.subarray(0,n));i.enqueue(s)}})}function M6(e){let t=Math.max(1,Math.ceil(e/kT));return e+oa*t}var oa=16,kT,ET;var q6=v(()=>{iA();kT=(()=>65536)(),ET=(()=>kT+oa)()});var Mi={};Lt(Mi,{decode:()=>yle,encode:()=>gle});function gle(e){let t=[];t.push(`-----BEGIN AGE ENCRYPTED FILE-----
|
|
410
410
|
`);for(let r=0;r<e.length;r+=48){let o=r+48;if(o>e.length)o=e.length;t.push(YI.encode(e.subarray(r,o))+`
|
|
411
411
|
`)}return t.push(`-----END AGE ENCRYPTED FILE-----
|
|
412
|
-
`),t.join("")}function
|
|
412
|
+
`),t.join("")}function yle(e){let t=e.trim().replaceAll(`\r
|
|
413
413
|
`,`
|
|
414
414
|
`).split(`
|
|
415
|
-
`);if(t.shift()!=="-----BEGIN AGE ENCRYPTED FILE-----")throw Error("invalid header");if(t.pop()!=="-----END AGE ENCRYPTED FILE-----")throw Error("invalid footer");function r(o,n){if(o===t.length-1)return n.length>0&&n.length<=64&&n.length%4===0;return n.length===64}if(!t.every((o,n)=>r(n,o)))throw Error("invalid line length");if(!t.every((o)=>/^[A-Za-z0-9+/=]+$/.test(o)))throw Error("invalid base64");return YI.decode(t.join(""))}var F6=v(()=>{Ed();Ui()});var K6=v(()=>{Ui();cy();na();Ui()});class tp{passphrase=null;scryptWorkFactor=18;recipients=[];setPassphrase(e){if(this.passphrase!==null)throw Error("can encrypt to at most one passphrase");if(this.recipients.length!==0)throw Error("can't encrypt to both recipients and passphrases");this.passphrase=e}setScryptWorkFactor(e){this.scryptWorkFactor=e}addRecipient(e){if(this.passphrase!==null)throw Error("can't encrypt to both recipients and passphrases");if(typeof e==="string")if(e.startsWith("age1pq1"))this.recipients.push(new hT(e));else if(e.startsWith("age1tag1"))this.recipients.push(new yT(e));else if(e.startsWith("age1tagpq1"))this.recipients.push(new bT(e));else if(e.startsWith("age1"))this.recipients.push(new ST(e));else throw Error("unrecognized recipient type");else this.recipients.push(e)}async encrypt(e){let t=xo(16),r=[],o=this.recipients;if(this.passphrase!==null)o=[new vT(this.passphrase,this.scryptWorkFactor)];for(let m of o)r.push(...await m.wrapFileKey(t));let n=new TextEncoder().encode("header"),i=xi(wt,t,void 0,n,32),s=Mn(wt,i,dT(r)),a=N6(r,s),c=xo(16),u=new TextEncoder().encode("payload"),d=xi(wt,t,c,u,32),p=U6(d);if(!(e instanceof ReadableStream)){if(typeof e==="string")e=new TextEncoder().encode(e);return await lT(Yc(ay(e).pipeThrough(p),a,c))}return Object.assign(Yc(e.pipeThrough(p),a,c),{size:(m)=>M6(m)+a.length+c.length})}}class rp{identities=[];addPassphrase(e){this.identities.push(new wT(e))}addIdentity(e){if(
|
|
415
|
+
`);if(t.shift()!=="-----BEGIN AGE ENCRYPTED FILE-----")throw Error("invalid header");if(t.pop()!=="-----END AGE ENCRYPTED FILE-----")throw Error("invalid footer");function r(o,n){if(o===t.length-1)return n.length>0&&n.length<=64&&n.length%4===0;return n.length===64}if(!t.every((o,n)=>r(n,o)))throw Error("invalid line length");if(!t.every((o)=>/^[A-Za-z0-9+/=]+$/.test(o)))throw Error("invalid base64");return YI.decode(t.join(""))}var F6=v(()=>{Ed();Ui()});var K6=v(()=>{Ui();cy();na();Ui()});class tp{passphrase=null;scryptWorkFactor=18;recipients=[];setPassphrase(e){if(this.passphrase!==null)throw Error("can encrypt to at most one passphrase");if(this.recipients.length!==0)throw Error("can't encrypt to both recipients and passphrases");this.passphrase=e}setScryptWorkFactor(e){this.scryptWorkFactor=e}addRecipient(e){if(this.passphrase!==null)throw Error("can't encrypt to both recipients and passphrases");if(typeof e==="string")if(e.startsWith("age1pq1"))this.recipients.push(new hT(e));else if(e.startsWith("age1tag1"))this.recipients.push(new yT(e));else if(e.startsWith("age1tagpq1"))this.recipients.push(new bT(e));else if(e.startsWith("age1"))this.recipients.push(new ST(e));else throw Error("unrecognized recipient type");else this.recipients.push(e)}async encrypt(e){let t=xo(16),r=[],o=this.recipients;if(this.passphrase!==null)o=[new vT(this.passphrase,this.scryptWorkFactor)];for(let m of o)r.push(...await m.wrapFileKey(t));let n=new TextEncoder().encode("header"),i=xi(wt,t,void 0,n,32),s=Mn(wt,i,dT(r)),a=N6(r,s),c=xo(16),u=new TextEncoder().encode("payload"),d=xi(wt,t,c,u,32),p=U6(d);if(!(e instanceof ReadableStream)){if(typeof e==="string")e=new TextEncoder().encode(e);return await lT(Yc(ay(e).pipeThrough(p),a,c))}return Object.assign(Yc(e.pipeThrough(p),a,c),{size:(m)=>M6(m)+a.length+c.length})}}class rp{identities=[];addPassphrase(e){this.identities.push(new wT(e))}addIdentity(e){if(wle(e))this.identities.push(new py(e));else if(typeof e==="string")if(e.startsWith("AGE-SECRET-KEY-1"))this.identities.push(new py(e));else if(e.startsWith("AGE-SECRET-KEY-PQ-1"))this.identities.push(new gT(e));else throw Error("unrecognized identity type");else this.identities.push(e)}async decrypt(e,t){let r=e instanceof ReadableStream?e:ay(e),{fileKey:o,headerSize:n,rest:i}=await this.decryptHeaderInternal(r),{data:s,rest:a}=await P6(i,16),c=new TextEncoder().encode("payload"),u=xi(wt,o,s,c,32),d=j6(u),p=a.pipeThrough(d),m=Object.assign(p,{size:(h)=>Z6(h-n-s.length)});if(e instanceof ReadableStream)return m;if(t==="text")return await C6(p);return await lT(p)}async decryptHeader(e){return(await this.decryptHeaderInternal(ay(e))).fileKey}async decryptHeaderInternal(e){let t=await z6(e),r=await this.unwrapFileKey(t.stanzas);if(r===null)throw Error("no identity matched any of the file's recipients");let o=new TextEncoder().encode("header"),n=xi(wt,r,void 0,o,32),i=Mn(wt,n,t.headerNoMAC);if(!vle(t.MAC,i))throw Error("invalid header HMAC");return{fileKey:r,headerSize:t.headerSize,rest:t.rest}}async unwrapFileKey(e){for(let t of this.identities){let r=await t.unwrapFileKey(e);if(r!==null)return r}return null}}function vle(e,t){if(e.length!==t.length)return!1;let r=0;for(let o=0;o<e.length;o++)r|=e[o]^t[o];return r===0}function wle(e){return typeof CryptoKey<"u"&&e instanceof CryptoKey}var Ui=v(()=>{bd();KI();Cc();Gr();na();na();na();na();cy();q6();uT();F6();K6();na()});function H6(e,t,r){if(r.length===0)return;e(`${t} (${r.length}):`);for(let o of r)e(` - ${o}`)}function IT(e,t,r){let o=t.filter((i)=>r(i)),n=t.filter((i)=>!r(i));H6(e,"Required before first deploy",o),H6(e,"Safe to ignore for now",n)}async function qi(e,t={}){let r=t.runCommand??jt;(t.logger??console.log)(`Pushing ${e.length} secrets to GitHub Secrets...`),await Promise.all(e.map(([n,i])=>r("gh",["secret","set",n],{stdin:i})))}var np=v(()=>{jn()});function Xc(e){let t=e?.trim().toLowerCase();if(!t)return;if(t==="gh"||t==="github")return"gh";if(t==="bw"||t==="bitwarden")return"bitwarden";throw Error(`Unsupported --push-to value: ${e}`)}import{existsSync as xle,mkdirSync as _le,readFileSync as AT,writeFileSync as TT}from"fs";import{dirname as Ele,join as J6}from"path";async function RT(e,t={}){try{let r=await V6(e,t);return{success:!0,message:r.createdLocalKey?`Age key ready at ${r.identityPath}`:`Age key already ready at ${r.identityPath}`}}catch(r){return{success:!1,message:Ve(r,"Age key bootstrap failed")}}}async function V6(e,t={}){let r=t.logger??console.log,o=J6(e,".brains-ops","age","identity.txt"),n=!1,i,s;if(xle(o))i=el(AT(o,"utf8")),s=await uy(i);else _le(Ele(o),{recursive:!0,mode:448}),i=await mT(),s=await uy(i),TT(o,Ile(i,s),{encoding:"utf8",mode:384}),n=!0;kle(J6(e,"pilot.yaml"),s);let a=Xc(t.pushTo);if(a)await qi([["AGE_SECRET_KEY",AT(o,"utf8")]],{logger:r,runCommand:t.runCommand??jt});if(r(n?`Created ${o}`:`Reusing ${o}`),r(`Configured pilot.yaml agePublicKey ${s}`),a)r(`Pushed AGE_SECRET_KEY to ${a}`);return{createdLocalKey:n,identityPath:o,agePublicKey:s}}function kle(e,t){let r=AT(e,"utf8"),o=r.match(/^agePublicKey:\s*(.+)$/m),n=o?.[1]?.trim().replace(/^['"]|['"]$/g,"");if(n===t)return;if(n&&n!=="age1replace-with-your-public-key")throw Error(`pilot.yaml agePublicKey does not match local age identity (${n} !== ${t})`);if(o){TT(e,r.replace(/^agePublicKey:\s*.+$/m,`agePublicKey: ${t}`),"utf8");return}let i=r.endsWith(`
|
|
416
416
|
`)?`${r}agePublicKey: ${t}
|
|
417
417
|
`:`${r}
|
|
418
418
|
agePublicKey: ${t}
|
|
419
|
-
`;TT(e,i,"utf8")}function el(e){let t=e.split(/\r?\n/).map((r)=>r.trim()).find((r)=>r.startsWith("AGE-SECRET-KEY-"));if(!t)throw Error("Missing AGE-SECRET-KEY in age identity file");return t}function
|
|
420
|
-
`)}var fy=v(()=>{Ui();np();jn()});function gM(e){return Object.keys(e)}import{readFileSync as sp}from"fs";import{access as
|
|
421
|
-
`;
|
|
422
|
-
`);await wM(e,r,{flag:"wx"})}async function _M(e){try{return await
|
|
423
|
-
`)}function ZM(e,t,r,o){if(!mn(e.contents))throw Error("Desired-state YAML must contain a mapping");let n=e.contents.items.findIndex((s)=>bo(s.key)&&s.key.value===t),i=e.createPair(r,[...o]);if(n>=0){let s=e.contents.items[n];NM(s?.key,i.key),NM(s?.value,i.value),e.contents.items.splice(n,1,i)}else e.contents.add(i);return i}function UM(e){let t=jM(e),r=
|
|
424
|
-
`)}catch{}}}formatJsonEntry(e,t,r){let o={ts:new Date().toISOString(),level:e,msg:t};if(this.context)o.ctx=this.context;if(r.length>0)o.data=r;return JSON.stringify(o)}silly(e,...t){if(this.level<=ia.SILLY)this.write(console.debug.bind(console),"silly",e,t)}verbose(e,...t){if(this.level<=ia.VERBOSE)this.write(console.debug.bind(console),"verbose",e,t)}debug(e,...t){if(this.level<=ia.DEBUG)this.write(console.debug.bind(console),"debug",e,t)}info(e,...t){if(this.level<=ia.INFO){let r=this.useStderr?console.error.bind(console):console.info.bind(console);this.write(r,"info",e,t)}}warn(e,...t){if(this.level<=ia.WARN)this.write(console.warn.bind(console),"warn",e,t)}error(e,...t){if(this.level<=ia.ERROR)this.write(console.error.bind(console),"error",e,t)}child(e){return new Ar({level:this.level,context:e,useStderr:this.useStderr,format:this.format},this.fileHandle)}setUseStderr(e){this.useStderr=e}}var ia,yNe;var HT=v(()=>{ia={SILLY:0,VERBOSE:1,DEBUG:2,INFO:3,WARN:4,ERROR:5,NONE:6};yNe=Ar.getInstance()});var JT,Pde,sl,wNe;var lp=v(()=>{Rt();fe();JT=l.enum(["file_operations","content_operations","data_processing","batch_processing"]),Pde=l.looseObject({pluginId:l.string().optional(),progressToken:l.union([l.string(),l.number()]).optional(),operationType:JT,operationTarget:l.string().optional(),interfaceType:l.string().optional(),conversationId:l.string().optional(),channelId:l.string().optional(),requestedByActor:ci.optional(),requestedByUserId:l.string().optional(),requestedByInterface:l.string().optional(),silent:l.boolean().optional(),provenance:uo.optional()}),sl=l.looseObject({pluginId:l.string().optional(),progressToken:l.union([l.string(),l.number()]).optional(),operationType:JT,operationTarget:l.string().optional(),interfaceType:l.string().optional(),conversationId:l.string().optional(),channelId:l.string().optional(),requestedByActor:ci.optional(),requestedByUserId:l.string().optional(),requestedByInterface:l.string().optional(),silent:l.boolean().optional(),provenance:uo.optional(),rootJobId:l.string()}),wNe=l.enum(["none","skip","replace","coalesce"])});var zde,Hi=15000;var up=v(()=>{lp();fe();zde=l.object({id:l.string(),type:l.string(),data:l.string(),status:l.enum(["pending","processing","completed","failed"]),source:l.string().nullable(),priority:l.number(),retryCount:l.number(),maxRetries:l.number(),lastError:l.string().nullable(),lastErrorPublic:l.unknown(),createdAt:l.number(),scheduledFor:l.number(),startedAt:l.number().nullable(),completedAt:l.number().nullable(),attemptId:l.string().nullable(),workerSlotId:l.string().nullable(),workerSessionId:l.string().nullable(),leaseExpiresAt:l.number().nullable(),attemptHeartbeatAt:l.number().nullable(),runtimeUpdatedAt:l.number().nullable(),metadata:sl,progress:l.custom((e)=>typeof e==="object"&&e!==null&&("progress"in e)&&typeof e.progress==="number").nullable(),result:l.unknown().nullable().optional()})});var VT,aq,Oe,Nde,Dde,cq,lq,uq;var Do=v(()=>{Rt();fe();lp();VT=l.enum(["pending","processing","completed","failed"]),aq=l.enum(["completed","failed"]),Oe={PENDING:"pending",PROCESSING:"processing",COMPLETED:"completed",FAILED:"failed"},Nde=l.object({id:l.string(),type:l.string(),status:VT,data:l.unknown(),result:l.unknown().optional(),lastError:l.string().optional().nullable(),attempts:l.number(),maxRetries:l.number(),priority:l.number(),createdAt:l.date(),updatedAt:l.date(),processedAt:l.date().optional().nullable(),completedAt:l.date().optional().nullable(),failedAt:l.date().optional().nullable()}),Dde=l.object({jobId:l.string(),type:l.string(),status:aq,result:l.unknown().optional(),error:l.string().optional()}),cq=l.object({success:l.literal(!1),error:l.string().optional()}),lq=l.object({id:l.string(),type:l.enum(["job","batch"]),status:VT,message:l.string().optional(),progress:l.object({current:l.number(),total:l.number(),percentage:l.number()}).optional(),aggregationKey:l.string().optional(),batchDetails:l.object({totalOperations:l.number(),completedOperations:l.number(),failedOperations:l.number(),currentOperation:l.string().optional(),errors:l.array(l.string()).optional()}).optional(),jobDetails:l.object({jobType:l.string(),priority:l.number(),retryCount:l.number()}).optional(),metadata:sl}),uq=ui(ZE.progress,lq)});var Ce,Gt;var vn=v(()=>{Ce=class Ce extends Error{code;extendedCode;rawCode;constructor(e,t,r,o,n){if(t!==void 0)e=`${t}: ${e}`;super(e,{cause:n});this.code=t,this.extendedCode=r,this.rawCode=o,this.name="LibsqlError"}};Gt=class Gt extends Ce{statementIndex;constructor(e,t,r,o,n,i){super(e,r,o,n,i);this.statementIndex=t,this.name="LibsqlBatchError"}}});function dq(e){let t=Lde.exec(e);if(t===null)throw new Ce(`The URL '${e}' is not in a valid format`,"URL_INVALID");let r=t.groups,o=r.scheme,n=r.authority!==void 0?Bde(r.authority):void 0,i=sa(r.path),s=r.query!==void 0?Zde(r.query):void 0,a=r.fragment!==void 0?sa(r.fragment):void 0;return{scheme:o,authority:n,path:i,query:s,fragment:a}}function Bde(e){let t=jde.exec(e);if(t===null)throw new Ce("The authority part of the URL is not in a valid format","URL_INVALID");let r=t.groups,o=sa(r.host_br??r.host),n=r.port?parseInt(r.port,10):void 0,i=r.username!==void 0?{username:sa(r.username),password:r.password!==void 0?sa(r.password):void 0}:void 0;return{host:o,port:n,userinfo:i}}function Zde(e){let t=e.split("&"),r=[];for(let o of t){if(o==="")continue;let n,i,s=o.indexOf("=");if(s<0)n=o,i="";else n=o.substring(0,s),i=o.substring(s+1);r.push({key:sa(n.replaceAll("+"," ")),value:sa(i.replaceAll("+"," "))})}return{pairs:r}}function sa(e){try{return decodeURIComponent(e)}catch(t){if(t instanceof URIError)throw new Ce(`URL component has invalid percent encoding: ${t}`,"URL_INVALID",void 0,void 0,t);throw t}}function dp(e,t,r){if(t===void 0)throw new Ce(`URL with scheme ${JSON.stringify(e+":")} requires authority (the "//" part)`,"URL_INVALID");let o=`${e}:`,n=Ude(t.host),i=Mde(t.port),a=`//${qde(t.userinfo)}${n}${i}`,c=r.split("/").map(encodeURIComponent).join("/");if(c!==""&&!c.startsWith("/"))c="/"+c;return new URL(`${o}${a}${c}`)}function Ude(e){return e.includes(":")?`[${encodeURI(e)}]`:encodeURI(e)}function Mde(e){return e!==void 0?`:${e}`:""}function qde(e){if(e===void 0)return"";let t=encodeURIComponent(e.username),r=e.password!==void 0?`:${encodeURIComponent(e.password)}`:"";return`${t}${r}@`}var Lde,jde;var ky=v(()=>{vn();Lde=(()=>new RegExp("^(?<scheme>[A-Za-z][A-Za-z.+-]*):(//(?<authority>[^/?#]*))?(?<path>[^?#]*)(\\?(?<query>[^#]*))?(#(?<fragment>.*))?$","su"))();jde=(()=>new RegExp("^((?<username>[^:]*)(:(?<password>.*))?@)?((?<host>[^:\\[\\]]*)|(\\[(?<host_br>[^\\[\\]]*)\\]))(:(?<port>[0-9]*))?$","su"))()});var cl,pq,fq,pp,Iy,Fde,Qt,mq,yq=(e)=>e.replace(/=/g,"").replace(/[+\/]/g,(t)=>t=="+"?"-":"_"),bq=(e)=>e.replace(/[^A-Za-z0-9\+\/]/g,""),Sq=(e)=>{let t,r,o,n,i="",s=e.length%3;for(let a=0;a<e.length;){if((r=e.charCodeAt(a++))>255||(o=e.charCodeAt(a++))>255||(n=e.charCodeAt(a++))>255)throw TypeError("invalid character found");t=r<<16|o<<8|n,i+=pp[t>>18&63]+pp[t>>12&63]+pp[t>>6&63]+pp[t&63]}return s?i.slice(0,s-3)+"===".substring(s):i},QT,WT,Ay=(e,t=!1)=>t?yq(WT(e)):WT(e),Kde=(e)=>{if(e.length<2){var t=e.charCodeAt(0);return t<128?e:t<2048?Qt(192|t>>>6)+Qt(128|t&63):Qt(224|t>>>12&15)+Qt(128|t>>>6&63)+Qt(128|t&63)}else{var t=65536+(e.charCodeAt(0)-55296)*1024+(e.charCodeAt(1)-56320);return Qt(240|t>>>18&7)+Qt(128|t>>>12&63)+Qt(128|t>>>6&63)+Qt(128|t&63)}},Hde,vq=(e)=>e.replace(Hde,Kde),hq,al=(e,t=!1)=>t?yq(hq(e)):hq(e),gq=(e)=>al(e,!0),Jde,Vde=(e)=>{switch(e.length){case 4:var t=(7&e.charCodeAt(0))<<18|(63&e.charCodeAt(1))<<12|(63&e.charCodeAt(2))<<6|63&e.charCodeAt(3),r=t-65536;return Qt((r>>>10)+55296)+Qt((r&1023)+56320);case 3:return Qt((15&e.charCodeAt(0))<<12|(63&e.charCodeAt(1))<<6|63&e.charCodeAt(2));default:return Qt((31&e.charCodeAt(0))<<6|63&e.charCodeAt(1))}},wq=(e)=>e.replace(Jde,Vde),xq=(e)=>{if(e=e.replace(/\s+/g,""),!Fde.test(e))throw TypeError("malformed base64.");e+="==".slice(2-(e.length&3));let t,r,o,n=[];for(let i=0;i<e.length;)if(t=Iy[e.charAt(i++)]<<18|Iy[e.charAt(i++)]<<12|(r=Iy[e.charAt(i++)])<<6|(o=Iy[e.charAt(i++)]),r===64)n.push(Qt(t>>16&255));else if(o===64)n.push(Qt(t>>16&255,t>>8&255));else n.push(Qt(t>>16&255,t>>8&255,t&255));return n.join("")},YT,_q,Eq=(e)=>_q(kq(e)),Wde,kq=(e)=>bq(e.replace(/[-_]/g,(t)=>t=="-"?"+":"/")),GT=(e)=>Wde(kq(e)),Gde=(e)=>{if(typeof e!=="string")return!1;let t=e.replace(/\s+/g,"").replace(/={0,2}$/,"");return!/[^\s0-9a-zA-Z\+/]/.test(t)||!/[^\s0-9a-zA-Z\-_]/.test(t)},Iq=(e)=>({value:e,enumerable:!1,writable:!0,configurable:!0}),Aq=function(){let e=(t,r)=>Object.defineProperty(String.prototype,t,Iq(r));e("fromBase64",function(){return GT(this)}),e("toBase64",function(t){return al(this,t)}),e("toBase64URI",function(){return al(this,!0)}),e("toBase64URL",function(){return al(this,!0)}),e("toUint8Array",function(){return Eq(this)})},Tq=function(){let e=(t,r)=>Object.defineProperty(Uint8Array.prototype,t,Iq(r));e("toBase64",function(t){return Ay(this,t)}),e("toBase64URI",function(){return Ay(this,!0)}),e("toBase64URL",function(){return Ay(this,!0)})},Qde=()=>{Aq(),Tq()},ll;var Ty=v(()=>{cl=typeof Buffer==="function",pq=typeof TextDecoder==="function"?new TextDecoder("utf-8",{ignoreBOM:!0}):void 0,fq=typeof TextEncoder==="function"?new TextEncoder:void 0,pp=Array.prototype.slice.call("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="),Iy=((e)=>{let t={};return e.forEach((r,o)=>t[r]=o),t})(pp),Fde=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,Qt=String.fromCharCode.bind(String),mq=typeof Uint8Array.from==="function"?Uint8Array.from.bind(Uint8Array):(e)=>new Uint8Array(Array.prototype.slice.call(e,0)),QT=typeof btoa==="function"?(e)=>btoa(e):cl?(e)=>Buffer.from(e,"binary").toString("base64"):Sq,WT=cl?(e)=>Buffer.from(e).toString("base64"):(e)=>{let r=[];for(let o=0,n=e.length;o<n;o+=4096)r.push(Qt.apply(null,e.subarray(o,o+4096)));return QT(r.join(""))},Hde=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,hq=cl?(e)=>Buffer.from(e,"utf8").toString("base64"):fq?(e)=>WT(fq.encode(e)):(e)=>QT(vq(e)),Jde=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,YT=typeof atob==="function"?(e)=>atob(bq(e)):cl?(e)=>Buffer.from(e,"base64").toString("binary"):xq,_q=cl?(e)=>mq(Buffer.from(e,"base64")):(e)=>mq(YT(e).split("").map((t)=>t.charCodeAt(0))),Wde=cl?(e)=>Buffer.from(e,"base64").toString("utf8"):pq?(e)=>pq.decode(_q(e)):(e)=>wq(YT(e)),ll={version:"3.8.0",VERSION:"3.8.0",atob:YT,atobPolyfill:xq,btoa:QT,btoaPolyfill:Sq,fromBase64:GT,toBase64:al,encode:al,encodeURI:gq,encodeURL:gq,utob:vq,btou:wq,decode:GT,isValid:Gde,fromUint8Array:Ay,toUint8Array:Eq,extendString:Aq,extendUint8Array:Tq,extendBuiltins:Qde}});function Ji(e){if(e==="write")return"BEGIN IMMEDIATE";else if(e==="read")return"BEGIN TRANSACTION READONLY";else if(e==="deferred")return"BEGIN DEFERRED";else throw RangeError('Unknown transaction mode, supported values are "write", "read" and "deferred"')}class ul{columns;columnTypes;rows;rowsAffected;lastInsertRowid;constructor(e,t,r,o,n){this.columns=e,this.columnTypes=t,this.rows=r,this.rowsAffected=o,this.lastInsertRowid=n}toJSON(){return{columns:this.columns,columnTypes:this.columnTypes,rows:this.rows.map(Yde),rowsAffected:this.rowsAffected,lastInsertRowid:this.lastInsertRowid!==void 0?""+this.lastInsertRowid:null}}}function Yde(e){return Array.prototype.map.call(e,Xde)}function Xde(e){if(typeof e==="bigint")return""+e;else if(e instanceof ArrayBuffer)return ll.fromUint8Array(new Uint8Array(e));else return e}var Yn="https://github.com/libsql/libsql-client-ts#supported-urls";var dl=v(()=>{Ty()});function $q(e){return e.scheme==="file"&&(e.path===":memory:"||e.path.startsWith(":memory:?"))}function fp(e,t){if(typeof e!=="object")throw TypeError(`Expected client configuration as object, got ${typeof e}`);let{url:r,authToken:o,tls:n,intMode:i,concurrency:s}=e;s=Math.max(0,s||20),i??="number";let a=[];if(r===Rq)r="file::memory:";let c=dq(r),u=c.scheme.toLowerCase(),d=u==="file"&&c.path===Rq&&c.authority===void 0,p;if(d)p={cache:{values:["shared","private"],update:(y,S)=>a.push(`${y}=${S}`)}};else p={tls:{values:["0","1"],update:(y,S)=>n=S==="1"},authToken:{update:(y,S)=>o=S}};for(let{key:y,value:S}of c.query?.pairs??[]){if(!Object.hasOwn(p,y))throw new Ce(`Unsupported URL query parameter ${JSON.stringify(y)}`,"URL_PARAM_NOT_SUPPORTED");let x=p[y];if(x.values!==void 0&&!x.values.includes(S))throw new Ce(`Unknown value for the "${y}" query argument: ${JSON.stringify(S)}. Supported values are: [${x.values.map((_)=>'"'+_+'"').join(", ")}]`,"URL_INVALID");if(x.update!==void 0)x?.update(y,S)}let m=a.length===0?"":`?${a.join("&")}`,h=c.path+m,b;if(u==="libsql")if(n===!1){if(c.authority?.port===void 0)throw new Ce('A "libsql:" URL with ?tls=0 must specify an explicit port',"URL_INVALID");b=t?"http":"ws"}else b=t?"https":"wss";else b=u;if(b==="http"||b==="ws")n??=!1;else n??=!0;if(b!=="http"&&b!=="ws"&&b!=="https"&&b!=="wss"&&b!=="file")throw new Ce(`The client supports only "libsql:", "wss:", "ws:", "https:", "http:" and "file:" URLs, got ${JSON.stringify(c.scheme+":")}. For more information, please read ${Yn}`,"URL_SCHEME_NOT_SUPPORTED");if(i!=="number"&&i!=="bigint"&&i!=="string")throw TypeError(`Invalid value for intMode, expected "number", "bigint" or "string", got ${JSON.stringify(i)}`);if(c.fragment!==void 0)throw new Ce(`URL fragments are not supported: ${JSON.stringify("#"+c.fragment)}`,"URL_INVALID");if(d)return{scheme:"file",tls:!1,path:h,intMode:i,concurrency:s,syncUrl:e.syncUrl,syncInterval:e.syncInterval,readYourWrites:e.readYourWrites,offline:e.offline,fetch:e.fetch,timeout:e.timeout,authToken:void 0,encryptionKey:void 0,remoteEncryptionKey:void 0,authority:void 0};return{scheme:b,tls:n,authority:c.authority,path:h,authToken:o,intMode:i,concurrency:s,encryptionKey:e.encryptionKey,remoteEncryptionKey:e.remoteEncryptionKey,syncUrl:e.syncUrl,syncInterval:e.syncInterval,readYourWrites:e.readYourWrites,offline:e.offline,fetch:e.fetch,timeout:e.timeout}}var Rq=":memory:";var mp=v(()=>{vn();ky();dl()});var Cq=ge(function(nn){var epe=nn&&nn.__createBinding||(Object.create?function(e,t,r,o){if(o===void 0)o=r;var n=Object.getOwnPropertyDescriptor(t,r);if(!n||("get"in n?!t.__esModule:n.writable||n.configurable))n={enumerable:!0,get:function(){return t[r]}};Object.defineProperty(e,o,n)}:function(e,t,r,o){if(o===void 0)o=r;e[o]=t[r]}),tpe=nn&&nn.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Oq=nn&&nn.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null){for(var r in e)if(r!=="default"&&Object.prototype.hasOwnProperty.call(e,r))epe(t,e,r)}return tpe(t,e),t};Object.defineProperty(nn,"__esModule",{value:!0});nn.load=nn.currentTarget=void 0;var rpe=Oq(qr("path")),npe=Oq(qr("fs"));function ope(){let e=null;switch(process.platform){case"android":switch(process.arch){case"arm":return"android-arm-eabi";case"arm64":return"android-arm64"}e="Android";break;case"win32":switch(process.arch){case"x64":return"win32-x64-msvc";case"arm64":return"win32-arm64-msvc";case"ia32":return"win32-ia32-msvc"}e="Windows";break;case"darwin":switch(process.arch){case"x64":return"darwin-x64";case"arm64":return"darwin-arm64"}e="macOS";break;case"linux":switch(process.arch){case"x64":case"arm64":return ipe()?`linux-${process.arch}-gnu`:`linux-${process.arch}-musl`;case"arm":return"linux-arm-gnueabihf"}e="Linux";break;case"freebsd":if(process.arch==="x64")return"freebsd-x64";e="FreeBSD";break}if(e)throw Error(`Neon: unsupported ${e} architecture: ${process.arch}`);throw Error(`Neon: unsupported system: ${process.platform}`)}nn.currentTarget=ope;function ipe(){let e=process.report?.getReport();if(typeof e!=="object"||!e||!("header"in e))return!1;let t=e.header;return typeof t==="object"&&!!t&&"glibcVersionRuntime"in t}function spe(e){let t=rpe.join(e,"index.node");return npe.existsSync(t)?qr(t):null}nn.load=spe});var Nq=ge(function(MNe,zq){var Pq=()=>process.platform==="linux",XT=null,ape=()=>{if(!XT)XT=Pq()&&process.report?process.report.getReport():{};return XT};zq.exports={isLinux:Pq,getReport:ape}});var Bq=ge(function(qNe,Lq){var Dq=qr("fs"),cpe=(e)=>Dq.readFileSync(e,"utf-8"),lpe=(e)=>new Promise((t,r)=>{Dq.readFile(e,"utf-8",(o,n)=>{if(o)r(o);else t(n)})});Lq.exports={LDD_PATH:"/usr/bin/ldd",readFileSync:cpe,readFile:lpe}});var t4=ge(function(FNe,e4){var Zq=qr("child_process"),{isLinux:pl,getReport:Uq}=Nq(),{LDD_PATH:Ry,readFile:Mq,readFileSync:qq}=Bq(),Xn,eo,Vi="",Fq=()=>{if(!Vi)return new Promise((e)=>{Zq.exec("getconf GNU_LIBC_VERSION 2>&1 || true; ldd --version 2>&1 || true",(t,r)=>{Vi=t?" ":r,e(Vi)})});return Vi},Kq=()=>{if(!Vi)try{Vi=Zq.execSync("getconf GNU_LIBC_VERSION 2>&1 || true; ldd --version 2>&1 || true",{encoding:"utf8"})}catch(e){Vi=" "}return Vi},Lo="glibc",Hq=/GLIBC\s(\d+\.\d+)/,aa="musl",upe=Lo.toUpperCase(),dpe=aa.toLowerCase(),ppe=(e)=>e.includes("libc.musl-")||e.includes("ld-musl-"),Jq=()=>{let e=Uq();if(e.header&&e.header.glibcVersionRuntime)return Lo;if(Array.isArray(e.sharedObjects)){if(e.sharedObjects.some(ppe))return aa}return null},Vq=(e)=>{let[t,r]=e.split(/[\r\n]+/);if(t&&t.includes(Lo))return Lo;if(r&&r.includes(aa))return aa;return null},Wq=(e)=>{if(e.includes(dpe))return aa;if(e.includes(upe))return Lo;return null},fpe=async()=>{if(Xn!==void 0)return Xn;Xn=null;try{let e=await Mq(Ry);Xn=Wq(e)}catch(e){}return Xn},mpe=()=>{if(Xn!==void 0)return Xn;Xn=null;try{let e=qq(Ry);Xn=Wq(e)}catch(e){}return Xn},Gq=async()=>{let e=null;if(pl()){if(e=await fpe(),!e)e=Jq();if(!e){let t=await Fq();e=Vq(t)}}return e},Qq=()=>{let e=null;if(pl()){if(e=mpe(),!e)e=Jq();if(!e){let t=Kq();e=Vq(t)}}return e},hpe=async()=>pl()&&await Gq()!==Lo,gpe=()=>pl()&&Qq()!==Lo,ype=async()=>{if(eo!==void 0)return eo;eo=null;try{let t=(await Mq(Ry)).match(Hq);if(t)eo=t[1]}catch(e){}return eo},bpe=()=>{if(eo!==void 0)return eo;eo=null;try{let t=qq(Ry).match(Hq);if(t)eo=t[1]}catch(e){}return eo},Yq=()=>{let e=Uq();if(e.header&&e.header.glibcVersionRuntime)return e.header.glibcVersionRuntime;return null},jq=(e)=>e.trim().split(/\s+/)[1],Xq=(e)=>{let[t,r,o]=e.split(/[\r\n]+/);if(t&&t.includes(Lo))return jq(t);if(r&&o&&r.includes(aa))return jq(o);return null},Spe=async()=>{let e=null;if(pl()){if(e=await ype(),!e)e=Yq();if(!e){let t=await Fq();e=Xq(t)}}return e},vpe=()=>{let e=null;if(pl()){if(e=bpe(),!e)e=Yq();if(!e){let t=Kq();e=Xq(t)}}return e};e4.exports={GLIBC:Lo,MUSL:aa,family:Gq,familySync:Qq,isNonGlibcLinux:hpe,isNonGlibcLinuxSync:gpe,version:Spe,versionSync:vpe}});var n4=ge(function(KNe,r4){var wpe={ALLOW:0,DENY:1};r4.exports=wpe});var i4=ge(function(HNe,o4){var eR={value:"SqliteError",writable:!0,enumerable:!1,configurable:!0};function ca(e,t,r){if(new.target!==ca)return new ca(e,t);if(typeof t!=="string")throw TypeError("Expected second argument to be a string");Error.call(this,e),eR.value=""+e,Object.defineProperty(this,"message",eR),Error.captureStackTrace(this,ca),this.code=t,this.rawCode=r}Object.setPrototypeOf(ca,Error);Object.setPrototypeOf(ca.prototype,Error.prototype);Object.defineProperty(ca.prototype,"name",eR);o4.exports=ca});var f4=ge(function(JNe,$y){var __dirname="/home/runner/work/brains/brains/node_modules/libsql",{load:xpe,currentTarget:_pe}=Cq(),{familySync:s4,GLIBC:Epe,MUSL:kpe}=t4();function Ipe(){if(process.env.LIBSQL_JS_DEV)return xpe(__dirname);let e=_pe();if(s4()==Epe)switch(e){case"linux-x64-musl":e="linux-x64-gnu";break;case"linux-arm64-musl":e="linux-arm64-gnu";break}if(e==="linux-arm-gnueabihf"&&s4()==kpe)e="linux-arm-musleabihf";return qr(`@libsql/${e}`)}var{databaseOpen:Ape,databaseOpenWithSync:Tpe,databaseInTransaction:Rpe,databaseInterrupt:$pe,databaseClose:Ope,databaseSyncSync:Cpe,databaseSyncUntilSync:Ppe,databaseExecSync:zpe,databasePrepareSync:Npe,databaseDefaultSafeIntegers:Dpe,databaseAuthorizer:Lpe,databaseLoadExtension:Bpe,databaseMaxWriteReplicationIndex:jpe,statementRaw:Zpe,statementIsReader:Upe,statementGet:a4,statementRun:c4,statementInterrupt:Mpe,statementRowsSync:l4,statementColumns:qpe,statementSafeIntegers:Fpe,rowsNext:Kpe}=Ipe(),Hpe=n4(),u4=i4();function fl(e){if(e.libsqlError)return new u4(e.message,e.code,e.rawCode);return e}class d4{constructor(e,t){let r=t?.encryptionCipher??"aes256cbc";if(t&&t.syncUrl){var o="";if(t.syncAuth)console.warn("Warning: The `syncAuth` option is deprecated, please use `authToken` option instead."),o=t.syncAuth;else if(t.authToken)o=t.authToken;let i=t?.encryptionKey??"",s=t?.syncPeriod??0,a=t?.readYourWrites??!0,c=t?.offline??!1,u=t?.remoteEncryptionKey??"";this.db=Tpe(e,t.syncUrl,o,r,i,s,a,c,u)}else{let i=t?.authToken??"",s=t?.encryptionKey??"",a=t?.timeout??0,c=t?.remoteEncryptionKey??"";this.db=Ape(e,i,r,s,a,c)}this.memory=e===":memory:",this.readonly=!1,this.name="",this.open=!0;let n=this.db;Object.defineProperties(this,{inTransaction:{get(){return Rpe(n)}}})}sync(){return Cpe.call(this.db)}syncUntil(e){return Ppe.call(this.db,e)}prepare(e){try{let t=Npe.call(this.db,e);return new p4(t)}catch(t){throw fl(t)}}transaction(e){if(typeof e!=="function")throw TypeError("Expected first argument to be a function");let t=this,r=(n)=>(...i)=>{t.exec("BEGIN "+n);try{let s=e(...i);return t.exec("COMMIT"),s}catch(s){throw t.exec("ROLLBACK"),s}},o={default:{value:r("")},deferred:{value:r("DEFERRED")},immediate:{value:r("IMMEDIATE")},exclusive:{value:r("EXCLUSIVE")},database:{value:this,enumerable:!0}};return Object.defineProperties(o.default.value,o),Object.defineProperties(o.deferred.value,o),Object.defineProperties(o.immediate.value,o),Object.defineProperties(o.exclusive.value,o),o.default.value}pragma(e,t){if(t==null)t={};if(typeof e!=="string")throw TypeError("Expected first argument to be a string");if(typeof t!=="object")throw TypeError("Expected second argument to be an options object");let r=t.simple,o=this.prepare(`PRAGMA ${e}`,this,!0);return r?o.pluck().get():o.all()}backup(e,t){throw Error("not implemented")}serialize(e){throw Error("not implemented")}function(e,t,r){if(t==null)t={};if(typeof t==="function")r=t,t={};if(typeof e!=="string")throw TypeError("Expected first argument to be a string");if(typeof r!=="function")throw TypeError("Expected last argument to be a function");if(typeof t!=="object")throw TypeError("Expected second argument to be an options object");if(!e)throw TypeError("User-defined function name cannot be an empty string");throw Error("not implemented")}aggregate(e,t){if(typeof e!=="string")throw TypeError("Expected first argument to be a string");if(typeof t!=="object"||t===null)throw TypeError("Expected second argument to be an options object");if(!e)throw TypeError("User-defined function name cannot be an empty string");throw Error("not implemented")}table(e,t){if(typeof e!=="string")throw TypeError("Expected first argument to be a string");if(!e)throw TypeError("Virtual table module name cannot be an empty string");throw Error("not implemented")}authorizer(e){Lpe.call(this.db,e)}loadExtension(...e){Bpe.call(this.db,...e)}maxWriteReplicationIndex(){return jpe.call(this.db)}exec(e){try{zpe.call(this.db,e)}catch(t){throw fl(t)}}interrupt(){$pe.call(this.db)}close(){Ope.call(this.db),this.open=!1}defaultSafeIntegers(e){return Dpe.call(this.db,e??!0),this}unsafeMode(...e){throw Error("not implemented")}}class p4{constructor(e){this.stmt=e,this.pluckMode=!1}raw(e){return Zpe.call(this.stmt,e??!0),this}pluck(e){return this.pluckMode=e??!0,this}get reader(){return Upe.call(this.stmt)}run(...e){try{if(e.length==1&&typeof e[0]==="object")return c4.call(this.stmt,e[0]);else return c4.call(this.stmt,e.flat())}catch(t){throw fl(t)}}get(...e){try{if(e.length==1&&typeof e[0]==="object")return a4.call(this.stmt,e[0]);else return a4.call(this.stmt,e.flat())}catch(t){throw fl(t)}}iterate(...e){var t=void 0;if(e.length==1&&typeof e[0]==="object")t=l4.call(this.stmt,e[0]);else t=l4.call(this.stmt,e.flat());return{nextRows:Array(100),nextRowIndex:100,next(){try{if(this.nextRowIndex===100)Kpe.call(t,this.nextRows),this.nextRowIndex=0;let o=this.nextRows[this.nextRowIndex];if(this.nextRows[this.nextRowIndex]=void 0,!o)return{done:!0};return this.nextRowIndex++,{value:o,done:!1}}catch(o){throw fl(o)}},[Symbol.iterator](){return this}}}all(...e){try{let t=[];for(let r of this.iterate(...e))if(this.pluckMode)t.push(r[Object.keys(r)[0]]);else t.push(r);return t}catch(t){throw fl(t)}}interrupt(){Mpe.call(this.stmt)}columns(){return qpe.call(this.stmt)}safeIntegers(e){return Fpe.call(this.stmt,e??!0),this}}$y.exports=d4;$y.exports.Authorization=Hpe;$y.exports.SqliteError=u4});import{Buffer as h4}from"buffer";function g4(e){if(e.scheme!=="file")throw new Ce(`URL scheme ${JSON.stringify(e.scheme+":")} is not supported by the local sqlite3 client. For more information, please read ${Yn}`,"URL_SCHEME_NOT_SUPPORTED");let t=e.authority;if(t!==void 0){let s=t.host.toLowerCase();if(s!==""&&s!=="localhost")throw new Ce(`Invalid host in file URL: ${JSON.stringify(t.host)}. A "file:" URL with an absolute path should start with one slash ("file:/absolute/path.db") or with three slashes ("file:///absolute/path.db"). For more information, please read ${Yn}`,"URL_INVALID");if(t.port!==void 0)throw new Ce("File URL cannot have a port","URL_INVALID");if(t.userinfo!==void 0)throw new Ce("File URL cannot have username and password","URL_INVALID")}let r=$q(e);if(r&&e.syncUrl)throw new Ce(`Embedded replica must use file for local db but URI with in-memory mode were provided instead: ${e.path}`,"URL_INVALID");let o=e.path;if(r)o=`${e.scheme}:${e.path}`;let n={authToken:e.authToken,encryptionKey:e.encryptionKey,remoteEncryptionKey:e.remoteEncryptionKey,syncUrl:e.syncUrl,syncPeriod:e.syncInterval,readYourWrites:e.readYourWrites,offline:e.offline,timeout:e.timeout},i=new hp.default(o,n);return zt(i,"SELECT 1 AS checkThatTheDatabaseCanBeOpened",e.intMode),new y4(o,n,i,e.intMode)}class y4{#e;#t;#r;#n;closed;protocol;constructor(e,t,r,o){this.#e=e,this.#t=t,this.#r=r,this.#n=o,this.closed=!1,this.protocol="file"}async execute(e,t){let r;if(typeof e==="string")r={sql:e,args:t||[]};else r=e;return this.#o(),zt(this.#i(),r,this.#n)}async batch(e,t="deferred"){this.#o();let r=this.#i();try{zt(r,Ji(t),this.#n);let o=[];for(let n=0;n<e.length;n++)try{if(!r.inTransaction)throw new Gt("The transaction has been rolled back",n,"TRANSACTION_CLOSED");let i=e[n],s=Array.isArray(i)?{sql:i[0],args:i[1]||[]}:i;o.push(zt(r,s,this.#n))}catch(i){if(i instanceof Gt)throw i;if(i instanceof Ce)throw new Gt(i.message,n,i.code,i.extendedCode,i.rawCode,i.cause instanceof Error?i.cause:void 0);throw i}return zt(r,"COMMIT",this.#n),o}finally{if(r.inTransaction)zt(r,"ROLLBACK",this.#n)}}async migrate(e){this.#o();let t=this.#i();try{zt(t,"PRAGMA foreign_keys=off",this.#n),zt(t,Ji("deferred"),this.#n);let r=[];for(let o=0;o<e.length;o++)try{if(!t.inTransaction)throw new Gt("The transaction has been rolled back",o,"TRANSACTION_CLOSED");r.push(zt(t,e[o],this.#n))}catch(n){if(n instanceof Gt)throw n;if(n instanceof Ce)throw new Gt(n.message,o,n.code,n.extendedCode,n.rawCode,n.cause instanceof Error?n.cause:void 0);throw n}return zt(t,"COMMIT",this.#n),r}finally{if(t.inTransaction)zt(t,"ROLLBACK",this.#n);zt(t,"PRAGMA foreign_keys=on",this.#n)}}async transaction(e="write"){let t=this.#i();return zt(t,Ji(e),this.#n),this.#r=null,new b4(t,this.#n)}async executeMultiple(e){this.#o();let t=this.#i();try{return S4(t,e)}finally{if(t.inTransaction)zt(t,"ROLLBACK",this.#n)}}async sync(){this.#o();let e=await this.#i().sync();return{frames_synced:e.frames_synced,frame_no:e.frame_no}}async reconnect(){try{if(!this.closed&&this.#r!==null)this.#r.close()}finally{this.#r=new hp.default(this.#e,this.#t),this.closed=!1}}close(){if(this.closed=!0,this.#r!==null)this.#r.close(),this.#r=null}#o(){if(this.closed)throw new Ce("The client is closed","CLIENT_CLOSED")}#i(){if(this.#r===null)this.#r=new hp.default(this.#e,this.#t);return this.#r}}class b4{#e;#t;constructor(e,t){this.#e=e,this.#t=t}async execute(e,t){let r;if(typeof e==="string")r={sql:e,args:t||[]};else r=e;return this.#r(),zt(this.#e,r,this.#t)}async batch(e){let t=[];for(let r=0;r<e.length;r++)try{this.#r();let o=e[r],n=Array.isArray(o)?{sql:o[0],args:o[1]||[]}:o;t.push(zt(this.#e,n,this.#t))}catch(o){if(o instanceof Gt)throw o;if(o instanceof Ce)throw new Gt(o.message,r,o.code,o.extendedCode,o.rawCode,o.cause instanceof Error?o.cause:void 0);throw o}return t}async executeMultiple(e){return this.#r(),S4(this.#e,e)}async rollback(){if(!this.#e.open)return;this.#r(),zt(this.#e,"ROLLBACK",this.#t)}async commit(){this.#r(),zt(this.#e,"COMMIT",this.#t)}close(){if(this.#e.inTransaction)zt(this.#e,"ROLLBACK",this.#t)}get closed(){return!this.#e.inTransaction}#r(){if(this.closed)throw new Ce("The transaction is closed","TRANSACTION_CLOSED")}}function zt(e,t,r){let o,n;if(typeof t==="string")o=t,n=[];else if(o=t.sql,Array.isArray(t.args))n=t.args.map((i)=>m4(i,r));else{n={};for(let i in t.args){let s=i[0]==="@"||i[0]==="$"||i[0]===":"?i.substring(1):i;n[s]=m4(t.args[i],r)}}try{let i=e.prepare(o);i.safeIntegers(!0);let s=!0;try{i.raw(!0)}catch{s=!1}if(s){let a=Array.from(i.columns().map((m)=>m.name)),c=Array.from(i.columns().map((m)=>m.type??"")),u=i.all(n).map((m)=>Jpe(m,a,r)),d=0,p=void 0;return new ul(a,c,u,0,void 0)}else{let a=i.run(n),c=a.changes,u=BigInt(a.lastInsertRowid);return new ul([],[],[],c,u)}}catch(i){throw v4(i)}}function Jpe(e,t,r){let o={};Object.defineProperty(o,"length",{value:e.length});for(let n=0;n<e.length;++n){let i=Vpe(e[n],r);Object.defineProperty(o,n,{value:i});let s=t[n];if(!Object.hasOwn(o,s))Object.defineProperty(o,s,{value:i,enumerable:!0,configurable:!0,writable:!0})}return o}function Vpe(e,t){if(typeof e==="bigint")if(t==="number"){if(e<Wpe||e>Gpe)throw RangeError("Received integer which cannot be safely represented as a JavaScript number");return Number(e)}else if(t==="bigint")return e;else if(t==="string")return""+e;else throw Error("Invalid value for IntMode");else if(e instanceof h4)return e.buffer;return e}function m4(e,t){if(typeof e==="number"){if(!Number.isFinite(e))throw RangeError("Only finite numbers (not Infinity or NaN) can be passed as arguments");return e}else if(typeof e==="bigint"){if(e<Qpe||e>Ype)throw RangeError("bigint is too large to be represented as a 64-bit integer and passed as argument");return e}else if(typeof e==="boolean")switch(t){case"bigint":return e?1n:0n;case"string":return e?"1":"0";default:return e?1:0}else if(e instanceof ArrayBuffer)return h4.from(e);else if(e instanceof Date)return e.valueOf();else if(e===void 0)throw TypeError("undefined cannot be passed as argument to the database");else return e}function S4(e,t){try{e.exec(t)}catch(r){throw v4(r)}}function v4(e){if(e instanceof hp.default.SqliteError){let t=e.code,r=Xpe(e.rawCode);return new Ce(e.message,r,t,e.rawCode,e)}return e}function Xpe(e){if(e===void 0)return"SQLITE_UNKNOWN";let t=e&255;return efe[t]??`SQLITE_UNKNOWN_${t.toString()}`}var hp,Wpe,Gpe=9007199254740991n,Qpe,Ype=9223372036854775807n,efe;var w4=v(()=>{vn();mp();dl();hp=ql(f4(),1);vn();Wpe=-9007199254740991n;Qpe=-9223372036854775808n;efe={1:"SQLITE_ERROR",2:"SQLITE_INTERNAL",3:"SQLITE_PERM",4:"SQLITE_ABORT",5:"SQLITE_BUSY",6:"SQLITE_LOCKED",7:"SQLITE_NOMEM",8:"SQLITE_READONLY",9:"SQLITE_INTERRUPT",10:"SQLITE_IOERR",11:"SQLITE_CORRUPT",12:"SQLITE_NOTFOUND",13:"SQLITE_FULL",14:"SQLITE_CANTOPEN",15:"SQLITE_PROTOCOL",16:"SQLITE_EMPTY",17:"SQLITE_SCHEMA",18:"SQLITE_TOOBIG",19:"SQLITE_CONSTRAINT",20:"SQLITE_MISMATCH",21:"SQLITE_MISUSE",22:"SQLITE_NOLFS",23:"SQLITE_AUTH",24:"SQLITE_FORMAT",25:"SQLITE_RANGE",26:"SQLITE_NOTADB",27:"SQLITE_NOTICE",28:"SQLITE_WARNING"}});var Wi;var tR=v(()=>{if(typeof WebSocket<"u")Wi=WebSocket;else if(typeof global<"u")Wi=global.WebSocket;else if(typeof window<"u")Wi=window.WebSocket;else if(typeof self<"u")Wi=self.WebSocket});class ml{constructor(){this.intMode="number"}intMode}var Ge,Pe,gp,xt,yp,hl,la,wn,or,to;var _t=v(()=>{Ge=class Ge extends Error{constructor(e){super(e);this.name="ClientError"}};Pe=class Pe extends Ge{constructor(e){super(e);this.name="ProtoError"}};gp=class gp extends Ge{code;proto;constructor(e,t){super(e);this.name="ResponseError",this.code=t.code,this.proto=t,this.stack=void 0}};xt=class xt extends Ge{constructor(e,t){if(t!==void 0){super(`${e}: ${t}`);this.cause=t}else super(e);this.name="ClosedError"}};yp=class yp extends Ge{constructor(e){super(e);this.name="WebSocketUnsupportedError"}};hl=class hl extends Ge{constructor(e){super(e);this.name="WebSocketError"}};la=class la extends Ge{status;constructor(e,t){super(e);this.status=t,this.name="HttpServerError"}};wn=class wn extends Ge{constructor(e){super(e);this.name="ProtocolVersionError"}};or=class or extends Ge{constructor(e){super(e);this.name="InternalError"}};to=class to extends Ge{constructor(e){super(e);this.name="MisuseError"}}});function Tr(e){if(typeof e==="string")return e;throw gl(e,"string")}function Zr(e){if(e===null||e===void 0)return;else if(typeof e==="string")return e;throw gl(e,"string or null")}function Bo(e){if(typeof e==="number")return e;throw gl(e,"number")}function Gi(e){if(typeof e==="boolean")return e;throw gl(e,"boolean")}function bp(e){if(Array.isArray(e))return e;throw gl(e,"array")}function It(e){if(e!==null&&typeof e==="object"&&!Array.isArray(e))return e;throw gl(e,"object")}function xn(e,t){return bp(e).map((r)=>t(It(r)))}function gl(e,t){if(e===void 0)return new Pe(`Expected ${t}, but the property was missing`);let r=typeof e;if(e===null)r="null";else if(Array.isArray(e))r="array";return new Pe(`Expected ${t}, received ${r}`)}function ua(e,t){return t(It(e))}var yl=v(()=>{_t()});class x4{#e;#t;constructor(e){this.#e=e,this.#t=!1}begin(){this.#e.push("{"),this.#t=!0}end(){this.#e.push("}"),this.#t=!1}#r(e){if(this.#t)this.#e.push('"'),this.#t=!1;else this.#e.push(',"');this.#e.push(e),this.#e.push('":')}string(e,t){this.#r(e),this.#e.push(JSON.stringify(t))}stringRaw(e,t){this.#r(e),this.#e.push('"'),this.#e.push(t),this.#e.push('"')}number(e,t){this.#r(e),this.#e.push(""+t)}boolean(e,t){this.#r(e),this.#e.push(t?"true":"false")}object(e,t,r){this.#r(e),this.begin(),r(this,t),this.end()}arrayObjects(e,t,r){this.#r(e),this.#e.push("[");for(let o=0;o<t.length;++o){if(o!==0)this.#e.push(",");this.begin(),r(this,t[o]),this.end()}this.#e.push("]")}}function Sp(e,t){let r=[],o=new x4(r);return o.begin(),t(o,e),o.end(),r.join("")}var da=0,vp=1,wp=2,_4=5;class E4{#e;#t;#r;constructor(e){this.#e=e,this.#t=new DataView(e.buffer,e.byteOffset,e.byteLength),this.#r=0}varint(){let e=0;for(let t=0;;t+=7){let r=this.#e[this.#r++];if(e|=(r&127)<<t,!(r&128))break}return e}varintBig(){let e=0n;for(let t=0n;;t+=7n){let r=this.#e[this.#r++];if(e|=BigInt(r&127)<<t,!(r&128))break}return e}bytes(e){let t=new Uint8Array(this.#e.buffer,this.#e.byteOffset+this.#r,e);return this.#r+=e,t}double(){let e=this.#t.getFloat64(this.#r,!0);return this.#r+=8,e}skipVarint(){for(;;)if(!(this.#e[this.#r++]&128))break}skip(e){this.#r+=e}eof(){return this.#r>=this.#e.byteLength}}class k4{#e;#t;constructor(e){this.#e=e,this.#t=-1}setup(e){this.#t=e}#r(e){if(this.#t!==e)throw new Pe(`Expected wire type ${e}, got ${this.#t}`);this.#t=-1}bytes(){this.#r(wp);let e=this.#e.varint();return this.#e.bytes(e)}string(){return new TextDecoder().decode(this.bytes())}message(e){return Qi(this.bytes(),e)}int32(){return this.#r(da),this.#e.varint()}uint32(){return this.int32()}bool(){return this.int32()!==0}uint64(){return this.#r(da),this.#e.varintBig()}sint64(){let e=this.uint64();return e>>1n^-(e&1n)}double(){return this.#r(vp),this.#e.double()}maybeSkip(){if(this.#t<0)return;else if(this.#t===da)this.#e.skipVarint();else if(this.#t===vp)this.#e.skip(8);else if(this.#t===wp){let e=this.#e.varint();this.#e.skip(e)}else if(this.#t===_4)this.#e.skip(4);else throw new Pe(`Unexpected wire type ${this.#t}`);this.#t=-1}}function Qi(e,t){let r=new E4(e),o=new k4(r),n=t.default();while(!r.eof()){let i=r.varint(),s=i>>3,a=i&7;o.setup(a);let c=t[s];if(c!==void 0){let u=c(o,n);if(u!==void 0)n=u}o.maybeSkip()}return n}var rR=v(()=>{_t()});class nR{#e;#t;#r;#n;constructor(){this.#e=new ArrayBuffer(256),this.#t=new Uint8Array(this.#e),this.#r=new DataView(this.#e),this.#n=0}#o(e){if(this.#n+e<=this.#e.byteLength)return;let t=this.#e.byteLength;while(t<this.#n+e)t*=2;let r=new ArrayBuffer(t),o=new Uint8Array(r),n=new DataView(r);o.set(new Uint8Array(this.#e,0,this.#n)),this.#e=r,this.#t=o,this.#r=n}#i(e){this.#o(5),e=0|e;do{let t=e&127;e>>>=7,t|=e?128:0,this.#t[this.#n++]=t}while(e)}#a(e){this.#o(10),e=e&0xffffffffffffffffn;do{let t=Number(e&0x7fn);e>>=7n,t|=e?128:0,this.#t[this.#n++]=t}while(e)}#s(e,t){this.#i(e<<3|t)}bytes(e,t){this.#s(e,wp),this.#i(t.byteLength),this.#o(t.byteLength),this.#t.set(t,this.#n),this.#n+=t.byteLength}string(e,t){this.bytes(e,new TextEncoder().encode(t))}message(e,t,r){let o=new nR;r(o,t),this.bytes(e,o.data())}int32(e,t){this.#s(e,da),this.#i(t)}uint32(e,t){this.int32(e,t)}bool(e,t){this.int32(e,t?1:0)}sint64(e,t){this.#s(e,da),this.#a(t<<1n^t>>63n)}double(e,t){this.#s(e,vp),this.#o(8),this.#r.setFloat64(this.#n,t,!0),this.#n+=8}data(){return new Uint8Array(this.#e,0,this.#n)}}function xp(e,t){let r=new nR;return t(r,e),r.data()}var I4=()=>{};var oR=v(()=>{yl();rR();I4()});class Yi{#e;#t;constructor(){this.#e=new Set,this.#t=new Set}alloc(){for(let t of this.#t){if(this.#t.delete(t),this.#e.add(t),!this.#e.has(this.#e.size-1))this.#t.add(this.#e.size-1);return t}let e=this.#e.size;return this.#e.add(e),e}free(e){if(!this.#e.delete(e))throw new or("Freeing an id that is not allocated");if(this.#t.delete(this.#e.size),e<this.#e.size)this.#t.add(e)}}var iR=v(()=>{_t()});function He(e,t){throw new or(t)}var on=v(()=>{_t()});function bl(e){if(e===null)return null;else if(typeof e==="string")return e;else if(typeof e==="number"){if(!Number.isFinite(e))throw RangeError("Only finite numbers (not Infinity or NaN) can be passed as arguments");return e}else if(typeof e==="bigint"){if(e<rfe||e>nfe)throw RangeError("This bigint value is too large to be represented as a 64-bit integer and passed as argument");return e}else if(typeof e==="boolean")return e?1n:0n;else if(e instanceof ArrayBuffer)return new Uint8Array(e);else if(e instanceof Uint8Array)return e;else if(e instanceof Date)return+e.valueOf();else if(typeof e==="object")return""+e.toString();else throw TypeError("Unsupported type of value")}function sR(e,t){if(e===null)return null;else if(typeof e==="number")return e;else if(typeof e==="string")return e;else if(typeof e==="bigint")if(t==="number"){let r=Number(e);if(!Number.isSafeInteger(r))throw RangeError("Received integer which is too large to be safely represented as a JavaScript number");return r}else if(t==="bigint")return e;else if(t==="string")return""+e;else throw new to("Invalid value for IntMode");else if(e instanceof Uint8Array)return e.slice().buffer;else if(e===void 0)throw new Pe("Received unrecognized type of Value");else throw He(e,"Impossible type of Value")}var rfe,nfe=9223372036854775807n;var aR=v(()=>{_t();on();rfe=-9223372036854775808n});function pa(e){return{affectedRowCount:e.affectedRowCount,lastInsertRowid:e.lastInsertRowid,columnNames:e.cols.map((t)=>t.name),columnDecltypes:e.cols.map((t)=>t.decltype)}}function Cy(e,t){let r=pa(e),o=e.rows.map((n)=>A4(r.columnNames,n,t));return{...r,rows:o}}function Py(e,t){let r=pa(e),o;if(e.rows.length>0)o=A4(r.columnNames,e.rows[0],t);return{...r,row:o}}function zy(e,t){let r=pa(e),o;if(e.rows.length>0&&r.columnNames.length>0)o=sR(e.rows[0][0],t);return{...r,value:o}}function A4(e,t,r){let o={};Object.defineProperty(o,"length",{value:t.length});for(let n=0;n<t.length;++n){let i=sR(t[n],r);Object.defineProperty(o,n,{value:i});let s=e[n];if(s!==void 0&&!Object.hasOwn(o,s))Object.defineProperty(o,s,{value:i,enumerable:!0,configurable:!0,writable:!0})}return o}function jo(e){return new gp(e.message,e)}var _p=v(()=>{_t();aR()});class fa{#e;#t;#r;constructor(e,t){this.#e=e,this.#t=t,this.#r=void 0}_getSqlId(e){if(this.#e!==e)throw new to("Attempted to use SQL text opened with other object");else if(this.#r!==void 0)throw new xt("SQL text is closed",this.#r);return this.#t}close(){this._setClosed(new Ge("SQL text was manually closed"))}_setClosed(e){if(this.#r===void 0)this.#r=e,this.#e._closeSql(this.#t)}get closed(){return this.#r!==void 0}}function Ep(e,t){if(t instanceof fa)return{sqlId:t._getSqlId(e)};else return{sql:""+t}}var Sl=v(()=>{_t()});class Xi{#e;#t;constructor(){this.#e=[],this.#t=[]}get length(){return this.#e.length+this.#t.length}push(e){this.#e.push(e)}shift(){if(this.#t.length===0&&this.#e.length>0)this.#t=this.#e.reverse(),this.#e=[];return this.#t.pop()}first(){return this.#t.length!==0?this.#t[this.#t.length-1]:this.#e[0]}}class kp{sql;_args;_namedArgs;constructor(e){this.sql=e,this._args=[],this._namedArgs=new Map}bindIndexes(e){this._args.length=0;for(let t of e)this._args.push(bl(t));return this}bindIndex(e,t){if(e!==(e|0)||e<=0)throw RangeError("Index of a positional argument must be positive integer");while(this._args.length<e)this._args.push(null);return this._args[e-1]=bl(t),this}bindName(e,t){return this._namedArgs.set(e,bl(t)),this}unbindAll(){return this._args.length=0,this._namedArgs.clear(),this}}function Ny(e,t,r){let o,n=[],i=[];if(t instanceof kp){o=t.sql,n=t._args;for(let[c,u]of t._namedArgs.entries())i.push({name:c,value:u})}else if(Array.isArray(t))if(o=t[0],Array.isArray(t[1]))n=t[1].map((c)=>bl(c));else i=Object.entries(t[1]).map(([c,u])=>({name:c,value:bl(u)}));else o=t;let{sql:s,sqlId:a}=Ep(e,o);return{sql:s,sqlId:a,args:n,namedArgs:i,wantRows:r}}var Dy=v(()=>{Sl();aR()});class Ly{_stream;#e;_steps;#t;constructor(e,t){this._stream=e,this.#e=t,this._steps=[],this.#t=!1}step(){return new cR(this)}execute(){if(this.#t)throw new to("This batch has already been executed");this.#t=!0;let e={steps:this._steps.map((t)=>t.proto)};if(this.#e)return ife(this._stream,this._steps,e);else return ofe(this._stream,this._steps,e)}}function ofe(e,t,r){return e._batch(r).then((o)=>{for(let n=0;n<t.length;++n){let i=o.stepResults.get(n),s=o.stepErrors.get(n);t[n].callback(i,s)}})}async function ife(e,t,r){let o=await e._openCursor(r);try{let n=0,i=void 0,s=[];for(;;){let a=await o.next();if(a===void 0)break;if(a.type==="step_begin"){if(a.step<n||a.step>=t.length)throw new Pe("Server produced StepBeginEntry for unexpected step");else if(i!==void 0)throw new Pe("Server produced StepBeginEntry before terminating previous step");for(let c=n;c<a.step;++c)t[c].callback(void 0,void 0);n=a.step+1,i=a,s=[]}else if(a.type==="step_end"){if(i===void 0)throw new Pe("Server produced StepEndEntry but no step is active");let c={cols:i.cols,rows:s,affectedRowCount:a.affectedRowCount,lastInsertRowid:a.lastInsertRowid};t[i.step].callback(c,void 0),i=void 0,s=[]}else if(a.type==="step_error"){if(i===void 0){if(a.step>=t.length)throw new Pe("Server produced StepErrorEntry for unexpected step");for(let c=n;c<a.step;++c)t[c].callback(void 0,void 0)}else{if(a.step!==i.step)throw new Pe("Server produced StepErrorEntry for unexpected step");i=void 0,s=[]}t[a.step].callback(void 0,a.error),n=a.step+1}else if(a.type==="row"){if(i===void 0)throw new Pe("Server produced RowEntry but no step is active");s.push(a.row)}else if(a.type==="error")throw jo(a.error);else if(a.type==="none")throw new Pe("Server produced unrecognized CursorEntry");else throw He(a,"Impossible CursorEntry")}if(i!==void 0)throw new Pe("Server closed Cursor before terminating active step");for(let a=n;a<t.length;++a)t[a].callback(void 0,void 0)}finally{o.close()}}class cR{_batch;#e;_index;constructor(e){this._batch=e,this.#e=[],this._index=void 0}condition(e){return this.#e.push(e._proto),this}query(e){return this.#t(e,!0,Cy)}queryRow(e){return this.#t(e,!0,Py)}queryValue(e){return this.#t(e,!0,zy)}run(e){return this.#t(e,!1,pa)}#t(e,t,r){if(this._index!==void 0)throw new to("This BatchStep has already been added to the batch");let o=Ny(this._batch._stream._sqlOwner(),e,t),n;if(this.#e.length===0)n=void 0;else if(this.#e.length===1)n=this.#e[0];else n={type:"and",conds:this.#e.slice()};let i={stmt:o,condition:n};return new Promise((s,a)=>{let c=(u,d)=>{if(u!==void 0&&d!==void 0)a(new Pe("Server returned both result and error"));else if(d!==void 0)a(jo(d));else if(u!==void 0)s(r(u,this._batch._stream.intMode));else s(void 0)};this._index=this._batch._steps.length,this._batch._steps.push({proto:i,callback:c})})}}class dt{_batch;_proto;constructor(e,t){this._batch=e,this._proto=t}static ok(e){return new dt(e._batch,{type:"ok",step:T4(e)})}static error(e){return new dt(e._batch,{type:"error",step:T4(e)})}static not(e){return new dt(e._batch,{type:"not",cond:e._proto})}static and(e,t){for(let r of t)R4(e,r);return new dt(e,{type:"and",conds:t.map((r)=>r._proto)})}static or(e,t){for(let r of t)R4(e,r);return new dt(e,{type:"or",conds:t.map((r)=>r._proto)})}static isAutocommit(e){return e._stream.client()._ensureVersion(3,"BatchCond.isAutocommit()"),new dt(e,{type:"is_autocommit"})}}function T4(e){if(e._index===void 0)throw new to("Cannot add a condition referencing a step that has not been added to the batch");return e._index}function R4(e,t){if(t._batch!==e)throw new to("Cannot mix BatchCond objects for different Batch objects")}var lR=v(()=>{_t();_p();Dy();on()});function $4(e){return{paramNames:e.params.map((t)=>t.name),columns:e.cols,isExplain:e.isExplain,isReadonly:e.isReadonly}}class vl{constructor(e){this.intMode=e}query(e){return this.#e(e,!0,Cy)}queryRow(e){return this.#e(e,!0,Py)}queryValue(e){return this.#e(e,!0,zy)}run(e){return this.#e(e,!1,pa)}#e(e,t,r){let o=Ny(this._sqlOwner(),e,t);return this._execute(o).then((n)=>r(n,this.intMode))}batch(e=!1){return new Ly(this,e)}describe(e){let t=Ep(this._sqlOwner(),e);return this._describe(t).then($4)}sequence(e){let t=Ep(this._sqlOwner(),e);return this._sequence(t)}intMode}var By=v(()=>{lR();_p();Sl();Dy()});class Ip{}var sfe=1000,afe=10,uR;var O4=v(()=>{_t();uR=class uR extends Ip{#e;#t;#r;#n;#o;#i;#a;constructor(e,t,r){super();this.#e=e,this.#t=t,this.#r=r,this.#n=new Xi,this.#o=new Xi,this.#i=void 0,this.#a=!1}async next(){for(;;){if(this.#i!==void 0)throw new xt("Cursor is closed",this.#i);while(!this.#a&&this.#o.length<afe)this.#o.push(this.#s());let e=this.#n.shift();if(this.#a||e!==void 0)return e;await this.#o.shift().then((t)=>{if(t===void 0)return;for(let r of t.entries)this.#n.push(r);this.#a||=t.done})}}#s(){return this.#t._sendCursorRequest(this,{type:"fetch_cursor",cursorId:this.#r,maxCount:sfe}).then((e)=>e,(e)=>{this._setClosed(e);return})}_setClosed(e){if(this.#i!==void 0)return;this.#i=e,this.#t._sendCursorRequest(this,{type:"close_cursor",cursorId:this.#r}).catch(()=>{return}),this.#t._cursorClosed(this)}close(){this._setClosed(new Ge("Cursor was manually closed"))}get closed(){return this.#i!==void 0}}});var Ap;var dR=v(()=>{_t();By();O4();Ap=class Ap extends vl{#e;#t;#r;#n;#o;#i;static open(e){let t=e._streamIdAlloc.alloc(),r=new Ap(e,t),o=()=>{return},n=(s)=>r.#l(s),i={type:"open_stream",streamId:t};return e._sendRequest(i,{responseCallback:o,errorCallback:n}),r}constructor(e,t){super(e.intMode);this.#e=e,this.#t=t,this.#r=new Xi,this.#n=void 0,this.#o=!1,this.#i=void 0}client(){return this.#e}_sqlOwner(){return this.#e}_execute(e){return this.#a({type:"execute",streamId:this.#t,stmt:e}).then((t)=>t.result)}_batch(e){return this.#a({type:"batch",streamId:this.#t,batch:e}).then((t)=>t.result)}_describe(e){return this.#e._ensureVersion(2,"describe()"),this.#a({type:"describe",streamId:this.#t,sql:e.sql,sqlId:e.sqlId}).then((t)=>t.result)}_sequence(e){return this.#e._ensureVersion(2,"sequence()"),this.#a({type:"sequence",streamId:this.#t,sql:e.sql,sqlId:e.sqlId}).then((t)=>{return})}getAutocommit(){return this.#e._ensureVersion(3,"getAutocommit()"),this.#a({type:"get_autocommit",streamId:this.#t}).then((e)=>e.isAutocommit)}#a(e){return new Promise((t,r)=>{this.#s({type:"request",request:e,responseCallback:t,errorCallback:r})})}_openCursor(e){return this.#e._ensureVersion(3,"cursor"),new Promise((t,r)=>{this.#s({type:"cursor",batch:e,cursorCallback:t,errorCallback:r})})}_sendCursorRequest(e,t){if(e!==this.#n)throw new or("Cursor not associated with the stream attempted to execute a request");return new Promise((r,o)=>{if(this.#i!==void 0)o(new xt("Stream is closed",this.#i));else this.#e._sendRequest(t,{responseCallback:r,errorCallback:o})})}_cursorClosed(e){if(e!==this.#n)throw new or("Cursor was closed, but it was not associated with the stream");this.#n=void 0,this.#c()}#s(e){if(this.#i!==void 0)e.errorCallback(new xt("Stream is closed",this.#i));else if(this.#o)e.errorCallback(new xt("Stream is closing",void 0));else this.#r.push(e),this.#c()}#c(){for(;;){let e=this.#r.first();if(e===void 0&&this.#n===void 0&&this.#o){this.#l(new Ge("Stream was gracefully closed"));break}else if(e?.type==="request"&&this.#n===void 0){let{request:t,responseCallback:r,errorCallback:o}=e;this.#r.shift(),this.#e._sendRequest(t,{responseCallback:r,errorCallback:o})}else if(e?.type==="cursor"&&this.#n===void 0){let{batch:t,cursorCallback:r}=e;this.#r.shift();let o=this.#e._cursorIdAlloc.alloc(),n=new uR(this.#e,this,o),i={type:"open_cursor",streamId:this.#t,cursorId:o,batch:t},s=()=>{return},a=(c)=>n._setClosed(c);this.#e._sendRequest(i,{responseCallback:s,errorCallback:a}),this.#n=n,r(n)}else break}}#l(e){if(this.#i!==void 0)return;if(this.#i=e,this.#n!==void 0)this.#n._setClosed(e);for(;;){let n=this.#r.shift();if(n!==void 0)n.errorCallback(e);else break}let t={type:"close_stream",streamId:this.#t},r=()=>this.#e._streamIdAlloc.free(this.#t),o=()=>{return};this.#e._sendRequest(t,{responseCallback:r,errorCallback:o})}close(){this.#l(new Ge("Stream was manually closed"))}closeGracefully(){this.#o=!0,this.#c()}get closed(){return this.#i!==void 0||this.#o}}});function Tp(e,t){if(t.sql!==void 0)e.string("sql",t.sql);if(t.sqlId!==void 0)e.number("sql_id",t.sqlId);e.arrayObjects("args",t.args,C4),e.arrayObjects("named_args",t.namedArgs,cfe),e.boolean("want_rows",t.wantRows)}function cfe(e,t){e.string("name",t.name),e.object("value",t.value,C4)}function wl(e,t){e.arrayObjects("steps",t.steps,lfe)}function lfe(e,t){if(t.condition!==void 0)e.object("condition",t.condition,pR);e.object("stmt",t.stmt,Tp)}function pR(e,t){if(e.stringRaw("type",t.type),t.type==="ok"||t.type==="error")e.number("step",t.step);else if(t.type==="not")e.object("cond",t.cond,pR);else if(t.type==="and"||t.type==="or")e.arrayObjects("conds",t.conds,pR);else if(t.type==="is_autocommit");else throw He(t,"Impossible type of BatchCond")}function C4(e,t){if(t===null)e.stringRaw("type","null");else if(typeof t==="bigint")e.stringRaw("type","integer"),e.stringRaw("value",""+t);else if(typeof t==="number")e.stringRaw("type","float"),e.number("value",t);else if(typeof t==="string")e.stringRaw("type","text"),e.string("value",t);else if(t instanceof Uint8Array)e.stringRaw("type","blob"),e.stringRaw("base64",ll.fromUint8Array(t));else if(t===void 0);else throw He(t,"Impossible type of Value")}var fR=v(()=>{Ty();on()});function P4(e,t){if(e.stringRaw("type",t.type),t.type==="hello"){if(t.jwt!==void 0)e.string("jwt",t.jwt)}else if(t.type==="request")e.number("request_id",t.requestId),e.object("request",t.request,ufe);else throw He(t,"Impossible type of ClientMsg")}function ufe(e,t){if(e.stringRaw("type",t.type),t.type==="open_stream")e.number("stream_id",t.streamId);else if(t.type==="close_stream")e.number("stream_id",t.streamId);else if(t.type==="execute")e.number("stream_id",t.streamId),e.object("stmt",t.stmt,Tp);else if(t.type==="batch")e.number("stream_id",t.streamId),e.object("batch",t.batch,wl);else if(t.type==="open_cursor")e.number("stream_id",t.streamId),e.number("cursor_id",t.cursorId),e.object("batch",t.batch,wl);else if(t.type==="close_cursor")e.number("cursor_id",t.cursorId);else if(t.type==="fetch_cursor")e.number("cursor_id",t.cursorId),e.number("max_count",t.maxCount);else if(t.type==="sequence"){if(e.number("stream_id",t.streamId),t.sql!==void 0)e.string("sql",t.sql);if(t.sqlId!==void 0)e.number("sql_id",t.sqlId)}else if(t.type==="describe"){if(e.number("stream_id",t.streamId),t.sql!==void 0)e.string("sql",t.sql);if(t.sqlId!==void 0)e.number("sql_id",t.sqlId)}else if(t.type==="store_sql")e.number("sql_id",t.sqlId),e.string("sql",t.sql);else if(t.type==="close_sql")e.number("sql_id",t.sqlId);else if(t.type==="get_autocommit")e.number("stream_id",t.streamId);else throw He(t,"Impossible type of Request")}var z4=v(()=>{fR();on()});function Rp(e,t){if(t.sql!==void 0)e.string(1,t.sql);if(t.sqlId!==void 0)e.int32(2,t.sqlId);for(let r of t.args)e.message(3,r,D4);for(let r of t.namedArgs)e.message(4,r,dfe);e.bool(5,t.wantRows)}function dfe(e,t){e.string(1,t.name),e.message(2,t.value,D4)}function xl(e,t){for(let r of t.steps)e.message(1,r,pfe)}function pfe(e,t){if(t.condition!==void 0)e.message(1,t.condition,mR);e.message(2,t.stmt,Rp)}function mR(e,t){if(t.type==="ok")e.uint32(1,t.step);else if(t.type==="error")e.uint32(2,t.step);else if(t.type==="not")e.message(3,t.cond,mR);else if(t.type==="and")e.message(4,t.conds,N4);else if(t.type==="or")e.message(5,t.conds,N4);else if(t.type==="is_autocommit")e.message(6,void 0,L4);else throw He(t,"Impossible type of BatchCond")}function N4(e,t){for(let r of t)e.message(1,r,mR)}function D4(e,t){if(t===null)e.message(1,void 0,L4);else if(typeof t==="bigint")e.sint64(2,t);else if(typeof t==="number")e.double(3,t);else if(typeof t==="string")e.string(4,t);else if(t instanceof Uint8Array)e.bytes(5,t);else if(t===void 0);else throw He(t,"Impossible type of Value")}function L4(e,t){}var hR=v(()=>{on()});function B4(e,t){if(t.type==="hello")e.message(1,t,ffe);else if(t.type==="request")e.message(2,t,mfe);else throw He(t,"Impossible type of ClientMsg")}function ffe(e,t){if(t.jwt!==void 0)e.string(1,t.jwt)}function mfe(e,t){e.int32(1,t.requestId);let r=t.request;if(r.type==="open_stream")e.message(2,r,hfe);else if(r.type==="close_stream")e.message(3,r,gfe);else if(r.type==="execute")e.message(4,r,yfe);else if(r.type==="batch")e.message(5,r,bfe);else if(r.type==="open_cursor")e.message(6,r,Sfe);else if(r.type==="close_cursor")e.message(7,r,vfe);else if(r.type==="fetch_cursor")e.message(8,r,wfe);else if(r.type==="sequence")e.message(9,r,xfe);else if(r.type==="describe")e.message(10,r,_fe);else if(r.type==="store_sql")e.message(11,r,Efe);else if(r.type==="close_sql")e.message(12,r,kfe);else if(r.type==="get_autocommit")e.message(13,r,Ife);else throw He(r,"Impossible type of Request")}function hfe(e,t){e.int32(1,t.streamId)}function gfe(e,t){e.int32(1,t.streamId)}function yfe(e,t){e.int32(1,t.streamId),e.message(2,t.stmt,Rp)}function bfe(e,t){e.int32(1,t.streamId),e.message(2,t.batch,xl)}function Sfe(e,t){e.int32(1,t.streamId),e.int32(2,t.cursorId),e.message(3,t.batch,xl)}function vfe(e,t){e.int32(1,t.cursorId)}function wfe(e,t){e.int32(1,t.cursorId),e.uint32(2,t.maxCount)}function xfe(e,t){if(e.int32(1,t.streamId),t.sql!==void 0)e.string(2,t.sql);if(t.sqlId!==void 0)e.int32(3,t.sqlId)}function _fe(e,t){if(e.int32(1,t.streamId),t.sql!==void 0)e.string(2,t.sql);if(t.sqlId!==void 0)e.int32(3,t.sqlId)}function Efe(e,t){e.int32(1,t.sqlId),e.string(2,t.sql)}function kfe(e,t){e.int32(1,t.sqlId)}function Ife(e,t){e.int32(1,t.streamId)}var j4=v(()=>{hR();on()});function es(e){let t=Tr(e.message),r=Zr(e.code);return{message:t,code:r}}function $p(e){let t=xn(e.cols,Z4),r=bp(e.rows).map((s)=>xn(s,U4)),o=Bo(e.affected_row_count),n=Zr(e.last_insert_rowid),i=n!==void 0?BigInt(n):void 0;return{cols:t,rows:r,affectedRowCount:o,lastInsertRowid:i}}function Z4(e){let t=Zr(e.name),r=Zr(e.decltype);return{name:t,decltype:r}}function jy(e){let t=new Map;bp(e.step_results).forEach((o,n)=>{if(o!==null)t.set(n,$p(It(o)))});let r=new Map;return bp(e.step_errors).forEach((o,n)=>{if(o!==null)r.set(n,es(It(o)))}),{stepResults:t,stepErrors:r}}function Zy(e){let t=Tr(e.type);if(t==="step_begin"){let r=Bo(e.step),o=xn(e.cols,Z4);return{type:"step_begin",step:r,cols:o}}else if(t==="step_end"){let r=Bo(e.affected_row_count),o=Zr(e.last_insert_rowid),n=o!==void 0?BigInt(o):void 0;return{type:"step_end",affectedRowCount:r,lastInsertRowid:n}}else if(t==="step_error"){let r=Bo(e.step),o=es(It(e.error));return{type:"step_error",step:r,error:o}}else if(t==="row")return{type:"row",row:xn(e.row,U4)};else if(t==="error")return{type:"error",error:es(It(e.error))};else throw new Pe("Unexpected type of CursorEntry")}function Uy(e){let t=xn(e.params,Afe),r=xn(e.cols,Tfe),o=Gi(e.is_explain),n=Gi(e.is_readonly);return{params:t,cols:r,isExplain:o,isReadonly:n}}function Afe(e){return{name:Zr(e.name)}}function Tfe(e){let t=Tr(e.name),r=Zr(e.decltype);return{name:t,decltype:r}}function U4(e){let t=Tr(e.type);if(t==="null")return null;else if(t==="integer"){let r=Tr(e.value);return BigInt(r)}else if(t==="float")return Bo(e.value);else if(t==="text")return Tr(e.value);else if(t==="blob")return ll.toUint8Array(Tr(e.base64));else throw new Pe("Unexpected type of Value")}var My=v(()=>{Ty();_t();yl()});function M4(e){let t=Tr(e.type);if(t==="hello_ok")return{type:"hello_ok"};else if(t==="hello_error")return{type:"hello_error",error:es(It(e.error))};else if(t==="response_ok"){let r=Bo(e.request_id),o=Rfe(It(e.response));return{type:"response_ok",requestId:r,response:o}}else if(t==="response_error"){let r=Bo(e.request_id),o=es(It(e.error));return{type:"response_error",requestId:r,error:o}}else throw new Pe("Unexpected type of ServerMsg")}function Rfe(e){let t=Tr(e.type);if(t==="open_stream")return{type:"open_stream"};else if(t==="close_stream")return{type:"close_stream"};else if(t==="execute")return{type:"execute",result:$p(It(e.result))};else if(t==="batch")return{type:"batch",result:jy(It(e.result))};else if(t==="open_cursor")return{type:"open_cursor"};else if(t==="close_cursor")return{type:"close_cursor"};else if(t==="fetch_cursor"){let r=xn(e.entries,Zy),o=Gi(e.done);return{type:"fetch_cursor",entries:r,done:o}}else if(t==="sequence")return{type:"sequence"};else if(t==="describe")return{type:"describe",result:Uy(It(e.result))};else if(t==="store_sql")return{type:"store_sql"};else if(t==="close_sql")return{type:"close_sql"};else if(t==="get_autocommit")return{type:"get_autocommit",isAutocommit:Gi(e.is_autocommit)};else throw new Pe("Unexpected type of Response")}var q4=v(()=>{_t();yl();My()});var sn,ts,F4,K4,_l,$fe,Ofe,qy,Cfe,Pfe,zfe,El,Nfe,Dfe,Lfe;var Fy=v(()=>{sn={default(){return{message:"",code:void 0}},1(e,t){t.message=e.string()},2(e,t){t.code=e.string()}},ts={default(){return{cols:[],rows:[],affectedRowCount:0,lastInsertRowid:void 0}},1(e,t){t.cols.push(e.message(F4))},2(e,t){t.rows.push(e.message(K4))},3(e,t){t.affectedRowCount=Number(e.uint64())},4(e,t){t.lastInsertRowid=e.sint64()}},F4={default(){return{name:void 0,decltype:void 0}},1(e,t){t.name=e.string()},2(e,t){t.decltype=e.string()}},K4={default(){return[]},1(e,t){t.push(e.message(Lfe))}},_l={default(){return{stepResults:new Map,stepErrors:new Map}},1(e,t){let[r,o]=e.message($fe);t.stepResults.set(r,o)},2(e,t){let[r,o]=e.message(Ofe);t.stepErrors.set(r,o)}},$fe={default(){return[0,ts.default()]},1(e,t){t[0]=e.uint32()},2(e,t){t[1]=e.message(ts)}},Ofe={default(){return[0,sn.default()]},1(e,t){t[0]=e.uint32()},2(e,t){t[1]=e.message(sn)}},qy={default(){return{type:"none"}},1(e){return e.message(Cfe)},2(e){return e.message(Pfe)},3(e){return e.message(zfe)},4(e){return{type:"row",row:e.message(K4)}},5(e){return{type:"error",error:e.message(sn)}}},Cfe={default(){return{type:"step_begin",step:0,cols:[]}},1(e,t){t.step=e.uint32()},2(e,t){t.cols.push(e.message(F4))}},Pfe={default(){return{type:"step_end",affectedRowCount:0,lastInsertRowid:void 0}},1(e,t){t.affectedRowCount=e.uint32()},2(e,t){t.lastInsertRowid=e.uint64()}},zfe={default(){return{type:"step_error",step:0,error:sn.default()}},1(e,t){t.step=e.uint32()},2(e,t){t.error=e.message(sn)}},El={default(){return{params:[],cols:[],isExplain:!1,isReadonly:!1}},1(e,t){t.params.push(e.message(Nfe))},2(e,t){t.cols.push(e.message(Dfe))},3(e,t){t.isExplain=e.bool()},4(e,t){t.isReadonly=e.bool()}},Nfe={default(){return{name:void 0}},1(e,t){t.name=e.string()}},Dfe={default(){return{name:"",decltype:void 0}},1(e,t){t.name=e.string()},2(e,t){t.decltype=e.string()}},Lfe={default(){return},1(e){return null},2(e){return e.sint64()},3(e){return e.double()},4(e){return e.string()},5(e){return e.bytes()}}});var H4,Bfe,jfe,Zfe,Ufe,Mfe,qfe,Ffe,Kfe;var J4=v(()=>{Fy();H4={default(){return{type:"none"}},1(e){return{type:"hello_ok"}},2(e){return e.message(Bfe)},3(e){return e.message(Zfe)},4(e){return e.message(jfe)}},Bfe={default(){return{type:"hello_error",error:sn.default()}},1(e,t){t.error=e.message(sn)}},jfe={default(){return{type:"response_error",requestId:0,error:sn.default()}},1(e,t){t.requestId=e.int32()},2(e,t){t.error=e.message(sn)}},Zfe={default(){return{type:"response_ok",requestId:0,response:{type:"none"}}},1(e,t){t.requestId=e.int32()},2(e,t){t.response={type:"open_stream"}},3(e,t){t.response={type:"close_stream"}},4(e,t){t.response=e.message(Ufe)},5(e,t){t.response=e.message(Mfe)},6(e,t){t.response={type:"open_cursor"}},7(e,t){t.response={type:"close_cursor"}},8(e,t){t.response=e.message(qfe)},9(e,t){t.response={type:"sequence"}},10(e,t){t.response=e.message(Ffe)},11(e,t){t.response={type:"store_sql"}},12(e,t){t.response={type:"close_sql"}},13(e,t){t.response=e.message(Kfe)}},Ufe={default(){return{type:"execute",result:ts.default()}},1(e,t){t.result=e.message(ts)}},Mfe={default(){return{type:"batch",result:_l.default()}},1(e,t){t.result=e.message(_l)}},qfe={default(){return{type:"fetch_cursor",entries:[],done:!1}},1(e,t){t.entries.push(e.message(qy))},2(e,t){t.done=e.bool()}},Ffe={default(){return{type:"describe",result:El.default()}},1(e,t){t.result=e.message(El)}},Kfe={default(){return{type:"get_autocommit",isAutocommit:!1}},1(e,t){t.isAutocommit=e.bool()}}});var V4,gR,Ky;var Hy=v(()=>{oR();_t();iR();_p();Sl();on();dR();z4();j4();q4();J4();V4=new Map([["hrana2",{version:2,encoding:"json"}],["hrana1",{version:1,encoding:"json"}]]),gR=new Map([["hrana3-protobuf",{version:3,encoding:"protobuf"}],["hrana3",{version:3,encoding:"json"}],["hrana2",{version:2,encoding:"json"}],["hrana1",{version:1,encoding:"json"}]]);Ky=class Ky extends ml{#e;#t;#r;#n;#o;#i;#a;#s;#c;_streamIdAlloc;_cursorIdAlloc;#l;constructor(e,t){super();this.#e=e,this.#t=[],this.#r=!1,this.#n=void 0,this.#o=!1,this.#i=void 0,this.#a=!1,this.#s=new Map,this.#c=new Yi,this._streamIdAlloc=new Yi,this._cursorIdAlloc=new Yi,this.#l=new Yi,this.#e.binaryType="arraybuffer",this.#e.addEventListener("open",()=>this.#p()),this.#e.addEventListener("close",(r)=>this.#g(r)),this.#e.addEventListener("error",(r)=>this.#f(r)),this.#e.addEventListener("message",(r)=>this.#y(r)),this.#d({type:"hello",jwt:t})}#d(e){if(this.#n!==void 0)throw new or("Trying to send a message on a closed client");if(this.#r)this.#m(e);else{let t=()=>this.#m(e),r=()=>{return};this.#t.push({openCallback:t,errorCallback:r})}}#p(){let e=this.#e.protocol;if(e===void 0){this.#u(new Ge("The `WebSocket.protocol` property is undefined. This most likely means that the WebSocket implementation provided by the environment is broken. If you are using Miniflare 2, please update to Miniflare 3, which fixes this problem."));return}else if(e==="")this.#i={version:1,encoding:"json"};else if(this.#i=gR.get(e),this.#i===void 0){this.#u(new Pe(`Unrecognized WebSocket subprotocol: ${JSON.stringify(e)}`));return}for(let t of this.#t)t.openCallback();this.#t.length=0,this.#r=!0}#m(e){let t=this.#i.encoding;if(t==="json"){let r=Sp(e,P4);this.#e.send(r)}else if(t==="protobuf"){let r=xp(e,B4);this.#e.send(r)}else throw He(t,"Impossible encoding")}getVersion(){return new Promise((e,t)=>{if(this.#a=!0,this.#n!==void 0)t(this.#n);else if(!this.#r){let r=()=>e(this.#i.version);this.#t.push({openCallback:r,errorCallback:t})}else e(this.#i.version)})}_ensureVersion(e,t){if(this.#i===void 0||!this.#a)throw new wn(`${t} is supported only on protocol version ${e} and higher, but the version supported by the WebSocket server is not yet known. Use Client.getVersion() to wait until the version is available.`);else if(this.#i.version<e)throw new wn(`${t} is supported on protocol version ${e} and higher, but the WebSocket server only supports version ${this.#i.version}`)}_sendRequest(e,t){if(this.#n!==void 0){t.errorCallback(new xt("Client is closed",this.#n));return}let r=this.#c.alloc();this.#s.set(r,{...t,type:e.type}),this.#d({type:"request",requestId:r,request:e})}#f(e){let r=e.message??"WebSocket was closed due to an error";this.#u(new hl(r))}#g(e){let t=`WebSocket was closed with code ${e.code}`;if(e.reason)t+=`: ${e.reason}`;this.#u(new hl(t))}#u(e){if(this.#n!==void 0)return;this.#n=e;for(let t of this.#t)t.errorCallback(e);this.#t.length=0;for(let[t,r]of this.#s.entries())r.errorCallback(e),this.#c.free(t);this.#s.clear(),this.#e.close()}#y(e){if(this.#n!==void 0)return;try{let t,r=this.#i.encoding;if(r==="json"){if(typeof e.data!=="string"){this.#e.close(3003,"Only text messages are accepted with JSON encoding"),this.#u(new Pe("Received non-text message from server with JSON encoding"));return}t=ua(JSON.parse(e.data),M4)}else if(r==="protobuf"){if(!(e.data instanceof ArrayBuffer)){this.#e.close(3003,"Only binary messages are accepted with Protobuf encoding"),this.#u(new Pe("Received non-binary message from server with Protobuf encoding"));return}t=Qi(new Uint8Array(e.data),H4)}else throw He(r,"Impossible encoding");this.#b(t)}catch(t){this.#e.close(3007,"Could not handle message"),this.#u(t)}}#b(e){if(e.type==="none")throw new Pe("Received an unrecognized ServerMsg");else if(e.type==="hello_ok"||e.type==="hello_error"){if(this.#o)throw new Pe("Received a duplicated hello response");if(this.#o=!0,e.type==="hello_error")throw jo(e.error);return}else if(!this.#o)throw new Pe("Received a non-hello message before a hello response");if(e.type==="response_ok"){let t=e.requestId,r=this.#s.get(t);if(this.#s.delete(t),r===void 0)throw new Pe("Received unexpected OK response");this.#c.free(t);try{if(r.type!==e.response.type)throw console.dir({responseState:r,msg:e}),new Pe("Received unexpected type of response");r.responseCallback(e.response)}catch(o){throw r.errorCallback(o),o}}else if(e.type==="response_error"){let t=e.requestId,r=this.#s.get(t);if(this.#s.delete(t),r===void 0)throw new Pe("Received unexpected error response");this.#c.free(t),r.errorCallback(jo(e.error))}else throw He(e,"Impossible ServerMsg type")}openStream(){return Ap.open(this)}storeSql(e){this._ensureVersion(2,"storeSql()");let t=this.#l.alloc(),r=new fa(this,t),o=()=>{return},n=(s)=>r._setClosed(s),i={type:"store_sql",sqlId:t,sql:e};return this._sendRequest(i,{responseCallback:o,errorCallback:n}),r}_closeSql(e){if(this.#n!==void 0)return;let t=()=>this.#l.free(e),r=(n)=>this.#u(n),o={type:"close_sql",sqlId:e};this._sendRequest(o,{responseCallback:t,errorCallback:r})}close(){this.#u(new Ge("Client was manually closed"))}get closed(){return this.#n!==void 0}}});var ma;var W4=v(()=>{if(typeof queueMicrotask<"u")ma=queueMicrotask;else{let e=Promise.resolve();ma=(t)=>{e.then(t)}}});class yR{#e;#t;#r;constructor(e){this.#e=new Uint8Array(new ArrayBuffer(e)),this.#t=0,this.#r=0}get length(){return this.#r-this.#t}data(){return this.#e.slice(this.#t,this.#r)}push(e){this.#n(e.byteLength),this.#e.set(e,this.#r),this.#r+=e.byteLength}#n(e){if(this.#r+e<=this.#e.byteLength)return;let t=this.#r-this.#t;if(t+e<=this.#e.byteLength&&2*this.#r>=this.#e.byteLength)this.#e.copyWithin(0,this.#t,this.#r);else{let r=this.#e.byteLength;do r*=2;while(t+e>r);let o=new Uint8Array(new ArrayBuffer(r));o.set(this.#e.slice(this.#t,this.#r),0),this.#e=o}this.#r=t,this.#t=0}shift(e){this.#t+=e}}function G4(e){let t=Zr(e.baton),r=Zr(e.base_url),o=xn(e.results,Hfe);return{baton:t,baseUrl:r,results:o}}function Hfe(e){let t=Tr(e.type);if(t==="ok")return{type:"ok",response:Jfe(It(e.response))};else if(t==="error")return{type:"error",error:es(It(e.error))};else throw new Pe("Unexpected type of StreamResult")}function Jfe(e){let t=Tr(e.type);if(t==="close")return{type:"close"};else if(t==="execute")return{type:"execute",result:$p(It(e.result))};else if(t==="batch")return{type:"batch",result:jy(It(e.result))};else if(t==="sequence")return{type:"sequence"};else if(t==="describe")return{type:"describe",result:Uy(It(e.result))};else if(t==="store_sql")return{type:"store_sql"};else if(t==="close_sql")return{type:"close_sql"};else if(t==="get_autocommit")return{type:"get_autocommit",isAutocommit:Gi(e.is_autocommit)};else throw new Pe("Unexpected type of StreamResponse")}function Q4(e){let t=Zr(e.baton),r=Zr(e.base_url);return{baton:t,baseUrl:r}}var bR=v(()=>{_t();yl();My()});var Y4,Vfe,Wfe,Gfe,Qfe,Yfe,Xfe,X4;var SR=v(()=>{Fy();Y4={default(){return{baton:void 0,baseUrl:void 0,results:[]}},1(e,t){t.baton=e.string()},2(e,t){t.baseUrl=e.string()},3(e,t){t.results.push(e.message(Vfe))}},Vfe={default(){return{type:"none"}},1(e){return{type:"ok",response:e.message(Wfe)}},2(e){return{type:"error",error:e.message(sn)}}},Wfe={default(){return{type:"none"}},1(e){return{type:"close"}},2(e){return e.message(Gfe)},3(e){return e.message(Qfe)},4(e){return{type:"sequence"}},5(e){return e.message(Yfe)},6(e){return{type:"store_sql"}},7(e){return{type:"close_sql"}},8(e){return e.message(Xfe)}},Gfe={default(){return{type:"execute",result:ts.default()}},1(e,t){t.result=e.message(ts)}},Qfe={default(){return{type:"batch",result:_l.default()}},1(e,t){t.result=e.message(_l)}},Yfe={default(){return{type:"describe",result:El.default()}},1(e,t){t.result=e.message(El)}},Xfe={default(){return{type:"get_autocommit",isAutocommit:!1}},1(e,t){t.isAutocommit=e.bool()}},X4={default(){return{baton:void 0,baseUrl:void 0}},1(e,t){t.baton=e.string()},2(e,t){t.baseUrl=e.string()}}});var vR;var eF=v(()=>{yl();rR();_t();on();bR();SR();My();Fy();vR=class vR extends Ip{#e;#t;#r;#n;#o;#i;constructor(e,t){super();this.#e=e,this.#t=t,this.#r=void 0,this.#n=new yR(16384),this.#o=void 0,this.#i=!1}async open(e){if(e.body===null)throw new Pe("No response body for cursor request");this.#r=e.body[Symbol.asyncIterator]();let t=await this.#a(Q4,X4);if(t===void 0)throw new Pe("Empty response to cursor request");return t}next(){return this.#a(Zy,qy)}close(){this._setClosed(new Ge("Cursor was manually closed"))}_setClosed(e){if(this.#o!==void 0)return;if(this.#o=e,this.#e._cursorClosed(this),this.#r!==void 0)this.#r.return()}get closed(){return this.#o!==void 0}async#a(e,t){for(;;){if(this.#i)return;else if(this.#o!==void 0)throw new xt("Cursor is closed",this.#o);if(this.#t==="json"){let n=this.#s();if(n!==void 0){let i=new TextDecoder().decode(n),s=JSON.parse(i);return ua(s,e)}}else if(this.#t==="protobuf"){let n=this.#c();if(n!==void 0)return Qi(n,t)}else throw He(this.#t,"Impossible encoding");if(this.#r===void 0)throw new or("Attempted to read from HTTP cursor before it was opened");let{value:r,done:o}=await this.#r.next();if(o&&this.#n.length===0)this.#i=!0;else if(o)throw new Pe("Unexpected end of cursor stream");else this.#n.push(r)}}#s(){let e=this.#n.data(),t=10,r=e.indexOf(10);if(r<0)return;let o=e.slice(0,r);return this.#n.shift(r+1),o}#c(){let e=this.#n.data(),t=0,r=0;for(;;){if(r>=e.byteLength)return;let n=e[r];if(t|=(n&127)<<7*r,r+=1,!(n&128))break}if(e.byteLength<r+t)return;let o=e.slice(r,r+t);return this.#n.shift(r+t),o}}});function tF(e,t){if(t.baton!==void 0)e.string("baton",t.baton);e.arrayObjects("requests",t.requests,eme)}function eme(e,t){if(e.stringRaw("type",t.type),t.type==="close");else if(t.type==="execute")e.object("stmt",t.stmt,Tp);else if(t.type==="batch")e.object("batch",t.batch,wl);else if(t.type==="sequence"){if(t.sql!==void 0)e.string("sql",t.sql);if(t.sqlId!==void 0)e.number("sql_id",t.sqlId)}else if(t.type==="describe"){if(t.sql!==void 0)e.string("sql",t.sql);if(t.sqlId!==void 0)e.number("sql_id",t.sqlId)}else if(t.type==="store_sql")e.number("sql_id",t.sqlId),e.string("sql",t.sql);else if(t.type==="close_sql")e.number("sql_id",t.sqlId);else if(t.type==="get_autocommit");else throw He(t,"Impossible type of StreamRequest")}function rF(e,t){if(t.baton!==void 0)e.string("baton",t.baton);e.object("batch",t.batch,wl)}var wR=v(()=>{fR();on()});function nF(e,t){if(t.baton!==void 0)e.string(1,t.baton);for(let r of t.requests)e.message(2,r,tme)}function tme(e,t){if(t.type==="close")e.message(1,t,rme);else if(t.type==="execute")e.message(2,t,nme);else if(t.type==="batch")e.message(3,t,ome);else if(t.type==="sequence")e.message(4,t,ime);else if(t.type==="describe")e.message(5,t,sme);else if(t.type==="store_sql")e.message(6,t,ame);else if(t.type==="close_sql")e.message(7,t,cme);else if(t.type==="get_autocommit")e.message(8,t,lme);else throw He(t,"Impossible type of StreamRequest")}function rme(e,t){}function nme(e,t){e.message(1,t.stmt,Rp)}function ome(e,t){e.message(1,t.batch,xl)}function ime(e,t){if(t.sql!==void 0)e.string(1,t.sql);if(t.sqlId!==void 0)e.int32(2,t.sqlId)}function sme(e,t){if(t.sql!==void 0)e.string(1,t.sql);if(t.sqlId!==void 0)e.int32(2,t.sqlId)}function ame(e,t){e.int32(1,t.sqlId),e.string(2,t.sql)}function cme(e,t){e.int32(1,t.sqlId)}function lme(e,t){}function oF(e,t){if(t.baton!==void 0)e.string(1,t.baton);e.message(2,t.batch,xl)}var xR=v(()=>{hR();on()});function ume(e,t){if(t.results.length!==e.length)throw new Pe("Server returned unexpected number of pipeline results");for(let r=0;r<e.length;++r){let o=t.results[r],n=e[r];if(o.type==="ok"){if(o.response.type!==n.request.type)throw new Pe("Received unexpected type of response");n.responseCallback(o.response)}else if(o.type==="error")n.errorCallback(jo(o.error));else if(o.type==="none")throw new Pe("Received unrecognized type of StreamResult");else throw He(o,"Received impossible type of StreamResult")}}async function dme(e,t){if(t==="json"){let r=await e.json();return ua(r,G4)}if(t==="protobuf"){let r=await e.arrayBuffer();return Qi(new Uint8Array(r),Y4)}throw await e.body?.cancel(),He(t,"Impossible encoding")}async function pme(e){let t=e.headers.get("content-type")??"text/plain",r=`Server returned HTTP status ${e.status}`;if(t==="application/json"){let o=await e.json();if("message"in o)return jo(o);return new la(r,e.status)}if(t==="text/plain"){let o=(await e.text()).trim();if(o!=="")r+=`: ${o}`;return new la(r,e.status)}return await e.body?.cancel(),new la(r,e.status)}var Jy;var _R=v(()=>{_t();oR();iR();W4();_p();Sl();By();on();eF();wR();xR();wR();xR();bR();SR();Jy=class Jy extends vl{#e;#t;#r;#n;#o;#i;#a;#s;#c;#l;#d;#p;#m;constructor(e,t,r,o,n){super(e.intMode);this.#e=e,this.#t=t.toString(),this.#r=r,this.#n=o,this.#o=n,this.#i=void 0,this.#a=new Xi,this.#s=!1,this.#l=!1,this.#d=!1,this.#p=void 0,this.#m=new Yi}client(){return this.#e}_sqlOwner(){return this}storeSql(e){let t=this.#m.alloc();return this.#f({type:"store_sql",sqlId:t,sql:e}).then(()=>{return},(r)=>this._setClosed(r)),new fa(this,t)}_closeSql(e){if(this.#p!==void 0)return;this.#f({type:"close_sql",sqlId:e}).then(()=>this.#m.free(e),(t)=>this._setClosed(t))}_execute(e){return this.#f({type:"execute",stmt:e}).then((t)=>t.result)}_batch(e){return this.#f({type:"batch",batch:e}).then((t)=>t.result)}_describe(e){return this.#f({type:"describe",sql:e.sql,sqlId:e.sqlId}).then((t)=>t.result)}_sequence(e){return this.#f({type:"sequence",sql:e.sql,sqlId:e.sqlId}).then((t)=>{return})}getAutocommit(){return this.#e._ensureVersion(3,"getAutocommit()"),this.#f({type:"get_autocommit"}).then((e)=>e.isAutocommit)}#f(e){return new Promise((t,r)=>{this.#g({type:"pipeline",request:e,responseCallback:t,errorCallback:r})})}_openCursor(e){return new Promise((t,r)=>{this.#g({type:"cursor",batch:e,cursorCallback:t,errorCallback:r})})}_cursorClosed(e){if(e!==this.#c)throw new or("Cursor was closed, but it was not associated with the stream");this.#c=void 0,ma(()=>this.#u())}close(){this._setClosed(new Ge("Stream was manually closed"))}closeGracefully(){this.#l=!0,ma(()=>this.#u())}get closed(){return this.#p!==void 0||this.#l}_setClosed(e){if(this.#p!==void 0)return;if(this.#p=e,this.#c!==void 0)this.#c._setClosed(e);this.#e._streamClosed(this);for(;;){let t=this.#a.shift();if(t!==void 0)t.errorCallback(e);else break}if((this.#i!==void 0||this.#s)&&!this.#d)this.#a.push({type:"pipeline",request:{type:"close"},responseCallback:()=>{return},errorCallback:()=>{return}}),this.#d=!0,ma(()=>this.#u())}#g(e){if(this.#p!==void 0)throw new xt("Stream is closed",this.#p);else if(this.#l)throw new xt("Stream is closing",void 0);else this.#a.push(e),ma(()=>this.#u())}#u(){if(this.#s||this.#c!==void 0)return;if(this.#l&&this.#a.length===0){this._setClosed(new Ge("Stream was gracefully closed"));return}let e=this.#e._endpoint;if(e===void 0){this.#e._endpointPromise.then(()=>this.#u(),(r)=>this._setClosed(r));return}let t=this.#a.shift();if(t===void 0)return;else if(t.type==="pipeline"){let r=[t];for(;;){let o=this.#a.first();if(o!==void 0&&o.type==="pipeline")r.push(o),this.#a.shift();else if(o===void 0&&this.#l&&!this.#d){r.push({type:"pipeline",request:{type:"close"},responseCallback:()=>{return},errorCallback:()=>{return}}),this.#d=!0;break}else break}this.#y(e,r)}else if(t.type==="cursor")this.#b(e,t);else throw He(t,"Impossible type of QueueEntry")}#y(e,t){this.#h(()=>this.#S(t,e),(r)=>dme(r,e.encoding),(r)=>r.baton,(r)=>r.baseUrl,(r)=>ume(t,r),(r)=>t.forEach((o)=>o.errorCallback(r)))}#b(e,t){let r=new vR(this,e.encoding);this.#c=r,this.#h(()=>this.#v(t,e),(o)=>r.open(o),(o)=>o.baton,(o)=>o.baseUrl,(o)=>t.cursorCallback(r),(o)=>t.errorCallback(o))}#h(e,t,r,o,n,i){let s;try{let a=e(),c=this.#n;s=c(a)}catch(a){s=Promise.reject(a)}this.#s=!0,s.then((a)=>{if(!a.ok)return pme(a).then((c)=>{throw c});return t(a)}).then((a)=>{this.#i=r(a),this.#t=o(a)??this.#t,n(a)}).catch((a)=>{this._setClosed(a),i(a)}).finally(()=>{this.#s=!1,this.#u()})}#S(e,t){return this.#w(new URL(t.pipelinePath,this.#t),{baton:this.#i,requests:e.map((r)=>r.request)},t.encoding,tF,nF)}#v(e,t){if(t.cursorPath===void 0)throw new wn(`Cursors are supported only on protocol version 3 and higher, but the HTTP server only supports version ${t.version}.`);return this.#w(new URL(t.cursorPath,this.#t),{baton:this.#i,batch:e.batch},t.encoding,rF,oF)}#w(e,t,r,o,n){let i,s;if(r==="json")i=Sp(t,o),s="application/json";else if(r==="protobuf")i=xp(t,n),s="application/x-protobuf";else throw He(r,"Impossible encoding");let a=new Headers;if(a.set("content-type",s),this.#r!==void 0)a.set("authorization",`Bearer ${this.#r}`);if(this.#o!==void 0)a.set("x-turso-encryption-key",this.#o);return new Request(e.toString(),{method:"POST",headers:a,body:i})}}});async function mme(e,t){let r=e;for(let o of fme){let n=new URL(o.versionPath,t),i=new Request(n.toString(),{method:"GET"}),s=await r(i);if(await s.arrayBuffer(),s.ok)return o}return ER}var fme,ER,Vy;var kR=v(()=>{_t();_R();fme=[{versionPath:"v3-protobuf",pipelinePath:"v3-protobuf/pipeline",cursorPath:"v3-protobuf/cursor",version:3,encoding:"protobuf"}],ER={versionPath:"v2",pipelinePath:"v2/pipeline",cursorPath:void 0,version:2,encoding:"json"};Vy=class Vy extends ml{#e;#t;#r;#n;#o;#i;_endpointPromise;_endpoint;constructor(e,t,r,o,n=2){super();if(this.#e=e,this.#t=t,this.#r=r??globalThis.fetch,this.#n=o,this.#o=void 0,this.#i=new Set,n==3)this._endpointPromise=mme(this.#r,this.#e),this._endpointPromise.then((i)=>this._endpoint=i,(i)=>this.#a(i));else this._endpointPromise=Promise.resolve(ER),this._endpointPromise.then((i)=>this._endpoint=i,(i)=>this.#a(i))}async getVersion(){if(this._endpoint!==void 0)return this._endpoint.version;return(await this._endpointPromise).version}_ensureVersion(e,t){if(e<=ER.version)return;else if(this._endpoint===void 0)throw new wn(`${t} is supported only on protocol version ${e} and higher, but the version supported by the HTTP server is not yet known. Use Client.getVersion() to wait until the version is available.`);else if(this._endpoint.version<e)throw new wn(`${t} is supported only on protocol version ${e} and higher, but the HTTP server only supports version ${this._endpoint.version}.`)}openStream(){if(this.#o!==void 0)throw new xt("Client is closed",this.#o);let e=new Jy(this,this.#e,this.#t,this.#r,this.#n);return this.#i.add(e),e}_streamClosed(e){this.#i.delete(e)}close(){this.#a(new Ge("Client was manually closed"))}get closed(){return this.#o!==void 0}#a(e){if(this.#o!==void 0)return;this.#o=e;for(let t of Array.from(this.#i))t._setClosed(new xt("Client was closed",e))}}});var iF=v(()=>{_t()});function IR(e,t,r=2){if(typeof Wi>"u")throw new yp("WebSockets are not supported in this environment");var o=void 0;if(r==3)o=Array.from(gR.keys());else o=Array.from(V4.keys());let n=new Wi(e,o);return new Ky(n,t)}function AR(e,t,r,o,n=2){return new Vy(e instanceof URL?e:new URL(e),t,r,o,n)}var Wy=v(()=>{tR();Hy();_t();kR();Hy();tR();lR();iF();Sl();Dy();By();kR();_R();Hy();dR();_t()});class Op{#e;#t;#r;constructor(e,t){this.#e=e,this.#t=t,this.#r=void 0}execute(e){return this.batch([e]).then((t)=>t[0])}async batch(e){let t=this._getStream();if(t.closed)throw new Ce("Cannot execute statements because the transaction is closed","TRANSACTION_CLOSED");try{let r=e.map(Zo),o;if(this.#r===void 0){this._getSqlCache().apply(r);let i=t.batch(this.#t>=3),s=i.step(),a=s.run(Ji(this.#e)),c=s;o=r.map((u)=>{let d=i.step().condition(dt.ok(c));if(this.#t>=3)d.condition(dt.not(dt.isAutocommit(i)));let p=d.query(u);return p.catch(()=>{return}),c=d,p}),this.#r=i.execute().then(()=>a).then(()=>{return});try{await this.#r}catch(u){throw this.close(),u}}else{if(this.#t<3)await this.#r;this._getSqlCache().apply(r);let i=t.batch(this.#t>=3),s=void 0;o=r.map((a)=>{let c=i.step();if(s!==void 0)c.condition(dt.ok(s));if(this.#t>=3)c.condition(dt.not(dt.isAutocommit(i)));let u=c.query(a);return u.catch(()=>{return}),s=c,u}),await i.execute()}let n=[];for(let i=0;i<o.length;i++)try{let s=await o[i];if(s===void 0)throw new Gt("Statement in a transaction was not executed, probably because the transaction has been rolled back",i,"TRANSACTION_CLOSED");n.push(Il(s))}catch(s){if(s instanceof Gt)throw s;let a=st(s);if(a instanceof Ce)throw new Gt(a.message,i,a.code,a.extendedCode,a.rawCode,a.cause instanceof Error?a.cause:void 0);throw a}return n}catch(r){throw st(r)}}async executeMultiple(e){let t=this._getStream();if(t.closed)throw new Ce("Cannot execute statements because the transaction is closed","TRANSACTION_CLOSED");try{if(this.#r===void 0){this.#r=t.run(Ji(this.#e)).then(()=>{return});try{await this.#r}catch(r){throw this.close(),r}}else await this.#r;await t.sequence(e)}catch(r){throw st(r)}}async rollback(){try{let e=this._getStream();if(e.closed)return;if(this.#r!==void 0);else return;let t=e.run("ROLLBACK").catch((r)=>{throw st(r)});e.closeGracefully(),await t}catch(e){throw st(e)}finally{this.close()}}async commit(){try{let e=this._getStream();if(e.closed)throw new Ce("Cannot commit the transaction because it is already closed","TRANSACTION_CLOSED");if(this.#r!==void 0)await this.#r;else return;let t=e.run("COMMIT").catch((r)=>{throw st(r)});e.closeGracefully(),await t}catch(e){throw st(e)}finally{this.close()}}}async function kl(e,t,r,o,n=!1){if(n)r.step().run("PRAGMA foreign_keys=off");let i=r.step(),s=i.run(Ji(e)),a=i,c=o.map((h)=>{let b=r.step().condition(dt.ok(a));if(t>=3)b.condition(dt.not(dt.isAutocommit(r)));let y=b.query(h);return a=b,y}),u=r.step().condition(dt.ok(a));if(t>=3)u.condition(dt.not(dt.isAutocommit(r)));let d=u.run("COMMIT");if(r.step().condition(dt.not(dt.ok(u))).run("ROLLBACK").catch((h)=>{return}),n)r.step().run("PRAGMA foreign_keys=on");await r.execute();let m=[];await s;for(let h=0;h<c.length;h++)try{let b=await c[h];if(b===void 0)throw new Gt("Statement in a batch was not executed, probably because the transaction has been rolled back",h,"TRANSACTION_CLOSED");m.push(Il(b))}catch(b){if(b instanceof Gt)throw b;let y=st(b);if(y instanceof Ce)throw new Gt(y.message,h,y.code,y.extendedCode,y.rawCode,y.cause instanceof Error?y.cause:void 0);throw y}return await d,m}function Zo(e){let t,r;if(Array.isArray(e))[t,r]=e;else if(typeof e==="string")t=e;else t=e.sql,r=e.args;let o=new kp(t);if(r)if(Array.isArray(r))o.bindIndexes(r);else for(let[n,i]of Object.entries(r))o.bindName(n,i);return o}function Il(e){let t=e.columnNames.map((s)=>s??""),r=e.columnDecltypes.map((s)=>s??""),o=e.rows,n=e.affectedRowCount,i=e.lastInsertRowid!==void 0?e.lastInsertRowid:void 0;return new ul(t,r,o,n,i)}function st(e){if(e instanceof Ge){let t=sF(e);return new Ce(e.message,t,void 0,void 0,e)}return e}function sF(e){if(e instanceof gp&&e.code!==void 0)return e.code;else if(e instanceof Pe)return"HRANA_PROTO_ERROR";else if(e instanceof xt)return e.cause instanceof Ge?sF(e.cause):"HRANA_CLOSED_ERROR";else if(e instanceof hl)return"HRANA_WEBSOCKET_ERROR";else if(e instanceof la)return"SERVER_ERROR";else if(e instanceof wn)return"PROTOCOL_VERSION_ERROR";else if(e instanceof or)return"INTERNAL_ERROR";else return"UNKNOWN"}var RR=v(()=>{Wy();vn();dl()});class Al{#e;#t;capacity;constructor(e,t){this.#e=e,this.#t=new aF,this.capacity=t}apply(e){if(this.capacity<=0)return;let t=new Set;for(let r of e){if(typeof r.sql!=="string")continue;let o=r.sql;if(o.length>=5000)continue;let n=this.#t.get(o);if(n===void 0){while(this.#t.size+1>this.capacity){let[i,s]=this.#t.peekLru();if(t.has(s))break;s.close(),this.#t.delete(i)}if(this.#t.size+1<=this.capacity)n=this.#e.storeSql(o),this.#t.set(o,n)}if(n!==void 0)r.sql=n,t.add(n)}}}class aF{#e;constructor(){this.#e=new Map}get(e){let t=this.#e.get(e);if(t!==void 0)this.#e.delete(e),this.#e.set(e,t);return t}set(e,t){this.#e.set(e,t)}peekLru(){for(let e of this.#e.entries())return e;return}delete(e){this.#e.delete(e)}get size(){return this.#e.size}}var $R=ge(function(JLe,lF){function hme(e){var t=0,r=[];function o(){if(t--,t<e)n()}function n(){var c=r.shift();if(a.queue=r.length,c)s(c.fn).then(c.resolve).catch(c.reject)}function i(c){return new Promise(function(u,d){r.push({fn:c,resolve:u,reject:d}),a.queue=r.length})}function s(c){t++;try{return Promise.resolve(c()).then(function(u){return o(),u},function(u){throw o(),u})}catch(u){return o(),Promise.reject(u)}}var a=function(c){if(t>=e)return i(c);else return s(c)};return a}function gme(e,t){var r=!1,o=this;return Promise.all(e.map(function(){var n=arguments;return o(function(){if(!r)return t.apply(void 0,n).catch(function(i){throw r=!0,i})})}))}function cF(e){return e.queue=0,e.map=gme,e}lF.exports=function(e){if(e)return cF(hme(e));else return cF(function(t){return t()})}});function pF(e){if(e.scheme!=="wss"&&e.scheme!=="ws")throw new Ce(`The WebSocket client supports only "libsql:", "wss:" and "ws:" URLs, got ${JSON.stringify(e.scheme+":")}. For more information, please read ${Yn}`,"URL_SCHEME_NOT_SUPPORTED");if(e.encryptionKey!==void 0)throw new Ce("Encryption key is not supported by the remote client.","ENCRYPTION_KEY_NOT_SUPPORTED");if(e.scheme==="ws"&&e.tls)throw new Ce('A "ws:" URL cannot opt into TLS by using ?tls=1',"URL_INVALID");else if(e.scheme==="wss"&&!e.tls)throw new Ce('A "wss:" URL cannot opt out of TLS by using ?tls=0',"URL_INVALID");let t=dp(e.scheme,e.authority,e.path),r;try{r=IR(t,e.authToken)}catch(o){if(o instanceof yp){let n=e.scheme==="wss"?"https":"http",i=dp(n,e.authority,e.path);throw new Ce(`This environment does not support WebSockets, please switch to the HTTP client by using a "${n}:" URL (${JSON.stringify(i)}). For more information, please read ${Yn}`,"WEBSOCKETS_NOT_SUPPORTED")}throw st(o)}return new fF(r,t,e.authToken,e.intMode,e.concurrency)}class fF{#e;#t;#r;#n;#o;closed;protocol;#i;#a;constructor(e,t,r,o,n){this.#e=t,this.#t=r,this.#r=o,this.#n=this.#c(e),this.#o=void 0,this.closed=!1,this.protocol="ws",this.#a=dF.default(n)}async limit(e){return this.#a(e)}async execute(e,t){let r;if(typeof e==="string")r={sql:e,args:t||[]};else r=e;return this.limit(async()=>{let o=await this.#s();try{let n=Zo(r);o.conn.sqlCache.apply([n]);let i=o.stream.query(n);o.stream.closeGracefully();let s=await i;return Il(s)}catch(n){throw st(n)}finally{this._closeStream(o)}})}async batch(e,t="deferred"){return this.limit(async()=>{let r=await this.#s();try{let n=e.map((u)=>{if(Array.isArray(u))return{sql:u[0],args:u[1]||[]};return u}).map(Zo),i=await r.conn.client.getVersion();r.conn.sqlCache.apply(n);let s=r.stream.batch(i>=3);return await kl(t,i,s,n)}catch(o){throw st(o)}finally{this._closeStream(r)}})}async migrate(e){return this.limit(async()=>{let t=await this.#s();try{let r=e.map(Zo),o=await t.conn.client.getVersion(),n=t.stream.batch(o>=3);return await kl("deferred",o,n,r,!0)}catch(r){throw st(r)}finally{this._closeStream(t)}})}async transaction(e="write"){return this.limit(async()=>{let t=await this.#s();try{let r=await t.conn.client.getVersion();return new mF(this,t,e,r)}catch(r){throw this._closeStream(t),st(r)}})}async executeMultiple(e){return this.limit(async()=>{let t=await this.#s();try{let r=t.stream.sequence(e);t.stream.closeGracefully(),await r}catch(r){throw st(r)}finally{this._closeStream(t)}})}sync(){throw new Ce("sync not supported in ws mode","SYNC_NOT_SUPPORTED")}async#s(){if(this.closed)throw new Ce("The client is closed","CLIENT_CLOSED");if(new Date().valueOf()-this.#n.openTime.valueOf()>yme&&this.#o===void 0){let o=this.#c();this.#o=o,o.client.getVersion().then((n)=>{if(this.#n!==o){if(this.#n.streamStates.size===0)this.#n.client.close()}this.#n=o,this.#o=void 0},(n)=>{this.#o=void 0})}if(this.#n.client.closed)try{if(this.#o!==void 0)this.#n=this.#o;else this.#n=this.#c()}catch(o){throw st(o)}let r=this.#n;try{if(r.useSqlCache===void 0){if(r.useSqlCache=await r.client.getVersion()>=2,r.useSqlCache)r.sqlCache.capacity=uF}let o=r.client.openStream();o.intMode=this.#r;let n={conn:r,stream:o};return r.streamStates.add(n),n}catch(o){throw st(o)}}#c(e){try{return e??=IR(this.#e,this.#t),{client:e,useSqlCache:void 0,sqlCache:new Al(e,0),openTime:new Date,streamStates:new Set}}catch(t){throw st(t)}}async reconnect(){try{for(let r of Array.from(this.#n.streamStates))try{r.stream.close()}catch{}this.#n.client.close()}catch{}if(this.#o){try{this.#o.client.close()}catch{}this.#o=void 0}let e=this.#c(),t=await e.client.getVersion();if(e.useSqlCache=t>=2,e.useSqlCache)e.sqlCache.capacity=uF;this.#n=e,this.closed=!1}_closeStream(e){e.stream.close();let t=e.conn;if(t.streamStates.delete(e),t.streamStates.size===0&&t!==this.#n)t.client.close()}close(){if(this.#n.client.close(),this.closed=!0,this.#o){try{this.#o.client.close()}catch{}this.#o=void 0}this.closed=!0}}var dF,yme=60000,uF=100,mF;var hF=v(()=>{Wy();vn();mp();RR();ky();dl();dF=ql($R(),1);vn();mF=class mF extends Op{#e;#t;constructor(e,t,r,o){super(r,o);this.#e=e,this.#t=t}_getStream(){return this.#t.stream}_getSqlCache(){return this.#t.conn.sqlCache}close(){this.#e._closeStream(this.#t)}get closed(){return this.#t.stream.closed}}});function yF(e){if(e.scheme!=="https"&&e.scheme!=="http")throw new Ce(`The HTTP client supports only "libsql:", "https:" and "http:" URLs, got ${JSON.stringify(e.scheme+":")}. For more information, please read ${Yn}`,"URL_SCHEME_NOT_SUPPORTED");if(e.encryptionKey!==void 0)throw new Ce("Encryption key is not supported by the remote client.","ENCRYPTION_KEY_NOT_SUPPORTED");if(e.scheme==="http"&&e.tls)throw new Ce('A "http:" URL cannot opt into TLS by using ?tls=1',"URL_INVALID");else if(e.scheme==="https"&&!e.tls)throw new Ce('A "https:" URL cannot opt out of TLS by using ?tls=0',"URL_INVALID");let t=dp(e.scheme,e.authority,e.path);return new SF(t,e.authToken,e.intMode,e.fetch,e.concurrency,e.remoteEncryptionKey)}class SF{#e;protocol;#t;#r;#n;#o;#i;#a;#s;constructor(e,t,r,o,n,i){this.#t=e,this.#i=t,this.#r=r,this.#n=o,this.#o=n,this.#a=i,this.#e=AR(this.#t,this.#i,this.#n,i),this.#e.intMode=this.#r,this.protocol="http",this.#s=gF.default(this.#o)}async limit(e){return this.#s(e)}async execute(e,t){let r;if(typeof e==="string")r={sql:e,args:t||[]};else r=e;return this.limit(async()=>{try{let o=Zo(r),n,i=this.#e.openStream();try{n=i.query(o)}finally{i.closeGracefully()}let s=await n;return Il(s)}catch(o){throw st(o)}})}async batch(e,t="deferred"){return this.limit(async()=>{try{let o=e.map((c)=>{if(Array.isArray(c))return{sql:c[0],args:c[1]||[]};return c}).map(Zo),n=await this.#e.getVersion(),i,s=this.#e.openStream();try{new Al(s,bF).apply(o);let u=s.batch(!1);i=kl(t,n,u,o)}finally{s.closeGracefully()}return await i}catch(r){throw st(r)}})}async migrate(e){return this.limit(async()=>{try{let t=e.map(Zo),r=await this.#e.getVersion(),o,n=this.#e.openStream();try{let s=n.batch(!1);o=kl("deferred",r,s,t,!0)}finally{n.closeGracefully()}return await o}catch(t){throw st(t)}})}async transaction(e="write"){return this.limit(async()=>{try{let t=await this.#e.getVersion();return new vF(this.#e.openStream(),e,t)}catch(t){throw st(t)}})}async executeMultiple(e){return this.limit(async()=>{try{let t,r=this.#e.openStream();try{t=r.sequence(e)}finally{r.closeGracefully()}await t}catch(t){throw st(t)}})}sync(){throw new Ce("sync not supported in http mode","SYNC_NOT_SUPPORTED")}close(){this.#e.close()}async reconnect(){try{if(!this.closed)this.#e.close()}finally{this.#e=AR(this.#t,this.#i,this.#n,this.#a),this.#e.intMode=this.#r}}get closed(){return this.#e.closed}}var gF,bF=30,vF;var wF=v(()=>{Wy();vn();mp();RR();ky();dl();gF=ql($R(),1);vn();vF=class vF extends Op{#e;#t;constructor(e,t,r){super(t,r);this.#e=e,this.#t=new Al(e,bF)}_getStream(){return this.#e}_getSqlCache(){return this.#t}close(){this.#e.close()}get closed(){return this.#e.closed}}});function Tl(e){return bme(fp(e,!0))}function bme(e){if(e.scheme==="wss"||e.scheme==="ws")return pF(e);else if(e.scheme==="https"||e.scheme==="http")return yF(e);else return g4(e)}var OR=v(()=>{mp();w4();hF();wF();vn()});function oe(e,t){if(!e||typeof e!=="object")return!1;if(e instanceof t)return!0;if(!Object.prototype.hasOwnProperty.call(t,F))throw Error(`Class "${t.name??"<unknown>"}" doesn't look like a Drizzle entity. If this is incorrect and the class is provided by Drizzle, please report this as a bug.`);let r=Object.getPrototypeOf(e).constructor;if(r)while(r){if(F in r&&r[F]===t[F])return!0;r=Object.getPrototypeOf(r)}return!1}var F;var $e=v(()=>{F=Symbol.for("drizzle:entityKind")});var Je;var _n=v(()=>{$e();Je=class Je{constructor(e,t){this.table=e,this.config=t,this.name=t.name,this.keyAsName=t.keyAsName,this.notNull=t.notNull,this.default=t.default,this.defaultFn=t.defaultFn,this.onUpdateFn=t.onUpdateFn,this.hasDefault=t.hasDefault,this.primary=t.primaryKey,this.isUnique=t.isUnique,this.uniqueName=t.uniqueName,this.uniqueType=t.uniqueType,this.dataType=t.dataType,this.columnType=t.columnType,this.generated=t.generated,this.generatedIdentity=t.generatedIdentity}static[F]="Column";name;keyAsName;primary;notNull;default;defaultFn;onUpdateFn;hasDefault;isUnique;uniqueName;uniqueType;dataType;columnType;enumValues=void 0;generated=void 0;generatedIdentity=void 0;config;mapFromDriverValue(e){return e}mapToDriverValue(e){return e}shouldDisableInsert(){return this.config.generated!==void 0&&this.config.generated.type!=="byDefault"}}});var Cp;var Gy=v(()=>{$e();Cp=class Cp{static[F]="ColumnBuilder";config;constructor(e,t,r){this.config={name:e,keyAsName:e==="",notNull:!1,default:void 0,hasDefault:!1,primaryKey:!1,isUnique:!1,uniqueName:void 0,uniqueType:void 0,dataType:t,columnType:r,generated:void 0}}$type(){return this}notNull(){return this.config.notNull=!0,this}default(e){return this.config.default=e,this.config.hasDefault=!0,this}$defaultFn(e){return this.config.defaultFn=e,this.config.hasDefault=!0,this}$default=this.$defaultFn;$onUpdateFn(e){return this.config.onUpdateFn=e,this.config.hasDefault=!0,this}$onUpdate=this.$onUpdateFn;primaryKey(){return this.config.primaryKey=!0,this.config.notNull=!0,this}setName(e){if(this.config.name!=="")return;this.config.name=e}}});var ir;var Rl=v(()=>{ir=Symbol.for("drizzle:Name")});var CR,xF;var _F=v(()=>{$e();Rl();CR=class CR{static[F]="PgForeignKeyBuilder";reference;_onUpdate="no action";_onDelete="no action";constructor(e,t){if(this.reference=()=>{let{name:r,columns:o,foreignColumns:n}=e();return{name:r,columns:o,foreignTable:n[0].table,foreignColumns:n}},t)this._onUpdate=t.onUpdate,this._onDelete=t.onDelete}onUpdate(e){return this._onUpdate=e===void 0?"no action":e,this}onDelete(e){return this._onDelete=e===void 0?"no action":e,this}build(e){return new xF(e,this)}};xF=class xF{constructor(e,t){this.table=e,this.reference=t.reference,this.onUpdate=t._onUpdate,this.onDelete=t._onDelete}static[F]="PgForeignKey";reference;onUpdate;onDelete;getName(){let{name:e,columns:t,foreignColumns:r}=this.reference(),o=t.map((s)=>s.name),n=r.map((s)=>s.name),i=[this.table[ir],...o,r[0].table[ir],...n];return e??`${i.join("_")}_fk`}}});function Qy(e,...t){return e(...t)}var PR=()=>{};function zR(e,t){return`${e[ir]}_${t.join("_")}_unique`}var EF,Sme,kF;var IF=v(()=>{$e();Rl();EF=class EF{constructor(e,t){this.name=t,this.columns=e}static[F]="PgUniqueConstraintBuilder";columns;nullsNotDistinctConfig=!1;nullsNotDistinct(){return this.nullsNotDistinctConfig=!0,this}build(e){return new kF(e,this.columns,this.nullsNotDistinctConfig,this.name)}};Sme=class Sme{static[F]="PgUniqueOnConstraintBuilder";name;constructor(e){this.name=e}on(...e){return new EF(e,this.name)}};kF=class kF{constructor(e,t,r,o){this.table=e,this.columns=t,this.name=o??zR(this.table,this.columns.map((n)=>n.name)),this.nullsNotDistinct=r}static[F]="PgUniqueConstraint";columns;name;nullsNotDistinct=!1;getName(){return this.name}}});function AF(e,t,r){for(let o=t;o<e.length;o++){let n=e[o];if(n==="\\"){o++;continue}if(n==='"')return[e.slice(t,o).replace(/\\/g,""),o+1];if(r)continue;if(n===","||n==="}")return[e.slice(t,o).replace(/\\/g,""),o]}return[e.slice(t).replace(/\\/g,""),e.length]}function TF(e,t=0){let r=[],o=t,n=!1;while(o<e.length){let i=e[o];if(i===","){if(n||o===t)r.push("");n=!0,o++;continue}if(n=!1,i==="\\"){o+=2;continue}if(i==='"'){let[c,u]=AF(e,o+1,!0);r.push(c),o=u;continue}if(i==="}")return[r,o+1];if(i==="{"){let[c,u]=TF(e,o+1);r.push(c),o=u;continue}let[s,a]=AF(e,o,!1);r.push(s),o=a}return[r,o]}function RF(e){let[t]=TF(e,1);return t}function NR(e){return`{${e.map((t)=>{if(Array.isArray(t))return NR(t);if(typeof t==="string")return`"${t.replace(/\\/g,"\\\\").replace(/"/g,"\\\"")}"`;return`${t}`}).join(",")}}`}var $F=()=>{};var Pp,$l,OF,vme,CF,DR;var PF=v(()=>{Gy();_n();$e();_F();PR();IF();$F();Pp=class Pp extends Cp{foreignKeyConfigs=[];static[F]="PgColumnBuilder";array(e){return new CF(this.config.name,this,e)}references(e,t={}){return this.foreignKeyConfigs.push({ref:e,actions:t}),this}unique(e,t){return this.config.isUnique=!0,this.config.uniqueName=e,this.config.uniqueType=t?.nulls,this}generatedAlwaysAs(e){return this.config.generated={as:e,type:"always",mode:"stored"},this}buildForeignKeys(e,t){return this.foreignKeyConfigs.map(({ref:r,actions:o})=>Qy((n,i)=>{let s=new CR(()=>{let a=n();return{columns:[e],foreignColumns:[a]}});if(i.onUpdate)s.onUpdate(i.onUpdate);if(i.onDelete)s.onDelete(i.onDelete);return s.build(t)},r,o))}buildExtraConfigColumn(e){return new OF(e,this.config)}};$l=class $l extends Je{constructor(e,t){if(!t.uniqueName)t.uniqueName=zR(e,[t.name]);super(e,t);this.table=e}static[F]="PgColumn"};OF=class OF extends $l{static[F]="ExtraConfigColumn";getSQLType(){return this.getSQLType()}indexConfig={order:this.config.order??"asc",nulls:this.config.nulls??"last",opClass:this.config.opClass};defaultConfig={order:"asc",nulls:"last",opClass:void 0};asc(){return this.indexConfig.order="asc",this}desc(){return this.indexConfig.order="desc",this}nullsFirst(){return this.indexConfig.nulls="first",this}nullsLast(){return this.indexConfig.nulls="last",this}op(e){return this.indexConfig.opClass=e,this}};vme=class vme{static[F]="IndexedColumn";constructor(e,t,r,o){this.name=e,this.keyAsName=t,this.type=r,this.indexConfig=o}name;keyAsName;type;indexConfig};CF=class CF extends Pp{static[F]="PgArrayBuilder";constructor(e,t,r){super(e,"array","PgArray");this.config.baseBuilder=t,this.config.size=r}build(e){let t=this.config.baseBuilder.build(e);return new DR(e,this.config,t)}};DR=class DR extends $l{constructor(e,t,r,o){super(e,t);this.baseColumn=r,this.range=o,this.size=t.size}size;static[F]="PgArray";getSQLType(){return`${this.baseColumn.getSQLType()}[${typeof this.size==="number"?this.size:""}]`}mapFromDriverValue(e){if(typeof e==="string")e=RF(e);return e.map((t)=>this.baseColumn.mapFromDriverValue(t))}mapToDriverValue(e,t=!1){let r=e.map((o)=>o===null?null:oe(this.baseColumn,DR)?this.baseColumn.mapToDriverValue(o,!0):this.baseColumn.mapToDriverValue(o));if(t)return r;return NR(r)}}});function DF(e){return!!e&&typeof e==="function"&&zF in e&&e[zF]===!0}var wme,NF,zF,xme,LF;var BF=v(()=>{$e();PF();wme=class wme extends Pp{static[F]="PgEnumObjectColumnBuilder";constructor(e,t){super(e,"string","PgEnumObjectColumn");this.config.enum=t}build(e){return new NF(e,this.config)}};NF=class NF extends $l{static[F]="PgEnumObjectColumn";enum;enumValues=this.config.enum.enumValues;constructor(e,t){super(e,t);this.enum=t.enum}getSQLType(){return this.enum.enumName}};zF=Symbol.for("drizzle:isPgEnum");xme=class xme extends Pp{static[F]="PgEnumColumnBuilder";constructor(e,t){super(e,"string","PgEnumColumn");this.config.enum=t}build(e){return new LF(e,this.config)}};LF=class LF extends $l{static[F]="PgEnumColumn";enum=this.config.enum;enumValues=this.config.enum.enumValues;constructor(e,t){super(e,t);this.enum=t.enum}getSQLType(){return this.enum.enumName}}});var pt,zp;var En=v(()=>{$e();pt=class pt{static[F]="Subquery";constructor(e,t,r,o=!1,n=[]){this._={brand:"Subquery",sql:e,selectedFields:t,alias:r,isWith:o,usedTables:n}}};zp=class zp extends pt{static[F]="WithSubquery"}});var jF="0.45.2";var ZF=()=>{};var LR,BR,UF;var MF=v(()=>{PR();ZF();UF={startActiveSpan(e,t){if(!LR)return t();if(!BR)BR=LR.trace.getTracer("drizzle-orm",jF);return Qy((r,o)=>o.startActiveSpan(e,(n)=>{try{return t(n)}catch(i){throw n.setStatus({code:r.SpanStatusCode.ERROR,message:i instanceof Error?i.message:"Unknown error"}),i}finally{n.end()}}),LR,BR)}}});var ft;var Uo=v(()=>{ft=Symbol.for("drizzle:ViewBaseConfig")});function rs(e){return e[ir]}function ha(e){return`${e[Yy]??"public"}.${e[ir]}`}var Yy,Xy,qF,jR,ZR,Np,FF,_me,he;var sr=v(()=>{$e();Rl();Yy=Symbol.for("drizzle:Schema"),Xy=Symbol.for("drizzle:Columns"),qF=Symbol.for("drizzle:ExtraConfigColumns"),jR=Symbol.for("drizzle:OriginalName"),ZR=Symbol.for("drizzle:BaseName"),Np=Symbol.for("drizzle:IsAlias"),FF=Symbol.for("drizzle:ExtraConfigBuilder"),_me=Symbol.for("drizzle:IsDrizzleTable");he=class he{static[F]="Table";static Symbol={Name:ir,Schema:Yy,OriginalName:jR,Columns:Xy,ExtraConfigColumns:qF,BaseName:ZR,IsAlias:Np,ExtraConfigBuilder:FF};[ir];[jR];[Yy];[Xy];[qF];[ZR];[Np]=!1;[_me]=!0;[FF]=void 0;constructor(e,t,r){this[ir]=this[jR]=e,this[Yy]=t,this[ZR]=r}}});function UR(e){return e!==null&&e!==void 0&&typeof e.getSQL==="function"}function kme(e){let t={sql:"",params:[]};for(let r of e)if(t.sql+=r.sql,t.params.push(...r.params),r.typings?.length){if(!t.typings)t.typings=[];t.typings.push(...r.typings)}return t}function KF(e){return typeof e==="object"&&e!==null&&"mapToDriverValue"in e&&typeof e.mapToDriverValue==="function"}function C(e,...t){let r=[];if(t.length>0||e.length>0&&e[0]!=="")r.push(new Nt(e[0]));for(let[o,n]of t.entries())r.push(n,new Nt(e[o+1]));return new _e(r)}function Dp(e,t){return e.map((r)=>{if(oe(r,ns)){if(!(r.name in t))throw Error(`No value for placeholder "${r.name}" was provided`);return t[r.name]}if(oe(r,Ur)&&oe(r.value,ns)){if(!(r.value.name in t))throw Error(`No value for placeholder "${r.value.name}" was provided`);return r.encoder.mapToDriverValue(t[r.value.name])}return r})}var Eme,Nt,_e,eb,HF,JF,oje,Ur,ns,Ime,an;var Yt=v(()=>{$e();BF();En();MF();Uo();_n();sr();Eme=class Eme{static[F]="FakePrimitiveParam"};Nt=class Nt{static[F]="StringChunk";value;constructor(e){this.value=Array.isArray(e)?e:[e]}getSQL(){return new _e([this])}};_e=class _e{constructor(e){this.queryChunks=e;for(let t of e)if(oe(t,he)){let r=t[he.Symbol.Schema];this.usedTables.push(r===void 0?t[he.Symbol.Name]:r+"."+t[he.Symbol.Name])}}static[F]="SQL";decoder=HF;shouldInlineParams=!1;usedTables=[];append(e){return this.queryChunks.push(...e.queryChunks),this}toQuery(e){return UF.startActiveSpan("drizzle.buildSQL",(t)=>{let r=this.buildQueryFromSourceParams(this.queryChunks,e);return t?.setAttributes({"drizzle.query.text":r.sql,"drizzle.query.params":JSON.stringify(r.params)}),r})}buildQueryFromSourceParams(e,t){let r=Object.assign({},t,{inlineParams:t.inlineParams||this.shouldInlineParams,paramStartIndex:t.paramStartIndex||{value:0}}),{casing:o,escapeName:n,escapeParam:i,prepareTyping:s,inlineParams:a,paramStartIndex:c}=r;return kme(e.map((u)=>{if(oe(u,Nt))return{sql:u.value.join(""),params:[]};if(oe(u,eb))return{sql:n(u.value),params:[]};if(u===void 0)return{sql:"",params:[]};if(Array.isArray(u)){let d=[new Nt("(")];for(let[p,m]of u.entries())if(d.push(m),p<u.length-1)d.push(new Nt(", "));return d.push(new Nt(")")),this.buildQueryFromSourceParams(d,r)}if(oe(u,_e))return this.buildQueryFromSourceParams(u.queryChunks,{...r,inlineParams:a||u.shouldInlineParams});if(oe(u,he)){let d=u[he.Symbol.Schema],p=u[he.Symbol.Name];return{sql:d===void 0||u[Np]?n(p):n(d)+"."+n(p),params:[]}}if(oe(u,Je)){let d=o.getColumnCasing(u);if(t.invokeSource==="indexes")return{sql:n(d),params:[]};let p=u.table[he.Symbol.Schema];return{sql:u.table[Np]||p===void 0?n(u.table[he.Symbol.Name])+"."+n(d):n(p)+"."+n(u.table[he.Symbol.Name])+"."+n(d),params:[]}}if(oe(u,an)){let d=u[ft].schema,p=u[ft].name;return{sql:d===void 0||u[ft].isAlias?n(p):n(d)+"."+n(p),params:[]}}if(oe(u,Ur)){if(oe(u.value,ns))return{sql:i(c.value++,u),params:[u],typings:["none"]};let d=u.value===null?null:u.encoder.mapToDriverValue(u.value);if(oe(d,_e))return this.buildQueryFromSourceParams([d],r);if(a)return{sql:this.mapInlineParam(d,r),params:[]};let p=["none"];if(s)p=[s(u.encoder)];return{sql:i(c.value++,d),params:[d],typings:p}}if(oe(u,ns))return{sql:i(c.value++,u),params:[u],typings:["none"]};if(oe(u,_e.Aliased)&&u.fieldAlias!==void 0)return{sql:n(u.fieldAlias),params:[]};if(oe(u,pt)){if(u._.isWith)return{sql:n(u._.alias),params:[]};return this.buildQueryFromSourceParams([new Nt("("),u._.sql,new Nt(") "),new eb(u._.alias)],r)}if(DF(u)){if(u.schema)return{sql:n(u.schema)+"."+n(u.enumName),params:[]};return{sql:n(u.enumName),params:[]}}if(UR(u)){if(u.shouldOmitSQLParens?.())return this.buildQueryFromSourceParams([u.getSQL()],r);return this.buildQueryFromSourceParams([new Nt("("),u.getSQL(),new Nt(")")],r)}if(a)return{sql:this.mapInlineParam(u,r),params:[]};return{sql:i(c.value++,u),params:[u],typings:["none"]}}))}mapInlineParam(e,{escapeString:t}){if(e===null)return"null";if(typeof e==="number"||typeof e==="boolean")return e.toString();if(typeof e==="string")return t(e);if(typeof e==="object"){let r=e.toString();if(r==="[object Object]")return t(JSON.stringify(e));return t(r)}throw Error("Unexpected param value: "+e)}getSQL(){return this}as(e){if(e===void 0)return this;return new _e.Aliased(this,e)}mapWith(e){return this.decoder=typeof e==="function"?{mapFromDriverValue:e}:e,this}inlineParams(){return this.shouldInlineParams=!0,this}if(e){return e?this:void 0}};eb=class eb{constructor(e){this.value=e}static[F]="Name";brand;getSQL(){return new _e([this])}};HF={mapFromDriverValue:(e)=>e},JF={mapToDriverValue:(e)=>e},oje={...HF,...JF};Ur=class Ur{constructor(e,t=JF){this.value=e,this.encoder=t}static[F]="Param";brand;getSQL(){return new _e([this])}};((e)=>{function t(){return new _e([])}e.empty=t;function r(c){return new _e(c)}e.fromList=r;function o(c){return new _e([new Nt(c)])}e.raw=o;function n(c,u){let d=[];for(let[p,m]of c.entries()){if(p>0&&u!==void 0)d.push(u);d.push(m)}return new _e(d)}e.join=n;function i(c){return new eb(c)}e.identifier=i;function s(c){return new ns(c)}e.placeholder=s;function a(c,u){return new Ur(c,u)}e.param=a})(C||(C={}));((e)=>{class t{constructor(r,o){this.sql=r,this.fieldAlias=o}static[F]="SQL.Aliased";isSelectionField=!1;getSQL(){return this.sql}clone(){return new t(this.sql,this.fieldAlias)}}e.Aliased=t})(_e||(_e={}));ns=class ns{constructor(e){this.name=e}static[F]="Placeholder";getSQL(){return new _e([this])}};Ime=Symbol.for("drizzle:IsDrizzleView");an=class an{static[F]="View";[ft];[Ime]=!0;constructor({name:e,schema:t,selectedFields:r,query:o}){this[ft]={name:e,originalName:e,schema:t,selectedFields:r,query:o,isExisting:!o,isAlias:!1}}getSQL(){return new _e([this])}};Je.prototype.getSQL=function(){return new _e([this])};he.prototype.getSQL=function(){return new _e([this])};pt.prototype.getSQL=function(){return new _e([this])}});function MR(e,t,r){let o={},n=e.reduce((i,{path:s,field:a},c)=>{let u;if(oe(a,Je))u=a;else if(oe(a,_e))u=a.decoder;else if(oe(a,pt))u=a._.sql.decoder;else u=a.sql.decoder;let d=i;for(let[p,m]of s.entries())if(p<s.length-1){if(!(m in d))d[m]={};d=d[m]}else{let h=t[c],b=d[m]=h===null?null:u.mapFromDriverValue(h);if(r&&oe(a,Je)&&s.length===2){let y=s[0];if(!(y in o))o[y]=b===null?rs(a.table):!1;else if(typeof o[y]==="string"&&o[y]!==rs(a.table))o[y]=!1}}return i},{});if(r&&Object.keys(o).length>0){for(let[i,s]of Object.entries(o))if(typeof s==="string"&&!r[s])n[i]=null}return n}function cn(e,t){return Object.entries(e).reduce((r,[o,n])=>{if(typeof o!=="string")return r;let i=t?[...t,o]:[o];if(oe(n,Je)||oe(n,_e)||oe(n,_e.Aliased)||oe(n,pt))r.push({path:i,field:n});else if(oe(n,he))r.push(...cn(n[he.Symbol.Columns],i));else r.push(...cn(n,i));return r},[])}function Lp(e,t){let r=Object.keys(e),o=Object.keys(t);if(r.length!==o.length)return!1;for(let[n,i]of r.entries())if(i!==o[n])return!1;return!0}function tb(e,t){let r=Object.entries(t).filter(([,o])=>o!==void 0).map(([o,n])=>{if(oe(n,_e)||oe(n,Je))return[o,n];else return[o,new Ur(n,e[he.Symbol.Columns][o])]});if(r.length===0)throw Error("No values to set");return Object.fromEntries(r)}function VF(e,t){for(let r of t)for(let o of Object.getOwnPropertyNames(r.prototype)){if(o==="constructor")continue;Object.defineProperty(e.prototype,o,Object.getOwnPropertyDescriptor(r.prototype,o)||Object.create(null))}}function rb(e){return e[he.Symbol.Columns]}function Bp(e){return oe(e,pt)?e._.alias:oe(e,an)?e[ft].name:oe(e,_e)?void 0:e[he.Symbol.IsAlias]?e[he.Symbol.Name]:e[he.Symbol.BaseName]}function ro(e,t){return{name:typeof e==="string"&&e.length>0?e:"",config:typeof e==="object"?e:t}}function WF(e){if(typeof e!=="object"||e===null)return!1;if(e.constructor.name!=="Object")return!1;if("logger"in e){let t=typeof e.logger;if(t!=="boolean"&&(t!=="object"||typeof e.logger.logQuery!=="function")&&t!=="undefined")return!1;return!0}if("schema"in e){let t=typeof e.schema;if(t!=="object"&&t!=="undefined")return!1;return!0}if("casing"in e){let t=typeof e.casing;if(t!=="string"&&t!=="undefined")return!1;return!0}if("mode"in e){if(e.mode!=="default"||e.mode!=="planetscale"||e.mode!==void 0)return!1;return!0}if("connection"in e){let t=typeof e.connection;if(t!=="string"&&t!=="object"&&t!=="undefined")return!1;return!0}if("client"in e){let t=typeof e.client;if(t!=="object"&&t!=="function"&&t!=="undefined")return!1;return!0}if(Object.keys(e).length===0)return!0;return!1}var qR;var Sr=v(()=>{_n();$e();Yt();En();sr();Uo();qR=typeof TextDecoder>"u"?null:new TextDecoder});var GF,FR,KR;var nb=v(()=>{$e();GF=class GF{static[F]="ConsoleLogWriter";write(e){console.log(e)}};FR=class FR{static[F]="DefaultLogger";writer;constructor(e){this.writer=e?.writer??new GF}logQuery(e,t){let r=t.map((n)=>{try{return JSON.stringify(n)}catch{return String(n)}}),o=r.length?` -- params: [${r.join(", ")}]`:"";this.writer.write(`Query: ${e}${o}`)}};KR=class KR{static[F]="NoopLogger";logQuery(){}}});var QF,YF,HR;var XF=v(()=>{$e();sr();QF=Symbol.for("drizzle:PgInlineForeignKeys"),YF=Symbol.for("drizzle:EnableRLS");HR=class HR extends he{static[F]="PgTable";static Symbol=Object.assign({},he.Symbol,{InlineForeignKeys:QF,EnableRLS:YF});[QF]=[];[YF]=!1;[he.Symbol.ExtraConfigBuilder]=void 0;[he.Symbol.ExtraConfigColumns]={}}});var JR,e3;var t3=v(()=>{$e();XF();JR=class JR{static[F]="PgPrimaryKeyBuilder";columns;name;constructor(e,t){this.columns=e,this.name=t}build(e){return new e3(e,this.columns,this.name)}};e3=class e3{constructor(e,t,r){this.table=e,this.columns=t,this.name=r}static[F]="PgPrimaryKey";columns;name;getName(){return this.name??`${this.table[HR.Symbol.Name]}_${this.columns.map((e)=>e.name).join("_")}_pk`}}});function Rr(e,t){if(KF(t)&&!UR(e)&&!oe(e,Ur)&&!oe(e,ns)&&!oe(e,Je)&&!oe(e,he)&&!oe(e,an))return new Ur(e,t);return e}function tt(...e){let t=e.filter((r)=>r!==void 0);if(t.length===0)return;if(t.length===1)return new _e(t);return new _e([new Nt("("),C.join(t,new Nt(" and ")),new Nt(")")])}function ln(...e){let t=e.filter((r)=>r!==void 0);if(t.length===0)return;if(t.length===1)return new _e(t);return new _e([new Nt("("),C.join(t,new Nt(" or ")),new Nt(")")])}function n3(e){return C`not ${e}`}function is(e,t){if(Array.isArray(t)){if(t.length===0)return C`false`;return C`${e} in ${t.map((r)=>Rr(r,e))}`}return C`${e} in ${Rr(t,e)}`}function ob(e,t){if(Array.isArray(t)){if(t.length===0)return C`true`;return C`${e} not in ${t.map((r)=>Rr(r,e))}`}return C`${e} not in ${Rr(t,e)}`}function Mr(e){return C`${e} is null`}function s3(e){return C`${e} is not null`}function ib(e){return C`exists ${e}`}function ss(e){return C`not exists ${e}`}function a3(e,t,r){return C`${e} between ${Rr(t,e)} and ${Rr(r,e)}`}function c3(e,t,r){return C`${e} not between ${Rr(t,e)} and ${Rr(r,e)}`}function l3(e,t){return C`${e} like ${t}`}function u3(e,t){return C`${e} not like ${t}`}function d3(e,t){return C`${e} ilike ${t}`}function p3(e,t){return C`${e} not ilike ${t}`}var je=(e,t)=>C`${e} = ${Rr(t,e)}`,r3=(e,t)=>C`${e} <> ${Rr(t,e)}`,kn=(e,t)=>C`${e} > ${Rr(t,e)}`,o3=(e,t)=>C`${e} >= ${Rr(t,e)}`,i3=(e,t)=>C`${e} < ${Rr(t,e)}`,os=(e,t)=>C`${e} <= ${Rr(t,e)}`;var f3=v(()=>{_n();$e();sr();Yt()});function Mo(e){return C`${e} asc`}function ga(e){return C`${e} desc`}var m3=v(()=>{Yt()});var VR=v(()=>{f3();m3()});function g3(){return{and:tt,between:a3,eq:je,exists:ib,gt:kn,gte:o3,ilike:d3,inArray:is,isNull:Mr,isNotNull:s3,like:l3,lt:i3,lte:os,ne:r3,not:n3,notBetween:c3,notExists:ss,notLike:u3,notIlike:p3,notInArray:ob,or:ln,sql:C}}function y3(){return{sql:C,asc:Mo,desc:ga}}function b3(e,t){if(Object.keys(e).length===1&&"default"in e&&!oe(e.default,he))e=e.default;let r={},o={},n={};for(let[i,s]of Object.entries(e))if(oe(s,he)){let a=ha(s),c=o[a];r[a]=i,n[i]={tsName:i,dbName:s[he.Symbol.Name],schema:s[he.Symbol.Schema],columns:s[he.Symbol.Columns],relations:c?.relations??{},primaryKey:c?.primaryKey??[]};for(let d of Object.values(s[he.Symbol.Columns]))if(d.primary)n[i].primaryKey.push(d);let u=s[he.Symbol.ExtraConfigBuilder]?.(s[he.Symbol.ExtraConfigColumns]);if(u){for(let d of Object.values(u))if(oe(d,JR))n[i].primaryKey.push(...d.columns)}}else if(oe(s,h3)){let a=ha(s.table),c=r[a],u=s.config(t(s.table)),d;for(let[p,m]of Object.entries(u))if(c){let h=n[c];if(h.relations[p]=m,d)h.primaryKey.push(...d)}else{if(!(a in o))o[a]={relations:{},primaryKey:d};o[a].relations[p]=m}}return{tables:n,tableNamesMap:r}}function Ame(e){return function(r,o){return new as(e,r,o,o?.fields.reduce((n,i)=>n&&i.notNull,!0)??!1)}}function Tme(e){return function(r,o){return new jp(e,r,o)}}function S3(e,t,r){if(oe(r,as)&&r.config)return{fields:r.config.fields,references:r.config.references};let o=t[ha(r.referencedTable)];if(!o)throw Error(`Table "${r.referencedTable[he.Symbol.Name]}" not found in schema`);let n=e[o];if(!n)throw Error(`Table "${o}" not found in schema`);let i=r.sourceTable,s=t[ha(i)];if(!s)throw Error(`Table "${i[he.Symbol.Name]}" not found in schema`);let a=[];for(let c of Object.values(n.relations))if(r.relationName&&r!==c&&c.relationName===r.relationName||!r.relationName&&c.referencedTable===r.sourceTable)a.push(c);if(a.length>1)throw r.relationName?Error(`There are multiple relations with name "${r.relationName}" in table "${o}"`):Error(`There are multiple relations between "${o}" and "${r.sourceTable[he.Symbol.Name]}". Please specify relation name`);if(a[0]&&oe(a[0],as)&&a[0].config)return{fields:a[0].config.references,references:a[0].config.fields};throw Error(`There is not enough information to infer relation "${s}.${r.fieldName}"`)}function v3(e){return{one:Ame(e),many:Tme(e)}}function sb(e,t,r,o,n=(i)=>i){let i={};for(let[s,a]of o.entries())if(a.isJson){let c=t.relations[a.tsKey],u=r[s],d=typeof u==="string"?JSON.parse(u):u;i[a.tsKey]=oe(c,as)?d&&sb(e,e[a.relationTableTsKey],d,a.selection,n):d.map((p)=>sb(e,e[a.relationTableTsKey],p,a.selection,n))}else{let c=n(r[s]),u=a.field,d;if(oe(u,Je))d=u;else if(oe(u,_e))d=u.decoder;else d=u.sql.decoder;i[a.tsKey]=c===null?null:d.mapFromDriverValue(c)}return i}var WR,h3,as,jp;var Zp=v(()=>{sr();_n();$e();t3();VR();Yt();WR=class WR{constructor(e,t,r){this.sourceTable=e,this.referencedTable=t,this.relationName=r,this.referencedTableName=t[he.Symbol.Name]}static[F]="Relation";referencedTableName;fieldName};h3=class h3{constructor(e,t){this.table=e,this.config=t}static[F]="Relations"};as=class as extends WR{constructor(e,t,r,o){super(e,t,r?.relationName);this.config=r,this.isNullable=o}static[F]="One";withFieldName(e){let t=new as(this.sourceTable,this.referencedTable,this.config,this.isNullable);return t.fieldName=e,t}};jp=class jp extends WR{constructor(e,t,r){super(e,t,r?.relationName);this.config=r}static[F]="Many";withFieldName(e){let t=new jp(this.sourceTable,this.referencedTable,this.config);return t.fieldName=e,t}}});function Up(e,t){return new Proxy(e,new ya(t,!1))}function no(e,t){return new Proxy(e,new Ol(new Proxy(e.table,new ya(t,!1))))}function GR(e,t){return new _e.Aliased(Mp(e.sql,t),e.fieldAlias)}function Mp(e,t){return C.join(e.queryChunks.map((r)=>{if(oe(r,Je))return no(r,t);if(oe(r,_e))return Mp(r,t);if(oe(r,_e.Aliased))return GR(r,t);return r}))}var Ol,ya,Rme;var qp=v(()=>{_n();$e();Yt();sr();Uo();Ol=class Ol{constructor(e){this.table=e}static[F]="ColumnAliasProxyHandler";get(e,t){if(t==="table")return this.table;return e[t]}};ya=class ya{constructor(e,t){this.alias=e,this.replaceOriginalName=t}static[F]="TableAliasProxyHandler";get(e,t){if(t===he.Symbol.IsAlias)return!0;if(t===he.Symbol.Name)return this.alias;if(this.replaceOriginalName&&t===he.Symbol.OriginalName)return this.alias;if(t===ft)return{...e[ft],name:this.alias,isAlias:!0};if(t===he.Symbol.Columns){let o=e[he.Symbol.Columns];if(!o)return o;let n={};return Object.keys(o).map((i)=>{n[i]=new Proxy(o[i],new Ol(new Proxy(e,this)))}),n}let r=e[t];if(oe(r,Je))return new Proxy(r,new Ol(new Proxy(e,this)));return r}};Rme=class Rme{constructor(e){this.alias=e}static[F]="RelationTableAliasProxyHandler";get(e,t){if(t==="sourceTable")return Up(e.sourceTable,this.alias);return e[t]}}});var at;var ba=v(()=>{qp();_n();$e();Yt();En();Uo();at=class at{static[F]="SelectionProxyHandler";config;constructor(e){this.config={...e}}get(e,t){if(t==="_")return{...e._,selectedFields:new Proxy(e._.selectedFields,this)};if(t===ft)return{...e[ft],selectedFields:new Proxy(e[ft].selectedFields,this)};if(typeof t==="symbol")return e[t];let o=(oe(e,pt)?e._.selectedFields:oe(e,an)?e[ft].selectedFields:e)[t];if(oe(o,_e.Aliased)){if(this.config.sqlAliasedBehavior==="sql"&&!o.isSelectionField)return o.sql;let n=o.clone();return n.isSelectionField=!0,n}if(oe(o,_e)){if(this.config.sqlBehavior==="sql")return o;throw Error(`You tried to reference "${t}" field from a subquery, which is a raw SQL field, but it doesn't have an alias declared. Please add an alias to the field using ".as('alias')" method.`)}if(oe(o,Je)){if(this.config.alias)return new Proxy(o,new Ol(new Proxy(o.table,new ya(this.config.alias,this.config.replaceOriginalName??!1))));return o}if(typeof o!=="object"||o===null)return o;return new Proxy(o,new at(this.config))}}});var vr;var qo=v(()=>{$e();vr=class vr{static[F]="QueryPromise";[Symbol.toStringTag]="QueryPromise";catch(e){return this.then(void 0,e)}finally(e){return this.then((t)=>(e?.(),t),(t)=>{throw e?.(),t})}then(e,t){return this.execute().then(e,t)}}});var QR,w3;var YR=v(()=>{$e();Rl();QR=class QR{static[F]="SQLiteForeignKeyBuilder";reference;_onUpdate;_onDelete;constructor(e,t){if(this.reference=()=>{let{name:r,columns:o,foreignColumns:n}=e();return{name:r,columns:o,foreignTable:n[0].table,foreignColumns:n}},t)this._onUpdate=t.onUpdate,this._onDelete=t.onDelete}onUpdate(e){return this._onUpdate=e,this}onDelete(e){return this._onDelete=e,this}build(e){return new w3(e,this)}};w3=class w3{constructor(e,t){this.table=e,this.reference=t.reference,this.onUpdate=t._onUpdate,this.onDelete=t._onDelete}static[F]="SQLiteForeignKey";reference;onUpdate;onDelete;getName(){let{name:e,columns:t,foreignColumns:r}=this.reference(),o=t.map((s)=>s.name),n=r.map((s)=>s.name),i=[this.table[ir],...o,r[0].table[ir],...n];return e??`${i.join("_")}_fk`}}});function XR(e,t){return`${e[ir]}_${t.join("_")}_unique`}var x3,$me,_3;var e$=v(()=>{$e();Rl();x3=class x3{constructor(e,t){this.name=t,this.columns=e}static[F]="SQLiteUniqueConstraintBuilder";columns;build(e){return new _3(e,this.columns,this.name)}};$me=class $me{static[F]="SQLiteUniqueOnConstraintBuilder";name;constructor(e){this.name=e}on(...e){return new x3(e,this.name)}};_3=class _3{constructor(e,t,r){this.table=e,this.columns=t,this.name=r??XR(this.table,this.columns.map((o)=>o.name))}static[F]="SQLiteUniqueConstraint";columns;name;getName(){return this.name}}});var Ut,bt;var cs=v(()=>{Gy();_n();$e();YR();e$();Ut=class Ut extends Cp{static[F]="SQLiteColumnBuilder";foreignKeyConfigs=[];references(e,t={}){return this.foreignKeyConfigs.push({ref:e,actions:t}),this}unique(e){return this.config.isUnique=!0,this.config.uniqueName=e,this}generatedAlwaysAs(e,t){return this.config.generated={as:e,type:"always",mode:t?.mode??"virtual"},this}buildForeignKeys(e,t){return this.foreignKeyConfigs.map(({ref:r,actions:o})=>((n,i)=>{let s=new QR(()=>{let a=n();return{columns:[e],foreignColumns:[a]}});if(i.onUpdate)s.onUpdate(i.onUpdate);if(i.onDelete)s.onDelete(i.onDelete);return s.build(t)})(r,o))}};bt=class bt extends Je{constructor(e,t){if(!t.uniqueName)t.uniqueName=XR(e,[t.name]);super(e,t);this.table=e}static[F]="SQLiteColumn"}});function $3(e,t){let{name:r,config:o}=ro(e,t);if(o?.mode==="json")return new I3(r);if(o?.mode==="bigint")return new E3(r);return new T3(r)}var E3,k3,I3,A3,T3,R3;var t$=v(()=>{$e();Sr();cs();E3=class E3 extends Ut{static[F]="SQLiteBigIntBuilder";constructor(e){super(e,"bigint","SQLiteBigInt")}build(e){return new k3(e,this.config)}};k3=class k3 extends bt{static[F]="SQLiteBigInt";getSQLType(){return"blob"}mapFromDriverValue(e){if(typeof Buffer<"u"&&Buffer.from){let t=Buffer.isBuffer(e)?e:e instanceof ArrayBuffer?Buffer.from(e):e.buffer?Buffer.from(e.buffer,e.byteOffset,e.byteLength):Buffer.from(e);return BigInt(t.toString("utf8"))}return BigInt(qR.decode(e))}mapToDriverValue(e){return Buffer.from(e.toString())}};I3=class I3 extends Ut{static[F]="SQLiteBlobJsonBuilder";constructor(e){super(e,"json","SQLiteBlobJson")}build(e){return new A3(e,this.config)}};A3=class A3 extends bt{static[F]="SQLiteBlobJson";getSQLType(){return"blob"}mapFromDriverValue(e){if(typeof Buffer<"u"&&Buffer.from){let t=Buffer.isBuffer(e)?e:e instanceof ArrayBuffer?Buffer.from(e):e.buffer?Buffer.from(e.buffer,e.byteOffset,e.byteLength):Buffer.from(e);return JSON.parse(t.toString("utf8"))}return JSON.parse(qR.decode(e))}mapToDriverValue(e){return Buffer.from(JSON.stringify(e))}};T3=class T3 extends Ut{static[F]="SQLiteBlobBufferBuilder";constructor(e){super(e,"buffer","SQLiteBlobBuffer")}build(e){return new R3(e,this.config)}};R3=class R3 extends bt{static[F]="SQLiteBlobBuffer";mapFromDriverValue(e){if(Buffer.isBuffer(e))return e;return Buffer.from(e)}getSQLType(){return"blob"}}});function P3(e){return(t,r)=>{let{name:o,config:n}=ro(t,r);return new O3(o,n,e)}}var O3,C3;var r$=v(()=>{$e();Sr();cs();O3=class O3 extends Ut{static[F]="SQLiteCustomColumnBuilder";constructor(e,t,r){super(e,"custom","SQLiteCustomColumn");this.config.fieldConfig=t,this.config.customTypeParams=r}build(e){return new C3(e,this.config)}};C3=class C3 extends bt{static[F]="SQLiteCustomColumn";sqlName;mapTo;mapFrom;constructor(e,t){super(e,t);this.sqlName=t.customTypeParams.dataType(t.fieldConfig),this.mapTo=t.customTypeParams.toDriver,this.mapFrom=t.customTypeParams.fromDriver}getSQLType(){return this.sqlName}mapFromDriverValue(e){return typeof this.mapFrom==="function"?this.mapFrom(e):e}mapToDriverValue(e){return typeof this.mapTo==="function"?this.mapTo(e):e}}});function ar(e,t){let{name:r,config:o}=ro(e,t);if(o?.mode==="timestamp"||o?.mode==="timestamp_ms")return new D3(r,o.mode);if(o?.mode==="boolean")return new B3(r,o.mode);return new z3(r)}var ab,cb,z3,N3,D3,L3,B3,j3;var n$=v(()=>{$e();Yt();Sr();cs();ab=class ab extends Ut{static[F]="SQLiteBaseIntegerBuilder";constructor(e,t,r){super(e,t,r);this.config.autoIncrement=!1}primaryKey(e){if(e?.autoIncrement)this.config.autoIncrement=!0;return this.config.hasDefault=!0,super.primaryKey()}};cb=class cb extends bt{static[F]="SQLiteBaseInteger";autoIncrement=this.config.autoIncrement;getSQLType(){return"integer"}};z3=class z3 extends ab{static[F]="SQLiteIntegerBuilder";constructor(e){super(e,"number","SQLiteInteger")}build(e){return new N3(e,this.config)}};N3=class N3 extends cb{static[F]="SQLiteInteger"};D3=class D3 extends ab{static[F]="SQLiteTimestampBuilder";constructor(e,t){super(e,"date","SQLiteTimestamp");this.config.mode=t}defaultNow(){return this.default(C`(cast((julianday('now') - 2440587.5)*86400000 as integer))`)}build(e){return new L3(e,this.config)}};L3=class L3 extends cb{static[F]="SQLiteTimestamp";mode=this.config.mode;mapFromDriverValue(e){if(this.config.mode==="timestamp")return new Date(e*1000);return new Date(e)}mapToDriverValue(e){let t=e.getTime();if(this.config.mode==="timestamp")return Math.floor(t/1000);return t}};B3=class B3 extends ab{static[F]="SQLiteBooleanBuilder";constructor(e,t){super(e,"boolean","SQLiteBoolean");this.config.mode=t}build(e){return new j3(e,this.config)}};j3=class j3 extends cb{static[F]="SQLiteBoolean";mode=this.config.mode;mapFromDriverValue(e){return Number(e)===1}mapToDriverValue(e){return e?1:0}}});function H3(e,t){let{name:r,config:o}=ro(e,t),n=o?.mode;return n==="number"?new M3(r):n==="bigint"?new F3(r):new Z3(r)}var Z3,U3,M3,q3,F3,K3;var o$=v(()=>{$e();Sr();cs();Z3=class Z3 extends Ut{static[F]="SQLiteNumericBuilder";constructor(e){super(e,"string","SQLiteNumeric")}build(e){return new U3(e,this.config)}};U3=class U3 extends bt{static[F]="SQLiteNumeric";mapFromDriverValue(e){if(typeof e==="string")return e;return String(e)}getSQLType(){return"numeric"}};M3=class M3 extends Ut{static[F]="SQLiteNumericNumberBuilder";constructor(e){super(e,"number","SQLiteNumericNumber")}build(e){return new q3(e,this.config)}};q3=class q3 extends bt{static[F]="SQLiteNumericNumber";mapFromDriverValue(e){if(typeof e==="number")return e;return Number(e)}mapToDriverValue=String;getSQLType(){return"numeric"}};F3=class F3 extends Ut{static[F]="SQLiteNumericBigIntBuilder";constructor(e){super(e,"bigint","SQLiteNumericBigInt")}build(e){return new K3(e,this.config)}};K3=class K3 extends bt{static[F]="SQLiteNumericBigInt";mapFromDriverValue=BigInt;mapToDriverValue=String;getSQLType(){return"numeric"}}});function W3(e){return new J3(e??"")}var J3,V3;var i$=v(()=>{$e();cs();J3=class J3 extends Ut{static[F]="SQLiteRealBuilder";constructor(e){super(e,"number","SQLiteReal")}build(e){return new V3(e,this.config)}};V3=class V3 extends bt{static[F]="SQLiteReal";getSQLType(){return"real"}}});function mt(e,t={}){let{name:r,config:o}=ro(e,t);if(o.mode==="json")return new Y3(r);return new G3(r,o)}var G3,Q3,Y3,X3;var s$=v(()=>{$e();Sr();cs();G3=class G3 extends Ut{static[F]="SQLiteTextBuilder";constructor(e,t){super(e,"string","SQLiteText");this.config.enumValues=t.enum,this.config.length=t.length}build(e){return new Q3(e,this.config)}};Q3=class Q3 extends bt{static[F]="SQLiteText";enumValues=this.config.enumValues;length=this.config.length;constructor(e,t){super(e,t)}getSQLType(){return`text${this.config.length?`(${this.config.length})`:""}`}};Y3=class Y3 extends Ut{static[F]="SQLiteTextJsonBuilder";constructor(e){super(e,"json","SQLiteTextJson")}build(e){return new X3(e,this.config)}};X3=class X3 extends bt{static[F]="SQLiteTextJson";getSQLType(){return"text"}mapFromDriverValue(e){return JSON.parse(e)}mapToDriverValue(e){return JSON.stringify(e)}}});function e5(){return{blob:$3,customType:P3,integer:ar,numeric:H3,real:W3,text:mt}}var t5=v(()=>{t$();r$();n$();o$();i$();s$()});function Ome(e,t,r,o,n=e){let i=new At(e,o,n),s=typeof t==="function"?t(e5()):t,a=Object.fromEntries(Object.entries(s).map(([u,d])=>{let p=d;p.setName(u);let m=p.build(i);return i[a$].push(...p.buildForeignKeys(m,i)),[u,m]})),c=Object.assign(i,a);if(c[he.Symbol.Columns]=a,c[he.Symbol.ExtraConfigColumns]=a,r)c[At.Symbol.ExtraConfigBuilder]=r;return c}var a$,At,Fp=(e,t,r)=>Ome(e,t,r);var Fo=v(()=>{$e();sr();t5();a$=Symbol.for("drizzle:SQLiteInlineForeignKeys");At=class At extends he{static[F]="SQLiteTable";static Symbol=Object.assign({},he.Symbol,{InlineForeignKeys:a$});[he.Symbol.Columns];[a$]=[];[he.Symbol.ExtraConfigBuilder]=void 0}});var Cme,r5;var n5=v(()=>{$e();Cme=class Cme{constructor(e,t){this.name=e,this.value=t}static[F]="SQLiteCheckBuilder";brand;build(e){return new r5(e,this)}};r5=class r5{constructor(e,t){this.table=e,this.name=t.name,this.value=t.value}static[F]="SQLiteCheck";name;value}});function Ko(e){return new o5(e,!1)}var o5,i5,s5;var a5=v(()=>{$e();o5=class o5{constructor(e,t){this.name=e,this.unique=t}static[F]="SQLiteIndexBuilderOn";on(...e){return new i5(this.name,e,this.unique)}};i5=class i5{static[F]="SQLiteIndexBuilder";config;constructor(e,t,r){this.config={name:e,columns:t,unique:r,where:void 0}}where(e){return this.config.where=e,this}build(e){return new s5(this.config,e)}};s5=class s5{static[F]="SQLiteIndex";config;constructor(e,t){this.config={...e,table:t}}}});var Pme,c5;var l5=v(()=>{$e();Fo();Pme=class Pme{static[F]="SQLitePrimaryKeyBuilder";columns;name;constructor(e,t){this.columns=e,this.name=t}build(e){return new c5(e,this.columns,this.name)}};c5=class c5{constructor(e,t,r){this.table=e,this.columns=t,this.name=r}static[F]="SQLitePrimaryKey";columns;name;getName(){return this.name??`${this.table[At.Symbol.Name]}_${this.columns.map((e)=>e.name).join("_")}_pk`}}});function In(e){if(oe(e,At))return[`${e[he.Symbol.BaseName]}`];if(oe(e,pt))return e._.usedTables??[];if(oe(e,_e))return e.usedTables??[];return[]}var Cl=v(()=>{$e();Yt();En();sr();Fo()});var lb;var u5=v(()=>{$e();qo();ba();Fo();sr();Sr();Cl();lb=class lb extends vr{constructor(e,t,r,o){super();this.table=e,this.session=t,this.dialect=r,this.config={table:e,withList:o}}static[F]="SQLiteDelete";config;where(e){return this.config.where=e,this}orderBy(...e){if(typeof e[0]==="function"){let t=e[0](new Proxy(this.config.table[he.Symbol.Columns],new at({sqlAliasedBehavior:"alias",sqlBehavior:"sql"}))),r=Array.isArray(t)?t:[t];this.config.orderBy=r}else{let t=e;this.config.orderBy=t}return this}limit(e){return this.config.limit=e,this}returning(e=this.table[At.Symbol.Columns]){return this.config.returning=cn(e),this}getSQL(){return this.dialect.buildDeleteQuery(this.config)}toSQL(){let{typings:e,...t}=this.dialect.sqlToQuery(this.getSQL());return t}_prepare(e=!0){return this.session[e?"prepareOneTimeQuery":"prepareQuery"](this.dialect.sqlToQuery(this.getSQL()),this.config.returning,this.config.returning?"all":"run",!0,void 0,{type:"delete",tables:In(this.config.table)})}prepare(){return this._prepare(!1)}run=(e)=>this._prepare().run(e);all=(e)=>this._prepare().all(e);get=(e)=>this._prepare().get(e);values=(e)=>this._prepare().values(e);async execute(e){return this._prepare().execute(e)}$dynamic(){return this}}});function zme(e){return(e.replace(/['\u2019]/g,"").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).map((r)=>r.toLowerCase()).join("_")}function Nme(e){return(e.replace(/['\u2019]/g,"").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).reduce((r,o,n)=>{let i=n===0?o.toLowerCase():`${o[0].toUpperCase()}${o.slice(1)}`;return r+i},"")}function Dme(e){return e}var c$;var d5=v(()=>{$e();sr();c$=class c${static[F]="CasingCache";cache={};cachedTables={};convert;constructor(e){this.convert=e==="snake_case"?zme:e==="camelCase"?Nme:Dme}getColumnCasing(e){if(!e.keyAsName)return e.name;let t=e.table[he.Symbol.Schema]??"public",r=e.table[he.Symbol.OriginalName],o=`${t}.${r}.${e.name}`;if(!this.cache[o])this.cacheTable(e.table);return this.cache[o]}cacheTable(e){let t=e[he.Symbol.Schema]??"public",r=e[he.Symbol.OriginalName],o=`${t}.${r}`;if(!this.cachedTables[o]){for(let n of Object.values(e[he.Symbol.Columns])){let i=`${o}.${n.name}`;this.cache[i]=this.convert(n.name)}this.cachedTables[o]=!0}}clearCache(){this.cache={},this.cachedTables={}}}});var Pl,Ho,l$;var ub=v(()=>{$e();Pl=class Pl extends Error{static[F]="DrizzleError";constructor({message:e,cause:t}){super(e);this.name="DrizzleError",this.cause=t}};Ho=class Ho extends Error{constructor(e,t,r){super(`Failed query: ${e}
|
|
419
|
+
`;TT(e,i,"utf8")}function el(e){let t=e.split(/\r?\n/).map((r)=>r.trim()).find((r)=>r.startsWith("AGE-SECRET-KEY-"));if(!t)throw Error("Missing AGE-SECRET-KEY in age identity file");return t}function Ile(e,t){return["# generated by brains-ops age-key:bootstrap",`# public key: ${t}`,e,""].join(`
|
|
420
|
+
`)}var fy=v(()=>{Ui();np();jn()});function gM(e){return Object.keys(e)}import{readFileSync as sp}from"fs";import{access as wue,rm as xue,writeFile as wM}from"fs/promises";import{join as CT,relative as yM}from"path";async function PT(e,t,r={}){let{registry:o,user:n}=await xh(e,t),i=r.env??process.env,s=r.logger??console.log,a=Or(e),c=CT(e,"users",`${t}.secrets.yaml.age`),u=CT(e,"users",`${t}.secrets.yaml`),d=vM(yM(e,c)),p=vM(yM(e,u)),m=kue(u),h=await Iue(c,e,i,a),b=await _M(u),y={sharedOpenaiApiKeySelector:o.pilot.openaiApiKey,sharedGitSyncTokenSelector:o.pilot.gitSyncToken,effectiveOpenaiApiKeySelector:n.effectiveOpenaiApiKey,effectiveGitSyncTokenSelector:n.effectiveGitSyncToken,discordEnabled:n.discordEnabled},S;try{S=_ue(e,i,a,m,h,y)}catch(z){if(!r.dryRun&&m===void 0&&z instanceof Error){let H=Tue(y);if(H.length>0)throw await Rue(u,H),Error(`Missing required secrets for ${t}. Created ${p}; fill it in and rerun secrets:encrypt. ${z.message}`,{cause:z})}throw z}let x=`${Ra(S).trimEnd()}
|
|
421
|
+
`;Aue(x,S);let _=gM(S);if(r.dryRun){if(s(`Dry run: would encrypt ${_.length} secrets to ${d}.`),s(_.length>0?`Keys: ${_.join(", ")}`:"Keys: (none \u2014 shared defaults only)"),b)s(`Would remove plaintext file ${p}.`);return{encryptedPath:d,plaintextPath:p,deletedPlaintext:b,encryptedKeys:_,dryRun:!0}}let A=new tp;A.addRecipient(o.pilot.agePublicKey);let O=await A.encrypt(x),L=Mi.encode(O);if(await wM(c,L),await xue(u,{force:!0}),s(`Encrypted ${_.length} secrets to ${d}.`),b)s(`Removed plaintext file ${p}.`);return{encryptedPath:d,plaintextPath:p,deletedPlaintext:b,encryptedKeys:_}}function _ue(e,t,r,o,n,i){let s=bM(e,t,r,o,n,"openaiApiKey",i.effectiveOpenaiApiKeySelector,i.sharedOpenaiApiKeySelector),a=bM(e,t,r,o,n,"gitSyncToken",i.effectiveGitSyncTokenSelector,i.sharedGitSyncTokenSelector),c=i.discordEnabled?my(e,t,r,o,n,"discordBotToken","DISCORD_BOT_TOKEN"):void 0,u=i.discordEnabled?my(e,t,r,o,n,"discordPublicKey","DISCORD_PUBLIC_KEY"):void 0,d=i.discordEnabled?my(e,t,r,o,n,"discordApplicationId","DISCORD_APPLICATION_ID"):void 0,p=hy(e,t,r,o,n,"atprotoAppPassword","ATPROTO_APP_PASSWORD"),m=SM(hy(e,t,r,o,n,"certificatePem","CERTIFICATE_PEM")),h=SM(hy(e,t,r,o,n,"privateKeyPem","PRIVATE_KEY_PEM"));return xM.parse({...s?{openaiApiKey:s}:{},...a?{gitSyncToken:a}:{},...c?{discordBotToken:c}:{},...u?{discordPublicKey:u}:{},...d?{discordApplicationId:d}:{},...p?{atprotoAppPassword:p}:{},...m?{certificatePem:m}:{},...h?{privateKeyPem:h}:{}})}function bM(e,t,r,o,n,i,s,a){if(s===a)return;return my(e,t,r,o,n,i,s)}function my(e,t,r,o,n,i,s){let a=hy(e,t,r,o,n,i,s);if(a===void 0||a.trim().length===0)throw Error(`Missing required secret value for ${String(i)}. Set it in users/<handle>.secrets.yaml or fall back to ${s}/${s}_FILE before running secrets:encrypt.`);return a}function SM(e){return e?.replace(/\r\n?|\n/g,"\\n")}function hy(e,t,r,o,n,i,s){return Eue(o,n,i,s,t,r,e)}function Eue(e,t,r,o,n,i,s){let a=e?.[r];if(a!==void 0&&a.trim().length>0)return a;let c=Bt(`${o}_FILE`,n,i);if(c&&c.trim().length>0)return sp(Go(c,s),"utf8");let u=Bt(o,n,i);if(u!==void 0&&u.trim().length>0)return u;let d=t?.[r];if(d!==void 0&&d.trim().length>0)return d;return}function kue(e){let t;try{t=sp(e,"utf8")}catch{return}try{return NT(t)}catch(r){throw Error(`Unable to parse plaintext secrets file ${e}: ${Ve(r)}`,{cause:r})}}async function Iue(e,t,r,o){if(!await _M(e))return;let n=zT(t,r,o);if(!n)return;let i;try{let s=sp(e,"utf8"),a=Mi.decode(s),c=new rp;c.addIdentity(n),i=await c.decrypt(a,"text")}catch{return}try{return NT(i)}catch(s){throw Error(`Unable to parse decrypted secrets from ${e}: ${Ve(s)}`,{cause:s})}}function zT(e,t,r){let o=Bt("AGE_SECRET_KEY_FILE",t,r);if(o&&o.trim().length>0)return el(sp(Go(o,e),"utf8"));let n=Bt("AGE_SECRET_KEY",t,r);if(n&&n.trim().length>0)return el(n);try{return el(sp(CT(e,".brains-ops","age","identity.txt"),"utf8"))}catch{return}}function NT(e){let t=dC(e),r={};if(t!==null&&typeof t==="object"&&!Array.isArray(t)){for(let[o,n]of Object.entries(t))if(typeof n==="string")r[o]=n}return xM.partial().parse(r)}function Aue(e,t){let r={...t},o={...NT(e)},n=new Set([...Object.keys(r),...Object.keys(o)]);for(let i of n)if(r[i]!==o[i])throw Error(`secrets:encrypt round-trip verification failed for ${i}; refusing to write a corrupted encrypted payload`)}function Tue(e){return[...e.effectiveOpenaiApiKeySelector!==e.sharedOpenaiApiKeySelector?["openaiApiKey"]:[],...e.effectiveGitSyncTokenSelector!==e.sharedGitSyncTokenSelector?["gitSyncToken"]:[],...e.discordEnabled?["discordBotToken","discordPublicKey","discordApplicationId"]:[]]}async function Rue(e,t){let r=["# local per-user secret staging file","# fill values, run `bunx brains-ops secrets:encrypt . <handle>`, then the plaintext file will be removed",...t.map((o)=>`${o}: `),""].join(`
|
|
422
|
+
`);await wM(e,r,{flag:"wx"})}async function _M(e){try{return await wue(e),!0}catch{return!1}}function vM(e){return e.replaceAll("\\","/")}var xM;var gy=v(()=>{Ui();Qo();Cn();fe();fy();Fu();xM=l.strictObject({gitSyncToken:l.string().min(1).optional(),discordBotToken:l.string().min(1).optional(),discordPublicKey:l.string().min(1).optional(),discordApplicationId:l.string().min(1).optional(),openaiApiKey:l.string().min(1).optional(),atprotoAppPassword:l.string().min(1).optional(),certificatePem:l.string().min(1).optional(),privateKeyPem:l.string().min(1).optional()})});var RM={};Lt(RM,{upgradePilotRepo:()=>ede});import{readFile as Gue}from"fs/promises";import{join as Que}from"path";async function TM(e){let t=Que(e,"package.json"),o=Yue.parse(JSON.parse(await Gue(t,"utf8"))).devDependencies?.["@rizom/ops"];if(!o)throw Error(`${t} does not pin @rizom/ops as a devDependency`);return o}async function Xue(e,t){let o=await Bun.spawn(e,{cwd:t,stdout:"inherit",stderr:"inherit"}).exited;if(o!==0)throw Error(`${e.join(" ")} failed with exit ${o}`)}async function ede(e,t={}){let r=t.exec??Xue,o=await TM(e),n=t.version??"latest";await r(["bun","add","--dev","--exact",`@rizom/ops@${n}`],e);let i=await TM(e);return await r(["bun","x","brains-ops","init","."],e),{from:o,to:i}}var Yue;var $M=v(()=>{fe();Yue=l.object({devDependencies:l.record(l.string(),l.string()).optional()})});var zM={};Lt(zM,{migratePilotDeploySecrets:()=>CM,migratePilotEnvSchema:()=>PM,migratePilotRepoProviderKeys:()=>cde,migrateProviderKeyFieldsYaml:()=>MT,openaiSelectorFor:()=>qT,renameProviderKeyFields:()=>Fi});import{readdir as tde,readFile as ZT,writeFile as OM}from"fs/promises";import{join as zo}from"path";function MT(e){let t=Wr(e,{keepSourceTokens:!0});return Fi(t)?t.toString({lineWidth:0}):e}function Fi(e){if(!mn(e.contents))return!1;return e.contents.items.filter((r)=>{if(!bo(r.key)||typeof r.key.value!=="string")return!1;let o=rde[r.key.value];if(!o)return!1;if(r.key.value==="aiApiKey"&&bo(r.value)&&r.value.value===vy)r.value.value=wy;return r.key.value=o,!0}).length>0}function qT(e){return e===vy?wy:e}function CM(e){return e.replace(new RegExp(`^(\\s+- )${vy}$`,"m"),`$1${wy}`)}function PM(e){return e.replace(new RegExp(`^${vy}=`,"m"),`${wy}=`)}async function Sy(e){try{return(await tde(e)).filter((r)=>r.endsWith(".yaml")).sort()}catch{return[]}}async function UT(e){try{return await ZT(e,"utf8")}catch{return}}async function sde(e){let t=await Sy(zo(e,"cohorts")),r=await Promise.all(t.map(async(i)=>{let s=lr(await ZT(zo(e,"cohorts",i),"utf8"),ode);return s.ok&&s.data.aiApiKeyOverride?s.data.members:[]})),o=(await Sy(zo(e,"users"))).filter((i)=>!i.endsWith(".secrets.yaml")),n=await Promise.all(o.map(async(i)=>{let s=lr(await ZT(zo(e,"users",i),"utf8"),nde);return s.ok&&s.data.aiApiKeyOverride?[i.replace(/\.yaml$/,"")]:[]}));return[...new Set([...r.flat(),...n.flat()])]}async function ade(e,t,r,o){let n=zo(e,"users",`${t}.secrets.yaml.age`),i=await UT(n);if(i===void 0)return!1;if(!r)throw Error(`users/${t}.secrets.yaml.age may hold the legacy AI key; set AGE_SECRET_KEY or AGE_SECRET_KEY_FILE to migrate it`);let s=new rp;s.addIdentity(r);let a=await s.decrypt(Mi.decode(i),"text"),c=MT(a);if(c===a)return!1;let u=new tp;return u.addRecipient(o),await OM(n,Mi.encode(await u.encrypt(c))),!0}async function cde(e,t){let r=["pilot.yaml",...(await Sy(zo(e,"cohorts"))).map((c)=>`cohorts/${c}`),...(await Sy(zo(e,"users"))).filter((c)=>!c.endsWith(".secrets.yaml")).map((c)=>`users/${c}`)],o=await sde(e),n=await Promise.all([...r.map((c)=>({file:c,migrate:MT})),{file:".env.schema",migrate:PM},{file:"deploy/kamal/deploy.yml",migrate:CM}].map(async({file:c,migrate:u})=>{let d=zo(e,c),p=await UT(d);if(p===void 0)return[];let m=u(p);if(m===p)return[];return await OM(d,m),[c]})),i=lr(await UT(zo(e,"pilot.yaml"))??"",ide),s=zT(e,t,Or(e)),a=o.length===0?[]:await Promise.all(o.map(async(c)=>{if(!i.ok)throw Error("pilot.yaml needs agePublicKey to re-encrypt secrets");return await ade(e,c,s,i.data.agePublicKey)?[`users/${c}.secrets.yaml.age`]:[]}));return[...n.flat(),...a.flat()]}var vy="AI_API_KEY",wy="OPENAI_API_KEY",rde,nde,ode,ide;var xy=v(()=>{Ui();Qo();Cn();fe();Ac();gy();rde={aiApiKey:"openaiApiKey",aiApiKeyOverride:"openaiApiKeyOverride"};nde=l.looseObject({aiApiKeyOverride:l.string().optional()}),ode=l.looseObject({members:l.array(l.string()).default([]),aiApiKeyOverride:l.string().optional()}),ide=l.looseObject({agePublicKey:l.string()})});function BM(e){if(e==="core")return{bundles:["core","media","web","chat"]};if(e==="default")return{bundles:["core","media","automation","web","chat","site","publishing","federation"],add:["obsidian-vault"],remove:[...dde]};return{bundles:["core","media","automation","web","chat","site","publishing","federation"],add:["obsidian-vault"]}}function pde(e){let t=lde.parse(e);return pi.parse({brainVersion:t.brainVersion,bundleContract:di,...BM(t.preset),githubOrg:t.githubOrg,contentRepoPrefix:t.contentRepoPrefix,domainSuffix:t.domainSuffix,openaiApiKey:qT(t.aiApiKey),gitSyncToken:t.gitSyncToken,contentRepoAdminToken:t.contentRepoAdminToken,agePublicKey:t.agePublicKey})}function fde(e){let t=ude.parse(e),r=t.presetOverride?BM(t.presetOverride):void 0;return Kr.parse({members:[...t.members],...t.brainVersionOverride?{brainVersionOverride:t.brainVersionOverride}:{},...r?{bundlesOverride:r.bundles,...r.add?{addOverride:r.add}:{},...r.remove?{removeOverride:r.remove}:{}}:{},...t.aiApiKeyOverride?{openaiApiKeyOverride:t.aiApiKeyOverride}:{},...t.gitSyncTokenOverride?{gitSyncTokenOverride:t.gitSyncTokenOverride}:{}})}function jM(e){let t=Wr(e,{keepSourceTokens:!0});if(t.errors.length>0)throw Error(`Invalid desired-state YAML: ${t.errors[0]?.message}`);if(!mn(t.contents))throw Error("Desired-state YAML must contain a mapping");return t}function FT(e,t){if(!mn(e.contents))return;return e.contents.items.find((r)=>bo(r.key)&&r.key.value===t)}function NM(e,t){if(!yo(e)||!yo(t))return;if(e.commentBefore!==void 0)t.commentBefore=e.commentBefore;if(e.comment!==void 0)t.comment=e.comment;if(e.spaceBefore!==void 0)t.spaceBefore=e.spaceBefore}function DM(e,t){if(!e||!yo(t))return;let r=[yo(e.key)?e.key.commentBefore:void 0,yo(e.key)?e.key.comment:void 0,yo(e.value)?e.value.commentBefore:void 0,yo(e.value)?e.value.comment:void 0].filter((o)=>o!==void 0);if(r.length===0)return;t.commentBefore=[t.commentBefore,...r].filter((o)=>o!==void 0).join(`
|
|
423
|
+
`)}function ZM(e,t,r,o){if(!mn(e.contents))throw Error("Desired-state YAML must contain a mapping");let n=e.contents.items.findIndex((s)=>bo(s.key)&&s.key.value===t),i=e.createPair(r,[...o]);if(n>=0){let s=e.contents.items[n];NM(s?.key,i.key),NM(s?.value,i.value),e.contents.items.splice(n,1,i)}else e.contents.add(i);return i}function UM(e){let t=jM(e),r=pde(t.toJS()),o=FT(t,"schemaVersion"),n=FT(t,"model");DM(o,FT(t,"brainVersion")?.key),t.delete("schemaVersion"),t.set("bundleContract",di);let i=ZM(t,"preset","bundles",r.bundles);if(DM(n,i.key),t.delete("model"),r.add)t.set("add",r.add);else t.delete("add");if(r.remove)t.set("remove",r.remove);else t.delete("remove");return Fi(t),pi.parse(t.toJS()),t.toString({lineWidth:0})}function MM(e){let t=jM(e),r=fde(t.toJS());if(r.bundlesOverride)ZM(t,"presetOverride","bundlesOverride",r.bundlesOverride);else t.delete("presetOverride"),t.delete("bundlesOverride");if(r.addOverride)t.set("addOverride",r.addOverride);else t.delete("addOverride");if(r.removeOverride)t.set("removeOverride",r.removeOverride);else t.delete("removeOverride");return Fi(t),Kr.parse(t.toJS()),t.toString({lineWidth:0})}var LM,ap,lde,ude,dde;var qM=v(()=>{xy();Cn();fe();Ac();Bn();LM=l.enum(["core","default","pro"]),ap=l.string().min(1),lde=l.strictObject({schemaVersion:l.literal(1),brainVersion:$t,model:l.literal("rover"),githubOrg:l.string().min(1),contentRepoPrefix:l.string().min(1),domainSuffix:l.string().min(1),preset:LM,aiApiKey:ap,gitSyncToken:ap,contentRepoAdminToken:ap,agePublicKey:l.string().startsWith("age1").min(1)}),ude=l.strictObject({members:l.array(mr).min(1),brainVersionOverride:$t.optional(),presetOverride:LM.optional(),aiApiKeyOverride:ap.optional(),gitSyncTokenOverride:ap.optional()}).superRefine((e,t)=>{if(new Set(e.members).size!==e.members.length)t.addIssue({code:l.ZodIssueCode.custom,path:["members"],message:"cohort members must be unique"})}),dde=["series","portfolio","content-pipeline","social-media","newsletter","stock-photo"]});function KM(e,t){let r=Wr(e,{keepSourceTokens:!0});if(r.errors.length>0||!mn(r.contents))throw Error(`Invalid ${t} YAML`);return r}function bde(e,t){return e.length===t.length&&e.every((r,o)=>r===t[o])}function HM(e,t,r){if(!bde(t,r.sourceBundles))throw Error(`${e} source bundles changed after review: expected [${r.sourceBundles.join(", ")}], received [${t.join(", ")}]`)}function JM(e){let t=lr(e,yde);if(!t.ok)throw Error(`Invalid capability bundle review: ${t.error}`);return t.data}function VM(e,t){let r=KM(e,"pilot desired-state"),o=hde.parse(r.toJS());return HM("pilot.yaml",o.bundles,t),r.set("bundleContract",di),r.set("bundles",t.targetBundles),Fi(r),pi.parse(r.toJS()),r.toString({lineWidth:0})}function WM(e,t,r){let o=KM(e,`cohort ${t}`),n=gde.parse(o.toJS());if(n.bundlesOverride===void 0){if(r!==void 0)throw Error(`Capability bundle review names inheriting cohort ${t}`)}else{if(r===void 0)throw Error(`Cohort ${t} has an explicit legacy bundle selection but no reviewed mapping`);HM(`cohort ${t}`,n.bundlesOverride,r),o.set("bundlesOverride",r.targetBundles)}return Fi(o),Kr.parse(o.toJS()),o.toString({lineWidth:0})}var mde,KT,_y,hde,gde,FM,yde;var GM=v(()=>{xy();Cn();fe();Ac();Bn();mde=l.enum(["core","site","publishing","team"]),KT=l.array(mde).min(1),_y=l.array(l.string().min(1)),hde=l.strictObject({brainVersion:$t,bundles:KT,add:_y.optional(),remove:_y.optional(),githubOrg:l.string().min(1),contentRepoPrefix:l.string().min(1),domainSuffix:l.string().min(1),aiApiKey:l.string().min(1),gitSyncToken:l.string().min(1),contentRepoAdminToken:l.string().min(1),agePublicKey:l.string().startsWith("age1").min(1)}),gde=l.strictObject({members:l.array(mr).min(1),brainVersionOverride:$t.optional(),bundlesOverride:KT.optional(),addOverride:_y.optional(),removeOverride:_y.optional(),aiApiKeyOverride:l.string().min(1).optional(),gitSyncTokenOverride:l.string().min(1).optional()}),FM=l.strictObject({sourceBundles:KT,targetBundles:l.array(oh).min(1)}),yde=l.strictObject({bundleContract:l.literal(di),pilot:FM,cohorts:l.record(mr,FM)})});var tq={};Lt(tq,{loadCapabilityBundleReview:()=>Ade,loadReviewedSitePins:()=>Ide,parseReviewedSitePins:()=>eq,stageLegacyCrossover:()=>Rde});import{access as Sde,cp as vde,mkdir as QM,readFile as ol,readdir as XM,writeFile as nl}from"fs/promises";import{basename as wde,join as Qn,relative as Ey,resolve as YM}from"path";import{fileURLToPath as xde}from"url";function eq(e){let t=lr(e,_de);if(!t.ok)throw Error(`Invalid reviewed site pins: ${t.error}`);return t.data.sites}async function Ide(e){return eq(await ol(e,"utf8"))}async function Ade(e){return JM(await ol(e,"utf8"))}async function Tde(e,t){let r=Qn(e,"users"),o=(await XM(r,{withFileTypes:!0})).filter((s)=>s.isFile()&&/\.ya?ml$/.test(s.name)).map((s)=>s.name).sort(),n=new Set(Object.keys(t??{})),i=[];for(let s of o){let a=Qn(r,s),c=await ol(a,"utf8"),u=Wr(c,{keepSourceTokens:!0});if(u.errors.length>0||!mn(u.contents))throw Error(`Invalid user desired-state YAML: ${s}`);let d=Ede.parse(u.toJS());if(!d.siteOverride)continue;let p=t?.[d.handle];if(!p)throw Error(`User ${d.handle} has a siteOverride but no reviewed site pin`);if(n.delete(d.handle),p.package!==d.siteOverride.package||p.theme!==d.siteOverride.theme)throw Error(`Reviewed site pin identity does not match user ${d.handle}`);if(d.siteOverride.version!==void 0&&d.siteOverride.version!==p.version)throw Error(`Reviewed site version does not match the existing pin for user ${d.handle}`);if(d.siteOverride.themeVersion!==void 0&&d.siteOverride.themeVersion!==p.themeVersion)throw Error(`Reviewed theme version does not match the existing pin for user ${d.handle}`);if(u.setIn(["siteOverride","version"],p.version),p.themeVersion!==void 0)u.setIn(["siteOverride","themeVersion"],p.themeVersion);else u.deleteIn(["siteOverride","themeVersion"]);ih.parse(u.toJS());let m=u.toString({lineWidth:0});if(m!==c)await nl(a,m),i.push(Ey(e,a))}if(n.size>0)throw Error(`Reviewed site pins do not match site users: ${[...n].sort().join(", ")}`);return i}async function Rde(e,t,r={}){let o=YM(e),n=YM(t);if(o===n||n.startsWith(`${o}/`))throw Error("Crossover output must be outside the source repository");await vde(o,n,{recursive:!0,errorOnExist:!0,force:!1,filter:(A)=>{let O=wde(A);return O!==".git"&&O!==".operator"&&O!==".brains-ops"&&O!==".turbo"&&O!=="dist"&&O!=="node_modules"&&O!==".env"&&O!==".env.local"&&!O.endsWith(".secrets.yaml")}});let i=[],s=Qn(n,"docs","canonical-crossover-record.md");try{await Sde(s)}catch{await QM(Qn(n,"docs"),{recursive:!0}),await nl(s,await ol(kde,"utf8")),i.push("docs/canonical-crossover-record.md")}let a=Qn(n,"pilot.yaml"),c=await ol(a,"utf8"),d=Wr(c).toJS();if(!ju(d))throw Error(`${a} is not a YAML mapping`);let p=Array.isArray(d.bundles),m=r.bundleReview,h;if(p){if(!m)throw Error("Current canonical desired state requires an explicit capability bundle review manifest");h=VM(c,m.pilot)}else h=UM(c);await nl(a,h),i.push("pilot.yaml");let b=Qn(n,"cohorts"),y=(await XM(b,{withFileTypes:!0})).filter((A)=>A.isFile()&&/\.ya?ml$/.test(A.name)).map((A)=>A.name).sort(),S=new Set(Object.keys(m?.cohorts??{}));for(let A of y){let O=Qn(b,A),L=await ol(O,"utf8"),z=A.replace(/\.ya?ml$/,""),H=m?.cohorts[z];if(H)S.delete(z);await nl(O,p?WM(L,z,H):MM(L)),i.push(Ey(n,O))}if(p&&S.size>0)throw Error(`Capability bundle review names unknown cohorts: ${[...S].sort().join(", ")}`);i.push(...await Tde(n,r.sitePins));let x=await ut(n),_=wh(x.pilot.githubOrg);for(let A of x.users){let O=await _(A),L=Qn(n,"users",A.handle);if(await QM(L,{recursive:!0}),O.brainYaml){let z=Qn(L,"brain.yaml");await nl(z,O.brainYaml),i.push(Ey(n,z))}if(O.envFile){let z=Qn(L,".env");await nl(z,O.envFile),i.push(Ey(n,z))}}return await po(n,{registry:x}),i.push("views/users.md"),{outputDir:n,changedFiles:[...new Set(i)].sort()}}var _de,Ede,kde;var rq=v(()=>{Cn();Zu();fe();Ac();gk();qM();GM();Hr();uc();Bn();_de=l.strictObject({sites:l.record(mr,FE)}),Ede=l.object({handle:mr,siteOverride:l.object({package:l.string().min(1),version:$t.optional(),theme:l.string().min(1).optional(),themeVersion:$t.optional()}).optional()}).passthrough(),kde=xde(new URL("../templates/rover-pilot/docs/canonical-crossover-record.md",import.meta.url))});var nq="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";import{webcrypto as oq}from"crypto";function Ode(e){if(e<0)throw RangeError("Wrong ID size");try{if(!Ki||Ki.length<e)Ki=Buffer.allocUnsafe(e*$de),oq.getRandomValues(Ki),il=0;else if(il+e>Ki.length)oq.getRandomValues(Ki),il=0}catch(t){throw Ki=void 0,t}il+=e}function iq(e=21){Ode(e|=0);let t="";for(let r=il-e;r<il;r++)t+=nq[Ki[r]&63];return t}var $de=128,Ki,il;var sq=()=>{};function No(e=12){return iq(e)}var cp=v(()=>{sq()});import{openSync as Cde,writeSync as Pde}from"fs";class Ar{static instance=null;level;context;useStderr;format;logFile;fileHandle;constructor(e={},t){if(this.level=e.level??ia.INFO,this.context=e.context??void 0,this.useStderr=e.useStderr??!1,this.format=e.format??"text",this.logFile=e.logFile,t!==void 0)this.fileHandle=t;else if(this.logFile)try{this.fileHandle=Cde(this.logFile,"a")}catch{}}static getInstance(e){if(!Ar.instance)Ar.instance=new Ar(e);else{if(e?.useStderr!==void 0)Ar.instance.useStderr=e.useStderr;if(e?.level!==void 0)Ar.instance.level=e.level}return Ar.instance}static resetInstance(){Ar.instance=null}static createFresh(e){return new Ar(e)}formatEntry(e,t,r){let o=new Date().toISOString();if(this.format==="json"){let n={ts:o,level:e,msg:t};if(this.context)n.ctx=this.context;if(r.length>0)n.data=r;return JSON.stringify(n)}return this.context?`[${o}] [${this.context}] ${t}`:`[${o}] ${t}`}write(e,t,r,o){if(this.format==="json")e(this.formatEntry(t,r,o));else if(o.length>0)e(this.formatEntry(t,r,[]),...o);else e(this.formatEntry(t,r,[]));if(this.fileHandle!==void 0){let n=this.formatJsonEntry(t,r,o);try{Pde(this.fileHandle,n+`
|
|
424
|
+
`)}catch{}}}formatJsonEntry(e,t,r){let o={ts:new Date().toISOString(),level:e,msg:t};if(this.context)o.ctx=this.context;if(r.length>0)o.data=r;return JSON.stringify(o)}silly(e,...t){if(this.level<=ia.SILLY)this.write(console.debug.bind(console),"silly",e,t)}verbose(e,...t){if(this.level<=ia.VERBOSE)this.write(console.debug.bind(console),"verbose",e,t)}debug(e,...t){if(this.level<=ia.DEBUG)this.write(console.debug.bind(console),"debug",e,t)}info(e,...t){if(this.level<=ia.INFO){let r=this.useStderr?console.error.bind(console):console.info.bind(console);this.write(r,"info",e,t)}}warn(e,...t){if(this.level<=ia.WARN)this.write(console.warn.bind(console),"warn",e,t)}error(e,...t){if(this.level<=ia.ERROR)this.write(console.error.bind(console),"error",e,t)}child(e){return new Ar({level:this.level,context:e,useStderr:this.useStderr,format:this.format},this.fileHandle)}setUseStderr(e){this.useStderr=e}}var ia,bNe;var HT=v(()=>{ia={SILLY:0,VERBOSE:1,DEBUG:2,INFO:3,WARN:4,ERROR:5,NONE:6};bNe=Ar.getInstance()});var JT,zde,sl,xNe;var lp=v(()=>{Rt();fe();JT=l.enum(["file_operations","content_operations","data_processing","batch_processing"]),zde=l.looseObject({pluginId:l.string().optional(),progressToken:l.union([l.string(),l.number()]).optional(),operationType:JT,operationTarget:l.string().optional(),interfaceType:l.string().optional(),conversationId:l.string().optional(),channelId:l.string().optional(),requestedByActor:ci.optional(),requestedByUserId:l.string().optional(),requestedByInterface:l.string().optional(),silent:l.boolean().optional(),provenance:uo.optional()}),sl=l.looseObject({pluginId:l.string().optional(),progressToken:l.union([l.string(),l.number()]).optional(),operationType:JT,operationTarget:l.string().optional(),interfaceType:l.string().optional(),conversationId:l.string().optional(),channelId:l.string().optional(),requestedByActor:ci.optional(),requestedByUserId:l.string().optional(),requestedByInterface:l.string().optional(),silent:l.boolean().optional(),provenance:uo.optional(),rootJobId:l.string()}),xNe=l.enum(["none","skip","replace","coalesce"])});var Nde,Hi=15000;var up=v(()=>{lp();fe();Nde=l.object({id:l.string(),type:l.string(),data:l.string(),status:l.enum(["pending","processing","completed","failed"]),source:l.string().nullable(),priority:l.number(),retryCount:l.number(),maxRetries:l.number(),lastError:l.string().nullable(),lastErrorPublic:l.unknown(),createdAt:l.number(),scheduledFor:l.number(),startedAt:l.number().nullable(),completedAt:l.number().nullable(),attemptId:l.string().nullable(),workerSlotId:l.string().nullable(),workerSessionId:l.string().nullable(),leaseExpiresAt:l.number().nullable(),attemptHeartbeatAt:l.number().nullable(),runtimeUpdatedAt:l.number().nullable(),metadata:sl,progress:l.custom((e)=>typeof e==="object"&&e!==null&&("progress"in e)&&typeof e.progress==="number").nullable(),result:l.unknown().nullable().optional()})});var VT,aq,Oe,Dde,Lde,cq,lq,uq;var Do=v(()=>{Rt();fe();lp();VT=l.enum(["pending","processing","completed","failed"]),aq=l.enum(["completed","failed"]),Oe={PENDING:"pending",PROCESSING:"processing",COMPLETED:"completed",FAILED:"failed"},Dde=l.object({id:l.string(),type:l.string(),status:VT,data:l.unknown(),result:l.unknown().optional(),lastError:l.string().optional().nullable(),attempts:l.number(),maxRetries:l.number(),priority:l.number(),createdAt:l.date(),updatedAt:l.date(),processedAt:l.date().optional().nullable(),completedAt:l.date().optional().nullable(),failedAt:l.date().optional().nullable()}),Lde=l.object({jobId:l.string(),type:l.string(),status:aq,result:l.unknown().optional(),error:l.string().optional()}),cq=l.object({success:l.literal(!1),error:l.string().optional()}),lq=l.object({id:l.string(),type:l.enum(["job","batch"]),status:VT,message:l.string().optional(),progress:l.object({current:l.number(),total:l.number(),percentage:l.number()}).optional(),aggregationKey:l.string().optional(),batchDetails:l.object({totalOperations:l.number(),completedOperations:l.number(),failedOperations:l.number(),currentOperation:l.string().optional(),errors:l.array(l.string()).optional()}).optional(),jobDetails:l.object({jobType:l.string(),priority:l.number(),retryCount:l.number()}).optional(),metadata:sl}),uq=ui(ZE.progress,lq)});var Ce,Gt;var vn=v(()=>{Ce=class Ce extends Error{code;extendedCode;rawCode;constructor(e,t,r,o,n){if(t!==void 0)e=`${t}: ${e}`;super(e,{cause:n});this.code=t,this.extendedCode=r,this.rawCode=o,this.name="LibsqlError"}};Gt=class Gt extends Ce{statementIndex;constructor(e,t,r,o,n,i){super(e,r,o,n,i);this.statementIndex=t,this.name="LibsqlBatchError"}}});function dq(e){let t=Bde.exec(e);if(t===null)throw new Ce(`The URL '${e}' is not in a valid format`,"URL_INVALID");let r=t.groups,o=r.scheme,n=r.authority!==void 0?jde(r.authority):void 0,i=sa(r.path),s=r.query!==void 0?Ude(r.query):void 0,a=r.fragment!==void 0?sa(r.fragment):void 0;return{scheme:o,authority:n,path:i,query:s,fragment:a}}function jde(e){let t=Zde.exec(e);if(t===null)throw new Ce("The authority part of the URL is not in a valid format","URL_INVALID");let r=t.groups,o=sa(r.host_br??r.host),n=r.port?parseInt(r.port,10):void 0,i=r.username!==void 0?{username:sa(r.username),password:r.password!==void 0?sa(r.password):void 0}:void 0;return{host:o,port:n,userinfo:i}}function Ude(e){let t=e.split("&"),r=[];for(let o of t){if(o==="")continue;let n,i,s=o.indexOf("=");if(s<0)n=o,i="";else n=o.substring(0,s),i=o.substring(s+1);r.push({key:sa(n.replaceAll("+"," ")),value:sa(i.replaceAll("+"," "))})}return{pairs:r}}function sa(e){try{return decodeURIComponent(e)}catch(t){if(t instanceof URIError)throw new Ce(`URL component has invalid percent encoding: ${t}`,"URL_INVALID",void 0,void 0,t);throw t}}function dp(e,t,r){if(t===void 0)throw new Ce(`URL with scheme ${JSON.stringify(e+":")} requires authority (the "//" part)`,"URL_INVALID");let o=`${e}:`,n=Mde(t.host),i=qde(t.port),a=`//${Fde(t.userinfo)}${n}${i}`,c=r.split("/").map(encodeURIComponent).join("/");if(c!==""&&!c.startsWith("/"))c="/"+c;return new URL(`${o}${a}${c}`)}function Mde(e){return e.includes(":")?`[${encodeURI(e)}]`:encodeURI(e)}function qde(e){return e!==void 0?`:${e}`:""}function Fde(e){if(e===void 0)return"";let t=encodeURIComponent(e.username),r=e.password!==void 0?`:${encodeURIComponent(e.password)}`:"";return`${t}${r}@`}var Bde,Zde;var ky=v(()=>{vn();Bde=(()=>new RegExp("^(?<scheme>[A-Za-z][A-Za-z.+-]*):(//(?<authority>[^/?#]*))?(?<path>[^?#]*)(\\?(?<query>[^#]*))?(#(?<fragment>.*))?$","su"))();Zde=(()=>new RegExp("^((?<username>[^:]*)(:(?<password>.*))?@)?((?<host>[^:\\[\\]]*)|(\\[(?<host_br>[^\\[\\]]*)\\]))(:(?<port>[0-9]*))?$","su"))()});var cl,pq,fq,pp,Iy,Kde,Qt,mq,yq=(e)=>e.replace(/=/g,"").replace(/[+\/]/g,(t)=>t=="+"?"-":"_"),bq=(e)=>e.replace(/[^A-Za-z0-9\+\/]/g,""),Sq=(e)=>{let t,r,o,n,i="",s=e.length%3;for(let a=0;a<e.length;){if((r=e.charCodeAt(a++))>255||(o=e.charCodeAt(a++))>255||(n=e.charCodeAt(a++))>255)throw TypeError("invalid character found");t=r<<16|o<<8|n,i+=pp[t>>18&63]+pp[t>>12&63]+pp[t>>6&63]+pp[t&63]}return s?i.slice(0,s-3)+"===".substring(s):i},QT,WT,Ay=(e,t=!1)=>t?yq(WT(e)):WT(e),Hde=(e)=>{if(e.length<2){var t=e.charCodeAt(0);return t<128?e:t<2048?Qt(192|t>>>6)+Qt(128|t&63):Qt(224|t>>>12&15)+Qt(128|t>>>6&63)+Qt(128|t&63)}else{var t=65536+(e.charCodeAt(0)-55296)*1024+(e.charCodeAt(1)-56320);return Qt(240|t>>>18&7)+Qt(128|t>>>12&63)+Qt(128|t>>>6&63)+Qt(128|t&63)}},Jde,vq=(e)=>e.replace(Jde,Hde),hq,al=(e,t=!1)=>t?yq(hq(e)):hq(e),gq=(e)=>al(e,!0),Vde,Wde=(e)=>{switch(e.length){case 4:var t=(7&e.charCodeAt(0))<<18|(63&e.charCodeAt(1))<<12|(63&e.charCodeAt(2))<<6|63&e.charCodeAt(3),r=t-65536;return Qt((r>>>10)+55296)+Qt((r&1023)+56320);case 3:return Qt((15&e.charCodeAt(0))<<12|(63&e.charCodeAt(1))<<6|63&e.charCodeAt(2));default:return Qt((31&e.charCodeAt(0))<<6|63&e.charCodeAt(1))}},wq=(e)=>e.replace(Vde,Wde),xq=(e)=>{if(e=e.replace(/\s+/g,""),!Kde.test(e))throw TypeError("malformed base64.");e+="==".slice(2-(e.length&3));let t,r,o,n=[];for(let i=0;i<e.length;)if(t=Iy[e.charAt(i++)]<<18|Iy[e.charAt(i++)]<<12|(r=Iy[e.charAt(i++)])<<6|(o=Iy[e.charAt(i++)]),r===64)n.push(Qt(t>>16&255));else if(o===64)n.push(Qt(t>>16&255,t>>8&255));else n.push(Qt(t>>16&255,t>>8&255,t&255));return n.join("")},YT,_q,Eq=(e)=>_q(kq(e)),Gde,kq=(e)=>bq(e.replace(/[-_]/g,(t)=>t=="-"?"+":"/")),GT=(e)=>Gde(kq(e)),Qde=(e)=>{if(typeof e!=="string")return!1;let t=e.replace(/\s+/g,"").replace(/={0,2}$/,"");return!/[^\s0-9a-zA-Z\+/]/.test(t)||!/[^\s0-9a-zA-Z\-_]/.test(t)},Iq=(e)=>({value:e,enumerable:!1,writable:!0,configurable:!0}),Aq=function(){let e=(t,r)=>Object.defineProperty(String.prototype,t,Iq(r));e("fromBase64",function(){return GT(this)}),e("toBase64",function(t){return al(this,t)}),e("toBase64URI",function(){return al(this,!0)}),e("toBase64URL",function(){return al(this,!0)}),e("toUint8Array",function(){return Eq(this)})},Tq=function(){let e=(t,r)=>Object.defineProperty(Uint8Array.prototype,t,Iq(r));e("toBase64",function(t){return Ay(this,t)}),e("toBase64URI",function(){return Ay(this,!0)}),e("toBase64URL",function(){return Ay(this,!0)})},Yde=()=>{Aq(),Tq()},ll;var Ty=v(()=>{cl=typeof Buffer==="function",pq=typeof TextDecoder==="function"?new TextDecoder("utf-8",{ignoreBOM:!0}):void 0,fq=typeof TextEncoder==="function"?new TextEncoder:void 0,pp=Array.prototype.slice.call("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="),Iy=((e)=>{let t={};return e.forEach((r,o)=>t[r]=o),t})(pp),Kde=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,Qt=String.fromCharCode.bind(String),mq=typeof Uint8Array.from==="function"?Uint8Array.from.bind(Uint8Array):(e)=>new Uint8Array(Array.prototype.slice.call(e,0)),QT=typeof btoa==="function"?(e)=>btoa(e):cl?(e)=>Buffer.from(e,"binary").toString("base64"):Sq,WT=cl?(e)=>Buffer.from(e).toString("base64"):(e)=>{let r=[];for(let o=0,n=e.length;o<n;o+=4096)r.push(Qt.apply(null,e.subarray(o,o+4096)));return QT(r.join(""))},Jde=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,hq=cl?(e)=>Buffer.from(e,"utf8").toString("base64"):fq?(e)=>WT(fq.encode(e)):(e)=>QT(vq(e)),Vde=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,YT=typeof atob==="function"?(e)=>atob(bq(e)):cl?(e)=>Buffer.from(e,"base64").toString("binary"):xq,_q=cl?(e)=>mq(Buffer.from(e,"base64")):(e)=>mq(YT(e).split("").map((t)=>t.charCodeAt(0))),Gde=cl?(e)=>Buffer.from(e,"base64").toString("utf8"):pq?(e)=>pq.decode(_q(e)):(e)=>wq(YT(e)),ll={version:"3.8.0",VERSION:"3.8.0",atob:YT,atobPolyfill:xq,btoa:QT,btoaPolyfill:Sq,fromBase64:GT,toBase64:al,encode:al,encodeURI:gq,encodeURL:gq,utob:vq,btou:wq,decode:GT,isValid:Qde,fromUint8Array:Ay,toUint8Array:Eq,extendString:Aq,extendUint8Array:Tq,extendBuiltins:Yde}});function Ji(e){if(e==="write")return"BEGIN IMMEDIATE";else if(e==="read")return"BEGIN TRANSACTION READONLY";else if(e==="deferred")return"BEGIN DEFERRED";else throw RangeError('Unknown transaction mode, supported values are "write", "read" and "deferred"')}class ul{columns;columnTypes;rows;rowsAffected;lastInsertRowid;constructor(e,t,r,o,n){this.columns=e,this.columnTypes=t,this.rows=r,this.rowsAffected=o,this.lastInsertRowid=n}toJSON(){return{columns:this.columns,columnTypes:this.columnTypes,rows:this.rows.map(Xde),rowsAffected:this.rowsAffected,lastInsertRowid:this.lastInsertRowid!==void 0?""+this.lastInsertRowid:null}}}function Xde(e){return Array.prototype.map.call(e,epe)}function epe(e){if(typeof e==="bigint")return""+e;else if(e instanceof ArrayBuffer)return ll.fromUint8Array(new Uint8Array(e));else return e}var Yn="https://github.com/libsql/libsql-client-ts#supported-urls";var dl=v(()=>{Ty()});function $q(e){return e.scheme==="file"&&(e.path===":memory:"||e.path.startsWith(":memory:?"))}function fp(e,t){if(typeof e!=="object")throw TypeError(`Expected client configuration as object, got ${typeof e}`);let{url:r,authToken:o,tls:n,intMode:i,concurrency:s}=e;s=Math.max(0,s||20),i??="number";let a=[];if(r===Rq)r="file::memory:";let c=dq(r),u=c.scheme.toLowerCase(),d=u==="file"&&c.path===Rq&&c.authority===void 0,p;if(d)p={cache:{values:["shared","private"],update:(y,S)=>a.push(`${y}=${S}`)}};else p={tls:{values:["0","1"],update:(y,S)=>n=S==="1"},authToken:{update:(y,S)=>o=S}};for(let{key:y,value:S}of c.query?.pairs??[]){if(!Object.hasOwn(p,y))throw new Ce(`Unsupported URL query parameter ${JSON.stringify(y)}`,"URL_PARAM_NOT_SUPPORTED");let x=p[y];if(x.values!==void 0&&!x.values.includes(S))throw new Ce(`Unknown value for the "${y}" query argument: ${JSON.stringify(S)}. Supported values are: [${x.values.map((_)=>'"'+_+'"').join(", ")}]`,"URL_INVALID");if(x.update!==void 0)x?.update(y,S)}let m=a.length===0?"":`?${a.join("&")}`,h=c.path+m,b;if(u==="libsql")if(n===!1){if(c.authority?.port===void 0)throw new Ce('A "libsql:" URL with ?tls=0 must specify an explicit port',"URL_INVALID");b=t?"http":"ws"}else b=t?"https":"wss";else b=u;if(b==="http"||b==="ws")n??=!1;else n??=!0;if(b!=="http"&&b!=="ws"&&b!=="https"&&b!=="wss"&&b!=="file")throw new Ce(`The client supports only "libsql:", "wss:", "ws:", "https:", "http:" and "file:" URLs, got ${JSON.stringify(c.scheme+":")}. For more information, please read ${Yn}`,"URL_SCHEME_NOT_SUPPORTED");if(i!=="number"&&i!=="bigint"&&i!=="string")throw TypeError(`Invalid value for intMode, expected "number", "bigint" or "string", got ${JSON.stringify(i)}`);if(c.fragment!==void 0)throw new Ce(`URL fragments are not supported: ${JSON.stringify("#"+c.fragment)}`,"URL_INVALID");if(d)return{scheme:"file",tls:!1,path:h,intMode:i,concurrency:s,syncUrl:e.syncUrl,syncInterval:e.syncInterval,readYourWrites:e.readYourWrites,offline:e.offline,fetch:e.fetch,timeout:e.timeout,authToken:void 0,encryptionKey:void 0,remoteEncryptionKey:void 0,authority:void 0};return{scheme:b,tls:n,authority:c.authority,path:h,authToken:o,intMode:i,concurrency:s,encryptionKey:e.encryptionKey,remoteEncryptionKey:e.remoteEncryptionKey,syncUrl:e.syncUrl,syncInterval:e.syncInterval,readYourWrites:e.readYourWrites,offline:e.offline,fetch:e.fetch,timeout:e.timeout}}var Rq=":memory:";var mp=v(()=>{vn();ky();dl()});var Cq=ge(function(nn){var tpe=nn&&nn.__createBinding||(Object.create?function(e,t,r,o){if(o===void 0)o=r;var n=Object.getOwnPropertyDescriptor(t,r);if(!n||("get"in n?!t.__esModule:n.writable||n.configurable))n={enumerable:!0,get:function(){return t[r]}};Object.defineProperty(e,o,n)}:function(e,t,r,o){if(o===void 0)o=r;e[o]=t[r]}),rpe=nn&&nn.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Oq=nn&&nn.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null){for(var r in e)if(r!=="default"&&Object.prototype.hasOwnProperty.call(e,r))tpe(t,e,r)}return rpe(t,e),t};Object.defineProperty(nn,"__esModule",{value:!0});nn.load=nn.currentTarget=void 0;var npe=Oq(qr("path")),ope=Oq(qr("fs"));function ipe(){let e=null;switch(process.platform){case"android":switch(process.arch){case"arm":return"android-arm-eabi";case"arm64":return"android-arm64"}e="Android";break;case"win32":switch(process.arch){case"x64":return"win32-x64-msvc";case"arm64":return"win32-arm64-msvc";case"ia32":return"win32-ia32-msvc"}e="Windows";break;case"darwin":switch(process.arch){case"x64":return"darwin-x64";case"arm64":return"darwin-arm64"}e="macOS";break;case"linux":switch(process.arch){case"x64":case"arm64":return spe()?`linux-${process.arch}-gnu`:`linux-${process.arch}-musl`;case"arm":return"linux-arm-gnueabihf"}e="Linux";break;case"freebsd":if(process.arch==="x64")return"freebsd-x64";e="FreeBSD";break}if(e)throw Error(`Neon: unsupported ${e} architecture: ${process.arch}`);throw Error(`Neon: unsupported system: ${process.platform}`)}nn.currentTarget=ipe;function spe(){let e=process.report?.getReport();if(typeof e!=="object"||!e||!("header"in e))return!1;let t=e.header;return typeof t==="object"&&!!t&&"glibcVersionRuntime"in t}function ape(e){let t=npe.join(e,"index.node");return ope.existsSync(t)?qr(t):null}nn.load=ape});var Nq=ge(function(qNe,zq){var Pq=()=>process.platform==="linux",XT=null,cpe=()=>{if(!XT)XT=Pq()&&process.report?process.report.getReport():{};return XT};zq.exports={isLinux:Pq,getReport:cpe}});var Bq=ge(function(FNe,Lq){var Dq=qr("fs"),lpe=(e)=>Dq.readFileSync(e,"utf-8"),upe=(e)=>new Promise((t,r)=>{Dq.readFile(e,"utf-8",(o,n)=>{if(o)r(o);else t(n)})});Lq.exports={LDD_PATH:"/usr/bin/ldd",readFileSync:lpe,readFile:upe}});var t4=ge(function(KNe,e4){var Zq=qr("child_process"),{isLinux:pl,getReport:Uq}=Nq(),{LDD_PATH:Ry,readFile:Mq,readFileSync:qq}=Bq(),Xn,eo,Vi="",Fq=()=>{if(!Vi)return new Promise((e)=>{Zq.exec("getconf GNU_LIBC_VERSION 2>&1 || true; ldd --version 2>&1 || true",(t,r)=>{Vi=t?" ":r,e(Vi)})});return Vi},Kq=()=>{if(!Vi)try{Vi=Zq.execSync("getconf GNU_LIBC_VERSION 2>&1 || true; ldd --version 2>&1 || true",{encoding:"utf8"})}catch(e){Vi=" "}return Vi},Lo="glibc",Hq=/GLIBC\s(\d+\.\d+)/,aa="musl",dpe=Lo.toUpperCase(),ppe=aa.toLowerCase(),fpe=(e)=>e.includes("libc.musl-")||e.includes("ld-musl-"),Jq=()=>{let e=Uq();if(e.header&&e.header.glibcVersionRuntime)return Lo;if(Array.isArray(e.sharedObjects)){if(e.sharedObjects.some(fpe))return aa}return null},Vq=(e)=>{let[t,r]=e.split(/[\r\n]+/);if(t&&t.includes(Lo))return Lo;if(r&&r.includes(aa))return aa;return null},Wq=(e)=>{if(e.includes(ppe))return aa;if(e.includes(dpe))return Lo;return null},mpe=async()=>{if(Xn!==void 0)return Xn;Xn=null;try{let e=await Mq(Ry);Xn=Wq(e)}catch(e){}return Xn},hpe=()=>{if(Xn!==void 0)return Xn;Xn=null;try{let e=qq(Ry);Xn=Wq(e)}catch(e){}return Xn},Gq=async()=>{let e=null;if(pl()){if(e=await mpe(),!e)e=Jq();if(!e){let t=await Fq();e=Vq(t)}}return e},Qq=()=>{let e=null;if(pl()){if(e=hpe(),!e)e=Jq();if(!e){let t=Kq();e=Vq(t)}}return e},gpe=async()=>pl()&&await Gq()!==Lo,ype=()=>pl()&&Qq()!==Lo,bpe=async()=>{if(eo!==void 0)return eo;eo=null;try{let t=(await Mq(Ry)).match(Hq);if(t)eo=t[1]}catch(e){}return eo},Spe=()=>{if(eo!==void 0)return eo;eo=null;try{let t=qq(Ry).match(Hq);if(t)eo=t[1]}catch(e){}return eo},Yq=()=>{let e=Uq();if(e.header&&e.header.glibcVersionRuntime)return e.header.glibcVersionRuntime;return null},jq=(e)=>e.trim().split(/\s+/)[1],Xq=(e)=>{let[t,r,o]=e.split(/[\r\n]+/);if(t&&t.includes(Lo))return jq(t);if(r&&o&&r.includes(aa))return jq(o);return null},vpe=async()=>{let e=null;if(pl()){if(e=await bpe(),!e)e=Yq();if(!e){let t=await Fq();e=Xq(t)}}return e},wpe=()=>{let e=null;if(pl()){if(e=Spe(),!e)e=Yq();if(!e){let t=Kq();e=Xq(t)}}return e};e4.exports={GLIBC:Lo,MUSL:aa,family:Gq,familySync:Qq,isNonGlibcLinux:gpe,isNonGlibcLinuxSync:ype,version:vpe,versionSync:wpe}});var n4=ge(function(HNe,r4){var xpe={ALLOW:0,DENY:1};r4.exports=xpe});var i4=ge(function(JNe,o4){var eR={value:"SqliteError",writable:!0,enumerable:!1,configurable:!0};function ca(e,t,r){if(new.target!==ca)return new ca(e,t);if(typeof t!=="string")throw TypeError("Expected second argument to be a string");Error.call(this,e),eR.value=""+e,Object.defineProperty(this,"message",eR),Error.captureStackTrace(this,ca),this.code=t,this.rawCode=r}Object.setPrototypeOf(ca,Error);Object.setPrototypeOf(ca.prototype,Error.prototype);Object.defineProperty(ca.prototype,"name",eR);o4.exports=ca});var f4=ge(function(VNe,$y){var __dirname="/home/runner/work/brains/brains/node_modules/libsql",{load:_pe,currentTarget:Epe}=Cq(),{familySync:s4,GLIBC:kpe,MUSL:Ipe}=t4();function Ape(){if(process.env.LIBSQL_JS_DEV)return _pe(__dirname);let e=Epe();if(s4()==kpe)switch(e){case"linux-x64-musl":e="linux-x64-gnu";break;case"linux-arm64-musl":e="linux-arm64-gnu";break}if(e==="linux-arm-gnueabihf"&&s4()==Ipe)e="linux-arm-musleabihf";return qr(`@libsql/${e}`)}var{databaseOpen:Tpe,databaseOpenWithSync:Rpe,databaseInTransaction:$pe,databaseInterrupt:Ope,databaseClose:Cpe,databaseSyncSync:Ppe,databaseSyncUntilSync:zpe,databaseExecSync:Npe,databasePrepareSync:Dpe,databaseDefaultSafeIntegers:Lpe,databaseAuthorizer:Bpe,databaseLoadExtension:jpe,databaseMaxWriteReplicationIndex:Zpe,statementRaw:Upe,statementIsReader:Mpe,statementGet:a4,statementRun:c4,statementInterrupt:qpe,statementRowsSync:l4,statementColumns:Fpe,statementSafeIntegers:Kpe,rowsNext:Hpe}=Ape(),Jpe=n4(),u4=i4();function fl(e){if(e.libsqlError)return new u4(e.message,e.code,e.rawCode);return e}class d4{constructor(e,t){let r=t?.encryptionCipher??"aes256cbc";if(t&&t.syncUrl){var o="";if(t.syncAuth)console.warn("Warning: The `syncAuth` option is deprecated, please use `authToken` option instead."),o=t.syncAuth;else if(t.authToken)o=t.authToken;let i=t?.encryptionKey??"",s=t?.syncPeriod??0,a=t?.readYourWrites??!0,c=t?.offline??!1,u=t?.remoteEncryptionKey??"";this.db=Rpe(e,t.syncUrl,o,r,i,s,a,c,u)}else{let i=t?.authToken??"",s=t?.encryptionKey??"",a=t?.timeout??0,c=t?.remoteEncryptionKey??"";this.db=Tpe(e,i,r,s,a,c)}this.memory=e===":memory:",this.readonly=!1,this.name="",this.open=!0;let n=this.db;Object.defineProperties(this,{inTransaction:{get(){return $pe(n)}}})}sync(){return Ppe.call(this.db)}syncUntil(e){return zpe.call(this.db,e)}prepare(e){try{let t=Dpe.call(this.db,e);return new p4(t)}catch(t){throw fl(t)}}transaction(e){if(typeof e!=="function")throw TypeError("Expected first argument to be a function");let t=this,r=(n)=>(...i)=>{t.exec("BEGIN "+n);try{let s=e(...i);return t.exec("COMMIT"),s}catch(s){throw t.exec("ROLLBACK"),s}},o={default:{value:r("")},deferred:{value:r("DEFERRED")},immediate:{value:r("IMMEDIATE")},exclusive:{value:r("EXCLUSIVE")},database:{value:this,enumerable:!0}};return Object.defineProperties(o.default.value,o),Object.defineProperties(o.deferred.value,o),Object.defineProperties(o.immediate.value,o),Object.defineProperties(o.exclusive.value,o),o.default.value}pragma(e,t){if(t==null)t={};if(typeof e!=="string")throw TypeError("Expected first argument to be a string");if(typeof t!=="object")throw TypeError("Expected second argument to be an options object");let r=t.simple,o=this.prepare(`PRAGMA ${e}`,this,!0);return r?o.pluck().get():o.all()}backup(e,t){throw Error("not implemented")}serialize(e){throw Error("not implemented")}function(e,t,r){if(t==null)t={};if(typeof t==="function")r=t,t={};if(typeof e!=="string")throw TypeError("Expected first argument to be a string");if(typeof r!=="function")throw TypeError("Expected last argument to be a function");if(typeof t!=="object")throw TypeError("Expected second argument to be an options object");if(!e)throw TypeError("User-defined function name cannot be an empty string");throw Error("not implemented")}aggregate(e,t){if(typeof e!=="string")throw TypeError("Expected first argument to be a string");if(typeof t!=="object"||t===null)throw TypeError("Expected second argument to be an options object");if(!e)throw TypeError("User-defined function name cannot be an empty string");throw Error("not implemented")}table(e,t){if(typeof e!=="string")throw TypeError("Expected first argument to be a string");if(!e)throw TypeError("Virtual table module name cannot be an empty string");throw Error("not implemented")}authorizer(e){Bpe.call(this.db,e)}loadExtension(...e){jpe.call(this.db,...e)}maxWriteReplicationIndex(){return Zpe.call(this.db)}exec(e){try{Npe.call(this.db,e)}catch(t){throw fl(t)}}interrupt(){Ope.call(this.db)}close(){Cpe.call(this.db),this.open=!1}defaultSafeIntegers(e){return Lpe.call(this.db,e??!0),this}unsafeMode(...e){throw Error("not implemented")}}class p4{constructor(e){this.stmt=e,this.pluckMode=!1}raw(e){return Upe.call(this.stmt,e??!0),this}pluck(e){return this.pluckMode=e??!0,this}get reader(){return Mpe.call(this.stmt)}run(...e){try{if(e.length==1&&typeof e[0]==="object")return c4.call(this.stmt,e[0]);else return c4.call(this.stmt,e.flat())}catch(t){throw fl(t)}}get(...e){try{if(e.length==1&&typeof e[0]==="object")return a4.call(this.stmt,e[0]);else return a4.call(this.stmt,e.flat())}catch(t){throw fl(t)}}iterate(...e){var t=void 0;if(e.length==1&&typeof e[0]==="object")t=l4.call(this.stmt,e[0]);else t=l4.call(this.stmt,e.flat());return{nextRows:Array(100),nextRowIndex:100,next(){try{if(this.nextRowIndex===100)Hpe.call(t,this.nextRows),this.nextRowIndex=0;let o=this.nextRows[this.nextRowIndex];if(this.nextRows[this.nextRowIndex]=void 0,!o)return{done:!0};return this.nextRowIndex++,{value:o,done:!1}}catch(o){throw fl(o)}},[Symbol.iterator](){return this}}}all(...e){try{let t=[];for(let r of this.iterate(...e))if(this.pluckMode)t.push(r[Object.keys(r)[0]]);else t.push(r);return t}catch(t){throw fl(t)}}interrupt(){qpe.call(this.stmt)}columns(){return Fpe.call(this.stmt)}safeIntegers(e){return Kpe.call(this.stmt,e??!0),this}}$y.exports=d4;$y.exports.Authorization=Jpe;$y.exports.SqliteError=u4});import{Buffer as h4}from"buffer";function g4(e){if(e.scheme!=="file")throw new Ce(`URL scheme ${JSON.stringify(e.scheme+":")} is not supported by the local sqlite3 client. For more information, please read ${Yn}`,"URL_SCHEME_NOT_SUPPORTED");let t=e.authority;if(t!==void 0){let s=t.host.toLowerCase();if(s!==""&&s!=="localhost")throw new Ce(`Invalid host in file URL: ${JSON.stringify(t.host)}. A "file:" URL with an absolute path should start with one slash ("file:/absolute/path.db") or with three slashes ("file:///absolute/path.db"). For more information, please read ${Yn}`,"URL_INVALID");if(t.port!==void 0)throw new Ce("File URL cannot have a port","URL_INVALID");if(t.userinfo!==void 0)throw new Ce("File URL cannot have username and password","URL_INVALID")}let r=$q(e);if(r&&e.syncUrl)throw new Ce(`Embedded replica must use file for local db but URI with in-memory mode were provided instead: ${e.path}`,"URL_INVALID");let o=e.path;if(r)o=`${e.scheme}:${e.path}`;let n={authToken:e.authToken,encryptionKey:e.encryptionKey,remoteEncryptionKey:e.remoteEncryptionKey,syncUrl:e.syncUrl,syncPeriod:e.syncInterval,readYourWrites:e.readYourWrites,offline:e.offline,timeout:e.timeout},i=new hp.default(o,n);return zt(i,"SELECT 1 AS checkThatTheDatabaseCanBeOpened",e.intMode),new y4(o,n,i,e.intMode)}class y4{#e;#t;#r;#n;closed;protocol;constructor(e,t,r,o){this.#e=e,this.#t=t,this.#r=r,this.#n=o,this.closed=!1,this.protocol="file"}async execute(e,t){let r;if(typeof e==="string")r={sql:e,args:t||[]};else r=e;return this.#o(),zt(this.#i(),r,this.#n)}async batch(e,t="deferred"){this.#o();let r=this.#i();try{zt(r,Ji(t),this.#n);let o=[];for(let n=0;n<e.length;n++)try{if(!r.inTransaction)throw new Gt("The transaction has been rolled back",n,"TRANSACTION_CLOSED");let i=e[n],s=Array.isArray(i)?{sql:i[0],args:i[1]||[]}:i;o.push(zt(r,s,this.#n))}catch(i){if(i instanceof Gt)throw i;if(i instanceof Ce)throw new Gt(i.message,n,i.code,i.extendedCode,i.rawCode,i.cause instanceof Error?i.cause:void 0);throw i}return zt(r,"COMMIT",this.#n),o}finally{if(r.inTransaction)zt(r,"ROLLBACK",this.#n)}}async migrate(e){this.#o();let t=this.#i();try{zt(t,"PRAGMA foreign_keys=off",this.#n),zt(t,Ji("deferred"),this.#n);let r=[];for(let o=0;o<e.length;o++)try{if(!t.inTransaction)throw new Gt("The transaction has been rolled back",o,"TRANSACTION_CLOSED");r.push(zt(t,e[o],this.#n))}catch(n){if(n instanceof Gt)throw n;if(n instanceof Ce)throw new Gt(n.message,o,n.code,n.extendedCode,n.rawCode,n.cause instanceof Error?n.cause:void 0);throw n}return zt(t,"COMMIT",this.#n),r}finally{if(t.inTransaction)zt(t,"ROLLBACK",this.#n);zt(t,"PRAGMA foreign_keys=on",this.#n)}}async transaction(e="write"){let t=this.#i();return zt(t,Ji(e),this.#n),this.#r=null,new b4(t,this.#n)}async executeMultiple(e){this.#o();let t=this.#i();try{return S4(t,e)}finally{if(t.inTransaction)zt(t,"ROLLBACK",this.#n)}}async sync(){this.#o();let e=await this.#i().sync();return{frames_synced:e.frames_synced,frame_no:e.frame_no}}async reconnect(){try{if(!this.closed&&this.#r!==null)this.#r.close()}finally{this.#r=new hp.default(this.#e,this.#t),this.closed=!1}}close(){if(this.closed=!0,this.#r!==null)this.#r.close(),this.#r=null}#o(){if(this.closed)throw new Ce("The client is closed","CLIENT_CLOSED")}#i(){if(this.#r===null)this.#r=new hp.default(this.#e,this.#t);return this.#r}}class b4{#e;#t;constructor(e,t){this.#e=e,this.#t=t}async execute(e,t){let r;if(typeof e==="string")r={sql:e,args:t||[]};else r=e;return this.#r(),zt(this.#e,r,this.#t)}async batch(e){let t=[];for(let r=0;r<e.length;r++)try{this.#r();let o=e[r],n=Array.isArray(o)?{sql:o[0],args:o[1]||[]}:o;t.push(zt(this.#e,n,this.#t))}catch(o){if(o instanceof Gt)throw o;if(o instanceof Ce)throw new Gt(o.message,r,o.code,o.extendedCode,o.rawCode,o.cause instanceof Error?o.cause:void 0);throw o}return t}async executeMultiple(e){return this.#r(),S4(this.#e,e)}async rollback(){if(!this.#e.open)return;this.#r(),zt(this.#e,"ROLLBACK",this.#t)}async commit(){this.#r(),zt(this.#e,"COMMIT",this.#t)}close(){if(this.#e.inTransaction)zt(this.#e,"ROLLBACK",this.#t)}get closed(){return!this.#e.inTransaction}#r(){if(this.closed)throw new Ce("The transaction is closed","TRANSACTION_CLOSED")}}function zt(e,t,r){let o,n;if(typeof t==="string")o=t,n=[];else if(o=t.sql,Array.isArray(t.args))n=t.args.map((i)=>m4(i,r));else{n={};for(let i in t.args){let s=i[0]==="@"||i[0]==="$"||i[0]===":"?i.substring(1):i;n[s]=m4(t.args[i],r)}}try{let i=e.prepare(o);i.safeIntegers(!0);let s=!0;try{i.raw(!0)}catch{s=!1}if(s){let a=Array.from(i.columns().map((m)=>m.name)),c=Array.from(i.columns().map((m)=>m.type??"")),u=i.all(n).map((m)=>Vpe(m,a,r)),d=0,p=void 0;return new ul(a,c,u,0,void 0)}else{let a=i.run(n),c=a.changes,u=BigInt(a.lastInsertRowid);return new ul([],[],[],c,u)}}catch(i){throw v4(i)}}function Vpe(e,t,r){let o={};Object.defineProperty(o,"length",{value:e.length});for(let n=0;n<e.length;++n){let i=Wpe(e[n],r);Object.defineProperty(o,n,{value:i});let s=t[n];if(!Object.hasOwn(o,s))Object.defineProperty(o,s,{value:i,enumerable:!0,configurable:!0,writable:!0})}return o}function Wpe(e,t){if(typeof e==="bigint")if(t==="number"){if(e<Gpe||e>Qpe)throw RangeError("Received integer which cannot be safely represented as a JavaScript number");return Number(e)}else if(t==="bigint")return e;else if(t==="string")return""+e;else throw Error("Invalid value for IntMode");else if(e instanceof h4)return e.buffer;return e}function m4(e,t){if(typeof e==="number"){if(!Number.isFinite(e))throw RangeError("Only finite numbers (not Infinity or NaN) can be passed as arguments");return e}else if(typeof e==="bigint"){if(e<Ype||e>Xpe)throw RangeError("bigint is too large to be represented as a 64-bit integer and passed as argument");return e}else if(typeof e==="boolean")switch(t){case"bigint":return e?1n:0n;case"string":return e?"1":"0";default:return e?1:0}else if(e instanceof ArrayBuffer)return h4.from(e);else if(e instanceof Date)return e.valueOf();else if(e===void 0)throw TypeError("undefined cannot be passed as argument to the database");else return e}function S4(e,t){try{e.exec(t)}catch(r){throw v4(r)}}function v4(e){if(e instanceof hp.default.SqliteError){let t=e.code,r=efe(e.rawCode);return new Ce(e.message,r,t,e.rawCode,e)}return e}function efe(e){if(e===void 0)return"SQLITE_UNKNOWN";let t=e&255;return tfe[t]??`SQLITE_UNKNOWN_${t.toString()}`}var hp,Gpe,Qpe=9007199254740991n,Ype,Xpe=9223372036854775807n,tfe;var w4=v(()=>{vn();mp();dl();hp=ql(f4(),1);vn();Gpe=-9007199254740991n;Ype=-9223372036854775808n;tfe={1:"SQLITE_ERROR",2:"SQLITE_INTERNAL",3:"SQLITE_PERM",4:"SQLITE_ABORT",5:"SQLITE_BUSY",6:"SQLITE_LOCKED",7:"SQLITE_NOMEM",8:"SQLITE_READONLY",9:"SQLITE_INTERRUPT",10:"SQLITE_IOERR",11:"SQLITE_CORRUPT",12:"SQLITE_NOTFOUND",13:"SQLITE_FULL",14:"SQLITE_CANTOPEN",15:"SQLITE_PROTOCOL",16:"SQLITE_EMPTY",17:"SQLITE_SCHEMA",18:"SQLITE_TOOBIG",19:"SQLITE_CONSTRAINT",20:"SQLITE_MISMATCH",21:"SQLITE_MISUSE",22:"SQLITE_NOLFS",23:"SQLITE_AUTH",24:"SQLITE_FORMAT",25:"SQLITE_RANGE",26:"SQLITE_NOTADB",27:"SQLITE_NOTICE",28:"SQLITE_WARNING"}});var Wi;var tR=v(()=>{if(typeof WebSocket<"u")Wi=WebSocket;else if(typeof global<"u")Wi=global.WebSocket;else if(typeof window<"u")Wi=window.WebSocket;else if(typeof self<"u")Wi=self.WebSocket});class ml{constructor(){this.intMode="number"}intMode}var Ge,Pe,gp,xt,yp,hl,la,wn,or,to;var _t=v(()=>{Ge=class Ge extends Error{constructor(e){super(e);this.name="ClientError"}};Pe=class Pe extends Ge{constructor(e){super(e);this.name="ProtoError"}};gp=class gp extends Ge{code;proto;constructor(e,t){super(e);this.name="ResponseError",this.code=t.code,this.proto=t,this.stack=void 0}};xt=class xt extends Ge{constructor(e,t){if(t!==void 0){super(`${e}: ${t}`);this.cause=t}else super(e);this.name="ClosedError"}};yp=class yp extends Ge{constructor(e){super(e);this.name="WebSocketUnsupportedError"}};hl=class hl extends Ge{constructor(e){super(e);this.name="WebSocketError"}};la=class la extends Ge{status;constructor(e,t){super(e);this.status=t,this.name="HttpServerError"}};wn=class wn extends Ge{constructor(e){super(e);this.name="ProtocolVersionError"}};or=class or extends Ge{constructor(e){super(e);this.name="InternalError"}};to=class to extends Ge{constructor(e){super(e);this.name="MisuseError"}}});function Tr(e){if(typeof e==="string")return e;throw gl(e,"string")}function Zr(e){if(e===null||e===void 0)return;else if(typeof e==="string")return e;throw gl(e,"string or null")}function Bo(e){if(typeof e==="number")return e;throw gl(e,"number")}function Gi(e){if(typeof e==="boolean")return e;throw gl(e,"boolean")}function bp(e){if(Array.isArray(e))return e;throw gl(e,"array")}function It(e){if(e!==null&&typeof e==="object"&&!Array.isArray(e))return e;throw gl(e,"object")}function xn(e,t){return bp(e).map((r)=>t(It(r)))}function gl(e,t){if(e===void 0)return new Pe(`Expected ${t}, but the property was missing`);let r=typeof e;if(e===null)r="null";else if(Array.isArray(e))r="array";return new Pe(`Expected ${t}, received ${r}`)}function ua(e,t){return t(It(e))}var yl=v(()=>{_t()});class x4{#e;#t;constructor(e){this.#e=e,this.#t=!1}begin(){this.#e.push("{"),this.#t=!0}end(){this.#e.push("}"),this.#t=!1}#r(e){if(this.#t)this.#e.push('"'),this.#t=!1;else this.#e.push(',"');this.#e.push(e),this.#e.push('":')}string(e,t){this.#r(e),this.#e.push(JSON.stringify(t))}stringRaw(e,t){this.#r(e),this.#e.push('"'),this.#e.push(t),this.#e.push('"')}number(e,t){this.#r(e),this.#e.push(""+t)}boolean(e,t){this.#r(e),this.#e.push(t?"true":"false")}object(e,t,r){this.#r(e),this.begin(),r(this,t),this.end()}arrayObjects(e,t,r){this.#r(e),this.#e.push("[");for(let o=0;o<t.length;++o){if(o!==0)this.#e.push(",");this.begin(),r(this,t[o]),this.end()}this.#e.push("]")}}function Sp(e,t){let r=[],o=new x4(r);return o.begin(),t(o,e),o.end(),r.join("")}var da=0,vp=1,wp=2,_4=5;class E4{#e;#t;#r;constructor(e){this.#e=e,this.#t=new DataView(e.buffer,e.byteOffset,e.byteLength),this.#r=0}varint(){let e=0;for(let t=0;;t+=7){let r=this.#e[this.#r++];if(e|=(r&127)<<t,!(r&128))break}return e}varintBig(){let e=0n;for(let t=0n;;t+=7n){let r=this.#e[this.#r++];if(e|=BigInt(r&127)<<t,!(r&128))break}return e}bytes(e){let t=new Uint8Array(this.#e.buffer,this.#e.byteOffset+this.#r,e);return this.#r+=e,t}double(){let e=this.#t.getFloat64(this.#r,!0);return this.#r+=8,e}skipVarint(){for(;;)if(!(this.#e[this.#r++]&128))break}skip(e){this.#r+=e}eof(){return this.#r>=this.#e.byteLength}}class k4{#e;#t;constructor(e){this.#e=e,this.#t=-1}setup(e){this.#t=e}#r(e){if(this.#t!==e)throw new Pe(`Expected wire type ${e}, got ${this.#t}`);this.#t=-1}bytes(){this.#r(wp);let e=this.#e.varint();return this.#e.bytes(e)}string(){return new TextDecoder().decode(this.bytes())}message(e){return Qi(this.bytes(),e)}int32(){return this.#r(da),this.#e.varint()}uint32(){return this.int32()}bool(){return this.int32()!==0}uint64(){return this.#r(da),this.#e.varintBig()}sint64(){let e=this.uint64();return e>>1n^-(e&1n)}double(){return this.#r(vp),this.#e.double()}maybeSkip(){if(this.#t<0)return;else if(this.#t===da)this.#e.skipVarint();else if(this.#t===vp)this.#e.skip(8);else if(this.#t===wp){let e=this.#e.varint();this.#e.skip(e)}else if(this.#t===_4)this.#e.skip(4);else throw new Pe(`Unexpected wire type ${this.#t}`);this.#t=-1}}function Qi(e,t){let r=new E4(e),o=new k4(r),n=t.default();while(!r.eof()){let i=r.varint(),s=i>>3,a=i&7;o.setup(a);let c=t[s];if(c!==void 0){let u=c(o,n);if(u!==void 0)n=u}o.maybeSkip()}return n}var rR=v(()=>{_t()});class nR{#e;#t;#r;#n;constructor(){this.#e=new ArrayBuffer(256),this.#t=new Uint8Array(this.#e),this.#r=new DataView(this.#e),this.#n=0}#o(e){if(this.#n+e<=this.#e.byteLength)return;let t=this.#e.byteLength;while(t<this.#n+e)t*=2;let r=new ArrayBuffer(t),o=new Uint8Array(r),n=new DataView(r);o.set(new Uint8Array(this.#e,0,this.#n)),this.#e=r,this.#t=o,this.#r=n}#i(e){this.#o(5),e=0|e;do{let t=e&127;e>>>=7,t|=e?128:0,this.#t[this.#n++]=t}while(e)}#a(e){this.#o(10),e=e&0xffffffffffffffffn;do{let t=Number(e&0x7fn);e>>=7n,t|=e?128:0,this.#t[this.#n++]=t}while(e)}#s(e,t){this.#i(e<<3|t)}bytes(e,t){this.#s(e,wp),this.#i(t.byteLength),this.#o(t.byteLength),this.#t.set(t,this.#n),this.#n+=t.byteLength}string(e,t){this.bytes(e,new TextEncoder().encode(t))}message(e,t,r){let o=new nR;r(o,t),this.bytes(e,o.data())}int32(e,t){this.#s(e,da),this.#i(t)}uint32(e,t){this.int32(e,t)}bool(e,t){this.int32(e,t?1:0)}sint64(e,t){this.#s(e,da),this.#a(t<<1n^t>>63n)}double(e,t){this.#s(e,vp),this.#o(8),this.#r.setFloat64(this.#n,t,!0),this.#n+=8}data(){return new Uint8Array(this.#e,0,this.#n)}}function xp(e,t){let r=new nR;return t(r,e),r.data()}var I4=()=>{};var oR=v(()=>{yl();rR();I4()});class Yi{#e;#t;constructor(){this.#e=new Set,this.#t=new Set}alloc(){for(let t of this.#t){if(this.#t.delete(t),this.#e.add(t),!this.#e.has(this.#e.size-1))this.#t.add(this.#e.size-1);return t}let e=this.#e.size;return this.#e.add(e),e}free(e){if(!this.#e.delete(e))throw new or("Freeing an id that is not allocated");if(this.#t.delete(this.#e.size),e<this.#e.size)this.#t.add(e)}}var iR=v(()=>{_t()});function He(e,t){throw new or(t)}var on=v(()=>{_t()});function bl(e){if(e===null)return null;else if(typeof e==="string")return e;else if(typeof e==="number"){if(!Number.isFinite(e))throw RangeError("Only finite numbers (not Infinity or NaN) can be passed as arguments");return e}else if(typeof e==="bigint"){if(e<nfe||e>ofe)throw RangeError("This bigint value is too large to be represented as a 64-bit integer and passed as argument");return e}else if(typeof e==="boolean")return e?1n:0n;else if(e instanceof ArrayBuffer)return new Uint8Array(e);else if(e instanceof Uint8Array)return e;else if(e instanceof Date)return+e.valueOf();else if(typeof e==="object")return""+e.toString();else throw TypeError("Unsupported type of value")}function sR(e,t){if(e===null)return null;else if(typeof e==="number")return e;else if(typeof e==="string")return e;else if(typeof e==="bigint")if(t==="number"){let r=Number(e);if(!Number.isSafeInteger(r))throw RangeError("Received integer which is too large to be safely represented as a JavaScript number");return r}else if(t==="bigint")return e;else if(t==="string")return""+e;else throw new to("Invalid value for IntMode");else if(e instanceof Uint8Array)return e.slice().buffer;else if(e===void 0)throw new Pe("Received unrecognized type of Value");else throw He(e,"Impossible type of Value")}var nfe,ofe=9223372036854775807n;var aR=v(()=>{_t();on();nfe=-9223372036854775808n});function pa(e){return{affectedRowCount:e.affectedRowCount,lastInsertRowid:e.lastInsertRowid,columnNames:e.cols.map((t)=>t.name),columnDecltypes:e.cols.map((t)=>t.decltype)}}function Cy(e,t){let r=pa(e),o=e.rows.map((n)=>A4(r.columnNames,n,t));return{...r,rows:o}}function Py(e,t){let r=pa(e),o;if(e.rows.length>0)o=A4(r.columnNames,e.rows[0],t);return{...r,row:o}}function zy(e,t){let r=pa(e),o;if(e.rows.length>0&&r.columnNames.length>0)o=sR(e.rows[0][0],t);return{...r,value:o}}function A4(e,t,r){let o={};Object.defineProperty(o,"length",{value:t.length});for(let n=0;n<t.length;++n){let i=sR(t[n],r);Object.defineProperty(o,n,{value:i});let s=e[n];if(s!==void 0&&!Object.hasOwn(o,s))Object.defineProperty(o,s,{value:i,enumerable:!0,configurable:!0,writable:!0})}return o}function jo(e){return new gp(e.message,e)}var _p=v(()=>{_t();aR()});class fa{#e;#t;#r;constructor(e,t){this.#e=e,this.#t=t,this.#r=void 0}_getSqlId(e){if(this.#e!==e)throw new to("Attempted to use SQL text opened with other object");else if(this.#r!==void 0)throw new xt("SQL text is closed",this.#r);return this.#t}close(){this._setClosed(new Ge("SQL text was manually closed"))}_setClosed(e){if(this.#r===void 0)this.#r=e,this.#e._closeSql(this.#t)}get closed(){return this.#r!==void 0}}function Ep(e,t){if(t instanceof fa)return{sqlId:t._getSqlId(e)};else return{sql:""+t}}var Sl=v(()=>{_t()});class Xi{#e;#t;constructor(){this.#e=[],this.#t=[]}get length(){return this.#e.length+this.#t.length}push(e){this.#e.push(e)}shift(){if(this.#t.length===0&&this.#e.length>0)this.#t=this.#e.reverse(),this.#e=[];return this.#t.pop()}first(){return this.#t.length!==0?this.#t[this.#t.length-1]:this.#e[0]}}class kp{sql;_args;_namedArgs;constructor(e){this.sql=e,this._args=[],this._namedArgs=new Map}bindIndexes(e){this._args.length=0;for(let t of e)this._args.push(bl(t));return this}bindIndex(e,t){if(e!==(e|0)||e<=0)throw RangeError("Index of a positional argument must be positive integer");while(this._args.length<e)this._args.push(null);return this._args[e-1]=bl(t),this}bindName(e,t){return this._namedArgs.set(e,bl(t)),this}unbindAll(){return this._args.length=0,this._namedArgs.clear(),this}}function Ny(e,t,r){let o,n=[],i=[];if(t instanceof kp){o=t.sql,n=t._args;for(let[c,u]of t._namedArgs.entries())i.push({name:c,value:u})}else if(Array.isArray(t))if(o=t[0],Array.isArray(t[1]))n=t[1].map((c)=>bl(c));else i=Object.entries(t[1]).map(([c,u])=>({name:c,value:bl(u)}));else o=t;let{sql:s,sqlId:a}=Ep(e,o);return{sql:s,sqlId:a,args:n,namedArgs:i,wantRows:r}}var Dy=v(()=>{Sl();aR()});class Ly{_stream;#e;_steps;#t;constructor(e,t){this._stream=e,this.#e=t,this._steps=[],this.#t=!1}step(){return new cR(this)}execute(){if(this.#t)throw new to("This batch has already been executed");this.#t=!0;let e={steps:this._steps.map((t)=>t.proto)};if(this.#e)return sfe(this._stream,this._steps,e);else return ife(this._stream,this._steps,e)}}function ife(e,t,r){return e._batch(r).then((o)=>{for(let n=0;n<t.length;++n){let i=o.stepResults.get(n),s=o.stepErrors.get(n);t[n].callback(i,s)}})}async function sfe(e,t,r){let o=await e._openCursor(r);try{let n=0,i=void 0,s=[];for(;;){let a=await o.next();if(a===void 0)break;if(a.type==="step_begin"){if(a.step<n||a.step>=t.length)throw new Pe("Server produced StepBeginEntry for unexpected step");else if(i!==void 0)throw new Pe("Server produced StepBeginEntry before terminating previous step");for(let c=n;c<a.step;++c)t[c].callback(void 0,void 0);n=a.step+1,i=a,s=[]}else if(a.type==="step_end"){if(i===void 0)throw new Pe("Server produced StepEndEntry but no step is active");let c={cols:i.cols,rows:s,affectedRowCount:a.affectedRowCount,lastInsertRowid:a.lastInsertRowid};t[i.step].callback(c,void 0),i=void 0,s=[]}else if(a.type==="step_error"){if(i===void 0){if(a.step>=t.length)throw new Pe("Server produced StepErrorEntry for unexpected step");for(let c=n;c<a.step;++c)t[c].callback(void 0,void 0)}else{if(a.step!==i.step)throw new Pe("Server produced StepErrorEntry for unexpected step");i=void 0,s=[]}t[a.step].callback(void 0,a.error),n=a.step+1}else if(a.type==="row"){if(i===void 0)throw new Pe("Server produced RowEntry but no step is active");s.push(a.row)}else if(a.type==="error")throw jo(a.error);else if(a.type==="none")throw new Pe("Server produced unrecognized CursorEntry");else throw He(a,"Impossible CursorEntry")}if(i!==void 0)throw new Pe("Server closed Cursor before terminating active step");for(let a=n;a<t.length;++a)t[a].callback(void 0,void 0)}finally{o.close()}}class cR{_batch;#e;_index;constructor(e){this._batch=e,this.#e=[],this._index=void 0}condition(e){return this.#e.push(e._proto),this}query(e){return this.#t(e,!0,Cy)}queryRow(e){return this.#t(e,!0,Py)}queryValue(e){return this.#t(e,!0,zy)}run(e){return this.#t(e,!1,pa)}#t(e,t,r){if(this._index!==void 0)throw new to("This BatchStep has already been added to the batch");let o=Ny(this._batch._stream._sqlOwner(),e,t),n;if(this.#e.length===0)n=void 0;else if(this.#e.length===1)n=this.#e[0];else n={type:"and",conds:this.#e.slice()};let i={stmt:o,condition:n};return new Promise((s,a)=>{let c=(u,d)=>{if(u!==void 0&&d!==void 0)a(new Pe("Server returned both result and error"));else if(d!==void 0)a(jo(d));else if(u!==void 0)s(r(u,this._batch._stream.intMode));else s(void 0)};this._index=this._batch._steps.length,this._batch._steps.push({proto:i,callback:c})})}}class dt{_batch;_proto;constructor(e,t){this._batch=e,this._proto=t}static ok(e){return new dt(e._batch,{type:"ok",step:T4(e)})}static error(e){return new dt(e._batch,{type:"error",step:T4(e)})}static not(e){return new dt(e._batch,{type:"not",cond:e._proto})}static and(e,t){for(let r of t)R4(e,r);return new dt(e,{type:"and",conds:t.map((r)=>r._proto)})}static or(e,t){for(let r of t)R4(e,r);return new dt(e,{type:"or",conds:t.map((r)=>r._proto)})}static isAutocommit(e){return e._stream.client()._ensureVersion(3,"BatchCond.isAutocommit()"),new dt(e,{type:"is_autocommit"})}}function T4(e){if(e._index===void 0)throw new to("Cannot add a condition referencing a step that has not been added to the batch");return e._index}function R4(e,t){if(t._batch!==e)throw new to("Cannot mix BatchCond objects for different Batch objects")}var lR=v(()=>{_t();_p();Dy();on()});function $4(e){return{paramNames:e.params.map((t)=>t.name),columns:e.cols,isExplain:e.isExplain,isReadonly:e.isReadonly}}class vl{constructor(e){this.intMode=e}query(e){return this.#e(e,!0,Cy)}queryRow(e){return this.#e(e,!0,Py)}queryValue(e){return this.#e(e,!0,zy)}run(e){return this.#e(e,!1,pa)}#e(e,t,r){let o=Ny(this._sqlOwner(),e,t);return this._execute(o).then((n)=>r(n,this.intMode))}batch(e=!1){return new Ly(this,e)}describe(e){let t=Ep(this._sqlOwner(),e);return this._describe(t).then($4)}sequence(e){let t=Ep(this._sqlOwner(),e);return this._sequence(t)}intMode}var By=v(()=>{lR();_p();Sl();Dy()});class Ip{}var afe=1000,cfe=10,uR;var O4=v(()=>{_t();uR=class uR extends Ip{#e;#t;#r;#n;#o;#i;#a;constructor(e,t,r){super();this.#e=e,this.#t=t,this.#r=r,this.#n=new Xi,this.#o=new Xi,this.#i=void 0,this.#a=!1}async next(){for(;;){if(this.#i!==void 0)throw new xt("Cursor is closed",this.#i);while(!this.#a&&this.#o.length<cfe)this.#o.push(this.#s());let e=this.#n.shift();if(this.#a||e!==void 0)return e;await this.#o.shift().then((t)=>{if(t===void 0)return;for(let r of t.entries)this.#n.push(r);this.#a||=t.done})}}#s(){return this.#t._sendCursorRequest(this,{type:"fetch_cursor",cursorId:this.#r,maxCount:afe}).then((e)=>e,(e)=>{this._setClosed(e);return})}_setClosed(e){if(this.#i!==void 0)return;this.#i=e,this.#t._sendCursorRequest(this,{type:"close_cursor",cursorId:this.#r}).catch(()=>{return}),this.#t._cursorClosed(this)}close(){this._setClosed(new Ge("Cursor was manually closed"))}get closed(){return this.#i!==void 0}}});var Ap;var dR=v(()=>{_t();By();O4();Ap=class Ap extends vl{#e;#t;#r;#n;#o;#i;static open(e){let t=e._streamIdAlloc.alloc(),r=new Ap(e,t),o=()=>{return},n=(s)=>r.#l(s),i={type:"open_stream",streamId:t};return e._sendRequest(i,{responseCallback:o,errorCallback:n}),r}constructor(e,t){super(e.intMode);this.#e=e,this.#t=t,this.#r=new Xi,this.#n=void 0,this.#o=!1,this.#i=void 0}client(){return this.#e}_sqlOwner(){return this.#e}_execute(e){return this.#a({type:"execute",streamId:this.#t,stmt:e}).then((t)=>t.result)}_batch(e){return this.#a({type:"batch",streamId:this.#t,batch:e}).then((t)=>t.result)}_describe(e){return this.#e._ensureVersion(2,"describe()"),this.#a({type:"describe",streamId:this.#t,sql:e.sql,sqlId:e.sqlId}).then((t)=>t.result)}_sequence(e){return this.#e._ensureVersion(2,"sequence()"),this.#a({type:"sequence",streamId:this.#t,sql:e.sql,sqlId:e.sqlId}).then((t)=>{return})}getAutocommit(){return this.#e._ensureVersion(3,"getAutocommit()"),this.#a({type:"get_autocommit",streamId:this.#t}).then((e)=>e.isAutocommit)}#a(e){return new Promise((t,r)=>{this.#s({type:"request",request:e,responseCallback:t,errorCallback:r})})}_openCursor(e){return this.#e._ensureVersion(3,"cursor"),new Promise((t,r)=>{this.#s({type:"cursor",batch:e,cursorCallback:t,errorCallback:r})})}_sendCursorRequest(e,t){if(e!==this.#n)throw new or("Cursor not associated with the stream attempted to execute a request");return new Promise((r,o)=>{if(this.#i!==void 0)o(new xt("Stream is closed",this.#i));else this.#e._sendRequest(t,{responseCallback:r,errorCallback:o})})}_cursorClosed(e){if(e!==this.#n)throw new or("Cursor was closed, but it was not associated with the stream");this.#n=void 0,this.#c()}#s(e){if(this.#i!==void 0)e.errorCallback(new xt("Stream is closed",this.#i));else if(this.#o)e.errorCallback(new xt("Stream is closing",void 0));else this.#r.push(e),this.#c()}#c(){for(;;){let e=this.#r.first();if(e===void 0&&this.#n===void 0&&this.#o){this.#l(new Ge("Stream was gracefully closed"));break}else if(e?.type==="request"&&this.#n===void 0){let{request:t,responseCallback:r,errorCallback:o}=e;this.#r.shift(),this.#e._sendRequest(t,{responseCallback:r,errorCallback:o})}else if(e?.type==="cursor"&&this.#n===void 0){let{batch:t,cursorCallback:r}=e;this.#r.shift();let o=this.#e._cursorIdAlloc.alloc(),n=new uR(this.#e,this,o),i={type:"open_cursor",streamId:this.#t,cursorId:o,batch:t},s=()=>{return},a=(c)=>n._setClosed(c);this.#e._sendRequest(i,{responseCallback:s,errorCallback:a}),this.#n=n,r(n)}else break}}#l(e){if(this.#i!==void 0)return;if(this.#i=e,this.#n!==void 0)this.#n._setClosed(e);for(;;){let n=this.#r.shift();if(n!==void 0)n.errorCallback(e);else break}let t={type:"close_stream",streamId:this.#t},r=()=>this.#e._streamIdAlloc.free(this.#t),o=()=>{return};this.#e._sendRequest(t,{responseCallback:r,errorCallback:o})}close(){this.#l(new Ge("Stream was manually closed"))}closeGracefully(){this.#o=!0,this.#c()}get closed(){return this.#i!==void 0||this.#o}}});function Tp(e,t){if(t.sql!==void 0)e.string("sql",t.sql);if(t.sqlId!==void 0)e.number("sql_id",t.sqlId);e.arrayObjects("args",t.args,C4),e.arrayObjects("named_args",t.namedArgs,lfe),e.boolean("want_rows",t.wantRows)}function lfe(e,t){e.string("name",t.name),e.object("value",t.value,C4)}function wl(e,t){e.arrayObjects("steps",t.steps,ufe)}function ufe(e,t){if(t.condition!==void 0)e.object("condition",t.condition,pR);e.object("stmt",t.stmt,Tp)}function pR(e,t){if(e.stringRaw("type",t.type),t.type==="ok"||t.type==="error")e.number("step",t.step);else if(t.type==="not")e.object("cond",t.cond,pR);else if(t.type==="and"||t.type==="or")e.arrayObjects("conds",t.conds,pR);else if(t.type==="is_autocommit");else throw He(t,"Impossible type of BatchCond")}function C4(e,t){if(t===null)e.stringRaw("type","null");else if(typeof t==="bigint")e.stringRaw("type","integer"),e.stringRaw("value",""+t);else if(typeof t==="number")e.stringRaw("type","float"),e.number("value",t);else if(typeof t==="string")e.stringRaw("type","text"),e.string("value",t);else if(t instanceof Uint8Array)e.stringRaw("type","blob"),e.stringRaw("base64",ll.fromUint8Array(t));else if(t===void 0);else throw He(t,"Impossible type of Value")}var fR=v(()=>{Ty();on()});function P4(e,t){if(e.stringRaw("type",t.type),t.type==="hello"){if(t.jwt!==void 0)e.string("jwt",t.jwt)}else if(t.type==="request")e.number("request_id",t.requestId),e.object("request",t.request,dfe);else throw He(t,"Impossible type of ClientMsg")}function dfe(e,t){if(e.stringRaw("type",t.type),t.type==="open_stream")e.number("stream_id",t.streamId);else if(t.type==="close_stream")e.number("stream_id",t.streamId);else if(t.type==="execute")e.number("stream_id",t.streamId),e.object("stmt",t.stmt,Tp);else if(t.type==="batch")e.number("stream_id",t.streamId),e.object("batch",t.batch,wl);else if(t.type==="open_cursor")e.number("stream_id",t.streamId),e.number("cursor_id",t.cursorId),e.object("batch",t.batch,wl);else if(t.type==="close_cursor")e.number("cursor_id",t.cursorId);else if(t.type==="fetch_cursor")e.number("cursor_id",t.cursorId),e.number("max_count",t.maxCount);else if(t.type==="sequence"){if(e.number("stream_id",t.streamId),t.sql!==void 0)e.string("sql",t.sql);if(t.sqlId!==void 0)e.number("sql_id",t.sqlId)}else if(t.type==="describe"){if(e.number("stream_id",t.streamId),t.sql!==void 0)e.string("sql",t.sql);if(t.sqlId!==void 0)e.number("sql_id",t.sqlId)}else if(t.type==="store_sql")e.number("sql_id",t.sqlId),e.string("sql",t.sql);else if(t.type==="close_sql")e.number("sql_id",t.sqlId);else if(t.type==="get_autocommit")e.number("stream_id",t.streamId);else throw He(t,"Impossible type of Request")}var z4=v(()=>{fR();on()});function Rp(e,t){if(t.sql!==void 0)e.string(1,t.sql);if(t.sqlId!==void 0)e.int32(2,t.sqlId);for(let r of t.args)e.message(3,r,D4);for(let r of t.namedArgs)e.message(4,r,pfe);e.bool(5,t.wantRows)}function pfe(e,t){e.string(1,t.name),e.message(2,t.value,D4)}function xl(e,t){for(let r of t.steps)e.message(1,r,ffe)}function ffe(e,t){if(t.condition!==void 0)e.message(1,t.condition,mR);e.message(2,t.stmt,Rp)}function mR(e,t){if(t.type==="ok")e.uint32(1,t.step);else if(t.type==="error")e.uint32(2,t.step);else if(t.type==="not")e.message(3,t.cond,mR);else if(t.type==="and")e.message(4,t.conds,N4);else if(t.type==="or")e.message(5,t.conds,N4);else if(t.type==="is_autocommit")e.message(6,void 0,L4);else throw He(t,"Impossible type of BatchCond")}function N4(e,t){for(let r of t)e.message(1,r,mR)}function D4(e,t){if(t===null)e.message(1,void 0,L4);else if(typeof t==="bigint")e.sint64(2,t);else if(typeof t==="number")e.double(3,t);else if(typeof t==="string")e.string(4,t);else if(t instanceof Uint8Array)e.bytes(5,t);else if(t===void 0);else throw He(t,"Impossible type of Value")}function L4(e,t){}var hR=v(()=>{on()});function B4(e,t){if(t.type==="hello")e.message(1,t,mfe);else if(t.type==="request")e.message(2,t,hfe);else throw He(t,"Impossible type of ClientMsg")}function mfe(e,t){if(t.jwt!==void 0)e.string(1,t.jwt)}function hfe(e,t){e.int32(1,t.requestId);let r=t.request;if(r.type==="open_stream")e.message(2,r,gfe);else if(r.type==="close_stream")e.message(3,r,yfe);else if(r.type==="execute")e.message(4,r,bfe);else if(r.type==="batch")e.message(5,r,Sfe);else if(r.type==="open_cursor")e.message(6,r,vfe);else if(r.type==="close_cursor")e.message(7,r,wfe);else if(r.type==="fetch_cursor")e.message(8,r,xfe);else if(r.type==="sequence")e.message(9,r,_fe);else if(r.type==="describe")e.message(10,r,Efe);else if(r.type==="store_sql")e.message(11,r,kfe);else if(r.type==="close_sql")e.message(12,r,Ife);else if(r.type==="get_autocommit")e.message(13,r,Afe);else throw He(r,"Impossible type of Request")}function gfe(e,t){e.int32(1,t.streamId)}function yfe(e,t){e.int32(1,t.streamId)}function bfe(e,t){e.int32(1,t.streamId),e.message(2,t.stmt,Rp)}function Sfe(e,t){e.int32(1,t.streamId),e.message(2,t.batch,xl)}function vfe(e,t){e.int32(1,t.streamId),e.int32(2,t.cursorId),e.message(3,t.batch,xl)}function wfe(e,t){e.int32(1,t.cursorId)}function xfe(e,t){e.int32(1,t.cursorId),e.uint32(2,t.maxCount)}function _fe(e,t){if(e.int32(1,t.streamId),t.sql!==void 0)e.string(2,t.sql);if(t.sqlId!==void 0)e.int32(3,t.sqlId)}function Efe(e,t){if(e.int32(1,t.streamId),t.sql!==void 0)e.string(2,t.sql);if(t.sqlId!==void 0)e.int32(3,t.sqlId)}function kfe(e,t){e.int32(1,t.sqlId),e.string(2,t.sql)}function Ife(e,t){e.int32(1,t.sqlId)}function Afe(e,t){e.int32(1,t.streamId)}var j4=v(()=>{hR();on()});function es(e){let t=Tr(e.message),r=Zr(e.code);return{message:t,code:r}}function $p(e){let t=xn(e.cols,Z4),r=bp(e.rows).map((s)=>xn(s,U4)),o=Bo(e.affected_row_count),n=Zr(e.last_insert_rowid),i=n!==void 0?BigInt(n):void 0;return{cols:t,rows:r,affectedRowCount:o,lastInsertRowid:i}}function Z4(e){let t=Zr(e.name),r=Zr(e.decltype);return{name:t,decltype:r}}function jy(e){let t=new Map;bp(e.step_results).forEach((o,n)=>{if(o!==null)t.set(n,$p(It(o)))});let r=new Map;return bp(e.step_errors).forEach((o,n)=>{if(o!==null)r.set(n,es(It(o)))}),{stepResults:t,stepErrors:r}}function Zy(e){let t=Tr(e.type);if(t==="step_begin"){let r=Bo(e.step),o=xn(e.cols,Z4);return{type:"step_begin",step:r,cols:o}}else if(t==="step_end"){let r=Bo(e.affected_row_count),o=Zr(e.last_insert_rowid),n=o!==void 0?BigInt(o):void 0;return{type:"step_end",affectedRowCount:r,lastInsertRowid:n}}else if(t==="step_error"){let r=Bo(e.step),o=es(It(e.error));return{type:"step_error",step:r,error:o}}else if(t==="row")return{type:"row",row:xn(e.row,U4)};else if(t==="error")return{type:"error",error:es(It(e.error))};else throw new Pe("Unexpected type of CursorEntry")}function Uy(e){let t=xn(e.params,Tfe),r=xn(e.cols,Rfe),o=Gi(e.is_explain),n=Gi(e.is_readonly);return{params:t,cols:r,isExplain:o,isReadonly:n}}function Tfe(e){return{name:Zr(e.name)}}function Rfe(e){let t=Tr(e.name),r=Zr(e.decltype);return{name:t,decltype:r}}function U4(e){let t=Tr(e.type);if(t==="null")return null;else if(t==="integer"){let r=Tr(e.value);return BigInt(r)}else if(t==="float")return Bo(e.value);else if(t==="text")return Tr(e.value);else if(t==="blob")return ll.toUint8Array(Tr(e.base64));else throw new Pe("Unexpected type of Value")}var My=v(()=>{Ty();_t();yl()});function M4(e){let t=Tr(e.type);if(t==="hello_ok")return{type:"hello_ok"};else if(t==="hello_error")return{type:"hello_error",error:es(It(e.error))};else if(t==="response_ok"){let r=Bo(e.request_id),o=$fe(It(e.response));return{type:"response_ok",requestId:r,response:o}}else if(t==="response_error"){let r=Bo(e.request_id),o=es(It(e.error));return{type:"response_error",requestId:r,error:o}}else throw new Pe("Unexpected type of ServerMsg")}function $fe(e){let t=Tr(e.type);if(t==="open_stream")return{type:"open_stream"};else if(t==="close_stream")return{type:"close_stream"};else if(t==="execute")return{type:"execute",result:$p(It(e.result))};else if(t==="batch")return{type:"batch",result:jy(It(e.result))};else if(t==="open_cursor")return{type:"open_cursor"};else if(t==="close_cursor")return{type:"close_cursor"};else if(t==="fetch_cursor"){let r=xn(e.entries,Zy),o=Gi(e.done);return{type:"fetch_cursor",entries:r,done:o}}else if(t==="sequence")return{type:"sequence"};else if(t==="describe")return{type:"describe",result:Uy(It(e.result))};else if(t==="store_sql")return{type:"store_sql"};else if(t==="close_sql")return{type:"close_sql"};else if(t==="get_autocommit")return{type:"get_autocommit",isAutocommit:Gi(e.is_autocommit)};else throw new Pe("Unexpected type of Response")}var q4=v(()=>{_t();yl();My()});var sn,ts,F4,K4,_l,Ofe,Cfe,qy,Pfe,zfe,Nfe,El,Dfe,Lfe,Bfe;var Fy=v(()=>{sn={default(){return{message:"",code:void 0}},1(e,t){t.message=e.string()},2(e,t){t.code=e.string()}},ts={default(){return{cols:[],rows:[],affectedRowCount:0,lastInsertRowid:void 0}},1(e,t){t.cols.push(e.message(F4))},2(e,t){t.rows.push(e.message(K4))},3(e,t){t.affectedRowCount=Number(e.uint64())},4(e,t){t.lastInsertRowid=e.sint64()}},F4={default(){return{name:void 0,decltype:void 0}},1(e,t){t.name=e.string()},2(e,t){t.decltype=e.string()}},K4={default(){return[]},1(e,t){t.push(e.message(Bfe))}},_l={default(){return{stepResults:new Map,stepErrors:new Map}},1(e,t){let[r,o]=e.message(Ofe);t.stepResults.set(r,o)},2(e,t){let[r,o]=e.message(Cfe);t.stepErrors.set(r,o)}},Ofe={default(){return[0,ts.default()]},1(e,t){t[0]=e.uint32()},2(e,t){t[1]=e.message(ts)}},Cfe={default(){return[0,sn.default()]},1(e,t){t[0]=e.uint32()},2(e,t){t[1]=e.message(sn)}},qy={default(){return{type:"none"}},1(e){return e.message(Pfe)},2(e){return e.message(zfe)},3(e){return e.message(Nfe)},4(e){return{type:"row",row:e.message(K4)}},5(e){return{type:"error",error:e.message(sn)}}},Pfe={default(){return{type:"step_begin",step:0,cols:[]}},1(e,t){t.step=e.uint32()},2(e,t){t.cols.push(e.message(F4))}},zfe={default(){return{type:"step_end",affectedRowCount:0,lastInsertRowid:void 0}},1(e,t){t.affectedRowCount=e.uint32()},2(e,t){t.lastInsertRowid=e.uint64()}},Nfe={default(){return{type:"step_error",step:0,error:sn.default()}},1(e,t){t.step=e.uint32()},2(e,t){t.error=e.message(sn)}},El={default(){return{params:[],cols:[],isExplain:!1,isReadonly:!1}},1(e,t){t.params.push(e.message(Dfe))},2(e,t){t.cols.push(e.message(Lfe))},3(e,t){t.isExplain=e.bool()},4(e,t){t.isReadonly=e.bool()}},Dfe={default(){return{name:void 0}},1(e,t){t.name=e.string()}},Lfe={default(){return{name:"",decltype:void 0}},1(e,t){t.name=e.string()},2(e,t){t.decltype=e.string()}},Bfe={default(){return},1(e){return null},2(e){return e.sint64()},3(e){return e.double()},4(e){return e.string()},5(e){return e.bytes()}}});var H4,jfe,Zfe,Ufe,Mfe,qfe,Ffe,Kfe,Hfe;var J4=v(()=>{Fy();H4={default(){return{type:"none"}},1(e){return{type:"hello_ok"}},2(e){return e.message(jfe)},3(e){return e.message(Ufe)},4(e){return e.message(Zfe)}},jfe={default(){return{type:"hello_error",error:sn.default()}},1(e,t){t.error=e.message(sn)}},Zfe={default(){return{type:"response_error",requestId:0,error:sn.default()}},1(e,t){t.requestId=e.int32()},2(e,t){t.error=e.message(sn)}},Ufe={default(){return{type:"response_ok",requestId:0,response:{type:"none"}}},1(e,t){t.requestId=e.int32()},2(e,t){t.response={type:"open_stream"}},3(e,t){t.response={type:"close_stream"}},4(e,t){t.response=e.message(Mfe)},5(e,t){t.response=e.message(qfe)},6(e,t){t.response={type:"open_cursor"}},7(e,t){t.response={type:"close_cursor"}},8(e,t){t.response=e.message(Ffe)},9(e,t){t.response={type:"sequence"}},10(e,t){t.response=e.message(Kfe)},11(e,t){t.response={type:"store_sql"}},12(e,t){t.response={type:"close_sql"}},13(e,t){t.response=e.message(Hfe)}},Mfe={default(){return{type:"execute",result:ts.default()}},1(e,t){t.result=e.message(ts)}},qfe={default(){return{type:"batch",result:_l.default()}},1(e,t){t.result=e.message(_l)}},Ffe={default(){return{type:"fetch_cursor",entries:[],done:!1}},1(e,t){t.entries.push(e.message(qy))},2(e,t){t.done=e.bool()}},Kfe={default(){return{type:"describe",result:El.default()}},1(e,t){t.result=e.message(El)}},Hfe={default(){return{type:"get_autocommit",isAutocommit:!1}},1(e,t){t.isAutocommit=e.bool()}}});var V4,gR,Ky;var Hy=v(()=>{oR();_t();iR();_p();Sl();on();dR();z4();j4();q4();J4();V4=new Map([["hrana2",{version:2,encoding:"json"}],["hrana1",{version:1,encoding:"json"}]]),gR=new Map([["hrana3-protobuf",{version:3,encoding:"protobuf"}],["hrana3",{version:3,encoding:"json"}],["hrana2",{version:2,encoding:"json"}],["hrana1",{version:1,encoding:"json"}]]);Ky=class Ky extends ml{#e;#t;#r;#n;#o;#i;#a;#s;#c;_streamIdAlloc;_cursorIdAlloc;#l;constructor(e,t){super();this.#e=e,this.#t=[],this.#r=!1,this.#n=void 0,this.#o=!1,this.#i=void 0,this.#a=!1,this.#s=new Map,this.#c=new Yi,this._streamIdAlloc=new Yi,this._cursorIdAlloc=new Yi,this.#l=new Yi,this.#e.binaryType="arraybuffer",this.#e.addEventListener("open",()=>this.#p()),this.#e.addEventListener("close",(r)=>this.#g(r)),this.#e.addEventListener("error",(r)=>this.#f(r)),this.#e.addEventListener("message",(r)=>this.#y(r)),this.#d({type:"hello",jwt:t})}#d(e){if(this.#n!==void 0)throw new or("Trying to send a message on a closed client");if(this.#r)this.#m(e);else{let t=()=>this.#m(e),r=()=>{return};this.#t.push({openCallback:t,errorCallback:r})}}#p(){let e=this.#e.protocol;if(e===void 0){this.#u(new Ge("The `WebSocket.protocol` property is undefined. This most likely means that the WebSocket implementation provided by the environment is broken. If you are using Miniflare 2, please update to Miniflare 3, which fixes this problem."));return}else if(e==="")this.#i={version:1,encoding:"json"};else if(this.#i=gR.get(e),this.#i===void 0){this.#u(new Pe(`Unrecognized WebSocket subprotocol: ${JSON.stringify(e)}`));return}for(let t of this.#t)t.openCallback();this.#t.length=0,this.#r=!0}#m(e){let t=this.#i.encoding;if(t==="json"){let r=Sp(e,P4);this.#e.send(r)}else if(t==="protobuf"){let r=xp(e,B4);this.#e.send(r)}else throw He(t,"Impossible encoding")}getVersion(){return new Promise((e,t)=>{if(this.#a=!0,this.#n!==void 0)t(this.#n);else if(!this.#r){let r=()=>e(this.#i.version);this.#t.push({openCallback:r,errorCallback:t})}else e(this.#i.version)})}_ensureVersion(e,t){if(this.#i===void 0||!this.#a)throw new wn(`${t} is supported only on protocol version ${e} and higher, but the version supported by the WebSocket server is not yet known. Use Client.getVersion() to wait until the version is available.`);else if(this.#i.version<e)throw new wn(`${t} is supported on protocol version ${e} and higher, but the WebSocket server only supports version ${this.#i.version}`)}_sendRequest(e,t){if(this.#n!==void 0){t.errorCallback(new xt("Client is closed",this.#n));return}let r=this.#c.alloc();this.#s.set(r,{...t,type:e.type}),this.#d({type:"request",requestId:r,request:e})}#f(e){let r=e.message??"WebSocket was closed due to an error";this.#u(new hl(r))}#g(e){let t=`WebSocket was closed with code ${e.code}`;if(e.reason)t+=`: ${e.reason}`;this.#u(new hl(t))}#u(e){if(this.#n!==void 0)return;this.#n=e;for(let t of this.#t)t.errorCallback(e);this.#t.length=0;for(let[t,r]of this.#s.entries())r.errorCallback(e),this.#c.free(t);this.#s.clear(),this.#e.close()}#y(e){if(this.#n!==void 0)return;try{let t,r=this.#i.encoding;if(r==="json"){if(typeof e.data!=="string"){this.#e.close(3003,"Only text messages are accepted with JSON encoding"),this.#u(new Pe("Received non-text message from server with JSON encoding"));return}t=ua(JSON.parse(e.data),M4)}else if(r==="protobuf"){if(!(e.data instanceof ArrayBuffer)){this.#e.close(3003,"Only binary messages are accepted with Protobuf encoding"),this.#u(new Pe("Received non-binary message from server with Protobuf encoding"));return}t=Qi(new Uint8Array(e.data),H4)}else throw He(r,"Impossible encoding");this.#b(t)}catch(t){this.#e.close(3007,"Could not handle message"),this.#u(t)}}#b(e){if(e.type==="none")throw new Pe("Received an unrecognized ServerMsg");else if(e.type==="hello_ok"||e.type==="hello_error"){if(this.#o)throw new Pe("Received a duplicated hello response");if(this.#o=!0,e.type==="hello_error")throw jo(e.error);return}else if(!this.#o)throw new Pe("Received a non-hello message before a hello response");if(e.type==="response_ok"){let t=e.requestId,r=this.#s.get(t);if(this.#s.delete(t),r===void 0)throw new Pe("Received unexpected OK response");this.#c.free(t);try{if(r.type!==e.response.type)throw console.dir({responseState:r,msg:e}),new Pe("Received unexpected type of response");r.responseCallback(e.response)}catch(o){throw r.errorCallback(o),o}}else if(e.type==="response_error"){let t=e.requestId,r=this.#s.get(t);if(this.#s.delete(t),r===void 0)throw new Pe("Received unexpected error response");this.#c.free(t),r.errorCallback(jo(e.error))}else throw He(e,"Impossible ServerMsg type")}openStream(){return Ap.open(this)}storeSql(e){this._ensureVersion(2,"storeSql()");let t=this.#l.alloc(),r=new fa(this,t),o=()=>{return},n=(s)=>r._setClosed(s),i={type:"store_sql",sqlId:t,sql:e};return this._sendRequest(i,{responseCallback:o,errorCallback:n}),r}_closeSql(e){if(this.#n!==void 0)return;let t=()=>this.#l.free(e),r=(n)=>this.#u(n),o={type:"close_sql",sqlId:e};this._sendRequest(o,{responseCallback:t,errorCallback:r})}close(){this.#u(new Ge("Client was manually closed"))}get closed(){return this.#n!==void 0}}});var ma;var W4=v(()=>{if(typeof queueMicrotask<"u")ma=queueMicrotask;else{let e=Promise.resolve();ma=(t)=>{e.then(t)}}});class yR{#e;#t;#r;constructor(e){this.#e=new Uint8Array(new ArrayBuffer(e)),this.#t=0,this.#r=0}get length(){return this.#r-this.#t}data(){return this.#e.slice(this.#t,this.#r)}push(e){this.#n(e.byteLength),this.#e.set(e,this.#r),this.#r+=e.byteLength}#n(e){if(this.#r+e<=this.#e.byteLength)return;let t=this.#r-this.#t;if(t+e<=this.#e.byteLength&&2*this.#r>=this.#e.byteLength)this.#e.copyWithin(0,this.#t,this.#r);else{let r=this.#e.byteLength;do r*=2;while(t+e>r);let o=new Uint8Array(new ArrayBuffer(r));o.set(this.#e.slice(this.#t,this.#r),0),this.#e=o}this.#r=t,this.#t=0}shift(e){this.#t+=e}}function G4(e){let t=Zr(e.baton),r=Zr(e.base_url),o=xn(e.results,Jfe);return{baton:t,baseUrl:r,results:o}}function Jfe(e){let t=Tr(e.type);if(t==="ok")return{type:"ok",response:Vfe(It(e.response))};else if(t==="error")return{type:"error",error:es(It(e.error))};else throw new Pe("Unexpected type of StreamResult")}function Vfe(e){let t=Tr(e.type);if(t==="close")return{type:"close"};else if(t==="execute")return{type:"execute",result:$p(It(e.result))};else if(t==="batch")return{type:"batch",result:jy(It(e.result))};else if(t==="sequence")return{type:"sequence"};else if(t==="describe")return{type:"describe",result:Uy(It(e.result))};else if(t==="store_sql")return{type:"store_sql"};else if(t==="close_sql")return{type:"close_sql"};else if(t==="get_autocommit")return{type:"get_autocommit",isAutocommit:Gi(e.is_autocommit)};else throw new Pe("Unexpected type of StreamResponse")}function Q4(e){let t=Zr(e.baton),r=Zr(e.base_url);return{baton:t,baseUrl:r}}var bR=v(()=>{_t();yl();My()});var Y4,Wfe,Gfe,Qfe,Yfe,Xfe,eme,X4;var SR=v(()=>{Fy();Y4={default(){return{baton:void 0,baseUrl:void 0,results:[]}},1(e,t){t.baton=e.string()},2(e,t){t.baseUrl=e.string()},3(e,t){t.results.push(e.message(Wfe))}},Wfe={default(){return{type:"none"}},1(e){return{type:"ok",response:e.message(Gfe)}},2(e){return{type:"error",error:e.message(sn)}}},Gfe={default(){return{type:"none"}},1(e){return{type:"close"}},2(e){return e.message(Qfe)},3(e){return e.message(Yfe)},4(e){return{type:"sequence"}},5(e){return e.message(Xfe)},6(e){return{type:"store_sql"}},7(e){return{type:"close_sql"}},8(e){return e.message(eme)}},Qfe={default(){return{type:"execute",result:ts.default()}},1(e,t){t.result=e.message(ts)}},Yfe={default(){return{type:"batch",result:_l.default()}},1(e,t){t.result=e.message(_l)}},Xfe={default(){return{type:"describe",result:El.default()}},1(e,t){t.result=e.message(El)}},eme={default(){return{type:"get_autocommit",isAutocommit:!1}},1(e,t){t.isAutocommit=e.bool()}},X4={default(){return{baton:void 0,baseUrl:void 0}},1(e,t){t.baton=e.string()},2(e,t){t.baseUrl=e.string()}}});var vR;var eF=v(()=>{yl();rR();_t();on();bR();SR();My();Fy();vR=class vR extends Ip{#e;#t;#r;#n;#o;#i;constructor(e,t){super();this.#e=e,this.#t=t,this.#r=void 0,this.#n=new yR(16384),this.#o=void 0,this.#i=!1}async open(e){if(e.body===null)throw new Pe("No response body for cursor request");this.#r=e.body[Symbol.asyncIterator]();let t=await this.#a(Q4,X4);if(t===void 0)throw new Pe("Empty response to cursor request");return t}next(){return this.#a(Zy,qy)}close(){this._setClosed(new Ge("Cursor was manually closed"))}_setClosed(e){if(this.#o!==void 0)return;if(this.#o=e,this.#e._cursorClosed(this),this.#r!==void 0)this.#r.return()}get closed(){return this.#o!==void 0}async#a(e,t){for(;;){if(this.#i)return;else if(this.#o!==void 0)throw new xt("Cursor is closed",this.#o);if(this.#t==="json"){let n=this.#s();if(n!==void 0){let i=new TextDecoder().decode(n),s=JSON.parse(i);return ua(s,e)}}else if(this.#t==="protobuf"){let n=this.#c();if(n!==void 0)return Qi(n,t)}else throw He(this.#t,"Impossible encoding");if(this.#r===void 0)throw new or("Attempted to read from HTTP cursor before it was opened");let{value:r,done:o}=await this.#r.next();if(o&&this.#n.length===0)this.#i=!0;else if(o)throw new Pe("Unexpected end of cursor stream");else this.#n.push(r)}}#s(){let e=this.#n.data(),t=10,r=e.indexOf(10);if(r<0)return;let o=e.slice(0,r);return this.#n.shift(r+1),o}#c(){let e=this.#n.data(),t=0,r=0;for(;;){if(r>=e.byteLength)return;let n=e[r];if(t|=(n&127)<<7*r,r+=1,!(n&128))break}if(e.byteLength<r+t)return;let o=e.slice(r,r+t);return this.#n.shift(r+t),o}}});function tF(e,t){if(t.baton!==void 0)e.string("baton",t.baton);e.arrayObjects("requests",t.requests,tme)}function tme(e,t){if(e.stringRaw("type",t.type),t.type==="close");else if(t.type==="execute")e.object("stmt",t.stmt,Tp);else if(t.type==="batch")e.object("batch",t.batch,wl);else if(t.type==="sequence"){if(t.sql!==void 0)e.string("sql",t.sql);if(t.sqlId!==void 0)e.number("sql_id",t.sqlId)}else if(t.type==="describe"){if(t.sql!==void 0)e.string("sql",t.sql);if(t.sqlId!==void 0)e.number("sql_id",t.sqlId)}else if(t.type==="store_sql")e.number("sql_id",t.sqlId),e.string("sql",t.sql);else if(t.type==="close_sql")e.number("sql_id",t.sqlId);else if(t.type==="get_autocommit");else throw He(t,"Impossible type of StreamRequest")}function rF(e,t){if(t.baton!==void 0)e.string("baton",t.baton);e.object("batch",t.batch,wl)}var wR=v(()=>{fR();on()});function nF(e,t){if(t.baton!==void 0)e.string(1,t.baton);for(let r of t.requests)e.message(2,r,rme)}function rme(e,t){if(t.type==="close")e.message(1,t,nme);else if(t.type==="execute")e.message(2,t,ome);else if(t.type==="batch")e.message(3,t,ime);else if(t.type==="sequence")e.message(4,t,sme);else if(t.type==="describe")e.message(5,t,ame);else if(t.type==="store_sql")e.message(6,t,cme);else if(t.type==="close_sql")e.message(7,t,lme);else if(t.type==="get_autocommit")e.message(8,t,ume);else throw He(t,"Impossible type of StreamRequest")}function nme(e,t){}function ome(e,t){e.message(1,t.stmt,Rp)}function ime(e,t){e.message(1,t.batch,xl)}function sme(e,t){if(t.sql!==void 0)e.string(1,t.sql);if(t.sqlId!==void 0)e.int32(2,t.sqlId)}function ame(e,t){if(t.sql!==void 0)e.string(1,t.sql);if(t.sqlId!==void 0)e.int32(2,t.sqlId)}function cme(e,t){e.int32(1,t.sqlId),e.string(2,t.sql)}function lme(e,t){e.int32(1,t.sqlId)}function ume(e,t){}function oF(e,t){if(t.baton!==void 0)e.string(1,t.baton);e.message(2,t.batch,xl)}var xR=v(()=>{hR();on()});function dme(e,t){if(t.results.length!==e.length)throw new Pe("Server returned unexpected number of pipeline results");for(let r=0;r<e.length;++r){let o=t.results[r],n=e[r];if(o.type==="ok"){if(o.response.type!==n.request.type)throw new Pe("Received unexpected type of response");n.responseCallback(o.response)}else if(o.type==="error")n.errorCallback(jo(o.error));else if(o.type==="none")throw new Pe("Received unrecognized type of StreamResult");else throw He(o,"Received impossible type of StreamResult")}}async function pme(e,t){if(t==="json"){let r=await e.json();return ua(r,G4)}if(t==="protobuf"){let r=await e.arrayBuffer();return Qi(new Uint8Array(r),Y4)}throw await e.body?.cancel(),He(t,"Impossible encoding")}async function fme(e){let t=e.headers.get("content-type")??"text/plain",r=`Server returned HTTP status ${e.status}`;if(t==="application/json"){let o=await e.json();if("message"in o)return jo(o);return new la(r,e.status)}if(t==="text/plain"){let o=(await e.text()).trim();if(o!=="")r+=`: ${o}`;return new la(r,e.status)}return await e.body?.cancel(),new la(r,e.status)}var Jy;var _R=v(()=>{_t();oR();iR();W4();_p();Sl();By();on();eF();wR();xR();wR();xR();bR();SR();Jy=class Jy extends vl{#e;#t;#r;#n;#o;#i;#a;#s;#c;#l;#d;#p;#m;constructor(e,t,r,o,n){super(e.intMode);this.#e=e,this.#t=t.toString(),this.#r=r,this.#n=o,this.#o=n,this.#i=void 0,this.#a=new Xi,this.#s=!1,this.#l=!1,this.#d=!1,this.#p=void 0,this.#m=new Yi}client(){return this.#e}_sqlOwner(){return this}storeSql(e){let t=this.#m.alloc();return this.#f({type:"store_sql",sqlId:t,sql:e}).then(()=>{return},(r)=>this._setClosed(r)),new fa(this,t)}_closeSql(e){if(this.#p!==void 0)return;this.#f({type:"close_sql",sqlId:e}).then(()=>this.#m.free(e),(t)=>this._setClosed(t))}_execute(e){return this.#f({type:"execute",stmt:e}).then((t)=>t.result)}_batch(e){return this.#f({type:"batch",batch:e}).then((t)=>t.result)}_describe(e){return this.#f({type:"describe",sql:e.sql,sqlId:e.sqlId}).then((t)=>t.result)}_sequence(e){return this.#f({type:"sequence",sql:e.sql,sqlId:e.sqlId}).then((t)=>{return})}getAutocommit(){return this.#e._ensureVersion(3,"getAutocommit()"),this.#f({type:"get_autocommit"}).then((e)=>e.isAutocommit)}#f(e){return new Promise((t,r)=>{this.#g({type:"pipeline",request:e,responseCallback:t,errorCallback:r})})}_openCursor(e){return new Promise((t,r)=>{this.#g({type:"cursor",batch:e,cursorCallback:t,errorCallback:r})})}_cursorClosed(e){if(e!==this.#c)throw new or("Cursor was closed, but it was not associated with the stream");this.#c=void 0,ma(()=>this.#u())}close(){this._setClosed(new Ge("Stream was manually closed"))}closeGracefully(){this.#l=!0,ma(()=>this.#u())}get closed(){return this.#p!==void 0||this.#l}_setClosed(e){if(this.#p!==void 0)return;if(this.#p=e,this.#c!==void 0)this.#c._setClosed(e);this.#e._streamClosed(this);for(;;){let t=this.#a.shift();if(t!==void 0)t.errorCallback(e);else break}if((this.#i!==void 0||this.#s)&&!this.#d)this.#a.push({type:"pipeline",request:{type:"close"},responseCallback:()=>{return},errorCallback:()=>{return}}),this.#d=!0,ma(()=>this.#u())}#g(e){if(this.#p!==void 0)throw new xt("Stream is closed",this.#p);else if(this.#l)throw new xt("Stream is closing",void 0);else this.#a.push(e),ma(()=>this.#u())}#u(){if(this.#s||this.#c!==void 0)return;if(this.#l&&this.#a.length===0){this._setClosed(new Ge("Stream was gracefully closed"));return}let e=this.#e._endpoint;if(e===void 0){this.#e._endpointPromise.then(()=>this.#u(),(r)=>this._setClosed(r));return}let t=this.#a.shift();if(t===void 0)return;else if(t.type==="pipeline"){let r=[t];for(;;){let o=this.#a.first();if(o!==void 0&&o.type==="pipeline")r.push(o),this.#a.shift();else if(o===void 0&&this.#l&&!this.#d){r.push({type:"pipeline",request:{type:"close"},responseCallback:()=>{return},errorCallback:()=>{return}}),this.#d=!0;break}else break}this.#y(e,r)}else if(t.type==="cursor")this.#b(e,t);else throw He(t,"Impossible type of QueueEntry")}#y(e,t){this.#h(()=>this.#S(t,e),(r)=>pme(r,e.encoding),(r)=>r.baton,(r)=>r.baseUrl,(r)=>dme(t,r),(r)=>t.forEach((o)=>o.errorCallback(r)))}#b(e,t){let r=new vR(this,e.encoding);this.#c=r,this.#h(()=>this.#v(t,e),(o)=>r.open(o),(o)=>o.baton,(o)=>o.baseUrl,(o)=>t.cursorCallback(r),(o)=>t.errorCallback(o))}#h(e,t,r,o,n,i){let s;try{let a=e(),c=this.#n;s=c(a)}catch(a){s=Promise.reject(a)}this.#s=!0,s.then((a)=>{if(!a.ok)return fme(a).then((c)=>{throw c});return t(a)}).then((a)=>{this.#i=r(a),this.#t=o(a)??this.#t,n(a)}).catch((a)=>{this._setClosed(a),i(a)}).finally(()=>{this.#s=!1,this.#u()})}#S(e,t){return this.#w(new URL(t.pipelinePath,this.#t),{baton:this.#i,requests:e.map((r)=>r.request)},t.encoding,tF,nF)}#v(e,t){if(t.cursorPath===void 0)throw new wn(`Cursors are supported only on protocol version 3 and higher, but the HTTP server only supports version ${t.version}.`);return this.#w(new URL(t.cursorPath,this.#t),{baton:this.#i,batch:e.batch},t.encoding,rF,oF)}#w(e,t,r,o,n){let i,s;if(r==="json")i=Sp(t,o),s="application/json";else if(r==="protobuf")i=xp(t,n),s="application/x-protobuf";else throw He(r,"Impossible encoding");let a=new Headers;if(a.set("content-type",s),this.#r!==void 0)a.set("authorization",`Bearer ${this.#r}`);if(this.#o!==void 0)a.set("x-turso-encryption-key",this.#o);return new Request(e.toString(),{method:"POST",headers:a,body:i})}}});async function hme(e,t){let r=e;for(let o of mme){let n=new URL(o.versionPath,t),i=new Request(n.toString(),{method:"GET"}),s=await r(i);if(await s.arrayBuffer(),s.ok)return o}return ER}var mme,ER,Vy;var kR=v(()=>{_t();_R();mme=[{versionPath:"v3-protobuf",pipelinePath:"v3-protobuf/pipeline",cursorPath:"v3-protobuf/cursor",version:3,encoding:"protobuf"}],ER={versionPath:"v2",pipelinePath:"v2/pipeline",cursorPath:void 0,version:2,encoding:"json"};Vy=class Vy extends ml{#e;#t;#r;#n;#o;#i;_endpointPromise;_endpoint;constructor(e,t,r,o,n=2){super();if(this.#e=e,this.#t=t,this.#r=r??globalThis.fetch,this.#n=o,this.#o=void 0,this.#i=new Set,n==3)this._endpointPromise=hme(this.#r,this.#e),this._endpointPromise.then((i)=>this._endpoint=i,(i)=>this.#a(i));else this._endpointPromise=Promise.resolve(ER),this._endpointPromise.then((i)=>this._endpoint=i,(i)=>this.#a(i))}async getVersion(){if(this._endpoint!==void 0)return this._endpoint.version;return(await this._endpointPromise).version}_ensureVersion(e,t){if(e<=ER.version)return;else if(this._endpoint===void 0)throw new wn(`${t} is supported only on protocol version ${e} and higher, but the version supported by the HTTP server is not yet known. Use Client.getVersion() to wait until the version is available.`);else if(this._endpoint.version<e)throw new wn(`${t} is supported only on protocol version ${e} and higher, but the HTTP server only supports version ${this._endpoint.version}.`)}openStream(){if(this.#o!==void 0)throw new xt("Client is closed",this.#o);let e=new Jy(this,this.#e,this.#t,this.#r,this.#n);return this.#i.add(e),e}_streamClosed(e){this.#i.delete(e)}close(){this.#a(new Ge("Client was manually closed"))}get closed(){return this.#o!==void 0}#a(e){if(this.#o!==void 0)return;this.#o=e;for(let t of Array.from(this.#i))t._setClosed(new xt("Client was closed",e))}}});var iF=v(()=>{_t()});function IR(e,t,r=2){if(typeof Wi>"u")throw new yp("WebSockets are not supported in this environment");var o=void 0;if(r==3)o=Array.from(gR.keys());else o=Array.from(V4.keys());let n=new Wi(e,o);return new Ky(n,t)}function AR(e,t,r,o,n=2){return new Vy(e instanceof URL?e:new URL(e),t,r,o,n)}var Wy=v(()=>{tR();Hy();_t();kR();Hy();tR();lR();iF();Sl();Dy();By();kR();_R();Hy();dR();_t()});class Op{#e;#t;#r;constructor(e,t){this.#e=e,this.#t=t,this.#r=void 0}execute(e){return this.batch([e]).then((t)=>t[0])}async batch(e){let t=this._getStream();if(t.closed)throw new Ce("Cannot execute statements because the transaction is closed","TRANSACTION_CLOSED");try{let r=e.map(Zo),o;if(this.#r===void 0){this._getSqlCache().apply(r);let i=t.batch(this.#t>=3),s=i.step(),a=s.run(Ji(this.#e)),c=s;o=r.map((u)=>{let d=i.step().condition(dt.ok(c));if(this.#t>=3)d.condition(dt.not(dt.isAutocommit(i)));let p=d.query(u);return p.catch(()=>{return}),c=d,p}),this.#r=i.execute().then(()=>a).then(()=>{return});try{await this.#r}catch(u){throw this.close(),u}}else{if(this.#t<3)await this.#r;this._getSqlCache().apply(r);let i=t.batch(this.#t>=3),s=void 0;o=r.map((a)=>{let c=i.step();if(s!==void 0)c.condition(dt.ok(s));if(this.#t>=3)c.condition(dt.not(dt.isAutocommit(i)));let u=c.query(a);return u.catch(()=>{return}),s=c,u}),await i.execute()}let n=[];for(let i=0;i<o.length;i++)try{let s=await o[i];if(s===void 0)throw new Gt("Statement in a transaction was not executed, probably because the transaction has been rolled back",i,"TRANSACTION_CLOSED");n.push(Il(s))}catch(s){if(s instanceof Gt)throw s;let a=st(s);if(a instanceof Ce)throw new Gt(a.message,i,a.code,a.extendedCode,a.rawCode,a.cause instanceof Error?a.cause:void 0);throw a}return n}catch(r){throw st(r)}}async executeMultiple(e){let t=this._getStream();if(t.closed)throw new Ce("Cannot execute statements because the transaction is closed","TRANSACTION_CLOSED");try{if(this.#r===void 0){this.#r=t.run(Ji(this.#e)).then(()=>{return});try{await this.#r}catch(r){throw this.close(),r}}else await this.#r;await t.sequence(e)}catch(r){throw st(r)}}async rollback(){try{let e=this._getStream();if(e.closed)return;if(this.#r!==void 0);else return;let t=e.run("ROLLBACK").catch((r)=>{throw st(r)});e.closeGracefully(),await t}catch(e){throw st(e)}finally{this.close()}}async commit(){try{let e=this._getStream();if(e.closed)throw new Ce("Cannot commit the transaction because it is already closed","TRANSACTION_CLOSED");if(this.#r!==void 0)await this.#r;else return;let t=e.run("COMMIT").catch((r)=>{throw st(r)});e.closeGracefully(),await t}catch(e){throw st(e)}finally{this.close()}}}async function kl(e,t,r,o,n=!1){if(n)r.step().run("PRAGMA foreign_keys=off");let i=r.step(),s=i.run(Ji(e)),a=i,c=o.map((h)=>{let b=r.step().condition(dt.ok(a));if(t>=3)b.condition(dt.not(dt.isAutocommit(r)));let y=b.query(h);return a=b,y}),u=r.step().condition(dt.ok(a));if(t>=3)u.condition(dt.not(dt.isAutocommit(r)));let d=u.run("COMMIT");if(r.step().condition(dt.not(dt.ok(u))).run("ROLLBACK").catch((h)=>{return}),n)r.step().run("PRAGMA foreign_keys=on");await r.execute();let m=[];await s;for(let h=0;h<c.length;h++)try{let b=await c[h];if(b===void 0)throw new Gt("Statement in a batch was not executed, probably because the transaction has been rolled back",h,"TRANSACTION_CLOSED");m.push(Il(b))}catch(b){if(b instanceof Gt)throw b;let y=st(b);if(y instanceof Ce)throw new Gt(y.message,h,y.code,y.extendedCode,y.rawCode,y.cause instanceof Error?y.cause:void 0);throw y}return await d,m}function Zo(e){let t,r;if(Array.isArray(e))[t,r]=e;else if(typeof e==="string")t=e;else t=e.sql,r=e.args;let o=new kp(t);if(r)if(Array.isArray(r))o.bindIndexes(r);else for(let[n,i]of Object.entries(r))o.bindName(n,i);return o}function Il(e){let t=e.columnNames.map((s)=>s??""),r=e.columnDecltypes.map((s)=>s??""),o=e.rows,n=e.affectedRowCount,i=e.lastInsertRowid!==void 0?e.lastInsertRowid:void 0;return new ul(t,r,o,n,i)}function st(e){if(e instanceof Ge){let t=sF(e);return new Ce(e.message,t,void 0,void 0,e)}return e}function sF(e){if(e instanceof gp&&e.code!==void 0)return e.code;else if(e instanceof Pe)return"HRANA_PROTO_ERROR";else if(e instanceof xt)return e.cause instanceof Ge?sF(e.cause):"HRANA_CLOSED_ERROR";else if(e instanceof hl)return"HRANA_WEBSOCKET_ERROR";else if(e instanceof la)return"SERVER_ERROR";else if(e instanceof wn)return"PROTOCOL_VERSION_ERROR";else if(e instanceof or)return"INTERNAL_ERROR";else return"UNKNOWN"}var RR=v(()=>{Wy();vn();dl()});class Al{#e;#t;capacity;constructor(e,t){this.#e=e,this.#t=new aF,this.capacity=t}apply(e){if(this.capacity<=0)return;let t=new Set;for(let r of e){if(typeof r.sql!=="string")continue;let o=r.sql;if(o.length>=5000)continue;let n=this.#t.get(o);if(n===void 0){while(this.#t.size+1>this.capacity){let[i,s]=this.#t.peekLru();if(t.has(s))break;s.close(),this.#t.delete(i)}if(this.#t.size+1<=this.capacity)n=this.#e.storeSql(o),this.#t.set(o,n)}if(n!==void 0)r.sql=n,t.add(n)}}}class aF{#e;constructor(){this.#e=new Map}get(e){let t=this.#e.get(e);if(t!==void 0)this.#e.delete(e),this.#e.set(e,t);return t}set(e,t){this.#e.set(e,t)}peekLru(){for(let e of this.#e.entries())return e;return}delete(e){this.#e.delete(e)}get size(){return this.#e.size}}var $R=ge(function(VLe,lF){function gme(e){var t=0,r=[];function o(){if(t--,t<e)n()}function n(){var c=r.shift();if(a.queue=r.length,c)s(c.fn).then(c.resolve).catch(c.reject)}function i(c){return new Promise(function(u,d){r.push({fn:c,resolve:u,reject:d}),a.queue=r.length})}function s(c){t++;try{return Promise.resolve(c()).then(function(u){return o(),u},function(u){throw o(),u})}catch(u){return o(),Promise.reject(u)}}var a=function(c){if(t>=e)return i(c);else return s(c)};return a}function yme(e,t){var r=!1,o=this;return Promise.all(e.map(function(){var n=arguments;return o(function(){if(!r)return t.apply(void 0,n).catch(function(i){throw r=!0,i})})}))}function cF(e){return e.queue=0,e.map=yme,e}lF.exports=function(e){if(e)return cF(gme(e));else return cF(function(t){return t()})}});function pF(e){if(e.scheme!=="wss"&&e.scheme!=="ws")throw new Ce(`The WebSocket client supports only "libsql:", "wss:" and "ws:" URLs, got ${JSON.stringify(e.scheme+":")}. For more information, please read ${Yn}`,"URL_SCHEME_NOT_SUPPORTED");if(e.encryptionKey!==void 0)throw new Ce("Encryption key is not supported by the remote client.","ENCRYPTION_KEY_NOT_SUPPORTED");if(e.scheme==="ws"&&e.tls)throw new Ce('A "ws:" URL cannot opt into TLS by using ?tls=1',"URL_INVALID");else if(e.scheme==="wss"&&!e.tls)throw new Ce('A "wss:" URL cannot opt out of TLS by using ?tls=0',"URL_INVALID");let t=dp(e.scheme,e.authority,e.path),r;try{r=IR(t,e.authToken)}catch(o){if(o instanceof yp){let n=e.scheme==="wss"?"https":"http",i=dp(n,e.authority,e.path);throw new Ce(`This environment does not support WebSockets, please switch to the HTTP client by using a "${n}:" URL (${JSON.stringify(i)}). For more information, please read ${Yn}`,"WEBSOCKETS_NOT_SUPPORTED")}throw st(o)}return new fF(r,t,e.authToken,e.intMode,e.concurrency)}class fF{#e;#t;#r;#n;#o;closed;protocol;#i;#a;constructor(e,t,r,o,n){this.#e=t,this.#t=r,this.#r=o,this.#n=this.#c(e),this.#o=void 0,this.closed=!1,this.protocol="ws",this.#a=dF.default(n)}async limit(e){return this.#a(e)}async execute(e,t){let r;if(typeof e==="string")r={sql:e,args:t||[]};else r=e;return this.limit(async()=>{let o=await this.#s();try{let n=Zo(r);o.conn.sqlCache.apply([n]);let i=o.stream.query(n);o.stream.closeGracefully();let s=await i;return Il(s)}catch(n){throw st(n)}finally{this._closeStream(o)}})}async batch(e,t="deferred"){return this.limit(async()=>{let r=await this.#s();try{let n=e.map((u)=>{if(Array.isArray(u))return{sql:u[0],args:u[1]||[]};return u}).map(Zo),i=await r.conn.client.getVersion();r.conn.sqlCache.apply(n);let s=r.stream.batch(i>=3);return await kl(t,i,s,n)}catch(o){throw st(o)}finally{this._closeStream(r)}})}async migrate(e){return this.limit(async()=>{let t=await this.#s();try{let r=e.map(Zo),o=await t.conn.client.getVersion(),n=t.stream.batch(o>=3);return await kl("deferred",o,n,r,!0)}catch(r){throw st(r)}finally{this._closeStream(t)}})}async transaction(e="write"){return this.limit(async()=>{let t=await this.#s();try{let r=await t.conn.client.getVersion();return new mF(this,t,e,r)}catch(r){throw this._closeStream(t),st(r)}})}async executeMultiple(e){return this.limit(async()=>{let t=await this.#s();try{let r=t.stream.sequence(e);t.stream.closeGracefully(),await r}catch(r){throw st(r)}finally{this._closeStream(t)}})}sync(){throw new Ce("sync not supported in ws mode","SYNC_NOT_SUPPORTED")}async#s(){if(this.closed)throw new Ce("The client is closed","CLIENT_CLOSED");if(new Date().valueOf()-this.#n.openTime.valueOf()>bme&&this.#o===void 0){let o=this.#c();this.#o=o,o.client.getVersion().then((n)=>{if(this.#n!==o){if(this.#n.streamStates.size===0)this.#n.client.close()}this.#n=o,this.#o=void 0},(n)=>{this.#o=void 0})}if(this.#n.client.closed)try{if(this.#o!==void 0)this.#n=this.#o;else this.#n=this.#c()}catch(o){throw st(o)}let r=this.#n;try{if(r.useSqlCache===void 0){if(r.useSqlCache=await r.client.getVersion()>=2,r.useSqlCache)r.sqlCache.capacity=uF}let o=r.client.openStream();o.intMode=this.#r;let n={conn:r,stream:o};return r.streamStates.add(n),n}catch(o){throw st(o)}}#c(e){try{return e??=IR(this.#e,this.#t),{client:e,useSqlCache:void 0,sqlCache:new Al(e,0),openTime:new Date,streamStates:new Set}}catch(t){throw st(t)}}async reconnect(){try{for(let r of Array.from(this.#n.streamStates))try{r.stream.close()}catch{}this.#n.client.close()}catch{}if(this.#o){try{this.#o.client.close()}catch{}this.#o=void 0}let e=this.#c(),t=await e.client.getVersion();if(e.useSqlCache=t>=2,e.useSqlCache)e.sqlCache.capacity=uF;this.#n=e,this.closed=!1}_closeStream(e){e.stream.close();let t=e.conn;if(t.streamStates.delete(e),t.streamStates.size===0&&t!==this.#n)t.client.close()}close(){if(this.#n.client.close(),this.closed=!0,this.#o){try{this.#o.client.close()}catch{}this.#o=void 0}this.closed=!0}}var dF,bme=60000,uF=100,mF;var hF=v(()=>{Wy();vn();mp();RR();ky();dl();dF=ql($R(),1);vn();mF=class mF extends Op{#e;#t;constructor(e,t,r,o){super(r,o);this.#e=e,this.#t=t}_getStream(){return this.#t.stream}_getSqlCache(){return this.#t.conn.sqlCache}close(){this.#e._closeStream(this.#t)}get closed(){return this.#t.stream.closed}}});function yF(e){if(e.scheme!=="https"&&e.scheme!=="http")throw new Ce(`The HTTP client supports only "libsql:", "https:" and "http:" URLs, got ${JSON.stringify(e.scheme+":")}. For more information, please read ${Yn}`,"URL_SCHEME_NOT_SUPPORTED");if(e.encryptionKey!==void 0)throw new Ce("Encryption key is not supported by the remote client.","ENCRYPTION_KEY_NOT_SUPPORTED");if(e.scheme==="http"&&e.tls)throw new Ce('A "http:" URL cannot opt into TLS by using ?tls=1',"URL_INVALID");else if(e.scheme==="https"&&!e.tls)throw new Ce('A "https:" URL cannot opt out of TLS by using ?tls=0',"URL_INVALID");let t=dp(e.scheme,e.authority,e.path);return new SF(t,e.authToken,e.intMode,e.fetch,e.concurrency,e.remoteEncryptionKey)}class SF{#e;protocol;#t;#r;#n;#o;#i;#a;#s;constructor(e,t,r,o,n,i){this.#t=e,this.#i=t,this.#r=r,this.#n=o,this.#o=n,this.#a=i,this.#e=AR(this.#t,this.#i,this.#n,i),this.#e.intMode=this.#r,this.protocol="http",this.#s=gF.default(this.#o)}async limit(e){return this.#s(e)}async execute(e,t){let r;if(typeof e==="string")r={sql:e,args:t||[]};else r=e;return this.limit(async()=>{try{let o=Zo(r),n,i=this.#e.openStream();try{n=i.query(o)}finally{i.closeGracefully()}let s=await n;return Il(s)}catch(o){throw st(o)}})}async batch(e,t="deferred"){return this.limit(async()=>{try{let o=e.map((c)=>{if(Array.isArray(c))return{sql:c[0],args:c[1]||[]};return c}).map(Zo),n=await this.#e.getVersion(),i,s=this.#e.openStream();try{new Al(s,bF).apply(o);let u=s.batch(!1);i=kl(t,n,u,o)}finally{s.closeGracefully()}return await i}catch(r){throw st(r)}})}async migrate(e){return this.limit(async()=>{try{let t=e.map(Zo),r=await this.#e.getVersion(),o,n=this.#e.openStream();try{let s=n.batch(!1);o=kl("deferred",r,s,t,!0)}finally{n.closeGracefully()}return await o}catch(t){throw st(t)}})}async transaction(e="write"){return this.limit(async()=>{try{let t=await this.#e.getVersion();return new vF(this.#e.openStream(),e,t)}catch(t){throw st(t)}})}async executeMultiple(e){return this.limit(async()=>{try{let t,r=this.#e.openStream();try{t=r.sequence(e)}finally{r.closeGracefully()}await t}catch(t){throw st(t)}})}sync(){throw new Ce("sync not supported in http mode","SYNC_NOT_SUPPORTED")}close(){this.#e.close()}async reconnect(){try{if(!this.closed)this.#e.close()}finally{this.#e=AR(this.#t,this.#i,this.#n,this.#a),this.#e.intMode=this.#r}}get closed(){return this.#e.closed}}var gF,bF=30,vF;var wF=v(()=>{Wy();vn();mp();RR();ky();dl();gF=ql($R(),1);vn();vF=class vF extends Op{#e;#t;constructor(e,t,r){super(t,r);this.#e=e,this.#t=new Al(e,bF)}_getStream(){return this.#e}_getSqlCache(){return this.#t}close(){this.#e.close()}get closed(){return this.#e.closed}}});function Tl(e){return Sme(fp(e,!0))}function Sme(e){if(e.scheme==="wss"||e.scheme==="ws")return pF(e);else if(e.scheme==="https"||e.scheme==="http")return yF(e);else return g4(e)}var OR=v(()=>{mp();w4();hF();wF();vn()});function oe(e,t){if(!e||typeof e!=="object")return!1;if(e instanceof t)return!0;if(!Object.prototype.hasOwnProperty.call(t,F))throw Error(`Class "${t.name??"<unknown>"}" doesn't look like a Drizzle entity. If this is incorrect and the class is provided by Drizzle, please report this as a bug.`);let r=Object.getPrototypeOf(e).constructor;if(r)while(r){if(F in r&&r[F]===t[F])return!0;r=Object.getPrototypeOf(r)}return!1}var F;var $e=v(()=>{F=Symbol.for("drizzle:entityKind")});var Je;var _n=v(()=>{$e();Je=class Je{constructor(e,t){this.table=e,this.config=t,this.name=t.name,this.keyAsName=t.keyAsName,this.notNull=t.notNull,this.default=t.default,this.defaultFn=t.defaultFn,this.onUpdateFn=t.onUpdateFn,this.hasDefault=t.hasDefault,this.primary=t.primaryKey,this.isUnique=t.isUnique,this.uniqueName=t.uniqueName,this.uniqueType=t.uniqueType,this.dataType=t.dataType,this.columnType=t.columnType,this.generated=t.generated,this.generatedIdentity=t.generatedIdentity}static[F]="Column";name;keyAsName;primary;notNull;default;defaultFn;onUpdateFn;hasDefault;isUnique;uniqueName;uniqueType;dataType;columnType;enumValues=void 0;generated=void 0;generatedIdentity=void 0;config;mapFromDriverValue(e){return e}mapToDriverValue(e){return e}shouldDisableInsert(){return this.config.generated!==void 0&&this.config.generated.type!=="byDefault"}}});var Cp;var Gy=v(()=>{$e();Cp=class Cp{static[F]="ColumnBuilder";config;constructor(e,t,r){this.config={name:e,keyAsName:e==="",notNull:!1,default:void 0,hasDefault:!1,primaryKey:!1,isUnique:!1,uniqueName:void 0,uniqueType:void 0,dataType:t,columnType:r,generated:void 0}}$type(){return this}notNull(){return this.config.notNull=!0,this}default(e){return this.config.default=e,this.config.hasDefault=!0,this}$defaultFn(e){return this.config.defaultFn=e,this.config.hasDefault=!0,this}$default=this.$defaultFn;$onUpdateFn(e){return this.config.onUpdateFn=e,this.config.hasDefault=!0,this}$onUpdate=this.$onUpdateFn;primaryKey(){return this.config.primaryKey=!0,this.config.notNull=!0,this}setName(e){if(this.config.name!=="")return;this.config.name=e}}});var ir;var Rl=v(()=>{ir=Symbol.for("drizzle:Name")});var CR,xF;var _F=v(()=>{$e();Rl();CR=class CR{static[F]="PgForeignKeyBuilder";reference;_onUpdate="no action";_onDelete="no action";constructor(e,t){if(this.reference=()=>{let{name:r,columns:o,foreignColumns:n}=e();return{name:r,columns:o,foreignTable:n[0].table,foreignColumns:n}},t)this._onUpdate=t.onUpdate,this._onDelete=t.onDelete}onUpdate(e){return this._onUpdate=e===void 0?"no action":e,this}onDelete(e){return this._onDelete=e===void 0?"no action":e,this}build(e){return new xF(e,this)}};xF=class xF{constructor(e,t){this.table=e,this.reference=t.reference,this.onUpdate=t._onUpdate,this.onDelete=t._onDelete}static[F]="PgForeignKey";reference;onUpdate;onDelete;getName(){let{name:e,columns:t,foreignColumns:r}=this.reference(),o=t.map((s)=>s.name),n=r.map((s)=>s.name),i=[this.table[ir],...o,r[0].table[ir],...n];return e??`${i.join("_")}_fk`}}});function Qy(e,...t){return e(...t)}var PR=()=>{};function zR(e,t){return`${e[ir]}_${t.join("_")}_unique`}var EF,vme,kF;var IF=v(()=>{$e();Rl();EF=class EF{constructor(e,t){this.name=t,this.columns=e}static[F]="PgUniqueConstraintBuilder";columns;nullsNotDistinctConfig=!1;nullsNotDistinct(){return this.nullsNotDistinctConfig=!0,this}build(e){return new kF(e,this.columns,this.nullsNotDistinctConfig,this.name)}};vme=class vme{static[F]="PgUniqueOnConstraintBuilder";name;constructor(e){this.name=e}on(...e){return new EF(e,this.name)}};kF=class kF{constructor(e,t,r,o){this.table=e,this.columns=t,this.name=o??zR(this.table,this.columns.map((n)=>n.name)),this.nullsNotDistinct=r}static[F]="PgUniqueConstraint";columns;name;nullsNotDistinct=!1;getName(){return this.name}}});function AF(e,t,r){for(let o=t;o<e.length;o++){let n=e[o];if(n==="\\"){o++;continue}if(n==='"')return[e.slice(t,o).replace(/\\/g,""),o+1];if(r)continue;if(n===","||n==="}")return[e.slice(t,o).replace(/\\/g,""),o]}return[e.slice(t).replace(/\\/g,""),e.length]}function TF(e,t=0){let r=[],o=t,n=!1;while(o<e.length){let i=e[o];if(i===","){if(n||o===t)r.push("");n=!0,o++;continue}if(n=!1,i==="\\"){o+=2;continue}if(i==='"'){let[c,u]=AF(e,o+1,!0);r.push(c),o=u;continue}if(i==="}")return[r,o+1];if(i==="{"){let[c,u]=TF(e,o+1);r.push(c),o=u;continue}let[s,a]=AF(e,o,!1);r.push(s),o=a}return[r,o]}function RF(e){let[t]=TF(e,1);return t}function NR(e){return`{${e.map((t)=>{if(Array.isArray(t))return NR(t);if(typeof t==="string")return`"${t.replace(/\\/g,"\\\\").replace(/"/g,"\\\"")}"`;return`${t}`}).join(",")}}`}var $F=()=>{};var Pp,$l,OF,wme,CF,DR;var PF=v(()=>{Gy();_n();$e();_F();PR();IF();$F();Pp=class Pp extends Cp{foreignKeyConfigs=[];static[F]="PgColumnBuilder";array(e){return new CF(this.config.name,this,e)}references(e,t={}){return this.foreignKeyConfigs.push({ref:e,actions:t}),this}unique(e,t){return this.config.isUnique=!0,this.config.uniqueName=e,this.config.uniqueType=t?.nulls,this}generatedAlwaysAs(e){return this.config.generated={as:e,type:"always",mode:"stored"},this}buildForeignKeys(e,t){return this.foreignKeyConfigs.map(({ref:r,actions:o})=>Qy((n,i)=>{let s=new CR(()=>{let a=n();return{columns:[e],foreignColumns:[a]}});if(i.onUpdate)s.onUpdate(i.onUpdate);if(i.onDelete)s.onDelete(i.onDelete);return s.build(t)},r,o))}buildExtraConfigColumn(e){return new OF(e,this.config)}};$l=class $l extends Je{constructor(e,t){if(!t.uniqueName)t.uniqueName=zR(e,[t.name]);super(e,t);this.table=e}static[F]="PgColumn"};OF=class OF extends $l{static[F]="ExtraConfigColumn";getSQLType(){return this.getSQLType()}indexConfig={order:this.config.order??"asc",nulls:this.config.nulls??"last",opClass:this.config.opClass};defaultConfig={order:"asc",nulls:"last",opClass:void 0};asc(){return this.indexConfig.order="asc",this}desc(){return this.indexConfig.order="desc",this}nullsFirst(){return this.indexConfig.nulls="first",this}nullsLast(){return this.indexConfig.nulls="last",this}op(e){return this.indexConfig.opClass=e,this}};wme=class wme{static[F]="IndexedColumn";constructor(e,t,r,o){this.name=e,this.keyAsName=t,this.type=r,this.indexConfig=o}name;keyAsName;type;indexConfig};CF=class CF extends Pp{static[F]="PgArrayBuilder";constructor(e,t,r){super(e,"array","PgArray");this.config.baseBuilder=t,this.config.size=r}build(e){let t=this.config.baseBuilder.build(e);return new DR(e,this.config,t)}};DR=class DR extends $l{constructor(e,t,r,o){super(e,t);this.baseColumn=r,this.range=o,this.size=t.size}size;static[F]="PgArray";getSQLType(){return`${this.baseColumn.getSQLType()}[${typeof this.size==="number"?this.size:""}]`}mapFromDriverValue(e){if(typeof e==="string")e=RF(e);return e.map((t)=>this.baseColumn.mapFromDriverValue(t))}mapToDriverValue(e,t=!1){let r=e.map((o)=>o===null?null:oe(this.baseColumn,DR)?this.baseColumn.mapToDriverValue(o,!0):this.baseColumn.mapToDriverValue(o));if(t)return r;return NR(r)}}});function DF(e){return!!e&&typeof e==="function"&&zF in e&&e[zF]===!0}var xme,NF,zF,_me,LF;var BF=v(()=>{$e();PF();xme=class xme extends Pp{static[F]="PgEnumObjectColumnBuilder";constructor(e,t){super(e,"string","PgEnumObjectColumn");this.config.enum=t}build(e){return new NF(e,this.config)}};NF=class NF extends $l{static[F]="PgEnumObjectColumn";enum;enumValues=this.config.enum.enumValues;constructor(e,t){super(e,t);this.enum=t.enum}getSQLType(){return this.enum.enumName}};zF=Symbol.for("drizzle:isPgEnum");_me=class _me extends Pp{static[F]="PgEnumColumnBuilder";constructor(e,t){super(e,"string","PgEnumColumn");this.config.enum=t}build(e){return new LF(e,this.config)}};LF=class LF extends $l{static[F]="PgEnumColumn";enum=this.config.enum;enumValues=this.config.enum.enumValues;constructor(e,t){super(e,t);this.enum=t.enum}getSQLType(){return this.enum.enumName}}});var pt,zp;var En=v(()=>{$e();pt=class pt{static[F]="Subquery";constructor(e,t,r,o=!1,n=[]){this._={brand:"Subquery",sql:e,selectedFields:t,alias:r,isWith:o,usedTables:n}}};zp=class zp extends pt{static[F]="WithSubquery"}});var jF="0.45.2";var ZF=()=>{};var LR,BR,UF;var MF=v(()=>{PR();ZF();UF={startActiveSpan(e,t){if(!LR)return t();if(!BR)BR=LR.trace.getTracer("drizzle-orm",jF);return Qy((r,o)=>o.startActiveSpan(e,(n)=>{try{return t(n)}catch(i){throw n.setStatus({code:r.SpanStatusCode.ERROR,message:i instanceof Error?i.message:"Unknown error"}),i}finally{n.end()}}),LR,BR)}}});var ft;var Uo=v(()=>{ft=Symbol.for("drizzle:ViewBaseConfig")});function rs(e){return e[ir]}function ha(e){return`${e[Yy]??"public"}.${e[ir]}`}var Yy,Xy,qF,jR,ZR,Np,FF,Eme,he;var sr=v(()=>{$e();Rl();Yy=Symbol.for("drizzle:Schema"),Xy=Symbol.for("drizzle:Columns"),qF=Symbol.for("drizzle:ExtraConfigColumns"),jR=Symbol.for("drizzle:OriginalName"),ZR=Symbol.for("drizzle:BaseName"),Np=Symbol.for("drizzle:IsAlias"),FF=Symbol.for("drizzle:ExtraConfigBuilder"),Eme=Symbol.for("drizzle:IsDrizzleTable");he=class he{static[F]="Table";static Symbol={Name:ir,Schema:Yy,OriginalName:jR,Columns:Xy,ExtraConfigColumns:qF,BaseName:ZR,IsAlias:Np,ExtraConfigBuilder:FF};[ir];[jR];[Yy];[Xy];[qF];[ZR];[Np]=!1;[Eme]=!0;[FF]=void 0;constructor(e,t,r){this[ir]=this[jR]=e,this[Yy]=t,this[ZR]=r}}});function UR(e){return e!==null&&e!==void 0&&typeof e.getSQL==="function"}function Ime(e){let t={sql:"",params:[]};for(let r of e)if(t.sql+=r.sql,t.params.push(...r.params),r.typings?.length){if(!t.typings)t.typings=[];t.typings.push(...r.typings)}return t}function KF(e){return typeof e==="object"&&e!==null&&"mapToDriverValue"in e&&typeof e.mapToDriverValue==="function"}function C(e,...t){let r=[];if(t.length>0||e.length>0&&e[0]!=="")r.push(new Nt(e[0]));for(let[o,n]of t.entries())r.push(n,new Nt(e[o+1]));return new _e(r)}function Dp(e,t){return e.map((r)=>{if(oe(r,ns)){if(!(r.name in t))throw Error(`No value for placeholder "${r.name}" was provided`);return t[r.name]}if(oe(r,Ur)&&oe(r.value,ns)){if(!(r.value.name in t))throw Error(`No value for placeholder "${r.value.name}" was provided`);return r.encoder.mapToDriverValue(t[r.value.name])}return r})}var kme,Nt,_e,eb,HF,JF,ije,Ur,ns,Ame,an;var Yt=v(()=>{$e();BF();En();MF();Uo();_n();sr();kme=class kme{static[F]="FakePrimitiveParam"};Nt=class Nt{static[F]="StringChunk";value;constructor(e){this.value=Array.isArray(e)?e:[e]}getSQL(){return new _e([this])}};_e=class _e{constructor(e){this.queryChunks=e;for(let t of e)if(oe(t,he)){let r=t[he.Symbol.Schema];this.usedTables.push(r===void 0?t[he.Symbol.Name]:r+"."+t[he.Symbol.Name])}}static[F]="SQL";decoder=HF;shouldInlineParams=!1;usedTables=[];append(e){return this.queryChunks.push(...e.queryChunks),this}toQuery(e){return UF.startActiveSpan("drizzle.buildSQL",(t)=>{let r=this.buildQueryFromSourceParams(this.queryChunks,e);return t?.setAttributes({"drizzle.query.text":r.sql,"drizzle.query.params":JSON.stringify(r.params)}),r})}buildQueryFromSourceParams(e,t){let r=Object.assign({},t,{inlineParams:t.inlineParams||this.shouldInlineParams,paramStartIndex:t.paramStartIndex||{value:0}}),{casing:o,escapeName:n,escapeParam:i,prepareTyping:s,inlineParams:a,paramStartIndex:c}=r;return Ime(e.map((u)=>{if(oe(u,Nt))return{sql:u.value.join(""),params:[]};if(oe(u,eb))return{sql:n(u.value),params:[]};if(u===void 0)return{sql:"",params:[]};if(Array.isArray(u)){let d=[new Nt("(")];for(let[p,m]of u.entries())if(d.push(m),p<u.length-1)d.push(new Nt(", "));return d.push(new Nt(")")),this.buildQueryFromSourceParams(d,r)}if(oe(u,_e))return this.buildQueryFromSourceParams(u.queryChunks,{...r,inlineParams:a||u.shouldInlineParams});if(oe(u,he)){let d=u[he.Symbol.Schema],p=u[he.Symbol.Name];return{sql:d===void 0||u[Np]?n(p):n(d)+"."+n(p),params:[]}}if(oe(u,Je)){let d=o.getColumnCasing(u);if(t.invokeSource==="indexes")return{sql:n(d),params:[]};let p=u.table[he.Symbol.Schema];return{sql:u.table[Np]||p===void 0?n(u.table[he.Symbol.Name])+"."+n(d):n(p)+"."+n(u.table[he.Symbol.Name])+"."+n(d),params:[]}}if(oe(u,an)){let d=u[ft].schema,p=u[ft].name;return{sql:d===void 0||u[ft].isAlias?n(p):n(d)+"."+n(p),params:[]}}if(oe(u,Ur)){if(oe(u.value,ns))return{sql:i(c.value++,u),params:[u],typings:["none"]};let d=u.value===null?null:u.encoder.mapToDriverValue(u.value);if(oe(d,_e))return this.buildQueryFromSourceParams([d],r);if(a)return{sql:this.mapInlineParam(d,r),params:[]};let p=["none"];if(s)p=[s(u.encoder)];return{sql:i(c.value++,d),params:[d],typings:p}}if(oe(u,ns))return{sql:i(c.value++,u),params:[u],typings:["none"]};if(oe(u,_e.Aliased)&&u.fieldAlias!==void 0)return{sql:n(u.fieldAlias),params:[]};if(oe(u,pt)){if(u._.isWith)return{sql:n(u._.alias),params:[]};return this.buildQueryFromSourceParams([new Nt("("),u._.sql,new Nt(") "),new eb(u._.alias)],r)}if(DF(u)){if(u.schema)return{sql:n(u.schema)+"."+n(u.enumName),params:[]};return{sql:n(u.enumName),params:[]}}if(UR(u)){if(u.shouldOmitSQLParens?.())return this.buildQueryFromSourceParams([u.getSQL()],r);return this.buildQueryFromSourceParams([new Nt("("),u.getSQL(),new Nt(")")],r)}if(a)return{sql:this.mapInlineParam(u,r),params:[]};return{sql:i(c.value++,u),params:[u],typings:["none"]}}))}mapInlineParam(e,{escapeString:t}){if(e===null)return"null";if(typeof e==="number"||typeof e==="boolean")return e.toString();if(typeof e==="string")return t(e);if(typeof e==="object"){let r=e.toString();if(r==="[object Object]")return t(JSON.stringify(e));return t(r)}throw Error("Unexpected param value: "+e)}getSQL(){return this}as(e){if(e===void 0)return this;return new _e.Aliased(this,e)}mapWith(e){return this.decoder=typeof e==="function"?{mapFromDriverValue:e}:e,this}inlineParams(){return this.shouldInlineParams=!0,this}if(e){return e?this:void 0}};eb=class eb{constructor(e){this.value=e}static[F]="Name";brand;getSQL(){return new _e([this])}};HF={mapFromDriverValue:(e)=>e},JF={mapToDriverValue:(e)=>e},ije={...HF,...JF};Ur=class Ur{constructor(e,t=JF){this.value=e,this.encoder=t}static[F]="Param";brand;getSQL(){return new _e([this])}};((e)=>{function t(){return new _e([])}e.empty=t;function r(c){return new _e(c)}e.fromList=r;function o(c){return new _e([new Nt(c)])}e.raw=o;function n(c,u){let d=[];for(let[p,m]of c.entries()){if(p>0&&u!==void 0)d.push(u);d.push(m)}return new _e(d)}e.join=n;function i(c){return new eb(c)}e.identifier=i;function s(c){return new ns(c)}e.placeholder=s;function a(c,u){return new Ur(c,u)}e.param=a})(C||(C={}));((e)=>{class t{constructor(r,o){this.sql=r,this.fieldAlias=o}static[F]="SQL.Aliased";isSelectionField=!1;getSQL(){return this.sql}clone(){return new t(this.sql,this.fieldAlias)}}e.Aliased=t})(_e||(_e={}));ns=class ns{constructor(e){this.name=e}static[F]="Placeholder";getSQL(){return new _e([this])}};Ame=Symbol.for("drizzle:IsDrizzleView");an=class an{static[F]="View";[ft];[Ame]=!0;constructor({name:e,schema:t,selectedFields:r,query:o}){this[ft]={name:e,originalName:e,schema:t,selectedFields:r,query:o,isExisting:!o,isAlias:!1}}getSQL(){return new _e([this])}};Je.prototype.getSQL=function(){return new _e([this])};he.prototype.getSQL=function(){return new _e([this])};pt.prototype.getSQL=function(){return new _e([this])}});function MR(e,t,r){let o={},n=e.reduce((i,{path:s,field:a},c)=>{let u;if(oe(a,Je))u=a;else if(oe(a,_e))u=a.decoder;else if(oe(a,pt))u=a._.sql.decoder;else u=a.sql.decoder;let d=i;for(let[p,m]of s.entries())if(p<s.length-1){if(!(m in d))d[m]={};d=d[m]}else{let h=t[c],b=d[m]=h===null?null:u.mapFromDriverValue(h);if(r&&oe(a,Je)&&s.length===2){let y=s[0];if(!(y in o))o[y]=b===null?rs(a.table):!1;else if(typeof o[y]==="string"&&o[y]!==rs(a.table))o[y]=!1}}return i},{});if(r&&Object.keys(o).length>0){for(let[i,s]of Object.entries(o))if(typeof s==="string"&&!r[s])n[i]=null}return n}function cn(e,t){return Object.entries(e).reduce((r,[o,n])=>{if(typeof o!=="string")return r;let i=t?[...t,o]:[o];if(oe(n,Je)||oe(n,_e)||oe(n,_e.Aliased)||oe(n,pt))r.push({path:i,field:n});else if(oe(n,he))r.push(...cn(n[he.Symbol.Columns],i));else r.push(...cn(n,i));return r},[])}function Lp(e,t){let r=Object.keys(e),o=Object.keys(t);if(r.length!==o.length)return!1;for(let[n,i]of r.entries())if(i!==o[n])return!1;return!0}function tb(e,t){let r=Object.entries(t).filter(([,o])=>o!==void 0).map(([o,n])=>{if(oe(n,_e)||oe(n,Je))return[o,n];else return[o,new Ur(n,e[he.Symbol.Columns][o])]});if(r.length===0)throw Error("No values to set");return Object.fromEntries(r)}function VF(e,t){for(let r of t)for(let o of Object.getOwnPropertyNames(r.prototype)){if(o==="constructor")continue;Object.defineProperty(e.prototype,o,Object.getOwnPropertyDescriptor(r.prototype,o)||Object.create(null))}}function rb(e){return e[he.Symbol.Columns]}function Bp(e){return oe(e,pt)?e._.alias:oe(e,an)?e[ft].name:oe(e,_e)?void 0:e[he.Symbol.IsAlias]?e[he.Symbol.Name]:e[he.Symbol.BaseName]}function ro(e,t){return{name:typeof e==="string"&&e.length>0?e:"",config:typeof e==="object"?e:t}}function WF(e){if(typeof e!=="object"||e===null)return!1;if(e.constructor.name!=="Object")return!1;if("logger"in e){let t=typeof e.logger;if(t!=="boolean"&&(t!=="object"||typeof e.logger.logQuery!=="function")&&t!=="undefined")return!1;return!0}if("schema"in e){let t=typeof e.schema;if(t!=="object"&&t!=="undefined")return!1;return!0}if("casing"in e){let t=typeof e.casing;if(t!=="string"&&t!=="undefined")return!1;return!0}if("mode"in e){if(e.mode!=="default"||e.mode!=="planetscale"||e.mode!==void 0)return!1;return!0}if("connection"in e){let t=typeof e.connection;if(t!=="string"&&t!=="object"&&t!=="undefined")return!1;return!0}if("client"in e){let t=typeof e.client;if(t!=="object"&&t!=="function"&&t!=="undefined")return!1;return!0}if(Object.keys(e).length===0)return!0;return!1}var qR;var Sr=v(()=>{_n();$e();Yt();En();sr();Uo();qR=typeof TextDecoder>"u"?null:new TextDecoder});var GF,FR,KR;var nb=v(()=>{$e();GF=class GF{static[F]="ConsoleLogWriter";write(e){console.log(e)}};FR=class FR{static[F]="DefaultLogger";writer;constructor(e){this.writer=e?.writer??new GF}logQuery(e,t){let r=t.map((n)=>{try{return JSON.stringify(n)}catch{return String(n)}}),o=r.length?` -- params: [${r.join(", ")}]`:"";this.writer.write(`Query: ${e}${o}`)}};KR=class KR{static[F]="NoopLogger";logQuery(){}}});var QF,YF,HR;var XF=v(()=>{$e();sr();QF=Symbol.for("drizzle:PgInlineForeignKeys"),YF=Symbol.for("drizzle:EnableRLS");HR=class HR extends he{static[F]="PgTable";static Symbol=Object.assign({},he.Symbol,{InlineForeignKeys:QF,EnableRLS:YF});[QF]=[];[YF]=!1;[he.Symbol.ExtraConfigBuilder]=void 0;[he.Symbol.ExtraConfigColumns]={}}});var JR,e3;var t3=v(()=>{$e();XF();JR=class JR{static[F]="PgPrimaryKeyBuilder";columns;name;constructor(e,t){this.columns=e,this.name=t}build(e){return new e3(e,this.columns,this.name)}};e3=class e3{constructor(e,t,r){this.table=e,this.columns=t,this.name=r}static[F]="PgPrimaryKey";columns;name;getName(){return this.name??`${this.table[HR.Symbol.Name]}_${this.columns.map((e)=>e.name).join("_")}_pk`}}});function Rr(e,t){if(KF(t)&&!UR(e)&&!oe(e,Ur)&&!oe(e,ns)&&!oe(e,Je)&&!oe(e,he)&&!oe(e,an))return new Ur(e,t);return e}function tt(...e){let t=e.filter((r)=>r!==void 0);if(t.length===0)return;if(t.length===1)return new _e(t);return new _e([new Nt("("),C.join(t,new Nt(" and ")),new Nt(")")])}function ln(...e){let t=e.filter((r)=>r!==void 0);if(t.length===0)return;if(t.length===1)return new _e(t);return new _e([new Nt("("),C.join(t,new Nt(" or ")),new Nt(")")])}function n3(e){return C`not ${e}`}function is(e,t){if(Array.isArray(t)){if(t.length===0)return C`false`;return C`${e} in ${t.map((r)=>Rr(r,e))}`}return C`${e} in ${Rr(t,e)}`}function ob(e,t){if(Array.isArray(t)){if(t.length===0)return C`true`;return C`${e} not in ${t.map((r)=>Rr(r,e))}`}return C`${e} not in ${Rr(t,e)}`}function Mr(e){return C`${e} is null`}function s3(e){return C`${e} is not null`}function ib(e){return C`exists ${e}`}function ss(e){return C`not exists ${e}`}function a3(e,t,r){return C`${e} between ${Rr(t,e)} and ${Rr(r,e)}`}function c3(e,t,r){return C`${e} not between ${Rr(t,e)} and ${Rr(r,e)}`}function l3(e,t){return C`${e} like ${t}`}function u3(e,t){return C`${e} not like ${t}`}function d3(e,t){return C`${e} ilike ${t}`}function p3(e,t){return C`${e} not ilike ${t}`}var je=(e,t)=>C`${e} = ${Rr(t,e)}`,r3=(e,t)=>C`${e} <> ${Rr(t,e)}`,kn=(e,t)=>C`${e} > ${Rr(t,e)}`,o3=(e,t)=>C`${e} >= ${Rr(t,e)}`,i3=(e,t)=>C`${e} < ${Rr(t,e)}`,os=(e,t)=>C`${e} <= ${Rr(t,e)}`;var f3=v(()=>{_n();$e();sr();Yt()});function Mo(e){return C`${e} asc`}function ga(e){return C`${e} desc`}var m3=v(()=>{Yt()});var VR=v(()=>{f3();m3()});function g3(){return{and:tt,between:a3,eq:je,exists:ib,gt:kn,gte:o3,ilike:d3,inArray:is,isNull:Mr,isNotNull:s3,like:l3,lt:i3,lte:os,ne:r3,not:n3,notBetween:c3,notExists:ss,notLike:u3,notIlike:p3,notInArray:ob,or:ln,sql:C}}function y3(){return{sql:C,asc:Mo,desc:ga}}function b3(e,t){if(Object.keys(e).length===1&&"default"in e&&!oe(e.default,he))e=e.default;let r={},o={},n={};for(let[i,s]of Object.entries(e))if(oe(s,he)){let a=ha(s),c=o[a];r[a]=i,n[i]={tsName:i,dbName:s[he.Symbol.Name],schema:s[he.Symbol.Schema],columns:s[he.Symbol.Columns],relations:c?.relations??{},primaryKey:c?.primaryKey??[]};for(let d of Object.values(s[he.Symbol.Columns]))if(d.primary)n[i].primaryKey.push(d);let u=s[he.Symbol.ExtraConfigBuilder]?.(s[he.Symbol.ExtraConfigColumns]);if(u){for(let d of Object.values(u))if(oe(d,JR))n[i].primaryKey.push(...d.columns)}}else if(oe(s,h3)){let a=ha(s.table),c=r[a],u=s.config(t(s.table)),d;for(let[p,m]of Object.entries(u))if(c){let h=n[c];if(h.relations[p]=m,d)h.primaryKey.push(...d)}else{if(!(a in o))o[a]={relations:{},primaryKey:d};o[a].relations[p]=m}}return{tables:n,tableNamesMap:r}}function Tme(e){return function(r,o){return new as(e,r,o,o?.fields.reduce((n,i)=>n&&i.notNull,!0)??!1)}}function Rme(e){return function(r,o){return new jp(e,r,o)}}function S3(e,t,r){if(oe(r,as)&&r.config)return{fields:r.config.fields,references:r.config.references};let o=t[ha(r.referencedTable)];if(!o)throw Error(`Table "${r.referencedTable[he.Symbol.Name]}" not found in schema`);let n=e[o];if(!n)throw Error(`Table "${o}" not found in schema`);let i=r.sourceTable,s=t[ha(i)];if(!s)throw Error(`Table "${i[he.Symbol.Name]}" not found in schema`);let a=[];for(let c of Object.values(n.relations))if(r.relationName&&r!==c&&c.relationName===r.relationName||!r.relationName&&c.referencedTable===r.sourceTable)a.push(c);if(a.length>1)throw r.relationName?Error(`There are multiple relations with name "${r.relationName}" in table "${o}"`):Error(`There are multiple relations between "${o}" and "${r.sourceTable[he.Symbol.Name]}". Please specify relation name`);if(a[0]&&oe(a[0],as)&&a[0].config)return{fields:a[0].config.references,references:a[0].config.fields};throw Error(`There is not enough information to infer relation "${s}.${r.fieldName}"`)}function v3(e){return{one:Tme(e),many:Rme(e)}}function sb(e,t,r,o,n=(i)=>i){let i={};for(let[s,a]of o.entries())if(a.isJson){let c=t.relations[a.tsKey],u=r[s],d=typeof u==="string"?JSON.parse(u):u;i[a.tsKey]=oe(c,as)?d&&sb(e,e[a.relationTableTsKey],d,a.selection,n):d.map((p)=>sb(e,e[a.relationTableTsKey],p,a.selection,n))}else{let c=n(r[s]),u=a.field,d;if(oe(u,Je))d=u;else if(oe(u,_e))d=u.decoder;else d=u.sql.decoder;i[a.tsKey]=c===null?null:d.mapFromDriverValue(c)}return i}var WR,h3,as,jp;var Zp=v(()=>{sr();_n();$e();t3();VR();Yt();WR=class WR{constructor(e,t,r){this.sourceTable=e,this.referencedTable=t,this.relationName=r,this.referencedTableName=t[he.Symbol.Name]}static[F]="Relation";referencedTableName;fieldName};h3=class h3{constructor(e,t){this.table=e,this.config=t}static[F]="Relations"};as=class as extends WR{constructor(e,t,r,o){super(e,t,r?.relationName);this.config=r,this.isNullable=o}static[F]="One";withFieldName(e){let t=new as(this.sourceTable,this.referencedTable,this.config,this.isNullable);return t.fieldName=e,t}};jp=class jp extends WR{constructor(e,t,r){super(e,t,r?.relationName);this.config=r}static[F]="Many";withFieldName(e){let t=new jp(this.sourceTable,this.referencedTable,this.config);return t.fieldName=e,t}}});function Up(e,t){return new Proxy(e,new ya(t,!1))}function no(e,t){return new Proxy(e,new Ol(new Proxy(e.table,new ya(t,!1))))}function GR(e,t){return new _e.Aliased(Mp(e.sql,t),e.fieldAlias)}function Mp(e,t){return C.join(e.queryChunks.map((r)=>{if(oe(r,Je))return no(r,t);if(oe(r,_e))return Mp(r,t);if(oe(r,_e.Aliased))return GR(r,t);return r}))}var Ol,ya,$me;var qp=v(()=>{_n();$e();Yt();sr();Uo();Ol=class Ol{constructor(e){this.table=e}static[F]="ColumnAliasProxyHandler";get(e,t){if(t==="table")return this.table;return e[t]}};ya=class ya{constructor(e,t){this.alias=e,this.replaceOriginalName=t}static[F]="TableAliasProxyHandler";get(e,t){if(t===he.Symbol.IsAlias)return!0;if(t===he.Symbol.Name)return this.alias;if(this.replaceOriginalName&&t===he.Symbol.OriginalName)return this.alias;if(t===ft)return{...e[ft],name:this.alias,isAlias:!0};if(t===he.Symbol.Columns){let o=e[he.Symbol.Columns];if(!o)return o;let n={};return Object.keys(o).map((i)=>{n[i]=new Proxy(o[i],new Ol(new Proxy(e,this)))}),n}let r=e[t];if(oe(r,Je))return new Proxy(r,new Ol(new Proxy(e,this)));return r}};$me=class $me{constructor(e){this.alias=e}static[F]="RelationTableAliasProxyHandler";get(e,t){if(t==="sourceTable")return Up(e.sourceTable,this.alias);return e[t]}}});var at;var ba=v(()=>{qp();_n();$e();Yt();En();Uo();at=class at{static[F]="SelectionProxyHandler";config;constructor(e){this.config={...e}}get(e,t){if(t==="_")return{...e._,selectedFields:new Proxy(e._.selectedFields,this)};if(t===ft)return{...e[ft],selectedFields:new Proxy(e[ft].selectedFields,this)};if(typeof t==="symbol")return e[t];let o=(oe(e,pt)?e._.selectedFields:oe(e,an)?e[ft].selectedFields:e)[t];if(oe(o,_e.Aliased)){if(this.config.sqlAliasedBehavior==="sql"&&!o.isSelectionField)return o.sql;let n=o.clone();return n.isSelectionField=!0,n}if(oe(o,_e)){if(this.config.sqlBehavior==="sql")return o;throw Error(`You tried to reference "${t}" field from a subquery, which is a raw SQL field, but it doesn't have an alias declared. Please add an alias to the field using ".as('alias')" method.`)}if(oe(o,Je)){if(this.config.alias)return new Proxy(o,new Ol(new Proxy(o.table,new ya(this.config.alias,this.config.replaceOriginalName??!1))));return o}if(typeof o!=="object"||o===null)return o;return new Proxy(o,new at(this.config))}}});var vr;var qo=v(()=>{$e();vr=class vr{static[F]="QueryPromise";[Symbol.toStringTag]="QueryPromise";catch(e){return this.then(void 0,e)}finally(e){return this.then((t)=>(e?.(),t),(t)=>{throw e?.(),t})}then(e,t){return this.execute().then(e,t)}}});var QR,w3;var YR=v(()=>{$e();Rl();QR=class QR{static[F]="SQLiteForeignKeyBuilder";reference;_onUpdate;_onDelete;constructor(e,t){if(this.reference=()=>{let{name:r,columns:o,foreignColumns:n}=e();return{name:r,columns:o,foreignTable:n[0].table,foreignColumns:n}},t)this._onUpdate=t.onUpdate,this._onDelete=t.onDelete}onUpdate(e){return this._onUpdate=e,this}onDelete(e){return this._onDelete=e,this}build(e){return new w3(e,this)}};w3=class w3{constructor(e,t){this.table=e,this.reference=t.reference,this.onUpdate=t._onUpdate,this.onDelete=t._onDelete}static[F]="SQLiteForeignKey";reference;onUpdate;onDelete;getName(){let{name:e,columns:t,foreignColumns:r}=this.reference(),o=t.map((s)=>s.name),n=r.map((s)=>s.name),i=[this.table[ir],...o,r[0].table[ir],...n];return e??`${i.join("_")}_fk`}}});function XR(e,t){return`${e[ir]}_${t.join("_")}_unique`}var x3,Ome,_3;var e$=v(()=>{$e();Rl();x3=class x3{constructor(e,t){this.name=t,this.columns=e}static[F]="SQLiteUniqueConstraintBuilder";columns;build(e){return new _3(e,this.columns,this.name)}};Ome=class Ome{static[F]="SQLiteUniqueOnConstraintBuilder";name;constructor(e){this.name=e}on(...e){return new x3(e,this.name)}};_3=class _3{constructor(e,t,r){this.table=e,this.columns=t,this.name=r??XR(this.table,this.columns.map((o)=>o.name))}static[F]="SQLiteUniqueConstraint";columns;name;getName(){return this.name}}});var Ut,bt;var cs=v(()=>{Gy();_n();$e();YR();e$();Ut=class Ut extends Cp{static[F]="SQLiteColumnBuilder";foreignKeyConfigs=[];references(e,t={}){return this.foreignKeyConfigs.push({ref:e,actions:t}),this}unique(e){return this.config.isUnique=!0,this.config.uniqueName=e,this}generatedAlwaysAs(e,t){return this.config.generated={as:e,type:"always",mode:t?.mode??"virtual"},this}buildForeignKeys(e,t){return this.foreignKeyConfigs.map(({ref:r,actions:o})=>((n,i)=>{let s=new QR(()=>{let a=n();return{columns:[e],foreignColumns:[a]}});if(i.onUpdate)s.onUpdate(i.onUpdate);if(i.onDelete)s.onDelete(i.onDelete);return s.build(t)})(r,o))}};bt=class bt extends Je{constructor(e,t){if(!t.uniqueName)t.uniqueName=XR(e,[t.name]);super(e,t);this.table=e}static[F]="SQLiteColumn"}});function $3(e,t){let{name:r,config:o}=ro(e,t);if(o?.mode==="json")return new I3(r);if(o?.mode==="bigint")return new E3(r);return new T3(r)}var E3,k3,I3,A3,T3,R3;var t$=v(()=>{$e();Sr();cs();E3=class E3 extends Ut{static[F]="SQLiteBigIntBuilder";constructor(e){super(e,"bigint","SQLiteBigInt")}build(e){return new k3(e,this.config)}};k3=class k3 extends bt{static[F]="SQLiteBigInt";getSQLType(){return"blob"}mapFromDriverValue(e){if(typeof Buffer<"u"&&Buffer.from){let t=Buffer.isBuffer(e)?e:e instanceof ArrayBuffer?Buffer.from(e):e.buffer?Buffer.from(e.buffer,e.byteOffset,e.byteLength):Buffer.from(e);return BigInt(t.toString("utf8"))}return BigInt(qR.decode(e))}mapToDriverValue(e){return Buffer.from(e.toString())}};I3=class I3 extends Ut{static[F]="SQLiteBlobJsonBuilder";constructor(e){super(e,"json","SQLiteBlobJson")}build(e){return new A3(e,this.config)}};A3=class A3 extends bt{static[F]="SQLiteBlobJson";getSQLType(){return"blob"}mapFromDriverValue(e){if(typeof Buffer<"u"&&Buffer.from){let t=Buffer.isBuffer(e)?e:e instanceof ArrayBuffer?Buffer.from(e):e.buffer?Buffer.from(e.buffer,e.byteOffset,e.byteLength):Buffer.from(e);return JSON.parse(t.toString("utf8"))}return JSON.parse(qR.decode(e))}mapToDriverValue(e){return Buffer.from(JSON.stringify(e))}};T3=class T3 extends Ut{static[F]="SQLiteBlobBufferBuilder";constructor(e){super(e,"buffer","SQLiteBlobBuffer")}build(e){return new R3(e,this.config)}};R3=class R3 extends bt{static[F]="SQLiteBlobBuffer";mapFromDriverValue(e){if(Buffer.isBuffer(e))return e;return Buffer.from(e)}getSQLType(){return"blob"}}});function P3(e){return(t,r)=>{let{name:o,config:n}=ro(t,r);return new O3(o,n,e)}}var O3,C3;var r$=v(()=>{$e();Sr();cs();O3=class O3 extends Ut{static[F]="SQLiteCustomColumnBuilder";constructor(e,t,r){super(e,"custom","SQLiteCustomColumn");this.config.fieldConfig=t,this.config.customTypeParams=r}build(e){return new C3(e,this.config)}};C3=class C3 extends bt{static[F]="SQLiteCustomColumn";sqlName;mapTo;mapFrom;constructor(e,t){super(e,t);this.sqlName=t.customTypeParams.dataType(t.fieldConfig),this.mapTo=t.customTypeParams.toDriver,this.mapFrom=t.customTypeParams.fromDriver}getSQLType(){return this.sqlName}mapFromDriverValue(e){return typeof this.mapFrom==="function"?this.mapFrom(e):e}mapToDriverValue(e){return typeof this.mapTo==="function"?this.mapTo(e):e}}});function ar(e,t){let{name:r,config:o}=ro(e,t);if(o?.mode==="timestamp"||o?.mode==="timestamp_ms")return new D3(r,o.mode);if(o?.mode==="boolean")return new B3(r,o.mode);return new z3(r)}var ab,cb,z3,N3,D3,L3,B3,j3;var n$=v(()=>{$e();Yt();Sr();cs();ab=class ab extends Ut{static[F]="SQLiteBaseIntegerBuilder";constructor(e,t,r){super(e,t,r);this.config.autoIncrement=!1}primaryKey(e){if(e?.autoIncrement)this.config.autoIncrement=!0;return this.config.hasDefault=!0,super.primaryKey()}};cb=class cb extends bt{static[F]="SQLiteBaseInteger";autoIncrement=this.config.autoIncrement;getSQLType(){return"integer"}};z3=class z3 extends ab{static[F]="SQLiteIntegerBuilder";constructor(e){super(e,"number","SQLiteInteger")}build(e){return new N3(e,this.config)}};N3=class N3 extends cb{static[F]="SQLiteInteger"};D3=class D3 extends ab{static[F]="SQLiteTimestampBuilder";constructor(e,t){super(e,"date","SQLiteTimestamp");this.config.mode=t}defaultNow(){return this.default(C`(cast((julianday('now') - 2440587.5)*86400000 as integer))`)}build(e){return new L3(e,this.config)}};L3=class L3 extends cb{static[F]="SQLiteTimestamp";mode=this.config.mode;mapFromDriverValue(e){if(this.config.mode==="timestamp")return new Date(e*1000);return new Date(e)}mapToDriverValue(e){let t=e.getTime();if(this.config.mode==="timestamp")return Math.floor(t/1000);return t}};B3=class B3 extends ab{static[F]="SQLiteBooleanBuilder";constructor(e,t){super(e,"boolean","SQLiteBoolean");this.config.mode=t}build(e){return new j3(e,this.config)}};j3=class j3 extends cb{static[F]="SQLiteBoolean";mode=this.config.mode;mapFromDriverValue(e){return Number(e)===1}mapToDriverValue(e){return e?1:0}}});function H3(e,t){let{name:r,config:o}=ro(e,t),n=o?.mode;return n==="number"?new M3(r):n==="bigint"?new F3(r):new Z3(r)}var Z3,U3,M3,q3,F3,K3;var o$=v(()=>{$e();Sr();cs();Z3=class Z3 extends Ut{static[F]="SQLiteNumericBuilder";constructor(e){super(e,"string","SQLiteNumeric")}build(e){return new U3(e,this.config)}};U3=class U3 extends bt{static[F]="SQLiteNumeric";mapFromDriverValue(e){if(typeof e==="string")return e;return String(e)}getSQLType(){return"numeric"}};M3=class M3 extends Ut{static[F]="SQLiteNumericNumberBuilder";constructor(e){super(e,"number","SQLiteNumericNumber")}build(e){return new q3(e,this.config)}};q3=class q3 extends bt{static[F]="SQLiteNumericNumber";mapFromDriverValue(e){if(typeof e==="number")return e;return Number(e)}mapToDriverValue=String;getSQLType(){return"numeric"}};F3=class F3 extends Ut{static[F]="SQLiteNumericBigIntBuilder";constructor(e){super(e,"bigint","SQLiteNumericBigInt")}build(e){return new K3(e,this.config)}};K3=class K3 extends bt{static[F]="SQLiteNumericBigInt";mapFromDriverValue=BigInt;mapToDriverValue=String;getSQLType(){return"numeric"}}});function W3(e){return new J3(e??"")}var J3,V3;var i$=v(()=>{$e();cs();J3=class J3 extends Ut{static[F]="SQLiteRealBuilder";constructor(e){super(e,"number","SQLiteReal")}build(e){return new V3(e,this.config)}};V3=class V3 extends bt{static[F]="SQLiteReal";getSQLType(){return"real"}}});function mt(e,t={}){let{name:r,config:o}=ro(e,t);if(o.mode==="json")return new Y3(r);return new G3(r,o)}var G3,Q3,Y3,X3;var s$=v(()=>{$e();Sr();cs();G3=class G3 extends Ut{static[F]="SQLiteTextBuilder";constructor(e,t){super(e,"string","SQLiteText");this.config.enumValues=t.enum,this.config.length=t.length}build(e){return new Q3(e,this.config)}};Q3=class Q3 extends bt{static[F]="SQLiteText";enumValues=this.config.enumValues;length=this.config.length;constructor(e,t){super(e,t)}getSQLType(){return`text${this.config.length?`(${this.config.length})`:""}`}};Y3=class Y3 extends Ut{static[F]="SQLiteTextJsonBuilder";constructor(e){super(e,"json","SQLiteTextJson")}build(e){return new X3(e,this.config)}};X3=class X3 extends bt{static[F]="SQLiteTextJson";getSQLType(){return"text"}mapFromDriverValue(e){return JSON.parse(e)}mapToDriverValue(e){return JSON.stringify(e)}}});function e5(){return{blob:$3,customType:P3,integer:ar,numeric:H3,real:W3,text:mt}}var t5=v(()=>{t$();r$();n$();o$();i$();s$()});function Cme(e,t,r,o,n=e){let i=new At(e,o,n),s=typeof t==="function"?t(e5()):t,a=Object.fromEntries(Object.entries(s).map(([u,d])=>{let p=d;p.setName(u);let m=p.build(i);return i[a$].push(...p.buildForeignKeys(m,i)),[u,m]})),c=Object.assign(i,a);if(c[he.Symbol.Columns]=a,c[he.Symbol.ExtraConfigColumns]=a,r)c[At.Symbol.ExtraConfigBuilder]=r;return c}var a$,At,Fp=(e,t,r)=>Cme(e,t,r);var Fo=v(()=>{$e();sr();t5();a$=Symbol.for("drizzle:SQLiteInlineForeignKeys");At=class At extends he{static[F]="SQLiteTable";static Symbol=Object.assign({},he.Symbol,{InlineForeignKeys:a$});[he.Symbol.Columns];[a$]=[];[he.Symbol.ExtraConfigBuilder]=void 0}});var Pme,r5;var n5=v(()=>{$e();Pme=class Pme{constructor(e,t){this.name=e,this.value=t}static[F]="SQLiteCheckBuilder";brand;build(e){return new r5(e,this)}};r5=class r5{constructor(e,t){this.table=e,this.name=t.name,this.value=t.value}static[F]="SQLiteCheck";name;value}});function Ko(e){return new o5(e,!1)}var o5,i5,s5;var a5=v(()=>{$e();o5=class o5{constructor(e,t){this.name=e,this.unique=t}static[F]="SQLiteIndexBuilderOn";on(...e){return new i5(this.name,e,this.unique)}};i5=class i5{static[F]="SQLiteIndexBuilder";config;constructor(e,t,r){this.config={name:e,columns:t,unique:r,where:void 0}}where(e){return this.config.where=e,this}build(e){return new s5(this.config,e)}};s5=class s5{static[F]="SQLiteIndex";config;constructor(e,t){this.config={...e,table:t}}}});var zme,c5;var l5=v(()=>{$e();Fo();zme=class zme{static[F]="SQLitePrimaryKeyBuilder";columns;name;constructor(e,t){this.columns=e,this.name=t}build(e){return new c5(e,this.columns,this.name)}};c5=class c5{constructor(e,t,r){this.table=e,this.columns=t,this.name=r}static[F]="SQLitePrimaryKey";columns;name;getName(){return this.name??`${this.table[At.Symbol.Name]}_${this.columns.map((e)=>e.name).join("_")}_pk`}}});function In(e){if(oe(e,At))return[`${e[he.Symbol.BaseName]}`];if(oe(e,pt))return e._.usedTables??[];if(oe(e,_e))return e.usedTables??[];return[]}var Cl=v(()=>{$e();Yt();En();sr();Fo()});var lb;var u5=v(()=>{$e();qo();ba();Fo();sr();Sr();Cl();lb=class lb extends vr{constructor(e,t,r,o){super();this.table=e,this.session=t,this.dialect=r,this.config={table:e,withList:o}}static[F]="SQLiteDelete";config;where(e){return this.config.where=e,this}orderBy(...e){if(typeof e[0]==="function"){let t=e[0](new Proxy(this.config.table[he.Symbol.Columns],new at({sqlAliasedBehavior:"alias",sqlBehavior:"sql"}))),r=Array.isArray(t)?t:[t];this.config.orderBy=r}else{let t=e;this.config.orderBy=t}return this}limit(e){return this.config.limit=e,this}returning(e=this.table[At.Symbol.Columns]){return this.config.returning=cn(e),this}getSQL(){return this.dialect.buildDeleteQuery(this.config)}toSQL(){let{typings:e,...t}=this.dialect.sqlToQuery(this.getSQL());return t}_prepare(e=!0){return this.session[e?"prepareOneTimeQuery":"prepareQuery"](this.dialect.sqlToQuery(this.getSQL()),this.config.returning,this.config.returning?"all":"run",!0,void 0,{type:"delete",tables:In(this.config.table)})}prepare(){return this._prepare(!1)}run=(e)=>this._prepare().run(e);all=(e)=>this._prepare().all(e);get=(e)=>this._prepare().get(e);values=(e)=>this._prepare().values(e);async execute(e){return this._prepare().execute(e)}$dynamic(){return this}}});function Nme(e){return(e.replace(/['\u2019]/g,"").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).map((r)=>r.toLowerCase()).join("_")}function Dme(e){return(e.replace(/['\u2019]/g,"").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).reduce((r,o,n)=>{let i=n===0?o.toLowerCase():`${o[0].toUpperCase()}${o.slice(1)}`;return r+i},"")}function Lme(e){return e}var c$;var d5=v(()=>{$e();sr();c$=class c${static[F]="CasingCache";cache={};cachedTables={};convert;constructor(e){this.convert=e==="snake_case"?Nme:e==="camelCase"?Dme:Lme}getColumnCasing(e){if(!e.keyAsName)return e.name;let t=e.table[he.Symbol.Schema]??"public",r=e.table[he.Symbol.OriginalName],o=`${t}.${r}.${e.name}`;if(!this.cache[o])this.cacheTable(e.table);return this.cache[o]}cacheTable(e){let t=e[he.Symbol.Schema]??"public",r=e[he.Symbol.OriginalName],o=`${t}.${r}`;if(!this.cachedTables[o]){for(let n of Object.values(e[he.Symbol.Columns])){let i=`${o}.${n.name}`;this.cache[i]=this.convert(n.name)}this.cachedTables[o]=!0}}clearCache(){this.cache={},this.cachedTables={}}}});var Pl,Ho,l$;var ub=v(()=>{$e();Pl=class Pl extends Error{static[F]="DrizzleError";constructor({message:e,cause:t}){super(e);this.name="DrizzleError",this.cause=t}};Ho=class Ho extends Error{constructor(e,t,r){super(`Failed query: ${e}
|
|
425
425
|
params: ${t}`);if(this.query=e,this.params=t,this.cause=r,Error.captureStackTrace(this,Ho),r)this.cause=r}};l$=class l$ extends Pl{static[F]="TransactionRollbackError";constructor(){super({message:"Rollback"})}}});var p5=()=>{};var f5=()=>{};var m5=v(()=>{p5();f5()});var u$=v(()=>{VR();m5();Yt()});var d$=v(()=>{t$();cs();r$();n$();o$();i$();s$()});var Jo;var Kp=v(()=>{$e();Yt();Jo=class Jo extends an{static[F]="SQLiteViewBase"}});var zl,p$,f$;var db=v(()=>{qp();d5();_n();$e();ub();Zp();u$();Yt();d$();Fo();En();sr();Sr();Uo();Kp();zl=class zl{static[F]="SQLiteDialect";casing;constructor(e){this.casing=new c$(e?.casing)}escapeName(e){return`"${e.replace(/"/g,'""')}"`}escapeParam(e){return"?"}escapeString(e){return`'${e.replace(/'/g,"''")}'`}buildWithCTE(e){if(!e?.length)return;let t=[C`with `];for(let[r,o]of e.entries())if(t.push(C`${C.identifier(o._.alias)} as (${o._.sql})`),r<e.length-1)t.push(C`, `);return t.push(C` `),C.join(t)}buildDeleteQuery({table:e,where:t,returning:r,withList:o,limit:n,orderBy:i}){let s=this.buildWithCTE(o),a=r?C` returning ${this.buildSelection(r,{isSingleTable:!0})}`:void 0,c=t?C` where ${t}`:void 0,u=this.buildOrderBy(i),d=this.buildLimit(n);return C`${s}delete from ${e}${c}${a}${u}${d}`}buildUpdateSet(e,t){let r=e[he.Symbol.Columns],o=Object.keys(r).filter((i)=>t[i]!==void 0||r[i]?.onUpdateFn!==void 0),n=o.length;return C.join(o.flatMap((i,s)=>{let a=r[i],c=a.onUpdateFn?.(),u=t[i]??(oe(c,_e)?c:C.param(c,a)),d=C`${C.identifier(this.casing.getColumnCasing(a))} = ${u}`;if(s<n-1)return[d,C.raw(", ")];return[d]}))}buildUpdateQuery({table:e,set:t,where:r,returning:o,withList:n,joins:i,from:s,limit:a,orderBy:c}){let u=this.buildWithCTE(n),d=this.buildUpdateSet(e,t),p=s&&C.join([C.raw(" from "),this.buildFromTable(s)]),m=this.buildJoins(i),h=o?C` returning ${this.buildSelection(o,{isSingleTable:!0})}`:void 0,b=r?C` where ${r}`:void 0,y=this.buildOrderBy(c),S=this.buildLimit(a);return C`${u}update ${e} set ${d}${p}${m}${b}${h}${y}${S}`}buildSelection(e,{isSingleTable:t=!1}={}){let r=e.length,o=e.flatMap(({field:n},i)=>{let s=[];if(oe(n,_e.Aliased)&&n.isSelectionField)s.push(C.identifier(n.fieldAlias));else if(oe(n,_e.Aliased)||oe(n,_e)){let a=oe(n,_e.Aliased)?n.sql:n;if(t)s.push(new _e(a.queryChunks.map((c)=>{if(oe(c,Je))return C.identifier(this.casing.getColumnCasing(c));return c})));else s.push(a);if(oe(n,_e.Aliased))s.push(C` as ${C.identifier(n.fieldAlias)}`)}else if(oe(n,Je)){let a=n.table[he.Symbol.Name];if(n.columnType==="SQLiteNumericBigInt")if(t)s.push(C`cast(${C.identifier(this.casing.getColumnCasing(n))} as text)`);else s.push(C`cast(${C.identifier(a)}.${C.identifier(this.casing.getColumnCasing(n))} as text)`);else if(t)s.push(C.identifier(this.casing.getColumnCasing(n)));else s.push(C`${C.identifier(a)}.${C.identifier(this.casing.getColumnCasing(n))}`)}else if(oe(n,pt)){let a=Object.entries(n._.selectedFields);if(a.length===1){let c=a[0][1],u=oe(c,_e)?c.decoder:oe(c,Je)?{mapFromDriverValue:(d)=>c.mapFromDriverValue(d)}:c.sql.decoder;if(u)n._.sql.decoder=u}s.push(n)}if(i<r-1)s.push(C`, `);return s});return C.join(o)}buildJoins(e){if(!e||e.length===0)return;let t=[];if(e)for(let[r,o]of e.entries()){if(r===0)t.push(C` `);let n=o.table,i=o.on?C` on ${o.on}`:void 0;if(oe(n,At)){let s=n[At.Symbol.Name],a=n[At.Symbol.Schema],c=n[At.Symbol.OriginalName],u=s===c?void 0:o.alias;t.push(C`${C.raw(o.joinType)} join ${a?C`${C.identifier(a)}.`:void 0}${C.identifier(c)}${u&&C` ${C.identifier(u)}`}${i}`)}else t.push(C`${C.raw(o.joinType)} join ${n}${i}`);if(r<e.length-1)t.push(C` `)}return C.join(t)}buildLimit(e){return typeof e==="object"||typeof e==="number"&&e>=0?C` limit ${e}`:void 0}buildOrderBy(e){let t=[];if(e){for(let[r,o]of e.entries())if(t.push(o),r<e.length-1)t.push(C`, `)}return t.length>0?C` order by ${C.join(t)}`:void 0}buildFromTable(e){if(oe(e,he)&&e[he.Symbol.IsAlias])return C`${C`${C.identifier(e[he.Symbol.Schema]??"")}.`.if(e[he.Symbol.Schema])}${C.identifier(e[he.Symbol.OriginalName])} ${C.identifier(e[he.Symbol.Name])}`;return e}buildSelectQuery({withList:e,fields:t,fieldsFlat:r,where:o,having:n,table:i,joins:s,orderBy:a,groupBy:c,limit:u,offset:d,distinct:p,setOperators:m}){let h=r??cn(t);for(let R of h)if(oe(R.field,Je)&&rs(R.field.table)!==(oe(i,pt)?i._.alias:oe(i,Jo)?i[ft].name:oe(i,_e)?void 0:rs(i))&&!((B)=>s?.some(({alias:k})=>k===(B[he.Symbol.IsAlias]?rs(B):B[he.Symbol.BaseName])))(R.field.table)){let B=rs(R.field.table);throw Error(`Your "${R.path.join("->")}" field references a column "${B}"."${R.field.name}", but the table "${B}" is not part of the query! Did you forget to join it?`)}let b=!s||s.length===0,y=this.buildWithCTE(e),S=p?C` distinct`:void 0,x=this.buildSelection(h,{isSingleTable:b}),_=this.buildFromTable(i),A=this.buildJoins(s),O=o?C` where ${o}`:void 0,L=n?C` having ${n}`:void 0,z=[];if(c){for(let[R,B]of c.entries())if(z.push(B),R<c.length-1)z.push(C`, `)}let H=z.length>0?C` group by ${C.join(z)}`:void 0,P=this.buildOrderBy(a),W=this.buildLimit(u),ee=d?C` offset ${d}`:void 0,j=C`${y}select${S} ${x} from ${_}${A}${O}${H}${L}${P}${W}${ee}`;if(m.length>0)return this.buildSetOperations(j,m);return j}buildSetOperations(e,t){let[r,...o]=t;if(!r)throw Error("Cannot pass undefined values to any set operator");if(o.length===0)return this.buildSetOperationQuery({leftSelect:e,setOperator:r});return this.buildSetOperations(this.buildSetOperationQuery({leftSelect:e,setOperator:r}),o)}buildSetOperationQuery({leftSelect:e,setOperator:{type:t,isAll:r,rightSelect:o,limit:n,orderBy:i,offset:s}}){let a=C`${e.getSQL()} `,c=C`${o.getSQL()}`,u;if(i&&i.length>0){let h=[];for(let b of i)if(oe(b,bt))h.push(C.identifier(b.name));else if(oe(b,_e)){for(let y=0;y<b.queryChunks.length;y++){let S=b.queryChunks[y];if(oe(S,bt))b.queryChunks[y]=C.identifier(this.casing.getColumnCasing(S))}h.push(C`${b}`)}else h.push(C`${b}`);u=C` order by ${C.join(h,C`, `)}`}let d=typeof n==="object"||typeof n==="number"&&n>=0?C` limit ${n}`:void 0,p=C.raw(`${t} ${r?"all ":""}`),m=s?C` offset ${s}`:void 0;return C`${a}${p}${c}${u}${d}${m}`}buildInsertQuery({table:e,values:t,onConflict:r,returning:o,withList:n,select:i}){let s=[],a=e[he.Symbol.Columns],c=Object.entries(a).filter(([b,y])=>!y.shouldDisableInsert()),u=c.map(([,b])=>C.identifier(this.casing.getColumnCasing(b)));if(i){let b=t;if(oe(b,_e))s.push(b);else s.push(b.getSQL())}else{let b=t;s.push(C.raw("values "));for(let[y,S]of b.entries()){let x=[];for(let[_,A]of c){let O=S[_];if(O===void 0||oe(O,Ur)&&O.value===void 0){let L;if(A.default!==null&&A.default!==void 0)L=oe(A.default,_e)?A.default:C.param(A.default,A);else if(A.defaultFn!==void 0){let z=A.defaultFn();L=oe(z,_e)?z:C.param(z,A)}else if(!A.default&&A.onUpdateFn!==void 0){let z=A.onUpdateFn();L=oe(z,_e)?z:C.param(z,A)}else L=C`null`;x.push(L)}else x.push(O)}if(s.push(x),y<b.length-1)s.push(C`, `)}}let d=this.buildWithCTE(n),p=C.join(s),m=o?C` returning ${this.buildSelection(o,{isSingleTable:!0})}`:void 0,h=r?.length?C.join(r):void 0;return C`${d}insert into ${e} ${u} ${p}${h}${m}`}sqlToQuery(e,t){return e.toQuery({casing:this.casing,escapeName:this.escapeName,escapeParam:this.escapeParam,escapeString:this.escapeString,invokeSource:t})}buildRelationalQuery({fullSchema:e,schema:t,tableNamesMap:r,table:o,tableConfig:n,queryConfig:i,tableAlias:s,nestedQueryRelation:a,joinOn:c}){let u=[],d,p,m=[],h,b=[];if(i===!0)u=Object.entries(n.columns).map(([x,_])=>({dbKey:_.name,tsKey:x,field:no(_,s),relationTableTsKey:void 0,isJson:!1,selection:[]}));else{let S=Object.fromEntries(Object.entries(n.columns).map(([z,H])=>[z,no(H,s)]));if(i.where){let z=typeof i.where==="function"?i.where(S,g3()):i.where;h=z&&Mp(z,s)}let x=[],_=[];if(i.columns){let z=!1;for(let[H,P]of Object.entries(i.columns)){if(P===void 0)continue;if(H in n.columns){if(!z&&P===!0)z=!0;_.push(H)}}if(_.length>0)_=z?_.filter((H)=>i.columns?.[H]===!0):Object.keys(n.columns).filter((H)=>!_.includes(H))}else _=Object.keys(n.columns);for(let z of _){let H=n.columns[z];x.push({tsKey:z,value:H})}let A=[];if(i.with)A=Object.entries(i.with).filter((z)=>!!z[1]).map(([z,H])=>({tsKey:z,queryConfig:H,relation:n.relations[z]}));let O;if(i.extras){O=typeof i.extras==="function"?i.extras(S,{sql:C}):i.extras;for(let[z,H]of Object.entries(O))x.push({tsKey:z,value:GR(H,s)})}for(let{tsKey:z,value:H}of x)u.push({dbKey:oe(H,_e.Aliased)?H.fieldAlias:n.columns[z].name,tsKey:z,field:oe(H,Je)?no(H,s):H,relationTableTsKey:void 0,isJson:!1,selection:[]});let L=typeof i.orderBy==="function"?i.orderBy(S,y3()):i.orderBy??[];if(!Array.isArray(L))L=[L];m=L.map((z)=>{if(oe(z,Je))return no(z,s);return Mp(z,s)}),d=i.limit,p=i.offset;for(let{tsKey:z,queryConfig:H,relation:P}of A){let W=S3(t,r,P),ee=ha(P.referencedTable),j=r[ee],R=`${s}_${z}`,B=tt(...W.fields.map((I,q)=>je(no(W.references[q],R),no(I,s)))),k=this.buildRelationalQuery({fullSchema:e,schema:t,tableNamesMap:r,table:e[j],tableConfig:t[j],queryConfig:oe(P,as)?H===!0?{limit:1}:{...H,limit:1}:H,tableAlias:R,joinOn:B,nestedQueryRelation:P}),T=C`(${k.sql})`.as(z);u.push({dbKey:z,tsKey:z,field:T,relationTableTsKey:j,isJson:!0,selection:k.selection})}}if(u.length===0)throw new Pl({message:`No fields selected for table "${n.tsName}" ("${s}"). You need to have at least one item in "columns", "with" or "extras". If you need to select all columns, omit the "columns" key or set it to undefined.`});let y;if(h=tt(c,h),a){let S=C`json_array(${C.join(u.map(({field:A})=>oe(A,bt)?C.identifier(this.casing.getColumnCasing(A)):oe(A,_e.Aliased)?A.sql:A),C`, `)})`;if(oe(a,jp))S=C`coalesce(json_group_array(${S}), json_array())`;let x=[{dbKey:"data",tsKey:"data",field:S.as("data"),isJson:!0,relationTableTsKey:n.tsName,selection:u}];if(d!==void 0||p!==void 0||m.length>0)y=this.buildSelectQuery({table:Up(o,s),fields:{},fieldsFlat:[{path:[],field:C.raw("*")}],where:h,limit:d,offset:p,orderBy:m,setOperators:[]}),h=void 0,d=void 0,p=void 0,m=void 0;else y=Up(o,s);y=this.buildSelectQuery({table:oe(y,At)?y:new pt(y,{},s),fields:{},fieldsFlat:x.map(({field:A})=>({path:[],field:oe(A,Je)?no(A,s):A})),joins:b,where:h,limit:d,offset:p,orderBy:m,setOperators:[]})}else y=this.buildSelectQuery({table:Up(o,s),fields:{},fieldsFlat:u.map(({field:S})=>({path:[],field:oe(S,Je)?no(S,s):S})),joins:b,where:h,limit:d,offset:p,orderBy:m,setOperators:[]});return{tableTsKey:n.tsName,sql:y,selection:u}}};p$=class p$ extends zl{static[F]="SQLiteSyncDialect";migrate(e,t,r){let o=r===void 0?"__drizzle_migrations":typeof r==="string"?"__drizzle_migrations":r.migrationsTable??"__drizzle_migrations",n=C`
|
|
426
426
|
CREATE TABLE IF NOT EXISTS ${C.identifier(o)} (
|
|
427
427
|
id SERIAL PRIMARY KEY,
|
|
@@ -434,21 +434,21 @@ params: ${t}`);if(this.query=e,this.params=t,this.cause=r,Error.captureStackTrac
|
|
|
434
434
|
hash text NOT NULL,
|
|
435
435
|
created_at numeric
|
|
436
436
|
)
|
|
437
|
-
`;await t.run(n);let s=(await t.values(C`SELECT id, hash, created_at FROM ${C.identifier(o)} ORDER BY created_at DESC LIMIT 1`))[0]??void 0;await t.transaction(async(a)=>{for(let c of e)if(!s||Number(s[2])<c.folderMillis){for(let u of c.sql)await a.run(C.raw(u));await a.run(C`INSERT INTO ${C.identifier(o)} ("hash", "created_at") VALUES(${c.hash}, ${c.folderMillis})`)}})}}});var m$;var h5=v(()=>{$e();m$=class m${static[F]="TypedQueryBuilder";getSelectedFields(){return this._.selectedFields}}});function pb(e,t){return(r,o,...n)=>{let i=[o,...n].map((s)=>({type:e,isAll:t,rightSelect:s}));for(let s of i)if(!Lp(r.getSelectedFields(),s.rightSelect.getSelectedFields()))throw Error("Set operator error (union / intersect / except): selected fields are not the same or are in a different order");return r.addSetOperators(i)}}var An,g5,h$,Lme=()=>({union:Bme,unionAll:jme,intersect:Zme,except:Ume}),Bme,jme,Zme,Ume;var g$=v(()=>{$e();h5();qo();ba();Yt();En();sr();Sr();Uo();Cl();Kp();An=class An{static[F]="SQLiteSelectBuilder";fields;session;dialect;withList;distinct;constructor(e){this.fields=e.fields,this.session=e.session,this.dialect=e.dialect,this.withList=e.withList,this.distinct=e.distinct}from(e){let t=!!this.fields,r;if(this.fields)r=this.fields;else if(oe(e,pt))r=Object.fromEntries(Object.keys(e._.selectedFields).map((o)=>[o,e[o]]));else if(oe(e,Jo))r=e[ft].selectedFields;else if(oe(e,_e))r={};else r=rb(e);return new h$({table:e,fields:r,isPartialSelect:t,session:this.session,dialect:this.dialect,withList:this.withList,distinct:this.distinct})}};g5=class g5 extends m${static[F]="SQLiteSelectQueryBuilder";_;config;joinsNotNullableMap;tableName;isPartialSelect;session;dialect;cacheConfig=void 0;usedTables=new Set;constructor({table:e,fields:t,isPartialSelect:r,session:o,dialect:n,withList:i,distinct:s}){super();this.config={withList:i,table:e,fields:{...t},distinct:s,setOperators:[]},this.isPartialSelect=r,this.session=o,this.dialect=n,this._={selectedFields:t,config:this.config},this.tableName=Bp(e),this.joinsNotNullableMap=typeof this.tableName==="string"?{[this.tableName]:!0}:{};for(let a of In(e))this.usedTables.add(a)}getUsedTables(){return[...this.usedTables]}createJoin(e){return(t,r)=>{let o=this.tableName,n=Bp(t);for(let i of In(t))this.usedTables.add(i);if(typeof n==="string"&&this.config.joins?.some((i)=>i.alias===n))throw Error(`Alias "${n}" is already used in this query`);if(!this.isPartialSelect){if(Object.keys(this.joinsNotNullableMap).length===1&&typeof o==="string")this.config.fields={[o]:this.config.fields};if(typeof n==="string"&&!oe(t,_e)){let i=oe(t,pt)?t._.selectedFields:oe(t,an)?t[ft].selectedFields:t[he.Symbol.Columns];this.config.fields[n]=i}}if(typeof r==="function")r=r(new Proxy(this.config.fields,new at({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})));if(!this.config.joins)this.config.joins=[];if(this.config.joins.push({on:r,table:t,joinType:e,alias:n}),typeof n==="string")switch(e){case"left":{this.joinsNotNullableMap[n]=!1;break}case"right":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([i])=>[i,!1])),this.joinsNotNullableMap[n]=!0;break}case"cross":case"inner":{this.joinsNotNullableMap[n]=!0;break}case"full":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([i])=>[i,!1])),this.joinsNotNullableMap[n]=!1;break}}return this}}leftJoin=this.createJoin("left");rightJoin=this.createJoin("right");innerJoin=this.createJoin("inner");fullJoin=this.createJoin("full");crossJoin=this.createJoin("cross");createSetOperator(e,t){return(r)=>{let o=typeof r==="function"?r(Lme()):r;if(!Lp(this.getSelectedFields(),o.getSelectedFields()))throw Error("Set operator error (union / intersect / except): selected fields are not the same or are in a different order");return this.config.setOperators.push({type:e,isAll:t,rightSelect:o}),this}}union=this.createSetOperator("union",!1);unionAll=this.createSetOperator("union",!0);intersect=this.createSetOperator("intersect",!1);except=this.createSetOperator("except",!1);addSetOperators(e){return this.config.setOperators.push(...e),this}where(e){if(typeof e==="function")e=e(new Proxy(this.config.fields,new at({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})));return this.config.where=e,this}having(e){if(typeof e==="function")e=e(new Proxy(this.config.fields,new at({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})));return this.config.having=e,this}groupBy(...e){if(typeof e[0]==="function"){let t=e[0](new Proxy(this.config.fields,new at({sqlAliasedBehavior:"alias",sqlBehavior:"sql"})));this.config.groupBy=Array.isArray(t)?t:[t]}else this.config.groupBy=e;return this}orderBy(...e){if(typeof e[0]==="function"){let t=e[0](new Proxy(this.config.fields,new at({sqlAliasedBehavior:"alias",sqlBehavior:"sql"}))),r=Array.isArray(t)?t:[t];if(this.config.setOperators.length>0)this.config.setOperators.at(-1).orderBy=r;else this.config.orderBy=r}else{let t=e;if(this.config.setOperators.length>0)this.config.setOperators.at(-1).orderBy=t;else this.config.orderBy=t}return this}limit(e){if(this.config.setOperators.length>0)this.config.setOperators.at(-1).limit=e;else this.config.limit=e;return this}offset(e){if(this.config.setOperators.length>0)this.config.setOperators.at(-1).offset=e;else this.config.offset=e;return this}getSQL(){return this.dialect.buildSelectQuery(this.config)}toSQL(){let{typings:e,...t}=this.dialect.sqlToQuery(this.getSQL());return t}as(e){let t=[];if(t.push(...In(this.config.table)),this.config.joins)for(let r of this.config.joins)t.push(...In(r.table));return new Proxy(new pt(this.getSQL(),this.config.fields,e,!1,[...new Set(t)]),new at({alias:e,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}getSelectedFields(){return new Proxy(this.config.fields,new at({alias:this.tableName,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}$dynamic(){return this}};h$=class h$ extends g5{static[F]="SQLiteSelect";_prepare(e=!0){if(!this.session)throw Error("Cannot execute a query on a query builder. Please use a database instance instead.");let t=cn(this.config.fields),r=this.session[e?"prepareOneTimeQuery":"prepareQuery"](this.dialect.sqlToQuery(this.getSQL()),t,"all",!0,void 0,{type:"select",tables:[...this.usedTables]},this.cacheConfig);return r.joinsNotNullableMap=this.joinsNotNullableMap,r}$withCache(e){return this.cacheConfig=e===void 0?{config:{},enable:!0,autoInvalidate:!0}:e===!1?{enable:!1}:{enable:!0,autoInvalidate:!0,...e},this}prepare(){return this._prepare(!1)}run=(e)=>this._prepare().run(e);all=(e)=>this._prepare().all(e);get=(e)=>this._prepare().get(e);values=(e)=>this._prepare().values(e);async execute(){return this.all()}};VF(h$,[vr]);Bme=pb("union",!1),jme=pb("union",!0),Zme=pb("intersect",!1),Ume=pb("except",!1)});var Sa;var fb=v(()=>{$e();ba();db();En();g$();Sa=class Sa{static[F]="SQLiteQueryBuilder";dialect;dialectConfig;constructor(e){this.dialect=oe(e,zl)?e:void 0,this.dialectConfig=oe(e,zl)?void 0:e}$with=(e,t)=>{let r=this;return{as:(n)=>{if(typeof n==="function")n=n(r);return new Proxy(new zp(n.getSQL(),t??("getSelectedFields"in n?n.getSelectedFields()??{}:{}),e,!0),new at({alias:e,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}}};with(...e){let t=this;function r(n){return new An({fields:n??void 0,session:void 0,dialect:t.getDialect(),withList:e})}function o(n){return new An({fields:n??void 0,session:void 0,dialect:t.getDialect(),withList:e,distinct:!0})}return{select:r,selectDistinct:o}}select(e){return new An({fields:e??void 0,session:void 0,dialect:this.getDialect()})}selectDistinct(e){return new An({fields:e??void 0,session:void 0,dialect:this.getDialect(),distinct:!0})}getDialect(){if(!this.dialect)this.dialect=new p$(this.dialectConfig);return this.dialect}}});var mb,y$;var y5=v(()=>{$e();qo();Yt();Fo();sr();Sr();Cl();fb();mb=class mb{constructor(e,t,r,o){this.table=e,this.session=t,this.dialect=r,this.withList=o}static[F]="SQLiteInsertBuilder";values(e){if(e=Array.isArray(e)?e:[e],e.length===0)throw Error("values() must be called with at least one value");let t=e.map((r)=>{let o={},n=this.table[he.Symbol.Columns];for(let i of Object.keys(r)){let s=r[i];o[i]=oe(s,_e)?s:new Ur(s,n[i])}return o});return new y$(this.table,t,this.session,this.dialect,this.withList)}select(e){let t=typeof e==="function"?e(new Sa):e;if(!oe(t,_e)&&!Lp(this.table[Xy],t._.selectedFields))throw Error("Insert select error: selected fields are not the same or are in a different order compared to the table definition");return new y$(this.table,t,this.session,this.dialect,this.withList,!0)}};y$=class y$ extends vr{constructor(e,t,r,o,n,i){super();this.session=r,this.dialect=o,this.config={table:e,values:t,withList:n,select:i}}static[F]="SQLiteInsert";config;returning(e=this.config.table[At.Symbol.Columns]){return this.config.returning=cn(e),this}onConflictDoNothing(e={}){if(!this.config.onConflict)this.config.onConflict=[];if(e.target===void 0)this.config.onConflict.push(C` on conflict do nothing`);else{let t=Array.isArray(e.target)?C`${e.target}`:C`${[e.target]}`,r=e.where?C` where ${e.where}`:C``;this.config.onConflict.push(C` on conflict ${t} do nothing${r}`)}return this}onConflictDoUpdate(e){if(e.where&&(e.targetWhere||e.setWhere))throw Error('You cannot use both "where" and "targetWhere"/"setWhere" at the same time - "where" is deprecated, use "targetWhere" or "setWhere" instead.');if(!this.config.onConflict)this.config.onConflict=[];let t=e.where?C` where ${e.where}`:void 0,r=e.targetWhere?C` where ${e.targetWhere}`:void 0,o=e.setWhere?C` where ${e.setWhere}`:void 0,n=Array.isArray(e.target)?C`${e.target}`:C`${[e.target]}`,i=this.dialect.buildUpdateSet(this.config.table,tb(this.config.table,e.set));return this.config.onConflict.push(C` on conflict ${n}${r} do update set ${i}${t}${o}`),this}getSQL(){return this.dialect.buildInsertQuery(this.config)}toSQL(){let{typings:e,...t}=this.dialect.sqlToQuery(this.getSQL());return t}_prepare(e=!0){return this.session[e?"prepareOneTimeQuery":"prepareQuery"](this.dialect.sqlToQuery(this.getSQL()),this.config.returning,this.config.returning?"all":"run",!0,void 0,{type:"insert",tables:In(this.config.table)})}prepare(){return this._prepare(!1)}run=(e)=>this._prepare().run(e);all=(e)=>this._prepare().all(e);get=(e)=>this._prepare().get(e);values=(e)=>this._prepare().values(e);async execute(){return this.config.returning?this.all():this.run()}$dynamic(){return this}}});var hb,b5;var S5=v(()=>{$e();qo();ba();Fo();En();sr();Sr();Uo();Cl();Kp();hb=class hb{constructor(e,t,r,o){this.table=e,this.session=t,this.dialect=r,this.withList=o}static[F]="SQLiteUpdateBuilder";set(e){return new b5(this.table,tb(this.table,e),this.session,this.dialect,this.withList)}};b5=class b5 extends vr{constructor(e,t,r,o,n){super();this.session=r,this.dialect=o,this.config={set:t,table:e,withList:n,joins:[]}}static[F]="SQLiteUpdate";config;from(e){return this.config.from=e,this}createJoin(e){return(t,r)=>{let o=Bp(t);if(typeof o==="string"&&this.config.joins.some((n)=>n.alias===o))throw Error(`Alias "${o}" is already used in this query`);if(typeof r==="function"){let n=this.config.from?oe(t,At)?t[he.Symbol.Columns]:oe(t,pt)?t._.selectedFields:oe(t,Jo)?t[ft].selectedFields:void 0:void 0;r=r(new Proxy(this.config.table[he.Symbol.Columns],new at({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})),n&&new Proxy(n,new at({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))}return this.config.joins.push({on:r,table:t,joinType:e,alias:o}),this}}leftJoin=this.createJoin("left");rightJoin=this.createJoin("right");innerJoin=this.createJoin("inner");fullJoin=this.createJoin("full");where(e){return this.config.where=e,this}orderBy(...e){if(typeof e[0]==="function"){let t=e[0](new Proxy(this.config.table[he.Symbol.Columns],new at({sqlAliasedBehavior:"alias",sqlBehavior:"sql"}))),r=Array.isArray(t)?t:[t];this.config.orderBy=r}else{let t=e;this.config.orderBy=t}return this}limit(e){return this.config.limit=e,this}returning(e=this.config.table[At.Symbol.Columns]){return this.config.returning=cn(e),this}getSQL(){return this.dialect.buildUpdateQuery(this.config)}toSQL(){let{typings:e,...t}=this.dialect.sqlToQuery(this.getSQL());return t}_prepare(e=!0){return this.session[e?"prepareOneTimeQuery":"prepareQuery"](this.dialect.sqlToQuery(this.getSQL()),this.config.returning,this.config.returning?"all":"run",!0,void 0,{type:"insert",tables:In(this.config.table)})}prepare(){return this._prepare(!1)}run=(e)=>this._prepare().run(e);all=(e)=>this._prepare().all(e);get=(e)=>this._prepare().get(e);values=(e)=>this._prepare().values(e);async execute(){return this.config.returning?this.all():this.run()}$dynamic(){return this}}});var b$=v(()=>{u5();y5();fb();g$();S5()});var Hp;var v5=v(()=>{$e();Yt();Hp=class Hp extends _e{constructor(e){super(Hp.buildEmbeddedCount(e.source,e.filters).queryChunks);this.params=e,this.session=e.session,this.sql=Hp.buildCount(e.source,e.filters)}sql;static[F]="SQLiteCountBuilderAsync";[Symbol.toStringTag]="SQLiteCountBuilderAsync";session;static buildEmbeddedCount(e,t){return C`(select count(*) from ${e}${C.raw(" where ").if(t)}${t})`}static buildCount(e,t){return C`select count(*) from ${e}${C.raw(" where ").if(t)}${t}`}then(e,t){return Promise.resolve(this.session.count(this.sql)).then(e,t)}catch(e){return this.then(void 0,e)}finally(e){return this.then((t)=>(e?.(),t),(t)=>{throw e?.(),t})}}});var v$,gb,S$;var w5=v(()=>{$e();qo();Zp();v$=class v${constructor(e,t,r,o,n,i,s,a){this.mode=e,this.fullSchema=t,this.schema=r,this.tableNamesMap=o,this.table=n,this.tableConfig=i,this.dialect=s,this.session=a}static[F]="SQLiteAsyncRelationalQueryBuilder";findMany(e){return this.mode==="sync"?new S$(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e?e:{},"many"):new gb(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e?e:{},"many")}findFirst(e){return this.mode==="sync"?new S$(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e?{...e,limit:1}:{limit:1},"first"):new gb(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e?{...e,limit:1}:{limit:1},"first")}};gb=class gb extends vr{constructor(e,t,r,o,n,i,s,a,c){super();this.fullSchema=e,this.schema=t,this.tableNamesMap=r,this.table=o,this.tableConfig=n,this.dialect=i,this.session=s,this.config=a,this.mode=c}static[F]="SQLiteAsyncRelationalQuery";mode;getSQL(){return this.dialect.buildRelationalQuery({fullSchema:this.fullSchema,schema:this.schema,tableNamesMap:this.tableNamesMap,table:this.table,tableConfig:this.tableConfig,queryConfig:this.config,tableAlias:this.tableConfig.tsName}).sql}_prepare(e=!1){let{query:t,builtQuery:r}=this._toSQL();return this.session[e?"prepareOneTimeQuery":"prepareQuery"](r,void 0,this.mode==="first"?"get":"all",!0,(o,n)=>{let i=o.map((s)=>sb(this.schema,this.tableConfig,s,t.selection,n));if(this.mode==="first")return i[0];return i})}prepare(){return this._prepare(!1)}_toSQL(){let e=this.dialect.buildRelationalQuery({fullSchema:this.fullSchema,schema:this.schema,tableNamesMap:this.tableNamesMap,table:this.table,tableConfig:this.tableConfig,queryConfig:this.config,tableAlias:this.tableConfig.tsName}),t=this.dialect.sqlToQuery(e.sql);return{query:e,builtQuery:t}}toSQL(){return this._toSQL().builtQuery}executeRaw(){if(this.mode==="first")return this._prepare(!1).get();return this._prepare(!1).all()}async execute(){return this.executeRaw()}};S$=class S$ extends gb{static[F]="SQLiteSyncRelationalQuery";sync(){return this.executeRaw()}}});var Nl;var x5=v(()=>{$e();qo();Nl=class Nl extends vr{constructor(e,t,r,o,n){super();this.execute=e,this.getSQL=t,this.dialect=o,this.mapBatchResult=n,this.config={action:r}}static[F]="SQLiteRaw";config;getQuery(){return{...this.dialect.sqlToQuery(this.getSQL()),method:this.config.action}}mapResult(e,t){return t?this.mapBatchResult(e):e}_prepare(){return this}isResponseInArrayMode(){return!1}}});var Jp;var yb=v(()=>{$e();ba();Yt();b$();En();v5();w5();x5();Jp=class Jp{constructor(e,t,r,o){this.resultKind=e,this.dialect=t,this.session=r,this._=o?{schema:o.schema,fullSchema:o.fullSchema,tableNamesMap:o.tableNamesMap}:{schema:void 0,fullSchema:{},tableNamesMap:{}},this.query={};let n=this.query;if(this._.schema)for(let[i,s]of Object.entries(this._.schema))n[i]=new v$(e,o.fullSchema,this._.schema,this._.tableNamesMap,o.fullSchema[i],s,t,r);this.$cache={invalidate:async(i)=>{}}}static[F]="BaseSQLiteDatabase";query;$with=(e,t)=>{let r=this;return{as:(n)=>{if(typeof n==="function")n=n(new Sa(r.dialect));return new Proxy(new zp(n.getSQL(),t??("getSelectedFields"in n?n.getSelectedFields()??{}:{}),e,!0),new at({alias:e,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}}};$count(e,t){return new Hp({source:e,filters:t,session:this.session})}with(...e){let t=this;function r(a){return new An({fields:a??void 0,session:t.session,dialect:t.dialect,withList:e})}function o(a){return new An({fields:a??void 0,session:t.session,dialect:t.dialect,withList:e,distinct:!0})}function n(a){return new hb(a,t.session,t.dialect,e)}function i(a){return new mb(a,t.session,t.dialect,e)}function s(a){return new lb(a,t.session,t.dialect,e)}return{select:r,selectDistinct:o,update:n,insert:i,delete:s}}select(e){return new An({fields:e??void 0,session:this.session,dialect:this.dialect})}selectDistinct(e){return new An({fields:e??void 0,session:this.session,dialect:this.dialect,distinct:!0})}update(e){return new hb(e,this.session,this.dialect)}$cache;insert(e){return new mb(e,this.session,this.dialect)}delete(e){return new lb(e,this.session,this.dialect)}run(e){let t=typeof e==="string"?C.raw(e):e.getSQL();if(this.resultKind==="async")return new Nl(async()=>this.session.run(t),()=>t,"run",this.dialect,this.session.extractRawRunValueFromBatchResult.bind(this.session));return this.session.run(t)}all(e){let t=typeof e==="string"?C.raw(e):e.getSQL();if(this.resultKind==="async")return new Nl(async()=>this.session.all(t),()=>t,"all",this.dialect,this.session.extractRawAllValueFromBatchResult.bind(this.session));return this.session.all(t)}get(e){let t=typeof e==="string"?C.raw(e):e.getSQL();if(this.resultKind==="async")return new Nl(async()=>this.session.get(t),()=>t,"get",this.dialect,this.session.extractRawGetValueFromBatchResult.bind(this.session));return this.session.get(t)}values(e){let t=typeof e==="string"?C.raw(e):e.getSQL();if(this.resultKind==="async")return new Nl(async()=>this.session.values(t),()=>t,"values",this.dialect,this.session.extractRawValuesValueFromBatchResult.bind(this.session));return this.session.values(t)}transaction(e,t){return this.session.transaction(e,t)}}});async function w$(e,t){let r=`${e}-${JSON.stringify(t)}`,n=new TextEncoder().encode(r),i=await crypto.subtle.digest("SHA-256",n);return[...new Uint8Array(i)].map((c)=>c.toString(16).padStart(2,"0")).join("")}var _5,Vp;var x$=v(()=>{$e();_5=class _5{static[F]="Cache"};Vp=class Vp extends _5{strategy(){return"all"}static[F]="NoopCache";async get(e){return}async put(e,t,r,o){}async onMutate(e){}}});var E5=v(()=>{x$()});function bb(e,t){return new Proxy(e,new ya(t,!1))}var k5=v(()=>{qp()});var I5,_$,E$,k$;var I$=v(()=>{x$();$e();ub();qo();yb();I5=class I5 extends vr{constructor(e){super();this.resultCb=e}static[F]="ExecuteResultSync";async execute(){return this.resultCb()}sync(){return this.resultCb()}};_$=class _${constructor(e,t,r,o,n,i){if(this.mode=e,this.executeMethod=t,this.query=r,this.cache=o,this.queryMetadata=n,this.cacheConfig=i,o&&o.strategy()==="all"&&i===void 0)this.cacheConfig={enable:!0,autoInvalidate:!0};if(!this.cacheConfig?.enable)this.cacheConfig=void 0}static[F]="PreparedQuery";joinsNotNullableMap;async queryWithCache(e,t,r){if(this.cache===void 0||oe(this.cache,Vp)||this.queryMetadata===void 0)try{return await r()}catch(o){throw new Ho(e,t,o)}if(this.cacheConfig&&!this.cacheConfig.enable)try{return await r()}catch(o){throw new Ho(e,t,o)}if((this.queryMetadata.type==="insert"||this.queryMetadata.type==="update"||this.queryMetadata.type==="delete")&&this.queryMetadata.tables.length>0)try{let[o]=await Promise.all([r(),this.cache.onMutate({tables:this.queryMetadata.tables})]);return o}catch(o){throw new Ho(e,t,o)}if(!this.cacheConfig)try{return await r()}catch(o){throw new Ho(e,t,o)}if(this.queryMetadata.type==="select"){let o=await this.cache.get(this.cacheConfig.tag??await w$(e,t),this.queryMetadata.tables,this.cacheConfig.tag!==void 0,this.cacheConfig.autoInvalidate);if(o===void 0){let n;try{n=await r()}catch(i){throw new Ho(e,t,i)}return await this.cache.put(this.cacheConfig.tag??await w$(e,t),n,this.cacheConfig.autoInvalidate?this.queryMetadata.tables:[],this.cacheConfig.tag!==void 0,this.cacheConfig.config),n}return o}try{return await r()}catch(o){throw new Ho(e,t,o)}}getQuery(){return this.query}mapRunResult(e,t){return e}mapAllResult(e,t){throw Error("Not implemented")}mapGetResult(e,t){throw Error("Not implemented")}execute(e){if(this.mode==="async")return this[this.executeMethod](e);return new I5(()=>this[this.executeMethod](e))}mapResult(e,t){switch(this.executeMethod){case"run":return this.mapRunResult(e,t);case"all":return this.mapAllResult(e,t);case"get":return this.mapGetResult(e,t)}}};E$=class E${constructor(e){this.dialect=e}static[F]="SQLiteSession";prepareOneTimeQuery(e,t,r,o,n,i,s){return this.prepareQuery(e,t,r,o,n,i,s)}run(e){let t=this.dialect.sqlToQuery(e);try{return this.prepareOneTimeQuery(t,void 0,"run",!1).run()}catch(r){throw new Pl({cause:r,message:`Failed to run the query '${t.sql}'`})}}extractRawRunValueFromBatchResult(e){return e}all(e){return this.prepareOneTimeQuery(this.dialect.sqlToQuery(e),void 0,"run",!1).all()}extractRawAllValueFromBatchResult(e){throw Error("Not implemented")}get(e){return this.prepareOneTimeQuery(this.dialect.sqlToQuery(e),void 0,"run",!1).get()}extractRawGetValueFromBatchResult(e){throw Error("Not implemented")}values(e){return this.prepareOneTimeQuery(this.dialect.sqlToQuery(e),void 0,"run",!1).values()}async count(e){return(await this.values(e))[0][0]}extractRawValuesValueFromBatchResult(e){throw Error("Not implemented")}};k$=class k$ extends Jp{constructor(e,t,r,o,n=0){super(e,t,r,o);this.schema=o,this.nestedIndex=n}static[F]="SQLiteTransaction";rollback(){throw new l$}}});var A$,Mme,qme,Sb;var A5=v(()=>{$e();ba();Sr();fb();Fo();Kp();A$=class A${constructor(e){this.name=e}static[F]="SQLiteViewBuilderCore";config={}};Mme=class Mme extends A${static[F]="SQLiteViewBuilder";as(e){if(typeof e==="function")e=e(new Sa);let t=new at({alias:this.name,sqlBehavior:"error",sqlAliasedBehavior:"alias",replaceOriginalName:!0}),r=e.getSelectedFields();return new Proxy(new Sb({config:{name:this.name,schema:void 0,selectedFields:r,query:e.getSQL().inlineParams()}}),t)}};qme=class qme extends A${static[F]="SQLiteManualViewBuilder";columns;constructor(e,t){super(e);this.columns=rb(Fp(e,t))}existing(){return new Proxy(new Sb({config:{name:this.name,schema:void 0,selectedFields:this.columns,query:void 0}}),new at({alias:this.name,sqlBehavior:"error",sqlAliasedBehavior:"alias",replaceOriginalName:!0}))}as(e){return new Proxy(new Sb({config:{name:this.name,schema:void 0,selectedFields:this.columns,query:e.inlineParams()}}),new at({alias:this.name,sqlBehavior:"error",sqlAliasedBehavior:"alias",replaceOriginalName:!0}))}};Sb=class Sb extends Jo{static[F]="SQLiteView";constructor({config:e}){super(e)}}});var vb=v(()=>{k5();n5();d$();yb();db();YR();a5();l5();b$();I$();Fo();e$();Cl();A5()});function T5(e){return Object.keys(e).reduce((t,r)=>{if(Object.prototype.propertyIsEnumerable.call(e,r))t[r]=e[r];return t},{})}function wb(e){if(typeof ArrayBuffer<"u"&&e instanceof ArrayBuffer){if(typeof Buffer<"u"){if(!(e instanceof Buffer))return Buffer.from(e);return e}if(typeof TextDecoder<"u")return new TextDecoder().decode(e);throw Error("TextDecoder is not available. Please provide either Buffer or TextDecoder polyfill.")}return e}var xb,T$,R5;var R$=v(()=>{E5();$e();nb();Yt();vb();I$();Sr();xb=class xb extends E${constructor(e,t,r,o,n){super(t);this.client=e,this.schema=r,this.options=o,this.tx=n,this.logger=o.logger??new KR,this.cache=o.cache??new Vp}static[F]="LibSQLSession";logger;cache;prepareQuery(e,t,r,o,n,i,s){return new R5(this.client,e,this.logger,this.cache,i,s,t,this.tx,r,o,n)}async batch(e){let t=[],r=[];for(let n of e){let i=n._prepare(),s=i.getQuery();t.push(i),r.push({sql:s.sql,args:s.params})}return(await this.client.batch(r)).map((n,i)=>t[i].mapResult(n,!0))}async migrate(e){let t=[],r=[];for(let n of e){let i=n._prepare(),s=i.getQuery();t.push(i),r.push({sql:s.sql,args:s.params})}return(await this.client.migrate(r)).map((n,i)=>t[i].mapResult(n,!0))}async transaction(e,t){let r=await this.client.transaction(),o=new xb(this.client,this.dialect,this.schema,this.options,r),n=new T$("async",this.dialect,o,this.schema);try{let i=await e(n);return await r.commit(),i}catch(i){throw await r.rollback(),i}}extractRawAllValueFromBatchResult(e){return e.rows}extractRawGetValueFromBatchResult(e){return e.rows[0]}extractRawValuesValueFromBatchResult(e){return e.rows}};T$=class T$ extends k${static[F]="LibSQLTransaction";async transaction(e){let t=`sp${this.nestedIndex}`,r=new T$("async",this.dialect,this.session,this.schema,this.nestedIndex+1);await this.session.run(C.raw(`savepoint ${t}`));try{let o=await e(r);return await this.session.run(C.raw(`release savepoint ${t}`)),o}catch(o){throw await this.session.run(C.raw(`rollback to savepoint ${t}`)),o}}};R5=class R5 extends _${constructor(e,t,r,o,n,i,s,a,c,u,d){super("async",c,t,o,n,i);this.client=e,this.logger=r,this.fields=s,this.tx=a,this._isResponseInArrayMode=u,this.customResultMapper=d,this.customResultMapper=d,this.fields=s}static[F]="LibSQLPreparedQuery";async run(e){let t=Dp(this.query.params,e??{});return this.logger.logQuery(this.query.sql,t),await this.queryWithCache(this.query.sql,t,async()=>{let r={sql:this.query.sql,args:t};return this.tx?this.tx.execute(r):this.client.execute(r)})}async all(e){let{fields:t,logger:r,query:o,tx:n,client:i,customResultMapper:s}=this;if(!t&&!s){let c=Dp(o.params,e??{});return r.logQuery(o.sql,c),await this.queryWithCache(o.sql,c,async()=>{let u={sql:o.sql,args:c};return(n?n.execute(u):i.execute(u)).then(({rows:d})=>this.mapAllResult(d))})}let a=await this.values(e);return this.mapAllResult(a)}mapAllResult(e,t){if(t)e=e.rows;if(!this.fields&&!this.customResultMapper)return e.map((r)=>T5(r));if(this.customResultMapper)return this.customResultMapper(e,wb);return e.map((r)=>MR(this.fields,Array.prototype.slice.call(r).map((o)=>wb(o)),this.joinsNotNullableMap))}async get(e){let{fields:t,logger:r,query:o,tx:n,client:i,customResultMapper:s}=this;if(!t&&!s){let c=Dp(o.params,e??{});return r.logQuery(o.sql,c),await this.queryWithCache(o.sql,c,async()=>{let u={sql:o.sql,args:c};return(n?n.execute(u):i.execute(u)).then(({rows:d})=>this.mapGetResult(d))})}let a=await this.values(e);return this.mapGetResult(a)}mapGetResult(e,t){if(t)e=e.rows;let r=e[0];if(!this.fields&&!this.customResultMapper)return T5(r);if(!r)return;if(this.customResultMapper)return this.customResultMapper(e,wb);return MR(this.fields,Array.prototype.slice.call(r).map((o)=>wb(o)),this.joinsNotNullableMap)}async values(e){let t=Dp(this.query.params,e??{});return this.logger.logQuery(this.query.sql,t),await this.queryWithCache(this.query.sql,t,async()=>{let r={sql:this.query.sql,args:t};return(this.tx?this.tx.execute(r):this.client.execute(r)).then(({rows:o})=>o)})}isResponseInArrayMode(){return this._isResponseInArrayMode}}});function Dl(e,t={}){let r=new f$({casing:t.casing}),o;if(t.logger===!0)o=new FR;else if(t.logger!==!1)o=t.logger;let n;if(t.schema){let a=b3(t.schema,v3);n={fullSchema:t.schema,schema:a.tables,tableNamesMap:a.tableNamesMap}}let i=new xb(e,r,n,{logger:o,cache:t.cache},void 0),s=new $5("async",r,i,n);if(s.$client=e,s.$cache=t.cache,s.$cache)s.$cache.invalidate=t.cache?.onMutate;return s}var $5;var O5=v(()=>{$e();nb();Zp();yb();db();R$();$5=class $5 extends Jp{static[F]="LibSQLDatabase";async batch(e){return this.session.batch(e)}}});function _b(...e){if(typeof e[0]==="string"){let t=Tl({url:e[0]});return Dl(t,e[1])}if(WF(e[0])){let{connection:t,client:r,...o}=e[0];if(r)return Dl(r,o);let n=typeof t==="string"?Tl({url:t}):Tl(t);return Dl(n,o)}return Dl(e[0],e[1])}var C5=v(()=>{OR();Sr();O5();((e)=>{function t(r){return Dl({},r)}e.mock=t})(_b||(_b={}))});var P5=v(()=>{C5();R$()});function Fme(){return new Promise((e)=>setTimeout(e,0))}function Hme(){if($$)return;$$=!0,setTimeout(()=>{$$=!1,O$=performance.now()},0)}async function Wp(e=Kme){if(Hme(),performance.now()-O$<e)return;await Fme(),O$=performance.now()}var Kme=50,O$,$$=!1;var z5=v(()=>{O$=performance.now()});function N5(e){if(e.authToken!==void 0)return e.authToken;if(e.authTokenEnv===void 0)return;return process.env[e.authTokenEnv]}function Gme(e){return e instanceof Ce&&/^SQLITE_(?:BUSY|LOCKED)$/u.test(e.code)}async function Eb(e,t){let r=Date.now()+(t.budgetMs??Jme),o=async(n)=>{if(t.isClosed())throw new Ce("The client is closed","CLIENT_CLOSED");try{return await e()}catch(i){if(t.isClosed()||!Gme(i))throw i;await t.afterRefusal?.();let s=Math.min(Vme*2**(n-1),Wme),a=s/2+Math.random()*(s/2);if(t.isClosed()||Date.now()+a>=r)throw i;if(await new Promise((c)=>setTimeout(c,a)),t.isClosed()||Date.now()>=r)throw i;return o(n+1)}};return o(1)}function C$(e,t={}){let r=Tl({...e,...e.url.startsWith("file:")?{timeout:0}:{}});if(e.url.startsWith("file:")&&e.syncUrl===void 0){let o=r.transaction.bind(r),n=()=>r.closed,i=t.contentionRetryBudgetMs,s=r.execute.bind(r),a=r.batch.bind(r),c=r.migrate.bind(r),u={isClosed:n,budgetMs:i,afterRefusal:async()=>{await Promise.resolve(r.reconnect())}};async function d(p,m){return await Wp(),Eb(()=>typeof p==="string"?s(p,m):s(p),u)}r.execute=d,r.batch=async(p,m)=>(await Wp(),Eb(()=>a(p,m),u)),r.migrate=async(p)=>(await Wp(),Eb(()=>c(p),u)),r.transaction=async(p)=>(await Wp(),Eb(()=>o(p),u))}return r}function kb(e){let{url:t,schema:r}=e,o=N5(e),n={contentionRetryBudgetMs:e.contentionRetryBudgetMs},i=o?C$({url:t,authToken:o},n):C$({url:t},n);return{db:_b(i,{schema:r}),client:i,url:t}}async function Ib(e,t){if(!t.startsWith("file:"))return;for(let r of["PRAGMA busy_timeout = 0","PRAGMA journal_mode = WAL"])await e.execute(r)}var Jme=5000,Vme=5,Wme=40;var P$=v(()=>{OR();P5();z5()});var D5=v(()=>{HT();P$()});var z$=v(()=>{P$();D5()});var N$=v(()=>{qp();Gy();_n();$e();ub();nb();qo();Zp();u$();En();sr();Sr();Uo()});var Y,Me;var D$=v(()=>{vb();N$();cp();Y=Fp("job_queue",{id:mt("id").primaryKey().$defaultFn(()=>No()),type:mt("type").notNull(),data:mt("data").notNull(),result:mt("result",{mode:"json"}),progress:mt("progress",{mode:"json"}).$type(),source:mt("source"),metadata:mt("metadata",{mode:"json"}).$type().notNull(),status:mt("status",{enum:["pending","processing","completed","failed"]}).notNull().default("pending"),priority:ar("priority").notNull().default(0),retryCount:ar("retryCount").notNull().default(0),maxRetries:ar("maxRetries").notNull().default(3),lastError:mt("lastError"),lastErrorPublic:mt("lastErrorPublic",{mode:"json"}),createdAt:ar("createdAt").notNull().$defaultFn(()=>Date.now()),scheduledFor:ar("scheduledFor").notNull().$defaultFn(()=>Date.now()),startedAt:ar("startedAt"),completedAt:ar("completedAt"),attemptId:mt("attemptId"),workerSlotId:mt("workerSlotId"),workerSessionId:mt("workerSessionId"),leaseExpiresAt:ar("leaseExpiresAt"),attemptHeartbeatAt:ar("attemptHeartbeatAt"),runtimeUpdatedAt:ar("runtimeUpdatedAt"),brainVersion:mt("brainVersion"),brainVersionSortKey:mt("brainVersionSortKey")},(e)=>({queueReadyIdx:Ko("idx_job_queue_ready").on(e.status,e.priority,e.scheduledFor),jobTypeIdx:Ko("idx_job_queue_type").on(e.type,e.status),runtimeUpdatesIdx:Ko("idx_job_queue_runtime_updates").on(e.runtimeUpdatedAt,e.id),jobSourceIdx:Ko("idx_job_queue_source").on(e.source),rootJobIdx:Ko("idx_job_queue_root_job").on(C`json_extract(${e.metadata}, '$.rootJobId')`,e.createdAt,e.id),deduplicationIdx:Ko("idx_job_queue_deduplication").on(e.type,C`json_extract(${e.metadata}, '$.deduplicationKey')`,e.status)})),Me=Fp("job_worker_sessions",{slotId:mt("slotId").primaryKey(),sessionId:mt("sessionId").notNull().unique(),startedAt:ar("startedAt").notNull(),heartbeatAt:ar("heartbeatAt").notNull(),expiresAt:ar("expiresAt").notNull().default(0),brainVersion:mt("brainVersion"),brainVersionSortKey:mt("brainVersionSortKey"),stableSlotId:mt("stableSlotId")},(e)=>({heartbeatIdx:Ko("idx_job_worker_sessions_heartbeat").on(e.heartbeatAt),expiresIdx:Ko("idx_job_worker_sessions_expires").on(e.expiresAt)}))});function L5(e){return kb({url:e.url,schema:{jobQueue:Y,jobWorkerSessions:Me},authToken:e.authToken,authTokenEnv:"JOB_QUEUE_DATABASE_AUTH_TOKEN",contentionRetryBudgetMs:0})}var B5=v(()=>{z$();D$()});class L${declarations=new Map;handlers=new Map;validators=new Map;logger;mode;finalizedRegistrations;constructor(e,t){this.logger=e.child("HandlerRegistry"),this.mode=t}registerHandler(e,t,r){if(this.finalizedRegistrations)throw Error("Job handler registrations are finalized");if(this.declarations.has(e))throw Error(`Job handler is already registered for type: ${e}`);if(this.declarations.set(e,{handler:t,pluginId:r}),this.validators.set(e,t),this.mode!=="validation-only")this.handlers.set(e,t);this.logger.debug("Registered job execution declaration",{type:e,pluginId:r,mode:this.mode})}unregisterHandler(e){this.declarations.delete(e),this.handlers.delete(e),this.validators.delete(e),this.logger.debug("Unregistered job handler",{type:e})}unregisterPluginHandlers(e){let t=[...this.declarations.entries()].filter(([,r])=>r.pluginId===e).map(([r])=>r);for(let r of t)this.declarations.delete(r),this.handlers.delete(r),this.validators.delete(r);if(t.length>0)this.logger.debug("Unregistered plugin handlers",{pluginId:e,count:t.length,types:t})}finalizeRegistrations(){return this.finalizedRegistrations??=Object.freeze([...this.declarations.entries()].sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>Object.freeze({type:e,pluginId:t.pluginId}))),this.finalizedRegistrations}getExecutionRegistrations(){return this.finalizedRegistrations}getRegisteredTypes(){return[...this.handlers.keys()]}getExclusiveTypes(){return[...this.handlers].filter(([,e])=>e.exclusive===!0).map(([e])=>e)}getHandler(e){return this.handlers.get(e)}getValidator(e){return this.validators.get(e)}}class B${tails=new Map;async run(e,t){let r=this.tails.get(e),o=()=>{},n=new Promise((i)=>{o=i});this.tails.set(e,n),await r;try{return await t()}finally{if(o(),this.tails.get(e)===n)this.tails.delete(e)}}}class j${findDuplicate(e,t,r){if(!t||t==="none")return null;let o=this.filterByDeduplicationKey(e,r).sort((i,s)=>s.createdAt-i.createdAt||s.id.localeCompare(i.id)),n=o.find((i)=>i.status===Oe.PENDING)??null;if(t==="skip"||t==="replace")return n;return n??o[0]??null}filterByDeduplicationKey(e,t){if(!t)return e;return e.filter((r)=>{let o=Qme.safeParse(r.metadata);return o.success&&o.data.deduplicationKey===t})}}var Qme;var j5=v(()=>{fe();Do();Qme=l.looseObject({deduplicationKey:l.string().optional()})});function M5(e){return`${String(e.length).padStart(2,"0")}${e}`}function Xme(e){return Yme.test(e)?`0${M5(e)}`:`1${e}`}function Gp(e){let t=Z5.exec(e);if(!t)throw Error(`Invalid brain version "${e}"`);let[,r="",o="",n="",i]=t,s=[r,o,n].map(M5).join("");return i===void 0?`${s}~`:`${s}-${i.split(".").map(Xme).join("!")}`}var Z5,Yme,U5;var Z$=v(()=>{fe();Z5=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*)?$/u,Yme=/^\d+$/u,U5=l.string().regex(Z5,"Brain version must be a semver version")});function q5(e){return JSON.stringify(new li(e).toJSON())}class U${db;transactionClient;databaseUrl;logger;deduplicator=new j$;writeRetryBudgetMs;constructor(e,t,r,o,n){this.db=e,this.transactionClient=t,this.databaseUrl=r,this.logger=o.child("JobQueueRepository"),this.writeRetryBudgetMs=n?.writeRetryBudgetMs??ehe}async insert(e){await this.write("insert",async()=>this.db.insert(Y).values(e))}async enqueueAtomic(e){return ohe.run(this.databaseUrl,async()=>{let t=Date.now()+this.writeRetryBudgetMs;return this.attemptEnqueue(e,t,1)})}async attemptEnqueue(e,t,r){let o=await this.runEnqueueTransaction(e,t,r);if(o.retry)return this.attemptEnqueue(e,t,r+1);return o.decision}async runEnqueueTransaction(e,t,r){let o=await this.acquireWriteTransaction(e,t),n={prepared:!1},i=!1;try{let s=await this.decideEnqueue(o,e,()=>{n.prepared=!0});return i=!0,await o.commit(),{retry:!1,decision:s}}catch(s){let a=i&&this.isSerializationConflict(s)&&!o.closed,c=!0;if(!o.closed)try{await o.rollback()}catch(u){c=!1,this.logger.error("Failed to roll back atomic enqueue",{type:e.jobData.type,rollbackError:u})}if(n.prepared)e.onInsertRollback?.();if(!a||!c)throw s;return await this.waitForConflictRetry("commit",e,t,r,s),{retry:!0}}finally{o.close()}}async decideEnqueue(e,t,r){let{jobData:o,strategy:n,deduplicationKey:i,beforeInsert:s}=t,a=n??"none",c=async()=>{await s?.(),r()},u=async()=>{await c(),await this.insertJob(e,o)};if(a==="none")return await u(),{kind:"inserted",jobId:o.id};let d=await this.getActiveDeduplicationCandidates(e,o.type,i),p=this.deduplicator.findDuplicate(d,a,i);if(!p)return await u(),{kind:"inserted",jobId:o.id};if(a==="skip")return await this.raiseBrainVersion(e,p.id,o),{kind:"skipped",jobId:p.id};if(a==="coalesce"){if(await this.raiseBrainVersion(e,p.id,o),(await e.execute({sql:"UPDATE `job_queue` SET `scheduledFor` = ? WHERE `id` = ? AND `status` = ?",args:[Date.now(),p.id,p.status]})).rowsAffected!==1)throw Error(`Atomic coalesce lost selected job ${p.id}`);return{kind:"coalesced",jobId:p.id}}await c();let m=Date.now();if((await e.execute({sql:"UPDATE `job_queue`\n SET `status` = ?,\n `lastError` = ?,\n `lastErrorPublic` = ?,\n `completedAt` = ?,\n `runtimeUpdatedAt` = max(?, coalesce((SELECT max(`runtimeUpdatedAt`) FROM `job_queue`), 0) + 1)\n WHERE `id` = ? AND `status` = ?",args:[Oe.FAILED,"Replaced by newer job",q5("cancelled"),m,m,p.id,Oe.PENDING]})).rowsAffected!==1)throw Error(`Atomic replace lost selected job ${p.id}`);return await this.insertJob(e,o),{kind:"replaced",jobId:o.id,replacedJobId:p.id}}async getActiveDeduplicationCandidates(e,t,r){return(await e.execute(r?{sql:"SELECT `id`, `status`, `createdAt`, `metadata`\n FROM `job_queue`\n WHERE `type` = ?\n AND json_extract(`metadata`, '$.deduplicationKey') = ?\n AND `status` IN (?, ?)",args:[t,r,Oe.PENDING,Oe.PROCESSING]}:{sql:"SELECT `id`, `status`, `createdAt`, `metadata`\n FROM `job_queue`\n WHERE `type` = ? AND `status` IN (?, ?)",args:[t,Oe.PENDING,Oe.PROCESSING]})).rows.map((n)=>this.parseDeduplicationCandidate(n))}parseDeduplicationCandidate(e){let{id:t,status:r,createdAt:o,metadata:n}=e;if(typeof t!=="string"||r!==Oe.PENDING&&r!==Oe.PROCESSING||typeof o!=="number"&&typeof o!=="bigint"||typeof n!=="string")throw Error("Invalid active job row returned during atomic enqueue");let i=JSON.parse(n);return{id:t,status:r,createdAt:Number(o),metadata:i}}async raiseBrainVersion(e,t,r){if(!r.brainVersion)return;let o=Gp(r.brainVersion);await e.execute({sql:"UPDATE `job_queue`\n SET `brainVersion` = ?, `brainVersionSortKey` = ?\n WHERE `id` = ?\n AND (`brainVersionSortKey` IS NULL OR `brainVersionSortKey` < ?)",args:[r.brainVersion,o,t,o]})}async insertJob(e,t){if((await e.execute({sql:"INSERT INTO `job_queue` (\n `id`, `type`, `data`, `result`, `source`, `metadata`,\n `status`, `priority`, `retryCount`, `maxRetries`,\n `lastError`, `createdAt`, `scheduledFor`, `startedAt`,\n `completedAt`, `brainVersion`, `brainVersionSortKey`\n ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",args:[t.id,t.type,t.data,this.serializeJson(t.result),t.source,JSON.stringify(t.metadata),t.status,t.priority,t.retryCount,t.maxRetries,t.lastError,t.createdAt,t.scheduledFor,t.startedAt,t.completedAt,t.brainVersion??null,t.brainVersion?Gp(t.brainVersion):null]})).rowsAffected!==1)throw Error(`Atomic enqueue did not insert job ${t.id}`)}serializeJson(e){if(e===void 0||e===null)return null;return JSON.stringify(e)}acquireWriteTransaction(e,t){return this.retryOnConflict("acquire",e,()=>this.transactionClient.transaction("write"),(r)=>this.isSerializationConflict(r),t)}async waitForConflictRetry(e,t,r,o,n){let i=Math.min(the*2**(o-1),rhe),s=i/2+Math.random()*(i/2);if(Date.now()+s>=r)throw this.transactionConflictError(e,t,o,n);await new Promise((a)=>setTimeout(a,s))}async retryOnConflict(e,t,r,o,n=Date.now()+this.writeRetryBudgetMs,i=1){try{return await r()}catch(s){if(!o(s))throw s;return await this.waitForConflictRetry(e,t,n,i,s),this.retryOnConflict(e,t,r,o,n,i+1)}}transactionConflictError(e,t,r,o){if(typeof t==="string")return Error(`Failed job queue write "${t}" within ${this.writeRetryBudgetMs}ms after ${r} attempts`,{cause:o});let n=t.strategy??"none",i=t.deduplicationKey?"present":"absent";return Error(`Failed to ${e} atomic enqueue transaction for type "${t.jobData.type}" within ${this.writeRetryBudgetMs}ms after ${r} attempts (strategy: ${n}, key: ${i})`,{cause:o})}write(e,t){return this.retryOnConflict("write",e,t,(r)=>{let o=new Set;for(let n=r;n!==void 0&&!o.has(n);){if(o.add(n),typeof n==="object"&&n!==null&&"code"in n&&/^SQLITE_(?:BUSY|LOCKED)(?:_|$)/u.test(String(n.code)))return!0;n=n instanceof Error?n.cause:void 0}return!1})}isSerializationConflict(e){for(let t=e;t!==void 0;){let r=typeof t==="object"&&t!==null&&"code"in t?String(t.code):"",o=Ve(t,"");if(/SQLITE_(?:BUSY|LOCKED)/u.test(r)||/SQLITE_(?:BUSY|LOCKED)|database is locked|transaction (?:busy|conflict)/iu.test(o))return!0;t=t instanceof Error?t.cause:void 0}return!1}async startWorkerSession(e,t,r=Date.now(),o=Hi,n,i){let s=r+o,a={brainVersion:n??null,brainVersionSortKey:n?Gp(n):null,stableSlotId:i??null};await this.write("start worker session",async()=>{await this.db.insert(Me).values({slotId:e,sessionId:t,startedAt:r,heartbeatAt:r,expiresAt:s,...a}).onConflictDoUpdate({target:Me.slotId,set:{sessionId:t,startedAt:r,heartbeatAt:r,expiresAt:s,...a}}),await this.pruneDeadWorkerSessions(r,o)})}async heartbeatWorkerSession(e,t,r=Date.now(),o=Hi){return(await this.write("heartbeat worker session",async()=>{let i=await this.db.update(Me).set({heartbeatAt:r,expiresAt:r+o}).where(tt(je(Me.slotId,e),je(Me.sessionId,t))).returning({slotId:Me.slotId});return await this.pruneDeadWorkerSessions(r,o),i})).length===1}async pruneDeadWorkerSessions(e,t){let r=this.db.select({id:Y.id}).from(Y).where(tt(je(Y.workerSlotId,Me.slotId),je(Y.workerSessionId,Me.sessionId),je(Y.status,Oe.PROCESSING),kn(Y.leaseExpiresAt,e)));await this.db.delete(Me).where(tt(os(Me.expiresAt,e-t),ss(r)))}async endWorkerSession(e,t){return(await this.write("end worker session",async()=>this.db.delete(Me).where(tt(je(Me.slotId,e),je(Me.sessionId,t))).returning({slotId:Me.slotId}))).length===1}async complete(e,t,r){let o=Date.now(),i=(await this.write("complete",async()=>this.db.update(Y).set({status:Oe.COMPLETED,result:t,lastError:null,lastErrorPublic:null,completedAt:o,runtimeUpdatedAt:this.nextRuntimeUpdatedAt(o)}).where(this.attemptWriteGuard(e,r)).returning({id:Y.id}))).length===1;if(i)this.logger.debug("Job completed",{jobId:e,hasResult:t!==void 0});return i}async update(e,t,r){let n=(await this.write("update",async()=>this.db.update(Y).set({data:JSON.stringify(t)}).where(this.attemptWriteGuard(e,r)).returning({id:Y.id}))).length===1;if(n)this.logger.debug("Job data updated",{jobId:e});return n}async recordAttemptProgress(e,t,r,o=Date.now()){return(await this.write("record progress",async()=>this.db.update(Y).set({attemptHeartbeatAt:o,runtimeUpdatedAt:this.nextRuntimeUpdatedAt(o),progress:r}).where(this.attemptWriteGuard(e,t)).returning({id:Y.id}))).length===1}async renewAttemptLease(e,t,r,o){return(await this.write("renew attempt lease",async()=>this.db.update(Y).set({attemptHeartbeatAt:r,leaseExpiresAt:r+o}).where(this.attemptWriteGuard(e,t)).returning({id:Y.id}))).length===1}async fail(e,t,r,o=Date.now()){let i=(await this.db.select({retryCount:Y.retryCount,maxRetries:Y.maxRetries,type:Y.type,scheduledFor:Y.scheduledFor,startedAt:Y.startedAt,runtimeUpdatedAt:Y.runtimeUpdatedAt}).from(Y).where(this.attemptWriteGuard(e,r)).limit(1))[0];if(!i)return!1;let s=i.retryCount<i.maxRetries,a=s?i.retryCount+1:i.retryCount,c=Math.min(1000*2**i.retryCount,60000),u=s?o+c:i.scheduledFor;if((await this.write("fail",async()=>this.db.update(Y).set({status:s?Oe.PENDING:Oe.FAILED,retryCount:a,lastError:t.message,lastErrorPublic:Qm(t).toJSON(),scheduledFor:u,completedAt:s?null:o,runtimeUpdatedAt:s?i.runtimeUpdatedAt:this.nextRuntimeUpdatedAt(o),startedAt:s?null:i.startedAt,attemptId:null,workerSlotId:null,workerSessionId:null,leaseExpiresAt:null,attemptHeartbeatAt:null}).where(tt(this.attemptWriteGuard(e,r),je(Y.retryCount,i.retryCount))).returning({id:Y.id}))).length!==1)return!1;if(s)this.logger.debug("Job scheduled for retry",{jobId:e,retryCount:a,backoffMs:c,scheduledFor:new Date(u).toISOString()});else this.logger.error("Job failed after max retries",{jobId:e,type:i.type,retryCount:i.retryCount,error:t.message});return!0}async retireUnownedActiveJob(e){let t=e.reason.trim();if(t.length===0)throw Error("Retired job reason must not be empty");let o=(await this.write("retire unowned job",async()=>this.db.update(Y).set({status:Oe.FAILED,lastError:t,lastErrorPublic:new li("no_handler").toJSON(),completedAt:e.now,runtimeUpdatedAt:this.nextRuntimeUpdatedAt(e.now)}).where(tt(je(Y.id,e.jobId),je(Y.type,e.expectedType),ln(je(Y.status,Oe.PENDING),je(Y.status,Oe.PROCESSING)),Mr(Y.attemptId),Mr(Y.workerSlotId),Mr(Y.workerSessionId),Mr(Y.leaseExpiresAt),Mr(Y.attemptHeartbeatAt),Mr(Y.progress),Mr(Y.result))).returning()))[0]??null;if(o)this.logger.warn("Retired unowned legacy job",{jobId:o.id,type:o.type,reason:t});return o}async getStatus(e){return(await this.db.select().from(Y).where(je(Y.id,e)).limit(1))[0]??null}async getJobsByRootJobId(e){return this.db.select().from(Y).where(C`json_extract(${Y.metadata}, '$.rootJobId') = ${e}`).orderBy(Mo(Y.createdAt),Mo(Y.id))}async getStatusByEntityId(e){return(await this.db.select().from(Y).where(C`json_extract(${Y.data}, '$.id') = ${e}`).orderBy(ga(Y.createdAt)).limit(1))[0]??null}async getStats(){let e=await this.db.select({status:Y.status,count:C`count(*)`}).from(Y).groupBy(Y.status),t={pending:0,processing:0,failed:0,completed:0,total:0};for(let r of e){let o=Number(r.count);t[r.status]=o,t.total+=o}return t}async getDiagnostics(e=Date.now()){let[t,r,o]=await Promise.all([this.db.select({type:Y.type,status:Y.status,count:C`count(*)`}).from(Y).groupBy(Y.type,Y.status),this.db.select({oldestPendingAt:C`min(case when ${Y.status} = ${Oe.PENDING} then ${Y.createdAt} end)`,duePending:C`coalesce(sum(case when ${Y.status} = ${Oe.PENDING} and ${Y.scheduledFor} <= ${e} then 1 else 0 end), 0)`,oldestDuePendingAt:C`min(case when ${Y.status} = ${Oe.PENDING} and ${Y.scheduledFor} <= ${e} then ${Y.scheduledFor} end)`,latestClaimAt:C`max(${Y.startedAt})`,oldestProcessingAt:C`min(case when ${Y.status} = ${Oe.PROCESSING} then ${Y.startedAt} end)`,staleLeaseCount:C`coalesce(sum(case when ${Y.status} = ${Oe.PROCESSING} and ${Y.leaseExpiresAt} is not null and ${Y.leaseExpiresAt} <= ${e} then 1 else 0 end), 0)`}).from(Y),this.db.select({total:C`count(*)`,active:C`coalesce(sum(case when ${Me.expiresAt} > ${e} then 1 else 0 end), 0)`,stale:C`coalesce(sum(case when ${Me.expiresAt} <= ${e} then 1 else 0 end), 0)`,latestHeartbeatAt:C`max(${Me.heartbeatAt})`}).from(Me)]),n={pending:0,processing:0,completed:0,failed:0},i=t.map((u)=>{let d=Number(u.count);return n[u.status]+=d,{type:u.type,status:u.status,count:d}}),s=r[0],a=o[0],c=(u)=>u===null||u===void 0?null:Math.max(0,e-Number(u));return{totals:n,byType:i,oldestPendingAgeMs:c(s?.oldestPendingAt),duePending:Number(s?.duePending??0),oldestDuePendingAgeMs:c(s?.oldestDuePendingAt),latestClaimAgeMs:c(s?.latestClaimAt),oldestProcessingAgeMs:c(s?.oldestProcessingAt),staleLeaseCount:Number(s?.staleLeaseCount??0),workerSessions:{total:Number(a?.total??0),active:Number(a?.active??0),stale:Number(a?.stale??0),latestHeartbeatAgeMs:c(a?.latestHeartbeatAt)}}}async getRuntimeUpdates(e,t){let r=nhe.parse(t);if(r===0)return[];return(await this.db.select().from(Y).where(C`(${Y.runtimeUpdatedAt}, ${Y.id}) > (${e.updatedAt}, ${e.jobId})`).orderBy(Mo(Y.runtimeUpdatedAt),Mo(Y.id)).limit(r)).map((n)=>({job:n,cursor:{updatedAt:n.runtimeUpdatedAt??0,jobId:n.id}}))}async cleanup(e){let t=Date.now()-e;return(await this.write("cleanup",async()=>this.db.delete(Y).where(tt(ln(je(Y.status,Oe.COMPLETED),je(Y.status,Oe.FAILED)),os(Y.completedAt,t))))).rowsAffected}async getActiveJobs(e){let t=ln(je(Y.status,Oe.PENDING),je(Y.status,Oe.PROCESSING)),r=e&&e.length>0?tt(t,is(Y.type,e)):t;return this.db.select().from(Y).where(r).orderBy(ga(Y.createdAt))}async getRecentJobs(e,t=20){let r=e&&e.length>0?is(Y.type,e):void 0;return this.db.select().from(Y).where(r).orderBy(ga(Y.createdAt)).limit(t)}async getFailedJobs(e){let t=je(Y.status,Oe.FAILED),r=e&&e.length>0?tt(t,is(Y.type,e)):t;return this.db.select().from(Y).where(r).orderBy(ga(Y.createdAt))}async claimNextReady(e){let{now:t,attemptId:r,workerSlotId:o,workerSessionId:n,leaseDurationMs:i,executableTypes:s,exclusiveTypes:a=[],brainVersion:c}=e,u=c?this.brainVersionGate(c,t):{admissible:void 0,noNewerWorker:void 0},d=this.db.select({slotId:Me.slotId}).from(Me).where(tt(je(Me.slotId,o),je(Me.sessionId,n),kn(Me.expiresAt,t))),p=this.noNewerLiveInstance(o,n,t),m=this.db.select({slotId:Me.slotId}).from(Me).where(tt(je(Me.slotId,Y.workerSlotId),je(Me.sessionId,Y.workerSessionId))),h=tt(je(Y.status,Oe.PROCESSING),ln(Mr(Y.attemptId),ss(m),os(Y.leaseExpiresAt,t))),b=bb(Y,"running"),y=this.db.select({id:b.id}).from(b).where(tt(je(b.type,Y.type),je(b.status,Oe.PROCESSING),kn(b.leaseExpiresAt,t),C`${b.id} <> ${Y.id}`)),S=a.length===0?void 0:ln(ob(Y.type,[...a]),ss(y)),x=C`${Y.status} = ${Oe.PROCESSING} AND ${Y.retryCount} + 1 > ${Y.maxRetries}`,_=this.db.select({id:Y.id}).from(Y).where(tt(is(Y.type,s),S,u.admissible,ln(tt(je(Y.status,Oe.PENDING),os(Y.scheduledFor,t)),h))).orderBy(Mo(Y.priority),Mo(Y.createdAt)).limit(1),O=(await this.write("claim",async()=>this.db.update(Y).set({status:C`CASE WHEN ${x} THEN ${Oe.FAILED} ELSE ${Oe.PROCESSING} END`,retryCount:C`CASE WHEN ${Y.status} = ${Oe.PROCESSING} THEN ${Y.retryCount} + 1 ELSE ${Y.retryCount} END`,lastError:C`CASE WHEN ${Y.status} = ${Oe.PROCESSING} THEN 'Attempt lease expired' ELSE ${Y.lastError} END`,lastErrorPublic:C`CASE WHEN ${Y.status} = ${Oe.PROCESSING} THEN ${q5("deadline_exceeded")} ELSE ${Y.lastErrorPublic} END`,startedAt:C`CASE WHEN ${x} THEN ${Y.startedAt} ELSE ${t} END`,completedAt:C`CASE WHEN ${x} THEN ${t} ELSE NULL END`,attemptId:C`CASE WHEN ${x} THEN ${Y.attemptId} ELSE ${r} END`,workerSlotId:C`CASE WHEN ${x} THEN ${Y.workerSlotId} ELSE ${o} END`,workerSessionId:C`CASE WHEN ${x} THEN ${Y.workerSessionId} ELSE ${n} END`,leaseExpiresAt:C`CASE WHEN ${x} THEN ${Y.leaseExpiresAt} ELSE ${t+i} END`,attemptHeartbeatAt:C`CASE WHEN ${x} THEN ${Y.attemptHeartbeatAt} ELSE ${t} END`,runtimeUpdatedAt:C`CASE WHEN ${x} THEN ${this.nextRuntimeUpdatedAt(t)} ELSE ${Y.runtimeUpdatedAt} END`}).where(tt(is(Y.id,_),ib(d),p,u.noNewerWorker)).returning()))[0];if(!O)return null;if(O.status===Oe.FAILED)return O;return this.logger.debug("Job claimed",{jobId:O.id,attemptId:O.attemptId,workerSlotId:o,workerSessionId:n}),O}noNewerLiveInstance(e,t,r){let o=bb(Me,"claimer"),n=bb(Me,"peer"),i=this.db.select({slotId:n.slotId}).from(n).innerJoin(o,tt(je(o.slotId,e),je(o.sessionId,t))).where(tt(je(n.stableSlotId,o.stableSlotId),kn(n.expiresAt,r),ln(kn(n.startedAt,o.startedAt),tt(je(n.startedAt,o.startedAt),kn(n.slotId,o.slotId)))));return ss(i)}brainVersionGate(e,t){let r=Gp(e),o=this.db.select({slotId:Me.slotId}).from(Me).where(tt(kn(Me.expiresAt,t),kn(Me.brainVersionSortKey,r)));return{admissible:ln(Mr(Y.brainVersionSortKey),os(Y.brainVersionSortKey,r)),noNewerWorker:ss(o)}}nextRuntimeUpdatedAt(e){return C`max(${e}, coalesce((select max(${Y.runtimeUpdatedAt}) from ${Y}), 0) + 1)`}attemptWriteGuard(e,t){return t?tt(je(Y.id,e),je(Y.status,Oe.PROCESSING),je(Y.attemptId,t)):tt(je(Y.id,e),Mr(Y.attemptId),ln(je(Y.status,Oe.PENDING),je(Y.status,Oe.PROCESSING)))}}var ehe=2000,the=5,rhe=40,nhe,ohe;var F5=v(()=>{N$();vb();D$();Rt();fe();Do();up();j5();Z$();nhe=l.number().int().min(0).max(1000),ohe=new B$});import{AsyncLocalStorage as ihe}from"async_hooks";class Ll{storage=new ihe;static createFresh(){return new Ll}constructor(){}current(){return this.storage.getStore()}run(e,t,r){if(t.length===0)throw Error("Operation ID must not be empty");let o=uo.parse(e),n=she(o);return this.storage.run(Object.freeze({provenance:n,operationId:t}),r)}}function she(e){if(Object.freeze(e.projectionLineage),e.sourceEntity)Object.freeze(e.sourceEntity);return Object.freeze(e)}var Ab=v(()=>{Rt()});class Qp{client;logger;handlerRegistry;repository;walInitialization=null;walInitializationSettled=!1;closeRequested=!1;clientClosed=!1;inFlightEnqueues=0;databaseUrl;operationContext;projectionAdmission;directWorkerSlotId=`direct:${No()}`;directWorkerSessionId=No();directLeaseDurationMs;directSessionStart=null;brainVersion;close(){this.closeRequested=!0,this.closeClientWhenReady()}static createFresh(e,t,r){return new Qp(e,t??Ar.getInstance(),r)}constructor(e,t,r){this.brainVersion=e.brainVersion===void 0?void 0:U5.parse(e.brainVersion);let{db:o,client:n,url:i}=L5(e);this.client=n,this.databaseUrl=i,this.logger=t.child("JobQueueService"),this.operationContext=r?.operationContext??Ll.createFresh(),this.projectionAdmission=r?.projectionAdmission,this.handlerRegistry=new L$(this.logger,r?.handlerRegistrationMode??"combined"),this.repository=new U$(o,n,i,this.logger),this.directLeaseDurationMs=e.claimTimeoutMs??300000}initialize(){if(this.closeRequested)return Promise.resolve();return this.walInitialization??=this.initializeWALMode(),this.walInitialization}async initializeWALMode(){try{await Ib(this.client,this.databaseUrl)}catch(e){this.logger.warn("Failed to enable WAL mode (non-fatal)",e)}finally{this.walInitializationSettled=!0,this.closeClientWhenReady()}}closeClientWhenReady(){if(!this.closeRequested||this.inFlightEnqueues>0||this.walInitialization!==null&&!this.walInitializationSettled)return;this.closeClient()}closeClient(){if(this.clientClosed)return;this.clientClosed=!0,this.client.close()}registerHandler(e,t,r){this.handlerRegistry.registerHandler(e,t,r)}unregisterHandler(e){this.handlerRegistry.unregisterHandler(e)}unregisterPluginHandlers(e){this.handlerRegistry.unregisterPluginHandlers(e)}getRegisteredTypes(){return this.handlerRegistry.getRegisteredTypes()}getHandler(e){return this.handlerRegistry.getHandler(e)}getValidator(e){return this.handlerRegistry.getValidator(e)}finalizeHandlerRegistrations(){return this.handlerRegistry.finalizeRegistrations()}getExecutionRegistrations(){return this.handlerRegistry.getExecutionRegistrations()}async enqueue(e){if(this.closeRequested)throw Error("Cannot enqueue a job after the queue service is closed");this.inFlightEnqueues++;try{return await this.enqueueValidated(e)}finally{this.inFlightEnqueues--,this.closeClientWhenReady()}}async enqueueValidated(e){let{type:t,data:r,options:o}=e,n=this.handlerRegistry.getValidator(t);if(!n)throw Error(`No job type declared: ${t}`);let i=n.validateAndParse(r);if(i===null)throw Error(`Invalid job data for type: ${t}`);let s=Date.now(),a=No(),c=o?.rootJobId??(o?.detached?a:this.operationContext.current()?.provenance.rootJobId)??a,u=this.createJobProvenance(a,c,o),d=o?.metadata??{operationType:"data_processing"},{provenance:p,...m}=d,h={id:a,type:t,data:JSON.stringify(i),status:Oe.PENDING,priority:o?.priority??0,maxRetries:o?.maxRetries??3,retryCount:0,source:o?.source??null,metadata:{...m,...o?.deduplicationKey&&{deduplicationKey:o.deduplicationKey},rootJobId:c,provenance:u},createdAt:s,scheduledFor:o?.delayMs?s+o.delayMs:s,result:null,lastError:null,startedAt:null,completedAt:null,brainVersion:this.brainVersion},b,y=()=>{b?.rollback(),b=void 0};try{let S=await this.repository.enqueueAtomic({jobData:h,strategy:o?.deduplication,deduplicationKey:o?.deduplicationKey,beforeInsert:async()=>{b=await this.projectionAdmission?.reserveJobAdmission(u)},onInsertRollback:y});if(b?.commit(),b=void 0,S.kind==="skipped")this.logger.debug("Skipping duplicate job (already pending)",{type:t,existingJobId:S.jobId});else if(S.kind==="coalesced")this.logger.debug("Coalescing with existing job",{type:t,existingJobId:S.jobId});else{if(S.kind==="replaced")this.logger.debug("Replacing duplicate job",{type:t,oldJobId:S.replacedJobId});this.logger.debug("Job enqueued",{id:S.jobId,type:t,priority:h.priority,rootJobId:h.metadata.rootJobId})}return S.jobId}catch(S){throw y(),this.logger.error("Failed to enqueue job",{type:t,error:Ve(S)}),S}}createJobProvenance(e,t,r){let o=this.operationContext.current(),n=r?.metadata.provenance??o?.provenance,i=n?.rootJobId===t?n:void 0,s=o?.provenance.rootJobId===t?o.operationId:void 0,a=r?.projection,c=a?[...i?.projectionLineage??[],a.id]:[...i?.projectionLineage??[]],u=a?.id??i?.projectionId;return uo.parse({rootJobId:t,causationId:s??i?.causationId??e,...u?{projectionId:u}:{},projectionLineage:c,...a?.sourceEntity?{sourceEntity:a.sourceEntity}:i?.sourceEntity?{sourceEntity:i.sourceEntity}:{},derivationDepth:c.length})}async dequeue(e){let t=this.handlerRegistry.getRegisteredTypes();if(t.length===0)return null;let{onTerminalReclaim:r,...o}=e??await this.getDirectClaimOptions(),n=Date.now(),i=await this.repository.claimNextReady({...o,workerSlotId:this.sessionSlotId(o.workerSlotId,o.workerSessionId),brainVersion:this.brainVersion,now:n,attemptId:No(),executableTypes:t,exclusiveTypes:this.handlerRegistry.getExclusiveTypes()});if(!i)return null;if(i.status===Oe.FAILED)return this.logger.warn("Expired attempt failed terminally on reclaim",{id:i.id,type:i.type,retryCount:i.retryCount}),await r?.(i),null;return this.logger.debug("Job dequeued",{id:i.id,type:i.type,priority:i.priority,retryCount:i.retryCount,attemptId:i.attemptId,workerSlotId:i.workerSlotId,workerSessionId:i.workerSessionId}),i}async startWorkerSession(e,t,r=Hi){await this.repository.startWorkerSession(this.sessionSlotId(e,t),t,Date.now(),r,this.brainVersion,this.versionedSlotId(e))}heartbeatWorkerSession(e,t,r=Hi){return this.repository.heartbeatWorkerSession(this.sessionSlotId(e,t),t,Date.now(),r)}endWorkerSession(e,t){return this.repository.endWorkerSession(this.sessionSlotId(e,t),t)}versionedSlotId(e){return this.brainVersion?`${e}@${this.brainVersion}`:e}sessionSlotId(e,t){return`${this.versionedSlotId(e)}#${t}`}renewAttemptLease(e,t,r){return this.repository.renewAttemptLease(e,t,Date.now(),r)}recordAttemptProgress(e,t,r){return this.repository.recordAttemptProgress(e,t,r)}complete(e,t,r){return this.repository.complete(e,t,r)}update(e,t,r){return this.repository.update(e,t,r)}fail(e,t,r){return this.repository.fail(e,t,r)}retireUnownedActiveJob(e){return this.repository.retireUnownedActiveJob(e)}async getDirectClaimOptions(){return this.directSessionStart??=this.repository.startWorkerSession(this.sessionSlotId(this.directWorkerSlotId,this.directWorkerSessionId),this.directWorkerSessionId,Date.now(),this.directLeaseDurationMs,this.brainVersion),await this.directSessionStart,{workerSlotId:this.directWorkerSlotId,workerSessionId:this.directWorkerSessionId,leaseDurationMs:this.directLeaseDurationMs}}async getStatus(e){return this.repository.getStatus(e)}async getJobsByRootJobId(e){return this.repository.getJobsByRootJobId(e)}async getStatusByEntityId(e){return this.repository.getStatusByEntityId(e)}async getStats(){return this.repository.getStats()}getDiagnostics(e){return this.repository.getDiagnostics(e)}async waitForIdle(e={}){let t=e.quietMs??250,r=e.pollIntervalMs??25,o=Date.now()+(e.timeoutMs??30000),n=async(i)=>{e.signal?.throwIfAborted();let{totals:s}=await this.getDiagnostics(),c=s.pending===0&&s.processing===0?i??Date.now():null;if(c!==null&&Date.now()-c>=t)return;if(Date.now()>=o)throw Error(`Timed out waiting for the job queue to settle: ${s.pending} pending, ${s.processing} processing`);return await Bun.sleep(r),n(c)};return n(null)}getRuntimeUpdates(e,t=1000){return this.repository.getRuntimeUpdates(e,t)}async cleanup(e){let t=await this.repository.cleanup(e);if(t>0)this.logger.info("Cleaned up old jobs",{deletedCount:t,olderThanMs:e});return t}async getActiveJobs(e){return this.repository.getActiveJobs(e)}async getRecentJobs(e,t){return this.repository.getRecentJobs(e,t)}async getFailedJobs(e){return this.repository.getFailedJobs(e)}}var K5=v(()=>{cp();HT();up();Do();z$();B5();F5();Rt();Ab();Z$()});var M$=()=>{};var H5=v(()=>{cp();Do();up();Do();M$();Ab()});var J5=v(()=>{Do();M$()});var Tb,V5;var q$=v(()=>{fe();Tb=l.object({success:l.boolean(),data:l.unknown().optional(),error:l.string().optional(),code:l.string().optional()}),V5=l.object({id:l.string().min(1),timestamp:l.string(),type:l.string().min(1),source:l.string().min(1),target:l.string().optional(),metadata:l.record(l.string(),l.unknown()).optional()})});var nFe;var W5=v(()=>{fe();q$();nFe=l.union([l.object({noop:l.literal(!0)}),Tb])});var Rb=v(()=>{W5()});var G5=v(()=>{Rb()});var Q5=v(()=>{Rb()});var Y5=v(()=>{Q5()});var wFe;var F$=v(()=>{fe();wFe=l.looseObject({issues:l.array(l.looseObject({message:l.string()})).optional()})});var X5=v(()=>{G5();Rb();Y5();F$();Rt();Ab()});var ghe;var e8=v(()=>{fe();q$();ghe=l.object({id:l.string().min(1),requestId:l.string().min(1),success:l.boolean(),data:l.unknown().optional(),error:l.object({message:l.string(),code:l.string().optional()}).optional(),timestamp:l.string().datetime()})});var jFe;var t8=v(()=>{Rt();jFe=new li("invalid_response").toJSON()});var r8=v(()=>{X5();e8();F$();t8()});var o3e;var n8=v(()=>{fe();r8();lp();Do();o3e=l.preprocess((e)=>{if(typeof e!=="string")return e;return JSON.parse(e)},l.record(l.string(),l.unknown()))});var a3e;var o8=v(()=>{fe();a3e=l.record(l.string(),l.unknown())});var i8=v(()=>{Rt();cp()});var s8=v(()=>{K5();H5();J5();n8();o8();up();Do();lp();i8()});var K$={};Lt(K$,{LEGACY_PROJECTION_JOB_TYPES:()=>c8,LEGACY_PROJECTION_RETIREMENT_REASON:()=>u8,legacyProjectionJobTypeSchema:()=>l8,retireLegacyProjectionJob:()=>whe});import{existsSync as bhe}from"fs";import{resolve as She}from"path";function a8(e){return{id:e.id,type:e.type,status:e.status,retryCount:e.retryCount,maxRetries:e.maxRetries,createdAt:e.createdAt,startedAt:e.startedAt,completedAt:e.completedAt}}function vhe(e,t){if(e.type!==t)throw Error(`Job ${e.id} has type ${e.type}; expected ${t}`);if(e.status!=="pending"&&e.status!=="processing")throw Error(`Job ${e.id} is already terminal (${e.status})`);if(e.attemptId!==null||e.workerSlotId!==null||e.workerSessionId!==null||e.leaseExpiresAt!==null||e.attemptHeartbeatAt!==null)throw Error(`Job ${e.id} still has attempt ownership`);if(e.progress!==null||e.result!=null)throw Error(`Job ${e.id} contains partial progress or a result`)}async function whe(e){let t=She(e.databasePath);if(!bhe(t))throw Error(`Job database does not exist: ${t}`);let r=l8.parse(e.jobType),o=Qp.createFresh({url:`file:${t}`});try{let n=await o.getStatus(e.jobId);if(!n)throw Error(`Job not found: ${e.jobId}`);if(vhe(n,r),e.dryRun){if(e.confirmation!==void 0)throw Error("Dry-run recovery must not include confirmation");return{databasePath:t,job:a8(n),retired:!1}}let i=`retire:${n.id}`;if(e.confirmation!==i)throw Error(`Refusing to retire ${n.id}; expected --confirm ${i}`);let s=await o.retireUnownedActiveJob({jobId:n.id,expectedType:r,reason:u8,now:e.now?.()??Date.now()});if(!s)throw Error(`Job ${n.id} changed or acquired ownership before retirement`);return{databasePath:t,job:a8(s),retired:!0}}finally{o.close()}}var c8,l8,u8="Retired legacy projection job superseded by scheduler-owned projections";var H$=v(()=>{s8();fe();c8=["conversation-memory:project","skill:project","swot:derive","topic:project"],l8=l.enum(c8)});function Mt(e,t,r,o,n){return p8.parse({id:e,operation:t,count:r,targetProbeCount:o,settleMs:n})}function V$(e){return Xp.parse(structuredClone(khe[e]))}function ef(e){let t=`stress:${e.handle}`;if(e.confirmation!==t)throw Error(`Directory-sync stress requires --confirm ${t}`);let r=/(^|[-_.])smoke($|[-_.])/i;if(!r.test(e.handle)||!r.test(e.domain)||!r.test(e.contentRepo))throw Error("Directory-sync stress is smoke-only; handle, domain, and content repository must all identify smoke")}async function Ob(e,t={}){let r=t.fetchImpl??fetch,o=t.now??(()=>new Date),n=t.timeoutMs??20000,i=o(),s=new AbortController,a=setTimeout(()=>s.abort(),n);try{let c=await r(e,{method:"GET",signal:s.signal});return await c.arrayBuffer(),J$.parse({timestamp:i.toISOString(),endpoint:new URL(e).pathname,status:c.status,durationMs:Math.max(0,o().getTime()-i.getTime()),ok:c.ok})}catch(c){return J$.parse({timestamp:i.toISOString(),endpoint:new URL(e).pathname,status:0,durationMs:Math.max(0,o().getTime()-i.getTime()),ok:!1,error:Ihe(c)})}finally{clearTimeout(a)}}async function W$(e,t){let r=Xp.parse(e),o=[],n,i=await t.prepare(r),s,a;try{try{await t.startMonitoring()}catch(c){n=`monitor: ${$b(c)}`}if(!n)for(let c of r.phases)try{let u=f8.parse(await t.executePhase(c,i));if(o.push(u),!u.success){n=`${c.id}: ${u.error??"phase failed"}`;break}}catch(u){let d=$b(u);o.push({id:c.id,operation:c.operation,count:c.count,success:!1,error:d}),n=`${c.id}: ${d}`;break}}finally{try{if(s=m8.parse(await t.cleanup(i)),!s.success&&!n)n=s.error??"cleanup failed"}catch(c){let u=$b(c);s={success:!1,probesRemaining:0,error:u},n??=`cleanup: ${u}`}try{a=h8.parse(await t.stopMonitoring())}catch(c){let u=$b(c);a={health:[],runtime:[]},n??=`monitor: ${u}`}}return n??=y8(a,r.maximumExternalAiCalls??0),g8.parse({profile:r.profile,success:n===void 0&&o.length===r.phases.length&&s.success,baseline:i,phases:o,cleanup:s,metrics:a,...n?{failure:n}:{}})}function y8(e,t=0){let r=e.health.find((i)=>!i.ok);if(r)return`health: ${r.endpoint} unavailable`;let o=e.externalAiCalls??0;if(o>t)return t===0?`external AI: observed ${o} call(s)`:`external AI: observed ${o} call(s), cap ${t}`;if(e.container?.oomKilled)return"container: OOM killed";let n=e.container?.restartCount??0;if(n>0)return`container: restarted ${n} time(s)`;if(e.container&&e.container.status!=="running")return`container: ${e.container.status}`;return}function Ihe(e){if(e instanceof Error)return`${e.name}: ${e.message}`;return String(e)}function $b(e){return Ve(e)}var Yp,d8,p8,Xp,xhe,J$,_he,f8,m8,Ehe,h8,g8,khe;var Cb=v(()=>{fe();Yp=l.enum(["regression","load","stress"]),d8=l.enum(["add","update","rename","delete"]),p8=l.object({id:l.string().min(1),operation:d8,count:l.number().int().positive().max(700),targetProbeCount:l.number().int().min(0).max(700),settleMs:l.number().int().nonnegative().max(300000)}),Xp=l.object({profile:Yp,maximumProbeCount:l.number().int().positive().max(700),maximumExternalAiCalls:l.number().int().nonnegative().max(1e4).optional(),phases:l.array(p8).min(1)}),xhe=l.object({entities:l.number().int().nonnegative(),notes:l.number().int().nonnegative(),version:l.string().min(1)}),J$=l.object({timestamp:l.iso.datetime(),endpoint:l.string().startsWith("/"),status:l.number().int().nonnegative(),durationMs:l.number().nonnegative(),ok:l.boolean(),error:l.string().optional()}),_he=l.object({timestamp:l.iso.datetime(),cpuPercent:l.number().nonnegative(),memoryPercent:l.number().nonnegative(),pids:l.number().int().nonnegative()}),f8=l.object({id:l.string().min(1),operation:d8,count:l.number().int().positive(),success:l.boolean(),commitLatencyMs:l.number().nonnegative().optional(),persistenceLatencyMs:l.number().nonnegative().optional(),error:l.string().optional()}),m8=l.object({success:l.boolean(),probesRemaining:l.number().int().nonnegative(),finalEntities:l.number().int().nonnegative().optional(),finalNotes:l.number().int().nonnegative().optional(),contentTreeRestored:l.boolean().optional(),error:l.string().optional()}),Ehe=l.object({status:l.string(),restartCount:l.number().int().nonnegative(),oomKilled:l.boolean()}),h8=l.object({health:l.array(J$),runtime:l.array(_he),externalAiCalls:l.number().int().nonnegative().optional(),container:Ehe.optional()}),g8=l.object({profile:Yp,success:l.boolean(),baseline:xhe,phases:l.array(f8),cleanup:m8,metrics:h8,failure:l.string().optional()}),khe={regression:{profile:"regression",maximumProbeCount:20,phases:[Mt("add20","add",20,20,0),Mt("update20","update",20,20,30000),Mt("delete20","delete",20,0,150000)]},load:{profile:"load",maximumProbeCount:350,phases:[Mt("add50","add",50,50,0),Mt("add150","add",100,150,0),Mt("add350","add",200,350,0),Mt("update350a","update",350,350,45000),Mt("rename100","rename",100,350,45000),Mt("update350b","update",350,350,45000),Mt("delete350","delete",350,0,150000)]},stress:{profile:"stress",maximumProbeCount:700,phases:[Mt("add50","add",50,50,0),Mt("add150","add",100,150,0),Mt("add350","add",200,350,0),Mt("add700","add",350,700,0),Mt("update700a","update",700,700,45000),Mt("rename200","rename",200,700,45000),Mt("update700b","update",700,700,45000),Mt("delete700","delete",700,0,150000)]}}});import{spawn as Ahe}from"child_process";async function b8(e,t,r,o){let n=await e(t,r,o);if(n.exitCode!==0)throw oo(t,r,n);return n}function oo(e,t,r){let o=r.stderr.trim()||r.stdout.trim();return Error(`${e} ${t.join(" ")} exited with ${r.exitCode}${o?`: ${o}`:""}`)}var Vo=async(e,t,r={})=>new Promise((o,n)=>{let i=Ahe(e,[...t],{cwd:r.cwd,env:r.env?{...process.env,...r.env}:process.env,stdio:["pipe","pipe","pipe"]}),s="",a="";i.stdout.setEncoding("utf8"),i.stderr.setEncoding("utf8"),i.stdout.on("data",(c)=>{s+=c}),i.stderr.on("data",(c)=>{a+=c}),i.on("error",n),i.on("close",(c)=>{o({exitCode:c??1,stdout:s,stderr:a})}),i.stdin.end(r.stdin)});var tf=()=>{};class Bl{#e;#t;dir;constructor(e,t,r){this.#e=e,this.dir=t,this.#t=r}static async clone(e,t,r,o){let n=new Bl(e,r,o);return await b8(e,"git",["-c","credential.helper=","-c",`credential.helper=${S8}`,"clone","--branch","main","--single-branch",`https://github.com/${t}.git`,r],{env:n.environment()}),await n.run(["config","--local","credential.helper",S8]),await n.run(["reset","--hard","origin/main"]),n}async run(e,t=!0){let r=await this.#e("git",e,{cwd:this.dir,env:this.environment()});if(t&&r.exitCode!==0)throw oo("git",e,r);return r}async output(e){return(await this.run(e)).stdout.trim()}async sync(e=!1){if(await this.run(["fetch","origin","main"]),e)await this.run(["reset","--hard","origin/main"]);else await this.run(["pull","--rebase","origin","main"])}async commitAll(e){await this.run(["add","-A"]),await this.run(["-c","user.name=brains-ops","-c","user.email=ops@rizom.ai","commit","-m",e])}async pushMainWithRebase(){for(let e=1;e<=5;e+=1){if((await this.run(["push","origin","main"],!1)).exitCode===0)return;await this.run(["pull","--rebase","origin","main"])}throw Error("Unable to push content main after five rebase attempts")}async pruneStressBackupBranches(){let t=(await this.run(["ls-remote","--heads","origin","refs/heads/ops/directory-sync-stress-backup-*"])).stdout.split(/\r?\n/).map((r)=>r.match(/\trefs\/heads\/(ops\/directory-sync-stress-backup-[^\s]+)$/)?.[1]).filter((r)=>r!==void 0).sort();for(let r of t)await this.run(["push","origin","--delete",r]);return t}environment(){return{GH_TOKEN:this.#t,GITHUB_TOKEN:this.#t}}}var S8='!f() { test "$1" = get && echo username=x-access-token && echo "password=$GH_TOKEN"; }; f';var v8=v(()=>{tf()});function rf(e){return e.entityCounts.find((t)=>t.entityType==="note")?.count??0}class G${#e;#t=[];#r=[];#n=new Set(["/health/ready"]);#o=!0;#i;#a;#s="";#c=0;#l;constructor(e){this.#e=e}get startedAt(){return this.#s}get error(){return this.#a}get healthSamples(){return this.#t}get runtimeSamples(){return this.#r}gateHealthSamples(){return this.#t.slice(this.#c,this.#l??this.#t.length)}markGateEnd(){this.#l=this.#t.length}async discoverEndpoints(){for(let e of["/health/live","/health/operate"])if((await Ob(`https://${this.#e.domain}${e}`,{fetchImpl:this.#e.fetchImpl,now:this.#e.now,timeoutMs:5000})).status!==404)this.#n.add(e)}start(){this.#o=!1,this.#a=void 0,this.#c=this.#t.length,this.#l=void 0,this.#s=this.#e.now().toISOString(),this.#i=Promise.all([this.#m(),this.#f()]).then(()=>{return}).catch((e)=>{this.#a=e,this.#o=!0})}async stop(){this.#o=!0,await this.#i}async waitForHealthSnapshot(e){return this.waitForEntityBaseline(void 0,void 0,e)}async waitForEntityBaseline(e,t,r){let o=this.#e.now().getTime();while(this.#e.now().getTime()-o<r){let n=await this.fetchHealthPayload();if(this.#p(n,e,t))return n;await this.#e.sleep(5000)}return}async waitForStableEntityBaseline(e,t,r){let o=this.#e.now().getTime(),n=0;while(this.#e.now().getTime()-o<r){let i=await this.fetchHealthPayload();if(this.#p(i,e,t)){if(n+=1,n===2)return i}else n=0;await this.#e.sleep(5000)}return}async fetchHealthPayload(){let e=await this.#d();if(e===void 0)return;let t=await this.#e.readEntityCounts();if(!t)return;return{version:e,entities:t.reduce((r,o)=>r+o.count,0),entityCounts:t}}async#d(){let e=this.#e.now(),t=new AbortController,r=setTimeout(()=>t.abort(),20000);try{let o=await this.#e.fetchImpl(`https://${this.#e.domain}/health/operate`,{signal:t.signal}),n=await o.text();if(this.#t.push({timestamp:e.toISOString(),endpoint:"/health/operate",status:o.status,durationMs:Math.max(0,this.#e.now().getTime()-e.getTime()),ok:o.ok}),!o.ok)return;return The.parse(JSON.parse(n)).app.version}catch(o){this.#t.push({timestamp:e.toISOString(),endpoint:"/health/operate",status:0,durationMs:Math.max(0,this.#e.now().getTime()-e.getTime()),ok:!1,error:o instanceof Error?`${o.name}: ${o.message}`:String(o)});return}finally{clearTimeout(r)}}#p(e,t,r){return e!==void 0&&(t===void 0||rf(e)===t)&&(r===void 0||e.entities===r)}async#m(){while(!this.#o){for(let e of this.#n)this.#t.push(await Ob(`https://${this.#e.domain}${e}`,{fetchImpl:this.#e.fetchImpl,now:this.#e.now,timeoutMs:20000}));await this.#e.sleep(4000)}}async#f(){while(!this.#o){let e=await this.#e.sampleRuntime();if(e)this.#r.push(e);await this.#e.sleep(1000)}}}var w8,The;var x8=v(()=>{fe();Cb();w8=l.array(l.object({entityType:l.string(),count:l.number().int().nonnegative()})),The=l.object({status:l.literal("ready"),operationalStatus:l.literal("operational"),app:l.object({version:l.string()})})});var Pb={};Lt(Pb,{applyDirectorySyncStressPhase:()=>R8,cleanupDirectorySyncStress:()=>I8,listProbeFiles:()=>va,parseStressRuntimeSample:()=>$8,removeProbeFiles:()=>nO,runDeployedDirectorySyncStress:()=>E8,runStressCommand:()=>Vo,verifyDirectorySyncStressAccess:()=>k8});import{chmod as Rhe,mkdir as Y$,mkdtemp as X$,readFile as $he,readdir as Ohe,rename as Che,rm as of,writeFile as Tn}from"fs/promises";import{tmpdir as eO}from"os";import{join as ct,resolve as tO}from"path";async function E8(e){let t=e.now??(()=>new Date),r=t().toISOString(),o=oO(r),n=tO(e.artifactsDir??ct(e.rootDir,".brains-ops","stress",o));await Y$(n,{recursive:!0});let{pilot:i,user:s}=await rO(e.rootDir,e.handle);ef({handle:s.handle,domain:s.domain,contentRepo:s.contentRepo,confirmation:e.confirmation});let a=Yp.parse(e.profile),c=e.plan?Xp.parse(e.plan):V$(a);if(c.profile!==a)throw Error(`Directory-sync stress plan profile ${c.profile} does not match requested profile ${a}`);if((c.maximumExternalAiCalls??0)===0)T8(s);let u=Phe.parse(e.env??process.env),d=new A8({runId:o,artifactsDir:n,user:s,githubOrg:i.githubOrg,serverLabel:`${i.contentRepoPrefix}${s.handle}`,environment:u,fetchImpl:e.fetchImpl??fetch,commandRunner:e.commandRunner??Vo,logger:e.logger??console.info,now:t,sleep:e.sleep??Bun.sleep}),p;try{p=await W$(c,d)}finally{await d.dispose()}let m={runId:o,artifactsDir:n,target:{handle:s.handle,domain:s.domain,contentRepo:`${i.githubOrg}/${s.contentRepo}`},startedAt:r,completedAt:t().toISOString(),report:p};return await jhe(m),m}async function k8(e){let r=(e.now??(()=>new Date))().toISOString(),o=oO(r),n=tO(e.artifactsDir??ct(e.rootDir,".brains-ops","stress",`access-check-${o}`));await Y$(n,{recursive:!0});let{pilot:i,user:s}=await rO(e.rootDir,e.handle);ef({handle:s.handle,domain:s.domain,contentRepo:s.contentRepo,confirmation:e.confirmation}),T8(s);let a=(e.env??process.env).CONTENT_REPO_ADMIN_TOKEN;if(!a)throw Error("Missing CONTENT_REPO_ADMIN_TOKEN");let c=await X$(ct(eO(),"brains-ops-directory-sync-access-check-"));try{let u=await Bl.clone(e.commandRunner??Vo,`${i.githubOrg}/${s.contentRepo}`,ct(c,"content"),a),d=await u.output(["rev-parse","HEAD"]);await u.run(["push","--dry-run","origin",`HEAD:refs/heads/ops/directory-sync-stress-access-check-${o}`]);let p={success:!0,artifactsDir:n,checkedAt:r,remoteHead:d,target:{handle:s.handle,domain:s.domain,contentRepo:`${i.githubOrg}/${s.contentRepo}`}};return await Tn(ct(n,"access-check.json"),`${JSON.stringify(p,null,2)}
|
|
437
|
+
`;await t.run(n);let s=(await t.values(C`SELECT id, hash, created_at FROM ${C.identifier(o)} ORDER BY created_at DESC LIMIT 1`))[0]??void 0;await t.transaction(async(a)=>{for(let c of e)if(!s||Number(s[2])<c.folderMillis){for(let u of c.sql)await a.run(C.raw(u));await a.run(C`INSERT INTO ${C.identifier(o)} ("hash", "created_at") VALUES(${c.hash}, ${c.folderMillis})`)}})}}});var m$;var h5=v(()=>{$e();m$=class m${static[F]="TypedQueryBuilder";getSelectedFields(){return this._.selectedFields}}});function pb(e,t){return(r,o,...n)=>{let i=[o,...n].map((s)=>({type:e,isAll:t,rightSelect:s}));for(let s of i)if(!Lp(r.getSelectedFields(),s.rightSelect.getSelectedFields()))throw Error("Set operator error (union / intersect / except): selected fields are not the same or are in a different order");return r.addSetOperators(i)}}var An,g5,h$,Bme=()=>({union:jme,unionAll:Zme,intersect:Ume,except:Mme}),jme,Zme,Ume,Mme;var g$=v(()=>{$e();h5();qo();ba();Yt();En();sr();Sr();Uo();Cl();Kp();An=class An{static[F]="SQLiteSelectBuilder";fields;session;dialect;withList;distinct;constructor(e){this.fields=e.fields,this.session=e.session,this.dialect=e.dialect,this.withList=e.withList,this.distinct=e.distinct}from(e){let t=!!this.fields,r;if(this.fields)r=this.fields;else if(oe(e,pt))r=Object.fromEntries(Object.keys(e._.selectedFields).map((o)=>[o,e[o]]));else if(oe(e,Jo))r=e[ft].selectedFields;else if(oe(e,_e))r={};else r=rb(e);return new h$({table:e,fields:r,isPartialSelect:t,session:this.session,dialect:this.dialect,withList:this.withList,distinct:this.distinct})}};g5=class g5 extends m${static[F]="SQLiteSelectQueryBuilder";_;config;joinsNotNullableMap;tableName;isPartialSelect;session;dialect;cacheConfig=void 0;usedTables=new Set;constructor({table:e,fields:t,isPartialSelect:r,session:o,dialect:n,withList:i,distinct:s}){super();this.config={withList:i,table:e,fields:{...t},distinct:s,setOperators:[]},this.isPartialSelect=r,this.session=o,this.dialect=n,this._={selectedFields:t,config:this.config},this.tableName=Bp(e),this.joinsNotNullableMap=typeof this.tableName==="string"?{[this.tableName]:!0}:{};for(let a of In(e))this.usedTables.add(a)}getUsedTables(){return[...this.usedTables]}createJoin(e){return(t,r)=>{let o=this.tableName,n=Bp(t);for(let i of In(t))this.usedTables.add(i);if(typeof n==="string"&&this.config.joins?.some((i)=>i.alias===n))throw Error(`Alias "${n}" is already used in this query`);if(!this.isPartialSelect){if(Object.keys(this.joinsNotNullableMap).length===1&&typeof o==="string")this.config.fields={[o]:this.config.fields};if(typeof n==="string"&&!oe(t,_e)){let i=oe(t,pt)?t._.selectedFields:oe(t,an)?t[ft].selectedFields:t[he.Symbol.Columns];this.config.fields[n]=i}}if(typeof r==="function")r=r(new Proxy(this.config.fields,new at({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})));if(!this.config.joins)this.config.joins=[];if(this.config.joins.push({on:r,table:t,joinType:e,alias:n}),typeof n==="string")switch(e){case"left":{this.joinsNotNullableMap[n]=!1;break}case"right":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([i])=>[i,!1])),this.joinsNotNullableMap[n]=!0;break}case"cross":case"inner":{this.joinsNotNullableMap[n]=!0;break}case"full":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([i])=>[i,!1])),this.joinsNotNullableMap[n]=!1;break}}return this}}leftJoin=this.createJoin("left");rightJoin=this.createJoin("right");innerJoin=this.createJoin("inner");fullJoin=this.createJoin("full");crossJoin=this.createJoin("cross");createSetOperator(e,t){return(r)=>{let o=typeof r==="function"?r(Bme()):r;if(!Lp(this.getSelectedFields(),o.getSelectedFields()))throw Error("Set operator error (union / intersect / except): selected fields are not the same or are in a different order");return this.config.setOperators.push({type:e,isAll:t,rightSelect:o}),this}}union=this.createSetOperator("union",!1);unionAll=this.createSetOperator("union",!0);intersect=this.createSetOperator("intersect",!1);except=this.createSetOperator("except",!1);addSetOperators(e){return this.config.setOperators.push(...e),this}where(e){if(typeof e==="function")e=e(new Proxy(this.config.fields,new at({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})));return this.config.where=e,this}having(e){if(typeof e==="function")e=e(new Proxy(this.config.fields,new at({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})));return this.config.having=e,this}groupBy(...e){if(typeof e[0]==="function"){let t=e[0](new Proxy(this.config.fields,new at({sqlAliasedBehavior:"alias",sqlBehavior:"sql"})));this.config.groupBy=Array.isArray(t)?t:[t]}else this.config.groupBy=e;return this}orderBy(...e){if(typeof e[0]==="function"){let t=e[0](new Proxy(this.config.fields,new at({sqlAliasedBehavior:"alias",sqlBehavior:"sql"}))),r=Array.isArray(t)?t:[t];if(this.config.setOperators.length>0)this.config.setOperators.at(-1).orderBy=r;else this.config.orderBy=r}else{let t=e;if(this.config.setOperators.length>0)this.config.setOperators.at(-1).orderBy=t;else this.config.orderBy=t}return this}limit(e){if(this.config.setOperators.length>0)this.config.setOperators.at(-1).limit=e;else this.config.limit=e;return this}offset(e){if(this.config.setOperators.length>0)this.config.setOperators.at(-1).offset=e;else this.config.offset=e;return this}getSQL(){return this.dialect.buildSelectQuery(this.config)}toSQL(){let{typings:e,...t}=this.dialect.sqlToQuery(this.getSQL());return t}as(e){let t=[];if(t.push(...In(this.config.table)),this.config.joins)for(let r of this.config.joins)t.push(...In(r.table));return new Proxy(new pt(this.getSQL(),this.config.fields,e,!1,[...new Set(t)]),new at({alias:e,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}getSelectedFields(){return new Proxy(this.config.fields,new at({alias:this.tableName,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}$dynamic(){return this}};h$=class h$ extends g5{static[F]="SQLiteSelect";_prepare(e=!0){if(!this.session)throw Error("Cannot execute a query on a query builder. Please use a database instance instead.");let t=cn(this.config.fields),r=this.session[e?"prepareOneTimeQuery":"prepareQuery"](this.dialect.sqlToQuery(this.getSQL()),t,"all",!0,void 0,{type:"select",tables:[...this.usedTables]},this.cacheConfig);return r.joinsNotNullableMap=this.joinsNotNullableMap,r}$withCache(e){return this.cacheConfig=e===void 0?{config:{},enable:!0,autoInvalidate:!0}:e===!1?{enable:!1}:{enable:!0,autoInvalidate:!0,...e},this}prepare(){return this._prepare(!1)}run=(e)=>this._prepare().run(e);all=(e)=>this._prepare().all(e);get=(e)=>this._prepare().get(e);values=(e)=>this._prepare().values(e);async execute(){return this.all()}};VF(h$,[vr]);jme=pb("union",!1),Zme=pb("union",!0),Ume=pb("intersect",!1),Mme=pb("except",!1)});var Sa;var fb=v(()=>{$e();ba();db();En();g$();Sa=class Sa{static[F]="SQLiteQueryBuilder";dialect;dialectConfig;constructor(e){this.dialect=oe(e,zl)?e:void 0,this.dialectConfig=oe(e,zl)?void 0:e}$with=(e,t)=>{let r=this;return{as:(n)=>{if(typeof n==="function")n=n(r);return new Proxy(new zp(n.getSQL(),t??("getSelectedFields"in n?n.getSelectedFields()??{}:{}),e,!0),new at({alias:e,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}}};with(...e){let t=this;function r(n){return new An({fields:n??void 0,session:void 0,dialect:t.getDialect(),withList:e})}function o(n){return new An({fields:n??void 0,session:void 0,dialect:t.getDialect(),withList:e,distinct:!0})}return{select:r,selectDistinct:o}}select(e){return new An({fields:e??void 0,session:void 0,dialect:this.getDialect()})}selectDistinct(e){return new An({fields:e??void 0,session:void 0,dialect:this.getDialect(),distinct:!0})}getDialect(){if(!this.dialect)this.dialect=new p$(this.dialectConfig);return this.dialect}}});var mb,y$;var y5=v(()=>{$e();qo();Yt();Fo();sr();Sr();Cl();fb();mb=class mb{constructor(e,t,r,o){this.table=e,this.session=t,this.dialect=r,this.withList=o}static[F]="SQLiteInsertBuilder";values(e){if(e=Array.isArray(e)?e:[e],e.length===0)throw Error("values() must be called with at least one value");let t=e.map((r)=>{let o={},n=this.table[he.Symbol.Columns];for(let i of Object.keys(r)){let s=r[i];o[i]=oe(s,_e)?s:new Ur(s,n[i])}return o});return new y$(this.table,t,this.session,this.dialect,this.withList)}select(e){let t=typeof e==="function"?e(new Sa):e;if(!oe(t,_e)&&!Lp(this.table[Xy],t._.selectedFields))throw Error("Insert select error: selected fields are not the same or are in a different order compared to the table definition");return new y$(this.table,t,this.session,this.dialect,this.withList,!0)}};y$=class y$ extends vr{constructor(e,t,r,o,n,i){super();this.session=r,this.dialect=o,this.config={table:e,values:t,withList:n,select:i}}static[F]="SQLiteInsert";config;returning(e=this.config.table[At.Symbol.Columns]){return this.config.returning=cn(e),this}onConflictDoNothing(e={}){if(!this.config.onConflict)this.config.onConflict=[];if(e.target===void 0)this.config.onConflict.push(C` on conflict do nothing`);else{let t=Array.isArray(e.target)?C`${e.target}`:C`${[e.target]}`,r=e.where?C` where ${e.where}`:C``;this.config.onConflict.push(C` on conflict ${t} do nothing${r}`)}return this}onConflictDoUpdate(e){if(e.where&&(e.targetWhere||e.setWhere))throw Error('You cannot use both "where" and "targetWhere"/"setWhere" at the same time - "where" is deprecated, use "targetWhere" or "setWhere" instead.');if(!this.config.onConflict)this.config.onConflict=[];let t=e.where?C` where ${e.where}`:void 0,r=e.targetWhere?C` where ${e.targetWhere}`:void 0,o=e.setWhere?C` where ${e.setWhere}`:void 0,n=Array.isArray(e.target)?C`${e.target}`:C`${[e.target]}`,i=this.dialect.buildUpdateSet(this.config.table,tb(this.config.table,e.set));return this.config.onConflict.push(C` on conflict ${n}${r} do update set ${i}${t}${o}`),this}getSQL(){return this.dialect.buildInsertQuery(this.config)}toSQL(){let{typings:e,...t}=this.dialect.sqlToQuery(this.getSQL());return t}_prepare(e=!0){return this.session[e?"prepareOneTimeQuery":"prepareQuery"](this.dialect.sqlToQuery(this.getSQL()),this.config.returning,this.config.returning?"all":"run",!0,void 0,{type:"insert",tables:In(this.config.table)})}prepare(){return this._prepare(!1)}run=(e)=>this._prepare().run(e);all=(e)=>this._prepare().all(e);get=(e)=>this._prepare().get(e);values=(e)=>this._prepare().values(e);async execute(){return this.config.returning?this.all():this.run()}$dynamic(){return this}}});var hb,b5;var S5=v(()=>{$e();qo();ba();Fo();En();sr();Sr();Uo();Cl();Kp();hb=class hb{constructor(e,t,r,o){this.table=e,this.session=t,this.dialect=r,this.withList=o}static[F]="SQLiteUpdateBuilder";set(e){return new b5(this.table,tb(this.table,e),this.session,this.dialect,this.withList)}};b5=class b5 extends vr{constructor(e,t,r,o,n){super();this.session=r,this.dialect=o,this.config={set:t,table:e,withList:n,joins:[]}}static[F]="SQLiteUpdate";config;from(e){return this.config.from=e,this}createJoin(e){return(t,r)=>{let o=Bp(t);if(typeof o==="string"&&this.config.joins.some((n)=>n.alias===o))throw Error(`Alias "${o}" is already used in this query`);if(typeof r==="function"){let n=this.config.from?oe(t,At)?t[he.Symbol.Columns]:oe(t,pt)?t._.selectedFields:oe(t,Jo)?t[ft].selectedFields:void 0:void 0;r=r(new Proxy(this.config.table[he.Symbol.Columns],new at({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})),n&&new Proxy(n,new at({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))}return this.config.joins.push({on:r,table:t,joinType:e,alias:o}),this}}leftJoin=this.createJoin("left");rightJoin=this.createJoin("right");innerJoin=this.createJoin("inner");fullJoin=this.createJoin("full");where(e){return this.config.where=e,this}orderBy(...e){if(typeof e[0]==="function"){let t=e[0](new Proxy(this.config.table[he.Symbol.Columns],new at({sqlAliasedBehavior:"alias",sqlBehavior:"sql"}))),r=Array.isArray(t)?t:[t];this.config.orderBy=r}else{let t=e;this.config.orderBy=t}return this}limit(e){return this.config.limit=e,this}returning(e=this.config.table[At.Symbol.Columns]){return this.config.returning=cn(e),this}getSQL(){return this.dialect.buildUpdateQuery(this.config)}toSQL(){let{typings:e,...t}=this.dialect.sqlToQuery(this.getSQL());return t}_prepare(e=!0){return this.session[e?"prepareOneTimeQuery":"prepareQuery"](this.dialect.sqlToQuery(this.getSQL()),this.config.returning,this.config.returning?"all":"run",!0,void 0,{type:"insert",tables:In(this.config.table)})}prepare(){return this._prepare(!1)}run=(e)=>this._prepare().run(e);all=(e)=>this._prepare().all(e);get=(e)=>this._prepare().get(e);values=(e)=>this._prepare().values(e);async execute(){return this.config.returning?this.all():this.run()}$dynamic(){return this}}});var b$=v(()=>{u5();y5();fb();g$();S5()});var Hp;var v5=v(()=>{$e();Yt();Hp=class Hp extends _e{constructor(e){super(Hp.buildEmbeddedCount(e.source,e.filters).queryChunks);this.params=e,this.session=e.session,this.sql=Hp.buildCount(e.source,e.filters)}sql;static[F]="SQLiteCountBuilderAsync";[Symbol.toStringTag]="SQLiteCountBuilderAsync";session;static buildEmbeddedCount(e,t){return C`(select count(*) from ${e}${C.raw(" where ").if(t)}${t})`}static buildCount(e,t){return C`select count(*) from ${e}${C.raw(" where ").if(t)}${t}`}then(e,t){return Promise.resolve(this.session.count(this.sql)).then(e,t)}catch(e){return this.then(void 0,e)}finally(e){return this.then((t)=>(e?.(),t),(t)=>{throw e?.(),t})}}});var v$,gb,S$;var w5=v(()=>{$e();qo();Zp();v$=class v${constructor(e,t,r,o,n,i,s,a){this.mode=e,this.fullSchema=t,this.schema=r,this.tableNamesMap=o,this.table=n,this.tableConfig=i,this.dialect=s,this.session=a}static[F]="SQLiteAsyncRelationalQueryBuilder";findMany(e){return this.mode==="sync"?new S$(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e?e:{},"many"):new gb(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e?e:{},"many")}findFirst(e){return this.mode==="sync"?new S$(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e?{...e,limit:1}:{limit:1},"first"):new gb(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e?{...e,limit:1}:{limit:1},"first")}};gb=class gb extends vr{constructor(e,t,r,o,n,i,s,a,c){super();this.fullSchema=e,this.schema=t,this.tableNamesMap=r,this.table=o,this.tableConfig=n,this.dialect=i,this.session=s,this.config=a,this.mode=c}static[F]="SQLiteAsyncRelationalQuery";mode;getSQL(){return this.dialect.buildRelationalQuery({fullSchema:this.fullSchema,schema:this.schema,tableNamesMap:this.tableNamesMap,table:this.table,tableConfig:this.tableConfig,queryConfig:this.config,tableAlias:this.tableConfig.tsName}).sql}_prepare(e=!1){let{query:t,builtQuery:r}=this._toSQL();return this.session[e?"prepareOneTimeQuery":"prepareQuery"](r,void 0,this.mode==="first"?"get":"all",!0,(o,n)=>{let i=o.map((s)=>sb(this.schema,this.tableConfig,s,t.selection,n));if(this.mode==="first")return i[0];return i})}prepare(){return this._prepare(!1)}_toSQL(){let e=this.dialect.buildRelationalQuery({fullSchema:this.fullSchema,schema:this.schema,tableNamesMap:this.tableNamesMap,table:this.table,tableConfig:this.tableConfig,queryConfig:this.config,tableAlias:this.tableConfig.tsName}),t=this.dialect.sqlToQuery(e.sql);return{query:e,builtQuery:t}}toSQL(){return this._toSQL().builtQuery}executeRaw(){if(this.mode==="first")return this._prepare(!1).get();return this._prepare(!1).all()}async execute(){return this.executeRaw()}};S$=class S$ extends gb{static[F]="SQLiteSyncRelationalQuery";sync(){return this.executeRaw()}}});var Nl;var x5=v(()=>{$e();qo();Nl=class Nl extends vr{constructor(e,t,r,o,n){super();this.execute=e,this.getSQL=t,this.dialect=o,this.mapBatchResult=n,this.config={action:r}}static[F]="SQLiteRaw";config;getQuery(){return{...this.dialect.sqlToQuery(this.getSQL()),method:this.config.action}}mapResult(e,t){return t?this.mapBatchResult(e):e}_prepare(){return this}isResponseInArrayMode(){return!1}}});var Jp;var yb=v(()=>{$e();ba();Yt();b$();En();v5();w5();x5();Jp=class Jp{constructor(e,t,r,o){this.resultKind=e,this.dialect=t,this.session=r,this._=o?{schema:o.schema,fullSchema:o.fullSchema,tableNamesMap:o.tableNamesMap}:{schema:void 0,fullSchema:{},tableNamesMap:{}},this.query={};let n=this.query;if(this._.schema)for(let[i,s]of Object.entries(this._.schema))n[i]=new v$(e,o.fullSchema,this._.schema,this._.tableNamesMap,o.fullSchema[i],s,t,r);this.$cache={invalidate:async(i)=>{}}}static[F]="BaseSQLiteDatabase";query;$with=(e,t)=>{let r=this;return{as:(n)=>{if(typeof n==="function")n=n(new Sa(r.dialect));return new Proxy(new zp(n.getSQL(),t??("getSelectedFields"in n?n.getSelectedFields()??{}:{}),e,!0),new at({alias:e,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}}};$count(e,t){return new Hp({source:e,filters:t,session:this.session})}with(...e){let t=this;function r(a){return new An({fields:a??void 0,session:t.session,dialect:t.dialect,withList:e})}function o(a){return new An({fields:a??void 0,session:t.session,dialect:t.dialect,withList:e,distinct:!0})}function n(a){return new hb(a,t.session,t.dialect,e)}function i(a){return new mb(a,t.session,t.dialect,e)}function s(a){return new lb(a,t.session,t.dialect,e)}return{select:r,selectDistinct:o,update:n,insert:i,delete:s}}select(e){return new An({fields:e??void 0,session:this.session,dialect:this.dialect})}selectDistinct(e){return new An({fields:e??void 0,session:this.session,dialect:this.dialect,distinct:!0})}update(e){return new hb(e,this.session,this.dialect)}$cache;insert(e){return new mb(e,this.session,this.dialect)}delete(e){return new lb(e,this.session,this.dialect)}run(e){let t=typeof e==="string"?C.raw(e):e.getSQL();if(this.resultKind==="async")return new Nl(async()=>this.session.run(t),()=>t,"run",this.dialect,this.session.extractRawRunValueFromBatchResult.bind(this.session));return this.session.run(t)}all(e){let t=typeof e==="string"?C.raw(e):e.getSQL();if(this.resultKind==="async")return new Nl(async()=>this.session.all(t),()=>t,"all",this.dialect,this.session.extractRawAllValueFromBatchResult.bind(this.session));return this.session.all(t)}get(e){let t=typeof e==="string"?C.raw(e):e.getSQL();if(this.resultKind==="async")return new Nl(async()=>this.session.get(t),()=>t,"get",this.dialect,this.session.extractRawGetValueFromBatchResult.bind(this.session));return this.session.get(t)}values(e){let t=typeof e==="string"?C.raw(e):e.getSQL();if(this.resultKind==="async")return new Nl(async()=>this.session.values(t),()=>t,"values",this.dialect,this.session.extractRawValuesValueFromBatchResult.bind(this.session));return this.session.values(t)}transaction(e,t){return this.session.transaction(e,t)}}});async function w$(e,t){let r=`${e}-${JSON.stringify(t)}`,n=new TextEncoder().encode(r),i=await crypto.subtle.digest("SHA-256",n);return[...new Uint8Array(i)].map((c)=>c.toString(16).padStart(2,"0")).join("")}var _5,Vp;var x$=v(()=>{$e();_5=class _5{static[F]="Cache"};Vp=class Vp extends _5{strategy(){return"all"}static[F]="NoopCache";async get(e){return}async put(e,t,r,o){}async onMutate(e){}}});var E5=v(()=>{x$()});function bb(e,t){return new Proxy(e,new ya(t,!1))}var k5=v(()=>{qp()});var I5,_$,E$,k$;var I$=v(()=>{x$();$e();ub();qo();yb();I5=class I5 extends vr{constructor(e){super();this.resultCb=e}static[F]="ExecuteResultSync";async execute(){return this.resultCb()}sync(){return this.resultCb()}};_$=class _${constructor(e,t,r,o,n,i){if(this.mode=e,this.executeMethod=t,this.query=r,this.cache=o,this.queryMetadata=n,this.cacheConfig=i,o&&o.strategy()==="all"&&i===void 0)this.cacheConfig={enable:!0,autoInvalidate:!0};if(!this.cacheConfig?.enable)this.cacheConfig=void 0}static[F]="PreparedQuery";joinsNotNullableMap;async queryWithCache(e,t,r){if(this.cache===void 0||oe(this.cache,Vp)||this.queryMetadata===void 0)try{return await r()}catch(o){throw new Ho(e,t,o)}if(this.cacheConfig&&!this.cacheConfig.enable)try{return await r()}catch(o){throw new Ho(e,t,o)}if((this.queryMetadata.type==="insert"||this.queryMetadata.type==="update"||this.queryMetadata.type==="delete")&&this.queryMetadata.tables.length>0)try{let[o]=await Promise.all([r(),this.cache.onMutate({tables:this.queryMetadata.tables})]);return o}catch(o){throw new Ho(e,t,o)}if(!this.cacheConfig)try{return await r()}catch(o){throw new Ho(e,t,o)}if(this.queryMetadata.type==="select"){let o=await this.cache.get(this.cacheConfig.tag??await w$(e,t),this.queryMetadata.tables,this.cacheConfig.tag!==void 0,this.cacheConfig.autoInvalidate);if(o===void 0){let n;try{n=await r()}catch(i){throw new Ho(e,t,i)}return await this.cache.put(this.cacheConfig.tag??await w$(e,t),n,this.cacheConfig.autoInvalidate?this.queryMetadata.tables:[],this.cacheConfig.tag!==void 0,this.cacheConfig.config),n}return o}try{return await r()}catch(o){throw new Ho(e,t,o)}}getQuery(){return this.query}mapRunResult(e,t){return e}mapAllResult(e,t){throw Error("Not implemented")}mapGetResult(e,t){throw Error("Not implemented")}execute(e){if(this.mode==="async")return this[this.executeMethod](e);return new I5(()=>this[this.executeMethod](e))}mapResult(e,t){switch(this.executeMethod){case"run":return this.mapRunResult(e,t);case"all":return this.mapAllResult(e,t);case"get":return this.mapGetResult(e,t)}}};E$=class E${constructor(e){this.dialect=e}static[F]="SQLiteSession";prepareOneTimeQuery(e,t,r,o,n,i,s){return this.prepareQuery(e,t,r,o,n,i,s)}run(e){let t=this.dialect.sqlToQuery(e);try{return this.prepareOneTimeQuery(t,void 0,"run",!1).run()}catch(r){throw new Pl({cause:r,message:`Failed to run the query '${t.sql}'`})}}extractRawRunValueFromBatchResult(e){return e}all(e){return this.prepareOneTimeQuery(this.dialect.sqlToQuery(e),void 0,"run",!1).all()}extractRawAllValueFromBatchResult(e){throw Error("Not implemented")}get(e){return this.prepareOneTimeQuery(this.dialect.sqlToQuery(e),void 0,"run",!1).get()}extractRawGetValueFromBatchResult(e){throw Error("Not implemented")}values(e){return this.prepareOneTimeQuery(this.dialect.sqlToQuery(e),void 0,"run",!1).values()}async count(e){return(await this.values(e))[0][0]}extractRawValuesValueFromBatchResult(e){throw Error("Not implemented")}};k$=class k$ extends Jp{constructor(e,t,r,o,n=0){super(e,t,r,o);this.schema=o,this.nestedIndex=n}static[F]="SQLiteTransaction";rollback(){throw new l$}}});var A$,qme,Fme,Sb;var A5=v(()=>{$e();ba();Sr();fb();Fo();Kp();A$=class A${constructor(e){this.name=e}static[F]="SQLiteViewBuilderCore";config={}};qme=class qme extends A${static[F]="SQLiteViewBuilder";as(e){if(typeof e==="function")e=e(new Sa);let t=new at({alias:this.name,sqlBehavior:"error",sqlAliasedBehavior:"alias",replaceOriginalName:!0}),r=e.getSelectedFields();return new Proxy(new Sb({config:{name:this.name,schema:void 0,selectedFields:r,query:e.getSQL().inlineParams()}}),t)}};Fme=class Fme extends A${static[F]="SQLiteManualViewBuilder";columns;constructor(e,t){super(e);this.columns=rb(Fp(e,t))}existing(){return new Proxy(new Sb({config:{name:this.name,schema:void 0,selectedFields:this.columns,query:void 0}}),new at({alias:this.name,sqlBehavior:"error",sqlAliasedBehavior:"alias",replaceOriginalName:!0}))}as(e){return new Proxy(new Sb({config:{name:this.name,schema:void 0,selectedFields:this.columns,query:e.inlineParams()}}),new at({alias:this.name,sqlBehavior:"error",sqlAliasedBehavior:"alias",replaceOriginalName:!0}))}};Sb=class Sb extends Jo{static[F]="SQLiteView";constructor({config:e}){super(e)}}});var vb=v(()=>{k5();n5();d$();yb();db();YR();a5();l5();b$();I$();Fo();e$();Cl();A5()});function T5(e){return Object.keys(e).reduce((t,r)=>{if(Object.prototype.propertyIsEnumerable.call(e,r))t[r]=e[r];return t},{})}function wb(e){if(typeof ArrayBuffer<"u"&&e instanceof ArrayBuffer){if(typeof Buffer<"u"){if(!(e instanceof Buffer))return Buffer.from(e);return e}if(typeof TextDecoder<"u")return new TextDecoder().decode(e);throw Error("TextDecoder is not available. Please provide either Buffer or TextDecoder polyfill.")}return e}var xb,T$,R5;var R$=v(()=>{E5();$e();nb();Yt();vb();I$();Sr();xb=class xb extends E${constructor(e,t,r,o,n){super(t);this.client=e,this.schema=r,this.options=o,this.tx=n,this.logger=o.logger??new KR,this.cache=o.cache??new Vp}static[F]="LibSQLSession";logger;cache;prepareQuery(e,t,r,o,n,i,s){return new R5(this.client,e,this.logger,this.cache,i,s,t,this.tx,r,o,n)}async batch(e){let t=[],r=[];for(let n of e){let i=n._prepare(),s=i.getQuery();t.push(i),r.push({sql:s.sql,args:s.params})}return(await this.client.batch(r)).map((n,i)=>t[i].mapResult(n,!0))}async migrate(e){let t=[],r=[];for(let n of e){let i=n._prepare(),s=i.getQuery();t.push(i),r.push({sql:s.sql,args:s.params})}return(await this.client.migrate(r)).map((n,i)=>t[i].mapResult(n,!0))}async transaction(e,t){let r=await this.client.transaction(),o=new xb(this.client,this.dialect,this.schema,this.options,r),n=new T$("async",this.dialect,o,this.schema);try{let i=await e(n);return await r.commit(),i}catch(i){throw await r.rollback(),i}}extractRawAllValueFromBatchResult(e){return e.rows}extractRawGetValueFromBatchResult(e){return e.rows[0]}extractRawValuesValueFromBatchResult(e){return e.rows}};T$=class T$ extends k${static[F]="LibSQLTransaction";async transaction(e){let t=`sp${this.nestedIndex}`,r=new T$("async",this.dialect,this.session,this.schema,this.nestedIndex+1);await this.session.run(C.raw(`savepoint ${t}`));try{let o=await e(r);return await this.session.run(C.raw(`release savepoint ${t}`)),o}catch(o){throw await this.session.run(C.raw(`rollback to savepoint ${t}`)),o}}};R5=class R5 extends _${constructor(e,t,r,o,n,i,s,a,c,u,d){super("async",c,t,o,n,i);this.client=e,this.logger=r,this.fields=s,this.tx=a,this._isResponseInArrayMode=u,this.customResultMapper=d,this.customResultMapper=d,this.fields=s}static[F]="LibSQLPreparedQuery";async run(e){let t=Dp(this.query.params,e??{});return this.logger.logQuery(this.query.sql,t),await this.queryWithCache(this.query.sql,t,async()=>{let r={sql:this.query.sql,args:t};return this.tx?this.tx.execute(r):this.client.execute(r)})}async all(e){let{fields:t,logger:r,query:o,tx:n,client:i,customResultMapper:s}=this;if(!t&&!s){let c=Dp(o.params,e??{});return r.logQuery(o.sql,c),await this.queryWithCache(o.sql,c,async()=>{let u={sql:o.sql,args:c};return(n?n.execute(u):i.execute(u)).then(({rows:d})=>this.mapAllResult(d))})}let a=await this.values(e);return this.mapAllResult(a)}mapAllResult(e,t){if(t)e=e.rows;if(!this.fields&&!this.customResultMapper)return e.map((r)=>T5(r));if(this.customResultMapper)return this.customResultMapper(e,wb);return e.map((r)=>MR(this.fields,Array.prototype.slice.call(r).map((o)=>wb(o)),this.joinsNotNullableMap))}async get(e){let{fields:t,logger:r,query:o,tx:n,client:i,customResultMapper:s}=this;if(!t&&!s){let c=Dp(o.params,e??{});return r.logQuery(o.sql,c),await this.queryWithCache(o.sql,c,async()=>{let u={sql:o.sql,args:c};return(n?n.execute(u):i.execute(u)).then(({rows:d})=>this.mapGetResult(d))})}let a=await this.values(e);return this.mapGetResult(a)}mapGetResult(e,t){if(t)e=e.rows;let r=e[0];if(!this.fields&&!this.customResultMapper)return T5(r);if(!r)return;if(this.customResultMapper)return this.customResultMapper(e,wb);return MR(this.fields,Array.prototype.slice.call(r).map((o)=>wb(o)),this.joinsNotNullableMap)}async values(e){let t=Dp(this.query.params,e??{});return this.logger.logQuery(this.query.sql,t),await this.queryWithCache(this.query.sql,t,async()=>{let r={sql:this.query.sql,args:t};return(this.tx?this.tx.execute(r):this.client.execute(r)).then(({rows:o})=>o)})}isResponseInArrayMode(){return this._isResponseInArrayMode}}});function Dl(e,t={}){let r=new f$({casing:t.casing}),o;if(t.logger===!0)o=new FR;else if(t.logger!==!1)o=t.logger;let n;if(t.schema){let a=b3(t.schema,v3);n={fullSchema:t.schema,schema:a.tables,tableNamesMap:a.tableNamesMap}}let i=new xb(e,r,n,{logger:o,cache:t.cache},void 0),s=new $5("async",r,i,n);if(s.$client=e,s.$cache=t.cache,s.$cache)s.$cache.invalidate=t.cache?.onMutate;return s}var $5;var O5=v(()=>{$e();nb();Zp();yb();db();R$();$5=class $5 extends Jp{static[F]="LibSQLDatabase";async batch(e){return this.session.batch(e)}}});function _b(...e){if(typeof e[0]==="string"){let t=Tl({url:e[0]});return Dl(t,e[1])}if(WF(e[0])){let{connection:t,client:r,...o}=e[0];if(r)return Dl(r,o);let n=typeof t==="string"?Tl({url:t}):Tl(t);return Dl(n,o)}return Dl(e[0],e[1])}var C5=v(()=>{OR();Sr();O5();((e)=>{function t(r){return Dl({},r)}e.mock=t})(_b||(_b={}))});var P5=v(()=>{C5();R$()});function Kme(){return new Promise((e)=>setTimeout(e,0))}function Jme(){if($$)return;$$=!0,setTimeout(()=>{$$=!1,O$=performance.now()},0)}async function Wp(e=Hme){if(Jme(),performance.now()-O$<e)return;await Kme(),O$=performance.now()}var Hme=50,O$,$$=!1;var z5=v(()=>{O$=performance.now()});function N5(e){if(e.authToken!==void 0)return e.authToken;if(e.authTokenEnv===void 0)return;return process.env[e.authTokenEnv]}function Qme(e){return e instanceof Ce&&/^SQLITE_(?:BUSY|LOCKED)$/u.test(e.code)}async function Eb(e,t){let r=Date.now()+(t.budgetMs??Vme),o=async(n)=>{if(t.isClosed())throw new Ce("The client is closed","CLIENT_CLOSED");try{return await e()}catch(i){if(t.isClosed()||!Qme(i))throw i;await t.afterRefusal?.();let s=Math.min(Wme*2**(n-1),Gme),a=s/2+Math.random()*(s/2);if(t.isClosed()||Date.now()+a>=r)throw i;if(await new Promise((c)=>setTimeout(c,a)),t.isClosed()||Date.now()>=r)throw i;return o(n+1)}};return o(1)}function C$(e,t={}){let r=Tl({...e,...e.url.startsWith("file:")?{timeout:0}:{}});if(e.url.startsWith("file:")&&e.syncUrl===void 0){let o=r.transaction.bind(r),n=()=>r.closed,i=t.contentionRetryBudgetMs,s=r.execute.bind(r),a=r.batch.bind(r),c=r.migrate.bind(r),u={isClosed:n,budgetMs:i,afterRefusal:async()=>{await Promise.resolve(r.reconnect())}};async function d(p,m){return await Wp(),Eb(()=>typeof p==="string"?s(p,m):s(p),u)}r.execute=d,r.batch=async(p,m)=>(await Wp(),Eb(()=>a(p,m),u)),r.migrate=async(p)=>(await Wp(),Eb(()=>c(p),u)),r.transaction=async(p)=>(await Wp(),Eb(()=>o(p),u))}return r}function kb(e){let{url:t,schema:r}=e,o=N5(e),n={contentionRetryBudgetMs:e.contentionRetryBudgetMs},i=o?C$({url:t,authToken:o},n):C$({url:t},n);return{db:_b(i,{schema:r}),client:i,url:t}}async function Ib(e,t){if(!t.startsWith("file:"))return;for(let r of["PRAGMA busy_timeout = 0","PRAGMA journal_mode = WAL"])await e.execute(r)}var Vme=5000,Wme=5,Gme=40;var P$=v(()=>{OR();P5();z5()});var D5=v(()=>{HT();P$()});var z$=v(()=>{P$();D5()});var N$=v(()=>{qp();Gy();_n();$e();ub();nb();qo();Zp();u$();En();sr();Sr();Uo()});var Y,Me;var D$=v(()=>{vb();N$();cp();Y=Fp("job_queue",{id:mt("id").primaryKey().$defaultFn(()=>No()),type:mt("type").notNull(),data:mt("data").notNull(),result:mt("result",{mode:"json"}),progress:mt("progress",{mode:"json"}).$type(),source:mt("source"),metadata:mt("metadata",{mode:"json"}).$type().notNull(),status:mt("status",{enum:["pending","processing","completed","failed"]}).notNull().default("pending"),priority:ar("priority").notNull().default(0),retryCount:ar("retryCount").notNull().default(0),maxRetries:ar("maxRetries").notNull().default(3),lastError:mt("lastError"),lastErrorPublic:mt("lastErrorPublic",{mode:"json"}),createdAt:ar("createdAt").notNull().$defaultFn(()=>Date.now()),scheduledFor:ar("scheduledFor").notNull().$defaultFn(()=>Date.now()),startedAt:ar("startedAt"),completedAt:ar("completedAt"),attemptId:mt("attemptId"),workerSlotId:mt("workerSlotId"),workerSessionId:mt("workerSessionId"),leaseExpiresAt:ar("leaseExpiresAt"),attemptHeartbeatAt:ar("attemptHeartbeatAt"),runtimeUpdatedAt:ar("runtimeUpdatedAt"),brainVersion:mt("brainVersion"),brainVersionSortKey:mt("brainVersionSortKey")},(e)=>({queueReadyIdx:Ko("idx_job_queue_ready").on(e.status,e.priority,e.scheduledFor),jobTypeIdx:Ko("idx_job_queue_type").on(e.type,e.status),runtimeUpdatesIdx:Ko("idx_job_queue_runtime_updates").on(e.runtimeUpdatedAt,e.id),jobSourceIdx:Ko("idx_job_queue_source").on(e.source),rootJobIdx:Ko("idx_job_queue_root_job").on(C`json_extract(${e.metadata}, '$.rootJobId')`,e.createdAt,e.id),deduplicationIdx:Ko("idx_job_queue_deduplication").on(e.type,C`json_extract(${e.metadata}, '$.deduplicationKey')`,e.status)})),Me=Fp("job_worker_sessions",{slotId:mt("slotId").primaryKey(),sessionId:mt("sessionId").notNull().unique(),startedAt:ar("startedAt").notNull(),heartbeatAt:ar("heartbeatAt").notNull(),expiresAt:ar("expiresAt").notNull().default(0),brainVersion:mt("brainVersion"),brainVersionSortKey:mt("brainVersionSortKey"),stableSlotId:mt("stableSlotId")},(e)=>({heartbeatIdx:Ko("idx_job_worker_sessions_heartbeat").on(e.heartbeatAt),expiresIdx:Ko("idx_job_worker_sessions_expires").on(e.expiresAt)}))});function L5(e){return kb({url:e.url,schema:{jobQueue:Y,jobWorkerSessions:Me},authToken:e.authToken,authTokenEnv:"JOB_QUEUE_DATABASE_AUTH_TOKEN",contentionRetryBudgetMs:0})}var B5=v(()=>{z$();D$()});class L${declarations=new Map;handlers=new Map;validators=new Map;logger;mode;finalizedRegistrations;constructor(e,t){this.logger=e.child("HandlerRegistry"),this.mode=t}registerHandler(e,t,r){if(this.finalizedRegistrations)throw Error("Job handler registrations are finalized");if(this.declarations.has(e))throw Error(`Job handler is already registered for type: ${e}`);if(this.declarations.set(e,{handler:t,pluginId:r}),this.validators.set(e,t),this.mode!=="validation-only")this.handlers.set(e,t);this.logger.debug("Registered job execution declaration",{type:e,pluginId:r,mode:this.mode})}unregisterHandler(e){this.declarations.delete(e),this.handlers.delete(e),this.validators.delete(e),this.logger.debug("Unregistered job handler",{type:e})}unregisterPluginHandlers(e){let t=[...this.declarations.entries()].filter(([,r])=>r.pluginId===e).map(([r])=>r);for(let r of t)this.declarations.delete(r),this.handlers.delete(r),this.validators.delete(r);if(t.length>0)this.logger.debug("Unregistered plugin handlers",{pluginId:e,count:t.length,types:t})}finalizeRegistrations(){return this.finalizedRegistrations??=Object.freeze([...this.declarations.entries()].sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>Object.freeze({type:e,pluginId:t.pluginId}))),this.finalizedRegistrations}getExecutionRegistrations(){return this.finalizedRegistrations}getRegisteredTypes(){return[...this.handlers.keys()]}getExclusiveTypes(){return[...this.handlers].filter(([,e])=>e.exclusive===!0).map(([e])=>e)}getHandler(e){return this.handlers.get(e)}getValidator(e){return this.validators.get(e)}}class B${tails=new Map;async run(e,t){let r=this.tails.get(e),o=()=>{},n=new Promise((i)=>{o=i});this.tails.set(e,n),await r;try{return await t()}finally{if(o(),this.tails.get(e)===n)this.tails.delete(e)}}}class j${findDuplicate(e,t,r){if(!t||t==="none")return null;let o=this.filterByDeduplicationKey(e,r).sort((i,s)=>s.createdAt-i.createdAt||s.id.localeCompare(i.id)),n=o.find((i)=>i.status===Oe.PENDING)??null;if(t==="skip"||t==="replace")return n;return n??o[0]??null}filterByDeduplicationKey(e,t){if(!t)return e;return e.filter((r)=>{let o=Yme.safeParse(r.metadata);return o.success&&o.data.deduplicationKey===t})}}var Yme;var j5=v(()=>{fe();Do();Yme=l.looseObject({deduplicationKey:l.string().optional()})});function M5(e){return`${String(e.length).padStart(2,"0")}${e}`}function ehe(e){return Xme.test(e)?`0${M5(e)}`:`1${e}`}function Gp(e){let t=Z5.exec(e);if(!t)throw Error(`Invalid brain version "${e}"`);let[,r="",o="",n="",i]=t,s=[r,o,n].map(M5).join("");return i===void 0?`${s}~`:`${s}-${i.split(".").map(ehe).join("!")}`}var Z5,Xme,U5;var Z$=v(()=>{fe();Z5=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*)?$/u,Xme=/^\d+$/u,U5=l.string().regex(Z5,"Brain version must be a semver version")});function q5(e){return JSON.stringify(new li(e).toJSON())}class U${db;transactionClient;databaseUrl;logger;deduplicator=new j$;writeRetryBudgetMs;constructor(e,t,r,o,n){this.db=e,this.transactionClient=t,this.databaseUrl=r,this.logger=o.child("JobQueueRepository"),this.writeRetryBudgetMs=n?.writeRetryBudgetMs??the}async insert(e){await this.write("insert",async()=>this.db.insert(Y).values(e))}async enqueueAtomic(e){return ihe.run(this.databaseUrl,async()=>{let t=Date.now()+this.writeRetryBudgetMs;return this.attemptEnqueue(e,t,1)})}async attemptEnqueue(e,t,r){let o=await this.runEnqueueTransaction(e,t,r);if(o.retry)return this.attemptEnqueue(e,t,r+1);return o.decision}async runEnqueueTransaction(e,t,r){let o=await this.acquireWriteTransaction(e,t),n={prepared:!1},i=!1;try{let s=await this.decideEnqueue(o,e,()=>{n.prepared=!0});return i=!0,await o.commit(),{retry:!1,decision:s}}catch(s){let a=i&&this.isSerializationConflict(s)&&!o.closed,c=!0;if(!o.closed)try{await o.rollback()}catch(u){c=!1,this.logger.error("Failed to roll back atomic enqueue",{type:e.jobData.type,rollbackError:u})}if(n.prepared)e.onInsertRollback?.();if(!a||!c)throw s;return await this.waitForConflictRetry("commit",e,t,r,s),{retry:!0}}finally{o.close()}}async decideEnqueue(e,t,r){let{jobData:o,strategy:n,deduplicationKey:i,beforeInsert:s}=t,a=n??"none",c=async()=>{await s?.(),r()},u=async()=>{await c(),await this.insertJob(e,o)};if(a==="none")return await u(),{kind:"inserted",jobId:o.id};let d=await this.getActiveDeduplicationCandidates(e,o.type,i),p=this.deduplicator.findDuplicate(d,a,i);if(!p)return await u(),{kind:"inserted",jobId:o.id};if(a==="skip")return await this.raiseBrainVersion(e,p.id,o),{kind:"skipped",jobId:p.id};if(a==="coalesce"){if(await this.raiseBrainVersion(e,p.id,o),(await e.execute({sql:"UPDATE `job_queue` SET `scheduledFor` = ? WHERE `id` = ? AND `status` = ?",args:[Date.now(),p.id,p.status]})).rowsAffected!==1)throw Error(`Atomic coalesce lost selected job ${p.id}`);return{kind:"coalesced",jobId:p.id}}await c();let m=Date.now();if((await e.execute({sql:"UPDATE `job_queue`\n SET `status` = ?,\n `lastError` = ?,\n `lastErrorPublic` = ?,\n `completedAt` = ?,\n `runtimeUpdatedAt` = max(?, coalesce((SELECT max(`runtimeUpdatedAt`) FROM `job_queue`), 0) + 1)\n WHERE `id` = ? AND `status` = ?",args:[Oe.FAILED,"Replaced by newer job",q5("cancelled"),m,m,p.id,Oe.PENDING]})).rowsAffected!==1)throw Error(`Atomic replace lost selected job ${p.id}`);return await this.insertJob(e,o),{kind:"replaced",jobId:o.id,replacedJobId:p.id}}async getActiveDeduplicationCandidates(e,t,r){return(await e.execute(r?{sql:"SELECT `id`, `status`, `createdAt`, `metadata`\n FROM `job_queue`\n WHERE `type` = ?\n AND json_extract(`metadata`, '$.deduplicationKey') = ?\n AND `status` IN (?, ?)",args:[t,r,Oe.PENDING,Oe.PROCESSING]}:{sql:"SELECT `id`, `status`, `createdAt`, `metadata`\n FROM `job_queue`\n WHERE `type` = ? AND `status` IN (?, ?)",args:[t,Oe.PENDING,Oe.PROCESSING]})).rows.map((n)=>this.parseDeduplicationCandidate(n))}parseDeduplicationCandidate(e){let{id:t,status:r,createdAt:o,metadata:n}=e;if(typeof t!=="string"||r!==Oe.PENDING&&r!==Oe.PROCESSING||typeof o!=="number"&&typeof o!=="bigint"||typeof n!=="string")throw Error("Invalid active job row returned during atomic enqueue");let i=JSON.parse(n);return{id:t,status:r,createdAt:Number(o),metadata:i}}async raiseBrainVersion(e,t,r){if(!r.brainVersion)return;let o=Gp(r.brainVersion);await e.execute({sql:"UPDATE `job_queue`\n SET `brainVersion` = ?, `brainVersionSortKey` = ?\n WHERE `id` = ?\n AND (`brainVersionSortKey` IS NULL OR `brainVersionSortKey` < ?)",args:[r.brainVersion,o,t,o]})}async insertJob(e,t){if((await e.execute({sql:"INSERT INTO `job_queue` (\n `id`, `type`, `data`, `result`, `source`, `metadata`,\n `status`, `priority`, `retryCount`, `maxRetries`,\n `lastError`, `createdAt`, `scheduledFor`, `startedAt`,\n `completedAt`, `brainVersion`, `brainVersionSortKey`\n ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",args:[t.id,t.type,t.data,this.serializeJson(t.result),t.source,JSON.stringify(t.metadata),t.status,t.priority,t.retryCount,t.maxRetries,t.lastError,t.createdAt,t.scheduledFor,t.startedAt,t.completedAt,t.brainVersion??null,t.brainVersion?Gp(t.brainVersion):null]})).rowsAffected!==1)throw Error(`Atomic enqueue did not insert job ${t.id}`)}serializeJson(e){if(e===void 0||e===null)return null;return JSON.stringify(e)}acquireWriteTransaction(e,t){return this.retryOnConflict("acquire",e,()=>this.transactionClient.transaction("write"),(r)=>this.isSerializationConflict(r),t)}async waitForConflictRetry(e,t,r,o,n){let i=Math.min(rhe*2**(o-1),nhe),s=i/2+Math.random()*(i/2);if(Date.now()+s>=r)throw this.transactionConflictError(e,t,o,n);await new Promise((a)=>setTimeout(a,s))}async retryOnConflict(e,t,r,o,n=Date.now()+this.writeRetryBudgetMs,i=1){try{return await r()}catch(s){if(!o(s))throw s;return await this.waitForConflictRetry(e,t,n,i,s),this.retryOnConflict(e,t,r,o,n,i+1)}}transactionConflictError(e,t,r,o){if(typeof t==="string")return Error(`Failed job queue write "${t}" within ${this.writeRetryBudgetMs}ms after ${r} attempts`,{cause:o});let n=t.strategy??"none",i=t.deduplicationKey?"present":"absent";return Error(`Failed to ${e} atomic enqueue transaction for type "${t.jobData.type}" within ${this.writeRetryBudgetMs}ms after ${r} attempts (strategy: ${n}, key: ${i})`,{cause:o})}write(e,t){return this.retryOnConflict("write",e,t,(r)=>{let o=new Set;for(let n=r;n!==void 0&&!o.has(n);){if(o.add(n),typeof n==="object"&&n!==null&&"code"in n&&/^SQLITE_(?:BUSY|LOCKED)(?:_|$)/u.test(String(n.code)))return!0;n=n instanceof Error?n.cause:void 0}return!1})}isSerializationConflict(e){for(let t=e;t!==void 0;){let r=typeof t==="object"&&t!==null&&"code"in t?String(t.code):"",o=Ve(t,"");if(/SQLITE_(?:BUSY|LOCKED)/u.test(r)||/SQLITE_(?:BUSY|LOCKED)|database is locked|transaction (?:busy|conflict)/iu.test(o))return!0;t=t instanceof Error?t.cause:void 0}return!1}async startWorkerSession(e,t,r=Date.now(),o=Hi,n,i){let s=r+o,a={brainVersion:n??null,brainVersionSortKey:n?Gp(n):null,stableSlotId:i??null};await this.write("start worker session",async()=>{await this.db.insert(Me).values({slotId:e,sessionId:t,startedAt:r,heartbeatAt:r,expiresAt:s,...a}).onConflictDoUpdate({target:Me.slotId,set:{sessionId:t,startedAt:r,heartbeatAt:r,expiresAt:s,...a}}),await this.pruneDeadWorkerSessions(r,o)})}async heartbeatWorkerSession(e,t,r=Date.now(),o=Hi){return(await this.write("heartbeat worker session",async()=>{let i=await this.db.update(Me).set({heartbeatAt:r,expiresAt:r+o}).where(tt(je(Me.slotId,e),je(Me.sessionId,t))).returning({slotId:Me.slotId});return await this.pruneDeadWorkerSessions(r,o),i})).length===1}async pruneDeadWorkerSessions(e,t){let r=this.db.select({id:Y.id}).from(Y).where(tt(je(Y.workerSlotId,Me.slotId),je(Y.workerSessionId,Me.sessionId),je(Y.status,Oe.PROCESSING),kn(Y.leaseExpiresAt,e)));await this.db.delete(Me).where(tt(os(Me.expiresAt,e-t),ss(r)))}async endWorkerSession(e,t){return(await this.write("end worker session",async()=>this.db.delete(Me).where(tt(je(Me.slotId,e),je(Me.sessionId,t))).returning({slotId:Me.slotId}))).length===1}async complete(e,t,r){let o=Date.now(),i=(await this.write("complete",async()=>this.db.update(Y).set({status:Oe.COMPLETED,result:t,lastError:null,lastErrorPublic:null,completedAt:o,runtimeUpdatedAt:this.nextRuntimeUpdatedAt(o)}).where(this.attemptWriteGuard(e,r)).returning({id:Y.id}))).length===1;if(i)this.logger.debug("Job completed",{jobId:e,hasResult:t!==void 0});return i}async update(e,t,r){let n=(await this.write("update",async()=>this.db.update(Y).set({data:JSON.stringify(t)}).where(this.attemptWriteGuard(e,r)).returning({id:Y.id}))).length===1;if(n)this.logger.debug("Job data updated",{jobId:e});return n}async recordAttemptProgress(e,t,r,o=Date.now()){return(await this.write("record progress",async()=>this.db.update(Y).set({attemptHeartbeatAt:o,runtimeUpdatedAt:this.nextRuntimeUpdatedAt(o),progress:r}).where(this.attemptWriteGuard(e,t)).returning({id:Y.id}))).length===1}async renewAttemptLease(e,t,r,o){return(await this.write("renew attempt lease",async()=>this.db.update(Y).set({attemptHeartbeatAt:r,leaseExpiresAt:r+o}).where(this.attemptWriteGuard(e,t)).returning({id:Y.id}))).length===1}async fail(e,t,r,o=Date.now()){let i=(await this.db.select({retryCount:Y.retryCount,maxRetries:Y.maxRetries,type:Y.type,scheduledFor:Y.scheduledFor,startedAt:Y.startedAt,runtimeUpdatedAt:Y.runtimeUpdatedAt}).from(Y).where(this.attemptWriteGuard(e,r)).limit(1))[0];if(!i)return!1;let s=i.retryCount<i.maxRetries,a=s?i.retryCount+1:i.retryCount,c=Math.min(1000*2**i.retryCount,60000),u=s?o+c:i.scheduledFor;if((await this.write("fail",async()=>this.db.update(Y).set({status:s?Oe.PENDING:Oe.FAILED,retryCount:a,lastError:t.message,lastErrorPublic:Qm(t).toJSON(),scheduledFor:u,completedAt:s?null:o,runtimeUpdatedAt:s?i.runtimeUpdatedAt:this.nextRuntimeUpdatedAt(o),startedAt:s?null:i.startedAt,attemptId:null,workerSlotId:null,workerSessionId:null,leaseExpiresAt:null,attemptHeartbeatAt:null}).where(tt(this.attemptWriteGuard(e,r),je(Y.retryCount,i.retryCount))).returning({id:Y.id}))).length!==1)return!1;if(s)this.logger.debug("Job scheduled for retry",{jobId:e,retryCount:a,backoffMs:c,scheduledFor:new Date(u).toISOString()});else this.logger.error("Job failed after max retries",{jobId:e,type:i.type,retryCount:i.retryCount,error:t.message});return!0}async retireUnownedActiveJob(e){let t=e.reason.trim();if(t.length===0)throw Error("Retired job reason must not be empty");let o=(await this.write("retire unowned job",async()=>this.db.update(Y).set({status:Oe.FAILED,lastError:t,lastErrorPublic:new li("no_handler").toJSON(),completedAt:e.now,runtimeUpdatedAt:this.nextRuntimeUpdatedAt(e.now)}).where(tt(je(Y.id,e.jobId),je(Y.type,e.expectedType),ln(je(Y.status,Oe.PENDING),je(Y.status,Oe.PROCESSING)),Mr(Y.attemptId),Mr(Y.workerSlotId),Mr(Y.workerSessionId),Mr(Y.leaseExpiresAt),Mr(Y.attemptHeartbeatAt),Mr(Y.progress),Mr(Y.result))).returning()))[0]??null;if(o)this.logger.warn("Retired unowned legacy job",{jobId:o.id,type:o.type,reason:t});return o}async getStatus(e){return(await this.db.select().from(Y).where(je(Y.id,e)).limit(1))[0]??null}async getJobsByRootJobId(e){return this.db.select().from(Y).where(C`json_extract(${Y.metadata}, '$.rootJobId') = ${e}`).orderBy(Mo(Y.createdAt),Mo(Y.id))}async getStatusByEntityId(e){return(await this.db.select().from(Y).where(C`json_extract(${Y.data}, '$.id') = ${e}`).orderBy(ga(Y.createdAt)).limit(1))[0]??null}async getStats(){let e=await this.db.select({status:Y.status,count:C`count(*)`}).from(Y).groupBy(Y.status),t={pending:0,processing:0,failed:0,completed:0,total:0};for(let r of e){let o=Number(r.count);t[r.status]=o,t.total+=o}return t}async getDiagnostics(e=Date.now()){let[t,r,o]=await Promise.all([this.db.select({type:Y.type,status:Y.status,count:C`count(*)`}).from(Y).groupBy(Y.type,Y.status),this.db.select({oldestPendingAt:C`min(case when ${Y.status} = ${Oe.PENDING} then ${Y.createdAt} end)`,duePending:C`coalesce(sum(case when ${Y.status} = ${Oe.PENDING} and ${Y.scheduledFor} <= ${e} then 1 else 0 end), 0)`,oldestDuePendingAt:C`min(case when ${Y.status} = ${Oe.PENDING} and ${Y.scheduledFor} <= ${e} then ${Y.scheduledFor} end)`,latestClaimAt:C`max(${Y.startedAt})`,oldestProcessingAt:C`min(case when ${Y.status} = ${Oe.PROCESSING} then ${Y.startedAt} end)`,staleLeaseCount:C`coalesce(sum(case when ${Y.status} = ${Oe.PROCESSING} and ${Y.leaseExpiresAt} is not null and ${Y.leaseExpiresAt} <= ${e} then 1 else 0 end), 0)`}).from(Y),this.db.select({total:C`count(*)`,active:C`coalesce(sum(case when ${Me.expiresAt} > ${e} then 1 else 0 end), 0)`,stale:C`coalesce(sum(case when ${Me.expiresAt} <= ${e} then 1 else 0 end), 0)`,latestHeartbeatAt:C`max(${Me.heartbeatAt})`}).from(Me)]),n={pending:0,processing:0,completed:0,failed:0},i=t.map((u)=>{let d=Number(u.count);return n[u.status]+=d,{type:u.type,status:u.status,count:d}}),s=r[0],a=o[0],c=(u)=>u===null||u===void 0?null:Math.max(0,e-Number(u));return{totals:n,byType:i,oldestPendingAgeMs:c(s?.oldestPendingAt),duePending:Number(s?.duePending??0),oldestDuePendingAgeMs:c(s?.oldestDuePendingAt),latestClaimAgeMs:c(s?.latestClaimAt),oldestProcessingAgeMs:c(s?.oldestProcessingAt),staleLeaseCount:Number(s?.staleLeaseCount??0),workerSessions:{total:Number(a?.total??0),active:Number(a?.active??0),stale:Number(a?.stale??0),latestHeartbeatAgeMs:c(a?.latestHeartbeatAt)}}}async getRuntimeUpdates(e,t){let r=ohe.parse(t);if(r===0)return[];return(await this.db.select().from(Y).where(C`(${Y.runtimeUpdatedAt}, ${Y.id}) > (${e.updatedAt}, ${e.jobId})`).orderBy(Mo(Y.runtimeUpdatedAt),Mo(Y.id)).limit(r)).map((n)=>({job:n,cursor:{updatedAt:n.runtimeUpdatedAt??0,jobId:n.id}}))}async cleanup(e){let t=Date.now()-e;return(await this.write("cleanup",async()=>this.db.delete(Y).where(tt(ln(je(Y.status,Oe.COMPLETED),je(Y.status,Oe.FAILED)),os(Y.completedAt,t))))).rowsAffected}async getActiveJobs(e){let t=ln(je(Y.status,Oe.PENDING),je(Y.status,Oe.PROCESSING)),r=e&&e.length>0?tt(t,is(Y.type,e)):t;return this.db.select().from(Y).where(r).orderBy(ga(Y.createdAt))}async getRecentJobs(e,t=20){let r=e&&e.length>0?is(Y.type,e):void 0;return this.db.select().from(Y).where(r).orderBy(ga(Y.createdAt)).limit(t)}async getFailedJobs(e){let t=je(Y.status,Oe.FAILED),r=e&&e.length>0?tt(t,is(Y.type,e)):t;return this.db.select().from(Y).where(r).orderBy(ga(Y.createdAt))}async claimNextReady(e){let{now:t,attemptId:r,workerSlotId:o,workerSessionId:n,leaseDurationMs:i,executableTypes:s,exclusiveTypes:a=[],brainVersion:c}=e,u=c?this.brainVersionGate(c,t):{admissible:void 0,noNewerWorker:void 0},d=this.db.select({slotId:Me.slotId}).from(Me).where(tt(je(Me.slotId,o),je(Me.sessionId,n),kn(Me.expiresAt,t))),p=this.noNewerLiveInstance(o,n,t),m=this.db.select({slotId:Me.slotId}).from(Me).where(tt(je(Me.slotId,Y.workerSlotId),je(Me.sessionId,Y.workerSessionId))),h=tt(je(Y.status,Oe.PROCESSING),ln(Mr(Y.attemptId),ss(m),os(Y.leaseExpiresAt,t))),b=bb(Y,"running"),y=this.db.select({id:b.id}).from(b).where(tt(je(b.type,Y.type),je(b.status,Oe.PROCESSING),kn(b.leaseExpiresAt,t),C`${b.id} <> ${Y.id}`)),S=a.length===0?void 0:ln(ob(Y.type,[...a]),ss(y)),x=C`${Y.status} = ${Oe.PROCESSING} AND ${Y.retryCount} + 1 > ${Y.maxRetries}`,_=this.db.select({id:Y.id}).from(Y).where(tt(is(Y.type,s),S,u.admissible,ln(tt(je(Y.status,Oe.PENDING),os(Y.scheduledFor,t)),h))).orderBy(Mo(Y.priority),Mo(Y.createdAt)).limit(1),O=(await this.write("claim",async()=>this.db.update(Y).set({status:C`CASE WHEN ${x} THEN ${Oe.FAILED} ELSE ${Oe.PROCESSING} END`,retryCount:C`CASE WHEN ${Y.status} = ${Oe.PROCESSING} THEN ${Y.retryCount} + 1 ELSE ${Y.retryCount} END`,lastError:C`CASE WHEN ${Y.status} = ${Oe.PROCESSING} THEN 'Attempt lease expired' ELSE ${Y.lastError} END`,lastErrorPublic:C`CASE WHEN ${Y.status} = ${Oe.PROCESSING} THEN ${q5("deadline_exceeded")} ELSE ${Y.lastErrorPublic} END`,startedAt:C`CASE WHEN ${x} THEN ${Y.startedAt} ELSE ${t} END`,completedAt:C`CASE WHEN ${x} THEN ${t} ELSE NULL END`,attemptId:C`CASE WHEN ${x} THEN ${Y.attemptId} ELSE ${r} END`,workerSlotId:C`CASE WHEN ${x} THEN ${Y.workerSlotId} ELSE ${o} END`,workerSessionId:C`CASE WHEN ${x} THEN ${Y.workerSessionId} ELSE ${n} END`,leaseExpiresAt:C`CASE WHEN ${x} THEN ${Y.leaseExpiresAt} ELSE ${t+i} END`,attemptHeartbeatAt:C`CASE WHEN ${x} THEN ${Y.attemptHeartbeatAt} ELSE ${t} END`,runtimeUpdatedAt:C`CASE WHEN ${x} THEN ${this.nextRuntimeUpdatedAt(t)} ELSE ${Y.runtimeUpdatedAt} END`}).where(tt(is(Y.id,_),ib(d),p,u.noNewerWorker)).returning()))[0];if(!O)return null;if(O.status===Oe.FAILED)return O;return this.logger.debug("Job claimed",{jobId:O.id,attemptId:O.attemptId,workerSlotId:o,workerSessionId:n}),O}noNewerLiveInstance(e,t,r){let o=bb(Me,"claimer"),n=bb(Me,"peer"),i=this.db.select({slotId:n.slotId}).from(n).innerJoin(o,tt(je(o.slotId,e),je(o.sessionId,t))).where(tt(je(n.stableSlotId,o.stableSlotId),kn(n.expiresAt,r),ln(kn(n.startedAt,o.startedAt),tt(je(n.startedAt,o.startedAt),kn(n.slotId,o.slotId)))));return ss(i)}brainVersionGate(e,t){let r=Gp(e),o=this.db.select({slotId:Me.slotId}).from(Me).where(tt(kn(Me.expiresAt,t),kn(Me.brainVersionSortKey,r)));return{admissible:ln(Mr(Y.brainVersionSortKey),os(Y.brainVersionSortKey,r)),noNewerWorker:ss(o)}}nextRuntimeUpdatedAt(e){return C`max(${e}, coalesce((select max(${Y.runtimeUpdatedAt}) from ${Y}), 0) + 1)`}attemptWriteGuard(e,t){return t?tt(je(Y.id,e),je(Y.status,Oe.PROCESSING),je(Y.attemptId,t)):tt(je(Y.id,e),Mr(Y.attemptId),ln(je(Y.status,Oe.PENDING),je(Y.status,Oe.PROCESSING)))}}var the=2000,rhe=5,nhe=40,ohe,ihe;var F5=v(()=>{N$();vb();D$();Rt();fe();Do();up();j5();Z$();ohe=l.number().int().min(0).max(1000),ihe=new B$});import{AsyncLocalStorage as she}from"async_hooks";class Ll{storage=new she;static createFresh(){return new Ll}constructor(){}current(){return this.storage.getStore()}run(e,t,r){if(t.length===0)throw Error("Operation ID must not be empty");let o=uo.parse(e),n=ahe(o);return this.storage.run(Object.freeze({provenance:n,operationId:t}),r)}}function ahe(e){if(Object.freeze(e.projectionLineage),e.sourceEntity)Object.freeze(e.sourceEntity);return Object.freeze(e)}var Ab=v(()=>{Rt()});class Qp{client;logger;handlerRegistry;repository;walInitialization=null;walInitializationSettled=!1;closeRequested=!1;clientClosed=!1;inFlightEnqueues=0;databaseUrl;operationContext;projectionAdmission;directWorkerSlotId=`direct:${No()}`;directWorkerSessionId=No();directLeaseDurationMs;directSessionStart=null;brainVersion;close(){this.closeRequested=!0,this.closeClientWhenReady()}static createFresh(e,t,r){return new Qp(e,t??Ar.getInstance(),r)}constructor(e,t,r){this.brainVersion=e.brainVersion===void 0?void 0:U5.parse(e.brainVersion);let{db:o,client:n,url:i}=L5(e);this.client=n,this.databaseUrl=i,this.logger=t.child("JobQueueService"),this.operationContext=r?.operationContext??Ll.createFresh(),this.projectionAdmission=r?.projectionAdmission,this.handlerRegistry=new L$(this.logger,r?.handlerRegistrationMode??"combined"),this.repository=new U$(o,n,i,this.logger),this.directLeaseDurationMs=e.claimTimeoutMs??300000}initialize(){if(this.closeRequested)return Promise.resolve();return this.walInitialization??=this.initializeWALMode(),this.walInitialization}async initializeWALMode(){try{await Ib(this.client,this.databaseUrl)}catch(e){this.logger.warn("Failed to enable WAL mode (non-fatal)",e)}finally{this.walInitializationSettled=!0,this.closeClientWhenReady()}}closeClientWhenReady(){if(!this.closeRequested||this.inFlightEnqueues>0||this.walInitialization!==null&&!this.walInitializationSettled)return;this.closeClient()}closeClient(){if(this.clientClosed)return;this.clientClosed=!0,this.client.close()}registerHandler(e,t,r){this.handlerRegistry.registerHandler(e,t,r)}unregisterHandler(e){this.handlerRegistry.unregisterHandler(e)}unregisterPluginHandlers(e){this.handlerRegistry.unregisterPluginHandlers(e)}getRegisteredTypes(){return this.handlerRegistry.getRegisteredTypes()}getHandler(e){return this.handlerRegistry.getHandler(e)}getValidator(e){return this.handlerRegistry.getValidator(e)}finalizeHandlerRegistrations(){return this.handlerRegistry.finalizeRegistrations()}getExecutionRegistrations(){return this.handlerRegistry.getExecutionRegistrations()}async enqueue(e){if(this.closeRequested)throw Error("Cannot enqueue a job after the queue service is closed");this.inFlightEnqueues++;try{return await this.enqueueValidated(e)}finally{this.inFlightEnqueues--,this.closeClientWhenReady()}}async enqueueValidated(e){let{type:t,data:r,options:o}=e,n=this.handlerRegistry.getValidator(t);if(!n)throw Error(`No job type declared: ${t}`);let i=n.validateAndParse(r);if(i===null)throw Error(`Invalid job data for type: ${t}`);let s=Date.now(),a=No(),c=o?.rootJobId??(o?.detached?a:this.operationContext.current()?.provenance.rootJobId)??a,u=this.createJobProvenance(a,c,o),d=o?.metadata??{operationType:"data_processing"},{provenance:p,...m}=d,h={id:a,type:t,data:JSON.stringify(i),status:Oe.PENDING,priority:o?.priority??0,maxRetries:o?.maxRetries??3,retryCount:0,source:o?.source??null,metadata:{...m,...o?.deduplicationKey&&{deduplicationKey:o.deduplicationKey},rootJobId:c,provenance:u},createdAt:s,scheduledFor:o?.delayMs?s+o.delayMs:s,result:null,lastError:null,startedAt:null,completedAt:null,brainVersion:this.brainVersion},b,y=()=>{b?.rollback(),b=void 0};try{let S=await this.repository.enqueueAtomic({jobData:h,strategy:o?.deduplication,deduplicationKey:o?.deduplicationKey,beforeInsert:async()=>{b=await this.projectionAdmission?.reserveJobAdmission(u)},onInsertRollback:y});if(b?.commit(),b=void 0,S.kind==="skipped")this.logger.debug("Skipping duplicate job (already pending)",{type:t,existingJobId:S.jobId});else if(S.kind==="coalesced")this.logger.debug("Coalescing with existing job",{type:t,existingJobId:S.jobId});else{if(S.kind==="replaced")this.logger.debug("Replacing duplicate job",{type:t,oldJobId:S.replacedJobId});this.logger.debug("Job enqueued",{id:S.jobId,type:t,priority:h.priority,rootJobId:h.metadata.rootJobId})}return S.jobId}catch(S){throw y(),this.logger.error("Failed to enqueue job",{type:t,error:Ve(S)}),S}}createJobProvenance(e,t,r){let o=this.operationContext.current(),n=r?.metadata.provenance??o?.provenance,i=n?.rootJobId===t?n:void 0,s=o?.provenance.rootJobId===t?o.operationId:void 0,a=r?.projection,c=a?[...i?.projectionLineage??[],a.id]:[...i?.projectionLineage??[]],u=a?.id??i?.projectionId;return uo.parse({rootJobId:t,causationId:s??i?.causationId??e,...u?{projectionId:u}:{},projectionLineage:c,...a?.sourceEntity?{sourceEntity:a.sourceEntity}:i?.sourceEntity?{sourceEntity:i.sourceEntity}:{},derivationDepth:c.length})}async dequeue(e){let t=this.handlerRegistry.getRegisteredTypes();if(t.length===0)return null;let{onTerminalReclaim:r,...o}=e??await this.getDirectClaimOptions(),n=Date.now(),i=await this.repository.claimNextReady({...o,workerSlotId:this.sessionSlotId(o.workerSlotId,o.workerSessionId),brainVersion:this.brainVersion,now:n,attemptId:No(),executableTypes:t,exclusiveTypes:this.handlerRegistry.getExclusiveTypes()});if(!i)return null;if(i.status===Oe.FAILED)return this.logger.warn("Expired attempt failed terminally on reclaim",{id:i.id,type:i.type,retryCount:i.retryCount}),await r?.(i),null;return this.logger.debug("Job dequeued",{id:i.id,type:i.type,priority:i.priority,retryCount:i.retryCount,attemptId:i.attemptId,workerSlotId:i.workerSlotId,workerSessionId:i.workerSessionId}),i}async startWorkerSession(e,t,r=Hi){await this.repository.startWorkerSession(this.sessionSlotId(e,t),t,Date.now(),r,this.brainVersion,this.versionedSlotId(e))}heartbeatWorkerSession(e,t,r=Hi){return this.repository.heartbeatWorkerSession(this.sessionSlotId(e,t),t,Date.now(),r)}endWorkerSession(e,t){return this.repository.endWorkerSession(this.sessionSlotId(e,t),t)}versionedSlotId(e){return this.brainVersion?`${e}@${this.brainVersion}`:e}sessionSlotId(e,t){return`${this.versionedSlotId(e)}#${t}`}renewAttemptLease(e,t,r){return this.repository.renewAttemptLease(e,t,Date.now(),r)}recordAttemptProgress(e,t,r){return this.repository.recordAttemptProgress(e,t,r)}complete(e,t,r){return this.repository.complete(e,t,r)}update(e,t,r){return this.repository.update(e,t,r)}fail(e,t,r){return this.repository.fail(e,t,r)}retireUnownedActiveJob(e){return this.repository.retireUnownedActiveJob(e)}async getDirectClaimOptions(){return this.directSessionStart??=this.repository.startWorkerSession(this.sessionSlotId(this.directWorkerSlotId,this.directWorkerSessionId),this.directWorkerSessionId,Date.now(),this.directLeaseDurationMs,this.brainVersion),await this.directSessionStart,{workerSlotId:this.directWorkerSlotId,workerSessionId:this.directWorkerSessionId,leaseDurationMs:this.directLeaseDurationMs}}async getStatus(e){return this.repository.getStatus(e)}async getJobsByRootJobId(e){return this.repository.getJobsByRootJobId(e)}async getStatusByEntityId(e){return this.repository.getStatusByEntityId(e)}async getStats(){return this.repository.getStats()}getDiagnostics(e){return this.repository.getDiagnostics(e)}async waitForIdle(e={}){let t=e.quietMs??250,r=e.pollIntervalMs??25,o=Date.now()+(e.timeoutMs??30000),n=async(i)=>{e.signal?.throwIfAborted();let{totals:s}=await this.getDiagnostics(),c=s.pending===0&&s.processing===0?i??Date.now():null;if(c!==null&&Date.now()-c>=t)return;if(Date.now()>=o)throw Error(`Timed out waiting for the job queue to settle: ${s.pending} pending, ${s.processing} processing`);return await Bun.sleep(r),n(c)};return n(null)}getRuntimeUpdates(e,t=1000){return this.repository.getRuntimeUpdates(e,t)}async cleanup(e){let t=await this.repository.cleanup(e);if(t>0)this.logger.info("Cleaned up old jobs",{deletedCount:t,olderThanMs:e});return t}async getActiveJobs(e){return this.repository.getActiveJobs(e)}async getRecentJobs(e,t){return this.repository.getRecentJobs(e,t)}async getFailedJobs(e){return this.repository.getFailedJobs(e)}}var K5=v(()=>{cp();HT();up();Do();z$();B5();F5();Rt();Ab();Z$()});var M$=()=>{};var H5=v(()=>{cp();Do();up();Do();M$();Ab()});var J5=v(()=>{Do();M$()});var Tb,V5;var q$=v(()=>{fe();Tb=l.object({success:l.boolean(),data:l.unknown().optional(),error:l.string().optional(),code:l.string().optional()}),V5=l.object({id:l.string().min(1),timestamp:l.string(),type:l.string().min(1),source:l.string().min(1),target:l.string().optional(),metadata:l.record(l.string(),l.unknown()).optional()})});var oFe;var W5=v(()=>{fe();q$();oFe=l.union([l.object({noop:l.literal(!0)}),Tb])});var Rb=v(()=>{W5()});var G5=v(()=>{Rb()});var Q5=v(()=>{Rb()});var Y5=v(()=>{Q5()});var xFe;var F$=v(()=>{fe();xFe=l.looseObject({issues:l.array(l.looseObject({message:l.string()})).optional()})});var X5=v(()=>{G5();Rb();Y5();F$();Rt();Ab()});var yhe;var e8=v(()=>{fe();q$();yhe=l.object({id:l.string().min(1),requestId:l.string().min(1),success:l.boolean(),data:l.unknown().optional(),error:l.object({message:l.string(),code:l.string().optional()}).optional(),timestamp:l.string().datetime()})});var ZFe;var t8=v(()=>{Rt();ZFe=new li("invalid_response").toJSON()});var r8=v(()=>{X5();e8();F$();t8()});var i3e;var n8=v(()=>{fe();r8();lp();Do();i3e=l.preprocess((e)=>{if(typeof e!=="string")return e;return JSON.parse(e)},l.record(l.string(),l.unknown()))});var c3e;var o8=v(()=>{fe();c3e=l.record(l.string(),l.unknown())});var i8=v(()=>{Rt();cp()});var s8=v(()=>{K5();H5();J5();n8();o8();up();Do();lp();i8()});var K$={};Lt(K$,{LEGACY_PROJECTION_JOB_TYPES:()=>c8,LEGACY_PROJECTION_RETIREMENT_REASON:()=>u8,legacyProjectionJobTypeSchema:()=>l8,retireLegacyProjectionJob:()=>xhe});import{existsSync as She}from"fs";import{resolve as vhe}from"path";function a8(e){return{id:e.id,type:e.type,status:e.status,retryCount:e.retryCount,maxRetries:e.maxRetries,createdAt:e.createdAt,startedAt:e.startedAt,completedAt:e.completedAt}}function whe(e,t){if(e.type!==t)throw Error(`Job ${e.id} has type ${e.type}; expected ${t}`);if(e.status!=="pending"&&e.status!=="processing")throw Error(`Job ${e.id} is already terminal (${e.status})`);if(e.attemptId!==null||e.workerSlotId!==null||e.workerSessionId!==null||e.leaseExpiresAt!==null||e.attemptHeartbeatAt!==null)throw Error(`Job ${e.id} still has attempt ownership`);if(e.progress!==null||e.result!=null)throw Error(`Job ${e.id} contains partial progress or a result`)}async function xhe(e){let t=vhe(e.databasePath);if(!She(t))throw Error(`Job database does not exist: ${t}`);let r=l8.parse(e.jobType),o=Qp.createFresh({url:`file:${t}`});try{let n=await o.getStatus(e.jobId);if(!n)throw Error(`Job not found: ${e.jobId}`);if(whe(n,r),e.dryRun){if(e.confirmation!==void 0)throw Error("Dry-run recovery must not include confirmation");return{databasePath:t,job:a8(n),retired:!1}}let i=`retire:${n.id}`;if(e.confirmation!==i)throw Error(`Refusing to retire ${n.id}; expected --confirm ${i}`);let s=await o.retireUnownedActiveJob({jobId:n.id,expectedType:r,reason:u8,now:e.now?.()??Date.now()});if(!s)throw Error(`Job ${n.id} changed or acquired ownership before retirement`);return{databasePath:t,job:a8(s),retired:!0}}finally{o.close()}}var c8,l8,u8="Retired legacy projection job superseded by scheduler-owned projections";var H$=v(()=>{s8();fe();c8=["conversation-memory:project","skill:project","swot:derive","topic:project"],l8=l.enum(c8)});function Mt(e,t,r,o,n){return p8.parse({id:e,operation:t,count:r,targetProbeCount:o,settleMs:n})}function V$(e){return Xp.parse(structuredClone(Ihe[e]))}function ef(e){let t=`stress:${e.handle}`;if(e.confirmation!==t)throw Error(`Directory-sync stress requires --confirm ${t}`);let r=/(^|[-_.])smoke($|[-_.])/i;if(!r.test(e.handle)||!r.test(e.domain)||!r.test(e.contentRepo))throw Error("Directory-sync stress is smoke-only; handle, domain, and content repository must all identify smoke")}async function Ob(e,t={}){let r=t.fetchImpl??fetch,o=t.now??(()=>new Date),n=t.timeoutMs??20000,i=o(),s=new AbortController,a=setTimeout(()=>s.abort(),n);try{let c=await r(e,{method:"GET",signal:s.signal});return await c.arrayBuffer(),J$.parse({timestamp:i.toISOString(),endpoint:new URL(e).pathname,status:c.status,durationMs:Math.max(0,o().getTime()-i.getTime()),ok:c.ok})}catch(c){return J$.parse({timestamp:i.toISOString(),endpoint:new URL(e).pathname,status:0,durationMs:Math.max(0,o().getTime()-i.getTime()),ok:!1,error:Ahe(c)})}finally{clearTimeout(a)}}async function W$(e,t){let r=Xp.parse(e),o=[],n,i=await t.prepare(r),s,a;try{try{await t.startMonitoring()}catch(c){n=`monitor: ${$b(c)}`}if(!n)for(let c of r.phases)try{let u=f8.parse(await t.executePhase(c,i));if(o.push(u),!u.success){n=`${c.id}: ${u.error??"phase failed"}`;break}}catch(u){let d=$b(u);o.push({id:c.id,operation:c.operation,count:c.count,success:!1,error:d}),n=`${c.id}: ${d}`;break}}finally{try{if(s=m8.parse(await t.cleanup(i)),!s.success&&!n)n=s.error??"cleanup failed"}catch(c){let u=$b(c);s={success:!1,probesRemaining:0,error:u},n??=`cleanup: ${u}`}try{a=h8.parse(await t.stopMonitoring())}catch(c){let u=$b(c);a={health:[],runtime:[]},n??=`monitor: ${u}`}}return n??=y8(a,r.maximumExternalAiCalls??0),g8.parse({profile:r.profile,success:n===void 0&&o.length===r.phases.length&&s.success,baseline:i,phases:o,cleanup:s,metrics:a,...n?{failure:n}:{}})}function y8(e,t=0){let r=e.health.find((i)=>!i.ok);if(r)return`health: ${r.endpoint} unavailable`;let o=e.externalAiCalls??0;if(o>t)return t===0?`external AI: observed ${o} call(s)`:`external AI: observed ${o} call(s), cap ${t}`;if(e.container?.oomKilled)return"container: OOM killed";let n=e.container?.restartCount??0;if(n>0)return`container: restarted ${n} time(s)`;if(e.container&&e.container.status!=="running")return`container: ${e.container.status}`;return}function Ahe(e){if(e instanceof Error)return`${e.name}: ${e.message}`;return String(e)}function $b(e){return Ve(e)}var Yp,d8,p8,Xp,_he,J$,Ehe,f8,m8,khe,h8,g8,Ihe;var Cb=v(()=>{fe();Yp=l.enum(["regression","load","stress"]),d8=l.enum(["add","update","rename","delete"]),p8=l.object({id:l.string().min(1),operation:d8,count:l.number().int().positive().max(700),targetProbeCount:l.number().int().min(0).max(700),settleMs:l.number().int().nonnegative().max(300000)}),Xp=l.object({profile:Yp,maximumProbeCount:l.number().int().positive().max(700),maximumExternalAiCalls:l.number().int().nonnegative().max(1e4).optional(),phases:l.array(p8).min(1)}),_he=l.object({entities:l.number().int().nonnegative(),notes:l.number().int().nonnegative(),version:l.string().min(1)}),J$=l.object({timestamp:l.iso.datetime(),endpoint:l.string().startsWith("/"),status:l.number().int().nonnegative(),durationMs:l.number().nonnegative(),ok:l.boolean(),error:l.string().optional()}),Ehe=l.object({timestamp:l.iso.datetime(),cpuPercent:l.number().nonnegative(),memoryPercent:l.number().nonnegative(),pids:l.number().int().nonnegative()}),f8=l.object({id:l.string().min(1),operation:d8,count:l.number().int().positive(),success:l.boolean(),commitLatencyMs:l.number().nonnegative().optional(),persistenceLatencyMs:l.number().nonnegative().optional(),error:l.string().optional()}),m8=l.object({success:l.boolean(),probesRemaining:l.number().int().nonnegative(),finalEntities:l.number().int().nonnegative().optional(),finalNotes:l.number().int().nonnegative().optional(),contentTreeRestored:l.boolean().optional(),error:l.string().optional()}),khe=l.object({status:l.string(),restartCount:l.number().int().nonnegative(),oomKilled:l.boolean()}),h8=l.object({health:l.array(J$),runtime:l.array(Ehe),externalAiCalls:l.number().int().nonnegative().optional(),container:khe.optional()}),g8=l.object({profile:Yp,success:l.boolean(),baseline:_he,phases:l.array(f8),cleanup:m8,metrics:h8,failure:l.string().optional()}),Ihe={regression:{profile:"regression",maximumProbeCount:20,phases:[Mt("add20","add",20,20,0),Mt("update20","update",20,20,30000),Mt("delete20","delete",20,0,150000)]},load:{profile:"load",maximumProbeCount:350,phases:[Mt("add50","add",50,50,0),Mt("add150","add",100,150,0),Mt("add350","add",200,350,0),Mt("update350a","update",350,350,45000),Mt("rename100","rename",100,350,45000),Mt("update350b","update",350,350,45000),Mt("delete350","delete",350,0,150000)]},stress:{profile:"stress",maximumProbeCount:700,phases:[Mt("add50","add",50,50,0),Mt("add150","add",100,150,0),Mt("add350","add",200,350,0),Mt("add700","add",350,700,0),Mt("update700a","update",700,700,45000),Mt("rename200","rename",200,700,45000),Mt("update700b","update",700,700,45000),Mt("delete700","delete",700,0,150000)]}}});import{spawn as The}from"child_process";async function b8(e,t,r,o){let n=await e(t,r,o);if(n.exitCode!==0)throw oo(t,r,n);return n}function oo(e,t,r){let o=r.stderr.trim()||r.stdout.trim();return Error(`${e} ${t.join(" ")} exited with ${r.exitCode}${o?`: ${o}`:""}`)}var Vo=async(e,t,r={})=>new Promise((o,n)=>{let i=The(e,[...t],{cwd:r.cwd,env:r.env?{...process.env,...r.env}:process.env,stdio:["pipe","pipe","pipe"]}),s="",a="";i.stdout.setEncoding("utf8"),i.stderr.setEncoding("utf8"),i.stdout.on("data",(c)=>{s+=c}),i.stderr.on("data",(c)=>{a+=c}),i.on("error",n),i.on("close",(c)=>{o({exitCode:c??1,stdout:s,stderr:a})}),i.stdin.end(r.stdin)});var tf=()=>{};class Bl{#e;#t;dir;constructor(e,t,r){this.#e=e,this.dir=t,this.#t=r}static async clone(e,t,r,o){let n=new Bl(e,r,o);return await b8(e,"git",["-c","credential.helper=","-c",`credential.helper=${S8}`,"clone","--branch","main","--single-branch",`https://github.com/${t}.git`,r],{env:n.environment()}),await n.run(["config","--local","credential.helper",S8]),await n.run(["reset","--hard","origin/main"]),n}async run(e,t=!0){let r=await this.#e("git",e,{cwd:this.dir,env:this.environment()});if(t&&r.exitCode!==0)throw oo("git",e,r);return r}async output(e){return(await this.run(e)).stdout.trim()}async sync(e=!1){if(await this.run(["fetch","origin","main"]),e)await this.run(["reset","--hard","origin/main"]);else await this.run(["pull","--rebase","origin","main"])}async commitAll(e){await this.run(["add","-A"]),await this.run(["-c","user.name=brains-ops","-c","user.email=ops@rizom.ai","commit","-m",e])}async pushMainWithRebase(){for(let e=1;e<=5;e+=1){if((await this.run(["push","origin","main"],!1)).exitCode===0)return;await this.run(["pull","--rebase","origin","main"])}throw Error("Unable to push content main after five rebase attempts")}async pruneStressBackupBranches(){let t=(await this.run(["ls-remote","--heads","origin","refs/heads/ops/directory-sync-stress-backup-*"])).stdout.split(/\r?\n/).map((r)=>r.match(/\trefs\/heads\/(ops\/directory-sync-stress-backup-[^\s]+)$/)?.[1]).filter((r)=>r!==void 0).sort();for(let r of t)await this.run(["push","origin","--delete",r]);return t}environment(){return{GH_TOKEN:this.#t,GITHUB_TOKEN:this.#t}}}var S8='!f() { test "$1" = get && echo username=x-access-token && echo "password=$GH_TOKEN"; }; f';var v8=v(()=>{tf()});function rf(e){return e.entityCounts.find((t)=>t.entityType==="note")?.count??0}class G${#e;#t=[];#r=[];#n=new Set(["/health/ready"]);#o=!0;#i;#a;#s="";#c=0;#l;constructor(e){this.#e=e}get startedAt(){return this.#s}get error(){return this.#a}get healthSamples(){return this.#t}get runtimeSamples(){return this.#r}gateHealthSamples(){return this.#t.slice(this.#c,this.#l??this.#t.length)}markGateEnd(){this.#l=this.#t.length}async discoverEndpoints(){for(let e of["/health/live","/health/operate"])if((await Ob(`https://${this.#e.domain}${e}`,{fetchImpl:this.#e.fetchImpl,now:this.#e.now,timeoutMs:5000})).status!==404)this.#n.add(e)}start(){this.#o=!1,this.#a=void 0,this.#c=this.#t.length,this.#l=void 0,this.#s=this.#e.now().toISOString(),this.#i=Promise.all([this.#m(),this.#f()]).then(()=>{return}).catch((e)=>{this.#a=e,this.#o=!0})}async stop(){this.#o=!0,await this.#i}async waitForHealthSnapshot(e){return this.waitForEntityBaseline(void 0,void 0,e)}async waitForEntityBaseline(e,t,r){let o=this.#e.now().getTime();while(this.#e.now().getTime()-o<r){let n=await this.fetchHealthPayload();if(this.#p(n,e,t))return n;await this.#e.sleep(5000)}return}async waitForStableEntityBaseline(e,t,r){let o=this.#e.now().getTime(),n=0;while(this.#e.now().getTime()-o<r){let i=await this.fetchHealthPayload();if(this.#p(i,e,t)){if(n+=1,n===2)return i}else n=0;await this.#e.sleep(5000)}return}async fetchHealthPayload(){let e=await this.#d();if(e===void 0)return;let t=await this.#e.readEntityCounts();if(!t)return;return{version:e,entities:t.reduce((r,o)=>r+o.count,0),entityCounts:t}}async#d(){let e=this.#e.now(),t=new AbortController,r=setTimeout(()=>t.abort(),20000);try{let o=await this.#e.fetchImpl(`https://${this.#e.domain}/health/operate`,{signal:t.signal}),n=await o.text();if(this.#t.push({timestamp:e.toISOString(),endpoint:"/health/operate",status:o.status,durationMs:Math.max(0,this.#e.now().getTime()-e.getTime()),ok:o.ok}),!o.ok)return;return Rhe.parse(JSON.parse(n)).app.version}catch(o){this.#t.push({timestamp:e.toISOString(),endpoint:"/health/operate",status:0,durationMs:Math.max(0,this.#e.now().getTime()-e.getTime()),ok:!1,error:o instanceof Error?`${o.name}: ${o.message}`:String(o)});return}finally{clearTimeout(r)}}#p(e,t,r){return e!==void 0&&(t===void 0||rf(e)===t)&&(r===void 0||e.entities===r)}async#m(){while(!this.#o){for(let e of this.#n)this.#t.push(await Ob(`https://${this.#e.domain}${e}`,{fetchImpl:this.#e.fetchImpl,now:this.#e.now,timeoutMs:20000}));await this.#e.sleep(4000)}}async#f(){while(!this.#o){let e=await this.#e.sampleRuntime();if(e)this.#r.push(e);await this.#e.sleep(1000)}}}var w8,Rhe;var x8=v(()=>{fe();Cb();w8=l.array(l.object({entityType:l.string(),count:l.number().int().nonnegative()})),Rhe=l.object({status:l.literal("ready"),operationalStatus:l.literal("operational"),app:l.object({version:l.string()})})});var Pb={};Lt(Pb,{applyDirectorySyncStressPhase:()=>R8,cleanupDirectorySyncStress:()=>I8,listProbeFiles:()=>va,parseStressRuntimeSample:()=>$8,removeProbeFiles:()=>nO,runDeployedDirectorySyncStress:()=>E8,runStressCommand:()=>Vo,verifyDirectorySyncStressAccess:()=>k8});import{chmod as $he,mkdir as Y$,mkdtemp as X$,readFile as Ohe,readdir as Che,rename as Phe,rm as of,writeFile as Tn}from"fs/promises";import{tmpdir as eO}from"os";import{join as ct,resolve as tO}from"path";async function E8(e){let t=e.now??(()=>new Date),r=t().toISOString(),o=oO(r),n=tO(e.artifactsDir??ct(e.rootDir,".brains-ops","stress",o));await Y$(n,{recursive:!0});let{pilot:i,user:s}=await rO(e.rootDir,e.handle);ef({handle:s.handle,domain:s.domain,contentRepo:s.contentRepo,confirmation:e.confirmation});let a=Yp.parse(e.profile),c=e.plan?Xp.parse(e.plan):V$(a);if(c.profile!==a)throw Error(`Directory-sync stress plan profile ${c.profile} does not match requested profile ${a}`);if((c.maximumExternalAiCalls??0)===0)T8(s);let u=zhe.parse(e.env??process.env),d=new A8({runId:o,artifactsDir:n,user:s,githubOrg:i.githubOrg,serverLabel:`${i.contentRepoPrefix}${s.handle}`,environment:u,fetchImpl:e.fetchImpl??fetch,commandRunner:e.commandRunner??Vo,logger:e.logger??console.info,now:t,sleep:e.sleep??Bun.sleep}),p;try{p=await W$(c,d)}finally{await d.dispose()}let m={runId:o,artifactsDir:n,target:{handle:s.handle,domain:s.domain,contentRepo:`${i.githubOrg}/${s.contentRepo}`},startedAt:r,completedAt:t().toISOString(),report:p};return await Zhe(m),m}async function k8(e){let r=(e.now??(()=>new Date))().toISOString(),o=oO(r),n=tO(e.artifactsDir??ct(e.rootDir,".brains-ops","stress",`access-check-${o}`));await Y$(n,{recursive:!0});let{pilot:i,user:s}=await rO(e.rootDir,e.handle);ef({handle:s.handle,domain:s.domain,contentRepo:s.contentRepo,confirmation:e.confirmation}),T8(s);let a=(e.env??process.env).CONTENT_REPO_ADMIN_TOKEN;if(!a)throw Error("Missing CONTENT_REPO_ADMIN_TOKEN");let c=await X$(ct(eO(),"brains-ops-directory-sync-access-check-"));try{let u=await Bl.clone(e.commandRunner??Vo,`${i.githubOrg}/${s.contentRepo}`,ct(c,"content"),a),d=await u.output(["rev-parse","HEAD"]);await u.run(["push","--dry-run","origin",`HEAD:refs/heads/ops/directory-sync-stress-access-check-${o}`]);let p={success:!0,artifactsDir:n,checkedAt:r,remoteHead:d,target:{handle:s.handle,domain:s.domain,contentRepo:`${i.githubOrg}/${s.contentRepo}`}};return await Tn(ct(n,"access-check.json"),`${JSON.stringify(p,null,2)}
|
|
438
438
|
`),p}finally{await of(c,{recursive:!0,force:!0})}}async function I8(e){let t=e.now??(()=>new Date),r=tO(e.artifactsDir??ct(e.rootDir,".brains-ops","stress",`cleanup-${oO(t().toISOString())}`));await Y$(r,{recursive:!0});let{pilot:o,user:n}=await rO(e.rootDir,e.handle);ef({handle:n.handle,domain:n.domain,contentRepo:n.contentRepo,confirmation:e.confirmation});let i=(e.env??process.env).CONTENT_REPO_ADMIN_TOKEN;if(!i)throw Error("Missing CONTENT_REPO_ADMIN_TOKEN");let s=e.commandRunner??Vo,a=e.logger??console.info,c=await X$(ct(eO(),"brains-ops-directory-sync-cleanup-")),u=ct(c,"content");try{let d=await Bl.clone(s,`${o.githubOrg}/${n.contentRepo}`,u,i),p=await nO(d.dir),m;if(p>0)await d.commitAll("test(directory-sync): clean residual stress probes"),await d.pushMainWithRebase(),m=await d.output(["rev-parse","HEAD"]),a(`Removed ${p} directory-sync stress probes`);let h=(await va(d.dir)).length,b=h===0?await d.pruneStressBackupBranches():[],y={success:h===0,artifactsDir:r,probesRemoved:p,probesRemaining:h,backupBranchesDeleted:b,...m?{cleanupCommit:m}:{}};return await Tn(ct(r,"cleanup.json"),`${JSON.stringify(y,null,2)}
|
|
439
|
-
`),y}finally{await of(c,{recursive:!0,force:!0})}}class A8{#e;#t;#r;#n;#o;#i;#a;#s;#c;#l;#d;constructor(e){this.#e=e,this.#t=new G$({domain:e.user.domain,fetchImpl:e.fetchImpl,now:e.now,sleep:e.sleep,sampleRuntime:()=>this.#b(),readEntityCounts:()=>this.#y()})}async prepare(e){this.#r=await X$(ct(eO(),"brains-ops-directory-sync-stress-"));let t=ct(this.#r,"content");this.#o=ct(this.#r,"id_ed25519"),this.#i=ct(this.#r,"known_hosts"),this.#a=await this.#m(),await Tn(this.#o,
|
|
439
|
+
`),y}finally{await of(c,{recursive:!0,force:!0})}}class A8{#e;#t;#r;#n;#o;#i;#a;#s;#c;#l;#d;constructor(e){this.#e=e,this.#t=new G$({domain:e.user.domain,fetchImpl:e.fetchImpl,now:e.now,sleep:e.sleep,sampleRuntime:()=>this.#b(),readEntityCounts:()=>this.#y()})}async prepare(e){this.#r=await X$(ct(eO(),"brains-ops-directory-sync-stress-"));let t=ct(this.#r,"content");this.#o=ct(this.#r,"id_ed25519"),this.#i=ct(this.#r,"known_hosts"),this.#a=await this.#m(),await Tn(this.#o,jhe(this.#e.environment.KAMAL_SSH_PRIVATE_KEY),{mode:384}),await $he(this.#o,384);let r=await this.#S("ssh-keyscan",["-T","10","-t","ed25519",this.#a]);if(r.exitCode!==0||!r.stdout.trim())throw Error("Unable to resolve smoke SSH host key");await Tn(this.#i,r.stdout,{mode:384});let o=await this.#h(["docker","ps","--filter","label=service=rover","--filter","label=role=web","--format","{{.Names}}"]);if(this.#s=o.stdout.trim().split(/\r?\n/)[0],!this.#s||!/^[A-Za-z0-9_.-]+$/.test(this.#s))throw Error("Unable to resolve a running smoke container");let n=await Bl.clone(this.#e.commandRunner,`${this.#e.githubOrg}/${this.#e.user.contentRepo}`,t,this.#e.environment.CONTENT_REPO_ADMIN_TOKEN);if(this.#n=n,(await va(n.dir)).length>0)throw Error("Directory-sync stress probes already exist");let i=await n.output(["rev-parse","HEAD"]);this.#l=await n.output(["rev-parse","HEAD^{tree}"]),this.#d=await this.#p();let s=await this.#t.waitForHealthSnapshot(60000);if(!s)throw Error("Smoke health was unavailable before stress testing");return this.#c=`ops/directory-sync-stress-backup-${this.#e.runId}`,await n.run(["push","origin",`HEAD:refs/heads/${this.#c}`]),await this.#t.discoverEndpoints(),await Tn(ct(this.#e.artifactsDir,"state.json"),`${JSON.stringify({runId:this.#e.runId,profile:e.profile,originalHead:i,originalTree:this.#l,backupBranch:this.#c,baseline:{entities:s.entities,notes:rf(s),version:s.version}},null,2)}
|
|
440
440
|
`),this.#e.logger(`Prepared ${e.profile} directory-sync stress run for ${this.#e.user.handle}`),{entities:s.entities,notes:rf(s),version:s.version}}async startMonitoring(){this.#v(),this.#t.start()}async executePhase(e,t){this.#v();let r=this.#n;if(!r)throw Error("Directory-sync stress checkout is not prepared");await r.sync();let o=this.#t.healthSamples.length,n=this.#e.now().getTime(),i=await this.#g();if(i?.pending!==0||i.processing!==0)return jl(e,"health did not provide a drained queue before the phase");await R8(r.dir,e),await r.commitAll(`test(directory-sync): stress ${e.id}`),await r.pushMainWithRebase();let s=this.#e.now().getTime(),a=await r.output(["rev-parse","HEAD"]),c=await this.#f(a,900000);if(c===void 0)return jl(e,"runtime did not pull the phase commit");let u;if(e.operation==="rename"){let h=t.notes+e.targetProbeCount;if(e.settleMs>0)await this.#e.sleep(e.settleMs);let b=await this.#t.waitForStableEntityBaseline(h,void 0,1200000);if(u=this.#e.now().getTime()-s,!b)return jl(e,`health did not stabilize at ${h} notes`,c,u)}else if(e.operation==="add"||e.operation==="delete"){let h=t.notes+e.targetProbeCount,b=this.#e.now().getTime(),y=await this.#t.waitForEntityBaseline(h,void 0,1200000);if(u=this.#e.now().getTime()-b,!y)return jl(e,`health did not reach ${h} notes`,c,u)}if(e.operation!=="rename"&&e.settleMs>0)await this.#e.sleep(e.settleMs);let d=e.operation==="delete"?0:Math.ceil(e.count/50);if(!await this.#u(i.completedImports+d,1200000))return jl(e,`health did not observe ${d} completed import job(s) with a drained queue`,c,u);let m=this.#t.healthSamples.slice(o).find((h)=>!h.ok);if(m)return jl(e,`${m.endpoint} unavailable (${m.status===0?m.error??"unknown":m.status})`,c,u);return this.#e.logger(`Completed ${e.id} in ${this.#e.now().getTime()-n}ms`),{id:e.id,operation:e.operation,count:e.count,success:!0,commitLatencyMs:c,...u===void 0?{}:{persistenceLatencyMs:u}}}async cleanup(e){let t=this.#n;if(!t)return{success:!1,probesRemaining:0,error:"stress checkout was not prepared"};try{if(await t.sync(!0),await nO(t.dir)>0)await t.commitAll("test(directory-sync): remove stress probes"),await t.pushMainWithRebase();let o=(await va(t.dir)).length;this.#t.markGateEnd();let n=await this.#t.waitForEntityBaseline(e.notes,e.entities,1200000);await t.sync(!0);let s=await t.output(["rev-parse","HEAD^{tree}"])===this.#l,a=o===0&&n!==void 0&&s;if(a&&this.#c){if((await t.run(["push","origin","--delete",this.#c],!1)).exitCode!==0)this.#e.logger(`Warning: unable to delete backup branch ${this.#c}`)}return{success:a,probesRemaining:o,...n?{finalEntities:n.entities,finalNotes:rf(n)}:{},contentTreeRestored:s,...!a?{error:!n?"entity baseline was not restored before cleanup timeout":!s?"content tree differs from the pre-stress baseline":"stress probes remain after cleanup"}:{}}}catch(r){return{success:!1,probesRemaining:(await va(t.dir)).length,error:Ve(r)}}}async stopMonitoring(){await this.#t.stop(),await Tn(ct(this.#e.artifactsDir,"health-samples.json"),`${JSON.stringify(this.#t.healthSamples,null,2)}
|
|
441
|
-
`);let e=0;if(this.#s&&this.#t.startedAt){let o=await this.#h(["docker","logs","--since",this.#t.startedAt,this.#s],!1),n=`${o.stdout}${o.stderr}`;e=n.match(/\] ai:usage \{/g)?.length??0,await Tn(ct(this.#e.artifactsDir,"runtime.log"),n)}let t=await this.#p(),r={health:this.#t.gateHealthSamples(),runtime:[...this.#t.runtimeSamples],externalAiCalls:e,...t?{container:t}:{}};if(this.#t.error)throw this.#t.error;return r}async dispose(){if(await this.#t.stop(),this.#r)await of(this.#r,{recursive:!0,force:!0})}async#p(){if(!this.#s)return;let e=await this.#h(["docker","inspect",this.#s],!1);if(e.exitCode!==0)throw Error(`docker inspect ${this.#s} exited with code ${e.exitCode}`);let t;try{t=l.array(l.object({RestartCount:l.number().int().nonnegative(),State:l.object({Status:l.string(),OOMKilled:l.boolean(),StartedAt:l.string().min(1)})})).parse(JSON.parse(e.stdout))}catch(i){throw Error(`Could not read docker inspect output for ${this.#s}`,{cause:i})}let r=t[0];if(!r)throw Error("docker inspect reported no such container");let o=Math.max(0,r.RestartCount-(this.#d?.restartCount??0)),n=this.#d!==void 0&&r.State.StartedAt!==this.#d.startedAt;return{status:r.State.Status,restartCount:Math.max(o,n?1:0),oomKilled:r.State.OOMKilled&&!(this.#d?.oomKilled??!1),startedAt:r.State.StartedAt}}async#m(){let e=encodeURIComponent(`brain=${this.#e.serverLabel}`),t=await this.#e.fetchImpl(`https://api.hetzner.cloud/v1/servers?label_selector=${e}`,{headers:{Authorization:`Bearer ${this.#e.environment.HCLOUD_TOKEN}`}});if(!t.ok)throw Error(`Hetzner server lookup failed with ${t.status}`);let o=
|
|
442
|
-
`))}break}case"update":{if(r.length!==t.count)throw Error(`${t.id} expected ${t.count} probes, found ${r.length}`);for(let o of r){let n=ct(e,o),i=await
|
|
441
|
+
`);let e=0;if(this.#s&&this.#t.startedAt){let o=await this.#h(["docker","logs","--since",this.#t.startedAt,this.#s],!1),n=`${o.stdout}${o.stderr}`;e=n.match(/\] ai:usage \{/g)?.length??0,await Tn(ct(this.#e.artifactsDir,"runtime.log"),n)}let t=await this.#p(),r={health:this.#t.gateHealthSamples(),runtime:[...this.#t.runtimeSamples],externalAiCalls:e,...t?{container:t}:{}};if(this.#t.error)throw this.#t.error;return r}async dispose(){if(await this.#t.stop(),this.#r)await of(this.#r,{recursive:!0,force:!0})}async#p(){if(!this.#s)return;let e=await this.#h(["docker","inspect",this.#s],!1);if(e.exitCode!==0)throw Error(`docker inspect ${this.#s} exited with code ${e.exitCode}`);let t;try{t=l.array(l.object({RestartCount:l.number().int().nonnegative(),State:l.object({Status:l.string(),OOMKilled:l.boolean(),StartedAt:l.string().min(1)})})).parse(JSON.parse(e.stdout))}catch(i){throw Error(`Could not read docker inspect output for ${this.#s}`,{cause:i})}let r=t[0];if(!r)throw Error("docker inspect reported no such container");let o=Math.max(0,r.RestartCount-(this.#d?.restartCount??0)),n=this.#d!==void 0&&r.State.StartedAt!==this.#d.startedAt;return{status:r.State.Status,restartCount:Math.max(o,n?1:0),oomKilled:r.State.OOMKilled&&!(this.#d?.oomKilled??!1),startedAt:r.State.StartedAt}}async#m(){let e=encodeURIComponent(`brain=${this.#e.serverLabel}`),t=await this.#e.fetchImpl(`https://api.hetzner.cloud/v1/servers?label_selector=${e}`,{headers:{Authorization:`Bearer ${this.#e.environment.HCLOUD_TOKEN}`}});if(!t.ok)throw Error(`Hetzner server lookup failed with ${t.status}`);let o=Nhe.parse(await t.json()).servers[0];if(o?.status!=="running")throw Error("Smoke server is not running");return o.public_net.ipv4.ip}async#f(e,t){let r=this.#s;if(!r)throw Error("Directory-sync stress container is not prepared");let o=this.#e.now().getTime();while(this.#e.now().getTime()-o<t){if((await this.#h(["docker","exec",r,"git","-C","/app/brain-data","merge-base","--is-ancestor",e,"HEAD"],!1)).exitCode===0)return this.#e.now().getTime()-o;await this.#e.sleep(5000)}return}async#g(){let e=new AbortController,t=setTimeout(()=>e.abort(),20000),r;try{let i=await this.#e.fetchImpl(`https://${this.#e.user.domain}/health/operate`,{method:"GET",signal:e.signal});if(!i.ok)return;r=await i.json()}catch{return}finally{clearTimeout(t)}let o=Dhe.safeParse(r);if(!o.success)throw Error(`Unexpected /health/operate payload from ${this.#e.user.domain}`,{cause:o.error});let n=o.data.resources.queue.byType.filter((i)=>i.type==="directory-sync:directory-import"&&i.status==="completed").reduce((i,s)=>i+s.count,0);return{pending:o.data.resources.queue.totals.pending,processing:o.data.resources.queue.totals.processing,completedImports:n}}async#u(e,t){let r=this.#e.now().getTime(),o=0;while(this.#e.now().getTime()-r<t){let n=await this.#g();if(n?.pending===0&&n.processing===0&&n.completedImports>=e){if(o+=1,o===2)return!0}else o=0;await this.#e.sleep(5000)}return!1}async#y(){let e=this.#s;if(!e)throw Error("Directory-sync stress container is not prepared");let t=await this.#h(["docker","exec",e,"bun","-e",`'${Lhe}'`],!1);if(t.exitCode!==0)return;try{return w8.parse(JSON.parse(t.stdout))}catch(r){throw Error(`Could not read entity counts from ${e}`,{cause:r})}}async#b(){let e=this.#s;if(!e)throw Error("Directory-sync stress container is not prepared");let t=await this.#h(["timeout","15","docker","stats","--no-stream","--format","{{.CPUPerc}},{{.MemPerc}},{{.PIDs}}",e],!1);return $8(t.stdout.trim(),this.#e.now().toISOString())}async#h(e,t=!0){let r=this.#o,o=this.#i,n=this.#a;if(!r||!o||!n)throw Error("Directory-sync stress SSH access is not prepared");let i=await this.#S("ssh",["-i",r,"-o","BatchMode=yes","-o","IdentitiesOnly=yes","-o","ConnectTimeout=10","-o","StrictHostKeyChecking=yes","-o",`UserKnownHostsFile=${o}`,`root@${n}`,...e]);if(t&&i.exitCode!==0)throw oo("ssh",e,i);return i}async#S(e,t,r){return this.#e.commandRunner(e,t,r)}#v(){if(!this.#n||!this.#o||!this.#i||!this.#a||!this.#s)throw Error("Directory-sync stress driver is not prepared")}}function T8(e){if(e.embeddingEnabled!==!1)throw Error("Directory-sync stress requires embeddingEnabled: false for a hermetic smoke workload");if(e.topicExtractionEnabled!==!1)throw Error("Directory-sync stress requires topicExtractionEnabled: false for a hermetic smoke workload");if(e.skillDerivationEnabled!==!1)throw Error("Directory-sync stress requires skillDerivationEnabled: false for a hermetic smoke workload");if(e.swotDerivationEnabled!==!1)throw Error("Directory-sync stress requires swotDerivationEnabled: false for a hermetic smoke workload")}async function rO(e,t){let r=await ut(e),o=r.users.find((n)=>n.handle===t);if(!o)throw Error(`Unknown pilot user: ${t}`);return{pilot:r.pilot,user:o}}async function R8(e,t){let r=await va(e);switch(t.operation){case"add":{let o=t.targetProbeCount-r.length;if(o!==t.count)throw Error(`${t.id} expected to add ${t.count} probes from ${r.length}`);let n=r.map(Bhe).filter((s)=>s!==void 0),i=n.length===0?1:Math.max(...n)+1;for(let s=i;s<i+o;s+=1){let a=String(s).padStart(3,"0");await Tn(ct(e,`directory-sync-stress-${a}.md`),["---",`title: "Directory Sync Stress ${a}"`,"---","",`Deterministic directory-sync stress probe ${a}.`,"Payload: abcdefghijklmnopqrstuvwxyz-0123456789-abcdefghijklmnopqrstuvwxyz.",""].join(`
|
|
442
|
+
`))}break}case"update":{if(r.length!==t.count)throw Error(`${t.id} expected ${t.count} probes, found ${r.length}`);for(let o of r){let n=ct(e,o),i=await Ohe(n,"utf8");await Tn(n,`${i.trimEnd()}
|
|
443
443
|
|
|
444
444
|
Update marker: ${t.id}.
|
|
445
|
-
`)}break}case"rename":{let o=r.filter((n)=>/^directory-sync-stress-\d+\.md$/.test(n)).slice(0,t.count);if(o.length!==t.count)throw Error(`${t.id} expected ${t.count} unrenamed probes, found ${o.length}`);for(let n of o)await
|
|
445
|
+
`)}break}case"rename":{let o=r.filter((n)=>/^directory-sync-stress-\d+\.md$/.test(n)).slice(0,t.count);if(o.length!==t.count)throw Error(`${t.id} expected ${t.count} unrenamed probes, found ${o.length}`);for(let n of o)await Phe(ct(e,n),ct(e,n.replace("directory-sync-stress-","directory-sync-stress-renamed-")));break}case"delete":{if(r.length!==t.count)throw Error(`${t.id} expected ${t.count} probes, found ${r.length}`);await Promise.all(r.map((o)=>of(ct(e,o),{force:!0})));break}}}async function va(e){return(await Che(e)).filter((r)=>/^directory-sync-stress-(?:renamed-)?\d+\.md$/.test(r)&&!r.includes("/")).sort()}async function nO(e){let t=await va(e);return await Promise.all(t.map((r)=>of(ct(e,r),{force:!0}))),t.length}function Bhe(e){let t=e.match(/(\d+)\.md$/)?.[1];return t?Number.parseInt(t,10):void 0}function jl(e,t,r,o){return{id:e.id,operation:e.operation,count:e.count,success:!1,...r===void 0?{}:{commitLatencyMs:r},...o===void 0?{}:{persistenceLatencyMs:o},error:t}}function $8(e,t){let[r,o,n]=e.split(",");if(!r||!o||!n)return;let i=Number.parseFloat(r.replace("%","")),s=Number.parseFloat(o.replace("%","")),a=Number.parseInt(n,10);if(!Number.isFinite(i)||!Number.isFinite(s)||!Number.isFinite(a))return;return{timestamp:t,cpuPercent:i,memoryPercent:s,pids:a}}function jhe(e){return`${e.replace(/\r\n/g,`
|
|
446
446
|
`).replace(/\\n/g,`
|
|
447
447
|
`).trimEnd()}
|
|
448
|
-
`}function oO(e){return e.replace(/[-:.TZ]/g,"").slice(0,14)}async function
|
|
449
|
-
`),await Tn(ct(e.artifactsDir,"report.md"),
|
|
448
|
+
`}function oO(e){return e.replace(/[-:.TZ]/g,"").slice(0,14)}async function Zhe(e){await Tn(ct(e.artifactsDir,"report.json"),`${JSON.stringify(e,null,2)}
|
|
449
|
+
`),await Tn(ct(e.artifactsDir,"report.md"),Uhe(e))}function Uhe(e){let t=e.report.metrics.runtime,r=e.report.metrics.health,o=t.map((a)=>a.cpuPercent).sort((a,c)=>a-c),n=t.map((a)=>a.memoryPercent),i=r.filter((a)=>!a.ok),s=["# Directory-sync stress report","",`- Run: \`${e.runId}\``,`- Target: \`${e.target.handle}\` (${e.target.domain})`,`- Profile: \`${e.report.profile}\``,`- Version: \`${e.report.baseline.version}\``,`- Result: **${e.report.success?"PASS":"FAIL"}**`,`- Started: ${e.startedAt}`,`- Completed: ${e.completedAt}`,"","## Phases","","| Phase | Operation | Count | Result | Pull latency | Persistence latency |","| --- | --- | ---: | --- | ---: | ---: |",...e.report.phases.map((a)=>`| ${a.id} | ${a.operation} | ${a.count} | ${a.success?"pass":`fail: ${a.error??"unknown"}`} | ${_8(a.commitLatencyMs)} | ${_8(a.persistenceLatencyMs)} |`),"","## Runtime","",`- Samples: ${t.length}`,`- CPU p50/p95/p99/max: ${nf(Q$(o,0.5))} / ${nf(Q$(o,0.95))} / ${nf(Q$(o,0.99))} / ${nf(o.at(-1))}`,`- Memory max: ${nf(n.length?Math.max(...n):void 0)}`,`- PIDs max: ${t.length?Math.max(...t.map((a)=>a.pids)):"n/a"}`,`- Container status/restarts/OOM: ${e.report.metrics.container?`${e.report.metrics.container.status} / ${e.report.metrics.container.restartCount} / ${e.report.metrics.container.oomKilled}`:"unknown"}`,`- External AI calls: ${e.report.metrics.externalAiCalls??0}`,`- Health samples: ${r.length}`,`- Health failures: ${i.length}`,"","## Cleanup","",`- Result: ${e.report.cleanup.success?"pass":"fail"}`,`- Remaining probes: ${e.report.cleanup.probesRemaining}`,`- Final entities: ${e.report.cleanup.finalEntities??"unknown"}`,`- Final notes: ${e.report.cleanup.finalNotes??"unknown"}`,`- Content tree restored: ${e.report.cleanup.contentTreeRestored??"unknown"}`,""];if(e.report.failure)s.push("## Failure","",e.report.failure,"");return`${s.join(`
|
|
450
450
|
`)}
|
|
451
|
-
`}function Q$(e,t){if(e.length===0)return;let r=Math.max(0,Math.ceil(e.length*t)-1);return e[r]}function nf(e){return e===void 0?"n/a":`${e.toFixed(2)}%`}function _8(e){return e===void 0?"n/a":`${(e/1000).toFixed(1)}s`}var
|
|
451
|
+
`}function Q$(e,t){if(e.length===0)return;let r=Math.max(0,Math.ceil(e.length*t)-1);return e[r]}function nf(e){return e===void 0?"n/a":`${e.toFixed(2)}%`}function _8(e){return e===void 0?"n/a":`${(e/1000).toFixed(1)}s`}var zhe,Nhe,Dhe,Lhe;var sf=v(()=>{fe();Cb();Hr();tf();v8();x8();tf();zhe=l.object({HCLOUD_TOKEN:l.string().min(1),KAMAL_SSH_PRIVATE_KEY:l.string().min(1),CONTENT_REPO_ADMIN_TOKEN:l.string().min(1)}),Nhe=l.object({servers:l.array(l.object({id:l.number().int(),status:l.string(),public_net:l.object({ipv4:l.object({ip:l.string().min(1)})})}))}),Dhe=l.object({status:l.literal("ready"),operationalStatus:l.literal("operational"),resources:l.object({queue:l.object({totals:l.object({pending:l.number().int().nonnegative(),processing:l.number().int().nonnegative()}),byType:l.array(l.object({type:l.string(),status:l.string(),count:l.number().int().nonnegative()}))})})}),Lhe=['import { Database } from "bun:sqlite";','const path = (process.env.XDG_DATA_HOME || "./data") + "/brain.db";',"const db = new Database(path, { readonly: true });",'const rows = db.query(`SELECT "entityType" AS "entityType", COUNT(*) AS "count" FROM entities GROUP BY "entityType"`).all();',"process.stdout.write(JSON.stringify(rows));"].join(" ")});var O8=v(()=>{Qo()});var Mhe="/usr/local/sbin/brains-health-watchdog",qhe="ai.rizom.brain.watchdog",Fhe="true",iO,C8,i5e;var P8=v(async()=>{O8();iO=`${qhe}=${Fhe}`,C8=`#!/usr/bin/env bash
|
|
452
452
|
set -euo pipefail
|
|
453
453
|
umask 077
|
|
454
454
|
|
|
@@ -507,14 +507,14 @@ while read -r container_id; do
|
|
|
507
507
|
logger -t brains-health-watchdog "restarting unhealthy container=$container_name service=$service_name incident=$incident_path"
|
|
508
508
|
docker restart "$container_id"
|
|
509
509
|
done < <(docker ps --filter health=unhealthy --filter label=${iO} --format '{{.ID}}')
|
|
510
|
-
`,
|
|
510
|
+
`,i5e=`[Unit]
|
|
511
511
|
Description=Restart persistently unhealthy Brain containers
|
|
512
512
|
After=docker.service
|
|
513
513
|
Requires=docker.service
|
|
514
514
|
|
|
515
515
|
[Service]
|
|
516
516
|
Type=oneshot
|
|
517
|
-
ExecStart=${
|
|
517
|
+
ExecStart=${Mhe}
|
|
518
518
|
`});var N8=`#!/usr/bin/env bash
|
|
519
519
|
set -euo pipefail
|
|
520
520
|
umask 077
|
|
@@ -742,36 +742,36 @@ deployed_container_restarted=false
|
|
|
742
742
|
EOF
|
|
743
743
|
pass "fleet watchdog isolation smoke completed"
|
|
744
744
|
printf 'REMOTE_ARTIFACT_DIR=%s\\n' "$remote_dir"
|
|
745
|
-
`;var z8=()=>{};var lO={};Lt(lO,{assertHealthWatchdogSmokeTarget:()=>Nb,cleanupHealthWatchdogSmoke:()=>Z8,renderHealthWatchdogSmokeRemoteScript:()=>cO,runHealthWatchdogSmoke:()=>j8});import{access as
|
|
745
|
+
`;var z8=()=>{};var lO={};Lt(lO,{assertHealthWatchdogSmokeTarget:()=>Nb,cleanupHealthWatchdogSmoke:()=>Z8,renderHealthWatchdogSmokeRemoteScript:()=>cO,runHealthWatchdogSmoke:()=>j8});import{access as Hhe,chmod as Jhe,mkdir as D8,mkdtemp as Vhe,rm as aO,writeFile as Zl}from"fs/promises";import{tmpdir as Whe}from"os";import{join as io,resolve as L8}from"path";function Nb(e){let t=`watchdog-smoke:${e.handle}`;if(e.confirmation!==t)throw Error(`Health watchdog smoke requires --confirm ${t}`);if(!/^[A-Za-z0-9][A-Za-z0-9_.-]{0,100}$/.test(e.runId))throw Error("Health watchdog smoke run ID is invalid");let r=/(^|[-_.])smoke($|[-_.])/i;if(!r.test(e.handle)||!r.test(e.domain))throw Error("Health watchdog smoke is smoke-only; handle and domain must both identify smoke")}function cO(){return N8.replace("__WATCHDOG_PAYLOAD_BASE64__",Buffer.from(C8,"utf8").toString("base64")).replace("__WATCHDOG_LABEL_FILTER__",iO)}async function j8(e){let t=L8(e.artifactsDir??io(e.rootDir,".brains-ops","watchdog-smoke",e.runId)),r=await U8(e.rootDir,e.handle);Nb({handle:r.user.handle,domain:r.user.domain,confirmation:e.confirmation,runId:e.runId}),await D8(t,{recursive:!0});let o=B8.parse(e.env??process.env),n=e.commandRunner??Vo,i=e.logger??console.info,s=await M8({target:r,environment:o,commandRunner:n,fetchImpl:e.fetchImpl??fetch}),a=`/tmp/brains-health-watchdog-smoke-${e.runId}`,c,u=!1;try{let m=await sO(s,"run",e.runId);if(await zb(t,"remote",m),m.stdout.trim())i(m.stdout.trim());if(m.exitCode!==0)c=oo("ssh",["watchdog-smoke","run"],m);let h=await Qhe(s,a,t);if(await zb(t,"scp",h),h.exitCode===0){if(u=await Yhe(io(t,"summary.txt")),!u)c??=Error("Health watchdog smoke evidence is missing summary.txt")}else c??=oo("scp",[a,t],h)}catch(m){c=Error(Ve(m,"Health watchdog smoke execution failed"))}let d;try{let m=await sO(s,"cleanup",e.runId);if(await zb(t,"cleanup",m),m.exitCode!==0)d=oo("ssh",["watchdog-smoke","cleanup"],m)}catch(m){d=Error(Ve(m,"Health watchdog smoke cleanup failed"))}finally{await aO(s.temporaryRoot,{recursive:!0,force:!0})}if(c)throw c;if(d)throw d;if(!u)throw Error("Health watchdog smoke completed without copied evidence");let p={success:!0,runId:e.runId,artifactsDir:t,target:{handle:r.user.handle,domain:r.user.domain,serverIp:s.serverIp}};return await Zl(io(t,"result.json"),`${JSON.stringify(p,null,2)}
|
|
746
746
|
`),p}async function Z8(e){let t=L8(e.artifactsDir??io(e.rootDir,".brains-ops","watchdog-smoke",`cleanup-${e.runId}`)),r=await U8(e.rootDir,e.handle);Nb({handle:r.user.handle,domain:r.user.domain,confirmation:e.confirmation,runId:e.runId}),await D8(t,{recursive:!0});let o=B8.parse(e.env??process.env),n=await M8({target:r,environment:o,commandRunner:e.commandRunner??Vo,fetchImpl:e.fetchImpl??fetch});try{let s=await sO(n,"cleanup",e.runId);if(await zb(t,"cleanup",s),s.stdout.trim())(e.logger??console.info)(s.stdout.trim());if(s.exitCode!==0)throw oo("ssh",["watchdog-smoke","cleanup"],s)}finally{await aO(n.temporaryRoot,{recursive:!0,force:!0})}let i={success:!0,runId:e.runId,artifactsDir:t,target:{handle:r.user.handle,domain:r.user.domain,serverIp:n.serverIp}};return await Zl(io(t,"result.json"),`${JSON.stringify(i,null,2)}
|
|
747
|
-
`),i}async function U8(e,t){let r=await ut(e),o=r.users.find((n)=>n.handle===t);if(!o)throw Error(`Unknown pilot user: ${t}`);return{pilot:r.pilot,user:o}}async function M8(e){let t=await
|
|
747
|
+
`),i}async function U8(e,t){let r=await ut(e),o=r.users.find((n)=>n.handle===t);if(!o)throw Error(`Unknown pilot user: ${t}`);return{pilot:r.pilot,user:o}}async function M8(e){let t=await Vhe(io(Whe(),"brains-ops-watchdog-smoke-")),r=io(t,"id_ed25519"),o=io(t,"known_hosts");try{let n=encodeURIComponent(`brain=${e.target.pilot.contentRepoPrefix}${e.target.user.handle}`),i=await e.fetchImpl(`https://api.hetzner.cloud/v1/servers?label_selector=${n}`,{headers:{Authorization:`Bearer ${e.environment.HCLOUD_TOKEN}`}});if(!i.ok)throw Error(`Hetzner server lookup failed with ${i.status}`);let s=Ghe.parse(await i.json());if(s.servers.length!==1)throw Error(`Expected one smoke server, found ${s.servers.length}`);let a=s.servers[0];if(a?.status!=="running")throw Error("Smoke server is not running");await Zl(r,Xhe(e.environment.KAMAL_SSH_PRIVATE_KEY),{mode:384}),await Jhe(r,384);let c=await e.commandRunner("ssh-keyscan",["-T","10","-t","ed25519",a.public_net.ipv4.ip]);if(c.exitCode!==0||!c.stdout.trim())throw Error("Unable to resolve watchdog smoke SSH host key");return await Zl(o,c.stdout,{mode:384}),{temporaryRoot:t,sshKeyPath:r,knownHostsPath:o,serverIp:a.public_net.ipv4.ip,commandRunner:e.commandRunner}}catch(n){throw await aO(t,{recursive:!0,force:!0}),n}}async function sO(e,t,r){return e.commandRunner("ssh",[...q8(e),`root@${e.serverIp}`,"bash","-s","--",t,r],{stdin:cO()})}async function Qhe(e,t,r){return e.commandRunner("scp",[...q8(e),"-r",`root@${e.serverIp}:${t}/.`,r])}function q8(e){return["-i",e.sshKeyPath,"-o","BatchMode=yes","-o","IdentitiesOnly=yes","-o","ConnectTimeout=10","-o","StrictHostKeyChecking=yes","-o",`UserKnownHostsFile=${e.knownHostsPath}`]}async function Yhe(e){try{return await Hhe(e),!0}catch{return!1}}async function zb(e,t,r){await Promise.all([Zl(io(e,`${t}.stdout.log`),r.stdout),Zl(io(e,`${t}.stderr.log`),r.stderr)])}function Xhe(e){return`${e.replace(/\r\n/g,`
|
|
748
748
|
`).replace(/\\n/g,`
|
|
749
749
|
`).trimEnd()}
|
|
750
|
-
`}var B8,
|
|
750
|
+
`}var B8,Ghe;var Db=v(async()=>{fe();z8();Hr();tf();await P8();B8=l.object({HCLOUD_TOKEN:l.string().min(1),KAMAL_SSH_PRIVATE_KEY:l.string().min(1)}),Ghe=l.object({servers:l.array(l.object({status:l.string(),public_net:l.object({ipv4:l.object({ip:l.string().min(1)})})}))})});import{access as w2,chmod as JE,mkdir as sh,readFile as _2,writeFile as x2}from"fs/promises";import{dirname as PW,join as dc}from"path";import{fileURLToPath as zW}from"url";var af={name:"@rizom/ops",version:"0.2.0-alpha.692",description:"Operator CLI for managing private brain fleet registry repos",keywords:["brains","ops","cli","deploy","fleet","operator"],license:"AGPL-3.0-only",author:"Yeehaa <yeehaa@rizom.ai> (https://rizom.ai)",bin:{"brains-ops":"./dist/brains-ops.js"},bugs:"https://github.com/rizom-ai/brains/issues",dependencies:{"@libsql/client":"^0.17.4","age-encryption":"^0.3.0",yaml:"^2.9.0"},devDependencies:{"@brains/contracts":"workspace:*","@brains/deploy-support":"workspace:*","@brains/eslint-config":"workspace:*","@brains/job-queue":"workspace:*","@brains/profile":"workspace:*","@brains/site-composition":"workspace:*","@brains/test-utils":"workspace:*","@brains/typescript-config":"workspace:*","@brains/utils":"workspace:*","@types/bun":"^1.4.0",typescript:"^7.0.2"},engines:{bun:">=1.3.3"},exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.js"},"./deploy":{types:"./dist/deploy.d.ts",import:"./dist/deploy.js",bun:"./dist/deploy.js"}},files:["dist","templates"],homepage:"https://github.com/rizom-ai/brains/tree/main/packages/brains-ops#readme",main:"./dist/index.js",publishConfig:{access:"public"},repository:{type:"git",url:"https://github.com/rizom-ai/brains.git",directory:"packages/brains-ops"},scripts:{build:"bun scripts/build.ts",lint:"eslint . --max-warnings 0","lint:fix":"eslint . --max-warnings 0 --fix",prepublishOnly:"bun scripts/build.ts",test:"bun test --timeout 20000","test:smoke":"bun run build && RUN_SMOKE_TESTS=1 bun test --timeout 60000",typecheck:"tsc --noEmit"},type:"module",types:"./dist/index.d.ts"};Qo();uc();var NW=["pilot.yaml","package.json",".env.schema",".gitignore","cohorts/cohort-1.yaml","users/alice.yaml",".github/actions/varlock-env/action.yml",".github/workflows/build.yml",".github/workflows/deploy.yml",".github/workflows/directory-sync-stress.yml",".github/workflows/health-watchdog-smoke.yml",".github/workflows/offboard.yml",".github/workflows/reconcile.yml",".github/workflows/upgrade.yml","deploy/Dockerfile","deploy/kamal/deploy.yml","deploy/scripts/helpers.ts","deploy/scripts/create-predeploy-backup.ts","deploy/scripts/install-health-watchdog.ts","deploy/scripts/provision-server.ts","deploy/scripts/pull-local-models.ts","deploy/scripts/update-dns.ts","deploy/scripts/write-ssh-key.ts","deploy/scripts/decrypt-user-secrets.ts","deploy/scripts/validate-secrets.ts","deploy/scripts/write-kamal-secrets.ts","deploy/scripts/resolve-user-config.ts","deploy/scripts/resolve-missing-images.ts","deploy/scripts/verify-runtime-image.ts","deploy/scripts/resolve-deploy-handles.ts","deploy/scripts/sync-content-repo.ts",".kamal/hooks/pre-deploy","docs/onboarding-checklist.md","docs/canonical-crossover-record.md","docs/operator-playbook.md","docs/user-onboarding.md","README.md"],VE=new Set([".kamal/hooks/pre-deploy"]),DW=new Set(["cohorts/cohort-1.yaml","users/alice.yaml","docs/canonical-crossover-record.md"]),LW=zW(new URL("../templates/rover-pilot/",import.meta.url));function fo(e){return(t)=>t.includes(e)}function BW(e){return yO.find((t)=>e===`deploy/scripts/${t}`)}function WE(e){return e.replace(/\n {2}secret:\n(?: {4}- .*\n)+\nvolumes:\n/,`
|
|
751
751
|
secret:
|
|
752
752
|
- __DYNAMIC_SECRETS__
|
|
753
753
|
|
|
754
754
|
volumes:
|
|
755
|
-
`)}function
|
|
756
|
-
`),
|
|
757
|
-
`),o));return r(e)===r(t)}var
|
|
755
|
+
`)}function jW(e){return wO(e,"rover",WE)}function ZW(e){if(e.includes("DISCORD_APPLICATION_ID")&&e.includes("ATPROTO_APP_PASSWORD"))return!1;let t=Ea(WE(e)),r=Ea(WE(uf(df({serviceName:"rover"}))));return t===r}var UW=[/\n# Stored with the per-user Discord credentials and injected at deploy time\.\n# @sensitive\nDISCORD_PUBLIC_KEY=\n\n# @sensitive\nDISCORD_APPLICATION_ID=\n/,/\n# AT Protocol publishing\/discovery \(optional, per-user\)\n# Comes from the decrypted users\/<handle>\.secrets\.yaml\.age file when configured\.\n# @sensitive\nATPROTO_APP_PASSWORD=\n/],MW=[/# OpenAI, the provider of the canonical chat and embedding models\n[^]*?\nGOOGLE_GENERATIVE_AI_API_KEY=\n/,/# AI provider\n[^]*?\nAI_API_KEY=\n/];function qW(e,t){let r=(o)=>UW.reduce((n,i)=>n.replace(i,`
|
|
756
|
+
`),MW.reduce((n,i)=>n.replace(i,`__PROVIDER_KEYS__
|
|
757
|
+
`),o));return r(e)===r(t)}var FW=[['writeSecretGitHubEnv("AI_API_KEY", secrets["aiApiKey"]);','writeSecretGitHubEnv("OPENAI_API_KEY", secrets["openaiApiKey"]);'],[`"shared_ai_api_key_secret_name",
|
|
758
758
|
requireFlatValue(pilot, "aiApiKey", "pilot.yaml"),`,`"shared_openai_api_key_secret_name",
|
|
759
|
-
requireFlatValue(pilot, "openaiApiKey", "pilot.yaml"),`]],
|
|
759
|
+
requireFlatValue(pilot, "openaiApiKey", "pilot.yaml"),`]],KW=[`writeSecretGitHubEnv("DISCORD_PUBLIC_KEY", secrets["discordPublicKey"]);
|
|
760
760
|
writeSecretGitHubEnv("DISCORD_APPLICATION_ID", secrets["discordApplicationId"]);
|
|
761
761
|
`,`writeSecretGitHubEnv("ATPROTO_APP_PASSWORD", secrets["atprotoAppPassword"]);
|
|
762
|
-
`];function
|
|
762
|
+
`];function HW(e,t){let r=(o)=>KW.reduce((n,i)=>n.replace(i,""),FW.reduce((n,[i,s])=>n.replace(i,s),o));return r(e)===r(t)}function JW(e){return e.includes('if (eventName !== "push") {')&&e.includes('const currentSha = requireEnv("GITHUB_SHA");')||e.includes("path.match(/^users\\/([^/]+)\\/")&&!e.includes("existsSync(`users/${handle}.yaml`)")}var VW={".env.schema":qW,"deploy/Dockerfile":(e)=>vO(e),"deploy/kamal/deploy.yml":(e)=>jW(e)||ZW(e),"deploy/scripts/decrypt-user-secrets.ts":HW,"deploy/scripts/resolve-deploy-handles.ts":(e)=>JW(e),"deploy/scripts/helpers.ts":fo('"@rizom/ops/deploy"'),"deploy/scripts/resolve-user-config.ts":fo("sitePackagesFor"),"deploy/scripts/resolve-missing-images.ts":fo("runResolveMissingImages"),"deploy/scripts/sync-content-repo.ts":fo("GIT_SYNC_TOKEN"),".github/workflows/build.yml":fo("resolve-missing-images.ts"),".github/workflows/deploy.yml":fo("install-health-watchdog.ts"),".github/workflows/offboard.yml":fo("user:offboard"),".github/workflows/reconcile.yml":fo("brains-ops reconcile"),".github/workflows/upgrade.yml":fo("brains-ops upgrade")};function WW(e,t,r){let o=BW(e);if(o&&bO(o,t,r))return!0;return VW[e]?.(t,r)??!1}async function GE(e){await sh(e,{recursive:!0});let t=dc(e,"views","users.md"),r=!0;try{await w2(t)}catch{r=!1}let o=!0;try{await w2(dc(e,"pilot.yaml"))}catch{o=!1}await sh(dc(e,"users"),{recursive:!0}),await sh(dc(e,"cohorts"),{recursive:!0});let n=NW.filter((i)=>!(o&&DW.has(i))).map(async(i)=>{let s=dc(e,i);await sh(PW(s),{recursive:!0}),await GW(i,s)});if(await Promise.all(n),!r)await po(e)}async function GW(e,t){let r=await QW(e);try{if(await x2(t,r,{flag:"wx"}),VE.has(e))await JE(t,493);return}catch(n){if(!XW(n,"EEXIST"))throw n}let o=await _2(t,"utf8");if(o===r){if(VE.has(e))await JE(t,493);return}if(!WW(e,o,r))return;if(await x2(t,r),VE.has(e))await JE(t,493)}async function QW(e){if(e===".gitignore")return`node_modules/
|
|
763
763
|
.brains-ops/
|
|
764
764
|
users/*.secrets.yaml
|
|
765
|
-
`;if(e==="deploy/Dockerfile")return SO();if(e==="deploy/kamal/deploy.yml")return df({serviceName:"rover"});if(e===".kamal/hooks/pre-deploy")return Zb({deployConfigPath:"deploy/kamal/deploy.yml",brainYamlPath:"${BRAIN_YAML_PATH:-brain.yaml}"});let t=dc(
|
|
766
|
-
`)}function
|
|
767
|
-
`)}function
|
|
768
|
-
`)}async function FD(e,t){try{return await KD(e,t,{flag:"wx"}),!0}catch(r){if(
|
|
769
|
-
`)}function pj(e){let t=new Map;for(let r of e){if(t.has(r.name))throw Error(`Duplicate command name: ${r.name}`);t.set(r.name,r)}return t}function ot(e,t){let r=e[t];return typeof r==="string"?r:void 0}function Ns(e,t){let r=e[t];return typeof r==="boolean"?r:void 0}fy();Qo();import{writeFile as
|
|
770
|
-
`};if(i.result.expires_on)a.expiresOn=i.result.expires_on;return a}async function rM(e,t,r){let o=await e(`${X6}/zones/${r}/settings/ssl`,{method:"PATCH",headers:tM(t),body:JSON.stringify({value:"strict"}),signal:AbortSignal.timeout(eM)});await tl(o,
|
|
771
|
-
`)}function
|
|
772
|
-
`)}function aM(e){return`"${e.replace(/"/g,"\\\"").replace(/\n/g,"\\n")}"`}function
|
|
773
|
-
`,"utf-8");if(h.length===0)throw Error(`Unable to derive a public key from ${d}`);let b=await
|
|
765
|
+
`;if(e==="deploy/Dockerfile")return SO();if(e==="deploy/kamal/deploy.yml")return df({serviceName:"rover"});if(e===".kamal/hooks/pre-deploy")return Zb({deployConfigPath:"deploy/kamal/deploy.yml",brainYamlPath:"${BRAIN_YAML_PATH:-brain.yaml}"});let t=dc(LW,e),r=await _2(t,"utf8");return YW(r)}function YW(e){return e.replaceAll("__BRAINS_OPS_VERSION__",af.version).replaceAll("__BUN_VERSION__",Bun.version)}function XW(e,t){return typeof e==="object"&&e!==null&&"code"in e&&e.code===t}Hr();uh();fk();uc();Fu();async function bk(e,t,r,o={}){let{registry:n,user:i}=await xh(e,t);await mc(e,n,[i],r,o)}Zu();vh();Cn();Bn();import{access as EQ,mkdir as qD,readFile as kQ,writeFile as KD}from"fs/promises";import{basename as IQ,join as hc}from"path";async function Sk(e,t,r){let o=mr.parse(t),n=mr.parse(r.cohort),i=hc(e,"users"),s=hc(e,"cohorts"),a=hc(i,`${o}.yaml`),c=hc(i,`${o}.secrets.yaml`),u=hc(i,`${o}.secrets.yaml.age`),d=hc(s,`${n}.yaml`);await Promise.all([qD(i,{recursive:!0}),qD(s,{recursive:!0})]);let p=r.discord===!0||Boolean(r.anchorId),m=await FD(a,RQ(o,p,r.anchorId)),b=await CQ(u)?!1:await FD(c,$Q(o,p)),{addedToCohort:y}=await AQ(d,o);return{handle:o,cohort:n,userPath:a,secretsTemplatePath:c,cohortPath:d,createdUser:m,createdSecretsTemplate:b,addedToCohort:y}}async function AQ(e,t){let r=await TQ(e);if(r.members.includes(t))return{addedToCohort:!1};let o={...r,members:[...r.members,t].sort()};return await KD(e,OQ(o)),{addedToCohort:!0}}async function TQ(e){try{let t=await kQ(e,"utf8"),r=lr(t,Kr);if(!r.ok)throw Error(`${IQ(e)}: ${r.error}`);return r.data}catch(t){if(ah(t))return{members:[]};throw t}}function RQ(e,t,r){return[`handle: ${e}`,"anchorProfile:",` name: ${NQ(e)}`,"discord:",` enabled: ${String(t)}`,...t&&r?[` anchorUserId: ${JSON.stringify(r)}`]:[],""].join(`
|
|
766
|
+
`)}function $Q(e,t){return["# local per-user secret staging file",`# fill values, run \`bunx brains-ops secrets:encrypt . ${e}\`, then the plaintext file will be removed`,...t?["discordBotToken: "]:[],"atprotoAppPassword: ","# For custom-domain sites, paste PEMs with literal \\n escapes.","certificatePem: ","privateKeyPem: ",""].join(`
|
|
767
|
+
`)}function OQ(e){return["members:",...e.members.map((t)=>` - ${t}`),...e.brainVersionOverride?[`brainVersionOverride: ${e.brainVersionOverride}`]:[],...e.bundlesOverride?["bundlesOverride:",...e.bundlesOverride.map((t)=>` - ${t}`)]:[],...e.addOverride?["addOverride:",...e.addOverride.map((t)=>` - ${t}`)]:[],...e.removeOverride?["removeOverride:",...e.removeOverride.map((t)=>` - ${t}`)]:[],...e.openaiApiKeyOverride?[`openaiApiKeyOverride: ${e.openaiApiKeyOverride}`]:[],...e.gitSyncTokenOverride?[`gitSyncTokenOverride: ${e.gitSyncTokenOverride}`]:[],""].join(`
|
|
768
|
+
`)}async function FD(e,t){try{return await KD(e,t,{flag:"wx"}),!0}catch(r){if(PQ(r))return!1;throw r}}async function CQ(e){try{return await EQ(e),!0}catch{return!1}}function PQ(e){return zQ(e,"EEXIST")}function zQ(e,t){return typeof e==="object"&&e!==null&&"code"in e&&e.code===t}function NQ(e){return e.split("-").filter((t)=>t.length>0).map(AD).join(" ")}zI();Fu();async function NI(e,t,r,o={}){let{registry:n,users:i}=await UD(e,t);await mc(e,n,i,r,o)}Fu();async function gd(e,t,r={}){let{registry:o,users:n}=await MD(e);await mc(e,o,n,t,r)}import{parseArgs as Mse}from"util";function nt(e){return e}class sj extends Error{constructor(e){super(e);this.name="CliUsageError"}}function qse(e,t){let r={...t};for(let o of e)for(let[n,i]of Object.entries(o.flags??{})){let s=r[n];if(s===void 0){r[n]=i;continue}if(s.type!==i.type||s.short!==i.short||s.default!==i.default)throw Error(`Conflicting definitions for flag --${n}: commands must agree on type, short, and default`)}return r}function Fse(e){let t={};for(let[r,o]of Object.entries(e))t[r]={type:o.type,...o.short!==void 0?{short:o.short}:{},...o.default!==void 0?{default:o.default}:{}};return t}function Kse(e){if(!(e instanceof Error)||!("code"in e))return!1;return e.code==="ERR_PARSE_ARGS_UNKNOWN_OPTION"||e.code==="ERR_PARSE_ARGS_INVALID_OPTION_VALUE"}function aj(e,t){let r=qse(t.commands,t.globalFlags??{}),o,n;try{({values:o,positionals:n}=Mse({args:e,options:Fse(r),allowPositionals:!0,strict:t.strict??!0}))}catch(s){if(Kse(s))throw new sj(s.message.split(". ")[0]??s.message);throw s}if("help"in r&&o.help===!0)return{command:"help",args:[],flags:{help:!0}};if("version"in r&&o.version===!0)return{command:"version",args:[],flags:{version:!0}};let i={};for(let[s,a]of Object.entries(r)){let c=o[s];if(typeof c==="string"&&a.type==="string")i[s]=c;else if(typeof c==="boolean"&&a.type==="boolean")i[s]=c}return{command:n[0]??"help",args:n.slice(1),flags:i}}function cj(e){let t=e.reduce((r,o)=>Math.max(r,o.label.length),0);return e.map((r)=>` ${r.label.padEnd(t)} ${r.description}`)}function Hse(e){return cj(e.map((t)=>({label:t.usage?`${t.name} ${t.usage}`:t.name,description:t.description})))}function Jse(e,t){let r=t.type==="string"?` ${t.placeholder??"<value>"}`:"",o=t.short!==void 0?`, -${t.short}`:"";return`--${e}${r}${o}`}function lj(e){return cj(Object.entries(e).map(([t,r])=>({label:Jse(t,r),description:r.description})))}function uj(e,t){return`Usage: ${e} ${t.name}${t.usage?` ${t.usage}`:""}`}function Vse(e){return JSON.stringify(Object.entries(e).map(([t,r])=>[t,r.type,r.short??"",r.description,r.placeholder??"",r.default??""]).sort((t,r)=>String(t[0]).localeCompare(String(r[0]))))}function Wse(e){let t=[],r=new Map;for(let n of e){let i=n.flags??{};if(Object.keys(i).length===0)continue;let s=Vse(i),a=r.get(s);if(a){a.names.push(n.name);continue}let c={names:[n.name],flags:i};r.set(s,c),t.push(c)}let o=[];for(let n of t)o.push("",`${n.names.join(" / ")} options:`),o.push(...lj(n.flags));return o}function dj(e){let t=[e.intro,"",`Usage: ${e.cliName} ${e.usage??"<command> [args]"}`,"","Commands:",...Hse(e.commands)];if(e.globalFlags&&Object.keys(e.globalFlags).length>0)t.push("","Options:",...lj(e.globalFlags));return t.push(...Wse(e.commands)),t.join(`
|
|
769
|
+
`)}function pj(e){let t=new Map;for(let r of e){if(t.has(r.name))throw Error(`Duplicate command name: ${r.name}`);t.set(r.name,r)}return t}function ot(e,t){let r=e[t];return typeof r==="string"?r:void 0}function Ns(e,t){let r=e[t];return typeof r==="boolean"?r:void 0}fy();Qo();import{writeFile as Xle}from"fs/promises";import{join as sM}from"path";import{createSign as Rle,generateKeyPairSync as $le}from"crypto";import{mkdir as Ole,writeFile as W6}from"fs/promises";import{join as G6}from"path";async function Ale(e){let t=await e.text();if(!t.trim())return;try{return JSON.parse(t)}catch{return t}}async function tl(e,t,r){let o=await Ale(e),n=t.safeParse(o);if(!e.ok||!n.success){let i=r.formatError??Tle;throw Error(`${r.label}${i(e,o)}`)}return n.data}function Tle(e,t){let r=t===void 0?"":`: ${typeof t==="string"?t:JSON.stringify(t)}`;return` (${e.status} ${e.statusText}${r})`}fe();var Cle="2.5.4.3",Ple="1.2.840.113549.1.1.11",X6="https://api.cloudflare.com/client/v4",zle="origin-rsa",Nle=5475,eM=15000;function tM(e){return{Authorization:`Bearer ${e}`,"Content-Type":"application/json"}}var Q6=l.looseObject({message:l.string().optional()}),Dle=l.looseObject({errors:l.array(Q6).optional(),messages:l.array(Q6).optional()}),Lle=l.looseObject({certificate:l.string().min(1),expires_on:l.string().optional()}),Ble=l.looseObject({success:l.literal(!0),result:Lle}),jle=l.looseObject({success:l.literal(!0)});function Zle(){let{privateKey:e,publicKey:t}=$le("rsa",{modulusLength:2048,privateKeyEncoding:{type:"pkcs8",format:"pem"},publicKeyEncoding:{type:"spki",format:"der"}});return{privateKeyPem:e,publicKeyDer:Buffer.from(t)}}function Ule(e,t){let r=op(Vle(op(Y6(Cle),Kle(e)))),o=op(Fle(0),r,Buffer.from(t.publicKeyDer),Wle(0,Buffer.alloc(0))),n=Rle("sha256").update(o).sign(t.privateKeyPem),i=op(o,op(Y6(Ple),Jle()),Hle(n));return{csrPem:qle("CERTIFICATE REQUEST",i),certificationRequestInfoDer:o,signature:n}}async function Mle(e,t,r,o){let n=await e(`${X6}/certificates`,{method:"POST",headers:tM(t),body:JSON.stringify({hostnames:[o,`*.${o}`],requested_validity:Nle,request_type:zle,csr:r}),signal:AbortSignal.timeout(eM)}),i=await tl(n,Ble,{label:"Cloudflare Origin CA request failed",formatError:nM}),a={certificatePem:`${i.result.certificate.trim()}
|
|
770
|
+
`};if(i.result.expires_on)a.expiresOn=i.result.expires_on;return a}async function rM(e,t,r){let o=await e(`${X6}/zones/${r}/settings/ssl`,{method:"PATCH",headers:tM(t),body:JSON.stringify({value:"strict"}),signal:AbortSignal.timeout(eM)});await tl(o,jle,{label:"Cloudflare zone SSL update failed",formatError:nM})}function qle(e,t){let o=t.toString("base64").match(/.{1,64}/g)??[];return[`-----BEGIN ${e}-----`,...o,`-----END ${e}-----`,""].join(`
|
|
771
|
+
`)}function Fle(e){if(e!==0)throw Error("Only zero-valued INTEGER encoding is currently supported");return Buffer.from([2,1,0])}function Y6(e){let t=e.split(".").map((s)=>Number(s));if(t.length<2||t.some((s)=>Number.isNaN(s)))throw Error(`Invalid OID: ${e}`);let r=t[0],o=t[1];if(r===void 0||o===void 0)throw Error(`Invalid OID: ${e}`);let i=[r*40+o];for(let s of t.slice(2)){let a=Qle(s);i.push(...a)}return rl(6,Buffer.from(i))}function Kle(e){return rl(12,Buffer.from(e,"utf8"))}function Hle(e){return rl(3,Buffer.concat([Buffer.from([0]),e]))}function Jle(){return Buffer.from([5,0])}function op(...e){return rl(48,Buffer.concat(e))}function Vle(...e){return rl(49,Buffer.concat(e))}function Wle(e,t){return rl(160+e,t)}function rl(e,t){return Buffer.concat([Buffer.from([e]),Gle(t.length),t])}function Gle(e){if(e<128)return Buffer.from([e]);let t=[],r=e;while(r>0)t.unshift(r&255),r>>=8;return Buffer.from([128|t.length,...t])}function Qle(e){if(!Number.isInteger(e)||e<0)throw Error(`Invalid OID component: ${e}`);if(e===0)return[0];let t=[],r=e;while(r>0)t.unshift(r&127),r>>=7;for(let o=0;o<t.length-1;o+=1)t[o]=(t[o]??0)|128;return t}function nM(e,t){let r=Yle(t),o=r.length>0?`: ${r.join("; ")}`:"";return` (${e.status} ${e.statusText}${o})`}function Yle(e){let t=Dle.safeParse(e);if(!t.success)return[];return[...t.data.errors??[],...t.data.messages??[]].map((r)=>r.message).filter((r)=>typeof r==="string"&&r.length>0)}async function oM(e,t,r){let o=Zle(),{csrPem:n}=Ule(r,o),i=await Mle(e,t,n,r);return{certificatePem:i.certificatePem,privateKeyPem:o.privateKeyPem,...i.expiresOn!==void 0&&{expiresOn:i.expiresOn}}}async function iM(e,t){let r=G6(e,"origin.pem"),o=G6(e,"origin.key");return await Ole(e,{recursive:!0}),await Promise.all([W6(r,t.certificatePem,"utf-8"),W6(o,t.privateKeyPem,{encoding:"utf-8",mode:384})]),{certificatePath:r,privateKeyPath:o}}Hr();np();jn();async function $T(e,t={}){try{return await cM(e,t),{success:!0}}catch(r){return{success:!1,message:Ve(r,"Certificate bootstrap failed")}}}async function cM(e,t={}){let r=await ut(e),o=tue(r,t.handle),n=o.domain,i=t.env??process.env,s=Or(e),a=t.cfApiToken??Bt("CF_API_TOKEN",i,s),c=t.cfZoneId??o.cloudflareZoneId??Bt("CF_ZONE_ID",i,s);if(!a)throw Error("Missing CF_API_TOKEN");if(!c)throw Error("Missing CF_ZONE_ID");let u=t.fetchImpl??fetch,d=t.logger??console.log,p=await oM(u,a,n),m=sM(e,".brains-ops","certs",o.id),{certificatePath:h,privateKeyPath:b}=await iM(m,p),y=sM(m,"secrets.yaml");await Xle(y,eue(p.certificatePem,p.privateKeyPem),"utf-8"),await rM(u,a,c);let S=Xc(t.pushTo);if(S)await qi([["CERTIFICATE_PEM",p.certificatePem],["PRIVATE_KEY_PEM",p.privateKeyPem]],{logger:d,runCommand:t.runCommand??jt});if(d(`Issued ${o.id} Origin CA cert for ${n} and *.${n}`),d(`Wrote ${h}`),d(`Wrote ${b}`),d(`Wrote ${y}`),p.expiresOn)d(`Expires on ${p.expiresOn}`);if(d("Cloudflare zone SSL mode set to Full (strict)"),S)d(`Pushed CERTIFICATE_PEM and PRIVATE_KEY_PEM to ${S}`);return{domain:n,certificatePath:h,privateKeyPath:b,certificatePem:p.certificatePem,secretsSnippetPath:y}}function eue(e,t){return[`certificatePem: ${aM(e)}`,`privateKeyPem: ${aM(t)}`,""].join(`
|
|
772
|
+
`)}function aM(e){return`"${e.replace(/"/g,"\\\"").replace(/\n/g,"\\n")}"`}function tue(e,t){if(!t)return{id:"shared",domain:rue(e.pilot.domainSuffix)};let r=e.users.find((o)=>o.handle===t);if(!r)throw Error(`Unknown user handle: ${t}`);return{id:t,domain:r.domain,...r.cloudflareZoneId?{cloudflareZoneId:r.cloudflareZoneId}:{}}}function rue(e){let t=e.trim().replace(/^\./,"").replace(/\.$/,"");if(!t||t.includes("*"))throw Error(`Invalid pilot domainSuffix: ${e}`);return t}Hr();uh();tk();Bn();import{lookup as nue}from"dns/promises";function uM(e={}){let t=e.fetchImpl??fetch,r=e.lookupHost??nue;return async function(n){let i=await oue(n.domain,r),[s,a,c]=await Promise.all([lM(n.domain,"/health/ready",t),lM(n.domain,"/health/operate",t),iue(n.domain,t)]);return{dnsStatus:i,serverStatus:s,deployStatus:a,mcpStatus:c}}}async function oue(e,t){try{return(await t(e)).address?"ready":"failed"}catch{return"failed"}}async function lM(e,t,r){try{return(await dM(r,`https://${e}${t}`,{method:"GET"})).ok?"ready":"failed"}catch{return"failed"}}async function iue(e,t){try{let r=await dM(t,`https://${e}/mcp`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",id:1,method:"initialize",params:{}})});return r.status===401||r.ok?"ready":"failed"}catch{return"failed"}}async function dM(e,t,r){let o=new AbortController,n=setTimeout(()=>o.abort(),5000);try{return await e(t,{...r,signal:o.signal})}finally{clearTimeout(n)}}import{createHash as sue}from"crypto";import{cp as aue,lstat as cue,mkdtemp as lue,readFile as uue,readdir as due,readlink as pue,rm as fue}from"fs/promises";import{tmpdir as mue}from"os";import{basename as hue,join as ip,relative as gue,resolve as yue,sep as bue}from"path";var Sue=new Set([".git",".operator",".brains-ops",".turbo","dist","node_modules"]);async function mM(e){let t=yue(e),r=await lue(ip(mue(),"brains-ops-reconcile-")),o=ip(r,"repo");try{await aue(t,o,{recursive:!0,errorOnExist:!0,force:!1,filter:(a)=>vue(t,a)});let n=await OT(o);await pM(o);let i=await OT(o);await pM(o);let s=await OT(o);return{firstPassChangedFiles:fM(n,i),secondPassChangedFiles:fM(i,s)}}finally{await fue(r,{recursive:!0,force:!0})}}function vue(e,t){let r=gue(e,t);if(r.length===0)return!0;if(r.split(bue).some((n)=>Sue.has(n)))return!1;if(r===".env"||r===".env.local")return!1;return!hue(r).endsWith(".secrets.yaml")}async function pM(e){await gd(e,void 0,{env:{},contentRepoRemoteResolver:()=>{return},fetchImpl:async()=>{throw Error("Dry-run reconcile attempted external HTTP access")},runCommand:async()=>{throw Error("Dry-run reconcile attempted a subprocess")}})}async function OT(e){let t=new Map;return await hM(e,"",t),t}async function hM(e,t,r){let o=ip(e,t),n=await due(o,{withFileTypes:!0});n.sort((i,s)=>i.name.localeCompare(s.name));for(let i of n){let s=ip(t,i.name),a=ip(e,s);if(i.isDirectory()){await hM(e,s,r);continue}let u=(await cue(a)).isSymbolicLink()?`symlink:${await pue(a)}`:await uue(a);r.set(s,sue("sha256").update(u).digest("hex"))}}function fM(e,t){return[...new Set([...e.keys(),...t.keys()])].filter((o)=>e.get(o)!==t.get(o)).sort()}uc();gy();Qo();np();jn();import{readFileSync as $ue}from"fs";async function DT(e,t={}){let r=t.env??process.env,o=t.logger??console.log,n=Or(e),i=Mb(`${e}/.env.schema`),s=Cue(i),a=[],c=[],u=new Map;for(let p of s){u.set(p.key,p.required);let m=Pue(p.key,r,n,e);if(m===void 0||m.trim().length===0){c.push(p.key);continue}a.push([p.key,m])}if(a.length===0)throw Error("No pushable local secrets found for this pilot repo");let d=(p)=>u.get(p)??!1;if(t.dryRun)return o(`Dry run: would push ${a.length} secrets to GitHub Secrets.`),o(`Secrets: ${a.map(([p])=>p).join(", ")}`),IT(o,c,d),{pushedKeys:a.map(([p])=>p),skippedKeys:c,dryRun:!0};return await qi(a,{logger:o,runCommand:t.runCommand??jt}),IT(o,c,d),{pushedKeys:a.map(([p])=>p),skippedKeys:c}}var Oue=new Set(["DISCORD_BOT_TOKEN","DISCORD_PUBLIC_KEY","DISCORD_APPLICATION_ID"]);function Cue(e){return e.filter((t)=>!Oue.has(t.key)).map((t)=>({key:t.key,required:t.required}))}function Pue(e,t,r,o){let n=Bt(`${e}_FILE`,t,r);if(n&&n.trim().length>0)return $ue(Go(n,o),"utf8");let i=Bt(e,t,r);if(i===void 0||i.trim().length===0)return;return i}fe();import{execFileSync as EM}from"child_process";import{chmodSync as zue,existsSync as Nue,mkdirSync as Due,readFileSync as kM,writeFileSync as Lue}from"fs";import{dirname as Bue,join as jue}from"path";import{homedir as Zue}from"os";Fb();np();jn();var IM=l.object({id:l.number(),name:l.string(),public_key:l.string()}),Uue=l.object({ssh_keys:l.array(IM)}),Mue={createEd25519KeyPair(e,t){EM("ssh-keygen",["-t","ed25519","-f",e,"-C",t,"-N",""],{stdio:"ignore"})},derivePublicKey(e){return EM("ssh-keygen",["-y","-f",e],{encoding:"utf-8",stdio:["ignore","pipe","inherit"]}).trim()}};async function yy(e,t={}){try{let r=await LT(e,t);return{success:!0,message:r.createdLocalKey?`SSH deploy key ready at ${r.privateKeyPath}`:`SSH deploy key already ready at ${r.privateKeyPath}`}}catch(r){return{success:!1,message:Ve(r,"SSH key bootstrap failed")}}}async function LT(e,t={}){let r=t.env??process.env,o=Or(e),n=t.logger??console.log,i=t.fetchImpl??fetch,s=t.sshKeygen??Mue,a=Bt("HCLOUD_TOKEN",r,o);if(!a)throw Error("Missing HCLOUD_TOKEN");let c=Bt("HCLOUD_SSH_KEY_NAME",r,o);if(!c)throw Error("Missing HCLOUD_SSH_KEY_NAME");let u=Bt("KAMAL_SSH_PRIVATE_KEY_FILE",r,o),d=u?Go(u,e):jue(Zue(),".ssh",`${Fue(c)}_ed25519`),p=`${d}.pub`,m=!1;if(!Nue(d))Due(Bue(d),{recursive:!0,mode:448}),s.createEd25519KeyPair(d,c),m=!0;zue(d,384);let h;if(m)h=kM(p,"utf-8").trim();else h=s.derivePublicKey(d),Lue(p,`${h}
|
|
773
|
+
`,"utf-8");if(h.length===0)throw Error(`Unable to derive a public key from ${d}`);let b=await que({fetchImpl:i,hcloudToken:a,publicKey:h,sshKeyName:c}),y=Xc(t.pushTo);if(y)await qi([["KAMAL_SSH_PRIVATE_KEY",kM(d,"utf-8")]],{logger:n,runCommand:t.runCommand??jt});if(n(m?`Created ${d}`:`Reusing ${d}`),n(b?`Registered Hetzner SSH key ${c}`:`Hetzner SSH key ${c} already exists`),y)n(`Pushed KAMAL_SSH_PRIVATE_KEY to ${y}`);return{createdHetznerKey:b,createdLocalKey:m,privateKeyPath:d,publicKeyPath:p,sshKeyName:c}}async function que(e){let t=new URL("https://api.hetzner.cloud/v1/ssh_keys");t.searchParams.set("name",e.sshKeyName);let r=await e.fetchImpl(t.toString(),{headers:{Authorization:`Bearer ${e.hcloudToken}`,"Content-Type":"application/json"}}),{ssh_keys:o}=await tl(r,Uue,{label:"Hetzner SSH key lookup failed"}),[n]=o;if(n){if(n.public_key.trim()!==e.publicKey)throw Error(`Existing Hetzner SSH key ${e.sshKeyName} does not match the local public key`);return!1}let i=await e.fetchImpl("https://api.hetzner.cloud/v1/ssh_keys",{method:"POST",headers:{Authorization:`Bearer ${e.hcloudToken}`,"Content-Type":"application/json"},body:JSON.stringify({name:e.sshKeyName,public_key:e.publicKey})});return await tl(i,l.object({ssh_key:IM}),{label:"Hetzner SSH key create failed"}),!0}function Fue(e){return e.replace(/[^A-Za-z0-9._-]+/g,"_")}fe();Hr();var Kue=l.looseObject({status:l.string(),operationalStatus:l.string(),checks:l.array(l.looseObject({name:l.string(),status:l.string(),message:l.string().optional()})).default([]),app:l.looseObject({daemons:l.array(l.looseObject({name:l.string().optional(),status:l.string().optional(),health:l.looseObject({status:l.string().optional(),message:l.string().optional()}).optional()})).default([])}).default({daemons:[]})});async function BT(e,t,r={}){let o=r.fetchImpl??fetch,i=(await ut(e)).users.find((m)=>m.handle===t);if(!i)throw Error(`Unknown pilot user: ${t}`);let s=`https://${i.domain}`,a=[],c=[],u=l.number().int().positive().max(30).parse(r.operationalRetryAttempts??6),d=l.number().int().nonnegative().max(60000).parse(r.operationalRetryDelayMs??1e4),p=r.sleep??((m)=>new Promise((h)=>setTimeout(h,m)));if(await by("health",()=>Hue(o,s,u,d,p),a,c),await by("mcp-auth-gate",()=>Wue(o,s),a,c),i.bundles.includes("site"))await by("site",()=>AM(o,`${s}/`,"site"),a,c),await by("studio",()=>AM(o,`${s}/studio`,"studio"),a,c),r.logger?.("WARN Manual check still required: passkey setup/handoff completed from the setup email.");return{handle:i.handle,bundles:i.bundles,domain:i.domain,contentRepo:i.contentRepo,checks:a,failedChecks:c}}async function by(e,t,r,o){try{await t(),r.push(e)}catch(n){o.push({name:e,message:Ve(n)})}}async function Hue(e,t,r,o,n){let i;for(let s=1;s<=r;s++)try{await Jue(e,t);return}catch(a){if(i=a,s<r)await n(o)}throw i}async function Jue(e,t){let o=await jT(e,`${t}/health/operate`,{method:"GET"}),n=await o.json().catch(()=>null),i=Kue.safeParse(n);if(!o.ok){let a=i.success?i.data.checks.filter((c)=>c.status!=="healthy").slice(0,10).map((c)=>`${c.name}: ${Vue(c.message??c.status)}`):[];throw Error(`/health/operate returned ${o.status}, expected 200${a.length>0?` (${a.join("; ")})`:""}`)}if(!i.success)throw Error(`/health/operate response did not match expected shape: ${i.error.message}`);let s=i.data;if(s.status!=="ready")throw Error(`/health/operate status is ${s.status}, expected ready`);if(s.operationalStatus!=="operational")throw Error(`/health/operate operationalStatus is ${s.operationalStatus}, expected operational`);for(let a of s.app.daemons){let c=a.status??"unknown",u=a.health?.status;if(c==="error"||u==="unhealthy")throw Error(`daemon ${a.name??"unknown"} is unhealthy (${c}/${u??"unknown"})`)}}function Vue(e){let t=e.replaceAll(/\s+/g," ").trim();return t.length<=300?t:`${t.slice(0,297)}...`}async function Wue(e,t){let r=await jT(e,`${t}/mcp`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",id:1,method:"initialize"})});if(r.status<400||r.status>=500)throw Error(`unauthenticated POST /mcp returned ${r.status}, expected a 4xx auth failure`)}async function AM(e,t,r){let o=await jT(e,t,{method:"GET"});if(o.status>=400)throw Error(`${r} ${t} returned ${o.status}, expected < 400`)}async function jT(e,t,r){let o=new AbortController,n=setTimeout(()=>o.abort(),20000);try{return await e(t,{...r,redirect:"follow",signal:o.signal})}finally{clearTimeout(n)}}var K8="brains-ops",uO={type:"string",placeholder:"<target>",description:"Push target (`gh` or `github`)"},Lb={type:"boolean",description:"Show what would happen without writing anything"};function ht(e){return{success:!1,message:uj(K8,e)}}var H8=nt({name:"init",usage:"<repo>",description:"Create a pilot repo skeleton",run:async({args:e})=>{let t=e[0];if(!t)return ht(H8);return await GE(t),{success:!0,message:`Initialized ${t}`}}}),J8=nt({name:"upgrade",usage:"<repo>",description:"Bump @rizom/ops and refresh the generated scaffold",flags:{to:{type:"string",placeholder:"<version>",description:"Explicit @rizom/ops version (`latest` by default)"}},run:async({args:e,flags:t})=>{let r=e[0];if(!r)return ht(J8);let o=ot(t,"to"),{upgradePilotRepo:n}=await Promise.resolve().then(() => ($M(),RM)),{from:i,to:s}=await n(r,{...o&&o!=="latest"?{version:o}:{}});return{success:!0,message:i===s?`Already at @rizom/ops@${s}; scaffold refreshed`:`Upgraded @rizom/ops ${i} -> ${s}; scaffold refreshed`}}}),V8=nt({name:"images:lock",usage:"<repo> [--brain-version <version>] [--site-packages <pins>]",description:"Create immutable runtime dependency locks for operator review (no build or deploy)",flags:{"brain-version":{type:"string",placeholder:"<version>",description:"Lock one exact Brain version instead of the declared fleet"},"site-packages":{type:"string",placeholder:"<pins>",description:"Exact site/theme pins for an explicit Brain version"}},run:async({args:e,flags:t},r)=>{let o=e[0],n=ot(t,"brain-version"),i=ot(t,"site-packages");if(!o||i!==void 0&&!n)return ht(V8);if(n!==void 0)$t.parse(n);let{users:s}=await ut(o),a=await lh({users:s,brainVersionInput:n,sitePackagesInput:i,imageExists:async()=>!1,verifyImage:async()=>{throw Error("Lock generation must not inspect images")}}),c=[];for(let u of a){let d=await D2(o,u,r.imageLockRunCommand);c.push(`${d}: ${u.tag}`)}return{success:!0,message:["Review and commit runtime dependency locks before building:",...c].join(`
|
|
774
774
|
`)}}}),W8=nt({name:"crossover:stage",usage:"<source-repo> <output-dir> <bundle-review.yaml> [site-pins.yaml]",description:"Stage a reviewed capability-bundle crossover copy",run:async({args:e})=>{let t=e[0],r=e[1],o=e[2],n=e[3];if(!t||!r||!o)return ht(W8);let{loadCapabilityBundleReview:i,loadReviewedSitePins:s,stageLegacyCrossover:a}=await Promise.resolve().then(() => (rq(),tq)),c=await i(o),u=n?await s(n):void 0,d=await a(t,r,{bundleReview:c,sitePins:u});return{success:!0,message:`Staged ${d.changedFiles.length} reviewed crossover files in ${d.outputDir}`}}}),G8=nt({name:"migrate:provider-keys",usage:"<repo>",description:"Move a pilot repo from the legacy AI_API_KEY to the OpenAI key its brains read",run:async({args:e})=>{let t=e[0];if(!t)return ht(G8);let{migratePilotRepoProviderKeys:r}=await Promise.resolve().then(() => (xy(),zM)),o=await r(t,process.env);return{success:!0,message:o.length===0?`${t} already uses the OpenAI key`:`Migrated ${o.length} files: ${o.join(", ")}. Then run brains-ops init ${t} to refresh the deploy scripts.`}}}),Q8=nt({name:"render",usage:"<repo>",description:"Render the observed users table to views/users.md",run:async({args:e},t)=>{let r=e[0];if(!r)return ht(Q8);let o=t.resolveStatus??uM({...t.fetchImpl?{fetchImpl:t.fetchImpl}:{},...t.lookupHost?{lookupHost:t.lookupHost}:{}});return await po(r,{resolveStatus:o}),{success:!0,message:`Rendered ${r}/views/users.md`}}}),Y8=nt({name:"user:add",usage:"<repo> <handle> --cohort <cohort> [--discord] [--anchor-id <id>]",description:"Add a user to a cohort",flags:{cohort:{type:"string",placeholder:"<cohort>",description:"Cohort the user joins"},discord:{type:"boolean",description:"Enable Discord for the user (browser chat is the default)"},"anchor-id":{type:"string",placeholder:"<id>",description:"Discord anchor user id stored on the user record (implies --discord)"}},run:async({args:e,flags:t})=>{let r=e[0],o=e[1],n=ot(t,"cohort");if(!r||!o||!n)return ht(Y8);let i=ot(t,"anchor-id");return await Sk(r,o,{cohort:n,...Ns(t,"discord")?{discord:!0}:{},...i?{anchorId:i}:{}}),{success:!0,message:`Added ${o} to ${n}`}}}),X8=nt({name:"user:offboard",usage:"<repo> <handle>... [--apply --confirm sunset:<sorted-comma-separated-handles>]",description:"Archive content and remove pilot users, DNS, and servers",flags:{apply:{type:"boolean",description:"Apply the plan (defaults to a read-only dry run)"},confirm:{type:"string",placeholder:"<confirmation>",description:"Exact batch confirmation required with --apply"}},run:async({args:e,flags:t},r)=>{let o=e[0],n=e.slice(1);if(!o||n.length===0)return ht(X8);let i=Ns(t,"apply")??!1,s=ot(t,"confirm"),{offboardPilotUsers:a}=await Promise.resolve().then(() => (zI(),ij)),c=await a(o,{handles:n,dryRun:!i,...s?{confirmation:s}:{},...r.env?{env:r.env}:{},...r.fetchImpl?{fetchImpl:r.fetchImpl}:{},...r.logger?{logger:r.logger}:{},...r.pilotOffboardDriver?{driver:r.pilotOffboardDriver}:{}});return{success:!0,message:c.dryRun?`Dry run: ${c.handles.length} pilot user(s); apply with --apply --confirm ${c.confirmation}`:`Offboarded ${c.handles.length} pilot user(s)`}}}),eK=nt({name:"onboard",usage:"<repo> <handle>",description:"Generate a user's brain.yaml and .env",run:async({args:e},t)=>{let r=e[0],o=e[1];if(!r||!o)return ht(eK);return await bk(r,o,t.runner,{...t.env?{env:t.env}:{}}),{success:!0,message:`Onboarded ${o}`}}}),tK=nt({name:"age-key:bootstrap",usage:"<repo>",description:"Generate the pilot age key and optional GitHub secret",flags:{"push-to":uO},run:async({args:e,flags:t},r)=>{let o=e[0];if(!o)return ht(tK);let n=ot(t,"push-to");return RT(o,{...r.logger?{logger:r.logger}:{},...n?{pushTo:n}:{},...r.bootstrapRunCommand?{runCommand:r.bootstrapRunCommand}:{}})}}),rK=nt({name:"ssh-key:bootstrap",usage:"<repo>",description:"Bootstrap a deploy SSH key and optional GitHub secret",flags:{"push-to":uO},run:async({args:e,flags:t},r)=>{let o=e[0];if(!o)return ht(rK);let n=ot(t,"push-to");return yy(o,{...r.env?{env:r.env}:{},...r.fetchImpl?{fetchImpl:r.fetchImpl}:{},...r.logger?{logger:r.logger}:{},...n?{pushTo:n}:{},...r.bootstrapRunCommand?{runCommand:r.bootstrapRunCommand}:{},...r.sshKeygen?{sshKeygen:r.sshKeygen}:{}})}}),nK=nt({name:"cert:bootstrap",usage:"<repo>",description:"Issue Cloudflare Origin CA certificates for pilot users",flags:{handle:{type:"string",placeholder:"<handle>",description:"Only issue the certificate for this user handle"},"push-to":uO},run:async({args:e,flags:t},r)=>{let o=e[0];if(!o)return ht(nK);let n=ot(t,"handle"),i=ot(t,"push-to");return $T(o,{...r.env?{env:r.env}:{},...r.fetchImpl?{fetchImpl:r.fetchImpl}:{},...r.logger?{logger:r.logger}:{},...n?{handle:n}:{},...i?{pushTo:i}:{},...r.bootstrapRunCommand?{runCommand:r.bootstrapRunCommand}:{}})}}),oK=nt({name:"secrets:push",usage:"<repo>",description:"Push env-backed local secrets to GitHub Secrets",flags:{"dry-run":Lb},run:async({args:e,flags:t},r)=>{let o=e[0];if(!o)return ht(oK);let n=await DT(o,{env:r.env,logger:r.logger,dryRun:Ns(t,"dry-run")});return{success:!0,message:n.dryRun?`Dry run: would push ${n.pushedKeys.length} secrets`:`Pushed ${n.pushedKeys.length} secrets`}}}),iK=nt({name:"secrets:encrypt",usage:"<repo> <handle>",description:"Encrypt pilot secrets for a user with age",flags:{"dry-run":Lb},run:async({args:e,flags:t},r)=>{let o=e[0],n=e[1];if(!o||!n)return ht(iK);let i=await PT(o,n,{env:r.env,logger:r.logger,dryRun:Ns(t,"dry-run")});return{success:!0,message:i.dryRun?`Dry run: would encrypt ${i.encryptedKeys.length} secrets for ${n}`:`Encrypted ${i.encryptedKeys.length} secrets for ${n}`}}}),sK=nt({name:"recover:retire-legacy-projection-job",usage:"<database> <job-id> --type <legacy-type> (--dry-run | --confirm retire:<job-id>)",description:"Retire one exact unowned pre-scheduler projection job",flags:{type:{type:"string",placeholder:"<legacy-type>",description:"Exact retired projection job type"},confirm:{type:"string",placeholder:"retire:<job-id>",description:"Exact job retirement confirmation"},"dry-run":Lb},run:async({args:e,flags:t},r)=>{let o=e[0],n=e[1],i=ot(t,"type"),s=ot(t,"confirm"),a=Ns(t,"dry-run")??!1;if(!o||!n||!i||a===(s!==void 0))return ht(sK);let{legacyProjectionJobTypeSchema:c}=await Promise.resolve().then(() => (H$(),K$)),u=c.safeParse(i);if(!u.success)return{success:!1,message:`Unsupported legacy projection job type: ${i}`};let d=r.legacyProjectionJobRecoveryRunner??(await Promise.resolve().then(() => (H$(),K$))).retireLegacyProjectionJob;try{let p=await d({databasePath:o,jobId:n,jobType:u.data,...s?{confirmation:s}:{},dryRun:a});return{success:!0,message:p.retired?`Retired unowned legacy projection job ${p.job.id} (${p.job.type})`:`Dry run: legacy projection job ${p.job.id} (${p.job.type}) is unowned and retirable`}}catch(p){return{success:!1,message:`Legacy projection job recovery failed: ${Ve(p)}`}}}}),aK=nt({name:"stress:directory-sync",usage:"<repo> <handle> --profile <regression|load|stress> --confirm stress:<handle> [--artifacts-dir <path>]",description:"Run a smoke-only directory-sync stress profile",flags:{profile:{type:"string",placeholder:"<profile>",description:"Stress profile (`regression`, `load`, or `stress`)"},confirm:{type:"string",placeholder:"stress:<handle>",description:"Explicit smoke target confirmation"},"artifacts-dir":{type:"string",placeholder:"<path>",description:"Directory for JSON, Markdown, samples, and logs"}},run:async({args:e,flags:t},r)=>{let o=e[0],n=e[1],i=ot(t,"profile"),s=ot(t,"confirm");if(!o||!n||!s||i!=="regression"&&i!=="load"&&i!=="stress")return ht(aK);let a=r.directorySyncStressRunner??(await Promise.resolve().then(() => (sf(),Pb))).runDeployedDirectorySyncStress,c=ot(t,"artifacts-dir"),u=await a({rootDir:o,handle:n,profile:i,confirmation:s,...c?{artifactsDir:c}:{},...r.env?{env:r.env}:{},...r.fetchImpl?{fetchImpl:r.fetchImpl}:{},...r.logger?{logger:r.logger}:{}});return{success:u.report.success,message:`${u.report.success?"Passed":"Failed"} ${i} directory-sync stress for ${n}; artifacts: ${u.artifactsDir}`}}}),cK=nt({name:"stress:directory-sync:verify-access",usage:"<repo> <handle> --confirm stress:<handle> [--artifacts-dir <path>]",description:"Verify smoke stress credentials without remote writes",flags:{confirm:{type:"string",placeholder:"stress:<handle>",description:"Explicit smoke target confirmation"},"artifacts-dir":{type:"string",placeholder:"<path>",description:"Directory for the access-check result"}},run:async({args:e,flags:t},r)=>{let o=e[0],n=e[1],i=ot(t,"confirm");if(!o||!n||!i)return ht(cK);let s=r.directorySyncStressAccessRunner??(await Promise.resolve().then(() => (sf(),Pb))).verifyDirectorySyncStressAccess,a=ot(t,"artifacts-dir"),c=await s({rootDir:o,handle:n,confirmation:i,...a?{artifactsDir:a}:{},...r.env?{env:r.env}:{}});return{success:c.success,message:`Verified directory-sync stress access for ${n} at ${c.remoteHead}; artifacts: ${c.artifactsDir}`}}}),lK=nt({name:"stress:directory-sync:cleanup",usage:"<repo> <handle> --confirm stress:<handle> [--artifacts-dir <path>]",description:"Remove residual smoke directory-sync stress probes",flags:{confirm:{type:"string",placeholder:"stress:<handle>",description:"Explicit smoke target confirmation"},"artifacts-dir":{type:"string",placeholder:"<path>",description:"Directory for the cleanup result"}},run:async({args:e,flags:t},r)=>{let o=e[0],n=e[1],i=ot(t,"confirm");if(!o||!n||!i)return ht(lK);let s=r.directorySyncStressCleanupRunner??(await Promise.resolve().then(() => (sf(),Pb))).cleanupDirectorySyncStress,a=ot(t,"artifacts-dir"),c=await s({rootDir:o,handle:n,confirmation:i,...a?{artifactsDir:a}:{},...r.env?{env:r.env}:{},...r.logger?{logger:r.logger}:{}});return{success:c.success,message:`${c.success?"Cleaned":"Failed to clean"} directory-sync stress probes for ${n}; removed ${c.probesRemoved}, remaining ${c.probesRemaining}`}}}),uK={confirm:{type:"string",placeholder:"watchdog-smoke:<handle>",description:"Explicit smoke target confirmation"},"run-id":{type:"string",placeholder:"<id>",description:"Stable workflow run identifier used for cleanup"},"artifacts-dir":{type:"string",placeholder:"<path>",description:"Directory for remote smoke evidence"}},dK=nt({name:"smoke:health-watchdog",usage:"<repo> <handle> --confirm watchdog-smoke:<handle> --run-id <id> [--artifacts-dir <path>]",description:"Run the smoke-fleet host watchdog isolation check",flags:uK,run:async({args:e,flags:t},r)=>{let o=e[0],n=e[1],i=ot(t,"confirm"),s=ot(t,"run-id");if(!o||!n||!i||!s)return ht(dK);let a=r.healthWatchdogSmokeRunner??(await Db().then(() => lO)).runHealthWatchdogSmoke,c=ot(t,"artifacts-dir"),u=await a({rootDir:o,handle:n,confirmation:i,runId:s,...c?{artifactsDir:c}:{},...r.env?{env:r.env}:{},...r.fetchImpl?{fetchImpl:r.fetchImpl}:{},...r.logger?{logger:r.logger}:{}});return{success:u.success,message:`Passed health watchdog smoke for ${n}; artifacts: ${u.artifactsDir}`}}}),pK=nt({name:"smoke:health-watchdog:cleanup",usage:"<repo> <handle> --confirm watchdog-smoke:<handle> --run-id <id> [--artifacts-dir <path>]",description:"Remove residual smoke-fleet watchdog fixtures",flags:uK,run:async({args:e,flags:t},r)=>{let o=e[0],n=e[1],i=ot(t,"confirm"),s=ot(t,"run-id");if(!o||!n||!i||!s)return ht(pK);let a=r.healthWatchdogSmokeCleanupRunner??(await Db().then(() => lO)).cleanupHealthWatchdogSmoke,c=ot(t,"artifacts-dir"),u=await a({rootDir:o,handle:n,confirmation:i,runId:s,...c?{artifactsDir:c}:{},...r.env?{env:r.env}:{},...r.fetchImpl?{fetchImpl:r.fetchImpl}:{},...r.logger?{logger:r.logger}:{}});return{success:u.success,message:`Cleaned health watchdog smoke fixtures for ${n}; artifacts: ${u.artifactsDir}`}}}),fK=nt({name:"verify-user",usage:"<repo> <handle>",description:"Probe a deployed user's endpoints",run:async({args:e},t)=>{let r=e[0],o=e[1];if(!r||!o)return ht(fK);let n=await BT(r,o,{...t.fetchImpl?{fetchImpl:t.fetchImpl}:{},...t.logger?{logger:t.logger}:{},...t.verificationRetryAttempts!==void 0?{operationalRetryAttempts:t.verificationRetryAttempts}:{},...t.verificationRetryDelayMs!==void 0?{operationalRetryDelayMs:t.verificationRetryDelayMs}:{},...t.sleep?{sleep:t.sleep}:{}}),i=n.checks.length>0?n.checks.join(", "):"none";if(n.failedChecks.length>0){let s=n.failedChecks.map((a)=>` ${a.name}: ${a.message}`).join(`
|
|
775
775
|
`);return{success:!1,message:`Verified ${n.handle} (${n.bundles.join(",")}) at https://${n.domain}: passed ${i}; failed:
|
|
776
776
|
${s}`}}return{success:!0,message:`Verified ${n.handle} (${n.bundles.join(",")}) at https://${n.domain}: ${i}`}}}),mK=nt({name:"reconcile-cohort",usage:"<repo> <cohort>",description:"Reconcile all users in a cohort",run:async({args:e},t)=>{let r=e[0],o=e[1];if(!r||!o)return ht(mK);return await NI(r,o,t.runner,{...t.env?{env:t.env}:{}}),{success:!0,message:`Reconciled cohort ${o}`}}});function F8(e,t){return[e,...t.length===0?["- (none)"]:t.map((r)=>`- ${r}`)]}var hK=nt({name:"reconcile-all",usage:"<repo> [--dry-run]",description:"Reconcile every cohort",flags:{"dry-run":Lb},run:async({args:e,flags:t},r)=>{let o=e[0];if(!o)return ht(hK);if(Ns(t,"dry-run")){let n=await mM(o),i=n.firstPassChangedFiles.length,s=n.secondPassChangedFiles.length;return{success:s===0,message:[`Dry-run reconcile found ${i} first-pass changed file(s); second pass ${s===0?"converged with zero drift":`still changed ${s} file(s)`}`,...F8("First-pass changed files:",n.firstPassChangedFiles),...F8("Second-pass changed files:",n.secondPassChangedFiles)].join(`
|
|
777
|
-
`)}}return await gd(o,r.runner,{...r.env?{env:r.env}:{}}),{success:!0,message:"Reconciled all cohorts"}}}),
|
|
777
|
+
`)}}return await gd(o,r.runner,{...r.env?{env:r.env}:{}}),{success:!0,message:"Reconciled all cohorts"}}}),ege=nt({name:"help",description:"Show this help message",run:()=>({success:!0,message:dj({cliName:K8,intro:"brains-ops \u2014 operator CLI for private brain fleet repos",commands:Bb,globalFlags:dO})})}),tge=nt({name:"version",description:"Show version",run:()=>({success:!0,message:`brains-ops ${af.version}`})}),dO={help:{type:"boolean",short:"h",description:"Show help"},version:{type:"boolean",short:"v",description:"Show version"}},Bb=[H8,J8,V8,W8,G8,Q8,Y8,X8,eK,tK,rK,nK,oK,iK,sK,aK,cK,lK,dK,pK,fK,mK,hK,ege,tge],rge=pj(Bb);async function nge(e,t={}){let r=rge.get(e.command);if(!r)return{success:!1,message:`Unknown command: ${e.command}`};return r.run({args:e.args,flags:e.flags},t)}function oge(e){return aj(e,{commands:Bb,globalFlags:dO})}fy();gy();Cb();sf();Bn();await Db();export{di as CAPABILITY_BUNDLE_CONTRACT,Sk as addPilotUser,ef as assertDirectorySyncStressTarget,Nb as assertHealthWatchdogSmokeTarget,PI as assertPilotUsersRemoved,V6 as bootstrapPilotAgeKey,cM as bootstrapPilotOriginCertificate,LT as bootstrapPilotSshKey,oh as canonicalBundleIdSchema,I8 as cleanupDirectorySyncStress,Z8 as cleanupHealthWatchdogSmoke,Kr as cohortSchema,CI as createPilotOffboardDriver,pk as derivePreviewDomain,Xp as directorySyncStressPlanSchema,Yp as directorySyncStressProfileSchema,g8 as directorySyncStressReportSchema,PT as encryptPilotSecrets,el as extractAgeIdentity,GE as initPilotRepo,ut as loadPilotRegistry,rj as offboardPilotUsers,bk as onboardUser,oge as parseArgs,pi as pilotSchema,DT as pushPilotSecrets,gd as reconcileAll,NI as reconcileCohort,cO as renderHealthWatchdogSmokeRemoteScript,B2 as requiredImages,V$ as resolveDirectorySyncStressPlan,lh as resolveImageBuilds,nge as runCommand,E8 as runDeployedDirectorySyncStress,W$ as runDirectorySyncStressPlan,j8 as runHealthWatchdogSmoke,RT as runPilotAgeKeyBootstrap,$T as runPilotCertBootstrap,yy as runPilotSshKeyBootstrap,dG as runResolveMissingImages,Uu as runtimeImageTag,Ob as sampleStressHealth,ch as sitePackagesFor,y8 as stressMetricsFailure,k8 as verifyDirectorySyncStressAccess,BT as verifyPilotUser,po as writeUsersTable};
|