@rizom/ops 0.2.0-alpha.484 → 0.2.0-alpha.485

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -105,7 +105,7 @@ IFS=',' read -ra HOSTS <<< "$KAMAL_HOSTS"
105
105
  for host in "\${HOSTS[@]}"; do
106
106
  scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null "$BRAIN_FILE" "\${SSH_USER}@\${host}:/opt/brain.yaml"
107
107
  done
108
- `}import{appendFileSync as kEe,readFileSync as gW}from"fs";function Wx(e,t){let r=[],i=new Set,n=t?.skipSections??new Set,o=!1,s=!1,a=!1;for(let c of e.split(/\r?\n/)){let l=c.trim();if(yW.test(l)){o=n.has(l),s=!1,a=!1;continue}if(o)continue;if(l.startsWith("#")){if(l.includes("@required"))s=!0;if(l.includes("@sensitive"))a=!0;continue}let u=l.match(/^([A-Z][A-Z0-9_]*)=/);if(!u?.[1]){s=!1,a=!1;continue}let d=u[1];if(!i.has(d))i.add(d),r.push({key:d,required:s,sensitive:a});s=!1,a=!1}return r}function Gx(e,t){return Wx(gW(e,"utf8"),t)}var yW;var TR=x(()=>{yW=/^# ---- .+ ----$/});import{existsSync as bW,readFileSync as xW}from"fs";import{homedir as SW}from"os";import{isAbsolute as wW,join as Qx,resolve as vW}from"path";function zn(e){let t={};for(let r of[Qx(e,".env"),Qx(e,".env.local")]){if(!bW(r))continue;let i=_W(xW(r,"utf8"));for(let[n,o]of Object.entries(i))t[n]=o}return t}function Wt(e,t,r){return t[e]??r[e]}function ho(e,t){if(e.startsWith("~/"))return Qx(process.env.HOME??SW(),e.slice(2));if(wW(e))return e;return vW(t,e)}function _W(e){let t={};for(let r of e.split(/\r?\n/)){let i=r.trim();if(i.length===0||i.startsWith("#"))continue;let n=r.match(/^\s*(?:export\s+)?([A-Z][A-Z0-9_]*)\s*=\s*(.*)\s*$/),o=n?.[1],s=n?.[2];if(!o||s===void 0)continue;t[o]=kW(s)}return t}function kW(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,`
108
+ `}import{appendFileSync as _Ee,readFileSync as gW}from"fs";function Wx(e,t){let r=[],i=new Set,n=t?.skipSections??new Set,o=!1,s=!1,a=!1;for(let c of e.split(/\r?\n/)){let l=c.trim();if(yW.test(l)){o=n.has(l),s=!1,a=!1;continue}if(o)continue;if(l.startsWith("#")){if(l.includes("@required"))s=!0;if(l.includes("@sensitive"))a=!0;continue}let u=l.match(/^([A-Z][A-Z0-9_]*)=/);if(!u?.[1]){s=!1,a=!1;continue}let d=u[1];if(!i.has(d))i.add(d),r.push({key:d,required:s,sensitive:a});s=!1,a=!1}return r}function Gx(e,t){return Wx(gW(e,"utf8"),t)}var yW;var TR=x(()=>{yW=/^# ---- .+ ----$/});import{existsSync as bW,readFileSync as xW}from"fs";import{homedir as SW}from"os";import{isAbsolute as wW,join as Qx,resolve as vW}from"path";function zn(e){let t={};for(let r of[Qx(e,".env"),Qx(e,".env.local")]){if(!bW(r))continue;let i=_W(xW(r,"utf8"));for(let[n,o]of Object.entries(i))t[n]=o}return t}function Wt(e,t,r){return t[e]??r[e]}function ho(e,t){if(e.startsWith("~/"))return Qx(process.env.HOME??SW(),e.slice(2));if(wW(e))return e;return vW(t,e)}function _W(e){let t={};for(let r of e.split(/\r?\n/)){let i=r.trim();if(i.length===0||i.startsWith("#"))continue;let n=r.match(/^\s*(?:export\s+)?([A-Z][A-Z0-9_]*)\s*=\s*(.*)\s*$/),o=n?.[1],s=n?.[2];if(!o||s===void 0)continue;t[o]=kW(s)}return t}function kW(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,`
109
109
  `).replace(/\\r/g,"\r").replace(/\\t/g,"\t").replace(/\\"/g,'"').replace(/\\\\/g,"\\");return e}var Yx=()=>{};function RR(e,t,r){if(t===r)return!1;return t.includes(CW[e])}function PR(){return ER}function zR(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"]'))return!1;let r=['CMD ["./node_modules/.bin/brain", "start"]','CMD ["bun", "./node_modules/@rizom/brain/dist/brain.js", "start"]','CMD ["bun", "--no-orphans", "./node_modules/@rizom/brain/dist/brain.js", "start"]'].some((n)=>e.includes(n)),i=e.includes("chromium-headless-shell");return r&&i&&["ARG BUN_VERSION=","FROM oven/bun:${BUN_VERSION}-slim AS runtime","FROM runtime AS standalone","FROM runtime AS fleet"].every((n)=>e.includes(n))}function rm(e){return AR.replace("__SERVICE_NAME__",e.serviceName)}function nc(e){return e.replace(/\nvolumes:\n(?: {2}- .*\n)+$/,`
110
110
  volumes:
111
111
  - __VOLUMES__
@@ -140,7 +140,7 @@ volumes:
140
140
  `+k.slice(ae,ge),ae=ge+1;pe=Ae}if(Ie+=`
141
141
  `,k.length-ae>W&&pe>ae)Ie+=k.slice(ae,pe)+`
142
142
  `+k.slice(pe+1);else Ie+=k.slice(ae);return Ie.slice(1)}function Ru(k){let W="",le=0;for(let se=0;se<k.length;le>=65536?se+=2:se++){le=Xe(k,se);let ae=I[le];if(!ae&&$e(le)){if(W+=k[se],le>=65536)W+=k[se+1]}else W+=ae||L(le)}return W}function tc(k,W,le){let se="",ae=k.tag;for(let ge=0,pe=le.length;ge<pe;ge+=1){let Ae=le[ge];if(k.replacer)Ae=k.replacer.call(le,String(ge),Ae);if(G(k,W,Ae,!1,!1)||typeof Ae>"u"&&G(k,W,null,!1,!1)){if(se!=="")se+=","+(!k.condenseFlow?" ":"");se+=k.dump}}k.tag=ae,k.dump="["+se+"]"}function re(k,W,le,se){let ae="",ge=k.tag;for(let pe=0,Ae=le.length;pe<Ae;pe+=1){let Ie=le[pe];if(k.replacer)Ie=k.replacer.call(le,String(pe),Ie);if(G(k,W+1,Ie,!0,!0,!1,!0)||typeof Ie>"u"&&G(k,W+1,null,!0,!0,!1,!0)){if(!se||ae!=="")ae+=C(k,W);if(k.dump&&a===k.dump.charCodeAt(0))ae+="-";else ae+="- ";ae+=k.dump}}k.tag=ge,k.dump=ae||"[]"}function ne(k,W,le){let se="",ae=k.tag,ge=Object.keys(le);for(let pe=0,Ae=ge.length;pe<Ae;pe+=1){let Ie="";if(se!=="")Ie+=", ";if(k.condenseFlow)Ie+='"';let Pe=ge[pe],Le=le[Pe];if(k.replacer)Le=k.replacer.call(le,Pe,Le);if(!G(k,W,Pe,!1,!1))continue;if(k.dump.length>1024)Ie+="? ";if(Ie+=k.dump+(k.condenseFlow?'"':"")+":"+(k.condenseFlow?"":" "),!G(k,W,Le,!1,!1))continue;Ie+=k.dump,se+=Ie}k.tag=ae,k.dump="{"+se+"}"}function h(k,W,le,se){let ae="",ge=k.tag,pe=Object.keys(le);if(k.sortKeys===!0)pe.sort();else if(typeof k.sortKeys==="function")pe.sort(k.sortKeys);else if(k.sortKeys)throw new t("sortKeys must be a boolean or a function");for(let Ae=0,Ie=pe.length;Ae<Ie;Ae+=1){let Pe="";if(!se||ae!=="")Pe+=C(k,W);let Le=pe[Ae],We=le[Le];if(k.replacer)We=k.replacer.call(le,Le,We);if(!G(k,W+1,Le,!0,!0,!0))continue;let pt=k.tag!==null&&k.tag!=="?"||k.dump&&k.dump.length>1024;if(pt)if(k.dump&&a===k.dump.charCodeAt(0))Pe+="?";else Pe+="? ";if(Pe+=k.dump,pt)Pe+=C(k,W);if(!G(k,W+1,We,!0,pt))continue;if(k.dump&&a===k.dump.charCodeAt(0))Pe+=":";else Pe+=": ";Pe+=k.dump,ae+=Pe}k.tag=ge,k.dump=ae||"{}"}function U(k,W,le){let se=le?k.explicitTypes:k.implicitTypes;for(let ae=0,ge=se.length;ae<ge;ae+=1){let pe=se[ae];if((pe.instanceOf||pe.predicate)&&(!pe.instanceOf||typeof W==="object"&&W instanceof pe.instanceOf)&&(!pe.predicate||pe.predicate(W))){if(le)if(pe.multi&&pe.representName)k.tag=pe.representName(W);else k.tag=pe.tag;else k.tag="?";if(pe.represent){let Ae=k.styleMap[pe.tag]||pe.defaultStyle,Ie;if(i.call(pe.represent)==="[object Function]")Ie=pe.represent(W,Ae);else if(n.call(pe.represent,Ae))Ie=pe.represent[Ae](W,Ae);else throw new t("!<"+pe.tag+'> tag resolver accepts not "'+Ae+'" style');k.dump=Ie}return!0}}return!1}function G(k,W,le,se,ae,ge,pe){if(k.tag=null,k.dump=le,!U(k,le,!1))U(k,le,!0);let Ae=i.call(k.dump),Ie=se;if(se)se=k.flowLevel<0||k.flowLevel>W;let Pe=Ae==="[object Object]"||Ae==="[object Array]",Le,We;if(Pe)Le=k.duplicates.indexOf(le),We=Le!==-1;if(k.tag!==null&&k.tag!=="?"||We||k.indent!==2&&W>0)ae=!1;if(We&&k.usedDuplicates[Le])k.dump="*ref_"+Le;else{if(Pe&&We&&!k.usedDuplicates[Le])k.usedDuplicates[Le]=!0;if(Ae==="[object Object]"){if(se&&Object.keys(k.dump).length!==0){if(h(k,W,k.dump,ae),We)k.dump="&ref_"+Le+k.dump}else if(ne(k,W,k.dump),We)k.dump="&ref_"+Le+" "+k.dump}else if(Ae==="[object Array]"){if(se&&k.dump.length!==0){if(k.noArrayIndent&&!pe&&W>0)re(k,W-1,k.dump,ae);else re(k,W,k.dump,ae);if(We)k.dump="&ref_"+Le+k.dump}else if(tc(k,W,k.dump),We)k.dump="&ref_"+Le+" "+k.dump}else if(Ae==="[object String]"){if(k.tag!=="?")Xa(k,k.dump,W,ge,Ie)}else if(Ae==="[object Undefined]")return!1;else{if(k.skipInvalid)return!1;throw new t("unacceptable kind of an object to dump "+Ae)}if(k.tag!==null&&k.tag!=="?"){let pt=encodeURI(k.tag[0]==="!"?k.tag.slice(1):k.tag).replace(/!/g,"%21");if(k.tag[0]==="!")pt="!"+pt;else if(pt.slice(0,18)==="tag:yaml.org,2002:")pt="!!"+pt.slice(18);else pt="!<"+pt+">";k.dump=pt+" "+k.dump}}return!0}function ie(k,W){let le=[],se=[];Y(k,le,se);let ae=se.length;for(let ge=0;ge<ae;ge+=1)W.duplicates.push(le[se[ge]]);W.usedDuplicates=Array(ae)}function Y(k,W,le){if(k!==null&&typeof k==="object"){let se=W.indexOf(k);if(se!==-1){if(le.indexOf(se)===-1)le.push(se)}else if(W.push(k),Array.isArray(k))for(let ae=0,ge=k.length;ae<ge;ae+=1)Y(k[ae],W,le);else{let ae=Object.keys(k);for(let ge=0,pe=ae.length;ge<pe;ge+=1)Y(k[ae[ge]],W,le)}}}function de(k,W){W=W||{};let le=new te(W);if(!le.noRefs)ie(k,le);let se=k;if(le.replacer)se=le.replacer.call({"":se},"",se);if(G(le,0,se,!0,!0))return le.dump+`
143
- `;return""}return SS.dump=de,SS}function NW(){if(sP)return gr;sP=1;let e=PW(),t=zW();function r(i,n){return function(){throw Error("Function yaml."+i+" is removed in js-yaml 4. Use yaml."+n+" instead, which is now safe by default.")}}return gr.Type=Tr(),gr.Schema=aP(),gr.FAILSAFE_SCHEMA=dP(),gr.JSON_SCHEMA=gP(),gr.CORE_SCHEMA=yP(),gr.DEFAULT_SCHEMA=wS(),gr.load=e.load,gr.loadAll=e.loadAll,gr.dump=t.dump,gr.YAMLException=Du(),gr.types={binary:SP(),float:hP(),map:uP(),null:fP(),pairs:vP(),set:_P(),timestamp:bP(),bool:pP(),int:mP(),merge:xP(),omap:wP(),seq:lP(),str:cP()},gr.safeLoad=r("safeLoad","load"),gr.safeLoadAll=r("safeLoadAll","loadAll"),gr.safeDump=r("safeDump","dump"),gr}var gr,nm,go,DR,Xx,LR,eS,BR,tS,jR,rS,qR,nS,UR,iS,MR,oS,FR,sS,ZR,aS,HR,cS,KR,lS,JR,uS,VR,dS,WR,fS,GR,pS,QR,mS,YR,hS,XR,gS,eP,yS,tP,bS,rP,xS,nP,iP,SS,oP,sP,DW,LW,jEe,qEe,UEe,MEe,FEe,ZEe,im,HEe,vS,KEe,JEe,VEe,WEe,GEe;var om=x(()=>{gr={},nm={},go={};SS={};DW=NW(),LW=OW(DW),{Type:jEe,Schema:qEe,FAILSAFE_SCHEMA:UEe,JSON_SCHEMA:MEe,CORE_SCHEMA:FEe,DEFAULT_SCHEMA:ZEe,load:im,loadAll:HEe,dump:vS,YAMLException:KEe,types:JEe,safeLoad:VEe,safeLoadAll:WEe,safeDump:GEe}=LW});function at(e,t){if(e instanceof Error)return e.message;return t??String(e)}function ic(e){return vS(e,{skipInvalid:!0,noRefs:!0,sortKeys:!0})}function kP(e){return im(e)}function Nn(e,t){if(!e.trim())return{ok:!1,error:"file is empty"};let r;try{r=im(e)}catch(n){return{ok:!1,error:at(n,"YAML parse error")}}if(!BW(r))return{ok:!1,error:"expected a YAML mapping (key: value pairs)"};if(!t)return{ok:!0,data:r};let i=t.safeParse(r);if(!i.success)return{ok:!1,error:`invalid field(s): ${i.error.issues.map((o)=>o.path.map(String).join(".")).join(", ")}`};return{ok:!0,data:i.data}}function BW(e){return Boolean(e)&&typeof e==="object"&&!Array.isArray(e)}var Ai=x(()=>{om()});function K(e,t,r){function i(a,c){if(!a._zod)Object.defineProperty(a,"_zod",{value:{def:c,constr:s,traits:new Set},enumerable:!1});if(a._zod.traits.has(e))return;a._zod.traits.add(e),t(a,c);let l=s.prototype,u=Object.keys(l);for(let d=0;d<u.length;d++){let p=u[d];if(!(p in a))a[p]=l[p].bind(a)}}let n=r?.Parent??Object;class o extends n{}Object.defineProperty(o,"name",{value:e});function s(a){var c;let l=r?.Parent?new o:this;i(l,a),(c=l._zod).deferred??(c.deferred=[]);for(let u of l._zod.deferred)u();return l}return Object.defineProperty(s,"init",{value:i}),Object.defineProperty(s,Symbol.hasInstance,{value:(a)=>{if(r?.Parent&&a instanceof r.Parent)return!0;return a?._zod?.traits?.has(e)}}),Object.defineProperty(s,"name",{value:e}),s}function kt(e){if(e)Object.assign(Ps,e);return Ps}var EP,kS,ES,ei,zs,Ps;var Ns=x(()=>{kS=Object.freeze({status:"aborted"});ES=Symbol("zod_brand");ei=class ei extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}};zs=class zs extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name="ZodEncodeError"}};(EP=globalThis).__zod_globalConfig??(EP.__zod_globalConfig={});Ps=globalThis.__zod_globalConfig});var ye={};tr(ye,{BIGINT_FORMAT_RANGES:()=>zS,Class:()=>CP,NUMBER_FORMAT_RANGES:()=>PS,aborted:()=>So,allowsEval:()=>CS,assert:()=>FW,assertEqual:()=>jW,assertIs:()=>UW,assertNever:()=>MW,assertNotEqual:()=>qW,assignProp:()=>bo,base64ToUint8Array:()=>AP,base64urlToUint8Array:()=>sG,cached:()=>sc,captureStackTrace:()=>am,cleanEnum:()=>oG,cleanRegex:()=>ju,clone:()=>Cr,cloneDef:()=>HW,createTransparentProxy:()=>QW,defineLazy:()=>Je,esc:()=>sm,escapeRegex:()=>gn,explicitlyAborted:()=>NS,extend:()=>eG,finalizeIssue:()=>$r,floatSafeRemainder:()=>AS,getElementAtPath:()=>KW,getEnumValues:()=>Bu,getLengthableOrigin:()=>Mu,getParsedType:()=>GW,getSizableOrigin:()=>Uu,hexToUint8Array:()=>cG,isObject:()=>Ds,isPlainObject:()=>xo,issue:()=>ac,joinValues:()=>Q,jsonStringifyReplacer:()=>oc,merge:()=>rG,mergeDefs:()=>Ti,normalizeParams:()=>xe,nullish:()=>yo,numKeys:()=>WW,objectClone:()=>ZW,omit:()=>XW,optionalKeys:()=>RS,parsedType:()=>he,partial:()=>nG,pick:()=>YW,prefixIssues:()=>Fr,primitiveTypes:()=>OS,promiseAllObject:()=>JW,propertyKeyTypes:()=>qu,randomString:()=>VW,required:()=>iG,safeExtend:()=>tG,shallowClone:()=>$S,slugify:()=>TS,stringifyPrimitive:()=>fe,uint8ArrayToBase64:()=>TP,uint8ArrayToBase64url:()=>aG,uint8ArrayToHex:()=>lG,unwrapMessage:()=>Lu});function jW(e){return e}function qW(e){return e}function UW(e){}function MW(e){throw Error("Unexpected value in exhaustive check")}function FW(e){}function Bu(e){let t=Object.values(e).filter((i)=>typeof i==="number");return Object.entries(e).filter(([i,n])=>t.indexOf(+i)===-1).map(([i,n])=>n)}function Q(e,t="|"){return e.map((r)=>fe(r)).join(t)}function oc(e,t){if(typeof t==="bigint")return t.toString();return t}function sc(e){return{get value(){{let r=e();return Object.defineProperty(this,"value",{value:r}),r}throw Error("cached value already set")}}}function yo(e){return e===null||e===void 0}function ju(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function AS(e,t){let r=e/t,i=Math.round(r),n=Number.EPSILON*Math.max(Math.abs(r),1);if(Math.abs(r-i)<n)return 0;return r-i}function Je(e,t,r){let i=void 0;Object.defineProperty(e,t,{get(){if(i===IP)return;if(i===void 0)i=IP,i=r();return i},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function ZW(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function bo(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Ti(...e){let t={};for(let r of e){let i=Object.getOwnPropertyDescriptors(r);Object.assign(t,i)}return Object.defineProperties({},t)}function HW(e){return Ti(e._zod.def)}function KW(e,t){if(!t)return e;return t.reduce((r,i)=>r?.[i],e)}function JW(e){let t=Object.keys(e),r=t.map((i)=>e[i]);return Promise.all(r).then((i)=>{let n={};for(let o=0;o<t.length;o++)n[t[o]]=i[o];return n})}function VW(e=10){let r="";for(let i=0;i<e;i++)r+="abcdefghijklmnopqrstuvwxyz"[Math.floor(Math.random()*26)];return r}function sm(e){return JSON.stringify(e)}function TS(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}function Ds(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function xo(e){if(Ds(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;if(typeof t!=="function")return!0;let r=t.prototype;if(Ds(r)===!1)return!1;if(Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)return!1;return!0}function $S(e){if(xo(e))return{...e};if(Array.isArray(e))return[...e];if(e instanceof Map)return new Map(e);if(e instanceof Set)return new Set(e);return e}function WW(e){let t=0;for(let r in e)if(Object.prototype.hasOwnProperty.call(e,r))t++;return t}function gn(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Cr(e,t,r){let i=new e._zod.constr(t??e._zod.def);if(!t||r?.parent)i._zod.parent=e;return i}function xe(e){let t=e;if(!t)return{};if(typeof t==="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}if(delete t.message,typeof t.error==="string")return{...t,error:()=>t.error};return t}function QW(e){let t;return new Proxy({},{get(r,i,n){return t??(t=e()),Reflect.get(t,i,n)},set(r,i,n,o){return t??(t=e()),Reflect.set(t,i,n,o)},has(r,i){return t??(t=e()),Reflect.has(t,i)},deleteProperty(r,i){return t??(t=e()),Reflect.deleteProperty(t,i)},ownKeys(r){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(r,i){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,i)},defineProperty(r,i,n){return t??(t=e()),Reflect.defineProperty(t,i,n)}})}function fe(e){if(typeof e==="bigint")return e.toString()+"n";if(typeof e==="string")return`"${e}"`;return`${e}`}function RS(e){return Object.keys(e).filter((t)=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}function YW(e,t){let r=e._zod.def,i=r.checks;if(i&&i.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let o=Ti(e._zod.def,{get shape(){let s={};for(let a in t){if(!(a in r.shape))throw Error(`Unrecognized key: "${a}"`);if(!t[a])continue;s[a]=r.shape[a]}return bo(this,"shape",s),s},checks:[]});return Cr(e,o)}function XW(e,t){let r=e._zod.def,i=r.checks;if(i&&i.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let o=Ti(e._zod.def,{get shape(){let s={...e._zod.def.shape};for(let a in t){if(!(a in r.shape))throw Error(`Unrecognized key: "${a}"`);if(!t[a])continue;delete s[a]}return bo(this,"shape",s),s},checks:[]});return Cr(e,o)}function eG(e,t){if(!xo(t))throw Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let o=e._zod.def.shape;for(let s in t)if(Object.getOwnPropertyDescriptor(o,s)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let n=Ti(e._zod.def,{get shape(){let o={...e._zod.def.shape,...t};return bo(this,"shape",o),o}});return Cr(e,n)}function tG(e,t){if(!xo(t))throw Error("Invalid input to safeExtend: expected a plain object");let r=Ti(e._zod.def,{get shape(){let i={...e._zod.def.shape,...t};return bo(this,"shape",i),i}});return Cr(e,r)}function rG(e,t){if(e._zod.def.checks?.length)throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let r=Ti(e._zod.def,{get shape(){let i={...e._zod.def.shape,...t._zod.def.shape};return bo(this,"shape",i),i},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return Cr(e,r)}function nG(e,t,r){let n=t._zod.def.checks;if(n&&n.length>0)throw Error(".partial() cannot be used on object schemas containing refinements");let s=Ti(t._zod.def,{get shape(){let a=t._zod.def.shape,c={...a};if(r)for(let l in r){if(!(l in a))throw Error(`Unrecognized key: "${l}"`);if(!r[l])continue;c[l]=e?new e({type:"optional",innerType:a[l]}):a[l]}else for(let l in a)c[l]=e?new e({type:"optional",innerType:a[l]}):a[l];return bo(this,"shape",c),c},checks:[]});return Cr(t,s)}function iG(e,t,r){let i=Ti(t._zod.def,{get shape(){let n=t._zod.def.shape,o={...n};if(r)for(let s in r){if(!(s in o))throw Error(`Unrecognized key: "${s}"`);if(!r[s])continue;o[s]=new e({type:"nonoptional",innerType:n[s]})}else for(let s in n)o[s]=new e({type:"nonoptional",innerType:n[s]});return bo(this,"shape",o),o}});return Cr(t,i)}function So(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function NS(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}function Fr(e,t){return t.map((r)=>{var i;return(i=r).path??(i.path=[]),r.path.unshift(e),r})}function Lu(e){return typeof e==="string"?e:e?.message}function $r(e,t,r){let i=e.message?e.message:Lu(e.inst?._zod.def?.error?.(e))??Lu(t?.error?.(e))??Lu(r.customError?.(e))??Lu(r.localeError?.(e))??"Invalid input",{inst:n,continue:o,input:s,...a}=e;if(a.path??(a.path=[]),a.message=i,t?.reportInput)a.input=s;return a}function Uu(e){if(e instanceof Set)return"set";if(e instanceof Map)return"map";if(e instanceof File)return"file";return"unknown"}function Mu(e){if(Array.isArray(e))return"array";if(typeof e==="string")return"string";return"unknown"}function he(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let r=e;if(r&&Object.getPrototypeOf(r)!==Object.prototype&&"constructor"in r&&r.constructor)return r.constructor.name}}return t}function ac(...e){let[t,r,i]=e;if(typeof t==="string")return{message:t,code:"custom",input:r,inst:i};return{...t}}function oG(e){return Object.entries(e).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map((t)=>t[1])}function AP(e){let t=atob(e),r=new Uint8Array(t.length);for(let i=0;i<t.length;i++)r[i]=t.charCodeAt(i);return r}function TP(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}function sG(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-t.length%4)%4);return AP(t+r)}function aG(e){return TP(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function cG(e){let t=e.replace(/^0x/,"");if(t.length%2!==0)throw Error("Invalid hex string length");let r=new Uint8Array(t.length/2);for(let i=0;i<t.length;i+=2)r[i/2]=Number.parseInt(t.slice(i,i+2),16);return r}function lG(e){return Array.from(e).map((t)=>t.toString(16).padStart(2,"0")).join("")}class CP{constructor(...e){}}var IP,am,CS,GW=(e)=>{let t=typeof e;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":if(Array.isArray(e))return"array";if(e===null)return"null";if(e.then&&typeof e.then==="function"&&e.catch&&typeof e.catch==="function")return"promise";if(typeof Map<"u"&&e instanceof Map)return"map";if(typeof Set<"u"&&e instanceof Set)return"set";if(typeof Date<"u"&&e instanceof Date)return"date";if(typeof File<"u"&&e instanceof File)return"file";return"object";default:throw Error(`Unknown data type: ${t}`)}},qu,OS,PS,zS;var Oe=x(()=>{Ns();IP=Symbol("evaluating");am="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};CS=sc(()=>{if(Ps.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});qu=new Set(["string","number","symbol"]),OS=new Set(["string","number","bigint","boolean","symbol","undefined"]);PS={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},zS={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]}});function Zu(e,t=(r)=>r.message){let r={},i=[];for(let n of e.issues)if(n.path.length>0)r[n.path[0]]=r[n.path[0]]||[],r[n.path[0]].push(t(n));else i.push(t(n));return{formErrors:i,fieldErrors:r}}function Hu(e,t=(r)=>r.message){let r={_errors:[]},i=(n,o=[])=>{for(let s of n.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map((a)=>i({issues:a},[...o,...s.path]));else if(s.code==="invalid_key")i({issues:s.issues},[...o,...s.path]);else if(s.code==="invalid_element")i({issues:s.issues},[...o,...s.path]);else{let a=[...o,...s.path];if(a.length===0)r._errors.push(t(s));else{let c=r,l=0;while(l<a.length){let u=a[l];if(l!==a.length-1)c[u]=c[u]||{_errors:[]};else c[u]=c[u]||{_errors:[]},c[u]._errors.push(t(s));c=c[u],l++}}}};return i(e),r}function DS(e,t=(r)=>r.message){let r={errors:[]},i=(n,o=[])=>{var s,a;for(let c of n.issues)if(c.code==="invalid_union"&&c.errors.length)c.errors.map((l)=>i({issues:l},[...o,...c.path]));else if(c.code==="invalid_key")i({issues:c.issues},[...o,...c.path]);else if(c.code==="invalid_element")i({issues:c.issues},[...o,...c.path]);else{let l=[...o,...c.path];if(l.length===0){r.errors.push(t(c));continue}let u=r,d=0;while(d<l.length){let p=l[d],m=d===l.length-1;if(typeof p==="string")u.properties??(u.properties={}),(s=u.properties)[p]??(s[p]={errors:[]}),u=u.properties[p];else u.items??(u.items=[]),(a=u.items)[p]??(a[p]={errors:[]}),u=u.items[p];if(m)u.errors.push(t(c));d++}}};return i(e),r}function OP(e){let t=[],r=e.map((i)=>typeof i==="object"?i.key:i);for(let i of r)if(typeof i==="number")t.push(`[${i}]`);else if(typeof i==="symbol")t.push(`[${JSON.stringify(String(i))}]`);else if(/[^\w$]/.test(i))t.push(`[${JSON.stringify(i)}]`);else{if(t.length)t.push(".");t.push(i)}return t.join("")}function LS(e){let t=[],r=[...e.issues].sort((i,n)=>(i.path??[]).length-(n.path??[]).length);for(let i of r)if(t.push(`\u2716 ${i.message}`),i.path?.length)t.push(` \u2192 at ${OP(i.path)}`);return t.join(`
143
+ `;return""}return SS.dump=de,SS}function NW(){if(sP)return gr;sP=1;let e=PW(),t=zW();function r(i,n){return function(){throw Error("Function yaml."+i+" is removed in js-yaml 4. Use yaml."+n+" instead, which is now safe by default.")}}return gr.Type=Tr(),gr.Schema=aP(),gr.FAILSAFE_SCHEMA=dP(),gr.JSON_SCHEMA=gP(),gr.CORE_SCHEMA=yP(),gr.DEFAULT_SCHEMA=wS(),gr.load=e.load,gr.loadAll=e.loadAll,gr.dump=t.dump,gr.YAMLException=Du(),gr.types={binary:SP(),float:hP(),map:uP(),null:fP(),pairs:vP(),set:_P(),timestamp:bP(),bool:pP(),int:mP(),merge:xP(),omap:wP(),seq:lP(),str:cP()},gr.safeLoad=r("safeLoad","load"),gr.safeLoadAll=r("safeLoadAll","loadAll"),gr.safeDump=r("safeDump","dump"),gr}var gr,nm,go,DR,Xx,LR,eS,BR,tS,jR,rS,qR,nS,UR,iS,MR,oS,FR,sS,ZR,aS,HR,cS,KR,lS,JR,uS,VR,dS,WR,fS,GR,pS,QR,mS,YR,hS,XR,gS,eP,yS,tP,bS,rP,xS,nP,iP,SS,oP,sP,DW,LW,BEe,jEe,qEe,UEe,MEe,FEe,im,ZEe,vS,HEe,KEe,JEe,VEe,WEe;var om=x(()=>{gr={},nm={},go={};SS={};DW=NW(),LW=OW(DW),{Type:BEe,Schema:jEe,FAILSAFE_SCHEMA:qEe,JSON_SCHEMA:UEe,CORE_SCHEMA:MEe,DEFAULT_SCHEMA:FEe,load:im,loadAll:ZEe,dump:vS,YAMLException:HEe,types:KEe,safeLoad:JEe,safeLoadAll:VEe,safeDump:WEe}=LW});function at(e,t){if(e instanceof Error)return e.message;return t??String(e)}function ic(e){return vS(e,{skipInvalid:!0,noRefs:!0,sortKeys:!0})}function kP(e){return im(e)}function Nn(e,t){if(!e.trim())return{ok:!1,error:"file is empty"};let r;try{r=im(e)}catch(n){return{ok:!1,error:at(n,"YAML parse error")}}if(!BW(r))return{ok:!1,error:"expected a YAML mapping (key: value pairs)"};if(!t)return{ok:!0,data:r};let i=t.safeParse(r);if(!i.success)return{ok:!1,error:`invalid field(s): ${i.error.issues.map((o)=>o.path.map(String).join(".")).join(", ")}`};return{ok:!0,data:i.data}}function BW(e){return Boolean(e)&&typeof e==="object"&&!Array.isArray(e)}var Ai=x(()=>{om()});function K(e,t,r){function i(a,c){if(!a._zod)Object.defineProperty(a,"_zod",{value:{def:c,constr:s,traits:new Set},enumerable:!1});if(a._zod.traits.has(e))return;a._zod.traits.add(e),t(a,c);let l=s.prototype,u=Object.keys(l);for(let d=0;d<u.length;d++){let p=u[d];if(!(p in a))a[p]=l[p].bind(a)}}let n=r?.Parent??Object;class o extends n{}Object.defineProperty(o,"name",{value:e});function s(a){var c;let l=r?.Parent?new o:this;i(l,a),(c=l._zod).deferred??(c.deferred=[]);for(let u of l._zod.deferred)u();return l}return Object.defineProperty(s,"init",{value:i}),Object.defineProperty(s,Symbol.hasInstance,{value:(a)=>{if(r?.Parent&&a instanceof r.Parent)return!0;return a?._zod?.traits?.has(e)}}),Object.defineProperty(s,"name",{value:e}),s}function kt(e){if(e)Object.assign(Ps,e);return Ps}var EP,kS,ES,ei,zs,Ps;var Ns=x(()=>{kS=Object.freeze({status:"aborted"});ES=Symbol("zod_brand");ei=class ei extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}};zs=class zs extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name="ZodEncodeError"}};(EP=globalThis).__zod_globalConfig??(EP.__zod_globalConfig={});Ps=globalThis.__zod_globalConfig});var ye={};tr(ye,{BIGINT_FORMAT_RANGES:()=>zS,Class:()=>CP,NUMBER_FORMAT_RANGES:()=>PS,aborted:()=>So,allowsEval:()=>CS,assert:()=>FW,assertEqual:()=>jW,assertIs:()=>UW,assertNever:()=>MW,assertNotEqual:()=>qW,assignProp:()=>bo,base64ToUint8Array:()=>AP,base64urlToUint8Array:()=>sG,cached:()=>sc,captureStackTrace:()=>am,cleanEnum:()=>oG,cleanRegex:()=>ju,clone:()=>Cr,cloneDef:()=>HW,createTransparentProxy:()=>QW,defineLazy:()=>Je,esc:()=>sm,escapeRegex:()=>gn,explicitlyAborted:()=>NS,extend:()=>eG,finalizeIssue:()=>$r,floatSafeRemainder:()=>AS,getElementAtPath:()=>KW,getEnumValues:()=>Bu,getLengthableOrigin:()=>Mu,getParsedType:()=>GW,getSizableOrigin:()=>Uu,hexToUint8Array:()=>cG,isObject:()=>Ds,isPlainObject:()=>xo,issue:()=>ac,joinValues:()=>Q,jsonStringifyReplacer:()=>oc,merge:()=>rG,mergeDefs:()=>Ti,normalizeParams:()=>xe,nullish:()=>yo,numKeys:()=>WW,objectClone:()=>ZW,omit:()=>XW,optionalKeys:()=>RS,parsedType:()=>he,partial:()=>nG,pick:()=>YW,prefixIssues:()=>Fr,primitiveTypes:()=>OS,promiseAllObject:()=>JW,propertyKeyTypes:()=>qu,randomString:()=>VW,required:()=>iG,safeExtend:()=>tG,shallowClone:()=>$S,slugify:()=>TS,stringifyPrimitive:()=>fe,uint8ArrayToBase64:()=>TP,uint8ArrayToBase64url:()=>aG,uint8ArrayToHex:()=>lG,unwrapMessage:()=>Lu});function jW(e){return e}function qW(e){return e}function UW(e){}function MW(e){throw Error("Unexpected value in exhaustive check")}function FW(e){}function Bu(e){let t=Object.values(e).filter((i)=>typeof i==="number");return Object.entries(e).filter(([i,n])=>t.indexOf(+i)===-1).map(([i,n])=>n)}function Q(e,t="|"){return e.map((r)=>fe(r)).join(t)}function oc(e,t){if(typeof t==="bigint")return t.toString();return t}function sc(e){return{get value(){{let r=e();return Object.defineProperty(this,"value",{value:r}),r}throw Error("cached value already set")}}}function yo(e){return e===null||e===void 0}function ju(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function AS(e,t){let r=e/t,i=Math.round(r),n=Number.EPSILON*Math.max(Math.abs(r),1);if(Math.abs(r-i)<n)return 0;return r-i}function Je(e,t,r){let i=void 0;Object.defineProperty(e,t,{get(){if(i===IP)return;if(i===void 0)i=IP,i=r();return i},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function ZW(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function bo(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Ti(...e){let t={};for(let r of e){let i=Object.getOwnPropertyDescriptors(r);Object.assign(t,i)}return Object.defineProperties({},t)}function HW(e){return Ti(e._zod.def)}function KW(e,t){if(!t)return e;return t.reduce((r,i)=>r?.[i],e)}function JW(e){let t=Object.keys(e),r=t.map((i)=>e[i]);return Promise.all(r).then((i)=>{let n={};for(let o=0;o<t.length;o++)n[t[o]]=i[o];return n})}function VW(e=10){let r="";for(let i=0;i<e;i++)r+="abcdefghijklmnopqrstuvwxyz"[Math.floor(Math.random()*26)];return r}function sm(e){return JSON.stringify(e)}function TS(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}function Ds(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function xo(e){if(Ds(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;if(typeof t!=="function")return!0;let r=t.prototype;if(Ds(r)===!1)return!1;if(Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)return!1;return!0}function $S(e){if(xo(e))return{...e};if(Array.isArray(e))return[...e];if(e instanceof Map)return new Map(e);if(e instanceof Set)return new Set(e);return e}function WW(e){let t=0;for(let r in e)if(Object.prototype.hasOwnProperty.call(e,r))t++;return t}function gn(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Cr(e,t,r){let i=new e._zod.constr(t??e._zod.def);if(!t||r?.parent)i._zod.parent=e;return i}function xe(e){let t=e;if(!t)return{};if(typeof t==="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}if(delete t.message,typeof t.error==="string")return{...t,error:()=>t.error};return t}function QW(e){let t;return new Proxy({},{get(r,i,n){return t??(t=e()),Reflect.get(t,i,n)},set(r,i,n,o){return t??(t=e()),Reflect.set(t,i,n,o)},has(r,i){return t??(t=e()),Reflect.has(t,i)},deleteProperty(r,i){return t??(t=e()),Reflect.deleteProperty(t,i)},ownKeys(r){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(r,i){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,i)},defineProperty(r,i,n){return t??(t=e()),Reflect.defineProperty(t,i,n)}})}function fe(e){if(typeof e==="bigint")return e.toString()+"n";if(typeof e==="string")return`"${e}"`;return`${e}`}function RS(e){return Object.keys(e).filter((t)=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}function YW(e,t){let r=e._zod.def,i=r.checks;if(i&&i.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let o=Ti(e._zod.def,{get shape(){let s={};for(let a in t){if(!(a in r.shape))throw Error(`Unrecognized key: "${a}"`);if(!t[a])continue;s[a]=r.shape[a]}return bo(this,"shape",s),s},checks:[]});return Cr(e,o)}function XW(e,t){let r=e._zod.def,i=r.checks;if(i&&i.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let o=Ti(e._zod.def,{get shape(){let s={...e._zod.def.shape};for(let a in t){if(!(a in r.shape))throw Error(`Unrecognized key: "${a}"`);if(!t[a])continue;delete s[a]}return bo(this,"shape",s),s},checks:[]});return Cr(e,o)}function eG(e,t){if(!xo(t))throw Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let o=e._zod.def.shape;for(let s in t)if(Object.getOwnPropertyDescriptor(o,s)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let n=Ti(e._zod.def,{get shape(){let o={...e._zod.def.shape,...t};return bo(this,"shape",o),o}});return Cr(e,n)}function tG(e,t){if(!xo(t))throw Error("Invalid input to safeExtend: expected a plain object");let r=Ti(e._zod.def,{get shape(){let i={...e._zod.def.shape,...t};return bo(this,"shape",i),i}});return Cr(e,r)}function rG(e,t){if(e._zod.def.checks?.length)throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let r=Ti(e._zod.def,{get shape(){let i={...e._zod.def.shape,...t._zod.def.shape};return bo(this,"shape",i),i},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return Cr(e,r)}function nG(e,t,r){let n=t._zod.def.checks;if(n&&n.length>0)throw Error(".partial() cannot be used on object schemas containing refinements");let s=Ti(t._zod.def,{get shape(){let a=t._zod.def.shape,c={...a};if(r)for(let l in r){if(!(l in a))throw Error(`Unrecognized key: "${l}"`);if(!r[l])continue;c[l]=e?new e({type:"optional",innerType:a[l]}):a[l]}else for(let l in a)c[l]=e?new e({type:"optional",innerType:a[l]}):a[l];return bo(this,"shape",c),c},checks:[]});return Cr(t,s)}function iG(e,t,r){let i=Ti(t._zod.def,{get shape(){let n=t._zod.def.shape,o={...n};if(r)for(let s in r){if(!(s in o))throw Error(`Unrecognized key: "${s}"`);if(!r[s])continue;o[s]=new e({type:"nonoptional",innerType:n[s]})}else for(let s in n)o[s]=new e({type:"nonoptional",innerType:n[s]});return bo(this,"shape",o),o}});return Cr(t,i)}function So(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function NS(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}function Fr(e,t){return t.map((r)=>{var i;return(i=r).path??(i.path=[]),r.path.unshift(e),r})}function Lu(e){return typeof e==="string"?e:e?.message}function $r(e,t,r){let i=e.message?e.message:Lu(e.inst?._zod.def?.error?.(e))??Lu(t?.error?.(e))??Lu(r.customError?.(e))??Lu(r.localeError?.(e))??"Invalid input",{inst:n,continue:o,input:s,...a}=e;if(a.path??(a.path=[]),a.message=i,t?.reportInput)a.input=s;return a}function Uu(e){if(e instanceof Set)return"set";if(e instanceof Map)return"map";if(e instanceof File)return"file";return"unknown"}function Mu(e){if(Array.isArray(e))return"array";if(typeof e==="string")return"string";return"unknown"}function he(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let r=e;if(r&&Object.getPrototypeOf(r)!==Object.prototype&&"constructor"in r&&r.constructor)return r.constructor.name}}return t}function ac(...e){let[t,r,i]=e;if(typeof t==="string")return{message:t,code:"custom",input:r,inst:i};return{...t}}function oG(e){return Object.entries(e).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map((t)=>t[1])}function AP(e){let t=atob(e),r=new Uint8Array(t.length);for(let i=0;i<t.length;i++)r[i]=t.charCodeAt(i);return r}function TP(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}function sG(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-t.length%4)%4);return AP(t+r)}function aG(e){return TP(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function cG(e){let t=e.replace(/^0x/,"");if(t.length%2!==0)throw Error("Invalid hex string length");let r=new Uint8Array(t.length/2);for(let i=0;i<t.length;i+=2)r[i/2]=Number.parseInt(t.slice(i,i+2),16);return r}function lG(e){return Array.from(e).map((t)=>t.toString(16).padStart(2,"0")).join("")}class CP{constructor(...e){}}var IP,am,CS,GW=(e)=>{let t=typeof e;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":if(Array.isArray(e))return"array";if(e===null)return"null";if(e.then&&typeof e.then==="function"&&e.catch&&typeof e.catch==="function")return"promise";if(typeof Map<"u"&&e instanceof Map)return"map";if(typeof Set<"u"&&e instanceof Set)return"set";if(typeof Date<"u"&&e instanceof Date)return"date";if(typeof File<"u"&&e instanceof File)return"file";return"object";default:throw Error(`Unknown data type: ${t}`)}},qu,OS,PS,zS;var Oe=x(()=>{Ns();IP=Symbol("evaluating");am="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};CS=sc(()=>{if(Ps.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});qu=new Set(["string","number","symbol"]),OS=new Set(["string","number","bigint","boolean","symbol","undefined"]);PS={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},zS={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]}});function Zu(e,t=(r)=>r.message){let r={},i=[];for(let n of e.issues)if(n.path.length>0)r[n.path[0]]=r[n.path[0]]||[],r[n.path[0]].push(t(n));else i.push(t(n));return{formErrors:i,fieldErrors:r}}function Hu(e,t=(r)=>r.message){let r={_errors:[]},i=(n,o=[])=>{for(let s of n.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map((a)=>i({issues:a},[...o,...s.path]));else if(s.code==="invalid_key")i({issues:s.issues},[...o,...s.path]);else if(s.code==="invalid_element")i({issues:s.issues},[...o,...s.path]);else{let a=[...o,...s.path];if(a.length===0)r._errors.push(t(s));else{let c=r,l=0;while(l<a.length){let u=a[l];if(l!==a.length-1)c[u]=c[u]||{_errors:[]};else c[u]=c[u]||{_errors:[]},c[u]._errors.push(t(s));c=c[u],l++}}}};return i(e),r}function DS(e,t=(r)=>r.message){let r={errors:[]},i=(n,o=[])=>{var s,a;for(let c of n.issues)if(c.code==="invalid_union"&&c.errors.length)c.errors.map((l)=>i({issues:l},[...o,...c.path]));else if(c.code==="invalid_key")i({issues:c.issues},[...o,...c.path]);else if(c.code==="invalid_element")i({issues:c.issues},[...o,...c.path]);else{let l=[...o,...c.path];if(l.length===0){r.errors.push(t(c));continue}let u=r,d=0;while(d<l.length){let p=l[d],m=d===l.length-1;if(typeof p==="string")u.properties??(u.properties={}),(s=u.properties)[p]??(s[p]={errors:[]}),u=u.properties[p];else u.items??(u.items=[]),(a=u.items)[p]??(a[p]={errors:[]}),u=u.items[p];if(m)u.errors.push(t(c));d++}}};return i(e),r}function OP(e){let t=[],r=e.map((i)=>typeof i==="object"?i.key:i);for(let i of r)if(typeof i==="number")t.push(`[${i}]`);else if(typeof i==="symbol")t.push(`[${JSON.stringify(String(i))}]`);else if(/[^\w$]/.test(i))t.push(`[${JSON.stringify(i)}]`);else{if(t.length)t.push(".");t.push(i)}return t.join("")}function LS(e){let t=[],r=[...e.issues].sort((i,n)=>(i.path??[]).length-(n.path??[]).length);for(let i of r)if(t.push(`\u2716 ${i.message}`),i.path?.length)t.push(` \u2192 at ${OP(i.path)}`);return t.join(`
144
144
  `)}var $P=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,oc,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Fu,Zr;var BS=x(()=>{Ns();Oe();Fu=K("$ZodError",$P),Zr=K("$ZodError",$P,{Parent:Error})});var cc=(e)=>(t,r,i,n)=>{let o=i?{...i,async:!1}:{async:!1},s=t._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new ei;if(s.issues.length){let a=new(n?.Err??e)(s.issues.map((c)=>$r(c,o,kt())));throw am(a,n?.callee),a}return s.value},cm,lc=(e)=>async(t,r,i,n)=>{let o=i?{...i,async:!0}:{async:!0},s=t._zod.run({value:r,issues:[]},o);if(s instanceof Promise)s=await s;if(s.issues.length){let a=new(n?.Err??e)(s.issues.map((c)=>$r(c,o,kt())));throw am(a,n?.callee),a}return s.value},lm,uc=(e)=>(t,r,i)=>{let n=i?{...i,async:!1}:{async:!1},o=t._zod.run({value:r,issues:[]},n);if(o instanceof Promise)throw new ei;return o.issues.length?{success:!1,error:new(e??Fu)(o.issues.map((s)=>$r(s,n,kt())))}:{success:!0,data:o.value}},jS,dc=(e)=>async(t,r,i)=>{let n=i?{...i,async:!0}:{async:!0},o=t._zod.run({value:r,issues:[]},n);if(o instanceof Promise)o=await o;return o.issues.length?{success:!1,error:new e(o.issues.map((s)=>$r(s,n,kt())))}:{success:!0,data:o.value}},qS,um=(e)=>(t,r,i)=>{let n=i?{...i,direction:"backward"}:{direction:"backward"};return cc(e)(t,r,n)},dG,dm=(e)=>(t,r,i)=>cc(e)(t,r,i),fG,fm=(e)=>async(t,r,i)=>{let n=i?{...i,direction:"backward"}:{direction:"backward"};return lc(e)(t,r,n)},pG,pm=(e)=>async(t,r,i)=>lc(e)(t,r,i),mG,mm=(e)=>(t,r,i)=>{let n=i?{...i,direction:"backward"}:{direction:"backward"};return uc(e)(t,r,n)},hG,hm=(e)=>(t,r,i)=>uc(e)(t,r,i),gG,gm=(e)=>async(t,r,i)=>{let n=i?{...i,direction:"backward"}:{direction:"backward"};return dc(e)(t,r,n)},yG,ym=(e)=>async(t,r,i)=>dc(e)(t,r,i),bG;var US=x(()=>{Ns();BS();Oe();cm=cc(Zr),lm=lc(Zr),jS=uc(Zr),qS=dc(Zr),dG=um(Zr),fG=dm(Zr),pG=fm(Zr),mG=pm(Zr),hG=mm(Zr),gG=hm(Zr),yG=gm(Zr),bG=ym(Zr)});var en={};tr(en,{base64:()=>nw,base64url:()=>bm,bigint:()=>uw,boolean:()=>fw,browserEmail:()=>IG,cidrv4:()=>tw,cidrv6:()=>rw,cuid:()=>MS,cuid2:()=>FS,date:()=>sw,datetime:()=>cw,domain:()=>CG,duration:()=>VS,e164:()=>ow,email:()=>GS,emoji:()=>QS,extendedDuration:()=>xG,guid:()=>WS,hex:()=>$G,hostname:()=>TG,html5Email:()=>_G,httpProtocol:()=>iw,idnEmail:()=>EG,integer:()=>dw,ipv4:()=>YS,ipv6:()=>XS,ksuid:()=>KS,lowercase:()=>hw,mac:()=>ew,md5_base64:()=>RG,md5_base64url:()=>PG,md5_hex:()=>OG,nanoid:()=>JS,null:()=>pw,number:()=>Ku,rfc5322Email:()=>kG,sha1_base64:()=>NG,sha1_base64url:()=>DG,sha1_hex:()=>zG,sha256_base64:()=>BG,sha256_base64url:()=>jG,sha256_hex:()=>LG,sha384_base64:()=>UG,sha384_base64url:()=>MG,sha384_hex:()=>qG,sha512_base64:()=>ZG,sha512_base64url:()=>HG,sha512_hex:()=>FG,string:()=>lw,time:()=>aw,ulid:()=>ZS,undefined:()=>mw,unicodeEmail:()=>RP,uppercase:()=>gw,uuid:()=>Ls,uuid4:()=>SG,uuid6:()=>wG,uuid7:()=>vG,xid:()=>HS});function QS(){return new RegExp(AG,"u")}function zP(e){return typeof e.precision==="number"?e.precision===-1?"(?:[01]\\d|2[0-3]):[0-5]\\d":e.precision===0?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d":`(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{${e.precision}}`:"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function aw(e){return new RegExp(`^${zP(e)}$`)}function cw(e){let t=zP({precision:e.precision}),r=["Z"];if(e.local)r.push("");if(e.offset)r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let i=`${t}(?:${r.join("|")})`;return new RegExp(`^${PP}T(?:${i})$`)}function Ju(e,t){return new RegExp(`^[A-Za-z0-9+/]{${e}}${t}$`)}function Vu(e){return new RegExp(`^[A-Za-z0-9_-]{${e}}$`)}var MS,FS,ZS,HS,KS,JS,VS,xG,WS,Ls=(e)=>{if(!e)return/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)},SG,wG,vG,GS,_G,kG,RP,EG,IG,AG="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",YS,XS,ew=(e)=>{let t=gn(e??":");return new RegExp(`^(?:[0-9A-F]{2}${t}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${t}){5}[0-9a-f]{2}$`)},tw,rw,nw,bm,TG,CG,iw,ow,PP="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",sw,lw=(e)=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},uw,dw,Ku,fw,pw,mw,hw,gw,$G,OG,RG,PG,zG,NG,DG,LG,BG,jG,qG,UG,MG,FG,ZG,HG;var xm=x(()=>{Oe();MS=/^[cC][0-9a-z]{6,}$/,FS=/^[0-9a-z]+$/,ZS=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,HS=/^[0-9a-vA-V]{20}$/,KS=/^[A-Za-z0-9]{27}$/,JS=/^[a-zA-Z0-9_-]{21}$/,VS=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,xG=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,WS=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,SG=Ls(4),wG=Ls(6),vG=Ls(7),GS=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,_G=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,kG=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,RP=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,EG=RP,IG=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;YS=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,XS=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,tw=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,rw=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,nw=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,bm=/^[A-Za-z0-9_-]*$/,TG=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,CG=/^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,iw=/^https?$/,ow=/^\+[1-9]\d{6,14}$/,sw=new RegExp(`^${PP}$`);uw=/^-?\d+n?$/,dw=/^-?\d+$/,Ku=/^-?\d+(?:\.\d+)?$/,fw=/^(?:true|false)$/i,pw=/^null$/i,mw=/^undefined$/i,hw=/^[^A-Z]*$/,gw=/^[^a-z]*$/,$G=/^[0-9a-fA-F]*$/;OG=/^[0-9a-fA-F]{32}$/,RG=Ju(22,"=="),PG=Vu(22),zG=/^[0-9a-fA-F]{40}$/,NG=Ju(27,"="),DG=Vu(27),LG=/^[0-9a-fA-F]{64}$/,BG=Ju(43,"="),jG=Vu(43),qG=/^[0-9a-fA-F]{96}$/,UG=Ju(64,""),MG=Vu(64),FG=/^[0-9a-fA-F]{128}$/,ZG=Ju(86,"=="),HG=Vu(86)});function NP(e,t,r){if(e.issues.length)t.issues.push(...Fr(r,e.issues))}var dt,DP,Sm,wm,yw,bw,xw,Sw,ww,vw,_w,kw,Ew,fc,Iw,Aw,Tw,Cw,$w,Ow,Rw,Pw,zw;var vm=x(()=>{Ns();xm();Oe();dt=K("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),DP={number:"number",bigint:"bigint",object:"date"},Sm=K("$ZodCheckLessThan",(e,t)=>{dt.init(e,t);let r=DP[typeof t.value];e._zod.onattach.push((i)=>{let n=i._zod.bag,o=(t.inclusive?n.maximum:n.exclusiveMaximum)??Number.POSITIVE_INFINITY;if(t.value<o)if(t.inclusive)n.maximum=t.value;else n.exclusiveMaximum=t.value}),e._zod.check=(i)=>{if(t.inclusive?i.value<=t.value:i.value<t.value)return;i.issues.push({origin:r,code:"too_big",maximum:typeof t.value==="object"?t.value.getTime():t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),wm=K("$ZodCheckGreaterThan",(e,t)=>{dt.init(e,t);let r=DP[typeof t.value];e._zod.onattach.push((i)=>{let n=i._zod.bag,o=(t.inclusive?n.minimum:n.exclusiveMinimum)??Number.NEGATIVE_INFINITY;if(t.value>o)if(t.inclusive)n.minimum=t.value;else n.exclusiveMinimum=t.value}),e._zod.check=(i)=>{if(t.inclusive?i.value>=t.value:i.value>t.value)return;i.issues.push({origin:r,code:"too_small",minimum:typeof t.value==="object"?t.value.getTime():t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),yw=K("$ZodCheckMultipleOf",(e,t)=>{dt.init(e,t),e._zod.onattach.push((r)=>{var i;(i=r._zod.bag).multipleOf??(i.multipleOf=t.value)}),e._zod.check=(r)=>{if(typeof r.value!==typeof t.value)throw Error("Cannot mix number and bigint in multiple_of check.");if(typeof r.value==="bigint"?r.value%t.value===BigInt(0):AS(r.value,t.value)===0)return;r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),bw=K("$ZodCheckNumberFormat",(e,t)=>{dt.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),i=r?"int":"number",[n,o]=PS[t.format];e._zod.onattach.push((s)=>{let a=s._zod.bag;if(a.format=t.format,a.minimum=n,a.maximum=o,r)a.pattern=dw}),e._zod.check=(s)=>{let a=s.value;if(r){if(!Number.isInteger(a)){s.issues.push({expected:i,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){if(a>0)s.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:i,inclusive:!0,continue:!t.abort});else s.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:i,inclusive:!0,continue:!t.abort});return}}if(a<n)s.issues.push({origin:"number",input:a,code:"too_small",minimum:n,inclusive:!0,inst:e,continue:!t.abort});if(a>o)s.issues.push({origin:"number",input:a,code:"too_big",maximum:o,inclusive:!0,inst:e,continue:!t.abort})}}),xw=K("$ZodCheckBigIntFormat",(e,t)=>{dt.init(e,t);let[r,i]=zS[t.format];e._zod.onattach.push((n)=>{let o=n._zod.bag;o.format=t.format,o.minimum=r,o.maximum=i}),e._zod.check=(n)=>{let o=n.value;if(o<r)n.issues.push({origin:"bigint",input:o,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort});if(o>i)n.issues.push({origin:"bigint",input:o,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}}),Sw=K("$ZodCheckMaxSize",(e,t)=>{var r;dt.init(e,t),(r=e._zod.def).when??(r.when=(i)=>{let n=i.value;return!yo(n)&&n.size!==void 0}),e._zod.onattach.push((i)=>{let n=i._zod.bag.maximum??Number.POSITIVE_INFINITY;if(t.maximum<n)i._zod.bag.maximum=t.maximum}),e._zod.check=(i)=>{let n=i.value;if(n.size<=t.maximum)return;i.issues.push({origin:Uu(n),code:"too_big",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),ww=K("$ZodCheckMinSize",(e,t)=>{var r;dt.init(e,t),(r=e._zod.def).when??(r.when=(i)=>{let n=i.value;return!yo(n)&&n.size!==void 0}),e._zod.onattach.push((i)=>{let n=i._zod.bag.minimum??Number.NEGATIVE_INFINITY;if(t.minimum>n)i._zod.bag.minimum=t.minimum}),e._zod.check=(i)=>{let n=i.value;if(n.size>=t.minimum)return;i.issues.push({origin:Uu(n),code:"too_small",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),vw=K("$ZodCheckSizeEquals",(e,t)=>{var r;dt.init(e,t),(r=e._zod.def).when??(r.when=(i)=>{let n=i.value;return!yo(n)&&n.size!==void 0}),e._zod.onattach.push((i)=>{let n=i._zod.bag;n.minimum=t.size,n.maximum=t.size,n.size=t.size}),e._zod.check=(i)=>{let n=i.value,o=n.size;if(o===t.size)return;let s=o>t.size;i.issues.push({origin:Uu(n),...s?{code:"too_big",maximum:t.size}:{code:"too_small",minimum:t.size},inclusive:!0,exact:!0,input:i.value,inst:e,continue:!t.abort})}}),_w=K("$ZodCheckMaxLength",(e,t)=>{var r;dt.init(e,t),(r=e._zod.def).when??(r.when=(i)=>{let n=i.value;return!yo(n)&&n.length!==void 0}),e._zod.onattach.push((i)=>{let n=i._zod.bag.maximum??Number.POSITIVE_INFINITY;if(t.maximum<n)i._zod.bag.maximum=t.maximum}),e._zod.check=(i)=>{let n=i.value;if(n.length<=t.maximum)return;let s=Mu(n);i.issues.push({origin:s,code:"too_big",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),kw=K("$ZodCheckMinLength",(e,t)=>{var r;dt.init(e,t),(r=e._zod.def).when??(r.when=(i)=>{let n=i.value;return!yo(n)&&n.length!==void 0}),e._zod.onattach.push((i)=>{let n=i._zod.bag.minimum??Number.NEGATIVE_INFINITY;if(t.minimum>n)i._zod.bag.minimum=t.minimum}),e._zod.check=(i)=>{let n=i.value;if(n.length>=t.minimum)return;let s=Mu(n);i.issues.push({origin:s,code:"too_small",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),Ew=K("$ZodCheckLengthEquals",(e,t)=>{var r;dt.init(e,t),(r=e._zod.def).when??(r.when=(i)=>{let n=i.value;return!yo(n)&&n.length!==void 0}),e._zod.onattach.push((i)=>{let n=i._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=(i)=>{let n=i.value,o=n.length;if(o===t.length)return;let s=Mu(n),a=o>t.length;i.issues.push({origin:s,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:i.value,inst:e,continue:!t.abort})}}),fc=K("$ZodCheckStringFormat",(e,t)=>{var r,i;if(dt.init(e,t),e._zod.onattach.push((n)=>{let o=n._zod.bag;if(o.format=t.format,t.pattern)o.patterns??(o.patterns=new Set),o.patterns.add(t.pattern)}),t.pattern)(r=e._zod).check??(r.check=(n)=>{if(t.pattern.lastIndex=0,t.pattern.test(n.value))return;n.issues.push({origin:"string",code:"invalid_format",format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})});else(i=e._zod).check??(i.check=()=>{})}),Iw=K("$ZodCheckRegex",(e,t)=>{fc.init(e,t),e._zod.check=(r)=>{if(t.pattern.lastIndex=0,t.pattern.test(r.value))return;r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Aw=K("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=hw),fc.init(e,t)}),Tw=K("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=gw),fc.init(e,t)}),Cw=K("$ZodCheckIncludes",(e,t)=>{dt.init(e,t);let r=gn(t.includes),i=new RegExp(typeof t.position==="number"?`^.{${t.position}}${r}`:r);t.pattern=i,e._zod.onattach.push((n)=>{let o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(i)}),e._zod.check=(n)=>{if(n.value.includes(t.includes,t.position))return;n.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),$w=K("$ZodCheckStartsWith",(e,t)=>{dt.init(e,t);let r=new RegExp(`^${gn(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push((i)=>{let n=i._zod.bag;n.patterns??(n.patterns=new Set),n.patterns.add(r)}),e._zod.check=(i)=>{if(i.value.startsWith(t.prefix))return;i.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:i.value,inst:e,continue:!t.abort})}}),Ow=K("$ZodCheckEndsWith",(e,t)=>{dt.init(e,t);let r=new RegExp(`.*${gn(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push((i)=>{let n=i._zod.bag;n.patterns??(n.patterns=new Set),n.patterns.add(r)}),e._zod.check=(i)=>{if(i.value.endsWith(t.suffix))return;i.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:i.value,inst:e,continue:!t.abort})}});Rw=K("$ZodCheckProperty",(e,t)=>{dt.init(e,t),e._zod.check=(r)=>{let i=t.schema._zod.run({value:r.value[t.property],issues:[]},{});if(i instanceof Promise)return i.then((n)=>NP(n,r,t.property));NP(i,r,t.property);return}}),Pw=K("$ZodCheckMimeType",(e,t)=>{dt.init(e,t);let r=new Set(t.mime);e._zod.onattach.push((i)=>{i._zod.bag.mime=t.mime}),e._zod.check=(i)=>{if(r.has(i.value.type))return;i.issues.push({code:"invalid_value",values:t.mime,input:i.value.type,inst:e,continue:!t.abort})}}),zw=K("$ZodCheckOverwrite",(e,t)=>{dt.init(e,t),e._zod.check=(r)=>{r.value=t.tx(r.value)}})});class _m{constructor(e=[]){if(this.content=[],this.indent=0,this)this.args=e}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e==="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let r=e.split(`
145
145
  `).filter((o)=>o),i=Math.min(...r.map((o)=>o.length-o.trimStart().length)),n=r.map((o)=>o.slice(i)).map((o)=>" ".repeat(this.indent*2)+o);for(let o of n)this.content.push(o)}compile(){let e=Function,t=this?.args,i=[...(this?.content??[""]).map((n)=>` ${n}`)];return new e(...t,i.join(`
146
146
  `))}}var Nw;var Dw=x(()=>{Nw={major:4,minor:4,patch:3}});function i0(e){if(e==="")return!0;if(/\s/.test(e))return!1;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}function YP(e){if(!bm.test(e))return!1;let t=e.replace(/[-_]/g,(i)=>i==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return i0(r)}function XP(e,t=null){try{let r=e.split(".");if(r.length!==3)return!1;let[i]=r;if(!i)return!1;let n=JSON.parse(atob(i));if("typ"in n&&n?.typ!=="JWT")return!1;if(!n.alg)return!1;if(t&&(!("alg"in n)||n.alg!==t))return!1;return!0}catch{return!1}}function BP(e,t,r){if(e.issues.length)t.issues.push(...Fr(r,e.issues));t.value[r]=e.value}function Am(e,t,r,i,n,o){let s=r in i;if(e.issues.length){if(n&&o&&!s)return;t.issues.push(...Fr(r,e.issues))}if(!s&&!n){if(!e.issues.length)t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}if(e.value===void 0){if(s)t.value[r]=void 0}else t.value[r]=e.value}function ez(e){let t=Object.keys(e.shape);for(let i of t)if(!e.shape?.[i]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${i}": expected a Zod schema`);let r=RS(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function tz(e,t,r,i,n,o){let s=[],a=n.keySet,c=n.catchall._zod,l=c.def.type,u=c.optin==="optional",d=c.optout==="optional";for(let p in t){if(p==="__proto__")continue;if(a.has(p))continue;if(l==="never"){s.push(p);continue}let m=c.run({value:t[p],issues:[]},i);if(m instanceof Promise)e.push(m.then((y)=>Am(y,r,p,t,u,d)));else Am(m,r,p,t,u,d)}if(s.length)r.issues.push({code:"unrecognized_keys",keys:s,input:t,inst:o});if(!e.length)return r;return Promise.all(e).then(()=>r)}function jP(e,t,r,i){for(let o of e)if(o.issues.length===0)return t.value=o.value,t;let n=e.filter((o)=>!So(o));if(n.length===1)return t.value=n[0].value,n[0];return t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map((o)=>o.issues.map((s)=>$r(s,i,kt())))}),t}function qP(e,t,r,i){let n=e.filter((o)=>o.issues.length===0);if(n.length===1)return t.value=n[0].value,t;if(n.length===0)t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map((o)=>o.issues.map((s)=>$r(s,i,kt())))});else t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:[],inclusive:!1});return t}function Lw(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e===+t)return{valid:!0,data:e};if(xo(e)&&xo(t)){let r=Object.keys(t),i=Object.keys(e).filter((o)=>r.indexOf(o)!==-1),n={...e,...t};for(let o of i){let s=Lw(e[o],t[o]);if(!s.valid)return{valid:!1,mergeErrorPath:[o,...s.mergeErrorPath]};n[o]=s.data}return{valid:!0,data:n}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let i=0;i<e.length;i++){let n=e[i],o=t[i],s=Lw(n,o);if(!s.valid)return{valid:!1,mergeErrorPath:[i,...s.mergeErrorPath]};r.push(s.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function UP(e,t,r){let i=new Map,n;for(let a of t.issues)if(a.code==="unrecognized_keys"){n??(n=a);for(let c of a.keys){if(!i.has(c))i.set(c,{});i.get(c).l=!0}}else e.issues.push(a);for(let a of r.issues)if(a.code==="unrecognized_keys")for(let c of a.keys){if(!i.has(c))i.set(c,{});i.get(c).r=!0}else e.issues.push(a);let o=[...i].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(o.length&&n)e.issues.push({...n,keys:o});if(So(e))return e;let s=Lw(t.value,r.value);if(!s.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(s.mergeErrorPath)}`);return e.value=s.data,e}function MP(e,t){for(let r=e.length-1;r>=0;r--)if(e[r]._zod[t]!=="optional")return r+1;return 0}function FP(e,t,r){if(e.issues.length)t.issues.push(...Fr(r,e.issues));t.value[r]=e.value}function ZP(e,t,r,i,n){for(let o=0;o<r.length;o++){let s=e[o],a=o<i.length;if(s.issues.length){if(!a&&o>=n){t.value.length=o;break}t.issues.push(...Fr(o,s.issues))}t.value[o]=s.value}for(let o=t.value.length-1;o>=i.length;o--)if(r[o]._zod.optout==="optional"&&t.value[o]===void 0)t.value.length=o;else break;return t}function HP(e,t,r,i,n,o,s){if(e.issues.length)if(qu.has(typeof i))r.issues.push(...Fr(i,e.issues));else r.issues.push({code:"invalid_key",origin:"map",input:n,inst:o,issues:e.issues.map((a)=>$r(a,s,kt()))});if(t.issues.length)if(qu.has(typeof i))r.issues.push(...Fr(i,t.issues));else r.issues.push({origin:"map",code:"invalid_element",input:n,inst:o,key:i,issues:t.issues.map((a)=>$r(a,s,kt()))});r.value.set(e.value,t.value)}function KP(e,t){if(e.issues.length)t.issues.push(...e.issues);t.value.add(e.value)}function JP(e,t){if(t===void 0&&(e.issues.length||e.fallback))return{issues:[],value:void 0};return e}function VP(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}function WP(e,t){if(!e.issues.length&&e.value===void 0)e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t});return e}function km(e,t,r){if(e.issues.length)return e.aborted=!0,e;return t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},r)}function Em(e,t,r){if(e.issues.length)return e.aborted=!0,e;if((r.direction||"forward")==="forward"){let n=t.transform(e.value,e);if(n instanceof Promise)return n.then((o)=>Im(e,o,t.out,r));return Im(e,n,t.out,r)}else{let n=t.reverseTransform(e.value,e);if(n instanceof Promise)return n.then((o)=>Im(e,o,t.in,r));return Im(e,n,t.in,r)}}function Im(e,t,r,i){if(e.issues.length)return e.aborted=!0,e;return r._zod.run({value:t,issues:e.issues},i)}function GP(e){return e.value=Object.freeze(e.value),e}function QP(e,t,r,i){if(!e){let n={code:"custom",input:r,inst:i,path:[...i._zod.def.path??[]],continue:!i._zod.def.abort};if(i._zod.def.params)n.params=i._zod.def.params;t.issues.push(ac(n))}}var Ue,Bs,ct,Bw,jw,qw,Uw,Mw,Fw,Zw,Hw,Kw,Jw,Vw,Ww,Gw,Qw,Yw,Xw,e0,t0,r0,n0,o0,s0,a0,c0,l0,Tm,u0,Wu,Cm,d0,f0,p0,m0,h0,g0,y0,b0,x0,S0,rz,w0,Gu,v0,_0,k0,$m,E0,I0,A0,T0,C0,$0,O0,Om,R0,P0,z0,N0,D0,L0,B0,j0,Rm,Qu,q0,U0,M0,F0,Z0,H0,K0;var J0=x(()=>{vm();Ns();US();xm();Oe();Dw();Oe();Ue=K("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Nw;let i=[...e._zod.def.checks??[]];if(e._zod.traits.has("$ZodCheck"))i.unshift(e);for(let n of i)for(let o of n._zod.onattach)o(e);if(i.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let n=(s,a,c)=>{let l=So(s),u;for(let d of a){if(d._zod.def.when){if(NS(s))continue;if(!d._zod.def.when(s))continue}else if(l)continue;let p=s.issues.length,m=d._zod.check(s);if(m instanceof Promise&&c?.async===!1)throw new ei;if(u||m instanceof Promise)u=(u??Promise.resolve()).then(async()=>{if(await m,s.issues.length===p)return;if(!l)l=So(s,p)});else{if(s.issues.length===p)continue;if(!l)l=So(s,p)}}if(u)return u.then(()=>s);return s},o=(s,a,c)=>{if(So(s))return s.aborted=!0,s;let l=n(a,i,c);if(l instanceof Promise){if(c.async===!1)throw new ei;return l.then((u)=>e._zod.parse(u,c))}return e._zod.parse(l,c)};e._zod.run=(s,a)=>{if(a.skipChecks)return e._zod.parse(s,a);if(a.direction==="backward"){let l=e._zod.parse({value:s.value,issues:[]},{...a,skipChecks:!0});if(l instanceof Promise)return l.then((u)=>o(u,s,a));return o(l,s,a)}let c=e._zod.parse(s,a);if(c instanceof Promise){if(a.async===!1)throw new ei;return c.then((l)=>n(l,i,a))}return n(c,i,a)}}Je(e,"~standard",()=>({validate:(n)=>{try{let o=jS(e,n);return o.success?{value:o.data}:{issues:o.error?.issues}}catch(o){return qS(e,n).then((s)=>s.success?{value:s.data}:{issues:s.error?.issues})}},vendor:"zod",version:1}))}),Bs=K("$ZodString",(e,t)=>{Ue.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??lw(e._zod.bag),e._zod.parse=(r,i)=>{if(t.coerce)try{r.value=String(r.value)}catch(n){}if(typeof r.value==="string")return r;return r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),ct=K("$ZodStringFormat",(e,t)=>{fc.init(e,t),Bs.init(e,t)}),Bw=K("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=WS),ct.init(e,t)}),jw=K("$ZodUUID",(e,t)=>{if(t.version){let i={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(i===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Ls(i))}else t.pattern??(t.pattern=Ls());ct.init(e,t)}),qw=K("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=GS),ct.init(e,t)}),Uw=K("$ZodURL",(e,t)=>{ct.init(e,t),e._zod.check=(r)=>{try{let i=r.value.trim();if(!t.normalize&&t.protocol?.source===iw.source){if(!/^https?:\/\//i.test(i)){r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});return}}let n=new URL(i);if(t.hostname){if(t.hostname.lastIndex=0,!t.hostname.test(n.hostname))r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort})}if(t.protocol){if(t.protocol.lastIndex=0,!t.protocol.test(n.protocol.endsWith(":")?n.protocol.slice(0,-1):n.protocol))r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort})}if(t.normalize)r.value=n.href;else r.value=i;return}catch(i){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),Mw=K("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=QS()),ct.init(e,t)}),Fw=K("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=JS),ct.init(e,t)}),Zw=K("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=MS),ct.init(e,t)}),Hw=K("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=FS),ct.init(e,t)}),Kw=K("$ZodULID",(e,t)=>{t.pattern??(t.pattern=ZS),ct.init(e,t)}),Jw=K("$ZodXID",(e,t)=>{t.pattern??(t.pattern=HS),ct.init(e,t)}),Vw=K("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=KS),ct.init(e,t)}),Ww=K("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=cw(t)),ct.init(e,t)}),Gw=K("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=sw),ct.init(e,t)}),Qw=K("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=aw(t)),ct.init(e,t)}),Yw=K("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=VS),ct.init(e,t)}),Xw=K("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=YS),ct.init(e,t),e._zod.bag.format="ipv4"}),e0=K("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=XS),ct.init(e,t),e._zod.bag.format="ipv6",e._zod.check=(r)=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}}),t0=K("$ZodMAC",(e,t)=>{t.pattern??(t.pattern=ew(t.delimiter)),ct.init(e,t),e._zod.bag.format="mac"}),r0=K("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=tw),ct.init(e,t)}),n0=K("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=rw),ct.init(e,t),e._zod.check=(r)=>{let i=r.value.split("/");try{if(i.length!==2)throw Error();let[n,o]=i;if(!o)throw Error();let s=Number(o);if(`${s}`!==o)throw Error();if(s<0||s>128)throw Error();new URL(`http://[${n}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}});o0=K("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=nw),ct.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=(r)=>{if(i0(r.value))return;r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});s0=K("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=bm),ct.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=(r)=>{if(YP(r.value))return;r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),a0=K("$ZodE164",(e,t)=>{t.pattern??(t.pattern=ow),ct.init(e,t)});c0=K("$ZodJWT",(e,t)=>{ct.init(e,t),e._zod.check=(r)=>{if(XP(r.value,t.alg))return;r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),l0=K("$ZodCustomStringFormat",(e,t)=>{ct.init(e,t),e._zod.check=(r)=>{if(t.fn(r.value))return;r.issues.push({code:"invalid_format",format:t.format,input:r.value,inst:e,continue:!t.abort})}}),Tm=K("$ZodNumber",(e,t)=>{Ue.init(e,t),e._zod.pattern=e._zod.bag.pattern??Ku,e._zod.parse=(r,i)=>{if(t.coerce)try{r.value=Number(r.value)}catch(s){}let n=r.value;if(typeof n==="number"&&!Number.isNaN(n)&&Number.isFinite(n))return r;let o=typeof n==="number"?Number.isNaN(n)?"NaN":!Number.isFinite(n)?"Infinity":void 0:void 0;return r.issues.push({expected:"number",code:"invalid_type",input:n,inst:e,...o?{received:o}:{}}),r}}),u0=K("$ZodNumberFormat",(e,t)=>{bw.init(e,t),Tm.init(e,t)}),Wu=K("$ZodBoolean",(e,t)=>{Ue.init(e,t),e._zod.pattern=fw,e._zod.parse=(r,i)=>{if(t.coerce)try{r.value=Boolean(r.value)}catch(o){}let n=r.value;if(typeof n==="boolean")return r;return r.issues.push({expected:"boolean",code:"invalid_type",input:n,inst:e}),r}}),Cm=K("$ZodBigInt",(e,t)=>{Ue.init(e,t),e._zod.pattern=uw,e._zod.parse=(r,i)=>{if(t.coerce)try{r.value=BigInt(r.value)}catch(n){}if(typeof r.value==="bigint")return r;return r.issues.push({expected:"bigint",code:"invalid_type",input:r.value,inst:e}),r}}),d0=K("$ZodBigIntFormat",(e,t)=>{xw.init(e,t),Cm.init(e,t)}),f0=K("$ZodSymbol",(e,t)=>{Ue.init(e,t),e._zod.parse=(r,i)=>{let n=r.value;if(typeof n==="symbol")return r;return r.issues.push({expected:"symbol",code:"invalid_type",input:n,inst:e}),r}}),p0=K("$ZodUndefined",(e,t)=>{Ue.init(e,t),e._zod.pattern=mw,e._zod.values=new Set([void 0]),e._zod.parse=(r,i)=>{let n=r.value;if(typeof n>"u")return r;return r.issues.push({expected:"undefined",code:"invalid_type",input:n,inst:e}),r}}),m0=K("$ZodNull",(e,t)=>{Ue.init(e,t),e._zod.pattern=pw,e._zod.values=new Set([null]),e._zod.parse=(r,i)=>{let n=r.value;if(n===null)return r;return r.issues.push({expected:"null",code:"invalid_type",input:n,inst:e}),r}}),h0=K("$ZodAny",(e,t)=>{Ue.init(e,t),e._zod.parse=(r)=>r}),g0=K("$ZodUnknown",(e,t)=>{Ue.init(e,t),e._zod.parse=(r)=>r}),y0=K("$ZodNever",(e,t)=>{Ue.init(e,t),e._zod.parse=(r,i)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)}),b0=K("$ZodVoid",(e,t)=>{Ue.init(e,t),e._zod.parse=(r,i)=>{let n=r.value;if(typeof n>"u")return r;return r.issues.push({expected:"void",code:"invalid_type",input:n,inst:e}),r}}),x0=K("$ZodDate",(e,t)=>{Ue.init(e,t),e._zod.parse=(r,i)=>{if(t.coerce)try{r.value=new Date(r.value)}catch(a){}let n=r.value,o=n instanceof Date;if(o&&!Number.isNaN(n.getTime()))return r;return r.issues.push({expected:"date",code:"invalid_type",input:n,...o?{received:"Invalid Date"}:{},inst:e}),r}});S0=K("$ZodArray",(e,t)=>{Ue.init(e,t),e._zod.parse=(r,i)=>{let n=r.value;if(!Array.isArray(n))return r.issues.push({expected:"array",code:"invalid_type",input:n,inst:e}),r;r.value=Array(n.length);let o=[];for(let s=0;s<n.length;s++){let a=n[s],c=t.element._zod.run({value:a,issues:[]},i);if(c instanceof Promise)o.push(c.then((l)=>BP(l,r,s)));else BP(c,r,s)}if(o.length)return Promise.all(o).then(()=>r);return r}});rz=K("$ZodObject",(e,t)=>{if(Ue.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){let a=t.shape;Object.defineProperty(t,"shape",{get:()=>{let c={...a};return Object.defineProperty(t,"shape",{value:c}),c}})}let i=sc(()=>ez(t));Je(e._zod,"propValues",()=>{let a=t.shape,c={};for(let l in a){let u=a[l]._zod;if(u.values){c[l]??(c[l]=new Set);for(let d of u.values)c[l].add(d)}}return c});let n=Ds,o=t.catchall,s;e._zod.parse=(a,c)=>{s??(s=i.value);let l=a.value;if(!n(l))return a.issues.push({expected:"object",code:"invalid_type",input:l,inst:e}),a;a.value={};let u=[],d=s.shape;for(let p of s.keys){let m=d[p],y=m._zod.optin==="optional",g=m._zod.optout==="optional",b=m._zod.run({value:l[p],issues:[]},c);if(b instanceof Promise)u.push(b.then((v)=>Am(v,a,p,l,y,g)));else Am(b,a,p,l,y,g)}if(!o)return u.length?Promise.all(u).then(()=>a):a;return tz(u,l,a,c,i.value,e)}}),w0=K("$ZodObjectJIT",(e,t)=>{rz.init(e,t);let r=e._zod.parse,i=sc(()=>ez(t)),n=(p)=>{let m=new _m(["shape","payload","ctx"]),y=i.value,g=(T)=>{let z=sm(T);return`shape[${z}]._zod.run({ value: input[${z}], issues: [] }, ctx)`};m.write("const input = payload.value;");let b=Object.create(null),v=0;for(let T of y.keys)b[T]=`key_${v++}`;m.write("const newResult = {};");for(let T of y.keys){let z=b[T],j=sm(T),E=p[T],Z=E?._zod?.optin==="optional",D=E?._zod?.optout==="optional";if(m.write(`const ${z} = ${g(T)};`),Z&&D)m.write(`
@@ -218,22 +218,22 @@ for (const spec of specs) {
218
218
  }
219
219
  }
220
220
  `;var MN=x(()=>{Pi()});import{createHash as wX}from"crypto";function Ed(e,t=[]){let r=`brain-${e}`,i=[...t].sort();if(i.length===0)return r;let n=`${r}--${i.map((s)=>s.replace(/^@/,"").replace("/","-").replace(/@(?=[^@]*$)/,"-")).join("--")}`;if(n.length<=vX)return n;let o=wX("sha256").update(i.join(`
221
- `)).digest("hex");return`${r}--s${o.slice(0,12)}`}function Hh(e){if(!e)return[];if(!e.theme?.startsWith("@rizom/"))return[`${e.package}@${e.version}`];if(e.themeVersion===void 0)throw Error(`Theme ${e.theme} has no explicit version pin`);return[`${e.package}@${e.version}`,`${e.theme}@${e.themeVersion}`]}function FN(e){let t=new Map;for(let r of e){let i=Hh(r.siteOverride).sort(),n=Ed(r.brainVersion,i);t.set(n,{tag:n,brainVersion:r.brainVersion,sitePackages:i})}return[...t.values()].sort((r,i)=>r.tag.localeCompare(i.tag))}function _X(e,t){let r=new Map;for(let i of[...e,...t]){let n=i.lastIndexOf("@"),o=n>0?i.slice(0,n):i,s=r.get(o);if(s&&s!==i)throw Error(`Fleet shared images have conflicting pins for ${o}: ${s} and ${i}`);r.set(o,i)}return[...r.values()].sort()}async function ZN(e){let t=e.brainVersionInput?.trim()??"";if(t){let i=_X([],(e.sitePackagesInput??"").split(/\s+/).filter(Boolean)),n=Ed(t,i);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:i}]}let r=[];for(let i of FN(e.users))if(!await e.imageExists(i.tag))r.push(i);else await e.verifyImage(i);return r}async function kX(e,t,r){try{return await e("docker",["manifest","inspect",`${t}:${r}`]),!0}catch(i){if(i instanceof Error&&/exited with code/.test(i.message))return!1;throw i}}async function EX(e){let t=e.env??process.env,r=e.runCommand??br,i=e.log??console.log,n=t.BRAIN_VERSION_INPUT?.trim()??"",o=t.SITE_PACKAGES_INPUT?.trim()??"",s=t.ALLOW_TAG_OVERWRITE?.trim()==="true",{users:a}=await Ct(e.rootDir),c=await ZN({users:a,brainVersionInput:n,sitePackagesInput:o,allowTagOverwrite:s,imageExists:(l)=>kX(r,e.imageRepository,l),verifyImage:(l)=>UN(e.imageRepository,l,r)});for(let l of c)i(`build needed: ${l.tag} (brain ${l.brainVersion}${l.sitePackages.length>0?`, sites ${l.sitePackages.join(" ")}`:""})`);if(c.length===0)i("All declared images already exist; nothing to build.");return e.writeOutput("images_json",JSON.stringify(c.map((l)=>({tag:l.tag,brain_version:l.brainVersion,site_packages:l.sitePackages.join(" ")})))),c}var vX=128;var UE=x(()=>{MN();Ln();Pi()});var KN,IX,AX,TX,CX,ME,$X,HN,OX,RX,JN,ATe,VN;var FE=x(()=>{PE();KN=["primary","secondary"],IX=f.custom((e)=>typeof e==="function","Expected a React component"),AX=f.strictObject({show:f.boolean().optional(),label:f.string().min(1).optional(),slot:f.enum(KN).optional(),priority:f.number().optional()}),TX=f.strictObject({id:f.string().min(1),template:f.string().min(1),content:f.unknown().optional(),dataQuery:f.looseObject({entityType:f.string().optional(),template:f.string().optional(),query:f.record(f.string(),f.unknown()).optional()}).optional(),order:f.number().optional()}),CX=f.strictObject({id:f.string().min(1),path:f.string().startsWith("/"),title:f.string().optional(),pageLabel:f.string().optional(),description:f.string().optional(),sections:f.array(TX).optional(),layout:f.string().min(1).optional(),fullscreen:f.boolean().optional(),pluginId:f.string().optional(),sourceEntityType:f.string().optional(),external:f.boolean().optional(),navigation:AX.optional()}),ME=f.strictObject({label:f.string().min(1),pluralName:f.string().min(1).optional(),layout:f.string().min(1).optional(),paginate:f.boolean().optional(),pageSize:f.number().int().positive().optional(),citable:f.boolean().optional(),navigation:f.strictObject({show:f.boolean().optional(),slot:f.enum(KN).optional(),priority:f.number().optional()}).optional()}),$X=f.strictObject({schema:f.custom((e)=>e instanceof f.ZodType,"Expected a Zod schema"),component:f.custom((e)=>typeof e==="function","Expected a React component"),title:f.string().min(1),description:f.string(),requiredPermission:f.enum(["admin","trusted","public"]).optional(),fullscreen:f.boolean().optional()}),HN=f.strictObject({namespace:f.string().min(1),sections:f.record(f.string(),$X)}),OX=f.record(f.string(),f.json()),RX=f.record(f.string(),f.record(f.string(),OX)),JN={layouts:f.record(f.string(),IX).refine((e)=>typeof e.default==="function",{message:'Site layouts must include a "default" component'}),routes:f.array(CX),content:RX.optional(),sections:f.union([HN,f.array(HN)]).optional(),themeOverride:f.string().optional(),headScripts:f.array(f.string()).optional(),entityDisplay:f.record(f.string(),ME),staticAssets:f.record(f.string(),f.string()).optional()},ATe=f.strictObject(JN).partial(),VN=f.strictObject(JN).superRefine((e,t)=>{let r=new Set;for(let[o,s]of e.routes.entries()){if(r.has(s.id))t.addIssue({code:"custom",path:["routes",o,"id"],message:`Duplicate route id "${s.id}"`});r.add(s.id);let a=s.layout??"default";if(!e.layouts[a])t.addIssue({code:"custom",path:["routes",o,"layout"],message:`Unknown layout "${a}"`})}let i=Array.isArray(e.sections)?e.sections:e.sections?[e.sections]:[],n=new Map(i.map((o)=>[o.namespace,o]));if(n.size!==i.length)t.addIssue({code:"custom",path:["sections"],message:"Section group namespaces must be unique"});for(let[o,s]of Object.entries(e.content??{})){let a=n.get(o);if(!a){t.addIssue({code:"custom",path:["content",o],message:`Content namespace "${o}" has no section group`});continue}for(let[c,l]of Object.entries(s)){let u=a.sections[c];if(!u){t.addIssue({code:"custom",path:["content",o,c],message:`Content section "${o}.${c}" is not defined`});continue}let d=u.schema.safeParse(l);if(!d.success)t.addIssue({code:"custom",path:["content",o,c],message:`Content does not satisfy the "${o}.${c}" schema: ${f.prettifyError(d.error)}`})}}})});var WN,GN,QN,YN,PX,zX,NX,DX,Kh;var ZE=x(()=>{Re();FE();WN=f.object({id:f.string(),template:f.string(),content:f.unknown().optional(),dataQuery:f.looseObject({entityType:f.string().optional(),template:f.string().optional(),query:f.looseObject({id:f.string().optional(),limit:f.number().optional(),offset:f.number().optional()}).optional()}).optional(),order:f.number().optional()}),GN=["primary","secondary"],QN=f.object({show:f.boolean().default(!1),label:f.string().optional(),slot:f.enum(GN).default("primary"),priority:f.number().min(0).max(100).default(50)}).optional(),YN=f.object({id:f.string(),path:f.string(),title:f.string().default(""),pageLabel:f.string().optional(),description:f.string().default(""),sections:f.array(WN).default([]),layout:f.string().default("default"),fullscreen:f.boolean().optional(),pluginId:f.string().optional(),sourceEntityType:f.string().optional(),external:f.boolean().optional(),navigation:QN}),PX=f.object({routes:f.array(YN),pluginId:f.string()}),zX=f.object({paths:f.array(f.string()).optional(),pluginId:f.string().optional()}),NX=f.object({pluginId:f.string().optional()}),DX=f.object({path:f.string()}),Kh=f.object({label:f.string(),href:f.string(),priority:f.number()})});var HE,XN,Jh,LX,BX;var KE=x(()=>{Re();ZE();HE=f.object({heading:f.string().describe("Main CTA heading text"),buttonText:f.string().describe("Call-to-action button text"),buttonLink:f.string().describe("URL or anchor for the CTA button")}),XN=f.object({blurb:f.string().optional().describe("Short italic subtitle under the section title")}),Jh=f.object({represents:f.enum(["brain","anchor"]).default("anchor").describe("Identity represented by the site"),title:f.string().describe("The site's title"),description:f.string().describe("The site's description"),url:f.string().optional().describe("Canonical site URL"),copyright:f.string().optional().describe("Copyright notice text"),logo:f.boolean().optional().describe("Whether to display logo instead of title text in header"),themeMode:f.enum(["light","dark"]).optional().describe("Default theme mode"),analyticsScript:f.string().optional().describe("Analytics script HTML"),cta:HE.optional().describe("Call-to-action configuration"),sections:f.record(f.string(),XN).optional().describe("Optional per-section blurbs, keyed by section id (e.g. 'essays', 'presentations', 'about'). Used by homepage templates that render editorial section headers.")}),LX=f.object({platform:f.enum(["github","instagram","linkedin","email","website"]).describe("Social media platform"),url:f.string().describe("Profile or contact URL"),label:f.string().optional().describe("Optional display label")}),BX=Jh.extend({copyright:f.string(),navigation:f.object({primary:f.array(Kh),secondary:f.array(Kh)}),socialLinks:f.array(LX).optional().describe("Social media links from profile metadata")})});var DTe;var JE=x(()=>{Re();DTe=f.record(f.string(),f.unknown())});var Id=x(()=>{JE()});var FTe;var eD=x(()=>{Id();Re();FTe=f.object({message:f.string()})});var VE,tD;var WE=x(()=>{Re();VE=f.object({title:f.string().trim().min(1).max(500).optional(),introduction:f.string().trim().min(1).max(4000).optional(),topics:f.array(f.string().trim().min(1).max(500)).max(20).optional(),topicsHeading:f.string().trim().min(1).max(120).optional(),contactLabel:f.string().trim().min(1).max(80).optional(),contactNote:f.string().trim().min(1).max(240).optional(),mapCaption:f.string().trim().min(1).max(160).optional(),refusal:f.string().trim().min(1).max(500).optional(),faqHeading:f.string().trim().min(1).max(120).optional()}),tD=VE.omit({introduction:!0})});var Ad=ee(function(JTe,nD){var qX=Object.prototype.toString;nD.exports=function(t){if(t===void 0)return"undefined";if(t===null)return"null";var r=typeof t;if(r==="boolean")return"boolean";if(r==="string")return"string";if(r==="number")return"number";if(r==="symbol")return"symbol";if(r==="function")return HX(t)?"generatorfunction":"function";if(UX(t))return"array";if(VX(t))return"buffer";if(JX(t))return"arguments";if(FX(t))return"date";if(MX(t))return"error";if(ZX(t))return"regexp";switch(rD(t)){case"Symbol":return"symbol";case"Promise":return"promise";case"WeakMap":return"weakmap";case"WeakSet":return"weakset";case"Map":return"map";case"Set":return"set";case"Int8Array":return"int8array";case"Uint8Array":return"uint8array";case"Uint8ClampedArray":return"uint8clampedarray";case"Int16Array":return"int16array";case"Uint16Array":return"uint16array";case"Int32Array":return"int32array";case"Uint32Array":return"uint32array";case"Float32Array":return"float32array";case"Float64Array":return"float64array"}if(KX(t))return"generator";switch(r=qX.call(t),r){case"[object Object]":return"object";case"[object Map Iterator]":return"mapiterator";case"[object Set Iterator]":return"setiterator";case"[object String Iterator]":return"stringiterator";case"[object Array Iterator]":return"arrayiterator"}return r.slice(8,-1).toLowerCase().replace(/\s/g,"")};function rD(e){return typeof e.constructor==="function"?e.constructor.name:null}function UX(e){if(Array.isArray)return Array.isArray(e);return e instanceof Array}function MX(e){return e instanceof Error||typeof e.message==="string"&&e.constructor&&typeof e.constructor.stackTraceLimit==="number"}function FX(e){if(e instanceof Date)return!0;return typeof e.toDateString==="function"&&typeof e.getDate==="function"&&typeof e.setDate==="function"}function ZX(e){if(e instanceof RegExp)return!0;return typeof e.flags==="string"&&typeof e.ignoreCase==="boolean"&&typeof e.multiline==="boolean"&&typeof e.global==="boolean"}function HX(e,t){return rD(e)==="GeneratorFunction"}function KX(e){return typeof e.throw==="function"&&typeof e.return==="function"&&typeof e.next==="function"}function JX(e){try{if(typeof e.length==="number"&&typeof e.callee==="function")return!0}catch(t){if(t.message.indexOf("callee")!==-1)return!0}return!1}function VX(e){if(e.constructor&&typeof e.constructor.isBuffer==="function")return e.constructor.isBuffer(e);return!1}});var oD=ee(function(VTe,iD){/*!
221
+ `)).digest("hex");return`${r}--s${o.slice(0,12)}`}function Hh(e){if(!e)return[];if(!e.theme?.startsWith("@rizom/"))return[`${e.package}@${e.version}`];if(e.themeVersion===void 0)throw Error(`Theme ${e.theme} has no explicit version pin`);return[`${e.package}@${e.version}`,`${e.theme}@${e.themeVersion}`]}function FN(e){let t=new Map;for(let r of e){let i=Hh(r.siteOverride).sort(),n=Ed(r.brainVersion,i);t.set(n,{tag:n,brainVersion:r.brainVersion,sitePackages:i})}return[...t.values()].sort((r,i)=>r.tag.localeCompare(i.tag))}function _X(e,t){let r=new Map;for(let i of[...e,...t]){let n=i.lastIndexOf("@"),o=n>0?i.slice(0,n):i,s=r.get(o);if(s&&s!==i)throw Error(`Fleet shared images have conflicting pins for ${o}: ${s} and ${i}`);r.set(o,i)}return[...r.values()].sort()}async function ZN(e){let t=e.brainVersionInput?.trim()??"";if(t){let i=_X([],(e.sitePackagesInput??"").split(/\s+/).filter(Boolean)),n=Ed(t,i);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:i}]}let r=[];for(let i of FN(e.users))if(!await e.imageExists(i.tag))r.push(i);else await e.verifyImage(i);return r}async function kX(e,t,r){try{return await e("docker",["manifest","inspect",`${t}:${r}`]),!0}catch(i){if(i instanceof Error&&/exited with code/.test(i.message))return!1;throw i}}async function EX(e){let t=e.env??process.env,r=e.runCommand??br,i=e.log??console.log,n=t.BRAIN_VERSION_INPUT?.trim()??"",o=t.SITE_PACKAGES_INPUT?.trim()??"",s=t.ALLOW_TAG_OVERWRITE?.trim()==="true",{users:a}=await Ct(e.rootDir),c=await ZN({users:a,brainVersionInput:n,sitePackagesInput:o,allowTagOverwrite:s,imageExists:(l)=>kX(r,e.imageRepository,l),verifyImage:(l)=>UN(e.imageRepository,l,r)});for(let l of c)i(`build needed: ${l.tag} (brain ${l.brainVersion}${l.sitePackages.length>0?`, sites ${l.sitePackages.join(" ")}`:""})`);if(c.length===0)i("All declared images already exist; nothing to build.");return e.writeOutput("images_json",JSON.stringify(c.map((l)=>({tag:l.tag,brain_version:l.brainVersion,site_packages:l.sitePackages.join(" ")})))),c}var vX=128;var UE=x(()=>{MN();Ln();Pi()});var KN,IX,AX,TX,CX,ME,$X,HN,OX,RX,JN,ITe,VN;var FE=x(()=>{PE();KN=["primary","secondary"],IX=f.custom((e)=>typeof e==="function","Expected a React component"),AX=f.strictObject({show:f.boolean().optional(),label:f.string().min(1).optional(),slot:f.enum(KN).optional(),priority:f.number().optional()}),TX=f.strictObject({id:f.string().min(1),template:f.string().min(1),content:f.unknown().optional(),dataQuery:f.looseObject({entityType:f.string().optional(),template:f.string().optional(),query:f.record(f.string(),f.unknown()).optional()}).optional(),order:f.number().optional()}),CX=f.strictObject({id:f.string().min(1),path:f.string().startsWith("/"),title:f.string().optional(),pageLabel:f.string().optional(),description:f.string().optional(),sections:f.array(TX).optional(),layout:f.string().min(1).optional(),fullscreen:f.boolean().optional(),pluginId:f.string().optional(),sourceEntityType:f.string().optional(),external:f.boolean().optional(),navigation:AX.optional()}),ME=f.strictObject({label:f.string().min(1),pluralName:f.string().min(1).optional(),layout:f.string().min(1).optional(),paginate:f.boolean().optional(),pageSize:f.number().int().positive().optional(),citable:f.boolean().optional(),navigation:f.strictObject({show:f.boolean().optional(),slot:f.enum(KN).optional(),priority:f.number().optional()}).optional()}),$X=f.strictObject({schema:f.custom((e)=>e instanceof f.ZodType,"Expected a Zod schema"),component:f.custom((e)=>typeof e==="function","Expected a React component"),title:f.string().min(1),description:f.string(),requiredPermission:f.enum(["admin","trusted","public"]).optional(),fullscreen:f.boolean().optional()}),HN=f.strictObject({namespace:f.string().min(1),sections:f.record(f.string(),$X)}),OX=f.record(f.string(),f.json()),RX=f.record(f.string(),f.record(f.string(),OX)),JN={layouts:f.record(f.string(),IX).refine((e)=>typeof e.default==="function",{message:'Site layouts must include a "default" component'}),routes:f.array(CX),content:RX.optional(),sections:f.union([HN,f.array(HN)]).optional(),themeOverride:f.string().optional(),headScripts:f.array(f.string()).optional(),entityDisplay:f.record(f.string(),ME),staticAssets:f.record(f.string(),f.string()).optional()},ITe=f.strictObject(JN).partial(),VN=f.strictObject(JN).superRefine((e,t)=>{let r=new Set;for(let[o,s]of e.routes.entries()){if(r.has(s.id))t.addIssue({code:"custom",path:["routes",o,"id"],message:`Duplicate route id "${s.id}"`});r.add(s.id);let a=s.layout??"default";if(!e.layouts[a])t.addIssue({code:"custom",path:["routes",o,"layout"],message:`Unknown layout "${a}"`})}let i=Array.isArray(e.sections)?e.sections:e.sections?[e.sections]:[],n=new Map(i.map((o)=>[o.namespace,o]));if(n.size!==i.length)t.addIssue({code:"custom",path:["sections"],message:"Section group namespaces must be unique"});for(let[o,s]of Object.entries(e.content??{})){let a=n.get(o);if(!a){t.addIssue({code:"custom",path:["content",o],message:`Content namespace "${o}" has no section group`});continue}for(let[c,l]of Object.entries(s)){let u=a.sections[c];if(!u){t.addIssue({code:"custom",path:["content",o,c],message:`Content section "${o}.${c}" is not defined`});continue}let d=u.schema.safeParse(l);if(!d.success)t.addIssue({code:"custom",path:["content",o,c],message:`Content does not satisfy the "${o}.${c}" schema: ${f.prettifyError(d.error)}`})}}})});var WN,GN,QN,YN,PX,zX,NX,DX,Kh;var ZE=x(()=>{Re();FE();WN=f.object({id:f.string(),template:f.string(),content:f.unknown().optional(),dataQuery:f.looseObject({entityType:f.string().optional(),template:f.string().optional(),query:f.looseObject({id:f.string().optional(),limit:f.number().optional(),offset:f.number().optional()}).optional()}).optional(),order:f.number().optional()}),GN=["primary","secondary"],QN=f.object({show:f.boolean().default(!1),label:f.string().optional(),slot:f.enum(GN).default("primary"),priority:f.number().min(0).max(100).default(50)}).optional(),YN=f.object({id:f.string(),path:f.string(),title:f.string().default(""),pageLabel:f.string().optional(),description:f.string().default(""),sections:f.array(WN).default([]),layout:f.string().default("default"),fullscreen:f.boolean().optional(),pluginId:f.string().optional(),sourceEntityType:f.string().optional(),external:f.boolean().optional(),navigation:QN}),PX=f.object({routes:f.array(YN),pluginId:f.string()}),zX=f.object({paths:f.array(f.string()).optional(),pluginId:f.string().optional()}),NX=f.object({pluginId:f.string().optional()}),DX=f.object({path:f.string()}),Kh=f.object({label:f.string(),href:f.string(),priority:f.number()})});var HE,XN,Jh,LX,BX;var KE=x(()=>{Re();ZE();HE=f.object({heading:f.string().describe("Main CTA heading text"),buttonText:f.string().describe("Call-to-action button text"),buttonLink:f.string().describe("URL or anchor for the CTA button")}),XN=f.object({blurb:f.string().optional().describe("Short italic subtitle under the section title")}),Jh=f.object({represents:f.enum(["brain","anchor"]).default("anchor").describe("Identity represented by the site"),title:f.string().describe("The site's title"),description:f.string().describe("The site's description"),url:f.string().optional().describe("Canonical site URL"),copyright:f.string().optional().describe("Copyright notice text"),logo:f.boolean().optional().describe("Whether to display logo instead of title text in header"),themeMode:f.enum(["light","dark"]).optional().describe("Default theme mode"),analyticsScript:f.string().optional().describe("Analytics script HTML"),cta:HE.optional().describe("Call-to-action configuration"),sections:f.record(f.string(),XN).optional().describe("Optional per-section blurbs, keyed by section id (e.g. 'essays', 'presentations', 'about'). Used by homepage templates that render editorial section headers.")}),LX=f.object({platform:f.enum(["github","instagram","linkedin","email","website"]).describe("Social media platform"),url:f.string().describe("Profile or contact URL"),label:f.string().optional().describe("Optional display label")}),BX=Jh.extend({copyright:f.string(),navigation:f.object({primary:f.array(Kh),secondary:f.array(Kh)}),socialLinks:f.array(LX).optional().describe("Social media links from profile metadata")})});var NTe;var JE=x(()=>{Re();NTe=f.record(f.string(),f.unknown())});var Id=x(()=>{JE()});var MTe;var eD=x(()=>{Id();Re();MTe=f.object({message:f.string()})});var VE,tD;var WE=x(()=>{Re();VE=f.object({title:f.string().trim().min(1).max(500).optional(),introduction:f.string().trim().min(1).max(4000).optional(),topics:f.array(f.string().trim().min(1).max(500)).max(20).optional(),topicsHeading:f.string().trim().min(1).max(120).optional(),contactLabel:f.string().trim().min(1).max(80).optional(),contactNote:f.string().trim().min(1).max(240).optional(),mapCaption:f.string().trim().min(1).max(160).optional(),refusal:f.string().trim().min(1).max(500).optional(),faqHeading:f.string().trim().min(1).max(120).optional()}),tD=VE.omit({introduction:!0})});var Ad=ee(function(KTe,nD){var qX=Object.prototype.toString;nD.exports=function(t){if(t===void 0)return"undefined";if(t===null)return"null";var r=typeof t;if(r==="boolean")return"boolean";if(r==="string")return"string";if(r==="number")return"number";if(r==="symbol")return"symbol";if(r==="function")return HX(t)?"generatorfunction":"function";if(UX(t))return"array";if(VX(t))return"buffer";if(JX(t))return"arguments";if(FX(t))return"date";if(MX(t))return"error";if(ZX(t))return"regexp";switch(rD(t)){case"Symbol":return"symbol";case"Promise":return"promise";case"WeakMap":return"weakmap";case"WeakSet":return"weakset";case"Map":return"map";case"Set":return"set";case"Int8Array":return"int8array";case"Uint8Array":return"uint8array";case"Uint8ClampedArray":return"uint8clampedarray";case"Int16Array":return"int16array";case"Uint16Array":return"uint16array";case"Int32Array":return"int32array";case"Uint32Array":return"uint32array";case"Float32Array":return"float32array";case"Float64Array":return"float64array"}if(KX(t))return"generator";switch(r=qX.call(t),r){case"[object Object]":return"object";case"[object Map Iterator]":return"mapiterator";case"[object Set Iterator]":return"setiterator";case"[object String Iterator]":return"stringiterator";case"[object Array Iterator]":return"arrayiterator"}return r.slice(8,-1).toLowerCase().replace(/\s/g,"")};function rD(e){return typeof e.constructor==="function"?e.constructor.name:null}function UX(e){if(Array.isArray)return Array.isArray(e);return e instanceof Array}function MX(e){return e instanceof Error||typeof e.message==="string"&&e.constructor&&typeof e.constructor.stackTraceLimit==="number"}function FX(e){if(e instanceof Date)return!0;return typeof e.toDateString==="function"&&typeof e.getDate==="function"&&typeof e.setDate==="function"}function ZX(e){if(e instanceof RegExp)return!0;return typeof e.flags==="string"&&typeof e.ignoreCase==="boolean"&&typeof e.multiline==="boolean"&&typeof e.global==="boolean"}function HX(e,t){return rD(e)==="GeneratorFunction"}function KX(e){return typeof e.throw==="function"&&typeof e.return==="function"&&typeof e.next==="function"}function JX(e){try{if(typeof e.length==="number"&&typeof e.callee==="function")return!0}catch(t){if(t.message.indexOf("callee")!==-1)return!0}return!1}function VX(e){if(e.constructor&&typeof e.constructor.isBuffer==="function")return e.constructor.isBuffer(e);return!1}});var oD=ee(function(JTe,iD){/*!
222
222
  * is-extendable <https://github.com/jonschlinkert/is-extendable>
223
223
  *
224
224
  * Copyright (c) 2015, Jon Schlinkert.
225
225
  * Licensed under the MIT License.
226
- */iD.exports=function(t){return typeof t<"u"&&t!==null&&(typeof t==="object"||typeof t==="function")}});var cD=ee(function(WTe,aD){var sD=oD();aD.exports=function(t){if(!sD(t))t={};var r=arguments.length;for(var i=1;i<r;i++){var n=arguments[i];if(sD(n))WX(t,n)}return t};function WX(e,t){for(var r in t)if(GX(t,r))e[r]=t[r]}function GX(e,t){return Object.prototype.hasOwnProperty.call(e,t)}});var dD=ee(function(GTe,uD){var QX=Ad(),YX=cD();uD.exports=function(e,t){if(typeof t==="function")t={parse:t};var r=eee(e),i={section_delimiter:"---",parse:ree},n=YX({},i,t),o=n.section_delimiter,s=r.content.split(/\r?\n/),a=null,c=lD(),l=[],u=[];function d(v){r.content=v,a=[],l=[]}function p(v){if(u.length)c.key=tee(u[0],o),c.content=v,n.parse(c,a),a.push(c),c=lD(),l=[],u=[]}for(var m=0;m<s.length;m++){var y=s[m],g=u.length,b=y.trim();if(XX(b,o)){if(b.length===3&&m!==0){if(g===0||g===2){l.push(y);continue}u.push(b),c.data=l.join(`
226
+ */iD.exports=function(t){return typeof t<"u"&&t!==null&&(typeof t==="object"||typeof t==="function")}});var cD=ee(function(VTe,aD){var sD=oD();aD.exports=function(t){if(!sD(t))t={};var r=arguments.length;for(var i=1;i<r;i++){var n=arguments[i];if(sD(n))WX(t,n)}return t};function WX(e,t){for(var r in t)if(GX(t,r))e[r]=t[r]}function GX(e,t){return Object.prototype.hasOwnProperty.call(e,t)}});var dD=ee(function(WTe,uD){var QX=Ad(),YX=cD();uD.exports=function(e,t){if(typeof t==="function")t={parse:t};var r=eee(e),i={section_delimiter:"---",parse:ree},n=YX({},i,t),o=n.section_delimiter,s=r.content.split(/\r?\n/),a=null,c=lD(),l=[],u=[];function d(v){r.content=v,a=[],l=[]}function p(v){if(u.length)c.key=tee(u[0],o),c.content=v,n.parse(c,a),a.push(c),c=lD(),l=[],u=[]}for(var m=0;m<s.length;m++){var y=s[m],g=u.length,b=y.trim();if(XX(b,o)){if(b.length===3&&m!==0){if(g===0||g===2){l.push(y);continue}u.push(b),c.data=l.join(`
227
227
  `),l=[];continue}if(a===null)d(l.join(`
228
228
  `));if(g===2)p(l.join(`
229
229
  `));u.push(b);continue}l.push(y)}if(a===null)d(l.join(`
230
230
  `));else p(l.join(`
231
- `));return r.sections=a,r};function XX(e,t){if(e.slice(0,t.length)!==t)return!1;if(e.charAt(t.length+1)===t.slice(-1))return!1;return!0}function eee(e){if(QX(e)!=="object")e={content:e};if(typeof e.content!=="string"&&!nee(e.content))throw TypeError("expected a buffer or string");return e.content=e.content.toString(),e.sections=[],e}function tee(e,t){return e?e.slice(t.length).trim():""}function lD(){return{key:"",data:"",content:""}}function ree(e){return e}function nee(e){if(e&&e.constructor&&typeof e.constructor.isBuffer==="function")return e.constructor.isBuffer(e);return!1}});var Js=ee(function(lee,Ks){function fD(e){return typeof e>"u"||e===null}function iee(e){return typeof e==="object"&&e!==null}function oee(e){if(Array.isArray(e))return e;else if(fD(e))return[];return[e]}function see(e,t){var r,i,n,o;if(t){o=Object.keys(t);for(r=0,i=o.length;r<i;r+=1)n=o[r],e[n]=t[n]}return e}function aee(e,t){var r="",i;for(i=0;i<t;i+=1)r+=e;return r}function cee(e){return e===0&&Number.NEGATIVE_INFINITY===1/e}lee.isNothing=fD;lee.isObject=iee;lee.toArray=oee;lee.repeat=aee;lee.isNegativeZero=cee;lee.extend=see});var Bc=ee(function(QTe,pD){function Td(e,t){if(Error.call(this),this.name="YAMLException",this.reason=e,this.mark=t,this.message=(this.reason||"(unknown reason)")+(this.mark?" "+this.mark.toString():""),Error.captureStackTrace)Error.captureStackTrace(this,this.constructor);else this.stack=Error().stack||""}Td.prototype=Object.create(Error.prototype);Td.prototype.constructor=Td;Td.prototype.toString=function(t){var r=this.name+": ";if(r+=this.reason||"(unknown reason)",!t&&this.mark)r+=" "+this.mark.toString();return r};pD.exports=Td});var gD=ee(function(YTe,hD){var mD=Js();function GE(e,t,r,i,n){this.name=e,this.buffer=t,this.position=r,this.line=i,this.column=n}GE.prototype.getSnippet=function(t,r){var i,n,o,s,a;if(!this.buffer)return null;t=t||4,r=r||75,i="",n=this.position;while(n>0&&`\x00\r
231
+ `));return r.sections=a,r};function XX(e,t){if(e.slice(0,t.length)!==t)return!1;if(e.charAt(t.length+1)===t.slice(-1))return!1;return!0}function eee(e){if(QX(e)!=="object")e={content:e};if(typeof e.content!=="string"&&!nee(e.content))throw TypeError("expected a buffer or string");return e.content=e.content.toString(),e.sections=[],e}function tee(e,t){return e?e.slice(t.length).trim():""}function lD(){return{key:"",data:"",content:""}}function ree(e){return e}function nee(e){if(e&&e.constructor&&typeof e.constructor.isBuffer==="function")return e.constructor.isBuffer(e);return!1}});var Js=ee(function(lee,Ks){function fD(e){return typeof e>"u"||e===null}function iee(e){return typeof e==="object"&&e!==null}function oee(e){if(Array.isArray(e))return e;else if(fD(e))return[];return[e]}function see(e,t){var r,i,n,o;if(t){o=Object.keys(t);for(r=0,i=o.length;r<i;r+=1)n=o[r],e[n]=t[n]}return e}function aee(e,t){var r="",i;for(i=0;i<t;i+=1)r+=e;return r}function cee(e){return e===0&&Number.NEGATIVE_INFINITY===1/e}lee.isNothing=fD;lee.isObject=iee;lee.toArray=oee;lee.repeat=aee;lee.isNegativeZero=cee;lee.extend=see});var Bc=ee(function(GTe,pD){function Td(e,t){if(Error.call(this),this.name="YAMLException",this.reason=e,this.mark=t,this.message=(this.reason||"(unknown reason)")+(this.mark?" "+this.mark.toString():""),Error.captureStackTrace)Error.captureStackTrace(this,this.constructor);else this.stack=Error().stack||""}Td.prototype=Object.create(Error.prototype);Td.prototype.constructor=Td;Td.prototype.toString=function(t){var r=this.name+": ";if(r+=this.reason||"(unknown reason)",!t&&this.mark)r+=" "+this.mark.toString();return r};pD.exports=Td});var gD=ee(function(QTe,hD){var mD=Js();function GE(e,t,r,i,n){this.name=e,this.buffer=t,this.position=r,this.line=i,this.column=n}GE.prototype.getSnippet=function(t,r){var i,n,o,s,a;if(!this.buffer)return null;t=t||4,r=r||75,i="",n=this.position;while(n>0&&`\x00\r
232
232
  \x85\u2028\u2029`.indexOf(this.buffer.charAt(n-1))===-1)if(n-=1,this.position-n>r/2-1){i=" ... ",n+=5;break}o="",s=this.position;while(s<this.buffer.length&&`\x00\r
233
233
  \x85\u2028\u2029`.indexOf(this.buffer.charAt(s))===-1)if(s+=1,s-this.position>r/2-1){o=" ... ",s-=5;break}return a=this.buffer.slice(n,s),mD.repeat(" ",t)+i+a+o+`
234
234
  `+mD.repeat(" ",t+this.position-n+i.length)+"^"};GE.prototype.toString=function(t){var r,i="";if(this.name)i+='in "'+this.name+'" ';if(i+="at line "+(this.line+1)+", column "+(this.column+1),!t){if(r=this.getSnippet(),r)i+=`:
235
- `+r}return i};hD.exports=GE});var Ft=ee(function(XTe,bD){var yD=Bc(),gee=["kind","resolve","construct","instanceOf","predicate","represent","defaultStyle","styleAliases"],yee=["scalar","sequence","mapping"];function bee(e){var t={};if(e!==null)Object.keys(e).forEach(function(r){e[r].forEach(function(i){t[String(i)]=r})});return t}function xee(e,t){if(t=t||{},Object.keys(t).forEach(function(r){if(gee.indexOf(r)===-1)throw new yD('Unknown option "'+r+'" is met in definition of "'+e+'" YAML type.')}),this.tag=e,this.kind=t.kind||null,this.resolve=t.resolve||function(){return!0},this.construct=t.construct||function(r){return r},this.instanceOf=t.instanceOf||null,this.predicate=t.predicate||null,this.represent=t.represent||null,this.defaultStyle=t.defaultStyle||null,this.styleAliases=bee(t.styleAliases||null),yee.indexOf(this.kind)===-1)throw new yD('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')}bD.exports=xee});var Vs=ee(function(eCe,SD){var xD=Js(),Wh=Bc(),See=Ft();function QE(e,t,r){var i=[];return e.include.forEach(function(n){r=QE(n,t,r)}),e[t].forEach(function(n){r.forEach(function(o,s){if(o.tag===n.tag&&o.kind===n.kind)i.push(s)}),r.push(n)}),r.filter(function(n,o){return i.indexOf(o)===-1})}function wee(){var e={scalar:{},sequence:{},mapping:{},fallback:{}},t,r;function i(n){e[n.kind][n.tag]=e.fallback[n.tag]=n}for(t=0,r=arguments.length;t<r;t+=1)arguments[t].forEach(i);return e}function jc(e){this.include=e.include||[],this.implicit=e.implicit||[],this.explicit=e.explicit||[],this.implicit.forEach(function(t){if(t.loadKind&&t.loadKind!=="scalar")throw new Wh("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.")}),this.compiledImplicit=QE(this,"implicit",[]),this.compiledExplicit=QE(this,"explicit",[]),this.compiledTypeMap=wee(this.compiledImplicit,this.compiledExplicit)}jc.DEFAULT=null;jc.create=function(){var t,r;switch(arguments.length){case 1:t=jc.DEFAULT,r=arguments[0];break;case 2:t=arguments[0],r=arguments[1];break;default:throw new Wh("Wrong number of arguments for Schema.create function")}if(t=xD.toArray(t),r=xD.toArray(r),!t.every(function(i){return i instanceof jc}))throw new Wh("Specified list of super schemas (or a single Schema object) contains a non-Schema object.");if(!r.every(function(i){return i instanceof See}))throw new Wh("Specified list of YAML types (or a single Type object) contains a non-Type object.");return new jc({include:t,explicit:r})};SD.exports=jc});var vD=ee(function(tCe,wD){var vee=Ft();wD.exports=new vee("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return e!==null?e:""}})});var kD=ee(function(rCe,_D){var _ee=Ft();_D.exports=new _ee("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return e!==null?e:[]}})});var ID=ee(function(nCe,ED){var kee=Ft();ED.exports=new kee("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return e!==null?e:{}}})});var Gh=ee(function(iCe,AD){var Eee=Vs();AD.exports=new Eee({explicit:[vD(),kD(),ID()]})});var CD=ee(function(oCe,TD){var Iee=Ft();function Aee(e){if(e===null)return!0;var t=e.length;return t===1&&e==="~"||t===4&&(e==="null"||e==="Null"||e==="NULL")}function Tee(){return null}function Cee(e){return e===null}TD.exports=new Iee("tag:yaml.org,2002:null",{kind:"scalar",resolve:Aee,construct:Tee,predicate:Cee,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"}},defaultStyle:"lowercase"})});var OD=ee(function(sCe,$D){var $ee=Ft();function Oee(e){if(e===null)return!1;var t=e.length;return t===4&&(e==="true"||e==="True"||e==="TRUE")||t===5&&(e==="false"||e==="False"||e==="FALSE")}function Ree(e){return e==="true"||e==="True"||e==="TRUE"}function Pee(e){return Object.prototype.toString.call(e)==="[object Boolean]"}$D.exports=new $ee("tag:yaml.org,2002:bool",{kind:"scalar",resolve:Oee,construct:Ree,predicate:Pee,represent:{lowercase:function(e){return e?"true":"false"},uppercase:function(e){return e?"TRUE":"FALSE"},camelcase:function(e){return e?"True":"False"}},defaultStyle:"lowercase"})});var PD=ee(function(aCe,RD){var zee=Js(),Nee=Ft();function Dee(e){return 48<=e&&e<=57||65<=e&&e<=70||97<=e&&e<=102}function Lee(e){return 48<=e&&e<=55}function Bee(e){return 48<=e&&e<=57}function jee(e){if(e===null)return!1;var t=e.length,r=0,i=!1,n;if(!t)return!1;if(n=e[r],n==="-"||n==="+")n=e[++r];if(n==="0"){if(r+1===t)return!0;if(n=e[++r],n==="b"){r++;for(;r<t;r++){if(n=e[r],n==="_")continue;if(n!=="0"&&n!=="1")return!1;i=!0}return i&&n!=="_"}if(n==="x"){r++;for(;r<t;r++){if(n=e[r],n==="_")continue;if(!Dee(e.charCodeAt(r)))return!1;i=!0}return i&&n!=="_"}for(;r<t;r++){if(n=e[r],n==="_")continue;if(!Lee(e.charCodeAt(r)))return!1;i=!0}return i&&n!=="_"}if(n==="_")return!1;for(;r<t;r++){if(n=e[r],n==="_")continue;if(n===":")break;if(!Bee(e.charCodeAt(r)))return!1;i=!0}if(!i||n==="_")return!1;if(n!==":")return!0;return/^(:[0-5]?[0-9])+$/.test(e.slice(r))}function qee(e){var t=e,r=1,i,n,o=[];if(t.indexOf("_")!==-1)t=t.replace(/_/g,"");if(i=t[0],i==="-"||i==="+"){if(i==="-")r=-1;t=t.slice(1),i=t[0]}if(t==="0")return 0;if(i==="0"){if(t[1]==="b")return r*parseInt(t.slice(2),2);if(t[1]==="x")return r*parseInt(t,16);return r*parseInt(t,8)}if(t.indexOf(":")!==-1)return t.split(":").forEach(function(s){o.unshift(parseInt(s,10))}),t=0,n=1,o.forEach(function(s){t+=s*n,n*=60}),r*t;return r*parseInt(t,10)}function Uee(e){return Object.prototype.toString.call(e)==="[object Number]"&&(e%1===0&&!zee.isNegativeZero(e))}RD.exports=new Nee("tag:yaml.org,2002:int",{kind:"scalar",resolve:jee,construct:qee,predicate:Uee,represent:{binary:function(e){return e>=0?"0b"+e.toString(2):"-0b"+e.toString(2).slice(1)},octal:function(e){return e>=0?"0"+e.toString(8):"-0"+e.toString(8).slice(1)},decimal:function(e){return e.toString(10)},hexadecimal:function(e){return e>=0?"0x"+e.toString(16).toUpperCase():"-0x"+e.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}})});var DD=ee(function(cCe,ND){var zD=Js(),Mee=Ft(),Fee=new RegExp("^(?:[-+]?(?:0|[1-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function Zee(e){if(e===null)return!1;if(!Fee.test(e)||e[e.length-1]==="_")return!1;return!0}function Hee(e){var t,r,i,n;if(t=e.replace(/_/g,"").toLowerCase(),r=t[0]==="-"?-1:1,n=[],"+-".indexOf(t[0])>=0)t=t.slice(1);if(t===".inf")return r===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY;else if(t===".nan")return NaN;else if(t.indexOf(":")>=0)return t.split(":").forEach(function(o){n.unshift(parseFloat(o,10))}),t=0,i=1,n.forEach(function(o){t+=o*i,i*=60}),r*t;return r*parseFloat(t,10)}var Kee=/^[-+]?[0-9]+e/;function Jee(e,t){var r;if(isNaN(e))switch(t){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===e)switch(t){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===e)switch(t){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(zD.isNegativeZero(e))return"-0.0";return r=e.toString(10),Kee.test(r)?r.replace("e",".e"):r}function Vee(e){return Object.prototype.toString.call(e)==="[object Number]"&&(e%1!==0||zD.isNegativeZero(e))}ND.exports=new Mee("tag:yaml.org,2002:float",{kind:"scalar",resolve:Zee,construct:Hee,predicate:Vee,represent:Jee,defaultStyle:"lowercase"})});var YE=ee(function(lCe,LD){var Wee=Vs();LD.exports=new Wee({include:[Gh()],implicit:[CD(),OD(),PD(),DD()]})});var XE=ee(function(uCe,BD){var Gee=Vs();BD.exports=new Gee({include:[YE()]})});var MD=ee(function(dCe,UD){var Qee=Ft(),jD=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),qD=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function Yee(e){if(e===null)return!1;if(jD.exec(e)!==null)return!0;if(qD.exec(e)!==null)return!0;return!1}function Xee(e){var t,r,i,n,o,s,a,c=0,l=null,u,d,p;if(t=jD.exec(e),t===null)t=qD.exec(e);if(t===null)throw Error("Date resolve error");if(r=+t[1],i=+t[2]-1,n=+t[3],!t[4])return new Date(Date.UTC(r,i,n));if(o=+t[4],s=+t[5],a=+t[6],t[7]){c=t[7].slice(0,3);while(c.length<3)c+="0";c=+c}if(t[9]){if(u=+t[10],d=+(t[11]||0),l=(u*60+d)*60000,t[9]==="-")l=-l}if(p=new Date(Date.UTC(r,i,n,o,s,a,c)),l)p.setTime(p.getTime()-l);return p}function ete(e){return e.toISOString()}UD.exports=new Qee("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:Yee,construct:Xee,instanceOf:Date,represent:ete})});var ZD=ee(function(fCe,FD){var tte=Ft();function rte(e){return e==="<<"||e===null}FD.exports=new tte("tag:yaml.org,2002:merge",{kind:"scalar",resolve:rte})});var KD=ee(function(pCe,HD){var Ws;try{e1=Tt,Ws=e1("buffer").Buffer}catch(e){}var e1,nte=Ft(),t1=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
236
- \r`;function ite(e){if(e===null)return!1;var t,r,i=0,n=e.length,o=t1;for(r=0;r<n;r++){if(t=o.indexOf(e.charAt(r)),t>64)continue;if(t<0)return!1;i+=6}return i%8===0}function ote(e){var t,r,i=e.replace(/[\r\n=]/g,""),n=i.length,o=t1,s=0,a=[];for(t=0;t<n;t++){if(t%4===0&&t)a.push(s>>16&255),a.push(s>>8&255),a.push(s&255);s=s<<6|o.indexOf(i.charAt(t))}if(r=n%4*6,r===0)a.push(s>>16&255),a.push(s>>8&255),a.push(s&255);else if(r===18)a.push(s>>10&255),a.push(s>>2&255);else if(r===12)a.push(s>>4&255);if(Ws)return Ws.from?Ws.from(a):new Ws(a);return a}function ste(e){var t="",r=0,i,n,o=e.length,s=t1;for(i=0;i<o;i++){if(i%3===0&&i)t+=s[r>>18&63],t+=s[r>>12&63],t+=s[r>>6&63],t+=s[r&63];r=(r<<8)+e[i]}if(n=o%3,n===0)t+=s[r>>18&63],t+=s[r>>12&63],t+=s[r>>6&63],t+=s[r&63];else if(n===2)t+=s[r>>10&63],t+=s[r>>4&63],t+=s[r<<2&63],t+=s[64];else if(n===1)t+=s[r>>2&63],t+=s[r<<4&63],t+=s[64],t+=s[64];return t}function ate(e){return Ws&&Ws.isBuffer(e)}HD.exports=new nte("tag:yaml.org,2002:binary",{kind:"scalar",resolve:ite,construct:ote,predicate:ate,represent:ste})});var VD=ee(function(hCe,JD){var cte=Ft(),lte=Object.prototype.hasOwnProperty,ute=Object.prototype.toString;function dte(e){if(e===null)return!0;var t=[],r,i,n,o,s,a=e;for(r=0,i=a.length;r<i;r+=1){if(n=a[r],s=!1,ute.call(n)!=="[object Object]")return!1;for(o in n)if(lte.call(n,o))if(!s)s=!0;else return!1;if(!s)return!1;if(t.indexOf(o)===-1)t.push(o);else return!1}return!0}function fte(e){return e!==null?e:[]}JD.exports=new cte("tag:yaml.org,2002:omap",{kind:"sequence",resolve:dte,construct:fte})});var GD=ee(function(gCe,WD){var pte=Ft(),mte=Object.prototype.toString;function hte(e){if(e===null)return!0;var t,r,i,n,o,s=e;o=Array(s.length);for(t=0,r=s.length;t<r;t+=1){if(i=s[t],mte.call(i)!=="[object Object]")return!1;if(n=Object.keys(i),n.length!==1)return!1;o[t]=[n[0],i[n[0]]]}return!0}function gte(e){if(e===null)return[];var t,r,i,n,o,s=e;o=Array(s.length);for(t=0,r=s.length;t<r;t+=1)i=s[t],n=Object.keys(i),o[t]=[n[0],i[n[0]]];return o}WD.exports=new pte("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:hte,construct:gte})});var YD=ee(function(yCe,QD){var yte=Ft(),bte=Object.prototype.hasOwnProperty;function xte(e){if(e===null)return!0;var t,r=e;for(t in r)if(bte.call(r,t)){if(r[t]!==null)return!1}return!0}function Ste(e){return e!==null?e:{}}QD.exports=new yte("tag:yaml.org,2002:set",{kind:"mapping",resolve:xte,construct:Ste})});var qc=ee(function(bCe,XD){var wte=Vs();XD.exports=new wte({include:[XE()],implicit:[MD(),ZD()],explicit:[KD(),VD(),GD(),YD()]})});var tL=ee(function(xCe,eL){var vte=Ft();function _te(){return!0}function kte(){return}function Ete(){return""}function Ite(e){return typeof e>"u"}eL.exports=new vte("tag:yaml.org,2002:js/undefined",{kind:"scalar",resolve:_te,construct:kte,predicate:Ite,represent:Ete})});var nL=ee(function(SCe,rL){var Ate=Ft();function Tte(e){if(e===null)return!1;if(e.length===0)return!1;var t=e,r=/\/([gim]*)$/.exec(e),i="";if(t[0]==="/"){if(r)i=r[1];if(i.length>3)return!1;if(t[t.length-i.length-1]!=="/")return!1}return!0}function Cte(e){var t=e,r=/\/([gim]*)$/.exec(e),i="";if(t[0]==="/"){if(r)i=r[1];t=t.slice(1,t.length-i.length-1)}return new RegExp(t,i)}function $te(e){var t="/"+e.source+"/";if(e.global)t+="g";if(e.multiline)t+="m";if(e.ignoreCase)t+="i";return t}function Ote(e){return Object.prototype.toString.call(e)==="[object RegExp]"}rL.exports=new Ate("tag:yaml.org,2002:js/regexp",{kind:"scalar",resolve:Tte,construct:Cte,predicate:Ote,represent:$te})});var oL=ee(function(wCe,iL){var Qh;try{r1=Tt,Qh=r1("esprima")}catch(e){if(typeof window<"u")Qh=window.esprima}var r1,Rte=Ft();function Pte(e){if(e===null)return!1;try{var t="("+e+")",r=Qh.parse(t,{range:!0});if(r.type!=="Program"||r.body.length!==1||r.body[0].type!=="ExpressionStatement"||r.body[0].expression.type!=="ArrowFunctionExpression"&&r.body[0].expression.type!=="FunctionExpression")return!1;return!0}catch(i){return!1}}function zte(e){var t="("+e+")",r=Qh.parse(t,{range:!0}),i=[],n;if(r.type!=="Program"||r.body.length!==1||r.body[0].type!=="ExpressionStatement"||r.body[0].expression.type!=="ArrowFunctionExpression"&&r.body[0].expression.type!=="FunctionExpression")throw Error("Failed to resolve function");if(r.body[0].expression.params.forEach(function(o){i.push(o.name)}),n=r.body[0].expression.body.range,r.body[0].expression.body.type==="BlockStatement")return Function(i,t.slice(n[0]+1,n[1]-1));return Function(i,"return "+t.slice(n[0],n[1]))}function Nte(e){return e.toString()}function Dte(e){return Object.prototype.toString.call(e)==="[object Function]"}iL.exports=new Rte("tag:yaml.org,2002:js/function",{kind:"scalar",resolve:Pte,construct:zte,predicate:Dte,represent:Nte})});var Cd=ee(function(_Ce,aL){var sL=Vs();aL.exports=sL.DEFAULT=new sL({include:[qc()],explicit:[tL(),nL(),oL()]})});var AL=ee(function(sre,$d){var zi=Js(),mL=Bc(),Lte=gD(),hL=qc(),Bte=Cd(),Oo=Object.prototype.hasOwnProperty,Yh=1,gL=2,yL=3,Xh=4,n1=1,jte=2,cL=3,qte=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,Ute=/[\x85\u2028\u2029]/,Mte=/[,\[\]\{\}]/,bL=/^(?:!|!!|![a-z\-]+!)$/i,xL=/^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;function lL(e){return Object.prototype.toString.call(e)}function oi(e){return e===10||e===13}function Gs(e){return e===9||e===32}function Kr(e){return e===9||e===32||e===10||e===13}function Uc(e){return e===44||e===91||e===93||e===123||e===125}function Fte(e){var t;if(48<=e&&e<=57)return e-48;if(t=e|32,97<=t&&t<=102)return t-97+10;return-1}function Zte(e){if(e===120)return 2;if(e===117)return 4;if(e===85)return 8;return 0}function Hte(e){if(48<=e&&e<=57)return e-48;return-1}function uL(e){return e===48?"\x00":e===97?"\x07":e===98?"\b":e===116?"\t":e===9?"\t":e===110?`
235
+ `+r}return i};hD.exports=GE});var Ft=ee(function(YTe,bD){var yD=Bc(),gee=["kind","resolve","construct","instanceOf","predicate","represent","defaultStyle","styleAliases"],yee=["scalar","sequence","mapping"];function bee(e){var t={};if(e!==null)Object.keys(e).forEach(function(r){e[r].forEach(function(i){t[String(i)]=r})});return t}function xee(e,t){if(t=t||{},Object.keys(t).forEach(function(r){if(gee.indexOf(r)===-1)throw new yD('Unknown option "'+r+'" is met in definition of "'+e+'" YAML type.')}),this.tag=e,this.kind=t.kind||null,this.resolve=t.resolve||function(){return!0},this.construct=t.construct||function(r){return r},this.instanceOf=t.instanceOf||null,this.predicate=t.predicate||null,this.represent=t.represent||null,this.defaultStyle=t.defaultStyle||null,this.styleAliases=bee(t.styleAliases||null),yee.indexOf(this.kind)===-1)throw new yD('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')}bD.exports=xee});var Vs=ee(function(XTe,SD){var xD=Js(),Wh=Bc(),See=Ft();function QE(e,t,r){var i=[];return e.include.forEach(function(n){r=QE(n,t,r)}),e[t].forEach(function(n){r.forEach(function(o,s){if(o.tag===n.tag&&o.kind===n.kind)i.push(s)}),r.push(n)}),r.filter(function(n,o){return i.indexOf(o)===-1})}function wee(){var e={scalar:{},sequence:{},mapping:{},fallback:{}},t,r;function i(n){e[n.kind][n.tag]=e.fallback[n.tag]=n}for(t=0,r=arguments.length;t<r;t+=1)arguments[t].forEach(i);return e}function jc(e){this.include=e.include||[],this.implicit=e.implicit||[],this.explicit=e.explicit||[],this.implicit.forEach(function(t){if(t.loadKind&&t.loadKind!=="scalar")throw new Wh("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.")}),this.compiledImplicit=QE(this,"implicit",[]),this.compiledExplicit=QE(this,"explicit",[]),this.compiledTypeMap=wee(this.compiledImplicit,this.compiledExplicit)}jc.DEFAULT=null;jc.create=function(){var t,r;switch(arguments.length){case 1:t=jc.DEFAULT,r=arguments[0];break;case 2:t=arguments[0],r=arguments[1];break;default:throw new Wh("Wrong number of arguments for Schema.create function")}if(t=xD.toArray(t),r=xD.toArray(r),!t.every(function(i){return i instanceof jc}))throw new Wh("Specified list of super schemas (or a single Schema object) contains a non-Schema object.");if(!r.every(function(i){return i instanceof See}))throw new Wh("Specified list of YAML types (or a single Type object) contains a non-Type object.");return new jc({include:t,explicit:r})};SD.exports=jc});var vD=ee(function(eCe,wD){var vee=Ft();wD.exports=new vee("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return e!==null?e:""}})});var kD=ee(function(tCe,_D){var _ee=Ft();_D.exports=new _ee("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return e!==null?e:[]}})});var ID=ee(function(rCe,ED){var kee=Ft();ED.exports=new kee("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return e!==null?e:{}}})});var Gh=ee(function(nCe,AD){var Eee=Vs();AD.exports=new Eee({explicit:[vD(),kD(),ID()]})});var CD=ee(function(iCe,TD){var Iee=Ft();function Aee(e){if(e===null)return!0;var t=e.length;return t===1&&e==="~"||t===4&&(e==="null"||e==="Null"||e==="NULL")}function Tee(){return null}function Cee(e){return e===null}TD.exports=new Iee("tag:yaml.org,2002:null",{kind:"scalar",resolve:Aee,construct:Tee,predicate:Cee,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"}},defaultStyle:"lowercase"})});var OD=ee(function(oCe,$D){var $ee=Ft();function Oee(e){if(e===null)return!1;var t=e.length;return t===4&&(e==="true"||e==="True"||e==="TRUE")||t===5&&(e==="false"||e==="False"||e==="FALSE")}function Ree(e){return e==="true"||e==="True"||e==="TRUE"}function Pee(e){return Object.prototype.toString.call(e)==="[object Boolean]"}$D.exports=new $ee("tag:yaml.org,2002:bool",{kind:"scalar",resolve:Oee,construct:Ree,predicate:Pee,represent:{lowercase:function(e){return e?"true":"false"},uppercase:function(e){return e?"TRUE":"FALSE"},camelcase:function(e){return e?"True":"False"}},defaultStyle:"lowercase"})});var PD=ee(function(sCe,RD){var zee=Js(),Nee=Ft();function Dee(e){return 48<=e&&e<=57||65<=e&&e<=70||97<=e&&e<=102}function Lee(e){return 48<=e&&e<=55}function Bee(e){return 48<=e&&e<=57}function jee(e){if(e===null)return!1;var t=e.length,r=0,i=!1,n;if(!t)return!1;if(n=e[r],n==="-"||n==="+")n=e[++r];if(n==="0"){if(r+1===t)return!0;if(n=e[++r],n==="b"){r++;for(;r<t;r++){if(n=e[r],n==="_")continue;if(n!=="0"&&n!=="1")return!1;i=!0}return i&&n!=="_"}if(n==="x"){r++;for(;r<t;r++){if(n=e[r],n==="_")continue;if(!Dee(e.charCodeAt(r)))return!1;i=!0}return i&&n!=="_"}for(;r<t;r++){if(n=e[r],n==="_")continue;if(!Lee(e.charCodeAt(r)))return!1;i=!0}return i&&n!=="_"}if(n==="_")return!1;for(;r<t;r++){if(n=e[r],n==="_")continue;if(n===":")break;if(!Bee(e.charCodeAt(r)))return!1;i=!0}if(!i||n==="_")return!1;if(n!==":")return!0;return/^(:[0-5]?[0-9])+$/.test(e.slice(r))}function qee(e){var t=e,r=1,i,n,o=[];if(t.indexOf("_")!==-1)t=t.replace(/_/g,"");if(i=t[0],i==="-"||i==="+"){if(i==="-")r=-1;t=t.slice(1),i=t[0]}if(t==="0")return 0;if(i==="0"){if(t[1]==="b")return r*parseInt(t.slice(2),2);if(t[1]==="x")return r*parseInt(t,16);return r*parseInt(t,8)}if(t.indexOf(":")!==-1)return t.split(":").forEach(function(s){o.unshift(parseInt(s,10))}),t=0,n=1,o.forEach(function(s){t+=s*n,n*=60}),r*t;return r*parseInt(t,10)}function Uee(e){return Object.prototype.toString.call(e)==="[object Number]"&&(e%1===0&&!zee.isNegativeZero(e))}RD.exports=new Nee("tag:yaml.org,2002:int",{kind:"scalar",resolve:jee,construct:qee,predicate:Uee,represent:{binary:function(e){return e>=0?"0b"+e.toString(2):"-0b"+e.toString(2).slice(1)},octal:function(e){return e>=0?"0"+e.toString(8):"-0"+e.toString(8).slice(1)},decimal:function(e){return e.toString(10)},hexadecimal:function(e){return e>=0?"0x"+e.toString(16).toUpperCase():"-0x"+e.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}})});var DD=ee(function(aCe,ND){var zD=Js(),Mee=Ft(),Fee=new RegExp("^(?:[-+]?(?:0|[1-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function Zee(e){if(e===null)return!1;if(!Fee.test(e)||e[e.length-1]==="_")return!1;return!0}function Hee(e){var t,r,i,n;if(t=e.replace(/_/g,"").toLowerCase(),r=t[0]==="-"?-1:1,n=[],"+-".indexOf(t[0])>=0)t=t.slice(1);if(t===".inf")return r===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY;else if(t===".nan")return NaN;else if(t.indexOf(":")>=0)return t.split(":").forEach(function(o){n.unshift(parseFloat(o,10))}),t=0,i=1,n.forEach(function(o){t+=o*i,i*=60}),r*t;return r*parseFloat(t,10)}var Kee=/^[-+]?[0-9]+e/;function Jee(e,t){var r;if(isNaN(e))switch(t){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===e)switch(t){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===e)switch(t){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(zD.isNegativeZero(e))return"-0.0";return r=e.toString(10),Kee.test(r)?r.replace("e",".e"):r}function Vee(e){return Object.prototype.toString.call(e)==="[object Number]"&&(e%1!==0||zD.isNegativeZero(e))}ND.exports=new Mee("tag:yaml.org,2002:float",{kind:"scalar",resolve:Zee,construct:Hee,predicate:Vee,represent:Jee,defaultStyle:"lowercase"})});var YE=ee(function(cCe,LD){var Wee=Vs();LD.exports=new Wee({include:[Gh()],implicit:[CD(),OD(),PD(),DD()]})});var XE=ee(function(lCe,BD){var Gee=Vs();BD.exports=new Gee({include:[YE()]})});var MD=ee(function(uCe,UD){var Qee=Ft(),jD=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),qD=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function Yee(e){if(e===null)return!1;if(jD.exec(e)!==null)return!0;if(qD.exec(e)!==null)return!0;return!1}function Xee(e){var t,r,i,n,o,s,a,c=0,l=null,u,d,p;if(t=jD.exec(e),t===null)t=qD.exec(e);if(t===null)throw Error("Date resolve error");if(r=+t[1],i=+t[2]-1,n=+t[3],!t[4])return new Date(Date.UTC(r,i,n));if(o=+t[4],s=+t[5],a=+t[6],t[7]){c=t[7].slice(0,3);while(c.length<3)c+="0";c=+c}if(t[9]){if(u=+t[10],d=+(t[11]||0),l=(u*60+d)*60000,t[9]==="-")l=-l}if(p=new Date(Date.UTC(r,i,n,o,s,a,c)),l)p.setTime(p.getTime()-l);return p}function ete(e){return e.toISOString()}UD.exports=new Qee("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:Yee,construct:Xee,instanceOf:Date,represent:ete})});var ZD=ee(function(dCe,FD){var tte=Ft();function rte(e){return e==="<<"||e===null}FD.exports=new tte("tag:yaml.org,2002:merge",{kind:"scalar",resolve:rte})});var KD=ee(function(fCe,HD){var Ws;try{e1=Tt,Ws=e1("buffer").Buffer}catch(e){}var e1,nte=Ft(),t1=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
236
+ \r`;function ite(e){if(e===null)return!1;var t,r,i=0,n=e.length,o=t1;for(r=0;r<n;r++){if(t=o.indexOf(e.charAt(r)),t>64)continue;if(t<0)return!1;i+=6}return i%8===0}function ote(e){var t,r,i=e.replace(/[\r\n=]/g,""),n=i.length,o=t1,s=0,a=[];for(t=0;t<n;t++){if(t%4===0&&t)a.push(s>>16&255),a.push(s>>8&255),a.push(s&255);s=s<<6|o.indexOf(i.charAt(t))}if(r=n%4*6,r===0)a.push(s>>16&255),a.push(s>>8&255),a.push(s&255);else if(r===18)a.push(s>>10&255),a.push(s>>2&255);else if(r===12)a.push(s>>4&255);if(Ws)return Ws.from?Ws.from(a):new Ws(a);return a}function ste(e){var t="",r=0,i,n,o=e.length,s=t1;for(i=0;i<o;i++){if(i%3===0&&i)t+=s[r>>18&63],t+=s[r>>12&63],t+=s[r>>6&63],t+=s[r&63];r=(r<<8)+e[i]}if(n=o%3,n===0)t+=s[r>>18&63],t+=s[r>>12&63],t+=s[r>>6&63],t+=s[r&63];else if(n===2)t+=s[r>>10&63],t+=s[r>>4&63],t+=s[r<<2&63],t+=s[64];else if(n===1)t+=s[r>>2&63],t+=s[r<<4&63],t+=s[64],t+=s[64];return t}function ate(e){return Ws&&Ws.isBuffer(e)}HD.exports=new nte("tag:yaml.org,2002:binary",{kind:"scalar",resolve:ite,construct:ote,predicate:ate,represent:ste})});var VD=ee(function(mCe,JD){var cte=Ft(),lte=Object.prototype.hasOwnProperty,ute=Object.prototype.toString;function dte(e){if(e===null)return!0;var t=[],r,i,n,o,s,a=e;for(r=0,i=a.length;r<i;r+=1){if(n=a[r],s=!1,ute.call(n)!=="[object Object]")return!1;for(o in n)if(lte.call(n,o))if(!s)s=!0;else return!1;if(!s)return!1;if(t.indexOf(o)===-1)t.push(o);else return!1}return!0}function fte(e){return e!==null?e:[]}JD.exports=new cte("tag:yaml.org,2002:omap",{kind:"sequence",resolve:dte,construct:fte})});var GD=ee(function(hCe,WD){var pte=Ft(),mte=Object.prototype.toString;function hte(e){if(e===null)return!0;var t,r,i,n,o,s=e;o=Array(s.length);for(t=0,r=s.length;t<r;t+=1){if(i=s[t],mte.call(i)!=="[object Object]")return!1;if(n=Object.keys(i),n.length!==1)return!1;o[t]=[n[0],i[n[0]]]}return!0}function gte(e){if(e===null)return[];var t,r,i,n,o,s=e;o=Array(s.length);for(t=0,r=s.length;t<r;t+=1)i=s[t],n=Object.keys(i),o[t]=[n[0],i[n[0]]];return o}WD.exports=new pte("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:hte,construct:gte})});var YD=ee(function(gCe,QD){var yte=Ft(),bte=Object.prototype.hasOwnProperty;function xte(e){if(e===null)return!0;var t,r=e;for(t in r)if(bte.call(r,t)){if(r[t]!==null)return!1}return!0}function Ste(e){return e!==null?e:{}}QD.exports=new yte("tag:yaml.org,2002:set",{kind:"mapping",resolve:xte,construct:Ste})});var qc=ee(function(yCe,XD){var wte=Vs();XD.exports=new wte({include:[XE()],implicit:[MD(),ZD()],explicit:[KD(),VD(),GD(),YD()]})});var tL=ee(function(bCe,eL){var vte=Ft();function _te(){return!0}function kte(){return}function Ete(){return""}function Ite(e){return typeof e>"u"}eL.exports=new vte("tag:yaml.org,2002:js/undefined",{kind:"scalar",resolve:_te,construct:kte,predicate:Ite,represent:Ete})});var nL=ee(function(xCe,rL){var Ate=Ft();function Tte(e){if(e===null)return!1;if(e.length===0)return!1;var t=e,r=/\/([gim]*)$/.exec(e),i="";if(t[0]==="/"){if(r)i=r[1];if(i.length>3)return!1;if(t[t.length-i.length-1]!=="/")return!1}return!0}function Cte(e){var t=e,r=/\/([gim]*)$/.exec(e),i="";if(t[0]==="/"){if(r)i=r[1];t=t.slice(1,t.length-i.length-1)}return new RegExp(t,i)}function $te(e){var t="/"+e.source+"/";if(e.global)t+="g";if(e.multiline)t+="m";if(e.ignoreCase)t+="i";return t}function Ote(e){return Object.prototype.toString.call(e)==="[object RegExp]"}rL.exports=new Ate("tag:yaml.org,2002:js/regexp",{kind:"scalar",resolve:Tte,construct:Cte,predicate:Ote,represent:$te})});var oL=ee(function(SCe,iL){var Qh;try{r1=Tt,Qh=r1("esprima")}catch(e){if(typeof window<"u")Qh=window.esprima}var r1,Rte=Ft();function Pte(e){if(e===null)return!1;try{var t="("+e+")",r=Qh.parse(t,{range:!0});if(r.type!=="Program"||r.body.length!==1||r.body[0].type!=="ExpressionStatement"||r.body[0].expression.type!=="ArrowFunctionExpression"&&r.body[0].expression.type!=="FunctionExpression")return!1;return!0}catch(i){return!1}}function zte(e){var t="("+e+")",r=Qh.parse(t,{range:!0}),i=[],n;if(r.type!=="Program"||r.body.length!==1||r.body[0].type!=="ExpressionStatement"||r.body[0].expression.type!=="ArrowFunctionExpression"&&r.body[0].expression.type!=="FunctionExpression")throw Error("Failed to resolve function");if(r.body[0].expression.params.forEach(function(o){i.push(o.name)}),n=r.body[0].expression.body.range,r.body[0].expression.body.type==="BlockStatement")return Function(i,t.slice(n[0]+1,n[1]-1));return Function(i,"return "+t.slice(n[0],n[1]))}function Nte(e){return e.toString()}function Dte(e){return Object.prototype.toString.call(e)==="[object Function]"}iL.exports=new Rte("tag:yaml.org,2002:js/function",{kind:"scalar",resolve:Pte,construct:zte,predicate:Dte,represent:Nte})});var Cd=ee(function(vCe,aL){var sL=Vs();aL.exports=sL.DEFAULT=new sL({include:[qc()],explicit:[tL(),nL(),oL()]})});var AL=ee(function(sre,$d){var zi=Js(),mL=Bc(),Lte=gD(),hL=qc(),Bte=Cd(),Oo=Object.prototype.hasOwnProperty,Yh=1,gL=2,yL=3,Xh=4,n1=1,jte=2,cL=3,qte=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,Ute=/[\x85\u2028\u2029]/,Mte=/[,\[\]\{\}]/,bL=/^(?:!|!!|![a-z\-]+!)$/i,xL=/^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;function lL(e){return Object.prototype.toString.call(e)}function oi(e){return e===10||e===13}function Gs(e){return e===9||e===32}function Kr(e){return e===9||e===32||e===10||e===13}function Uc(e){return e===44||e===91||e===93||e===123||e===125}function Fte(e){var t;if(48<=e&&e<=57)return e-48;if(t=e|32,97<=t&&t<=102)return t-97+10;return-1}function Zte(e){if(e===120)return 2;if(e===117)return 4;if(e===85)return 8;return 0}function Hte(e){if(48<=e&&e<=57)return e-48;return-1}function uL(e){return e===48?"\x00":e===97?"\x07":e===98?"\b":e===116?"\t":e===9?"\t":e===110?`
237
237
  `:e===118?"\v":e===102?"\f":e===114?"\r":e===101?"\x1B":e===32?" ":e===34?'"':e===47?"/":e===92?"\\":e===78?"\x85":e===95?"\xA0":e===76?"\u2028":e===80?"\u2029":""}function Kte(e){if(e<=65535)return String.fromCharCode(e);return String.fromCharCode((e-65536>>10)+55296,(e-65536&1023)+56320)}function SL(e,t,r){if(t==="__proto__")Object.defineProperty(e,t,{configurable:!0,enumerable:!0,writable:!0,value:r});else e[t]=r}var wL=Array(256),vL=Array(256);for(Co=0;Co<256;Co++)wL[Co]=uL(Co)?1:0,vL[Co]=uL(Co);var Co;function Jte(e,t){this.input=e,this.filename=t.filename||null,this.schema=t.schema||Bte,this.onWarning=t.onWarning||null,this.legacy=t.legacy||!1,this.json=t.json||!1,this.listener=t.listener||null,this.maxTotalMergeKeys=typeof t.maxTotalMergeKeys==="number"?t.maxTotalMergeKeys:1e4,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=e.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.totalMergeKeys=0,this.documents=[]}function _L(e,t){return new mL(t,new Lte(e.filename,e.input,e.position,e.line,e.position-e.lineStart))}function Be(e,t){throw _L(e,t)}function eg(e,t){if(e.onWarning)e.onWarning.call(null,_L(e,t))}var dL={YAML:function(t,r,i){var n,o,s;if(t.version!==null)Be(t,"duplication of %YAML directive");if(i.length!==1)Be(t,"YAML directive accepts exactly one argument");if(n=/^([0-9]+)\.([0-9]+)$/.exec(i[0]),n===null)Be(t,"ill-formed argument of the YAML directive");if(o=parseInt(n[1],10),s=parseInt(n[2],10),o!==1)Be(t,"unacceptable YAML version of the document");if(t.version=i[0],t.checkLineBreaks=s<2,s!==1&&s!==2)eg(t,"unsupported YAML version of the document")},TAG:function(t,r,i){var n,o;if(i.length!==2)Be(t,"TAG directive accepts exactly two arguments");if(n=i[0],o=i[1],!bL.test(n))Be(t,"ill-formed tag handle (first argument) of the TAG directive");if(Oo.call(t.tagMap,n))Be(t,'there is a previously declared suffix for "'+n+'" tag handle');if(!xL.test(o))Be(t,"ill-formed tag prefix (second argument) of the TAG directive");t.tagMap[n]=o}};function $o(e,t,r,i){var n,o,s,a;if(t<r){if(a=e.input.slice(t,r),i){for(n=0,o=a.length;n<o;n+=1)if(s=a.charCodeAt(n),!(s===9||32<=s&&s<=1114111))Be(e,"expected valid JSON character")}else if(qte.test(a))Be(e,"the stream contains non-printable characters");e.result+=a}}function fL(e,t,r,i){var n,o,s,a;if(!zi.isObject(r))Be(e,"cannot merge mappings; the provided source object is unacceptable");n=Object.keys(r);for(s=0,a=n.length;s<a;s+=1){if(o=n[s],e.maxTotalMergeKeys!==-1&&++e.totalMergeKeys>e.maxTotalMergeKeys)Be(e,"merge keys exceeded maxTotalMergeKeys ("+e.maxTotalMergeKeys+")");if(!Oo.call(t,o))SL(t,o,r[o]),i[o]=!0}}function Mc(e,t,r,i,n,o,s,a){var c,l;if(Array.isArray(n)){n=Array.prototype.slice.call(n);for(c=0,l=n.length;c<l;c+=1){if(Array.isArray(n[c]))Be(e,"nested arrays are not supported inside keys");if(typeof n==="object"&&lL(n[c])==="[object Object]")n[c]="[object Object]"}}if(typeof n==="object"&&lL(n)==="[object Object]")n="[object Object]";if(n=String(n),t===null)t={};if(i==="tag:yaml.org,2002:merge")if(Array.isArray(o))for(c=0,l=o.length;c<l;c+=1)fL(e,t,o[c],r);else fL(e,t,o,r);else{if(!e.json&&!Oo.call(r,n)&&Oo.call(t,n))e.line=s||e.line,e.position=a||e.position,Be(e,"duplicated mapping key");SL(t,n,o),delete r[n]}return t}function i1(e){var t=e.input.charCodeAt(e.position);if(t===10)e.position++;else if(t===13){if(e.position++,e.input.charCodeAt(e.position)===10)e.position++}else Be(e,"a line break is expected");e.line+=1,e.lineStart=e.position}function Bt(e,t,r){var i=0,n=e.input.charCodeAt(e.position);while(n!==0){while(Gs(n))n=e.input.charCodeAt(++e.position);if(t&&n===35)do n=e.input.charCodeAt(++e.position);while(n!==10&&n!==13&&n!==0);if(oi(n)){i1(e),n=e.input.charCodeAt(e.position),i++,e.lineIndent=0;while(n===32)e.lineIndent++,n=e.input.charCodeAt(++e.position)}else break}if(r!==-1&&i!==0&&e.lineIndent<r)eg(e,"deficient indentation");return i}function tg(e){var t=e.position,r;if(r=e.input.charCodeAt(t),(r===45||r===46)&&r===e.input.charCodeAt(t+1)&&r===e.input.charCodeAt(t+2)){if(t+=3,r=e.input.charCodeAt(t),r===0||Kr(r))return!0}return!1}function o1(e,t){if(t===1)e.result+=" ";else if(t>1)e.result+=zi.repeat(`
238
238
  `,t-1)}function Vte(e,t,r){var i,n,o,s,a,c,l,u,d=e.kind,p=e.result,m;if(m=e.input.charCodeAt(e.position),Kr(m)||Uc(m)||m===35||m===38||m===42||m===33||m===124||m===62||m===39||m===34||m===37||m===64||m===96)return!1;if(m===63||m===45){if(n=e.input.charCodeAt(e.position+1),Kr(n)||r&&Uc(n))return!1}e.kind="scalar",e.result="",o=s=e.position,a=!1;while(m!==0){if(m===58){if(n=e.input.charCodeAt(e.position+1),Kr(n)||r&&Uc(n))break}else if(m===35){if(i=e.input.charCodeAt(e.position-1),Kr(i))break}else if(e.position===e.lineStart&&tg(e)||r&&Uc(m))break;else if(oi(m))if(c=e.line,l=e.lineStart,u=e.lineIndent,Bt(e,!1,-1),e.lineIndent>=t){a=!0,m=e.input.charCodeAt(e.position);continue}else{e.position=s,e.line=c,e.lineStart=l,e.lineIndent=u;break}if(a)$o(e,o,s,!1),o1(e,e.line-c),o=s=e.position,a=!1;if(!Gs(m))s=e.position+1;m=e.input.charCodeAt(++e.position)}if($o(e,o,s,!1),e.result)return!0;return e.kind=d,e.result=p,!1}function Wte(e,t){var r,i,n;if(r=e.input.charCodeAt(e.position),r!==39)return!1;e.kind="scalar",e.result="",e.position++,i=n=e.position;while((r=e.input.charCodeAt(e.position))!==0)if(r===39)if($o(e,i,e.position,!0),r=e.input.charCodeAt(++e.position),r===39)i=e.position,e.position++,n=e.position;else return!0;else if(oi(r))$o(e,i,n,!0),o1(e,Bt(e,!1,t)),i=n=e.position;else if(e.position===e.lineStart&&tg(e))Be(e,"unexpected end of the document within a single quoted scalar");else e.position++,n=e.position;Be(e,"unexpected end of the stream within a single quoted scalar")}function Gte(e,t){var r,i,n,o,s,a;if(a=e.input.charCodeAt(e.position),a!==34)return!1;e.kind="scalar",e.result="",e.position++,r=i=e.position;while((a=e.input.charCodeAt(e.position))!==0)if(a===34)return $o(e,r,e.position,!0),e.position++,!0;else if(a===92){if($o(e,r,e.position,!0),a=e.input.charCodeAt(++e.position),oi(a))Bt(e,!1,t);else if(a<256&&wL[a])e.result+=vL[a],e.position++;else if((s=Zte(a))>0){n=s,o=0;for(;n>0;n--)if(a=e.input.charCodeAt(++e.position),(s=Fte(a))>=0)o=(o<<4)+s;else Be(e,"expected hexadecimal character");e.result+=Kte(o),e.position++}else Be(e,"unknown escape sequence");r=i=e.position}else if(oi(a))$o(e,r,i,!0),o1(e,Bt(e,!1,t)),r=i=e.position;else if(e.position===e.lineStart&&tg(e))Be(e,"unexpected end of the document within a double quoted scalar");else e.position++,i=e.position;Be(e,"unexpected end of the stream within a double quoted scalar")}function Qte(e,t){var r=!0,i,n=e.tag,o,s=e.anchor,a,c,l,u,d,p={},m,y,g,b;if(b=e.input.charCodeAt(e.position),b===91)c=93,d=!1,o=[];else if(b===123)c=125,d=!0,o={};else return!1;if(e.anchor!==null)e.anchorMap[e.anchor]=o;b=e.input.charCodeAt(++e.position);while(b!==0){if(Bt(e,!0,t),b=e.input.charCodeAt(e.position),b===c)return e.position++,e.tag=n,e.anchor=s,e.kind=d?"mapping":"sequence",e.result=o,!0;else if(!r)Be(e,"missed comma between flow collection entries");if(y=m=g=null,l=u=!1,b===63){if(a=e.input.charCodeAt(e.position+1),Kr(a))l=u=!0,e.position++,Bt(e,!0,t)}if(i=e.line,Fc(e,t,Yh,!1,!0),y=e.tag,m=e.result,Bt(e,!0,t),b=e.input.charCodeAt(e.position),(u||e.line===i)&&b===58)l=!0,b=e.input.charCodeAt(++e.position),Bt(e,!0,t),Fc(e,t,Yh,!1,!0),g=e.result;if(d)Mc(e,o,p,y,m,g);else if(l)o.push(Mc(e,null,p,y,m,g));else o.push(m);if(Bt(e,!0,t),b=e.input.charCodeAt(e.position),b===44)r=!0,b=e.input.charCodeAt(++e.position);else r=!1}Be(e,"unexpected end of the stream within a flow collection")}function Yte(e,t){var r,i,n=n1,o=!1,s=!1,a=t,c=0,l=!1,u,d;if(d=e.input.charCodeAt(e.position),d===124)i=!1;else if(d===62)i=!0;else return!1;e.kind="scalar",e.result="";while(d!==0)if(d=e.input.charCodeAt(++e.position),d===43||d===45)if(n1===n)n=d===43?cL:jte;else Be(e,"repeat of a chomping mode identifier");else if((u=Hte(d))>=0)if(u===0)Be(e,"bad explicit indentation width of a block scalar; it cannot be less than one");else if(!s)a=t+u-1,s=!0;else Be(e,"repeat of an indentation width identifier");else break;if(Gs(d)){do d=e.input.charCodeAt(++e.position);while(Gs(d));if(d===35)do d=e.input.charCodeAt(++e.position);while(!oi(d)&&d!==0)}while(d!==0){i1(e),e.lineIndent=0,d=e.input.charCodeAt(e.position);while((!s||e.lineIndent<a)&&d===32)e.lineIndent++,d=e.input.charCodeAt(++e.position);if(!s&&e.lineIndent>a)a=e.lineIndent;if(oi(d)){c++;continue}if(e.lineIndent<a){if(n===cL)e.result+=zi.repeat(`
239
239
  `,o?1+c:c);else if(n===n1){if(o)e.result+=`
@@ -257,24 +257,24 @@ for (const spec of specs) {
257
257
  `+e.slice(n,o),n=o+1;s=a}if(c+=`
258
258
  `,e.length-n>t&&s>n)c+=e.slice(n,s)+`
259
259
  `+e.slice(s+1);else c+=e.slice(n);return c.slice(1)}function Bre(e){var t="",r,i,n;for(var o=0;o<e.length;o++){if(r=e.charCodeAt(o),r>=55296&&r<=56319){if(i=e.charCodeAt(o+1),i>=56320&&i<=57343){t+=TL((r-55296)*1024+i-56320+65536),o++;continue}}n=xr[r],t+=!n&&Zc(r)?e[o]:n||TL(r)}return t}function jre(e,t,r){var i="",n=e.tag,o,s;for(o=0,s=r.length;o<s;o+=1)if(Qs(e,t,r[o],!1,!1)){if(o!==0)i+=","+(!e.condenseFlow?" ":"");i+=e.dump}e.tag=n,e.dump="["+i+"]"}function qre(e,t,r,i){var n="",o=e.tag,s,a;for(s=0,a=r.length;s<a;s+=1)if(Qs(e,t+1,r[s],!0,!0)){if(!i||s!==0)n+=s1(e,t);if(e.dump&&Od===e.dump.charCodeAt(0))n+="-";else n+="- ";n+=e.dump}e.tag=o,e.dump=n||"[]"}function Ure(e,t,r){var i="",n=e.tag,o=Object.keys(r),s,a,c,l,u;for(s=0,a=o.length;s<a;s+=1){if(u="",s!==0)u+=", ";if(e.condenseFlow)u+='"';if(c=o[s],l=r[c],!Qs(e,t,c,!1,!1))continue;if(e.dump.length>1024)u+="? ";if(u+=e.dump+(e.condenseFlow?'"':"")+":"+(e.condenseFlow?"":" "),!Qs(e,t,l,!1,!1))continue;u+=e.dump,i+=u}e.tag=n,e.dump="{"+i+"}"}function Mre(e,t,r,i){var n="",o=e.tag,s=Object.keys(r),a,c,l,u,d,p;if(e.sortKeys===!0)s.sort();else if(typeof e.sortKeys==="function")s.sort(e.sortKeys);else if(e.sortKeys)throw new Pd("sortKeys must be a boolean or a function");for(a=0,c=s.length;a<c;a+=1){if(p="",!i||a!==0)p+=s1(e,t);if(l=s[a],u=r[l],!Qs(e,t+1,l,!0,!0,!0))continue;if(d=e.tag!==null&&e.tag!=="?"||e.dump&&e.dump.length>1024,d)if(e.dump&&Od===e.dump.charCodeAt(0))p+="?";else p+="? ";if(p+=e.dump,d)p+=s1(e,t);if(!Qs(e,t+1,u,!0,d))continue;if(e.dump&&Od===e.dump.charCodeAt(0))p+=":";else p+=": ";p+=e.dump,n+=p}e.tag=o,e.dump=n||"{}"}function zL(e,t,r){var i,n,o,s,a,c;n=r?e.explicitTypes:e.implicitTypes;for(o=0,s=n.length;o<s;o+=1)if(a=n[o],(a.instanceOf||a.predicate)&&(!a.instanceOf||typeof t==="object"&&t instanceof a.instanceOf)&&(!a.predicate||a.predicate(t))){if(e.tag=r?a.tag:"?",a.represent){if(c=e.styleMap[a.tag]||a.defaultStyle,NL.call(a.represent)==="[object Function]")i=a.represent(t,c);else if(DL.call(a.represent,c))i=a.represent[c](t,c);else throw new Pd("!<"+a.tag+'> tag resolver accepts not "'+c+'" style');e.dump=i}return!0}return!1}function Qs(e,t,r,i,n,o){if(e.tag=null,e.dump=r,!zL(e,r,!1))zL(e,r,!0);var s=NL.call(e.dump);if(i)i=e.flowLevel<0||e.flowLevel>t;var a=s==="[object Object]"||s==="[object Array]",c,l;if(a)c=e.duplicates.indexOf(r),l=c!==-1;if(e.tag!==null&&e.tag!=="?"||l||e.indent!==2&&t>0)n=!1;if(l&&e.usedDuplicates[c])e.dump="*ref_"+c;else{if(a&&l&&!e.usedDuplicates[c])e.usedDuplicates[c]=!0;if(s==="[object Object]"){if(i&&Object.keys(e.dump).length!==0){if(Mre(e,t,e.dump,n),l)e.dump="&ref_"+c+e.dump}else if(Ure(e,t,e.dump),l)e.dump="&ref_"+c+" "+e.dump}else if(s==="[object Array]"){var u=e.noArrayIndent&&t>0?t-1:t;if(i&&e.dump.length!==0){if(qre(e,u,e.dump,n),l)e.dump="&ref_"+c+e.dump}else if(jre(e,u,e.dump),l)e.dump="&ref_"+c+" "+e.dump}else if(s==="[object String]"){if(e.tag!=="?")Dre(e,e.dump,t,o)}else{if(e.skipInvalid)return!1;throw new Pd("unacceptable kind of an object to dump "+s)}if(e.tag!==null&&e.tag!=="?")e.dump="!<"+e.tag+"> "+e.dump}return!0}function Fre(e,t){var r=[],i=[],n,o;a1(e,r,i);for(n=0,o=i.length;n<o;n+=1)t.duplicates.push(r[i[n]]);t.usedDuplicates=Array(o)}function a1(e,t,r){var i,n,o;if(e!==null&&typeof e==="object")if(n=t.indexOf(e),n!==-1){if(r.indexOf(n)===-1)r.push(n)}else if(t.push(e),Array.isArray(e))for(n=0,o=e.length;n<o;n+=1)a1(e[n],t,r);else{i=Object.keys(e);for(n=0,o=i.length;n<o;n+=1)a1(e[i[n]],t,r)}}function WL(e,t){t=t||{};var r=new Ore(t);if(!r.noRefs)Fre(e,r);if(Qs(r,0,e,!0,!0))return r.dump+`
260
- `;return""}function Zre(e,t){return WL(e,Rd.extend({schema:fre},t))}Hre.dump=WL;Hre.safeDump=Zre});var YL=ee(function(Vre,Et){var ng=AL(),QL=GL();function ig(e){return function(){throw Error("Function "+e+" is deprecated and cannot be used.")}}Vre.Type=Ft();Vre.Schema=Vs();Vre.FAILSAFE_SCHEMA=Gh();Vre.JSON_SCHEMA=YE();Vre.CORE_SCHEMA=XE();Vre.DEFAULT_SAFE_SCHEMA=qc();Vre.DEFAULT_FULL_SCHEMA=Cd();Vre.load=ng.load;Vre.loadAll=ng.loadAll;Vre.safeLoad=ng.safeLoad;Vre.safeLoadAll=ng.safeLoadAll;Vre.dump=QL.dump;Vre.safeDump=QL.safeDump;Vre.YAMLException=Bc();Vre.MINIMAL_SCHEMA=Gh();Vre.SAFE_SCHEMA=qc();Vre.DEFAULT_SCHEMA=Cd();Vre.scan=ig("scan");Vre.parse=ig("parse");Vre.compose=ig("compose");Vre.addConstructor=ig("addConstructor")});var eB=ee(function(kCe,XL){var gne=YL();XL.exports=gne});var p1=ee(function(d1,f1){var og=eB(),u1=d1=f1.exports;u1.yaml={parse:og.safeLoad.bind(og),stringify:og.safeDump.bind(og)};u1.json={parse:JSON.parse.bind(JSON),stringify:function(e,t){let r=Object.assign({replacer:null,space:2},t);return JSON.stringify(e,r.replacer,r.space)}};u1.javascript={parse:function parse(str,options,wrap){try{if(wrap!==!1)str=`(function() {
260
+ `;return""}function Zre(e,t){return WL(e,Rd.extend({schema:fre},t))}Hre.dump=WL;Hre.safeDump=Zre});var YL=ee(function(Vre,Et){var ng=AL(),QL=GL();function ig(e){return function(){throw Error("Function "+e+" is deprecated and cannot be used.")}}Vre.Type=Ft();Vre.Schema=Vs();Vre.FAILSAFE_SCHEMA=Gh();Vre.JSON_SCHEMA=YE();Vre.CORE_SCHEMA=XE();Vre.DEFAULT_SAFE_SCHEMA=qc();Vre.DEFAULT_FULL_SCHEMA=Cd();Vre.load=ng.load;Vre.loadAll=ng.loadAll;Vre.safeLoad=ng.safeLoad;Vre.safeLoadAll=ng.safeLoadAll;Vre.dump=QL.dump;Vre.safeDump=QL.safeDump;Vre.YAMLException=Bc();Vre.MINIMAL_SCHEMA=Gh();Vre.SAFE_SCHEMA=qc();Vre.DEFAULT_SCHEMA=Cd();Vre.scan=ig("scan");Vre.parse=ig("parse");Vre.compose=ig("compose");Vre.addConstructor=ig("addConstructor")});var eB=ee(function(_Ce,XL){var gne=YL();XL.exports=gne});var p1=ee(function(d1,f1){var og=eB(),u1=d1=f1.exports;u1.yaml={parse:og.safeLoad.bind(og),stringify:og.safeDump.bind(og)};u1.json={parse:JSON.parse.bind(JSON),stringify:function(e,t){let r=Object.assign({replacer:null,space:2},t);return JSON.stringify(e,r.replacer,r.space)}};u1.javascript={parse:function parse(str,options,wrap){try{if(wrap!==!1)str=`(function() {
261
261
  return `+str.trim()+`;
262
- }());`;return eval(str)||{}}catch(e){if(wrap!==!1&&/(unexpected|identifier)/i.test(e.message))return parse(str,options,!1);throw SyntaxError(e)}},stringify:function(){throw Error("stringifying JavaScript is not supported")}}});var rB=ee(function(ECe,tB){/*!
262
+ }());`;return eval(str)||{}}catch(e){if(wrap!==!1&&/(unexpected|identifier)/i.test(e.message))return parse(str,options,!1);throw SyntaxError(e)}},stringify:function(){throw Error("stringifying JavaScript is not supported")}}});var rB=ee(function(kCe,tB){/*!
263
263
  * strip-bom-string <https://github.com/jonschlinkert/strip-bom-string>
264
264
  *
265
265
  * Copyright (c) 2015, 2017, Jon Schlinkert.
266
266
  * Released under the MIT License.
267
- */tB.exports=function(e){if(typeof e==="string"&&e.charAt(0)==="\uFEFF")return e.slice(1);return e}});var sg=ee(function(yne){var nB=rB(),iB=Ad();yne.define=function(e,t,r){Reflect.defineProperty(e,t,{enumerable:!1,configurable:!0,writable:!0,value:r})};yne.isBuffer=function(e){return iB(e)==="buffer"};yne.isObject=function(e){return iB(e)==="object"};yne.toBuffer=function(e){return typeof e==="string"?Buffer.from(e):e};yne.toString=function(e){if(yne.isBuffer(e))return nB(String(e));if(typeof e!=="string")throw TypeError("expected input to be a string or buffer");return nB(e)};yne.arrayify=function(e){return e?Array.isArray(e)?e:[e]:[]};yne.startsWith=function(e,t,r){if(typeof r!=="number")r=t.length;return e.slice(0,r)===t}});var zd=ee(function(ACe,sB){var kne=p1(),Ene=sg();sB.exports=function(e){let t=Object.assign({},e);if(t.delimiters=Ene.arrayify(t.delims||t.delimiters||"---"),t.delimiters.length===1)t.delimiters.push(t.delimiters[0]);return t.language=(t.language||t.lang||"yaml").toLowerCase(),t.engines=Object.assign({},kne,t.parsers,t.engines),t}});var m1=ee(function(TCe,aB){aB.exports=function(e,t){let r=t.engines[e]||t.engines[Ine(e)];if(typeof r>"u")throw Error('gray-matter engine "'+e+'" is not registered');if(typeof r==="function")r={parse:r};return r};function Ine(e){switch(e.toLowerCase()){case"js":case"javascript":return"javascript";case"coffee":case"coffeescript":case"cson":return"coffee";case"yaml":case"yml":return"yaml";default:return e}}});var h1=ee(function(CCe,cB){var Ane=Ad(),Tne=m1(),Cne=zd();cB.exports=function(e,t,r){if(t==null&&r==null)switch(Ane(e)){case"object":t=e.data,r={};break;case"string":return e;default:throw TypeError("expected file to be a string or object")}let i=e.content,n=Cne(r);if(t==null){if(!n.data)return e;t=n.data}let o=e.language||n.language,s=Tne(o,n);if(typeof s.stringify!=="function")throw TypeError('expected "'+o+'.stringify" to be a function');t=Object.assign({},e.data,t);let a=n.delimiters[0],c=n.delimiters[1],l=s.stringify(t,r).trim(),u="";if(l!=="{}")u=Hc(a)+Hc(l)+Hc(c);if(typeof e.excerpt==="string"&&e.excerpt!==""){if(i.indexOf(e.excerpt.trim())===-1)u+=Hc(e.excerpt)+Hc(c)}return u+Hc(i)};function Hc(e){return e.slice(-1)!==`
267
+ */tB.exports=function(e){if(typeof e==="string"&&e.charAt(0)==="\uFEFF")return e.slice(1);return e}});var sg=ee(function(yne){var nB=rB(),iB=Ad();yne.define=function(e,t,r){Reflect.defineProperty(e,t,{enumerable:!1,configurable:!0,writable:!0,value:r})};yne.isBuffer=function(e){return iB(e)==="buffer"};yne.isObject=function(e){return iB(e)==="object"};yne.toBuffer=function(e){return typeof e==="string"?Buffer.from(e):e};yne.toString=function(e){if(yne.isBuffer(e))return nB(String(e));if(typeof e!=="string")throw TypeError("expected input to be a string or buffer");return nB(e)};yne.arrayify=function(e){return e?Array.isArray(e)?e:[e]:[]};yne.startsWith=function(e,t,r){if(typeof r!=="number")r=t.length;return e.slice(0,r)===t}});var zd=ee(function(ICe,sB){var kne=p1(),Ene=sg();sB.exports=function(e){let t=Object.assign({},e);if(t.delimiters=Ene.arrayify(t.delims||t.delimiters||"---"),t.delimiters.length===1)t.delimiters.push(t.delimiters[0]);return t.language=(t.language||t.lang||"yaml").toLowerCase(),t.engines=Object.assign({},kne,t.parsers,t.engines),t}});var m1=ee(function(ACe,aB){aB.exports=function(e,t){let r=t.engines[e]||t.engines[Ine(e)];if(typeof r>"u")throw Error('gray-matter engine "'+e+'" is not registered');if(typeof r==="function")r={parse:r};return r};function Ine(e){switch(e.toLowerCase()){case"js":case"javascript":return"javascript";case"coffee":case"coffeescript":case"cson":return"coffee";case"yaml":case"yml":return"yaml";default:return e}}});var h1=ee(function(TCe,cB){var Ane=Ad(),Tne=m1(),Cne=zd();cB.exports=function(e,t,r){if(t==null&&r==null)switch(Ane(e)){case"object":t=e.data,r={};break;case"string":return e;default:throw TypeError("expected file to be a string or object")}let i=e.content,n=Cne(r);if(t==null){if(!n.data)return e;t=n.data}let o=e.language||n.language,s=Tne(o,n);if(typeof s.stringify!=="function")throw TypeError('expected "'+o+'.stringify" to be a function');t=Object.assign({},e.data,t);let a=n.delimiters[0],c=n.delimiters[1],l=s.stringify(t,r).trim(),u="";if(l!=="{}")u=Hc(a)+Hc(l)+Hc(c);if(typeof e.excerpt==="string"&&e.excerpt!==""){if(i.indexOf(e.excerpt.trim())===-1)u+=Hc(e.excerpt)+Hc(c)}return u+Hc(i)};function Hc(e){return e.slice(-1)!==`
268
268
  `?e+`
269
- `:e}});var uB=ee(function($Ce,lB){var $ne=zd();lB.exports=function(e,t){let r=$ne(t);if(e.data==null)e.data={};if(typeof r.excerpt==="function")return r.excerpt(e,r);let i=e.data.excerpt_separator||r.excerpt_separator;if(i==null&&(r.excerpt===!1||r.excerpt==null))return e;let n=typeof r.excerpt==="string"?r.excerpt:i||r.delimiters[0],o=e.content.indexOf(n);if(o!==-1)e.excerpt=e.content.slice(0,o);return e}});var pB=ee(function(OCe,fB){var dB=Ad(),One=h1(),Kc=sg();fB.exports=function(e){if(dB(e)!=="object")e={content:e};if(dB(e.data)!=="object")e.data={};if(e.contents&&e.content==null)e.content=e.contents;return Kc.define(e,"orig",Kc.toBuffer(e.content)),Kc.define(e,"language",e.language||""),Kc.define(e,"matter",e.matter||""),Kc.define(e,"stringify",function(t,r){if(r&&r.language)e.language=r.language;return One(e,t,r)}),e.content=Kc.toString(e.content),e.isEmpty=!1,e.excerpt="",e}});var hB=ee(function(RCe,mB){var Rne=m1(),Pne=zd();mB.exports=function(e,t,r){let i=Pne(r),n=Rne(e,i);if(typeof n.parse!=="function")throw TypeError('expected "'+e+'.parse" to be a function');return n.parse(t,i)}});var xB=ee(function(PCe,bB){var zne=Tt("fs"),Nne=dD(),g1=zd(),Dne=h1(),gB=uB(),Lne=p1(),Bne=pB(),jne=hB(),yB=sg();function zr(e,t){if(e==="")return{data:{},content:e,excerpt:"",orig:e};let r=Bne(e),i=zr.cache[r.content];if(!t){if(i)return r=Object.assign({},i),r.orig=i.orig,r;zr.cache[r.content]=r}return qne(r,t)}function qne(e,t){let r=g1(t),i=r.delimiters[0],n=`
269
+ `:e}});var uB=ee(function(CCe,lB){var $ne=zd();lB.exports=function(e,t){let r=$ne(t);if(e.data==null)e.data={};if(typeof r.excerpt==="function")return r.excerpt(e,r);let i=e.data.excerpt_separator||r.excerpt_separator;if(i==null&&(r.excerpt===!1||r.excerpt==null))return e;let n=typeof r.excerpt==="string"?r.excerpt:i||r.delimiters[0],o=e.content.indexOf(n);if(o!==-1)e.excerpt=e.content.slice(0,o);return e}});var pB=ee(function($Ce,fB){var dB=Ad(),One=h1(),Kc=sg();fB.exports=function(e){if(dB(e)!=="object")e={content:e};if(dB(e.data)!=="object")e.data={};if(e.contents&&e.content==null)e.content=e.contents;return Kc.define(e,"orig",Kc.toBuffer(e.content)),Kc.define(e,"language",e.language||""),Kc.define(e,"matter",e.matter||""),Kc.define(e,"stringify",function(t,r){if(r&&r.language)e.language=r.language;return One(e,t,r)}),e.content=Kc.toString(e.content),e.isEmpty=!1,e.excerpt="",e}});var hB=ee(function(OCe,mB){var Rne=m1(),Pne=zd();mB.exports=function(e,t,r){let i=Pne(r),n=Rne(e,i);if(typeof n.parse!=="function")throw TypeError('expected "'+e+'.parse" to be a function');return n.parse(t,i)}});var xB=ee(function(RCe,bB){var zne=Tt("fs"),Nne=dD(),g1=zd(),Dne=h1(),gB=uB(),Lne=p1(),Bne=pB(),jne=hB(),yB=sg();function zr(e,t){if(e==="")return{data:{},content:e,excerpt:"",orig:e};let r=Bne(e),i=zr.cache[r.content];if(!t){if(i)return r=Object.assign({},i),r.orig=i.orig,r;zr.cache[r.content]=r}return qne(r,t)}function qne(e,t){let r=g1(t),i=r.delimiters[0],n=`
270
270
  `+r.delimiters[1],o=e.content;if(r.language)e.language=r.language;let s=i.length;if(!yB.startsWith(o,i,s))return gB(e,r),e;if(o.charAt(s)===i.slice(-1))return e;o=o.slice(s);let a=o.length,c=zr.language(o,r);if(c.name)e.language=c.name,o=o.slice(c.raw.length);let l=o.indexOf(n);if(l===-1)l=a;if(e.matter=o.slice(0,l),e.matter.replace(/^\s*#[^\n]+/gm,"").trim()==="")e.isEmpty=!0,e.empty=e.content,e.data={};else e.data=jne(e.language,e.matter,r);if(l===a)e.content="";else{if(e.content=o.slice(l+n.length),e.content[0]==="\r")e.content=e.content.slice(1);if(e.content[0]===`
271
- `)e.content=e.content.slice(1)}if(gB(e,r),r.sections===!0||typeof r.section==="function")Nne(e,r.section);return e}zr.engines=Lne;zr.stringify=function(e,t,r){if(typeof e==="string")e=zr(e,r);return Dne(e,t,r)};zr.read=function(e,t){let r=zne.readFileSync(e,"utf8"),i=zr(r,t);return i.path=e,i};zr.test=function(e,t){return yB.startsWith(e,g1(t).delimiters[0])};zr.language=function(e,t){let i=g1(t).delimiters[0];if(zr.test(e))e=e.slice(i.length);let n=e.slice(0,e.search(/\r?\n/));return{raw:n,name:n?n.trim():""}};zr.cache={};zr.clearCache=function(){zr.cache={}};bB.exports=zr});var Une;var ag=x(()=>{Une=rc(xB(),1)});var SB=x(()=>{ag();WE()});var Mne,cg,Fne,b1="data-ask-sheet",Zne;var x1=x(()=>{Re();Mne=f.object({public:f.boolean(),preview:f.boolean()}),cg=f.object({name:f.string().trim().min(1).max(200),url:f.string().url().optional()}),Fne=f.object({sources:f.array(f.object({id:f.string(),title:f.string(),brain:cg.optional()}))}),Zne=`body *:not([${b1}], [${b1}] *) { -webkit-backdrop-filter: none !important; backdrop-filter: none !important; }`});var wB,Hne;var vB=x(()=>{Re();wB=f.object({type:f.literal("event"),event:f.string().min(1),fromState:f.string().min(1).optional()}),Hne=f.object({conversationId:f.string().min(1),interfaceType:f.string().min(1),channelId:f.string().min(1).optional(),channelName:f.string().min(1),userPermissionLevel:f.enum(["admin","trusted","public"]),isAnchor:f.boolean(),action:wB})});var Kne,ZCe,Jc,Jne,Vne,_B,HCe,Wne,Gne,kB;var EB=x(()=>{Re();Kne=f.strictObject({messageCharacters:f.number().int().positive(),requestTimeoutSeconds:f.number().int().positive().max(2147483)}),ZCe=f.strictObject({limits:Kne,maxCostMicroUsd:f.number().int().positive()}),Jc=f.number().int().nonnegative(),Jne=f.strictObject({modelCalls:Jc,inputTokens:Jc,cachedInputTokens:Jc,outputTokens:Jc,reasoningTokens:Jc,embeddingTokens:Jc}),Vne=f.discriminatedUnion("state",[f.strictObject({state:f.literal("known"),microUsd:f.number().int().nonnegative(),pricing:f.string().trim().min(1).max(120)}),f.strictObject({state:f.literal("unknown"),reason:f.enum(["missing-usage","unsupported-pricing"])})]),_B=f.strictObject({usage:Jne,cost:Vne}),HCe=f.strictObject({topics:f.array(f.string().trim().min(1).max(500)).max(20),introduction:f.string().trim().min(1).max(4000).optional(),refusal:f.string().trim().min(1).max(500).optional()}),Wne=f.enum(["in-scope","off-topic","abusive","injection","harmful"]),Gne=Wne.exclude(["in-scope"]),kB=f.discriminatedUnion("outcome",[f.strictObject({outcome:f.literal("answered")}),f.strictObject({outcome:f.literal("refused"),category:Gne}),f.strictObject({outcome:f.literal("unscreened")})])});var IB,AB,TB,CB,$B,OB,lg,RB,PB,zB,NB,DB,LB,BB,jB,Qne;var S1=x(()=>{Re();x1();EB();IB=f.object({id:f.string(),toolCallId:f.string().optional(),toolName:f.string(),summary:f.string(),completionSummary:f.string().optional(),preview:f.string().optional(),args:f.unknown()}),AB=f.enum(["approval-requested","approval-responded","output-available","output-denied","output-error"]),TB=f.object({kind:f.literal("tool-approval"),id:f.string(),toolCallId:f.string().optional(),toolName:f.string(),input:f.record(f.string(),f.unknown()).optional(),summary:f.string(),completionSummary:f.string().optional(),preview:f.string().optional(),state:AB,output:f.unknown().optional(),error:f.string().optional()}),CB=f.object({entityType:f.string().optional(),entityId:f.string().optional(),attachmentType:f.string().optional()}),$B=f.object({mediaType:f.string().min(1),url:f.string().min(1),downloadUrl:f.string().min(1).optional(),previewUrl:f.string().min(1).optional(),filename:f.string().min(1).optional(),sizeBytes:f.number().nonnegative().optional(),source:CB.optional()}),OB=f.object({kind:f.literal("attachment"),id:f.string(),jobId:f.string().optional(),title:f.string(),description:f.string().optional(),attachment:$B}),lg=f.object({id:f.string().min(1),title:f.string().min(1).optional(),source:f.string().min(1),url:f.string().min(1).optional(),entityType:f.string().min(1).optional(),entityId:f.string().min(1).optional(),excerpt:f.string().min(1).optional(),provenance:f.record(f.string(),f.unknown()).optional(),brain:cg.optional()}),RB=f.object({kind:f.literal("sources"),id:f.string().min(1),title:f.string().min(1).optional(),sources:f.array(lg).min(1)}),PB=f.object({type:f.literal("prompt"),id:f.string().min(1),label:f.string().min(1),prompt:f.string().min(1),description:f.string().min(1).optional()}),zB=f.object({type:f.literal("event"),id:f.string().min(1),label:f.string().min(1),event:f.string().min(1),fromState:f.string().min(1).optional(),description:f.string().min(1).optional()}),NB=f.discriminatedUnion("type",[PB,zB]),DB=f.object({kind:f.literal("actions"),id:f.string().min(1),title:f.string().min(1).optional(),defaultOpen:f.boolean().optional(),actions:f.array(NB).min(1)}),LB=f.discriminatedUnion("kind",[TB,OB,RB,DB]),BB=f.object({toolName:f.string(),args:f.record(f.string(),f.unknown()).optional(),jobId:f.string().optional(),data:f.unknown().optional(),error:f.object({message:f.string(),code:f.string().optional()}).optional()}),jB=f.object({faqId:f.string().min(1)}),Qne=f.object({text:f.string(),error:f.string().optional(),toolResults:f.array(BB).optional(),cards:f.array(LB).optional(),pendingConfirmations:f.array(IB).optional(),usage:f.object({promptTokens:f.number(),completionTokens:f.number(),totalTokens:f.number()}),guestSettlement:_B.optional(),guestScreening:kB.optional(),askedBefore:jB.optional()})});var Yne,qB,Xne;var UB=x(()=>{Re();S1();Yne=f.object({question:f.string().trim().min(1)}),qB=f.object({faqId:f.string().min(1),answer:f.string().trim().min(1),sources:f.array(lg).default([])}),Xne=f.object({hit:qB.optional()})});var MB,eie,FB,tie;var ZB=x(()=>{Re();MB=f.enum(["admin","trusted","public"]),eie=f.object({conversationId:f.string().min(1),message:f.string(),interfaceType:f.string().min(1),channelId:f.string().optional(),channelName:f.string().optional(),userPermissionLevel:MB}),FB=f.object({id:f.string().min(1),source:f.string().min(1),title:f.string().optional(),content:f.string().min(1),provenance:f.record(f.string(),f.unknown()).optional()}),tie=f.object({items:f.array(FB).default([])})});var Vc;var w1=x(()=>{Re();Vc=f.discriminatedUnion("kind",[f.object({kind:f.literal("user"),userId:f.string().min(1),canonicalId:f.string().min(1).optional()}),f.object({kind:f.literal("external"),externalActorId:f.string().min(1)}),f.object({kind:f.literal("agent"),agentId:f.string().min(1)}),f.object({kind:f.literal("service"),serviceId:f.string().min(1)})])});var rie,HB,nie;var KB=x(()=>{Re();w1();rie=f.object({actor:Vc}),HB=f.object({userId:f.string().min(1),personId:f.string().min(1),canonicalId:f.string().min(1).optional(),displayName:f.string().min(1),permissionLevel:f.enum(["admin","trusted","public"])}),nie=f.object({principal:HB.nullable()})});var v1,iie,oie;var JB=x(()=>{Re();v1=f.strictObject({name:f.string().min(1).optional(),address:f.email()}),iie=f.strictObject({personId:f.string().min(1).max(200),displayName:f.string().trim().min(1).max(200),permissionLevel:f.enum(["admin","trusted","public"])}),oie=f.strictObject({messageId:f.string().min(1),sourceRef:f.string().min(1),threadId:f.string().min(1).optional(),from:v1,replyTo:v1.optional(),to:f.array(v1),subject:f.string(),receivedAt:f.iso.datetime(),text:f.string(),html:f.string().min(1).optional(),headers:f.strictObject({listUnsubscribe:f.string().min(1).optional(),autoSubmitted:f.string().min(1).optional(),precedence:f.string().min(1).optional(),inReplyTo:f.string().min(1).optional(),references:f.array(f.string().min(1)).optional()}),sender:iie.optional()})});var sie,aie,cie,_1,lie,uie;var VB=x(()=>{Re();sie=f.strictObject({permissionLevel:f.enum(["admin","trusted","public"])}),aie=f.custom((e)=>typeof AbortSignal<"u"&&e instanceof AbortSignal),cie=f.strictObject({sourceRef:f.string().regex(/^imap:[a-f0-9]{64}$/),actor:sie,signal:aie.optional()}),_1=f.strictObject({name:f.string().trim().min(1).max(300).optional(),address:f.email().max(320)}),lie=f.strictObject({messageId:f.string().trim().min(1).max(2000),from:_1,replyTo:_1.optional(),to:f.array(_1).max(100),subject:f.string().max(1000),receivedAt:f.iso.datetime(),text:f.string().max(1e5),inReplyTo:f.string().trim().min(1).max(2000).optional(),references:f.array(f.string().trim().min(1).max(2000)).max(100),truncated:f.boolean()}),uie=f.discriminatedUnion("kind",[f.strictObject({kind:f.literal("available"),message:lie}),f.strictObject({kind:f.literal("unavailable")})])});var WB=()=>{};var GB=x(()=>{WB()});var die;var QB=x(()=>{Re();die=f.object({url:f.string(),authToken:f.string().optional()})});var fie;var YB=x(()=>{Re();fie=f.object({success:f.boolean(),entityId:f.string().optional(),error:f.string().optional()})});var XB=()=>{};var ug,pie;var ej=x(()=>{Re();ug=f.lazy(()=>f.union([f.null(),f.boolean(),f.number().finite().refine((e)=>!Number.isInteger(e)||Number.isSafeInteger(e),{message:"integer exceeds the JSON-safe range"}),f.string(),f.array(ug),f.record(f.string(),ug)])),pie=f.record(f.string(),ug)});var mie;var tj=x(()=>{Re();mie=f.enum(["user","assistant"])});var rj,Ro;var nj=x(()=>{Re();rj=f.object({entityType:f.string().min(1),entityId:f.string().min(1),contentHash:f.string().min(1).optional()}),Ro=f.object({rootJobId:f.string().min(1),causationId:f.string().min(1),projectionId:f.string().min(1).optional(),projectionLineage:f.array(f.string().min(1)),sourceEntity:rj.optional(),derivationDepth:f.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 ij=()=>{};var hie,gie;var oj=x(()=>{Re();hie=f.object({entityType:f.string().min(1),entityId:f.string(),metadata:f.record(f.string(),f.unknown()).default({}),content:f.string().default("")}),gie=f.object({relativePath:f.string(),leaf:f.object({start:f.number().int().nonnegative(),end:f.number().int().nonnegative()}).nullable(),owner:f.object({entityType:f.string(),id:f.string()}).optional(),writable:f.boolean().optional()})});var sj=()=>{};var yie;var aj=x(()=>{Re();yie=f.strictObject({waveId:f.string().trim().min(1),sourceTypes:f.array(f.string().trim().min(1)),changedTargetTypes:f.array(f.string().trim().min(1))})});var cj,lj,uj,bie;var dj=x(()=>{ag();Re();cj=f.object({audiences:f.array(f.string()).optional(),positioning:f.string().optional()}),lj=f.object({summary:f.string().optional(),traits:f.array(f.string()).optional(),principles:f.array(f.string()).optional(),preferredTerms:f.array(f.string()).optional(),avoid:f.array(f.string()).optional()}),uj=f.object({artDirection:f.string().optional(),palette:f.array(f.string()).optional(),composition:f.string().optional(),mood:f.string().optional(),preferred:f.array(f.string()).optional(),avoid:f.array(f.string()).optional()}),bie=f.object({name:f.string().describe("Style guide name"),messaging:cj.optional(),voice:lj.optional(),visual:uj.optional()})});var xie;var fj=x(()=>{Re();xie=f.object({id:f.string().min(1),trigger:f.string().min(1),playbookId:f.string().min(1),once:f.boolean().default(!0),starterText:f.string().min(1),description:f.string().min(1).optional(),starterPrompt:f.string().min(1)}).strict()});var Sie,wie,pj,mj;var hj=x(()=>{Re();Sie=f.object({message:f.string().describe("Natural language response to the query"),summary:f.string().optional().describe("Brief summary if applicable"),topics:f.array(f.string()).optional().describe("Related topics mentioned"),sources:f.array(f.object({id:f.string(),type:f.string(),excerpt:f.string().optional(),relevance:f.number().min(0).max(1).optional()})).optional().describe("Source entities used to answer the query"),metadata:f.record(f.string(),f.unknown()).optional()}).describe("defaultQueryResponse"),wie=f.object({message:f.string()}).describe("simpleTextResponse"),pj=f.object({success:f.boolean(),entityId:f.string().optional(),message:f.string()}).describe("createEntityResponse"),mj=f.object({success:f.boolean(),entityId:f.string(),changes:f.array(f.string()).optional(),message:f.string()}).describe("updateEntityResponse")});var gj,Z$e,yj,vie,_ie;var bj=x(()=>{Re();gj={recipientMissing:"Notification recipient missing",transportMissing:"Notification transport missing",deliveryFailed:"Notification delivery failed"},Z$e=new RegExp(`^${gj.deliveryFailed}: ([a-z0-9_:.-]{1,80})$`),yj=f.discriminatedUnion("type",[f.strictObject({type:f.literal("email"),address:f.email()})]),vie=f.strictObject({recipient:yj.optional(),title:f.string().min(1),body:f.string().min(1),html:f.string().min(1).optional(),sensitivity:f.enum(["normal","secret"]).default("normal"),idempotencyKey:f.string().trim().min(1).max(200).optional()}),_ie=f.discriminatedUnion("status",[f.strictObject({status:f.literal("sent"),deliveryId:f.string().optional()}),f.strictObject({status:f.literal("failed")})])});var kie;var xj=x(()=>{Re();kie=f.strictObject({titles:f.array(f.string().trim().min(1).max(500)).max(20)})});var Eie,Iie;var Sj=x(()=>{Re();Eie=f.strictObject({id:f.string().regex(/^[a-z0-9][a-z0-9-]{0,79}$/),title:f.string().trim().min(1).max(200),body:f.string().trim().min(1).max(20000)}),Iie=f.strictObject({noteId:f.string(),created:f.boolean()})});var Po=x(()=>{WE();SB();x1();vB();S1();UB();ZB();w1();KB();JB();VB();GB();QB();YB();XB();ej();tj();nj();ij();oj();sj();aj();dj();fj();hj();bj();xj();Sj()});var wj=x(()=>{Id();Po()});var vj=x(()=>{Id();Po()});var _j=()=>{};function B(e,t){Cie(Boolean(e),!1,!0,"ok","Expected value to be truthy",t)}function Cie(e,t,r,i,n,o){if(!e)throw o instanceof Error?o:new kj(o||n,t,r,i,!o)}var kj;var tt=x(()=>{_j();kj=class kj extends Error{name="Assertion";code="ERR_ASSERTION";constructor(e,t,r,i,n){super(e);if(Error.captureStackTrace)Error.captureStackTrace(this,this.constructor);this.actual=t,this.expected=r,this.generated=n,this.operator=i}}});function Ys(e,t){let r=t||$ie,i=typeof r.includeImageAlt==="boolean"?r.includeImageAlt:!0,n=typeof r.includeHtml==="boolean"?r.includeHtml:!0;return Ij(e,i,n)}function Ij(e,t,r){if(Oie(e)){if("value"in e)return e.type==="html"&&!r?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return Ej(e.children,t,r)}if(Array.isArray(e))return Ej(e,t,r);return""}function Ej(e,t,r){let i=[],n=-1;while(++n<e.length)i[n]=Ij(e[n],t,r);return i.join("")}function Oie(e){return Boolean(e&&typeof e==="object")}var $ie;var Aj=x(()=>{$ie={}});var dg=x(()=>{Aj()});var k1;var Tj=x(()=>{k1={AElig:"\xC6",AMP:"&",Aacute:"\xC1",Abreve:"\u0102",Acirc:"\xC2",Acy:"\u0410",Afr:"\uD835\uDD04",Agrave:"\xC0",Alpha:"\u0391",Amacr:"\u0100",And:"\u2A53",Aogon:"\u0104",Aopf:"\uD835\uDD38",ApplyFunction:"\u2061",Aring:"\xC5",Ascr:"\uD835\uDC9C",Assign:"\u2254",Atilde:"\xC3",Auml:"\xC4",Backslash:"\u2216",Barv:"\u2AE7",Barwed:"\u2306",Bcy:"\u0411",Because:"\u2235",Bernoullis:"\u212C",Beta:"\u0392",Bfr:"\uD835\uDD05",Bopf:"\uD835\uDD39",Breve:"\u02D8",Bscr:"\u212C",Bumpeq:"\u224E",CHcy:"\u0427",COPY:"\xA9",Cacute:"\u0106",Cap:"\u22D2",CapitalDifferentialD:"\u2145",Cayleys:"\u212D",Ccaron:"\u010C",Ccedil:"\xC7",Ccirc:"\u0108",Cconint:"\u2230",Cdot:"\u010A",Cedilla:"\xB8",CenterDot:"\xB7",Cfr:"\u212D",Chi:"\u03A7",CircleDot:"\u2299",CircleMinus:"\u2296",CirclePlus:"\u2295",CircleTimes:"\u2297",ClockwiseContourIntegral:"\u2232",CloseCurlyDoubleQuote:"\u201D",CloseCurlyQuote:"\u2019",Colon:"\u2237",Colone:"\u2A74",Congruent:"\u2261",Conint:"\u222F",ContourIntegral:"\u222E",Copf:"\u2102",Coproduct:"\u2210",CounterClockwiseContourIntegral:"\u2233",Cross:"\u2A2F",Cscr:"\uD835\uDC9E",Cup:"\u22D3",CupCap:"\u224D",DD:"\u2145",DDotrahd:"\u2911",DJcy:"\u0402",DScy:"\u0405",DZcy:"\u040F",Dagger:"\u2021",Darr:"\u21A1",Dashv:"\u2AE4",Dcaron:"\u010E",Dcy:"\u0414",Del:"\u2207",Delta:"\u0394",Dfr:"\uD835\uDD07",DiacriticalAcute:"\xB4",DiacriticalDot:"\u02D9",DiacriticalDoubleAcute:"\u02DD",DiacriticalGrave:"`",DiacriticalTilde:"\u02DC",Diamond:"\u22C4",DifferentialD:"\u2146",Dopf:"\uD835\uDD3B",Dot:"\xA8",DotDot:"\u20DC",DotEqual:"\u2250",DoubleContourIntegral:"\u222F",DoubleDot:"\xA8",DoubleDownArrow:"\u21D3",DoubleLeftArrow:"\u21D0",DoubleLeftRightArrow:"\u21D4",DoubleLeftTee:"\u2AE4",DoubleLongLeftArrow:"\u27F8",DoubleLongLeftRightArrow:"\u27FA",DoubleLongRightArrow:"\u27F9",DoubleRightArrow:"\u21D2",DoubleRightTee:"\u22A8",DoubleUpArrow:"\u21D1",DoubleUpDownArrow:"\u21D5",DoubleVerticalBar:"\u2225",DownArrow:"\u2193",DownArrowBar:"\u2913",DownArrowUpArrow:"\u21F5",DownBreve:"\u0311",DownLeftRightVector:"\u2950",DownLeftTeeVector:"\u295E",DownLeftVector:"\u21BD",DownLeftVectorBar:"\u2956",DownRightTeeVector:"\u295F",DownRightVector:"\u21C1",DownRightVectorBar:"\u2957",DownTee:"\u22A4",DownTeeArrow:"\u21A7",Downarrow:"\u21D3",Dscr:"\uD835\uDC9F",Dstrok:"\u0110",ENG:"\u014A",ETH:"\xD0",Eacute:"\xC9",Ecaron:"\u011A",Ecirc:"\xCA",Ecy:"\u042D",Edot:"\u0116",Efr:"\uD835\uDD08",Egrave:"\xC8",Element:"\u2208",Emacr:"\u0112",EmptySmallSquare:"\u25FB",EmptyVerySmallSquare:"\u25AB",Eogon:"\u0118",Eopf:"\uD835\uDD3C",Epsilon:"\u0395",Equal:"\u2A75",EqualTilde:"\u2242",Equilibrium:"\u21CC",Escr:"\u2130",Esim:"\u2A73",Eta:"\u0397",Euml:"\xCB",Exists:"\u2203",ExponentialE:"\u2147",Fcy:"\u0424",Ffr:"\uD835\uDD09",FilledSmallSquare:"\u25FC",FilledVerySmallSquare:"\u25AA",Fopf:"\uD835\uDD3D",ForAll:"\u2200",Fouriertrf:"\u2131",Fscr:"\u2131",GJcy:"\u0403",GT:">",Gamma:"\u0393",Gammad:"\u03DC",Gbreve:"\u011E",Gcedil:"\u0122",Gcirc:"\u011C",Gcy:"\u0413",Gdot:"\u0120",Gfr:"\uD835\uDD0A",Gg:"\u22D9",Gopf:"\uD835\uDD3E",GreaterEqual:"\u2265",GreaterEqualLess:"\u22DB",GreaterFullEqual:"\u2267",GreaterGreater:"\u2AA2",GreaterLess:"\u2277",GreaterSlantEqual:"\u2A7E",GreaterTilde:"\u2273",Gscr:"\uD835\uDCA2",Gt:"\u226B",HARDcy:"\u042A",Hacek:"\u02C7",Hat:"^",Hcirc:"\u0124",Hfr:"\u210C",HilbertSpace:"\u210B",Hopf:"\u210D",HorizontalLine:"\u2500",Hscr:"\u210B",Hstrok:"\u0126",HumpDownHump:"\u224E",HumpEqual:"\u224F",IEcy:"\u0415",IJlig:"\u0132",IOcy:"\u0401",Iacute:"\xCD",Icirc:"\xCE",Icy:"\u0418",Idot:"\u0130",Ifr:"\u2111",Igrave:"\xCC",Im:"\u2111",Imacr:"\u012A",ImaginaryI:"\u2148",Implies:"\u21D2",Int:"\u222C",Integral:"\u222B",Intersection:"\u22C2",InvisibleComma:"\u2063",InvisibleTimes:"\u2062",Iogon:"\u012E",Iopf:"\uD835\uDD40",Iota:"\u0399",Iscr:"\u2110",Itilde:"\u0128",Iukcy:"\u0406",Iuml:"\xCF",Jcirc:"\u0134",Jcy:"\u0419",Jfr:"\uD835\uDD0D",Jopf:"\uD835\uDD41",Jscr:"\uD835\uDCA5",Jsercy:"\u0408",Jukcy:"\u0404",KHcy:"\u0425",KJcy:"\u040C",Kappa:"\u039A",Kcedil:"\u0136",Kcy:"\u041A",Kfr:"\uD835\uDD0E",Kopf:"\uD835\uDD42",Kscr:"\uD835\uDCA6",LJcy:"\u0409",LT:"<",Lacute:"\u0139",Lambda:"\u039B",Lang:"\u27EA",Laplacetrf:"\u2112",Larr:"\u219E",Lcaron:"\u013D",Lcedil:"\u013B",Lcy:"\u041B",LeftAngleBracket:"\u27E8",LeftArrow:"\u2190",LeftArrowBar:"\u21E4",LeftArrowRightArrow:"\u21C6",LeftCeiling:"\u2308",LeftDoubleBracket:"\u27E6",LeftDownTeeVector:"\u2961",LeftDownVector:"\u21C3",LeftDownVectorBar:"\u2959",LeftFloor:"\u230A",LeftRightArrow:"\u2194",LeftRightVector:"\u294E",LeftTee:"\u22A3",LeftTeeArrow:"\u21A4",LeftTeeVector:"\u295A",LeftTriangle:"\u22B2",LeftTriangleBar:"\u29CF",LeftTriangleEqual:"\u22B4",LeftUpDownVector:"\u2951",LeftUpTeeVector:"\u2960",LeftUpVector:"\u21BF",LeftUpVectorBar:"\u2958",LeftVector:"\u21BC",LeftVectorBar:"\u2952",Leftarrow:"\u21D0",Leftrightarrow:"\u21D4",LessEqualGreater:"\u22DA",LessFullEqual:"\u2266",LessGreater:"\u2276",LessLess:"\u2AA1",LessSlantEqual:"\u2A7D",LessTilde:"\u2272",Lfr:"\uD835\uDD0F",Ll:"\u22D8",Lleftarrow:"\u21DA",Lmidot:"\u013F",LongLeftArrow:"\u27F5",LongLeftRightArrow:"\u27F7",LongRightArrow:"\u27F6",Longleftarrow:"\u27F8",Longleftrightarrow:"\u27FA",Longrightarrow:"\u27F9",Lopf:"\uD835\uDD43",LowerLeftArrow:"\u2199",LowerRightArrow:"\u2198",Lscr:"\u2112",Lsh:"\u21B0",Lstrok:"\u0141",Lt:"\u226A",Map:"\u2905",Mcy:"\u041C",MediumSpace:"\u205F",Mellintrf:"\u2133",Mfr:"\uD835\uDD10",MinusPlus:"\u2213",Mopf:"\uD835\uDD44",Mscr:"\u2133",Mu:"\u039C",NJcy:"\u040A",Nacute:"\u0143",Ncaron:"\u0147",Ncedil:"\u0145",Ncy:"\u041D",NegativeMediumSpace:"\u200B",NegativeThickSpace:"\u200B",NegativeThinSpace:"\u200B",NegativeVeryThinSpace:"\u200B",NestedGreaterGreater:"\u226B",NestedLessLess:"\u226A",NewLine:`
272
- `,Nfr:"\uD835\uDD11",NoBreak:"\u2060",NonBreakingSpace:"\xA0",Nopf:"\u2115",Not:"\u2AEC",NotCongruent:"\u2262",NotCupCap:"\u226D",NotDoubleVerticalBar:"\u2226",NotElement:"\u2209",NotEqual:"\u2260",NotEqualTilde:"\u2242\u0338",NotExists:"\u2204",NotGreater:"\u226F",NotGreaterEqual:"\u2271",NotGreaterFullEqual:"\u2267\u0338",NotGreaterGreater:"\u226B\u0338",NotGreaterLess:"\u2279",NotGreaterSlantEqual:"\u2A7E\u0338",NotGreaterTilde:"\u2275",NotHumpDownHump:"\u224E\u0338",NotHumpEqual:"\u224F\u0338",NotLeftTriangle:"\u22EA",NotLeftTriangleBar:"\u29CF\u0338",NotLeftTriangleEqual:"\u22EC",NotLess:"\u226E",NotLessEqual:"\u2270",NotLessGreater:"\u2278",NotLessLess:"\u226A\u0338",NotLessSlantEqual:"\u2A7D\u0338",NotLessTilde:"\u2274",NotNestedGreaterGreater:"\u2AA2\u0338",NotNestedLessLess:"\u2AA1\u0338",NotPrecedes:"\u2280",NotPrecedesEqual:"\u2AAF\u0338",NotPrecedesSlantEqual:"\u22E0",NotReverseElement:"\u220C",NotRightTriangle:"\u22EB",NotRightTriangleBar:"\u29D0\u0338",NotRightTriangleEqual:"\u22ED",NotSquareSubset:"\u228F\u0338",NotSquareSubsetEqual:"\u22E2",NotSquareSuperset:"\u2290\u0338",NotSquareSupersetEqual:"\u22E3",NotSubset:"\u2282\u20D2",NotSubsetEqual:"\u2288",NotSucceeds:"\u2281",NotSucceedsEqual:"\u2AB0\u0338",NotSucceedsSlantEqual:"\u22E1",NotSucceedsTilde:"\u227F\u0338",NotSuperset:"\u2283\u20D2",NotSupersetEqual:"\u2289",NotTilde:"\u2241",NotTildeEqual:"\u2244",NotTildeFullEqual:"\u2247",NotTildeTilde:"\u2249",NotVerticalBar:"\u2224",Nscr:"\uD835\uDCA9",Ntilde:"\xD1",Nu:"\u039D",OElig:"\u0152",Oacute:"\xD3",Ocirc:"\xD4",Ocy:"\u041E",Odblac:"\u0150",Ofr:"\uD835\uDD12",Ograve:"\xD2",Omacr:"\u014C",Omega:"\u03A9",Omicron:"\u039F",Oopf:"\uD835\uDD46",OpenCurlyDoubleQuote:"\u201C",OpenCurlyQuote:"\u2018",Or:"\u2A54",Oscr:"\uD835\uDCAA",Oslash:"\xD8",Otilde:"\xD5",Otimes:"\u2A37",Ouml:"\xD6",OverBar:"\u203E",OverBrace:"\u23DE",OverBracket:"\u23B4",OverParenthesis:"\u23DC",PartialD:"\u2202",Pcy:"\u041F",Pfr:"\uD835\uDD13",Phi:"\u03A6",Pi:"\u03A0",PlusMinus:"\xB1",Poincareplane:"\u210C",Popf:"\u2119",Pr:"\u2ABB",Precedes:"\u227A",PrecedesEqual:"\u2AAF",PrecedesSlantEqual:"\u227C",PrecedesTilde:"\u227E",Prime:"\u2033",Product:"\u220F",Proportion:"\u2237",Proportional:"\u221D",Pscr:"\uD835\uDCAB",Psi:"\u03A8",QUOT:'"',Qfr:"\uD835\uDD14",Qopf:"\u211A",Qscr:"\uD835\uDCAC",RBarr:"\u2910",REG:"\xAE",Racute:"\u0154",Rang:"\u27EB",Rarr:"\u21A0",Rarrtl:"\u2916",Rcaron:"\u0158",Rcedil:"\u0156",Rcy:"\u0420",Re:"\u211C",ReverseElement:"\u220B",ReverseEquilibrium:"\u21CB",ReverseUpEquilibrium:"\u296F",Rfr:"\u211C",Rho:"\u03A1",RightAngleBracket:"\u27E9",RightArrow:"\u2192",RightArrowBar:"\u21E5",RightArrowLeftArrow:"\u21C4",RightCeiling:"\u2309",RightDoubleBracket:"\u27E7",RightDownTeeVector:"\u295D",RightDownVector:"\u21C2",RightDownVectorBar:"\u2955",RightFloor:"\u230B",RightTee:"\u22A2",RightTeeArrow:"\u21A6",RightTeeVector:"\u295B",RightTriangle:"\u22B3",RightTriangleBar:"\u29D0",RightTriangleEqual:"\u22B5",RightUpDownVector:"\u294F",RightUpTeeVector:"\u295C",RightUpVector:"\u21BE",RightUpVectorBar:"\u2954",RightVector:"\u21C0",RightVectorBar:"\u2953",Rightarrow:"\u21D2",Ropf:"\u211D",RoundImplies:"\u2970",Rrightarrow:"\u21DB",Rscr:"\u211B",Rsh:"\u21B1",RuleDelayed:"\u29F4",SHCHcy:"\u0429",SHcy:"\u0428",SOFTcy:"\u042C",Sacute:"\u015A",Sc:"\u2ABC",Scaron:"\u0160",Scedil:"\u015E",Scirc:"\u015C",Scy:"\u0421",Sfr:"\uD835\uDD16",ShortDownArrow:"\u2193",ShortLeftArrow:"\u2190",ShortRightArrow:"\u2192",ShortUpArrow:"\u2191",Sigma:"\u03A3",SmallCircle:"\u2218",Sopf:"\uD835\uDD4A",Sqrt:"\u221A",Square:"\u25A1",SquareIntersection:"\u2293",SquareSubset:"\u228F",SquareSubsetEqual:"\u2291",SquareSuperset:"\u2290",SquareSupersetEqual:"\u2292",SquareUnion:"\u2294",Sscr:"\uD835\uDCAE",Star:"\u22C6",Sub:"\u22D0",Subset:"\u22D0",SubsetEqual:"\u2286",Succeeds:"\u227B",SucceedsEqual:"\u2AB0",SucceedsSlantEqual:"\u227D",SucceedsTilde:"\u227F",SuchThat:"\u220B",Sum:"\u2211",Sup:"\u22D1",Superset:"\u2283",SupersetEqual:"\u2287",Supset:"\u22D1",THORN:"\xDE",TRADE:"\u2122",TSHcy:"\u040B",TScy:"\u0426",Tab:"\t",Tau:"\u03A4",Tcaron:"\u0164",Tcedil:"\u0162",Tcy:"\u0422",Tfr:"\uD835\uDD17",Therefore:"\u2234",Theta:"\u0398",ThickSpace:"\u205F\u200A",ThinSpace:"\u2009",Tilde:"\u223C",TildeEqual:"\u2243",TildeFullEqual:"\u2245",TildeTilde:"\u2248",Topf:"\uD835\uDD4B",TripleDot:"\u20DB",Tscr:"\uD835\uDCAF",Tstrok:"\u0166",Uacute:"\xDA",Uarr:"\u219F",Uarrocir:"\u2949",Ubrcy:"\u040E",Ubreve:"\u016C",Ucirc:"\xDB",Ucy:"\u0423",Udblac:"\u0170",Ufr:"\uD835\uDD18",Ugrave:"\xD9",Umacr:"\u016A",UnderBar:"_",UnderBrace:"\u23DF",UnderBracket:"\u23B5",UnderParenthesis:"\u23DD",Union:"\u22C3",UnionPlus:"\u228E",Uogon:"\u0172",Uopf:"\uD835\uDD4C",UpArrow:"\u2191",UpArrowBar:"\u2912",UpArrowDownArrow:"\u21C5",UpDownArrow:"\u2195",UpEquilibrium:"\u296E",UpTee:"\u22A5",UpTeeArrow:"\u21A5",Uparrow:"\u21D1",Updownarrow:"\u21D5",UpperLeftArrow:"\u2196",UpperRightArrow:"\u2197",Upsi:"\u03D2",Upsilon:"\u03A5",Uring:"\u016E",Uscr:"\uD835\uDCB0",Utilde:"\u0168",Uuml:"\xDC",VDash:"\u22AB",Vbar:"\u2AEB",Vcy:"\u0412",Vdash:"\u22A9",Vdashl:"\u2AE6",Vee:"\u22C1",Verbar:"\u2016",Vert:"\u2016",VerticalBar:"\u2223",VerticalLine:"|",VerticalSeparator:"\u2758",VerticalTilde:"\u2240",VeryThinSpace:"\u200A",Vfr:"\uD835\uDD19",Vopf:"\uD835\uDD4D",Vscr:"\uD835\uDCB1",Vvdash:"\u22AA",Wcirc:"\u0174",Wedge:"\u22C0",Wfr:"\uD835\uDD1A",Wopf:"\uD835\uDD4E",Wscr:"\uD835\uDCB2",Xfr:"\uD835\uDD1B",Xi:"\u039E",Xopf:"\uD835\uDD4F",Xscr:"\uD835\uDCB3",YAcy:"\u042F",YIcy:"\u0407",YUcy:"\u042E",Yacute:"\xDD",Ycirc:"\u0176",Ycy:"\u042B",Yfr:"\uD835\uDD1C",Yopf:"\uD835\uDD50",Yscr:"\uD835\uDCB4",Yuml:"\u0178",ZHcy:"\u0416",Zacute:"\u0179",Zcaron:"\u017D",Zcy:"\u0417",Zdot:"\u017B",ZeroWidthSpace:"\u200B",Zeta:"\u0396",Zfr:"\u2128",Zopf:"\u2124",Zscr:"\uD835\uDCB5",aacute:"\xE1",abreve:"\u0103",ac:"\u223E",acE:"\u223E\u0333",acd:"\u223F",acirc:"\xE2",acute:"\xB4",acy:"\u0430",aelig:"\xE6",af:"\u2061",afr:"\uD835\uDD1E",agrave:"\xE0",alefsym:"\u2135",aleph:"\u2135",alpha:"\u03B1",amacr:"\u0101",amalg:"\u2A3F",amp:"&",and:"\u2227",andand:"\u2A55",andd:"\u2A5C",andslope:"\u2A58",andv:"\u2A5A",ang:"\u2220",ange:"\u29A4",angle:"\u2220",angmsd:"\u2221",angmsdaa:"\u29A8",angmsdab:"\u29A9",angmsdac:"\u29AA",angmsdad:"\u29AB",angmsdae:"\u29AC",angmsdaf:"\u29AD",angmsdag:"\u29AE",angmsdah:"\u29AF",angrt:"\u221F",angrtvb:"\u22BE",angrtvbd:"\u299D",angsph:"\u2222",angst:"\xC5",angzarr:"\u237C",aogon:"\u0105",aopf:"\uD835\uDD52",ap:"\u2248",apE:"\u2A70",apacir:"\u2A6F",ape:"\u224A",apid:"\u224B",apos:"'",approx:"\u2248",approxeq:"\u224A",aring:"\xE5",ascr:"\uD835\uDCB6",ast:"*",asymp:"\u2248",asympeq:"\u224D",atilde:"\xE3",auml:"\xE4",awconint:"\u2233",awint:"\u2A11",bNot:"\u2AED",backcong:"\u224C",backepsilon:"\u03F6",backprime:"\u2035",backsim:"\u223D",backsimeq:"\u22CD",barvee:"\u22BD",barwed:"\u2305",barwedge:"\u2305",bbrk:"\u23B5",bbrktbrk:"\u23B6",bcong:"\u224C",bcy:"\u0431",bdquo:"\u201E",becaus:"\u2235",because:"\u2235",bemptyv:"\u29B0",bepsi:"\u03F6",bernou:"\u212C",beta:"\u03B2",beth:"\u2136",between:"\u226C",bfr:"\uD835\uDD1F",bigcap:"\u22C2",bigcirc:"\u25EF",bigcup:"\u22C3",bigodot:"\u2A00",bigoplus:"\u2A01",bigotimes:"\u2A02",bigsqcup:"\u2A06",bigstar:"\u2605",bigtriangledown:"\u25BD",bigtriangleup:"\u25B3",biguplus:"\u2A04",bigvee:"\u22C1",bigwedge:"\u22C0",bkarow:"\u290D",blacklozenge:"\u29EB",blacksquare:"\u25AA",blacktriangle:"\u25B4",blacktriangledown:"\u25BE",blacktriangleleft:"\u25C2",blacktriangleright:"\u25B8",blank:"\u2423",blk12:"\u2592",blk14:"\u2591",blk34:"\u2593",block:"\u2588",bne:"=\u20E5",bnequiv:"\u2261\u20E5",bnot:"\u2310",bopf:"\uD835\uDD53",bot:"\u22A5",bottom:"\u22A5",bowtie:"\u22C8",boxDL:"\u2557",boxDR:"\u2554",boxDl:"\u2556",boxDr:"\u2553",boxH:"\u2550",boxHD:"\u2566",boxHU:"\u2569",boxHd:"\u2564",boxHu:"\u2567",boxUL:"\u255D",boxUR:"\u255A",boxUl:"\u255C",boxUr:"\u2559",boxV:"\u2551",boxVH:"\u256C",boxVL:"\u2563",boxVR:"\u2560",boxVh:"\u256B",boxVl:"\u2562",boxVr:"\u255F",boxbox:"\u29C9",boxdL:"\u2555",boxdR:"\u2552",boxdl:"\u2510",boxdr:"\u250C",boxh:"\u2500",boxhD:"\u2565",boxhU:"\u2568",boxhd:"\u252C",boxhu:"\u2534",boxminus:"\u229F",boxplus:"\u229E",boxtimes:"\u22A0",boxuL:"\u255B",boxuR:"\u2558",boxul:"\u2518",boxur:"\u2514",boxv:"\u2502",boxvH:"\u256A",boxvL:"\u2561",boxvR:"\u255E",boxvh:"\u253C",boxvl:"\u2524",boxvr:"\u251C",bprime:"\u2035",breve:"\u02D8",brvbar:"\xA6",bscr:"\uD835\uDCB7",bsemi:"\u204F",bsim:"\u223D",bsime:"\u22CD",bsol:"\\",bsolb:"\u29C5",bsolhsub:"\u27C8",bull:"\u2022",bullet:"\u2022",bump:"\u224E",bumpE:"\u2AAE",bumpe:"\u224F",bumpeq:"\u224F",cacute:"\u0107",cap:"\u2229",capand:"\u2A44",capbrcup:"\u2A49",capcap:"\u2A4B",capcup:"\u2A47",capdot:"\u2A40",caps:"\u2229\uFE00",caret:"\u2041",caron:"\u02C7",ccaps:"\u2A4D",ccaron:"\u010D",ccedil:"\xE7",ccirc:"\u0109",ccups:"\u2A4C",ccupssm:"\u2A50",cdot:"\u010B",cedil:"\xB8",cemptyv:"\u29B2",cent:"\xA2",centerdot:"\xB7",cfr:"\uD835\uDD20",chcy:"\u0447",check:"\u2713",checkmark:"\u2713",chi:"\u03C7",cir:"\u25CB",cirE:"\u29C3",circ:"\u02C6",circeq:"\u2257",circlearrowleft:"\u21BA",circlearrowright:"\u21BB",circledR:"\xAE",circledS:"\u24C8",circledast:"\u229B",circledcirc:"\u229A",circleddash:"\u229D",cire:"\u2257",cirfnint:"\u2A10",cirmid:"\u2AEF",cirscir:"\u29C2",clubs:"\u2663",clubsuit:"\u2663",colon:":",colone:"\u2254",coloneq:"\u2254",comma:",",commat:"@",comp:"\u2201",compfn:"\u2218",complement:"\u2201",complexes:"\u2102",cong:"\u2245",congdot:"\u2A6D",conint:"\u222E",copf:"\uD835\uDD54",coprod:"\u2210",copy:"\xA9",copysr:"\u2117",crarr:"\u21B5",cross:"\u2717",cscr:"\uD835\uDCB8",csub:"\u2ACF",csube:"\u2AD1",csup:"\u2AD0",csupe:"\u2AD2",ctdot:"\u22EF",cudarrl:"\u2938",cudarrr:"\u2935",cuepr:"\u22DE",cuesc:"\u22DF",cularr:"\u21B6",cularrp:"\u293D",cup:"\u222A",cupbrcap:"\u2A48",cupcap:"\u2A46",cupcup:"\u2A4A",cupdot:"\u228D",cupor:"\u2A45",cups:"\u222A\uFE00",curarr:"\u21B7",curarrm:"\u293C",curlyeqprec:"\u22DE",curlyeqsucc:"\u22DF",curlyvee:"\u22CE",curlywedge:"\u22CF",curren:"\xA4",curvearrowleft:"\u21B6",curvearrowright:"\u21B7",cuvee:"\u22CE",cuwed:"\u22CF",cwconint:"\u2232",cwint:"\u2231",cylcty:"\u232D",dArr:"\u21D3",dHar:"\u2965",dagger:"\u2020",daleth:"\u2138",darr:"\u2193",dash:"\u2010",dashv:"\u22A3",dbkarow:"\u290F",dblac:"\u02DD",dcaron:"\u010F",dcy:"\u0434",dd:"\u2146",ddagger:"\u2021",ddarr:"\u21CA",ddotseq:"\u2A77",deg:"\xB0",delta:"\u03B4",demptyv:"\u29B1",dfisht:"\u297F",dfr:"\uD835\uDD21",dharl:"\u21C3",dharr:"\u21C2",diam:"\u22C4",diamond:"\u22C4",diamondsuit:"\u2666",diams:"\u2666",die:"\xA8",digamma:"\u03DD",disin:"\u22F2",div:"\xF7",divide:"\xF7",divideontimes:"\u22C7",divonx:"\u22C7",djcy:"\u0452",dlcorn:"\u231E",dlcrop:"\u230D",dollar:"$",dopf:"\uD835\uDD55",dot:"\u02D9",doteq:"\u2250",doteqdot:"\u2251",dotminus:"\u2238",dotplus:"\u2214",dotsquare:"\u22A1",doublebarwedge:"\u2306",downarrow:"\u2193",downdownarrows:"\u21CA",downharpoonleft:"\u21C3",downharpoonright:"\u21C2",drbkarow:"\u2910",drcorn:"\u231F",drcrop:"\u230C",dscr:"\uD835\uDCB9",dscy:"\u0455",dsol:"\u29F6",dstrok:"\u0111",dtdot:"\u22F1",dtri:"\u25BF",dtrif:"\u25BE",duarr:"\u21F5",duhar:"\u296F",dwangle:"\u29A6",dzcy:"\u045F",dzigrarr:"\u27FF",eDDot:"\u2A77",eDot:"\u2251",eacute:"\xE9",easter:"\u2A6E",ecaron:"\u011B",ecir:"\u2256",ecirc:"\xEA",ecolon:"\u2255",ecy:"\u044D",edot:"\u0117",ee:"\u2147",efDot:"\u2252",efr:"\uD835\uDD22",eg:"\u2A9A",egrave:"\xE8",egs:"\u2A96",egsdot:"\u2A98",el:"\u2A99",elinters:"\u23E7",ell:"\u2113",els:"\u2A95",elsdot:"\u2A97",emacr:"\u0113",empty:"\u2205",emptyset:"\u2205",emptyv:"\u2205",emsp13:"\u2004",emsp14:"\u2005",emsp:"\u2003",eng:"\u014B",ensp:"\u2002",eogon:"\u0119",eopf:"\uD835\uDD56",epar:"\u22D5",eparsl:"\u29E3",eplus:"\u2A71",epsi:"\u03B5",epsilon:"\u03B5",epsiv:"\u03F5",eqcirc:"\u2256",eqcolon:"\u2255",eqsim:"\u2242",eqslantgtr:"\u2A96",eqslantless:"\u2A95",equals:"=",equest:"\u225F",equiv:"\u2261",equivDD:"\u2A78",eqvparsl:"\u29E5",erDot:"\u2253",erarr:"\u2971",escr:"\u212F",esdot:"\u2250",esim:"\u2242",eta:"\u03B7",eth:"\xF0",euml:"\xEB",euro:"\u20AC",excl:"!",exist:"\u2203",expectation:"\u2130",exponentiale:"\u2147",fallingdotseq:"\u2252",fcy:"\u0444",female:"\u2640",ffilig:"\uFB03",fflig:"\uFB00",ffllig:"\uFB04",ffr:"\uD835\uDD23",filig:"\uFB01",fjlig:"fj",flat:"\u266D",fllig:"\uFB02",fltns:"\u25B1",fnof:"\u0192",fopf:"\uD835\uDD57",forall:"\u2200",fork:"\u22D4",forkv:"\u2AD9",fpartint:"\u2A0D",frac12:"\xBD",frac13:"\u2153",frac14:"\xBC",frac15:"\u2155",frac16:"\u2159",frac18:"\u215B",frac23:"\u2154",frac25:"\u2156",frac34:"\xBE",frac35:"\u2157",frac38:"\u215C",frac45:"\u2158",frac56:"\u215A",frac58:"\u215D",frac78:"\u215E",frasl:"\u2044",frown:"\u2322",fscr:"\uD835\uDCBB",gE:"\u2267",gEl:"\u2A8C",gacute:"\u01F5",gamma:"\u03B3",gammad:"\u03DD",gap:"\u2A86",gbreve:"\u011F",gcirc:"\u011D",gcy:"\u0433",gdot:"\u0121",ge:"\u2265",gel:"\u22DB",geq:"\u2265",geqq:"\u2267",geqslant:"\u2A7E",ges:"\u2A7E",gescc:"\u2AA9",gesdot:"\u2A80",gesdoto:"\u2A82",gesdotol:"\u2A84",gesl:"\u22DB\uFE00",gesles:"\u2A94",gfr:"\uD835\uDD24",gg:"\u226B",ggg:"\u22D9",gimel:"\u2137",gjcy:"\u0453",gl:"\u2277",glE:"\u2A92",gla:"\u2AA5",glj:"\u2AA4",gnE:"\u2269",gnap:"\u2A8A",gnapprox:"\u2A8A",gne:"\u2A88",gneq:"\u2A88",gneqq:"\u2269",gnsim:"\u22E7",gopf:"\uD835\uDD58",grave:"`",gscr:"\u210A",gsim:"\u2273",gsime:"\u2A8E",gsiml:"\u2A90",gt:">",gtcc:"\u2AA7",gtcir:"\u2A7A",gtdot:"\u22D7",gtlPar:"\u2995",gtquest:"\u2A7C",gtrapprox:"\u2A86",gtrarr:"\u2978",gtrdot:"\u22D7",gtreqless:"\u22DB",gtreqqless:"\u2A8C",gtrless:"\u2277",gtrsim:"\u2273",gvertneqq:"\u2269\uFE00",gvnE:"\u2269\uFE00",hArr:"\u21D4",hairsp:"\u200A",half:"\xBD",hamilt:"\u210B",hardcy:"\u044A",harr:"\u2194",harrcir:"\u2948",harrw:"\u21AD",hbar:"\u210F",hcirc:"\u0125",hearts:"\u2665",heartsuit:"\u2665",hellip:"\u2026",hercon:"\u22B9",hfr:"\uD835\uDD25",hksearow:"\u2925",hkswarow:"\u2926",hoarr:"\u21FF",homtht:"\u223B",hookleftarrow:"\u21A9",hookrightarrow:"\u21AA",hopf:"\uD835\uDD59",horbar:"\u2015",hscr:"\uD835\uDCBD",hslash:"\u210F",hstrok:"\u0127",hybull:"\u2043",hyphen:"\u2010",iacute:"\xED",ic:"\u2063",icirc:"\xEE",icy:"\u0438",iecy:"\u0435",iexcl:"\xA1",iff:"\u21D4",ifr:"\uD835\uDD26",igrave:"\xEC",ii:"\u2148",iiiint:"\u2A0C",iiint:"\u222D",iinfin:"\u29DC",iiota:"\u2129",ijlig:"\u0133",imacr:"\u012B",image:"\u2111",imagline:"\u2110",imagpart:"\u2111",imath:"\u0131",imof:"\u22B7",imped:"\u01B5",in:"\u2208",incare:"\u2105",infin:"\u221E",infintie:"\u29DD",inodot:"\u0131",int:"\u222B",intcal:"\u22BA",integers:"\u2124",intercal:"\u22BA",intlarhk:"\u2A17",intprod:"\u2A3C",iocy:"\u0451",iogon:"\u012F",iopf:"\uD835\uDD5A",iota:"\u03B9",iprod:"\u2A3C",iquest:"\xBF",iscr:"\uD835\uDCBE",isin:"\u2208",isinE:"\u22F9",isindot:"\u22F5",isins:"\u22F4",isinsv:"\u22F3",isinv:"\u2208",it:"\u2062",itilde:"\u0129",iukcy:"\u0456",iuml:"\xEF",jcirc:"\u0135",jcy:"\u0439",jfr:"\uD835\uDD27",jmath:"\u0237",jopf:"\uD835\uDD5B",jscr:"\uD835\uDCBF",jsercy:"\u0458",jukcy:"\u0454",kappa:"\u03BA",kappav:"\u03F0",kcedil:"\u0137",kcy:"\u043A",kfr:"\uD835\uDD28",kgreen:"\u0138",khcy:"\u0445",kjcy:"\u045C",kopf:"\uD835\uDD5C",kscr:"\uD835\uDCC0",lAarr:"\u21DA",lArr:"\u21D0",lAtail:"\u291B",lBarr:"\u290E",lE:"\u2266",lEg:"\u2A8B",lHar:"\u2962",lacute:"\u013A",laemptyv:"\u29B4",lagran:"\u2112",lambda:"\u03BB",lang:"\u27E8",langd:"\u2991",langle:"\u27E8",lap:"\u2A85",laquo:"\xAB",larr:"\u2190",larrb:"\u21E4",larrbfs:"\u291F",larrfs:"\u291D",larrhk:"\u21A9",larrlp:"\u21AB",larrpl:"\u2939",larrsim:"\u2973",larrtl:"\u21A2",lat:"\u2AAB",latail:"\u2919",late:"\u2AAD",lates:"\u2AAD\uFE00",lbarr:"\u290C",lbbrk:"\u2772",lbrace:"{",lbrack:"[",lbrke:"\u298B",lbrksld:"\u298F",lbrkslu:"\u298D",lcaron:"\u013E",lcedil:"\u013C",lceil:"\u2308",lcub:"{",lcy:"\u043B",ldca:"\u2936",ldquo:"\u201C",ldquor:"\u201E",ldrdhar:"\u2967",ldrushar:"\u294B",ldsh:"\u21B2",le:"\u2264",leftarrow:"\u2190",leftarrowtail:"\u21A2",leftharpoondown:"\u21BD",leftharpoonup:"\u21BC",leftleftarrows:"\u21C7",leftrightarrow:"\u2194",leftrightarrows:"\u21C6",leftrightharpoons:"\u21CB",leftrightsquigarrow:"\u21AD",leftthreetimes:"\u22CB",leg:"\u22DA",leq:"\u2264",leqq:"\u2266",leqslant:"\u2A7D",les:"\u2A7D",lescc:"\u2AA8",lesdot:"\u2A7F",lesdoto:"\u2A81",lesdotor:"\u2A83",lesg:"\u22DA\uFE00",lesges:"\u2A93",lessapprox:"\u2A85",lessdot:"\u22D6",lesseqgtr:"\u22DA",lesseqqgtr:"\u2A8B",lessgtr:"\u2276",lesssim:"\u2272",lfisht:"\u297C",lfloor:"\u230A",lfr:"\uD835\uDD29",lg:"\u2276",lgE:"\u2A91",lhard:"\u21BD",lharu:"\u21BC",lharul:"\u296A",lhblk:"\u2584",ljcy:"\u0459",ll:"\u226A",llarr:"\u21C7",llcorner:"\u231E",llhard:"\u296B",lltri:"\u25FA",lmidot:"\u0140",lmoust:"\u23B0",lmoustache:"\u23B0",lnE:"\u2268",lnap:"\u2A89",lnapprox:"\u2A89",lne:"\u2A87",lneq:"\u2A87",lneqq:"\u2268",lnsim:"\u22E6",loang:"\u27EC",loarr:"\u21FD",lobrk:"\u27E6",longleftarrow:"\u27F5",longleftrightarrow:"\u27F7",longmapsto:"\u27FC",longrightarrow:"\u27F6",looparrowleft:"\u21AB",looparrowright:"\u21AC",lopar:"\u2985",lopf:"\uD835\uDD5D",loplus:"\u2A2D",lotimes:"\u2A34",lowast:"\u2217",lowbar:"_",loz:"\u25CA",lozenge:"\u25CA",lozf:"\u29EB",lpar:"(",lparlt:"\u2993",lrarr:"\u21C6",lrcorner:"\u231F",lrhar:"\u21CB",lrhard:"\u296D",lrm:"\u200E",lrtri:"\u22BF",lsaquo:"\u2039",lscr:"\uD835\uDCC1",lsh:"\u21B0",lsim:"\u2272",lsime:"\u2A8D",lsimg:"\u2A8F",lsqb:"[",lsquo:"\u2018",lsquor:"\u201A",lstrok:"\u0142",lt:"<",ltcc:"\u2AA6",ltcir:"\u2A79",ltdot:"\u22D6",lthree:"\u22CB",ltimes:"\u22C9",ltlarr:"\u2976",ltquest:"\u2A7B",ltrPar:"\u2996",ltri:"\u25C3",ltrie:"\u22B4",ltrif:"\u25C2",lurdshar:"\u294A",luruhar:"\u2966",lvertneqq:"\u2268\uFE00",lvnE:"\u2268\uFE00",mDDot:"\u223A",macr:"\xAF",male:"\u2642",malt:"\u2720",maltese:"\u2720",map:"\u21A6",mapsto:"\u21A6",mapstodown:"\u21A7",mapstoleft:"\u21A4",mapstoup:"\u21A5",marker:"\u25AE",mcomma:"\u2A29",mcy:"\u043C",mdash:"\u2014",measuredangle:"\u2221",mfr:"\uD835\uDD2A",mho:"\u2127",micro:"\xB5",mid:"\u2223",midast:"*",midcir:"\u2AF0",middot:"\xB7",minus:"\u2212",minusb:"\u229F",minusd:"\u2238",minusdu:"\u2A2A",mlcp:"\u2ADB",mldr:"\u2026",mnplus:"\u2213",models:"\u22A7",mopf:"\uD835\uDD5E",mp:"\u2213",mscr:"\uD835\uDCC2",mstpos:"\u223E",mu:"\u03BC",multimap:"\u22B8",mumap:"\u22B8",nGg:"\u22D9\u0338",nGt:"\u226B\u20D2",nGtv:"\u226B\u0338",nLeftarrow:"\u21CD",nLeftrightarrow:"\u21CE",nLl:"\u22D8\u0338",nLt:"\u226A\u20D2",nLtv:"\u226A\u0338",nRightarrow:"\u21CF",nVDash:"\u22AF",nVdash:"\u22AE",nabla:"\u2207",nacute:"\u0144",nang:"\u2220\u20D2",nap:"\u2249",napE:"\u2A70\u0338",napid:"\u224B\u0338",napos:"\u0149",napprox:"\u2249",natur:"\u266E",natural:"\u266E",naturals:"\u2115",nbsp:"\xA0",nbump:"\u224E\u0338",nbumpe:"\u224F\u0338",ncap:"\u2A43",ncaron:"\u0148",ncedil:"\u0146",ncong:"\u2247",ncongdot:"\u2A6D\u0338",ncup:"\u2A42",ncy:"\u043D",ndash:"\u2013",ne:"\u2260",neArr:"\u21D7",nearhk:"\u2924",nearr:"\u2197",nearrow:"\u2197",nedot:"\u2250\u0338",nequiv:"\u2262",nesear:"\u2928",nesim:"\u2242\u0338",nexist:"\u2204",nexists:"\u2204",nfr:"\uD835\uDD2B",ngE:"\u2267\u0338",nge:"\u2271",ngeq:"\u2271",ngeqq:"\u2267\u0338",ngeqslant:"\u2A7E\u0338",nges:"\u2A7E\u0338",ngsim:"\u2275",ngt:"\u226F",ngtr:"\u226F",nhArr:"\u21CE",nharr:"\u21AE",nhpar:"\u2AF2",ni:"\u220B",nis:"\u22FC",nisd:"\u22FA",niv:"\u220B",njcy:"\u045A",nlArr:"\u21CD",nlE:"\u2266\u0338",nlarr:"\u219A",nldr:"\u2025",nle:"\u2270",nleftarrow:"\u219A",nleftrightarrow:"\u21AE",nleq:"\u2270",nleqq:"\u2266\u0338",nleqslant:"\u2A7D\u0338",nles:"\u2A7D\u0338",nless:"\u226E",nlsim:"\u2274",nlt:"\u226E",nltri:"\u22EA",nltrie:"\u22EC",nmid:"\u2224",nopf:"\uD835\uDD5F",not:"\xAC",notin:"\u2209",notinE:"\u22F9\u0338",notindot:"\u22F5\u0338",notinva:"\u2209",notinvb:"\u22F7",notinvc:"\u22F6",notni:"\u220C",notniva:"\u220C",notnivb:"\u22FE",notnivc:"\u22FD",npar:"\u2226",nparallel:"\u2226",nparsl:"\u2AFD\u20E5",npart:"\u2202\u0338",npolint:"\u2A14",npr:"\u2280",nprcue:"\u22E0",npre:"\u2AAF\u0338",nprec:"\u2280",npreceq:"\u2AAF\u0338",nrArr:"\u21CF",nrarr:"\u219B",nrarrc:"\u2933\u0338",nrarrw:"\u219D\u0338",nrightarrow:"\u219B",nrtri:"\u22EB",nrtrie:"\u22ED",nsc:"\u2281",nsccue:"\u22E1",nsce:"\u2AB0\u0338",nscr:"\uD835\uDCC3",nshortmid:"\u2224",nshortparallel:"\u2226",nsim:"\u2241",nsime:"\u2244",nsimeq:"\u2244",nsmid:"\u2224",nspar:"\u2226",nsqsube:"\u22E2",nsqsupe:"\u22E3",nsub:"\u2284",nsubE:"\u2AC5\u0338",nsube:"\u2288",nsubset:"\u2282\u20D2",nsubseteq:"\u2288",nsubseteqq:"\u2AC5\u0338",nsucc:"\u2281",nsucceq:"\u2AB0\u0338",nsup:"\u2285",nsupE:"\u2AC6\u0338",nsupe:"\u2289",nsupset:"\u2283\u20D2",nsupseteq:"\u2289",nsupseteqq:"\u2AC6\u0338",ntgl:"\u2279",ntilde:"\xF1",ntlg:"\u2278",ntriangleleft:"\u22EA",ntrianglelefteq:"\u22EC",ntriangleright:"\u22EB",ntrianglerighteq:"\u22ED",nu:"\u03BD",num:"#",numero:"\u2116",numsp:"\u2007",nvDash:"\u22AD",nvHarr:"\u2904",nvap:"\u224D\u20D2",nvdash:"\u22AC",nvge:"\u2265\u20D2",nvgt:">\u20D2",nvinfin:"\u29DE",nvlArr:"\u2902",nvle:"\u2264\u20D2",nvlt:"<\u20D2",nvltrie:"\u22B4\u20D2",nvrArr:"\u2903",nvrtrie:"\u22B5\u20D2",nvsim:"\u223C\u20D2",nwArr:"\u21D6",nwarhk:"\u2923",nwarr:"\u2196",nwarrow:"\u2196",nwnear:"\u2927",oS:"\u24C8",oacute:"\xF3",oast:"\u229B",ocir:"\u229A",ocirc:"\xF4",ocy:"\u043E",odash:"\u229D",odblac:"\u0151",odiv:"\u2A38",odot:"\u2299",odsold:"\u29BC",oelig:"\u0153",ofcir:"\u29BF",ofr:"\uD835\uDD2C",ogon:"\u02DB",ograve:"\xF2",ogt:"\u29C1",ohbar:"\u29B5",ohm:"\u03A9",oint:"\u222E",olarr:"\u21BA",olcir:"\u29BE",olcross:"\u29BB",oline:"\u203E",olt:"\u29C0",omacr:"\u014D",omega:"\u03C9",omicron:"\u03BF",omid:"\u29B6",ominus:"\u2296",oopf:"\uD835\uDD60",opar:"\u29B7",operp:"\u29B9",oplus:"\u2295",or:"\u2228",orarr:"\u21BB",ord:"\u2A5D",order:"\u2134",orderof:"\u2134",ordf:"\xAA",ordm:"\xBA",origof:"\u22B6",oror:"\u2A56",orslope:"\u2A57",orv:"\u2A5B",oscr:"\u2134",oslash:"\xF8",osol:"\u2298",otilde:"\xF5",otimes:"\u2297",otimesas:"\u2A36",ouml:"\xF6",ovbar:"\u233D",par:"\u2225",para:"\xB6",parallel:"\u2225",parsim:"\u2AF3",parsl:"\u2AFD",part:"\u2202",pcy:"\u043F",percnt:"%",period:".",permil:"\u2030",perp:"\u22A5",pertenk:"\u2031",pfr:"\uD835\uDD2D",phi:"\u03C6",phiv:"\u03D5",phmmat:"\u2133",phone:"\u260E",pi:"\u03C0",pitchfork:"\u22D4",piv:"\u03D6",planck:"\u210F",planckh:"\u210E",plankv:"\u210F",plus:"+",plusacir:"\u2A23",plusb:"\u229E",pluscir:"\u2A22",plusdo:"\u2214",plusdu:"\u2A25",pluse:"\u2A72",plusmn:"\xB1",plussim:"\u2A26",plustwo:"\u2A27",pm:"\xB1",pointint:"\u2A15",popf:"\uD835\uDD61",pound:"\xA3",pr:"\u227A",prE:"\u2AB3",prap:"\u2AB7",prcue:"\u227C",pre:"\u2AAF",prec:"\u227A",precapprox:"\u2AB7",preccurlyeq:"\u227C",preceq:"\u2AAF",precnapprox:"\u2AB9",precneqq:"\u2AB5",precnsim:"\u22E8",precsim:"\u227E",prime:"\u2032",primes:"\u2119",prnE:"\u2AB5",prnap:"\u2AB9",prnsim:"\u22E8",prod:"\u220F",profalar:"\u232E",profline:"\u2312",profsurf:"\u2313",prop:"\u221D",propto:"\u221D",prsim:"\u227E",prurel:"\u22B0",pscr:"\uD835\uDCC5",psi:"\u03C8",puncsp:"\u2008",qfr:"\uD835\uDD2E",qint:"\u2A0C",qopf:"\uD835\uDD62",qprime:"\u2057",qscr:"\uD835\uDCC6",quaternions:"\u210D",quatint:"\u2A16",quest:"?",questeq:"\u225F",quot:'"',rAarr:"\u21DB",rArr:"\u21D2",rAtail:"\u291C",rBarr:"\u290F",rHar:"\u2964",race:"\u223D\u0331",racute:"\u0155",radic:"\u221A",raemptyv:"\u29B3",rang:"\u27E9",rangd:"\u2992",range:"\u29A5",rangle:"\u27E9",raquo:"\xBB",rarr:"\u2192",rarrap:"\u2975",rarrb:"\u21E5",rarrbfs:"\u2920",rarrc:"\u2933",rarrfs:"\u291E",rarrhk:"\u21AA",rarrlp:"\u21AC",rarrpl:"\u2945",rarrsim:"\u2974",rarrtl:"\u21A3",rarrw:"\u219D",ratail:"\u291A",ratio:"\u2236",rationals:"\u211A",rbarr:"\u290D",rbbrk:"\u2773",rbrace:"}",rbrack:"]",rbrke:"\u298C",rbrksld:"\u298E",rbrkslu:"\u2990",rcaron:"\u0159",rcedil:"\u0157",rceil:"\u2309",rcub:"}",rcy:"\u0440",rdca:"\u2937",rdldhar:"\u2969",rdquo:"\u201D",rdquor:"\u201D",rdsh:"\u21B3",real:"\u211C",realine:"\u211B",realpart:"\u211C",reals:"\u211D",rect:"\u25AD",reg:"\xAE",rfisht:"\u297D",rfloor:"\u230B",rfr:"\uD835\uDD2F",rhard:"\u21C1",rharu:"\u21C0",rharul:"\u296C",rho:"\u03C1",rhov:"\u03F1",rightarrow:"\u2192",rightarrowtail:"\u21A3",rightharpoondown:"\u21C1",rightharpoonup:"\u21C0",rightleftarrows:"\u21C4",rightleftharpoons:"\u21CC",rightrightarrows:"\u21C9",rightsquigarrow:"\u219D",rightthreetimes:"\u22CC",ring:"\u02DA",risingdotseq:"\u2253",rlarr:"\u21C4",rlhar:"\u21CC",rlm:"\u200F",rmoust:"\u23B1",rmoustache:"\u23B1",rnmid:"\u2AEE",roang:"\u27ED",roarr:"\u21FE",robrk:"\u27E7",ropar:"\u2986",ropf:"\uD835\uDD63",roplus:"\u2A2E",rotimes:"\u2A35",rpar:")",rpargt:"\u2994",rppolint:"\u2A12",rrarr:"\u21C9",rsaquo:"\u203A",rscr:"\uD835\uDCC7",rsh:"\u21B1",rsqb:"]",rsquo:"\u2019",rsquor:"\u2019",rthree:"\u22CC",rtimes:"\u22CA",rtri:"\u25B9",rtrie:"\u22B5",rtrif:"\u25B8",rtriltri:"\u29CE",ruluhar:"\u2968",rx:"\u211E",sacute:"\u015B",sbquo:"\u201A",sc:"\u227B",scE:"\u2AB4",scap:"\u2AB8",scaron:"\u0161",sccue:"\u227D",sce:"\u2AB0",scedil:"\u015F",scirc:"\u015D",scnE:"\u2AB6",scnap:"\u2ABA",scnsim:"\u22E9",scpolint:"\u2A13",scsim:"\u227F",scy:"\u0441",sdot:"\u22C5",sdotb:"\u22A1",sdote:"\u2A66",seArr:"\u21D8",searhk:"\u2925",searr:"\u2198",searrow:"\u2198",sect:"\xA7",semi:";",seswar:"\u2929",setminus:"\u2216",setmn:"\u2216",sext:"\u2736",sfr:"\uD835\uDD30",sfrown:"\u2322",sharp:"\u266F",shchcy:"\u0449",shcy:"\u0448",shortmid:"\u2223",shortparallel:"\u2225",shy:"\xAD",sigma:"\u03C3",sigmaf:"\u03C2",sigmav:"\u03C2",sim:"\u223C",simdot:"\u2A6A",sime:"\u2243",simeq:"\u2243",simg:"\u2A9E",simgE:"\u2AA0",siml:"\u2A9D",simlE:"\u2A9F",simne:"\u2246",simplus:"\u2A24",simrarr:"\u2972",slarr:"\u2190",smallsetminus:"\u2216",smashp:"\u2A33",smeparsl:"\u29E4",smid:"\u2223",smile:"\u2323",smt:"\u2AAA",smte:"\u2AAC",smtes:"\u2AAC\uFE00",softcy:"\u044C",sol:"/",solb:"\u29C4",solbar:"\u233F",sopf:"\uD835\uDD64",spades:"\u2660",spadesuit:"\u2660",spar:"\u2225",sqcap:"\u2293",sqcaps:"\u2293\uFE00",sqcup:"\u2294",sqcups:"\u2294\uFE00",sqsub:"\u228F",sqsube:"\u2291",sqsubset:"\u228F",sqsubseteq:"\u2291",sqsup:"\u2290",sqsupe:"\u2292",sqsupset:"\u2290",sqsupseteq:"\u2292",squ:"\u25A1",square:"\u25A1",squarf:"\u25AA",squf:"\u25AA",srarr:"\u2192",sscr:"\uD835\uDCC8",ssetmn:"\u2216",ssmile:"\u2323",sstarf:"\u22C6",star:"\u2606",starf:"\u2605",straightepsilon:"\u03F5",straightphi:"\u03D5",strns:"\xAF",sub:"\u2282",subE:"\u2AC5",subdot:"\u2ABD",sube:"\u2286",subedot:"\u2AC3",submult:"\u2AC1",subnE:"\u2ACB",subne:"\u228A",subplus:"\u2ABF",subrarr:"\u2979",subset:"\u2282",subseteq:"\u2286",subseteqq:"\u2AC5",subsetneq:"\u228A",subsetneqq:"\u2ACB",subsim:"\u2AC7",subsub:"\u2AD5",subsup:"\u2AD3",succ:"\u227B",succapprox:"\u2AB8",succcurlyeq:"\u227D",succeq:"\u2AB0",succnapprox:"\u2ABA",succneqq:"\u2AB6",succnsim:"\u22E9",succsim:"\u227F",sum:"\u2211",sung:"\u266A",sup1:"\xB9",sup2:"\xB2",sup3:"\xB3",sup:"\u2283",supE:"\u2AC6",supdot:"\u2ABE",supdsub:"\u2AD8",supe:"\u2287",supedot:"\u2AC4",suphsol:"\u27C9",suphsub:"\u2AD7",suplarr:"\u297B",supmult:"\u2AC2",supnE:"\u2ACC",supne:"\u228B",supplus:"\u2AC0",supset:"\u2283",supseteq:"\u2287",supseteqq:"\u2AC6",supsetneq:"\u228B",supsetneqq:"\u2ACC",supsim:"\u2AC8",supsub:"\u2AD4",supsup:"\u2AD6",swArr:"\u21D9",swarhk:"\u2926",swarr:"\u2199",swarrow:"\u2199",swnwar:"\u292A",szlig:"\xDF",target:"\u2316",tau:"\u03C4",tbrk:"\u23B4",tcaron:"\u0165",tcedil:"\u0163",tcy:"\u0442",tdot:"\u20DB",telrec:"\u2315",tfr:"\uD835\uDD31",there4:"\u2234",therefore:"\u2234",theta:"\u03B8",thetasym:"\u03D1",thetav:"\u03D1",thickapprox:"\u2248",thicksim:"\u223C",thinsp:"\u2009",thkap:"\u2248",thksim:"\u223C",thorn:"\xFE",tilde:"\u02DC",times:"\xD7",timesb:"\u22A0",timesbar:"\u2A31",timesd:"\u2A30",tint:"\u222D",toea:"\u2928",top:"\u22A4",topbot:"\u2336",topcir:"\u2AF1",topf:"\uD835\uDD65",topfork:"\u2ADA",tosa:"\u2929",tprime:"\u2034",trade:"\u2122",triangle:"\u25B5",triangledown:"\u25BF",triangleleft:"\u25C3",trianglelefteq:"\u22B4",triangleq:"\u225C",triangleright:"\u25B9",trianglerighteq:"\u22B5",tridot:"\u25EC",trie:"\u225C",triminus:"\u2A3A",triplus:"\u2A39",trisb:"\u29CD",tritime:"\u2A3B",trpezium:"\u23E2",tscr:"\uD835\uDCC9",tscy:"\u0446",tshcy:"\u045B",tstrok:"\u0167",twixt:"\u226C",twoheadleftarrow:"\u219E",twoheadrightarrow:"\u21A0",uArr:"\u21D1",uHar:"\u2963",uacute:"\xFA",uarr:"\u2191",ubrcy:"\u045E",ubreve:"\u016D",ucirc:"\xFB",ucy:"\u0443",udarr:"\u21C5",udblac:"\u0171",udhar:"\u296E",ufisht:"\u297E",ufr:"\uD835\uDD32",ugrave:"\xF9",uharl:"\u21BF",uharr:"\u21BE",uhblk:"\u2580",ulcorn:"\u231C",ulcorner:"\u231C",ulcrop:"\u230F",ultri:"\u25F8",umacr:"\u016B",uml:"\xA8",uogon:"\u0173",uopf:"\uD835\uDD66",uparrow:"\u2191",updownarrow:"\u2195",upharpoonleft:"\u21BF",upharpoonright:"\u21BE",uplus:"\u228E",upsi:"\u03C5",upsih:"\u03D2",upsilon:"\u03C5",upuparrows:"\u21C8",urcorn:"\u231D",urcorner:"\u231D",urcrop:"\u230E",uring:"\u016F",urtri:"\u25F9",uscr:"\uD835\uDCCA",utdot:"\u22F0",utilde:"\u0169",utri:"\u25B5",utrif:"\u25B4",uuarr:"\u21C8",uuml:"\xFC",uwangle:"\u29A7",vArr:"\u21D5",vBar:"\u2AE8",vBarv:"\u2AE9",vDash:"\u22A8",vangrt:"\u299C",varepsilon:"\u03F5",varkappa:"\u03F0",varnothing:"\u2205",varphi:"\u03D5",varpi:"\u03D6",varpropto:"\u221D",varr:"\u2195",varrho:"\u03F1",varsigma:"\u03C2",varsubsetneq:"\u228A\uFE00",varsubsetneqq:"\u2ACB\uFE00",varsupsetneq:"\u228B\uFE00",varsupsetneqq:"\u2ACC\uFE00",vartheta:"\u03D1",vartriangleleft:"\u22B2",vartriangleright:"\u22B3",vcy:"\u0432",vdash:"\u22A2",vee:"\u2228",veebar:"\u22BB",veeeq:"\u225A",vellip:"\u22EE",verbar:"|",vert:"|",vfr:"\uD835\uDD33",vltri:"\u22B2",vnsub:"\u2282\u20D2",vnsup:"\u2283\u20D2",vopf:"\uD835\uDD67",vprop:"\u221D",vrtri:"\u22B3",vscr:"\uD835\uDCCB",vsubnE:"\u2ACB\uFE00",vsubne:"\u228A\uFE00",vsupnE:"\u2ACC\uFE00",vsupne:"\u228B\uFE00",vzigzag:"\u299A",wcirc:"\u0175",wedbar:"\u2A5F",wedge:"\u2227",wedgeq:"\u2259",weierp:"\u2118",wfr:"\uD835\uDD34",wopf:"\uD835\uDD68",wp:"\u2118",wr:"\u2240",wreath:"\u2240",wscr:"\uD835\uDCCC",xcap:"\u22C2",xcirc:"\u25EF",xcup:"\u22C3",xdtri:"\u25BD",xfr:"\uD835\uDD35",xhArr:"\u27FA",xharr:"\u27F7",xi:"\u03BE",xlArr:"\u27F8",xlarr:"\u27F5",xmap:"\u27FC",xnis:"\u22FB",xodot:"\u2A00",xopf:"\uD835\uDD69",xoplus:"\u2A01",xotime:"\u2A02",xrArr:"\u27F9",xrarr:"\u27F6",xscr:"\uD835\uDCCD",xsqcup:"\u2A06",xuplus:"\u2A04",xutri:"\u25B3",xvee:"\u22C1",xwedge:"\u22C0",yacute:"\xFD",yacy:"\u044F",ycirc:"\u0177",ycy:"\u044B",yen:"\xA5",yfr:"\uD835\uDD36",yicy:"\u0457",yopf:"\uD835\uDD6A",yscr:"\uD835\uDCCE",yucy:"\u044E",yuml:"\xFF",zacute:"\u017A",zcaron:"\u017E",zcy:"\u0437",zdot:"\u017C",zeetrf:"\u2128",zeta:"\u03B6",zfr:"\uD835\uDD37",zhcy:"\u0436",zigrarr:"\u21DD",zopf:"\uD835\uDD6B",zscr:"\uD835\uDCCF",zwj:"\u200D",zwnj:"\u200C"}});function Wc(e){return Rie.call(k1,e)?k1[e]:!1}var Rie;var fg=x(()=>{Tj();Rie={}.hasOwnProperty});var w;var Cj=x(()=>{w={carriageReturn:-5,lineFeed:-4,carriageReturnLineFeed:-3,horizontalTab:-2,virtualSpace:-1,eof:null,nul:0,soh:1,stx:2,etx:3,eot:4,enq:5,ack:6,bel:7,bs:8,ht:9,lf:10,vt:11,ff:12,cr:13,so:14,si:15,dle:16,dc1:17,dc2:18,dc3:19,dc4:20,nak:21,syn:22,etb:23,can:24,em:25,sub:26,esc:27,fs:28,gs:29,rs:30,us:31,space:32,exclamationMark:33,quotationMark:34,numberSign:35,dollarSign:36,percentSign:37,ampersand:38,apostrophe:39,leftParenthesis:40,rightParenthesis:41,asterisk:42,plusSign:43,comma:44,dash:45,dot:46,slash:47,digit0:48,digit1:49,digit2:50,digit3:51,digit4:52,digit5:53,digit6:54,digit7:55,digit8:56,digit9:57,colon:58,semicolon:59,lessThan:60,equalsTo:61,greaterThan:62,questionMark:63,atSign:64,uppercaseA:65,uppercaseB:66,uppercaseC:67,uppercaseD:68,uppercaseE:69,uppercaseF:70,uppercaseG:71,uppercaseH:72,uppercaseI:73,uppercaseJ:74,uppercaseK:75,uppercaseL:76,uppercaseM:77,uppercaseN:78,uppercaseO:79,uppercaseP:80,uppercaseQ:81,uppercaseR:82,uppercaseS:83,uppercaseT:84,uppercaseU:85,uppercaseV:86,uppercaseW:87,uppercaseX:88,uppercaseY:89,uppercaseZ:90,leftSquareBracket:91,backslash:92,rightSquareBracket:93,caret:94,underscore:95,graveAccent:96,lowercaseA:97,lowercaseB:98,lowercaseC:99,lowercaseD:100,lowercaseE:101,lowercaseF:102,lowercaseG:103,lowercaseH:104,lowercaseI:105,lowercaseJ:106,lowercaseK:107,lowercaseL:108,lowercaseM:109,lowercaseN:110,lowercaseO:111,lowercaseP:112,lowercaseQ:113,lowercaseR:114,lowercaseS:115,lowercaseT:116,lowercaseU:117,lowercaseV:118,lowercaseW:119,lowercaseX:120,lowercaseY:121,lowercaseZ:122,leftCurlyBrace:123,verticalBar:124,rightCurlyBrace:125,tilde:126,del:127,byteOrderMarker:65279,replacementCharacter:65533}});var be;var $j=x(()=>{be={attentionSideAfter:2,attentionSideBefore:1,atxHeadingOpeningFenceSizeMax:6,autolinkDomainSizeMax:63,autolinkSchemeSizeMax:32,cdataOpeningString:"CDATA[",characterGroupPunctuation:2,characterGroupWhitespace:1,characterReferenceDecimalSizeMax:7,characterReferenceHexadecimalSizeMax:6,characterReferenceNamedSizeMax:31,codeFencedSequenceSizeMin:3,contentTypeContent:"content",contentTypeDocument:"document",contentTypeFlow:"flow",contentTypeString:"string",contentTypeText:"text",hardBreakPrefixSizeMin:2,htmlBasic:6,htmlCdata:5,htmlComment:2,htmlComplete:7,htmlDeclaration:4,htmlInstruction:3,htmlRawSizeMax:8,htmlRaw:1,linkResourceDestinationBalanceMax:32,linkReferenceSizeMax:999,listItemValueSizeMax:10,numericBaseDecimal:10,numericBaseHexadecimal:16,tabSize:4,thematicBreakMarkerCountMin:3,v8MaxSafeChunkSize:1e4}});var S;var Oj=x(()=>{S={data:"data",whitespace:"whitespace",lineEnding:"lineEnding",lineEndingBlank:"lineEndingBlank",linePrefix:"linePrefix",lineSuffix:"lineSuffix",atxHeading:"atxHeading",atxHeadingSequence:"atxHeadingSequence",atxHeadingText:"atxHeadingText",autolink:"autolink",autolinkEmail:"autolinkEmail",autolinkMarker:"autolinkMarker",autolinkProtocol:"autolinkProtocol",characterEscape:"characterEscape",characterEscapeValue:"characterEscapeValue",characterReference:"characterReference",characterReferenceMarker:"characterReferenceMarker",characterReferenceMarkerNumeric:"characterReferenceMarkerNumeric",characterReferenceMarkerHexadecimal:"characterReferenceMarkerHexadecimal",characterReferenceValue:"characterReferenceValue",codeFenced:"codeFenced",codeFencedFence:"codeFencedFence",codeFencedFenceSequence:"codeFencedFenceSequence",codeFencedFenceInfo:"codeFencedFenceInfo",codeFencedFenceMeta:"codeFencedFenceMeta",codeFlowValue:"codeFlowValue",codeIndented:"codeIndented",codeText:"codeText",codeTextData:"codeTextData",codeTextPadding:"codeTextPadding",codeTextSequence:"codeTextSequence",content:"content",definition:"definition",definitionDestination:"definitionDestination",definitionDestinationLiteral:"definitionDestinationLiteral",definitionDestinationLiteralMarker:"definitionDestinationLiteralMarker",definitionDestinationRaw:"definitionDestinationRaw",definitionDestinationString:"definitionDestinationString",definitionLabel:"definitionLabel",definitionLabelMarker:"definitionLabelMarker",definitionLabelString:"definitionLabelString",definitionMarker:"definitionMarker",definitionTitle:"definitionTitle",definitionTitleMarker:"definitionTitleMarker",definitionTitleString:"definitionTitleString",emphasis:"emphasis",emphasisSequence:"emphasisSequence",emphasisText:"emphasisText",escapeMarker:"escapeMarker",hardBreakEscape:"hardBreakEscape",hardBreakTrailing:"hardBreakTrailing",htmlFlow:"htmlFlow",htmlFlowData:"htmlFlowData",htmlText:"htmlText",htmlTextData:"htmlTextData",image:"image",label:"label",labelText:"labelText",labelLink:"labelLink",labelImage:"labelImage",labelMarker:"labelMarker",labelImageMarker:"labelImageMarker",labelEnd:"labelEnd",link:"link",paragraph:"paragraph",reference:"reference",referenceMarker:"referenceMarker",referenceString:"referenceString",resource:"resource",resourceDestination:"resourceDestination",resourceDestinationLiteral:"resourceDestinationLiteral",resourceDestinationLiteralMarker:"resourceDestinationLiteralMarker",resourceDestinationRaw:"resourceDestinationRaw",resourceDestinationString:"resourceDestinationString",resourceMarker:"resourceMarker",resourceTitle:"resourceTitle",resourceTitleMarker:"resourceTitleMarker",resourceTitleString:"resourceTitleString",setextHeading:"setextHeading",setextHeadingText:"setextHeadingText",setextHeadingLine:"setextHeadingLine",setextHeadingLineSequence:"setextHeadingLineSequence",strong:"strong",strongSequence:"strongSequence",strongText:"strongText",thematicBreak:"thematicBreak",thematicBreakSequence:"thematicBreakSequence",blockQuote:"blockQuote",blockQuotePrefix:"blockQuotePrefix",blockQuoteMarker:"blockQuoteMarker",blockQuotePrefixWhitespace:"blockQuotePrefixWhitespace",listOrdered:"listOrdered",listUnordered:"listUnordered",listItemIndent:"listItemIndent",listItemMarker:"listItemMarker",listItemPrefix:"listItemPrefix",listItemPrefixWhitespace:"listItemPrefixWhitespace",listItemValue:"listItemValue",chunkDocument:"chunkDocument",chunkContent:"chunkContent",chunkFlow:"chunkFlow",chunkText:"chunkText",chunkString:"chunkString"}});var on;var Rj=x(()=>{on={ht:"\t",lf:`
273
- `,cr:"\r",space:" ",exclamationMark:"!",quotationMark:'"',numberSign:"#",dollarSign:"$",percentSign:"%",ampersand:"&",apostrophe:"'",leftParenthesis:"(",rightParenthesis:")",asterisk:"*",plusSign:"+",comma:",",dash:"-",dot:".",slash:"/",digit0:"0",digit1:"1",digit2:"2",digit3:"3",digit4:"4",digit5:"5",digit6:"6",digit7:"7",digit8:"8",digit9:"9",colon:":",semicolon:";",lessThan:"<",equalsTo:"=",greaterThan:">",questionMark:"?",atSign:"@",uppercaseA:"A",uppercaseB:"B",uppercaseC:"C",uppercaseD:"D",uppercaseE:"E",uppercaseF:"F",uppercaseG:"G",uppercaseH:"H",uppercaseI:"I",uppercaseJ:"J",uppercaseK:"K",uppercaseL:"L",uppercaseM:"M",uppercaseN:"N",uppercaseO:"O",uppercaseP:"P",uppercaseQ:"Q",uppercaseR:"R",uppercaseS:"S",uppercaseT:"T",uppercaseU:"U",uppercaseV:"V",uppercaseW:"W",uppercaseX:"X",uppercaseY:"Y",uppercaseZ:"Z",leftSquareBracket:"[",backslash:"\\",rightSquareBracket:"]",caret:"^",underscore:"_",graveAccent:"`",lowercaseA:"a",lowercaseB:"b",lowercaseC:"c",lowercaseD:"d",lowercaseE:"e",lowercaseF:"f",lowercaseG:"g",lowercaseH:"h",lowercaseI:"i",lowercaseJ:"j",lowercaseK:"k",lowercaseL:"l",lowercaseM:"m",lowercaseN:"n",lowercaseO:"o",lowercaseP:"p",lowercaseQ:"q",lowercaseR:"r",lowercaseS:"s",lowercaseT:"t",lowercaseU:"u",lowercaseV:"v",lowercaseW:"w",lowercaseX:"x",lowercaseY:"y",lowercaseZ:"z",leftCurlyBrace:"{",verticalBar:"|",rightCurlyBrace:"}",tilde:"~",replacementCharacter:"\uFFFD"}});var Fe=x(()=>{Cj();$j();Oj();Rj()});function nr(e,t,r,i){let n=e.length,o=0,s;if(t<0)t=-t>n?0:n+t;else t=t>n?n:t;if(r=r>0?r:0,i.length<be.v8MaxSafeChunkSize)s=Array.from(i),s.unshift(t,r),e.splice(...s);else{if(r)e.splice(t,r);while(o<i.length)s=i.slice(o,o+be.v8MaxSafeChunkSize),s.unshift(t,0),e.splice(...s),o+=be.v8MaxSafeChunkSize,t+=be.v8MaxSafeChunkSize}}function Nr(e,t){if(e.length>0)return nr(e,e.length,0,t),e;return t}var zo=x(()=>{Fe()});function zj(e){let t={},r=-1;while(++r<e.length)Pie(t,e[r]);return t}function Pie(e,t){let r;for(r in t){let n=(Pj.call(e,r)?e[r]:void 0)||(e[r]={}),o=t[r],s;if(o)for(s in o){if(!Pj.call(n,s))n[s]=[];let a=o[s];zie(n[s],Array.isArray(a)?a:a?[a]:[])}}}function zie(e,t){let r=-1,i=[];while(++r<t.length)(t[r].add==="after"?e:i).push(t[r]);nr(e,0,0,i)}var Pj;var Nj=x(()=>{zo();Pj={}.hasOwnProperty});function pg(e,t){let r=Number.parseInt(e,t);if(r<w.ht||r===w.vt||r>w.cr&&r<w.space||r>w.tilde&&r<160||r>55295&&r<57344||r>64975&&r<65008||(r&65535)===65535||(r&65535)===65534||r>1114111)return on.replacementCharacter;return String.fromCodePoint(r)}var E1=x(()=>{Fe()});function Ni(e){return e.replace(/[\t\n\r ]+/g,on.space).replace(/^ | $/g,"").toLowerCase().toUpperCase()}var mg=x(()=>{Fe()});function Nd(e){return e!==null&&(e<w.space||e===w.del)}function ve(e){return e!==null&&e<w.horizontalTab}function $t(e){return e!==null&&(e<w.nul||e===w.space)}function Me(e){return e===w.horizontalTab||e===w.virtualSpace||e===w.space}function No(e){return t;function t(r){return r!==null&&r>-1&&e.test(String.fromCharCode(r))}}var sn,Dr,Dj,Dd,Lj,Bj,jj,qj;var ot=x(()=>{Fe();sn=No(/[A-Za-z]/),Dr=No(/[\dA-Za-z]/),Dj=No(/[#-'*+\--9=?A-Z^-~]/);Dd=No(/\d/),Lj=No(/[\dA-Fa-f]/),Bj=No(/[!-/:-@[-`{-~]/);jj=No(/\p{P}|\p{S}/u),qj=No(/\s/)});function Ze(e,t,r,i){let n=i?i-1:Number.POSITIVE_INFINITY,o=0;return s;function s(c){if(Me(c))return e.enter(r),a(c);return t(c)}function a(c){if(Me(c)&&o++<n)return e.consume(c),a;return e.exit(r),t(c)}}var Gt=x(()=>{ot()});function Nie(e){let t=e.attempt(this.parser.constructs.contentInitial,i,n),r;return t;function i(a){if(B(a===w.eof||ve(a),"expected eol or eof"),a===w.eof){e.consume(a);return}return e.enter(S.lineEnding),e.consume(a),e.exit(S.lineEnding),Ze(e,t,S.linePrefix)}function n(a){return B(a!==w.eof&&!ve(a),"expected anything other than a line ending or EOF"),e.enter(S.paragraph),o(a)}function o(a){let c=e.enter(S.chunkText,{contentType:be.contentTypeText,previous:r});if(r)r.next=c;return r=c,s(a)}function s(a){if(a===w.eof){e.exit(S.chunkText),e.exit(S.paragraph),e.consume(a);return}if(ve(a))return e.consume(a),e.exit(S.chunkText),o;return e.consume(a),s}}var Uj;var Mj=x(()=>{tt();Gt();ot();Fe();Uj={tokenize:Nie}});function Die(e){let t=this,r=[],i=0,n,o,s;return a;function a(T){if(i<r.length){let z=r[i];return t.containerState=z[1],B(z[0].continuation,"expected `continuation` to be defined on container construct"),e.attempt(z[0].continuation,c,l)(T)}return l(T)}function c(T){if(B(t.containerState,"expected `containerState` to be defined after continuation"),i++,t.containerState._closeFlow){if(t.containerState._closeFlow=void 0,n)A();let z=t.events.length,j=z,E;while(j--)if(t.events[j][0]==="exit"&&t.events[j][1].type===S.chunkFlow){E=t.events[j][1].end;break}B(E,"could not find previous flow chunk"),v(i);let Z=z;while(Z<t.events.length)t.events[Z][1].end={...E},Z++;return nr(t.events,j+1,0,t.events.slice(z)),t.events.length=Z,l(T)}return a(T)}function l(T){if(i===r.length){if(!n)return p(T);if(n.currentConstruct&&n.currentConstruct.concrete)return y(T);t.interrupt=Boolean(n.currentConstruct&&!n._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Fj,u,d)(T)}function u(T){if(n)A();return v(i),p(T)}function d(T){return t.parser.lazy[t.now().line]=i!==r.length,s=t.now().offset,y(T)}function p(T){return t.containerState={},e.attempt(Fj,m,y)(T)}function m(T){return B(t.currentConstruct,"expected `currentConstruct` to be defined on tokenizer"),B(t.containerState,"expected `containerState` to be defined on tokenizer"),i++,r.push([t.currentConstruct,t.containerState]),p(T)}function y(T){if(T===w.eof){if(n)A();v(0),e.consume(T);return}return n=n||t.parser.flow(t.now()),e.enter(S.chunkFlow,{_tokenizer:n,contentType:be.contentTypeFlow,previous:o}),g(T)}function g(T){if(T===w.eof){b(e.exit(S.chunkFlow),!0),v(0),e.consume(T);return}if(ve(T))return e.consume(T),b(e.exit(S.chunkFlow)),i=0,t.interrupt=void 0,a;return e.consume(T),g}function b(T,z){B(n,"expected `childFlow` to be defined when continuing");let j=t.sliceStream(T);if(z)j.push(null);if(T.previous=o,o)o.next=T;if(o=T,n.defineSkip(T.start),n.write(j),t.parser.lazy[T.start.line]){let E=n.events.length;while(E--)if(n.events[E][1].start.offset<s&&(!n.events[E][1].end||n.events[E][1].end.offset>s))return;let Z=t.events.length,D=Z,H,X;while(D--)if(t.events[D][0]==="exit"&&t.events[D][1].type===S.chunkFlow){if(H){X=t.events[D][1].end;break}H=!0}B(X,"could not find previous flow chunk"),v(i),E=Z;while(E<t.events.length)t.events[E][1].end={...X},E++;nr(t.events,D+1,0,t.events.slice(Z)),t.events.length=E}}function v(T){let z=r.length;while(z-- >T){let j=r[z];t.containerState=j[1],B(j[0].exit,"expected `exit` to be defined on container construct"),j[0].exit.call(t,e)}r.length=T}function A(){B(t.containerState,"expected `containerState` to be defined when closing flow"),B(n,"expected `childFlow` to be defined when closing it"),n.write([w.eof]),o=void 0,n=void 0,t.containerState._closeFlow=void 0}}function Lie(e,t,r){return B(this.parser.constructs.disable.null,"expected `disable.null` to be populated"),Ze(e,e.attempt(this.parser.constructs.document,t,r),S.linePrefix,this.parser.constructs.disable.null.includes("codeIndented")?void 0:be.tabSize)}var Zj,Fj;var Hj=x(()=>{tt();Gt();ot();zo();Fe();Zj={tokenize:Die},Fj={tokenize:Lie}});function Gc(e){if(e===w.eof||$t(e)||qj(e))return be.characterGroupWhitespace;if(jj(e))return be.characterGroupPunctuation}var I1=x(()=>{ot();Fe()});function Qc(e,t,r){let i=[],n=-1;while(++n<e.length){let o=e[n].resolveAll;if(o&&!i.includes(o))t=o(t,r),i.push(o)}return t}function Bie(e,t){let r=-1,i,n,o,s,a,c,l,u;while(++r<e.length)if(e[r][0]==="enter"&&e[r][1].type==="attentionSequence"&&e[r][1]._close){i=r;while(i--)if(e[i][0]==="exit"&&e[i][1].type==="attentionSequence"&&e[i][1]._open&&t.sliceSerialize(e[i][1]).charCodeAt(0)===t.sliceSerialize(e[r][1]).charCodeAt(0)){if((e[i][1]._close||e[r][1]._open)&&(e[r][1].end.offset-e[r][1].start.offset)%3&&!((e[i][1].end.offset-e[i][1].start.offset+e[r][1].end.offset-e[r][1].start.offset)%3))continue;c=e[i][1].end.offset-e[i][1].start.offset>1&&e[r][1].end.offset-e[r][1].start.offset>1?2:1;let d={...e[i][1].end},p={...e[r][1].start};if(Kj(d,-c),Kj(p,c),s={type:c>1?S.strongSequence:S.emphasisSequence,start:d,end:{...e[i][1].end}},a={type:c>1?S.strongSequence:S.emphasisSequence,start:{...e[r][1].start},end:p},o={type:c>1?S.strongText:S.emphasisText,start:{...e[i][1].end},end:{...e[r][1].start}},n={type:c>1?S.strong:S.emphasis,start:{...s.start},end:{...a.end}},e[i][1].end={...s.start},e[r][1].start={...a.end},l=[],e[i][1].end.offset-e[i][1].start.offset)l=Nr(l,[["enter",e[i][1],t],["exit",e[i][1],t]]);if(l=Nr(l,[["enter",n,t],["enter",s,t],["exit",s,t],["enter",o,t]]),B(t.parser.constructs.insideSpan.null,"expected `insideSpan` to be populated"),l=Nr(l,Qc(t.parser.constructs.insideSpan.null,e.slice(i+1,r),t)),l=Nr(l,[["exit",o,t],["enter",a,t],["exit",a,t],["exit",n,t]]),e[r][1].end.offset-e[r][1].start.offset)u=2,l=Nr(l,[["enter",e[r][1],t],["exit",e[r][1],t]]);else u=0;nr(e,i-1,r-i+3,l),r=i+l.length-u-2;break}}r=-1;while(++r<e.length)if(e[r][1].type==="attentionSequence")e[r][1].type="data";return e}function jie(e,t){let r=this.parser.constructs.attentionMarkers.null,i=this.previous,n=Gc(i),o;return s;function s(c){return B(c===w.asterisk||c===w.underscore,"expected asterisk or underscore"),o=c,e.enter("attentionSequence"),a(c)}function a(c){if(c===o)return e.consume(c),a;let l=e.exit("attentionSequence"),u=Gc(c);B(r,"expected `attentionMarkers` to be populated");let d=!u||u===be.characterGroupPunctuation&&n||r.includes(c),p=!n||n===be.characterGroupPunctuation&&u||r.includes(i);return l._open=Boolean(o===w.asterisk?d:d&&(n||!p)),l._close=Boolean(o===w.asterisk?p:p&&(u||!d)),t(c)}}function Kj(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var Ld;var Jj=x(()=>{tt();zo();I1();Fe();Ld={name:"attention",resolveAll:Bie,tokenize:jie}});function qie(e,t,r){let i=0;return n;function n(m){return B(m===w.lessThan,"expected `<`"),e.enter(S.autolink),e.enter(S.autolinkMarker),e.consume(m),e.exit(S.autolinkMarker),e.enter(S.autolinkProtocol),o}function o(m){if(sn(m))return e.consume(m),s;if(m===w.atSign)return r(m);return l(m)}function s(m){if(m===w.plusSign||m===w.dash||m===w.dot||Dr(m))return i=1,a(m);return l(m)}function a(m){if(m===w.colon)return e.consume(m),i=0,c;if((m===w.plusSign||m===w.dash||m===w.dot||Dr(m))&&i++<be.autolinkSchemeSizeMax)return e.consume(m),a;return i=0,l(m)}function c(m){if(m===w.greaterThan)return e.exit(S.autolinkProtocol),e.enter(S.autolinkMarker),e.consume(m),e.exit(S.autolinkMarker),e.exit(S.autolink),t;if(m===w.eof||m===w.space||m===w.lessThan||Nd(m))return r(m);return e.consume(m),c}function l(m){if(m===w.atSign)return e.consume(m),u;if(Dj(m))return e.consume(m),l;return r(m)}function u(m){return Dr(m)?d(m):r(m)}function d(m){if(m===w.dot)return e.consume(m),i=0,u;if(m===w.greaterThan)return e.exit(S.autolinkProtocol).type=S.autolinkEmail,e.enter(S.autolinkMarker),e.consume(m),e.exit(S.autolinkMarker),e.exit(S.autolink),t;return p(m)}function p(m){if((m===w.dash||Dr(m))&&i++<be.autolinkDomainSizeMax){let y=m===w.dash?p:d;return e.consume(m),y}return r(m)}}var A1;var Vj=x(()=>{tt();ot();Fe();A1={name:"autolink",tokenize:qie}});function Uie(e,t,r){return i;function i(o){return Me(o)?Ze(e,n,S.linePrefix)(o):n(o)}function n(o){return o===w.eof||ve(o)?t(o):r(o)}}var Do;var hg=x(()=>{Gt();ot();Fe();Do={partial:!0,tokenize:Uie}});function Mie(e,t,r){let i=this;return n;function n(s){if(s===w.greaterThan){let a=i.containerState;if(B(a,"expected `containerState` to be defined in container"),!a.open)e.enter(S.blockQuote,{_container:!0}),a.open=!0;return e.enter(S.blockQuotePrefix),e.enter(S.blockQuoteMarker),e.consume(s),e.exit(S.blockQuoteMarker),o}return r(s)}function o(s){if(Me(s))return e.enter(S.blockQuotePrefixWhitespace),e.consume(s),e.exit(S.blockQuotePrefixWhitespace),e.exit(S.blockQuotePrefix),t;return e.exit(S.blockQuotePrefix),t(s)}}function Fie(e,t,r){let i=this;return n;function n(s){if(Me(s))return B(i.parser.constructs.disable.null,"expected `disable.null` to be populated"),Ze(e,o,S.linePrefix,i.parser.constructs.disable.null.includes("codeIndented")?void 0:be.tabSize)(s);return o(s)}function o(s){return e.attempt(gg,t,r)(s)}}function Zie(e){e.exit(S.blockQuote)}var gg;var Wj=x(()=>{tt();Gt();ot();Fe();gg={continuation:{tokenize:Fie},exit:Zie,name:"blockQuote",tokenize:Mie}});function Hie(e,t,r){return i;function i(o){return B(o===w.backslash,"expected `\\`"),e.enter(S.characterEscape),e.enter(S.escapeMarker),e.consume(o),e.exit(S.escapeMarker),n}function n(o){if(Bj(o))return e.enter(S.characterEscapeValue),e.consume(o),e.exit(S.characterEscapeValue),e.exit(S.characterEscape),t;return r(o)}}var yg;var Gj=x(()=>{tt();ot();Fe();yg={name:"characterEscape",tokenize:Hie}});function Kie(e,t,r){let i=this,n=0,o,s;return a;function a(d){return B(d===w.ampersand,"expected `&`"),e.enter(S.characterReference),e.enter(S.characterReferenceMarker),e.consume(d),e.exit(S.characterReferenceMarker),c}function c(d){if(d===w.numberSign)return e.enter(S.characterReferenceMarkerNumeric),e.consume(d),e.exit(S.characterReferenceMarkerNumeric),l;return e.enter(S.characterReferenceValue),o=be.characterReferenceNamedSizeMax,s=Dr,u(d)}function l(d){if(d===w.uppercaseX||d===w.lowercaseX)return e.enter(S.characterReferenceMarkerHexadecimal),e.consume(d),e.exit(S.characterReferenceMarkerHexadecimal),e.enter(S.characterReferenceValue),o=be.characterReferenceHexadecimalSizeMax,s=Lj,u;return e.enter(S.characterReferenceValue),o=be.characterReferenceDecimalSizeMax,s=Dd,u(d)}function u(d){if(d===w.semicolon&&n){let p=e.exit(S.characterReferenceValue);if(s===Dr&&!Wc(i.sliceSerialize(p)))return r(d);return e.enter(S.characterReferenceMarker),e.consume(d),e.exit(S.characterReferenceMarker),e.exit(S.characterReference),t}if(s(d)&&n++<o)return e.consume(d),u;return r(d)}}var bg;var Qj=x(()=>{tt();fg();ot();Fe();bg={name:"characterReference",tokenize:Kie}});function Jie(e,t,r){let i=this,n={partial:!0,tokenize:j},o=0,s=0,a;return c;function c(E){return l(E)}function l(E){B(E===w.graveAccent||E===w.tilde,"expected `` ` `` or `~`");let Z=i.events[i.events.length-1];return o=Z&&Z[1].type===S.linePrefix?Z[2].sliceSerialize(Z[1],!0).length:0,a=E,e.enter(S.codeFenced),e.enter(S.codeFencedFence),e.enter(S.codeFencedFenceSequence),u(E)}function u(E){if(E===a)return s++,e.consume(E),u;if(s<be.codeFencedSequenceSizeMin)return r(E);return e.exit(S.codeFencedFenceSequence),Me(E)?Ze(e,d,S.whitespace)(E):d(E)}function d(E){if(E===w.eof||ve(E))return e.exit(S.codeFencedFence),i.interrupt?t(E):e.check(Yj,g,z)(E);return e.enter(S.codeFencedFenceInfo),e.enter(S.chunkString,{contentType:be.contentTypeString}),p(E)}function p(E){if(E===w.eof||ve(E))return e.exit(S.chunkString),e.exit(S.codeFencedFenceInfo),d(E);if(Me(E))return e.exit(S.chunkString),e.exit(S.codeFencedFenceInfo),Ze(e,m,S.whitespace)(E);if(E===w.graveAccent&&E===a)return r(E);return e.consume(E),p}function m(E){if(E===w.eof||ve(E))return d(E);return e.enter(S.codeFencedFenceMeta),e.enter(S.chunkString,{contentType:be.contentTypeString}),y(E)}function y(E){if(E===w.eof||ve(E))return e.exit(S.chunkString),e.exit(S.codeFencedFenceMeta),d(E);if(E===w.graveAccent&&E===a)return r(E);return e.consume(E),y}function g(E){return B(ve(E),"expected eol"),e.attempt(n,z,b)(E)}function b(E){return B(ve(E),"expected eol"),e.enter(S.lineEnding),e.consume(E),e.exit(S.lineEnding),v}function v(E){return o>0&&Me(E)?Ze(e,A,S.linePrefix,o+1)(E):A(E)}function A(E){if(E===w.eof||ve(E))return e.check(Yj,g,z)(E);return e.enter(S.codeFlowValue),T(E)}function T(E){if(E===w.eof||ve(E))return e.exit(S.codeFlowValue),A(E);return e.consume(E),T}function z(E){return e.exit(S.codeFenced),t(E)}function j(E,Z,D){let H=0;return X;function X(R){return B(ve(R),"expected eol"),E.enter(S.lineEnding),E.consume(R),E.exit(S.lineEnding),M}function M(R){return B(i.parser.constructs.disable.null,"expected `disable.null` to be populated"),E.enter(S.codeFencedFence),Me(R)?Ze(E,P,S.linePrefix,i.parser.constructs.disable.null.includes("codeIndented")?void 0:be.tabSize)(R):P(R)}function P(R){if(R===a)return E.enter(S.codeFencedFenceSequence),N(R);return D(R)}function N(R){if(R===a)return H++,E.consume(R),N;if(H>=s)return E.exit(S.codeFencedFenceSequence),Me(R)?Ze(E,I,S.whitespace)(R):I(R);return D(R)}function I(R){if(R===w.eof||ve(R))return E.exit(S.codeFencedFence),Z(R);return D(R)}}}function Vie(e,t,r){let i=this;return n;function n(s){if(s===w.eof)return r(s);return B(ve(s),"expected eol"),e.enter(S.lineEnding),e.consume(s),e.exit(S.lineEnding),o}function o(s){return i.parser.lazy[i.now().line]?r(s):t(s)}}var Yj,xg;var Xj=x(()=>{tt();Gt();ot();Fe();Yj={partial:!0,tokenize:Vie},xg={concrete:!0,name:"codeFenced",tokenize:Jie}});function Gie(e,t,r){let i=this;return n;function n(l){return B(Me(l)),e.enter(S.codeIndented),Ze(e,o,S.linePrefix,be.tabSize+1)(l)}function o(l){let u=i.events[i.events.length-1];return u&&u[1].type===S.linePrefix&&u[2].sliceSerialize(u[1],!0).length>=be.tabSize?s(l):r(l)}function s(l){if(l===w.eof)return c(l);if(ve(l))return e.attempt(Wie,s,c)(l);return e.enter(S.codeFlowValue),a(l)}function a(l){if(l===w.eof||ve(l))return e.exit(S.codeFlowValue),s(l);return e.consume(l),a}function c(l){return e.exit(S.codeIndented),t(l)}}function Qie(e,t,r){let i=this;return n;function n(s){if(i.parser.lazy[i.now().line])return r(s);if(ve(s))return e.enter(S.lineEnding),e.consume(s),e.exit(S.lineEnding),n;return Ze(e,o,S.linePrefix,be.tabSize+1)(s)}function o(s){let a=i.events[i.events.length-1];return a&&a[1].type===S.linePrefix&&a[2].sliceSerialize(a[1],!0).length>=be.tabSize?t(s):ve(s)?n(s):r(s)}}var Bd,Wie;var e6=x(()=>{tt();Gt();ot();Fe();Bd={name:"codeIndented",tokenize:Gie},Wie={partial:!0,tokenize:Qie}});function Yie(e){let t=e.length-4,r=3,i,n;if((e[r][1].type===S.lineEnding||e[r][1].type==="space")&&(e[t][1].type===S.lineEnding||e[t][1].type==="space")){i=r;while(++i<t)if(e[i][1].type===S.codeTextData){e[r][1].type=S.codeTextPadding,e[t][1].type=S.codeTextPadding,r+=2,t-=2;break}}i=r-1,t++;while(++i<=t)if(n===void 0){if(i!==t&&e[i][1].type!==S.lineEnding)n=i}else if(i===t||e[i][1].type===S.lineEnding){if(e[n][1].type=S.codeTextData,i!==n+2)e[n][1].end=e[i-1][1].end,e.splice(n+2,i-n-2),t-=i-n-2,i=n+2;n=void 0}return e}function t6(e){return e!==w.graveAccent||this.events[this.events.length-1][1].type===S.characterEscape}function Xie(e,t,r){let i=this,n=0,o,s;return a;function a(p){return B(p===w.graveAccent,"expected `` ` ``"),B(t6.call(i,i.previous),"expected correct previous"),e.enter(S.codeText),e.enter(S.codeTextSequence),c(p)}function c(p){if(p===w.graveAccent)return e.consume(p),n++,c;return e.exit(S.codeTextSequence),l(p)}function l(p){if(p===w.eof)return r(p);if(p===w.space)return e.enter("space"),e.consume(p),e.exit("space"),l;if(p===w.graveAccent)return s=e.enter(S.codeTextSequence),o=0,d(p);if(ve(p))return e.enter(S.lineEnding),e.consume(p),e.exit(S.lineEnding),l;return e.enter(S.codeTextData),u(p)}function u(p){if(p===w.eof||p===w.space||p===w.graveAccent||ve(p))return e.exit(S.codeTextData),l(p);return e.consume(p),u}function d(p){if(p===w.graveAccent)return e.consume(p),o++,d;if(o===n)return e.exit(S.codeTextSequence),e.exit(S.codeText),t(p);return s.type=S.codeTextData,u(p)}}var T1;var r6=x(()=>{tt();ot();Fe();T1={name:"codeText",previous:t6,resolve:Yie,tokenize:Xie}});class C1{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");if(e<this.left.length)return this.left[e];return this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let r=t===null||t===void 0?Number.POSITIVE_INFINITY:t;if(r<this.left.length)return this.left.slice(e,r);if(e>this.left.length)return this.right.slice(this.right.length-r+this.left.length,this.right.length-e+this.left.length).reverse();return this.left.slice(e).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(e,t,r){let i=t||0;this.setCursor(Math.trunc(e));let n=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);if(r)jd(this.left,r);return n.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(e){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(e)}pushMany(e){this.setCursor(Number.POSITIVE_INFINITY),jd(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),jd(this.right,e.reverse())}setCursor(e){if(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0)return;if(e<this.left.length){let t=this.left.splice(e,Number.POSITIVE_INFINITY);jd(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,Number.POSITIVE_INFINITY);jd(this.left,t.reverse())}}}function jd(e,t){let r=0;if(t.length<be.v8MaxSafeChunkSize)e.push(...t);else while(r<t.length)e.push(...t.slice(r,r+be.v8MaxSafeChunkSize)),r+=be.v8MaxSafeChunkSize}var n6=x(()=>{Fe()});function Sg(e){let t={},r=-1,i,n,o,s,a,c,l,u=new C1(e);while(++r<u.length){while(r in t)r=t[r];if(i=u.get(r),r&&i[1].type===S.chunkFlow&&u.get(r-1)[1].type===S.listItemPrefix){if(B(i[1]._tokenizer,"expected `_tokenizer` on subtokens"),c=i[1]._tokenizer.events,o=0,o<c.length&&c[o][1].type===S.lineEndingBlank)o+=2;if(o<c.length&&c[o][1].type===S.content)while(++o<c.length){if(c[o][1].type===S.content)break;if(c[o][1].type===S.chunkText)c[o][1]._isInFirstContentOfListItem=!0,o++}}if(i[0]==="enter"){if(i[1].contentType)Object.assign(t,eoe(u,r)),r=t[r],l=!0}else if(i[1]._container){o=r,n=void 0;while(o--)if(s=u.get(o),s[1].type===S.lineEnding||s[1].type===S.lineEndingBlank){if(s[0]==="enter"){if(n)u.get(n)[1].type=S.lineEndingBlank;s[1].type=S.lineEnding,n=o}}else if(s[1].type===S.linePrefix||s[1].type===S.listItemIndent);else break;if(n)i[1].end={...u.get(n)[1].start},a=u.slice(n,r),a.unshift(i),u.splice(n,r-n+1,a)}}return nr(e,0,Number.POSITIVE_INFINITY,u.slice(0)),!l}function eoe(e,t){let r=e.get(t)[1],i=e.get(t)[2],n=t-1,o=[];B(r.contentType,"expected `contentType` on subtokens");let s=r._tokenizer;if(!s){if(s=i.parser[r.contentType](r.start),r._contentTypeTextTrailing)s._contentTypeTextTrailing=!0}let a=s.events,c=[],l={},u,d,p=-1,m=r,y=0,g=0,b=[g];while(m){while(e.get(++n)[1]!==m);if(B(!d||m.previous===d,"expected previous to match"),B(!d||d.next===m,"expected next to match"),o.push(n),!m._tokenizer){if(u=i.sliceStream(m),!m.next)u.push(w.eof);if(d)s.defineSkip(m.start);if(m._isInFirstContentOfListItem)s._gfmTasklistFirstContentOfListItem=!0;if(s.write(u),m._isInFirstContentOfListItem)s._gfmTasklistFirstContentOfListItem=void 0}d=m,m=m.next}m=r;while(++p<a.length)if(a[p][0]==="exit"&&a[p-1][0]==="enter"&&a[p][1].type===a[p-1][1].type&&a[p][1].start.line!==a[p][1].end.line)B(m,"expected a current token"),g=p+1,b.push(g),m._tokenizer=void 0,m.previous=void 0,m=m.next;if(s.events=[],m)m._tokenizer=void 0,m.previous=void 0,B(!m.next,"expected no next token");else b.pop();p=b.length;while(p--){let v=a.slice(b[p],b[p+1]),A=o.pop();B(A!==void 0,"expected a start position when splicing"),c.push([A,A+v.length-1]),e.splice(A,2,v)}c.reverse(),p=-1;while(++p<c.length)l[y+c[p][0]]=y+c[p][1],y+=c[p][1]-c[p][0]-1;return l}var $1=x(()=>{tt();zo();Fe();n6()});function roe(e){return Sg(e),e}function noe(e,t){let r;return i;function i(a){return B(a!==w.eof&&!ve(a),"expected no eof or eol"),e.enter(S.content),r=e.enter(S.chunkContent,{contentType:be.contentTypeContent}),n(a)}function n(a){if(a===w.eof)return o(a);if(ve(a))return e.check(toe,s,o)(a);return e.consume(a),n}function o(a){return e.exit(S.chunkContent),e.exit(S.content),t(a)}function s(a){return B(ve(a),"expected eol"),e.consume(a),e.exit(S.chunkContent),B(r,"expected previous token"),r.next=e.enter(S.chunkContent,{contentType:be.contentTypeContent,previous:r}),r=r.next,n}}function ioe(e,t,r){let i=this;return n;function n(s){return B(ve(s),"expected a line ending"),e.exit(S.chunkContent),e.enter(S.lineEnding),e.consume(s),e.exit(S.lineEnding),Ze(e,o,S.linePrefix)}function o(s){if(s===w.eof||ve(s))return r(s);B(i.parser.constructs.disable.null,"expected `disable.null` to be populated");let a=i.events[i.events.length-1];if(!i.parser.constructs.disable.null.includes("codeIndented")&&a&&a[1].type===S.linePrefix&&a[2].sliceSerialize(a[1],!0).length>=be.tabSize)return t(s);return e.interrupt(i.parser.constructs.flow,r,t)(s)}}var O1,toe;var i6=x(()=>{tt();Gt();ot();$1();Fe();O1={resolve:roe,tokenize:noe},toe={partial:!0,tokenize:ioe}});function wg(e,t,r,i,n,o,s,a,c){let l=c||Number.POSITIVE_INFINITY,u=0;return d;function d(v){if(v===w.lessThan)return e.enter(i),e.enter(n),e.enter(o),e.consume(v),e.exit(o),p;if(v===w.eof||v===w.space||v===w.rightParenthesis||Nd(v))return r(v);return e.enter(i),e.enter(s),e.enter(a),e.enter(S.chunkString,{contentType:be.contentTypeString}),g(v)}function p(v){if(v===w.greaterThan)return e.enter(o),e.consume(v),e.exit(o),e.exit(n),e.exit(i),t;return e.enter(a),e.enter(S.chunkString,{contentType:be.contentTypeString}),m(v)}function m(v){if(v===w.greaterThan)return e.exit(S.chunkString),e.exit(a),p(v);if(v===w.eof||v===w.lessThan||ve(v))return r(v);return e.consume(v),v===w.backslash?y:m}function y(v){if(v===w.lessThan||v===w.greaterThan||v===w.backslash)return e.consume(v),m;return m(v)}function g(v){if(!u&&(v===w.eof||v===w.rightParenthesis||$t(v)))return e.exit(S.chunkString),e.exit(a),e.exit(s),e.exit(i),t(v);if(u<l&&v===w.leftParenthesis)return e.consume(v),u++,g;if(v===w.rightParenthesis)return e.consume(v),u--,g;if(v===w.eof||v===w.space||v===w.leftParenthesis||Nd(v))return r(v);return e.consume(v),v===w.backslash?b:g}function b(v){if(v===w.leftParenthesis||v===w.rightParenthesis||v===w.backslash)return e.consume(v),g;return g(v)}}var R1=x(()=>{ot();Fe()});function vg(e,t,r,i,n,o){let s=this,a=0,c;return l;function l(m){return B(m===w.leftSquareBracket,"expected `[`"),e.enter(i),e.enter(n),e.consume(m),e.exit(n),e.enter(o),u}function u(m){if(a>be.linkReferenceSizeMax||m===w.eof||m===w.leftSquareBracket||m===w.rightSquareBracket&&!c||m===w.caret&&!a&&"_hiddenFootnoteSupport"in s.parser.constructs)return r(m);if(m===w.rightSquareBracket)return e.exit(o),e.enter(n),e.consume(m),e.exit(n),e.exit(i),t;if(ve(m))return e.enter(S.lineEnding),e.consume(m),e.exit(S.lineEnding),u;return e.enter(S.chunkString,{contentType:be.contentTypeString}),d(m)}function d(m){if(m===w.eof||m===w.leftSquareBracket||m===w.rightSquareBracket||ve(m)||a++>be.linkReferenceSizeMax)return e.exit(S.chunkString),u(m);if(e.consume(m),!c)c=!Me(m);return m===w.backslash?p:d}function p(m){if(m===w.leftSquareBracket||m===w.backslash||m===w.rightSquareBracket)return e.consume(m),a++,d;return d(m)}}var P1=x(()=>{tt();ot();Fe()});function _g(e,t,r,i,n,o){let s;return a;function a(p){if(p===w.quotationMark||p===w.apostrophe||p===w.leftParenthesis)return e.enter(i),e.enter(n),e.consume(p),e.exit(n),s=p===w.leftParenthesis?w.rightParenthesis:p,c;return r(p)}function c(p){if(p===s)return e.enter(n),e.consume(p),e.exit(n),e.exit(i),t;return e.enter(o),l(p)}function l(p){if(p===s)return e.exit(o),c(s);if(p===w.eof)return r(p);if(ve(p))return e.enter(S.lineEnding),e.consume(p),e.exit(S.lineEnding),Ze(e,l,S.linePrefix);return e.enter(S.chunkString,{contentType:be.contentTypeString}),u(p)}function u(p){if(p===s||p===w.eof||ve(p))return e.exit(S.chunkString),l(p);return e.consume(p),p===w.backslash?d:u}function d(p){if(p===s||p===w.backslash)return e.consume(p),u;return u(p)}}var z1=x(()=>{Gt();ot();Fe()});function Xs(e,t){let r;return i;function i(n){if(ve(n))return e.enter(S.lineEnding),e.consume(n),e.exit(S.lineEnding),r=!0,i;if(Me(n))return Ze(e,i,r?S.linePrefix:S.lineSuffix)(n);return t(n)}}var N1=x(()=>{Gt();ot();Fe()});function soe(e,t,r){let i=this,n;return o;function o(m){return e.enter(S.definition),s(m)}function s(m){return B(m===w.leftSquareBracket,"expected `[`"),vg.call(i,e,a,r,S.definitionLabel,S.definitionLabelMarker,S.definitionLabelString)(m)}function a(m){if(n=Ni(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)),m===w.colon)return e.enter(S.definitionMarker),e.consume(m),e.exit(S.definitionMarker),c;return r(m)}function c(m){return $t(m)?Xs(e,l)(m):l(m)}function l(m){return wg(e,u,r,S.definitionDestination,S.definitionDestinationLiteral,S.definitionDestinationLiteralMarker,S.definitionDestinationRaw,S.definitionDestinationString)(m)}function u(m){return e.attempt(ooe,d,d)(m)}function d(m){return Me(m)?Ze(e,p,S.whitespace)(m):p(m)}function p(m){if(m===w.eof||ve(m))return e.exit(S.definition),i.parser.defined.push(n),t(m);return r(m)}}function aoe(e,t,r){return i;function i(a){return $t(a)?Xs(e,n)(a):r(a)}function n(a){return _g(e,o,r,S.definitionTitle,S.definitionTitleMarker,S.definitionTitleString)(a)}function o(a){return Me(a)?Ze(e,s,S.whitespace)(a):s(a)}function s(a){return a===w.eof||ve(a)?t(a):r(a)}}var D1,ooe;var o6=x(()=>{tt();R1();P1();Gt();z1();N1();ot();mg();Fe();D1={name:"definition",tokenize:soe},ooe={partial:!0,tokenize:aoe}});function coe(e,t,r){return i;function i(o){return B(o===w.backslash,"expected `\\`"),e.enter(S.hardBreakEscape),e.consume(o),n}function n(o){if(ve(o))return e.exit(S.hardBreakEscape),t(o);return r(o)}}var L1;var s6=x(()=>{tt();ot();Fe();L1={name:"hardBreakEscape",tokenize:coe}});function loe(e,t){let r=e.length-2,i=3,n,o;if(e[i][1].type===S.whitespace)i+=2;if(r-2>i&&e[r][1].type===S.whitespace)r-=2;if(e[r][1].type===S.atxHeadingSequence&&(i===r-1||r-4>i&&e[r-2][1].type===S.whitespace))r-=i+1===r?2:4;if(r>i)n={type:S.atxHeadingText,start:e[i][1].start,end:e[r][1].end},o={type:S.chunkText,start:e[i][1].start,end:e[r][1].end,contentType:be.contentTypeText},nr(e,i,r-i+1,[["enter",n,t],["enter",o,t],["exit",o,t],["exit",n,t]]);return e}function uoe(e,t,r){let i=0;return n;function n(u){return e.enter(S.atxHeading),o(u)}function o(u){return B(u===w.numberSign,"expected `#`"),e.enter(S.atxHeadingSequence),s(u)}function s(u){if(u===w.numberSign&&i++<be.atxHeadingOpeningFenceSizeMax)return e.consume(u),s;if(u===w.eof||$t(u))return e.exit(S.atxHeadingSequence),a(u);return r(u)}function a(u){if(u===w.numberSign)return e.enter(S.atxHeadingSequence),c(u);if(u===w.eof||ve(u))return e.exit(S.atxHeading),t(u);if(Me(u))return Ze(e,a,S.whitespace)(u);return e.enter(S.atxHeadingText),l(u)}function c(u){if(u===w.numberSign)return e.consume(u),c;return e.exit(S.atxHeadingSequence),a(u)}function l(u){if(u===w.eof||u===w.numberSign||$t(u))return e.exit(S.atxHeadingText),a(u);return e.consume(u),l}}var B1;var a6=x(()=>{tt();Gt();ot();zo();Fe();B1={name:"headingAtx",resolve:loe,tokenize:uoe}});var c6,j1;var l6=x(()=>{c6=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],j1=["pre","script","style","textarea"]});function poe(e){let t=e.length;while(t--)if(e[t][0]==="enter"&&e[t][1].type===S.htmlFlow)break;if(t>1&&e[t-2][1].type===S.linePrefix)e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2);return e}function moe(e,t,r){let i=this,n,o,s,a,c;return l;function l(C){return u(C)}function u(C){return B(C===w.lessThan,"expected `<`"),e.enter(S.htmlFlow),e.enter(S.htmlFlowData),e.consume(C),d}function d(C){if(C===w.exclamationMark)return e.consume(C),p;if(C===w.slash)return e.consume(C),o=!0,g;if(C===w.questionMark)return e.consume(C),n=be.htmlInstruction,i.interrupt?t:_;if(sn(C))return B(C!==null),e.consume(C),s=String.fromCharCode(C),b;return r(C)}function p(C){if(C===w.dash)return e.consume(C),n=be.htmlComment,m;if(C===w.leftSquareBracket)return e.consume(C),n=be.htmlCdata,a=0,y;if(sn(C))return e.consume(C),n=be.htmlDeclaration,i.interrupt?t:_;return r(C)}function m(C){if(C===w.dash)return e.consume(C),i.interrupt?t:_;return r(C)}function y(C){let Se=be.cdataOpeningString;if(C===Se.charCodeAt(a++)){if(e.consume(C),a===Se.length)return i.interrupt?t:P;return y}return r(C)}function g(C){if(sn(C))return B(C!==null),e.consume(C),s=String.fromCharCode(C),b;return r(C)}function b(C){if(C===w.eof||C===w.slash||C===w.greaterThan||$t(C)){let Se=C===w.slash,Ee=s.toLowerCase();if(!Se&&!o&&j1.includes(Ee))return n=be.htmlRaw,i.interrupt?t(C):P(C);if(c6.includes(s.toLowerCase())){if(n=be.htmlBasic,Se)return e.consume(C),v;return i.interrupt?t(C):P(C)}return n=be.htmlComplete,i.interrupt&&!i.parser.lazy[i.now().line]?r(C):o?A(C):T(C)}if(C===w.dash||Dr(C))return e.consume(C),s+=String.fromCharCode(C),b;return r(C)}function v(C){if(C===w.greaterThan)return e.consume(C),i.interrupt?t:P;return r(C)}function A(C){if(Me(C))return e.consume(C),A;return X(C)}function T(C){if(C===w.slash)return e.consume(C),X;if(C===w.colon||C===w.underscore||sn(C))return e.consume(C),z;if(Me(C))return e.consume(C),T;return X(C)}function z(C){if(C===w.dash||C===w.dot||C===w.colon||C===w.underscore||Dr(C))return e.consume(C),z;return j(C)}function j(C){if(C===w.equalsTo)return e.consume(C),E;if(Me(C))return e.consume(C),j;return T(C)}function E(C){if(C===w.eof||C===w.lessThan||C===w.equalsTo||C===w.greaterThan||C===w.graveAccent)return r(C);if(C===w.quotationMark||C===w.apostrophe)return e.consume(C),c=C,Z;if(Me(C))return e.consume(C),E;return D(C)}function Z(C){if(C===c)return e.consume(C),c=null,H;if(C===w.eof||ve(C))return r(C);return e.consume(C),Z}function D(C){if(C===w.eof||C===w.quotationMark||C===w.apostrophe||C===w.slash||C===w.lessThan||C===w.equalsTo||C===w.greaterThan||C===w.graveAccent||$t(C))return j(C);return e.consume(C),D}function H(C){if(C===w.slash||C===w.greaterThan||Me(C))return T(C);return r(C)}function X(C){if(C===w.greaterThan)return e.consume(C),M;return r(C)}function M(C){if(C===w.eof||ve(C))return P(C);if(Me(C))return e.consume(C),M;return r(C)}function P(C){if(C===w.dash&&n===be.htmlComment)return e.consume(C),O;if(C===w.lessThan&&n===be.htmlRaw)return e.consume(C),F;if(C===w.greaterThan&&n===be.htmlDeclaration)return e.consume(C),te;if(C===w.questionMark&&n===be.htmlInstruction)return e.consume(C),_;if(C===w.rightSquareBracket&&n===be.htmlCdata)return e.consume(C),V;if(ve(C)&&(n===be.htmlBasic||n===be.htmlComplete))return e.exit(S.htmlFlowData),e.check(doe,ue,N)(C);if(C===w.eof||ve(C))return e.exit(S.htmlFlowData),N(C);return e.consume(C),P}function N(C){return e.check(foe,I,ue)(C)}function I(C){return B(ve(C)),e.enter(S.lineEnding),e.consume(C),e.exit(S.lineEnding),R}function R(C){if(C===w.eof||ve(C))return N(C);return e.enter(S.htmlFlowData),P(C)}function O(C){if(C===w.dash)return e.consume(C),_;return P(C)}function F(C){if(C===w.slash)return e.consume(C),s="",L;return P(C)}function L(C){if(C===w.greaterThan){let Se=s.toLowerCase();if(j1.includes(Se))return e.consume(C),te;return P(C)}if(sn(C)&&s.length<be.htmlRawSizeMax)return B(C!==null),e.consume(C),s+=String.fromCharCode(C),L;return P(C)}function V(C){if(C===w.rightSquareBracket)return e.consume(C),_;return P(C)}function _(C){if(C===w.greaterThan)return e.consume(C),te;if(C===w.dash&&n===be.htmlComment)return e.consume(C),_;return P(C)}function te(C){if(C===w.eof||ve(C))return e.exit(S.htmlFlowData),ue(C);return e.consume(C),te}function ue(C){return e.exit(S.htmlFlow),t(C)}}function hoe(e,t,r){let i=this;return n;function n(s){if(ve(s))return e.enter(S.lineEnding),e.consume(s),e.exit(S.lineEnding),o;return r(s)}function o(s){return i.parser.lazy[i.now().line]?r(s):t(s)}}function goe(e,t,r){return i;function i(n){return B(ve(n),"expected a line ending"),e.enter(S.lineEnding),e.consume(n),e.exit(S.lineEnding),e.attempt(Do,t,r)}}var q1,doe,foe;var u6=x(()=>{tt();ot();l6();Fe();hg();q1={concrete:!0,name:"htmlFlow",resolveTo:poe,tokenize:moe},doe={partial:!0,tokenize:goe},foe={partial:!0,tokenize:hoe}});function yoe(e,t,r){let i=this,n,o,s;return a;function a(_){return B(_===w.lessThan,"expected `<`"),e.enter(S.htmlText),e.enter(S.htmlTextData),e.consume(_),c}function c(_){if(_===w.exclamationMark)return e.consume(_),l;if(_===w.slash)return e.consume(_),j;if(_===w.questionMark)return e.consume(_),T;if(sn(_))return e.consume(_),D;return r(_)}function l(_){if(_===w.dash)return e.consume(_),u;if(_===w.leftSquareBracket)return e.consume(_),o=0,y;if(sn(_))return e.consume(_),A;return r(_)}function u(_){if(_===w.dash)return e.consume(_),m;return r(_)}function d(_){if(_===w.eof)return r(_);if(_===w.dash)return e.consume(_),p;if(ve(_))return s=d,F(_);return e.consume(_),d}function p(_){if(_===w.dash)return e.consume(_),m;return d(_)}function m(_){return _===w.greaterThan?O(_):_===w.dash?p(_):d(_)}function y(_){let te=be.cdataOpeningString;if(_===te.charCodeAt(o++))return e.consume(_),o===te.length?g:y;return r(_)}function g(_){if(_===w.eof)return r(_);if(_===w.rightSquareBracket)return e.consume(_),b;if(ve(_))return s=g,F(_);return e.consume(_),g}function b(_){if(_===w.rightSquareBracket)return e.consume(_),v;return g(_)}function v(_){if(_===w.greaterThan)return O(_);if(_===w.rightSquareBracket)return e.consume(_),v;return g(_)}function A(_){if(_===w.eof||_===w.greaterThan)return O(_);if(ve(_))return s=A,F(_);return e.consume(_),A}function T(_){if(_===w.eof)return r(_);if(_===w.questionMark)return e.consume(_),z;if(ve(_))return s=T,F(_);return e.consume(_),T}function z(_){return _===w.greaterThan?O(_):T(_)}function j(_){if(sn(_))return e.consume(_),E;return r(_)}function E(_){if(_===w.dash||Dr(_))return e.consume(_),E;return Z(_)}function Z(_){if(ve(_))return s=Z,F(_);if(Me(_))return e.consume(_),Z;return O(_)}function D(_){if(_===w.dash||Dr(_))return e.consume(_),D;if(_===w.slash||_===w.greaterThan||$t(_))return H(_);return r(_)}function H(_){if(_===w.slash)return e.consume(_),O;if(_===w.colon||_===w.underscore||sn(_))return e.consume(_),X;if(ve(_))return s=H,F(_);if(Me(_))return e.consume(_),H;return O(_)}function X(_){if(_===w.dash||_===w.dot||_===w.colon||_===w.underscore||Dr(_))return e.consume(_),X;return M(_)}function M(_){if(_===w.equalsTo)return e.consume(_),P;if(ve(_))return s=M,F(_);if(Me(_))return e.consume(_),M;return H(_)}function P(_){if(_===w.eof||_===w.lessThan||_===w.equalsTo||_===w.greaterThan||_===w.graveAccent)return r(_);if(_===w.quotationMark||_===w.apostrophe)return e.consume(_),n=_,N;if(ve(_))return s=P,F(_);if(Me(_))return e.consume(_),P;return e.consume(_),I}function N(_){if(_===n)return e.consume(_),n=void 0,R;if(_===w.eof)return r(_);if(ve(_))return s=N,F(_);return e.consume(_),N}function I(_){if(_===w.eof||_===w.quotationMark||_===w.apostrophe||_===w.lessThan||_===w.equalsTo||_===w.graveAccent)return r(_);if(_===w.slash||_===w.greaterThan||$t(_))return H(_);return e.consume(_),I}function R(_){if(_===w.slash||_===w.greaterThan||$t(_))return H(_);return r(_)}function O(_){if(_===w.greaterThan)return e.consume(_),e.exit(S.htmlTextData),e.exit(S.htmlText),t;return r(_)}function F(_){return B(s,"expected return state"),B(ve(_),"expected eol"),e.exit(S.htmlTextData),e.enter(S.lineEnding),e.consume(_),e.exit(S.lineEnding),L}function L(_){return B(i.parser.constructs.disable.null,"expected `disable.null` to be populated"),Me(_)?Ze(e,V,S.linePrefix,i.parser.constructs.disable.null.includes("codeIndented")?void 0:be.tabSize)(_):V(_)}function V(_){return e.enter(S.htmlTextData),s(_)}}var U1;var d6=x(()=>{tt();Gt();ot();Fe();U1={name:"htmlText",tokenize:yoe}});function woe(e){let t=-1,r=[];while(++t<e.length){let i=e[t][1];if(r.push(e[t]),i.type===S.labelImage||i.type===S.labelLink||i.type===S.labelEnd){let n=i.type===S.labelImage?4:2;i.type=S.data,t+=n}}if(e.length!==r.length)nr(e,0,e.length,r);return e}function voe(e,t){let r=e.length,i=0,n,o,s,a;while(r--)if(n=e[r][1],o){if(n.type===S.link||n.type===S.labelLink&&n._inactive)break;if(e[r][0]==="enter"&&n.type===S.labelLink)n._inactive=!0}else if(s){if(e[r][0]==="enter"&&(n.type===S.labelImage||n.type===S.labelLink)&&!n._balanced){if(o=r,n.type!==S.labelLink){i=2;break}}}else if(n.type===S.labelEnd)s=r;B(o!==void 0,"`open` is supposed to be found"),B(s!==void 0,"`close` is supposed to be found");let c={type:e[o][1].type===S.labelLink?S.link:S.image,start:{...e[o][1].start},end:{...e[e.length-1][1].end}},l={type:S.label,start:{...e[o][1].start},end:{...e[s][1].end}},u={type:S.labelText,start:{...e[o+i+2][1].end},end:{...e[s-2][1].start}};return a=[["enter",c,t],["enter",l,t]],a=Nr(a,e.slice(o+1,o+i+3)),a=Nr(a,[["enter",u,t]]),B(t.parser.constructs.insideSpan.null,"expected `insideSpan.null` to be populated"),a=Nr(a,Qc(t.parser.constructs.insideSpan.null,e.slice(o+i+4,s-3),t)),a=Nr(a,[["exit",u,t],e[s-2],e[s-1],["exit",l,t]]),a=Nr(a,e.slice(s+1)),a=Nr(a,[["exit",c,t]]),nr(e,o,e.length,a),e}function _oe(e,t,r){let i=this,n=i.events.length,o,s;while(n--)if((i.events[n][1].type===S.labelImage||i.events[n][1].type===S.labelLink)&&!i.events[n][1]._balanced){o=i.events[n][1];break}return a;function a(p){if(B(p===w.rightSquareBracket,"expected `]`"),!o)return r(p);if(o._inactive)return d(p);return s=i.parser.defined.includes(Ni(i.sliceSerialize({start:o.end,end:i.now()}))),e.enter(S.labelEnd),e.enter(S.labelMarker),e.consume(p),e.exit(S.labelMarker),e.exit(S.labelEnd),c}function c(p){if(p===w.leftParenthesis)return e.attempt(boe,u,s?u:d)(p);if(p===w.leftSquareBracket)return e.attempt(xoe,u,s?l:d)(p);return s?u(p):d(p)}function l(p){return e.attempt(Soe,u,d)(p)}function u(p){return t(p)}function d(p){return o._balanced=!0,r(p)}}function koe(e,t,r){return i;function i(d){return B(d===w.leftParenthesis,"expected left paren"),e.enter(S.resource),e.enter(S.resourceMarker),e.consume(d),e.exit(S.resourceMarker),n}function n(d){return $t(d)?Xs(e,o)(d):o(d)}function o(d){if(d===w.rightParenthesis)return u(d);return wg(e,s,a,S.resourceDestination,S.resourceDestinationLiteral,S.resourceDestinationLiteralMarker,S.resourceDestinationRaw,S.resourceDestinationString,be.linkResourceDestinationBalanceMax)(d)}function s(d){return $t(d)?Xs(e,c)(d):u(d)}function a(d){return r(d)}function c(d){if(d===w.quotationMark||d===w.apostrophe||d===w.leftParenthesis)return _g(e,l,r,S.resourceTitle,S.resourceTitleMarker,S.resourceTitleString)(d);return u(d)}function l(d){return $t(d)?Xs(e,u)(d):u(d)}function u(d){if(d===w.rightParenthesis)return e.enter(S.resourceMarker),e.consume(d),e.exit(S.resourceMarker),e.exit(S.resource),t;return r(d)}}function Eoe(e,t,r){let i=this;return n;function n(a){return B(a===w.leftSquareBracket,"expected left bracket"),vg.call(i,e,o,s,S.reference,S.referenceMarker,S.referenceString)(a)}function o(a){return i.parser.defined.includes(Ni(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)))?t(a):r(a)}function s(a){return r(a)}}function Ioe(e,t,r){return i;function i(o){return B(o===w.leftSquareBracket,"expected left bracket"),e.enter(S.reference),e.enter(S.referenceMarker),e.consume(o),e.exit(S.referenceMarker),n}function n(o){if(o===w.rightSquareBracket)return e.enter(S.referenceMarker),e.consume(o),e.exit(S.referenceMarker),e.exit(S.reference),t;return r(o)}}var ea,boe,xoe,Soe;var kg=x(()=>{tt();R1();P1();z1();N1();ot();zo();mg();Fe();ea={name:"labelEnd",resolveAll:woe,resolveTo:voe,tokenize:_oe},boe={tokenize:koe},xoe={tokenize:Eoe},Soe={tokenize:Ioe}});function Aoe(e,t,r){let i=this;return n;function n(a){return B(a===w.exclamationMark,"expected `!`"),e.enter(S.labelImage),e.enter(S.labelImageMarker),e.consume(a),e.exit(S.labelImageMarker),o}function o(a){if(a===w.leftSquareBracket)return e.enter(S.labelMarker),e.consume(a),e.exit(S.labelMarker),e.exit(S.labelImage),s;return r(a)}function s(a){return a===w.caret&&"_hiddenFootnoteSupport"in i.parser.constructs?r(a):t(a)}}var M1;var f6=x(()=>{tt();Fe();kg();M1={name:"labelStartImage",resolveAll:ea.resolveAll,tokenize:Aoe}});function Toe(e,t,r){let i=this;return n;function n(s){return B(s===w.leftSquareBracket,"expected `[`"),e.enter(S.labelLink),e.enter(S.labelMarker),e.consume(s),e.exit(S.labelMarker),e.exit(S.labelLink),o}function o(s){return s===w.caret&&"_hiddenFootnoteSupport"in i.parser.constructs?r(s):t(s)}}var F1;var p6=x(()=>{tt();Fe();kg();F1={name:"labelStartLink",resolveAll:ea.resolveAll,tokenize:Toe}});function Coe(e,t){return r;function r(i){return B(ve(i),"expected eol"),e.enter(S.lineEnding),e.consume(i),e.exit(S.lineEnding),Ze(e,t,S.linePrefix)}}var qd;var m6=x(()=>{tt();Gt();ot();Fe();qd={name:"lineEnding",tokenize:Coe}});function $oe(e,t,r){let i=0,n;return o;function o(l){return e.enter(S.thematicBreak),s(l)}function s(l){return B(l===w.asterisk||l===w.dash||l===w.underscore,"expected `*`, `-`, or `_`"),n=l,a(l)}function a(l){if(l===n)return e.enter(S.thematicBreakSequence),c(l);if(i>=be.thematicBreakMarkerCountMin&&(l===w.eof||ve(l)))return e.exit(S.thematicBreak),t(l);return r(l)}function c(l){if(l===n)return e.consume(l),i++,c;return e.exit(S.thematicBreakSequence),Me(l)?Ze(e,a,S.whitespace)(l):a(l)}}var ta;var Z1=x(()=>{tt();Gt();ot();Fe();ta={name:"thematicBreak",tokenize:$oe}});function Poe(e,t,r){let i=this,n=i.events[i.events.length-1],o=n&&n[1].type===S.linePrefix?n[2].sliceSerialize(n[1],!0).length:0,s=0;return a;function a(m){B(i.containerState,"expected state");let y=i.containerState.type||(m===w.asterisk||m===w.plusSign||m===w.dash?S.listUnordered:S.listOrdered);if(y===S.listUnordered?!i.containerState.marker||m===i.containerState.marker:Dd(m)){if(!i.containerState.type)i.containerState.type=y,e.enter(y,{_container:!0});if(y===S.listUnordered)return e.enter(S.listItemPrefix),m===w.asterisk||m===w.dash?e.check(ta,r,l)(m):l(m);if(!i.interrupt||m===w.digit1)return e.enter(S.listItemPrefix),e.enter(S.listItemValue),c(m)}return r(m)}function c(m){if(B(i.containerState,"expected state"),Dd(m)&&++s<be.listItemValueSizeMax)return e.consume(m),c;if((!i.interrupt||s<2)&&(i.containerState.marker?m===i.containerState.marker:m===w.rightParenthesis||m===w.dot))return e.exit(S.listItemValue),l(m);return r(m)}function l(m){return B(i.containerState,"expected state"),B(m!==w.eof,"eof (`null`) is not a marker"),e.enter(S.listItemMarker),e.consume(m),e.exit(S.listItemMarker),i.containerState.marker=i.containerState.marker||m,e.check(Do,i.interrupt?r:u,e.attempt(Ooe,p,d))}function u(m){return B(i.containerState,"expected state"),i.containerState.initialBlankLine=!0,o++,p(m)}function d(m){if(Me(m))return e.enter(S.listItemPrefixWhitespace),e.consume(m),e.exit(S.listItemPrefixWhitespace),p;return r(m)}function p(m){return B(i.containerState,"expected state"),i.containerState.size=o+i.sliceSerialize(e.exit(S.listItemPrefix),!0).length,t(m)}}function zoe(e,t,r){let i=this;return B(i.containerState,"expected state"),i.containerState._closeFlow=void 0,e.check(Do,n,o);function n(a){return B(i.containerState,"expected state"),B(typeof i.containerState.size==="number","expected size"),i.containerState.furtherBlankLines=i.containerState.furtherBlankLines||i.containerState.initialBlankLine,Ze(e,t,S.listItemIndent,i.containerState.size+1)(a)}function o(a){if(B(i.containerState,"expected state"),i.containerState.furtherBlankLines||!Me(a))return i.containerState.furtherBlankLines=void 0,i.containerState.initialBlankLine=void 0,s(a);return i.containerState.furtherBlankLines=void 0,i.containerState.initialBlankLine=void 0,e.attempt(Roe,t,s)(a)}function s(a){return B(i.containerState,"expected state"),i.containerState._closeFlow=!0,i.interrupt=void 0,B(i.parser.constructs.disable.null,"expected `disable.null` to be populated"),Ze(e,e.attempt(Sr,t,r),S.linePrefix,i.parser.constructs.disable.null.includes("codeIndented")?void 0:be.tabSize)(a)}}function Noe(e,t,r){let i=this;return B(i.containerState,"expected state"),B(typeof i.containerState.size==="number","expected size"),Ze(e,n,S.listItemIndent,i.containerState.size+1);function n(o){B(i.containerState,"expected state");let s=i.events[i.events.length-1];return s&&s[1].type===S.listItemIndent&&s[2].sliceSerialize(s[1],!0).length===i.containerState.size?t(o):r(o)}}function Doe(e){B(this.containerState,"expected state"),B(typeof this.containerState.type==="string","expected type"),e.exit(this.containerState.type)}function Loe(e,t,r){let i=this;return B(i.parser.constructs.disable.null,"expected `disable.null` to be populated"),Ze(e,n,S.listItemPrefixWhitespace,i.parser.constructs.disable.null.includes("codeIndented")?void 0:be.tabSize+1);function n(o){let s=i.events[i.events.length-1];return!Me(o)&&s&&s[1].type===S.listItemPrefixWhitespace?t(o):r(o)}}var Sr,Ooe,Roe;var h6=x(()=>{tt();Gt();ot();Fe();hg();Z1();Sr={continuation:{tokenize:zoe},exit:Doe,name:"list",tokenize:Poe},Ooe={partial:!0,tokenize:Loe},Roe={partial:!0,tokenize:Noe}});function Boe(e,t){let r=e.length,i,n,o;while(r--)if(e[r][0]==="enter"){if(e[r][1].type===S.content){i=r;break}if(e[r][1].type===S.paragraph)n=r}else{if(e[r][1].type===S.content)e.splice(r,1);if(!o&&e[r][1].type===S.definition)o=r}B(n!==void 0,"expected a `text` index to be found"),B(i!==void 0,"expected a `text` index to be found"),B(e[i][2]===t,"enter context should be same"),B(e[e.length-1][2]===t,"enter context should be same");let s={type:S.setextHeading,start:{...e[i][1].start},end:{...e[e.length-1][1].end}};if(e[n][1].type=S.setextHeadingText,o)e.splice(n,0,["enter",s,t]),e.splice(o+1,0,["exit",e[i][1],t]),e[i][1].end={...e[o][1].end};else e[i][1]=s;return e.push(["exit",s,t]),e}function joe(e,t,r){let i=this,n;return o;function o(l){let u=i.events.length,d;B(l===w.dash||l===w.equalsTo,"expected `=` or `-`");while(u--)if(i.events[u][1].type!==S.lineEnding&&i.events[u][1].type!==S.linePrefix&&i.events[u][1].type!==S.content){d=i.events[u][1].type===S.paragraph;break}if(!i.parser.lazy[i.now().line]&&(i.interrupt||d))return e.enter(S.setextHeadingLine),n=l,s(l);return r(l)}function s(l){return e.enter(S.setextHeadingLineSequence),a(l)}function a(l){if(l===n)return e.consume(l),a;return e.exit(S.setextHeadingLineSequence),Me(l)?Ze(e,c,S.lineSuffix)(l):c(l)}function c(l){if(l===w.eof||ve(l))return e.exit(S.setextHeadingLine),t(l);return r(l)}}var Eg;var g6=x(()=>{tt();Gt();ot();Fe();Eg={name:"setextUnderline",resolveTo:Boe,tokenize:joe}});var H1=x(()=>{Jj();Vj();hg();Wj();Gj();Qj();Xj();e6();r6();i6();o6();s6();a6();u6();d6();kg();f6();p6();m6();h6();g6();Z1()});function qoe(e){let t=this,r=e.attempt(Do,i,e.attempt(this.parser.constructs.flowInitial,n,Ze(e,e.attempt(this.parser.constructs.flow,n,e.attempt(O1,n)),S.linePrefix)));return r;function i(o){if(B(o===w.eof||ve(o),"expected eol or eof"),o===w.eof){e.consume(o);return}return e.enter(S.lineEndingBlank),e.consume(o),e.exit(S.lineEndingBlank),t.currentConstruct=void 0,r}function n(o){if(B(o===w.eof||ve(o),"expected eol or eof"),o===w.eof){e.consume(o);return}return e.enter(S.lineEnding),e.consume(o),e.exit(S.lineEnding),t.currentConstruct=void 0,r}}var y6;var b6=x(()=>{tt();H1();Gt();ot();Fe();y6={tokenize:qoe}});function v6(e){return{resolveAll:_6(e==="text"?Uoe:void 0),tokenize:t};function t(r){let i=this,n=this.parser.constructs[e],o=r.attempt(n,s,a);return s;function s(u){return l(u)?o(u):a(u)}function a(u){if(u===w.eof){r.consume(u);return}return r.enter(S.data),r.consume(u),c}function c(u){if(l(u))return r.exit(S.data),o(u);return r.consume(u),c}function l(u){if(u===w.eof)return!0;let d=n[u],p=-1;if(d){B(Array.isArray(d),"expected `disable.null` to be populated");while(++p<d.length){let m=d[p];if(!m.previous||m.previous.call(i,i.previous))return!0}}return!1}}}function _6(e){return t;function t(r,i){let n=-1,o;while(++n<=r.length)if(o===void 0){if(r[n]&&r[n][1].type===S.data)o=n,n++}else if(!r[n]||r[n][1].type!==S.data){if(n!==o+2)r[o][1].end=r[n-1][1].end,r.splice(o+2,n-o-2),n=o+2;o=void 0}return e?e(r,i):r}}function Uoe(e,t){let r=0;while(++r<=e.length)if((r===e.length||e[r][1].type===S.lineEnding)&&e[r-1][1].type===S.data){let i=e[r-1][1],n=t.sliceStream(i),o=n.length,s=-1,a=0,c;while(o--){let l=n[o];if(typeof l==="string"){s=l.length;while(l.charCodeAt(s-1)===w.space)a++,s--;if(s)break;s=-1}else if(l===w.horizontalTab)c=!0,a++;else if(l===w.virtualSpace);else{o++;break}}if(t._contentTypeTextTrailing&&r===e.length)a=0;if(a){let l={type:r===e.length||c||a<be.hardBreakPrefixSizeMin?S.lineSuffix:S.hardBreakTrailing,start:{_bufferIndex:o?s:i.start._bufferIndex+s,_index:i.start._index+o,line:i.end.line,column:i.end.column-a,offset:i.end.offset-a},end:{...i.end}};if(i.end={...l.start},i.start.offset===i.end.offset)Object.assign(i,l);else e.splice(r,0,["enter",l,t],["exit",l,t]),r+=2}r++}return e}var x6,S6,w6;var K1=x(()=>{tt();Fe();x6={resolveAll:_6()},S6=v6("string"),w6=v6("text")});var J1={};tr(J1,{attentionMarkers:()=>Woe,contentInitial:()=>Foe,disable:()=>Goe,document:()=>Moe,flow:()=>Hoe,flowInitial:()=>Zoe,insideSpan:()=>Voe,string:()=>Koe,text:()=>Joe});var Moe,Foe,Zoe,Hoe,Koe,Joe,Voe,Woe,Goe;var k6=x(()=>{H1();Fe();K1();Moe={[w.asterisk]:Sr,[w.plusSign]:Sr,[w.dash]:Sr,[w.digit0]:Sr,[w.digit1]:Sr,[w.digit2]:Sr,[w.digit3]:Sr,[w.digit4]:Sr,[w.digit5]:Sr,[w.digit6]:Sr,[w.digit7]:Sr,[w.digit8]:Sr,[w.digit9]:Sr,[w.greaterThan]:gg},Foe={[w.leftSquareBracket]:D1},Zoe={[w.horizontalTab]:Bd,[w.virtualSpace]:Bd,[w.space]:Bd},Hoe={[w.numberSign]:B1,[w.asterisk]:ta,[w.dash]:[Eg,ta],[w.lessThan]:q1,[w.equalsTo]:Eg,[w.underscore]:ta,[w.graveAccent]:xg,[w.tilde]:xg},Koe={[w.ampersand]:bg,[w.backslash]:yg},Joe={[w.carriageReturn]:qd,[w.lineFeed]:qd,[w.carriageReturnLineFeed]:qd,[w.exclamationMark]:M1,[w.ampersand]:bg,[w.asterisk]:Ld,[w.lessThan]:[A1,U1],[w.leftSquareBracket]:F1,[w.backslash]:[L1,yg],[w.rightSquareBracket]:ea,[w.underscore]:Ld,[w.graveAccent]:T1},Voe={null:[Ld,x6]},Woe={null:[w.asterisk,w.underscore]},Goe={null:[]}});var I6=ee(function(hDe,E6){var Yc=1000,Xc=Yc*60,el=Xc*60,ra=el*24,Qoe=ra*7,Yoe=ra*365.25;E6.exports=function(e,t){t=t||{};var r=typeof e;if(r==="string"&&e.length>0)return Xoe(e);else if(r==="number"&&isFinite(e))return t.long?tse(e):ese(e);throw Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function Xoe(e){if(e=String(e),e.length>100)return;var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!t)return;var r=parseFloat(t[1]),i=(t[2]||"ms").toLowerCase();switch(i){case"years":case"year":case"yrs":case"yr":case"y":return r*Yoe;case"weeks":case"week":case"w":return r*Qoe;case"days":case"day":case"d":return r*ra;case"hours":case"hour":case"hrs":case"hr":case"h":return r*el;case"minutes":case"minute":case"mins":case"min":case"m":return r*Xc;case"seconds":case"second":case"secs":case"sec":case"s":return r*Yc;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}function ese(e){var t=Math.abs(e);if(t>=ra)return Math.round(e/ra)+"d";if(t>=el)return Math.round(e/el)+"h";if(t>=Xc)return Math.round(e/Xc)+"m";if(t>=Yc)return Math.round(e/Yc)+"s";return e+"ms"}function tse(e){var t=Math.abs(e);if(t>=ra)return Ig(e,t,ra,"day");if(t>=el)return Ig(e,t,el,"hour");if(t>=Xc)return Ig(e,t,Xc,"minute");if(t>=Yc)return Ig(e,t,Yc,"second");return e+" ms"}function Ig(e,t,r,i){var n=t>=r*1.5;return Math.round(e/r)+" "+i+(n?"s":"")}});var V1=ee(function(gDe,A6){function rse(e){r.debug=r,r.default=r,r.coerce=c,r.disable=s,r.enable=n,r.enabled=a,r.humanize=I6(),r.destroy=l,Object.keys(e).forEach((u)=>{r[u]=e[u]}),r.names=[],r.skips=[],r.formatters={};function t(u){let d=0;for(let p=0;p<u.length;p++)d=(d<<5)-d+u.charCodeAt(p),d|=0;return r.colors[Math.abs(d)%r.colors.length]}r.selectColor=t;function r(u){let d,p=null,m,y;function g(...b){if(!g.enabled)return;let v=g,A=Number(new Date),T=A-(d||A);if(v.diff=T,v.prev=d,v.curr=A,d=A,b[0]=r.coerce(b[0]),typeof b[0]!=="string")b.unshift("%O");let z=0;b[0]=b[0].replace(/%([a-zA-Z%])/g,(E,Z)=>{if(E==="%%")return"%";z++;let D=r.formatters[Z];if(typeof D==="function"){let H=b[z];E=D.call(v,H),b.splice(z,1),z--}return E}),r.formatArgs.call(v,b),(v.log||r.log).apply(v,b)}if(g.namespace=u,g.useColors=r.useColors(),g.color=r.selectColor(u),g.extend=i,g.destroy=r.destroy,Object.defineProperty(g,"enabled",{enumerable:!0,configurable:!1,get:()=>{if(p!==null)return p;if(m!==r.namespaces)m=r.namespaces,y=r.enabled(u);return y},set:(b)=>{p=b}}),typeof r.init==="function")r.init(g);return g}function i(u,d){let p=r(this.namespace+(typeof d>"u"?":":d)+u);return p.log=this.log,p}function n(u){r.save(u),r.namespaces=u,r.names=[],r.skips=[];let d=(typeof u==="string"?u:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(let p of d)if(p[0]==="-")r.skips.push(p.slice(1));else r.names.push(p)}function o(u,d){let p=0,m=0,y=-1,g=0;while(p<u.length)if(m<d.length&&(d[m]===u[p]||d[m]==="*"))if(d[m]==="*")y=m,g=p,m++;else p++,m++;else if(y!==-1)m=y+1,g++,p=g;else return!1;while(m<d.length&&d[m]==="*")m++;return m===d.length}function s(){let u=[...r.names,...r.skips.map((d)=>"-"+d)].join(",");return r.enable(""),u}function a(u){for(let d of r.skips)if(o(u,d))return!1;for(let d of r.names)if(o(u,d))return!0;return!1}function c(u){if(u instanceof Error)return u.stack||u.message;return u}function l(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return r.enable(r.load()),r}A6.exports=rse});var C6=ee(function(T6,Ag){T6.formatArgs=ise;T6.save=ose;T6.load=sse;T6.useColors=nse;T6.storage=ase();T6.destroy=(()=>{let e=!1;return()=>{if(!e)e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}})();T6.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function nse(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let e;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function ise(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+Ag.exports.humanize(this.diff),!this.useColors)return;let t="color: "+this.color;e.splice(1,0,t,"color: inherit");let r=0,i=0;e[0].replace(/%[a-zA-Z%]/g,(n)=>{if(n==="%%")return;if(r++,n==="%c")i=r}),e.splice(i,0,t)}T6.log=console.debug||console.log||(()=>{});function ose(e){try{if(e)T6.storage.setItem("debug",e);else T6.storage.removeItem("debug")}catch(t){}}function sse(){let e;try{e=T6.storage.getItem("debug")||T6.storage.getItem("DEBUG")}catch(t){}if(!e&&typeof process<"u"&&"env"in process)e=process.env.DEBUG;return e}function ase(){try{return localStorage}catch(e){}}Ag.exports=V1()(T6);var{formatters:cse}=Ag.exports;cse.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}});var O6=ee(function(bDe,$6){$6.exports=(e,t=process.argv)=>{let r=e.startsWith("-")?"":e.length===1?"-":"--",i=t.indexOf(r+e),n=t.indexOf("--");return i!==-1&&(n===-1||i<n)}});var z6=ee(function(xDe,P6){var gse=Tt("os"),R6=Tt("tty"),bn=O6(),{env:Qt}=process,Lo;if(bn("no-color")||bn("no-colors")||bn("color=false")||bn("color=never"))Lo=0;else if(bn("color")||bn("colors")||bn("color=true")||bn("color=always"))Lo=1;if("FORCE_COLOR"in Qt)if(Qt.FORCE_COLOR==="true")Lo=1;else if(Qt.FORCE_COLOR==="false")Lo=0;else Lo=Qt.FORCE_COLOR.length===0?1:Math.min(parseInt(Qt.FORCE_COLOR,10),3);function W1(e){if(e===0)return!1;return{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function G1(e,t){if(Lo===0)return 0;if(bn("color=16m")||bn("color=full")||bn("color=truecolor"))return 3;if(bn("color=256"))return 2;if(e&&!t&&Lo===void 0)return 0;let r=Lo||0;if(Qt.TERM==="dumb")return r;if(process.platform==="win32"){let i=gse.release().split(".");if(Number(i[0])>=10&&Number(i[2])>=10586)return Number(i[2])>=14931?3:2;return 1}if("CI"in Qt){if(["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some((i)=>(i in Qt))||Qt.CI_NAME==="codeship")return 1;return r}if("TEAMCITY_VERSION"in Qt)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(Qt.TEAMCITY_VERSION)?1:0;if(Qt.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in Qt){let i=parseInt((Qt.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(Qt.TERM_PROGRAM){case"iTerm.app":return i>=3?3:2;case"Apple_Terminal":return 2}}if(/-256(color)?$/i.test(Qt.TERM))return 2;if(/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(Qt.TERM))return 1;if("COLORTERM"in Qt)return 1;return r}function yse(e){let t=G1(e,e&&e.isTTY);return W1(t)}P6.exports={supportsColor:yse,stdout:W1(G1(!0,R6.isatty(1))),stderr:W1(G1(!0,R6.isatty(2)))}});var B6=ee(function(D6,Cg){var bse=Tt("tty"),Tg=Tt("util");D6.init=Ese;D6.log=vse;D6.formatArgs=Sse;D6.save=_se;D6.load=kse;D6.useColors=xse;D6.destroy=Tg.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");D6.colors=[6,2,3,4,5,1];try{let e=z6();if(e&&(e.stderr||e).level>=2)D6.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221]}catch(e){}D6.inspectOpts=Object.keys(process.env).filter((e)=>/^debug_/i.test(e)).reduce((e,t)=>{let r=t.substring(6).toLowerCase().replace(/_([a-z])/g,(n,o)=>o.toUpperCase()),i=process.env[t];if(/^(yes|on|true|enabled)$/i.test(i))i=!0;else if(/^(no|off|false|disabled)$/i.test(i))i=!1;else if(i==="null")i=null;else i=Number(i);return e[r]=i,e},{});function xse(){return"colors"in D6.inspectOpts?Boolean(D6.inspectOpts.colors):bse.isatty(process.stderr.fd)}function Sse(e){let{namespace:t,useColors:r}=this;if(r){let i=this.color,n="\x1B[3"+(i<8?i:"8;5;"+i),o=` ${n};1m${t} \x1B[0m`;e[0]=o+e[0].split(`
271
+ `)e.content=e.content.slice(1)}if(gB(e,r),r.sections===!0||typeof r.section==="function")Nne(e,r.section);return e}zr.engines=Lne;zr.stringify=function(e,t,r){if(typeof e==="string")e=zr(e,r);return Dne(e,t,r)};zr.read=function(e,t){let r=zne.readFileSync(e,"utf8"),i=zr(r,t);return i.path=e,i};zr.test=function(e,t){return yB.startsWith(e,g1(t).delimiters[0])};zr.language=function(e,t){let i=g1(t).delimiters[0];if(zr.test(e))e=e.slice(i.length);let n=e.slice(0,e.search(/\r?\n/));return{raw:n,name:n?n.trim():""}};zr.cache={};zr.clearCache=function(){zr.cache={}};bB.exports=zr});var Une;var ag=x(()=>{Une=rc(xB(),1)});var SB=x(()=>{ag();WE()});var Mne,cg,Fne,b1="data-ask-sheet",Zne;var x1=x(()=>{Re();Mne=f.object({public:f.boolean(),preview:f.boolean()}),cg=f.object({name:f.string().trim().min(1).max(200),url:f.string().url().optional()}),Fne=f.object({sources:f.array(f.object({id:f.string(),title:f.string(),brain:cg.optional()}))}),Zne=`body *:not([${b1}], [${b1}] *) { -webkit-backdrop-filter: none !important; backdrop-filter: none !important; }`});var wB,Hne;var vB=x(()=>{Re();wB=f.object({type:f.literal("event"),event:f.string().min(1),fromState:f.string().min(1).optional()}),Hne=f.object({conversationId:f.string().min(1),interfaceType:f.string().min(1),channelId:f.string().min(1).optional(),channelName:f.string().min(1),userPermissionLevel:f.enum(["admin","trusted","public"]),isAnchor:f.boolean(),action:wB})});var Kne,FCe,Jc,Jne,Vne,_B,ZCe,Wne,Gne,kB;var EB=x(()=>{Re();Kne=f.strictObject({messageCharacters:f.number().int().positive(),requestTimeoutSeconds:f.number().int().positive().max(2147483)}),FCe=f.strictObject({limits:Kne,maxCostMicroUsd:f.number().int().positive()}),Jc=f.number().int().nonnegative(),Jne=f.strictObject({modelCalls:Jc,inputTokens:Jc,cachedInputTokens:Jc,outputTokens:Jc,reasoningTokens:Jc,embeddingTokens:Jc}),Vne=f.discriminatedUnion("state",[f.strictObject({state:f.literal("known"),microUsd:f.number().int().nonnegative(),pricing:f.string().trim().min(1).max(120)}),f.strictObject({state:f.literal("unknown"),reason:f.enum(["missing-usage","unsupported-pricing"])})]),_B=f.strictObject({usage:Jne,cost:Vne}),ZCe=f.strictObject({topics:f.array(f.string().trim().min(1).max(500)).max(20),introduction:f.string().trim().min(1).max(4000).optional(),refusal:f.string().trim().min(1).max(500).optional()}),Wne=f.enum(["in-scope","off-topic","abusive","injection","harmful"]),Gne=Wne.exclude(["in-scope"]),kB=f.discriminatedUnion("outcome",[f.strictObject({outcome:f.literal("answered")}),f.strictObject({outcome:f.literal("refused"),category:Gne}),f.strictObject({outcome:f.literal("unscreened")})])});var IB,AB,TB,CB,$B,OB,lg,RB,PB,zB,NB,DB,LB,BB,jB,Qne;var S1=x(()=>{Re();x1();EB();IB=f.object({id:f.string(),toolCallId:f.string().optional(),toolName:f.string(),summary:f.string(),completionSummary:f.string().optional(),preview:f.string().optional(),args:f.unknown()}),AB=f.enum(["approval-requested","approval-responded","output-available","output-denied","output-error"]),TB=f.object({kind:f.literal("tool-approval"),id:f.string(),toolCallId:f.string().optional(),toolName:f.string(),input:f.record(f.string(),f.unknown()).optional(),summary:f.string(),completionSummary:f.string().optional(),preview:f.string().optional(),state:AB,output:f.unknown().optional(),error:f.string().optional()}),CB=f.object({entityType:f.string().optional(),entityId:f.string().optional(),attachmentType:f.string().optional()}),$B=f.object({mediaType:f.string().min(1),url:f.string().min(1),downloadUrl:f.string().min(1).optional(),previewUrl:f.string().min(1).optional(),filename:f.string().min(1).optional(),sizeBytes:f.number().nonnegative().optional(),source:CB.optional()}),OB=f.object({kind:f.literal("attachment"),id:f.string(),jobId:f.string().optional(),title:f.string(),description:f.string().optional(),attachment:$B}),lg=f.object({id:f.string().min(1),title:f.string().min(1).optional(),source:f.string().min(1),url:f.string().min(1).optional(),entityType:f.string().min(1).optional(),entityId:f.string().min(1).optional(),excerpt:f.string().min(1).optional(),provenance:f.record(f.string(),f.unknown()).optional(),brain:cg.optional()}),RB=f.object({kind:f.literal("sources"),id:f.string().min(1),title:f.string().min(1).optional(),sources:f.array(lg).min(1)}),PB=f.object({type:f.literal("prompt"),id:f.string().min(1),label:f.string().min(1),prompt:f.string().min(1),description:f.string().min(1).optional()}),zB=f.object({type:f.literal("event"),id:f.string().min(1),label:f.string().min(1),event:f.string().min(1),fromState:f.string().min(1).optional(),description:f.string().min(1).optional()}),NB=f.discriminatedUnion("type",[PB,zB]),DB=f.object({kind:f.literal("actions"),id:f.string().min(1),title:f.string().min(1).optional(),defaultOpen:f.boolean().optional(),actions:f.array(NB).min(1)}),LB=f.discriminatedUnion("kind",[TB,OB,RB,DB]),BB=f.object({toolName:f.string(),args:f.record(f.string(),f.unknown()).optional(),jobId:f.string().optional(),data:f.unknown().optional(),error:f.object({message:f.string(),code:f.string().optional()}).optional()}),jB=f.object({faqId:f.string().min(1)}),Qne=f.object({text:f.string(),error:f.string().optional(),toolResults:f.array(BB).optional(),cards:f.array(LB).optional(),pendingConfirmations:f.array(IB).optional(),usage:f.object({promptTokens:f.number(),completionTokens:f.number(),totalTokens:f.number()}),guestSettlement:_B.optional(),guestScreening:kB.optional(),askedBefore:jB.optional()})});var Yne,qB,Xne;var UB=x(()=>{Re();S1();Yne=f.object({question:f.string().trim().min(1)}),qB=f.object({faqId:f.string().min(1),answer:f.string().trim().min(1),sources:f.array(lg).default([])}),Xne=f.object({hit:qB.optional()})});var MB,eie,FB,tie;var ZB=x(()=>{Re();MB=f.enum(["admin","trusted","public"]),eie=f.object({conversationId:f.string().min(1),message:f.string(),interfaceType:f.string().min(1),channelId:f.string().optional(),channelName:f.string().optional(),userPermissionLevel:MB}),FB=f.object({id:f.string().min(1),source:f.string().min(1),title:f.string().optional(),content:f.string().min(1),provenance:f.record(f.string(),f.unknown()).optional()}),tie=f.object({items:f.array(FB).default([])})});var Vc;var w1=x(()=>{Re();Vc=f.discriminatedUnion("kind",[f.object({kind:f.literal("user"),userId:f.string().min(1),canonicalId:f.string().min(1).optional()}),f.object({kind:f.literal("external"),externalActorId:f.string().min(1)}),f.object({kind:f.literal("agent"),agentId:f.string().min(1)}),f.object({kind:f.literal("service"),serviceId:f.string().min(1)})])});var rie,HB,nie;var KB=x(()=>{Re();w1();rie=f.object({actor:Vc}),HB=f.object({userId:f.string().min(1),personId:f.string().min(1),canonicalId:f.string().min(1).optional(),displayName:f.string().min(1),permissionLevel:f.enum(["admin","trusted","public"])}),nie=f.object({principal:HB.nullable()})});var v1,iie,oie;var JB=x(()=>{Re();v1=f.strictObject({name:f.string().min(1).optional(),address:f.email()}),iie=f.strictObject({personId:f.string().min(1).max(200),displayName:f.string().trim().min(1).max(200),permissionLevel:f.enum(["admin","trusted","public"])}),oie=f.strictObject({messageId:f.string().min(1),sourceRef:f.string().min(1),threadId:f.string().min(1).optional(),from:v1,replyTo:v1.optional(),to:f.array(v1),subject:f.string(),receivedAt:f.iso.datetime(),text:f.string(),html:f.string().min(1).optional(),headers:f.strictObject({listUnsubscribe:f.string().min(1).optional(),autoSubmitted:f.string().min(1).optional(),precedence:f.string().min(1).optional(),inReplyTo:f.string().min(1).optional(),references:f.array(f.string().min(1)).optional()}),sender:iie.optional()})});var sie,aie,cie,_1,lie,uie;var VB=x(()=>{Re();sie=f.strictObject({permissionLevel:f.enum(["admin","trusted","public"])}),aie=f.custom((e)=>typeof AbortSignal<"u"&&e instanceof AbortSignal),cie=f.strictObject({sourceRef:f.string().regex(/^imap:[a-f0-9]{64}$/),actor:sie,signal:aie.optional()}),_1=f.strictObject({name:f.string().trim().min(1).max(300).optional(),address:f.email().max(320)}),lie=f.strictObject({messageId:f.string().trim().min(1).max(2000),from:_1,replyTo:_1.optional(),to:f.array(_1).max(100),subject:f.string().max(1000),receivedAt:f.iso.datetime(),text:f.string().max(1e5),inReplyTo:f.string().trim().min(1).max(2000).optional(),references:f.array(f.string().trim().min(1).max(2000)).max(100),truncated:f.boolean()}),uie=f.discriminatedUnion("kind",[f.strictObject({kind:f.literal("available"),message:lie}),f.strictObject({kind:f.literal("unavailable")})])});var WB=()=>{};var GB=x(()=>{WB()});var die;var QB=x(()=>{Re();die=f.object({url:f.string(),authToken:f.string().optional()})});var fie;var YB=x(()=>{Re();fie=f.object({success:f.boolean(),entityId:f.string().optional(),error:f.string().optional()})});var XB=()=>{};var ug,pie;var e6=x(()=>{Re();ug=f.lazy(()=>f.union([f.null(),f.boolean(),f.number().finite().refine((e)=>!Number.isInteger(e)||Number.isSafeInteger(e),{message:"integer exceeds the JSON-safe range"}),f.string(),f.array(ug),f.record(f.string(),ug)])),pie=f.record(f.string(),ug)});var mie;var t6=x(()=>{Re();mie=f.enum(["user","assistant"])});var r6,Ro;var n6=x(()=>{Re();r6=f.object({entityType:f.string().min(1),entityId:f.string().min(1),contentHash:f.string().min(1).optional()}),Ro=f.object({rootJobId:f.string().min(1),causationId:f.string().min(1),projectionId:f.string().min(1).optional(),projectionLineage:f.array(f.string().min(1)),sourceEntity:r6.optional(),derivationDepth:f.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 i6=()=>{};var hie,gie;var o6=x(()=>{Re();hie=f.object({entityType:f.string().min(1),entityId:f.string(),metadata:f.record(f.string(),f.unknown()).default({}),content:f.string().default("")}),gie=f.object({relativePath:f.string(),leaf:f.object({start:f.number().int().nonnegative(),end:f.number().int().nonnegative()}).nullable(),owner:f.object({entityType:f.string(),id:f.string()}).optional(),writable:f.boolean().optional()})});var s6=()=>{};var yie;var a6=x(()=>{Re();yie=f.strictObject({waveId:f.string().trim().min(1),sourceTypes:f.array(f.string().trim().min(1)),changedTargetTypes:f.array(f.string().trim().min(1))})});var c6,l6,u6,bie;var d6=x(()=>{ag();Re();c6=f.object({audiences:f.array(f.string()).optional(),positioning:f.string().optional()}),l6=f.object({summary:f.string().optional(),traits:f.array(f.string()).optional(),principles:f.array(f.string()).optional(),preferredTerms:f.array(f.string()).optional(),avoid:f.array(f.string()).optional()}),u6=f.object({artDirection:f.string().optional(),palette:f.array(f.string()).optional(),composition:f.string().optional(),mood:f.string().optional(),preferred:f.array(f.string()).optional(),avoid:f.array(f.string()).optional()}),bie=f.object({name:f.string().describe("Style guide name"),messaging:c6.optional(),voice:l6.optional(),visual:u6.optional()})});var xie;var f6=x(()=>{Re();xie=f.object({id:f.string().min(1),trigger:f.string().min(1),playbookId:f.string().min(1),once:f.boolean().default(!0),starterText:f.string().min(1),description:f.string().min(1).optional(),starterPrompt:f.string().min(1)}).strict()});var Sie,wie,p6,m6;var h6=x(()=>{Re();Sie=f.object({message:f.string().describe("Natural language response to the query"),summary:f.string().optional().describe("Brief summary if applicable"),topics:f.array(f.string()).optional().describe("Related topics mentioned"),sources:f.array(f.object({id:f.string(),type:f.string(),excerpt:f.string().optional(),relevance:f.number().min(0).max(1).optional()})).optional().describe("Source entities used to answer the query"),metadata:f.record(f.string(),f.unknown()).optional()}).describe("defaultQueryResponse"),wie=f.object({message:f.string()}).describe("simpleTextResponse"),p6=f.object({success:f.boolean(),entityId:f.string().optional(),message:f.string()}).describe("createEntityResponse"),m6=f.object({success:f.boolean(),entityId:f.string(),changes:f.array(f.string()).optional(),message:f.string()}).describe("updateEntityResponse")});var g6,F$e,y6,vie,_ie;var b6=x(()=>{Re();g6={recipientMissing:"Notification recipient missing",transportMissing:"Notification transport missing",deliveryFailed:"Notification delivery failed"},F$e=new RegExp(`^${g6.deliveryFailed}: ([a-z0-9_:.-]{1,80})$`),y6=f.discriminatedUnion("type",[f.strictObject({type:f.literal("email"),address:f.email()})]),vie=f.strictObject({recipient:y6.optional(),title:f.string().min(1),body:f.string().min(1),html:f.string().min(1).optional(),sensitivity:f.enum(["normal","secret"]).default("normal"),idempotencyKey:f.string().trim().min(1).max(200).optional()}),_ie=f.discriminatedUnion("status",[f.strictObject({status:f.literal("sent"),deliveryId:f.string().optional()}),f.strictObject({status:f.literal("failed")})])});var kie;var x6=x(()=>{Re();kie=f.strictObject({titles:f.array(f.string().trim().min(1).max(500)).max(20)})});var Eie,Iie;var S6=x(()=>{Re();Eie=f.strictObject({id:f.string().regex(/^[a-z0-9][a-z0-9-]{0,79}$/),title:f.string().trim().min(1).max(200),body:f.string().trim().min(1).max(20000)}),Iie=f.strictObject({noteId:f.string(),created:f.boolean()})});var Po=x(()=>{WE();SB();x1();vB();S1();UB();ZB();w1();KB();JB();VB();GB();QB();YB();XB();e6();t6();n6();i6();o6();s6();a6();d6();f6();h6();b6();x6();S6()});var w6=x(()=>{Id();Po()});var v6=x(()=>{Id();Po()});var _6=()=>{};function B(e,t){Cie(Boolean(e),!1,!0,"ok","Expected value to be truthy",t)}function Cie(e,t,r,i,n,o){if(!e)throw o instanceof Error?o:new k6(o||n,t,r,i,!o)}var k6;var tt=x(()=>{_6();k6=class k6 extends Error{name="Assertion";code="ERR_ASSERTION";constructor(e,t,r,i,n){super(e);if(Error.captureStackTrace)Error.captureStackTrace(this,this.constructor);this.actual=t,this.expected=r,this.generated=n,this.operator=i}}});function Ys(e,t){let r=t||$ie,i=typeof r.includeImageAlt==="boolean"?r.includeImageAlt:!0,n=typeof r.includeHtml==="boolean"?r.includeHtml:!0;return I6(e,i,n)}function I6(e,t,r){if(Oie(e)){if("value"in e)return e.type==="html"&&!r?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return E6(e.children,t,r)}if(Array.isArray(e))return E6(e,t,r);return""}function E6(e,t,r){let i=[],n=-1;while(++n<e.length)i[n]=I6(e[n],t,r);return i.join("")}function Oie(e){return Boolean(e&&typeof e==="object")}var $ie;var A6=x(()=>{$ie={}});var dg=x(()=>{A6()});var k1;var T6=x(()=>{k1={AElig:"\xC6",AMP:"&",Aacute:"\xC1",Abreve:"\u0102",Acirc:"\xC2",Acy:"\u0410",Afr:"\uD835\uDD04",Agrave:"\xC0",Alpha:"\u0391",Amacr:"\u0100",And:"\u2A53",Aogon:"\u0104",Aopf:"\uD835\uDD38",ApplyFunction:"\u2061",Aring:"\xC5",Ascr:"\uD835\uDC9C",Assign:"\u2254",Atilde:"\xC3",Auml:"\xC4",Backslash:"\u2216",Barv:"\u2AE7",Barwed:"\u2306",Bcy:"\u0411",Because:"\u2235",Bernoullis:"\u212C",Beta:"\u0392",Bfr:"\uD835\uDD05",Bopf:"\uD835\uDD39",Breve:"\u02D8",Bscr:"\u212C",Bumpeq:"\u224E",CHcy:"\u0427",COPY:"\xA9",Cacute:"\u0106",Cap:"\u22D2",CapitalDifferentialD:"\u2145",Cayleys:"\u212D",Ccaron:"\u010C",Ccedil:"\xC7",Ccirc:"\u0108",Cconint:"\u2230",Cdot:"\u010A",Cedilla:"\xB8",CenterDot:"\xB7",Cfr:"\u212D",Chi:"\u03A7",CircleDot:"\u2299",CircleMinus:"\u2296",CirclePlus:"\u2295",CircleTimes:"\u2297",ClockwiseContourIntegral:"\u2232",CloseCurlyDoubleQuote:"\u201D",CloseCurlyQuote:"\u2019",Colon:"\u2237",Colone:"\u2A74",Congruent:"\u2261",Conint:"\u222F",ContourIntegral:"\u222E",Copf:"\u2102",Coproduct:"\u2210",CounterClockwiseContourIntegral:"\u2233",Cross:"\u2A2F",Cscr:"\uD835\uDC9E",Cup:"\u22D3",CupCap:"\u224D",DD:"\u2145",DDotrahd:"\u2911",DJcy:"\u0402",DScy:"\u0405",DZcy:"\u040F",Dagger:"\u2021",Darr:"\u21A1",Dashv:"\u2AE4",Dcaron:"\u010E",Dcy:"\u0414",Del:"\u2207",Delta:"\u0394",Dfr:"\uD835\uDD07",DiacriticalAcute:"\xB4",DiacriticalDot:"\u02D9",DiacriticalDoubleAcute:"\u02DD",DiacriticalGrave:"`",DiacriticalTilde:"\u02DC",Diamond:"\u22C4",DifferentialD:"\u2146",Dopf:"\uD835\uDD3B",Dot:"\xA8",DotDot:"\u20DC",DotEqual:"\u2250",DoubleContourIntegral:"\u222F",DoubleDot:"\xA8",DoubleDownArrow:"\u21D3",DoubleLeftArrow:"\u21D0",DoubleLeftRightArrow:"\u21D4",DoubleLeftTee:"\u2AE4",DoubleLongLeftArrow:"\u27F8",DoubleLongLeftRightArrow:"\u27FA",DoubleLongRightArrow:"\u27F9",DoubleRightArrow:"\u21D2",DoubleRightTee:"\u22A8",DoubleUpArrow:"\u21D1",DoubleUpDownArrow:"\u21D5",DoubleVerticalBar:"\u2225",DownArrow:"\u2193",DownArrowBar:"\u2913",DownArrowUpArrow:"\u21F5",DownBreve:"\u0311",DownLeftRightVector:"\u2950",DownLeftTeeVector:"\u295E",DownLeftVector:"\u21BD",DownLeftVectorBar:"\u2956",DownRightTeeVector:"\u295F",DownRightVector:"\u21C1",DownRightVectorBar:"\u2957",DownTee:"\u22A4",DownTeeArrow:"\u21A7",Downarrow:"\u21D3",Dscr:"\uD835\uDC9F",Dstrok:"\u0110",ENG:"\u014A",ETH:"\xD0",Eacute:"\xC9",Ecaron:"\u011A",Ecirc:"\xCA",Ecy:"\u042D",Edot:"\u0116",Efr:"\uD835\uDD08",Egrave:"\xC8",Element:"\u2208",Emacr:"\u0112",EmptySmallSquare:"\u25FB",EmptyVerySmallSquare:"\u25AB",Eogon:"\u0118",Eopf:"\uD835\uDD3C",Epsilon:"\u0395",Equal:"\u2A75",EqualTilde:"\u2242",Equilibrium:"\u21CC",Escr:"\u2130",Esim:"\u2A73",Eta:"\u0397",Euml:"\xCB",Exists:"\u2203",ExponentialE:"\u2147",Fcy:"\u0424",Ffr:"\uD835\uDD09",FilledSmallSquare:"\u25FC",FilledVerySmallSquare:"\u25AA",Fopf:"\uD835\uDD3D",ForAll:"\u2200",Fouriertrf:"\u2131",Fscr:"\u2131",GJcy:"\u0403",GT:">",Gamma:"\u0393",Gammad:"\u03DC",Gbreve:"\u011E",Gcedil:"\u0122",Gcirc:"\u011C",Gcy:"\u0413",Gdot:"\u0120",Gfr:"\uD835\uDD0A",Gg:"\u22D9",Gopf:"\uD835\uDD3E",GreaterEqual:"\u2265",GreaterEqualLess:"\u22DB",GreaterFullEqual:"\u2267",GreaterGreater:"\u2AA2",GreaterLess:"\u2277",GreaterSlantEqual:"\u2A7E",GreaterTilde:"\u2273",Gscr:"\uD835\uDCA2",Gt:"\u226B",HARDcy:"\u042A",Hacek:"\u02C7",Hat:"^",Hcirc:"\u0124",Hfr:"\u210C",HilbertSpace:"\u210B",Hopf:"\u210D",HorizontalLine:"\u2500",Hscr:"\u210B",Hstrok:"\u0126",HumpDownHump:"\u224E",HumpEqual:"\u224F",IEcy:"\u0415",IJlig:"\u0132",IOcy:"\u0401",Iacute:"\xCD",Icirc:"\xCE",Icy:"\u0418",Idot:"\u0130",Ifr:"\u2111",Igrave:"\xCC",Im:"\u2111",Imacr:"\u012A",ImaginaryI:"\u2148",Implies:"\u21D2",Int:"\u222C",Integral:"\u222B",Intersection:"\u22C2",InvisibleComma:"\u2063",InvisibleTimes:"\u2062",Iogon:"\u012E",Iopf:"\uD835\uDD40",Iota:"\u0399",Iscr:"\u2110",Itilde:"\u0128",Iukcy:"\u0406",Iuml:"\xCF",Jcirc:"\u0134",Jcy:"\u0419",Jfr:"\uD835\uDD0D",Jopf:"\uD835\uDD41",Jscr:"\uD835\uDCA5",Jsercy:"\u0408",Jukcy:"\u0404",KHcy:"\u0425",KJcy:"\u040C",Kappa:"\u039A",Kcedil:"\u0136",Kcy:"\u041A",Kfr:"\uD835\uDD0E",Kopf:"\uD835\uDD42",Kscr:"\uD835\uDCA6",LJcy:"\u0409",LT:"<",Lacute:"\u0139",Lambda:"\u039B",Lang:"\u27EA",Laplacetrf:"\u2112",Larr:"\u219E",Lcaron:"\u013D",Lcedil:"\u013B",Lcy:"\u041B",LeftAngleBracket:"\u27E8",LeftArrow:"\u2190",LeftArrowBar:"\u21E4",LeftArrowRightArrow:"\u21C6",LeftCeiling:"\u2308",LeftDoubleBracket:"\u27E6",LeftDownTeeVector:"\u2961",LeftDownVector:"\u21C3",LeftDownVectorBar:"\u2959",LeftFloor:"\u230A",LeftRightArrow:"\u2194",LeftRightVector:"\u294E",LeftTee:"\u22A3",LeftTeeArrow:"\u21A4",LeftTeeVector:"\u295A",LeftTriangle:"\u22B2",LeftTriangleBar:"\u29CF",LeftTriangleEqual:"\u22B4",LeftUpDownVector:"\u2951",LeftUpTeeVector:"\u2960",LeftUpVector:"\u21BF",LeftUpVectorBar:"\u2958",LeftVector:"\u21BC",LeftVectorBar:"\u2952",Leftarrow:"\u21D0",Leftrightarrow:"\u21D4",LessEqualGreater:"\u22DA",LessFullEqual:"\u2266",LessGreater:"\u2276",LessLess:"\u2AA1",LessSlantEqual:"\u2A7D",LessTilde:"\u2272",Lfr:"\uD835\uDD0F",Ll:"\u22D8",Lleftarrow:"\u21DA",Lmidot:"\u013F",LongLeftArrow:"\u27F5",LongLeftRightArrow:"\u27F7",LongRightArrow:"\u27F6",Longleftarrow:"\u27F8",Longleftrightarrow:"\u27FA",Longrightarrow:"\u27F9",Lopf:"\uD835\uDD43",LowerLeftArrow:"\u2199",LowerRightArrow:"\u2198",Lscr:"\u2112",Lsh:"\u21B0",Lstrok:"\u0141",Lt:"\u226A",Map:"\u2905",Mcy:"\u041C",MediumSpace:"\u205F",Mellintrf:"\u2133",Mfr:"\uD835\uDD10",MinusPlus:"\u2213",Mopf:"\uD835\uDD44",Mscr:"\u2133",Mu:"\u039C",NJcy:"\u040A",Nacute:"\u0143",Ncaron:"\u0147",Ncedil:"\u0145",Ncy:"\u041D",NegativeMediumSpace:"\u200B",NegativeThickSpace:"\u200B",NegativeThinSpace:"\u200B",NegativeVeryThinSpace:"\u200B",NestedGreaterGreater:"\u226B",NestedLessLess:"\u226A",NewLine:`
272
+ `,Nfr:"\uD835\uDD11",NoBreak:"\u2060",NonBreakingSpace:"\xA0",Nopf:"\u2115",Not:"\u2AEC",NotCongruent:"\u2262",NotCupCap:"\u226D",NotDoubleVerticalBar:"\u2226",NotElement:"\u2209",NotEqual:"\u2260",NotEqualTilde:"\u2242\u0338",NotExists:"\u2204",NotGreater:"\u226F",NotGreaterEqual:"\u2271",NotGreaterFullEqual:"\u2267\u0338",NotGreaterGreater:"\u226B\u0338",NotGreaterLess:"\u2279",NotGreaterSlantEqual:"\u2A7E\u0338",NotGreaterTilde:"\u2275",NotHumpDownHump:"\u224E\u0338",NotHumpEqual:"\u224F\u0338",NotLeftTriangle:"\u22EA",NotLeftTriangleBar:"\u29CF\u0338",NotLeftTriangleEqual:"\u22EC",NotLess:"\u226E",NotLessEqual:"\u2270",NotLessGreater:"\u2278",NotLessLess:"\u226A\u0338",NotLessSlantEqual:"\u2A7D\u0338",NotLessTilde:"\u2274",NotNestedGreaterGreater:"\u2AA2\u0338",NotNestedLessLess:"\u2AA1\u0338",NotPrecedes:"\u2280",NotPrecedesEqual:"\u2AAF\u0338",NotPrecedesSlantEqual:"\u22E0",NotReverseElement:"\u220C",NotRightTriangle:"\u22EB",NotRightTriangleBar:"\u29D0\u0338",NotRightTriangleEqual:"\u22ED",NotSquareSubset:"\u228F\u0338",NotSquareSubsetEqual:"\u22E2",NotSquareSuperset:"\u2290\u0338",NotSquareSupersetEqual:"\u22E3",NotSubset:"\u2282\u20D2",NotSubsetEqual:"\u2288",NotSucceeds:"\u2281",NotSucceedsEqual:"\u2AB0\u0338",NotSucceedsSlantEqual:"\u22E1",NotSucceedsTilde:"\u227F\u0338",NotSuperset:"\u2283\u20D2",NotSupersetEqual:"\u2289",NotTilde:"\u2241",NotTildeEqual:"\u2244",NotTildeFullEqual:"\u2247",NotTildeTilde:"\u2249",NotVerticalBar:"\u2224",Nscr:"\uD835\uDCA9",Ntilde:"\xD1",Nu:"\u039D",OElig:"\u0152",Oacute:"\xD3",Ocirc:"\xD4",Ocy:"\u041E",Odblac:"\u0150",Ofr:"\uD835\uDD12",Ograve:"\xD2",Omacr:"\u014C",Omega:"\u03A9",Omicron:"\u039F",Oopf:"\uD835\uDD46",OpenCurlyDoubleQuote:"\u201C",OpenCurlyQuote:"\u2018",Or:"\u2A54",Oscr:"\uD835\uDCAA",Oslash:"\xD8",Otilde:"\xD5",Otimes:"\u2A37",Ouml:"\xD6",OverBar:"\u203E",OverBrace:"\u23DE",OverBracket:"\u23B4",OverParenthesis:"\u23DC",PartialD:"\u2202",Pcy:"\u041F",Pfr:"\uD835\uDD13",Phi:"\u03A6",Pi:"\u03A0",PlusMinus:"\xB1",Poincareplane:"\u210C",Popf:"\u2119",Pr:"\u2ABB",Precedes:"\u227A",PrecedesEqual:"\u2AAF",PrecedesSlantEqual:"\u227C",PrecedesTilde:"\u227E",Prime:"\u2033",Product:"\u220F",Proportion:"\u2237",Proportional:"\u221D",Pscr:"\uD835\uDCAB",Psi:"\u03A8",QUOT:'"',Qfr:"\uD835\uDD14",Qopf:"\u211A",Qscr:"\uD835\uDCAC",RBarr:"\u2910",REG:"\xAE",Racute:"\u0154",Rang:"\u27EB",Rarr:"\u21A0",Rarrtl:"\u2916",Rcaron:"\u0158",Rcedil:"\u0156",Rcy:"\u0420",Re:"\u211C",ReverseElement:"\u220B",ReverseEquilibrium:"\u21CB",ReverseUpEquilibrium:"\u296F",Rfr:"\u211C",Rho:"\u03A1",RightAngleBracket:"\u27E9",RightArrow:"\u2192",RightArrowBar:"\u21E5",RightArrowLeftArrow:"\u21C4",RightCeiling:"\u2309",RightDoubleBracket:"\u27E7",RightDownTeeVector:"\u295D",RightDownVector:"\u21C2",RightDownVectorBar:"\u2955",RightFloor:"\u230B",RightTee:"\u22A2",RightTeeArrow:"\u21A6",RightTeeVector:"\u295B",RightTriangle:"\u22B3",RightTriangleBar:"\u29D0",RightTriangleEqual:"\u22B5",RightUpDownVector:"\u294F",RightUpTeeVector:"\u295C",RightUpVector:"\u21BE",RightUpVectorBar:"\u2954",RightVector:"\u21C0",RightVectorBar:"\u2953",Rightarrow:"\u21D2",Ropf:"\u211D",RoundImplies:"\u2970",Rrightarrow:"\u21DB",Rscr:"\u211B",Rsh:"\u21B1",RuleDelayed:"\u29F4",SHCHcy:"\u0429",SHcy:"\u0428",SOFTcy:"\u042C",Sacute:"\u015A",Sc:"\u2ABC",Scaron:"\u0160",Scedil:"\u015E",Scirc:"\u015C",Scy:"\u0421",Sfr:"\uD835\uDD16",ShortDownArrow:"\u2193",ShortLeftArrow:"\u2190",ShortRightArrow:"\u2192",ShortUpArrow:"\u2191",Sigma:"\u03A3",SmallCircle:"\u2218",Sopf:"\uD835\uDD4A",Sqrt:"\u221A",Square:"\u25A1",SquareIntersection:"\u2293",SquareSubset:"\u228F",SquareSubsetEqual:"\u2291",SquareSuperset:"\u2290",SquareSupersetEqual:"\u2292",SquareUnion:"\u2294",Sscr:"\uD835\uDCAE",Star:"\u22C6",Sub:"\u22D0",Subset:"\u22D0",SubsetEqual:"\u2286",Succeeds:"\u227B",SucceedsEqual:"\u2AB0",SucceedsSlantEqual:"\u227D",SucceedsTilde:"\u227F",SuchThat:"\u220B",Sum:"\u2211",Sup:"\u22D1",Superset:"\u2283",SupersetEqual:"\u2287",Supset:"\u22D1",THORN:"\xDE",TRADE:"\u2122",TSHcy:"\u040B",TScy:"\u0426",Tab:"\t",Tau:"\u03A4",Tcaron:"\u0164",Tcedil:"\u0162",Tcy:"\u0422",Tfr:"\uD835\uDD17",Therefore:"\u2234",Theta:"\u0398",ThickSpace:"\u205F\u200A",ThinSpace:"\u2009",Tilde:"\u223C",TildeEqual:"\u2243",TildeFullEqual:"\u2245",TildeTilde:"\u2248",Topf:"\uD835\uDD4B",TripleDot:"\u20DB",Tscr:"\uD835\uDCAF",Tstrok:"\u0166",Uacute:"\xDA",Uarr:"\u219F",Uarrocir:"\u2949",Ubrcy:"\u040E",Ubreve:"\u016C",Ucirc:"\xDB",Ucy:"\u0423",Udblac:"\u0170",Ufr:"\uD835\uDD18",Ugrave:"\xD9",Umacr:"\u016A",UnderBar:"_",UnderBrace:"\u23DF",UnderBracket:"\u23B5",UnderParenthesis:"\u23DD",Union:"\u22C3",UnionPlus:"\u228E",Uogon:"\u0172",Uopf:"\uD835\uDD4C",UpArrow:"\u2191",UpArrowBar:"\u2912",UpArrowDownArrow:"\u21C5",UpDownArrow:"\u2195",UpEquilibrium:"\u296E",UpTee:"\u22A5",UpTeeArrow:"\u21A5",Uparrow:"\u21D1",Updownarrow:"\u21D5",UpperLeftArrow:"\u2196",UpperRightArrow:"\u2197",Upsi:"\u03D2",Upsilon:"\u03A5",Uring:"\u016E",Uscr:"\uD835\uDCB0",Utilde:"\u0168",Uuml:"\xDC",VDash:"\u22AB",Vbar:"\u2AEB",Vcy:"\u0412",Vdash:"\u22A9",Vdashl:"\u2AE6",Vee:"\u22C1",Verbar:"\u2016",Vert:"\u2016",VerticalBar:"\u2223",VerticalLine:"|",VerticalSeparator:"\u2758",VerticalTilde:"\u2240",VeryThinSpace:"\u200A",Vfr:"\uD835\uDD19",Vopf:"\uD835\uDD4D",Vscr:"\uD835\uDCB1",Vvdash:"\u22AA",Wcirc:"\u0174",Wedge:"\u22C0",Wfr:"\uD835\uDD1A",Wopf:"\uD835\uDD4E",Wscr:"\uD835\uDCB2",Xfr:"\uD835\uDD1B",Xi:"\u039E",Xopf:"\uD835\uDD4F",Xscr:"\uD835\uDCB3",YAcy:"\u042F",YIcy:"\u0407",YUcy:"\u042E",Yacute:"\xDD",Ycirc:"\u0176",Ycy:"\u042B",Yfr:"\uD835\uDD1C",Yopf:"\uD835\uDD50",Yscr:"\uD835\uDCB4",Yuml:"\u0178",ZHcy:"\u0416",Zacute:"\u0179",Zcaron:"\u017D",Zcy:"\u0417",Zdot:"\u017B",ZeroWidthSpace:"\u200B",Zeta:"\u0396",Zfr:"\u2128",Zopf:"\u2124",Zscr:"\uD835\uDCB5",aacute:"\xE1",abreve:"\u0103",ac:"\u223E",acE:"\u223E\u0333",acd:"\u223F",acirc:"\xE2",acute:"\xB4",acy:"\u0430",aelig:"\xE6",af:"\u2061",afr:"\uD835\uDD1E",agrave:"\xE0",alefsym:"\u2135",aleph:"\u2135",alpha:"\u03B1",amacr:"\u0101",amalg:"\u2A3F",amp:"&",and:"\u2227",andand:"\u2A55",andd:"\u2A5C",andslope:"\u2A58",andv:"\u2A5A",ang:"\u2220",ange:"\u29A4",angle:"\u2220",angmsd:"\u2221",angmsdaa:"\u29A8",angmsdab:"\u29A9",angmsdac:"\u29AA",angmsdad:"\u29AB",angmsdae:"\u29AC",angmsdaf:"\u29AD",angmsdag:"\u29AE",angmsdah:"\u29AF",angrt:"\u221F",angrtvb:"\u22BE",angrtvbd:"\u299D",angsph:"\u2222",angst:"\xC5",angzarr:"\u237C",aogon:"\u0105",aopf:"\uD835\uDD52",ap:"\u2248",apE:"\u2A70",apacir:"\u2A6F",ape:"\u224A",apid:"\u224B",apos:"'",approx:"\u2248",approxeq:"\u224A",aring:"\xE5",ascr:"\uD835\uDCB6",ast:"*",asymp:"\u2248",asympeq:"\u224D",atilde:"\xE3",auml:"\xE4",awconint:"\u2233",awint:"\u2A11",bNot:"\u2AED",backcong:"\u224C",backepsilon:"\u03F6",backprime:"\u2035",backsim:"\u223D",backsimeq:"\u22CD",barvee:"\u22BD",barwed:"\u2305",barwedge:"\u2305",bbrk:"\u23B5",bbrktbrk:"\u23B6",bcong:"\u224C",bcy:"\u0431",bdquo:"\u201E",becaus:"\u2235",because:"\u2235",bemptyv:"\u29B0",bepsi:"\u03F6",bernou:"\u212C",beta:"\u03B2",beth:"\u2136",between:"\u226C",bfr:"\uD835\uDD1F",bigcap:"\u22C2",bigcirc:"\u25EF",bigcup:"\u22C3",bigodot:"\u2A00",bigoplus:"\u2A01",bigotimes:"\u2A02",bigsqcup:"\u2A06",bigstar:"\u2605",bigtriangledown:"\u25BD",bigtriangleup:"\u25B3",biguplus:"\u2A04",bigvee:"\u22C1",bigwedge:"\u22C0",bkarow:"\u290D",blacklozenge:"\u29EB",blacksquare:"\u25AA",blacktriangle:"\u25B4",blacktriangledown:"\u25BE",blacktriangleleft:"\u25C2",blacktriangleright:"\u25B8",blank:"\u2423",blk12:"\u2592",blk14:"\u2591",blk34:"\u2593",block:"\u2588",bne:"=\u20E5",bnequiv:"\u2261\u20E5",bnot:"\u2310",bopf:"\uD835\uDD53",bot:"\u22A5",bottom:"\u22A5",bowtie:"\u22C8",boxDL:"\u2557",boxDR:"\u2554",boxDl:"\u2556",boxDr:"\u2553",boxH:"\u2550",boxHD:"\u2566",boxHU:"\u2569",boxHd:"\u2564",boxHu:"\u2567",boxUL:"\u255D",boxUR:"\u255A",boxUl:"\u255C",boxUr:"\u2559",boxV:"\u2551",boxVH:"\u256C",boxVL:"\u2563",boxVR:"\u2560",boxVh:"\u256B",boxVl:"\u2562",boxVr:"\u255F",boxbox:"\u29C9",boxdL:"\u2555",boxdR:"\u2552",boxdl:"\u2510",boxdr:"\u250C",boxh:"\u2500",boxhD:"\u2565",boxhU:"\u2568",boxhd:"\u252C",boxhu:"\u2534",boxminus:"\u229F",boxplus:"\u229E",boxtimes:"\u22A0",boxuL:"\u255B",boxuR:"\u2558",boxul:"\u2518",boxur:"\u2514",boxv:"\u2502",boxvH:"\u256A",boxvL:"\u2561",boxvR:"\u255E",boxvh:"\u253C",boxvl:"\u2524",boxvr:"\u251C",bprime:"\u2035",breve:"\u02D8",brvbar:"\xA6",bscr:"\uD835\uDCB7",bsemi:"\u204F",bsim:"\u223D",bsime:"\u22CD",bsol:"\\",bsolb:"\u29C5",bsolhsub:"\u27C8",bull:"\u2022",bullet:"\u2022",bump:"\u224E",bumpE:"\u2AAE",bumpe:"\u224F",bumpeq:"\u224F",cacute:"\u0107",cap:"\u2229",capand:"\u2A44",capbrcup:"\u2A49",capcap:"\u2A4B",capcup:"\u2A47",capdot:"\u2A40",caps:"\u2229\uFE00",caret:"\u2041",caron:"\u02C7",ccaps:"\u2A4D",ccaron:"\u010D",ccedil:"\xE7",ccirc:"\u0109",ccups:"\u2A4C",ccupssm:"\u2A50",cdot:"\u010B",cedil:"\xB8",cemptyv:"\u29B2",cent:"\xA2",centerdot:"\xB7",cfr:"\uD835\uDD20",chcy:"\u0447",check:"\u2713",checkmark:"\u2713",chi:"\u03C7",cir:"\u25CB",cirE:"\u29C3",circ:"\u02C6",circeq:"\u2257",circlearrowleft:"\u21BA",circlearrowright:"\u21BB",circledR:"\xAE",circledS:"\u24C8",circledast:"\u229B",circledcirc:"\u229A",circleddash:"\u229D",cire:"\u2257",cirfnint:"\u2A10",cirmid:"\u2AEF",cirscir:"\u29C2",clubs:"\u2663",clubsuit:"\u2663",colon:":",colone:"\u2254",coloneq:"\u2254",comma:",",commat:"@",comp:"\u2201",compfn:"\u2218",complement:"\u2201",complexes:"\u2102",cong:"\u2245",congdot:"\u2A6D",conint:"\u222E",copf:"\uD835\uDD54",coprod:"\u2210",copy:"\xA9",copysr:"\u2117",crarr:"\u21B5",cross:"\u2717",cscr:"\uD835\uDCB8",csub:"\u2ACF",csube:"\u2AD1",csup:"\u2AD0",csupe:"\u2AD2",ctdot:"\u22EF",cudarrl:"\u2938",cudarrr:"\u2935",cuepr:"\u22DE",cuesc:"\u22DF",cularr:"\u21B6",cularrp:"\u293D",cup:"\u222A",cupbrcap:"\u2A48",cupcap:"\u2A46",cupcup:"\u2A4A",cupdot:"\u228D",cupor:"\u2A45",cups:"\u222A\uFE00",curarr:"\u21B7",curarrm:"\u293C",curlyeqprec:"\u22DE",curlyeqsucc:"\u22DF",curlyvee:"\u22CE",curlywedge:"\u22CF",curren:"\xA4",curvearrowleft:"\u21B6",curvearrowright:"\u21B7",cuvee:"\u22CE",cuwed:"\u22CF",cwconint:"\u2232",cwint:"\u2231",cylcty:"\u232D",dArr:"\u21D3",dHar:"\u2965",dagger:"\u2020",daleth:"\u2138",darr:"\u2193",dash:"\u2010",dashv:"\u22A3",dbkarow:"\u290F",dblac:"\u02DD",dcaron:"\u010F",dcy:"\u0434",dd:"\u2146",ddagger:"\u2021",ddarr:"\u21CA",ddotseq:"\u2A77",deg:"\xB0",delta:"\u03B4",demptyv:"\u29B1",dfisht:"\u297F",dfr:"\uD835\uDD21",dharl:"\u21C3",dharr:"\u21C2",diam:"\u22C4",diamond:"\u22C4",diamondsuit:"\u2666",diams:"\u2666",die:"\xA8",digamma:"\u03DD",disin:"\u22F2",div:"\xF7",divide:"\xF7",divideontimes:"\u22C7",divonx:"\u22C7",djcy:"\u0452",dlcorn:"\u231E",dlcrop:"\u230D",dollar:"$",dopf:"\uD835\uDD55",dot:"\u02D9",doteq:"\u2250",doteqdot:"\u2251",dotminus:"\u2238",dotplus:"\u2214",dotsquare:"\u22A1",doublebarwedge:"\u2306",downarrow:"\u2193",downdownarrows:"\u21CA",downharpoonleft:"\u21C3",downharpoonright:"\u21C2",drbkarow:"\u2910",drcorn:"\u231F",drcrop:"\u230C",dscr:"\uD835\uDCB9",dscy:"\u0455",dsol:"\u29F6",dstrok:"\u0111",dtdot:"\u22F1",dtri:"\u25BF",dtrif:"\u25BE",duarr:"\u21F5",duhar:"\u296F",dwangle:"\u29A6",dzcy:"\u045F",dzigrarr:"\u27FF",eDDot:"\u2A77",eDot:"\u2251",eacute:"\xE9",easter:"\u2A6E",ecaron:"\u011B",ecir:"\u2256",ecirc:"\xEA",ecolon:"\u2255",ecy:"\u044D",edot:"\u0117",ee:"\u2147",efDot:"\u2252",efr:"\uD835\uDD22",eg:"\u2A9A",egrave:"\xE8",egs:"\u2A96",egsdot:"\u2A98",el:"\u2A99",elinters:"\u23E7",ell:"\u2113",els:"\u2A95",elsdot:"\u2A97",emacr:"\u0113",empty:"\u2205",emptyset:"\u2205",emptyv:"\u2205",emsp13:"\u2004",emsp14:"\u2005",emsp:"\u2003",eng:"\u014B",ensp:"\u2002",eogon:"\u0119",eopf:"\uD835\uDD56",epar:"\u22D5",eparsl:"\u29E3",eplus:"\u2A71",epsi:"\u03B5",epsilon:"\u03B5",epsiv:"\u03F5",eqcirc:"\u2256",eqcolon:"\u2255",eqsim:"\u2242",eqslantgtr:"\u2A96",eqslantless:"\u2A95",equals:"=",equest:"\u225F",equiv:"\u2261",equivDD:"\u2A78",eqvparsl:"\u29E5",erDot:"\u2253",erarr:"\u2971",escr:"\u212F",esdot:"\u2250",esim:"\u2242",eta:"\u03B7",eth:"\xF0",euml:"\xEB",euro:"\u20AC",excl:"!",exist:"\u2203",expectation:"\u2130",exponentiale:"\u2147",fallingdotseq:"\u2252",fcy:"\u0444",female:"\u2640",ffilig:"\uFB03",fflig:"\uFB00",ffllig:"\uFB04",ffr:"\uD835\uDD23",filig:"\uFB01",fjlig:"fj",flat:"\u266D",fllig:"\uFB02",fltns:"\u25B1",fnof:"\u0192",fopf:"\uD835\uDD57",forall:"\u2200",fork:"\u22D4",forkv:"\u2AD9",fpartint:"\u2A0D",frac12:"\xBD",frac13:"\u2153",frac14:"\xBC",frac15:"\u2155",frac16:"\u2159",frac18:"\u215B",frac23:"\u2154",frac25:"\u2156",frac34:"\xBE",frac35:"\u2157",frac38:"\u215C",frac45:"\u2158",frac56:"\u215A",frac58:"\u215D",frac78:"\u215E",frasl:"\u2044",frown:"\u2322",fscr:"\uD835\uDCBB",gE:"\u2267",gEl:"\u2A8C",gacute:"\u01F5",gamma:"\u03B3",gammad:"\u03DD",gap:"\u2A86",gbreve:"\u011F",gcirc:"\u011D",gcy:"\u0433",gdot:"\u0121",ge:"\u2265",gel:"\u22DB",geq:"\u2265",geqq:"\u2267",geqslant:"\u2A7E",ges:"\u2A7E",gescc:"\u2AA9",gesdot:"\u2A80",gesdoto:"\u2A82",gesdotol:"\u2A84",gesl:"\u22DB\uFE00",gesles:"\u2A94",gfr:"\uD835\uDD24",gg:"\u226B",ggg:"\u22D9",gimel:"\u2137",gjcy:"\u0453",gl:"\u2277",glE:"\u2A92",gla:"\u2AA5",glj:"\u2AA4",gnE:"\u2269",gnap:"\u2A8A",gnapprox:"\u2A8A",gne:"\u2A88",gneq:"\u2A88",gneqq:"\u2269",gnsim:"\u22E7",gopf:"\uD835\uDD58",grave:"`",gscr:"\u210A",gsim:"\u2273",gsime:"\u2A8E",gsiml:"\u2A90",gt:">",gtcc:"\u2AA7",gtcir:"\u2A7A",gtdot:"\u22D7",gtlPar:"\u2995",gtquest:"\u2A7C",gtrapprox:"\u2A86",gtrarr:"\u2978",gtrdot:"\u22D7",gtreqless:"\u22DB",gtreqqless:"\u2A8C",gtrless:"\u2277",gtrsim:"\u2273",gvertneqq:"\u2269\uFE00",gvnE:"\u2269\uFE00",hArr:"\u21D4",hairsp:"\u200A",half:"\xBD",hamilt:"\u210B",hardcy:"\u044A",harr:"\u2194",harrcir:"\u2948",harrw:"\u21AD",hbar:"\u210F",hcirc:"\u0125",hearts:"\u2665",heartsuit:"\u2665",hellip:"\u2026",hercon:"\u22B9",hfr:"\uD835\uDD25",hksearow:"\u2925",hkswarow:"\u2926",hoarr:"\u21FF",homtht:"\u223B",hookleftarrow:"\u21A9",hookrightarrow:"\u21AA",hopf:"\uD835\uDD59",horbar:"\u2015",hscr:"\uD835\uDCBD",hslash:"\u210F",hstrok:"\u0127",hybull:"\u2043",hyphen:"\u2010",iacute:"\xED",ic:"\u2063",icirc:"\xEE",icy:"\u0438",iecy:"\u0435",iexcl:"\xA1",iff:"\u21D4",ifr:"\uD835\uDD26",igrave:"\xEC",ii:"\u2148",iiiint:"\u2A0C",iiint:"\u222D",iinfin:"\u29DC",iiota:"\u2129",ijlig:"\u0133",imacr:"\u012B",image:"\u2111",imagline:"\u2110",imagpart:"\u2111",imath:"\u0131",imof:"\u22B7",imped:"\u01B5",in:"\u2208",incare:"\u2105",infin:"\u221E",infintie:"\u29DD",inodot:"\u0131",int:"\u222B",intcal:"\u22BA",integers:"\u2124",intercal:"\u22BA",intlarhk:"\u2A17",intprod:"\u2A3C",iocy:"\u0451",iogon:"\u012F",iopf:"\uD835\uDD5A",iota:"\u03B9",iprod:"\u2A3C",iquest:"\xBF",iscr:"\uD835\uDCBE",isin:"\u2208",isinE:"\u22F9",isindot:"\u22F5",isins:"\u22F4",isinsv:"\u22F3",isinv:"\u2208",it:"\u2062",itilde:"\u0129",iukcy:"\u0456",iuml:"\xEF",jcirc:"\u0135",jcy:"\u0439",jfr:"\uD835\uDD27",jmath:"\u0237",jopf:"\uD835\uDD5B",jscr:"\uD835\uDCBF",jsercy:"\u0458",jukcy:"\u0454",kappa:"\u03BA",kappav:"\u03F0",kcedil:"\u0137",kcy:"\u043A",kfr:"\uD835\uDD28",kgreen:"\u0138",khcy:"\u0445",kjcy:"\u045C",kopf:"\uD835\uDD5C",kscr:"\uD835\uDCC0",lAarr:"\u21DA",lArr:"\u21D0",lAtail:"\u291B",lBarr:"\u290E",lE:"\u2266",lEg:"\u2A8B",lHar:"\u2962",lacute:"\u013A",laemptyv:"\u29B4",lagran:"\u2112",lambda:"\u03BB",lang:"\u27E8",langd:"\u2991",langle:"\u27E8",lap:"\u2A85",laquo:"\xAB",larr:"\u2190",larrb:"\u21E4",larrbfs:"\u291F",larrfs:"\u291D",larrhk:"\u21A9",larrlp:"\u21AB",larrpl:"\u2939",larrsim:"\u2973",larrtl:"\u21A2",lat:"\u2AAB",latail:"\u2919",late:"\u2AAD",lates:"\u2AAD\uFE00",lbarr:"\u290C",lbbrk:"\u2772",lbrace:"{",lbrack:"[",lbrke:"\u298B",lbrksld:"\u298F",lbrkslu:"\u298D",lcaron:"\u013E",lcedil:"\u013C",lceil:"\u2308",lcub:"{",lcy:"\u043B",ldca:"\u2936",ldquo:"\u201C",ldquor:"\u201E",ldrdhar:"\u2967",ldrushar:"\u294B",ldsh:"\u21B2",le:"\u2264",leftarrow:"\u2190",leftarrowtail:"\u21A2",leftharpoondown:"\u21BD",leftharpoonup:"\u21BC",leftleftarrows:"\u21C7",leftrightarrow:"\u2194",leftrightarrows:"\u21C6",leftrightharpoons:"\u21CB",leftrightsquigarrow:"\u21AD",leftthreetimes:"\u22CB",leg:"\u22DA",leq:"\u2264",leqq:"\u2266",leqslant:"\u2A7D",les:"\u2A7D",lescc:"\u2AA8",lesdot:"\u2A7F",lesdoto:"\u2A81",lesdotor:"\u2A83",lesg:"\u22DA\uFE00",lesges:"\u2A93",lessapprox:"\u2A85",lessdot:"\u22D6",lesseqgtr:"\u22DA",lesseqqgtr:"\u2A8B",lessgtr:"\u2276",lesssim:"\u2272",lfisht:"\u297C",lfloor:"\u230A",lfr:"\uD835\uDD29",lg:"\u2276",lgE:"\u2A91",lhard:"\u21BD",lharu:"\u21BC",lharul:"\u296A",lhblk:"\u2584",ljcy:"\u0459",ll:"\u226A",llarr:"\u21C7",llcorner:"\u231E",llhard:"\u296B",lltri:"\u25FA",lmidot:"\u0140",lmoust:"\u23B0",lmoustache:"\u23B0",lnE:"\u2268",lnap:"\u2A89",lnapprox:"\u2A89",lne:"\u2A87",lneq:"\u2A87",lneqq:"\u2268",lnsim:"\u22E6",loang:"\u27EC",loarr:"\u21FD",lobrk:"\u27E6",longleftarrow:"\u27F5",longleftrightarrow:"\u27F7",longmapsto:"\u27FC",longrightarrow:"\u27F6",looparrowleft:"\u21AB",looparrowright:"\u21AC",lopar:"\u2985",lopf:"\uD835\uDD5D",loplus:"\u2A2D",lotimes:"\u2A34",lowast:"\u2217",lowbar:"_",loz:"\u25CA",lozenge:"\u25CA",lozf:"\u29EB",lpar:"(",lparlt:"\u2993",lrarr:"\u21C6",lrcorner:"\u231F",lrhar:"\u21CB",lrhard:"\u296D",lrm:"\u200E",lrtri:"\u22BF",lsaquo:"\u2039",lscr:"\uD835\uDCC1",lsh:"\u21B0",lsim:"\u2272",lsime:"\u2A8D",lsimg:"\u2A8F",lsqb:"[",lsquo:"\u2018",lsquor:"\u201A",lstrok:"\u0142",lt:"<",ltcc:"\u2AA6",ltcir:"\u2A79",ltdot:"\u22D6",lthree:"\u22CB",ltimes:"\u22C9",ltlarr:"\u2976",ltquest:"\u2A7B",ltrPar:"\u2996",ltri:"\u25C3",ltrie:"\u22B4",ltrif:"\u25C2",lurdshar:"\u294A",luruhar:"\u2966",lvertneqq:"\u2268\uFE00",lvnE:"\u2268\uFE00",mDDot:"\u223A",macr:"\xAF",male:"\u2642",malt:"\u2720",maltese:"\u2720",map:"\u21A6",mapsto:"\u21A6",mapstodown:"\u21A7",mapstoleft:"\u21A4",mapstoup:"\u21A5",marker:"\u25AE",mcomma:"\u2A29",mcy:"\u043C",mdash:"\u2014",measuredangle:"\u2221",mfr:"\uD835\uDD2A",mho:"\u2127",micro:"\xB5",mid:"\u2223",midast:"*",midcir:"\u2AF0",middot:"\xB7",minus:"\u2212",minusb:"\u229F",minusd:"\u2238",minusdu:"\u2A2A",mlcp:"\u2ADB",mldr:"\u2026",mnplus:"\u2213",models:"\u22A7",mopf:"\uD835\uDD5E",mp:"\u2213",mscr:"\uD835\uDCC2",mstpos:"\u223E",mu:"\u03BC",multimap:"\u22B8",mumap:"\u22B8",nGg:"\u22D9\u0338",nGt:"\u226B\u20D2",nGtv:"\u226B\u0338",nLeftarrow:"\u21CD",nLeftrightarrow:"\u21CE",nLl:"\u22D8\u0338",nLt:"\u226A\u20D2",nLtv:"\u226A\u0338",nRightarrow:"\u21CF",nVDash:"\u22AF",nVdash:"\u22AE",nabla:"\u2207",nacute:"\u0144",nang:"\u2220\u20D2",nap:"\u2249",napE:"\u2A70\u0338",napid:"\u224B\u0338",napos:"\u0149",napprox:"\u2249",natur:"\u266E",natural:"\u266E",naturals:"\u2115",nbsp:"\xA0",nbump:"\u224E\u0338",nbumpe:"\u224F\u0338",ncap:"\u2A43",ncaron:"\u0148",ncedil:"\u0146",ncong:"\u2247",ncongdot:"\u2A6D\u0338",ncup:"\u2A42",ncy:"\u043D",ndash:"\u2013",ne:"\u2260",neArr:"\u21D7",nearhk:"\u2924",nearr:"\u2197",nearrow:"\u2197",nedot:"\u2250\u0338",nequiv:"\u2262",nesear:"\u2928",nesim:"\u2242\u0338",nexist:"\u2204",nexists:"\u2204",nfr:"\uD835\uDD2B",ngE:"\u2267\u0338",nge:"\u2271",ngeq:"\u2271",ngeqq:"\u2267\u0338",ngeqslant:"\u2A7E\u0338",nges:"\u2A7E\u0338",ngsim:"\u2275",ngt:"\u226F",ngtr:"\u226F",nhArr:"\u21CE",nharr:"\u21AE",nhpar:"\u2AF2",ni:"\u220B",nis:"\u22FC",nisd:"\u22FA",niv:"\u220B",njcy:"\u045A",nlArr:"\u21CD",nlE:"\u2266\u0338",nlarr:"\u219A",nldr:"\u2025",nle:"\u2270",nleftarrow:"\u219A",nleftrightarrow:"\u21AE",nleq:"\u2270",nleqq:"\u2266\u0338",nleqslant:"\u2A7D\u0338",nles:"\u2A7D\u0338",nless:"\u226E",nlsim:"\u2274",nlt:"\u226E",nltri:"\u22EA",nltrie:"\u22EC",nmid:"\u2224",nopf:"\uD835\uDD5F",not:"\xAC",notin:"\u2209",notinE:"\u22F9\u0338",notindot:"\u22F5\u0338",notinva:"\u2209",notinvb:"\u22F7",notinvc:"\u22F6",notni:"\u220C",notniva:"\u220C",notnivb:"\u22FE",notnivc:"\u22FD",npar:"\u2226",nparallel:"\u2226",nparsl:"\u2AFD\u20E5",npart:"\u2202\u0338",npolint:"\u2A14",npr:"\u2280",nprcue:"\u22E0",npre:"\u2AAF\u0338",nprec:"\u2280",npreceq:"\u2AAF\u0338",nrArr:"\u21CF",nrarr:"\u219B",nrarrc:"\u2933\u0338",nrarrw:"\u219D\u0338",nrightarrow:"\u219B",nrtri:"\u22EB",nrtrie:"\u22ED",nsc:"\u2281",nsccue:"\u22E1",nsce:"\u2AB0\u0338",nscr:"\uD835\uDCC3",nshortmid:"\u2224",nshortparallel:"\u2226",nsim:"\u2241",nsime:"\u2244",nsimeq:"\u2244",nsmid:"\u2224",nspar:"\u2226",nsqsube:"\u22E2",nsqsupe:"\u22E3",nsub:"\u2284",nsubE:"\u2AC5\u0338",nsube:"\u2288",nsubset:"\u2282\u20D2",nsubseteq:"\u2288",nsubseteqq:"\u2AC5\u0338",nsucc:"\u2281",nsucceq:"\u2AB0\u0338",nsup:"\u2285",nsupE:"\u2AC6\u0338",nsupe:"\u2289",nsupset:"\u2283\u20D2",nsupseteq:"\u2289",nsupseteqq:"\u2AC6\u0338",ntgl:"\u2279",ntilde:"\xF1",ntlg:"\u2278",ntriangleleft:"\u22EA",ntrianglelefteq:"\u22EC",ntriangleright:"\u22EB",ntrianglerighteq:"\u22ED",nu:"\u03BD",num:"#",numero:"\u2116",numsp:"\u2007",nvDash:"\u22AD",nvHarr:"\u2904",nvap:"\u224D\u20D2",nvdash:"\u22AC",nvge:"\u2265\u20D2",nvgt:">\u20D2",nvinfin:"\u29DE",nvlArr:"\u2902",nvle:"\u2264\u20D2",nvlt:"<\u20D2",nvltrie:"\u22B4\u20D2",nvrArr:"\u2903",nvrtrie:"\u22B5\u20D2",nvsim:"\u223C\u20D2",nwArr:"\u21D6",nwarhk:"\u2923",nwarr:"\u2196",nwarrow:"\u2196",nwnear:"\u2927",oS:"\u24C8",oacute:"\xF3",oast:"\u229B",ocir:"\u229A",ocirc:"\xF4",ocy:"\u043E",odash:"\u229D",odblac:"\u0151",odiv:"\u2A38",odot:"\u2299",odsold:"\u29BC",oelig:"\u0153",ofcir:"\u29BF",ofr:"\uD835\uDD2C",ogon:"\u02DB",ograve:"\xF2",ogt:"\u29C1",ohbar:"\u29B5",ohm:"\u03A9",oint:"\u222E",olarr:"\u21BA",olcir:"\u29BE",olcross:"\u29BB",oline:"\u203E",olt:"\u29C0",omacr:"\u014D",omega:"\u03C9",omicron:"\u03BF",omid:"\u29B6",ominus:"\u2296",oopf:"\uD835\uDD60",opar:"\u29B7",operp:"\u29B9",oplus:"\u2295",or:"\u2228",orarr:"\u21BB",ord:"\u2A5D",order:"\u2134",orderof:"\u2134",ordf:"\xAA",ordm:"\xBA",origof:"\u22B6",oror:"\u2A56",orslope:"\u2A57",orv:"\u2A5B",oscr:"\u2134",oslash:"\xF8",osol:"\u2298",otilde:"\xF5",otimes:"\u2297",otimesas:"\u2A36",ouml:"\xF6",ovbar:"\u233D",par:"\u2225",para:"\xB6",parallel:"\u2225",parsim:"\u2AF3",parsl:"\u2AFD",part:"\u2202",pcy:"\u043F",percnt:"%",period:".",permil:"\u2030",perp:"\u22A5",pertenk:"\u2031",pfr:"\uD835\uDD2D",phi:"\u03C6",phiv:"\u03D5",phmmat:"\u2133",phone:"\u260E",pi:"\u03C0",pitchfork:"\u22D4",piv:"\u03D6",planck:"\u210F",planckh:"\u210E",plankv:"\u210F",plus:"+",plusacir:"\u2A23",plusb:"\u229E",pluscir:"\u2A22",plusdo:"\u2214",plusdu:"\u2A25",pluse:"\u2A72",plusmn:"\xB1",plussim:"\u2A26",plustwo:"\u2A27",pm:"\xB1",pointint:"\u2A15",popf:"\uD835\uDD61",pound:"\xA3",pr:"\u227A",prE:"\u2AB3",prap:"\u2AB7",prcue:"\u227C",pre:"\u2AAF",prec:"\u227A",precapprox:"\u2AB7",preccurlyeq:"\u227C",preceq:"\u2AAF",precnapprox:"\u2AB9",precneqq:"\u2AB5",precnsim:"\u22E8",precsim:"\u227E",prime:"\u2032",primes:"\u2119",prnE:"\u2AB5",prnap:"\u2AB9",prnsim:"\u22E8",prod:"\u220F",profalar:"\u232E",profline:"\u2312",profsurf:"\u2313",prop:"\u221D",propto:"\u221D",prsim:"\u227E",prurel:"\u22B0",pscr:"\uD835\uDCC5",psi:"\u03C8",puncsp:"\u2008",qfr:"\uD835\uDD2E",qint:"\u2A0C",qopf:"\uD835\uDD62",qprime:"\u2057",qscr:"\uD835\uDCC6",quaternions:"\u210D",quatint:"\u2A16",quest:"?",questeq:"\u225F",quot:'"',rAarr:"\u21DB",rArr:"\u21D2",rAtail:"\u291C",rBarr:"\u290F",rHar:"\u2964",race:"\u223D\u0331",racute:"\u0155",radic:"\u221A",raemptyv:"\u29B3",rang:"\u27E9",rangd:"\u2992",range:"\u29A5",rangle:"\u27E9",raquo:"\xBB",rarr:"\u2192",rarrap:"\u2975",rarrb:"\u21E5",rarrbfs:"\u2920",rarrc:"\u2933",rarrfs:"\u291E",rarrhk:"\u21AA",rarrlp:"\u21AC",rarrpl:"\u2945",rarrsim:"\u2974",rarrtl:"\u21A3",rarrw:"\u219D",ratail:"\u291A",ratio:"\u2236",rationals:"\u211A",rbarr:"\u290D",rbbrk:"\u2773",rbrace:"}",rbrack:"]",rbrke:"\u298C",rbrksld:"\u298E",rbrkslu:"\u2990",rcaron:"\u0159",rcedil:"\u0157",rceil:"\u2309",rcub:"}",rcy:"\u0440",rdca:"\u2937",rdldhar:"\u2969",rdquo:"\u201D",rdquor:"\u201D",rdsh:"\u21B3",real:"\u211C",realine:"\u211B",realpart:"\u211C",reals:"\u211D",rect:"\u25AD",reg:"\xAE",rfisht:"\u297D",rfloor:"\u230B",rfr:"\uD835\uDD2F",rhard:"\u21C1",rharu:"\u21C0",rharul:"\u296C",rho:"\u03C1",rhov:"\u03F1",rightarrow:"\u2192",rightarrowtail:"\u21A3",rightharpoondown:"\u21C1",rightharpoonup:"\u21C0",rightleftarrows:"\u21C4",rightleftharpoons:"\u21CC",rightrightarrows:"\u21C9",rightsquigarrow:"\u219D",rightthreetimes:"\u22CC",ring:"\u02DA",risingdotseq:"\u2253",rlarr:"\u21C4",rlhar:"\u21CC",rlm:"\u200F",rmoust:"\u23B1",rmoustache:"\u23B1",rnmid:"\u2AEE",roang:"\u27ED",roarr:"\u21FE",robrk:"\u27E7",ropar:"\u2986",ropf:"\uD835\uDD63",roplus:"\u2A2E",rotimes:"\u2A35",rpar:")",rpargt:"\u2994",rppolint:"\u2A12",rrarr:"\u21C9",rsaquo:"\u203A",rscr:"\uD835\uDCC7",rsh:"\u21B1",rsqb:"]",rsquo:"\u2019",rsquor:"\u2019",rthree:"\u22CC",rtimes:"\u22CA",rtri:"\u25B9",rtrie:"\u22B5",rtrif:"\u25B8",rtriltri:"\u29CE",ruluhar:"\u2968",rx:"\u211E",sacute:"\u015B",sbquo:"\u201A",sc:"\u227B",scE:"\u2AB4",scap:"\u2AB8",scaron:"\u0161",sccue:"\u227D",sce:"\u2AB0",scedil:"\u015F",scirc:"\u015D",scnE:"\u2AB6",scnap:"\u2ABA",scnsim:"\u22E9",scpolint:"\u2A13",scsim:"\u227F",scy:"\u0441",sdot:"\u22C5",sdotb:"\u22A1",sdote:"\u2A66",seArr:"\u21D8",searhk:"\u2925",searr:"\u2198",searrow:"\u2198",sect:"\xA7",semi:";",seswar:"\u2929",setminus:"\u2216",setmn:"\u2216",sext:"\u2736",sfr:"\uD835\uDD30",sfrown:"\u2322",sharp:"\u266F",shchcy:"\u0449",shcy:"\u0448",shortmid:"\u2223",shortparallel:"\u2225",shy:"\xAD",sigma:"\u03C3",sigmaf:"\u03C2",sigmav:"\u03C2",sim:"\u223C",simdot:"\u2A6A",sime:"\u2243",simeq:"\u2243",simg:"\u2A9E",simgE:"\u2AA0",siml:"\u2A9D",simlE:"\u2A9F",simne:"\u2246",simplus:"\u2A24",simrarr:"\u2972",slarr:"\u2190",smallsetminus:"\u2216",smashp:"\u2A33",smeparsl:"\u29E4",smid:"\u2223",smile:"\u2323",smt:"\u2AAA",smte:"\u2AAC",smtes:"\u2AAC\uFE00",softcy:"\u044C",sol:"/",solb:"\u29C4",solbar:"\u233F",sopf:"\uD835\uDD64",spades:"\u2660",spadesuit:"\u2660",spar:"\u2225",sqcap:"\u2293",sqcaps:"\u2293\uFE00",sqcup:"\u2294",sqcups:"\u2294\uFE00",sqsub:"\u228F",sqsube:"\u2291",sqsubset:"\u228F",sqsubseteq:"\u2291",sqsup:"\u2290",sqsupe:"\u2292",sqsupset:"\u2290",sqsupseteq:"\u2292",squ:"\u25A1",square:"\u25A1",squarf:"\u25AA",squf:"\u25AA",srarr:"\u2192",sscr:"\uD835\uDCC8",ssetmn:"\u2216",ssmile:"\u2323",sstarf:"\u22C6",star:"\u2606",starf:"\u2605",straightepsilon:"\u03F5",straightphi:"\u03D5",strns:"\xAF",sub:"\u2282",subE:"\u2AC5",subdot:"\u2ABD",sube:"\u2286",subedot:"\u2AC3",submult:"\u2AC1",subnE:"\u2ACB",subne:"\u228A",subplus:"\u2ABF",subrarr:"\u2979",subset:"\u2282",subseteq:"\u2286",subseteqq:"\u2AC5",subsetneq:"\u228A",subsetneqq:"\u2ACB",subsim:"\u2AC7",subsub:"\u2AD5",subsup:"\u2AD3",succ:"\u227B",succapprox:"\u2AB8",succcurlyeq:"\u227D",succeq:"\u2AB0",succnapprox:"\u2ABA",succneqq:"\u2AB6",succnsim:"\u22E9",succsim:"\u227F",sum:"\u2211",sung:"\u266A",sup1:"\xB9",sup2:"\xB2",sup3:"\xB3",sup:"\u2283",supE:"\u2AC6",supdot:"\u2ABE",supdsub:"\u2AD8",supe:"\u2287",supedot:"\u2AC4",suphsol:"\u27C9",suphsub:"\u2AD7",suplarr:"\u297B",supmult:"\u2AC2",supnE:"\u2ACC",supne:"\u228B",supplus:"\u2AC0",supset:"\u2283",supseteq:"\u2287",supseteqq:"\u2AC6",supsetneq:"\u228B",supsetneqq:"\u2ACC",supsim:"\u2AC8",supsub:"\u2AD4",supsup:"\u2AD6",swArr:"\u21D9",swarhk:"\u2926",swarr:"\u2199",swarrow:"\u2199",swnwar:"\u292A",szlig:"\xDF",target:"\u2316",tau:"\u03C4",tbrk:"\u23B4",tcaron:"\u0165",tcedil:"\u0163",tcy:"\u0442",tdot:"\u20DB",telrec:"\u2315",tfr:"\uD835\uDD31",there4:"\u2234",therefore:"\u2234",theta:"\u03B8",thetasym:"\u03D1",thetav:"\u03D1",thickapprox:"\u2248",thicksim:"\u223C",thinsp:"\u2009",thkap:"\u2248",thksim:"\u223C",thorn:"\xFE",tilde:"\u02DC",times:"\xD7",timesb:"\u22A0",timesbar:"\u2A31",timesd:"\u2A30",tint:"\u222D",toea:"\u2928",top:"\u22A4",topbot:"\u2336",topcir:"\u2AF1",topf:"\uD835\uDD65",topfork:"\u2ADA",tosa:"\u2929",tprime:"\u2034",trade:"\u2122",triangle:"\u25B5",triangledown:"\u25BF",triangleleft:"\u25C3",trianglelefteq:"\u22B4",triangleq:"\u225C",triangleright:"\u25B9",trianglerighteq:"\u22B5",tridot:"\u25EC",trie:"\u225C",triminus:"\u2A3A",triplus:"\u2A39",trisb:"\u29CD",tritime:"\u2A3B",trpezium:"\u23E2",tscr:"\uD835\uDCC9",tscy:"\u0446",tshcy:"\u045B",tstrok:"\u0167",twixt:"\u226C",twoheadleftarrow:"\u219E",twoheadrightarrow:"\u21A0",uArr:"\u21D1",uHar:"\u2963",uacute:"\xFA",uarr:"\u2191",ubrcy:"\u045E",ubreve:"\u016D",ucirc:"\xFB",ucy:"\u0443",udarr:"\u21C5",udblac:"\u0171",udhar:"\u296E",ufisht:"\u297E",ufr:"\uD835\uDD32",ugrave:"\xF9",uharl:"\u21BF",uharr:"\u21BE",uhblk:"\u2580",ulcorn:"\u231C",ulcorner:"\u231C",ulcrop:"\u230F",ultri:"\u25F8",umacr:"\u016B",uml:"\xA8",uogon:"\u0173",uopf:"\uD835\uDD66",uparrow:"\u2191",updownarrow:"\u2195",upharpoonleft:"\u21BF",upharpoonright:"\u21BE",uplus:"\u228E",upsi:"\u03C5",upsih:"\u03D2",upsilon:"\u03C5",upuparrows:"\u21C8",urcorn:"\u231D",urcorner:"\u231D",urcrop:"\u230E",uring:"\u016F",urtri:"\u25F9",uscr:"\uD835\uDCCA",utdot:"\u22F0",utilde:"\u0169",utri:"\u25B5",utrif:"\u25B4",uuarr:"\u21C8",uuml:"\xFC",uwangle:"\u29A7",vArr:"\u21D5",vBar:"\u2AE8",vBarv:"\u2AE9",vDash:"\u22A8",vangrt:"\u299C",varepsilon:"\u03F5",varkappa:"\u03F0",varnothing:"\u2205",varphi:"\u03D5",varpi:"\u03D6",varpropto:"\u221D",varr:"\u2195",varrho:"\u03F1",varsigma:"\u03C2",varsubsetneq:"\u228A\uFE00",varsubsetneqq:"\u2ACB\uFE00",varsupsetneq:"\u228B\uFE00",varsupsetneqq:"\u2ACC\uFE00",vartheta:"\u03D1",vartriangleleft:"\u22B2",vartriangleright:"\u22B3",vcy:"\u0432",vdash:"\u22A2",vee:"\u2228",veebar:"\u22BB",veeeq:"\u225A",vellip:"\u22EE",verbar:"|",vert:"|",vfr:"\uD835\uDD33",vltri:"\u22B2",vnsub:"\u2282\u20D2",vnsup:"\u2283\u20D2",vopf:"\uD835\uDD67",vprop:"\u221D",vrtri:"\u22B3",vscr:"\uD835\uDCCB",vsubnE:"\u2ACB\uFE00",vsubne:"\u228A\uFE00",vsupnE:"\u2ACC\uFE00",vsupne:"\u228B\uFE00",vzigzag:"\u299A",wcirc:"\u0175",wedbar:"\u2A5F",wedge:"\u2227",wedgeq:"\u2259",weierp:"\u2118",wfr:"\uD835\uDD34",wopf:"\uD835\uDD68",wp:"\u2118",wr:"\u2240",wreath:"\u2240",wscr:"\uD835\uDCCC",xcap:"\u22C2",xcirc:"\u25EF",xcup:"\u22C3",xdtri:"\u25BD",xfr:"\uD835\uDD35",xhArr:"\u27FA",xharr:"\u27F7",xi:"\u03BE",xlArr:"\u27F8",xlarr:"\u27F5",xmap:"\u27FC",xnis:"\u22FB",xodot:"\u2A00",xopf:"\uD835\uDD69",xoplus:"\u2A01",xotime:"\u2A02",xrArr:"\u27F9",xrarr:"\u27F6",xscr:"\uD835\uDCCD",xsqcup:"\u2A06",xuplus:"\u2A04",xutri:"\u25B3",xvee:"\u22C1",xwedge:"\u22C0",yacute:"\xFD",yacy:"\u044F",ycirc:"\u0177",ycy:"\u044B",yen:"\xA5",yfr:"\uD835\uDD36",yicy:"\u0457",yopf:"\uD835\uDD6A",yscr:"\uD835\uDCCE",yucy:"\u044E",yuml:"\xFF",zacute:"\u017A",zcaron:"\u017E",zcy:"\u0437",zdot:"\u017C",zeetrf:"\u2128",zeta:"\u03B6",zfr:"\uD835\uDD37",zhcy:"\u0436",zigrarr:"\u21DD",zopf:"\uD835\uDD6B",zscr:"\uD835\uDCCF",zwj:"\u200D",zwnj:"\u200C"}});function Wc(e){return Rie.call(k1,e)?k1[e]:!1}var Rie;var fg=x(()=>{T6();Rie={}.hasOwnProperty});var w;var C6=x(()=>{w={carriageReturn:-5,lineFeed:-4,carriageReturnLineFeed:-3,horizontalTab:-2,virtualSpace:-1,eof:null,nul:0,soh:1,stx:2,etx:3,eot:4,enq:5,ack:6,bel:7,bs:8,ht:9,lf:10,vt:11,ff:12,cr:13,so:14,si:15,dle:16,dc1:17,dc2:18,dc3:19,dc4:20,nak:21,syn:22,etb:23,can:24,em:25,sub:26,esc:27,fs:28,gs:29,rs:30,us:31,space:32,exclamationMark:33,quotationMark:34,numberSign:35,dollarSign:36,percentSign:37,ampersand:38,apostrophe:39,leftParenthesis:40,rightParenthesis:41,asterisk:42,plusSign:43,comma:44,dash:45,dot:46,slash:47,digit0:48,digit1:49,digit2:50,digit3:51,digit4:52,digit5:53,digit6:54,digit7:55,digit8:56,digit9:57,colon:58,semicolon:59,lessThan:60,equalsTo:61,greaterThan:62,questionMark:63,atSign:64,uppercaseA:65,uppercaseB:66,uppercaseC:67,uppercaseD:68,uppercaseE:69,uppercaseF:70,uppercaseG:71,uppercaseH:72,uppercaseI:73,uppercaseJ:74,uppercaseK:75,uppercaseL:76,uppercaseM:77,uppercaseN:78,uppercaseO:79,uppercaseP:80,uppercaseQ:81,uppercaseR:82,uppercaseS:83,uppercaseT:84,uppercaseU:85,uppercaseV:86,uppercaseW:87,uppercaseX:88,uppercaseY:89,uppercaseZ:90,leftSquareBracket:91,backslash:92,rightSquareBracket:93,caret:94,underscore:95,graveAccent:96,lowercaseA:97,lowercaseB:98,lowercaseC:99,lowercaseD:100,lowercaseE:101,lowercaseF:102,lowercaseG:103,lowercaseH:104,lowercaseI:105,lowercaseJ:106,lowercaseK:107,lowercaseL:108,lowercaseM:109,lowercaseN:110,lowercaseO:111,lowercaseP:112,lowercaseQ:113,lowercaseR:114,lowercaseS:115,lowercaseT:116,lowercaseU:117,lowercaseV:118,lowercaseW:119,lowercaseX:120,lowercaseY:121,lowercaseZ:122,leftCurlyBrace:123,verticalBar:124,rightCurlyBrace:125,tilde:126,del:127,byteOrderMarker:65279,replacementCharacter:65533}});var be;var $6=x(()=>{be={attentionSideAfter:2,attentionSideBefore:1,atxHeadingOpeningFenceSizeMax:6,autolinkDomainSizeMax:63,autolinkSchemeSizeMax:32,cdataOpeningString:"CDATA[",characterGroupPunctuation:2,characterGroupWhitespace:1,characterReferenceDecimalSizeMax:7,characterReferenceHexadecimalSizeMax:6,characterReferenceNamedSizeMax:31,codeFencedSequenceSizeMin:3,contentTypeContent:"content",contentTypeDocument:"document",contentTypeFlow:"flow",contentTypeString:"string",contentTypeText:"text",hardBreakPrefixSizeMin:2,htmlBasic:6,htmlCdata:5,htmlComment:2,htmlComplete:7,htmlDeclaration:4,htmlInstruction:3,htmlRawSizeMax:8,htmlRaw:1,linkResourceDestinationBalanceMax:32,linkReferenceSizeMax:999,listItemValueSizeMax:10,numericBaseDecimal:10,numericBaseHexadecimal:16,tabSize:4,thematicBreakMarkerCountMin:3,v8MaxSafeChunkSize:1e4}});var S;var O6=x(()=>{S={data:"data",whitespace:"whitespace",lineEnding:"lineEnding",lineEndingBlank:"lineEndingBlank",linePrefix:"linePrefix",lineSuffix:"lineSuffix",atxHeading:"atxHeading",atxHeadingSequence:"atxHeadingSequence",atxHeadingText:"atxHeadingText",autolink:"autolink",autolinkEmail:"autolinkEmail",autolinkMarker:"autolinkMarker",autolinkProtocol:"autolinkProtocol",characterEscape:"characterEscape",characterEscapeValue:"characterEscapeValue",characterReference:"characterReference",characterReferenceMarker:"characterReferenceMarker",characterReferenceMarkerNumeric:"characterReferenceMarkerNumeric",characterReferenceMarkerHexadecimal:"characterReferenceMarkerHexadecimal",characterReferenceValue:"characterReferenceValue",codeFenced:"codeFenced",codeFencedFence:"codeFencedFence",codeFencedFenceSequence:"codeFencedFenceSequence",codeFencedFenceInfo:"codeFencedFenceInfo",codeFencedFenceMeta:"codeFencedFenceMeta",codeFlowValue:"codeFlowValue",codeIndented:"codeIndented",codeText:"codeText",codeTextData:"codeTextData",codeTextPadding:"codeTextPadding",codeTextSequence:"codeTextSequence",content:"content",definition:"definition",definitionDestination:"definitionDestination",definitionDestinationLiteral:"definitionDestinationLiteral",definitionDestinationLiteralMarker:"definitionDestinationLiteralMarker",definitionDestinationRaw:"definitionDestinationRaw",definitionDestinationString:"definitionDestinationString",definitionLabel:"definitionLabel",definitionLabelMarker:"definitionLabelMarker",definitionLabelString:"definitionLabelString",definitionMarker:"definitionMarker",definitionTitle:"definitionTitle",definitionTitleMarker:"definitionTitleMarker",definitionTitleString:"definitionTitleString",emphasis:"emphasis",emphasisSequence:"emphasisSequence",emphasisText:"emphasisText",escapeMarker:"escapeMarker",hardBreakEscape:"hardBreakEscape",hardBreakTrailing:"hardBreakTrailing",htmlFlow:"htmlFlow",htmlFlowData:"htmlFlowData",htmlText:"htmlText",htmlTextData:"htmlTextData",image:"image",label:"label",labelText:"labelText",labelLink:"labelLink",labelImage:"labelImage",labelMarker:"labelMarker",labelImageMarker:"labelImageMarker",labelEnd:"labelEnd",link:"link",paragraph:"paragraph",reference:"reference",referenceMarker:"referenceMarker",referenceString:"referenceString",resource:"resource",resourceDestination:"resourceDestination",resourceDestinationLiteral:"resourceDestinationLiteral",resourceDestinationLiteralMarker:"resourceDestinationLiteralMarker",resourceDestinationRaw:"resourceDestinationRaw",resourceDestinationString:"resourceDestinationString",resourceMarker:"resourceMarker",resourceTitle:"resourceTitle",resourceTitleMarker:"resourceTitleMarker",resourceTitleString:"resourceTitleString",setextHeading:"setextHeading",setextHeadingText:"setextHeadingText",setextHeadingLine:"setextHeadingLine",setextHeadingLineSequence:"setextHeadingLineSequence",strong:"strong",strongSequence:"strongSequence",strongText:"strongText",thematicBreak:"thematicBreak",thematicBreakSequence:"thematicBreakSequence",blockQuote:"blockQuote",blockQuotePrefix:"blockQuotePrefix",blockQuoteMarker:"blockQuoteMarker",blockQuotePrefixWhitespace:"blockQuotePrefixWhitespace",listOrdered:"listOrdered",listUnordered:"listUnordered",listItemIndent:"listItemIndent",listItemMarker:"listItemMarker",listItemPrefix:"listItemPrefix",listItemPrefixWhitespace:"listItemPrefixWhitespace",listItemValue:"listItemValue",chunkDocument:"chunkDocument",chunkContent:"chunkContent",chunkFlow:"chunkFlow",chunkText:"chunkText",chunkString:"chunkString"}});var on;var R6=x(()=>{on={ht:"\t",lf:`
273
+ `,cr:"\r",space:" ",exclamationMark:"!",quotationMark:'"',numberSign:"#",dollarSign:"$",percentSign:"%",ampersand:"&",apostrophe:"'",leftParenthesis:"(",rightParenthesis:")",asterisk:"*",plusSign:"+",comma:",",dash:"-",dot:".",slash:"/",digit0:"0",digit1:"1",digit2:"2",digit3:"3",digit4:"4",digit5:"5",digit6:"6",digit7:"7",digit8:"8",digit9:"9",colon:":",semicolon:";",lessThan:"<",equalsTo:"=",greaterThan:">",questionMark:"?",atSign:"@",uppercaseA:"A",uppercaseB:"B",uppercaseC:"C",uppercaseD:"D",uppercaseE:"E",uppercaseF:"F",uppercaseG:"G",uppercaseH:"H",uppercaseI:"I",uppercaseJ:"J",uppercaseK:"K",uppercaseL:"L",uppercaseM:"M",uppercaseN:"N",uppercaseO:"O",uppercaseP:"P",uppercaseQ:"Q",uppercaseR:"R",uppercaseS:"S",uppercaseT:"T",uppercaseU:"U",uppercaseV:"V",uppercaseW:"W",uppercaseX:"X",uppercaseY:"Y",uppercaseZ:"Z",leftSquareBracket:"[",backslash:"\\",rightSquareBracket:"]",caret:"^",underscore:"_",graveAccent:"`",lowercaseA:"a",lowercaseB:"b",lowercaseC:"c",lowercaseD:"d",lowercaseE:"e",lowercaseF:"f",lowercaseG:"g",lowercaseH:"h",lowercaseI:"i",lowercaseJ:"j",lowercaseK:"k",lowercaseL:"l",lowercaseM:"m",lowercaseN:"n",lowercaseO:"o",lowercaseP:"p",lowercaseQ:"q",lowercaseR:"r",lowercaseS:"s",lowercaseT:"t",lowercaseU:"u",lowercaseV:"v",lowercaseW:"w",lowercaseX:"x",lowercaseY:"y",lowercaseZ:"z",leftCurlyBrace:"{",verticalBar:"|",rightCurlyBrace:"}",tilde:"~",replacementCharacter:"\uFFFD"}});var Fe=x(()=>{C6();$6();O6();R6()});function nr(e,t,r,i){let n=e.length,o=0,s;if(t<0)t=-t>n?0:n+t;else t=t>n?n:t;if(r=r>0?r:0,i.length<be.v8MaxSafeChunkSize)s=Array.from(i),s.unshift(t,r),e.splice(...s);else{if(r)e.splice(t,r);while(o<i.length)s=i.slice(o,o+be.v8MaxSafeChunkSize),s.unshift(t,0),e.splice(...s),o+=be.v8MaxSafeChunkSize,t+=be.v8MaxSafeChunkSize}}function Nr(e,t){if(e.length>0)return nr(e,e.length,0,t),e;return t}var zo=x(()=>{Fe()});function z6(e){let t={},r=-1;while(++r<e.length)Pie(t,e[r]);return t}function Pie(e,t){let r;for(r in t){let n=(P6.call(e,r)?e[r]:void 0)||(e[r]={}),o=t[r],s;if(o)for(s in o){if(!P6.call(n,s))n[s]=[];let a=o[s];zie(n[s],Array.isArray(a)?a:a?[a]:[])}}}function zie(e,t){let r=-1,i=[];while(++r<t.length)(t[r].add==="after"?e:i).push(t[r]);nr(e,0,0,i)}var P6;var N6=x(()=>{zo();P6={}.hasOwnProperty});function pg(e,t){let r=Number.parseInt(e,t);if(r<w.ht||r===w.vt||r>w.cr&&r<w.space||r>w.tilde&&r<160||r>55295&&r<57344||r>64975&&r<65008||(r&65535)===65535||(r&65535)===65534||r>1114111)return on.replacementCharacter;return String.fromCodePoint(r)}var E1=x(()=>{Fe()});function Ni(e){return e.replace(/[\t\n\r ]+/g,on.space).replace(/^ | $/g,"").toLowerCase().toUpperCase()}var mg=x(()=>{Fe()});function Nd(e){return e!==null&&(e<w.space||e===w.del)}function ve(e){return e!==null&&e<w.horizontalTab}function $t(e){return e!==null&&(e<w.nul||e===w.space)}function Me(e){return e===w.horizontalTab||e===w.virtualSpace||e===w.space}function No(e){return t;function t(r){return r!==null&&r>-1&&e.test(String.fromCharCode(r))}}var sn,Dr,D6,Dd,L6,B6,j6,q6;var ot=x(()=>{Fe();sn=No(/[A-Za-z]/),Dr=No(/[\dA-Za-z]/),D6=No(/[#-'*+\--9=?A-Z^-~]/);Dd=No(/\d/),L6=No(/[\dA-Fa-f]/),B6=No(/[!-/:-@[-`{-~]/);j6=No(/\p{P}|\p{S}/u),q6=No(/\s/)});function Ze(e,t,r,i){let n=i?i-1:Number.POSITIVE_INFINITY,o=0;return s;function s(c){if(Me(c))return e.enter(r),a(c);return t(c)}function a(c){if(Me(c)&&o++<n)return e.consume(c),a;return e.exit(r),t(c)}}var Gt=x(()=>{ot()});function Nie(e){let t=e.attempt(this.parser.constructs.contentInitial,i,n),r;return t;function i(a){if(B(a===w.eof||ve(a),"expected eol or eof"),a===w.eof){e.consume(a);return}return e.enter(S.lineEnding),e.consume(a),e.exit(S.lineEnding),Ze(e,t,S.linePrefix)}function n(a){return B(a!==w.eof&&!ve(a),"expected anything other than a line ending or EOF"),e.enter(S.paragraph),o(a)}function o(a){let c=e.enter(S.chunkText,{contentType:be.contentTypeText,previous:r});if(r)r.next=c;return r=c,s(a)}function s(a){if(a===w.eof){e.exit(S.chunkText),e.exit(S.paragraph),e.consume(a);return}if(ve(a))return e.consume(a),e.exit(S.chunkText),o;return e.consume(a),s}}var U6;var M6=x(()=>{tt();Gt();ot();Fe();U6={tokenize:Nie}});function Die(e){let t=this,r=[],i=0,n,o,s;return a;function a(T){if(i<r.length){let z=r[i];return t.containerState=z[1],B(z[0].continuation,"expected `continuation` to be defined on container construct"),e.attempt(z[0].continuation,c,l)(T)}return l(T)}function c(T){if(B(t.containerState,"expected `containerState` to be defined after continuation"),i++,t.containerState._closeFlow){if(t.containerState._closeFlow=void 0,n)A();let z=t.events.length,j=z,E;while(j--)if(t.events[j][0]==="exit"&&t.events[j][1].type===S.chunkFlow){E=t.events[j][1].end;break}B(E,"could not find previous flow chunk"),v(i);let Z=z;while(Z<t.events.length)t.events[Z][1].end={...E},Z++;return nr(t.events,j+1,0,t.events.slice(z)),t.events.length=Z,l(T)}return a(T)}function l(T){if(i===r.length){if(!n)return p(T);if(n.currentConstruct&&n.currentConstruct.concrete)return y(T);t.interrupt=Boolean(n.currentConstruct&&!n._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(F6,u,d)(T)}function u(T){if(n)A();return v(i),p(T)}function d(T){return t.parser.lazy[t.now().line]=i!==r.length,s=t.now().offset,y(T)}function p(T){return t.containerState={},e.attempt(F6,m,y)(T)}function m(T){return B(t.currentConstruct,"expected `currentConstruct` to be defined on tokenizer"),B(t.containerState,"expected `containerState` to be defined on tokenizer"),i++,r.push([t.currentConstruct,t.containerState]),p(T)}function y(T){if(T===w.eof){if(n)A();v(0),e.consume(T);return}return n=n||t.parser.flow(t.now()),e.enter(S.chunkFlow,{_tokenizer:n,contentType:be.contentTypeFlow,previous:o}),g(T)}function g(T){if(T===w.eof){b(e.exit(S.chunkFlow),!0),v(0),e.consume(T);return}if(ve(T))return e.consume(T),b(e.exit(S.chunkFlow)),i=0,t.interrupt=void 0,a;return e.consume(T),g}function b(T,z){B(n,"expected `childFlow` to be defined when continuing");let j=t.sliceStream(T);if(z)j.push(null);if(T.previous=o,o)o.next=T;if(o=T,n.defineSkip(T.start),n.write(j),t.parser.lazy[T.start.line]){let E=n.events.length;while(E--)if(n.events[E][1].start.offset<s&&(!n.events[E][1].end||n.events[E][1].end.offset>s))return;let Z=t.events.length,D=Z,H,X;while(D--)if(t.events[D][0]==="exit"&&t.events[D][1].type===S.chunkFlow){if(H){X=t.events[D][1].end;break}H=!0}B(X,"could not find previous flow chunk"),v(i),E=Z;while(E<t.events.length)t.events[E][1].end={...X},E++;nr(t.events,D+1,0,t.events.slice(Z)),t.events.length=E}}function v(T){let z=r.length;while(z-- >T){let j=r[z];t.containerState=j[1],B(j[0].exit,"expected `exit` to be defined on container construct"),j[0].exit.call(t,e)}r.length=T}function A(){B(t.containerState,"expected `containerState` to be defined when closing flow"),B(n,"expected `childFlow` to be defined when closing it"),n.write([w.eof]),o=void 0,n=void 0,t.containerState._closeFlow=void 0}}function Lie(e,t,r){return B(this.parser.constructs.disable.null,"expected `disable.null` to be populated"),Ze(e,e.attempt(this.parser.constructs.document,t,r),S.linePrefix,this.parser.constructs.disable.null.includes("codeIndented")?void 0:be.tabSize)}var Z6,F6;var H6=x(()=>{tt();Gt();ot();zo();Fe();Z6={tokenize:Die},F6={tokenize:Lie}});function Gc(e){if(e===w.eof||$t(e)||q6(e))return be.characterGroupWhitespace;if(j6(e))return be.characterGroupPunctuation}var I1=x(()=>{ot();Fe()});function Qc(e,t,r){let i=[],n=-1;while(++n<e.length){let o=e[n].resolveAll;if(o&&!i.includes(o))t=o(t,r),i.push(o)}return t}function Bie(e,t){let r=-1,i,n,o,s,a,c,l,u;while(++r<e.length)if(e[r][0]==="enter"&&e[r][1].type==="attentionSequence"&&e[r][1]._close){i=r;while(i--)if(e[i][0]==="exit"&&e[i][1].type==="attentionSequence"&&e[i][1]._open&&t.sliceSerialize(e[i][1]).charCodeAt(0)===t.sliceSerialize(e[r][1]).charCodeAt(0)){if((e[i][1]._close||e[r][1]._open)&&(e[r][1].end.offset-e[r][1].start.offset)%3&&!((e[i][1].end.offset-e[i][1].start.offset+e[r][1].end.offset-e[r][1].start.offset)%3))continue;c=e[i][1].end.offset-e[i][1].start.offset>1&&e[r][1].end.offset-e[r][1].start.offset>1?2:1;let d={...e[i][1].end},p={...e[r][1].start};if(K6(d,-c),K6(p,c),s={type:c>1?S.strongSequence:S.emphasisSequence,start:d,end:{...e[i][1].end}},a={type:c>1?S.strongSequence:S.emphasisSequence,start:{...e[r][1].start},end:p},o={type:c>1?S.strongText:S.emphasisText,start:{...e[i][1].end},end:{...e[r][1].start}},n={type:c>1?S.strong:S.emphasis,start:{...s.start},end:{...a.end}},e[i][1].end={...s.start},e[r][1].start={...a.end},l=[],e[i][1].end.offset-e[i][1].start.offset)l=Nr(l,[["enter",e[i][1],t],["exit",e[i][1],t]]);if(l=Nr(l,[["enter",n,t],["enter",s,t],["exit",s,t],["enter",o,t]]),B(t.parser.constructs.insideSpan.null,"expected `insideSpan` to be populated"),l=Nr(l,Qc(t.parser.constructs.insideSpan.null,e.slice(i+1,r),t)),l=Nr(l,[["exit",o,t],["enter",a,t],["exit",a,t],["exit",n,t]]),e[r][1].end.offset-e[r][1].start.offset)u=2,l=Nr(l,[["enter",e[r][1],t],["exit",e[r][1],t]]);else u=0;nr(e,i-1,r-i+3,l),r=i+l.length-u-2;break}}r=-1;while(++r<e.length)if(e[r][1].type==="attentionSequence")e[r][1].type="data";return e}function jie(e,t){let r=this.parser.constructs.attentionMarkers.null,i=this.previous,n=Gc(i),o;return s;function s(c){return B(c===w.asterisk||c===w.underscore,"expected asterisk or underscore"),o=c,e.enter("attentionSequence"),a(c)}function a(c){if(c===o)return e.consume(c),a;let l=e.exit("attentionSequence"),u=Gc(c);B(r,"expected `attentionMarkers` to be populated");let d=!u||u===be.characterGroupPunctuation&&n||r.includes(c),p=!n||n===be.characterGroupPunctuation&&u||r.includes(i);return l._open=Boolean(o===w.asterisk?d:d&&(n||!p)),l._close=Boolean(o===w.asterisk?p:p&&(u||!d)),t(c)}}function K6(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var Ld;var J6=x(()=>{tt();zo();I1();Fe();Ld={name:"attention",resolveAll:Bie,tokenize:jie}});function qie(e,t,r){let i=0;return n;function n(m){return B(m===w.lessThan,"expected `<`"),e.enter(S.autolink),e.enter(S.autolinkMarker),e.consume(m),e.exit(S.autolinkMarker),e.enter(S.autolinkProtocol),o}function o(m){if(sn(m))return e.consume(m),s;if(m===w.atSign)return r(m);return l(m)}function s(m){if(m===w.plusSign||m===w.dash||m===w.dot||Dr(m))return i=1,a(m);return l(m)}function a(m){if(m===w.colon)return e.consume(m),i=0,c;if((m===w.plusSign||m===w.dash||m===w.dot||Dr(m))&&i++<be.autolinkSchemeSizeMax)return e.consume(m),a;return i=0,l(m)}function c(m){if(m===w.greaterThan)return e.exit(S.autolinkProtocol),e.enter(S.autolinkMarker),e.consume(m),e.exit(S.autolinkMarker),e.exit(S.autolink),t;if(m===w.eof||m===w.space||m===w.lessThan||Nd(m))return r(m);return e.consume(m),c}function l(m){if(m===w.atSign)return e.consume(m),u;if(D6(m))return e.consume(m),l;return r(m)}function u(m){return Dr(m)?d(m):r(m)}function d(m){if(m===w.dot)return e.consume(m),i=0,u;if(m===w.greaterThan)return e.exit(S.autolinkProtocol).type=S.autolinkEmail,e.enter(S.autolinkMarker),e.consume(m),e.exit(S.autolinkMarker),e.exit(S.autolink),t;return p(m)}function p(m){if((m===w.dash||Dr(m))&&i++<be.autolinkDomainSizeMax){let y=m===w.dash?p:d;return e.consume(m),y}return r(m)}}var A1;var V6=x(()=>{tt();ot();Fe();A1={name:"autolink",tokenize:qie}});function Uie(e,t,r){return i;function i(o){return Me(o)?Ze(e,n,S.linePrefix)(o):n(o)}function n(o){return o===w.eof||ve(o)?t(o):r(o)}}var Do;var hg=x(()=>{Gt();ot();Fe();Do={partial:!0,tokenize:Uie}});function Mie(e,t,r){let i=this;return n;function n(s){if(s===w.greaterThan){let a=i.containerState;if(B(a,"expected `containerState` to be defined in container"),!a.open)e.enter(S.blockQuote,{_container:!0}),a.open=!0;return e.enter(S.blockQuotePrefix),e.enter(S.blockQuoteMarker),e.consume(s),e.exit(S.blockQuoteMarker),o}return r(s)}function o(s){if(Me(s))return e.enter(S.blockQuotePrefixWhitespace),e.consume(s),e.exit(S.blockQuotePrefixWhitespace),e.exit(S.blockQuotePrefix),t;return e.exit(S.blockQuotePrefix),t(s)}}function Fie(e,t,r){let i=this;return n;function n(s){if(Me(s))return B(i.parser.constructs.disable.null,"expected `disable.null` to be populated"),Ze(e,o,S.linePrefix,i.parser.constructs.disable.null.includes("codeIndented")?void 0:be.tabSize)(s);return o(s)}function o(s){return e.attempt(gg,t,r)(s)}}function Zie(e){e.exit(S.blockQuote)}var gg;var W6=x(()=>{tt();Gt();ot();Fe();gg={continuation:{tokenize:Fie},exit:Zie,name:"blockQuote",tokenize:Mie}});function Hie(e,t,r){return i;function i(o){return B(o===w.backslash,"expected `\\`"),e.enter(S.characterEscape),e.enter(S.escapeMarker),e.consume(o),e.exit(S.escapeMarker),n}function n(o){if(B6(o))return e.enter(S.characterEscapeValue),e.consume(o),e.exit(S.characterEscapeValue),e.exit(S.characterEscape),t;return r(o)}}var yg;var G6=x(()=>{tt();ot();Fe();yg={name:"characterEscape",tokenize:Hie}});function Kie(e,t,r){let i=this,n=0,o,s;return a;function a(d){return B(d===w.ampersand,"expected `&`"),e.enter(S.characterReference),e.enter(S.characterReferenceMarker),e.consume(d),e.exit(S.characterReferenceMarker),c}function c(d){if(d===w.numberSign)return e.enter(S.characterReferenceMarkerNumeric),e.consume(d),e.exit(S.characterReferenceMarkerNumeric),l;return e.enter(S.characterReferenceValue),o=be.characterReferenceNamedSizeMax,s=Dr,u(d)}function l(d){if(d===w.uppercaseX||d===w.lowercaseX)return e.enter(S.characterReferenceMarkerHexadecimal),e.consume(d),e.exit(S.characterReferenceMarkerHexadecimal),e.enter(S.characterReferenceValue),o=be.characterReferenceHexadecimalSizeMax,s=L6,u;return e.enter(S.characterReferenceValue),o=be.characterReferenceDecimalSizeMax,s=Dd,u(d)}function u(d){if(d===w.semicolon&&n){let p=e.exit(S.characterReferenceValue);if(s===Dr&&!Wc(i.sliceSerialize(p)))return r(d);return e.enter(S.characterReferenceMarker),e.consume(d),e.exit(S.characterReferenceMarker),e.exit(S.characterReference),t}if(s(d)&&n++<o)return e.consume(d),u;return r(d)}}var bg;var Q6=x(()=>{tt();fg();ot();Fe();bg={name:"characterReference",tokenize:Kie}});function Jie(e,t,r){let i=this,n={partial:!0,tokenize:j},o=0,s=0,a;return c;function c(E){return l(E)}function l(E){B(E===w.graveAccent||E===w.tilde,"expected `` ` `` or `~`");let Z=i.events[i.events.length-1];return o=Z&&Z[1].type===S.linePrefix?Z[2].sliceSerialize(Z[1],!0).length:0,a=E,e.enter(S.codeFenced),e.enter(S.codeFencedFence),e.enter(S.codeFencedFenceSequence),u(E)}function u(E){if(E===a)return s++,e.consume(E),u;if(s<be.codeFencedSequenceSizeMin)return r(E);return e.exit(S.codeFencedFenceSequence),Me(E)?Ze(e,d,S.whitespace)(E):d(E)}function d(E){if(E===w.eof||ve(E))return e.exit(S.codeFencedFence),i.interrupt?t(E):e.check(Y6,g,z)(E);return e.enter(S.codeFencedFenceInfo),e.enter(S.chunkString,{contentType:be.contentTypeString}),p(E)}function p(E){if(E===w.eof||ve(E))return e.exit(S.chunkString),e.exit(S.codeFencedFenceInfo),d(E);if(Me(E))return e.exit(S.chunkString),e.exit(S.codeFencedFenceInfo),Ze(e,m,S.whitespace)(E);if(E===w.graveAccent&&E===a)return r(E);return e.consume(E),p}function m(E){if(E===w.eof||ve(E))return d(E);return e.enter(S.codeFencedFenceMeta),e.enter(S.chunkString,{contentType:be.contentTypeString}),y(E)}function y(E){if(E===w.eof||ve(E))return e.exit(S.chunkString),e.exit(S.codeFencedFenceMeta),d(E);if(E===w.graveAccent&&E===a)return r(E);return e.consume(E),y}function g(E){return B(ve(E),"expected eol"),e.attempt(n,z,b)(E)}function b(E){return B(ve(E),"expected eol"),e.enter(S.lineEnding),e.consume(E),e.exit(S.lineEnding),v}function v(E){return o>0&&Me(E)?Ze(e,A,S.linePrefix,o+1)(E):A(E)}function A(E){if(E===w.eof||ve(E))return e.check(Y6,g,z)(E);return e.enter(S.codeFlowValue),T(E)}function T(E){if(E===w.eof||ve(E))return e.exit(S.codeFlowValue),A(E);return e.consume(E),T}function z(E){return e.exit(S.codeFenced),t(E)}function j(E,Z,D){let H=0;return X;function X(R){return B(ve(R),"expected eol"),E.enter(S.lineEnding),E.consume(R),E.exit(S.lineEnding),M}function M(R){return B(i.parser.constructs.disable.null,"expected `disable.null` to be populated"),E.enter(S.codeFencedFence),Me(R)?Ze(E,P,S.linePrefix,i.parser.constructs.disable.null.includes("codeIndented")?void 0:be.tabSize)(R):P(R)}function P(R){if(R===a)return E.enter(S.codeFencedFenceSequence),N(R);return D(R)}function N(R){if(R===a)return H++,E.consume(R),N;if(H>=s)return E.exit(S.codeFencedFenceSequence),Me(R)?Ze(E,I,S.whitespace)(R):I(R);return D(R)}function I(R){if(R===w.eof||ve(R))return E.exit(S.codeFencedFence),Z(R);return D(R)}}}function Vie(e,t,r){let i=this;return n;function n(s){if(s===w.eof)return r(s);return B(ve(s),"expected eol"),e.enter(S.lineEnding),e.consume(s),e.exit(S.lineEnding),o}function o(s){return i.parser.lazy[i.now().line]?r(s):t(s)}}var Y6,xg;var X6=x(()=>{tt();Gt();ot();Fe();Y6={partial:!0,tokenize:Vie},xg={concrete:!0,name:"codeFenced",tokenize:Jie}});function Gie(e,t,r){let i=this;return n;function n(l){return B(Me(l)),e.enter(S.codeIndented),Ze(e,o,S.linePrefix,be.tabSize+1)(l)}function o(l){let u=i.events[i.events.length-1];return u&&u[1].type===S.linePrefix&&u[2].sliceSerialize(u[1],!0).length>=be.tabSize?s(l):r(l)}function s(l){if(l===w.eof)return c(l);if(ve(l))return e.attempt(Wie,s,c)(l);return e.enter(S.codeFlowValue),a(l)}function a(l){if(l===w.eof||ve(l))return e.exit(S.codeFlowValue),s(l);return e.consume(l),a}function c(l){return e.exit(S.codeIndented),t(l)}}function Qie(e,t,r){let i=this;return n;function n(s){if(i.parser.lazy[i.now().line])return r(s);if(ve(s))return e.enter(S.lineEnding),e.consume(s),e.exit(S.lineEnding),n;return Ze(e,o,S.linePrefix,be.tabSize+1)(s)}function o(s){let a=i.events[i.events.length-1];return a&&a[1].type===S.linePrefix&&a[2].sliceSerialize(a[1],!0).length>=be.tabSize?t(s):ve(s)?n(s):r(s)}}var Bd,Wie;var ej=x(()=>{tt();Gt();ot();Fe();Bd={name:"codeIndented",tokenize:Gie},Wie={partial:!0,tokenize:Qie}});function Yie(e){let t=e.length-4,r=3,i,n;if((e[r][1].type===S.lineEnding||e[r][1].type==="space")&&(e[t][1].type===S.lineEnding||e[t][1].type==="space")){i=r;while(++i<t)if(e[i][1].type===S.codeTextData){e[r][1].type=S.codeTextPadding,e[t][1].type=S.codeTextPadding,r+=2,t-=2;break}}i=r-1,t++;while(++i<=t)if(n===void 0){if(i!==t&&e[i][1].type!==S.lineEnding)n=i}else if(i===t||e[i][1].type===S.lineEnding){if(e[n][1].type=S.codeTextData,i!==n+2)e[n][1].end=e[i-1][1].end,e.splice(n+2,i-n-2),t-=i-n-2,i=n+2;n=void 0}return e}function tj(e){return e!==w.graveAccent||this.events[this.events.length-1][1].type===S.characterEscape}function Xie(e,t,r){let i=this,n=0,o,s;return a;function a(p){return B(p===w.graveAccent,"expected `` ` ``"),B(tj.call(i,i.previous),"expected correct previous"),e.enter(S.codeText),e.enter(S.codeTextSequence),c(p)}function c(p){if(p===w.graveAccent)return e.consume(p),n++,c;return e.exit(S.codeTextSequence),l(p)}function l(p){if(p===w.eof)return r(p);if(p===w.space)return e.enter("space"),e.consume(p),e.exit("space"),l;if(p===w.graveAccent)return s=e.enter(S.codeTextSequence),o=0,d(p);if(ve(p))return e.enter(S.lineEnding),e.consume(p),e.exit(S.lineEnding),l;return e.enter(S.codeTextData),u(p)}function u(p){if(p===w.eof||p===w.space||p===w.graveAccent||ve(p))return e.exit(S.codeTextData),l(p);return e.consume(p),u}function d(p){if(p===w.graveAccent)return e.consume(p),o++,d;if(o===n)return e.exit(S.codeTextSequence),e.exit(S.codeText),t(p);return s.type=S.codeTextData,u(p)}}var T1;var rj=x(()=>{tt();ot();Fe();T1={name:"codeText",previous:tj,resolve:Yie,tokenize:Xie}});class C1{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");if(e<this.left.length)return this.left[e];return this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let r=t===null||t===void 0?Number.POSITIVE_INFINITY:t;if(r<this.left.length)return this.left.slice(e,r);if(e>this.left.length)return this.right.slice(this.right.length-r+this.left.length,this.right.length-e+this.left.length).reverse();return this.left.slice(e).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(e,t,r){let i=t||0;this.setCursor(Math.trunc(e));let n=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);if(r)jd(this.left,r);return n.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(e){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(e)}pushMany(e){this.setCursor(Number.POSITIVE_INFINITY),jd(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),jd(this.right,e.reverse())}setCursor(e){if(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0)return;if(e<this.left.length){let t=this.left.splice(e,Number.POSITIVE_INFINITY);jd(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,Number.POSITIVE_INFINITY);jd(this.left,t.reverse())}}}function jd(e,t){let r=0;if(t.length<be.v8MaxSafeChunkSize)e.push(...t);else while(r<t.length)e.push(...t.slice(r,r+be.v8MaxSafeChunkSize)),r+=be.v8MaxSafeChunkSize}var nj=x(()=>{Fe()});function Sg(e){let t={},r=-1,i,n,o,s,a,c,l,u=new C1(e);while(++r<u.length){while(r in t)r=t[r];if(i=u.get(r),r&&i[1].type===S.chunkFlow&&u.get(r-1)[1].type===S.listItemPrefix){if(B(i[1]._tokenizer,"expected `_tokenizer` on subtokens"),c=i[1]._tokenizer.events,o=0,o<c.length&&c[o][1].type===S.lineEndingBlank)o+=2;if(o<c.length&&c[o][1].type===S.content)while(++o<c.length){if(c[o][1].type===S.content)break;if(c[o][1].type===S.chunkText)c[o][1]._isInFirstContentOfListItem=!0,o++}}if(i[0]==="enter"){if(i[1].contentType)Object.assign(t,eoe(u,r)),r=t[r],l=!0}else if(i[1]._container){o=r,n=void 0;while(o--)if(s=u.get(o),s[1].type===S.lineEnding||s[1].type===S.lineEndingBlank){if(s[0]==="enter"){if(n)u.get(n)[1].type=S.lineEndingBlank;s[1].type=S.lineEnding,n=o}}else if(s[1].type===S.linePrefix||s[1].type===S.listItemIndent);else break;if(n)i[1].end={...u.get(n)[1].start},a=u.slice(n,r),a.unshift(i),u.splice(n,r-n+1,a)}}return nr(e,0,Number.POSITIVE_INFINITY,u.slice(0)),!l}function eoe(e,t){let r=e.get(t)[1],i=e.get(t)[2],n=t-1,o=[];B(r.contentType,"expected `contentType` on subtokens");let s=r._tokenizer;if(!s){if(s=i.parser[r.contentType](r.start),r._contentTypeTextTrailing)s._contentTypeTextTrailing=!0}let a=s.events,c=[],l={},u,d,p=-1,m=r,y=0,g=0,b=[g];while(m){while(e.get(++n)[1]!==m);if(B(!d||m.previous===d,"expected previous to match"),B(!d||d.next===m,"expected next to match"),o.push(n),!m._tokenizer){if(u=i.sliceStream(m),!m.next)u.push(w.eof);if(d)s.defineSkip(m.start);if(m._isInFirstContentOfListItem)s._gfmTasklistFirstContentOfListItem=!0;if(s.write(u),m._isInFirstContentOfListItem)s._gfmTasklistFirstContentOfListItem=void 0}d=m,m=m.next}m=r;while(++p<a.length)if(a[p][0]==="exit"&&a[p-1][0]==="enter"&&a[p][1].type===a[p-1][1].type&&a[p][1].start.line!==a[p][1].end.line)B(m,"expected a current token"),g=p+1,b.push(g),m._tokenizer=void 0,m.previous=void 0,m=m.next;if(s.events=[],m)m._tokenizer=void 0,m.previous=void 0,B(!m.next,"expected no next token");else b.pop();p=b.length;while(p--){let v=a.slice(b[p],b[p+1]),A=o.pop();B(A!==void 0,"expected a start position when splicing"),c.push([A,A+v.length-1]),e.splice(A,2,v)}c.reverse(),p=-1;while(++p<c.length)l[y+c[p][0]]=y+c[p][1],y+=c[p][1]-c[p][0]-1;return l}var $1=x(()=>{tt();zo();Fe();nj()});function roe(e){return Sg(e),e}function noe(e,t){let r;return i;function i(a){return B(a!==w.eof&&!ve(a),"expected no eof or eol"),e.enter(S.content),r=e.enter(S.chunkContent,{contentType:be.contentTypeContent}),n(a)}function n(a){if(a===w.eof)return o(a);if(ve(a))return e.check(toe,s,o)(a);return e.consume(a),n}function o(a){return e.exit(S.chunkContent),e.exit(S.content),t(a)}function s(a){return B(ve(a),"expected eol"),e.consume(a),e.exit(S.chunkContent),B(r,"expected previous token"),r.next=e.enter(S.chunkContent,{contentType:be.contentTypeContent,previous:r}),r=r.next,n}}function ioe(e,t,r){let i=this;return n;function n(s){return B(ve(s),"expected a line ending"),e.exit(S.chunkContent),e.enter(S.lineEnding),e.consume(s),e.exit(S.lineEnding),Ze(e,o,S.linePrefix)}function o(s){if(s===w.eof||ve(s))return r(s);B(i.parser.constructs.disable.null,"expected `disable.null` to be populated");let a=i.events[i.events.length-1];if(!i.parser.constructs.disable.null.includes("codeIndented")&&a&&a[1].type===S.linePrefix&&a[2].sliceSerialize(a[1],!0).length>=be.tabSize)return t(s);return e.interrupt(i.parser.constructs.flow,r,t)(s)}}var O1,toe;var ij=x(()=>{tt();Gt();ot();$1();Fe();O1={resolve:roe,tokenize:noe},toe={partial:!0,tokenize:ioe}});function wg(e,t,r,i,n,o,s,a,c){let l=c||Number.POSITIVE_INFINITY,u=0;return d;function d(v){if(v===w.lessThan)return e.enter(i),e.enter(n),e.enter(o),e.consume(v),e.exit(o),p;if(v===w.eof||v===w.space||v===w.rightParenthesis||Nd(v))return r(v);return e.enter(i),e.enter(s),e.enter(a),e.enter(S.chunkString,{contentType:be.contentTypeString}),g(v)}function p(v){if(v===w.greaterThan)return e.enter(o),e.consume(v),e.exit(o),e.exit(n),e.exit(i),t;return e.enter(a),e.enter(S.chunkString,{contentType:be.contentTypeString}),m(v)}function m(v){if(v===w.greaterThan)return e.exit(S.chunkString),e.exit(a),p(v);if(v===w.eof||v===w.lessThan||ve(v))return r(v);return e.consume(v),v===w.backslash?y:m}function y(v){if(v===w.lessThan||v===w.greaterThan||v===w.backslash)return e.consume(v),m;return m(v)}function g(v){if(!u&&(v===w.eof||v===w.rightParenthesis||$t(v)))return e.exit(S.chunkString),e.exit(a),e.exit(s),e.exit(i),t(v);if(u<l&&v===w.leftParenthesis)return e.consume(v),u++,g;if(v===w.rightParenthesis)return e.consume(v),u--,g;if(v===w.eof||v===w.space||v===w.leftParenthesis||Nd(v))return r(v);return e.consume(v),v===w.backslash?b:g}function b(v){if(v===w.leftParenthesis||v===w.rightParenthesis||v===w.backslash)return e.consume(v),g;return g(v)}}var R1=x(()=>{ot();Fe()});function vg(e,t,r,i,n,o){let s=this,a=0,c;return l;function l(m){return B(m===w.leftSquareBracket,"expected `[`"),e.enter(i),e.enter(n),e.consume(m),e.exit(n),e.enter(o),u}function u(m){if(a>be.linkReferenceSizeMax||m===w.eof||m===w.leftSquareBracket||m===w.rightSquareBracket&&!c||m===w.caret&&!a&&"_hiddenFootnoteSupport"in s.parser.constructs)return r(m);if(m===w.rightSquareBracket)return e.exit(o),e.enter(n),e.consume(m),e.exit(n),e.exit(i),t;if(ve(m))return e.enter(S.lineEnding),e.consume(m),e.exit(S.lineEnding),u;return e.enter(S.chunkString,{contentType:be.contentTypeString}),d(m)}function d(m){if(m===w.eof||m===w.leftSquareBracket||m===w.rightSquareBracket||ve(m)||a++>be.linkReferenceSizeMax)return e.exit(S.chunkString),u(m);if(e.consume(m),!c)c=!Me(m);return m===w.backslash?p:d}function p(m){if(m===w.leftSquareBracket||m===w.backslash||m===w.rightSquareBracket)return e.consume(m),a++,d;return d(m)}}var P1=x(()=>{tt();ot();Fe()});function _g(e,t,r,i,n,o){let s;return a;function a(p){if(p===w.quotationMark||p===w.apostrophe||p===w.leftParenthesis)return e.enter(i),e.enter(n),e.consume(p),e.exit(n),s=p===w.leftParenthesis?w.rightParenthesis:p,c;return r(p)}function c(p){if(p===s)return e.enter(n),e.consume(p),e.exit(n),e.exit(i),t;return e.enter(o),l(p)}function l(p){if(p===s)return e.exit(o),c(s);if(p===w.eof)return r(p);if(ve(p))return e.enter(S.lineEnding),e.consume(p),e.exit(S.lineEnding),Ze(e,l,S.linePrefix);return e.enter(S.chunkString,{contentType:be.contentTypeString}),u(p)}function u(p){if(p===s||p===w.eof||ve(p))return e.exit(S.chunkString),l(p);return e.consume(p),p===w.backslash?d:u}function d(p){if(p===s||p===w.backslash)return e.consume(p),u;return u(p)}}var z1=x(()=>{Gt();ot();Fe()});function Xs(e,t){let r;return i;function i(n){if(ve(n))return e.enter(S.lineEnding),e.consume(n),e.exit(S.lineEnding),r=!0,i;if(Me(n))return Ze(e,i,r?S.linePrefix:S.lineSuffix)(n);return t(n)}}var N1=x(()=>{Gt();ot();Fe()});function soe(e,t,r){let i=this,n;return o;function o(m){return e.enter(S.definition),s(m)}function s(m){return B(m===w.leftSquareBracket,"expected `[`"),vg.call(i,e,a,r,S.definitionLabel,S.definitionLabelMarker,S.definitionLabelString)(m)}function a(m){if(n=Ni(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)),m===w.colon)return e.enter(S.definitionMarker),e.consume(m),e.exit(S.definitionMarker),c;return r(m)}function c(m){return $t(m)?Xs(e,l)(m):l(m)}function l(m){return wg(e,u,r,S.definitionDestination,S.definitionDestinationLiteral,S.definitionDestinationLiteralMarker,S.definitionDestinationRaw,S.definitionDestinationString)(m)}function u(m){return e.attempt(ooe,d,d)(m)}function d(m){return Me(m)?Ze(e,p,S.whitespace)(m):p(m)}function p(m){if(m===w.eof||ve(m))return e.exit(S.definition),i.parser.defined.push(n),t(m);return r(m)}}function aoe(e,t,r){return i;function i(a){return $t(a)?Xs(e,n)(a):r(a)}function n(a){return _g(e,o,r,S.definitionTitle,S.definitionTitleMarker,S.definitionTitleString)(a)}function o(a){return Me(a)?Ze(e,s,S.whitespace)(a):s(a)}function s(a){return a===w.eof||ve(a)?t(a):r(a)}}var D1,ooe;var oj=x(()=>{tt();R1();P1();Gt();z1();N1();ot();mg();Fe();D1={name:"definition",tokenize:soe},ooe={partial:!0,tokenize:aoe}});function coe(e,t,r){return i;function i(o){return B(o===w.backslash,"expected `\\`"),e.enter(S.hardBreakEscape),e.consume(o),n}function n(o){if(ve(o))return e.exit(S.hardBreakEscape),t(o);return r(o)}}var L1;var sj=x(()=>{tt();ot();Fe();L1={name:"hardBreakEscape",tokenize:coe}});function loe(e,t){let r=e.length-2,i=3,n,o;if(e[i][1].type===S.whitespace)i+=2;if(r-2>i&&e[r][1].type===S.whitespace)r-=2;if(e[r][1].type===S.atxHeadingSequence&&(i===r-1||r-4>i&&e[r-2][1].type===S.whitespace))r-=i+1===r?2:4;if(r>i)n={type:S.atxHeadingText,start:e[i][1].start,end:e[r][1].end},o={type:S.chunkText,start:e[i][1].start,end:e[r][1].end,contentType:be.contentTypeText},nr(e,i,r-i+1,[["enter",n,t],["enter",o,t],["exit",o,t],["exit",n,t]]);return e}function uoe(e,t,r){let i=0;return n;function n(u){return e.enter(S.atxHeading),o(u)}function o(u){return B(u===w.numberSign,"expected `#`"),e.enter(S.atxHeadingSequence),s(u)}function s(u){if(u===w.numberSign&&i++<be.atxHeadingOpeningFenceSizeMax)return e.consume(u),s;if(u===w.eof||$t(u))return e.exit(S.atxHeadingSequence),a(u);return r(u)}function a(u){if(u===w.numberSign)return e.enter(S.atxHeadingSequence),c(u);if(u===w.eof||ve(u))return e.exit(S.atxHeading),t(u);if(Me(u))return Ze(e,a,S.whitespace)(u);return e.enter(S.atxHeadingText),l(u)}function c(u){if(u===w.numberSign)return e.consume(u),c;return e.exit(S.atxHeadingSequence),a(u)}function l(u){if(u===w.eof||u===w.numberSign||$t(u))return e.exit(S.atxHeadingText),a(u);return e.consume(u),l}}var B1;var aj=x(()=>{tt();Gt();ot();zo();Fe();B1={name:"headingAtx",resolve:loe,tokenize:uoe}});var cj,j1;var lj=x(()=>{cj=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],j1=["pre","script","style","textarea"]});function poe(e){let t=e.length;while(t--)if(e[t][0]==="enter"&&e[t][1].type===S.htmlFlow)break;if(t>1&&e[t-2][1].type===S.linePrefix)e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2);return e}function moe(e,t,r){let i=this,n,o,s,a,c;return l;function l(C){return u(C)}function u(C){return B(C===w.lessThan,"expected `<`"),e.enter(S.htmlFlow),e.enter(S.htmlFlowData),e.consume(C),d}function d(C){if(C===w.exclamationMark)return e.consume(C),p;if(C===w.slash)return e.consume(C),o=!0,g;if(C===w.questionMark)return e.consume(C),n=be.htmlInstruction,i.interrupt?t:_;if(sn(C))return B(C!==null),e.consume(C),s=String.fromCharCode(C),b;return r(C)}function p(C){if(C===w.dash)return e.consume(C),n=be.htmlComment,m;if(C===w.leftSquareBracket)return e.consume(C),n=be.htmlCdata,a=0,y;if(sn(C))return e.consume(C),n=be.htmlDeclaration,i.interrupt?t:_;return r(C)}function m(C){if(C===w.dash)return e.consume(C),i.interrupt?t:_;return r(C)}function y(C){let Se=be.cdataOpeningString;if(C===Se.charCodeAt(a++)){if(e.consume(C),a===Se.length)return i.interrupt?t:P;return y}return r(C)}function g(C){if(sn(C))return B(C!==null),e.consume(C),s=String.fromCharCode(C),b;return r(C)}function b(C){if(C===w.eof||C===w.slash||C===w.greaterThan||$t(C)){let Se=C===w.slash,Ee=s.toLowerCase();if(!Se&&!o&&j1.includes(Ee))return n=be.htmlRaw,i.interrupt?t(C):P(C);if(cj.includes(s.toLowerCase())){if(n=be.htmlBasic,Se)return e.consume(C),v;return i.interrupt?t(C):P(C)}return n=be.htmlComplete,i.interrupt&&!i.parser.lazy[i.now().line]?r(C):o?A(C):T(C)}if(C===w.dash||Dr(C))return e.consume(C),s+=String.fromCharCode(C),b;return r(C)}function v(C){if(C===w.greaterThan)return e.consume(C),i.interrupt?t:P;return r(C)}function A(C){if(Me(C))return e.consume(C),A;return X(C)}function T(C){if(C===w.slash)return e.consume(C),X;if(C===w.colon||C===w.underscore||sn(C))return e.consume(C),z;if(Me(C))return e.consume(C),T;return X(C)}function z(C){if(C===w.dash||C===w.dot||C===w.colon||C===w.underscore||Dr(C))return e.consume(C),z;return j(C)}function j(C){if(C===w.equalsTo)return e.consume(C),E;if(Me(C))return e.consume(C),j;return T(C)}function E(C){if(C===w.eof||C===w.lessThan||C===w.equalsTo||C===w.greaterThan||C===w.graveAccent)return r(C);if(C===w.quotationMark||C===w.apostrophe)return e.consume(C),c=C,Z;if(Me(C))return e.consume(C),E;return D(C)}function Z(C){if(C===c)return e.consume(C),c=null,H;if(C===w.eof||ve(C))return r(C);return e.consume(C),Z}function D(C){if(C===w.eof||C===w.quotationMark||C===w.apostrophe||C===w.slash||C===w.lessThan||C===w.equalsTo||C===w.greaterThan||C===w.graveAccent||$t(C))return j(C);return e.consume(C),D}function H(C){if(C===w.slash||C===w.greaterThan||Me(C))return T(C);return r(C)}function X(C){if(C===w.greaterThan)return e.consume(C),M;return r(C)}function M(C){if(C===w.eof||ve(C))return P(C);if(Me(C))return e.consume(C),M;return r(C)}function P(C){if(C===w.dash&&n===be.htmlComment)return e.consume(C),O;if(C===w.lessThan&&n===be.htmlRaw)return e.consume(C),F;if(C===w.greaterThan&&n===be.htmlDeclaration)return e.consume(C),te;if(C===w.questionMark&&n===be.htmlInstruction)return e.consume(C),_;if(C===w.rightSquareBracket&&n===be.htmlCdata)return e.consume(C),V;if(ve(C)&&(n===be.htmlBasic||n===be.htmlComplete))return e.exit(S.htmlFlowData),e.check(doe,ue,N)(C);if(C===w.eof||ve(C))return e.exit(S.htmlFlowData),N(C);return e.consume(C),P}function N(C){return e.check(foe,I,ue)(C)}function I(C){return B(ve(C)),e.enter(S.lineEnding),e.consume(C),e.exit(S.lineEnding),R}function R(C){if(C===w.eof||ve(C))return N(C);return e.enter(S.htmlFlowData),P(C)}function O(C){if(C===w.dash)return e.consume(C),_;return P(C)}function F(C){if(C===w.slash)return e.consume(C),s="",L;return P(C)}function L(C){if(C===w.greaterThan){let Se=s.toLowerCase();if(j1.includes(Se))return e.consume(C),te;return P(C)}if(sn(C)&&s.length<be.htmlRawSizeMax)return B(C!==null),e.consume(C),s+=String.fromCharCode(C),L;return P(C)}function V(C){if(C===w.rightSquareBracket)return e.consume(C),_;return P(C)}function _(C){if(C===w.greaterThan)return e.consume(C),te;if(C===w.dash&&n===be.htmlComment)return e.consume(C),_;return P(C)}function te(C){if(C===w.eof||ve(C))return e.exit(S.htmlFlowData),ue(C);return e.consume(C),te}function ue(C){return e.exit(S.htmlFlow),t(C)}}function hoe(e,t,r){let i=this;return n;function n(s){if(ve(s))return e.enter(S.lineEnding),e.consume(s),e.exit(S.lineEnding),o;return r(s)}function o(s){return i.parser.lazy[i.now().line]?r(s):t(s)}}function goe(e,t,r){return i;function i(n){return B(ve(n),"expected a line ending"),e.enter(S.lineEnding),e.consume(n),e.exit(S.lineEnding),e.attempt(Do,t,r)}}var q1,doe,foe;var uj=x(()=>{tt();ot();lj();Fe();hg();q1={concrete:!0,name:"htmlFlow",resolveTo:poe,tokenize:moe},doe={partial:!0,tokenize:goe},foe={partial:!0,tokenize:hoe}});function yoe(e,t,r){let i=this,n,o,s;return a;function a(_){return B(_===w.lessThan,"expected `<`"),e.enter(S.htmlText),e.enter(S.htmlTextData),e.consume(_),c}function c(_){if(_===w.exclamationMark)return e.consume(_),l;if(_===w.slash)return e.consume(_),j;if(_===w.questionMark)return e.consume(_),T;if(sn(_))return e.consume(_),D;return r(_)}function l(_){if(_===w.dash)return e.consume(_),u;if(_===w.leftSquareBracket)return e.consume(_),o=0,y;if(sn(_))return e.consume(_),A;return r(_)}function u(_){if(_===w.dash)return e.consume(_),m;return r(_)}function d(_){if(_===w.eof)return r(_);if(_===w.dash)return e.consume(_),p;if(ve(_))return s=d,F(_);return e.consume(_),d}function p(_){if(_===w.dash)return e.consume(_),m;return d(_)}function m(_){return _===w.greaterThan?O(_):_===w.dash?p(_):d(_)}function y(_){let te=be.cdataOpeningString;if(_===te.charCodeAt(o++))return e.consume(_),o===te.length?g:y;return r(_)}function g(_){if(_===w.eof)return r(_);if(_===w.rightSquareBracket)return e.consume(_),b;if(ve(_))return s=g,F(_);return e.consume(_),g}function b(_){if(_===w.rightSquareBracket)return e.consume(_),v;return g(_)}function v(_){if(_===w.greaterThan)return O(_);if(_===w.rightSquareBracket)return e.consume(_),v;return g(_)}function A(_){if(_===w.eof||_===w.greaterThan)return O(_);if(ve(_))return s=A,F(_);return e.consume(_),A}function T(_){if(_===w.eof)return r(_);if(_===w.questionMark)return e.consume(_),z;if(ve(_))return s=T,F(_);return e.consume(_),T}function z(_){return _===w.greaterThan?O(_):T(_)}function j(_){if(sn(_))return e.consume(_),E;return r(_)}function E(_){if(_===w.dash||Dr(_))return e.consume(_),E;return Z(_)}function Z(_){if(ve(_))return s=Z,F(_);if(Me(_))return e.consume(_),Z;return O(_)}function D(_){if(_===w.dash||Dr(_))return e.consume(_),D;if(_===w.slash||_===w.greaterThan||$t(_))return H(_);return r(_)}function H(_){if(_===w.slash)return e.consume(_),O;if(_===w.colon||_===w.underscore||sn(_))return e.consume(_),X;if(ve(_))return s=H,F(_);if(Me(_))return e.consume(_),H;return O(_)}function X(_){if(_===w.dash||_===w.dot||_===w.colon||_===w.underscore||Dr(_))return e.consume(_),X;return M(_)}function M(_){if(_===w.equalsTo)return e.consume(_),P;if(ve(_))return s=M,F(_);if(Me(_))return e.consume(_),M;return H(_)}function P(_){if(_===w.eof||_===w.lessThan||_===w.equalsTo||_===w.greaterThan||_===w.graveAccent)return r(_);if(_===w.quotationMark||_===w.apostrophe)return e.consume(_),n=_,N;if(ve(_))return s=P,F(_);if(Me(_))return e.consume(_),P;return e.consume(_),I}function N(_){if(_===n)return e.consume(_),n=void 0,R;if(_===w.eof)return r(_);if(ve(_))return s=N,F(_);return e.consume(_),N}function I(_){if(_===w.eof||_===w.quotationMark||_===w.apostrophe||_===w.lessThan||_===w.equalsTo||_===w.graveAccent)return r(_);if(_===w.slash||_===w.greaterThan||$t(_))return H(_);return e.consume(_),I}function R(_){if(_===w.slash||_===w.greaterThan||$t(_))return H(_);return r(_)}function O(_){if(_===w.greaterThan)return e.consume(_),e.exit(S.htmlTextData),e.exit(S.htmlText),t;return r(_)}function F(_){return B(s,"expected return state"),B(ve(_),"expected eol"),e.exit(S.htmlTextData),e.enter(S.lineEnding),e.consume(_),e.exit(S.lineEnding),L}function L(_){return B(i.parser.constructs.disable.null,"expected `disable.null` to be populated"),Me(_)?Ze(e,V,S.linePrefix,i.parser.constructs.disable.null.includes("codeIndented")?void 0:be.tabSize)(_):V(_)}function V(_){return e.enter(S.htmlTextData),s(_)}}var U1;var dj=x(()=>{tt();Gt();ot();Fe();U1={name:"htmlText",tokenize:yoe}});function woe(e){let t=-1,r=[];while(++t<e.length){let i=e[t][1];if(r.push(e[t]),i.type===S.labelImage||i.type===S.labelLink||i.type===S.labelEnd){let n=i.type===S.labelImage?4:2;i.type=S.data,t+=n}}if(e.length!==r.length)nr(e,0,e.length,r);return e}function voe(e,t){let r=e.length,i=0,n,o,s,a;while(r--)if(n=e[r][1],o){if(n.type===S.link||n.type===S.labelLink&&n._inactive)break;if(e[r][0]==="enter"&&n.type===S.labelLink)n._inactive=!0}else if(s){if(e[r][0]==="enter"&&(n.type===S.labelImage||n.type===S.labelLink)&&!n._balanced){if(o=r,n.type!==S.labelLink){i=2;break}}}else if(n.type===S.labelEnd)s=r;B(o!==void 0,"`open` is supposed to be found"),B(s!==void 0,"`close` is supposed to be found");let c={type:e[o][1].type===S.labelLink?S.link:S.image,start:{...e[o][1].start},end:{...e[e.length-1][1].end}},l={type:S.label,start:{...e[o][1].start},end:{...e[s][1].end}},u={type:S.labelText,start:{...e[o+i+2][1].end},end:{...e[s-2][1].start}};return a=[["enter",c,t],["enter",l,t]],a=Nr(a,e.slice(o+1,o+i+3)),a=Nr(a,[["enter",u,t]]),B(t.parser.constructs.insideSpan.null,"expected `insideSpan.null` to be populated"),a=Nr(a,Qc(t.parser.constructs.insideSpan.null,e.slice(o+i+4,s-3),t)),a=Nr(a,[["exit",u,t],e[s-2],e[s-1],["exit",l,t]]),a=Nr(a,e.slice(s+1)),a=Nr(a,[["exit",c,t]]),nr(e,o,e.length,a),e}function _oe(e,t,r){let i=this,n=i.events.length,o,s;while(n--)if((i.events[n][1].type===S.labelImage||i.events[n][1].type===S.labelLink)&&!i.events[n][1]._balanced){o=i.events[n][1];break}return a;function a(p){if(B(p===w.rightSquareBracket,"expected `]`"),!o)return r(p);if(o._inactive)return d(p);return s=i.parser.defined.includes(Ni(i.sliceSerialize({start:o.end,end:i.now()}))),e.enter(S.labelEnd),e.enter(S.labelMarker),e.consume(p),e.exit(S.labelMarker),e.exit(S.labelEnd),c}function c(p){if(p===w.leftParenthesis)return e.attempt(boe,u,s?u:d)(p);if(p===w.leftSquareBracket)return e.attempt(xoe,u,s?l:d)(p);return s?u(p):d(p)}function l(p){return e.attempt(Soe,u,d)(p)}function u(p){return t(p)}function d(p){return o._balanced=!0,r(p)}}function koe(e,t,r){return i;function i(d){return B(d===w.leftParenthesis,"expected left paren"),e.enter(S.resource),e.enter(S.resourceMarker),e.consume(d),e.exit(S.resourceMarker),n}function n(d){return $t(d)?Xs(e,o)(d):o(d)}function o(d){if(d===w.rightParenthesis)return u(d);return wg(e,s,a,S.resourceDestination,S.resourceDestinationLiteral,S.resourceDestinationLiteralMarker,S.resourceDestinationRaw,S.resourceDestinationString,be.linkResourceDestinationBalanceMax)(d)}function s(d){return $t(d)?Xs(e,c)(d):u(d)}function a(d){return r(d)}function c(d){if(d===w.quotationMark||d===w.apostrophe||d===w.leftParenthesis)return _g(e,l,r,S.resourceTitle,S.resourceTitleMarker,S.resourceTitleString)(d);return u(d)}function l(d){return $t(d)?Xs(e,u)(d):u(d)}function u(d){if(d===w.rightParenthesis)return e.enter(S.resourceMarker),e.consume(d),e.exit(S.resourceMarker),e.exit(S.resource),t;return r(d)}}function Eoe(e,t,r){let i=this;return n;function n(a){return B(a===w.leftSquareBracket,"expected left bracket"),vg.call(i,e,o,s,S.reference,S.referenceMarker,S.referenceString)(a)}function o(a){return i.parser.defined.includes(Ni(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)))?t(a):r(a)}function s(a){return r(a)}}function Ioe(e,t,r){return i;function i(o){return B(o===w.leftSquareBracket,"expected left bracket"),e.enter(S.reference),e.enter(S.referenceMarker),e.consume(o),e.exit(S.referenceMarker),n}function n(o){if(o===w.rightSquareBracket)return e.enter(S.referenceMarker),e.consume(o),e.exit(S.referenceMarker),e.exit(S.reference),t;return r(o)}}var ea,boe,xoe,Soe;var kg=x(()=>{tt();R1();P1();z1();N1();ot();zo();mg();Fe();ea={name:"labelEnd",resolveAll:woe,resolveTo:voe,tokenize:_oe},boe={tokenize:koe},xoe={tokenize:Eoe},Soe={tokenize:Ioe}});function Aoe(e,t,r){let i=this;return n;function n(a){return B(a===w.exclamationMark,"expected `!`"),e.enter(S.labelImage),e.enter(S.labelImageMarker),e.consume(a),e.exit(S.labelImageMarker),o}function o(a){if(a===w.leftSquareBracket)return e.enter(S.labelMarker),e.consume(a),e.exit(S.labelMarker),e.exit(S.labelImage),s;return r(a)}function s(a){return a===w.caret&&"_hiddenFootnoteSupport"in i.parser.constructs?r(a):t(a)}}var M1;var fj=x(()=>{tt();Fe();kg();M1={name:"labelStartImage",resolveAll:ea.resolveAll,tokenize:Aoe}});function Toe(e,t,r){let i=this;return n;function n(s){return B(s===w.leftSquareBracket,"expected `[`"),e.enter(S.labelLink),e.enter(S.labelMarker),e.consume(s),e.exit(S.labelMarker),e.exit(S.labelLink),o}function o(s){return s===w.caret&&"_hiddenFootnoteSupport"in i.parser.constructs?r(s):t(s)}}var F1;var pj=x(()=>{tt();Fe();kg();F1={name:"labelStartLink",resolveAll:ea.resolveAll,tokenize:Toe}});function Coe(e,t){return r;function r(i){return B(ve(i),"expected eol"),e.enter(S.lineEnding),e.consume(i),e.exit(S.lineEnding),Ze(e,t,S.linePrefix)}}var qd;var mj=x(()=>{tt();Gt();ot();Fe();qd={name:"lineEnding",tokenize:Coe}});function $oe(e,t,r){let i=0,n;return o;function o(l){return e.enter(S.thematicBreak),s(l)}function s(l){return B(l===w.asterisk||l===w.dash||l===w.underscore,"expected `*`, `-`, or `_`"),n=l,a(l)}function a(l){if(l===n)return e.enter(S.thematicBreakSequence),c(l);if(i>=be.thematicBreakMarkerCountMin&&(l===w.eof||ve(l)))return e.exit(S.thematicBreak),t(l);return r(l)}function c(l){if(l===n)return e.consume(l),i++,c;return e.exit(S.thematicBreakSequence),Me(l)?Ze(e,a,S.whitespace)(l):a(l)}}var ta;var Z1=x(()=>{tt();Gt();ot();Fe();ta={name:"thematicBreak",tokenize:$oe}});function Poe(e,t,r){let i=this,n=i.events[i.events.length-1],o=n&&n[1].type===S.linePrefix?n[2].sliceSerialize(n[1],!0).length:0,s=0;return a;function a(m){B(i.containerState,"expected state");let y=i.containerState.type||(m===w.asterisk||m===w.plusSign||m===w.dash?S.listUnordered:S.listOrdered);if(y===S.listUnordered?!i.containerState.marker||m===i.containerState.marker:Dd(m)){if(!i.containerState.type)i.containerState.type=y,e.enter(y,{_container:!0});if(y===S.listUnordered)return e.enter(S.listItemPrefix),m===w.asterisk||m===w.dash?e.check(ta,r,l)(m):l(m);if(!i.interrupt||m===w.digit1)return e.enter(S.listItemPrefix),e.enter(S.listItemValue),c(m)}return r(m)}function c(m){if(B(i.containerState,"expected state"),Dd(m)&&++s<be.listItemValueSizeMax)return e.consume(m),c;if((!i.interrupt||s<2)&&(i.containerState.marker?m===i.containerState.marker:m===w.rightParenthesis||m===w.dot))return e.exit(S.listItemValue),l(m);return r(m)}function l(m){return B(i.containerState,"expected state"),B(m!==w.eof,"eof (`null`) is not a marker"),e.enter(S.listItemMarker),e.consume(m),e.exit(S.listItemMarker),i.containerState.marker=i.containerState.marker||m,e.check(Do,i.interrupt?r:u,e.attempt(Ooe,p,d))}function u(m){return B(i.containerState,"expected state"),i.containerState.initialBlankLine=!0,o++,p(m)}function d(m){if(Me(m))return e.enter(S.listItemPrefixWhitespace),e.consume(m),e.exit(S.listItemPrefixWhitespace),p;return r(m)}function p(m){return B(i.containerState,"expected state"),i.containerState.size=o+i.sliceSerialize(e.exit(S.listItemPrefix),!0).length,t(m)}}function zoe(e,t,r){let i=this;return B(i.containerState,"expected state"),i.containerState._closeFlow=void 0,e.check(Do,n,o);function n(a){return B(i.containerState,"expected state"),B(typeof i.containerState.size==="number","expected size"),i.containerState.furtherBlankLines=i.containerState.furtherBlankLines||i.containerState.initialBlankLine,Ze(e,t,S.listItemIndent,i.containerState.size+1)(a)}function o(a){if(B(i.containerState,"expected state"),i.containerState.furtherBlankLines||!Me(a))return i.containerState.furtherBlankLines=void 0,i.containerState.initialBlankLine=void 0,s(a);return i.containerState.furtherBlankLines=void 0,i.containerState.initialBlankLine=void 0,e.attempt(Roe,t,s)(a)}function s(a){return B(i.containerState,"expected state"),i.containerState._closeFlow=!0,i.interrupt=void 0,B(i.parser.constructs.disable.null,"expected `disable.null` to be populated"),Ze(e,e.attempt(Sr,t,r),S.linePrefix,i.parser.constructs.disable.null.includes("codeIndented")?void 0:be.tabSize)(a)}}function Noe(e,t,r){let i=this;return B(i.containerState,"expected state"),B(typeof i.containerState.size==="number","expected size"),Ze(e,n,S.listItemIndent,i.containerState.size+1);function n(o){B(i.containerState,"expected state");let s=i.events[i.events.length-1];return s&&s[1].type===S.listItemIndent&&s[2].sliceSerialize(s[1],!0).length===i.containerState.size?t(o):r(o)}}function Doe(e){B(this.containerState,"expected state"),B(typeof this.containerState.type==="string","expected type"),e.exit(this.containerState.type)}function Loe(e,t,r){let i=this;return B(i.parser.constructs.disable.null,"expected `disable.null` to be populated"),Ze(e,n,S.listItemPrefixWhitespace,i.parser.constructs.disable.null.includes("codeIndented")?void 0:be.tabSize+1);function n(o){let s=i.events[i.events.length-1];return!Me(o)&&s&&s[1].type===S.listItemPrefixWhitespace?t(o):r(o)}}var Sr,Ooe,Roe;var hj=x(()=>{tt();Gt();ot();Fe();hg();Z1();Sr={continuation:{tokenize:zoe},exit:Doe,name:"list",tokenize:Poe},Ooe={partial:!0,tokenize:Loe},Roe={partial:!0,tokenize:Noe}});function Boe(e,t){let r=e.length,i,n,o;while(r--)if(e[r][0]==="enter"){if(e[r][1].type===S.content){i=r;break}if(e[r][1].type===S.paragraph)n=r}else{if(e[r][1].type===S.content)e.splice(r,1);if(!o&&e[r][1].type===S.definition)o=r}B(n!==void 0,"expected a `text` index to be found"),B(i!==void 0,"expected a `text` index to be found"),B(e[i][2]===t,"enter context should be same"),B(e[e.length-1][2]===t,"enter context should be same");let s={type:S.setextHeading,start:{...e[i][1].start},end:{...e[e.length-1][1].end}};if(e[n][1].type=S.setextHeadingText,o)e.splice(n,0,["enter",s,t]),e.splice(o+1,0,["exit",e[i][1],t]),e[i][1].end={...e[o][1].end};else e[i][1]=s;return e.push(["exit",s,t]),e}function joe(e,t,r){let i=this,n;return o;function o(l){let u=i.events.length,d;B(l===w.dash||l===w.equalsTo,"expected `=` or `-`");while(u--)if(i.events[u][1].type!==S.lineEnding&&i.events[u][1].type!==S.linePrefix&&i.events[u][1].type!==S.content){d=i.events[u][1].type===S.paragraph;break}if(!i.parser.lazy[i.now().line]&&(i.interrupt||d))return e.enter(S.setextHeadingLine),n=l,s(l);return r(l)}function s(l){return e.enter(S.setextHeadingLineSequence),a(l)}function a(l){if(l===n)return e.consume(l),a;return e.exit(S.setextHeadingLineSequence),Me(l)?Ze(e,c,S.lineSuffix)(l):c(l)}function c(l){if(l===w.eof||ve(l))return e.exit(S.setextHeadingLine),t(l);return r(l)}}var Eg;var gj=x(()=>{tt();Gt();ot();Fe();Eg={name:"setextUnderline",resolveTo:Boe,tokenize:joe}});var H1=x(()=>{J6();V6();hg();W6();G6();Q6();X6();ej();rj();ij();oj();sj();aj();uj();dj();kg();fj();pj();mj();hj();gj();Z1()});function qoe(e){let t=this,r=e.attempt(Do,i,e.attempt(this.parser.constructs.flowInitial,n,Ze(e,e.attempt(this.parser.constructs.flow,n,e.attempt(O1,n)),S.linePrefix)));return r;function i(o){if(B(o===w.eof||ve(o),"expected eol or eof"),o===w.eof){e.consume(o);return}return e.enter(S.lineEndingBlank),e.consume(o),e.exit(S.lineEndingBlank),t.currentConstruct=void 0,r}function n(o){if(B(o===w.eof||ve(o),"expected eol or eof"),o===w.eof){e.consume(o);return}return e.enter(S.lineEnding),e.consume(o),e.exit(S.lineEnding),t.currentConstruct=void 0,r}}var yj;var bj=x(()=>{tt();H1();Gt();ot();Fe();yj={tokenize:qoe}});function vj(e){return{resolveAll:_j(e==="text"?Uoe:void 0),tokenize:t};function t(r){let i=this,n=this.parser.constructs[e],o=r.attempt(n,s,a);return s;function s(u){return l(u)?o(u):a(u)}function a(u){if(u===w.eof){r.consume(u);return}return r.enter(S.data),r.consume(u),c}function c(u){if(l(u))return r.exit(S.data),o(u);return r.consume(u),c}function l(u){if(u===w.eof)return!0;let d=n[u],p=-1;if(d){B(Array.isArray(d),"expected `disable.null` to be populated");while(++p<d.length){let m=d[p];if(!m.previous||m.previous.call(i,i.previous))return!0}}return!1}}}function _j(e){return t;function t(r,i){let n=-1,o;while(++n<=r.length)if(o===void 0){if(r[n]&&r[n][1].type===S.data)o=n,n++}else if(!r[n]||r[n][1].type!==S.data){if(n!==o+2)r[o][1].end=r[n-1][1].end,r.splice(o+2,n-o-2),n=o+2;o=void 0}return e?e(r,i):r}}function Uoe(e,t){let r=0;while(++r<=e.length)if((r===e.length||e[r][1].type===S.lineEnding)&&e[r-1][1].type===S.data){let i=e[r-1][1],n=t.sliceStream(i),o=n.length,s=-1,a=0,c;while(o--){let l=n[o];if(typeof l==="string"){s=l.length;while(l.charCodeAt(s-1)===w.space)a++,s--;if(s)break;s=-1}else if(l===w.horizontalTab)c=!0,a++;else if(l===w.virtualSpace);else{o++;break}}if(t._contentTypeTextTrailing&&r===e.length)a=0;if(a){let l={type:r===e.length||c||a<be.hardBreakPrefixSizeMin?S.lineSuffix:S.hardBreakTrailing,start:{_bufferIndex:o?s:i.start._bufferIndex+s,_index:i.start._index+o,line:i.end.line,column:i.end.column-a,offset:i.end.offset-a},end:{...i.end}};if(i.end={...l.start},i.start.offset===i.end.offset)Object.assign(i,l);else e.splice(r,0,["enter",l,t],["exit",l,t]),r+=2}r++}return e}var xj,Sj,wj;var K1=x(()=>{tt();Fe();xj={resolveAll:_j()},Sj=vj("string"),wj=vj("text")});var J1={};tr(J1,{attentionMarkers:()=>Woe,contentInitial:()=>Foe,disable:()=>Goe,document:()=>Moe,flow:()=>Hoe,flowInitial:()=>Zoe,insideSpan:()=>Voe,string:()=>Koe,text:()=>Joe});var Moe,Foe,Zoe,Hoe,Koe,Joe,Voe,Woe,Goe;var kj=x(()=>{H1();Fe();K1();Moe={[w.asterisk]:Sr,[w.plusSign]:Sr,[w.dash]:Sr,[w.digit0]:Sr,[w.digit1]:Sr,[w.digit2]:Sr,[w.digit3]:Sr,[w.digit4]:Sr,[w.digit5]:Sr,[w.digit6]:Sr,[w.digit7]:Sr,[w.digit8]:Sr,[w.digit9]:Sr,[w.greaterThan]:gg},Foe={[w.leftSquareBracket]:D1},Zoe={[w.horizontalTab]:Bd,[w.virtualSpace]:Bd,[w.space]:Bd},Hoe={[w.numberSign]:B1,[w.asterisk]:ta,[w.dash]:[Eg,ta],[w.lessThan]:q1,[w.equalsTo]:Eg,[w.underscore]:ta,[w.graveAccent]:xg,[w.tilde]:xg},Koe={[w.ampersand]:bg,[w.backslash]:yg},Joe={[w.carriageReturn]:qd,[w.lineFeed]:qd,[w.carriageReturnLineFeed]:qd,[w.exclamationMark]:M1,[w.ampersand]:bg,[w.asterisk]:Ld,[w.lessThan]:[A1,U1],[w.leftSquareBracket]:F1,[w.backslash]:[L1,yg],[w.rightSquareBracket]:ea,[w.underscore]:Ld,[w.graveAccent]:T1},Voe={null:[Ld,xj]},Woe={null:[w.asterisk,w.underscore]},Goe={null:[]}});var Ij=ee(function(mDe,Ej){var Yc=1000,Xc=Yc*60,el=Xc*60,ra=el*24,Qoe=ra*7,Yoe=ra*365.25;Ej.exports=function(e,t){t=t||{};var r=typeof e;if(r==="string"&&e.length>0)return Xoe(e);else if(r==="number"&&isFinite(e))return t.long?tse(e):ese(e);throw Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function Xoe(e){if(e=String(e),e.length>100)return;var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!t)return;var r=parseFloat(t[1]),i=(t[2]||"ms").toLowerCase();switch(i){case"years":case"year":case"yrs":case"yr":case"y":return r*Yoe;case"weeks":case"week":case"w":return r*Qoe;case"days":case"day":case"d":return r*ra;case"hours":case"hour":case"hrs":case"hr":case"h":return r*el;case"minutes":case"minute":case"mins":case"min":case"m":return r*Xc;case"seconds":case"second":case"secs":case"sec":case"s":return r*Yc;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}function ese(e){var t=Math.abs(e);if(t>=ra)return Math.round(e/ra)+"d";if(t>=el)return Math.round(e/el)+"h";if(t>=Xc)return Math.round(e/Xc)+"m";if(t>=Yc)return Math.round(e/Yc)+"s";return e+"ms"}function tse(e){var t=Math.abs(e);if(t>=ra)return Ig(e,t,ra,"day");if(t>=el)return Ig(e,t,el,"hour");if(t>=Xc)return Ig(e,t,Xc,"minute");if(t>=Yc)return Ig(e,t,Yc,"second");return e+" ms"}function Ig(e,t,r,i){var n=t>=r*1.5;return Math.round(e/r)+" "+i+(n?"s":"")}});var V1=ee(function(hDe,Aj){function rse(e){r.debug=r,r.default=r,r.coerce=c,r.disable=s,r.enable=n,r.enabled=a,r.humanize=Ij(),r.destroy=l,Object.keys(e).forEach((u)=>{r[u]=e[u]}),r.names=[],r.skips=[],r.formatters={};function t(u){let d=0;for(let p=0;p<u.length;p++)d=(d<<5)-d+u.charCodeAt(p),d|=0;return r.colors[Math.abs(d)%r.colors.length]}r.selectColor=t;function r(u){let d,p=null,m,y;function g(...b){if(!g.enabled)return;let v=g,A=Number(new Date),T=A-(d||A);if(v.diff=T,v.prev=d,v.curr=A,d=A,b[0]=r.coerce(b[0]),typeof b[0]!=="string")b.unshift("%O");let z=0;b[0]=b[0].replace(/%([a-zA-Z%])/g,(E,Z)=>{if(E==="%%")return"%";z++;let D=r.formatters[Z];if(typeof D==="function"){let H=b[z];E=D.call(v,H),b.splice(z,1),z--}return E}),r.formatArgs.call(v,b),(v.log||r.log).apply(v,b)}if(g.namespace=u,g.useColors=r.useColors(),g.color=r.selectColor(u),g.extend=i,g.destroy=r.destroy,Object.defineProperty(g,"enabled",{enumerable:!0,configurable:!1,get:()=>{if(p!==null)return p;if(m!==r.namespaces)m=r.namespaces,y=r.enabled(u);return y},set:(b)=>{p=b}}),typeof r.init==="function")r.init(g);return g}function i(u,d){let p=r(this.namespace+(typeof d>"u"?":":d)+u);return p.log=this.log,p}function n(u){r.save(u),r.namespaces=u,r.names=[],r.skips=[];let d=(typeof u==="string"?u:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(let p of d)if(p[0]==="-")r.skips.push(p.slice(1));else r.names.push(p)}function o(u,d){let p=0,m=0,y=-1,g=0;while(p<u.length)if(m<d.length&&(d[m]===u[p]||d[m]==="*"))if(d[m]==="*")y=m,g=p,m++;else p++,m++;else if(y!==-1)m=y+1,g++,p=g;else return!1;while(m<d.length&&d[m]==="*")m++;return m===d.length}function s(){let u=[...r.names,...r.skips.map((d)=>"-"+d)].join(",");return r.enable(""),u}function a(u){for(let d of r.skips)if(o(u,d))return!1;for(let d of r.names)if(o(u,d))return!0;return!1}function c(u){if(u instanceof Error)return u.stack||u.message;return u}function l(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return r.enable(r.load()),r}Aj.exports=rse});var Cj=ee(function(Tj,Ag){Tj.formatArgs=ise;Tj.save=ose;Tj.load=sse;Tj.useColors=nse;Tj.storage=ase();Tj.destroy=(()=>{let e=!1;return()=>{if(!e)e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}})();Tj.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function nse(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let e;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function ise(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+Ag.exports.humanize(this.diff),!this.useColors)return;let t="color: "+this.color;e.splice(1,0,t,"color: inherit");let r=0,i=0;e[0].replace(/%[a-zA-Z%]/g,(n)=>{if(n==="%%")return;if(r++,n==="%c")i=r}),e.splice(i,0,t)}Tj.log=console.debug||console.log||(()=>{});function ose(e){try{if(e)Tj.storage.setItem("debug",e);else Tj.storage.removeItem("debug")}catch(t){}}function sse(){let e;try{e=Tj.storage.getItem("debug")||Tj.storage.getItem("DEBUG")}catch(t){}if(!e&&typeof process<"u"&&"env"in process)e=process.env.DEBUG;return e}function ase(){try{return localStorage}catch(e){}}Ag.exports=V1()(Tj);var{formatters:cse}=Ag.exports;cse.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}});var Oj=ee(function(yDe,$j){$j.exports=(e,t=process.argv)=>{let r=e.startsWith("-")?"":e.length===1?"-":"--",i=t.indexOf(r+e),n=t.indexOf("--");return i!==-1&&(n===-1||i<n)}});var zj=ee(function(bDe,Pj){var gse=Tt("os"),Rj=Tt("tty"),bn=Oj(),{env:Qt}=process,Lo;if(bn("no-color")||bn("no-colors")||bn("color=false")||bn("color=never"))Lo=0;else if(bn("color")||bn("colors")||bn("color=true")||bn("color=always"))Lo=1;if("FORCE_COLOR"in Qt)if(Qt.FORCE_COLOR==="true")Lo=1;else if(Qt.FORCE_COLOR==="false")Lo=0;else Lo=Qt.FORCE_COLOR.length===0?1:Math.min(parseInt(Qt.FORCE_COLOR,10),3);function W1(e){if(e===0)return!1;return{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function G1(e,t){if(Lo===0)return 0;if(bn("color=16m")||bn("color=full")||bn("color=truecolor"))return 3;if(bn("color=256"))return 2;if(e&&!t&&Lo===void 0)return 0;let r=Lo||0;if(Qt.TERM==="dumb")return r;if(process.platform==="win32"){let i=gse.release().split(".");if(Number(i[0])>=10&&Number(i[2])>=10586)return Number(i[2])>=14931?3:2;return 1}if("CI"in Qt){if(["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some((i)=>(i in Qt))||Qt.CI_NAME==="codeship")return 1;return r}if("TEAMCITY_VERSION"in Qt)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(Qt.TEAMCITY_VERSION)?1:0;if(Qt.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in Qt){let i=parseInt((Qt.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(Qt.TERM_PROGRAM){case"iTerm.app":return i>=3?3:2;case"Apple_Terminal":return 2}}if(/-256(color)?$/i.test(Qt.TERM))return 2;if(/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(Qt.TERM))return 1;if("COLORTERM"in Qt)return 1;return r}function yse(e){let t=G1(e,e&&e.isTTY);return W1(t)}Pj.exports={supportsColor:yse,stdout:W1(G1(!0,Rj.isatty(1))),stderr:W1(G1(!0,Rj.isatty(2)))}});var Bj=ee(function(Dj,Cg){var bse=Tt("tty"),Tg=Tt("util");Dj.init=Ese;Dj.log=vse;Dj.formatArgs=Sse;Dj.save=_se;Dj.load=kse;Dj.useColors=xse;Dj.destroy=Tg.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");Dj.colors=[6,2,3,4,5,1];try{let e=zj();if(e&&(e.stderr||e).level>=2)Dj.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221]}catch(e){}Dj.inspectOpts=Object.keys(process.env).filter((e)=>/^debug_/i.test(e)).reduce((e,t)=>{let r=t.substring(6).toLowerCase().replace(/_([a-z])/g,(n,o)=>o.toUpperCase()),i=process.env[t];if(/^(yes|on|true|enabled)$/i.test(i))i=!0;else if(/^(no|off|false|disabled)$/i.test(i))i=!1;else if(i==="null")i=null;else i=Number(i);return e[r]=i,e},{});function xse(){return"colors"in Dj.inspectOpts?Boolean(Dj.inspectOpts.colors):bse.isatty(process.stderr.fd)}function Sse(e){let{namespace:t,useColors:r}=this;if(r){let i=this.color,n="\x1B[3"+(i<8?i:"8;5;"+i),o=` ${n};1m${t} \x1B[0m`;e[0]=o+e[0].split(`
274
274
  `).join(`
275
- `+o),e.push(n+"m+"+Cg.exports.humanize(this.diff)+"\x1B[0m")}else e[0]=wse()+t+" "+e[0]}function wse(){if(D6.inspectOpts.hideDate)return"";return new Date().toISOString()+" "}function vse(...e){return process.stderr.write(Tg.formatWithOptions(D6.inspectOpts,...e)+`
276
- `)}function _se(e){if(e)process.env.DEBUG=e;else delete process.env.DEBUG}function kse(){return process.env.DEBUG}function Ese(e){e.inspectOpts={};let t=Object.keys(D6.inspectOpts);for(let r=0;r<t.length;r++)e.inspectOpts[t[r]]=D6.inspectOpts[t[r]]}Cg.exports=V1()(D6);var{formatters:N6}=Cg.exports;N6.o=function(e){return this.inspectOpts.colors=this.useColors,Tg.inspect(e,this.inspectOpts).split(`
277
- `).map((t)=>t.trim()).join(" ")};N6.O=function(e){return this.inspectOpts.colors=this.useColors,Tg.inspect(e,this.inspectOpts)}});var j6=ee(function(wDe,Q1){if(typeof process>"u"||process.type==="renderer"||!1||process.__nwjs)Q1.exports=C6();else Q1.exports=B6()});function U6(e,t,r){let i={_bufferIndex:-1,_index:0,line:r&&r.line||1,column:r&&r.column||1,offset:r&&r.offset||0},n={},o=[],s=[],a=[],c=!0,l={attempt:H(Z),check:H(D),consume:z,enter:j,exit:E,interrupt:H(D,{interrupt:!0})},u={code:w.eof,containerState:{},defineSkip:v,events:[],now:b,parser:e,previous:w.eof,sliceSerialize:y,sliceStream:g,write:m},d=t.tokenize.call(u,l),p;if(t.resolveAll)o.push(t);return u;function m(N){if(s=Nr(s,N),A(),s[s.length-1]!==w.eof)return[];return X(t,0),u.events=Qc(o,u.events,u),u.events}function y(N,I){return zse(g(N),I)}function g(N){return Pse(s,N)}function b(){let{_bufferIndex:N,_index:I,line:R,column:O,offset:F}=i;return{_bufferIndex:N,_index:I,line:R,column:O,offset:F}}function v(N){n[N.line]=N.column,P(),ia("position: define skip: `%j`",i)}function A(){let N;while(i._index<s.length){let I=s[i._index];if(typeof I==="string"){if(N=i._index,i._bufferIndex<0)i._bufferIndex=0;while(i._index===N&&i._bufferIndex<I.length)T(I.charCodeAt(i._bufferIndex))}else T(I)}}function T(N){B(c===!0,"expected character to be consumed"),c=void 0,ia("main: passing `%s` to %s",N,d&&d.name),p=N,B(typeof d==="function","expected state"),d=d(N)}function z(N){if(B(N===p,"expected given code to equal expected code"),ia("consume: `%s`",N),B(c===void 0,"expected code to not have been consumed: this might be because `return x(code)` instead of `return x` was used"),B(N===null?u.events.length===0||u.events[u.events.length-1][0]==="exit":u.events[u.events.length-1][0]==="enter","expected last token to be open"),ve(N))i.line++,i.column=1,i.offset+=N===w.carriageReturnLineFeed?2:1,P(),ia("position: after eol: `%j`",i);else if(N!==w.virtualSpace)i.column++,i.offset++;if(i._bufferIndex<0)i._index++;else if(i._bufferIndex++,i._bufferIndex===s[i._index].length)i._bufferIndex=-1,i._index++;u.previous=N,c=!0}function j(N,I){let R=I||{};return R.type=N,R.start=b(),B(typeof N==="string","expected string type"),B(N.length>0,"expected non-empty string"),ia("enter: `%s`",N),u.events.push(["enter",R,u]),a.push(R),R}function E(N){B(typeof N==="string","expected string type"),B(N.length>0,"expected non-empty string");let I=a.pop();return B(I,"cannot close w/o open tokens"),I.end=b(),B(N===I.type,"expected exit token to match current token"),B(!(I.start._index===I.end._index&&I.start._bufferIndex===I.end._bufferIndex),"expected non-empty token (`"+N+"`)"),ia("exit: `%s`",I.type),u.events.push(["exit",I,u]),I}function Z(N,I){X(N,I.from)}function D(N,I){I.restore()}function H(N,I){return R;function R(O,F,L){let V,_,te,ue;return Array.isArray(O)?Se(O):("tokenize"in O)?Se([O]):C(O);function C(_e){return ze;function ze(Ve){let Xe=Ve!==null&&_e[Ve],St=Ve!==null&&_e.null,Lt=[...Array.isArray(Xe)?Xe:Xe?[Xe]:[],...Array.isArray(St)?St:St?[St]:[]];return Se(Lt)(Ve)}}function Se(_e){if(V=_e,_=0,_e.length===0)return B(L,"expected `bogusState` to be given"),L;return Ee(_e[_])}function Ee(_e){return ze;function ze(Ve){if(ue=M(),te=_e,!_e.partial)u.currentConstruct=_e;if(B(u.parser.constructs.disable.null,"expected `disable.null` to be populated"),_e.name&&u.parser.constructs.disable.null.includes(_e.name))return Ce(Ve);return _e.tokenize.call(I?Object.assign(Object.create(u),I):u,l,$e,Ce)(Ve)}}function $e(_e){return B(_e===p,"expected code"),c=!0,N(te,ue),F}function Ce(_e){if(B(_e===p,"expected code"),c=!0,ue.restore(),++_<V.length)return Ee(V[_]);return L}}}function X(N,I){if(N.resolveAll&&!o.includes(N))o.push(N);if(N.resolve)nr(u.events,I,u.events.length-I,N.resolve(u.events.slice(I),u));if(N.resolveTo)u.events=N.resolveTo(u.events,u);B(N.partial||u.events.length===0||u.events[u.events.length-1][0]==="exit","expected last token to end")}function M(){let N=b(),I=u.previous,R=u.currentConstruct,O=u.events.length,F=Array.from(a);return{from:O,restore:L};function L(){i=N,u.previous=I,u.currentConstruct=R,u.events.length=O,a=F,P(),ia("position: restore: `%j`",i)}}function P(){if(i.line in n&&i.column<2)i.column=n[i.line],i.offset+=n[i.line]-1}}function Pse(e,t){let r=t.start._index,i=t.start._bufferIndex,n=t.end._index,o=t.end._bufferIndex,s;if(r===n)B(o>-1,"expected non-negative end buffer index"),B(i>-1,"expected non-negative start buffer index"),s=[e[r].slice(i,o)];else{if(s=e.slice(r,n),i>-1){let a=s[0];if(typeof a==="string")s[0]=a.slice(i);else B(i===0,"expected `startBufferIndex` to be `0`"),s.shift()}if(o>0)s.push(e[n].slice(0,o))}return s}function zse(e,t){let r=-1,i=[],n;while(++r<e.length){let o=e[r],s;if(typeof o==="string")s=o;else switch(o){case w.carriageReturn:{s=on.cr;break}case w.lineFeed:{s=on.lf;break}case w.carriageReturnLineFeed:{s=on.cr+on.lf;break}case w.horizontalTab:{s=t?on.space:on.ht;break}case w.virtualSpace:{if(!t&&n)continue;s=on.space;break}default:B(typeof o==="number","expected number"),s=String.fromCharCode(o)}n=o===w.horizontalTab,i.push(s)}return i.join("")}var q6,ia;var M6=x(()=>{tt();ot();zo();Fe();q6=rc(j6(),1),ia=q6.default("micromark")});function Y1(e){let i={constructs:zj([J1,...(e||{}).extensions||[]]),content:n(Uj),defined:[],document:n(Zj),flow:n(y6),lazy:{},string:n(S6),text:n(w6)};return i;function n(o){return s;function s(a){return U6(i,o,a)}}}var F6=x(()=>{Nj();Mj();Hj();b6();K1();k6();M6()});function X1(e){while(!Sg(e));return e}var Z6=x(()=>{$1()});function eI(){let e=1,t="",r=!0,i;return n;function n(o,s,a){let c=[],l,u,d,p,m;if(o=t+(typeof o==="string"?o.toString():new TextDecoder(s||void 0).decode(o)),d=0,t="",r){if(o.charCodeAt(0)===w.byteOrderMarker)d++;r=void 0}while(d<o.length){if(H6.lastIndex=d,l=H6.exec(o),p=l&&l.index!==void 0?l.index:o.length,m=o.charCodeAt(p),!l){t=o.slice(d);break}if(m===w.lf&&d===p&&i)c.push(w.carriageReturnLineFeed),i=void 0;else{if(i)c.push(w.carriageReturn),i=void 0;if(d<p)c.push(o.slice(d,p)),e+=p-d;switch(m){case w.nul:{c.push(w.replacementCharacter),e++;break}case w.ht:{u=Math.ceil(e/be.tabSize)*be.tabSize,c.push(w.horizontalTab);while(e++<u)c.push(w.virtualSpace);break}case w.lf:{c.push(w.lineFeed),e=1;break}default:i=!0,e=1}}d=p+1}if(a){if(i)c.push(w.carriageReturn);if(t)c.push(t);c.push(w.eof)}return c}}var H6;var K6=x(()=>{Fe();H6=/[\0\t\n\r]/g});var J6=x(()=>{F6();Z6();K6()});function $g(e){return e.replace(Nse,Dse)}function Dse(e,t,r){if(t)return t;if(r.charCodeAt(0)===w.numberSign){let n=r.charCodeAt(1),o=n===w.lowercaseX||n===w.uppercaseX;return pg(r.slice(o?2:1),o?be.numericBaseHexadecimal:be.numericBaseDecimal)}return Wc(r)||e}var Nse;var tI=x(()=>{fg();E1();Fe();Nse=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi});function Bo(e){if(!e||typeof e!=="object")return"";if("position"in e||"type"in e)return V6(e.position);if("start"in e||"end"in e)return V6(e);if("line"in e||"column"in e)return rI(e);return""}function rI(e){return W6(e&&e.line)+":"+W6(e&&e.column)}function V6(e){return rI(e&&e.start)+"-"+rI(e&&e.end)}function W6(e){return e&&typeof e==="number"?e:1}var nI=()=>{};function iI(e,t,r){if(t&&typeof t==="object")r=t,t=void 0;return Lse(r)(X1(Y1(r).document().write(eI()(e,t,!0))))}function Lse(e){let t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:o(Xa),autolinkProtocol:H,autolinkEmail:H,atxHeading:o(Yr),blockQuote:o(Ve),characterEscape:H,characterReference:H,codeFenced:o(Xe),codeFencedFenceInfo:s,codeFencedFenceMeta:s,codeIndented:o(Xe,s),codeText:o(St,s),codeTextData:H,data:H,codeFlowValue:H,definition:o(Lt),definitionDestinationString:s,definitionLabelString:s,definitionTitleString:s,emphasis:o(hr),hardBreakEscape:o(Xr),hardBreakTrailing:o(Xr),htmlFlow:o(hn,s),htmlFlowData:H,htmlText:o(hn,s),htmlTextData:H,image:o(Ya),label:s,link:o(Xa),listItem:o(ec),listItemValue:p,listOrdered:o(Os,d),listUnordered:o(Os),paragraph:o(Ou),reference:C,referenceString:s,resourceDestinationString:s,resourceTitleString:s,setextHeading:o(Yr),strong:o(Pn),thematicBreak:o(tc)},exit:{atxHeading:c(),atxHeadingSequence:j,autolink:c(),autolinkEmail:ze,autolinkProtocol:_e,blockQuote:c(),characterEscapeValue:X,characterReferenceMarkerHexadecimal:Ee,characterReferenceMarkerNumeric:Ee,characterReferenceValue:$e,characterReference:Ce,codeFenced:c(b),codeFencedFence:g,codeFencedFenceInfo:m,codeFencedFenceMeta:y,codeFlowValue:X,codeIndented:c(v),codeText:c(R),codeTextData:X,data:X,definition:c(),definitionDestinationString:z,definitionLabelString:A,definitionTitleString:T,emphasis:c(),hardBreakEscape:c(P),hardBreakTrailing:c(P),htmlFlow:c(N),htmlFlowData:X,htmlText:c(I),htmlTextData:X,image:c(F),label:V,labelText:L,lineEnding:M,link:c(O),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:Se,resourceDestinationString:_,resourceTitleString:te,resource:ue,setextHeading:c(D),setextHeadingLineSequence:Z,setextHeadingText:E,strong:c(),thematicBreak:c()}};Y6(t,(e||{}).mdastExtensions||[]);let r={};return i;function i(re){let ne={type:"root",children:[]},h={stack:[ne],tokenStack:[],config:t,enter:a,exit:l,buffer:s,resume:u,data:r},U=[],G=-1;while(++G<re.length)if(re[G][1].type===S.listOrdered||re[G][1].type===S.listUnordered)if(re[G][0]==="enter")U.push(G);else{let ie=U.pop();B(typeof ie==="number","expected list to be open"),G=n(re,ie,G)}G=-1;while(++G<re.length){let ie=t[re[G][0]];if(Q6.call(ie,re[G][1].type))ie[re[G][1].type].call(Object.assign({sliceSerialize:re[G][2].sliceSerialize},h),re[G][1])}if(h.tokenStack.length>0){let ie=h.tokenStack[h.tokenStack.length-1];(ie[1]||G6).call(h,void 0,ie[0])}ne.position={start:jo(re.length>0?re[0][1].start:{line:1,column:1,offset:0}),end:jo(re.length>0?re[re.length-2][1].end:{line:1,column:1,offset:0})},G=-1;while(++G<t.transforms.length)ne=t.transforms[G](ne)||ne;return ne}function n(re,ne,h){let U=ne-1,G=-1,ie=!1,Y,de,k,W;while(++U<=h){let le=re[U];switch(le[1].type){case S.listUnordered:case S.listOrdered:case S.blockQuote:{if(le[0]==="enter")G++;else G--;W=void 0;break}case S.lineEndingBlank:{if(le[0]==="enter"){if(Y&&!W&&!G&&!k)k=U;W=void 0}break}case S.linePrefix:case S.listItemValue:case S.listItemMarker:case S.listItemPrefix:case S.listItemPrefixWhitespace:break;default:W=void 0}if(!G&&le[0]==="enter"&&le[1].type===S.listItemPrefix||G===-1&&le[0]==="exit"&&(le[1].type===S.listUnordered||le[1].type===S.listOrdered)){if(Y){let se=U;de=void 0;while(se--){let ae=re[se];if(ae[1].type===S.lineEnding||ae[1].type===S.lineEndingBlank){if(ae[0]==="exit")continue;if(de)re[de][1].type=S.lineEndingBlank,ie=!0;ae[1].type=S.lineEnding,de=se}else if(ae[1].type===S.linePrefix||ae[1].type===S.blockQuotePrefix||ae[1].type===S.blockQuotePrefixWhitespace||ae[1].type===S.blockQuoteMarker||ae[1].type===S.listItemIndent);else break}if(k&&(!de||k<de))Y._spread=!0;Y.end=Object.assign({},de?re[de][1].start:le[1].end),re.splice(de||U,0,["exit",Y,le[2]]),U++,h++}if(le[1].type===S.listItemPrefix){let se={type:"listItem",_spread:!1,start:Object.assign({},le[1].start),end:void 0};Y=se,re.splice(U,0,["enter",se,le[2]]),U++,h++,k=void 0,W=!0}}}return re[ne][1]._spread=ie,h}function o(re,ne){return h;function h(U){if(a.call(this,re(U),U),ne)ne.call(this,U)}}function s(){this.stack.push({type:"fragment",children:[]})}function a(re,ne,h){let U=this.stack[this.stack.length-1];B(U,"expected `parent`"),B("children"in U,"expected `parent`"),U.children.push(re),this.stack.push(re),this.tokenStack.push([ne,h||void 0]),re.position={start:jo(ne.start),end:void 0}}function c(re){return ne;function ne(h){if(re)re.call(this,h);l.call(this,h)}}function l(re,ne){let h=this.stack.pop();B(h,"expected `node`");let U=this.tokenStack.pop();if(!U)throw Error("Cannot close `"+re.type+"` ("+Bo({start:re.start,end:re.end})+"): it\u2019s not open");else if(U[0].type!==re.type)if(ne)ne.call(this,re,U[0]);else(U[1]||G6).call(this,re,U[0]);B(h.type!=="fragment","unexpected fragment `exit`ed"),B(h.position,"expected `position` to be defined"),h.position.end=jo(re.end)}function u(){return Ys(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function p(re){if(this.data.expectingFirstListItemValue){let ne=this.stack[this.stack.length-2];B(ne,"expected nodes on stack"),B(ne.type==="list","expected list on stack"),ne.start=Number.parseInt(this.sliceSerialize(re),be.numericBaseDecimal),this.data.expectingFirstListItemValue=void 0}}function m(){let re=this.resume(),ne=this.stack[this.stack.length-1];B(ne,"expected node on stack"),B(ne.type==="code","expected code on stack"),ne.lang=re}function y(){let re=this.resume(),ne=this.stack[this.stack.length-1];B(ne,"expected node on stack"),B(ne.type==="code","expected code on stack"),ne.meta=re}function g(){if(this.data.flowCodeInside)return;this.buffer(),this.data.flowCodeInside=!0}function b(){let re=this.resume(),ne=this.stack[this.stack.length-1];B(ne,"expected node on stack"),B(ne.type==="code","expected code on stack"),ne.value=re.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function v(){let re=this.resume(),ne=this.stack[this.stack.length-1];B(ne,"expected node on stack"),B(ne.type==="code","expected code on stack"),ne.value=re.replace(/(\r?\n|\r)$/g,"")}function A(re){let ne=this.resume(),h=this.stack[this.stack.length-1];B(h,"expected node on stack"),B(h.type==="definition","expected definition on stack"),h.label=ne,h.identifier=Ni(this.sliceSerialize(re)).toLowerCase()}function T(){let re=this.resume(),ne=this.stack[this.stack.length-1];B(ne,"expected node on stack"),B(ne.type==="definition","expected definition on stack"),ne.title=re}function z(){let re=this.resume(),ne=this.stack[this.stack.length-1];B(ne,"expected node on stack"),B(ne.type==="definition","expected definition on stack"),ne.url=re}function j(re){let ne=this.stack[this.stack.length-1];if(B(ne,"expected node on stack"),B(ne.type==="heading","expected heading on stack"),!ne.depth){let h=this.sliceSerialize(re).length;B(h===1||h===2||h===3||h===4||h===5||h===6,"expected `depth` between `1` and `6`"),ne.depth=h}}function E(){this.data.setextHeadingSlurpLineEnding=!0}function Z(re){let ne=this.stack[this.stack.length-1];B(ne,"expected node on stack"),B(ne.type==="heading","expected heading on stack"),ne.depth=this.sliceSerialize(re).codePointAt(0)===w.equalsTo?1:2}function D(){this.data.setextHeadingSlurpLineEnding=void 0}function H(re){let ne=this.stack[this.stack.length-1];B(ne,"expected node on stack"),B("children"in ne,"expected parent on stack");let h=ne.children,U=h[h.length-1];if(!U||U.type!=="text")U=Ru(),U.position={start:jo(re.start),end:void 0},h.push(U);this.stack.push(U)}function X(re){let ne=this.stack.pop();B(ne,"expected a `node` to be on the stack"),B("value"in ne,"expected a `literal` to be on the stack"),B(ne.position,"expected `node` to have an open position"),ne.value+=this.sliceSerialize(re),ne.position.end=jo(re.end)}function M(re){let ne=this.stack[this.stack.length-1];if(B(ne,"expected `node`"),this.data.atHardBreak){B("children"in ne,"expected `parent`");let h=ne.children[ne.children.length-1];B(h.position,"expected tail to have a starting position"),h.position.end=jo(re.end),this.data.atHardBreak=void 0;return}if(!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(ne.type))H.call(this,re),X.call(this,re)}function P(){this.data.atHardBreak=!0}function N(){let re=this.resume(),ne=this.stack[this.stack.length-1];B(ne,"expected node on stack"),B(ne.type==="html","expected html on stack"),ne.value=re}function I(){let re=this.resume(),ne=this.stack[this.stack.length-1];B(ne,"expected node on stack"),B(ne.type==="html","expected html on stack"),ne.value=re}function R(){let re=this.resume(),ne=this.stack[this.stack.length-1];B(ne,"expected node on stack"),B(ne.type==="inlineCode","expected inline code on stack"),ne.value=re}function O(){let re=this.stack[this.stack.length-1];if(B(re,"expected node on stack"),B(re.type==="link","expected link on stack"),this.data.inReference){let ne=this.data.referenceType||"shortcut";re.type+="Reference",re.referenceType=ne,delete re.url,delete re.title}else delete re.identifier,delete re.label;this.data.referenceType=void 0}function F(){let re=this.stack[this.stack.length-1];if(B(re,"expected node on stack"),B(re.type==="image","expected image on stack"),this.data.inReference){let ne=this.data.referenceType||"shortcut";re.type+="Reference",re.referenceType=ne,delete re.url,delete re.title}else delete re.identifier,delete re.label;this.data.referenceType=void 0}function L(re){let ne=this.sliceSerialize(re),h=this.stack[this.stack.length-2];B(h,"expected ancestor on stack"),B(h.type==="image"||h.type==="link","expected image or link on stack"),h.label=$g(ne),h.identifier=Ni(ne).toLowerCase()}function V(){let re=this.stack[this.stack.length-1];B(re,"expected node on stack"),B(re.type==="fragment","expected fragment on stack");let ne=this.resume(),h=this.stack[this.stack.length-1];if(B(h,"expected node on stack"),B(h.type==="image"||h.type==="link","expected image or link on stack"),this.data.inReference=!0,h.type==="link"){let U=re.children;h.children=U}else h.alt=ne}function _(){let re=this.resume(),ne=this.stack[this.stack.length-1];B(ne,"expected node on stack"),B(ne.type==="image"||ne.type==="link","expected image or link on stack"),ne.url=re}function te(){let re=this.resume(),ne=this.stack[this.stack.length-1];B(ne,"expected node on stack"),B(ne.type==="image"||ne.type==="link","expected image or link on stack"),ne.title=re}function ue(){this.data.inReference=void 0}function C(){this.data.referenceType="collapsed"}function Se(re){let ne=this.resume(),h=this.stack[this.stack.length-1];B(h,"expected node on stack"),B(h.type==="image"||h.type==="link","expected image reference or link reference on stack"),h.label=ne,h.identifier=Ni(this.sliceSerialize(re)).toLowerCase(),this.data.referenceType="full"}function Ee(re){B(re.type==="characterReferenceMarkerNumeric"||re.type==="characterReferenceMarkerHexadecimal"),this.data.characterReferenceType=re.type}function $e(re){let ne=this.sliceSerialize(re),h=this.data.characterReferenceType,U;if(h)U=pg(ne,h===S.characterReferenceMarkerNumeric?be.numericBaseDecimal:be.numericBaseHexadecimal),this.data.characterReferenceType=void 0;else{let ie=Wc(ne);B(ie!==!1,"expected reference to decode"),U=ie}let G=this.stack[this.stack.length-1];B(G,"expected `node`"),B("value"in G,"expected `node.value`"),G.value+=U}function Ce(re){let ne=this.stack.pop();B(ne,"expected `node`"),B(ne.position,"expected `node.position`"),ne.position.end=jo(re.end)}function _e(re){X.call(this,re);let ne=this.stack[this.stack.length-1];B(ne,"expected node on stack"),B(ne.type==="link","expected link on stack"),ne.url=this.sliceSerialize(re)}function ze(re){X.call(this,re);let ne=this.stack[this.stack.length-1];B(ne,"expected node on stack"),B(ne.type==="link","expected link on stack"),ne.url="mailto:"+this.sliceSerialize(re)}function Ve(){return{type:"blockquote",children:[]}}function Xe(){return{type:"code",lang:null,meta:null,value:""}}function St(){return{type:"inlineCode",value:""}}function Lt(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function hr(){return{type:"emphasis",children:[]}}function Yr(){return{type:"heading",depth:0,children:[]}}function Xr(){return{type:"break"}}function hn(){return{type:"html",value:""}}function Ya(){return{type:"image",title:null,url:"",alt:null}}function Xa(){return{type:"link",title:null,url:"",children:[]}}function Os(re){return{type:"list",ordered:re.type==="listOrdered",start:null,spread:re._spread,children:[]}}function ec(re){return{type:"listItem",spread:re._spread,checked:null,children:[]}}function Ou(){return{type:"paragraph",children:[]}}function Pn(){return{type:"strong",children:[]}}function Ru(){return{type:"text",value:""}}function tc(){return{type:"thematicBreak"}}}function jo(e){return{line:e.line,column:e.column,offset:e.offset}}function Y6(e,t){let r=-1;while(++r<t.length){let i=t[r];if(Array.isArray(i))Y6(e,i);else Bse(e,i)}}function Bse(e,t){let r;for(r in t)if(Q6.call(t,r))switch(r){case"canContainEols":{let i=t[r];if(i)e[r].push(...i);break}case"transforms":{let i=t[r];if(i)e[r].push(...i);break}case"enter":case"exit":{let i=t[r];if(i)Object.assign(e[r],i);break}}}function G6(e,t){if(e)throw Error("Cannot close `"+e.type+"` ("+Bo({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Bo({start:t.start,end:t.end})+") is open");else throw Error("Cannot close document, a token (`"+t.type+"`, "+Bo({start:t.start,end:t.end})+") is still open")}var Q6;var X6=x(()=>{tt();dg();J6();E1();tI();mg();Fe();fg();nI();Q6={}.hasOwnProperty});var eq=x(()=>{X6()});function Og(e){let t=this;t.parser=r;function r(i){return iI(i,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}var tq=x(()=>{eq()});var rq=x(()=>{tq()});function iq(e,t){let r=t||{};function i(n,...o){let{invalid:s,handlers:a}=i;if(n&&nq.call(n,e)){let c=String(n[e]);s=nq.call(a,c)?a[c]:i.unknown}if(s)return s.call(this,n,...o)}return i.handlers=r.handlers||{},i.invalid=r.invalid,i.unknown=r.unknown,i}var nq;var oq=x(()=>{nq={}.hasOwnProperty});function oI(e,t){let r=-1,i;if(t.extensions)while(++r<t.extensions.length)oI(e,t.extensions[r]);for(i in t)if(jse.call(t,i))switch(i){case"extensions":break;case"unsafe":{sq(e[i],t[i]);break}case"join":{sq(e[i],t[i]);break}case"handlers":{qse(e[i],t[i]);break}default:e.options[i]=t[i]}return e}function sq(e,t){if(t)e.push(...t)}function qse(e,t){if(t)Object.assign(e,t)}var jse;var aq=x(()=>{jse={}.hasOwnProperty});function cq(e,t,r,i){let n=r.enter("blockquote"),o=r.createTracker(i);o.move("> "),o.shift(2);let s=r.indentLines(r.containerFlow(e,o.current()),Use);return n(),s}function Use(e,t,r){return">"+(r?"":" ")+e}function Rg(e,t){return lq(e,t.inConstruct,!0)&&!lq(e,t.notInConstruct,!1)}function lq(e,t,r){if(typeof t==="string")t=[t];if(!t||t.length===0)return r;let i=-1;while(++i<t.length)if(e.includes(t[i]))return!0;return!1}function sI(e,t,r,i){let n=-1;while(++n<r.unsafe.length)if(r.unsafe[n].character===`
275
+ `+o),e.push(n+"m+"+Cg.exports.humanize(this.diff)+"\x1B[0m")}else e[0]=wse()+t+" "+e[0]}function wse(){if(Dj.inspectOpts.hideDate)return"";return new Date().toISOString()+" "}function vse(...e){return process.stderr.write(Tg.formatWithOptions(Dj.inspectOpts,...e)+`
276
+ `)}function _se(e){if(e)process.env.DEBUG=e;else delete process.env.DEBUG}function kse(){return process.env.DEBUG}function Ese(e){e.inspectOpts={};let t=Object.keys(Dj.inspectOpts);for(let r=0;r<t.length;r++)e.inspectOpts[t[r]]=Dj.inspectOpts[t[r]]}Cg.exports=V1()(Dj);var{formatters:Nj}=Cg.exports;Nj.o=function(e){return this.inspectOpts.colors=this.useColors,Tg.inspect(e,this.inspectOpts).split(`
277
+ `).map((t)=>t.trim()).join(" ")};Nj.O=function(e){return this.inspectOpts.colors=this.useColors,Tg.inspect(e,this.inspectOpts)}});var jj=ee(function(SDe,Q1){if(typeof process>"u"||process.type==="renderer"||!1||process.__nwjs)Q1.exports=Cj();else Q1.exports=Bj()});function Uj(e,t,r){let i={_bufferIndex:-1,_index:0,line:r&&r.line||1,column:r&&r.column||1,offset:r&&r.offset||0},n={},o=[],s=[],a=[],c=!0,l={attempt:H(Z),check:H(D),consume:z,enter:j,exit:E,interrupt:H(D,{interrupt:!0})},u={code:w.eof,containerState:{},defineSkip:v,events:[],now:b,parser:e,previous:w.eof,sliceSerialize:y,sliceStream:g,write:m},d=t.tokenize.call(u,l),p;if(t.resolveAll)o.push(t);return u;function m(N){if(s=Nr(s,N),A(),s[s.length-1]!==w.eof)return[];return X(t,0),u.events=Qc(o,u.events,u),u.events}function y(N,I){return zse(g(N),I)}function g(N){return Pse(s,N)}function b(){let{_bufferIndex:N,_index:I,line:R,column:O,offset:F}=i;return{_bufferIndex:N,_index:I,line:R,column:O,offset:F}}function v(N){n[N.line]=N.column,P(),ia("position: define skip: `%j`",i)}function A(){let N;while(i._index<s.length){let I=s[i._index];if(typeof I==="string"){if(N=i._index,i._bufferIndex<0)i._bufferIndex=0;while(i._index===N&&i._bufferIndex<I.length)T(I.charCodeAt(i._bufferIndex))}else T(I)}}function T(N){B(c===!0,"expected character to be consumed"),c=void 0,ia("main: passing `%s` to %s",N,d&&d.name),p=N,B(typeof d==="function","expected state"),d=d(N)}function z(N){if(B(N===p,"expected given code to equal expected code"),ia("consume: `%s`",N),B(c===void 0,"expected code to not have been consumed: this might be because `return x(code)` instead of `return x` was used"),B(N===null?u.events.length===0||u.events[u.events.length-1][0]==="exit":u.events[u.events.length-1][0]==="enter","expected last token to be open"),ve(N))i.line++,i.column=1,i.offset+=N===w.carriageReturnLineFeed?2:1,P(),ia("position: after eol: `%j`",i);else if(N!==w.virtualSpace)i.column++,i.offset++;if(i._bufferIndex<0)i._index++;else if(i._bufferIndex++,i._bufferIndex===s[i._index].length)i._bufferIndex=-1,i._index++;u.previous=N,c=!0}function j(N,I){let R=I||{};return R.type=N,R.start=b(),B(typeof N==="string","expected string type"),B(N.length>0,"expected non-empty string"),ia("enter: `%s`",N),u.events.push(["enter",R,u]),a.push(R),R}function E(N){B(typeof N==="string","expected string type"),B(N.length>0,"expected non-empty string");let I=a.pop();return B(I,"cannot close w/o open tokens"),I.end=b(),B(N===I.type,"expected exit token to match current token"),B(!(I.start._index===I.end._index&&I.start._bufferIndex===I.end._bufferIndex),"expected non-empty token (`"+N+"`)"),ia("exit: `%s`",I.type),u.events.push(["exit",I,u]),I}function Z(N,I){X(N,I.from)}function D(N,I){I.restore()}function H(N,I){return R;function R(O,F,L){let V,_,te,ue;return Array.isArray(O)?Se(O):("tokenize"in O)?Se([O]):C(O);function C(_e){return ze;function ze(Ve){let Xe=Ve!==null&&_e[Ve],St=Ve!==null&&_e.null,Lt=[...Array.isArray(Xe)?Xe:Xe?[Xe]:[],...Array.isArray(St)?St:St?[St]:[]];return Se(Lt)(Ve)}}function Se(_e){if(V=_e,_=0,_e.length===0)return B(L,"expected `bogusState` to be given"),L;return Ee(_e[_])}function Ee(_e){return ze;function ze(Ve){if(ue=M(),te=_e,!_e.partial)u.currentConstruct=_e;if(B(u.parser.constructs.disable.null,"expected `disable.null` to be populated"),_e.name&&u.parser.constructs.disable.null.includes(_e.name))return Ce(Ve);return _e.tokenize.call(I?Object.assign(Object.create(u),I):u,l,$e,Ce)(Ve)}}function $e(_e){return B(_e===p,"expected code"),c=!0,N(te,ue),F}function Ce(_e){if(B(_e===p,"expected code"),c=!0,ue.restore(),++_<V.length)return Ee(V[_]);return L}}}function X(N,I){if(N.resolveAll&&!o.includes(N))o.push(N);if(N.resolve)nr(u.events,I,u.events.length-I,N.resolve(u.events.slice(I),u));if(N.resolveTo)u.events=N.resolveTo(u.events,u);B(N.partial||u.events.length===0||u.events[u.events.length-1][0]==="exit","expected last token to end")}function M(){let N=b(),I=u.previous,R=u.currentConstruct,O=u.events.length,F=Array.from(a);return{from:O,restore:L};function L(){i=N,u.previous=I,u.currentConstruct=R,u.events.length=O,a=F,P(),ia("position: restore: `%j`",i)}}function P(){if(i.line in n&&i.column<2)i.column=n[i.line],i.offset+=n[i.line]-1}}function Pse(e,t){let r=t.start._index,i=t.start._bufferIndex,n=t.end._index,o=t.end._bufferIndex,s;if(r===n)B(o>-1,"expected non-negative end buffer index"),B(i>-1,"expected non-negative start buffer index"),s=[e[r].slice(i,o)];else{if(s=e.slice(r,n),i>-1){let a=s[0];if(typeof a==="string")s[0]=a.slice(i);else B(i===0,"expected `startBufferIndex` to be `0`"),s.shift()}if(o>0)s.push(e[n].slice(0,o))}return s}function zse(e,t){let r=-1,i=[],n;while(++r<e.length){let o=e[r],s;if(typeof o==="string")s=o;else switch(o){case w.carriageReturn:{s=on.cr;break}case w.lineFeed:{s=on.lf;break}case w.carriageReturnLineFeed:{s=on.cr+on.lf;break}case w.horizontalTab:{s=t?on.space:on.ht;break}case w.virtualSpace:{if(!t&&n)continue;s=on.space;break}default:B(typeof o==="number","expected number"),s=String.fromCharCode(o)}n=o===w.horizontalTab,i.push(s)}return i.join("")}var qj,ia;var Mj=x(()=>{tt();ot();zo();Fe();qj=rc(jj(),1),ia=qj.default("micromark")});function Y1(e){let i={constructs:z6([J1,...(e||{}).extensions||[]]),content:n(U6),defined:[],document:n(Z6),flow:n(yj),lazy:{},string:n(Sj),text:n(wj)};return i;function n(o){return s;function s(a){return Uj(i,o,a)}}}var Fj=x(()=>{N6();M6();H6();bj();K1();kj();Mj()});function X1(e){while(!Sg(e));return e}var Zj=x(()=>{$1()});function eI(){let e=1,t="",r=!0,i;return n;function n(o,s,a){let c=[],l,u,d,p,m;if(o=t+(typeof o==="string"?o.toString():new TextDecoder(s||void 0).decode(o)),d=0,t="",r){if(o.charCodeAt(0)===w.byteOrderMarker)d++;r=void 0}while(d<o.length){if(Hj.lastIndex=d,l=Hj.exec(o),p=l&&l.index!==void 0?l.index:o.length,m=o.charCodeAt(p),!l){t=o.slice(d);break}if(m===w.lf&&d===p&&i)c.push(w.carriageReturnLineFeed),i=void 0;else{if(i)c.push(w.carriageReturn),i=void 0;if(d<p)c.push(o.slice(d,p)),e+=p-d;switch(m){case w.nul:{c.push(w.replacementCharacter),e++;break}case w.ht:{u=Math.ceil(e/be.tabSize)*be.tabSize,c.push(w.horizontalTab);while(e++<u)c.push(w.virtualSpace);break}case w.lf:{c.push(w.lineFeed),e=1;break}default:i=!0,e=1}}d=p+1}if(a){if(i)c.push(w.carriageReturn);if(t)c.push(t);c.push(w.eof)}return c}}var Hj;var Kj=x(()=>{Fe();Hj=/[\0\t\n\r]/g});var Jj=x(()=>{Fj();Zj();Kj()});function $g(e){return e.replace(Nse,Dse)}function Dse(e,t,r){if(t)return t;if(r.charCodeAt(0)===w.numberSign){let n=r.charCodeAt(1),o=n===w.lowercaseX||n===w.uppercaseX;return pg(r.slice(o?2:1),o?be.numericBaseHexadecimal:be.numericBaseDecimal)}return Wc(r)||e}var Nse;var tI=x(()=>{fg();E1();Fe();Nse=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi});function Bo(e){if(!e||typeof e!=="object")return"";if("position"in e||"type"in e)return Vj(e.position);if("start"in e||"end"in e)return Vj(e);if("line"in e||"column"in e)return rI(e);return""}function rI(e){return Wj(e&&e.line)+":"+Wj(e&&e.column)}function Vj(e){return rI(e&&e.start)+"-"+rI(e&&e.end)}function Wj(e){return e&&typeof e==="number"?e:1}var nI=()=>{};function iI(e,t,r){if(t&&typeof t==="object")r=t,t=void 0;return Lse(r)(X1(Y1(r).document().write(eI()(e,t,!0))))}function Lse(e){let t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:o(Xa),autolinkProtocol:H,autolinkEmail:H,atxHeading:o(Yr),blockQuote:o(Ve),characterEscape:H,characterReference:H,codeFenced:o(Xe),codeFencedFenceInfo:s,codeFencedFenceMeta:s,codeIndented:o(Xe,s),codeText:o(St,s),codeTextData:H,data:H,codeFlowValue:H,definition:o(Lt),definitionDestinationString:s,definitionLabelString:s,definitionTitleString:s,emphasis:o(hr),hardBreakEscape:o(Xr),hardBreakTrailing:o(Xr),htmlFlow:o(hn,s),htmlFlowData:H,htmlText:o(hn,s),htmlTextData:H,image:o(Ya),label:s,link:o(Xa),listItem:o(ec),listItemValue:p,listOrdered:o(Os,d),listUnordered:o(Os),paragraph:o(Ou),reference:C,referenceString:s,resourceDestinationString:s,resourceTitleString:s,setextHeading:o(Yr),strong:o(Pn),thematicBreak:o(tc)},exit:{atxHeading:c(),atxHeadingSequence:j,autolink:c(),autolinkEmail:ze,autolinkProtocol:_e,blockQuote:c(),characterEscapeValue:X,characterReferenceMarkerHexadecimal:Ee,characterReferenceMarkerNumeric:Ee,characterReferenceValue:$e,characterReference:Ce,codeFenced:c(b),codeFencedFence:g,codeFencedFenceInfo:m,codeFencedFenceMeta:y,codeFlowValue:X,codeIndented:c(v),codeText:c(R),codeTextData:X,data:X,definition:c(),definitionDestinationString:z,definitionLabelString:A,definitionTitleString:T,emphasis:c(),hardBreakEscape:c(P),hardBreakTrailing:c(P),htmlFlow:c(N),htmlFlowData:X,htmlText:c(I),htmlTextData:X,image:c(F),label:V,labelText:L,lineEnding:M,link:c(O),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:Se,resourceDestinationString:_,resourceTitleString:te,resource:ue,setextHeading:c(D),setextHeadingLineSequence:Z,setextHeadingText:E,strong:c(),thematicBreak:c()}};Yj(t,(e||{}).mdastExtensions||[]);let r={};return i;function i(re){let ne={type:"root",children:[]},h={stack:[ne],tokenStack:[],config:t,enter:a,exit:l,buffer:s,resume:u,data:r},U=[],G=-1;while(++G<re.length)if(re[G][1].type===S.listOrdered||re[G][1].type===S.listUnordered)if(re[G][0]==="enter")U.push(G);else{let ie=U.pop();B(typeof ie==="number","expected list to be open"),G=n(re,ie,G)}G=-1;while(++G<re.length){let ie=t[re[G][0]];if(Qj.call(ie,re[G][1].type))ie[re[G][1].type].call(Object.assign({sliceSerialize:re[G][2].sliceSerialize},h),re[G][1])}if(h.tokenStack.length>0){let ie=h.tokenStack[h.tokenStack.length-1];(ie[1]||Gj).call(h,void 0,ie[0])}ne.position={start:jo(re.length>0?re[0][1].start:{line:1,column:1,offset:0}),end:jo(re.length>0?re[re.length-2][1].end:{line:1,column:1,offset:0})},G=-1;while(++G<t.transforms.length)ne=t.transforms[G](ne)||ne;return ne}function n(re,ne,h){let U=ne-1,G=-1,ie=!1,Y,de,k,W;while(++U<=h){let le=re[U];switch(le[1].type){case S.listUnordered:case S.listOrdered:case S.blockQuote:{if(le[0]==="enter")G++;else G--;W=void 0;break}case S.lineEndingBlank:{if(le[0]==="enter"){if(Y&&!W&&!G&&!k)k=U;W=void 0}break}case S.linePrefix:case S.listItemValue:case S.listItemMarker:case S.listItemPrefix:case S.listItemPrefixWhitespace:break;default:W=void 0}if(!G&&le[0]==="enter"&&le[1].type===S.listItemPrefix||G===-1&&le[0]==="exit"&&(le[1].type===S.listUnordered||le[1].type===S.listOrdered)){if(Y){let se=U;de=void 0;while(se--){let ae=re[se];if(ae[1].type===S.lineEnding||ae[1].type===S.lineEndingBlank){if(ae[0]==="exit")continue;if(de)re[de][1].type=S.lineEndingBlank,ie=!0;ae[1].type=S.lineEnding,de=se}else if(ae[1].type===S.linePrefix||ae[1].type===S.blockQuotePrefix||ae[1].type===S.blockQuotePrefixWhitespace||ae[1].type===S.blockQuoteMarker||ae[1].type===S.listItemIndent);else break}if(k&&(!de||k<de))Y._spread=!0;Y.end=Object.assign({},de?re[de][1].start:le[1].end),re.splice(de||U,0,["exit",Y,le[2]]),U++,h++}if(le[1].type===S.listItemPrefix){let se={type:"listItem",_spread:!1,start:Object.assign({},le[1].start),end:void 0};Y=se,re.splice(U,0,["enter",se,le[2]]),U++,h++,k=void 0,W=!0}}}return re[ne][1]._spread=ie,h}function o(re,ne){return h;function h(U){if(a.call(this,re(U),U),ne)ne.call(this,U)}}function s(){this.stack.push({type:"fragment",children:[]})}function a(re,ne,h){let U=this.stack[this.stack.length-1];B(U,"expected `parent`"),B("children"in U,"expected `parent`"),U.children.push(re),this.stack.push(re),this.tokenStack.push([ne,h||void 0]),re.position={start:jo(ne.start),end:void 0}}function c(re){return ne;function ne(h){if(re)re.call(this,h);l.call(this,h)}}function l(re,ne){let h=this.stack.pop();B(h,"expected `node`");let U=this.tokenStack.pop();if(!U)throw Error("Cannot close `"+re.type+"` ("+Bo({start:re.start,end:re.end})+"): it\u2019s not open");else if(U[0].type!==re.type)if(ne)ne.call(this,re,U[0]);else(U[1]||Gj).call(this,re,U[0]);B(h.type!=="fragment","unexpected fragment `exit`ed"),B(h.position,"expected `position` to be defined"),h.position.end=jo(re.end)}function u(){return Ys(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function p(re){if(this.data.expectingFirstListItemValue){let ne=this.stack[this.stack.length-2];B(ne,"expected nodes on stack"),B(ne.type==="list","expected list on stack"),ne.start=Number.parseInt(this.sliceSerialize(re),be.numericBaseDecimal),this.data.expectingFirstListItemValue=void 0}}function m(){let re=this.resume(),ne=this.stack[this.stack.length-1];B(ne,"expected node on stack"),B(ne.type==="code","expected code on stack"),ne.lang=re}function y(){let re=this.resume(),ne=this.stack[this.stack.length-1];B(ne,"expected node on stack"),B(ne.type==="code","expected code on stack"),ne.meta=re}function g(){if(this.data.flowCodeInside)return;this.buffer(),this.data.flowCodeInside=!0}function b(){let re=this.resume(),ne=this.stack[this.stack.length-1];B(ne,"expected node on stack"),B(ne.type==="code","expected code on stack"),ne.value=re.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function v(){let re=this.resume(),ne=this.stack[this.stack.length-1];B(ne,"expected node on stack"),B(ne.type==="code","expected code on stack"),ne.value=re.replace(/(\r?\n|\r)$/g,"")}function A(re){let ne=this.resume(),h=this.stack[this.stack.length-1];B(h,"expected node on stack"),B(h.type==="definition","expected definition on stack"),h.label=ne,h.identifier=Ni(this.sliceSerialize(re)).toLowerCase()}function T(){let re=this.resume(),ne=this.stack[this.stack.length-1];B(ne,"expected node on stack"),B(ne.type==="definition","expected definition on stack"),ne.title=re}function z(){let re=this.resume(),ne=this.stack[this.stack.length-1];B(ne,"expected node on stack"),B(ne.type==="definition","expected definition on stack"),ne.url=re}function j(re){let ne=this.stack[this.stack.length-1];if(B(ne,"expected node on stack"),B(ne.type==="heading","expected heading on stack"),!ne.depth){let h=this.sliceSerialize(re).length;B(h===1||h===2||h===3||h===4||h===5||h===6,"expected `depth` between `1` and `6`"),ne.depth=h}}function E(){this.data.setextHeadingSlurpLineEnding=!0}function Z(re){let ne=this.stack[this.stack.length-1];B(ne,"expected node on stack"),B(ne.type==="heading","expected heading on stack"),ne.depth=this.sliceSerialize(re).codePointAt(0)===w.equalsTo?1:2}function D(){this.data.setextHeadingSlurpLineEnding=void 0}function H(re){let ne=this.stack[this.stack.length-1];B(ne,"expected node on stack"),B("children"in ne,"expected parent on stack");let h=ne.children,U=h[h.length-1];if(!U||U.type!=="text")U=Ru(),U.position={start:jo(re.start),end:void 0},h.push(U);this.stack.push(U)}function X(re){let ne=this.stack.pop();B(ne,"expected a `node` to be on the stack"),B("value"in ne,"expected a `literal` to be on the stack"),B(ne.position,"expected `node` to have an open position"),ne.value+=this.sliceSerialize(re),ne.position.end=jo(re.end)}function M(re){let ne=this.stack[this.stack.length-1];if(B(ne,"expected `node`"),this.data.atHardBreak){B("children"in ne,"expected `parent`");let h=ne.children[ne.children.length-1];B(h.position,"expected tail to have a starting position"),h.position.end=jo(re.end),this.data.atHardBreak=void 0;return}if(!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(ne.type))H.call(this,re),X.call(this,re)}function P(){this.data.atHardBreak=!0}function N(){let re=this.resume(),ne=this.stack[this.stack.length-1];B(ne,"expected node on stack"),B(ne.type==="html","expected html on stack"),ne.value=re}function I(){let re=this.resume(),ne=this.stack[this.stack.length-1];B(ne,"expected node on stack"),B(ne.type==="html","expected html on stack"),ne.value=re}function R(){let re=this.resume(),ne=this.stack[this.stack.length-1];B(ne,"expected node on stack"),B(ne.type==="inlineCode","expected inline code on stack"),ne.value=re}function O(){let re=this.stack[this.stack.length-1];if(B(re,"expected node on stack"),B(re.type==="link","expected link on stack"),this.data.inReference){let ne=this.data.referenceType||"shortcut";re.type+="Reference",re.referenceType=ne,delete re.url,delete re.title}else delete re.identifier,delete re.label;this.data.referenceType=void 0}function F(){let re=this.stack[this.stack.length-1];if(B(re,"expected node on stack"),B(re.type==="image","expected image on stack"),this.data.inReference){let ne=this.data.referenceType||"shortcut";re.type+="Reference",re.referenceType=ne,delete re.url,delete re.title}else delete re.identifier,delete re.label;this.data.referenceType=void 0}function L(re){let ne=this.sliceSerialize(re),h=this.stack[this.stack.length-2];B(h,"expected ancestor on stack"),B(h.type==="image"||h.type==="link","expected image or link on stack"),h.label=$g(ne),h.identifier=Ni(ne).toLowerCase()}function V(){let re=this.stack[this.stack.length-1];B(re,"expected node on stack"),B(re.type==="fragment","expected fragment on stack");let ne=this.resume(),h=this.stack[this.stack.length-1];if(B(h,"expected node on stack"),B(h.type==="image"||h.type==="link","expected image or link on stack"),this.data.inReference=!0,h.type==="link"){let U=re.children;h.children=U}else h.alt=ne}function _(){let re=this.resume(),ne=this.stack[this.stack.length-1];B(ne,"expected node on stack"),B(ne.type==="image"||ne.type==="link","expected image or link on stack"),ne.url=re}function te(){let re=this.resume(),ne=this.stack[this.stack.length-1];B(ne,"expected node on stack"),B(ne.type==="image"||ne.type==="link","expected image or link on stack"),ne.title=re}function ue(){this.data.inReference=void 0}function C(){this.data.referenceType="collapsed"}function Se(re){let ne=this.resume(),h=this.stack[this.stack.length-1];B(h,"expected node on stack"),B(h.type==="image"||h.type==="link","expected image reference or link reference on stack"),h.label=ne,h.identifier=Ni(this.sliceSerialize(re)).toLowerCase(),this.data.referenceType="full"}function Ee(re){B(re.type==="characterReferenceMarkerNumeric"||re.type==="characterReferenceMarkerHexadecimal"),this.data.characterReferenceType=re.type}function $e(re){let ne=this.sliceSerialize(re),h=this.data.characterReferenceType,U;if(h)U=pg(ne,h===S.characterReferenceMarkerNumeric?be.numericBaseDecimal:be.numericBaseHexadecimal),this.data.characterReferenceType=void 0;else{let ie=Wc(ne);B(ie!==!1,"expected reference to decode"),U=ie}let G=this.stack[this.stack.length-1];B(G,"expected `node`"),B("value"in G,"expected `node.value`"),G.value+=U}function Ce(re){let ne=this.stack.pop();B(ne,"expected `node`"),B(ne.position,"expected `node.position`"),ne.position.end=jo(re.end)}function _e(re){X.call(this,re);let ne=this.stack[this.stack.length-1];B(ne,"expected node on stack"),B(ne.type==="link","expected link on stack"),ne.url=this.sliceSerialize(re)}function ze(re){X.call(this,re);let ne=this.stack[this.stack.length-1];B(ne,"expected node on stack"),B(ne.type==="link","expected link on stack"),ne.url="mailto:"+this.sliceSerialize(re)}function Ve(){return{type:"blockquote",children:[]}}function Xe(){return{type:"code",lang:null,meta:null,value:""}}function St(){return{type:"inlineCode",value:""}}function Lt(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function hr(){return{type:"emphasis",children:[]}}function Yr(){return{type:"heading",depth:0,children:[]}}function Xr(){return{type:"break"}}function hn(){return{type:"html",value:""}}function Ya(){return{type:"image",title:null,url:"",alt:null}}function Xa(){return{type:"link",title:null,url:"",children:[]}}function Os(re){return{type:"list",ordered:re.type==="listOrdered",start:null,spread:re._spread,children:[]}}function ec(re){return{type:"listItem",spread:re._spread,checked:null,children:[]}}function Ou(){return{type:"paragraph",children:[]}}function Pn(){return{type:"strong",children:[]}}function Ru(){return{type:"text",value:""}}function tc(){return{type:"thematicBreak"}}}function jo(e){return{line:e.line,column:e.column,offset:e.offset}}function Yj(e,t){let r=-1;while(++r<t.length){let i=t[r];if(Array.isArray(i))Yj(e,i);else Bse(e,i)}}function Bse(e,t){let r;for(r in t)if(Qj.call(t,r))switch(r){case"canContainEols":{let i=t[r];if(i)e[r].push(...i);break}case"transforms":{let i=t[r];if(i)e[r].push(...i);break}case"enter":case"exit":{let i=t[r];if(i)Object.assign(e[r],i);break}}}function Gj(e,t){if(e)throw Error("Cannot close `"+e.type+"` ("+Bo({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Bo({start:t.start,end:t.end})+") is open");else throw Error("Cannot close document, a token (`"+t.type+"`, "+Bo({start:t.start,end:t.end})+") is still open")}var Qj;var Xj=x(()=>{tt();dg();Jj();E1();tI();mg();Fe();fg();nI();Qj={}.hasOwnProperty});var eq=x(()=>{Xj()});function Og(e){let t=this;t.parser=r;function r(i){return iI(i,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}var tq=x(()=>{eq()});var rq=x(()=>{tq()});function iq(e,t){let r=t||{};function i(n,...o){let{invalid:s,handlers:a}=i;if(n&&nq.call(n,e)){let c=String(n[e]);s=nq.call(a,c)?a[c]:i.unknown}if(s)return s.call(this,n,...o)}return i.handlers=r.handlers||{},i.invalid=r.invalid,i.unknown=r.unknown,i}var nq;var oq=x(()=>{nq={}.hasOwnProperty});function oI(e,t){let r=-1,i;if(t.extensions)while(++r<t.extensions.length)oI(e,t.extensions[r]);for(i in t)if(jse.call(t,i))switch(i){case"extensions":break;case"unsafe":{sq(e[i],t[i]);break}case"join":{sq(e[i],t[i]);break}case"handlers":{qse(e[i],t[i]);break}default:e.options[i]=t[i]}return e}function sq(e,t){if(t)e.push(...t)}function qse(e,t){if(t)Object.assign(e,t)}var jse;var aq=x(()=>{jse={}.hasOwnProperty});function cq(e,t,r,i){let n=r.enter("blockquote"),o=r.createTracker(i);o.move("> "),o.shift(2);let s=r.indentLines(r.containerFlow(e,o.current()),Use);return n(),s}function Use(e,t,r){return">"+(r?"":" ")+e}function Rg(e,t){return lq(e,t.inConstruct,!0)&&!lq(e,t.notInConstruct,!1)}function lq(e,t,r){if(typeof t==="string")t=[t];if(!t||t.length===0)return r;let i=-1;while(++i<t.length)if(e.includes(t[i]))return!0;return!1}function sI(e,t,r,i){let n=-1;while(++n<r.unsafe.length)if(r.unsafe[n].character===`
278
278
  `&&Rg(r.stack,r.unsafe[n]))return/[ \t]/.test(i.before)?"":" ";return"\\\n"}var uq=()=>{};function dq(e,t){let r=String(e),i=r.indexOf(t),n=i,o=0,s=0;if(typeof t!=="string")throw TypeError("Expected substring");while(i!==-1){if(i===n){if(++o>s)s=o}else o=1;n=i+t.length,i=r.indexOf(t,n)}return s}function Md(e,t){return Boolean(t.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function fq(e){let t=e.options.fence||"`";if(t!=="`"&&t!=="~")throw Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function pq(e,t,r,i){let n=fq(r),o=e.value||"",s=n==="`"?"GraveAccent":"Tilde";if(Md(e,r)){let d=r.enter("codeIndented"),p=r.indentLines(o,Mse);return d(),p}let a=r.createTracker(i),c=n.repeat(Math.max(dq(o,n)+1,3)),l=r.enter("codeFenced"),u=a.move(c);if(e.lang){let d=r.enter(`codeFencedLang${s}`);u+=a.move(r.safe(e.lang,{before:u,after:" ",encode:["`"],...a.current()})),d()}if(e.lang&&e.meta){let d=r.enter(`codeFencedMeta${s}`);u+=a.move(" "),u+=a.move(r.safe(e.meta,{before:u,after:`
279
279
  `,encode:["`"],...a.current()})),d()}if(u+=a.move(`
280
280
  `),o)u+=a.move(o+`
@@ -303,24 +303,23 @@ return `+str.trim()+`;
303
303
  `}function uU(e,t){let r=[],i=0,n=0,o;while(o=oae.exec(e))s(e.slice(i,o.index)),r.push(o[0]),i=o.index+o[0].length,n++;return s(e.slice(i)),r.join("");function s(a){r.push(t(a,n,!a))}}var oae;var dU=x(()=>{oae=/\r?\n|\r/g});function pU(e,t,r){let i=(r.before||"")+(t||"")+(r.after||""),n=[],o=[],s={},a=-1;while(++a<e.unsafe.length){let u=e.unsafe[a];if(!Rg(e.stack,u))continue;let d=e.compilePattern(u),p;while(p=d.exec(i)){let m="before"in u||Boolean(u.atBreak),y="after"in u,g=p.index+(m?p[1].length:0);if(n.includes(g)){if(s[g].before&&!m)s[g].before=!1;if(s[g].after&&!y)s[g].after=!1}else n.push(g),s[g]={before:m,after:y}}}n.sort(sae);let c=r.before?r.before.length:0,l=i.length-(r.after?r.after.length:0);a=-1;while(++a<n.length){let u=n[a];if(u<c||u>=l)continue;if(u+1<l&&n[a+1]===u+1&&s[u].after&&!s[u+1].before&&!s[u+1].after||n[a-1]===u-1&&s[u].before&&!s[u-1].before&&!s[u-1].after)continue;if(c!==u)o.push(fU(i.slice(c,u),"\\"));if(c=u,/[!-/:-@[-`{-~]/.test(i.charAt(u))&&(!r.encode||!r.encode.includes(i.charAt(u))))o.push("\\");else o.push(an(i.charCodeAt(u))),c++}return o.push(fU(i.slice(c,l),r.after)),o.join("")}function sae(e,t){return e-t}function fU(e,t){let r=/\\(?=[!-/:-@[-`{-~])/g,i=[],n=[],o=e+t,s=-1,a=0,c;while(c=r.exec(o))i.push(c.index);while(++s<i.length){if(a!==i[s])n.push(e.slice(a,i[s]));n.push("\\"),a=i[s]}return n.push(e.slice(a)),n.join("")}var mU=()=>{};function hU(e){let t=e||{},r=t.now||{},i=t.lineShift||0,n=r.line||1,o=r.column||1;return{move:c,current:s,shift:a};function s(){return{now:{line:n,column:o},lineShift:i}}function a(l){i+=l}function c(l){let u=l||"",d=u.split(/\r?\n|\r/g),p=d[d.length-1];return n+=d.length-1,o=d.length===1?o+p.length:1+p.length+i,u}}function _I(e,t){let r=t||{},i={associationId:iU,containerPhrasing:uae,containerFlow:dae,createTracker:hU,compilePattern:sU,enter:o,handlers:{...Yq},handle:void 0,indentLines:uU,indexStack:[],join:[...eU],options:{},safe:fae,stack:[],unsafe:[...rU]};if(oI(i,r),i.options.tightDefinitions)i.join.push(lae);i.handle=iq("type",{invalid:aae,unknown:cae,handlers:i.handlers});let n=i.handle(e,void 0,i,{before:`
304
304
  `,after:`
305
305
  `,now:{line:1,column:1},lineShift:0});if(n&&n.charCodeAt(n.length-1)!==10&&n.charCodeAt(n.length-1)!==13)n+=`
306
- `;return n;function o(s){return i.stack.push(s),a;function a(){i.stack.pop()}}}function aae(e){throw Error("Cannot handle value `"+e+"`, expected node")}function cae(e){throw Error("Cannot handle unknown node `"+e.type+"`")}function lae(e,t){if(e.type==="definition"&&e.type===t.type)return 0}function uae(e,t){return aU(e,this,t)}function dae(e,t){return lU(e,this,t)}function fae(e,t){return pU(this,e,t)}var gU=x(()=>{oq();aq();Xq();tU();nU();oU();cU();dU();mU()});var yU=x(()=>{gU()});function Bg(e){let t=this;t.compiler=r;function r(i){return _I(i,{...t.data("settings"),...e,extensions:t.data("toMarkdownExtensions")||[]})}}var bU=x(()=>{yU()});var xU=x(()=>{bU()});function kI(e){if(e)throw e}var TU=ee(function(Vje,AU){var jg=Object.prototype.hasOwnProperty,IU=Object.prototype.toString,SU=Object.defineProperty,wU=Object.getOwnPropertyDescriptor,vU=function(t){if(typeof Array.isArray==="function")return Array.isArray(t);return IU.call(t)==="[object Array]"},_U=function(t){if(!t||IU.call(t)!=="[object Object]")return!1;var r=jg.call(t,"constructor"),i=t.constructor&&t.constructor.prototype&&jg.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!r&&!i)return!1;var n;for(n in t);return typeof n>"u"||jg.call(t,n)},kU=function(t,r){if(SU&&r.name==="__proto__")SU(t,r.name,{enumerable:!0,configurable:!0,value:r.newValue,writable:!0});else t[r.name]=r.newValue},EU=function(t,r){if(r==="__proto__"){if(!jg.call(t,r))return;else if(wU)return wU(t,r).value}return t[r]};AU.exports=function e(){var t,r,i,n,o,s,a=arguments[0],c=1,l=arguments.length,u=!1;if(typeof a==="boolean")u=a,a=arguments[1]||{},c=2;if(a==null||typeof a!=="object"&&typeof a!=="function")a={};for(;c<l;++c)if(t=arguments[c],t!=null){for(r in t)if(i=EU(a,r),n=EU(t,r),a!==n){if(u&&n&&(_U(n)||(o=vU(n)))){if(o)o=!1,s=i&&vU(i)?i:[];else s=i&&_U(i)?i:{};kU(a,{name:r,newValue:e(u,s,n)})}else if(typeof n<"u")kU(a,{name:r,newValue:n})}}return a}});function Fd(e){if(typeof e!=="object"||e===null)return!1;let t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function EI(){let e=[],t={run:r,use:i};return t;function r(...n){let o=-1,s=n.pop();if(typeof s!=="function")throw TypeError("Expected function as last argument, not "+s);a(null,...n);function a(c,...l){let u=e[++o],d=-1;if(c){s(c);return}while(++d<n.length)if(l[d]===null||l[d]===void 0)l[d]=n[d];if(n=l,u)CU(u,a)(...l);else s(null,...l)}}function i(n){if(typeof n!=="function")throw TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}}function CU(e,t){let r;return i;function i(...s){let a=e.length>s.length,c;if(a)s.push(n);try{c=e.apply(this,s)}catch(l){let u=l;if(a&&r)throw u;return n(u)}if(!a)if(c&&c.then&&typeof c.then==="function")c.then(o,n);else if(c instanceof Error)n(c);else o(c)}function n(s,...a){if(!r)r=!0,t(s,...a)}function o(s){n(null,s)}}var $U=()=>{};var ir;var OU=x(()=>{nI();ir=class ir extends Error{constructor(e,t,r){super();if(typeof t==="string")r=t,t=void 0;let i="",n={},o=!1;if(t)if("line"in t&&"column"in t)n={place:t};else if("start"in t&&"end"in t)n={place:t};else if("type"in t)n={ancestors:[t],place:t.position};else n={...t};if(typeof e==="string")i=e;else if(!n.cause&&e)o=!0,i=e.message,n.cause=e;if(!n.ruleId&&!n.source&&typeof r==="string"){let a=r.indexOf(":");if(a===-1)n.ruleId=r;else n.source=r.slice(0,a),n.ruleId=r.slice(a+1)}if(!n.place&&n.ancestors&&n.ancestors){let a=n.ancestors[n.ancestors.length-1];if(a)n.place=a.position}let s=n.place&&"start"in n.place?n.place.start:n.place;this.ancestors=n.ancestors||void 0,this.cause=n.cause||void 0,this.column=s?s.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=s?s.line:void 0,this.name=Bo(n.place)||"1:1",this.place=n.place||void 0,this.reason=this.message,this.ruleId=n.ruleId||void 0,this.source=n.source||void 0,this.stack=o&&n.cause&&typeof n.cause.stack==="string"?n.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};ir.prototype.file="";ir.prototype.name="";ir.prototype.reason="";ir.prototype.message="";ir.prototype.stack="";ir.prototype.column=void 0;ir.prototype.line=void 0;ir.prototype.ancestors=void 0;ir.prototype.cause=void 0;ir.prototype.fatal=void 0;ir.prototype.place=void 0;ir.prototype.ruleId=void 0;ir.prototype.source=void 0});var RU=x(()=>{OU()});import{default as Bn}from"path";var PU=()=>{};import{default as zU}from"process";var NU=()=>{};function qg(e){return Boolean(e!==null&&typeof e==="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}import{fileURLToPath as DU}from"url";var LU=()=>{};class Ug{constructor(e){let t;if(!e)t={};else if(qg(e))t={path:e};else if(typeof e==="string"||pae(e))t={value:e};else t=e;this.cwd="cwd"in t?"":zU.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;while(++r<II.length){let n=II[r];if(n in t&&t[n]!==void 0&&t[n]!==null)this[n]=n==="history"?[...t[n]]:t[n]}let i;for(i in t)if(!II.includes(i))this[i]=t[i]}get basename(){return typeof this.path==="string"?Bn.basename(this.path):void 0}set basename(e){TI(e,"basename"),AI(e,"basename"),this.path=Bn.join(this.dirname||"",e)}get dirname(){return typeof this.path==="string"?Bn.dirname(this.path):void 0}set dirname(e){BU(this.basename,"dirname"),this.path=Bn.join(e||"",this.basename)}get extname(){return typeof this.path==="string"?Bn.extname(this.path):void 0}set extname(e){if(AI(e,"extname"),BU(this.dirname,"extname"),e){if(e.codePointAt(0)!==46)throw Error("`extname` must start with `.`");if(e.includes(".",1))throw Error("`extname` cannot contain multiple dots")}this.path=Bn.join(this.dirname,this.stem+(e||""))}get path(){return this.history[this.history.length-1]}set path(e){if(qg(e))e=DU(e);if(TI(e,"path"),this.path!==e)this.history.push(e)}get stem(){return typeof this.path==="string"?Bn.basename(this.path,this.extname):void 0}set stem(e){TI(e,"stem"),AI(e,"stem"),this.path=Bn.join(this.dirname||"",e+(this.extname||""))}fail(e,t,r){let i=this.message(e,t,r);throw i.fatal=!0,i}info(e,t,r){let i=this.message(e,t,r);return i.fatal=void 0,i}message(e,t,r){let i=new ir(e,t,r);if(this.path)i.name=this.path+":"+i.name,i.file=this.path;return i.fatal=!1,this.messages.push(i),i}toString(e){if(this.value===void 0)return"";if(typeof this.value==="string")return this.value;return new TextDecoder(e||void 0).decode(this.value)}}function AI(e,t){if(e&&e.includes(Bn.sep))throw Error("`"+t+"` cannot be a path: did not expect `"+Bn.sep+"`")}function TI(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function BU(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}function pae(e){return Boolean(e&&typeof e==="object"&&"byteLength"in e&&"byteOffset"in e)}var II;var jU=x(()=>{RU();PU();NU();LU();II=["history","path","basename","stem","extname","dirname"]});var qU=x(()=>{jU()});var UU=function(e){let i=this.constructor.prototype,n=i[e],o=function(){return n.apply(o,arguments)};return Object.setPrototypeOf(o,i),o};function CI(e,t){if(typeof t!=="function")throw TypeError("Cannot `"+e+"` without `parser`")}function $I(e,t){if(typeof t!=="function")throw TypeError("Cannot `"+e+"` without `compiler`")}function OI(e,t){if(t)throw Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function MU(e){if(!Fd(e)||typeof e.type!=="string")throw TypeError("Expected node, got `"+e+"`")}function FU(e,t,r){if(!r)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function Mg(e){return hae(e)?e:new Ug(e)}function hae(e){return Boolean(e&&typeof e==="object"&&"message"in e&&"messages"in e)}function gae(e){return typeof e==="string"||yae(e)}function yae(e){return Boolean(e&&typeof e==="object"&&"byteLength"in e&&"byteOffset"in e)}var Fg,mae,RI,PI;var ZU=x(()=>{tt();$U();qU();Fg=rc(TU(),1),mae={}.hasOwnProperty;RI=class RI extends UU{constructor(){super("copy");this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=EI()}copy(){let e=new RI,t=-1;while(++t<this.attachers.length){let r=this.attachers[t];e.use(...r)}return e.data(Fg.default(!0,{},this.namespace)),e}data(e,t){if(typeof e==="string"){if(arguments.length===2)return OI("data",this.frozen),this.namespace[e]=t,this;return mae.call(this.namespace,e)&&this.namespace[e]||void 0}if(e)return OI("data",this.frozen),this.namespace=e,this;return this.namespace}freeze(){if(this.frozen)return this;let e=this;while(++this.freezeIndex<this.attachers.length){let[t,...r]=this.attachers[this.freezeIndex];if(r[0]===!1)continue;if(r[0]===!0)r[0]=void 0;let i=t.call(e,...r);if(typeof i==="function")this.transformers.use(i)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(e){this.freeze();let t=Mg(e),r=this.parser||this.Parser;return CI("parse",r),r(String(t),t)}process(e,t){let r=this;return this.freeze(),CI("process",this.parser||this.Parser),$I("process",this.compiler||this.Compiler),t?i(void 0,t):new Promise(i);function i(n,o){let s=Mg(e),a=r.parse(s);r.run(a,s,function(l,u,d){if(l||!u||!d)return c(l);let p=u,m=r.stringify(p,d);if(gae(m))d.value=m;else d.result=m;c(l,d)});function c(l,u){if(l||!u)o(l);else if(n)n(u);else B(t,"`done` is defined if `resolve` is not"),t(void 0,u)}}}processSync(e){let t=!1,r;return this.freeze(),CI("processSync",this.parser||this.Parser),$I("processSync",this.compiler||this.Compiler),this.process(e,i),FU("processSync","process",t),B(r,"we either bailed on an error or have a tree"),r;function i(n,o){t=!0,kI(n),r=o}}run(e,t,r){MU(e),this.freeze();let i=this.transformers;if(!r&&typeof t==="function")r=t,t=void 0;return r?n(void 0,r):new Promise(n);function n(o,s){B(typeof t!=="function","`file` can\u2019t be a `done` anymore, we checked");let a=Mg(t);i.run(e,a,c);function c(l,u,d){let p=u||e;if(l)s(l);else if(o)o(p);else B(r,"`done` is defined if `resolve` is not"),r(void 0,p,d)}}}runSync(e,t){let r=!1,i;return this.run(e,t,n),FU("runSync","run",r),B(i,"we either bailed on an error or have a tree"),i;function n(o,s){kI(o),i=s,r=!0}}stringify(e,t){this.freeze();let r=Mg(t),i=this.compiler||this.Compiler;return $I("stringify",i),MU(e),i(e,r)}use(e,...t){let r=this.attachers,i=this.namespace;if(OI("use",this.frozen),e===null||e===void 0);else if(typeof e==="function")a(e,t);else if(typeof e==="object")if(Array.isArray(e))s(e);else o(e);else throw TypeError("Expected usable value, not `"+e+"`");return this;function n(c){if(typeof c==="function")a(c,[]);else if(typeof c==="object")if(Array.isArray(c)){let[l,...u]=c;a(l,u)}else o(c);else throw TypeError("Expected usable value, not `"+c+"`")}function o(c){if(!("plugins"in c)&&!("settings"in c))throw Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");if(s(c.plugins),c.settings)i.settings=Fg.default(!0,i.settings,c.settings)}function s(c){let l=-1;if(c===null||c===void 0);else if(Array.isArray(c))while(++l<c.length){let u=c[l];n(u)}else throw TypeError("Expected a list of plugins, not `"+c+"`")}function a(c,l){let u=-1,d=-1;while(++u<r.length)if(r[u][0]===c){d=u;break}if(d===-1)r.push([c,...l]);else if(l.length>0){let[p,...m]=l,y=r[d][1];if(Fd(y)&&Fd(p))p=Fg.default(!0,y,p);r[d]=[c,p,...m]}}}};PI=new RI().freeze()});var HU=x(()=>{ZU()});var KU;var JU=x(()=>{rq();xU();HU();KU=PI().use(Og).use(Bg).freeze()});var z6e;var VU=x(()=>{Re();z6e=f.record(f.string(),f.unknown())});var L6e;var WU=x(()=>{Re();om();L6e=f.record(f.string(),f.unknown())});var GU=x(()=>{om()});var QU=x(()=>{Id();eD();wj();vj();VU();WU();GU();JE()});var Iae;var YU=x(()=>{Re();Iae=f.object({slug:f.string(),title:f.string(),type:f.string(),entityId:f.string(),contentHash:f.string()})});var NI=x(()=>{QU();YU()});var XU=x(()=>{NI();Re()});var e4=x(()=>{NI();Re()});var kqe;var t4=x(()=>{ag();JU();kqe=KU()});var Aae,Tae;var r4=x(()=>{t4();Re();KE();Aae=Jh.omit({url:!0,analyticsScript:!0}),Tae=Aae.extend({title:f.string().optional().describe("Optional site title override"),description:f.string().optional().describe("Optional site description override")})});function DI(e,t={}){let r=n4(e),i=n4(t.sharedDomain??"rizom.ai").replace(/^\./,""),n=`.${i}`;if(r.endsWith(n)){let o=r.slice(0,-n.length);if(o.length>0&&!o.includes("."))return`${o}-preview.${i}`}return`preview.${r}`}function n4(e){return e.trim().replace(/^https?:\/\//i,"").replace(/\/$/,"").toLowerCase()}var i4=()=>{};var o4=x(()=>{i4()});function s4(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var Cae,$ae;var a4=x(()=>{Re();FE();Cae=f.string(),$ae=f.custom((e)=>{if(!s4(e))return!1;let{plugin:t,...r}=e;if(t!==void 0&&typeof t!=="function")return!1;return VN.safeParse(r).success})});var c4=x(()=>{ZE();KE();XU();e4();r4();o4();a4()});function LI(e,t={}){return DI(e,t)}var BI=x(()=>{c4()});function jI(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 l4(e,t){let{org:r,name:i}=jI(e,t);return`${r}/${i}`}function m4(e){return Zae.safeParse(e).success}function qI(e,t,r={}){let i={...e};for(let n of Object.keys(t)){let o=t[n];if(o===null&&r.nulls!=="preserve")delete i[n];else if(m4(i[n])&&m4(o))i[n]=qI(i[n],o,r);else i[n]=o}return i}var Zae;var h4=x(()=>{Re();Zae=f.record(f.string(),f.unknown())});function Zg(e){return async(t)=>({brainYaml:Hae(t,e),envFile:Wae(t,e),contentRepoFiles:Jae(t)})}function Hae(e,t){let r={...e.setup?.delivery==="email"?{"auth-service":{setupEmail:Kae(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:g4(e,t),authToken:"${GIT_SYNC_TOKEN}"}},...e.atproto?{atproto:{...e.atproto,appPassword:"${ATPROTO_APP_PASSWORD}"}}:{}};return ic({brain:"brain",bundleContract:e.bundleContract,kind:e.profileKind??"professional",domain:e.domain,bundles:e.bundles,...e.embeddingEnabled!==void 0?{embedding:{enabled:e.embeddingEnabled}}:{},...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}:{}}}:{},anchors:e.discordEnabled&&e.discordAnchorUserId?[`discord:${e.discordAnchorUserId}`]:[],plugins:qI(r,e.plugins??{},{nulls:"preserve"})})}function g4(e,t){return l4(e.contentRepo,t)}function Kae(e){return{to:e,subject:"Welcome to Rover \u2014 set up your passkey",body:["Hi,","","Your Rover is ready.","","Rover is your own AI \u2014 a private assistant deployed just for you, that holds your notes, links, and ideas, and gets more useful the more you put into it.","","Set up your passkey:","{{setupUrl}}","","This link is single-use. Do not forward it.","It expires at {{expiresAt}}.","","After setup, open your chat and say hello:","{{origin}}/chat","","Sign in with the passkey you just registered. The chat in your browser is where you and Rover will spend most of your time.","","The onboarding guide shows the way of working \u2014 capture, ask back, shape:","https://github.com/rizom-ai/brains/blob/main/packages/brains-ops/templates/rover-pilot/docs/user-onboarding.md","","If this link is expired, does not work, or you did not expect this email, reply to your Rover operator and we will help.",""].join(`
307
- `)}}function Jae(e){return[{path:"anchor-profile/anchor-profile.md",content:Vae(e)}]}function Vae(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`---
306
+ `;return n;function o(s){return i.stack.push(s),a;function a(){i.stack.pop()}}}function aae(e){throw Error("Cannot handle value `"+e+"`, expected node")}function cae(e){throw Error("Cannot handle unknown node `"+e.type+"`")}function lae(e,t){if(e.type==="definition"&&e.type===t.type)return 0}function uae(e,t){return aU(e,this,t)}function dae(e,t){return lU(e,this,t)}function fae(e,t){return pU(this,e,t)}var gU=x(()=>{oq();aq();Xq();tU();nU();oU();cU();dU();mU()});var yU=x(()=>{gU()});function Bg(e){let t=this;t.compiler=r;function r(i){return _I(i,{...t.data("settings"),...e,extensions:t.data("toMarkdownExtensions")||[]})}}var bU=x(()=>{yU()});var xU=x(()=>{bU()});function kI(e){if(e)throw e}var TU=ee(function(J6e,AU){var jg=Object.prototype.hasOwnProperty,IU=Object.prototype.toString,SU=Object.defineProperty,wU=Object.getOwnPropertyDescriptor,vU=function(t){if(typeof Array.isArray==="function")return Array.isArray(t);return IU.call(t)==="[object Array]"},_U=function(t){if(!t||IU.call(t)!=="[object Object]")return!1;var r=jg.call(t,"constructor"),i=t.constructor&&t.constructor.prototype&&jg.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!r&&!i)return!1;var n;for(n in t);return typeof n>"u"||jg.call(t,n)},kU=function(t,r){if(SU&&r.name==="__proto__")SU(t,r.name,{enumerable:!0,configurable:!0,value:r.newValue,writable:!0});else t[r.name]=r.newValue},EU=function(t,r){if(r==="__proto__"){if(!jg.call(t,r))return;else if(wU)return wU(t,r).value}return t[r]};AU.exports=function e(){var t,r,i,n,o,s,a=arguments[0],c=1,l=arguments.length,u=!1;if(typeof a==="boolean")u=a,a=arguments[1]||{},c=2;if(a==null||typeof a!=="object"&&typeof a!=="function")a={};for(;c<l;++c)if(t=arguments[c],t!=null){for(r in t)if(i=EU(a,r),n=EU(t,r),a!==n){if(u&&n&&(_U(n)||(o=vU(n)))){if(o)o=!1,s=i&&vU(i)?i:[];else s=i&&_U(i)?i:{};kU(a,{name:r,newValue:e(u,s,n)})}else if(typeof n<"u")kU(a,{name:r,newValue:n})}}return a}});function Fd(e){if(typeof e!=="object"||e===null)return!1;let t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function EI(){let e=[],t={run:r,use:i};return t;function r(...n){let o=-1,s=n.pop();if(typeof s!=="function")throw TypeError("Expected function as last argument, not "+s);a(null,...n);function a(c,...l){let u=e[++o],d=-1;if(c){s(c);return}while(++d<n.length)if(l[d]===null||l[d]===void 0)l[d]=n[d];if(n=l,u)CU(u,a)(...l);else s(null,...l)}}function i(n){if(typeof n!=="function")throw TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}}function CU(e,t){let r;return i;function i(...s){let a=e.length>s.length,c;if(a)s.push(n);try{c=e.apply(this,s)}catch(l){let u=l;if(a&&r)throw u;return n(u)}if(!a)if(c&&c.then&&typeof c.then==="function")c.then(o,n);else if(c instanceof Error)n(c);else o(c)}function n(s,...a){if(!r)r=!0,t(s,...a)}function o(s){n(null,s)}}var $U=()=>{};var ir;var OU=x(()=>{nI();ir=class ir extends Error{constructor(e,t,r){super();if(typeof t==="string")r=t,t=void 0;let i="",n={},o=!1;if(t)if("line"in t&&"column"in t)n={place:t};else if("start"in t&&"end"in t)n={place:t};else if("type"in t)n={ancestors:[t],place:t.position};else n={...t};if(typeof e==="string")i=e;else if(!n.cause&&e)o=!0,i=e.message,n.cause=e;if(!n.ruleId&&!n.source&&typeof r==="string"){let a=r.indexOf(":");if(a===-1)n.ruleId=r;else n.source=r.slice(0,a),n.ruleId=r.slice(a+1)}if(!n.place&&n.ancestors&&n.ancestors){let a=n.ancestors[n.ancestors.length-1];if(a)n.place=a.position}let s=n.place&&"start"in n.place?n.place.start:n.place;this.ancestors=n.ancestors||void 0,this.cause=n.cause||void 0,this.column=s?s.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=s?s.line:void 0,this.name=Bo(n.place)||"1:1",this.place=n.place||void 0,this.reason=this.message,this.ruleId=n.ruleId||void 0,this.source=n.source||void 0,this.stack=o&&n.cause&&typeof n.cause.stack==="string"?n.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};ir.prototype.file="";ir.prototype.name="";ir.prototype.reason="";ir.prototype.message="";ir.prototype.stack="";ir.prototype.column=void 0;ir.prototype.line=void 0;ir.prototype.ancestors=void 0;ir.prototype.cause=void 0;ir.prototype.fatal=void 0;ir.prototype.place=void 0;ir.prototype.ruleId=void 0;ir.prototype.source=void 0});var RU=x(()=>{OU()});import{default as Bn}from"path";var PU=()=>{};import{default as zU}from"process";var NU=()=>{};function qg(e){return Boolean(e!==null&&typeof e==="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}import{fileURLToPath as DU}from"url";var LU=()=>{};class Ug{constructor(e){let t;if(!e)t={};else if(qg(e))t={path:e};else if(typeof e==="string"||pae(e))t={value:e};else t=e;this.cwd="cwd"in t?"":zU.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;while(++r<II.length){let n=II[r];if(n in t&&t[n]!==void 0&&t[n]!==null)this[n]=n==="history"?[...t[n]]:t[n]}let i;for(i in t)if(!II.includes(i))this[i]=t[i]}get basename(){return typeof this.path==="string"?Bn.basename(this.path):void 0}set basename(e){TI(e,"basename"),AI(e,"basename"),this.path=Bn.join(this.dirname||"",e)}get dirname(){return typeof this.path==="string"?Bn.dirname(this.path):void 0}set dirname(e){BU(this.basename,"dirname"),this.path=Bn.join(e||"",this.basename)}get extname(){return typeof this.path==="string"?Bn.extname(this.path):void 0}set extname(e){if(AI(e,"extname"),BU(this.dirname,"extname"),e){if(e.codePointAt(0)!==46)throw Error("`extname` must start with `.`");if(e.includes(".",1))throw Error("`extname` cannot contain multiple dots")}this.path=Bn.join(this.dirname,this.stem+(e||""))}get path(){return this.history[this.history.length-1]}set path(e){if(qg(e))e=DU(e);if(TI(e,"path"),this.path!==e)this.history.push(e)}get stem(){return typeof this.path==="string"?Bn.basename(this.path,this.extname):void 0}set stem(e){TI(e,"stem"),AI(e,"stem"),this.path=Bn.join(this.dirname||"",e+(this.extname||""))}fail(e,t,r){let i=this.message(e,t,r);throw i.fatal=!0,i}info(e,t,r){let i=this.message(e,t,r);return i.fatal=void 0,i}message(e,t,r){let i=new ir(e,t,r);if(this.path)i.name=this.path+":"+i.name,i.file=this.path;return i.fatal=!1,this.messages.push(i),i}toString(e){if(this.value===void 0)return"";if(typeof this.value==="string")return this.value;return new TextDecoder(e||void 0).decode(this.value)}}function AI(e,t){if(e&&e.includes(Bn.sep))throw Error("`"+t+"` cannot be a path: did not expect `"+Bn.sep+"`")}function TI(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function BU(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}function pae(e){return Boolean(e&&typeof e==="object"&&"byteLength"in e&&"byteOffset"in e)}var II;var jU=x(()=>{RU();PU();NU();LU();II=["history","path","basename","stem","extname","dirname"]});var qU=x(()=>{jU()});var UU=function(e){let i=this.constructor.prototype,n=i[e],o=function(){return n.apply(o,arguments)};return Object.setPrototypeOf(o,i),o};function CI(e,t){if(typeof t!=="function")throw TypeError("Cannot `"+e+"` without `parser`")}function $I(e,t){if(typeof t!=="function")throw TypeError("Cannot `"+e+"` without `compiler`")}function OI(e,t){if(t)throw Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function MU(e){if(!Fd(e)||typeof e.type!=="string")throw TypeError("Expected node, got `"+e+"`")}function FU(e,t,r){if(!r)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function Mg(e){return hae(e)?e:new Ug(e)}function hae(e){return Boolean(e&&typeof e==="object"&&"message"in e&&"messages"in e)}function gae(e){return typeof e==="string"||yae(e)}function yae(e){return Boolean(e&&typeof e==="object"&&"byteLength"in e&&"byteOffset"in e)}var Fg,mae,RI,PI;var ZU=x(()=>{tt();$U();qU();Fg=rc(TU(),1),mae={}.hasOwnProperty;RI=class RI extends UU{constructor(){super("copy");this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=EI()}copy(){let e=new RI,t=-1;while(++t<this.attachers.length){let r=this.attachers[t];e.use(...r)}return e.data(Fg.default(!0,{},this.namespace)),e}data(e,t){if(typeof e==="string"){if(arguments.length===2)return OI("data",this.frozen),this.namespace[e]=t,this;return mae.call(this.namespace,e)&&this.namespace[e]||void 0}if(e)return OI("data",this.frozen),this.namespace=e,this;return this.namespace}freeze(){if(this.frozen)return this;let e=this;while(++this.freezeIndex<this.attachers.length){let[t,...r]=this.attachers[this.freezeIndex];if(r[0]===!1)continue;if(r[0]===!0)r[0]=void 0;let i=t.call(e,...r);if(typeof i==="function")this.transformers.use(i)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(e){this.freeze();let t=Mg(e),r=this.parser||this.Parser;return CI("parse",r),r(String(t),t)}process(e,t){let r=this;return this.freeze(),CI("process",this.parser||this.Parser),$I("process",this.compiler||this.Compiler),t?i(void 0,t):new Promise(i);function i(n,o){let s=Mg(e),a=r.parse(s);r.run(a,s,function(l,u,d){if(l||!u||!d)return c(l);let p=u,m=r.stringify(p,d);if(gae(m))d.value=m;else d.result=m;c(l,d)});function c(l,u){if(l||!u)o(l);else if(n)n(u);else B(t,"`done` is defined if `resolve` is not"),t(void 0,u)}}}processSync(e){let t=!1,r;return this.freeze(),CI("processSync",this.parser||this.Parser),$I("processSync",this.compiler||this.Compiler),this.process(e,i),FU("processSync","process",t),B(r,"we either bailed on an error or have a tree"),r;function i(n,o){t=!0,kI(n),r=o}}run(e,t,r){MU(e),this.freeze();let i=this.transformers;if(!r&&typeof t==="function")r=t,t=void 0;return r?n(void 0,r):new Promise(n);function n(o,s){B(typeof t!=="function","`file` can\u2019t be a `done` anymore, we checked");let a=Mg(t);i.run(e,a,c);function c(l,u,d){let p=u||e;if(l)s(l);else if(o)o(p);else B(r,"`done` is defined if `resolve` is not"),r(void 0,p,d)}}}runSync(e,t){let r=!1,i;return this.run(e,t,n),FU("runSync","run",r),B(i,"we either bailed on an error or have a tree"),i;function n(o,s){kI(o),i=s,r=!0}}stringify(e,t){this.freeze();let r=Mg(t),i=this.compiler||this.Compiler;return $I("stringify",i),MU(e),i(e,r)}use(e,...t){let r=this.attachers,i=this.namespace;if(OI("use",this.frozen),e===null||e===void 0);else if(typeof e==="function")a(e,t);else if(typeof e==="object")if(Array.isArray(e))s(e);else o(e);else throw TypeError("Expected usable value, not `"+e+"`");return this;function n(c){if(typeof c==="function")a(c,[]);else if(typeof c==="object")if(Array.isArray(c)){let[l,...u]=c;a(l,u)}else o(c);else throw TypeError("Expected usable value, not `"+c+"`")}function o(c){if(!("plugins"in c)&&!("settings"in c))throw Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");if(s(c.plugins),c.settings)i.settings=Fg.default(!0,i.settings,c.settings)}function s(c){let l=-1;if(c===null||c===void 0);else if(Array.isArray(c))while(++l<c.length){let u=c[l];n(u)}else throw TypeError("Expected a list of plugins, not `"+c+"`")}function a(c,l){let u=-1,d=-1;while(++u<r.length)if(r[u][0]===c){d=u;break}if(d===-1)r.push([c,...l]);else if(l.length>0){let[p,...m]=l,y=r[d][1];if(Fd(y)&&Fd(p))p=Fg.default(!0,y,p);r[d]=[c,p,...m]}}}};PI=new RI().freeze()});var HU=x(()=>{ZU()});var KU;var JU=x(()=>{rq();xU();HU();KU=PI().use(Og).use(Bg).freeze()});var Pje;var VU=x(()=>{Re();Pje=f.record(f.string(),f.unknown())});var Dje;var WU=x(()=>{Re();om();Dje=f.record(f.string(),f.unknown())});var GU=x(()=>{om()});var QU=x(()=>{Id();eD();w6();v6();VU();WU();GU();JE()});var Iae;var YU=x(()=>{Re();Iae=f.object({slug:f.string(),title:f.string(),type:f.string(),entityId:f.string(),contentHash:f.string()})});var NI=x(()=>{QU();YU()});var XU=x(()=>{NI();Re()});var e4=x(()=>{NI();Re()});var _qe;var t4=x(()=>{ag();JU();_qe=KU()});var Aae,Tae;var r4=x(()=>{t4();Re();KE();Aae=Jh.omit({url:!0,analyticsScript:!0}),Tae=Aae.extend({title:f.string().optional().describe("Optional site title override"),description:f.string().optional().describe("Optional site description override")})});function DI(e,t={}){let r=n4(e),i=n4(t.sharedDomain??"rizom.ai").replace(/^\./,""),n=`.${i}`;if(r.endsWith(n)){let o=r.slice(0,-n.length);if(o.length>0&&!o.includes("."))return`${o}-preview.${i}`}return`preview.${r}`}function n4(e){return e.trim().replace(/^https?:\/\//i,"").replace(/\/$/,"").toLowerCase()}var i4=()=>{};var o4=x(()=>{i4()});function s4(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var Cae,$ae;var a4=x(()=>{Re();FE();Cae=f.string(),$ae=f.custom((e)=>{if(!s4(e))return!1;let{plugin:t,...r}=e;if(t!==void 0&&typeof t!=="function")return!1;return VN.safeParse(r).success})});var c4=x(()=>{ZE();KE();XU();e4();r4();o4();a4()});function LI(e,t={}){return DI(e,t)}var BI=x(()=>{c4()});function jI(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 l4(e,t){let{org:r,name:i}=jI(e,t);return`${r}/${i}`}function m4(e){return Zae.safeParse(e).success}function qI(e,t,r={}){let i={...e};for(let n of Object.keys(t)){let o=t[n];if(o===null&&r.nulls!=="preserve")delete i[n];else if(m4(i[n])&&m4(o))i[n]=qI(i[n],o,r);else i[n]=o}return i}var Zae;var h4=x(()=>{Re();Zae=f.record(f.string(),f.unknown())});function Zg(e){return async(t)=>({brainYaml:Hae(t,e),envFile:Vae(t,e),contentRepoFiles:Kae(t)})}function Hae(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:g4(e,t),authToken:"${GIT_SYNC_TOKEN}"}},...e.atproto?{atproto:{...e.atproto,appPassword:"${ATPROTO_APP_PASSWORD}"}}:{}};return ic({brain:"brain",bundleContract:e.bundleContract,kind:e.profileKind??"professional",domain:e.domain,bundles:e.bundles,...e.embeddingEnabled!==void 0?{embedding:{enabled:e.embeddingEnabled}}:{},...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}:{}}}:{},anchors:e.discordEnabled&&e.discordAnchorUserId?[`discord:${e.discordAnchorUserId}`]:[],plugins:qI(r,e.plugins??{},{nulls:"preserve"})})}function g4(e,t){return l4(e.contentRepo,t)}function Kae(e){return[{path:"anchor-profile/anchor-profile.md",content:Jae(e)}]}function Jae(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`---
308
307
  ${ic(t).trimEnd()}
309
308
  ---
310
309
 
311
310
  ${r}
312
- `}function Wae(e,t){let r=Hh(e.siteOverride);return[`BRAIN_VERSION=${e.brainVersion}`,...r.length>0?[`IMAGE_TAG=${Ed(e.brainVersion,r)}`]:[],`CONTENT_REPO=${g4(e,t)}`,""].join(`
313
- `)}var UI=x(()=>{h4();UE();Ai()});var Ge=ee(function(xce){var HI=Symbol.for("yaml.alias"),k4=Symbol.for("yaml.document"),Kg=Symbol.for("yaml.map"),E4=Symbol.for("yaml.pair"),KI=Symbol.for("yaml.scalar"),Jg=Symbol.for("yaml.seq"),Di=Symbol.for("yaml.node.type"),fce=(e)=>!!e&&typeof e==="object"&&e[Di]===HI,pce=(e)=>!!e&&typeof e==="object"&&e[Di]===k4,mce=(e)=>!!e&&typeof e==="object"&&e[Di]===Kg,hce=(e)=>!!e&&typeof e==="object"&&e[Di]===E4,I4=(e)=>!!e&&typeof e==="object"&&e[Di]===KI,gce=(e)=>!!e&&typeof e==="object"&&e[Di]===Jg;function A4(e){if(e&&typeof e==="object")switch(e[Di]){case Kg:case Jg:return!0}return!1}function yce(e){if(e&&typeof e==="object")switch(e[Di]){case HI:case Kg:case KI:case Jg:return!0}return!1}var bce=(e)=>(I4(e)||A4(e))&&!!e.anchor;xce.ALIAS=HI;xce.DOC=k4;xce.MAP=Kg;xce.NODE_TYPE=Di;xce.PAIR=E4;xce.SCALAR=KI;xce.SEQ=Jg;xce.hasAnchor=bce;xce.isAlias=fce;xce.isCollection=A4;xce.isDocument=pce;xce.isMap=mce;xce.isNode=yce;xce.isPair=hce;xce.isScalar=I4;xce.isSeq=gce});var Zd=ee(function(Dce){var Zt=Ge(),Jr=Symbol("break visit"),T4=Symbol("skip children"),si=Symbol("remove node");function Vg(e,t){let r=C4(t);if(Zt.isDocument(e)){if(al(null,e.contents,r,Object.freeze([e]))===si)e.contents=null}else al(null,e,r,Object.freeze([]))}Vg.BREAK=Jr;Vg.SKIP=T4;Vg.REMOVE=si;function al(e,t,r,i){let n=$4(e,t,r,i);if(Zt.isNode(n)||Zt.isPair(n))return O4(e,i,n),al(e,n,r,i);if(typeof n!=="symbol"){if(Zt.isCollection(t)){i=Object.freeze(i.concat(t));for(let o=0;o<t.items.length;++o){let s=al(o,t.items[o],r,i);if(typeof s==="number")o=s-1;else if(s===Jr)return Jr;else if(s===si)t.items.splice(o,1),o-=1}}else if(Zt.isPair(t)){i=Object.freeze(i.concat(t));let o=al("key",t.key,r,i);if(o===Jr)return Jr;else if(o===si)t.key=null;let s=al("value",t.value,r,i);if(s===Jr)return Jr;else if(s===si)t.value=null}}return n}async function Wg(e,t){let r=C4(t);if(Zt.isDocument(e)){if(await cl(null,e.contents,r,Object.freeze([e]))===si)e.contents=null}else await cl(null,e,r,Object.freeze([]))}Wg.BREAK=Jr;Wg.SKIP=T4;Wg.REMOVE=si;async function cl(e,t,r,i){let n=await $4(e,t,r,i);if(Zt.isNode(n)||Zt.isPair(n))return O4(e,i,n),cl(e,n,r,i);if(typeof n!=="symbol"){if(Zt.isCollection(t)){i=Object.freeze(i.concat(t));for(let o=0;o<t.items.length;++o){let s=await cl(o,t.items[o],r,i);if(typeof s==="number")o=s-1;else if(s===Jr)return Jr;else if(s===si)t.items.splice(o,1),o-=1}}else if(Zt.isPair(t)){i=Object.freeze(i.concat(t));let o=await cl("key",t.key,r,i);if(o===Jr)return Jr;else if(o===si)t.key=null;let s=await cl("value",t.value,r,i);if(s===Jr)return Jr;else if(s===si)t.value=null}}return n}function C4(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 $4(e,t,r,i){if(typeof r==="function")return r(e,t,i);if(Zt.isMap(t))return r.Map?.(e,t,i);if(Zt.isSeq(t))return r.Seq?.(e,t,i);if(Zt.isPair(t))return r.Pair?.(e,t,i);if(Zt.isScalar(t))return r.Scalar?.(e,t,i);if(Zt.isAlias(t))return r.Alias?.(e,t,i);return}function O4(e,t,r){let i=t[t.length-1];if(Zt.isCollection(i))i.items[e]=r;else if(Zt.isPair(i))if(e==="key")i.key=r;else i.value=r;else if(Zt.isDocument(i))i.contents=r;else{let n=Zt.isAlias(i)?"alias":"scalar";throw Error(`Cannot replace node with ${n} parent`)}}Dce.visit=Vg;Dce.visitAsync=Wg});var JI=ee(function(Mce){var R4=Ge(),jce=Zd(),qce={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},Uce=(e)=>e.replace(/[!,[\]{}]/g,(t)=>qce[t]);class xn{constructor(e,t){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},xn.defaultYaml,e),this.tags=Object.assign({},xn.defaultTags,t)}clone(){let e=new xn(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){let e=new xn(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:xn.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},xn.defaultTags);break}return e}add(e,t){if(this.atNextDocument)this.yaml={explicit:xn.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},xn.defaultTags),this.atNextDocument=!1;let r=e.trim().split(/[ \t]+/),i=r.shift();switch(i){case"%TAG":{if(r.length!==2){if(t(0,"%TAG directive should contain exactly two parts"),r.length<2)return!1}let[n,o]=r;return this.tags[n]=o,!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 o=/^\d+\.\d+$/.test(n);return t(6,`Unsupported YAML version ${n}`,o),!1}}default:return t(0,`Unknown directive ${i}`,!0),!1}}tagName(e,t){if(e==="!")return"!";if(e[0]!=="!")return t(`Not a valid tag: ${e}`),null;if(e[1]==="<"){let o=e.slice(2,-1);if(o==="!"||o==="!!")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 o}let[,r,i]=e.match(/^(.*!)([^!]*)$/s);if(!i)t(`The ${e} tag has no suffix`);let n=this.tags[r];if(n)try{return n+decodeURIComponent(i)}catch(o){return t(String(o)),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+Uce(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),i;if(e&&r.length>0&&R4.isNode(e.contents)){let n={};jce.visit(e.contents,(o,s)=>{if(R4.isNode(s)&&s.tag)n[s.tag]=!0}),i=Object.keys(n)}else i=[];for(let[n,o]of r){if(n==="!!"&&o==="tag:yaml.org,2002:")continue;if(!e||i.some((s)=>s.startsWith(o)))t.push(`%TAG ${n} ${o}`)}return t.join(`
314
- `)}}xn.defaultYaml={explicit:!1,version:"1.2"};xn.defaultTags={"!!":"tag:yaml.org,2002:"};Mce.Directives=xn});var Gg=ee(function(Jce){var P4=Ge(),Zce=Zd();function Hce(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 z4(e){let t=new Set;return Zce.visit(e,{Value(r,i){if(i.anchor)t.add(i.anchor)}}),t}function N4(e,t){for(let r=1;;++r){let i=`${e}${r}`;if(!t.has(i))return i}}function Kce(e,t){let r=[],i=new Map,n=null;return{onAnchor:(o)=>{r.push(o),n??(n=z4(e));let s=N4(t,n);return n.add(s),s},setAnchors:()=>{for(let o of r){let s=i.get(o);if(typeof s==="object"&&s.anchor&&(P4.isScalar(s.node)||P4.isCollection(s.node)))s.node.anchor=s.anchor;else{let a=Error("Failed to resolve repeated object (this should not happen)");throw a.source=o,a}}},sourceObjects:i}}Jce.anchorIsValid=Hce;Jce.anchorNames=z4;Jce.createNodeAnchors=Kce;Jce.findNewAnchor=N4});var VI=ee(function(Yce){function Hd(e,t,r,i){if(i&&typeof i==="object")if(Array.isArray(i))for(let n=0,o=i.length;n<o;++n){let s=i[n],a=Hd(e,i,String(n),s);if(a===void 0)delete i[n];else if(a!==s)i[n]=a}else if(i instanceof Map)for(let n of Array.from(i.keys())){let o=i.get(n),s=Hd(e,i,n,o);if(s===void 0)i.delete(n);else if(s!==o)i.set(n,s)}else if(i instanceof Set)for(let n of Array.from(i)){let o=Hd(e,i,n,n);if(o===void 0)i.delete(n);else if(o!==n)i.delete(n),i.add(o)}else for(let[n,o]of Object.entries(i)){let s=Hd(e,i,n,o);if(s===void 0)delete i[n];else if(s!==o)i[n]=s}return e.call(t,r,i)}Yce.applyReviver=Hd});var qo=ee(function(tle){var ele=Ge();function D4(e,t,r){if(Array.isArray(e))return e.map((i,n)=>D4(i,String(n),r));if(e&&typeof e.toJSON==="function"){if(!r||!ele.hasAnchor(e))return e.toJSON(t,r);let i={aliasCount:0,count:1,res:void 0};r.anchors.set(e,i),r.onCreate=(o)=>{i.res=o,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}tle.toJS=D4});var Qg=ee(function(ole){var nle=VI(),L4=Ge(),ile=qo();class B4{constructor(e){Object.defineProperty(this,L4.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:i,reviver:n}={}){if(!L4.isDocument(e))throw TypeError("A document argument is required");let o={anchors:new Map,doc:e,keep:!0,mapAsMap:t===!0,mapKeyWarned:!1,maxAliasCount:typeof r==="number"?r:100},s=ile.toJS(this,"",o);if(typeof i==="function")for(let{count:a,res:c}of o.anchors.values())i(c,a);return typeof n==="function"?nle.applyReviver(n,{"":s},"",s):s}}ole.NodeBase=B4});var Kd=ee(function(dle){var ale=Gg(),cle=Zd(),ll=Ge(),lle=Qg(),ule=qo();class j4 extends lle.NodeBase{constructor(e){super(ll.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=[],cle.visit(e,{Node:(n,o)=>{if(ll.isAlias(o)||ll.hasAnchor(o))r.push(o)}}),t)t.aliasResolveCache=r;let i=void 0;for(let n of r){if(n===this)break;if(n.anchor===this.source)i=n}return i}toJSON(e,t){if(!t)return{source:this.source};let{anchors:r,doc:i,maxAliasCount:n}=t,o=this.resolve(i,t);if(!o){let a=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(a)}let s=r.get(o);if(!s)ule.toJS(o,null,t),s=r.get(o);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=Yg(i,o,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 i=`*${this.source}`;if(e){if(ale.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`${i} `}return i}}function Yg(e,t,r){if(ll.isAlias(t)){let i=t.resolve(e),n=r&&i&&r.get(i);return n?n.count*n.aliasCount:0}else if(ll.isCollection(t)){let i=0;for(let n of t.items){let o=Yg(e,n,r);if(o>i)i=o}return i}else if(ll.isPair(t)){let i=Yg(e,t.key,r),n=Yg(e,t.value,r);return Math.max(i,n)}return 1}dle.Alias=j4});var jt=ee(function(yle){var ple=Ge(),mle=Qg(),hle=qo(),gle=(e)=>!e||typeof e!=="function"&&typeof e!=="object";class aa extends mle.NodeBase{constructor(e){super(ple.SCALAR);this.value=e}toJSON(e,t){return t?.keep?this.value:hle.toJS(this.value,e,t)}toString(){return String(this.value)}}aa.BLOCK_FOLDED="BLOCK_FOLDED";aa.BLOCK_LITERAL="BLOCK_LITERAL";aa.PLAIN="PLAIN";aa.QUOTE_DOUBLE="QUOTE_DOUBLE";aa.QUOTE_SINGLE="QUOTE_SINGLE";yle.Scalar=aa;yle.isScalarValue=gle});var Jd=ee(function(kle){var Sle=Kd(),ca=Ge(),q4=jt(),wle="tag:yaml.org,2002:";function vle(e,t,r){if(t){let i=r.filter((o)=>o.tag===t),n=i.find((o)=>!o.format)??i[0];if(!n)throw Error(`Tag ${t} not found`);return n}return r.find((i)=>i.identify?.(e)&&!i.format)}function _le(e,t,r){if(ca.isDocument(e))e=e.contents;if(ca.isNode(e))return e;if(ca.isPair(e)){let d=r.schema[ca.MAP].createNode?.(r.schema,null,r);return d.items.push(e),d}if(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<"u"&&e instanceof BigInt)e=e.valueOf();let{aliasDuplicateObjects:i,onAnchor:n,onTagObj:o,schema:s,sourceObjects:a}=r,c=void 0;if(i&&e&&typeof e==="object")if(c=a.get(e),c)return c.anchor??(c.anchor=n(e)),new Sle.Alias(c.anchor);else c={anchor:null,node:null},a.set(e,c);if(t?.startsWith("!!"))t=wle+t.slice(2);let l=vle(e,t,s.tags);if(!l){if(e&&typeof e.toJSON==="function")e=e.toJSON();if(!e||typeof e!=="object"){let d=new q4.Scalar(e);if(c)c.node=d;return d}l=e instanceof Map?s[ca.MAP]:(Symbol.iterator in Object(e))?s[ca.SEQ]:s[ca.MAP]}if(o)o(l),delete r.onTagObj;let u=l?.createNode?l.createNode(r.schema,e,r):typeof l?.nodeClass?.from==="function"?l.nodeClass.from(r.schema,e,r):new q4.Scalar(e);if(t)u.tag=t;else if(!l.default)u.tag=l.tag;if(c)c.node=u;return u}kle.createNode=_le});var Xg=ee(function(Tle){var Ile=Jd(),ai=Ge(),Ale=Qg();function WI(e,t,r){let i=r;for(let n=t.length-1;n>=0;--n){let o=t[n];if(typeof o==="number"&&Number.isInteger(o)&&o>=0){let s=[];s[o]=i,i=s}else i=new Map([[o,i]])}return Ile.createNode(i,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw Error("This should not happen, please report a bug.")},schema:e,sourceObjects:new Map})}var U4=(e)=>e==null||typeof e==="object"&&!!e[Symbol.iterator]().next().done;class M4 extends Ale.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)=>ai.isNode(r)||ai.isPair(r)?r.clone(e):r),this.range)t.range=this.range.slice();return t}addIn(e,t){if(U4(e))this.add(t);else{let[r,...i]=e,n=this.get(r,!0);if(ai.isCollection(n))n.addIn(i,t);else if(n===void 0&&this.schema)this.set(r,WI(this.schema,i,t));else throw Error(`Expected YAML collection at ${r}. Remaining path: ${i}`)}}deleteIn(e){let[t,...r]=e;if(r.length===0)return this.delete(t);let i=this.get(t,!0);if(ai.isCollection(i))return i.deleteIn(r);else throw Error(`Expected YAML collection at ${t}. Remaining path: ${r}`)}getIn(e,t){let[r,...i]=e,n=this.get(r,!0);if(i.length===0)return!t&&ai.isScalar(n)?n.value:n;else return ai.isCollection(n)?n.getIn(i,t):void 0}hasAllNullValues(e){return this.items.every((t)=>{if(!ai.isPair(t))return!1;let r=t.value;return r==null||e&&ai.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 i=this.get(t,!0);return ai.isCollection(i)?i.hasIn(r):!1}setIn(e,t){let[r,...i]=e;if(i.length===0)this.set(r,t);else{let n=this.get(r,!0);if(ai.isCollection(n))n.setIn(i,t);else if(n===void 0&&this.schema)this.set(r,WI(this.schema,i,t));else throw Error(`Expected YAML collection at ${r}. Remaining path: ${i}`)}}}Tle.Collection=M4;Tle.collectionFromPath=WI;Tle.isEmptyPath=U4});var Vd=ee(function(zle){var Rle=(e)=>e.replace(/^(?!$)(?: $)?/gm,"#");function GI(e,t){if(/^\n+$/.test(e))return e.substring(1);return t?e.replace(/^(?! *$)/gm,t):e}var Ple=(e,t,r)=>e.endsWith(`
311
+ `}function Vae(e,t){let r=Hh(e.siteOverride);return[`BRAIN_VERSION=${e.brainVersion}`,...r.length>0?[`IMAGE_TAG=${Ed(e.brainVersion,r)}`]:[],`CONTENT_REPO=${g4(e,t)}`,""].join(`
312
+ `)}var UI=x(()=>{h4();UE();Ai()});var Ge=ee(function(bce){var HI=Symbol.for("yaml.alias"),k4=Symbol.for("yaml.document"),Kg=Symbol.for("yaml.map"),E4=Symbol.for("yaml.pair"),KI=Symbol.for("yaml.scalar"),Jg=Symbol.for("yaml.seq"),Di=Symbol.for("yaml.node.type"),dce=(e)=>!!e&&typeof e==="object"&&e[Di]===HI,fce=(e)=>!!e&&typeof e==="object"&&e[Di]===k4,pce=(e)=>!!e&&typeof e==="object"&&e[Di]===Kg,mce=(e)=>!!e&&typeof e==="object"&&e[Di]===E4,I4=(e)=>!!e&&typeof e==="object"&&e[Di]===KI,hce=(e)=>!!e&&typeof e==="object"&&e[Di]===Jg;function A4(e){if(e&&typeof e==="object")switch(e[Di]){case Kg:case Jg:return!0}return!1}function gce(e){if(e&&typeof e==="object")switch(e[Di]){case HI:case Kg:case KI:case Jg:return!0}return!1}var yce=(e)=>(I4(e)||A4(e))&&!!e.anchor;bce.ALIAS=HI;bce.DOC=k4;bce.MAP=Kg;bce.NODE_TYPE=Di;bce.PAIR=E4;bce.SCALAR=KI;bce.SEQ=Jg;bce.hasAnchor=yce;bce.isAlias=dce;bce.isCollection=A4;bce.isDocument=fce;bce.isMap=pce;bce.isNode=gce;bce.isPair=mce;bce.isScalar=I4;bce.isSeq=hce});var Zd=ee(function(Nce){var Zt=Ge(),Jr=Symbol("break visit"),T4=Symbol("skip children"),si=Symbol("remove node");function Vg(e,t){let r=C4(t);if(Zt.isDocument(e)){if(al(null,e.contents,r,Object.freeze([e]))===si)e.contents=null}else al(null,e,r,Object.freeze([]))}Vg.BREAK=Jr;Vg.SKIP=T4;Vg.REMOVE=si;function al(e,t,r,i){let n=$4(e,t,r,i);if(Zt.isNode(n)||Zt.isPair(n))return O4(e,i,n),al(e,n,r,i);if(typeof n!=="symbol"){if(Zt.isCollection(t)){i=Object.freeze(i.concat(t));for(let o=0;o<t.items.length;++o){let s=al(o,t.items[o],r,i);if(typeof s==="number")o=s-1;else if(s===Jr)return Jr;else if(s===si)t.items.splice(o,1),o-=1}}else if(Zt.isPair(t)){i=Object.freeze(i.concat(t));let o=al("key",t.key,r,i);if(o===Jr)return Jr;else if(o===si)t.key=null;let s=al("value",t.value,r,i);if(s===Jr)return Jr;else if(s===si)t.value=null}}return n}async function Wg(e,t){let r=C4(t);if(Zt.isDocument(e)){if(await cl(null,e.contents,r,Object.freeze([e]))===si)e.contents=null}else await cl(null,e,r,Object.freeze([]))}Wg.BREAK=Jr;Wg.SKIP=T4;Wg.REMOVE=si;async function cl(e,t,r,i){let n=await $4(e,t,r,i);if(Zt.isNode(n)||Zt.isPair(n))return O4(e,i,n),cl(e,n,r,i);if(typeof n!=="symbol"){if(Zt.isCollection(t)){i=Object.freeze(i.concat(t));for(let o=0;o<t.items.length;++o){let s=await cl(o,t.items[o],r,i);if(typeof s==="number")o=s-1;else if(s===Jr)return Jr;else if(s===si)t.items.splice(o,1),o-=1}}else if(Zt.isPair(t)){i=Object.freeze(i.concat(t));let o=await cl("key",t.key,r,i);if(o===Jr)return Jr;else if(o===si)t.key=null;let s=await cl("value",t.value,r,i);if(s===Jr)return Jr;else if(s===si)t.value=null}}return n}function C4(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 $4(e,t,r,i){if(typeof r==="function")return r(e,t,i);if(Zt.isMap(t))return r.Map?.(e,t,i);if(Zt.isSeq(t))return r.Seq?.(e,t,i);if(Zt.isPair(t))return r.Pair?.(e,t,i);if(Zt.isScalar(t))return r.Scalar?.(e,t,i);if(Zt.isAlias(t))return r.Alias?.(e,t,i);return}function O4(e,t,r){let i=t[t.length-1];if(Zt.isCollection(i))i.items[e]=r;else if(Zt.isPair(i))if(e==="key")i.key=r;else i.value=r;else if(Zt.isDocument(i))i.contents=r;else{let n=Zt.isAlias(i)?"alias":"scalar";throw Error(`Cannot replace node with ${n} parent`)}}Nce.visit=Vg;Nce.visitAsync=Wg});var JI=ee(function(Uce){var R4=Ge(),Bce=Zd(),jce={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},qce=(e)=>e.replace(/[!,[\]{}]/g,(t)=>jce[t]);class xn{constructor(e,t){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},xn.defaultYaml,e),this.tags=Object.assign({},xn.defaultTags,t)}clone(){let e=new xn(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){let e=new xn(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:xn.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},xn.defaultTags);break}return e}add(e,t){if(this.atNextDocument)this.yaml={explicit:xn.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},xn.defaultTags),this.atNextDocument=!1;let r=e.trim().split(/[ \t]+/),i=r.shift();switch(i){case"%TAG":{if(r.length!==2){if(t(0,"%TAG directive should contain exactly two parts"),r.length<2)return!1}let[n,o]=r;return this.tags[n]=o,!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 o=/^\d+\.\d+$/.test(n);return t(6,`Unsupported YAML version ${n}`,o),!1}}default:return t(0,`Unknown directive ${i}`,!0),!1}}tagName(e,t){if(e==="!")return"!";if(e[0]!=="!")return t(`Not a valid tag: ${e}`),null;if(e[1]==="<"){let o=e.slice(2,-1);if(o==="!"||o==="!!")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 o}let[,r,i]=e.match(/^(.*!)([^!]*)$/s);if(!i)t(`The ${e} tag has no suffix`);let n=this.tags[r];if(n)try{return n+decodeURIComponent(i)}catch(o){return t(String(o)),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+qce(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),i;if(e&&r.length>0&&R4.isNode(e.contents)){let n={};Bce.visit(e.contents,(o,s)=>{if(R4.isNode(s)&&s.tag)n[s.tag]=!0}),i=Object.keys(n)}else i=[];for(let[n,o]of r){if(n==="!!"&&o==="tag:yaml.org,2002:")continue;if(!e||i.some((s)=>s.startsWith(o)))t.push(`%TAG ${n} ${o}`)}return t.join(`
313
+ `)}}xn.defaultYaml={explicit:!1,version:"1.2"};xn.defaultTags={"!!":"tag:yaml.org,2002:"};Uce.Directives=xn});var Gg=ee(function(Kce){var P4=Ge(),Fce=Zd();function Zce(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 z4(e){let t=new Set;return Fce.visit(e,{Value(r,i){if(i.anchor)t.add(i.anchor)}}),t}function N4(e,t){for(let r=1;;++r){let i=`${e}${r}`;if(!t.has(i))return i}}function Hce(e,t){let r=[],i=new Map,n=null;return{onAnchor:(o)=>{r.push(o),n??(n=z4(e));let s=N4(t,n);return n.add(s),s},setAnchors:()=>{for(let o of r){let s=i.get(o);if(typeof s==="object"&&s.anchor&&(P4.isScalar(s.node)||P4.isCollection(s.node)))s.node.anchor=s.anchor;else{let a=Error("Failed to resolve repeated object (this should not happen)");throw a.source=o,a}}},sourceObjects:i}}Kce.anchorIsValid=Zce;Kce.anchorNames=z4;Kce.createNodeAnchors=Hce;Kce.findNewAnchor=N4});var VI=ee(function(Qce){function Hd(e,t,r,i){if(i&&typeof i==="object")if(Array.isArray(i))for(let n=0,o=i.length;n<o;++n){let s=i[n],a=Hd(e,i,String(n),s);if(a===void 0)delete i[n];else if(a!==s)i[n]=a}else if(i instanceof Map)for(let n of Array.from(i.keys())){let o=i.get(n),s=Hd(e,i,n,o);if(s===void 0)i.delete(n);else if(s!==o)i.set(n,s)}else if(i instanceof Set)for(let n of Array.from(i)){let o=Hd(e,i,n,n);if(o===void 0)i.delete(n);else if(o!==n)i.delete(n),i.add(o)}else for(let[n,o]of Object.entries(i)){let s=Hd(e,i,n,o);if(s===void 0)delete i[n];else if(s!==o)i[n]=s}return e.call(t,r,i)}Qce.applyReviver=Hd});var qo=ee(function(ele){var Xce=Ge();function D4(e,t,r){if(Array.isArray(e))return e.map((i,n)=>D4(i,String(n),r));if(e&&typeof e.toJSON==="function"){if(!r||!Xce.hasAnchor(e))return e.toJSON(t,r);let i={aliasCount:0,count:1,res:void 0};r.anchors.set(e,i),r.onCreate=(o)=>{i.res=o,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}ele.toJS=D4});var Qg=ee(function(ile){var rle=VI(),L4=Ge(),nle=qo();class B4{constructor(e){Object.defineProperty(this,L4.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:i,reviver:n}={}){if(!L4.isDocument(e))throw TypeError("A document argument is required");let o={anchors:new Map,doc:e,keep:!0,mapAsMap:t===!0,mapKeyWarned:!1,maxAliasCount:typeof r==="number"?r:100},s=nle.toJS(this,"",o);if(typeof i==="function")for(let{count:a,res:c}of o.anchors.values())i(c,a);return typeof n==="function"?rle.applyReviver(n,{"":s},"",s):s}}ile.NodeBase=B4});var Kd=ee(function(ule){var sle=Gg(),ale=Zd(),ll=Ge(),cle=Qg(),lle=qo();class j4 extends cle.NodeBase{constructor(e){super(ll.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=[],ale.visit(e,{Node:(n,o)=>{if(ll.isAlias(o)||ll.hasAnchor(o))r.push(o)}}),t)t.aliasResolveCache=r;let i=void 0;for(let n of r){if(n===this)break;if(n.anchor===this.source)i=n}return i}toJSON(e,t){if(!t)return{source:this.source};let{anchors:r,doc:i,maxAliasCount:n}=t,o=this.resolve(i,t);if(!o){let a=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(a)}let s=r.get(o);if(!s)lle.toJS(o,null,t),s=r.get(o);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=Yg(i,o,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 i=`*${this.source}`;if(e){if(sle.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`${i} `}return i}}function Yg(e,t,r){if(ll.isAlias(t)){let i=t.resolve(e),n=r&&i&&r.get(i);return n?n.count*n.aliasCount:0}else if(ll.isCollection(t)){let i=0;for(let n of t.items){let o=Yg(e,n,r);if(o>i)i=o}return i}else if(ll.isPair(t)){let i=Yg(e,t.key,r),n=Yg(e,t.value,r);return Math.max(i,n)}return 1}ule.Alias=j4});var jt=ee(function(gle){var fle=Ge(),ple=Qg(),mle=qo(),hle=(e)=>!e||typeof e!=="function"&&typeof e!=="object";class aa extends ple.NodeBase{constructor(e){super(fle.SCALAR);this.value=e}toJSON(e,t){return t?.keep?this.value:mle.toJS(this.value,e,t)}toString(){return String(this.value)}}aa.BLOCK_FOLDED="BLOCK_FOLDED";aa.BLOCK_LITERAL="BLOCK_LITERAL";aa.PLAIN="PLAIN";aa.QUOTE_DOUBLE="QUOTE_DOUBLE";aa.QUOTE_SINGLE="QUOTE_SINGLE";gle.Scalar=aa;gle.isScalarValue=hle});var Jd=ee(function(_le){var xle=Kd(),ca=Ge(),q4=jt(),Sle="tag:yaml.org,2002:";function wle(e,t,r){if(t){let i=r.filter((o)=>o.tag===t),n=i.find((o)=>!o.format)??i[0];if(!n)throw Error(`Tag ${t} not found`);return n}return r.find((i)=>i.identify?.(e)&&!i.format)}function vle(e,t,r){if(ca.isDocument(e))e=e.contents;if(ca.isNode(e))return e;if(ca.isPair(e)){let d=r.schema[ca.MAP].createNode?.(r.schema,null,r);return d.items.push(e),d}if(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<"u"&&e instanceof BigInt)e=e.valueOf();let{aliasDuplicateObjects:i,onAnchor:n,onTagObj:o,schema:s,sourceObjects:a}=r,c=void 0;if(i&&e&&typeof e==="object")if(c=a.get(e),c)return c.anchor??(c.anchor=n(e)),new xle.Alias(c.anchor);else c={anchor:null,node:null},a.set(e,c);if(t?.startsWith("!!"))t=Sle+t.slice(2);let l=wle(e,t,s.tags);if(!l){if(e&&typeof e.toJSON==="function")e=e.toJSON();if(!e||typeof e!=="object"){let d=new q4.Scalar(e);if(c)c.node=d;return d}l=e instanceof Map?s[ca.MAP]:(Symbol.iterator in Object(e))?s[ca.SEQ]:s[ca.MAP]}if(o)o(l),delete r.onTagObj;let u=l?.createNode?l.createNode(r.schema,e,r):typeof l?.nodeClass?.from==="function"?l.nodeClass.from(r.schema,e,r):new q4.Scalar(e);if(t)u.tag=t;else if(!l.default)u.tag=l.tag;if(c)c.node=u;return u}_le.createNode=vle});var Xg=ee(function(Ale){var Ele=Jd(),ai=Ge(),Ile=Qg();function WI(e,t,r){let i=r;for(let n=t.length-1;n>=0;--n){let o=t[n];if(typeof o==="number"&&Number.isInteger(o)&&o>=0){let s=[];s[o]=i,i=s}else i=new Map([[o,i]])}return Ele.createNode(i,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw Error("This should not happen, please report a bug.")},schema:e,sourceObjects:new Map})}var U4=(e)=>e==null||typeof e==="object"&&!!e[Symbol.iterator]().next().done;class M4 extends Ile.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)=>ai.isNode(r)||ai.isPair(r)?r.clone(e):r),this.range)t.range=this.range.slice();return t}addIn(e,t){if(U4(e))this.add(t);else{let[r,...i]=e,n=this.get(r,!0);if(ai.isCollection(n))n.addIn(i,t);else if(n===void 0&&this.schema)this.set(r,WI(this.schema,i,t));else throw Error(`Expected YAML collection at ${r}. Remaining path: ${i}`)}}deleteIn(e){let[t,...r]=e;if(r.length===0)return this.delete(t);let i=this.get(t,!0);if(ai.isCollection(i))return i.deleteIn(r);else throw Error(`Expected YAML collection at ${t}. Remaining path: ${r}`)}getIn(e,t){let[r,...i]=e,n=this.get(r,!0);if(i.length===0)return!t&&ai.isScalar(n)?n.value:n;else return ai.isCollection(n)?n.getIn(i,t):void 0}hasAllNullValues(e){return this.items.every((t)=>{if(!ai.isPair(t))return!1;let r=t.value;return r==null||e&&ai.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 i=this.get(t,!0);return ai.isCollection(i)?i.hasIn(r):!1}setIn(e,t){let[r,...i]=e;if(i.length===0)this.set(r,t);else{let n=this.get(r,!0);if(ai.isCollection(n))n.setIn(i,t);else if(n===void 0&&this.schema)this.set(r,WI(this.schema,i,t));else throw Error(`Expected YAML collection at ${r}. Remaining path: ${i}`)}}}Ale.Collection=M4;Ale.collectionFromPath=WI;Ale.isEmptyPath=U4});var Vd=ee(function(Ple){var Ole=(e)=>e.replace(/^(?!$)(?: $)?/gm,"#");function GI(e,t){if(/^\n+$/.test(e))return e.substring(1);return t?e.replace(/^(?! *$)/gm,t):e}var Rle=(e,t,r)=>e.endsWith(`
315
314
  `)?GI(r,t):r.includes(`
316
315
  `)?`
317
- `+GI(r,t):(e.endsWith(" ")?"":" ")+r;zle.indentComment=GI;zle.lineComment=Ple;zle.stringifyComment=Rle});var Z4=ee(function(jle){function Ble(e,t,r="flow",{indentAtStart:i,lineWidth:n=80,minContentWidth:o=20,onFold:s,onOverflow:a}={}){if(!n||n<0)return e;if(n<o)o=0;let c=Math.max(1+o,1+n-t.length);if(e.length<=c)return e;let l=[],u={},d=n-t.length;if(typeof i==="number")if(i>n-Math.max(2,o))l.push(0);else d=n-i;let p=void 0,m=void 0,y=!1,g=-1,b=-1,v=-1;if(r==="block"){if(g=F4(e,g,t.length),g!==-1)d=g+c}for(let T;T=e[g+=1];){if(r==="quoted"&&T==="\\"){switch(b=g,e[g+1]){case"x":g+=3;break;case"u":g+=5;break;case"U":g+=9;break;default:g+=1}v=g}if(T===`
316
+ `+GI(r,t):(e.endsWith(" ")?"":" ")+r;Ple.indentComment=GI;Ple.lineComment=Rle;Ple.stringifyComment=Ole});var Z4=ee(function(Ble){function Lle(e,t,r="flow",{indentAtStart:i,lineWidth:n=80,minContentWidth:o=20,onFold:s,onOverflow:a}={}){if(!n||n<0)return e;if(n<o)o=0;let c=Math.max(1+o,1+n-t.length);if(e.length<=c)return e;let l=[],u={},d=n-t.length;if(typeof i==="number")if(i>n-Math.max(2,o))l.push(0);else d=n-i;let p=void 0,m=void 0,y=!1,g=-1,b=-1,v=-1;if(r==="block"){if(g=F4(e,g,t.length),g!==-1)d=g+c}for(let T;T=e[g+=1];){if(r==="quoted"&&T==="\\"){switch(b=g,e[g+1]){case"x":g+=3;break;case"u":g+=5;break;case"U":g+=9;break;default:g+=1}v=g}if(T===`
318
317
  `){if(r==="block")g=F4(e,g,t.length);d=g+t.length+c,p=void 0}else{if(T===" "&&m&&m!==" "&&m!==`
319
318
  `&&m!=="\t"){let z=e[g+1];if(z&&z!==" "&&z!==`
320
319
  `&&z!=="\t")p=g}if(g>=d)if(p)l.push(p),d=p+c,p=void 0;else if(r==="quoted"){while(m===" "||m==="\t")m=T,T=e[g+=1],y=!0;let z=g>v+1?g-2:b-1;if(u[z])return e;l.push(z),u[z]=!0,d=z+c,p=void 0}else y=!0}m=T}if(y&&a)a();if(l.length===0)return e;if(s)s();let A=e.slice(0,l[0]);for(let T=0;T<l.length;++T){let z=l[T],j=l[T+1]||e.length;if(z===0)A=`
321
320
  ${t}${e.slice(0,j)}`;else{if(r==="quoted"&&u[z])A+=`${e[z]}\\`;A+=`
322
321
  ${t}${e.slice(z+1,j)}`}}return A}function F4(e,t,r){let i=t,n=t+1,o=e[n];while(o===" "||o==="\t")if(t<n+r)o=e[++t];else{do o=e[++t];while(o&&o!==`
323
- `);i=t,n=t+1,o=e[n]}return i}jle.FOLD_BLOCK="block";jle.FOLD_FLOW="flow";jle.FOLD_QUOTED="quoted";jle.foldFlowLines=Ble});var Gd=ee(function(Jle){var jn=jt(),Uo=Z4(),ty=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),ry=(e)=>/^(%|---|\.\.\.)/m.test(e);function Zle(e,t,r){if(!t||t<0)return!1;let i=t-r,n=e.length;if(n<=i)return!1;for(let o=0,s=0;o<n;++o)if(e[o]===`
322
+ `);i=t,n=t+1,o=e[n]}return i}Ble.FOLD_BLOCK="block";Ble.FOLD_FLOW="flow";Ble.FOLD_QUOTED="quoted";Ble.foldFlowLines=Lle});var Gd=ee(function(Kle){var jn=jt(),Uo=Z4(),ty=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),ry=(e)=>/^(%|---|\.\.\.)/m.test(e);function Fle(e,t,r){if(!t||t<0)return!1;let i=t-r,n=e.length;if(n<=i)return!1;for(let o=0,s=0;o<n;++o)if(e[o]===`
324
323
  `){if(o-s>i)return!0;if(s=o+1,n-s<=i)return!1}return!0}function Wd(e,t){let r=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return r;let{implicitKey:i}=t,n=t.options.doubleQuotedMinMultiLineLength,o=t.indent||(ry(e)?" ":""),s="",a=0;for(let c=0,l=r[c];l;l=r[++c]){if(l===" "&&r[c+1]==="\\"&&r[c+2]==="n")s+=r.slice(a,c)+"\\ ",c+=1,a=c,l="\\";if(l==="\\")switch(r[c+1]){case"u":{s+=r.slice(a,c);let u=r.substr(c+2,4);switch(u){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(u.substr(0,2)==="00")s+="\\x"+u.substr(2);else s+=r.substr(c,6)}c+=5,a=c+1}break;case"n":if(i||r[c+2]==='"'||r.length<n)c+=1;else{s+=r.slice(a,c)+`
325
324
 
326
325
  `;while(r[c+2]==="\\"&&r[c+3]==="n"&&r[c+4]!=='"')s+=`
@@ -329,7 +328,7 @@ ${t}${e.slice(z+1,j)}`}}return A}function F4(e,t,r){let i=t,n=t+1,o=e[n];while(o
329
328
  ${r}`)+"'";return t.implicitKey?i:Uo.foldFlowLines(i,r,Uo.FOLD_FLOW,ty(t,!1))}function ul(e,t){let{singleQuote:r}=t.options,i;if(r===!1)i=Wd;else{let n=e.includes('"'),o=e.includes("'");if(n&&!o)i=QI;else if(o&&!n)i=Wd;else i=r?QI:Wd}return i(e,t)}var YI;try{YI=new RegExp(`(^|(?<!
330
329
  ))
331
330
  +(?!
332
- |$)`,"g")}catch{YI=/\n+(?!\n|$)/g}function ey({comment:e,type:t,value:r},i,n,o){let{blockQuote:s,commentString:a,lineWidth:c}=i.options;if(!s||/\n[\t ]+$/.test(r))return ul(r,i);let l=i.indent||(i.forceBlockIndent||ry(r)?" ":""),u=s==="literal"?!0:s==="folded"||t===jn.Scalar.BLOCK_FOLDED?!1:t===jn.Scalar.BLOCK_LITERAL?!0:!Zle(r,c,l.length);if(!r)return u?`|
331
+ |$)`,"g")}catch{YI=/\n+(?!\n|$)/g}function ey({comment:e,type:t,value:r},i,n,o){let{blockQuote:s,commentString:a,lineWidth:c}=i.options;if(!s||/\n[\t ]+$/.test(r))return ul(r,i);let l=i.indent||(i.forceBlockIndent||ry(r)?" ":""),u=s==="literal"?!0:s==="folded"||t===jn.Scalar.BLOCK_FOLDED?!1:t===jn.Scalar.BLOCK_LITERAL?!0:!Fle(r,c,l.length);if(!r)return u?`|
333
332
  `:`>
334
333
  `;let d,p;for(p=r.length;p>0;--p){let j=r[p-1];if(j!==`
335
334
  `&&j!=="\t"&&j!==" ")break}let m=r.substring(p),y=m.indexOf(`
@@ -338,12 +337,12 @@ ${r}`)+"'";return t.implicitKey?i:Uo.foldFlowLines(i,r,Uo.FOLD_FLOW,ty(t,!1))}fu
338
337
  `)v=b;else break}let A=r.substring(0,v<b?v+1:b);if(A)r=r.substring(A.length),A=A.replace(/\n+/g,`$&${l}`);let z=(g?l?"2":"1":"")+d;if(e){if(z+=" "+a(e.replace(/ ?[\r\n]+/g," ")),n)n()}if(!u){let j=r.replace(/\n+/g,`
339
338
  $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${l}`),E=!1,Z=ty(i,!0);if(s!=="folded"&&t!==jn.Scalar.BLOCK_FOLDED)Z.onOverflow=()=>{E=!0};let D=Uo.foldFlowLines(`${A}${j}${m}`,l,Uo.FOLD_BLOCK,Z);if(!E)return`>${z}
340
339
  ${l}${D}`}return r=r.replace(/\n+/g,`$&${l}`),`|${z}
341
- ${l}${A}${r}${m}`}function Hle(e,t,r,i){let{type:n,value:o}=e,{actualString:s,implicitKey:a,indent:c,indentStep:l,inFlow:u}=t;if(a&&o.includes(`
340
+ ${l}${A}${r}${m}`}function Zle(e,t,r,i){let{type:n,value:o}=e,{actualString:s,implicitKey:a,indent:c,indentStep:l,inFlow:u}=t;if(a&&o.includes(`
342
341
  `)||u&&/[[\]{},]/.test(o))return ul(o,t);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(o))return a||u||!o.includes(`
343
342
  `)?ul(o,t):ey(e,t,r,i);if(!a&&!u&&n!==jn.Scalar.PLAIN&&o.includes(`
344
343
  `))return ey(e,t,r,i);if(ry(o)){if(c==="")return t.forceBlockIndent=!0,ey(e,t,r,i);else if(a&&c===l)return ul(o,t)}let d=o.replace(/\n+/g,`$&
345
- ${c}`);if(s){let p=(g)=>g.default&&g.tag!=="tag:yaml.org,2002:str"&&g.test?.test(d),{compat:m,tags:y}=t.doc.schema;if(y.some(p)||m?.some(p))return ul(o,t)}return a?d:Uo.foldFlowLines(d,c,Uo.FOLD_FLOW,ty(t,!1))}function Kle(e,t,r,i){let{implicitKey:n,inFlow:o}=t,s=typeof e.value==="string"?e:Object.assign({},e,{value:String(e.value)}),{type:a}=e;if(a!==jn.Scalar.QUOTE_DOUBLE){if(/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(s.value))a=jn.Scalar.QUOTE_DOUBLE}let c=(u)=>{switch(u){case jn.Scalar.BLOCK_FOLDED:case jn.Scalar.BLOCK_LITERAL:return n||o?ul(s.value,t):ey(s,t,r,i);case jn.Scalar.QUOTE_DOUBLE:return Wd(s.value,t);case jn.Scalar.QUOTE_SINGLE:return QI(s.value,t);case jn.Scalar.PLAIN:return Hle(s,t,r,i);default:return null}},l=c(a);if(l===null){let{defaultKeyType:u,defaultStringType:d}=t.options,p=n&&u||d;if(l=c(p),l===null)throw Error(`Unsupported default string type ${p}`)}return l}Jle.stringifyString=Kle});var Qd=ee(function(rue){var Wle=Gg(),Mo=Ge(),Gle=Vd(),Qle=Gd();function Yle(e,t){let r=Object.assign({blockQuote:!0,commentString:Gle.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),i;switch(r.collectionStyle){case"block":i=!1;break;case"flow":i=!0;break;default:i=null}return{anchors:new Set,doc:e,flowCollectionPadding:r.flowCollectionPadding?" ":"",indent:"",indentStep:typeof r.indent==="number"?" ".repeat(r.indent):" ",inFlow:i,options:r}}function Xle(e,t){if(t.tag){let n=e.filter((o)=>o.tag===t.tag);if(n.length>0)return n.find((o)=>o.format===t.format)??n[0]}let r=void 0,i;if(Mo.isScalar(t)){i=t.value;let n=e.filter((o)=>o.identify?.(i));if(n.length>1){let o=n.filter((s)=>s.test);if(o.length>0)n=o}r=n.find((o)=>o.format===t.format)??n.find((o)=>!o.format)}else i=t,r=e.find((n)=>n.nodeClass&&i instanceof n.nodeClass);if(!r){let n=i?.constructor?.name??(i===null?"null":typeof i);throw Error(`Tag not resolved for ${n} value`)}return r}function eue(e,t,{anchors:r,doc:i}){if(!i.directives)return"";let n=[],o=(Mo.isScalar(e)||Mo.isCollection(e))&&e.anchor;if(o&&Wle.anchorIsValid(o))r.add(o),n.push(`&${o}`);let s=e.tag??(t.default?null:t.tag);if(s)n.push(i.directives.tagString(s));return n.join(" ")}function tue(e,t,r,i){if(Mo.isPair(e))return e.toString(t,r,i);if(Mo.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,o=Mo.isNode(e)?e:t.doc.createNode(e,{onTagObj:(c)=>n=c});n??(n=Xle(t.doc.schema.tags,o));let s=eue(o,n,t);if(s.length>0)t.indentAtStart=(t.indentAtStart??0)+s.length+1;let a=typeof n.stringify==="function"?n.stringify(o,t,r,i):Mo.isScalar(o)?Qle.stringifyString(o,t,r,i):o.toString(t,r,i);if(!s)return a;return Mo.isScalar(o)||a[0]==="{"||a[0]==="["?`${s} ${a}`:`${s}
346
- ${t.indent}${a}`}rue.createStringifyContext=Yle;rue.stringify=tue});var J4=ee(function(sue){var Li=Ge(),H4=jt(),K4=Qd(),Yd=Vd();function oue({key:e,value:t},r,i,n){let{allNullValues:o,doc:s,indent:a,indentStep:c,options:{commentString:l,indentSeq:u,simpleKeys:d}}=r,p=Li.isNode(e)&&e.comment||null;if(d){if(p)throw Error("With simple keys, key nodes cannot have comments");if(Li.isCollection(e)||!Li.isNode(e)&&typeof e==="object")throw Error("With simple keys, collection cannot be used as a key value")}let m=!d&&(!e||p&&t==null&&!r.inFlow||Li.isCollection(e)||(Li.isScalar(e)?e.type===H4.Scalar.BLOCK_FOLDED||e.type===H4.Scalar.BLOCK_LITERAL:typeof e==="object"));r=Object.assign({},r,{allNullValues:!1,implicitKey:!m&&(d||!o),indent:a+c});let y=!1,g=!1,b=K4.stringify(e,r,()=>y=!0,()=>g=!0);if(!m&&!r.inFlow&&b.length>1024){if(d)throw Error("With simple keys, single line scalar must not span more than 1024 characters");m=!0}if(r.inFlow){if(o||t==null){if(y&&i)i();return b===""?"?":m?`? ${b}`:b}}else if(o&&!d||t==null&&m){if(b=`? ${b}`,p&&!y)b+=Yd.lineComment(b,r.indent,l(p));else if(g&&n)n();return b}if(y)p=null;if(m){if(p)b+=Yd.lineComment(b,r.indent,l(p));b=`? ${b}
344
+ ${c}`);if(s){let p=(g)=>g.default&&g.tag!=="tag:yaml.org,2002:str"&&g.test?.test(d),{compat:m,tags:y}=t.doc.schema;if(y.some(p)||m?.some(p))return ul(o,t)}return a?d:Uo.foldFlowLines(d,c,Uo.FOLD_FLOW,ty(t,!1))}function Hle(e,t,r,i){let{implicitKey:n,inFlow:o}=t,s=typeof e.value==="string"?e:Object.assign({},e,{value:String(e.value)}),{type:a}=e;if(a!==jn.Scalar.QUOTE_DOUBLE){if(/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(s.value))a=jn.Scalar.QUOTE_DOUBLE}let c=(u)=>{switch(u){case jn.Scalar.BLOCK_FOLDED:case jn.Scalar.BLOCK_LITERAL:return n||o?ul(s.value,t):ey(s,t,r,i);case jn.Scalar.QUOTE_DOUBLE:return Wd(s.value,t);case jn.Scalar.QUOTE_SINGLE:return QI(s.value,t);case jn.Scalar.PLAIN:return Zle(s,t,r,i);default:return null}},l=c(a);if(l===null){let{defaultKeyType:u,defaultStringType:d}=t.options,p=n&&u||d;if(l=c(p),l===null)throw Error(`Unsupported default string type ${p}`)}return l}Kle.stringifyString=Hle});var Qd=ee(function(tue){var Vle=Gg(),Mo=Ge(),Wle=Vd(),Gle=Gd();function Qle(e,t){let r=Object.assign({blockQuote:!0,commentString:Wle.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),i;switch(r.collectionStyle){case"block":i=!1;break;case"flow":i=!0;break;default:i=null}return{anchors:new Set,doc:e,flowCollectionPadding:r.flowCollectionPadding?" ":"",indent:"",indentStep:typeof r.indent==="number"?" ".repeat(r.indent):" ",inFlow:i,options:r}}function Yle(e,t){if(t.tag){let n=e.filter((o)=>o.tag===t.tag);if(n.length>0)return n.find((o)=>o.format===t.format)??n[0]}let r=void 0,i;if(Mo.isScalar(t)){i=t.value;let n=e.filter((o)=>o.identify?.(i));if(n.length>1){let o=n.filter((s)=>s.test);if(o.length>0)n=o}r=n.find((o)=>o.format===t.format)??n.find((o)=>!o.format)}else i=t,r=e.find((n)=>n.nodeClass&&i instanceof n.nodeClass);if(!r){let n=i?.constructor?.name??(i===null?"null":typeof i);throw Error(`Tag not resolved for ${n} value`)}return r}function Xle(e,t,{anchors:r,doc:i}){if(!i.directives)return"";let n=[],o=(Mo.isScalar(e)||Mo.isCollection(e))&&e.anchor;if(o&&Vle.anchorIsValid(o))r.add(o),n.push(`&${o}`);let s=e.tag??(t.default?null:t.tag);if(s)n.push(i.directives.tagString(s));return n.join(" ")}function eue(e,t,r,i){if(Mo.isPair(e))return e.toString(t,r,i);if(Mo.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,o=Mo.isNode(e)?e:t.doc.createNode(e,{onTagObj:(c)=>n=c});n??(n=Yle(t.doc.schema.tags,o));let s=Xle(o,n,t);if(s.length>0)t.indentAtStart=(t.indentAtStart??0)+s.length+1;let a=typeof n.stringify==="function"?n.stringify(o,t,r,i):Mo.isScalar(o)?Gle.stringifyString(o,t,r,i):o.toString(t,r,i);if(!s)return a;return Mo.isScalar(o)||a[0]==="{"||a[0]==="["?`${s} ${a}`:`${s}
345
+ ${t.indent}${a}`}tue.createStringifyContext=Qle;tue.stringify=eue});var J4=ee(function(oue){var Li=Ge(),H4=jt(),K4=Qd(),Yd=Vd();function iue({key:e,value:t},r,i,n){let{allNullValues:o,doc:s,indent:a,indentStep:c,options:{commentString:l,indentSeq:u,simpleKeys:d}}=r,p=Li.isNode(e)&&e.comment||null;if(d){if(p)throw Error("With simple keys, key nodes cannot have comments");if(Li.isCollection(e)||!Li.isNode(e)&&typeof e==="object")throw Error("With simple keys, collection cannot be used as a key value")}let m=!d&&(!e||p&&t==null&&!r.inFlow||Li.isCollection(e)||(Li.isScalar(e)?e.type===H4.Scalar.BLOCK_FOLDED||e.type===H4.Scalar.BLOCK_LITERAL:typeof e==="object"));r=Object.assign({},r,{allNullValues:!1,implicitKey:!m&&(d||!o),indent:a+c});let y=!1,g=!1,b=K4.stringify(e,r,()=>y=!0,()=>g=!0);if(!m&&!r.inFlow&&b.length>1024){if(d)throw Error("With simple keys, single line scalar must not span more than 1024 characters");m=!0}if(r.inFlow){if(o||t==null){if(y&&i)i();return b===""?"?":m?`? ${b}`:b}}else if(o&&!d||t==null&&m){if(b=`? ${b}`,p&&!y)b+=Yd.lineComment(b,r.indent,l(p));else if(g&&n)n();return b}if(y)p=null;if(m){if(p)b+=Yd.lineComment(b,r.indent,l(p));b=`? ${b}
347
346
  ${a}:`}else if(b=`${b}:`,p)b+=Yd.lineComment(b,r.indent,l(p));let v,A,T;if(Li.isNode(t))v=!!t.spaceBefore,A=t.commentBefore,T=t.comment;else if(v=!1,A=null,T=null,t&&typeof t==="object")t=s.createNode(t);if(r.implicitKey=!1,!m&&!p&&Li.isScalar(t))r.indentAtStart=b.length+1;if(g=!1,!u&&c.length>=2&&!r.inFlow&&!m&&Li.isSeq(t)&&!t.flow&&!t.tag&&!t.anchor)r.indent=r.indent.substring(2);let z=!1,j=K4.stringify(t,r,()=>z=!0,()=>g=!0),E=" ";if(p||v||A){if(E=v?`
348
347
  `:"",A){let Z=l(A);E+=`
349
348
  ${Yd.indentComment(Z,r.indent)}`}if(j===""&&!r.inFlow){if(E===`
@@ -353,32 +352,32 @@ ${Yd.indentComment(Z,r.indent)}`}if(j===""&&!r.inFlow){if(E===`
353
352
  ${r.indent}`}else if(!m&&Li.isCollection(t)){let Z=j[0],D=j.indexOf(`
354
353
  `),H=D!==-1,X=r.inFlow??t.flow??t.items.length===0;if(H||!X){let M=!1;if(H&&(Z==="&"||Z==="!")){let P=j.indexOf(" ");if(Z==="&"&&P!==-1&&P<D&&j[P+1]==="!")P=j.indexOf(" ",P+1);if(P===-1||D<P)M=!0}if(!M)E=`
355
354
  ${r.indent}`}}else if(j===""||j[0]===`
356
- `)E="";if(b+=E+j,r.inFlow){if(z&&i)i()}else if(T&&!z)b+=Yd.lineComment(b,r.indent,l(T));else if(g&&n)n();return b}sue.stringifyPair=oue});var XI=ee(function(uue){var V4=Tt("process");function cue(e,...t){if(e==="debug")console.log(...t)}function lue(e,t){if(e==="debug"||e==="warn")if(typeof V4.emitWarning==="function")V4.emitWarning(t);else console.warn(t)}uue.debug=cue;uue.warn=lue});var sy=ee(function(mue){var oy=Ge(),W4=jt(),ny="<<",iy={identify:(e)=>e===ny||typeof e==="symbol"&&e.description===ny,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new W4.Scalar(Symbol(ny)),{addToJSMap:G4}),stringify:()=>ny},pue=(e,t)=>(iy.identify(t)||oy.isScalar(t)&&(!t.type||t.type===W4.Scalar.PLAIN)&&iy.identify(t.value))&&e?.doc.schema.tags.some((r)=>r.tag===iy.tag&&r.default);function G4(e,t,r){let i=Q4(e,r);if(oy.isSeq(i))for(let n of i.items)eA(e,t,n);else if(Array.isArray(i))for(let n of i)eA(e,t,n);else eA(e,t,i)}function eA(e,t,r){let i=Q4(e,r);if(!oy.isMap(i))throw Error("Merge sources must be maps or map aliases");let n=i.toJSON(null,e,Map);for(let[o,s]of n)if(t instanceof Map){if(!t.has(o))t.set(o,s)}else if(t instanceof Set)t.add(o);else if(!Object.prototype.hasOwnProperty.call(t,o))Object.defineProperty(t,o,{value:s,writable:!0,enumerable:!0,configurable:!0});return t}function Q4(e,t){return e&&oy.isAlias(t)?t.resolve(e.doc,e):t}mue.addMergeToJSMap=G4;mue.isMergeKey=pue;mue.merge=iy});var rA=ee(function(vue){var bue=XI(),Y4=sy(),xue=Qd(),X4=Ge(),tA=qo();function Sue(e,t,{key:r,value:i}){if(X4.isNode(r)&&r.addToJSMap)r.addToJSMap(e,t,i);else if(Y4.isMergeKey(e,r))Y4.addMergeToJSMap(e,t,i);else{let n=tA.toJS(r,"",e);if(t instanceof Map)t.set(n,tA.toJS(i,n,e));else if(t instanceof Set)t.add(n);else{let o=wue(r,n,e),s=tA.toJS(i,o,e);if(o in t)Object.defineProperty(t,o,{value:s,writable:!0,enumerable:!0,configurable:!0});else t[o]=s}}return t}function wue(e,t,r){if(t===null)return"";if(typeof t!=="object")return String(t);if(X4.isNode(e)&&r?.doc){let i=xue.createStringifyContext(r.doc,{});i.anchors=new Set;for(let o of r.anchors.keys())i.anchors.add(o.anchor);i.inFlow=!0,i.inStringifyKey=!0;let n=e.toString(i);if(!r.mapKeyWarned){let o=JSON.stringify(n);if(o.length>40)o=o.substring(0,36)+'..."';bue.warn(r.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${o}. Set mapAsMap: true to use object keys.`),r.mapKeyWarned=!0}return n}return JSON.stringify(t)}vue.addPairToJSMap=Sue});var Fo=ee(function(Aue){var eM=Jd(),kue=J4(),Eue=rA(),ay=Ge();function Iue(e,t,r){let i=eM.createNode(e,void 0,r),n=eM.createNode(t,void 0,r);return new cy(i,n)}class cy{constructor(e,t=null){Object.defineProperty(this,ay.NODE_TYPE,{value:ay.PAIR}),this.key=e,this.value=t}clone(e){let{key:t,value:r}=this;if(ay.isNode(t))t=t.clone(e);if(ay.isNode(r))r=r.clone(e);return new cy(t,r)}toJSON(e,t){let r=t?.mapAsMap?new Map:{};return Eue.addPairToJSMap(t,r,this)}toString(e,t,r){return e?.doc?kue.stringifyPair(this,e,t,r):JSON.stringify(this)}}Aue.Pair=cy;Aue.createPair=Iue});var nA=ee(function(Pue){var la=Ge(),tM=Qd(),ly=Vd();function $ue(e,t,r){return(t.inFlow??e.flow?Rue:Oue)(e,t,r)}function Oue({comment:e,items:t},r,{blockItemPrefix:i,flowChars:n,itemIndent:o,onChompKeep:s,onComment:a}){let{indent:c,options:{commentString:l}}=r,u=Object.assign({},r,{indent:o,type:null}),d=!1,p=[];for(let y=0;y<t.length;++y){let g=t[y],b=null;if(la.isNode(g)){if(!d&&g.spaceBefore)p.push("");if(uy(r,p,g.commentBefore,d),g.comment)b=g.comment}else if(la.isPair(g)){let A=la.isNode(g.key)?g.key:null;if(A){if(!d&&A.spaceBefore)p.push("");uy(r,p,A.commentBefore,d)}}d=!1;let v=tM.stringify(g,u,()=>b=null,()=>d=!0);if(b)v+=ly.lineComment(v,o,l(b));if(d&&b)d=!1;p.push(i+v)}let m;if(p.length===0)m=n.start+n.end;else{m=p[0];for(let y=1;y<p.length;++y){let g=p[y];m+=g?`
355
+ `)E="";if(b+=E+j,r.inFlow){if(z&&i)i()}else if(T&&!z)b+=Yd.lineComment(b,r.indent,l(T));else if(g&&n)n();return b}oue.stringifyPair=iue});var XI=ee(function(lue){var V4=Tt("process");function aue(e,...t){if(e==="debug")console.log(...t)}function cue(e,t){if(e==="debug"||e==="warn")if(typeof V4.emitWarning==="function")V4.emitWarning(t);else console.warn(t)}lue.debug=aue;lue.warn=cue});var sy=ee(function(pue){var oy=Ge(),W4=jt(),ny="<<",iy={identify:(e)=>e===ny||typeof e==="symbol"&&e.description===ny,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new W4.Scalar(Symbol(ny)),{addToJSMap:G4}),stringify:()=>ny},fue=(e,t)=>(iy.identify(t)||oy.isScalar(t)&&(!t.type||t.type===W4.Scalar.PLAIN)&&iy.identify(t.value))&&e?.doc.schema.tags.some((r)=>r.tag===iy.tag&&r.default);function G4(e,t,r){let i=Q4(e,r);if(oy.isSeq(i))for(let n of i.items)eA(e,t,n);else if(Array.isArray(i))for(let n of i)eA(e,t,n);else eA(e,t,i)}function eA(e,t,r){let i=Q4(e,r);if(!oy.isMap(i))throw Error("Merge sources must be maps or map aliases");let n=i.toJSON(null,e,Map);for(let[o,s]of n)if(t instanceof Map){if(!t.has(o))t.set(o,s)}else if(t instanceof Set)t.add(o);else if(!Object.prototype.hasOwnProperty.call(t,o))Object.defineProperty(t,o,{value:s,writable:!0,enumerable:!0,configurable:!0});return t}function Q4(e,t){return e&&oy.isAlias(t)?t.resolve(e.doc,e):t}pue.addMergeToJSMap=G4;pue.isMergeKey=fue;pue.merge=iy});var rA=ee(function(wue){var yue=XI(),Y4=sy(),bue=Qd(),X4=Ge(),tA=qo();function xue(e,t,{key:r,value:i}){if(X4.isNode(r)&&r.addToJSMap)r.addToJSMap(e,t,i);else if(Y4.isMergeKey(e,r))Y4.addMergeToJSMap(e,t,i);else{let n=tA.toJS(r,"",e);if(t instanceof Map)t.set(n,tA.toJS(i,n,e));else if(t instanceof Set)t.add(n);else{let o=Sue(r,n,e),s=tA.toJS(i,o,e);if(o in t)Object.defineProperty(t,o,{value:s,writable:!0,enumerable:!0,configurable:!0});else t[o]=s}}return t}function Sue(e,t,r){if(t===null)return"";if(typeof t!=="object")return String(t);if(X4.isNode(e)&&r?.doc){let i=bue.createStringifyContext(r.doc,{});i.anchors=new Set;for(let o of r.anchors.keys())i.anchors.add(o.anchor);i.inFlow=!0,i.inStringifyKey=!0;let n=e.toString(i);if(!r.mapKeyWarned){let o=JSON.stringify(n);if(o.length>40)o=o.substring(0,36)+'..."';yue.warn(r.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${o}. Set mapAsMap: true to use object keys.`),r.mapKeyWarned=!0}return n}return JSON.stringify(t)}wue.addPairToJSMap=xue});var Fo=ee(function(Iue){var eM=Jd(),_ue=J4(),kue=rA(),ay=Ge();function Eue(e,t,r){let i=eM.createNode(e,void 0,r),n=eM.createNode(t,void 0,r);return new cy(i,n)}class cy{constructor(e,t=null){Object.defineProperty(this,ay.NODE_TYPE,{value:ay.PAIR}),this.key=e,this.value=t}clone(e){let{key:t,value:r}=this;if(ay.isNode(t))t=t.clone(e);if(ay.isNode(r))r=r.clone(e);return new cy(t,r)}toJSON(e,t){let r=t?.mapAsMap?new Map:{};return kue.addPairToJSMap(t,r,this)}toString(e,t,r){return e?.doc?_ue.stringifyPair(this,e,t,r):JSON.stringify(this)}}Iue.Pair=cy;Iue.createPair=Eue});var nA=ee(function(Rue){var la=Ge(),tM=Qd(),ly=Vd();function Cue(e,t,r){return(t.inFlow??e.flow?Oue:$ue)(e,t,r)}function $ue({comment:e,items:t},r,{blockItemPrefix:i,flowChars:n,itemIndent:o,onChompKeep:s,onComment:a}){let{indent:c,options:{commentString:l}}=r,u=Object.assign({},r,{indent:o,type:null}),d=!1,p=[];for(let y=0;y<t.length;++y){let g=t[y],b=null;if(la.isNode(g)){if(!d&&g.spaceBefore)p.push("");if(uy(r,p,g.commentBefore,d),g.comment)b=g.comment}else if(la.isPair(g)){let A=la.isNode(g.key)?g.key:null;if(A){if(!d&&A.spaceBefore)p.push("");uy(r,p,A.commentBefore,d)}}d=!1;let v=tM.stringify(g,u,()=>b=null,()=>d=!0);if(b)v+=ly.lineComment(v,o,l(b));if(d&&b)d=!1;p.push(i+v)}let m;if(p.length===0)m=n.start+n.end;else{m=p[0];for(let y=1;y<p.length;++y){let g=p[y];m+=g?`
357
356
  ${c}${g}`:`
358
357
  `}}if(e){if(m+=`
359
- `+ly.indentComment(l(e),c),a)a()}else if(d&&s)s();return m}function Rue({items:e},t,{flowChars:r,itemIndent:i}){let{indent:n,indentStep:o,flowCollectionPadding:s,options:{commentString:a}}=t;i+=o;let c=Object.assign({},t,{indent:i,inFlow:!0,type:null}),l=!1,u=0,d=[];for(let y=0;y<e.length;++y){let g=e[y],b=null;if(la.isNode(g)){if(g.spaceBefore)d.push("");if(uy(t,d,g.commentBefore,!1),g.comment)b=g.comment}else if(la.isPair(g)){let A=la.isNode(g.key)?g.key:null;if(A){if(A.spaceBefore)d.push("");if(uy(t,d,A.commentBefore,!1),A.comment)l=!0}let T=la.isNode(g.value)?g.value:null;if(T){if(T.comment)b=T.comment;if(T.commentBefore)l=!0}else if(g.value==null&&A?.comment)b=A.comment}if(b)l=!0;let v=tM.stringify(g,c,()=>b=null);if(l||(l=d.length>u||v.includes(`
358
+ `+ly.indentComment(l(e),c),a)a()}else if(d&&s)s();return m}function Oue({items:e},t,{flowChars:r,itemIndent:i}){let{indent:n,indentStep:o,flowCollectionPadding:s,options:{commentString:a}}=t;i+=o;let c=Object.assign({},t,{indent:i,inFlow:!0,type:null}),l=!1,u=0,d=[];for(let y=0;y<e.length;++y){let g=e[y],b=null;if(la.isNode(g)){if(g.spaceBefore)d.push("");if(uy(t,d,g.commentBefore,!1),g.comment)b=g.comment}else if(la.isPair(g)){let A=la.isNode(g.key)?g.key:null;if(A){if(A.spaceBefore)d.push("");if(uy(t,d,A.commentBefore,!1),A.comment)l=!0}let T=la.isNode(g.value)?g.value:null;if(T){if(T.comment)b=T.comment;if(T.commentBefore)l=!0}else if(g.value==null&&A?.comment)b=A.comment}if(b)l=!0;let v=tM.stringify(g,c,()=>b=null);if(l||(l=d.length>u||v.includes(`
360
359
  `)),y<e.length-1)v+=",";else if(t.options.trailingComma){if(t.options.lineWidth>0)l||(l=d.reduce((A,T)=>A+T.length+2,2)+(v.length+2)>t.options.lineWidth);if(l)v+=","}if(b)v+=ly.lineComment(v,i,a(b));d.push(v),u=d.length}let{start:p,end:m}=r;if(d.length===0)return p+m;else{if(!l){let y=d.reduce((g,b)=>g+b.length+2,2);l=t.options.lineWidth>0&&y>t.options.lineWidth}if(l){let y=p;for(let g of d)y+=g?`
361
360
  ${o}${n}${g}`:`
362
361
  `;return`${y}
363
- ${n}${m}`}else return`${p}${s}${d.join(" ")}${s}${m}`}}function uy({indent:e,options:{commentString:t}},r,i,n){if(i&&n)i=i.replace(/^\n+/,"");if(i){let o=ly.indentComment(t(i),e);r.push(o.trimStart())}}Pue.stringifyCollection=$ue});var Ho=ee(function(jue){var Nue=nA(),Due=rA(),Lue=Xg(),Zo=Ge(),dy=Fo(),Bue=jt();function Xd(e,t){let r=Zo.isScalar(t)?t.value:t;for(let i of e)if(Zo.isPair(i)){if(i.key===t||i.key===r)return i;if(Zo.isScalar(i.key)&&i.key.value===r)return i}return}class rM extends Lue.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(Zo.MAP,e);this.items=[]}static from(e,t,r){let{keepUndefined:i,replacer:n}=r,o=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||i)o.items.push(dy.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")o.items.sort(e.sortMapEntries);return o}add(e,t){let r;if(Zo.isPair(e))r=e;else if(!e||typeof e!=="object"||!("key"in e))r=new dy.Pair(e,e?.value);else r=new dy.Pair(e.key,e.value);let i=Xd(this.items,r.key),n=this.schema?.sortMapEntries;if(i){if(!t)throw Error(`Key ${r.key} already set`);if(Zo.isScalar(i.value)&&Bue.isScalarValue(r.value))i.value.value=r.value;else i.value=r.value}else if(n){let o=this.items.findIndex((s)=>n(r,s)<0);if(o===-1)this.items.push(r);else this.items.splice(o,0,r)}else this.items.push(r)}delete(e){let t=Xd(this.items,e);if(!t)return!1;return this.items.splice(this.items.indexOf(t),1).length>0}get(e,t){let i=Xd(this.items,e)?.value;return(!t&&Zo.isScalar(i)?i.value:i)??void 0}has(e){return!!Xd(this.items,e)}set(e,t){this.add(new dy.Pair(e,t),!0)}toJSON(e,t,r){let i=r?new r:t?.mapAsMap?new Map:{};if(t?.onCreate)t.onCreate(i);for(let n of this.items)Due.addPairToJSMap(t,i,n);return i}toString(e,t,r){if(!e)return JSON.stringify(this);for(let i of this.items)if(!Zo.isPair(i))throw Error(`Map items must all be pairs; found ${JSON.stringify(i)} instead`);if(!e.allNullValues&&this.hasAllNullValues(!1))e=Object.assign({},e,{allNullValues:!0});return Nue.stringifyCollection(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:r,onComment:t})}}jue.YAMLMap=rM;jue.findPair=Xd});var dl=ee(function(Zue){var Mue=Ge(),nM=Ho(),Fue={collection:"map",default:!0,nodeClass:nM.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(e,t){if(!Mue.isMap(e))t("Expected a mapping for this tag");return e},createNode:(e,t,r)=>nM.YAMLMap.from(e,t,r)};Zue.map=Fue});var Ko=ee(function(Que){var Kue=Jd(),Jue=nA(),Vue=Xg(),py=Ge(),Wue=jt(),Gue=qo();class iM extends Vue.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(py.SEQ,e);this.items=[]}add(e){this.items.push(e)}delete(e){let t=fy(e);if(typeof t!=="number")return!1;return this.items.splice(t,1).length>0}get(e,t){let r=fy(e);if(typeof r!=="number")return;let i=this.items[r];return!t&&py.isScalar(i)?i.value:i}has(e){let t=fy(e);return typeof t==="number"&&t<this.items.length}set(e,t){let r=fy(e);if(typeof r!=="number")throw Error(`Expected a valid index, not ${e}.`);let i=this.items[r];if(py.isScalar(i)&&Wue.isScalarValue(t))i.value=t;else this.items[r]=t}toJSON(e,t){let r=[];if(t?.onCreate)t.onCreate(r);let i=0;for(let n of this.items)r.push(Gue.toJS(n,String(i++),t));return r}toString(e,t,r){if(!e)return JSON.stringify(this);return Jue.stringifyCollection(this,e,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(e.indent||"")+" ",onChompKeep:r,onComment:t})}static from(e,t,r){let{replacer:i}=r,n=new this(e);if(t&&Symbol.iterator in Object(t)){let o=0;for(let s of t){if(typeof i==="function"){let a=t instanceof Set?s:String(o++);s=i.call(t,a,s)}n.items.push(Kue.createNode(s,void 0,r))}}return n}}function fy(e){let t=py.isScalar(e)?e.value:e;if(t&&typeof t==="string")t=Number(t);return typeof t==="number"&&Number.isInteger(t)&&t>=0?t:null}Que.YAMLSeq=iM});var fl=ee(function(tde){var Xue=Ge(),oM=Ko(),ede={collection:"seq",default:!0,nodeClass:oM.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(e,t){if(!Xue.isSeq(e))t("Expected a sequence for this tag");return e},createNode:(e,t,r)=>oM.YAMLSeq.from(e,t,r)};tde.seq=ede});var ef=ee(function(ode){var nde=Gd(),ide={identify:(e)=>typeof e==="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:(e)=>e,stringify(e,t,r,i){return t=Object.assign({actualString:!0},t),nde.stringifyString(e,t,r,i)}};ode.string=ide});var my=ee(function(ade){var sM=jt(),aM={identify:(e)=>e==null,createNode:()=>new sM.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new sM.Scalar(null),stringify:({source:e},t)=>typeof e==="string"&&aM.test.test(e)?e:t.options.nullStr};ade.nullTag=aM});var iA=ee(function(ude){var lde=jt(),cM={identify:(e)=>typeof e==="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:(e)=>new lde.Scalar(e[0]==="t"||e[0]==="T"),stringify({source:e,value:t},r){if(e&&cM.test.test(e)){let i=e[0]==="t"||e[0]==="T";if(t===i)return e}return t?r.options.trueStr:r.options.falseStr}};ude.boolTag=cM});var pl=ee(function(pde){function fde({format:e,minFractionDigits:t,tag:r,value:i}){if(typeof i==="bigint")return String(i);let n=typeof i==="number"?i:Number(i);if(!isFinite(n))return isNaN(n)?".nan":n<0?"-.inf":".inf";let o=Object.is(i,-0)?"-0":JSON.stringify(i);if(!e&&t&&(!r||r==="tag:yaml.org,2002:float")&&/^-?\d/.test(o)&&!o.includes("e")){let s=o.indexOf(".");if(s<0)s=o.length,o+=".";let a=t-(o.length-s-1);while(a-- >0)o+="0"}return o}pde.stringifyNumber=fde});var sA=ee(function(xde){var hde=jt(),oA=pl(),gde={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:oA.stringifyNumber},yde={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():oA.stringifyNumber(e)}},bde={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 hde.Scalar(parseFloat(e)),r=e.indexOf(".");if(r!==-1&&e[e.length-1]==="0")t.minFractionDigits=e.length-r-1;return t},stringify:oA.stringifyNumber};xde.float=bde;xde.floatExp=yde;xde.floatNaN=gde});var cA=ee(function(Ide){var lM=pl(),hy=(e)=>typeof e==="bigint"||Number.isInteger(e),aA=(e,t,r,{intAsBigInt:i})=>i?BigInt(e):parseInt(e.substring(t),r);function uM(e,t,r){let{value:i}=e;if(hy(i)&&i>=0)return r+i.toString(t);return lM.stringifyNumber(e)}var _de={identify:(e)=>hy(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(e,t,r)=>aA(e,2,8,r),stringify:(e)=>uM(e,8,"0o")},kde={identify:hy,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(e,t,r)=>aA(e,0,10,r),stringify:lM.stringifyNumber},Ede={identify:(e)=>hy(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(e,t,r)=>aA(e,2,16,r),stringify:(e)=>uM(e,16,"0x")};Ide.int=kde;Ide.intHex=Ede;Ide.intOct=_de});var dM=ee(function(Dde){var $de=dl(),Ode=my(),Rde=fl(),Pde=ef(),zde=iA(),lA=sA(),uA=cA(),Nde=[$de.map,Rde.seq,Pde.string,Ode.nullTag,zde.boolTag,uA.intOct,uA.int,uA.intHex,lA.floatNaN,lA.floatExp,lA.float];Dde.schema=Nde});var pM=ee(function(Zde){var Bde=jt(),jde=dl(),qde=fl();function fM(e){return typeof e==="bigint"||Number.isInteger(e)}var gy=({value:e})=>JSON.stringify(e),Ude=[{identify:(e)=>typeof e==="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:(e)=>e,stringify:gy},{identify:(e)=>e==null,createNode:()=>new Bde.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:gy},{identify:(e)=>typeof e==="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:(e)=>e==="true",stringify:gy},{identify:fM,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})=>fM(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:gy}],Mde={default:!0,tag:"",test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}},Fde=[jde.map,qde.seq].concat(Ude,Mde);Zde.schema=Fde});var fA=ee(function(Vde){var tf=Tt("buffer"),dA=jt(),Kde=Gd(),Jde={identify:(e)=>e instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(e,t){if(typeof tf.Buffer==="function")return tf.Buffer.from(e,"base64");else if(typeof atob==="function"){let r=atob(e.replace(/[\n\r]/g,"")),i=new Uint8Array(r.length);for(let n=0;n<r.length;++n)i[n]=r.charCodeAt(n);return i}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},i,n,o){if(!r)return"";let s=r,a;if(typeof tf.Buffer==="function")a=s instanceof tf.Buffer?s.toString("base64"):tf.Buffer.from(s.buffer).toString("base64");else if(typeof btoa==="function"){let c="";for(let l=0;l<s.length;++l)c+=String.fromCharCode(s[l]);a=btoa(c)}else throw Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(t??(t=dA.Scalar.BLOCK_LITERAL),t!==dA.Scalar.QUOTE_DOUBLE){let c=Math.max(i.options.lineWidth-i.indent.length,i.options.minContentWidth),l=Math.ceil(a.length/c),u=Array(l);for(let d=0,p=0;d<l;++d,p+=c)u[d]=a.substr(p,c);a=u.join(t===dA.Scalar.BLOCK_LITERAL?`
364
- `:" ")}return Kde.stringifyString({comment:e,type:t,value:a},i,n,o)}};Vde.binary=Jde});var by=ee(function(Xde){var yy=Ge(),pA=Fo(),Gde=jt(),Qde=Ko();function mM(e,t){if(yy.isSeq(e))for(let r=0;r<e.items.length;++r){let i=e.items[r];if(yy.isPair(i))continue;else if(yy.isMap(i)){if(i.items.length>1)t("Each pair must have its own sequence indicator");let n=i.items[0]||new pA.Pair(new Gde.Scalar(null));if(i.commentBefore)n.key.commentBefore=n.key.commentBefore?`${i.commentBefore}
362
+ ${n}${m}`}else return`${p}${s}${d.join(" ")}${s}${m}`}}function uy({indent:e,options:{commentString:t}},r,i,n){if(i&&n)i=i.replace(/^\n+/,"");if(i){let o=ly.indentComment(t(i),e);r.push(o.trimStart())}}Rue.stringifyCollection=Cue});var Ho=ee(function(Bue){var zue=nA(),Nue=rA(),Due=Xg(),Zo=Ge(),dy=Fo(),Lue=jt();function Xd(e,t){let r=Zo.isScalar(t)?t.value:t;for(let i of e)if(Zo.isPair(i)){if(i.key===t||i.key===r)return i;if(Zo.isScalar(i.key)&&i.key.value===r)return i}return}class rM extends Due.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(Zo.MAP,e);this.items=[]}static from(e,t,r){let{keepUndefined:i,replacer:n}=r,o=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||i)o.items.push(dy.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")o.items.sort(e.sortMapEntries);return o}add(e,t){let r;if(Zo.isPair(e))r=e;else if(!e||typeof e!=="object"||!("key"in e))r=new dy.Pair(e,e?.value);else r=new dy.Pair(e.key,e.value);let i=Xd(this.items,r.key),n=this.schema?.sortMapEntries;if(i){if(!t)throw Error(`Key ${r.key} already set`);if(Zo.isScalar(i.value)&&Lue.isScalarValue(r.value))i.value.value=r.value;else i.value=r.value}else if(n){let o=this.items.findIndex((s)=>n(r,s)<0);if(o===-1)this.items.push(r);else this.items.splice(o,0,r)}else this.items.push(r)}delete(e){let t=Xd(this.items,e);if(!t)return!1;return this.items.splice(this.items.indexOf(t),1).length>0}get(e,t){let i=Xd(this.items,e)?.value;return(!t&&Zo.isScalar(i)?i.value:i)??void 0}has(e){return!!Xd(this.items,e)}set(e,t){this.add(new dy.Pair(e,t),!0)}toJSON(e,t,r){let i=r?new r:t?.mapAsMap?new Map:{};if(t?.onCreate)t.onCreate(i);for(let n of this.items)Nue.addPairToJSMap(t,i,n);return i}toString(e,t,r){if(!e)return JSON.stringify(this);for(let i of this.items)if(!Zo.isPair(i))throw Error(`Map items must all be pairs; found ${JSON.stringify(i)} instead`);if(!e.allNullValues&&this.hasAllNullValues(!1))e=Object.assign({},e,{allNullValues:!0});return zue.stringifyCollection(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:r,onComment:t})}}Bue.YAMLMap=rM;Bue.findPair=Xd});var dl=ee(function(Fue){var Uue=Ge(),nM=Ho(),Mue={collection:"map",default:!0,nodeClass:nM.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(e,t){if(!Uue.isMap(e))t("Expected a mapping for this tag");return e},createNode:(e,t,r)=>nM.YAMLMap.from(e,t,r)};Fue.map=Mue});var Ko=ee(function(Gue){var Hue=Jd(),Kue=nA(),Jue=Xg(),py=Ge(),Vue=jt(),Wue=qo();class iM extends Jue.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(py.SEQ,e);this.items=[]}add(e){this.items.push(e)}delete(e){let t=fy(e);if(typeof t!=="number")return!1;return this.items.splice(t,1).length>0}get(e,t){let r=fy(e);if(typeof r!=="number")return;let i=this.items[r];return!t&&py.isScalar(i)?i.value:i}has(e){let t=fy(e);return typeof t==="number"&&t<this.items.length}set(e,t){let r=fy(e);if(typeof r!=="number")throw Error(`Expected a valid index, not ${e}.`);let i=this.items[r];if(py.isScalar(i)&&Vue.isScalarValue(t))i.value=t;else this.items[r]=t}toJSON(e,t){let r=[];if(t?.onCreate)t.onCreate(r);let i=0;for(let n of this.items)r.push(Wue.toJS(n,String(i++),t));return r}toString(e,t,r){if(!e)return JSON.stringify(this);return Kue.stringifyCollection(this,e,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(e.indent||"")+" ",onChompKeep:r,onComment:t})}static from(e,t,r){let{replacer:i}=r,n=new this(e);if(t&&Symbol.iterator in Object(t)){let o=0;for(let s of t){if(typeof i==="function"){let a=t instanceof Set?s:String(o++);s=i.call(t,a,s)}n.items.push(Hue.createNode(s,void 0,r))}}return n}}function fy(e){let t=py.isScalar(e)?e.value:e;if(t&&typeof t==="string")t=Number(t);return typeof t==="number"&&Number.isInteger(t)&&t>=0?t:null}Gue.YAMLSeq=iM});var fl=ee(function(ede){var Yue=Ge(),oM=Ko(),Xue={collection:"seq",default:!0,nodeClass:oM.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(e,t){if(!Yue.isSeq(e))t("Expected a sequence for this tag");return e},createNode:(e,t,r)=>oM.YAMLSeq.from(e,t,r)};ede.seq=Xue});var ef=ee(function(ide){var rde=Gd(),nde={identify:(e)=>typeof e==="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:(e)=>e,stringify(e,t,r,i){return t=Object.assign({actualString:!0},t),rde.stringifyString(e,t,r,i)}};ide.string=nde});var my=ee(function(sde){var sM=jt(),aM={identify:(e)=>e==null,createNode:()=>new sM.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new sM.Scalar(null),stringify:({source:e},t)=>typeof e==="string"&&aM.test.test(e)?e:t.options.nullStr};sde.nullTag=aM});var iA=ee(function(lde){var cde=jt(),cM={identify:(e)=>typeof e==="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:(e)=>new cde.Scalar(e[0]==="t"||e[0]==="T"),stringify({source:e,value:t},r){if(e&&cM.test.test(e)){let i=e[0]==="t"||e[0]==="T";if(t===i)return e}return t?r.options.trueStr:r.options.falseStr}};lde.boolTag=cM});var pl=ee(function(fde){function dde({format:e,minFractionDigits:t,tag:r,value:i}){if(typeof i==="bigint")return String(i);let n=typeof i==="number"?i:Number(i);if(!isFinite(n))return isNaN(n)?".nan":n<0?"-.inf":".inf";let o=Object.is(i,-0)?"-0":JSON.stringify(i);if(!e&&t&&(!r||r==="tag:yaml.org,2002:float")&&/^-?\d/.test(o)&&!o.includes("e")){let s=o.indexOf(".");if(s<0)s=o.length,o+=".";let a=t-(o.length-s-1);while(a-- >0)o+="0"}return o}fde.stringifyNumber=dde});var sA=ee(function(bde){var mde=jt(),oA=pl(),hde={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:oA.stringifyNumber},gde={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():oA.stringifyNumber(e)}},yde={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 mde.Scalar(parseFloat(e)),r=e.indexOf(".");if(r!==-1&&e[e.length-1]==="0")t.minFractionDigits=e.length-r-1;return t},stringify:oA.stringifyNumber};bde.float=yde;bde.floatExp=gde;bde.floatNaN=hde});var cA=ee(function(Ede){var lM=pl(),hy=(e)=>typeof e==="bigint"||Number.isInteger(e),aA=(e,t,r,{intAsBigInt:i})=>i?BigInt(e):parseInt(e.substring(t),r);function uM(e,t,r){let{value:i}=e;if(hy(i)&&i>=0)return r+i.toString(t);return lM.stringifyNumber(e)}var vde={identify:(e)=>hy(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(e,t,r)=>aA(e,2,8,r),stringify:(e)=>uM(e,8,"0o")},_de={identify:hy,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(e,t,r)=>aA(e,0,10,r),stringify:lM.stringifyNumber},kde={identify:(e)=>hy(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(e,t,r)=>aA(e,2,16,r),stringify:(e)=>uM(e,16,"0x")};Ede.int=_de;Ede.intHex=kde;Ede.intOct=vde});var dM=ee(function(Nde){var Cde=dl(),$de=my(),Ode=fl(),Rde=ef(),Pde=iA(),lA=sA(),uA=cA(),zde=[Cde.map,Ode.seq,Rde.string,$de.nullTag,Pde.boolTag,uA.intOct,uA.int,uA.intHex,lA.floatNaN,lA.floatExp,lA.float];Nde.schema=zde});var pM=ee(function(Fde){var Lde=jt(),Bde=dl(),jde=fl();function fM(e){return typeof e==="bigint"||Number.isInteger(e)}var gy=({value:e})=>JSON.stringify(e),qde=[{identify:(e)=>typeof e==="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:(e)=>e,stringify:gy},{identify:(e)=>e==null,createNode:()=>new Lde.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:gy},{identify:(e)=>typeof e==="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:(e)=>e==="true",stringify:gy},{identify:fM,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})=>fM(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:gy}],Ude={default:!0,tag:"",test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}},Mde=[Bde.map,jde.seq].concat(qde,Ude);Fde.schema=Mde});var fA=ee(function(Jde){var tf=Tt("buffer"),dA=jt(),Hde=Gd(),Kde={identify:(e)=>e instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(e,t){if(typeof tf.Buffer==="function")return tf.Buffer.from(e,"base64");else if(typeof atob==="function"){let r=atob(e.replace(/[\n\r]/g,"")),i=new Uint8Array(r.length);for(let n=0;n<r.length;++n)i[n]=r.charCodeAt(n);return i}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},i,n,o){if(!r)return"";let s=r,a;if(typeof tf.Buffer==="function")a=s instanceof tf.Buffer?s.toString("base64"):tf.Buffer.from(s.buffer).toString("base64");else if(typeof btoa==="function"){let c="";for(let l=0;l<s.length;++l)c+=String.fromCharCode(s[l]);a=btoa(c)}else throw Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(t??(t=dA.Scalar.BLOCK_LITERAL),t!==dA.Scalar.QUOTE_DOUBLE){let c=Math.max(i.options.lineWidth-i.indent.length,i.options.minContentWidth),l=Math.ceil(a.length/c),u=Array(l);for(let d=0,p=0;d<l;++d,p+=c)u[d]=a.substr(p,c);a=u.join(t===dA.Scalar.BLOCK_LITERAL?`
363
+ `:" ")}return Hde.stringifyString({comment:e,type:t,value:a},i,n,o)}};Jde.binary=Kde});var by=ee(function(Yde){var yy=Ge(),pA=Fo(),Wde=jt(),Gde=Ko();function mM(e,t){if(yy.isSeq(e))for(let r=0;r<e.items.length;++r){let i=e.items[r];if(yy.isPair(i))continue;else if(yy.isMap(i)){if(i.items.length>1)t("Each pair must have its own sequence indicator");let n=i.items[0]||new pA.Pair(new Wde.Scalar(null));if(i.commentBefore)n.key.commentBefore=n.key.commentBefore?`${i.commentBefore}
365
364
  ${n.key.commentBefore}`:i.commentBefore;if(i.comment){let o=n.value??n.key;o.comment=o.comment?`${i.comment}
366
- ${o.comment}`:i.comment}i=n}e.items[r]=yy.isPair(i)?i:new pA.Pair(i)}else t("Expected a sequence for this tag");return e}function hM(e,t,r){let{replacer:i}=r,n=new Qde.YAMLSeq(e);n.tag="tag:yaml.org,2002:pairs";let o=0;if(t&&Symbol.iterator in Object(t))for(let s of t){if(typeof i==="function")s=i.call(t,String(o++),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 l=Object.keys(s);if(l.length===1)a=l[0],c=s[a];else throw TypeError(`Expected tuple with one key, not ${l.length} keys`)}else a=s;n.items.push(pA.createPair(a,c,r))}return n}var Yde={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:mM,createNode:hM};Xde.createPairs=hM;Xde.pairs=Yde;Xde.resolvePairs=mM});var hA=ee(function(ofe){var gM=Ge(),mA=qo(),rf=Ho(),nfe=Ko(),yM=by();class ua extends nfe.YAMLSeq{constructor(){super();this.add=rf.YAMLMap.prototype.add.bind(this),this.delete=rf.YAMLMap.prototype.delete.bind(this),this.get=rf.YAMLMap.prototype.get.bind(this),this.has=rf.YAMLMap.prototype.has.bind(this),this.set=rf.YAMLMap.prototype.set.bind(this),this.tag=ua.tag}toJSON(e,t){if(!t)return super.toJSON(e);let r=new Map;if(t?.onCreate)t.onCreate(r);for(let i of this.items){let n,o;if(gM.isPair(i))n=mA.toJS(i.key,"",t),o=mA.toJS(i.value,n,t);else n=mA.toJS(i,"",t);if(r.has(n))throw Error("Ordered maps must not include duplicate keys");r.set(n,o)}return r}static from(e,t,r){let i=yM.createPairs(e,t,r),n=new this;return n.items=i.items,n}}ua.tag="tag:yaml.org,2002:omap";var ife={collection:"seq",identify:(e)=>e instanceof Map,nodeClass:ua,default:!1,tag:"tag:yaml.org,2002:omap",resolve(e,t){let r=yM.resolvePairs(e,t),i=[];for(let{key:n}of r.items)if(gM.isScalar(n))if(i.includes(n.value))t(`Ordered maps must not include duplicate keys: ${n.value}`);else i.push(n.value);return Object.assign(new ua,r)},createNode:(e,t,r)=>ua.from(e,t,r)};ofe.YAMLOMap=ua;ofe.omap=ife});var vM=ee(function(cfe){var bM=jt();function xM({value:e,source:t},r){if(t&&(e?SM:wM).test.test(t))return t;return e?r.options.trueStr:r.options.falseStr}var SM={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 bM.Scalar(!0),stringify:xM},wM={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 bM.Scalar(!1),stringify:xM};cfe.falseTag=wM;cfe.trueTag=SM});var _M=ee(function(hfe){var dfe=jt(),gA=pl(),ffe={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:gA.stringifyNumber},pfe={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():gA.stringifyNumber(e)}},mfe={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 dfe.Scalar(parseFloat(e.replace(/_/g,""))),r=e.indexOf(".");if(r!==-1){let i=e.substring(r+1).replace(/_/g,"");if(i[i.length-1]==="0")t.minFractionDigits=i.length}return t},stringify:gA.stringifyNumber};hfe.float=mfe;hfe.floatExp=pfe;hfe.floatNaN=ffe});var EM=ee(function(_fe){var kM=pl(),nf=(e)=>typeof e==="bigint"||Number.isInteger(e);function xy(e,t,r,{intAsBigInt:i}){let n=e[0];if(n==="-"||n==="+")t+=1;if(e=e.substring(t).replace(/_/g,""),i){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 o=parseInt(e,r);return n==="-"?-1*o:o}function yA(e,t,r){let{value:i}=e;if(nf(i)){let n=i.toString(t);return i<0?"-"+r+n.substr(1):r+n}return kM.stringifyNumber(e)}var xfe={identify:nf,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,r)=>xy(e,2,2,r),stringify:(e)=>yA(e,2,"0b")},Sfe={identify:nf,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(e,t,r)=>xy(e,1,8,r),stringify:(e)=>yA(e,8,"0")},wfe={identify:nf,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,r)=>xy(e,0,10,r),stringify:kM.stringifyNumber},vfe={identify:nf,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,r)=>xy(e,2,16,r),stringify:(e)=>yA(e,16,"0x")};_fe.int=wfe;_fe.intBin=xfe;_fe.intHex=vfe;_fe.intOct=Sfe});var bA=ee(function(Cfe){var vy=Ge(),Sy=Fo(),wy=Ho();class da extends wy.YAMLMap{constructor(e){super(e);this.tag=da.tag}add(e){let t;if(vy.isPair(e))t=e;else if(e&&typeof e==="object"&&"key"in e&&"value"in e&&e.value===null)t=new Sy.Pair(e.key,null);else t=new Sy.Pair(e,null);if(!wy.findPair(this.items,t.key))this.items.push(t)}get(e,t){let r=wy.findPair(this.items,e);return!t&&vy.isPair(r)?vy.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=wy.findPair(this.items,e);if(r&&!t)this.items.splice(this.items.indexOf(r),1);else if(!r&&t)this.items.push(new Sy.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:i}=r,n=new this(e);if(t&&Symbol.iterator in Object(t))for(let o of t){if(typeof i==="function")o=i.call(t,o,o);n.items.push(Sy.createPair(o,null,r))}return n}}da.tag="tag:yaml.org,2002:set";var Tfe={collection:"map",identify:(e)=>e instanceof Set,nodeClass:da,default:!1,tag:"tag:yaml.org,2002:set",createNode:(e,t,r)=>da.from(e,t,r),resolve(e,t){if(vy.isMap(e))if(e.hasAllNullValues(!0))return Object.assign(new da,e);else t("Set items must all have null values");else t("Expected a mapping for this tag");return e}};Cfe.YAMLSet=da;Cfe.set=Tfe});var SA=ee(function(Nfe){var Rfe=pl();function xA(e,t){let r=e[0],i=r==="-"||r==="+"?e.substring(1):e,n=(s)=>t?BigInt(s):Number(s),o=i.replace(/_/g,"").split(":").reduce((s,a)=>s*n(60)+n(a),n(0));return r==="-"?n(-1)*o:o}function IM(e){let{value:t}=e,r=(s)=>s;if(typeof t==="bigint")r=(s)=>BigInt(s);else if(isNaN(t)||!isFinite(t))return Rfe.stringifyNumber(e);let i="";if(t<0)i="-",t*=r(-1);let n=r(60),o=[t%n];if(t<60)o.unshift(0);else if(t=(t-o[0])/n,o.unshift(t%n),t>=60)t=(t-o[0])/n,o.unshift(t);return i+o.map((s)=>String(s).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var Pfe={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})=>xA(e,r),stringify:IM},zfe={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)=>xA(e,!1),stringify:IM},AM={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(AM.test);if(!t)throw Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,r,i,n,o,s,a]=t.map(Number),c=t[7]?Number((t[7]+"00").substr(1,3)):0,l=Date.UTC(r,i-1,n,o||0,s||0,a||0,c),u=t[8];if(u&&u!=="Z"){let d=xA(u,!1);if(Math.abs(d)<30)d*=60;l-=60000*d}return new Date(l)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};Nfe.floatTime=zfe;Nfe.intTime=Pfe;Nfe.timestamp=AM});var CM=ee(function(Wfe){var jfe=dl(),qfe=my(),Ufe=fl(),Mfe=ef(),Ffe=fA(),TM=vM(),wA=_M(),_y=EM(),Zfe=sy(),Hfe=hA(),Kfe=by(),Jfe=bA(),vA=SA(),Vfe=[jfe.map,Ufe.seq,Mfe.string,qfe.nullTag,TM.trueTag,TM.falseTag,_y.intBin,_y.intOct,_y.int,_y.intHex,wA.floatNaN,wA.floatExp,wA.float,Ffe.binary,Zfe.merge,Hfe.omap,Kfe.pairs,Jfe.set,vA.intTime,vA.floatTime,vA.timestamp];Wfe.schema=Vfe});var jM=ee(function(ipe){var PM=dl(),Qfe=my(),zM=fl(),Yfe=ef(),Xfe=iA(),_A=sA(),kA=cA(),epe=dM(),tpe=pM(),NM=fA(),of=sy(),DM=hA(),LM=by(),$M=CM(),BM=bA(),ky=SA(),OM=new Map([["core",epe.schema],["failsafe",[PM.map,zM.seq,Yfe.string]],["json",tpe.schema],["yaml11",$M.schema],["yaml-1.1",$M.schema]]),RM={binary:NM.binary,bool:Xfe.boolTag,float:_A.float,floatExp:_A.floatExp,floatNaN:_A.floatNaN,floatTime:ky.floatTime,int:kA.int,intHex:kA.intHex,intOct:kA.intOct,intTime:ky.intTime,map:PM.map,merge:of.merge,null:Qfe.nullTag,omap:DM.omap,pairs:LM.pairs,seq:zM.seq,set:BM.set,timestamp:ky.timestamp},rpe={"tag:yaml.org,2002:binary":NM.binary,"tag:yaml.org,2002:merge":of.merge,"tag:yaml.org,2002:omap":DM.omap,"tag:yaml.org,2002:pairs":LM.pairs,"tag:yaml.org,2002:set":BM.set,"tag:yaml.org,2002:timestamp":ky.timestamp};function npe(e,t,r){let i=OM.get(t);if(i&&!e)return r&&!i.includes(of.merge)?i.concat(of.merge):i.slice();let n=i;if(!n)if(Array.isArray(e))n=[];else{let o=Array.from(OM.keys()).filter((s)=>s!=="yaml11").map((s)=>JSON.stringify(s)).join(", ");throw Error(`Unknown schema "${t}"; use one of ${o} or define customTags array`)}if(Array.isArray(e))for(let o of e)n=n.concat(o);else if(typeof e==="function")n=e(n.slice());if(r)n=n.concat(of.merge);return n.reduce((o,s)=>{let a=typeof s==="string"?RM[s]:s;if(!a){let c=JSON.stringify(s),l=Object.keys(RM).map((u)=>JSON.stringify(u)).join(", ");throw Error(`Unknown custom tag ${c}; use one of ${l}`)}if(!o.includes(a))o.push(a);return o},[])}ipe.coreKnownTags=rpe;ipe.getTags=npe});var AA=ee(function(dpe){var EA=Ge(),ape=dl(),cpe=fl(),lpe=ef(),Ey=jM(),upe=(e,t)=>e.key<t.key?-1:e.key>t.key?1:0;class IA{constructor({compat:e,customTags:t,merge:r,resolveKnownTags:i,schema:n,sortMapEntries:o,toStringDefaults:s}){this.compat=Array.isArray(e)?Ey.getTags(e,"compat"):e?Ey.getTags(null,e):null,this.name=typeof n==="string"&&n||"core",this.knownTags=i?Ey.coreKnownTags:{},this.tags=Ey.getTags(t,this.name,r),this.toStringOptions=s??null,Object.defineProperty(this,EA.MAP,{value:ape.map}),Object.defineProperty(this,EA.SCALAR,{value:lpe.string}),Object.defineProperty(this,EA.SEQ,{value:cpe.seq}),this.sortMapEntries=typeof o==="function"?o:o===!0?upe:null}clone(){let e=Object.create(IA.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}}dpe.Schema=IA});var qM=ee(function(hpe){var ppe=Ge(),TA=Qd(),sf=Vd();function mpe(e,t){let r=[],i=t.directives===!0;if(t.directives!==!1&&e.directives){let c=e.directives.toString(e);if(c)r.push(c),i=!0;else if(e.directives.docStart)i=!0}if(i)r.push("---");let n=TA.createStringifyContext(e,t),{commentString:o}=n.options;if(e.commentBefore){if(r.length!==1)r.unshift("");let c=o(e.commentBefore);r.unshift(sf.indentComment(c,""))}let s=!1,a=null;if(e.contents){if(ppe.isNode(e.contents)){if(e.contents.spaceBefore&&i)r.push("");if(e.contents.commentBefore){let u=o(e.contents.commentBefore);r.push(sf.indentComment(u,""))}n.forceBlockIndent=!!e.comment,a=e.contents.comment}let c=a?void 0:()=>s=!0,l=TA.stringify(e.contents,n,()=>a=null,c);if(a)l+=sf.lineComment(l,"",o(a));if((l[0]==="|"||l[0]===">")&&r[r.length-1]==="---")r[r.length-1]=`--- ${l}`;else r.push(l)}else r.push(TA.stringify(e.contents,n));if(e.directives?.docEnd)if(e.comment){let c=o(e.comment);if(c.includes(`
365
+ ${o.comment}`:i.comment}i=n}e.items[r]=yy.isPair(i)?i:new pA.Pair(i)}else t("Expected a sequence for this tag");return e}function hM(e,t,r){let{replacer:i}=r,n=new Gde.YAMLSeq(e);n.tag="tag:yaml.org,2002:pairs";let o=0;if(t&&Symbol.iterator in Object(t))for(let s of t){if(typeof i==="function")s=i.call(t,String(o++),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 l=Object.keys(s);if(l.length===1)a=l[0],c=s[a];else throw TypeError(`Expected tuple with one key, not ${l.length} keys`)}else a=s;n.items.push(pA.createPair(a,c,r))}return n}var Qde={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:mM,createNode:hM};Yde.createPairs=hM;Yde.pairs=Qde;Yde.resolvePairs=mM});var hA=ee(function(ife){var gM=Ge(),mA=qo(),rf=Ho(),rfe=Ko(),yM=by();class ua extends rfe.YAMLSeq{constructor(){super();this.add=rf.YAMLMap.prototype.add.bind(this),this.delete=rf.YAMLMap.prototype.delete.bind(this),this.get=rf.YAMLMap.prototype.get.bind(this),this.has=rf.YAMLMap.prototype.has.bind(this),this.set=rf.YAMLMap.prototype.set.bind(this),this.tag=ua.tag}toJSON(e,t){if(!t)return super.toJSON(e);let r=new Map;if(t?.onCreate)t.onCreate(r);for(let i of this.items){let n,o;if(gM.isPair(i))n=mA.toJS(i.key,"",t),o=mA.toJS(i.value,n,t);else n=mA.toJS(i,"",t);if(r.has(n))throw Error("Ordered maps must not include duplicate keys");r.set(n,o)}return r}static from(e,t,r){let i=yM.createPairs(e,t,r),n=new this;return n.items=i.items,n}}ua.tag="tag:yaml.org,2002:omap";var nfe={collection:"seq",identify:(e)=>e instanceof Map,nodeClass:ua,default:!1,tag:"tag:yaml.org,2002:omap",resolve(e,t){let r=yM.resolvePairs(e,t),i=[];for(let{key:n}of r.items)if(gM.isScalar(n))if(i.includes(n.value))t(`Ordered maps must not include duplicate keys: ${n.value}`);else i.push(n.value);return Object.assign(new ua,r)},createNode:(e,t,r)=>ua.from(e,t,r)};ife.YAMLOMap=ua;ife.omap=nfe});var vM=ee(function(afe){var bM=jt();function xM({value:e,source:t},r){if(t&&(e?SM:wM).test.test(t))return t;return e?r.options.trueStr:r.options.falseStr}var SM={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 bM.Scalar(!0),stringify:xM},wM={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 bM.Scalar(!1),stringify:xM};afe.falseTag=wM;afe.trueTag=SM});var _M=ee(function(mfe){var ufe=jt(),gA=pl(),dfe={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:gA.stringifyNumber},ffe={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():gA.stringifyNumber(e)}},pfe={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 ufe.Scalar(parseFloat(e.replace(/_/g,""))),r=e.indexOf(".");if(r!==-1){let i=e.substring(r+1).replace(/_/g,"");if(i[i.length-1]==="0")t.minFractionDigits=i.length}return t},stringify:gA.stringifyNumber};mfe.float=pfe;mfe.floatExp=ffe;mfe.floatNaN=dfe});var EM=ee(function(vfe){var kM=pl(),nf=(e)=>typeof e==="bigint"||Number.isInteger(e);function xy(e,t,r,{intAsBigInt:i}){let n=e[0];if(n==="-"||n==="+")t+=1;if(e=e.substring(t).replace(/_/g,""),i){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 o=parseInt(e,r);return n==="-"?-1*o:o}function yA(e,t,r){let{value:i}=e;if(nf(i)){let n=i.toString(t);return i<0?"-"+r+n.substr(1):r+n}return kM.stringifyNumber(e)}var bfe={identify:nf,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,r)=>xy(e,2,2,r),stringify:(e)=>yA(e,2,"0b")},xfe={identify:nf,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(e,t,r)=>xy(e,1,8,r),stringify:(e)=>yA(e,8,"0")},Sfe={identify:nf,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,r)=>xy(e,0,10,r),stringify:kM.stringifyNumber},wfe={identify:nf,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,r)=>xy(e,2,16,r),stringify:(e)=>yA(e,16,"0x")};vfe.int=Sfe;vfe.intBin=bfe;vfe.intHex=wfe;vfe.intOct=xfe});var bA=ee(function(Tfe){var vy=Ge(),Sy=Fo(),wy=Ho();class da extends wy.YAMLMap{constructor(e){super(e);this.tag=da.tag}add(e){let t;if(vy.isPair(e))t=e;else if(e&&typeof e==="object"&&"key"in e&&"value"in e&&e.value===null)t=new Sy.Pair(e.key,null);else t=new Sy.Pair(e,null);if(!wy.findPair(this.items,t.key))this.items.push(t)}get(e,t){let r=wy.findPair(this.items,e);return!t&&vy.isPair(r)?vy.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=wy.findPair(this.items,e);if(r&&!t)this.items.splice(this.items.indexOf(r),1);else if(!r&&t)this.items.push(new Sy.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:i}=r,n=new this(e);if(t&&Symbol.iterator in Object(t))for(let o of t){if(typeof i==="function")o=i.call(t,o,o);n.items.push(Sy.createPair(o,null,r))}return n}}da.tag="tag:yaml.org,2002:set";var Afe={collection:"map",identify:(e)=>e instanceof Set,nodeClass:da,default:!1,tag:"tag:yaml.org,2002:set",createNode:(e,t,r)=>da.from(e,t,r),resolve(e,t){if(vy.isMap(e))if(e.hasAllNullValues(!0))return Object.assign(new da,e);else t("Set items must all have null values");else t("Expected a mapping for this tag");return e}};Tfe.YAMLSet=da;Tfe.set=Afe});var SA=ee(function(zfe){var Ofe=pl();function xA(e,t){let r=e[0],i=r==="-"||r==="+"?e.substring(1):e,n=(s)=>t?BigInt(s):Number(s),o=i.replace(/_/g,"").split(":").reduce((s,a)=>s*n(60)+n(a),n(0));return r==="-"?n(-1)*o:o}function IM(e){let{value:t}=e,r=(s)=>s;if(typeof t==="bigint")r=(s)=>BigInt(s);else if(isNaN(t)||!isFinite(t))return Ofe.stringifyNumber(e);let i="";if(t<0)i="-",t*=r(-1);let n=r(60),o=[t%n];if(t<60)o.unshift(0);else if(t=(t-o[0])/n,o.unshift(t%n),t>=60)t=(t-o[0])/n,o.unshift(t);return i+o.map((s)=>String(s).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var Rfe={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})=>xA(e,r),stringify:IM},Pfe={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)=>xA(e,!1),stringify:IM},AM={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(AM.test);if(!t)throw Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,r,i,n,o,s,a]=t.map(Number),c=t[7]?Number((t[7]+"00").substr(1,3)):0,l=Date.UTC(r,i-1,n,o||0,s||0,a||0,c),u=t[8];if(u&&u!=="Z"){let d=xA(u,!1);if(Math.abs(d)<30)d*=60;l-=60000*d}return new Date(l)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};zfe.floatTime=Pfe;zfe.intTime=Rfe;zfe.timestamp=AM});var CM=ee(function(Vfe){var Bfe=dl(),jfe=my(),qfe=fl(),Ufe=ef(),Mfe=fA(),TM=vM(),wA=_M(),_y=EM(),Ffe=sy(),Zfe=hA(),Hfe=by(),Kfe=bA(),vA=SA(),Jfe=[Bfe.map,qfe.seq,Ufe.string,jfe.nullTag,TM.trueTag,TM.falseTag,_y.intBin,_y.intOct,_y.int,_y.intHex,wA.floatNaN,wA.floatExp,wA.float,Mfe.binary,Ffe.merge,Zfe.omap,Hfe.pairs,Kfe.set,vA.intTime,vA.floatTime,vA.timestamp];Vfe.schema=Jfe});var jM=ee(function(npe){var PM=dl(),Gfe=my(),zM=fl(),Qfe=ef(),Yfe=iA(),_A=sA(),kA=cA(),Xfe=dM(),epe=pM(),NM=fA(),of=sy(),DM=hA(),LM=by(),$M=CM(),BM=bA(),ky=SA(),OM=new Map([["core",Xfe.schema],["failsafe",[PM.map,zM.seq,Qfe.string]],["json",epe.schema],["yaml11",$M.schema],["yaml-1.1",$M.schema]]),RM={binary:NM.binary,bool:Yfe.boolTag,float:_A.float,floatExp:_A.floatExp,floatNaN:_A.floatNaN,floatTime:ky.floatTime,int:kA.int,intHex:kA.intHex,intOct:kA.intOct,intTime:ky.intTime,map:PM.map,merge:of.merge,null:Gfe.nullTag,omap:DM.omap,pairs:LM.pairs,seq:zM.seq,set:BM.set,timestamp:ky.timestamp},tpe={"tag:yaml.org,2002:binary":NM.binary,"tag:yaml.org,2002:merge":of.merge,"tag:yaml.org,2002:omap":DM.omap,"tag:yaml.org,2002:pairs":LM.pairs,"tag:yaml.org,2002:set":BM.set,"tag:yaml.org,2002:timestamp":ky.timestamp};function rpe(e,t,r){let i=OM.get(t);if(i&&!e)return r&&!i.includes(of.merge)?i.concat(of.merge):i.slice();let n=i;if(!n)if(Array.isArray(e))n=[];else{let o=Array.from(OM.keys()).filter((s)=>s!=="yaml11").map((s)=>JSON.stringify(s)).join(", ");throw Error(`Unknown schema "${t}"; use one of ${o} or define customTags array`)}if(Array.isArray(e))for(let o of e)n=n.concat(o);else if(typeof e==="function")n=e(n.slice());if(r)n=n.concat(of.merge);return n.reduce((o,s)=>{let a=typeof s==="string"?RM[s]:s;if(!a){let c=JSON.stringify(s),l=Object.keys(RM).map((u)=>JSON.stringify(u)).join(", ");throw Error(`Unknown custom tag ${c}; use one of ${l}`)}if(!o.includes(a))o.push(a);return o},[])}npe.coreKnownTags=tpe;npe.getTags=rpe});var AA=ee(function(upe){var EA=Ge(),spe=dl(),ape=fl(),cpe=ef(),Ey=jM(),lpe=(e,t)=>e.key<t.key?-1:e.key>t.key?1:0;class IA{constructor({compat:e,customTags:t,merge:r,resolveKnownTags:i,schema:n,sortMapEntries:o,toStringDefaults:s}){this.compat=Array.isArray(e)?Ey.getTags(e,"compat"):e?Ey.getTags(null,e):null,this.name=typeof n==="string"&&n||"core",this.knownTags=i?Ey.coreKnownTags:{},this.tags=Ey.getTags(t,this.name,r),this.toStringOptions=s??null,Object.defineProperty(this,EA.MAP,{value:spe.map}),Object.defineProperty(this,EA.SCALAR,{value:cpe.string}),Object.defineProperty(this,EA.SEQ,{value:ape.seq}),this.sortMapEntries=typeof o==="function"?o:o===!0?lpe:null}clone(){let e=Object.create(IA.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}}upe.Schema=IA});var qM=ee(function(mpe){var fpe=Ge(),TA=Qd(),sf=Vd();function ppe(e,t){let r=[],i=t.directives===!0;if(t.directives!==!1&&e.directives){let c=e.directives.toString(e);if(c)r.push(c),i=!0;else if(e.directives.docStart)i=!0}if(i)r.push("---");let n=TA.createStringifyContext(e,t),{commentString:o}=n.options;if(e.commentBefore){if(r.length!==1)r.unshift("");let c=o(e.commentBefore);r.unshift(sf.indentComment(c,""))}let s=!1,a=null;if(e.contents){if(fpe.isNode(e.contents)){if(e.contents.spaceBefore&&i)r.push("");if(e.contents.commentBefore){let u=o(e.contents.commentBefore);r.push(sf.indentComment(u,""))}n.forceBlockIndent=!!e.comment,a=e.contents.comment}let c=a?void 0:()=>s=!0,l=TA.stringify(e.contents,n,()=>a=null,c);if(a)l+=sf.lineComment(l,"",o(a));if((l[0]==="|"||l[0]===">")&&r[r.length-1]==="---")r[r.length-1]=`--- ${l}`;else r.push(l)}else r.push(TA.stringify(e.contents,n));if(e.directives?.docEnd)if(e.comment){let c=o(e.comment);if(c.includes(`
367
366
  `))r.push("..."),r.push(sf.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(sf.indentComment(o(c),""))}}return r.join(`
368
367
  `)+`
369
- `}hpe.stringifyDocument=mpe});var af=ee(function(kpe){var ype=Kd(),ml=Xg(),Sn=Ge(),bpe=Fo(),xpe=qo(),Spe=AA(),wpe=qM(),CA=Gg(),vpe=VI(),_pe=Jd(),$A=JI();class OA{constructor(e,t,r){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,Sn.NODE_TYPE,{value:Sn.DOC});let i=null;if(typeof t==="function"||Array.isArray(t))i=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:o}=n;if(r?._directives){if(this.directives=r._directives.atDocument(),this.directives.yaml.explicit)o=this.directives.yaml.version}else this.directives=new $A.Directives({version:o});this.setSchema(o,r),this.contents=e===void 0?null:this.createNode(e,i,r)}clone(){let e=Object.create(OA.prototype,{[Sn.NODE_TYPE]:{value:Sn.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=Sn.isNode(this.contents)?this.contents.clone(e.schema):this.contents,this.range)e.range=this.range.slice();return e}add(e){if(hl(this.contents))this.contents.add(e)}addIn(e,t){if(hl(this.contents))this.contents.addIn(e,t)}createAlias(e,t){if(!e.anchor){let r=CA.anchorNames(this);e.anchor=!t||r.has(t)?CA.findNewAnchor(t||"a",r):t}return new ype.Alias(e.anchor)}createNode(e,t,r){let i=void 0;if(typeof t==="function")e=t.call({"":e},"",e),i=t;else if(Array.isArray(t)){let g=(v)=>typeof v==="number"||v instanceof String||v instanceof Number,b=t.filter(g).map(String);if(b.length>0)t=t.concat(b);i=t}else if(r===void 0&&t)r=t,t=void 0;let{aliasDuplicateObjects:n,anchorPrefix:o,flow:s,keepUndefined:a,onTagObj:c,tag:l}=r??{},{onAnchor:u,setAnchors:d,sourceObjects:p}=CA.createNodeAnchors(this,o||"a"),m={aliasDuplicateObjects:n??!0,keepUndefined:a??!1,onAnchor:u,onTagObj:c,replacer:i,schema:this.schema,sourceObjects:p},y=_pe.createNode(e,l,m);if(s&&Sn.isCollection(y))y.flow=!0;return d(),y}createPair(e,t,r={}){let i=this.createNode(e,null,r),n=this.createNode(t,null,r);return new bpe.Pair(i,n)}delete(e){return hl(this.contents)?this.contents.delete(e):!1}deleteIn(e){if(ml.isEmptyPath(e)){if(this.contents==null)return!1;return this.contents=null,!0}return hl(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return Sn.isCollection(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){if(ml.isEmptyPath(e))return!t&&Sn.isScalar(this.contents)?this.contents.value:this.contents;return Sn.isCollection(this.contents)?this.contents.getIn(e,t):void 0}has(e){return Sn.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){if(ml.isEmptyPath(e))return this.contents!==void 0;return Sn.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,t){if(this.contents==null)this.contents=ml.collectionFromPath(this.schema,[e],t);else if(hl(this.contents))this.contents.set(e,t)}setIn(e,t){if(ml.isEmptyPath(e))this.contents=t;else if(this.contents==null)this.contents=ml.collectionFromPath(this.schema,Array.from(e),t);else if(hl(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 $A.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 $A.Directives({version:e});r={resolveKnownTags:!0,schema:"core"};break;case null:if(this.directives)delete this.directives;r=null;break;default:{let i=JSON.stringify(e);throw Error(`Expected '1.1', '1.2' or null as first argument, but found: ${i}`)}}if(t.schema instanceof Object)this.schema=t.schema;else if(r)this.schema=new Spe.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:i,onAnchor:n,reviver:o}={}){let s={anchors:new Map,doc:this,keep:!e,mapAsMap:r===!0,mapKeyWarned:!1,maxAliasCount:typeof i==="number"?i:100},a=xpe.toJS(this.contents,t??"",s);if(typeof n==="function")for(let{count:c,res:l}of s.anchors.values())n(l,c);return typeof o==="function"?vpe.applyReviver(o,{"":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 wpe.stringifyDocument(this,e)}}function hl(e){if(Sn.isCollection(e))return!0;throw Error("Expected a YAML collection as document contents")}kpe.Document=OA});var cf=ee(function(Ape){class Iy extends Error{constructor(e,t,r,i){super();this.name=e,this.code=r,this.message=i,this.pos=t}}class UM extends Iy{constructor(e,t,r){super("YAMLParseError",e,t,r)}}class MM extends Iy{constructor(e,t,r){super("YAMLWarning",e,t,r)}}var Ipe=(e,t)=>(r)=>{if(r.pos[0]===-1)return;r.linePos=r.pos.map((a)=>t.linePos(a));let{line:i,col:n}=r.linePos[0];r.message+=` at line ${i}, column ${n}`;let o=n-1,s=e.substring(t.lineStarts[i-1],t.lineStarts[i]).replace(/[\n\r]+$/,"");if(o>=60&&s.length>80){let a=Math.min(o-39,s.length-79);s="\u2026"+s.substring(a),o-=a-1}if(s.length>80)s=s.substring(0,79)+"\u2026";if(i>1&&/^ *$/.test(s.substring(0,o))){let a=e.substring(t.lineStarts[i-2],t.lineStarts[i-1]);if(a.length>80)a=a.substring(0,79)+`\u2026
368
+ `}mpe.stringifyDocument=ppe});var af=ee(function(_pe){var gpe=Kd(),ml=Xg(),Sn=Ge(),ype=Fo(),bpe=qo(),xpe=AA(),Spe=qM(),CA=Gg(),wpe=VI(),vpe=Jd(),$A=JI();class OA{constructor(e,t,r){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,Sn.NODE_TYPE,{value:Sn.DOC});let i=null;if(typeof t==="function"||Array.isArray(t))i=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:o}=n;if(r?._directives){if(this.directives=r._directives.atDocument(),this.directives.yaml.explicit)o=this.directives.yaml.version}else this.directives=new $A.Directives({version:o});this.setSchema(o,r),this.contents=e===void 0?null:this.createNode(e,i,r)}clone(){let e=Object.create(OA.prototype,{[Sn.NODE_TYPE]:{value:Sn.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=Sn.isNode(this.contents)?this.contents.clone(e.schema):this.contents,this.range)e.range=this.range.slice();return e}add(e){if(hl(this.contents))this.contents.add(e)}addIn(e,t){if(hl(this.contents))this.contents.addIn(e,t)}createAlias(e,t){if(!e.anchor){let r=CA.anchorNames(this);e.anchor=!t||r.has(t)?CA.findNewAnchor(t||"a",r):t}return new gpe.Alias(e.anchor)}createNode(e,t,r){let i=void 0;if(typeof t==="function")e=t.call({"":e},"",e),i=t;else if(Array.isArray(t)){let g=(v)=>typeof v==="number"||v instanceof String||v instanceof Number,b=t.filter(g).map(String);if(b.length>0)t=t.concat(b);i=t}else if(r===void 0&&t)r=t,t=void 0;let{aliasDuplicateObjects:n,anchorPrefix:o,flow:s,keepUndefined:a,onTagObj:c,tag:l}=r??{},{onAnchor:u,setAnchors:d,sourceObjects:p}=CA.createNodeAnchors(this,o||"a"),m={aliasDuplicateObjects:n??!0,keepUndefined:a??!1,onAnchor:u,onTagObj:c,replacer:i,schema:this.schema,sourceObjects:p},y=vpe.createNode(e,l,m);if(s&&Sn.isCollection(y))y.flow=!0;return d(),y}createPair(e,t,r={}){let i=this.createNode(e,null,r),n=this.createNode(t,null,r);return new ype.Pair(i,n)}delete(e){return hl(this.contents)?this.contents.delete(e):!1}deleteIn(e){if(ml.isEmptyPath(e)){if(this.contents==null)return!1;return this.contents=null,!0}return hl(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return Sn.isCollection(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){if(ml.isEmptyPath(e))return!t&&Sn.isScalar(this.contents)?this.contents.value:this.contents;return Sn.isCollection(this.contents)?this.contents.getIn(e,t):void 0}has(e){return Sn.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){if(ml.isEmptyPath(e))return this.contents!==void 0;return Sn.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,t){if(this.contents==null)this.contents=ml.collectionFromPath(this.schema,[e],t);else if(hl(this.contents))this.contents.set(e,t)}setIn(e,t){if(ml.isEmptyPath(e))this.contents=t;else if(this.contents==null)this.contents=ml.collectionFromPath(this.schema,Array.from(e),t);else if(hl(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 $A.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 $A.Directives({version:e});r={resolveKnownTags:!0,schema:"core"};break;case null:if(this.directives)delete this.directives;r=null;break;default:{let i=JSON.stringify(e);throw Error(`Expected '1.1', '1.2' or null as first argument, but found: ${i}`)}}if(t.schema instanceof Object)this.schema=t.schema;else if(r)this.schema=new xpe.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:i,onAnchor:n,reviver:o}={}){let s={anchors:new Map,doc:this,keep:!e,mapAsMap:r===!0,mapKeyWarned:!1,maxAliasCount:typeof i==="number"?i:100},a=bpe.toJS(this.contents,t??"",s);if(typeof n==="function")for(let{count:c,res:l}of s.anchors.values())n(l,c);return typeof o==="function"?wpe.applyReviver(o,{"":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 Spe.stringifyDocument(this,e)}}function hl(e){if(Sn.isCollection(e))return!0;throw Error("Expected a YAML collection as document contents")}_pe.Document=OA});var cf=ee(function(Ipe){class Iy extends Error{constructor(e,t,r,i){super();this.name=e,this.code=r,this.message=i,this.pos=t}}class UM extends Iy{constructor(e,t,r){super("YAMLParseError",e,t,r)}}class MM extends Iy{constructor(e,t,r){super("YAMLWarning",e,t,r)}}var Epe=(e,t)=>(r)=>{if(r.pos[0]===-1)return;r.linePos=r.pos.map((a)=>t.linePos(a));let{line:i,col:n}=r.linePos[0];r.message+=` at line ${i}, column ${n}`;let o=n-1,s=e.substring(t.lineStarts[i-1],t.lineStarts[i]).replace(/[\n\r]+$/,"");if(o>=60&&s.length>80){let a=Math.min(o-39,s.length-79);s="\u2026"+s.substring(a),o-=a-1}if(s.length>80)s=s.substring(0,79)+"\u2026";if(i>1&&/^ *$/.test(s.substring(0,o))){let a=e.substring(t.lineStarts[i-2],t.lineStarts[i-1]);if(a.length>80)a=a.substring(0,79)+`\u2026
370
369
  `;s=a+s}if(/[^ ]/.test(s)){let a=1,c=r.linePos[1];if(c?.line===i&&c.col>n)a=Math.max(1,Math.min(c.col-n,80-o));let l=" ".repeat(o)+"^".repeat(a);r.message+=`:
371
370
 
372
371
  ${s}
373
372
  ${l}
374
- `}};Ape.YAMLError=Iy;Ape.YAMLParseError=UM;Ape.YAMLWarning=MM;Ape.prettifyError=Ipe});var lf=ee(function(Ppe){function Rpe(e,{flow:t,indicator:r,next:i,offset:n,onError:o,parentIndent:s,startOnNewline:a}){let c=!1,l=a,u=a,d="",p="",m=!1,y=!1,g=null,b=null,v=null,A=null,T=null,z=null,j=null;for(let D of e){if(y){if(D.type!=="space"&&D.type!=="newline"&&D.type!=="comma")o(D.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space");y=!1}if(g){if(l&&D.type!=="comment"&&D.type!=="newline")o(g,"TAB_AS_INDENT","Tabs are not allowed as indentation");g=null}switch(D.type){case"space":if(!t&&(r!=="doc-start"||i?.type!=="flow-collection")&&D.source.includes("\t"))g=D;u=!0;break;case"comment":{if(!u)o(D,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let H=D.source.substring(1)||" ";if(!d)d=H;else d+=p+H;p="",l=!1;break}case"newline":if(l){if(d)d+=D.source;else if(!z||r!=="seq-item-ind")c=!0}else p+=D.source;if(l=!0,m=!0,b||v)A=D;u=!0;break;case"anchor":if(b)o(D,"MULTIPLE_ANCHORS","A node can have at most one anchor");if(D.source.endsWith(":"))o(D.offset+D.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0);b=D,j??(j=D.offset),l=!1,u=!1,y=!0;break;case"tag":{if(v)o(D,"MULTIPLE_TAGS","A node can have at most one tag");v=D,j??(j=D.offset),l=!1,u=!1,y=!0;break}case r:if(b||v)o(D,"BAD_PROP_ORDER",`Anchors and tags must be after the ${D.source} indicator`);if(z)o(D,"UNEXPECTED_TOKEN",`Unexpected ${D.source} in ${t??"collection"}`);z=D,l=r==="seq-item-ind"||r==="explicit-key-ind",u=!1;break;case"comma":if(t){if(T)o(D,"UNEXPECTED_TOKEN",`Unexpected , in ${t}`);T=D,l=!1,u=!1;break}default:o(D,"UNEXPECTED_TOKEN",`Unexpected ${D.type} token`),l=!1,u=!1}}let E=e[e.length-1],Z=E?E.offset+E.source.length:n;if(y&&i&&i.type!=="space"&&i.type!=="newline"&&i.type!=="comma"&&(i.type!=="scalar"||i.source!==""))o(i.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space");if(g&&(l&&g.indent<=s||i?.type==="block-map"||i?.type==="block-seq"))o(g,"TAB_AS_INDENT","Tabs are not allowed as indentation");return{comma:T,found:z,spaceBefore:c,comment:d,hasNewline:m,anchor:b,tag:v,newlineAfterProp:A,end:Z,start:j??Z}}Ppe.resolveProps=Rpe});var Ay=ee(function(Npe){function RA(e){if(!e)return null;switch(e.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(e.source.includes(`
375
- `))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(RA(t.key)||RA(t.value))return!0}return!1;default:return!0}}Npe.containsNewline=RA});var PA=ee(function(jpe){var Lpe=Ay();function Bpe(e,t,r){if(t?.type==="flow-collection"){let i=t.end[0];if(i.indent===e&&(i.source==="]"||i.source==="}")&&Lpe.containsNewline(t))r(i,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}jpe.flowIndentCheck=Bpe});var zA=ee(function(Mpe){var FM=Ge();function Upe(e,t,r){let{uniqueKeys:i}=e.options;if(i===!1)return!1;let n=typeof i==="function"?i:(o,s)=>o===s||FM.isScalar(o)&&FM.isScalar(s)&&o.value===s.value;return t.some((o)=>n(o.key,r))}Mpe.mapIncludes=Upe});var VM=ee(function(Vpe){var ZM=Fo(),Zpe=Ho(),HM=lf(),Hpe=Ay(),KM=PA(),Kpe=zA(),JM="All mapping items must start at the same column";function Jpe({composeNode:e,composeEmptyNode:t},r,i,n,o){let a=new(o?.nodeClass??Zpe.YAMLMap)(r.schema);if(r.atRoot)r.atRoot=!1;let c=i.offset,l=null;for(let u of i.items){let{start:d,key:p,sep:m,value:y}=u,g=HM.resolveProps(d,{indicator:"explicit-key-ind",next:p??m?.[0],offset:c,onError:n,parentIndent:i.indent,startOnNewline:!0}),b=!g.found;if(b){if(p){if(p.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 p&&p.indent!==i.indent)n(c,"BAD_INDENT",JM)}if(!g.anchor&&!g.tag&&!m){if(l=g.end,g.comment)if(a.comment)a.comment+=`
376
- `+g.comment;else a.comment=g.comment;continue}if(g.newlineAfterProp||Hpe.containsNewline(p))n(p??d[d.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else if(g.found?.indent!==i.indent)n(c,"BAD_INDENT",JM);r.atKey=!0;let v=g.end,A=p?e(r,p,g,n):t(r,v,d,null,g,n);if(r.schema.compat)KM.flowIndentCheck(i.indent,p,n);if(r.atKey=!1,Kpe.mapIncludes(r,a.items,A))n(v,"DUPLICATE_KEY","Map keys must be unique");let T=HM.resolveProps(m??[],{indicator:"map-value-ind",next:y,offset:A.range[2],onError:n,parentIndent:i.indent,startOnNewline:!p||p.type==="block-scalar"});if(c=T.end,T.found){if(b){if(y?.type==="block-map"&&!T.hasNewline)n(c,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings");if(r.options.strict&&g.start<T.found.offset-1024)n(A.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key")}let z=y?e(r,y,T,n):t(r,c,m,null,T,n);if(r.schema.compat)KM.flowIndentCheck(i.indent,y,n);c=z.range[2];let j=new ZM.Pair(A,z);if(r.options.keepSourceTokens)j.srcToken=u;a.items.push(j)}else{if(b)n(A.range,"MISSING_CHAR","Implicit map keys need to be followed by map values");if(T.comment)if(A.comment)A.comment+=`
377
- `+T.comment;else A.comment=T.comment;let z=new ZM.Pair(A);if(r.options.keepSourceTokens)z.srcToken=u;a.items.push(z)}}if(l&&l<c)n(l,"IMPOSSIBLE","Map comment with trailing content");return a.range=[i.offset,c,l??c],a}Vpe.resolveBlockMap=Jpe});var WM=ee(function(eme){var Gpe=Ko(),Qpe=lf(),Ype=PA();function Xpe({composeNode:e,composeEmptyNode:t},r,i,n,o){let a=new(o?.nodeClass??Gpe.YAMLSeq)(r.schema);if(r.atRoot)r.atRoot=!1;if(r.atKey)r.atKey=!1;let c=i.offset,l=null;for(let{start:u,value:d}of i.items){let p=Qpe.resolveProps(u,{indicator:"seq-item-ind",next:d,offset:c,onError:n,parentIndent:i.indent,startOnNewline:!0});if(!p.found)if(p.anchor||p.tag||d)if(d?.type==="block-seq")n(p.end,"BAD_INDENT","All sequence items must start at the same column");else n(c,"MISSING_CHAR","Sequence item without - indicator");else{if(l=p.end,p.comment)a.comment=p.comment;continue}let m=d?e(r,d,p,n):t(r,p.end,u,null,p,n);if(r.schema.compat)Ype.flowIndentCheck(i.indent,d,n);c=m.range[2],a.items.push(m)}return a.range=[i.offset,c,l??c],a}eme.resolveBlockSeq=Xpe});var gl=ee(function(nme){function rme(e,t,r,i){let n="";if(e){let o=!1,s="";for(let a of e){let{source:c,type:l}=a;switch(l){case"space":o=!0;break;case"comment":{if(r&&!o)i(a,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let u=c.substring(1)||" ";if(!n)n=u;else n+=s+u;s="";break}case"newline":if(n)s+=c;o=!0;break;default:i(a,"UNEXPECTED_TOKEN",`Unexpected ${l} at node end`)}t+=c.length}}return{comment:n,offset:t}}nme.resolveEnd=rme});var YM=ee(function(fme){var ome=Ge(),sme=Fo(),GM=Ho(),ame=Ko(),cme=gl(),QM=lf(),lme=Ay(),ume=zA(),NA="Block collections are not allowed within flow collections",DA=(e)=>e&&(e.type==="block-map"||e.type==="block-seq");function dme({composeNode:e,composeEmptyNode:t},r,i,n,o){let s=i.start.source==="{",a=s?"flow map":"flow sequence",l=new(o?.nodeClass??(s?GM.YAMLMap:ame.YAMLSeq))(r.schema);l.flow=!0;let u=r.atRoot;if(u)r.atRoot=!1;if(r.atKey)r.atKey=!1;let d=i.offset+i.start.source.length;for(let b=0;b<i.items.length;++b){let v=i.items[b],{start:A,key:T,sep:z,value:j}=v,E=QM.resolveProps(A,{flow:a,indicator:"explicit-key-ind",next:T??z?.[0],offset:d,onError:n,parentIndent:i.indent,startOnNewline:!1});if(!E.found){if(!E.anchor&&!E.tag&&!z&&!j){if(b===0&&E.comma)n(E.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`);else if(b<i.items.length-1)n(E.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${a}`);if(E.comment)if(l.comment)l.comment+=`
378
- `+E.comment;else l.comment=E.comment;d=E.end;continue}if(!s&&r.options.strict&&lme.containsNewline(T))n(T,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(b===0){if(E.comma)n(E.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`)}else{if(!E.comma)n(E.start,"MISSING_CHAR",`Missing , between ${a} items`);if(E.comment){let Z="";e:for(let D of A)switch(D.type){case"comma":case"space":break;case"comment":Z=D.source.substring(1);break e;default:break e}if(Z){let D=l.items[l.items.length-1];if(ome.isPair(D))D=D.value??D.key;if(D.comment)D.comment+=`
373
+ `}};Ipe.YAMLError=Iy;Ipe.YAMLParseError=UM;Ipe.YAMLWarning=MM;Ipe.prettifyError=Epe});var lf=ee(function(Rpe){function Ope(e,{flow:t,indicator:r,next:i,offset:n,onError:o,parentIndent:s,startOnNewline:a}){let c=!1,l=a,u=a,d="",p="",m=!1,y=!1,g=null,b=null,v=null,A=null,T=null,z=null,j=null;for(let D of e){if(y){if(D.type!=="space"&&D.type!=="newline"&&D.type!=="comma")o(D.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space");y=!1}if(g){if(l&&D.type!=="comment"&&D.type!=="newline")o(g,"TAB_AS_INDENT","Tabs are not allowed as indentation");g=null}switch(D.type){case"space":if(!t&&(r!=="doc-start"||i?.type!=="flow-collection")&&D.source.includes("\t"))g=D;u=!0;break;case"comment":{if(!u)o(D,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let H=D.source.substring(1)||" ";if(!d)d=H;else d+=p+H;p="",l=!1;break}case"newline":if(l){if(d)d+=D.source;else if(!z||r!=="seq-item-ind")c=!0}else p+=D.source;if(l=!0,m=!0,b||v)A=D;u=!0;break;case"anchor":if(b)o(D,"MULTIPLE_ANCHORS","A node can have at most one anchor");if(D.source.endsWith(":"))o(D.offset+D.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0);b=D,j??(j=D.offset),l=!1,u=!1,y=!0;break;case"tag":{if(v)o(D,"MULTIPLE_TAGS","A node can have at most one tag");v=D,j??(j=D.offset),l=!1,u=!1,y=!0;break}case r:if(b||v)o(D,"BAD_PROP_ORDER",`Anchors and tags must be after the ${D.source} indicator`);if(z)o(D,"UNEXPECTED_TOKEN",`Unexpected ${D.source} in ${t??"collection"}`);z=D,l=r==="seq-item-ind"||r==="explicit-key-ind",u=!1;break;case"comma":if(t){if(T)o(D,"UNEXPECTED_TOKEN",`Unexpected , in ${t}`);T=D,l=!1,u=!1;break}default:o(D,"UNEXPECTED_TOKEN",`Unexpected ${D.type} token`),l=!1,u=!1}}let E=e[e.length-1],Z=E?E.offset+E.source.length:n;if(y&&i&&i.type!=="space"&&i.type!=="newline"&&i.type!=="comma"&&(i.type!=="scalar"||i.source!==""))o(i.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space");if(g&&(l&&g.indent<=s||i?.type==="block-map"||i?.type==="block-seq"))o(g,"TAB_AS_INDENT","Tabs are not allowed as indentation");return{comma:T,found:z,spaceBefore:c,comment:d,hasNewline:m,anchor:b,tag:v,newlineAfterProp:A,end:Z,start:j??Z}}Rpe.resolveProps=Ope});var Ay=ee(function(zpe){function RA(e){if(!e)return null;switch(e.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(e.source.includes(`
374
+ `))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(RA(t.key)||RA(t.value))return!0}return!1;default:return!0}}zpe.containsNewline=RA});var PA=ee(function(Bpe){var Dpe=Ay();function Lpe(e,t,r){if(t?.type==="flow-collection"){let i=t.end[0];if(i.indent===e&&(i.source==="]"||i.source==="}")&&Dpe.containsNewline(t))r(i,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}Bpe.flowIndentCheck=Lpe});var zA=ee(function(Upe){var FM=Ge();function qpe(e,t,r){let{uniqueKeys:i}=e.options;if(i===!1)return!1;let n=typeof i==="function"?i:(o,s)=>o===s||FM.isScalar(o)&&FM.isScalar(s)&&o.value===s.value;return t.some((o)=>n(o.key,r))}Upe.mapIncludes=qpe});var VM=ee(function(Jpe){var ZM=Fo(),Fpe=Ho(),HM=lf(),Zpe=Ay(),KM=PA(),Hpe=zA(),JM="All mapping items must start at the same column";function Kpe({composeNode:e,composeEmptyNode:t},r,i,n,o){let a=new(o?.nodeClass??Fpe.YAMLMap)(r.schema);if(r.atRoot)r.atRoot=!1;let c=i.offset,l=null;for(let u of i.items){let{start:d,key:p,sep:m,value:y}=u,g=HM.resolveProps(d,{indicator:"explicit-key-ind",next:p??m?.[0],offset:c,onError:n,parentIndent:i.indent,startOnNewline:!0}),b=!g.found;if(b){if(p){if(p.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 p&&p.indent!==i.indent)n(c,"BAD_INDENT",JM)}if(!g.anchor&&!g.tag&&!m){if(l=g.end,g.comment)if(a.comment)a.comment+=`
375
+ `+g.comment;else a.comment=g.comment;continue}if(g.newlineAfterProp||Zpe.containsNewline(p))n(p??d[d.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else if(g.found?.indent!==i.indent)n(c,"BAD_INDENT",JM);r.atKey=!0;let v=g.end,A=p?e(r,p,g,n):t(r,v,d,null,g,n);if(r.schema.compat)KM.flowIndentCheck(i.indent,p,n);if(r.atKey=!1,Hpe.mapIncludes(r,a.items,A))n(v,"DUPLICATE_KEY","Map keys must be unique");let T=HM.resolveProps(m??[],{indicator:"map-value-ind",next:y,offset:A.range[2],onError:n,parentIndent:i.indent,startOnNewline:!p||p.type==="block-scalar"});if(c=T.end,T.found){if(b){if(y?.type==="block-map"&&!T.hasNewline)n(c,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings");if(r.options.strict&&g.start<T.found.offset-1024)n(A.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key")}let z=y?e(r,y,T,n):t(r,c,m,null,T,n);if(r.schema.compat)KM.flowIndentCheck(i.indent,y,n);c=z.range[2];let j=new ZM.Pair(A,z);if(r.options.keepSourceTokens)j.srcToken=u;a.items.push(j)}else{if(b)n(A.range,"MISSING_CHAR","Implicit map keys need to be followed by map values");if(T.comment)if(A.comment)A.comment+=`
376
+ `+T.comment;else A.comment=T.comment;let z=new ZM.Pair(A);if(r.options.keepSourceTokens)z.srcToken=u;a.items.push(z)}}if(l&&l<c)n(l,"IMPOSSIBLE","Map comment with trailing content");return a.range=[i.offset,c,l??c],a}Jpe.resolveBlockMap=Kpe});var WM=ee(function(Xpe){var Wpe=Ko(),Gpe=lf(),Qpe=PA();function Ype({composeNode:e,composeEmptyNode:t},r,i,n,o){let a=new(o?.nodeClass??Wpe.YAMLSeq)(r.schema);if(r.atRoot)r.atRoot=!1;if(r.atKey)r.atKey=!1;let c=i.offset,l=null;for(let{start:u,value:d}of i.items){let p=Gpe.resolveProps(u,{indicator:"seq-item-ind",next:d,offset:c,onError:n,parentIndent:i.indent,startOnNewline:!0});if(!p.found)if(p.anchor||p.tag||d)if(d?.type==="block-seq")n(p.end,"BAD_INDENT","All sequence items must start at the same column");else n(c,"MISSING_CHAR","Sequence item without - indicator");else{if(l=p.end,p.comment)a.comment=p.comment;continue}let m=d?e(r,d,p,n):t(r,p.end,u,null,p,n);if(r.schema.compat)Qpe.flowIndentCheck(i.indent,d,n);c=m.range[2],a.items.push(m)}return a.range=[i.offset,c,l??c],a}Xpe.resolveBlockSeq=Ype});var gl=ee(function(rme){function tme(e,t,r,i){let n="";if(e){let o=!1,s="";for(let a of e){let{source:c,type:l}=a;switch(l){case"space":o=!0;break;case"comment":{if(r&&!o)i(a,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let u=c.substring(1)||" ";if(!n)n=u;else n+=s+u;s="";break}case"newline":if(n)s+=c;o=!0;break;default:i(a,"UNEXPECTED_TOKEN",`Unexpected ${l} at node end`)}t+=c.length}}return{comment:n,offset:t}}rme.resolveEnd=tme});var YM=ee(function(dme){var ime=Ge(),ome=Fo(),GM=Ho(),sme=Ko(),ame=gl(),QM=lf(),cme=Ay(),lme=zA(),NA="Block collections are not allowed within flow collections",DA=(e)=>e&&(e.type==="block-map"||e.type==="block-seq");function ume({composeNode:e,composeEmptyNode:t},r,i,n,o){let s=i.start.source==="{",a=s?"flow map":"flow sequence",l=new(o?.nodeClass??(s?GM.YAMLMap:sme.YAMLSeq))(r.schema);l.flow=!0;let u=r.atRoot;if(u)r.atRoot=!1;if(r.atKey)r.atKey=!1;let d=i.offset+i.start.source.length;for(let b=0;b<i.items.length;++b){let v=i.items[b],{start:A,key:T,sep:z,value:j}=v,E=QM.resolveProps(A,{flow:a,indicator:"explicit-key-ind",next:T??z?.[0],offset:d,onError:n,parentIndent:i.indent,startOnNewline:!1});if(!E.found){if(!E.anchor&&!E.tag&&!z&&!j){if(b===0&&E.comma)n(E.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`);else if(b<i.items.length-1)n(E.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${a}`);if(E.comment)if(l.comment)l.comment+=`
377
+ `+E.comment;else l.comment=E.comment;d=E.end;continue}if(!s&&r.options.strict&&cme.containsNewline(T))n(T,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(b===0){if(E.comma)n(E.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`)}else{if(!E.comma)n(E.start,"MISSING_CHAR",`Missing , between ${a} items`);if(E.comment){let Z="";e:for(let D of A)switch(D.type){case"comma":case"space":break;case"comment":Z=D.source.substring(1);break e;default:break e}if(Z){let D=l.items[l.items.length-1];if(ime.isPair(D))D=D.value??D.key;if(D.comment)D.comment+=`
379
378
  `+Z;else D.comment=Z;E.comment=E.comment.substring(Z.length+1)}}}if(!s&&!z&&!E.found){let Z=j?e(r,j,E,n):t(r,E.end,z,null,E,n);if(l.items.push(Z),d=Z.range[2],DA(j))n(Z.range,"BLOCK_IN_FLOW",NA)}else{r.atKey=!0;let Z=E.end,D=T?e(r,T,E,n):t(r,Z,A,null,E,n);if(DA(T))n(D.range,"BLOCK_IN_FLOW",NA);r.atKey=!1;let H=QM.resolveProps(z??[],{flow:a,indicator:"map-value-ind",next:j,offset:D.range[2],onError:n,parentIndent:i.indent,startOnNewline:!1});if(H.found){if(!s&&!E.found&&r.options.strict){if(z)for(let P of z){if(P===H.found)break;if(P.type==="newline"){n(P,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}if(E.start<H.found.offset-1024)n(H.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else if(j)if("source"in j&&j.source?.[0]===":")n(j,"MISSING_CHAR",`Missing space after : in ${a}`);else n(H.start,"MISSING_CHAR",`Missing , or : between ${a} items`);let X=j?e(r,j,H,n):H.found?t(r,H.end,z,null,H,n):null;if(X){if(DA(j))n(X.range,"BLOCK_IN_FLOW",NA)}else if(H.comment)if(D.comment)D.comment+=`
380
- `+H.comment;else D.comment=H.comment;let M=new sme.Pair(D,X);if(r.options.keepSourceTokens)M.srcToken=v;if(s){let P=l;if(ume.mapIncludes(r,P.items,D))n(Z,"DUPLICATE_KEY","Map keys must be unique");P.items.push(M)}else{let P=new GM.YAMLMap(r.schema);P.flow=!0,P.items.push(M);let N=(X??D).range;P.range=[D.range[0],N[1],N[2]],l.items.push(P)}d=X?X.range[2]:H.end}}let p=s?"}":"]",[m,...y]=i.end,g=d;if(m?.source===p)g=m.offset+m.source.length;else{let b=a[0].toUpperCase()+a.substring(1),v=u?`${b} must end with a ${p}`:`${b} in block collection must be sufficiently indented and end with a ${p}`;if(n(d,u?"MISSING_CHAR":"BAD_INDENT",v),m&&m.source.length!==1)y.unshift(m)}if(y.length>0){let b=cme.resolveEnd(y,g,r.options.strict,n);if(b.comment)if(l.comment)l.comment+=`
381
- `+b.comment;else l.comment=b.comment;l.range=[i.offset,g,b.offset]}else l.range=[i.offset,g,g];return l}fme.resolveFlowCollection=dme});var XM=ee(function(vme){var mme=Ge(),hme=jt(),gme=Ho(),yme=Ko(),bme=VM(),xme=WM(),Sme=YM();function LA(e,t,r,i,n,o){let s=r.type==="block-map"?bme.resolveBlockMap(e,t,r,i,o):r.type==="block-seq"?xme.resolveBlockSeq(e,t,r,i,o):Sme.resolveFlowCollection(e,t,r,i,o),a=s.constructor;if(n==="!"||n===a.tagName)return s.tag=a.tagName,s;if(n)s.tag=n;return s}function wme(e,t,r,i,n){let o=i.tag,s=!o?null:t.directives.tagName(o.source,(p)=>n(o,"TAG_RESOLVE_FAILED",p));if(r.type==="block-seq"){let{anchor:p,newlineAfterProp:m}=i,y=p&&o?p.offset>o.offset?p:o:p??o;if(y&&(!m||m.offset<y.offset))n(y,"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(!o||!s||s==="!"||s===gme.YAMLMap.tagName&&a==="map"||s===yme.YAMLSeq.tagName&&a==="seq")return LA(e,t,r,n,s);let c=t.schema.tags.find((p)=>p.tag===s&&p.collection===a);if(!c){let p=t.schema.knownTags[s];if(p?.collection===a)t.schema.tags.push(Object.assign({},p,{default:!1})),c=p;else{if(p)n(o,"BAD_COLLECTION_TYPE",`${p.tag} used for ${a} collection, but expects ${p.collection??"scalar"}`,!0);else n(o,"TAG_RESOLVE_FAILED",`Unresolved tag: ${s}`,!0);return LA(e,t,r,n,s)}}let l=LA(e,t,r,n,s,c),u=c.resolve?.(l,(p)=>n(o,"TAG_RESOLVE_FAILED",p),t.options)??l,d=mme.isNode(u)?u:new hme.Scalar(u);if(d.range=l.range,d.tag=s,c?.format)d.format=c.format;return d}vme.composeCollection=wme});var jA=ee(function(Ame){var BA=jt();function kme(e,t,r){let i=t.offset,n=Eme(t,e.options.strict,r);if(!n)return{value:"",type:null,comment:"",range:[i,i,i]};let o=n.mode===">"?BA.Scalar.BLOCK_FOLDED:BA.Scalar.BLOCK_LITERAL,s=t.source?Ime(t.source):[],a=s.length;for(let g=s.length-1;g>=0;--g){let b=s[g][1];if(b===""||b==="\r")a=g;else break}if(a===0){let g=n.chomp==="+"&&s.length>0?`
379
+ `+H.comment;else D.comment=H.comment;let M=new ome.Pair(D,X);if(r.options.keepSourceTokens)M.srcToken=v;if(s){let P=l;if(lme.mapIncludes(r,P.items,D))n(Z,"DUPLICATE_KEY","Map keys must be unique");P.items.push(M)}else{let P=new GM.YAMLMap(r.schema);P.flow=!0,P.items.push(M);let N=(X??D).range;P.range=[D.range[0],N[1],N[2]],l.items.push(P)}d=X?X.range[2]:H.end}}let p=s?"}":"]",[m,...y]=i.end,g=d;if(m?.source===p)g=m.offset+m.source.length;else{let b=a[0].toUpperCase()+a.substring(1),v=u?`${b} must end with a ${p}`:`${b} in block collection must be sufficiently indented and end with a ${p}`;if(n(d,u?"MISSING_CHAR":"BAD_INDENT",v),m&&m.source.length!==1)y.unshift(m)}if(y.length>0){let b=ame.resolveEnd(y,g,r.options.strict,n);if(b.comment)if(l.comment)l.comment+=`
380
+ `+b.comment;else l.comment=b.comment;l.range=[i.offset,g,b.offset]}else l.range=[i.offset,g,g];return l}dme.resolveFlowCollection=ume});var XM=ee(function(wme){var pme=Ge(),mme=jt(),hme=Ho(),gme=Ko(),yme=VM(),bme=WM(),xme=YM();function LA(e,t,r,i,n,o){let s=r.type==="block-map"?yme.resolveBlockMap(e,t,r,i,o):r.type==="block-seq"?bme.resolveBlockSeq(e,t,r,i,o):xme.resolveFlowCollection(e,t,r,i,o),a=s.constructor;if(n==="!"||n===a.tagName)return s.tag=a.tagName,s;if(n)s.tag=n;return s}function Sme(e,t,r,i,n){let o=i.tag,s=!o?null:t.directives.tagName(o.source,(p)=>n(o,"TAG_RESOLVE_FAILED",p));if(r.type==="block-seq"){let{anchor:p,newlineAfterProp:m}=i,y=p&&o?p.offset>o.offset?p:o:p??o;if(y&&(!m||m.offset<y.offset))n(y,"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(!o||!s||s==="!"||s===hme.YAMLMap.tagName&&a==="map"||s===gme.YAMLSeq.tagName&&a==="seq")return LA(e,t,r,n,s);let c=t.schema.tags.find((p)=>p.tag===s&&p.collection===a);if(!c){let p=t.schema.knownTags[s];if(p?.collection===a)t.schema.tags.push(Object.assign({},p,{default:!1})),c=p;else{if(p)n(o,"BAD_COLLECTION_TYPE",`${p.tag} used for ${a} collection, but expects ${p.collection??"scalar"}`,!0);else n(o,"TAG_RESOLVE_FAILED",`Unresolved tag: ${s}`,!0);return LA(e,t,r,n,s)}}let l=LA(e,t,r,n,s,c),u=c.resolve?.(l,(p)=>n(o,"TAG_RESOLVE_FAILED",p),t.options)??l,d=pme.isNode(u)?u:new mme.Scalar(u);if(d.range=l.range,d.tag=s,c?.format)d.format=c.format;return d}wme.composeCollection=Sme});var jA=ee(function(Ime){var BA=jt();function _me(e,t,r){let i=t.offset,n=kme(t,e.options.strict,r);if(!n)return{value:"",type:null,comment:"",range:[i,i,i]};let o=n.mode===">"?BA.Scalar.BLOCK_FOLDED:BA.Scalar.BLOCK_LITERAL,s=t.source?Eme(t.source):[],a=s.length;for(let g=s.length-1;g>=0;--g){let b=s[g][1];if(b===""||b==="\r")a=g;else break}if(a===0){let g=n.chomp==="+"&&s.length>0?`
382
381
  `.repeat(Math.max(1,s.length-1)):"",b=i+n.length;if(t.source)b+=t.source.length;return{value:g,type:o,comment:n.comment,range:[i,b,b]}}let c=t.indent+n.indent,l=t.offset+n.length,u=0;for(let g=0;g<a;++g){let[b,v]=s[g];if(v===""||v==="\r"){if(n.indent===0&&b.length>c)c=b.length}else{if(b.length<c)r(l+b.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator");if(n.indent===0)c=b.length;if(u=g,c===0&&!e.atRoot)r(l,"BAD_INDENT","Block scalar values in collections must be indented");break}l+=b.length+v.length+1}for(let g=s.length-1;g>=a;--g)if(s[g][0].length>c)a=g+1;let d="",p="",m=!1;for(let g=0;g<u;++g)d+=s[g][0].slice(c)+`
383
382
  `;for(let g=u;g<a;++g){let[b,v]=s[g];l+=b.length+v.length+1;let A=v[v.length-1]==="\r";if(A)v=v.slice(0,-1);if(v&&b.length<c){let z=`Block scalar lines must not be less indented than their ${n.indent?"explicit indentation indicator":"first line"}`;r(l-v.length-(A?2:1),"BAD_INDENT",z),b=""}if(o===BA.Scalar.BLOCK_LITERAL)d+=p+b.slice(c)+v,p=`
384
383
  `;else if(b.length>c||v[0]==="\t"){if(p===" ")p=`
@@ -393,41 +392,41 @@ ${l}
393
392
  `+s[g][0].slice(c);if(d[d.length-1]!==`
394
393
  `)d+=`
395
394
  `;break;default:d+=`
396
- `}let y=i+n.length+t.source.length;return{value:d,type:o,comment:n.comment,range:[i,y,y]}}function Eme({offset:e,props:t},r,i){if(t[0].type!=="block-scalar-header")return i(t[0],"IMPOSSIBLE","Block scalar header not found"),null;let{source:n}=t[0],o=n[0],s=0,a="",c=-1;for(let p=1;p<n.length;++p){let m=n[p];if(!a&&(m==="-"||m==="+"))a=m;else{let y=Number(m);if(!s&&y)s=y;else if(c===-1)c=e+p}}if(c!==-1)i(c,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${n}`);let l=!1,u="",d=n.length;for(let p=1;p<t.length;++p){let m=t[p];switch(m.type){case"space":l=!0;case"newline":d+=m.source.length;break;case"comment":if(r&&!l)i(m,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");d+=m.source.length,u=m.source.substring(1);break;case"error":i(m,"UNEXPECTED_TOKEN",m.message),d+=m.source.length;break;default:{let y=`Unexpected token in block scalar header: ${m.type}`;i(m,"UNEXPECTED_TOKEN",y);let g=m.source;if(g&&typeof g==="string")d+=g.length}}}return{mode:o,indent:s,chomp:a,comment:u,length:d}}function Ime(e){let t=e.split(/\n( *)/),r=t[0],i=r.match(/^( *)/),o=[i?.[1]?[i[1],r.slice(i[1].length)]:["",r]];for(let s=1;s<t.length;s+=2)o.push([t[s],t[s+1]]);return o}Ame.resolveBlockScalar=kme});var UA=ee(function(Lme){var qA=jt(),Cme=gl();function $me(e,t,r){let{offset:i,type:n,source:o,end:s}=e,a,c,l=(p,m,y)=>r(i+p,m,y);switch(n){case"scalar":a=qA.Scalar.PLAIN,c=Ome(o,l);break;case"single-quoted-scalar":a=qA.Scalar.QUOTE_SINGLE,c=Rme(o,l);break;case"double-quoted-scalar":a=qA.Scalar.QUOTE_DOUBLE,c=Pme(o,l);break;default:return r(e,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${n}`),{value:"",type:null,comment:"",range:[i,i+o.length,i+o.length]}}let u=i+o.length,d=Cme.resolveEnd(s,u,t,r);return{value:c,type:a,comment:d.comment,range:[i,u,d.offset]}}function Ome(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 eF(e)}function Rme(e,t){if(e[e.length-1]!=="'"||e.length===1)t(e.length,"MISSING_CHAR","Missing closing 'quote");return eF(e.slice(1,-1)).replace(/''/g,"'")}function eF(e){let t,r;try{t=new RegExp(`(.*?)(?<![ ])[ ]*\r?
395
+ `}let y=i+n.length+t.source.length;return{value:d,type:o,comment:n.comment,range:[i,y,y]}}function kme({offset:e,props:t},r,i){if(t[0].type!=="block-scalar-header")return i(t[0],"IMPOSSIBLE","Block scalar header not found"),null;let{source:n}=t[0],o=n[0],s=0,a="",c=-1;for(let p=1;p<n.length;++p){let m=n[p];if(!a&&(m==="-"||m==="+"))a=m;else{let y=Number(m);if(!s&&y)s=y;else if(c===-1)c=e+p}}if(c!==-1)i(c,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${n}`);let l=!1,u="",d=n.length;for(let p=1;p<t.length;++p){let m=t[p];switch(m.type){case"space":l=!0;case"newline":d+=m.source.length;break;case"comment":if(r&&!l)i(m,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");d+=m.source.length,u=m.source.substring(1);break;case"error":i(m,"UNEXPECTED_TOKEN",m.message),d+=m.source.length;break;default:{let y=`Unexpected token in block scalar header: ${m.type}`;i(m,"UNEXPECTED_TOKEN",y);let g=m.source;if(g&&typeof g==="string")d+=g.length}}}return{mode:o,indent:s,chomp:a,comment:u,length:d}}function Eme(e){let t=e.split(/\n( *)/),r=t[0],i=r.match(/^( *)/),o=[i?.[1]?[i[1],r.slice(i[1].length)]:["",r]];for(let s=1;s<t.length;s+=2)o.push([t[s],t[s+1]]);return o}Ime.resolveBlockScalar=_me});var UA=ee(function(Dme){var qA=jt(),Tme=gl();function Cme(e,t,r){let{offset:i,type:n,source:o,end:s}=e,a,c,l=(p,m,y)=>r(i+p,m,y);switch(n){case"scalar":a=qA.Scalar.PLAIN,c=$me(o,l);break;case"single-quoted-scalar":a=qA.Scalar.QUOTE_SINGLE,c=Ome(o,l);break;case"double-quoted-scalar":a=qA.Scalar.QUOTE_DOUBLE,c=Rme(o,l);break;default:return r(e,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${n}`),{value:"",type:null,comment:"",range:[i,i+o.length,i+o.length]}}let u=i+o.length,d=Tme.resolveEnd(s,u,t,r);return{value:c,type:a,comment:d.comment,range:[i,u,d.offset]}}function $me(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 eF(e)}function Ome(e,t){if(e[e.length-1]!=="'"||e.length===1)t(e.length,"MISSING_CHAR","Missing closing 'quote");return eF(e.slice(1,-1)).replace(/''/g,"'")}function eF(e){let t,r;try{t=new RegExp(`(.*?)(?<![ ])[ ]*\r?
397
396
  `,"sy"),r=new RegExp(`[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?
398
397
  `,"sy")}catch{t=/(.*?)[ \t]*\r?\n/sy,r=/[ \t]*(.*?)[ \t]*\r?\n/sy}let i=t.exec(e);if(!i)return e;let n=i[1],o=" ",s=t.lastIndex;r.lastIndex=s;while(i=r.exec(e)){if(i[1]==="")if(o===`
399
398
  `)n+=o;else o=`
400
- `;else n+=o+i[1],o=" ";s=r.lastIndex}let a=/[ \t]*(.*)/sy;return a.lastIndex=s,i=a.exec(e),n+o+(i?.[1]??"")}function Pme(e,t){let r="";for(let i=1;i<e.length-1;++i){let n=e[i];if(n==="\r"&&e[i+1]===`
399
+ `;else n+=o+i[1],o=" ";s=r.lastIndex}let a=/[ \t]*(.*)/sy;return a.lastIndex=s,i=a.exec(e),n+o+(i?.[1]??"")}function Rme(e,t){let r="";for(let i=1;i<e.length-1;++i){let n=e[i];if(n==="\r"&&e[i+1]===`
401
400
  `)continue;if(n===`
402
- `){let{fold:o,offset:s}=zme(e,i);r+=o,i=s}else if(n==="\\"){let o=e[++i],s=Nme[o];if(s)r+=s;else if(o===`
401
+ `){let{fold:o,offset:s}=Pme(e,i);r+=o,i=s}else if(n==="\\"){let o=e[++i],s=zme[o];if(s)r+=s;else if(o===`
403
402
  `){o=e[i+1];while(o===" "||o==="\t")o=e[++i+1]}else if(o==="\r"&&e[i+1]===`
404
- `){o=e[++i+1];while(o===" "||o==="\t")o=e[++i+1]}else if(o==="x"||o==="u"||o==="U"){let a=o==="x"?2:o==="u"?4:8;r+=Dme(e,i+1,a,t),i+=a}else{let a=e.substr(i-1,2);t(i-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),r+=a}}else if(n===" "||n==="\t"){let o=i,s=e[i+1];while(s===" "||s==="\t")s=e[++i+1];if(s!==`
403
+ `){o=e[++i+1];while(o===" "||o==="\t")o=e[++i+1]}else if(o==="x"||o==="u"||o==="U"){let a=o==="x"?2:o==="u"?4:8;r+=Nme(e,i+1,a,t),i+=a}else{let a=e.substr(i-1,2);t(i-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),r+=a}}else if(n===" "||n==="\t"){let o=i,s=e[i+1];while(s===" "||s==="\t")s=e[++i+1];if(s!==`
405
404
  `&&!(s==="\r"&&e[i+2]===`
406
- `))r+=i>o?e.slice(o,i+1):n}else r+=n}if(e[e.length-1]!=='"'||e.length===1)t(e.length,"MISSING_CHAR",'Missing closing "quote');return r}function zme(e,t){let r="",i=e[t+1];while(i===" "||i==="\t"||i===`
405
+ `))r+=i>o?e.slice(o,i+1):n}else r+=n}if(e[e.length-1]!=='"'||e.length===1)t(e.length,"MISSING_CHAR",'Missing closing "quote');return r}function Pme(e,t){let r="",i=e[t+1];while(i===" "||i==="\t"||i===`
407
406
  `||i==="\r"){if(i==="\r"&&e[t+2]!==`
408
407
  `)break;if(i===`
409
408
  `)r+=`
410
- `;t+=1,i=e[t+1]}if(!r)r=" ";return{fold:r,offset:t}}var Nme={"0":"\x00",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
411
- `,r:"\r",t:"\t",v:"\v",N:"\x85",_:"\xA0",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\","\t":"\t"};function Dme(e,t,r,i){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 i(t-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),a}}Lme.resolveFlowScalar=$me});var rF=ee(function(Zme){var fa=Ge(),tF=jt(),jme=jA(),qme=UA();function Ume(e,t,r,i){let{value:n,type:o,comment:s,range:a}=t.type==="block-scalar"?jme.resolveBlockScalar(e,t,i):qme.resolveFlowScalar(t,e.options.strict,i),c=r?e.directives.tagName(r.source,(d)=>i(r,"TAG_RESOLVE_FAILED",d)):null,l;if(e.options.stringKeys&&e.atKey)l=e.schema[fa.SCALAR];else if(c)l=Mme(e.schema,n,c,r,i);else if(t.type==="scalar")l=Fme(e,n,t,i);else l=e.schema[fa.SCALAR];let u;try{let d=l.resolve(n,(p)=>i(r??t,"TAG_RESOLVE_FAILED",p),e.options);u=fa.isScalar(d)?d:new tF.Scalar(d)}catch(d){let p=d instanceof Error?d.message:String(d);i(r??t,"TAG_RESOLVE_FAILED",p),u=new tF.Scalar(n)}if(u.range=a,u.source=n,o)u.type=o;if(c)u.tag=c;if(l.format)u.format=l.format;if(s)u.comment=s;return u}function Mme(e,t,r,i,n){if(r==="!")return e[fa.SCALAR];let o=[];for(let a of e.tags)if(!a.collection&&a.tag===r)if(a.default&&a.test)o.push(a);else return a;for(let a of o)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(i,"TAG_RESOLVE_FAILED",`Unresolved tag: ${r}`,r!=="tag:yaml.org,2002:str"),e[fa.SCALAR]}function Fme({atKey:e,directives:t,schema:r},i,n,o){let s=r.tags.find((a)=>(a.default===!0||e&&a.default==="key")&&a.test?.test(i))||r[fa.SCALAR];if(r.compat){let a=r.compat.find((c)=>c.default&&c.test?.test(i))??r[fa.SCALAR];if(s.tag!==a.tag){let c=t.tagString(s.tag),l=t.tagString(a.tag),u=`Value may be parsed as either ${c} or ${l}`;o(n,"TAG_RESOLVE_FAILED",u,!0)}}return s}Zme.composeScalar=Ume});var nF=ee(function(Jme){function Kme(e,t,r){if(t){r??(r=t.length);for(let i=r-1;i>=0;--i){let n=t[i];switch(n.type){case"space":case"comment":case"newline":e-=n.source.length;continue}n=t[++i];while(n?.type==="space")e+=n.source.length,n=t[++i];break}}return e}Jme.emptyScalarPosition=Kme});var sF=ee(function(rhe){var Wme=Kd(),Gme=Ge(),Qme=XM(),iF=rF(),Yme=gl(),Xme=nF(),ehe={composeNode:oF,composeEmptyNode:MA};function oF(e,t,r,i){let n=e.atKey,{spaceBefore:o,comment:s,anchor:a,tag:c}=r,l,u=!0;switch(t.type){case"alias":if(l=the(e,t,i),a||c)i(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(l=iF.composeScalar(e,t,c,i),a)l.anchor=a.source.substring(1);break;case"block-map":case"block-seq":case"flow-collection":try{if(l=Qme.composeCollection(ehe,e,t,r,i),a)l.anchor=a.source.substring(1)}catch(d){let p=d instanceof Error?d.message:String(d);i(t,"RESOURCE_EXHAUSTION",p)}break;default:{let d=t.type==="error"?t.message:`Unsupported token (type: ${t.type})`;i(t,"UNEXPECTED_TOKEN",d),u=!1}}if(l??(l=MA(e,t.offset,void 0,null,r,i)),a&&l.anchor==="")i(a,"BAD_ALIAS","Anchor cannot be an empty string");if(n&&e.options.stringKeys&&(!Gme.isScalar(l)||typeof l.value!=="string"||l.tag&&l.tag!=="tag:yaml.org,2002:str"))i(c??t,"NON_STRING_KEY","With stringKeys, all keys must be strings");if(o)l.spaceBefore=!0;if(s)if(t.type==="scalar"&&t.source==="")l.comment=s;else l.commentBefore=s;if(e.options.keepSourceTokens&&u)l.srcToken=t;return l}function MA(e,t,r,i,{spaceBefore:n,comment:o,anchor:s,tag:a,end:c},l){let u={type:"scalar",offset:Xme.emptyScalarPosition(t,r,i),indent:-1,source:""},d=iF.composeScalar(e,u,a,l);if(s){if(d.anchor=s.source.substring(1),d.anchor==="")l(s,"BAD_ALIAS","Anchor cannot be an empty string")}if(n)d.spaceBefore=!0;if(o)d.comment=o,d.range[2]=c;return d}function the({options:e},{offset:t,source:r,end:i},n){let o=new Wme.Alias(r.substring(1));if(o.source==="")n(t,"BAD_ALIAS","Alias cannot be an empty string");if(o.source.endsWith(":"))n(t+r.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let s=t+r.length,a=Yme.resolveEnd(i,s,e.strict,n);if(o.range=[t,s,a.offset],a.comment)o.comment=a.comment;return o}rhe.composeEmptyNode=MA;rhe.composeNode=oF});var cF=ee(function(lhe){var ohe=af(),aF=sF(),she=gl(),ahe=lf();function che(e,t,{offset:r,start:i,value:n,end:o},s){let a=Object.assign({_directives:t},e),c=new ohe.Document(void 0,a),l={atKey:!1,atRoot:!0,directives:c.directives,options:c.options,schema:c.schema},u=ahe.resolveProps(i,{indicator:"doc-start",next:n??o?.[0],offset:r,onError:s,parentIndent:0,startOnNewline:!0});if(u.found){if(c.directives.docStart=!0,n&&(n.type==="block-map"||n.type==="block-seq")&&!u.hasNewline)s(u.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")}c.contents=n?aF.composeNode(l,n,u,s):aF.composeEmptyNode(l,u.end,i,null,u,s);let d=c.contents.range[2],p=she.resolveEnd(o,d,!1,s);if(p.comment)c.comment=p.comment;return c.range=[r,d,p.offset],c}lhe.composeDoc=che});var FA=ee(function(ghe){var dhe=Tt("process"),fhe=JI(),phe=af(),uf=cf(),lF=Ge(),mhe=cF(),hhe=gl();function df(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 uF(e){let t="",r=!1,i=!1;for(let n=0;n<e.length;++n){let o=e[n];switch(o[0]){case"#":t+=(t===""?"":i?`
409
+ `;t+=1,i=e[t+1]}if(!r)r=" ";return{fold:r,offset:t}}var zme={"0":"\x00",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
410
+ `,r:"\r",t:"\t",v:"\v",N:"\x85",_:"\xA0",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\","\t":"\t"};function Nme(e,t,r,i){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 i(t-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),a}}Dme.resolveFlowScalar=Cme});var rF=ee(function(Fme){var fa=Ge(),tF=jt(),Bme=jA(),jme=UA();function qme(e,t,r,i){let{value:n,type:o,comment:s,range:a}=t.type==="block-scalar"?Bme.resolveBlockScalar(e,t,i):jme.resolveFlowScalar(t,e.options.strict,i),c=r?e.directives.tagName(r.source,(d)=>i(r,"TAG_RESOLVE_FAILED",d)):null,l;if(e.options.stringKeys&&e.atKey)l=e.schema[fa.SCALAR];else if(c)l=Ume(e.schema,n,c,r,i);else if(t.type==="scalar")l=Mme(e,n,t,i);else l=e.schema[fa.SCALAR];let u;try{let d=l.resolve(n,(p)=>i(r??t,"TAG_RESOLVE_FAILED",p),e.options);u=fa.isScalar(d)?d:new tF.Scalar(d)}catch(d){let p=d instanceof Error?d.message:String(d);i(r??t,"TAG_RESOLVE_FAILED",p),u=new tF.Scalar(n)}if(u.range=a,u.source=n,o)u.type=o;if(c)u.tag=c;if(l.format)u.format=l.format;if(s)u.comment=s;return u}function Ume(e,t,r,i,n){if(r==="!")return e[fa.SCALAR];let o=[];for(let a of e.tags)if(!a.collection&&a.tag===r)if(a.default&&a.test)o.push(a);else return a;for(let a of o)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(i,"TAG_RESOLVE_FAILED",`Unresolved tag: ${r}`,r!=="tag:yaml.org,2002:str"),e[fa.SCALAR]}function Mme({atKey:e,directives:t,schema:r},i,n,o){let s=r.tags.find((a)=>(a.default===!0||e&&a.default==="key")&&a.test?.test(i))||r[fa.SCALAR];if(r.compat){let a=r.compat.find((c)=>c.default&&c.test?.test(i))??r[fa.SCALAR];if(s.tag!==a.tag){let c=t.tagString(s.tag),l=t.tagString(a.tag),u=`Value may be parsed as either ${c} or ${l}`;o(n,"TAG_RESOLVE_FAILED",u,!0)}}return s}Fme.composeScalar=qme});var nF=ee(function(Kme){function Hme(e,t,r){if(t){r??(r=t.length);for(let i=r-1;i>=0;--i){let n=t[i];switch(n.type){case"space":case"comment":case"newline":e-=n.source.length;continue}n=t[++i];while(n?.type==="space")e+=n.source.length,n=t[++i];break}}return e}Kme.emptyScalarPosition=Hme});var sF=ee(function(the){var Vme=Kd(),Wme=Ge(),Gme=XM(),iF=rF(),Qme=gl(),Yme=nF(),Xme={composeNode:oF,composeEmptyNode:MA};function oF(e,t,r,i){let n=e.atKey,{spaceBefore:o,comment:s,anchor:a,tag:c}=r,l,u=!0;switch(t.type){case"alias":if(l=ehe(e,t,i),a||c)i(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(l=iF.composeScalar(e,t,c,i),a)l.anchor=a.source.substring(1);break;case"block-map":case"block-seq":case"flow-collection":try{if(l=Gme.composeCollection(Xme,e,t,r,i),a)l.anchor=a.source.substring(1)}catch(d){let p=d instanceof Error?d.message:String(d);i(t,"RESOURCE_EXHAUSTION",p)}break;default:{let d=t.type==="error"?t.message:`Unsupported token (type: ${t.type})`;i(t,"UNEXPECTED_TOKEN",d),u=!1}}if(l??(l=MA(e,t.offset,void 0,null,r,i)),a&&l.anchor==="")i(a,"BAD_ALIAS","Anchor cannot be an empty string");if(n&&e.options.stringKeys&&(!Wme.isScalar(l)||typeof l.value!=="string"||l.tag&&l.tag!=="tag:yaml.org,2002:str"))i(c??t,"NON_STRING_KEY","With stringKeys, all keys must be strings");if(o)l.spaceBefore=!0;if(s)if(t.type==="scalar"&&t.source==="")l.comment=s;else l.commentBefore=s;if(e.options.keepSourceTokens&&u)l.srcToken=t;return l}function MA(e,t,r,i,{spaceBefore:n,comment:o,anchor:s,tag:a,end:c},l){let u={type:"scalar",offset:Yme.emptyScalarPosition(t,r,i),indent:-1,source:""},d=iF.composeScalar(e,u,a,l);if(s){if(d.anchor=s.source.substring(1),d.anchor==="")l(s,"BAD_ALIAS","Anchor cannot be an empty string")}if(n)d.spaceBefore=!0;if(o)d.comment=o,d.range[2]=c;return d}function ehe({options:e},{offset:t,source:r,end:i},n){let o=new Vme.Alias(r.substring(1));if(o.source==="")n(t,"BAD_ALIAS","Alias cannot be an empty string");if(o.source.endsWith(":"))n(t+r.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let s=t+r.length,a=Qme.resolveEnd(i,s,e.strict,n);if(o.range=[t,s,a.offset],a.comment)o.comment=a.comment;return o}the.composeEmptyNode=MA;the.composeNode=oF});var cF=ee(function(che){var ihe=af(),aF=sF(),ohe=gl(),she=lf();function ahe(e,t,{offset:r,start:i,value:n,end:o},s){let a=Object.assign({_directives:t},e),c=new ihe.Document(void 0,a),l={atKey:!1,atRoot:!0,directives:c.directives,options:c.options,schema:c.schema},u=she.resolveProps(i,{indicator:"doc-start",next:n??o?.[0],offset:r,onError:s,parentIndent:0,startOnNewline:!0});if(u.found){if(c.directives.docStart=!0,n&&(n.type==="block-map"||n.type==="block-seq")&&!u.hasNewline)s(u.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")}c.contents=n?aF.composeNode(l,n,u,s):aF.composeEmptyNode(l,u.end,i,null,u,s);let d=c.contents.range[2],p=ohe.resolveEnd(o,d,!1,s);if(p.comment)c.comment=p.comment;return c.range=[r,d,p.offset],c}che.composeDoc=ahe});var FA=ee(function(hhe){var uhe=Tt("process"),dhe=JI(),fhe=af(),uf=cf(),lF=Ge(),phe=cF(),mhe=gl();function df(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 uF(e){let t="",r=!1,i=!1;for(let n=0;n<e.length;++n){let o=e[n];switch(o[0]){case"#":t+=(t===""?"":i?`
412
411
 
413
412
  `:`
414
- `)+(o.substring(1)||" "),r=!0,i=!1;break;case"%":if(e[n+1]?.[0]!=="#")n+=1;r=!1;break;default:if(!r)i=!0;r=!1}}return{comment:t,afterEmptyLine:i}}class dF{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(t,r,i,n)=>{let o=df(t);if(n)this.warnings.push(new uf.YAMLWarning(o,r,i));else this.errors.push(new uf.YAMLParseError(o,r,i))},this.directives=new fhe.Directives({version:e.version||"1.2"}),this.options=e}decorate(e,t){let{comment:r,afterEmptyLine:i}=uF(this.prelude);if(r){let n=e.contents;if(t)e.comment=e.comment?`${e.comment}
413
+ `)+(o.substring(1)||" "),r=!0,i=!1;break;case"%":if(e[n+1]?.[0]!=="#")n+=1;r=!1;break;default:if(!r)i=!0;r=!1}}return{comment:t,afterEmptyLine:i}}class dF{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(t,r,i,n)=>{let o=df(t);if(n)this.warnings.push(new uf.YAMLWarning(o,r,i));else this.errors.push(new uf.YAMLParseError(o,r,i))},this.directives=new dhe.Directives({version:e.version||"1.2"}),this.options=e}decorate(e,t){let{comment:r,afterEmptyLine:i}=uF(this.prelude);if(r){let n=e.contents;if(t)e.comment=e.comment?`${e.comment}
415
414
  ${r}`:r;else if(i||e.directives.docStart||!n)e.commentBefore=r;else if(lF.isCollection(n)&&!n.flow&&n.items.length>0){let o=n.items[0];if(lF.isPair(o))o=o.key;let s=o.commentBefore;o.commentBefore=s?`${r}
416
415
  ${s}`:r}else{let o=n.commentBefore;n.commentBefore=o?`${r}
417
- ${o}`: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:uF(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,r=-1){for(let i of e)yield*this.next(i);yield*this.end(t,r)}*next(e){if(dhe.env.LOG_STREAM)console.dir(e,{depth:null});switch(e.type){case"directive":this.directives.add(e.source,(t,r,i)=>{let n=df(e);n[0]+=t,this.onError(n,"BAD_DIRECTIVE",r,i)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let t=mhe.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 uf.YAMLParseError(df(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 uf.YAMLParseError(df(e),"UNEXPECTED_TOKEN","Unexpected doc-end without preceding document"));break}this.doc.directives.docEnd=!0;let t=hhe.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}
418
- ${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new uf.YAMLParseError(df(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),i=new phe.Document(void 0,r);if(this.atDirectives)this.onError(t,"MISSING_CHAR","Missing directives-end indicator line");i.range=[0,t,t],this.decorate(i,!1),yield i}}}ghe.Composer=dF});var mF=ee(function(Ehe){var bhe=jA(),xhe=UA(),She=cf(),fF=Gd();function whe(e,t=!0,r){if(e){let i=(n,o,s)=>{let a=typeof n==="number"?n:Array.isArray(n)?n[0]:n.offset;if(r)r(a,o,s);else throw new She.YAMLParseError([a,a+1],o,s)};switch(e.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return xhe.resolveFlowScalar(e,t,i);case"block-scalar":return bhe.resolveBlockScalar({options:{strict:t}},e,i)}}return null}function vhe(e,t){let{implicitKey:r=!1,indent:i,inFlow:n=!1,offset:o=-1,type:s="PLAIN"}=t,a=fF.stringifyString({type:s,value:e},{implicitKey:r,indent:i>0?" ".repeat(i):"",inFlow:n,options:{blockQuote:!0,lineWidth:-1}}),c=t.end??[{type:"newline",offset:-1,indent:i,source:`
416
+ ${o}`: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:uF(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,r=-1){for(let i of e)yield*this.next(i);yield*this.end(t,r)}*next(e){if(uhe.env.LOG_STREAM)console.dir(e,{depth:null});switch(e.type){case"directive":this.directives.add(e.source,(t,r,i)=>{let n=df(e);n[0]+=t,this.onError(n,"BAD_DIRECTIVE",r,i)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let t=phe.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 uf.YAMLParseError(df(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 uf.YAMLParseError(df(e),"UNEXPECTED_TOKEN","Unexpected doc-end without preceding document"));break}this.doc.directives.docEnd=!0;let t=mhe.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}
417
+ ${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new uf.YAMLParseError(df(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),i=new fhe.Document(void 0,r);if(this.atDirectives)this.onError(t,"MISSING_CHAR","Missing directives-end indicator line");i.range=[0,t,t],this.decorate(i,!1),yield i}}}hhe.Composer=dF});var mF=ee(function(khe){var yhe=jA(),bhe=UA(),xhe=cf(),fF=Gd();function She(e,t=!0,r){if(e){let i=(n,o,s)=>{let a=typeof n==="number"?n:Array.isArray(n)?n[0]:n.offset;if(r)r(a,o,s);else throw new xhe.YAMLParseError([a,a+1],o,s)};switch(e.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return bhe.resolveFlowScalar(e,t,i);case"block-scalar":return yhe.resolveBlockScalar({options:{strict:t}},e,i)}}return null}function whe(e,t){let{implicitKey:r=!1,indent:i,inFlow:n=!1,offset:o=-1,type:s="PLAIN"}=t,a=fF.stringifyString({type:s,value:e},{implicitKey:r,indent:i>0?" ".repeat(i):"",inFlow:n,options:{blockQuote:!0,lineWidth:-1}}),c=t.end??[{type:"newline",offset:-1,indent:i,source:`
419
418
  `}];switch(a[0]){case"|":case">":{let l=a.indexOf(`
420
419
  `),u=a.substring(0,l),d=a.substring(l+1)+`
421
420
  `,p=[{type:"block-scalar-header",offset:o,indent:i,source:u}];if(!pF(p,c))p.push({type:"newline",offset:-1,indent:i,source:`
422
- `});return{type:"block-scalar",offset:o,indent:i,props:p,source:d}}case'"':return{type:"double-quoted-scalar",offset:o,indent:i,source:a,end:c};case"'":return{type:"single-quoted-scalar",offset:o,indent:i,source:a,end:c};default:return{type:"scalar",offset:o,indent:i,source:a,end:c}}}function _he(e,t,r={}){let{afterKey:i=!1,implicitKey:n=!1,inFlow:o=!1,type:s}=r,a="indent"in e?e.indent:null;if(i&&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 l=e.props[0];if(l.type!=="block-scalar-header")throw Error("Invalid block scalar header");s=l.source[0]===">"?"BLOCK_FOLDED":"BLOCK_LITERAL";break}default:s="PLAIN"}let c=fF.stringifyString({type:s,value:t},{implicitKey:n||a===null,indent:a!==null&&a>0?" ".repeat(a):"",inFlow:o,options:{blockQuote:!0,lineWidth:-1}});switch(c[0]){case"|":case">":khe(e,c);break;case'"':ZA(e,c,"double-quoted-scalar");break;case"'":ZA(e,c,"single-quoted-scalar");break;default:ZA(e,c,"scalar")}}function khe(e,t){let r=t.indexOf(`
421
+ `});return{type:"block-scalar",offset:o,indent:i,props:p,source:d}}case'"':return{type:"double-quoted-scalar",offset:o,indent:i,source:a,end:c};case"'":return{type:"single-quoted-scalar",offset:o,indent:i,source:a,end:c};default:return{type:"scalar",offset:o,indent:i,source:a,end:c}}}function vhe(e,t,r={}){let{afterKey:i=!1,implicitKey:n=!1,inFlow:o=!1,type:s}=r,a="indent"in e?e.indent:null;if(i&&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 l=e.props[0];if(l.type!=="block-scalar-header")throw Error("Invalid block scalar header");s=l.source[0]===">"?"BLOCK_FOLDED":"BLOCK_LITERAL";break}default:s="PLAIN"}let c=fF.stringifyString({type:s,value:t},{implicitKey:n||a===null,indent:a!==null&&a>0?" ".repeat(a):"",inFlow:o,options:{blockQuote:!0,lineWidth:-1}});switch(c[0]){case"|":case">":_he(e,c);break;case'"':ZA(e,c,"double-quoted-scalar");break;case"'":ZA(e,c,"single-quoted-scalar");break;default:ZA(e,c,"scalar")}}function _he(e,t){let r=t.indexOf(`
423
422
  `),i=t.substring(0,r),n=t.substring(r+1)+`
424
423
  `;if(e.type==="block-scalar"){let o=e.props[0];if(o.type!=="block-scalar-header")throw Error("Invalid block scalar header");o.source=i,e.source=n}else{let{offset:o}=e,s="indent"in e?e.indent:-1,a=[{type:"block-scalar-header",offset:o,indent:s,source:i}];if(!pF(a,"end"in e?e.end:void 0))a.push({type:"newline",offset:-1,indent:s,source:`
425
424
  `});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 pF(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 ZA(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 i=e.props.slice(1),n=t.length;if(e.props[0].type==="block-scalar-header")n-=e.props[0].source.length;for(let o of i)o.offset+=n;delete e.props,Object.assign(e,{type:r,source:t,end:i});break}case"block-map":case"block-seq":{let n={type:"newline",offset:e.offset+t.length,indent:e.indent,source:`
426
- `};delete e.items,Object.assign(e,{type:r,source:t,end:[n]});break}default:{let i="indent"in e?e.indent:-1,n="end"in e&&Array.isArray(e.end)?e.end.filter((o)=>o.type==="space"||o.type==="comment"||o.type==="newline"):[];for(let o of Object.keys(e))if(o!=="type"&&o!=="offset")delete e[o];Object.assign(e,{type:r,indent:i,source:t,end:n})}}}Ehe.createScalarToken=vhe;Ehe.resolveAsScalar=whe;Ehe.setScalarValue=_he});var hF=ee(function($he){var Che=(e)=>("type"in e)?Cy(e):Ty(e);function Cy(e){switch(e.type){case"block-scalar":{let t="";for(let r of e.props)t+=Cy(r);return t+e.source}case"block-map":case"block-seq":{let t="";for(let r of e.items)t+=Ty(r);return t}case"flow-collection":{let t=e.start.source;for(let r of e.items)t+=Ty(r);for(let r of e.end)t+=r.source;return t}case"document":{let t=Ty(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 Ty({start:e,key:t,sep:r,value:i}){let n="";for(let o of e)n+=o.source;if(t)n+=Cy(t);if(r)for(let o of r)n+=o.source;if(i)n+=Cy(i);return n}$he.stringify=Che});var bF=ee(function(Phe){var HA=Symbol("break visit"),Rhe=Symbol("skip children"),gF=Symbol("remove item");function pa(e,t){if("type"in e&&e.type==="document")e={start:e.start,value:e.value};yF(Object.freeze([]),e,t)}pa.BREAK=HA;pa.SKIP=Rhe;pa.REMOVE=gF;pa.itemAtPath=(e,t)=>{let r=e;for(let[i,n]of t){let o=r?.[i];if(o&&"items"in o)r=o.items[n];else return}return r};pa.parentCollection=(e,t)=>{let r=pa.itemAtPath(e,t.slice(0,-1)),i=t[t.length-1][0],n=r?.[i];if(n&&"items"in n)return n;throw Error("Parent collection not found")};function yF(e,t,r){let i=r(t,e);if(typeof i==="symbol")return i;for(let n of["key","value"]){let o=t[n];if(o&&"items"in o){for(let s=0;s<o.items.length;++s){let a=yF(Object.freeze(e.concat([[n,s]])),o.items[s],r);if(typeof a==="number")s=a-1;else if(a===HA)return HA;else if(a===gF)o.items.splice(s,1),s-=1}if(typeof i==="function"&&n==="key")i=i(t,e)}}return typeof i==="function"?i(t,e):i}Phe.visit=pa});var $y=ee(function(Uhe){var KA=mF(),Nhe=hF(),Dhe=bF(),JA="\uFEFF",VA="\x02",WA="\x18",GA="\x1F",Lhe=(e)=>!!e&&("items"in e),Bhe=(e)=>!!e&&(e.type==="scalar"||e.type==="single-quoted-scalar"||e.type==="double-quoted-scalar"||e.type==="block-scalar");function jhe(e){switch(e){case JA:return"<BOM>";case VA:return"<DOC>";case WA:return"<FLOW_END>";case GA:return"<SCALAR>";default:return JSON.stringify(e)}}function qhe(e){switch(e){case JA:return"byte-order-mark";case VA:return"doc-mode";case WA:return"flow-error-end";case GA:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
425
+ `};delete e.items,Object.assign(e,{type:r,source:t,end:[n]});break}default:{let i="indent"in e?e.indent:-1,n="end"in e&&Array.isArray(e.end)?e.end.filter((o)=>o.type==="space"||o.type==="comment"||o.type==="newline"):[];for(let o of Object.keys(e))if(o!=="type"&&o!=="offset")delete e[o];Object.assign(e,{type:r,indent:i,source:t,end:n})}}}khe.createScalarToken=whe;khe.resolveAsScalar=She;khe.setScalarValue=vhe});var hF=ee(function(Che){var The=(e)=>("type"in e)?Cy(e):Ty(e);function Cy(e){switch(e.type){case"block-scalar":{let t="";for(let r of e.props)t+=Cy(r);return t+e.source}case"block-map":case"block-seq":{let t="";for(let r of e.items)t+=Ty(r);return t}case"flow-collection":{let t=e.start.source;for(let r of e.items)t+=Ty(r);for(let r of e.end)t+=r.source;return t}case"document":{let t=Ty(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 Ty({start:e,key:t,sep:r,value:i}){let n="";for(let o of e)n+=o.source;if(t)n+=Cy(t);if(r)for(let o of r)n+=o.source;if(i)n+=Cy(i);return n}Che.stringify=The});var bF=ee(function(Rhe){var HA=Symbol("break visit"),Ohe=Symbol("skip children"),gF=Symbol("remove item");function pa(e,t){if("type"in e&&e.type==="document")e={start:e.start,value:e.value};yF(Object.freeze([]),e,t)}pa.BREAK=HA;pa.SKIP=Ohe;pa.REMOVE=gF;pa.itemAtPath=(e,t)=>{let r=e;for(let[i,n]of t){let o=r?.[i];if(o&&"items"in o)r=o.items[n];else return}return r};pa.parentCollection=(e,t)=>{let r=pa.itemAtPath(e,t.slice(0,-1)),i=t[t.length-1][0],n=r?.[i];if(n&&"items"in n)return n;throw Error("Parent collection not found")};function yF(e,t,r){let i=r(t,e);if(typeof i==="symbol")return i;for(let n of["key","value"]){let o=t[n];if(o&&"items"in o){for(let s=0;s<o.items.length;++s){let a=yF(Object.freeze(e.concat([[n,s]])),o.items[s],r);if(typeof a==="number")s=a-1;else if(a===HA)return HA;else if(a===gF)o.items.splice(s,1),s-=1}if(typeof i==="function"&&n==="key")i=i(t,e)}}return typeof i==="function"?i(t,e):i}Rhe.visit=pa});var $y=ee(function(qhe){var KA=mF(),zhe=hF(),Nhe=bF(),JA="\uFEFF",VA="\x02",WA="\x18",GA="\x1F",Dhe=(e)=>!!e&&("items"in e),Lhe=(e)=>!!e&&(e.type==="scalar"||e.type==="single-quoted-scalar"||e.type==="double-quoted-scalar"||e.type==="block-scalar");function Bhe(e){switch(e){case JA:return"<BOM>";case VA:return"<DOC>";case WA:return"<FLOW_END>";case GA:return"<SCALAR>";default:return JSON.stringify(e)}}function jhe(e){switch(e){case JA:return"byte-order-mark";case VA:return"doc-mode";case WA:return"flow-error-end";case GA:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
427
426
  `:case`\r
428
- `: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}Uhe.createScalarToken=KA.createScalarToken;Uhe.resolveAsScalar=KA.resolveAsScalar;Uhe.setScalarValue=KA.setScalarValue;Uhe.stringify=Nhe.stringify;Uhe.visit=Dhe.visit;Uhe.BOM=JA;Uhe.DOCUMENT=VA;Uhe.FLOW_END=WA;Uhe.SCALAR=GA;Uhe.isCollection=Lhe;Uhe.isScalar=Bhe;Uhe.prettyToken=jhe;Uhe.tokenType=qhe});var YA=ee(function(nge){var ff=$y();function qn(e){switch(e){case void 0:case" ":case`
429
- `:case"\r":case"\t":return!0;default:return!1}}var xF=new Set("0123456789ABCDEFabcdef"),tge=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),Oy=new Set(",[]{}"),rge=new Set(` ,[]{}
430
- \r `),QA=(e)=>!e||rge.has(e);class SF{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===`
427
+ `: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}qhe.createScalarToken=KA.createScalarToken;qhe.resolveAsScalar=KA.resolveAsScalar;qhe.setScalarValue=KA.setScalarValue;qhe.stringify=zhe.stringify;qhe.visit=Nhe.visit;qhe.BOM=JA;qhe.DOCUMENT=VA;qhe.FLOW_END=WA;qhe.SCALAR=GA;qhe.isCollection=Dhe;qhe.isScalar=Lhe;qhe.prettyToken=Bhe;qhe.tokenType=jhe});var YA=ee(function(rge){var ff=$y();function qn(e){switch(e){case void 0:case" ":case`
428
+ `:case"\r":case"\t":return!0;default:return!1}}var xF=new Set("0123456789ABCDEFabcdef"),ege=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),Oy=new Set(",[]{}"),tge=new Set(` ,[]{}
429
+ \r `),QA=(e)=>!e||tge.has(e);class SF{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===`
431
430
  `)return!0;if(t==="\r")return this.buffer[e+1]===`
432
431
  `;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 i=this.buffer[r+e+1];if(i===`
433
432
  `||!i&&!this.atEnd)return e+r+1}return t===`
@@ -442,15 +441,15 @@ ${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.pus
442
441
  `&&n>=this.pos&&n+1+t>s)e=n;else break}while(!0);return yield ff.SCALAR,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e=this.flowLevel>0,t=this.pos-1,r=this.pos-1,i;while(i=this.buffer[++r])if(i===":"){let n=this.buffer[r+1];if(qn(n)||e&&Oy.has(n))break;t=r}else if(qn(i)){let n=this.buffer[r+1];if(i==="\r")if(n===`
443
442
  `)r+=1,i=`
444
443
  `,n=this.buffer[r+1];else t=r;if(n==="#"||e&&Oy.has(n))break;if(i===`
445
- `){let o=this.continueScalar(r+1);if(o===-1)break;r=Math.max(r,o-2)}}else{if(e&&Oy.has(i))break;t=r}if(!i&&!this.atEnd)return this.setNext("plain-scalar");return yield ff.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(QA),e+=yield*this.pushSpaces(!0);continue e;case"-":case"?":case":":{let t=this.flowLevel>0,r=this.charAt(1);if(qn(r)||t&&Oy.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(!qn(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(tge.has(t))t=this.buffer[++e];else if(t==="%"&&xF.has(this.buffer[e+1])&&xF.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===`
444
+ `){let o=this.continueScalar(r+1);if(o===-1)break;r=Math.max(r,o-2)}}else{if(e&&Oy.has(i))break;t=r}if(!i&&!this.atEnd)return this.setNext("plain-scalar");return yield ff.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(QA),e+=yield*this.pushSpaces(!0);continue e;case"-":case"?":case":":{let t=this.flowLevel>0,r=this.charAt(1);if(qn(r)||t&&Oy.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(!qn(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(ege.has(t))t=this.buffer[++e];else if(t==="%"&&xF.has(this.buffer[e+1])&&xF.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===`
446
445
  `)return yield*this.pushCount(1);else if(e==="\r"&&this.charAt(1)===`
447
- `)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 i=t-this.pos;if(i>0)yield this.buffer.substr(this.pos,i),this.pos=t;return i}*pushUntil(e){let t=this.pos,r=this.buffer[t];while(!e(r))r=this.buffer[++t];return yield*this.pushToIndex(t,!1)}}nge.Lexer=SF});var XA=ee(function(oge){class wF{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 i=this.lineStarts[t-1];return{line:t,col:e-i+1}}}}oge.LineCounter=wF});var eT=ee(function(lge){var age=Tt("process"),vF=$y(),cge=YA();function Jo(e,t){for(let r=0;r<e.length;++r)if(e[r].type===t)return!0;return!1}function _F(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 EF(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 Ry(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 yl(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 Py(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 kF(e){if(e.start.type==="flow-seq-start"){for(let t of e.items)if(t.sep&&!t.value&&!Jo(t.start,"explicit-key-ind")&&!Jo(t.sep,"map-value-ind")){if(t.key)t.value=t.key;if(delete t.key,EF(t.value))if(t.value.end)Py(t.value.end,t.sep);else t.value.end=t.sep;else Py(t.start,t.sep);delete t.sep}}}class IF{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 cge.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,age.env.LOG_TOKENS)console.log("|",vF.prettyToken(e));if(this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let t=vF.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")kF(t);switch(r.type){case"document":r.value=t;break;case"block-scalar":r.props.push(t);break;case"block-map":{let i=r.items[r.items.length-1];if(i.value){r.items.push({start:[],key:t,sep:[]}),this.onKeyLine=!0;return}else if(i.sep)i.value=t;else{Object.assign(i,{key:t,sep:[]}),this.onKeyLine=!i.explicitKey;return}break}case"block-seq":{let i=r.items[r.items.length-1];if(i.value)r.items.push({start:[],value:t});else i.value=t;break}case"flow-collection":{let i=r.items[r.items.length-1];if(!i||i.value)r.items.push({start:[],key:t,sep:[]});else if(i.sep)i.value=t;else Object.assign(i,{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 i=t.items[t.items.length-1];if(i&&!i.sep&&!i.value&&i.start.length>0&&_F(i.start)===-1&&(t.indent===0||i.start.every((n)=>n.type!=="comment"||n.indent<t.indent))){if(r.type==="document")r.end=i.start;else r.items.push({start:i.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(_F(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=Ry(this.peek(2)),r=yl(t),i;if(e.end)i=e.end,i.push(this.sourceToken),delete e.end;else i=[this.sourceToken];let n={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:r,key:e,sep:i}]};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(`
446
+ `)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 i=t-this.pos;if(i>0)yield this.buffer.substr(this.pos,i),this.pos=t;return i}*pushUntil(e){let t=this.pos,r=this.buffer[t];while(!e(r))r=this.buffer[++t];return yield*this.pushToIndex(t,!1)}}rge.Lexer=SF});var XA=ee(function(ige){class wF{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 i=this.lineStarts[t-1];return{line:t,col:e-i+1}}}}ige.LineCounter=wF});var eT=ee(function(cge){var sge=Tt("process"),vF=$y(),age=YA();function Jo(e,t){for(let r=0;r<e.length;++r)if(e[r].type===t)return!0;return!1}function _F(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 EF(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 Ry(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 yl(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 Py(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 kF(e){if(e.start.type==="flow-seq-start"){for(let t of e.items)if(t.sep&&!t.value&&!Jo(t.start,"explicit-key-ind")&&!Jo(t.sep,"map-value-ind")){if(t.key)t.value=t.key;if(delete t.key,EF(t.value))if(t.value.end)Py(t.value.end,t.sep);else t.value.end=t.sep;else Py(t.start,t.sep);delete t.sep}}}class IF{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 age.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,sge.env.LOG_TOKENS)console.log("|",vF.prettyToken(e));if(this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let t=vF.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")kF(t);switch(r.type){case"document":r.value=t;break;case"block-scalar":r.props.push(t);break;case"block-map":{let i=r.items[r.items.length-1];if(i.value){r.items.push({start:[],key:t,sep:[]}),this.onKeyLine=!0;return}else if(i.sep)i.value=t;else{Object.assign(i,{key:t,sep:[]}),this.onKeyLine=!i.explicitKey;return}break}case"block-seq":{let i=r.items[r.items.length-1];if(i.value)r.items.push({start:[],value:t});else i.value=t;break}case"flow-collection":{let i=r.items[r.items.length-1];if(!i||i.value)r.items.push({start:[],key:t,sep:[]});else if(i.sep)i.value=t;else Object.assign(i,{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 i=t.items[t.items.length-1];if(i&&!i.sep&&!i.value&&i.start.length>0&&_F(i.start)===-1&&(t.indent===0||i.start.every((n)=>n.type!=="comment"||n.indent<t.indent))){if(r.type==="document")r.end=i.start;else r.items.push({start:i.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(_F(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=Ry(this.peek(2)),r=yl(t),i;if(e.end)i=e.end,i.push(this.sourceToken),delete e.end;else i=[this.sourceToken];let n={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:r,key:e,sep:i}]};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(`
448
447
  `)+1;while(t!==0)this.onNewLine(this.offset+t),t=this.source.indexOf(`
449
448
  `,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 i=e.items[e.items.length-2]?.value?.end;if(Array.isArray(i)){Py(i,t.start),i.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,i=r&&(t.sep||t.explicitKey)&&this.type!=="seq-item-ind",n=[];if(i&&t.sep&&!t.value){let o=[];for(let s=0;s<t.sep.length;++s){let a=t.sep[s];switch(a.type){case"newline":o.push(s);break;case"space":break;case"comment":if(a.indent>e.indent)o.length=0;break;default:o.length=0}}if(o.length>=2)n=t.sep.splice(o[1])}switch(this.type){case"anchor":case"tag":if(i||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(i||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(Jo(t.start,"newline"))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let o=yl(t.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:null,sep:[this.sourceToken]}]})}else if(t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(Jo(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(EF(t.key)&&!Jo(t.sep,"newline")){let o=yl(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:o,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||i)e.items.push({start:n,key:null,sep:[this.sourceToken]});else if(Jo(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 o=this.flowScalar(this.type);if(i||t.value)e.items.push({start:n,key:o,sep:[]}),this.onKeyLine=!0;else if(t.sep)this.stack.push(o);else Object.assign(t,{key:o,sep:[]}),this.onKeyLine=!0;return}default:{let o=this.startBlockValue(e);if(o){if(o.type==="block-seq"){if(!t.explicitKey&&t.sep&&!Jo(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(o);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 i=e.items[e.items.length-2]?.value?.end;if(Array.isArray(i)){Py(i,t.start),i.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||Jo(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 i=this.flowScalar(this.type);if(!t||t.value)e.items.push({start:[],key:i,sep:[]});else if(t.sep)this.stack.push(i);else Object.assign(t,{key:i,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 i=Ry(r),n=yl(i);kF(e);let o=e.end.splice(1,e.end.length);o.push(this.sourceToken);let s={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:n,key:e,sep:o}]};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(`
450
449
  `)+1;while(t!==0)this.onNewLine(this.offset+t),t=this.source.indexOf(`
451
- `,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=Ry(e),r=yl(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=Ry(e),r=yl(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()}}}lge.Parser=IF});var OF=ee(function(bge){var AF=FA(),dge=af(),pf=cf(),fge=XI(),pge=Ge(),mge=XA(),TF=eT();function CF(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new mge.LineCounter||null,prettyErrors:t}}function hge(e,t={}){let{lineCounter:r,prettyErrors:i}=CF(t),n=new TF.Parser(r?.addNewLine),o=new AF.Composer(t),s=Array.from(o.compose(n.parse(e)));if(i&&r)for(let a of s)a.errors.forEach(pf.prettifyError(e,r)),a.warnings.forEach(pf.prettifyError(e,r));if(s.length>0)return s;return Object.assign([],{empty:!0},o.streamInfo())}function $F(e,t={}){let{lineCounter:r,prettyErrors:i}=CF(t),n=new TF.Parser(r?.addNewLine),o=new AF.Composer(t),s=null;for(let a of o.compose(n.parse(e),!0,e.length))if(!s)s=a;else if(s.options.logLevel!=="silent"){s.errors.push(new pf.YAMLParseError(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}if(i&&r)s.errors.forEach(pf.prettifyError(e,r)),s.warnings.forEach(pf.prettifyError(e,r));return s}function gge(e,t,r){let i=void 0;if(typeof t==="function")i=t;else if(r===void 0&&t&&typeof t==="object")r=t;let n=$F(e,r);if(!n)return null;if(n.warnings.forEach((o)=>fge.warn(n.options.logLevel,o)),n.errors.length>0)if(n.options.logLevel!=="silent")throw n.errors[0];else n.errors=[];return n.toJS(Object.assign({reviver:i},r))}function yge(e,t,r){let i=null;if(typeof t==="function"||Array.isArray(t))i=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(pge.isDocument(e)&&!i)return e.toString(r);return new dge.Document(e,i,r).toString(r)}bge.parse=gge;bge.parseAllDocuments=hge;bge.parseDocument=$F;bge.stringify=yge});var _ge,kge,Ege,tT,Ige,Vo,Age,Tge,Cge,$ge,rMe,Oge,Rge,Pge,zy,RF,zge,Nge,Dge,Lge,Bge,jge,qge,Uge,Mge,Fge,Bi,ji,Zge,bl,rT,Hge,Kge,Jge,Vge,Wge,Gge,Qge,Yge,Xge,ci,eye,tye,rye;var mf=x(()=>{_ge=FA(),kge=af(),Ege=AA(),tT=cf(),Ige=Kd(),Vo=Ge(),Age=Fo(),Tge=jt(),Cge=Ho(),$ge=Ko(),rMe=$y(),Oge=YA(),Rge=XA(),Pge=eT(),zy=OF(),RF=Zd();zge=_ge.Composer,Nge=kge.Document,Dge=Ege.Schema,Lge=tT.YAMLError,Bge=tT.YAMLParseError,jge=tT.YAMLWarning,qge=Ige.Alias,Uge=Vo.isAlias,Mge=Vo.isCollection,Fge=Vo.isDocument,Bi=Vo.isMap,ji=Vo.isNode,Zge=Vo.isPair,bl=Vo.isScalar,rT=Vo.isSeq,Hge=Age.Pair,Kge=Tge.Scalar,Jge=Cge.YAMLMap,Vge=$ge.YAMLSeq,Wge=Oge.Lexer,Gge=Rge.LineCounter,Qge=Pge.Parser,Yge=zy.parse,Xge=zy.parseAllDocuments,ci=zy.parseDocument,eye=zy.stringify,tye=RF.visit,rye=RF.visitAsync});var BF={};tr(BF,{assertPilotUsersRemoved:()=>iT,createPilotOffboardDriver:()=>nT,offboardPilotUsers:()=>zF});import{access as nye,readdir as iye,readFile as oye,rm as hf,writeFile as sye}from"fs/promises";import{basename as aye,join as qi}from"path";async function zF(e,t){let r=[...new Set(t.handles.map((d)=>Pr.parse(d)))].sort((d,p)=>d.localeCompare(p));if(r.length===0)throw Error("At least one pilot handle is required");let i=t.dryRun??!0,n=`sunset:${r.join(",")}`;if(!i&&t.confirmation!==n)throw Error(`Exact confirmation required: ${n}`);let o=t.env??process.env,s=t.logger??console.info,a=await Ct(e),c=r.map((d)=>cye(a,d,o)),l=t.driver??nT({env:o,fetchImpl:t.fetchImpl,contentRepoTokenName:a.pilot.contentRepoAdminToken}),u=await Promise.all(c.map(async(d)=>({target:d,inspection:await l.inspect(d)})));if(uye(u),dye(u,i,s),!i){for(let d of u)if(!d.inspection.contentRepoArchived)await l.archiveContentRepo(d.target),s(`[${d.target.handle}] archived ${d.target.contentRepo}`);for(let d of u)for(let p of d.inspection.dnsRecords)await l.deleteDnsRecord(d.target,p),s(`[${d.target.handle}] deleted DNS ${p.name}`);for(let d of u)if(d.inspection.server)await l.deleteServer(d.target,d.inspection.server),s(`[${d.target.handle}] deleted ${d.target.instanceName}`);await lye(c,l,t.sleep??((d)=>new Promise((p)=>setTimeout(p,d)))),await fye(e,r),await Oi(e),await iT(e,r),s(`Removed desired state for ${r.length} pilot user(s)`)}return{dryRun:i,handles:r,confirmation:n,plans:u}}function cye(e,t,r){let i=e.users.find((u)=>u.handle===t),n=`${t}${e.pilot.domainSuffix}`,o=i?.domain??n,s=LI(o,{sharedDomain:e.pilot.domainSuffix}),a=i?.cloudflareZoneId??Ny(r,"CF_ZONE_ID"),c=i?.contentRepo??`${e.pilot.contentRepoPrefix}${t}-content`,l=c.includes("/")?c:`${e.pilot.githubOrg}/${c}`;return{handle:t,instanceName:`rover-${t}`,domain:o,previewDomain:s,...o===n?{}:{wwwDomain:`www.${o}`},contentRepo:l,cloudflareZoneId:a}}async function lye(e,t,r){for(let i of e)for(let n=1;n<=20;n+=1){let o=await t.inspect(i);if(!o.server&&o.dnsRecords.length===0&&o.contentRepoArchived)break;if(n===20)throw Error(`[${i.handle}] provider cleanup did not converge`);await r(1500)}}function uye(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 i=new Set([t.domain,t.previewDomain,...t.wwwDomain?[t.wwwDomain]:[]]);for(let n of r.dnsRecords){if(!i.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 dye(e,t,r){r(`${t?"Dry run":"Apply"}: ${e.map(({target:i})=>i.handle).join(", ")}`);for(let{target:i,inspection:n}of e){let o=n.server?`delete ${i.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 ${i.contentRepo}`;r(`[${i.handle}] server: ${o}; DNS: ${s}; repo: ${a}`)}r("Runtime backups: none")}async function fye(e,t){let r=new Set(t),i=qi(e,"cohorts");for(let n of(await iye(i)).filter((o)=>o.endsWith(".yaml"))){let o=qi(i,n),s=await oye(o,"utf8"),a=ci(s);if(a.errors.length>0)throw Error(`${n}: ${a.errors[0]?.message??"invalid YAML"}`);let c=a.get("members",!0);if(!rT(c))throw Error(`${n}: members must be a sequence`);let l=c.items.filter((u)=>!bl(u)||typeof u.value!=="string"||!r.has(u.value));if(l.length===c.items.length)continue;if(l.length===0){await hf(o);continue}c.items=l,yn.parse(a.toJS()),await sye(o,a.toString())}for(let n of t)await Promise.all([hf(qi(e,"users",`${n}.yaml`),{force:!0}),hf(qi(e,"users",`${n}.secrets.yaml`),{force:!0}),hf(qi(e,"users",`${n}.secrets.yaml.age`),{force:!0}),hf(qi(e,"users",n),{recursive:!0,force:!0})])}function nT(e){let t=e.fetchImpl??fetch,r=Ny(e.env,"HCLOUD_TOKEN"),i=Ny(e.env,"CF_API_TOKEN"),n=Ny(e.env,e.contentRepoTokenName);return{async inspect(o){let[s,a,c]=await Promise.all([pye(t,r,o.instanceName),Promise.all([o.domain,o.previewDomain,...o.wwwDomain?[o.wwwDomain]:[]].map((l)=>mye(t,i,o.cloudflareZoneId,l))).then((l)=>l.flat()),hye(t,n,o.contentRepo)]);if(s.length>1)throw Error(`[${o.handle}] expected at most one server, found ${s.length}`);return{...s[0]?{server:s[0]}:{},dnsRecords:a,contentRepoArchived:c.archived}},async archiveContentRepo(o){await xl(t,`https://api.github.com/repos/${o.contentRepo}`,{method:"PATCH",headers:NF(n),body:JSON.stringify({archived:!0})},"GitHub repository archive")},async deleteDnsRecord(o,s){if(Sl(await xl(t,`https://api.cloudflare.com/client/v4/zones/${o.cloudflareZoneId}/dns_records/${s.id}`,{method:"DELETE",headers:DF(i)},"Cloudflare DNS delete")).success!==!0)throw Error(`Cloudflare DNS delete failed for ${s.name}`)},async deleteServer(o,s){await xl(t,`https://api.hetzner.cloud/v1/servers/${s.id}`,{method:"DELETE",headers:{Authorization:`Bearer ${r}`}},"Hetzner server delete",!0)}}}async function pye(e,t,r){let i=new URL("https://api.hetzner.cloud/v1/servers");i.searchParams.set("label_selector",`brain=${r}`);let o=Sl(await xl(e,i.toString(),{headers:{Authorization:`Bearer ${t}`}},"Hetzner server lookup")).servers;if(!Array.isArray(o))throw Error("Hetzner server lookup returned an invalid payload");return o.map((s)=>{let a=Sl(s),c=PF(a.public_net),l=PF(c?.ipv4);return{id:gye(a.id,"Hetzner server id"),name:gf(a.name,"Hetzner server name"),...typeof l?.ip==="string"?{ip:l.ip}:{}}})}async function mye(e,t,r,i){let n=new URL(`https://api.cloudflare.com/client/v4/zones/${r}/dns_records`);n.searchParams.set("name",i);let o=Sl(await xl(e,n.toString(),{headers:DF(t)},"Cloudflare DNS lookup")),s=o.result;if(o.success!==!0||!Array.isArray(s))throw Error(`Cloudflare DNS lookup failed for ${i}`);return s.map((a)=>{let c=Sl(a),l=gf(c.type,"Cloudflare record type");if(l!=="A"&&l!=="CNAME")throw Error(`Unsupported Cloudflare record type ${l} for ${i}`);return{id:gf(c.id,"Cloudflare record id"),name:gf(c.name,"Cloudflare record name"),type:l,content:gf(c.content,"Cloudflare record content")}})}async function hye(e,t,r){let i=Sl(await xl(e,`https://api.github.com/repos/${r}`,{headers:NF(t)},"GitHub repository lookup"));if(typeof i.archived!=="boolean")throw Error(`Invalid repository archive state for ${r}`);return{archived:i.archived}}async function xl(e,t,r,i,n=!1){let o=await e(t,r),s=await o.text();if(!o.ok)throw Error(`${i} failed (${o.status}): ${s}`);if(!s&&n)return{};try{return JSON.parse(s)}catch{throw Error(`${i} returned an invalid JSON response`)}}function NF(e){return{Accept:"application/vnd.github+json",Authorization:`Bearer ${e}`,"Content-Type":"application/json","X-GitHub-Api-Version":"2022-11-28"}}function DF(e){return{Authorization:`Bearer ${e}`}}function Ny(e,t){let r=e[t];if(!r)throw Error(`Missing required environment variable: ${t}`);return r}function LF(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function Sl(e){if(!LF(e))throw Error("Provider returned an unexpected payload");return e}function PF(e){return LF(e)?e:void 0}function gf(e,t){if(typeof e!=="string"||e.length===0)throw Error(`Missing ${t}`);return e}function gye(e,t){if(typeof e!=="number")throw Error(`Missing ${t}`);return e}async function yye(e){try{return await nye(e),!0}catch{return!1}}async function iT(e,t){for(let r of t)for(let i of[qi(e,"users",`${r}.yaml`),qi(e,"users",`${r}.secrets.yaml.age`),qi(e,"users",r)])if(await yye(i))throw Error(`Offboarded user state remains: ${aye(i)}`)}var oT=x(()=>{mf();Ln();BI();Dc();To()});var D8={};tr(D8,{upgradePilotRepo:()=>Owe});import{readFile as Awe}from"fs/promises";import{join as Twe}from"path";async function N8(e){let t=Twe(e,"package.json"),i=Cwe.parse(JSON.parse(await Awe(t,"utf8"))).devDependencies?.["@rizom/ops"];if(!i)throw Error(`${t} does not pin @rizom/ops as a devDependency`);return i}async function $we(e,t){let i=await Bun.spawn(e,{cwd:t,stdout:"inherit",stderr:"inherit"}).exited;if(i!==0)throw Error(`${e.join(" ")} failed with exit ${i}`)}async function Owe(e,t={}){let r=t.exec??$we,i=await N8(e),n=t.version??"latest";await r(["bun","add","--dev","--exact",`@rizom/ops@${n}`],e);let o=await N8(e);return await r(["bun","x","brains-ops","init","."],e),{from:i,to:o}}var Cwe;var L8=x(()=>{Re();Cwe=f.object({devDependencies:f.record(f.string(),f.string()).optional()})});function B8(e){if(e===null||typeof e!=="object"||Array.isArray(e))return!1;let t=Rwe(e);return t===Object.prototype||t===null}var Rwe;var j8=x(()=>{Rwe=Object.getPrototypeOf});function F8(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:[...Nwe]};return{bundles:["core","media","automation","web","chat","site","publishing","federation"],add:["obsidian-vault"]}}function Dwe(e){let t=Pwe.parse(e);return Ao.parse({brainVersion:t.brainVersion,bundleContract:Io,...F8(t.preset),githubOrg:t.githubOrg,contentRepoPrefix:t.contentRepoPrefix,domainSuffix:t.domainSuffix,aiApiKey:t.aiApiKey,gitSyncToken:t.gitSyncToken,contentRepoAdminToken:t.contentRepoAdminToken,agePublicKey:t.agePublicKey})}function Lwe(e){let t=zwe.parse(e),r=t.presetOverride?F8(t.presetOverride):void 0;return yn.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?{aiApiKeyOverride:t.aiApiKeyOverride}:{},...t.gitSyncTokenOverride?{gitSyncTokenOverride:t.gitSyncTokenOverride}:{}})}function Z8(e){let t=ci(e,{keepSourceTokens:!0});if(t.errors.length>0)throw Error(`Invalid desired-state YAML: ${t.errors[0]?.message}`);if(!Bi(t.contents))throw Error("Desired-state YAML must contain a mapping");return t}function o$(e,t){if(!Bi(e.contents))return;return e.contents.items.find((r)=>bl(r.key)&&r.key.value===t)}function q8(e,t){if(!ji(e)||!ji(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 U8(e,t){if(!e||!ji(t))return;let r=[ji(e.key)?e.key.commentBefore:void 0,ji(e.key)?e.key.comment:void 0,ji(e.value)?e.value.commentBefore:void 0,ji(e.value)?e.value.comment:void 0].filter((i)=>i!==void 0);if(r.length===0)return;t.commentBefore=[t.commentBefore,...r].filter((i)=>i!==void 0).join(`
452
- `)}function H8(e,t,r,i){if(!Bi(e.contents))throw Error("Desired-state YAML must contain a mapping");let n=e.contents.items.findIndex((s)=>bl(s.key)&&s.key.value===t),o=e.createPair(r,[...i]);if(n>=0){let s=e.contents.items[n];q8(s?.key,o.key),q8(s?.value,o.value),e.contents.items.splice(n,1,o)}else e.contents.add(o);return o}function K8(e){let t=Z8(e),r=Dwe(t.toJS()),i=o$(t,"schemaVersion"),n=o$(t,"model");U8(i,o$(t,"brainVersion")?.key),t.delete("schemaVersion"),t.set("bundleContract",Io);let o=H8(t,"preset","bundles",r.bundles);if(U8(n,o.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 Ao.parse(t.toJS()),t.toString({lineWidth:0})}function J8(e){let t=Z8(e),r=Lwe(t.toJS());if(r.bundlesOverride)H8(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 yn.parse(t.toJS()),t.toString({lineWidth:0})}var M8,rp,Pwe,zwe,Nwe;var V8=x(()=>{Ai();Re();mf();To();M8=f.enum(["core","default","pro"]),rp=f.string().min(1),Pwe=f.strictObject({schemaVersion:f.literal(1),brainVersion:nn,model:f.literal("rover"),githubOrg:f.string().min(1),contentRepoPrefix:f.string().min(1),domainSuffix:f.string().min(1),preset:M8,aiApiKey:rp,gitSyncToken:rp,contentRepoAdminToken:rp,agePublicKey:f.string().startsWith("age1").min(1)}),zwe=f.strictObject({members:f.array(Pr).min(1),brainVersionOverride:nn.optional(),presetOverride:M8.optional(),aiApiKeyOverride:rp.optional(),gitSyncTokenOverride:rp.optional()}).superRefine((e,t)=>{if(new Set(e.members).size!==e.members.length)t.addIssue({code:f.ZodIssueCode.custom,path:["members"],message:"cohort members must be unique"})}),Nwe=["series","portfolio","content-pipeline","social-media","newsletter","stock-photo"]});function G8(e,t){let r=ci(e,{keepSourceTokens:!0});if(r.errors.length>0||!Bi(r.contents))throw Error(`Invalid ${t} YAML`);return r}function Mwe(e,t){return e.length===t.length&&e.every((r,i)=>r===t[i])}function Q8(e,t,r){if(!Mwe(t,r.sourceBundles))throw Error(`${e} source bundles changed after review: expected [${r.sourceBundles.join(", ")}], received [${t.join(", ")}]`)}function Y8(e){let t=Nn(e,Uwe);if(!t.ok)throw Error(`Invalid capability bundle review: ${t.error}`);return t.data}function X8(e,t){let r=G8(e,"pilot desired-state"),i=jwe.parse(r.toJS());return Q8("pilot.yaml",i.bundles,t),r.set("bundleContract",Io),r.set("bundles",t.targetBundles),Ao.parse(r.toJS()),r.toString({lineWidth:0})}function eH(e,t,r){let i=G8(e,`cohort ${t}`),n=qwe.parse(i.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`);Q8(`cohort ${t}`,n.bundlesOverride,r),i.set("bundlesOverride",r.targetBundles)}return yn.parse(i.toJS()),i.toString({lineWidth:0})}var Bwe,s$,Nb,jwe,qwe,W8,Uwe;var tH=x(()=>{Ai();Re();mf();To();Bwe=f.enum(["core","site","publishing","team"]),s$=f.array(Bwe).min(1),Nb=f.array(f.string().min(1)),jwe=f.strictObject({brainVersion:nn,bundles:s$,add:Nb.optional(),remove:Nb.optional(),githubOrg:f.string().min(1),contentRepoPrefix:f.string().min(1),domainSuffix:f.string().min(1),aiApiKey:f.string().min(1),gitSyncToken:f.string().min(1),contentRepoAdminToken:f.string().min(1),agePublicKey:f.string().startsWith("age1").min(1)}),qwe=f.strictObject({members:f.array(Pr).min(1),brainVersionOverride:nn.optional(),bundlesOverride:s$.optional(),addOverride:Nb.optional(),removeOverride:Nb.optional(),aiApiKeyOverride:f.string().min(1).optional(),gitSyncTokenOverride:f.string().min(1).optional()}),W8=f.strictObject({sourceBundles:s$,targetBundles:f.array(Mh).min(1)}),Uwe=f.strictObject({bundleContract:f.literal(Io),pilot:W8,cohorts:f.record(Pr,W8)})});var sH={};tr(sH,{loadCapabilityBundleReview:()=>Qwe,loadReviewedSitePins:()=>Gwe,parseReviewedSitePins:()=>oH,stageLegacyCrossover:()=>Xwe});import{access as Fwe,cp as Zwe,mkdir as rH,readFile as Vl,readdir as iH,writeFile as Jl}from"fs/promises";import{basename as Hwe,join as bi,relative as Db,resolve as nH}from"path";import{fileURLToPath as Kwe}from"url";function oH(e){let t=Nn(e,Jwe);if(!t.ok)throw Error(`Invalid reviewed site pins: ${t.error}`);return t.data.sites}async function Gwe(e){return oH(await Vl(e,"utf8"))}async function Qwe(e){return Y8(await Vl(e,"utf8"))}async function Ywe(e,t){let r=bi(e,"users"),i=(await iH(r,{withFileTypes:!0})).filter((s)=>s.isFile()&&/\.ya?ml$/.test(s.name)).map((s)=>s.name).sort(),n=new Set(Object.keys(t??{})),o=[];for(let s of i){let a=bi(r,s),c=await Vl(a,"utf8"),l=ci(c,{keepSourceTokens:!0});if(l.errors.length>0||!Bi(l.contents))throw Error(`Invalid user desired-state YAML: ${s}`);let u=Vwe.parse(l.toJS());if(!u.siteOverride)continue;let d=t?.[u.handle];if(!d)throw Error(`User ${u.handle} has a siteOverride but no reviewed site pin`);if(n.delete(u.handle),d.package!==u.siteOverride.package||d.theme!==u.siteOverride.theme)throw Error(`Reviewed site pin identity does not match user ${u.handle}`);if(u.siteOverride.version!==void 0&&u.siteOverride.version!==d.version)throw Error(`Reviewed site version does not match the existing pin for user ${u.handle}`);if(u.siteOverride.themeVersion!==void 0&&u.siteOverride.themeVersion!==d.themeVersion)throw Error(`Reviewed theme version does not match the existing pin for user ${u.handle}`);if(l.setIn(["siteOverride","version"],d.version),d.themeVersion!==void 0)l.setIn(["siteOverride","themeVersion"],d.themeVersion);else l.deleteIn(["siteOverride","themeVersion"]);Fh.parse(l.toJS());let p=l.toString({lineWidth:0});if(p!==c)await Jl(a,p),o.push(Db(e,a))}if(n.size>0)throw Error(`Reviewed site pins do not match site users: ${[...n].sort().join(", ")}`);return o}async function Xwe(e,t,r={}){let i=nH(e),n=nH(t);if(i===n||n.startsWith(`${i}/`))throw Error("Crossover output must be outside the source repository");await Zwe(i,n,{recursive:!0,errorOnExist:!0,force:!1,filter:(T)=>{let z=Hwe(T);return z!==".git"&&z!==".operator"&&z!==".brains-ops"&&z!==".turbo"&&z!=="dist"&&z!=="node_modules"&&z!==".env"&&z!==".env.local"&&!z.endsWith(".secrets.yaml")}});let o=[],s=bi(n,"docs","canonical-crossover-record.md");try{await Fwe(s)}catch{await rH(bi(n,"docs"),{recursive:!0}),await Jl(s,await Vl(Wwe,"utf8")),o.push("docs/canonical-crossover-record.md")}let a=bi(n,"pilot.yaml"),c=await Vl(a,"utf8"),u=ci(c).toJS();if(!B8(u))throw Error(`${a} is not a YAML mapping`);let d=Array.isArray(u.bundles),p=r.bundleReview,m;if(d){if(!p)throw Error("Current canonical desired state requires an explicit capability bundle review manifest");m=X8(c,p.pilot)}else m=K8(c);await Jl(a,m),o.push("pilot.yaml");let y=bi(n,"cohorts"),g=(await iH(y,{withFileTypes:!0})).filter((T)=>T.isFile()&&/\.ya?ml$/.test(T.name)).map((T)=>T.name).sort(),b=new Set(Object.keys(p?.cohorts??{}));for(let T of g){let z=bi(y,T),j=await Vl(z,"utf8"),E=T.replace(/\.ya?ml$/,""),Z=p?.cohorts[E];if(Z)b.delete(E);await Jl(z,d?eH(j,E,Z):J8(j)),o.push(Db(n,z))}if(d&&b.size>0)throw Error(`Capability bundle review names unknown cohorts: ${[...b].sort().join(", ")}`);o.push(...await Ywe(n,r.sitePins));let v=await Ct(n),A=Zg(v.pilot.githubOrg);for(let T of v.users){let z=await A(T),j=bi(n,"users",T.handle);if(await rH(j,{recursive:!0}),z.brainYaml){let E=bi(j,"brain.yaml");await Jl(E,z.brainYaml),o.push(Db(n,E))}if(z.envFile){let E=bi(j,".env");await Jl(E,z.envFile),o.push(Db(n,E))}}return await Oi(n,{registry:v}),o.push("views/users.md"),{outputDir:n,changedFiles:[...new Set(o)].sort()}}var Jwe,Vwe,Wwe;var aH=x(()=>{Ai();j8();Re();mf();UI();V8();tH();Ln();Dc();To();Jwe=f.strictObject({sites:f.record(Pr,zE)}),Vwe=f.object({handle:Pr,siteOverride:f.object({package:f.string().min(1),version:nn.optional(),theme:f.string().min(1).optional(),themeVersion:nn.optional()}).optional()}).passthrough(),Wwe=Kwe(new URL("../templates/rover-pilot/docs/canonical-crossover-record.md",import.meta.url))});var cH="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";import{webcrypto as lH}from"crypto";function t0e(e){if(e<0)throw RangeError("Wrong ID size");try{if(!ms||ms.length<e)ms=Buffer.allocUnsafe(e*e0e),lH.getRandomValues(ms),Wl=0;else if(Wl+e>ms.length)lH.getRandomValues(ms),Wl=0}catch(t){throw ms=void 0,t}Wl+=e}function uH(e=21){t0e(e|=0);let t="";for(let r=Wl-e;r<Wl;r++)t+=cH[ms[r]&63];return t}var e0e=128,ms,Wl;var dH=()=>{};function to(e=12){return uH(e)}var np=x(()=>{dH()});import{openSync as r0e,writeSync as n0e}from"fs";class fn{static instance=null;level;context;useStderr;format;logFile;fileHandle;constructor(e={},t){if(this.level=e.level??Da.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=r0e(this.logFile,"a")}catch{}}static getInstance(e){if(!fn.instance)fn.instance=new fn(e);else if(e?.useStderr!==void 0)fn.instance.useStderr=e.useStderr;return fn.instance}static resetInstance(){fn.instance=null}static createFresh(e){return new fn(e)}formatEntry(e,t,r){let i=new Date().toISOString();if(this.format==="json"){let n={ts:i,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?`[${i}] [${this.context}] ${t}`:`[${i}] ${t}`}write(e,t,r,i){if(this.format==="json")e(this.formatEntry(t,r,i));else if(i.length>0)e(this.formatEntry(t,r,[]),...i);else e(this.formatEntry(t,r,[]));if(this.fileHandle!==void 0){let n=this.formatJsonEntry(t,r,i);try{n0e(this.fileHandle,n+`
453
- `)}catch{}}}formatJsonEntry(e,t,r){let i={ts:new Date().toISOString(),level:e,msg:t};if(this.context)i.ctx=this.context;if(r.length>0)i.data=r;return JSON.stringify(i)}silly(e,...t){if(this.level<=Da.SILLY)this.write(console.debug.bind(console),"silly",e,t)}verbose(e,...t){if(this.level<=Da.VERBOSE)this.write(console.debug.bind(console),"verbose",e,t)}debug(e,...t){if(this.level<=Da.DEBUG)this.write(console.debug.bind(console),"debug",e,t)}info(e,...t){if(this.level<=Da.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<=Da.WARN)this.write(console.warn.bind(console),"warn",e,t)}error(e,...t){if(this.level<=Da.ERROR)this.write(console.error.bind(console),"error",e,t)}child(e){return new fn({level:this.level,context:e,useStderr:this.useStderr,format:this.format},this.fileHandle)}setUseStderr(e){this.useStderr=e}}var Da,cHe;var a$=x(()=>{Da={SILLY:0,VERBOSE:1,DEBUG:2,INFO:3,WARN:4,ERROR:5,NONE:6};cHe=fn.getInstance()});var c$,i0e,Gl,fHe;var ip=x(()=>{Po();Re();c$=f.enum(["file_operations","content_operations","data_processing","batch_processing"]),i0e=f.looseObject({pluginId:f.string().optional(),progressToken:f.union([f.string(),f.number()]).optional(),operationType:c$,operationTarget:f.string().optional(),interfaceType:f.string().optional(),conversationId:f.string().optional(),channelId:f.string().optional(),requestedByActor:Vc.optional(),requestedByUserId:f.string().optional(),requestedByInterface:f.string().optional(),silent:f.boolean().optional(),provenance:Ro.optional()}),Gl=f.looseObject({pluginId:f.string().optional(),progressToken:f.union([f.string(),f.number()]).optional(),operationType:c$,operationTarget:f.string().optional(),interfaceType:f.string().optional(),conversationId:f.string().optional(),channelId:f.string().optional(),requestedByActor:Vc.optional(),requestedByUserId:f.string().optional(),requestedByInterface:f.string().optional(),silent:f.boolean().optional(),provenance:Ro.optional(),rootJobId:f.string()}),fHe=f.enum(["none","skip","replace","coalesce"])});var o0e,hs=15000;var op=x(()=>{ip();Re();o0e=f.object({id:f.string(),type:f.string(),data:f.string(),status:f.enum(["pending","processing","completed","failed"]),source:f.string().nullable(),priority:f.number(),retryCount:f.number(),maxRetries:f.number(),lastError:f.string().nullable(),createdAt:f.number(),scheduledFor:f.number(),startedAt:f.number().nullable(),completedAt:f.number().nullable(),attemptId:f.string().nullable(),workerSlotId:f.string().nullable(),workerSessionId:f.string().nullable(),leaseExpiresAt:f.number().nullable(),attemptHeartbeatAt:f.number().nullable(),runtimeUpdatedAt:f.number().nullable(),metadata:Gl,progress:f.custom((e)=>typeof e==="object"&&e!==null&&("progress"in e)&&typeof e.progress==="number").nullable(),result:f.unknown().nullable().optional()})});var l$,fH,He,s0e,a0e,pH,c0e;var gs=x(()=>{Re();ip();l$=f.enum(["pending","processing","completed","failed"]),fH=f.enum(["completed","failed"]),He={PENDING:"pending",PROCESSING:"processing",COMPLETED:"completed",FAILED:"failed"},s0e=f.object({id:f.string(),type:f.string(),status:l$,data:f.unknown(),result:f.unknown().optional(),lastError:f.string().optional().nullable(),attempts:f.number(),maxRetries:f.number(),priority:f.number(),createdAt:f.date(),updatedAt:f.date(),processedAt:f.date().optional().nullable(),completedAt:f.date().optional().nullable(),failedAt:f.date().optional().nullable()}),a0e=f.object({jobId:f.string(),type:f.string(),status:fH,result:f.unknown().optional(),error:f.string().optional()}),pH=f.object({success:f.literal(!1),error:f.string().optional()}),c0e=f.object({id:f.string(),type:f.enum(["job","batch"]),status:l$,message:f.string().optional(),progress:f.object({current:f.number(),total:f.number(),percentage:f.number()}).optional(),aggregationKey:f.string().optional(),batchDetails:f.object({totalOperations:f.number(),completedOperations:f.number(),failedOperations:f.number(),currentOperation:f.string().optional(),errors:f.array(f.string()).optional()}).optional(),jobDetails:f.object({jobType:f.string(),priority:f.number(),retryCount:f.number()}).optional(),metadata:Gl})});var je,dr;var Kn=x(()=>{je=class je extends Error{code;extendedCode;rawCode;constructor(e,t,r,i,n){if(t!==void 0)e=`${t}: ${e}`;super(e,{cause:n});this.code=t,this.extendedCode=r,this.rawCode=i,this.name="LibsqlError"}};dr=class dr extends je{statementIndex;constructor(e,t,r,i,n,o){super(e,r,i,n,o);this.statementIndex=t,this.name="LibsqlBatchError"}}});function mH(e){let t=l0e.exec(e);if(t===null)throw new je(`The URL '${e}' is not in a valid format`,"URL_INVALID");let r=t.groups,i=r.scheme,n=r.authority!==void 0?u0e(r.authority):void 0,o=La(r.path),s=r.query!==void 0?f0e(r.query):void 0,a=r.fragment!==void 0?La(r.fragment):void 0;return{scheme:i,authority:n,path:o,query:s,fragment:a}}function u0e(e){let t=d0e.exec(e);if(t===null)throw new je("The authority part of the URL is not in a valid format","URL_INVALID");let r=t.groups,i=La(r.host_br??r.host),n=r.port?parseInt(r.port,10):void 0,o=r.username!==void 0?{username:La(r.username),password:r.password!==void 0?La(r.password):void 0}:void 0;return{host:i,port:n,userinfo:o}}function f0e(e){let t=e.split("&"),r=[];for(let i of t){if(i==="")continue;let n,o,s=i.indexOf("=");if(s<0)n=i,o="";else n=i.substring(0,s),o=i.substring(s+1);r.push({key:La(n.replaceAll("+"," ")),value:La(o.replaceAll("+"," "))})}return{pairs:r}}function La(e){try{return decodeURIComponent(e)}catch(t){if(t instanceof URIError)throw new je(`URL component has invalid percent encoding: ${t}`,"URL_INVALID",void 0,void 0,t);throw t}}function sp(e,t,r){if(t===void 0)throw new je(`URL with scheme ${JSON.stringify(e+":")} requires authority (the "//" part)`,"URL_INVALID");let i=`${e}:`,n=p0e(t.host),o=m0e(t.port),a=`//${h0e(t.userinfo)}${n}${o}`,c=r.split("/").map(encodeURIComponent).join("/");if(c!==""&&!c.startsWith("/"))c="/"+c;return new URL(`${i}${a}${c}`)}function p0e(e){return e.includes(":")?`[${encodeURI(e)}]`:encodeURI(e)}function m0e(e){return e!==void 0?`:${e}`:""}function h0e(e){if(e===void 0)return"";let t=encodeURIComponent(e.username),r=e.password!==void 0?`:${encodeURIComponent(e.password)}`:"";return`${t}${r}@`}var l0e,d0e;var Lb=x(()=>{Kn();l0e=(()=>new RegExp("^(?<scheme>[A-Za-z][A-Za-z.+-]*):(//(?<authority>[^/?#]*))?(?<path>[^?#]*)(\\?(?<query>[^#]*))?(#(?<fragment>.*))?$","su"))();d0e=(()=>new RegExp("^((?<username>[^:]*)(:(?<password>.*))?@)?((?<host>[^:\\[\\]]*)|(\\[(?<host_br>[^\\[\\]]*)\\]))(:(?<port>[0-9]*))?$","su"))()});var Yl,hH,gH,ap,Bb,g0e,fr,yH,SH=(e)=>e.replace(/=/g,"").replace(/[+\/]/g,(t)=>t=="+"?"-":"_"),wH=(e)=>e.replace(/[^A-Za-z0-9\+\/]/g,""),vH=(e)=>{let t,r,i,n,o="",s=e.length%3;for(let a=0;a<e.length;){if((r=e.charCodeAt(a++))>255||(i=e.charCodeAt(a++))>255||(n=e.charCodeAt(a++))>255)throw TypeError("invalid character found");t=r<<16|i<<8|n,o+=ap[t>>18&63]+ap[t>>12&63]+ap[t>>6&63]+ap[t&63]}return s?o.slice(0,s-3)+"===".substring(s):o},f$,u$,jb=(e,t=!1)=>t?SH(u$(e)):u$(e),y0e=(e)=>{if(e.length<2){var t=e.charCodeAt(0);return t<128?e:t<2048?fr(192|t>>>6)+fr(128|t&63):fr(224|t>>>12&15)+fr(128|t>>>6&63)+fr(128|t&63)}else{var t=65536+(e.charCodeAt(0)-55296)*1024+(e.charCodeAt(1)-56320);return fr(240|t>>>18&7)+fr(128|t>>>12&63)+fr(128|t>>>6&63)+fr(128|t&63)}},b0e,_H=(e)=>e.replace(b0e,y0e),bH,Ql=(e,t=!1)=>t?SH(bH(e)):bH(e),xH=(e)=>Ql(e,!0),x0e,S0e=(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 fr((r>>>10)+55296)+fr((r&1023)+56320);case 3:return fr((15&e.charCodeAt(0))<<12|(63&e.charCodeAt(1))<<6|63&e.charCodeAt(2));default:return fr((31&e.charCodeAt(0))<<6|63&e.charCodeAt(1))}},kH=(e)=>e.replace(x0e,S0e),EH=(e)=>{if(e=e.replace(/\s+/g,""),!g0e.test(e))throw TypeError("malformed base64.");e+="==".slice(2-(e.length&3));let t,r,i,n=[];for(let o=0;o<e.length;)if(t=Bb[e.charAt(o++)]<<18|Bb[e.charAt(o++)]<<12|(r=Bb[e.charAt(o++)])<<6|(i=Bb[e.charAt(o++)]),r===64)n.push(fr(t>>16&255));else if(i===64)n.push(fr(t>>16&255,t>>8&255));else n.push(fr(t>>16&255,t>>8&255,t&255));return n.join("")},p$,IH,AH=(e)=>IH(TH(e)),w0e,TH=(e)=>wH(e.replace(/[-_]/g,(t)=>t=="-"?"+":"/")),d$=(e)=>w0e(TH(e)),v0e=(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)},CH=(e)=>({value:e,enumerable:!1,writable:!0,configurable:!0}),$H=function(){let e=(t,r)=>Object.defineProperty(String.prototype,t,CH(r));e("fromBase64",function(){return d$(this)}),e("toBase64",function(t){return Ql(this,t)}),e("toBase64URI",function(){return Ql(this,!0)}),e("toBase64URL",function(){return Ql(this,!0)}),e("toUint8Array",function(){return AH(this)})},OH=function(){let e=(t,r)=>Object.defineProperty(Uint8Array.prototype,t,CH(r));e("toBase64",function(t){return jb(this,t)}),e("toBase64URI",function(){return jb(this,!0)}),e("toBase64URL",function(){return jb(this,!0)})},_0e=()=>{$H(),OH()},Xl;var qb=x(()=>{Yl=typeof Buffer==="function",hH=typeof TextDecoder==="function"?new TextDecoder("utf-8",{ignoreBOM:!0}):void 0,gH=typeof TextEncoder==="function"?new TextEncoder:void 0,ap=Array.prototype.slice.call("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="),Bb=((e)=>{let t={};return e.forEach((r,i)=>t[r]=i),t})(ap),g0e=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,fr=String.fromCharCode.bind(String),yH=typeof Uint8Array.from==="function"?Uint8Array.from.bind(Uint8Array):(e)=>new Uint8Array(Array.prototype.slice.call(e,0)),f$=typeof btoa==="function"?(e)=>btoa(e):Yl?(e)=>Buffer.from(e,"binary").toString("base64"):vH,u$=Yl?(e)=>Buffer.from(e).toString("base64"):(e)=>{let r=[];for(let i=0,n=e.length;i<n;i+=4096)r.push(fr.apply(null,e.subarray(i,i+4096)));return f$(r.join(""))},b0e=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,bH=Yl?(e)=>Buffer.from(e,"utf8").toString("base64"):gH?(e)=>u$(gH.encode(e)):(e)=>f$(_H(e)),x0e=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,p$=typeof atob==="function"?(e)=>atob(wH(e)):Yl?(e)=>Buffer.from(e,"base64").toString("binary"):EH,IH=Yl?(e)=>yH(Buffer.from(e,"base64")):(e)=>yH(p$(e).split("").map((t)=>t.charCodeAt(0))),w0e=Yl?(e)=>Buffer.from(e,"base64").toString("utf8"):hH?(e)=>hH.decode(IH(e)):(e)=>kH(p$(e)),Xl={version:"3.8.0",VERSION:"3.8.0",atob:p$,atobPolyfill:EH,btoa:f$,btoaPolyfill:vH,fromBase64:d$,toBase64:Ql,encode:Ql,encodeURI:xH,encodeURL:xH,utob:_H,btou:kH,decode:d$,isValid:v0e,fromUint8Array:jb,toUint8Array:AH,extendString:$H,extendUint8Array:OH,extendBuiltins:_0e}});function ys(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 eu{columns;columnTypes;rows;rowsAffected;lastInsertRowid;constructor(e,t,r,i,n){this.columns=e,this.columnTypes=t,this.rows=r,this.rowsAffected=i,this.lastInsertRowid=n}toJSON(){return{columns:this.columns,columnTypes:this.columnTypes,rows:this.rows.map(k0e),rowsAffected:this.rowsAffected,lastInsertRowid:this.lastInsertRowid!==void 0?""+this.lastInsertRowid:null}}}function k0e(e){return Array.prototype.map.call(e,E0e)}function E0e(e){if(typeof e==="bigint")return""+e;else if(e instanceof ArrayBuffer)return Xl.fromUint8Array(new Uint8Array(e));else return e}var xi="https://github.com/libsql/libsql-client-ts#supported-urls";var tu=x(()=>{qb()});function PH(e){return e.scheme==="file"&&(e.path===":memory:"||e.path.startsWith(":memory:?"))}function cp(e,t){if(typeof e!=="object")throw TypeError(`Expected client configuration as object, got ${typeof e}`);let{url:r,authToken:i,tls:n,intMode:o,concurrency:s}=e;s=Math.max(0,s||20),o??="number";let a=[];if(r===RH)r="file::memory:";let c=mH(r),l=c.scheme.toLowerCase(),u=l==="file"&&c.path===RH&&c.authority===void 0,d;if(u)d={cache:{values:["shared","private"],update:(g,b)=>a.push(`${g}=${b}`)}};else d={tls:{values:["0","1"],update:(g,b)=>n=b==="1"},authToken:{update:(g,b)=>i=b}};for(let{key:g,value:b}of c.query?.pairs??[]){if(!Object.hasOwn(d,g))throw new je(`Unsupported URL query parameter ${JSON.stringify(g)}`,"URL_PARAM_NOT_SUPPORTED");let v=d[g];if(v.values!==void 0&&!v.values.includes(b))throw new je(`Unknown value for the "${g}" query argument: ${JSON.stringify(b)}. Supported values are: [${v.values.map((A)=>'"'+A+'"').join(", ")}]`,"URL_INVALID");if(v.update!==void 0)v?.update(g,b)}let p=a.length===0?"":`?${a.join("&")}`,m=c.path+p,y;if(l==="libsql")if(n===!1){if(c.authority?.port===void 0)throw new je('A "libsql:" URL with ?tls=0 must specify an explicit port',"URL_INVALID");y=t?"http":"ws"}else y=t?"https":"wss";else y=l;if(y==="http"||y==="ws")n??=!1;else n??=!0;if(y!=="http"&&y!=="ws"&&y!=="https"&&y!=="wss"&&y!=="file")throw new je(`The client supports only "libsql:", "wss:", "ws:", "https:", "http:" and "file:" URLs, got ${JSON.stringify(c.scheme+":")}. For more information, please read ${xi}`,"URL_SCHEME_NOT_SUPPORTED");if(o!=="number"&&o!=="bigint"&&o!=="string")throw TypeError(`Invalid value for intMode, expected "number", "bigint" or "string", got ${JSON.stringify(o)}`);if(c.fragment!==void 0)throw new je(`URL fragments are not supported: ${JSON.stringify("#"+c.fragment)}`,"URL_INVALID");if(u)return{scheme:"file",tls:!1,path:m,intMode:o,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:y,tls:n,authority:c.authority,path:m,authToken:i,intMode:o,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 RH=":memory:";var lp=x(()=>{Kn();Lb();tu()});var NH=ee(function(An){var I0e=An&&An.__createBinding||(Object.create?function(e,t,r,i){if(i===void 0)i=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,i,n)}:function(e,t,r,i){if(i===void 0)i=r;e[i]=t[r]}),A0e=An&&An.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),zH=An&&An.__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))I0e(t,e,r)}return A0e(t,e),t};Object.defineProperty(An,"__esModule",{value:!0});An.load=An.currentTarget=void 0;var T0e=zH(Tt("path")),C0e=zH(Tt("fs"));function $0e(){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 O0e()?`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}`)}An.currentTarget=$0e;function O0e(){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 R0e(e){let t=T0e.join(e,"index.node");return C0e.existsSync(t)?Tt(t):null}An.load=R0e});var BH=ee(function(RHe,LH){var DH=()=>process.platform==="linux",m$=null,P0e=()=>{if(!m$)m$=DH()&&process.report?process.report.getReport():{};return m$};LH.exports={isLinux:DH,getReport:P0e}});var UH=ee(function(PHe,qH){var jH=Tt("fs"),z0e=(e)=>jH.readFileSync(e,"utf-8"),N0e=(e)=>new Promise((t,r)=>{jH.readFile(e,"utf-8",(i,n)=>{if(i)r(i);else t(n)})});qH.exports={LDD_PATH:"/usr/bin/ldd",readFileSync:z0e,readFile:N0e}});var iK=ee(function(zHe,nK){var FH=Tt("child_process"),{isLinux:ru,getReport:ZH}=BH(),{LDD_PATH:Ub,readFile:HH,readFileSync:KH}=UH(),Si,wi,bs="",JH=()=>{if(!bs)return new Promise((e)=>{FH.exec("getconf GNU_LIBC_VERSION 2>&1 || true; ldd --version 2>&1 || true",(t,r)=>{bs=t?" ":r,e(bs)})});return bs},VH=()=>{if(!bs)try{bs=FH.execSync("getconf GNU_LIBC_VERSION 2>&1 || true; ldd --version 2>&1 || true",{encoding:"utf8"})}catch(e){bs=" "}return bs},ro="glibc",WH=/GLIBC\s(\d+\.\d+)/,Ba="musl",D0e=ro.toUpperCase(),L0e=Ba.toLowerCase(),B0e=(e)=>e.includes("libc.musl-")||e.includes("ld-musl-"),GH=()=>{let e=ZH();if(e.header&&e.header.glibcVersionRuntime)return ro;if(Array.isArray(e.sharedObjects)){if(e.sharedObjects.some(B0e))return Ba}return null},QH=(e)=>{let[t,r]=e.split(/[\r\n]+/);if(t&&t.includes(ro))return ro;if(r&&r.includes(Ba))return Ba;return null},YH=(e)=>{if(e.includes(L0e))return Ba;if(e.includes(D0e))return ro;return null},j0e=async()=>{if(Si!==void 0)return Si;Si=null;try{let e=await HH(Ub);Si=YH(e)}catch(e){}return Si},q0e=()=>{if(Si!==void 0)return Si;Si=null;try{let e=KH(Ub);Si=YH(e)}catch(e){}return Si},XH=async()=>{let e=null;if(ru()){if(e=await j0e(),!e)e=GH();if(!e){let t=await JH();e=QH(t)}}return e},eK=()=>{let e=null;if(ru()){if(e=q0e(),!e)e=GH();if(!e){let t=VH();e=QH(t)}}return e},U0e=async()=>ru()&&await XH()!==ro,M0e=()=>ru()&&eK()!==ro,F0e=async()=>{if(wi!==void 0)return wi;wi=null;try{let t=(await HH(Ub)).match(WH);if(t)wi=t[1]}catch(e){}return wi},Z0e=()=>{if(wi!==void 0)return wi;wi=null;try{let t=KH(Ub).match(WH);if(t)wi=t[1]}catch(e){}return wi},tK=()=>{let e=ZH();if(e.header&&e.header.glibcVersionRuntime)return e.header.glibcVersionRuntime;return null},MH=(e)=>e.trim().split(/\s+/)[1],rK=(e)=>{let[t,r,i]=e.split(/[\r\n]+/);if(t&&t.includes(ro))return MH(t);if(r&&i&&r.includes(Ba))return MH(i);return null},H0e=async()=>{let e=null;if(ru()){if(e=await F0e(),!e)e=tK();if(!e){let t=await JH();e=rK(t)}}return e},K0e=()=>{let e=null;if(ru()){if(e=Z0e(),!e)e=tK();if(!e){let t=VH();e=rK(t)}}return e};nK.exports={GLIBC:ro,MUSL:Ba,family:XH,familySync:eK,isNonGlibcLinux:U0e,isNonGlibcLinuxSync:M0e,version:H0e,versionSync:K0e}});var sK=ee(function(NHe,oK){var J0e={ALLOW:0,DENY:1};oK.exports=J0e});var cK=ee(function(DHe,aK){var h$={value:"SqliteError",writable:!0,enumerable:!1,configurable:!0};function ja(e,t,r){if(new.target!==ja)return new ja(e,t);if(typeof t!=="string")throw TypeError("Expected second argument to be a string");Error.call(this,e),h$.value=""+e,Object.defineProperty(this,"message",h$),Error.captureStackTrace(this,ja),this.code=t,this.rawCode=r}Object.setPrototypeOf(ja,Error);Object.setPrototypeOf(ja.prototype,Error.prototype);Object.defineProperty(ja.prototype,"name",h$);aK.exports=ja});var gK=ee(function(LHe,Mb){var __dirname="/home/runner/work/brains/brains/node_modules/libsql",{load:V0e,currentTarget:W0e}=NH(),{familySync:lK,GLIBC:G0e,MUSL:Q0e}=iK();function Y0e(){if(process.env.LIBSQL_JS_DEV)return V0e(__dirname);let e=W0e();if(lK()==G0e)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"&&lK()==Q0e)e="linux-arm-musleabihf";return Tt(`@libsql/${e}`)}var{databaseOpen:X0e,databaseOpenWithSync:eve,databaseInTransaction:tve,databaseInterrupt:rve,databaseClose:nve,databaseSyncSync:ive,databaseSyncUntilSync:ove,databaseExecSync:sve,databasePrepareSync:ave,databaseDefaultSafeIntegers:cve,databaseAuthorizer:lve,databaseLoadExtension:uve,databaseMaxWriteReplicationIndex:dve,statementRaw:fve,statementIsReader:pve,statementGet:uK,statementRun:dK,statementInterrupt:mve,statementRowsSync:fK,statementColumns:hve,statementSafeIntegers:gve,rowsNext:yve}=Y0e(),bve=sK(),pK=cK();function nu(e){if(e.libsqlError)return new pK(e.message,e.code,e.rawCode);return e}class mK{constructor(e,t){let r=t?.encryptionCipher??"aes256cbc";if(t&&t.syncUrl){var i="";if(t.syncAuth)console.warn("Warning: The `syncAuth` option is deprecated, please use `authToken` option instead."),i=t.syncAuth;else if(t.authToken)i=t.authToken;let o=t?.encryptionKey??"",s=t?.syncPeriod??0,a=t?.readYourWrites??!0,c=t?.offline??!1,l=t?.remoteEncryptionKey??"";this.db=eve(e,t.syncUrl,i,r,o,s,a,c,l)}else{let o=t?.authToken??"",s=t?.encryptionKey??"",a=t?.timeout??0,c=t?.remoteEncryptionKey??"";this.db=X0e(e,o,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 tve(n)}}})}sync(){return ive.call(this.db)}syncUntil(e){return ove.call(this.db,e)}prepare(e){try{let t=ave.call(this.db,e);return new hK(t)}catch(t){throw nu(t)}}transaction(e){if(typeof e!=="function")throw TypeError("Expected first argument to be a function");let t=this,r=(n)=>(...o)=>{t.exec("BEGIN "+n);try{let s=e(...o);return t.exec("COMMIT"),s}catch(s){throw t.exec("ROLLBACK"),s}},i={default:{value:r("")},deferred:{value:r("DEFERRED")},immediate:{value:r("IMMEDIATE")},exclusive:{value:r("EXCLUSIVE")},database:{value:this,enumerable:!0}};return Object.defineProperties(i.default.value,i),Object.defineProperties(i.deferred.value,i),Object.defineProperties(i.immediate.value,i),Object.defineProperties(i.exclusive.value,i),i.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,i=this.prepare(`PRAGMA ${e}`,this,!0);return r?i.pluck().get():i.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){lve.call(this.db,e)}loadExtension(...e){uve.call(this.db,...e)}maxWriteReplicationIndex(){return dve.call(this.db)}exec(e){try{sve.call(this.db,e)}catch(t){throw nu(t)}}interrupt(){rve.call(this.db)}close(){nve.call(this.db),this.open=!1}defaultSafeIntegers(e){return cve.call(this.db,e??!0),this}unsafeMode(...e){throw Error("not implemented")}}class hK{constructor(e){this.stmt=e,this.pluckMode=!1}raw(e){return fve.call(this.stmt,e??!0),this}pluck(e){return this.pluckMode=e??!0,this}get reader(){return pve.call(this.stmt)}run(...e){try{if(e.length==1&&typeof e[0]==="object")return dK.call(this.stmt,e[0]);else return dK.call(this.stmt,e.flat())}catch(t){throw nu(t)}}get(...e){try{if(e.length==1&&typeof e[0]==="object")return uK.call(this.stmt,e[0]);else return uK.call(this.stmt,e.flat())}catch(t){throw nu(t)}}iterate(...e){var t=void 0;if(e.length==1&&typeof e[0]==="object")t=fK.call(this.stmt,e[0]);else t=fK.call(this.stmt,e.flat());return{nextRows:Array(100),nextRowIndex:100,next(){try{if(this.nextRowIndex===100)yve.call(t,this.nextRows),this.nextRowIndex=0;let i=this.nextRows[this.nextRowIndex];if(this.nextRows[this.nextRowIndex]=void 0,!i)return{done:!0};return this.nextRowIndex++,{value:i,done:!1}}catch(i){throw nu(i)}},[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 nu(t)}}interrupt(){mve.call(this.stmt)}columns(){return hve.call(this.stmt)}safeIntegers(e){return gve.call(this.stmt,e??!0),this}}Mb.exports=mK;Mb.exports.Authorization=bve;Mb.exports.SqliteError=pK});import{Buffer as bK}from"buffer";function xK(e){if(e.scheme!=="file")throw new je(`URL scheme ${JSON.stringify(e.scheme+":")} is not supported by the local sqlite3 client. For more information, please read ${xi}`,"URL_SCHEME_NOT_SUPPORTED");let t=e.authority;if(t!==void 0){let s=t.host.toLowerCase();if(s!==""&&s!=="localhost")throw new je(`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 ${xi}`,"URL_INVALID");if(t.port!==void 0)throw new je("File URL cannot have a port","URL_INVALID");if(t.userinfo!==void 0)throw new je("File URL cannot have username and password","URL_INVALID")}let r=PH(e);if(r&&e.syncUrl)throw new je(`Embedded replica must use file for local db but URI with in-memory mode were provided instead: ${e.path}`,"URL_INVALID");let i=e.path;if(r)i=`${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},o=new up.default(i,n);return Jt(o,"SELECT 1 AS checkThatTheDatabaseCanBeOpened",e.intMode),new SK(i,n,o,e.intMode)}class SK{#e;#t;#r;#n;closed;protocol;constructor(e,t,r,i){this.#e=e,this.#t=t,this.#r=r,this.#n=i,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.#i(),Jt(this.#o(),r,this.#n)}async batch(e,t="deferred"){this.#i();let r=this.#o();try{Jt(r,ys(t),this.#n);let i=[];for(let n=0;n<e.length;n++)try{if(!r.inTransaction)throw new dr("The transaction has been rolled back",n,"TRANSACTION_CLOSED");let o=e[n],s=Array.isArray(o)?{sql:o[0],args:o[1]||[]}:o;i.push(Jt(r,s,this.#n))}catch(o){if(o instanceof dr)throw o;if(o instanceof je)throw new dr(o.message,n,o.code,o.extendedCode,o.rawCode,o.cause instanceof Error?o.cause:void 0);throw o}return Jt(r,"COMMIT",this.#n),i}finally{if(r.inTransaction)Jt(r,"ROLLBACK",this.#n)}}async migrate(e){this.#i();let t=this.#o();try{Jt(t,"PRAGMA foreign_keys=off",this.#n),Jt(t,ys("deferred"),this.#n);let r=[];for(let i=0;i<e.length;i++)try{if(!t.inTransaction)throw new dr("The transaction has been rolled back",i,"TRANSACTION_CLOSED");r.push(Jt(t,e[i],this.#n))}catch(n){if(n instanceof dr)throw n;if(n instanceof je)throw new dr(n.message,i,n.code,n.extendedCode,n.rawCode,n.cause instanceof Error?n.cause:void 0);throw n}return Jt(t,"COMMIT",this.#n),r}finally{if(t.inTransaction)Jt(t,"ROLLBACK",this.#n);Jt(t,"PRAGMA foreign_keys=on",this.#n)}}async transaction(e="write"){let t=this.#o();return Jt(t,ys(e),this.#n),this.#r=null,new wK(t,this.#n)}async executeMultiple(e){this.#i();let t=this.#o();try{return vK(t,e)}finally{if(t.inTransaction)Jt(t,"ROLLBACK",this.#n)}}async sync(){this.#i();let e=await this.#o().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 up.default(this.#e,this.#t),this.closed=!1}}close(){if(this.closed=!0,this.#r!==null)this.#r.close(),this.#r=null}#i(){if(this.closed)throw new je("The client is closed","CLIENT_CLOSED")}#o(){if(this.#r===null)this.#r=new up.default(this.#e,this.#t);return this.#r}}class wK{#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(),Jt(this.#e,r,this.#t)}async batch(e){let t=[];for(let r=0;r<e.length;r++)try{this.#r();let i=e[r],n=Array.isArray(i)?{sql:i[0],args:i[1]||[]}:i;t.push(Jt(this.#e,n,this.#t))}catch(i){if(i instanceof dr)throw i;if(i instanceof je)throw new dr(i.message,r,i.code,i.extendedCode,i.rawCode,i.cause instanceof Error?i.cause:void 0);throw i}return t}async executeMultiple(e){return this.#r(),vK(this.#e,e)}async rollback(){if(!this.#e.open)return;this.#r(),Jt(this.#e,"ROLLBACK",this.#t)}async commit(){this.#r(),Jt(this.#e,"COMMIT",this.#t)}close(){if(this.#e.inTransaction)Jt(this.#e,"ROLLBACK",this.#t)}get closed(){return!this.#e.inTransaction}#r(){if(this.closed)throw new je("The transaction is closed","TRANSACTION_CLOSED")}}function Jt(e,t,r){let i,n;if(typeof t==="string")i=t,n=[];else if(i=t.sql,Array.isArray(t.args))n=t.args.map((o)=>yK(o,r));else{n={};for(let o in t.args){let s=o[0]==="@"||o[0]==="$"||o[0]===":"?o.substring(1):o;n[s]=yK(t.args[o],r)}}try{let o=e.prepare(i);o.safeIntegers(!0);let s=!0;try{o.raw(!0)}catch{s=!1}if(s){let a=Array.from(o.columns().map((p)=>p.name)),c=Array.from(o.columns().map((p)=>p.type??"")),l=o.all(n).map((p)=>xve(p,a,r)),u=0,d=void 0;return new eu(a,c,l,0,void 0)}else{let a=o.run(n),c=a.changes,l=BigInt(a.lastInsertRowid);return new eu([],[],[],c,l)}}catch(o){throw _K(o)}}function xve(e,t,r){let i={};Object.defineProperty(i,"length",{value:e.length});for(let n=0;n<e.length;++n){let o=Sve(e[n],r);Object.defineProperty(i,n,{value:o});let s=t[n];if(!Object.hasOwn(i,s))Object.defineProperty(i,s,{value:o,enumerable:!0,configurable:!0,writable:!0})}return i}function Sve(e,t){if(typeof e==="bigint")if(t==="number"){if(e<wve||e>vve)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 bK)return e.buffer;return e}function yK(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<_ve||e>kve)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 bK.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 vK(e,t){try{e.exec(t)}catch(r){throw _K(r)}}function _K(e){if(e instanceof up.default.SqliteError){let t=e.code,r=Eve(e.rawCode);return new je(e.message,r,t,e.rawCode,e)}return e}function Eve(e){if(e===void 0)return"SQLITE_UNKNOWN";let t=e&255;return Ive[t]??`SQLITE_UNKNOWN_${t.toString()}`}var up,wve,vve=9007199254740991n,_ve,kve=9223372036854775807n,Ive;var kK=x(()=>{Kn();lp();tu();up=rc(gK(),1);Kn();wve=-9007199254740991n;_ve=-9223372036854775808n;Ive={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 xs;var g$=x(()=>{if(typeof WebSocket<"u")xs=WebSocket;else if(typeof global<"u")xs=global.WebSocket;else if(typeof window<"u")xs=window.WebSocket;else if(typeof self<"u")xs=self.WebSocket});class iu{constructor(){this.intMode="number"}intMode}var st,qe,dp,Pt,fp,ou,qa,Jn,kr,vi;var zt=x(()=>{st=class st extends Error{constructor(e){super(e);this.name="ClientError"}};qe=class qe extends st{constructor(e){super(e);this.name="ProtoError"}};dp=class dp extends st{code;proto;constructor(e,t){super(e);this.name="ResponseError",this.code=t.code,this.proto=t,this.stack=void 0}};Pt=class Pt extends st{constructor(e,t){if(t!==void 0){super(`${e}: ${t}`);this.cause=t}else super(e);this.name="ClosedError"}};fp=class fp extends st{constructor(e){super(e);this.name="WebSocketUnsupportedError"}};ou=class ou extends st{constructor(e){super(e);this.name="WebSocketError"}};qa=class qa extends st{status;constructor(e,t){super(e);this.status=t,this.name="HttpServerError"}};Jn=class Jn extends st{constructor(e){super(e);this.name="ProtocolVersionError"}};kr=class kr extends st{constructor(e){super(e);this.name="InternalError"}};vi=class vi extends st{constructor(e){super(e);this.name="MisuseError"}}});function Gr(e){if(typeof e==="string")return e;throw su(e,"string")}function pn(e){if(e===null||e===void 0)return;else if(typeof e==="string")return e;throw su(e,"string or null")}function no(e){if(typeof e==="number")return e;throw su(e,"number")}function Ss(e){if(typeof e==="boolean")return e;throw su(e,"boolean")}function pp(e){if(Array.isArray(e))return e;throw su(e,"array")}function Ut(e){if(e!==null&&typeof e==="object"&&!Array.isArray(e))return e;throw su(e,"object")}function Vn(e,t){return pp(e).map((r)=>t(Ut(r)))}function su(e,t){if(e===void 0)return new qe(`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 qe(`Expected ${t}, received ${r}`)}function Ua(e,t){return t(Ut(e))}var au=x(()=>{zt()});class EK{#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 i=0;i<t.length;++i){if(i!==0)this.#e.push(",");this.begin(),r(this,t[i]),this.end()}this.#e.push("]")}}function mp(e,t){let r=[],i=new EK(r);return i.begin(),t(i,e),i.end(),r.join("")}var Ma=0,hp=1,gp=2,IK=5;class AK{#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 TK{#e;#t;constructor(e){this.#e=e,this.#t=-1}setup(e){this.#t=e}#r(e){if(this.#t!==e)throw new qe(`Expected wire type ${e}, got ${this.#t}`);this.#t=-1}bytes(){this.#r(gp);let e=this.#e.varint();return this.#e.bytes(e)}string(){return new TextDecoder().decode(this.bytes())}message(e){return ws(this.bytes(),e)}int32(){return this.#r(Ma),this.#e.varint()}uint32(){return this.int32()}bool(){return this.int32()!==0}uint64(){return this.#r(Ma),this.#e.varintBig()}sint64(){let e=this.uint64();return e>>1n^-(e&1n)}double(){return this.#r(hp),this.#e.double()}maybeSkip(){if(this.#t<0)return;else if(this.#t===Ma)this.#e.skipVarint();else if(this.#t===hp)this.#e.skip(8);else if(this.#t===gp){let e=this.#e.varint();this.#e.skip(e)}else if(this.#t===IK)this.#e.skip(4);else throw new qe(`Unexpected wire type ${this.#t}`);this.#t=-1}}function ws(e,t){let r=new AK(e),i=new TK(r),n=t.default();while(!r.eof()){let o=r.varint(),s=o>>3,a=o&7;i.setup(a);let c=t[s];if(c!==void 0){let l=c(i,n);if(l!==void 0)n=l}i.maybeSkip()}return n}var y$=x(()=>{zt()});class b${#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}#i(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),i=new Uint8Array(r),n=new DataView(r);i.set(new Uint8Array(this.#e,0,this.#n)),this.#e=r,this.#t=i,this.#r=n}#o(e){this.#i(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.#i(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.#o(e<<3|t)}bytes(e,t){this.#s(e,gp),this.#o(t.byteLength),this.#i(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 i=new b$;r(i,t),this.bytes(e,i.data())}int32(e,t){this.#s(e,Ma),this.#o(t)}uint32(e,t){this.int32(e,t)}bool(e,t){this.int32(e,t?1:0)}sint64(e,t){this.#s(e,Ma),this.#a(t<<1n^t>>63n)}double(e,t){this.#s(e,hp),this.#i(8),this.#r.setFloat64(this.#n,t,!0),this.#n+=8}data(){return new Uint8Array(this.#e,0,this.#n)}}function yp(e,t){let r=new b$;return t(r,e),r.data()}var CK=()=>{};var x$=x(()=>{au();y$();CK()});class vs{#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 kr("Freeing an id that is not allocated");if(this.#t.delete(this.#e.size),e<this.#e.size)this.#t.add(e)}}var S$=x(()=>{zt()});function rt(e,t){throw new kr(t)}var Tn=x(()=>{zt()});function cu(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<Tve||e>Cve)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 w$(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 vi("Invalid value for IntMode");else if(e instanceof Uint8Array)return e.slice().buffer;else if(e===void 0)throw new qe("Received unrecognized type of Value");else throw rt(e,"Impossible type of Value")}var Tve,Cve=9223372036854775807n;var v$=x(()=>{zt();Tn();Tve=-9223372036854775808n});function Fa(e){return{affectedRowCount:e.affectedRowCount,lastInsertRowid:e.lastInsertRowid,columnNames:e.cols.map((t)=>t.name),columnDecltypes:e.cols.map((t)=>t.decltype)}}function Zb(e,t){let r=Fa(e),i=e.rows.map((n)=>$K(r.columnNames,n,t));return{...r,rows:i}}function Hb(e,t){let r=Fa(e),i;if(e.rows.length>0)i=$K(r.columnNames,e.rows[0],t);return{...r,row:i}}function Kb(e,t){let r=Fa(e),i;if(e.rows.length>0&&r.columnNames.length>0)i=w$(e.rows[0][0],t);return{...r,value:i}}function $K(e,t,r){let i={};Object.defineProperty(i,"length",{value:t.length});for(let n=0;n<t.length;++n){let o=w$(t[n],r);Object.defineProperty(i,n,{value:o});let s=e[n];if(s!==void 0&&!Object.hasOwn(i,s))Object.defineProperty(i,s,{value:o,enumerable:!0,configurable:!0,writable:!0})}return i}function io(e){return new dp(e.message,e)}var bp=x(()=>{zt();v$()});class Za{#e;#t;#r;constructor(e,t){this.#e=e,this.#t=t,this.#r=void 0}_getSqlId(e){if(this.#e!==e)throw new vi("Attempted to use SQL text opened with other object");else if(this.#r!==void 0)throw new Pt("SQL text is closed",this.#r);return this.#t}close(){this._setClosed(new st("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 xp(e,t){if(t instanceof Za)return{sqlId:t._getSqlId(e)};else return{sql:""+t}}var lu=x(()=>{zt()});class _s{#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 Sp{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(cu(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]=cu(t),this}bindName(e,t){return this._namedArgs.set(e,cu(t)),this}unbindAll(){return this._args.length=0,this._namedArgs.clear(),this}}function Jb(e,t,r){let i,n=[],o=[];if(t instanceof Sp){i=t.sql,n=t._args;for(let[c,l]of t._namedArgs.entries())o.push({name:c,value:l})}else if(Array.isArray(t))if(i=t[0],Array.isArray(t[1]))n=t[1].map((c)=>cu(c));else o=Object.entries(t[1]).map(([c,l])=>({name:c,value:cu(l)}));else i=t;let{sql:s,sqlId:a}=xp(e,i);return{sql:s,sqlId:a,args:n,namedArgs:o,wantRows:r}}var Vb=x(()=>{lu();v$()});class Wb{_stream;#e;_steps;#t;constructor(e,t){this._stream=e,this.#e=t,this._steps=[],this.#t=!1}step(){return new _$(this)}execute(){if(this.#t)throw new vi("This batch has already been executed");this.#t=!0;let e={steps:this._steps.map((t)=>t.proto)};if(this.#e)return Ove(this._stream,this._steps,e);else return $ve(this._stream,this._steps,e)}}function $ve(e,t,r){return e._batch(r).then((i)=>{for(let n=0;n<t.length;++n){let o=i.stepResults.get(n),s=i.stepErrors.get(n);t[n].callback(o,s)}})}async function Ove(e,t,r){let i=await e._openCursor(r);try{let n=0,o=void 0,s=[];for(;;){let a=await i.next();if(a===void 0)break;if(a.type==="step_begin"){if(a.step<n||a.step>=t.length)throw new qe("Server produced StepBeginEntry for unexpected step");else if(o!==void 0)throw new qe("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,o=a,s=[]}else if(a.type==="step_end"){if(o===void 0)throw new qe("Server produced StepEndEntry but no step is active");let c={cols:o.cols,rows:s,affectedRowCount:a.affectedRowCount,lastInsertRowid:a.lastInsertRowid};t[o.step].callback(c,void 0),o=void 0,s=[]}else if(a.type==="step_error"){if(o===void 0){if(a.step>=t.length)throw new qe("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!==o.step)throw new qe("Server produced StepErrorEntry for unexpected step");o=void 0,s=[]}t[a.step].callback(void 0,a.error),n=a.step+1}else if(a.type==="row"){if(o===void 0)throw new qe("Server produced RowEntry but no step is active");s.push(a.row)}else if(a.type==="error")throw io(a.error);else if(a.type==="none")throw new qe("Server produced unrecognized CursorEntry");else throw rt(a,"Impossible CursorEntry")}if(o!==void 0)throw new qe("Server closed Cursor before terminating active step");for(let a=n;a<t.length;++a)t[a].callback(void 0,void 0)}finally{i.close()}}class _${_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,Zb)}queryRow(e){return this.#t(e,!0,Hb)}queryValue(e){return this.#t(e,!0,Kb)}run(e){return this.#t(e,!1,Fa)}#t(e,t,r){if(this._index!==void 0)throw new vi("This BatchStep has already been added to the batch");let i=Jb(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 o={stmt:i,condition:n};return new Promise((s,a)=>{let c=(l,u)=>{if(l!==void 0&&u!==void 0)a(new qe("Server returned both result and error"));else if(u!==void 0)a(io(u));else if(l!==void 0)s(r(l,this._batch._stream.intMode));else s(void 0)};this._index=this._batch._steps.length,this._batch._steps.push({proto:o,callback:c})})}}class wt{_batch;_proto;constructor(e,t){this._batch=e,this._proto=t}static ok(e){return new wt(e._batch,{type:"ok",step:OK(e)})}static error(e){return new wt(e._batch,{type:"error",step:OK(e)})}static not(e){return new wt(e._batch,{type:"not",cond:e._proto})}static and(e,t){for(let r of t)RK(e,r);return new wt(e,{type:"and",conds:t.map((r)=>r._proto)})}static or(e,t){for(let r of t)RK(e,r);return new wt(e,{type:"or",conds:t.map((r)=>r._proto)})}static isAutocommit(e){return e._stream.client()._ensureVersion(3,"BatchCond.isAutocommit()"),new wt(e,{type:"is_autocommit"})}}function OK(e){if(e._index===void 0)throw new vi("Cannot add a condition referencing a step that has not been added to the batch");return e._index}function RK(e,t){if(t._batch!==e)throw new vi("Cannot mix BatchCond objects for different Batch objects")}var k$=x(()=>{zt();bp();Vb();Tn()});function PK(e){return{paramNames:e.params.map((t)=>t.name),columns:e.cols,isExplain:e.isExplain,isReadonly:e.isReadonly}}class uu{constructor(e){this.intMode=e}query(e){return this.#e(e,!0,Zb)}queryRow(e){return this.#e(e,!0,Hb)}queryValue(e){return this.#e(e,!0,Kb)}run(e){return this.#e(e,!1,Fa)}#e(e,t,r){let i=Jb(this._sqlOwner(),e,t);return this._execute(i).then((n)=>r(n,this.intMode))}batch(e=!1){return new Wb(this,e)}describe(e){let t=xp(this._sqlOwner(),e);return this._describe(t).then(PK)}sequence(e){let t=xp(this._sqlOwner(),e);return this._sequence(t)}intMode}var Gb=x(()=>{k$();bp();lu();Vb()});class wp{}var Rve=1000,Pve=10,E$;var zK=x(()=>{zt();E$=class E$ extends wp{#e;#t;#r;#n;#i;#o;#a;constructor(e,t,r){super();this.#e=e,this.#t=t,this.#r=r,this.#n=new _s,this.#i=new _s,this.#o=void 0,this.#a=!1}async next(){for(;;){if(this.#o!==void 0)throw new Pt("Cursor is closed",this.#o);while(!this.#a&&this.#i.length<Pve)this.#i.push(this.#s());let e=this.#n.shift();if(this.#a||e!==void 0)return e;await this.#i.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:Rve}).then((e)=>e,(e)=>{this._setClosed(e);return})}_setClosed(e){if(this.#o!==void 0)return;this.#o=e,this.#t._sendCursorRequest(this,{type:"close_cursor",cursorId:this.#r}).catch(()=>{return}),this.#t._cursorClosed(this)}close(){this._setClosed(new st("Cursor was manually closed"))}get closed(){return this.#o!==void 0}}});var vp;var I$=x(()=>{zt();Gb();zK();vp=class vp extends uu{#e;#t;#r;#n;#i;#o;static open(e){let t=e._streamIdAlloc.alloc(),r=new vp(e,t),i=()=>{return},n=(s)=>r.#l(s),o={type:"open_stream",streamId:t};return e._sendRequest(o,{responseCallback:i,errorCallback:n}),r}constructor(e,t){super(e.intMode);this.#e=e,this.#t=t,this.#r=new _s,this.#n=void 0,this.#i=!1,this.#o=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 kr("Cursor not associated with the stream attempted to execute a request");return new Promise((r,i)=>{if(this.#o!==void 0)i(new Pt("Stream is closed",this.#o));else this.#e._sendRequest(t,{responseCallback:r,errorCallback:i})})}_cursorClosed(e){if(e!==this.#n)throw new kr("Cursor was closed, but it was not associated with the stream");this.#n=void 0,this.#c()}#s(e){if(this.#o!==void 0)e.errorCallback(new Pt("Stream is closed",this.#o));else if(this.#i)e.errorCallback(new Pt("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.#i){this.#l(new st("Stream was gracefully closed"));break}else if(e?.type==="request"&&this.#n===void 0){let{request:t,responseCallback:r,errorCallback:i}=e;this.#r.shift(),this.#e._sendRequest(t,{responseCallback:r,errorCallback:i})}else if(e?.type==="cursor"&&this.#n===void 0){let{batch:t,cursorCallback:r}=e;this.#r.shift();let i=this.#e._cursorIdAlloc.alloc(),n=new E$(this.#e,this,i),o={type:"open_cursor",streamId:this.#t,cursorId:i,batch:t},s=()=>{return},a=(c)=>n._setClosed(c);this.#e._sendRequest(o,{responseCallback:s,errorCallback:a}),this.#n=n,r(n)}else break}}#l(e){if(this.#o!==void 0)return;if(this.#o=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),i=()=>{return};this.#e._sendRequest(t,{responseCallback:r,errorCallback:i})}close(){this.#l(new st("Stream was manually closed"))}closeGracefully(){this.#i=!0,this.#c()}get closed(){return this.#o!==void 0||this.#i}}});function _p(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,NK),e.arrayObjects("named_args",t.namedArgs,zve),e.boolean("want_rows",t.wantRows)}function zve(e,t){e.string("name",t.name),e.object("value",t.value,NK)}function du(e,t){e.arrayObjects("steps",t.steps,Nve)}function Nve(e,t){if(t.condition!==void 0)e.object("condition",t.condition,A$);e.object("stmt",t.stmt,_p)}function A$(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,A$);else if(t.type==="and"||t.type==="or")e.arrayObjects("conds",t.conds,A$);else if(t.type==="is_autocommit");else throw rt(t,"Impossible type of BatchCond")}function NK(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",Xl.fromUint8Array(t));else if(t===void 0);else throw rt(t,"Impossible type of Value")}var T$=x(()=>{qb();Tn()});function DK(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,Dve);else throw rt(t,"Impossible type of ClientMsg")}function Dve(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,_p);else if(t.type==="batch")e.number("stream_id",t.streamId),e.object("batch",t.batch,du);else if(t.type==="open_cursor")e.number("stream_id",t.streamId),e.number("cursor_id",t.cursorId),e.object("batch",t.batch,du);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 rt(t,"Impossible type of Request")}var LK=x(()=>{T$();Tn()});function kp(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,jK);for(let r of t.namedArgs)e.message(4,r,Lve);e.bool(5,t.wantRows)}function Lve(e,t){e.string(1,t.name),e.message(2,t.value,jK)}function fu(e,t){for(let r of t.steps)e.message(1,r,Bve)}function Bve(e,t){if(t.condition!==void 0)e.message(1,t.condition,C$);e.message(2,t.stmt,kp)}function C$(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,C$);else if(t.type==="and")e.message(4,t.conds,BK);else if(t.type==="or")e.message(5,t.conds,BK);else if(t.type==="is_autocommit")e.message(6,void 0,qK);else throw rt(t,"Impossible type of BatchCond")}function BK(e,t){for(let r of t)e.message(1,r,C$)}function jK(e,t){if(t===null)e.message(1,void 0,qK);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 rt(t,"Impossible type of Value")}function qK(e,t){}var $$=x(()=>{Tn()});function UK(e,t){if(t.type==="hello")e.message(1,t,jve);else if(t.type==="request")e.message(2,t,qve);else throw rt(t,"Impossible type of ClientMsg")}function jve(e,t){if(t.jwt!==void 0)e.string(1,t.jwt)}function qve(e,t){e.int32(1,t.requestId);let r=t.request;if(r.type==="open_stream")e.message(2,r,Uve);else if(r.type==="close_stream")e.message(3,r,Mve);else if(r.type==="execute")e.message(4,r,Fve);else if(r.type==="batch")e.message(5,r,Zve);else if(r.type==="open_cursor")e.message(6,r,Hve);else if(r.type==="close_cursor")e.message(7,r,Kve);else if(r.type==="fetch_cursor")e.message(8,r,Jve);else if(r.type==="sequence")e.message(9,r,Vve);else if(r.type==="describe")e.message(10,r,Wve);else if(r.type==="store_sql")e.message(11,r,Gve);else if(r.type==="close_sql")e.message(12,r,Qve);else if(r.type==="get_autocommit")e.message(13,r,Yve);else throw rt(r,"Impossible type of Request")}function Uve(e,t){e.int32(1,t.streamId)}function Mve(e,t){e.int32(1,t.streamId)}function Fve(e,t){e.int32(1,t.streamId),e.message(2,t.stmt,kp)}function Zve(e,t){e.int32(1,t.streamId),e.message(2,t.batch,fu)}function Hve(e,t){e.int32(1,t.streamId),e.int32(2,t.cursorId),e.message(3,t.batch,fu)}function Kve(e,t){e.int32(1,t.cursorId)}function Jve(e,t){e.int32(1,t.cursorId),e.uint32(2,t.maxCount)}function Vve(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 Wve(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 Gve(e,t){e.int32(1,t.sqlId),e.string(2,t.sql)}function Qve(e,t){e.int32(1,t.sqlId)}function Yve(e,t){e.int32(1,t.streamId)}var MK=x(()=>{$$();Tn()});function ks(e){let t=Gr(e.message),r=pn(e.code);return{message:t,code:r}}function Ep(e){let t=Vn(e.cols,FK),r=pp(e.rows).map((s)=>Vn(s,ZK)),i=no(e.affected_row_count),n=pn(e.last_insert_rowid),o=n!==void 0?BigInt(n):void 0;return{cols:t,rows:r,affectedRowCount:i,lastInsertRowid:o}}function FK(e){let t=pn(e.name),r=pn(e.decltype);return{name:t,decltype:r}}function Qb(e){let t=new Map;pp(e.step_results).forEach((i,n)=>{if(i!==null)t.set(n,Ep(Ut(i)))});let r=new Map;return pp(e.step_errors).forEach((i,n)=>{if(i!==null)r.set(n,ks(Ut(i)))}),{stepResults:t,stepErrors:r}}function Yb(e){let t=Gr(e.type);if(t==="step_begin"){let r=no(e.step),i=Vn(e.cols,FK);return{type:"step_begin",step:r,cols:i}}else if(t==="step_end"){let r=no(e.affected_row_count),i=pn(e.last_insert_rowid),n=i!==void 0?BigInt(i):void 0;return{type:"step_end",affectedRowCount:r,lastInsertRowid:n}}else if(t==="step_error"){let r=no(e.step),i=ks(Ut(e.error));return{type:"step_error",step:r,error:i}}else if(t==="row")return{type:"row",row:Vn(e.row,ZK)};else if(t==="error")return{type:"error",error:ks(Ut(e.error))};else throw new qe("Unexpected type of CursorEntry")}function Xb(e){let t=Vn(e.params,Xve),r=Vn(e.cols,e_e),i=Ss(e.is_explain),n=Ss(e.is_readonly);return{params:t,cols:r,isExplain:i,isReadonly:n}}function Xve(e){return{name:pn(e.name)}}function e_e(e){let t=Gr(e.name),r=pn(e.decltype);return{name:t,decltype:r}}function ZK(e){let t=Gr(e.type);if(t==="null")return null;else if(t==="integer"){let r=Gr(e.value);return BigInt(r)}else if(t==="float")return no(e.value);else if(t==="text")return Gr(e.value);else if(t==="blob")return Xl.toUint8Array(Gr(e.base64));else throw new qe("Unexpected type of Value")}var ex=x(()=>{qb();zt();au()});function HK(e){let t=Gr(e.type);if(t==="hello_ok")return{type:"hello_ok"};else if(t==="hello_error")return{type:"hello_error",error:ks(Ut(e.error))};else if(t==="response_ok"){let r=no(e.request_id),i=t_e(Ut(e.response));return{type:"response_ok",requestId:r,response:i}}else if(t==="response_error"){let r=no(e.request_id),i=ks(Ut(e.error));return{type:"response_error",requestId:r,error:i}}else throw new qe("Unexpected type of ServerMsg")}function t_e(e){let t=Gr(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:Ep(Ut(e.result))};else if(t==="batch")return{type:"batch",result:Qb(Ut(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=Vn(e.entries,Yb),i=Ss(e.done);return{type:"fetch_cursor",entries:r,done:i}}else if(t==="sequence")return{type:"sequence"};else if(t==="describe")return{type:"describe",result:Xb(Ut(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:Ss(e.is_autocommit)};else throw new qe("Unexpected type of Response")}var KK=x(()=>{zt();au();ex()});var Cn,Es,JK,VK,pu,r_e,n_e,tx,i_e,o_e,s_e,mu,a_e,c_e,l_e;var rx=x(()=>{Cn={default(){return{message:"",code:void 0}},1(e,t){t.message=e.string()},2(e,t){t.code=e.string()}},Es={default(){return{cols:[],rows:[],affectedRowCount:0,lastInsertRowid:void 0}},1(e,t){t.cols.push(e.message(JK))},2(e,t){t.rows.push(e.message(VK))},3(e,t){t.affectedRowCount=Number(e.uint64())},4(e,t){t.lastInsertRowid=e.sint64()}},JK={default(){return{name:void 0,decltype:void 0}},1(e,t){t.name=e.string()},2(e,t){t.decltype=e.string()}},VK={default(){return[]},1(e,t){t.push(e.message(l_e))}},pu={default(){return{stepResults:new Map,stepErrors:new Map}},1(e,t){let[r,i]=e.message(r_e);t.stepResults.set(r,i)},2(e,t){let[r,i]=e.message(n_e);t.stepErrors.set(r,i)}},r_e={default(){return[0,Es.default()]},1(e,t){t[0]=e.uint32()},2(e,t){t[1]=e.message(Es)}},n_e={default(){return[0,Cn.default()]},1(e,t){t[0]=e.uint32()},2(e,t){t[1]=e.message(Cn)}},tx={default(){return{type:"none"}},1(e){return e.message(i_e)},2(e){return e.message(o_e)},3(e){return e.message(s_e)},4(e){return{type:"row",row:e.message(VK)}},5(e){return{type:"error",error:e.message(Cn)}}},i_e={default(){return{type:"step_begin",step:0,cols:[]}},1(e,t){t.step=e.uint32()},2(e,t){t.cols.push(e.message(JK))}},o_e={default(){return{type:"step_end",affectedRowCount:0,lastInsertRowid:void 0}},1(e,t){t.affectedRowCount=e.uint32()},2(e,t){t.lastInsertRowid=e.uint64()}},s_e={default(){return{type:"step_error",step:0,error:Cn.default()}},1(e,t){t.step=e.uint32()},2(e,t){t.error=e.message(Cn)}},mu={default(){return{params:[],cols:[],isExplain:!1,isReadonly:!1}},1(e,t){t.params.push(e.message(a_e))},2(e,t){t.cols.push(e.message(c_e))},3(e,t){t.isExplain=e.bool()},4(e,t){t.isReadonly=e.bool()}},a_e={default(){return{name:void 0}},1(e,t){t.name=e.string()}},c_e={default(){return{name:"",decltype:void 0}},1(e,t){t.name=e.string()},2(e,t){t.decltype=e.string()}},l_e={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 WK,u_e,d_e,f_e,p_e,m_e,h_e,g_e,y_e;var GK=x(()=>{rx();WK={default(){return{type:"none"}},1(e){return{type:"hello_ok"}},2(e){return e.message(u_e)},3(e){return e.message(f_e)},4(e){return e.message(d_e)}},u_e={default(){return{type:"hello_error",error:Cn.default()}},1(e,t){t.error=e.message(Cn)}},d_e={default(){return{type:"response_error",requestId:0,error:Cn.default()}},1(e,t){t.requestId=e.int32()},2(e,t){t.error=e.message(Cn)}},f_e={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(p_e)},5(e,t){t.response=e.message(m_e)},6(e,t){t.response={type:"open_cursor"}},7(e,t){t.response={type:"close_cursor"}},8(e,t){t.response=e.message(h_e)},9(e,t){t.response={type:"sequence"}},10(e,t){t.response=e.message(g_e)},11(e,t){t.response={type:"store_sql"}},12(e,t){t.response={type:"close_sql"}},13(e,t){t.response=e.message(y_e)}},p_e={default(){return{type:"execute",result:Es.default()}},1(e,t){t.result=e.message(Es)}},m_e={default(){return{type:"batch",result:pu.default()}},1(e,t){t.result=e.message(pu)}},h_e={default(){return{type:"fetch_cursor",entries:[],done:!1}},1(e,t){t.entries.push(e.message(tx))},2(e,t){t.done=e.bool()}},g_e={default(){return{type:"describe",result:mu.default()}},1(e,t){t.result=e.message(mu)}},y_e={default(){return{type:"get_autocommit",isAutocommit:!1}},1(e,t){t.isAutocommit=e.bool()}}});var QK,O$,nx;var ix=x(()=>{x$();zt();S$();bp();lu();Tn();I$();LK();MK();KK();GK();QK=new Map([["hrana2",{version:2,encoding:"json"}],["hrana1",{version:1,encoding:"json"}]]),O$=new Map([["hrana3-protobuf",{version:3,encoding:"protobuf"}],["hrana3",{version:3,encoding:"json"}],["hrana2",{version:2,encoding:"json"}],["hrana1",{version:1,encoding:"json"}]]);nx=class nx extends iu{#e;#t;#r;#n;#i;#o;#a;#s;#c;_streamIdAlloc;_cursorIdAlloc;#l;constructor(e,t){super();this.#e=e,this.#t=[],this.#r=!1,this.#n=void 0,this.#i=!1,this.#o=void 0,this.#a=!1,this.#s=new Map,this.#c=new vs,this._streamIdAlloc=new vs,this._cursorIdAlloc=new vs,this.#l=new vs,this.#e.binaryType="arraybuffer",this.#e.addEventListener("open",()=>this.#f()),this.#e.addEventListener("close",(r)=>this.#g(r)),this.#e.addEventListener("error",(r)=>this.#p(r)),this.#e.addEventListener("message",(r)=>this.#y(r)),this.#d({type:"hello",jwt:t})}#d(e){if(this.#n!==void 0)throw new kr("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})}}#f(){let e=this.#e.protocol;if(e===void 0){this.#u(new st("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.#o={version:1,encoding:"json"};else if(this.#o=O$.get(e),this.#o===void 0){this.#u(new qe(`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.#o.encoding;if(t==="json"){let r=mp(e,DK);this.#e.send(r)}else if(t==="protobuf"){let r=yp(e,UK);this.#e.send(r)}else throw rt(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.#o.version);this.#t.push({openCallback:r,errorCallback:t})}else e(this.#o.version)})}_ensureVersion(e,t){if(this.#o===void 0||!this.#a)throw new Jn(`${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.#o.version<e)throw new Jn(`${t} is supported on protocol version ${e} and higher, but the WebSocket server only supports version ${this.#o.version}`)}_sendRequest(e,t){if(this.#n!==void 0){t.errorCallback(new Pt("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})}#p(e){let r=e.message??"WebSocket was closed due to an error";this.#u(new ou(r))}#g(e){let t=`WebSocket was closed with code ${e.code}`;if(e.reason)t+=`: ${e.reason}`;this.#u(new ou(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.#o.encoding;if(r==="json"){if(typeof e.data!=="string"){this.#e.close(3003,"Only text messages are accepted with JSON encoding"),this.#u(new qe("Received non-text message from server with JSON encoding"));return}t=Ua(JSON.parse(e.data),HK)}else if(r==="protobuf"){if(!(e.data instanceof ArrayBuffer)){this.#e.close(3003,"Only binary messages are accepted with Protobuf encoding"),this.#u(new qe("Received non-binary message from server with Protobuf encoding"));return}t=ws(new Uint8Array(e.data),WK)}else throw rt(r,"Impossible encoding");this.#h(t)}catch(t){this.#e.close(3007,"Could not handle message"),this.#u(t)}}#h(e){if(e.type==="none")throw new qe("Received an unrecognized ServerMsg");else if(e.type==="hello_ok"||e.type==="hello_error"){if(this.#i)throw new qe("Received a duplicated hello response");if(this.#i=!0,e.type==="hello_error")throw io(e.error);return}else if(!this.#i)throw new qe("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 qe("Received unexpected OK response");this.#c.free(t);try{if(r.type!==e.response.type)throw console.dir({responseState:r,msg:e}),new qe("Received unexpected type of response");r.responseCallback(e.response)}catch(i){throw r.errorCallback(i),i}}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 qe("Received unexpected error response");this.#c.free(t),r.errorCallback(io(e.error))}else throw rt(e,"Impossible ServerMsg type")}openStream(){return vp.open(this)}storeSql(e){this._ensureVersion(2,"storeSql()");let t=this.#l.alloc(),r=new Za(this,t),i=()=>{return},n=(s)=>r._setClosed(s),o={type:"store_sql",sqlId:t,sql:e};return this._sendRequest(o,{responseCallback:i,errorCallback:n}),r}_closeSql(e){if(this.#n!==void 0)return;let t=()=>this.#l.free(e),r=(n)=>this.#u(n),i={type:"close_sql",sqlId:e};this._sendRequest(i,{responseCallback:t,errorCallback:r})}close(){this.#u(new st("Client was manually closed"))}get closed(){return this.#n!==void 0}}});var Ha;var YK=x(()=>{if(typeof queueMicrotask<"u")Ha=queueMicrotask;else{let e=Promise.resolve();Ha=(t)=>{e.then(t)}}});class R${#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 i=new Uint8Array(new ArrayBuffer(r));i.set(this.#e.slice(this.#t,this.#r),0),this.#e=i}this.#r=t,this.#t=0}shift(e){this.#t+=e}}function XK(e){let t=pn(e.baton),r=pn(e.base_url),i=Vn(e.results,b_e);return{baton:t,baseUrl:r,results:i}}function b_e(e){let t=Gr(e.type);if(t==="ok")return{type:"ok",response:x_e(Ut(e.response))};else if(t==="error")return{type:"error",error:ks(Ut(e.error))};else throw new qe("Unexpected type of StreamResult")}function x_e(e){let t=Gr(e.type);if(t==="close")return{type:"close"};else if(t==="execute")return{type:"execute",result:Ep(Ut(e.result))};else if(t==="batch")return{type:"batch",result:Qb(Ut(e.result))};else if(t==="sequence")return{type:"sequence"};else if(t==="describe")return{type:"describe",result:Xb(Ut(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:Ss(e.is_autocommit)};else throw new qe("Unexpected type of StreamResponse")}function eJ(e){let t=pn(e.baton),r=pn(e.base_url);return{baton:t,baseUrl:r}}var P$=x(()=>{zt();au();ex()});var tJ,S_e,w_e,v_e,__e,k_e,E_e,rJ;var z$=x(()=>{rx();tJ={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(S_e))}},S_e={default(){return{type:"none"}},1(e){return{type:"ok",response:e.message(w_e)}},2(e){return{type:"error",error:e.message(Cn)}}},w_e={default(){return{type:"none"}},1(e){return{type:"close"}},2(e){return e.message(v_e)},3(e){return e.message(__e)},4(e){return{type:"sequence"}},5(e){return e.message(k_e)},6(e){return{type:"store_sql"}},7(e){return{type:"close_sql"}},8(e){return e.message(E_e)}},v_e={default(){return{type:"execute",result:Es.default()}},1(e,t){t.result=e.message(Es)}},__e={default(){return{type:"batch",result:pu.default()}},1(e,t){t.result=e.message(pu)}},k_e={default(){return{type:"describe",result:mu.default()}},1(e,t){t.result=e.message(mu)}},E_e={default(){return{type:"get_autocommit",isAutocommit:!1}},1(e,t){t.isAutocommit=e.bool()}},rJ={default(){return{baton:void 0,baseUrl:void 0}},1(e,t){t.baton=e.string()},2(e,t){t.baseUrl=e.string()}}});var N$;var nJ=x(()=>{au();y$();zt();Tn();P$();z$();ex();rx();N$=class N$ extends wp{#e;#t;#r;#n;#i;#o;constructor(e,t){super();this.#e=e,this.#t=t,this.#r=void 0,this.#n=new R$(16384),this.#i=void 0,this.#o=!1}async open(e){if(e.body===null)throw new qe("No response body for cursor request");this.#r=e.body[Symbol.asyncIterator]();let t=await this.#a(eJ,rJ);if(t===void 0)throw new qe("Empty response to cursor request");return t}next(){return this.#a(Yb,tx)}close(){this._setClosed(new st("Cursor was manually closed"))}_setClosed(e){if(this.#i!==void 0)return;if(this.#i=e,this.#e._cursorClosed(this),this.#r!==void 0)this.#r.return()}get closed(){return this.#i!==void 0}async#a(e,t){for(;;){if(this.#o)return;else if(this.#i!==void 0)throw new Pt("Cursor is closed",this.#i);if(this.#t==="json"){let n=this.#s();if(n!==void 0){let o=new TextDecoder().decode(n),s=JSON.parse(o);return Ua(s,e)}}else if(this.#t==="protobuf"){let n=this.#c();if(n!==void 0)return ws(n,t)}else throw rt(this.#t,"Impossible encoding");if(this.#r===void 0)throw new kr("Attempted to read from HTTP cursor before it was opened");let{value:r,done:i}=await this.#r.next();if(i&&this.#n.length===0)this.#o=!0;else if(i)throw new qe("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 i=e.slice(0,r);return this.#n.shift(r+1),i}#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 i=e.slice(r,r+t);return this.#n.shift(r+t),i}}});function iJ(e,t){if(t.baton!==void 0)e.string("baton",t.baton);e.arrayObjects("requests",t.requests,I_e)}function I_e(e,t){if(e.stringRaw("type",t.type),t.type==="close");else if(t.type==="execute")e.object("stmt",t.stmt,_p);else if(t.type==="batch")e.object("batch",t.batch,du);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 rt(t,"Impossible type of StreamRequest")}function oJ(e,t){if(t.baton!==void 0)e.string("baton",t.baton);e.object("batch",t.batch,du)}var D$=x(()=>{T$();Tn()});function sJ(e,t){if(t.baton!==void 0)e.string(1,t.baton);for(let r of t.requests)e.message(2,r,A_e)}function A_e(e,t){if(t.type==="close")e.message(1,t,T_e);else if(t.type==="execute")e.message(2,t,C_e);else if(t.type==="batch")e.message(3,t,$_e);else if(t.type==="sequence")e.message(4,t,O_e);else if(t.type==="describe")e.message(5,t,R_e);else if(t.type==="store_sql")e.message(6,t,P_e);else if(t.type==="close_sql")e.message(7,t,z_e);else if(t.type==="get_autocommit")e.message(8,t,N_e);else throw rt(t,"Impossible type of StreamRequest")}function T_e(e,t){}function C_e(e,t){e.message(1,t.stmt,kp)}function $_e(e,t){e.message(1,t.batch,fu)}function O_e(e,t){if(t.sql!==void 0)e.string(1,t.sql);if(t.sqlId!==void 0)e.int32(2,t.sqlId)}function R_e(e,t){if(t.sql!==void 0)e.string(1,t.sql);if(t.sqlId!==void 0)e.int32(2,t.sqlId)}function P_e(e,t){e.int32(1,t.sqlId),e.string(2,t.sql)}function z_e(e,t){e.int32(1,t.sqlId)}function N_e(e,t){}function aJ(e,t){if(t.baton!==void 0)e.string(1,t.baton);e.message(2,t.batch,fu)}var L$=x(()=>{$$();Tn()});function D_e(e,t){if(t.results.length!==e.length)throw new qe("Server returned unexpected number of pipeline results");for(let r=0;r<e.length;++r){let i=t.results[r],n=e[r];if(i.type==="ok"){if(i.response.type!==n.request.type)throw new qe("Received unexpected type of response");n.responseCallback(i.response)}else if(i.type==="error")n.errorCallback(io(i.error));else if(i.type==="none")throw new qe("Received unrecognized type of StreamResult");else throw rt(i,"Received impossible type of StreamResult")}}async function L_e(e,t){if(t==="json"){let r=await e.json();return Ua(r,XK)}if(t==="protobuf"){let r=await e.arrayBuffer();return ws(new Uint8Array(r),tJ)}throw await e.body?.cancel(),rt(t,"Impossible encoding")}async function B_e(e){let t=e.headers.get("content-type")??"text/plain",r=`Server returned HTTP status ${e.status}`;if(t==="application/json"){let i=await e.json();if("message"in i)return io(i);return new qa(r,e.status)}if(t==="text/plain"){let i=(await e.text()).trim();if(i!=="")r+=`: ${i}`;return new qa(r,e.status)}return await e.body?.cancel(),new qa(r,e.status)}var ox;var B$=x(()=>{zt();x$();S$();YK();bp();lu();Gb();Tn();nJ();D$();L$();D$();L$();P$();z$();ox=class ox extends uu{#e;#t;#r;#n;#i;#o;#a;#s;#c;#l;#d;#f;#m;constructor(e,t,r,i,n){super(e.intMode);this.#e=e,this.#t=t.toString(),this.#r=r,this.#n=i,this.#i=n,this.#o=void 0,this.#a=new _s,this.#s=!1,this.#l=!1,this.#d=!1,this.#f=void 0,this.#m=new vs}client(){return this.#e}_sqlOwner(){return this}storeSql(e){let t=this.#m.alloc();return this.#p({type:"store_sql",sqlId:t,sql:e}).then(()=>{return},(r)=>this._setClosed(r)),new Za(this,t)}_closeSql(e){if(this.#f!==void 0)return;this.#p({type:"close_sql",sqlId:e}).then(()=>this.#m.free(e),(t)=>this._setClosed(t))}_execute(e){return this.#p({type:"execute",stmt:e}).then((t)=>t.result)}_batch(e){return this.#p({type:"batch",batch:e}).then((t)=>t.result)}_describe(e){return this.#p({type:"describe",sql:e.sql,sqlId:e.sqlId}).then((t)=>t.result)}_sequence(e){return this.#p({type:"sequence",sql:e.sql,sqlId:e.sqlId}).then((t)=>{return})}getAutocommit(){return this.#e._ensureVersion(3,"getAutocommit()"),this.#p({type:"get_autocommit"}).then((e)=>e.isAutocommit)}#p(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 kr("Cursor was closed, but it was not associated with the stream");this.#c=void 0,Ha(()=>this.#u())}close(){this._setClosed(new st("Stream was manually closed"))}closeGracefully(){this.#l=!0,Ha(()=>this.#u())}get closed(){return this.#f!==void 0||this.#l}_setClosed(e){if(this.#f!==void 0)return;if(this.#f=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.#o!==void 0||this.#s)&&!this.#d)this.#a.push({type:"pipeline",request:{type:"close"},responseCallback:()=>{return},errorCallback:()=>{return}}),this.#d=!0,Ha(()=>this.#u())}#g(e){if(this.#f!==void 0)throw new Pt("Stream is closed",this.#f);else if(this.#l)throw new Pt("Stream is closing",void 0);else this.#a.push(e),Ha(()=>this.#u())}#u(){if(this.#s||this.#c!==void 0)return;if(this.#l&&this.#a.length===0){this._setClosed(new st("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 i=this.#a.first();if(i!==void 0&&i.type==="pipeline")r.push(i),this.#a.shift();else if(i===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.#h(e,t);else throw rt(t,"Impossible type of QueueEntry")}#y(e,t){this.#b(()=>this.#x(t,e),(r)=>L_e(r,e.encoding),(r)=>r.baton,(r)=>r.baseUrl,(r)=>D_e(t,r),(r)=>t.forEach((i)=>i.errorCallback(r)))}#h(e,t){let r=new N$(this,e.encoding);this.#c=r,this.#b(()=>this.#w(t,e),(i)=>r.open(i),(i)=>i.baton,(i)=>i.baseUrl,(i)=>t.cursorCallback(r),(i)=>t.errorCallback(i))}#b(e,t,r,i,n,o){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 B_e(a).then((c)=>{throw c});return t(a)}).then((a)=>{this.#o=r(a),this.#t=i(a)??this.#t,n(a)}).catch((a)=>{this._setClosed(a),o(a)}).finally(()=>{this.#s=!1,this.#u()})}#x(e,t){return this.#S(new URL(t.pipelinePath,this.#t),{baton:this.#o,requests:e.map((r)=>r.request)},t.encoding,iJ,sJ)}#w(e,t){if(t.cursorPath===void 0)throw new Jn(`Cursors are supported only on protocol version 3 and higher, but the HTTP server only supports version ${t.version}.`);return this.#S(new URL(t.cursorPath,this.#t),{baton:this.#o,batch:e.batch},t.encoding,oJ,aJ)}#S(e,t,r,i,n){let o,s;if(r==="json")o=mp(t,i),s="application/json";else if(r==="protobuf")o=yp(t,n),s="application/x-protobuf";else throw rt(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.#i!==void 0)a.set("x-turso-encryption-key",this.#i);return new Request(e.toString(),{method:"POST",headers:a,body:o})}}});async function q_e(e,t){let r=e;for(let i of j_e){let n=new URL(i.versionPath,t),o=new Request(n.toString(),{method:"GET"}),s=await r(o);if(await s.arrayBuffer(),s.ok)return i}return j$}var j_e,j$,sx;var q$=x(()=>{zt();B$();j_e=[{versionPath:"v3-protobuf",pipelinePath:"v3-protobuf/pipeline",cursorPath:"v3-protobuf/cursor",version:3,encoding:"protobuf"}],j$={versionPath:"v2",pipelinePath:"v2/pipeline",cursorPath:void 0,version:2,encoding:"json"};sx=class sx extends iu{#e;#t;#r;#n;#i;#o;_endpointPromise;_endpoint;constructor(e,t,r,i,n=2){super();if(this.#e=e,this.#t=t,this.#r=r??globalThis.fetch,this.#n=i,this.#i=void 0,this.#o=new Set,n==3)this._endpointPromise=q_e(this.#r,this.#e),this._endpointPromise.then((o)=>this._endpoint=o,(o)=>this.#a(o));else this._endpointPromise=Promise.resolve(j$),this._endpointPromise.then((o)=>this._endpoint=o,(o)=>this.#a(o))}async getVersion(){if(this._endpoint!==void 0)return this._endpoint.version;return(await this._endpointPromise).version}_ensureVersion(e,t){if(e<=j$.version)return;else if(this._endpoint===void 0)throw new Jn(`${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 Jn(`${t} is supported only on protocol version ${e} and higher, but the HTTP server only supports version ${this._endpoint.version}.`)}openStream(){if(this.#i!==void 0)throw new Pt("Client is closed",this.#i);let e=new ox(this,this.#e,this.#t,this.#r,this.#n);return this.#o.add(e),e}_streamClosed(e){this.#o.delete(e)}close(){this.#a(new st("Client was manually closed"))}get closed(){return this.#i!==void 0}#a(e){if(this.#i!==void 0)return;this.#i=e;for(let t of Array.from(this.#o))t._setClosed(new Pt("Client was closed",e))}}});var cJ=x(()=>{zt()});function U$(e,t,r=2){if(typeof xs>"u")throw new fp("WebSockets are not supported in this environment");var i=void 0;if(r==3)i=Array.from(O$.keys());else i=Array.from(QK.keys());let n=new xs(e,i);return new nx(n,t)}function M$(e,t,r,i,n=2){return new sx(e instanceof URL?e:new URL(e),t,r,i,n)}var ax=x(()=>{g$();ix();zt();q$();ix();g$();k$();cJ();lu();Vb();Gb();q$();B$();ix();I$();zt()});class Ip{#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 je("Cannot execute statements because the transaction is closed","TRANSACTION_CLOSED");try{let r=e.map(oo),i;if(this.#r===void 0){this._getSqlCache().apply(r);let o=t.batch(this.#t>=3),s=o.step(),a=s.run(ys(this.#e)),c=s;i=r.map((l)=>{let u=o.step().condition(wt.ok(c));if(this.#t>=3)u.condition(wt.not(wt.isAutocommit(o)));let d=u.query(l);return d.catch(()=>{return}),c=u,d}),this.#r=o.execute().then(()=>a).then(()=>{return});try{await this.#r}catch(l){throw this.close(),l}}else{if(this.#t<3)await this.#r;this._getSqlCache().apply(r);let o=t.batch(this.#t>=3),s=void 0;i=r.map((a)=>{let c=o.step();if(s!==void 0)c.condition(wt.ok(s));if(this.#t>=3)c.condition(wt.not(wt.isAutocommit(o)));let l=c.query(a);return l.catch(()=>{return}),s=c,l}),await o.execute()}let n=[];for(let o=0;o<i.length;o++)try{let s=await i[o];if(s===void 0)throw new dr("Statement in a transaction was not executed, probably because the transaction has been rolled back",o,"TRANSACTION_CLOSED");n.push(gu(s))}catch(s){if(s instanceof dr)throw s;let a=yt(s);if(a instanceof je)throw new dr(a.message,o,a.code,a.extendedCode,a.rawCode,a.cause instanceof Error?a.cause:void 0);throw a}return n}catch(r){throw yt(r)}}async executeMultiple(e){let t=this._getStream();if(t.closed)throw new je("Cannot execute statements because the transaction is closed","TRANSACTION_CLOSED");try{if(this.#r===void 0){this.#r=t.run(ys(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 yt(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 yt(r)});e.closeGracefully(),await t}catch(e){throw yt(e)}finally{this.close()}}async commit(){try{let e=this._getStream();if(e.closed)throw new je("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 yt(r)});e.closeGracefully(),await t}catch(e){throw yt(e)}finally{this.close()}}}async function hu(e,t,r,i,n=!1){if(n)r.step().run("PRAGMA foreign_keys=off");let o=r.step(),s=o.run(ys(e)),a=o,c=i.map((m)=>{let y=r.step().condition(wt.ok(a));if(t>=3)y.condition(wt.not(wt.isAutocommit(r)));let g=y.query(m);return a=y,g}),l=r.step().condition(wt.ok(a));if(t>=3)l.condition(wt.not(wt.isAutocommit(r)));let u=l.run("COMMIT");if(r.step().condition(wt.not(wt.ok(l))).run("ROLLBACK").catch((m)=>{return}),n)r.step().run("PRAGMA foreign_keys=on");await r.execute();let p=[];await s;for(let m=0;m<c.length;m++)try{let y=await c[m];if(y===void 0)throw new dr("Statement in a batch was not executed, probably because the transaction has been rolled back",m,"TRANSACTION_CLOSED");p.push(gu(y))}catch(y){if(y instanceof dr)throw y;let g=yt(y);if(g instanceof je)throw new dr(g.message,m,g.code,g.extendedCode,g.rawCode,g.cause instanceof Error?g.cause:void 0);throw g}return await u,p}function oo(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 i=new Sp(t);if(r)if(Array.isArray(r))i.bindIndexes(r);else for(let[n,o]of Object.entries(r))i.bindName(n,o);return i}function gu(e){let t=e.columnNames.map((s)=>s??""),r=e.columnDecltypes.map((s)=>s??""),i=e.rows,n=e.affectedRowCount,o=e.lastInsertRowid!==void 0?e.lastInsertRowid:void 0;return new eu(t,r,i,n,o)}function yt(e){if(e instanceof st){let t=lJ(e);return new je(e.message,t,void 0,void 0,e)}return e}function lJ(e){if(e instanceof dp&&e.code!==void 0)return e.code;else if(e instanceof qe)return"HRANA_PROTO_ERROR";else if(e instanceof Pt)return e.cause instanceof st?lJ(e.cause):"HRANA_CLOSED_ERROR";else if(e instanceof ou)return"HRANA_WEBSOCKET_ERROR";else if(e instanceof qa)return"SERVER_ERROR";else if(e instanceof Jn)return"PROTOCOL_VERSION_ERROR";else if(e instanceof kr)return"INTERNAL_ERROR";else return"UNKNOWN"}var Z$=x(()=>{ax();Kn();tu()});class yu{#e;#t;capacity;constructor(e,t){this.#e=e,this.#t=new uJ,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 i=r.sql;if(i.length>=5000)continue;let n=this.#t.get(i);if(n===void 0){while(this.#t.size+1>this.capacity){let[o,s]=this.#t.peekLru();if(t.has(s))break;s.close(),this.#t.delete(o)}if(this.#t.size+1<=this.capacity)n=this.#e.storeSql(i),this.#t.set(i,n)}if(n!==void 0)r.sql=n,t.add(n)}}}class uJ{#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 H$=ee(function(L9e,fJ){function U_e(e){var t=0,r=[];function i(){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 o(c){return new Promise(function(l,u){r.push({fn:c,resolve:l,reject:u}),a.queue=r.length})}function s(c){t++;try{return Promise.resolve(c()).then(function(l){return i(),l},function(l){throw i(),l})}catch(l){return i(),Promise.reject(l)}}var a=function(c){if(t>=e)return o(c);else return s(c)};return a}function M_e(e,t){var r=!1,i=this;return Promise.all(e.map(function(){var n=arguments;return i(function(){if(!r)return t.apply(void 0,n).catch(function(o){throw r=!0,o})})}))}function dJ(e){return e.queue=0,e.map=M_e,e}fJ.exports=function(e){if(e)return dJ(U_e(e));else return dJ(function(t){return t()})}});function hJ(e){if(e.scheme!=="wss"&&e.scheme!=="ws")throw new je(`The WebSocket client supports only "libsql:", "wss:" and "ws:" URLs, got ${JSON.stringify(e.scheme+":")}. For more information, please read ${xi}`,"URL_SCHEME_NOT_SUPPORTED");if(e.encryptionKey!==void 0)throw new je("Encryption key is not supported by the remote client.","ENCRYPTION_KEY_NOT_SUPPORTED");if(e.scheme==="ws"&&e.tls)throw new je('A "ws:" URL cannot opt into TLS by using ?tls=1',"URL_INVALID");else if(e.scheme==="wss"&&!e.tls)throw new je('A "wss:" URL cannot opt out of TLS by using ?tls=0',"URL_INVALID");let t=sp(e.scheme,e.authority,e.path),r;try{r=U$(t,e.authToken)}catch(i){if(i instanceof fp){let n=e.scheme==="wss"?"https":"http",o=sp(n,e.authority,e.path);throw new je(`This environment does not support WebSockets, please switch to the HTTP client by using a "${n}:" URL (${JSON.stringify(o)}). For more information, please read ${xi}`,"WEBSOCKETS_NOT_SUPPORTED")}throw yt(i)}return new gJ(r,t,e.authToken,e.intMode,e.concurrency)}class gJ{#e;#t;#r;#n;#i;closed;protocol;#o;#a;constructor(e,t,r,i,n){this.#e=t,this.#t=r,this.#r=i,this.#n=this.#c(e),this.#i=void 0,this.closed=!1,this.protocol="ws",this.#a=mJ.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 i=await this.#s();try{let n=oo(r);i.conn.sqlCache.apply([n]);let o=i.stream.query(n);i.stream.closeGracefully();let s=await o;return gu(s)}catch(n){throw yt(n)}finally{this._closeStream(i)}})}async batch(e,t="deferred"){return this.limit(async()=>{let r=await this.#s();try{let n=e.map((l)=>{if(Array.isArray(l))return{sql:l[0],args:l[1]||[]};return l}).map(oo),o=await r.conn.client.getVersion();r.conn.sqlCache.apply(n);let s=r.stream.batch(o>=3);return await hu(t,o,s,n)}catch(i){throw yt(i)}finally{this._closeStream(r)}})}async migrate(e){return this.limit(async()=>{let t=await this.#s();try{let r=e.map(oo),i=await t.conn.client.getVersion(),n=t.stream.batch(i>=3);return await hu("deferred",i,n,r,!0)}catch(r){throw yt(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 yJ(this,t,e,r)}catch(r){throw this._closeStream(t),yt(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 yt(r)}finally{this._closeStream(t)}})}sync(){throw new je("sync not supported in ws mode","SYNC_NOT_SUPPORTED")}async#s(){if(this.closed)throw new je("The client is closed","CLIENT_CLOSED");if(new Date().valueOf()-this.#n.openTime.valueOf()>F_e&&this.#i===void 0){let i=this.#c();this.#i=i,i.client.getVersion().then((n)=>{if(this.#n!==i){if(this.#n.streamStates.size===0)this.#n.client.close()}this.#n=i,this.#i=void 0},(n)=>{this.#i=void 0})}if(this.#n.client.closed)try{if(this.#i!==void 0)this.#n=this.#i;else this.#n=this.#c()}catch(i){throw yt(i)}let r=this.#n;try{if(r.useSqlCache===void 0){if(r.useSqlCache=await r.client.getVersion()>=2,r.useSqlCache)r.sqlCache.capacity=pJ}let i=r.client.openStream();i.intMode=this.#r;let n={conn:r,stream:i};return r.streamStates.add(n),n}catch(i){throw yt(i)}}#c(e){try{return e??=U$(this.#e,this.#t),{client:e,useSqlCache:void 0,sqlCache:new yu(e,0),openTime:new Date,streamStates:new Set}}catch(t){throw yt(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.#i){try{this.#i.client.close()}catch{}this.#i=void 0}let e=this.#c(),t=await e.client.getVersion();if(e.useSqlCache=t>=2,e.useSqlCache)e.sqlCache.capacity=pJ;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.#i){try{this.#i.client.close()}catch{}this.#i=void 0}this.closed=!0}}var mJ,F_e=60000,pJ=100,yJ;var bJ=x(()=>{ax();Kn();lp();Z$();Lb();tu();mJ=rc(H$(),1);Kn();yJ=class yJ extends Ip{#e;#t;constructor(e,t,r,i){super(r,i);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 SJ(e){if(e.scheme!=="https"&&e.scheme!=="http")throw new je(`The HTTP client supports only "libsql:", "https:" and "http:" URLs, got ${JSON.stringify(e.scheme+":")}. For more information, please read ${xi}`,"URL_SCHEME_NOT_SUPPORTED");if(e.encryptionKey!==void 0)throw new je("Encryption key is not supported by the remote client.","ENCRYPTION_KEY_NOT_SUPPORTED");if(e.scheme==="http"&&e.tls)throw new je('A "http:" URL cannot opt into TLS by using ?tls=1',"URL_INVALID");else if(e.scheme==="https"&&!e.tls)throw new je('A "https:" URL cannot opt out of TLS by using ?tls=0',"URL_INVALID");let t=sp(e.scheme,e.authority,e.path);return new vJ(t,e.authToken,e.intMode,e.fetch,e.concurrency,e.remoteEncryptionKey)}class vJ{#e;protocol;#t;#r;#n;#i;#o;#a;#s;constructor(e,t,r,i,n,o){this.#t=e,this.#o=t,this.#r=r,this.#n=i,this.#i=n,this.#a=o,this.#e=M$(this.#t,this.#o,this.#n,o),this.#e.intMode=this.#r,this.protocol="http",this.#s=xJ.default(this.#i)}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 i=oo(r),n,o=this.#e.openStream();try{n=o.query(i)}finally{o.closeGracefully()}let s=await n;return gu(s)}catch(i){throw yt(i)}})}async batch(e,t="deferred"){return this.limit(async()=>{try{let i=e.map((c)=>{if(Array.isArray(c))return{sql:c[0],args:c[1]||[]};return c}).map(oo),n=await this.#e.getVersion(),o,s=this.#e.openStream();try{new yu(s,wJ).apply(i);let l=s.batch(!1);o=hu(t,n,l,i)}finally{s.closeGracefully()}return await o}catch(r){throw yt(r)}})}async migrate(e){return this.limit(async()=>{try{let t=e.map(oo),r=await this.#e.getVersion(),i,n=this.#e.openStream();try{let s=n.batch(!1);i=hu("deferred",r,s,t,!0)}finally{n.closeGracefully()}return await i}catch(t){throw yt(t)}})}async transaction(e="write"){return this.limit(async()=>{try{let t=await this.#e.getVersion();return new _J(this.#e.openStream(),e,t)}catch(t){throw yt(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 yt(t)}})}sync(){throw new je("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=M$(this.#t,this.#o,this.#n,this.#a),this.#e.intMode=this.#r}}get closed(){return this.#e.closed}}var xJ,wJ=30,_J;var kJ=x(()=>{ax();Kn();lp();Z$();Lb();tu();xJ=rc(H$(),1);Kn();_J=class _J extends Ip{#e;#t;constructor(e,t,r){super(t,r);this.#e=e,this.#t=new yu(e,wJ)}_getStream(){return this.#e}_getSqlCache(){return this.#t}close(){this.#e.close()}get closed(){return this.#e.closed}}});function bu(e){return Z_e(cp(e,!0))}function Z_e(e){if(e.scheme==="wss"||e.scheme==="ws")return hJ(e);else if(e.scheme==="https"||e.scheme==="http")return SJ(e);else return xK(e)}var K$=x(()=>{lp();kK();bJ();kJ();Kn()});function ce(e,t){if(!e||typeof e!=="object")return!1;if(e instanceof t)return!0;if(!Object.prototype.hasOwnProperty.call(t,J))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(J in r&&r[J]===t[J])return!0;r=Object.getPrototypeOf(r)}return!1}var J;var De=x(()=>{J=Symbol.for("drizzle:entityKind")});var nt;var Wn=x(()=>{De();nt=class nt{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[J]="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 Ap;var cx=x(()=>{De();Ap=class Ap{static[J]="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 Er;var xu=x(()=>{Er=Symbol.for("drizzle:Name")});var J$,EJ;var IJ=x(()=>{De();xu();J$=class J${static[J]="PgForeignKeyBuilder";reference;_onUpdate="no action";_onDelete="no action";constructor(e,t){if(this.reference=()=>{let{name:r,columns:i,foreignColumns:n}=e();return{name:r,columns:i,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 EJ(e,this)}};EJ=class EJ{constructor(e,t){this.table=e,this.reference=t.reference,this.onUpdate=t._onUpdate,this.onDelete=t._onDelete}static[J]="PgForeignKey";reference;onUpdate;onDelete;getName(){let{name:e,columns:t,foreignColumns:r}=this.reference(),i=t.map((s)=>s.name),n=r.map((s)=>s.name),o=[this.table[Er],...i,r[0].table[Er],...n];return e??`${o.join("_")}_fk`}}});function lx(e,...t){return e(...t)}var V$=()=>{};function W$(e,t){return`${e[Er]}_${t.join("_")}_unique`}var AJ,H_e,TJ;var CJ=x(()=>{De();xu();AJ=class AJ{constructor(e,t){this.name=t,this.columns=e}static[J]="PgUniqueConstraintBuilder";columns;nullsNotDistinctConfig=!1;nullsNotDistinct(){return this.nullsNotDistinctConfig=!0,this}build(e){return new TJ(e,this.columns,this.nullsNotDistinctConfig,this.name)}};H_e=class H_e{static[J]="PgUniqueOnConstraintBuilder";name;constructor(e){this.name=e}on(...e){return new AJ(e,this.name)}};TJ=class TJ{constructor(e,t,r,i){this.table=e,this.columns=t,this.name=i??W$(this.table,this.columns.map((n)=>n.name)),this.nullsNotDistinct=r}static[J]="PgUniqueConstraint";columns;name;nullsNotDistinct=!1;getName(){return this.name}}});function $J(e,t,r){for(let i=t;i<e.length;i++){let n=e[i];if(n==="\\"){i++;continue}if(n==='"')return[e.slice(t,i).replace(/\\/g,""),i+1];if(r)continue;if(n===","||n==="}")return[e.slice(t,i).replace(/\\/g,""),i]}return[e.slice(t).replace(/\\/g,""),e.length]}function OJ(e,t=0){let r=[],i=t,n=!1;while(i<e.length){let o=e[i];if(o===","){if(n||i===t)r.push("");n=!0,i++;continue}if(n=!1,o==="\\"){i+=2;continue}if(o==='"'){let[c,l]=$J(e,i+1,!0);r.push(c),i=l;continue}if(o==="}")return[r,i+1];if(o==="{"){let[c,l]=OJ(e,i+1);r.push(c),i=l;continue}let[s,a]=$J(e,i,!1);r.push(s),i=a}return[r,i]}function RJ(e){let[t]=OJ(e,1);return t}function G$(e){return`{${e.map((t)=>{if(Array.isArray(t))return G$(t);if(typeof t==="string")return`"${t.replace(/\\/g,"\\\\").replace(/"/g,"\\\"")}"`;return`${t}`}).join(",")}}`}var PJ=()=>{};var Tp,Su,zJ,K_e,NJ,Q$;var DJ=x(()=>{cx();Wn();De();IJ();V$();CJ();PJ();Tp=class Tp extends Ap{foreignKeyConfigs=[];static[J]="PgColumnBuilder";array(e){return new NJ(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:i})=>lx((n,o)=>{let s=new J$(()=>{let a=n();return{columns:[e],foreignColumns:[a]}});if(o.onUpdate)s.onUpdate(o.onUpdate);if(o.onDelete)s.onDelete(o.onDelete);return s.build(t)},r,i))}buildExtraConfigColumn(e){return new zJ(e,this.config)}};Su=class Su extends nt{constructor(e,t){if(!t.uniqueName)t.uniqueName=W$(e,[t.name]);super(e,t);this.table=e}static[J]="PgColumn"};zJ=class zJ extends Su{static[J]="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}};K_e=class K_e{static[J]="IndexedColumn";constructor(e,t,r,i){this.name=e,this.keyAsName=t,this.type=r,this.indexConfig=i}name;keyAsName;type;indexConfig};NJ=class NJ extends Tp{static[J]="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 Q$(e,this.config,t)}};Q$=class Q$ extends Su{constructor(e,t,r,i){super(e,t);this.baseColumn=r,this.range=i,this.size=t.size}size;static[J]="PgArray";getSQLType(){return`${this.baseColumn.getSQLType()}[${typeof this.size==="number"?this.size:""}]`}mapFromDriverValue(e){if(typeof e==="string")e=RJ(e);return e.map((t)=>this.baseColumn.mapFromDriverValue(t))}mapToDriverValue(e,t=!1){let r=e.map((i)=>i===null?null:ce(this.baseColumn,Q$)?this.baseColumn.mapToDriverValue(i,!0):this.baseColumn.mapToDriverValue(i));if(t)return r;return G$(r)}}});function jJ(e){return!!e&&typeof e==="function"&&LJ in e&&e[LJ]===!0}var J_e,BJ,LJ,V_e,qJ;var UJ=x(()=>{De();DJ();J_e=class J_e extends Tp{static[J]="PgEnumObjectColumnBuilder";constructor(e,t){super(e,"string","PgEnumObjectColumn");this.config.enum=t}build(e){return new BJ(e,this.config)}};BJ=class BJ extends Su{static[J]="PgEnumObjectColumn";enum;enumValues=this.config.enum.enumValues;constructor(e,t){super(e,t);this.enum=t.enum}getSQLType(){return this.enum.enumName}};LJ=Symbol.for("drizzle:isPgEnum");V_e=class V_e extends Tp{static[J]="PgEnumColumnBuilder";constructor(e,t){super(e,"string","PgEnumColumn");this.config.enum=t}build(e){return new qJ(e,this.config)}};qJ=class qJ extends Su{static[J]="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 vt,Cp;var Gn=x(()=>{De();vt=class vt{static[J]="Subquery";constructor(e,t,r,i=!1,n=[]){this._={brand:"Subquery",sql:e,selectedFields:t,alias:r,isWith:i,usedTables:n}}};Cp=class Cp extends vt{static[J]="WithSubquery"}});var MJ="0.45.2";var FJ=()=>{};var Y$,X$,ZJ;var HJ=x(()=>{V$();FJ();ZJ={startActiveSpan(e,t){if(!Y$)return t();if(!X$)X$=Y$.trace.getTracer("drizzle-orm",MJ);return lx((r,i)=>i.startActiveSpan(e,(n)=>{try{return t(n)}catch(o){throw n.setStatus({code:r.SpanStatusCode.ERROR,message:o instanceof Error?o.message:"Unknown error"}),o}finally{n.end()}}),Y$,X$)}}});var _t;var so=x(()=>{_t=Symbol.for("drizzle:ViewBaseConfig")});function Is(e){return e[Er]}function Ka(e){return`${e[ux]??"public"}.${e[Er]}`}var ux,dx,KJ,eO,tO,$p,JJ,W_e,we;var Ir=x(()=>{De();xu();ux=Symbol.for("drizzle:Schema"),dx=Symbol.for("drizzle:Columns"),KJ=Symbol.for("drizzle:ExtraConfigColumns"),eO=Symbol.for("drizzle:OriginalName"),tO=Symbol.for("drizzle:BaseName"),$p=Symbol.for("drizzle:IsAlias"),JJ=Symbol.for("drizzle:ExtraConfigBuilder"),W_e=Symbol.for("drizzle:IsDrizzleTable");we=class we{static[J]="Table";static Symbol={Name:Er,Schema:ux,OriginalName:eO,Columns:dx,ExtraConfigColumns:KJ,BaseName:tO,IsAlias:$p,ExtraConfigBuilder:JJ};[Er];[eO];[ux];[dx];[KJ];[tO];[$p]=!1;[W_e]=!0;[JJ]=void 0;constructor(e,t,r){this[Er]=this[eO]=e,this[ux]=t,this[tO]=r}}});function rO(e){return e!==null&&e!==void 0&&typeof e.getSQL==="function"}function Q_e(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 VJ(e){return typeof e==="object"&&e!==null&&"mapToDriverValue"in e&&typeof e.mapToDriverValue==="function"}function q(e,...t){let r=[];if(t.length>0||e.length>0&&e[0]!=="")r.push(new Vt(e[0]));for(let[i,n]of t.entries())r.push(n,new Vt(e[i+1]));return new Te(r)}function Op(e,t){return e.map((r)=>{if(ce(r,As)){if(!(r.name in t))throw Error(`No value for placeholder "${r.name}" was provided`);return t[r.name]}if(ce(r,mn)&&ce(r.value,As)){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 G_e,Vt,Te,fx,WJ,GJ,VVe,mn,As,Y_e,$n;var pr=x(()=>{De();UJ();Gn();HJ();so();Wn();Ir();G_e=class G_e{static[J]="FakePrimitiveParam"};Vt=class Vt{static[J]="StringChunk";value;constructor(e){this.value=Array.isArray(e)?e:[e]}getSQL(){return new Te([this])}};Te=class Te{constructor(e){this.queryChunks=e;for(let t of e)if(ce(t,we)){let r=t[we.Symbol.Schema];this.usedTables.push(r===void 0?t[we.Symbol.Name]:r+"."+t[we.Symbol.Name])}}static[J]="SQL";decoder=WJ;shouldInlineParams=!1;usedTables=[];append(e){return this.queryChunks.push(...e.queryChunks),this}toQuery(e){return ZJ.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:i,escapeName:n,escapeParam:o,prepareTyping:s,inlineParams:a,paramStartIndex:c}=r;return Q_e(e.map((l)=>{if(ce(l,Vt))return{sql:l.value.join(""),params:[]};if(ce(l,fx))return{sql:n(l.value),params:[]};if(l===void 0)return{sql:"",params:[]};if(Array.isArray(l)){let u=[new Vt("(")];for(let[d,p]of l.entries())if(u.push(p),d<l.length-1)u.push(new Vt(", "));return u.push(new Vt(")")),this.buildQueryFromSourceParams(u,r)}if(ce(l,Te))return this.buildQueryFromSourceParams(l.queryChunks,{...r,inlineParams:a||l.shouldInlineParams});if(ce(l,we)){let u=l[we.Symbol.Schema],d=l[we.Symbol.Name];return{sql:u===void 0||l[$p]?n(d):n(u)+"."+n(d),params:[]}}if(ce(l,nt)){let u=i.getColumnCasing(l);if(t.invokeSource==="indexes")return{sql:n(u),params:[]};let d=l.table[we.Symbol.Schema];return{sql:l.table[$p]||d===void 0?n(l.table[we.Symbol.Name])+"."+n(u):n(d)+"."+n(l.table[we.Symbol.Name])+"."+n(u),params:[]}}if(ce(l,$n)){let u=l[_t].schema,d=l[_t].name;return{sql:u===void 0||l[_t].isAlias?n(d):n(u)+"."+n(d),params:[]}}if(ce(l,mn)){if(ce(l.value,As))return{sql:o(c.value++,l),params:[l],typings:["none"]};let u=l.value===null?null:l.encoder.mapToDriverValue(l.value);if(ce(u,Te))return this.buildQueryFromSourceParams([u],r);if(a)return{sql:this.mapInlineParam(u,r),params:[]};let d=["none"];if(s)d=[s(l.encoder)];return{sql:o(c.value++,u),params:[u],typings:d}}if(ce(l,As))return{sql:o(c.value++,l),params:[l],typings:["none"]};if(ce(l,Te.Aliased)&&l.fieldAlias!==void 0)return{sql:n(l.fieldAlias),params:[]};if(ce(l,vt)){if(l._.isWith)return{sql:n(l._.alias),params:[]};return this.buildQueryFromSourceParams([new Vt("("),l._.sql,new Vt(") "),new fx(l._.alias)],r)}if(jJ(l)){if(l.schema)return{sql:n(l.schema)+"."+n(l.enumName),params:[]};return{sql:n(l.enumName),params:[]}}if(rO(l)){if(l.shouldOmitSQLParens?.())return this.buildQueryFromSourceParams([l.getSQL()],r);return this.buildQueryFromSourceParams([new Vt("("),l.getSQL(),new Vt(")")],r)}if(a)return{sql:this.mapInlineParam(l,r),params:[]};return{sql:o(c.value++,l),params:[l],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 Te.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}};fx=class fx{constructor(e){this.value=e}static[J]="Name";brand;getSQL(){return new Te([this])}};WJ={mapFromDriverValue:(e)=>e},GJ={mapToDriverValue:(e)=>e},VVe={...WJ,...GJ};mn=class mn{constructor(e,t=GJ){this.value=e,this.encoder=t}static[J]="Param";brand;getSQL(){return new Te([this])}};((e)=>{function t(){return new Te([])}e.empty=t;function r(c){return new Te(c)}e.fromList=r;function i(c){return new Te([new Vt(c)])}e.raw=i;function n(c,l){let u=[];for(let[d,p]of c.entries()){if(d>0&&l!==void 0)u.push(l);u.push(p)}return new Te(u)}e.join=n;function o(c){return new fx(c)}e.identifier=o;function s(c){return new As(c)}e.placeholder=s;function a(c,l){return new mn(c,l)}e.param=a})(q||(q={}));((e)=>{class t{constructor(r,i){this.sql=r,this.fieldAlias=i}static[J]="SQL.Aliased";isSelectionField=!1;getSQL(){return this.sql}clone(){return new t(this.sql,this.fieldAlias)}}e.Aliased=t})(Te||(Te={}));As=class As{constructor(e){this.name=e}static[J]="Placeholder";getSQL(){return new Te([this])}};Y_e=Symbol.for("drizzle:IsDrizzleView");$n=class $n{static[J]="View";[_t];[Y_e]=!0;constructor({name:e,schema:t,selectedFields:r,query:i}){this[_t]={name:e,originalName:e,schema:t,selectedFields:r,query:i,isExisting:!i,isAlias:!1}}getSQL(){return new Te([this])}};nt.prototype.getSQL=function(){return new Te([this])};we.prototype.getSQL=function(){return new Te([this])};vt.prototype.getSQL=function(){return new Te([this])}});function nO(e,t,r){let i={},n=e.reduce((o,{path:s,field:a},c)=>{let l;if(ce(a,nt))l=a;else if(ce(a,Te))l=a.decoder;else if(ce(a,vt))l=a._.sql.decoder;else l=a.sql.decoder;let u=o;for(let[d,p]of s.entries())if(d<s.length-1){if(!(p in u))u[p]={};u=u[p]}else{let m=t[c],y=u[p]=m===null?null:l.mapFromDriverValue(m);if(r&&ce(a,nt)&&s.length===2){let g=s[0];if(!(g in i))i[g]=y===null?Is(a.table):!1;else if(typeof i[g]==="string"&&i[g]!==Is(a.table))i[g]=!1}}return o},{});if(r&&Object.keys(i).length>0){for(let[o,s]of Object.entries(i))if(typeof s==="string"&&!r[s])n[o]=null}return n}function On(e,t){return Object.entries(e).reduce((r,[i,n])=>{if(typeof i!=="string")return r;let o=t?[...t,i]:[i];if(ce(n,nt)||ce(n,Te)||ce(n,Te.Aliased)||ce(n,vt))r.push({path:o,field:n});else if(ce(n,we))r.push(...On(n[we.Symbol.Columns],o));else r.push(...On(n,o));return r},[])}function Rp(e,t){let r=Object.keys(e),i=Object.keys(t);if(r.length!==i.length)return!1;for(let[n,o]of r.entries())if(o!==i[n])return!1;return!0}function px(e,t){let r=Object.entries(t).filter(([,i])=>i!==void 0).map(([i,n])=>{if(ce(n,Te)||ce(n,nt))return[i,n];else return[i,new mn(n,e[we.Symbol.Columns][i])]});if(r.length===0)throw Error("No values to set");return Object.fromEntries(r)}function QJ(e,t){for(let r of t)for(let i of Object.getOwnPropertyNames(r.prototype)){if(i==="constructor")continue;Object.defineProperty(e.prototype,i,Object.getOwnPropertyDescriptor(r.prototype,i)||Object.create(null))}}function mx(e){return e[we.Symbol.Columns]}function Pp(e){return ce(e,vt)?e._.alias:ce(e,$n)?e[_t].name:ce(e,Te)?void 0:e[we.Symbol.IsAlias]?e[we.Symbol.Name]:e[we.Symbol.BaseName]}function _i(e,t){return{name:typeof e==="string"&&e.length>0?e:"",config:typeof e==="object"?e:t}}function YJ(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 iO;var Ur=x(()=>{Wn();De();pr();Gn();Ir();so();iO=typeof TextDecoder>"u"?null:new TextDecoder});var XJ,oO,sO;var hx=x(()=>{De();XJ=class XJ{static[J]="ConsoleLogWriter";write(e){console.log(e)}};oO=class oO{static[J]="DefaultLogger";writer;constructor(e){this.writer=e?.writer??new XJ}logQuery(e,t){let r=t.map((n)=>{try{return JSON.stringify(n)}catch{return String(n)}}),i=r.length?` -- params: [${r.join(", ")}]`:"";this.writer.write(`Query: ${e}${i}`)}};sO=class sO{static[J]="NoopLogger";logQuery(){}}});var e9,t9,aO;var r9=x(()=>{De();Ir();e9=Symbol.for("drizzle:PgInlineForeignKeys"),t9=Symbol.for("drizzle:EnableRLS");aO=class aO extends we{static[J]="PgTable";static Symbol=Object.assign({},we.Symbol,{InlineForeignKeys:e9,EnableRLS:t9});[e9]=[];[t9]=!1;[we.Symbol.ExtraConfigBuilder]=void 0;[we.Symbol.ExtraConfigColumns]={}}});var cO,n9;var i9=x(()=>{De();r9();cO=class cO{static[J]="PgPrimaryKeyBuilder";columns;name;constructor(e,t){this.columns=e,this.name=t}build(e){return new n9(e,this.columns,this.name)}};n9=class n9{constructor(e,t,r){this.table=e,this.columns=t,this.name=r}static[J]="PgPrimaryKey";columns;name;getName(){return this.name??`${this.table[aO.Symbol.Name]}_${this.columns.map((e)=>e.name).join("_")}_pk`}}});function Qr(e,t){if(VJ(t)&&!rO(e)&&!ce(e,mn)&&!ce(e,As)&&!ce(e,nt)&&!ce(e,we)&&!ce(e,$n))return new mn(e,t);return e}function Nt(...e){let t=e.filter((r)=>r!==void 0);if(t.length===0)return;if(t.length===1)return new Te(t);return new Te([new Vt("("),q.join(t,new Vt(" and ")),new Vt(")")])}function ao(...e){let t=e.filter((r)=>r!==void 0);if(t.length===0)return;if(t.length===1)return new Te(t);return new Te([new Vt("("),q.join(t,new Vt(" or ")),new Vt(")")])}function s9(e){return q`not ${e}`}function Ts(e,t){if(Array.isArray(t)){if(t.length===0)return q`false`;return q`${e} in ${t.map((r)=>Qr(r,e))}`}return q`${e} in ${Qr(t,e)}`}function l9(e,t){if(Array.isArray(t)){if(t.length===0)return q`true`;return q`${e} not in ${t.map((r)=>Qr(r,e))}`}return q`${e} not in ${Qr(t,e)}`}function Rn(e){return q`${e} is null`}function u9(e){return q`${e} is not null`}function yx(e){return q`exists ${e}`}function bx(e){return q`not exists ${e}`}function d9(e,t,r){return q`${e} between ${Qr(t,e)} and ${Qr(r,e)}`}function f9(e,t,r){return q`${e} not between ${Qr(t,e)} and ${Qr(r,e)}`}function p9(e,t){return q`${e} like ${t}`}function m9(e,t){return q`${e} not like ${t}`}function h9(e,t){return q`${e} ilike ${t}`}function g9(e,t){return q`${e} not ilike ${t}`}var et=(e,t)=>q`${e} = ${Qr(t,e)}`,o9=(e,t)=>q`${e} <> ${Qr(t,e)}`,gx=(e,t)=>q`${e} > ${Qr(t,e)}`,a9=(e,t)=>q`${e} >= ${Qr(t,e)}`,c9=(e,t)=>q`${e} < ${Qr(t,e)}`,wu=(e,t)=>q`${e} <= ${Qr(t,e)}`;var y9=x(()=>{Wn();De();Ir();pr()});function co(e){return q`${e} asc`}function Ja(e){return q`${e} desc`}var b9=x(()=>{pr()});var lO=x(()=>{y9();b9()});function S9(){return{and:Nt,between:d9,eq:et,exists:yx,gt:gx,gte:a9,ilike:h9,inArray:Ts,isNull:Rn,isNotNull:u9,like:p9,lt:c9,lte:wu,ne:o9,not:s9,notBetween:f9,notExists:bx,notLike:m9,notIlike:g9,notInArray:l9,or:ao,sql:q}}function w9(){return{sql:q,asc:co,desc:Ja}}function v9(e,t){if(Object.keys(e).length===1&&"default"in e&&!ce(e.default,we))e=e.default;let r={},i={},n={};for(let[o,s]of Object.entries(e))if(ce(s,we)){let a=Ka(s),c=i[a];r[a]=o,n[o]={tsName:o,dbName:s[we.Symbol.Name],schema:s[we.Symbol.Schema],columns:s[we.Symbol.Columns],relations:c?.relations??{},primaryKey:c?.primaryKey??[]};for(let u of Object.values(s[we.Symbol.Columns]))if(u.primary)n[o].primaryKey.push(u);let l=s[we.Symbol.ExtraConfigBuilder]?.(s[we.Symbol.ExtraConfigColumns]);if(l){for(let u of Object.values(l))if(ce(u,cO))n[o].primaryKey.push(...u.columns)}}else if(ce(s,x9)){let a=Ka(s.table),c=r[a],l=s.config(t(s.table)),u;for(let[d,p]of Object.entries(l))if(c){let m=n[c];if(m.relations[d]=p,u)m.primaryKey.push(...u)}else{if(!(a in i))i[a]={relations:{},primaryKey:u};i[a].relations[d]=p}}return{tables:n,tableNamesMap:r}}function X_e(e){return function(r,i){return new Cs(e,r,i,i?.fields.reduce((n,o)=>n&&o.notNull,!0)??!1)}}function eke(e){return function(r,i){return new zp(e,r,i)}}function _9(e,t,r){if(ce(r,Cs)&&r.config)return{fields:r.config.fields,references:r.config.references};let i=t[Ka(r.referencedTable)];if(!i)throw Error(`Table "${r.referencedTable[we.Symbol.Name]}" not found in schema`);let n=e[i];if(!n)throw Error(`Table "${i}" not found in schema`);let o=r.sourceTable,s=t[Ka(o)];if(!s)throw Error(`Table "${o[we.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 "${i}"`):Error(`There are multiple relations between "${i}" and "${r.sourceTable[we.Symbol.Name]}". Please specify relation name`);if(a[0]&&ce(a[0],Cs)&&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 k9(e){return{one:X_e(e),many:eke(e)}}function xx(e,t,r,i,n=(o)=>o){let o={};for(let[s,a]of i.entries())if(a.isJson){let c=t.relations[a.tsKey],l=r[s],u=typeof l==="string"?JSON.parse(l):l;o[a.tsKey]=ce(c,Cs)?u&&xx(e,e[a.relationTableTsKey],u,a.selection,n):u.map((d)=>xx(e,e[a.relationTableTsKey],d,a.selection,n))}else{let c=n(r[s]),l=a.field,u;if(ce(l,nt))u=l;else if(ce(l,Te))u=l.decoder;else u=l.sql.decoder;o[a.tsKey]=c===null?null:u.mapFromDriverValue(c)}return o}var uO,x9,Cs,zp;var Np=x(()=>{Ir();Wn();De();i9();lO();pr();uO=class uO{constructor(e,t,r){this.sourceTable=e,this.referencedTable=t,this.relationName=r,this.referencedTableName=t[we.Symbol.Name]}static[J]="Relation";referencedTableName;fieldName};x9=class x9{constructor(e,t){this.table=e,this.config=t}static[J]="Relations"};Cs=class Cs extends uO{constructor(e,t,r,i){super(e,t,r?.relationName);this.config=r,this.isNullable=i}static[J]="One";withFieldName(e){let t=new Cs(this.sourceTable,this.referencedTable,this.config,this.isNullable);return t.fieldName=e,t}};zp=class zp extends uO{constructor(e,t,r){super(e,t,r?.relationName);this.config=r}static[J]="Many";withFieldName(e){let t=new zp(this.sourceTable,this.referencedTable,this.config);return t.fieldName=e,t}}});function Lp(e,t){return new Proxy(e,new Dp(t,!1))}function ki(e,t){return new Proxy(e,new vu(new Proxy(e.table,new Dp(t,!1))))}function dO(e,t){return new Te.Aliased(Bp(e.sql,t),e.fieldAlias)}function Bp(e,t){return q.join(e.queryChunks.map((r)=>{if(ce(r,nt))return ki(r,t);if(ce(r,Te))return Bp(r,t);if(ce(r,Te.Aliased))return dO(r,t);return r}))}var vu,Dp,tke;var Sx=x(()=>{Wn();De();pr();Ir();so();vu=class vu{constructor(e){this.table=e}static[J]="ColumnAliasProxyHandler";get(e,t){if(t==="table")return this.table;return e[t]}};Dp=class Dp{constructor(e,t){this.alias=e,this.replaceOriginalName=t}static[J]="TableAliasProxyHandler";get(e,t){if(t===we.Symbol.IsAlias)return!0;if(t===we.Symbol.Name)return this.alias;if(this.replaceOriginalName&&t===we.Symbol.OriginalName)return this.alias;if(t===_t)return{...e[_t],name:this.alias,isAlias:!0};if(t===we.Symbol.Columns){let i=e[we.Symbol.Columns];if(!i)return i;let n={};return Object.keys(i).map((o)=>{n[o]=new Proxy(i[o],new vu(new Proxy(e,this)))}),n}let r=e[t];if(ce(r,nt))return new Proxy(r,new vu(new Proxy(e,this)));return r}};tke=class tke{constructor(e){this.alias=e}static[J]="RelationTableAliasProxyHandler";get(e,t){if(t==="sourceTable")return Lp(e.sourceTable,this.alias);return e[t]}}});var bt;var Va=x(()=>{Sx();Wn();De();pr();Gn();so();bt=class bt{static[J]="SelectionProxyHandler";config;constructor(e){this.config={...e}}get(e,t){if(t==="_")return{...e._,selectedFields:new Proxy(e._.selectedFields,this)};if(t===_t)return{...e[_t],selectedFields:new Proxy(e[_t].selectedFields,this)};if(typeof t==="symbol")return e[t];let i=(ce(e,vt)?e._.selectedFields:ce(e,$n)?e[_t].selectedFields:e)[t];if(ce(i,Te.Aliased)){if(this.config.sqlAliasedBehavior==="sql"&&!i.isSelectionField)return i.sql;let n=i.clone();return n.isSelectionField=!0,n}if(ce(i,Te)){if(this.config.sqlBehavior==="sql")return i;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(ce(i,nt)){if(this.config.alias)return new Proxy(i,new vu(new Proxy(i.table,new Dp(this.config.alias,this.config.replaceOriginalName??!1))));return i}if(typeof i!=="object"||i===null)return i;return new Proxy(i,new bt(this.config))}}});var Mr;var lo=x(()=>{De();Mr=class Mr{static[J]="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 fO,E9;var pO=x(()=>{De();xu();fO=class fO{static[J]="SQLiteForeignKeyBuilder";reference;_onUpdate;_onDelete;constructor(e,t){if(this.reference=()=>{let{name:r,columns:i,foreignColumns:n}=e();return{name:r,columns:i,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 E9(e,this)}};E9=class E9{constructor(e,t){this.table=e,this.reference=t.reference,this.onUpdate=t._onUpdate,this.onDelete=t._onDelete}static[J]="SQLiteForeignKey";reference;onUpdate;onDelete;getName(){let{name:e,columns:t,foreignColumns:r}=this.reference(),i=t.map((s)=>s.name),n=r.map((s)=>s.name),o=[this.table[Er],...i,r[0].table[Er],...n];return e??`${o.join("_")}_fk`}}});function mO(e,t){return`${e[Er]}_${t.join("_")}_unique`}var I9,rke,A9;var hO=x(()=>{De();xu();I9=class I9{constructor(e,t){this.name=t,this.columns=e}static[J]="SQLiteUniqueConstraintBuilder";columns;build(e){return new A9(e,this.columns,this.name)}};rke=class rke{static[J]="SQLiteUniqueOnConstraintBuilder";name;constructor(e){this.name=e}on(...e){return new I9(e,this.name)}};A9=class A9{constructor(e,t,r){this.table=e,this.columns=t,this.name=r??mO(this.table,this.columns.map((i)=>i.name))}static[J]="SQLiteUniqueConstraint";columns;name;getName(){return this.name}}});var Xt,At;var $s=x(()=>{cx();Wn();De();pO();hO();Xt=class Xt extends Ap{static[J]="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:i})=>((n,o)=>{let s=new fO(()=>{let a=n();return{columns:[e],foreignColumns:[a]}});if(o.onUpdate)s.onUpdate(o.onUpdate);if(o.onDelete)s.onDelete(o.onDelete);return s.build(t)})(r,i))}};At=class At extends nt{constructor(e,t){if(!t.uniqueName)t.uniqueName=mO(e,[t.name]);super(e,t);this.table=e}static[J]="SQLiteColumn"}});function z9(e,t){let{name:r,config:i}=_i(e,t);if(i?.mode==="json")return new $9(r);if(i?.mode==="bigint")return new T9(r);return new R9(r)}var T9,C9,$9,O9,R9,P9;var gO=x(()=>{De();Ur();$s();T9=class T9 extends Xt{static[J]="SQLiteBigIntBuilder";constructor(e){super(e,"bigint","SQLiteBigInt")}build(e){return new C9(e,this.config)}};C9=class C9 extends At{static[J]="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(iO.decode(e))}mapToDriverValue(e){return Buffer.from(e.toString())}};$9=class $9 extends Xt{static[J]="SQLiteBlobJsonBuilder";constructor(e){super(e,"json","SQLiteBlobJson")}build(e){return new O9(e,this.config)}};O9=class O9 extends At{static[J]="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(iO.decode(e))}mapToDriverValue(e){return Buffer.from(JSON.stringify(e))}};R9=class R9 extends Xt{static[J]="SQLiteBlobBufferBuilder";constructor(e){super(e,"buffer","SQLiteBlobBuffer")}build(e){return new P9(e,this.config)}};P9=class P9 extends At{static[J]="SQLiteBlobBuffer";mapFromDriverValue(e){if(Buffer.isBuffer(e))return e;return Buffer.from(e)}getSQLType(){return"blob"}}});function L9(e){return(t,r)=>{let{name:i,config:n}=_i(t,r);return new N9(i,n,e)}}var N9,D9;var yO=x(()=>{De();Ur();$s();N9=class N9 extends Xt{static[J]="SQLiteCustomColumnBuilder";constructor(e,t,r){super(e,"custom","SQLiteCustomColumn");this.config.fieldConfig=t,this.config.customTypeParams=r}build(e){return new D9(e,this.config)}};D9=class D9 extends At{static[J]="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:i}=_i(e,t);if(i?.mode==="timestamp"||i?.mode==="timestamp_ms")return new q9(r,i.mode);if(i?.mode==="boolean")return new M9(r,i.mode);return new B9(r)}var wx,vx,B9,j9,q9,U9,M9,F9;var bO=x(()=>{De();pr();Ur();$s();wx=class wx extends Xt{static[J]="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()}};vx=class vx extends At{static[J]="SQLiteBaseInteger";autoIncrement=this.config.autoIncrement;getSQLType(){return"integer"}};B9=class B9 extends wx{static[J]="SQLiteIntegerBuilder";constructor(e){super(e,"number","SQLiteInteger")}build(e){return new j9(e,this.config)}};j9=class j9 extends vx{static[J]="SQLiteInteger"};q9=class q9 extends wx{static[J]="SQLiteTimestampBuilder";constructor(e,t){super(e,"date","SQLiteTimestamp");this.config.mode=t}defaultNow(){return this.default(q`(cast((julianday('now') - 2440587.5)*86400000 as integer))`)}build(e){return new U9(e,this.config)}};U9=class U9 extends vx{static[J]="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}};M9=class M9 extends wx{static[J]="SQLiteBooleanBuilder";constructor(e,t){super(e,"boolean","SQLiteBoolean");this.config.mode=t}build(e){return new F9(e,this.config)}};F9=class F9 extends vx{static[J]="SQLiteBoolean";mode=this.config.mode;mapFromDriverValue(e){return Number(e)===1}mapToDriverValue(e){return e?1:0}}});function G9(e,t){let{name:r,config:i}=_i(e,t),n=i?.mode;return n==="number"?new K9(r):n==="bigint"?new V9(r):new Z9(r)}var Z9,H9,K9,J9,V9,W9;var xO=x(()=>{De();Ur();$s();Z9=class Z9 extends Xt{static[J]="SQLiteNumericBuilder";constructor(e){super(e,"string","SQLiteNumeric")}build(e){return new H9(e,this.config)}};H9=class H9 extends At{static[J]="SQLiteNumeric";mapFromDriverValue(e){if(typeof e==="string")return e;return String(e)}getSQLType(){return"numeric"}};K9=class K9 extends Xt{static[J]="SQLiteNumericNumberBuilder";constructor(e){super(e,"number","SQLiteNumericNumber")}build(e){return new J9(e,this.config)}};J9=class J9 extends At{static[J]="SQLiteNumericNumber";mapFromDriverValue(e){if(typeof e==="number")return e;return Number(e)}mapToDriverValue=String;getSQLType(){return"numeric"}};V9=class V9 extends Xt{static[J]="SQLiteNumericBigIntBuilder";constructor(e){super(e,"bigint","SQLiteNumericBigInt")}build(e){return new W9(e,this.config)}};W9=class W9 extends At{static[J]="SQLiteNumericBigInt";mapFromDriverValue=BigInt;mapToDriverValue=String;getSQLType(){return"numeric"}}});function X9(e){return new Q9(e??"")}var Q9,Y9;var SO=x(()=>{De();$s();Q9=class Q9 extends Xt{static[J]="SQLiteRealBuilder";constructor(e){super(e,"number","SQLiteReal")}build(e){return new Y9(e,this.config)}};Y9=class Y9 extends At{static[J]="SQLiteReal";getSQLType(){return"real"}}});function mr(e,t={}){let{name:r,config:i}=_i(e,t);if(i.mode==="json")return new rV(r);return new eV(r,i)}var eV,tV,rV,nV;var wO=x(()=>{De();Ur();$s();eV=class eV extends Xt{static[J]="SQLiteTextBuilder";constructor(e,t){super(e,"string","SQLiteText");this.config.enumValues=t.enum,this.config.length=t.length}build(e){return new tV(e,this.config)}};tV=class tV extends At{static[J]="SQLiteText";enumValues=this.config.enumValues;length=this.config.length;constructor(e,t){super(e,t)}getSQLType(){return`text${this.config.length?`(${this.config.length})`:""}`}};rV=class rV extends Xt{static[J]="SQLiteTextJsonBuilder";constructor(e){super(e,"json","SQLiteTextJson")}build(e){return new nV(e,this.config)}};nV=class nV extends At{static[J]="SQLiteTextJson";getSQLType(){return"text"}mapFromDriverValue(e){return JSON.parse(e)}mapToDriverValue(e){return JSON.stringify(e)}}});function iV(){return{blob:z9,customType:L9,integer:Ar,numeric:G9,real:X9,text:mr}}var oV=x(()=>{gO();yO();bO();xO();SO();wO()});function nke(e,t,r,i,n=e){let o=new Mt(e,i,n),s=typeof t==="function"?t(iV()):t,a=Object.fromEntries(Object.entries(s).map(([l,u])=>{let d=u;d.setName(l);let p=d.build(o);return o[vO].push(...d.buildForeignKeys(p,o)),[l,p]})),c=Object.assign(o,a);if(c[we.Symbol.Columns]=a,c[we.Symbol.ExtraConfigColumns]=a,r)c[Mt.Symbol.ExtraConfigBuilder]=r;return c}var vO,Mt,jp=(e,t,r)=>nke(e,t,r);var uo=x(()=>{De();Ir();oV();vO=Symbol.for("drizzle:SQLiteInlineForeignKeys");Mt=class Mt extends we{static[J]="SQLiteTable";static Symbol=Object.assign({},we.Symbol,{InlineForeignKeys:vO});[we.Symbol.Columns];[vO]=[];[we.Symbol.ExtraConfigBuilder]=void 0}});var ike,sV;var aV=x(()=>{De();ike=class ike{constructor(e,t){this.name=e,this.value=t}static[J]="SQLiteCheckBuilder";brand;build(e){return new sV(e,this)}};sV=class sV{constructor(e,t){this.table=e,this.name=t.name,this.value=t.value}static[J]="SQLiteCheck";name;value}});function Wa(e){return new cV(e,!1)}var cV,lV,uV;var dV=x(()=>{De();cV=class cV{constructor(e,t){this.name=e,this.unique=t}static[J]="SQLiteIndexBuilderOn";on(...e){return new lV(this.name,e,this.unique)}};lV=class lV{static[J]="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 uV(this.config,e)}};uV=class uV{static[J]="SQLiteIndex";config;constructor(e,t){this.config={...e,table:t}}}});var oke,fV;var pV=x(()=>{De();uo();oke=class oke{static[J]="SQLitePrimaryKeyBuilder";columns;name;constructor(e,t){this.columns=e,this.name=t}build(e){return new fV(e,this.columns,this.name)}};fV=class fV{constructor(e,t,r){this.table=e,this.columns=t,this.name=r}static[J]="SQLitePrimaryKey";columns;name;getName(){return this.name??`${this.table[Mt.Symbol.Name]}_${this.columns.map((e)=>e.name).join("_")}_pk`}}});function Qn(e){if(ce(e,Mt))return[`${e[we.Symbol.BaseName]}`];if(ce(e,vt))return e._.usedTables??[];if(ce(e,Te))return e.usedTables??[];return[]}var _u=x(()=>{De();pr();Gn();Ir();uo()});var _x;var mV=x(()=>{De();lo();Va();uo();Ir();Ur();_u();_x=class _x extends Mr{constructor(e,t,r,i){super();this.table=e,this.session=t,this.dialect=r,this.config={table:e,withList:i}}static[J]="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[we.Symbol.Columns],new bt({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[Mt.Symbol.Columns]){return this.config.returning=On(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:Qn(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 ske(e){return(e.replace(/['\u2019]/g,"").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).map((r)=>r.toLowerCase()).join("_")}function ake(e){return(e.replace(/['\u2019]/g,"").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).reduce((r,i,n)=>{let o=n===0?i.toLowerCase():`${i[0].toUpperCase()}${i.slice(1)}`;return r+o},"")}function cke(e){return e}var _O;var hV=x(()=>{De();Ir();_O=class _O{static[J]="CasingCache";cache={};cachedTables={};convert;constructor(e){this.convert=e==="snake_case"?ske:e==="camelCase"?ake:cke}getColumnCasing(e){if(!e.keyAsName)return e.name;let t=e.table[we.Symbol.Schema]??"public",r=e.table[we.Symbol.OriginalName],i=`${t}.${r}.${e.name}`;if(!this.cache[i])this.cacheTable(e.table);return this.cache[i]}cacheTable(e){let t=e[we.Symbol.Schema]??"public",r=e[we.Symbol.OriginalName],i=`${t}.${r}`;if(!this.cachedTables[i]){for(let n of Object.values(e[we.Symbol.Columns])){let o=`${i}.${n.name}`;this.cache[o]=this.convert(n.name)}this.cachedTables[i]=!0}}clearCache(){this.cache={},this.cachedTables={}}}});var ku,fo,kO;var kx=x(()=>{De();ku=class ku extends Error{static[J]="DrizzleError";constructor({message:e,cause:t}){super(e);this.name="DrizzleError",this.cause=t}};fo=class fo extends Error{constructor(e,t,r){super(`Failed query: ${e}
450
+ `,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=Ry(e),r=yl(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=Ry(e),r=yl(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()}}}cge.Parser=IF});var OF=ee(function(yge){var AF=FA(),uge=af(),pf=cf(),dge=XI(),fge=Ge(),pge=XA(),TF=eT();function CF(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new pge.LineCounter||null,prettyErrors:t}}function mge(e,t={}){let{lineCounter:r,prettyErrors:i}=CF(t),n=new TF.Parser(r?.addNewLine),o=new AF.Composer(t),s=Array.from(o.compose(n.parse(e)));if(i&&r)for(let a of s)a.errors.forEach(pf.prettifyError(e,r)),a.warnings.forEach(pf.prettifyError(e,r));if(s.length>0)return s;return Object.assign([],{empty:!0},o.streamInfo())}function $F(e,t={}){let{lineCounter:r,prettyErrors:i}=CF(t),n=new TF.Parser(r?.addNewLine),o=new AF.Composer(t),s=null;for(let a of o.compose(n.parse(e),!0,e.length))if(!s)s=a;else if(s.options.logLevel!=="silent"){s.errors.push(new pf.YAMLParseError(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}if(i&&r)s.errors.forEach(pf.prettifyError(e,r)),s.warnings.forEach(pf.prettifyError(e,r));return s}function hge(e,t,r){let i=void 0;if(typeof t==="function")i=t;else if(r===void 0&&t&&typeof t==="object")r=t;let n=$F(e,r);if(!n)return null;if(n.warnings.forEach((o)=>dge.warn(n.options.logLevel,o)),n.errors.length>0)if(n.options.logLevel!=="silent")throw n.errors[0];else n.errors=[];return n.toJS(Object.assign({reviver:i},r))}function gge(e,t,r){let i=null;if(typeof t==="function"||Array.isArray(t))i=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(fge.isDocument(e)&&!i)return e.toString(r);return new uge.Document(e,i,r).toString(r)}yge.parse=hge;yge.parseAllDocuments=mge;yge.parseDocument=$F;yge.stringify=gge});var vge,_ge,kge,tT,Ege,Vo,Ige,Age,Tge,Cge,tMe,$ge,Oge,Rge,zy,RF,Pge,zge,Nge,Dge,Lge,Bge,jge,qge,Uge,Mge,Bi,ji,Fge,bl,rT,Zge,Hge,Kge,Jge,Vge,Wge,Gge,Qge,Yge,ci,Xge,eye,tye;var mf=x(()=>{vge=FA(),_ge=af(),kge=AA(),tT=cf(),Ege=Kd(),Vo=Ge(),Ige=Fo(),Age=jt(),Tge=Ho(),Cge=Ko(),tMe=$y(),$ge=YA(),Oge=XA(),Rge=eT(),zy=OF(),RF=Zd();Pge=vge.Composer,zge=_ge.Document,Nge=kge.Schema,Dge=tT.YAMLError,Lge=tT.YAMLParseError,Bge=tT.YAMLWarning,jge=Ege.Alias,qge=Vo.isAlias,Uge=Vo.isCollection,Mge=Vo.isDocument,Bi=Vo.isMap,ji=Vo.isNode,Fge=Vo.isPair,bl=Vo.isScalar,rT=Vo.isSeq,Zge=Ige.Pair,Hge=Age.Scalar,Kge=Tge.YAMLMap,Jge=Cge.YAMLSeq,Vge=$ge.Lexer,Wge=Oge.LineCounter,Gge=Rge.Parser,Qge=zy.parse,Yge=zy.parseAllDocuments,ci=zy.parseDocument,Xge=zy.stringify,eye=RF.visit,tye=RF.visitAsync});var BF={};tr(BF,{assertPilotUsersRemoved:()=>iT,createPilotOffboardDriver:()=>nT,offboardPilotUsers:()=>zF});import{access as rye,readdir as nye,readFile as iye,rm as hf,writeFile as oye}from"fs/promises";import{basename as sye,join as qi}from"path";async function zF(e,t){let r=[...new Set(t.handles.map((d)=>Pr.parse(d)))].sort((d,p)=>d.localeCompare(p));if(r.length===0)throw Error("At least one pilot handle is required");let i=t.dryRun??!0,n=`sunset:${r.join(",")}`;if(!i&&t.confirmation!==n)throw Error(`Exact confirmation required: ${n}`);let o=t.env??process.env,s=t.logger??console.info,a=await Ct(e),c=r.map((d)=>aye(a,d,o)),l=t.driver??nT({env:o,fetchImpl:t.fetchImpl,contentRepoTokenName:a.pilot.contentRepoAdminToken}),u=await Promise.all(c.map(async(d)=>({target:d,inspection:await l.inspect(d)})));if(lye(u),uye(u,i,s),!i){for(let d of u)if(!d.inspection.contentRepoArchived)await l.archiveContentRepo(d.target),s(`[${d.target.handle}] archived ${d.target.contentRepo}`);for(let d of u)for(let p of d.inspection.dnsRecords)await l.deleteDnsRecord(d.target,p),s(`[${d.target.handle}] deleted DNS ${p.name}`);for(let d of u)if(d.inspection.server)await l.deleteServer(d.target,d.inspection.server),s(`[${d.target.handle}] deleted ${d.target.instanceName}`);await cye(c,l,t.sleep??((d)=>new Promise((p)=>setTimeout(p,d)))),await dye(e,r),await Oi(e),await iT(e,r),s(`Removed desired state for ${r.length} pilot user(s)`)}return{dryRun:i,handles:r,confirmation:n,plans:u}}function aye(e,t,r){let i=e.users.find((u)=>u.handle===t),n=`${t}${e.pilot.domainSuffix}`,o=i?.domain??n,s=LI(o,{sharedDomain:e.pilot.domainSuffix}),a=i?.cloudflareZoneId??Ny(r,"CF_ZONE_ID"),c=i?.contentRepo??`${e.pilot.contentRepoPrefix}${t}-content`,l=c.includes("/")?c:`${e.pilot.githubOrg}/${c}`;return{handle:t,instanceName:`rover-${t}`,domain:o,previewDomain:s,...o===n?{}:{wwwDomain:`www.${o}`},contentRepo:l,cloudflareZoneId:a}}async function cye(e,t,r){for(let i of e)for(let n=1;n<=20;n+=1){let o=await t.inspect(i);if(!o.server&&o.dnsRecords.length===0&&o.contentRepoArchived)break;if(n===20)throw Error(`[${i.handle}] provider cleanup did not converge`);await r(1500)}}function lye(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 i=new Set([t.domain,t.previewDomain,...t.wwwDomain?[t.wwwDomain]:[]]);for(let n of r.dnsRecords){if(!i.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 uye(e,t,r){r(`${t?"Dry run":"Apply"}: ${e.map(({target:i})=>i.handle).join(", ")}`);for(let{target:i,inspection:n}of e){let o=n.server?`delete ${i.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 ${i.contentRepo}`;r(`[${i.handle}] server: ${o}; DNS: ${s}; repo: ${a}`)}r("Runtime backups: none")}async function dye(e,t){let r=new Set(t),i=qi(e,"cohorts");for(let n of(await nye(i)).filter((o)=>o.endsWith(".yaml"))){let o=qi(i,n),s=await iye(o,"utf8"),a=ci(s);if(a.errors.length>0)throw Error(`${n}: ${a.errors[0]?.message??"invalid YAML"}`);let c=a.get("members",!0);if(!rT(c))throw Error(`${n}: members must be a sequence`);let l=c.items.filter((u)=>!bl(u)||typeof u.value!=="string"||!r.has(u.value));if(l.length===c.items.length)continue;if(l.length===0){await hf(o);continue}c.items=l,yn.parse(a.toJS()),await oye(o,a.toString())}for(let n of t)await Promise.all([hf(qi(e,"users",`${n}.yaml`),{force:!0}),hf(qi(e,"users",`${n}.secrets.yaml`),{force:!0}),hf(qi(e,"users",`${n}.secrets.yaml.age`),{force:!0}),hf(qi(e,"users",n),{recursive:!0,force:!0})])}function nT(e){let t=e.fetchImpl??fetch,r=Ny(e.env,"HCLOUD_TOKEN"),i=Ny(e.env,"CF_API_TOKEN"),n=Ny(e.env,e.contentRepoTokenName);return{async inspect(o){let[s,a,c]=await Promise.all([fye(t,r,o.instanceName),Promise.all([o.domain,o.previewDomain,...o.wwwDomain?[o.wwwDomain]:[]].map((l)=>pye(t,i,o.cloudflareZoneId,l))).then((l)=>l.flat()),mye(t,n,o.contentRepo)]);if(s.length>1)throw Error(`[${o.handle}] expected at most one server, found ${s.length}`);return{...s[0]?{server:s[0]}:{},dnsRecords:a,contentRepoArchived:c.archived}},async archiveContentRepo(o){await xl(t,`https://api.github.com/repos/${o.contentRepo}`,{method:"PATCH",headers:NF(n),body:JSON.stringify({archived:!0})},"GitHub repository archive")},async deleteDnsRecord(o,s){if(Sl(await xl(t,`https://api.cloudflare.com/client/v4/zones/${o.cloudflareZoneId}/dns_records/${s.id}`,{method:"DELETE",headers:DF(i)},"Cloudflare DNS delete")).success!==!0)throw Error(`Cloudflare DNS delete failed for ${s.name}`)},async deleteServer(o,s){await xl(t,`https://api.hetzner.cloud/v1/servers/${s.id}`,{method:"DELETE",headers:{Authorization:`Bearer ${r}`}},"Hetzner server delete",!0)}}}async function fye(e,t,r){let i=new URL("https://api.hetzner.cloud/v1/servers");i.searchParams.set("label_selector",`brain=${r}`);let o=Sl(await xl(e,i.toString(),{headers:{Authorization:`Bearer ${t}`}},"Hetzner server lookup")).servers;if(!Array.isArray(o))throw Error("Hetzner server lookup returned an invalid payload");return o.map((s)=>{let a=Sl(s),c=PF(a.public_net),l=PF(c?.ipv4);return{id:hye(a.id,"Hetzner server id"),name:gf(a.name,"Hetzner server name"),...typeof l?.ip==="string"?{ip:l.ip}:{}}})}async function pye(e,t,r,i){let n=new URL(`https://api.cloudflare.com/client/v4/zones/${r}/dns_records`);n.searchParams.set("name",i);let o=Sl(await xl(e,n.toString(),{headers:DF(t)},"Cloudflare DNS lookup")),s=o.result;if(o.success!==!0||!Array.isArray(s))throw Error(`Cloudflare DNS lookup failed for ${i}`);return s.map((a)=>{let c=Sl(a),l=gf(c.type,"Cloudflare record type");if(l!=="A"&&l!=="CNAME")throw Error(`Unsupported Cloudflare record type ${l} for ${i}`);return{id:gf(c.id,"Cloudflare record id"),name:gf(c.name,"Cloudflare record name"),type:l,content:gf(c.content,"Cloudflare record content")}})}async function mye(e,t,r){let i=Sl(await xl(e,`https://api.github.com/repos/${r}`,{headers:NF(t)},"GitHub repository lookup"));if(typeof i.archived!=="boolean")throw Error(`Invalid repository archive state for ${r}`);return{archived:i.archived}}async function xl(e,t,r,i,n=!1){let o=await e(t,r),s=await o.text();if(!o.ok)throw Error(`${i} failed (${o.status}): ${s}`);if(!s&&n)return{};try{return JSON.parse(s)}catch{throw Error(`${i} returned an invalid JSON response`)}}function NF(e){return{Accept:"application/vnd.github+json",Authorization:`Bearer ${e}`,"Content-Type":"application/json","X-GitHub-Api-Version":"2022-11-28"}}function DF(e){return{Authorization:`Bearer ${e}`}}function Ny(e,t){let r=e[t];if(!r)throw Error(`Missing required environment variable: ${t}`);return r}function LF(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function Sl(e){if(!LF(e))throw Error("Provider returned an unexpected payload");return e}function PF(e){return LF(e)?e:void 0}function gf(e,t){if(typeof e!=="string"||e.length===0)throw Error(`Missing ${t}`);return e}function hye(e,t){if(typeof e!=="number")throw Error(`Missing ${t}`);return e}async function gye(e){try{return await rye(e),!0}catch{return!1}}async function iT(e,t){for(let r of t)for(let i of[qi(e,"users",`${r}.yaml`),qi(e,"users",`${r}.secrets.yaml.age`),qi(e,"users",r)])if(await gye(i))throw Error(`Offboarded user state remains: ${sye(i)}`)}var oT=x(()=>{mf();Ln();BI();Dc();To()});var D8={};tr(D8,{upgradePilotRepo:()=>$we});import{readFile as Iwe}from"fs/promises";import{join as Awe}from"path";async function N8(e){let t=Awe(e,"package.json"),i=Twe.parse(JSON.parse(await Iwe(t,"utf8"))).devDependencies?.["@rizom/ops"];if(!i)throw Error(`${t} does not pin @rizom/ops as a devDependency`);return i}async function Cwe(e,t){let i=await Bun.spawn(e,{cwd:t,stdout:"inherit",stderr:"inherit"}).exited;if(i!==0)throw Error(`${e.join(" ")} failed with exit ${i}`)}async function $we(e,t={}){let r=t.exec??Cwe,i=await N8(e),n=t.version??"latest";await r(["bun","add","--dev","--exact",`@rizom/ops@${n}`],e);let o=await N8(e);return await r(["bun","x","brains-ops","init","."],e),{from:i,to:o}}var Twe;var L8=x(()=>{Re();Twe=f.object({devDependencies:f.record(f.string(),f.string()).optional()})});function B8(e){if(e===null||typeof e!=="object"||Array.isArray(e))return!1;let t=Owe(e);return t===Object.prototype||t===null}var Owe;var j8=x(()=>{Owe=Object.getPrototypeOf});function F8(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:[...zwe]};return{bundles:["core","media","automation","web","chat","site","publishing","federation"],add:["obsidian-vault"]}}function Nwe(e){let t=Rwe.parse(e);return Ao.parse({brainVersion:t.brainVersion,bundleContract:Io,...F8(t.preset),githubOrg:t.githubOrg,contentRepoPrefix:t.contentRepoPrefix,domainSuffix:t.domainSuffix,aiApiKey:t.aiApiKey,gitSyncToken:t.gitSyncToken,contentRepoAdminToken:t.contentRepoAdminToken,agePublicKey:t.agePublicKey})}function Dwe(e){let t=Pwe.parse(e),r=t.presetOverride?F8(t.presetOverride):void 0;return yn.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?{aiApiKeyOverride:t.aiApiKeyOverride}:{},...t.gitSyncTokenOverride?{gitSyncTokenOverride:t.gitSyncTokenOverride}:{}})}function Z8(e){let t=ci(e,{keepSourceTokens:!0});if(t.errors.length>0)throw Error(`Invalid desired-state YAML: ${t.errors[0]?.message}`);if(!Bi(t.contents))throw Error("Desired-state YAML must contain a mapping");return t}function o$(e,t){if(!Bi(e.contents))return;return e.contents.items.find((r)=>bl(r.key)&&r.key.value===t)}function q8(e,t){if(!ji(e)||!ji(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 U8(e,t){if(!e||!ji(t))return;let r=[ji(e.key)?e.key.commentBefore:void 0,ji(e.key)?e.key.comment:void 0,ji(e.value)?e.value.commentBefore:void 0,ji(e.value)?e.value.comment:void 0].filter((i)=>i!==void 0);if(r.length===0)return;t.commentBefore=[t.commentBefore,...r].filter((i)=>i!==void 0).join(`
451
+ `)}function H8(e,t,r,i){if(!Bi(e.contents))throw Error("Desired-state YAML must contain a mapping");let n=e.contents.items.findIndex((s)=>bl(s.key)&&s.key.value===t),o=e.createPair(r,[...i]);if(n>=0){let s=e.contents.items[n];q8(s?.key,o.key),q8(s?.value,o.value),e.contents.items.splice(n,1,o)}else e.contents.add(o);return o}function K8(e){let t=Z8(e),r=Nwe(t.toJS()),i=o$(t,"schemaVersion"),n=o$(t,"model");U8(i,o$(t,"brainVersion")?.key),t.delete("schemaVersion"),t.set("bundleContract",Io);let o=H8(t,"preset","bundles",r.bundles);if(U8(n,o.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 Ao.parse(t.toJS()),t.toString({lineWidth:0})}function J8(e){let t=Z8(e),r=Dwe(t.toJS());if(r.bundlesOverride)H8(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 yn.parse(t.toJS()),t.toString({lineWidth:0})}var M8,rp,Rwe,Pwe,zwe;var V8=x(()=>{Ai();Re();mf();To();M8=f.enum(["core","default","pro"]),rp=f.string().min(1),Rwe=f.strictObject({schemaVersion:f.literal(1),brainVersion:nn,model:f.literal("rover"),githubOrg:f.string().min(1),contentRepoPrefix:f.string().min(1),domainSuffix:f.string().min(1),preset:M8,aiApiKey:rp,gitSyncToken:rp,contentRepoAdminToken:rp,agePublicKey:f.string().startsWith("age1").min(1)}),Pwe=f.strictObject({members:f.array(Pr).min(1),brainVersionOverride:nn.optional(),presetOverride:M8.optional(),aiApiKeyOverride:rp.optional(),gitSyncTokenOverride:rp.optional()}).superRefine((e,t)=>{if(new Set(e.members).size!==e.members.length)t.addIssue({code:f.ZodIssueCode.custom,path:["members"],message:"cohort members must be unique"})}),zwe=["series","portfolio","content-pipeline","social-media","newsletter","stock-photo"]});function G8(e,t){let r=ci(e,{keepSourceTokens:!0});if(r.errors.length>0||!Bi(r.contents))throw Error(`Invalid ${t} YAML`);return r}function Uwe(e,t){return e.length===t.length&&e.every((r,i)=>r===t[i])}function Q8(e,t,r){if(!Uwe(t,r.sourceBundles))throw Error(`${e} source bundles changed after review: expected [${r.sourceBundles.join(", ")}], received [${t.join(", ")}]`)}function Y8(e){let t=Nn(e,qwe);if(!t.ok)throw Error(`Invalid capability bundle review: ${t.error}`);return t.data}function X8(e,t){let r=G8(e,"pilot desired-state"),i=Bwe.parse(r.toJS());return Q8("pilot.yaml",i.bundles,t),r.set("bundleContract",Io),r.set("bundles",t.targetBundles),Ao.parse(r.toJS()),r.toString({lineWidth:0})}function eH(e,t,r){let i=G8(e,`cohort ${t}`),n=jwe.parse(i.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`);Q8(`cohort ${t}`,n.bundlesOverride,r),i.set("bundlesOverride",r.targetBundles)}return yn.parse(i.toJS()),i.toString({lineWidth:0})}var Lwe,s$,Nb,Bwe,jwe,W8,qwe;var tH=x(()=>{Ai();Re();mf();To();Lwe=f.enum(["core","site","publishing","team"]),s$=f.array(Lwe).min(1),Nb=f.array(f.string().min(1)),Bwe=f.strictObject({brainVersion:nn,bundles:s$,add:Nb.optional(),remove:Nb.optional(),githubOrg:f.string().min(1),contentRepoPrefix:f.string().min(1),domainSuffix:f.string().min(1),aiApiKey:f.string().min(1),gitSyncToken:f.string().min(1),contentRepoAdminToken:f.string().min(1),agePublicKey:f.string().startsWith("age1").min(1)}),jwe=f.strictObject({members:f.array(Pr).min(1),brainVersionOverride:nn.optional(),bundlesOverride:s$.optional(),addOverride:Nb.optional(),removeOverride:Nb.optional(),aiApiKeyOverride:f.string().min(1).optional(),gitSyncTokenOverride:f.string().min(1).optional()}),W8=f.strictObject({sourceBundles:s$,targetBundles:f.array(Mh).min(1)}),qwe=f.strictObject({bundleContract:f.literal(Io),pilot:W8,cohorts:f.record(Pr,W8)})});var sH={};tr(sH,{loadCapabilityBundleReview:()=>Gwe,loadReviewedSitePins:()=>Wwe,parseReviewedSitePins:()=>oH,stageLegacyCrossover:()=>Ywe});import{access as Mwe,cp as Fwe,mkdir as rH,readFile as Vl,readdir as iH,writeFile as Jl}from"fs/promises";import{basename as Zwe,join as bi,relative as Db,resolve as nH}from"path";import{fileURLToPath as Hwe}from"url";function oH(e){let t=Nn(e,Kwe);if(!t.ok)throw Error(`Invalid reviewed site pins: ${t.error}`);return t.data.sites}async function Wwe(e){return oH(await Vl(e,"utf8"))}async function Gwe(e){return Y8(await Vl(e,"utf8"))}async function Qwe(e,t){let r=bi(e,"users"),i=(await iH(r,{withFileTypes:!0})).filter((s)=>s.isFile()&&/\.ya?ml$/.test(s.name)).map((s)=>s.name).sort(),n=new Set(Object.keys(t??{})),o=[];for(let s of i){let a=bi(r,s),c=await Vl(a,"utf8"),l=ci(c,{keepSourceTokens:!0});if(l.errors.length>0||!Bi(l.contents))throw Error(`Invalid user desired-state YAML: ${s}`);let u=Jwe.parse(l.toJS());if(!u.siteOverride)continue;let d=t?.[u.handle];if(!d)throw Error(`User ${u.handle} has a siteOverride but no reviewed site pin`);if(n.delete(u.handle),d.package!==u.siteOverride.package||d.theme!==u.siteOverride.theme)throw Error(`Reviewed site pin identity does not match user ${u.handle}`);if(u.siteOverride.version!==void 0&&u.siteOverride.version!==d.version)throw Error(`Reviewed site version does not match the existing pin for user ${u.handle}`);if(u.siteOverride.themeVersion!==void 0&&u.siteOverride.themeVersion!==d.themeVersion)throw Error(`Reviewed theme version does not match the existing pin for user ${u.handle}`);if(l.setIn(["siteOverride","version"],d.version),d.themeVersion!==void 0)l.setIn(["siteOverride","themeVersion"],d.themeVersion);else l.deleteIn(["siteOverride","themeVersion"]);Fh.parse(l.toJS());let p=l.toString({lineWidth:0});if(p!==c)await Jl(a,p),o.push(Db(e,a))}if(n.size>0)throw Error(`Reviewed site pins do not match site users: ${[...n].sort().join(", ")}`);return o}async function Ywe(e,t,r={}){let i=nH(e),n=nH(t);if(i===n||n.startsWith(`${i}/`))throw Error("Crossover output must be outside the source repository");await Fwe(i,n,{recursive:!0,errorOnExist:!0,force:!1,filter:(T)=>{let z=Zwe(T);return z!==".git"&&z!==".operator"&&z!==".brains-ops"&&z!==".turbo"&&z!=="dist"&&z!=="node_modules"&&z!==".env"&&z!==".env.local"&&!z.endsWith(".secrets.yaml")}});let o=[],s=bi(n,"docs","canonical-crossover-record.md");try{await Mwe(s)}catch{await rH(bi(n,"docs"),{recursive:!0}),await Jl(s,await Vl(Vwe,"utf8")),o.push("docs/canonical-crossover-record.md")}let a=bi(n,"pilot.yaml"),c=await Vl(a,"utf8"),u=ci(c).toJS();if(!B8(u))throw Error(`${a} is not a YAML mapping`);let d=Array.isArray(u.bundles),p=r.bundleReview,m;if(d){if(!p)throw Error("Current canonical desired state requires an explicit capability bundle review manifest");m=X8(c,p.pilot)}else m=K8(c);await Jl(a,m),o.push("pilot.yaml");let y=bi(n,"cohorts"),g=(await iH(y,{withFileTypes:!0})).filter((T)=>T.isFile()&&/\.ya?ml$/.test(T.name)).map((T)=>T.name).sort(),b=new Set(Object.keys(p?.cohorts??{}));for(let T of g){let z=bi(y,T),j=await Vl(z,"utf8"),E=T.replace(/\.ya?ml$/,""),Z=p?.cohorts[E];if(Z)b.delete(E);await Jl(z,d?eH(j,E,Z):J8(j)),o.push(Db(n,z))}if(d&&b.size>0)throw Error(`Capability bundle review names unknown cohorts: ${[...b].sort().join(", ")}`);o.push(...await Qwe(n,r.sitePins));let v=await Ct(n),A=Zg(v.pilot.githubOrg);for(let T of v.users){let z=await A(T),j=bi(n,"users",T.handle);if(await rH(j,{recursive:!0}),z.brainYaml){let E=bi(j,"brain.yaml");await Jl(E,z.brainYaml),o.push(Db(n,E))}if(z.envFile){let E=bi(j,".env");await Jl(E,z.envFile),o.push(Db(n,E))}}return await Oi(n,{registry:v}),o.push("views/users.md"),{outputDir:n,changedFiles:[...new Set(o)].sort()}}var Kwe,Jwe,Vwe;var aH=x(()=>{Ai();j8();Re();mf();UI();V8();tH();Ln();Dc();To();Kwe=f.strictObject({sites:f.record(Pr,zE)}),Jwe=f.object({handle:Pr,siteOverride:f.object({package:f.string().min(1),version:nn.optional(),theme:f.string().min(1).optional(),themeVersion:nn.optional()}).optional()}).passthrough(),Vwe=Hwe(new URL("../templates/rover-pilot/docs/canonical-crossover-record.md",import.meta.url))});var cH="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";import{webcrypto as lH}from"crypto";function e0e(e){if(e<0)throw RangeError("Wrong ID size");try{if(!ms||ms.length<e)ms=Buffer.allocUnsafe(e*Xwe),lH.getRandomValues(ms),Wl=0;else if(Wl+e>ms.length)lH.getRandomValues(ms),Wl=0}catch(t){throw ms=void 0,t}Wl+=e}function uH(e=21){e0e(e|=0);let t="";for(let r=Wl-e;r<Wl;r++)t+=cH[ms[r]&63];return t}var Xwe=128,ms,Wl;var dH=()=>{};function to(e=12){return uH(e)}var np=x(()=>{dH()});import{openSync as t0e,writeSync as r0e}from"fs";class fn{static instance=null;level;context;useStderr;format;logFile;fileHandle;constructor(e={},t){if(this.level=e.level??Da.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=t0e(this.logFile,"a")}catch{}}static getInstance(e){if(!fn.instance)fn.instance=new fn(e);else if(e?.useStderr!==void 0)fn.instance.useStderr=e.useStderr;return fn.instance}static resetInstance(){fn.instance=null}static createFresh(e){return new fn(e)}formatEntry(e,t,r){let i=new Date().toISOString();if(this.format==="json"){let n={ts:i,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?`[${i}] [${this.context}] ${t}`:`[${i}] ${t}`}write(e,t,r,i){if(this.format==="json")e(this.formatEntry(t,r,i));else if(i.length>0)e(this.formatEntry(t,r,[]),...i);else e(this.formatEntry(t,r,[]));if(this.fileHandle!==void 0){let n=this.formatJsonEntry(t,r,i);try{r0e(this.fileHandle,n+`
452
+ `)}catch{}}}formatJsonEntry(e,t,r){let i={ts:new Date().toISOString(),level:e,msg:t};if(this.context)i.ctx=this.context;if(r.length>0)i.data=r;return JSON.stringify(i)}silly(e,...t){if(this.level<=Da.SILLY)this.write(console.debug.bind(console),"silly",e,t)}verbose(e,...t){if(this.level<=Da.VERBOSE)this.write(console.debug.bind(console),"verbose",e,t)}debug(e,...t){if(this.level<=Da.DEBUG)this.write(console.debug.bind(console),"debug",e,t)}info(e,...t){if(this.level<=Da.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<=Da.WARN)this.write(console.warn.bind(console),"warn",e,t)}error(e,...t){if(this.level<=Da.ERROR)this.write(console.error.bind(console),"error",e,t)}child(e){return new fn({level:this.level,context:e,useStderr:this.useStderr,format:this.format},this.fileHandle)}setUseStderr(e){this.useStderr=e}}var Da,aHe;var a$=x(()=>{Da={SILLY:0,VERBOSE:1,DEBUG:2,INFO:3,WARN:4,ERROR:5,NONE:6};aHe=fn.getInstance()});var c$,n0e,Gl,dHe;var ip=x(()=>{Po();Re();c$=f.enum(["file_operations","content_operations","data_processing","batch_processing"]),n0e=f.looseObject({pluginId:f.string().optional(),progressToken:f.union([f.string(),f.number()]).optional(),operationType:c$,operationTarget:f.string().optional(),interfaceType:f.string().optional(),conversationId:f.string().optional(),channelId:f.string().optional(),requestedByActor:Vc.optional(),requestedByUserId:f.string().optional(),requestedByInterface:f.string().optional(),silent:f.boolean().optional(),provenance:Ro.optional()}),Gl=f.looseObject({pluginId:f.string().optional(),progressToken:f.union([f.string(),f.number()]).optional(),operationType:c$,operationTarget:f.string().optional(),interfaceType:f.string().optional(),conversationId:f.string().optional(),channelId:f.string().optional(),requestedByActor:Vc.optional(),requestedByUserId:f.string().optional(),requestedByInterface:f.string().optional(),silent:f.boolean().optional(),provenance:Ro.optional(),rootJobId:f.string()}),dHe=f.enum(["none","skip","replace","coalesce"])});var i0e,hs=15000;var op=x(()=>{ip();Re();i0e=f.object({id:f.string(),type:f.string(),data:f.string(),status:f.enum(["pending","processing","completed","failed"]),source:f.string().nullable(),priority:f.number(),retryCount:f.number(),maxRetries:f.number(),lastError:f.string().nullable(),createdAt:f.number(),scheduledFor:f.number(),startedAt:f.number().nullable(),completedAt:f.number().nullable(),attemptId:f.string().nullable(),workerSlotId:f.string().nullable(),workerSessionId:f.string().nullable(),leaseExpiresAt:f.number().nullable(),attemptHeartbeatAt:f.number().nullable(),runtimeUpdatedAt:f.number().nullable(),metadata:Gl,progress:f.custom((e)=>typeof e==="object"&&e!==null&&("progress"in e)&&typeof e.progress==="number").nullable(),result:f.unknown().nullable().optional()})});var l$,fH,He,o0e,s0e,pH,a0e;var gs=x(()=>{Re();ip();l$=f.enum(["pending","processing","completed","failed"]),fH=f.enum(["completed","failed"]),He={PENDING:"pending",PROCESSING:"processing",COMPLETED:"completed",FAILED:"failed"},o0e=f.object({id:f.string(),type:f.string(),status:l$,data:f.unknown(),result:f.unknown().optional(),lastError:f.string().optional().nullable(),attempts:f.number(),maxRetries:f.number(),priority:f.number(),createdAt:f.date(),updatedAt:f.date(),processedAt:f.date().optional().nullable(),completedAt:f.date().optional().nullable(),failedAt:f.date().optional().nullable()}),s0e=f.object({jobId:f.string(),type:f.string(),status:fH,result:f.unknown().optional(),error:f.string().optional()}),pH=f.object({success:f.literal(!1),error:f.string().optional()}),a0e=f.object({id:f.string(),type:f.enum(["job","batch"]),status:l$,message:f.string().optional(),progress:f.object({current:f.number(),total:f.number(),percentage:f.number()}).optional(),aggregationKey:f.string().optional(),batchDetails:f.object({totalOperations:f.number(),completedOperations:f.number(),failedOperations:f.number(),currentOperation:f.string().optional(),errors:f.array(f.string()).optional()}).optional(),jobDetails:f.object({jobType:f.string(),priority:f.number(),retryCount:f.number()}).optional(),metadata:Gl})});var je,dr;var Kn=x(()=>{je=class je extends Error{code;extendedCode;rawCode;constructor(e,t,r,i,n){if(t!==void 0)e=`${t}: ${e}`;super(e,{cause:n});this.code=t,this.extendedCode=r,this.rawCode=i,this.name="LibsqlError"}};dr=class dr extends je{statementIndex;constructor(e,t,r,i,n,o){super(e,r,i,n,o);this.statementIndex=t,this.name="LibsqlBatchError"}}});function mH(e){let t=c0e.exec(e);if(t===null)throw new je(`The URL '${e}' is not in a valid format`,"URL_INVALID");let r=t.groups,i=r.scheme,n=r.authority!==void 0?l0e(r.authority):void 0,o=La(r.path),s=r.query!==void 0?d0e(r.query):void 0,a=r.fragment!==void 0?La(r.fragment):void 0;return{scheme:i,authority:n,path:o,query:s,fragment:a}}function l0e(e){let t=u0e.exec(e);if(t===null)throw new je("The authority part of the URL is not in a valid format","URL_INVALID");let r=t.groups,i=La(r.host_br??r.host),n=r.port?parseInt(r.port,10):void 0,o=r.username!==void 0?{username:La(r.username),password:r.password!==void 0?La(r.password):void 0}:void 0;return{host:i,port:n,userinfo:o}}function d0e(e){let t=e.split("&"),r=[];for(let i of t){if(i==="")continue;let n,o,s=i.indexOf("=");if(s<0)n=i,o="";else n=i.substring(0,s),o=i.substring(s+1);r.push({key:La(n.replaceAll("+"," ")),value:La(o.replaceAll("+"," "))})}return{pairs:r}}function La(e){try{return decodeURIComponent(e)}catch(t){if(t instanceof URIError)throw new je(`URL component has invalid percent encoding: ${t}`,"URL_INVALID",void 0,void 0,t);throw t}}function sp(e,t,r){if(t===void 0)throw new je(`URL with scheme ${JSON.stringify(e+":")} requires authority (the "//" part)`,"URL_INVALID");let i=`${e}:`,n=f0e(t.host),o=p0e(t.port),a=`//${m0e(t.userinfo)}${n}${o}`,c=r.split("/").map(encodeURIComponent).join("/");if(c!==""&&!c.startsWith("/"))c="/"+c;return new URL(`${i}${a}${c}`)}function f0e(e){return e.includes(":")?`[${encodeURI(e)}]`:encodeURI(e)}function p0e(e){return e!==void 0?`:${e}`:""}function m0e(e){if(e===void 0)return"";let t=encodeURIComponent(e.username),r=e.password!==void 0?`:${encodeURIComponent(e.password)}`:"";return`${t}${r}@`}var c0e,u0e;var Lb=x(()=>{Kn();c0e=(()=>new RegExp("^(?<scheme>[A-Za-z][A-Za-z.+-]*):(//(?<authority>[^/?#]*))?(?<path>[^?#]*)(\\?(?<query>[^#]*))?(#(?<fragment>.*))?$","su"))();u0e=(()=>new RegExp("^((?<username>[^:]*)(:(?<password>.*))?@)?((?<host>[^:\\[\\]]*)|(\\[(?<host_br>[^\\[\\]]*)\\]))(:(?<port>[0-9]*))?$","su"))()});var Yl,hH,gH,ap,Bb,h0e,fr,yH,SH=(e)=>e.replace(/=/g,"").replace(/[+\/]/g,(t)=>t=="+"?"-":"_"),wH=(e)=>e.replace(/[^A-Za-z0-9\+\/]/g,""),vH=(e)=>{let t,r,i,n,o="",s=e.length%3;for(let a=0;a<e.length;){if((r=e.charCodeAt(a++))>255||(i=e.charCodeAt(a++))>255||(n=e.charCodeAt(a++))>255)throw TypeError("invalid character found");t=r<<16|i<<8|n,o+=ap[t>>18&63]+ap[t>>12&63]+ap[t>>6&63]+ap[t&63]}return s?o.slice(0,s-3)+"===".substring(s):o},f$,u$,jb=(e,t=!1)=>t?SH(u$(e)):u$(e),g0e=(e)=>{if(e.length<2){var t=e.charCodeAt(0);return t<128?e:t<2048?fr(192|t>>>6)+fr(128|t&63):fr(224|t>>>12&15)+fr(128|t>>>6&63)+fr(128|t&63)}else{var t=65536+(e.charCodeAt(0)-55296)*1024+(e.charCodeAt(1)-56320);return fr(240|t>>>18&7)+fr(128|t>>>12&63)+fr(128|t>>>6&63)+fr(128|t&63)}},y0e,_H=(e)=>e.replace(y0e,g0e),bH,Ql=(e,t=!1)=>t?SH(bH(e)):bH(e),xH=(e)=>Ql(e,!0),b0e,x0e=(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 fr((r>>>10)+55296)+fr((r&1023)+56320);case 3:return fr((15&e.charCodeAt(0))<<12|(63&e.charCodeAt(1))<<6|63&e.charCodeAt(2));default:return fr((31&e.charCodeAt(0))<<6|63&e.charCodeAt(1))}},kH=(e)=>e.replace(b0e,x0e),EH=(e)=>{if(e=e.replace(/\s+/g,""),!h0e.test(e))throw TypeError("malformed base64.");e+="==".slice(2-(e.length&3));let t,r,i,n=[];for(let o=0;o<e.length;)if(t=Bb[e.charAt(o++)]<<18|Bb[e.charAt(o++)]<<12|(r=Bb[e.charAt(o++)])<<6|(i=Bb[e.charAt(o++)]),r===64)n.push(fr(t>>16&255));else if(i===64)n.push(fr(t>>16&255,t>>8&255));else n.push(fr(t>>16&255,t>>8&255,t&255));return n.join("")},p$,IH,AH=(e)=>IH(TH(e)),S0e,TH=(e)=>wH(e.replace(/[-_]/g,(t)=>t=="-"?"+":"/")),d$=(e)=>S0e(TH(e)),w0e=(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)},CH=(e)=>({value:e,enumerable:!1,writable:!0,configurable:!0}),$H=function(){let e=(t,r)=>Object.defineProperty(String.prototype,t,CH(r));e("fromBase64",function(){return d$(this)}),e("toBase64",function(t){return Ql(this,t)}),e("toBase64URI",function(){return Ql(this,!0)}),e("toBase64URL",function(){return Ql(this,!0)}),e("toUint8Array",function(){return AH(this)})},OH=function(){let e=(t,r)=>Object.defineProperty(Uint8Array.prototype,t,CH(r));e("toBase64",function(t){return jb(this,t)}),e("toBase64URI",function(){return jb(this,!0)}),e("toBase64URL",function(){return jb(this,!0)})},v0e=()=>{$H(),OH()},Xl;var qb=x(()=>{Yl=typeof Buffer==="function",hH=typeof TextDecoder==="function"?new TextDecoder("utf-8",{ignoreBOM:!0}):void 0,gH=typeof TextEncoder==="function"?new TextEncoder:void 0,ap=Array.prototype.slice.call("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="),Bb=((e)=>{let t={};return e.forEach((r,i)=>t[r]=i),t})(ap),h0e=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,fr=String.fromCharCode.bind(String),yH=typeof Uint8Array.from==="function"?Uint8Array.from.bind(Uint8Array):(e)=>new Uint8Array(Array.prototype.slice.call(e,0)),f$=typeof btoa==="function"?(e)=>btoa(e):Yl?(e)=>Buffer.from(e,"binary").toString("base64"):vH,u$=Yl?(e)=>Buffer.from(e).toString("base64"):(e)=>{let r=[];for(let i=0,n=e.length;i<n;i+=4096)r.push(fr.apply(null,e.subarray(i,i+4096)));return f$(r.join(""))},y0e=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,bH=Yl?(e)=>Buffer.from(e,"utf8").toString("base64"):gH?(e)=>u$(gH.encode(e)):(e)=>f$(_H(e)),b0e=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,p$=typeof atob==="function"?(e)=>atob(wH(e)):Yl?(e)=>Buffer.from(e,"base64").toString("binary"):EH,IH=Yl?(e)=>yH(Buffer.from(e,"base64")):(e)=>yH(p$(e).split("").map((t)=>t.charCodeAt(0))),S0e=Yl?(e)=>Buffer.from(e,"base64").toString("utf8"):hH?(e)=>hH.decode(IH(e)):(e)=>kH(p$(e)),Xl={version:"3.8.0",VERSION:"3.8.0",atob:p$,atobPolyfill:EH,btoa:f$,btoaPolyfill:vH,fromBase64:d$,toBase64:Ql,encode:Ql,encodeURI:xH,encodeURL:xH,utob:_H,btou:kH,decode:d$,isValid:w0e,fromUint8Array:jb,toUint8Array:AH,extendString:$H,extendUint8Array:OH,extendBuiltins:v0e}});function ys(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 eu{columns;columnTypes;rows;rowsAffected;lastInsertRowid;constructor(e,t,r,i,n){this.columns=e,this.columnTypes=t,this.rows=r,this.rowsAffected=i,this.lastInsertRowid=n}toJSON(){return{columns:this.columns,columnTypes:this.columnTypes,rows:this.rows.map(_0e),rowsAffected:this.rowsAffected,lastInsertRowid:this.lastInsertRowid!==void 0?""+this.lastInsertRowid:null}}}function _0e(e){return Array.prototype.map.call(e,k0e)}function k0e(e){if(typeof e==="bigint")return""+e;else if(e instanceof ArrayBuffer)return Xl.fromUint8Array(new Uint8Array(e));else return e}var xi="https://github.com/libsql/libsql-client-ts#supported-urls";var tu=x(()=>{qb()});function PH(e){return e.scheme==="file"&&(e.path===":memory:"||e.path.startsWith(":memory:?"))}function cp(e,t){if(typeof e!=="object")throw TypeError(`Expected client configuration as object, got ${typeof e}`);let{url:r,authToken:i,tls:n,intMode:o,concurrency:s}=e;s=Math.max(0,s||20),o??="number";let a=[];if(r===RH)r="file::memory:";let c=mH(r),l=c.scheme.toLowerCase(),u=l==="file"&&c.path===RH&&c.authority===void 0,d;if(u)d={cache:{values:["shared","private"],update:(g,b)=>a.push(`${g}=${b}`)}};else d={tls:{values:["0","1"],update:(g,b)=>n=b==="1"},authToken:{update:(g,b)=>i=b}};for(let{key:g,value:b}of c.query?.pairs??[]){if(!Object.hasOwn(d,g))throw new je(`Unsupported URL query parameter ${JSON.stringify(g)}`,"URL_PARAM_NOT_SUPPORTED");let v=d[g];if(v.values!==void 0&&!v.values.includes(b))throw new je(`Unknown value for the "${g}" query argument: ${JSON.stringify(b)}. Supported values are: [${v.values.map((A)=>'"'+A+'"').join(", ")}]`,"URL_INVALID");if(v.update!==void 0)v?.update(g,b)}let p=a.length===0?"":`?${a.join("&")}`,m=c.path+p,y;if(l==="libsql")if(n===!1){if(c.authority?.port===void 0)throw new je('A "libsql:" URL with ?tls=0 must specify an explicit port',"URL_INVALID");y=t?"http":"ws"}else y=t?"https":"wss";else y=l;if(y==="http"||y==="ws")n??=!1;else n??=!0;if(y!=="http"&&y!=="ws"&&y!=="https"&&y!=="wss"&&y!=="file")throw new je(`The client supports only "libsql:", "wss:", "ws:", "https:", "http:" and "file:" URLs, got ${JSON.stringify(c.scheme+":")}. For more information, please read ${xi}`,"URL_SCHEME_NOT_SUPPORTED");if(o!=="number"&&o!=="bigint"&&o!=="string")throw TypeError(`Invalid value for intMode, expected "number", "bigint" or "string", got ${JSON.stringify(o)}`);if(c.fragment!==void 0)throw new je(`URL fragments are not supported: ${JSON.stringify("#"+c.fragment)}`,"URL_INVALID");if(u)return{scheme:"file",tls:!1,path:m,intMode:o,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:y,tls:n,authority:c.authority,path:m,authToken:i,intMode:o,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 RH=":memory:";var lp=x(()=>{Kn();Lb();tu()});var NH=ee(function(An){var E0e=An&&An.__createBinding||(Object.create?function(e,t,r,i){if(i===void 0)i=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,i,n)}:function(e,t,r,i){if(i===void 0)i=r;e[i]=t[r]}),I0e=An&&An.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),zH=An&&An.__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))E0e(t,e,r)}return I0e(t,e),t};Object.defineProperty(An,"__esModule",{value:!0});An.load=An.currentTarget=void 0;var A0e=zH(Tt("path")),T0e=zH(Tt("fs"));function C0e(){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 $0e()?`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}`)}An.currentTarget=C0e;function $0e(){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 O0e(e){let t=A0e.join(e,"index.node");return T0e.existsSync(t)?Tt(t):null}An.load=O0e});var BH=ee(function(OHe,LH){var DH=()=>process.platform==="linux",m$=null,R0e=()=>{if(!m$)m$=DH()&&process.report?process.report.getReport():{};return m$};LH.exports={isLinux:DH,getReport:R0e}});var UH=ee(function(RHe,qH){var jH=Tt("fs"),P0e=(e)=>jH.readFileSync(e,"utf-8"),z0e=(e)=>new Promise((t,r)=>{jH.readFile(e,"utf-8",(i,n)=>{if(i)r(i);else t(n)})});qH.exports={LDD_PATH:"/usr/bin/ldd",readFileSync:P0e,readFile:z0e}});var iK=ee(function(PHe,nK){var FH=Tt("child_process"),{isLinux:ru,getReport:ZH}=BH(),{LDD_PATH:Ub,readFile:HH,readFileSync:KH}=UH(),Si,wi,bs="",JH=()=>{if(!bs)return new Promise((e)=>{FH.exec("getconf GNU_LIBC_VERSION 2>&1 || true; ldd --version 2>&1 || true",(t,r)=>{bs=t?" ":r,e(bs)})});return bs},VH=()=>{if(!bs)try{bs=FH.execSync("getconf GNU_LIBC_VERSION 2>&1 || true; ldd --version 2>&1 || true",{encoding:"utf8"})}catch(e){bs=" "}return bs},ro="glibc",WH=/GLIBC\s(\d+\.\d+)/,Ba="musl",N0e=ro.toUpperCase(),D0e=Ba.toLowerCase(),L0e=(e)=>e.includes("libc.musl-")||e.includes("ld-musl-"),GH=()=>{let e=ZH();if(e.header&&e.header.glibcVersionRuntime)return ro;if(Array.isArray(e.sharedObjects)){if(e.sharedObjects.some(L0e))return Ba}return null},QH=(e)=>{let[t,r]=e.split(/[\r\n]+/);if(t&&t.includes(ro))return ro;if(r&&r.includes(Ba))return Ba;return null},YH=(e)=>{if(e.includes(D0e))return Ba;if(e.includes(N0e))return ro;return null},B0e=async()=>{if(Si!==void 0)return Si;Si=null;try{let e=await HH(Ub);Si=YH(e)}catch(e){}return Si},j0e=()=>{if(Si!==void 0)return Si;Si=null;try{let e=KH(Ub);Si=YH(e)}catch(e){}return Si},XH=async()=>{let e=null;if(ru()){if(e=await B0e(),!e)e=GH();if(!e){let t=await JH();e=QH(t)}}return e},eK=()=>{let e=null;if(ru()){if(e=j0e(),!e)e=GH();if(!e){let t=VH();e=QH(t)}}return e},q0e=async()=>ru()&&await XH()!==ro,U0e=()=>ru()&&eK()!==ro,M0e=async()=>{if(wi!==void 0)return wi;wi=null;try{let t=(await HH(Ub)).match(WH);if(t)wi=t[1]}catch(e){}return wi},F0e=()=>{if(wi!==void 0)return wi;wi=null;try{let t=KH(Ub).match(WH);if(t)wi=t[1]}catch(e){}return wi},tK=()=>{let e=ZH();if(e.header&&e.header.glibcVersionRuntime)return e.header.glibcVersionRuntime;return null},MH=(e)=>e.trim().split(/\s+/)[1],rK=(e)=>{let[t,r,i]=e.split(/[\r\n]+/);if(t&&t.includes(ro))return MH(t);if(r&&i&&r.includes(Ba))return MH(i);return null},Z0e=async()=>{let e=null;if(ru()){if(e=await M0e(),!e)e=tK();if(!e){let t=await JH();e=rK(t)}}return e},H0e=()=>{let e=null;if(ru()){if(e=F0e(),!e)e=tK();if(!e){let t=VH();e=rK(t)}}return e};nK.exports={GLIBC:ro,MUSL:Ba,family:XH,familySync:eK,isNonGlibcLinux:q0e,isNonGlibcLinuxSync:U0e,version:Z0e,versionSync:H0e}});var sK=ee(function(zHe,oK){var K0e={ALLOW:0,DENY:1};oK.exports=K0e});var cK=ee(function(NHe,aK){var h$={value:"SqliteError",writable:!0,enumerable:!1,configurable:!0};function ja(e,t,r){if(new.target!==ja)return new ja(e,t);if(typeof t!=="string")throw TypeError("Expected second argument to be a string");Error.call(this,e),h$.value=""+e,Object.defineProperty(this,"message",h$),Error.captureStackTrace(this,ja),this.code=t,this.rawCode=r}Object.setPrototypeOf(ja,Error);Object.setPrototypeOf(ja.prototype,Error.prototype);Object.defineProperty(ja.prototype,"name",h$);aK.exports=ja});var gK=ee(function(DHe,Mb){var __dirname="/home/runner/work/brains/brains/node_modules/libsql",{load:J0e,currentTarget:V0e}=NH(),{familySync:lK,GLIBC:W0e,MUSL:G0e}=iK();function Q0e(){if(process.env.LIBSQL_JS_DEV)return J0e(__dirname);let e=V0e();if(lK()==W0e)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"&&lK()==G0e)e="linux-arm-musleabihf";return Tt(`@libsql/${e}`)}var{databaseOpen:Y0e,databaseOpenWithSync:X0e,databaseInTransaction:eve,databaseInterrupt:tve,databaseClose:rve,databaseSyncSync:nve,databaseSyncUntilSync:ive,databaseExecSync:ove,databasePrepareSync:sve,databaseDefaultSafeIntegers:ave,databaseAuthorizer:cve,databaseLoadExtension:lve,databaseMaxWriteReplicationIndex:uve,statementRaw:dve,statementIsReader:fve,statementGet:uK,statementRun:dK,statementInterrupt:pve,statementRowsSync:fK,statementColumns:mve,statementSafeIntegers:hve,rowsNext:gve}=Q0e(),yve=sK(),pK=cK();function nu(e){if(e.libsqlError)return new pK(e.message,e.code,e.rawCode);return e}class mK{constructor(e,t){let r=t?.encryptionCipher??"aes256cbc";if(t&&t.syncUrl){var i="";if(t.syncAuth)console.warn("Warning: The `syncAuth` option is deprecated, please use `authToken` option instead."),i=t.syncAuth;else if(t.authToken)i=t.authToken;let o=t?.encryptionKey??"",s=t?.syncPeriod??0,a=t?.readYourWrites??!0,c=t?.offline??!1,l=t?.remoteEncryptionKey??"";this.db=X0e(e,t.syncUrl,i,r,o,s,a,c,l)}else{let o=t?.authToken??"",s=t?.encryptionKey??"",a=t?.timeout??0,c=t?.remoteEncryptionKey??"";this.db=Y0e(e,o,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 eve(n)}}})}sync(){return nve.call(this.db)}syncUntil(e){return ive.call(this.db,e)}prepare(e){try{let t=sve.call(this.db,e);return new hK(t)}catch(t){throw nu(t)}}transaction(e){if(typeof e!=="function")throw TypeError("Expected first argument to be a function");let t=this,r=(n)=>(...o)=>{t.exec("BEGIN "+n);try{let s=e(...o);return t.exec("COMMIT"),s}catch(s){throw t.exec("ROLLBACK"),s}},i={default:{value:r("")},deferred:{value:r("DEFERRED")},immediate:{value:r("IMMEDIATE")},exclusive:{value:r("EXCLUSIVE")},database:{value:this,enumerable:!0}};return Object.defineProperties(i.default.value,i),Object.defineProperties(i.deferred.value,i),Object.defineProperties(i.immediate.value,i),Object.defineProperties(i.exclusive.value,i),i.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,i=this.prepare(`PRAGMA ${e}`,this,!0);return r?i.pluck().get():i.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){cve.call(this.db,e)}loadExtension(...e){lve.call(this.db,...e)}maxWriteReplicationIndex(){return uve.call(this.db)}exec(e){try{ove.call(this.db,e)}catch(t){throw nu(t)}}interrupt(){tve.call(this.db)}close(){rve.call(this.db),this.open=!1}defaultSafeIntegers(e){return ave.call(this.db,e??!0),this}unsafeMode(...e){throw Error("not implemented")}}class hK{constructor(e){this.stmt=e,this.pluckMode=!1}raw(e){return dve.call(this.stmt,e??!0),this}pluck(e){return this.pluckMode=e??!0,this}get reader(){return fve.call(this.stmt)}run(...e){try{if(e.length==1&&typeof e[0]==="object")return dK.call(this.stmt,e[0]);else return dK.call(this.stmt,e.flat())}catch(t){throw nu(t)}}get(...e){try{if(e.length==1&&typeof e[0]==="object")return uK.call(this.stmt,e[0]);else return uK.call(this.stmt,e.flat())}catch(t){throw nu(t)}}iterate(...e){var t=void 0;if(e.length==1&&typeof e[0]==="object")t=fK.call(this.stmt,e[0]);else t=fK.call(this.stmt,e.flat());return{nextRows:Array(100),nextRowIndex:100,next(){try{if(this.nextRowIndex===100)gve.call(t,this.nextRows),this.nextRowIndex=0;let i=this.nextRows[this.nextRowIndex];if(this.nextRows[this.nextRowIndex]=void 0,!i)return{done:!0};return this.nextRowIndex++,{value:i,done:!1}}catch(i){throw nu(i)}},[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 nu(t)}}interrupt(){pve.call(this.stmt)}columns(){return mve.call(this.stmt)}safeIntegers(e){return hve.call(this.stmt,e??!0),this}}Mb.exports=mK;Mb.exports.Authorization=yve;Mb.exports.SqliteError=pK});import{Buffer as bK}from"buffer";function xK(e){if(e.scheme!=="file")throw new je(`URL scheme ${JSON.stringify(e.scheme+":")} is not supported by the local sqlite3 client. For more information, please read ${xi}`,"URL_SCHEME_NOT_SUPPORTED");let t=e.authority;if(t!==void 0){let s=t.host.toLowerCase();if(s!==""&&s!=="localhost")throw new je(`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 ${xi}`,"URL_INVALID");if(t.port!==void 0)throw new je("File URL cannot have a port","URL_INVALID");if(t.userinfo!==void 0)throw new je("File URL cannot have username and password","URL_INVALID")}let r=PH(e);if(r&&e.syncUrl)throw new je(`Embedded replica must use file for local db but URI with in-memory mode were provided instead: ${e.path}`,"URL_INVALID");let i=e.path;if(r)i=`${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},o=new up.default(i,n);return Jt(o,"SELECT 1 AS checkThatTheDatabaseCanBeOpened",e.intMode),new SK(i,n,o,e.intMode)}class SK{#e;#t;#r;#n;closed;protocol;constructor(e,t,r,i){this.#e=e,this.#t=t,this.#r=r,this.#n=i,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.#i(),Jt(this.#o(),r,this.#n)}async batch(e,t="deferred"){this.#i();let r=this.#o();try{Jt(r,ys(t),this.#n);let i=[];for(let n=0;n<e.length;n++)try{if(!r.inTransaction)throw new dr("The transaction has been rolled back",n,"TRANSACTION_CLOSED");let o=e[n],s=Array.isArray(o)?{sql:o[0],args:o[1]||[]}:o;i.push(Jt(r,s,this.#n))}catch(o){if(o instanceof dr)throw o;if(o instanceof je)throw new dr(o.message,n,o.code,o.extendedCode,o.rawCode,o.cause instanceof Error?o.cause:void 0);throw o}return Jt(r,"COMMIT",this.#n),i}finally{if(r.inTransaction)Jt(r,"ROLLBACK",this.#n)}}async migrate(e){this.#i();let t=this.#o();try{Jt(t,"PRAGMA foreign_keys=off",this.#n),Jt(t,ys("deferred"),this.#n);let r=[];for(let i=0;i<e.length;i++)try{if(!t.inTransaction)throw new dr("The transaction has been rolled back",i,"TRANSACTION_CLOSED");r.push(Jt(t,e[i],this.#n))}catch(n){if(n instanceof dr)throw n;if(n instanceof je)throw new dr(n.message,i,n.code,n.extendedCode,n.rawCode,n.cause instanceof Error?n.cause:void 0);throw n}return Jt(t,"COMMIT",this.#n),r}finally{if(t.inTransaction)Jt(t,"ROLLBACK",this.#n);Jt(t,"PRAGMA foreign_keys=on",this.#n)}}async transaction(e="write"){let t=this.#o();return Jt(t,ys(e),this.#n),this.#r=null,new wK(t,this.#n)}async executeMultiple(e){this.#i();let t=this.#o();try{return vK(t,e)}finally{if(t.inTransaction)Jt(t,"ROLLBACK",this.#n)}}async sync(){this.#i();let e=await this.#o().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 up.default(this.#e,this.#t),this.closed=!1}}close(){if(this.closed=!0,this.#r!==null)this.#r.close(),this.#r=null}#i(){if(this.closed)throw new je("The client is closed","CLIENT_CLOSED")}#o(){if(this.#r===null)this.#r=new up.default(this.#e,this.#t);return this.#r}}class wK{#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(),Jt(this.#e,r,this.#t)}async batch(e){let t=[];for(let r=0;r<e.length;r++)try{this.#r();let i=e[r],n=Array.isArray(i)?{sql:i[0],args:i[1]||[]}:i;t.push(Jt(this.#e,n,this.#t))}catch(i){if(i instanceof dr)throw i;if(i instanceof je)throw new dr(i.message,r,i.code,i.extendedCode,i.rawCode,i.cause instanceof Error?i.cause:void 0);throw i}return t}async executeMultiple(e){return this.#r(),vK(this.#e,e)}async rollback(){if(!this.#e.open)return;this.#r(),Jt(this.#e,"ROLLBACK",this.#t)}async commit(){this.#r(),Jt(this.#e,"COMMIT",this.#t)}close(){if(this.#e.inTransaction)Jt(this.#e,"ROLLBACK",this.#t)}get closed(){return!this.#e.inTransaction}#r(){if(this.closed)throw new je("The transaction is closed","TRANSACTION_CLOSED")}}function Jt(e,t,r){let i,n;if(typeof t==="string")i=t,n=[];else if(i=t.sql,Array.isArray(t.args))n=t.args.map((o)=>yK(o,r));else{n={};for(let o in t.args){let s=o[0]==="@"||o[0]==="$"||o[0]===":"?o.substring(1):o;n[s]=yK(t.args[o],r)}}try{let o=e.prepare(i);o.safeIntegers(!0);let s=!0;try{o.raw(!0)}catch{s=!1}if(s){let a=Array.from(o.columns().map((p)=>p.name)),c=Array.from(o.columns().map((p)=>p.type??"")),l=o.all(n).map((p)=>bve(p,a,r)),u=0,d=void 0;return new eu(a,c,l,0,void 0)}else{let a=o.run(n),c=a.changes,l=BigInt(a.lastInsertRowid);return new eu([],[],[],c,l)}}catch(o){throw _K(o)}}function bve(e,t,r){let i={};Object.defineProperty(i,"length",{value:e.length});for(let n=0;n<e.length;++n){let o=xve(e[n],r);Object.defineProperty(i,n,{value:o});let s=t[n];if(!Object.hasOwn(i,s))Object.defineProperty(i,s,{value:o,enumerable:!0,configurable:!0,writable:!0})}return i}function xve(e,t){if(typeof e==="bigint")if(t==="number"){if(e<Sve||e>wve)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 bK)return e.buffer;return e}function yK(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<vve||e>_ve)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 bK.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 vK(e,t){try{e.exec(t)}catch(r){throw _K(r)}}function _K(e){if(e instanceof up.default.SqliteError){let t=e.code,r=kve(e.rawCode);return new je(e.message,r,t,e.rawCode,e)}return e}function kve(e){if(e===void 0)return"SQLITE_UNKNOWN";let t=e&255;return Eve[t]??`SQLITE_UNKNOWN_${t.toString()}`}var up,Sve,wve=9007199254740991n,vve,_ve=9223372036854775807n,Eve;var kK=x(()=>{Kn();lp();tu();up=rc(gK(),1);Kn();Sve=-9007199254740991n;vve=-9223372036854775808n;Eve={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 xs;var g$=x(()=>{if(typeof WebSocket<"u")xs=WebSocket;else if(typeof global<"u")xs=global.WebSocket;else if(typeof window<"u")xs=window.WebSocket;else if(typeof self<"u")xs=self.WebSocket});class iu{constructor(){this.intMode="number"}intMode}var st,qe,dp,Pt,fp,ou,qa,Jn,kr,vi;var zt=x(()=>{st=class st extends Error{constructor(e){super(e);this.name="ClientError"}};qe=class qe extends st{constructor(e){super(e);this.name="ProtoError"}};dp=class dp extends st{code;proto;constructor(e,t){super(e);this.name="ResponseError",this.code=t.code,this.proto=t,this.stack=void 0}};Pt=class Pt extends st{constructor(e,t){if(t!==void 0){super(`${e}: ${t}`);this.cause=t}else super(e);this.name="ClosedError"}};fp=class fp extends st{constructor(e){super(e);this.name="WebSocketUnsupportedError"}};ou=class ou extends st{constructor(e){super(e);this.name="WebSocketError"}};qa=class qa extends st{status;constructor(e,t){super(e);this.status=t,this.name="HttpServerError"}};Jn=class Jn extends st{constructor(e){super(e);this.name="ProtocolVersionError"}};kr=class kr extends st{constructor(e){super(e);this.name="InternalError"}};vi=class vi extends st{constructor(e){super(e);this.name="MisuseError"}}});function Gr(e){if(typeof e==="string")return e;throw su(e,"string")}function pn(e){if(e===null||e===void 0)return;else if(typeof e==="string")return e;throw su(e,"string or null")}function no(e){if(typeof e==="number")return e;throw su(e,"number")}function Ss(e){if(typeof e==="boolean")return e;throw su(e,"boolean")}function pp(e){if(Array.isArray(e))return e;throw su(e,"array")}function Ut(e){if(e!==null&&typeof e==="object"&&!Array.isArray(e))return e;throw su(e,"object")}function Vn(e,t){return pp(e).map((r)=>t(Ut(r)))}function su(e,t){if(e===void 0)return new qe(`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 qe(`Expected ${t}, received ${r}`)}function Ua(e,t){return t(Ut(e))}var au=x(()=>{zt()});class EK{#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 i=0;i<t.length;++i){if(i!==0)this.#e.push(",");this.begin(),r(this,t[i]),this.end()}this.#e.push("]")}}function mp(e,t){let r=[],i=new EK(r);return i.begin(),t(i,e),i.end(),r.join("")}var Ma=0,hp=1,gp=2,IK=5;class AK{#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 TK{#e;#t;constructor(e){this.#e=e,this.#t=-1}setup(e){this.#t=e}#r(e){if(this.#t!==e)throw new qe(`Expected wire type ${e}, got ${this.#t}`);this.#t=-1}bytes(){this.#r(gp);let e=this.#e.varint();return this.#e.bytes(e)}string(){return new TextDecoder().decode(this.bytes())}message(e){return ws(this.bytes(),e)}int32(){return this.#r(Ma),this.#e.varint()}uint32(){return this.int32()}bool(){return this.int32()!==0}uint64(){return this.#r(Ma),this.#e.varintBig()}sint64(){let e=this.uint64();return e>>1n^-(e&1n)}double(){return this.#r(hp),this.#e.double()}maybeSkip(){if(this.#t<0)return;else if(this.#t===Ma)this.#e.skipVarint();else if(this.#t===hp)this.#e.skip(8);else if(this.#t===gp){let e=this.#e.varint();this.#e.skip(e)}else if(this.#t===IK)this.#e.skip(4);else throw new qe(`Unexpected wire type ${this.#t}`);this.#t=-1}}function ws(e,t){let r=new AK(e),i=new TK(r),n=t.default();while(!r.eof()){let o=r.varint(),s=o>>3,a=o&7;i.setup(a);let c=t[s];if(c!==void 0){let l=c(i,n);if(l!==void 0)n=l}i.maybeSkip()}return n}var y$=x(()=>{zt()});class b${#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}#i(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),i=new Uint8Array(r),n=new DataView(r);i.set(new Uint8Array(this.#e,0,this.#n)),this.#e=r,this.#t=i,this.#r=n}#o(e){this.#i(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.#i(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.#o(e<<3|t)}bytes(e,t){this.#s(e,gp),this.#o(t.byteLength),this.#i(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 i=new b$;r(i,t),this.bytes(e,i.data())}int32(e,t){this.#s(e,Ma),this.#o(t)}uint32(e,t){this.int32(e,t)}bool(e,t){this.int32(e,t?1:0)}sint64(e,t){this.#s(e,Ma),this.#a(t<<1n^t>>63n)}double(e,t){this.#s(e,hp),this.#i(8),this.#r.setFloat64(this.#n,t,!0),this.#n+=8}data(){return new Uint8Array(this.#e,0,this.#n)}}function yp(e,t){let r=new b$;return t(r,e),r.data()}var CK=()=>{};var x$=x(()=>{au();y$();CK()});class vs{#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 kr("Freeing an id that is not allocated");if(this.#t.delete(this.#e.size),e<this.#e.size)this.#t.add(e)}}var S$=x(()=>{zt()});function rt(e,t){throw new kr(t)}var Tn=x(()=>{zt()});function cu(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<Ave||e>Tve)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 w$(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 vi("Invalid value for IntMode");else if(e instanceof Uint8Array)return e.slice().buffer;else if(e===void 0)throw new qe("Received unrecognized type of Value");else throw rt(e,"Impossible type of Value")}var Ave,Tve=9223372036854775807n;var v$=x(()=>{zt();Tn();Ave=-9223372036854775808n});function Fa(e){return{affectedRowCount:e.affectedRowCount,lastInsertRowid:e.lastInsertRowid,columnNames:e.cols.map((t)=>t.name),columnDecltypes:e.cols.map((t)=>t.decltype)}}function Zb(e,t){let r=Fa(e),i=e.rows.map((n)=>$K(r.columnNames,n,t));return{...r,rows:i}}function Hb(e,t){let r=Fa(e),i;if(e.rows.length>0)i=$K(r.columnNames,e.rows[0],t);return{...r,row:i}}function Kb(e,t){let r=Fa(e),i;if(e.rows.length>0&&r.columnNames.length>0)i=w$(e.rows[0][0],t);return{...r,value:i}}function $K(e,t,r){let i={};Object.defineProperty(i,"length",{value:t.length});for(let n=0;n<t.length;++n){let o=w$(t[n],r);Object.defineProperty(i,n,{value:o});let s=e[n];if(s!==void 0&&!Object.hasOwn(i,s))Object.defineProperty(i,s,{value:o,enumerable:!0,configurable:!0,writable:!0})}return i}function io(e){return new dp(e.message,e)}var bp=x(()=>{zt();v$()});class Za{#e;#t;#r;constructor(e,t){this.#e=e,this.#t=t,this.#r=void 0}_getSqlId(e){if(this.#e!==e)throw new vi("Attempted to use SQL text opened with other object");else if(this.#r!==void 0)throw new Pt("SQL text is closed",this.#r);return this.#t}close(){this._setClosed(new st("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 xp(e,t){if(t instanceof Za)return{sqlId:t._getSqlId(e)};else return{sql:""+t}}var lu=x(()=>{zt()});class _s{#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 Sp{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(cu(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]=cu(t),this}bindName(e,t){return this._namedArgs.set(e,cu(t)),this}unbindAll(){return this._args.length=0,this._namedArgs.clear(),this}}function Jb(e,t,r){let i,n=[],o=[];if(t instanceof Sp){i=t.sql,n=t._args;for(let[c,l]of t._namedArgs.entries())o.push({name:c,value:l})}else if(Array.isArray(t))if(i=t[0],Array.isArray(t[1]))n=t[1].map((c)=>cu(c));else o=Object.entries(t[1]).map(([c,l])=>({name:c,value:cu(l)}));else i=t;let{sql:s,sqlId:a}=xp(e,i);return{sql:s,sqlId:a,args:n,namedArgs:o,wantRows:r}}var Vb=x(()=>{lu();v$()});class Wb{_stream;#e;_steps;#t;constructor(e,t){this._stream=e,this.#e=t,this._steps=[],this.#t=!1}step(){return new _$(this)}execute(){if(this.#t)throw new vi("This batch has already been executed");this.#t=!0;let e={steps:this._steps.map((t)=>t.proto)};if(this.#e)return $ve(this._stream,this._steps,e);else return Cve(this._stream,this._steps,e)}}function Cve(e,t,r){return e._batch(r).then((i)=>{for(let n=0;n<t.length;++n){let o=i.stepResults.get(n),s=i.stepErrors.get(n);t[n].callback(o,s)}})}async function $ve(e,t,r){let i=await e._openCursor(r);try{let n=0,o=void 0,s=[];for(;;){let a=await i.next();if(a===void 0)break;if(a.type==="step_begin"){if(a.step<n||a.step>=t.length)throw new qe("Server produced StepBeginEntry for unexpected step");else if(o!==void 0)throw new qe("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,o=a,s=[]}else if(a.type==="step_end"){if(o===void 0)throw new qe("Server produced StepEndEntry but no step is active");let c={cols:o.cols,rows:s,affectedRowCount:a.affectedRowCount,lastInsertRowid:a.lastInsertRowid};t[o.step].callback(c,void 0),o=void 0,s=[]}else if(a.type==="step_error"){if(o===void 0){if(a.step>=t.length)throw new qe("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!==o.step)throw new qe("Server produced StepErrorEntry for unexpected step");o=void 0,s=[]}t[a.step].callback(void 0,a.error),n=a.step+1}else if(a.type==="row"){if(o===void 0)throw new qe("Server produced RowEntry but no step is active");s.push(a.row)}else if(a.type==="error")throw io(a.error);else if(a.type==="none")throw new qe("Server produced unrecognized CursorEntry");else throw rt(a,"Impossible CursorEntry")}if(o!==void 0)throw new qe("Server closed Cursor before terminating active step");for(let a=n;a<t.length;++a)t[a].callback(void 0,void 0)}finally{i.close()}}class _${_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,Zb)}queryRow(e){return this.#t(e,!0,Hb)}queryValue(e){return this.#t(e,!0,Kb)}run(e){return this.#t(e,!1,Fa)}#t(e,t,r){if(this._index!==void 0)throw new vi("This BatchStep has already been added to the batch");let i=Jb(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 o={stmt:i,condition:n};return new Promise((s,a)=>{let c=(l,u)=>{if(l!==void 0&&u!==void 0)a(new qe("Server returned both result and error"));else if(u!==void 0)a(io(u));else if(l!==void 0)s(r(l,this._batch._stream.intMode));else s(void 0)};this._index=this._batch._steps.length,this._batch._steps.push({proto:o,callback:c})})}}class wt{_batch;_proto;constructor(e,t){this._batch=e,this._proto=t}static ok(e){return new wt(e._batch,{type:"ok",step:OK(e)})}static error(e){return new wt(e._batch,{type:"error",step:OK(e)})}static not(e){return new wt(e._batch,{type:"not",cond:e._proto})}static and(e,t){for(let r of t)RK(e,r);return new wt(e,{type:"and",conds:t.map((r)=>r._proto)})}static or(e,t){for(let r of t)RK(e,r);return new wt(e,{type:"or",conds:t.map((r)=>r._proto)})}static isAutocommit(e){return e._stream.client()._ensureVersion(3,"BatchCond.isAutocommit()"),new wt(e,{type:"is_autocommit"})}}function OK(e){if(e._index===void 0)throw new vi("Cannot add a condition referencing a step that has not been added to the batch");return e._index}function RK(e,t){if(t._batch!==e)throw new vi("Cannot mix BatchCond objects for different Batch objects")}var k$=x(()=>{zt();bp();Vb();Tn()});function PK(e){return{paramNames:e.params.map((t)=>t.name),columns:e.cols,isExplain:e.isExplain,isReadonly:e.isReadonly}}class uu{constructor(e){this.intMode=e}query(e){return this.#e(e,!0,Zb)}queryRow(e){return this.#e(e,!0,Hb)}queryValue(e){return this.#e(e,!0,Kb)}run(e){return this.#e(e,!1,Fa)}#e(e,t,r){let i=Jb(this._sqlOwner(),e,t);return this._execute(i).then((n)=>r(n,this.intMode))}batch(e=!1){return new Wb(this,e)}describe(e){let t=xp(this._sqlOwner(),e);return this._describe(t).then(PK)}sequence(e){let t=xp(this._sqlOwner(),e);return this._sequence(t)}intMode}var Gb=x(()=>{k$();bp();lu();Vb()});class wp{}var Ove=1000,Rve=10,E$;var zK=x(()=>{zt();E$=class E$ extends wp{#e;#t;#r;#n;#i;#o;#a;constructor(e,t,r){super();this.#e=e,this.#t=t,this.#r=r,this.#n=new _s,this.#i=new _s,this.#o=void 0,this.#a=!1}async next(){for(;;){if(this.#o!==void 0)throw new Pt("Cursor is closed",this.#o);while(!this.#a&&this.#i.length<Rve)this.#i.push(this.#s());let e=this.#n.shift();if(this.#a||e!==void 0)return e;await this.#i.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:Ove}).then((e)=>e,(e)=>{this._setClosed(e);return})}_setClosed(e){if(this.#o!==void 0)return;this.#o=e,this.#t._sendCursorRequest(this,{type:"close_cursor",cursorId:this.#r}).catch(()=>{return}),this.#t._cursorClosed(this)}close(){this._setClosed(new st("Cursor was manually closed"))}get closed(){return this.#o!==void 0}}});var vp;var I$=x(()=>{zt();Gb();zK();vp=class vp extends uu{#e;#t;#r;#n;#i;#o;static open(e){let t=e._streamIdAlloc.alloc(),r=new vp(e,t),i=()=>{return},n=(s)=>r.#l(s),o={type:"open_stream",streamId:t};return e._sendRequest(o,{responseCallback:i,errorCallback:n}),r}constructor(e,t){super(e.intMode);this.#e=e,this.#t=t,this.#r=new _s,this.#n=void 0,this.#i=!1,this.#o=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 kr("Cursor not associated with the stream attempted to execute a request");return new Promise((r,i)=>{if(this.#o!==void 0)i(new Pt("Stream is closed",this.#o));else this.#e._sendRequest(t,{responseCallback:r,errorCallback:i})})}_cursorClosed(e){if(e!==this.#n)throw new kr("Cursor was closed, but it was not associated with the stream");this.#n=void 0,this.#c()}#s(e){if(this.#o!==void 0)e.errorCallback(new Pt("Stream is closed",this.#o));else if(this.#i)e.errorCallback(new Pt("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.#i){this.#l(new st("Stream was gracefully closed"));break}else if(e?.type==="request"&&this.#n===void 0){let{request:t,responseCallback:r,errorCallback:i}=e;this.#r.shift(),this.#e._sendRequest(t,{responseCallback:r,errorCallback:i})}else if(e?.type==="cursor"&&this.#n===void 0){let{batch:t,cursorCallback:r}=e;this.#r.shift();let i=this.#e._cursorIdAlloc.alloc(),n=new E$(this.#e,this,i),o={type:"open_cursor",streamId:this.#t,cursorId:i,batch:t},s=()=>{return},a=(c)=>n._setClosed(c);this.#e._sendRequest(o,{responseCallback:s,errorCallback:a}),this.#n=n,r(n)}else break}}#l(e){if(this.#o!==void 0)return;if(this.#o=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),i=()=>{return};this.#e._sendRequest(t,{responseCallback:r,errorCallback:i})}close(){this.#l(new st("Stream was manually closed"))}closeGracefully(){this.#i=!0,this.#c()}get closed(){return this.#o!==void 0||this.#i}}});function _p(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,NK),e.arrayObjects("named_args",t.namedArgs,Pve),e.boolean("want_rows",t.wantRows)}function Pve(e,t){e.string("name",t.name),e.object("value",t.value,NK)}function du(e,t){e.arrayObjects("steps",t.steps,zve)}function zve(e,t){if(t.condition!==void 0)e.object("condition",t.condition,A$);e.object("stmt",t.stmt,_p)}function A$(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,A$);else if(t.type==="and"||t.type==="or")e.arrayObjects("conds",t.conds,A$);else if(t.type==="is_autocommit");else throw rt(t,"Impossible type of BatchCond")}function NK(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",Xl.fromUint8Array(t));else if(t===void 0);else throw rt(t,"Impossible type of Value")}var T$=x(()=>{qb();Tn()});function DK(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,Nve);else throw rt(t,"Impossible type of ClientMsg")}function Nve(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,_p);else if(t.type==="batch")e.number("stream_id",t.streamId),e.object("batch",t.batch,du);else if(t.type==="open_cursor")e.number("stream_id",t.streamId),e.number("cursor_id",t.cursorId),e.object("batch",t.batch,du);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 rt(t,"Impossible type of Request")}var LK=x(()=>{T$();Tn()});function kp(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,jK);for(let r of t.namedArgs)e.message(4,r,Dve);e.bool(5,t.wantRows)}function Dve(e,t){e.string(1,t.name),e.message(2,t.value,jK)}function fu(e,t){for(let r of t.steps)e.message(1,r,Lve)}function Lve(e,t){if(t.condition!==void 0)e.message(1,t.condition,C$);e.message(2,t.stmt,kp)}function C$(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,C$);else if(t.type==="and")e.message(4,t.conds,BK);else if(t.type==="or")e.message(5,t.conds,BK);else if(t.type==="is_autocommit")e.message(6,void 0,qK);else throw rt(t,"Impossible type of BatchCond")}function BK(e,t){for(let r of t)e.message(1,r,C$)}function jK(e,t){if(t===null)e.message(1,void 0,qK);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 rt(t,"Impossible type of Value")}function qK(e,t){}var $$=x(()=>{Tn()});function UK(e,t){if(t.type==="hello")e.message(1,t,Bve);else if(t.type==="request")e.message(2,t,jve);else throw rt(t,"Impossible type of ClientMsg")}function Bve(e,t){if(t.jwt!==void 0)e.string(1,t.jwt)}function jve(e,t){e.int32(1,t.requestId);let r=t.request;if(r.type==="open_stream")e.message(2,r,qve);else if(r.type==="close_stream")e.message(3,r,Uve);else if(r.type==="execute")e.message(4,r,Mve);else if(r.type==="batch")e.message(5,r,Fve);else if(r.type==="open_cursor")e.message(6,r,Zve);else if(r.type==="close_cursor")e.message(7,r,Hve);else if(r.type==="fetch_cursor")e.message(8,r,Kve);else if(r.type==="sequence")e.message(9,r,Jve);else if(r.type==="describe")e.message(10,r,Vve);else if(r.type==="store_sql")e.message(11,r,Wve);else if(r.type==="close_sql")e.message(12,r,Gve);else if(r.type==="get_autocommit")e.message(13,r,Qve);else throw rt(r,"Impossible type of Request")}function qve(e,t){e.int32(1,t.streamId)}function Uve(e,t){e.int32(1,t.streamId)}function Mve(e,t){e.int32(1,t.streamId),e.message(2,t.stmt,kp)}function Fve(e,t){e.int32(1,t.streamId),e.message(2,t.batch,fu)}function Zve(e,t){e.int32(1,t.streamId),e.int32(2,t.cursorId),e.message(3,t.batch,fu)}function Hve(e,t){e.int32(1,t.cursorId)}function Kve(e,t){e.int32(1,t.cursorId),e.uint32(2,t.maxCount)}function Jve(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 Vve(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 Wve(e,t){e.int32(1,t.sqlId),e.string(2,t.sql)}function Gve(e,t){e.int32(1,t.sqlId)}function Qve(e,t){e.int32(1,t.streamId)}var MK=x(()=>{$$();Tn()});function ks(e){let t=Gr(e.message),r=pn(e.code);return{message:t,code:r}}function Ep(e){let t=Vn(e.cols,FK),r=pp(e.rows).map((s)=>Vn(s,ZK)),i=no(e.affected_row_count),n=pn(e.last_insert_rowid),o=n!==void 0?BigInt(n):void 0;return{cols:t,rows:r,affectedRowCount:i,lastInsertRowid:o}}function FK(e){let t=pn(e.name),r=pn(e.decltype);return{name:t,decltype:r}}function Qb(e){let t=new Map;pp(e.step_results).forEach((i,n)=>{if(i!==null)t.set(n,Ep(Ut(i)))});let r=new Map;return pp(e.step_errors).forEach((i,n)=>{if(i!==null)r.set(n,ks(Ut(i)))}),{stepResults:t,stepErrors:r}}function Yb(e){let t=Gr(e.type);if(t==="step_begin"){let r=no(e.step),i=Vn(e.cols,FK);return{type:"step_begin",step:r,cols:i}}else if(t==="step_end"){let r=no(e.affected_row_count),i=pn(e.last_insert_rowid),n=i!==void 0?BigInt(i):void 0;return{type:"step_end",affectedRowCount:r,lastInsertRowid:n}}else if(t==="step_error"){let r=no(e.step),i=ks(Ut(e.error));return{type:"step_error",step:r,error:i}}else if(t==="row")return{type:"row",row:Vn(e.row,ZK)};else if(t==="error")return{type:"error",error:ks(Ut(e.error))};else throw new qe("Unexpected type of CursorEntry")}function Xb(e){let t=Vn(e.params,Yve),r=Vn(e.cols,Xve),i=Ss(e.is_explain),n=Ss(e.is_readonly);return{params:t,cols:r,isExplain:i,isReadonly:n}}function Yve(e){return{name:pn(e.name)}}function Xve(e){let t=Gr(e.name),r=pn(e.decltype);return{name:t,decltype:r}}function ZK(e){let t=Gr(e.type);if(t==="null")return null;else if(t==="integer"){let r=Gr(e.value);return BigInt(r)}else if(t==="float")return no(e.value);else if(t==="text")return Gr(e.value);else if(t==="blob")return Xl.toUint8Array(Gr(e.base64));else throw new qe("Unexpected type of Value")}var ex=x(()=>{qb();zt();au()});function HK(e){let t=Gr(e.type);if(t==="hello_ok")return{type:"hello_ok"};else if(t==="hello_error")return{type:"hello_error",error:ks(Ut(e.error))};else if(t==="response_ok"){let r=no(e.request_id),i=e_e(Ut(e.response));return{type:"response_ok",requestId:r,response:i}}else if(t==="response_error"){let r=no(e.request_id),i=ks(Ut(e.error));return{type:"response_error",requestId:r,error:i}}else throw new qe("Unexpected type of ServerMsg")}function e_e(e){let t=Gr(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:Ep(Ut(e.result))};else if(t==="batch")return{type:"batch",result:Qb(Ut(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=Vn(e.entries,Yb),i=Ss(e.done);return{type:"fetch_cursor",entries:r,done:i}}else if(t==="sequence")return{type:"sequence"};else if(t==="describe")return{type:"describe",result:Xb(Ut(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:Ss(e.is_autocommit)};else throw new qe("Unexpected type of Response")}var KK=x(()=>{zt();au();ex()});var Cn,Es,JK,VK,pu,t_e,r_e,tx,n_e,i_e,o_e,mu,s_e,a_e,c_e;var rx=x(()=>{Cn={default(){return{message:"",code:void 0}},1(e,t){t.message=e.string()},2(e,t){t.code=e.string()}},Es={default(){return{cols:[],rows:[],affectedRowCount:0,lastInsertRowid:void 0}},1(e,t){t.cols.push(e.message(JK))},2(e,t){t.rows.push(e.message(VK))},3(e,t){t.affectedRowCount=Number(e.uint64())},4(e,t){t.lastInsertRowid=e.sint64()}},JK={default(){return{name:void 0,decltype:void 0}},1(e,t){t.name=e.string()},2(e,t){t.decltype=e.string()}},VK={default(){return[]},1(e,t){t.push(e.message(c_e))}},pu={default(){return{stepResults:new Map,stepErrors:new Map}},1(e,t){let[r,i]=e.message(t_e);t.stepResults.set(r,i)},2(e,t){let[r,i]=e.message(r_e);t.stepErrors.set(r,i)}},t_e={default(){return[0,Es.default()]},1(e,t){t[0]=e.uint32()},2(e,t){t[1]=e.message(Es)}},r_e={default(){return[0,Cn.default()]},1(e,t){t[0]=e.uint32()},2(e,t){t[1]=e.message(Cn)}},tx={default(){return{type:"none"}},1(e){return e.message(n_e)},2(e){return e.message(i_e)},3(e){return e.message(o_e)},4(e){return{type:"row",row:e.message(VK)}},5(e){return{type:"error",error:e.message(Cn)}}},n_e={default(){return{type:"step_begin",step:0,cols:[]}},1(e,t){t.step=e.uint32()},2(e,t){t.cols.push(e.message(JK))}},i_e={default(){return{type:"step_end",affectedRowCount:0,lastInsertRowid:void 0}},1(e,t){t.affectedRowCount=e.uint32()},2(e,t){t.lastInsertRowid=e.uint64()}},o_e={default(){return{type:"step_error",step:0,error:Cn.default()}},1(e,t){t.step=e.uint32()},2(e,t){t.error=e.message(Cn)}},mu={default(){return{params:[],cols:[],isExplain:!1,isReadonly:!1}},1(e,t){t.params.push(e.message(s_e))},2(e,t){t.cols.push(e.message(a_e))},3(e,t){t.isExplain=e.bool()},4(e,t){t.isReadonly=e.bool()}},s_e={default(){return{name:void 0}},1(e,t){t.name=e.string()}},a_e={default(){return{name:"",decltype:void 0}},1(e,t){t.name=e.string()},2(e,t){t.decltype=e.string()}},c_e={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 WK,l_e,u_e,d_e,f_e,p_e,m_e,h_e,g_e;var GK=x(()=>{rx();WK={default(){return{type:"none"}},1(e){return{type:"hello_ok"}},2(e){return e.message(l_e)},3(e){return e.message(d_e)},4(e){return e.message(u_e)}},l_e={default(){return{type:"hello_error",error:Cn.default()}},1(e,t){t.error=e.message(Cn)}},u_e={default(){return{type:"response_error",requestId:0,error:Cn.default()}},1(e,t){t.requestId=e.int32()},2(e,t){t.error=e.message(Cn)}},d_e={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(f_e)},5(e,t){t.response=e.message(p_e)},6(e,t){t.response={type:"open_cursor"}},7(e,t){t.response={type:"close_cursor"}},8(e,t){t.response=e.message(m_e)},9(e,t){t.response={type:"sequence"}},10(e,t){t.response=e.message(h_e)},11(e,t){t.response={type:"store_sql"}},12(e,t){t.response={type:"close_sql"}},13(e,t){t.response=e.message(g_e)}},f_e={default(){return{type:"execute",result:Es.default()}},1(e,t){t.result=e.message(Es)}},p_e={default(){return{type:"batch",result:pu.default()}},1(e,t){t.result=e.message(pu)}},m_e={default(){return{type:"fetch_cursor",entries:[],done:!1}},1(e,t){t.entries.push(e.message(tx))},2(e,t){t.done=e.bool()}},h_e={default(){return{type:"describe",result:mu.default()}},1(e,t){t.result=e.message(mu)}},g_e={default(){return{type:"get_autocommit",isAutocommit:!1}},1(e,t){t.isAutocommit=e.bool()}}});var QK,O$,nx;var ix=x(()=>{x$();zt();S$();bp();lu();Tn();I$();LK();MK();KK();GK();QK=new Map([["hrana2",{version:2,encoding:"json"}],["hrana1",{version:1,encoding:"json"}]]),O$=new Map([["hrana3-protobuf",{version:3,encoding:"protobuf"}],["hrana3",{version:3,encoding:"json"}],["hrana2",{version:2,encoding:"json"}],["hrana1",{version:1,encoding:"json"}]]);nx=class nx extends iu{#e;#t;#r;#n;#i;#o;#a;#s;#c;_streamIdAlloc;_cursorIdAlloc;#l;constructor(e,t){super();this.#e=e,this.#t=[],this.#r=!1,this.#n=void 0,this.#i=!1,this.#o=void 0,this.#a=!1,this.#s=new Map,this.#c=new vs,this._streamIdAlloc=new vs,this._cursorIdAlloc=new vs,this.#l=new vs,this.#e.binaryType="arraybuffer",this.#e.addEventListener("open",()=>this.#f()),this.#e.addEventListener("close",(r)=>this.#g(r)),this.#e.addEventListener("error",(r)=>this.#p(r)),this.#e.addEventListener("message",(r)=>this.#y(r)),this.#d({type:"hello",jwt:t})}#d(e){if(this.#n!==void 0)throw new kr("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})}}#f(){let e=this.#e.protocol;if(e===void 0){this.#u(new st("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.#o={version:1,encoding:"json"};else if(this.#o=O$.get(e),this.#o===void 0){this.#u(new qe(`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.#o.encoding;if(t==="json"){let r=mp(e,DK);this.#e.send(r)}else if(t==="protobuf"){let r=yp(e,UK);this.#e.send(r)}else throw rt(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.#o.version);this.#t.push({openCallback:r,errorCallback:t})}else e(this.#o.version)})}_ensureVersion(e,t){if(this.#o===void 0||!this.#a)throw new Jn(`${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.#o.version<e)throw new Jn(`${t} is supported on protocol version ${e} and higher, but the WebSocket server only supports version ${this.#o.version}`)}_sendRequest(e,t){if(this.#n!==void 0){t.errorCallback(new Pt("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})}#p(e){let r=e.message??"WebSocket was closed due to an error";this.#u(new ou(r))}#g(e){let t=`WebSocket was closed with code ${e.code}`;if(e.reason)t+=`: ${e.reason}`;this.#u(new ou(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.#o.encoding;if(r==="json"){if(typeof e.data!=="string"){this.#e.close(3003,"Only text messages are accepted with JSON encoding"),this.#u(new qe("Received non-text message from server with JSON encoding"));return}t=Ua(JSON.parse(e.data),HK)}else if(r==="protobuf"){if(!(e.data instanceof ArrayBuffer)){this.#e.close(3003,"Only binary messages are accepted with Protobuf encoding"),this.#u(new qe("Received non-binary message from server with Protobuf encoding"));return}t=ws(new Uint8Array(e.data),WK)}else throw rt(r,"Impossible encoding");this.#h(t)}catch(t){this.#e.close(3007,"Could not handle message"),this.#u(t)}}#h(e){if(e.type==="none")throw new qe("Received an unrecognized ServerMsg");else if(e.type==="hello_ok"||e.type==="hello_error"){if(this.#i)throw new qe("Received a duplicated hello response");if(this.#i=!0,e.type==="hello_error")throw io(e.error);return}else if(!this.#i)throw new qe("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 qe("Received unexpected OK response");this.#c.free(t);try{if(r.type!==e.response.type)throw console.dir({responseState:r,msg:e}),new qe("Received unexpected type of response");r.responseCallback(e.response)}catch(i){throw r.errorCallback(i),i}}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 qe("Received unexpected error response");this.#c.free(t),r.errorCallback(io(e.error))}else throw rt(e,"Impossible ServerMsg type")}openStream(){return vp.open(this)}storeSql(e){this._ensureVersion(2,"storeSql()");let t=this.#l.alloc(),r=new Za(this,t),i=()=>{return},n=(s)=>r._setClosed(s),o={type:"store_sql",sqlId:t,sql:e};return this._sendRequest(o,{responseCallback:i,errorCallback:n}),r}_closeSql(e){if(this.#n!==void 0)return;let t=()=>this.#l.free(e),r=(n)=>this.#u(n),i={type:"close_sql",sqlId:e};this._sendRequest(i,{responseCallback:t,errorCallback:r})}close(){this.#u(new st("Client was manually closed"))}get closed(){return this.#n!==void 0}}});var Ha;var YK=x(()=>{if(typeof queueMicrotask<"u")Ha=queueMicrotask;else{let e=Promise.resolve();Ha=(t)=>{e.then(t)}}});class R${#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 i=new Uint8Array(new ArrayBuffer(r));i.set(this.#e.slice(this.#t,this.#r),0),this.#e=i}this.#r=t,this.#t=0}shift(e){this.#t+=e}}function XK(e){let t=pn(e.baton),r=pn(e.base_url),i=Vn(e.results,y_e);return{baton:t,baseUrl:r,results:i}}function y_e(e){let t=Gr(e.type);if(t==="ok")return{type:"ok",response:b_e(Ut(e.response))};else if(t==="error")return{type:"error",error:ks(Ut(e.error))};else throw new qe("Unexpected type of StreamResult")}function b_e(e){let t=Gr(e.type);if(t==="close")return{type:"close"};else if(t==="execute")return{type:"execute",result:Ep(Ut(e.result))};else if(t==="batch")return{type:"batch",result:Qb(Ut(e.result))};else if(t==="sequence")return{type:"sequence"};else if(t==="describe")return{type:"describe",result:Xb(Ut(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:Ss(e.is_autocommit)};else throw new qe("Unexpected type of StreamResponse")}function eJ(e){let t=pn(e.baton),r=pn(e.base_url);return{baton:t,baseUrl:r}}var P$=x(()=>{zt();au();ex()});var tJ,x_e,S_e,w_e,v_e,__e,k_e,rJ;var z$=x(()=>{rx();tJ={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(x_e))}},x_e={default(){return{type:"none"}},1(e){return{type:"ok",response:e.message(S_e)}},2(e){return{type:"error",error:e.message(Cn)}}},S_e={default(){return{type:"none"}},1(e){return{type:"close"}},2(e){return e.message(w_e)},3(e){return e.message(v_e)},4(e){return{type:"sequence"}},5(e){return e.message(__e)},6(e){return{type:"store_sql"}},7(e){return{type:"close_sql"}},8(e){return e.message(k_e)}},w_e={default(){return{type:"execute",result:Es.default()}},1(e,t){t.result=e.message(Es)}},v_e={default(){return{type:"batch",result:pu.default()}},1(e,t){t.result=e.message(pu)}},__e={default(){return{type:"describe",result:mu.default()}},1(e,t){t.result=e.message(mu)}},k_e={default(){return{type:"get_autocommit",isAutocommit:!1}},1(e,t){t.isAutocommit=e.bool()}},rJ={default(){return{baton:void 0,baseUrl:void 0}},1(e,t){t.baton=e.string()},2(e,t){t.baseUrl=e.string()}}});var N$;var nJ=x(()=>{au();y$();zt();Tn();P$();z$();ex();rx();N$=class N$ extends wp{#e;#t;#r;#n;#i;#o;constructor(e,t){super();this.#e=e,this.#t=t,this.#r=void 0,this.#n=new R$(16384),this.#i=void 0,this.#o=!1}async open(e){if(e.body===null)throw new qe("No response body for cursor request");this.#r=e.body[Symbol.asyncIterator]();let t=await this.#a(eJ,rJ);if(t===void 0)throw new qe("Empty response to cursor request");return t}next(){return this.#a(Yb,tx)}close(){this._setClosed(new st("Cursor was manually closed"))}_setClosed(e){if(this.#i!==void 0)return;if(this.#i=e,this.#e._cursorClosed(this),this.#r!==void 0)this.#r.return()}get closed(){return this.#i!==void 0}async#a(e,t){for(;;){if(this.#o)return;else if(this.#i!==void 0)throw new Pt("Cursor is closed",this.#i);if(this.#t==="json"){let n=this.#s();if(n!==void 0){let o=new TextDecoder().decode(n),s=JSON.parse(o);return Ua(s,e)}}else if(this.#t==="protobuf"){let n=this.#c();if(n!==void 0)return ws(n,t)}else throw rt(this.#t,"Impossible encoding");if(this.#r===void 0)throw new kr("Attempted to read from HTTP cursor before it was opened");let{value:r,done:i}=await this.#r.next();if(i&&this.#n.length===0)this.#o=!0;else if(i)throw new qe("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 i=e.slice(0,r);return this.#n.shift(r+1),i}#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 i=e.slice(r,r+t);return this.#n.shift(r+t),i}}});function iJ(e,t){if(t.baton!==void 0)e.string("baton",t.baton);e.arrayObjects("requests",t.requests,E_e)}function E_e(e,t){if(e.stringRaw("type",t.type),t.type==="close");else if(t.type==="execute")e.object("stmt",t.stmt,_p);else if(t.type==="batch")e.object("batch",t.batch,du);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 rt(t,"Impossible type of StreamRequest")}function oJ(e,t){if(t.baton!==void 0)e.string("baton",t.baton);e.object("batch",t.batch,du)}var D$=x(()=>{T$();Tn()});function sJ(e,t){if(t.baton!==void 0)e.string(1,t.baton);for(let r of t.requests)e.message(2,r,I_e)}function I_e(e,t){if(t.type==="close")e.message(1,t,A_e);else if(t.type==="execute")e.message(2,t,T_e);else if(t.type==="batch")e.message(3,t,C_e);else if(t.type==="sequence")e.message(4,t,$_e);else if(t.type==="describe")e.message(5,t,O_e);else if(t.type==="store_sql")e.message(6,t,R_e);else if(t.type==="close_sql")e.message(7,t,P_e);else if(t.type==="get_autocommit")e.message(8,t,z_e);else throw rt(t,"Impossible type of StreamRequest")}function A_e(e,t){}function T_e(e,t){e.message(1,t.stmt,kp)}function C_e(e,t){e.message(1,t.batch,fu)}function $_e(e,t){if(t.sql!==void 0)e.string(1,t.sql);if(t.sqlId!==void 0)e.int32(2,t.sqlId)}function O_e(e,t){if(t.sql!==void 0)e.string(1,t.sql);if(t.sqlId!==void 0)e.int32(2,t.sqlId)}function R_e(e,t){e.int32(1,t.sqlId),e.string(2,t.sql)}function P_e(e,t){e.int32(1,t.sqlId)}function z_e(e,t){}function aJ(e,t){if(t.baton!==void 0)e.string(1,t.baton);e.message(2,t.batch,fu)}var L$=x(()=>{$$();Tn()});function N_e(e,t){if(t.results.length!==e.length)throw new qe("Server returned unexpected number of pipeline results");for(let r=0;r<e.length;++r){let i=t.results[r],n=e[r];if(i.type==="ok"){if(i.response.type!==n.request.type)throw new qe("Received unexpected type of response");n.responseCallback(i.response)}else if(i.type==="error")n.errorCallback(io(i.error));else if(i.type==="none")throw new qe("Received unrecognized type of StreamResult");else throw rt(i,"Received impossible type of StreamResult")}}async function D_e(e,t){if(t==="json"){let r=await e.json();return Ua(r,XK)}if(t==="protobuf"){let r=await e.arrayBuffer();return ws(new Uint8Array(r),tJ)}throw await e.body?.cancel(),rt(t,"Impossible encoding")}async function L_e(e){let t=e.headers.get("content-type")??"text/plain",r=`Server returned HTTP status ${e.status}`;if(t==="application/json"){let i=await e.json();if("message"in i)return io(i);return new qa(r,e.status)}if(t==="text/plain"){let i=(await e.text()).trim();if(i!=="")r+=`: ${i}`;return new qa(r,e.status)}return await e.body?.cancel(),new qa(r,e.status)}var ox;var B$=x(()=>{zt();x$();S$();YK();bp();lu();Gb();Tn();nJ();D$();L$();D$();L$();P$();z$();ox=class ox extends uu{#e;#t;#r;#n;#i;#o;#a;#s;#c;#l;#d;#f;#m;constructor(e,t,r,i,n){super(e.intMode);this.#e=e,this.#t=t.toString(),this.#r=r,this.#n=i,this.#i=n,this.#o=void 0,this.#a=new _s,this.#s=!1,this.#l=!1,this.#d=!1,this.#f=void 0,this.#m=new vs}client(){return this.#e}_sqlOwner(){return this}storeSql(e){let t=this.#m.alloc();return this.#p({type:"store_sql",sqlId:t,sql:e}).then(()=>{return},(r)=>this._setClosed(r)),new Za(this,t)}_closeSql(e){if(this.#f!==void 0)return;this.#p({type:"close_sql",sqlId:e}).then(()=>this.#m.free(e),(t)=>this._setClosed(t))}_execute(e){return this.#p({type:"execute",stmt:e}).then((t)=>t.result)}_batch(e){return this.#p({type:"batch",batch:e}).then((t)=>t.result)}_describe(e){return this.#p({type:"describe",sql:e.sql,sqlId:e.sqlId}).then((t)=>t.result)}_sequence(e){return this.#p({type:"sequence",sql:e.sql,sqlId:e.sqlId}).then((t)=>{return})}getAutocommit(){return this.#e._ensureVersion(3,"getAutocommit()"),this.#p({type:"get_autocommit"}).then((e)=>e.isAutocommit)}#p(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 kr("Cursor was closed, but it was not associated with the stream");this.#c=void 0,Ha(()=>this.#u())}close(){this._setClosed(new st("Stream was manually closed"))}closeGracefully(){this.#l=!0,Ha(()=>this.#u())}get closed(){return this.#f!==void 0||this.#l}_setClosed(e){if(this.#f!==void 0)return;if(this.#f=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.#o!==void 0||this.#s)&&!this.#d)this.#a.push({type:"pipeline",request:{type:"close"},responseCallback:()=>{return},errorCallback:()=>{return}}),this.#d=!0,Ha(()=>this.#u())}#g(e){if(this.#f!==void 0)throw new Pt("Stream is closed",this.#f);else if(this.#l)throw new Pt("Stream is closing",void 0);else this.#a.push(e),Ha(()=>this.#u())}#u(){if(this.#s||this.#c!==void 0)return;if(this.#l&&this.#a.length===0){this._setClosed(new st("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 i=this.#a.first();if(i!==void 0&&i.type==="pipeline")r.push(i),this.#a.shift();else if(i===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.#h(e,t);else throw rt(t,"Impossible type of QueueEntry")}#y(e,t){this.#b(()=>this.#x(t,e),(r)=>D_e(r,e.encoding),(r)=>r.baton,(r)=>r.baseUrl,(r)=>N_e(t,r),(r)=>t.forEach((i)=>i.errorCallback(r)))}#h(e,t){let r=new N$(this,e.encoding);this.#c=r,this.#b(()=>this.#w(t,e),(i)=>r.open(i),(i)=>i.baton,(i)=>i.baseUrl,(i)=>t.cursorCallback(r),(i)=>t.errorCallback(i))}#b(e,t,r,i,n,o){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 L_e(a).then((c)=>{throw c});return t(a)}).then((a)=>{this.#o=r(a),this.#t=i(a)??this.#t,n(a)}).catch((a)=>{this._setClosed(a),o(a)}).finally(()=>{this.#s=!1,this.#u()})}#x(e,t){return this.#S(new URL(t.pipelinePath,this.#t),{baton:this.#o,requests:e.map((r)=>r.request)},t.encoding,iJ,sJ)}#w(e,t){if(t.cursorPath===void 0)throw new Jn(`Cursors are supported only on protocol version 3 and higher, but the HTTP server only supports version ${t.version}.`);return this.#S(new URL(t.cursorPath,this.#t),{baton:this.#o,batch:e.batch},t.encoding,oJ,aJ)}#S(e,t,r,i,n){let o,s;if(r==="json")o=mp(t,i),s="application/json";else if(r==="protobuf")o=yp(t,n),s="application/x-protobuf";else throw rt(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.#i!==void 0)a.set("x-turso-encryption-key",this.#i);return new Request(e.toString(),{method:"POST",headers:a,body:o})}}});async function j_e(e,t){let r=e;for(let i of B_e){let n=new URL(i.versionPath,t),o=new Request(n.toString(),{method:"GET"}),s=await r(o);if(await s.arrayBuffer(),s.ok)return i}return j$}var B_e,j$,sx;var q$=x(()=>{zt();B$();B_e=[{versionPath:"v3-protobuf",pipelinePath:"v3-protobuf/pipeline",cursorPath:"v3-protobuf/cursor",version:3,encoding:"protobuf"}],j$={versionPath:"v2",pipelinePath:"v2/pipeline",cursorPath:void 0,version:2,encoding:"json"};sx=class sx extends iu{#e;#t;#r;#n;#i;#o;_endpointPromise;_endpoint;constructor(e,t,r,i,n=2){super();if(this.#e=e,this.#t=t,this.#r=r??globalThis.fetch,this.#n=i,this.#i=void 0,this.#o=new Set,n==3)this._endpointPromise=j_e(this.#r,this.#e),this._endpointPromise.then((o)=>this._endpoint=o,(o)=>this.#a(o));else this._endpointPromise=Promise.resolve(j$),this._endpointPromise.then((o)=>this._endpoint=o,(o)=>this.#a(o))}async getVersion(){if(this._endpoint!==void 0)return this._endpoint.version;return(await this._endpointPromise).version}_ensureVersion(e,t){if(e<=j$.version)return;else if(this._endpoint===void 0)throw new Jn(`${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 Jn(`${t} is supported only on protocol version ${e} and higher, but the HTTP server only supports version ${this._endpoint.version}.`)}openStream(){if(this.#i!==void 0)throw new Pt("Client is closed",this.#i);let e=new ox(this,this.#e,this.#t,this.#r,this.#n);return this.#o.add(e),e}_streamClosed(e){this.#o.delete(e)}close(){this.#a(new st("Client was manually closed"))}get closed(){return this.#i!==void 0}#a(e){if(this.#i!==void 0)return;this.#i=e;for(let t of Array.from(this.#o))t._setClosed(new Pt("Client was closed",e))}}});var cJ=x(()=>{zt()});function U$(e,t,r=2){if(typeof xs>"u")throw new fp("WebSockets are not supported in this environment");var i=void 0;if(r==3)i=Array.from(O$.keys());else i=Array.from(QK.keys());let n=new xs(e,i);return new nx(n,t)}function M$(e,t,r,i,n=2){return new sx(e instanceof URL?e:new URL(e),t,r,i,n)}var ax=x(()=>{g$();ix();zt();q$();ix();g$();k$();cJ();lu();Vb();Gb();q$();B$();ix();I$();zt()});class Ip{#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 je("Cannot execute statements because the transaction is closed","TRANSACTION_CLOSED");try{let r=e.map(oo),i;if(this.#r===void 0){this._getSqlCache().apply(r);let o=t.batch(this.#t>=3),s=o.step(),a=s.run(ys(this.#e)),c=s;i=r.map((l)=>{let u=o.step().condition(wt.ok(c));if(this.#t>=3)u.condition(wt.not(wt.isAutocommit(o)));let d=u.query(l);return d.catch(()=>{return}),c=u,d}),this.#r=o.execute().then(()=>a).then(()=>{return});try{await this.#r}catch(l){throw this.close(),l}}else{if(this.#t<3)await this.#r;this._getSqlCache().apply(r);let o=t.batch(this.#t>=3),s=void 0;i=r.map((a)=>{let c=o.step();if(s!==void 0)c.condition(wt.ok(s));if(this.#t>=3)c.condition(wt.not(wt.isAutocommit(o)));let l=c.query(a);return l.catch(()=>{return}),s=c,l}),await o.execute()}let n=[];for(let o=0;o<i.length;o++)try{let s=await i[o];if(s===void 0)throw new dr("Statement in a transaction was not executed, probably because the transaction has been rolled back",o,"TRANSACTION_CLOSED");n.push(gu(s))}catch(s){if(s instanceof dr)throw s;let a=yt(s);if(a instanceof je)throw new dr(a.message,o,a.code,a.extendedCode,a.rawCode,a.cause instanceof Error?a.cause:void 0);throw a}return n}catch(r){throw yt(r)}}async executeMultiple(e){let t=this._getStream();if(t.closed)throw new je("Cannot execute statements because the transaction is closed","TRANSACTION_CLOSED");try{if(this.#r===void 0){this.#r=t.run(ys(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 yt(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 yt(r)});e.closeGracefully(),await t}catch(e){throw yt(e)}finally{this.close()}}async commit(){try{let e=this._getStream();if(e.closed)throw new je("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 yt(r)});e.closeGracefully(),await t}catch(e){throw yt(e)}finally{this.close()}}}async function hu(e,t,r,i,n=!1){if(n)r.step().run("PRAGMA foreign_keys=off");let o=r.step(),s=o.run(ys(e)),a=o,c=i.map((m)=>{let y=r.step().condition(wt.ok(a));if(t>=3)y.condition(wt.not(wt.isAutocommit(r)));let g=y.query(m);return a=y,g}),l=r.step().condition(wt.ok(a));if(t>=3)l.condition(wt.not(wt.isAutocommit(r)));let u=l.run("COMMIT");if(r.step().condition(wt.not(wt.ok(l))).run("ROLLBACK").catch((m)=>{return}),n)r.step().run("PRAGMA foreign_keys=on");await r.execute();let p=[];await s;for(let m=0;m<c.length;m++)try{let y=await c[m];if(y===void 0)throw new dr("Statement in a batch was not executed, probably because the transaction has been rolled back",m,"TRANSACTION_CLOSED");p.push(gu(y))}catch(y){if(y instanceof dr)throw y;let g=yt(y);if(g instanceof je)throw new dr(g.message,m,g.code,g.extendedCode,g.rawCode,g.cause instanceof Error?g.cause:void 0);throw g}return await u,p}function oo(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 i=new Sp(t);if(r)if(Array.isArray(r))i.bindIndexes(r);else for(let[n,o]of Object.entries(r))i.bindName(n,o);return i}function gu(e){let t=e.columnNames.map((s)=>s??""),r=e.columnDecltypes.map((s)=>s??""),i=e.rows,n=e.affectedRowCount,o=e.lastInsertRowid!==void 0?e.lastInsertRowid:void 0;return new eu(t,r,i,n,o)}function yt(e){if(e instanceof st){let t=lJ(e);return new je(e.message,t,void 0,void 0,e)}return e}function lJ(e){if(e instanceof dp&&e.code!==void 0)return e.code;else if(e instanceof qe)return"HRANA_PROTO_ERROR";else if(e instanceof Pt)return e.cause instanceof st?lJ(e.cause):"HRANA_CLOSED_ERROR";else if(e instanceof ou)return"HRANA_WEBSOCKET_ERROR";else if(e instanceof qa)return"SERVER_ERROR";else if(e instanceof Jn)return"PROTOCOL_VERSION_ERROR";else if(e instanceof kr)return"INTERNAL_ERROR";else return"UNKNOWN"}var Z$=x(()=>{ax();Kn();tu()});class yu{#e;#t;capacity;constructor(e,t){this.#e=e,this.#t=new uJ,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 i=r.sql;if(i.length>=5000)continue;let n=this.#t.get(i);if(n===void 0){while(this.#t.size+1>this.capacity){let[o,s]=this.#t.peekLru();if(t.has(s))break;s.close(),this.#t.delete(o)}if(this.#t.size+1<=this.capacity)n=this.#e.storeSql(i),this.#t.set(i,n)}if(n!==void 0)r.sql=n,t.add(n)}}}class uJ{#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 H$=ee(function(D9e,fJ){function q_e(e){var t=0,r=[];function i(){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 o(c){return new Promise(function(l,u){r.push({fn:c,resolve:l,reject:u}),a.queue=r.length})}function s(c){t++;try{return Promise.resolve(c()).then(function(l){return i(),l},function(l){throw i(),l})}catch(l){return i(),Promise.reject(l)}}var a=function(c){if(t>=e)return o(c);else return s(c)};return a}function U_e(e,t){var r=!1,i=this;return Promise.all(e.map(function(){var n=arguments;return i(function(){if(!r)return t.apply(void 0,n).catch(function(o){throw r=!0,o})})}))}function dJ(e){return e.queue=0,e.map=U_e,e}fJ.exports=function(e){if(e)return dJ(q_e(e));else return dJ(function(t){return t()})}});function hJ(e){if(e.scheme!=="wss"&&e.scheme!=="ws")throw new je(`The WebSocket client supports only "libsql:", "wss:" and "ws:" URLs, got ${JSON.stringify(e.scheme+":")}. For more information, please read ${xi}`,"URL_SCHEME_NOT_SUPPORTED");if(e.encryptionKey!==void 0)throw new je("Encryption key is not supported by the remote client.","ENCRYPTION_KEY_NOT_SUPPORTED");if(e.scheme==="ws"&&e.tls)throw new je('A "ws:" URL cannot opt into TLS by using ?tls=1',"URL_INVALID");else if(e.scheme==="wss"&&!e.tls)throw new je('A "wss:" URL cannot opt out of TLS by using ?tls=0',"URL_INVALID");let t=sp(e.scheme,e.authority,e.path),r;try{r=U$(t,e.authToken)}catch(i){if(i instanceof fp){let n=e.scheme==="wss"?"https":"http",o=sp(n,e.authority,e.path);throw new je(`This environment does not support WebSockets, please switch to the HTTP client by using a "${n}:" URL (${JSON.stringify(o)}). For more information, please read ${xi}`,"WEBSOCKETS_NOT_SUPPORTED")}throw yt(i)}return new gJ(r,t,e.authToken,e.intMode,e.concurrency)}class gJ{#e;#t;#r;#n;#i;closed;protocol;#o;#a;constructor(e,t,r,i,n){this.#e=t,this.#t=r,this.#r=i,this.#n=this.#c(e),this.#i=void 0,this.closed=!1,this.protocol="ws",this.#a=mJ.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 i=await this.#s();try{let n=oo(r);i.conn.sqlCache.apply([n]);let o=i.stream.query(n);i.stream.closeGracefully();let s=await o;return gu(s)}catch(n){throw yt(n)}finally{this._closeStream(i)}})}async batch(e,t="deferred"){return this.limit(async()=>{let r=await this.#s();try{let n=e.map((l)=>{if(Array.isArray(l))return{sql:l[0],args:l[1]||[]};return l}).map(oo),o=await r.conn.client.getVersion();r.conn.sqlCache.apply(n);let s=r.stream.batch(o>=3);return await hu(t,o,s,n)}catch(i){throw yt(i)}finally{this._closeStream(r)}})}async migrate(e){return this.limit(async()=>{let t=await this.#s();try{let r=e.map(oo),i=await t.conn.client.getVersion(),n=t.stream.batch(i>=3);return await hu("deferred",i,n,r,!0)}catch(r){throw yt(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 yJ(this,t,e,r)}catch(r){throw this._closeStream(t),yt(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 yt(r)}finally{this._closeStream(t)}})}sync(){throw new je("sync not supported in ws mode","SYNC_NOT_SUPPORTED")}async#s(){if(this.closed)throw new je("The client is closed","CLIENT_CLOSED");if(new Date().valueOf()-this.#n.openTime.valueOf()>M_e&&this.#i===void 0){let i=this.#c();this.#i=i,i.client.getVersion().then((n)=>{if(this.#n!==i){if(this.#n.streamStates.size===0)this.#n.client.close()}this.#n=i,this.#i=void 0},(n)=>{this.#i=void 0})}if(this.#n.client.closed)try{if(this.#i!==void 0)this.#n=this.#i;else this.#n=this.#c()}catch(i){throw yt(i)}let r=this.#n;try{if(r.useSqlCache===void 0){if(r.useSqlCache=await r.client.getVersion()>=2,r.useSqlCache)r.sqlCache.capacity=pJ}let i=r.client.openStream();i.intMode=this.#r;let n={conn:r,stream:i};return r.streamStates.add(n),n}catch(i){throw yt(i)}}#c(e){try{return e??=U$(this.#e,this.#t),{client:e,useSqlCache:void 0,sqlCache:new yu(e,0),openTime:new Date,streamStates:new Set}}catch(t){throw yt(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.#i){try{this.#i.client.close()}catch{}this.#i=void 0}let e=this.#c(),t=await e.client.getVersion();if(e.useSqlCache=t>=2,e.useSqlCache)e.sqlCache.capacity=pJ;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.#i){try{this.#i.client.close()}catch{}this.#i=void 0}this.closed=!0}}var mJ,M_e=60000,pJ=100,yJ;var bJ=x(()=>{ax();Kn();lp();Z$();Lb();tu();mJ=rc(H$(),1);Kn();yJ=class yJ extends Ip{#e;#t;constructor(e,t,r,i){super(r,i);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 SJ(e){if(e.scheme!=="https"&&e.scheme!=="http")throw new je(`The HTTP client supports only "libsql:", "https:" and "http:" URLs, got ${JSON.stringify(e.scheme+":")}. For more information, please read ${xi}`,"URL_SCHEME_NOT_SUPPORTED");if(e.encryptionKey!==void 0)throw new je("Encryption key is not supported by the remote client.","ENCRYPTION_KEY_NOT_SUPPORTED");if(e.scheme==="http"&&e.tls)throw new je('A "http:" URL cannot opt into TLS by using ?tls=1',"URL_INVALID");else if(e.scheme==="https"&&!e.tls)throw new je('A "https:" URL cannot opt out of TLS by using ?tls=0',"URL_INVALID");let t=sp(e.scheme,e.authority,e.path);return new vJ(t,e.authToken,e.intMode,e.fetch,e.concurrency,e.remoteEncryptionKey)}class vJ{#e;protocol;#t;#r;#n;#i;#o;#a;#s;constructor(e,t,r,i,n,o){this.#t=e,this.#o=t,this.#r=r,this.#n=i,this.#i=n,this.#a=o,this.#e=M$(this.#t,this.#o,this.#n,o),this.#e.intMode=this.#r,this.protocol="http",this.#s=xJ.default(this.#i)}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 i=oo(r),n,o=this.#e.openStream();try{n=o.query(i)}finally{o.closeGracefully()}let s=await n;return gu(s)}catch(i){throw yt(i)}})}async batch(e,t="deferred"){return this.limit(async()=>{try{let i=e.map((c)=>{if(Array.isArray(c))return{sql:c[0],args:c[1]||[]};return c}).map(oo),n=await this.#e.getVersion(),o,s=this.#e.openStream();try{new yu(s,wJ).apply(i);let l=s.batch(!1);o=hu(t,n,l,i)}finally{s.closeGracefully()}return await o}catch(r){throw yt(r)}})}async migrate(e){return this.limit(async()=>{try{let t=e.map(oo),r=await this.#e.getVersion(),i,n=this.#e.openStream();try{let s=n.batch(!1);i=hu("deferred",r,s,t,!0)}finally{n.closeGracefully()}return await i}catch(t){throw yt(t)}})}async transaction(e="write"){return this.limit(async()=>{try{let t=await this.#e.getVersion();return new _J(this.#e.openStream(),e,t)}catch(t){throw yt(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 yt(t)}})}sync(){throw new je("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=M$(this.#t,this.#o,this.#n,this.#a),this.#e.intMode=this.#r}}get closed(){return this.#e.closed}}var xJ,wJ=30,_J;var kJ=x(()=>{ax();Kn();lp();Z$();Lb();tu();xJ=rc(H$(),1);Kn();_J=class _J extends Ip{#e;#t;constructor(e,t,r){super(t,r);this.#e=e,this.#t=new yu(e,wJ)}_getStream(){return this.#e}_getSqlCache(){return this.#t}close(){this.#e.close()}get closed(){return this.#e.closed}}});function bu(e){return F_e(cp(e,!0))}function F_e(e){if(e.scheme==="wss"||e.scheme==="ws")return hJ(e);else if(e.scheme==="https"||e.scheme==="http")return SJ(e);else return xK(e)}var K$=x(()=>{lp();kK();bJ();kJ();Kn()});function ce(e,t){if(!e||typeof e!=="object")return!1;if(e instanceof t)return!0;if(!Object.prototype.hasOwnProperty.call(t,J))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(J in r&&r[J]===t[J])return!0;r=Object.getPrototypeOf(r)}return!1}var J;var De=x(()=>{J=Symbol.for("drizzle:entityKind")});var nt;var Wn=x(()=>{De();nt=class nt{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[J]="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 Ap;var cx=x(()=>{De();Ap=class Ap{static[J]="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 Er;var xu=x(()=>{Er=Symbol.for("drizzle:Name")});var J$,EJ;var IJ=x(()=>{De();xu();J$=class J${static[J]="PgForeignKeyBuilder";reference;_onUpdate="no action";_onDelete="no action";constructor(e,t){if(this.reference=()=>{let{name:r,columns:i,foreignColumns:n}=e();return{name:r,columns:i,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 EJ(e,this)}};EJ=class EJ{constructor(e,t){this.table=e,this.reference=t.reference,this.onUpdate=t._onUpdate,this.onDelete=t._onDelete}static[J]="PgForeignKey";reference;onUpdate;onDelete;getName(){let{name:e,columns:t,foreignColumns:r}=this.reference(),i=t.map((s)=>s.name),n=r.map((s)=>s.name),o=[this.table[Er],...i,r[0].table[Er],...n];return e??`${o.join("_")}_fk`}}});function lx(e,...t){return e(...t)}var V$=()=>{};function W$(e,t){return`${e[Er]}_${t.join("_")}_unique`}var AJ,Z_e,TJ;var CJ=x(()=>{De();xu();AJ=class AJ{constructor(e,t){this.name=t,this.columns=e}static[J]="PgUniqueConstraintBuilder";columns;nullsNotDistinctConfig=!1;nullsNotDistinct(){return this.nullsNotDistinctConfig=!0,this}build(e){return new TJ(e,this.columns,this.nullsNotDistinctConfig,this.name)}};Z_e=class Z_e{static[J]="PgUniqueOnConstraintBuilder";name;constructor(e){this.name=e}on(...e){return new AJ(e,this.name)}};TJ=class TJ{constructor(e,t,r,i){this.table=e,this.columns=t,this.name=i??W$(this.table,this.columns.map((n)=>n.name)),this.nullsNotDistinct=r}static[J]="PgUniqueConstraint";columns;name;nullsNotDistinct=!1;getName(){return this.name}}});function $J(e,t,r){for(let i=t;i<e.length;i++){let n=e[i];if(n==="\\"){i++;continue}if(n==='"')return[e.slice(t,i).replace(/\\/g,""),i+1];if(r)continue;if(n===","||n==="}")return[e.slice(t,i).replace(/\\/g,""),i]}return[e.slice(t).replace(/\\/g,""),e.length]}function OJ(e,t=0){let r=[],i=t,n=!1;while(i<e.length){let o=e[i];if(o===","){if(n||i===t)r.push("");n=!0,i++;continue}if(n=!1,o==="\\"){i+=2;continue}if(o==='"'){let[c,l]=$J(e,i+1,!0);r.push(c),i=l;continue}if(o==="}")return[r,i+1];if(o==="{"){let[c,l]=OJ(e,i+1);r.push(c),i=l;continue}let[s,a]=$J(e,i,!1);r.push(s),i=a}return[r,i]}function RJ(e){let[t]=OJ(e,1);return t}function G$(e){return`{${e.map((t)=>{if(Array.isArray(t))return G$(t);if(typeof t==="string")return`"${t.replace(/\\/g,"\\\\").replace(/"/g,"\\\"")}"`;return`${t}`}).join(",")}}`}var PJ=()=>{};var Tp,Su,zJ,H_e,NJ,Q$;var DJ=x(()=>{cx();Wn();De();IJ();V$();CJ();PJ();Tp=class Tp extends Ap{foreignKeyConfigs=[];static[J]="PgColumnBuilder";array(e){return new NJ(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:i})=>lx((n,o)=>{let s=new J$(()=>{let a=n();return{columns:[e],foreignColumns:[a]}});if(o.onUpdate)s.onUpdate(o.onUpdate);if(o.onDelete)s.onDelete(o.onDelete);return s.build(t)},r,i))}buildExtraConfigColumn(e){return new zJ(e,this.config)}};Su=class Su extends nt{constructor(e,t){if(!t.uniqueName)t.uniqueName=W$(e,[t.name]);super(e,t);this.table=e}static[J]="PgColumn"};zJ=class zJ extends Su{static[J]="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}};H_e=class H_e{static[J]="IndexedColumn";constructor(e,t,r,i){this.name=e,this.keyAsName=t,this.type=r,this.indexConfig=i}name;keyAsName;type;indexConfig};NJ=class NJ extends Tp{static[J]="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 Q$(e,this.config,t)}};Q$=class Q$ extends Su{constructor(e,t,r,i){super(e,t);this.baseColumn=r,this.range=i,this.size=t.size}size;static[J]="PgArray";getSQLType(){return`${this.baseColumn.getSQLType()}[${typeof this.size==="number"?this.size:""}]`}mapFromDriverValue(e){if(typeof e==="string")e=RJ(e);return e.map((t)=>this.baseColumn.mapFromDriverValue(t))}mapToDriverValue(e,t=!1){let r=e.map((i)=>i===null?null:ce(this.baseColumn,Q$)?this.baseColumn.mapToDriverValue(i,!0):this.baseColumn.mapToDriverValue(i));if(t)return r;return G$(r)}}});function jJ(e){return!!e&&typeof e==="function"&&LJ in e&&e[LJ]===!0}var K_e,BJ,LJ,J_e,qJ;var UJ=x(()=>{De();DJ();K_e=class K_e extends Tp{static[J]="PgEnumObjectColumnBuilder";constructor(e,t){super(e,"string","PgEnumObjectColumn");this.config.enum=t}build(e){return new BJ(e,this.config)}};BJ=class BJ extends Su{static[J]="PgEnumObjectColumn";enum;enumValues=this.config.enum.enumValues;constructor(e,t){super(e,t);this.enum=t.enum}getSQLType(){return this.enum.enumName}};LJ=Symbol.for("drizzle:isPgEnum");J_e=class J_e extends Tp{static[J]="PgEnumColumnBuilder";constructor(e,t){super(e,"string","PgEnumColumn");this.config.enum=t}build(e){return new qJ(e,this.config)}};qJ=class qJ extends Su{static[J]="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 vt,Cp;var Gn=x(()=>{De();vt=class vt{static[J]="Subquery";constructor(e,t,r,i=!1,n=[]){this._={brand:"Subquery",sql:e,selectedFields:t,alias:r,isWith:i,usedTables:n}}};Cp=class Cp extends vt{static[J]="WithSubquery"}});var MJ="0.45.2";var FJ=()=>{};var Y$,X$,ZJ;var HJ=x(()=>{V$();FJ();ZJ={startActiveSpan(e,t){if(!Y$)return t();if(!X$)X$=Y$.trace.getTracer("drizzle-orm",MJ);return lx((r,i)=>i.startActiveSpan(e,(n)=>{try{return t(n)}catch(o){throw n.setStatus({code:r.SpanStatusCode.ERROR,message:o instanceof Error?o.message:"Unknown error"}),o}finally{n.end()}}),Y$,X$)}}});var _t;var so=x(()=>{_t=Symbol.for("drizzle:ViewBaseConfig")});function Is(e){return e[Er]}function Ka(e){return`${e[ux]??"public"}.${e[Er]}`}var ux,dx,KJ,eO,tO,$p,JJ,V_e,we;var Ir=x(()=>{De();xu();ux=Symbol.for("drizzle:Schema"),dx=Symbol.for("drizzle:Columns"),KJ=Symbol.for("drizzle:ExtraConfigColumns"),eO=Symbol.for("drizzle:OriginalName"),tO=Symbol.for("drizzle:BaseName"),$p=Symbol.for("drizzle:IsAlias"),JJ=Symbol.for("drizzle:ExtraConfigBuilder"),V_e=Symbol.for("drizzle:IsDrizzleTable");we=class we{static[J]="Table";static Symbol={Name:Er,Schema:ux,OriginalName:eO,Columns:dx,ExtraConfigColumns:KJ,BaseName:tO,IsAlias:$p,ExtraConfigBuilder:JJ};[Er];[eO];[ux];[dx];[KJ];[tO];[$p]=!1;[V_e]=!0;[JJ]=void 0;constructor(e,t,r){this[Er]=this[eO]=e,this[ux]=t,this[tO]=r}}});function rO(e){return e!==null&&e!==void 0&&typeof e.getSQL==="function"}function G_e(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 VJ(e){return typeof e==="object"&&e!==null&&"mapToDriverValue"in e&&typeof e.mapToDriverValue==="function"}function q(e,...t){let r=[];if(t.length>0||e.length>0&&e[0]!=="")r.push(new Vt(e[0]));for(let[i,n]of t.entries())r.push(n,new Vt(e[i+1]));return new Te(r)}function Op(e,t){return e.map((r)=>{if(ce(r,As)){if(!(r.name in t))throw Error(`No value for placeholder "${r.name}" was provided`);return t[r.name]}if(ce(r,mn)&&ce(r.value,As)){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 W_e,Vt,Te,fx,WJ,GJ,JVe,mn,As,Q_e,$n;var pr=x(()=>{De();UJ();Gn();HJ();so();Wn();Ir();W_e=class W_e{static[J]="FakePrimitiveParam"};Vt=class Vt{static[J]="StringChunk";value;constructor(e){this.value=Array.isArray(e)?e:[e]}getSQL(){return new Te([this])}};Te=class Te{constructor(e){this.queryChunks=e;for(let t of e)if(ce(t,we)){let r=t[we.Symbol.Schema];this.usedTables.push(r===void 0?t[we.Symbol.Name]:r+"."+t[we.Symbol.Name])}}static[J]="SQL";decoder=WJ;shouldInlineParams=!1;usedTables=[];append(e){return this.queryChunks.push(...e.queryChunks),this}toQuery(e){return ZJ.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:i,escapeName:n,escapeParam:o,prepareTyping:s,inlineParams:a,paramStartIndex:c}=r;return G_e(e.map((l)=>{if(ce(l,Vt))return{sql:l.value.join(""),params:[]};if(ce(l,fx))return{sql:n(l.value),params:[]};if(l===void 0)return{sql:"",params:[]};if(Array.isArray(l)){let u=[new Vt("(")];for(let[d,p]of l.entries())if(u.push(p),d<l.length-1)u.push(new Vt(", "));return u.push(new Vt(")")),this.buildQueryFromSourceParams(u,r)}if(ce(l,Te))return this.buildQueryFromSourceParams(l.queryChunks,{...r,inlineParams:a||l.shouldInlineParams});if(ce(l,we)){let u=l[we.Symbol.Schema],d=l[we.Symbol.Name];return{sql:u===void 0||l[$p]?n(d):n(u)+"."+n(d),params:[]}}if(ce(l,nt)){let u=i.getColumnCasing(l);if(t.invokeSource==="indexes")return{sql:n(u),params:[]};let d=l.table[we.Symbol.Schema];return{sql:l.table[$p]||d===void 0?n(l.table[we.Symbol.Name])+"."+n(u):n(d)+"."+n(l.table[we.Symbol.Name])+"."+n(u),params:[]}}if(ce(l,$n)){let u=l[_t].schema,d=l[_t].name;return{sql:u===void 0||l[_t].isAlias?n(d):n(u)+"."+n(d),params:[]}}if(ce(l,mn)){if(ce(l.value,As))return{sql:o(c.value++,l),params:[l],typings:["none"]};let u=l.value===null?null:l.encoder.mapToDriverValue(l.value);if(ce(u,Te))return this.buildQueryFromSourceParams([u],r);if(a)return{sql:this.mapInlineParam(u,r),params:[]};let d=["none"];if(s)d=[s(l.encoder)];return{sql:o(c.value++,u),params:[u],typings:d}}if(ce(l,As))return{sql:o(c.value++,l),params:[l],typings:["none"]};if(ce(l,Te.Aliased)&&l.fieldAlias!==void 0)return{sql:n(l.fieldAlias),params:[]};if(ce(l,vt)){if(l._.isWith)return{sql:n(l._.alias),params:[]};return this.buildQueryFromSourceParams([new Vt("("),l._.sql,new Vt(") "),new fx(l._.alias)],r)}if(jJ(l)){if(l.schema)return{sql:n(l.schema)+"."+n(l.enumName),params:[]};return{sql:n(l.enumName),params:[]}}if(rO(l)){if(l.shouldOmitSQLParens?.())return this.buildQueryFromSourceParams([l.getSQL()],r);return this.buildQueryFromSourceParams([new Vt("("),l.getSQL(),new Vt(")")],r)}if(a)return{sql:this.mapInlineParam(l,r),params:[]};return{sql:o(c.value++,l),params:[l],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 Te.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}};fx=class fx{constructor(e){this.value=e}static[J]="Name";brand;getSQL(){return new Te([this])}};WJ={mapFromDriverValue:(e)=>e},GJ={mapToDriverValue:(e)=>e},JVe={...WJ,...GJ};mn=class mn{constructor(e,t=GJ){this.value=e,this.encoder=t}static[J]="Param";brand;getSQL(){return new Te([this])}};((e)=>{function t(){return new Te([])}e.empty=t;function r(c){return new Te(c)}e.fromList=r;function i(c){return new Te([new Vt(c)])}e.raw=i;function n(c,l){let u=[];for(let[d,p]of c.entries()){if(d>0&&l!==void 0)u.push(l);u.push(p)}return new Te(u)}e.join=n;function o(c){return new fx(c)}e.identifier=o;function s(c){return new As(c)}e.placeholder=s;function a(c,l){return new mn(c,l)}e.param=a})(q||(q={}));((e)=>{class t{constructor(r,i){this.sql=r,this.fieldAlias=i}static[J]="SQL.Aliased";isSelectionField=!1;getSQL(){return this.sql}clone(){return new t(this.sql,this.fieldAlias)}}e.Aliased=t})(Te||(Te={}));As=class As{constructor(e){this.name=e}static[J]="Placeholder";getSQL(){return new Te([this])}};Q_e=Symbol.for("drizzle:IsDrizzleView");$n=class $n{static[J]="View";[_t];[Q_e]=!0;constructor({name:e,schema:t,selectedFields:r,query:i}){this[_t]={name:e,originalName:e,schema:t,selectedFields:r,query:i,isExisting:!i,isAlias:!1}}getSQL(){return new Te([this])}};nt.prototype.getSQL=function(){return new Te([this])};we.prototype.getSQL=function(){return new Te([this])};vt.prototype.getSQL=function(){return new Te([this])}});function nO(e,t,r){let i={},n=e.reduce((o,{path:s,field:a},c)=>{let l;if(ce(a,nt))l=a;else if(ce(a,Te))l=a.decoder;else if(ce(a,vt))l=a._.sql.decoder;else l=a.sql.decoder;let u=o;for(let[d,p]of s.entries())if(d<s.length-1){if(!(p in u))u[p]={};u=u[p]}else{let m=t[c],y=u[p]=m===null?null:l.mapFromDriverValue(m);if(r&&ce(a,nt)&&s.length===2){let g=s[0];if(!(g in i))i[g]=y===null?Is(a.table):!1;else if(typeof i[g]==="string"&&i[g]!==Is(a.table))i[g]=!1}}return o},{});if(r&&Object.keys(i).length>0){for(let[o,s]of Object.entries(i))if(typeof s==="string"&&!r[s])n[o]=null}return n}function On(e,t){return Object.entries(e).reduce((r,[i,n])=>{if(typeof i!=="string")return r;let o=t?[...t,i]:[i];if(ce(n,nt)||ce(n,Te)||ce(n,Te.Aliased)||ce(n,vt))r.push({path:o,field:n});else if(ce(n,we))r.push(...On(n[we.Symbol.Columns],o));else r.push(...On(n,o));return r},[])}function Rp(e,t){let r=Object.keys(e),i=Object.keys(t);if(r.length!==i.length)return!1;for(let[n,o]of r.entries())if(o!==i[n])return!1;return!0}function px(e,t){let r=Object.entries(t).filter(([,i])=>i!==void 0).map(([i,n])=>{if(ce(n,Te)||ce(n,nt))return[i,n];else return[i,new mn(n,e[we.Symbol.Columns][i])]});if(r.length===0)throw Error("No values to set");return Object.fromEntries(r)}function QJ(e,t){for(let r of t)for(let i of Object.getOwnPropertyNames(r.prototype)){if(i==="constructor")continue;Object.defineProperty(e.prototype,i,Object.getOwnPropertyDescriptor(r.prototype,i)||Object.create(null))}}function mx(e){return e[we.Symbol.Columns]}function Pp(e){return ce(e,vt)?e._.alias:ce(e,$n)?e[_t].name:ce(e,Te)?void 0:e[we.Symbol.IsAlias]?e[we.Symbol.Name]:e[we.Symbol.BaseName]}function _i(e,t){return{name:typeof e==="string"&&e.length>0?e:"",config:typeof e==="object"?e:t}}function YJ(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 iO;var Ur=x(()=>{Wn();De();pr();Gn();Ir();so();iO=typeof TextDecoder>"u"?null:new TextDecoder});var XJ,oO,sO;var hx=x(()=>{De();XJ=class XJ{static[J]="ConsoleLogWriter";write(e){console.log(e)}};oO=class oO{static[J]="DefaultLogger";writer;constructor(e){this.writer=e?.writer??new XJ}logQuery(e,t){let r=t.map((n)=>{try{return JSON.stringify(n)}catch{return String(n)}}),i=r.length?` -- params: [${r.join(", ")}]`:"";this.writer.write(`Query: ${e}${i}`)}};sO=class sO{static[J]="NoopLogger";logQuery(){}}});var e9,t9,aO;var r9=x(()=>{De();Ir();e9=Symbol.for("drizzle:PgInlineForeignKeys"),t9=Symbol.for("drizzle:EnableRLS");aO=class aO extends we{static[J]="PgTable";static Symbol=Object.assign({},we.Symbol,{InlineForeignKeys:e9,EnableRLS:t9});[e9]=[];[t9]=!1;[we.Symbol.ExtraConfigBuilder]=void 0;[we.Symbol.ExtraConfigColumns]={}}});var cO,n9;var i9=x(()=>{De();r9();cO=class cO{static[J]="PgPrimaryKeyBuilder";columns;name;constructor(e,t){this.columns=e,this.name=t}build(e){return new n9(e,this.columns,this.name)}};n9=class n9{constructor(e,t,r){this.table=e,this.columns=t,this.name=r}static[J]="PgPrimaryKey";columns;name;getName(){return this.name??`${this.table[aO.Symbol.Name]}_${this.columns.map((e)=>e.name).join("_")}_pk`}}});function Qr(e,t){if(VJ(t)&&!rO(e)&&!ce(e,mn)&&!ce(e,As)&&!ce(e,nt)&&!ce(e,we)&&!ce(e,$n))return new mn(e,t);return e}function Nt(...e){let t=e.filter((r)=>r!==void 0);if(t.length===0)return;if(t.length===1)return new Te(t);return new Te([new Vt("("),q.join(t,new Vt(" and ")),new Vt(")")])}function ao(...e){let t=e.filter((r)=>r!==void 0);if(t.length===0)return;if(t.length===1)return new Te(t);return new Te([new Vt("("),q.join(t,new Vt(" or ")),new Vt(")")])}function s9(e){return q`not ${e}`}function Ts(e,t){if(Array.isArray(t)){if(t.length===0)return q`false`;return q`${e} in ${t.map((r)=>Qr(r,e))}`}return q`${e} in ${Qr(t,e)}`}function l9(e,t){if(Array.isArray(t)){if(t.length===0)return q`true`;return q`${e} not in ${t.map((r)=>Qr(r,e))}`}return q`${e} not in ${Qr(t,e)}`}function Rn(e){return q`${e} is null`}function u9(e){return q`${e} is not null`}function yx(e){return q`exists ${e}`}function bx(e){return q`not exists ${e}`}function d9(e,t,r){return q`${e} between ${Qr(t,e)} and ${Qr(r,e)}`}function f9(e,t,r){return q`${e} not between ${Qr(t,e)} and ${Qr(r,e)}`}function p9(e,t){return q`${e} like ${t}`}function m9(e,t){return q`${e} not like ${t}`}function h9(e,t){return q`${e} ilike ${t}`}function g9(e,t){return q`${e} not ilike ${t}`}var et=(e,t)=>q`${e} = ${Qr(t,e)}`,o9=(e,t)=>q`${e} <> ${Qr(t,e)}`,gx=(e,t)=>q`${e} > ${Qr(t,e)}`,a9=(e,t)=>q`${e} >= ${Qr(t,e)}`,c9=(e,t)=>q`${e} < ${Qr(t,e)}`,wu=(e,t)=>q`${e} <= ${Qr(t,e)}`;var y9=x(()=>{Wn();De();Ir();pr()});function co(e){return q`${e} asc`}function Ja(e){return q`${e} desc`}var b9=x(()=>{pr()});var lO=x(()=>{y9();b9()});function S9(){return{and:Nt,between:d9,eq:et,exists:yx,gt:gx,gte:a9,ilike:h9,inArray:Ts,isNull:Rn,isNotNull:u9,like:p9,lt:c9,lte:wu,ne:o9,not:s9,notBetween:f9,notExists:bx,notLike:m9,notIlike:g9,notInArray:l9,or:ao,sql:q}}function w9(){return{sql:q,asc:co,desc:Ja}}function v9(e,t){if(Object.keys(e).length===1&&"default"in e&&!ce(e.default,we))e=e.default;let r={},i={},n={};for(let[o,s]of Object.entries(e))if(ce(s,we)){let a=Ka(s),c=i[a];r[a]=o,n[o]={tsName:o,dbName:s[we.Symbol.Name],schema:s[we.Symbol.Schema],columns:s[we.Symbol.Columns],relations:c?.relations??{},primaryKey:c?.primaryKey??[]};for(let u of Object.values(s[we.Symbol.Columns]))if(u.primary)n[o].primaryKey.push(u);let l=s[we.Symbol.ExtraConfigBuilder]?.(s[we.Symbol.ExtraConfigColumns]);if(l){for(let u of Object.values(l))if(ce(u,cO))n[o].primaryKey.push(...u.columns)}}else if(ce(s,x9)){let a=Ka(s.table),c=r[a],l=s.config(t(s.table)),u;for(let[d,p]of Object.entries(l))if(c){let m=n[c];if(m.relations[d]=p,u)m.primaryKey.push(...u)}else{if(!(a in i))i[a]={relations:{},primaryKey:u};i[a].relations[d]=p}}return{tables:n,tableNamesMap:r}}function Y_e(e){return function(r,i){return new Cs(e,r,i,i?.fields.reduce((n,o)=>n&&o.notNull,!0)??!1)}}function X_e(e){return function(r,i){return new zp(e,r,i)}}function _9(e,t,r){if(ce(r,Cs)&&r.config)return{fields:r.config.fields,references:r.config.references};let i=t[Ka(r.referencedTable)];if(!i)throw Error(`Table "${r.referencedTable[we.Symbol.Name]}" not found in schema`);let n=e[i];if(!n)throw Error(`Table "${i}" not found in schema`);let o=r.sourceTable,s=t[Ka(o)];if(!s)throw Error(`Table "${o[we.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 "${i}"`):Error(`There are multiple relations between "${i}" and "${r.sourceTable[we.Symbol.Name]}". Please specify relation name`);if(a[0]&&ce(a[0],Cs)&&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 k9(e){return{one:Y_e(e),many:X_e(e)}}function xx(e,t,r,i,n=(o)=>o){let o={};for(let[s,a]of i.entries())if(a.isJson){let c=t.relations[a.tsKey],l=r[s],u=typeof l==="string"?JSON.parse(l):l;o[a.tsKey]=ce(c,Cs)?u&&xx(e,e[a.relationTableTsKey],u,a.selection,n):u.map((d)=>xx(e,e[a.relationTableTsKey],d,a.selection,n))}else{let c=n(r[s]),l=a.field,u;if(ce(l,nt))u=l;else if(ce(l,Te))u=l.decoder;else u=l.sql.decoder;o[a.tsKey]=c===null?null:u.mapFromDriverValue(c)}return o}var uO,x9,Cs,zp;var Np=x(()=>{Ir();Wn();De();i9();lO();pr();uO=class uO{constructor(e,t,r){this.sourceTable=e,this.referencedTable=t,this.relationName=r,this.referencedTableName=t[we.Symbol.Name]}static[J]="Relation";referencedTableName;fieldName};x9=class x9{constructor(e,t){this.table=e,this.config=t}static[J]="Relations"};Cs=class Cs extends uO{constructor(e,t,r,i){super(e,t,r?.relationName);this.config=r,this.isNullable=i}static[J]="One";withFieldName(e){let t=new Cs(this.sourceTable,this.referencedTable,this.config,this.isNullable);return t.fieldName=e,t}};zp=class zp extends uO{constructor(e,t,r){super(e,t,r?.relationName);this.config=r}static[J]="Many";withFieldName(e){let t=new zp(this.sourceTable,this.referencedTable,this.config);return t.fieldName=e,t}}});function Lp(e,t){return new Proxy(e,new Dp(t,!1))}function ki(e,t){return new Proxy(e,new vu(new Proxy(e.table,new Dp(t,!1))))}function dO(e,t){return new Te.Aliased(Bp(e.sql,t),e.fieldAlias)}function Bp(e,t){return q.join(e.queryChunks.map((r)=>{if(ce(r,nt))return ki(r,t);if(ce(r,Te))return Bp(r,t);if(ce(r,Te.Aliased))return dO(r,t);return r}))}var vu,Dp,eke;var Sx=x(()=>{Wn();De();pr();Ir();so();vu=class vu{constructor(e){this.table=e}static[J]="ColumnAliasProxyHandler";get(e,t){if(t==="table")return this.table;return e[t]}};Dp=class Dp{constructor(e,t){this.alias=e,this.replaceOriginalName=t}static[J]="TableAliasProxyHandler";get(e,t){if(t===we.Symbol.IsAlias)return!0;if(t===we.Symbol.Name)return this.alias;if(this.replaceOriginalName&&t===we.Symbol.OriginalName)return this.alias;if(t===_t)return{...e[_t],name:this.alias,isAlias:!0};if(t===we.Symbol.Columns){let i=e[we.Symbol.Columns];if(!i)return i;let n={};return Object.keys(i).map((o)=>{n[o]=new Proxy(i[o],new vu(new Proxy(e,this)))}),n}let r=e[t];if(ce(r,nt))return new Proxy(r,new vu(new Proxy(e,this)));return r}};eke=class eke{constructor(e){this.alias=e}static[J]="RelationTableAliasProxyHandler";get(e,t){if(t==="sourceTable")return Lp(e.sourceTable,this.alias);return e[t]}}});var bt;var Va=x(()=>{Sx();Wn();De();pr();Gn();so();bt=class bt{static[J]="SelectionProxyHandler";config;constructor(e){this.config={...e}}get(e,t){if(t==="_")return{...e._,selectedFields:new Proxy(e._.selectedFields,this)};if(t===_t)return{...e[_t],selectedFields:new Proxy(e[_t].selectedFields,this)};if(typeof t==="symbol")return e[t];let i=(ce(e,vt)?e._.selectedFields:ce(e,$n)?e[_t].selectedFields:e)[t];if(ce(i,Te.Aliased)){if(this.config.sqlAliasedBehavior==="sql"&&!i.isSelectionField)return i.sql;let n=i.clone();return n.isSelectionField=!0,n}if(ce(i,Te)){if(this.config.sqlBehavior==="sql")return i;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(ce(i,nt)){if(this.config.alias)return new Proxy(i,new vu(new Proxy(i.table,new Dp(this.config.alias,this.config.replaceOriginalName??!1))));return i}if(typeof i!=="object"||i===null)return i;return new Proxy(i,new bt(this.config))}}});var Mr;var lo=x(()=>{De();Mr=class Mr{static[J]="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 fO,E9;var pO=x(()=>{De();xu();fO=class fO{static[J]="SQLiteForeignKeyBuilder";reference;_onUpdate;_onDelete;constructor(e,t){if(this.reference=()=>{let{name:r,columns:i,foreignColumns:n}=e();return{name:r,columns:i,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 E9(e,this)}};E9=class E9{constructor(e,t){this.table=e,this.reference=t.reference,this.onUpdate=t._onUpdate,this.onDelete=t._onDelete}static[J]="SQLiteForeignKey";reference;onUpdate;onDelete;getName(){let{name:e,columns:t,foreignColumns:r}=this.reference(),i=t.map((s)=>s.name),n=r.map((s)=>s.name),o=[this.table[Er],...i,r[0].table[Er],...n];return e??`${o.join("_")}_fk`}}});function mO(e,t){return`${e[Er]}_${t.join("_")}_unique`}var I9,tke,A9;var hO=x(()=>{De();xu();I9=class I9{constructor(e,t){this.name=t,this.columns=e}static[J]="SQLiteUniqueConstraintBuilder";columns;build(e){return new A9(e,this.columns,this.name)}};tke=class tke{static[J]="SQLiteUniqueOnConstraintBuilder";name;constructor(e){this.name=e}on(...e){return new I9(e,this.name)}};A9=class A9{constructor(e,t,r){this.table=e,this.columns=t,this.name=r??mO(this.table,this.columns.map((i)=>i.name))}static[J]="SQLiteUniqueConstraint";columns;name;getName(){return this.name}}});var Xt,At;var $s=x(()=>{cx();Wn();De();pO();hO();Xt=class Xt extends Ap{static[J]="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:i})=>((n,o)=>{let s=new fO(()=>{let a=n();return{columns:[e],foreignColumns:[a]}});if(o.onUpdate)s.onUpdate(o.onUpdate);if(o.onDelete)s.onDelete(o.onDelete);return s.build(t)})(r,i))}};At=class At extends nt{constructor(e,t){if(!t.uniqueName)t.uniqueName=mO(e,[t.name]);super(e,t);this.table=e}static[J]="SQLiteColumn"}});function z9(e,t){let{name:r,config:i}=_i(e,t);if(i?.mode==="json")return new $9(r);if(i?.mode==="bigint")return new T9(r);return new R9(r)}var T9,C9,$9,O9,R9,P9;var gO=x(()=>{De();Ur();$s();T9=class T9 extends Xt{static[J]="SQLiteBigIntBuilder";constructor(e){super(e,"bigint","SQLiteBigInt")}build(e){return new C9(e,this.config)}};C9=class C9 extends At{static[J]="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(iO.decode(e))}mapToDriverValue(e){return Buffer.from(e.toString())}};$9=class $9 extends Xt{static[J]="SQLiteBlobJsonBuilder";constructor(e){super(e,"json","SQLiteBlobJson")}build(e){return new O9(e,this.config)}};O9=class O9 extends At{static[J]="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(iO.decode(e))}mapToDriverValue(e){return Buffer.from(JSON.stringify(e))}};R9=class R9 extends Xt{static[J]="SQLiteBlobBufferBuilder";constructor(e){super(e,"buffer","SQLiteBlobBuffer")}build(e){return new P9(e,this.config)}};P9=class P9 extends At{static[J]="SQLiteBlobBuffer";mapFromDriverValue(e){if(Buffer.isBuffer(e))return e;return Buffer.from(e)}getSQLType(){return"blob"}}});function L9(e){return(t,r)=>{let{name:i,config:n}=_i(t,r);return new N9(i,n,e)}}var N9,D9;var yO=x(()=>{De();Ur();$s();N9=class N9 extends Xt{static[J]="SQLiteCustomColumnBuilder";constructor(e,t,r){super(e,"custom","SQLiteCustomColumn");this.config.fieldConfig=t,this.config.customTypeParams=r}build(e){return new D9(e,this.config)}};D9=class D9 extends At{static[J]="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:i}=_i(e,t);if(i?.mode==="timestamp"||i?.mode==="timestamp_ms")return new q9(r,i.mode);if(i?.mode==="boolean")return new M9(r,i.mode);return new B9(r)}var wx,vx,B9,j9,q9,U9,M9,F9;var bO=x(()=>{De();pr();Ur();$s();wx=class wx extends Xt{static[J]="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()}};vx=class vx extends At{static[J]="SQLiteBaseInteger";autoIncrement=this.config.autoIncrement;getSQLType(){return"integer"}};B9=class B9 extends wx{static[J]="SQLiteIntegerBuilder";constructor(e){super(e,"number","SQLiteInteger")}build(e){return new j9(e,this.config)}};j9=class j9 extends vx{static[J]="SQLiteInteger"};q9=class q9 extends wx{static[J]="SQLiteTimestampBuilder";constructor(e,t){super(e,"date","SQLiteTimestamp");this.config.mode=t}defaultNow(){return this.default(q`(cast((julianday('now') - 2440587.5)*86400000 as integer))`)}build(e){return new U9(e,this.config)}};U9=class U9 extends vx{static[J]="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}};M9=class M9 extends wx{static[J]="SQLiteBooleanBuilder";constructor(e,t){super(e,"boolean","SQLiteBoolean");this.config.mode=t}build(e){return new F9(e,this.config)}};F9=class F9 extends vx{static[J]="SQLiteBoolean";mode=this.config.mode;mapFromDriverValue(e){return Number(e)===1}mapToDriverValue(e){return e?1:0}}});function G9(e,t){let{name:r,config:i}=_i(e,t),n=i?.mode;return n==="number"?new K9(r):n==="bigint"?new V9(r):new Z9(r)}var Z9,H9,K9,J9,V9,W9;var xO=x(()=>{De();Ur();$s();Z9=class Z9 extends Xt{static[J]="SQLiteNumericBuilder";constructor(e){super(e,"string","SQLiteNumeric")}build(e){return new H9(e,this.config)}};H9=class H9 extends At{static[J]="SQLiteNumeric";mapFromDriverValue(e){if(typeof e==="string")return e;return String(e)}getSQLType(){return"numeric"}};K9=class K9 extends Xt{static[J]="SQLiteNumericNumberBuilder";constructor(e){super(e,"number","SQLiteNumericNumber")}build(e){return new J9(e,this.config)}};J9=class J9 extends At{static[J]="SQLiteNumericNumber";mapFromDriverValue(e){if(typeof e==="number")return e;return Number(e)}mapToDriverValue=String;getSQLType(){return"numeric"}};V9=class V9 extends Xt{static[J]="SQLiteNumericBigIntBuilder";constructor(e){super(e,"bigint","SQLiteNumericBigInt")}build(e){return new W9(e,this.config)}};W9=class W9 extends At{static[J]="SQLiteNumericBigInt";mapFromDriverValue=BigInt;mapToDriverValue=String;getSQLType(){return"numeric"}}});function X9(e){return new Q9(e??"")}var Q9,Y9;var SO=x(()=>{De();$s();Q9=class Q9 extends Xt{static[J]="SQLiteRealBuilder";constructor(e){super(e,"number","SQLiteReal")}build(e){return new Y9(e,this.config)}};Y9=class Y9 extends At{static[J]="SQLiteReal";getSQLType(){return"real"}}});function mr(e,t={}){let{name:r,config:i}=_i(e,t);if(i.mode==="json")return new rV(r);return new eV(r,i)}var eV,tV,rV,nV;var wO=x(()=>{De();Ur();$s();eV=class eV extends Xt{static[J]="SQLiteTextBuilder";constructor(e,t){super(e,"string","SQLiteText");this.config.enumValues=t.enum,this.config.length=t.length}build(e){return new tV(e,this.config)}};tV=class tV extends At{static[J]="SQLiteText";enumValues=this.config.enumValues;length=this.config.length;constructor(e,t){super(e,t)}getSQLType(){return`text${this.config.length?`(${this.config.length})`:""}`}};rV=class rV extends Xt{static[J]="SQLiteTextJsonBuilder";constructor(e){super(e,"json","SQLiteTextJson")}build(e){return new nV(e,this.config)}};nV=class nV extends At{static[J]="SQLiteTextJson";getSQLType(){return"text"}mapFromDriverValue(e){return JSON.parse(e)}mapToDriverValue(e){return JSON.stringify(e)}}});function iV(){return{blob:z9,customType:L9,integer:Ar,numeric:G9,real:X9,text:mr}}var oV=x(()=>{gO();yO();bO();xO();SO();wO()});function rke(e,t,r,i,n=e){let o=new Mt(e,i,n),s=typeof t==="function"?t(iV()):t,a=Object.fromEntries(Object.entries(s).map(([l,u])=>{let d=u;d.setName(l);let p=d.build(o);return o[vO].push(...d.buildForeignKeys(p,o)),[l,p]})),c=Object.assign(o,a);if(c[we.Symbol.Columns]=a,c[we.Symbol.ExtraConfigColumns]=a,r)c[Mt.Symbol.ExtraConfigBuilder]=r;return c}var vO,Mt,jp=(e,t,r)=>rke(e,t,r);var uo=x(()=>{De();Ir();oV();vO=Symbol.for("drizzle:SQLiteInlineForeignKeys");Mt=class Mt extends we{static[J]="SQLiteTable";static Symbol=Object.assign({},we.Symbol,{InlineForeignKeys:vO});[we.Symbol.Columns];[vO]=[];[we.Symbol.ExtraConfigBuilder]=void 0}});var nke,sV;var aV=x(()=>{De();nke=class nke{constructor(e,t){this.name=e,this.value=t}static[J]="SQLiteCheckBuilder";brand;build(e){return new sV(e,this)}};sV=class sV{constructor(e,t){this.table=e,this.name=t.name,this.value=t.value}static[J]="SQLiteCheck";name;value}});function Wa(e){return new cV(e,!1)}var cV,lV,uV;var dV=x(()=>{De();cV=class cV{constructor(e,t){this.name=e,this.unique=t}static[J]="SQLiteIndexBuilderOn";on(...e){return new lV(this.name,e,this.unique)}};lV=class lV{static[J]="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 uV(this.config,e)}};uV=class uV{static[J]="SQLiteIndex";config;constructor(e,t){this.config={...e,table:t}}}});var ike,fV;var pV=x(()=>{De();uo();ike=class ike{static[J]="SQLitePrimaryKeyBuilder";columns;name;constructor(e,t){this.columns=e,this.name=t}build(e){return new fV(e,this.columns,this.name)}};fV=class fV{constructor(e,t,r){this.table=e,this.columns=t,this.name=r}static[J]="SQLitePrimaryKey";columns;name;getName(){return this.name??`${this.table[Mt.Symbol.Name]}_${this.columns.map((e)=>e.name).join("_")}_pk`}}});function Qn(e){if(ce(e,Mt))return[`${e[we.Symbol.BaseName]}`];if(ce(e,vt))return e._.usedTables??[];if(ce(e,Te))return e.usedTables??[];return[]}var _u=x(()=>{De();pr();Gn();Ir();uo()});var _x;var mV=x(()=>{De();lo();Va();uo();Ir();Ur();_u();_x=class _x extends Mr{constructor(e,t,r,i){super();this.table=e,this.session=t,this.dialect=r,this.config={table:e,withList:i}}static[J]="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[we.Symbol.Columns],new bt({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[Mt.Symbol.Columns]){return this.config.returning=On(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:Qn(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 oke(e){return(e.replace(/['\u2019]/g,"").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).map((r)=>r.toLowerCase()).join("_")}function ske(e){return(e.replace(/['\u2019]/g,"").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).reduce((r,i,n)=>{let o=n===0?i.toLowerCase():`${i[0].toUpperCase()}${i.slice(1)}`;return r+o},"")}function ake(e){return e}var _O;var hV=x(()=>{De();Ir();_O=class _O{static[J]="CasingCache";cache={};cachedTables={};convert;constructor(e){this.convert=e==="snake_case"?oke:e==="camelCase"?ske:ake}getColumnCasing(e){if(!e.keyAsName)return e.name;let t=e.table[we.Symbol.Schema]??"public",r=e.table[we.Symbol.OriginalName],i=`${t}.${r}.${e.name}`;if(!this.cache[i])this.cacheTable(e.table);return this.cache[i]}cacheTable(e){let t=e[we.Symbol.Schema]??"public",r=e[we.Symbol.OriginalName],i=`${t}.${r}`;if(!this.cachedTables[i]){for(let n of Object.values(e[we.Symbol.Columns])){let o=`${i}.${n.name}`;this.cache[o]=this.convert(n.name)}this.cachedTables[i]=!0}}clearCache(){this.cache={},this.cachedTables={}}}});var ku,fo,kO;var kx=x(()=>{De();ku=class ku extends Error{static[J]="DrizzleError";constructor({message:e,cause:t}){super(e);this.name="DrizzleError",this.cause=t}};fo=class fo extends Error{constructor(e,t,r){super(`Failed query: ${e}
454
453
  params: ${t}`);if(this.query=e,this.params=t,this.cause=r,Error.captureStackTrace(this,fo),r)this.cause=r}};kO=class kO extends ku{static[J]="TransactionRollbackError";constructor(){super({message:"Rollback"})}}});var gV=()=>{};var yV=()=>{};var bV=x(()=>{gV();yV()});var EO=x(()=>{lO();bV();pr()});var IO=x(()=>{gO();$s();yO();bO();xO();SO();wO()});var po;var qp=x(()=>{De();pr();po=class po extends $n{static[J]="SQLiteViewBase"}});var Eu,AO,TO;var Ex=x(()=>{Sx();hV();Wn();De();kx();Np();EO();pr();IO();uo();Gn();Ir();Ur();so();qp();Eu=class Eu{static[J]="SQLiteDialect";casing;constructor(e){this.casing=new _O(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=[q`with `];for(let[r,i]of e.entries())if(t.push(q`${q.identifier(i._.alias)} as (${i._.sql})`),r<e.length-1)t.push(q`, `);return t.push(q` `),q.join(t)}buildDeleteQuery({table:e,where:t,returning:r,withList:i,limit:n,orderBy:o}){let s=this.buildWithCTE(i),a=r?q` returning ${this.buildSelection(r,{isSingleTable:!0})}`:void 0,c=t?q` where ${t}`:void 0,l=this.buildOrderBy(o),u=this.buildLimit(n);return q`${s}delete from ${e}${c}${a}${l}${u}`}buildUpdateSet(e,t){let r=e[we.Symbol.Columns],i=Object.keys(r).filter((o)=>t[o]!==void 0||r[o]?.onUpdateFn!==void 0),n=i.length;return q.join(i.flatMap((o,s)=>{let a=r[o],c=a.onUpdateFn?.(),l=t[o]??(ce(c,Te)?c:q.param(c,a)),u=q`${q.identifier(this.casing.getColumnCasing(a))} = ${l}`;if(s<n-1)return[u,q.raw(", ")];return[u]}))}buildUpdateQuery({table:e,set:t,where:r,returning:i,withList:n,joins:o,from:s,limit:a,orderBy:c}){let l=this.buildWithCTE(n),u=this.buildUpdateSet(e,t),d=s&&q.join([q.raw(" from "),this.buildFromTable(s)]),p=this.buildJoins(o),m=i?q` returning ${this.buildSelection(i,{isSingleTable:!0})}`:void 0,y=r?q` where ${r}`:void 0,g=this.buildOrderBy(c),b=this.buildLimit(a);return q`${l}update ${e} set ${u}${d}${p}${y}${m}${g}${b}`}buildSelection(e,{isSingleTable:t=!1}={}){let r=e.length,i=e.flatMap(({field:n},o)=>{let s=[];if(ce(n,Te.Aliased)&&n.isSelectionField)s.push(q.identifier(n.fieldAlias));else if(ce(n,Te.Aliased)||ce(n,Te)){let a=ce(n,Te.Aliased)?n.sql:n;if(t)s.push(new Te(a.queryChunks.map((c)=>{if(ce(c,nt))return q.identifier(this.casing.getColumnCasing(c));return c})));else s.push(a);if(ce(n,Te.Aliased))s.push(q` as ${q.identifier(n.fieldAlias)}`)}else if(ce(n,nt)){let a=n.table[we.Symbol.Name];if(n.columnType==="SQLiteNumericBigInt")if(t)s.push(q`cast(${q.identifier(this.casing.getColumnCasing(n))} as text)`);else s.push(q`cast(${q.identifier(a)}.${q.identifier(this.casing.getColumnCasing(n))} as text)`);else if(t)s.push(q.identifier(this.casing.getColumnCasing(n)));else s.push(q`${q.identifier(a)}.${q.identifier(this.casing.getColumnCasing(n))}`)}else if(ce(n,vt)){let a=Object.entries(n._.selectedFields);if(a.length===1){let c=a[0][1],l=ce(c,Te)?c.decoder:ce(c,nt)?{mapFromDriverValue:(u)=>c.mapFromDriverValue(u)}:c.sql.decoder;if(l)n._.sql.decoder=l}s.push(n)}if(o<r-1)s.push(q`, `);return s});return q.join(i)}buildJoins(e){if(!e||e.length===0)return;let t=[];if(e)for(let[r,i]of e.entries()){if(r===0)t.push(q` `);let n=i.table,o=i.on?q` on ${i.on}`:void 0;if(ce(n,Mt)){let s=n[Mt.Symbol.Name],a=n[Mt.Symbol.Schema],c=n[Mt.Symbol.OriginalName],l=s===c?void 0:i.alias;t.push(q`${q.raw(i.joinType)} join ${a?q`${q.identifier(a)}.`:void 0}${q.identifier(c)}${l&&q` ${q.identifier(l)}`}${o}`)}else t.push(q`${q.raw(i.joinType)} join ${n}${o}`);if(r<e.length-1)t.push(q` `)}return q.join(t)}buildLimit(e){return typeof e==="object"||typeof e==="number"&&e>=0?q` limit ${e}`:void 0}buildOrderBy(e){let t=[];if(e){for(let[r,i]of e.entries())if(t.push(i),r<e.length-1)t.push(q`, `)}return t.length>0?q` order by ${q.join(t)}`:void 0}buildFromTable(e){if(ce(e,we)&&e[we.Symbol.IsAlias])return q`${q`${q.identifier(e[we.Symbol.Schema]??"")}.`.if(e[we.Symbol.Schema])}${q.identifier(e[we.Symbol.OriginalName])} ${q.identifier(e[we.Symbol.Name])}`;return e}buildSelectQuery({withList:e,fields:t,fieldsFlat:r,where:i,having:n,table:o,joins:s,orderBy:a,groupBy:c,limit:l,offset:u,distinct:d,setOperators:p}){let m=r??On(t);for(let P of m)if(ce(P.field,nt)&&Is(P.field.table)!==(ce(o,vt)?o._.alias:ce(o,po)?o[_t].name:ce(o,Te)?void 0:Is(o))&&!((N)=>s?.some(({alias:I})=>I===(N[we.Symbol.IsAlias]?Is(N):N[we.Symbol.BaseName])))(P.field.table)){let N=Is(P.field.table);throw Error(`Your "${P.path.join("->")}" field references a column "${N}"."${P.field.name}", but the table "${N}" is not part of the query! Did you forget to join it?`)}let y=!s||s.length===0,g=this.buildWithCTE(e),b=d?q` distinct`:void 0,v=this.buildSelection(m,{isSingleTable:y}),A=this.buildFromTable(o),T=this.buildJoins(s),z=i?q` where ${i}`:void 0,j=n?q` having ${n}`:void 0,E=[];if(c){for(let[P,N]of c.entries())if(E.push(N),P<c.length-1)E.push(q`, `)}let Z=E.length>0?q` group by ${q.join(E)}`:void 0,D=this.buildOrderBy(a),H=this.buildLimit(l),X=u?q` offset ${u}`:void 0,M=q`${g}select${b} ${v} from ${A}${T}${z}${Z}${j}${D}${H}${X}`;if(p.length>0)return this.buildSetOperations(M,p);return M}buildSetOperations(e,t){let[r,...i]=t;if(!r)throw Error("Cannot pass undefined values to any set operator");if(i.length===0)return this.buildSetOperationQuery({leftSelect:e,setOperator:r});return this.buildSetOperations(this.buildSetOperationQuery({leftSelect:e,setOperator:r}),i)}buildSetOperationQuery({leftSelect:e,setOperator:{type:t,isAll:r,rightSelect:i,limit:n,orderBy:o,offset:s}}){let a=q`${e.getSQL()} `,c=q`${i.getSQL()}`,l;if(o&&o.length>0){let m=[];for(let y of o)if(ce(y,At))m.push(q.identifier(y.name));else if(ce(y,Te)){for(let g=0;g<y.queryChunks.length;g++){let b=y.queryChunks[g];if(ce(b,At))y.queryChunks[g]=q.identifier(this.casing.getColumnCasing(b))}m.push(q`${y}`)}else m.push(q`${y}`);l=q` order by ${q.join(m,q`, `)}`}let u=typeof n==="object"||typeof n==="number"&&n>=0?q` limit ${n}`:void 0,d=q.raw(`${t} ${r?"all ":""}`),p=s?q` offset ${s}`:void 0;return q`${a}${d}${c}${l}${u}${p}`}buildInsertQuery({table:e,values:t,onConflict:r,returning:i,withList:n,select:o}){let s=[],a=e[we.Symbol.Columns],c=Object.entries(a).filter(([y,g])=>!g.shouldDisableInsert()),l=c.map(([,y])=>q.identifier(this.casing.getColumnCasing(y)));if(o){let y=t;if(ce(y,Te))s.push(y);else s.push(y.getSQL())}else{let y=t;s.push(q.raw("values "));for(let[g,b]of y.entries()){let v=[];for(let[A,T]of c){let z=b[A];if(z===void 0||ce(z,mn)&&z.value===void 0){let j;if(T.default!==null&&T.default!==void 0)j=ce(T.default,Te)?T.default:q.param(T.default,T);else if(T.defaultFn!==void 0){let E=T.defaultFn();j=ce(E,Te)?E:q.param(E,T)}else if(!T.default&&T.onUpdateFn!==void 0){let E=T.onUpdateFn();j=ce(E,Te)?E:q.param(E,T)}else j=q`null`;v.push(j)}else v.push(z)}if(s.push(v),g<y.length-1)s.push(q`, `)}}let u=this.buildWithCTE(n),d=q.join(s),p=i?q` returning ${this.buildSelection(i,{isSingleTable:!0})}`:void 0,m=r?.length?q.join(r):void 0;return q`${u}insert into ${e} ${l} ${d}${m}${p}`}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:i,tableConfig:n,queryConfig:o,tableAlias:s,nestedQueryRelation:a,joinOn:c}){let l=[],u,d,p=[],m,y=[];if(o===!0)l=Object.entries(n.columns).map(([v,A])=>({dbKey:A.name,tsKey:v,field:ki(A,s),relationTableTsKey:void 0,isJson:!1,selection:[]}));else{let b=Object.fromEntries(Object.entries(n.columns).map(([E,Z])=>[E,ki(Z,s)]));if(o.where){let E=typeof o.where==="function"?o.where(b,S9()):o.where;m=E&&Bp(E,s)}let v=[],A=[];if(o.columns){let E=!1;for(let[Z,D]of Object.entries(o.columns)){if(D===void 0)continue;if(Z in n.columns){if(!E&&D===!0)E=!0;A.push(Z)}}if(A.length>0)A=E?A.filter((Z)=>o.columns?.[Z]===!0):Object.keys(n.columns).filter((Z)=>!A.includes(Z))}else A=Object.keys(n.columns);for(let E of A){let Z=n.columns[E];v.push({tsKey:E,value:Z})}let T=[];if(o.with)T=Object.entries(o.with).filter((E)=>!!E[1]).map(([E,Z])=>({tsKey:E,queryConfig:Z,relation:n.relations[E]}));let z;if(o.extras){z=typeof o.extras==="function"?o.extras(b,{sql:q}):o.extras;for(let[E,Z]of Object.entries(z))v.push({tsKey:E,value:dO(Z,s)})}for(let{tsKey:E,value:Z}of v)l.push({dbKey:ce(Z,Te.Aliased)?Z.fieldAlias:n.columns[E].name,tsKey:E,field:ce(Z,nt)?ki(Z,s):Z,relationTableTsKey:void 0,isJson:!1,selection:[]});let j=typeof o.orderBy==="function"?o.orderBy(b,w9()):o.orderBy??[];if(!Array.isArray(j))j=[j];p=j.map((E)=>{if(ce(E,nt))return ki(E,s);return Bp(E,s)}),u=o.limit,d=o.offset;for(let{tsKey:E,queryConfig:Z,relation:D}of T){let H=_9(t,r,D),X=Ka(D.referencedTable),M=r[X],P=`${s}_${E}`,N=Nt(...H.fields.map((O,F)=>et(ki(H.references[F],P),ki(O,s)))),I=this.buildRelationalQuery({fullSchema:e,schema:t,tableNamesMap:r,table:e[M],tableConfig:t[M],queryConfig:ce(D,Cs)?Z===!0?{limit:1}:{...Z,limit:1}:Z,tableAlias:P,joinOn:N,nestedQueryRelation:D}),R=q`(${I.sql})`.as(E);l.push({dbKey:E,tsKey:E,field:R,relationTableTsKey:M,isJson:!0,selection:I.selection})}}if(l.length===0)throw new ku({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 g;if(m=Nt(c,m),a){let b=q`json_array(${q.join(l.map(({field:T})=>ce(T,At)?q.identifier(this.casing.getColumnCasing(T)):ce(T,Te.Aliased)?T.sql:T),q`, `)})`;if(ce(a,zp))b=q`coalesce(json_group_array(${b}), json_array())`;let v=[{dbKey:"data",tsKey:"data",field:b.as("data"),isJson:!0,relationTableTsKey:n.tsName,selection:l}];if(u!==void 0||d!==void 0||p.length>0)g=this.buildSelectQuery({table:Lp(i,s),fields:{},fieldsFlat:[{path:[],field:q.raw("*")}],where:m,limit:u,offset:d,orderBy:p,setOperators:[]}),m=void 0,u=void 0,d=void 0,p=void 0;else g=Lp(i,s);g=this.buildSelectQuery({table:ce(g,Mt)?g:new vt(g,{},s),fields:{},fieldsFlat:v.map(({field:T})=>({path:[],field:ce(T,nt)?ki(T,s):T})),joins:y,where:m,limit:u,offset:d,orderBy:p,setOperators:[]})}else g=this.buildSelectQuery({table:Lp(i,s),fields:{},fieldsFlat:l.map(({field:b})=>({path:[],field:ce(b,nt)?ki(b,s):b})),joins:y,where:m,limit:u,offset:d,orderBy:p,setOperators:[]});return{tableTsKey:n.tsName,sql:g,selection:l}}};AO=class AO extends Eu{static[J]="SQLiteSyncDialect";migrate(e,t,r){let i=r===void 0?"__drizzle_migrations":typeof r==="string"?"__drizzle_migrations":r.migrationsTable??"__drizzle_migrations",n=q`
455
454
  CREATE TABLE IF NOT EXISTS ${q.identifier(i)} (
456
455
  id SERIAL PRIMARY KEY,
@@ -463,21 +462,21 @@ params: ${t}`);if(this.query=e,this.params=t,this.cause=r,Error.captureStackTrac
463
462
  hash text NOT NULL,
464
463
  created_at numeric
465
464
  )
466
- `;await t.run(n);let s=(await t.values(q`SELECT id, hash, created_at FROM ${q.identifier(i)} 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 l of c.sql)await a.run(q.raw(l));await a.run(q`INSERT INTO ${q.identifier(i)} ("hash", "created_at") VALUES(${c.hash}, ${c.folderMillis})`)}})}}});var CO;var xV=x(()=>{De();CO=class CO{static[J]="TypedQueryBuilder";getSelectedFields(){return this._.selectedFields}}});function Ix(e,t){return(r,i,...n)=>{let o=[i,...n].map((s)=>({type:e,isAll:t,rightSelect:s}));for(let s of o)if(!Rp(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(o)}}var Yn,SV,$O,lke=()=>({union:uke,unionAll:dke,intersect:fke,except:pke}),uke,dke,fke,pke;var OO=x(()=>{De();xV();lo();Va();pr();Gn();Ir();Ur();so();_u();qp();Yn=class Yn{static[J]="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(ce(e,vt))r=Object.fromEntries(Object.keys(e._.selectedFields).map((i)=>[i,e[i]]));else if(ce(e,po))r=e[_t].selectedFields;else if(ce(e,Te))r={};else r=mx(e);return new $O({table:e,fields:r,isPartialSelect:t,session:this.session,dialect:this.dialect,withList:this.withList,distinct:this.distinct})}};SV=class SV extends CO{static[J]="SQLiteSelectQueryBuilder";_;config;joinsNotNullableMap;tableName;isPartialSelect;session;dialect;cacheConfig=void 0;usedTables=new Set;constructor({table:e,fields:t,isPartialSelect:r,session:i,dialect:n,withList:o,distinct:s}){super();this.config={withList:o,table:e,fields:{...t},distinct:s,setOperators:[]},this.isPartialSelect=r,this.session=i,this.dialect=n,this._={selectedFields:t,config:this.config},this.tableName=Pp(e),this.joinsNotNullableMap=typeof this.tableName==="string"?{[this.tableName]:!0}:{};for(let a of Qn(e))this.usedTables.add(a)}getUsedTables(){return[...this.usedTables]}createJoin(e){return(t,r)=>{let i=this.tableName,n=Pp(t);for(let o of Qn(t))this.usedTables.add(o);if(typeof n==="string"&&this.config.joins?.some((o)=>o.alias===n))throw Error(`Alias "${n}" is already used in this query`);if(!this.isPartialSelect){if(Object.keys(this.joinsNotNullableMap).length===1&&typeof i==="string")this.config.fields={[i]:this.config.fields};if(typeof n==="string"&&!ce(t,Te)){let o=ce(t,vt)?t._.selectedFields:ce(t,$n)?t[_t].selectedFields:t[we.Symbol.Columns];this.config.fields[n]=o}}if(typeof r==="function")r=r(new Proxy(this.config.fields,new bt({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(([o])=>[o,!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(([o])=>[o,!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 i=typeof r==="function"?r(lke()):r;if(!Rp(this.getSelectedFields(),i.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:i}),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 bt({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})));return this.config.where=e,this}having(e){if(typeof e==="function")e=e(new Proxy(this.config.fields,new bt({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 bt({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 bt({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(...Qn(this.config.table)),this.config.joins)for(let r of this.config.joins)t.push(...Qn(r.table));return new Proxy(new vt(this.getSQL(),this.config.fields,e,!1,[...new Set(t)]),new bt({alias:e,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}getSelectedFields(){return new Proxy(this.config.fields,new bt({alias:this.tableName,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}$dynamic(){return this}};$O=class $O extends SV{static[J]="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=On(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()}};QJ($O,[Mr]);uke=Ix("union",!1),dke=Ix("union",!0),fke=Ix("intersect",!1),pke=Ix("except",!1)});var Ga;var Ax=x(()=>{De();Va();Ex();Gn();OO();Ga=class Ga{static[J]="SQLiteQueryBuilder";dialect;dialectConfig;constructor(e){this.dialect=ce(e,Eu)?e:void 0,this.dialectConfig=ce(e,Eu)?void 0:e}$with=(e,t)=>{let r=this;return{as:(n)=>{if(typeof n==="function")n=n(r);return new Proxy(new Cp(n.getSQL(),t??("getSelectedFields"in n?n.getSelectedFields()??{}:{}),e,!0),new bt({alias:e,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}}};with(...e){let t=this;function r(n){return new Yn({fields:n??void 0,session:void 0,dialect:t.getDialect(),withList:e})}function i(n){return new Yn({fields:n??void 0,session:void 0,dialect:t.getDialect(),withList:e,distinct:!0})}return{select:r,selectDistinct:i}}select(e){return new Yn({fields:e??void 0,session:void 0,dialect:this.getDialect()})}selectDistinct(e){return new Yn({fields:e??void 0,session:void 0,dialect:this.getDialect(),distinct:!0})}getDialect(){if(!this.dialect)this.dialect=new AO(this.dialectConfig);return this.dialect}}});var Tx,RO;var wV=x(()=>{De();lo();pr();uo();Ir();Ur();_u();Ax();Tx=class Tx{constructor(e,t,r,i){this.table=e,this.session=t,this.dialect=r,this.withList=i}static[J]="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 i={},n=this.table[we.Symbol.Columns];for(let o of Object.keys(r)){let s=r[o];i[o]=ce(s,Te)?s:new mn(s,n[o])}return i});return new RO(this.table,t,this.session,this.dialect,this.withList)}select(e){let t=typeof e==="function"?e(new Ga):e;if(!ce(t,Te)&&!Rp(this.table[dx],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 RO(this.table,t,this.session,this.dialect,this.withList,!0)}};RO=class RO extends Mr{constructor(e,t,r,i,n,o){super();this.session=r,this.dialect=i,this.config={table:e,values:t,withList:n,select:o}}static[J]="SQLiteInsert";config;returning(e=this.config.table[Mt.Symbol.Columns]){return this.config.returning=On(e),this}onConflictDoNothing(e={}){if(!this.config.onConflict)this.config.onConflict=[];if(e.target===void 0)this.config.onConflict.push(q` on conflict do nothing`);else{let t=Array.isArray(e.target)?q`${e.target}`:q`${[e.target]}`,r=e.where?q` where ${e.where}`:q``;this.config.onConflict.push(q` 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?q` where ${e.where}`:void 0,r=e.targetWhere?q` where ${e.targetWhere}`:void 0,i=e.setWhere?q` where ${e.setWhere}`:void 0,n=Array.isArray(e.target)?q`${e.target}`:q`${[e.target]}`,o=this.dialect.buildUpdateSet(this.config.table,px(this.config.table,e.set));return this.config.onConflict.push(q` on conflict ${n}${r} do update set ${o}${t}${i}`),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:Qn(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 Cx,vV;var _V=x(()=>{De();lo();Va();uo();Gn();Ir();Ur();so();_u();qp();Cx=class Cx{constructor(e,t,r,i){this.table=e,this.session=t,this.dialect=r,this.withList=i}static[J]="SQLiteUpdateBuilder";set(e){return new vV(this.table,px(this.table,e),this.session,this.dialect,this.withList)}};vV=class vV extends Mr{constructor(e,t,r,i,n){super();this.session=r,this.dialect=i,this.config={set:t,table:e,withList:n,joins:[]}}static[J]="SQLiteUpdate";config;from(e){return this.config.from=e,this}createJoin(e){return(t,r)=>{let i=Pp(t);if(typeof i==="string"&&this.config.joins.some((n)=>n.alias===i))throw Error(`Alias "${i}" is already used in this query`);if(typeof r==="function"){let n=this.config.from?ce(t,Mt)?t[we.Symbol.Columns]:ce(t,vt)?t._.selectedFields:ce(t,po)?t[_t].selectedFields:void 0:void 0;r=r(new Proxy(this.config.table[we.Symbol.Columns],new bt({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})),n&&new Proxy(n,new bt({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))}return this.config.joins.push({on:r,table:t,joinType:e,alias:i}),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[we.Symbol.Columns],new bt({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[Mt.Symbol.Columns]){return this.config.returning=On(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:Qn(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 PO=x(()=>{mV();wV();Ax();OO();_V()});var Up;var kV=x(()=>{De();pr();Up=class Up extends Te{constructor(e){super(Up.buildEmbeddedCount(e.source,e.filters).queryChunks);this.params=e,this.session=e.session,this.sql=Up.buildCount(e.source,e.filters)}sql;static[J]="SQLiteCountBuilderAsync";[Symbol.toStringTag]="SQLiteCountBuilderAsync";session;static buildEmbeddedCount(e,t){return q`(select count(*) from ${e}${q.raw(" where ").if(t)}${t})`}static buildCount(e,t){return q`select count(*) from ${e}${q.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 NO,$x,zO;var EV=x(()=>{De();lo();Np();NO=class NO{constructor(e,t,r,i,n,o,s,a){this.mode=e,this.fullSchema=t,this.schema=r,this.tableNamesMap=i,this.table=n,this.tableConfig=o,this.dialect=s,this.session=a}static[J]="SQLiteAsyncRelationalQueryBuilder";findMany(e){return this.mode==="sync"?new zO(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e?e:{},"many"):new $x(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e?e:{},"many")}findFirst(e){return this.mode==="sync"?new zO(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e?{...e,limit:1}:{limit:1},"first"):new $x(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e?{...e,limit:1}:{limit:1},"first")}};$x=class $x extends Mr{constructor(e,t,r,i,n,o,s,a,c){super();this.fullSchema=e,this.schema=t,this.tableNamesMap=r,this.table=i,this.tableConfig=n,this.dialect=o,this.session=s,this.config=a,this.mode=c}static[J]="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,(i,n)=>{let o=i.map((s)=>xx(this.schema,this.tableConfig,s,t.selection,n));if(this.mode==="first")return o[0];return o})}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()}};zO=class zO extends $x{static[J]="SQLiteSyncRelationalQuery";sync(){return this.executeRaw()}}});var Iu;var IV=x(()=>{De();lo();Iu=class Iu extends Mr{constructor(e,t,r,i,n){super();this.execute=e,this.getSQL=t,this.dialect=i,this.mapBatchResult=n,this.config={action:r}}static[J]="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 Mp;var Ox=x(()=>{De();Va();pr();PO();Gn();kV();EV();IV();Mp=class Mp{constructor(e,t,r,i){this.resultKind=e,this.dialect=t,this.session=r,this._=i?{schema:i.schema,fullSchema:i.fullSchema,tableNamesMap:i.tableNamesMap}:{schema:void 0,fullSchema:{},tableNamesMap:{}},this.query={};let n=this.query;if(this._.schema)for(let[o,s]of Object.entries(this._.schema))n[o]=new NO(e,i.fullSchema,this._.schema,this._.tableNamesMap,i.fullSchema[o],s,t,r);this.$cache={invalidate:async(o)=>{}}}static[J]="BaseSQLiteDatabase";query;$with=(e,t)=>{let r=this;return{as:(n)=>{if(typeof n==="function")n=n(new Ga(r.dialect));return new Proxy(new Cp(n.getSQL(),t??("getSelectedFields"in n?n.getSelectedFields()??{}:{}),e,!0),new bt({alias:e,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}}};$count(e,t){return new Up({source:e,filters:t,session:this.session})}with(...e){let t=this;function r(a){return new Yn({fields:a??void 0,session:t.session,dialect:t.dialect,withList:e})}function i(a){return new Yn({fields:a??void 0,session:t.session,dialect:t.dialect,withList:e,distinct:!0})}function n(a){return new Cx(a,t.session,t.dialect,e)}function o(a){return new Tx(a,t.session,t.dialect,e)}function s(a){return new _x(a,t.session,t.dialect,e)}return{select:r,selectDistinct:i,update:n,insert:o,delete:s}}select(e){return new Yn({fields:e??void 0,session:this.session,dialect:this.dialect})}selectDistinct(e){return new Yn({fields:e??void 0,session:this.session,dialect:this.dialect,distinct:!0})}update(e){return new Cx(e,this.session,this.dialect)}$cache;insert(e){return new Tx(e,this.session,this.dialect)}delete(e){return new _x(e,this.session,this.dialect)}run(e){let t=typeof e==="string"?q.raw(e):e.getSQL();if(this.resultKind==="async")return new Iu(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"?q.raw(e):e.getSQL();if(this.resultKind==="async")return new Iu(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"?q.raw(e):e.getSQL();if(this.resultKind==="async")return new Iu(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"?q.raw(e):e.getSQL();if(this.resultKind==="async")return new Iu(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 DO(e,t){let r=`${e}-${JSON.stringify(t)}`,n=new TextEncoder().encode(r),o=await crypto.subtle.digest("SHA-256",n);return[...new Uint8Array(o)].map((c)=>c.toString(16).padStart(2,"0")).join("")}var AV,Fp;var LO=x(()=>{De();AV=class AV{static[J]="Cache"};Fp=class Fp extends AV{strategy(){return"all"}static[J]="NoopCache";async get(e){return}async put(e,t,r,i){}async onMutate(e){}}});var TV=x(()=>{LO()});var CV=()=>{};var $V,BO,jO,qO;var UO=x(()=>{LO();De();kx();lo();Ox();$V=class $V extends Mr{constructor(e){super();this.resultCb=e}static[J]="ExecuteResultSync";async execute(){return this.resultCb()}sync(){return this.resultCb()}};BO=class BO{constructor(e,t,r,i,n,o){if(this.mode=e,this.executeMethod=t,this.query=r,this.cache=i,this.queryMetadata=n,this.cacheConfig=o,i&&i.strategy()==="all"&&o===void 0)this.cacheConfig={enable:!0,autoInvalidate:!0};if(!this.cacheConfig?.enable)this.cacheConfig=void 0}static[J]="PreparedQuery";joinsNotNullableMap;async queryWithCache(e,t,r){if(this.cache===void 0||ce(this.cache,Fp)||this.queryMetadata===void 0)try{return await r()}catch(i){throw new fo(e,t,i)}if(this.cacheConfig&&!this.cacheConfig.enable)try{return await r()}catch(i){throw new fo(e,t,i)}if((this.queryMetadata.type==="insert"||this.queryMetadata.type==="update"||this.queryMetadata.type==="delete")&&this.queryMetadata.tables.length>0)try{let[i]=await Promise.all([r(),this.cache.onMutate({tables:this.queryMetadata.tables})]);return i}catch(i){throw new fo(e,t,i)}if(!this.cacheConfig)try{return await r()}catch(i){throw new fo(e,t,i)}if(this.queryMetadata.type==="select"){let i=await this.cache.get(this.cacheConfig.tag??await DO(e,t),this.queryMetadata.tables,this.cacheConfig.tag!==void 0,this.cacheConfig.autoInvalidate);if(i===void 0){let n;try{n=await r()}catch(o){throw new fo(e,t,o)}return await this.cache.put(this.cacheConfig.tag??await DO(e,t),n,this.cacheConfig.autoInvalidate?this.queryMetadata.tables:[],this.cacheConfig.tag!==void 0,this.cacheConfig.config),n}return i}try{return await r()}catch(i){throw new fo(e,t,i)}}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 $V(()=>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)}}};jO=class jO{constructor(e){this.dialect=e}static[J]="SQLiteSession";prepareOneTimeQuery(e,t,r,i,n,o,s){return this.prepareQuery(e,t,r,i,n,o,s)}run(e){let t=this.dialect.sqlToQuery(e);try{return this.prepareOneTimeQuery(t,void 0,"run",!1).run()}catch(r){throw new ku({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")}};qO=class qO extends Mp{constructor(e,t,r,i,n=0){super(e,t,r,i);this.schema=i,this.nestedIndex=n}static[J]="SQLiteTransaction";rollback(){throw new kO}}});var MO,mke,hke,Rx;var OV=x(()=>{De();Va();Ur();Ax();uo();qp();MO=class MO{constructor(e){this.name=e}static[J]="SQLiteViewBuilderCore";config={}};mke=class mke extends MO{static[J]="SQLiteViewBuilder";as(e){if(typeof e==="function")e=e(new Ga);let t=new bt({alias:this.name,sqlBehavior:"error",sqlAliasedBehavior:"alias",replaceOriginalName:!0}),r=e.getSelectedFields();return new Proxy(new Rx({config:{name:this.name,schema:void 0,selectedFields:r,query:e.getSQL().inlineParams()}}),t)}};hke=class hke extends MO{static[J]="SQLiteManualViewBuilder";columns;constructor(e,t){super(e);this.columns=mx(jp(e,t))}existing(){return new Proxy(new Rx({config:{name:this.name,schema:void 0,selectedFields:this.columns,query:void 0}}),new bt({alias:this.name,sqlBehavior:"error",sqlAliasedBehavior:"alias",replaceOriginalName:!0}))}as(e){return new Proxy(new Rx({config:{name:this.name,schema:void 0,selectedFields:this.columns,query:e.inlineParams()}}),new bt({alias:this.name,sqlBehavior:"error",sqlAliasedBehavior:"alias",replaceOriginalName:!0}))}};Rx=class Rx extends po{static[J]="SQLiteView";constructor({config:e}){super(e)}}});var FO=x(()=>{CV();aV();IO();Ox();Ex();pO();dV();pV();PO();UO();uo();hO();_u();OV()});function RV(e){return Object.keys(e).reduce((t,r)=>{if(Object.prototype.propertyIsEnumerable.call(e,r))t[r]=e[r];return t},{})}function Px(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 zx,ZO,PV;var HO=x(()=>{TV();De();hx();pr();FO();UO();Ur();zx=class zx extends jO{constructor(e,t,r,i,n){super(t);this.client=e,this.schema=r,this.options=i,this.tx=n,this.logger=i.logger??new sO,this.cache=i.cache??new Fp}static[J]="LibSQLSession";logger;cache;prepareQuery(e,t,r,i,n,o,s){return new PV(this.client,e,this.logger,this.cache,o,s,t,this.tx,r,i,n)}async batch(e){let t=[],r=[];for(let n of e){let o=n._prepare(),s=o.getQuery();t.push(o),r.push({sql:s.sql,args:s.params})}return(await this.client.batch(r)).map((n,o)=>t[o].mapResult(n,!0))}async migrate(e){let t=[],r=[];for(let n of e){let o=n._prepare(),s=o.getQuery();t.push(o),r.push({sql:s.sql,args:s.params})}return(await this.client.migrate(r)).map((n,o)=>t[o].mapResult(n,!0))}async transaction(e,t){let r=await this.client.transaction(),i=new zx(this.client,this.dialect,this.schema,this.options,r),n=new ZO("async",this.dialect,i,this.schema);try{let o=await e(n);return await r.commit(),o}catch(o){throw await r.rollback(),o}}extractRawAllValueFromBatchResult(e){return e.rows}extractRawGetValueFromBatchResult(e){return e.rows[0]}extractRawValuesValueFromBatchResult(e){return e.rows}};ZO=class ZO extends qO{static[J]="LibSQLTransaction";async transaction(e){let t=`sp${this.nestedIndex}`,r=new ZO("async",this.dialect,this.session,this.schema,this.nestedIndex+1);await this.session.run(q.raw(`savepoint ${t}`));try{let i=await e(r);return await this.session.run(q.raw(`release savepoint ${t}`)),i}catch(i){throw await this.session.run(q.raw(`rollback to savepoint ${t}`)),i}}};PV=class PV extends BO{constructor(e,t,r,i,n,o,s,a,c,l,u){super("async",c,t,i,n,o);this.client=e,this.logger=r,this.fields=s,this.tx=a,this._isResponseInArrayMode=l,this.customResultMapper=u,this.customResultMapper=u,this.fields=s}static[J]="LibSQLPreparedQuery";async run(e){let t=Op(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:i,tx:n,client:o,customResultMapper:s}=this;if(!t&&!s){let c=Op(i.params,e??{});return r.logQuery(i.sql,c),await this.queryWithCache(i.sql,c,async()=>{let l={sql:i.sql,args:c};return(n?n.execute(l):o.execute(l)).then(({rows:u})=>this.mapAllResult(u))})}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)=>RV(r));if(this.customResultMapper)return this.customResultMapper(e,Px);return e.map((r)=>nO(this.fields,Array.prototype.slice.call(r).map((i)=>Px(i)),this.joinsNotNullableMap))}async get(e){let{fields:t,logger:r,query:i,tx:n,client:o,customResultMapper:s}=this;if(!t&&!s){let c=Op(i.params,e??{});return r.logQuery(i.sql,c),await this.queryWithCache(i.sql,c,async()=>{let l={sql:i.sql,args:c};return(n?n.execute(l):o.execute(l)).then(({rows:u})=>this.mapGetResult(u))})}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 RV(r);if(!r)return;if(this.customResultMapper)return this.customResultMapper(e,Px);return nO(this.fields,Array.prototype.slice.call(r).map((i)=>Px(i)),this.joinsNotNullableMap)}async values(e){let t=Op(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:i})=>i)})}isResponseInArrayMode(){return this._isResponseInArrayMode}}});function Au(e,t={}){let r=new TO({casing:t.casing}),i;if(t.logger===!0)i=new oO;else if(t.logger!==!1)i=t.logger;let n;if(t.schema){let a=v9(t.schema,k9);n={fullSchema:t.schema,schema:a.tables,tableNamesMap:a.tableNamesMap}}let o=new zx(e,r,n,{logger:i,cache:t.cache},void 0),s=new zV("async",r,o,n);if(s.$client=e,s.$cache=t.cache,s.$cache)s.$cache.invalidate=t.cache?.onMutate;return s}var zV;var NV=x(()=>{De();hx();Np();Ox();Ex();HO();zV=class zV extends Mp{static[J]="LibSQLDatabase";async batch(e){return this.session.batch(e)}}});function Nx(...e){if(typeof e[0]==="string"){let t=bu({url:e[0]});return Au(t,e[1])}if(YJ(e[0])){let{connection:t,client:r,...i}=e[0];if(r)return Au(r,i);let n=typeof t==="string"?bu({url:t}):bu(t);return Au(n,i)}return Au(e[0],e[1])}var DV=x(()=>{K$();Ur();NV();((e)=>{function t(r){return Au({},r)}e.mock=t})(Nx||(Nx={}))});var LV=x(()=>{DV();HO()});function BV(e){if(e.authToken!==void 0)return e.authToken;if(e.authTokenEnv===void 0)return;return process.env[e.authTokenEnv]}function xke(e){return e instanceof je&&/^SQLITE_(?:BUSY|LOCKED)$/u.test(e.code)}async function Zp(e,t){let r=Date.now()+(t.budgetMs??gke),i=async(n)=>{if(t.isClosed())throw new je("The client is closed","CLIENT_CLOSED");try{return await e()}catch(o){if(t.isClosed()||!xke(o))throw o;await t.afterRefusal?.();let s=Math.min(yke*2**(n-1),bke),a=s/2+Math.random()*(s/2);if(t.isClosed()||Date.now()+a>=r)throw o;if(await new Promise((c)=>setTimeout(c,a)),t.isClosed()||Date.now()>=r)throw o;return i(n+1)}};return i(1)}function KO(e,t={}){let r=bu({...e,...e.url.startsWith("file:")?{timeout:0}:{}});if(e.url.startsWith("file:")&&e.syncUrl===void 0){let u=function(d,p){return Zp(()=>typeof d==="string"?s(d,p):s(d),{isClosed:n,budgetMs:o})},i=r.transaction.bind(r),n=()=>r.closed,o=t.contentionRetryBudgetMs,s=r.execute.bind(r),a=r.batch.bind(r),c=r.migrate.bind(r),l={isClosed:n,budgetMs:o,afterRefusal:async()=>{await Promise.resolve(r.reconnect())}};r.execute=u,r.batch=(d,p)=>Zp(()=>a(d,p),l),r.migrate=(d)=>Zp(()=>c(d),l),r.transaction=(d)=>Zp(()=>i(d),l)}return r}function Dx(e){let{url:t,schema:r}=e,i=BV(e),n={contentionRetryBudgetMs:e.contentionRetryBudgetMs},o=i?KO({url:t,authToken:i},n):KO({url:t},n);return{db:Nx(o,{schema:r}),client:o,url:t}}async function Lx(e,t){if(!t.startsWith("file:"))return;let r=()=>e.closed===!0;for(let i of["PRAGMA busy_timeout = 0","PRAGMA journal_mode = WAL"])await Zp(()=>e.execute(i),{isClosed:r})}var gke=5000,yke=5,bke=40;var JO=x(()=>{K$();LV()});var jV=x(()=>{a$();JO()});var VO=x(()=>{JO();jV()});var oe,ft;var WO=x(()=>{FO();np();oe=jp("job_queue",{id:mr("id").primaryKey().$defaultFn(()=>to()),type:mr("type").notNull(),data:mr("data").notNull(),result:mr("result",{mode:"json"}),progress:mr("progress",{mode:"json"}).$type(),source:mr("source"),metadata:mr("metadata",{mode:"json"}).$type().notNull(),status:mr("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:mr("lastError"),createdAt:Ar("createdAt").notNull().$defaultFn(()=>Date.now()),scheduledFor:Ar("scheduledFor").notNull().$defaultFn(()=>Date.now()),startedAt:Ar("startedAt"),completedAt:Ar("completedAt"),attemptId:mr("attemptId"),workerSlotId:mr("workerSlotId"),workerSessionId:mr("workerSessionId"),leaseExpiresAt:Ar("leaseExpiresAt"),attemptHeartbeatAt:Ar("attemptHeartbeatAt"),runtimeUpdatedAt:Ar("runtimeUpdatedAt")},(e)=>({queueReadyIdx:Wa("idx_job_queue_ready").on(e.status,e.priority,e.scheduledFor),jobTypeIdx:Wa("idx_job_queue_type").on(e.type,e.status),runtimeUpdatesIdx:Wa("idx_job_queue_runtime_updates").on(e.runtimeUpdatedAt,e.id),jobSourceIdx:Wa("idx_job_queue_source").on(e.source)})),ft=jp("job_worker_sessions",{slotId:mr("slotId").primaryKey(),sessionId:mr("sessionId").notNull().unique(),startedAt:Ar("startedAt").notNull(),heartbeatAt:Ar("heartbeatAt").notNull(),expiresAt:Ar("expiresAt").notNull().default(0)},(e)=>({heartbeatIdx:Wa("idx_job_worker_sessions_heartbeat").on(e.heartbeatAt),expiresIdx:Wa("idx_job_worker_sessions_expires").on(e.expiresAt)}))});function qV(e){return Dx({url:e.url,schema:{jobQueue:oe,jobWorkerSessions:ft},authToken:e.authToken,authTokenEnv:"JOB_QUEUE_DATABASE_AUTH_TOKEN",contentionRetryBudgetMs:0})}var UV=x(()=>{VO();WO()});class GO{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(){if(!this.finalizedRegistrations)throw Error("Job handler registrations are not finalized");return this.finalizedRegistrations}getRegisteredTypes(){return[...this.handlers.keys()]}getHandler(e){return this.handlers.get(e)}getValidator(e){return this.validators.get(e)}}var MV=x(()=>{Sx();cx();Wn();De();kx();hx();lo();Np();EO();Gn();Ir();Ur();so()});class QO{tails=new Map;async run(e,t){let r=this.tails.get(e),i=()=>{},n=new Promise((o)=>{i=o});this.tails.set(e,n),await r;try{return await t()}finally{if(i(),this.tails.get(e)===n)this.tails.delete(e)}}}class YO{findDuplicate(e,t,r){if(!t||t==="none")return null;let i=this.filterByDeduplicationKey(e,r).sort((o,s)=>s.createdAt-o.createdAt||s.id.localeCompare(o.id)),n=i.find((o)=>o.status===He.PENDING)??null;if(t==="skip"||t==="replace")return n;return n??i[0]??null}filterByDeduplicationKey(e,t){if(!t)return e;return e.filter((r)=>{let i=Ske.safeParse(r.metadata);return i.success&&i.data.deduplicationKey===t})}}var Ske;var FV=x(()=>{Re();gs();Ske=f.looseObject({deduplicationKey:f.string().optional()})});class XO{db;transactionClient;databaseUrl;logger;deduplicator=new YO;writeRetryBudgetMs;constructor(e,t,r,i,n){this.db=e,this.transactionClient=t,this.databaseUrl=r,this.logger=i.child("JobQueueRepository"),this.writeRetryBudgetMs=n?.writeRetryBudgetMs??wke}async insert(e){await this.write("insert",async()=>this.db.insert(oe).values(e))}async enqueueAtomic(e){return Eke.run(this.databaseUrl,async()=>{let t=Date.now()+this.writeRetryBudgetMs;return this.attemptEnqueue(e,t,1)})}async attemptEnqueue(e,t,r){let i=await this.runEnqueueTransaction(e,t,r);if(i.retry)return this.attemptEnqueue(e,t,r+1);return i.decision}async runEnqueueTransaction(e,t,r){let i=await this.acquireWriteTransaction(e,t),n={prepared:!1},o=!1;try{let s=await this.decideEnqueue(i,e,()=>{n.prepared=!0});return o=!0,await i.commit(),{retry:!1,decision:s}}catch(s){let a=o&&this.isSerializationConflict(s)&&!i.closed,c=!0;if(!i.closed)try{await i.rollback()}catch(l){c=!1,this.logger.error("Failed to roll back atomic enqueue",{type:e.jobData.type,rollbackError:l})}if(n.prepared)e.onInsertRollback?.();if(!a||!c)throw s;return await this.waitForConflictRetry("commit",e,t,r,s),{retry:!0}}finally{i.close()}}async decideEnqueue(e,t,r){let{jobData:i,strategy:n,deduplicationKey:o,beforeInsert:s}=t,a=n??"none",c=async()=>{await s?.(),r()},l=async()=>{await c(),await this.insertJob(e,i)};if(a==="none")return await l(),{kind:"inserted",jobId:i.id};let u=await this.getActiveDeduplicationCandidates(e,i.type),d=this.deduplicator.findDuplicate(u,a,o);if(!d)return await l(),{kind:"inserted",jobId:i.id};if(a==="skip")return{kind:"skipped",jobId:d.id};if(a==="coalesce"){if((await e.execute({sql:"UPDATE `job_queue` SET `scheduledFor` = ? WHERE `id` = ? AND `status` = ?",args:[Date.now(),d.id,d.status]})).rowsAffected!==1)throw Error(`Atomic coalesce lost selected job ${d.id}`);return{kind:"coalesced",jobId:d.id}}await c();let p=Date.now();if((await e.execute({sql:"UPDATE `job_queue`\n SET `status` = ?,\n `lastError` = ?,\n `completedAt` = ?,\n `runtimeUpdatedAt` = max(?, coalesce((SELECT max(`runtimeUpdatedAt`) FROM `job_queue`), 0) + 1)\n WHERE `id` = ? AND `status` = ?",args:[He.FAILED,"Replaced by newer job",p,p,d.id,He.PENDING]})).rowsAffected!==1)throw Error(`Atomic replace lost selected job ${d.id}`);return await this.insertJob(e,i),{kind:"replaced",jobId:i.id,replacedJobId:d.id}}async getActiveDeduplicationCandidates(e,t){return(await e.execute({sql:"SELECT `id`, `status`, `createdAt`, `metadata`\n FROM `job_queue`\n WHERE `type` = ? AND `status` IN (?, ?)",args:[t,He.PENDING,He.PROCESSING]})).rows.map((i)=>this.parseDeduplicationCandidate(i))}parseDeduplicationCandidate(e){let{id:t,status:r,createdAt:i,metadata:n}=e;if(typeof t!=="string"||r!==He.PENDING&&r!==He.PROCESSING||typeof i!=="number"&&typeof i!=="bigint"||typeof n!=="string")throw Error("Invalid active job row returned during atomic enqueue");let o=JSON.parse(n);return{id:t,status:r,createdAt:Number(i),metadata: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`\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]})).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,i,n){let o=Math.min(vke*2**(i-1),_ke),s=o/2+Math.random()*(o/2);if(Date.now()+s>=r)throw this.transactionConflictError(e,t,i,n);await new Promise((a)=>setTimeout(a,s))}async retryOnConflict(e,t,r,i,n=Date.now()+this.writeRetryBudgetMs,o=1){try{return await r()}catch(s){if(!i(s))throw s;return await this.waitForConflictRetry(e,t,n,o,s),this.retryOnConflict(e,t,r,i,n,o+1)}}transactionConflictError(e,t,r,i){if(typeof t==="string")return Error(`Failed job queue write "${t}" within ${this.writeRetryBudgetMs}ms after ${r} attempts`,{cause:i});let n=t.strategy??"none",o=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: ${o})`,{cause:i})}write(e,t){return this.retryOnConflict("write",e,t,(r)=>{let i=new Set;for(let n=r;n!==void 0&&!i.has(n);){if(i.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):"",i=at(t,"");if(/SQLITE_(?:BUSY|LOCKED)/u.test(r)||/SQLITE_(?:BUSY|LOCKED)|database is locked|transaction (?:busy|conflict)/iu.test(i))return!0;t=t instanceof Error?t.cause:void 0}return!1}async startWorkerSession(e,t,r=Date.now(),i=hs){let n=r+i;await this.write("start worker session",async()=>this.db.insert(ft).values({slotId:e,sessionId:t,startedAt:r,heartbeatAt:r,expiresAt:n}).onConflictDoUpdate({target:ft.slotId,set:{sessionId:t,startedAt:r,heartbeatAt:r,expiresAt:n}}))}async heartbeatWorkerSession(e,t,r=Date.now(),i=hs){return(await this.write("heartbeat worker session",async()=>this.db.update(ft).set({heartbeatAt:r,expiresAt:r+i}).where(Nt(et(ft.slotId,e),et(ft.sessionId,t))).returning({slotId:ft.slotId}))).length===1}async endWorkerSession(e,t){return(await this.write("end worker session",async()=>this.db.delete(ft).where(Nt(et(ft.slotId,e),et(ft.sessionId,t))).returning({slotId:ft.slotId}))).length===1}async complete(e,t,r){let i=Date.now(),o=(await this.write("complete",async()=>this.db.update(oe).set({status:He.COMPLETED,result:t,lastError:null,completedAt:i,runtimeUpdatedAt:this.nextRuntimeUpdatedAt(i)}).where(this.attemptWriteGuard(e,r)).returning({id:oe.id}))).length===1;if(o)this.logger.debug("Job completed",{jobId:e,hasResult:t!==void 0});return o}async update(e,t,r){let n=(await this.write("update",async()=>this.db.update(oe).set({data:JSON.stringify(t)}).where(this.attemptWriteGuard(e,r)).returning({id:oe.id}))).length===1;if(n)this.logger.debug("Job data updated",{jobId:e});return n}async recordAttemptProgress(e,t,r,i=Date.now()){return(await this.write("record progress",async()=>this.db.update(oe).set({attemptHeartbeatAt:i,runtimeUpdatedAt:this.nextRuntimeUpdatedAt(i),progress:r}).where(this.attemptWriteGuard(e,t)).returning({id:oe.id}))).length===1}async renewAttemptLease(e,t,r,i){return(await this.write("renew attempt lease",async()=>this.db.update(oe).set({attemptHeartbeatAt:r,leaseExpiresAt:r+i}).where(this.attemptWriteGuard(e,t)).returning({id:oe.id}))).length===1}async fail(e,t,r,i=Date.now()){let o=(await this.db.select({retryCount:oe.retryCount,maxRetries:oe.maxRetries,type:oe.type,scheduledFor:oe.scheduledFor,startedAt:oe.startedAt,runtimeUpdatedAt:oe.runtimeUpdatedAt}).from(oe).where(this.attemptWriteGuard(e,r)).limit(1))[0];if(!o)return!1;let s=o.retryCount<o.maxRetries,a=s?o.retryCount+1:o.retryCount,c=Math.min(1000*2**o.retryCount,60000),l=s?i+c:o.scheduledFor;if((await this.write("fail",async()=>this.db.update(oe).set({status:s?He.PENDING:He.FAILED,retryCount:a,lastError:t.message,scheduledFor:l,completedAt:s?null:i,runtimeUpdatedAt:s?o.runtimeUpdatedAt:this.nextRuntimeUpdatedAt(i),startedAt:s?null:o.startedAt,attemptId:null,workerSlotId:null,workerSessionId:null,leaseExpiresAt:null,attemptHeartbeatAt:null}).where(Nt(this.attemptWriteGuard(e,r),et(oe.retryCount,o.retryCount))).returning({id:oe.id}))).length!==1)return!1;if(s)this.logger.debug("Job scheduled for retry",{jobId:e,retryCount:a,backoffMs:c,scheduledFor:new Date(l).toISOString()});else this.logger.error("Job failed after max retries",{jobId:e,type:o.type,retryCount:o.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 i=(await this.write("retire unowned job",async()=>this.db.update(oe).set({status:He.FAILED,lastError:t,completedAt:e.now,runtimeUpdatedAt:this.nextRuntimeUpdatedAt(e.now)}).where(Nt(et(oe.id,e.jobId),et(oe.type,e.expectedType),ao(et(oe.status,He.PENDING),et(oe.status,He.PROCESSING)),Rn(oe.attemptId),Rn(oe.workerSlotId),Rn(oe.workerSessionId),Rn(oe.leaseExpiresAt),Rn(oe.attemptHeartbeatAt),Rn(oe.progress),Rn(oe.result))).returning()))[0]??null;if(i)this.logger.warn("Retired unowned legacy job",{jobId:i.id,type:i.type,reason:t});return i}async getStatus(e){return(await this.db.select().from(oe).where(et(oe.id,e)).limit(1))[0]??null}async getJobsByRootJobId(e){return this.db.select().from(oe).where(q`json_extract(${oe.metadata}, '$.rootJobId') = ${e}`).orderBy(co(oe.createdAt),co(oe.id))}async getStatusByEntityId(e){return(await this.db.select().from(oe).where(q`json_extract(${oe.data}, '$.id') = ${e}`).orderBy(Ja(oe.createdAt)).limit(1))[0]??null}async getStats(){let e=await this.db.select({status:oe.status,count:q`count(*)`}).from(oe).groupBy(oe.status),t={pending:0,processing:0,failed:0,completed:0,total:0};for(let r of e){let i=Number(r.count);t[r.status]=i,t.total+=i}return t}async getDiagnostics(e=Date.now()){let[t,r,i]=await Promise.all([this.db.select({type:oe.type,status:oe.status,count:q`count(*)`}).from(oe).groupBy(oe.type,oe.status),this.db.select({oldestPendingAt:q`min(case when ${oe.status} = ${He.PENDING} then ${oe.createdAt} end)`,duePending:q`coalesce(sum(case when ${oe.status} = ${He.PENDING} and ${oe.scheduledFor} <= ${e} then 1 else 0 end), 0)`,oldestDuePendingAt:q`min(case when ${oe.status} = ${He.PENDING} and ${oe.scheduledFor} <= ${e} then ${oe.scheduledFor} end)`,latestClaimAt:q`max(${oe.startedAt})`,oldestProcessingAt:q`min(case when ${oe.status} = ${He.PROCESSING} then ${oe.startedAt} end)`,staleLeaseCount:q`coalesce(sum(case when ${oe.status} = ${He.PROCESSING} and ${oe.leaseExpiresAt} is not null and ${oe.leaseExpiresAt} <= ${e} then 1 else 0 end), 0)`}).from(oe),this.db.select({total:q`count(*)`,active:q`coalesce(sum(case when ${ft.expiresAt} > ${e} then 1 else 0 end), 0)`,stale:q`coalesce(sum(case when ${ft.expiresAt} <= ${e} then 1 else 0 end), 0)`,latestHeartbeatAt:q`max(${ft.heartbeatAt})`}).from(ft)]),n={pending:0,processing:0,completed:0,failed:0},o=t.map((l)=>{let u=Number(l.count);return n[l.status]+=u,{type:l.type,status:l.status,count:u}}),s=r[0],a=i[0],c=(l)=>l===null||l===void 0?null:Math.max(0,e-Number(l));return{totals:n,byType:o,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=kke.parse(t);if(r===0)return[];return(await this.db.select().from(oe).where(q`(${oe.runtimeUpdatedAt}, ${oe.id}) > (${e.updatedAt}, ${e.jobId})`).orderBy(co(oe.runtimeUpdatedAt),co(oe.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(oe).where(Nt(ao(et(oe.status,He.COMPLETED),et(oe.status,He.FAILED)),wu(oe.completedAt,t))))).rowsAffected}async getActiveJobs(e){let t=ao(et(oe.status,He.PENDING),et(oe.status,He.PROCESSING)),r=e&&e.length>0?Nt(t,Ts(oe.type,e)):t;return this.db.select().from(oe).where(r).orderBy(Ja(oe.createdAt))}async getRecentJobs(e,t=20){let r=e&&e.length>0?Ts(oe.type,e):void 0;return this.db.select().from(oe).where(r).orderBy(Ja(oe.createdAt)).limit(t)}async getFailedJobs(e){let t=et(oe.status,He.FAILED),r=e&&e.length>0?Nt(t,Ts(oe.type,e)):t;return this.db.select().from(oe).where(r).orderBy(Ja(oe.createdAt))}async claimNextReady(e){let{now:t,attemptId:r,workerSlotId:i,workerSessionId:n,leaseDurationMs:o,executableTypes:s}=e,a=this.db.select({slotId:ft.slotId}).from(ft).where(Nt(et(ft.slotId,i),et(ft.sessionId,n),gx(ft.expiresAt,t))),c=this.db.select({slotId:ft.slotId}).from(ft).where(Nt(et(ft.slotId,oe.workerSlotId),et(ft.sessionId,oe.workerSessionId))),l=Nt(et(oe.status,He.PROCESSING),ao(Rn(oe.attemptId),bx(c),wu(oe.leaseExpiresAt,t))),u=q`${oe.status} = ${He.PROCESSING} AND ${oe.retryCount} + 1 > ${oe.maxRetries}`,d=this.db.select({id:oe.id}).from(oe).where(Nt(Ts(oe.type,s),ao(Nt(et(oe.status,He.PENDING),wu(oe.scheduledFor,t)),l))).orderBy(co(oe.priority),co(oe.createdAt)).limit(1),m=(await this.write("claim",async()=>this.db.update(oe).set({status:q`CASE WHEN ${u} THEN ${He.FAILED} ELSE ${He.PROCESSING} END`,retryCount:q`CASE WHEN ${oe.status} = ${He.PROCESSING} THEN ${oe.retryCount} + 1 ELSE ${oe.retryCount} END`,lastError:q`CASE WHEN ${oe.status} = ${He.PROCESSING} THEN 'Attempt lease expired' ELSE ${oe.lastError} END`,startedAt:q`CASE WHEN ${u} THEN ${oe.startedAt} ELSE ${t} END`,completedAt:q`CASE WHEN ${u} THEN ${t} ELSE NULL END`,attemptId:q`CASE WHEN ${u} THEN ${oe.attemptId} ELSE ${r} END`,workerSlotId:q`CASE WHEN ${u} THEN ${oe.workerSlotId} ELSE ${i} END`,workerSessionId:q`CASE WHEN ${u} THEN ${oe.workerSessionId} ELSE ${n} END`,leaseExpiresAt:q`CASE WHEN ${u} THEN ${oe.leaseExpiresAt} ELSE ${t+o} END`,attemptHeartbeatAt:q`CASE WHEN ${u} THEN ${oe.attemptHeartbeatAt} ELSE ${t} END`,runtimeUpdatedAt:q`CASE WHEN ${u} THEN ${this.nextRuntimeUpdatedAt(t)} ELSE ${oe.runtimeUpdatedAt} END`}).where(Nt(Ts(oe.id,d),yx(a))).returning()))[0];if(m?.status!==He.PROCESSING)return null;return this.logger.debug("Job claimed",{jobId:m.id,attemptId:m.attemptId,workerSlotId:i,workerSessionId:n}),m}nextRuntimeUpdatedAt(e){return q`max(${e}, coalesce((select max(${oe.runtimeUpdatedAt}) from ${oe}), 0) + 1)`}attemptWriteGuard(e,t){return t?Nt(et(oe.id,e),et(oe.status,He.PROCESSING),et(oe.attemptId,t)):Nt(et(oe.id,e),Rn(oe.attemptId),ao(et(oe.status,He.PENDING),et(oe.status,He.PROCESSING)))}}var wke=2000,vke=5,_ke=40,kke,Eke;var ZV=x(()=>{MV();WO();Re();gs();op();FV();kke=f.number().int().min(0).max(1000),Eke=new QO});import{AsyncLocalStorage as Ike}from"async_hooks";class Hp{storage=new Ike;static createFresh(){return new Hp}constructor(){}current(){return this.storage.getStore()}run(e,t,r){if(t.length===0)throw Error("Operation ID must not be empty");let i=Ro.parse(e),n=Ake(i);return this.storage.run(Object.freeze({provenance:n,operationId:t}),r)}}function Ake(e){if(Object.freeze(e.projectionLineage),e.sourceEntity)Object.freeze(e.sourceEntity);return Object.freeze(e)}var eR=x(()=>{Po()});class Kp{client;logger;handlerRegistry;repository;walInitialization=null;walInitializationSettled=!1;closeRequested=!1;clientClosed=!1;inFlightEnqueues=0;databaseUrl;operationContext;projectionAdmission;directWorkerSlotId=`direct:${to()}`;directWorkerSessionId=to();directLeaseDurationMs;directSessionStart=null;close(){this.closeRequested=!0,this.closeClientWhenReady()}static createFresh(e,t,r){return new Kp(e,t??fn.getInstance(),r)}constructor(e,t,r){let{db:i,client:n,url:o}=qV(e);this.client=n,this.databaseUrl=o,this.logger=t.child("JobQueueService"),this.operationContext=r?.operationContext??Hp.createFresh(),this.projectionAdmission=r?.projectionAdmission,this.handlerRegistry=new GO(this.logger,r?.handlerRegistrationMode??"combined"),this.repository=new XO(i,n,o,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 Lx(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:i}=e,n=this.handlerRegistry.getValidator(t);if(!n)throw Error(`No job type declared: ${t}`);let o=n.validateAndParse(r);if(o===null)throw Error(`Invalid job data for type: ${t}`);let s=Date.now(),a=to(),c=i?.rootJobId??this.operationContext.current()?.provenance.rootJobId??a,l=this.createJobProvenance(a,c,i),u=i?.metadata??{operationType:"data_processing"},{provenance:d,...p}=u,m={id:a,type:t,data:JSON.stringify(o),status:He.PENDING,priority:i?.priority??0,maxRetries:i?.maxRetries??3,retryCount:0,source:i?.source??null,metadata:{...p,...i?.deduplicationKey&&{deduplicationKey:i.deduplicationKey},rootJobId:c,provenance:l},createdAt:s,scheduledFor:i?.delayMs?s+i.delayMs:s,result:null,lastError:null,startedAt:null,completedAt:null},y,g=()=>{y?.rollback(),y=void 0};try{let b=await this.repository.enqueueAtomic({jobData:m,strategy:i?.deduplication,deduplicationKey:i?.deduplicationKey,beforeInsert:async()=>{y=await this.projectionAdmission?.reserveJobAdmission(l)},onInsertRollback:g});if(y?.commit(),y=void 0,b.kind==="skipped")this.logger.debug("Skipping duplicate job (already pending)",{type:t,existingJobId:b.jobId});else if(b.kind==="coalesced")this.logger.debug("Coalescing with existing job",{type:t,existingJobId:b.jobId});else{if(b.kind==="replaced")this.logger.debug("Replacing duplicate job",{type:t,oldJobId:b.replacedJobId});this.logger.debug("Job enqueued",{id:b.jobId,type:t,priority:m.priority,rootJobId:m.metadata.rootJobId})}return b.jobId}catch(b){throw g(),this.logger.error("Failed to enqueue job",{type:t,error:at(b)}),b}}createJobProvenance(e,t,r){let i=this.operationContext.current(),n=r?.metadata.provenance??i?.provenance,o=n?.rootJobId===t?n:void 0,s=i?.provenance.rootJobId===t?i.operationId:void 0,a=r?.projection,c=a?[...o?.projectionLineage??[],a.id]:[...o?.projectionLineage??[]],l=a?.id??o?.projectionId;return Ro.parse({rootJobId:t,causationId:s??o?.causationId??e,...l?{projectionId:l}:{},projectionLineage:c,...a?.sourceEntity?{sourceEntity:a.sourceEntity}:o?.sourceEntity?{sourceEntity:o.sourceEntity}:{},derivationDepth:c.length})}async dequeue(e){let t=this.handlerRegistry.getRegisteredTypes();if(t.length===0)return null;let r=e??await this.getDirectClaimOptions(),i=Date.now(),n=await this.repository.claimNextReady({...r,now:i,attemptId:to(),executableTypes:t});if(!n)return null;return this.logger.debug("Job dequeued",{id:n.id,type:n.type,priority:n.priority,retryCount:n.retryCount,attemptId:n.attemptId,workerSlotId:n.workerSlotId,workerSessionId:n.workerSessionId}),n}async startWorkerSession(e,t,r=hs){await this.repository.startWorkerSession(e,t,Date.now(),r)}heartbeatWorkerSession(e,t,r=hs){return this.repository.heartbeatWorkerSession(e,t,Date.now(),r)}endWorkerSession(e,t){return this.repository.endWorkerSession(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.directWorkerSlotId,this.directWorkerSessionId,Date.now(),this.directLeaseDurationMs),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,i=Date.now()+(e.timeoutMs??30000),n=async(o)=>{e.signal?.throwIfAborted();let{totals:s}=await this.getDiagnostics(),c=s.pending===0&&s.processing===0?o??Date.now():null;if(c!==null&&Date.now()-c>=t)return;if(Date.now()>=i)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 HV=x(()=>{np();a$();op();gs();VO();UV();ZV();Po();eR()});var tR=()=>{};var KV=x(()=>{np();gs();op();gs();tR();eR()});var JV=x(()=>{gs();tR()});var Net;var VV=x(()=>{Po();Re();ip();Net=f.preprocess((e)=>{if(typeof e!=="string")return e;return JSON.parse(e)},f.record(f.string(),f.unknown()))});var Bet;var WV=x(()=>{Re();Bet=f.record(f.string(),f.unknown())});var GV=x(()=>{Po();np()});var QV=x(()=>{HV();KV();JV();VV();WV();op();gs();ip();GV()});var rR={};tr(rR,{LEGACY_PROJECTION_JOB_TYPES:()=>XV,LEGACY_PROJECTION_RETIREMENT_REASON:()=>t7,legacyProjectionJobTypeSchema:()=>e7,retireLegacyProjectionJob:()=>Dke});import{existsSync as Pke}from"fs";import{resolve as zke}from"path";function YV(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 Nke(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 Dke(e){let t=zke(e.databasePath);if(!Pke(t))throw Error(`Job database does not exist: ${t}`);let r=e7.parse(e.jobType),i=Kp.createFresh({url:`file:${t}`});try{let n=await i.getStatus(e.jobId);if(!n)throw Error(`Job not found: ${e.jobId}`);if(Nke(n,r),e.dryRun){if(e.confirmation!==void 0)throw Error("Dry-run recovery must not include confirmation");return{databasePath:t,job:YV(n),retired:!1}}let o=`retire:${n.id}`;if(e.confirmation!==o)throw Error(`Refusing to retire ${n.id}; expected --confirm ${o}`);let s=await i.retireUnownedActiveJob({jobId:n.id,expectedType:r,reason:t7,now:e.now?.()??Date.now()});if(!s)throw Error(`Job ${n.id} changed or acquired ownership before retirement`);return{databasePath:t,job:YV(s),retired:!0}}finally{i.close()}}var XV,e7,t7="Retired legacy projection job superseded by scheduler-owned projections";var nR=x(()=>{QV();Re();XV=["conversation-memory:project","skill:project","swot:derive","topic:project"],e7=f.enum(XV)});function er(e,t,r,i,n){return n7.parse({id:e,operation:t,count:r,targetProbeCount:i,settleMs:n})}function oR(e){return Vp.parse(structuredClone(qke[e]))}function Wp(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 jx(e,t={}){let r=t.fetchImpl??fetch,i=t.now??(()=>new Date),n=t.timeoutMs??20000,o=i(),s=new AbortController,a=setTimeout(()=>s.abort(),n);try{let c=await r(e,{method:"GET",signal:s.signal});return await c.arrayBuffer(),iR.parse({timestamp:o.toISOString(),endpoint:new URL(e).pathname,status:c.status,durationMs:Math.max(0,i().getTime()-o.getTime()),ok:c.ok})}catch(c){return iR.parse({timestamp:o.toISOString(),endpoint:new URL(e).pathname,status:0,durationMs:Math.max(0,i().getTime()-o.getTime()),ok:!1,error:Uke(c)})}finally{clearTimeout(a)}}async function sR(e,t){let r=Vp.parse(e),i=[],n,o=await t.prepare(r),s,a;try{try{await t.startMonitoring()}catch(c){n=`monitor: ${Bx(c)}`}if(!n)for(let c of r.phases)try{let l=i7.parse(await t.executePhase(c,o));if(i.push(l),!l.success){n=`${c.id}: ${l.error??"phase failed"}`;break}}catch(l){let u=Bx(l);i.push({id:c.id,operation:c.operation,count:c.count,success:!1,error:u}),n=`${c.id}: ${u}`;break}}finally{try{if(s=o7.parse(await t.cleanup(o)),!s.success&&!n)n=s.error??"cleanup failed"}catch(c){let l=Bx(c);s={success:!1,probesRemaining:0,error:l},n??=`cleanup: ${l}`}try{a=s7.parse(await t.stopMonitoring())}catch(c){let l=Bx(c);a={health:[],runtime:[]},n??=`monitor: ${l}`}}return n??=c7(a,r.maximumExternalAiCalls??0),a7.parse({profile:r.profile,success:n===void 0&&i.length===r.phases.length&&s.success,baseline:o,phases:i,cleanup:s,metrics:a,...n?{failure:n}:{}})}function c7(e,t=0){let r=e.health.find((o)=>!o.ok);if(r)return`health: ${r.endpoint} unavailable`;let i=e.externalAiCalls??0;if(i>t)return t===0?`external AI: observed ${i} call(s)`:`external AI: observed ${i} 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 Uke(e){if(e instanceof Error)return`${e.name}: ${e.message}`;return String(e)}function Bx(e){return at(e)}var Jp,r7,n7,Vp,Lke,iR,Bke,i7,o7,jke,s7,a7,qke;var qx=x(()=>{Re();Jp=f.enum(["regression","load","stress"]),r7=f.enum(["add","update","rename","delete"]),n7=f.object({id:f.string().min(1),operation:r7,count:f.number().int().positive().max(700),targetProbeCount:f.number().int().min(0).max(700),settleMs:f.number().int().nonnegative().max(300000)}),Vp=f.object({profile:Jp,maximumProbeCount:f.number().int().positive().max(700),maximumExternalAiCalls:f.number().int().nonnegative().max(1e4).optional(),phases:f.array(n7).min(1)}),Lke=f.object({entities:f.number().int().nonnegative(),notes:f.number().int().nonnegative(),version:f.string().min(1)}),iR=f.object({timestamp:f.iso.datetime(),endpoint:f.string().startsWith("/"),status:f.number().int().nonnegative(),durationMs:f.number().nonnegative(),ok:f.boolean(),error:f.string().optional()}),Bke=f.object({timestamp:f.iso.datetime(),cpuPercent:f.number().nonnegative(),memoryPercent:f.number().nonnegative(),pids:f.number().int().nonnegative()}),i7=f.object({id:f.string().min(1),operation:r7,count:f.number().int().positive(),success:f.boolean(),commitLatencyMs:f.number().nonnegative().optional(),persistenceLatencyMs:f.number().nonnegative().optional(),error:f.string().optional()}),o7=f.object({success:f.boolean(),probesRemaining:f.number().int().nonnegative(),finalEntities:f.number().int().nonnegative().optional(),finalNotes:f.number().int().nonnegative().optional(),contentTreeRestored:f.boolean().optional(),error:f.string().optional()}),jke=f.object({status:f.string(),restartCount:f.number().int().nonnegative(),oomKilled:f.boolean()}),s7=f.object({health:f.array(iR),runtime:f.array(Bke),externalAiCalls:f.number().int().nonnegative().optional(),container:jke.optional()}),a7=f.object({profile:Jp,success:f.boolean(),baseline:Lke,phases:f.array(i7),cleanup:o7,metrics:s7,failure:f.string().optional()}),qke={regression:{profile:"regression",maximumProbeCount:20,phases:[er("add20","add",20,20,0),er("update20","update",20,20,30000),er("delete20","delete",20,0,150000)]},load:{profile:"load",maximumProbeCount:350,phases:[er("add50","add",50,50,0),er("add150","add",100,150,0),er("add350","add",200,350,0),er("update350a","update",350,350,45000),er("rename100","rename",100,350,45000),er("update350b","update",350,350,45000),er("delete350","delete",350,0,150000)]},stress:{profile:"stress",maximumProbeCount:700,phases:[er("add50","add",50,50,0),er("add150","add",100,150,0),er("add350","add",200,350,0),er("add700","add",350,700,0),er("update700a","update",700,700,45000),er("rename200","rename",200,700,45000),er("update700b","update",700,700,45000),er("delete700","delete",700,0,150000)]}}});import{spawn as Mke}from"child_process";async function l7(e,t,r,i){let n=await e(t,r,i);if(n.exitCode!==0)throw Ei(t,r,n);return n}function Ei(e,t,r){let i=r.stderr.trim()||r.stdout.trim();return Error(`${e} ${t.join(" ")} exited with ${r.exitCode}${i?`: ${i}`:""}`)}var mo=async(e,t,r={})=>new Promise((i,n)=>{let o=Mke(e,[...t],{cwd:r.cwd,env:r.env?{...process.env,...r.env}:process.env,stdio:["pipe","pipe","pipe"]}),s="",a="";o.stdout.setEncoding("utf8"),o.stderr.setEncoding("utf8"),o.stdout.on("data",(c)=>{s+=c}),o.stderr.on("data",(c)=>{a+=c}),o.on("error",n),o.on("close",(c)=>{i({exitCode:c??1,stdout:s,stderr:a})}),o.stdin.end(r.stdin)});var Gp=()=>{};class Tu{#e;#t;dir;constructor(e,t,r){this.#e=e,this.dir=t,this.#t=r}static async clone(e,t,r,i){let n=new Tu(e,r,i);return await l7(e,"git",["-c","credential.helper=","-c",`credential.helper=${u7}`,"clone","--branch","main","--single-branch",`https://github.com/${t}.git`,r],{env:n.environment()}),await n.run(["config","--local","credential.helper",u7]),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 Ei("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 u7='!f() { test "$1" = get && echo username=x-access-token && echo "password=$GH_TOKEN"; }; f';var d7=x(()=>{Gp()});function Qp(e){return e.entityCounts.find((t)=>t.entityType==="note")?.count??0}class aR{#e;#t=[];#r=[];#n=new Set(["/health/ready"]);#i=!0;#o;#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 jx(`https://${this.#e.domain}${e}`,{fetchImpl:this.#e.fetchImpl,now:this.#e.now,timeoutMs:5000})).status!==404)this.#n.add(e)}start(){this.#i=!1,this.#a=void 0,this.#c=this.#t.length,this.#l=void 0,this.#s=this.#e.now().toISOString(),this.#o=Promise.all([this.#f(),this.#m()]).then(()=>{return}).catch((e)=>{this.#a=e,this.#i=!0})}async stop(){this.#i=!0,await this.#o}async waitForHealthSnapshot(e){return this.waitForEntityBaseline(void 0,void 0,e)}async waitForEntityBaseline(e,t,r){let i=this.#e.now().getTime();while(this.#e.now().getTime()-i<r){let n=await this.fetchHealthPayload();if(this.#d(n,e,t))return n;await this.#e.sleep(5000)}return}async waitForStableEntityBaseline(e,t,r){let i=this.#e.now().getTime(),n=0;while(this.#e.now().getTime()-i<r){let o=await this.fetchHealthPayload();if(this.#d(o,e,t)){if(n+=1,n===2)return o}else n=0;await this.#e.sleep(5000)}return}async fetchHealthPayload(){let e=this.#e.now(),t=new AbortController,r=setTimeout(()=>t.abort(),20000);try{let i=await this.#e.fetchImpl(`https://${this.#e.domain}/health/operate`,{signal:t.signal}),n=await i.text();if(this.#t.push({timestamp:e.toISOString(),endpoint:"/health/operate",status:i.status,durationMs:Math.max(0,this.#e.now().getTime()-e.getTime()),ok:i.ok}),!i.ok)return;return Fke.parse(JSON.parse(n)).app}catch(i){this.#t.push({timestamp:e.toISOString(),endpoint:"/health/operate",status:0,durationMs:Math.max(0,this.#e.now().getTime()-e.getTime()),ok:!1,error:i instanceof Error?`${i.name}: ${i.message}`:String(i)});return}finally{clearTimeout(r)}}#d(e,t,r){return e!==void 0&&(t===void 0||Qp(e)===t)&&(r===void 0||e.entities===r)}async#f(){while(!this.#i){for(let e of this.#n)this.#t.push(await jx(`https://${this.#e.domain}${e}`,{fetchImpl:this.#e.fetchImpl,now:this.#e.now,timeoutMs:20000}));await this.#e.sleep(4000)}}async#m(){while(!this.#i){let e=await this.#e.sampleRuntime();if(e)this.#r.push(e);await this.#e.sleep(1000)}}}var Fke;var f7=x(()=>{Re();qx();Fke=f.object({status:f.literal("ready"),operationalStatus:f.literal("operational"),app:f.object({version:f.string(),entities:f.number().int().nonnegative(),entityCounts:f.array(f.object({entityType:f.string(),count:f.number().int().nonnegative()})).default([])})})});var Ux={};tr(Ux,{applyDirectorySyncStressPhase:()=>x7,cleanupDirectorySyncStress:()=>g7,listProbeFiles:()=>Qa,parseStressRuntimeSample:()=>S7,removeProbeFiles:()=>mR,runDeployedDirectorySyncStress:()=>m7,runStressCommand:()=>mo,verifyDirectorySyncStressAccess:()=>h7});import{chmod as Zke,mkdir as lR,mkdtemp as uR,readFile as Hke,readdir as Kke,rename as Jke,rm as Xp,writeFile as Xn}from"fs/promises";import{tmpdir as dR}from"os";import{join as xt,resolve as fR}from"path";async function m7(e){let t=e.now??(()=>new Date),r=t().toISOString(),i=hR(r),n=fR(e.artifactsDir??xt(e.rootDir,".brains-ops","stress",i));await lR(n,{recursive:!0});let{pilot:o,user:s}=await pR(e.rootDir,e.handle);Wp({handle:s.handle,domain:s.domain,contentRepo:s.contentRepo,confirmation:e.confirmation});let a=Jp.parse(e.profile),c=e.plan?Vp.parse(e.plan):oR(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)b7(s);let l=Vke.parse(e.env??process.env),u=new y7({runId:i,artifactsDir:n,user:s,githubOrg:o.githubOrg,serverLabel:`${o.contentRepoPrefix}${s.handle}`,environment:l,fetchImpl:e.fetchImpl??fetch,commandRunner:e.commandRunner??mo,logger:e.logger??console.info,now:t,sleep:e.sleep??Bun.sleep}),d;try{d=await sR(c,u)}finally{await u.dispose()}let p={runId:i,artifactsDir:n,target:{handle:s.handle,domain:s.domain,contentRepo:`${o.githubOrg}/${s.contentRepo}`},startedAt:r,completedAt:t().toISOString(),report:d};return await Xke(p),p}async function h7(e){let r=(e.now??(()=>new Date))().toISOString(),i=hR(r),n=fR(e.artifactsDir??xt(e.rootDir,".brains-ops","stress",`access-check-${i}`));await lR(n,{recursive:!0});let{pilot:o,user:s}=await pR(e.rootDir,e.handle);Wp({handle:s.handle,domain:s.domain,contentRepo:s.contentRepo,confirmation:e.confirmation}),b7(s);let a=(e.env??process.env).CONTENT_REPO_ADMIN_TOKEN;if(!a)throw Error("Missing CONTENT_REPO_ADMIN_TOKEN");let c=await uR(xt(dR(),"brains-ops-directory-sync-access-check-"));try{let l=await Tu.clone(e.commandRunner??mo,`${o.githubOrg}/${s.contentRepo}`,xt(c,"content"),a),u=await l.output(["rev-parse","HEAD"]);await l.run(["push","--dry-run","origin",`HEAD:refs/heads/ops/directory-sync-stress-access-check-${i}`]);let d={success:!0,artifactsDir:n,checkedAt:r,remoteHead:u,target:{handle:s.handle,domain:s.domain,contentRepo:`${o.githubOrg}/${s.contentRepo}`}};return await Xn(xt(n,"access-check.json"),`${JSON.stringify(d,null,2)}
465
+ `;await t.run(n);let s=(await t.values(q`SELECT id, hash, created_at FROM ${q.identifier(i)} 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 l of c.sql)await a.run(q.raw(l));await a.run(q`INSERT INTO ${q.identifier(i)} ("hash", "created_at") VALUES(${c.hash}, ${c.folderMillis})`)}})}}});var CO;var xV=x(()=>{De();CO=class CO{static[J]="TypedQueryBuilder";getSelectedFields(){return this._.selectedFields}}});function Ix(e,t){return(r,i,...n)=>{let o=[i,...n].map((s)=>({type:e,isAll:t,rightSelect:s}));for(let s of o)if(!Rp(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(o)}}var Yn,SV,$O,cke=()=>({union:lke,unionAll:uke,intersect:dke,except:fke}),lke,uke,dke,fke;var OO=x(()=>{De();xV();lo();Va();pr();Gn();Ir();Ur();so();_u();qp();Yn=class Yn{static[J]="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(ce(e,vt))r=Object.fromEntries(Object.keys(e._.selectedFields).map((i)=>[i,e[i]]));else if(ce(e,po))r=e[_t].selectedFields;else if(ce(e,Te))r={};else r=mx(e);return new $O({table:e,fields:r,isPartialSelect:t,session:this.session,dialect:this.dialect,withList:this.withList,distinct:this.distinct})}};SV=class SV extends CO{static[J]="SQLiteSelectQueryBuilder";_;config;joinsNotNullableMap;tableName;isPartialSelect;session;dialect;cacheConfig=void 0;usedTables=new Set;constructor({table:e,fields:t,isPartialSelect:r,session:i,dialect:n,withList:o,distinct:s}){super();this.config={withList:o,table:e,fields:{...t},distinct:s,setOperators:[]},this.isPartialSelect=r,this.session=i,this.dialect=n,this._={selectedFields:t,config:this.config},this.tableName=Pp(e),this.joinsNotNullableMap=typeof this.tableName==="string"?{[this.tableName]:!0}:{};for(let a of Qn(e))this.usedTables.add(a)}getUsedTables(){return[...this.usedTables]}createJoin(e){return(t,r)=>{let i=this.tableName,n=Pp(t);for(let o of Qn(t))this.usedTables.add(o);if(typeof n==="string"&&this.config.joins?.some((o)=>o.alias===n))throw Error(`Alias "${n}" is already used in this query`);if(!this.isPartialSelect){if(Object.keys(this.joinsNotNullableMap).length===1&&typeof i==="string")this.config.fields={[i]:this.config.fields};if(typeof n==="string"&&!ce(t,Te)){let o=ce(t,vt)?t._.selectedFields:ce(t,$n)?t[_t].selectedFields:t[we.Symbol.Columns];this.config.fields[n]=o}}if(typeof r==="function")r=r(new Proxy(this.config.fields,new bt({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(([o])=>[o,!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(([o])=>[o,!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 i=typeof r==="function"?r(cke()):r;if(!Rp(this.getSelectedFields(),i.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:i}),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 bt({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})));return this.config.where=e,this}having(e){if(typeof e==="function")e=e(new Proxy(this.config.fields,new bt({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 bt({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 bt({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(...Qn(this.config.table)),this.config.joins)for(let r of this.config.joins)t.push(...Qn(r.table));return new Proxy(new vt(this.getSQL(),this.config.fields,e,!1,[...new Set(t)]),new bt({alias:e,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}getSelectedFields(){return new Proxy(this.config.fields,new bt({alias:this.tableName,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}$dynamic(){return this}};$O=class $O extends SV{static[J]="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=On(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()}};QJ($O,[Mr]);lke=Ix("union",!1),uke=Ix("union",!0),dke=Ix("intersect",!1),fke=Ix("except",!1)});var Ga;var Ax=x(()=>{De();Va();Ex();Gn();OO();Ga=class Ga{static[J]="SQLiteQueryBuilder";dialect;dialectConfig;constructor(e){this.dialect=ce(e,Eu)?e:void 0,this.dialectConfig=ce(e,Eu)?void 0:e}$with=(e,t)=>{let r=this;return{as:(n)=>{if(typeof n==="function")n=n(r);return new Proxy(new Cp(n.getSQL(),t??("getSelectedFields"in n?n.getSelectedFields()??{}:{}),e,!0),new bt({alias:e,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}}};with(...e){let t=this;function r(n){return new Yn({fields:n??void 0,session:void 0,dialect:t.getDialect(),withList:e})}function i(n){return new Yn({fields:n??void 0,session:void 0,dialect:t.getDialect(),withList:e,distinct:!0})}return{select:r,selectDistinct:i}}select(e){return new Yn({fields:e??void 0,session:void 0,dialect:this.getDialect()})}selectDistinct(e){return new Yn({fields:e??void 0,session:void 0,dialect:this.getDialect(),distinct:!0})}getDialect(){if(!this.dialect)this.dialect=new AO(this.dialectConfig);return this.dialect}}});var Tx,RO;var wV=x(()=>{De();lo();pr();uo();Ir();Ur();_u();Ax();Tx=class Tx{constructor(e,t,r,i){this.table=e,this.session=t,this.dialect=r,this.withList=i}static[J]="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 i={},n=this.table[we.Symbol.Columns];for(let o of Object.keys(r)){let s=r[o];i[o]=ce(s,Te)?s:new mn(s,n[o])}return i});return new RO(this.table,t,this.session,this.dialect,this.withList)}select(e){let t=typeof e==="function"?e(new Ga):e;if(!ce(t,Te)&&!Rp(this.table[dx],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 RO(this.table,t,this.session,this.dialect,this.withList,!0)}};RO=class RO extends Mr{constructor(e,t,r,i,n,o){super();this.session=r,this.dialect=i,this.config={table:e,values:t,withList:n,select:o}}static[J]="SQLiteInsert";config;returning(e=this.config.table[Mt.Symbol.Columns]){return this.config.returning=On(e),this}onConflictDoNothing(e={}){if(!this.config.onConflict)this.config.onConflict=[];if(e.target===void 0)this.config.onConflict.push(q` on conflict do nothing`);else{let t=Array.isArray(e.target)?q`${e.target}`:q`${[e.target]}`,r=e.where?q` where ${e.where}`:q``;this.config.onConflict.push(q` 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?q` where ${e.where}`:void 0,r=e.targetWhere?q` where ${e.targetWhere}`:void 0,i=e.setWhere?q` where ${e.setWhere}`:void 0,n=Array.isArray(e.target)?q`${e.target}`:q`${[e.target]}`,o=this.dialect.buildUpdateSet(this.config.table,px(this.config.table,e.set));return this.config.onConflict.push(q` on conflict ${n}${r} do update set ${o}${t}${i}`),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:Qn(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 Cx,vV;var _V=x(()=>{De();lo();Va();uo();Gn();Ir();Ur();so();_u();qp();Cx=class Cx{constructor(e,t,r,i){this.table=e,this.session=t,this.dialect=r,this.withList=i}static[J]="SQLiteUpdateBuilder";set(e){return new vV(this.table,px(this.table,e),this.session,this.dialect,this.withList)}};vV=class vV extends Mr{constructor(e,t,r,i,n){super();this.session=r,this.dialect=i,this.config={set:t,table:e,withList:n,joins:[]}}static[J]="SQLiteUpdate";config;from(e){return this.config.from=e,this}createJoin(e){return(t,r)=>{let i=Pp(t);if(typeof i==="string"&&this.config.joins.some((n)=>n.alias===i))throw Error(`Alias "${i}" is already used in this query`);if(typeof r==="function"){let n=this.config.from?ce(t,Mt)?t[we.Symbol.Columns]:ce(t,vt)?t._.selectedFields:ce(t,po)?t[_t].selectedFields:void 0:void 0;r=r(new Proxy(this.config.table[we.Symbol.Columns],new bt({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})),n&&new Proxy(n,new bt({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))}return this.config.joins.push({on:r,table:t,joinType:e,alias:i}),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[we.Symbol.Columns],new bt({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[Mt.Symbol.Columns]){return this.config.returning=On(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:Qn(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 PO=x(()=>{mV();wV();Ax();OO();_V()});var Up;var kV=x(()=>{De();pr();Up=class Up extends Te{constructor(e){super(Up.buildEmbeddedCount(e.source,e.filters).queryChunks);this.params=e,this.session=e.session,this.sql=Up.buildCount(e.source,e.filters)}sql;static[J]="SQLiteCountBuilderAsync";[Symbol.toStringTag]="SQLiteCountBuilderAsync";session;static buildEmbeddedCount(e,t){return q`(select count(*) from ${e}${q.raw(" where ").if(t)}${t})`}static buildCount(e,t){return q`select count(*) from ${e}${q.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 NO,$x,zO;var EV=x(()=>{De();lo();Np();NO=class NO{constructor(e,t,r,i,n,o,s,a){this.mode=e,this.fullSchema=t,this.schema=r,this.tableNamesMap=i,this.table=n,this.tableConfig=o,this.dialect=s,this.session=a}static[J]="SQLiteAsyncRelationalQueryBuilder";findMany(e){return this.mode==="sync"?new zO(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e?e:{},"many"):new $x(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e?e:{},"many")}findFirst(e){return this.mode==="sync"?new zO(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e?{...e,limit:1}:{limit:1},"first"):new $x(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e?{...e,limit:1}:{limit:1},"first")}};$x=class $x extends Mr{constructor(e,t,r,i,n,o,s,a,c){super();this.fullSchema=e,this.schema=t,this.tableNamesMap=r,this.table=i,this.tableConfig=n,this.dialect=o,this.session=s,this.config=a,this.mode=c}static[J]="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,(i,n)=>{let o=i.map((s)=>xx(this.schema,this.tableConfig,s,t.selection,n));if(this.mode==="first")return o[0];return o})}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()}};zO=class zO extends $x{static[J]="SQLiteSyncRelationalQuery";sync(){return this.executeRaw()}}});var Iu;var IV=x(()=>{De();lo();Iu=class Iu extends Mr{constructor(e,t,r,i,n){super();this.execute=e,this.getSQL=t,this.dialect=i,this.mapBatchResult=n,this.config={action:r}}static[J]="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 Mp;var Ox=x(()=>{De();Va();pr();PO();Gn();kV();EV();IV();Mp=class Mp{constructor(e,t,r,i){this.resultKind=e,this.dialect=t,this.session=r,this._=i?{schema:i.schema,fullSchema:i.fullSchema,tableNamesMap:i.tableNamesMap}:{schema:void 0,fullSchema:{},tableNamesMap:{}},this.query={};let n=this.query;if(this._.schema)for(let[o,s]of Object.entries(this._.schema))n[o]=new NO(e,i.fullSchema,this._.schema,this._.tableNamesMap,i.fullSchema[o],s,t,r);this.$cache={invalidate:async(o)=>{}}}static[J]="BaseSQLiteDatabase";query;$with=(e,t)=>{let r=this;return{as:(n)=>{if(typeof n==="function")n=n(new Ga(r.dialect));return new Proxy(new Cp(n.getSQL(),t??("getSelectedFields"in n?n.getSelectedFields()??{}:{}),e,!0),new bt({alias:e,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}}};$count(e,t){return new Up({source:e,filters:t,session:this.session})}with(...e){let t=this;function r(a){return new Yn({fields:a??void 0,session:t.session,dialect:t.dialect,withList:e})}function i(a){return new Yn({fields:a??void 0,session:t.session,dialect:t.dialect,withList:e,distinct:!0})}function n(a){return new Cx(a,t.session,t.dialect,e)}function o(a){return new Tx(a,t.session,t.dialect,e)}function s(a){return new _x(a,t.session,t.dialect,e)}return{select:r,selectDistinct:i,update:n,insert:o,delete:s}}select(e){return new Yn({fields:e??void 0,session:this.session,dialect:this.dialect})}selectDistinct(e){return new Yn({fields:e??void 0,session:this.session,dialect:this.dialect,distinct:!0})}update(e){return new Cx(e,this.session,this.dialect)}$cache;insert(e){return new Tx(e,this.session,this.dialect)}delete(e){return new _x(e,this.session,this.dialect)}run(e){let t=typeof e==="string"?q.raw(e):e.getSQL();if(this.resultKind==="async")return new Iu(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"?q.raw(e):e.getSQL();if(this.resultKind==="async")return new Iu(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"?q.raw(e):e.getSQL();if(this.resultKind==="async")return new Iu(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"?q.raw(e):e.getSQL();if(this.resultKind==="async")return new Iu(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 DO(e,t){let r=`${e}-${JSON.stringify(t)}`,n=new TextEncoder().encode(r),o=await crypto.subtle.digest("SHA-256",n);return[...new Uint8Array(o)].map((c)=>c.toString(16).padStart(2,"0")).join("")}var AV,Fp;var LO=x(()=>{De();AV=class AV{static[J]="Cache"};Fp=class Fp extends AV{strategy(){return"all"}static[J]="NoopCache";async get(e){return}async put(e,t,r,i){}async onMutate(e){}}});var TV=x(()=>{LO()});var CV=()=>{};var $V,BO,jO,qO;var UO=x(()=>{LO();De();kx();lo();Ox();$V=class $V extends Mr{constructor(e){super();this.resultCb=e}static[J]="ExecuteResultSync";async execute(){return this.resultCb()}sync(){return this.resultCb()}};BO=class BO{constructor(e,t,r,i,n,o){if(this.mode=e,this.executeMethod=t,this.query=r,this.cache=i,this.queryMetadata=n,this.cacheConfig=o,i&&i.strategy()==="all"&&o===void 0)this.cacheConfig={enable:!0,autoInvalidate:!0};if(!this.cacheConfig?.enable)this.cacheConfig=void 0}static[J]="PreparedQuery";joinsNotNullableMap;async queryWithCache(e,t,r){if(this.cache===void 0||ce(this.cache,Fp)||this.queryMetadata===void 0)try{return await r()}catch(i){throw new fo(e,t,i)}if(this.cacheConfig&&!this.cacheConfig.enable)try{return await r()}catch(i){throw new fo(e,t,i)}if((this.queryMetadata.type==="insert"||this.queryMetadata.type==="update"||this.queryMetadata.type==="delete")&&this.queryMetadata.tables.length>0)try{let[i]=await Promise.all([r(),this.cache.onMutate({tables:this.queryMetadata.tables})]);return i}catch(i){throw new fo(e,t,i)}if(!this.cacheConfig)try{return await r()}catch(i){throw new fo(e,t,i)}if(this.queryMetadata.type==="select"){let i=await this.cache.get(this.cacheConfig.tag??await DO(e,t),this.queryMetadata.tables,this.cacheConfig.tag!==void 0,this.cacheConfig.autoInvalidate);if(i===void 0){let n;try{n=await r()}catch(o){throw new fo(e,t,o)}return await this.cache.put(this.cacheConfig.tag??await DO(e,t),n,this.cacheConfig.autoInvalidate?this.queryMetadata.tables:[],this.cacheConfig.tag!==void 0,this.cacheConfig.config),n}return i}try{return await r()}catch(i){throw new fo(e,t,i)}}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 $V(()=>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)}}};jO=class jO{constructor(e){this.dialect=e}static[J]="SQLiteSession";prepareOneTimeQuery(e,t,r,i,n,o,s){return this.prepareQuery(e,t,r,i,n,o,s)}run(e){let t=this.dialect.sqlToQuery(e);try{return this.prepareOneTimeQuery(t,void 0,"run",!1).run()}catch(r){throw new ku({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")}};qO=class qO extends Mp{constructor(e,t,r,i,n=0){super(e,t,r,i);this.schema=i,this.nestedIndex=n}static[J]="SQLiteTransaction";rollback(){throw new kO}}});var MO,pke,mke,Rx;var OV=x(()=>{De();Va();Ur();Ax();uo();qp();MO=class MO{constructor(e){this.name=e}static[J]="SQLiteViewBuilderCore";config={}};pke=class pke extends MO{static[J]="SQLiteViewBuilder";as(e){if(typeof e==="function")e=e(new Ga);let t=new bt({alias:this.name,sqlBehavior:"error",sqlAliasedBehavior:"alias",replaceOriginalName:!0}),r=e.getSelectedFields();return new Proxy(new Rx({config:{name:this.name,schema:void 0,selectedFields:r,query:e.getSQL().inlineParams()}}),t)}};mke=class mke extends MO{static[J]="SQLiteManualViewBuilder";columns;constructor(e,t){super(e);this.columns=mx(jp(e,t))}existing(){return new Proxy(new Rx({config:{name:this.name,schema:void 0,selectedFields:this.columns,query:void 0}}),new bt({alias:this.name,sqlBehavior:"error",sqlAliasedBehavior:"alias",replaceOriginalName:!0}))}as(e){return new Proxy(new Rx({config:{name:this.name,schema:void 0,selectedFields:this.columns,query:e.inlineParams()}}),new bt({alias:this.name,sqlBehavior:"error",sqlAliasedBehavior:"alias",replaceOriginalName:!0}))}};Rx=class Rx extends po{static[J]="SQLiteView";constructor({config:e}){super(e)}}});var FO=x(()=>{CV();aV();IO();Ox();Ex();pO();dV();pV();PO();UO();uo();hO();_u();OV()});function RV(e){return Object.keys(e).reduce((t,r)=>{if(Object.prototype.propertyIsEnumerable.call(e,r))t[r]=e[r];return t},{})}function Px(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 zx,ZO,PV;var HO=x(()=>{TV();De();hx();pr();FO();UO();Ur();zx=class zx extends jO{constructor(e,t,r,i,n){super(t);this.client=e,this.schema=r,this.options=i,this.tx=n,this.logger=i.logger??new sO,this.cache=i.cache??new Fp}static[J]="LibSQLSession";logger;cache;prepareQuery(e,t,r,i,n,o,s){return new PV(this.client,e,this.logger,this.cache,o,s,t,this.tx,r,i,n)}async batch(e){let t=[],r=[];for(let n of e){let o=n._prepare(),s=o.getQuery();t.push(o),r.push({sql:s.sql,args:s.params})}return(await this.client.batch(r)).map((n,o)=>t[o].mapResult(n,!0))}async migrate(e){let t=[],r=[];for(let n of e){let o=n._prepare(),s=o.getQuery();t.push(o),r.push({sql:s.sql,args:s.params})}return(await this.client.migrate(r)).map((n,o)=>t[o].mapResult(n,!0))}async transaction(e,t){let r=await this.client.transaction(),i=new zx(this.client,this.dialect,this.schema,this.options,r),n=new ZO("async",this.dialect,i,this.schema);try{let o=await e(n);return await r.commit(),o}catch(o){throw await r.rollback(),o}}extractRawAllValueFromBatchResult(e){return e.rows}extractRawGetValueFromBatchResult(e){return e.rows[0]}extractRawValuesValueFromBatchResult(e){return e.rows}};ZO=class ZO extends qO{static[J]="LibSQLTransaction";async transaction(e){let t=`sp${this.nestedIndex}`,r=new ZO("async",this.dialect,this.session,this.schema,this.nestedIndex+1);await this.session.run(q.raw(`savepoint ${t}`));try{let i=await e(r);return await this.session.run(q.raw(`release savepoint ${t}`)),i}catch(i){throw await this.session.run(q.raw(`rollback to savepoint ${t}`)),i}}};PV=class PV extends BO{constructor(e,t,r,i,n,o,s,a,c,l,u){super("async",c,t,i,n,o);this.client=e,this.logger=r,this.fields=s,this.tx=a,this._isResponseInArrayMode=l,this.customResultMapper=u,this.customResultMapper=u,this.fields=s}static[J]="LibSQLPreparedQuery";async run(e){let t=Op(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:i,tx:n,client:o,customResultMapper:s}=this;if(!t&&!s){let c=Op(i.params,e??{});return r.logQuery(i.sql,c),await this.queryWithCache(i.sql,c,async()=>{let l={sql:i.sql,args:c};return(n?n.execute(l):o.execute(l)).then(({rows:u})=>this.mapAllResult(u))})}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)=>RV(r));if(this.customResultMapper)return this.customResultMapper(e,Px);return e.map((r)=>nO(this.fields,Array.prototype.slice.call(r).map((i)=>Px(i)),this.joinsNotNullableMap))}async get(e){let{fields:t,logger:r,query:i,tx:n,client:o,customResultMapper:s}=this;if(!t&&!s){let c=Op(i.params,e??{});return r.logQuery(i.sql,c),await this.queryWithCache(i.sql,c,async()=>{let l={sql:i.sql,args:c};return(n?n.execute(l):o.execute(l)).then(({rows:u})=>this.mapGetResult(u))})}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 RV(r);if(!r)return;if(this.customResultMapper)return this.customResultMapper(e,Px);return nO(this.fields,Array.prototype.slice.call(r).map((i)=>Px(i)),this.joinsNotNullableMap)}async values(e){let t=Op(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:i})=>i)})}isResponseInArrayMode(){return this._isResponseInArrayMode}}});function Au(e,t={}){let r=new TO({casing:t.casing}),i;if(t.logger===!0)i=new oO;else if(t.logger!==!1)i=t.logger;let n;if(t.schema){let a=v9(t.schema,k9);n={fullSchema:t.schema,schema:a.tables,tableNamesMap:a.tableNamesMap}}let o=new zx(e,r,n,{logger:i,cache:t.cache},void 0),s=new zV("async",r,o,n);if(s.$client=e,s.$cache=t.cache,s.$cache)s.$cache.invalidate=t.cache?.onMutate;return s}var zV;var NV=x(()=>{De();hx();Np();Ox();Ex();HO();zV=class zV extends Mp{static[J]="LibSQLDatabase";async batch(e){return this.session.batch(e)}}});function Nx(...e){if(typeof e[0]==="string"){let t=bu({url:e[0]});return Au(t,e[1])}if(YJ(e[0])){let{connection:t,client:r,...i}=e[0];if(r)return Au(r,i);let n=typeof t==="string"?bu({url:t}):bu(t);return Au(n,i)}return Au(e[0],e[1])}var DV=x(()=>{K$();Ur();NV();((e)=>{function t(r){return Au({},r)}e.mock=t})(Nx||(Nx={}))});var LV=x(()=>{DV();HO()});function BV(e){if(e.authToken!==void 0)return e.authToken;if(e.authTokenEnv===void 0)return;return process.env[e.authTokenEnv]}function bke(e){return e instanceof je&&/^SQLITE_(?:BUSY|LOCKED)$/u.test(e.code)}async function Zp(e,t){let r=Date.now()+(t.budgetMs??hke),i=async(n)=>{if(t.isClosed())throw new je("The client is closed","CLIENT_CLOSED");try{return await e()}catch(o){if(t.isClosed()||!bke(o))throw o;await t.afterRefusal?.();let s=Math.min(gke*2**(n-1),yke),a=s/2+Math.random()*(s/2);if(t.isClosed()||Date.now()+a>=r)throw o;if(await new Promise((c)=>setTimeout(c,a)),t.isClosed()||Date.now()>=r)throw o;return i(n+1)}};return i(1)}function KO(e,t={}){let r=bu({...e,...e.url.startsWith("file:")?{timeout:0}:{}});if(e.url.startsWith("file:")&&e.syncUrl===void 0){let u=function(d,p){return Zp(()=>typeof d==="string"?s(d,p):s(d),{isClosed:n,budgetMs:o})},i=r.transaction.bind(r),n=()=>r.closed,o=t.contentionRetryBudgetMs,s=r.execute.bind(r),a=r.batch.bind(r),c=r.migrate.bind(r),l={isClosed:n,budgetMs:o,afterRefusal:async()=>{await Promise.resolve(r.reconnect())}};r.execute=u,r.batch=(d,p)=>Zp(()=>a(d,p),l),r.migrate=(d)=>Zp(()=>c(d),l),r.transaction=(d)=>Zp(()=>i(d),l)}return r}function Dx(e){let{url:t,schema:r}=e,i=BV(e),n={contentionRetryBudgetMs:e.contentionRetryBudgetMs},o=i?KO({url:t,authToken:i},n):KO({url:t},n);return{db:Nx(o,{schema:r}),client:o,url:t}}async function Lx(e,t){if(!t.startsWith("file:"))return;let r=()=>e.closed===!0;for(let i of["PRAGMA busy_timeout = 0","PRAGMA journal_mode = WAL"])await Zp(()=>e.execute(i),{isClosed:r})}var hke=5000,gke=5,yke=40;var JO=x(()=>{K$();LV()});var jV=x(()=>{a$();JO()});var VO=x(()=>{JO();jV()});var oe,ft;var WO=x(()=>{FO();np();oe=jp("job_queue",{id:mr("id").primaryKey().$defaultFn(()=>to()),type:mr("type").notNull(),data:mr("data").notNull(),result:mr("result",{mode:"json"}),progress:mr("progress",{mode:"json"}).$type(),source:mr("source"),metadata:mr("metadata",{mode:"json"}).$type().notNull(),status:mr("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:mr("lastError"),createdAt:Ar("createdAt").notNull().$defaultFn(()=>Date.now()),scheduledFor:Ar("scheduledFor").notNull().$defaultFn(()=>Date.now()),startedAt:Ar("startedAt"),completedAt:Ar("completedAt"),attemptId:mr("attemptId"),workerSlotId:mr("workerSlotId"),workerSessionId:mr("workerSessionId"),leaseExpiresAt:Ar("leaseExpiresAt"),attemptHeartbeatAt:Ar("attemptHeartbeatAt"),runtimeUpdatedAt:Ar("runtimeUpdatedAt")},(e)=>({queueReadyIdx:Wa("idx_job_queue_ready").on(e.status,e.priority,e.scheduledFor),jobTypeIdx:Wa("idx_job_queue_type").on(e.type,e.status),runtimeUpdatesIdx:Wa("idx_job_queue_runtime_updates").on(e.runtimeUpdatedAt,e.id),jobSourceIdx:Wa("idx_job_queue_source").on(e.source)})),ft=jp("job_worker_sessions",{slotId:mr("slotId").primaryKey(),sessionId:mr("sessionId").notNull().unique(),startedAt:Ar("startedAt").notNull(),heartbeatAt:Ar("heartbeatAt").notNull(),expiresAt:Ar("expiresAt").notNull().default(0)},(e)=>({heartbeatIdx:Wa("idx_job_worker_sessions_heartbeat").on(e.heartbeatAt),expiresIdx:Wa("idx_job_worker_sessions_expires").on(e.expiresAt)}))});function qV(e){return Dx({url:e.url,schema:{jobQueue:oe,jobWorkerSessions:ft},authToken:e.authToken,authTokenEnv:"JOB_QUEUE_DATABASE_AUTH_TOKEN",contentionRetryBudgetMs:0})}var UV=x(()=>{VO();WO()});class GO{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(){if(!this.finalizedRegistrations)throw Error("Job handler registrations are not finalized");return this.finalizedRegistrations}getRegisteredTypes(){return[...this.handlers.keys()]}getHandler(e){return this.handlers.get(e)}getValidator(e){return this.validators.get(e)}}var MV=x(()=>{Sx();cx();Wn();De();kx();hx();lo();Np();EO();Gn();Ir();Ur();so()});class QO{tails=new Map;async run(e,t){let r=this.tails.get(e),i=()=>{},n=new Promise((o)=>{i=o});this.tails.set(e,n),await r;try{return await t()}finally{if(i(),this.tails.get(e)===n)this.tails.delete(e)}}}class YO{findDuplicate(e,t,r){if(!t||t==="none")return null;let i=this.filterByDeduplicationKey(e,r).sort((o,s)=>s.createdAt-o.createdAt||s.id.localeCompare(o.id)),n=i.find((o)=>o.status===He.PENDING)??null;if(t==="skip"||t==="replace")return n;return n??i[0]??null}filterByDeduplicationKey(e,t){if(!t)return e;return e.filter((r)=>{let i=xke.safeParse(r.metadata);return i.success&&i.data.deduplicationKey===t})}}var xke;var FV=x(()=>{Re();gs();xke=f.looseObject({deduplicationKey:f.string().optional()})});class XO{db;transactionClient;databaseUrl;logger;deduplicator=new YO;writeRetryBudgetMs;constructor(e,t,r,i,n){this.db=e,this.transactionClient=t,this.databaseUrl=r,this.logger=i.child("JobQueueRepository"),this.writeRetryBudgetMs=n?.writeRetryBudgetMs??Ske}async insert(e){await this.write("insert",async()=>this.db.insert(oe).values(e))}async enqueueAtomic(e){return kke.run(this.databaseUrl,async()=>{let t=Date.now()+this.writeRetryBudgetMs;return this.attemptEnqueue(e,t,1)})}async attemptEnqueue(e,t,r){let i=await this.runEnqueueTransaction(e,t,r);if(i.retry)return this.attemptEnqueue(e,t,r+1);return i.decision}async runEnqueueTransaction(e,t,r){let i=await this.acquireWriteTransaction(e,t),n={prepared:!1},o=!1;try{let s=await this.decideEnqueue(i,e,()=>{n.prepared=!0});return o=!0,await i.commit(),{retry:!1,decision:s}}catch(s){let a=o&&this.isSerializationConflict(s)&&!i.closed,c=!0;if(!i.closed)try{await i.rollback()}catch(l){c=!1,this.logger.error("Failed to roll back atomic enqueue",{type:e.jobData.type,rollbackError:l})}if(n.prepared)e.onInsertRollback?.();if(!a||!c)throw s;return await this.waitForConflictRetry("commit",e,t,r,s),{retry:!0}}finally{i.close()}}async decideEnqueue(e,t,r){let{jobData:i,strategy:n,deduplicationKey:o,beforeInsert:s}=t,a=n??"none",c=async()=>{await s?.(),r()},l=async()=>{await c(),await this.insertJob(e,i)};if(a==="none")return await l(),{kind:"inserted",jobId:i.id};let u=await this.getActiveDeduplicationCandidates(e,i.type),d=this.deduplicator.findDuplicate(u,a,o);if(!d)return await l(),{kind:"inserted",jobId:i.id};if(a==="skip")return{kind:"skipped",jobId:d.id};if(a==="coalesce"){if((await e.execute({sql:"UPDATE `job_queue` SET `scheduledFor` = ? WHERE `id` = ? AND `status` = ?",args:[Date.now(),d.id,d.status]})).rowsAffected!==1)throw Error(`Atomic coalesce lost selected job ${d.id}`);return{kind:"coalesced",jobId:d.id}}await c();let p=Date.now();if((await e.execute({sql:"UPDATE `job_queue`\n SET `status` = ?,\n `lastError` = ?,\n `completedAt` = ?,\n `runtimeUpdatedAt` = max(?, coalesce((SELECT max(`runtimeUpdatedAt`) FROM `job_queue`), 0) + 1)\n WHERE `id` = ? AND `status` = ?",args:[He.FAILED,"Replaced by newer job",p,p,d.id,He.PENDING]})).rowsAffected!==1)throw Error(`Atomic replace lost selected job ${d.id}`);return await this.insertJob(e,i),{kind:"replaced",jobId:i.id,replacedJobId:d.id}}async getActiveDeduplicationCandidates(e,t){return(await e.execute({sql:"SELECT `id`, `status`, `createdAt`, `metadata`\n FROM `job_queue`\n WHERE `type` = ? AND `status` IN (?, ?)",args:[t,He.PENDING,He.PROCESSING]})).rows.map((i)=>this.parseDeduplicationCandidate(i))}parseDeduplicationCandidate(e){let{id:t,status:r,createdAt:i,metadata:n}=e;if(typeof t!=="string"||r!==He.PENDING&&r!==He.PROCESSING||typeof i!=="number"&&typeof i!=="bigint"||typeof n!=="string")throw Error("Invalid active job row returned during atomic enqueue");let o=JSON.parse(n);return{id:t,status:r,createdAt:Number(i),metadata: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`\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]})).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,i,n){let o=Math.min(wke*2**(i-1),vke),s=o/2+Math.random()*(o/2);if(Date.now()+s>=r)throw this.transactionConflictError(e,t,i,n);await new Promise((a)=>setTimeout(a,s))}async retryOnConflict(e,t,r,i,n=Date.now()+this.writeRetryBudgetMs,o=1){try{return await r()}catch(s){if(!i(s))throw s;return await this.waitForConflictRetry(e,t,n,o,s),this.retryOnConflict(e,t,r,i,n,o+1)}}transactionConflictError(e,t,r,i){if(typeof t==="string")return Error(`Failed job queue write "${t}" within ${this.writeRetryBudgetMs}ms after ${r} attempts`,{cause:i});let n=t.strategy??"none",o=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: ${o})`,{cause:i})}write(e,t){return this.retryOnConflict("write",e,t,(r)=>{let i=new Set;for(let n=r;n!==void 0&&!i.has(n);){if(i.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):"",i=at(t,"");if(/SQLITE_(?:BUSY|LOCKED)/u.test(r)||/SQLITE_(?:BUSY|LOCKED)|database is locked|transaction (?:busy|conflict)/iu.test(i))return!0;t=t instanceof Error?t.cause:void 0}return!1}async startWorkerSession(e,t,r=Date.now(),i=hs){let n=r+i;await this.write("start worker session",async()=>this.db.insert(ft).values({slotId:e,sessionId:t,startedAt:r,heartbeatAt:r,expiresAt:n}).onConflictDoUpdate({target:ft.slotId,set:{sessionId:t,startedAt:r,heartbeatAt:r,expiresAt:n}}))}async heartbeatWorkerSession(e,t,r=Date.now(),i=hs){return(await this.write("heartbeat worker session",async()=>this.db.update(ft).set({heartbeatAt:r,expiresAt:r+i}).where(Nt(et(ft.slotId,e),et(ft.sessionId,t))).returning({slotId:ft.slotId}))).length===1}async endWorkerSession(e,t){return(await this.write("end worker session",async()=>this.db.delete(ft).where(Nt(et(ft.slotId,e),et(ft.sessionId,t))).returning({slotId:ft.slotId}))).length===1}async complete(e,t,r){let i=Date.now(),o=(await this.write("complete",async()=>this.db.update(oe).set({status:He.COMPLETED,result:t,lastError:null,completedAt:i,runtimeUpdatedAt:this.nextRuntimeUpdatedAt(i)}).where(this.attemptWriteGuard(e,r)).returning({id:oe.id}))).length===1;if(o)this.logger.debug("Job completed",{jobId:e,hasResult:t!==void 0});return o}async update(e,t,r){let n=(await this.write("update",async()=>this.db.update(oe).set({data:JSON.stringify(t)}).where(this.attemptWriteGuard(e,r)).returning({id:oe.id}))).length===1;if(n)this.logger.debug("Job data updated",{jobId:e});return n}async recordAttemptProgress(e,t,r,i=Date.now()){return(await this.write("record progress",async()=>this.db.update(oe).set({attemptHeartbeatAt:i,runtimeUpdatedAt:this.nextRuntimeUpdatedAt(i),progress:r}).where(this.attemptWriteGuard(e,t)).returning({id:oe.id}))).length===1}async renewAttemptLease(e,t,r,i){return(await this.write("renew attempt lease",async()=>this.db.update(oe).set({attemptHeartbeatAt:r,leaseExpiresAt:r+i}).where(this.attemptWriteGuard(e,t)).returning({id:oe.id}))).length===1}async fail(e,t,r,i=Date.now()){let o=(await this.db.select({retryCount:oe.retryCount,maxRetries:oe.maxRetries,type:oe.type,scheduledFor:oe.scheduledFor,startedAt:oe.startedAt,runtimeUpdatedAt:oe.runtimeUpdatedAt}).from(oe).where(this.attemptWriteGuard(e,r)).limit(1))[0];if(!o)return!1;let s=o.retryCount<o.maxRetries,a=s?o.retryCount+1:o.retryCount,c=Math.min(1000*2**o.retryCount,60000),l=s?i+c:o.scheduledFor;if((await this.write("fail",async()=>this.db.update(oe).set({status:s?He.PENDING:He.FAILED,retryCount:a,lastError:t.message,scheduledFor:l,completedAt:s?null:i,runtimeUpdatedAt:s?o.runtimeUpdatedAt:this.nextRuntimeUpdatedAt(i),startedAt:s?null:o.startedAt,attemptId:null,workerSlotId:null,workerSessionId:null,leaseExpiresAt:null,attemptHeartbeatAt:null}).where(Nt(this.attemptWriteGuard(e,r),et(oe.retryCount,o.retryCount))).returning({id:oe.id}))).length!==1)return!1;if(s)this.logger.debug("Job scheduled for retry",{jobId:e,retryCount:a,backoffMs:c,scheduledFor:new Date(l).toISOString()});else this.logger.error("Job failed after max retries",{jobId:e,type:o.type,retryCount:o.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 i=(await this.write("retire unowned job",async()=>this.db.update(oe).set({status:He.FAILED,lastError:t,completedAt:e.now,runtimeUpdatedAt:this.nextRuntimeUpdatedAt(e.now)}).where(Nt(et(oe.id,e.jobId),et(oe.type,e.expectedType),ao(et(oe.status,He.PENDING),et(oe.status,He.PROCESSING)),Rn(oe.attemptId),Rn(oe.workerSlotId),Rn(oe.workerSessionId),Rn(oe.leaseExpiresAt),Rn(oe.attemptHeartbeatAt),Rn(oe.progress),Rn(oe.result))).returning()))[0]??null;if(i)this.logger.warn("Retired unowned legacy job",{jobId:i.id,type:i.type,reason:t});return i}async getStatus(e){return(await this.db.select().from(oe).where(et(oe.id,e)).limit(1))[0]??null}async getJobsByRootJobId(e){return this.db.select().from(oe).where(q`json_extract(${oe.metadata}, '$.rootJobId') = ${e}`).orderBy(co(oe.createdAt),co(oe.id))}async getStatusByEntityId(e){return(await this.db.select().from(oe).where(q`json_extract(${oe.data}, '$.id') = ${e}`).orderBy(Ja(oe.createdAt)).limit(1))[0]??null}async getStats(){let e=await this.db.select({status:oe.status,count:q`count(*)`}).from(oe).groupBy(oe.status),t={pending:0,processing:0,failed:0,completed:0,total:0};for(let r of e){let i=Number(r.count);t[r.status]=i,t.total+=i}return t}async getDiagnostics(e=Date.now()){let[t,r,i]=await Promise.all([this.db.select({type:oe.type,status:oe.status,count:q`count(*)`}).from(oe).groupBy(oe.type,oe.status),this.db.select({oldestPendingAt:q`min(case when ${oe.status} = ${He.PENDING} then ${oe.createdAt} end)`,duePending:q`coalesce(sum(case when ${oe.status} = ${He.PENDING} and ${oe.scheduledFor} <= ${e} then 1 else 0 end), 0)`,oldestDuePendingAt:q`min(case when ${oe.status} = ${He.PENDING} and ${oe.scheduledFor} <= ${e} then ${oe.scheduledFor} end)`,latestClaimAt:q`max(${oe.startedAt})`,oldestProcessingAt:q`min(case when ${oe.status} = ${He.PROCESSING} then ${oe.startedAt} end)`,staleLeaseCount:q`coalesce(sum(case when ${oe.status} = ${He.PROCESSING} and ${oe.leaseExpiresAt} is not null and ${oe.leaseExpiresAt} <= ${e} then 1 else 0 end), 0)`}).from(oe),this.db.select({total:q`count(*)`,active:q`coalesce(sum(case when ${ft.expiresAt} > ${e} then 1 else 0 end), 0)`,stale:q`coalesce(sum(case when ${ft.expiresAt} <= ${e} then 1 else 0 end), 0)`,latestHeartbeatAt:q`max(${ft.heartbeatAt})`}).from(ft)]),n={pending:0,processing:0,completed:0,failed:0},o=t.map((l)=>{let u=Number(l.count);return n[l.status]+=u,{type:l.type,status:l.status,count:u}}),s=r[0],a=i[0],c=(l)=>l===null||l===void 0?null:Math.max(0,e-Number(l));return{totals:n,byType:o,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=_ke.parse(t);if(r===0)return[];return(await this.db.select().from(oe).where(q`(${oe.runtimeUpdatedAt}, ${oe.id}) > (${e.updatedAt}, ${e.jobId})`).orderBy(co(oe.runtimeUpdatedAt),co(oe.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(oe).where(Nt(ao(et(oe.status,He.COMPLETED),et(oe.status,He.FAILED)),wu(oe.completedAt,t))))).rowsAffected}async getActiveJobs(e){let t=ao(et(oe.status,He.PENDING),et(oe.status,He.PROCESSING)),r=e&&e.length>0?Nt(t,Ts(oe.type,e)):t;return this.db.select().from(oe).where(r).orderBy(Ja(oe.createdAt))}async getRecentJobs(e,t=20){let r=e&&e.length>0?Ts(oe.type,e):void 0;return this.db.select().from(oe).where(r).orderBy(Ja(oe.createdAt)).limit(t)}async getFailedJobs(e){let t=et(oe.status,He.FAILED),r=e&&e.length>0?Nt(t,Ts(oe.type,e)):t;return this.db.select().from(oe).where(r).orderBy(Ja(oe.createdAt))}async claimNextReady(e){let{now:t,attemptId:r,workerSlotId:i,workerSessionId:n,leaseDurationMs:o,executableTypes:s}=e,a=this.db.select({slotId:ft.slotId}).from(ft).where(Nt(et(ft.slotId,i),et(ft.sessionId,n),gx(ft.expiresAt,t))),c=this.db.select({slotId:ft.slotId}).from(ft).where(Nt(et(ft.slotId,oe.workerSlotId),et(ft.sessionId,oe.workerSessionId))),l=Nt(et(oe.status,He.PROCESSING),ao(Rn(oe.attemptId),bx(c),wu(oe.leaseExpiresAt,t))),u=q`${oe.status} = ${He.PROCESSING} AND ${oe.retryCount} + 1 > ${oe.maxRetries}`,d=this.db.select({id:oe.id}).from(oe).where(Nt(Ts(oe.type,s),ao(Nt(et(oe.status,He.PENDING),wu(oe.scheduledFor,t)),l))).orderBy(co(oe.priority),co(oe.createdAt)).limit(1),m=(await this.write("claim",async()=>this.db.update(oe).set({status:q`CASE WHEN ${u} THEN ${He.FAILED} ELSE ${He.PROCESSING} END`,retryCount:q`CASE WHEN ${oe.status} = ${He.PROCESSING} THEN ${oe.retryCount} + 1 ELSE ${oe.retryCount} END`,lastError:q`CASE WHEN ${oe.status} = ${He.PROCESSING} THEN 'Attempt lease expired' ELSE ${oe.lastError} END`,startedAt:q`CASE WHEN ${u} THEN ${oe.startedAt} ELSE ${t} END`,completedAt:q`CASE WHEN ${u} THEN ${t} ELSE NULL END`,attemptId:q`CASE WHEN ${u} THEN ${oe.attemptId} ELSE ${r} END`,workerSlotId:q`CASE WHEN ${u} THEN ${oe.workerSlotId} ELSE ${i} END`,workerSessionId:q`CASE WHEN ${u} THEN ${oe.workerSessionId} ELSE ${n} END`,leaseExpiresAt:q`CASE WHEN ${u} THEN ${oe.leaseExpiresAt} ELSE ${t+o} END`,attemptHeartbeatAt:q`CASE WHEN ${u} THEN ${oe.attemptHeartbeatAt} ELSE ${t} END`,runtimeUpdatedAt:q`CASE WHEN ${u} THEN ${this.nextRuntimeUpdatedAt(t)} ELSE ${oe.runtimeUpdatedAt} END`}).where(Nt(Ts(oe.id,d),yx(a))).returning()))[0];if(m?.status!==He.PROCESSING)return null;return this.logger.debug("Job claimed",{jobId:m.id,attemptId:m.attemptId,workerSlotId:i,workerSessionId:n}),m}nextRuntimeUpdatedAt(e){return q`max(${e}, coalesce((select max(${oe.runtimeUpdatedAt}) from ${oe}), 0) + 1)`}attemptWriteGuard(e,t){return t?Nt(et(oe.id,e),et(oe.status,He.PROCESSING),et(oe.attemptId,t)):Nt(et(oe.id,e),Rn(oe.attemptId),ao(et(oe.status,He.PENDING),et(oe.status,He.PROCESSING)))}}var Ske=2000,wke=5,vke=40,_ke,kke;var ZV=x(()=>{MV();WO();Re();gs();op();FV();_ke=f.number().int().min(0).max(1000),kke=new QO});import{AsyncLocalStorage as Eke}from"async_hooks";class Hp{storage=new Eke;static createFresh(){return new Hp}constructor(){}current(){return this.storage.getStore()}run(e,t,r){if(t.length===0)throw Error("Operation ID must not be empty");let i=Ro.parse(e),n=Ike(i);return this.storage.run(Object.freeze({provenance:n,operationId:t}),r)}}function Ike(e){if(Object.freeze(e.projectionLineage),e.sourceEntity)Object.freeze(e.sourceEntity);return Object.freeze(e)}var eR=x(()=>{Po()});class Kp{client;logger;handlerRegistry;repository;walInitialization=null;walInitializationSettled=!1;closeRequested=!1;clientClosed=!1;inFlightEnqueues=0;databaseUrl;operationContext;projectionAdmission;directWorkerSlotId=`direct:${to()}`;directWorkerSessionId=to();directLeaseDurationMs;directSessionStart=null;close(){this.closeRequested=!0,this.closeClientWhenReady()}static createFresh(e,t,r){return new Kp(e,t??fn.getInstance(),r)}constructor(e,t,r){let{db:i,client:n,url:o}=qV(e);this.client=n,this.databaseUrl=o,this.logger=t.child("JobQueueService"),this.operationContext=r?.operationContext??Hp.createFresh(),this.projectionAdmission=r?.projectionAdmission,this.handlerRegistry=new GO(this.logger,r?.handlerRegistrationMode??"combined"),this.repository=new XO(i,n,o,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 Lx(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:i}=e,n=this.handlerRegistry.getValidator(t);if(!n)throw Error(`No job type declared: ${t}`);let o=n.validateAndParse(r);if(o===null)throw Error(`Invalid job data for type: ${t}`);let s=Date.now(),a=to(),c=i?.rootJobId??this.operationContext.current()?.provenance.rootJobId??a,l=this.createJobProvenance(a,c,i),u=i?.metadata??{operationType:"data_processing"},{provenance:d,...p}=u,m={id:a,type:t,data:JSON.stringify(o),status:He.PENDING,priority:i?.priority??0,maxRetries:i?.maxRetries??3,retryCount:0,source:i?.source??null,metadata:{...p,...i?.deduplicationKey&&{deduplicationKey:i.deduplicationKey},rootJobId:c,provenance:l},createdAt:s,scheduledFor:i?.delayMs?s+i.delayMs:s,result:null,lastError:null,startedAt:null,completedAt:null},y,g=()=>{y?.rollback(),y=void 0};try{let b=await this.repository.enqueueAtomic({jobData:m,strategy:i?.deduplication,deduplicationKey:i?.deduplicationKey,beforeInsert:async()=>{y=await this.projectionAdmission?.reserveJobAdmission(l)},onInsertRollback:g});if(y?.commit(),y=void 0,b.kind==="skipped")this.logger.debug("Skipping duplicate job (already pending)",{type:t,existingJobId:b.jobId});else if(b.kind==="coalesced")this.logger.debug("Coalescing with existing job",{type:t,existingJobId:b.jobId});else{if(b.kind==="replaced")this.logger.debug("Replacing duplicate job",{type:t,oldJobId:b.replacedJobId});this.logger.debug("Job enqueued",{id:b.jobId,type:t,priority:m.priority,rootJobId:m.metadata.rootJobId})}return b.jobId}catch(b){throw g(),this.logger.error("Failed to enqueue job",{type:t,error:at(b)}),b}}createJobProvenance(e,t,r){let i=this.operationContext.current(),n=r?.metadata.provenance??i?.provenance,o=n?.rootJobId===t?n:void 0,s=i?.provenance.rootJobId===t?i.operationId:void 0,a=r?.projection,c=a?[...o?.projectionLineage??[],a.id]:[...o?.projectionLineage??[]],l=a?.id??o?.projectionId;return Ro.parse({rootJobId:t,causationId:s??o?.causationId??e,...l?{projectionId:l}:{},projectionLineage:c,...a?.sourceEntity?{sourceEntity:a.sourceEntity}:o?.sourceEntity?{sourceEntity:o.sourceEntity}:{},derivationDepth:c.length})}async dequeue(e){let t=this.handlerRegistry.getRegisteredTypes();if(t.length===0)return null;let r=e??await this.getDirectClaimOptions(),i=Date.now(),n=await this.repository.claimNextReady({...r,now:i,attemptId:to(),executableTypes:t});if(!n)return null;return this.logger.debug("Job dequeued",{id:n.id,type:n.type,priority:n.priority,retryCount:n.retryCount,attemptId:n.attemptId,workerSlotId:n.workerSlotId,workerSessionId:n.workerSessionId}),n}async startWorkerSession(e,t,r=hs){await this.repository.startWorkerSession(e,t,Date.now(),r)}heartbeatWorkerSession(e,t,r=hs){return this.repository.heartbeatWorkerSession(e,t,Date.now(),r)}endWorkerSession(e,t){return this.repository.endWorkerSession(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.directWorkerSlotId,this.directWorkerSessionId,Date.now(),this.directLeaseDurationMs),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,i=Date.now()+(e.timeoutMs??30000),n=async(o)=>{e.signal?.throwIfAborted();let{totals:s}=await this.getDiagnostics(),c=s.pending===0&&s.processing===0?o??Date.now():null;if(c!==null&&Date.now()-c>=t)return;if(Date.now()>=i)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 HV=x(()=>{np();a$();op();gs();VO();UV();ZV();Po();eR()});var tR=()=>{};var KV=x(()=>{np();gs();op();gs();tR();eR()});var JV=x(()=>{gs();tR()});var zet;var VV=x(()=>{Po();Re();ip();zet=f.preprocess((e)=>{if(typeof e!=="string")return e;return JSON.parse(e)},f.record(f.string(),f.unknown()))});var Let;var WV=x(()=>{Re();Let=f.record(f.string(),f.unknown())});var GV=x(()=>{Po();np()});var QV=x(()=>{HV();KV();JV();VV();WV();op();gs();ip();GV()});var rR={};tr(rR,{LEGACY_PROJECTION_JOB_TYPES:()=>XV,LEGACY_PROJECTION_RETIREMENT_REASON:()=>t7,legacyProjectionJobTypeSchema:()=>e7,retireLegacyProjectionJob:()=>Nke});import{existsSync as Rke}from"fs";import{resolve as Pke}from"path";function YV(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 zke(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 Nke(e){let t=Pke(e.databasePath);if(!Rke(t))throw Error(`Job database does not exist: ${t}`);let r=e7.parse(e.jobType),i=Kp.createFresh({url:`file:${t}`});try{let n=await i.getStatus(e.jobId);if(!n)throw Error(`Job not found: ${e.jobId}`);if(zke(n,r),e.dryRun){if(e.confirmation!==void 0)throw Error("Dry-run recovery must not include confirmation");return{databasePath:t,job:YV(n),retired:!1}}let o=`retire:${n.id}`;if(e.confirmation!==o)throw Error(`Refusing to retire ${n.id}; expected --confirm ${o}`);let s=await i.retireUnownedActiveJob({jobId:n.id,expectedType:r,reason:t7,now:e.now?.()??Date.now()});if(!s)throw Error(`Job ${n.id} changed or acquired ownership before retirement`);return{databasePath:t,job:YV(s),retired:!0}}finally{i.close()}}var XV,e7,t7="Retired legacy projection job superseded by scheduler-owned projections";var nR=x(()=>{QV();Re();XV=["conversation-memory:project","skill:project","swot:derive","topic:project"],e7=f.enum(XV)});function er(e,t,r,i,n){return n7.parse({id:e,operation:t,count:r,targetProbeCount:i,settleMs:n})}function oR(e){return Vp.parse(structuredClone(jke[e]))}function Wp(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 jx(e,t={}){let r=t.fetchImpl??fetch,i=t.now??(()=>new Date),n=t.timeoutMs??20000,o=i(),s=new AbortController,a=setTimeout(()=>s.abort(),n);try{let c=await r(e,{method:"GET",signal:s.signal});return await c.arrayBuffer(),iR.parse({timestamp:o.toISOString(),endpoint:new URL(e).pathname,status:c.status,durationMs:Math.max(0,i().getTime()-o.getTime()),ok:c.ok})}catch(c){return iR.parse({timestamp:o.toISOString(),endpoint:new URL(e).pathname,status:0,durationMs:Math.max(0,i().getTime()-o.getTime()),ok:!1,error:qke(c)})}finally{clearTimeout(a)}}async function sR(e,t){let r=Vp.parse(e),i=[],n,o=await t.prepare(r),s,a;try{try{await t.startMonitoring()}catch(c){n=`monitor: ${Bx(c)}`}if(!n)for(let c of r.phases)try{let l=i7.parse(await t.executePhase(c,o));if(i.push(l),!l.success){n=`${c.id}: ${l.error??"phase failed"}`;break}}catch(l){let u=Bx(l);i.push({id:c.id,operation:c.operation,count:c.count,success:!1,error:u}),n=`${c.id}: ${u}`;break}}finally{try{if(s=o7.parse(await t.cleanup(o)),!s.success&&!n)n=s.error??"cleanup failed"}catch(c){let l=Bx(c);s={success:!1,probesRemaining:0,error:l},n??=`cleanup: ${l}`}try{a=s7.parse(await t.stopMonitoring())}catch(c){let l=Bx(c);a={health:[],runtime:[]},n??=`monitor: ${l}`}}return n??=c7(a,r.maximumExternalAiCalls??0),a7.parse({profile:r.profile,success:n===void 0&&i.length===r.phases.length&&s.success,baseline:o,phases:i,cleanup:s,metrics:a,...n?{failure:n}:{}})}function c7(e,t=0){let r=e.health.find((o)=>!o.ok);if(r)return`health: ${r.endpoint} unavailable`;let i=e.externalAiCalls??0;if(i>t)return t===0?`external AI: observed ${i} call(s)`:`external AI: observed ${i} 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 qke(e){if(e instanceof Error)return`${e.name}: ${e.message}`;return String(e)}function Bx(e){return at(e)}var Jp,r7,n7,Vp,Dke,iR,Lke,i7,o7,Bke,s7,a7,jke;var qx=x(()=>{Re();Jp=f.enum(["regression","load","stress"]),r7=f.enum(["add","update","rename","delete"]),n7=f.object({id:f.string().min(1),operation:r7,count:f.number().int().positive().max(700),targetProbeCount:f.number().int().min(0).max(700),settleMs:f.number().int().nonnegative().max(300000)}),Vp=f.object({profile:Jp,maximumProbeCount:f.number().int().positive().max(700),maximumExternalAiCalls:f.number().int().nonnegative().max(1e4).optional(),phases:f.array(n7).min(1)}),Dke=f.object({entities:f.number().int().nonnegative(),notes:f.number().int().nonnegative(),version:f.string().min(1)}),iR=f.object({timestamp:f.iso.datetime(),endpoint:f.string().startsWith("/"),status:f.number().int().nonnegative(),durationMs:f.number().nonnegative(),ok:f.boolean(),error:f.string().optional()}),Lke=f.object({timestamp:f.iso.datetime(),cpuPercent:f.number().nonnegative(),memoryPercent:f.number().nonnegative(),pids:f.number().int().nonnegative()}),i7=f.object({id:f.string().min(1),operation:r7,count:f.number().int().positive(),success:f.boolean(),commitLatencyMs:f.number().nonnegative().optional(),persistenceLatencyMs:f.number().nonnegative().optional(),error:f.string().optional()}),o7=f.object({success:f.boolean(),probesRemaining:f.number().int().nonnegative(),finalEntities:f.number().int().nonnegative().optional(),finalNotes:f.number().int().nonnegative().optional(),contentTreeRestored:f.boolean().optional(),error:f.string().optional()}),Bke=f.object({status:f.string(),restartCount:f.number().int().nonnegative(),oomKilled:f.boolean()}),s7=f.object({health:f.array(iR),runtime:f.array(Lke),externalAiCalls:f.number().int().nonnegative().optional(),container:Bke.optional()}),a7=f.object({profile:Jp,success:f.boolean(),baseline:Dke,phases:f.array(i7),cleanup:o7,metrics:s7,failure:f.string().optional()}),jke={regression:{profile:"regression",maximumProbeCount:20,phases:[er("add20","add",20,20,0),er("update20","update",20,20,30000),er("delete20","delete",20,0,150000)]},load:{profile:"load",maximumProbeCount:350,phases:[er("add50","add",50,50,0),er("add150","add",100,150,0),er("add350","add",200,350,0),er("update350a","update",350,350,45000),er("rename100","rename",100,350,45000),er("update350b","update",350,350,45000),er("delete350","delete",350,0,150000)]},stress:{profile:"stress",maximumProbeCount:700,phases:[er("add50","add",50,50,0),er("add150","add",100,150,0),er("add350","add",200,350,0),er("add700","add",350,700,0),er("update700a","update",700,700,45000),er("rename200","rename",200,700,45000),er("update700b","update",700,700,45000),er("delete700","delete",700,0,150000)]}}});import{spawn as Uke}from"child_process";async function l7(e,t,r,i){let n=await e(t,r,i);if(n.exitCode!==0)throw Ei(t,r,n);return n}function Ei(e,t,r){let i=r.stderr.trim()||r.stdout.trim();return Error(`${e} ${t.join(" ")} exited with ${r.exitCode}${i?`: ${i}`:""}`)}var mo=async(e,t,r={})=>new Promise((i,n)=>{let o=Uke(e,[...t],{cwd:r.cwd,env:r.env?{...process.env,...r.env}:process.env,stdio:["pipe","pipe","pipe"]}),s="",a="";o.stdout.setEncoding("utf8"),o.stderr.setEncoding("utf8"),o.stdout.on("data",(c)=>{s+=c}),o.stderr.on("data",(c)=>{a+=c}),o.on("error",n),o.on("close",(c)=>{i({exitCode:c??1,stdout:s,stderr:a})}),o.stdin.end(r.stdin)});var Gp=()=>{};class Tu{#e;#t;dir;constructor(e,t,r){this.#e=e,this.dir=t,this.#t=r}static async clone(e,t,r,i){let n=new Tu(e,r,i);return await l7(e,"git",["-c","credential.helper=","-c",`credential.helper=${u7}`,"clone","--branch","main","--single-branch",`https://github.com/${t}.git`,r],{env:n.environment()}),await n.run(["config","--local","credential.helper",u7]),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 Ei("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 u7='!f() { test "$1" = get && echo username=x-access-token && echo "password=$GH_TOKEN"; }; f';var d7=x(()=>{Gp()});function Qp(e){return e.entityCounts.find((t)=>t.entityType==="note")?.count??0}class aR{#e;#t=[];#r=[];#n=new Set(["/health/ready"]);#i=!0;#o;#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 jx(`https://${this.#e.domain}${e}`,{fetchImpl:this.#e.fetchImpl,now:this.#e.now,timeoutMs:5000})).status!==404)this.#n.add(e)}start(){this.#i=!1,this.#a=void 0,this.#c=this.#t.length,this.#l=void 0,this.#s=this.#e.now().toISOString(),this.#o=Promise.all([this.#f(),this.#m()]).then(()=>{return}).catch((e)=>{this.#a=e,this.#i=!0})}async stop(){this.#i=!0,await this.#o}async waitForHealthSnapshot(e){return this.waitForEntityBaseline(void 0,void 0,e)}async waitForEntityBaseline(e,t,r){let i=this.#e.now().getTime();while(this.#e.now().getTime()-i<r){let n=await this.fetchHealthPayload();if(this.#d(n,e,t))return n;await this.#e.sleep(5000)}return}async waitForStableEntityBaseline(e,t,r){let i=this.#e.now().getTime(),n=0;while(this.#e.now().getTime()-i<r){let o=await this.fetchHealthPayload();if(this.#d(o,e,t)){if(n+=1,n===2)return o}else n=0;await this.#e.sleep(5000)}return}async fetchHealthPayload(){let e=this.#e.now(),t=new AbortController,r=setTimeout(()=>t.abort(),20000);try{let i=await this.#e.fetchImpl(`https://${this.#e.domain}/health/operate`,{signal:t.signal}),n=await i.text();if(this.#t.push({timestamp:e.toISOString(),endpoint:"/health/operate",status:i.status,durationMs:Math.max(0,this.#e.now().getTime()-e.getTime()),ok:i.ok}),!i.ok)return;return Mke.parse(JSON.parse(n)).app}catch(i){this.#t.push({timestamp:e.toISOString(),endpoint:"/health/operate",status:0,durationMs:Math.max(0,this.#e.now().getTime()-e.getTime()),ok:!1,error:i instanceof Error?`${i.name}: ${i.message}`:String(i)});return}finally{clearTimeout(r)}}#d(e,t,r){return e!==void 0&&(t===void 0||Qp(e)===t)&&(r===void 0||e.entities===r)}async#f(){while(!this.#i){for(let e of this.#n)this.#t.push(await jx(`https://${this.#e.domain}${e}`,{fetchImpl:this.#e.fetchImpl,now:this.#e.now,timeoutMs:20000}));await this.#e.sleep(4000)}}async#m(){while(!this.#i){let e=await this.#e.sampleRuntime();if(e)this.#r.push(e);await this.#e.sleep(1000)}}}var Mke;var f7=x(()=>{Re();qx();Mke=f.object({status:f.literal("ready"),operationalStatus:f.literal("operational"),app:f.object({version:f.string(),entities:f.number().int().nonnegative(),entityCounts:f.array(f.object({entityType:f.string(),count:f.number().int().nonnegative()})).default([])})})});var Ux={};tr(Ux,{applyDirectorySyncStressPhase:()=>x7,cleanupDirectorySyncStress:()=>g7,listProbeFiles:()=>Qa,parseStressRuntimeSample:()=>S7,removeProbeFiles:()=>mR,runDeployedDirectorySyncStress:()=>m7,runStressCommand:()=>mo,verifyDirectorySyncStressAccess:()=>h7});import{chmod as Fke,mkdir as lR,mkdtemp as uR,readFile as Zke,readdir as Hke,rename as Kke,rm as Xp,writeFile as Xn}from"fs/promises";import{tmpdir as dR}from"os";import{join as xt,resolve as fR}from"path";async function m7(e){let t=e.now??(()=>new Date),r=t().toISOString(),i=hR(r),n=fR(e.artifactsDir??xt(e.rootDir,".brains-ops","stress",i));await lR(n,{recursive:!0});let{pilot:o,user:s}=await pR(e.rootDir,e.handle);Wp({handle:s.handle,domain:s.domain,contentRepo:s.contentRepo,confirmation:e.confirmation});let a=Jp.parse(e.profile),c=e.plan?Vp.parse(e.plan):oR(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)b7(s);let l=Jke.parse(e.env??process.env),u=new y7({runId:i,artifactsDir:n,user:s,githubOrg:o.githubOrg,serverLabel:`${o.contentRepoPrefix}${s.handle}`,environment:l,fetchImpl:e.fetchImpl??fetch,commandRunner:e.commandRunner??mo,logger:e.logger??console.info,now:t,sleep:e.sleep??Bun.sleep}),d;try{d=await sR(c,u)}finally{await u.dispose()}let p={runId:i,artifactsDir:n,target:{handle:s.handle,domain:s.domain,contentRepo:`${o.githubOrg}/${s.contentRepo}`},startedAt:r,completedAt:t().toISOString(),report:d};return await Yke(p),p}async function h7(e){let r=(e.now??(()=>new Date))().toISOString(),i=hR(r),n=fR(e.artifactsDir??xt(e.rootDir,".brains-ops","stress",`access-check-${i}`));await lR(n,{recursive:!0});let{pilot:o,user:s}=await pR(e.rootDir,e.handle);Wp({handle:s.handle,domain:s.domain,contentRepo:s.contentRepo,confirmation:e.confirmation}),b7(s);let a=(e.env??process.env).CONTENT_REPO_ADMIN_TOKEN;if(!a)throw Error("Missing CONTENT_REPO_ADMIN_TOKEN");let c=await uR(xt(dR(),"brains-ops-directory-sync-access-check-"));try{let l=await Tu.clone(e.commandRunner??mo,`${o.githubOrg}/${s.contentRepo}`,xt(c,"content"),a),u=await l.output(["rev-parse","HEAD"]);await l.run(["push","--dry-run","origin",`HEAD:refs/heads/ops/directory-sync-stress-access-check-${i}`]);let d={success:!0,artifactsDir:n,checkedAt:r,remoteHead:u,target:{handle:s.handle,domain:s.domain,contentRepo:`${o.githubOrg}/${s.contentRepo}`}};return await Xn(xt(n,"access-check.json"),`${JSON.stringify(d,null,2)}
467
466
  `),d}finally{await Xp(c,{recursive:!0,force:!0})}}async function g7(e){let t=e.now??(()=>new Date),r=fR(e.artifactsDir??xt(e.rootDir,".brains-ops","stress",`cleanup-${hR(t().toISOString())}`));await lR(r,{recursive:!0});let{pilot:i,user:n}=await pR(e.rootDir,e.handle);Wp({handle:n.handle,domain:n.domain,contentRepo:n.contentRepo,confirmation:e.confirmation});let o=(e.env??process.env).CONTENT_REPO_ADMIN_TOKEN;if(!o)throw Error("Missing CONTENT_REPO_ADMIN_TOKEN");let s=e.commandRunner??mo,a=e.logger??console.info,c=await uR(xt(dR(),"brains-ops-directory-sync-cleanup-")),l=xt(c,"content");try{let u=await Tu.clone(s,`${i.githubOrg}/${n.contentRepo}`,l,o),d=await mR(u.dir),p;if(d>0)await u.commitAll("test(directory-sync): clean residual stress probes"),await u.pushMainWithRebase(),p=await u.output(["rev-parse","HEAD"]),a(`Removed ${d} directory-sync stress probes`);let m=(await Qa(u.dir)).length,y=m===0?await u.pruneStressBackupBranches():[],g={success:m===0,artifactsDir:r,probesRemoved:d,probesRemaining:m,backupBranchesDeleted:y,...p?{cleanupCommit:p}:{}};return await Xn(xt(r,"cleanup.json"),`${JSON.stringify(g,null,2)}
468
- `),g}finally{await Xp(c,{recursive:!0,force:!0})}}class y7{#e;#t;#r;#n;#i;#o;#a;#s;#c;#l;#d;constructor(e){this.#e=e,this.#t=new aR({domain:e.user.domain,fetchImpl:e.fetchImpl,now:e.now,sleep:e.sleep,sampleRuntime:()=>this.#y()})}async prepare(e){this.#r=await uR(xt(dR(),"brains-ops-directory-sync-stress-"));let t=xt(this.#r,"content");this.#i=xt(this.#r,"id_ed25519"),this.#o=xt(this.#r,"known_hosts"),this.#a=await this.#m(),await Xn(this.#i,Yke(this.#e.environment.KAMAL_SSH_PRIVATE_KEY),{mode:384}),await Zke(this.#i,384);let r=await this.#b("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 Xn(this.#o,r.stdout,{mode:384});let i=await this.#h(["docker","ps","--filter","label=service=rover","--filter","label=role=web","--format","{{.Names}}"]);if(this.#s=i.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 Tu.clone(this.#e.commandRunner,`${this.#e.githubOrg}/${this.#e.user.contentRepo}`,t,this.#e.environment.CONTENT_REPO_ADMIN_TOKEN);if(this.#n=n,(await Qa(n.dir)).length>0)throw Error("Directory-sync stress probes already exist");let o=await n.output(["rev-parse","HEAD"]);this.#l=await n.output(["rev-parse","HEAD^{tree}"]),this.#d=await this.#f();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 Xn(xt(this.#e.artifactsDir,"state.json"),`${JSON.stringify({runId:this.#e.runId,profile:e.profile,originalHead:o,originalTree:this.#l,backupBranch:this.#c,baseline:{entities:s.entities,notes:Qp(s),version:s.version}},null,2)}
467
+ `),g}finally{await Xp(c,{recursive:!0,force:!0})}}class y7{#e;#t;#r;#n;#i;#o;#a;#s;#c;#l;#d;constructor(e){this.#e=e,this.#t=new aR({domain:e.user.domain,fetchImpl:e.fetchImpl,now:e.now,sleep:e.sleep,sampleRuntime:()=>this.#y()})}async prepare(e){this.#r=await uR(xt(dR(),"brains-ops-directory-sync-stress-"));let t=xt(this.#r,"content");this.#i=xt(this.#r,"id_ed25519"),this.#o=xt(this.#r,"known_hosts"),this.#a=await this.#m(),await Xn(this.#i,Qke(this.#e.environment.KAMAL_SSH_PRIVATE_KEY),{mode:384}),await Fke(this.#i,384);let r=await this.#b("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 Xn(this.#o,r.stdout,{mode:384});let i=await this.#h(["docker","ps","--filter","label=service=rover","--filter","label=role=web","--format","{{.Names}}"]);if(this.#s=i.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 Tu.clone(this.#e.commandRunner,`${this.#e.githubOrg}/${this.#e.user.contentRepo}`,t,this.#e.environment.CONTENT_REPO_ADMIN_TOKEN);if(this.#n=n,(await Qa(n.dir)).length>0)throw Error("Directory-sync stress probes already exist");let o=await n.output(["rev-parse","HEAD"]);this.#l=await n.output(["rev-parse","HEAD^{tree}"]),this.#d=await this.#f();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 Xn(xt(this.#e.artifactsDir,"state.json"),`${JSON.stringify({runId:this.#e.runId,profile:e.profile,originalHead:o,originalTree:this.#l,backupBranch:this.#c,baseline:{entities:s.entities,notes:Qp(s),version:s.version}},null,2)}
469
468
  `),this.#e.logger(`Prepared ${e.profile} directory-sync stress run for ${this.#e.user.handle}`),{entities:s.entities,notes:Qp(s),version:s.version}}async startMonitoring(){this.#x(),this.#t.start()}async executePhase(e,t){this.#x();let r=this.#n;if(!r)throw Error("Directory-sync stress checkout is not prepared");await r.sync();let i=this.#t.healthSamples.length,n=this.#e.now().getTime(),o=await this.#g();if(o?.pending!==0||o.processing!==0)return Cu(e,"health did not provide a drained queue before the phase");await x7(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.#p(a,900000);if(c===void 0)return Cu(e,"runtime did not pull the phase commit");let l;if(e.operation==="rename"){let m=t.notes+e.targetProbeCount;if(e.settleMs>0)await this.#e.sleep(e.settleMs);let y=await this.#t.waitForStableEntityBaseline(m,void 0,1200000);if(l=this.#e.now().getTime()-s,!y)return Cu(e,`health did not stabilize at ${m} notes`,c,l)}else if(e.operation==="add"||e.operation==="delete"){let m=t.notes+e.targetProbeCount,y=this.#e.now().getTime(),g=await this.#t.waitForEntityBaseline(m,void 0,1200000);if(l=this.#e.now().getTime()-y,!g)return Cu(e,`health did not reach ${m} notes`,c,l)}if(e.operation!=="rename"&&e.settleMs>0)await this.#e.sleep(e.settleMs);let u=e.operation==="delete"?0:Math.ceil(e.count/50);if(!await this.#u(o.completedImports+u,1200000))return Cu(e,`health did not observe ${u} completed import job(s) with a drained queue`,c,l);let p=this.#t.healthSamples.slice(i).find((m)=>!m.ok);if(p)return Cu(e,`${p.endpoint} unavailable (${p.status===0?p.error??"unknown":p.status})`,c,l);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,...l===void 0?{}:{persistenceLatencyMs:l}}}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 mR(t.dir)>0)await t.commitAll("test(directory-sync): remove stress probes"),await t.pushMainWithRebase();let i=(await Qa(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=i===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:i,...n?{finalEntities:n.entities,finalNotes:Qp(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 Qa(t.dir)).length,error:at(r)}}}async stopMonitoring(){await this.#t.stop(),await Xn(xt(this.#e.artifactsDir,"health-samples.json"),`${JSON.stringify(this.#t.healthSamples,null,2)}
470
- `);let e=0;if(this.#s&&this.#t.startedAt){let i=await this.#h(["docker","logs","--since",this.#t.startedAt,this.#s],!1),n=`${i.stdout}${i.stderr}`;e=n.match(/\] ai:usage \{/g)?.length??0,await Xn(xt(this.#e.artifactsDir,"runtime.log"),n)}let t=await this.#f(),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 Xp(this.#r,{recursive:!0,force:!0})}async#f(){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=f.array(f.object({RestartCount:f.number().int().nonnegative(),State:f.object({Status:f.string(),OOMKilled:f.boolean(),StartedAt:f.string().min(1)})})).parse(JSON.parse(e.stdout))}catch(o){throw Error(`Could not read docker inspect output for ${this.#s}`,{cause:o})}let r=t[0];if(!r)throw Error("docker inspect reported no such container");let i=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(i,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 i=Wke.parse(await t.json()).servers[0];if(i?.status!=="running")throw Error("Smoke server is not running");return i.public_net.ipv4.ip}async#p(e,t){let r=this.#s;if(!r)throw Error("Directory-sync stress container is not prepared");let i=this.#e.now().getTime();while(this.#e.now().getTime()-i<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()-i;await this.#e.sleep(5000)}return}async#g(){let e=new AbortController,t=setTimeout(()=>e.abort(),20000),r;try{let o=await this.#e.fetchImpl(`https://${this.#e.user.domain}/health/operate`,{method:"GET",signal:e.signal});if(!o.ok)return;r=await o.json()}catch{return}finally{clearTimeout(t)}let i=Gke.safeParse(r);if(!i.success)throw Error(`Unexpected /health/operate payload from ${this.#e.user.domain}`,{cause:i.error});let n=i.data.resources.queue.byType.filter((o)=>o.type==="directory-sync:directory-import"&&o.status==="completed").reduce((o,s)=>o+s.count,0);return{pending:i.data.resources.queue.totals.pending,processing:i.data.resources.queue.totals.processing,completedImports:n}}async#u(e,t){let r=this.#e.now().getTime(),i=0;while(this.#e.now().getTime()-r<t){let n=await this.#g();if(n?.pending===0&&n.processing===0&&n.completedImports>=e){if(i+=1,i===2)return!0}else i=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(["timeout","15","docker","stats","--no-stream","--format","{{.CPUPerc}},{{.MemPerc}},{{.PIDs}}",e],!1);return S7(t.stdout.trim(),this.#e.now().toISOString())}async#h(e,t=!0){let r=this.#i,i=this.#o,n=this.#a;if(!r||!i||!n)throw Error("Directory-sync stress SSH access is not prepared");let o=await this.#b("ssh",["-i",r,"-o","BatchMode=yes","-o","IdentitiesOnly=yes","-o","ConnectTimeout=10","-o","StrictHostKeyChecking=yes","-o",`UserKnownHostsFile=${i}`,`root@${n}`,...e]);if(t&&o.exitCode!==0)throw Ei("ssh",e,o);return o}async#b(e,t,r){return this.#e.commandRunner(e,t,r)}#x(){if(!this.#n||!this.#i||!this.#o||!this.#a||!this.#s)throw Error("Directory-sync stress driver is not prepared")}}function b7(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 pR(e,t){let r=await Ct(e),i=r.users.find((n)=>n.handle===t);if(!i)throw Error(`Unknown pilot user: ${t}`);return{pilot:r.pilot,user:i}}async function x7(e,t){let r=await Qa(e);switch(t.operation){case"add":{let i=t.targetProbeCount-r.length;if(i!==t.count)throw Error(`${t.id} expected to add ${t.count} probes from ${r.length}`);let n=r.map(Qke).filter((s)=>s!==void 0),o=n.length===0?1:Math.max(...n)+1;for(let s=o;s<o+i;s+=1){let a=String(s).padStart(3,"0");await Xn(xt(e,`directory-sync-stress-${a}.md`),["---",`title: "Directory Sync Stress ${a}"`,"---","",`Deterministic directory-sync stress probe ${a}.`,"Payload: abcdefghijklmnopqrstuvwxyz-0123456789-abcdefghijklmnopqrstuvwxyz.",""].join(`
471
- `))}break}case"update":{if(r.length!==t.count)throw Error(`${t.id} expected ${t.count} probes, found ${r.length}`);for(let i of r){let n=xt(e,i),o=await Hke(n,"utf8");await Xn(n,`${o.trimEnd()}
469
+ `);let e=0;if(this.#s&&this.#t.startedAt){let i=await this.#h(["docker","logs","--since",this.#t.startedAt,this.#s],!1),n=`${i.stdout}${i.stderr}`;e=n.match(/\] ai:usage \{/g)?.length??0,await Xn(xt(this.#e.artifactsDir,"runtime.log"),n)}let t=await this.#f(),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 Xp(this.#r,{recursive:!0,force:!0})}async#f(){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=f.array(f.object({RestartCount:f.number().int().nonnegative(),State:f.object({Status:f.string(),OOMKilled:f.boolean(),StartedAt:f.string().min(1)})})).parse(JSON.parse(e.stdout))}catch(o){throw Error(`Could not read docker inspect output for ${this.#s}`,{cause:o})}let r=t[0];if(!r)throw Error("docker inspect reported no such container");let i=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(i,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 i=Vke.parse(await t.json()).servers[0];if(i?.status!=="running")throw Error("Smoke server is not running");return i.public_net.ipv4.ip}async#p(e,t){let r=this.#s;if(!r)throw Error("Directory-sync stress container is not prepared");let i=this.#e.now().getTime();while(this.#e.now().getTime()-i<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()-i;await this.#e.sleep(5000)}return}async#g(){let e=new AbortController,t=setTimeout(()=>e.abort(),20000),r;try{let o=await this.#e.fetchImpl(`https://${this.#e.user.domain}/health/operate`,{method:"GET",signal:e.signal});if(!o.ok)return;r=await o.json()}catch{return}finally{clearTimeout(t)}let i=Wke.safeParse(r);if(!i.success)throw Error(`Unexpected /health/operate payload from ${this.#e.user.domain}`,{cause:i.error});let n=i.data.resources.queue.byType.filter((o)=>o.type==="directory-sync:directory-import"&&o.status==="completed").reduce((o,s)=>o+s.count,0);return{pending:i.data.resources.queue.totals.pending,processing:i.data.resources.queue.totals.processing,completedImports:n}}async#u(e,t){let r=this.#e.now().getTime(),i=0;while(this.#e.now().getTime()-r<t){let n=await this.#g();if(n?.pending===0&&n.processing===0&&n.completedImports>=e){if(i+=1,i===2)return!0}else i=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(["timeout","15","docker","stats","--no-stream","--format","{{.CPUPerc}},{{.MemPerc}},{{.PIDs}}",e],!1);return S7(t.stdout.trim(),this.#e.now().toISOString())}async#h(e,t=!0){let r=this.#i,i=this.#o,n=this.#a;if(!r||!i||!n)throw Error("Directory-sync stress SSH access is not prepared");let o=await this.#b("ssh",["-i",r,"-o","BatchMode=yes","-o","IdentitiesOnly=yes","-o","ConnectTimeout=10","-o","StrictHostKeyChecking=yes","-o",`UserKnownHostsFile=${i}`,`root@${n}`,...e]);if(t&&o.exitCode!==0)throw Ei("ssh",e,o);return o}async#b(e,t,r){return this.#e.commandRunner(e,t,r)}#x(){if(!this.#n||!this.#i||!this.#o||!this.#a||!this.#s)throw Error("Directory-sync stress driver is not prepared")}}function b7(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 pR(e,t){let r=await Ct(e),i=r.users.find((n)=>n.handle===t);if(!i)throw Error(`Unknown pilot user: ${t}`);return{pilot:r.pilot,user:i}}async function x7(e,t){let r=await Qa(e);switch(t.operation){case"add":{let i=t.targetProbeCount-r.length;if(i!==t.count)throw Error(`${t.id} expected to add ${t.count} probes from ${r.length}`);let n=r.map(Gke).filter((s)=>s!==void 0),o=n.length===0?1:Math.max(...n)+1;for(let s=o;s<o+i;s+=1){let a=String(s).padStart(3,"0");await Xn(xt(e,`directory-sync-stress-${a}.md`),["---",`title: "Directory Sync Stress ${a}"`,"---","",`Deterministic directory-sync stress probe ${a}.`,"Payload: abcdefghijklmnopqrstuvwxyz-0123456789-abcdefghijklmnopqrstuvwxyz.",""].join(`
470
+ `))}break}case"update":{if(r.length!==t.count)throw Error(`${t.id} expected ${t.count} probes, found ${r.length}`);for(let i of r){let n=xt(e,i),o=await Zke(n,"utf8");await Xn(n,`${o.trimEnd()}
472
471
 
473
472
  Update marker: ${t.id}.
474
- `)}break}case"rename":{let i=r.filter((n)=>/^directory-sync-stress-\d+\.md$/.test(n)).slice(0,t.count);if(i.length!==t.count)throw Error(`${t.id} expected ${t.count} unrenamed probes, found ${i.length}`);for(let n of i)await Jke(xt(e,n),xt(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((i)=>Xp(xt(e,i),{force:!0})));break}}}async function Qa(e){return(await Kke(e)).filter((r)=>/^directory-sync-stress-(?:renamed-)?\d+\.md$/.test(r)&&!r.includes("/")).sort()}async function mR(e){let t=await Qa(e);return await Promise.all(t.map((r)=>Xp(xt(e,r),{force:!0}))),t.length}function Qke(e){let t=e.match(/(\d+)\.md$/)?.[1];return t?Number.parseInt(t,10):void 0}function Cu(e,t,r,i){return{id:e.id,operation:e.operation,count:e.count,success:!1,...r===void 0?{}:{commitLatencyMs:r},...i===void 0?{}:{persistenceLatencyMs:i},error:t}}function S7(e,t){let[r,i,n]=e.split(",");if(!r||!i||!n)return;let o=Number.parseFloat(r.replace("%","")),s=Number.parseFloat(i.replace("%","")),a=Number.parseInt(n,10);if(!Number.isFinite(o)||!Number.isFinite(s)||!Number.isFinite(a))return;return{timestamp:t,cpuPercent:o,memoryPercent:s,pids:a}}function Yke(e){return`${e.replace(/\r\n/g,`
473
+ `)}break}case"rename":{let i=r.filter((n)=>/^directory-sync-stress-\d+\.md$/.test(n)).slice(0,t.count);if(i.length!==t.count)throw Error(`${t.id} expected ${t.count} unrenamed probes, found ${i.length}`);for(let n of i)await Kke(xt(e,n),xt(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((i)=>Xp(xt(e,i),{force:!0})));break}}}async function Qa(e){return(await Hke(e)).filter((r)=>/^directory-sync-stress-(?:renamed-)?\d+\.md$/.test(r)&&!r.includes("/")).sort()}async function mR(e){let t=await Qa(e);return await Promise.all(t.map((r)=>Xp(xt(e,r),{force:!0}))),t.length}function Gke(e){let t=e.match(/(\d+)\.md$/)?.[1];return t?Number.parseInt(t,10):void 0}function Cu(e,t,r,i){return{id:e.id,operation:e.operation,count:e.count,success:!1,...r===void 0?{}:{commitLatencyMs:r},...i===void 0?{}:{persistenceLatencyMs:i},error:t}}function S7(e,t){let[r,i,n]=e.split(",");if(!r||!i||!n)return;let o=Number.parseFloat(r.replace("%","")),s=Number.parseFloat(i.replace("%","")),a=Number.parseInt(n,10);if(!Number.isFinite(o)||!Number.isFinite(s)||!Number.isFinite(a))return;return{timestamp:t,cpuPercent:o,memoryPercent:s,pids:a}}function Qke(e){return`${e.replace(/\r\n/g,`
475
474
  `).replace(/\\n/g,`
476
475
  `).trimEnd()}
477
- `}function hR(e){return e.replace(/[-:.TZ]/g,"").slice(0,14)}async function Xke(e){await Xn(xt(e.artifactsDir,"report.json"),`${JSON.stringify(e,null,2)}
478
- `),await Xn(xt(e.artifactsDir,"report.md"),eEe(e))}function eEe(e){let t=e.report.metrics.runtime,r=e.report.metrics.health,i=t.map((a)=>a.cpuPercent).sort((a,c)=>a-c),n=t.map((a)=>a.memoryPercent),o=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"}`} | ${p7(a.commitLatencyMs)} | ${p7(a.persistenceLatencyMs)} |`),"","## Runtime","",`- Samples: ${t.length}`,`- CPU p50/p95/p99/max: ${Yp(cR(i,0.5))} / ${Yp(cR(i,0.95))} / ${Yp(cR(i,0.99))} / ${Yp(i.at(-1))}`,`- Memory max: ${Yp(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: ${o.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(`
476
+ `}function hR(e){return e.replace(/[-:.TZ]/g,"").slice(0,14)}async function Yke(e){await Xn(xt(e.artifactsDir,"report.json"),`${JSON.stringify(e,null,2)}
477
+ `),await Xn(xt(e.artifactsDir,"report.md"),Xke(e))}function Xke(e){let t=e.report.metrics.runtime,r=e.report.metrics.health,i=t.map((a)=>a.cpuPercent).sort((a,c)=>a-c),n=t.map((a)=>a.memoryPercent),o=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"}`} | ${p7(a.commitLatencyMs)} | ${p7(a.persistenceLatencyMs)} |`),"","## Runtime","",`- Samples: ${t.length}`,`- CPU p50/p95/p99/max: ${Yp(cR(i,0.5))} / ${Yp(cR(i,0.95))} / ${Yp(cR(i,0.99))} / ${Yp(i.at(-1))}`,`- Memory max: ${Yp(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: ${o.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(`
479
478
  `)}
480
- `}function cR(e,t){if(e.length===0)return;let r=Math.max(0,Math.ceil(e.length*t)-1);return e[r]}function Yp(e){return e===void 0?"n/a":`${e.toFixed(2)}%`}function p7(e){return e===void 0?"n/a":`${(e/1000).toFixed(1)}s`}var Vke,Wke,Gke;var em=x(()=>{Re();qx();Ln();Gp();d7();f7();Gp();Vke=f.object({HCLOUD_TOKEN:f.string().min(1),KAMAL_SSH_PRIVATE_KEY:f.string().min(1),CONTENT_REPO_ADMIN_TOKEN:f.string().min(1)}),Wke=f.object({servers:f.array(f.object({id:f.number().int(),status:f.string(),public_net:f.object({ipv4:f.object({ip:f.string().min(1)})})}))}),Gke=f.object({status:f.literal("ready"),operationalStatus:f.literal("operational"),resources:f.object({queue:f.object({totals:f.object({pending:f.number().int().nonnegative(),processing:f.number().int().nonnegative()}),byType:f.array(f.object({type:f.string(),status:f.string(),count:f.number().int().nonnegative()}))})})})});var w7=x(()=>{Rs()});var tEe="/usr/local/sbin/brains-health-watchdog",rEe="ai.rizom.brain.watchdog",nEe="true",gR,v7,ztt;var _7=x(async()=>{w7();gR=`${rEe}=${nEe}`,v7=`#!/usr/bin/env bash
479
+ `}function cR(e,t){if(e.length===0)return;let r=Math.max(0,Math.ceil(e.length*t)-1);return e[r]}function Yp(e){return e===void 0?"n/a":`${e.toFixed(2)}%`}function p7(e){return e===void 0?"n/a":`${(e/1000).toFixed(1)}s`}var Jke,Vke,Wke;var em=x(()=>{Re();qx();Ln();Gp();d7();f7();Gp();Jke=f.object({HCLOUD_TOKEN:f.string().min(1),KAMAL_SSH_PRIVATE_KEY:f.string().min(1),CONTENT_REPO_ADMIN_TOKEN:f.string().min(1)}),Vke=f.object({servers:f.array(f.object({id:f.number().int(),status:f.string(),public_net:f.object({ipv4:f.object({ip:f.string().min(1)})})}))}),Wke=f.object({status:f.literal("ready"),operationalStatus:f.literal("operational"),resources:f.object({queue:f.object({totals:f.object({pending:f.number().int().nonnegative(),processing:f.number().int().nonnegative()}),byType:f.array(f.object({type:f.string(),status:f.string(),count:f.number().int().nonnegative()}))})})})});var w7=x(()=>{Rs()});var eEe="/usr/local/sbin/brains-health-watchdog",tEe="ai.rizom.brain.watchdog",rEe="true",gR,v7,Ptt;var _7=x(async()=>{w7();gR=`${tEe}=${rEe}`,v7=`#!/usr/bin/env bash
481
480
  set -euo pipefail
482
481
  umask 077
483
482
 
@@ -536,14 +535,14 @@ while read -r container_id; do
536
535
  logger -t brains-health-watchdog "restarting unhealthy container=$container_name service=$service_name incident=$incident_path"
537
536
  docker restart "$container_id"
538
537
  done < <(docker ps --filter health=unhealthy --filter label=${gR} --format '{{.ID}}')
539
- `,ztt=`[Unit]
538
+ `,Ptt=`[Unit]
540
539
  Description=Restart persistently unhealthy Brain containers
541
540
  After=docker.service
542
541
  Requires=docker.service
543
542
 
544
543
  [Service]
545
544
  Type=oneshot
546
- ExecStart=${tEe}
545
+ ExecStart=${eEe}
547
546
  `});var E7=`#!/usr/bin/env bash
548
547
  set -euo pipefail
549
548
  umask 077
@@ -771,12 +770,12 @@ deployed_container_restarted=false
771
770
  EOF
772
771
  pass "fleet watchdog isolation smoke completed"
773
772
  printf 'REMOTE_ARTIFACT_DIR=%s\\n' "$remote_dir"
774
- `;var k7=()=>{};var SR={};tr(SR,{assertHealthWatchdogSmokeTarget:()=>Fx,cleanupHealthWatchdogSmoke:()=>$7,renderHealthWatchdogSmokeRemoteScript:()=>xR,runHealthWatchdogSmoke:()=>C7});import{access as oEe,chmod as sEe,mkdir as I7,mkdtemp as aEe,rm as bR,writeFile as $u}from"fs/promises";import{tmpdir as cEe}from"os";import{join as Ii,resolve as A7}from"path";function Fx(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 xR(){return E7.replace("__WATCHDOG_PAYLOAD_BASE64__",Buffer.from(v7,"utf8").toString("base64")).replace("__WATCHDOG_LABEL_FILTER__",gR)}async function C7(e){let t=A7(e.artifactsDir??Ii(e.rootDir,".brains-ops","watchdog-smoke",e.runId)),r=await O7(e.rootDir,e.handle);Fx({handle:r.user.handle,domain:r.user.domain,confirmation:e.confirmation,runId:e.runId}),await I7(t,{recursive:!0});let i=T7.parse(e.env??process.env),n=e.commandRunner??mo,o=e.logger??console.info,s=await R7({target:r,environment:i,commandRunner:n,fetchImpl:e.fetchImpl??fetch}),a=`/tmp/brains-health-watchdog-smoke-${e.runId}`,c,l=!1;try{let p=await yR(s,"run",e.runId);if(await Mx(t,"remote",p),p.stdout.trim())o(p.stdout.trim());if(p.exitCode!==0)c=Ei("ssh",["watchdog-smoke","run"],p);let m=await uEe(s,a,t);if(await Mx(t,"scp",m),m.exitCode===0){if(l=await dEe(Ii(t,"summary.txt")),!l)c??=Error("Health watchdog smoke evidence is missing summary.txt")}else c??=Ei("scp",[a,t],m)}catch(p){c=Error(at(p,"Health watchdog smoke execution failed"))}let u;try{let p=await yR(s,"cleanup",e.runId);if(await Mx(t,"cleanup",p),p.exitCode!==0)u=Ei("ssh",["watchdog-smoke","cleanup"],p)}catch(p){u=Error(at(p,"Health watchdog smoke cleanup failed"))}finally{await bR(s.temporaryRoot,{recursive:!0,force:!0})}if(c)throw c;if(u)throw u;if(!l)throw Error("Health watchdog smoke completed without copied evidence");let d={success:!0,runId:e.runId,artifactsDir:t,target:{handle:r.user.handle,domain:r.user.domain,serverIp:s.serverIp}};return await $u(Ii(t,"result.json"),`${JSON.stringify(d,null,2)}
773
+ `;var k7=()=>{};var SR={};tr(SR,{assertHealthWatchdogSmokeTarget:()=>Fx,cleanupHealthWatchdogSmoke:()=>$7,renderHealthWatchdogSmokeRemoteScript:()=>xR,runHealthWatchdogSmoke:()=>C7});import{access as iEe,chmod as oEe,mkdir as I7,mkdtemp as sEe,rm as bR,writeFile as $u}from"fs/promises";import{tmpdir as aEe}from"os";import{join as Ii,resolve as A7}from"path";function Fx(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 xR(){return E7.replace("__WATCHDOG_PAYLOAD_BASE64__",Buffer.from(v7,"utf8").toString("base64")).replace("__WATCHDOG_LABEL_FILTER__",gR)}async function C7(e){let t=A7(e.artifactsDir??Ii(e.rootDir,".brains-ops","watchdog-smoke",e.runId)),r=await O7(e.rootDir,e.handle);Fx({handle:r.user.handle,domain:r.user.domain,confirmation:e.confirmation,runId:e.runId}),await I7(t,{recursive:!0});let i=T7.parse(e.env??process.env),n=e.commandRunner??mo,o=e.logger??console.info,s=await R7({target:r,environment:i,commandRunner:n,fetchImpl:e.fetchImpl??fetch}),a=`/tmp/brains-health-watchdog-smoke-${e.runId}`,c,l=!1;try{let p=await yR(s,"run",e.runId);if(await Mx(t,"remote",p),p.stdout.trim())o(p.stdout.trim());if(p.exitCode!==0)c=Ei("ssh",["watchdog-smoke","run"],p);let m=await lEe(s,a,t);if(await Mx(t,"scp",m),m.exitCode===0){if(l=await uEe(Ii(t,"summary.txt")),!l)c??=Error("Health watchdog smoke evidence is missing summary.txt")}else c??=Ei("scp",[a,t],m)}catch(p){c=Error(at(p,"Health watchdog smoke execution failed"))}let u;try{let p=await yR(s,"cleanup",e.runId);if(await Mx(t,"cleanup",p),p.exitCode!==0)u=Ei("ssh",["watchdog-smoke","cleanup"],p)}catch(p){u=Error(at(p,"Health watchdog smoke cleanup failed"))}finally{await bR(s.temporaryRoot,{recursive:!0,force:!0})}if(c)throw c;if(u)throw u;if(!l)throw Error("Health watchdog smoke completed without copied evidence");let d={success:!0,runId:e.runId,artifactsDir:t,target:{handle:r.user.handle,domain:r.user.domain,serverIp:s.serverIp}};return await $u(Ii(t,"result.json"),`${JSON.stringify(d,null,2)}
775
774
  `),d}async function $7(e){let t=A7(e.artifactsDir??Ii(e.rootDir,".brains-ops","watchdog-smoke",`cleanup-${e.runId}`)),r=await O7(e.rootDir,e.handle);Fx({handle:r.user.handle,domain:r.user.domain,confirmation:e.confirmation,runId:e.runId}),await I7(t,{recursive:!0});let i=T7.parse(e.env??process.env),n=await R7({target:r,environment:i,commandRunner:e.commandRunner??mo,fetchImpl:e.fetchImpl??fetch});try{let s=await yR(n,"cleanup",e.runId);if(await Mx(t,"cleanup",s),s.stdout.trim())(e.logger??console.info)(s.stdout.trim());if(s.exitCode!==0)throw Ei("ssh",["watchdog-smoke","cleanup"],s)}finally{await bR(n.temporaryRoot,{recursive:!0,force:!0})}let o={success:!0,runId:e.runId,artifactsDir:t,target:{handle:r.user.handle,domain:r.user.domain,serverIp:n.serverIp}};return await $u(Ii(t,"result.json"),`${JSON.stringify(o,null,2)}
776
- `),o}async function O7(e,t){let r=await Ct(e),i=r.users.find((n)=>n.handle===t);if(!i)throw Error(`Unknown pilot user: ${t}`);return{pilot:r.pilot,user:i}}async function R7(e){let t=await aEe(Ii(cEe(),"brains-ops-watchdog-smoke-")),r=Ii(t,"id_ed25519"),i=Ii(t,"known_hosts");try{let n=encodeURIComponent(`brain=${e.target.pilot.contentRepoPrefix}${e.target.user.handle}`),o=await e.fetchImpl(`https://api.hetzner.cloud/v1/servers?label_selector=${n}`,{headers:{Authorization:`Bearer ${e.environment.HCLOUD_TOKEN}`}});if(!o.ok)throw Error(`Hetzner server lookup failed with ${o.status}`);let s=lEe.parse(await o.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 $u(r,fEe(e.environment.KAMAL_SSH_PRIVATE_KEY),{mode:384}),await sEe(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 $u(i,c.stdout,{mode:384}),{temporaryRoot:t,sshKeyPath:r,knownHostsPath:i,serverIp:a.public_net.ipv4.ip,commandRunner:e.commandRunner}}catch(n){throw await bR(t,{recursive:!0,force:!0}),n}}async function yR(e,t,r){return e.commandRunner("ssh",[...P7(e),`root@${e.serverIp}`,"bash","-s","--",t,r],{stdin:xR()})}async function uEe(e,t,r){return e.commandRunner("scp",[...P7(e),"-r",`root@${e.serverIp}:${t}/.`,r])}function P7(e){return["-i",e.sshKeyPath,"-o","BatchMode=yes","-o","IdentitiesOnly=yes","-o","ConnectTimeout=10","-o","StrictHostKeyChecking=yes","-o",`UserKnownHostsFile=${e.knownHostsPath}`]}async function dEe(e){try{return await oEe(e),!0}catch{return!1}}async function Mx(e,t,r){await Promise.all([$u(Ii(e,`${t}.stdout.log`),r.stdout),$u(Ii(e,`${t}.stderr.log`),r.stderr)])}function fEe(e){return`${e.replace(/\r\n/g,`
775
+ `),o}async function O7(e,t){let r=await Ct(e),i=r.users.find((n)=>n.handle===t);if(!i)throw Error(`Unknown pilot user: ${t}`);return{pilot:r.pilot,user:i}}async function R7(e){let t=await sEe(Ii(aEe(),"brains-ops-watchdog-smoke-")),r=Ii(t,"id_ed25519"),i=Ii(t,"known_hosts");try{let n=encodeURIComponent(`brain=${e.target.pilot.contentRepoPrefix}${e.target.user.handle}`),o=await e.fetchImpl(`https://api.hetzner.cloud/v1/servers?label_selector=${n}`,{headers:{Authorization:`Bearer ${e.environment.HCLOUD_TOKEN}`}});if(!o.ok)throw Error(`Hetzner server lookup failed with ${o.status}`);let s=cEe.parse(await o.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 $u(r,dEe(e.environment.KAMAL_SSH_PRIVATE_KEY),{mode:384}),await oEe(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 $u(i,c.stdout,{mode:384}),{temporaryRoot:t,sshKeyPath:r,knownHostsPath:i,serverIp:a.public_net.ipv4.ip,commandRunner:e.commandRunner}}catch(n){throw await bR(t,{recursive:!0,force:!0}),n}}async function yR(e,t,r){return e.commandRunner("ssh",[...P7(e),`root@${e.serverIp}`,"bash","-s","--",t,r],{stdin:xR()})}async function lEe(e,t,r){return e.commandRunner("scp",[...P7(e),"-r",`root@${e.serverIp}:${t}/.`,r])}function P7(e){return["-i",e.sshKeyPath,"-o","BatchMode=yes","-o","IdentitiesOnly=yes","-o","ConnectTimeout=10","-o","StrictHostKeyChecking=yes","-o",`UserKnownHostsFile=${e.knownHostsPath}`]}async function uEe(e){try{return await iEe(e),!0}catch{return!1}}async function Mx(e,t,r){await Promise.all([$u(Ii(e,`${t}.stdout.log`),r.stdout),$u(Ii(e,`${t}.stderr.log`),r.stderr)])}function dEe(e){return`${e.replace(/\r\n/g,`
777
776
  `).replace(/\\n/g,`
778
777
  `).trimEnd()}
779
- `}var T7,lEe;var Zx=x(async()=>{Re();k7();Ln();Gp();await _7();T7=f.object({HCLOUD_TOKEN:f.string().min(1),KAMAL_SSH_PRIVATE_KEY:f.string().min(1)}),lEe=f.object({servers:f.array(f.object({status:f.string(),public_net:f.object({ipv4:f.object({ip:f.string().min(1)})})}))})});import{access as BN,chmod as LE,mkdir as Zh,readFile as qN,writeFile as jN}from"fs/promises";import{dirname as XY,join as Lc}from"path";import{fileURLToPath as eX}from"url";var tm={name:"@rizom/ops",version:"0.2.0-alpha.484",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/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 run build && 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"};Rs();Dc();var tX=["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/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"],BE=new Set([".kamal/hooks/pre-deploy"]),rX=new Set(["cohorts/cohort-1.yaml","users/alice.yaml","docs/canonical-crossover-record.md"]),nX=eX(new URL("../templates/rover-pilot/",import.meta.url)),iX=[`service: rover
778
+ `}var T7,cEe;var Zx=x(async()=>{Re();k7();Ln();Gp();await _7();T7=f.object({HCLOUD_TOKEN:f.string().min(1),KAMAL_SSH_PRIVATE_KEY:f.string().min(1)}),cEe=f.object({servers:f.array(f.object({status:f.string(),public_net:f.object({ipv4:f.object({ip:f.string().min(1)})})}))})});import{access as BN,chmod as LE,mkdir as Zh,readFile as qN,writeFile as jN}from"fs/promises";import{dirname as XY,join as Lc}from"path";import{fileURLToPath as eX}from"url";var tm={name:"@rizom/ops",version:"0.2.0-alpha.485",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/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 run build && 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"};Rs();Dc();var tX=["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/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"],BE=new Set([".kamal/hooks/pre-deploy"]),rX=new Set(["cohorts/cohort-1.yaml","users/alice.yaml","docs/canonical-crossover-record.md"]),nX=eX(new URL("../templates/rover-pilot/",import.meta.url)),iX=[`service: rover
780
779
  image: <%= ENV['IMAGE_REPOSITORY'] %>
781
780
 
782
781
  servers:
@@ -827,33 +826,33 @@ writeSecretGitHubEnv("DISCORD_APPLICATION_ID", secrets["discordApplicationId"]);
827
826
  `];function dX(e,t){let r=(i)=>uX.reduce((n,o)=>n.replace(o,""),i);return r(e)===r(t)}function fX(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 pX={".env.schema":lX,"deploy/Dockerfile":(e)=>zR(e),"deploy/kamal/deploy.yml":(e)=>iX.includes(e)||sX(e)||aX(e),"deploy/scripts/decrypt-user-secrets.ts":dX,"deploy/scripts/resolve-deploy-handles.ts":(e)=>fX(e),"deploy/scripts/helpers.ts":Ri('"@rizom/ops/deploy"'),"deploy/scripts/resolve-user-config.ts":Ri("sitePackagesFor"),"deploy/scripts/resolve-missing-images.ts":Ri("runResolveMissingImages"),"deploy/scripts/sync-content-repo.ts":Ri("GIT_SYNC_TOKEN"),".github/workflows/build.yml":Ri("resolve-missing-images.ts"),".github/workflows/deploy.yml":Ri("install-health-watchdog.ts"),".github/workflows/offboard.yml":Ri("user:offboard"),".github/workflows/reconcile.yml":Ri("brains-ops reconcile"),".github/workflows/upgrade.yml":Ri("brains-ops upgrade")};function mX(e,t,r){let i=oX(e);if(i&&RR(i,t,r))return!0;return pX[e]?.(t,r)??!1}async function qE(e){await Zh(e,{recursive:!0});let t=Lc(e,"views","users.md"),r=!0;try{await BN(t)}catch{r=!1}let i=!0;try{await BN(Lc(e,"pilot.yaml"))}catch{i=!1}await Zh(Lc(e,"users"),{recursive:!0}),await Zh(Lc(e,"cohorts"),{recursive:!0});let n=tX.filter((o)=>!(i&&rX.has(o))).map(async(o)=>{let s=Lc(e,o);await Zh(XY(s),{recursive:!0}),await hX(o,s)});if(await Promise.all(n),!r)await Oi(e)}async function hX(e,t){let r=await gX(e);try{if(await jN(t,r,{flag:"wx"}),BE.has(e))await LE(t,493);return}catch(n){if(!bX(n,"EEXIST"))throw n}let i=await qN(t,"utf8");if(i===r){if(BE.has(e))await LE(t,493);return}if(!mX(e,i,r))return;if(await jN(t,r),BE.has(e))await LE(t,493)}async function gX(e){if(e===".gitignore")return`node_modules/
828
827
  .brains-ops/
829
828
  users/*.secrets.yaml
830
- `;if(e==="deploy/Dockerfile")return PR();if(e==="deploy/kamal/deploy.yml")return rm({serviceName:"rover"});if(e===".kamal/hooks/pre-deploy")return Vx({deployConfigPath:"deploy/kamal/deploy.yml",brainYamlPath:"${BRAIN_YAML_PATH:-brain.yaml}"});let t=Lc(nX,e),r=await qN(t,"utf8");return yX(r)}function yX(e){return e.replaceAll("__BRAINS_OPS_VERSION__",tm.version).replaceAll("__BUN_VERSION__",Bun.version)}function bX(e,t){return typeof e==="object"&&e!==null&&"code"in e&&e.code===t}Ln();UE();BI();Dc();Ai();import{mkdir as Gae,writeFile as Qae}from"fs/promises";import{dirname as Yae,join as y4}from"path";import{isDeepStrictEqual as Xae}from"util";Rs();Pi();import{mkdtemp as Oae,mkdir as Rae,readFile as Pae,rm as zae,writeFile as Nae}from"fs/promises";import{tmpdir as Dae}from"os";import{dirname as Lae,join as f4}from"path";var Bae=["name: Your Name Here","Delete this and write your own"];async function p4(e,t,r,i,n={}){if(i.length===0)return;let o=n.env??process.env,s=zn(e),a=u4(o,s,r.effectiveGitSyncToken),c=n.contentRepoAdminTokenSelector?u4(o,s,n.contentRepoAdminTokenSelector):void 0,l=jI(r.contentRepo,t),u=n.contentRepoRemoteResolver?.(r,t,a)??Uae(l,a);if(!u)return;let d=await Oae(f4(Dae(),`brains-ops-content-sync-${r.handle}-`)),p=n.runCommand??br,m=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 Mae(l,c,m)}await p("git",["clone",u,d]),await Fae(d,p),await p("git",["config","user.name","brains-ops[bot]"],{cwd:d}),await p("git",["config","user.email","41898282+github-actions[bot]@users.noreply.github.com"],{cwd:d});let y=!1;for(let g of i)if(await jae(d,g))y=!0;if(!y)return;await p("git",["add","."],{cwd:d}),await p("git",["commit","-m",`chore(content): seed ${r.handle} anchor profile`],{cwd:d}),await p("git",["push","origin","HEAD:main"],{cwd:d})}finally{await zae(d,{recursive:!0,force:!0})}}async function jae(e,t){let r=f4(e,t.path),i=await Pae(r,"utf8").catch(()=>{return});if(i===t.content)return!1;if(i!==void 0&&!qae(i))return!1;return await Rae(Lae(r),{recursive:!0}),await Nae(r,t.content),!0}function qae(e){return Bae.some((t)=>e.includes(t))}function u4(e,t,r){return Wt(r,e,t)}function Uae(e,t){if(!t)return;return`https://x-access-token:${encodeURIComponent(t)}@github.com/${e.org}/${e.name}.git`}async function Mae(e,t,r){let{org:i,name:n}=e,s=`https://api.github.com/repos/${`${encodeURIComponent(i)}/${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 ${i}/${n}: ${c.status} ${await d4(c)}`);let l=await r(`https://api.github.com/orgs/${encodeURIComponent(i)}/repos`,{method:"POST",headers:a,body:JSON.stringify({name:n,private:!0,auto_init:!1})});if(l.ok){console.log(`Created missing content repo ${i}/${n}`);return}if(l.status===422){if((await r(s,{headers:a})).ok)return}throw Error(`Failed to create GitHub repo ${i}/${n}: ${l.status} ${await d4(l)}`)}async function d4(e){let t=await e.text();return t.trim().length===0?e.statusText:t}async function Fae(e,t){try{await t("git",["checkout","-B","main","origin/main"],{cwd:e})}catch{await t("git",["checkout","-B","main"],{cwd:e})}}UI();Ln();async function ol(e,t,r,i,n={}){let o=Zg(t.pilot.githubOrg);for(let s of r){let a={};if(i){let p=await i(s);if(p!==void 0)a=p}let c=await o(s),l=a.brainYaml??c.brainYaml,u=a.envFile??c.envFile,d=a.contentRepoFiles??c.contentRepoFiles??[];if(u)await MI(e,s.handle,".env",u);if(l)await MI(e,s.handle,"brain.yaml",l);await p4(e,t.pilot.githubOrg,s,d,{contentRepoAdminTokenSelector:t.pilot.contentRepoAdminToken,...n});for(let p of d)await MI(e,s.handle,y4("content",p.path),p.content)}}async function MI(e,t,r,i){let n=y4(e,"users",t,r),o=Bun.file(n);if(r==="brain.yaml"&&await o.exists()){let s=Nn(await o.text()),a=Nn(i);if(s.ok&&a.ok&&Xae(s.data,a.data))return}await Gae(Yae(n),{recursive:!0}),await Qae(n,i)}async function Hg(e,t){let r=await Ct(e),i=r.users.find((n)=>n.handle===t);if(!i)throw Error(`Unknown user handle: ${t}`);return{registry:r,user:i}}async function b4(e,t){let r=await Ct(e),i=r.cohorts.find((n)=>n.id===t);if(!i)throw Error(`Unknown cohort: ${t}`);return{registry:r,users:r.users.filter((n)=>n.cohort===i.id)}}async function x4(e){let t=await Ct(e);return{registry:t,users:t.users}}async function FI(e,t,r,i={}){let{registry:n,user:o}=await Hg(e,t);await ol(e,n,[o],r,i)}Ai();To();import{access as ece,mkdir as S4,readFile as tce,writeFile as v4}from"fs/promises";import{basename as rce,join as sl}from"path";async function ZI(e,t,r){let i=Pr.parse(t),n=Pr.parse(r.cohort),o=sl(e,"users"),s=sl(e,"cohorts"),a=sl(o,`${i}.yaml`),c=sl(o,`${i}.secrets.yaml`),l=sl(o,`${i}.secrets.yaml.age`),u=sl(s,`${n}.yaml`);await Promise.all([S4(o,{recursive:!0}),S4(s,{recursive:!0})]);let d=await w4(a,oce(i,r.anchorId)),m=await cce(l)?!1:await w4(c,sce(i)),{addedToCohort:y}=await nce(u,i);return{handle:i,cohort:n,userPath:a,secretsTemplatePath:c,cohortPath:u,createdUser:d,createdSecretsTemplate:m,addedToCohort:y}}async function nce(e,t){let r=await ice(e);if(r.members.includes(t))return{addedToCohort:!1};let i={...r,members:[...r.members,t].sort()};return await v4(e,ace(i)),{addedToCohort:!0}}async function ice(e){try{let t=await tce(e,"utf8"),r=Nn(t,yn);if(!r.ok)throw Error(`${rce(e)}: ${r.error}`);return r.data}catch(t){if(uce(t))return{members:[]};throw t}}function oce(e,t){return[`handle: ${e}`,"anchorProfile:",` name: ${dce(e)}`,"discord:"," enabled: true",...t?[` anchorUserId: ${JSON.stringify(t)}`]:[],""].join(`
831
- `)}function sce(e){return["# local per-user secret staging file",`# fill values, run \`bunx brains-ops secrets:encrypt . ${e}\`, then the plaintext file will be removed`,"discordBotToken: ","atprotoAppPassword: ","# For custom-domain sites, paste PEMs with literal \\n escapes.","certificatePem: ","privateKeyPem: ",""].join(`
832
- `)}function ace(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.aiApiKeyOverride?[`aiApiKeyOverride: ${e.aiApiKeyOverride}`]:[],...e.gitSyncTokenOverride?[`gitSyncTokenOverride: ${e.gitSyncTokenOverride}`]:[],""].join(`
833
- `)}async function w4(e,t){try{return await v4(e,t,{flag:"wx"}),!0}catch(r){if(lce(r))return!1;throw r}}async function cce(e){try{return await ece(e),!0}catch{return!1}}function lce(e){return _4(e,"EEXIST")}function uce(e){return _4(e,"ENOENT")}function _4(e,t){return typeof e==="object"&&e!==null&&"code"in e&&e.code===t}function dce(e){return e.split("-").filter((t)=>t.length>0).map((t)=>`${t[0]?.toUpperCase()??""}${t.slice(1)}`).join(" ")}oT();async function sT(e,t,r,i={}){let{registry:n,users:o}=await b4(e,t);await ol(e,n,o,r,i)}async function yf(e,t,r={}){let{registry:i,users:n}=await x4(e);await ol(e,i,n,t,r)}import{parseArgs as bye}from"util";function mt(e){return e}class jF extends Error{constructor(e){super(e);this.name="CliUsageError"}}function xye(e,t){let r={...t};for(let i of e)for(let[n,o]of Object.entries(i.flags??{})){let s=r[n];if(s===void 0){r[n]=o;continue}if(s.type!==o.type||s.short!==o.short||s.default!==o.default)throw Error(`Conflicting definitions for flag --${n}: commands must agree on type, short, and default`)}return r}function Sye(e){let t={};for(let[r,i]of Object.entries(e))t[r]={type:i.type,...i.short!==void 0?{short:i.short}:{},...i.default!==void 0?{default:i.default}:{}};return t}function wye(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 qF(e,t){let r=xye(t.commands,t.globalFlags??{}),i,n;try{({values:i,positionals:n}=bye({args:e,options:Sye(r),allowPositionals:!0,strict:t.strict??!0}))}catch(s){if(wye(s))throw new jF(s.message.split(". ")[0]??s.message);throw s}if("help"in r&&i.help===!0)return{command:"help",args:[],flags:{help:!0}};if("version"in r&&i.version===!0)return{command:"version",args:[],flags:{version:!0}};let o={};for(let[s,a]of Object.entries(r)){let c=i[s];if(typeof c==="string"&&a.type==="string")o[s]=c;else if(typeof c==="boolean"&&a.type==="boolean")o[s]=c}return{command:n[0]??"help",args:n.slice(1),flags:o}}function UF(e){let t=e.reduce((r,i)=>Math.max(r,i.label.length),0);return e.map((r)=>` ${r.label.padEnd(t)} ${r.description}`)}function vye(e){return UF(e.map((t)=>({label:t.usage?`${t.name} ${t.usage}`:t.name,description:t.description})))}function _ye(e,t){let r=t.type==="string"?` ${t.placeholder??"<value>"}`:"",i=t.short!==void 0?`, -${t.short}`:"";return`--${e}${r}${i}`}function MF(e){return UF(Object.entries(e).map(([t,r])=>({label:_ye(t,r),description:r.description})))}function FF(e,t){return`Usage: ${e} ${t.name}${t.usage?` ${t.usage}`:""}`}function kye(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 Eye(e){let t=[],r=new Map;for(let n of e){let o=n.flags??{};if(Object.keys(o).length===0)continue;let s=kye(o),a=r.get(s);if(a){a.names.push(n.name);continue}let c={names:[n.name],flags:o};r.set(s,c),t.push(c)}let i=[];for(let n of t)i.push("",`${n.names.join(" / ")} options:`),i.push(...MF(n.flags));return i}function ZF(e){let t=[e.intro,"",`Usage: ${e.cliName} ${e.usage??"<command> [args]"}`,"","Commands:",...vye(e.commands)];if(e.globalFlags&&Object.keys(e.globalFlags).length>0)t.push("","Options:",...MF(e.globalFlags));return t.push(...Eye(e.commands)),t.join(`
834
- `)}function HF(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 ht(e,t){let r=e[t];return typeof r==="string"?r:void 0}function wl(e,t){let r=e[t];return typeof r==="boolean"?r:void 0}import{existsSync as Yxe,mkdirSync as Xxe,readFileSync as JC,writeFileSync as VC}from"fs";import{dirname as eSe,join as e8}from"path";function aT(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function Ot(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 or(e,t,r=""){let i=aT(e),n=e?.length,o=t!==void 0;if(!i||o&&n!==t){let s=r&&`"${r}" `,a=o?` of length ${t}`:"",c=i?`length=${n}`:`type=${typeof e}`,l=s+"expected Uint8Array"+a+", got "+c;if(!i)throw TypeError(l);throw RangeError(l)}return e}function Mi(e){if(typeof e!=="function"||typeof e.create!=="function")throw TypeError("Hash must wrapped by utils.createHasher");if(Ot(e.outputLen),Ot(e.blockLen),e.outputLen<1)throw Error('"outputLen" must be >= 1');if(e.blockLen<1)throw Error('"blockLen" must be >= 1')}function vl(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 Dy(e,t){or(e,void 0,"digestInto() output");let r=t.outputLen;if(e.length<r)throw RangeError('"digestInto() output" expected to be of length >='+r)}function Ly(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function Lr(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function _l(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Un(e,t){return e<<32-t|e>>>t}function Qe(e,t){return e<<t|e>>>32-t>>>0}var Iye=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)();function Aye(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function Tye(e){for(let t=0;t<e.length;t++)e[t]=Aye(e[t]);return e}var cT=Iye?(e)=>e:Tye,JF=(()=>typeof Uint8Array.from([]).toHex==="function"&&typeof Uint8Array.fromHex==="function")(),Cye=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function By(e){if(or(e),JF)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=Cye[e[r]];return t}var Ui={_0:48,_9:57,A:65,F:70,a:97,f:102};function KF(e){if(e>=Ui._0&&e<=Ui._9)return e-Ui._0;if(e>=Ui.A&&e<=Ui.F)return e-(Ui.A-10);if(e>=Ui.a&&e<=Ui.f)return e-(Ui.a-10);return}function bf(e){if(typeof e!=="string")throw TypeError("hex string expected, got "+typeof e);if(JF)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 i=new Uint8Array(r);for(let n=0,o=0;n<r;n++,o+=2){let s=KF(e.charCodeAt(o)),a=KF(e.charCodeAt(o+1));if(s===void 0||a===void 0){let c=e[o]+e[o+1];throw RangeError('hex string expected, got non-hex character "'+c+'" at index '+o)}i[n]=s*16+a}return i}function $ye(e){if(typeof e!=="string")throw TypeError("string expected");return new Uint8Array(new TextEncoder().encode(e))}function lT(e,t=""){if(typeof e==="string")return $ye(e);return or(e,void 0,t)}function uT(...e){let t=0;for(let i=0;i<e.length;i++){let n=e[i];or(n),t+=n.length}let r=new Uint8Array(t);for(let i=0,n=0;i<e.length;i++){let o=e[i];r.set(o,n),n+=o.length}return r}function jy(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 dT(e,t={}){let r=(n,o)=>e(o).update(n).digest(),i=e(void 0);return r.outputLen=i.outputLen,r.blockLen=i.blockLen,r.canXOF=i.canXOF,r.create=(n)=>e(n),Object.assign(r,t),Object.freeze(r)}function Fi(e=32){Ot(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 fT=(e)=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});class pT{oHash;iHash;blockLen;outputLen;canXOF=!1;finished=!1;destroyed=!1;constructor(e,t){if(Mi(e),or(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,i=new Uint8Array(r);i.set(t.length>r?e.create().update(t).digest():t);for(let n=0;n<i.length;n++)i[n]^=54;this.iHash.update(i),this.oHash=e.create();for(let n=0;n<i.length;n++)i[n]^=106;this.oHash.update(i),Lr(i)}update(e){return vl(this),this.iHash.update(e),this}digestInto(e){vl(this),Dy(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:i,destroyed:n,blockLen:o,outputLen:s}=this;return e=e,e.finished=i,e.destroyed=n,e.blockLen=o,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 li=(()=>{let e=(t,r,i)=>new pT(t,r).update(i).digest();return e.create=(t,r)=>new pT(t,r),e})();function xf(e,t,r){if(Mi(e),r===void 0)r=new Uint8Array(e.outputLen);return li(e,r,t)}var mT=Uint8Array.of(0),VF=Uint8Array.of();function hT(e,t,r,i=32){Mi(e),Ot(i,"length"),or(t,void 0,"prk");let n=e.outputLen;if(t.length<n)throw Error('"prk" must be at least HashLen octets');if(i>255*n)throw Error("Length must be <= 255*HashLen");let o=Math.ceil(i/n);if(r===void 0)r=VF;else or(r,void 0,"info");let s=new Uint8Array(o*n),a=li.create(e,t),c=a._cloneInto(),l=new Uint8Array(a.outputLen);for(let u=0;u<o;u++)mT[0]=u+1,c.update(u===0?VF:l).update(r).update(mT).digestInto(l),s.set(l,n*u),a._cloneInto(c);return a.destroy(),c.destroy(),Lr(l,mT),s.slice(0,i)}var Wo=(e,t,r,i,n)=>hT(e,xf(e,t,r),i,n);function WF(e,t,r){return e&t^~e&r}function GF(e,t,r){return e&t^e&r^t&r}class qy{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,t,r,i){this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=i,this.buffer=new Uint8Array(e),this.view=_l(this.buffer)}update(e){vl(this),or(e);let{view:t,buffer:r,blockLen:i}=this,n=e.length;for(let o=0;o<n;){let s=Math.min(i-this.pos,n-o);if(s===i){let a=_l(e);for(;i<=n-o;o+=i)this.process(a,o);continue}if(r.set(e.subarray(o,o+s),this.pos),this.pos+=s,o+=s,this.pos===i)this.process(t,0),this.pos=0}return this.length+=e.length,this.roundClean(),this}digestInto(e){vl(this),Dy(e,this),this.finished=!0;let{buffer:t,view:r,blockLen:i,isLE:n}=this,{pos:o}=this;if(t[o++]=128,Lr(this.buffer.subarray(o)),this.padOffset>i-o)this.process(r,0),o=0;for(let u=o;u<i;u++)t[u]=0;r.setBigUint64(i-8,BigInt(this.length*8),n),this.process(r,0);let s=_l(e),a=this.outputLen;if(a%4)throw Error("_sha2: outputLen must be aligned to 32bit");let c=a/4,l=this.get();if(c>l.length)throw Error("_sha2: outputLen bigger than state");for(let u=0;u<c;u++)s.setUint32(4*u,l[u],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:i,finished:n,destroyed:o,pos:s}=this;if(e.destroyed=o,e.finished=n,e.length=i,e.pos=s,i%t)e.buffer.set(r);return e}clone(){return this._cloneInto()}}var Zi=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var sr=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var Uy=BigInt(4294967295),QF=BigInt(32);function Oye(e,t=!1){if(t)return{h:Number(e&Uy),l:Number(e>>QF&Uy)};return{h:Number(e>>QF&Uy)|0,l:Number(e&Uy)|0}}function YF(e,t=!1){let r=e.length,i=new Uint32Array(r),n=new Uint32Array(r);for(let o=0;o<r;o++){let{h:s,l:a}=Oye(e[o],t);[i[o],n[o]]=[s,a]}return[i,n]}var gT=(e,t,r)=>e>>>r,yT=(e,t,r)=>e<<32-r|t>>>r,ma=(e,t,r)=>e>>>r|t<<32-r,ha=(e,t,r)=>e<<32-r|t>>>r,Sf=(e,t,r)=>e<<64-r|t>>>r-32,wf=(e,t,r)=>e>>>r-32|t<<64-r;function ui(e,t,r,i){let n=(t>>>0)+(i>>>0);return{h:e+r+(n/4294967296|0)|0,l:n|0}}var XF=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),eZ=(e,t,r,i)=>t+r+i+(e/4294967296|0)|0,tZ=(e,t,r,i)=>(e>>>0)+(t>>>0)+(r>>>0)+(i>>>0),rZ=(e,t,r,i,n)=>t+r+i+n+(e/4294967296|0)|0,nZ=(e,t,r,i,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(i>>>0)+(n>>>0),iZ=(e,t,r,i,n,o)=>t+r+i+n+o+(e/4294967296|0)|0;var Pye=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]),Go=new Uint32Array(64);class oZ extends qy{constructor(e){super(64,e,8,!1)}get(){let{A:e,B:t,C:r,D:i,E:n,F:o,G:s,H:a}=this;return[e,t,r,i,n,o,s,a]}set(e,t,r,i,n,o,s,a){this.A=e|0,this.B=t|0,this.C=r|0,this.D=i|0,this.E=n|0,this.F=o|0,this.G=s|0,this.H=a|0}process(e,t){for(let u=0;u<16;u++,t+=4)Go[u]=e.getUint32(t,!1);for(let u=16;u<64;u++){let d=Go[u-15],p=Go[u-2],m=Un(d,7)^Un(d,18)^d>>>3,y=Un(p,17)^Un(p,19)^p>>>10;Go[u]=y+Go[u-7]+m+Go[u-16]|0}let{A:r,B:i,C:n,D:o,E:s,F:a,G:c,H:l}=this;for(let u=0;u<64;u++){let d=Un(s,6)^Un(s,11)^Un(s,25),p=l+d+WF(s,a,c)+Pye[u]+Go[u]|0,y=(Un(r,2)^Un(r,13)^Un(r,22))+GF(r,i,n)|0;l=c,c=a,a=s,s=o+p|0,o=n,n=i,i=r,r=p+y|0}r=r+this.A|0,i=i+this.B|0,n=n+this.C|0,o=o+this.D|0,s=s+this.E|0,a=a+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(r,i,n,o,s,a,c,l)}roundClean(){Lr(Go)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),Lr(this.buffer)}}class sZ extends oZ{A=Zi[0]|0;B=Zi[1]|0;C=Zi[2]|0;D=Zi[3]|0;E=Zi[4]|0;F=Zi[5]|0;G=Zi[6]|0;H=Zi[7]|0;constructor(){super(32)}}var aZ=(()=>YF(["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))))(),zye=(()=>aZ[0])(),Nye=(()=>aZ[1])(),Qo=new Uint32Array(80),Yo=new Uint32Array(80);class cZ extends qy{constructor(e){super(128,e,16,!1)}get(){let{Ah:e,Al:t,Bh:r,Bl:i,Ch:n,Cl:o,Dh:s,Dl:a,Eh:c,El:l,Fh:u,Fl:d,Gh:p,Gl:m,Hh:y,Hl:g}=this;return[e,t,r,i,n,o,s,a,c,l,u,d,p,m,y,g]}set(e,t,r,i,n,o,s,a,c,l,u,d,p,m,y,g){this.Ah=e|0,this.Al=t|0,this.Bh=r|0,this.Bl=i|0,this.Ch=n|0,this.Cl=o|0,this.Dh=s|0,this.Dl=a|0,this.Eh=c|0,this.El=l|0,this.Fh=u|0,this.Fl=d|0,this.Gh=p|0,this.Gl=m|0,this.Hh=y|0,this.Hl=g|0}process(e,t){for(let A=0;A<16;A++,t+=4)Qo[A]=e.getUint32(t),Yo[A]=e.getUint32(t+=4);for(let A=16;A<80;A++){let T=Qo[A-15]|0,z=Yo[A-15]|0,j=ma(T,z,1)^ma(T,z,8)^gT(T,z,7),E=ha(T,z,1)^ha(T,z,8)^yT(T,z,7),Z=Qo[A-2]|0,D=Yo[A-2]|0,H=ma(Z,D,19)^Sf(Z,D,61)^gT(Z,D,6),X=ha(Z,D,19)^wf(Z,D,61)^yT(Z,D,6),M=tZ(E,X,Yo[A-7],Yo[A-16]),P=rZ(M,j,H,Qo[A-7],Qo[A-16]);Qo[A]=P|0,Yo[A]=M|0}let{Ah:r,Al:i,Bh:n,Bl:o,Ch:s,Cl:a,Dh:c,Dl:l,Eh:u,El:d,Fh:p,Fl:m,Gh:y,Gl:g,Hh:b,Hl:v}=this;for(let A=0;A<80;A++){let T=ma(u,d,14)^ma(u,d,18)^Sf(u,d,41),z=ha(u,d,14)^ha(u,d,18)^wf(u,d,41),j=u&p^~u&y,E=d&m^~d&g,Z=nZ(v,z,E,Nye[A],Yo[A]),D=iZ(Z,b,T,j,zye[A],Qo[A]),H=Z|0,X=ma(r,i,28)^Sf(r,i,34)^Sf(r,i,39),M=ha(r,i,28)^wf(r,i,34)^wf(r,i,39),P=r&n^r&s^n&s,N=i&o^i&a^o&a;b=y|0,v=g|0,y=p|0,g=m|0,p=u|0,m=d|0,{h:u,l:d}=ui(c|0,l|0,D|0,H|0),c=s|0,l=a|0,s=n|0,a=o|0,n=r|0,o=i|0;let I=XF(H,M,N);r=eZ(I,D,X,P),i=I|0}({h:r,l:i}=ui(this.Ah|0,this.Al|0,r|0,i|0)),{h:n,l:o}=ui(this.Bh|0,this.Bl|0,n|0,o|0),{h:s,l:a}=ui(this.Ch|0,this.Cl|0,s|0,a|0),{h:c,l}=ui(this.Dh|0,this.Dl|0,c|0,l|0),{h:u,l:d}=ui(this.Eh|0,this.El|0,u|0,d|0),{h:p,l:m}=ui(this.Fh|0,this.Fl|0,p|0,m|0),{h:y,l:g}=ui(this.Gh|0,this.Gl|0,y|0,g|0),{h:b,l:v}=ui(this.Hh|0,this.Hl|0,b|0,v|0),this.set(r,i,n,o,s,a,c,l,u,d,p,m,y,g,b,v)}roundClean(){Lr(Qo,Yo)}destroy(){this.destroyed=!0,Lr(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class lZ extends cZ{Ah=sr[0]|0;Al=sr[1]|0;Bh=sr[2]|0;Bl=sr[3]|0;Ch=sr[4]|0;Cl=sr[5]|0;Dh=sr[6]|0;Dl=sr[7]|0;Eh=sr[8]|0;El=sr[9]|0;Fh=sr[10]|0;Fl=sr[11]|0;Gh=sr[12]|0;Gl=sr[13]|0;Hh=sr[14]|0;Hl=sr[15]|0;constructor(){super(64)}}var Rt=dT(()=>new sZ,fT(1));var My=dT(()=>new lZ,fT(3));/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Jy(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function ST(e){if(!Jy(e))throw TypeError("Uint8Array expected")}function mZ(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 hZ(e){if(typeof e!=="function")throw TypeError("function expected");return!0}function Xo(e,t){if(typeof t!=="string")throw TypeError(`${e}: string expected`);return!0}function _f(e){if(typeof e!=="number")throw TypeError(`number expected, got ${typeof e}`);if(!Number.isSafeInteger(e))throw RangeError(`invalid integer: ${e}`)}function Zy(e){if(!Array.isArray(e))throw TypeError("array expected")}function Hy(e,t){if(!mZ(!0,t))throw TypeError(`${e}: array of strings expected`)}function wT(e,t){if(!mZ(!1,t))throw TypeError(`${e}: array of numbers expected`)}function cn(...e){let t=(o)=>o,r=(o,s)=>(a)=>o(s(a)),i=e.map((o)=>o.encode).reduceRight(r,t),n=e.map((o)=>o.decode).reduce(r,t);return{encode:i,decode:n}}function ln(e){let t=typeof e==="string"?e.split(""):e,r=t.length;Hy("alphabet",t);let i=new Map(t.map((n,o)=>[n,o]));return{encode:(n)=>(Zy(n),n.map((o)=>{if(!Number.isSafeInteger(o)||o<0||o>=r)throw Error(`alphabet.encode: digit index outside alphabet "${o}". Allowed: ${e}`);return t[o]})),decode:(n)=>(Zy(n),n.map((o)=>{Xo("alphabet.decode",o);let s=i.get(o);if(s===void 0)throw Error(`Unknown letter: "${o}". Allowed: ${e}`);return s}))}}function un(e=""){return Xo("join",e),{encode:(t)=>(Hy("join.decode",t),t.join(e)),decode:(t)=>(Xo("join.decode",t),t.split(e))}}function Vy(e,t="="){return _f(e),Xo("padding",t),{encode(r){Hy("padding.encode",r);while(r.length*e%8)r.push(t);return r},decode(r){Hy("padding.decode",r);let i=r.length;if(i*e%8)throw Error("padding: invalid, string should have whole number of bytes");for(;i>0&&r[i-1]===t;i--)if((i-1)*e%8===0)throw Error("padding: invalid, string has too much padding");return r.slice(0,i)}}}function gZ(e){return hZ(e),{encode:(t)=>t,decode:(t)=>e(t)}}function uZ(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(Zy(e),!e.length)return[];let i=0,n=[],o=Array.from(e,(a)=>{if(_f(a),a<0||a>=t)throw Error(`invalid integer: ${a}`);return a}),s=o.length;while(!0){let a=0,c=!0;for(let l=i;l<s;l++){let u=o[l],d=t*a,p=d+u;if(!Number.isSafeInteger(p)||d/t!==a||p-u!==d)throw Error("convertRadix: carry overflow");let m=p/r;a=p%r;let y=Math.floor(m);if(o[l]=y,!Number.isSafeInteger(y)||y*r+a!==p)throw Error("convertRadix: carry overflow");if(!c)continue;else if(!y)i=l;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()}var yZ=(e,t)=>t===0?e:yZ(t,e%t),Ky=(e,t)=>e+(t-yZ(e,t)),Fy=(()=>{let e=[];for(let t=0;t<40;t++)e.push(2**t);return e})();function bT(e,t,r,i){if(Zy(e),t<=0||t>32)throw RangeError(`convertRadix2: wrong from=${t}`);if(r<=0||r>32)throw RangeError(`convertRadix2: wrong to=${r}`);if(Ky(t,r)>32)throw Error(`convertRadix2: carry overflow from=${t} to=${r} carryBits=${Ky(t,r)}`);let n=0,o=0,s=Fy[t],a=Fy[r]-1,c=[];for(let l of e){if(_f(l),l>=s)throw Error(`convertRadix2: invalid data word=${l} from=${t}`);if(n=n<<t|l,o+t>32)throw Error(`convertRadix2: carry overflow pos=${o} from=${t}`);o+=t;for(;o>=r;o-=r)c.push((n>>o-r&a)>>>0);let u=Fy[o];if(u===void 0)throw Error("invalid carry");n&=u-1}if(n=n<<r-o&a,!i&&o>=t)throw Error("Excess padding");if(!i&&n>0)throw Error(`Non-zero padding: ${n}`);if(i&&o>0)c.push(n>>>0);return c}function Dye(e){_f(e);let t=256;return{encode:(r)=>{if(!Jy(r))throw TypeError("radix.encode input should be Uint8Array");return uZ(Array.from(r),t,e)},decode:(r)=>(wT("radix.decode",r),Uint8Array.from(uZ(r,e,t)))}}function wn(e,t=!1){if(_f(e),e<=0||e>32)throw RangeError("radix2: bits should be in (0..32]");if(Ky(8,e)>32||Ky(e,8)>32)throw RangeError("radix2: carry overflow");return{encode:(r)=>{if(!Jy(r))throw TypeError("radix2.encode input should be Uint8Array");return bT(Array.from(r),8,e,!t)},decode:(r)=>(wT("radix2.decode",r),Uint8Array.from(bT(r,e,8,t)))}}function dZ(e){return hZ(e),function(...t){try{return e.apply(null,t)}catch(r){}}}var $Me=Object.freeze(cn(wn(4),ln("0123456789ABCDEF"),un(""))),OMe=Object.freeze(cn(wn(5),ln("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),Vy(5),un(""))),RMe=Object.freeze(cn(wn(5),ln("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),un(""))),PMe=Object.freeze(cn(wn(5),ln("0123456789ABCDEFGHIJKLMNOPQRSTUV"),Vy(5),un(""))),zMe=Object.freeze(cn(wn(5),ln("0123456789ABCDEFGHIJKLMNOPQRSTUV"),un(""))),NMe=Object.freeze(cn(wn(5),ln("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),un(""),gZ((e)=>e.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1")))),bZ=(()=>typeof Uint8Array.from([]).toBase64==="function"&&typeof Uint8Array.fromBase64==="function")(),Lye=/[\t\n\f\r ]/,xZ=(e,t)=>{Xo("base64",e);let r=t?"base64url":"base64";if(e.length>0&&Lye.test(e))throw Error("invalid base64");return Uint8Array.fromBase64(e,{alphabet:r,lastChunkHandling:"strict"})},vT=Object.freeze(bZ?{encode(e){return ST(e),e.toBase64()},decode(e){return xZ(e,!1)}}:cn(wn(6),ln("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),Vy(6),un(""))),wr=Object.freeze(cn(wn(6),ln("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),un(""))),DMe=Object.freeze(bZ?{encode(e){return ST(e),e.toBase64({alphabet:"base64url"})},decode(e){return xZ(e,!0)}}:cn(wn(6),ln("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),Vy(6),un(""))),LMe=Object.freeze(cn(wn(6),ln("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),un(""))),_T=(e)=>cn(Dye(58),ln(e),un("")),BMe=Object.freeze(_T("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")),jMe=Object.freeze(_T("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ")),qMe=Object.freeze(_T("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz"));var xT=cn(ln("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),un("")),fZ=[996825010,642813549,513874426,1027748829,705979059];function vf(e){let t=e>>25,r=(e&33554431)<<5;for(let i=0;i<fZ.length;i++)if((t>>i&1)===1)r^=fZ[i];return r}function pZ(e,t,r=1){let i=e.length,n=1;for(let o=0;o<i;o++){let s=e.charCodeAt(o);if(s<33||s>126)throw Error(`Invalid prefix (${e})`);n=vf(n)^s>>5}n=vf(n);for(let o=0;o<i;o++)n=vf(n)^e.charCodeAt(o)&31;for(let o of t)n=vf(n)^o;for(let o=0;o<6;o++)n=vf(n);return n^=r,xT.encode(bT([n%Fy[30]],30,5,!1))}function SZ(e){let t=e==="bech32"?1:734539939,r=wn(5),i=r.decode,n=r.encode,o=dZ(i);function s(d,p,m=90){if(Xo("bech32.encode prefix",d),Jy(p))p=Array.from(p);wT("bech32.encode",p);let y=d.length;if(y===0)throw TypeError(`Invalid prefix length ${y}`);let g=y+7+p.length;if(m!==!1&&g>m)throw TypeError(`Length ${g} exceeds limit ${m}`);let b=d.toLowerCase(),v=pZ(b,p,t);return`${b}1${xT.encode(p)}${v}`}function a(d,p=90){Xo("bech32.decode input",d);let m=d.length;if(m<8||p!==!1&&m>p)throw TypeError(`invalid string length: ${m} (${d}). Expected (8..${p})`);let y=d.toLowerCase();if(d!==y&&d!==d.toUpperCase())throw Error("String must be lowercase or uppercase");let g=y.lastIndexOf("1");if(g===0||g===-1)throw Error('Letter "1" must be present between prefix and data only');let b=y.slice(0,g),v=y.slice(g+1);if(v.length<6)throw Error("Data must be at least 6 characters long");let A=xT.decode(v).slice(0,-6),T=pZ(b,A,t);if(!v.endsWith(T))throw Error(`Invalid checksum in ${d}: expected "${T}"`);return{prefix:b,words:A}}let c=dZ(a);function l(d){let{prefix:p,words:m}=a(d,!1);return{prefix:p,words:m,bytes:i(m)}}function u(d,p){return s(d,n(p))}return{encode:s,decode:a,encodeFromBytes:u,decodeToBytes:l,decodeUnsafe:c,fromWords:i,fromWordsUnsafe:o,toWords:n}}var dn=Object.freeze(SZ("bech32")),UMe=Object.freeze(SZ("bech32m"));var Bye=(()=>typeof Uint8Array.from([]).toHex==="function"&&typeof Uint8Array.fromHex==="function")(),jye={encode(e){return ST(e),e.toHex()},decode(e){return Xo("hex",e),Uint8Array.fromHex(e)}},MMe=Object.freeze(Bye?jye:cn(wn(4),ln("0123456789abcdef"),un(""),gZ((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 Uye(e,t,r,i){Mi(e);let n=jy({dkLen:32,asyncTick:10},i),{c:o,dkLen:s,asyncTick:a}=n;if(Ot(o,"c"),Ot(s,"dkLen"),Ot(a,"asyncTick"),o<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=lT(t,"password"),l=lT(r,"salt"),u=new Uint8Array(s),d=li.create(e,c),p=d._cloneInto().update(l);return{c:o,dkLen:s,asyncTick:a,DK:u,PRF:d,PRFSalt:p}}function Mye(e,t,r,i,n){if(e.destroy(),t.destroy(),i)i.destroy();return Lr(n),r}function kT(e,t,r,i){let{c:n,dkLen:o,DK:s,PRF:a,PRFSalt:c}=Uye(e,t,r,i),l,u=new Uint8Array(4),d=_l(u),p=new Uint8Array(a.outputLen);for(let m=1,y=0;y<o;m++,y+=a.outputLen){let g=s.subarray(y,y+a.outputLen);d.setInt32(0,m,!1),(l=c._cloneInto(l)).update(u).digestInto(p),g.set(p.subarray(0,g.length));for(let b=1;b<n;b++){a._cloneInto(l).update(p).digestInto(p);for(let v=0;v<g.length;v++)g[v]^=p[v]}}return Mye(a,c,s,l,p)}function wZ(e,t,r,i,n,o){let s=e[t++]^r[i++],a=e[t++]^r[i++],c=e[t++]^r[i++],l=e[t++]^r[i++],u=e[t++]^r[i++],d=e[t++]^r[i++],p=e[t++]^r[i++],m=e[t++]^r[i++],y=e[t++]^r[i++],g=e[t++]^r[i++],b=e[t++]^r[i++],v=e[t++]^r[i++],A=e[t++]^r[i++],T=e[t++]^r[i++],z=e[t++]^r[i++],j=e[t++]^r[i++],E=s,Z=a,D=c,H=l,X=u,M=d,P=p,N=m,I=y,R=g,O=b,F=v,L=A,V=T,_=z,te=j;for(let ue=0;ue<8;ue+=2)X^=Qe(E+L|0,7),I^=Qe(X+E|0,9),L^=Qe(I+X|0,13),E^=Qe(L+I|0,18),R^=Qe(M+Z|0,7),V^=Qe(R+M|0,9),Z^=Qe(V+R|0,13),M^=Qe(Z+V|0,18),_^=Qe(O+P|0,7),D^=Qe(_+O|0,9),P^=Qe(D+_|0,13),O^=Qe(P+D|0,18),H^=Qe(te+F|0,7),N^=Qe(H+te|0,9),F^=Qe(N+H|0,13),te^=Qe(F+N|0,18),Z^=Qe(E+H|0,7),D^=Qe(Z+E|0,9),H^=Qe(D+Z|0,13),E^=Qe(H+D|0,18),P^=Qe(M+X|0,7),N^=Qe(P+M|0,9),X^=Qe(N+P|0,13),M^=Qe(X+N|0,18),F^=Qe(O+R|0,7),I^=Qe(F+O|0,9),R^=Qe(I+F|0,13),O^=Qe(R+I|0,18),L^=Qe(te+_|0,7),V^=Qe(L+te|0,9),_^=Qe(V+L|0,13),te^=Qe(_+V|0,18);n[o++]=s+E|0,n[o++]=a+Z|0,n[o++]=c+D|0,n[o++]=l+H|0,n[o++]=u+X|0,n[o++]=d+M|0,n[o++]=p+P|0,n[o++]=m+N|0,n[o++]=y+I|0,n[o++]=g+R|0,n[o++]=b+O|0,n[o++]=v+F|0,n[o++]=A+L|0,n[o++]=T+V|0,n[o++]=z+_|0,n[o++]=j+te|0}function ET(e,t,r,i,n){let o=i+0,s=i+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++,o+=16,t+=16){if(wZ(r,s,e,t,r,o),a>0)s+=16;wZ(r,o,e,t+=16,r,s)}}function Fye(e,t,r){let i=jy({dkLen:32,asyncTick:10,maxmem:1073742848},r),{N:n,r:o,p:s,dkLen:a,asyncTick:c,maxmem:l,onProgress:u}=i;if(Ot(n,"N"),Ot(o,"r"),Ot(s,"p"),Ot(a,"dkLen"),Ot(c,"asyncTick"),Ot(l,"maxmem"),u!==void 0&&typeof u!=="function")throw Error("progressCb must be a function");let d=128*o,p=d/4,m=Math.pow(2,32);if(n<=1||(n&n-1)!==0||n>m)throw Error('"N" expected a power of 2, and 2^1 <= N <= 2^32');if(s<1||s>(m-1)*32/d)throw Error('"p" expected integer 1..((2^32 - 1) * 32) / (128 * r)');if(a<1||a>(m-1)*32)throw Error('"dkLen" expected integer 1..(2^32 - 1) * 32');let y=d*(n+s+1);if(y>l)throw Error('"maxmem" limit was hit: memUsed(128*r*(N+p+1))='+y+", maxmem="+l);let g=kT(Rt,e,t,{c:1,dkLen:d*s}),b=Ly(g),v=Ly(new Uint8Array(d*n)),A=Ly(new Uint8Array(d)),T=()=>{};if(u){let z=2*n*s,j=Math.max(Math.floor(z/1e4),1),E=0;T=()=>{if(E++,u&&(!(E%j)||E===z))u(E/z)}}return{N:n,r:o,p:s,dkLen:a,blockSize32:p,V:v,B32:b,B:g,tmp:A,blockMixCb:T,asyncTick:c}}function Zye(e,t,r,i,n){let o=kT(Rt,e,r,{c:1,dkLen:t});return Lr(r,i,n),o}function IT(e,t,r){let{N:i,r:n,p:o,dkLen:s,blockSize32:a,V:c,B32:l,B:u,tmp:d,blockMixCb:p}=Fye(e,t,r);cT(l);for(let m=0;m<o;m++){let y=a*m;for(let g=0;g<a;g++)c[g]=l[y+g];for(let g=0,b=0;g<i-1;g++)ET(c,b,c,b+=a,n),p();ET(c,(i-1)*a,l,y,n),p();for(let g=0;g<i;g++){let b=(l[y+a-16]&i-1)>>>0;for(let v=0;v<a;v++)d[v]=l[y+v]^c[b*a+v];ET(d,0,l,y,n),p()}}return cT(l),Zye(e,s,u,c,d)}/*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */function Hye(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function Wy(e){if(typeof e!=="boolean")throw TypeError(`boolean expected, not ${e}`)}function kl(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 Ht(e,t,r=""){let i=Hye(e),n=e?.length,o=t!==void 0;if(!i||o&&n!==t){let s=r&&`"${r}" `,a=o?` of length ${t}`:"",c=i?`length=${n}`:`type=${typeof e}`,l=s+"expected Uint8Array"+a+", got "+c;if(!i)throw TypeError(l);throw RangeError(l)}return e}function AT(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 vZ(e,t,r=!1){Ht(e,void 0,"output");let i=t.outputLen;if(e.length<i)throw RangeError("digestInto() expects output buffer of length at least "+i);if(r&&!El(e))throw Error("invalid output, must be aligned")}function di(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function Mn(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Kye(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}var ga=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)(),Jye=(e)=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255;var Vye=(e)=>{for(let t=0;t<e.length;t++)e[t]=Jye(e[t]);return e},Hi=ga?(e)=>e:Vye;function _Z(e,t){if(t==null||typeof t!=="object")throw Error("options must be defined");return Object.assign(e,t)}function kZ(e,t){if(e.length!==t.length)return!1;let r=0;for(let i=0;i<e.length;i++)r|=e[i]^t[i];return r===0}function EZ(e,t,r){let i=t,n=r||(()=>[]),o=(a,c)=>i(c,...n(a)).update(a).digest(),s=i(new Uint8Array(e),...n(new Uint8Array(0)));return o.outputLen=s.outputLen,o.blockLen=s.blockLen,o.create=(a,...c)=>i(a,...c),o}var IZ=(e,t)=>{function r(i,...n){if(Ht(i,void 0,"key"),e.nonceLength!==void 0){let u=n[0];Ht(u,e.varSizeNonce?void 0:e.nonceLength,"nonce")}let o=e.tagLength;if(o&&n[1]!==void 0)Ht(n[1],void 0,"AAD");let s=t(i,...n),a=(u,d)=>{if(d!==void 0){if(u!==2)throw Error("cipher output not supported");Ht(d,void 0,"output")}},c=!1;return{encrypt(u,d){if(c)throw Error("cannot encrypt() twice with same key + nonce");return c=!0,Ht(u),a(s.encrypt.length,d),s.encrypt(u,d)},decrypt(u,d){if(Ht(u),o&&u.length<o)throw Error('"ciphertext" expected length bigger than tagLength='+o);return a(s.decrypt.length,d),s.decrypt(u,d)}}}return Object.assign(r,e),r};function kf(e,t,r=!0){if(t===void 0)return new Uint8Array(e);if(Ht(t,void 0,"output"),t.length!==e)throw Error('"output" expected Uint8Array of length '+e+", got: "+t.length);if(r&&!El(t))throw Error("invalid output, must be aligned");return t}function AZ(e,t,r){kl(e),kl(t),Wy(r);let i=new Uint8Array(16),n=Kye(i);return n.setBigUint64(0,BigInt(t),r),n.setBigUint64(8,BigInt(e),r),i}function El(e){return e.byteOffset%4===0}function Il(e){return Uint8Array.from(Ht(e))}var CZ=(e)=>Uint8Array.from(e.split(""),(t)=>t.charCodeAt(0)),Wye=(()=>Hi(di(CZ("expand 16-byte k"))))(),Gye=(()=>Hi(di(CZ("expand 32-byte k"))))();function Ye(e,t){return e<<t|e>>>32-t}var Ef=64,Qye=16,TT=(()=>4294967295)(),TZ=Uint32Array.of();function Yye(e,t,r,i,n,o,s,a){let c=n.length,l=new Uint8Array(Ef),u=di(l),d=ga&&El(n)&&El(o),p=d?di(n):TZ,m=d?di(o):TZ;if(!ga){for(let y=0;y<c;s++){if(e(t,r,i,u,s,a),Hi(u),s>=TT)throw Error("arx: counter overflow");let g=Math.min(Ef,c-y);for(let b=0,v;b<g;b++)v=y+b,o[v]=n[v]^l[b];y+=g}return}for(let y=0;y<c;s++){if(e(t,r,i,u,s,a),s>=TT)throw Error("arx: counter overflow");let g=Math.min(Ef,c-y);if(d&&g===Ef){let b=y/4;if(y%4!==0)throw Error("arx: invalid block position");for(let v=0,A;v<Qye;v++)A=b+v,m[A]=p[A]^u[v];y+=Ef;continue}for(let b=0,v;b<g;b++)v=y+b,o[v]=n[v]^l[b];y+=g}}function $Z(e,t){let{allowShortKeys:r,extendNonceFn:i,counterLength:n,counterRight:o,rounds:s}=_Z({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},t);if(typeof e!=="function")throw Error("core must be a function");return kl(n),kl(s),Wy(o),Wy(r),(a,c,l,u,d=0)=>{Ht(a,void 0,"key"),Ht(c,void 0,"nonce"),Ht(l,void 0,"data");let p=l.length;if(u=kf(p,u,!1),kl(d),d<0||d>=TT)throw Error("arx: counter overflow");let m=[],y=a.length,g,b;if(y===32)m.push(g=Il(a)),b=Gye;else if(y===16&&r)g=new Uint8Array(32),g.set(a),g.set(a,16),b=Wye,m.push(g);else throw Ht(a,32,"arx key"),Error("invalid key size");if(!ga||!El(c))m.push(c=Il(c));let v=di(g);if(i){if(c.length!==24)throw Error("arx: extended nonce must be 24 bytes");let z=c.subarray(0,16);if(ga)i(b,v,di(z),v);else{let j=Hi(Uint32Array.from(b));i(j,v,di(z),v),Mn(j),Hi(v)}c=c.subarray(16)}else if(!ga)Hi(v);let A=16-n;if(A!==c.length)throw Error(`arx: nonce must be ${A} or 16 bytes`);if(A!==12){let z=new Uint8Array(12);z.set(c,o?0:12-c.length),c=z,m.push(c)}let T=Hi(di(c));try{return Yye(e,b,v,T,l,u,d,s),u}finally{Mn(...m)}}}function ar(e,t){return e[t++]&255|(e[t++]&255)<<8}class OZ{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=Il(Ht(e,32,"key"));let t=ar(e,0),r=ar(e,2),i=ar(e,4),n=ar(e,6),o=ar(e,8),s=ar(e,10),a=ar(e,12),c=ar(e,14);this.r[0]=t&8191,this.r[1]=(t>>>13|r<<3)&8191,this.r[2]=(r>>>10|i<<6)&7939,this.r[3]=(i>>>7|n<<9)&8191,this.r[4]=(n>>>4|o<<12)&255,this.r[5]=o>>>1&8190,this.r[6]=(o>>>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 l=0;l<8;l++)this.pad[l]=ar(e,16+2*l)}process(e,t,r=!1){let i=r?0:2048,{h:n,r:o}=this,s=o[0],a=o[1],c=o[2],l=o[3],u=o[4],d=o[5],p=o[6],m=o[7],y=o[8],g=o[9],b=ar(e,t+0),v=ar(e,t+2),A=ar(e,t+4),T=ar(e,t+6),z=ar(e,t+8),j=ar(e,t+10),E=ar(e,t+12),Z=ar(e,t+14),D=n[0]+(b&8191),H=n[1]+((b>>>13|v<<3)&8191),X=n[2]+((v>>>10|A<<6)&8191),M=n[3]+((A>>>7|T<<9)&8191),P=n[4]+((T>>>4|z<<12)&8191),N=n[5]+(z>>>1&8191),I=n[6]+((z>>>14|j<<2)&8191),R=n[7]+((j>>>11|E<<5)&8191),O=n[8]+((E>>>8|Z<<8)&8191),F=n[9]+(Z>>>5|i),L=0,V=L+D*s+H*(5*g)+X*(5*y)+M*(5*m)+P*(5*p);L=V>>>13,V&=8191,V+=N*(5*d)+I*(5*u)+R*(5*l)+O*(5*c)+F*(5*a),L+=V>>>13,V&=8191;let _=L+D*a+H*s+X*(5*g)+M*(5*y)+P*(5*m);L=_>>>13,_&=8191,_+=N*(5*p)+I*(5*d)+R*(5*u)+O*(5*l)+F*(5*c),L+=_>>>13,_&=8191;let te=L+D*c+H*a+X*s+M*(5*g)+P*(5*y);L=te>>>13,te&=8191,te+=N*(5*m)+I*(5*p)+R*(5*d)+O*(5*u)+F*(5*l),L+=te>>>13,te&=8191;let ue=L+D*l+H*c+X*a+M*s+P*(5*g);L=ue>>>13,ue&=8191,ue+=N*(5*y)+I*(5*m)+R*(5*p)+O*(5*d)+F*(5*u),L+=ue>>>13,ue&=8191;let C=L+D*u+H*l+X*c+M*a+P*s;L=C>>>13,C&=8191,C+=N*(5*g)+I*(5*y)+R*(5*m)+O*(5*p)+F*(5*d),L+=C>>>13,C&=8191;let Se=L+D*d+H*u+X*l+M*c+P*a;L=Se>>>13,Se&=8191,Se+=N*s+I*(5*g)+R*(5*y)+O*(5*m)+F*(5*p),L+=Se>>>13,Se&=8191;let Ee=L+D*p+H*d+X*u+M*l+P*c;L=Ee>>>13,Ee&=8191,Ee+=N*a+I*s+R*(5*g)+O*(5*y)+F*(5*m),L+=Ee>>>13,Ee&=8191;let $e=L+D*m+H*p+X*d+M*u+P*l;L=$e>>>13,$e&=8191,$e+=N*c+I*a+R*s+O*(5*g)+F*(5*y),L+=$e>>>13,$e&=8191;let Ce=L+D*y+H*m+X*p+M*d+P*u;L=Ce>>>13,Ce&=8191,Ce+=N*l+I*c+R*a+O*s+F*(5*g),L+=Ce>>>13,Ce&=8191;let _e=L+D*g+H*y+X*m+M*p+P*d;L=_e>>>13,_e&=8191,_e+=N*u+I*l+R*c+O*a+F*s,L+=_e>>>13,_e&=8191,L=(L<<2)+L|0,L=L+V|0,V=L&8191,L=L>>>13,_+=L,n[0]=V,n[1]=_,n[2]=te,n[3]=ue,n[4]=C,n[5]=Se,n[6]=Ee,n[7]=$e,n[8]=Ce,n[9]=_e}finalize(){let{h:e,pad:t}=this,r=new Uint16Array(10),i=e[1]>>>13;e[1]&=8191;for(let s=2;s<10;s++)e[s]+=i,i=e[s]>>>13,e[s]&=8191;e[0]+=i*5,i=e[0]>>>13,e[0]&=8191,e[1]+=i,i=e[1]>>>13,e[1]&=8191,e[2]+=i,r[0]=e[0]+5,i=r[0]>>>13,r[0]&=8191;for(let s=1;s<10;s++)r[s]=e[s]+i,i=r[s]>>>13,r[s]&=8191;r[9]-=8192;let n=(i^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 o=e[0]+t[0];e[0]=o&65535;for(let s=1;s<8;s++)o=(e[s]+t[s]|0)+(o>>>16)|0,e[s]=o&65535;Mn(r)}update(e){AT(this),Ht(e),e=Il(e);let{buffer:t,blockLen:r}=this,i=e.length;for(let n=0;n<i;){let o=Math.min(r-this.pos,i-n);if(o===r){for(;r<=i-n;n+=r)this.process(e,n);continue}if(t.set(e.subarray(n,n+o),this.pos),this.pos+=o,n+=o,this.pos===r)this.process(t,0,!1),this.pos=0}return this}destroy(){this.destroyed=!0,Mn(this.h,this.r,this.buffer,this.pad)}digestInto(e){AT(this),vZ(e,this),this.finished=!0;let{buffer:t,h:r}=this,{pos:i}=this;if(i){t[i++]=1;for(;i<16;i++)t[i]=0;this.process(t,0,!0)}this.finalize();let n=0;for(let o=0;o<8;o++)e[n++]=r[o]>>>0,e[n++]=r[o]>>>8}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let r=e.slice(0,t);return this.destroy(),r}}var RZ=EZ(32,(e)=>new OZ(e));function Xye(e,t,r,i,n,o=20){let s=e[0],a=e[1],c=e[2],l=e[3],u=t[0],d=t[1],p=t[2],m=t[3],y=t[4],g=t[5],b=t[6],v=t[7],A=n,T=r[0],z=r[1],j=r[2],E=s,Z=a,D=c,H=l,X=u,M=d,P=p,N=m,I=y,R=g,O=b,F=v,L=A,V=T,_=z,te=j;for(let C=0;C<o;C+=2)E=E+X|0,L=Ye(L^E,16),I=I+L|0,X=Ye(X^I,12),E=E+X|0,L=Ye(L^E,8),I=I+L|0,X=Ye(X^I,7),Z=Z+M|0,V=Ye(V^Z,16),R=R+V|0,M=Ye(M^R,12),Z=Z+M|0,V=Ye(V^Z,8),R=R+V|0,M=Ye(M^R,7),D=D+P|0,_=Ye(_^D,16),O=O+_|0,P=Ye(P^O,12),D=D+P|0,_=Ye(_^D,8),O=O+_|0,P=Ye(P^O,7),H=H+N|0,te=Ye(te^H,16),F=F+te|0,N=Ye(N^F,12),H=H+N|0,te=Ye(te^H,8),F=F+te|0,N=Ye(N^F,7),E=E+M|0,te=Ye(te^E,16),O=O+te|0,M=Ye(M^O,12),E=E+M|0,te=Ye(te^E,8),O=O+te|0,M=Ye(M^O,7),Z=Z+P|0,L=Ye(L^Z,16),F=F+L|0,P=Ye(P^F,12),Z=Z+P|0,L=Ye(L^Z,8),F=F+L|0,P=Ye(P^F,7),D=D+N|0,V=Ye(V^D,16),I=I+V|0,N=Ye(N^I,12),D=D+N|0,V=Ye(V^D,8),I=I+V|0,N=Ye(N^I,7),H=H+X|0,_=Ye(_^H,16),R=R+_|0,X=Ye(X^R,12),H=H+X|0,_=Ye(_^H,8),R=R+_|0,X=Ye(X^R,7);let ue=0;i[ue++]=s+E|0,i[ue++]=a+Z|0,i[ue++]=c+D|0,i[ue++]=l+H|0,i[ue++]=u+X|0,i[ue++]=d+M|0,i[ue++]=p+P|0,i[ue++]=m+N|0,i[ue++]=y+I|0,i[ue++]=g+R|0,i[ue++]=b+O|0,i[ue++]=v+F|0,i[ue++]=A+L|0,i[ue++]=T+V|0,i[ue++]=z+_|0,i[ue++]=j+te|0}var ebe=$Z(Xye,{counterRight:!1,counterLength:4,allowShortKeys:!1});var tbe=new Uint8Array(16),PZ=(e,t)=>{e.update(t);let r=t.length%16;if(r)e.update(tbe.subarray(r))},rbe=new Uint8Array(32);function zZ(e,t,r,i,n){if(n!==void 0)Ht(n,void 0,"AAD");let o=e(t,r,rbe),s=AZ(i.length,n?n.length:0,!0),a=RZ.create(o);if(n)PZ(a,n);PZ(a,i),a.update(s);let c=a.digest();return Mn(o,s),c}var nbe=(e)=>(t,r,i)=>({encrypt(o,s){let a=o.length;s=kf(a+16,s,!1),s.set(o);let c=s.subarray(0,-16);e(t,r,c,c,1);let l=zZ(e,t,r,c,i);return s.set(l,a),Mn(l),s},decrypt(o,s){s=kf(o.length-16,s,!1);let a=o.subarray(0,-16),c=o.subarray(-16),l=zZ(e,t,r,a,i);if(!kZ(c,l))throw Mn(l),Error("invalid tag");return s.set(o.subarray(0,-16)),e(t,r,s,s,1),Mn(l),s}}),vn=IZ({blockSize:64,nonceLength:12,tagLength:16},nbe(ebe));/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Al(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Yt(e,t=""){if(!Number.isSafeInteger(e)||e<0){let r=t&&`"${t}" `;throw Error(`${r}expected integer >= 0, got ${e}`)}}function Ne(e,t,r=""){let i=Al(e),n=e?.length,o=t!==void 0;if(!i||o&&n!==t){let s=r&&`"${r}" `,a=o?` of length ${t}`:"",c=i?`length=${n}`:`type=${typeof e}`;throw Error(s+"expected Uint8Array"+a+", got "+c)}return e}function _n(e){if(typeof e!=="function"||typeof e.create!=="function")throw Error("Hash must wrapped by utils.createHasher");Yt(e.outputLen),Yt(e.blockLen)}function Ji(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 Gy(e,t){Ne(e,void 0,"digestInto() output");let r=t.outputLen;if(e.length<r)throw Error('"digestInto() output" expected to be of length >='+r)}function Qy(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function Vr(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Yy(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Fn(e,t){return e<<32-t|e>>>t}var ibe=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)();function obe(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function sbe(e){for(let t=0;t<e.length;t++)e[t]=obe(e[t]);return e}var CT=ibe?(e)=>e:sbe,DZ=(()=>typeof Uint8Array.from([]).toHex==="function"&&typeof Uint8Array.fromHex==="function")(),abe=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function ya(e){if(Ne(e),DZ)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=abe[e[r]];return t}var Ki={_0:48,_9:57,A:65,F:70,a:97,f:102};function NZ(e){if(e>=Ki._0&&e<=Ki._9)return e-Ki._0;if(e>=Ki.A&&e<=Ki.F)return e-(Ki.A-10);if(e>=Ki.a&&e<=Ki.f)return e-(Ki.a-10);return}function ba(e){if(typeof e!=="string")throw Error("hex string expected, got "+typeof e);if(DZ)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 i=new Uint8Array(r);for(let n=0,o=0;n<r;n++,o+=2){let s=NZ(e.charCodeAt(o)),a=NZ(e.charCodeAt(o+1));if(s===void 0||a===void 0){let c=e[o]+e[o+1];throw Error('hex string expected, got non-hex character "'+c+'" at index '+o)}i[n]=s*16+a}return i}function qt(...e){let t=0;for(let i=0;i<e.length;i++){let n=e[i];Ne(n),t+=n.length}let r=new Uint8Array(t);for(let i=0,n=0;i<e.length;i++){let o=e[i];r.set(o,n),n+=o.length}return r}function Tl(e,t={}){let r=(n,o)=>e(o).update(n).digest(),i=e(void 0);return r.outputLen=i.outputLen,r.blockLen=i.blockLen,r.create=(n)=>e(n),Object.assign(r,t),Object.freeze(r)}function es(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 ts=(e)=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var OT=BigInt(0),$T=BigInt(1);function If(e,t=""){if(typeof e!=="boolean"){let r=t&&`"${t}" `;throw Error(r+"expected boolean, got type="+typeof e)}return e}function LZ(e){if(typeof e==="bigint"){if(!Xy(e))throw Error("positive bigint expected, got "+e)}else Yt(e);return e}function Af(e){let t=LZ(e).toString(16);return t.length&1?"0"+t:t}function BZ(e){if(typeof e!=="string")throw Error("hex string expected, got "+typeof e);return e===""?OT:BigInt("0x"+e)}function rs(e){return BZ(ya(e))}function ns(e){return BZ(ya(eb(Ne(e)).reverse()))}function Cl(e,t){Yt(t),e=LZ(e);let r=ba(e.toString(16).padStart(t*2,"0"));if(r.length!==t)throw Error("number too large");return r}function Tf(e,t){return Cl(e,t).reverse()}function eb(e){return Uint8Array.from(e)}function is(e){return Uint8Array.from(e,(t,r)=>{let i=t.charCodeAt(0);if(t.length!==1||i>127)throw Error(`string contains non-ASCII character "${e[r]}" with code ${i} at position ${r}`);return i})}var Xy=(e)=>typeof e==="bigint"&&OT<=e;function cbe(e,t,r){return Xy(e)&&Xy(t)&&Xy(r)&&t<=e&&e<r}function Cf(e,t,r,i){if(!cbe(t,r,i))throw Error("expected valid "+e+": "+r+" <= n < "+i+", got "+t)}function RT(e){let t;for(t=0;e>OT;e>>=$T,t+=1);return t}var $f=(e)=>($T<<BigInt(e))-$T;function jZ(e,t,r){if(Yt(e,"hashLen"),Yt(t,"qByteLen"),typeof r!=="function")throw Error("hmacFn must be a function");let i=(b)=>new Uint8Array(b),n=Uint8Array.of(),o=Uint8Array.of(0),s=Uint8Array.of(1),a=1000,c=i(e),l=i(e),u=0,d=()=>{c.fill(1),l.fill(0),u=0},p=(...b)=>r(l,qt(c,...b)),m=(b=n)=>{if(l=p(o,b),c=p(),b.length===0)return;l=p(s,b),c=p()},y=()=>{if(u++>=a)throw Error("drbg: tried max amount of iterations");let b=0,v=[];while(b<t){c=p();let A=c.slice();v.push(A),b+=c.length}return qt(...v)};return(b,v)=>{d(),m(b);let A=void 0;while(!(A=v(y())))m();return d(),A}}function xa(e,t={},r={}){if(!e||typeof e!=="object")throw Error("expected valid options object");function i(o,s,a){let c=e[o];if(a&&c===void 0)return;let l=typeof c;if(l!==s||c===null)throw Error(`param "${o}" is invalid: expected ${s}, got ${l}`)}let n=(o,s)=>Object.entries(o).forEach(([a,c])=>i(a,c,s));n(t,!1),n(r,!0)}function PT(e){let t=new WeakMap;return(r,...i)=>{let n=t.get(r);if(n!==void 0)return n;let o=e(r,...i);return t.set(r,o),o}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var jr=BigInt(0),vr=BigInt(1),Sa=BigInt(2),MZ=BigInt(3),FZ=BigInt(4),ZZ=BigInt(5),lbe=BigInt(7),HZ=BigInt(8),ube=BigInt(9),KZ=BigInt(16);function Br(e,t){let r=e%t;return r>=jr?r:t+r}function kn(e,t,r){let i=e;while(t-- >jr)i*=i,i%=r;return i}function qZ(e,t){if(e===jr)throw Error("invert: expected non-zero number");if(t<=jr)throw Error("invert: expected positive modulus, got "+t);let r=Br(e,t),i=t,n=jr,o=vr,s=vr,a=jr;while(r!==jr){let l=i/r,u=i%r,d=n-s*l,p=o-a*l;i=r,r=u,n=s,o=a,s=d,a=p}if(i!==vr)throw Error("invert: does not exist");return Br(n,t)}function zT(e,t,r){if(!e.eql(e.sqr(t),r))throw Error("Cannot find square root")}function JZ(e,t){let r=(e.ORDER+vr)/FZ,i=e.pow(t,r);return zT(e,i,t),i}function dbe(e,t){let r=(e.ORDER-ZZ)/HZ,i=e.mul(t,Sa),n=e.pow(i,r),o=e.mul(t,n),s=e.mul(e.mul(o,Sa),n),a=e.mul(o,e.sub(s,e.ONE));return zT(e,a,t),a}function fbe(e){let t=tb(e),r=VZ(e),i=r(t,t.neg(t.ONE)),n=r(t,i),o=r(t,t.neg(i)),s=(e+lbe)/KZ;return(a,c)=>{let l=a.pow(c,s),u=a.mul(l,i),d=a.mul(l,n),p=a.mul(l,o),m=a.eql(a.sqr(u),c),y=a.eql(a.sqr(d),c);l=a.cmov(l,u,m),u=a.cmov(p,d,y);let g=a.eql(a.sqr(u),c),b=a.cmov(l,u,g);return zT(a,b,c),b}}function VZ(e){if(e<MZ)throw Error("sqrt is not defined for small field");let t=e-vr,r=0;while(t%Sa===jr)t/=Sa,r++;let i=Sa,n=tb(e);while(UZ(n,i)===1)if(i++>1000)throw Error("Cannot find square root: probably non-prime P");if(r===1)return JZ;let o=n.pow(i,t),s=(t+vr)/Sa;return function(c,l){if(c.is0(l))return l;if(UZ(c,l)!==1)throw Error("Cannot find square root");let u=r,d=c.mul(c.ONE,o),p=c.pow(l,t),m=c.pow(l,s);while(!c.eql(p,c.ONE)){if(c.is0(p))return c.ZERO;let y=1,g=c.sqr(p);while(!c.eql(g,c.ONE))if(y++,g=c.sqr(g),y===u)throw Error("Cannot find square root");let b=vr<<BigInt(u-y-1),v=c.pow(d,b);u=y,d=c.sqr(v),p=c.mul(p,d),m=c.mul(m,v)}return m}}function pbe(e){if(e%FZ===MZ)return JZ;if(e%HZ===ZZ)return dbe;if(e%KZ===ube)return fbe(e);return VZ(e)}var mbe=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function NT(e){let t={ORDER:"bigint",BYTES:"number",BITS:"number"},r=mbe.reduce((i,n)=>(i[n]="function",i),t);return xa(e,r),e}function hbe(e,t,r){if(r<jr)throw Error("invalid exponent, negatives unsupported");if(r===jr)return e.ONE;if(r===vr)return t;let i=e.ONE,n=t;while(r>jr){if(r&vr)i=e.mul(i,n);n=e.sqr(n),r>>=vr}return i}function Of(e,t,r=!1){let i=Array(t.length).fill(r?e.ZERO:void 0),n=t.reduce((s,a,c)=>{if(e.is0(a))return s;return i[c]=s,e.mul(s,a)},e.ONE),o=e.inv(n);return t.reduceRight((s,a,c)=>{if(e.is0(a))return s;return i[c]=e.mul(s,i[c]),e.mul(s,a)},o),i}function UZ(e,t){let r=(e.ORDER-vr)/Sa,i=e.pow(t,r),n=e.eql(i,e.ONE),o=e.eql(i,e.ZERO),s=e.eql(i,e.neg(e.ONE));if(!n&&!o&&!s)throw Error("invalid Legendre symbol result");return n?1:o?0:-1}function gbe(e,t){if(t!==void 0)Yt(t);let r=t!==void 0?t:e.toString(2).length,i=Math.ceil(r/8);return{nBitLength:r,nByteLength:i}}class WZ{ORDER;BITS;BYTES;isLE;ZERO=jr;ONE=vr;_lengths;_sqrt;_mod;constructor(e,t={}){if(e<=jr)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:i,nByteLength:n}=gbe(e,r);if(n>2048)throw Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=e,this.BITS=i,this.BYTES=n,this._sqrt=void 0,Object.preventExtensions(this)}create(e){return Br(e,this.ORDER)}isValid(e){if(typeof e!=="bigint")throw Error("invalid field element: expected bigint, got "+typeof e);return jr<=e&&e<this.ORDER}is0(e){return e===jr}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&vr)===vr}neg(e){return Br(-e,this.ORDER)}eql(e,t){return e===t}sqr(e){return Br(e*e,this.ORDER)}add(e,t){return Br(e+t,this.ORDER)}sub(e,t){return Br(e-t,this.ORDER)}mul(e,t){return Br(e*t,this.ORDER)}pow(e,t){return hbe(this,e,t)}div(e,t){return Br(e*qZ(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 qZ(e,this.ORDER)}sqrt(e){if(!this._sqrt)this._sqrt=pbe(this.ORDER);return this._sqrt(this,e)}toBytes(e){return this.isLE?Tf(e,this.BYTES):Cl(e,this.BYTES)}fromBytes(e,t=!1){Ne(e);let{_lengths:r,BYTES:i,isLE:n,ORDER:o,_mod:s}=this;if(r){if(!r.includes(e.length)||e.length>i)throw Error("Field.fromBytes: expected "+r+" bytes, got "+e.length);let c=new Uint8Array(i);c.set(e,n?0:c.length-e.length),e=c}if(e.length!==i)throw Error("Field.fromBytes: expected "+i+" bytes, got "+e.length);let a=n?ns(e):rs(e);if(s)a=Br(a,o);if(!t){if(!this.isValid(a))throw Error("invalid field element: outside of range 0..ORDER")}return a}invertBatch(e){return Of(this,e)}cmov(e,t,r){return r?t:e}}function tb(e,t={}){return new WZ(e,t)}function GZ(e){if(typeof e!=="bigint")throw Error("field order must be bigint");let t=e.toString(2).length;return Math.ceil(t/8)}function DT(e){let t=GZ(e);return t+Math.ceil(t/2)}function QZ(e,t,r=!1){Ne(e);let i=e.length,n=GZ(t),o=DT(t);if(i<16||i<o||i>1024)throw Error("expected "+o+"-1024 bytes of input, got "+i);let s=r?ns(e):rs(e),a=Br(s,t-vr)+vr;return r?Tf(a,n):Cl(a,n)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var $l=BigInt(0),wa=BigInt(1);function Rf(e,t){let r=t.negate();return e?r:t}function qT(e,t){let r=Of(e.Fp,t.map((i)=>i.Z));return t.map((i,n)=>e.fromAffine(i.toAffine(r[n])))}function t3(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw Error("invalid window size, expected [1.."+t+"], got W="+e)}function LT(e,t){t3(e,t);let r=Math.ceil(t/e)+1,i=2**(e-1),n=2**e,o=$f(e),s=BigInt(e);return{windows:r,windowSize:i,mask:o,maxNumber:n,shiftBy:s}}function YZ(e,t,r){let{windowSize:i,mask:n,maxNumber:o,shiftBy:s}=r,a=Number(e&n),c=e>>s;if(a>i)a-=o,c+=wa;let l=t*i,u=l+Math.abs(a)-1,d=a===0,p=a<0,m=t%2!==0;return{nextN:c,offset:u,isZero:d,isNeg:p,isNegF:m,offsetF:l}}var BT=new WeakMap,r3=new WeakMap;function jT(e){return r3.get(e)||1}function XZ(e){if(e!==$l)throw Error("invalid wNAF")}class UT{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 i=e;while(t>$l){if(t&wa)r=r.add(i);i=i.double(),t>>=wa}return r}precomputeWindow(e,t){let{windows:r,windowSize:i}=LT(t,this.bits),n=[],o=e,s=o;for(let a=0;a<r;a++){s=o,n.push(s);for(let c=1;c<i;c++)s=s.add(o),n.push(s);o=s.double()}return n}wNAF(e,t,r){if(!this.Fn.isValid(r))throw Error("invalid scalar");let i=this.ZERO,n=this.BASE,o=LT(e,this.bits);for(let s=0;s<o.windows;s++){let{nextN:a,offset:c,isZero:l,isNeg:u,isNegF:d,offsetF:p}=YZ(r,s,o);if(r=a,l)n=n.add(Rf(d,t[p]));else i=i.add(Rf(u,t[c]))}return XZ(r),{p:i,f:n}}wNAFUnsafe(e,t,r,i=this.ZERO){let n=LT(e,this.bits);for(let o=0;o<n.windows;o++){if(r===$l)break;let{nextN:s,offset:a,isZero:c,isNeg:l}=YZ(r,o,n);if(r=s,c)continue;else{let u=t[a];i=i.add(l?u.negate():u)}}return XZ(r),i}getPrecomputes(e,t,r){let i=BT.get(t);if(!i){if(i=this.precomputeWindow(t,e),e!==1){if(typeof r==="function")i=r(i);BT.set(t,i)}}return i}cached(e,t,r){let i=jT(e);return this.wNAF(i,this.getPrecomputes(i,e,r),t)}unsafe(e,t,r,i){let n=jT(e);if(n===1)return this._unsafeLadder(e,t,i);return this.wNAFUnsafe(n,this.getPrecomputes(n,e,r),t,i)}createCache(e,t){t3(t,this.bits),r3.set(e,t),BT.delete(e)}hasCache(e){return jT(e)!==1}}function n3(e,t,r,i){let n=t,o=e.ZERO,s=e.ZERO;while(r>$l||i>$l){if(r&wa)o=o.add(n);if(i&wa)s=s.add(n);n=n.double(),r>>=wa,i>>=wa}return{p1:o,p2:s}}function e3(e,t,r){if(t){if(t.ORDER!==e)throw Error("Field.ORDER must match order: Fp == p, Fn == n");return NT(t),t}else return tb(e,{isLE:r})}function i3(e,t,r={},i){if(i===void 0)i=e==="edwards";if(!t||typeof t!=="object")throw Error(`expected valid ${e} CURVE object`);for(let c of["p","n","h"]){let l=t[c];if(!(typeof l==="bigint"&&l>$l))throw Error(`CURVE.${c} must be positive bigint`)}let n=e3(t.p,r.Fp,i),o=e3(t.n,r.Fn,i),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:o}}function rb(e,t){return function(i){let n=e(i);return{secretKey:n,publicKey:t(n)}}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var Pf=BigInt(0),Ol=BigInt(1),nb=BigInt(2);function ybe(e){return xa(e,{adjustScalarBytes:"function",powPminus2:"function"}),Object.freeze({...e})}function o3(e){let t=ybe(e),{P:r,type:i,adjustScalarBytes:n,powPminus2:o,randomBytes:s}=t,a=i==="x25519";if(!a&&i!=="x448")throw Error("invalid type");let c=s||es,l=a?255:448,u=a?32:56,d=a?BigInt(9):BigInt(5),p=a?BigInt(121665):BigInt(39081),m=a?nb**BigInt(254):nb**BigInt(447),y=a?BigInt(8)*nb**BigInt(251)-Ol:BigInt(4)*nb**BigInt(445)-Ol,g=m+y+Ol,b=(I)=>Br(I,r),v=A(d);function A(I){return Tf(b(I),u)}function T(I){let R=eb(Ne(I,u,"uCoordinate"));if(a)R[31]&=127;return b(ns(R))}function z(I){return ns(n(eb(Ne(I,u,"scalar"))))}function j(I,R){let O=X(T(R),z(I));if(O===Pf)throw Error("invalid private or public key received");return A(O)}function E(I){return j(I,v)}let Z=E,D=j;function H(I,R,O){let F=b(I*(R-O));return R=b(R-F),O=b(O+F),{x_2:R,x_3:O}}function X(I,R){Cf("u",I,Pf,r),Cf("scalar",R,m,g);let O=R,F=I,L=Ol,V=Pf,_=I,te=Ol,ue=Pf;for(let Se=BigInt(l-1);Se>=Pf;Se--){let Ee=O>>Se&Ol;ue^=Ee,{x_2:L,x_3:_}=H(ue,L,_),{x_2:V,x_3:te}=H(ue,V,te),ue=Ee;let $e=L+V,Ce=b($e*$e),_e=L-V,ze=b(_e*_e),Ve=Ce-ze,Xe=_+te,St=_-te,Lt=b(St*$e),hr=b(Xe*_e),Yr=Lt+hr,Xr=Lt-hr;_=b(Yr*Yr),te=b(F*b(Xr*Xr)),L=b(Ce*ze),V=b(Ve*(Ce+b(p*Ve)))}({x_2:L,x_3:_}=H(ue,L,_)),{x_2:V,x_3:te}=H(ue,V,te);let C=o(V);return b(L*C)}let M={secretKey:u,publicKey:u,seed:u},P=(I=c(u))=>(Ne(I,M.seed,"seed"),I),N={randomSecretKey:P};return Object.freeze({keygen:rb(P,Z),getSharedSecret:D,getPublicKey:Z,scalarMult:j,scalarMultBase:E,utils:N,GuBytes:v.slice(),lengths:M})}class MT{oHash;iHash;blockLen;outputLen;finished=!1;destroyed=!1;constructor(e,t){if(_n(e),Ne(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,i=new Uint8Array(r);i.set(t.length>r?e.create().update(t).digest():t);for(let n=0;n<i.length;n++)i[n]^=54;this.iHash.update(i),this.oHash=e.create();for(let n=0;n<i.length;n++)i[n]^=106;this.oHash.update(i),Vr(i)}update(e){return Ji(this),this.iHash.update(e),this}digestInto(e){Ji(this),Ne(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:i,destroyed:n,blockLen:o,outputLen:s}=this;return e=e,e.finished=i,e.destroyed=n,e.blockLen=o,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 Rl=(e,t,r)=>new MT(e,t).update(r).digest();Rl.create=(e,t)=>new MT(e,t);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var s3=(e,t)=>(e+(e>=0?t:-t)/c3)/t;function bbe(e,t,r){let[[i,n],[o,s]]=t,a=s3(s*e,r),c=s3(-n*e,r),l=e-a*i-c*o,u=-a*n-c*s,d=l<Vi,p=u<Vi;if(d)l=-l;if(p)u=-u;let m=$f(Math.ceil(RT(r)/2))+Pl;if(l<Vi||l>=m||u<Vi||u>=m)throw Error("splitScalar (endomorphism): failed, k="+e);return{k1neg:d,k1:l,k2neg:p,k2:u}}function ZT(e){if(!["compact","recovered","der"].includes(e))throw Error('Signature format must be "compact", "recovered", or "der"');return e}function FT(e,t){let r={};for(let i of Object.keys(t))r[i]=e[i]===void 0?t[i]:e[i];if(If(r.lowS,"lowS"),If(r.prehash,"prehash"),r.format!==void 0)ZT(r.format);return r}class a3 extends Error{constructor(e=""){super(e)}}var os={Err:a3,_tlv:{encode:(e,t)=>{let{Err:r}=os;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length&1)throw new r("tlv.encode: unpadded data");let i=t.length/2,n=Af(i);if(n.length/2&128)throw new r("tlv.encode: long form length too big");let o=i>127?Af(n.length/2|128):"";return Af(e)+o+n+t},decode(e,t){let{Err:r}=os,i=0;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length<2||t[i++]!==e)throw new r("tlv.decode: wrong tlv");let n=t[i++],o=!!(n&128),s=0;if(!o)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 l=t.subarray(i,i+c);if(l.length!==c)throw new r("tlv.decode: length bytes not complete");if(l[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let u of l)s=s<<8|u;if(i+=c,s<128)throw new r("tlv.decode(long): not minimal encoding")}let a=t.subarray(i,i+s);if(a.length!==s)throw new r("tlv.decode: wrong value length");return{v:a,l:t.subarray(i+s)}}},_int:{encode(e){let{Err:t}=os;if(e<Vi)throw new t("integer: negative integers are not allowed");let r=Af(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}=os;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 rs(e)}},toSig(e){let{Err:t,_int:r,_tlv:i}=os,n=Ne(e,void 0,"signature"),{v:o,l:s}=i.decode(48,n);if(s.length)throw new t("invalid signature: left bytes after parsing");let{v:a,l:c}=i.decode(2,o),{v:l,l:u}=i.decode(2,c);if(u.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(l)}},hexFromSig(e){let{_tlv:t,_int:r}=os,i=t.encode(2,r.encode(e.r)),n=t.encode(2,r.encode(e.s)),o=i+n;return t.encode(48,o)}},Vi=BigInt(0),Pl=BigInt(1),c3=BigInt(2),ib=BigInt(3),xbe=BigInt(4);function HT(e,t={}){let r=i3("weierstrass",e,t),{Fp:i,Fn:n}=r,o=r.CURVE,{h:s,n:a}=o;xa(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});let{endo:c}=t;if(c){if(!i.is0(o.a)||typeof c.beta!=="bigint"||!Array.isArray(c.basises))throw Error('invalid endo: expected "beta": bigint and "basises": array')}let l=u3(i,n);function u(){if(!i.isOdd)throw Error("compression is not supported: Field does not have .isOdd()")}function d(P,N,I){let{x:R,y:O}=N.toAffine(),F=i.toBytes(R);if(If(I,"isCompressed"),I){u();let L=!i.isOdd(O);return qt(l3(L),F)}else return qt(Uint8Array.of(4),F,i.toBytes(O))}function p(P){Ne(P,void 0,"Point");let{publicKey:N,publicKeyUncompressed:I}=l,R=P.length,O=P[0],F=P.subarray(1);if(R===N&&(O===2||O===3)){let L=i.fromBytes(F);if(!i.isValid(L))throw Error("bad point: is not on curve, wrong x");let V=g(L),_;try{_=i.sqrt(V)}catch(C){let Se=C instanceof Error?": "+C.message:"";throw Error("bad point: is not on curve, sqrt error"+Se)}u();let te=i.isOdd(_);if((O&1)===1!==te)_=i.neg(_);return{x:L,y:_}}else if(R===I&&O===4){let L=i.BYTES,V=i.fromBytes(F.subarray(0,L)),_=i.fromBytes(F.subarray(L,L*2));if(!b(V,_))throw Error("bad point: is not on curve");return{x:V,y:_}}else throw Error(`bad point: got length ${R}, expected compressed=${N} or uncompressed=${I}`)}let m=t.toBytes||d,y=t.fromBytes||p;function g(P){let N=i.sqr(P),I=i.mul(N,P);return i.add(i.add(I,i.mul(P,o.a)),o.b)}function b(P,N){let I=i.sqr(N),R=g(P);return i.eql(I,R)}if(!b(o.Gx,o.Gy))throw Error("bad curve params: generator point");let v=i.mul(i.pow(o.a,ib),xbe),A=i.mul(i.sqr(o.b),BigInt(27));if(i.is0(i.add(v,A)))throw Error("bad curve params: a or b");function T(P,N,I=!1){if(!i.isValid(N)||I&&i.is0(N))throw Error(`bad point coordinate ${P}`);return N}function z(P){if(!(P instanceof H))throw Error("Weierstrass Point expected")}function j(P){if(!c||!c.basises)throw Error("no endo");return bbe(P,c.basises,n.ORDER)}let E=PT((P,N)=>{let{X:I,Y:R,Z:O}=P;if(i.eql(O,i.ONE))return{x:I,y:R};let F=P.is0();if(N==null)N=F?i.ONE:i.inv(O);let L=i.mul(I,N),V=i.mul(R,N),_=i.mul(O,N);if(F)return{x:i.ZERO,y:i.ZERO};if(!i.eql(_,i.ONE))throw Error("invZ was invalid");return{x:L,y:V}}),Z=PT((P)=>{if(P.is0()){if(t.allowInfinityPoint&&!i.is0(P.Y))return;throw Error("bad point: ZERO")}let{x:N,y:I}=P.toAffine();if(!i.isValid(N)||!i.isValid(I))throw Error("bad point: x or y not field elements");if(!b(N,I))throw Error("bad point: equation left != right");if(!P.isTorsionFree())throw Error("bad point: not in prime-order subgroup");return!0});function D(P,N,I,R,O){return I=new H(i.mul(I.X,P),I.Y,I.Z),N=Rf(R,N),I=Rf(O,I),N.add(I)}class H{static BASE=new H(o.Gx,o.Gy,i.ONE);static ZERO=new H(i.ZERO,i.ONE,i.ZERO);static Fp=i;static Fn=n;X;Y;Z;constructor(P,N,I){this.X=T("x",P),this.Y=T("y",N,!0),this.Z=T("z",I),Object.freeze(this)}static CURVE(){return o}static fromAffine(P){let{x:N,y:I}=P||{};if(!P||!i.isValid(N)||!i.isValid(I))throw Error("invalid affine point");if(P instanceof H)throw Error("projective point not allowed");if(i.is0(N)&&i.is0(I))return H.ZERO;return new H(N,I,i.ONE)}static fromBytes(P){let N=H.fromAffine(y(Ne(P,void 0,"point")));return N.assertValidity(),N}static fromHex(P){return H.fromBytes(ba(P))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(P=8,N=!0){if(M.createCache(this,P),!N)this.multiply(ib);return this}assertValidity(){Z(this)}hasEvenY(){let{y:P}=this.toAffine();if(!i.isOdd)throw Error("Field doesn't support isOdd");return!i.isOdd(P)}equals(P){z(P);let{X:N,Y:I,Z:R}=this,{X:O,Y:F,Z:L}=P,V=i.eql(i.mul(N,L),i.mul(O,R)),_=i.eql(i.mul(I,L),i.mul(F,R));return V&&_}negate(){return new H(this.X,i.neg(this.Y),this.Z)}double(){let{a:P,b:N}=o,I=i.mul(N,ib),{X:R,Y:O,Z:F}=this,L=i.ZERO,V=i.ZERO,_=i.ZERO,te=i.mul(R,R),ue=i.mul(O,O),C=i.mul(F,F),Se=i.mul(R,O);return Se=i.add(Se,Se),_=i.mul(R,F),_=i.add(_,_),L=i.mul(P,_),V=i.mul(I,C),V=i.add(L,V),L=i.sub(ue,V),V=i.add(ue,V),V=i.mul(L,V),L=i.mul(Se,L),_=i.mul(I,_),C=i.mul(P,C),Se=i.sub(te,C),Se=i.mul(P,Se),Se=i.add(Se,_),_=i.add(te,te),te=i.add(_,te),te=i.add(te,C),te=i.mul(te,Se),V=i.add(V,te),C=i.mul(O,F),C=i.add(C,C),te=i.mul(C,Se),L=i.sub(L,te),_=i.mul(C,ue),_=i.add(_,_),_=i.add(_,_),new H(L,V,_)}add(P){z(P);let{X:N,Y:I,Z:R}=this,{X:O,Y:F,Z:L}=P,V=i.ZERO,_=i.ZERO,te=i.ZERO,ue=o.a,C=i.mul(o.b,ib),Se=i.mul(N,O),Ee=i.mul(I,F),$e=i.mul(R,L),Ce=i.add(N,I),_e=i.add(O,F);Ce=i.mul(Ce,_e),_e=i.add(Se,Ee),Ce=i.sub(Ce,_e),_e=i.add(N,R);let ze=i.add(O,L);return _e=i.mul(_e,ze),ze=i.add(Se,$e),_e=i.sub(_e,ze),ze=i.add(I,R),V=i.add(F,L),ze=i.mul(ze,V),V=i.add(Ee,$e),ze=i.sub(ze,V),te=i.mul(ue,_e),V=i.mul(C,$e),te=i.add(V,te),V=i.sub(Ee,te),te=i.add(Ee,te),_=i.mul(V,te),Ee=i.add(Se,Se),Ee=i.add(Ee,Se),$e=i.mul(ue,$e),_e=i.mul(C,_e),Ee=i.add(Ee,$e),$e=i.sub(Se,$e),$e=i.mul(ue,$e),_e=i.add(_e,$e),Se=i.mul(Ee,_e),_=i.add(_,Se),Se=i.mul(ze,_e),V=i.mul(Ce,V),V=i.sub(V,Se),Se=i.mul(Ce,Ee),te=i.mul(ze,te),te=i.add(te,Se),new H(V,_,te)}subtract(P){return this.add(P.negate())}is0(){return this.equals(H.ZERO)}multiply(P){let{endo:N}=t;if(!n.isValidNot0(P))throw Error("invalid scalar: out of range");let I,R,O=(F)=>M.cached(this,F,(L)=>qT(H,L));if(N){let{k1neg:F,k1:L,k2neg:V,k2:_}=j(P),{p:te,f:ue}=O(L),{p:C,f:Se}=O(_);R=ue.add(Se),I=D(N.beta,te,C,F,V)}else{let{p:F,f:L}=O(P);I=F,R=L}return qT(H,[I,R])[0]}multiplyUnsafe(P){let{endo:N}=t,I=this;if(!n.isValid(P))throw Error("invalid scalar: out of range");if(P===Vi||I.is0())return H.ZERO;if(P===Pl)return I;if(M.hasCache(this))return this.multiply(P);if(N){let{k1neg:R,k1:O,k2neg:F,k2:L}=j(P),{p1:V,p2:_}=n3(H,I,O,L);return D(N.beta,V,_,R,F)}else return M.unsafe(I,P)}toAffine(P){return E(this,P)}isTorsionFree(){let{isTorsionFree:P}=t;if(s===Pl)return!0;if(P)return P(H,this);return M.unsafe(this,a).is0()}clearCofactor(){let{clearCofactor:P}=t;if(s===Pl)return this;if(P)return P(H,this);return this.multiplyUnsafe(s)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}toBytes(P=!0){return If(P,"isCompressed"),this.assertValidity(),m(H,this,P)}toHex(P=!0){return ya(this.toBytes(P))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let X=n.BITS,M=new UT(H,t.endo?Math.ceil(X/2):X);return H.BASE.precompute(8),H}function l3(e){return Uint8Array.of(e?2:3)}function u3(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function Sbe(e,t={}){let{Fn:r}=e,i=t.randomBytes||es,n=Object.assign(u3(e.Fp,r),{seed:DT(r.ORDER)});function o(m){try{let y=r.fromBytes(m);return r.isValidNot0(y)}catch(y){return!1}}function s(m,y){let{publicKey:g,publicKeyUncompressed:b}=n;try{let v=m.length;if(y===!0&&v!==g)return!1;if(y===!1&&v!==b)return!1;return!!e.fromBytes(m)}catch(v){return!1}}function a(m=i(n.seed)){return QZ(Ne(m,n.seed,"seed"),r.ORDER)}function c(m,y=!0){return e.BASE.multiply(r.fromBytes(m)).toBytes(y)}function l(m){let{secretKey:y,publicKey:g,publicKeyUncompressed:b}=n;if(!Al(m))return;if("_lengths"in r&&r._lengths||y===g)return;let v=Ne(m,void 0,"key").length;return v===g||v===b}function u(m,y,g=!0){if(l(m)===!0)throw Error("first arg must be private key");if(l(y)===!1)throw Error("second arg must be public key");let b=r.fromBytes(m);return e.fromBytes(y).multiply(b).toBytes(g)}let d={isValidSecretKey:o,isValidPublicKey:s,randomSecretKey:a},p=rb(a,c);return Object.freeze({getPublicKey:c,getSharedSecret:u,keygen:p,Point:e,utils:d,lengths:n})}function KT(e,t,r={}){_n(t),xa(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),r=Object.assign({},r);let i=r.randomBytes||es,n=r.hmac||((I,R)=>Rl(t,I,R)),{Fp:o,Fn:s}=e,{ORDER:a,BITS:c}=s,{keygen:l,getPublicKey:u,getSharedSecret:d,utils:p,lengths:m}=Sbe(e,r),y={prehash:!0,lowS:typeof r.lowS==="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},g=a*c3<o.ORDER;function b(I){let R=a>>Pl;return I>R}function v(I,R){if(!s.isValidNot0(R))throw Error(`invalid signature ${I}: out of range 1..Point.Fn.ORDER`);return R}function A(){if(g)throw Error('"recovered" sig type is not supported for cofactor >2 curves')}function T(I,R){ZT(R);let O=m.signature,F=R==="compact"?O:R==="recovered"?O+1:void 0;return Ne(I,F)}class z{r;s;recovery;constructor(I,R,O){if(this.r=v("r",I),this.s=v("s",R),O!=null){if(A(),![0,1,2,3].includes(O))throw Error("invalid recovery id");this.recovery=O}Object.freeze(this)}static fromBytes(I,R=y.format){T(I,R);let O;if(R==="der"){let{r:_,s:te}=os.toSig(Ne(I));return new z(_,te)}if(R==="recovered")O=I[0],R="compact",I=I.subarray(1);let F=m.signature/2,L=I.subarray(0,F),V=I.subarray(F,F*2);return new z(s.fromBytes(L),s.fromBytes(V),O)}static fromHex(I,R){return this.fromBytes(ba(I),R)}assertRecovery(){let{recovery:I}=this;if(I==null)throw Error("invalid recovery id: must be present");return I}addRecoveryBit(I){return new z(this.r,this.s,I)}recoverPublicKey(I){let{r:R,s:O}=this,F=this.assertRecovery(),L=F===2||F===3?R+a:R;if(!o.isValid(L))throw Error("invalid recovery id: sig.r+curve.n != R.x");let V=o.toBytes(L),_=e.fromBytes(qt(l3((F&1)===0),V)),te=s.inv(L),ue=E(Ne(I,void 0,"msgHash")),C=s.create(-ue*te),Se=s.create(O*te),Ee=e.BASE.multiplyUnsafe(C).add(_.multiplyUnsafe(Se));if(Ee.is0())throw Error("invalid recovery: point at infinify");return Ee.assertValidity(),Ee}hasHighS(){return b(this.s)}toBytes(I=y.format){if(ZT(I),I==="der")return ba(os.hexFromSig(this));let{r:R,s:O}=this,F=s.toBytes(R),L=s.toBytes(O);if(I==="recovered")return A(),qt(Uint8Array.of(this.assertRecovery()),F,L);return qt(F,L)}toHex(I){return ya(this.toBytes(I))}}let j=r.bits2int||function(R){if(R.length>8192)throw Error("input is too large");let O=rs(R),F=R.length*8-c;return F>0?O>>BigInt(F):O},E=r.bits2int_modN||function(R){return s.create(j(R))},Z=$f(c);function D(I){return Cf("num < 2^"+c,I,Vi,Z),s.toBytes(I)}function H(I,R){return Ne(I,void 0,"message"),R?Ne(t(I),void 0,"prehashed message"):I}function X(I,R,O){let{lowS:F,prehash:L,extraEntropy:V}=FT(O,y);I=H(I,L);let _=E(I),te=s.fromBytes(R);if(!s.isValidNot0(te))throw Error("invalid private key");let ue=[D(te),D(_)];if(V!=null&&V!==!1){let $e=V===!0?i(m.secretKey):V;ue.push(Ne($e,void 0,"extraEntropy"))}let C=qt(...ue),Se=_;function Ee($e){let Ce=j($e);if(!s.isValidNot0(Ce))return;let _e=s.inv(Ce),ze=e.BASE.multiply(Ce).toAffine(),Ve=s.create(ze.x);if(Ve===Vi)return;let Xe=s.create(_e*s.create(Se+Ve*te));if(Xe===Vi)return;let St=(ze.x===Ve?0:2)|Number(ze.y&Pl),Lt=Xe;if(F&&b(Xe))Lt=s.neg(Xe),St^=1;return new z(Ve,Lt,g?void 0:St)}return{seed:C,k2sig:Ee}}function M(I,R,O={}){let{seed:F,k2sig:L}=X(I,R,O);return jZ(t.outputLen,s.BYTES,n)(F,L).toBytes(O.format)}function P(I,R,O,F={}){let{lowS:L,prehash:V,format:_}=FT(F,y);if(O=Ne(O,void 0,"publicKey"),R=H(R,V),!Al(I)){let te=I instanceof z?", use sig.toBytes()":"";throw Error("verify expects Uint8Array signature"+te)}T(I,_);try{let te=z.fromBytes(I,_),ue=e.fromBytes(O);if(L&&te.hasHighS())return!1;let{r:C,s:Se}=te,Ee=E(R),$e=s.inv(Se),Ce=s.create(Ee*$e),_e=s.create(C*$e),ze=e.BASE.multiplyUnsafe(Ce).add(ue.multiplyUnsafe(_e));if(ze.is0())return!1;return s.create(ze.x)===C}catch(te){return!1}}function N(I,R,O={}){let{prehash:F}=FT(O,y);return R=H(R,F),z.fromBytes(I,"recovered").recoverPublicKey(R).toBytes()}return Object.freeze({keygen:l,getPublicKey:u,getSharedSecret:d,utils:p,lengths:m,Point:e,sign:M,verify:P,recoverPublicKey:N,Signature:z,hash:t})}function d3(e,t,r){return e&t^~e&r}function f3(e,t,r){return e&t^e&r^t&r}class ob{blockLen;outputLen;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,t,r,i){this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=i,this.buffer=new Uint8Array(e),this.view=Yy(this.buffer)}update(e){Ji(this),Ne(e);let{view:t,buffer:r,blockLen:i}=this,n=e.length;for(let o=0;o<n;){let s=Math.min(i-this.pos,n-o);if(s===i){let a=Yy(e);for(;i<=n-o;o+=i)this.process(a,o);continue}if(r.set(e.subarray(o,o+s),this.pos),this.pos+=s,o+=s,this.pos===i)this.process(t,0),this.pos=0}return this.length+=e.length,this.roundClean(),this}digestInto(e){Ji(this),Gy(e,this),this.finished=!0;let{buffer:t,view:r,blockLen:i,isLE:n}=this,{pos:o}=this;if(t[o++]=128,Vr(this.buffer.subarray(o)),this.padOffset>i-o)this.process(r,0),o=0;for(let u=o;u<i;u++)t[u]=0;r.setBigUint64(i-8,BigInt(this.length*8),n),this.process(r,0);let s=Yy(e),a=this.outputLen;if(a%4)throw Error("_sha2: outputLen must be aligned to 32bit");let c=a/4,l=this.get();if(c>l.length)throw Error("_sha2: outputLen bigger than state");for(let u=0;u<c;u++)s.setUint32(4*u,l[u],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:i,finished:n,destroyed:o,pos:s}=this;if(e.destroyed=o,e.finished=n,e.length=i,e.pos=s,i%t)e.buffer.set(r);return e}clone(){return this._cloneInto()}}var Wi=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var cr=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]);var sb=BigInt(4294967295),p3=BigInt(32);function wbe(e,t=!1){if(t)return{h:Number(e&sb),l:Number(e>>p3&sb)};return{h:Number(e>>p3&sb)|0,l:Number(e&sb)|0}}function ab(e,t=!1){let r=e.length,i=new Uint32Array(r),n=new Uint32Array(r);for(let o=0;o<r;o++){let{h:s,l:a}=wbe(e[o],t);[i[o],n[o]]=[s,a]}return[i,n]}var JT=(e,t,r)=>e>>>r,VT=(e,t,r)=>e<<32-r|t>>>r,va=(e,t,r)=>e>>>r|t<<32-r,_a=(e,t,r)=>e<<32-r|t>>>r,zf=(e,t,r)=>e<<64-r|t>>>r-32,Nf=(e,t,r)=>e>>>r-32|t<<64-r;var m3=(e,t,r)=>e<<r|t>>>32-r,h3=(e,t,r)=>t<<r|e>>>32-r,g3=(e,t,r)=>t<<r-32|e>>>64-r,y3=(e,t,r)=>e<<r-32|t>>>64-r;function fi(e,t,r,i){let n=(t>>>0)+(i>>>0);return{h:e+r+(n/4294967296|0)|0,l:n|0}}var b3=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),x3=(e,t,r,i)=>t+r+i+(e/4294967296|0)|0,S3=(e,t,r,i)=>(e>>>0)+(t>>>0)+(r>>>0)+(i>>>0),w3=(e,t,r,i,n)=>t+r+i+n+(e/4294967296|0)|0,v3=(e,t,r,i,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(i>>>0)+(n>>>0),_3=(e,t,r,i,n,o)=>t+r+i+n+o+(e/4294967296|0)|0;var _be=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]),ss=new Uint32Array(64);class k3 extends ob{constructor(e){super(64,e,8,!1)}get(){let{A:e,B:t,C:r,D:i,E:n,F:o,G:s,H:a}=this;return[e,t,r,i,n,o,s,a]}set(e,t,r,i,n,o,s,a){this.A=e|0,this.B=t|0,this.C=r|0,this.D=i|0,this.E=n|0,this.F=o|0,this.G=s|0,this.H=a|0}process(e,t){for(let u=0;u<16;u++,t+=4)ss[u]=e.getUint32(t,!1);for(let u=16;u<64;u++){let d=ss[u-15],p=ss[u-2],m=Fn(d,7)^Fn(d,18)^d>>>3,y=Fn(p,17)^Fn(p,19)^p>>>10;ss[u]=y+ss[u-7]+m+ss[u-16]|0}let{A:r,B:i,C:n,D:o,E:s,F:a,G:c,H:l}=this;for(let u=0;u<64;u++){let d=Fn(s,6)^Fn(s,11)^Fn(s,25),p=l+d+d3(s,a,c)+_be[u]+ss[u]|0,y=(Fn(r,2)^Fn(r,13)^Fn(r,22))+f3(r,i,n)|0;l=c,c=a,a=s,s=o+p|0,o=n,n=i,i=r,r=p+y|0}r=r+this.A|0,i=i+this.B|0,n=n+this.C|0,o=o+this.D|0,s=s+this.E|0,a=a+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(r,i,n,o,s,a,c,l)}roundClean(){Vr(ss)}destroy(){this.set(0,0,0,0,0,0,0,0),Vr(this.buffer)}}class E3 extends k3{A=Wi[0]|0;B=Wi[1]|0;C=Wi[2]|0;D=Wi[3]|0;E=Wi[4]|0;F=Wi[5]|0;G=Wi[6]|0;H=Wi[7]|0;constructor(){super(32)}}var I3=(()=>ab(["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))))(),kbe=(()=>I3[0])(),Ebe=(()=>I3[1])(),as=new Uint32Array(80),cs=new Uint32Array(80);class A3 extends ob{constructor(e){super(128,e,16,!1)}get(){let{Ah:e,Al:t,Bh:r,Bl:i,Ch:n,Cl:o,Dh:s,Dl:a,Eh:c,El:l,Fh:u,Fl:d,Gh:p,Gl:m,Hh:y,Hl:g}=this;return[e,t,r,i,n,o,s,a,c,l,u,d,p,m,y,g]}set(e,t,r,i,n,o,s,a,c,l,u,d,p,m,y,g){this.Ah=e|0,this.Al=t|0,this.Bh=r|0,this.Bl=i|0,this.Ch=n|0,this.Cl=o|0,this.Dh=s|0,this.Dl=a|0,this.Eh=c|0,this.El=l|0,this.Fh=u|0,this.Fl=d|0,this.Gh=p|0,this.Gl=m|0,this.Hh=y|0,this.Hl=g|0}process(e,t){for(let A=0;A<16;A++,t+=4)as[A]=e.getUint32(t),cs[A]=e.getUint32(t+=4);for(let A=16;A<80;A++){let T=as[A-15]|0,z=cs[A-15]|0,j=va(T,z,1)^va(T,z,8)^JT(T,z,7),E=_a(T,z,1)^_a(T,z,8)^VT(T,z,7),Z=as[A-2]|0,D=cs[A-2]|0,H=va(Z,D,19)^zf(Z,D,61)^JT(Z,D,6),X=_a(Z,D,19)^Nf(Z,D,61)^VT(Z,D,6),M=S3(E,X,cs[A-7],cs[A-16]),P=w3(M,j,H,as[A-7],as[A-16]);as[A]=P|0,cs[A]=M|0}let{Ah:r,Al:i,Bh:n,Bl:o,Ch:s,Cl:a,Dh:c,Dl:l,Eh:u,El:d,Fh:p,Fl:m,Gh:y,Gl:g,Hh:b,Hl:v}=this;for(let A=0;A<80;A++){let T=va(u,d,14)^va(u,d,18)^zf(u,d,41),z=_a(u,d,14)^_a(u,d,18)^Nf(u,d,41),j=u&p^~u&y,E=d&m^~d&g,Z=v3(v,z,E,Ebe[A],cs[A]),D=_3(Z,b,T,j,kbe[A],as[A]),H=Z|0,X=va(r,i,28)^zf(r,i,34)^zf(r,i,39),M=_a(r,i,28)^Nf(r,i,34)^Nf(r,i,39),P=r&n^r&s^n&s,N=i&o^i&a^o&a;b=y|0,v=g|0,y=p|0,g=m|0,p=u|0,m=d|0,{h:u,l:d}=fi(c|0,l|0,D|0,H|0),c=s|0,l=a|0,s=n|0,a=o|0,n=r|0,o=i|0;let I=b3(H,M,N);r=x3(I,D,X,P),i=I|0}({h:r,l:i}=fi(this.Ah|0,this.Al|0,r|0,i|0)),{h:n,l:o}=fi(this.Bh|0,this.Bl|0,n|0,o|0),{h:s,l:a}=fi(this.Ch|0,this.Cl|0,s|0,a|0),{h:c,l}=fi(this.Dh|0,this.Dl|0,c|0,l|0),{h:u,l:d}=fi(this.Eh|0,this.El|0,u|0,d|0),{h:p,l:m}=fi(this.Fh|0,this.Fl|0,p|0,m|0),{h:y,l:g}=fi(this.Gh|0,this.Gl|0,y|0,g|0),{h:b,l:v}=fi(this.Hh|0,this.Hl|0,b|0,v|0),this.set(r,i,n,o,s,a,c,l,u,d,p,m,y,g,b,v)}roundClean(){Vr(as,cs)}destroy(){Vr(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class T3 extends A3{Ah=cr[0]|0;Al=cr[1]|0;Bh=cr[2]|0;Bl=cr[3]|0;Ch=cr[4]|0;Cl=cr[5]|0;Dh=cr[6]|0;Dl=cr[7]|0;Eh=cr[8]|0;El=cr[9]|0;Fh=cr[10]|0;Fl=cr[11]|0;Gh=cr[12]|0;Gl=cr[13]|0;Hh=cr[14]|0;Hl=cr[15]|0;constructor(){super(48)}}var cb=Tl(()=>new E3,ts(1));var C3=Tl(()=>new T3,ts(2));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var Ibe=BigInt(1),$3=BigInt(2),Abe=BigInt(3),Tbe=BigInt(5),HFe=BigInt(8),O3=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed");function Cbe(e){let t=BigInt(10),r=BigInt(20),i=BigInt(40),n=BigInt(80),o=O3,a=e*e%o*e%o,c=kn(a,$3,o)*a%o,l=kn(c,Ibe,o)*e%o,u=kn(l,Tbe,o)*l%o,d=kn(u,t,o)*u%o,p=kn(d,r,o)*d%o,m=kn(p,i,o)*p%o,y=kn(m,n,o)*m%o,g=kn(y,n,o)*m%o,b=kn(g,t,o)*u%o;return{pow_p_5_8:kn(b,$3,o)*e%o,b2:a}}function $be(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var R3=(()=>{let e=O3;return o3({P:e,type:"x25519",powPminus2:(t)=>{let{pow_p_5_8:r,b2:i}=Cbe(t);return Br(kn(r,Abe,e)*i,e)},adjustScalarBytes:$be})})();/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var Obe=(()=>({p:BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),h:BigInt(1),a:BigInt("0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc"),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")}))(),Rbe=(()=>({p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff"),n:BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973"),h:BigInt(1),a:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000fffffffc"),b:BigInt("0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef"),Gx:BigInt("0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7"),Gy:BigInt("0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f")}))();var Pbe=HT(Obe),WT=KT(Pbe,cb);var zbe=HT(Rbe),P3=KT(zbe,C3);function N3(e,t,r){if(_n(e),r===void 0)r=new Uint8Array(e.outputLen);return Rl(e,r,t)}var GT=Uint8Array.of(0),z3=Uint8Array.of();function D3(e,t,r,i=32){_n(e),Yt(i,"length");let n=e.outputLen;if(i>255*n)throw Error("Length must be <= 255*HashLen");let o=Math.ceil(i/n);if(r===void 0)r=z3;else Ne(r,void 0,"info");let s=new Uint8Array(o*n),a=Rl.create(e,t),c=a._cloneInto(),l=new Uint8Array(a.outputLen);for(let u=0;u<o;u++)GT[0]=u+1,c.update(u===0?z3:l).update(r).update(GT).digestInto(l),s.set(l,n*u),a._cloneInto(c);return a.destroy(),c.destroy(),Vr(l,GT),s.slice(0,i)}var Nbe=BigInt(0),Df=BigInt(1),Dbe=BigInt(2),Lbe=BigInt(7),Bbe=BigInt(256),jbe=BigInt(113),j3=[],q3=[],U3=[];for(let e=0,t=Df,r=1,i=0;e<24;e++){[r,i]=[i,(2*r+3*i)%5],j3.push(2*(5*i+r)),q3.push((e+1)*(e+2)/2%64);let n=Nbe;for(let o=0;o<7;o++)if(t=(t<<Df^(t>>Lbe)*jbe)%Bbe,t&Dbe)n^=Df<<(Df<<BigInt(o))-Df;U3.push(n)}var M3=ab(U3,!0),qbe=M3[0],Ube=M3[1],L3=(e,t,r)=>r>32?g3(e,t,r):m3(e,t,r),B3=(e,t,r)=>r>32?y3(e,t,r):h3(e,t,r);function Mbe(e,t=24){let r=new Uint32Array(10);for(let i=24-t;i<24;i++){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,l=r[c],u=r[c+1],d=L3(l,u,1)^r[a],p=B3(l,u,1)^r[a+1];for(let m=0;m<50;m+=10)e[s+m]^=d,e[s+m+1]^=p}let n=e[2],o=e[3];for(let s=0;s<24;s++){let a=q3[s],c=L3(n,o,a),l=B3(n,o,a),u=j3[s];n=e[u],o=e[u+1],e[u]=c,e[u+1]=l}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]^=qbe[i],e[1]^=Ube[i]}Vr(r)}class lb{state;pos=0;posOut=0;finished=!1;state32;destroyed=!1;blockLen;suffix;outputLen;enableXOF=!1;rounds;constructor(e,t,r,i=!1,n=24){if(this.blockLen=e,this.suffix=t,this.outputLen=r,this.enableXOF=i,this.rounds=n,Yt(r,"outputLen"),!(0<e&&e<200))throw Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=Qy(this.state)}clone(){return this._cloneInto()}keccak(){CT(this.state32),Mbe(this.state32,this.rounds),CT(this.state32),this.posOut=0,this.pos=0}update(e){Ji(this),Ne(e);let{blockLen:t,state:r}=this,i=e.length;for(let n=0;n<i;){let o=Math.min(t-this.pos,i-n);for(let s=0;s<o;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:i}=this;if(e[r]^=t,(t&128)!==0&&r===i-1)this.keccak();e[i-1]^=128,this.keccak()}writeInto(e){Ji(this,!1),Ne(e),this.finish();let t=this.state,{blockLen:r}=this;for(let i=0,n=e.length;i<n;){if(this.posOut>=r)this.keccak();let o=Math.min(r-this.posOut,n-i);e.set(t.subarray(this.posOut,this.posOut+o),i),this.posOut+=o,i+=o}return e}xofInto(e){if(!this.enableXOF)throw Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return Yt(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Gy(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,Vr(this.state)}_cloneInto(e){let{blockLen:t,suffix:r,outputLen:i,rounds:n,enableXOF:o}=this;return e||=new lb(t,r,i,o,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=i,e.enableXOF=o,e.destroyed=this.destroyed,e}}var F3=(e,t,r,i={})=>Tl(()=>new lb(t,e,r),i);var ka=F3(6,136,32,ts(8));var Z3=F3(6,72,64,ts(10));var H3=(e,t,r,i={})=>Tl((n={})=>new lb(t,e,n.dkLen===void 0?r:n.dkLen,!0),i),K3=H3(31,168,16,ts(11)),pi=H3(31,136,32,ts(12));function QT(e){if(!Number.isSafeInteger(e)||e<0||e>4294967295)throw Error("wrong u32 integer:"+e);return e}function V3(e){return QT(e),(e&e-1)===0&&e!==0}function YT(e,t){QT(e);let r=0;for(let i=0;i<t;i++,e>>>=1)r=r<<1|e&1;return r}function W3(e){return QT(e),31-Math.clz32(e)}function J3(e){let t=e.length;if(t<2||!V3(t))throw Error("n must be a power of 2 and greater than 1. Got "+t);let r=W3(t);for(let i=0;i<t;i++){let n=YT(i,r);if(i<n){let o=e[i];e[i]=e[n],e[n]=o}}return e}var XT=(e,t)=>{let{N:r,roots:i,dit:n,invertButterflies:o=!1,skipStages:s=0,brp:a=!0}=t,c=W3(r);if(!V3(r))throw Error("FFT: Polynomial size should be power of two");let l=n!==o;return(u)=>{if(u.length!==r)throw Error("FFT: wrong Polynomial length");if(n&&a)J3(u);for(let d=0,p=1;d<c-s;d++){let m=n?d+1+s:c-d,y=1<<m,g=y>>1,b=r>>m;for(let v=0;v<r;v+=y)for(let A=0,T=p++;A<g;A++){let z=o?n?r-T:T:A*b,j=v+A,E=v+A+g,Z=i[z],D=u[E],H=u[j];if(l){let X=e.mul(D,Z);u[j]=e.add(H,X),u[E]=e.sub(H,X)}else if(o)u[j]=e.add(D,H),u[E]=e.mul(e.sub(D,H),Z);else u[j]=e.add(H,D),u[E]=e.mul(e.sub(H,D),Z)}}if(!n&&a)J3(u);return u}};/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */var mi=es;function ub(e,t){if(e.length!==t.length)return!1;let r=0;for(let i=0;i<e.length;i++)r|=e[i]^t[i];return r===0}function G3(e){return Uint8Array.from(e)}function Ea(e,...t){let r=(n)=>typeof n==="number"?n:n.bytesLen,i=t.reduce((n,o)=>n+r(o),0);return{bytesLen:i,encode:(n)=>{let o=new Uint8Array(i);for(let s=0,a=0;s<t.length;s++){let c=t[s],l=r(c),u=typeof c==="number"?n[s]:c.encode(n[s]);if(Ne(u,l,e),o.set(u,a),typeof c!=="number")u.fill(0);a+=l}return o},decode:(n)=>{Ne(n,i,e);let o=[];for(let s of t){let a=r(s),c=n.subarray(0,a);o.push(typeof s==="number"?c:s.decode(c)),n=n.subarray(a)}return o}}}function db(e,t){let r=t*e.bytesLen;return{bytesLen:r,encode:(i)=>{if(i.length!==t)throw Error(`vecCoder.encode: wrong length=${i.length}. Expected: ${t}`);let n=new Uint8Array(r);for(let o=0,s=0;o<i.length;o++){let a=e.encode(i[o]);n.set(a,s),a.fill(0),s+=a.length}return n},decode:(i)=>{Ne(i,r);let n=[];for(let o=0;o<i.length;o+=e.bytesLen)n.push(e.decode(i.subarray(o,o+e.bytesLen)));return n}}}function Kt(...e){for(let t of e)if(Array.isArray(t))for(let r of t)r.fill(0);else t.fill(0)}function eC(e){return(1<<e)-1}var sZe=Uint8Array.of();/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */var Q3=(e)=>{let{newPoly:t,N:r,Q:i,F:n,ROOT_OF_UNITY:o,brvBits:s,isKyber:a}=e,c=(A,T=i)=>{let z=A%T|0;return(z>=0?z|0:T+z|0)|0},l=(A,T=i)=>{let z=c(A,T)|0;return(z>T>>1?z-T|0:z)|0};function u(){let A=t(r);for(let T=0;T<r;T++){let z=YT(T,s),j=BigInt(o)**BigInt(z)%BigInt(i);A[T]=Number(j)|0}return A}let d=u(),p={add:(A,T)=>c((A|0)+(T|0))|0,sub:(A,T)=>c((A|0)-(T|0))|0,mul:(A,T)=>c((A|0)*(T|0))|0,inv:(A)=>{throw Error("not implemented")}},m={N:r,roots:d,invertButterflies:!0,skipStages:a?1:0,brp:!1},y=XT(p,{dit:!1,...m}),g=XT(p,{dit:!0,...m});return{mod:c,smod:l,nttZetas:d,NTT:{encode:(A)=>y(A),decode:(A)=>{g(A);for(let T=0;T<A.length;T++)A[T]=c(n*A[T]);return A}},bitsCoder:(A,T)=>{let z=eC(A),j=A*(r/8);return{bytesLen:j,encode:(E)=>{let Z=new Uint8Array(j);for(let D=0,H=0,X=0,M=0;D<E.length;D++){H|=(T.encode(E[D])&z)<<X,X+=A;for(;X>=8;X-=8,H>>=8)Z[M++]=H&eC(X)}return Z},decode:(E)=>{let Z=t(r);for(let D=0,H=0,X=0,M=0;D<E.length;D++){H|=E[D]<<X,X+=8;for(;X>=A;X-=A,H>>=A)Z[M++]=T.decode(H&z)}return Z}}}}},Fbe=(e)=>(t,r)=>{if(!r)r=e.blockLen;let i=new Uint8Array(t.length+2);i.set(t);let n=t.length,o=new Uint8Array(r),s=e.create({}),a=0,c=0;return{stats:()=>({calls:a,xofs:c}),get:(l,u)=>(i[n+0]=l,i[n+1]=u,s.destroy(),s=e.create({}).update(i),a++,()=>(c++,s.xofInto(o))),clean:()=>{s.destroy(),Kt(o,i)}}},Y3=Fbe(K3);/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */var _r=256,Gi=3329,Zbe=3303,Hbe=17,{mod:jf,nttZetas:Kbe,NTT:Ia,bitsCoder:Jbe}=Q3({N:_r,Q:Gi,F:Zbe,ROOT_OF_UNITY:Hbe,newPoly:(e)=>new Uint16Array(e),brvBits:7,isKyber:!0}),tC={512:{N:_r,Q:Gi,K:2,ETA1:3,ETA2:2,du:10,dv:4,RBGstrength:128},768:{N:_r,Q:Gi,K:3,ETA1:2,ETA2:2,du:10,dv:4,RBGstrength:192},1024:{N:_r,Q:Gi,K:4,ETA1:2,ETA2:2,du:11,dv:5,RBGstrength:256}},Vbe=(e)=>{if(e>=12)return{encode:(r)=>r,decode:(r)=>r};let t=2**(e-1);return{encode:(r)=>((r<<e)+Gi/2)/Gi,decode:(r)=>r*Gi+t>>>e}},Lf=(e)=>Jbe(e,Vbe(e));function Aa(e,t){for(let r=0;r<_r;r++)e[r]=jf(e[r]+t[r])}function Wbe(e,t){for(let r=0;r<_r;r++)e[r]=jf(e[r]-t[r])}function Gbe(e,t,r,i,n){let o=jf(t*i*n+e*r),s=jf(e*i+t*r);return{c0:o,c1:s}}function fb(e,t){for(let r=0;r<_r/2;r++){let i=Kbe[64+(r>>1)];if(r&1)i=-i;let{c0:n,c1:o}=Gbe(e[2*r+0],e[2*r+1],t[2*r+0],t[2*r+1],i);e[2*r+0]=n,e[2*r+1]=o}return e}function X3(e){let t=new Uint16Array(_r);for(let r=0;r<_r;){let i=e();if(i.length%3)throw Error("SampleNTT: unaligned block");for(let n=0;r<_r&&n+3<=i.length;n+=3){let o=(i[n+0]>>0|i[n+1]<<8)&4095,s=(i[n+1]>>4|i[n+2]<<4)&4095;if(o<Gi)t[r++]=o;if(r<_r&&s<Gi)t[r++]=s}}return t}function Bf(e,t,r,i){let n=e(i*_r/4,t,r),o=new Uint16Array(_r),s=Qy(n),a=0;for(let c=0,l=0,u=0,d=0;c<s.length;c++){let p=s[c];for(let m=0;m<32;m++)if(u+=p&1,p>>=1,a+=1,a===i)d=u,u=0;else if(a===2*i)o[l++]=jf(d-u),u=0,a=0}if(a)throw Error(`sampleCBD: leftover bits: ${a}`);return o}var Qbe=(e)=>{let{K:t,PRF:r,XOF:i,HASH512:n,ETA1:o,ETA2:s,du:a,dv:c}=e,l=Lf(1),u=Lf(c),d=Lf(a),p=Ea("publicKey",db(Lf(12),t),32),m=db(Lf(12),t),y=Ea("ciphertext",db(d,t),u),g=Ea("seed",32,32);return{secretCoder:m,lengths:{secretKey:m.bytesLen,publicKey:p.bytesLen,cipherText:y.bytesLen},keygen:(b)=>{Ne(b,32,"seed");let v=new Uint8Array(33);v.set(b),v[32]=t;let A=n(v),[T,z]=g.decode(A),j=[],E=[];for(let H=0;H<t;H++)j.push(Ia.encode(Bf(r,z,H,o)));let Z=i(T);for(let H=0;H<t;H++){let X=Ia.encode(Bf(r,z,t+H,o));for(let M=0;M<t;M++){let P=X3(Z.get(M,H));Aa(X,fb(P,j[M]))}E.push(X)}Z.clean();let D={publicKey:p.encode([E,T]),secretKey:m.encode(j)};return Kt(T,z,j,E,v,A),D},encrypt:(b,v,A)=>{let[T,z]=p.decode(b),j=[];for(let M=0;M<t;M++)j.push(Ia.encode(Bf(r,A,M,o)));let E=i(z),Z=new Uint16Array(_r),D=[];for(let M=0;M<t;M++){let P=Bf(r,A,t+M,s),N=new Uint16Array(_r);for(let I=0;I<t;I++){let R=X3(E.get(M,I));Aa(N,fb(R,j[I]))}Aa(P,Ia.decode(N)),D.push(P),Aa(Z,fb(T[M],j[M])),Kt(N)}E.clean();let H=Bf(r,A,2*t,s);Aa(H,Ia.decode(Z));let X=l.decode(v);return Aa(X,H),Kt(T,j,Z,H),y.encode([D,X])},decrypt:(b,v)=>{let[A,T]=y.decode(b),z=m.decode(v),j=new Uint16Array(_r);for(let E=0;E<t;E++)Aa(j,fb(z[E],Ia.encode(A[E])));return Wbe(T,Ia.decode(j)),Kt(j,z,A),l.encode(T)}}};function rC(e){let t=Qbe(e),{HASH256:r,HASH512:i,KDF:n}=e,{secretCoder:o,lengths:s}=t,a=Ea("secretKey",s.secretKey,s.publicKey,32,32),c=32,l=64;return{info:{type:"ml-kem"},lengths:{...s,seed:64,msg:32,msgRand:32,secretKey:a.bytesLen},keygen:(u=mi(64))=>{Ne(u,64,"seed");let{publicKey:d,secretKey:p}=t.keygen(u.subarray(0,32)),m=r(d),y=a.encode([p,d,m,u.subarray(32)]);return Kt(p,m),{publicKey:d,secretKey:y}},getPublicKey:(u)=>{let[d,p,m,y]=a.decode(u);return Uint8Array.from(p)},encapsulate:(u,d=mi(32))=>{Ne(u,s.publicKey,"publicKey"),Ne(d,32,"message");let p=u.subarray(0,384*e.K),m=o.encode(o.decode(G3(p)));if(!ub(m,p))throw Kt(m),Error("ML-KEM.encapsulate: wrong publicKey modulus");Kt(m);let y=i.create().update(d).update(r(u)).digest(),g=t.encrypt(u,d,y.subarray(32,64));return Kt(y.subarray(32)),{cipherText:g,sharedSecret:y.subarray(0,32)}},decapsulate:(u,d)=>{Ne(d,a.bytesLen,"secretKey"),Ne(u,s.cipherText,"cipherText");let p=a.bytesLen-96,m=p+32,y=r(d.subarray(p/2,m));if(!ub(y,d.subarray(m,m+32)))throw Error("invalid secretKey: hash check failed");let[g,b,v,A]=a.decode(d),T=t.decrypt(u,g),z=i.create().update(T).update(v).digest(),j=z.subarray(0,32),E=t.encrypt(b,T,z.subarray(32,64)),Z=ub(u,E),D=n.create({dkLen:32}).update(A).update(u).digest();return Kt(T,E,!Z?j:D),Z?j:D}}}function Ybe(e,t,r){return pi.create({dkLen:e}).update(t).update(new Uint8Array([r])).digest()}var nC={HASH256:ka,HASH512:Z3,KDF:pi,XOF:Y3,PRF:Ybe},yZe=rC({...nC,...tC[512]}),qf=rC({...nC,...tC[768]}),e5=rC({...nC,...tC[1024]});/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */function Xbe(e,t=!1){let{lengths:r,keygen:i}=e;if(t){let o=e.Point.Fn;if(!o)throw Error("No Point.Fn");i=(s=mi(r.seed))=>{Ne(s,r.seed,"seed");let a=o.isLE?ns(s):rs(s),c=o.toBytes(o.create(a));return{secretKey:c,publicKey:e.getPublicKey(c)}}}return{lengths:{secretKey:r.secretKey,publicKey:r.publicKey,seed:r.seed},keygen:i,getPublicKey:(n)=>e.getPublicKey(n)}}function iC(e,t=!1){let r=Xbe(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(i,n=mi(e.lengths.seed)){let o=this.keygen(n).secretKey,s=this.decapsulate(i,o),a=e.getPublicKey(o);return Kt(o),{sharedSecret:s,cipherText:a}},decapsulate(i,n){let o=e.getSharedSecret(n,i);return e.lengths.publicKeyHasPrefix?o.subarray(1):o}}}function Uf(e,t){return Ea(t,...e.map((r)=>{if(typeof r.lengths[t]!=="number")throw Error("wrong length: "+t);return r.lengths[t]}))}function oC(e){return(t,r)=>e(t,{dkLen:r})}function exe(e,t,...r){let i=Uf(r,"seed"),n=Uf(r,"publicKey");if(e===void 0)e=i.bytesLen;Yt(e);function o(s){Ne(s,e);let a=i.decode(t(s,i.bytesLen)),c=r.map((d,p)=>d.keygen(a[p])),l=c.map((d)=>d.secretKey),u=c.map((d)=>d.publicKey);return{secretKey:l,publicKey:u}}return{info:{lengths:{seed:e,publicKey:n.bytesLen,secretKey:e}},getPublicKey(s){return this.keygen(s).publicKey},keygen(s=mi(e)){let{publicKey:a,secretKey:c}=o(s),l=n.encode(a);return Kt(a),Kt(c),{secretKey:s,publicKey:l}},expandDecapsulationKey:o,realSeedLen:e}}function pb(e,t,r,i,...n){let o=exe(e,r,...n),s=Uf(n,"cipherText"),a=Uf(n,"publicKey"),c=Uf(n,"msg");if(t===void 0)t=c.bytesLen;return Yt(t),{lengths:{...o.info.lengths,msg:t,msgRand:c.bytesLen,cipherText:s.bytesLen},getPublicKey:o.getPublicKey,keygen:o.keygen,encapsulate(l,u=mi(c.bytesLen)){let d=a.decode(l),p=c.decode(u),m=n.map((v,A)=>v.encapsulate(d[A],p[A])),y=m.map((v)=>v.sharedSecret),g=m.map((v)=>v.cipherText),b={sharedSecret:i(d,g,y),cipherText:s.encode(g)};return Kt(y,g),b},decapsulate(l,u){let d=s.decode(l),{publicKey:p,secretKey:m}=o.expandDecapsulationKey(u),y=n.map((g,b)=>g.decapsulate(d[b],m[b]));return i(p,d,y)}}}function t5(e,t,r,i,n){return _n(i),_n(n),pb(32,32,oC(i),(o,s,a)=>n(qt(a[0],a[1],s[1],o[1],is(e))),t,r)}var TZe=t5("QSF-KEM(ML-KEM-768,P-256)-XOF(SHAKE256)-KDF(SHA3-256)",qf,iC(WT,!0),pi,ka),CZe=t5("QSF-KEM(ML-KEM-1024,P-384)-XOF(SHAKE256)-KDF(SHA3-256)",e5,iC(P3,!0),pi,ka);function txe(e,t,r,i,n){return _n(i),_n(n),pb(32,32,oC(i),(o,s,a)=>{let c=qt(a[0],a[1],s[0],o[0],s[1],o[1],is(e)),l=32,u=qt(is("hybrid_prk"),c),d=N3(n,u),p=qt(Cl(32,2),is("shared_secret"),is("")),m=D3(n,d,p,32);return Kt(d,p,u,c),m},t,r)}var r5=iC(R3),$Ze=txe("KitchenSink-KEM(ML-KEM-768,X25519)-XOF(SHAKE256)-KDF(HKDF-SHA-256)",qf,r5,pi,cb),rxe=(()=>pb(32,32,oC(pi),(e,t,r)=>ka(qt(r[0],r[1],t[1],e[1],is("\\.//^\\"))),qf,r5))();function nxe(e,t,r,i){let n=e.Point.Fn;if(!n)throw Error("no Point.Fn");function o(s){let a;for(let u=0,d=t;;u=d,d+=t){if(d>s.length)throw Error("rejection sampling failed");if(a=n.fromBytes(s.subarray(u,d),!0),n.isValidNot0(a))break}let c=n.toBytes(n.create(a)),l=e.getPublicKey(c,!1);return{secretKey:c,publicKey:l}}return{lengths:{secretKey:t,publicKey:r,seed:i,msg:i,cipherText:r},keygen(s=mi(i)){return Ne(s,i,"seed"),o(s)},getPublicKey(s){return e.getPublicKey(s,!1)},encapsulate(s,a=mi(i)){Ne(a,i,"rand");let{secretKey:c}=o(a),l=this.decapsulate(s,c),u=e.getPublicKey(c,!1);return Kt(c),{sharedSecret:l,cipherText:u}},decapsulate(s,a){return e.getSharedSecret(a,s).subarray(1)}}}function ixe(e,t,r,i){let{secretKey:n,publicKeyUncompressed:o}=r.lengths;if(!n||!o)throw Error("wrong curve");let s=nxe(r,n,o,i),a=64,c=a+i;return pb(32,32,(l)=>{Ne(l,32);let u=pi(l,{dkLen:c}),d=u.subarray(0,a),p=u.subarray(a,c);return qt(d,p)},(l,u,d)=>ka(qt(d[0],d[1],u[1],l[1],is(e))),t,s)}var oxe=(()=>ixe("MLKEM768-P256",qf,WT,128))();var mb=rxe,n5=oxe;/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var ut=(e,t,r)=>or(e,t,r),aC=Ot,zl=By,lr=(...e)=>uT(...e),Nl=(e)=>bf(e),Dl=aT,Ll=(e)=>Fi(e),gb=BigInt(0),sC=BigInt(1);function Qi(e,t=""){if(typeof e!=="boolean"){let r=t&&`"${t}" `;throw TypeError(r+"expected boolean, got type="+typeof e)}return e}function yb(e){if(typeof e==="bigint"){if(!hb(e))throw RangeError("positive bigint expected, got "+e)}else aC(e);return e}function hi(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 Mf(e){let t=yb(e).toString(16);return t.length&1?"0"+t:t}function i5(e){if(typeof e!=="string")throw TypeError("hex string expected, got "+typeof e);return e===""?gb:BigInt("0x"+e)}function Ta(e){return i5(By(e))}function Zn(e){return i5(By(ls(or(e)).reverse()))}function bb(e,t){if(Ot(t),t===0)throw RangeError("zero length");e=yb(e);let r=e.toString(16);if(r.length>t*2)throw RangeError("number too large");return bf(r.padStart(t*2,"0"))}function Ff(e,t){return bb(e,t).reverse()}function o5(e,t){if(e=ut(e),t=ut(t),e.length!==t.length)return!1;let r=0;for(let i=0;i<e.length;i++)r|=e[i]^t[i];return r===0}function ls(e){return Uint8Array.from(ut(e))}function xb(e){if(typeof e!=="string")throw TypeError("ascii string expected, got "+typeof e);return Uint8Array.from(e,(t,r)=>{let i=t.charCodeAt(0);if(t.length!==1||i>127)throw RangeError(`string contains non-ASCII character "${e[r]}" with code ${i} at position ${r}`);return i})}var hb=(e)=>typeof e==="bigint"&&gb<=e;function sxe(e,t,r){return hb(e)&&hb(t)&&hb(r)&&t<=e&&e<r}function Yi(e,t,r,i){if(!sxe(t,r,i))throw RangeError("expected valid "+e+": "+r+" <= n < "+i+", got "+t)}function Bl(e){if(e<gb)throw Error("expected non-negative bigint, got "+e);let t;for(t=0;e>gb;e>>=sC,t+=1);return t}var Zf=(e)=>(sC<<BigInt(e))-sC;function s5(e,t,r){if(Ot(e,"hashLen"),Ot(t,"qByteLen"),typeof r!=="function")throw TypeError("hmacFn must be a function");let i=(b)=>new Uint8Array(b),n=Uint8Array.of(),o=Uint8Array.of(0),s=Uint8Array.of(1),a=1000,c=i(e),l=i(e),u=0,d=()=>{c.fill(1),l.fill(0),u=0},p=(...b)=>r(l,lr(c,...b)),m=(b=n)=>{if(l=p(o,b),c=p(),b.length===0)return;l=p(s,b),c=p()},y=()=>{if(u++>=a)throw Error("drbg: tried max amount of iterations");let b=0,v=[];while(b<t){c=p();let A=c.slice();v.push(A),b+=c.length}return lr(...v)};return(b,v)=>{d(),m(b);let A=void 0;while((A=v(y()))===void 0)m();return d(),A}}function En(e,t={},r={}){if(Object.prototype.toString.call(e)!=="[object Object]")throw TypeError("expected valid options object");function i(o,s,a){if(!a&&s!=="function"&&!Object.hasOwn(e,o))throw TypeError(`param "${o}" is invalid: expected own property`);let c=e[o];if(a&&c===void 0)return;let l=typeof c;if(l!==s||c===null)throw TypeError(`param "${o}" is invalid: expected ${s}, got ${l}`)}let n=(o,s)=>Object.entries(o).forEach(([a,c])=>i(a,c,s));n(t,!1),n(r,!0)}var cC=()=>{throw Error("not implemented")};/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var ur=BigInt(0),It=BigInt(1),Ca=BigInt(2),u5=BigInt(3),d5=BigInt(4),f5=BigInt(5),axe=BigInt(7),p5=BigInt(8),cxe=BigInt(9),m5=BigInt(16);function gt(e,t){if(t<=ur)throw Error("mod: expected positive modulus, got "+t);let r=e%t;return r>=ur?r:t+r}function In(e,t,r){if(t<ur)throw Error("pow2: expected non-negative exponent, got "+t);let i=e;while(t-- >ur)i*=i,i%=r;return i}function a5(e,t){if(e===ur)throw Error("invert: expected non-zero number");if(t<=ur)throw Error("invert: expected positive modulus, got "+t);let r=gt(e,t),i=t,n=ur,o=It,s=It,a=ur;while(r!==ur){let l=i/r,u=i-r*l,d=n-s*l,p=o-a*l;i=r,r=u,n=s,o=a,s=d,a=p}if(i!==It)throw Error("invert: does not exist");return gt(n,t)}function lC(e,t,r){let i=e;if(!i.eql(i.sqr(t),r))throw Error("Cannot find square root")}function h5(e,t){let r=e,i=(r.ORDER+It)/d5,n=r.pow(t,i);return lC(r,n,t),n}function lxe(e,t){let r=e,i=(r.ORDER-f5)/p5,n=r.mul(t,Ca),o=r.pow(n,i),s=r.mul(t,o),a=r.mul(r.mul(s,Ca),o),c=r.mul(s,r.sub(a,r.ONE));return lC(r,c,t),c}function uxe(e){let t=Sb(e),r=g5(e),i=r(t,t.neg(t.ONE)),n=r(t,i),o=r(t,t.neg(i)),s=(e+axe)/m5;return(a,c)=>{let l=a,u=l.pow(c,s),d=l.mul(u,i),p=l.mul(u,n),m=l.mul(u,o),y=l.eql(l.sqr(d),c),g=l.eql(l.sqr(p),c);u=l.cmov(u,d,y),d=l.cmov(m,p,g);let b=l.eql(l.sqr(d),c),v=l.cmov(u,d,b);return lC(l,v,c),v}}function g5(e){if(e<u5)throw Error("sqrt is not defined for small field");let t=e-It,r=0;while(t%Ca===ur)t/=Ca,r++;let i=Ca,n=Sb(e);while(c5(n,i)===1)if(i++>1000)throw Error("Cannot find square root: probably non-prime P");if(r===1)return h5;let o=n.pow(i,t),s=(t+It)/Ca;return function(c,l){let u=c;if(u.is0(l))return l;if(c5(u,l)!==1)throw Error("Cannot find square root");let d=r,p=u.mul(u.ONE,o),m=u.pow(l,t),y=u.pow(l,s);while(!u.eql(m,u.ONE)){if(u.is0(m))return u.ZERO;let g=1,b=u.sqr(m);while(!u.eql(b,u.ONE))if(g++,b=u.sqr(b),g===d)throw Error("Cannot find square root");let v=It<<BigInt(d-g-1),A=u.pow(p,v);d=g,p=u.sqr(A),m=u.mul(m,p),y=u.mul(y,A)}return y}}function dxe(e){if(e%d5===u5)return h5;if(e%p5===f5)return lxe;if(e%m5===cxe)return uxe(e);return g5(e)}var Xi=(e,t)=>(gt(e,t)&It)===It,fxe=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function uC(e){let t={ORDER:"bigint",BYTES:"number",BITS:"number"},r=fxe.reduce((i,n)=>(i[n]="function",i),t);if(En(e,r),hi(e.BYTES,"BYTES"),hi(e.BITS,"BITS"),e.BYTES<1||e.BITS<1)throw Error("invalid field: expected BYTES/BITS > 0");if(e.ORDER<=It)throw Error("invalid field: expected ORDER > 1, got "+e.ORDER);return e}function pxe(e,t,r){let i=e;if(r<ur)throw Error("invalid exponent, negatives unsupported");if(r===ur)return i.ONE;if(r===It)return t;let n=i.ONE,o=t;while(r>ur){if(r&It)n=i.mul(n,o);o=i.sqr(o),r>>=It}return n}function Hf(e,t,r=!1){let i=e,n=Array(t.length).fill(r?i.ZERO:void 0),o=t.reduce((a,c,l)=>{if(i.is0(c))return a;return n[l]=a,i.mul(a,c)},i.ONE),s=i.inv(o);return t.reduceRight((a,c,l)=>{if(i.is0(c))return a;return n[l]=i.mul(a,n[l]),i.mul(a,c)},s),n}function c5(e,t){let r=e,i=(r.ORDER-It)/Ca,n=r.pow(t,i),o=r.eql(n,r.ONE),s=r.eql(n,r.ZERO),a=r.eql(n,r.neg(r.ONE));if(!o&&!s&&!a)throw Error("invalid Legendre symbol result");return o?1:s?0:-1}function mxe(e,t){if(t!==void 0)aC(t);if(e<=ur)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=Bl(e);if(t!==void 0&&t<r)throw Error(`invalid n length: expected bit length (${r}) >= n.length (${t})`);let i=t!==void 0?t:r,n=Math.ceil(i/8);return{nBitLength:i,nByteLength:n}}var l5=new WeakMap;class dC{ORDER;BITS;BYTES;isLE;ZERO=ur;ONE=It;_lengths;_mod;constructor(e,t={}){if(e<=It)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:i,nByteLength:n}=mxe(e,r);if(n>2048)throw Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=e,this.BITS=i,this.BYTES=n,Object.freeze(this)}create(e){return gt(e,this.ORDER)}isValid(e){if(typeof e!=="bigint")throw TypeError("invalid field element: expected bigint, got "+typeof e);return ur<=e&&e<this.ORDER}is0(e){return e===ur}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&It)===It}neg(e){return gt(-e,this.ORDER)}eql(e,t){return e===t}sqr(e){return gt(e*e,this.ORDER)}add(e,t){return gt(e+t,this.ORDER)}sub(e,t){return gt(e-t,this.ORDER)}mul(e,t){return gt(e*t,this.ORDER)}pow(e,t){return pxe(this,e,t)}div(e,t){return gt(e*a5(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 a5(e,this.ORDER)}sqrt(e){let t=l5.get(this);if(!t)l5.set(this,t=dxe(this.ORDER));return t(this,e)}toBytes(e){return this.isLE?Ff(e,this.BYTES):bb(e,this.BYTES)}fromBytes(e,t=!1){ut(e);let{_lengths:r,BYTES:i,isLE:n,ORDER:o,_mod:s}=this;if(r){if(e.length<1||!r.includes(e.length)||e.length>i)throw Error("Field.fromBytes: expected "+r+" bytes, got "+e.length);let c=new Uint8Array(i);c.set(e,n?0:c.length-e.length),e=c}if(e.length!==i)throw Error("Field.fromBytes: expected "+i+" bytes, got "+e.length);let a=n?Zn(e):Ta(e);if(s)a=gt(a,o);if(!t){if(!this.isValid(a))throw Error("invalid field element: outside of range 0..ORDER")}return a}invertBatch(e){return Hf(this,e)}cmov(e,t,r){return Qi(r,"condition"),r?t:e}}Object.freeze(dC.prototype);function Sb(e,t={}){return new dC(e,t)}function y5(e){if(typeof e!=="bigint")throw Error("field order must be bigint");if(e<=It)throw Error("field order must be greater than 1");let t=Bl(e-It);return Math.ceil(t/8)}function fC(e){let t=y5(e);return t+Math.ceil(t/2)}function b5(e,t,r=!1){ut(e);let i=e.length,n=y5(t),o=Math.max(fC(t),16);if(i<o||i>1024)throw Error("expected "+o+"-1024 bytes of input, got "+i);let s=r?Zn(e):Ta(e),a=gt(s,t-It)+It;return r?Ff(a,n):bb(a,n)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var jl=BigInt(0),$a=BigInt(1);function Kf(e,t){let r=t.negate();return e?r:t}function Oa(e,t){let r=Hf(e.Fp,t.map((i)=>i.Z));return t.map((i,n)=>e.fromAffine(i.toAffine(r[n])))}function v5(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw Error("invalid window size, expected [1.."+t+"], got W="+e)}function pC(e,t){v5(e,t);let r=Math.ceil(t/e)+1,i=2**(e-1),n=2**e,o=Zf(e),s=BigInt(e);return{windows:r,windowSize:i,mask:o,maxNumber:n,shiftBy:s}}function x5(e,t,r){let{windowSize:i,mask:n,maxNumber:o,shiftBy:s}=r,a=Number(e&n),c=e>>s;if(a>i)a-=o,c+=$a;let l=t*i,u=l+Math.abs(a)-1,d=a===0,p=a<0,m=t%2!==0;return{nextN:c,offset:u,isZero:d,isNeg:p,isNegF:m,offsetF:l}}var mC=new WeakMap,_5=new WeakMap;function hC(e){return _5.get(e)||1}function S5(e){if(e!==jl)throw Error("invalid wNAF")}class Jf{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 i=e;while(t>jl){if(t&$a)r=r.add(i);i=i.double(),t>>=$a}return r}precomputeWindow(e,t){let{windows:r,windowSize:i}=pC(t,this.bits),n=[],o=e,s=o;for(let a=0;a<r;a++){s=o,n.push(s);for(let c=1;c<i;c++)s=s.add(o),n.push(s);o=s.double()}return n}wNAF(e,t,r){if(!this.Fn.isValid(r))throw Error("invalid scalar");let i=this.ZERO,n=this.BASE,o=pC(e,this.bits);for(let s=0;s<o.windows;s++){let{nextN:a,offset:c,isZero:l,isNeg:u,isNegF:d,offsetF:p}=x5(r,s,o);if(r=a,l)n=n.add(Kf(d,t[p]));else i=i.add(Kf(u,t[c]))}return S5(r),{p:i,f:n}}wNAFUnsafe(e,t,r,i=this.ZERO){let n=pC(e,this.bits);for(let o=0;o<n.windows;o++){if(r===jl)break;let{nextN:s,offset:a,isZero:c,isNeg:l}=x5(r,o,n);if(r=s,c)continue;else{let u=t[a];i=i.add(l?u.negate():u)}}return S5(r),i}getPrecomputes(e,t,r){let i=mC.get(t);if(!i){if(i=this.precomputeWindow(t,e),e!==1){if(typeof r==="function")i=r(i);mC.set(t,i)}}return i}cached(e,t,r){let i=hC(e);return this.wNAF(i,this.getPrecomputes(i,e,r),t)}unsafe(e,t,r,i){let n=hC(e);if(n===1)return this._unsafeLadder(e,t,i);return this.wNAFUnsafe(n,this.getPrecomputes(n,e,r),t,i)}createCache(e,t){v5(t,this.bits),_5.set(e,t),mC.delete(e)}hasCache(e){return hC(e)!==1}}function k5(e,t,r,i){let n=t,o=e.ZERO,s=e.ZERO;while(r>jl||i>jl){if(r&$a)o=o.add(n);if(i&$a)s=s.add(n);n=n.double(),r>>=$a,i>>=$a}return{p1:o,p2:s}}function w5(e,t,r){if(t){if(t.ORDER!==e)throw Error("Field.ORDER must match order: Fp == p, Fn == n");return uC(t),t}else return Sb(e,{isLE:r})}function wb(e,t,r={},i){if(i===void 0)i=e==="edwards";if(!t||typeof t!=="object")throw Error(`expected valid ${e} CURVE object`);for(let c of["p","n","h"]){let l=t[c];if(!(typeof l==="bigint"&&l>jl))throw Error(`CURVE.${c} must be positive bigint`)}let n=w5(t.p,r.Fp,i),o=w5(t.n,r.Fn,i),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:o}}function Vf(e,t){return function(i){let n=e(i);return{secretKey:n,publicKey:t(n)}}}function Wf(e,t){if(hi(e),hi(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 i=t-1;i>=0;i--)r[i]=e&255,e>>>=8;return new Uint8Array(r)}function hxe(e,t){let r=new Uint8Array(e.length);for(let i=0;i<e.length;i++)r[i]=e[i]^t[i];return r}function gxe(e){if(!Dl(e)&&typeof e!=="string")throw Error("DST must be Uint8Array or ascii string");let t=typeof e==="string"?xb(e):e;if(t.length===0)throw Error("DST must be non-empty");return t}function gC(e,t,r,i){if(ut(e),hi(r),t=gxe(t),t.length>255)t=i(lr(xb("H2C-OVERSIZE-DST-"),t));let{outputLen:n,blockLen:o}=i,s=Math.ceil(r/n);if(r>65535||s>255)throw Error("expand_message_xmd: invalid lenInBytes");let a=lr(t,Wf(t.length,1)),c=new Uint8Array(o),l=Wf(r,2),u=Array(s),d=i(lr(c,e,l,Wf(0,1),a));u[0]=i(lr(d,Wf(1,1),a));for(let m=1;m<s;m++){let y=[hxe(d,u[m-1]),Wf(m+1,1),a];u[m]=i(lr(...y))}return lr(...u).slice(0,r)}var E5="HashToScalar-";/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var I5=(e,t)=>(e+(e>=0?t:-t)/T5)/t;function yxe(e,t,r){Yi("scalar",e,gi,r);let[[i,n],[o,s]]=t,a=I5(s*e,r),c=I5(-n*e,r),l=e-a*i-c*o,u=-a*n-c*s,d=l<gi,p=u<gi;if(d)l=-l;if(p)u=-u;let m=Zf(Math.ceil(Bl(r)/2))+us;if(l<gi||l>=m||u<gi||u>=m)throw Error("splitScalar (endomorphism): failed for k");return{k1neg:d,k1:l,k2neg:p,k2:u}}function bC(e){if(!["compact","recovered","der"].includes(e))throw Error('Signature format must be "compact", "recovered", or "der"');return e}function yC(e,t){En(e);let r={};for(let i of Object.keys(t))r[i]=e[i]===void 0?t[i]:e[i];if(Qi(r.lowS,"lowS"),Qi(r.prehash,"prehash"),r.format!==void 0)bC(r.format);return r}class A5 extends Error{constructor(e=""){super(e)}}var Hn={Err:A5,_tlv:{encode:(e,t)=>{let{Err:r}=Hn;if(hi(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 i=t.length/2,n=Mf(i);if(n.length/2&128)throw new r("tlv.encode: long form length too big");let o=i>127?Mf(n.length/2|128):"";return Mf(e)+o+n+t},decode(e,t){let{Err:r}=Hn;t=ut(t,void 0,"DER data");let i=0;if(e<0||e>255)throw new r("tlv.encode: wrong tag");if(t.length<2||t[i++]!==e)throw new r("tlv.decode: wrong tlv");let n=t[i++],o=!!(n&128),s=0;if(!o)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 l=t.subarray(i,i+c);if(l.length!==c)throw new r("tlv.decode: length bytes not complete");if(l[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let u of l)s=s<<8|u;if(i+=c,s<128)throw new r("tlv.decode(long): not minimal encoding")}let a=t.subarray(i,i+s);if(a.length!==s)throw new r("tlv.decode: wrong value length");return{v:a,l:t.subarray(i+s)}}},_int:{encode(e){let{Err:t}=Hn;if(yb(e),e<gi)throw new t("integer: negative integers are not allowed");let r=Mf(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}=Hn;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 Ta(e)}},toSig(e){let{Err:t,_int:r,_tlv:i}=Hn,n=ut(e,void 0,"signature"),{v:o,l:s}=i.decode(48,n);if(s.length)throw new t("invalid signature: left bytes after parsing");let{v:a,l:c}=i.decode(2,o),{v:l,l:u}=i.decode(2,c);if(u.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(l)}},hexFromSig(e){let{_tlv:t,_int:r}=Hn,i=t.encode(2,r.encode(e.r)),n=t.encode(2,r.encode(e.s)),o=i+n;return t.encode(48,o)}};Object.freeze(Hn._tlv);Object.freeze(Hn._int);Object.freeze(Hn);var gi=BigInt(0),us=BigInt(1),T5=BigInt(2),vb=BigInt(3),bxe=BigInt(4);function C5(e,t={}){let r=wb("weierstrass",e,t),i=r.Fp,n=r.Fn,o=r.CURVE,{h:s,n:a}=o;En(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});let{endo:c,allowInfinityPoint:l}=t;if(c){if(!i.is0(o.a)||typeof c.beta!=="bigint"||!Array.isArray(c.basises))throw Error('invalid endo: expected "beta": bigint and "basises": array')}let u=O5(i,n);function d(){if(!i.isOdd)throw Error("compression is not supported: Field does not have .isOdd()")}function p(M,P,N){if(l&&P.is0())return Uint8Array.of(0);let{x:I,y:R}=P.toAffine(),O=i.toBytes(I);if(Qi(N,"isCompressed"),N){d();let F=!i.isOdd(R);return lr($5(F),O)}else return lr(Uint8Array.of(4),O,i.toBytes(R))}function m(M){ut(M,void 0,"Point");let{publicKey:P,publicKeyUncompressed:N}=u,I=M.length,R=M[0],O=M.subarray(1);if(l&&I===1&&R===0)return{x:i.ZERO,y:i.ZERO};if(I===P&&(R===2||R===3)){let F=i.fromBytes(O);if(!i.isValid(F))throw Error("bad point: is not on curve, wrong x");let L=b(F),V;try{V=i.sqrt(L)}catch(ue){let C=ue instanceof Error?": "+ue.message:"";throw Error("bad point: is not on curve, sqrt error"+C)}d();let _=i.isOdd(V);if((R&1)===1!==_)V=i.neg(V);return{x:F,y:V}}else if(I===N&&R===4){let F=i.BYTES,L=i.fromBytes(O.subarray(0,F)),V=i.fromBytes(O.subarray(F,F*2));if(!v(L,V))throw Error("bad point: is not on curve");return{x:L,y:V}}else throw Error(`bad point: got length ${I}, expected compressed=${P} or uncompressed=${N}`)}let y=t.toBytes===void 0?p:t.toBytes,g=t.fromBytes===void 0?m:t.fromBytes;function b(M){let P=i.sqr(M),N=i.mul(P,M);return i.add(i.add(N,i.mul(M,o.a)),o.b)}function v(M,P){let N=i.sqr(P),I=b(M);return i.eql(N,I)}if(!v(o.Gx,o.Gy))throw Error("bad curve params: generator point");let A=i.mul(i.pow(o.a,vb),bxe),T=i.mul(i.sqr(o.b),BigInt(27));if(i.is0(i.add(A,T)))throw Error("bad curve params: a or b");function z(M,P,N=!1){if(!i.isValid(P)||N&&i.is0(P))throw Error(`bad point coordinate ${M}`);return P}function j(M){if(!(M instanceof D))throw Error("Weierstrass Point expected")}function E(M){if(!c||!c.basises)throw Error("no endo");return yxe(M,c.basises,n.ORDER)}function Z(M,P,N,I,R){return N=new D(i.mul(N.X,M),N.Y,N.Z),P=Kf(I,P),N=Kf(R,N),P.add(N)}class D{static BASE=new D(o.Gx,o.Gy,i.ONE);static ZERO=new D(i.ZERO,i.ONE,i.ZERO);static Fp=i;static Fn=n;X;Y;Z;constructor(M,P,N){this.X=z("x",M),this.Y=z("y",P,!0),this.Z=z("z",N),Object.freeze(this)}static CURVE(){return o}static fromAffine(M){let{x:P,y:N}=M||{};if(!M||!i.isValid(P)||!i.isValid(N))throw Error("invalid affine point");if(M instanceof D)throw Error("projective point not allowed");if(i.is0(P)&&i.is0(N))return D.ZERO;return new D(P,N,i.ONE)}static fromBytes(M){let P=D.fromAffine(g(ut(M,void 0,"point")));return P.assertValidity(),P}static fromHex(M){return D.fromBytes(Nl(M))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(M=8,P=!0){if(X.createCache(this,M),!P)this.multiply(vb);return this}assertValidity(){let M=this;if(M.is0()){if(t.allowInfinityPoint&&i.is0(M.X)&&i.eql(M.Y,i.ONE)&&i.is0(M.Z))return;throw Error("bad point: ZERO")}let{x:P,y:N}=M.toAffine();if(!i.isValid(P)||!i.isValid(N))throw Error("bad point: x or y not field elements");if(!v(P,N))throw Error("bad point: equation left != right");if(!M.isTorsionFree())throw Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y:M}=this.toAffine();if(!i.isOdd)throw Error("Field doesn't support isOdd");return!i.isOdd(M)}equals(M){j(M);let{X:P,Y:N,Z:I}=this,{X:R,Y:O,Z:F}=M,L=i.eql(i.mul(P,F),i.mul(R,I)),V=i.eql(i.mul(N,F),i.mul(O,I));return L&&V}negate(){return new D(this.X,i.neg(this.Y),this.Z)}double(){let{a:M,b:P}=o,N=i.mul(P,vb),{X:I,Y:R,Z:O}=this,F=i.ZERO,L=i.ZERO,V=i.ZERO,_=i.mul(I,I),te=i.mul(R,R),ue=i.mul(O,O),C=i.mul(I,R);return C=i.add(C,C),V=i.mul(I,O),V=i.add(V,V),F=i.mul(M,V),L=i.mul(N,ue),L=i.add(F,L),F=i.sub(te,L),L=i.add(te,L),L=i.mul(F,L),F=i.mul(C,F),V=i.mul(N,V),ue=i.mul(M,ue),C=i.sub(_,ue),C=i.mul(M,C),C=i.add(C,V),V=i.add(_,_),_=i.add(V,_),_=i.add(_,ue),_=i.mul(_,C),L=i.add(L,_),ue=i.mul(R,O),ue=i.add(ue,ue),_=i.mul(ue,C),F=i.sub(F,_),V=i.mul(ue,te),V=i.add(V,V),V=i.add(V,V),new D(F,L,V)}add(M){j(M);let{X:P,Y:N,Z:I}=this,{X:R,Y:O,Z:F}=M,L=i.ZERO,V=i.ZERO,_=i.ZERO,te=o.a,ue=i.mul(o.b,vb),C=i.mul(P,R),Se=i.mul(N,O),Ee=i.mul(I,F),$e=i.add(P,N),Ce=i.add(R,O);$e=i.mul($e,Ce),Ce=i.add(C,Se),$e=i.sub($e,Ce),Ce=i.add(P,I);let _e=i.add(R,F);return Ce=i.mul(Ce,_e),_e=i.add(C,Ee),Ce=i.sub(Ce,_e),_e=i.add(N,I),L=i.add(O,F),_e=i.mul(_e,L),L=i.add(Se,Ee),_e=i.sub(_e,L),_=i.mul(te,Ce),L=i.mul(ue,Ee),_=i.add(L,_),L=i.sub(Se,_),_=i.add(Se,_),V=i.mul(L,_),Se=i.add(C,C),Se=i.add(Se,C),Ee=i.mul(te,Ee),Ce=i.mul(ue,Ce),Se=i.add(Se,Ee),Ee=i.sub(C,Ee),Ee=i.mul(te,Ee),Ce=i.add(Ce,Ee),C=i.mul(Se,Ce),V=i.add(V,C),C=i.mul(_e,Ce),L=i.mul($e,L),L=i.sub(L,C),C=i.mul($e,Se),_=i.mul(_e,_),_=i.add(_,C),new D(L,V,_)}subtract(M){return j(M),this.add(M.negate())}is0(){return this.equals(D.ZERO)}multiply(M){let{endo:P}=t;if(!n.isValidNot0(M))throw RangeError("invalid scalar: out of range");let N,I,R=(O)=>X.cached(this,O,(F)=>Oa(D,F));if(P){let{k1neg:O,k1:F,k2neg:L,k2:V}=E(M),{p:_,f:te}=R(F),{p:ue,f:C}=R(V);I=te.add(C),N=Z(P.beta,_,ue,O,L)}else{let{p:O,f:F}=R(M);N=O,I=F}return Oa(D,[N,I])[0]}multiplyUnsafe(M){let{endo:P}=t,N=this,I=M;if(!n.isValid(I))throw RangeError("invalid scalar: out of range");if(I===gi||N.is0())return D.ZERO;if(I===us)return N;if(X.hasCache(this))return this.multiply(I);if(P){let{k1neg:R,k1:O,k2neg:F,k2:L}=E(I),{p1:V,p2:_}=k5(D,N,O,L);return Z(P.beta,V,_,R,F)}else return X.unsafe(N,I)}toAffine(M){let P=this,N=M,{X:I,Y:R,Z:O}=P;if(i.eql(O,i.ONE))return{x:I,y:R};let F=P.is0();if(N==null)N=F?i.ONE:i.inv(O);let L=i.mul(I,N),V=i.mul(R,N),_=i.mul(O,N);if(F)return{x:i.ZERO,y:i.ZERO};if(!i.eql(_,i.ONE))throw Error("invZ was invalid");return{x:L,y:V}}isTorsionFree(){let{isTorsionFree:M}=t;if(s===us)return!0;if(M)return M(D,this);return X.unsafe(this,a).is0()}clearCofactor(){let{clearCofactor:M}=t;if(s===us)return this;if(M)return M(D,this);return this.multiplyUnsafe(s)}isSmallOrder(){if(s===us)return this.is0();return this.clearCofactor().is0()}toBytes(M=!0){return Qi(M,"isCompressed"),this.assertValidity(),y(D,this,M)}toHex(M=!0){return zl(this.toBytes(M))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let H=n.BITS,X=new Jf(D,t.endo?Math.ceil(H/2):H);if(H>=8)D.BASE.precompute(8);return Object.freeze(D.prototype),Object.freeze(D),D}function $5(e){return Uint8Array.of(e?2:3)}function O5(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function xxe(e,t={}){let{Fn:r}=e,i=t.randomBytes===void 0?Ll:t.randomBytes,n=Object.assign(O5(e.Fp,r),{seed:Math.max(fC(r.ORDER),16)});function o(m){try{let y=r.fromBytes(m);return r.isValidNot0(y)}catch(y){return!1}}function s(m,y){let{publicKey:g,publicKeyUncompressed:b}=n;try{let v=m.length;if(y===!0&&v!==g)return!1;if(y===!1&&v!==b)return!1;return!!e.fromBytes(m)}catch(v){return!1}}function a(m){return m=m===void 0?i(n.seed):m,b5(ut(m,n.seed,"seed"),r.ORDER)}function c(m,y=!0){return e.BASE.multiply(r.fromBytes(m)).toBytes(y)}function l(m){let{secretKey:y,publicKey:g,publicKeyUncompressed:b}=n,v=r._lengths;if(!Dl(m))return;let A=ut(m,void 0,"key").length,T=A===g||A===b,z=A===y||!!v?.includes(A);if(T&&z)return;return T}function u(m,y,g=!0){if(l(m)===!0)throw Error("first arg must be private key");if(l(y)===!1)throw Error("second arg must be public key");let b=r.fromBytes(m);return e.fromBytes(y).multiply(b).toBytes(g)}let d={isValidSecretKey:o,isValidPublicKey:s,randomSecretKey:a},p=Vf(a,c);return Object.freeze(d),Object.freeze(n),Object.freeze({getPublicKey:c,getSharedSecret:u,keygen:p,Point:e,utils:d,lengths:n})}function R5(e,t,r={}){let i=t;Mi(i),En(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),r=Object.assign({},r);let n=r.randomBytes===void 0?Ll:r.randomBytes,o=r.hmac===void 0?(R,O)=>li(i,R,O):r.hmac,{Fp:s,Fn:a}=e,{ORDER:c,BITS:l}=a,{keygen:u,getPublicKey:d,getSharedSecret:p,utils:m,lengths:y}=xxe(e,r),g={prehash:!0,lowS:typeof r.lowS==="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},b=c*T5+us<s.ORDER;function v(R){let O=c>>us;return R>O}function A(R,O){if(!a.isValidNot0(O))throw Error(`invalid signature ${R}: out of range 1..Point.Fn.ORDER`);return O}function T(){if(b)throw Error('"recovered" sig type is not supported for cofactor >2 curves')}function z(R,O){bC(O);let F=y.signature,L=O==="compact"?F:O==="recovered"?F+1:void 0;return ut(R,L)}class j{r;s;recovery;constructor(R,O,F){if(this.r=A("r",R),this.s=A("s",O),F!=null){if(T(),![0,1,2,3].includes(F))throw Error("invalid recovery id");this.recovery=F}Object.freeze(this)}static fromBytes(R,O=g.format){z(R,O);let F;if(O==="der"){let{r:te,s:ue}=Hn.toSig(ut(R));return new j(te,ue)}if(O==="recovered")F=R[0],O="compact",R=R.subarray(1);let L=y.signature/2,V=R.subarray(0,L),_=R.subarray(L,L*2);return new j(a.fromBytes(V),a.fromBytes(_),F)}static fromHex(R,O){return this.fromBytes(Nl(R),O)}assertRecovery(){let{recovery:R}=this;if(R==null)throw Error("invalid recovery id: must be present");return R}addRecoveryBit(R){return new j(this.r,this.s,R)}recoverPublicKey(R){let{r:O,s:F}=this,L=this.assertRecovery(),V=L===2||L===3?O+c:O;if(!s.isValid(V))throw Error("invalid recovery id: sig.r+curve.n != R.x");let _=s.toBytes(V),te=e.fromBytes(lr($5((L&1)===0),_)),ue=a.inv(V),C=Z(ut(R,void 0,"msgHash")),Se=a.create(-C*ue),Ee=a.create(F*ue),$e=e.BASE.multiplyUnsafe(Se).add(te.multiplyUnsafe(Ee));if($e.is0())throw Error("invalid recovery: point at infinify");return $e.assertValidity(),$e}hasHighS(){return v(this.s)}toBytes(R=g.format){if(bC(R),R==="der")return Nl(Hn.hexFromSig(this));let{r:O,s:F}=this,L=a.toBytes(O),V=a.toBytes(F);if(R==="recovered")return T(),lr(Uint8Array.of(this.assertRecovery()),L,V);return lr(L,V)}toHex(R){return zl(this.toBytes(R))}}Object.freeze(j.prototype),Object.freeze(j);let E=r.bits2int===void 0?function(O){if(O.length>8192)throw Error("input is too large");let F=Ta(O),L=O.length*8-l;return L>0?F>>BigInt(L):F}:r.bits2int,Z=r.bits2int_modN===void 0?function(O){return a.create(E(O))}:r.bits2int_modN,D=Zf(l);function H(R){return Yi("num < 2^"+l,R,gi,D),a.toBytes(R)}function X(R,O){return ut(R,void 0,"message"),O?ut(i(R),void 0,"prehashed message"):R}function M(R,O,F){let{lowS:L,prehash:V,extraEntropy:_}=yC(F,g);R=X(R,V);let te=Z(R),ue=a.fromBytes(O);if(!a.isValidNot0(ue))throw Error("invalid private key");let C=[H(ue),H(te)];if(_!=null&&_!==!1){let Ce=_===!0?n(y.secretKey):_;C.push(ut(Ce,void 0,"extraEntropy"))}let Se=lr(...C),Ee=te;function $e(Ce){let _e=E(Ce);if(!a.isValidNot0(_e))return;let ze=a.inv(_e),Ve=e.BASE.multiply(_e).toAffine(),Xe=a.create(Ve.x);if(Xe===gi)return;let St=a.create(ze*a.create(Ee+Xe*ue));if(St===gi)return;let Lt=(Ve.x===Xe?0:2)|Number(Ve.y&us),hr=St;if(L&&v(St))hr=a.neg(St),Lt^=1;return new j(Xe,hr,b?void 0:Lt)}return{seed:Se,k2sig:$e}}function P(R,O,F={}){let{seed:L,k2sig:V}=M(R,O,F);return s5(i.outputLen,a.BYTES,o)(L,V).toBytes(F.format)}function N(R,O,F,L={}){let{lowS:V,prehash:_,format:te}=yC(L,g);if(F=ut(F,void 0,"publicKey"),O=X(O,_),!Dl(R)){let ue=R instanceof j?", use sig.toBytes()":"";throw Error("verify expects Uint8Array signature"+ue)}z(R,te);try{let ue=j.fromBytes(R,te),C=e.fromBytes(F);if(V&&ue.hasHighS())return!1;let{r:Se,s:Ee}=ue,$e=Z(O),Ce=a.inv(Ee),_e=a.create($e*Ce),ze=a.create(Se*Ce),Ve=e.BASE.multiplyUnsafe(_e).add(C.multiplyUnsafe(ze));if(Ve.is0())return!1;return a.create(Ve.x)===Se}catch(ue){return!1}}function I(R,O,F={}){let{prehash:L}=yC(F,g);return O=X(O,L),j.fromBytes(R,"recovered").recoverPublicKey(O).toBytes()}return Object.freeze({keygen:u,getPublicKey:d,getSharedSecret:p,utils:m,lengths:y,Point:e,sign:P,verify:N,recoverPublicKey:I,Signature:j,hash:i})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var Sxe=(()=>({p:BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),h:BigInt(1),a:BigInt("0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc"),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")}))();var wxe=C5(Sxe),ql=R5(wxe,Rt);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var ds=BigInt(0),Wr=BigInt(1),xC=BigInt(2),vxe=BigInt(8);function _xe(e,t,r,i){let n=e.sqr(r),o=e.sqr(i),s=e.add(e.mul(t.a,n),o),a=e.add(e.ONE,e.mul(t.d,e.mul(n,o)));return e.eql(s,a)}function P5(e,t={}){let r=t,i=wb("edwards",e,r,r.FpFnLE),{Fp:n,Fn:o}=i,s=i.CURVE,{h:a}=s;En(r,{},{uvRatio:"function"});let c=xC<<BigInt(o.BYTES*8)-Wr,l=(g)=>n.create(g),u=r.uvRatio===void 0?(g,b)=>{try{return{isValid:!0,value:n.sqrt(n.div(g,b))}}catch(v){return{isValid:!1,value:ds}}}:r.uvRatio;if(!_xe(n,s,s.Gx,s.Gy))throw Error("bad curve params: generator point");function d(g,b,v=!1){let A=v?Wr:ds;return Yi("coordinate "+g,b,A,c),b}function p(g){if(!(g instanceof m))throw Error("EdwardsPoint expected")}class m{static BASE=new m(s.Gx,s.Gy,Wr,l(s.Gx*s.Gy));static ZERO=new m(ds,Wr,Wr,ds);static Fp=n;static Fn=o;X;Y;Z;T;constructor(g,b,v,A){this.X=d("x",g),this.Y=d("y",b),this.Z=d("z",v,!0),this.T=d("t",A),Object.freeze(this)}static CURVE(){return s}static fromAffine(g){if(g instanceof m)throw Error("extended point not allowed");let{x:b,y:v}=g||{};return d("x",b),d("y",v),new m(b,v,Wr,l(b*v))}static fromBytes(g,b=!1){let v=n.BYTES,{a:A,d:T}=s;g=ls(ut(g,v,"point")),Qi(b,"zip215");let z=ls(g),j=g[v-1];z[v-1]=j&-129;let E=Zn(z),Z=b?c:n.ORDER;Yi("point.y",E,ds,Z);let D=l(E*E),H=l(D-Wr),X=l(T*D-A),{isValid:M,value:P}=u(H,X);if(!M)throw Error("bad point: invalid y coordinate");let N=(P&Wr)===Wr,I=(j&128)!==0;if(!b&&P===ds&&I)throw Error("bad point: x=0 and x_0=1");if(I!==N)P=l(-P);return m.fromAffine({x:P,y:E})}static fromHex(g,b=!1){return m.fromBytes(Nl(g),b)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(g=8,b=!0){if(y.createCache(this,g),!b)this.multiply(xC);return this}assertValidity(){let g=this,{a:b,d:v}=s;if(g.is0())throw Error("bad point: ZERO");let{X:A,Y:T,Z:z,T:j}=g,E=l(A*A),Z=l(T*T),D=l(z*z),H=l(D*D),X=l(E*b),M=l(D*l(X+Z)),P=l(H+l(v*l(E*Z)));if(M!==P)throw Error("bad point: equation left != right (1)");let N=l(A*T),I=l(z*j);if(N!==I)throw Error("bad point: equation left != right (2)")}equals(g){p(g);let{X:b,Y:v,Z:A}=this,{X:T,Y:z,Z:j}=g,E=l(b*j),Z=l(T*A),D=l(v*j),H=l(z*A);return E===Z&&D===H}is0(){return this.equals(m.ZERO)}negate(){return new m(l(-this.X),this.Y,this.Z,l(-this.T))}double(){let{a:g}=s,{X:b,Y:v,Z:A}=this,T=l(b*b),z=l(v*v),j=l(xC*l(A*A)),E=l(g*T),Z=b+v,D=l(l(Z*Z)-T-z),H=E+z,X=H-j,M=E-z,P=l(D*X),N=l(H*M),I=l(D*M),R=l(X*H);return new m(P,N,R,I)}add(g){p(g);let{a:b,d:v}=s,{X:A,Y:T,Z:z,T:j}=this,{X:E,Y:Z,Z:D,T:H}=g,X=l(A*E),M=l(T*Z),P=l(j*v*H),N=l(z*D),I=l((A+T)*(E+Z)-X-M),R=N-P,O=N+P,F=l(M-b*X),L=l(I*R),V=l(O*F),_=l(I*F),te=l(R*O);return new m(L,V,te,_)}subtract(g){return p(g),this.add(g.negate())}multiply(g){if(!o.isValidNot0(g))throw RangeError("invalid scalar: expected 1 <= sc < curve.n");let{p:b,f:v}=y.cached(this,g,(A)=>Oa(m,A));return Oa(m,[b,v])[0]}multiplyUnsafe(g){if(!o.isValid(g))throw RangeError("invalid scalar: expected 0 <= sc < curve.n");if(g===ds)return m.ZERO;if(this.is0()||g===Wr)return this;return y.unsafe(this,g,(b)=>Oa(m,b))}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){return y.unsafe(this,s.n).is0()}toAffine(g){let b=this,v=g,{X:A,Y:T,Z:z}=b,j=b.is0();if(v==null)v=j?vxe:n.inv(z);let E=l(A*v),Z=l(T*v),D=n.mul(z,v);if(j)return{x:ds,y:Wr};if(D!==Wr)throw Error("invZ was invalid");return{x:E,y:Z}}clearCofactor(){if(a===Wr)return this;return this.multiplyUnsafe(a)}toBytes(){let{x:g,y:b}=this.toAffine(),v=n.toBytes(b);return v[v.length-1]|=g&Wr?128:0,v}toHex(){return zl(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let y=new Jf(m,o.BITS);if(o.BITS>=8)m.BASE.precompute(8);return Object.freeze(m.prototype),Object.freeze(m),m}class SC{static BASE;static ZERO;static Fp;static Fn;ep;constructor(e){this.ep=e}static fromBytes(e){cC()}static fromHex(e){cC()}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 zl(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}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var Gf=BigInt(0),Ul=BigInt(1),_b=BigInt(2);function kxe(e){return En(e,{P:"bigint",type:"string",adjustScalarBytes:"function",powPminus2:"function"},{randomBytes:"function"}),Object.freeze({...e})}function z5(e){let t=kxe(e),{P:r,type:i,adjustScalarBytes:n,powPminus2:o,randomBytes:s}=t,a=i==="x25519";if(!a&&i!=="x448")throw Error("invalid type");let c=s===void 0?Ll:s,l=a?255:448,u=a?32:56,d=a?BigInt(9):BigInt(5),p=a?BigInt(121665):BigInt(39081),m=a?_b**BigInt(254):_b**BigInt(447),y=a?BigInt(8)*_b**BigInt(251)-Ul:BigInt(4)*_b**BigInt(445)-Ul,g=m+y+Ul,b=(I)=>gt(I,r),v=A(d);function A(I){return Ff(b(I),u)}function T(I){let R=ls(ut(I,u,"uCoordinate"));if(a)R[31]&=127;return b(Zn(R))}function z(I){return Zn(n(ls(ut(I,u,"scalar"))))}function j(I,R){let O=X(T(R),z(I));if(O===Gf)throw Error("invalid private or public key received");return A(O)}function E(I){return j(I,v)}let Z=E,D=j;function H(I,R,O){let F=b(I*(R-O));return R=b(R-F),O=b(O+F),{x_2:R,x_3:O}}function X(I,R){Yi("u",I,Gf,r),Yi("scalar",R,m,g);let O=R,F=I,L=Ul,V=Gf,_=I,te=Ul,ue=Gf;for(let Se=BigInt(l-1);Se>=Gf;Se--){let Ee=O>>Se&Ul;ue^=Ee,{x_2:L,x_3:_}=H(ue,L,_),{x_2:V,x_3:te}=H(ue,V,te),ue=Ee;let $e=L+V,Ce=b($e*$e),_e=L-V,ze=b(_e*_e),Ve=Ce-ze,Xe=_+te,St=_-te,Lt=b(St*$e),hr=b(Xe*_e),Yr=Lt+hr,Xr=Lt-hr;_=b(Yr*Yr),te=b(F*b(Xr*Xr)),L=b(Ce*ze),V=b(Ve*(Ce+b(p*Ve)))}({x_2:L,x_3:_}=H(ue,L,_)),{x_2:V,x_3:te}=H(ue,V,te);let C=o(V);return b(L*C)}let M={secretKey:u,publicKey:u,seed:u},P=(I)=>(I=I===void 0?c(u):I,ut(I,M.seed,"seed"),I),N={randomSecretKey:P};return Object.freeze(M),Object.freeze(N),Object.freeze({keygen:Vf(P,Z),getSharedSecret:D,getPublicKey:Z,scalarMult:j,scalarMultBase:E,utils:N,GuBytes:v.slice(),lengths:M})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var Exe=BigInt(0),eo=BigInt(1),N5=BigInt(2),Ixe=BigInt(3),Axe=BigInt(5),Txe=BigInt(8),Pa=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),kC=(()=>({p:Pa,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:Txe,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")}))();function B5(e){let t=BigInt(10),r=BigInt(20),i=BigInt(40),n=BigInt(80),o=Pa,a=e*e%o*e%o,c=In(a,N5,o)*a%o,l=In(c,eo,o)*e%o,u=In(l,Axe,o)*l%o,d=In(u,t,o)*u%o,p=In(d,r,o)*d%o,m=In(p,i,o)*p%o,y=In(m,n,o)*m%o,g=In(y,n,o)*m%o,b=In(g,t,o)*u%o;return{pow_p_5_8:In(b,N5,o)*e%o,b2:a}}function Cxe(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var wC=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function EC(e,t){let r=Pa,i=gt(t*t*t,r),n=gt(i*i*t,r),o=B5(e*n).pow_p_5_8,s=gt(e*i*o,r),a=gt(t*s*s,r),c=s,l=gt(s*wC,r),u=a===e,d=a===gt(-e,r),p=a===gt(-e*wC,r);if(u)s=c;if(d||p)s=l;if(Xi(s,r))s=gt(-s,r);return{isValid:u||d,value:s}}var Ra=P5(kC,{uvRatio:EC}),fs=(()=>Ra.Fp)(),j5=(()=>Ra.Fn)();var kb=(()=>{let e=Pa;return z5({P:e,type:"x25519",powPminus2:(t)=>{let{pow_p_5_8:r,b2:i}=B5(t);return gt(In(r,Ixe,e)*i,e)},adjustScalarBytes:Cxe})})();var vC=wC,$xe=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),Oxe=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),Rxe=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),Pxe=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),D5=(e)=>EC(eo,e),zxe=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),_C=(e)=>fs.create(Zn(e)&zxe);function L5(e){let{d:t}=kC,r=Pa,i=(v)=>fs.create(v),n=i(vC*e*e),o=i((n+eo)*Rxe),s=BigInt(-1),a=i((s-t*n)*i(n+t)),{isValid:c,value:l}=EC(o,a),u=i(l*e);if(!Xi(u,r))u=i(-u);if(!c)l=u;if(!c)s=n;let d=i(s*(n-eo)*Pxe-a),p=l*l,m=i((l+l)*a),y=i(d*$xe),g=i(eo-p),b=i(eo+p);return new Ra(i(m*b),i(g*y),i(y*b),i(m*g))}class qr extends SC{static BASE=(()=>new qr(Ra.BASE))();static ZERO=(()=>new qr(Ra.ZERO))();static Fp=(()=>fs)();static Fn=(()=>j5)();constructor(e){super(e)}static fromAffine(e){return new qr(Ra.fromAffine(e))}assertSame(e){if(!(e instanceof qr))throw Error("RistrettoPoint expected")}init(e){return new qr(e)}static fromBytes(e){or(e,32);let{a:t,d:r}=kC,i=Pa,n=(T)=>fs.create(T),o=_C(e);if(!o5(fs.toBytes(o),e)||Xi(o,i))throw Error("invalid ristretto255 encoding 1");let s=n(o*o),a=n(eo+t*s),c=n(eo-t*s),l=n(a*a),u=n(c*c),d=n(t*r*l-u),{isValid:p,value:m}=D5(n(d*u)),y=n(m*c),g=n(m*y*d),b=n((o+o)*y);if(Xi(b,i))b=n(-b);let v=n(a*g),A=n(b*v);if(!p||Xi(A,i)||v===Exe)throw Error("invalid ristretto255 encoding 2");return new qr(new Ra(b,v,eo,A))}static fromHex(e){return qr.fromBytes(bf(e))}toBytes(){let{X:e,Y:t,Z:r,T:i}=this.ep,n=Pa,o=(g)=>fs.create(g),s=o(o(r+t)*o(r-t)),a=o(e*t),c=o(a*a),{value:l}=D5(o(s*c)),u=o(l*s),d=o(l*a),p=o(u*d*i),m;if(Xi(i*p,n)){let g=o(t*vC),b=o(e*vC);e=g,t=b,m=o(u*Oxe)}else m=d;if(Xi(e*p,n))t=o(-t);let y=o((r-t)*m);if(Xi(y,n))y=o(-y);return fs.toBytes(y)}equals(e){this.assertSame(e);let{X:t,Y:r}=this.ep,{X:i,Y:n}=e.ep,o=(c)=>fs.create(c),s=o(t*n)===o(r*i),a=o(r*n)===o(t*i);return s||a}is0(){return this.equals(qr.ZERO)}}Object.freeze(qr.BASE);Object.freeze(qr.ZERO);Object.freeze(qr.prototype);Object.freeze(qr);var Nxe=Object.freeze({Point:qr,hashToCurve(e,t){let r=t?.DST===void 0?"ristretto255_XMD:SHA-512_R255MAP_RO_":t.DST,i=gC(e,r,64,My);return Nxe.deriveToCurve(i)},hashToScalar(e,t={DST:E5}){let r=gC(e,t.DST,64,My);return j5.create(Zn(r))},deriveToCurve(e){or(e,64);let t=_C(e.subarray(0,32)),r=L5(t),i=_C(e.subarray(32,64)),n=L5(i);return new qr(r.add(n))}});var q5=!1,Dxe=!1;async function U5(e,t){if(Dxe)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 Eb(e,t){return await U5(async()=>{let r=IC(e)?e:await Bxe(e),i=await crypto.subtle.importKey("raw",jxe(t),{name:"X25519"},q5,[]);return new Uint8Array(await crypto.subtle.deriveBits({name:"X25519",public:i},r,256))},()=>{if(IC(e))throw Error("CryptoKey provided but X25519 WebCrypto is not supported");return kb.scalarMult(e,t)})}async function Qf(e){return await U5(async()=>Eb(e,kb.GuBytes),()=>{if(IC(e))throw Error("CryptoKey provided but X25519 WebCrypto is not supported");return kb.scalarMultBase(e)})}var Lxe=new Uint8Array([48,46,2,1,0,48,5,6,3,43,101,110,4,34,4,32]);async function Bxe(e){if(e.length!==32)throw Error("X25519 private key must be 32 bytes");let t=new Uint8Array([...Lxe,...e]);return crypto.subtle.importKey("pkcs8",t,{name:"X25519"},q5,["deriveBits"])}function IC(e){return typeof CryptoKey<"u"&&e instanceof CryptoKey}function jxe(e){return e}class AC{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),Uxe(za(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=za(e),null;this.buf=r.value}}close(){return this.s.releaseLock(),{rest:this.buf,transcript:za(this.transcript)}}}function Uxe(e){return e.forEach((t)=>{if(t<32||t>126)throw Error("invalid non-ASCII byte in header")}),new TextDecoder().decode(e)}function za(e){let t=e.reduce((n,o)=>n+o.length,0),r=new Uint8Array(t),i=0;for(let n of e)r.set(n,i),i+=n.length;return r}function Ml(e,...t){return e.pipeThrough(new TransformStream({start(r){for(let i of t)r.enqueue(i)}}))}function Ib(e){return new ReadableStream({start(t){t.enqueue(e),t.close()}})}async function TC(e){if(!(e instanceof ReadableStream))throw Error("readAll expects a ReadableStream<Uint8Array>");return new Uint8Array(await new Response(e).arrayBuffer())}async function M5(e){if(!(e instanceof ReadableStream))throw Error("readAllString expects a ReadableStream<Uint8Array>");return await new Response(e).text()}async function F5(e,t){let r=e.getReader(),i=[],n=0;while(n<t){let{done:c,value:l}=await r.read();if(c)throw Error("stream ended before reading "+t.toString()+" bytes");i.push(l),n+=l.length}r.releaseLock();let o=za(i),s=o.subarray(0,t),a=Ml(e,o.subarray(t));return{data:s,rest:a}}class yi{args;body;constructor(e,t){this.args=e,this.body=t}}async function Mxe(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 o of r)if(o.length===0)throw Error("invalid stanza");let i=[];for(;;){let o=await e.readLine();if(o===null)throw Error("invalid stanza");let s=wr.decode(o);if(s.length>48)throw Error("invalid stanza");if(i.push(s),s.length<48)break}let n=za(i);return{s:new yi(r,n)}}async function Z5(e){let t=new AC(e),r=await t.readLine();if(r!=="age-encryption.org/v1")throw Error("invalid version "+(r??"line"));let i=[];for(;;){let{s:n,next:o}=await Mxe(t);if(n!==void 0){i.push(n);continue}if(!o.startsWith("--- "))throw Error("invalid header");let s=wr.decode(o.slice(4)),{rest:a,transcript:c}=t.close(),l=c.slice(0,c.length-1-o.length+3);return{stanzas:i,headerNoMAC:l,MAC:s,headerSize:c.length,rest:Ml(e,a)}}}function CC(e){let t=[];t.push(`age-encryption.org/v1
829
+ `;if(e==="deploy/Dockerfile")return PR();if(e==="deploy/kamal/deploy.yml")return rm({serviceName:"rover"});if(e===".kamal/hooks/pre-deploy")return Vx({deployConfigPath:"deploy/kamal/deploy.yml",brainYamlPath:"${BRAIN_YAML_PATH:-brain.yaml}"});let t=Lc(nX,e),r=await qN(t,"utf8");return yX(r)}function yX(e){return e.replaceAll("__BRAINS_OPS_VERSION__",tm.version).replaceAll("__BUN_VERSION__",Bun.version)}function bX(e,t){return typeof e==="object"&&e!==null&&"code"in e&&e.code===t}Ln();UE();BI();Dc();Ai();import{mkdir as Wae,writeFile as Gae}from"fs/promises";import{dirname as Qae,join as y4}from"path";import{isDeepStrictEqual as Yae}from"util";Rs();Pi();import{mkdtemp as Oae,mkdir as Rae,readFile as Pae,rm as zae,writeFile as Nae}from"fs/promises";import{tmpdir as Dae}from"os";import{dirname as Lae,join as f4}from"path";var Bae=["name: Your Name Here","Delete this and write your own"];async function p4(e,t,r,i,n={}){if(i.length===0)return;let o=n.env??process.env,s=zn(e),a=u4(o,s,r.effectiveGitSyncToken),c=n.contentRepoAdminTokenSelector?u4(o,s,n.contentRepoAdminTokenSelector):void 0,l=jI(r.contentRepo,t),u=n.contentRepoRemoteResolver?.(r,t,a)??Uae(l,a);if(!u)return;let d=await Oae(f4(Dae(),`brains-ops-content-sync-${r.handle}-`)),p=n.runCommand??br,m=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 Mae(l,c,m)}await p("git",["clone",u,d]),await Fae(d,p),await p("git",["config","user.name","brains-ops[bot]"],{cwd:d}),await p("git",["config","user.email","41898282+github-actions[bot]@users.noreply.github.com"],{cwd:d});let y=!1;for(let g of i)if(await jae(d,g))y=!0;if(!y)return;await p("git",["add","."],{cwd:d}),await p("git",["commit","-m",`chore(content): seed ${r.handle} anchor profile`],{cwd:d}),await p("git",["push","origin","HEAD:main"],{cwd:d})}finally{await zae(d,{recursive:!0,force:!0})}}async function jae(e,t){let r=f4(e,t.path),i=await Pae(r,"utf8").catch(()=>{return});if(i===t.content)return!1;if(i!==void 0&&!qae(i))return!1;return await Rae(Lae(r),{recursive:!0}),await Nae(r,t.content),!0}function qae(e){return Bae.some((t)=>e.includes(t))}function u4(e,t,r){return Wt(r,e,t)}function Uae(e,t){if(!t)return;return`https://x-access-token:${encodeURIComponent(t)}@github.com/${e.org}/${e.name}.git`}async function Mae(e,t,r){let{org:i,name:n}=e,s=`https://api.github.com/repos/${`${encodeURIComponent(i)}/${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 ${i}/${n}: ${c.status} ${await d4(c)}`);let l=await r(`https://api.github.com/orgs/${encodeURIComponent(i)}/repos`,{method:"POST",headers:a,body:JSON.stringify({name:n,private:!0,auto_init:!1})});if(l.ok){console.log(`Created missing content repo ${i}/${n}`);return}if(l.status===422){if((await r(s,{headers:a})).ok)return}throw Error(`Failed to create GitHub repo ${i}/${n}: ${l.status} ${await d4(l)}`)}async function d4(e){let t=await e.text();return t.trim().length===0?e.statusText:t}async function Fae(e,t){try{await t("git",["checkout","-B","main","origin/main"],{cwd:e})}catch{await t("git",["checkout","-B","main"],{cwd:e})}}UI();Ln();async function ol(e,t,r,i,n={}){let o=Zg(t.pilot.githubOrg);for(let s of r){let a={};if(i){let p=await i(s);if(p!==void 0)a=p}let c=await o(s),l=a.brainYaml??c.brainYaml,u=a.envFile??c.envFile,d=a.contentRepoFiles??c.contentRepoFiles??[];if(u)await MI(e,s.handle,".env",u);if(l)await MI(e,s.handle,"brain.yaml",l);await p4(e,t.pilot.githubOrg,s,d,{contentRepoAdminTokenSelector:t.pilot.contentRepoAdminToken,...n});for(let p of d)await MI(e,s.handle,y4("content",p.path),p.content)}}async function MI(e,t,r,i){let n=y4(e,"users",t,r),o=Bun.file(n);if(r==="brain.yaml"&&await o.exists()){let s=Nn(await o.text()),a=Nn(i);if(s.ok&&a.ok&&Yae(s.data,a.data))return}await Wae(Qae(n),{recursive:!0}),await Gae(n,i)}async function Hg(e,t){let r=await Ct(e),i=r.users.find((n)=>n.handle===t);if(!i)throw Error(`Unknown user handle: ${t}`);return{registry:r,user:i}}async function b4(e,t){let r=await Ct(e),i=r.cohorts.find((n)=>n.id===t);if(!i)throw Error(`Unknown cohort: ${t}`);return{registry:r,users:r.users.filter((n)=>n.cohort===i.id)}}async function x4(e){let t=await Ct(e);return{registry:t,users:t.users}}async function FI(e,t,r,i={}){let{registry:n,user:o}=await Hg(e,t);await ol(e,n,[o],r,i)}Ai();To();import{access as Xae,mkdir as S4,readFile as ece,writeFile as v4}from"fs/promises";import{basename as tce,join as sl}from"path";async function ZI(e,t,r){let i=Pr.parse(t),n=Pr.parse(r.cohort),o=sl(e,"users"),s=sl(e,"cohorts"),a=sl(o,`${i}.yaml`),c=sl(o,`${i}.secrets.yaml`),l=sl(o,`${i}.secrets.yaml.age`),u=sl(s,`${n}.yaml`);await Promise.all([S4(o,{recursive:!0}),S4(s,{recursive:!0})]);let d=await w4(a,ice(i,r.anchorId)),m=await ace(l)?!1:await w4(c,oce(i)),{addedToCohort:y}=await rce(u,i);return{handle:i,cohort:n,userPath:a,secretsTemplatePath:c,cohortPath:u,createdUser:d,createdSecretsTemplate:m,addedToCohort:y}}async function rce(e,t){let r=await nce(e);if(r.members.includes(t))return{addedToCohort:!1};let i={...r,members:[...r.members,t].sort()};return await v4(e,sce(i)),{addedToCohort:!0}}async function nce(e){try{let t=await ece(e,"utf8"),r=Nn(t,yn);if(!r.ok)throw Error(`${tce(e)}: ${r.error}`);return r.data}catch(t){if(lce(t))return{members:[]};throw t}}function ice(e,t){return[`handle: ${e}`,"anchorProfile:",` name: ${uce(e)}`,"discord:"," enabled: true",...t?[` anchorUserId: ${JSON.stringify(t)}`]:[],""].join(`
830
+ `)}function oce(e){return["# local per-user secret staging file",`# fill values, run \`bunx brains-ops secrets:encrypt . ${e}\`, then the plaintext file will be removed`,"discordBotToken: ","atprotoAppPassword: ","# For custom-domain sites, paste PEMs with literal \\n escapes.","certificatePem: ","privateKeyPem: ",""].join(`
831
+ `)}function sce(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.aiApiKeyOverride?[`aiApiKeyOverride: ${e.aiApiKeyOverride}`]:[],...e.gitSyncTokenOverride?[`gitSyncTokenOverride: ${e.gitSyncTokenOverride}`]:[],""].join(`
832
+ `)}async function w4(e,t){try{return await v4(e,t,{flag:"wx"}),!0}catch(r){if(cce(r))return!1;throw r}}async function ace(e){try{return await Xae(e),!0}catch{return!1}}function cce(e){return _4(e,"EEXIST")}function lce(e){return _4(e,"ENOENT")}function _4(e,t){return typeof e==="object"&&e!==null&&"code"in e&&e.code===t}function uce(e){return e.split("-").filter((t)=>t.length>0).map((t)=>`${t[0]?.toUpperCase()??""}${t.slice(1)}`).join(" ")}oT();async function sT(e,t,r,i={}){let{registry:n,users:o}=await b4(e,t);await ol(e,n,o,r,i)}async function yf(e,t,r={}){let{registry:i,users:n}=await x4(e);await ol(e,i,n,t,r)}import{parseArgs as yye}from"util";function mt(e){return e}class jF extends Error{constructor(e){super(e);this.name="CliUsageError"}}function bye(e,t){let r={...t};for(let i of e)for(let[n,o]of Object.entries(i.flags??{})){let s=r[n];if(s===void 0){r[n]=o;continue}if(s.type!==o.type||s.short!==o.short||s.default!==o.default)throw Error(`Conflicting definitions for flag --${n}: commands must agree on type, short, and default`)}return r}function xye(e){let t={};for(let[r,i]of Object.entries(e))t[r]={type:i.type,...i.short!==void 0?{short:i.short}:{},...i.default!==void 0?{default:i.default}:{}};return t}function Sye(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 qF(e,t){let r=bye(t.commands,t.globalFlags??{}),i,n;try{({values:i,positionals:n}=yye({args:e,options:xye(r),allowPositionals:!0,strict:t.strict??!0}))}catch(s){if(Sye(s))throw new jF(s.message.split(". ")[0]??s.message);throw s}if("help"in r&&i.help===!0)return{command:"help",args:[],flags:{help:!0}};if("version"in r&&i.version===!0)return{command:"version",args:[],flags:{version:!0}};let o={};for(let[s,a]of Object.entries(r)){let c=i[s];if(typeof c==="string"&&a.type==="string")o[s]=c;else if(typeof c==="boolean"&&a.type==="boolean")o[s]=c}return{command:n[0]??"help",args:n.slice(1),flags:o}}function UF(e){let t=e.reduce((r,i)=>Math.max(r,i.label.length),0);return e.map((r)=>` ${r.label.padEnd(t)} ${r.description}`)}function wye(e){return UF(e.map((t)=>({label:t.usage?`${t.name} ${t.usage}`:t.name,description:t.description})))}function vye(e,t){let r=t.type==="string"?` ${t.placeholder??"<value>"}`:"",i=t.short!==void 0?`, -${t.short}`:"";return`--${e}${r}${i}`}function MF(e){return UF(Object.entries(e).map(([t,r])=>({label:vye(t,r),description:r.description})))}function FF(e,t){return`Usage: ${e} ${t.name}${t.usage?` ${t.usage}`:""}`}function _ye(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 kye(e){let t=[],r=new Map;for(let n of e){let o=n.flags??{};if(Object.keys(o).length===0)continue;let s=_ye(o),a=r.get(s);if(a){a.names.push(n.name);continue}let c={names:[n.name],flags:o};r.set(s,c),t.push(c)}let i=[];for(let n of t)i.push("",`${n.names.join(" / ")} options:`),i.push(...MF(n.flags));return i}function ZF(e){let t=[e.intro,"",`Usage: ${e.cliName} ${e.usage??"<command> [args]"}`,"","Commands:",...wye(e.commands)];if(e.globalFlags&&Object.keys(e.globalFlags).length>0)t.push("","Options:",...MF(e.globalFlags));return t.push(...kye(e.commands)),t.join(`
833
+ `)}function HF(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 ht(e,t){let r=e[t];return typeof r==="string"?r:void 0}function wl(e,t){let r=e[t];return typeof r==="boolean"?r:void 0}import{existsSync as Qxe,mkdirSync as Yxe,readFileSync as JC,writeFileSync as VC}from"fs";import{dirname as Xxe,join as e8}from"path";function aT(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function Ot(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 or(e,t,r=""){let i=aT(e),n=e?.length,o=t!==void 0;if(!i||o&&n!==t){let s=r&&`"${r}" `,a=o?` of length ${t}`:"",c=i?`length=${n}`:`type=${typeof e}`,l=s+"expected Uint8Array"+a+", got "+c;if(!i)throw TypeError(l);throw RangeError(l)}return e}function Mi(e){if(typeof e!=="function"||typeof e.create!=="function")throw TypeError("Hash must wrapped by utils.createHasher");if(Ot(e.outputLen),Ot(e.blockLen),e.outputLen<1)throw Error('"outputLen" must be >= 1');if(e.blockLen<1)throw Error('"blockLen" must be >= 1')}function vl(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 Dy(e,t){or(e,void 0,"digestInto() output");let r=t.outputLen;if(e.length<r)throw RangeError('"digestInto() output" expected to be of length >='+r)}function Ly(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function Lr(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function _l(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Un(e,t){return e<<32-t|e>>>t}function Qe(e,t){return e<<t|e>>>32-t>>>0}var Eye=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)();function Iye(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function Aye(e){for(let t=0;t<e.length;t++)e[t]=Iye(e[t]);return e}var cT=Eye?(e)=>e:Aye,JF=(()=>typeof Uint8Array.from([]).toHex==="function"&&typeof Uint8Array.fromHex==="function")(),Tye=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function By(e){if(or(e),JF)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=Tye[e[r]];return t}var Ui={_0:48,_9:57,A:65,F:70,a:97,f:102};function KF(e){if(e>=Ui._0&&e<=Ui._9)return e-Ui._0;if(e>=Ui.A&&e<=Ui.F)return e-(Ui.A-10);if(e>=Ui.a&&e<=Ui.f)return e-(Ui.a-10);return}function bf(e){if(typeof e!=="string")throw TypeError("hex string expected, got "+typeof e);if(JF)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 i=new Uint8Array(r);for(let n=0,o=0;n<r;n++,o+=2){let s=KF(e.charCodeAt(o)),a=KF(e.charCodeAt(o+1));if(s===void 0||a===void 0){let c=e[o]+e[o+1];throw RangeError('hex string expected, got non-hex character "'+c+'" at index '+o)}i[n]=s*16+a}return i}function Cye(e){if(typeof e!=="string")throw TypeError("string expected");return new Uint8Array(new TextEncoder().encode(e))}function lT(e,t=""){if(typeof e==="string")return Cye(e);return or(e,void 0,t)}function uT(...e){let t=0;for(let i=0;i<e.length;i++){let n=e[i];or(n),t+=n.length}let r=new Uint8Array(t);for(let i=0,n=0;i<e.length;i++){let o=e[i];r.set(o,n),n+=o.length}return r}function jy(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 dT(e,t={}){let r=(n,o)=>e(o).update(n).digest(),i=e(void 0);return r.outputLen=i.outputLen,r.blockLen=i.blockLen,r.canXOF=i.canXOF,r.create=(n)=>e(n),Object.assign(r,t),Object.freeze(r)}function Fi(e=32){Ot(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 fT=(e)=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});class pT{oHash;iHash;blockLen;outputLen;canXOF=!1;finished=!1;destroyed=!1;constructor(e,t){if(Mi(e),or(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,i=new Uint8Array(r);i.set(t.length>r?e.create().update(t).digest():t);for(let n=0;n<i.length;n++)i[n]^=54;this.iHash.update(i),this.oHash=e.create();for(let n=0;n<i.length;n++)i[n]^=106;this.oHash.update(i),Lr(i)}update(e){return vl(this),this.iHash.update(e),this}digestInto(e){vl(this),Dy(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:i,destroyed:n,blockLen:o,outputLen:s}=this;return e=e,e.finished=i,e.destroyed=n,e.blockLen=o,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 li=(()=>{let e=(t,r,i)=>new pT(t,r).update(i).digest();return e.create=(t,r)=>new pT(t,r),e})();function xf(e,t,r){if(Mi(e),r===void 0)r=new Uint8Array(e.outputLen);return li(e,r,t)}var mT=Uint8Array.of(0),VF=Uint8Array.of();function hT(e,t,r,i=32){Mi(e),Ot(i,"length"),or(t,void 0,"prk");let n=e.outputLen;if(t.length<n)throw Error('"prk" must be at least HashLen octets');if(i>255*n)throw Error("Length must be <= 255*HashLen");let o=Math.ceil(i/n);if(r===void 0)r=VF;else or(r,void 0,"info");let s=new Uint8Array(o*n),a=li.create(e,t),c=a._cloneInto(),l=new Uint8Array(a.outputLen);for(let u=0;u<o;u++)mT[0]=u+1,c.update(u===0?VF:l).update(r).update(mT).digestInto(l),s.set(l,n*u),a._cloneInto(c);return a.destroy(),c.destroy(),Lr(l,mT),s.slice(0,i)}var Wo=(e,t,r,i,n)=>hT(e,xf(e,t,r),i,n);function WF(e,t,r){return e&t^~e&r}function GF(e,t,r){return e&t^e&r^t&r}class qy{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,t,r,i){this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=i,this.buffer=new Uint8Array(e),this.view=_l(this.buffer)}update(e){vl(this),or(e);let{view:t,buffer:r,blockLen:i}=this,n=e.length;for(let o=0;o<n;){let s=Math.min(i-this.pos,n-o);if(s===i){let a=_l(e);for(;i<=n-o;o+=i)this.process(a,o);continue}if(r.set(e.subarray(o,o+s),this.pos),this.pos+=s,o+=s,this.pos===i)this.process(t,0),this.pos=0}return this.length+=e.length,this.roundClean(),this}digestInto(e){vl(this),Dy(e,this),this.finished=!0;let{buffer:t,view:r,blockLen:i,isLE:n}=this,{pos:o}=this;if(t[o++]=128,Lr(this.buffer.subarray(o)),this.padOffset>i-o)this.process(r,0),o=0;for(let u=o;u<i;u++)t[u]=0;r.setBigUint64(i-8,BigInt(this.length*8),n),this.process(r,0);let s=_l(e),a=this.outputLen;if(a%4)throw Error("_sha2: outputLen must be aligned to 32bit");let c=a/4,l=this.get();if(c>l.length)throw Error("_sha2: outputLen bigger than state");for(let u=0;u<c;u++)s.setUint32(4*u,l[u],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:i,finished:n,destroyed:o,pos:s}=this;if(e.destroyed=o,e.finished=n,e.length=i,e.pos=s,i%t)e.buffer.set(r);return e}clone(){return this._cloneInto()}}var Zi=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var sr=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var Uy=BigInt(4294967295),QF=BigInt(32);function $ye(e,t=!1){if(t)return{h:Number(e&Uy),l:Number(e>>QF&Uy)};return{h:Number(e>>QF&Uy)|0,l:Number(e&Uy)|0}}function YF(e,t=!1){let r=e.length,i=new Uint32Array(r),n=new Uint32Array(r);for(let o=0;o<r;o++){let{h:s,l:a}=$ye(e[o],t);[i[o],n[o]]=[s,a]}return[i,n]}var gT=(e,t,r)=>e>>>r,yT=(e,t,r)=>e<<32-r|t>>>r,ma=(e,t,r)=>e>>>r|t<<32-r,ha=(e,t,r)=>e<<32-r|t>>>r,Sf=(e,t,r)=>e<<64-r|t>>>r-32,wf=(e,t,r)=>e>>>r-32|t<<64-r;function ui(e,t,r,i){let n=(t>>>0)+(i>>>0);return{h:e+r+(n/4294967296|0)|0,l:n|0}}var XF=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),eZ=(e,t,r,i)=>t+r+i+(e/4294967296|0)|0,tZ=(e,t,r,i)=>(e>>>0)+(t>>>0)+(r>>>0)+(i>>>0),rZ=(e,t,r,i,n)=>t+r+i+n+(e/4294967296|0)|0,nZ=(e,t,r,i,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(i>>>0)+(n>>>0),iZ=(e,t,r,i,n,o)=>t+r+i+n+o+(e/4294967296|0)|0;var Rye=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]),Go=new Uint32Array(64);class oZ extends qy{constructor(e){super(64,e,8,!1)}get(){let{A:e,B:t,C:r,D:i,E:n,F:o,G:s,H:a}=this;return[e,t,r,i,n,o,s,a]}set(e,t,r,i,n,o,s,a){this.A=e|0,this.B=t|0,this.C=r|0,this.D=i|0,this.E=n|0,this.F=o|0,this.G=s|0,this.H=a|0}process(e,t){for(let u=0;u<16;u++,t+=4)Go[u]=e.getUint32(t,!1);for(let u=16;u<64;u++){let d=Go[u-15],p=Go[u-2],m=Un(d,7)^Un(d,18)^d>>>3,y=Un(p,17)^Un(p,19)^p>>>10;Go[u]=y+Go[u-7]+m+Go[u-16]|0}let{A:r,B:i,C:n,D:o,E:s,F:a,G:c,H:l}=this;for(let u=0;u<64;u++){let d=Un(s,6)^Un(s,11)^Un(s,25),p=l+d+WF(s,a,c)+Rye[u]+Go[u]|0,y=(Un(r,2)^Un(r,13)^Un(r,22))+GF(r,i,n)|0;l=c,c=a,a=s,s=o+p|0,o=n,n=i,i=r,r=p+y|0}r=r+this.A|0,i=i+this.B|0,n=n+this.C|0,o=o+this.D|0,s=s+this.E|0,a=a+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(r,i,n,o,s,a,c,l)}roundClean(){Lr(Go)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),Lr(this.buffer)}}class sZ extends oZ{A=Zi[0]|0;B=Zi[1]|0;C=Zi[2]|0;D=Zi[3]|0;E=Zi[4]|0;F=Zi[5]|0;G=Zi[6]|0;H=Zi[7]|0;constructor(){super(32)}}var aZ=(()=>YF(["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))))(),Pye=(()=>aZ[0])(),zye=(()=>aZ[1])(),Qo=new Uint32Array(80),Yo=new Uint32Array(80);class cZ extends qy{constructor(e){super(128,e,16,!1)}get(){let{Ah:e,Al:t,Bh:r,Bl:i,Ch:n,Cl:o,Dh:s,Dl:a,Eh:c,El:l,Fh:u,Fl:d,Gh:p,Gl:m,Hh:y,Hl:g}=this;return[e,t,r,i,n,o,s,a,c,l,u,d,p,m,y,g]}set(e,t,r,i,n,o,s,a,c,l,u,d,p,m,y,g){this.Ah=e|0,this.Al=t|0,this.Bh=r|0,this.Bl=i|0,this.Ch=n|0,this.Cl=o|0,this.Dh=s|0,this.Dl=a|0,this.Eh=c|0,this.El=l|0,this.Fh=u|0,this.Fl=d|0,this.Gh=p|0,this.Gl=m|0,this.Hh=y|0,this.Hl=g|0}process(e,t){for(let A=0;A<16;A++,t+=4)Qo[A]=e.getUint32(t),Yo[A]=e.getUint32(t+=4);for(let A=16;A<80;A++){let T=Qo[A-15]|0,z=Yo[A-15]|0,j=ma(T,z,1)^ma(T,z,8)^gT(T,z,7),E=ha(T,z,1)^ha(T,z,8)^yT(T,z,7),Z=Qo[A-2]|0,D=Yo[A-2]|0,H=ma(Z,D,19)^Sf(Z,D,61)^gT(Z,D,6),X=ha(Z,D,19)^wf(Z,D,61)^yT(Z,D,6),M=tZ(E,X,Yo[A-7],Yo[A-16]),P=rZ(M,j,H,Qo[A-7],Qo[A-16]);Qo[A]=P|0,Yo[A]=M|0}let{Ah:r,Al:i,Bh:n,Bl:o,Ch:s,Cl:a,Dh:c,Dl:l,Eh:u,El:d,Fh:p,Fl:m,Gh:y,Gl:g,Hh:b,Hl:v}=this;for(let A=0;A<80;A++){let T=ma(u,d,14)^ma(u,d,18)^Sf(u,d,41),z=ha(u,d,14)^ha(u,d,18)^wf(u,d,41),j=u&p^~u&y,E=d&m^~d&g,Z=nZ(v,z,E,zye[A],Yo[A]),D=iZ(Z,b,T,j,Pye[A],Qo[A]),H=Z|0,X=ma(r,i,28)^Sf(r,i,34)^Sf(r,i,39),M=ha(r,i,28)^wf(r,i,34)^wf(r,i,39),P=r&n^r&s^n&s,N=i&o^i&a^o&a;b=y|0,v=g|0,y=p|0,g=m|0,p=u|0,m=d|0,{h:u,l:d}=ui(c|0,l|0,D|0,H|0),c=s|0,l=a|0,s=n|0,a=o|0,n=r|0,o=i|0;let I=XF(H,M,N);r=eZ(I,D,X,P),i=I|0}({h:r,l:i}=ui(this.Ah|0,this.Al|0,r|0,i|0)),{h:n,l:o}=ui(this.Bh|0,this.Bl|0,n|0,o|0),{h:s,l:a}=ui(this.Ch|0,this.Cl|0,s|0,a|0),{h:c,l}=ui(this.Dh|0,this.Dl|0,c|0,l|0),{h:u,l:d}=ui(this.Eh|0,this.El|0,u|0,d|0),{h:p,l:m}=ui(this.Fh|0,this.Fl|0,p|0,m|0),{h:y,l:g}=ui(this.Gh|0,this.Gl|0,y|0,g|0),{h:b,l:v}=ui(this.Hh|0,this.Hl|0,b|0,v|0),this.set(r,i,n,o,s,a,c,l,u,d,p,m,y,g,b,v)}roundClean(){Lr(Qo,Yo)}destroy(){this.destroyed=!0,Lr(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class lZ extends cZ{Ah=sr[0]|0;Al=sr[1]|0;Bh=sr[2]|0;Bl=sr[3]|0;Ch=sr[4]|0;Cl=sr[5]|0;Dh=sr[6]|0;Dl=sr[7]|0;Eh=sr[8]|0;El=sr[9]|0;Fh=sr[10]|0;Fl=sr[11]|0;Gh=sr[12]|0;Gl=sr[13]|0;Hh=sr[14]|0;Hl=sr[15]|0;constructor(){super(64)}}var Rt=dT(()=>new sZ,fT(1));var My=dT(()=>new lZ,fT(3));/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Jy(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function ST(e){if(!Jy(e))throw TypeError("Uint8Array expected")}function mZ(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 hZ(e){if(typeof e!=="function")throw TypeError("function expected");return!0}function Xo(e,t){if(typeof t!=="string")throw TypeError(`${e}: string expected`);return!0}function _f(e){if(typeof e!=="number")throw TypeError(`number expected, got ${typeof e}`);if(!Number.isSafeInteger(e))throw RangeError(`invalid integer: ${e}`)}function Zy(e){if(!Array.isArray(e))throw TypeError("array expected")}function Hy(e,t){if(!mZ(!0,t))throw TypeError(`${e}: array of strings expected`)}function wT(e,t){if(!mZ(!1,t))throw TypeError(`${e}: array of numbers expected`)}function cn(...e){let t=(o)=>o,r=(o,s)=>(a)=>o(s(a)),i=e.map((o)=>o.encode).reduceRight(r,t),n=e.map((o)=>o.decode).reduce(r,t);return{encode:i,decode:n}}function ln(e){let t=typeof e==="string"?e.split(""):e,r=t.length;Hy("alphabet",t);let i=new Map(t.map((n,o)=>[n,o]));return{encode:(n)=>(Zy(n),n.map((o)=>{if(!Number.isSafeInteger(o)||o<0||o>=r)throw Error(`alphabet.encode: digit index outside alphabet "${o}". Allowed: ${e}`);return t[o]})),decode:(n)=>(Zy(n),n.map((o)=>{Xo("alphabet.decode",o);let s=i.get(o);if(s===void 0)throw Error(`Unknown letter: "${o}". Allowed: ${e}`);return s}))}}function un(e=""){return Xo("join",e),{encode:(t)=>(Hy("join.decode",t),t.join(e)),decode:(t)=>(Xo("join.decode",t),t.split(e))}}function Vy(e,t="="){return _f(e),Xo("padding",t),{encode(r){Hy("padding.encode",r);while(r.length*e%8)r.push(t);return r},decode(r){Hy("padding.decode",r);let i=r.length;if(i*e%8)throw Error("padding: invalid, string should have whole number of bytes");for(;i>0&&r[i-1]===t;i--)if((i-1)*e%8===0)throw Error("padding: invalid, string has too much padding");return r.slice(0,i)}}}function gZ(e){return hZ(e),{encode:(t)=>t,decode:(t)=>e(t)}}function uZ(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(Zy(e),!e.length)return[];let i=0,n=[],o=Array.from(e,(a)=>{if(_f(a),a<0||a>=t)throw Error(`invalid integer: ${a}`);return a}),s=o.length;while(!0){let a=0,c=!0;for(let l=i;l<s;l++){let u=o[l],d=t*a,p=d+u;if(!Number.isSafeInteger(p)||d/t!==a||p-u!==d)throw Error("convertRadix: carry overflow");let m=p/r;a=p%r;let y=Math.floor(m);if(o[l]=y,!Number.isSafeInteger(y)||y*r+a!==p)throw Error("convertRadix: carry overflow");if(!c)continue;else if(!y)i=l;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()}var yZ=(e,t)=>t===0?e:yZ(t,e%t),Ky=(e,t)=>e+(t-yZ(e,t)),Fy=(()=>{let e=[];for(let t=0;t<40;t++)e.push(2**t);return e})();function bT(e,t,r,i){if(Zy(e),t<=0||t>32)throw RangeError(`convertRadix2: wrong from=${t}`);if(r<=0||r>32)throw RangeError(`convertRadix2: wrong to=${r}`);if(Ky(t,r)>32)throw Error(`convertRadix2: carry overflow from=${t} to=${r} carryBits=${Ky(t,r)}`);let n=0,o=0,s=Fy[t],a=Fy[r]-1,c=[];for(let l of e){if(_f(l),l>=s)throw Error(`convertRadix2: invalid data word=${l} from=${t}`);if(n=n<<t|l,o+t>32)throw Error(`convertRadix2: carry overflow pos=${o} from=${t}`);o+=t;for(;o>=r;o-=r)c.push((n>>o-r&a)>>>0);let u=Fy[o];if(u===void 0)throw Error("invalid carry");n&=u-1}if(n=n<<r-o&a,!i&&o>=t)throw Error("Excess padding");if(!i&&n>0)throw Error(`Non-zero padding: ${n}`);if(i&&o>0)c.push(n>>>0);return c}function Nye(e){_f(e);let t=256;return{encode:(r)=>{if(!Jy(r))throw TypeError("radix.encode input should be Uint8Array");return uZ(Array.from(r),t,e)},decode:(r)=>(wT("radix.decode",r),Uint8Array.from(uZ(r,e,t)))}}function wn(e,t=!1){if(_f(e),e<=0||e>32)throw RangeError("radix2: bits should be in (0..32]");if(Ky(8,e)>32||Ky(e,8)>32)throw RangeError("radix2: carry overflow");return{encode:(r)=>{if(!Jy(r))throw TypeError("radix2.encode input should be Uint8Array");return bT(Array.from(r),8,e,!t)},decode:(r)=>(wT("radix2.decode",r),Uint8Array.from(bT(r,e,8,t)))}}function dZ(e){return hZ(e),function(...t){try{return e.apply(null,t)}catch(r){}}}var CMe=Object.freeze(cn(wn(4),ln("0123456789ABCDEF"),un(""))),$Me=Object.freeze(cn(wn(5),ln("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),Vy(5),un(""))),OMe=Object.freeze(cn(wn(5),ln("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),un(""))),RMe=Object.freeze(cn(wn(5),ln("0123456789ABCDEFGHIJKLMNOPQRSTUV"),Vy(5),un(""))),PMe=Object.freeze(cn(wn(5),ln("0123456789ABCDEFGHIJKLMNOPQRSTUV"),un(""))),zMe=Object.freeze(cn(wn(5),ln("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),un(""),gZ((e)=>e.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1")))),bZ=(()=>typeof Uint8Array.from([]).toBase64==="function"&&typeof Uint8Array.fromBase64==="function")(),Dye=/[\t\n\f\r ]/,xZ=(e,t)=>{Xo("base64",e);let r=t?"base64url":"base64";if(e.length>0&&Dye.test(e))throw Error("invalid base64");return Uint8Array.fromBase64(e,{alphabet:r,lastChunkHandling:"strict"})},vT=Object.freeze(bZ?{encode(e){return ST(e),e.toBase64()},decode(e){return xZ(e,!1)}}:cn(wn(6),ln("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),Vy(6),un(""))),wr=Object.freeze(cn(wn(6),ln("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),un(""))),NMe=Object.freeze(bZ?{encode(e){return ST(e),e.toBase64({alphabet:"base64url"})},decode(e){return xZ(e,!0)}}:cn(wn(6),ln("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),Vy(6),un(""))),DMe=Object.freeze(cn(wn(6),ln("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),un(""))),_T=(e)=>cn(Nye(58),ln(e),un("")),LMe=Object.freeze(_T("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")),BMe=Object.freeze(_T("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ")),jMe=Object.freeze(_T("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz"));var xT=cn(ln("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),un("")),fZ=[996825010,642813549,513874426,1027748829,705979059];function vf(e){let t=e>>25,r=(e&33554431)<<5;for(let i=0;i<fZ.length;i++)if((t>>i&1)===1)r^=fZ[i];return r}function pZ(e,t,r=1){let i=e.length,n=1;for(let o=0;o<i;o++){let s=e.charCodeAt(o);if(s<33||s>126)throw Error(`Invalid prefix (${e})`);n=vf(n)^s>>5}n=vf(n);for(let o=0;o<i;o++)n=vf(n)^e.charCodeAt(o)&31;for(let o of t)n=vf(n)^o;for(let o=0;o<6;o++)n=vf(n);return n^=r,xT.encode(bT([n%Fy[30]],30,5,!1))}function SZ(e){let t=e==="bech32"?1:734539939,r=wn(5),i=r.decode,n=r.encode,o=dZ(i);function s(d,p,m=90){if(Xo("bech32.encode prefix",d),Jy(p))p=Array.from(p);wT("bech32.encode",p);let y=d.length;if(y===0)throw TypeError(`Invalid prefix length ${y}`);let g=y+7+p.length;if(m!==!1&&g>m)throw TypeError(`Length ${g} exceeds limit ${m}`);let b=d.toLowerCase(),v=pZ(b,p,t);return`${b}1${xT.encode(p)}${v}`}function a(d,p=90){Xo("bech32.decode input",d);let m=d.length;if(m<8||p!==!1&&m>p)throw TypeError(`invalid string length: ${m} (${d}). Expected (8..${p})`);let y=d.toLowerCase();if(d!==y&&d!==d.toUpperCase())throw Error("String must be lowercase or uppercase");let g=y.lastIndexOf("1");if(g===0||g===-1)throw Error('Letter "1" must be present between prefix and data only');let b=y.slice(0,g),v=y.slice(g+1);if(v.length<6)throw Error("Data must be at least 6 characters long");let A=xT.decode(v).slice(0,-6),T=pZ(b,A,t);if(!v.endsWith(T))throw Error(`Invalid checksum in ${d}: expected "${T}"`);return{prefix:b,words:A}}let c=dZ(a);function l(d){let{prefix:p,words:m}=a(d,!1);return{prefix:p,words:m,bytes:i(m)}}function u(d,p){return s(d,n(p))}return{encode:s,decode:a,encodeFromBytes:u,decodeToBytes:l,decodeUnsafe:c,fromWords:i,fromWordsUnsafe:o,toWords:n}}var dn=Object.freeze(SZ("bech32")),qMe=Object.freeze(SZ("bech32m"));var Lye=(()=>typeof Uint8Array.from([]).toHex==="function"&&typeof Uint8Array.fromHex==="function")(),Bye={encode(e){return ST(e),e.toHex()},decode(e){return Xo("hex",e),Uint8Array.fromHex(e)}},UMe=Object.freeze(Lye?Bye:cn(wn(4),ln("0123456789abcdef"),un(""),gZ((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 qye(e,t,r,i){Mi(e);let n=jy({dkLen:32,asyncTick:10},i),{c:o,dkLen:s,asyncTick:a}=n;if(Ot(o,"c"),Ot(s,"dkLen"),Ot(a,"asyncTick"),o<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=lT(t,"password"),l=lT(r,"salt"),u=new Uint8Array(s),d=li.create(e,c),p=d._cloneInto().update(l);return{c:o,dkLen:s,asyncTick:a,DK:u,PRF:d,PRFSalt:p}}function Uye(e,t,r,i,n){if(e.destroy(),t.destroy(),i)i.destroy();return Lr(n),r}function kT(e,t,r,i){let{c:n,dkLen:o,DK:s,PRF:a,PRFSalt:c}=qye(e,t,r,i),l,u=new Uint8Array(4),d=_l(u),p=new Uint8Array(a.outputLen);for(let m=1,y=0;y<o;m++,y+=a.outputLen){let g=s.subarray(y,y+a.outputLen);d.setInt32(0,m,!1),(l=c._cloneInto(l)).update(u).digestInto(p),g.set(p.subarray(0,g.length));for(let b=1;b<n;b++){a._cloneInto(l).update(p).digestInto(p);for(let v=0;v<g.length;v++)g[v]^=p[v]}}return Uye(a,c,s,l,p)}function wZ(e,t,r,i,n,o){let s=e[t++]^r[i++],a=e[t++]^r[i++],c=e[t++]^r[i++],l=e[t++]^r[i++],u=e[t++]^r[i++],d=e[t++]^r[i++],p=e[t++]^r[i++],m=e[t++]^r[i++],y=e[t++]^r[i++],g=e[t++]^r[i++],b=e[t++]^r[i++],v=e[t++]^r[i++],A=e[t++]^r[i++],T=e[t++]^r[i++],z=e[t++]^r[i++],j=e[t++]^r[i++],E=s,Z=a,D=c,H=l,X=u,M=d,P=p,N=m,I=y,R=g,O=b,F=v,L=A,V=T,_=z,te=j;for(let ue=0;ue<8;ue+=2)X^=Qe(E+L|0,7),I^=Qe(X+E|0,9),L^=Qe(I+X|0,13),E^=Qe(L+I|0,18),R^=Qe(M+Z|0,7),V^=Qe(R+M|0,9),Z^=Qe(V+R|0,13),M^=Qe(Z+V|0,18),_^=Qe(O+P|0,7),D^=Qe(_+O|0,9),P^=Qe(D+_|0,13),O^=Qe(P+D|0,18),H^=Qe(te+F|0,7),N^=Qe(H+te|0,9),F^=Qe(N+H|0,13),te^=Qe(F+N|0,18),Z^=Qe(E+H|0,7),D^=Qe(Z+E|0,9),H^=Qe(D+Z|0,13),E^=Qe(H+D|0,18),P^=Qe(M+X|0,7),N^=Qe(P+M|0,9),X^=Qe(N+P|0,13),M^=Qe(X+N|0,18),F^=Qe(O+R|0,7),I^=Qe(F+O|0,9),R^=Qe(I+F|0,13),O^=Qe(R+I|0,18),L^=Qe(te+_|0,7),V^=Qe(L+te|0,9),_^=Qe(V+L|0,13),te^=Qe(_+V|0,18);n[o++]=s+E|0,n[o++]=a+Z|0,n[o++]=c+D|0,n[o++]=l+H|0,n[o++]=u+X|0,n[o++]=d+M|0,n[o++]=p+P|0,n[o++]=m+N|0,n[o++]=y+I|0,n[o++]=g+R|0,n[o++]=b+O|0,n[o++]=v+F|0,n[o++]=A+L|0,n[o++]=T+V|0,n[o++]=z+_|0,n[o++]=j+te|0}function ET(e,t,r,i,n){let o=i+0,s=i+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++,o+=16,t+=16){if(wZ(r,s,e,t,r,o),a>0)s+=16;wZ(r,o,e,t+=16,r,s)}}function Mye(e,t,r){let i=jy({dkLen:32,asyncTick:10,maxmem:1073742848},r),{N:n,r:o,p:s,dkLen:a,asyncTick:c,maxmem:l,onProgress:u}=i;if(Ot(n,"N"),Ot(o,"r"),Ot(s,"p"),Ot(a,"dkLen"),Ot(c,"asyncTick"),Ot(l,"maxmem"),u!==void 0&&typeof u!=="function")throw Error("progressCb must be a function");let d=128*o,p=d/4,m=Math.pow(2,32);if(n<=1||(n&n-1)!==0||n>m)throw Error('"N" expected a power of 2, and 2^1 <= N <= 2^32');if(s<1||s>(m-1)*32/d)throw Error('"p" expected integer 1..((2^32 - 1) * 32) / (128 * r)');if(a<1||a>(m-1)*32)throw Error('"dkLen" expected integer 1..(2^32 - 1) * 32');let y=d*(n+s+1);if(y>l)throw Error('"maxmem" limit was hit: memUsed(128*r*(N+p+1))='+y+", maxmem="+l);let g=kT(Rt,e,t,{c:1,dkLen:d*s}),b=Ly(g),v=Ly(new Uint8Array(d*n)),A=Ly(new Uint8Array(d)),T=()=>{};if(u){let z=2*n*s,j=Math.max(Math.floor(z/1e4),1),E=0;T=()=>{if(E++,u&&(!(E%j)||E===z))u(E/z)}}return{N:n,r:o,p:s,dkLen:a,blockSize32:p,V:v,B32:b,B:g,tmp:A,blockMixCb:T,asyncTick:c}}function Fye(e,t,r,i,n){let o=kT(Rt,e,r,{c:1,dkLen:t});return Lr(r,i,n),o}function IT(e,t,r){let{N:i,r:n,p:o,dkLen:s,blockSize32:a,V:c,B32:l,B:u,tmp:d,blockMixCb:p}=Mye(e,t,r);cT(l);for(let m=0;m<o;m++){let y=a*m;for(let g=0;g<a;g++)c[g]=l[y+g];for(let g=0,b=0;g<i-1;g++)ET(c,b,c,b+=a,n),p();ET(c,(i-1)*a,l,y,n),p();for(let g=0;g<i;g++){let b=(l[y+a-16]&i-1)>>>0;for(let v=0;v<a;v++)d[v]=l[y+v]^c[b*a+v];ET(d,0,l,y,n),p()}}return cT(l),Fye(e,s,u,c,d)}/*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */function Zye(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function Wy(e){if(typeof e!=="boolean")throw TypeError(`boolean expected, not ${e}`)}function kl(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 Ht(e,t,r=""){let i=Zye(e),n=e?.length,o=t!==void 0;if(!i||o&&n!==t){let s=r&&`"${r}" `,a=o?` of length ${t}`:"",c=i?`length=${n}`:`type=${typeof e}`,l=s+"expected Uint8Array"+a+", got "+c;if(!i)throw TypeError(l);throw RangeError(l)}return e}function AT(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 vZ(e,t,r=!1){Ht(e,void 0,"output");let i=t.outputLen;if(e.length<i)throw RangeError("digestInto() expects output buffer of length at least "+i);if(r&&!El(e))throw Error("invalid output, must be aligned")}function di(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function Mn(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Hye(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}var ga=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)(),Kye=(e)=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255;var Jye=(e)=>{for(let t=0;t<e.length;t++)e[t]=Kye(e[t]);return e},Hi=ga?(e)=>e:Jye;function _Z(e,t){if(t==null||typeof t!=="object")throw Error("options must be defined");return Object.assign(e,t)}function kZ(e,t){if(e.length!==t.length)return!1;let r=0;for(let i=0;i<e.length;i++)r|=e[i]^t[i];return r===0}function EZ(e,t,r){let i=t,n=r||(()=>[]),o=(a,c)=>i(c,...n(a)).update(a).digest(),s=i(new Uint8Array(e),...n(new Uint8Array(0)));return o.outputLen=s.outputLen,o.blockLen=s.blockLen,o.create=(a,...c)=>i(a,...c),o}var IZ=(e,t)=>{function r(i,...n){if(Ht(i,void 0,"key"),e.nonceLength!==void 0){let u=n[0];Ht(u,e.varSizeNonce?void 0:e.nonceLength,"nonce")}let o=e.tagLength;if(o&&n[1]!==void 0)Ht(n[1],void 0,"AAD");let s=t(i,...n),a=(u,d)=>{if(d!==void 0){if(u!==2)throw Error("cipher output not supported");Ht(d,void 0,"output")}},c=!1;return{encrypt(u,d){if(c)throw Error("cannot encrypt() twice with same key + nonce");return c=!0,Ht(u),a(s.encrypt.length,d),s.encrypt(u,d)},decrypt(u,d){if(Ht(u),o&&u.length<o)throw Error('"ciphertext" expected length bigger than tagLength='+o);return a(s.decrypt.length,d),s.decrypt(u,d)}}}return Object.assign(r,e),r};function kf(e,t,r=!0){if(t===void 0)return new Uint8Array(e);if(Ht(t,void 0,"output"),t.length!==e)throw Error('"output" expected Uint8Array of length '+e+", got: "+t.length);if(r&&!El(t))throw Error("invalid output, must be aligned");return t}function AZ(e,t,r){kl(e),kl(t),Wy(r);let i=new Uint8Array(16),n=Hye(i);return n.setBigUint64(0,BigInt(t),r),n.setBigUint64(8,BigInt(e),r),i}function El(e){return e.byteOffset%4===0}function Il(e){return Uint8Array.from(Ht(e))}var CZ=(e)=>Uint8Array.from(e.split(""),(t)=>t.charCodeAt(0)),Vye=(()=>Hi(di(CZ("expand 16-byte k"))))(),Wye=(()=>Hi(di(CZ("expand 32-byte k"))))();function Ye(e,t){return e<<t|e>>>32-t}var Ef=64,Gye=16,TT=(()=>4294967295)(),TZ=Uint32Array.of();function Qye(e,t,r,i,n,o,s,a){let c=n.length,l=new Uint8Array(Ef),u=di(l),d=ga&&El(n)&&El(o),p=d?di(n):TZ,m=d?di(o):TZ;if(!ga){for(let y=0;y<c;s++){if(e(t,r,i,u,s,a),Hi(u),s>=TT)throw Error("arx: counter overflow");let g=Math.min(Ef,c-y);for(let b=0,v;b<g;b++)v=y+b,o[v]=n[v]^l[b];y+=g}return}for(let y=0;y<c;s++){if(e(t,r,i,u,s,a),s>=TT)throw Error("arx: counter overflow");let g=Math.min(Ef,c-y);if(d&&g===Ef){let b=y/4;if(y%4!==0)throw Error("arx: invalid block position");for(let v=0,A;v<Gye;v++)A=b+v,m[A]=p[A]^u[v];y+=Ef;continue}for(let b=0,v;b<g;b++)v=y+b,o[v]=n[v]^l[b];y+=g}}function $Z(e,t){let{allowShortKeys:r,extendNonceFn:i,counterLength:n,counterRight:o,rounds:s}=_Z({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},t);if(typeof e!=="function")throw Error("core must be a function");return kl(n),kl(s),Wy(o),Wy(r),(a,c,l,u,d=0)=>{Ht(a,void 0,"key"),Ht(c,void 0,"nonce"),Ht(l,void 0,"data");let p=l.length;if(u=kf(p,u,!1),kl(d),d<0||d>=TT)throw Error("arx: counter overflow");let m=[],y=a.length,g,b;if(y===32)m.push(g=Il(a)),b=Wye;else if(y===16&&r)g=new Uint8Array(32),g.set(a),g.set(a,16),b=Vye,m.push(g);else throw Ht(a,32,"arx key"),Error("invalid key size");if(!ga||!El(c))m.push(c=Il(c));let v=di(g);if(i){if(c.length!==24)throw Error("arx: extended nonce must be 24 bytes");let z=c.subarray(0,16);if(ga)i(b,v,di(z),v);else{let j=Hi(Uint32Array.from(b));i(j,v,di(z),v),Mn(j),Hi(v)}c=c.subarray(16)}else if(!ga)Hi(v);let A=16-n;if(A!==c.length)throw Error(`arx: nonce must be ${A} or 16 bytes`);if(A!==12){let z=new Uint8Array(12);z.set(c,o?0:12-c.length),c=z,m.push(c)}let T=Hi(di(c));try{return Qye(e,b,v,T,l,u,d,s),u}finally{Mn(...m)}}}function ar(e,t){return e[t++]&255|(e[t++]&255)<<8}class OZ{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=Il(Ht(e,32,"key"));let t=ar(e,0),r=ar(e,2),i=ar(e,4),n=ar(e,6),o=ar(e,8),s=ar(e,10),a=ar(e,12),c=ar(e,14);this.r[0]=t&8191,this.r[1]=(t>>>13|r<<3)&8191,this.r[2]=(r>>>10|i<<6)&7939,this.r[3]=(i>>>7|n<<9)&8191,this.r[4]=(n>>>4|o<<12)&255,this.r[5]=o>>>1&8190,this.r[6]=(o>>>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 l=0;l<8;l++)this.pad[l]=ar(e,16+2*l)}process(e,t,r=!1){let i=r?0:2048,{h:n,r:o}=this,s=o[0],a=o[1],c=o[2],l=o[3],u=o[4],d=o[5],p=o[6],m=o[7],y=o[8],g=o[9],b=ar(e,t+0),v=ar(e,t+2),A=ar(e,t+4),T=ar(e,t+6),z=ar(e,t+8),j=ar(e,t+10),E=ar(e,t+12),Z=ar(e,t+14),D=n[0]+(b&8191),H=n[1]+((b>>>13|v<<3)&8191),X=n[2]+((v>>>10|A<<6)&8191),M=n[3]+((A>>>7|T<<9)&8191),P=n[4]+((T>>>4|z<<12)&8191),N=n[5]+(z>>>1&8191),I=n[6]+((z>>>14|j<<2)&8191),R=n[7]+((j>>>11|E<<5)&8191),O=n[8]+((E>>>8|Z<<8)&8191),F=n[9]+(Z>>>5|i),L=0,V=L+D*s+H*(5*g)+X*(5*y)+M*(5*m)+P*(5*p);L=V>>>13,V&=8191,V+=N*(5*d)+I*(5*u)+R*(5*l)+O*(5*c)+F*(5*a),L+=V>>>13,V&=8191;let _=L+D*a+H*s+X*(5*g)+M*(5*y)+P*(5*m);L=_>>>13,_&=8191,_+=N*(5*p)+I*(5*d)+R*(5*u)+O*(5*l)+F*(5*c),L+=_>>>13,_&=8191;let te=L+D*c+H*a+X*s+M*(5*g)+P*(5*y);L=te>>>13,te&=8191,te+=N*(5*m)+I*(5*p)+R*(5*d)+O*(5*u)+F*(5*l),L+=te>>>13,te&=8191;let ue=L+D*l+H*c+X*a+M*s+P*(5*g);L=ue>>>13,ue&=8191,ue+=N*(5*y)+I*(5*m)+R*(5*p)+O*(5*d)+F*(5*u),L+=ue>>>13,ue&=8191;let C=L+D*u+H*l+X*c+M*a+P*s;L=C>>>13,C&=8191,C+=N*(5*g)+I*(5*y)+R*(5*m)+O*(5*p)+F*(5*d),L+=C>>>13,C&=8191;let Se=L+D*d+H*u+X*l+M*c+P*a;L=Se>>>13,Se&=8191,Se+=N*s+I*(5*g)+R*(5*y)+O*(5*m)+F*(5*p),L+=Se>>>13,Se&=8191;let Ee=L+D*p+H*d+X*u+M*l+P*c;L=Ee>>>13,Ee&=8191,Ee+=N*a+I*s+R*(5*g)+O*(5*y)+F*(5*m),L+=Ee>>>13,Ee&=8191;let $e=L+D*m+H*p+X*d+M*u+P*l;L=$e>>>13,$e&=8191,$e+=N*c+I*a+R*s+O*(5*g)+F*(5*y),L+=$e>>>13,$e&=8191;let Ce=L+D*y+H*m+X*p+M*d+P*u;L=Ce>>>13,Ce&=8191,Ce+=N*l+I*c+R*a+O*s+F*(5*g),L+=Ce>>>13,Ce&=8191;let _e=L+D*g+H*y+X*m+M*p+P*d;L=_e>>>13,_e&=8191,_e+=N*u+I*l+R*c+O*a+F*s,L+=_e>>>13,_e&=8191,L=(L<<2)+L|0,L=L+V|0,V=L&8191,L=L>>>13,_+=L,n[0]=V,n[1]=_,n[2]=te,n[3]=ue,n[4]=C,n[5]=Se,n[6]=Ee,n[7]=$e,n[8]=Ce,n[9]=_e}finalize(){let{h:e,pad:t}=this,r=new Uint16Array(10),i=e[1]>>>13;e[1]&=8191;for(let s=2;s<10;s++)e[s]+=i,i=e[s]>>>13,e[s]&=8191;e[0]+=i*5,i=e[0]>>>13,e[0]&=8191,e[1]+=i,i=e[1]>>>13,e[1]&=8191,e[2]+=i,r[0]=e[0]+5,i=r[0]>>>13,r[0]&=8191;for(let s=1;s<10;s++)r[s]=e[s]+i,i=r[s]>>>13,r[s]&=8191;r[9]-=8192;let n=(i^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 o=e[0]+t[0];e[0]=o&65535;for(let s=1;s<8;s++)o=(e[s]+t[s]|0)+(o>>>16)|0,e[s]=o&65535;Mn(r)}update(e){AT(this),Ht(e),e=Il(e);let{buffer:t,blockLen:r}=this,i=e.length;for(let n=0;n<i;){let o=Math.min(r-this.pos,i-n);if(o===r){for(;r<=i-n;n+=r)this.process(e,n);continue}if(t.set(e.subarray(n,n+o),this.pos),this.pos+=o,n+=o,this.pos===r)this.process(t,0,!1),this.pos=0}return this}destroy(){this.destroyed=!0,Mn(this.h,this.r,this.buffer,this.pad)}digestInto(e){AT(this),vZ(e,this),this.finished=!0;let{buffer:t,h:r}=this,{pos:i}=this;if(i){t[i++]=1;for(;i<16;i++)t[i]=0;this.process(t,0,!0)}this.finalize();let n=0;for(let o=0;o<8;o++)e[n++]=r[o]>>>0,e[n++]=r[o]>>>8}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let r=e.slice(0,t);return this.destroy(),r}}var RZ=EZ(32,(e)=>new OZ(e));function Yye(e,t,r,i,n,o=20){let s=e[0],a=e[1],c=e[2],l=e[3],u=t[0],d=t[1],p=t[2],m=t[3],y=t[4],g=t[5],b=t[6],v=t[7],A=n,T=r[0],z=r[1],j=r[2],E=s,Z=a,D=c,H=l,X=u,M=d,P=p,N=m,I=y,R=g,O=b,F=v,L=A,V=T,_=z,te=j;for(let C=0;C<o;C+=2)E=E+X|0,L=Ye(L^E,16),I=I+L|0,X=Ye(X^I,12),E=E+X|0,L=Ye(L^E,8),I=I+L|0,X=Ye(X^I,7),Z=Z+M|0,V=Ye(V^Z,16),R=R+V|0,M=Ye(M^R,12),Z=Z+M|0,V=Ye(V^Z,8),R=R+V|0,M=Ye(M^R,7),D=D+P|0,_=Ye(_^D,16),O=O+_|0,P=Ye(P^O,12),D=D+P|0,_=Ye(_^D,8),O=O+_|0,P=Ye(P^O,7),H=H+N|0,te=Ye(te^H,16),F=F+te|0,N=Ye(N^F,12),H=H+N|0,te=Ye(te^H,8),F=F+te|0,N=Ye(N^F,7),E=E+M|0,te=Ye(te^E,16),O=O+te|0,M=Ye(M^O,12),E=E+M|0,te=Ye(te^E,8),O=O+te|0,M=Ye(M^O,7),Z=Z+P|0,L=Ye(L^Z,16),F=F+L|0,P=Ye(P^F,12),Z=Z+P|0,L=Ye(L^Z,8),F=F+L|0,P=Ye(P^F,7),D=D+N|0,V=Ye(V^D,16),I=I+V|0,N=Ye(N^I,12),D=D+N|0,V=Ye(V^D,8),I=I+V|0,N=Ye(N^I,7),H=H+X|0,_=Ye(_^H,16),R=R+_|0,X=Ye(X^R,12),H=H+X|0,_=Ye(_^H,8),R=R+_|0,X=Ye(X^R,7);let ue=0;i[ue++]=s+E|0,i[ue++]=a+Z|0,i[ue++]=c+D|0,i[ue++]=l+H|0,i[ue++]=u+X|0,i[ue++]=d+M|0,i[ue++]=p+P|0,i[ue++]=m+N|0,i[ue++]=y+I|0,i[ue++]=g+R|0,i[ue++]=b+O|0,i[ue++]=v+F|0,i[ue++]=A+L|0,i[ue++]=T+V|0,i[ue++]=z+_|0,i[ue++]=j+te|0}var Xye=$Z(Yye,{counterRight:!1,counterLength:4,allowShortKeys:!1});var ebe=new Uint8Array(16),PZ=(e,t)=>{e.update(t);let r=t.length%16;if(r)e.update(ebe.subarray(r))},tbe=new Uint8Array(32);function zZ(e,t,r,i,n){if(n!==void 0)Ht(n,void 0,"AAD");let o=e(t,r,tbe),s=AZ(i.length,n?n.length:0,!0),a=RZ.create(o);if(n)PZ(a,n);PZ(a,i),a.update(s);let c=a.digest();return Mn(o,s),c}var rbe=(e)=>(t,r,i)=>({encrypt(o,s){let a=o.length;s=kf(a+16,s,!1),s.set(o);let c=s.subarray(0,-16);e(t,r,c,c,1);let l=zZ(e,t,r,c,i);return s.set(l,a),Mn(l),s},decrypt(o,s){s=kf(o.length-16,s,!1);let a=o.subarray(0,-16),c=o.subarray(-16),l=zZ(e,t,r,a,i);if(!kZ(c,l))throw Mn(l),Error("invalid tag");return s.set(o.subarray(0,-16)),e(t,r,s,s,1),Mn(l),s}}),vn=IZ({blockSize:64,nonceLength:12,tagLength:16},rbe(Xye));/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Al(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Yt(e,t=""){if(!Number.isSafeInteger(e)||e<0){let r=t&&`"${t}" `;throw Error(`${r}expected integer >= 0, got ${e}`)}}function Ne(e,t,r=""){let i=Al(e),n=e?.length,o=t!==void 0;if(!i||o&&n!==t){let s=r&&`"${r}" `,a=o?` of length ${t}`:"",c=i?`length=${n}`:`type=${typeof e}`;throw Error(s+"expected Uint8Array"+a+", got "+c)}return e}function _n(e){if(typeof e!=="function"||typeof e.create!=="function")throw Error("Hash must wrapped by utils.createHasher");Yt(e.outputLen),Yt(e.blockLen)}function Ji(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 Gy(e,t){Ne(e,void 0,"digestInto() output");let r=t.outputLen;if(e.length<r)throw Error('"digestInto() output" expected to be of length >='+r)}function Qy(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function Vr(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Yy(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Fn(e,t){return e<<32-t|e>>>t}var nbe=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)();function ibe(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function obe(e){for(let t=0;t<e.length;t++)e[t]=ibe(e[t]);return e}var CT=nbe?(e)=>e:obe,DZ=(()=>typeof Uint8Array.from([]).toHex==="function"&&typeof Uint8Array.fromHex==="function")(),sbe=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function ya(e){if(Ne(e),DZ)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=sbe[e[r]];return t}var Ki={_0:48,_9:57,A:65,F:70,a:97,f:102};function NZ(e){if(e>=Ki._0&&e<=Ki._9)return e-Ki._0;if(e>=Ki.A&&e<=Ki.F)return e-(Ki.A-10);if(e>=Ki.a&&e<=Ki.f)return e-(Ki.a-10);return}function ba(e){if(typeof e!=="string")throw Error("hex string expected, got "+typeof e);if(DZ)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 i=new Uint8Array(r);for(let n=0,o=0;n<r;n++,o+=2){let s=NZ(e.charCodeAt(o)),a=NZ(e.charCodeAt(o+1));if(s===void 0||a===void 0){let c=e[o]+e[o+1];throw Error('hex string expected, got non-hex character "'+c+'" at index '+o)}i[n]=s*16+a}return i}function qt(...e){let t=0;for(let i=0;i<e.length;i++){let n=e[i];Ne(n),t+=n.length}let r=new Uint8Array(t);for(let i=0,n=0;i<e.length;i++){let o=e[i];r.set(o,n),n+=o.length}return r}function Tl(e,t={}){let r=(n,o)=>e(o).update(n).digest(),i=e(void 0);return r.outputLen=i.outputLen,r.blockLen=i.blockLen,r.create=(n)=>e(n),Object.assign(r,t),Object.freeze(r)}function es(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 ts=(e)=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var OT=BigInt(0),$T=BigInt(1);function If(e,t=""){if(typeof e!=="boolean"){let r=t&&`"${t}" `;throw Error(r+"expected boolean, got type="+typeof e)}return e}function LZ(e){if(typeof e==="bigint"){if(!Xy(e))throw Error("positive bigint expected, got "+e)}else Yt(e);return e}function Af(e){let t=LZ(e).toString(16);return t.length&1?"0"+t:t}function BZ(e){if(typeof e!=="string")throw Error("hex string expected, got "+typeof e);return e===""?OT:BigInt("0x"+e)}function rs(e){return BZ(ya(e))}function ns(e){return BZ(ya(eb(Ne(e)).reverse()))}function Cl(e,t){Yt(t),e=LZ(e);let r=ba(e.toString(16).padStart(t*2,"0"));if(r.length!==t)throw Error("number too large");return r}function Tf(e,t){return Cl(e,t).reverse()}function eb(e){return Uint8Array.from(e)}function is(e){return Uint8Array.from(e,(t,r)=>{let i=t.charCodeAt(0);if(t.length!==1||i>127)throw Error(`string contains non-ASCII character "${e[r]}" with code ${i} at position ${r}`);return i})}var Xy=(e)=>typeof e==="bigint"&&OT<=e;function abe(e,t,r){return Xy(e)&&Xy(t)&&Xy(r)&&t<=e&&e<r}function Cf(e,t,r,i){if(!abe(t,r,i))throw Error("expected valid "+e+": "+r+" <= n < "+i+", got "+t)}function RT(e){let t;for(t=0;e>OT;e>>=$T,t+=1);return t}var $f=(e)=>($T<<BigInt(e))-$T;function jZ(e,t,r){if(Yt(e,"hashLen"),Yt(t,"qByteLen"),typeof r!=="function")throw Error("hmacFn must be a function");let i=(b)=>new Uint8Array(b),n=Uint8Array.of(),o=Uint8Array.of(0),s=Uint8Array.of(1),a=1000,c=i(e),l=i(e),u=0,d=()=>{c.fill(1),l.fill(0),u=0},p=(...b)=>r(l,qt(c,...b)),m=(b=n)=>{if(l=p(o,b),c=p(),b.length===0)return;l=p(s,b),c=p()},y=()=>{if(u++>=a)throw Error("drbg: tried max amount of iterations");let b=0,v=[];while(b<t){c=p();let A=c.slice();v.push(A),b+=c.length}return qt(...v)};return(b,v)=>{d(),m(b);let A=void 0;while(!(A=v(y())))m();return d(),A}}function xa(e,t={},r={}){if(!e||typeof e!=="object")throw Error("expected valid options object");function i(o,s,a){let c=e[o];if(a&&c===void 0)return;let l=typeof c;if(l!==s||c===null)throw Error(`param "${o}" is invalid: expected ${s}, got ${l}`)}let n=(o,s)=>Object.entries(o).forEach(([a,c])=>i(a,c,s));n(t,!1),n(r,!0)}function PT(e){let t=new WeakMap;return(r,...i)=>{let n=t.get(r);if(n!==void 0)return n;let o=e(r,...i);return t.set(r,o),o}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var jr=BigInt(0),vr=BigInt(1),Sa=BigInt(2),MZ=BigInt(3),FZ=BigInt(4),ZZ=BigInt(5),cbe=BigInt(7),HZ=BigInt(8),lbe=BigInt(9),KZ=BigInt(16);function Br(e,t){let r=e%t;return r>=jr?r:t+r}function kn(e,t,r){let i=e;while(t-- >jr)i*=i,i%=r;return i}function qZ(e,t){if(e===jr)throw Error("invert: expected non-zero number");if(t<=jr)throw Error("invert: expected positive modulus, got "+t);let r=Br(e,t),i=t,n=jr,o=vr,s=vr,a=jr;while(r!==jr){let l=i/r,u=i%r,d=n-s*l,p=o-a*l;i=r,r=u,n=s,o=a,s=d,a=p}if(i!==vr)throw Error("invert: does not exist");return Br(n,t)}function zT(e,t,r){if(!e.eql(e.sqr(t),r))throw Error("Cannot find square root")}function JZ(e,t){let r=(e.ORDER+vr)/FZ,i=e.pow(t,r);return zT(e,i,t),i}function ube(e,t){let r=(e.ORDER-ZZ)/HZ,i=e.mul(t,Sa),n=e.pow(i,r),o=e.mul(t,n),s=e.mul(e.mul(o,Sa),n),a=e.mul(o,e.sub(s,e.ONE));return zT(e,a,t),a}function dbe(e){let t=tb(e),r=VZ(e),i=r(t,t.neg(t.ONE)),n=r(t,i),o=r(t,t.neg(i)),s=(e+cbe)/KZ;return(a,c)=>{let l=a.pow(c,s),u=a.mul(l,i),d=a.mul(l,n),p=a.mul(l,o),m=a.eql(a.sqr(u),c),y=a.eql(a.sqr(d),c);l=a.cmov(l,u,m),u=a.cmov(p,d,y);let g=a.eql(a.sqr(u),c),b=a.cmov(l,u,g);return zT(a,b,c),b}}function VZ(e){if(e<MZ)throw Error("sqrt is not defined for small field");let t=e-vr,r=0;while(t%Sa===jr)t/=Sa,r++;let i=Sa,n=tb(e);while(UZ(n,i)===1)if(i++>1000)throw Error("Cannot find square root: probably non-prime P");if(r===1)return JZ;let o=n.pow(i,t),s=(t+vr)/Sa;return function(c,l){if(c.is0(l))return l;if(UZ(c,l)!==1)throw Error("Cannot find square root");let u=r,d=c.mul(c.ONE,o),p=c.pow(l,t),m=c.pow(l,s);while(!c.eql(p,c.ONE)){if(c.is0(p))return c.ZERO;let y=1,g=c.sqr(p);while(!c.eql(g,c.ONE))if(y++,g=c.sqr(g),y===u)throw Error("Cannot find square root");let b=vr<<BigInt(u-y-1),v=c.pow(d,b);u=y,d=c.sqr(v),p=c.mul(p,d),m=c.mul(m,v)}return m}}function fbe(e){if(e%FZ===MZ)return JZ;if(e%HZ===ZZ)return ube;if(e%KZ===lbe)return dbe(e);return VZ(e)}var pbe=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function NT(e){let t={ORDER:"bigint",BYTES:"number",BITS:"number"},r=pbe.reduce((i,n)=>(i[n]="function",i),t);return xa(e,r),e}function mbe(e,t,r){if(r<jr)throw Error("invalid exponent, negatives unsupported");if(r===jr)return e.ONE;if(r===vr)return t;let i=e.ONE,n=t;while(r>jr){if(r&vr)i=e.mul(i,n);n=e.sqr(n),r>>=vr}return i}function Of(e,t,r=!1){let i=Array(t.length).fill(r?e.ZERO:void 0),n=t.reduce((s,a,c)=>{if(e.is0(a))return s;return i[c]=s,e.mul(s,a)},e.ONE),o=e.inv(n);return t.reduceRight((s,a,c)=>{if(e.is0(a))return s;return i[c]=e.mul(s,i[c]),e.mul(s,a)},o),i}function UZ(e,t){let r=(e.ORDER-vr)/Sa,i=e.pow(t,r),n=e.eql(i,e.ONE),o=e.eql(i,e.ZERO),s=e.eql(i,e.neg(e.ONE));if(!n&&!o&&!s)throw Error("invalid Legendre symbol result");return n?1:o?0:-1}function hbe(e,t){if(t!==void 0)Yt(t);let r=t!==void 0?t:e.toString(2).length,i=Math.ceil(r/8);return{nBitLength:r,nByteLength:i}}class WZ{ORDER;BITS;BYTES;isLE;ZERO=jr;ONE=vr;_lengths;_sqrt;_mod;constructor(e,t={}){if(e<=jr)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:i,nByteLength:n}=hbe(e,r);if(n>2048)throw Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=e,this.BITS=i,this.BYTES=n,this._sqrt=void 0,Object.preventExtensions(this)}create(e){return Br(e,this.ORDER)}isValid(e){if(typeof e!=="bigint")throw Error("invalid field element: expected bigint, got "+typeof e);return jr<=e&&e<this.ORDER}is0(e){return e===jr}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&vr)===vr}neg(e){return Br(-e,this.ORDER)}eql(e,t){return e===t}sqr(e){return Br(e*e,this.ORDER)}add(e,t){return Br(e+t,this.ORDER)}sub(e,t){return Br(e-t,this.ORDER)}mul(e,t){return Br(e*t,this.ORDER)}pow(e,t){return mbe(this,e,t)}div(e,t){return Br(e*qZ(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 qZ(e,this.ORDER)}sqrt(e){if(!this._sqrt)this._sqrt=fbe(this.ORDER);return this._sqrt(this,e)}toBytes(e){return this.isLE?Tf(e,this.BYTES):Cl(e,this.BYTES)}fromBytes(e,t=!1){Ne(e);let{_lengths:r,BYTES:i,isLE:n,ORDER:o,_mod:s}=this;if(r){if(!r.includes(e.length)||e.length>i)throw Error("Field.fromBytes: expected "+r+" bytes, got "+e.length);let c=new Uint8Array(i);c.set(e,n?0:c.length-e.length),e=c}if(e.length!==i)throw Error("Field.fromBytes: expected "+i+" bytes, got "+e.length);let a=n?ns(e):rs(e);if(s)a=Br(a,o);if(!t){if(!this.isValid(a))throw Error("invalid field element: outside of range 0..ORDER")}return a}invertBatch(e){return Of(this,e)}cmov(e,t,r){return r?t:e}}function tb(e,t={}){return new WZ(e,t)}function GZ(e){if(typeof e!=="bigint")throw Error("field order must be bigint");let t=e.toString(2).length;return Math.ceil(t/8)}function DT(e){let t=GZ(e);return t+Math.ceil(t/2)}function QZ(e,t,r=!1){Ne(e);let i=e.length,n=GZ(t),o=DT(t);if(i<16||i<o||i>1024)throw Error("expected "+o+"-1024 bytes of input, got "+i);let s=r?ns(e):rs(e),a=Br(s,t-vr)+vr;return r?Tf(a,n):Cl(a,n)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var $l=BigInt(0),wa=BigInt(1);function Rf(e,t){let r=t.negate();return e?r:t}function qT(e,t){let r=Of(e.Fp,t.map((i)=>i.Z));return t.map((i,n)=>e.fromAffine(i.toAffine(r[n])))}function t3(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw Error("invalid window size, expected [1.."+t+"], got W="+e)}function LT(e,t){t3(e,t);let r=Math.ceil(t/e)+1,i=2**(e-1),n=2**e,o=$f(e),s=BigInt(e);return{windows:r,windowSize:i,mask:o,maxNumber:n,shiftBy:s}}function YZ(e,t,r){let{windowSize:i,mask:n,maxNumber:o,shiftBy:s}=r,a=Number(e&n),c=e>>s;if(a>i)a-=o,c+=wa;let l=t*i,u=l+Math.abs(a)-1,d=a===0,p=a<0,m=t%2!==0;return{nextN:c,offset:u,isZero:d,isNeg:p,isNegF:m,offsetF:l}}var BT=new WeakMap,r3=new WeakMap;function jT(e){return r3.get(e)||1}function XZ(e){if(e!==$l)throw Error("invalid wNAF")}class UT{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 i=e;while(t>$l){if(t&wa)r=r.add(i);i=i.double(),t>>=wa}return r}precomputeWindow(e,t){let{windows:r,windowSize:i}=LT(t,this.bits),n=[],o=e,s=o;for(let a=0;a<r;a++){s=o,n.push(s);for(let c=1;c<i;c++)s=s.add(o),n.push(s);o=s.double()}return n}wNAF(e,t,r){if(!this.Fn.isValid(r))throw Error("invalid scalar");let i=this.ZERO,n=this.BASE,o=LT(e,this.bits);for(let s=0;s<o.windows;s++){let{nextN:a,offset:c,isZero:l,isNeg:u,isNegF:d,offsetF:p}=YZ(r,s,o);if(r=a,l)n=n.add(Rf(d,t[p]));else i=i.add(Rf(u,t[c]))}return XZ(r),{p:i,f:n}}wNAFUnsafe(e,t,r,i=this.ZERO){let n=LT(e,this.bits);for(let o=0;o<n.windows;o++){if(r===$l)break;let{nextN:s,offset:a,isZero:c,isNeg:l}=YZ(r,o,n);if(r=s,c)continue;else{let u=t[a];i=i.add(l?u.negate():u)}}return XZ(r),i}getPrecomputes(e,t,r){let i=BT.get(t);if(!i){if(i=this.precomputeWindow(t,e),e!==1){if(typeof r==="function")i=r(i);BT.set(t,i)}}return i}cached(e,t,r){let i=jT(e);return this.wNAF(i,this.getPrecomputes(i,e,r),t)}unsafe(e,t,r,i){let n=jT(e);if(n===1)return this._unsafeLadder(e,t,i);return this.wNAFUnsafe(n,this.getPrecomputes(n,e,r),t,i)}createCache(e,t){t3(t,this.bits),r3.set(e,t),BT.delete(e)}hasCache(e){return jT(e)!==1}}function n3(e,t,r,i){let n=t,o=e.ZERO,s=e.ZERO;while(r>$l||i>$l){if(r&wa)o=o.add(n);if(i&wa)s=s.add(n);n=n.double(),r>>=wa,i>>=wa}return{p1:o,p2:s}}function e3(e,t,r){if(t){if(t.ORDER!==e)throw Error("Field.ORDER must match order: Fp == p, Fn == n");return NT(t),t}else return tb(e,{isLE:r})}function i3(e,t,r={},i){if(i===void 0)i=e==="edwards";if(!t||typeof t!=="object")throw Error(`expected valid ${e} CURVE object`);for(let c of["p","n","h"]){let l=t[c];if(!(typeof l==="bigint"&&l>$l))throw Error(`CURVE.${c} must be positive bigint`)}let n=e3(t.p,r.Fp,i),o=e3(t.n,r.Fn,i),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:o}}function rb(e,t){return function(i){let n=e(i);return{secretKey:n,publicKey:t(n)}}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var Pf=BigInt(0),Ol=BigInt(1),nb=BigInt(2);function gbe(e){return xa(e,{adjustScalarBytes:"function",powPminus2:"function"}),Object.freeze({...e})}function o3(e){let t=gbe(e),{P:r,type:i,adjustScalarBytes:n,powPminus2:o,randomBytes:s}=t,a=i==="x25519";if(!a&&i!=="x448")throw Error("invalid type");let c=s||es,l=a?255:448,u=a?32:56,d=a?BigInt(9):BigInt(5),p=a?BigInt(121665):BigInt(39081),m=a?nb**BigInt(254):nb**BigInt(447),y=a?BigInt(8)*nb**BigInt(251)-Ol:BigInt(4)*nb**BigInt(445)-Ol,g=m+y+Ol,b=(I)=>Br(I,r),v=A(d);function A(I){return Tf(b(I),u)}function T(I){let R=eb(Ne(I,u,"uCoordinate"));if(a)R[31]&=127;return b(ns(R))}function z(I){return ns(n(eb(Ne(I,u,"scalar"))))}function j(I,R){let O=X(T(R),z(I));if(O===Pf)throw Error("invalid private or public key received");return A(O)}function E(I){return j(I,v)}let Z=E,D=j;function H(I,R,O){let F=b(I*(R-O));return R=b(R-F),O=b(O+F),{x_2:R,x_3:O}}function X(I,R){Cf("u",I,Pf,r),Cf("scalar",R,m,g);let O=R,F=I,L=Ol,V=Pf,_=I,te=Ol,ue=Pf;for(let Se=BigInt(l-1);Se>=Pf;Se--){let Ee=O>>Se&Ol;ue^=Ee,{x_2:L,x_3:_}=H(ue,L,_),{x_2:V,x_3:te}=H(ue,V,te),ue=Ee;let $e=L+V,Ce=b($e*$e),_e=L-V,ze=b(_e*_e),Ve=Ce-ze,Xe=_+te,St=_-te,Lt=b(St*$e),hr=b(Xe*_e),Yr=Lt+hr,Xr=Lt-hr;_=b(Yr*Yr),te=b(F*b(Xr*Xr)),L=b(Ce*ze),V=b(Ve*(Ce+b(p*Ve)))}({x_2:L,x_3:_}=H(ue,L,_)),{x_2:V,x_3:te}=H(ue,V,te);let C=o(V);return b(L*C)}let M={secretKey:u,publicKey:u,seed:u},P=(I=c(u))=>(Ne(I,M.seed,"seed"),I),N={randomSecretKey:P};return Object.freeze({keygen:rb(P,Z),getSharedSecret:D,getPublicKey:Z,scalarMult:j,scalarMultBase:E,utils:N,GuBytes:v.slice(),lengths:M})}class MT{oHash;iHash;blockLen;outputLen;finished=!1;destroyed=!1;constructor(e,t){if(_n(e),Ne(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,i=new Uint8Array(r);i.set(t.length>r?e.create().update(t).digest():t);for(let n=0;n<i.length;n++)i[n]^=54;this.iHash.update(i),this.oHash=e.create();for(let n=0;n<i.length;n++)i[n]^=106;this.oHash.update(i),Vr(i)}update(e){return Ji(this),this.iHash.update(e),this}digestInto(e){Ji(this),Ne(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:i,destroyed:n,blockLen:o,outputLen:s}=this;return e=e,e.finished=i,e.destroyed=n,e.blockLen=o,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 Rl=(e,t,r)=>new MT(e,t).update(r).digest();Rl.create=(e,t)=>new MT(e,t);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var s3=(e,t)=>(e+(e>=0?t:-t)/c3)/t;function ybe(e,t,r){let[[i,n],[o,s]]=t,a=s3(s*e,r),c=s3(-n*e,r),l=e-a*i-c*o,u=-a*n-c*s,d=l<Vi,p=u<Vi;if(d)l=-l;if(p)u=-u;let m=$f(Math.ceil(RT(r)/2))+Pl;if(l<Vi||l>=m||u<Vi||u>=m)throw Error("splitScalar (endomorphism): failed, k="+e);return{k1neg:d,k1:l,k2neg:p,k2:u}}function ZT(e){if(!["compact","recovered","der"].includes(e))throw Error('Signature format must be "compact", "recovered", or "der"');return e}function FT(e,t){let r={};for(let i of Object.keys(t))r[i]=e[i]===void 0?t[i]:e[i];if(If(r.lowS,"lowS"),If(r.prehash,"prehash"),r.format!==void 0)ZT(r.format);return r}class a3 extends Error{constructor(e=""){super(e)}}var os={Err:a3,_tlv:{encode:(e,t)=>{let{Err:r}=os;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length&1)throw new r("tlv.encode: unpadded data");let i=t.length/2,n=Af(i);if(n.length/2&128)throw new r("tlv.encode: long form length too big");let o=i>127?Af(n.length/2|128):"";return Af(e)+o+n+t},decode(e,t){let{Err:r}=os,i=0;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length<2||t[i++]!==e)throw new r("tlv.decode: wrong tlv");let n=t[i++],o=!!(n&128),s=0;if(!o)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 l=t.subarray(i,i+c);if(l.length!==c)throw new r("tlv.decode: length bytes not complete");if(l[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let u of l)s=s<<8|u;if(i+=c,s<128)throw new r("tlv.decode(long): not minimal encoding")}let a=t.subarray(i,i+s);if(a.length!==s)throw new r("tlv.decode: wrong value length");return{v:a,l:t.subarray(i+s)}}},_int:{encode(e){let{Err:t}=os;if(e<Vi)throw new t("integer: negative integers are not allowed");let r=Af(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}=os;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 rs(e)}},toSig(e){let{Err:t,_int:r,_tlv:i}=os,n=Ne(e,void 0,"signature"),{v:o,l:s}=i.decode(48,n);if(s.length)throw new t("invalid signature: left bytes after parsing");let{v:a,l:c}=i.decode(2,o),{v:l,l:u}=i.decode(2,c);if(u.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(l)}},hexFromSig(e){let{_tlv:t,_int:r}=os,i=t.encode(2,r.encode(e.r)),n=t.encode(2,r.encode(e.s)),o=i+n;return t.encode(48,o)}},Vi=BigInt(0),Pl=BigInt(1),c3=BigInt(2),ib=BigInt(3),bbe=BigInt(4);function HT(e,t={}){let r=i3("weierstrass",e,t),{Fp:i,Fn:n}=r,o=r.CURVE,{h:s,n:a}=o;xa(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});let{endo:c}=t;if(c){if(!i.is0(o.a)||typeof c.beta!=="bigint"||!Array.isArray(c.basises))throw Error('invalid endo: expected "beta": bigint and "basises": array')}let l=u3(i,n);function u(){if(!i.isOdd)throw Error("compression is not supported: Field does not have .isOdd()")}function d(P,N,I){let{x:R,y:O}=N.toAffine(),F=i.toBytes(R);if(If(I,"isCompressed"),I){u();let L=!i.isOdd(O);return qt(l3(L),F)}else return qt(Uint8Array.of(4),F,i.toBytes(O))}function p(P){Ne(P,void 0,"Point");let{publicKey:N,publicKeyUncompressed:I}=l,R=P.length,O=P[0],F=P.subarray(1);if(R===N&&(O===2||O===3)){let L=i.fromBytes(F);if(!i.isValid(L))throw Error("bad point: is not on curve, wrong x");let V=g(L),_;try{_=i.sqrt(V)}catch(C){let Se=C instanceof Error?": "+C.message:"";throw Error("bad point: is not on curve, sqrt error"+Se)}u();let te=i.isOdd(_);if((O&1)===1!==te)_=i.neg(_);return{x:L,y:_}}else if(R===I&&O===4){let L=i.BYTES,V=i.fromBytes(F.subarray(0,L)),_=i.fromBytes(F.subarray(L,L*2));if(!b(V,_))throw Error("bad point: is not on curve");return{x:V,y:_}}else throw Error(`bad point: got length ${R}, expected compressed=${N} or uncompressed=${I}`)}let m=t.toBytes||d,y=t.fromBytes||p;function g(P){let N=i.sqr(P),I=i.mul(N,P);return i.add(i.add(I,i.mul(P,o.a)),o.b)}function b(P,N){let I=i.sqr(N),R=g(P);return i.eql(I,R)}if(!b(o.Gx,o.Gy))throw Error("bad curve params: generator point");let v=i.mul(i.pow(o.a,ib),bbe),A=i.mul(i.sqr(o.b),BigInt(27));if(i.is0(i.add(v,A)))throw Error("bad curve params: a or b");function T(P,N,I=!1){if(!i.isValid(N)||I&&i.is0(N))throw Error(`bad point coordinate ${P}`);return N}function z(P){if(!(P instanceof H))throw Error("Weierstrass Point expected")}function j(P){if(!c||!c.basises)throw Error("no endo");return ybe(P,c.basises,n.ORDER)}let E=PT((P,N)=>{let{X:I,Y:R,Z:O}=P;if(i.eql(O,i.ONE))return{x:I,y:R};let F=P.is0();if(N==null)N=F?i.ONE:i.inv(O);let L=i.mul(I,N),V=i.mul(R,N),_=i.mul(O,N);if(F)return{x:i.ZERO,y:i.ZERO};if(!i.eql(_,i.ONE))throw Error("invZ was invalid");return{x:L,y:V}}),Z=PT((P)=>{if(P.is0()){if(t.allowInfinityPoint&&!i.is0(P.Y))return;throw Error("bad point: ZERO")}let{x:N,y:I}=P.toAffine();if(!i.isValid(N)||!i.isValid(I))throw Error("bad point: x or y not field elements");if(!b(N,I))throw Error("bad point: equation left != right");if(!P.isTorsionFree())throw Error("bad point: not in prime-order subgroup");return!0});function D(P,N,I,R,O){return I=new H(i.mul(I.X,P),I.Y,I.Z),N=Rf(R,N),I=Rf(O,I),N.add(I)}class H{static BASE=new H(o.Gx,o.Gy,i.ONE);static ZERO=new H(i.ZERO,i.ONE,i.ZERO);static Fp=i;static Fn=n;X;Y;Z;constructor(P,N,I){this.X=T("x",P),this.Y=T("y",N,!0),this.Z=T("z",I),Object.freeze(this)}static CURVE(){return o}static fromAffine(P){let{x:N,y:I}=P||{};if(!P||!i.isValid(N)||!i.isValid(I))throw Error("invalid affine point");if(P instanceof H)throw Error("projective point not allowed");if(i.is0(N)&&i.is0(I))return H.ZERO;return new H(N,I,i.ONE)}static fromBytes(P){let N=H.fromAffine(y(Ne(P,void 0,"point")));return N.assertValidity(),N}static fromHex(P){return H.fromBytes(ba(P))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(P=8,N=!0){if(M.createCache(this,P),!N)this.multiply(ib);return this}assertValidity(){Z(this)}hasEvenY(){let{y:P}=this.toAffine();if(!i.isOdd)throw Error("Field doesn't support isOdd");return!i.isOdd(P)}equals(P){z(P);let{X:N,Y:I,Z:R}=this,{X:O,Y:F,Z:L}=P,V=i.eql(i.mul(N,L),i.mul(O,R)),_=i.eql(i.mul(I,L),i.mul(F,R));return V&&_}negate(){return new H(this.X,i.neg(this.Y),this.Z)}double(){let{a:P,b:N}=o,I=i.mul(N,ib),{X:R,Y:O,Z:F}=this,L=i.ZERO,V=i.ZERO,_=i.ZERO,te=i.mul(R,R),ue=i.mul(O,O),C=i.mul(F,F),Se=i.mul(R,O);return Se=i.add(Se,Se),_=i.mul(R,F),_=i.add(_,_),L=i.mul(P,_),V=i.mul(I,C),V=i.add(L,V),L=i.sub(ue,V),V=i.add(ue,V),V=i.mul(L,V),L=i.mul(Se,L),_=i.mul(I,_),C=i.mul(P,C),Se=i.sub(te,C),Se=i.mul(P,Se),Se=i.add(Se,_),_=i.add(te,te),te=i.add(_,te),te=i.add(te,C),te=i.mul(te,Se),V=i.add(V,te),C=i.mul(O,F),C=i.add(C,C),te=i.mul(C,Se),L=i.sub(L,te),_=i.mul(C,ue),_=i.add(_,_),_=i.add(_,_),new H(L,V,_)}add(P){z(P);let{X:N,Y:I,Z:R}=this,{X:O,Y:F,Z:L}=P,V=i.ZERO,_=i.ZERO,te=i.ZERO,ue=o.a,C=i.mul(o.b,ib),Se=i.mul(N,O),Ee=i.mul(I,F),$e=i.mul(R,L),Ce=i.add(N,I),_e=i.add(O,F);Ce=i.mul(Ce,_e),_e=i.add(Se,Ee),Ce=i.sub(Ce,_e),_e=i.add(N,R);let ze=i.add(O,L);return _e=i.mul(_e,ze),ze=i.add(Se,$e),_e=i.sub(_e,ze),ze=i.add(I,R),V=i.add(F,L),ze=i.mul(ze,V),V=i.add(Ee,$e),ze=i.sub(ze,V),te=i.mul(ue,_e),V=i.mul(C,$e),te=i.add(V,te),V=i.sub(Ee,te),te=i.add(Ee,te),_=i.mul(V,te),Ee=i.add(Se,Se),Ee=i.add(Ee,Se),$e=i.mul(ue,$e),_e=i.mul(C,_e),Ee=i.add(Ee,$e),$e=i.sub(Se,$e),$e=i.mul(ue,$e),_e=i.add(_e,$e),Se=i.mul(Ee,_e),_=i.add(_,Se),Se=i.mul(ze,_e),V=i.mul(Ce,V),V=i.sub(V,Se),Se=i.mul(Ce,Ee),te=i.mul(ze,te),te=i.add(te,Se),new H(V,_,te)}subtract(P){return this.add(P.negate())}is0(){return this.equals(H.ZERO)}multiply(P){let{endo:N}=t;if(!n.isValidNot0(P))throw Error("invalid scalar: out of range");let I,R,O=(F)=>M.cached(this,F,(L)=>qT(H,L));if(N){let{k1neg:F,k1:L,k2neg:V,k2:_}=j(P),{p:te,f:ue}=O(L),{p:C,f:Se}=O(_);R=ue.add(Se),I=D(N.beta,te,C,F,V)}else{let{p:F,f:L}=O(P);I=F,R=L}return qT(H,[I,R])[0]}multiplyUnsafe(P){let{endo:N}=t,I=this;if(!n.isValid(P))throw Error("invalid scalar: out of range");if(P===Vi||I.is0())return H.ZERO;if(P===Pl)return I;if(M.hasCache(this))return this.multiply(P);if(N){let{k1neg:R,k1:O,k2neg:F,k2:L}=j(P),{p1:V,p2:_}=n3(H,I,O,L);return D(N.beta,V,_,R,F)}else return M.unsafe(I,P)}toAffine(P){return E(this,P)}isTorsionFree(){let{isTorsionFree:P}=t;if(s===Pl)return!0;if(P)return P(H,this);return M.unsafe(this,a).is0()}clearCofactor(){let{clearCofactor:P}=t;if(s===Pl)return this;if(P)return P(H,this);return this.multiplyUnsafe(s)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}toBytes(P=!0){return If(P,"isCompressed"),this.assertValidity(),m(H,this,P)}toHex(P=!0){return ya(this.toBytes(P))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let X=n.BITS,M=new UT(H,t.endo?Math.ceil(X/2):X);return H.BASE.precompute(8),H}function l3(e){return Uint8Array.of(e?2:3)}function u3(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function xbe(e,t={}){let{Fn:r}=e,i=t.randomBytes||es,n=Object.assign(u3(e.Fp,r),{seed:DT(r.ORDER)});function o(m){try{let y=r.fromBytes(m);return r.isValidNot0(y)}catch(y){return!1}}function s(m,y){let{publicKey:g,publicKeyUncompressed:b}=n;try{let v=m.length;if(y===!0&&v!==g)return!1;if(y===!1&&v!==b)return!1;return!!e.fromBytes(m)}catch(v){return!1}}function a(m=i(n.seed)){return QZ(Ne(m,n.seed,"seed"),r.ORDER)}function c(m,y=!0){return e.BASE.multiply(r.fromBytes(m)).toBytes(y)}function l(m){let{secretKey:y,publicKey:g,publicKeyUncompressed:b}=n;if(!Al(m))return;if("_lengths"in r&&r._lengths||y===g)return;let v=Ne(m,void 0,"key").length;return v===g||v===b}function u(m,y,g=!0){if(l(m)===!0)throw Error("first arg must be private key");if(l(y)===!1)throw Error("second arg must be public key");let b=r.fromBytes(m);return e.fromBytes(y).multiply(b).toBytes(g)}let d={isValidSecretKey:o,isValidPublicKey:s,randomSecretKey:a},p=rb(a,c);return Object.freeze({getPublicKey:c,getSharedSecret:u,keygen:p,Point:e,utils:d,lengths:n})}function KT(e,t,r={}){_n(t),xa(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),r=Object.assign({},r);let i=r.randomBytes||es,n=r.hmac||((I,R)=>Rl(t,I,R)),{Fp:o,Fn:s}=e,{ORDER:a,BITS:c}=s,{keygen:l,getPublicKey:u,getSharedSecret:d,utils:p,lengths:m}=xbe(e,r),y={prehash:!0,lowS:typeof r.lowS==="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},g=a*c3<o.ORDER;function b(I){let R=a>>Pl;return I>R}function v(I,R){if(!s.isValidNot0(R))throw Error(`invalid signature ${I}: out of range 1..Point.Fn.ORDER`);return R}function A(){if(g)throw Error('"recovered" sig type is not supported for cofactor >2 curves')}function T(I,R){ZT(R);let O=m.signature,F=R==="compact"?O:R==="recovered"?O+1:void 0;return Ne(I,F)}class z{r;s;recovery;constructor(I,R,O){if(this.r=v("r",I),this.s=v("s",R),O!=null){if(A(),![0,1,2,3].includes(O))throw Error("invalid recovery id");this.recovery=O}Object.freeze(this)}static fromBytes(I,R=y.format){T(I,R);let O;if(R==="der"){let{r:_,s:te}=os.toSig(Ne(I));return new z(_,te)}if(R==="recovered")O=I[0],R="compact",I=I.subarray(1);let F=m.signature/2,L=I.subarray(0,F),V=I.subarray(F,F*2);return new z(s.fromBytes(L),s.fromBytes(V),O)}static fromHex(I,R){return this.fromBytes(ba(I),R)}assertRecovery(){let{recovery:I}=this;if(I==null)throw Error("invalid recovery id: must be present");return I}addRecoveryBit(I){return new z(this.r,this.s,I)}recoverPublicKey(I){let{r:R,s:O}=this,F=this.assertRecovery(),L=F===2||F===3?R+a:R;if(!o.isValid(L))throw Error("invalid recovery id: sig.r+curve.n != R.x");let V=o.toBytes(L),_=e.fromBytes(qt(l3((F&1)===0),V)),te=s.inv(L),ue=E(Ne(I,void 0,"msgHash")),C=s.create(-ue*te),Se=s.create(O*te),Ee=e.BASE.multiplyUnsafe(C).add(_.multiplyUnsafe(Se));if(Ee.is0())throw Error("invalid recovery: point at infinify");return Ee.assertValidity(),Ee}hasHighS(){return b(this.s)}toBytes(I=y.format){if(ZT(I),I==="der")return ba(os.hexFromSig(this));let{r:R,s:O}=this,F=s.toBytes(R),L=s.toBytes(O);if(I==="recovered")return A(),qt(Uint8Array.of(this.assertRecovery()),F,L);return qt(F,L)}toHex(I){return ya(this.toBytes(I))}}let j=r.bits2int||function(R){if(R.length>8192)throw Error("input is too large");let O=rs(R),F=R.length*8-c;return F>0?O>>BigInt(F):O},E=r.bits2int_modN||function(R){return s.create(j(R))},Z=$f(c);function D(I){return Cf("num < 2^"+c,I,Vi,Z),s.toBytes(I)}function H(I,R){return Ne(I,void 0,"message"),R?Ne(t(I),void 0,"prehashed message"):I}function X(I,R,O){let{lowS:F,prehash:L,extraEntropy:V}=FT(O,y);I=H(I,L);let _=E(I),te=s.fromBytes(R);if(!s.isValidNot0(te))throw Error("invalid private key");let ue=[D(te),D(_)];if(V!=null&&V!==!1){let $e=V===!0?i(m.secretKey):V;ue.push(Ne($e,void 0,"extraEntropy"))}let C=qt(...ue),Se=_;function Ee($e){let Ce=j($e);if(!s.isValidNot0(Ce))return;let _e=s.inv(Ce),ze=e.BASE.multiply(Ce).toAffine(),Ve=s.create(ze.x);if(Ve===Vi)return;let Xe=s.create(_e*s.create(Se+Ve*te));if(Xe===Vi)return;let St=(ze.x===Ve?0:2)|Number(ze.y&Pl),Lt=Xe;if(F&&b(Xe))Lt=s.neg(Xe),St^=1;return new z(Ve,Lt,g?void 0:St)}return{seed:C,k2sig:Ee}}function M(I,R,O={}){let{seed:F,k2sig:L}=X(I,R,O);return jZ(t.outputLen,s.BYTES,n)(F,L).toBytes(O.format)}function P(I,R,O,F={}){let{lowS:L,prehash:V,format:_}=FT(F,y);if(O=Ne(O,void 0,"publicKey"),R=H(R,V),!Al(I)){let te=I instanceof z?", use sig.toBytes()":"";throw Error("verify expects Uint8Array signature"+te)}T(I,_);try{let te=z.fromBytes(I,_),ue=e.fromBytes(O);if(L&&te.hasHighS())return!1;let{r:C,s:Se}=te,Ee=E(R),$e=s.inv(Se),Ce=s.create(Ee*$e),_e=s.create(C*$e),ze=e.BASE.multiplyUnsafe(Ce).add(ue.multiplyUnsafe(_e));if(ze.is0())return!1;return s.create(ze.x)===C}catch(te){return!1}}function N(I,R,O={}){let{prehash:F}=FT(O,y);return R=H(R,F),z.fromBytes(I,"recovered").recoverPublicKey(R).toBytes()}return Object.freeze({keygen:l,getPublicKey:u,getSharedSecret:d,utils:p,lengths:m,Point:e,sign:M,verify:P,recoverPublicKey:N,Signature:z,hash:t})}function d3(e,t,r){return e&t^~e&r}function f3(e,t,r){return e&t^e&r^t&r}class ob{blockLen;outputLen;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,t,r,i){this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=i,this.buffer=new Uint8Array(e),this.view=Yy(this.buffer)}update(e){Ji(this),Ne(e);let{view:t,buffer:r,blockLen:i}=this,n=e.length;for(let o=0;o<n;){let s=Math.min(i-this.pos,n-o);if(s===i){let a=Yy(e);for(;i<=n-o;o+=i)this.process(a,o);continue}if(r.set(e.subarray(o,o+s),this.pos),this.pos+=s,o+=s,this.pos===i)this.process(t,0),this.pos=0}return this.length+=e.length,this.roundClean(),this}digestInto(e){Ji(this),Gy(e,this),this.finished=!0;let{buffer:t,view:r,blockLen:i,isLE:n}=this,{pos:o}=this;if(t[o++]=128,Vr(this.buffer.subarray(o)),this.padOffset>i-o)this.process(r,0),o=0;for(let u=o;u<i;u++)t[u]=0;r.setBigUint64(i-8,BigInt(this.length*8),n),this.process(r,0);let s=Yy(e),a=this.outputLen;if(a%4)throw Error("_sha2: outputLen must be aligned to 32bit");let c=a/4,l=this.get();if(c>l.length)throw Error("_sha2: outputLen bigger than state");for(let u=0;u<c;u++)s.setUint32(4*u,l[u],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:i,finished:n,destroyed:o,pos:s}=this;if(e.destroyed=o,e.finished=n,e.length=i,e.pos=s,i%t)e.buffer.set(r);return e}clone(){return this._cloneInto()}}var Wi=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var cr=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]);var sb=BigInt(4294967295),p3=BigInt(32);function Sbe(e,t=!1){if(t)return{h:Number(e&sb),l:Number(e>>p3&sb)};return{h:Number(e>>p3&sb)|0,l:Number(e&sb)|0}}function ab(e,t=!1){let r=e.length,i=new Uint32Array(r),n=new Uint32Array(r);for(let o=0;o<r;o++){let{h:s,l:a}=Sbe(e[o],t);[i[o],n[o]]=[s,a]}return[i,n]}var JT=(e,t,r)=>e>>>r,VT=(e,t,r)=>e<<32-r|t>>>r,va=(e,t,r)=>e>>>r|t<<32-r,_a=(e,t,r)=>e<<32-r|t>>>r,zf=(e,t,r)=>e<<64-r|t>>>r-32,Nf=(e,t,r)=>e>>>r-32|t<<64-r;var m3=(e,t,r)=>e<<r|t>>>32-r,h3=(e,t,r)=>t<<r|e>>>32-r,g3=(e,t,r)=>t<<r-32|e>>>64-r,y3=(e,t,r)=>e<<r-32|t>>>64-r;function fi(e,t,r,i){let n=(t>>>0)+(i>>>0);return{h:e+r+(n/4294967296|0)|0,l:n|0}}var b3=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),x3=(e,t,r,i)=>t+r+i+(e/4294967296|0)|0,S3=(e,t,r,i)=>(e>>>0)+(t>>>0)+(r>>>0)+(i>>>0),w3=(e,t,r,i,n)=>t+r+i+n+(e/4294967296|0)|0,v3=(e,t,r,i,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(i>>>0)+(n>>>0),_3=(e,t,r,i,n,o)=>t+r+i+n+o+(e/4294967296|0)|0;var vbe=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]),ss=new Uint32Array(64);class k3 extends ob{constructor(e){super(64,e,8,!1)}get(){let{A:e,B:t,C:r,D:i,E:n,F:o,G:s,H:a}=this;return[e,t,r,i,n,o,s,a]}set(e,t,r,i,n,o,s,a){this.A=e|0,this.B=t|0,this.C=r|0,this.D=i|0,this.E=n|0,this.F=o|0,this.G=s|0,this.H=a|0}process(e,t){for(let u=0;u<16;u++,t+=4)ss[u]=e.getUint32(t,!1);for(let u=16;u<64;u++){let d=ss[u-15],p=ss[u-2],m=Fn(d,7)^Fn(d,18)^d>>>3,y=Fn(p,17)^Fn(p,19)^p>>>10;ss[u]=y+ss[u-7]+m+ss[u-16]|0}let{A:r,B:i,C:n,D:o,E:s,F:a,G:c,H:l}=this;for(let u=0;u<64;u++){let d=Fn(s,6)^Fn(s,11)^Fn(s,25),p=l+d+d3(s,a,c)+vbe[u]+ss[u]|0,y=(Fn(r,2)^Fn(r,13)^Fn(r,22))+f3(r,i,n)|0;l=c,c=a,a=s,s=o+p|0,o=n,n=i,i=r,r=p+y|0}r=r+this.A|0,i=i+this.B|0,n=n+this.C|0,o=o+this.D|0,s=s+this.E|0,a=a+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(r,i,n,o,s,a,c,l)}roundClean(){Vr(ss)}destroy(){this.set(0,0,0,0,0,0,0,0),Vr(this.buffer)}}class E3 extends k3{A=Wi[0]|0;B=Wi[1]|0;C=Wi[2]|0;D=Wi[3]|0;E=Wi[4]|0;F=Wi[5]|0;G=Wi[6]|0;H=Wi[7]|0;constructor(){super(32)}}var I3=(()=>ab(["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))))(),_be=(()=>I3[0])(),kbe=(()=>I3[1])(),as=new Uint32Array(80),cs=new Uint32Array(80);class A3 extends ob{constructor(e){super(128,e,16,!1)}get(){let{Ah:e,Al:t,Bh:r,Bl:i,Ch:n,Cl:o,Dh:s,Dl:a,Eh:c,El:l,Fh:u,Fl:d,Gh:p,Gl:m,Hh:y,Hl:g}=this;return[e,t,r,i,n,o,s,a,c,l,u,d,p,m,y,g]}set(e,t,r,i,n,o,s,a,c,l,u,d,p,m,y,g){this.Ah=e|0,this.Al=t|0,this.Bh=r|0,this.Bl=i|0,this.Ch=n|0,this.Cl=o|0,this.Dh=s|0,this.Dl=a|0,this.Eh=c|0,this.El=l|0,this.Fh=u|0,this.Fl=d|0,this.Gh=p|0,this.Gl=m|0,this.Hh=y|0,this.Hl=g|0}process(e,t){for(let A=0;A<16;A++,t+=4)as[A]=e.getUint32(t),cs[A]=e.getUint32(t+=4);for(let A=16;A<80;A++){let T=as[A-15]|0,z=cs[A-15]|0,j=va(T,z,1)^va(T,z,8)^JT(T,z,7),E=_a(T,z,1)^_a(T,z,8)^VT(T,z,7),Z=as[A-2]|0,D=cs[A-2]|0,H=va(Z,D,19)^zf(Z,D,61)^JT(Z,D,6),X=_a(Z,D,19)^Nf(Z,D,61)^VT(Z,D,6),M=S3(E,X,cs[A-7],cs[A-16]),P=w3(M,j,H,as[A-7],as[A-16]);as[A]=P|0,cs[A]=M|0}let{Ah:r,Al:i,Bh:n,Bl:o,Ch:s,Cl:a,Dh:c,Dl:l,Eh:u,El:d,Fh:p,Fl:m,Gh:y,Gl:g,Hh:b,Hl:v}=this;for(let A=0;A<80;A++){let T=va(u,d,14)^va(u,d,18)^zf(u,d,41),z=_a(u,d,14)^_a(u,d,18)^Nf(u,d,41),j=u&p^~u&y,E=d&m^~d&g,Z=v3(v,z,E,kbe[A],cs[A]),D=_3(Z,b,T,j,_be[A],as[A]),H=Z|0,X=va(r,i,28)^zf(r,i,34)^zf(r,i,39),M=_a(r,i,28)^Nf(r,i,34)^Nf(r,i,39),P=r&n^r&s^n&s,N=i&o^i&a^o&a;b=y|0,v=g|0,y=p|0,g=m|0,p=u|0,m=d|0,{h:u,l:d}=fi(c|0,l|0,D|0,H|0),c=s|0,l=a|0,s=n|0,a=o|0,n=r|0,o=i|0;let I=b3(H,M,N);r=x3(I,D,X,P),i=I|0}({h:r,l:i}=fi(this.Ah|0,this.Al|0,r|0,i|0)),{h:n,l:o}=fi(this.Bh|0,this.Bl|0,n|0,o|0),{h:s,l:a}=fi(this.Ch|0,this.Cl|0,s|0,a|0),{h:c,l}=fi(this.Dh|0,this.Dl|0,c|0,l|0),{h:u,l:d}=fi(this.Eh|0,this.El|0,u|0,d|0),{h:p,l:m}=fi(this.Fh|0,this.Fl|0,p|0,m|0),{h:y,l:g}=fi(this.Gh|0,this.Gl|0,y|0,g|0),{h:b,l:v}=fi(this.Hh|0,this.Hl|0,b|0,v|0),this.set(r,i,n,o,s,a,c,l,u,d,p,m,y,g,b,v)}roundClean(){Vr(as,cs)}destroy(){Vr(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class T3 extends A3{Ah=cr[0]|0;Al=cr[1]|0;Bh=cr[2]|0;Bl=cr[3]|0;Ch=cr[4]|0;Cl=cr[5]|0;Dh=cr[6]|0;Dl=cr[7]|0;Eh=cr[8]|0;El=cr[9]|0;Fh=cr[10]|0;Fl=cr[11]|0;Gh=cr[12]|0;Gl=cr[13]|0;Hh=cr[14]|0;Hl=cr[15]|0;constructor(){super(48)}}var cb=Tl(()=>new E3,ts(1));var C3=Tl(()=>new T3,ts(2));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var Ebe=BigInt(1),$3=BigInt(2),Ibe=BigInt(3),Abe=BigInt(5),ZFe=BigInt(8),O3=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed");function Tbe(e){let t=BigInt(10),r=BigInt(20),i=BigInt(40),n=BigInt(80),o=O3,a=e*e%o*e%o,c=kn(a,$3,o)*a%o,l=kn(c,Ebe,o)*e%o,u=kn(l,Abe,o)*l%o,d=kn(u,t,o)*u%o,p=kn(d,r,o)*d%o,m=kn(p,i,o)*p%o,y=kn(m,n,o)*m%o,g=kn(y,n,o)*m%o,b=kn(g,t,o)*u%o;return{pow_p_5_8:kn(b,$3,o)*e%o,b2:a}}function Cbe(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var R3=(()=>{let e=O3;return o3({P:e,type:"x25519",powPminus2:(t)=>{let{pow_p_5_8:r,b2:i}=Tbe(t);return Br(kn(r,Ibe,e)*i,e)},adjustScalarBytes:Cbe})})();/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var $be=(()=>({p:BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),h:BigInt(1),a:BigInt("0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc"),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")}))(),Obe=(()=>({p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff"),n:BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973"),h:BigInt(1),a:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000fffffffc"),b:BigInt("0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef"),Gx:BigInt("0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7"),Gy:BigInt("0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f")}))();var Rbe=HT($be),WT=KT(Rbe,cb);var Pbe=HT(Obe),P3=KT(Pbe,C3);function N3(e,t,r){if(_n(e),r===void 0)r=new Uint8Array(e.outputLen);return Rl(e,r,t)}var GT=Uint8Array.of(0),z3=Uint8Array.of();function D3(e,t,r,i=32){_n(e),Yt(i,"length");let n=e.outputLen;if(i>255*n)throw Error("Length must be <= 255*HashLen");let o=Math.ceil(i/n);if(r===void 0)r=z3;else Ne(r,void 0,"info");let s=new Uint8Array(o*n),a=Rl.create(e,t),c=a._cloneInto(),l=new Uint8Array(a.outputLen);for(let u=0;u<o;u++)GT[0]=u+1,c.update(u===0?z3:l).update(r).update(GT).digestInto(l),s.set(l,n*u),a._cloneInto(c);return a.destroy(),c.destroy(),Vr(l,GT),s.slice(0,i)}var zbe=BigInt(0),Df=BigInt(1),Nbe=BigInt(2),Dbe=BigInt(7),Lbe=BigInt(256),Bbe=BigInt(113),j3=[],q3=[],U3=[];for(let e=0,t=Df,r=1,i=0;e<24;e++){[r,i]=[i,(2*r+3*i)%5],j3.push(2*(5*i+r)),q3.push((e+1)*(e+2)/2%64);let n=zbe;for(let o=0;o<7;o++)if(t=(t<<Df^(t>>Dbe)*Bbe)%Lbe,t&Nbe)n^=Df<<(Df<<BigInt(o))-Df;U3.push(n)}var M3=ab(U3,!0),jbe=M3[0],qbe=M3[1],L3=(e,t,r)=>r>32?g3(e,t,r):m3(e,t,r),B3=(e,t,r)=>r>32?y3(e,t,r):h3(e,t,r);function Ube(e,t=24){let r=new Uint32Array(10);for(let i=24-t;i<24;i++){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,l=r[c],u=r[c+1],d=L3(l,u,1)^r[a],p=B3(l,u,1)^r[a+1];for(let m=0;m<50;m+=10)e[s+m]^=d,e[s+m+1]^=p}let n=e[2],o=e[3];for(let s=0;s<24;s++){let a=q3[s],c=L3(n,o,a),l=B3(n,o,a),u=j3[s];n=e[u],o=e[u+1],e[u]=c,e[u+1]=l}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]^=jbe[i],e[1]^=qbe[i]}Vr(r)}class lb{state;pos=0;posOut=0;finished=!1;state32;destroyed=!1;blockLen;suffix;outputLen;enableXOF=!1;rounds;constructor(e,t,r,i=!1,n=24){if(this.blockLen=e,this.suffix=t,this.outputLen=r,this.enableXOF=i,this.rounds=n,Yt(r,"outputLen"),!(0<e&&e<200))throw Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=Qy(this.state)}clone(){return this._cloneInto()}keccak(){CT(this.state32),Ube(this.state32,this.rounds),CT(this.state32),this.posOut=0,this.pos=0}update(e){Ji(this),Ne(e);let{blockLen:t,state:r}=this,i=e.length;for(let n=0;n<i;){let o=Math.min(t-this.pos,i-n);for(let s=0;s<o;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:i}=this;if(e[r]^=t,(t&128)!==0&&r===i-1)this.keccak();e[i-1]^=128,this.keccak()}writeInto(e){Ji(this,!1),Ne(e),this.finish();let t=this.state,{blockLen:r}=this;for(let i=0,n=e.length;i<n;){if(this.posOut>=r)this.keccak();let o=Math.min(r-this.posOut,n-i);e.set(t.subarray(this.posOut,this.posOut+o),i),this.posOut+=o,i+=o}return e}xofInto(e){if(!this.enableXOF)throw Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return Yt(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Gy(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,Vr(this.state)}_cloneInto(e){let{blockLen:t,suffix:r,outputLen:i,rounds:n,enableXOF:o}=this;return e||=new lb(t,r,i,o,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=i,e.enableXOF=o,e.destroyed=this.destroyed,e}}var F3=(e,t,r,i={})=>Tl(()=>new lb(t,e,r),i);var ka=F3(6,136,32,ts(8));var Z3=F3(6,72,64,ts(10));var H3=(e,t,r,i={})=>Tl((n={})=>new lb(t,e,n.dkLen===void 0?r:n.dkLen,!0),i),K3=H3(31,168,16,ts(11)),pi=H3(31,136,32,ts(12));function QT(e){if(!Number.isSafeInteger(e)||e<0||e>4294967295)throw Error("wrong u32 integer:"+e);return e}function V3(e){return QT(e),(e&e-1)===0&&e!==0}function YT(e,t){QT(e);let r=0;for(let i=0;i<t;i++,e>>>=1)r=r<<1|e&1;return r}function W3(e){return QT(e),31-Math.clz32(e)}function J3(e){let t=e.length;if(t<2||!V3(t))throw Error("n must be a power of 2 and greater than 1. Got "+t);let r=W3(t);for(let i=0;i<t;i++){let n=YT(i,r);if(i<n){let o=e[i];e[i]=e[n],e[n]=o}}return e}var XT=(e,t)=>{let{N:r,roots:i,dit:n,invertButterflies:o=!1,skipStages:s=0,brp:a=!0}=t,c=W3(r);if(!V3(r))throw Error("FFT: Polynomial size should be power of two");let l=n!==o;return(u)=>{if(u.length!==r)throw Error("FFT: wrong Polynomial length");if(n&&a)J3(u);for(let d=0,p=1;d<c-s;d++){let m=n?d+1+s:c-d,y=1<<m,g=y>>1,b=r>>m;for(let v=0;v<r;v+=y)for(let A=0,T=p++;A<g;A++){let z=o?n?r-T:T:A*b,j=v+A,E=v+A+g,Z=i[z],D=u[E],H=u[j];if(l){let X=e.mul(D,Z);u[j]=e.add(H,X),u[E]=e.sub(H,X)}else if(o)u[j]=e.add(D,H),u[E]=e.mul(e.sub(D,H),Z);else u[j]=e.add(H,D),u[E]=e.mul(e.sub(H,D),Z)}}if(!n&&a)J3(u);return u}};/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */var mi=es;function ub(e,t){if(e.length!==t.length)return!1;let r=0;for(let i=0;i<e.length;i++)r|=e[i]^t[i];return r===0}function G3(e){return Uint8Array.from(e)}function Ea(e,...t){let r=(n)=>typeof n==="number"?n:n.bytesLen,i=t.reduce((n,o)=>n+r(o),0);return{bytesLen:i,encode:(n)=>{let o=new Uint8Array(i);for(let s=0,a=0;s<t.length;s++){let c=t[s],l=r(c),u=typeof c==="number"?n[s]:c.encode(n[s]);if(Ne(u,l,e),o.set(u,a),typeof c!=="number")u.fill(0);a+=l}return o},decode:(n)=>{Ne(n,i,e);let o=[];for(let s of t){let a=r(s),c=n.subarray(0,a);o.push(typeof s==="number"?c:s.decode(c)),n=n.subarray(a)}return o}}}function db(e,t){let r=t*e.bytesLen;return{bytesLen:r,encode:(i)=>{if(i.length!==t)throw Error(`vecCoder.encode: wrong length=${i.length}. Expected: ${t}`);let n=new Uint8Array(r);for(let o=0,s=0;o<i.length;o++){let a=e.encode(i[o]);n.set(a,s),a.fill(0),s+=a.length}return n},decode:(i)=>{Ne(i,r);let n=[];for(let o=0;o<i.length;o+=e.bytesLen)n.push(e.decode(i.subarray(o,o+e.bytesLen)));return n}}}function Kt(...e){for(let t of e)if(Array.isArray(t))for(let r of t)r.fill(0);else t.fill(0)}function eC(e){return(1<<e)-1}var oZe=Uint8Array.of();/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */var Q3=(e)=>{let{newPoly:t,N:r,Q:i,F:n,ROOT_OF_UNITY:o,brvBits:s,isKyber:a}=e,c=(A,T=i)=>{let z=A%T|0;return(z>=0?z|0:T+z|0)|0},l=(A,T=i)=>{let z=c(A,T)|0;return(z>T>>1?z-T|0:z)|0};function u(){let A=t(r);for(let T=0;T<r;T++){let z=YT(T,s),j=BigInt(o)**BigInt(z)%BigInt(i);A[T]=Number(j)|0}return A}let d=u(),p={add:(A,T)=>c((A|0)+(T|0))|0,sub:(A,T)=>c((A|0)-(T|0))|0,mul:(A,T)=>c((A|0)*(T|0))|0,inv:(A)=>{throw Error("not implemented")}},m={N:r,roots:d,invertButterflies:!0,skipStages:a?1:0,brp:!1},y=XT(p,{dit:!1,...m}),g=XT(p,{dit:!0,...m});return{mod:c,smod:l,nttZetas:d,NTT:{encode:(A)=>y(A),decode:(A)=>{g(A);for(let T=0;T<A.length;T++)A[T]=c(n*A[T]);return A}},bitsCoder:(A,T)=>{let z=eC(A),j=A*(r/8);return{bytesLen:j,encode:(E)=>{let Z=new Uint8Array(j);for(let D=0,H=0,X=0,M=0;D<E.length;D++){H|=(T.encode(E[D])&z)<<X,X+=A;for(;X>=8;X-=8,H>>=8)Z[M++]=H&eC(X)}return Z},decode:(E)=>{let Z=t(r);for(let D=0,H=0,X=0,M=0;D<E.length;D++){H|=E[D]<<X,X+=8;for(;X>=A;X-=A,H>>=A)Z[M++]=T.decode(H&z)}return Z}}}}},Mbe=(e)=>(t,r)=>{if(!r)r=e.blockLen;let i=new Uint8Array(t.length+2);i.set(t);let n=t.length,o=new Uint8Array(r),s=e.create({}),a=0,c=0;return{stats:()=>({calls:a,xofs:c}),get:(l,u)=>(i[n+0]=l,i[n+1]=u,s.destroy(),s=e.create({}).update(i),a++,()=>(c++,s.xofInto(o))),clean:()=>{s.destroy(),Kt(o,i)}}},Y3=Mbe(K3);/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */var _r=256,Gi=3329,Fbe=3303,Zbe=17,{mod:jf,nttZetas:Hbe,NTT:Ia,bitsCoder:Kbe}=Q3({N:_r,Q:Gi,F:Fbe,ROOT_OF_UNITY:Zbe,newPoly:(e)=>new Uint16Array(e),brvBits:7,isKyber:!0}),tC={512:{N:_r,Q:Gi,K:2,ETA1:3,ETA2:2,du:10,dv:4,RBGstrength:128},768:{N:_r,Q:Gi,K:3,ETA1:2,ETA2:2,du:10,dv:4,RBGstrength:192},1024:{N:_r,Q:Gi,K:4,ETA1:2,ETA2:2,du:11,dv:5,RBGstrength:256}},Jbe=(e)=>{if(e>=12)return{encode:(r)=>r,decode:(r)=>r};let t=2**(e-1);return{encode:(r)=>((r<<e)+Gi/2)/Gi,decode:(r)=>r*Gi+t>>>e}},Lf=(e)=>Kbe(e,Jbe(e));function Aa(e,t){for(let r=0;r<_r;r++)e[r]=jf(e[r]+t[r])}function Vbe(e,t){for(let r=0;r<_r;r++)e[r]=jf(e[r]-t[r])}function Wbe(e,t,r,i,n){let o=jf(t*i*n+e*r),s=jf(e*i+t*r);return{c0:o,c1:s}}function fb(e,t){for(let r=0;r<_r/2;r++){let i=Hbe[64+(r>>1)];if(r&1)i=-i;let{c0:n,c1:o}=Wbe(e[2*r+0],e[2*r+1],t[2*r+0],t[2*r+1],i);e[2*r+0]=n,e[2*r+1]=o}return e}function X3(e){let t=new Uint16Array(_r);for(let r=0;r<_r;){let i=e();if(i.length%3)throw Error("SampleNTT: unaligned block");for(let n=0;r<_r&&n+3<=i.length;n+=3){let o=(i[n+0]>>0|i[n+1]<<8)&4095,s=(i[n+1]>>4|i[n+2]<<4)&4095;if(o<Gi)t[r++]=o;if(r<_r&&s<Gi)t[r++]=s}}return t}function Bf(e,t,r,i){let n=e(i*_r/4,t,r),o=new Uint16Array(_r),s=Qy(n),a=0;for(let c=0,l=0,u=0,d=0;c<s.length;c++){let p=s[c];for(let m=0;m<32;m++)if(u+=p&1,p>>=1,a+=1,a===i)d=u,u=0;else if(a===2*i)o[l++]=jf(d-u),u=0,a=0}if(a)throw Error(`sampleCBD: leftover bits: ${a}`);return o}var Gbe=(e)=>{let{K:t,PRF:r,XOF:i,HASH512:n,ETA1:o,ETA2:s,du:a,dv:c}=e,l=Lf(1),u=Lf(c),d=Lf(a),p=Ea("publicKey",db(Lf(12),t),32),m=db(Lf(12),t),y=Ea("ciphertext",db(d,t),u),g=Ea("seed",32,32);return{secretCoder:m,lengths:{secretKey:m.bytesLen,publicKey:p.bytesLen,cipherText:y.bytesLen},keygen:(b)=>{Ne(b,32,"seed");let v=new Uint8Array(33);v.set(b),v[32]=t;let A=n(v),[T,z]=g.decode(A),j=[],E=[];for(let H=0;H<t;H++)j.push(Ia.encode(Bf(r,z,H,o)));let Z=i(T);for(let H=0;H<t;H++){let X=Ia.encode(Bf(r,z,t+H,o));for(let M=0;M<t;M++){let P=X3(Z.get(M,H));Aa(X,fb(P,j[M]))}E.push(X)}Z.clean();let D={publicKey:p.encode([E,T]),secretKey:m.encode(j)};return Kt(T,z,j,E,v,A),D},encrypt:(b,v,A)=>{let[T,z]=p.decode(b),j=[];for(let M=0;M<t;M++)j.push(Ia.encode(Bf(r,A,M,o)));let E=i(z),Z=new Uint16Array(_r),D=[];for(let M=0;M<t;M++){let P=Bf(r,A,t+M,s),N=new Uint16Array(_r);for(let I=0;I<t;I++){let R=X3(E.get(M,I));Aa(N,fb(R,j[I]))}Aa(P,Ia.decode(N)),D.push(P),Aa(Z,fb(T[M],j[M])),Kt(N)}E.clean();let H=Bf(r,A,2*t,s);Aa(H,Ia.decode(Z));let X=l.decode(v);return Aa(X,H),Kt(T,j,Z,H),y.encode([D,X])},decrypt:(b,v)=>{let[A,T]=y.decode(b),z=m.decode(v),j=new Uint16Array(_r);for(let E=0;E<t;E++)Aa(j,fb(z[E],Ia.encode(A[E])));return Vbe(T,Ia.decode(j)),Kt(j,z,A),l.encode(T)}}};function rC(e){let t=Gbe(e),{HASH256:r,HASH512:i,KDF:n}=e,{secretCoder:o,lengths:s}=t,a=Ea("secretKey",s.secretKey,s.publicKey,32,32),c=32,l=64;return{info:{type:"ml-kem"},lengths:{...s,seed:64,msg:32,msgRand:32,secretKey:a.bytesLen},keygen:(u=mi(64))=>{Ne(u,64,"seed");let{publicKey:d,secretKey:p}=t.keygen(u.subarray(0,32)),m=r(d),y=a.encode([p,d,m,u.subarray(32)]);return Kt(p,m),{publicKey:d,secretKey:y}},getPublicKey:(u)=>{let[d,p,m,y]=a.decode(u);return Uint8Array.from(p)},encapsulate:(u,d=mi(32))=>{Ne(u,s.publicKey,"publicKey"),Ne(d,32,"message");let p=u.subarray(0,384*e.K),m=o.encode(o.decode(G3(p)));if(!ub(m,p))throw Kt(m),Error("ML-KEM.encapsulate: wrong publicKey modulus");Kt(m);let y=i.create().update(d).update(r(u)).digest(),g=t.encrypt(u,d,y.subarray(32,64));return Kt(y.subarray(32)),{cipherText:g,sharedSecret:y.subarray(0,32)}},decapsulate:(u,d)=>{Ne(d,a.bytesLen,"secretKey"),Ne(u,s.cipherText,"cipherText");let p=a.bytesLen-96,m=p+32,y=r(d.subarray(p/2,m));if(!ub(y,d.subarray(m,m+32)))throw Error("invalid secretKey: hash check failed");let[g,b,v,A]=a.decode(d),T=t.decrypt(u,g),z=i.create().update(T).update(v).digest(),j=z.subarray(0,32),E=t.encrypt(b,T,z.subarray(32,64)),Z=ub(u,E),D=n.create({dkLen:32}).update(A).update(u).digest();return Kt(T,E,!Z?j:D),Z?j:D}}}function Qbe(e,t,r){return pi.create({dkLen:e}).update(t).update(new Uint8Array([r])).digest()}var nC={HASH256:ka,HASH512:Z3,KDF:pi,XOF:Y3,PRF:Qbe},gZe=rC({...nC,...tC[512]}),qf=rC({...nC,...tC[768]}),e5=rC({...nC,...tC[1024]});/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */function Ybe(e,t=!1){let{lengths:r,keygen:i}=e;if(t){let o=e.Point.Fn;if(!o)throw Error("No Point.Fn");i=(s=mi(r.seed))=>{Ne(s,r.seed,"seed");let a=o.isLE?ns(s):rs(s),c=o.toBytes(o.create(a));return{secretKey:c,publicKey:e.getPublicKey(c)}}}return{lengths:{secretKey:r.secretKey,publicKey:r.publicKey,seed:r.seed},keygen:i,getPublicKey:(n)=>e.getPublicKey(n)}}function iC(e,t=!1){let r=Ybe(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(i,n=mi(e.lengths.seed)){let o=this.keygen(n).secretKey,s=this.decapsulate(i,o),a=e.getPublicKey(o);return Kt(o),{sharedSecret:s,cipherText:a}},decapsulate(i,n){let o=e.getSharedSecret(n,i);return e.lengths.publicKeyHasPrefix?o.subarray(1):o}}}function Uf(e,t){return Ea(t,...e.map((r)=>{if(typeof r.lengths[t]!=="number")throw Error("wrong length: "+t);return r.lengths[t]}))}function oC(e){return(t,r)=>e(t,{dkLen:r})}function Xbe(e,t,...r){let i=Uf(r,"seed"),n=Uf(r,"publicKey");if(e===void 0)e=i.bytesLen;Yt(e);function o(s){Ne(s,e);let a=i.decode(t(s,i.bytesLen)),c=r.map((d,p)=>d.keygen(a[p])),l=c.map((d)=>d.secretKey),u=c.map((d)=>d.publicKey);return{secretKey:l,publicKey:u}}return{info:{lengths:{seed:e,publicKey:n.bytesLen,secretKey:e}},getPublicKey(s){return this.keygen(s).publicKey},keygen(s=mi(e)){let{publicKey:a,secretKey:c}=o(s),l=n.encode(a);return Kt(a),Kt(c),{secretKey:s,publicKey:l}},expandDecapsulationKey:o,realSeedLen:e}}function pb(e,t,r,i,...n){let o=Xbe(e,r,...n),s=Uf(n,"cipherText"),a=Uf(n,"publicKey"),c=Uf(n,"msg");if(t===void 0)t=c.bytesLen;return Yt(t),{lengths:{...o.info.lengths,msg:t,msgRand:c.bytesLen,cipherText:s.bytesLen},getPublicKey:o.getPublicKey,keygen:o.keygen,encapsulate(l,u=mi(c.bytesLen)){let d=a.decode(l),p=c.decode(u),m=n.map((v,A)=>v.encapsulate(d[A],p[A])),y=m.map((v)=>v.sharedSecret),g=m.map((v)=>v.cipherText),b={sharedSecret:i(d,g,y),cipherText:s.encode(g)};return Kt(y,g),b},decapsulate(l,u){let d=s.decode(l),{publicKey:p,secretKey:m}=o.expandDecapsulationKey(u),y=n.map((g,b)=>g.decapsulate(d[b],m[b]));return i(p,d,y)}}}function t5(e,t,r,i,n){return _n(i),_n(n),pb(32,32,oC(i),(o,s,a)=>n(qt(a[0],a[1],s[1],o[1],is(e))),t,r)}var AZe=t5("QSF-KEM(ML-KEM-768,P-256)-XOF(SHAKE256)-KDF(SHA3-256)",qf,iC(WT,!0),pi,ka),TZe=t5("QSF-KEM(ML-KEM-1024,P-384)-XOF(SHAKE256)-KDF(SHA3-256)",e5,iC(P3,!0),pi,ka);function exe(e,t,r,i,n){return _n(i),_n(n),pb(32,32,oC(i),(o,s,a)=>{let c=qt(a[0],a[1],s[0],o[0],s[1],o[1],is(e)),l=32,u=qt(is("hybrid_prk"),c),d=N3(n,u),p=qt(Cl(32,2),is("shared_secret"),is("")),m=D3(n,d,p,32);return Kt(d,p,u,c),m},t,r)}var r5=iC(R3),CZe=exe("KitchenSink-KEM(ML-KEM-768,X25519)-XOF(SHAKE256)-KDF(HKDF-SHA-256)",qf,r5,pi,cb),txe=(()=>pb(32,32,oC(pi),(e,t,r)=>ka(qt(r[0],r[1],t[1],e[1],is("\\.//^\\"))),qf,r5))();function rxe(e,t,r,i){let n=e.Point.Fn;if(!n)throw Error("no Point.Fn");function o(s){let a;for(let u=0,d=t;;u=d,d+=t){if(d>s.length)throw Error("rejection sampling failed");if(a=n.fromBytes(s.subarray(u,d),!0),n.isValidNot0(a))break}let c=n.toBytes(n.create(a)),l=e.getPublicKey(c,!1);return{secretKey:c,publicKey:l}}return{lengths:{secretKey:t,publicKey:r,seed:i,msg:i,cipherText:r},keygen(s=mi(i)){return Ne(s,i,"seed"),o(s)},getPublicKey(s){return e.getPublicKey(s,!1)},encapsulate(s,a=mi(i)){Ne(a,i,"rand");let{secretKey:c}=o(a),l=this.decapsulate(s,c),u=e.getPublicKey(c,!1);return Kt(c),{sharedSecret:l,cipherText:u}},decapsulate(s,a){return e.getSharedSecret(a,s).subarray(1)}}}function nxe(e,t,r,i){let{secretKey:n,publicKeyUncompressed:o}=r.lengths;if(!n||!o)throw Error("wrong curve");let s=rxe(r,n,o,i),a=64,c=a+i;return pb(32,32,(l)=>{Ne(l,32);let u=pi(l,{dkLen:c}),d=u.subarray(0,a),p=u.subarray(a,c);return qt(d,p)},(l,u,d)=>ka(qt(d[0],d[1],u[1],l[1],is(e))),t,s)}var ixe=(()=>nxe("MLKEM768-P256",qf,WT,128))();var mb=txe,n5=ixe;/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var ut=(e,t,r)=>or(e,t,r),aC=Ot,zl=By,lr=(...e)=>uT(...e),Nl=(e)=>bf(e),Dl=aT,Ll=(e)=>Fi(e),gb=BigInt(0),sC=BigInt(1);function Qi(e,t=""){if(typeof e!=="boolean"){let r=t&&`"${t}" `;throw TypeError(r+"expected boolean, got type="+typeof e)}return e}function yb(e){if(typeof e==="bigint"){if(!hb(e))throw RangeError("positive bigint expected, got "+e)}else aC(e);return e}function hi(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 Mf(e){let t=yb(e).toString(16);return t.length&1?"0"+t:t}function i5(e){if(typeof e!=="string")throw TypeError("hex string expected, got "+typeof e);return e===""?gb:BigInt("0x"+e)}function Ta(e){return i5(By(e))}function Zn(e){return i5(By(ls(or(e)).reverse()))}function bb(e,t){if(Ot(t),t===0)throw RangeError("zero length");e=yb(e);let r=e.toString(16);if(r.length>t*2)throw RangeError("number too large");return bf(r.padStart(t*2,"0"))}function Ff(e,t){return bb(e,t).reverse()}function o5(e,t){if(e=ut(e),t=ut(t),e.length!==t.length)return!1;let r=0;for(let i=0;i<e.length;i++)r|=e[i]^t[i];return r===0}function ls(e){return Uint8Array.from(ut(e))}function xb(e){if(typeof e!=="string")throw TypeError("ascii string expected, got "+typeof e);return Uint8Array.from(e,(t,r)=>{let i=t.charCodeAt(0);if(t.length!==1||i>127)throw RangeError(`string contains non-ASCII character "${e[r]}" with code ${i} at position ${r}`);return i})}var hb=(e)=>typeof e==="bigint"&&gb<=e;function oxe(e,t,r){return hb(e)&&hb(t)&&hb(r)&&t<=e&&e<r}function Yi(e,t,r,i){if(!oxe(t,r,i))throw RangeError("expected valid "+e+": "+r+" <= n < "+i+", got "+t)}function Bl(e){if(e<gb)throw Error("expected non-negative bigint, got "+e);let t;for(t=0;e>gb;e>>=sC,t+=1);return t}var Zf=(e)=>(sC<<BigInt(e))-sC;function s5(e,t,r){if(Ot(e,"hashLen"),Ot(t,"qByteLen"),typeof r!=="function")throw TypeError("hmacFn must be a function");let i=(b)=>new Uint8Array(b),n=Uint8Array.of(),o=Uint8Array.of(0),s=Uint8Array.of(1),a=1000,c=i(e),l=i(e),u=0,d=()=>{c.fill(1),l.fill(0),u=0},p=(...b)=>r(l,lr(c,...b)),m=(b=n)=>{if(l=p(o,b),c=p(),b.length===0)return;l=p(s,b),c=p()},y=()=>{if(u++>=a)throw Error("drbg: tried max amount of iterations");let b=0,v=[];while(b<t){c=p();let A=c.slice();v.push(A),b+=c.length}return lr(...v)};return(b,v)=>{d(),m(b);let A=void 0;while((A=v(y()))===void 0)m();return d(),A}}function En(e,t={},r={}){if(Object.prototype.toString.call(e)!=="[object Object]")throw TypeError("expected valid options object");function i(o,s,a){if(!a&&s!=="function"&&!Object.hasOwn(e,o))throw TypeError(`param "${o}" is invalid: expected own property`);let c=e[o];if(a&&c===void 0)return;let l=typeof c;if(l!==s||c===null)throw TypeError(`param "${o}" is invalid: expected ${s}, got ${l}`)}let n=(o,s)=>Object.entries(o).forEach(([a,c])=>i(a,c,s));n(t,!1),n(r,!0)}var cC=()=>{throw Error("not implemented")};/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var ur=BigInt(0),It=BigInt(1),Ca=BigInt(2),u5=BigInt(3),d5=BigInt(4),f5=BigInt(5),sxe=BigInt(7),p5=BigInt(8),axe=BigInt(9),m5=BigInt(16);function gt(e,t){if(t<=ur)throw Error("mod: expected positive modulus, got "+t);let r=e%t;return r>=ur?r:t+r}function In(e,t,r){if(t<ur)throw Error("pow2: expected non-negative exponent, got "+t);let i=e;while(t-- >ur)i*=i,i%=r;return i}function a5(e,t){if(e===ur)throw Error("invert: expected non-zero number");if(t<=ur)throw Error("invert: expected positive modulus, got "+t);let r=gt(e,t),i=t,n=ur,o=It,s=It,a=ur;while(r!==ur){let l=i/r,u=i-r*l,d=n-s*l,p=o-a*l;i=r,r=u,n=s,o=a,s=d,a=p}if(i!==It)throw Error("invert: does not exist");return gt(n,t)}function lC(e,t,r){let i=e;if(!i.eql(i.sqr(t),r))throw Error("Cannot find square root")}function h5(e,t){let r=e,i=(r.ORDER+It)/d5,n=r.pow(t,i);return lC(r,n,t),n}function cxe(e,t){let r=e,i=(r.ORDER-f5)/p5,n=r.mul(t,Ca),o=r.pow(n,i),s=r.mul(t,o),a=r.mul(r.mul(s,Ca),o),c=r.mul(s,r.sub(a,r.ONE));return lC(r,c,t),c}function lxe(e){let t=Sb(e),r=g5(e),i=r(t,t.neg(t.ONE)),n=r(t,i),o=r(t,t.neg(i)),s=(e+sxe)/m5;return(a,c)=>{let l=a,u=l.pow(c,s),d=l.mul(u,i),p=l.mul(u,n),m=l.mul(u,o),y=l.eql(l.sqr(d),c),g=l.eql(l.sqr(p),c);u=l.cmov(u,d,y),d=l.cmov(m,p,g);let b=l.eql(l.sqr(d),c),v=l.cmov(u,d,b);return lC(l,v,c),v}}function g5(e){if(e<u5)throw Error("sqrt is not defined for small field");let t=e-It,r=0;while(t%Ca===ur)t/=Ca,r++;let i=Ca,n=Sb(e);while(c5(n,i)===1)if(i++>1000)throw Error("Cannot find square root: probably non-prime P");if(r===1)return h5;let o=n.pow(i,t),s=(t+It)/Ca;return function(c,l){let u=c;if(u.is0(l))return l;if(c5(u,l)!==1)throw Error("Cannot find square root");let d=r,p=u.mul(u.ONE,o),m=u.pow(l,t),y=u.pow(l,s);while(!u.eql(m,u.ONE)){if(u.is0(m))return u.ZERO;let g=1,b=u.sqr(m);while(!u.eql(b,u.ONE))if(g++,b=u.sqr(b),g===d)throw Error("Cannot find square root");let v=It<<BigInt(d-g-1),A=u.pow(p,v);d=g,p=u.sqr(A),m=u.mul(m,p),y=u.mul(y,A)}return y}}function uxe(e){if(e%d5===u5)return h5;if(e%p5===f5)return cxe;if(e%m5===axe)return lxe(e);return g5(e)}var Xi=(e,t)=>(gt(e,t)&It)===It,dxe=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function uC(e){let t={ORDER:"bigint",BYTES:"number",BITS:"number"},r=dxe.reduce((i,n)=>(i[n]="function",i),t);if(En(e,r),hi(e.BYTES,"BYTES"),hi(e.BITS,"BITS"),e.BYTES<1||e.BITS<1)throw Error("invalid field: expected BYTES/BITS > 0");if(e.ORDER<=It)throw Error("invalid field: expected ORDER > 1, got "+e.ORDER);return e}function fxe(e,t,r){let i=e;if(r<ur)throw Error("invalid exponent, negatives unsupported");if(r===ur)return i.ONE;if(r===It)return t;let n=i.ONE,o=t;while(r>ur){if(r&It)n=i.mul(n,o);o=i.sqr(o),r>>=It}return n}function Hf(e,t,r=!1){let i=e,n=Array(t.length).fill(r?i.ZERO:void 0),o=t.reduce((a,c,l)=>{if(i.is0(c))return a;return n[l]=a,i.mul(a,c)},i.ONE),s=i.inv(o);return t.reduceRight((a,c,l)=>{if(i.is0(c))return a;return n[l]=i.mul(a,n[l]),i.mul(a,c)},s),n}function c5(e,t){let r=e,i=(r.ORDER-It)/Ca,n=r.pow(t,i),o=r.eql(n,r.ONE),s=r.eql(n,r.ZERO),a=r.eql(n,r.neg(r.ONE));if(!o&&!s&&!a)throw Error("invalid Legendre symbol result");return o?1:s?0:-1}function pxe(e,t){if(t!==void 0)aC(t);if(e<=ur)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=Bl(e);if(t!==void 0&&t<r)throw Error(`invalid n length: expected bit length (${r}) >= n.length (${t})`);let i=t!==void 0?t:r,n=Math.ceil(i/8);return{nBitLength:i,nByteLength:n}}var l5=new WeakMap;class dC{ORDER;BITS;BYTES;isLE;ZERO=ur;ONE=It;_lengths;_mod;constructor(e,t={}){if(e<=It)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:i,nByteLength:n}=pxe(e,r);if(n>2048)throw Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=e,this.BITS=i,this.BYTES=n,Object.freeze(this)}create(e){return gt(e,this.ORDER)}isValid(e){if(typeof e!=="bigint")throw TypeError("invalid field element: expected bigint, got "+typeof e);return ur<=e&&e<this.ORDER}is0(e){return e===ur}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&It)===It}neg(e){return gt(-e,this.ORDER)}eql(e,t){return e===t}sqr(e){return gt(e*e,this.ORDER)}add(e,t){return gt(e+t,this.ORDER)}sub(e,t){return gt(e-t,this.ORDER)}mul(e,t){return gt(e*t,this.ORDER)}pow(e,t){return fxe(this,e,t)}div(e,t){return gt(e*a5(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 a5(e,this.ORDER)}sqrt(e){let t=l5.get(this);if(!t)l5.set(this,t=uxe(this.ORDER));return t(this,e)}toBytes(e){return this.isLE?Ff(e,this.BYTES):bb(e,this.BYTES)}fromBytes(e,t=!1){ut(e);let{_lengths:r,BYTES:i,isLE:n,ORDER:o,_mod:s}=this;if(r){if(e.length<1||!r.includes(e.length)||e.length>i)throw Error("Field.fromBytes: expected "+r+" bytes, got "+e.length);let c=new Uint8Array(i);c.set(e,n?0:c.length-e.length),e=c}if(e.length!==i)throw Error("Field.fromBytes: expected "+i+" bytes, got "+e.length);let a=n?Zn(e):Ta(e);if(s)a=gt(a,o);if(!t){if(!this.isValid(a))throw Error("invalid field element: outside of range 0..ORDER")}return a}invertBatch(e){return Hf(this,e)}cmov(e,t,r){return Qi(r,"condition"),r?t:e}}Object.freeze(dC.prototype);function Sb(e,t={}){return new dC(e,t)}function y5(e){if(typeof e!=="bigint")throw Error("field order must be bigint");if(e<=It)throw Error("field order must be greater than 1");let t=Bl(e-It);return Math.ceil(t/8)}function fC(e){let t=y5(e);return t+Math.ceil(t/2)}function b5(e,t,r=!1){ut(e);let i=e.length,n=y5(t),o=Math.max(fC(t),16);if(i<o||i>1024)throw Error("expected "+o+"-1024 bytes of input, got "+i);let s=r?Zn(e):Ta(e),a=gt(s,t-It)+It;return r?Ff(a,n):bb(a,n)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var jl=BigInt(0),$a=BigInt(1);function Kf(e,t){let r=t.negate();return e?r:t}function Oa(e,t){let r=Hf(e.Fp,t.map((i)=>i.Z));return t.map((i,n)=>e.fromAffine(i.toAffine(r[n])))}function v5(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw Error("invalid window size, expected [1.."+t+"], got W="+e)}function pC(e,t){v5(e,t);let r=Math.ceil(t/e)+1,i=2**(e-1),n=2**e,o=Zf(e),s=BigInt(e);return{windows:r,windowSize:i,mask:o,maxNumber:n,shiftBy:s}}function x5(e,t,r){let{windowSize:i,mask:n,maxNumber:o,shiftBy:s}=r,a=Number(e&n),c=e>>s;if(a>i)a-=o,c+=$a;let l=t*i,u=l+Math.abs(a)-1,d=a===0,p=a<0,m=t%2!==0;return{nextN:c,offset:u,isZero:d,isNeg:p,isNegF:m,offsetF:l}}var mC=new WeakMap,_5=new WeakMap;function hC(e){return _5.get(e)||1}function S5(e){if(e!==jl)throw Error("invalid wNAF")}class Jf{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 i=e;while(t>jl){if(t&$a)r=r.add(i);i=i.double(),t>>=$a}return r}precomputeWindow(e,t){let{windows:r,windowSize:i}=pC(t,this.bits),n=[],o=e,s=o;for(let a=0;a<r;a++){s=o,n.push(s);for(let c=1;c<i;c++)s=s.add(o),n.push(s);o=s.double()}return n}wNAF(e,t,r){if(!this.Fn.isValid(r))throw Error("invalid scalar");let i=this.ZERO,n=this.BASE,o=pC(e,this.bits);for(let s=0;s<o.windows;s++){let{nextN:a,offset:c,isZero:l,isNeg:u,isNegF:d,offsetF:p}=x5(r,s,o);if(r=a,l)n=n.add(Kf(d,t[p]));else i=i.add(Kf(u,t[c]))}return S5(r),{p:i,f:n}}wNAFUnsafe(e,t,r,i=this.ZERO){let n=pC(e,this.bits);for(let o=0;o<n.windows;o++){if(r===jl)break;let{nextN:s,offset:a,isZero:c,isNeg:l}=x5(r,o,n);if(r=s,c)continue;else{let u=t[a];i=i.add(l?u.negate():u)}}return S5(r),i}getPrecomputes(e,t,r){let i=mC.get(t);if(!i){if(i=this.precomputeWindow(t,e),e!==1){if(typeof r==="function")i=r(i);mC.set(t,i)}}return i}cached(e,t,r){let i=hC(e);return this.wNAF(i,this.getPrecomputes(i,e,r),t)}unsafe(e,t,r,i){let n=hC(e);if(n===1)return this._unsafeLadder(e,t,i);return this.wNAFUnsafe(n,this.getPrecomputes(n,e,r),t,i)}createCache(e,t){v5(t,this.bits),_5.set(e,t),mC.delete(e)}hasCache(e){return hC(e)!==1}}function k5(e,t,r,i){let n=t,o=e.ZERO,s=e.ZERO;while(r>jl||i>jl){if(r&$a)o=o.add(n);if(i&$a)s=s.add(n);n=n.double(),r>>=$a,i>>=$a}return{p1:o,p2:s}}function w5(e,t,r){if(t){if(t.ORDER!==e)throw Error("Field.ORDER must match order: Fp == p, Fn == n");return uC(t),t}else return Sb(e,{isLE:r})}function wb(e,t,r={},i){if(i===void 0)i=e==="edwards";if(!t||typeof t!=="object")throw Error(`expected valid ${e} CURVE object`);for(let c of["p","n","h"]){let l=t[c];if(!(typeof l==="bigint"&&l>jl))throw Error(`CURVE.${c} must be positive bigint`)}let n=w5(t.p,r.Fp,i),o=w5(t.n,r.Fn,i),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:o}}function Vf(e,t){return function(i){let n=e(i);return{secretKey:n,publicKey:t(n)}}}function Wf(e,t){if(hi(e),hi(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 i=t-1;i>=0;i--)r[i]=e&255,e>>>=8;return new Uint8Array(r)}function mxe(e,t){let r=new Uint8Array(e.length);for(let i=0;i<e.length;i++)r[i]=e[i]^t[i];return r}function hxe(e){if(!Dl(e)&&typeof e!=="string")throw Error("DST must be Uint8Array or ascii string");let t=typeof e==="string"?xb(e):e;if(t.length===0)throw Error("DST must be non-empty");return t}function gC(e,t,r,i){if(ut(e),hi(r),t=hxe(t),t.length>255)t=i(lr(xb("H2C-OVERSIZE-DST-"),t));let{outputLen:n,blockLen:o}=i,s=Math.ceil(r/n);if(r>65535||s>255)throw Error("expand_message_xmd: invalid lenInBytes");let a=lr(t,Wf(t.length,1)),c=new Uint8Array(o),l=Wf(r,2),u=Array(s),d=i(lr(c,e,l,Wf(0,1),a));u[0]=i(lr(d,Wf(1,1),a));for(let m=1;m<s;m++){let y=[mxe(d,u[m-1]),Wf(m+1,1),a];u[m]=i(lr(...y))}return lr(...u).slice(0,r)}var E5="HashToScalar-";/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var I5=(e,t)=>(e+(e>=0?t:-t)/T5)/t;function gxe(e,t,r){Yi("scalar",e,gi,r);let[[i,n],[o,s]]=t,a=I5(s*e,r),c=I5(-n*e,r),l=e-a*i-c*o,u=-a*n-c*s,d=l<gi,p=u<gi;if(d)l=-l;if(p)u=-u;let m=Zf(Math.ceil(Bl(r)/2))+us;if(l<gi||l>=m||u<gi||u>=m)throw Error("splitScalar (endomorphism): failed for k");return{k1neg:d,k1:l,k2neg:p,k2:u}}function bC(e){if(!["compact","recovered","der"].includes(e))throw Error('Signature format must be "compact", "recovered", or "der"');return e}function yC(e,t){En(e);let r={};for(let i of Object.keys(t))r[i]=e[i]===void 0?t[i]:e[i];if(Qi(r.lowS,"lowS"),Qi(r.prehash,"prehash"),r.format!==void 0)bC(r.format);return r}class A5 extends Error{constructor(e=""){super(e)}}var Hn={Err:A5,_tlv:{encode:(e,t)=>{let{Err:r}=Hn;if(hi(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 i=t.length/2,n=Mf(i);if(n.length/2&128)throw new r("tlv.encode: long form length too big");let o=i>127?Mf(n.length/2|128):"";return Mf(e)+o+n+t},decode(e,t){let{Err:r}=Hn;t=ut(t,void 0,"DER data");let i=0;if(e<0||e>255)throw new r("tlv.encode: wrong tag");if(t.length<2||t[i++]!==e)throw new r("tlv.decode: wrong tlv");let n=t[i++],o=!!(n&128),s=0;if(!o)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 l=t.subarray(i,i+c);if(l.length!==c)throw new r("tlv.decode: length bytes not complete");if(l[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let u of l)s=s<<8|u;if(i+=c,s<128)throw new r("tlv.decode(long): not minimal encoding")}let a=t.subarray(i,i+s);if(a.length!==s)throw new r("tlv.decode: wrong value length");return{v:a,l:t.subarray(i+s)}}},_int:{encode(e){let{Err:t}=Hn;if(yb(e),e<gi)throw new t("integer: negative integers are not allowed");let r=Mf(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}=Hn;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 Ta(e)}},toSig(e){let{Err:t,_int:r,_tlv:i}=Hn,n=ut(e,void 0,"signature"),{v:o,l:s}=i.decode(48,n);if(s.length)throw new t("invalid signature: left bytes after parsing");let{v:a,l:c}=i.decode(2,o),{v:l,l:u}=i.decode(2,c);if(u.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(l)}},hexFromSig(e){let{_tlv:t,_int:r}=Hn,i=t.encode(2,r.encode(e.r)),n=t.encode(2,r.encode(e.s)),o=i+n;return t.encode(48,o)}};Object.freeze(Hn._tlv);Object.freeze(Hn._int);Object.freeze(Hn);var gi=BigInt(0),us=BigInt(1),T5=BigInt(2),vb=BigInt(3),yxe=BigInt(4);function C5(e,t={}){let r=wb("weierstrass",e,t),i=r.Fp,n=r.Fn,o=r.CURVE,{h:s,n:a}=o;En(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});let{endo:c,allowInfinityPoint:l}=t;if(c){if(!i.is0(o.a)||typeof c.beta!=="bigint"||!Array.isArray(c.basises))throw Error('invalid endo: expected "beta": bigint and "basises": array')}let u=O5(i,n);function d(){if(!i.isOdd)throw Error("compression is not supported: Field does not have .isOdd()")}function p(M,P,N){if(l&&P.is0())return Uint8Array.of(0);let{x:I,y:R}=P.toAffine(),O=i.toBytes(I);if(Qi(N,"isCompressed"),N){d();let F=!i.isOdd(R);return lr($5(F),O)}else return lr(Uint8Array.of(4),O,i.toBytes(R))}function m(M){ut(M,void 0,"Point");let{publicKey:P,publicKeyUncompressed:N}=u,I=M.length,R=M[0],O=M.subarray(1);if(l&&I===1&&R===0)return{x:i.ZERO,y:i.ZERO};if(I===P&&(R===2||R===3)){let F=i.fromBytes(O);if(!i.isValid(F))throw Error("bad point: is not on curve, wrong x");let L=b(F),V;try{V=i.sqrt(L)}catch(ue){let C=ue instanceof Error?": "+ue.message:"";throw Error("bad point: is not on curve, sqrt error"+C)}d();let _=i.isOdd(V);if((R&1)===1!==_)V=i.neg(V);return{x:F,y:V}}else if(I===N&&R===4){let F=i.BYTES,L=i.fromBytes(O.subarray(0,F)),V=i.fromBytes(O.subarray(F,F*2));if(!v(L,V))throw Error("bad point: is not on curve");return{x:L,y:V}}else throw Error(`bad point: got length ${I}, expected compressed=${P} or uncompressed=${N}`)}let y=t.toBytes===void 0?p:t.toBytes,g=t.fromBytes===void 0?m:t.fromBytes;function b(M){let P=i.sqr(M),N=i.mul(P,M);return i.add(i.add(N,i.mul(M,o.a)),o.b)}function v(M,P){let N=i.sqr(P),I=b(M);return i.eql(N,I)}if(!v(o.Gx,o.Gy))throw Error("bad curve params: generator point");let A=i.mul(i.pow(o.a,vb),yxe),T=i.mul(i.sqr(o.b),BigInt(27));if(i.is0(i.add(A,T)))throw Error("bad curve params: a or b");function z(M,P,N=!1){if(!i.isValid(P)||N&&i.is0(P))throw Error(`bad point coordinate ${M}`);return P}function j(M){if(!(M instanceof D))throw Error("Weierstrass Point expected")}function E(M){if(!c||!c.basises)throw Error("no endo");return gxe(M,c.basises,n.ORDER)}function Z(M,P,N,I,R){return N=new D(i.mul(N.X,M),N.Y,N.Z),P=Kf(I,P),N=Kf(R,N),P.add(N)}class D{static BASE=new D(o.Gx,o.Gy,i.ONE);static ZERO=new D(i.ZERO,i.ONE,i.ZERO);static Fp=i;static Fn=n;X;Y;Z;constructor(M,P,N){this.X=z("x",M),this.Y=z("y",P,!0),this.Z=z("z",N),Object.freeze(this)}static CURVE(){return o}static fromAffine(M){let{x:P,y:N}=M||{};if(!M||!i.isValid(P)||!i.isValid(N))throw Error("invalid affine point");if(M instanceof D)throw Error("projective point not allowed");if(i.is0(P)&&i.is0(N))return D.ZERO;return new D(P,N,i.ONE)}static fromBytes(M){let P=D.fromAffine(g(ut(M,void 0,"point")));return P.assertValidity(),P}static fromHex(M){return D.fromBytes(Nl(M))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(M=8,P=!0){if(X.createCache(this,M),!P)this.multiply(vb);return this}assertValidity(){let M=this;if(M.is0()){if(t.allowInfinityPoint&&i.is0(M.X)&&i.eql(M.Y,i.ONE)&&i.is0(M.Z))return;throw Error("bad point: ZERO")}let{x:P,y:N}=M.toAffine();if(!i.isValid(P)||!i.isValid(N))throw Error("bad point: x or y not field elements");if(!v(P,N))throw Error("bad point: equation left != right");if(!M.isTorsionFree())throw Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y:M}=this.toAffine();if(!i.isOdd)throw Error("Field doesn't support isOdd");return!i.isOdd(M)}equals(M){j(M);let{X:P,Y:N,Z:I}=this,{X:R,Y:O,Z:F}=M,L=i.eql(i.mul(P,F),i.mul(R,I)),V=i.eql(i.mul(N,F),i.mul(O,I));return L&&V}negate(){return new D(this.X,i.neg(this.Y),this.Z)}double(){let{a:M,b:P}=o,N=i.mul(P,vb),{X:I,Y:R,Z:O}=this,F=i.ZERO,L=i.ZERO,V=i.ZERO,_=i.mul(I,I),te=i.mul(R,R),ue=i.mul(O,O),C=i.mul(I,R);return C=i.add(C,C),V=i.mul(I,O),V=i.add(V,V),F=i.mul(M,V),L=i.mul(N,ue),L=i.add(F,L),F=i.sub(te,L),L=i.add(te,L),L=i.mul(F,L),F=i.mul(C,F),V=i.mul(N,V),ue=i.mul(M,ue),C=i.sub(_,ue),C=i.mul(M,C),C=i.add(C,V),V=i.add(_,_),_=i.add(V,_),_=i.add(_,ue),_=i.mul(_,C),L=i.add(L,_),ue=i.mul(R,O),ue=i.add(ue,ue),_=i.mul(ue,C),F=i.sub(F,_),V=i.mul(ue,te),V=i.add(V,V),V=i.add(V,V),new D(F,L,V)}add(M){j(M);let{X:P,Y:N,Z:I}=this,{X:R,Y:O,Z:F}=M,L=i.ZERO,V=i.ZERO,_=i.ZERO,te=o.a,ue=i.mul(o.b,vb),C=i.mul(P,R),Se=i.mul(N,O),Ee=i.mul(I,F),$e=i.add(P,N),Ce=i.add(R,O);$e=i.mul($e,Ce),Ce=i.add(C,Se),$e=i.sub($e,Ce),Ce=i.add(P,I);let _e=i.add(R,F);return Ce=i.mul(Ce,_e),_e=i.add(C,Ee),Ce=i.sub(Ce,_e),_e=i.add(N,I),L=i.add(O,F),_e=i.mul(_e,L),L=i.add(Se,Ee),_e=i.sub(_e,L),_=i.mul(te,Ce),L=i.mul(ue,Ee),_=i.add(L,_),L=i.sub(Se,_),_=i.add(Se,_),V=i.mul(L,_),Se=i.add(C,C),Se=i.add(Se,C),Ee=i.mul(te,Ee),Ce=i.mul(ue,Ce),Se=i.add(Se,Ee),Ee=i.sub(C,Ee),Ee=i.mul(te,Ee),Ce=i.add(Ce,Ee),C=i.mul(Se,Ce),V=i.add(V,C),C=i.mul(_e,Ce),L=i.mul($e,L),L=i.sub(L,C),C=i.mul($e,Se),_=i.mul(_e,_),_=i.add(_,C),new D(L,V,_)}subtract(M){return j(M),this.add(M.negate())}is0(){return this.equals(D.ZERO)}multiply(M){let{endo:P}=t;if(!n.isValidNot0(M))throw RangeError("invalid scalar: out of range");let N,I,R=(O)=>X.cached(this,O,(F)=>Oa(D,F));if(P){let{k1neg:O,k1:F,k2neg:L,k2:V}=E(M),{p:_,f:te}=R(F),{p:ue,f:C}=R(V);I=te.add(C),N=Z(P.beta,_,ue,O,L)}else{let{p:O,f:F}=R(M);N=O,I=F}return Oa(D,[N,I])[0]}multiplyUnsafe(M){let{endo:P}=t,N=this,I=M;if(!n.isValid(I))throw RangeError("invalid scalar: out of range");if(I===gi||N.is0())return D.ZERO;if(I===us)return N;if(X.hasCache(this))return this.multiply(I);if(P){let{k1neg:R,k1:O,k2neg:F,k2:L}=E(I),{p1:V,p2:_}=k5(D,N,O,L);return Z(P.beta,V,_,R,F)}else return X.unsafe(N,I)}toAffine(M){let P=this,N=M,{X:I,Y:R,Z:O}=P;if(i.eql(O,i.ONE))return{x:I,y:R};let F=P.is0();if(N==null)N=F?i.ONE:i.inv(O);let L=i.mul(I,N),V=i.mul(R,N),_=i.mul(O,N);if(F)return{x:i.ZERO,y:i.ZERO};if(!i.eql(_,i.ONE))throw Error("invZ was invalid");return{x:L,y:V}}isTorsionFree(){let{isTorsionFree:M}=t;if(s===us)return!0;if(M)return M(D,this);return X.unsafe(this,a).is0()}clearCofactor(){let{clearCofactor:M}=t;if(s===us)return this;if(M)return M(D,this);return this.multiplyUnsafe(s)}isSmallOrder(){if(s===us)return this.is0();return this.clearCofactor().is0()}toBytes(M=!0){return Qi(M,"isCompressed"),this.assertValidity(),y(D,this,M)}toHex(M=!0){return zl(this.toBytes(M))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let H=n.BITS,X=new Jf(D,t.endo?Math.ceil(H/2):H);if(H>=8)D.BASE.precompute(8);return Object.freeze(D.prototype),Object.freeze(D),D}function $5(e){return Uint8Array.of(e?2:3)}function O5(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function bxe(e,t={}){let{Fn:r}=e,i=t.randomBytes===void 0?Ll:t.randomBytes,n=Object.assign(O5(e.Fp,r),{seed:Math.max(fC(r.ORDER),16)});function o(m){try{let y=r.fromBytes(m);return r.isValidNot0(y)}catch(y){return!1}}function s(m,y){let{publicKey:g,publicKeyUncompressed:b}=n;try{let v=m.length;if(y===!0&&v!==g)return!1;if(y===!1&&v!==b)return!1;return!!e.fromBytes(m)}catch(v){return!1}}function a(m){return m=m===void 0?i(n.seed):m,b5(ut(m,n.seed,"seed"),r.ORDER)}function c(m,y=!0){return e.BASE.multiply(r.fromBytes(m)).toBytes(y)}function l(m){let{secretKey:y,publicKey:g,publicKeyUncompressed:b}=n,v=r._lengths;if(!Dl(m))return;let A=ut(m,void 0,"key").length,T=A===g||A===b,z=A===y||!!v?.includes(A);if(T&&z)return;return T}function u(m,y,g=!0){if(l(m)===!0)throw Error("first arg must be private key");if(l(y)===!1)throw Error("second arg must be public key");let b=r.fromBytes(m);return e.fromBytes(y).multiply(b).toBytes(g)}let d={isValidSecretKey:o,isValidPublicKey:s,randomSecretKey:a},p=Vf(a,c);return Object.freeze(d),Object.freeze(n),Object.freeze({getPublicKey:c,getSharedSecret:u,keygen:p,Point:e,utils:d,lengths:n})}function R5(e,t,r={}){let i=t;Mi(i),En(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),r=Object.assign({},r);let n=r.randomBytes===void 0?Ll:r.randomBytes,o=r.hmac===void 0?(R,O)=>li(i,R,O):r.hmac,{Fp:s,Fn:a}=e,{ORDER:c,BITS:l}=a,{keygen:u,getPublicKey:d,getSharedSecret:p,utils:m,lengths:y}=bxe(e,r),g={prehash:!0,lowS:typeof r.lowS==="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},b=c*T5+us<s.ORDER;function v(R){let O=c>>us;return R>O}function A(R,O){if(!a.isValidNot0(O))throw Error(`invalid signature ${R}: out of range 1..Point.Fn.ORDER`);return O}function T(){if(b)throw Error('"recovered" sig type is not supported for cofactor >2 curves')}function z(R,O){bC(O);let F=y.signature,L=O==="compact"?F:O==="recovered"?F+1:void 0;return ut(R,L)}class j{r;s;recovery;constructor(R,O,F){if(this.r=A("r",R),this.s=A("s",O),F!=null){if(T(),![0,1,2,3].includes(F))throw Error("invalid recovery id");this.recovery=F}Object.freeze(this)}static fromBytes(R,O=g.format){z(R,O);let F;if(O==="der"){let{r:te,s:ue}=Hn.toSig(ut(R));return new j(te,ue)}if(O==="recovered")F=R[0],O="compact",R=R.subarray(1);let L=y.signature/2,V=R.subarray(0,L),_=R.subarray(L,L*2);return new j(a.fromBytes(V),a.fromBytes(_),F)}static fromHex(R,O){return this.fromBytes(Nl(R),O)}assertRecovery(){let{recovery:R}=this;if(R==null)throw Error("invalid recovery id: must be present");return R}addRecoveryBit(R){return new j(this.r,this.s,R)}recoverPublicKey(R){let{r:O,s:F}=this,L=this.assertRecovery(),V=L===2||L===3?O+c:O;if(!s.isValid(V))throw Error("invalid recovery id: sig.r+curve.n != R.x");let _=s.toBytes(V),te=e.fromBytes(lr($5((L&1)===0),_)),ue=a.inv(V),C=Z(ut(R,void 0,"msgHash")),Se=a.create(-C*ue),Ee=a.create(F*ue),$e=e.BASE.multiplyUnsafe(Se).add(te.multiplyUnsafe(Ee));if($e.is0())throw Error("invalid recovery: point at infinify");return $e.assertValidity(),$e}hasHighS(){return v(this.s)}toBytes(R=g.format){if(bC(R),R==="der")return Nl(Hn.hexFromSig(this));let{r:O,s:F}=this,L=a.toBytes(O),V=a.toBytes(F);if(R==="recovered")return T(),lr(Uint8Array.of(this.assertRecovery()),L,V);return lr(L,V)}toHex(R){return zl(this.toBytes(R))}}Object.freeze(j.prototype),Object.freeze(j);let E=r.bits2int===void 0?function(O){if(O.length>8192)throw Error("input is too large");let F=Ta(O),L=O.length*8-l;return L>0?F>>BigInt(L):F}:r.bits2int,Z=r.bits2int_modN===void 0?function(O){return a.create(E(O))}:r.bits2int_modN,D=Zf(l);function H(R){return Yi("num < 2^"+l,R,gi,D),a.toBytes(R)}function X(R,O){return ut(R,void 0,"message"),O?ut(i(R),void 0,"prehashed message"):R}function M(R,O,F){let{lowS:L,prehash:V,extraEntropy:_}=yC(F,g);R=X(R,V);let te=Z(R),ue=a.fromBytes(O);if(!a.isValidNot0(ue))throw Error("invalid private key");let C=[H(ue),H(te)];if(_!=null&&_!==!1){let Ce=_===!0?n(y.secretKey):_;C.push(ut(Ce,void 0,"extraEntropy"))}let Se=lr(...C),Ee=te;function $e(Ce){let _e=E(Ce);if(!a.isValidNot0(_e))return;let ze=a.inv(_e),Ve=e.BASE.multiply(_e).toAffine(),Xe=a.create(Ve.x);if(Xe===gi)return;let St=a.create(ze*a.create(Ee+Xe*ue));if(St===gi)return;let Lt=(Ve.x===Xe?0:2)|Number(Ve.y&us),hr=St;if(L&&v(St))hr=a.neg(St),Lt^=1;return new j(Xe,hr,b?void 0:Lt)}return{seed:Se,k2sig:$e}}function P(R,O,F={}){let{seed:L,k2sig:V}=M(R,O,F);return s5(i.outputLen,a.BYTES,o)(L,V).toBytes(F.format)}function N(R,O,F,L={}){let{lowS:V,prehash:_,format:te}=yC(L,g);if(F=ut(F,void 0,"publicKey"),O=X(O,_),!Dl(R)){let ue=R instanceof j?", use sig.toBytes()":"";throw Error("verify expects Uint8Array signature"+ue)}z(R,te);try{let ue=j.fromBytes(R,te),C=e.fromBytes(F);if(V&&ue.hasHighS())return!1;let{r:Se,s:Ee}=ue,$e=Z(O),Ce=a.inv(Ee),_e=a.create($e*Ce),ze=a.create(Se*Ce),Ve=e.BASE.multiplyUnsafe(_e).add(C.multiplyUnsafe(ze));if(Ve.is0())return!1;return a.create(Ve.x)===Se}catch(ue){return!1}}function I(R,O,F={}){let{prehash:L}=yC(F,g);return O=X(O,L),j.fromBytes(R,"recovered").recoverPublicKey(O).toBytes()}return Object.freeze({keygen:u,getPublicKey:d,getSharedSecret:p,utils:m,lengths:y,Point:e,sign:P,verify:N,recoverPublicKey:I,Signature:j,hash:i})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var xxe=(()=>({p:BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),h:BigInt(1),a:BigInt("0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc"),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")}))();var Sxe=C5(xxe),ql=R5(Sxe,Rt);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var ds=BigInt(0),Wr=BigInt(1),xC=BigInt(2),wxe=BigInt(8);function vxe(e,t,r,i){let n=e.sqr(r),o=e.sqr(i),s=e.add(e.mul(t.a,n),o),a=e.add(e.ONE,e.mul(t.d,e.mul(n,o)));return e.eql(s,a)}function P5(e,t={}){let r=t,i=wb("edwards",e,r,r.FpFnLE),{Fp:n,Fn:o}=i,s=i.CURVE,{h:a}=s;En(r,{},{uvRatio:"function"});let c=xC<<BigInt(o.BYTES*8)-Wr,l=(g)=>n.create(g),u=r.uvRatio===void 0?(g,b)=>{try{return{isValid:!0,value:n.sqrt(n.div(g,b))}}catch(v){return{isValid:!1,value:ds}}}:r.uvRatio;if(!vxe(n,s,s.Gx,s.Gy))throw Error("bad curve params: generator point");function d(g,b,v=!1){let A=v?Wr:ds;return Yi("coordinate "+g,b,A,c),b}function p(g){if(!(g instanceof m))throw Error("EdwardsPoint expected")}class m{static BASE=new m(s.Gx,s.Gy,Wr,l(s.Gx*s.Gy));static ZERO=new m(ds,Wr,Wr,ds);static Fp=n;static Fn=o;X;Y;Z;T;constructor(g,b,v,A){this.X=d("x",g),this.Y=d("y",b),this.Z=d("z",v,!0),this.T=d("t",A),Object.freeze(this)}static CURVE(){return s}static fromAffine(g){if(g instanceof m)throw Error("extended point not allowed");let{x:b,y:v}=g||{};return d("x",b),d("y",v),new m(b,v,Wr,l(b*v))}static fromBytes(g,b=!1){let v=n.BYTES,{a:A,d:T}=s;g=ls(ut(g,v,"point")),Qi(b,"zip215");let z=ls(g),j=g[v-1];z[v-1]=j&-129;let E=Zn(z),Z=b?c:n.ORDER;Yi("point.y",E,ds,Z);let D=l(E*E),H=l(D-Wr),X=l(T*D-A),{isValid:M,value:P}=u(H,X);if(!M)throw Error("bad point: invalid y coordinate");let N=(P&Wr)===Wr,I=(j&128)!==0;if(!b&&P===ds&&I)throw Error("bad point: x=0 and x_0=1");if(I!==N)P=l(-P);return m.fromAffine({x:P,y:E})}static fromHex(g,b=!1){return m.fromBytes(Nl(g),b)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(g=8,b=!0){if(y.createCache(this,g),!b)this.multiply(xC);return this}assertValidity(){let g=this,{a:b,d:v}=s;if(g.is0())throw Error("bad point: ZERO");let{X:A,Y:T,Z:z,T:j}=g,E=l(A*A),Z=l(T*T),D=l(z*z),H=l(D*D),X=l(E*b),M=l(D*l(X+Z)),P=l(H+l(v*l(E*Z)));if(M!==P)throw Error("bad point: equation left != right (1)");let N=l(A*T),I=l(z*j);if(N!==I)throw Error("bad point: equation left != right (2)")}equals(g){p(g);let{X:b,Y:v,Z:A}=this,{X:T,Y:z,Z:j}=g,E=l(b*j),Z=l(T*A),D=l(v*j),H=l(z*A);return E===Z&&D===H}is0(){return this.equals(m.ZERO)}negate(){return new m(l(-this.X),this.Y,this.Z,l(-this.T))}double(){let{a:g}=s,{X:b,Y:v,Z:A}=this,T=l(b*b),z=l(v*v),j=l(xC*l(A*A)),E=l(g*T),Z=b+v,D=l(l(Z*Z)-T-z),H=E+z,X=H-j,M=E-z,P=l(D*X),N=l(H*M),I=l(D*M),R=l(X*H);return new m(P,N,R,I)}add(g){p(g);let{a:b,d:v}=s,{X:A,Y:T,Z:z,T:j}=this,{X:E,Y:Z,Z:D,T:H}=g,X=l(A*E),M=l(T*Z),P=l(j*v*H),N=l(z*D),I=l((A+T)*(E+Z)-X-M),R=N-P,O=N+P,F=l(M-b*X),L=l(I*R),V=l(O*F),_=l(I*F),te=l(R*O);return new m(L,V,te,_)}subtract(g){return p(g),this.add(g.negate())}multiply(g){if(!o.isValidNot0(g))throw RangeError("invalid scalar: expected 1 <= sc < curve.n");let{p:b,f:v}=y.cached(this,g,(A)=>Oa(m,A));return Oa(m,[b,v])[0]}multiplyUnsafe(g){if(!o.isValid(g))throw RangeError("invalid scalar: expected 0 <= sc < curve.n");if(g===ds)return m.ZERO;if(this.is0()||g===Wr)return this;return y.unsafe(this,g,(b)=>Oa(m,b))}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){return y.unsafe(this,s.n).is0()}toAffine(g){let b=this,v=g,{X:A,Y:T,Z:z}=b,j=b.is0();if(v==null)v=j?wxe:n.inv(z);let E=l(A*v),Z=l(T*v),D=n.mul(z,v);if(j)return{x:ds,y:Wr};if(D!==Wr)throw Error("invZ was invalid");return{x:E,y:Z}}clearCofactor(){if(a===Wr)return this;return this.multiplyUnsafe(a)}toBytes(){let{x:g,y:b}=this.toAffine(),v=n.toBytes(b);return v[v.length-1]|=g&Wr?128:0,v}toHex(){return zl(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let y=new Jf(m,o.BITS);if(o.BITS>=8)m.BASE.precompute(8);return Object.freeze(m.prototype),Object.freeze(m),m}class SC{static BASE;static ZERO;static Fp;static Fn;ep;constructor(e){this.ep=e}static fromBytes(e){cC()}static fromHex(e){cC()}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 zl(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}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var Gf=BigInt(0),Ul=BigInt(1),_b=BigInt(2);function _xe(e){return En(e,{P:"bigint",type:"string",adjustScalarBytes:"function",powPminus2:"function"},{randomBytes:"function"}),Object.freeze({...e})}function z5(e){let t=_xe(e),{P:r,type:i,adjustScalarBytes:n,powPminus2:o,randomBytes:s}=t,a=i==="x25519";if(!a&&i!=="x448")throw Error("invalid type");let c=s===void 0?Ll:s,l=a?255:448,u=a?32:56,d=a?BigInt(9):BigInt(5),p=a?BigInt(121665):BigInt(39081),m=a?_b**BigInt(254):_b**BigInt(447),y=a?BigInt(8)*_b**BigInt(251)-Ul:BigInt(4)*_b**BigInt(445)-Ul,g=m+y+Ul,b=(I)=>gt(I,r),v=A(d);function A(I){return Ff(b(I),u)}function T(I){let R=ls(ut(I,u,"uCoordinate"));if(a)R[31]&=127;return b(Zn(R))}function z(I){return Zn(n(ls(ut(I,u,"scalar"))))}function j(I,R){let O=X(T(R),z(I));if(O===Gf)throw Error("invalid private or public key received");return A(O)}function E(I){return j(I,v)}let Z=E,D=j;function H(I,R,O){let F=b(I*(R-O));return R=b(R-F),O=b(O+F),{x_2:R,x_3:O}}function X(I,R){Yi("u",I,Gf,r),Yi("scalar",R,m,g);let O=R,F=I,L=Ul,V=Gf,_=I,te=Ul,ue=Gf;for(let Se=BigInt(l-1);Se>=Gf;Se--){let Ee=O>>Se&Ul;ue^=Ee,{x_2:L,x_3:_}=H(ue,L,_),{x_2:V,x_3:te}=H(ue,V,te),ue=Ee;let $e=L+V,Ce=b($e*$e),_e=L-V,ze=b(_e*_e),Ve=Ce-ze,Xe=_+te,St=_-te,Lt=b(St*$e),hr=b(Xe*_e),Yr=Lt+hr,Xr=Lt-hr;_=b(Yr*Yr),te=b(F*b(Xr*Xr)),L=b(Ce*ze),V=b(Ve*(Ce+b(p*Ve)))}({x_2:L,x_3:_}=H(ue,L,_)),{x_2:V,x_3:te}=H(ue,V,te);let C=o(V);return b(L*C)}let M={secretKey:u,publicKey:u,seed:u},P=(I)=>(I=I===void 0?c(u):I,ut(I,M.seed,"seed"),I),N={randomSecretKey:P};return Object.freeze(M),Object.freeze(N),Object.freeze({keygen:Vf(P,Z),getSharedSecret:D,getPublicKey:Z,scalarMult:j,scalarMultBase:E,utils:N,GuBytes:v.slice(),lengths:M})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var kxe=BigInt(0),eo=BigInt(1),N5=BigInt(2),Exe=BigInt(3),Ixe=BigInt(5),Axe=BigInt(8),Pa=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),kC=(()=>({p:Pa,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:Axe,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")}))();function B5(e){let t=BigInt(10),r=BigInt(20),i=BigInt(40),n=BigInt(80),o=Pa,a=e*e%o*e%o,c=In(a,N5,o)*a%o,l=In(c,eo,o)*e%o,u=In(l,Ixe,o)*l%o,d=In(u,t,o)*u%o,p=In(d,r,o)*d%o,m=In(p,i,o)*p%o,y=In(m,n,o)*m%o,g=In(y,n,o)*m%o,b=In(g,t,o)*u%o;return{pow_p_5_8:In(b,N5,o)*e%o,b2:a}}function Txe(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var wC=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function EC(e,t){let r=Pa,i=gt(t*t*t,r),n=gt(i*i*t,r),o=B5(e*n).pow_p_5_8,s=gt(e*i*o,r),a=gt(t*s*s,r),c=s,l=gt(s*wC,r),u=a===e,d=a===gt(-e,r),p=a===gt(-e*wC,r);if(u)s=c;if(d||p)s=l;if(Xi(s,r))s=gt(-s,r);return{isValid:u||d,value:s}}var Ra=P5(kC,{uvRatio:EC}),fs=(()=>Ra.Fp)(),j5=(()=>Ra.Fn)();var kb=(()=>{let e=Pa;return z5({P:e,type:"x25519",powPminus2:(t)=>{let{pow_p_5_8:r,b2:i}=B5(t);return gt(In(r,Exe,e)*i,e)},adjustScalarBytes:Txe})})();var vC=wC,Cxe=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),$xe=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),Oxe=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),Rxe=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),D5=(e)=>EC(eo,e),Pxe=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),_C=(e)=>fs.create(Zn(e)&Pxe);function L5(e){let{d:t}=kC,r=Pa,i=(v)=>fs.create(v),n=i(vC*e*e),o=i((n+eo)*Oxe),s=BigInt(-1),a=i((s-t*n)*i(n+t)),{isValid:c,value:l}=EC(o,a),u=i(l*e);if(!Xi(u,r))u=i(-u);if(!c)l=u;if(!c)s=n;let d=i(s*(n-eo)*Rxe-a),p=l*l,m=i((l+l)*a),y=i(d*Cxe),g=i(eo-p),b=i(eo+p);return new Ra(i(m*b),i(g*y),i(y*b),i(m*g))}class qr extends SC{static BASE=(()=>new qr(Ra.BASE))();static ZERO=(()=>new qr(Ra.ZERO))();static Fp=(()=>fs)();static Fn=(()=>j5)();constructor(e){super(e)}static fromAffine(e){return new qr(Ra.fromAffine(e))}assertSame(e){if(!(e instanceof qr))throw Error("RistrettoPoint expected")}init(e){return new qr(e)}static fromBytes(e){or(e,32);let{a:t,d:r}=kC,i=Pa,n=(T)=>fs.create(T),o=_C(e);if(!o5(fs.toBytes(o),e)||Xi(o,i))throw Error("invalid ristretto255 encoding 1");let s=n(o*o),a=n(eo+t*s),c=n(eo-t*s),l=n(a*a),u=n(c*c),d=n(t*r*l-u),{isValid:p,value:m}=D5(n(d*u)),y=n(m*c),g=n(m*y*d),b=n((o+o)*y);if(Xi(b,i))b=n(-b);let v=n(a*g),A=n(b*v);if(!p||Xi(A,i)||v===kxe)throw Error("invalid ristretto255 encoding 2");return new qr(new Ra(b,v,eo,A))}static fromHex(e){return qr.fromBytes(bf(e))}toBytes(){let{X:e,Y:t,Z:r,T:i}=this.ep,n=Pa,o=(g)=>fs.create(g),s=o(o(r+t)*o(r-t)),a=o(e*t),c=o(a*a),{value:l}=D5(o(s*c)),u=o(l*s),d=o(l*a),p=o(u*d*i),m;if(Xi(i*p,n)){let g=o(t*vC),b=o(e*vC);e=g,t=b,m=o(u*$xe)}else m=d;if(Xi(e*p,n))t=o(-t);let y=o((r-t)*m);if(Xi(y,n))y=o(-y);return fs.toBytes(y)}equals(e){this.assertSame(e);let{X:t,Y:r}=this.ep,{X:i,Y:n}=e.ep,o=(c)=>fs.create(c),s=o(t*n)===o(r*i),a=o(r*n)===o(t*i);return s||a}is0(){return this.equals(qr.ZERO)}}Object.freeze(qr.BASE);Object.freeze(qr.ZERO);Object.freeze(qr.prototype);Object.freeze(qr);var zxe=Object.freeze({Point:qr,hashToCurve(e,t){let r=t?.DST===void 0?"ristretto255_XMD:SHA-512_R255MAP_RO_":t.DST,i=gC(e,r,64,My);return zxe.deriveToCurve(i)},hashToScalar(e,t={DST:E5}){let r=gC(e,t.DST,64,My);return j5.create(Zn(r))},deriveToCurve(e){or(e,64);let t=_C(e.subarray(0,32)),r=L5(t),i=_C(e.subarray(32,64)),n=L5(i);return new qr(r.add(n))}});var q5=!1,Nxe=!1;async function U5(e,t){if(Nxe)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 Eb(e,t){return await U5(async()=>{let r=IC(e)?e:await Lxe(e),i=await crypto.subtle.importKey("raw",Bxe(t),{name:"X25519"},q5,[]);return new Uint8Array(await crypto.subtle.deriveBits({name:"X25519",public:i},r,256))},()=>{if(IC(e))throw Error("CryptoKey provided but X25519 WebCrypto is not supported");return kb.scalarMult(e,t)})}async function Qf(e){return await U5(async()=>Eb(e,kb.GuBytes),()=>{if(IC(e))throw Error("CryptoKey provided but X25519 WebCrypto is not supported");return kb.scalarMultBase(e)})}var Dxe=new Uint8Array([48,46,2,1,0,48,5,6,3,43,101,110,4,34,4,32]);async function Lxe(e){if(e.length!==32)throw Error("X25519 private key must be 32 bytes");let t=new Uint8Array([...Dxe,...e]);return crypto.subtle.importKey("pkcs8",t,{name:"X25519"},q5,["deriveBits"])}function IC(e){return typeof CryptoKey<"u"&&e instanceof CryptoKey}function Bxe(e){return e}class AC{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),qxe(za(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=za(e),null;this.buf=r.value}}close(){return this.s.releaseLock(),{rest:this.buf,transcript:za(this.transcript)}}}function qxe(e){return e.forEach((t)=>{if(t<32||t>126)throw Error("invalid non-ASCII byte in header")}),new TextDecoder().decode(e)}function za(e){let t=e.reduce((n,o)=>n+o.length,0),r=new Uint8Array(t),i=0;for(let n of e)r.set(n,i),i+=n.length;return r}function Ml(e,...t){return e.pipeThrough(new TransformStream({start(r){for(let i of t)r.enqueue(i)}}))}function Ib(e){return new ReadableStream({start(t){t.enqueue(e),t.close()}})}async function TC(e){if(!(e instanceof ReadableStream))throw Error("readAll expects a ReadableStream<Uint8Array>");return new Uint8Array(await new Response(e).arrayBuffer())}async function M5(e){if(!(e instanceof ReadableStream))throw Error("readAllString expects a ReadableStream<Uint8Array>");return await new Response(e).text()}async function F5(e,t){let r=e.getReader(),i=[],n=0;while(n<t){let{done:c,value:l}=await r.read();if(c)throw Error("stream ended before reading "+t.toString()+" bytes");i.push(l),n+=l.length}r.releaseLock();let o=za(i),s=o.subarray(0,t),a=Ml(e,o.subarray(t));return{data:s,rest:a}}class yi{args;body;constructor(e,t){this.args=e,this.body=t}}async function Uxe(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 o of r)if(o.length===0)throw Error("invalid stanza");let i=[];for(;;){let o=await e.readLine();if(o===null)throw Error("invalid stanza");let s=wr.decode(o);if(s.length>48)throw Error("invalid stanza");if(i.push(s),s.length<48)break}let n=za(i);return{s:new yi(r,n)}}async function Z5(e){let t=new AC(e),r=await t.readLine();if(r!=="age-encryption.org/v1")throw Error("invalid version "+(r??"line"));let i=[];for(;;){let{s:n,next:o}=await Uxe(t);if(n!==void 0){i.push(n);continue}if(!o.startsWith("--- "))throw Error("invalid header");let s=wr.decode(o.slice(4)),{rest:a,transcript:c}=t.close(),l=c.slice(0,c.length-1-o.length+3);return{stanzas:i,headerNoMAC:l,MAC:s,headerSize:c.length,rest:Ml(e,a)}}}function CC(e){let t=[];t.push(`age-encryption.org/v1
835
834
  `);for(let r of e){t.push("-> "+r.args.join(" ")+`
836
835
  `);for(let i=0;i<r.body.length;i+=48){let n=i+48;if(n>r.body.length)n=r.body.length;t.push(wr.encode(r.body.subarray(i,n))+`
837
836
  `)}if(r.body.length%48===0)t.push(`
838
837
  `)}return t.push("---"),new TextEncoder().encode(t.join(""))}function H5(e,t){return za([CC(e),new TextEncoder().encode(" "+wr.encode(t)+`
839
- `)])}function RC(){return K5()}function K5(){let e=Fi(32),t=dn.encodeFromBytes("AGE-SECRET-KEY-",e).toUpperCase();return Promise.resolve(t)}async function Tb(e){let t;if(V5(e))t=e;else if(e.startsWith("AGE-SECRET-KEY-PQ-1")){let i=dn.decodeToBytes(e);if(i.prefix.toUpperCase()!=="AGE-SECRET-KEY-PQ-"||i.bytes.length!==32)throw Error("invalid identity");let n=mb.getPublicKey(i.bytes);return dn.encode("age1pq",dn.toWords(n),!1)}else{let i=dn.decodeToBytes(e);if(!e.startsWith("AGE-SECRET-KEY-1")||i.prefix.toUpperCase()!=="AGE-SECRET-KEY-"||i.bytes.length!==32)throw Error("invalid identity");t=i.bytes}let r=await Qf(t);return dn.encodeFromBytes("age",r)}class PC{recipient;constructor(e){let t=dn.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}=mb.encapsulate(this.recipient),i=new TextEncoder().encode("age-encryption.org/mlkem768x25519"),{key:n,nonce:o}=Cb(J5,r,i),s=vn(n,o).encrypt(e);return[new yi(["mlkem768x25519",wr.encode(t)],s)]}}class zC{identity;constructor(e){let t=dn.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=wr.decode(t.args[1]);if(r.length!==1120)throw Error("invalid mlkem768x25519 stanza");if(t.body.length!==32)throw Error("invalid mlkem768x25519 stanza");let i=mb.decapsulate(r,this.identity),n=new TextEncoder().encode("age-encryption.org/mlkem768x25519"),{key:o,nonce:s}=Cb(J5,i,n);try{return vn(o,s).decrypt(t.body)}catch{continue}}return null}}var J5=25722,Fxe=80,$C=16;function Cb(e,t,r){let i=Zxe(e),n=Ab(i,void 0,"psk_id_hash",new Uint8Array(0)),o=Ab(i,void 0,"info_hash",r),s=new Uint8Array(1+n.length+o.length);s[0]=0,s.set(n,1),s.set(o,1+n.length);let a=Ab(i,t,"secret",new Uint8Array(0)),c=OC(i,a,"key",s,32),l=OC(i,a,"base_nonce",s,12);return{key:c,nonce:l}}function Zxe(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 Ab(e,t,r,i){let n=new Uint8Array(7+e.length+r.length+i.length),o=0;return n.set(new TextEncoder().encode("HPKE-v1"),o),o+=7,n.set(e,o),o+=e.length,n.set(new TextEncoder().encode(r),o),o+=r.length,n.set(i,o),xf(Rt,n,t)}function OC(e,t,r,i,n){let o=new Uint8Array(9+e.length+r.length+i.length),s=0;return o[s]=n>>8&255,o[s+1]=n&255,s+=2,o.set(new TextEncoder().encode("HPKE-v1"),s),s+=7,o.set(e,s),s+=e.length,o.set(new TextEncoder().encode(r),s),s+=r.length,o.set(i,s),hT(Rt,t,o,n)}function Hxe(e){if(e.length!==ql.lengths.publicKeyUncompressed)e=ql.Point.fromBytes(e).toBytes(!1);let t=ql.utils.randomSecretKey(),r=ql.getPublicKey(t,!1),i=ql.getSharedSecret(t,e,!0).subarray(1),n=new Uint8Array(r.length+e.length);n.set(r,0),n.set(e,r.length);let o=new Uint8Array(5);o.set(new TextEncoder().encode("KEM"),0),o[3]=$C>>8,o[4]=$C&255;let s=Ab(o,void 0,"eae_prk",i),a=OC(o,s,"shared_secret",n,32);return{encapsulatedKey:r,sharedSecret:a}}class NC{recipient;constructor(e){let t=dn.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}=Hxe(this.recipient),i=new TextEncoder().encode("age-encryption.org/p256tag"),n=(()=>{let c=Rt(this.recipient).subarray(0,4),l=new Uint8Array(t.length+c.length);return l.set(t,0),l.set(c,t.length),xf(Rt,l,i).subarray(0,4)})(),{key:o,nonce:s}=Cb($C,r,i),a=vn(o,s).encrypt(e);return[new yi(["p256tag",wr.encode(n),wr.encode(t)],a)]}}class DC{recipient;constructor(e){let t=dn.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}=n5.encapsulate(this.recipient),i=new TextEncoder().encode("age-encryption.org/mlkem768p256tag"),n=(()=>{let c=Rt(this.recipient.subarray(1184)).subarray(0,4),l=new Uint8Array(t.length+c.length);return l.set(t,0),l.set(c,t.length),xf(Rt,l,i).subarray(0,4)})(),{key:o,nonce:s}=Cb(Fxe,r,i),a=vn(o,s).encrypt(e);return[new yi(["mlkem768p256tag",wr.encode(n),wr.encode(t)],a)]}}class LC{recipient;constructor(e){let t=dn.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=Fi(32),r=await Qf(t),i=await Eb(t,this.recipient),n=new Uint8Array(r.length+this.recipient.length);n.set(r),n.set(this.recipient,r.length);let o=new TextEncoder().encode("age-encryption.org/v1/X25519"),s=Wo(Rt,i,n,o,32);return[new yi(["X25519",wr.encode(r)],qC(e,s))]}}class $b{identity;recipient;constructor(e){if(V5(e)){this.identity=e,this.recipient=Qf(e);return}let t=dn.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=Qf(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=wr.decode(t.args[1]);if(r.length!==32)throw Error("invalid X25519 stanza");let i=await Eb(this.identity,r),n=await this.recipient,o=new Uint8Array(r.length+n.length);o.set(r),o.set(n,r.length);let s=new TextEncoder().encode("age-encryption.org/v1/X25519"),a=Wo(Rt,i,o,s,32),c=UC(t.body,a);if(c!==null)return c}return null}}class BC{passphrase;logN;constructor(e,t){this.passphrase=e,this.logN=t}wrapFileKey(e){let t=Fi(16),r="age-encryption.org/v1/scrypt",i=new Uint8Array(44);i.set(new TextEncoder().encode("age-encryption.org/v1/scrypt")),i.set(t,28);let n=IT(this.passphrase,i,{N:2**this.logN,r:8,p:1,dkLen:32});return[new yi(["scrypt",wr.encode(t),this.logN.toString()],qC(e,n))]}}class jC{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=wr.decode(t.args[1]);if(r.length!==16)throw Error("invalid scrypt stanza");let i=Number(t.args[2]);if(i>20)throw Error("scrypt work factor is too high");let n="age-encryption.org/v1/scrypt",o=new Uint8Array(n.length+16);o.set(new TextEncoder().encode(n)),o.set(r,n.length);let s=IT(this.passphrase,o,{N:2**i,r:8,p:1,dkLen:32}),a=UC(t.body,s);if(a!==null)return a}return null}}function qC(e,t){let r=new Uint8Array(12);return vn(t,r).encrypt(e)}function UC(e,t){if(e.length!==32)throw Error("invalid stanza");let r=new Uint8Array(12);try{return vn(t,r).decrypt(e)}catch{return null}}function V5(e){return typeof CryptoKey<"u"&&e instanceof CryptoKey}var Na=16,FC=(()=>65536)(),MC=(()=>FC+Na)();function W5(e){let t=new Uint8Array(12),r=()=>{for(let s=t.length-2;s>=0;s--)if(t[s]++,t[s]!==0)break},i=!0,n=new Uint8Array(MC),o=0;return new TransformStream({transform(s,a){while(s.length>0){if(o===n.length){let l=vn(e,t).decrypt(n);a.enqueue(l),r(),o=0,i=!1}let c=Math.min(n.length-o,s.length);n.set(s.subarray(0,c),o),o+=c,s=s.subarray(c)}},flush(s){t[11]=1;let a=vn(e,t).decrypt(n.subarray(0,o));if(!i&&a.length===0)throw Error("final chunk is empty");s.enqueue(a)}})}function G5(e){if(e<Na)throw Error("ciphertext is too small");if(e===Na)return 0;let t=Math.floor(e/MC),r=e%MC;if(0<r&&r<=Na)throw Error("ciphertext size is invalid");let i=e;return i-=t*Na,i-=r>0?Na:0,i}function Q5(e){let t=new Uint8Array(12),r=()=>{for(let o=t.length-2;o>=0;o--)if(t[o]++,t[o]!==0)break},i=new Uint8Array(FC),n=0;return new TransformStream({transform(o,s){while(o.length>0){if(n===i.length){let c=vn(e,t).encrypt(i);s.enqueue(c),r(),n=0}let a=Math.min(i.length-n,o.length);i.set(o.subarray(0,a),n),n+=a,o=o.subarray(a)}},flush(o){t[11]=1;let s=vn(e,t).encrypt(i.subarray(0,n));o.enqueue(s)}})}function Y5(e){let t=Math.max(1,Math.ceil(e/FC));return e+Na*t}var Yf={};tr(Yf,{decode:()=>Jxe,encode:()=>Kxe});function Kxe(e){let t=[];t.push(`-----BEGIN AGE ENCRYPTED FILE-----
838
+ `)])}function RC(){return K5()}function K5(){let e=Fi(32),t=dn.encodeFromBytes("AGE-SECRET-KEY-",e).toUpperCase();return Promise.resolve(t)}async function Tb(e){let t;if(V5(e))t=e;else if(e.startsWith("AGE-SECRET-KEY-PQ-1")){let i=dn.decodeToBytes(e);if(i.prefix.toUpperCase()!=="AGE-SECRET-KEY-PQ-"||i.bytes.length!==32)throw Error("invalid identity");let n=mb.getPublicKey(i.bytes);return dn.encode("age1pq",dn.toWords(n),!1)}else{let i=dn.decodeToBytes(e);if(!e.startsWith("AGE-SECRET-KEY-1")||i.prefix.toUpperCase()!=="AGE-SECRET-KEY-"||i.bytes.length!==32)throw Error("invalid identity");t=i.bytes}let r=await Qf(t);return dn.encodeFromBytes("age",r)}class PC{recipient;constructor(e){let t=dn.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}=mb.encapsulate(this.recipient),i=new TextEncoder().encode("age-encryption.org/mlkem768x25519"),{key:n,nonce:o}=Cb(J5,r,i),s=vn(n,o).encrypt(e);return[new yi(["mlkem768x25519",wr.encode(t)],s)]}}class zC{identity;constructor(e){let t=dn.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=wr.decode(t.args[1]);if(r.length!==1120)throw Error("invalid mlkem768x25519 stanza");if(t.body.length!==32)throw Error("invalid mlkem768x25519 stanza");let i=mb.decapsulate(r,this.identity),n=new TextEncoder().encode("age-encryption.org/mlkem768x25519"),{key:o,nonce:s}=Cb(J5,i,n);try{return vn(o,s).decrypt(t.body)}catch{continue}}return null}}var J5=25722,Mxe=80,$C=16;function Cb(e,t,r){let i=Fxe(e),n=Ab(i,void 0,"psk_id_hash",new Uint8Array(0)),o=Ab(i,void 0,"info_hash",r),s=new Uint8Array(1+n.length+o.length);s[0]=0,s.set(n,1),s.set(o,1+n.length);let a=Ab(i,t,"secret",new Uint8Array(0)),c=OC(i,a,"key",s,32),l=OC(i,a,"base_nonce",s,12);return{key:c,nonce:l}}function Fxe(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 Ab(e,t,r,i){let n=new Uint8Array(7+e.length+r.length+i.length),o=0;return n.set(new TextEncoder().encode("HPKE-v1"),o),o+=7,n.set(e,o),o+=e.length,n.set(new TextEncoder().encode(r),o),o+=r.length,n.set(i,o),xf(Rt,n,t)}function OC(e,t,r,i,n){let o=new Uint8Array(9+e.length+r.length+i.length),s=0;return o[s]=n>>8&255,o[s+1]=n&255,s+=2,o.set(new TextEncoder().encode("HPKE-v1"),s),s+=7,o.set(e,s),s+=e.length,o.set(new TextEncoder().encode(r),s),s+=r.length,o.set(i,s),hT(Rt,t,o,n)}function Zxe(e){if(e.length!==ql.lengths.publicKeyUncompressed)e=ql.Point.fromBytes(e).toBytes(!1);let t=ql.utils.randomSecretKey(),r=ql.getPublicKey(t,!1),i=ql.getSharedSecret(t,e,!0).subarray(1),n=new Uint8Array(r.length+e.length);n.set(r,0),n.set(e,r.length);let o=new Uint8Array(5);o.set(new TextEncoder().encode("KEM"),0),o[3]=$C>>8,o[4]=$C&255;let s=Ab(o,void 0,"eae_prk",i),a=OC(o,s,"shared_secret",n,32);return{encapsulatedKey:r,sharedSecret:a}}class NC{recipient;constructor(e){let t=dn.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}=Zxe(this.recipient),i=new TextEncoder().encode("age-encryption.org/p256tag"),n=(()=>{let c=Rt(this.recipient).subarray(0,4),l=new Uint8Array(t.length+c.length);return l.set(t,0),l.set(c,t.length),xf(Rt,l,i).subarray(0,4)})(),{key:o,nonce:s}=Cb($C,r,i),a=vn(o,s).encrypt(e);return[new yi(["p256tag",wr.encode(n),wr.encode(t)],a)]}}class DC{recipient;constructor(e){let t=dn.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}=n5.encapsulate(this.recipient),i=new TextEncoder().encode("age-encryption.org/mlkem768p256tag"),n=(()=>{let c=Rt(this.recipient.subarray(1184)).subarray(0,4),l=new Uint8Array(t.length+c.length);return l.set(t,0),l.set(c,t.length),xf(Rt,l,i).subarray(0,4)})(),{key:o,nonce:s}=Cb(Mxe,r,i),a=vn(o,s).encrypt(e);return[new yi(["mlkem768p256tag",wr.encode(n),wr.encode(t)],a)]}}class LC{recipient;constructor(e){let t=dn.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=Fi(32),r=await Qf(t),i=await Eb(t,this.recipient),n=new Uint8Array(r.length+this.recipient.length);n.set(r),n.set(this.recipient,r.length);let o=new TextEncoder().encode("age-encryption.org/v1/X25519"),s=Wo(Rt,i,n,o,32);return[new yi(["X25519",wr.encode(r)],qC(e,s))]}}class $b{identity;recipient;constructor(e){if(V5(e)){this.identity=e,this.recipient=Qf(e);return}let t=dn.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=Qf(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=wr.decode(t.args[1]);if(r.length!==32)throw Error("invalid X25519 stanza");let i=await Eb(this.identity,r),n=await this.recipient,o=new Uint8Array(r.length+n.length);o.set(r),o.set(n,r.length);let s=new TextEncoder().encode("age-encryption.org/v1/X25519"),a=Wo(Rt,i,o,s,32),c=UC(t.body,a);if(c!==null)return c}return null}}class BC{passphrase;logN;constructor(e,t){this.passphrase=e,this.logN=t}wrapFileKey(e){let t=Fi(16),r="age-encryption.org/v1/scrypt",i=new Uint8Array(44);i.set(new TextEncoder().encode("age-encryption.org/v1/scrypt")),i.set(t,28);let n=IT(this.passphrase,i,{N:2**this.logN,r:8,p:1,dkLen:32});return[new yi(["scrypt",wr.encode(t),this.logN.toString()],qC(e,n))]}}class jC{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=wr.decode(t.args[1]);if(r.length!==16)throw Error("invalid scrypt stanza");let i=Number(t.args[2]);if(i>20)throw Error("scrypt work factor is too high");let n="age-encryption.org/v1/scrypt",o=new Uint8Array(n.length+16);o.set(new TextEncoder().encode(n)),o.set(r,n.length);let s=IT(this.passphrase,o,{N:2**i,r:8,p:1,dkLen:32}),a=UC(t.body,s);if(a!==null)return a}return null}}function qC(e,t){let r=new Uint8Array(12);return vn(t,r).encrypt(e)}function UC(e,t){if(e.length!==32)throw Error("invalid stanza");let r=new Uint8Array(12);try{return vn(t,r).decrypt(e)}catch{return null}}function V5(e){return typeof CryptoKey<"u"&&e instanceof CryptoKey}var Na=16,FC=(()=>65536)(),MC=(()=>FC+Na)();function W5(e){let t=new Uint8Array(12),r=()=>{for(let s=t.length-2;s>=0;s--)if(t[s]++,t[s]!==0)break},i=!0,n=new Uint8Array(MC),o=0;return new TransformStream({transform(s,a){while(s.length>0){if(o===n.length){let l=vn(e,t).decrypt(n);a.enqueue(l),r(),o=0,i=!1}let c=Math.min(n.length-o,s.length);n.set(s.subarray(0,c),o),o+=c,s=s.subarray(c)}},flush(s){t[11]=1;let a=vn(e,t).decrypt(n.subarray(0,o));if(!i&&a.length===0)throw Error("final chunk is empty");s.enqueue(a)}})}function G5(e){if(e<Na)throw Error("ciphertext is too small");if(e===Na)return 0;let t=Math.floor(e/MC),r=e%MC;if(0<r&&r<=Na)throw Error("ciphertext size is invalid");let i=e;return i-=t*Na,i-=r>0?Na:0,i}function Q5(e){let t=new Uint8Array(12),r=()=>{for(let o=t.length-2;o>=0;o--)if(t[o]++,t[o]!==0)break},i=new Uint8Array(FC),n=0;return new TransformStream({transform(o,s){while(o.length>0){if(n===i.length){let c=vn(e,t).encrypt(i);s.enqueue(c),r(),n=0}let a=Math.min(i.length-n,o.length);i.set(o.subarray(0,a),n),n+=a,o=o.subarray(a)}},flush(o){t[11]=1;let s=vn(e,t).encrypt(i.subarray(0,n));o.enqueue(s)}})}function Y5(e){let t=Math.max(1,Math.ceil(e/FC));return e+Na*t}var Yf={};tr(Yf,{decode:()=>Kxe,encode:()=>Hxe});function Hxe(e){let t=[];t.push(`-----BEGIN AGE ENCRYPTED FILE-----
840
839
  `);for(let r=0;r<e.length;r+=48){let i=r+48;if(i>e.length)i=e.length;t.push(vT.encode(e.subarray(r,i))+`
841
840
  `)}return t.push(`-----END AGE ENCRYPTED FILE-----
842
- `),t.join("")}function Jxe(e){let t=e.trim().replaceAll(`\r
841
+ `),t.join("")}function Kxe(e){let t=e.trim().replaceAll(`\r
843
842
  `,`
844
843
  `).split(`
845
- `);if(t.shift()!=="-----BEGIN AGE ENCRYPTED FILE-----")throw Error("invalid header");if(t.pop()!=="-----END AGE ENCRYPTED FILE-----")throw Error("invalid footer");function r(i,n){if(i===t.length-1)return n.length>0&&n.length<=64&&n.length%4===0;return n.length===64}if(!t.every((i,n)=>r(n,i)))throw Error("invalid line length");if(!t.every((i)=>/^[A-Za-z0-9+/=]+$/.test(i)))throw Error("invalid base64");return vT.decode(t.join(""))}class ZC{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 PC(e));else if(e.startsWith("age1tag1"))this.recipients.push(new NC(e));else if(e.startsWith("age1tagpq1"))this.recipients.push(new DC(e));else if(e.startsWith("age1"))this.recipients.push(new LC(e));else throw Error("unrecognized recipient type");else this.recipients.push(e)}async encrypt(e){let t=Fi(16),r=[],i=this.recipients;if(this.passphrase!==null)i=[new BC(this.passphrase,this.scryptWorkFactor)];for(let p of i)r.push(...await p.wrapFileKey(t));let n=new TextEncoder().encode("header"),o=Wo(Rt,t,void 0,n,32),s=li(Rt,o,CC(r)),a=H5(r,s),c=Fi(16),l=new TextEncoder().encode("payload"),u=Wo(Rt,t,c,l,32),d=Q5(u);if(!(e instanceof ReadableStream)){if(typeof e==="string")e=new TextEncoder().encode(e);return await TC(Ml(Ib(e).pipeThrough(d),a,c))}return Object.assign(Ml(e.pipeThrough(d),a,c),{size:(p)=>Y5(p)+a.length+c.length})}}class HC{identities=[];addPassphrase(e){this.identities.push(new jC(e))}addIdentity(e){if(Qxe(e))this.identities.push(new $b(e));else if(typeof e==="string")if(e.startsWith("AGE-SECRET-KEY-1"))this.identities.push(new $b(e));else if(e.startsWith("AGE-SECRET-KEY-PQ-1"))this.identities.push(new zC(e));else throw Error("unrecognized identity type");else this.identities.push(e)}async decrypt(e,t){let r=e instanceof ReadableStream?e:Ib(e),{fileKey:i,headerSize:n,rest:o}=await this.decryptHeaderInternal(r),{data:s,rest:a}=await F5(o,16),c=new TextEncoder().encode("payload"),l=Wo(Rt,i,s,c,32),u=W5(l),d=a.pipeThrough(u),p=Object.assign(d,{size:(m)=>G5(m-n-s.length)});if(e instanceof ReadableStream)return p;if(t==="text")return await M5(d);return await TC(d)}async decryptHeader(e){return(await this.decryptHeaderInternal(Ib(e))).fileKey}async decryptHeaderInternal(e){let t=await Z5(e),r=await this.unwrapFileKey(t.stanzas);if(r===null)throw Error("no identity matched any of the file's recipients");let i=new TextEncoder().encode("header"),n=Wo(Rt,r,void 0,i,32),o=li(Rt,n,t.headerNoMAC);if(!Gxe(t.MAC,o))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 Gxe(e,t){if(e.length!==t.length)return!1;let r=0;for(let i=0;i<e.length;i++)r|=e[i]^t[i];return r===0}function Qxe(e){return typeof CryptoKey<"u"&&e instanceof CryptoKey}Pi();function X5(e,t,r){if(r.length===0)return;e(`${t} (${r.length}):`);for(let i of r)e(` - ${i}`)}function KC(e,t,r){let i=t.filter((o)=>r(o)),n=t.filter((o)=>!r(o));X5(e,"Required before first deploy",i),X5(e,"Safe to ignore for now",n)}async function ps(e,t={}){let r=t.runCommand??br;(t.logger??console.log)(`Pushing ${e.length} secrets to GitHub Secrets...`),await Promise.all(e.map(([n,o])=>r("gh",["secret","set",n],{stdin:o})))}function Fl(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}`)}Pi();async function WC(e,t={}){try{let r=await t8(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:at(r,"Age key bootstrap failed")}}}async function t8(e,t={}){let r=t.logger??console.log,i=e8(e,".brains-ops","age","identity.txt"),n=!1,o,s;if(Yxe(i))o=Zl(JC(i,"utf8")),s=await Tb(o);else Xxe(eSe(i),{recursive:!0,mode:448}),o=await RC(),s=await Tb(o),VC(i,rSe(o,s),{encoding:"utf8",mode:384}),n=!0;tSe(e8(e,"pilot.yaml"),s);let a=Fl(t.pushTo);if(a)await ps([["AGE_SECRET_KEY",JC(i,"utf8")]],{logger:r,runCommand:t.runCommand??br});if(r(n?`Created ${i}`:`Reusing ${i}`),r(`Configured pilot.yaml agePublicKey ${s}`),a)r(`Pushed AGE_SECRET_KEY to ${a}`);return{createdLocalKey:n,identityPath:i,agePublicKey:s}}function tSe(e,t){let r=JC(e,"utf8"),i=r.match(/^agePublicKey:\s*(.+)$/m),n=i?.[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(i){VC(e,r.replace(/^agePublicKey:\s*.+$/m,`agePublicKey: ${t}`),"utf8");return}let o=r.endsWith(`
844
+ `);if(t.shift()!=="-----BEGIN AGE ENCRYPTED FILE-----")throw Error("invalid header");if(t.pop()!=="-----END AGE ENCRYPTED FILE-----")throw Error("invalid footer");function r(i,n){if(i===t.length-1)return n.length>0&&n.length<=64&&n.length%4===0;return n.length===64}if(!t.every((i,n)=>r(n,i)))throw Error("invalid line length");if(!t.every((i)=>/^[A-Za-z0-9+/=]+$/.test(i)))throw Error("invalid base64");return vT.decode(t.join(""))}class ZC{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 PC(e));else if(e.startsWith("age1tag1"))this.recipients.push(new NC(e));else if(e.startsWith("age1tagpq1"))this.recipients.push(new DC(e));else if(e.startsWith("age1"))this.recipients.push(new LC(e));else throw Error("unrecognized recipient type");else this.recipients.push(e)}async encrypt(e){let t=Fi(16),r=[],i=this.recipients;if(this.passphrase!==null)i=[new BC(this.passphrase,this.scryptWorkFactor)];for(let p of i)r.push(...await p.wrapFileKey(t));let n=new TextEncoder().encode("header"),o=Wo(Rt,t,void 0,n,32),s=li(Rt,o,CC(r)),a=H5(r,s),c=Fi(16),l=new TextEncoder().encode("payload"),u=Wo(Rt,t,c,l,32),d=Q5(u);if(!(e instanceof ReadableStream)){if(typeof e==="string")e=new TextEncoder().encode(e);return await TC(Ml(Ib(e).pipeThrough(d),a,c))}return Object.assign(Ml(e.pipeThrough(d),a,c),{size:(p)=>Y5(p)+a.length+c.length})}}class HC{identities=[];addPassphrase(e){this.identities.push(new jC(e))}addIdentity(e){if(Gxe(e))this.identities.push(new $b(e));else if(typeof e==="string")if(e.startsWith("AGE-SECRET-KEY-1"))this.identities.push(new $b(e));else if(e.startsWith("AGE-SECRET-KEY-PQ-1"))this.identities.push(new zC(e));else throw Error("unrecognized identity type");else this.identities.push(e)}async decrypt(e,t){let r=e instanceof ReadableStream?e:Ib(e),{fileKey:i,headerSize:n,rest:o}=await this.decryptHeaderInternal(r),{data:s,rest:a}=await F5(o,16),c=new TextEncoder().encode("payload"),l=Wo(Rt,i,s,c,32),u=W5(l),d=a.pipeThrough(u),p=Object.assign(d,{size:(m)=>G5(m-n-s.length)});if(e instanceof ReadableStream)return p;if(t==="text")return await M5(d);return await TC(d)}async decryptHeader(e){return(await this.decryptHeaderInternal(Ib(e))).fileKey}async decryptHeaderInternal(e){let t=await Z5(e),r=await this.unwrapFileKey(t.stanzas);if(r===null)throw Error("no identity matched any of the file's recipients");let i=new TextEncoder().encode("header"),n=Wo(Rt,r,void 0,i,32),o=li(Rt,n,t.headerNoMAC);if(!Wxe(t.MAC,o))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 Wxe(e,t){if(e.length!==t.length)return!1;let r=0;for(let i=0;i<e.length;i++)r|=e[i]^t[i];return r===0}function Gxe(e){return typeof CryptoKey<"u"&&e instanceof CryptoKey}Pi();function X5(e,t,r){if(r.length===0)return;e(`${t} (${r.length}):`);for(let i of r)e(` - ${i}`)}function KC(e,t,r){let i=t.filter((o)=>r(o)),n=t.filter((o)=>!r(o));X5(e,"Required before first deploy",i),X5(e,"Safe to ignore for now",n)}async function ps(e,t={}){let r=t.runCommand??br;(t.logger??console.log)(`Pushing ${e.length} secrets to GitHub Secrets...`),await Promise.all(e.map(([n,o])=>r("gh",["secret","set",n],{stdin:o})))}function Fl(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}`)}Pi();async function WC(e,t={}){try{let r=await t8(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:at(r,"Age key bootstrap failed")}}}async function t8(e,t={}){let r=t.logger??console.log,i=e8(e,".brains-ops","age","identity.txt"),n=!1,o,s;if(Qxe(i))o=Zl(JC(i,"utf8")),s=await Tb(o);else Yxe(Xxe(i),{recursive:!0,mode:448}),o=await RC(),s=await Tb(o),VC(i,tSe(o,s),{encoding:"utf8",mode:384}),n=!0;eSe(e8(e,"pilot.yaml"),s);let a=Fl(t.pushTo);if(a)await ps([["AGE_SECRET_KEY",JC(i,"utf8")]],{logger:r,runCommand:t.runCommand??br});if(r(n?`Created ${i}`:`Reusing ${i}`),r(`Configured pilot.yaml agePublicKey ${s}`),a)r(`Pushed AGE_SECRET_KEY to ${a}`);return{createdLocalKey:n,identityPath:i,agePublicKey:s}}function eSe(e,t){let r=JC(e,"utf8"),i=r.match(/^agePublicKey:\s*(.+)$/m),n=i?.[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(i){VC(e,r.replace(/^agePublicKey:\s*.+$/m,`agePublicKey: ${t}`),"utf8");return}let o=r.endsWith(`
846
845
  `)?`${r}agePublicKey: ${t}
847
846
  `:`${r}
848
847
  agePublicKey: ${t}
849
- `;VC(e,o,"utf8")}function Zl(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 rSe(e,t){return["# generated by brains-ops age-key:bootstrap",`# public key: ${t}`,e,""].join(`
850
- `)}Rs();import{writeFile as CSe}from"fs/promises";import{join as p8}from"path";import{createSign as oSe,generateKeyPairSync as sSe}from"crypto";import{mkdir as aSe,writeFile as r8}from"fs/promises";import{join as n8}from"path";async function nSe(e){let t=await e.text();if(!t.trim())return;try{return JSON.parse(t)}catch{return t}}async function Hl(e,t,r){let i=await nSe(e),n=t.safeParse(i);if(!e.ok||!n.success){let o=r.formatError??iSe;throw Error(`${r.label}${o(e,i)}`)}return n.data}function iSe(e,t){let r=t===void 0?"":`: ${typeof t==="string"?t:JSON.stringify(t)}`;return` (${e.status} ${e.statusText}${r})`}Re();var cSe="2.5.4.3",lSe="1.2.840.113549.1.1.11",s8="https://api.cloudflare.com/client/v4",uSe="origin-rsa",dSe=5475,a8=15000;function c8(e){return{Authorization:`Bearer ${e}`,"Content-Type":"application/json"}}var i8=f.looseObject({message:f.string().optional()}),fSe=f.looseObject({errors:f.array(i8).optional(),messages:f.array(i8).optional()}),pSe=f.looseObject({certificate:f.string().min(1),expires_on:f.string().optional()}),mSe=f.looseObject({success:f.literal(!0),result:pSe}),hSe=f.looseObject({success:f.literal(!0)});function gSe(){let{privateKey:e,publicKey:t}=sSe("rsa",{modulusLength:2048,privateKeyEncoding:{type:"pkcs8",format:"pem"},publicKeyEncoding:{type:"spki",format:"der"}});return{privateKeyPem:e,publicKeyDer:Buffer.from(t)}}function ySe(e,t){let r=Xf(kSe(Xf(o8(cSe),wSe(e)))),i=Xf(SSe(0),r,Buffer.from(t.publicKeyDer),ESe(0,Buffer.alloc(0))),n=oSe("sha256").update(i).sign(t.privateKeyPem),o=Xf(i,Xf(o8(lSe),_Se()),vSe(n));return{csrPem:xSe("CERTIFICATE REQUEST",o),certificationRequestInfoDer:i,signature:n}}async function bSe(e,t,r,i){let n=await e(`${s8}/certificates`,{method:"POST",headers:c8(t),body:JSON.stringify({hostnames:[i,`*.${i}`],requested_validity:dSe,request_type:uSe,csr:r}),signal:AbortSignal.timeout(a8)}),o=await Hl(n,mSe,{label:"Cloudflare Origin CA request failed",formatError:u8}),a={certificatePem:`${o.result.certificate.trim()}
851
- `};if(o.result.expires_on)a.expiresOn=o.result.expires_on;return a}async function l8(e,t,r){let i=await e(`${s8}/zones/${r}/settings/ssl`,{method:"PATCH",headers:c8(t),body:JSON.stringify({value:"strict"}),signal:AbortSignal.timeout(a8)});await Hl(i,hSe,{label:"Cloudflare zone SSL update failed",formatError:u8})}function xSe(e,t){let i=t.toString("base64").match(/.{1,64}/g)??[];return[`-----BEGIN ${e}-----`,...i,`-----END ${e}-----`,""].join(`
852
- `)}function SSe(e){if(e!==0)throw Error("Only zero-valued INTEGER encoding is currently supported");return Buffer.from([2,1,0])}function o8(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],i=t[1];if(r===void 0||i===void 0)throw Error(`Invalid OID: ${e}`);let o=[r*40+i];for(let s of t.slice(2)){let a=ASe(s);o.push(...a)}return Kl(6,Buffer.from(o))}function wSe(e){return Kl(12,Buffer.from(e,"utf8"))}function vSe(e){return Kl(3,Buffer.concat([Buffer.from([0]),e]))}function _Se(){return Buffer.from([5,0])}function Xf(...e){return Kl(48,Buffer.concat(e))}function kSe(...e){return Kl(49,Buffer.concat(e))}function ESe(e,t){return Kl(160+e,t)}function Kl(e,t){return Buffer.concat([Buffer.from([e]),ISe(t.length),t])}function ISe(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 ASe(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 i=0;i<t.length-1;i+=1)t[i]=(t[i]??0)|128;return t}function u8(e,t){let r=TSe(t),i=r.length>0?`: ${r.join("; ")}`:"";return` (${e.status} ${e.statusText}${i})`}function TSe(e){let t=fSe.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 d8(e,t,r){let i=gSe(),{csrPem:n}=ySe(r,i),o=await bSe(e,t,n,r);return{certificatePem:o.certificatePem,privateKeyPem:i.privateKeyPem,...o.expiresOn!==void 0&&{expiresOn:o.expiresOn}}}async function f8(e,t){let r=n8(e,"origin.pem"),i=n8(e,"origin.key");return await aSe(e,{recursive:!0}),await Promise.all([r8(r,t.certificatePem,"utf-8"),r8(i,t.privateKeyPem,{encoding:"utf-8",mode:384})]),{certificatePath:r,privateKeyPath:i}}Ln();Pi();async function GC(e,t={}){try{return await h8(e,t),{success:!0}}catch(r){return{success:!1,message:at(r,"Certificate bootstrap failed")}}}async function h8(e,t={}){let r=await Ct(e),i=OSe(r,t.handle),n=i.domain,o=t.env??process.env,s=zn(e),a=t.cfApiToken??Wt("CF_API_TOKEN",o,s),c=t.cfZoneId??i.cloudflareZoneId??Wt("CF_ZONE_ID",o,s);if(!a)throw Error("Missing CF_API_TOKEN");if(!c)throw Error("Missing CF_ZONE_ID");let l=t.fetchImpl??fetch,u=t.logger??console.log,d=await d8(l,a,n),p=p8(e,".brains-ops","certs",i.id),{certificatePath:m,privateKeyPath:y}=await f8(p,d),g=p8(p,"secrets.yaml");await CSe(g,$Se(d.certificatePem,d.privateKeyPem),"utf-8"),await l8(l,a,c);let b=Fl(t.pushTo);if(b)await ps([["CERTIFICATE_PEM",d.certificatePem],["PRIVATE_KEY_PEM",d.privateKeyPem]],{logger:u,runCommand:t.runCommand??br});if(u(`Issued ${i.id} Origin CA cert for ${n} and *.${n}`),u(`Wrote ${m}`),u(`Wrote ${y}`),u(`Wrote ${g}`),d.expiresOn)u(`Expires on ${d.expiresOn}`);if(u("Cloudflare zone SSL mode set to Full (strict)"),b)u(`Pushed CERTIFICATE_PEM and PRIVATE_KEY_PEM to ${b}`);return{domain:n,certificatePath:m,privateKeyPath:y,certificatePem:d.certificatePem,secretsSnippetPath:g}}function $Se(e,t){return[`certificatePem: ${m8(e)}`,`privateKeyPem: ${m8(t)}`,""].join(`
853
- `)}function m8(e){return`"${e.replace(/"/g,"\\\"").replace(/\n/g,"\\n")}"`}function OSe(e,t){if(!t)return{id:"shared",domain:RSe(e.pilot.domainSuffix)};let r=e.users.find((i)=>i.handle===t);if(!r)throw Error(`Unknown user handle: ${t}`);return{id:t,domain:r.domain,...r.cloudflareZoneId?{cloudflareZoneId:r.cloudflareZoneId}:{}}}function RSe(e){let t=e.trim().replace(/^\./,"").replace(/\.$/,"");if(!t||t.includes("*"))throw Error(`Invalid pilot domainSuffix: ${e}`);return t}import{lookup as PSe}from"dns/promises";function y8(e={}){let t=e.fetchImpl??fetch,r=e.lookupHost??PSe;return async function(n){let o=await zSe(n.domain,r),[s,a,c]=await Promise.all([g8(n.domain,"/health/ready",t),g8(n.domain,"/health/operate",t),NSe(n.domain,t)]);return{dnsStatus:o,serverStatus:s,deployStatus:a,mcpStatus:c}}}async function zSe(e,t){try{return(await t(e)).address?"ready":"failed"}catch{return"failed"}}async function g8(e,t,r){try{return(await b8(r,`https://${e}${t}`,{method:"GET"})).ok?"ready":"failed"}catch{return"failed"}}async function NSe(e,t){try{let r=await b8(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 b8(e,t,r){let i=new AbortController,n=setTimeout(()=>i.abort(),5000);try{return await e(t,{...r,signal:i.signal})}finally{clearTimeout(n)}}import{createHash as DSe}from"crypto";import{cp as LSe,lstat as BSe,mkdtemp as jSe,readFile as qSe,readdir as USe,readlink as MSe,rm as FSe}from"fs/promises";import{tmpdir as ZSe}from"os";import{basename as HSe,join as ep,relative as KSe,resolve as JSe,sep as VSe}from"path";var WSe=new Set([".git",".operator",".brains-ops",".turbo","dist","node_modules"]);async function w8(e){let t=JSe(e),r=await jSe(ep(ZSe(),"brains-ops-reconcile-")),i=ep(r,"repo");try{await LSe(t,i,{recursive:!0,errorOnExist:!0,force:!1,filter:(a)=>GSe(t,a)});let n=await QC(i);await x8(i);let o=await QC(i);await x8(i);let s=await QC(i);return{firstPassChangedFiles:S8(n,o),secondPassChangedFiles:S8(o,s)}}finally{await FSe(r,{recursive:!0,force:!0})}}function GSe(e,t){let r=KSe(e,t);if(r.length===0)return!0;if(r.split(VSe).some((n)=>WSe.has(n)))return!1;if(r===".env"||r===".env.local")return!1;return!HSe(r).endsWith(".secrets.yaml")}async function x8(e){await yf(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 QC(e){let t=new Map;return await v8(e,"",t),t}async function v8(e,t,r){let i=ep(e,t),n=await USe(i,{withFileTypes:!0});n.sort((o,s)=>o.name.localeCompare(s.name));for(let o of n){let s=ep(t,o.name),a=ep(e,s);if(o.isDirectory()){await v8(e,s,r);continue}let l=(await BSe(a)).isSymbolicLink()?`symlink:${await MSe(a)}`:await qSe(a);r.set(s,DSe("sha256").update(l).digest("hex"))}}function S8(e,t){return[...new Set([...e.keys(),...t.keys()])].filter((i)=>e.get(i)!==t.get(i)).sort()}Dc();import{readFileSync as tp}from"fs";import{access as QSe,rm as YSe,writeFile as T8}from"fs/promises";import{join as YC,relative as k8}from"path";Rs();Ai();function _8(e){return Object.keys(e)}Re();var C8=f.strictObject({gitSyncToken:f.string().min(1).optional(),discordBotToken:f.string().min(1).optional(),discordPublicKey:f.string().min(1).optional(),discordApplicationId:f.string().min(1).optional(),aiApiKey:f.string().min(1).optional(),atprotoAppPassword:f.string().min(1).optional(),certificatePem:f.string().min(1).optional(),privateKeyPem:f.string().min(1).optional()});async function XC(e,t,r={}){let{registry:i,user:n}=await Hg(e,t),o=r.env??process.env,s=r.logger??console.log,a=zn(e),c=YC(e,"users",`${t}.secrets.yaml.age`),l=YC(e,"users",`${t}.secrets.yaml`),u=A8(k8(e,c)),d=A8(k8(e,l)),p=twe(l),m=await rwe(c,e,o,a),y=await $8(l),g={sharedAiApiKeySelector:i.pilot.aiApiKey,sharedGitSyncTokenSelector:i.pilot.gitSyncToken,effectiveAiApiKeySelector:n.effectiveAiApiKey,effectiveGitSyncTokenSelector:n.effectiveGitSyncToken,discordEnabled:n.discordEnabled},b;try{b=XSe(e,o,a,p,m,g)}catch(E){if(!r.dryRun&&p===void 0&&E instanceof Error){let Z=owe(g);if(Z.length>0)throw await swe(l,Z),Error(`Missing required secrets for ${t}. Created ${d}; fill it in and rerun secrets:encrypt. ${E.message}`,{cause:E})}throw E}let v=`${ic(b).trimEnd()}
854
- `;iwe(v,b);let A=_8(b);if(r.dryRun){if(s(`Dry run: would encrypt ${A.length} secrets to ${u}.`),s(A.length>0?`Keys: ${A.join(", ")}`:"Keys: (none \u2014 shared defaults only)"),y)s(`Would remove plaintext file ${d}.`);return{encryptedPath:u,plaintextPath:d,deletedPlaintext:y,encryptedKeys:A,dryRun:!0}}let T=new ZC;T.addRecipient(i.pilot.agePublicKey);let z=await T.encrypt(v),j=Yf.encode(z);if(await T8(c,j),await YSe(l,{force:!0}),s(`Encrypted ${A.length} secrets to ${u}.`),y)s(`Removed plaintext file ${d}.`);return{encryptedPath:u,plaintextPath:d,deletedPlaintext:y,encryptedKeys:A}}function XSe(e,t,r,i,n,o){let s=E8(e,t,r,i,n,"aiApiKey",o.effectiveAiApiKeySelector,o.sharedAiApiKeySelector),a=E8(e,t,r,i,n,"gitSyncToken",o.effectiveGitSyncTokenSelector,o.sharedGitSyncTokenSelector),c=o.discordEnabled?Ob(e,t,r,i,n,"discordBotToken","DISCORD_BOT_TOKEN"):void 0,l=o.discordEnabled?Ob(e,t,r,i,n,"discordPublicKey","DISCORD_PUBLIC_KEY"):void 0,u=o.discordEnabled?Ob(e,t,r,i,n,"discordApplicationId","DISCORD_APPLICATION_ID"):void 0,d=Rb(e,t,r,i,n,"atprotoAppPassword","ATPROTO_APP_PASSWORD"),p=I8(Rb(e,t,r,i,n,"certificatePem","CERTIFICATE_PEM")),m=I8(Rb(e,t,r,i,n,"privateKeyPem","PRIVATE_KEY_PEM"));return C8.parse({...s?{aiApiKey:s}:{},...a?{gitSyncToken:a}:{},...c?{discordBotToken:c}:{},...l?{discordPublicKey:l}:{},...u?{discordApplicationId:u}:{},...d?{atprotoAppPassword:d}:{},...p?{certificatePem:p}:{},...m?{privateKeyPem:m}:{}})}function E8(e,t,r,i,n,o,s,a){if(s===a)return;return Ob(e,t,r,i,n,o,s)}function Ob(e,t,r,i,n,o,s){let a=Rb(e,t,r,i,n,o,s);if(a===void 0||a.trim().length===0)throw Error(`Missing required secret value for ${String(o)}. Set it in users/<handle>.secrets.yaml or fall back to ${s}/${s}_FILE before running secrets:encrypt.`);return a}function I8(e){return e?.replace(/\r\n?|\n/g,"\\n")}function Rb(e,t,r,i,n,o,s){return ewe(i,n,o,s,t,r,e)}function ewe(e,t,r,i,n,o,s){let a=e?.[r];if(a!==void 0&&a.trim().length>0)return a;let c=Wt(`${i}_FILE`,n,o);if(c&&c.trim().length>0)return tp(ho(c,s),"utf8");let l=Wt(i,n,o);if(l!==void 0&&l.trim().length>0)return l;let u=t?.[r];if(u!==void 0&&u.trim().length>0)return u;return}function twe(e){let t;try{t=tp(e,"utf8")}catch{return}try{return e$(t)}catch(r){throw Error(`Unable to parse plaintext secrets file ${e}: ${at(r)}`,{cause:r})}}async function rwe(e,t,r,i){if(!await $8(e))return;let n=nwe(t,r,i);if(!n)return;let o;try{let s=tp(e,"utf8"),a=Yf.decode(s),c=new HC;c.addIdentity(n),o=await c.decrypt(a,"text")}catch{return}try{return e$(o)}catch(s){throw Error(`Unable to parse decrypted secrets from ${e}: ${at(s)}`,{cause:s})}}function nwe(e,t,r){let i=Wt("AGE_SECRET_KEY_FILE",t,r);if(i&&i.trim().length>0)return Zl(tp(ho(i,e),"utf8"));let n=Wt("AGE_SECRET_KEY",t,r);if(n&&n.trim().length>0)return Zl(n);try{return Zl(tp(YC(e,".brains-ops","age","identity.txt"),"utf8"))}catch{return}}function e$(e){let t=kP(e),r={};if(t!==null&&typeof t==="object"&&!Array.isArray(t)){for(let[i,n]of Object.entries(t))if(typeof n==="string")r[i]=n}return C8.partial().parse(r)}function iwe(e,t){let r={...t},i={...e$(e)},n=new Set([...Object.keys(r),...Object.keys(i)]);for(let o of n)if(r[o]!==i[o])throw Error(`secrets:encrypt round-trip verification failed for ${o}; refusing to write a corrupted encrypted payload`)}function owe(e){return[...e.effectiveAiApiKeySelector!==e.sharedAiApiKeySelector?["aiApiKey"]:[],...e.effectiveGitSyncTokenSelector!==e.sharedGitSyncTokenSelector?["gitSyncToken"]:[],...e.discordEnabled?["discordBotToken","discordPublicKey","discordApplicationId"]:[]]}async function swe(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((i)=>`${i}: `),""].join(`
855
- `);await T8(e,r,{flag:"wx"})}async function $8(e){try{return await QSe(e),!0}catch{return!1}}function A8(e){return e.replaceAll("\\","/")}Rs();import{readFileSync as awe}from"fs";Pi();async function t$(e,t={}){let r=t.env??process.env,i=t.logger??console.log,n=zn(e),o=Gx(`${e}/.env.schema`),s=lwe(o),a=[],c=[],l=new Map;for(let d of s){l.set(d.key,d.required);let p=uwe(d.key,r,n,e);if(p===void 0||p.trim().length===0){c.push(d.key);continue}a.push([d.key,p])}if(a.length===0)throw Error("No pushable local secrets found for this pilot repo");let u=(d)=>l.get(d)??!1;if(t.dryRun)return i(`Dry run: would push ${a.length} secrets to GitHub Secrets.`),i(`Secrets: ${a.map(([d])=>d).join(", ")}`),KC(i,c,u),{pushedKeys:a.map(([d])=>d),skippedKeys:c,dryRun:!0};return await ps(a,{logger:i,runCommand:t.runCommand??br}),KC(i,c,u),{pushedKeys:a.map(([d])=>d),skippedKeys:c}}var cwe=new Set(["DISCORD_BOT_TOKEN","DISCORD_PUBLIC_KEY","DISCORD_APPLICATION_ID"]);function lwe(e){return e.filter((t)=>!cwe.has(t.key)).map((t)=>({key:t.key,required:t.required}))}function uwe(e,t,r,i){let n=Wt(`${e}_FILE`,t,r);if(n&&n.trim().length>0)return awe(ho(n,i),"utf8");let o=Wt(e,t,r);if(o===void 0||o.trim().length===0)return;return o}Re();import{execFileSync as O8}from"child_process";import{chmodSync as dwe,existsSync as fwe,mkdirSync as pwe,readFileSync as R8,writeFileSync as mwe}from"fs";import{dirname as hwe,join as gwe}from"path";import{homedir as ywe}from"os";Yx();Pi();var P8=f.object({id:f.number(),name:f.string(),public_key:f.string()}),bwe=f.object({ssh_keys:f.array(P8)}),xwe={createEd25519KeyPair(e,t){O8("ssh-keygen",["-t","ed25519","-f",e,"-C",t,"-N",""],{stdio:"ignore"})},derivePublicKey(e){return O8("ssh-keygen",["-y","-f",e],{encoding:"utf-8",stdio:["ignore","pipe","inherit"]}).trim()}};async function Pb(e,t={}){try{let r=await r$(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:at(r,"SSH key bootstrap failed")}}}async function r$(e,t={}){let r=t.env??process.env,i=zn(e),n=t.logger??console.log,o=t.fetchImpl??fetch,s=t.sshKeygen??xwe,a=Wt("HCLOUD_TOKEN",r,i);if(!a)throw Error("Missing HCLOUD_TOKEN");let c=Wt("HCLOUD_SSH_KEY_NAME",r,i);if(!c)throw Error("Missing HCLOUD_SSH_KEY_NAME");let l=Wt("KAMAL_SSH_PRIVATE_KEY_FILE",r,i),u=l?ho(l,e):gwe(ywe(),".ssh",`${wwe(c)}_ed25519`),d=`${u}.pub`,p=!1;if(!fwe(u))pwe(hwe(u),{recursive:!0,mode:448}),s.createEd25519KeyPair(u,c),p=!0;dwe(u,384);let m;if(p)m=R8(d,"utf-8").trim();else m=s.derivePublicKey(u),mwe(d,`${m}
856
- `,"utf-8");if(m.length===0)throw Error(`Unable to derive a public key from ${u}`);let y=await Swe({fetchImpl:o,hcloudToken:a,publicKey:m,sshKeyName:c}),g=Fl(t.pushTo);if(g)await ps([["KAMAL_SSH_PRIVATE_KEY",R8(u,"utf-8")]],{logger:n,runCommand:t.runCommand??br});if(n(p?`Created ${u}`:`Reusing ${u}`),n(y?`Registered Hetzner SSH key ${c}`:`Hetzner SSH key ${c} already exists`),g)n(`Pushed KAMAL_SSH_PRIVATE_KEY to ${g}`);return{createdHetznerKey:y,createdLocalKey:p,privateKeyPath:u,publicKeyPath:d,sshKeyName:c}}async function Swe(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:i}=await Hl(r,bwe,{label:"Hetzner SSH key lookup failed"}),[n]=i;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 o=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 Hl(o,f.object({ssh_key:P8}),{label:"Hetzner SSH key create failed"}),!0}function wwe(e){return e.replace(/[^A-Za-z0-9._-]+/g,"_")}Re();Ln();var vwe=f.looseObject({status:f.string(),operationalStatus:f.string(),checks:f.array(f.looseObject({name:f.string(),status:f.string(),message:f.string().optional()})).default([]),app:f.looseObject({daemons:f.array(f.looseObject({name:f.string().optional(),status:f.string().optional(),health:f.looseObject({status:f.string().optional(),message:f.string().optional()}).optional()})).default([])}).default({daemons:[]})});async function n$(e,t,r={}){let i=r.fetchImpl??fetch,o=(await Ct(e)).users.find((p)=>p.handle===t);if(!o)throw Error(`Unknown pilot user: ${t}`);let s=`https://${o.domain}`,a=[],c=[],l=f.number().int().positive().max(30).parse(r.operationalRetryAttempts??6),u=f.number().int().nonnegative().max(60000).parse(r.operationalRetryDelayMs??1e4),d=r.sleep??((p)=>new Promise((m)=>setTimeout(m,p)));if(await zb("health",()=>_we(i,s,l,u,d),a,c),await zb("mcp-auth-gate",()=>Iwe(i,s),a,c),o.bundles.includes("site"))await zb("site",()=>z8(i,`${s}/`,"site"),a,c),await zb("studio",()=>z8(i,`${s}/studio`,"studio"),a,c),r.logger?.("WARN Manual check still required: passkey setup/handoff completed from the setup email.");return{handle:o.handle,bundles:o.bundles,domain:o.domain,contentRepo:o.contentRepo,checks:a,failedChecks:c}}async function zb(e,t,r,i){try{await t(),r.push(e)}catch(n){i.push({name:e,message:at(n)})}}async function _we(e,t,r,i,n){let o;for(let s=1;s<=r;s++)try{await kwe(e,t);return}catch(a){if(o=a,s<r)await n(i)}throw o}async function kwe(e,t){let i=await i$(e,`${t}/health/operate`,{method:"GET"}),n=await i.json().catch(()=>null),o=vwe.safeParse(n);if(!i.ok){let a=o.success?o.data.checks.filter((c)=>c.status!=="healthy").slice(0,10).map((c)=>`${c.name}: ${Ewe(c.message??c.status)}`):[];throw Error(`/health/operate returned ${i.status}, expected 200${a.length>0?` (${a.join("; ")})`:""}`)}if(!o.success)throw Error(`/health/operate response did not match expected shape: ${o.error.message}`);let s=o.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",l=a.health?.status;if(c==="error"||l==="unhealthy")throw Error(`daemon ${a.name??"unknown"} is unhealthy (${c}/${l??"unknown"})`)}}function Ewe(e){let t=e.replaceAll(/\s+/g," ").trim();return t.length<=300?t:`${t.slice(0,297)}...`}async function Iwe(e,t){let r=await i$(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 z8(e,t,r){let i=await i$(e,t,{method:"GET"});if(i.status>=400)throw Error(`${r} ${t} returned ${i.status}, expected < 400`)}async function i$(e,t,r){let i=new AbortController,n=setTimeout(()=>i.abort(),20000);try{return await e(t,{...r,redirect:"follow",signal:i.signal})}finally{clearTimeout(n)}}var N7="brains-ops",wR={type:"string",placeholder:"<target>",description:"Push target (`gh` or `github`)"},Hx={type:"boolean",description:"Show what would happen without writing anything"};function Dt(e){return{success:!1,message:FF(N7,e)}}var D7=mt({name:"init",usage:"<repo>",description:"Create a pilot repo skeleton",run:async({args:e})=>{let t=e[0];if(!t)return Dt(D7);return await qE(t),{success:!0,message:`Initialized ${t}`}}}),L7=mt({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 Dt(L7);let i=ht(t,"to"),{upgradePilotRepo:n}=await Promise.resolve().then(() => (L8(),D8)),{from:o,to:s}=await n(r,{...i&&i!=="latest"?{version:i}:{}});return{success:!0,message:o===s?`Already at @rizom/ops@${s}; scaffold refreshed`:`Upgraded @rizom/ops ${o} -> ${s}; scaffold refreshed`}}}),B7=mt({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],i=e[2],n=e[3];if(!t||!r||!i)return Dt(B7);let{loadCapabilityBundleReview:o,loadReviewedSitePins:s,stageLegacyCrossover:a}=await Promise.resolve().then(() => (aH(),sH)),c=await o(i),l=n?await s(n):void 0,u=await a(t,r,{bundleReview:c,sitePins:l});return{success:!0,message:`Staged ${u.changedFiles.length} reviewed crossover files in ${u.outputDir}`}}}),j7=mt({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 Dt(j7);let i=t.resolveStatus??y8({...t.fetchImpl?{fetchImpl:t.fetchImpl}:{},...t.lookupHost?{lookupHost:t.lookupHost}:{}});return await Oi(r,{resolveStatus:i}),{success:!0,message:`Rendered ${r}/views/users.md`}}}),q7=mt({name:"user:add",usage:"<repo> <handle> --cohort <cohort>",description:"Add a user to a cohort",flags:{cohort:{type:"string",placeholder:"<cohort>",description:"Cohort the user joins"},"anchor-id":{type:"string",placeholder:"<id>",description:"Discord anchor user id stored on the user record"}},run:async({args:e,flags:t})=>{let r=e[0],i=e[1],n=ht(t,"cohort");if(!r||!i||!n)return Dt(q7);let o=ht(t,"anchor-id");return await ZI(r,i,{cohort:n,...o?{anchorId:o}:{}}),{success:!0,message:`Added ${i} to ${n}`}}}),U7=mt({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 i=e[0],n=e.slice(1);if(!i||n.length===0)return Dt(U7);let o=wl(t,"apply")??!1,s=ht(t,"confirm"),{offboardPilotUsers:a}=await Promise.resolve().then(() => (oT(),BF)),c=await a(i,{handles:n,dryRun:!o,...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)`}}}),M7=mt({name:"onboard",usage:"<repo> <handle>",description:"Generate a user's brain.yaml and .env",run:async({args:e},t)=>{let r=e[0],i=e[1];if(!r||!i)return Dt(M7);return await FI(r,i,t.runner,{...t.env?{env:t.env}:{}}),{success:!0,message:`Onboarded ${i}`}}}),F7=mt({name:"age-key:bootstrap",usage:"<repo>",description:"Generate the pilot age key and optional GitHub secret",flags:{"push-to":wR},run:async({args:e,flags:t},r)=>{let i=e[0];if(!i)return Dt(F7);let n=ht(t,"push-to");return WC(i,{...r.logger?{logger:r.logger}:{},...n?{pushTo:n}:{},...r.bootstrapRunCommand?{runCommand:r.bootstrapRunCommand}:{}})}}),Z7=mt({name:"ssh-key:bootstrap",usage:"<repo>",description:"Bootstrap a deploy SSH key and optional GitHub secret",flags:{"push-to":wR},run:async({args:e,flags:t},r)=>{let i=e[0];if(!i)return Dt(Z7);let n=ht(t,"push-to");return Pb(i,{...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}:{}})}}),H7=mt({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":wR},run:async({args:e,flags:t},r)=>{let i=e[0];if(!i)return Dt(H7);let n=ht(t,"handle"),o=ht(t,"push-to");return GC(i,{...r.env?{env:r.env}:{},...r.fetchImpl?{fetchImpl:r.fetchImpl}:{},...r.logger?{logger:r.logger}:{},...n?{handle:n}:{},...o?{pushTo:o}:{},...r.bootstrapRunCommand?{runCommand:r.bootstrapRunCommand}:{}})}}),K7=mt({name:"secrets:push",usage:"<repo>",description:"Push env-backed local secrets to GitHub Secrets",flags:{"dry-run":Hx},run:async({args:e,flags:t},r)=>{let i=e[0];if(!i)return Dt(K7);let n=await t$(i,{env:r.env,logger:r.logger,dryRun:wl(t,"dry-run")});return{success:!0,message:n.dryRun?`Dry run: would push ${n.pushedKeys.length} secrets`:`Pushed ${n.pushedKeys.length} secrets`}}}),J7=mt({name:"secrets:encrypt",usage:"<repo> <handle>",description:"Encrypt pilot secrets for a user with age",flags:{"dry-run":Hx},run:async({args:e,flags:t},r)=>{let i=e[0],n=e[1];if(!i||!n)return Dt(J7);let o=await XC(i,n,{env:r.env,logger:r.logger,dryRun:wl(t,"dry-run")});return{success:!0,message:o.dryRun?`Dry run: would encrypt ${o.encryptedKeys.length} secrets for ${n}`:`Encrypted ${o.encryptedKeys.length} secrets for ${n}`}}}),V7=mt({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":Hx},run:async({args:e,flags:t},r)=>{let i=e[0],n=e[1],o=ht(t,"type"),s=ht(t,"confirm"),a=wl(t,"dry-run")??!1;if(!i||!n||!o||a===(s!==void 0))return Dt(V7);let{legacyProjectionJobTypeSchema:c}=await Promise.resolve().then(() => (nR(),rR)),l=c.safeParse(o);if(!l.success)return{success:!1,message:`Unsupported legacy projection job type: ${o}`};let u=r.legacyProjectionJobRecoveryRunner??(await Promise.resolve().then(() => (nR(),rR))).retireLegacyProjectionJob;try{let d=await u({databasePath:i,jobId:n,jobType:l.data,...s?{confirmation:s}:{},dryRun:a});return{success:!0,message:d.retired?`Retired unowned legacy projection job ${d.job.id} (${d.job.type})`:`Dry run: legacy projection job ${d.job.id} (${d.job.type}) is unowned and retirable`}}catch(d){return{success:!1,message:`Legacy projection job recovery failed: ${at(d)}`}}}}),W7=mt({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 i=e[0],n=e[1],o=ht(t,"profile"),s=ht(t,"confirm");if(!i||!n||!s||o!=="regression"&&o!=="load"&&o!=="stress")return Dt(W7);let a=r.directorySyncStressRunner??(await Promise.resolve().then(() => (em(),Ux))).runDeployedDirectorySyncStress,c=ht(t,"artifacts-dir"),l=await a({rootDir:i,handle:n,profile:o,confirmation:s,...c?{artifactsDir:c}:{},...r.env?{env:r.env}:{},...r.fetchImpl?{fetchImpl:r.fetchImpl}:{},...r.logger?{logger:r.logger}:{}});return{success:l.report.success,message:`${l.report.success?"Passed":"Failed"} ${o} directory-sync stress for ${n}; artifacts: ${l.artifactsDir}`}}}),G7=mt({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 i=e[0],n=e[1],o=ht(t,"confirm");if(!i||!n||!o)return Dt(G7);let s=r.directorySyncStressAccessRunner??(await Promise.resolve().then(() => (em(),Ux))).verifyDirectorySyncStressAccess,a=ht(t,"artifacts-dir"),c=await s({rootDir:i,handle:n,confirmation:o,...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}`}}}),Q7=mt({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 i=e[0],n=e[1],o=ht(t,"confirm");if(!i||!n||!o)return Dt(Q7);let s=r.directorySyncStressCleanupRunner??(await Promise.resolve().then(() => (em(),Ux))).cleanupDirectorySyncStress,a=ht(t,"artifacts-dir"),c=await s({rootDir:i,handle:n,confirmation:o,...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}`}}}),Y7={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"}},X7=mt({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:Y7,run:async({args:e,flags:t},r)=>{let i=e[0],n=e[1],o=ht(t,"confirm"),s=ht(t,"run-id");if(!i||!n||!o||!s)return Dt(X7);let a=r.healthWatchdogSmokeRunner??(await Zx().then(() => SR)).runHealthWatchdogSmoke,c=ht(t,"artifacts-dir"),l=await a({rootDir:i,handle:n,confirmation:o,runId:s,...c?{artifactsDir:c}:{},...r.env?{env:r.env}:{},...r.fetchImpl?{fetchImpl:r.fetchImpl}:{},...r.logger?{logger:r.logger}:{}});return{success:l.success,message:`Passed health watchdog smoke for ${n}; artifacts: ${l.artifactsDir}`}}}),eW=mt({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:Y7,run:async({args:e,flags:t},r)=>{let i=e[0],n=e[1],o=ht(t,"confirm"),s=ht(t,"run-id");if(!i||!n||!o||!s)return Dt(eW);let a=r.healthWatchdogSmokeCleanupRunner??(await Zx().then(() => SR)).cleanupHealthWatchdogSmoke,c=ht(t,"artifacts-dir"),l=await a({rootDir:i,handle:n,confirmation:o,runId:s,...c?{artifactsDir:c}:{},...r.env?{env:r.env}:{},...r.fetchImpl?{fetchImpl:r.fetchImpl}:{},...r.logger?{logger:r.logger}:{}});return{success:l.success,message:`Cleaned health watchdog smoke fixtures for ${n}; artifacts: ${l.artifactsDir}`}}}),tW=mt({name:"verify-user",usage:"<repo> <handle>",description:"Probe a deployed user's endpoints",run:async({args:e},t)=>{let r=e[0],i=e[1];if(!r||!i)return Dt(tW);let n=await n$(r,i,{...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}:{}}),o=n.checks.length>0?n.checks.join(", "):"none";if(n.failedChecks.length>0){let s=n.failedChecks.map((a)=>` ${a.name}: ${a.message}`).join(`
848
+ `;VC(e,o,"utf8")}function Zl(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 tSe(e,t){return["# generated by brains-ops age-key:bootstrap",`# public key: ${t}`,e,""].join(`
849
+ `)}Rs();import{writeFile as TSe}from"fs/promises";import{join as p8}from"path";import{createSign as iSe,generateKeyPairSync as oSe}from"crypto";import{mkdir as sSe,writeFile as r8}from"fs/promises";import{join as n8}from"path";async function rSe(e){let t=await e.text();if(!t.trim())return;try{return JSON.parse(t)}catch{return t}}async function Hl(e,t,r){let i=await rSe(e),n=t.safeParse(i);if(!e.ok||!n.success){let o=r.formatError??nSe;throw Error(`${r.label}${o(e,i)}`)}return n.data}function nSe(e,t){let r=t===void 0?"":`: ${typeof t==="string"?t:JSON.stringify(t)}`;return` (${e.status} ${e.statusText}${r})`}Re();var aSe="2.5.4.3",cSe="1.2.840.113549.1.1.11",s8="https://api.cloudflare.com/client/v4",lSe="origin-rsa",uSe=5475,a8=15000;function c8(e){return{Authorization:`Bearer ${e}`,"Content-Type":"application/json"}}var i8=f.looseObject({message:f.string().optional()}),dSe=f.looseObject({errors:f.array(i8).optional(),messages:f.array(i8).optional()}),fSe=f.looseObject({certificate:f.string().min(1),expires_on:f.string().optional()}),pSe=f.looseObject({success:f.literal(!0),result:fSe}),mSe=f.looseObject({success:f.literal(!0)});function hSe(){let{privateKey:e,publicKey:t}=oSe("rsa",{modulusLength:2048,privateKeyEncoding:{type:"pkcs8",format:"pem"},publicKeyEncoding:{type:"spki",format:"der"}});return{privateKeyPem:e,publicKeyDer:Buffer.from(t)}}function gSe(e,t){let r=Xf(_Se(Xf(o8(aSe),SSe(e)))),i=Xf(xSe(0),r,Buffer.from(t.publicKeyDer),kSe(0,Buffer.alloc(0))),n=iSe("sha256").update(i).sign(t.privateKeyPem),o=Xf(i,Xf(o8(cSe),vSe()),wSe(n));return{csrPem:bSe("CERTIFICATE REQUEST",o),certificationRequestInfoDer:i,signature:n}}async function ySe(e,t,r,i){let n=await e(`${s8}/certificates`,{method:"POST",headers:c8(t),body:JSON.stringify({hostnames:[i,`*.${i}`],requested_validity:uSe,request_type:lSe,csr:r}),signal:AbortSignal.timeout(a8)}),o=await Hl(n,pSe,{label:"Cloudflare Origin CA request failed",formatError:u8}),a={certificatePem:`${o.result.certificate.trim()}
850
+ `};if(o.result.expires_on)a.expiresOn=o.result.expires_on;return a}async function l8(e,t,r){let i=await e(`${s8}/zones/${r}/settings/ssl`,{method:"PATCH",headers:c8(t),body:JSON.stringify({value:"strict"}),signal:AbortSignal.timeout(a8)});await Hl(i,mSe,{label:"Cloudflare zone SSL update failed",formatError:u8})}function bSe(e,t){let i=t.toString("base64").match(/.{1,64}/g)??[];return[`-----BEGIN ${e}-----`,...i,`-----END ${e}-----`,""].join(`
851
+ `)}function xSe(e){if(e!==0)throw Error("Only zero-valued INTEGER encoding is currently supported");return Buffer.from([2,1,0])}function o8(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],i=t[1];if(r===void 0||i===void 0)throw Error(`Invalid OID: ${e}`);let o=[r*40+i];for(let s of t.slice(2)){let a=ISe(s);o.push(...a)}return Kl(6,Buffer.from(o))}function SSe(e){return Kl(12,Buffer.from(e,"utf8"))}function wSe(e){return Kl(3,Buffer.concat([Buffer.from([0]),e]))}function vSe(){return Buffer.from([5,0])}function Xf(...e){return Kl(48,Buffer.concat(e))}function _Se(...e){return Kl(49,Buffer.concat(e))}function kSe(e,t){return Kl(160+e,t)}function Kl(e,t){return Buffer.concat([Buffer.from([e]),ESe(t.length),t])}function ESe(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 ISe(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 i=0;i<t.length-1;i+=1)t[i]=(t[i]??0)|128;return t}function u8(e,t){let r=ASe(t),i=r.length>0?`: ${r.join("; ")}`:"";return` (${e.status} ${e.statusText}${i})`}function ASe(e){let t=dSe.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 d8(e,t,r){let i=hSe(),{csrPem:n}=gSe(r,i),o=await ySe(e,t,n,r);return{certificatePem:o.certificatePem,privateKeyPem:i.privateKeyPem,...o.expiresOn!==void 0&&{expiresOn:o.expiresOn}}}async function f8(e,t){let r=n8(e,"origin.pem"),i=n8(e,"origin.key");return await sSe(e,{recursive:!0}),await Promise.all([r8(r,t.certificatePem,"utf-8"),r8(i,t.privateKeyPem,{encoding:"utf-8",mode:384})]),{certificatePath:r,privateKeyPath:i}}Ln();Pi();async function GC(e,t={}){try{return await h8(e,t),{success:!0}}catch(r){return{success:!1,message:at(r,"Certificate bootstrap failed")}}}async function h8(e,t={}){let r=await Ct(e),i=$Se(r,t.handle),n=i.domain,o=t.env??process.env,s=zn(e),a=t.cfApiToken??Wt("CF_API_TOKEN",o,s),c=t.cfZoneId??i.cloudflareZoneId??Wt("CF_ZONE_ID",o,s);if(!a)throw Error("Missing CF_API_TOKEN");if(!c)throw Error("Missing CF_ZONE_ID");let l=t.fetchImpl??fetch,u=t.logger??console.log,d=await d8(l,a,n),p=p8(e,".brains-ops","certs",i.id),{certificatePath:m,privateKeyPath:y}=await f8(p,d),g=p8(p,"secrets.yaml");await TSe(g,CSe(d.certificatePem,d.privateKeyPem),"utf-8"),await l8(l,a,c);let b=Fl(t.pushTo);if(b)await ps([["CERTIFICATE_PEM",d.certificatePem],["PRIVATE_KEY_PEM",d.privateKeyPem]],{logger:u,runCommand:t.runCommand??br});if(u(`Issued ${i.id} Origin CA cert for ${n} and *.${n}`),u(`Wrote ${m}`),u(`Wrote ${y}`),u(`Wrote ${g}`),d.expiresOn)u(`Expires on ${d.expiresOn}`);if(u("Cloudflare zone SSL mode set to Full (strict)"),b)u(`Pushed CERTIFICATE_PEM and PRIVATE_KEY_PEM to ${b}`);return{domain:n,certificatePath:m,privateKeyPath:y,certificatePem:d.certificatePem,secretsSnippetPath:g}}function CSe(e,t){return[`certificatePem: ${m8(e)}`,`privateKeyPem: ${m8(t)}`,""].join(`
852
+ `)}function m8(e){return`"${e.replace(/"/g,"\\\"").replace(/\n/g,"\\n")}"`}function $Se(e,t){if(!t)return{id:"shared",domain:OSe(e.pilot.domainSuffix)};let r=e.users.find((i)=>i.handle===t);if(!r)throw Error(`Unknown user handle: ${t}`);return{id:t,domain:r.domain,...r.cloudflareZoneId?{cloudflareZoneId:r.cloudflareZoneId}:{}}}function OSe(e){let t=e.trim().replace(/^\./,"").replace(/\.$/,"");if(!t||t.includes("*"))throw Error(`Invalid pilot domainSuffix: ${e}`);return t}import{lookup as RSe}from"dns/promises";function y8(e={}){let t=e.fetchImpl??fetch,r=e.lookupHost??RSe;return async function(n){let o=await PSe(n.domain,r),[s,a,c]=await Promise.all([g8(n.domain,"/health/ready",t),g8(n.domain,"/health/operate",t),zSe(n.domain,t)]);return{dnsStatus:o,serverStatus:s,deployStatus:a,mcpStatus:c}}}async function PSe(e,t){try{return(await t(e)).address?"ready":"failed"}catch{return"failed"}}async function g8(e,t,r){try{return(await b8(r,`https://${e}${t}`,{method:"GET"})).ok?"ready":"failed"}catch{return"failed"}}async function zSe(e,t){try{let r=await b8(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 b8(e,t,r){let i=new AbortController,n=setTimeout(()=>i.abort(),5000);try{return await e(t,{...r,signal:i.signal})}finally{clearTimeout(n)}}import{createHash as NSe}from"crypto";import{cp as DSe,lstat as LSe,mkdtemp as BSe,readFile as jSe,readdir as qSe,readlink as USe,rm as MSe}from"fs/promises";import{tmpdir as FSe}from"os";import{basename as ZSe,join as ep,relative as HSe,resolve as KSe,sep as JSe}from"path";var VSe=new Set([".git",".operator",".brains-ops",".turbo","dist","node_modules"]);async function w8(e){let t=KSe(e),r=await BSe(ep(FSe(),"brains-ops-reconcile-")),i=ep(r,"repo");try{await DSe(t,i,{recursive:!0,errorOnExist:!0,force:!1,filter:(a)=>WSe(t,a)});let n=await QC(i);await x8(i);let o=await QC(i);await x8(i);let s=await QC(i);return{firstPassChangedFiles:S8(n,o),secondPassChangedFiles:S8(o,s)}}finally{await MSe(r,{recursive:!0,force:!0})}}function WSe(e,t){let r=HSe(e,t);if(r.length===0)return!0;if(r.split(JSe).some((n)=>VSe.has(n)))return!1;if(r===".env"||r===".env.local")return!1;return!ZSe(r).endsWith(".secrets.yaml")}async function x8(e){await yf(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 QC(e){let t=new Map;return await v8(e,"",t),t}async function v8(e,t,r){let i=ep(e,t),n=await qSe(i,{withFileTypes:!0});n.sort((o,s)=>o.name.localeCompare(s.name));for(let o of n){let s=ep(t,o.name),a=ep(e,s);if(o.isDirectory()){await v8(e,s,r);continue}let l=(await LSe(a)).isSymbolicLink()?`symlink:${await USe(a)}`:await jSe(a);r.set(s,NSe("sha256").update(l).digest("hex"))}}function S8(e,t){return[...new Set([...e.keys(),...t.keys()])].filter((i)=>e.get(i)!==t.get(i)).sort()}Dc();import{readFileSync as tp}from"fs";import{access as GSe,rm as QSe,writeFile as T8}from"fs/promises";import{join as YC,relative as k8}from"path";Rs();Ai();function _8(e){return Object.keys(e)}Re();var C8=f.strictObject({gitSyncToken:f.string().min(1).optional(),discordBotToken:f.string().min(1).optional(),discordPublicKey:f.string().min(1).optional(),discordApplicationId:f.string().min(1).optional(),aiApiKey:f.string().min(1).optional(),atprotoAppPassword:f.string().min(1).optional(),certificatePem:f.string().min(1).optional(),privateKeyPem:f.string().min(1).optional()});async function XC(e,t,r={}){let{registry:i,user:n}=await Hg(e,t),o=r.env??process.env,s=r.logger??console.log,a=zn(e),c=YC(e,"users",`${t}.secrets.yaml.age`),l=YC(e,"users",`${t}.secrets.yaml`),u=A8(k8(e,c)),d=A8(k8(e,l)),p=ewe(l),m=await twe(c,e,o,a),y=await $8(l),g={sharedAiApiKeySelector:i.pilot.aiApiKey,sharedGitSyncTokenSelector:i.pilot.gitSyncToken,effectiveAiApiKeySelector:n.effectiveAiApiKey,effectiveGitSyncTokenSelector:n.effectiveGitSyncToken,discordEnabled:n.discordEnabled},b;try{b=YSe(e,o,a,p,m,g)}catch(E){if(!r.dryRun&&p===void 0&&E instanceof Error){let Z=iwe(g);if(Z.length>0)throw await owe(l,Z),Error(`Missing required secrets for ${t}. Created ${d}; fill it in and rerun secrets:encrypt. ${E.message}`,{cause:E})}throw E}let v=`${ic(b).trimEnd()}
853
+ `;nwe(v,b);let A=_8(b);if(r.dryRun){if(s(`Dry run: would encrypt ${A.length} secrets to ${u}.`),s(A.length>0?`Keys: ${A.join(", ")}`:"Keys: (none \u2014 shared defaults only)"),y)s(`Would remove plaintext file ${d}.`);return{encryptedPath:u,plaintextPath:d,deletedPlaintext:y,encryptedKeys:A,dryRun:!0}}let T=new ZC;T.addRecipient(i.pilot.agePublicKey);let z=await T.encrypt(v),j=Yf.encode(z);if(await T8(c,j),await QSe(l,{force:!0}),s(`Encrypted ${A.length} secrets to ${u}.`),y)s(`Removed plaintext file ${d}.`);return{encryptedPath:u,plaintextPath:d,deletedPlaintext:y,encryptedKeys:A}}function YSe(e,t,r,i,n,o){let s=E8(e,t,r,i,n,"aiApiKey",o.effectiveAiApiKeySelector,o.sharedAiApiKeySelector),a=E8(e,t,r,i,n,"gitSyncToken",o.effectiveGitSyncTokenSelector,o.sharedGitSyncTokenSelector),c=o.discordEnabled?Ob(e,t,r,i,n,"discordBotToken","DISCORD_BOT_TOKEN"):void 0,l=o.discordEnabled?Ob(e,t,r,i,n,"discordPublicKey","DISCORD_PUBLIC_KEY"):void 0,u=o.discordEnabled?Ob(e,t,r,i,n,"discordApplicationId","DISCORD_APPLICATION_ID"):void 0,d=Rb(e,t,r,i,n,"atprotoAppPassword","ATPROTO_APP_PASSWORD"),p=I8(Rb(e,t,r,i,n,"certificatePem","CERTIFICATE_PEM")),m=I8(Rb(e,t,r,i,n,"privateKeyPem","PRIVATE_KEY_PEM"));return C8.parse({...s?{aiApiKey:s}:{},...a?{gitSyncToken:a}:{},...c?{discordBotToken:c}:{},...l?{discordPublicKey:l}:{},...u?{discordApplicationId:u}:{},...d?{atprotoAppPassword:d}:{},...p?{certificatePem:p}:{},...m?{privateKeyPem:m}:{}})}function E8(e,t,r,i,n,o,s,a){if(s===a)return;return Ob(e,t,r,i,n,o,s)}function Ob(e,t,r,i,n,o,s){let a=Rb(e,t,r,i,n,o,s);if(a===void 0||a.trim().length===0)throw Error(`Missing required secret value for ${String(o)}. Set it in users/<handle>.secrets.yaml or fall back to ${s}/${s}_FILE before running secrets:encrypt.`);return a}function I8(e){return e?.replace(/\r\n?|\n/g,"\\n")}function Rb(e,t,r,i,n,o,s){return XSe(i,n,o,s,t,r,e)}function XSe(e,t,r,i,n,o,s){let a=e?.[r];if(a!==void 0&&a.trim().length>0)return a;let c=Wt(`${i}_FILE`,n,o);if(c&&c.trim().length>0)return tp(ho(c,s),"utf8");let l=Wt(i,n,o);if(l!==void 0&&l.trim().length>0)return l;let u=t?.[r];if(u!==void 0&&u.trim().length>0)return u;return}function ewe(e){let t;try{t=tp(e,"utf8")}catch{return}try{return e$(t)}catch(r){throw Error(`Unable to parse plaintext secrets file ${e}: ${at(r)}`,{cause:r})}}async function twe(e,t,r,i){if(!await $8(e))return;let n=rwe(t,r,i);if(!n)return;let o;try{let s=tp(e,"utf8"),a=Yf.decode(s),c=new HC;c.addIdentity(n),o=await c.decrypt(a,"text")}catch{return}try{return e$(o)}catch(s){throw Error(`Unable to parse decrypted secrets from ${e}: ${at(s)}`,{cause:s})}}function rwe(e,t,r){let i=Wt("AGE_SECRET_KEY_FILE",t,r);if(i&&i.trim().length>0)return Zl(tp(ho(i,e),"utf8"));let n=Wt("AGE_SECRET_KEY",t,r);if(n&&n.trim().length>0)return Zl(n);try{return Zl(tp(YC(e,".brains-ops","age","identity.txt"),"utf8"))}catch{return}}function e$(e){let t=kP(e),r={};if(t!==null&&typeof t==="object"&&!Array.isArray(t)){for(let[i,n]of Object.entries(t))if(typeof n==="string")r[i]=n}return C8.partial().parse(r)}function nwe(e,t){let r={...t},i={...e$(e)},n=new Set([...Object.keys(r),...Object.keys(i)]);for(let o of n)if(r[o]!==i[o])throw Error(`secrets:encrypt round-trip verification failed for ${o}; refusing to write a corrupted encrypted payload`)}function iwe(e){return[...e.effectiveAiApiKeySelector!==e.sharedAiApiKeySelector?["aiApiKey"]:[],...e.effectiveGitSyncTokenSelector!==e.sharedGitSyncTokenSelector?["gitSyncToken"]:[],...e.discordEnabled?["discordBotToken","discordPublicKey","discordApplicationId"]:[]]}async function owe(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((i)=>`${i}: `),""].join(`
854
+ `);await T8(e,r,{flag:"wx"})}async function $8(e){try{return await GSe(e),!0}catch{return!1}}function A8(e){return e.replaceAll("\\","/")}Rs();import{readFileSync as swe}from"fs";Pi();async function t$(e,t={}){let r=t.env??process.env,i=t.logger??console.log,n=zn(e),o=Gx(`${e}/.env.schema`),s=cwe(o),a=[],c=[],l=new Map;for(let d of s){l.set(d.key,d.required);let p=lwe(d.key,r,n,e);if(p===void 0||p.trim().length===0){c.push(d.key);continue}a.push([d.key,p])}if(a.length===0)throw Error("No pushable local secrets found for this pilot repo");let u=(d)=>l.get(d)??!1;if(t.dryRun)return i(`Dry run: would push ${a.length} secrets to GitHub Secrets.`),i(`Secrets: ${a.map(([d])=>d).join(", ")}`),KC(i,c,u),{pushedKeys:a.map(([d])=>d),skippedKeys:c,dryRun:!0};return await ps(a,{logger:i,runCommand:t.runCommand??br}),KC(i,c,u),{pushedKeys:a.map(([d])=>d),skippedKeys:c}}var awe=new Set(["DISCORD_BOT_TOKEN","DISCORD_PUBLIC_KEY","DISCORD_APPLICATION_ID"]);function cwe(e){return e.filter((t)=>!awe.has(t.key)).map((t)=>({key:t.key,required:t.required}))}function lwe(e,t,r,i){let n=Wt(`${e}_FILE`,t,r);if(n&&n.trim().length>0)return swe(ho(n,i),"utf8");let o=Wt(e,t,r);if(o===void 0||o.trim().length===0)return;return o}Re();import{execFileSync as O8}from"child_process";import{chmodSync as uwe,existsSync as dwe,mkdirSync as fwe,readFileSync as R8,writeFileSync as pwe}from"fs";import{dirname as mwe,join as hwe}from"path";import{homedir as gwe}from"os";Yx();Pi();var P8=f.object({id:f.number(),name:f.string(),public_key:f.string()}),ywe=f.object({ssh_keys:f.array(P8)}),bwe={createEd25519KeyPair(e,t){O8("ssh-keygen",["-t","ed25519","-f",e,"-C",t,"-N",""],{stdio:"ignore"})},derivePublicKey(e){return O8("ssh-keygen",["-y","-f",e],{encoding:"utf-8",stdio:["ignore","pipe","inherit"]}).trim()}};async function Pb(e,t={}){try{let r=await r$(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:at(r,"SSH key bootstrap failed")}}}async function r$(e,t={}){let r=t.env??process.env,i=zn(e),n=t.logger??console.log,o=t.fetchImpl??fetch,s=t.sshKeygen??bwe,a=Wt("HCLOUD_TOKEN",r,i);if(!a)throw Error("Missing HCLOUD_TOKEN");let c=Wt("HCLOUD_SSH_KEY_NAME",r,i);if(!c)throw Error("Missing HCLOUD_SSH_KEY_NAME");let l=Wt("KAMAL_SSH_PRIVATE_KEY_FILE",r,i),u=l?ho(l,e):hwe(gwe(),".ssh",`${Swe(c)}_ed25519`),d=`${u}.pub`,p=!1;if(!dwe(u))fwe(mwe(u),{recursive:!0,mode:448}),s.createEd25519KeyPair(u,c),p=!0;uwe(u,384);let m;if(p)m=R8(d,"utf-8").trim();else m=s.derivePublicKey(u),pwe(d,`${m}
855
+ `,"utf-8");if(m.length===0)throw Error(`Unable to derive a public key from ${u}`);let y=await xwe({fetchImpl:o,hcloudToken:a,publicKey:m,sshKeyName:c}),g=Fl(t.pushTo);if(g)await ps([["KAMAL_SSH_PRIVATE_KEY",R8(u,"utf-8")]],{logger:n,runCommand:t.runCommand??br});if(n(p?`Created ${u}`:`Reusing ${u}`),n(y?`Registered Hetzner SSH key ${c}`:`Hetzner SSH key ${c} already exists`),g)n(`Pushed KAMAL_SSH_PRIVATE_KEY to ${g}`);return{createdHetznerKey:y,createdLocalKey:p,privateKeyPath:u,publicKeyPath:d,sshKeyName:c}}async function xwe(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:i}=await Hl(r,ywe,{label:"Hetzner SSH key lookup failed"}),[n]=i;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 o=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 Hl(o,f.object({ssh_key:P8}),{label:"Hetzner SSH key create failed"}),!0}function Swe(e){return e.replace(/[^A-Za-z0-9._-]+/g,"_")}Re();Ln();var wwe=f.looseObject({status:f.string(),operationalStatus:f.string(),checks:f.array(f.looseObject({name:f.string(),status:f.string(),message:f.string().optional()})).default([]),app:f.looseObject({daemons:f.array(f.looseObject({name:f.string().optional(),status:f.string().optional(),health:f.looseObject({status:f.string().optional(),message:f.string().optional()}).optional()})).default([])}).default({daemons:[]})});async function n$(e,t,r={}){let i=r.fetchImpl??fetch,o=(await Ct(e)).users.find((p)=>p.handle===t);if(!o)throw Error(`Unknown pilot user: ${t}`);let s=`https://${o.domain}`,a=[],c=[],l=f.number().int().positive().max(30).parse(r.operationalRetryAttempts??6),u=f.number().int().nonnegative().max(60000).parse(r.operationalRetryDelayMs??1e4),d=r.sleep??((p)=>new Promise((m)=>setTimeout(m,p)));if(await zb("health",()=>vwe(i,s,l,u,d),a,c),await zb("mcp-auth-gate",()=>Ewe(i,s),a,c),o.bundles.includes("site"))await zb("site",()=>z8(i,`${s}/`,"site"),a,c),await zb("studio",()=>z8(i,`${s}/studio`,"studio"),a,c),r.logger?.("WARN Manual check still required: passkey setup/handoff completed from the setup email.");return{handle:o.handle,bundles:o.bundles,domain:o.domain,contentRepo:o.contentRepo,checks:a,failedChecks:c}}async function zb(e,t,r,i){try{await t(),r.push(e)}catch(n){i.push({name:e,message:at(n)})}}async function vwe(e,t,r,i,n){let o;for(let s=1;s<=r;s++)try{await _we(e,t);return}catch(a){if(o=a,s<r)await n(i)}throw o}async function _we(e,t){let i=await i$(e,`${t}/health/operate`,{method:"GET"}),n=await i.json().catch(()=>null),o=wwe.safeParse(n);if(!i.ok){let a=o.success?o.data.checks.filter((c)=>c.status!=="healthy").slice(0,10).map((c)=>`${c.name}: ${kwe(c.message??c.status)}`):[];throw Error(`/health/operate returned ${i.status}, expected 200${a.length>0?` (${a.join("; ")})`:""}`)}if(!o.success)throw Error(`/health/operate response did not match expected shape: ${o.error.message}`);let s=o.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",l=a.health?.status;if(c==="error"||l==="unhealthy")throw Error(`daemon ${a.name??"unknown"} is unhealthy (${c}/${l??"unknown"})`)}}function kwe(e){let t=e.replaceAll(/\s+/g," ").trim();return t.length<=300?t:`${t.slice(0,297)}...`}async function Ewe(e,t){let r=await i$(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 z8(e,t,r){let i=await i$(e,t,{method:"GET"});if(i.status>=400)throw Error(`${r} ${t} returned ${i.status}, expected < 400`)}async function i$(e,t,r){let i=new AbortController,n=setTimeout(()=>i.abort(),20000);try{return await e(t,{...r,redirect:"follow",signal:i.signal})}finally{clearTimeout(n)}}var N7="brains-ops",wR={type:"string",placeholder:"<target>",description:"Push target (`gh` or `github`)"},Hx={type:"boolean",description:"Show what would happen without writing anything"};function Dt(e){return{success:!1,message:FF(N7,e)}}var D7=mt({name:"init",usage:"<repo>",description:"Create a pilot repo skeleton",run:async({args:e})=>{let t=e[0];if(!t)return Dt(D7);return await qE(t),{success:!0,message:`Initialized ${t}`}}}),L7=mt({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 Dt(L7);let i=ht(t,"to"),{upgradePilotRepo:n}=await Promise.resolve().then(() => (L8(),D8)),{from:o,to:s}=await n(r,{...i&&i!=="latest"?{version:i}:{}});return{success:!0,message:o===s?`Already at @rizom/ops@${s}; scaffold refreshed`:`Upgraded @rizom/ops ${o} -> ${s}; scaffold refreshed`}}}),B7=mt({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],i=e[2],n=e[3];if(!t||!r||!i)return Dt(B7);let{loadCapabilityBundleReview:o,loadReviewedSitePins:s,stageLegacyCrossover:a}=await Promise.resolve().then(() => (aH(),sH)),c=await o(i),l=n?await s(n):void 0,u=await a(t,r,{bundleReview:c,sitePins:l});return{success:!0,message:`Staged ${u.changedFiles.length} reviewed crossover files in ${u.outputDir}`}}}),j7=mt({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 Dt(j7);let i=t.resolveStatus??y8({...t.fetchImpl?{fetchImpl:t.fetchImpl}:{},...t.lookupHost?{lookupHost:t.lookupHost}:{}});return await Oi(r,{resolveStatus:i}),{success:!0,message:`Rendered ${r}/views/users.md`}}}),q7=mt({name:"user:add",usage:"<repo> <handle> --cohort <cohort>",description:"Add a user to a cohort",flags:{cohort:{type:"string",placeholder:"<cohort>",description:"Cohort the user joins"},"anchor-id":{type:"string",placeholder:"<id>",description:"Discord anchor user id stored on the user record"}},run:async({args:e,flags:t})=>{let r=e[0],i=e[1],n=ht(t,"cohort");if(!r||!i||!n)return Dt(q7);let o=ht(t,"anchor-id");return await ZI(r,i,{cohort:n,...o?{anchorId:o}:{}}),{success:!0,message:`Added ${i} to ${n}`}}}),U7=mt({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 i=e[0],n=e.slice(1);if(!i||n.length===0)return Dt(U7);let o=wl(t,"apply")??!1,s=ht(t,"confirm"),{offboardPilotUsers:a}=await Promise.resolve().then(() => (oT(),BF)),c=await a(i,{handles:n,dryRun:!o,...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)`}}}),M7=mt({name:"onboard",usage:"<repo> <handle>",description:"Generate a user's brain.yaml and .env",run:async({args:e},t)=>{let r=e[0],i=e[1];if(!r||!i)return Dt(M7);return await FI(r,i,t.runner,{...t.env?{env:t.env}:{}}),{success:!0,message:`Onboarded ${i}`}}}),F7=mt({name:"age-key:bootstrap",usage:"<repo>",description:"Generate the pilot age key and optional GitHub secret",flags:{"push-to":wR},run:async({args:e,flags:t},r)=>{let i=e[0];if(!i)return Dt(F7);let n=ht(t,"push-to");return WC(i,{...r.logger?{logger:r.logger}:{},...n?{pushTo:n}:{},...r.bootstrapRunCommand?{runCommand:r.bootstrapRunCommand}:{}})}}),Z7=mt({name:"ssh-key:bootstrap",usage:"<repo>",description:"Bootstrap a deploy SSH key and optional GitHub secret",flags:{"push-to":wR},run:async({args:e,flags:t},r)=>{let i=e[0];if(!i)return Dt(Z7);let n=ht(t,"push-to");return Pb(i,{...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}:{}})}}),H7=mt({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":wR},run:async({args:e,flags:t},r)=>{let i=e[0];if(!i)return Dt(H7);let n=ht(t,"handle"),o=ht(t,"push-to");return GC(i,{...r.env?{env:r.env}:{},...r.fetchImpl?{fetchImpl:r.fetchImpl}:{},...r.logger?{logger:r.logger}:{},...n?{handle:n}:{},...o?{pushTo:o}:{},...r.bootstrapRunCommand?{runCommand:r.bootstrapRunCommand}:{}})}}),K7=mt({name:"secrets:push",usage:"<repo>",description:"Push env-backed local secrets to GitHub Secrets",flags:{"dry-run":Hx},run:async({args:e,flags:t},r)=>{let i=e[0];if(!i)return Dt(K7);let n=await t$(i,{env:r.env,logger:r.logger,dryRun:wl(t,"dry-run")});return{success:!0,message:n.dryRun?`Dry run: would push ${n.pushedKeys.length} secrets`:`Pushed ${n.pushedKeys.length} secrets`}}}),J7=mt({name:"secrets:encrypt",usage:"<repo> <handle>",description:"Encrypt pilot secrets for a user with age",flags:{"dry-run":Hx},run:async({args:e,flags:t},r)=>{let i=e[0],n=e[1];if(!i||!n)return Dt(J7);let o=await XC(i,n,{env:r.env,logger:r.logger,dryRun:wl(t,"dry-run")});return{success:!0,message:o.dryRun?`Dry run: would encrypt ${o.encryptedKeys.length} secrets for ${n}`:`Encrypted ${o.encryptedKeys.length} secrets for ${n}`}}}),V7=mt({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":Hx},run:async({args:e,flags:t},r)=>{let i=e[0],n=e[1],o=ht(t,"type"),s=ht(t,"confirm"),a=wl(t,"dry-run")??!1;if(!i||!n||!o||a===(s!==void 0))return Dt(V7);let{legacyProjectionJobTypeSchema:c}=await Promise.resolve().then(() => (nR(),rR)),l=c.safeParse(o);if(!l.success)return{success:!1,message:`Unsupported legacy projection job type: ${o}`};let u=r.legacyProjectionJobRecoveryRunner??(await Promise.resolve().then(() => (nR(),rR))).retireLegacyProjectionJob;try{let d=await u({databasePath:i,jobId:n,jobType:l.data,...s?{confirmation:s}:{},dryRun:a});return{success:!0,message:d.retired?`Retired unowned legacy projection job ${d.job.id} (${d.job.type})`:`Dry run: legacy projection job ${d.job.id} (${d.job.type}) is unowned and retirable`}}catch(d){return{success:!1,message:`Legacy projection job recovery failed: ${at(d)}`}}}}),W7=mt({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 i=e[0],n=e[1],o=ht(t,"profile"),s=ht(t,"confirm");if(!i||!n||!s||o!=="regression"&&o!=="load"&&o!=="stress")return Dt(W7);let a=r.directorySyncStressRunner??(await Promise.resolve().then(() => (em(),Ux))).runDeployedDirectorySyncStress,c=ht(t,"artifacts-dir"),l=await a({rootDir:i,handle:n,profile:o,confirmation:s,...c?{artifactsDir:c}:{},...r.env?{env:r.env}:{},...r.fetchImpl?{fetchImpl:r.fetchImpl}:{},...r.logger?{logger:r.logger}:{}});return{success:l.report.success,message:`${l.report.success?"Passed":"Failed"} ${o} directory-sync stress for ${n}; artifacts: ${l.artifactsDir}`}}}),G7=mt({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 i=e[0],n=e[1],o=ht(t,"confirm");if(!i||!n||!o)return Dt(G7);let s=r.directorySyncStressAccessRunner??(await Promise.resolve().then(() => (em(),Ux))).verifyDirectorySyncStressAccess,a=ht(t,"artifacts-dir"),c=await s({rootDir:i,handle:n,confirmation:o,...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}`}}}),Q7=mt({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 i=e[0],n=e[1],o=ht(t,"confirm");if(!i||!n||!o)return Dt(Q7);let s=r.directorySyncStressCleanupRunner??(await Promise.resolve().then(() => (em(),Ux))).cleanupDirectorySyncStress,a=ht(t,"artifacts-dir"),c=await s({rootDir:i,handle:n,confirmation:o,...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}`}}}),Y7={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"}},X7=mt({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:Y7,run:async({args:e,flags:t},r)=>{let i=e[0],n=e[1],o=ht(t,"confirm"),s=ht(t,"run-id");if(!i||!n||!o||!s)return Dt(X7);let a=r.healthWatchdogSmokeRunner??(await Zx().then(() => SR)).runHealthWatchdogSmoke,c=ht(t,"artifacts-dir"),l=await a({rootDir:i,handle:n,confirmation:o,runId:s,...c?{artifactsDir:c}:{},...r.env?{env:r.env}:{},...r.fetchImpl?{fetchImpl:r.fetchImpl}:{},...r.logger?{logger:r.logger}:{}});return{success:l.success,message:`Passed health watchdog smoke for ${n}; artifacts: ${l.artifactsDir}`}}}),eW=mt({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:Y7,run:async({args:e,flags:t},r)=>{let i=e[0],n=e[1],o=ht(t,"confirm"),s=ht(t,"run-id");if(!i||!n||!o||!s)return Dt(eW);let a=r.healthWatchdogSmokeCleanupRunner??(await Zx().then(() => SR)).cleanupHealthWatchdogSmoke,c=ht(t,"artifacts-dir"),l=await a({rootDir:i,handle:n,confirmation:o,runId:s,...c?{artifactsDir:c}:{},...r.env?{env:r.env}:{},...r.fetchImpl?{fetchImpl:r.fetchImpl}:{},...r.logger?{logger:r.logger}:{}});return{success:l.success,message:`Cleaned health watchdog smoke fixtures for ${n}; artifacts: ${l.artifactsDir}`}}}),tW=mt({name:"verify-user",usage:"<repo> <handle>",description:"Probe a deployed user's endpoints",run:async({args:e},t)=>{let r=e[0],i=e[1];if(!r||!i)return Dt(tW);let n=await n$(r,i,{...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}:{}}),o=n.checks.length>0?n.checks.join(", "):"none";if(n.failedChecks.length>0){let s=n.failedChecks.map((a)=>` ${a.name}: ${a.message}`).join(`
857
856
  `);return{success:!1,message:`Verified ${n.handle} (${n.bundles.join(",")}) at https://${n.domain}: passed ${o}; failed:
858
857
  ${s}`}}return{success:!0,message:`Verified ${n.handle} (${n.bundles.join(",")}) at https://${n.domain}: ${o}`}}}),rW=mt({name:"reconcile-cohort",usage:"<repo> <cohort>",description:"Reconcile all users in a cohort",run:async({args:e},t)=>{let r=e[0],i=e[1];if(!r||!i)return Dt(rW);return await sT(r,i,t.runner,{...t.env?{env:t.env}:{}}),{success:!0,message:`Reconciled cohort ${i}`}}});function z7(e,t){return[e,...t.length===0?["- (none)"]:t.map((r)=>`- ${r}`)]}var nW=mt({name:"reconcile-all",usage:"<repo> [--dry-run]",description:"Reconcile every cohort",flags:{"dry-run":Hx},run:async({args:e,flags:t},r)=>{let i=e[0];if(!i)return Dt(nW);if(wl(t,"dry-run")){let n=await w8(i),o=n.firstPassChangedFiles.length,s=n.secondPassChangedFiles.length;return{success:s===0,message:[`Dry-run reconcile found ${o} first-pass changed file(s); second pass ${s===0?"converged with zero drift":`still changed ${s} file(s)`}`,...z7("First-pass changed files:",n.firstPassChangedFiles),...z7("Second-pass changed files:",n.secondPassChangedFiles)].join(`
859
- `)}}return await yf(i,r.runner,{...r.env?{env:r.env}:{}}),{success:!0,message:"Reconciled all cohorts"}}}),pEe=mt({name:"help",description:"Show this help message",run:()=>({success:!0,message:ZF({cliName:N7,intro:"brains-ops \u2014 operator CLI for private brain fleet repos",commands:Kx,globalFlags:vR})})}),mEe=mt({name:"version",description:"Show version",run:()=>({success:!0,message:`brains-ops ${tm.version}`})}),vR={help:{type:"boolean",short:"h",description:"Show help"},version:{type:"boolean",short:"v",description:"Show version"}},Kx=[D7,L7,B7,j7,q7,U7,M7,F7,Z7,H7,K7,J7,V7,W7,G7,Q7,X7,eW,tW,rW,nW,pEe,mEe],hEe=HF(Kx);async function gEe(e,t={}){let r=hEe.get(e.command);if(!r)return{success:!1,message:`Unknown command: ${e.command}`};return r.run({args:e.args,flags:e.flags},t)}function yEe(e){return qF(e,{commands:Kx,globalFlags:vR})}qx();em();To();await Zx();export{Io as CAPABILITY_BUNDLE_CONTRACT,ZI as addPilotUser,Wp as assertDirectorySyncStressTarget,Fx as assertHealthWatchdogSmokeTarget,iT as assertPilotUsersRemoved,t8 as bootstrapPilotAgeKey,h8 as bootstrapPilotOriginCertificate,r$ as bootstrapPilotSshKey,Mh as canonicalBundleIdSchema,g7 as cleanupDirectorySyncStress,$7 as cleanupHealthWatchdogSmoke,yn as cohortSchema,nT as createPilotOffboardDriver,LI as derivePreviewDomain,Vp as directorySyncStressPlanSchema,Jp as directorySyncStressProfileSchema,a7 as directorySyncStressReportSchema,XC as encryptPilotSecrets,Zl as extractAgeIdentity,qE as initPilotRepo,Ct as loadPilotRegistry,zF as offboardPilotUsers,FI as onboardUser,yEe as parseArgs,Ao as pilotSchema,t$ as pushPilotSecrets,yf as reconcileAll,sT as reconcileCohort,xR as renderHealthWatchdogSmokeRemoteScript,FN as requiredImages,oR as resolveDirectorySyncStressPlan,ZN as resolveImageBuilds,gEe as runCommand,m7 as runDeployedDirectorySyncStress,sR as runDirectorySyncStressPlan,C7 as runHealthWatchdogSmoke,WC as runPilotAgeKeyBootstrap,GC as runPilotCertBootstrap,Pb as runPilotSshKeyBootstrap,EX as runResolveMissingImages,Ed as runtimeImageTag,jx as sampleStressHealth,Hh as sitePackagesFor,c7 as stressMetricsFailure,h7 as verifyDirectorySyncStressAccess,n$ as verifyPilotUser,Oi as writeUsersTable};
858
+ `)}}return await yf(i,r.runner,{...r.env?{env:r.env}:{}}),{success:!0,message:"Reconciled all cohorts"}}}),fEe=mt({name:"help",description:"Show this help message",run:()=>({success:!0,message:ZF({cliName:N7,intro:"brains-ops \u2014 operator CLI for private brain fleet repos",commands:Kx,globalFlags:vR})})}),pEe=mt({name:"version",description:"Show version",run:()=>({success:!0,message:`brains-ops ${tm.version}`})}),vR={help:{type:"boolean",short:"h",description:"Show help"},version:{type:"boolean",short:"v",description:"Show version"}},Kx=[D7,L7,B7,j7,q7,U7,M7,F7,Z7,H7,K7,J7,V7,W7,G7,Q7,X7,eW,tW,rW,nW,fEe,pEe],mEe=HF(Kx);async function hEe(e,t={}){let r=mEe.get(e.command);if(!r)return{success:!1,message:`Unknown command: ${e.command}`};return r.run({args:e.args,flags:e.flags},t)}function gEe(e){return qF(e,{commands:Kx,globalFlags:vR})}qx();em();To();await Zx();export{Io as CAPABILITY_BUNDLE_CONTRACT,ZI as addPilotUser,Wp as assertDirectorySyncStressTarget,Fx as assertHealthWatchdogSmokeTarget,iT as assertPilotUsersRemoved,t8 as bootstrapPilotAgeKey,h8 as bootstrapPilotOriginCertificate,r$ as bootstrapPilotSshKey,Mh as canonicalBundleIdSchema,g7 as cleanupDirectorySyncStress,$7 as cleanupHealthWatchdogSmoke,yn as cohortSchema,nT as createPilotOffboardDriver,LI as derivePreviewDomain,Vp as directorySyncStressPlanSchema,Jp as directorySyncStressProfileSchema,a7 as directorySyncStressReportSchema,XC as encryptPilotSecrets,Zl as extractAgeIdentity,qE as initPilotRepo,Ct as loadPilotRegistry,zF as offboardPilotUsers,FI as onboardUser,gEe as parseArgs,Ao as pilotSchema,t$ as pushPilotSecrets,yf as reconcileAll,sT as reconcileCohort,xR as renderHealthWatchdogSmokeRemoteScript,FN as requiredImages,oR as resolveDirectorySyncStressPlan,ZN as resolveImageBuilds,hEe as runCommand,m7 as runDeployedDirectorySyncStress,sR as runDirectorySyncStressPlan,C7 as runHealthWatchdogSmoke,WC as runPilotAgeKeyBootstrap,GC as runPilotCertBootstrap,Pb as runPilotSshKeyBootstrap,EX as runResolveMissingImages,Ed as runtimeImageTag,jx as sampleStressHealth,Hh as sitePackagesFor,c7 as stressMetricsFailure,h7 as verifyDirectorySyncStressAccess,n$ as verifyPilotUser,Oi as writeUsersTable};