@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.
@@ -106,7 +106,7 @@ IFS=',' read -ra HOSTS <<< "$KAMAL_HOSTS"
106
106
  for host in "\${HOSTS[@]}"; do
107
107
  scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null "$BRAIN_FILE" "\${SSH_USER}@\${host}:/opt/brain.yaml"
108
108
  done
109
- `}import{appendFileSync as ATe,readFileSync as JQ}from"fs";function Ow(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(VQ.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 Rw(e,t){return Ow(JQ(e,"utf8"),t)}var VQ;var E2=x(()=>{VQ=/^# ---- .+ ----$/});import{existsSync as WQ,readFileSync as GQ}from"fs";import{homedir as QQ}from"os";import{isAbsolute as YQ,join as Pw,resolve as XQ}from"path";function Bn(e){let t={};for(let r of[Pw(e,".env"),Pw(e,".env.local")]){if(!WQ(r))continue;let i=eY(GQ(r,"utf8"));for(let[n,o]of Object.entries(i))t[n]=o}return t}function Gt(e,t,r){return t[e]??r[e]}function Po(e,t){if(e.startsWith("~/"))return Pw(process.env.HOME??QQ(),e.slice(2));if(YQ(e))return e;return XQ(t,e)}function eY(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]=tY(s)}return t}function tY(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
+ `}import{appendFileSync as ITe,readFileSync as JQ}from"fs";function Ow(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(VQ.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 Rw(e,t){return Ow(JQ(e,"utf8"),t)}var VQ;var E2=x(()=>{VQ=/^# ---- .+ ----$/});import{existsSync as WQ,readFileSync as GQ}from"fs";import{homedir as QQ}from"os";import{isAbsolute as YQ,join as Pw,resolve as XQ}from"path";function Bn(e){let t={};for(let r of[Pw(e,".env"),Pw(e,".env.local")]){if(!WQ(r))continue;let i=eY(GQ(r,"utf8"));for(let[n,o]of Object.entries(i))t[n]=o}return t}function Gt(e,t,r){return t[e]??r[e]}function Po(e,t){if(e.startsWith("~/"))return Pw(process.env.HOME??QQ(),e.slice(2));if(YQ(e))return e;return XQ(t,e)}function eY(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]=tY(s)}return t}function tY(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,`
110
110
  `).replace(/\\r/g,"\r").replace(/\\t/g,"\t").replace(/\\"/g,'"').replace(/\\\\/g,"\\");return e}var zw=()=>{};function C2(e,t,r){if(t===r)return!1;return t.includes(sY[e])}function $2(){return v2}function O2(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 Jm(e){return k2.replace("__SERVICE_NAME__",e.serviceName)}function Ic(e){return e.replace(/\nvolumes:\n(?: {2}- .*\n)+$/,`
111
111
  volumes:
112
112
  - __VOLUMES__
@@ -205,26 +205,25 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
205
205
  `+k.slice(ae,ge),ae=ge+1;pe=Ae}if(Ie+=`
206
206
  `,k.length-ae>W&&pe>ae)Ie+=k.slice(ae,pe)+`
207
207
  `+k.slice(pe+1);else Ie+=k.slice(ae);return Ie.slice(1)}function $u(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+`
208
- `;return""}return fI.dump=de,fI}function Ite(){if(wB)return Sr;wB=1;let e=kte(),t=Ete();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 Sr.Type=Nr(),Sr.Schema=vB(),Sr.FAILSAFE_SCHEMA=IB(),Sr.JSON_SCHEMA=OB(),Sr.CORE_SCHEMA=RB(),Sr.DEFAULT_SCHEMA=pI(),Sr.load=e.load,Sr.loadAll=e.loadAll,Sr.dump=t.dump,Sr.YAMLException=of(),Sr.types={binary:NB(),float:$B(),map:EB(),null:AB(),pairs:LB(),set:BB(),timestamp:PB(),bool:TB(),int:CB(),merge:zB(),omap:DB(),seq:kB(),str:_B()},Sr.safeLoad=r("safeLoad","load"),Sr.safeLoadAll=r("safeLoadAll","loadAll"),Sr.safeDump=r("safeDump","dump"),Sr}var Sr,Cg,Fo,QL,H1,YL,K1,XL,J1,eB,V1,tB,W1,rB,G1,nB,Q1,iB,Y1,oB,X1,sB,eI,aB,tI,cB,rI,lB,nI,uB,iI,dB,oI,fB,sI,pB,aI,mB,cI,hB,lI,gB,uI,yB,dI,bB,xB,fI,SB,wB,Ate,Tte,VOe,WOe,GOe,QOe,YOe,XOe,$g,eRe,mI,tRe,rRe,nRe,iRe,oRe;var Og=x(()=>{Sr={},Cg={},Fo={};fI={};Ate=Ite(),Tte=vte(Ate),{Type:VOe,Schema:WOe,FAILSAFE_SCHEMA:GOe,JSON_SCHEMA:QOe,CORE_SCHEMA:YOe,DEFAULT_SCHEMA:XOe,load:$g,loadAll:eRe,dump:mI,YAMLException:tRe,types:rRe,safeLoad:nRe,safeLoadAll:iRe,safeDump:oRe}=Tte});function sl(e){return mI(e,{skipInvalid:!0,noRefs:!0,sortKeys:!0})}function jB(e){return $g(e)}function qn(e,t){if(!e.trim())return{ok:!1,error:"file is empty"};let r;try{r=$g(e)}catch(n){return{ok:!1,error:at(n,"YAML parse error")}}if(!Cte(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 Cte(e){return Boolean(e)&&typeof e==="object"&&!Array.isArray(e)}var Hi=x(()=>{Og()});var $te,Ote,cn,Dr,la,Rte,ua="capability-bundles-v1",gI,Pte,zte,qB,Rg,da,Un,Nte,Dte,Lte,Bte,jte,yI,qte,Ute,Pg;var fa=x(()=>{Re();$te=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/,Ote=/^[a-z0-9]+(?:-[a-z0-9]+)*$/,cn=f.string().regex($te,"expected exact pinned version"),Dr=f.string().regex(Ote,"expected lowercase handle slug"),la=f.string().min(1),Rte=f.string().startsWith("age1").min(1),gI=f.enum(["core","media","automation","web","chat","site","publishing","federation","team"]),Pte=["professional","team","organization"],zte=f.enum(Pte),qB=f.array(gI).min(1),Rg=f.array(f.string().min(1)),da=f.strictObject({brainVersion:cn,bundleContract:f.literal(ua),bundles:qB,add:Rg.optional(),remove:Rg.optional(),githubOrg:f.string().min(1),contentRepoPrefix:f.string().min(1),domainSuffix:f.string().min(1),aiApiKey:la,gitSyncToken:la,contentRepoAdminToken:la,agePublicKey:Rte}).superRefine((e,t)=>{if(new Set(e.bundles).size!==e.bundles.length)t.addIssue({code:f.ZodIssueCode.custom,path:["bundles"],message:"canonical bundles must be unique"})}),Un=f.strictObject({members:f.array(Dr).min(1),brainVersionOverride:cn.optional(),bundlesOverride:qB.optional(),addOverride:Rg.optional(),removeOverride:Rg.optional(),aiApiKeyOverride:la.optional(),gitSyncTokenOverride:la.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"});if(e.bundlesOverride&&new Set(e.bundlesOverride).size!==e.bundlesOverride.length)t.addIssue({code:f.ZodIssueCode.custom,path:["bundlesOverride"],message:"canonical bundle overrides must be unique"})}),Nte=f.strictObject({platform:f.enum(["github","instagram","linkedin","email","website"]),url:f.string().min(1),label:f.string().min(1).optional()}),Dte=f.strictObject({name:f.string().min(1).optional(),description:f.string().min(1).optional(),website:f.string().min(1).optional(),email:f.string().min(1).optional(),story:f.string().min(1).optional(),socialLinks:f.array(Nte).optional()}),Lte=f.strictObject({delivery:f.literal("email"),email:f.string().email()}),Bte=f.strictObject({enabled:f.boolean().optional(),endpoint:f.string().url().refine((e)=>new URL(e).protocol==="wss:",{message:"Jetstream endpoint must use wss"}).optional(),replayWindowSeconds:f.number().int().min(60).optional(),denyDids:f.array(f.string().startsWith("did:plc:")).optional(),denyDomains:f.array(f.string().min(1)).optional(),skillKeywords:f.array(f.string().min(1)).optional(),queueLimit:f.number().int().min(1).max(1e4).optional(),concurrency:f.number().int().min(1).max(32).optional(),perDidCooldownSeconds:f.number().int().nonnegative().optional(),fetchBudgetPerMinute:f.number().int().min(1).optional(),newAgentsPerHour:f.number().int().min(1).optional(),pendingCandidateCeiling:f.number().int().min(1).optional(),staleCandidateRetentionDays:f.number().int().min(1).optional(),requestTimeoutMs:f.number().int().min(100).optional(),maxResponseBytes:f.number().int().min(1024).optional(),maxRedirects:f.number().int().nonnegative().optional(),retryAttempts:f.number().int().min(1).optional(),heartbeatIntervalHours:f.number().min(1).optional()}),jte=f.strictObject({identifier:f.string().min(1),accountDid:f.string().min(1).optional(),lexiconAuthority:f.boolean().optional(),jetstream:Bte.optional()}),yI=f.strictObject({package:f.string().min(1),version:cn,theme:f.string().min(1).optional(),themeVersion:cn.optional()}).superRefine((e,t)=>{let r=e.theme?.startsWith("@rizom/")===!0;if(r&&e.themeVersion===void 0)t.addIssue({code:f.ZodIssueCode.custom,path:["themeVersion"],message:"external @rizom themes require an exact version pin"});if(!r&&e.themeVersion!==void 0)t.addIssue({code:f.ZodIssueCode.custom,path:["themeVersion"],message:"themeVersion is valid only for external @rizom themes"})}),qte=f.strictObject({onboarding:f.boolean().optional()}),Ute=f.record(f.string().min(1),f.record(f.string(),f.unknown())),Pg=f.strictObject({handle:Dr,discord:f.strictObject({enabled:f.boolean(),anchorUserId:f.string().min(1).optional()}),aiApiKeyOverride:la.optional(),gitSyncTokenOverride:la.optional(),domainOverride:f.string().min(1).optional(),cloudflareZoneId:f.string().min(1).optional(),contentRepoOverride:f.string().min(1).optional(),profileKind:zte.optional(),plugins:Ute.optional(),embeddingEnabled:f.boolean().optional(),topicExtractionEnabled:f.boolean().optional(),skillDerivationEnabled:f.boolean().optional(),swotDerivationEnabled:f.boolean().optional(),addOverride:f.array(f.string().min(1)).optional(),removeOverride:f.array(f.string().min(1)).optional(),siteOverride:yI.optional(),setup:Lte.optional(),atproto:jte.optional(),playbooks:qte.optional(),anchorProfile:Dte.optional()})});import{access as Mte,readdir as Fte,readFile as Zte}from"fs/promises";import{basename as bI,join as sf,relative as Hte}from"path";async function Zt(e,t={}){let[r,i,n]=await Promise.all([xI(sf(e,"pilot.yaml"),da),Kte(e),Jte(e)]),o=Vte(i,n),s=n.map((c)=>({id:c.id,members:[...c.data.members].sort(),...c.data.brainVersionOverride?{brainVersionOverride:c.data.brainVersionOverride}:{},...c.data.bundlesOverride?{bundlesOverride:c.data.bundlesOverride}:{},...c.data.addOverride?{addOverride:c.data.addOverride}:{},...c.data.removeOverride?{removeOverride:c.data.removeOverride}:{},...c.data.aiApiKeyOverride?{aiApiKeyOverride:c.data.aiApiKeyOverride}:{},...c.data.gitSyncTokenOverride?{gitSyncTokenOverride:c.data.gitSyncTokenOverride}:{}})).sort((c,l)=>c.id.localeCompare(l.id)),a=await Promise.all(i.map(async(c)=>{let l=o.get(c.data.handle);if(!l)throw new pa(`User ${c.data.handle} must belong to exactly one cohort`);let u=l.data.brainVersionOverride??r.brainVersion,d={handle:c.data.handle,cohort:l.id,brainVersion:u,bundleContract:r.bundleContract,bundles:[...l.data.bundlesOverride??r.bundles],add:UB([...l.data.addOverride??(l.data.bundlesOverride?[]:r.add??[]),...c.data.addOverride??[]]),remove:UB([...l.data.removeOverride??(l.data.bundlesOverride?[]:r.remove??[]),...c.data.removeOverride??[]]),domain:c.data.domainOverride??`${c.data.handle}${r.domainSuffix}`,...c.data.cloudflareZoneId?{cloudflareZoneId:c.data.cloudflareZoneId}:{},contentRepo:c.data.contentRepoOverride??`${r.contentRepoPrefix}${c.data.handle}-content`,...c.data.profileKind?{profileKind:c.data.profileKind}:{},...c.data.embeddingEnabled!==void 0?{embeddingEnabled:c.data.embeddingEnabled}:{},...c.data.plugins!==void 0?{plugins:c.data.plugins}:{},...c.data.topicExtractionEnabled!==void 0?{topicExtractionEnabled:c.data.topicExtractionEnabled}:{},...c.data.skillDerivationEnabled!==void 0?{skillDerivationEnabled:c.data.skillDerivationEnabled}:{},...c.data.swotDerivationEnabled!==void 0?{swotDerivationEnabled:c.data.swotDerivationEnabled}:{},...c.data.siteOverride?{siteOverride:{...c.data.siteOverride}}:{},discordEnabled:c.data.discord.enabled,...c.data.discord.anchorUserId?{discordAnchorUserId:c.data.discord.anchorUserId}:{},effectiveAiApiKey:c.data.aiApiKeyOverride??l.data.aiApiKeyOverride??r.aiApiKey,effectiveGitSyncToken:c.data.gitSyncTokenOverride??l.data.gitSyncTokenOverride??r.gitSyncToken,...c.data.setup?{setup:c.data.setup}:{},...c.data.atproto?{atproto:c.data.atproto}:{},...c.data.playbooks?{playbooks:c.data.playbooks}:{},anchorProfile:Wte(c.data.handle,c.data.anchorProfile),snapshotStatus:await Qte(e,c.data.handle)},p=await t.resolveStatus?.(d);return{...d,serverStatus:p?.serverStatus??"unknown",deployStatus:p?.deployStatus??"unknown",dnsStatus:p?.dnsStatus??"unknown",mcpStatus:p?.mcpStatus??"unknown"}}));return a.sort((c,l)=>c.handle.localeCompare(l.handle)),{pilot:r,cohorts:s,users:a}}async function Kte(e){let t=sf(e,"users"),r=(await MB(t)).filter((n)=>!bI(n).endsWith(".secrets.yaml"));return(await Promise.all(r.map(async(n)=>{let o=FB(bI(n)),s=await xI(n,Pg);if(s.handle!==o){let a=ZB(Hte(e,n));throw new pa(`${a} must declare handle: ${o}`)}return{id:o,data:s}}))).sort((n,o)=>n.id.localeCompare(o.id))}async function Jte(e){let t=sf(e,"cohorts"),r=await MB(t);return(await Promise.all(r.map(async(n)=>({id:FB(bI(n)),data:await xI(n,Un)})))).sort((n,o)=>n.id.localeCompare(o.id))}function Vte(e,t){let r=new Map(e.map((n)=>[n.data.handle,n])),i=new Map;for(let n of t)for(let o of n.data.members){if(!r.has(o))throw new pa(`Cohort ${n.id} references unknown user ${o}`);if(i.has(o))throw new pa(`User ${o} must belong to exactly one cohort`);i.set(o,n)}for(let n of e)if(!i.has(n.data.handle))throw new pa(`User ${n.data.handle} must belong to exactly one cohort`);return i}function Wte(e,t){return{name:t?.name??Gte(e),...t?.description?{description:t.description}:{},...t?.website?{website:t.website}:{},...t?.email?{email:t.email}:{},...t?.story?{story:t.story}:{},...t?.socialLinks?{socialLinks:t.socialLinks.map((r)=>({platform:r.platform,url:r.url,...r.label?{label:r.label}:{}}))}:{}}}function Gte(e){return e.split("-").filter((t)=>t.length>0).map((t)=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}async function Qte(e,t){let r=sf(e,"users",t,"brain.yaml");try{return await Mte(r),"present"}catch{return"missing"}}async function MB(e){return(await Fte(e,{withFileTypes:!0})).filter((r)=>r.isFile()&&r.name.endsWith(".yaml")).map((r)=>sf(e,r.name)).sort((r,i)=>r.localeCompare(i))}async function xI(e,t){let r=await Zte(e,"utf8"),i=qn(r,t);if(!i.ok)throw new pa(`${ZB(e)}: ${i.error}`);return i.data}function UB(e){return[...new Set(e)]}function FB(e){return e.replace(/\.ya?ml$/,"")}function ZB(e){return e.replaceAll("\\","/")}var pa;var pi=x(()=>{Hi();fa();pa=class pa extends Error{}});import{mkdir as nre,writeFile as ire}from"fs/promises";import{join as VB}from"path";async function Zo(e,t={}){let i=(t.registry??await Zt(e,t)).users.map((o)=>{let s=o.discordEnabled?"on":"off";return[o.handle,o.cohort,o.bundles.join(","),o.add.join(","),o.remove.join(","),o.brainVersion,o.domain,o.contentRepo,s,o.serverStatus,o.deployStatus,o.dnsStatus,o.mcpStatus]}),n=["<!-- generated by brains-ops; do not edit -->","",ore,sre,...i.map((o)=>`| ${o.join(" | ")} |`),""].join(`
209
- `);await nre(VB(e,"views"),{recursive:!0}),await ire(VB(e,"views","users.md"),n)}var ore="| handle | cohort | bundles | add | remove | brainVersion | domain | contentRepo | discord | serverStatus | deployStatus | dnsStatus | mcpStatus |",sre="| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |";var af=x(()=>{pi()});function _I(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 rj(e,t){let{org:r,name:i}=_I(e,t);return`${r}/${i}`}function aj(e){return Fre.safeParse(e).success}function kI(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(aj(i[n])&&aj(o))i[n]=kI(i[n],o,r);else i[n]=o}return i}var Fre;var cj=x(()=>{Re();Fre=f.record(f.string(),f.unknown())});var lj=x(()=>{Ui()});import{createHash as Zre}from"crypto";function uj(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<=Hre)return n;let o=Zre("sha256").update(i.join(`
210
- `)).digest("hex");return`${r}--s${o.slice(0,12)}`}function dj(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}`]}var Hre=128;var fj=x(()=>{lj();pi();Ui()});function Ng(e){return async(t)=>({brainYaml:Kre(t,e),envFile:Gre(t,e),contentRepoFiles:Vre(t)})}function Kre(e,t){let r={...e.setup?.delivery==="email"?{"auth-service":{setupEmail:Jre(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:pj(e,t),authToken:"${GIT_SYNC_TOKEN}"}},...e.atproto?{atproto:{...e.atproto,appPassword:"${ATPROTO_APP_PASSWORD}"}}:{}};return sl({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:kI(r,e.plugins??{},{nulls:"preserve"})})}function pj(e,t){return rj(e.contentRepo,t)}function Jre(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(`
211
- `)}}function Vre(e){return[{path:"anchor-profile/anchor-profile.md",content:Wre(e)}]}function Wre(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`---
208
+ `;return""}return fI.dump=de,fI}function Ite(){if(wB)return Sr;wB=1;let e=kte(),t=Ete();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 Sr.Type=Nr(),Sr.Schema=vB(),Sr.FAILSAFE_SCHEMA=IB(),Sr.JSON_SCHEMA=OB(),Sr.CORE_SCHEMA=RB(),Sr.DEFAULT_SCHEMA=pI(),Sr.load=e.load,Sr.loadAll=e.loadAll,Sr.dump=t.dump,Sr.YAMLException=of(),Sr.types={binary:NB(),float:$B(),map:EB(),null:AB(),pairs:LB(),set:BB(),timestamp:PB(),bool:TB(),int:CB(),merge:zB(),omap:DB(),seq:kB(),str:_B()},Sr.safeLoad=r("safeLoad","load"),Sr.safeLoadAll=r("safeLoadAll","loadAll"),Sr.safeDump=r("safeDump","dump"),Sr}var Sr,Cg,Fo,QL,H1,YL,K1,XL,J1,eB,V1,tB,W1,rB,G1,nB,Q1,iB,Y1,oB,X1,sB,eI,aB,tI,cB,rI,lB,nI,uB,iI,dB,oI,fB,sI,pB,aI,mB,cI,hB,lI,gB,uI,yB,dI,bB,xB,fI,SB,wB,Ate,Tte,JOe,VOe,WOe,GOe,QOe,YOe,$g,XOe,mI,eRe,tRe,rRe,nRe,iRe;var Og=x(()=>{Sr={},Cg={},Fo={};fI={};Ate=Ite(),Tte=vte(Ate),{Type:JOe,Schema:VOe,FAILSAFE_SCHEMA:WOe,JSON_SCHEMA:GOe,CORE_SCHEMA:QOe,DEFAULT_SCHEMA:YOe,load:$g,loadAll:XOe,dump:mI,YAMLException:eRe,types:tRe,safeLoad:rRe,safeLoadAll:nRe,safeDump:iRe}=Tte});function sl(e){return mI(e,{skipInvalid:!0,noRefs:!0,sortKeys:!0})}function jB(e){return $g(e)}function qn(e,t){if(!e.trim())return{ok:!1,error:"file is empty"};let r;try{r=$g(e)}catch(n){return{ok:!1,error:at(n,"YAML parse error")}}if(!Cte(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 Cte(e){return Boolean(e)&&typeof e==="object"&&!Array.isArray(e)}var Hi=x(()=>{Og()});var $te,Ote,cn,Dr,la,Rte,ua="capability-bundles-v1",gI,Pte,zte,qB,Rg,da,Un,Nte,Dte,Lte,Bte,jte,yI,qte,Ute,Pg;var fa=x(()=>{Re();$te=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/,Ote=/^[a-z0-9]+(?:-[a-z0-9]+)*$/,cn=f.string().regex($te,"expected exact pinned version"),Dr=f.string().regex(Ote,"expected lowercase handle slug"),la=f.string().min(1),Rte=f.string().startsWith("age1").min(1),gI=f.enum(["core","media","automation","web","chat","site","publishing","federation","team"]),Pte=["professional","team","organization"],zte=f.enum(Pte),qB=f.array(gI).min(1),Rg=f.array(f.string().min(1)),da=f.strictObject({brainVersion:cn,bundleContract:f.literal(ua),bundles:qB,add:Rg.optional(),remove:Rg.optional(),githubOrg:f.string().min(1),contentRepoPrefix:f.string().min(1),domainSuffix:f.string().min(1),aiApiKey:la,gitSyncToken:la,contentRepoAdminToken:la,agePublicKey:Rte}).superRefine((e,t)=>{if(new Set(e.bundles).size!==e.bundles.length)t.addIssue({code:f.ZodIssueCode.custom,path:["bundles"],message:"canonical bundles must be unique"})}),Un=f.strictObject({members:f.array(Dr).min(1),brainVersionOverride:cn.optional(),bundlesOverride:qB.optional(),addOverride:Rg.optional(),removeOverride:Rg.optional(),aiApiKeyOverride:la.optional(),gitSyncTokenOverride:la.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"});if(e.bundlesOverride&&new Set(e.bundlesOverride).size!==e.bundlesOverride.length)t.addIssue({code:f.ZodIssueCode.custom,path:["bundlesOverride"],message:"canonical bundle overrides must be unique"})}),Nte=f.strictObject({platform:f.enum(["github","instagram","linkedin","email","website"]),url:f.string().min(1),label:f.string().min(1).optional()}),Dte=f.strictObject({name:f.string().min(1).optional(),description:f.string().min(1).optional(),website:f.string().min(1).optional(),email:f.string().min(1).optional(),story:f.string().min(1).optional(),socialLinks:f.array(Nte).optional()}),Lte=f.strictObject({delivery:f.literal("email"),email:f.string().email()}),Bte=f.strictObject({enabled:f.boolean().optional(),endpoint:f.string().url().refine((e)=>new URL(e).protocol==="wss:",{message:"Jetstream endpoint must use wss"}).optional(),replayWindowSeconds:f.number().int().min(60).optional(),denyDids:f.array(f.string().startsWith("did:plc:")).optional(),denyDomains:f.array(f.string().min(1)).optional(),skillKeywords:f.array(f.string().min(1)).optional(),queueLimit:f.number().int().min(1).max(1e4).optional(),concurrency:f.number().int().min(1).max(32).optional(),perDidCooldownSeconds:f.number().int().nonnegative().optional(),fetchBudgetPerMinute:f.number().int().min(1).optional(),newAgentsPerHour:f.number().int().min(1).optional(),pendingCandidateCeiling:f.number().int().min(1).optional(),staleCandidateRetentionDays:f.number().int().min(1).optional(),requestTimeoutMs:f.number().int().min(100).optional(),maxResponseBytes:f.number().int().min(1024).optional(),maxRedirects:f.number().int().nonnegative().optional(),retryAttempts:f.number().int().min(1).optional(),heartbeatIntervalHours:f.number().min(1).optional()}),jte=f.strictObject({identifier:f.string().min(1),accountDid:f.string().min(1).optional(),lexiconAuthority:f.boolean().optional(),jetstream:Bte.optional()}),yI=f.strictObject({package:f.string().min(1),version:cn,theme:f.string().min(1).optional(),themeVersion:cn.optional()}).superRefine((e,t)=>{let r=e.theme?.startsWith("@rizom/")===!0;if(r&&e.themeVersion===void 0)t.addIssue({code:f.ZodIssueCode.custom,path:["themeVersion"],message:"external @rizom themes require an exact version pin"});if(!r&&e.themeVersion!==void 0)t.addIssue({code:f.ZodIssueCode.custom,path:["themeVersion"],message:"themeVersion is valid only for external @rizom themes"})}),qte=f.strictObject({onboarding:f.boolean().optional()}),Ute=f.record(f.string().min(1),f.record(f.string(),f.unknown())),Pg=f.strictObject({handle:Dr,discord:f.strictObject({enabled:f.boolean(),anchorUserId:f.string().min(1).optional()}),aiApiKeyOverride:la.optional(),gitSyncTokenOverride:la.optional(),domainOverride:f.string().min(1).optional(),cloudflareZoneId:f.string().min(1).optional(),contentRepoOverride:f.string().min(1).optional(),profileKind:zte.optional(),plugins:Ute.optional(),embeddingEnabled:f.boolean().optional(),topicExtractionEnabled:f.boolean().optional(),skillDerivationEnabled:f.boolean().optional(),swotDerivationEnabled:f.boolean().optional(),addOverride:f.array(f.string().min(1)).optional(),removeOverride:f.array(f.string().min(1)).optional(),siteOverride:yI.optional(),setup:Lte.optional(),atproto:jte.optional(),playbooks:qte.optional(),anchorProfile:Dte.optional()})});import{access as Mte,readdir as Fte,readFile as Zte}from"fs/promises";import{basename as bI,join as sf,relative as Hte}from"path";async function Zt(e,t={}){let[r,i,n]=await Promise.all([xI(sf(e,"pilot.yaml"),da),Kte(e),Jte(e)]),o=Vte(i,n),s=n.map((c)=>({id:c.id,members:[...c.data.members].sort(),...c.data.brainVersionOverride?{brainVersionOverride:c.data.brainVersionOverride}:{},...c.data.bundlesOverride?{bundlesOverride:c.data.bundlesOverride}:{},...c.data.addOverride?{addOverride:c.data.addOverride}:{},...c.data.removeOverride?{removeOverride:c.data.removeOverride}:{},...c.data.aiApiKeyOverride?{aiApiKeyOverride:c.data.aiApiKeyOverride}:{},...c.data.gitSyncTokenOverride?{gitSyncTokenOverride:c.data.gitSyncTokenOverride}:{}})).sort((c,l)=>c.id.localeCompare(l.id)),a=await Promise.all(i.map(async(c)=>{let l=o.get(c.data.handle);if(!l)throw new pa(`User ${c.data.handle} must belong to exactly one cohort`);let u=l.data.brainVersionOverride??r.brainVersion,d={handle:c.data.handle,cohort:l.id,brainVersion:u,bundleContract:r.bundleContract,bundles:[...l.data.bundlesOverride??r.bundles],add:UB([...l.data.addOverride??(l.data.bundlesOverride?[]:r.add??[]),...c.data.addOverride??[]]),remove:UB([...l.data.removeOverride??(l.data.bundlesOverride?[]:r.remove??[]),...c.data.removeOverride??[]]),domain:c.data.domainOverride??`${c.data.handle}${r.domainSuffix}`,...c.data.cloudflareZoneId?{cloudflareZoneId:c.data.cloudflareZoneId}:{},contentRepo:c.data.contentRepoOverride??`${r.contentRepoPrefix}${c.data.handle}-content`,...c.data.profileKind?{profileKind:c.data.profileKind}:{},...c.data.embeddingEnabled!==void 0?{embeddingEnabled:c.data.embeddingEnabled}:{},...c.data.plugins!==void 0?{plugins:c.data.plugins}:{},...c.data.topicExtractionEnabled!==void 0?{topicExtractionEnabled:c.data.topicExtractionEnabled}:{},...c.data.skillDerivationEnabled!==void 0?{skillDerivationEnabled:c.data.skillDerivationEnabled}:{},...c.data.swotDerivationEnabled!==void 0?{swotDerivationEnabled:c.data.swotDerivationEnabled}:{},...c.data.siteOverride?{siteOverride:{...c.data.siteOverride}}:{},discordEnabled:c.data.discord.enabled,...c.data.discord.anchorUserId?{discordAnchorUserId:c.data.discord.anchorUserId}:{},effectiveAiApiKey:c.data.aiApiKeyOverride??l.data.aiApiKeyOverride??r.aiApiKey,effectiveGitSyncToken:c.data.gitSyncTokenOverride??l.data.gitSyncTokenOverride??r.gitSyncToken,...c.data.setup?{setup:c.data.setup}:{},...c.data.atproto?{atproto:c.data.atproto}:{},...c.data.playbooks?{playbooks:c.data.playbooks}:{},anchorProfile:Wte(c.data.handle,c.data.anchorProfile),snapshotStatus:await Qte(e,c.data.handle)},p=await t.resolveStatus?.(d);return{...d,serverStatus:p?.serverStatus??"unknown",deployStatus:p?.deployStatus??"unknown",dnsStatus:p?.dnsStatus??"unknown",mcpStatus:p?.mcpStatus??"unknown"}}));return a.sort((c,l)=>c.handle.localeCompare(l.handle)),{pilot:r,cohorts:s,users:a}}async function Kte(e){let t=sf(e,"users"),r=(await MB(t)).filter((n)=>!bI(n).endsWith(".secrets.yaml"));return(await Promise.all(r.map(async(n)=>{let o=FB(bI(n)),s=await xI(n,Pg);if(s.handle!==o){let a=ZB(Hte(e,n));throw new pa(`${a} must declare handle: ${o}`)}return{id:o,data:s}}))).sort((n,o)=>n.id.localeCompare(o.id))}async function Jte(e){let t=sf(e,"cohorts"),r=await MB(t);return(await Promise.all(r.map(async(n)=>({id:FB(bI(n)),data:await xI(n,Un)})))).sort((n,o)=>n.id.localeCompare(o.id))}function Vte(e,t){let r=new Map(e.map((n)=>[n.data.handle,n])),i=new Map;for(let n of t)for(let o of n.data.members){if(!r.has(o))throw new pa(`Cohort ${n.id} references unknown user ${o}`);if(i.has(o))throw new pa(`User ${o} must belong to exactly one cohort`);i.set(o,n)}for(let n of e)if(!i.has(n.data.handle))throw new pa(`User ${n.data.handle} must belong to exactly one cohort`);return i}function Wte(e,t){return{name:t?.name??Gte(e),...t?.description?{description:t.description}:{},...t?.website?{website:t.website}:{},...t?.email?{email:t.email}:{},...t?.story?{story:t.story}:{},...t?.socialLinks?{socialLinks:t.socialLinks.map((r)=>({platform:r.platform,url:r.url,...r.label?{label:r.label}:{}}))}:{}}}function Gte(e){return e.split("-").filter((t)=>t.length>0).map((t)=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}async function Qte(e,t){let r=sf(e,"users",t,"brain.yaml");try{return await Mte(r),"present"}catch{return"missing"}}async function MB(e){return(await Fte(e,{withFileTypes:!0})).filter((r)=>r.isFile()&&r.name.endsWith(".yaml")).map((r)=>sf(e,r.name)).sort((r,i)=>r.localeCompare(i))}async function xI(e,t){let r=await Zte(e,"utf8"),i=qn(r,t);if(!i.ok)throw new pa(`${ZB(e)}: ${i.error}`);return i.data}function UB(e){return[...new Set(e)]}function FB(e){return e.replace(/\.ya?ml$/,"")}function ZB(e){return e.replaceAll("\\","/")}var pa;var pi=x(()=>{Hi();fa();pa=class pa extends Error{}});import{mkdir as nre,writeFile as ire}from"fs/promises";import{join as VB}from"path";async function Zo(e,t={}){let i=(t.registry??await Zt(e,t)).users.map((o)=>{let s=o.discordEnabled?"on":"off";return[o.handle,o.cohort,o.bundles.join(","),o.add.join(","),o.remove.join(","),o.brainVersion,o.domain,o.contentRepo,s,o.serverStatus,o.deployStatus,o.dnsStatus,o.mcpStatus]}),n=["<!-- generated by brains-ops; do not edit -->","",ore,sre,...i.map((o)=>`| ${o.join(" | ")} |`),""].join(`
209
+ `);await nre(VB(e,"views"),{recursive:!0}),await ire(VB(e,"views","users.md"),n)}var ore="| handle | cohort | bundles | add | remove | brainVersion | domain | contentRepo | discord | serverStatus | deployStatus | dnsStatus | mcpStatus |",sre="| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |";var af=x(()=>{pi()});function _I(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 r6(e,t){let{org:r,name:i}=_I(e,t);return`${r}/${i}`}function a6(e){return Fre.safeParse(e).success}function kI(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(a6(i[n])&&a6(o))i[n]=kI(i[n],o,r);else i[n]=o}return i}var Fre;var c6=x(()=>{Re();Fre=f.record(f.string(),f.unknown())});var l6=x(()=>{Ui()});import{createHash as Zre}from"crypto";function u6(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<=Hre)return n;let o=Zre("sha256").update(i.join(`
210
+ `)).digest("hex");return`${r}--s${o.slice(0,12)}`}function d6(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}`]}var Hre=128;var f6=x(()=>{l6();pi();Ui()});function Ng(e){return async(t)=>({brainYaml:Kre(t,e),envFile:Wre(t,e),contentRepoFiles:Jre(t)})}function Kre(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:p6(e,t),authToken:"${GIT_SYNC_TOKEN}"}},...e.atproto?{atproto:{...e.atproto,appPassword:"${ATPROTO_APP_PASSWORD}"}}:{}};return sl({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:kI(r,e.plugins??{},{nulls:"preserve"})})}function p6(e,t){return r6(e.contentRepo,t)}function Jre(e){return[{path:"anchor-profile/anchor-profile.md",content:Vre(e)}]}function Vre(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`---
212
211
  ${sl(t).trimEnd()}
213
212
  ---
214
213
 
215
214
  ${r}
216
- `}function Gre(e,t){let r=dj(e.siteOverride);return[`BRAIN_VERSION=${e.brainVersion}`,...r.length>0?[`IMAGE_TAG=${uj(e.brainVersion,r)}`]:[],`CONTENT_REPO=${pj(e,t)}`,""].join(`
217
- `)}var EI=x(()=>{cj();fj();Hi()});var Hj={};tr(Hj,{upgradePilotRepo:()=>cie});import{readFile as iie}from"fs/promises";import{join as oie}from"path";async function Zj(e){let t=oie(e,"package.json"),i=sie.parse(JSON.parse(await iie(t,"utf8"))).devDependencies?.["@rizom/ops"];if(!i)throw Error(`${t} does not pin @rizom/ops as a devDependency`);return i}async function aie(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 cie(e,t={}){let r=t.exec??aie,i=await Zj(e),n=t.version??"latest";await r(["bun","add","--dev","--exact",`@rizom/ops@${n}`],e);let o=await Zj(e);return await r(["bun","x","brains-ops","init","."],e),{from:i,to:o}}var sie;var Kj=x(()=>{Re();sie=f.object({devDependencies:f.record(f.string(),f.string()).optional()})});function Jj(e){if(e===null||typeof e!=="object"||Array.isArray(e))return!1;let t=lie(e);return t===Object.prototype||t===null}var lie;var Vj=x(()=>{lie=Object.getPrototypeOf});var Ge=ee(function(yie){var RI=Symbol.for("yaml.alias"),Wj=Symbol.for("yaml.document"),Ug=Symbol.for("yaml.map"),Gj=Symbol.for("yaml.pair"),PI=Symbol.for("yaml.scalar"),Mg=Symbol.for("yaml.seq"),Ji=Symbol.for("yaml.node.type"),uie=(e)=>!!e&&typeof e==="object"&&e[Ji]===RI,die=(e)=>!!e&&typeof e==="object"&&e[Ji]===Wj,fie=(e)=>!!e&&typeof e==="object"&&e[Ji]===Ug,pie=(e)=>!!e&&typeof e==="object"&&e[Ji]===Gj,Qj=(e)=>!!e&&typeof e==="object"&&e[Ji]===PI,mie=(e)=>!!e&&typeof e==="object"&&e[Ji]===Mg;function Yj(e){if(e&&typeof e==="object")switch(e[Ji]){case Ug:case Mg:return!0}return!1}function hie(e){if(e&&typeof e==="object")switch(e[Ji]){case RI:case Ug:case PI:case Mg:return!0}return!1}var gie=(e)=>(Qj(e)||Yj(e))&&!!e.anchor;yie.ALIAS=RI;yie.DOC=Wj;yie.MAP=Ug;yie.NODE_TYPE=Ji;yie.PAIR=Gj;yie.SCALAR=PI;yie.SEQ=Mg;yie.hasAnchor=gie;yie.isAlias=uie;yie.isCollection=Yj;yie.isDocument=die;yie.isMap=fie;yie.isNode=hie;yie.isPair=pie;yie.isScalar=Qj;yie.isSeq=mie});var uf=ee(function(zie){var Ht=Ge(),Vr=Symbol("break visit"),Xj=Symbol("skip children"),mi=Symbol("remove node");function Fg(e,t){let r=e6(t);if(Ht.isDocument(e)){if(ul(null,e.contents,r,Object.freeze([e]))===mi)e.contents=null}else ul(null,e,r,Object.freeze([]))}Fg.BREAK=Vr;Fg.SKIP=Xj;Fg.REMOVE=mi;function ul(e,t,r,i){let n=t6(e,t,r,i);if(Ht.isNode(n)||Ht.isPair(n))return r6(e,i,n),ul(e,n,r,i);if(typeof n!=="symbol"){if(Ht.isCollection(t)){i=Object.freeze(i.concat(t));for(let o=0;o<t.items.length;++o){let s=ul(o,t.items[o],r,i);if(typeof s==="number")o=s-1;else if(s===Vr)return Vr;else if(s===mi)t.items.splice(o,1),o-=1}}else if(Ht.isPair(t)){i=Object.freeze(i.concat(t));let o=ul("key",t.key,r,i);if(o===Vr)return Vr;else if(o===mi)t.key=null;let s=ul("value",t.value,r,i);if(s===Vr)return Vr;else if(s===mi)t.value=null}}return n}async function Zg(e,t){let r=e6(t);if(Ht.isDocument(e)){if(await dl(null,e.contents,r,Object.freeze([e]))===mi)e.contents=null}else await dl(null,e,r,Object.freeze([]))}Zg.BREAK=Vr;Zg.SKIP=Xj;Zg.REMOVE=mi;async function dl(e,t,r,i){let n=await t6(e,t,r,i);if(Ht.isNode(n)||Ht.isPair(n))return r6(e,i,n),dl(e,n,r,i);if(typeof n!=="symbol"){if(Ht.isCollection(t)){i=Object.freeze(i.concat(t));for(let o=0;o<t.items.length;++o){let s=await dl(o,t.items[o],r,i);if(typeof s==="number")o=s-1;else if(s===Vr)return Vr;else if(s===mi)t.items.splice(o,1),o-=1}}else if(Ht.isPair(t)){i=Object.freeze(i.concat(t));let o=await dl("key",t.key,r,i);if(o===Vr)return Vr;else if(o===mi)t.key=null;let s=await dl("value",t.value,r,i);if(s===Vr)return Vr;else if(s===mi)t.value=null}}return n}function e6(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 t6(e,t,r,i){if(typeof r==="function")return r(e,t,i);if(Ht.isMap(t))return r.Map?.(e,t,i);if(Ht.isSeq(t))return r.Seq?.(e,t,i);if(Ht.isPair(t))return r.Pair?.(e,t,i);if(Ht.isScalar(t))return r.Scalar?.(e,t,i);if(Ht.isAlias(t))return r.Alias?.(e,t,i);return}function r6(e,t,r){let i=t[t.length-1];if(Ht.isCollection(i))i.items[e]=r;else if(Ht.isPair(i))if(e==="key")i.key=r;else i.value=r;else if(Ht.isDocument(i))i.contents=r;else{let n=Ht.isAlias(i)?"alias":"scalar";throw Error(`Cannot replace node with ${n} parent`)}}zie.visit=Fg;zie.visitAsync=Zg});var zI=ee(function(qie){var n6=Ge(),Lie=uf(),Bie={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},jie=(e)=>e.replace(/[!,[\]{}]/g,(t)=>Bie[t]);class _n{constructor(e,t){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},_n.defaultYaml,e),this.tags=Object.assign({},_n.defaultTags,t)}clone(){let e=new _n(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){let e=new _n(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:_n.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},_n.defaultTags);break}return e}add(e,t){if(this.atNextDocument)this.yaml={explicit:_n.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},_n.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+jie(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&&n6.isNode(e.contents)){let n={};Lie.visit(e.contents,(o,s)=>{if(n6.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(`
218
- `)}}_n.defaultYaml={explicit:!1,version:"1.2"};_n.defaultTags={"!!":"tag:yaml.org,2002:"};qie.Directives=_n});var Hg=ee(function(Hie){var i6=Ge(),Mie=uf();function Fie(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 o6(e){let t=new Set;return Mie.visit(e,{Value(r,i){if(i.anchor)t.add(i.anchor)}}),t}function s6(e,t){for(let r=1;;++r){let i=`${e}${r}`;if(!t.has(i))return i}}function Zie(e,t){let r=[],i=new Map,n=null;return{onAnchor:(o)=>{r.push(o),n??(n=o6(e));let s=s6(t,n);return n.add(s),s},setAnchors:()=>{for(let o of r){let s=i.get(o);if(typeof s==="object"&&s.anchor&&(i6.isScalar(s.node)||i6.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}}Hie.anchorIsValid=Fie;Hie.anchorNames=o6;Hie.createNodeAnchors=Zie;Hie.findNewAnchor=s6});var NI=ee(function(Gie){function df(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=df(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=df(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=df(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=df(e,i,n,o);if(s===void 0)delete i[n];else if(s!==o)i[n]=s}return e.call(t,r,i)}Gie.applyReviver=df});var Ho=ee(function(Xie){var Yie=Ge();function a6(e,t,r){if(Array.isArray(e))return e.map((i,n)=>a6(i,String(n),r));if(e&&typeof e.toJSON==="function"){if(!r||!Yie.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}Xie.toJS=a6});var Kg=ee(function(noe){var toe=NI(),c6=Ge(),roe=Ho();class l6{constructor(e){Object.defineProperty(this,c6.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(!c6.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=roe.toJS(this,"",o);if(typeof i==="function")for(let{count:a,res:c}of o.anchors.values())i(c,a);return typeof n==="function"?toe.applyReviver(n,{"":s},"",s):s}}noe.NodeBase=l6});var ff=ee(function(loe){var ooe=Hg(),soe=uf(),fl=Ge(),aoe=Kg(),coe=Ho();class u6 extends aoe.NodeBase{constructor(e){super(fl.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=[],soe.visit(e,{Node:(n,o)=>{if(fl.isAlias(o)||fl.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)coe.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=Jg(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(ooe.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 Jg(e,t,r){if(fl.isAlias(t)){let i=t.resolve(e),n=r&&i&&r.get(i);return n?n.count*n.aliasCount:0}else if(fl.isCollection(t)){let i=0;for(let n of t.items){let o=Jg(e,n,r);if(o>i)i=o}return i}else if(fl.isPair(t)){let i=Jg(e,t.key,r),n=Jg(e,t.value,r);return Math.max(i,n)}return 1}loe.Alias=u6});var Bt=ee(function(hoe){var doe=Ge(),foe=Kg(),poe=Ho(),moe=(e)=>!e||typeof e!=="function"&&typeof e!=="object";class ma extends foe.NodeBase{constructor(e){super(doe.SCALAR);this.value=e}toJSON(e,t){return t?.keep?this.value:poe.toJS(this.value,e,t)}toString(){return String(this.value)}}ma.BLOCK_FOLDED="BLOCK_FOLDED";ma.BLOCK_LITERAL="BLOCK_LITERAL";ma.PLAIN="PLAIN";ma.QUOTE_DOUBLE="QUOTE_DOUBLE";ma.QUOTE_SINGLE="QUOTE_SINGLE";hoe.Scalar=ma;hoe.isScalarValue=moe});var pf=ee(function(voe){var boe=ff(),ha=Ge(),d6=Bt(),xoe="tag:yaml.org,2002:";function Soe(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 woe(e,t,r){if(ha.isDocument(e))e=e.contents;if(ha.isNode(e))return e;if(ha.isPair(e)){let d=r.schema[ha.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 boe.Alias(c.anchor);else c={anchor:null,node:null},a.set(e,c);if(t?.startsWith("!!"))t=xoe+t.slice(2);let l=Soe(e,t,s.tags);if(!l){if(e&&typeof e.toJSON==="function")e=e.toJSON();if(!e||typeof e!=="object"){let d=new d6.Scalar(e);if(c)c.node=d;return d}l=e instanceof Map?s[ha.MAP]:(Symbol.iterator in Object(e))?s[ha.SEQ]:s[ha.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 d6.Scalar(e);if(t)u.tag=t;else if(!l.default)u.tag=l.tag;if(c)c.node=u;return u}voe.createNode=woe});var Vg=ee(function(Ioe){var koe=pf(),hi=Ge(),Eoe=Kg();function DI(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 koe.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 f6=(e)=>e==null||typeof e==="object"&&!!e[Symbol.iterator]().next().done;class p6 extends Eoe.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)=>hi.isNode(r)||hi.isPair(r)?r.clone(e):r),this.range)t.range=this.range.slice();return t}addIn(e,t){if(f6(e))this.add(t);else{let[r,...i]=e,n=this.get(r,!0);if(hi.isCollection(n))n.addIn(i,t);else if(n===void 0&&this.schema)this.set(r,DI(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(hi.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&&hi.isScalar(n)?n.value:n;else return hi.isCollection(n)?n.getIn(i,t):void 0}hasAllNullValues(e){return this.items.every((t)=>{if(!hi.isPair(t))return!1;let r=t.value;return r==null||e&&hi.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 hi.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(hi.isCollection(n))n.setIn(i,t);else if(n===void 0&&this.schema)this.set(r,DI(this.schema,i,t));else throw Error(`Expected YAML collection at ${r}. Remaining path: ${i}`)}}}Ioe.Collection=p6;Ioe.collectionFromPath=DI;Ioe.isEmptyPath=f6});var mf=ee(function(Roe){var $oe=(e)=>e.replace(/^(?!$)(?: $)?/gm,"#");function LI(e,t){if(/^\n+$/.test(e))return e.substring(1);return t?e.replace(/^(?! *$)/gm,t):e}var Ooe=(e,t,r)=>e.endsWith(`
215
+ `}function Wre(e,t){let r=d6(e.siteOverride);return[`BRAIN_VERSION=${e.brainVersion}`,...r.length>0?[`IMAGE_TAG=${u6(e.brainVersion,r)}`]:[],`CONTENT_REPO=${p6(e,t)}`,""].join(`
216
+ `)}var EI=x(()=>{c6();f6();Hi()});var H6={};tr(H6,{upgradePilotRepo:()=>aie});import{readFile as nie}from"fs/promises";import{join as iie}from"path";async function Z6(e){let t=iie(e,"package.json"),i=oie.parse(JSON.parse(await nie(t,"utf8"))).devDependencies?.["@rizom/ops"];if(!i)throw Error(`${t} does not pin @rizom/ops as a devDependency`);return i}async function sie(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 aie(e,t={}){let r=t.exec??sie,i=await Z6(e),n=t.version??"latest";await r(["bun","add","--dev","--exact",`@rizom/ops@${n}`],e);let o=await Z6(e);return await r(["bun","x","brains-ops","init","."],e),{from:i,to:o}}var oie;var K6=x(()=>{Re();oie=f.object({devDependencies:f.record(f.string(),f.string()).optional()})});function J6(e){if(e===null||typeof e!=="object"||Array.isArray(e))return!1;let t=cie(e);return t===Object.prototype||t===null}var cie;var V6=x(()=>{cie=Object.getPrototypeOf});var Ge=ee(function(gie){var RI=Symbol.for("yaml.alias"),W6=Symbol.for("yaml.document"),Ug=Symbol.for("yaml.map"),G6=Symbol.for("yaml.pair"),PI=Symbol.for("yaml.scalar"),Mg=Symbol.for("yaml.seq"),Ji=Symbol.for("yaml.node.type"),lie=(e)=>!!e&&typeof e==="object"&&e[Ji]===RI,uie=(e)=>!!e&&typeof e==="object"&&e[Ji]===W6,die=(e)=>!!e&&typeof e==="object"&&e[Ji]===Ug,fie=(e)=>!!e&&typeof e==="object"&&e[Ji]===G6,Q6=(e)=>!!e&&typeof e==="object"&&e[Ji]===PI,pie=(e)=>!!e&&typeof e==="object"&&e[Ji]===Mg;function Y6(e){if(e&&typeof e==="object")switch(e[Ji]){case Ug:case Mg:return!0}return!1}function mie(e){if(e&&typeof e==="object")switch(e[Ji]){case RI:case Ug:case PI:case Mg:return!0}return!1}var hie=(e)=>(Q6(e)||Y6(e))&&!!e.anchor;gie.ALIAS=RI;gie.DOC=W6;gie.MAP=Ug;gie.NODE_TYPE=Ji;gie.PAIR=G6;gie.SCALAR=PI;gie.SEQ=Mg;gie.hasAnchor=hie;gie.isAlias=lie;gie.isCollection=Y6;gie.isDocument=uie;gie.isMap=die;gie.isNode=mie;gie.isPair=fie;gie.isScalar=Q6;gie.isSeq=pie});var uf=ee(function(Pie){var Ht=Ge(),Vr=Symbol("break visit"),X6=Symbol("skip children"),mi=Symbol("remove node");function Fg(e,t){let r=ej(t);if(Ht.isDocument(e)){if(ul(null,e.contents,r,Object.freeze([e]))===mi)e.contents=null}else ul(null,e,r,Object.freeze([]))}Fg.BREAK=Vr;Fg.SKIP=X6;Fg.REMOVE=mi;function ul(e,t,r,i){let n=tj(e,t,r,i);if(Ht.isNode(n)||Ht.isPair(n))return rj(e,i,n),ul(e,n,r,i);if(typeof n!=="symbol"){if(Ht.isCollection(t)){i=Object.freeze(i.concat(t));for(let o=0;o<t.items.length;++o){let s=ul(o,t.items[o],r,i);if(typeof s==="number")o=s-1;else if(s===Vr)return Vr;else if(s===mi)t.items.splice(o,1),o-=1}}else if(Ht.isPair(t)){i=Object.freeze(i.concat(t));let o=ul("key",t.key,r,i);if(o===Vr)return Vr;else if(o===mi)t.key=null;let s=ul("value",t.value,r,i);if(s===Vr)return Vr;else if(s===mi)t.value=null}}return n}async function Zg(e,t){let r=ej(t);if(Ht.isDocument(e)){if(await dl(null,e.contents,r,Object.freeze([e]))===mi)e.contents=null}else await dl(null,e,r,Object.freeze([]))}Zg.BREAK=Vr;Zg.SKIP=X6;Zg.REMOVE=mi;async function dl(e,t,r,i){let n=await tj(e,t,r,i);if(Ht.isNode(n)||Ht.isPair(n))return rj(e,i,n),dl(e,n,r,i);if(typeof n!=="symbol"){if(Ht.isCollection(t)){i=Object.freeze(i.concat(t));for(let o=0;o<t.items.length;++o){let s=await dl(o,t.items[o],r,i);if(typeof s==="number")o=s-1;else if(s===Vr)return Vr;else if(s===mi)t.items.splice(o,1),o-=1}}else if(Ht.isPair(t)){i=Object.freeze(i.concat(t));let o=await dl("key",t.key,r,i);if(o===Vr)return Vr;else if(o===mi)t.key=null;let s=await dl("value",t.value,r,i);if(s===Vr)return Vr;else if(s===mi)t.value=null}}return n}function ej(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 tj(e,t,r,i){if(typeof r==="function")return r(e,t,i);if(Ht.isMap(t))return r.Map?.(e,t,i);if(Ht.isSeq(t))return r.Seq?.(e,t,i);if(Ht.isPair(t))return r.Pair?.(e,t,i);if(Ht.isScalar(t))return r.Scalar?.(e,t,i);if(Ht.isAlias(t))return r.Alias?.(e,t,i);return}function rj(e,t,r){let i=t[t.length-1];if(Ht.isCollection(i))i.items[e]=r;else if(Ht.isPair(i))if(e==="key")i.key=r;else i.value=r;else if(Ht.isDocument(i))i.contents=r;else{let n=Ht.isAlias(i)?"alias":"scalar";throw Error(`Cannot replace node with ${n} parent`)}}Pie.visit=Fg;Pie.visitAsync=Zg});var zI=ee(function(jie){var nj=Ge(),Die=uf(),Lie={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},Bie=(e)=>e.replace(/[!,[\]{}]/g,(t)=>Lie[t]);class _n{constructor(e,t){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},_n.defaultYaml,e),this.tags=Object.assign({},_n.defaultTags,t)}clone(){let e=new _n(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){let e=new _n(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:_n.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},_n.defaultTags);break}return e}add(e,t){if(this.atNextDocument)this.yaml={explicit:_n.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},_n.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+Bie(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&&nj.isNode(e.contents)){let n={};Die.visit(e.contents,(o,s)=>{if(nj.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(`
217
+ `)}}_n.defaultYaml={explicit:!1,version:"1.2"};_n.defaultTags={"!!":"tag:yaml.org,2002:"};jie.Directives=_n});var Hg=ee(function(Zie){var ij=Ge(),Uie=uf();function Mie(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 oj(e){let t=new Set;return Uie.visit(e,{Value(r,i){if(i.anchor)t.add(i.anchor)}}),t}function sj(e,t){for(let r=1;;++r){let i=`${e}${r}`;if(!t.has(i))return i}}function Fie(e,t){let r=[],i=new Map,n=null;return{onAnchor:(o)=>{r.push(o),n??(n=oj(e));let s=sj(t,n);return n.add(s),s},setAnchors:()=>{for(let o of r){let s=i.get(o);if(typeof s==="object"&&s.anchor&&(ij.isScalar(s.node)||ij.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}}Zie.anchorIsValid=Mie;Zie.anchorNames=oj;Zie.createNodeAnchors=Fie;Zie.findNewAnchor=sj});var NI=ee(function(Wie){function df(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=df(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=df(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=df(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=df(e,i,n,o);if(s===void 0)delete i[n];else if(s!==o)i[n]=s}return e.call(t,r,i)}Wie.applyReviver=df});var Ho=ee(function(Yie){var Qie=Ge();function aj(e,t,r){if(Array.isArray(e))return e.map((i,n)=>aj(i,String(n),r));if(e&&typeof e.toJSON==="function"){if(!r||!Qie.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}Yie.toJS=aj});var Kg=ee(function(roe){var eoe=NI(),cj=Ge(),toe=Ho();class lj{constructor(e){Object.defineProperty(this,cj.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(!cj.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=toe.toJS(this,"",o);if(typeof i==="function")for(let{count:a,res:c}of o.anchors.values())i(c,a);return typeof n==="function"?eoe.applyReviver(n,{"":s},"",s):s}}roe.NodeBase=lj});var ff=ee(function(coe){var ioe=Hg(),ooe=uf(),fl=Ge(),soe=Kg(),aoe=Ho();class uj extends soe.NodeBase{constructor(e){super(fl.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=[],ooe.visit(e,{Node:(n,o)=>{if(fl.isAlias(o)||fl.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)aoe.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=Jg(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(ioe.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 Jg(e,t,r){if(fl.isAlias(t)){let i=t.resolve(e),n=r&&i&&r.get(i);return n?n.count*n.aliasCount:0}else if(fl.isCollection(t)){let i=0;for(let n of t.items){let o=Jg(e,n,r);if(o>i)i=o}return i}else if(fl.isPair(t)){let i=Jg(e,t.key,r),n=Jg(e,t.value,r);return Math.max(i,n)}return 1}coe.Alias=uj});var Bt=ee(function(moe){var uoe=Ge(),doe=Kg(),foe=Ho(),poe=(e)=>!e||typeof e!=="function"&&typeof e!=="object";class ma extends doe.NodeBase{constructor(e){super(uoe.SCALAR);this.value=e}toJSON(e,t){return t?.keep?this.value:foe.toJS(this.value,e,t)}toString(){return String(this.value)}}ma.BLOCK_FOLDED="BLOCK_FOLDED";ma.BLOCK_LITERAL="BLOCK_LITERAL";ma.PLAIN="PLAIN";ma.QUOTE_DOUBLE="QUOTE_DOUBLE";ma.QUOTE_SINGLE="QUOTE_SINGLE";moe.Scalar=ma;moe.isScalarValue=poe});var pf=ee(function(woe){var yoe=ff(),ha=Ge(),dj=Bt(),boe="tag:yaml.org,2002:";function xoe(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 Soe(e,t,r){if(ha.isDocument(e))e=e.contents;if(ha.isNode(e))return e;if(ha.isPair(e)){let d=r.schema[ha.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 yoe.Alias(c.anchor);else c={anchor:null,node:null},a.set(e,c);if(t?.startsWith("!!"))t=boe+t.slice(2);let l=xoe(e,t,s.tags);if(!l){if(e&&typeof e.toJSON==="function")e=e.toJSON();if(!e||typeof e!=="object"){let d=new dj.Scalar(e);if(c)c.node=d;return d}l=e instanceof Map?s[ha.MAP]:(Symbol.iterator in Object(e))?s[ha.SEQ]:s[ha.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 dj.Scalar(e);if(t)u.tag=t;else if(!l.default)u.tag=l.tag;if(c)c.node=u;return u}woe.createNode=Soe});var Vg=ee(function(Eoe){var _oe=pf(),hi=Ge(),koe=Kg();function DI(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 _oe.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 fj=(e)=>e==null||typeof e==="object"&&!!e[Symbol.iterator]().next().done;class pj extends koe.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)=>hi.isNode(r)||hi.isPair(r)?r.clone(e):r),this.range)t.range=this.range.slice();return t}addIn(e,t){if(fj(e))this.add(t);else{let[r,...i]=e,n=this.get(r,!0);if(hi.isCollection(n))n.addIn(i,t);else if(n===void 0&&this.schema)this.set(r,DI(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(hi.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&&hi.isScalar(n)?n.value:n;else return hi.isCollection(n)?n.getIn(i,t):void 0}hasAllNullValues(e){return this.items.every((t)=>{if(!hi.isPair(t))return!1;let r=t.value;return r==null||e&&hi.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 hi.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(hi.isCollection(n))n.setIn(i,t);else if(n===void 0&&this.schema)this.set(r,DI(this.schema,i,t));else throw Error(`Expected YAML collection at ${r}. Remaining path: ${i}`)}}}Eoe.Collection=pj;Eoe.collectionFromPath=DI;Eoe.isEmptyPath=fj});var mf=ee(function(Ooe){var Coe=(e)=>e.replace(/^(?!$)(?: $)?/gm,"#");function LI(e,t){if(/^\n+$/.test(e))return e.substring(1);return t?e.replace(/^(?! *$)/gm,t):e}var $oe=(e,t,r)=>e.endsWith(`
219
218
  `)?LI(r,t):r.includes(`
220
219
  `)?`
221
- `+LI(r,t):(e.endsWith(" ")?"":" ")+r;Roe.indentComment=LI;Roe.lineComment=Ooe;Roe.stringifyComment=$oe});var h6=ee(function(Loe){function Doe(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=m6(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===`
222
- `){if(r==="block")g=m6(e,g,t.length);d=g+t.length+c,p=void 0}else{if(T===" "&&m&&m!==" "&&m!==`
220
+ `+LI(r,t):(e.endsWith(" ")?"":" ")+r;Ooe.indentComment=LI;Ooe.lineComment=$oe;Ooe.stringifyComment=Coe});var hj=ee(function(Doe){function Noe(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=mj(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===`
221
+ `){if(r==="block")g=mj(e,g,t.length);d=g+t.length+c,p=void 0}else{if(T===" "&&m&&m!==" "&&m!==`
223
222
  `&&m!=="\t"){let z=e[g+1];if(z&&z!==" "&&z!==`
224
223
  `&&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=`
225
224
  ${t}${e.slice(0,j)}`;else{if(r==="quoted"&&u[z])A+=`${e[z]}\\`;A+=`
226
- ${t}${e.slice(z+1,j)}`}}return A}function m6(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!==`
227
- `);i=t,n=t+1,o=e[n]}return i}Loe.FOLD_BLOCK="block";Loe.FOLD_FLOW="flow";Loe.FOLD_QUOTED="quoted";Loe.foldFlowLines=Doe});var gf=ee(function(Hoe){var Mn=Bt(),Ko=h6(),Gg=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),Qg=(e)=>/^(%|---|\.\.\.)/m.test(e);function Moe(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]===`
225
+ ${t}${e.slice(z+1,j)}`}}return A}function mj(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!==`
226
+ `);i=t,n=t+1,o=e[n]}return i}Doe.FOLD_BLOCK="block";Doe.FOLD_FLOW="flow";Doe.FOLD_QUOTED="quoted";Doe.foldFlowLines=Noe});var gf=ee(function(Zoe){var Mn=Bt(),Ko=hj(),Gg=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),Qg=(e)=>/^(%|---|\.\.\.)/m.test(e);function Uoe(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]===`
228
227
  `){if(o-s>i)return!0;if(s=o+1,n-s<=i)return!1}return!0}function hf(e,t){let r=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return r;let{implicitKey:i}=t,n=t.options.doubleQuotedMinMultiLineLength,o=t.indent||(Qg(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)+`
229
228
 
230
229
  `;while(r[c+2]==="\\"&&r[c+3]==="n"&&r[c+4]!=='"')s+=`
@@ -233,7 +232,7 @@ ${t}${e.slice(z+1,j)}`}}return A}function m6(e,t,r){let i=t,n=t+1,o=e[n];while(o
233
232
  ${r}`)+"'";return t.implicitKey?i:Ko.foldFlowLines(i,r,Ko.FOLD_FLOW,Gg(t,!1))}function pl(e,t){let{singleQuote:r}=t.options,i;if(r===!1)i=hf;else{let n=e.includes('"'),o=e.includes("'");if(n&&!o)i=BI;else if(o&&!n)i=hf;else i=r?BI:hf}return i(e,t)}var jI;try{jI=new RegExp(`(^|(?<!
234
233
  ))
235
234
  +(?!
236
- |$)`,"g")}catch{jI=/\n+(?!\n|$)/g}function Wg({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 pl(r,i);let l=i.indent||(i.forceBlockIndent||Qg(r)?" ":""),u=s==="literal"?!0:s==="folded"||t===Mn.Scalar.BLOCK_FOLDED?!1:t===Mn.Scalar.BLOCK_LITERAL?!0:!Moe(r,c,l.length);if(!r)return u?`|
235
+ |$)`,"g")}catch{jI=/\n+(?!\n|$)/g}function Wg({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 pl(r,i);let l=i.indent||(i.forceBlockIndent||Qg(r)?" ":""),u=s==="literal"?!0:s==="folded"||t===Mn.Scalar.BLOCK_FOLDED?!1:t===Mn.Scalar.BLOCK_LITERAL?!0:!Uoe(r,c,l.length);if(!r)return u?`|
237
236
  `:`>
238
237
  `;let d,p;for(p=r.length;p>0;--p){let j=r[p-1];if(j!==`
239
238
  `&&j!=="\t"&&j!==" ")break}let m=r.substring(p),y=m.indexOf(`
@@ -242,13 +241,13 @@ ${r}`)+"'";return t.implicitKey?i:Ko.foldFlowLines(i,r,Ko.FOLD_FLOW,Gg(t,!1))}fu
242
241
  `)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,`
243
242
  $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${l}`),E=!1,Z=Gg(i,!0);if(s!=="folded"&&t!==Mn.Scalar.BLOCK_FOLDED)Z.onOverflow=()=>{E=!0};let D=Ko.foldFlowLines(`${A}${j}${m}`,l,Ko.FOLD_BLOCK,Z);if(!E)return`>${z}
244
243
  ${l}${D}`}return r=r.replace(/\n+/g,`$&${l}`),`|${z}
245
- ${l}${A}${r}${m}`}function Foe(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(`
244
+ ${l}${A}${r}${m}`}function Moe(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(`
246
245
  `)||u&&/[[\]{},]/.test(o))return pl(o,t);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(o))return a||u||!o.includes(`
247
246
  `)?pl(o,t):Wg(e,t,r,i);if(!a&&!u&&n!==Mn.Scalar.PLAIN&&o.includes(`
248
247
  `))return Wg(e,t,r,i);if(Qg(o)){if(c==="")return t.forceBlockIndent=!0,Wg(e,t,r,i);else if(a&&c===l)return pl(o,t)}let d=o.replace(/\n+/g,`$&
249
- ${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 pl(o,t)}return a?d:Ko.foldFlowLines(d,c,Ko.FOLD_FLOW,Gg(t,!1))}function Zoe(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!==Mn.Scalar.QUOTE_DOUBLE){if(/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(s.value))a=Mn.Scalar.QUOTE_DOUBLE}let c=(u)=>{switch(u){case Mn.Scalar.BLOCK_FOLDED:case Mn.Scalar.BLOCK_LITERAL:return n||o?pl(s.value,t):Wg(s,t,r,i);case Mn.Scalar.QUOTE_DOUBLE:return hf(s.value,t);case Mn.Scalar.QUOTE_SINGLE:return BI(s.value,t);case Mn.Scalar.PLAIN:return Foe(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}Hoe.stringifyString=Zoe});var yf=ee(function(ese){var Joe=Hg(),Jo=Ge(),Voe=mf(),Woe=gf();function Goe(e,t){let r=Object.assign({blockQuote:!0,commentString:Voe.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 Qoe(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(Jo.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 Yoe(e,t,{anchors:r,doc:i}){if(!i.directives)return"";let n=[],o=(Jo.isScalar(e)||Jo.isCollection(e))&&e.anchor;if(o&&Joe.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 Xoe(e,t,r,i){if(Jo.isPair(e))return e.toString(t,r,i);if(Jo.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=Jo.isNode(e)?e:t.doc.createNode(e,{onTagObj:(c)=>n=c});n??(n=Qoe(t.doc.schema.tags,o));let s=Yoe(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):Jo.isScalar(o)?Woe.stringifyString(o,t,r,i):o.toString(t,r,i);if(!s)return a;return Jo.isScalar(o)||a[0]==="{"||a[0]==="["?`${s} ${a}`:`${s}
250
- ${t.indent}${a}`}ese.createStringifyContext=Goe;ese.stringify=Xoe});var b6=ee(function(ise){var Vi=Ge(),g6=Bt(),y6=yf(),bf=mf();function nse({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=Vi.isNode(e)&&e.comment||null;if(d){if(p)throw Error("With simple keys, key nodes cannot have comments");if(Vi.isCollection(e)||!Vi.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||Vi.isCollection(e)||(Vi.isScalar(e)?e.type===g6.Scalar.BLOCK_FOLDED||e.type===g6.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=y6.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+=bf.lineComment(b,r.indent,l(p));else if(g&&n)n();return b}if(y)p=null;if(m){if(p)b+=bf.lineComment(b,r.indent,l(p));b=`? ${b}
251
- ${a}:`}else if(b=`${b}:`,p)b+=bf.lineComment(b,r.indent,l(p));let v,A,T;if(Vi.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&&Vi.isScalar(t))r.indentAtStart=b.length+1;if(g=!1,!u&&c.length>=2&&!r.inFlow&&!m&&Vi.isSeq(t)&&!t.flow&&!t.tag&&!t.anchor)r.indent=r.indent.substring(2);let z=!1,j=y6.stringify(t,r,()=>z=!0,()=>g=!0),E=" ";if(p||v||A){if(E=v?`
248
+ ${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 pl(o,t)}return a?d:Ko.foldFlowLines(d,c,Ko.FOLD_FLOW,Gg(t,!1))}function Foe(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!==Mn.Scalar.QUOTE_DOUBLE){if(/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(s.value))a=Mn.Scalar.QUOTE_DOUBLE}let c=(u)=>{switch(u){case Mn.Scalar.BLOCK_FOLDED:case Mn.Scalar.BLOCK_LITERAL:return n||o?pl(s.value,t):Wg(s,t,r,i);case Mn.Scalar.QUOTE_DOUBLE:return hf(s.value,t);case Mn.Scalar.QUOTE_SINGLE:return BI(s.value,t);case Mn.Scalar.PLAIN:return Moe(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}Zoe.stringifyString=Foe});var yf=ee(function(Xoe){var Koe=Hg(),Jo=Ge(),Joe=mf(),Voe=gf();function Woe(e,t){let r=Object.assign({blockQuote:!0,commentString:Joe.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 Goe(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(Jo.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 Qoe(e,t,{anchors:r,doc:i}){if(!i.directives)return"";let n=[],o=(Jo.isScalar(e)||Jo.isCollection(e))&&e.anchor;if(o&&Koe.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 Yoe(e,t,r,i){if(Jo.isPair(e))return e.toString(t,r,i);if(Jo.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=Jo.isNode(e)?e:t.doc.createNode(e,{onTagObj:(c)=>n=c});n??(n=Goe(t.doc.schema.tags,o));let s=Qoe(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):Jo.isScalar(o)?Voe.stringifyString(o,t,r,i):o.toString(t,r,i);if(!s)return a;return Jo.isScalar(o)||a[0]==="{"||a[0]==="["?`${s} ${a}`:`${s}
249
+ ${t.indent}${a}`}Xoe.createStringifyContext=Woe;Xoe.stringify=Yoe});var bj=ee(function(nse){var Vi=Ge(),gj=Bt(),yj=yf(),bf=mf();function rse({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=Vi.isNode(e)&&e.comment||null;if(d){if(p)throw Error("With simple keys, key nodes cannot have comments");if(Vi.isCollection(e)||!Vi.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||Vi.isCollection(e)||(Vi.isScalar(e)?e.type===gj.Scalar.BLOCK_FOLDED||e.type===gj.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=yj.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+=bf.lineComment(b,r.indent,l(p));else if(g&&n)n();return b}if(y)p=null;if(m){if(p)b+=bf.lineComment(b,r.indent,l(p));b=`? ${b}
250
+ ${a}:`}else if(b=`${b}:`,p)b+=bf.lineComment(b,r.indent,l(p));let v,A,T;if(Vi.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&&Vi.isScalar(t))r.indentAtStart=b.length+1;if(g=!1,!u&&c.length>=2&&!r.inFlow&&!m&&Vi.isSeq(t)&&!t.flow&&!t.tag&&!t.anchor)r.indent=r.indent.substring(2);let z=!1,j=yj.stringify(t,r,()=>z=!0,()=>g=!0),E=" ";if(p||v||A){if(E=v?`
252
251
  `:"",A){let Z=l(A);E+=`
253
252
  ${bf.indentComment(Z,r.indent)}`}if(j===""&&!r.inFlow){if(E===`
254
253
  `&&T)E=`
@@ -257,32 +256,32 @@ ${bf.indentComment(Z,r.indent)}`}if(j===""&&!r.inFlow){if(E===`
257
256
  ${r.indent}`}else if(!m&&Vi.isCollection(t)){let Z=j[0],D=j.indexOf(`
258
257
  `),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=`
259
258
  ${r.indent}`}}else if(j===""||j[0]===`
260
- `)E="";if(b+=E+j,r.inFlow){if(z&&i)i()}else if(T&&!z)b+=bf.lineComment(b,r.indent,l(T));else if(g&&n)n();return b}ise.stringifyPair=nse});var qI=ee(function(cse){var x6=Tt("process");function sse(e,...t){if(e==="debug")console.log(...t)}function ase(e,t){if(e==="debug"||e==="warn")if(typeof x6.emitWarning==="function")x6.emitWarning(t);else console.warn(t)}cse.debug=sse;cse.warn=ase});var ty=ee(function(fse){var ey=Ge(),S6=Bt(),Yg="<<",Xg={identify:(e)=>e===Yg||typeof e==="symbol"&&e.description===Yg,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new S6.Scalar(Symbol(Yg)),{addToJSMap:w6}),stringify:()=>Yg},dse=(e,t)=>(Xg.identify(t)||ey.isScalar(t)&&(!t.type||t.type===S6.Scalar.PLAIN)&&Xg.identify(t.value))&&e?.doc.schema.tags.some((r)=>r.tag===Xg.tag&&r.default);function w6(e,t,r){let i=v6(e,r);if(ey.isSeq(i))for(let n of i.items)UI(e,t,n);else if(Array.isArray(i))for(let n of i)UI(e,t,n);else UI(e,t,i)}function UI(e,t,r){let i=v6(e,r);if(!ey.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 v6(e,t){return e&&ey.isAlias(t)?t.resolve(e.doc,e):t}fse.addMergeToJSMap=w6;fse.isMergeKey=dse;fse.merge=Xg});var FI=ee(function(Sse){var gse=qI(),_6=ty(),yse=yf(),k6=Ge(),MI=Ho();function bse(e,t,{key:r,value:i}){if(k6.isNode(r)&&r.addToJSMap)r.addToJSMap(e,t,i);else if(_6.isMergeKey(e,r))_6.addMergeToJSMap(e,t,i);else{let n=MI.toJS(r,"",e);if(t instanceof Map)t.set(n,MI.toJS(i,n,e));else if(t instanceof Set)t.add(n);else{let o=xse(r,n,e),s=MI.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 xse(e,t,r){if(t===null)return"";if(typeof t!=="object")return String(t);if(k6.isNode(e)&&r?.doc){let i=yse.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)+'..."';gse.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)}Sse.addPairToJSMap=bse});var Vo=ee(function(Ese){var E6=pf(),vse=b6(),_se=FI(),ry=Ge();function kse(e,t,r){let i=E6.createNode(e,void 0,r),n=E6.createNode(t,void 0,r);return new ny(i,n)}class ny{constructor(e,t=null){Object.defineProperty(this,ry.NODE_TYPE,{value:ry.PAIR}),this.key=e,this.value=t}clone(e){let{key:t,value:r}=this;if(ry.isNode(t))t=t.clone(e);if(ry.isNode(r))r=r.clone(e);return new ny(t,r)}toJSON(e,t){let r=t?.mapAsMap?new Map:{};return _se.addPairToJSMap(t,r,this)}toString(e,t,r){return e?.doc?vse.stringifyPair(this,e,t,r):JSON.stringify(this)}}Ese.Pair=ny;Ese.createPair=kse});var ZI=ee(function(Ose){var ga=Ge(),I6=yf(),iy=mf();function Tse(e,t,r){return(t.inFlow??e.flow?$se:Cse)(e,t,r)}function Cse({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(ga.isNode(g)){if(!d&&g.spaceBefore)p.push("");if(oy(r,p,g.commentBefore,d),g.comment)b=g.comment}else if(ga.isPair(g)){let A=ga.isNode(g.key)?g.key:null;if(A){if(!d&&A.spaceBefore)p.push("");oy(r,p,A.commentBefore,d)}}d=!1;let v=I6.stringify(g,u,()=>b=null,()=>d=!0);if(b)v+=iy.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?`
259
+ `)E="";if(b+=E+j,r.inFlow){if(z&&i)i()}else if(T&&!z)b+=bf.lineComment(b,r.indent,l(T));else if(g&&n)n();return b}nse.stringifyPair=rse});var qI=ee(function(ase){var xj=Tt("process");function ose(e,...t){if(e==="debug")console.log(...t)}function sse(e,t){if(e==="debug"||e==="warn")if(typeof xj.emitWarning==="function")xj.emitWarning(t);else console.warn(t)}ase.debug=ose;ase.warn=sse});var ty=ee(function(dse){var ey=Ge(),Sj=Bt(),Yg="<<",Xg={identify:(e)=>e===Yg||typeof e==="symbol"&&e.description===Yg,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new Sj.Scalar(Symbol(Yg)),{addToJSMap:wj}),stringify:()=>Yg},use=(e,t)=>(Xg.identify(t)||ey.isScalar(t)&&(!t.type||t.type===Sj.Scalar.PLAIN)&&Xg.identify(t.value))&&e?.doc.schema.tags.some((r)=>r.tag===Xg.tag&&r.default);function wj(e,t,r){let i=vj(e,r);if(ey.isSeq(i))for(let n of i.items)UI(e,t,n);else if(Array.isArray(i))for(let n of i)UI(e,t,n);else UI(e,t,i)}function UI(e,t,r){let i=vj(e,r);if(!ey.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 vj(e,t){return e&&ey.isAlias(t)?t.resolve(e.doc,e):t}dse.addMergeToJSMap=wj;dse.isMergeKey=use;dse.merge=Xg});var FI=ee(function(xse){var hse=qI(),_j=ty(),gse=yf(),kj=Ge(),MI=Ho();function yse(e,t,{key:r,value:i}){if(kj.isNode(r)&&r.addToJSMap)r.addToJSMap(e,t,i);else if(_j.isMergeKey(e,r))_j.addMergeToJSMap(e,t,i);else{let n=MI.toJS(r,"",e);if(t instanceof Map)t.set(n,MI.toJS(i,n,e));else if(t instanceof Set)t.add(n);else{let o=bse(r,n,e),s=MI.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 bse(e,t,r){if(t===null)return"";if(typeof t!=="object")return String(t);if(kj.isNode(e)&&r?.doc){let i=gse.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)+'..."';hse.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)}xse.addPairToJSMap=yse});var Vo=ee(function(kse){var Ej=pf(),wse=bj(),vse=FI(),ry=Ge();function _se(e,t,r){let i=Ej.createNode(e,void 0,r),n=Ej.createNode(t,void 0,r);return new ny(i,n)}class ny{constructor(e,t=null){Object.defineProperty(this,ry.NODE_TYPE,{value:ry.PAIR}),this.key=e,this.value=t}clone(e){let{key:t,value:r}=this;if(ry.isNode(t))t=t.clone(e);if(ry.isNode(r))r=r.clone(e);return new ny(t,r)}toJSON(e,t){let r=t?.mapAsMap?new Map:{};return vse.addPairToJSMap(t,r,this)}toString(e,t,r){return e?.doc?wse.stringifyPair(this,e,t,r):JSON.stringify(this)}}kse.Pair=ny;kse.createPair=_se});var ZI=ee(function($se){var ga=Ge(),Ij=yf(),iy=mf();function Ase(e,t,r){return(t.inFlow??e.flow?Cse:Tse)(e,t,r)}function Tse({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(ga.isNode(g)){if(!d&&g.spaceBefore)p.push("");if(oy(r,p,g.commentBefore,d),g.comment)b=g.comment}else if(ga.isPair(g)){let A=ga.isNode(g.key)?g.key:null;if(A){if(!d&&A.spaceBefore)p.push("");oy(r,p,A.commentBefore,d)}}d=!1;let v=Ij.stringify(g,u,()=>b=null,()=>d=!0);if(b)v+=iy.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?`
261
260
  ${c}${g}`:`
262
261
  `}}if(e){if(m+=`
263
- `+iy.indentComment(l(e),c),a)a()}else if(d&&s)s();return m}function $se({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(ga.isNode(g)){if(g.spaceBefore)d.push("");if(oy(t,d,g.commentBefore,!1),g.comment)b=g.comment}else if(ga.isPair(g)){let A=ga.isNode(g.key)?g.key:null;if(A){if(A.spaceBefore)d.push("");if(oy(t,d,A.commentBefore,!1),A.comment)l=!0}let T=ga.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=I6.stringify(g,c,()=>b=null);if(l||(l=d.length>u||v.includes(`
262
+ `+iy.indentComment(l(e),c),a)a()}else if(d&&s)s();return m}function Cse({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(ga.isNode(g)){if(g.spaceBefore)d.push("");if(oy(t,d,g.commentBefore,!1),g.comment)b=g.comment}else if(ga.isPair(g)){let A=ga.isNode(g.key)?g.key:null;if(A){if(A.spaceBefore)d.push("");if(oy(t,d,A.commentBefore,!1),A.comment)l=!0}let T=ga.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=Ij.stringify(g,c,()=>b=null);if(l||(l=d.length>u||v.includes(`
264
263
  `)),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+=iy.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?`
265
264
  ${o}${n}${g}`:`
266
265
  `;return`${y}
267
- ${n}${m}`}else return`${p}${s}${d.join(" ")}${s}${m}`}}function oy({indent:e,options:{commentString:t}},r,i,n){if(i&&n)i=i.replace(/^\n+/,"");if(i){let o=iy.indentComment(t(i),e);r.push(o.trimStart())}}Ose.stringifyCollection=Tse});var Go=ee(function(Lse){var Pse=ZI(),zse=FI(),Nse=Vg(),Wo=Ge(),sy=Vo(),Dse=Bt();function xf(e,t){let r=Wo.isScalar(t)?t.value:t;for(let i of e)if(Wo.isPair(i)){if(i.key===t||i.key===r)return i;if(Wo.isScalar(i.key)&&i.key.value===r)return i}return}class A6 extends Nse.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(Wo.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(sy.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(Wo.isPair(e))r=e;else if(!e||typeof e!=="object"||!("key"in e))r=new sy.Pair(e,e?.value);else r=new sy.Pair(e.key,e.value);let i=xf(this.items,r.key),n=this.schema?.sortMapEntries;if(i){if(!t)throw Error(`Key ${r.key} already set`);if(Wo.isScalar(i.value)&&Dse.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=xf(this.items,e);if(!t)return!1;return this.items.splice(this.items.indexOf(t),1).length>0}get(e,t){let i=xf(this.items,e)?.value;return(!t&&Wo.isScalar(i)?i.value:i)??void 0}has(e){return!!xf(this.items,e)}set(e,t){this.add(new sy.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)zse.addPairToJSMap(t,i,n);return i}toString(e,t,r){if(!e)return JSON.stringify(this);for(let i of this.items)if(!Wo.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 Pse.stringifyCollection(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:r,onComment:t})}}Lse.YAMLMap=A6;Lse.findPair=xf});var ml=ee(function(Mse){var qse=Ge(),T6=Go(),Use={collection:"map",default:!0,nodeClass:T6.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(e,t){if(!qse.isMap(e))t("Expected a mapping for this tag");return e},createNode:(e,t,r)=>T6.YAMLMap.from(e,t,r)};Mse.map=Use});var Qo=ee(function(Wse){var Zse=pf(),Hse=ZI(),Kse=Vg(),cy=Ge(),Jse=Bt(),Vse=Ho();class C6 extends Kse.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(cy.SEQ,e);this.items=[]}add(e){this.items.push(e)}delete(e){let t=ay(e);if(typeof t!=="number")return!1;return this.items.splice(t,1).length>0}get(e,t){let r=ay(e);if(typeof r!=="number")return;let i=this.items[r];return!t&&cy.isScalar(i)?i.value:i}has(e){let t=ay(e);return typeof t==="number"&&t<this.items.length}set(e,t){let r=ay(e);if(typeof r!=="number")throw Error(`Expected a valid index, not ${e}.`);let i=this.items[r];if(cy.isScalar(i)&&Jse.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(Vse.toJS(n,String(i++),t));return r}toString(e,t,r){if(!e)return JSON.stringify(this);return Hse.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(Zse.createNode(s,void 0,r))}}return n}}function ay(e){let t=cy.isScalar(e)?e.value:e;if(t&&typeof t==="string")t=Number(t);return typeof t==="number"&&Number.isInteger(t)&&t>=0?t:null}Wse.YAMLSeq=C6});var hl=ee(function(Xse){var Qse=Ge(),$6=Qo(),Yse={collection:"seq",default:!0,nodeClass:$6.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(e,t){if(!Qse.isSeq(e))t("Expected a sequence for this tag");return e},createNode:(e,t,r)=>$6.YAMLSeq.from(e,t,r)};Xse.seq=Yse});var Sf=ee(function(nae){var tae=gf(),rae={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),tae.stringifyString(e,t,r,i)}};nae.string=rae});var ly=ee(function(oae){var O6=Bt(),R6={identify:(e)=>e==null,createNode:()=>new O6.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new O6.Scalar(null),stringify:({source:e},t)=>typeof e==="string"&&R6.test.test(e)?e:t.options.nullStr};oae.nullTag=R6});var HI=ee(function(cae){var aae=Bt(),P6={identify:(e)=>typeof e==="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:(e)=>new aae.Scalar(e[0]==="t"||e[0]==="T"),stringify({source:e,value:t},r){if(e&&P6.test.test(e)){let i=e[0]==="t"||e[0]==="T";if(t===i)return e}return t?r.options.trueStr:r.options.falseStr}};cae.boolTag=P6});var gl=ee(function(dae){function uae({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}dae.stringifyNumber=uae});var JI=ee(function(yae){var pae=Bt(),KI=gl(),mae={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:KI.stringifyNumber},hae={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():KI.stringifyNumber(e)}},gae={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 pae.Scalar(parseFloat(e)),r=e.indexOf(".");if(r!==-1&&e[e.length-1]==="0")t.minFractionDigits=e.length-r-1;return t},stringify:KI.stringifyNumber};yae.float=gae;yae.floatExp=hae;yae.floatNaN=mae});var WI=ee(function(kae){var z6=gl(),uy=(e)=>typeof e==="bigint"||Number.isInteger(e),VI=(e,t,r,{intAsBigInt:i})=>i?BigInt(e):parseInt(e.substring(t),r);function N6(e,t,r){let{value:i}=e;if(uy(i)&&i>=0)return r+i.toString(t);return z6.stringifyNumber(e)}var wae={identify:(e)=>uy(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(e,t,r)=>VI(e,2,8,r),stringify:(e)=>N6(e,8,"0o")},vae={identify:uy,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(e,t,r)=>VI(e,0,10,r),stringify:z6.stringifyNumber},_ae={identify:(e)=>uy(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(e,t,r)=>VI(e,2,16,r),stringify:(e)=>N6(e,16,"0x")};kae.int=vae;kae.intHex=_ae;kae.intOct=wae});var D6=ee(function(zae){var Tae=ml(),Cae=ly(),$ae=hl(),Oae=Sf(),Rae=HI(),GI=JI(),QI=WI(),Pae=[Tae.map,$ae.seq,Oae.string,Cae.nullTag,Rae.boolTag,QI.intOct,QI.int,QI.intHex,GI.floatNaN,GI.floatExp,GI.float];zae.schema=Pae});var B6=ee(function(Mae){var Dae=Bt(),Lae=ml(),Bae=hl();function L6(e){return typeof e==="bigint"||Number.isInteger(e)}var dy=({value:e})=>JSON.stringify(e),jae=[{identify:(e)=>typeof e==="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:(e)=>e,stringify:dy},{identify:(e)=>e==null,createNode:()=>new Dae.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:dy},{identify:(e)=>typeof e==="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:(e)=>e==="true",stringify:dy},{identify:L6,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})=>L6(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:dy}],qae={default:!0,tag:"",test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}},Uae=[Lae.map,Bae.seq].concat(jae,qae);Mae.schema=Uae});var XI=ee(function(Kae){var wf=Tt("buffer"),YI=Bt(),Zae=gf(),Hae={identify:(e)=>e instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(e,t){if(typeof wf.Buffer==="function")return wf.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 wf.Buffer==="function")a=s instanceof wf.Buffer?s.toString("base64"):wf.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=YI.Scalar.BLOCK_LITERAL),t!==YI.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===YI.Scalar.BLOCK_LITERAL?`
268
- `:" ")}return Zae.stringifyString({comment:e,type:t,value:a},i,n,o)}};Kae.binary=Hae});var py=ee(function(Qae){var fy=Ge(),eA=Vo(),Vae=Bt(),Wae=Qo();function j6(e,t){if(fy.isSeq(e))for(let r=0;r<e.items.length;++r){let i=e.items[r];if(fy.isPair(i))continue;else if(fy.isMap(i)){if(i.items.length>1)t("Each pair must have its own sequence indicator");let n=i.items[0]||new eA.Pair(new Vae.Scalar(null));if(i.commentBefore)n.key.commentBefore=n.key.commentBefore?`${i.commentBefore}
266
+ ${n}${m}`}else return`${p}${s}${d.join(" ")}${s}${m}`}}function oy({indent:e,options:{commentString:t}},r,i,n){if(i&&n)i=i.replace(/^\n+/,"");if(i){let o=iy.indentComment(t(i),e);r.push(o.trimStart())}}$se.stringifyCollection=Ase});var Go=ee(function(Dse){var Rse=ZI(),Pse=FI(),zse=Vg(),Wo=Ge(),sy=Vo(),Nse=Bt();function xf(e,t){let r=Wo.isScalar(t)?t.value:t;for(let i of e)if(Wo.isPair(i)){if(i.key===t||i.key===r)return i;if(Wo.isScalar(i.key)&&i.key.value===r)return i}return}class Aj extends zse.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(Wo.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(sy.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(Wo.isPair(e))r=e;else if(!e||typeof e!=="object"||!("key"in e))r=new sy.Pair(e,e?.value);else r=new sy.Pair(e.key,e.value);let i=xf(this.items,r.key),n=this.schema?.sortMapEntries;if(i){if(!t)throw Error(`Key ${r.key} already set`);if(Wo.isScalar(i.value)&&Nse.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=xf(this.items,e);if(!t)return!1;return this.items.splice(this.items.indexOf(t),1).length>0}get(e,t){let i=xf(this.items,e)?.value;return(!t&&Wo.isScalar(i)?i.value:i)??void 0}has(e){return!!xf(this.items,e)}set(e,t){this.add(new sy.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)Pse.addPairToJSMap(t,i,n);return i}toString(e,t,r){if(!e)return JSON.stringify(this);for(let i of this.items)if(!Wo.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 Rse.stringifyCollection(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:r,onComment:t})}}Dse.YAMLMap=Aj;Dse.findPair=xf});var ml=ee(function(Use){var jse=Ge(),Tj=Go(),qse={collection:"map",default:!0,nodeClass:Tj.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(e,t){if(!jse.isMap(e))t("Expected a mapping for this tag");return e},createNode:(e,t,r)=>Tj.YAMLMap.from(e,t,r)};Use.map=qse});var Qo=ee(function(Vse){var Fse=pf(),Zse=ZI(),Hse=Vg(),cy=Ge(),Kse=Bt(),Jse=Ho();class Cj extends Hse.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(cy.SEQ,e);this.items=[]}add(e){this.items.push(e)}delete(e){let t=ay(e);if(typeof t!=="number")return!1;return this.items.splice(t,1).length>0}get(e,t){let r=ay(e);if(typeof r!=="number")return;let i=this.items[r];return!t&&cy.isScalar(i)?i.value:i}has(e){let t=ay(e);return typeof t==="number"&&t<this.items.length}set(e,t){let r=ay(e);if(typeof r!=="number")throw Error(`Expected a valid index, not ${e}.`);let i=this.items[r];if(cy.isScalar(i)&&Kse.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(Jse.toJS(n,String(i++),t));return r}toString(e,t,r){if(!e)return JSON.stringify(this);return Zse.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(Fse.createNode(s,void 0,r))}}return n}}function ay(e){let t=cy.isScalar(e)?e.value:e;if(t&&typeof t==="string")t=Number(t);return typeof t==="number"&&Number.isInteger(t)&&t>=0?t:null}Vse.YAMLSeq=Cj});var hl=ee(function(Yse){var Gse=Ge(),$j=Qo(),Qse={collection:"seq",default:!0,nodeClass:$j.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(e,t){if(!Gse.isSeq(e))t("Expected a sequence for this tag");return e},createNode:(e,t,r)=>$j.YAMLSeq.from(e,t,r)};Yse.seq=Qse});var Sf=ee(function(rae){var eae=gf(),tae={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),eae.stringifyString(e,t,r,i)}};rae.string=tae});var ly=ee(function(iae){var Oj=Bt(),Rj={identify:(e)=>e==null,createNode:()=>new Oj.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new Oj.Scalar(null),stringify:({source:e},t)=>typeof e==="string"&&Rj.test.test(e)?e:t.options.nullStr};iae.nullTag=Rj});var HI=ee(function(aae){var sae=Bt(),Pj={identify:(e)=>typeof e==="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:(e)=>new sae.Scalar(e[0]==="t"||e[0]==="T"),stringify({source:e,value:t},r){if(e&&Pj.test.test(e)){let i=e[0]==="t"||e[0]==="T";if(t===i)return e}return t?r.options.trueStr:r.options.falseStr}};aae.boolTag=Pj});var gl=ee(function(uae){function lae({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}uae.stringifyNumber=lae});var JI=ee(function(gae){var fae=Bt(),KI=gl(),pae={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:KI.stringifyNumber},mae={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():KI.stringifyNumber(e)}},hae={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 fae.Scalar(parseFloat(e)),r=e.indexOf(".");if(r!==-1&&e[e.length-1]==="0")t.minFractionDigits=e.length-r-1;return t},stringify:KI.stringifyNumber};gae.float=hae;gae.floatExp=mae;gae.floatNaN=pae});var WI=ee(function(_ae){var zj=gl(),uy=(e)=>typeof e==="bigint"||Number.isInteger(e),VI=(e,t,r,{intAsBigInt:i})=>i?BigInt(e):parseInt(e.substring(t),r);function Nj(e,t,r){let{value:i}=e;if(uy(i)&&i>=0)return r+i.toString(t);return zj.stringifyNumber(e)}var Sae={identify:(e)=>uy(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(e,t,r)=>VI(e,2,8,r),stringify:(e)=>Nj(e,8,"0o")},wae={identify:uy,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(e,t,r)=>VI(e,0,10,r),stringify:zj.stringifyNumber},vae={identify:(e)=>uy(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(e,t,r)=>VI(e,2,16,r),stringify:(e)=>Nj(e,16,"0x")};_ae.int=wae;_ae.intHex=vae;_ae.intOct=Sae});var Dj=ee(function(Pae){var Aae=ml(),Tae=ly(),Cae=hl(),$ae=Sf(),Oae=HI(),GI=JI(),QI=WI(),Rae=[Aae.map,Cae.seq,$ae.string,Tae.nullTag,Oae.boolTag,QI.intOct,QI.int,QI.intHex,GI.floatNaN,GI.floatExp,GI.float];Pae.schema=Rae});var Bj=ee(function(Uae){var Nae=Bt(),Dae=ml(),Lae=hl();function Lj(e){return typeof e==="bigint"||Number.isInteger(e)}var dy=({value:e})=>JSON.stringify(e),Bae=[{identify:(e)=>typeof e==="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:(e)=>e,stringify:dy},{identify:(e)=>e==null,createNode:()=>new Nae.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:dy},{identify:(e)=>typeof e==="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:(e)=>e==="true",stringify:dy},{identify:Lj,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})=>Lj(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:dy}],jae={default:!0,tag:"",test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}},qae=[Dae.map,Lae.seq].concat(Bae,jae);Uae.schema=qae});var XI=ee(function(Hae){var wf=Tt("buffer"),YI=Bt(),Fae=gf(),Zae={identify:(e)=>e instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(e,t){if(typeof wf.Buffer==="function")return wf.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 wf.Buffer==="function")a=s instanceof wf.Buffer?s.toString("base64"):wf.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=YI.Scalar.BLOCK_LITERAL),t!==YI.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===YI.Scalar.BLOCK_LITERAL?`
267
+ `:" ")}return Fae.stringifyString({comment:e,type:t,value:a},i,n,o)}};Hae.binary=Zae});var py=ee(function(Gae){var fy=Ge(),eA=Vo(),Jae=Bt(),Vae=Qo();function jj(e,t){if(fy.isSeq(e))for(let r=0;r<e.items.length;++r){let i=e.items[r];if(fy.isPair(i))continue;else if(fy.isMap(i)){if(i.items.length>1)t("Each pair must have its own sequence indicator");let n=i.items[0]||new eA.Pair(new Jae.Scalar(null));if(i.commentBefore)n.key.commentBefore=n.key.commentBefore?`${i.commentBefore}
269
268
  ${n.key.commentBefore}`:i.commentBefore;if(i.comment){let o=n.value??n.key;o.comment=o.comment?`${i.comment}
270
- ${o.comment}`:i.comment}i=n}e.items[r]=fy.isPair(i)?i:new eA.Pair(i)}else t("Expected a sequence for this tag");return e}function q6(e,t,r){let{replacer:i}=r,n=new Wae.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(eA.createPair(a,c,r))}return n}var Gae={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:j6,createNode:q6};Qae.createPairs=q6;Qae.pairs=Gae;Qae.resolvePairs=j6});var rA=ee(function(nce){var U6=Ge(),tA=Ho(),vf=Go(),tce=Qo(),M6=py();class ya extends tce.YAMLSeq{constructor(){super();this.add=vf.YAMLMap.prototype.add.bind(this),this.delete=vf.YAMLMap.prototype.delete.bind(this),this.get=vf.YAMLMap.prototype.get.bind(this),this.has=vf.YAMLMap.prototype.has.bind(this),this.set=vf.YAMLMap.prototype.set.bind(this),this.tag=ya.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(U6.isPair(i))n=tA.toJS(i.key,"",t),o=tA.toJS(i.value,n,t);else n=tA.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=M6.createPairs(e,t,r),n=new this;return n.items=i.items,n}}ya.tag="tag:yaml.org,2002:omap";var rce={collection:"seq",identify:(e)=>e instanceof Map,nodeClass:ya,default:!1,tag:"tag:yaml.org,2002:omap",resolve(e,t){let r=M6.resolvePairs(e,t),i=[];for(let{key:n}of r.items)if(U6.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 ya,r)},createNode:(e,t,r)=>ya.from(e,t,r)};nce.YAMLOMap=ya;nce.omap=rce});var J6=ee(function(sce){var F6=Bt();function Z6({value:e,source:t},r){if(t&&(e?H6:K6).test.test(t))return t;return e?r.options.trueStr:r.options.falseStr}var H6={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 F6.Scalar(!0),stringify:Z6},K6={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 F6.Scalar(!1),stringify:Z6};sce.falseTag=K6;sce.trueTag=H6});var V6=ee(function(pce){var lce=Bt(),nA=gl(),uce={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:nA.stringifyNumber},dce={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():nA.stringifyNumber(e)}},fce={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 lce.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:nA.stringifyNumber};pce.float=fce;pce.floatExp=dce;pce.floatNaN=uce});var G6=ee(function(wce){var W6=gl(),_f=(e)=>typeof e==="bigint"||Number.isInteger(e);function my(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 iA(e,t,r){let{value:i}=e;if(_f(i)){let n=i.toString(t);return i<0?"-"+r+n.substr(1):r+n}return W6.stringifyNumber(e)}var yce={identify:_f,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,r)=>my(e,2,2,r),stringify:(e)=>iA(e,2,"0b")},bce={identify:_f,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(e,t,r)=>my(e,1,8,r),stringify:(e)=>iA(e,8,"0")},xce={identify:_f,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,r)=>my(e,0,10,r),stringify:W6.stringifyNumber},Sce={identify:_f,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,r)=>my(e,2,16,r),stringify:(e)=>iA(e,16,"0x")};wce.int=xce;wce.intBin=yce;wce.intHex=Sce;wce.intOct=bce});var oA=ee(function(Ace){var yy=Ge(),hy=Vo(),gy=Go();class ba extends gy.YAMLMap{constructor(e){super(e);this.tag=ba.tag}add(e){let t;if(yy.isPair(e))t=e;else if(e&&typeof e==="object"&&"key"in e&&"value"in e&&e.value===null)t=new hy.Pair(e.key,null);else t=new hy.Pair(e,null);if(!gy.findPair(this.items,t.key))this.items.push(t)}get(e,t){let r=gy.findPair(this.items,e);return!t&&yy.isPair(r)?yy.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=gy.findPair(this.items,e);if(r&&!t)this.items.splice(this.items.indexOf(r),1);else if(!r&&t)this.items.push(new hy.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(hy.createPair(o,null,r))}return n}}ba.tag="tag:yaml.org,2002:set";var Ice={collection:"map",identify:(e)=>e instanceof Set,nodeClass:ba,default:!1,tag:"tag:yaml.org,2002:set",createNode:(e,t,r)=>ba.from(e,t,r),resolve(e,t){if(yy.isMap(e))if(e.hasAllNullValues(!0))return Object.assign(new ba,e);else t("Set items must all have null values");else t("Expected a mapping for this tag");return e}};Ace.YAMLSet=ba;Ace.set=Ice});var aA=ee(function(Pce){var $ce=gl();function sA(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 Q6(e){let{value:t}=e,r=(s)=>s;if(typeof t==="bigint")r=(s)=>BigInt(s);else if(isNaN(t)||!isFinite(t))return $ce.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 Oce={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})=>sA(e,r),stringify:Q6},Rce={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)=>sA(e,!1),stringify:Q6},Y6={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(Y6.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=sA(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$/,"")??""};Pce.floatTime=Rce;Pce.intTime=Oce;Pce.timestamp=Y6});var eq=ee(function(Jce){var Lce=ml(),Bce=ly(),jce=hl(),qce=Sf(),Uce=XI(),X6=J6(),cA=V6(),by=G6(),Mce=ty(),Fce=rA(),Zce=py(),Hce=oA(),lA=aA(),Kce=[Lce.map,jce.seq,qce.string,Bce.nullTag,X6.trueTag,X6.falseTag,by.intBin,by.intOct,by.int,by.intHex,cA.floatNaN,cA.floatExp,cA.float,Uce.binary,Mce.merge,Fce.omap,Zce.pairs,Hce.set,lA.intTime,lA.floatTime,lA.timestamp];Jce.schema=Kce});var uq=ee(function(rle){var iq=ml(),Wce=ly(),oq=hl(),Gce=Sf(),Qce=HI(),uA=JI(),dA=WI(),Yce=D6(),Xce=B6(),sq=XI(),kf=ty(),aq=rA(),cq=py(),tq=eq(),lq=oA(),xy=aA(),rq=new Map([["core",Yce.schema],["failsafe",[iq.map,oq.seq,Gce.string]],["json",Xce.schema],["yaml11",tq.schema],["yaml-1.1",tq.schema]]),nq={binary:sq.binary,bool:Qce.boolTag,float:uA.float,floatExp:uA.floatExp,floatNaN:uA.floatNaN,floatTime:xy.floatTime,int:dA.int,intHex:dA.intHex,intOct:dA.intOct,intTime:xy.intTime,map:iq.map,merge:kf.merge,null:Wce.nullTag,omap:aq.omap,pairs:cq.pairs,seq:oq.seq,set:lq.set,timestamp:xy.timestamp},ele={"tag:yaml.org,2002:binary":sq.binary,"tag:yaml.org,2002:merge":kf.merge,"tag:yaml.org,2002:omap":aq.omap,"tag:yaml.org,2002:pairs":cq.pairs,"tag:yaml.org,2002:set":lq.set,"tag:yaml.org,2002:timestamp":xy.timestamp};function tle(e,t,r){let i=rq.get(t);if(i&&!e)return r&&!i.includes(kf.merge)?i.concat(kf.merge):i.slice();let n=i;if(!n)if(Array.isArray(e))n=[];else{let o=Array.from(rq.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(kf.merge);return n.reduce((o,s)=>{let a=typeof s==="string"?nq[s]:s;if(!a){let c=JSON.stringify(s),l=Object.keys(nq).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},[])}rle.coreKnownTags=ele;rle.getTags=tle});var mA=ee(function(lle){var fA=Ge(),ole=ml(),sle=hl(),ale=Sf(),Sy=uq(),cle=(e,t)=>e.key<t.key?-1:e.key>t.key?1:0;class pA{constructor({compat:e,customTags:t,merge:r,resolveKnownTags:i,schema:n,sortMapEntries:o,toStringDefaults:s}){this.compat=Array.isArray(e)?Sy.getTags(e,"compat"):e?Sy.getTags(null,e):null,this.name=typeof n==="string"&&n||"core",this.knownTags=i?Sy.coreKnownTags:{},this.tags=Sy.getTags(t,this.name,r),this.toStringOptions=s??null,Object.defineProperty(this,fA.MAP,{value:ole.map}),Object.defineProperty(this,fA.SCALAR,{value:ale.string}),Object.defineProperty(this,fA.SEQ,{value:sle.seq}),this.sortMapEntries=typeof o==="function"?o:o===!0?cle:null}clone(){let e=Object.create(pA.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}}lle.Schema=pA});var dq=ee(function(ple){var dle=Ge(),hA=yf(),Ef=mf();function fle(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=hA.createStringifyContext(e,t),{commentString:o}=n.options;if(e.commentBefore){if(r.length!==1)r.unshift("");let c=o(e.commentBefore);r.unshift(Ef.indentComment(c,""))}let s=!1,a=null;if(e.contents){if(dle.isNode(e.contents)){if(e.contents.spaceBefore&&i)r.push("");if(e.contents.commentBefore){let u=o(e.contents.commentBefore);r.push(Ef.indentComment(u,""))}n.forceBlockIndent=!!e.comment,a=e.contents.comment}let c=a?void 0:()=>s=!0,l=hA.stringify(e.contents,n,()=>a=null,c);if(a)l+=Ef.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(hA.stringify(e.contents,n));if(e.directives?.docEnd)if(e.comment){let c=o(e.comment);if(c.includes(`
269
+ ${o.comment}`:i.comment}i=n}e.items[r]=fy.isPair(i)?i:new eA.Pair(i)}else t("Expected a sequence for this tag");return e}function qj(e,t,r){let{replacer:i}=r,n=new Vae.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(eA.createPair(a,c,r))}return n}var Wae={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:jj,createNode:qj};Gae.createPairs=qj;Gae.pairs=Wae;Gae.resolvePairs=jj});var rA=ee(function(rce){var Uj=Ge(),tA=Ho(),vf=Go(),ece=Qo(),Mj=py();class ya extends ece.YAMLSeq{constructor(){super();this.add=vf.YAMLMap.prototype.add.bind(this),this.delete=vf.YAMLMap.prototype.delete.bind(this),this.get=vf.YAMLMap.prototype.get.bind(this),this.has=vf.YAMLMap.prototype.has.bind(this),this.set=vf.YAMLMap.prototype.set.bind(this),this.tag=ya.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(Uj.isPair(i))n=tA.toJS(i.key,"",t),o=tA.toJS(i.value,n,t);else n=tA.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=Mj.createPairs(e,t,r),n=new this;return n.items=i.items,n}}ya.tag="tag:yaml.org,2002:omap";var tce={collection:"seq",identify:(e)=>e instanceof Map,nodeClass:ya,default:!1,tag:"tag:yaml.org,2002:omap",resolve(e,t){let r=Mj.resolvePairs(e,t),i=[];for(let{key:n}of r.items)if(Uj.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 ya,r)},createNode:(e,t,r)=>ya.from(e,t,r)};rce.YAMLOMap=ya;rce.omap=tce});var Jj=ee(function(oce){var Fj=Bt();function Zj({value:e,source:t},r){if(t&&(e?Hj:Kj).test.test(t))return t;return e?r.options.trueStr:r.options.falseStr}var Hj={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 Fj.Scalar(!0),stringify:Zj},Kj={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 Fj.Scalar(!1),stringify:Zj};oce.falseTag=Kj;oce.trueTag=Hj});var Vj=ee(function(fce){var cce=Bt(),nA=gl(),lce={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:nA.stringifyNumber},uce={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():nA.stringifyNumber(e)}},dce={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 cce.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:nA.stringifyNumber};fce.float=dce;fce.floatExp=uce;fce.floatNaN=lce});var Gj=ee(function(Sce){var Wj=gl(),_f=(e)=>typeof e==="bigint"||Number.isInteger(e);function my(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 iA(e,t,r){let{value:i}=e;if(_f(i)){let n=i.toString(t);return i<0?"-"+r+n.substr(1):r+n}return Wj.stringifyNumber(e)}var gce={identify:_f,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,r)=>my(e,2,2,r),stringify:(e)=>iA(e,2,"0b")},yce={identify:_f,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(e,t,r)=>my(e,1,8,r),stringify:(e)=>iA(e,8,"0")},bce={identify:_f,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,r)=>my(e,0,10,r),stringify:Wj.stringifyNumber},xce={identify:_f,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,r)=>my(e,2,16,r),stringify:(e)=>iA(e,16,"0x")};Sce.int=bce;Sce.intBin=gce;Sce.intHex=xce;Sce.intOct=yce});var oA=ee(function(Ice){var yy=Ge(),hy=Vo(),gy=Go();class ba extends gy.YAMLMap{constructor(e){super(e);this.tag=ba.tag}add(e){let t;if(yy.isPair(e))t=e;else if(e&&typeof e==="object"&&"key"in e&&"value"in e&&e.value===null)t=new hy.Pair(e.key,null);else t=new hy.Pair(e,null);if(!gy.findPair(this.items,t.key))this.items.push(t)}get(e,t){let r=gy.findPair(this.items,e);return!t&&yy.isPair(r)?yy.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=gy.findPair(this.items,e);if(r&&!t)this.items.splice(this.items.indexOf(r),1);else if(!r&&t)this.items.push(new hy.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(hy.createPair(o,null,r))}return n}}ba.tag="tag:yaml.org,2002:set";var Ece={collection:"map",identify:(e)=>e instanceof Set,nodeClass:ba,default:!1,tag:"tag:yaml.org,2002:set",createNode:(e,t,r)=>ba.from(e,t,r),resolve(e,t){if(yy.isMap(e))if(e.hasAllNullValues(!0))return Object.assign(new ba,e);else t("Set items must all have null values");else t("Expected a mapping for this tag");return e}};Ice.YAMLSet=ba;Ice.set=Ece});var aA=ee(function(Rce){var Cce=gl();function sA(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 Qj(e){let{value:t}=e,r=(s)=>s;if(typeof t==="bigint")r=(s)=>BigInt(s);else if(isNaN(t)||!isFinite(t))return Cce.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 $ce={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})=>sA(e,r),stringify:Qj},Oce={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)=>sA(e,!1),stringify:Qj},Yj={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(Yj.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=sA(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$/,"")??""};Rce.floatTime=Oce;Rce.intTime=$ce;Rce.timestamp=Yj});var eq=ee(function(Kce){var Dce=ml(),Lce=ly(),Bce=hl(),jce=Sf(),qce=XI(),Xj=Jj(),cA=Vj(),by=Gj(),Uce=ty(),Mce=rA(),Fce=py(),Zce=oA(),lA=aA(),Hce=[Dce.map,Bce.seq,jce.string,Lce.nullTag,Xj.trueTag,Xj.falseTag,by.intBin,by.intOct,by.int,by.intHex,cA.floatNaN,cA.floatExp,cA.float,qce.binary,Uce.merge,Mce.omap,Fce.pairs,Zce.set,lA.intTime,lA.floatTime,lA.timestamp];Kce.schema=Hce});var uq=ee(function(tle){var iq=ml(),Vce=ly(),oq=hl(),Wce=Sf(),Gce=HI(),uA=JI(),dA=WI(),Qce=Dj(),Yce=Bj(),sq=XI(),kf=ty(),aq=rA(),cq=py(),tq=eq(),lq=oA(),xy=aA(),rq=new Map([["core",Qce.schema],["failsafe",[iq.map,oq.seq,Wce.string]],["json",Yce.schema],["yaml11",tq.schema],["yaml-1.1",tq.schema]]),nq={binary:sq.binary,bool:Gce.boolTag,float:uA.float,floatExp:uA.floatExp,floatNaN:uA.floatNaN,floatTime:xy.floatTime,int:dA.int,intHex:dA.intHex,intOct:dA.intOct,intTime:xy.intTime,map:iq.map,merge:kf.merge,null:Vce.nullTag,omap:aq.omap,pairs:cq.pairs,seq:oq.seq,set:lq.set,timestamp:xy.timestamp},Xce={"tag:yaml.org,2002:binary":sq.binary,"tag:yaml.org,2002:merge":kf.merge,"tag:yaml.org,2002:omap":aq.omap,"tag:yaml.org,2002:pairs":cq.pairs,"tag:yaml.org,2002:set":lq.set,"tag:yaml.org,2002:timestamp":xy.timestamp};function ele(e,t,r){let i=rq.get(t);if(i&&!e)return r&&!i.includes(kf.merge)?i.concat(kf.merge):i.slice();let n=i;if(!n)if(Array.isArray(e))n=[];else{let o=Array.from(rq.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(kf.merge);return n.reduce((o,s)=>{let a=typeof s==="string"?nq[s]:s;if(!a){let c=JSON.stringify(s),l=Object.keys(nq).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},[])}tle.coreKnownTags=Xce;tle.getTags=ele});var mA=ee(function(cle){var fA=Ge(),ile=ml(),ole=hl(),sle=Sf(),Sy=uq(),ale=(e,t)=>e.key<t.key?-1:e.key>t.key?1:0;class pA{constructor({compat:e,customTags:t,merge:r,resolveKnownTags:i,schema:n,sortMapEntries:o,toStringDefaults:s}){this.compat=Array.isArray(e)?Sy.getTags(e,"compat"):e?Sy.getTags(null,e):null,this.name=typeof n==="string"&&n||"core",this.knownTags=i?Sy.coreKnownTags:{},this.tags=Sy.getTags(t,this.name,r),this.toStringOptions=s??null,Object.defineProperty(this,fA.MAP,{value:ile.map}),Object.defineProperty(this,fA.SCALAR,{value:sle.string}),Object.defineProperty(this,fA.SEQ,{value:ole.seq}),this.sortMapEntries=typeof o==="function"?o:o===!0?ale:null}clone(){let e=Object.create(pA.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}}cle.Schema=pA});var dq=ee(function(fle){var ule=Ge(),hA=yf(),Ef=mf();function dle(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=hA.createStringifyContext(e,t),{commentString:o}=n.options;if(e.commentBefore){if(r.length!==1)r.unshift("");let c=o(e.commentBefore);r.unshift(Ef.indentComment(c,""))}let s=!1,a=null;if(e.contents){if(ule.isNode(e.contents)){if(e.contents.spaceBefore&&i)r.push("");if(e.contents.commentBefore){let u=o(e.contents.commentBefore);r.push(Ef.indentComment(u,""))}n.forceBlockIndent=!!e.comment,a=e.contents.comment}let c=a?void 0:()=>s=!0,l=hA.stringify(e.contents,n,()=>a=null,c);if(a)l+=Ef.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(hA.stringify(e.contents,n));if(e.directives?.docEnd)if(e.comment){let c=o(e.comment);if(c.includes(`
271
270
  `))r.push("..."),r.push(Ef.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(Ef.indentComment(o(c),""))}}return r.join(`
272
271
  `)+`
273
- `}ple.stringifyDocument=fle});var If=ee(function(vle){var hle=ff(),yl=Vg(),kn=Ge(),gle=Vo(),yle=Ho(),ble=mA(),xle=dq(),gA=Hg(),Sle=NI(),wle=pf(),yA=zI();class bA{constructor(e,t,r){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,kn.NODE_TYPE,{value:kn.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 yA.Directives({version:o});this.setSchema(o,r),this.contents=e===void 0?null:this.createNode(e,i,r)}clone(){let e=Object.create(bA.prototype,{[kn.NODE_TYPE]:{value:kn.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=kn.isNode(this.contents)?this.contents.clone(e.schema):this.contents,this.range)e.range=this.range.slice();return e}add(e){if(bl(this.contents))this.contents.add(e)}addIn(e,t){if(bl(this.contents))this.contents.addIn(e,t)}createAlias(e,t){if(!e.anchor){let r=gA.anchorNames(this);e.anchor=!t||r.has(t)?gA.findNewAnchor(t||"a",r):t}return new hle.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}=gA.createNodeAnchors(this,o||"a"),m={aliasDuplicateObjects:n??!0,keepUndefined:a??!1,onAnchor:u,onTagObj:c,replacer:i,schema:this.schema,sourceObjects:p},y=wle.createNode(e,l,m);if(s&&kn.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 gle.Pair(i,n)}delete(e){return bl(this.contents)?this.contents.delete(e):!1}deleteIn(e){if(yl.isEmptyPath(e)){if(this.contents==null)return!1;return this.contents=null,!0}return bl(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return kn.isCollection(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){if(yl.isEmptyPath(e))return!t&&kn.isScalar(this.contents)?this.contents.value:this.contents;return kn.isCollection(this.contents)?this.contents.getIn(e,t):void 0}has(e){return kn.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){if(yl.isEmptyPath(e))return this.contents!==void 0;return kn.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,t){if(this.contents==null)this.contents=yl.collectionFromPath(this.schema,[e],t);else if(bl(this.contents))this.contents.set(e,t)}setIn(e,t){if(yl.isEmptyPath(e))this.contents=t;else if(this.contents==null)this.contents=yl.collectionFromPath(this.schema,Array.from(e),t);else if(bl(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 yA.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 yA.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 ble.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=yle.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"?Sle.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 xle.stringifyDocument(this,e)}}function bl(e){if(kn.isCollection(e))return!0;throw Error("Expected a YAML collection as document contents")}vle.Document=bA});var Af=ee(function(Ele){class wy extends Error{constructor(e,t,r,i){super();this.name=e,this.code=r,this.message=i,this.pos=t}}class fq extends wy{constructor(e,t,r){super("YAMLParseError",e,t,r)}}class pq extends wy{constructor(e,t,r){super("YAMLWarning",e,t,r)}}var kle=(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
272
+ `}fle.stringifyDocument=dle});var If=ee(function(wle){var mle=ff(),yl=Vg(),kn=Ge(),hle=Vo(),gle=Ho(),yle=mA(),ble=dq(),gA=Hg(),xle=NI(),Sle=pf(),yA=zI();class bA{constructor(e,t,r){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,kn.NODE_TYPE,{value:kn.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 yA.Directives({version:o});this.setSchema(o,r),this.contents=e===void 0?null:this.createNode(e,i,r)}clone(){let e=Object.create(bA.prototype,{[kn.NODE_TYPE]:{value:kn.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=kn.isNode(this.contents)?this.contents.clone(e.schema):this.contents,this.range)e.range=this.range.slice();return e}add(e){if(bl(this.contents))this.contents.add(e)}addIn(e,t){if(bl(this.contents))this.contents.addIn(e,t)}createAlias(e,t){if(!e.anchor){let r=gA.anchorNames(this);e.anchor=!t||r.has(t)?gA.findNewAnchor(t||"a",r):t}return new mle.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}=gA.createNodeAnchors(this,o||"a"),m={aliasDuplicateObjects:n??!0,keepUndefined:a??!1,onAnchor:u,onTagObj:c,replacer:i,schema:this.schema,sourceObjects:p},y=Sle.createNode(e,l,m);if(s&&kn.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 hle.Pair(i,n)}delete(e){return bl(this.contents)?this.contents.delete(e):!1}deleteIn(e){if(yl.isEmptyPath(e)){if(this.contents==null)return!1;return this.contents=null,!0}return bl(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return kn.isCollection(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){if(yl.isEmptyPath(e))return!t&&kn.isScalar(this.contents)?this.contents.value:this.contents;return kn.isCollection(this.contents)?this.contents.getIn(e,t):void 0}has(e){return kn.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){if(yl.isEmptyPath(e))return this.contents!==void 0;return kn.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,t){if(this.contents==null)this.contents=yl.collectionFromPath(this.schema,[e],t);else if(bl(this.contents))this.contents.set(e,t)}setIn(e,t){if(yl.isEmptyPath(e))this.contents=t;else if(this.contents==null)this.contents=yl.collectionFromPath(this.schema,Array.from(e),t);else if(bl(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 yA.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 yA.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 yle.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=gle.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"?xle.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 ble.stringifyDocument(this,e)}}function bl(e){if(kn.isCollection(e))return!0;throw Error("Expected a YAML collection as document contents")}wle.Document=bA});var Af=ee(function(kle){class wy extends Error{constructor(e,t,r,i){super();this.name=e,this.code=r,this.message=i,this.pos=t}}class fq extends wy{constructor(e,t,r){super("YAMLParseError",e,t,r)}}class pq extends wy{constructor(e,t,r){super("YAMLWarning",e,t,r)}}var _le=(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
274
273
  `;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+=`:
275
274
 
276
275
  ${s}
277
276
  ${l}
278
- `}};Ele.YAMLError=wy;Ele.YAMLParseError=fq;Ele.YAMLWarning=pq;Ele.prettifyError=kle});var Tf=ee(function(Ole){function $le(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}}Ole.resolveProps=$le});var vy=ee(function(Ple){function xA(e){if(!e)return null;switch(e.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(e.source.includes(`
279
- `))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(xA(t.key)||xA(t.value))return!0}return!1;default:return!0}}Ple.containsNewline=xA});var SA=ee(function(Lle){var Nle=vy();function Dle(e,t,r){if(t?.type==="flow-collection"){let i=t.end[0];if(i.indent===e&&(i.source==="]"||i.source==="}")&&Nle.containsNewline(t))r(i,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}Lle.flowIndentCheck=Dle});var wA=ee(function(qle){var mq=Ge();function jle(e,t,r){let{uniqueKeys:i}=e.options;if(i===!1)return!1;let n=typeof i==="function"?i:(o,s)=>o===s||mq.isScalar(o)&&mq.isScalar(s)&&o.value===s.value;return t.some((o)=>n(o.key,r))}qle.mapIncludes=jle});var xq=ee(function(Kle){var hq=Vo(),Mle=Go(),gq=Tf(),Fle=vy(),yq=SA(),Zle=wA(),bq="All mapping items must start at the same column";function Hle({composeNode:e,composeEmptyNode:t},r,i,n,o){let a=new(o?.nodeClass??Mle.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=gq.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",bq)}if(!g.anchor&&!g.tag&&!m){if(l=g.end,g.comment)if(a.comment)a.comment+=`
280
- `+g.comment;else a.comment=g.comment;continue}if(g.newlineAfterProp||Fle.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",bq);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)yq.flowIndentCheck(i.indent,p,n);if(r.atKey=!1,Zle.mapIncludes(r,a.items,A))n(v,"DUPLICATE_KEY","Map keys must be unique");let T=gq.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)yq.flowIndentCheck(i.indent,y,n);c=z.range[2];let j=new hq.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+=`
281
- `+T.comment;else A.comment=T.comment;let z=new hq.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}Kle.resolveBlockMap=Hle});var Sq=ee(function(Yle){var Vle=Qo(),Wle=Tf(),Gle=SA();function Qle({composeNode:e,composeEmptyNode:t},r,i,n,o){let a=new(o?.nodeClass??Vle.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=Wle.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)Gle.flowIndentCheck(i.indent,d,n);c=m.range[2],a.items.push(m)}return a.range=[i.offset,c,l??c],a}Yle.resolveBlockSeq=Qle});var xl=ee(function(tue){function eue(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}}tue.resolveEnd=eue});var _q=ee(function(uue){var nue=Ge(),iue=Vo(),wq=Go(),oue=Qo(),sue=xl(),vq=Tf(),aue=vy(),cue=wA(),vA="Block collections are not allowed within flow collections",_A=(e)=>e&&(e.type==="block-map"||e.type==="block-seq");function lue({composeNode:e,composeEmptyNode:t},r,i,n,o){let s=i.start.source==="{",a=s?"flow map":"flow sequence",l=new(o?.nodeClass??(s?wq.YAMLMap:oue.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=vq.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+=`
282
- `+E.comment;else l.comment=E.comment;d=E.end;continue}if(!s&&r.options.strict&&aue.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(nue.isPair(D))D=D.value??D.key;if(D.comment)D.comment+=`
277
+ `}};kle.YAMLError=wy;kle.YAMLParseError=fq;kle.YAMLWarning=pq;kle.prettifyError=_le});var Tf=ee(function($le){function Cle(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}}$le.resolveProps=Cle});var vy=ee(function(Rle){function xA(e){if(!e)return null;switch(e.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(e.source.includes(`
278
+ `))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(xA(t.key)||xA(t.value))return!0}return!1;default:return!0}}Rle.containsNewline=xA});var SA=ee(function(Dle){var zle=vy();function Nle(e,t,r){if(t?.type==="flow-collection"){let i=t.end[0];if(i.indent===e&&(i.source==="]"||i.source==="}")&&zle.containsNewline(t))r(i,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}Dle.flowIndentCheck=Nle});var wA=ee(function(jle){var mq=Ge();function Ble(e,t,r){let{uniqueKeys:i}=e.options;if(i===!1)return!1;let n=typeof i==="function"?i:(o,s)=>o===s||mq.isScalar(o)&&mq.isScalar(s)&&o.value===s.value;return t.some((o)=>n(o.key,r))}jle.mapIncludes=Ble});var xq=ee(function(Hle){var hq=Vo(),Ule=Go(),gq=Tf(),Mle=vy(),yq=SA(),Fle=wA(),bq="All mapping items must start at the same column";function Zle({composeNode:e,composeEmptyNode:t},r,i,n,o){let a=new(o?.nodeClass??Ule.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=gq.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",bq)}if(!g.anchor&&!g.tag&&!m){if(l=g.end,g.comment)if(a.comment)a.comment+=`
279
+ `+g.comment;else a.comment=g.comment;continue}if(g.newlineAfterProp||Mle.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",bq);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)yq.flowIndentCheck(i.indent,p,n);if(r.atKey=!1,Fle.mapIncludes(r,a.items,A))n(v,"DUPLICATE_KEY","Map keys must be unique");let T=gq.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)yq.flowIndentCheck(i.indent,y,n);c=z.range[2];let j=new hq.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+=`
280
+ `+T.comment;else A.comment=T.comment;let z=new hq.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}Hle.resolveBlockMap=Zle});var Sq=ee(function(Qle){var Jle=Qo(),Vle=Tf(),Wle=SA();function Gle({composeNode:e,composeEmptyNode:t},r,i,n,o){let a=new(o?.nodeClass??Jle.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=Vle.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)Wle.flowIndentCheck(i.indent,d,n);c=m.range[2],a.items.push(m)}return a.range=[i.offset,c,l??c],a}Qle.resolveBlockSeq=Gle});var xl=ee(function(eue){function Xle(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}}eue.resolveEnd=Xle});var _q=ee(function(lue){var rue=Ge(),nue=Vo(),wq=Go(),iue=Qo(),oue=xl(),vq=Tf(),sue=vy(),aue=wA(),vA="Block collections are not allowed within flow collections",_A=(e)=>e&&(e.type==="block-map"||e.type==="block-seq");function cue({composeNode:e,composeEmptyNode:t},r,i,n,o){let s=i.start.source==="{",a=s?"flow map":"flow sequence",l=new(o?.nodeClass??(s?wq.YAMLMap:iue.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=vq.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+=`
281
+ `+E.comment;else l.comment=E.comment;d=E.end;continue}if(!s&&r.options.strict&&sue.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(rue.isPair(D))D=D.value??D.key;if(D.comment)D.comment+=`
283
282
  `+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],_A(j))n(Z.range,"BLOCK_IN_FLOW",vA)}else{r.atKey=!0;let Z=E.end,D=T?e(r,T,E,n):t(r,Z,A,null,E,n);if(_A(T))n(D.range,"BLOCK_IN_FLOW",vA);r.atKey=!1;let H=vq.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(_A(j))n(X.range,"BLOCK_IN_FLOW",vA)}else if(H.comment)if(D.comment)D.comment+=`
284
- `+H.comment;else D.comment=H.comment;let M=new iue.Pair(D,X);if(r.options.keepSourceTokens)M.srcToken=v;if(s){let P=l;if(cue.mapIncludes(r,P.items,D))n(Z,"DUPLICATE_KEY","Map keys must be unique");P.items.push(M)}else{let P=new wq.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=sue.resolveEnd(y,g,r.options.strict,n);if(b.comment)if(l.comment)l.comment+=`
285
- `+b.comment;else l.comment=b.comment;l.range=[i.offset,g,b.offset]}else l.range=[i.offset,g,g];return l}uue.resolveFlowCollection=lue});var kq=ee(function(Sue){var fue=Ge(),pue=Bt(),mue=Go(),hue=Qo(),gue=xq(),yue=Sq(),bue=_q();function kA(e,t,r,i,n,o){let s=r.type==="block-map"?gue.resolveBlockMap(e,t,r,i,o):r.type==="block-seq"?yue.resolveBlockSeq(e,t,r,i,o):bue.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 xue(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===mue.YAMLMap.tagName&&a==="map"||s===hue.YAMLSeq.tagName&&a==="seq")return kA(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 kA(e,t,r,n,s)}}let l=kA(e,t,r,n,s,c),u=c.resolve?.(l,(p)=>n(o,"TAG_RESOLVE_FAILED",p),t.options)??l,d=fue.isNode(u)?u:new pue.Scalar(u);if(d.range=l.range,d.tag=s,c?.format)d.format=c.format;return d}Sue.composeCollection=xue});var IA=ee(function(Eue){var EA=Bt();function vue(e,t,r){let i=t.offset,n=_ue(t,e.options.strict,r);if(!n)return{value:"",type:null,comment:"",range:[i,i,i]};let o=n.mode===">"?EA.Scalar.BLOCK_FOLDED:EA.Scalar.BLOCK_LITERAL,s=t.source?kue(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?`
283
+ `+H.comment;else D.comment=H.comment;let M=new nue.Pair(D,X);if(r.options.keepSourceTokens)M.srcToken=v;if(s){let P=l;if(aue.mapIncludes(r,P.items,D))n(Z,"DUPLICATE_KEY","Map keys must be unique");P.items.push(M)}else{let P=new wq.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=oue.resolveEnd(y,g,r.options.strict,n);if(b.comment)if(l.comment)l.comment+=`
284
+ `+b.comment;else l.comment=b.comment;l.range=[i.offset,g,b.offset]}else l.range=[i.offset,g,g];return l}lue.resolveFlowCollection=cue});var kq=ee(function(xue){var due=Ge(),fue=Bt(),pue=Go(),mue=Qo(),hue=xq(),gue=Sq(),yue=_q();function kA(e,t,r,i,n,o){let s=r.type==="block-map"?hue.resolveBlockMap(e,t,r,i,o):r.type==="block-seq"?gue.resolveBlockSeq(e,t,r,i,o):yue.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 bue(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===pue.YAMLMap.tagName&&a==="map"||s===mue.YAMLSeq.tagName&&a==="seq")return kA(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 kA(e,t,r,n,s)}}let l=kA(e,t,r,n,s,c),u=c.resolve?.(l,(p)=>n(o,"TAG_RESOLVE_FAILED",p),t.options)??l,d=due.isNode(u)?u:new fue.Scalar(u);if(d.range=l.range,d.tag=s,c?.format)d.format=c.format;return d}xue.composeCollection=bue});var IA=ee(function(kue){var EA=Bt();function wue(e,t,r){let i=t.offset,n=vue(t,e.options.strict,r);if(!n)return{value:"",type:null,comment:"",range:[i,i,i]};let o=n.mode===">"?EA.Scalar.BLOCK_FOLDED:EA.Scalar.BLOCK_LITERAL,s=t.source?_ue(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?`
286
285
  `.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)+`
287
286
  `;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===EA.Scalar.BLOCK_LITERAL)d+=p+b.slice(c)+v,p=`
288
287
  `;else if(b.length>c||v[0]==="\t"){if(p===" ")p=`
@@ -297,41 +296,41 @@ ${l}
297
296
  `+s[g][0].slice(c);if(d[d.length-1]!==`
298
297
  `)d+=`
299
298
  `;break;default:d+=`
300
- `}let y=i+n.length+t.source.length;return{value:d,type:o,comment:n.comment,range:[i,y,y]}}function _ue({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 kue(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}Eue.resolveBlockScalar=vue});var TA=ee(function(Nue){var AA=Bt(),Aue=xl();function Tue(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=AA.Scalar.PLAIN,c=Cue(o,l);break;case"single-quoted-scalar":a=AA.Scalar.QUOTE_SINGLE,c=$ue(o,l);break;case"double-quoted-scalar":a=AA.Scalar.QUOTE_DOUBLE,c=Oue(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=Aue.resolveEnd(s,u,t,r);return{value:c,type:a,comment:d.comment,range:[i,u,d.offset]}}function Cue(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 Eq(e)}function $ue(e,t){if(e[e.length-1]!=="'"||e.length===1)t(e.length,"MISSING_CHAR","Missing closing 'quote");return Eq(e.slice(1,-1)).replace(/''/g,"'")}function Eq(e){let t,r;try{t=new RegExp(`(.*?)(?<![ ])[ ]*\r?
299
+ `}let y=i+n.length+t.source.length;return{value:d,type:o,comment:n.comment,range:[i,y,y]}}function vue({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 _ue(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}kue.resolveBlockScalar=wue});var TA=ee(function(zue){var AA=Bt(),Iue=xl();function Aue(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=AA.Scalar.PLAIN,c=Tue(o,l);break;case"single-quoted-scalar":a=AA.Scalar.QUOTE_SINGLE,c=Cue(o,l);break;case"double-quoted-scalar":a=AA.Scalar.QUOTE_DOUBLE,c=$ue(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=Iue.resolveEnd(s,u,t,r);return{value:c,type:a,comment:d.comment,range:[i,u,d.offset]}}function Tue(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 Eq(e)}function Cue(e,t){if(e[e.length-1]!=="'"||e.length===1)t(e.length,"MISSING_CHAR","Missing closing 'quote");return Eq(e.slice(1,-1)).replace(/''/g,"'")}function Eq(e){let t,r;try{t=new RegExp(`(.*?)(?<![ ])[ ]*\r?
301
300
  `,"sy"),r=new RegExp(`[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?
302
301
  `,"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===`
303
302
  `)n+=o;else o=`
304
- `;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 Oue(e,t){let r="";for(let i=1;i<e.length-1;++i){let n=e[i];if(n==="\r"&&e[i+1]===`
303
+ `;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 $ue(e,t){let r="";for(let i=1;i<e.length-1;++i){let n=e[i];if(n==="\r"&&e[i+1]===`
305
304
  `)continue;if(n===`
306
- `){let{fold:o,offset:s}=Rue(e,i);r+=o,i=s}else if(n==="\\"){let o=e[++i],s=Pue[o];if(s)r+=s;else if(o===`
305
+ `){let{fold:o,offset:s}=Oue(e,i);r+=o,i=s}else if(n==="\\"){let o=e[++i],s=Rue[o];if(s)r+=s;else if(o===`
307
306
  `){o=e[i+1];while(o===" "||o==="\t")o=e[++i+1]}else if(o==="\r"&&e[i+1]===`
308
- `){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+=zue(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!==`
307
+ `){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+=Pue(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!==`
309
308
  `&&!(s==="\r"&&e[i+2]===`
310
- `))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 Rue(e,t){let r="",i=e[t+1];while(i===" "||i==="\t"||i===`
309
+ `))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 Oue(e,t){let r="",i=e[t+1];while(i===" "||i==="\t"||i===`
311
310
  `||i==="\r"){if(i==="\r"&&e[t+2]!==`
312
311
  `)break;if(i===`
313
312
  `)r+=`
314
- `;t+=1,i=e[t+1]}if(!r)r=" ";return{fold:r,offset:t}}var Pue={"0":"\x00",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
315
- `,r:"\r",t:"\t",v:"\v",N:"\x85",_:"\xA0",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\","\t":"\t"};function zue(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}}Nue.resolveFlowScalar=Tue});var Aq=ee(function(Mue){var xa=Ge(),Iq=Bt(),Lue=IA(),Bue=TA();function jue(e,t,r,i){let{value:n,type:o,comment:s,range:a}=t.type==="block-scalar"?Lue.resolveBlockScalar(e,t,i):Bue.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[xa.SCALAR];else if(c)l=que(e.schema,n,c,r,i);else if(t.type==="scalar")l=Uue(e,n,t,i);else l=e.schema[xa.SCALAR];let u;try{let d=l.resolve(n,(p)=>i(r??t,"TAG_RESOLVE_FAILED",p),e.options);u=xa.isScalar(d)?d:new Iq.Scalar(d)}catch(d){let p=d instanceof Error?d.message:String(d);i(r??t,"TAG_RESOLVE_FAILED",p),u=new Iq.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 que(e,t,r,i,n){if(r==="!")return e[xa.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[xa.SCALAR]}function Uue({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[xa.SCALAR];if(r.compat){let a=r.compat.find((c)=>c.default&&c.test?.test(i))??r[xa.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}Mue.composeScalar=jue});var Tq=ee(function(Hue){function Zue(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}Hue.emptyScalarPosition=Zue});var Oq=ee(function(ede){var Jue=ff(),Vue=Ge(),Wue=kq(),Cq=Aq(),Gue=xl(),Que=Tq(),Yue={composeNode:$q,composeEmptyNode:CA};function $q(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=Xue(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=Cq.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=Wue.composeCollection(Yue,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=CA(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&&(!Vue.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 CA(e,t,r,i,{spaceBefore:n,comment:o,anchor:s,tag:a,end:c},l){let u={type:"scalar",offset:Que.emptyScalarPosition(t,r,i),indent:-1,source:""},d=Cq.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 Xue({options:e},{offset:t,source:r,end:i},n){let o=new Jue.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=Gue.resolveEnd(i,s,e.strict,n);if(o.range=[t,s,a.offset],a.comment)o.comment=a.comment;return o}ede.composeEmptyNode=CA;ede.composeNode=$q});var Pq=ee(function(ade){var nde=If(),Rq=Oq(),ide=xl(),ode=Tf();function sde(e,t,{offset:r,start:i,value:n,end:o},s){let a=Object.assign({_directives:t},e),c=new nde.Document(void 0,a),l={atKey:!1,atRoot:!0,directives:c.directives,options:c.options,schema:c.schema},u=ode.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?Rq.composeNode(l,n,u,s):Rq.composeEmptyNode(l,u.end,i,null,u,s);let d=c.contents.range[2],p=ide.resolveEnd(o,d,!1,s);if(p.comment)c.comment=p.comment;return c.range=[r,d,p.offset],c}ade.composeDoc=sde});var $A=ee(function(mde){var lde=Tt("process"),ude=zI(),dde=If(),Cf=Af(),zq=Ge(),fde=Pq(),pde=xl();function $f(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 Nq(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?`
313
+ `;t+=1,i=e[t+1]}if(!r)r=" ";return{fold:r,offset:t}}var Rue={"0":"\x00",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
314
+ `,r:"\r",t:"\t",v:"\v",N:"\x85",_:"\xA0",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\","\t":"\t"};function Pue(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}}zue.resolveFlowScalar=Aue});var Aq=ee(function(Uue){var xa=Ge(),Iq=Bt(),Due=IA(),Lue=TA();function Bue(e,t,r,i){let{value:n,type:o,comment:s,range:a}=t.type==="block-scalar"?Due.resolveBlockScalar(e,t,i):Lue.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[xa.SCALAR];else if(c)l=jue(e.schema,n,c,r,i);else if(t.type==="scalar")l=que(e,n,t,i);else l=e.schema[xa.SCALAR];let u;try{let d=l.resolve(n,(p)=>i(r??t,"TAG_RESOLVE_FAILED",p),e.options);u=xa.isScalar(d)?d:new Iq.Scalar(d)}catch(d){let p=d instanceof Error?d.message:String(d);i(r??t,"TAG_RESOLVE_FAILED",p),u=new Iq.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 jue(e,t,r,i,n){if(r==="!")return e[xa.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[xa.SCALAR]}function que({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[xa.SCALAR];if(r.compat){let a=r.compat.find((c)=>c.default&&c.test?.test(i))??r[xa.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}Uue.composeScalar=Bue});var Tq=ee(function(Zue){function Fue(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}Zue.emptyScalarPosition=Fue});var Oq=ee(function(Xue){var Kue=ff(),Jue=Ge(),Vue=kq(),Cq=Aq(),Wue=xl(),Gue=Tq(),Que={composeNode:$q,composeEmptyNode:CA};function $q(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=Yue(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=Cq.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=Vue.composeCollection(Que,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=CA(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&&(!Jue.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 CA(e,t,r,i,{spaceBefore:n,comment:o,anchor:s,tag:a,end:c},l){let u={type:"scalar",offset:Gue.emptyScalarPosition(t,r,i),indent:-1,source:""},d=Cq.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 Yue({options:e},{offset:t,source:r,end:i},n){let o=new Kue.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=Wue.resolveEnd(i,s,e.strict,n);if(o.range=[t,s,a.offset],a.comment)o.comment=a.comment;return o}Xue.composeEmptyNode=CA;Xue.composeNode=$q});var Pq=ee(function(sde){var rde=If(),Rq=Oq(),nde=xl(),ide=Tf();function ode(e,t,{offset:r,start:i,value:n,end:o},s){let a=Object.assign({_directives:t},e),c=new rde.Document(void 0,a),l={atKey:!1,atRoot:!0,directives:c.directives,options:c.options,schema:c.schema},u=ide.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?Rq.composeNode(l,n,u,s):Rq.composeEmptyNode(l,u.end,i,null,u,s);let d=c.contents.range[2],p=nde.resolveEnd(o,d,!1,s);if(p.comment)c.comment=p.comment;return c.range=[r,d,p.offset],c}sde.composeDoc=ode});var $A=ee(function(pde){var cde=Tt("process"),lde=zI(),ude=If(),Cf=Af(),zq=Ge(),dde=Pq(),fde=xl();function $f(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 Nq(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?`
316
315
 
317
316
  `:`
318
- `)+(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 Dq{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(t,r,i,n)=>{let o=$f(t);if(n)this.warnings.push(new Cf.YAMLWarning(o,r,i));else this.errors.push(new Cf.YAMLParseError(o,r,i))},this.directives=new ude.Directives({version:e.version||"1.2"}),this.options=e}decorate(e,t){let{comment:r,afterEmptyLine:i}=Nq(this.prelude);if(r){let n=e.contents;if(t)e.comment=e.comment?`${e.comment}
317
+ `)+(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 Dq{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(t,r,i,n)=>{let o=$f(t);if(n)this.warnings.push(new Cf.YAMLWarning(o,r,i));else this.errors.push(new Cf.YAMLParseError(o,r,i))},this.directives=new lde.Directives({version:e.version||"1.2"}),this.options=e}decorate(e,t){let{comment:r,afterEmptyLine:i}=Nq(this.prelude);if(r){let n=e.contents;if(t)e.comment=e.comment?`${e.comment}
319
318
  ${r}`:r;else if(i||e.directives.docStart||!n)e.commentBefore=r;else if(zq.isCollection(n)&&!n.flow&&n.items.length>0){let o=n.items[0];if(zq.isPair(o))o=o.key;let s=o.commentBefore;o.commentBefore=s?`${r}
320
319
  ${s}`:r}else{let o=n.commentBefore;n.commentBefore=o?`${r}
321
- ${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:Nq(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(lde.env.LOG_STREAM)console.dir(e,{depth:null});switch(e.type){case"directive":this.directives.add(e.source,(t,r,i)=>{let n=$f(e);n[0]+=t,this.onError(n,"BAD_DIRECTIVE",r,i)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let t=fde.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 Cf.YAMLParseError($f(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 Cf.YAMLParseError($f(e),"UNEXPECTED_TOKEN","Unexpected doc-end without preceding document"));break}this.doc.directives.docEnd=!0;let t=pde.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}
322
- ${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new Cf.YAMLParseError($f(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 dde.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}}}mde.Composer=Dq});var jq=ee(function(_de){var gde=IA(),yde=TA(),bde=Af(),Lq=gf();function xde(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 bde.YAMLParseError([a,a+1],o,s)};switch(e.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return yde.resolveFlowScalar(e,t,i);case"block-scalar":return gde.resolveBlockScalar({options:{strict:t}},e,i)}}return null}function Sde(e,t){let{implicitKey:r=!1,indent:i,inFlow:n=!1,offset:o=-1,type:s="PLAIN"}=t,a=Lq.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:`
320
+ ${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:Nq(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(cde.env.LOG_STREAM)console.dir(e,{depth:null});switch(e.type){case"directive":this.directives.add(e.source,(t,r,i)=>{let n=$f(e);n[0]+=t,this.onError(n,"BAD_DIRECTIVE",r,i)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let t=dde.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 Cf.YAMLParseError($f(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 Cf.YAMLParseError($f(e),"UNEXPECTED_TOKEN","Unexpected doc-end without preceding document"));break}this.doc.directives.docEnd=!0;let t=fde.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}
321
+ ${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new Cf.YAMLParseError($f(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 ude.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}}}pde.Composer=Dq});var jq=ee(function(vde){var hde=IA(),gde=TA(),yde=Af(),Lq=gf();function bde(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 yde.YAMLParseError([a,a+1],o,s)};switch(e.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return gde.resolveFlowScalar(e,t,i);case"block-scalar":return hde.resolveBlockScalar({options:{strict:t}},e,i)}}return null}function xde(e,t){let{implicitKey:r=!1,indent:i,inFlow:n=!1,offset:o=-1,type:s="PLAIN"}=t,a=Lq.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:`
323
322
  `}];switch(a[0]){case"|":case">":{let l=a.indexOf(`
324
323
  `),u=a.substring(0,l),d=a.substring(l+1)+`
325
324
  `,p=[{type:"block-scalar-header",offset:o,indent:i,source:u}];if(!Bq(p,c))p.push({type:"newline",offset:-1,indent:i,source:`
326
- `});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 wde(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=Lq.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">":vde(e,c);break;case'"':OA(e,c,"double-quoted-scalar");break;case"'":OA(e,c,"single-quoted-scalar");break;default:OA(e,c,"scalar")}}function vde(e,t){let r=t.indexOf(`
325
+ `});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 Sde(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=Lq.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">":wde(e,c);break;case'"':OA(e,c,"double-quoted-scalar");break;case"'":OA(e,c,"single-quoted-scalar");break;default:OA(e,c,"scalar")}}function wde(e,t){let r=t.indexOf(`
327
326
  `),i=t.substring(0,r),n=t.substring(r+1)+`
328
327
  `;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(!Bq(a,"end"in e?e.end:void 0))a.push({type:"newline",offset:-1,indent:s,source:`
329
328
  `});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 Bq(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 OA(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:`
330
- `};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})}}}_de.createScalarToken=Sde;_de.resolveAsScalar=xde;_de.setScalarValue=wde});var qq=ee(function(Tde){var Ade=(e)=>("type"in e)?ky(e):_y(e);function ky(e){switch(e.type){case"block-scalar":{let t="";for(let r of e.props)t+=ky(r);return t+e.source}case"block-map":case"block-seq":{let t="";for(let r of e.items)t+=_y(r);return t}case"flow-collection":{let t=e.start.source;for(let r of e.items)t+=_y(r);for(let r of e.end)t+=r.source;return t}case"document":{let t=_y(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 _y({start:e,key:t,sep:r,value:i}){let n="";for(let o of e)n+=o.source;if(t)n+=ky(t);if(r)for(let o of r)n+=o.source;if(i)n+=ky(i);return n}Tde.stringify=Ade});var Fq=ee(function(Ode){var RA=Symbol("break visit"),$de=Symbol("skip children"),Uq=Symbol("remove item");function Sa(e,t){if("type"in e&&e.type==="document")e={start:e.start,value:e.value};Mq(Object.freeze([]),e,t)}Sa.BREAK=RA;Sa.SKIP=$de;Sa.REMOVE=Uq;Sa.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};Sa.parentCollection=(e,t)=>{let r=Sa.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 Mq(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=Mq(Object.freeze(e.concat([[n,s]])),o.items[s],r);if(typeof a==="number")s=a-1;else if(a===RA)return RA;else if(a===Uq)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}Ode.visit=Sa});var Ey=ee(function(jde){var PA=jq(),Pde=qq(),zde=Fq(),zA="\uFEFF",NA="\x02",DA="\x18",LA="\x1F",Nde=(e)=>!!e&&("items"in e),Dde=(e)=>!!e&&(e.type==="scalar"||e.type==="single-quoted-scalar"||e.type==="double-quoted-scalar"||e.type==="block-scalar");function Lde(e){switch(e){case zA:return"<BOM>";case NA:return"<DOC>";case DA:return"<FLOW_END>";case LA:return"<SCALAR>";default:return JSON.stringify(e)}}function Bde(e){switch(e){case zA:return"byte-order-mark";case NA:return"doc-mode";case DA:return"flow-error-end";case LA:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
329
+ `};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})}}}vde.createScalarToken=xde;vde.resolveAsScalar=bde;vde.setScalarValue=Sde});var qq=ee(function(Ade){var Ide=(e)=>("type"in e)?ky(e):_y(e);function ky(e){switch(e.type){case"block-scalar":{let t="";for(let r of e.props)t+=ky(r);return t+e.source}case"block-map":case"block-seq":{let t="";for(let r of e.items)t+=_y(r);return t}case"flow-collection":{let t=e.start.source;for(let r of e.items)t+=_y(r);for(let r of e.end)t+=r.source;return t}case"document":{let t=_y(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 _y({start:e,key:t,sep:r,value:i}){let n="";for(let o of e)n+=o.source;if(t)n+=ky(t);if(r)for(let o of r)n+=o.source;if(i)n+=ky(i);return n}Ade.stringify=Ide});var Fq=ee(function($de){var RA=Symbol("break visit"),Cde=Symbol("skip children"),Uq=Symbol("remove item");function Sa(e,t){if("type"in e&&e.type==="document")e={start:e.start,value:e.value};Mq(Object.freeze([]),e,t)}Sa.BREAK=RA;Sa.SKIP=Cde;Sa.REMOVE=Uq;Sa.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};Sa.parentCollection=(e,t)=>{let r=Sa.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 Mq(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=Mq(Object.freeze(e.concat([[n,s]])),o.items[s],r);if(typeof a==="number")s=a-1;else if(a===RA)return RA;else if(a===Uq)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}$de.visit=Sa});var Ey=ee(function(Bde){var PA=jq(),Rde=qq(),Pde=Fq(),zA="\uFEFF",NA="\x02",DA="\x18",LA="\x1F",zde=(e)=>!!e&&("items"in e),Nde=(e)=>!!e&&(e.type==="scalar"||e.type==="single-quoted-scalar"||e.type==="double-quoted-scalar"||e.type==="block-scalar");function Dde(e){switch(e){case zA:return"<BOM>";case NA:return"<DOC>";case DA:return"<FLOW_END>";case LA:return"<SCALAR>";default:return JSON.stringify(e)}}function Lde(e){switch(e){case zA:return"byte-order-mark";case NA:return"doc-mode";case DA:return"flow-error-end";case LA:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
331
330
  `:case`\r
332
- `: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}jde.createScalarToken=PA.createScalarToken;jde.resolveAsScalar=PA.resolveAsScalar;jde.setScalarValue=PA.setScalarValue;jde.stringify=Pde.stringify;jde.visit=zde.visit;jde.BOM=zA;jde.DOCUMENT=NA;jde.FLOW_END=DA;jde.SCALAR=LA;jde.isCollection=Nde;jde.isScalar=Dde;jde.prettyToken=Lde;jde.tokenType=Bde});var jA=ee(function(tfe){var Of=Ey();function Fn(e){switch(e){case void 0:case" ":case`
333
- `:case"\r":case"\t":return!0;default:return!1}}var Zq=new Set("0123456789ABCDEFabcdef"),Xde=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),Iy=new Set(",[]{}"),efe=new Set(` ,[]{}
334
- \r `),BA=(e)=>!e||efe.has(e);class Hq{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===`
331
+ `: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}Bde.createScalarToken=PA.createScalarToken;Bde.resolveAsScalar=PA.resolveAsScalar;Bde.setScalarValue=PA.setScalarValue;Bde.stringify=Rde.stringify;Bde.visit=Pde.visit;Bde.BOM=zA;Bde.DOCUMENT=NA;Bde.FLOW_END=DA;Bde.SCALAR=LA;Bde.isCollection=zde;Bde.isScalar=Nde;Bde.prettyToken=Dde;Bde.tokenType=Lde});var jA=ee(function(efe){var Of=Ey();function Fn(e){switch(e){case void 0:case" ":case`
332
+ `:case"\r":case"\t":return!0;default:return!1}}var Zq=new Set("0123456789ABCDEFabcdef"),Yde=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),Iy=new Set(",[]{}"),Xde=new Set(` ,[]{}
333
+ \r `),BA=(e)=>!e||Xde.has(e);class Hq{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===`
335
334
  `)return!0;if(t==="\r")return this.buffer[e+1]===`
336
335
  `;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===`
337
336
  `||!i&&!this.atEnd)return e+r+1}return t===`
@@ -346,80 +345,80 @@ ${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.pus
346
345
  `&&n>=this.pos&&n+1+t>s)e=n;else break}while(!0);return yield Of.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(Fn(n)||e&&Iy.has(n))break;t=r}else if(Fn(i)){let n=this.buffer[r+1];if(i==="\r")if(n===`
347
346
  `)r+=1,i=`
348
347
  `,n=this.buffer[r+1];else t=r;if(n==="#"||e&&Iy.has(n))break;if(i===`
349
- `){let o=this.continueScalar(r+1);if(o===-1)break;r=Math.max(r,o-2)}}else{if(e&&Iy.has(i))break;t=r}if(!i&&!this.atEnd)return this.setNext("plain-scalar");return yield Of.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(BA),e+=yield*this.pushSpaces(!0);continue e;case"-":case"?":case":":{let t=this.flowLevel>0,r=this.charAt(1);if(Fn(r)||t&&Iy.has(r)){if(!t)this.indentNext=this.indentValue+1;else if(this.flowKey)this.flowKey=!1;e+=yield*this.pushCount(1),e+=yield*this.pushSpaces(!0);continue e}}}break e}return e}*pushTag(){if(this.charAt(1)==="<"){let e=this.pos+2,t=this.buffer[e];while(!Fn(t)&&t!==">")t=this.buffer[++e];return yield*this.pushToIndex(t===">"?e+1:e,!1)}else{let e=this.pos+1,t=this.buffer[e];while(t)if(Xde.has(t))t=this.buffer[++e];else if(t==="%"&&Zq.has(this.buffer[e+1])&&Zq.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===`
348
+ `){let o=this.continueScalar(r+1);if(o===-1)break;r=Math.max(r,o-2)}}else{if(e&&Iy.has(i))break;t=r}if(!i&&!this.atEnd)return this.setNext("plain-scalar");return yield Of.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(BA),e+=yield*this.pushSpaces(!0);continue e;case"-":case"?":case":":{let t=this.flowLevel>0,r=this.charAt(1);if(Fn(r)||t&&Iy.has(r)){if(!t)this.indentNext=this.indentValue+1;else if(this.flowKey)this.flowKey=!1;e+=yield*this.pushCount(1),e+=yield*this.pushSpaces(!0);continue e}}}break e}return e}*pushTag(){if(this.charAt(1)==="<"){let e=this.pos+2,t=this.buffer[e];while(!Fn(t)&&t!==">")t=this.buffer[++e];return yield*this.pushToIndex(t===">"?e+1:e,!1)}else{let e=this.pos+1,t=this.buffer[e];while(t)if(Yde.has(t))t=this.buffer[++e];else if(t==="%"&&Zq.has(this.buffer[e+1])&&Zq.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===`
350
349
  `)return yield*this.pushCount(1);else if(e==="\r"&&this.charAt(1)===`
351
- `)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)}}tfe.Lexer=Hq});var qA=ee(function(nfe){class Kq{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}}}}nfe.LineCounter=Kq});var UA=ee(function(afe){var ofe=Tt("process"),Jq=Ey(),sfe=jA();function Yo(e,t){for(let r=0;r<e.length;++r)if(e[r].type===t)return!0;return!1}function Vq(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 Gq(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 Ay(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 Sl(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 Ty(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 Wq(e){if(e.start.type==="flow-seq-start"){for(let t of e.items)if(t.sep&&!t.value&&!Yo(t.start,"explicit-key-ind")&&!Yo(t.sep,"map-value-ind")){if(t.key)t.value=t.key;if(delete t.key,Gq(t.value))if(t.value.end)Ty(t.value.end,t.sep);else t.value.end=t.sep;else Ty(t.start,t.sep);delete t.sep}}}class Qq{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 sfe.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,ofe.env.LOG_TOKENS)console.log("|",Jq.prettyToken(e));if(this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let t=Jq.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")Wq(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&&Vq(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(Vq(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=Ay(this.peek(2)),r=Sl(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(`
350
+ `)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)}}efe.Lexer=Hq});var qA=ee(function(rfe){class Kq{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}}}}rfe.LineCounter=Kq});var UA=ee(function(sfe){var ife=Tt("process"),Jq=Ey(),ofe=jA();function Yo(e,t){for(let r=0;r<e.length;++r)if(e[r].type===t)return!0;return!1}function Vq(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 Gq(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 Ay(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 Sl(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 Ty(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 Wq(e){if(e.start.type==="flow-seq-start"){for(let t of e.items)if(t.sep&&!t.value&&!Yo(t.start,"explicit-key-ind")&&!Yo(t.sep,"map-value-ind")){if(t.key)t.value=t.key;if(delete t.key,Gq(t.value))if(t.value.end)Ty(t.value.end,t.sep);else t.value.end=t.sep;else Ty(t.start,t.sep);delete t.sep}}}class Qq{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 ofe.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,ife.env.LOG_TOKENS)console.log("|",Jq.prettyToken(e));if(this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let t=Jq.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")Wq(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&&Vq(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(Vq(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=Ay(this.peek(2)),r=Sl(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(`
352
351
  `)+1;while(t!==0)this.onNewLine(this.offset+t),t=this.source.indexOf(`
353
352
  `,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)){Ty(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(Yo(t.start,"newline"))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let o=Sl(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(Yo(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(Gq(t.key)&&!Yo(t.sep,"newline")){let o=Sl(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(Yo(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&&!Yo(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)){Ty(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||Yo(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=Ay(r),n=Sl(i);Wq(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(`
354
353
  `)+1;while(t!==0)this.onNewLine(this.offset+t),t=this.source.indexOf(`
355
- `,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=Ay(e),r=Sl(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=Ay(e),r=Sl(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()}}}afe.Parser=Qq});var rU=ee(function(gfe){var Yq=$A(),lfe=If(),Rf=Af(),ufe=qI(),dfe=Ge(),ffe=qA(),Xq=UA();function eU(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new ffe.LineCounter||null,prettyErrors:t}}function pfe(e,t={}){let{lineCounter:r,prettyErrors:i}=eU(t),n=new Xq.Parser(r?.addNewLine),o=new Yq.Composer(t),s=Array.from(o.compose(n.parse(e)));if(i&&r)for(let a of s)a.errors.forEach(Rf.prettifyError(e,r)),a.warnings.forEach(Rf.prettifyError(e,r));if(s.length>0)return s;return Object.assign([],{empty:!0},o.streamInfo())}function tU(e,t={}){let{lineCounter:r,prettyErrors:i}=eU(t),n=new Xq.Parser(r?.addNewLine),o=new Yq.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 Rf.YAMLParseError(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}if(i&&r)s.errors.forEach(Rf.prettifyError(e,r)),s.warnings.forEach(Rf.prettifyError(e,r));return s}function mfe(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=tU(e,r);if(!n)return null;if(n.warnings.forEach((o)=>ufe.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 hfe(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(dfe.isDocument(e)&&!i)return e.toString(r);return new lfe.Document(e,i,r).toString(r)}gfe.parse=mfe;gfe.parseAllDocuments=pfe;gfe.parseDocument=tU;gfe.stringify=hfe});var wfe,vfe,_fe,MA,kfe,Xo,Efe,Ife,Afe,Tfe,N2e,Cfe,$fe,Ofe,Cy,nU,Rfe,Pfe,zfe,Nfe,Dfe,Lfe,Bfe,jfe,qfe,Ufe,Wi,Gi,Mfe,wl,FA,Ffe,Zfe,Hfe,Kfe,Jfe,Vfe,Wfe,Gfe,Qfe,gi,Yfe,Xfe,epe;var Pf=x(()=>{wfe=$A(),vfe=If(),_fe=mA(),MA=Af(),kfe=ff(),Xo=Ge(),Efe=Vo(),Ife=Bt(),Afe=Go(),Tfe=Qo(),N2e=Ey(),Cfe=jA(),$fe=qA(),Ofe=UA(),Cy=rU(),nU=uf();Rfe=wfe.Composer,Pfe=vfe.Document,zfe=_fe.Schema,Nfe=MA.YAMLError,Dfe=MA.YAMLParseError,Lfe=MA.YAMLWarning,Bfe=kfe.Alias,jfe=Xo.isAlias,qfe=Xo.isCollection,Ufe=Xo.isDocument,Wi=Xo.isMap,Gi=Xo.isNode,Mfe=Xo.isPair,wl=Xo.isScalar,FA=Xo.isSeq,Ffe=Efe.Pair,Zfe=Ife.Scalar,Hfe=Afe.YAMLMap,Kfe=Tfe.YAMLSeq,Jfe=Cfe.Lexer,Vfe=$fe.LineCounter,Wfe=Ofe.Parser,Gfe=Cy.parse,Qfe=Cy.parseAllDocuments,gi=Cy.parseDocument,Yfe=Cy.stringify,Xfe=nU.visit,epe=nU.visitAsync});function aU(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:[...npe]};return{bundles:["core","media","automation","web","chat","site","publishing","federation"],add:["obsidian-vault"]}}function ipe(e){let t=tpe.parse(e);return da.parse({brainVersion:t.brainVersion,bundleContract:ua,...aU(t.preset),githubOrg:t.githubOrg,contentRepoPrefix:t.contentRepoPrefix,domainSuffix:t.domainSuffix,aiApiKey:t.aiApiKey,gitSyncToken:t.gitSyncToken,contentRepoAdminToken:t.contentRepoAdminToken,agePublicKey:t.agePublicKey})}function ope(e){let t=rpe.parse(e),r=t.presetOverride?aU(t.presetOverride):void 0;return Un.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 cU(e){let t=gi(e,{keepSourceTokens:!0});if(t.errors.length>0)throw Error(`Invalid desired-state YAML: ${t.errors[0]?.message}`);if(!Wi(t.contents))throw Error("Desired-state YAML must contain a mapping");return t}function ZA(e,t){if(!Wi(e.contents))return;return e.contents.items.find((r)=>wl(r.key)&&r.key.value===t)}function iU(e,t){if(!Gi(e)||!Gi(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 oU(e,t){if(!e||!Gi(t))return;let r=[Gi(e.key)?e.key.commentBefore:void 0,Gi(e.key)?e.key.comment:void 0,Gi(e.value)?e.value.commentBefore:void 0,Gi(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(`
356
- `)}function lU(e,t,r,i){if(!Wi(e.contents))throw Error("Desired-state YAML must contain a mapping");let n=e.contents.items.findIndex((s)=>wl(s.key)&&s.key.value===t),o=e.createPair(r,[...i]);if(n>=0){let s=e.contents.items[n];iU(s?.key,o.key),iU(s?.value,o.value),e.contents.items.splice(n,1,o)}else e.contents.add(o);return o}function uU(e){let t=cU(e),r=ipe(t.toJS()),i=ZA(t,"schemaVersion"),n=ZA(t,"model");oU(i,ZA(t,"brainVersion")?.key),t.delete("schemaVersion"),t.set("bundleContract",ua);let o=lU(t,"preset","bundles",r.bundles);if(oU(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 da.parse(t.toJS()),t.toString({lineWidth:0})}function dU(e){let t=cU(e),r=ope(t.toJS());if(r.bundlesOverride)lU(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 Un.parse(t.toJS()),t.toString({lineWidth:0})}var sU,zf,tpe,rpe,npe;var fU=x(()=>{Hi();Re();Pf();fa();sU=f.enum(["core","default","pro"]),zf=f.string().min(1),tpe=f.strictObject({schemaVersion:f.literal(1),brainVersion:cn,model:f.literal("rover"),githubOrg:f.string().min(1),contentRepoPrefix:f.string().min(1),domainSuffix:f.string().min(1),preset:sU,aiApiKey:zf,gitSyncToken:zf,contentRepoAdminToken:zf,agePublicKey:f.string().startsWith("age1").min(1)}),rpe=f.strictObject({members:f.array(Dr).min(1),brainVersionOverride:cn.optional(),presetOverride:sU.optional(),aiApiKeyOverride:zf.optional(),gitSyncTokenOverride:zf.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"})}),npe=["series","portfolio","content-pipeline","social-media","newsletter","stock-photo"]});function mU(e,t){let r=gi(e,{keepSourceTokens:!0});if(r.errors.length>0||!Wi(r.contents))throw Error(`Invalid ${t} YAML`);return r}function upe(e,t){return e.length===t.length&&e.every((r,i)=>r===t[i])}function hU(e,t,r){if(!upe(t,r.sourceBundles))throw Error(`${e} source bundles changed after review: expected [${r.sourceBundles.join(", ")}], received [${t.join(", ")}]`)}function gU(e){let t=qn(e,lpe);if(!t.ok)throw Error(`Invalid capability bundle review: ${t.error}`);return t.data}function yU(e,t){let r=mU(e,"pilot desired-state"),i=ape.parse(r.toJS());return hU("pilot.yaml",i.bundles,t),r.set("bundleContract",ua),r.set("bundles",t.targetBundles),da.parse(r.toJS()),r.toString({lineWidth:0})}function bU(e,t,r){let i=mU(e,`cohort ${t}`),n=cpe.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`);hU(`cohort ${t}`,n.bundlesOverride,r),i.set("bundlesOverride",r.targetBundles)}return Un.parse(i.toJS()),i.toString({lineWidth:0})}var spe,HA,$y,ape,cpe,pU,lpe;var xU=x(()=>{Hi();Re();Pf();fa();spe=f.enum(["core","site","publishing","team"]),HA=f.array(spe).min(1),$y=f.array(f.string().min(1)),ape=f.strictObject({brainVersion:cn,bundles:HA,add:$y.optional(),remove:$y.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)}),cpe=f.strictObject({members:f.array(Dr).min(1),brainVersionOverride:cn.optional(),bundlesOverride:HA.optional(),addOverride:$y.optional(),removeOverride:$y.optional(),aiApiKeyOverride:f.string().min(1).optional(),gitSyncTokenOverride:f.string().min(1).optional()}),pU=f.strictObject({sourceBundles:HA,targetBundles:f.array(gI).min(1)}),lpe=f.strictObject({bundleContract:f.literal(ua),pilot:pU,cohorts:f.record(Dr,pU)})});var kU={};tr(kU,{loadCapabilityBundleReview:()=>xpe,loadReviewedSitePins:()=>bpe,parseReviewedSitePins:()=>_U,stageLegacyCrossover:()=>wpe});import{access as dpe,cp as fpe,mkdir as SU,readFile as _l,readdir as vU,writeFile as vl}from"fs/promises";import{basename as ppe,join as yi,relative as Oy,resolve as wU}from"path";import{fileURLToPath as mpe}from"url";function _U(e){let t=qn(e,hpe);if(!t.ok)throw Error(`Invalid reviewed site pins: ${t.error}`);return t.data.sites}async function bpe(e){return _U(await _l(e,"utf8"))}async function xpe(e){return gU(await _l(e,"utf8"))}async function Spe(e,t){let r=yi(e,"users"),i=(await vU(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=yi(r,s),c=await _l(a,"utf8"),l=gi(c,{keepSourceTokens:!0});if(l.errors.length>0||!Wi(l.contents))throw Error(`Invalid user desired-state YAML: ${s}`);let u=gpe.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"]);Pg.parse(l.toJS());let p=l.toString({lineWidth:0});if(p!==c)await vl(a,p),o.push(Oy(e,a))}if(n.size>0)throw Error(`Reviewed site pins do not match site users: ${[...n].sort().join(", ")}`);return o}async function wpe(e,t,r={}){let i=wU(e),n=wU(t);if(i===n||n.startsWith(`${i}/`))throw Error("Crossover output must be outside the source repository");await fpe(i,n,{recursive:!0,errorOnExist:!0,force:!1,filter:(T)=>{let z=ppe(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=yi(n,"docs","canonical-crossover-record.md");try{await dpe(s)}catch{await SU(yi(n,"docs"),{recursive:!0}),await vl(s,await _l(ype,"utf8")),o.push("docs/canonical-crossover-record.md")}let a=yi(n,"pilot.yaml"),c=await _l(a,"utf8"),u=gi(c).toJS();if(!Jj(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=yU(c,p.pilot)}else m=uU(c);await vl(a,m),o.push("pilot.yaml");let y=yi(n,"cohorts"),g=(await vU(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=yi(y,T),j=await _l(z,"utf8"),E=T.replace(/\.ya?ml$/,""),Z=p?.cohorts[E];if(Z)b.delete(E);await vl(z,d?bU(j,E,Z):dU(j)),o.push(Oy(n,z))}if(d&&b.size>0)throw Error(`Capability bundle review names unknown cohorts: ${[...b].sort().join(", ")}`);o.push(...await Spe(n,r.sitePins));let v=await Zt(n),A=Ng(v.pilot.githubOrg);for(let T of v.users){let z=await A(T),j=yi(n,"users",T.handle);if(await SU(j,{recursive:!0}),z.brainYaml){let E=yi(j,"brain.yaml");await vl(E,z.brainYaml),o.push(Oy(n,E))}if(z.envFile){let E=yi(j,".env");await vl(E,z.envFile),o.push(Oy(n,E))}}return await Zo(n,{registry:v}),o.push("views/users.md"),{outputDir:n,changedFiles:[...new Set(o)].sort()}}var hpe,gpe,ype;var EU=x(()=>{Hi();Vj();Re();Pf();EI();fU();xU();pi();af();fa();hpe=f.strictObject({sites:f.record(Dr,yI)}),gpe=f.object({handle:Dr,siteOverride:f.object({package:f.string().min(1),version:cn.optional(),theme:f.string().min(1).optional(),themeVersion:cn.optional()}).optional()}).passthrough(),ype=mpe(new URL("../templates/rover-pilot/docs/canonical-crossover-record.md",import.meta.url))});var AU,vpe,_pe,kpe,Epe,KA,Ipe,IU,Ape,Tpe,TU,aNe,CU;var JA=x(()=>{Z1();AU=["primary","secondary"],vpe=f.custom((e)=>typeof e==="function","Expected a React component"),_pe=f.strictObject({show:f.boolean().optional(),label:f.string().min(1).optional(),slot:f.enum(AU).optional(),priority:f.number().optional()}),kpe=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()}),Epe=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(kpe).optional(),layout:f.string().min(1).optional(),fullscreen:f.boolean().optional(),pluginId:f.string().optional(),sourceEntityType:f.string().optional(),external:f.boolean().optional(),navigation:_pe.optional()}),KA=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(AU).optional(),priority:f.number().optional()}).optional()}),Ipe=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()}),IU=f.strictObject({namespace:f.string().min(1),sections:f.record(f.string(),Ipe)}),Ape=f.record(f.string(),f.json()),Tpe=f.record(f.string(),f.record(f.string(),Ape)),TU={layouts:f.record(f.string(),vpe).refine((e)=>typeof e.default==="function",{message:'Site layouts must include a "default" component'}),routes:f.array(Epe),content:Tpe.optional(),sections:f.union([IU,f.array(IU)]).optional(),themeOverride:f.string().optional(),headScripts:f.array(f.string()).optional(),entityDisplay:f.record(f.string(),KA),staticAssets:f.record(f.string(),f.string()).optional()},aNe=f.strictObject(TU).partial(),CU=f.strictObject(TU).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 $U,OU,RU,PU,Cpe,$pe,Ope,Rpe,Ry;var VA=x(()=>{Re();JA();$U=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()}),OU=["primary","secondary"],RU=f.object({show:f.boolean().default(!1),label:f.string().optional(),slot:f.enum(OU).default("primary"),priority:f.number().min(0).max(100).default(50)}).optional(),PU=f.object({id:f.string(),path:f.string(),title:f.string().default(""),pageLabel:f.string().optional(),description:f.string().default(""),sections:f.array($U).default([]),layout:f.string().default("default"),fullscreen:f.boolean().optional(),pluginId:f.string().optional(),sourceEntityType:f.string().optional(),external:f.boolean().optional(),navigation:RU}),Cpe=f.object({routes:f.array(PU),pluginId:f.string()}),$pe=f.object({paths:f.array(f.string()).optional(),pluginId:f.string().optional()}),Ope=f.object({pluginId:f.string().optional()}),Rpe=f.object({path:f.string()}),Ry=f.object({label:f.string(),href:f.string(),priority:f.number()})});var WA,zU,Py,Ppe,zpe;var GA=x(()=>{Re();VA();WA=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")}),zU=f.object({blurb:f.string().optional().describe("Short italic subtitle under the section title")}),Py=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:WA.optional().describe("Call-to-action configuration"),sections:f.record(f.string(),zU).optional().describe("Optional per-section blurbs, keyed by section id (e.g. 'essays', 'presentations', 'about'). Used by homepage templates that render editorial section headers.")}),Ppe=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")}),zpe=Py.extend({copyright:f.string(),navigation:f.object({primary:f.array(Ry),secondary:f.array(Ry)}),socialLinks:f.array(Ppe).optional().describe("Social media links from profile metadata")})});var gNe;var QA=x(()=>{Re();gNe=f.record(f.string(),f.unknown())});var Nf=x(()=>{QA()});var _Ne;var NU=x(()=>{Nf();Re();_Ne=f.object({message:f.string()})});var YA,DU;var XA=x(()=>{Re();YA=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()}),DU=YA.omit({introduction:!0})});var Df=ee(function(ANe,BU){var Dpe=Object.prototype.toString;BU.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 Upe(t)?"generatorfunction":"function";if(Lpe(t))return"array";if(Zpe(t))return"buffer";if(Fpe(t))return"arguments";if(jpe(t))return"date";if(Bpe(t))return"error";if(qpe(t))return"regexp";switch(LU(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(Mpe(t))return"generator";switch(r=Dpe.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 LU(e){return typeof e.constructor==="function"?e.constructor.name:null}function Lpe(e){if(Array.isArray)return Array.isArray(e);return e instanceof Array}function Bpe(e){return e instanceof Error||typeof e.message==="string"&&e.constructor&&typeof e.constructor.stackTraceLimit==="number"}function jpe(e){if(e instanceof Date)return!0;return typeof e.toDateString==="function"&&typeof e.getDate==="function"&&typeof e.setDate==="function"}function qpe(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 Upe(e,t){return LU(e)==="GeneratorFunction"}function Mpe(e){return typeof e.throw==="function"&&typeof e.return==="function"&&typeof e.next==="function"}function Fpe(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 Zpe(e){if(e.constructor&&typeof e.constructor.isBuffer==="function")return e.constructor.isBuffer(e);return!1}});var qU=ee(function(TNe,jU){/*!
354
+ `,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=Ay(e),r=Sl(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=Ay(e),r=Sl(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()}}}sfe.Parser=Qq});var rU=ee(function(hfe){var Yq=$A(),cfe=If(),Rf=Af(),lfe=qI(),ufe=Ge(),dfe=qA(),Xq=UA();function eU(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new dfe.LineCounter||null,prettyErrors:t}}function ffe(e,t={}){let{lineCounter:r,prettyErrors:i}=eU(t),n=new Xq.Parser(r?.addNewLine),o=new Yq.Composer(t),s=Array.from(o.compose(n.parse(e)));if(i&&r)for(let a of s)a.errors.forEach(Rf.prettifyError(e,r)),a.warnings.forEach(Rf.prettifyError(e,r));if(s.length>0)return s;return Object.assign([],{empty:!0},o.streamInfo())}function tU(e,t={}){let{lineCounter:r,prettyErrors:i}=eU(t),n=new Xq.Parser(r?.addNewLine),o=new Yq.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 Rf.YAMLParseError(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}if(i&&r)s.errors.forEach(Rf.prettifyError(e,r)),s.warnings.forEach(Rf.prettifyError(e,r));return s}function pfe(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=tU(e,r);if(!n)return null;if(n.warnings.forEach((o)=>lfe.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 mfe(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(ufe.isDocument(e)&&!i)return e.toString(r);return new cfe.Document(e,i,r).toString(r)}hfe.parse=pfe;hfe.parseAllDocuments=ffe;hfe.parseDocument=tU;hfe.stringify=mfe});var Sfe,wfe,vfe,MA,_fe,Xo,kfe,Efe,Ife,Afe,z2e,Tfe,Cfe,$fe,Cy,nU,Ofe,Rfe,Pfe,zfe,Nfe,Dfe,Lfe,Bfe,jfe,qfe,Wi,Gi,Ufe,wl,FA,Mfe,Ffe,Zfe,Hfe,Kfe,Jfe,Vfe,Wfe,Gfe,gi,Qfe,Yfe,Xfe;var Pf=x(()=>{Sfe=$A(),wfe=If(),vfe=mA(),MA=Af(),_fe=ff(),Xo=Ge(),kfe=Vo(),Efe=Bt(),Ife=Go(),Afe=Qo(),z2e=Ey(),Tfe=jA(),Cfe=qA(),$fe=UA(),Cy=rU(),nU=uf();Ofe=Sfe.Composer,Rfe=wfe.Document,Pfe=vfe.Schema,zfe=MA.YAMLError,Nfe=MA.YAMLParseError,Dfe=MA.YAMLWarning,Lfe=_fe.Alias,Bfe=Xo.isAlias,jfe=Xo.isCollection,qfe=Xo.isDocument,Wi=Xo.isMap,Gi=Xo.isNode,Ufe=Xo.isPair,wl=Xo.isScalar,FA=Xo.isSeq,Mfe=kfe.Pair,Ffe=Efe.Scalar,Zfe=Ife.YAMLMap,Hfe=Afe.YAMLSeq,Kfe=Tfe.Lexer,Jfe=Cfe.LineCounter,Vfe=$fe.Parser,Wfe=Cy.parse,Gfe=Cy.parseAllDocuments,gi=Cy.parseDocument,Qfe=Cy.stringify,Yfe=nU.visit,Xfe=nU.visitAsync});function aU(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:[...rpe]};return{bundles:["core","media","automation","web","chat","site","publishing","federation"],add:["obsidian-vault"]}}function npe(e){let t=epe.parse(e);return da.parse({brainVersion:t.brainVersion,bundleContract:ua,...aU(t.preset),githubOrg:t.githubOrg,contentRepoPrefix:t.contentRepoPrefix,domainSuffix:t.domainSuffix,aiApiKey:t.aiApiKey,gitSyncToken:t.gitSyncToken,contentRepoAdminToken:t.contentRepoAdminToken,agePublicKey:t.agePublicKey})}function ipe(e){let t=tpe.parse(e),r=t.presetOverride?aU(t.presetOverride):void 0;return Un.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 cU(e){let t=gi(e,{keepSourceTokens:!0});if(t.errors.length>0)throw Error(`Invalid desired-state YAML: ${t.errors[0]?.message}`);if(!Wi(t.contents))throw Error("Desired-state YAML must contain a mapping");return t}function ZA(e,t){if(!Wi(e.contents))return;return e.contents.items.find((r)=>wl(r.key)&&r.key.value===t)}function iU(e,t){if(!Gi(e)||!Gi(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 oU(e,t){if(!e||!Gi(t))return;let r=[Gi(e.key)?e.key.commentBefore:void 0,Gi(e.key)?e.key.comment:void 0,Gi(e.value)?e.value.commentBefore:void 0,Gi(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(`
355
+ `)}function lU(e,t,r,i){if(!Wi(e.contents))throw Error("Desired-state YAML must contain a mapping");let n=e.contents.items.findIndex((s)=>wl(s.key)&&s.key.value===t),o=e.createPair(r,[...i]);if(n>=0){let s=e.contents.items[n];iU(s?.key,o.key),iU(s?.value,o.value),e.contents.items.splice(n,1,o)}else e.contents.add(o);return o}function uU(e){let t=cU(e),r=npe(t.toJS()),i=ZA(t,"schemaVersion"),n=ZA(t,"model");oU(i,ZA(t,"brainVersion")?.key),t.delete("schemaVersion"),t.set("bundleContract",ua);let o=lU(t,"preset","bundles",r.bundles);if(oU(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 da.parse(t.toJS()),t.toString({lineWidth:0})}function dU(e){let t=cU(e),r=ipe(t.toJS());if(r.bundlesOverride)lU(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 Un.parse(t.toJS()),t.toString({lineWidth:0})}var sU,zf,epe,tpe,rpe;var fU=x(()=>{Hi();Re();Pf();fa();sU=f.enum(["core","default","pro"]),zf=f.string().min(1),epe=f.strictObject({schemaVersion:f.literal(1),brainVersion:cn,model:f.literal("rover"),githubOrg:f.string().min(1),contentRepoPrefix:f.string().min(1),domainSuffix:f.string().min(1),preset:sU,aiApiKey:zf,gitSyncToken:zf,contentRepoAdminToken:zf,agePublicKey:f.string().startsWith("age1").min(1)}),tpe=f.strictObject({members:f.array(Dr).min(1),brainVersionOverride:cn.optional(),presetOverride:sU.optional(),aiApiKeyOverride:zf.optional(),gitSyncTokenOverride:zf.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"})}),rpe=["series","portfolio","content-pipeline","social-media","newsletter","stock-photo"]});function mU(e,t){let r=gi(e,{keepSourceTokens:!0});if(r.errors.length>0||!Wi(r.contents))throw Error(`Invalid ${t} YAML`);return r}function lpe(e,t){return e.length===t.length&&e.every((r,i)=>r===t[i])}function hU(e,t,r){if(!lpe(t,r.sourceBundles))throw Error(`${e} source bundles changed after review: expected [${r.sourceBundles.join(", ")}], received [${t.join(", ")}]`)}function gU(e){let t=qn(e,cpe);if(!t.ok)throw Error(`Invalid capability bundle review: ${t.error}`);return t.data}function yU(e,t){let r=mU(e,"pilot desired-state"),i=spe.parse(r.toJS());return hU("pilot.yaml",i.bundles,t),r.set("bundleContract",ua),r.set("bundles",t.targetBundles),da.parse(r.toJS()),r.toString({lineWidth:0})}function bU(e,t,r){let i=mU(e,`cohort ${t}`),n=ape.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`);hU(`cohort ${t}`,n.bundlesOverride,r),i.set("bundlesOverride",r.targetBundles)}return Un.parse(i.toJS()),i.toString({lineWidth:0})}var ope,HA,$y,spe,ape,pU,cpe;var xU=x(()=>{Hi();Re();Pf();fa();ope=f.enum(["core","site","publishing","team"]),HA=f.array(ope).min(1),$y=f.array(f.string().min(1)),spe=f.strictObject({brainVersion:cn,bundles:HA,add:$y.optional(),remove:$y.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)}),ape=f.strictObject({members:f.array(Dr).min(1),brainVersionOverride:cn.optional(),bundlesOverride:HA.optional(),addOverride:$y.optional(),removeOverride:$y.optional(),aiApiKeyOverride:f.string().min(1).optional(),gitSyncTokenOverride:f.string().min(1).optional()}),pU=f.strictObject({sourceBundles:HA,targetBundles:f.array(gI).min(1)}),cpe=f.strictObject({bundleContract:f.literal(ua),pilot:pU,cohorts:f.record(Dr,pU)})});var kU={};tr(kU,{loadCapabilityBundleReview:()=>bpe,loadReviewedSitePins:()=>ype,parseReviewedSitePins:()=>_U,stageLegacyCrossover:()=>Spe});import{access as upe,cp as dpe,mkdir as SU,readFile as _l,readdir as vU,writeFile as vl}from"fs/promises";import{basename as fpe,join as yi,relative as Oy,resolve as wU}from"path";import{fileURLToPath as ppe}from"url";function _U(e){let t=qn(e,mpe);if(!t.ok)throw Error(`Invalid reviewed site pins: ${t.error}`);return t.data.sites}async function ype(e){return _U(await _l(e,"utf8"))}async function bpe(e){return gU(await _l(e,"utf8"))}async function xpe(e,t){let r=yi(e,"users"),i=(await vU(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=yi(r,s),c=await _l(a,"utf8"),l=gi(c,{keepSourceTokens:!0});if(l.errors.length>0||!Wi(l.contents))throw Error(`Invalid user desired-state YAML: ${s}`);let u=hpe.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"]);Pg.parse(l.toJS());let p=l.toString({lineWidth:0});if(p!==c)await vl(a,p),o.push(Oy(e,a))}if(n.size>0)throw Error(`Reviewed site pins do not match site users: ${[...n].sort().join(", ")}`);return o}async function Spe(e,t,r={}){let i=wU(e),n=wU(t);if(i===n||n.startsWith(`${i}/`))throw Error("Crossover output must be outside the source repository");await dpe(i,n,{recursive:!0,errorOnExist:!0,force:!1,filter:(T)=>{let z=fpe(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=yi(n,"docs","canonical-crossover-record.md");try{await upe(s)}catch{await SU(yi(n,"docs"),{recursive:!0}),await vl(s,await _l(gpe,"utf8")),o.push("docs/canonical-crossover-record.md")}let a=yi(n,"pilot.yaml"),c=await _l(a,"utf8"),u=gi(c).toJS();if(!J6(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=yU(c,p.pilot)}else m=uU(c);await vl(a,m),o.push("pilot.yaml");let y=yi(n,"cohorts"),g=(await vU(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=yi(y,T),j=await _l(z,"utf8"),E=T.replace(/\.ya?ml$/,""),Z=p?.cohorts[E];if(Z)b.delete(E);await vl(z,d?bU(j,E,Z):dU(j)),o.push(Oy(n,z))}if(d&&b.size>0)throw Error(`Capability bundle review names unknown cohorts: ${[...b].sort().join(", ")}`);o.push(...await xpe(n,r.sitePins));let v=await Zt(n),A=Ng(v.pilot.githubOrg);for(let T of v.users){let z=await A(T),j=yi(n,"users",T.handle);if(await SU(j,{recursive:!0}),z.brainYaml){let E=yi(j,"brain.yaml");await vl(E,z.brainYaml),o.push(Oy(n,E))}if(z.envFile){let E=yi(j,".env");await vl(E,z.envFile),o.push(Oy(n,E))}}return await Zo(n,{registry:v}),o.push("views/users.md"),{outputDir:n,changedFiles:[...new Set(o)].sort()}}var mpe,hpe,gpe;var EU=x(()=>{Hi();V6();Re();Pf();EI();fU();xU();pi();af();fa();mpe=f.strictObject({sites:f.record(Dr,yI)}),hpe=f.object({handle:Dr,siteOverride:f.object({package:f.string().min(1),version:cn.optional(),theme:f.string().min(1).optional(),themeVersion:cn.optional()}).optional()}).passthrough(),gpe=ppe(new URL("../templates/rover-pilot/docs/canonical-crossover-record.md",import.meta.url))});var AU,wpe,vpe,_pe,kpe,KA,Epe,IU,Ipe,Ape,TU,sNe,CU;var JA=x(()=>{Z1();AU=["primary","secondary"],wpe=f.custom((e)=>typeof e==="function","Expected a React component"),vpe=f.strictObject({show:f.boolean().optional(),label:f.string().min(1).optional(),slot:f.enum(AU).optional(),priority:f.number().optional()}),_pe=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()}),kpe=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(_pe).optional(),layout:f.string().min(1).optional(),fullscreen:f.boolean().optional(),pluginId:f.string().optional(),sourceEntityType:f.string().optional(),external:f.boolean().optional(),navigation:vpe.optional()}),KA=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(AU).optional(),priority:f.number().optional()}).optional()}),Epe=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()}),IU=f.strictObject({namespace:f.string().min(1),sections:f.record(f.string(),Epe)}),Ipe=f.record(f.string(),f.json()),Ape=f.record(f.string(),f.record(f.string(),Ipe)),TU={layouts:f.record(f.string(),wpe).refine((e)=>typeof e.default==="function",{message:'Site layouts must include a "default" component'}),routes:f.array(kpe),content:Ape.optional(),sections:f.union([IU,f.array(IU)]).optional(),themeOverride:f.string().optional(),headScripts:f.array(f.string()).optional(),entityDisplay:f.record(f.string(),KA),staticAssets:f.record(f.string(),f.string()).optional()},sNe=f.strictObject(TU).partial(),CU=f.strictObject(TU).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 $U,OU,RU,PU,Tpe,Cpe,$pe,Ope,Ry;var VA=x(()=>{Re();JA();$U=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()}),OU=["primary","secondary"],RU=f.object({show:f.boolean().default(!1),label:f.string().optional(),slot:f.enum(OU).default("primary"),priority:f.number().min(0).max(100).default(50)}).optional(),PU=f.object({id:f.string(),path:f.string(),title:f.string().default(""),pageLabel:f.string().optional(),description:f.string().default(""),sections:f.array($U).default([]),layout:f.string().default("default"),fullscreen:f.boolean().optional(),pluginId:f.string().optional(),sourceEntityType:f.string().optional(),external:f.boolean().optional(),navigation:RU}),Tpe=f.object({routes:f.array(PU),pluginId:f.string()}),Cpe=f.object({paths:f.array(f.string()).optional(),pluginId:f.string().optional()}),$pe=f.object({pluginId:f.string().optional()}),Ope=f.object({path:f.string()}),Ry=f.object({label:f.string(),href:f.string(),priority:f.number()})});var WA,zU,Py,Rpe,Ppe;var GA=x(()=>{Re();VA();WA=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")}),zU=f.object({blurb:f.string().optional().describe("Short italic subtitle under the section title")}),Py=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:WA.optional().describe("Call-to-action configuration"),sections:f.record(f.string(),zU).optional().describe("Optional per-section blurbs, keyed by section id (e.g. 'essays', 'presentations', 'about'). Used by homepage templates that render editorial section headers.")}),Rpe=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")}),Ppe=Py.extend({copyright:f.string(),navigation:f.object({primary:f.array(Ry),secondary:f.array(Ry)}),socialLinks:f.array(Rpe).optional().describe("Social media links from profile metadata")})});var hNe;var QA=x(()=>{Re();hNe=f.record(f.string(),f.unknown())});var Nf=x(()=>{QA()});var vNe;var NU=x(()=>{Nf();Re();vNe=f.object({message:f.string()})});var YA,DU;var XA=x(()=>{Re();YA=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()}),DU=YA.omit({introduction:!0})});var Df=ee(function(INe,BU){var Npe=Object.prototype.toString;BU.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 qpe(t)?"generatorfunction":"function";if(Dpe(t))return"array";if(Fpe(t))return"buffer";if(Mpe(t))return"arguments";if(Bpe(t))return"date";if(Lpe(t))return"error";if(jpe(t))return"regexp";switch(LU(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(Upe(t))return"generator";switch(r=Npe.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 LU(e){return typeof e.constructor==="function"?e.constructor.name:null}function Dpe(e){if(Array.isArray)return Array.isArray(e);return e instanceof Array}function Lpe(e){return e instanceof Error||typeof e.message==="string"&&e.constructor&&typeof e.constructor.stackTraceLimit==="number"}function Bpe(e){if(e instanceof Date)return!0;return typeof e.toDateString==="function"&&typeof e.getDate==="function"&&typeof e.setDate==="function"}function jpe(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 qpe(e,t){return LU(e)==="GeneratorFunction"}function Upe(e){return typeof e.throw==="function"&&typeof e.return==="function"&&typeof e.next==="function"}function Mpe(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 Fpe(e){if(e.constructor&&typeof e.constructor.isBuffer==="function")return e.constructor.isBuffer(e);return!1}});var qU=ee(function(ANe,jU){/*!
357
356
  * is-extendable <https://github.com/jonschlinkert/is-extendable>
358
357
  *
359
358
  * Copyright (c) 2015, Jon Schlinkert.
360
359
  * Licensed under the MIT License.
361
- */jU.exports=function(t){return typeof t<"u"&&t!==null&&(typeof t==="object"||typeof t==="function")}});var FU=ee(function(CNe,MU){var UU=qU();MU.exports=function(t){if(!UU(t))t={};var r=arguments.length;for(var i=1;i<r;i++){var n=arguments[i];if(UU(n))Hpe(t,n)}return t};function Hpe(e,t){for(var r in t)if(Kpe(t,r))e[r]=t[r]}function Kpe(e,t){return Object.prototype.hasOwnProperty.call(e,t)}});var KU=ee(function($Ne,HU){var Jpe=Df(),Vpe=FU();HU.exports=function(e,t){if(typeof t==="function")t={parse:t};var r=Gpe(e),i={section_delimiter:"---",parse:Ype},n=Vpe({},i,t),o=n.section_delimiter,s=r.content.split(/\r?\n/),a=null,c=ZU(),l=[],u=[];function d(v){r.content=v,a=[],l=[]}function p(v){if(u.length)c.key=Qpe(u[0],o),c.content=v,n.parse(c,a),a.push(c),c=ZU(),l=[],u=[]}for(var m=0;m<s.length;m++){var y=s[m],g=u.length,b=y.trim();if(Wpe(b,o)){if(b.length===3&&m!==0){if(g===0||g===2){l.push(y);continue}u.push(b),c.data=l.join(`
360
+ */jU.exports=function(t){return typeof t<"u"&&t!==null&&(typeof t==="object"||typeof t==="function")}});var FU=ee(function(TNe,MU){var UU=qU();MU.exports=function(t){if(!UU(t))t={};var r=arguments.length;for(var i=1;i<r;i++){var n=arguments[i];if(UU(n))Zpe(t,n)}return t};function Zpe(e,t){for(var r in t)if(Hpe(t,r))e[r]=t[r]}function Hpe(e,t){return Object.prototype.hasOwnProperty.call(e,t)}});var KU=ee(function(CNe,HU){var Kpe=Df(),Jpe=FU();HU.exports=function(e,t){if(typeof t==="function")t={parse:t};var r=Wpe(e),i={section_delimiter:"---",parse:Qpe},n=Jpe({},i,t),o=n.section_delimiter,s=r.content.split(/\r?\n/),a=null,c=ZU(),l=[],u=[];function d(v){r.content=v,a=[],l=[]}function p(v){if(u.length)c.key=Gpe(u[0],o),c.content=v,n.parse(c,a),a.push(c),c=ZU(),l=[],u=[]}for(var m=0;m<s.length;m++){var y=s[m],g=u.length,b=y.trim();if(Vpe(b,o)){if(b.length===3&&m!==0){if(g===0||g===2){l.push(y);continue}u.push(b),c.data=l.join(`
362
361
  `),l=[];continue}if(a===null)d(l.join(`
363
362
  `));if(g===2)p(l.join(`
364
363
  `));u.push(b);continue}l.push(y)}if(a===null)d(l.join(`
365
364
  `));else p(l.join(`
366
- `));return r.sections=a,r};function Wpe(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 Gpe(e){if(Jpe(e)!=="object")e={content:e};if(typeof e.content!=="string"&&!Xpe(e.content))throw TypeError("expected a buffer or string");return e.content=e.content.toString(),e.sections=[],e}function Qpe(e,t){return e?e.slice(t.length).trim():""}function ZU(){return{key:"",data:"",content:""}}function Ype(e){return e}function Xpe(e){if(e&&e.constructor&&typeof e.constructor.isBuffer==="function")return e.constructor.isBuffer(e);return!1}});var va=ee(function(ome,wa){function JU(e){return typeof e>"u"||e===null}function eme(e){return typeof e==="object"&&e!==null}function tme(e){if(Array.isArray(e))return e;else if(JU(e))return[];return[e]}function rme(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 nme(e,t){var r="",i;for(i=0;i<t;i+=1)r+=e;return r}function ime(e){return e===0&&Number.NEGATIVE_INFINITY===1/e}ome.isNothing=JU;ome.isObject=eme;ome.toArray=tme;ome.repeat=nme;ome.isNegativeZero=ime;ome.extend=rme});var kl=ee(function(ONe,VU){function Lf(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||""}Lf.prototype=Object.create(Error.prototype);Lf.prototype.constructor=Lf;Lf.prototype.toString=function(t){var r=this.name+": ";if(r+=this.reason||"(unknown reason)",!t&&this.mark)r+=" "+this.mark.toString();return r};VU.exports=Lf});var QU=ee(function(RNe,GU){var WU=va();function eT(e,t,r,i,n){this.name=e,this.buffer=t,this.position=r,this.line=i,this.column=n}eT.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
365
+ `));return r.sections=a,r};function Vpe(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 Wpe(e){if(Kpe(e)!=="object")e={content:e};if(typeof e.content!=="string"&&!Ype(e.content))throw TypeError("expected a buffer or string");return e.content=e.content.toString(),e.sections=[],e}function Gpe(e,t){return e?e.slice(t.length).trim():""}function ZU(){return{key:"",data:"",content:""}}function Qpe(e){return e}function Ype(e){if(e&&e.constructor&&typeof e.constructor.isBuffer==="function")return e.constructor.isBuffer(e);return!1}});var va=ee(function(ime,wa){function JU(e){return typeof e>"u"||e===null}function Xpe(e){return typeof e==="object"&&e!==null}function eme(e){if(Array.isArray(e))return e;else if(JU(e))return[];return[e]}function tme(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 rme(e,t){var r="",i;for(i=0;i<t;i+=1)r+=e;return r}function nme(e){return e===0&&Number.NEGATIVE_INFINITY===1/e}ime.isNothing=JU;ime.isObject=Xpe;ime.toArray=eme;ime.repeat=rme;ime.isNegativeZero=nme;ime.extend=tme});var kl=ee(function($Ne,VU){function Lf(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||""}Lf.prototype=Object.create(Error.prototype);Lf.prototype.constructor=Lf;Lf.prototype.toString=function(t){var r=this.name+": ";if(r+=this.reason||"(unknown reason)",!t&&this.mark)r+=" "+this.mark.toString();return r};VU.exports=Lf});var QU=ee(function(ONe,GU){var WU=va();function eT(e,t,r,i,n){this.name=e,this.buffer=t,this.position=r,this.line=i,this.column=n}eT.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
367
366
  \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
368
367
  \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),WU.repeat(" ",t)+i+a+o+`
369
368
  `+WU.repeat(" ",t+this.position-n+i.length)+"^"};eT.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+=`:
370
- `+r}return i};GU.exports=eT});var Kt=ee(function(PNe,XU){var YU=kl(),fme=["kind","resolve","construct","instanceOf","predicate","represent","defaultStyle","styleAliases"],pme=["scalar","sequence","mapping"];function mme(e){var t={};if(e!==null)Object.keys(e).forEach(function(r){e[r].forEach(function(i){t[String(i)]=r})});return t}function hme(e,t){if(t=t||{},Object.keys(t).forEach(function(r){if(fme.indexOf(r)===-1)throw new YU('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=mme(t.styleAliases||null),pme.indexOf(this.kind)===-1)throw new YU('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')}XU.exports=hme});var _a=ee(function(zNe,t4){var e4=va(),Ny=kl(),gme=Kt();function tT(e,t,r){var i=[];return e.include.forEach(function(n){r=tT(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 yme(){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 El(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 Ny("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.")}),this.compiledImplicit=tT(this,"implicit",[]),this.compiledExplicit=tT(this,"explicit",[]),this.compiledTypeMap=yme(this.compiledImplicit,this.compiledExplicit)}El.DEFAULT=null;El.create=function(){var t,r;switch(arguments.length){case 1:t=El.DEFAULT,r=arguments[0];break;case 2:t=arguments[0],r=arguments[1];break;default:throw new Ny("Wrong number of arguments for Schema.create function")}if(t=e4.toArray(t),r=e4.toArray(r),!t.every(function(i){return i instanceof El}))throw new Ny("Specified list of super schemas (or a single Schema object) contains a non-Schema object.");if(!r.every(function(i){return i instanceof gme}))throw new Ny("Specified list of YAML types (or a single Type object) contains a non-Type object.");return new El({include:t,explicit:r})};t4.exports=El});var n4=ee(function(NNe,r4){var bme=Kt();r4.exports=new bme("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return e!==null?e:""}})});var o4=ee(function(DNe,i4){var xme=Kt();i4.exports=new xme("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return e!==null?e:[]}})});var a4=ee(function(LNe,s4){var Sme=Kt();s4.exports=new Sme("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return e!==null?e:{}}})});var Dy=ee(function(BNe,c4){var wme=_a();c4.exports=new wme({explicit:[n4(),o4(),a4()]})});var u4=ee(function(jNe,l4){var vme=Kt();function _me(e){if(e===null)return!0;var t=e.length;return t===1&&e==="~"||t===4&&(e==="null"||e==="Null"||e==="NULL")}function kme(){return null}function Eme(e){return e===null}l4.exports=new vme("tag:yaml.org,2002:null",{kind:"scalar",resolve:_me,construct:kme,predicate:Eme,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"}},defaultStyle:"lowercase"})});var f4=ee(function(qNe,d4){var Ime=Kt();function Ame(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 Tme(e){return e==="true"||e==="True"||e==="TRUE"}function Cme(e){return Object.prototype.toString.call(e)==="[object Boolean]"}d4.exports=new Ime("tag:yaml.org,2002:bool",{kind:"scalar",resolve:Ame,construct:Tme,predicate:Cme,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 m4=ee(function(UNe,p4){var $me=va(),Ome=Kt();function Rme(e){return 48<=e&&e<=57||65<=e&&e<=70||97<=e&&e<=102}function Pme(e){return 48<=e&&e<=55}function zme(e){return 48<=e&&e<=57}function Nme(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(!Rme(e.charCodeAt(r)))return!1;i=!0}return i&&n!=="_"}for(;r<t;r++){if(n=e[r],n==="_")continue;if(!Pme(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(!zme(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 Dme(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 Lme(e){return Object.prototype.toString.call(e)==="[object Number]"&&(e%1===0&&!$me.isNegativeZero(e))}p4.exports=new Ome("tag:yaml.org,2002:int",{kind:"scalar",resolve:Nme,construct:Dme,predicate:Lme,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 y4=ee(function(MNe,g4){var h4=va(),Bme=Kt(),jme=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 qme(e){if(e===null)return!1;if(!jme.test(e)||e[e.length-1]==="_")return!1;return!0}function Ume(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 Mme=/^[-+]?[0-9]+e/;function Fme(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(h4.isNegativeZero(e))return"-0.0";return r=e.toString(10),Mme.test(r)?r.replace("e",".e"):r}function Zme(e){return Object.prototype.toString.call(e)==="[object Number]"&&(e%1!==0||h4.isNegativeZero(e))}g4.exports=new Bme("tag:yaml.org,2002:float",{kind:"scalar",resolve:qme,construct:Ume,predicate:Zme,represent:Fme,defaultStyle:"lowercase"})});var rT=ee(function(FNe,b4){var Hme=_a();b4.exports=new Hme({include:[Dy()],implicit:[u4(),f4(),m4(),y4()]})});var nT=ee(function(ZNe,x4){var Kme=_a();x4.exports=new Kme({include:[rT()]})});var _4=ee(function(HNe,v4){var Jme=Kt(),S4=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),w4=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 Vme(e){if(e===null)return!1;if(S4.exec(e)!==null)return!0;if(w4.exec(e)!==null)return!0;return!1}function Wme(e){var t,r,i,n,o,s,a,c=0,l=null,u,d,p;if(t=S4.exec(e),t===null)t=w4.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 Gme(e){return e.toISOString()}v4.exports=new Jme("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:Vme,construct:Wme,instanceOf:Date,represent:Gme})});var E4=ee(function(KNe,k4){var Qme=Kt();function Yme(e){return e==="<<"||e===null}k4.exports=new Qme("tag:yaml.org,2002:merge",{kind:"scalar",resolve:Yme})});var A4=ee(function(JNe,I4){var ka;try{iT=Tt,ka=iT("buffer").Buffer}catch(e){}var iT,Xme=Kt(),oT=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
371
- \r`;function ehe(e){if(e===null)return!1;var t,r,i=0,n=e.length,o=oT;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 the(e){var t,r,i=e.replace(/[\r\n=]/g,""),n=i.length,o=oT,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(ka)return ka.from?ka.from(a):new ka(a);return a}function rhe(e){var t="",r=0,i,n,o=e.length,s=oT;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 nhe(e){return ka&&ka.isBuffer(e)}I4.exports=new Xme("tag:yaml.org,2002:binary",{kind:"scalar",resolve:ehe,construct:the,predicate:nhe,represent:rhe})});var C4=ee(function(WNe,T4){var ihe=Kt(),ohe=Object.prototype.hasOwnProperty,she=Object.prototype.toString;function ahe(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,she.call(n)!=="[object Object]")return!1;for(o in n)if(ohe.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 che(e){return e!==null?e:[]}T4.exports=new ihe("tag:yaml.org,2002:omap",{kind:"sequence",resolve:ahe,construct:che})});var O4=ee(function(GNe,$4){var lhe=Kt(),uhe=Object.prototype.toString;function dhe(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],uhe.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 fhe(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}$4.exports=new lhe("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:dhe,construct:fhe})});var P4=ee(function(QNe,R4){var phe=Kt(),mhe=Object.prototype.hasOwnProperty;function hhe(e){if(e===null)return!0;var t,r=e;for(t in r)if(mhe.call(r,t)){if(r[t]!==null)return!1}return!0}function ghe(e){return e!==null?e:{}}R4.exports=new phe("tag:yaml.org,2002:set",{kind:"mapping",resolve:hhe,construct:ghe})});var Il=ee(function(YNe,z4){var yhe=_a();z4.exports=new yhe({include:[nT()],implicit:[_4(),E4()],explicit:[A4(),C4(),O4(),P4()]})});var D4=ee(function(XNe,N4){var bhe=Kt();function xhe(){return!0}function She(){return}function whe(){return""}function vhe(e){return typeof e>"u"}N4.exports=new bhe("tag:yaml.org,2002:js/undefined",{kind:"scalar",resolve:xhe,construct:She,predicate:vhe,represent:whe})});var B4=ee(function(eDe,L4){var _he=Kt();function khe(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 Ehe(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 Ihe(e){var t="/"+e.source+"/";if(e.global)t+="g";if(e.multiline)t+="m";if(e.ignoreCase)t+="i";return t}function Ahe(e){return Object.prototype.toString.call(e)==="[object RegExp]"}L4.exports=new _he("tag:yaml.org,2002:js/regexp",{kind:"scalar",resolve:khe,construct:Ehe,predicate:Ahe,represent:Ihe})});var q4=ee(function(tDe,j4){var Ly;try{sT=Tt,Ly=sT("esprima")}catch(e){if(typeof window<"u")Ly=window.esprima}var sT,The=Kt();function Che(e){if(e===null)return!1;try{var t="("+e+")",r=Ly.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 $he(e){var t="("+e+")",r=Ly.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 Ohe(e){return e.toString()}function Rhe(e){return Object.prototype.toString.call(e)==="[object Function]"}j4.exports=new The("tag:yaml.org,2002:js/function",{kind:"scalar",resolve:Che,construct:$he,predicate:Rhe,represent:Ohe})});var Bf=ee(function(nDe,M4){var U4=_a();M4.exports=U4.DEFAULT=new U4({include:[Il()],explicit:[D4(),B4(),q4()]})});var cM=ee(function(rge,jf){var Qi=va(),W4=kl(),Phe=QU(),G4=Il(),zhe=Bf(),rs=Object.prototype.hasOwnProperty,By=1,Q4=2,Y4=3,jy=4,aT=1,Nhe=2,F4=3,Dhe=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,Lhe=/[\x85\u2028\u2029]/,Bhe=/[,\[\]\{\}]/,X4=/^(?:!|!!|![a-z\-]+!)$/i,eM=/^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;function Z4(e){return Object.prototype.toString.call(e)}function bi(e){return e===10||e===13}function Ea(e){return e===9||e===32}function Wr(e){return e===9||e===32||e===10||e===13}function Al(e){return e===44||e===91||e===93||e===123||e===125}function jhe(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 qhe(e){if(e===120)return 2;if(e===117)return 4;if(e===85)return 8;return 0}function Uhe(e){if(48<=e&&e<=57)return e-48;return-1}function H4(e){return e===48?"\x00":e===97?"\x07":e===98?"\b":e===116?"\t":e===9?"\t":e===110?`
372
- `: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 Mhe(e){if(e<=65535)return String.fromCharCode(e);return String.fromCharCode((e-65536>>10)+55296,(e-65536&1023)+56320)}function tM(e,t,r){if(t==="__proto__")Object.defineProperty(e,t,{configurable:!0,enumerable:!0,writable:!0,value:r});else e[t]=r}var rM=Array(256),nM=Array(256);for(es=0;es<256;es++)rM[es]=H4(es)?1:0,nM[es]=H4(es);var es;function Fhe(e,t){this.input=e,this.filename=t.filename||null,this.schema=t.schema||zhe,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 iM(e,t){return new W4(t,new Phe(e.filename,e.input,e.position,e.line,e.position-e.lineStart))}function Be(e,t){throw iM(e,t)}function qy(e,t){if(e.onWarning)e.onWarning.call(null,iM(e,t))}var K4={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)qy(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],!X4.test(n))Be(t,"ill-formed tag handle (first argument) of the TAG directive");if(rs.call(t.tagMap,n))Be(t,'there is a previously declared suffix for "'+n+'" tag handle');if(!eM.test(o))Be(t,"ill-formed tag prefix (second argument) of the TAG directive");t.tagMap[n]=o}};function ts(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(Dhe.test(a))Be(e,"the stream contains non-printable characters");e.result+=a}}function J4(e,t,r,i){var n,o,s,a;if(!Qi.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(!rs.call(t,o))tM(t,o,r[o]),i[o]=!0}}function Tl(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"&&Z4(n[c])==="[object Object]")n[c]="[object Object]"}}if(typeof n==="object"&&Z4(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)J4(e,t,o[c],r);else J4(e,t,o,r);else{if(!e.json&&!rs.call(r,n)&&rs.call(t,n))e.line=s||e.line,e.position=a||e.position,Be(e,"duplicated mapping key");tM(t,n,o),delete r[n]}return t}function cT(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 jt(e,t,r){var i=0,n=e.input.charCodeAt(e.position);while(n!==0){while(Ea(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(bi(n)){cT(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)qy(e,"deficient indentation");return i}function Uy(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||Wr(r))return!0}return!1}function lT(e,t){if(t===1)e.result+=" ";else if(t>1)e.result+=Qi.repeat(`
373
- `,t-1)}function Zhe(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),Wr(m)||Al(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),Wr(n)||r&&Al(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),Wr(n)||r&&Al(n))break}else if(m===35){if(i=e.input.charCodeAt(e.position-1),Wr(i))break}else if(e.position===e.lineStart&&Uy(e)||r&&Al(m))break;else if(bi(m))if(c=e.line,l=e.lineStart,u=e.lineIndent,jt(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)ts(e,o,s,!1),lT(e,e.line-c),o=s=e.position,a=!1;if(!Ea(m))s=e.position+1;m=e.input.charCodeAt(++e.position)}if(ts(e,o,s,!1),e.result)return!0;return e.kind=d,e.result=p,!1}function Hhe(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(ts(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(bi(r))ts(e,i,n,!0),lT(e,jt(e,!1,t)),i=n=e.position;else if(e.position===e.lineStart&&Uy(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 Khe(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 ts(e,r,e.position,!0),e.position++,!0;else if(a===92){if(ts(e,r,e.position,!0),a=e.input.charCodeAt(++e.position),bi(a))jt(e,!1,t);else if(a<256&&rM[a])e.result+=nM[a],e.position++;else if((s=qhe(a))>0){n=s,o=0;for(;n>0;n--)if(a=e.input.charCodeAt(++e.position),(s=jhe(a))>=0)o=(o<<4)+s;else Be(e,"expected hexadecimal character");e.result+=Mhe(o),e.position++}else Be(e,"unknown escape sequence");r=i=e.position}else if(bi(a))ts(e,r,i,!0),lT(e,jt(e,!1,t)),r=i=e.position;else if(e.position===e.lineStart&&Uy(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 Jhe(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(jt(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),Wr(a))l=u=!0,e.position++,jt(e,!0,t)}if(i=e.line,Cl(e,t,By,!1,!0),y=e.tag,m=e.result,jt(e,!0,t),b=e.input.charCodeAt(e.position),(u||e.line===i)&&b===58)l=!0,b=e.input.charCodeAt(++e.position),jt(e,!0,t),Cl(e,t,By,!1,!0),g=e.result;if(d)Tl(e,o,p,y,m,g);else if(l)o.push(Tl(e,null,p,y,m,g));else o.push(m);if(jt(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 Vhe(e,t){var r,i,n=aT,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(aT===n)n=d===43?F4:Nhe;else Be(e,"repeat of a chomping mode identifier");else if((u=Uhe(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(Ea(d)){do d=e.input.charCodeAt(++e.position);while(Ea(d));if(d===35)do d=e.input.charCodeAt(++e.position);while(!bi(d)&&d!==0)}while(d!==0){cT(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(bi(d)){c++;continue}if(e.lineIndent<a){if(n===F4)e.result+=Qi.repeat(`
369
+ `+r}return i};GU.exports=eT});var Kt=ee(function(RNe,XU){var YU=kl(),dme=["kind","resolve","construct","instanceOf","predicate","represent","defaultStyle","styleAliases"],fme=["scalar","sequence","mapping"];function pme(e){var t={};if(e!==null)Object.keys(e).forEach(function(r){e[r].forEach(function(i){t[String(i)]=r})});return t}function mme(e,t){if(t=t||{},Object.keys(t).forEach(function(r){if(dme.indexOf(r)===-1)throw new YU('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=pme(t.styleAliases||null),fme.indexOf(this.kind)===-1)throw new YU('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')}XU.exports=mme});var _a=ee(function(PNe,t4){var e4=va(),Ny=kl(),hme=Kt();function tT(e,t,r){var i=[];return e.include.forEach(function(n){r=tT(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 gme(){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 El(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 Ny("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.")}),this.compiledImplicit=tT(this,"implicit",[]),this.compiledExplicit=tT(this,"explicit",[]),this.compiledTypeMap=gme(this.compiledImplicit,this.compiledExplicit)}El.DEFAULT=null;El.create=function(){var t,r;switch(arguments.length){case 1:t=El.DEFAULT,r=arguments[0];break;case 2:t=arguments[0],r=arguments[1];break;default:throw new Ny("Wrong number of arguments for Schema.create function")}if(t=e4.toArray(t),r=e4.toArray(r),!t.every(function(i){return i instanceof El}))throw new Ny("Specified list of super schemas (or a single Schema object) contains a non-Schema object.");if(!r.every(function(i){return i instanceof hme}))throw new Ny("Specified list of YAML types (or a single Type object) contains a non-Type object.");return new El({include:t,explicit:r})};t4.exports=El});var n4=ee(function(zNe,r4){var yme=Kt();r4.exports=new yme("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return e!==null?e:""}})});var o4=ee(function(NNe,i4){var bme=Kt();i4.exports=new bme("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return e!==null?e:[]}})});var a4=ee(function(DNe,s4){var xme=Kt();s4.exports=new xme("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return e!==null?e:{}}})});var Dy=ee(function(LNe,c4){var Sme=_a();c4.exports=new Sme({explicit:[n4(),o4(),a4()]})});var u4=ee(function(BNe,l4){var wme=Kt();function vme(e){if(e===null)return!0;var t=e.length;return t===1&&e==="~"||t===4&&(e==="null"||e==="Null"||e==="NULL")}function _me(){return null}function kme(e){return e===null}l4.exports=new wme("tag:yaml.org,2002:null",{kind:"scalar",resolve:vme,construct:_me,predicate:kme,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"}},defaultStyle:"lowercase"})});var f4=ee(function(jNe,d4){var Eme=Kt();function Ime(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 Ame(e){return e==="true"||e==="True"||e==="TRUE"}function Tme(e){return Object.prototype.toString.call(e)==="[object Boolean]"}d4.exports=new Eme("tag:yaml.org,2002:bool",{kind:"scalar",resolve:Ime,construct:Ame,predicate:Tme,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 m4=ee(function(qNe,p4){var Cme=va(),$me=Kt();function Ome(e){return 48<=e&&e<=57||65<=e&&e<=70||97<=e&&e<=102}function Rme(e){return 48<=e&&e<=55}function Pme(e){return 48<=e&&e<=57}function zme(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(!Ome(e.charCodeAt(r)))return!1;i=!0}return i&&n!=="_"}for(;r<t;r++){if(n=e[r],n==="_")continue;if(!Rme(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(!Pme(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 Nme(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 Dme(e){return Object.prototype.toString.call(e)==="[object Number]"&&(e%1===0&&!Cme.isNegativeZero(e))}p4.exports=new $me("tag:yaml.org,2002:int",{kind:"scalar",resolve:zme,construct:Nme,predicate:Dme,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 y4=ee(function(UNe,g4){var h4=va(),Lme=Kt(),Bme=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 jme(e){if(e===null)return!1;if(!Bme.test(e)||e[e.length-1]==="_")return!1;return!0}function qme(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 Ume=/^[-+]?[0-9]+e/;function Mme(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(h4.isNegativeZero(e))return"-0.0";return r=e.toString(10),Ume.test(r)?r.replace("e",".e"):r}function Fme(e){return Object.prototype.toString.call(e)==="[object Number]"&&(e%1!==0||h4.isNegativeZero(e))}g4.exports=new Lme("tag:yaml.org,2002:float",{kind:"scalar",resolve:jme,construct:qme,predicate:Fme,represent:Mme,defaultStyle:"lowercase"})});var rT=ee(function(MNe,b4){var Zme=_a();b4.exports=new Zme({include:[Dy()],implicit:[u4(),f4(),m4(),y4()]})});var nT=ee(function(FNe,x4){var Hme=_a();x4.exports=new Hme({include:[rT()]})});var _4=ee(function(ZNe,v4){var Kme=Kt(),S4=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),w4=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 Jme(e){if(e===null)return!1;if(S4.exec(e)!==null)return!0;if(w4.exec(e)!==null)return!0;return!1}function Vme(e){var t,r,i,n,o,s,a,c=0,l=null,u,d,p;if(t=S4.exec(e),t===null)t=w4.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 Wme(e){return e.toISOString()}v4.exports=new Kme("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:Jme,construct:Vme,instanceOf:Date,represent:Wme})});var E4=ee(function(HNe,k4){var Gme=Kt();function Qme(e){return e==="<<"||e===null}k4.exports=new Gme("tag:yaml.org,2002:merge",{kind:"scalar",resolve:Qme})});var A4=ee(function(KNe,I4){var ka;try{iT=Tt,ka=iT("buffer").Buffer}catch(e){}var iT,Yme=Kt(),oT=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
370
+ \r`;function Xme(e){if(e===null)return!1;var t,r,i=0,n=e.length,o=oT;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 ehe(e){var t,r,i=e.replace(/[\r\n=]/g,""),n=i.length,o=oT,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(ka)return ka.from?ka.from(a):new ka(a);return a}function the(e){var t="",r=0,i,n,o=e.length,s=oT;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 rhe(e){return ka&&ka.isBuffer(e)}I4.exports=new Yme("tag:yaml.org,2002:binary",{kind:"scalar",resolve:Xme,construct:ehe,predicate:rhe,represent:the})});var C4=ee(function(VNe,T4){var nhe=Kt(),ihe=Object.prototype.hasOwnProperty,ohe=Object.prototype.toString;function she(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,ohe.call(n)!=="[object Object]")return!1;for(o in n)if(ihe.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 ahe(e){return e!==null?e:[]}T4.exports=new nhe("tag:yaml.org,2002:omap",{kind:"sequence",resolve:she,construct:ahe})});var O4=ee(function(WNe,$4){var che=Kt(),lhe=Object.prototype.toString;function uhe(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],lhe.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 dhe(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}$4.exports=new che("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:uhe,construct:dhe})});var P4=ee(function(GNe,R4){var fhe=Kt(),phe=Object.prototype.hasOwnProperty;function mhe(e){if(e===null)return!0;var t,r=e;for(t in r)if(phe.call(r,t)){if(r[t]!==null)return!1}return!0}function hhe(e){return e!==null?e:{}}R4.exports=new fhe("tag:yaml.org,2002:set",{kind:"mapping",resolve:mhe,construct:hhe})});var Il=ee(function(QNe,z4){var ghe=_a();z4.exports=new ghe({include:[nT()],implicit:[_4(),E4()],explicit:[A4(),C4(),O4(),P4()]})});var D4=ee(function(YNe,N4){var yhe=Kt();function bhe(){return!0}function xhe(){return}function She(){return""}function whe(e){return typeof e>"u"}N4.exports=new yhe("tag:yaml.org,2002:js/undefined",{kind:"scalar",resolve:bhe,construct:xhe,predicate:whe,represent:She})});var B4=ee(function(XNe,L4){var vhe=Kt();function _he(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 khe(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 Ehe(e){var t="/"+e.source+"/";if(e.global)t+="g";if(e.multiline)t+="m";if(e.ignoreCase)t+="i";return t}function Ihe(e){return Object.prototype.toString.call(e)==="[object RegExp]"}L4.exports=new vhe("tag:yaml.org,2002:js/regexp",{kind:"scalar",resolve:_he,construct:khe,predicate:Ihe,represent:Ehe})});var q4=ee(function(eDe,j4){var Ly;try{sT=Tt,Ly=sT("esprima")}catch(e){if(typeof window<"u")Ly=window.esprima}var sT,Ahe=Kt();function The(e){if(e===null)return!1;try{var t="("+e+")",r=Ly.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 Che(e){var t="("+e+")",r=Ly.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 $he(e){return e.toString()}function Ohe(e){return Object.prototype.toString.call(e)==="[object Function]"}j4.exports=new Ahe("tag:yaml.org,2002:js/function",{kind:"scalar",resolve:The,construct:Che,predicate:Ohe,represent:$he})});var Bf=ee(function(rDe,M4){var U4=_a();M4.exports=U4.DEFAULT=new U4({include:[Il()],explicit:[D4(),B4(),q4()]})});var cM=ee(function(tge,jf){var Qi=va(),W4=kl(),Rhe=QU(),G4=Il(),Phe=Bf(),rs=Object.prototype.hasOwnProperty,By=1,Q4=2,Y4=3,jy=4,aT=1,zhe=2,F4=3,Nhe=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,Dhe=/[\x85\u2028\u2029]/,Lhe=/[,\[\]\{\}]/,X4=/^(?:!|!!|![a-z\-]+!)$/i,eM=/^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;function Z4(e){return Object.prototype.toString.call(e)}function bi(e){return e===10||e===13}function Ea(e){return e===9||e===32}function Wr(e){return e===9||e===32||e===10||e===13}function Al(e){return e===44||e===91||e===93||e===123||e===125}function Bhe(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 jhe(e){if(e===120)return 2;if(e===117)return 4;if(e===85)return 8;return 0}function qhe(e){if(48<=e&&e<=57)return e-48;return-1}function H4(e){return e===48?"\x00":e===97?"\x07":e===98?"\b":e===116?"\t":e===9?"\t":e===110?`
371
+ `: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 Uhe(e){if(e<=65535)return String.fromCharCode(e);return String.fromCharCode((e-65536>>10)+55296,(e-65536&1023)+56320)}function tM(e,t,r){if(t==="__proto__")Object.defineProperty(e,t,{configurable:!0,enumerable:!0,writable:!0,value:r});else e[t]=r}var rM=Array(256),nM=Array(256);for(es=0;es<256;es++)rM[es]=H4(es)?1:0,nM[es]=H4(es);var es;function Mhe(e,t){this.input=e,this.filename=t.filename||null,this.schema=t.schema||Phe,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 iM(e,t){return new W4(t,new Rhe(e.filename,e.input,e.position,e.line,e.position-e.lineStart))}function Be(e,t){throw iM(e,t)}function qy(e,t){if(e.onWarning)e.onWarning.call(null,iM(e,t))}var K4={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)qy(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],!X4.test(n))Be(t,"ill-formed tag handle (first argument) of the TAG directive");if(rs.call(t.tagMap,n))Be(t,'there is a previously declared suffix for "'+n+'" tag handle');if(!eM.test(o))Be(t,"ill-formed tag prefix (second argument) of the TAG directive");t.tagMap[n]=o}};function ts(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(Nhe.test(a))Be(e,"the stream contains non-printable characters");e.result+=a}}function J4(e,t,r,i){var n,o,s,a;if(!Qi.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(!rs.call(t,o))tM(t,o,r[o]),i[o]=!0}}function Tl(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"&&Z4(n[c])==="[object Object]")n[c]="[object Object]"}}if(typeof n==="object"&&Z4(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)J4(e,t,o[c],r);else J4(e,t,o,r);else{if(!e.json&&!rs.call(r,n)&&rs.call(t,n))e.line=s||e.line,e.position=a||e.position,Be(e,"duplicated mapping key");tM(t,n,o),delete r[n]}return t}function cT(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 jt(e,t,r){var i=0,n=e.input.charCodeAt(e.position);while(n!==0){while(Ea(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(bi(n)){cT(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)qy(e,"deficient indentation");return i}function Uy(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||Wr(r))return!0}return!1}function lT(e,t){if(t===1)e.result+=" ";else if(t>1)e.result+=Qi.repeat(`
372
+ `,t-1)}function Fhe(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),Wr(m)||Al(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),Wr(n)||r&&Al(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),Wr(n)||r&&Al(n))break}else if(m===35){if(i=e.input.charCodeAt(e.position-1),Wr(i))break}else if(e.position===e.lineStart&&Uy(e)||r&&Al(m))break;else if(bi(m))if(c=e.line,l=e.lineStart,u=e.lineIndent,jt(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)ts(e,o,s,!1),lT(e,e.line-c),o=s=e.position,a=!1;if(!Ea(m))s=e.position+1;m=e.input.charCodeAt(++e.position)}if(ts(e,o,s,!1),e.result)return!0;return e.kind=d,e.result=p,!1}function Zhe(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(ts(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(bi(r))ts(e,i,n,!0),lT(e,jt(e,!1,t)),i=n=e.position;else if(e.position===e.lineStart&&Uy(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 Hhe(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 ts(e,r,e.position,!0),e.position++,!0;else if(a===92){if(ts(e,r,e.position,!0),a=e.input.charCodeAt(++e.position),bi(a))jt(e,!1,t);else if(a<256&&rM[a])e.result+=nM[a],e.position++;else if((s=jhe(a))>0){n=s,o=0;for(;n>0;n--)if(a=e.input.charCodeAt(++e.position),(s=Bhe(a))>=0)o=(o<<4)+s;else Be(e,"expected hexadecimal character");e.result+=Uhe(o),e.position++}else Be(e,"unknown escape sequence");r=i=e.position}else if(bi(a))ts(e,r,i,!0),lT(e,jt(e,!1,t)),r=i=e.position;else if(e.position===e.lineStart&&Uy(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 Khe(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(jt(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),Wr(a))l=u=!0,e.position++,jt(e,!0,t)}if(i=e.line,Cl(e,t,By,!1,!0),y=e.tag,m=e.result,jt(e,!0,t),b=e.input.charCodeAt(e.position),(u||e.line===i)&&b===58)l=!0,b=e.input.charCodeAt(++e.position),jt(e,!0,t),Cl(e,t,By,!1,!0),g=e.result;if(d)Tl(e,o,p,y,m,g);else if(l)o.push(Tl(e,null,p,y,m,g));else o.push(m);if(jt(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 Jhe(e,t){var r,i,n=aT,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(aT===n)n=d===43?F4:zhe;else Be(e,"repeat of a chomping mode identifier");else if((u=qhe(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(Ea(d)){do d=e.input.charCodeAt(++e.position);while(Ea(d));if(d===35)do d=e.input.charCodeAt(++e.position);while(!bi(d)&&d!==0)}while(d!==0){cT(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(bi(d)){c++;continue}if(e.lineIndent<a){if(n===F4)e.result+=Qi.repeat(`
374
373
  `,o?1+c:c);else if(n===aT){if(o)e.result+=`
375
374
  `}break}if(i)if(Ea(d))l=!0,e.result+=Qi.repeat(`
376
375
  `,o?1+c:c);else if(l)l=!1,e.result+=Qi.repeat(`
377
376
  `,c+1);else if(c===0){if(o)e.result+=" "}else e.result+=Qi.repeat(`
378
377
  `,c);else e.result+=Qi.repeat(`
379
- `,o?1+c:c);o=!0,s=!0,c=0,r=e.position;while(!bi(d)&&d!==0)d=e.input.charCodeAt(++e.position);ts(e,r,e.position,!1)}return!0}function V4(e,t){var r,i=e.tag,n=e.anchor,o=[],s,a=!1,c;if(e.anchor!==null)e.anchorMap[e.anchor]=o;c=e.input.charCodeAt(e.position);while(c!==0){if(c!==45)break;if(s=e.input.charCodeAt(e.position+1),!Wr(s))break;if(a=!0,e.position++,jt(e,!0,-1)){if(e.lineIndent<=t){o.push(null),c=e.input.charCodeAt(e.position);continue}}if(r=e.line,Cl(e,t,Y4,!1,!0),o.push(e.result),jt(e,!0,-1),c=e.input.charCodeAt(e.position),(e.line===r||e.lineIndent>t)&&c!==0)Be(e,"bad indentation of a sequence entry");else if(e.lineIndent<t)break}if(a)return e.tag=i,e.anchor=n,e.kind="sequence",e.result=o,!0;return!1}function Whe(e,t,r){var i,n,o,s,a=e.tag,c=e.anchor,l={},u={},d=null,p=null,m=null,y=!1,g=!1,b;if(e.anchor!==null)e.anchorMap[e.anchor]=l;b=e.input.charCodeAt(e.position);while(b!==0){if(i=e.input.charCodeAt(e.position+1),o=e.line,s=e.position,(b===63||b===58)&&Wr(i)){if(b===63){if(y)Tl(e,l,u,d,p,null),d=p=m=null;g=!0,y=!0,n=!0}else if(y)y=!1,n=!0;else Be(e,"incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line");e.position+=1,b=i}else if(Cl(e,r,Q4,!1,!0))if(e.line===o){b=e.input.charCodeAt(e.position);while(Ea(b))b=e.input.charCodeAt(++e.position);if(b===58){if(b=e.input.charCodeAt(++e.position),!Wr(b))Be(e,"a whitespace character is expected after the key-value separator within a block mapping");if(y)Tl(e,l,u,d,p,null),d=p=m=null;g=!0,y=!1,n=!1,d=e.tag,p=e.result}else if(g)Be(e,"can not read an implicit mapping pair; a colon is missed");else return e.tag=a,e.anchor=c,!0}else if(g)Be(e,"can not read a block mapping entry; a multiline key may not be an implicit key");else return e.tag=a,e.anchor=c,!0;else break;if(e.line===o||e.lineIndent>t){if(Cl(e,t,jy,!0,n))if(y)p=e.result;else m=e.result;if(!y)Tl(e,l,u,d,p,m,o,s),d=p=m=null;jt(e,!0,-1),b=e.input.charCodeAt(e.position)}if(e.lineIndent>t&&b!==0)Be(e,"bad indentation of a mapping entry");else if(e.lineIndent<t)break}if(y)Tl(e,l,u,d,p,null);if(g)e.tag=a,e.anchor=c,e.kind="mapping",e.result=l;return g}function Ghe(e){var t,r=!1,i=!1,n,o,s;if(s=e.input.charCodeAt(e.position),s!==33)return!1;if(e.tag!==null)Be(e,"duplication of a tag property");if(s=e.input.charCodeAt(++e.position),s===60)r=!0,s=e.input.charCodeAt(++e.position);else if(s===33)i=!0,n="!!",s=e.input.charCodeAt(++e.position);else n="!";if(t=e.position,r){do s=e.input.charCodeAt(++e.position);while(s!==0&&s!==62);if(e.position<e.length)o=e.input.slice(t,e.position),s=e.input.charCodeAt(++e.position);else Be(e,"unexpected end of the stream within a verbatim tag")}else{while(s!==0&&!Wr(s)){if(s===33)if(!i){if(n=e.input.slice(t-1,e.position+1),!X4.test(n))Be(e,"named tag handle cannot contain such characters");i=!0,t=e.position+1}else Be(e,"tag suffix cannot contain exclamation marks");s=e.input.charCodeAt(++e.position)}if(o=e.input.slice(t,e.position),Bhe.test(o))Be(e,"tag suffix cannot contain flow indicator characters")}if(o&&!eM.test(o))Be(e,"tag name cannot contain such characters: "+o);if(r)e.tag=o;else if(rs.call(e.tagMap,n))e.tag=e.tagMap[n]+o;else if(n==="!")e.tag="!"+o;else if(n==="!!")e.tag="tag:yaml.org,2002:"+o;else Be(e,'undeclared tag handle "'+n+'"');return!0}function Qhe(e){var t,r;if(r=e.input.charCodeAt(e.position),r!==38)return!1;if(e.anchor!==null)Be(e,"duplication of an anchor property");r=e.input.charCodeAt(++e.position),t=e.position;while(r!==0&&!Wr(r)&&!Al(r))r=e.input.charCodeAt(++e.position);if(e.position===t)Be(e,"name of an anchor node must contain at least one character");return e.anchor=e.input.slice(t,e.position),!0}function Yhe(e){var t,r,i;if(i=e.input.charCodeAt(e.position),i!==42)return!1;i=e.input.charCodeAt(++e.position),t=e.position;while(i!==0&&!Wr(i)&&!Al(i))i=e.input.charCodeAt(++e.position);if(e.position===t)Be(e,"name of an alias node must contain at least one character");if(r=e.input.slice(t,e.position),!rs.call(e.anchorMap,r))Be(e,'unidentified alias "'+r+'"');return e.result=e.anchorMap[r],jt(e,!0,-1),!0}function Cl(e,t,r,i,n){var o,s,a,c=1,l=!1,u=!1,d,p,m,y,g;if(e.listener!==null)e.listener("open",e);if(e.tag=null,e.anchor=null,e.kind=null,e.result=null,o=s=a=jy===r||Y4===r,i){if(jt(e,!0,-1)){if(l=!0,e.lineIndent>t)c=1;else if(e.lineIndent===t)c=0;else if(e.lineIndent<t)c=-1}}if(c===1)while(Ghe(e)||Qhe(e))if(jt(e,!0,-1)){if(l=!0,a=o,e.lineIndent>t)c=1;else if(e.lineIndent===t)c=0;else if(e.lineIndent<t)c=-1}else a=!1;if(a)a=l||n;if(c===1||jy===r){if(By===r||Q4===r)y=t;else y=t+1;if(g=e.position-e.lineStart,c===1)if(a&&(V4(e,g)||Whe(e,g,y))||Jhe(e,y))u=!0;else{if(s&&Vhe(e,y)||Hhe(e,y)||Khe(e,y))u=!0;else if(Yhe(e)){if(u=!0,e.tag!==null||e.anchor!==null)Be(e,"alias node should not have any properties")}else if(Zhe(e,y,By===r)){if(u=!0,e.tag===null)e.tag="?"}if(e.anchor!==null)e.anchorMap[e.anchor]=e.result}else if(c===0)u=a&&V4(e,g)}if(e.tag!==null&&e.tag!=="!")if(e.tag==="?"){if(e.result!==null&&e.kind!=="scalar")Be(e,'unacceptable node kind for !<?> tag; it should be "scalar", not "'+e.kind+'"');for(d=0,p=e.implicitTypes.length;d<p;d+=1)if(m=e.implicitTypes[d],m.resolve(e.result)){if(e.result=m.construct(e.result),e.tag=m.tag,e.anchor!==null)e.anchorMap[e.anchor]=e.result;break}}else if(rs.call(e.typeMap[e.kind||"fallback"],e.tag)){if(m=e.typeMap[e.kind||"fallback"][e.tag],e.result!==null&&m.kind!==e.kind)Be(e,"unacceptable node kind for !<"+e.tag+'> tag; it should be "'+m.kind+'", not "'+e.kind+'"');if(!m.resolve(e.result))Be(e,"cannot resolve a node with !<"+e.tag+"> explicit tag");else if(e.result=m.construct(e.result),e.anchor!==null)e.anchorMap[e.anchor]=e.result}else Be(e,"unknown tag !<"+e.tag+">");if(e.listener!==null)e.listener("close",e);return e.tag!==null||e.anchor!==null||u}function Xhe(e){var t=e.position,r,i,n,o=!1,s;e.version=null,e.checkLineBreaks=e.legacy,e.tagMap={},e.anchorMap={};while((s=e.input.charCodeAt(e.position))!==0){if(jt(e,!0,-1),s=e.input.charCodeAt(e.position),e.lineIndent>0||s!==37)break;o=!0,s=e.input.charCodeAt(++e.position),r=e.position;while(s!==0&&!Wr(s))s=e.input.charCodeAt(++e.position);if(i=e.input.slice(r,e.position),n=[],i.length<1)Be(e,"directive name must not be less than one character in length");while(s!==0){while(Ea(s))s=e.input.charCodeAt(++e.position);if(s===35){do s=e.input.charCodeAt(++e.position);while(s!==0&&!bi(s));break}if(bi(s))break;r=e.position;while(s!==0&&!Wr(s))s=e.input.charCodeAt(++e.position);n.push(e.input.slice(r,e.position))}if(s!==0)cT(e);if(rs.call(K4,i))K4[i](e,i,n);else qy(e,'unknown document directive "'+i+'"')}if(jt(e,!0,-1),e.lineIndent===0&&e.input.charCodeAt(e.position)===45&&e.input.charCodeAt(e.position+1)===45&&e.input.charCodeAt(e.position+2)===45)e.position+=3,jt(e,!0,-1);else if(o)Be(e,"directives end mark is expected");if(Cl(e,e.lineIndent-1,jy,!1,!0),jt(e,!0,-1),e.checkLineBreaks&&Lhe.test(e.input.slice(t,e.position)))qy(e,"non-ASCII line breaks are interpreted as content");if(e.documents.push(e.result),e.position===e.lineStart&&Uy(e)){if(e.input.charCodeAt(e.position)===46)e.position+=3,jt(e,!0,-1);return}if(e.position<e.length-1)Be(e,"end of the stream or a document separator is expected");else return}function oM(e,t){if(e=String(e),t=t||{},e.length!==0){if(e.charCodeAt(e.length-1)!==10&&e.charCodeAt(e.length-1)!==13)e+=`
380
- `;if(e.charCodeAt(0)===65279)e=e.slice(1)}var r=new Fhe(e,t),i=e.indexOf("\x00");if(i!==-1)r.position=i,Be(r,"null byte is not allowed in input");r.input+="\x00";while(r.input.charCodeAt(r.position)===32)r.lineIndent+=1,r.position+=1;while(r.position<r.length-1)Xhe(r);return r.documents}function sM(e,t,r){if(t!==null&&typeof t==="object"&&typeof r>"u")r=t,t=null;var i=oM(e,r);if(typeof t!=="function")return i;for(var n=0,o=i.length;n<o;n+=1)t(i[n])}function aM(e,t){var r=oM(e,t);if(r.length===0)return;else if(r.length===1)return r[0];throw new W4("expected a single document in the stream, but found more")}function ege(e,t,r){if(typeof t==="object"&&t!==null&&typeof r>"u")r=t,t=null;return sM(e,t,Qi.extend({schema:G4},r))}function tge(e,t){return aM(e,Qi.extend({schema:G4},t))}rge.loadAll=sM;rge.load=aM;rge.safeLoadAll=ege;rge.safeLoad=tge});var OM=ee(function(Uge,pT){var Uf=va(),Mf=kl(),age=Bf(),cge=Il(),gM=Object.prototype.toString,yM=Object.prototype.hasOwnProperty,lge=9,qf=10,uge=13,dge=32,fge=33,pge=34,bM=35,mge=37,hge=38,gge=39,yge=42,xM=44,bge=45,SM=58,xge=61,Sge=62,wge=63,vge=64,wM=91,vM=93,_ge=96,_M=123,kge=124,kM=125,wr={};wr[0]="\\0";wr[7]="\\a";wr[8]="\\b";wr[9]="\\t";wr[10]="\\n";wr[11]="\\v";wr[12]="\\f";wr[13]="\\r";wr[27]="\\e";wr[34]="\\\"";wr[92]="\\\\";wr[133]="\\N";wr[160]="\\_";wr[8232]="\\L";wr[8233]="\\P";var Ege=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"];function Ige(e,t){var r,i,n,o,s,a,c;if(t===null)return{};r={},i=Object.keys(t);for(n=0,o=i.length;n<o;n+=1){if(s=i[n],a=String(t[s]),s.slice(0,2)==="!!")s="tag:yaml.org,2002:"+s.slice(2);if(c=e.compiledTypeMap.fallback[s],c&&yM.call(c.styleAliases,a))a=c.styleAliases[a];r[s]=a}return r}function lM(e){var t,r,i;if(t=e.toString(16).toUpperCase(),e<=255)r="x",i=2;else if(e<=65535)r="u",i=4;else if(e<=4294967295)r="U",i=8;else throw new Mf("code point within a string may not be greater than 0xFFFFFFFF");return"\\"+r+Uf.repeat("0",i-t.length)+t}function Age(e){this.schema=e.schema||age,this.indent=Math.max(1,e.indent||2),this.noArrayIndent=e.noArrayIndent||!1,this.skipInvalid=e.skipInvalid||!1,this.flowLevel=Uf.isNothing(e.flowLevel)?-1:e.flowLevel,this.styleMap=Ige(this.schema,e.styles||null),this.sortKeys=e.sortKeys||!1,this.lineWidth=e.lineWidth||80,this.noRefs=e.noRefs||!1,this.noCompatMode=e.noCompatMode||!1,this.condenseFlow=e.condenseFlow||!1,this.implicitTypes=this.schema.compiledImplicit,this.explicitTypes=this.schema.compiledExplicit,this.tag=null,this.result="",this.duplicates=[],this.usedDuplicates=null}function uM(e,t){var r=Uf.repeat(" ",t),i=0,n=-1,o="",s,a=e.length;while(i<a){if(n=e.indexOf(`
378
+ `,o?1+c:c);o=!0,s=!0,c=0,r=e.position;while(!bi(d)&&d!==0)d=e.input.charCodeAt(++e.position);ts(e,r,e.position,!1)}return!0}function V4(e,t){var r,i=e.tag,n=e.anchor,o=[],s,a=!1,c;if(e.anchor!==null)e.anchorMap[e.anchor]=o;c=e.input.charCodeAt(e.position);while(c!==0){if(c!==45)break;if(s=e.input.charCodeAt(e.position+1),!Wr(s))break;if(a=!0,e.position++,jt(e,!0,-1)){if(e.lineIndent<=t){o.push(null),c=e.input.charCodeAt(e.position);continue}}if(r=e.line,Cl(e,t,Y4,!1,!0),o.push(e.result),jt(e,!0,-1),c=e.input.charCodeAt(e.position),(e.line===r||e.lineIndent>t)&&c!==0)Be(e,"bad indentation of a sequence entry");else if(e.lineIndent<t)break}if(a)return e.tag=i,e.anchor=n,e.kind="sequence",e.result=o,!0;return!1}function Vhe(e,t,r){var i,n,o,s,a=e.tag,c=e.anchor,l={},u={},d=null,p=null,m=null,y=!1,g=!1,b;if(e.anchor!==null)e.anchorMap[e.anchor]=l;b=e.input.charCodeAt(e.position);while(b!==0){if(i=e.input.charCodeAt(e.position+1),o=e.line,s=e.position,(b===63||b===58)&&Wr(i)){if(b===63){if(y)Tl(e,l,u,d,p,null),d=p=m=null;g=!0,y=!0,n=!0}else if(y)y=!1,n=!0;else Be(e,"incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line");e.position+=1,b=i}else if(Cl(e,r,Q4,!1,!0))if(e.line===o){b=e.input.charCodeAt(e.position);while(Ea(b))b=e.input.charCodeAt(++e.position);if(b===58){if(b=e.input.charCodeAt(++e.position),!Wr(b))Be(e,"a whitespace character is expected after the key-value separator within a block mapping");if(y)Tl(e,l,u,d,p,null),d=p=m=null;g=!0,y=!1,n=!1,d=e.tag,p=e.result}else if(g)Be(e,"can not read an implicit mapping pair; a colon is missed");else return e.tag=a,e.anchor=c,!0}else if(g)Be(e,"can not read a block mapping entry; a multiline key may not be an implicit key");else return e.tag=a,e.anchor=c,!0;else break;if(e.line===o||e.lineIndent>t){if(Cl(e,t,jy,!0,n))if(y)p=e.result;else m=e.result;if(!y)Tl(e,l,u,d,p,m,o,s),d=p=m=null;jt(e,!0,-1),b=e.input.charCodeAt(e.position)}if(e.lineIndent>t&&b!==0)Be(e,"bad indentation of a mapping entry");else if(e.lineIndent<t)break}if(y)Tl(e,l,u,d,p,null);if(g)e.tag=a,e.anchor=c,e.kind="mapping",e.result=l;return g}function Whe(e){var t,r=!1,i=!1,n,o,s;if(s=e.input.charCodeAt(e.position),s!==33)return!1;if(e.tag!==null)Be(e,"duplication of a tag property");if(s=e.input.charCodeAt(++e.position),s===60)r=!0,s=e.input.charCodeAt(++e.position);else if(s===33)i=!0,n="!!",s=e.input.charCodeAt(++e.position);else n="!";if(t=e.position,r){do s=e.input.charCodeAt(++e.position);while(s!==0&&s!==62);if(e.position<e.length)o=e.input.slice(t,e.position),s=e.input.charCodeAt(++e.position);else Be(e,"unexpected end of the stream within a verbatim tag")}else{while(s!==0&&!Wr(s)){if(s===33)if(!i){if(n=e.input.slice(t-1,e.position+1),!X4.test(n))Be(e,"named tag handle cannot contain such characters");i=!0,t=e.position+1}else Be(e,"tag suffix cannot contain exclamation marks");s=e.input.charCodeAt(++e.position)}if(o=e.input.slice(t,e.position),Lhe.test(o))Be(e,"tag suffix cannot contain flow indicator characters")}if(o&&!eM.test(o))Be(e,"tag name cannot contain such characters: "+o);if(r)e.tag=o;else if(rs.call(e.tagMap,n))e.tag=e.tagMap[n]+o;else if(n==="!")e.tag="!"+o;else if(n==="!!")e.tag="tag:yaml.org,2002:"+o;else Be(e,'undeclared tag handle "'+n+'"');return!0}function Ghe(e){var t,r;if(r=e.input.charCodeAt(e.position),r!==38)return!1;if(e.anchor!==null)Be(e,"duplication of an anchor property");r=e.input.charCodeAt(++e.position),t=e.position;while(r!==0&&!Wr(r)&&!Al(r))r=e.input.charCodeAt(++e.position);if(e.position===t)Be(e,"name of an anchor node must contain at least one character");return e.anchor=e.input.slice(t,e.position),!0}function Qhe(e){var t,r,i;if(i=e.input.charCodeAt(e.position),i!==42)return!1;i=e.input.charCodeAt(++e.position),t=e.position;while(i!==0&&!Wr(i)&&!Al(i))i=e.input.charCodeAt(++e.position);if(e.position===t)Be(e,"name of an alias node must contain at least one character");if(r=e.input.slice(t,e.position),!rs.call(e.anchorMap,r))Be(e,'unidentified alias "'+r+'"');return e.result=e.anchorMap[r],jt(e,!0,-1),!0}function Cl(e,t,r,i,n){var o,s,a,c=1,l=!1,u=!1,d,p,m,y,g;if(e.listener!==null)e.listener("open",e);if(e.tag=null,e.anchor=null,e.kind=null,e.result=null,o=s=a=jy===r||Y4===r,i){if(jt(e,!0,-1)){if(l=!0,e.lineIndent>t)c=1;else if(e.lineIndent===t)c=0;else if(e.lineIndent<t)c=-1}}if(c===1)while(Whe(e)||Ghe(e))if(jt(e,!0,-1)){if(l=!0,a=o,e.lineIndent>t)c=1;else if(e.lineIndent===t)c=0;else if(e.lineIndent<t)c=-1}else a=!1;if(a)a=l||n;if(c===1||jy===r){if(By===r||Q4===r)y=t;else y=t+1;if(g=e.position-e.lineStart,c===1)if(a&&(V4(e,g)||Vhe(e,g,y))||Khe(e,y))u=!0;else{if(s&&Jhe(e,y)||Zhe(e,y)||Hhe(e,y))u=!0;else if(Qhe(e)){if(u=!0,e.tag!==null||e.anchor!==null)Be(e,"alias node should not have any properties")}else if(Fhe(e,y,By===r)){if(u=!0,e.tag===null)e.tag="?"}if(e.anchor!==null)e.anchorMap[e.anchor]=e.result}else if(c===0)u=a&&V4(e,g)}if(e.tag!==null&&e.tag!=="!")if(e.tag==="?"){if(e.result!==null&&e.kind!=="scalar")Be(e,'unacceptable node kind for !<?> tag; it should be "scalar", not "'+e.kind+'"');for(d=0,p=e.implicitTypes.length;d<p;d+=1)if(m=e.implicitTypes[d],m.resolve(e.result)){if(e.result=m.construct(e.result),e.tag=m.tag,e.anchor!==null)e.anchorMap[e.anchor]=e.result;break}}else if(rs.call(e.typeMap[e.kind||"fallback"],e.tag)){if(m=e.typeMap[e.kind||"fallback"][e.tag],e.result!==null&&m.kind!==e.kind)Be(e,"unacceptable node kind for !<"+e.tag+'> tag; it should be "'+m.kind+'", not "'+e.kind+'"');if(!m.resolve(e.result))Be(e,"cannot resolve a node with !<"+e.tag+"> explicit tag");else if(e.result=m.construct(e.result),e.anchor!==null)e.anchorMap[e.anchor]=e.result}else Be(e,"unknown tag !<"+e.tag+">");if(e.listener!==null)e.listener("close",e);return e.tag!==null||e.anchor!==null||u}function Yhe(e){var t=e.position,r,i,n,o=!1,s;e.version=null,e.checkLineBreaks=e.legacy,e.tagMap={},e.anchorMap={};while((s=e.input.charCodeAt(e.position))!==0){if(jt(e,!0,-1),s=e.input.charCodeAt(e.position),e.lineIndent>0||s!==37)break;o=!0,s=e.input.charCodeAt(++e.position),r=e.position;while(s!==0&&!Wr(s))s=e.input.charCodeAt(++e.position);if(i=e.input.slice(r,e.position),n=[],i.length<1)Be(e,"directive name must not be less than one character in length");while(s!==0){while(Ea(s))s=e.input.charCodeAt(++e.position);if(s===35){do s=e.input.charCodeAt(++e.position);while(s!==0&&!bi(s));break}if(bi(s))break;r=e.position;while(s!==0&&!Wr(s))s=e.input.charCodeAt(++e.position);n.push(e.input.slice(r,e.position))}if(s!==0)cT(e);if(rs.call(K4,i))K4[i](e,i,n);else qy(e,'unknown document directive "'+i+'"')}if(jt(e,!0,-1),e.lineIndent===0&&e.input.charCodeAt(e.position)===45&&e.input.charCodeAt(e.position+1)===45&&e.input.charCodeAt(e.position+2)===45)e.position+=3,jt(e,!0,-1);else if(o)Be(e,"directives end mark is expected");if(Cl(e,e.lineIndent-1,jy,!1,!0),jt(e,!0,-1),e.checkLineBreaks&&Dhe.test(e.input.slice(t,e.position)))qy(e,"non-ASCII line breaks are interpreted as content");if(e.documents.push(e.result),e.position===e.lineStart&&Uy(e)){if(e.input.charCodeAt(e.position)===46)e.position+=3,jt(e,!0,-1);return}if(e.position<e.length-1)Be(e,"end of the stream or a document separator is expected");else return}function oM(e,t){if(e=String(e),t=t||{},e.length!==0){if(e.charCodeAt(e.length-1)!==10&&e.charCodeAt(e.length-1)!==13)e+=`
379
+ `;if(e.charCodeAt(0)===65279)e=e.slice(1)}var r=new Mhe(e,t),i=e.indexOf("\x00");if(i!==-1)r.position=i,Be(r,"null byte is not allowed in input");r.input+="\x00";while(r.input.charCodeAt(r.position)===32)r.lineIndent+=1,r.position+=1;while(r.position<r.length-1)Yhe(r);return r.documents}function sM(e,t,r){if(t!==null&&typeof t==="object"&&typeof r>"u")r=t,t=null;var i=oM(e,r);if(typeof t!=="function")return i;for(var n=0,o=i.length;n<o;n+=1)t(i[n])}function aM(e,t){var r=oM(e,t);if(r.length===0)return;else if(r.length===1)return r[0];throw new W4("expected a single document in the stream, but found more")}function Xhe(e,t,r){if(typeof t==="object"&&t!==null&&typeof r>"u")r=t,t=null;return sM(e,t,Qi.extend({schema:G4},r))}function ege(e,t){return aM(e,Qi.extend({schema:G4},t))}tge.loadAll=sM;tge.load=aM;tge.safeLoadAll=Xhe;tge.safeLoad=ege});var OM=ee(function(qge,pT){var Uf=va(),Mf=kl(),sge=Bf(),age=Il(),gM=Object.prototype.toString,yM=Object.prototype.hasOwnProperty,cge=9,qf=10,lge=13,uge=32,dge=33,fge=34,bM=35,pge=37,mge=38,hge=39,gge=42,xM=44,yge=45,SM=58,bge=61,xge=62,Sge=63,wge=64,wM=91,vM=93,vge=96,_M=123,_ge=124,kM=125,wr={};wr[0]="\\0";wr[7]="\\a";wr[8]="\\b";wr[9]="\\t";wr[10]="\\n";wr[11]="\\v";wr[12]="\\f";wr[13]="\\r";wr[27]="\\e";wr[34]="\\\"";wr[92]="\\\\";wr[133]="\\N";wr[160]="\\_";wr[8232]="\\L";wr[8233]="\\P";var kge=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"];function Ege(e,t){var r,i,n,o,s,a,c;if(t===null)return{};r={},i=Object.keys(t);for(n=0,o=i.length;n<o;n+=1){if(s=i[n],a=String(t[s]),s.slice(0,2)==="!!")s="tag:yaml.org,2002:"+s.slice(2);if(c=e.compiledTypeMap.fallback[s],c&&yM.call(c.styleAliases,a))a=c.styleAliases[a];r[s]=a}return r}function lM(e){var t,r,i;if(t=e.toString(16).toUpperCase(),e<=255)r="x",i=2;else if(e<=65535)r="u",i=4;else if(e<=4294967295)r="U",i=8;else throw new Mf("code point within a string may not be greater than 0xFFFFFFFF");return"\\"+r+Uf.repeat("0",i-t.length)+t}function Ige(e){this.schema=e.schema||sge,this.indent=Math.max(1,e.indent||2),this.noArrayIndent=e.noArrayIndent||!1,this.skipInvalid=e.skipInvalid||!1,this.flowLevel=Uf.isNothing(e.flowLevel)?-1:e.flowLevel,this.styleMap=Ege(this.schema,e.styles||null),this.sortKeys=e.sortKeys||!1,this.lineWidth=e.lineWidth||80,this.noRefs=e.noRefs||!1,this.noCompatMode=e.noCompatMode||!1,this.condenseFlow=e.condenseFlow||!1,this.implicitTypes=this.schema.compiledImplicit,this.explicitTypes=this.schema.compiledExplicit,this.tag=null,this.result="",this.duplicates=[],this.usedDuplicates=null}function uM(e,t){var r=Uf.repeat(" ",t),i=0,n=-1,o="",s,a=e.length;while(i<a){if(n=e.indexOf(`
381
380
  `,i),n===-1)s=e.slice(i),i=a;else s=e.slice(i,n+1),i=n+1;if(s.length&&s!==`
382
381
  `)o+=r;o+=s}return o}function uT(e,t){return`
383
- `+Uf.repeat(" ",e.indent*t)}function Tge(e,t){var r,i,n;for(r=0,i=e.implicitTypes.length;r<i;r+=1)if(n=e.implicitTypes[r],n.resolve(t))return!0;return!1}function fT(e){return e===dge||e===lge}function $l(e){return 32<=e&&e<=126||161<=e&&e<=55295&&e!==8232&&e!==8233||57344<=e&&e<=65533&&e!==65279||65536<=e&&e<=1114111}function Cge(e){return $l(e)&&!fT(e)&&e!==65279&&e!==uge&&e!==qf}function dM(e,t){return $l(e)&&e!==65279&&e!==xM&&e!==wM&&e!==vM&&e!==_M&&e!==kM&&e!==SM&&(e!==bM||t&&Cge(t))}function $ge(e){return $l(e)&&e!==65279&&!fT(e)&&e!==bge&&e!==wge&&e!==SM&&e!==xM&&e!==wM&&e!==vM&&e!==_M&&e!==kM&&e!==bM&&e!==hge&&e!==yge&&e!==fge&&e!==kge&&e!==xge&&e!==Sge&&e!==gge&&e!==pge&&e!==mge&&e!==vge&&e!==_ge}function EM(e){var t=/^\n* /;return t.test(e)}var IM=1,AM=2,TM=3,CM=4,My=5;function Oge(e,t,r,i,n){var o,s,a,c=!1,l=!1,u=i!==-1,d=-1,p=$ge(e.charCodeAt(0))&&!fT(e.charCodeAt(e.length-1));if(t)for(o=0;o<e.length;o++){if(s=e.charCodeAt(o),!$l(s))return My;a=o>0?e.charCodeAt(o-1):null,p=p&&dM(s,a)}else{for(o=0;o<e.length;o++){if(s=e.charCodeAt(o),s===qf){if(c=!0,u)l=l||o-d-1>i&&e[d+1]!==" ",d=o}else if(!$l(s))return My;a=o>0?e.charCodeAt(o-1):null,p=p&&dM(s,a)}l=l||u&&(o-d-1>i&&e[d+1]!==" ")}if(!c&&!l)return p&&!n(e)?IM:AM;if(r>9&&EM(e))return My;return l?CM:TM}function Rge(e,t,r,i){e.dump=function(){if(t.length===0)return"''";if(!e.noCompatMode&&Ege.indexOf(t)!==-1)return"'"+t+"'";var n=e.indent*Math.max(1,r),o=e.lineWidth===-1?-1:Math.max(Math.min(e.lineWidth,40),e.lineWidth-n),s=i||e.flowLevel>-1&&r>=e.flowLevel;function a(c){return Tge(e,c)}switch(Oge(t,s,e.indent,o,a)){case IM:return t;case AM:return"'"+t.replace(/'/g,"''")+"'";case TM:return"|"+fM(t,e.indent)+pM(uM(t,n));case CM:return">"+fM(t,e.indent)+pM(uM(Pge(t,o),n));case My:return'"'+zge(t,o)+'"';default:throw new Mf("impossible error: invalid scalar style")}}()}function fM(e,t){var r=EM(e)?String(t):"",i=e[e.length-1]===`
382
+ `+Uf.repeat(" ",e.indent*t)}function Age(e,t){var r,i,n;for(r=0,i=e.implicitTypes.length;r<i;r+=1)if(n=e.implicitTypes[r],n.resolve(t))return!0;return!1}function fT(e){return e===uge||e===cge}function $l(e){return 32<=e&&e<=126||161<=e&&e<=55295&&e!==8232&&e!==8233||57344<=e&&e<=65533&&e!==65279||65536<=e&&e<=1114111}function Tge(e){return $l(e)&&!fT(e)&&e!==65279&&e!==lge&&e!==qf}function dM(e,t){return $l(e)&&e!==65279&&e!==xM&&e!==wM&&e!==vM&&e!==_M&&e!==kM&&e!==SM&&(e!==bM||t&&Tge(t))}function Cge(e){return $l(e)&&e!==65279&&!fT(e)&&e!==yge&&e!==Sge&&e!==SM&&e!==xM&&e!==wM&&e!==vM&&e!==_M&&e!==kM&&e!==bM&&e!==mge&&e!==gge&&e!==dge&&e!==_ge&&e!==bge&&e!==xge&&e!==hge&&e!==fge&&e!==pge&&e!==wge&&e!==vge}function EM(e){var t=/^\n* /;return t.test(e)}var IM=1,AM=2,TM=3,CM=4,My=5;function $ge(e,t,r,i,n){var o,s,a,c=!1,l=!1,u=i!==-1,d=-1,p=Cge(e.charCodeAt(0))&&!fT(e.charCodeAt(e.length-1));if(t)for(o=0;o<e.length;o++){if(s=e.charCodeAt(o),!$l(s))return My;a=o>0?e.charCodeAt(o-1):null,p=p&&dM(s,a)}else{for(o=0;o<e.length;o++){if(s=e.charCodeAt(o),s===qf){if(c=!0,u)l=l||o-d-1>i&&e[d+1]!==" ",d=o}else if(!$l(s))return My;a=o>0?e.charCodeAt(o-1):null,p=p&&dM(s,a)}l=l||u&&(o-d-1>i&&e[d+1]!==" ")}if(!c&&!l)return p&&!n(e)?IM:AM;if(r>9&&EM(e))return My;return l?CM:TM}function Oge(e,t,r,i){e.dump=function(){if(t.length===0)return"''";if(!e.noCompatMode&&kge.indexOf(t)!==-1)return"'"+t+"'";var n=e.indent*Math.max(1,r),o=e.lineWidth===-1?-1:Math.max(Math.min(e.lineWidth,40),e.lineWidth-n),s=i||e.flowLevel>-1&&r>=e.flowLevel;function a(c){return Age(e,c)}switch($ge(t,s,e.indent,o,a)){case IM:return t;case AM:return"'"+t.replace(/'/g,"''")+"'";case TM:return"|"+fM(t,e.indent)+pM(uM(t,n));case CM:return">"+fM(t,e.indent)+pM(uM(Rge(t,o),n));case My:return'"'+Pge(t,o)+'"';default:throw new Mf("impossible error: invalid scalar style")}}()}function fM(e,t){var r=EM(e)?String(t):"",i=e[e.length-1]===`
384
383
  `,n=i&&(e[e.length-2]===`
385
384
  `||e===`
386
385
  `),o=n?"+":i?"":"-";return r+o+`
387
386
  `}function pM(e){return e[e.length-1]===`
388
- `?e.slice(0,-1):e}function Pge(e,t){var r=/(\n+)([^\n]*)/g,i=function(){var l=e.indexOf(`
387
+ `?e.slice(0,-1):e}function Rge(e,t){var r=/(\n+)([^\n]*)/g,i=function(){var l=e.indexOf(`
389
388
  `);return l=l!==-1?l:e.length,r.lastIndex=l,mM(e.slice(0,l),t)}(),n=e[0]===`
390
389
  `||e[0]===" ",o,s;while(s=r.exec(e)){var a=s[1],c=s[2];o=c[0]===" ",i+=a+(!n&&!o&&c!==""?`
391
390
  `:"")+mM(c,t),n=o}return i}function mM(e,t){if(e===""||e[0]===" ")return e;var r=/ [^ ]/g,i,n=0,o,s=0,a=0,c="";while(i=r.exec(e)){if(a=i.index,a-n>t)o=s>n?s:a,c+=`
392
391
  `+e.slice(n,o),n=o+1;s=a}if(c+=`
393
392
  `,e.length-n>t&&s>n)c+=e.slice(n,s)+`
394
- `+e.slice(s+1);else c+=e.slice(n);return c.slice(1)}function zge(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+=lM((r-55296)*1024+i-56320+65536),o++;continue}}n=wr[r],t+=!n&&$l(r)?e[o]:n||lM(r)}return t}function Nge(e,t,r){var i="",n=e.tag,o,s;for(o=0,s=r.length;o<s;o+=1)if(Ia(e,t,r[o],!1,!1)){if(o!==0)i+=","+(!e.condenseFlow?" ":"");i+=e.dump}e.tag=n,e.dump="["+i+"]"}function Dge(e,t,r,i){var n="",o=e.tag,s,a;for(s=0,a=r.length;s<a;s+=1)if(Ia(e,t+1,r[s],!0,!0)){if(!i||s!==0)n+=uT(e,t);if(e.dump&&qf===e.dump.charCodeAt(0))n+="-";else n+="- ";n+=e.dump}e.tag=o,e.dump=n||"[]"}function Lge(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],!Ia(e,t,c,!1,!1))continue;if(e.dump.length>1024)u+="? ";if(u+=e.dump+(e.condenseFlow?'"':"")+":"+(e.condenseFlow?"":" "),!Ia(e,t,l,!1,!1))continue;u+=e.dump,i+=u}e.tag=n,e.dump="{"+i+"}"}function Bge(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 Mf("sortKeys must be a boolean or a function");for(a=0,c=s.length;a<c;a+=1){if(p="",!i||a!==0)p+=uT(e,t);if(l=s[a],u=r[l],!Ia(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&&qf===e.dump.charCodeAt(0))p+="?";else p+="? ";if(p+=e.dump,d)p+=uT(e,t);if(!Ia(e,t+1,u,!0,d))continue;if(e.dump&&qf===e.dump.charCodeAt(0))p+=":";else p+=": ";p+=e.dump,n+=p}e.tag=o,e.dump=n||"{}"}function hM(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,gM.call(a.represent)==="[object Function]")i=a.represent(t,c);else if(yM.call(a.represent,c))i=a.represent[c](t,c);else throw new Mf("!<"+a.tag+'> tag resolver accepts not "'+c+'" style');e.dump=i}return!0}return!1}function Ia(e,t,r,i,n,o){if(e.tag=null,e.dump=r,!hM(e,r,!1))hM(e,r,!0);var s=gM.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(Bge(e,t,e.dump,n),l)e.dump="&ref_"+c+e.dump}else if(Lge(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(Dge(e,u,e.dump,n),l)e.dump="&ref_"+c+e.dump}else if(Nge(e,u,e.dump),l)e.dump="&ref_"+c+" "+e.dump}else if(s==="[object String]"){if(e.tag!=="?")Rge(e,e.dump,t,o)}else{if(e.skipInvalid)return!1;throw new Mf("unacceptable kind of an object to dump "+s)}if(e.tag!==null&&e.tag!=="?")e.dump="!<"+e.tag+"> "+e.dump}return!0}function jge(e,t){var r=[],i=[],n,o;dT(e,r,i);for(n=0,o=i.length;n<o;n+=1)t.duplicates.push(r[i[n]]);t.usedDuplicates=Array(o)}function dT(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)dT(e[n],t,r);else{i=Object.keys(e);for(n=0,o=i.length;n<o;n+=1)dT(e[i[n]],t,r)}}function $M(e,t){t=t||{};var r=new Age(t);if(!r.noRefs)jge(e,r);if(Ia(r,0,e,!0,!0))return r.dump+`
395
- `;return""}function qge(e,t){return $M(e,Uf.extend({schema:cge},t))}Uge.dump=$M;Uge.safeDump=qge});var PM=ee(function(Zge,It){var Fy=cM(),RM=OM();function Zy(e){return function(){throw Error("Function "+e+" is deprecated and cannot be used.")}}Zge.Type=Kt();Zge.Schema=_a();Zge.FAILSAFE_SCHEMA=Dy();Zge.JSON_SCHEMA=rT();Zge.CORE_SCHEMA=nT();Zge.DEFAULT_SAFE_SCHEMA=Il();Zge.DEFAULT_FULL_SCHEMA=Bf();Zge.load=Fy.load;Zge.loadAll=Fy.loadAll;Zge.safeLoad=Fy.safeLoad;Zge.safeLoadAll=Fy.safeLoadAll;Zge.dump=RM.dump;Zge.safeDump=RM.safeDump;Zge.YAMLException=kl();Zge.MINIMAL_SCHEMA=Dy();Zge.SAFE_SCHEMA=Il();Zge.DEFAULT_SCHEMA=Bf();Zge.scan=Zy("scan");Zge.parse=Zy("parse");Zge.compose=Zy("compose");Zge.addConstructor=Zy("addConstructor")});var NM=ee(function(iDe,zM){var fye=PM();zM.exports=fye});var yT=ee(function(hT,gT){var Hy=NM(),mT=hT=gT.exports;mT.yaml={parse:Hy.safeLoad.bind(Hy),stringify:Hy.safeDump.bind(Hy)};mT.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)}};mT.javascript={parse:function parse(str,options,wrap){try{if(wrap!==!1)str=`(function() {
393
+ `+e.slice(s+1);else c+=e.slice(n);return c.slice(1)}function Pge(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+=lM((r-55296)*1024+i-56320+65536),o++;continue}}n=wr[r],t+=!n&&$l(r)?e[o]:n||lM(r)}return t}function zge(e,t,r){var i="",n=e.tag,o,s;for(o=0,s=r.length;o<s;o+=1)if(Ia(e,t,r[o],!1,!1)){if(o!==0)i+=","+(!e.condenseFlow?" ":"");i+=e.dump}e.tag=n,e.dump="["+i+"]"}function Nge(e,t,r,i){var n="",o=e.tag,s,a;for(s=0,a=r.length;s<a;s+=1)if(Ia(e,t+1,r[s],!0,!0)){if(!i||s!==0)n+=uT(e,t);if(e.dump&&qf===e.dump.charCodeAt(0))n+="-";else n+="- ";n+=e.dump}e.tag=o,e.dump=n||"[]"}function Dge(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],!Ia(e,t,c,!1,!1))continue;if(e.dump.length>1024)u+="? ";if(u+=e.dump+(e.condenseFlow?'"':"")+":"+(e.condenseFlow?"":" "),!Ia(e,t,l,!1,!1))continue;u+=e.dump,i+=u}e.tag=n,e.dump="{"+i+"}"}function Lge(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 Mf("sortKeys must be a boolean or a function");for(a=0,c=s.length;a<c;a+=1){if(p="",!i||a!==0)p+=uT(e,t);if(l=s[a],u=r[l],!Ia(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&&qf===e.dump.charCodeAt(0))p+="?";else p+="? ";if(p+=e.dump,d)p+=uT(e,t);if(!Ia(e,t+1,u,!0,d))continue;if(e.dump&&qf===e.dump.charCodeAt(0))p+=":";else p+=": ";p+=e.dump,n+=p}e.tag=o,e.dump=n||"{}"}function hM(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,gM.call(a.represent)==="[object Function]")i=a.represent(t,c);else if(yM.call(a.represent,c))i=a.represent[c](t,c);else throw new Mf("!<"+a.tag+'> tag resolver accepts not "'+c+'" style');e.dump=i}return!0}return!1}function Ia(e,t,r,i,n,o){if(e.tag=null,e.dump=r,!hM(e,r,!1))hM(e,r,!0);var s=gM.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(Lge(e,t,e.dump,n),l)e.dump="&ref_"+c+e.dump}else if(Dge(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(Nge(e,u,e.dump,n),l)e.dump="&ref_"+c+e.dump}else if(zge(e,u,e.dump),l)e.dump="&ref_"+c+" "+e.dump}else if(s==="[object String]"){if(e.tag!=="?")Oge(e,e.dump,t,o)}else{if(e.skipInvalid)return!1;throw new Mf("unacceptable kind of an object to dump "+s)}if(e.tag!==null&&e.tag!=="?")e.dump="!<"+e.tag+"> "+e.dump}return!0}function Bge(e,t){var r=[],i=[],n,o;dT(e,r,i);for(n=0,o=i.length;n<o;n+=1)t.duplicates.push(r[i[n]]);t.usedDuplicates=Array(o)}function dT(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)dT(e[n],t,r);else{i=Object.keys(e);for(n=0,o=i.length;n<o;n+=1)dT(e[i[n]],t,r)}}function $M(e,t){t=t||{};var r=new Ige(t);if(!r.noRefs)Bge(e,r);if(Ia(r,0,e,!0,!0))return r.dump+`
394
+ `;return""}function jge(e,t){return $M(e,Uf.extend({schema:age},t))}qge.dump=$M;qge.safeDump=jge});var PM=ee(function(Fge,It){var Fy=cM(),RM=OM();function Zy(e){return function(){throw Error("Function "+e+" is deprecated and cannot be used.")}}Fge.Type=Kt();Fge.Schema=_a();Fge.FAILSAFE_SCHEMA=Dy();Fge.JSON_SCHEMA=rT();Fge.CORE_SCHEMA=nT();Fge.DEFAULT_SAFE_SCHEMA=Il();Fge.DEFAULT_FULL_SCHEMA=Bf();Fge.load=Fy.load;Fge.loadAll=Fy.loadAll;Fge.safeLoad=Fy.safeLoad;Fge.safeLoadAll=Fy.safeLoadAll;Fge.dump=RM.dump;Fge.safeDump=RM.safeDump;Fge.YAMLException=kl();Fge.MINIMAL_SCHEMA=Dy();Fge.SAFE_SCHEMA=Il();Fge.DEFAULT_SCHEMA=Bf();Fge.scan=Zy("scan");Fge.parse=Zy("parse");Fge.compose=Zy("compose");Fge.addConstructor=Zy("addConstructor")});var NM=ee(function(nDe,zM){var dye=PM();zM.exports=dye});var yT=ee(function(hT,gT){var Hy=NM(),mT=hT=gT.exports;mT.yaml={parse:Hy.safeLoad.bind(Hy),stringify:Hy.safeDump.bind(Hy)};mT.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)}};mT.javascript={parse:function parse(str,options,wrap){try{if(wrap!==!1)str=`(function() {
396
395
  return `+str.trim()+`;
397
- }());`;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 LM=ee(function(oDe,DM){/*!
396
+ }());`;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 LM=ee(function(iDe,DM){/*!
398
397
  * strip-bom-string <https://github.com/jonschlinkert/strip-bom-string>
399
398
  *
400
399
  * Copyright (c) 2015, 2017, Jon Schlinkert.
401
400
  * Released under the MIT License.
402
- */DM.exports=function(e){if(typeof e==="string"&&e.charAt(0)==="\uFEFF")return e.slice(1);return e}});var Ky=ee(function(pye){var BM=LM(),jM=Df();pye.define=function(e,t,r){Reflect.defineProperty(e,t,{enumerable:!1,configurable:!0,writable:!0,value:r})};pye.isBuffer=function(e){return jM(e)==="buffer"};pye.isObject=function(e){return jM(e)==="object"};pye.toBuffer=function(e){return typeof e==="string"?Buffer.from(e):e};pye.toString=function(e){if(pye.isBuffer(e))return BM(String(e));if(typeof e!=="string")throw TypeError("expected input to be a string or buffer");return BM(e)};pye.arrayify=function(e){return e?Array.isArray(e)?e:[e]:[]};pye.startsWith=function(e,t,r){if(typeof r!=="number")r=t.length;return e.slice(0,r)===t}});var Ff=ee(function(aDe,UM){var Sye=yT(),wye=Ky();UM.exports=function(e){let t=Object.assign({},e);if(t.delimiters=wye.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({},Sye,t.parsers,t.engines),t}});var bT=ee(function(cDe,MM){MM.exports=function(e,t){let r=t.engines[e]||t.engines[vye(e)];if(typeof r>"u")throw Error('gray-matter engine "'+e+'" is not registered');if(typeof r==="function")r={parse:r};return r};function vye(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 xT=ee(function(lDe,FM){var _ye=Df(),kye=bT(),Eye=Ff();FM.exports=function(e,t,r){if(t==null&&r==null)switch(_ye(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=Eye(r);if(t==null){if(!n.data)return e;t=n.data}let o=e.language||n.language,s=kye(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=Ol(a)+Ol(l)+Ol(c);if(typeof e.excerpt==="string"&&e.excerpt!==""){if(i.indexOf(e.excerpt.trim())===-1)u+=Ol(e.excerpt)+Ol(c)}return u+Ol(i)};function Ol(e){return e.slice(-1)!==`
401
+ */DM.exports=function(e){if(typeof e==="string"&&e.charAt(0)==="\uFEFF")return e.slice(1);return e}});var Ky=ee(function(fye){var BM=LM(),jM=Df();fye.define=function(e,t,r){Reflect.defineProperty(e,t,{enumerable:!1,configurable:!0,writable:!0,value:r})};fye.isBuffer=function(e){return jM(e)==="buffer"};fye.isObject=function(e){return jM(e)==="object"};fye.toBuffer=function(e){return typeof e==="string"?Buffer.from(e):e};fye.toString=function(e){if(fye.isBuffer(e))return BM(String(e));if(typeof e!=="string")throw TypeError("expected input to be a string or buffer");return BM(e)};fye.arrayify=function(e){return e?Array.isArray(e)?e:[e]:[]};fye.startsWith=function(e,t,r){if(typeof r!=="number")r=t.length;return e.slice(0,r)===t}});var Ff=ee(function(sDe,UM){var xye=yT(),Sye=Ky();UM.exports=function(e){let t=Object.assign({},e);if(t.delimiters=Sye.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({},xye,t.parsers,t.engines),t}});var bT=ee(function(aDe,MM){MM.exports=function(e,t){let r=t.engines[e]||t.engines[wye(e)];if(typeof r>"u")throw Error('gray-matter engine "'+e+'" is not registered');if(typeof r==="function")r={parse:r};return r};function wye(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 xT=ee(function(cDe,FM){var vye=Df(),_ye=bT(),kye=Ff();FM.exports=function(e,t,r){if(t==null&&r==null)switch(vye(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=kye(r);if(t==null){if(!n.data)return e;t=n.data}let o=e.language||n.language,s=_ye(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=Ol(a)+Ol(l)+Ol(c);if(typeof e.excerpt==="string"&&e.excerpt!==""){if(i.indexOf(e.excerpt.trim())===-1)u+=Ol(e.excerpt)+Ol(c)}return u+Ol(i)};function Ol(e){return e.slice(-1)!==`
403
402
  `?e+`
404
- `:e}});var HM=ee(function(uDe,ZM){var Iye=Ff();ZM.exports=function(e,t){let r=Iye(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 VM=ee(function(dDe,JM){var KM=Df(),Aye=xT(),Rl=Ky();JM.exports=function(e){if(KM(e)!=="object")e={content:e};if(KM(e.data)!=="object")e.data={};if(e.contents&&e.content==null)e.content=e.contents;return Rl.define(e,"orig",Rl.toBuffer(e.content)),Rl.define(e,"language",e.language||""),Rl.define(e,"matter",e.matter||""),Rl.define(e,"stringify",function(t,r){if(r&&r.language)e.language=r.language;return Aye(e,t,r)}),e.content=Rl.toString(e.content),e.isEmpty=!1,e.excerpt="",e}});var GM=ee(function(fDe,WM){var Tye=bT(),Cye=Ff();WM.exports=function(e,t,r){let i=Cye(r),n=Tye(e,i);if(typeof n.parse!=="function")throw TypeError('expected "'+e+'.parse" to be a function');return n.parse(t,i)}});var eF=ee(function(pDe,XM){var $ye=Tt("fs"),Oye=KU(),ST=Ff(),Rye=xT(),QM=HM(),Pye=yT(),zye=VM(),Nye=GM(),YM=Ky();function Lr(e,t){if(e==="")return{data:{},content:e,excerpt:"",orig:e};let r=zye(e),i=Lr.cache[r.content];if(!t){if(i)return r=Object.assign({},i),r.orig=i.orig,r;Lr.cache[r.content]=r}return Dye(r,t)}function Dye(e,t){let r=ST(t),i=r.delimiters[0],n=`
405
- `+r.delimiters[1],o=e.content;if(r.language)e.language=r.language;let s=i.length;if(!YM.startsWith(o,i,s))return QM(e,r),e;if(o.charAt(s)===i.slice(-1))return e;o=o.slice(s);let a=o.length,c=Lr.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=Nye(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]===`
406
- `)e.content=e.content.slice(1)}if(QM(e,r),r.sections===!0||typeof r.section==="function")Oye(e,r.section);return e}Lr.engines=Pye;Lr.stringify=function(e,t,r){if(typeof e==="string")e=Lr(e,r);return Rye(e,t,r)};Lr.read=function(e,t){let r=$ye.readFileSync(e,"utf8"),i=Lr(r,t);return i.path=e,i};Lr.test=function(e,t){return YM.startsWith(e,ST(t).delimiters[0])};Lr.language=function(e,t){let i=ST(t).delimiters[0];if(Lr.test(e))e=e.slice(i.length);let n=e.slice(0,e.search(/\r?\n/));return{raw:n,name:n?n.trim():""}};Lr.cache={};Lr.clearCache=function(){Lr.cache={}};XM.exports=Lr});var Lye;var Jy=x(()=>{Lye=rc(eF(),1)});var tF=x(()=>{Jy();XA()});var Bye,Vy,jye,vT="data-ask-sheet",qye;var _T=x(()=>{Re();Bye=f.object({public:f.boolean(),preview:f.boolean()}),Vy=f.object({name:f.string().trim().min(1).max(200),url:f.string().url().optional()}),jye=f.object({sources:f.array(f.object({id:f.string(),title:f.string(),brain:Vy.optional()}))}),qye=`body *:not([${vT}], [${vT}] *) { -webkit-backdrop-filter: none !important; backdrop-filter: none !important; }`});var rF,Uye;var nF=x(()=>{Re();rF=f.object({type:f.literal("event"),event:f.string().min(1),fromState:f.string().min(1).optional()}),Uye=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:rF})});var Mye,kDe,Pl,Fye,Zye,iF,EDe,Hye,Kye,oF;var sF=x(()=>{Re();Mye=f.strictObject({messageCharacters:f.number().int().positive(),requestTimeoutSeconds:f.number().int().positive().max(2147483)}),kDe=f.strictObject({limits:Mye,maxCostMicroUsd:f.number().int().positive()}),Pl=f.number().int().nonnegative(),Fye=f.strictObject({modelCalls:Pl,inputTokens:Pl,cachedInputTokens:Pl,outputTokens:Pl,reasoningTokens:Pl,embeddingTokens:Pl}),Zye=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"])})]),iF=f.strictObject({usage:Fye,cost:Zye}),EDe=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()}),Hye=f.enum(["in-scope","off-topic","abusive","injection","harmful"]),Kye=Hye.exclude(["in-scope"]),oF=f.discriminatedUnion("outcome",[f.strictObject({outcome:f.literal("answered")}),f.strictObject({outcome:f.literal("refused"),category:Kye}),f.strictObject({outcome:f.literal("unscreened")})])});var aF,cF,lF,uF,dF,fF,Wy,pF,mF,hF,gF,yF,bF,xF,SF,Jye;var kT=x(()=>{Re();_T();sF();aF=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()}),cF=f.enum(["approval-requested","approval-responded","output-available","output-denied","output-error"]),lF=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:cF,output:f.unknown().optional(),error:f.string().optional()}),uF=f.object({entityType:f.string().optional(),entityId:f.string().optional(),attachmentType:f.string().optional()}),dF=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:uF.optional()}),fF=f.object({kind:f.literal("attachment"),id:f.string(),jobId:f.string().optional(),title:f.string(),description:f.string().optional(),attachment:dF}),Wy=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:Vy.optional()}),pF=f.object({kind:f.literal("sources"),id:f.string().min(1),title:f.string().min(1).optional(),sources:f.array(Wy).min(1)}),mF=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()}),hF=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()}),gF=f.discriminatedUnion("type",[mF,hF]),yF=f.object({kind:f.literal("actions"),id:f.string().min(1),title:f.string().min(1).optional(),defaultOpen:f.boolean().optional(),actions:f.array(gF).min(1)}),bF=f.discriminatedUnion("kind",[lF,fF,pF,yF]),xF=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()}),SF=f.object({faqId:f.string().min(1)}),Jye=f.object({text:f.string(),error:f.string().optional(),toolResults:f.array(xF).optional(),cards:f.array(bF).optional(),pendingConfirmations:f.array(aF).optional(),usage:f.object({promptTokens:f.number(),completionTokens:f.number(),totalTokens:f.number()}),guestSettlement:iF.optional(),guestScreening:oF.optional(),askedBefore:SF.optional()})});var Vye,wF,Wye;var vF=x(()=>{Re();kT();Vye=f.object({question:f.string().trim().min(1)}),wF=f.object({faqId:f.string().min(1),answer:f.string().trim().min(1),sources:f.array(Wy).default([])}),Wye=f.object({hit:wF.optional()})});var _F,Gye,kF,Qye;var EF=x(()=>{Re();_F=f.enum(["admin","trusted","public"]),Gye=f.object({conversationId:f.string().min(1),message:f.string(),interfaceType:f.string().min(1),channelId:f.string().optional(),channelName:f.string().optional(),userPermissionLevel:_F}),kF=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()}),Qye=f.object({items:f.array(kF).default([])})});var zl;var ET=x(()=>{Re();zl=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 Yye,IF,Xye;var AF=x(()=>{Re();ET();Yye=f.object({actor:zl}),IF=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"])}),Xye=f.object({principal:IF.nullable()})});var IT,ebe,tbe;var TF=x(()=>{Re();IT=f.strictObject({name:f.string().min(1).optional(),address:f.email()}),ebe=f.strictObject({personId:f.string().min(1).max(200),displayName:f.string().trim().min(1).max(200),permissionLevel:f.enum(["admin","trusted","public"])}),tbe=f.strictObject({messageId:f.string().min(1),sourceRef:f.string().min(1),threadId:f.string().min(1).optional(),from:IT,replyTo:IT.optional(),to:f.array(IT),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:ebe.optional()})});var rbe,nbe,ibe,AT,obe,sbe;var CF=x(()=>{Re();rbe=f.strictObject({permissionLevel:f.enum(["admin","trusted","public"])}),nbe=f.custom((e)=>typeof AbortSignal<"u"&&e instanceof AbortSignal),ibe=f.strictObject({sourceRef:f.string().regex(/^imap:[a-f0-9]{64}$/),actor:rbe,signal:nbe.optional()}),AT=f.strictObject({name:f.string().trim().min(1).max(300).optional(),address:f.email().max(320)}),obe=f.strictObject({messageId:f.string().trim().min(1).max(2000),from:AT,replyTo:AT.optional(),to:f.array(AT).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()}),sbe=f.discriminatedUnion("kind",[f.strictObject({kind:f.literal("available"),message:obe}),f.strictObject({kind:f.literal("unavailable")})])});var $F=()=>{};var OF=x(()=>{$F()});var abe;var RF=x(()=>{Re();abe=f.object({url:f.string(),authToken:f.string().optional()})});var cbe;var PF=x(()=>{Re();cbe=f.object({success:f.boolean(),entityId:f.string().optional(),error:f.string().optional()})});var zF=()=>{};var Gy,lbe;var NF=x(()=>{Re();Gy=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(Gy),f.record(f.string(),Gy)])),lbe=f.record(f.string(),Gy)});var ube;var DF=x(()=>{Re();ube=f.enum(["user","assistant"])});var LF,ns;var BF=x(()=>{Re();LF=f.object({entityType:f.string().min(1),entityId:f.string().min(1),contentHash:f.string().min(1).optional()}),ns=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:LF.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 jF=()=>{};var dbe,fbe;var qF=x(()=>{Re();dbe=f.object({entityType:f.string().min(1),entityId:f.string(),metadata:f.record(f.string(),f.unknown()).default({}),content:f.string().default("")}),fbe=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 UF=()=>{};var pbe;var MF=x(()=>{Re();pbe=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 FF,ZF,HF,mbe;var KF=x(()=>{Jy();Re();FF=f.object({audiences:f.array(f.string()).optional(),positioning:f.string().optional()}),ZF=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()}),HF=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()}),mbe=f.object({name:f.string().describe("Style guide name"),messaging:FF.optional(),voice:ZF.optional(),visual:HF.optional()})});var hbe;var JF=x(()=>{Re();hbe=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 gbe,ybe,VF,WF;var GF=x(()=>{Re();gbe=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"),ybe=f.object({message:f.string()}).describe("simpleTextResponse"),VF=f.object({success:f.boolean(),entityId:f.string().optional(),message:f.string()}).describe("createEntityResponse"),WF=f.object({success:f.boolean(),entityId:f.string(),changes:f.array(f.string()).optional(),message:f.string()}).describe("updateEntityResponse")});var QF,kLe,YF,bbe,xbe;var XF=x(()=>{Re();QF={recipientMissing:"Notification recipient missing",transportMissing:"Notification transport missing",deliveryFailed:"Notification delivery failed"},kLe=new RegExp(`^${QF.deliveryFailed}: ([a-z0-9_:.-]{1,80})$`),YF=f.discriminatedUnion("type",[f.strictObject({type:f.literal("email"),address:f.email()})]),bbe=f.strictObject({recipient:YF.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()}),xbe=f.discriminatedUnion("status",[f.strictObject({status:f.literal("sent"),deliveryId:f.string().optional()}),f.strictObject({status:f.literal("failed")})])});var Sbe;var eZ=x(()=>{Re();Sbe=f.strictObject({titles:f.array(f.string().trim().min(1).max(500)).max(20)})});var wbe,vbe;var tZ=x(()=>{Re();wbe=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)}),vbe=f.strictObject({noteId:f.string(),created:f.boolean()})});var is=x(()=>{XA();tF();_T();nF();kT();vF();EF();ET();AF();TF();CF();OF();RF();PF();zF();NF();DF();BF();jF();qF();UF();MF();KF();JF();GF();XF();eZ();tZ()});var rZ=x(()=>{Nf();is()});var nZ=x(()=>{Nf();is()});var iZ=()=>{};function B(e,t){Ebe(Boolean(e),!1,!0,"ok","Expected value to be truthy",t)}function Ebe(e,t,r,i,n,o){if(!e)throw o instanceof Error?o:new oZ(o||n,t,r,i,!o)}var oZ;var tt=x(()=>{iZ();oZ=class oZ 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 Aa(e,t){let r=t||Ibe,i=typeof r.includeImageAlt==="boolean"?r.includeImageAlt:!0,n=typeof r.includeHtml==="boolean"?r.includeHtml:!0;return aZ(e,i,n)}function aZ(e,t,r){if(Abe(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 sZ(e.children,t,r)}if(Array.isArray(e))return sZ(e,t,r);return""}function sZ(e,t,r){let i=[],n=-1;while(++n<e.length)i[n]=aZ(e[n],t,r);return i.join("")}function Abe(e){return Boolean(e&&typeof e==="object")}var Ibe;var cZ=x(()=>{Ibe={}});var Qy=x(()=>{cZ()});var TT;var lZ=x(()=>{TT={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:`
407
- `,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 Nl(e){return Tbe.call(TT,e)?TT[e]:!1}var Tbe;var Yy=x(()=>{lZ();Tbe={}.hasOwnProperty});var w;var uZ=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 dZ=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 fZ=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 ln;var pZ=x(()=>{ln={ht:"\t",lf:`
408
- `,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(()=>{uZ();dZ();fZ();pZ()});function lr(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 Br(e,t){if(e.length>0)return lr(e,e.length,0,t),e;return t}var os=x(()=>{Fe()});function hZ(e){let t={},r=-1;while(++r<e.length)Cbe(t,e[r]);return t}function Cbe(e,t){let r;for(r in t){let n=(mZ.call(e,r)?e[r]:void 0)||(e[r]={}),o=t[r],s;if(o)for(s in o){if(!mZ.call(n,s))n[s]=[];let a=o[s];$be(n[s],Array.isArray(a)?a:a?[a]:[])}}}function $be(e,t){let r=-1,i=[];while(++r<t.length)(t[r].add==="after"?e:i).push(t[r]);lr(e,0,0,i)}var mZ;var gZ=x(()=>{os();mZ={}.hasOwnProperty});function Xy(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 ln.replacementCharacter;return String.fromCodePoint(r)}var CT=x(()=>{Fe()});function Yi(e){return e.replace(/[\t\n\r ]+/g,ln.space).replace(/^ | $/g,"").toLowerCase().toUpperCase()}var eb=x(()=>{Fe()});function Zf(e){return e!==null&&(e<w.space||e===w.del)}function ve(e){return e!==null&&e<w.horizontalTab}function Ot(e){return e!==null&&(e<w.nul||e===w.space)}function Me(e){return e===w.horizontalTab||e===w.virtualSpace||e===w.space}function ss(e){return t;function t(r){return r!==null&&r>-1&&e.test(String.fromCharCode(r))}}var un,jr,yZ,Hf,bZ,xZ,SZ,wZ;var ot=x(()=>{Fe();un=ss(/[A-Za-z]/),jr=ss(/[\dA-Za-z]/),yZ=ss(/[#-'*+\--9=?A-Z^-~]/);Hf=ss(/\d/),bZ=ss(/[\dA-Fa-f]/),xZ=ss(/[!-/:-@[-`{-~]/);SZ=ss(/\p{P}|\p{S}/u),wZ=ss(/\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 Qt=x(()=>{ot()});function Obe(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 vZ;var _Z=x(()=>{tt();Qt();ot();Fe();vZ={tokenize:Obe}});function Rbe(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 lr(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(kZ,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(kZ,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++;lr(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 Pbe(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 EZ,kZ;var IZ=x(()=>{tt();Qt();ot();os();Fe();EZ={tokenize:Rbe},kZ={tokenize:Pbe}});function Dl(e){if(e===w.eof||Ot(e)||wZ(e))return be.characterGroupWhitespace;if(SZ(e))return be.characterGroupPunctuation}var $T=x(()=>{ot();Fe()});function Ll(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 zbe(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(AZ(d,-c),AZ(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=Br(l,[["enter",e[i][1],t],["exit",e[i][1],t]]);if(l=Br(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=Br(l,Ll(t.parser.constructs.insideSpan.null,e.slice(i+1,r),t)),l=Br(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=Br(l,[["enter",e[r][1],t],["exit",e[r][1],t]]);else u=0;lr(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 Nbe(e,t){let r=this.parser.constructs.attentionMarkers.null,i=this.previous,n=Dl(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=Dl(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 AZ(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var Kf;var TZ=x(()=>{tt();os();$T();Fe();Kf={name:"attention",resolveAll:zbe,tokenize:Nbe}});function Dbe(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(un(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||jr(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||jr(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||Zf(m))return r(m);return e.consume(m),c}function l(m){if(m===w.atSign)return e.consume(m),u;if(yZ(m))return e.consume(m),l;return r(m)}function u(m){return jr(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||jr(m))&&i++<be.autolinkDomainSizeMax){let y=m===w.dash?p:d;return e.consume(m),y}return r(m)}}var OT;var CZ=x(()=>{tt();ot();Fe();OT={name:"autolink",tokenize:Dbe}});function Lbe(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 as;var tb=x(()=>{Qt();ot();Fe();as={partial:!0,tokenize:Lbe}});function Bbe(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 jbe(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(rb,t,r)(s)}}function qbe(e){e.exit(S.blockQuote)}var rb;var $Z=x(()=>{tt();Qt();ot();Fe();rb={continuation:{tokenize:jbe},exit:qbe,name:"blockQuote",tokenize:Bbe}});function Ube(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(xZ(o))return e.enter(S.characterEscapeValue),e.consume(o),e.exit(S.characterEscapeValue),e.exit(S.characterEscape),t;return r(o)}}var nb;var OZ=x(()=>{tt();ot();Fe();nb={name:"characterEscape",tokenize:Ube}});function Mbe(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=jr,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=bZ,u;return e.enter(S.characterReferenceValue),o=be.characterReferenceDecimalSizeMax,s=Hf,u(d)}function u(d){if(d===w.semicolon&&n){let p=e.exit(S.characterReferenceValue);if(s===jr&&!Nl(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 ib;var RZ=x(()=>{tt();Yy();ot();Fe();ib={name:"characterReference",tokenize:Mbe}});function Fbe(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(PZ,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(PZ,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 Zbe(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 PZ,ob;var zZ=x(()=>{tt();Qt();ot();Fe();PZ={partial:!0,tokenize:Zbe},ob={concrete:!0,name:"codeFenced",tokenize:Fbe}});function Kbe(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(Hbe,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 Jbe(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 Jf,Hbe;var NZ=x(()=>{tt();Qt();ot();Fe();Jf={name:"codeIndented",tokenize:Kbe},Hbe={partial:!0,tokenize:Jbe}});function Vbe(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 DZ(e){return e!==w.graveAccent||this.events[this.events.length-1][1].type===S.characterEscape}function Wbe(e,t,r){let i=this,n=0,o,s;return a;function a(p){return B(p===w.graveAccent,"expected `` ` ``"),B(DZ.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 RT;var LZ=x(()=>{tt();ot();Fe();RT={name:"codeText",previous:DZ,resolve:Vbe,tokenize:Wbe}});class PT{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)Vf(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),Vf(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),Vf(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);Vf(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,Number.POSITIVE_INFINITY);Vf(this.left,t.reverse())}}}function Vf(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 BZ=x(()=>{Fe()});function sb(e){let t={},r=-1,i,n,o,s,a,c,l,u=new PT(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,Gbe(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 lr(e,0,Number.POSITIVE_INFINITY,u.slice(0)),!l}function Gbe(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 zT=x(()=>{tt();os();Fe();BZ()});function Ybe(e){return sb(e),e}function Xbe(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(Qbe,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 exe(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 NT,Qbe;var jZ=x(()=>{tt();Qt();ot();zT();Fe();NT={resolve:Ybe,tokenize:Xbe},Qbe={partial:!0,tokenize:exe}});function ab(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||Zf(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||Ot(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||Zf(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 DT=x(()=>{ot();Fe()});function cb(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 LT=x(()=>{tt();ot();Fe()});function lb(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 BT=x(()=>{Qt();ot();Fe()});function Ta(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 jT=x(()=>{Qt();ot();Fe()});function rxe(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 `[`"),cb.call(i,e,a,r,S.definitionLabel,S.definitionLabelMarker,S.definitionLabelString)(m)}function a(m){if(n=Yi(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 Ot(m)?Ta(e,l)(m):l(m)}function l(m){return ab(e,u,r,S.definitionDestination,S.definitionDestinationLiteral,S.definitionDestinationLiteralMarker,S.definitionDestinationRaw,S.definitionDestinationString)(m)}function u(m){return e.attempt(txe,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 nxe(e,t,r){return i;function i(a){return Ot(a)?Ta(e,n)(a):r(a)}function n(a){return lb(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 qT,txe;var qZ=x(()=>{tt();DT();LT();Qt();BT();jT();ot();eb();Fe();qT={name:"definition",tokenize:rxe},txe={partial:!0,tokenize:nxe}});function ixe(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 UT;var UZ=x(()=>{tt();ot();Fe();UT={name:"hardBreakEscape",tokenize:ixe}});function oxe(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},lr(e,i,r-i+1,[["enter",n,t],["enter",o,t],["exit",o,t],["exit",n,t]]);return e}function sxe(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||Ot(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||Ot(u))return e.exit(S.atxHeadingText),a(u);return e.consume(u),l}}var MT;var MZ=x(()=>{tt();Qt();ot();os();Fe();MT={name:"headingAtx",resolve:oxe,tokenize:sxe}});var FZ,FT;var ZZ=x(()=>{FZ=["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"],FT=["pre","script","style","textarea"]});function lxe(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 uxe(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(un(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(un(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(un(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||Ot(C)){let Se=C===w.slash,Ee=s.toLowerCase();if(!Se&&!o&&FT.includes(Ee))return n=be.htmlRaw,i.interrupt?t(C):P(C);if(FZ.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||jr(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||un(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||jr(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||Ot(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(axe,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(cxe,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(FT.includes(Se))return e.consume(C),te;return P(C)}if(un(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 dxe(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 fxe(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(as,t,r)}}var ZT,axe,cxe;var HZ=x(()=>{tt();ot();ZZ();Fe();tb();ZT={concrete:!0,name:"htmlFlow",resolveTo:lxe,tokenize:uxe},axe={partial:!0,tokenize:fxe},cxe={partial:!0,tokenize:dxe}});function pxe(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(un(_))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(un(_))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(un(_))return e.consume(_),E;return r(_)}function E(_){if(_===w.dash||jr(_))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||jr(_))return e.consume(_),D;if(_===w.slash||_===w.greaterThan||Ot(_))return H(_);return r(_)}function H(_){if(_===w.slash)return e.consume(_),O;if(_===w.colon||_===w.underscore||un(_))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||jr(_))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||Ot(_))return H(_);return e.consume(_),I}function R(_){if(_===w.slash||_===w.greaterThan||Ot(_))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 HT;var KZ=x(()=>{tt();Qt();ot();Fe();HT={name:"htmlText",tokenize:pxe}});function yxe(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)lr(e,0,e.length,r);return e}function bxe(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=Br(a,e.slice(o+1,o+i+3)),a=Br(a,[["enter",u,t]]),B(t.parser.constructs.insideSpan.null,"expected `insideSpan.null` to be populated"),a=Br(a,Ll(t.parser.constructs.insideSpan.null,e.slice(o+i+4,s-3),t)),a=Br(a,[["exit",u,t],e[s-2],e[s-1],["exit",l,t]]),a=Br(a,e.slice(s+1)),a=Br(a,[["exit",c,t]]),lr(e,o,e.length,a),e}function xxe(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(Yi(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(mxe,u,s?u:d)(p);if(p===w.leftSquareBracket)return e.attempt(hxe,u,s?l:d)(p);return s?u(p):d(p)}function l(p){return e.attempt(gxe,u,d)(p)}function u(p){return t(p)}function d(p){return o._balanced=!0,r(p)}}function Sxe(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 Ot(d)?Ta(e,o)(d):o(d)}function o(d){if(d===w.rightParenthesis)return u(d);return ab(e,s,a,S.resourceDestination,S.resourceDestinationLiteral,S.resourceDestinationLiteralMarker,S.resourceDestinationRaw,S.resourceDestinationString,be.linkResourceDestinationBalanceMax)(d)}function s(d){return Ot(d)?Ta(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 lb(e,l,r,S.resourceTitle,S.resourceTitleMarker,S.resourceTitleString)(d);return u(d)}function l(d){return Ot(d)?Ta(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 wxe(e,t,r){let i=this;return n;function n(a){return B(a===w.leftSquareBracket,"expected left bracket"),cb.call(i,e,o,s,S.reference,S.referenceMarker,S.referenceString)(a)}function o(a){return i.parser.defined.includes(Yi(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)))?t(a):r(a)}function s(a){return r(a)}}function vxe(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 Ca,mxe,hxe,gxe;var ub=x(()=>{tt();DT();LT();BT();jT();ot();os();eb();Fe();Ca={name:"labelEnd",resolveAll:yxe,resolveTo:bxe,tokenize:xxe},mxe={tokenize:Sxe},hxe={tokenize:wxe},gxe={tokenize:vxe}});function _xe(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 KT;var JZ=x(()=>{tt();Fe();ub();KT={name:"labelStartImage",resolveAll:Ca.resolveAll,tokenize:_xe}});function kxe(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 JT;var VZ=x(()=>{tt();Fe();ub();JT={name:"labelStartLink",resolveAll:Ca.resolveAll,tokenize:kxe}});function Exe(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 Wf;var WZ=x(()=>{tt();Qt();ot();Fe();Wf={name:"lineEnding",tokenize:Exe}});function Ixe(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 $a;var VT=x(()=>{tt();Qt();ot();Fe();$a={name:"thematicBreak",tokenize:Ixe}});function Cxe(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:Hf(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($a,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"),Hf(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(as,i.interrupt?r:u,e.attempt(Axe,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 $xe(e,t,r){let i=this;return B(i.containerState,"expected state"),i.containerState._closeFlow=void 0,e.check(as,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(Txe,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(vr,t,r),S.linePrefix,i.parser.constructs.disable.null.includes("codeIndented")?void 0:be.tabSize)(a)}}function Oxe(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 Rxe(e){B(this.containerState,"expected state"),B(typeof this.containerState.type==="string","expected type"),e.exit(this.containerState.type)}function Pxe(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 vr,Axe,Txe;var GZ=x(()=>{tt();Qt();ot();Fe();tb();VT();vr={continuation:{tokenize:$xe},exit:Rxe,name:"list",tokenize:Cxe},Axe={partial:!0,tokenize:Pxe},Txe={partial:!0,tokenize:Oxe}});function zxe(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 Nxe(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 db;var QZ=x(()=>{tt();Qt();ot();Fe();db={name:"setextUnderline",resolveTo:zxe,tokenize:Nxe}});var WT=x(()=>{TZ();CZ();tb();$Z();OZ();RZ();zZ();NZ();LZ();jZ();qZ();UZ();MZ();HZ();KZ();ub();JZ();VZ();WZ();GZ();QZ();VT()});function Dxe(e){let t=this,r=e.attempt(as,i,e.attempt(this.parser.constructs.flowInitial,n,Ze(e,e.attempt(this.parser.constructs.flow,n,e.attempt(NT,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 YZ;var XZ=x(()=>{tt();WT();Qt();ot();Fe();YZ={tokenize:Dxe}});function n3(e){return{resolveAll:i3(e==="text"?Lxe: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 i3(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 Lxe(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 e3,t3,r3;var GT=x(()=>{tt();Fe();e3={resolveAll:i3()},t3=n3("string"),r3=n3("text")});var QT={};tr(QT,{attentionMarkers:()=>Hxe,contentInitial:()=>jxe,disable:()=>Kxe,document:()=>Bxe,flow:()=>Uxe,flowInitial:()=>qxe,insideSpan:()=>Zxe,string:()=>Mxe,text:()=>Fxe});var Bxe,jxe,qxe,Uxe,Mxe,Fxe,Zxe,Hxe,Kxe;var o3=x(()=>{WT();Fe();GT();Bxe={[w.asterisk]:vr,[w.plusSign]:vr,[w.dash]:vr,[w.digit0]:vr,[w.digit1]:vr,[w.digit2]:vr,[w.digit3]:vr,[w.digit4]:vr,[w.digit5]:vr,[w.digit6]:vr,[w.digit7]:vr,[w.digit8]:vr,[w.digit9]:vr,[w.greaterThan]:rb},jxe={[w.leftSquareBracket]:qT},qxe={[w.horizontalTab]:Jf,[w.virtualSpace]:Jf,[w.space]:Jf},Uxe={[w.numberSign]:MT,[w.asterisk]:$a,[w.dash]:[db,$a],[w.lessThan]:ZT,[w.equalsTo]:db,[w.underscore]:$a,[w.graveAccent]:ob,[w.tilde]:ob},Mxe={[w.ampersand]:ib,[w.backslash]:nb},Fxe={[w.carriageReturn]:Wf,[w.lineFeed]:Wf,[w.carriageReturnLineFeed]:Wf,[w.exclamationMark]:KT,[w.ampersand]:ib,[w.asterisk]:Kf,[w.lessThan]:[OT,HT],[w.leftSquareBracket]:JT,[w.backslash]:[UT,nb],[w.rightSquareBracket]:Ca,[w.underscore]:Kf,[w.graveAccent]:RT},Zxe={null:[Kf,e3]},Hxe={null:[w.asterisk,w.underscore]},Kxe={null:[]}});var a3=ee(function(W4e,s3){var Bl=1000,jl=Bl*60,ql=jl*60,Oa=ql*24,Jxe=Oa*7,Vxe=Oa*365.25;s3.exports=function(e,t){t=t||{};var r=typeof e;if(r==="string"&&e.length>0)return Wxe(e);else if(r==="number"&&isFinite(e))return t.long?Qxe(e):Gxe(e);throw Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function Wxe(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*Vxe;case"weeks":case"week":case"w":return r*Jxe;case"days":case"day":case"d":return r*Oa;case"hours":case"hour":case"hrs":case"hr":case"h":return r*ql;case"minutes":case"minute":case"mins":case"min":case"m":return r*jl;case"seconds":case"second":case"secs":case"sec":case"s":return r*Bl;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}function Gxe(e){var t=Math.abs(e);if(t>=Oa)return Math.round(e/Oa)+"d";if(t>=ql)return Math.round(e/ql)+"h";if(t>=jl)return Math.round(e/jl)+"m";if(t>=Bl)return Math.round(e/Bl)+"s";return e+"ms"}function Qxe(e){var t=Math.abs(e);if(t>=Oa)return fb(e,t,Oa,"day");if(t>=ql)return fb(e,t,ql,"hour");if(t>=jl)return fb(e,t,jl,"minute");if(t>=Bl)return fb(e,t,Bl,"second");return e+" ms"}function fb(e,t,r,i){var n=t>=r*1.5;return Math.round(e/r)+" "+i+(n?"s":"")}});var YT=ee(function(G4e,c3){function Yxe(e){r.debug=r,r.default=r,r.coerce=c,r.disable=s,r.enable=n,r.enabled=a,r.humanize=a3(),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}c3.exports=Yxe});var u3=ee(function(l3,pb){l3.formatArgs=eSe;l3.save=tSe;l3.load=rSe;l3.useColors=Xxe;l3.storage=nSe();l3.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`.")}})();l3.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 Xxe(){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 eSe(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+pb.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)}l3.log=console.debug||console.log||(()=>{});function tSe(e){try{if(e)l3.storage.setItem("debug",e);else l3.storage.removeItem("debug")}catch(t){}}function rSe(){let e;try{e=l3.storage.getItem("debug")||l3.storage.getItem("DEBUG")}catch(t){}if(!e&&typeof process<"u"&&"env"in process)e=process.env.DEBUG;return e}function nSe(){try{return localStorage}catch(e){}}pb.exports=YT()(l3);var{formatters:iSe}=pb.exports;iSe.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}});var f3=ee(function(Y4e,d3){d3.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 h3=ee(function(X4e,m3){var fSe=Tt("os"),p3=Tt("tty"),En=f3(),{env:Yt}=process,cs;if(En("no-color")||En("no-colors")||En("color=false")||En("color=never"))cs=0;else if(En("color")||En("colors")||En("color=true")||En("color=always"))cs=1;if("FORCE_COLOR"in Yt)if(Yt.FORCE_COLOR==="true")cs=1;else if(Yt.FORCE_COLOR==="false")cs=0;else cs=Yt.FORCE_COLOR.length===0?1:Math.min(parseInt(Yt.FORCE_COLOR,10),3);function XT(e){if(e===0)return!1;return{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function eC(e,t){if(cs===0)return 0;if(En("color=16m")||En("color=full")||En("color=truecolor"))return 3;if(En("color=256"))return 2;if(e&&!t&&cs===void 0)return 0;let r=cs||0;if(Yt.TERM==="dumb")return r;if(process.platform==="win32"){let i=fSe.release().split(".");if(Number(i[0])>=10&&Number(i[2])>=10586)return Number(i[2])>=14931?3:2;return 1}if("CI"in Yt){if(["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some((i)=>(i in Yt))||Yt.CI_NAME==="codeship")return 1;return r}if("TEAMCITY_VERSION"in Yt)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(Yt.TEAMCITY_VERSION)?1:0;if(Yt.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in Yt){let i=parseInt((Yt.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(Yt.TERM_PROGRAM){case"iTerm.app":return i>=3?3:2;case"Apple_Terminal":return 2}}if(/-256(color)?$/i.test(Yt.TERM))return 2;if(/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(Yt.TERM))return 1;if("COLORTERM"in Yt)return 1;return r}function pSe(e){let t=eC(e,e&&e.isTTY);return XT(t)}m3.exports={supportsColor:pSe,stdout:XT(eC(!0,p3.isatty(1))),stderr:XT(eC(!0,p3.isatty(2)))}});var x3=ee(function(y3,hb){var mSe=Tt("tty"),mb=Tt("util");y3.init=wSe;y3.log=bSe;y3.formatArgs=gSe;y3.save=xSe;y3.load=SSe;y3.useColors=hSe;y3.destroy=mb.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");y3.colors=[6,2,3,4,5,1];try{let e=h3();if(e&&(e.stderr||e).level>=2)y3.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){}y3.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 hSe(){return"colors"in y3.inspectOpts?Boolean(y3.inspectOpts.colors):mSe.isatty(process.stderr.fd)}function gSe(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(`
403
+ `:e}});var HM=ee(function(lDe,ZM){var Eye=Ff();ZM.exports=function(e,t){let r=Eye(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 VM=ee(function(uDe,JM){var KM=Df(),Iye=xT(),Rl=Ky();JM.exports=function(e){if(KM(e)!=="object")e={content:e};if(KM(e.data)!=="object")e.data={};if(e.contents&&e.content==null)e.content=e.contents;return Rl.define(e,"orig",Rl.toBuffer(e.content)),Rl.define(e,"language",e.language||""),Rl.define(e,"matter",e.matter||""),Rl.define(e,"stringify",function(t,r){if(r&&r.language)e.language=r.language;return Iye(e,t,r)}),e.content=Rl.toString(e.content),e.isEmpty=!1,e.excerpt="",e}});var GM=ee(function(dDe,WM){var Aye=bT(),Tye=Ff();WM.exports=function(e,t,r){let i=Tye(r),n=Aye(e,i);if(typeof n.parse!=="function")throw TypeError('expected "'+e+'.parse" to be a function');return n.parse(t,i)}});var eF=ee(function(fDe,XM){var Cye=Tt("fs"),$ye=KU(),ST=Ff(),Oye=xT(),QM=HM(),Rye=yT(),Pye=VM(),zye=GM(),YM=Ky();function Lr(e,t){if(e==="")return{data:{},content:e,excerpt:"",orig:e};let r=Pye(e),i=Lr.cache[r.content];if(!t){if(i)return r=Object.assign({},i),r.orig=i.orig,r;Lr.cache[r.content]=r}return Nye(r,t)}function Nye(e,t){let r=ST(t),i=r.delimiters[0],n=`
404
+ `+r.delimiters[1],o=e.content;if(r.language)e.language=r.language;let s=i.length;if(!YM.startsWith(o,i,s))return QM(e,r),e;if(o.charAt(s)===i.slice(-1))return e;o=o.slice(s);let a=o.length,c=Lr.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=zye(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]===`
405
+ `)e.content=e.content.slice(1)}if(QM(e,r),r.sections===!0||typeof r.section==="function")$ye(e,r.section);return e}Lr.engines=Rye;Lr.stringify=function(e,t,r){if(typeof e==="string")e=Lr(e,r);return Oye(e,t,r)};Lr.read=function(e,t){let r=Cye.readFileSync(e,"utf8"),i=Lr(r,t);return i.path=e,i};Lr.test=function(e,t){return YM.startsWith(e,ST(t).delimiters[0])};Lr.language=function(e,t){let i=ST(t).delimiters[0];if(Lr.test(e))e=e.slice(i.length);let n=e.slice(0,e.search(/\r?\n/));return{raw:n,name:n?n.trim():""}};Lr.cache={};Lr.clearCache=function(){Lr.cache={}};XM.exports=Lr});var Dye;var Jy=x(()=>{Dye=rc(eF(),1)});var tF=x(()=>{Jy();XA()});var Lye,Vy,Bye,vT="data-ask-sheet",jye;var _T=x(()=>{Re();Lye=f.object({public:f.boolean(),preview:f.boolean()}),Vy=f.object({name:f.string().trim().min(1).max(200),url:f.string().url().optional()}),Bye=f.object({sources:f.array(f.object({id:f.string(),title:f.string(),brain:Vy.optional()}))}),jye=`body *:not([${vT}], [${vT}] *) { -webkit-backdrop-filter: none !important; backdrop-filter: none !important; }`});var rF,qye;var nF=x(()=>{Re();rF=f.object({type:f.literal("event"),event:f.string().min(1),fromState:f.string().min(1).optional()}),qye=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:rF})});var Uye,_De,Pl,Mye,Fye,iF,kDe,Zye,Hye,oF;var sF=x(()=>{Re();Uye=f.strictObject({messageCharacters:f.number().int().positive(),requestTimeoutSeconds:f.number().int().positive().max(2147483)}),_De=f.strictObject({limits:Uye,maxCostMicroUsd:f.number().int().positive()}),Pl=f.number().int().nonnegative(),Mye=f.strictObject({modelCalls:Pl,inputTokens:Pl,cachedInputTokens:Pl,outputTokens:Pl,reasoningTokens:Pl,embeddingTokens:Pl}),Fye=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"])})]),iF=f.strictObject({usage:Mye,cost:Fye}),kDe=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()}),Zye=f.enum(["in-scope","off-topic","abusive","injection","harmful"]),Hye=Zye.exclude(["in-scope"]),oF=f.discriminatedUnion("outcome",[f.strictObject({outcome:f.literal("answered")}),f.strictObject({outcome:f.literal("refused"),category:Hye}),f.strictObject({outcome:f.literal("unscreened")})])});var aF,cF,lF,uF,dF,fF,Wy,pF,mF,hF,gF,yF,bF,xF,SF,Kye;var kT=x(()=>{Re();_T();sF();aF=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()}),cF=f.enum(["approval-requested","approval-responded","output-available","output-denied","output-error"]),lF=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:cF,output:f.unknown().optional(),error:f.string().optional()}),uF=f.object({entityType:f.string().optional(),entityId:f.string().optional(),attachmentType:f.string().optional()}),dF=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:uF.optional()}),fF=f.object({kind:f.literal("attachment"),id:f.string(),jobId:f.string().optional(),title:f.string(),description:f.string().optional(),attachment:dF}),Wy=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:Vy.optional()}),pF=f.object({kind:f.literal("sources"),id:f.string().min(1),title:f.string().min(1).optional(),sources:f.array(Wy).min(1)}),mF=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()}),hF=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()}),gF=f.discriminatedUnion("type",[mF,hF]),yF=f.object({kind:f.literal("actions"),id:f.string().min(1),title:f.string().min(1).optional(),defaultOpen:f.boolean().optional(),actions:f.array(gF).min(1)}),bF=f.discriminatedUnion("kind",[lF,fF,pF,yF]),xF=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()}),SF=f.object({faqId:f.string().min(1)}),Kye=f.object({text:f.string(),error:f.string().optional(),toolResults:f.array(xF).optional(),cards:f.array(bF).optional(),pendingConfirmations:f.array(aF).optional(),usage:f.object({promptTokens:f.number(),completionTokens:f.number(),totalTokens:f.number()}),guestSettlement:iF.optional(),guestScreening:oF.optional(),askedBefore:SF.optional()})});var Jye,wF,Vye;var vF=x(()=>{Re();kT();Jye=f.object({question:f.string().trim().min(1)}),wF=f.object({faqId:f.string().min(1),answer:f.string().trim().min(1),sources:f.array(Wy).default([])}),Vye=f.object({hit:wF.optional()})});var _F,Wye,kF,Gye;var EF=x(()=>{Re();_F=f.enum(["admin","trusted","public"]),Wye=f.object({conversationId:f.string().min(1),message:f.string(),interfaceType:f.string().min(1),channelId:f.string().optional(),channelName:f.string().optional(),userPermissionLevel:_F}),kF=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()}),Gye=f.object({items:f.array(kF).default([])})});var zl;var ET=x(()=>{Re();zl=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 Qye,IF,Yye;var AF=x(()=>{Re();ET();Qye=f.object({actor:zl}),IF=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"])}),Yye=f.object({principal:IF.nullable()})});var IT,Xye,ebe;var TF=x(()=>{Re();IT=f.strictObject({name:f.string().min(1).optional(),address:f.email()}),Xye=f.strictObject({personId:f.string().min(1).max(200),displayName:f.string().trim().min(1).max(200),permissionLevel:f.enum(["admin","trusted","public"])}),ebe=f.strictObject({messageId:f.string().min(1),sourceRef:f.string().min(1),threadId:f.string().min(1).optional(),from:IT,replyTo:IT.optional(),to:f.array(IT),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:Xye.optional()})});var tbe,rbe,nbe,AT,ibe,obe;var CF=x(()=>{Re();tbe=f.strictObject({permissionLevel:f.enum(["admin","trusted","public"])}),rbe=f.custom((e)=>typeof AbortSignal<"u"&&e instanceof AbortSignal),nbe=f.strictObject({sourceRef:f.string().regex(/^imap:[a-f0-9]{64}$/),actor:tbe,signal:rbe.optional()}),AT=f.strictObject({name:f.string().trim().min(1).max(300).optional(),address:f.email().max(320)}),ibe=f.strictObject({messageId:f.string().trim().min(1).max(2000),from:AT,replyTo:AT.optional(),to:f.array(AT).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()}),obe=f.discriminatedUnion("kind",[f.strictObject({kind:f.literal("available"),message:ibe}),f.strictObject({kind:f.literal("unavailable")})])});var $F=()=>{};var OF=x(()=>{$F()});var sbe;var RF=x(()=>{Re();sbe=f.object({url:f.string(),authToken:f.string().optional()})});var abe;var PF=x(()=>{Re();abe=f.object({success:f.boolean(),entityId:f.string().optional(),error:f.string().optional()})});var zF=()=>{};var Gy,cbe;var NF=x(()=>{Re();Gy=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(Gy),f.record(f.string(),Gy)])),cbe=f.record(f.string(),Gy)});var lbe;var DF=x(()=>{Re();lbe=f.enum(["user","assistant"])});var LF,ns;var BF=x(()=>{Re();LF=f.object({entityType:f.string().min(1),entityId:f.string().min(1),contentHash:f.string().min(1).optional()}),ns=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:LF.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 jF=()=>{};var ube,dbe;var qF=x(()=>{Re();ube=f.object({entityType:f.string().min(1),entityId:f.string(),metadata:f.record(f.string(),f.unknown()).default({}),content:f.string().default("")}),dbe=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 UF=()=>{};var fbe;var MF=x(()=>{Re();fbe=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 FF,ZF,HF,pbe;var KF=x(()=>{Jy();Re();FF=f.object({audiences:f.array(f.string()).optional(),positioning:f.string().optional()}),ZF=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()}),HF=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()}),pbe=f.object({name:f.string().describe("Style guide name"),messaging:FF.optional(),voice:ZF.optional(),visual:HF.optional()})});var mbe;var JF=x(()=>{Re();mbe=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 hbe,gbe,VF,WF;var GF=x(()=>{Re();hbe=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"),gbe=f.object({message:f.string()}).describe("simpleTextResponse"),VF=f.object({success:f.boolean(),entityId:f.string().optional(),message:f.string()}).describe("createEntityResponse"),WF=f.object({success:f.boolean(),entityId:f.string(),changes:f.array(f.string()).optional(),message:f.string()}).describe("updateEntityResponse")});var QF,_Le,YF,ybe,bbe;var XF=x(()=>{Re();QF={recipientMissing:"Notification recipient missing",transportMissing:"Notification transport missing",deliveryFailed:"Notification delivery failed"},_Le=new RegExp(`^${QF.deliveryFailed}: ([a-z0-9_:.-]{1,80})$`),YF=f.discriminatedUnion("type",[f.strictObject({type:f.literal("email"),address:f.email()})]),ybe=f.strictObject({recipient:YF.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()}),bbe=f.discriminatedUnion("status",[f.strictObject({status:f.literal("sent"),deliveryId:f.string().optional()}),f.strictObject({status:f.literal("failed")})])});var xbe;var eZ=x(()=>{Re();xbe=f.strictObject({titles:f.array(f.string().trim().min(1).max(500)).max(20)})});var Sbe,wbe;var tZ=x(()=>{Re();Sbe=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)}),wbe=f.strictObject({noteId:f.string(),created:f.boolean()})});var is=x(()=>{XA();tF();_T();nF();kT();vF();EF();ET();AF();TF();CF();OF();RF();PF();zF();NF();DF();BF();jF();qF();UF();MF();KF();JF();GF();XF();eZ();tZ()});var rZ=x(()=>{Nf();is()});var nZ=x(()=>{Nf();is()});var iZ=()=>{};function B(e,t){kbe(Boolean(e),!1,!0,"ok","Expected value to be truthy",t)}function kbe(e,t,r,i,n,o){if(!e)throw o instanceof Error?o:new oZ(o||n,t,r,i,!o)}var oZ;var tt=x(()=>{iZ();oZ=class oZ 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 Aa(e,t){let r=t||Ebe,i=typeof r.includeImageAlt==="boolean"?r.includeImageAlt:!0,n=typeof r.includeHtml==="boolean"?r.includeHtml:!0;return aZ(e,i,n)}function aZ(e,t,r){if(Ibe(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 sZ(e.children,t,r)}if(Array.isArray(e))return sZ(e,t,r);return""}function sZ(e,t,r){let i=[],n=-1;while(++n<e.length)i[n]=aZ(e[n],t,r);return i.join("")}function Ibe(e){return Boolean(e&&typeof e==="object")}var Ebe;var cZ=x(()=>{Ebe={}});var Qy=x(()=>{cZ()});var TT;var lZ=x(()=>{TT={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:`
406
+ `,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 Nl(e){return Abe.call(TT,e)?TT[e]:!1}var Abe;var Yy=x(()=>{lZ();Abe={}.hasOwnProperty});var w;var uZ=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 dZ=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 fZ=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 ln;var pZ=x(()=>{ln={ht:"\t",lf:`
407
+ `,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(()=>{uZ();dZ();fZ();pZ()});function lr(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 Br(e,t){if(e.length>0)return lr(e,e.length,0,t),e;return t}var os=x(()=>{Fe()});function hZ(e){let t={},r=-1;while(++r<e.length)Tbe(t,e[r]);return t}function Tbe(e,t){let r;for(r in t){let n=(mZ.call(e,r)?e[r]:void 0)||(e[r]={}),o=t[r],s;if(o)for(s in o){if(!mZ.call(n,s))n[s]=[];let a=o[s];Cbe(n[s],Array.isArray(a)?a:a?[a]:[])}}}function Cbe(e,t){let r=-1,i=[];while(++r<t.length)(t[r].add==="after"?e:i).push(t[r]);lr(e,0,0,i)}var mZ;var gZ=x(()=>{os();mZ={}.hasOwnProperty});function Xy(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 ln.replacementCharacter;return String.fromCodePoint(r)}var CT=x(()=>{Fe()});function Yi(e){return e.replace(/[\t\n\r ]+/g,ln.space).replace(/^ | $/g,"").toLowerCase().toUpperCase()}var eb=x(()=>{Fe()});function Zf(e){return e!==null&&(e<w.space||e===w.del)}function ve(e){return e!==null&&e<w.horizontalTab}function Ot(e){return e!==null&&(e<w.nul||e===w.space)}function Me(e){return e===w.horizontalTab||e===w.virtualSpace||e===w.space}function ss(e){return t;function t(r){return r!==null&&r>-1&&e.test(String.fromCharCode(r))}}var un,jr,yZ,Hf,bZ,xZ,SZ,wZ;var ot=x(()=>{Fe();un=ss(/[A-Za-z]/),jr=ss(/[\dA-Za-z]/),yZ=ss(/[#-'*+\--9=?A-Z^-~]/);Hf=ss(/\d/),bZ=ss(/[\dA-Fa-f]/),xZ=ss(/[!-/:-@[-`{-~]/);SZ=ss(/\p{P}|\p{S}/u),wZ=ss(/\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 Qt=x(()=>{ot()});function $be(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 vZ;var _Z=x(()=>{tt();Qt();ot();Fe();vZ={tokenize:$be}});function Obe(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 lr(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(kZ,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(kZ,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++;lr(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 Rbe(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 EZ,kZ;var IZ=x(()=>{tt();Qt();ot();os();Fe();EZ={tokenize:Obe},kZ={tokenize:Rbe}});function Dl(e){if(e===w.eof||Ot(e)||wZ(e))return be.characterGroupWhitespace;if(SZ(e))return be.characterGroupPunctuation}var $T=x(()=>{ot();Fe()});function Ll(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 Pbe(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(AZ(d,-c),AZ(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=Br(l,[["enter",e[i][1],t],["exit",e[i][1],t]]);if(l=Br(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=Br(l,Ll(t.parser.constructs.insideSpan.null,e.slice(i+1,r),t)),l=Br(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=Br(l,[["enter",e[r][1],t],["exit",e[r][1],t]]);else u=0;lr(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 zbe(e,t){let r=this.parser.constructs.attentionMarkers.null,i=this.previous,n=Dl(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=Dl(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 AZ(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var Kf;var TZ=x(()=>{tt();os();$T();Fe();Kf={name:"attention",resolveAll:Pbe,tokenize:zbe}});function Nbe(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(un(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||jr(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||jr(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||Zf(m))return r(m);return e.consume(m),c}function l(m){if(m===w.atSign)return e.consume(m),u;if(yZ(m))return e.consume(m),l;return r(m)}function u(m){return jr(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||jr(m))&&i++<be.autolinkDomainSizeMax){let y=m===w.dash?p:d;return e.consume(m),y}return r(m)}}var OT;var CZ=x(()=>{tt();ot();Fe();OT={name:"autolink",tokenize:Nbe}});function Dbe(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 as;var tb=x(()=>{Qt();ot();Fe();as={partial:!0,tokenize:Dbe}});function Lbe(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 Bbe(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(rb,t,r)(s)}}function jbe(e){e.exit(S.blockQuote)}var rb;var $Z=x(()=>{tt();Qt();ot();Fe();rb={continuation:{tokenize:Bbe},exit:jbe,name:"blockQuote",tokenize:Lbe}});function qbe(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(xZ(o))return e.enter(S.characterEscapeValue),e.consume(o),e.exit(S.characterEscapeValue),e.exit(S.characterEscape),t;return r(o)}}var nb;var OZ=x(()=>{tt();ot();Fe();nb={name:"characterEscape",tokenize:qbe}});function Ube(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=jr,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=bZ,u;return e.enter(S.characterReferenceValue),o=be.characterReferenceDecimalSizeMax,s=Hf,u(d)}function u(d){if(d===w.semicolon&&n){let p=e.exit(S.characterReferenceValue);if(s===jr&&!Nl(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 ib;var RZ=x(()=>{tt();Yy();ot();Fe();ib={name:"characterReference",tokenize:Ube}});function Mbe(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(PZ,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(PZ,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 Fbe(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 PZ,ob;var zZ=x(()=>{tt();Qt();ot();Fe();PZ={partial:!0,tokenize:Fbe},ob={concrete:!0,name:"codeFenced",tokenize:Mbe}});function Hbe(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(Zbe,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 Kbe(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 Jf,Zbe;var NZ=x(()=>{tt();Qt();ot();Fe();Jf={name:"codeIndented",tokenize:Hbe},Zbe={partial:!0,tokenize:Kbe}});function Jbe(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 DZ(e){return e!==w.graveAccent||this.events[this.events.length-1][1].type===S.characterEscape}function Vbe(e,t,r){let i=this,n=0,o,s;return a;function a(p){return B(p===w.graveAccent,"expected `` ` ``"),B(DZ.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 RT;var LZ=x(()=>{tt();ot();Fe();RT={name:"codeText",previous:DZ,resolve:Jbe,tokenize:Vbe}});class PT{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)Vf(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),Vf(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),Vf(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);Vf(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,Number.POSITIVE_INFINITY);Vf(this.left,t.reverse())}}}function Vf(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 BZ=x(()=>{Fe()});function sb(e){let t={},r=-1,i,n,o,s,a,c,l,u=new PT(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,Wbe(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 lr(e,0,Number.POSITIVE_INFINITY,u.slice(0)),!l}function Wbe(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 zT=x(()=>{tt();os();Fe();BZ()});function Qbe(e){return sb(e),e}function Ybe(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(Gbe,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 Xbe(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 NT,Gbe;var jZ=x(()=>{tt();Qt();ot();zT();Fe();NT={resolve:Qbe,tokenize:Ybe},Gbe={partial:!0,tokenize:Xbe}});function ab(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||Zf(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||Ot(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||Zf(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 DT=x(()=>{ot();Fe()});function cb(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 LT=x(()=>{tt();ot();Fe()});function lb(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 BT=x(()=>{Qt();ot();Fe()});function Ta(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 jT=x(()=>{Qt();ot();Fe()});function txe(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 `[`"),cb.call(i,e,a,r,S.definitionLabel,S.definitionLabelMarker,S.definitionLabelString)(m)}function a(m){if(n=Yi(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 Ot(m)?Ta(e,l)(m):l(m)}function l(m){return ab(e,u,r,S.definitionDestination,S.definitionDestinationLiteral,S.definitionDestinationLiteralMarker,S.definitionDestinationRaw,S.definitionDestinationString)(m)}function u(m){return e.attempt(exe,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 rxe(e,t,r){return i;function i(a){return Ot(a)?Ta(e,n)(a):r(a)}function n(a){return lb(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 qT,exe;var qZ=x(()=>{tt();DT();LT();Qt();BT();jT();ot();eb();Fe();qT={name:"definition",tokenize:txe},exe={partial:!0,tokenize:rxe}});function nxe(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 UT;var UZ=x(()=>{tt();ot();Fe();UT={name:"hardBreakEscape",tokenize:nxe}});function ixe(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},lr(e,i,r-i+1,[["enter",n,t],["enter",o,t],["exit",o,t],["exit",n,t]]);return e}function oxe(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||Ot(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||Ot(u))return e.exit(S.atxHeadingText),a(u);return e.consume(u),l}}var MT;var MZ=x(()=>{tt();Qt();ot();os();Fe();MT={name:"headingAtx",resolve:ixe,tokenize:oxe}});var FZ,FT;var ZZ=x(()=>{FZ=["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"],FT=["pre","script","style","textarea"]});function cxe(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 lxe(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(un(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(un(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(un(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||Ot(C)){let Se=C===w.slash,Ee=s.toLowerCase();if(!Se&&!o&&FT.includes(Ee))return n=be.htmlRaw,i.interrupt?t(C):P(C);if(FZ.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||jr(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||un(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||jr(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||Ot(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(sxe,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(axe,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(FT.includes(Se))return e.consume(C),te;return P(C)}if(un(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 uxe(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 dxe(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(as,t,r)}}var ZT,sxe,axe;var HZ=x(()=>{tt();ot();ZZ();Fe();tb();ZT={concrete:!0,name:"htmlFlow",resolveTo:cxe,tokenize:lxe},sxe={partial:!0,tokenize:dxe},axe={partial:!0,tokenize:uxe}});function fxe(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(un(_))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(un(_))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(un(_))return e.consume(_),E;return r(_)}function E(_){if(_===w.dash||jr(_))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||jr(_))return e.consume(_),D;if(_===w.slash||_===w.greaterThan||Ot(_))return H(_);return r(_)}function H(_){if(_===w.slash)return e.consume(_),O;if(_===w.colon||_===w.underscore||un(_))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||jr(_))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||Ot(_))return H(_);return e.consume(_),I}function R(_){if(_===w.slash||_===w.greaterThan||Ot(_))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 HT;var KZ=x(()=>{tt();Qt();ot();Fe();HT={name:"htmlText",tokenize:fxe}});function gxe(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)lr(e,0,e.length,r);return e}function yxe(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=Br(a,e.slice(o+1,o+i+3)),a=Br(a,[["enter",u,t]]),B(t.parser.constructs.insideSpan.null,"expected `insideSpan.null` to be populated"),a=Br(a,Ll(t.parser.constructs.insideSpan.null,e.slice(o+i+4,s-3),t)),a=Br(a,[["exit",u,t],e[s-2],e[s-1],["exit",l,t]]),a=Br(a,e.slice(s+1)),a=Br(a,[["exit",c,t]]),lr(e,o,e.length,a),e}function bxe(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(Yi(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(pxe,u,s?u:d)(p);if(p===w.leftSquareBracket)return e.attempt(mxe,u,s?l:d)(p);return s?u(p):d(p)}function l(p){return e.attempt(hxe,u,d)(p)}function u(p){return t(p)}function d(p){return o._balanced=!0,r(p)}}function xxe(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 Ot(d)?Ta(e,o)(d):o(d)}function o(d){if(d===w.rightParenthesis)return u(d);return ab(e,s,a,S.resourceDestination,S.resourceDestinationLiteral,S.resourceDestinationLiteralMarker,S.resourceDestinationRaw,S.resourceDestinationString,be.linkResourceDestinationBalanceMax)(d)}function s(d){return Ot(d)?Ta(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 lb(e,l,r,S.resourceTitle,S.resourceTitleMarker,S.resourceTitleString)(d);return u(d)}function l(d){return Ot(d)?Ta(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 Sxe(e,t,r){let i=this;return n;function n(a){return B(a===w.leftSquareBracket,"expected left bracket"),cb.call(i,e,o,s,S.reference,S.referenceMarker,S.referenceString)(a)}function o(a){return i.parser.defined.includes(Yi(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)))?t(a):r(a)}function s(a){return r(a)}}function wxe(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 Ca,pxe,mxe,hxe;var ub=x(()=>{tt();DT();LT();BT();jT();ot();os();eb();Fe();Ca={name:"labelEnd",resolveAll:gxe,resolveTo:yxe,tokenize:bxe},pxe={tokenize:xxe},mxe={tokenize:Sxe},hxe={tokenize:wxe}});function vxe(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 KT;var JZ=x(()=>{tt();Fe();ub();KT={name:"labelStartImage",resolveAll:Ca.resolveAll,tokenize:vxe}});function _xe(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 JT;var VZ=x(()=>{tt();Fe();ub();JT={name:"labelStartLink",resolveAll:Ca.resolveAll,tokenize:_xe}});function kxe(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 Wf;var WZ=x(()=>{tt();Qt();ot();Fe();Wf={name:"lineEnding",tokenize:kxe}});function Exe(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 $a;var VT=x(()=>{tt();Qt();ot();Fe();$a={name:"thematicBreak",tokenize:Exe}});function Txe(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:Hf(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($a,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"),Hf(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(as,i.interrupt?r:u,e.attempt(Ixe,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 Cxe(e,t,r){let i=this;return B(i.containerState,"expected state"),i.containerState._closeFlow=void 0,e.check(as,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(Axe,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(vr,t,r),S.linePrefix,i.parser.constructs.disable.null.includes("codeIndented")?void 0:be.tabSize)(a)}}function $xe(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 Oxe(e){B(this.containerState,"expected state"),B(typeof this.containerState.type==="string","expected type"),e.exit(this.containerState.type)}function Rxe(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 vr,Ixe,Axe;var GZ=x(()=>{tt();Qt();ot();Fe();tb();VT();vr={continuation:{tokenize:Cxe},exit:Oxe,name:"list",tokenize:Txe},Ixe={partial:!0,tokenize:Rxe},Axe={partial:!0,tokenize:$xe}});function Pxe(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 zxe(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 db;var QZ=x(()=>{tt();Qt();ot();Fe();db={name:"setextUnderline",resolveTo:Pxe,tokenize:zxe}});var WT=x(()=>{TZ();CZ();tb();$Z();OZ();RZ();zZ();NZ();LZ();jZ();qZ();UZ();MZ();HZ();KZ();ub();JZ();VZ();WZ();GZ();QZ();VT()});function Nxe(e){let t=this,r=e.attempt(as,i,e.attempt(this.parser.constructs.flowInitial,n,Ze(e,e.attempt(this.parser.constructs.flow,n,e.attempt(NT,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 YZ;var XZ=x(()=>{tt();WT();Qt();ot();Fe();YZ={tokenize:Nxe}});function n3(e){return{resolveAll:i3(e==="text"?Dxe: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 i3(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 Dxe(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 e3,t3,r3;var GT=x(()=>{tt();Fe();e3={resolveAll:i3()},t3=n3("string"),r3=n3("text")});var QT={};tr(QT,{attentionMarkers:()=>Zxe,contentInitial:()=>Bxe,disable:()=>Hxe,document:()=>Lxe,flow:()=>qxe,flowInitial:()=>jxe,insideSpan:()=>Fxe,string:()=>Uxe,text:()=>Mxe});var Lxe,Bxe,jxe,qxe,Uxe,Mxe,Fxe,Zxe,Hxe;var o3=x(()=>{WT();Fe();GT();Lxe={[w.asterisk]:vr,[w.plusSign]:vr,[w.dash]:vr,[w.digit0]:vr,[w.digit1]:vr,[w.digit2]:vr,[w.digit3]:vr,[w.digit4]:vr,[w.digit5]:vr,[w.digit6]:vr,[w.digit7]:vr,[w.digit8]:vr,[w.digit9]:vr,[w.greaterThan]:rb},Bxe={[w.leftSquareBracket]:qT},jxe={[w.horizontalTab]:Jf,[w.virtualSpace]:Jf,[w.space]:Jf},qxe={[w.numberSign]:MT,[w.asterisk]:$a,[w.dash]:[db,$a],[w.lessThan]:ZT,[w.equalsTo]:db,[w.underscore]:$a,[w.graveAccent]:ob,[w.tilde]:ob},Uxe={[w.ampersand]:ib,[w.backslash]:nb},Mxe={[w.carriageReturn]:Wf,[w.lineFeed]:Wf,[w.carriageReturnLineFeed]:Wf,[w.exclamationMark]:KT,[w.ampersand]:ib,[w.asterisk]:Kf,[w.lessThan]:[OT,HT],[w.leftSquareBracket]:JT,[w.backslash]:[UT,nb],[w.rightSquareBracket]:Ca,[w.underscore]:Kf,[w.graveAccent]:RT},Fxe={null:[Kf,e3]},Zxe={null:[w.asterisk,w.underscore]},Hxe={null:[]}});var a3=ee(function(V4e,s3){var Bl=1000,jl=Bl*60,ql=jl*60,Oa=ql*24,Kxe=Oa*7,Jxe=Oa*365.25;s3.exports=function(e,t){t=t||{};var r=typeof e;if(r==="string"&&e.length>0)return Vxe(e);else if(r==="number"&&isFinite(e))return t.long?Gxe(e):Wxe(e);throw Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function Vxe(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*Jxe;case"weeks":case"week":case"w":return r*Kxe;case"days":case"day":case"d":return r*Oa;case"hours":case"hour":case"hrs":case"hr":case"h":return r*ql;case"minutes":case"minute":case"mins":case"min":case"m":return r*jl;case"seconds":case"second":case"secs":case"sec":case"s":return r*Bl;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}function Wxe(e){var t=Math.abs(e);if(t>=Oa)return Math.round(e/Oa)+"d";if(t>=ql)return Math.round(e/ql)+"h";if(t>=jl)return Math.round(e/jl)+"m";if(t>=Bl)return Math.round(e/Bl)+"s";return e+"ms"}function Gxe(e){var t=Math.abs(e);if(t>=Oa)return fb(e,t,Oa,"day");if(t>=ql)return fb(e,t,ql,"hour");if(t>=jl)return fb(e,t,jl,"minute");if(t>=Bl)return fb(e,t,Bl,"second");return e+" ms"}function fb(e,t,r,i){var n=t>=r*1.5;return Math.round(e/r)+" "+i+(n?"s":"")}});var YT=ee(function(W4e,c3){function Qxe(e){r.debug=r,r.default=r,r.coerce=c,r.disable=s,r.enable=n,r.enabled=a,r.humanize=a3(),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}c3.exports=Qxe});var u3=ee(function(l3,pb){l3.formatArgs=Xxe;l3.save=eSe;l3.load=tSe;l3.useColors=Yxe;l3.storage=rSe();l3.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`.")}})();l3.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 Yxe(){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 Xxe(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+pb.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)}l3.log=console.debug||console.log||(()=>{});function eSe(e){try{if(e)l3.storage.setItem("debug",e);else l3.storage.removeItem("debug")}catch(t){}}function tSe(){let e;try{e=l3.storage.getItem("debug")||l3.storage.getItem("DEBUG")}catch(t){}if(!e&&typeof process<"u"&&"env"in process)e=process.env.DEBUG;return e}function rSe(){try{return localStorage}catch(e){}}pb.exports=YT()(l3);var{formatters:nSe}=pb.exports;nSe.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}});var f3=ee(function(Q4e,d3){d3.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 h3=ee(function(Y4e,m3){var dSe=Tt("os"),p3=Tt("tty"),En=f3(),{env:Yt}=process,cs;if(En("no-color")||En("no-colors")||En("color=false")||En("color=never"))cs=0;else if(En("color")||En("colors")||En("color=true")||En("color=always"))cs=1;if("FORCE_COLOR"in Yt)if(Yt.FORCE_COLOR==="true")cs=1;else if(Yt.FORCE_COLOR==="false")cs=0;else cs=Yt.FORCE_COLOR.length===0?1:Math.min(parseInt(Yt.FORCE_COLOR,10),3);function XT(e){if(e===0)return!1;return{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function eC(e,t){if(cs===0)return 0;if(En("color=16m")||En("color=full")||En("color=truecolor"))return 3;if(En("color=256"))return 2;if(e&&!t&&cs===void 0)return 0;let r=cs||0;if(Yt.TERM==="dumb")return r;if(process.platform==="win32"){let i=dSe.release().split(".");if(Number(i[0])>=10&&Number(i[2])>=10586)return Number(i[2])>=14931?3:2;return 1}if("CI"in Yt){if(["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some((i)=>(i in Yt))||Yt.CI_NAME==="codeship")return 1;return r}if("TEAMCITY_VERSION"in Yt)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(Yt.TEAMCITY_VERSION)?1:0;if(Yt.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in Yt){let i=parseInt((Yt.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(Yt.TERM_PROGRAM){case"iTerm.app":return i>=3?3:2;case"Apple_Terminal":return 2}}if(/-256(color)?$/i.test(Yt.TERM))return 2;if(/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(Yt.TERM))return 1;if("COLORTERM"in Yt)return 1;return r}function fSe(e){let t=eC(e,e&&e.isTTY);return XT(t)}m3.exports={supportsColor:fSe,stdout:XT(eC(!0,p3.isatty(1))),stderr:XT(eC(!0,p3.isatty(2)))}});var x3=ee(function(y3,hb){var pSe=Tt("tty"),mb=Tt("util");y3.init=SSe;y3.log=ySe;y3.formatArgs=hSe;y3.save=bSe;y3.load=xSe;y3.useColors=mSe;y3.destroy=mb.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");y3.colors=[6,2,3,4,5,1];try{let e=h3();if(e&&(e.stderr||e).level>=2)y3.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){}y3.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 mSe(){return"colors"in y3.inspectOpts?Boolean(y3.inspectOpts.colors):pSe.isatty(process.stderr.fd)}function hSe(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(`
409
408
  `).join(`
410
- `+o),e.push(n+"m+"+hb.exports.humanize(this.diff)+"\x1B[0m")}else e[0]=ySe()+t+" "+e[0]}function ySe(){if(y3.inspectOpts.hideDate)return"";return new Date().toISOString()+" "}function bSe(...e){return process.stderr.write(mb.formatWithOptions(y3.inspectOpts,...e)+`
411
- `)}function xSe(e){if(e)process.env.DEBUG=e;else delete process.env.DEBUG}function SSe(){return process.env.DEBUG}function wSe(e){e.inspectOpts={};let t=Object.keys(y3.inspectOpts);for(let r=0;r<t.length;r++)e.inspectOpts[t[r]]=y3.inspectOpts[t[r]]}hb.exports=YT()(y3);var{formatters:g3}=hb.exports;g3.o=function(e){return this.inspectOpts.colors=this.useColors,mb.inspect(e,this.inspectOpts).split(`
412
- `).map((t)=>t.trim()).join(" ")};g3.O=function(e){return this.inspectOpts.colors=this.useColors,mb.inspect(e,this.inspectOpts)}});var S3=ee(function(tMe,tC){if(typeof process>"u"||process.type==="renderer"||!1||process.__nwjs)tC.exports=u3();else tC.exports=x3()});function v3(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=Br(s,N),A(),s[s.length-1]!==w.eof)return[];return X(t,0),u.events=Ll(o,u.events,u),u.events}function y(N,I){return $Se(g(N),I)}function g(N){return CSe(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(),Pa("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,Pa("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"),Pa("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(),Pa("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"),Pa("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+"`)"),Pa("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,Dt=[...Array.isArray(Xe)?Xe:Xe?[Xe]:[],...Array.isArray(St)?St:St?[St]:[]];return Se(Dt)(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)lr(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(),Pa("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 CSe(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 $Se(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=ln.cr;break}case w.lineFeed:{s=ln.lf;break}case w.carriageReturnLineFeed:{s=ln.cr+ln.lf;break}case w.horizontalTab:{s=t?ln.space:ln.ht;break}case w.virtualSpace:{if(!t&&n)continue;s=ln.space;break}default:B(typeof o==="number","expected number"),s=String.fromCharCode(o)}n=o===w.horizontalTab,i.push(s)}return i.join("")}var w3,Pa;var _3=x(()=>{tt();ot();os();Fe();w3=rc(S3(),1),Pa=w3.default("micromark")});function rC(e){let i={constructs:hZ([QT,...(e||{}).extensions||[]]),content:n(vZ),defined:[],document:n(EZ),flow:n(YZ),lazy:{},string:n(t3),text:n(r3)};return i;function n(o){return s;function s(a){return v3(i,o,a)}}}var k3=x(()=>{gZ();_Z();IZ();XZ();GT();o3();_3()});function nC(e){while(!sb(e));return e}var E3=x(()=>{zT()});function iC(){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(I3.lastIndex=d,l=I3.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 I3;var A3=x(()=>{Fe();I3=/[\0\t\n\r]/g});var T3=x(()=>{k3();E3();A3()});function gb(e){return e.replace(OSe,RSe)}function RSe(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 Xy(r.slice(o?2:1),o?be.numericBaseHexadecimal:be.numericBaseDecimal)}return Nl(r)||e}var OSe;var oC=x(()=>{Yy();CT();Fe();OSe=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi});function ls(e){if(!e||typeof e!=="object")return"";if("position"in e||"type"in e)return C3(e.position);if("start"in e||"end"in e)return C3(e);if("line"in e||"column"in e)return sC(e);return""}function sC(e){return $3(e&&e.line)+":"+$3(e&&e.column)}function C3(e){return sC(e&&e.start)+"-"+sC(e&&e.end)}function $3(e){return e&&typeof e==="number"?e:1}var aC=()=>{};function cC(e,t,r){if(t&&typeof t==="object")r=t,t=void 0;return PSe(r)(nC(rC(r).document().write(iC()(e,t,!0))))}function PSe(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(Dt),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(Ts,d),listUnordered:o(Ts),paragraph:o(Cu),reference:C,referenceString:s,resourceDestinationString:s,resourceTitleString:s,setextHeading:o(Yr),strong:o(Rn),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()}};P3(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(R3.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]||O3).call(h,void 0,ie[0])}ne.position={start:us(re.length>0?re[0][1].start:{line:1,column:1,offset:0}),end:us(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:us(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+"` ("+ls({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]||O3).call(this,re,U[0]);B(h.type!=="fragment","unexpected fragment `exit`ed"),B(h.position,"expected `position` to be defined"),h.position.end=us(re.end)}function u(){return Aa(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=Yi(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=$u(),U.position={start:us(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=us(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=us(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=gb(ne),h.identifier=Yi(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=Yi(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=Xy(ne,h===S.characterReferenceMarkerNumeric?be.numericBaseDecimal:be.numericBaseHexadecimal),this.data.characterReferenceType=void 0;else{let ie=Nl(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=us(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 Dt(){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 Ts(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 Cu(){return{type:"paragraph",children:[]}}function Rn(){return{type:"strong",children:[]}}function $u(){return{type:"text",value:""}}function tc(){return{type:"thematicBreak"}}}function us(e){return{line:e.line,column:e.column,offset:e.offset}}function P3(e,t){let r=-1;while(++r<t.length){let i=t[r];if(Array.isArray(i))P3(e,i);else zSe(e,i)}}function zSe(e,t){let r;for(r in t)if(R3.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 O3(e,t){if(e)throw Error("Cannot close `"+e.type+"` ("+ls({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+ls({start:t.start,end:t.end})+") is open");else throw Error("Cannot close document, a token (`"+t.type+"`, "+ls({start:t.start,end:t.end})+") is still open")}var R3;var z3=x(()=>{tt();Qy();T3();CT();oC();eb();Fe();Yy();aC();R3={}.hasOwnProperty});var N3=x(()=>{z3()});function yb(e){let t=this;t.parser=r;function r(i){return cC(i,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}var D3=x(()=>{N3()});var L3=x(()=>{D3()});function j3(e,t){let r=t||{};function i(n,...o){let{invalid:s,handlers:a}=i;if(n&&B3.call(n,e)){let c=String(n[e]);s=B3.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 B3;var q3=x(()=>{B3={}.hasOwnProperty});function lC(e,t){let r=-1,i;if(t.extensions)while(++r<t.extensions.length)lC(e,t.extensions[r]);for(i in t)if(NSe.call(t,i))switch(i){case"extensions":break;case"unsafe":{U3(e[i],t[i]);break}case"join":{U3(e[i],t[i]);break}case"handlers":{DSe(e[i],t[i]);break}default:e.options[i]=t[i]}return e}function U3(e,t){if(t)e.push(...t)}function DSe(e,t){if(t)Object.assign(e,t)}var NSe;var M3=x(()=>{NSe={}.hasOwnProperty});function F3(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()),LSe);return n(),s}function LSe(e,t,r){return">"+(r?"":" ")+e}function bb(e,t){return Z3(e,t.inConstruct,!0)&&!Z3(e,t.notInConstruct,!1)}function Z3(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 uC(e,t,r,i){let n=-1;while(++n<r.unsafe.length)if(r.unsafe[n].character===`
413
- `&&bb(r.stack,r.unsafe[n]))return/[ \t]/.test(i.before)?"":" ";return"\\\n"}var H3=()=>{};function K3(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 Qf(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 J3(e){let t=e.options.fence||"`";if(t!=="`"&&t!=="~")throw Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function V3(e,t,r,i){let n=J3(r),o=e.value||"",s=n==="`"?"GraveAccent":"Tilde";if(Qf(e,r)){let d=r.enter("codeIndented"),p=r.indentLines(o,BSe);return d(),p}let a=r.createTracker(i),c=n.repeat(Math.max(K3(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:`
409
+ `+o),e.push(n+"m+"+hb.exports.humanize(this.diff)+"\x1B[0m")}else e[0]=gSe()+t+" "+e[0]}function gSe(){if(y3.inspectOpts.hideDate)return"";return new Date().toISOString()+" "}function ySe(...e){return process.stderr.write(mb.formatWithOptions(y3.inspectOpts,...e)+`
410
+ `)}function bSe(e){if(e)process.env.DEBUG=e;else delete process.env.DEBUG}function xSe(){return process.env.DEBUG}function SSe(e){e.inspectOpts={};let t=Object.keys(y3.inspectOpts);for(let r=0;r<t.length;r++)e.inspectOpts[t[r]]=y3.inspectOpts[t[r]]}hb.exports=YT()(y3);var{formatters:g3}=hb.exports;g3.o=function(e){return this.inspectOpts.colors=this.useColors,mb.inspect(e,this.inspectOpts).split(`
411
+ `).map((t)=>t.trim()).join(" ")};g3.O=function(e){return this.inspectOpts.colors=this.useColors,mb.inspect(e,this.inspectOpts)}});var S3=ee(function(eMe,tC){if(typeof process>"u"||process.type==="renderer"||!1||process.__nwjs)tC.exports=u3();else tC.exports=x3()});function v3(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=Br(s,N),A(),s[s.length-1]!==w.eof)return[];return X(t,0),u.events=Ll(o,u.events,u),u.events}function y(N,I){return CSe(g(N),I)}function g(N){return TSe(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(),Pa("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,Pa("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"),Pa("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(),Pa("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"),Pa("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+"`)"),Pa("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,Dt=[...Array.isArray(Xe)?Xe:Xe?[Xe]:[],...Array.isArray(St)?St:St?[St]:[]];return Se(Dt)(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)lr(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(),Pa("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 TSe(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 CSe(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=ln.cr;break}case w.lineFeed:{s=ln.lf;break}case w.carriageReturnLineFeed:{s=ln.cr+ln.lf;break}case w.horizontalTab:{s=t?ln.space:ln.ht;break}case w.virtualSpace:{if(!t&&n)continue;s=ln.space;break}default:B(typeof o==="number","expected number"),s=String.fromCharCode(o)}n=o===w.horizontalTab,i.push(s)}return i.join("")}var w3,Pa;var _3=x(()=>{tt();ot();os();Fe();w3=rc(S3(),1),Pa=w3.default("micromark")});function rC(e){let i={constructs:hZ([QT,...(e||{}).extensions||[]]),content:n(vZ),defined:[],document:n(EZ),flow:n(YZ),lazy:{},string:n(t3),text:n(r3)};return i;function n(o){return s;function s(a){return v3(i,o,a)}}}var k3=x(()=>{gZ();_Z();IZ();XZ();GT();o3();_3()});function nC(e){while(!sb(e));return e}var E3=x(()=>{zT()});function iC(){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(I3.lastIndex=d,l=I3.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 I3;var A3=x(()=>{Fe();I3=/[\0\t\n\r]/g});var T3=x(()=>{k3();E3();A3()});function gb(e){return e.replace($Se,OSe)}function OSe(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 Xy(r.slice(o?2:1),o?be.numericBaseHexadecimal:be.numericBaseDecimal)}return Nl(r)||e}var $Se;var oC=x(()=>{Yy();CT();Fe();$Se=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi});function ls(e){if(!e||typeof e!=="object")return"";if("position"in e||"type"in e)return C3(e.position);if("start"in e||"end"in e)return C3(e);if("line"in e||"column"in e)return sC(e);return""}function sC(e){return $3(e&&e.line)+":"+$3(e&&e.column)}function C3(e){return sC(e&&e.start)+"-"+sC(e&&e.end)}function $3(e){return e&&typeof e==="number"?e:1}var aC=()=>{};function cC(e,t,r){if(t&&typeof t==="object")r=t,t=void 0;return RSe(r)(nC(rC(r).document().write(iC()(e,t,!0))))}function RSe(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(Dt),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(Ts,d),listUnordered:o(Ts),paragraph:o(Cu),reference:C,referenceString:s,resourceDestinationString:s,resourceTitleString:s,setextHeading:o(Yr),strong:o(Rn),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()}};P3(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(R3.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]||O3).call(h,void 0,ie[0])}ne.position={start:us(re.length>0?re[0][1].start:{line:1,column:1,offset:0}),end:us(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:us(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+"` ("+ls({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]||O3).call(this,re,U[0]);B(h.type!=="fragment","unexpected fragment `exit`ed"),B(h.position,"expected `position` to be defined"),h.position.end=us(re.end)}function u(){return Aa(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=Yi(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=$u(),U.position={start:us(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=us(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=us(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=gb(ne),h.identifier=Yi(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=Yi(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=Xy(ne,h===S.characterReferenceMarkerNumeric?be.numericBaseDecimal:be.numericBaseHexadecimal),this.data.characterReferenceType=void 0;else{let ie=Nl(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=us(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 Dt(){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 Ts(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 Cu(){return{type:"paragraph",children:[]}}function Rn(){return{type:"strong",children:[]}}function $u(){return{type:"text",value:""}}function tc(){return{type:"thematicBreak"}}}function us(e){return{line:e.line,column:e.column,offset:e.offset}}function P3(e,t){let r=-1;while(++r<t.length){let i=t[r];if(Array.isArray(i))P3(e,i);else PSe(e,i)}}function PSe(e,t){let r;for(r in t)if(R3.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 O3(e,t){if(e)throw Error("Cannot close `"+e.type+"` ("+ls({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+ls({start:t.start,end:t.end})+") is open");else throw Error("Cannot close document, a token (`"+t.type+"`, "+ls({start:t.start,end:t.end})+") is still open")}var R3;var z3=x(()=>{tt();Qy();T3();CT();oC();eb();Fe();Yy();aC();R3={}.hasOwnProperty});var N3=x(()=>{z3()});function yb(e){let t=this;t.parser=r;function r(i){return cC(i,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}var D3=x(()=>{N3()});var L3=x(()=>{D3()});function j3(e,t){let r=t||{};function i(n,...o){let{invalid:s,handlers:a}=i;if(n&&B3.call(n,e)){let c=String(n[e]);s=B3.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 B3;var q3=x(()=>{B3={}.hasOwnProperty});function lC(e,t){let r=-1,i;if(t.extensions)while(++r<t.extensions.length)lC(e,t.extensions[r]);for(i in t)if(zSe.call(t,i))switch(i){case"extensions":break;case"unsafe":{U3(e[i],t[i]);break}case"join":{U3(e[i],t[i]);break}case"handlers":{NSe(e[i],t[i]);break}default:e.options[i]=t[i]}return e}function U3(e,t){if(t)e.push(...t)}function NSe(e,t){if(t)Object.assign(e,t)}var zSe;var M3=x(()=>{zSe={}.hasOwnProperty});function F3(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()),DSe);return n(),s}function DSe(e,t,r){return">"+(r?"":" ")+e}function bb(e,t){return Z3(e,t.inConstruct,!0)&&!Z3(e,t.notInConstruct,!1)}function Z3(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 uC(e,t,r,i){let n=-1;while(++n<r.unsafe.length)if(r.unsafe[n].character===`
412
+ `&&bb(r.stack,r.unsafe[n]))return/[ \t]/.test(i.before)?"":" ";return"\\\n"}var H3=()=>{};function K3(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 Qf(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 J3(e){let t=e.options.fence||"`";if(t!=="`"&&t!=="~")throw Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function V3(e,t,r,i){let n=J3(r),o=e.value||"",s=n==="`"?"GraveAccent":"Tilde";if(Qf(e,r)){let d=r.enter("codeIndented"),p=r.indentLines(o,LSe);return d(),p}let a=r.createTracker(i),c=n.repeat(Math.max(K3(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:`
414
413
  `,encode:["`"],...a.current()})),d()}if(u+=a.move(`
415
414
  `),o)u+=a.move(o+`
416
- `);return u+=a.move(c),l(),u}function BSe(e,t,r){return(r?"":" ")+e}var W3=()=>{};function Ul(e){let t=e.options.quote||'"';if(t!=='"'&&t!=="'")throw Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function G3(e,t,r,i){let n=Ul(r),o=n==='"'?"Quote":"Apostrophe",s=r.enter("definition"),a=r.enter("label"),c=r.createTracker(i),l=c.move("[");if(l+=c.move(r.safe(r.associationId(e),{before:l,after:"]",...c.current()})),l+=c.move("]: "),a(),!e.url||/[\0- \u007F]/.test(e.url))a=r.enter("destinationLiteral"),l+=c.move("<"),l+=c.move(r.safe(e.url,{before:l,after:">",...c.current()})),l+=c.move(">");else a=r.enter("destinationRaw"),l+=c.move(r.safe(e.url,{before:l,after:e.title?" ":`
417
- `,...c.current()}));if(a(),e.title)a=r.enter(`title${o}`),l+=c.move(" "+n),l+=c.move(r.safe(e.title,{before:l,after:n,...c.current()})),l+=c.move(n),a();return s(),l}var Q3=()=>{};function Y3(e){let t=e.options.emphasis||"*";if(t!=="*"&&t!=="_")throw Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function dn(e){return"&#x"+e.toString(16).toUpperCase()+";"}function Ml(e,t,r){let i=Dl(e),n=Dl(t);if(i===void 0)return n===void 0?r==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:n===1?{inside:!0,outside:!0}:{inside:!1,outside:!0};if(i===1)return n===void 0?{inside:!1,outside:!1}:n===1?{inside:!0,outside:!0}:{inside:!1,outside:!1};return n===void 0?{inside:!1,outside:!1}:n===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}var dC=x(()=>{$T()});function fC(e,t,r,i){let n=Y3(r),o=r.enter("emphasis"),s=r.createTracker(i),a=s.move(n),c=s.move(r.containerPhrasing(e,{after:n,before:a,...s.current()})),l=c.charCodeAt(0),u=Ml(i.before.charCodeAt(i.before.length-1),l,n);if(u.inside)c=dn(l)+c.slice(1);let d=c.charCodeAt(c.length-1),p=Ml(i.after.charCodeAt(0),d,n);if(p.inside)c=c.slice(0,-1)+dn(d);let m=s.move(n);return o(),r.attentionEncodeSurroundingInfo={after:p.outside,before:u.outside},a+c+m}function jSe(e,t,r){return r.options.emphasis||"*"}var X3=x(()=>{dC();fC.peek=jSe});function qSe(e){let t=[],r=-1;while(++r<e.length)t[r]=Fl(e[r]);return xb(i);function i(...n){let o=-1;while(++o<t.length)if(t[o].apply(this,n))return!0;return!1}}function USe(e){let t=e;return xb(r);function r(i){let n=i,o;for(o in e)if(n[o]!==t[o])return!1;return!0}}function MSe(e){return xb(t);function t(r){return r&&r.type===e}}function xb(e){return t;function t(r,i,n){return Boolean(ZSe(r)&&e.call(this,r,typeof i==="number"?i:void 0,n||void 0))}}function FSe(){return!0}function ZSe(e){return e!==null&&typeof e==="object"&&"type"in e}var Fl=function(e){if(e===null||e===void 0)return FSe;if(typeof e==="function")return xb(e);if(typeof e==="object")return Array.isArray(e)?qSe(e):USe(e);if(typeof e==="string")return MSe(e);throw Error("Expected function, string, or object as test")};var pC=()=>{};function e5(e){return"\x1B[33m"+e+"\x1B[39m"}function mC(e,t,r,i){let n;if(typeof t==="function"&&typeof r!=="function")i=r,r=t;else n=t;let o=Fl(n),s=i?-1:1;a(e,void 0,[])();function a(c,l,u){let d=c&&typeof c==="object"?c:{};if(typeof d.type==="string"){let m=typeof d.tagName==="string"?d.tagName:typeof d.name==="string"?d.name:void 0;Object.defineProperty(p,"name",{value:"node ("+e5(c.type+(m?"<"+m+">":""))+")"})}return p;function p(){let m=t5,y,g,b;if(!t||o(c,l,u[u.length-1]||void 0)){if(m=HSe(r(c,u)),m[0]===za)return m}if("children"in c&&c.children){let v=c;if(v.children&&m[0]!==wb){g=(i?v.children.length:-1)+s,b=u.concat(v);while(g>-1&&g<v.children.length){let A=v.children[g];if(y=a(A,g,b)(),y[0]===za)return y;g=typeof y[1]==="number"?y[1]:g+s}}}return m}}}function HSe(e){if(Array.isArray(e))return e;if(typeof e==="number")return[Sb,e];return e===null||e===void 0?t5:[e]}var t5,Sb=!0,za=!1,wb="skip";var r5=x(()=>{pC();t5=[]});var hC=x(()=>{r5()});function gC(e,t,r,i){let n,o,s;if(typeof t==="function"&&typeof r!=="function")o=void 0,s=t,n=r;else o=t,s=r,n=i;mC(e,o,a,n);function a(c,l){let u=l[l.length-1],d=u?u.children.indexOf(c):void 0;return s(c,d,u)}}var n5=x(()=>{hC();hC()});var i5=x(()=>{n5()});function vb(e,t){let r=!1;return gC(e,function(i){if("value"in i&&/\r?\n|\r/.test(i.value)||i.type==="break")return r=!0,za}),Boolean((!e.depth||e.depth<3)&&Aa(e)&&(t.options.setext||r))}var yC=x(()=>{i5();Qy()});function o5(e,t,r,i){let n=Math.max(Math.min(6,e.depth||1),1),o=r.createTracker(i);if(vb(e,r)){let u=r.enter("headingSetext"),d=r.enter("phrasing"),p=r.containerPhrasing(e,{...o.current(),before:`
415
+ `);return u+=a.move(c),l(),u}function LSe(e,t,r){return(r?"":" ")+e}var W3=()=>{};function Ul(e){let t=e.options.quote||'"';if(t!=='"'&&t!=="'")throw Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function G3(e,t,r,i){let n=Ul(r),o=n==='"'?"Quote":"Apostrophe",s=r.enter("definition"),a=r.enter("label"),c=r.createTracker(i),l=c.move("[");if(l+=c.move(r.safe(r.associationId(e),{before:l,after:"]",...c.current()})),l+=c.move("]: "),a(),!e.url||/[\0- \u007F]/.test(e.url))a=r.enter("destinationLiteral"),l+=c.move("<"),l+=c.move(r.safe(e.url,{before:l,after:">",...c.current()})),l+=c.move(">");else a=r.enter("destinationRaw"),l+=c.move(r.safe(e.url,{before:l,after:e.title?" ":`
416
+ `,...c.current()}));if(a(),e.title)a=r.enter(`title${o}`),l+=c.move(" "+n),l+=c.move(r.safe(e.title,{before:l,after:n,...c.current()})),l+=c.move(n),a();return s(),l}var Q3=()=>{};function Y3(e){let t=e.options.emphasis||"*";if(t!=="*"&&t!=="_")throw Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function dn(e){return"&#x"+e.toString(16).toUpperCase()+";"}function Ml(e,t,r){let i=Dl(e),n=Dl(t);if(i===void 0)return n===void 0?r==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:n===1?{inside:!0,outside:!0}:{inside:!1,outside:!0};if(i===1)return n===void 0?{inside:!1,outside:!1}:n===1?{inside:!0,outside:!0}:{inside:!1,outside:!1};return n===void 0?{inside:!1,outside:!1}:n===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}var dC=x(()=>{$T()});function fC(e,t,r,i){let n=Y3(r),o=r.enter("emphasis"),s=r.createTracker(i),a=s.move(n),c=s.move(r.containerPhrasing(e,{after:n,before:a,...s.current()})),l=c.charCodeAt(0),u=Ml(i.before.charCodeAt(i.before.length-1),l,n);if(u.inside)c=dn(l)+c.slice(1);let d=c.charCodeAt(c.length-1),p=Ml(i.after.charCodeAt(0),d,n);if(p.inside)c=c.slice(0,-1)+dn(d);let m=s.move(n);return o(),r.attentionEncodeSurroundingInfo={after:p.outside,before:u.outside},a+c+m}function BSe(e,t,r){return r.options.emphasis||"*"}var X3=x(()=>{dC();fC.peek=BSe});function jSe(e){let t=[],r=-1;while(++r<e.length)t[r]=Fl(e[r]);return xb(i);function i(...n){let o=-1;while(++o<t.length)if(t[o].apply(this,n))return!0;return!1}}function qSe(e){let t=e;return xb(r);function r(i){let n=i,o;for(o in e)if(n[o]!==t[o])return!1;return!0}}function USe(e){return xb(t);function t(r){return r&&r.type===e}}function xb(e){return t;function t(r,i,n){return Boolean(FSe(r)&&e.call(this,r,typeof i==="number"?i:void 0,n||void 0))}}function MSe(){return!0}function FSe(e){return e!==null&&typeof e==="object"&&"type"in e}var Fl=function(e){if(e===null||e===void 0)return MSe;if(typeof e==="function")return xb(e);if(typeof e==="object")return Array.isArray(e)?jSe(e):qSe(e);if(typeof e==="string")return USe(e);throw Error("Expected function, string, or object as test")};var pC=()=>{};function e5(e){return"\x1B[33m"+e+"\x1B[39m"}function mC(e,t,r,i){let n;if(typeof t==="function"&&typeof r!=="function")i=r,r=t;else n=t;let o=Fl(n),s=i?-1:1;a(e,void 0,[])();function a(c,l,u){let d=c&&typeof c==="object"?c:{};if(typeof d.type==="string"){let m=typeof d.tagName==="string"?d.tagName:typeof d.name==="string"?d.name:void 0;Object.defineProperty(p,"name",{value:"node ("+e5(c.type+(m?"<"+m+">":""))+")"})}return p;function p(){let m=t5,y,g,b;if(!t||o(c,l,u[u.length-1]||void 0)){if(m=ZSe(r(c,u)),m[0]===za)return m}if("children"in c&&c.children){let v=c;if(v.children&&m[0]!==wb){g=(i?v.children.length:-1)+s,b=u.concat(v);while(g>-1&&g<v.children.length){let A=v.children[g];if(y=a(A,g,b)(),y[0]===za)return y;g=typeof y[1]==="number"?y[1]:g+s}}}return m}}}function ZSe(e){if(Array.isArray(e))return e;if(typeof e==="number")return[Sb,e];return e===null||e===void 0?t5:[e]}var t5,Sb=!0,za=!1,wb="skip";var r5=x(()=>{pC();t5=[]});var hC=x(()=>{r5()});function gC(e,t,r,i){let n,o,s;if(typeof t==="function"&&typeof r!=="function")o=void 0,s=t,n=r;else o=t,s=r,n=i;mC(e,o,a,n);function a(c,l){let u=l[l.length-1],d=u?u.children.indexOf(c):void 0;return s(c,d,u)}}var n5=x(()=>{hC();hC()});var i5=x(()=>{n5()});function vb(e,t){let r=!1;return gC(e,function(i){if("value"in i&&/\r?\n|\r/.test(i.value)||i.type==="break")return r=!0,za}),Boolean((!e.depth||e.depth<3)&&Aa(e)&&(t.options.setext||r))}var yC=x(()=>{i5();Qy()});function o5(e,t,r,i){let n=Math.max(Math.min(6,e.depth||1),1),o=r.createTracker(i);if(vb(e,r)){let u=r.enter("headingSetext"),d=r.enter("phrasing"),p=r.containerPhrasing(e,{...o.current(),before:`
418
417
  `,after:`
419
418
  `});return d(),u(),p+`
420
419
  `+(n===1?"=":"-").repeat(p.length-(Math.max(p.lastIndexOf("\r"),p.lastIndexOf(`
421
420
  `))+1))}let s="#".repeat(n),a=r.enter("headingAtx"),c=r.enter("phrasing");o.move(s+" ");let l=r.containerPhrasing(e,{before:"# ",after:`
422
- `,...o.current()});if(/^[\t ]/.test(l))l=dn(l.charCodeAt(0))+l.slice(1);if(l=l?s+" "+l:s,r.options.closeAtx)l+=" "+s;return c(),a(),l}var s5=x(()=>{yC()});function bC(e){return e.value||""}function KSe(){return"<"}var a5=x(()=>{bC.peek=KSe});function xC(e,t,r,i){let n=Ul(r),o=n==='"'?"Quote":"Apostrophe",s=r.enter("image"),a=r.enter("label"),c=r.createTracker(i),l=c.move("![");if(l+=c.move(r.safe(e.alt,{before:l,after:"]",...c.current()})),l+=c.move("]("),a(),!e.url&&e.title||/[\0- \u007F]/.test(e.url))a=r.enter("destinationLiteral"),l+=c.move("<"),l+=c.move(r.safe(e.url,{before:l,after:">",...c.current()})),l+=c.move(">");else a=r.enter("destinationRaw"),l+=c.move(r.safe(e.url,{before:l,after:e.title?" ":")",...c.current()}));if(a(),e.title)a=r.enter(`title${o}`),l+=c.move(" "+n),l+=c.move(r.safe(e.title,{before:l,after:n,...c.current()})),l+=c.move(n),a();return l+=c.move(")"),s(),l}function JSe(){return"!"}var c5=x(()=>{xC.peek=JSe});function SC(e,t,r,i){let n=e.referenceType,o=r.enter("imageReference"),s=r.enter("label"),a=r.createTracker(i),c=a.move("!["),l=r.safe(e.alt,{before:c,after:"]",...a.current()});c+=a.move(l+"]["),s();let u=r.stack;r.stack=[],s=r.enter("reference");let d=r.safe(r.associationId(e),{before:c,after:"]",...a.current()});if(s(),r.stack=u,o(),n==="full"||!l||l!==d)c+=a.move(d+"]");else if(n==="shortcut")c=c.slice(0,-1);else c+=a.move("]");return c}function VSe(){return"!"}var l5=x(()=>{SC.peek=VSe});function wC(e,t,r){let i=e.value||"",n="`",o=-1;while(new RegExp("(^|[^`])"+n+"([^`]|$)").test(i))n+="`";if(/[^ \r\n]/.test(i)&&(/^[ \r\n]/.test(i)&&/[ \r\n]$/.test(i)||/^`|`$/.test(i)))i=" "+i+" ";while(++o<r.unsafe.length){let s=r.unsafe[o],a=r.compilePattern(s),c;if(!s.atBreak)continue;while(c=a.exec(i)){let l=c.index;if(i.charCodeAt(l)===10&&i.charCodeAt(l-1)===13)l--;i=i.slice(0,l)+" "+i.slice(c.index+1)}}return n+i+n}function WSe(){return"`"}var u5=x(()=>{wC.peek=WSe});function vC(e,t){let r=Aa(e);return Boolean(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type==="text"&&(r===e.url||"mailto:"+r===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}var d5=x(()=>{Qy()});function _C(e,t,r,i){let n=Ul(r),o=n==='"'?"Quote":"Apostrophe",s=r.createTracker(i),a,c;if(vC(e,r)){let u=r.stack;r.stack=[],a=r.enter("autolink");let d=s.move("<");return d+=s.move(r.containerPhrasing(e,{before:d,after:">",...s.current()})),d+=s.move(">"),a(),r.stack=u,d}a=r.enter("link"),c=r.enter("label");let l=s.move("[");if(l+=s.move(r.containerPhrasing(e,{before:l,after:"](",...s.current()})),l+=s.move("]("),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url))c=r.enter("destinationLiteral"),l+=s.move("<"),l+=s.move(r.safe(e.url,{before:l,after:">",...s.current()})),l+=s.move(">");else c=r.enter("destinationRaw"),l+=s.move(r.safe(e.url,{before:l,after:e.title?" ":")",...s.current()}));if(c(),e.title)c=r.enter(`title${o}`),l+=s.move(" "+n),l+=s.move(r.safe(e.title,{before:l,after:n,...s.current()})),l+=s.move(n),c();return l+=s.move(")"),a(),l}function GSe(e,t,r){return vC(e,r)?"<":"["}var f5=x(()=>{d5();_C.peek=GSe});function kC(e,t,r,i){let n=e.referenceType,o=r.enter("linkReference"),s=r.enter("label"),a=r.createTracker(i),c=a.move("["),l=r.containerPhrasing(e,{before:c,after:"]",...a.current()});c+=a.move(l+"]["),s();let u=r.stack;r.stack=[],s=r.enter("reference");let d=r.safe(r.associationId(e),{before:c,after:"]",...a.current()});if(s(),r.stack=u,o(),n==="full"||!l||l!==d)c+=a.move(d+"]");else if(n==="shortcut")c=c.slice(0,-1);else c+=a.move("]");return c}function QSe(){return"["}var p5=x(()=>{kC.peek=QSe});function Zl(e){let t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function m5(e){let t=Zl(e),r=e.options.bulletOther;if(!r)return t==="*"?"-":"*";if(r!=="*"&&r!=="+"&&r!=="-")throw Error("Cannot serialize items with `"+r+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(r===t)throw Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+r+"`) to be different");return r}var h5=()=>{};function g5(e){let t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function _b(e){let t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function y5(e,t,r,i){let n=r.enter("list"),o=r.bulletCurrent,s=e.ordered?g5(r):Zl(r),a=e.ordered?s==="."?")":".":m5(r),c=t&&r.bulletLastUsed?s===r.bulletLastUsed:!1;if(!e.ordered){let u=e.children?e.children[0]:void 0;if((s==="*"||s==="-")&&u&&(!u.children||!u.children[0])&&r.stack[r.stack.length-1]==="list"&&r.stack[r.stack.length-2]==="listItem"&&r.stack[r.stack.length-3]==="list"&&r.stack[r.stack.length-4]==="listItem"&&r.indexStack[r.indexStack.length-1]===0&&r.indexStack[r.indexStack.length-2]===0&&r.indexStack[r.indexStack.length-3]===0)c=!0;if(_b(r)===s&&u){let d=-1;while(++d<e.children.length){let p=e.children[d];if(p&&p.type==="listItem"&&p.children&&p.children[0]&&p.children[0].type==="thematicBreak"){c=!0;break}}}}if(c)s=a;r.bulletCurrent=s;let l=r.containerFlow(e,i);return r.bulletLastUsed=s,r.bulletCurrent=o,n(),l}var b5=x(()=>{h5()});function x5(e){let t=e.options.listItemIndent||"one";if(t!=="tab"&&t!=="one"&&t!=="mixed")throw Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function S5(e,t,r,i){let n=x5(r),o=r.bulletCurrent||Zl(r);if(t&&t.type==="list"&&t.ordered)o=(typeof t.start==="number"&&t.start>-1?t.start:1)+(r.options.incrementListMarker===!1?0:t.children.indexOf(e))+o;let s=o.length+1;if(n==="tab"||n==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))s=Math.ceil(s/4)*4;let a=r.createTracker(i);a.move(o+" ".repeat(s-o.length)),a.shift(s);let c=r.enter("listItem"),l=r.indentLines(r.containerFlow(e,a.current()),u);return c(),l;function u(d,p,m){if(p)return(m?"":" ".repeat(s))+d;return(m?o:o+" ".repeat(s-o.length))+d}}var w5=()=>{};function v5(e,t,r,i){let n=r.enter("paragraph"),o=r.enter("phrasing"),s=r.containerPhrasing(e,i);return o(),n(),s}var EC;var _5=x(()=>{pC();EC=Fl(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"])});var k5=x(()=>{_5()});function E5(e,t,r,i){return(e.children.some(function(s){return EC(s)})?r.containerPhrasing:r.containerFlow).call(r,e,i)}var I5=x(()=>{k5()});function A5(e){let t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}function IC(e,t,r,i){let n=A5(r),o=r.enter("strong"),s=r.createTracker(i),a=s.move(n+n),c=s.move(r.containerPhrasing(e,{after:n,before:a,...s.current()})),l=c.charCodeAt(0),u=Ml(i.before.charCodeAt(i.before.length-1),l,n);if(u.inside)c=dn(l)+c.slice(1);let d=c.charCodeAt(c.length-1),p=Ml(i.after.charCodeAt(0),d,n);if(p.inside)c=c.slice(0,-1)+dn(d);let m=s.move(n+n);return o(),r.attentionEncodeSurroundingInfo={after:p.outside,before:u.outside},a+c+m}function YSe(e,t,r){return r.options.strong||"*"}var T5=x(()=>{dC();IC.peek=YSe});function C5(e,t,r,i){return r.safe(e.value,i)}function $5(e){let t=e.options.ruleRepetition||3;if(t<3)throw Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function O5(e,t,r){let i=(_b(r)+(r.options.ruleSpaces?" ":"")).repeat($5(r));return r.options.ruleSpaces?i.slice(0,-1):i}var R5=()=>{};var P5;var z5=x(()=>{H3();W3();Q3();X3();s5();a5();c5();l5();u5();f5();p5();b5();w5();I5();T5();R5();P5={blockquote:F3,break:uC,code:V3,definition:G3,emphasis:fC,hardBreak:uC,heading:o5,html:bC,image:xC,imageReference:SC,inlineCode:wC,link:_C,linkReference:kC,list:y5,listItem:S5,paragraph:v5,root:E5,strong:IC,text:C5,thematicBreak:O5}});function XSe(e,t,r,i){if(t.type==="code"&&Qf(t,i)&&(e.type==="list"||e.type===t.type&&Qf(e,i)))return!1;if("spread"in r&&typeof r.spread==="boolean"){if(e.type==="paragraph"&&(e.type===t.type||t.type==="definition"||t.type==="heading"&&vb(t,i)))return;return r.spread?1:0}}var N5;var D5=x(()=>{yC();N5=[XSe]});var Na,L5;var B5=x(()=>{Na=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"],L5=[{character:"\t",after:"[\\r\\n]",inConstruct:"phrasing"},{character:"\t",before:"[\\r\\n]",inConstruct:"phrasing"},{character:"\t",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde"]},{character:"\r",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde","codeFencedMetaGraveAccent","codeFencedMetaTilde","destinationLiteral","headingAtx"]},{character:`
421
+ `,...o.current()});if(/^[\t ]/.test(l))l=dn(l.charCodeAt(0))+l.slice(1);if(l=l?s+" "+l:s,r.options.closeAtx)l+=" "+s;return c(),a(),l}var s5=x(()=>{yC()});function bC(e){return e.value||""}function HSe(){return"<"}var a5=x(()=>{bC.peek=HSe});function xC(e,t,r,i){let n=Ul(r),o=n==='"'?"Quote":"Apostrophe",s=r.enter("image"),a=r.enter("label"),c=r.createTracker(i),l=c.move("![");if(l+=c.move(r.safe(e.alt,{before:l,after:"]",...c.current()})),l+=c.move("]("),a(),!e.url&&e.title||/[\0- \u007F]/.test(e.url))a=r.enter("destinationLiteral"),l+=c.move("<"),l+=c.move(r.safe(e.url,{before:l,after:">",...c.current()})),l+=c.move(">");else a=r.enter("destinationRaw"),l+=c.move(r.safe(e.url,{before:l,after:e.title?" ":")",...c.current()}));if(a(),e.title)a=r.enter(`title${o}`),l+=c.move(" "+n),l+=c.move(r.safe(e.title,{before:l,after:n,...c.current()})),l+=c.move(n),a();return l+=c.move(")"),s(),l}function KSe(){return"!"}var c5=x(()=>{xC.peek=KSe});function SC(e,t,r,i){let n=e.referenceType,o=r.enter("imageReference"),s=r.enter("label"),a=r.createTracker(i),c=a.move("!["),l=r.safe(e.alt,{before:c,after:"]",...a.current()});c+=a.move(l+"]["),s();let u=r.stack;r.stack=[],s=r.enter("reference");let d=r.safe(r.associationId(e),{before:c,after:"]",...a.current()});if(s(),r.stack=u,o(),n==="full"||!l||l!==d)c+=a.move(d+"]");else if(n==="shortcut")c=c.slice(0,-1);else c+=a.move("]");return c}function JSe(){return"!"}var l5=x(()=>{SC.peek=JSe});function wC(e,t,r){let i=e.value||"",n="`",o=-1;while(new RegExp("(^|[^`])"+n+"([^`]|$)").test(i))n+="`";if(/[^ \r\n]/.test(i)&&(/^[ \r\n]/.test(i)&&/[ \r\n]$/.test(i)||/^`|`$/.test(i)))i=" "+i+" ";while(++o<r.unsafe.length){let s=r.unsafe[o],a=r.compilePattern(s),c;if(!s.atBreak)continue;while(c=a.exec(i)){let l=c.index;if(i.charCodeAt(l)===10&&i.charCodeAt(l-1)===13)l--;i=i.slice(0,l)+" "+i.slice(c.index+1)}}return n+i+n}function VSe(){return"`"}var u5=x(()=>{wC.peek=VSe});function vC(e,t){let r=Aa(e);return Boolean(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type==="text"&&(r===e.url||"mailto:"+r===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}var d5=x(()=>{Qy()});function _C(e,t,r,i){let n=Ul(r),o=n==='"'?"Quote":"Apostrophe",s=r.createTracker(i),a,c;if(vC(e,r)){let u=r.stack;r.stack=[],a=r.enter("autolink");let d=s.move("<");return d+=s.move(r.containerPhrasing(e,{before:d,after:">",...s.current()})),d+=s.move(">"),a(),r.stack=u,d}a=r.enter("link"),c=r.enter("label");let l=s.move("[");if(l+=s.move(r.containerPhrasing(e,{before:l,after:"](",...s.current()})),l+=s.move("]("),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url))c=r.enter("destinationLiteral"),l+=s.move("<"),l+=s.move(r.safe(e.url,{before:l,after:">",...s.current()})),l+=s.move(">");else c=r.enter("destinationRaw"),l+=s.move(r.safe(e.url,{before:l,after:e.title?" ":")",...s.current()}));if(c(),e.title)c=r.enter(`title${o}`),l+=s.move(" "+n),l+=s.move(r.safe(e.title,{before:l,after:n,...s.current()})),l+=s.move(n),c();return l+=s.move(")"),a(),l}function WSe(e,t,r){return vC(e,r)?"<":"["}var f5=x(()=>{d5();_C.peek=WSe});function kC(e,t,r,i){let n=e.referenceType,o=r.enter("linkReference"),s=r.enter("label"),a=r.createTracker(i),c=a.move("["),l=r.containerPhrasing(e,{before:c,after:"]",...a.current()});c+=a.move(l+"]["),s();let u=r.stack;r.stack=[],s=r.enter("reference");let d=r.safe(r.associationId(e),{before:c,after:"]",...a.current()});if(s(),r.stack=u,o(),n==="full"||!l||l!==d)c+=a.move(d+"]");else if(n==="shortcut")c=c.slice(0,-1);else c+=a.move("]");return c}function GSe(){return"["}var p5=x(()=>{kC.peek=GSe});function Zl(e){let t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function m5(e){let t=Zl(e),r=e.options.bulletOther;if(!r)return t==="*"?"-":"*";if(r!=="*"&&r!=="+"&&r!=="-")throw Error("Cannot serialize items with `"+r+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(r===t)throw Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+r+"`) to be different");return r}var h5=()=>{};function g5(e){let t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function _b(e){let t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function y5(e,t,r,i){let n=r.enter("list"),o=r.bulletCurrent,s=e.ordered?g5(r):Zl(r),a=e.ordered?s==="."?")":".":m5(r),c=t&&r.bulletLastUsed?s===r.bulletLastUsed:!1;if(!e.ordered){let u=e.children?e.children[0]:void 0;if((s==="*"||s==="-")&&u&&(!u.children||!u.children[0])&&r.stack[r.stack.length-1]==="list"&&r.stack[r.stack.length-2]==="listItem"&&r.stack[r.stack.length-3]==="list"&&r.stack[r.stack.length-4]==="listItem"&&r.indexStack[r.indexStack.length-1]===0&&r.indexStack[r.indexStack.length-2]===0&&r.indexStack[r.indexStack.length-3]===0)c=!0;if(_b(r)===s&&u){let d=-1;while(++d<e.children.length){let p=e.children[d];if(p&&p.type==="listItem"&&p.children&&p.children[0]&&p.children[0].type==="thematicBreak"){c=!0;break}}}}if(c)s=a;r.bulletCurrent=s;let l=r.containerFlow(e,i);return r.bulletLastUsed=s,r.bulletCurrent=o,n(),l}var b5=x(()=>{h5()});function x5(e){let t=e.options.listItemIndent||"one";if(t!=="tab"&&t!=="one"&&t!=="mixed")throw Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function S5(e,t,r,i){let n=x5(r),o=r.bulletCurrent||Zl(r);if(t&&t.type==="list"&&t.ordered)o=(typeof t.start==="number"&&t.start>-1?t.start:1)+(r.options.incrementListMarker===!1?0:t.children.indexOf(e))+o;let s=o.length+1;if(n==="tab"||n==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))s=Math.ceil(s/4)*4;let a=r.createTracker(i);a.move(o+" ".repeat(s-o.length)),a.shift(s);let c=r.enter("listItem"),l=r.indentLines(r.containerFlow(e,a.current()),u);return c(),l;function u(d,p,m){if(p)return(m?"":" ".repeat(s))+d;return(m?o:o+" ".repeat(s-o.length))+d}}var w5=()=>{};function v5(e,t,r,i){let n=r.enter("paragraph"),o=r.enter("phrasing"),s=r.containerPhrasing(e,i);return o(),n(),s}var EC;var _5=x(()=>{pC();EC=Fl(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"])});var k5=x(()=>{_5()});function E5(e,t,r,i){return(e.children.some(function(s){return EC(s)})?r.containerPhrasing:r.containerFlow).call(r,e,i)}var I5=x(()=>{k5()});function A5(e){let t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}function IC(e,t,r,i){let n=A5(r),o=r.enter("strong"),s=r.createTracker(i),a=s.move(n+n),c=s.move(r.containerPhrasing(e,{after:n,before:a,...s.current()})),l=c.charCodeAt(0),u=Ml(i.before.charCodeAt(i.before.length-1),l,n);if(u.inside)c=dn(l)+c.slice(1);let d=c.charCodeAt(c.length-1),p=Ml(i.after.charCodeAt(0),d,n);if(p.inside)c=c.slice(0,-1)+dn(d);let m=s.move(n+n);return o(),r.attentionEncodeSurroundingInfo={after:p.outside,before:u.outside},a+c+m}function QSe(e,t,r){return r.options.strong||"*"}var T5=x(()=>{dC();IC.peek=QSe});function C5(e,t,r,i){return r.safe(e.value,i)}function $5(e){let t=e.options.ruleRepetition||3;if(t<3)throw Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function O5(e,t,r){let i=(_b(r)+(r.options.ruleSpaces?" ":"")).repeat($5(r));return r.options.ruleSpaces?i.slice(0,-1):i}var R5=()=>{};var P5;var z5=x(()=>{H3();W3();Q3();X3();s5();a5();c5();l5();u5();f5();p5();b5();w5();I5();T5();R5();P5={blockquote:F3,break:uC,code:V3,definition:G3,emphasis:fC,hardBreak:uC,heading:o5,html:bC,image:xC,imageReference:SC,inlineCode:wC,link:_C,linkReference:kC,list:y5,listItem:S5,paragraph:v5,root:E5,strong:IC,text:C5,thematicBreak:O5}});function YSe(e,t,r,i){if(t.type==="code"&&Qf(t,i)&&(e.type==="list"||e.type===t.type&&Qf(e,i)))return!1;if("spread"in r&&typeof r.spread==="boolean"){if(e.type==="paragraph"&&(e.type===t.type||t.type==="definition"||t.type==="heading"&&vb(t,i)))return;return r.spread?1:0}}var N5;var D5=x(()=>{yC();N5=[YSe]});var Na,L5;var B5=x(()=>{Na=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"],L5=[{character:"\t",after:"[\\r\\n]",inConstruct:"phrasing"},{character:"\t",before:"[\\r\\n]",inConstruct:"phrasing"},{character:"\t",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde"]},{character:"\r",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde","codeFencedMetaGraveAccent","codeFencedMetaTilde","destinationLiteral","headingAtx"]},{character:`
423
422
  `,inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde","codeFencedMetaGraveAccent","codeFencedMetaTilde","destinationLiteral","headingAtx"]},{character:" ",after:"[\\r\\n]",inConstruct:"phrasing"},{character:" ",before:"[\\r\\n]",inConstruct:"phrasing"},{character:" ",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde"]},{character:"!",after:"\\[",inConstruct:"phrasing",notInConstruct:Na},{character:'"',inConstruct:"titleQuote"},{atBreak:!0,character:"#"},{character:"#",inConstruct:"headingAtx",after:`(?:[\r
424
423
  ]|$)`},{character:"&",after:"[#A-Za-z]",inConstruct:"phrasing"},{character:"'",inConstruct:"titleApostrophe"},{character:"(",inConstruct:"destinationRaw"},{before:"\\]",character:"(",inConstruct:"phrasing",notInConstruct:Na},{atBreak:!0,before:"\\d+",character:")"},{character:")",inConstruct:"destinationRaw"},{atBreak:!0,character:"*",after:`(?:[ \r
425
424
  *])`},{character:"*",inConstruct:"phrasing",notInConstruct:Na},{atBreak:!0,character:"+",after:`(?:[ \r
@@ -428,18 +427,18 @@ return `+str.trim()+`;
428
427
  ]|$)`},{atBreak:!0,character:"<",after:"[!/?A-Za-z]"},{character:"<",after:"[!/?A-Za-z]",inConstruct:"phrasing",notInConstruct:Na},{character:"<",inConstruct:"destinationLiteral"},{atBreak:!0,character:"="},{atBreak:!0,character:">"},{character:">",inConstruct:"destinationLiteral"},{atBreak:!0,character:"["},{character:"[",inConstruct:"phrasing",notInConstruct:Na},{character:"[",inConstruct:["label","reference"]},{character:"\\",after:"[\\r\\n]",inConstruct:"phrasing"},{character:"]",inConstruct:["label","reference"]},{atBreak:!0,character:"_"},{character:"_",inConstruct:"phrasing",notInConstruct:Na},{atBreak:!0,character:"`"},{character:"`",inConstruct:["codeFencedLangGraveAccent","codeFencedMetaGraveAccent"]},{character:"`",inConstruct:"phrasing",notInConstruct:Na},{atBreak:!0,character:"~"}]});function j5(e){if(e.label||!e.identifier)return e.label||"";return gb(e.identifier)}var q5=x(()=>{oC()});function U5(e){if(!e._compiled){let t=(e.atBreak?"[\\r\\n][\\t ]*":"")+(e.before?"(?:"+e.before+")":"");e._compiled=new RegExp((t?"("+t+")":"")+(/[|\\{}()[\]^$+*?.-]/.test(e.character)?"\\":"")+e.character+(e.after?"(?:"+e.after+")":""),"g")}return e._compiled}function M5(e,t,r){let i=t.indexStack,n=e.children||[],o=[],s=-1,a=r.before,c;i.push(-1);let l=t.createTracker(r);while(++s<n.length){let u=n[s],d;if(i[i.length-1]=s,s+1<n.length){let y=t.handle.handlers[n[s+1].type];if(y&&y.peek)y=y.peek;d=y?y(n[s+1],e,t,{before:"",after:"",...l.current()}).charAt(0):""}else d=r.after;if(o.length>0&&(a==="\r"||a===`
429
428
  `)&&u.type==="html")o[o.length-1]=o[o.length-1].replace(/(\r?\n|\r)$/," "),a=" ",l=t.createTracker(r),l.move(o.join(""));let p=t.handle(u,e,t,{...l.current(),after:d,before:a});if(c&&c===p.slice(0,1))p=dn(c.charCodeAt(0))+p.slice(1);let m=t.attentionEncodeSurroundingInfo;if(t.attentionEncodeSurroundingInfo=void 0,c=void 0,m){if(o.length>0&&m.before&&a===o[o.length-1].slice(-1))o[o.length-1]=o[o.length-1].slice(0,-1)+dn(a.charCodeAt(0));if(m.after)c=d}l.move(p),o.push(p),a=p.slice(-1)}return i.pop(),o.join("")}var F5=()=>{};function Z5(e,t,r){let i=t.indexStack,n=e.children||[],o=t.createTracker(r),s=[],a=-1;i.push(-1);while(++a<n.length){let c=n[a];if(i[i.length-1]=a,s.push(o.move(t.handle(c,e,t,{before:`
430
429
  `,after:`
431
- `,...o.current()}))),c.type!=="list")t.bulletLastUsed=void 0;if(a<n.length-1)s.push(o.move(ewe(c,n[a+1],e,t)))}return i.pop(),s.join("")}function ewe(e,t,r,i){let n=i.join.length;while(n--){let o=i.join[n](e,t,r,i);if(o===!0||o===1)break;if(typeof o==="number")return`
430
+ `,...o.current()}))),c.type!=="list")t.bulletLastUsed=void 0;if(a<n.length-1)s.push(o.move(XSe(c,n[a+1],e,t)))}return i.pop(),s.join("")}function XSe(e,t,r,i){let n=i.join.length;while(n--){let o=i.join[n](e,t,r,i);if(o===!0||o===1)break;if(typeof o==="number")return`
432
431
  `.repeat(1+o);if(o===!1)return`
433
432
 
434
433
  <!---->
435
434
 
436
435
  `}return`
437
436
 
438
- `}function H5(e,t){let r=[],i=0,n=0,o;while(o=twe.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 twe;var K5=x(()=>{twe=/\r?\n|\r/g});function V5(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(!bb(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(rwe);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(J5(i.slice(c,u),"\\"));if(c=u,/[!-/:-@[-`{-~]/.test(i.charAt(u))&&(!r.encode||!r.encode.includes(i.charAt(u))))o.push("\\");else o.push(dn(i.charCodeAt(u))),c++}return o.push(J5(i.slice(c,l),r.after)),o.join("")}function rwe(e,t){return e-t}function J5(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 W5=()=>{};function G5(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 AC(e,t){let r=t||{},i={associationId:j5,containerPhrasing:swe,containerFlow:awe,createTracker:G5,compilePattern:U5,enter:o,handlers:{...P5},handle:void 0,indentLines:H5,indexStack:[],join:[...N5],options:{},safe:cwe,stack:[],unsafe:[...L5]};if(lC(i,r),i.options.tightDefinitions)i.join.push(owe);i.handle=j3("type",{invalid:nwe,unknown:iwe,handlers:i.handlers});let n=i.handle(e,void 0,i,{before:`
437
+ `}function H5(e,t){let r=[],i=0,n=0,o;while(o=ewe.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 ewe;var K5=x(()=>{ewe=/\r?\n|\r/g});function V5(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(!bb(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(twe);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(J5(i.slice(c,u),"\\"));if(c=u,/[!-/:-@[-`{-~]/.test(i.charAt(u))&&(!r.encode||!r.encode.includes(i.charAt(u))))o.push("\\");else o.push(dn(i.charCodeAt(u))),c++}return o.push(J5(i.slice(c,l),r.after)),o.join("")}function twe(e,t){return e-t}function J5(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 W5=()=>{};function G5(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 AC(e,t){let r=t||{},i={associationId:j5,containerPhrasing:owe,containerFlow:swe,createTracker:G5,compilePattern:U5,enter:o,handlers:{...P5},handle:void 0,indentLines:H5,indexStack:[],join:[...N5],options:{},safe:awe,stack:[],unsafe:[...L5]};if(lC(i,r),i.options.tightDefinitions)i.join.push(iwe);i.handle=j3("type",{invalid:rwe,unknown:nwe,handlers:i.handlers});let n=i.handle(e,void 0,i,{before:`
439
438
  `,after:`
440
439
  `,now:{line:1,column:1},lineShift:0});if(n&&n.charCodeAt(n.length-1)!==10&&n.charCodeAt(n.length-1)!==13)n+=`
441
- `;return n;function o(s){return i.stack.push(s),a;function a(){i.stack.pop()}}}function nwe(e){throw Error("Cannot handle value `"+e+"`, expected node")}function iwe(e){throw Error("Cannot handle unknown node `"+e.type+"`")}function owe(e,t){if(e.type==="definition"&&e.type===t.type)return 0}function swe(e,t){return M5(e,this,t)}function awe(e,t){return Z5(e,this,t)}function cwe(e,t){return V5(this,e,t)}var Q5=x(()=>{q3();M3();z5();D5();B5();q5();F5();K5();W5()});var Y5=x(()=>{Q5()});function kb(e){let t=this;t.compiler=r;function r(i){return AC(i,{...t.data("settings"),...e,extensions:t.data("toMarkdownExtensions")||[]})}}var X5=x(()=>{Y5()});var e8=x(()=>{X5()});function TC(e){if(e)throw e}var l8=ee(function(T3e,c8){var Eb=Object.prototype.hasOwnProperty,a8=Object.prototype.toString,t8=Object.defineProperty,r8=Object.getOwnPropertyDescriptor,n8=function(t){if(typeof Array.isArray==="function")return Array.isArray(t);return a8.call(t)==="[object Array]"},i8=function(t){if(!t||a8.call(t)!=="[object Object]")return!1;var r=Eb.call(t,"constructor"),i=t.constructor&&t.constructor.prototype&&Eb.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!r&&!i)return!1;var n;for(n in t);return typeof n>"u"||Eb.call(t,n)},o8=function(t,r){if(t8&&r.name==="__proto__")t8(t,r.name,{enumerable:!0,configurable:!0,value:r.newValue,writable:!0});else t[r.name]=r.newValue},s8=function(t,r){if(r==="__proto__"){if(!Eb.call(t,r))return;else if(r8)return r8(t,r).value}return t[r]};c8.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=s8(a,r),n=s8(t,r),a!==n){if(u&&n&&(i8(n)||(o=n8(n)))){if(o)o=!1,s=i&&n8(i)?i:[];else s=i&&i8(i)?i:{};o8(a,{name:r,newValue:e(u,s,n)})}else if(typeof n<"u")o8(a,{name:r,newValue:n})}}return a}});function Yf(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 CC(){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)u8(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 u8(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 d8=()=>{};var ur;var f8=x(()=>{aC();ur=class ur 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=ls(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}};ur.prototype.file="";ur.prototype.name="";ur.prototype.reason="";ur.prototype.message="";ur.prototype.stack="";ur.prototype.column=void 0;ur.prototype.line=void 0;ur.prototype.ancestors=void 0;ur.prototype.cause=void 0;ur.prototype.fatal=void 0;ur.prototype.place=void 0;ur.prototype.ruleId=void 0;ur.prototype.source=void 0});var p8=x(()=>{f8()});import{default as Zn}from"path";var m8=()=>{};import{default as h8}from"process";var g8=()=>{};function Ib(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 y8}from"url";var b8=()=>{};class Ab{constructor(e){let t;if(!e)t={};else if(Ib(e))t={path:e};else if(typeof e==="string"||lwe(e))t={value:e};else t=e;this.cwd="cwd"in t?"":h8.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;while(++r<$C.length){let n=$C[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(!$C.includes(i))this[i]=t[i]}get basename(){return typeof this.path==="string"?Zn.basename(this.path):void 0}set basename(e){RC(e,"basename"),OC(e,"basename"),this.path=Zn.join(this.dirname||"",e)}get dirname(){return typeof this.path==="string"?Zn.dirname(this.path):void 0}set dirname(e){x8(this.basename,"dirname"),this.path=Zn.join(e||"",this.basename)}get extname(){return typeof this.path==="string"?Zn.extname(this.path):void 0}set extname(e){if(OC(e,"extname"),x8(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=Zn.join(this.dirname,this.stem+(e||""))}get path(){return this.history[this.history.length-1]}set path(e){if(Ib(e))e=y8(e);if(RC(e,"path"),this.path!==e)this.history.push(e)}get stem(){return typeof this.path==="string"?Zn.basename(this.path,this.extname):void 0}set stem(e){RC(e,"stem"),OC(e,"stem"),this.path=Zn.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 ur(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 OC(e,t){if(e&&e.includes(Zn.sep))throw Error("`"+t+"` cannot be a path: did not expect `"+Zn.sep+"`")}function RC(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function x8(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}function lwe(e){return Boolean(e&&typeof e==="object"&&"byteLength"in e&&"byteOffset"in e)}var $C;var S8=x(()=>{p8();m8();g8();b8();$C=["history","path","basename","stem","extname","dirname"]});var w8=x(()=>{S8()});var v8=function(e){let i=this.constructor.prototype,n=i[e],o=function(){return n.apply(o,arguments)};return Object.setPrototypeOf(o,i),o};function PC(e,t){if(typeof t!=="function")throw TypeError("Cannot `"+e+"` without `parser`")}function zC(e,t){if(typeof t!=="function")throw TypeError("Cannot `"+e+"` without `compiler`")}function NC(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 _8(e){if(!Yf(e)||typeof e.type!=="string")throw TypeError("Expected node, got `"+e+"`")}function k8(e,t,r){if(!r)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function Tb(e){return dwe(e)?e:new Ab(e)}function dwe(e){return Boolean(e&&typeof e==="object"&&"message"in e&&"messages"in e)}function fwe(e){return typeof e==="string"||pwe(e)}function pwe(e){return Boolean(e&&typeof e==="object"&&"byteLength"in e&&"byteOffset"in e)}var Cb,uwe,DC,LC;var E8=x(()=>{tt();d8();w8();Cb=rc(l8(),1),uwe={}.hasOwnProperty;DC=class DC extends v8{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=CC()}copy(){let e=new DC,t=-1;while(++t<this.attachers.length){let r=this.attachers[t];e.use(...r)}return e.data(Cb.default(!0,{},this.namespace)),e}data(e,t){if(typeof e==="string"){if(arguments.length===2)return NC("data",this.frozen),this.namespace[e]=t,this;return uwe.call(this.namespace,e)&&this.namespace[e]||void 0}if(e)return NC("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=Tb(e),r=this.parser||this.Parser;return PC("parse",r),r(String(t),t)}process(e,t){let r=this;return this.freeze(),PC("process",this.parser||this.Parser),zC("process",this.compiler||this.Compiler),t?i(void 0,t):new Promise(i);function i(n,o){let s=Tb(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(fwe(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(),PC("processSync",this.parser||this.Parser),zC("processSync",this.compiler||this.Compiler),this.process(e,i),k8("processSync","process",t),B(r,"we either bailed on an error or have a tree"),r;function i(n,o){t=!0,TC(n),r=o}}run(e,t,r){_8(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=Tb(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),k8("runSync","run",r),B(i,"we either bailed on an error or have a tree"),i;function n(o,s){TC(o),i=s,r=!0}}stringify(e,t){this.freeze();let r=Tb(t),i=this.compiler||this.Compiler;return zC("stringify",i),_8(e),i(e,r)}use(e,...t){let r=this.attachers,i=this.namespace;if(NC("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=Cb.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(Yf(y)&&Yf(p))p=Cb.default(!0,y,p);r[d]=[c,p,...m]}}}};LC=new DC().freeze()});var I8=x(()=>{E8()});var A8;var T8=x(()=>{L3();e8();I8();A8=LC().use(yb).use(kb).freeze()});var m5e;var C8=x(()=>{Re();m5e=f.record(f.string(),f.unknown())});var y5e;var $8=x(()=>{Re();Og();y5e=f.record(f.string(),f.unknown())});var O8=x(()=>{Og()});var R8=x(()=>{Nf();NU();rZ();nZ();C8();$8();O8();QA()});var vwe;var P8=x(()=>{Re();vwe=f.object({slug:f.string(),title:f.string(),type:f.string(),entityId:f.string(),contentHash:f.string()})});var jC=x(()=>{R8();P8()});var z8=x(()=>{jC();Re()});var N8=x(()=>{jC();Re()});var i8e;var D8=x(()=>{Jy();T8();i8e=A8()});var _we,kwe;var L8=x(()=>{D8();Re();GA();_we=Py.omit({url:!0,analyticsScript:!0}),kwe=_we.extend({title:f.string().optional().describe("Optional site title override"),description:f.string().optional().describe("Optional site description override")})});function qC(e,t={}){let r=B8(e),i=B8(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 B8(e){return e.trim().replace(/^https?:\/\//i,"").replace(/\/$/,"").toLowerCase()}var j8=()=>{};var q8=x(()=>{j8()});function U8(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var Ewe,Iwe;var M8=x(()=>{Re();JA();Ewe=f.string(),Iwe=f.custom((e)=>{if(!U8(e))return!1;let{plugin:t,...r}=e;if(t!==void 0&&typeof t!=="function")return!1;return CU.safeParse(r).success})});var F8=x(()=>{VA();GA();z8();N8();L8();q8();M8()});function Z8(e,t={}){return qC(e,t)}var H8=x(()=>{F8()});var Y8={};tr(Y8,{assertPilotUsersRemoved:()=>Q8,createPilotOffboardDriver:()=>J8,offboardPilotUsers:()=>Rwe});import{access as Awe,readdir as Twe,readFile as Cwe,rm as Xf,writeFile as $we}from"fs/promises";import{basename as Owe,join as Xi}from"path";async function Rwe(e,t){let r=[...new Set(t.handles.map((d)=>Dr.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 Zt(e),c=r.map((d)=>Pwe(a,d,o)),l=t.driver??J8({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(Nwe(u),Dwe(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 zwe(c,l,t.sleep??((d)=>new Promise((p)=>setTimeout(p,d)))),await Lwe(e,r),await Zo(e),await Q8(e,r),s(`Removed desired state for ${r.length} pilot user(s)`)}return{dryRun:i,handles:r,confirmation:n,plans:u}}function Pwe(e,t,r){let i=e.users.find((u)=>u.handle===t),n=`${t}${e.pilot.domainSuffix}`,o=i?.domain??n,s=Z8(o,{sharedDomain:e.pilot.domainSuffix}),a=i?.cloudflareZoneId??$b(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 zwe(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 Nwe(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 Dwe(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 Lwe(e,t){let r=new Set(t),i=Xi(e,"cohorts");for(let n of(await Twe(i)).filter((o)=>o.endsWith(".yaml"))){let o=Xi(i,n),s=await Cwe(o,"utf8"),a=gi(s);if(a.errors.length>0)throw Error(`${n}: ${a.errors[0]?.message??"invalid YAML"}`);let c=a.get("members",!0);if(!FA(c))throw Error(`${n}: members must be a sequence`);let l=c.items.filter((u)=>!wl(u)||typeof u.value!=="string"||!r.has(u.value));if(l.length===c.items.length)continue;if(l.length===0){await Xf(o);continue}c.items=l,Un.parse(a.toJS()),await $we(o,a.toString())}for(let n of t)await Promise.all([Xf(Xi(e,"users",`${n}.yaml`),{force:!0}),Xf(Xi(e,"users",`${n}.secrets.yaml`),{force:!0}),Xf(Xi(e,"users",`${n}.secrets.yaml.age`),{force:!0}),Xf(Xi(e,"users",n),{recursive:!0,force:!0})])}function J8(e){let t=e.fetchImpl??fetch,r=$b(e.env,"HCLOUD_TOKEN"),i=$b(e.env,"CF_API_TOKEN"),n=$b(e.env,e.contentRepoTokenName);return{async inspect(o){let[s,a,c]=await Promise.all([Bwe(t,r,o.instanceName),Promise.all([o.domain,o.previewDomain,...o.wwwDomain?[o.wwwDomain]:[]].map((l)=>jwe(t,i,o.cloudflareZoneId,l))).then((l)=>l.flat()),qwe(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 Hl(t,`https://api.github.com/repos/${o.contentRepo}`,{method:"PATCH",headers:V8(n),body:JSON.stringify({archived:!0})},"GitHub repository archive")},async deleteDnsRecord(o,s){if(Kl(await Hl(t,`https://api.cloudflare.com/client/v4/zones/${o.cloudflareZoneId}/dns_records/${s.id}`,{method:"DELETE",headers:W8(i)},"Cloudflare DNS delete")).success!==!0)throw Error(`Cloudflare DNS delete failed for ${s.name}`)},async deleteServer(o,s){await Hl(t,`https://api.hetzner.cloud/v1/servers/${s.id}`,{method:"DELETE",headers:{Authorization:`Bearer ${r}`}},"Hetzner server delete",!0)}}}async function Bwe(e,t,r){let i=new URL("https://api.hetzner.cloud/v1/servers");i.searchParams.set("label_selector",`brain=${r}`);let o=Kl(await Hl(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=Kl(s),c=K8(a.public_net),l=K8(c?.ipv4);return{id:Uwe(a.id,"Hetzner server id"),name:ep(a.name,"Hetzner server name"),...typeof l?.ip==="string"?{ip:l.ip}:{}}})}async function jwe(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=Kl(await Hl(e,n.toString(),{headers:W8(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=Kl(a),l=ep(c.type,"Cloudflare record type");if(l!=="A"&&l!=="CNAME")throw Error(`Unsupported Cloudflare record type ${l} for ${i}`);return{id:ep(c.id,"Cloudflare record id"),name:ep(c.name,"Cloudflare record name"),type:l,content:ep(c.content,"Cloudflare record content")}})}async function qwe(e,t,r){let i=Kl(await Hl(e,`https://api.github.com/repos/${r}`,{headers:V8(t)},"GitHub repository lookup"));if(typeof i.archived!=="boolean")throw Error(`Invalid repository archive state for ${r}`);return{archived:i.archived}}async function Hl(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 V8(e){return{Accept:"application/vnd.github+json",Authorization:`Bearer ${e}`,"Content-Type":"application/json","X-GitHub-Api-Version":"2022-11-28"}}function W8(e){return{Authorization:`Bearer ${e}`}}function $b(e,t){let r=e[t];if(!r)throw Error(`Missing required environment variable: ${t}`);return r}function G8(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function Kl(e){if(!G8(e))throw Error("Provider returned an unexpected payload");return e}function K8(e){return G8(e)?e:void 0}function ep(e,t){if(typeof e!=="string"||e.length===0)throw Error(`Missing ${t}`);return e}function Uwe(e,t){if(typeof e!=="number")throw Error(`Missing ${t}`);return e}async function Mwe(e){try{return await Awe(e),!0}catch{return!1}}async function Q8(e,t){for(let r of t)for(let i of[Xi(e,"users",`${r}.yaml`),Xi(e,"users",`${r}.secrets.yaml.age`),Xi(e,"users",r)])if(await Mwe(i))throw Error(`Offboarded user state remains: ${Owe(i)}`)}var X8=x(()=>{Pf();pi();H8();af();fa()});var eH="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";import{webcrypto as tH}from"crypto";function Zwe(e){if(e<0)throw RangeError("Wrong ID size");try{if(!ds||ds.length<e)ds=Buffer.allocUnsafe(e*Fwe),tH.getRandomValues(ds),Jl=0;else if(Jl+e>ds.length)tH.getRandomValues(ds),Jl=0}catch(t){throw ds=void 0,t}Jl+=e}function rH(e=21){Zwe(e|=0);let t="";for(let r=Jl-e;r<Jl;r++)t+=eH[ds[r]&63];return t}var Fwe=128,ds,Jl;var nH=()=>{};function eo(e=12){return rH(e)}var tp=x(()=>{nH()});import{openSync as Hwe,writeSync as Kwe}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=Hwe(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{Kwe(this.fileHandle,n+`
442
- `)}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,nHe;var UC=x(()=>{Da={SILLY:0,VERBOSE:1,DEBUG:2,INFO:3,WARN:4,ERROR:5,NONE:6};nHe=fn.getInstance()});var MC,Jwe,Vl,aHe;var rp=x(()=>{is();Re();MC=f.enum(["file_operations","content_operations","data_processing","batch_processing"]),Jwe=f.looseObject({pluginId:f.string().optional(),progressToken:f.union([f.string(),f.number()]).optional(),operationType:MC,operationTarget:f.string().optional(),interfaceType:f.string().optional(),conversationId:f.string().optional(),channelId:f.string().optional(),requestedByActor:zl.optional(),requestedByUserId:f.string().optional(),requestedByInterface:f.string().optional(),silent:f.boolean().optional(),provenance:ns.optional()}),Vl=f.looseObject({pluginId:f.string().optional(),progressToken:f.union([f.string(),f.number()]).optional(),operationType:MC,operationTarget:f.string().optional(),interfaceType:f.string().optional(),conversationId:f.string().optional(),channelId:f.string().optional(),requestedByActor:zl.optional(),requestedByUserId:f.string().optional(),requestedByInterface:f.string().optional(),silent:f.boolean().optional(),provenance:ns.optional(),rootJobId:f.string()}),aHe=f.enum(["none","skip","replace","coalesce"])});var Vwe,fs=15000;var np=x(()=>{rp();Re();Vwe=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:Vl,progress:f.custom((e)=>typeof e==="object"&&e!==null&&("progress"in e)&&typeof e.progress==="number").nullable(),result:f.unknown().nullable().optional()})});var FC,iH,He,Wwe,Gwe,oH,Qwe;var ps=x(()=>{Re();rp();FC=f.enum(["pending","processing","completed","failed"]),iH=f.enum(["completed","failed"]),He={PENDING:"pending",PROCESSING:"processing",COMPLETED:"completed",FAILED:"failed"},Wwe=f.object({id:f.string(),type:f.string(),status:FC,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()}),Gwe=f.object({jobId:f.string(),type:f.string(),status:iH,result:f.unknown().optional(),error:f.string().optional()}),oH=f.object({success:f.literal(!1),error:f.string().optional()}),Qwe=f.object({id:f.string(),type:f.enum(["job","batch"]),status:FC,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:Vl})});var je,dr;var Hn=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 sH(e){let t=Ywe.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?Xwe(r.authority):void 0,o=La(r.path),s=r.query!==void 0?t0e(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 Xwe(e){let t=e0e.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 t0e(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 ip(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=r0e(t.host),o=n0e(t.port),a=`//${i0e(t.userinfo)}${n}${o}`,c=r.split("/").map(encodeURIComponent).join("/");if(c!==""&&!c.startsWith("/"))c="/"+c;return new URL(`${i}${a}${c}`)}function r0e(e){return e.includes(":")?`[${encodeURI(e)}]`:encodeURI(e)}function n0e(e){return e!==void 0?`:${e}`:""}function i0e(e){if(e===void 0)return"";let t=encodeURIComponent(e.username),r=e.password!==void 0?`:${encodeURIComponent(e.password)}`:"";return`${t}${r}@`}var Ywe,e0e;var Ob=x(()=>{Hn();Ywe=(()=>new RegExp("^(?<scheme>[A-Za-z][A-Za-z.+-]*):(//(?<authority>[^/?#]*))?(?<path>[^?#]*)(\\?(?<query>[^#]*))?(#(?<fragment>.*))?$","su"))();e0e=(()=>new RegExp("^((?<username>[^:]*)(:(?<password>.*))?@)?((?<host>[^:\\[\\]]*)|(\\[(?<host_br>[^\\[\\]]*)\\]))(:(?<port>[0-9]*))?$","su"))()});var Gl,aH,cH,op,Rb,o0e,fr,lH,fH=(e)=>e.replace(/=/g,"").replace(/[+\/]/g,(t)=>t=="+"?"-":"_"),pH=(e)=>e.replace(/[^A-Za-z0-9\+\/]/g,""),mH=(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+=op[t>>18&63]+op[t>>12&63]+op[t>>6&63]+op[t&63]}return s?o.slice(0,s-3)+"===".substring(s):o},KC,ZC,Pb=(e,t=!1)=>t?fH(ZC(e)):ZC(e),s0e=(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)}},a0e,hH=(e)=>e.replace(a0e,s0e),uH,Wl=(e,t=!1)=>t?fH(uH(e)):uH(e),dH=(e)=>Wl(e,!0),c0e,l0e=(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))}},gH=(e)=>e.replace(c0e,l0e),yH=(e)=>{if(e=e.replace(/\s+/g,""),!o0e.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=Rb[e.charAt(o++)]<<18|Rb[e.charAt(o++)]<<12|(r=Rb[e.charAt(o++)])<<6|(i=Rb[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("")},JC,bH,xH=(e)=>bH(SH(e)),u0e,SH=(e)=>pH(e.replace(/[-_]/g,(t)=>t=="-"?"+":"/")),HC=(e)=>u0e(SH(e)),d0e=(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)},wH=(e)=>({value:e,enumerable:!1,writable:!0,configurable:!0}),vH=function(){let e=(t,r)=>Object.defineProperty(String.prototype,t,wH(r));e("fromBase64",function(){return HC(this)}),e("toBase64",function(t){return Wl(this,t)}),e("toBase64URI",function(){return Wl(this,!0)}),e("toBase64URL",function(){return Wl(this,!0)}),e("toUint8Array",function(){return xH(this)})},_H=function(){let e=(t,r)=>Object.defineProperty(Uint8Array.prototype,t,wH(r));e("toBase64",function(t){return Pb(this,t)}),e("toBase64URI",function(){return Pb(this,!0)}),e("toBase64URL",function(){return Pb(this,!0)})},f0e=()=>{vH(),_H()},Ql;var zb=x(()=>{Gl=typeof Buffer==="function",aH=typeof TextDecoder==="function"?new TextDecoder("utf-8",{ignoreBOM:!0}):void 0,cH=typeof TextEncoder==="function"?new TextEncoder:void 0,op=Array.prototype.slice.call("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="),Rb=((e)=>{let t={};return e.forEach((r,i)=>t[r]=i),t})(op),o0e=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,fr=String.fromCharCode.bind(String),lH=typeof Uint8Array.from==="function"?Uint8Array.from.bind(Uint8Array):(e)=>new Uint8Array(Array.prototype.slice.call(e,0)),KC=typeof btoa==="function"?(e)=>btoa(e):Gl?(e)=>Buffer.from(e,"binary").toString("base64"):mH,ZC=Gl?(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 KC(r.join(""))},a0e=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,uH=Gl?(e)=>Buffer.from(e,"utf8").toString("base64"):cH?(e)=>ZC(cH.encode(e)):(e)=>KC(hH(e)),c0e=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,JC=typeof atob==="function"?(e)=>atob(pH(e)):Gl?(e)=>Buffer.from(e,"base64").toString("binary"):yH,bH=Gl?(e)=>lH(Buffer.from(e,"base64")):(e)=>lH(JC(e).split("").map((t)=>t.charCodeAt(0))),u0e=Gl?(e)=>Buffer.from(e,"base64").toString("utf8"):aH?(e)=>aH.decode(bH(e)):(e)=>gH(JC(e)),Ql={version:"3.8.0",VERSION:"3.8.0",atob:JC,atobPolyfill:yH,btoa:KC,btoaPolyfill:mH,fromBase64:HC,toBase64:Wl,encode:Wl,encodeURI:dH,encodeURL:dH,utob:hH,btou:gH,decode:HC,isValid:d0e,fromUint8Array:Pb,toUint8Array:xH,extendString:vH,extendUint8Array:_H,extendBuiltins:f0e}});function ms(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 Yl{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(p0e),rowsAffected:this.rowsAffected,lastInsertRowid:this.lastInsertRowid!==void 0?""+this.lastInsertRowid:null}}}function p0e(e){return Array.prototype.map.call(e,m0e)}function m0e(e){if(typeof e==="bigint")return""+e;else if(e instanceof ArrayBuffer)return Ql.fromUint8Array(new Uint8Array(e));else return e}var xi="https://github.com/libsql/libsql-client-ts#supported-urls";var Xl=x(()=>{zb()});function EH(e){return e.scheme==="file"&&(e.path===":memory:"||e.path.startsWith(":memory:?"))}function sp(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===kH)r="file::memory:";let c=sH(r),l=c.scheme.toLowerCase(),u=l==="file"&&c.path===kH&&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 kH=":memory:";var ap=x(()=>{Hn();Ob();Xl()});var AH=ee(function(In){var h0e=In&&In.__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]}),g0e=In&&In.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),IH=In&&In.__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))h0e(t,e,r)}return g0e(t,e),t};Object.defineProperty(In,"__esModule",{value:!0});In.load=In.currentTarget=void 0;var y0e=IH(Tt("path")),b0e=IH(Tt("fs"));function x0e(){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 S0e()?`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}`)}In.currentTarget=x0e;function S0e(){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 w0e(e){let t=y0e.join(e,"index.node");return b0e.existsSync(t)?Tt(t):null}In.load=w0e});var $H=ee(function(AHe,CH){var TH=()=>process.platform==="linux",VC=null,v0e=()=>{if(!VC)VC=TH()&&process.report?process.report.getReport():{};return VC};CH.exports={isLinux:TH,getReport:v0e}});var PH=ee(function(THe,RH){var OH=Tt("fs"),_0e=(e)=>OH.readFileSync(e,"utf-8"),k0e=(e)=>new Promise((t,r)=>{OH.readFile(e,"utf-8",(i,n)=>{if(i)r(i);else t(n)})});RH.exports={LDD_PATH:"/usr/bin/ldd",readFileSync:_0e,readFile:k0e}});var GH=ee(function(CHe,WH){var NH=Tt("child_process"),{isLinux:eu,getReport:DH}=$H(),{LDD_PATH:Nb,readFile:LH,readFileSync:BH}=PH(),Si,wi,hs="",jH=()=>{if(!hs)return new Promise((e)=>{NH.exec("getconf GNU_LIBC_VERSION 2>&1 || true; ldd --version 2>&1 || true",(t,r)=>{hs=t?" ":r,e(hs)})});return hs},qH=()=>{if(!hs)try{hs=NH.execSync("getconf GNU_LIBC_VERSION 2>&1 || true; ldd --version 2>&1 || true",{encoding:"utf8"})}catch(e){hs=" "}return hs},to="glibc",UH=/GLIBC\s(\d+\.\d+)/,Ba="musl",E0e=to.toUpperCase(),I0e=Ba.toLowerCase(),A0e=(e)=>e.includes("libc.musl-")||e.includes("ld-musl-"),MH=()=>{let e=DH();if(e.header&&e.header.glibcVersionRuntime)return to;if(Array.isArray(e.sharedObjects)){if(e.sharedObjects.some(A0e))return Ba}return null},FH=(e)=>{let[t,r]=e.split(/[\r\n]+/);if(t&&t.includes(to))return to;if(r&&r.includes(Ba))return Ba;return null},ZH=(e)=>{if(e.includes(I0e))return Ba;if(e.includes(E0e))return to;return null},T0e=async()=>{if(Si!==void 0)return Si;Si=null;try{let e=await LH(Nb);Si=ZH(e)}catch(e){}return Si},C0e=()=>{if(Si!==void 0)return Si;Si=null;try{let e=BH(Nb);Si=ZH(e)}catch(e){}return Si},HH=async()=>{let e=null;if(eu()){if(e=await T0e(),!e)e=MH();if(!e){let t=await jH();e=FH(t)}}return e},KH=()=>{let e=null;if(eu()){if(e=C0e(),!e)e=MH();if(!e){let t=qH();e=FH(t)}}return e},$0e=async()=>eu()&&await HH()!==to,O0e=()=>eu()&&KH()!==to,R0e=async()=>{if(wi!==void 0)return wi;wi=null;try{let t=(await LH(Nb)).match(UH);if(t)wi=t[1]}catch(e){}return wi},P0e=()=>{if(wi!==void 0)return wi;wi=null;try{let t=BH(Nb).match(UH);if(t)wi=t[1]}catch(e){}return wi},JH=()=>{let e=DH();if(e.header&&e.header.glibcVersionRuntime)return e.header.glibcVersionRuntime;return null},zH=(e)=>e.trim().split(/\s+/)[1],VH=(e)=>{let[t,r,i]=e.split(/[\r\n]+/);if(t&&t.includes(to))return zH(t);if(r&&i&&r.includes(Ba))return zH(i);return null},z0e=async()=>{let e=null;if(eu()){if(e=await R0e(),!e)e=JH();if(!e){let t=await jH();e=VH(t)}}return e},N0e=()=>{let e=null;if(eu()){if(e=P0e(),!e)e=JH();if(!e){let t=qH();e=VH(t)}}return e};WH.exports={GLIBC:to,MUSL:Ba,family:HH,familySync:KH,isNonGlibcLinux:$0e,isNonGlibcLinuxSync:O0e,version:z0e,versionSync:N0e}});var YH=ee(function($He,QH){var D0e={ALLOW:0,DENY:1};QH.exports=D0e});var eK=ee(function(OHe,XH){var WC={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),WC.value=""+e,Object.defineProperty(this,"message",WC),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",WC);XH.exports=ja});var cK=ee(function(RHe,Db){var __dirname="/home/runner/work/brains/brains/node_modules/libsql",{load:L0e,currentTarget:B0e}=AH(),{familySync:tK,GLIBC:j0e,MUSL:q0e}=GH();function U0e(){if(process.env.LIBSQL_JS_DEV)return L0e(__dirname);let e=B0e();if(tK()==j0e)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"&&tK()==q0e)e="linux-arm-musleabihf";return Tt(`@libsql/${e}`)}var{databaseOpen:M0e,databaseOpenWithSync:F0e,databaseInTransaction:Z0e,databaseInterrupt:H0e,databaseClose:K0e,databaseSyncSync:J0e,databaseSyncUntilSync:V0e,databaseExecSync:W0e,databasePrepareSync:G0e,databaseDefaultSafeIntegers:Q0e,databaseAuthorizer:Y0e,databaseLoadExtension:X0e,databaseMaxWriteReplicationIndex:eve,statementRaw:tve,statementIsReader:rve,statementGet:rK,statementRun:nK,statementInterrupt:nve,statementRowsSync:iK,statementColumns:ive,statementSafeIntegers:ove,rowsNext:sve}=U0e(),ave=YH(),oK=eK();function tu(e){if(e.libsqlError)return new oK(e.message,e.code,e.rawCode);return e}class sK{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=F0e(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=M0e(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 Z0e(n)}}})}sync(){return J0e.call(this.db)}syncUntil(e){return V0e.call(this.db,e)}prepare(e){try{let t=G0e.call(this.db,e);return new aK(t)}catch(t){throw tu(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){Y0e.call(this.db,e)}loadExtension(...e){X0e.call(this.db,...e)}maxWriteReplicationIndex(){return eve.call(this.db)}exec(e){try{W0e.call(this.db,e)}catch(t){throw tu(t)}}interrupt(){H0e.call(this.db)}close(){K0e.call(this.db),this.open=!1}defaultSafeIntegers(e){return Q0e.call(this.db,e??!0),this}unsafeMode(...e){throw Error("not implemented")}}class aK{constructor(e){this.stmt=e,this.pluckMode=!1}raw(e){return tve.call(this.stmt,e??!0),this}pluck(e){return this.pluckMode=e??!0,this}get reader(){return rve.call(this.stmt)}run(...e){try{if(e.length==1&&typeof e[0]==="object")return nK.call(this.stmt,e[0]);else return nK.call(this.stmt,e.flat())}catch(t){throw tu(t)}}get(...e){try{if(e.length==1&&typeof e[0]==="object")return rK.call(this.stmt,e[0]);else return rK.call(this.stmt,e.flat())}catch(t){throw tu(t)}}iterate(...e){var t=void 0;if(e.length==1&&typeof e[0]==="object")t=iK.call(this.stmt,e[0]);else t=iK.call(this.stmt,e.flat());return{nextRows:Array(100),nextRowIndex:100,next(){try{if(this.nextRowIndex===100)sve.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 tu(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 tu(t)}}interrupt(){nve.call(this.stmt)}columns(){return ive.call(this.stmt)}safeIntegers(e){return ove.call(this.stmt,e??!0),this}}Db.exports=sK;Db.exports.Authorization=ave;Db.exports.SqliteError=oK});import{Buffer as uK}from"buffer";function dK(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=EH(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 cp.default(i,n);return Jt(o,"SELECT 1 AS checkThatTheDatabaseCanBeOpened",e.intMode),new fK(i,n,o,e.intMode)}class fK{#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,ms(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,ms("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,ms(e),this.#n),this.#r=null,new pK(t,this.#n)}async executeMultiple(e){this.#i();let t=this.#o();try{return mK(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 cp.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 cp.default(this.#e,this.#t);return this.#r}}class pK{#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(),mK(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)=>lK(o,r));else{n={};for(let o in t.args){let s=o[0]==="@"||o[0]==="$"||o[0]===":"?o.substring(1):o;n[s]=lK(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)=>cve(p,a,r)),u=0,d=void 0;return new Yl(a,c,l,0,void 0)}else{let a=o.run(n),c=a.changes,l=BigInt(a.lastInsertRowid);return new Yl([],[],[],c,l)}}catch(o){throw hK(o)}}function cve(e,t,r){let i={};Object.defineProperty(i,"length",{value:e.length});for(let n=0;n<e.length;++n){let o=lve(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 lve(e,t){if(typeof e==="bigint")if(t==="number"){if(e<uve||e>dve)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 uK)return e.buffer;return e}function lK(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<fve||e>pve)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 uK.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 mK(e,t){try{e.exec(t)}catch(r){throw hK(r)}}function hK(e){if(e instanceof cp.default.SqliteError){let t=e.code,r=mve(e.rawCode);return new je(e.message,r,t,e.rawCode,e)}return e}function mve(e){if(e===void 0)return"SQLITE_UNKNOWN";let t=e&255;return hve[t]??`SQLITE_UNKNOWN_${t.toString()}`}var cp,uve,dve=9007199254740991n,fve,pve=9223372036854775807n,hve;var gK=x(()=>{Hn();ap();Xl();cp=rc(cK(),1);Hn();uve=-9007199254740991n;fve=-9223372036854775808n;hve={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 gs;var GC=x(()=>{if(typeof WebSocket<"u")gs=WebSocket;else if(typeof global<"u")gs=global.WebSocket;else if(typeof window<"u")gs=window.WebSocket;else if(typeof self<"u")gs=self.WebSocket});class ru{constructor(){this.intMode="number"}intMode}var st,qe,lp,Rt,up,nu,qa,Kn,_r,vi;var Pt=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"}};lp=class lp extends st{code;proto;constructor(e,t){super(e);this.name="ResponseError",this.code=t.code,this.proto=t,this.stack=void 0}};Rt=class Rt extends st{constructor(e,t){if(t!==void 0){super(`${e}: ${t}`);this.cause=t}else super(e);this.name="ClosedError"}};up=class up extends st{constructor(e){super(e);this.name="WebSocketUnsupportedError"}};nu=class nu 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"}};Kn=class Kn extends st{constructor(e){super(e);this.name="ProtocolVersionError"}};_r=class _r 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 iu(e,"string")}function pn(e){if(e===null||e===void 0)return;else if(typeof e==="string")return e;throw iu(e,"string or null")}function ro(e){if(typeof e==="number")return e;throw iu(e,"number")}function ys(e){if(typeof e==="boolean")return e;throw iu(e,"boolean")}function dp(e){if(Array.isArray(e))return e;throw iu(e,"array")}function qt(e){if(e!==null&&typeof e==="object"&&!Array.isArray(e))return e;throw iu(e,"object")}function Jn(e,t){return dp(e).map((r)=>t(qt(r)))}function iu(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(qt(e))}var ou=x(()=>{Pt()});class yK{#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 fp(e,t){let r=[],i=new yK(r);return i.begin(),t(i,e),i.end(),r.join("")}var Ma=0,pp=1,mp=2,bK=5;class xK{#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 SK{#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(mp);let e=this.#e.varint();return this.#e.bytes(e)}string(){return new TextDecoder().decode(this.bytes())}message(e){return bs(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(pp),this.#e.double()}maybeSkip(){if(this.#t<0)return;else if(this.#t===Ma)this.#e.skipVarint();else if(this.#t===pp)this.#e.skip(8);else if(this.#t===mp){let e=this.#e.varint();this.#e.skip(e)}else if(this.#t===bK)this.#e.skip(4);else throw new qe(`Unexpected wire type ${this.#t}`);this.#t=-1}}function bs(e,t){let r=new xK(e),i=new SK(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 QC=x(()=>{Pt()});class YC{#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,mp),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 YC;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,pp),this.#i(8),this.#r.setFloat64(this.#n,t,!0),this.#n+=8}data(){return new Uint8Array(this.#e,0,this.#n)}}function hp(e,t){let r=new YC;return t(r,e),r.data()}var wK=()=>{};var XC=x(()=>{ou();QC();wK()});class xs{#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 _r("Freeing an id that is not allocated");if(this.#t.delete(this.#e.size),e<this.#e.size)this.#t.add(e)}}var e$=x(()=>{Pt()});function rt(e,t){throw new _r(t)}var An=x(()=>{Pt()});function su(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<yve||e>bve)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 t$(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 yve,bve=9223372036854775807n;var r$=x(()=>{Pt();An();yve=-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 Bb(e,t){let r=Fa(e),i=e.rows.map((n)=>vK(r.columnNames,n,t));return{...r,rows:i}}function jb(e,t){let r=Fa(e),i;if(e.rows.length>0)i=vK(r.columnNames,e.rows[0],t);return{...r,row:i}}function qb(e,t){let r=Fa(e),i;if(e.rows.length>0&&r.columnNames.length>0)i=t$(e.rows[0][0],t);return{...r,value:i}}function vK(e,t,r){let i={};Object.defineProperty(i,"length",{value:t.length});for(let n=0;n<t.length;++n){let o=t$(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 no(e){return new lp(e.message,e)}var gp=x(()=>{Pt();r$()});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 Rt("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 yp(e,t){if(t instanceof Za)return{sqlId:t._getSqlId(e)};else return{sql:""+t}}var au=x(()=>{Pt()});class Ss{#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 bp{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(su(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]=su(t),this}bindName(e,t){return this._namedArgs.set(e,su(t)),this}unbindAll(){return this._args.length=0,this._namedArgs.clear(),this}}function Ub(e,t,r){let i,n=[],o=[];if(t instanceof bp){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)=>su(c));else o=Object.entries(t[1]).map(([c,l])=>({name:c,value:su(l)}));else i=t;let{sql:s,sqlId:a}=yp(e,i);return{sql:s,sqlId:a,args:n,namedArgs:o,wantRows:r}}var Mb=x(()=>{au();r$()});class Fb{_stream;#e;_steps;#t;constructor(e,t){this._stream=e,this.#e=t,this._steps=[],this.#t=!1}step(){return new n$(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 Sve(this._stream,this._steps,e);else return xve(this._stream,this._steps,e)}}function xve(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 Sve(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 no(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 n${_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,Bb)}queryRow(e){return this.#t(e,!0,jb)}queryValue(e){return this.#t(e,!0,qb)}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=Ub(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(no(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:_K(e)})}static error(e){return new wt(e._batch,{type:"error",step:_K(e)})}static not(e){return new wt(e._batch,{type:"not",cond:e._proto})}static and(e,t){for(let r of t)kK(e,r);return new wt(e,{type:"and",conds:t.map((r)=>r._proto)})}static or(e,t){for(let r of t)kK(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 _K(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 kK(e,t){if(t._batch!==e)throw new vi("Cannot mix BatchCond objects for different Batch objects")}var i$=x(()=>{Pt();gp();Mb();An()});function EK(e){return{paramNames:e.params.map((t)=>t.name),columns:e.cols,isExplain:e.isExplain,isReadonly:e.isReadonly}}class cu{constructor(e){this.intMode=e}query(e){return this.#e(e,!0,Bb)}queryRow(e){return this.#e(e,!0,jb)}queryValue(e){return this.#e(e,!0,qb)}run(e){return this.#e(e,!1,Fa)}#e(e,t,r){let i=Ub(this._sqlOwner(),e,t);return this._execute(i).then((n)=>r(n,this.intMode))}batch(e=!1){return new Fb(this,e)}describe(e){let t=yp(this._sqlOwner(),e);return this._describe(t).then(EK)}sequence(e){let t=yp(this._sqlOwner(),e);return this._sequence(t)}intMode}var Zb=x(()=>{i$();gp();au();Mb()});class xp{}var wve=1000,vve=10,o$;var IK=x(()=>{Pt();o$=class o$ extends xp{#e;#t;#r;#n;#i;#o;#a;constructor(e,t,r){super();this.#e=e,this.#t=t,this.#r=r,this.#n=new Ss,this.#i=new Ss,this.#o=void 0,this.#a=!1}async next(){for(;;){if(this.#o!==void 0)throw new Rt("Cursor is closed",this.#o);while(!this.#a&&this.#i.length<vve)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:wve}).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 Sp;var s$=x(()=>{Pt();Zb();IK();Sp=class Sp extends cu{#e;#t;#r;#n;#i;#o;static open(e){let t=e._streamIdAlloc.alloc(),r=new Sp(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 Ss,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 _r("Cursor not associated with the stream attempted to execute a request");return new Promise((r,i)=>{if(this.#o!==void 0)i(new Rt("Stream is closed",this.#o));else this.#e._sendRequest(t,{responseCallback:r,errorCallback:i})})}_cursorClosed(e){if(e!==this.#n)throw new _r("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 Rt("Stream is closed",this.#o));else if(this.#i)e.errorCallback(new Rt("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 o$(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 wp(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,AK),e.arrayObjects("named_args",t.namedArgs,_ve),e.boolean("want_rows",t.wantRows)}function _ve(e,t){e.string("name",t.name),e.object("value",t.value,AK)}function lu(e,t){e.arrayObjects("steps",t.steps,kve)}function kve(e,t){if(t.condition!==void 0)e.object("condition",t.condition,a$);e.object("stmt",t.stmt,wp)}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 AK(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",Ql.fromUint8Array(t));else if(t===void 0);else throw rt(t,"Impossible type of Value")}var c$=x(()=>{zb();An()});function TK(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,Eve);else throw rt(t,"Impossible type of ClientMsg")}function Eve(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,wp);else if(t.type==="batch")e.number("stream_id",t.streamId),e.object("batch",t.batch,lu);else if(t.type==="open_cursor")e.number("stream_id",t.streamId),e.number("cursor_id",t.cursorId),e.object("batch",t.batch,lu);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 CK=x(()=>{c$();An()});function vp(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,OK);for(let r of t.namedArgs)e.message(4,r,Ive);e.bool(5,t.wantRows)}function Ive(e,t){e.string(1,t.name),e.message(2,t.value,OK)}function uu(e,t){for(let r of t.steps)e.message(1,r,Ave)}function Ave(e,t){if(t.condition!==void 0)e.message(1,t.condition,l$);e.message(2,t.stmt,vp)}function l$(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,l$);else if(t.type==="and")e.message(4,t.conds,$K);else if(t.type==="or")e.message(5,t.conds,$K);else if(t.type==="is_autocommit")e.message(6,void 0,RK);else throw rt(t,"Impossible type of BatchCond")}function $K(e,t){for(let r of t)e.message(1,r,l$)}function OK(e,t){if(t===null)e.message(1,void 0,RK);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 RK(e,t){}var u$=x(()=>{An()});function PK(e,t){if(t.type==="hello")e.message(1,t,Tve);else if(t.type==="request")e.message(2,t,Cve);else throw rt(t,"Impossible type of ClientMsg")}function Tve(e,t){if(t.jwt!==void 0)e.string(1,t.jwt)}function Cve(e,t){e.int32(1,t.requestId);let r=t.request;if(r.type==="open_stream")e.message(2,r,$ve);else if(r.type==="close_stream")e.message(3,r,Ove);else if(r.type==="execute")e.message(4,r,Rve);else if(r.type==="batch")e.message(5,r,Pve);else if(r.type==="open_cursor")e.message(6,r,zve);else if(r.type==="close_cursor")e.message(7,r,Nve);else if(r.type==="fetch_cursor")e.message(8,r,Dve);else if(r.type==="sequence")e.message(9,r,Lve);else if(r.type==="describe")e.message(10,r,Bve);else if(r.type==="store_sql")e.message(11,r,jve);else if(r.type==="close_sql")e.message(12,r,qve);else if(r.type==="get_autocommit")e.message(13,r,Uve);else throw rt(r,"Impossible type of Request")}function $ve(e,t){e.int32(1,t.streamId)}function Ove(e,t){e.int32(1,t.streamId)}function Rve(e,t){e.int32(1,t.streamId),e.message(2,t.stmt,vp)}function Pve(e,t){e.int32(1,t.streamId),e.message(2,t.batch,uu)}function zve(e,t){e.int32(1,t.streamId),e.int32(2,t.cursorId),e.message(3,t.batch,uu)}function Nve(e,t){e.int32(1,t.cursorId)}function Dve(e,t){e.int32(1,t.cursorId),e.uint32(2,t.maxCount)}function Lve(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 Bve(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 jve(e,t){e.int32(1,t.sqlId),e.string(2,t.sql)}function qve(e,t){e.int32(1,t.sqlId)}function Uve(e,t){e.int32(1,t.streamId)}var zK=x(()=>{u$();An()});function ws(e){let t=Gr(e.message),r=pn(e.code);return{message:t,code:r}}function _p(e){let t=Jn(e.cols,NK),r=dp(e.rows).map((s)=>Jn(s,DK)),i=ro(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 NK(e){let t=pn(e.name),r=pn(e.decltype);return{name:t,decltype:r}}function Hb(e){let t=new Map;dp(e.step_results).forEach((i,n)=>{if(i!==null)t.set(n,_p(qt(i)))});let r=new Map;return dp(e.step_errors).forEach((i,n)=>{if(i!==null)r.set(n,ws(qt(i)))}),{stepResults:t,stepErrors:r}}function Kb(e){let t=Gr(e.type);if(t==="step_begin"){let r=ro(e.step),i=Jn(e.cols,NK);return{type:"step_begin",step:r,cols:i}}else if(t==="step_end"){let r=ro(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=ro(e.step),i=ws(qt(e.error));return{type:"step_error",step:r,error:i}}else if(t==="row")return{type:"row",row:Jn(e.row,DK)};else if(t==="error")return{type:"error",error:ws(qt(e.error))};else throw new qe("Unexpected type of CursorEntry")}function Jb(e){let t=Jn(e.params,Mve),r=Jn(e.cols,Fve),i=ys(e.is_explain),n=ys(e.is_readonly);return{params:t,cols:r,isExplain:i,isReadonly:n}}function Mve(e){return{name:pn(e.name)}}function Fve(e){let t=Gr(e.name),r=pn(e.decltype);return{name:t,decltype:r}}function DK(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 ro(e.value);else if(t==="text")return Gr(e.value);else if(t==="blob")return Ql.toUint8Array(Gr(e.base64));else throw new qe("Unexpected type of Value")}var Vb=x(()=>{zb();Pt();ou()});function LK(e){let t=Gr(e.type);if(t==="hello_ok")return{type:"hello_ok"};else if(t==="hello_error")return{type:"hello_error",error:ws(qt(e.error))};else if(t==="response_ok"){let r=ro(e.request_id),i=Zve(qt(e.response));return{type:"response_ok",requestId:r,response:i}}else if(t==="response_error"){let r=ro(e.request_id),i=ws(qt(e.error));return{type:"response_error",requestId:r,error:i}}else throw new qe("Unexpected type of ServerMsg")}function Zve(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:_p(qt(e.result))};else if(t==="batch")return{type:"batch",result:Hb(qt(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=Jn(e.entries,Kb),i=ys(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:Jb(qt(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:ys(e.is_autocommit)};else throw new qe("Unexpected type of Response")}var BK=x(()=>{Pt();ou();Vb()});var Tn,vs,jK,qK,du,Hve,Kve,Wb,Jve,Vve,Wve,fu,Gve,Qve,Yve;var Gb=x(()=>{Tn={default(){return{message:"",code:void 0}},1(e,t){t.message=e.string()},2(e,t){t.code=e.string()}},vs={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(qK))},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()}},qK={default(){return[]},1(e,t){t.push(e.message(Yve))}},du={default(){return{stepResults:new Map,stepErrors:new Map}},1(e,t){let[r,i]=e.message(Hve);t.stepResults.set(r,i)},2(e,t){let[r,i]=e.message(Kve);t.stepErrors.set(r,i)}},Hve={default(){return[0,vs.default()]},1(e,t){t[0]=e.uint32()},2(e,t){t[1]=e.message(vs)}},Kve={default(){return[0,Tn.default()]},1(e,t){t[0]=e.uint32()},2(e,t){t[1]=e.message(Tn)}},Wb={default(){return{type:"none"}},1(e){return e.message(Jve)},2(e){return e.message(Vve)},3(e){return e.message(Wve)},4(e){return{type:"row",row:e.message(qK)}},5(e){return{type:"error",error:e.message(Tn)}}},Jve={default(){return{type:"step_begin",step:0,cols:[]}},1(e,t){t.step=e.uint32()},2(e,t){t.cols.push(e.message(jK))}},Vve={default(){return{type:"step_end",affectedRowCount:0,lastInsertRowid:void 0}},1(e,t){t.affectedRowCount=e.uint32()},2(e,t){t.lastInsertRowid=e.uint64()}},Wve={default(){return{type:"step_error",step:0,error:Tn.default()}},1(e,t){t.step=e.uint32()},2(e,t){t.error=e.message(Tn)}},fu={default(){return{params:[],cols:[],isExplain:!1,isReadonly:!1}},1(e,t){t.params.push(e.message(Gve))},2(e,t){t.cols.push(e.message(Qve))},3(e,t){t.isExplain=e.bool()},4(e,t){t.isReadonly=e.bool()}},Gve={default(){return{name:void 0}},1(e,t){t.name=e.string()}},Qve={default(){return{name:"",decltype:void 0}},1(e,t){t.name=e.string()},2(e,t){t.decltype=e.string()}},Yve={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 UK,Xve,e_e,t_e,r_e,n_e,i_e,o_e,s_e;var MK=x(()=>{Gb();UK={default(){return{type:"none"}},1(e){return{type:"hello_ok"}},2(e){return e.message(Xve)},3(e){return e.message(t_e)},4(e){return e.message(e_e)}},Xve={default(){return{type:"hello_error",error:Tn.default()}},1(e,t){t.error=e.message(Tn)}},e_e={default(){return{type:"response_error",requestId:0,error:Tn.default()}},1(e,t){t.requestId=e.int32()},2(e,t){t.error=e.message(Tn)}},t_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(r_e)},5(e,t){t.response=e.message(n_e)},6(e,t){t.response={type:"open_cursor"}},7(e,t){t.response={type:"close_cursor"}},8(e,t){t.response=e.message(i_e)},9(e,t){t.response={type:"sequence"}},10(e,t){t.response=e.message(o_e)},11(e,t){t.response={type:"store_sql"}},12(e,t){t.response={type:"close_sql"}},13(e,t){t.response=e.message(s_e)}},r_e={default(){return{type:"execute",result:vs.default()}},1(e,t){t.result=e.message(vs)}},n_e={default(){return{type:"batch",result:du.default()}},1(e,t){t.result=e.message(du)}},i_e={default(){return{type:"fetch_cursor",entries:[],done:!1}},1(e,t){t.entries.push(e.message(Wb))},2(e,t){t.done=e.bool()}},o_e={default(){return{type:"describe",result:fu.default()}},1(e,t){t.result=e.message(fu)}},s_e={default(){return{type:"get_autocommit",isAutocommit:!1}},1(e,t){t.isAutocommit=e.bool()}}});var FK,d$,Qb;var Yb=x(()=>{XC();Pt();e$();gp();au();An();s$();CK();zK();BK();MK();FK=new Map([["hrana2",{version:2,encoding:"json"}],["hrana1",{version:1,encoding:"json"}]]),d$=new Map([["hrana3-protobuf",{version:3,encoding:"protobuf"}],["hrana3",{version:3,encoding:"json"}],["hrana2",{version:2,encoding:"json"}],["hrana1",{version:1,encoding:"json"}]]);Qb=class Qb extends ru{#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 xs,this._streamIdAlloc=new xs,this._cursorIdAlloc=new xs,this.#l=new xs,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 _r("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=d$.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=fp(e,TK);this.#e.send(r)}else if(t==="protobuf"){let r=hp(e,PK);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 Kn(`${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 Kn(`${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 Rt("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 nu(r))}#g(e){let t=`WebSocket was closed with code ${e.code}`;if(e.reason)t+=`: ${e.reason}`;this.#u(new nu(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),LK)}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=bs(new Uint8Array(e.data),UK)}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 no(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(no(e.error))}else throw rt(e,"Impossible ServerMsg type")}openStream(){return Sp.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 ZK=x(()=>{if(typeof queueMicrotask<"u")Ha=queueMicrotask;else{let e=Promise.resolve();Ha=(t)=>{e.then(t)}}});class f${#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 HK(e){let t=pn(e.baton),r=pn(e.base_url),i=Jn(e.results,a_e);return{baton:t,baseUrl:r,results:i}}function a_e(e){let t=Gr(e.type);if(t==="ok")return{type:"ok",response:c_e(qt(e.response))};else if(t==="error")return{type:"error",error:ws(qt(e.error))};else throw new qe("Unexpected type of StreamResult")}function c_e(e){let t=Gr(e.type);if(t==="close")return{type:"close"};else if(t==="execute")return{type:"execute",result:_p(qt(e.result))};else if(t==="batch")return{type:"batch",result:Hb(qt(e.result))};else if(t==="sequence")return{type:"sequence"};else if(t==="describe")return{type:"describe",result:Jb(qt(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:ys(e.is_autocommit)};else throw new qe("Unexpected type of StreamResponse")}function KK(e){let t=pn(e.baton),r=pn(e.base_url);return{baton:t,baseUrl:r}}var p$=x(()=>{Pt();ou();Vb()});var JK,l_e,u_e,d_e,f_e,p_e,m_e,VK;var m$=x(()=>{Gb();JK={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(l_e))}},l_e={default(){return{type:"none"}},1(e){return{type:"ok",response:e.message(u_e)}},2(e){return{type:"error",error:e.message(Tn)}}},u_e={default(){return{type:"none"}},1(e){return{type:"close"}},2(e){return e.message(d_e)},3(e){return e.message(f_e)},4(e){return{type:"sequence"}},5(e){return e.message(p_e)},6(e){return{type:"store_sql"}},7(e){return{type:"close_sql"}},8(e){return e.message(m_e)}},d_e={default(){return{type:"execute",result:vs.default()}},1(e,t){t.result=e.message(vs)}},f_e={default(){return{type:"batch",result:du.default()}},1(e,t){t.result=e.message(du)}},p_e={default(){return{type:"describe",result:fu.default()}},1(e,t){t.result=e.message(fu)}},m_e={default(){return{type:"get_autocommit",isAutocommit:!1}},1(e,t){t.isAutocommit=e.bool()}},VK={default(){return{baton:void 0,baseUrl:void 0}},1(e,t){t.baton=e.string()},2(e,t){t.baseUrl=e.string()}}});var h$;var WK=x(()=>{ou();QC();Pt();An();p$();m$();Vb();Gb();h$=class h$ extends xp{#e;#t;#r;#n;#i;#o;constructor(e,t){super();this.#e=e,this.#t=t,this.#r=void 0,this.#n=new f$(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(KK,VK);if(t===void 0)throw new qe("Empty response to cursor request");return t}next(){return this.#a(Kb,Wb)}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 Rt("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 bs(n,t)}else throw rt(this.#t,"Impossible encoding");if(this.#r===void 0)throw new _r("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 GK(e,t){if(t.baton!==void 0)e.string("baton",t.baton);e.arrayObjects("requests",t.requests,h_e)}function h_e(e,t){if(e.stringRaw("type",t.type),t.type==="close");else if(t.type==="execute")e.object("stmt",t.stmt,wp);else if(t.type==="batch")e.object("batch",t.batch,lu);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 QK(e,t){if(t.baton!==void 0)e.string("baton",t.baton);e.object("batch",t.batch,lu)}var g$=x(()=>{c$();An()});function YK(e,t){if(t.baton!==void 0)e.string(1,t.baton);for(let r of t.requests)e.message(2,r,g_e)}function g_e(e,t){if(t.type==="close")e.message(1,t,y_e);else if(t.type==="execute")e.message(2,t,b_e);else if(t.type==="batch")e.message(3,t,x_e);else if(t.type==="sequence")e.message(4,t,S_e);else if(t.type==="describe")e.message(5,t,w_e);else if(t.type==="store_sql")e.message(6,t,v_e);else if(t.type==="close_sql")e.message(7,t,__e);else if(t.type==="get_autocommit")e.message(8,t,k_e);else throw rt(t,"Impossible type of StreamRequest")}function y_e(e,t){}function b_e(e,t){e.message(1,t.stmt,vp)}function x_e(e,t){e.message(1,t.batch,uu)}function S_e(e,t){if(t.sql!==void 0)e.string(1,t.sql);if(t.sqlId!==void 0)e.int32(2,t.sqlId)}function w_e(e,t){if(t.sql!==void 0)e.string(1,t.sql);if(t.sqlId!==void 0)e.int32(2,t.sqlId)}function v_e(e,t){e.int32(1,t.sqlId),e.string(2,t.sql)}function __e(e,t){e.int32(1,t.sqlId)}function k_e(e,t){}function XK(e,t){if(t.baton!==void 0)e.string(1,t.baton);e.message(2,t.batch,uu)}var y$=x(()=>{u$();An()});function E_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(no(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 I_e(e,t){if(t==="json"){let r=await e.json();return Ua(r,HK)}if(t==="protobuf"){let r=await e.arrayBuffer();return bs(new Uint8Array(r),JK)}throw await e.body?.cancel(),rt(t,"Impossible encoding")}async function A_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 no(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 Xb;var b$=x(()=>{Pt();XC();e$();ZK();gp();au();Zb();An();WK();g$();y$();g$();y$();p$();m$();Xb=class Xb extends cu{#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 Ss,this.#s=!1,this.#l=!1,this.#d=!1,this.#f=void 0,this.#m=new xs}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 _r("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 Rt("Stream is closed",this.#f);else if(this.#l)throw new Rt("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)=>I_e(r,e.encoding),(r)=>r.baton,(r)=>r.baseUrl,(r)=>E_e(t,r),(r)=>t.forEach((i)=>i.errorCallback(r)))}#h(e,t){let r=new h$(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 A_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,GK,YK)}#w(e,t){if(t.cursorPath===void 0)throw new Kn(`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,QK,XK)}#S(e,t,r,i,n){let o,s;if(r==="json")o=fp(t,i),s="application/json";else if(r==="protobuf")o=hp(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 C_e(e,t){let r=e;for(let i of T_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 x$}var T_e,x$,ex;var S$=x(()=>{Pt();b$();T_e=[{versionPath:"v3-protobuf",pipelinePath:"v3-protobuf/pipeline",cursorPath:"v3-protobuf/cursor",version:3,encoding:"protobuf"}],x$={versionPath:"v2",pipelinePath:"v2/pipeline",cursorPath:void 0,version:2,encoding:"json"};ex=class ex extends ru{#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=C_e(this.#r,this.#e),this._endpointPromise.then((o)=>this._endpoint=o,(o)=>this.#a(o));else this._endpointPromise=Promise.resolve(x$),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<=x$.version)return;else if(this._endpoint===void 0)throw new Kn(`${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 Kn(`${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 Rt("Client is closed",this.#i);let e=new Xb(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 Rt("Client was closed",e))}}});var eJ=x(()=>{Pt()});function w$(e,t,r=2){if(typeof gs>"u")throw new up("WebSockets are not supported in this environment");var i=void 0;if(r==3)i=Array.from(d$.keys());else i=Array.from(FK.keys());let n=new gs(e,i);return new Qb(n,t)}function v$(e,t,r,i,n=2){return new ex(e instanceof URL?e:new URL(e),t,r,i,n)}var tx=x(()=>{GC();Yb();Pt();S$();Yb();GC();i$();eJ();au();Mb();Zb();S$();b$();Yb();s$();Pt()});class kp{#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(io),i;if(this.#r===void 0){this._getSqlCache().apply(r);let o=t.batch(this.#t>=3),s=o.step(),a=s.run(ms(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(mu(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(ms(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 pu(e,t,r,i,n=!1){if(n)r.step().run("PRAGMA foreign_keys=off");let o=r.step(),s=o.run(ms(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(mu(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 io(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 bp(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 mu(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 Yl(t,r,i,n,o)}function yt(e){if(e instanceof st){let t=tJ(e);return new je(e.message,t,void 0,void 0,e)}return e}function tJ(e){if(e instanceof lp&&e.code!==void 0)return e.code;else if(e instanceof qe)return"HRANA_PROTO_ERROR";else if(e instanceof Rt)return e.cause instanceof st?tJ(e.cause):"HRANA_CLOSED_ERROR";else if(e instanceof nu)return"HRANA_WEBSOCKET_ERROR";else if(e instanceof qa)return"SERVER_ERROR";else if(e instanceof Kn)return"PROTOCOL_VERSION_ERROR";else if(e instanceof _r)return"INTERNAL_ERROR";else return"UNKNOWN"}var k$=x(()=>{tx();Hn();Xl()});class hu{#e;#t;capacity;constructor(e,t){this.#e=e,this.#t=new rJ,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 rJ{#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 E$=ee(function(R9e,iJ){function $_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 O_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 nJ(e){return e.queue=0,e.map=O_e,e}iJ.exports=function(e){if(e)return nJ($_e(e));else return nJ(function(t){return t()})}});function aJ(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=ip(e.scheme,e.authority,e.path),r;try{r=w$(t,e.authToken)}catch(i){if(i instanceof up){let n=e.scheme==="wss"?"https":"http",o=ip(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 cJ(r,t,e.authToken,e.intMode,e.concurrency)}class cJ{#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=sJ.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=io(r);i.conn.sqlCache.apply([n]);let o=i.stream.query(n);i.stream.closeGracefully();let s=await o;return mu(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(io),o=await r.conn.client.getVersion();r.conn.sqlCache.apply(n);let s=r.stream.batch(o>=3);return await pu(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(io),i=await t.conn.client.getVersion(),n=t.stream.batch(i>=3);return await pu("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 lJ(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()>R_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=oJ}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??=w$(this.#e,this.#t),{client:e,useSqlCache:void 0,sqlCache:new hu(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=oJ;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 sJ,R_e=60000,oJ=100,lJ;var uJ=x(()=>{tx();Hn();ap();k$();Ob();Xl();sJ=rc(E$(),1);Hn();lJ=class lJ extends kp{#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 fJ(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=ip(e.scheme,e.authority,e.path);return new mJ(t,e.authToken,e.intMode,e.fetch,e.concurrency,e.remoteEncryptionKey)}class mJ{#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=v$(this.#t,this.#o,this.#n,o),this.#e.intMode=this.#r,this.protocol="http",this.#s=dJ.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=io(r),n,o=this.#e.openStream();try{n=o.query(i)}finally{o.closeGracefully()}let s=await n;return mu(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(io),n=await this.#e.getVersion(),o,s=this.#e.openStream();try{new hu(s,pJ).apply(i);let l=s.batch(!1);o=pu(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(io),r=await this.#e.getVersion(),i,n=this.#e.openStream();try{let s=n.batch(!1);i=pu("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 hJ(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=v$(this.#t,this.#o,this.#n,this.#a),this.#e.intMode=this.#r}}get closed(){return this.#e.closed}}var dJ,pJ=30,hJ;var gJ=x(()=>{tx();Hn();ap();k$();Ob();Xl();dJ=rc(E$(),1);Hn();hJ=class hJ extends kp{#e;#t;constructor(e,t,r){super(t,r);this.#e=e,this.#t=new hu(e,pJ)}_getStream(){return this.#e}_getSqlCache(){return this.#t}close(){this.#e.close()}get closed(){return this.#e.closed}}});function gu(e){return P_e(sp(e,!0))}function P_e(e){if(e.scheme==="wss"||e.scheme==="ws")return aJ(e);else if(e.scheme==="https"||e.scheme==="http")return fJ(e);else return dK(e)}var I$=x(()=>{ap();gK();uJ();gJ();Hn()});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 Vn=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 Ep;var rx=x(()=>{De();Ep=class Ep{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 kr;var yu=x(()=>{kr=Symbol.for("drizzle:Name")});var A$,yJ;var bJ=x(()=>{De();yu();A$=class A${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 yJ(e,this)}};yJ=class yJ{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[kr],...i,r[0].table[kr],...n];return e??`${o.join("_")}_fk`}}});function nx(e,...t){return e(...t)}var T$=()=>{};function C$(e,t){return`${e[kr]}_${t.join("_")}_unique`}var xJ,z_e,SJ;var wJ=x(()=>{De();yu();xJ=class xJ{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 SJ(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 xJ(e,this.name)}};SJ=class SJ{constructor(e,t,r,i){this.table=e,this.columns=t,this.name=i??C$(this.table,this.columns.map((n)=>n.name)),this.nullsNotDistinct=r}static[J]="PgUniqueConstraint";columns;name;nullsNotDistinct=!1;getName(){return this.name}}});function vJ(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 _J(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]=vJ(e,i+1,!0);r.push(c),i=l;continue}if(o==="}")return[r,i+1];if(o==="{"){let[c,l]=_J(e,i+1);r.push(c),i=l;continue}let[s,a]=vJ(e,i,!1);r.push(s),i=a}return[r,i]}function kJ(e){let[t]=_J(e,1);return t}function $$(e){return`{${e.map((t)=>{if(Array.isArray(t))return $$(t);if(typeof t==="string")return`"${t.replace(/\\/g,"\\\\").replace(/"/g,"\\\"")}"`;return`${t}`}).join(",")}}`}var EJ=()=>{};var Ip,bu,IJ,N_e,AJ,O$;var TJ=x(()=>{rx();Vn();De();bJ();T$();wJ();EJ();Ip=class Ip extends Ep{foreignKeyConfigs=[];static[J]="PgColumnBuilder";array(e){return new AJ(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})=>nx((n,o)=>{let s=new A$(()=>{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 IJ(e,this.config)}};bu=class bu extends nt{constructor(e,t){if(!t.uniqueName)t.uniqueName=C$(e,[t.name]);super(e,t);this.table=e}static[J]="PgColumn"};IJ=class IJ extends bu{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}};N_e=class N_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};AJ=class AJ extends Ip{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 O$(e,this.config,t)}};O$=class O$ extends bu{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=kJ(e);return e.map((t)=>this.baseColumn.mapFromDriverValue(t))}mapToDriverValue(e,t=!1){let r=e.map((i)=>i===null?null:ce(this.baseColumn,O$)?this.baseColumn.mapToDriverValue(i,!0):this.baseColumn.mapToDriverValue(i));if(t)return r;return $$(r)}}});function OJ(e){return!!e&&typeof e==="function"&&CJ in e&&e[CJ]===!0}var D_e,$J,CJ,L_e,RJ;var PJ=x(()=>{De();TJ();D_e=class D_e extends Ip{static[J]="PgEnumObjectColumnBuilder";constructor(e,t){super(e,"string","PgEnumObjectColumn");this.config.enum=t}build(e){return new $J(e,this.config)}};$J=class $J extends bu{static[J]="PgEnumObjectColumn";enum;enumValues=this.config.enum.enumValues;constructor(e,t){super(e,t);this.enum=t.enum}getSQLType(){return this.enum.enumName}};CJ=Symbol.for("drizzle:isPgEnum");L_e=class L_e extends Ip{static[J]="PgEnumColumnBuilder";constructor(e,t){super(e,"string","PgEnumColumn");this.config.enum=t}build(e){return new RJ(e,this.config)}};RJ=class RJ extends bu{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,Ap;var Wn=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}}};Ap=class Ap extends vt{static[J]="WithSubquery"}});var zJ="0.45.2";var NJ=()=>{};var R$,P$,DJ;var LJ=x(()=>{T$();NJ();DJ={startActiveSpan(e,t){if(!R$)return t();if(!P$)P$=R$.trace.getTracer("drizzle-orm",zJ);return nx((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()}}),R$,P$)}}});var _t;var oo=x(()=>{_t=Symbol.for("drizzle:ViewBaseConfig")});function _s(e){return e[kr]}function Ka(e){return`${e[ix]??"public"}.${e[kr]}`}var ix,ox,BJ,z$,N$,Tp,jJ,B_e,we;var Er=x(()=>{De();yu();ix=Symbol.for("drizzle:Schema"),ox=Symbol.for("drizzle:Columns"),BJ=Symbol.for("drizzle:ExtraConfigColumns"),z$=Symbol.for("drizzle:OriginalName"),N$=Symbol.for("drizzle:BaseName"),Tp=Symbol.for("drizzle:IsAlias"),jJ=Symbol.for("drizzle:ExtraConfigBuilder"),B_e=Symbol.for("drizzle:IsDrizzleTable");we=class we{static[J]="Table";static Symbol={Name:kr,Schema:ix,OriginalName:z$,Columns:ox,ExtraConfigColumns:BJ,BaseName:N$,IsAlias:Tp,ExtraConfigBuilder:jJ};[kr];[z$];[ix];[ox];[BJ];[N$];[Tp]=!1;[B_e]=!0;[jJ]=void 0;constructor(e,t,r){this[kr]=this[z$]=e,this[ix]=t,this[N$]=r}}});function D$(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 qJ(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 Cp(e,t){return e.map((r)=>{if(ce(r,ks)){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,ks)){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 j_e,Vt,Te,sx,UJ,MJ,FVe,mn,ks,U_e,Cn;var pr=x(()=>{De();PJ();Wn();LJ();oo();Vn();Er();j_e=class j_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=UJ;shouldInlineParams=!1;usedTables=[];append(e){return this.queryChunks.push(...e.queryChunks),this}toQuery(e){return DJ.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,sx))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[Tp]?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[Tp]||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,Cn)){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,ks))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,ks))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 sx(l._.alias)],r)}if(OJ(l)){if(l.schema)return{sql:n(l.schema)+"."+n(l.enumName),params:[]};return{sql:n(l.enumName),params:[]}}if(D$(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}};sx=class sx{constructor(e){this.value=e}static[J]="Name";brand;getSQL(){return new Te([this])}};UJ={mapFromDriverValue:(e)=>e},MJ={mapToDriverValue:(e)=>e},FVe={...UJ,...MJ};mn=class mn{constructor(e,t=MJ){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 sx(c)}e.identifier=o;function s(c){return new ks(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={}));ks=class ks{constructor(e){this.name=e}static[J]="Placeholder";getSQL(){return new Te([this])}};U_e=Symbol.for("drizzle:IsDrizzleView");Cn=class Cn{static[J]="View";[_t];[U_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 L$(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?_s(a.table):!1;else if(typeof i[g]==="string"&&i[g]!==_s(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 $n(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(...$n(n[we.Symbol.Columns],o));else r.push(...$n(n,o));return r},[])}function $p(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 ax(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 FJ(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 cx(e){return e[we.Symbol.Columns]}function Op(e){return ce(e,vt)?e._.alias:ce(e,Cn)?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 ZJ(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 B$;var qr=x(()=>{Vn();De();pr();Wn();Er();oo();B$=typeof TextDecoder>"u"?null:new TextDecoder});var HJ,j$,q$;var lx=x(()=>{De();HJ=class HJ{static[J]="ConsoleLogWriter";write(e){console.log(e)}};j$=class j${static[J]="DefaultLogger";writer;constructor(e){this.writer=e?.writer??new HJ}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}`)}};q$=class q${static[J]="NoopLogger";logQuery(){}}});var KJ,JJ,U$;var VJ=x(()=>{De();Er();KJ=Symbol.for("drizzle:PgInlineForeignKeys"),JJ=Symbol.for("drizzle:EnableRLS");U$=class U$ extends we{static[J]="PgTable";static Symbol=Object.assign({},we.Symbol,{InlineForeignKeys:KJ,EnableRLS:JJ});[KJ]=[];[JJ]=!1;[we.Symbol.ExtraConfigBuilder]=void 0;[we.Symbol.ExtraConfigColumns]={}}});var M$,WJ;var GJ=x(()=>{De();VJ();M$=class M${static[J]="PgPrimaryKeyBuilder";columns;name;constructor(e,t){this.columns=e,this.name=t}build(e){return new WJ(e,this.columns,this.name)}};WJ=class WJ{constructor(e,t,r){this.table=e,this.columns=t,this.name=r}static[J]="PgPrimaryKey";columns;name;getName(){return this.name??`${this.table[U$.Symbol.Name]}_${this.columns.map((e)=>e.name).join("_")}_pk`}}});function Qr(e,t){if(qJ(t)&&!D$(e)&&!ce(e,mn)&&!ce(e,ks)&&!ce(e,nt)&&!ce(e,we)&&!ce(e,Cn))return new mn(e,t);return e}function zt(...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 so(...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 YJ(e){return q`not ${e}`}function Es(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 t9(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 On(e){return q`${e} is null`}function r9(e){return q`${e} is not null`}function dx(e){return q`exists ${e}`}function fx(e){return q`not exists ${e}`}function n9(e,t,r){return q`${e} between ${Qr(t,e)} and ${Qr(r,e)}`}function i9(e,t,r){return q`${e} not between ${Qr(t,e)} and ${Qr(r,e)}`}function o9(e,t){return q`${e} like ${t}`}function s9(e,t){return q`${e} not like ${t}`}function a9(e,t){return q`${e} ilike ${t}`}function c9(e,t){return q`${e} not ilike ${t}`}var et=(e,t)=>q`${e} = ${Qr(t,e)}`,QJ=(e,t)=>q`${e} <> ${Qr(t,e)}`,ux=(e,t)=>q`${e} > ${Qr(t,e)}`,XJ=(e,t)=>q`${e} >= ${Qr(t,e)}`,e9=(e,t)=>q`${e} < ${Qr(t,e)}`,xu=(e,t)=>q`${e} <= ${Qr(t,e)}`;var l9=x(()=>{Vn();De();Er();pr()});function ao(e){return q`${e} asc`}function Ja(e){return q`${e} desc`}var u9=x(()=>{pr()});var F$=x(()=>{l9();u9()});function f9(){return{and:zt,between:n9,eq:et,exists:dx,gt:ux,gte:XJ,ilike:a9,inArray:Es,isNull:On,isNotNull:r9,like:o9,lt:e9,lte:xu,ne:QJ,not:YJ,notBetween:i9,notExists:fx,notLike:s9,notIlike:c9,notInArray:t9,or:so,sql:q}}function p9(){return{sql:q,asc:ao,desc:Ja}}function m9(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,M$))n[o].primaryKey.push(...u.columns)}}else if(ce(s,d9)){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 M_e(e){return function(r,i){return new Is(e,r,i,i?.fields.reduce((n,o)=>n&&o.notNull,!0)??!1)}}function F_e(e){return function(r,i){return new Rp(e,r,i)}}function h9(e,t,r){if(ce(r,Is)&&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],Is)&&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 g9(e){return{one:M_e(e),many:F_e(e)}}function px(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,Is)?u&&px(e,e[a.relationTableTsKey],u,a.selection,n):u.map((d)=>px(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 Z$,d9,Is,Rp;var Pp=x(()=>{Er();Vn();De();GJ();F$();pr();Z$=class Z${constructor(e,t,r){this.sourceTable=e,this.referencedTable=t,this.relationName=r,this.referencedTableName=t[we.Symbol.Name]}static[J]="Relation";referencedTableName;fieldName};d9=class d9{constructor(e,t){this.table=e,this.config=t}static[J]="Relations"};Is=class Is extends Z${constructor(e,t,r,i){super(e,t,r?.relationName);this.config=r,this.isNullable=i}static[J]="One";withFieldName(e){let t=new Is(this.sourceTable,this.referencedTable,this.config,this.isNullable);return t.fieldName=e,t}};Rp=class Rp extends Z${constructor(e,t,r){super(e,t,r?.relationName);this.config=r}static[J]="Many";withFieldName(e){let t=new Rp(this.sourceTable,this.referencedTable,this.config);return t.fieldName=e,t}}});function Np(e,t){return new Proxy(e,new zp(t,!1))}function ki(e,t){return new Proxy(e,new Su(new Proxy(e.table,new zp(t,!1))))}function H$(e,t){return new Te.Aliased(Dp(e.sql,t),e.fieldAlias)}function Dp(e,t){return q.join(e.queryChunks.map((r)=>{if(ce(r,nt))return ki(r,t);if(ce(r,Te))return Dp(r,t);if(ce(r,Te.Aliased))return H$(r,t);return r}))}var Su,zp,Z_e;var mx=x(()=>{Vn();De();pr();Er();oo();Su=class Su{constructor(e){this.table=e}static[J]="ColumnAliasProxyHandler";get(e,t){if(t==="table")return this.table;return e[t]}};zp=class zp{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 Su(new Proxy(e,this)))}),n}let r=e[t];if(ce(r,nt))return new Proxy(r,new Su(new Proxy(e,this)));return r}};Z_e=class Z_e{constructor(e){this.alias=e}static[J]="RelationTableAliasProxyHandler";get(e,t){if(t==="sourceTable")return Np(e.sourceTable,this.alias);return e[t]}}});var bt;var Va=x(()=>{mx();Vn();De();pr();Wn();oo();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,Cn)?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 Su(new Proxy(i.table,new zp(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 Ur;var co=x(()=>{De();Ur=class Ur{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 K$,y9;var J$=x(()=>{De();yu();K$=class K${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 y9(e,this)}};y9=class y9{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[kr],...i,r[0].table[kr],...n];return e??`${o.join("_")}_fk`}}});function V$(e,t){return`${e[kr]}_${t.join("_")}_unique`}var b9,H_e,x9;var W$=x(()=>{De();yu();b9=class b9{constructor(e,t){this.name=t,this.columns=e}static[J]="SQLiteUniqueConstraintBuilder";columns;build(e){return new x9(e,this.columns,this.name)}};H_e=class H_e{static[J]="SQLiteUniqueOnConstraintBuilder";name;constructor(e){this.name=e}on(...e){return new b9(e,this.name)}};x9=class x9{constructor(e,t,r){this.table=e,this.columns=t,this.name=r??V$(this.table,this.columns.map((i)=>i.name))}static[J]="SQLiteUniqueConstraint";columns;name;getName(){return this.name}}});var Xt,At;var As=x(()=>{rx();Vn();De();J$();W$();Xt=class Xt extends Ep{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 K$(()=>{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=V$(e,[t.name]);super(e,t);this.table=e}static[J]="SQLiteColumn"}});function I9(e,t){let{name:r,config:i}=_i(e,t);if(i?.mode==="json")return new v9(r);if(i?.mode==="bigint")return new S9(r);return new k9(r)}var S9,w9,v9,_9,k9,E9;var G$=x(()=>{De();qr();As();S9=class S9 extends Xt{static[J]="SQLiteBigIntBuilder";constructor(e){super(e,"bigint","SQLiteBigInt")}build(e){return new w9(e,this.config)}};w9=class w9 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(B$.decode(e))}mapToDriverValue(e){return Buffer.from(e.toString())}};v9=class v9 extends Xt{static[J]="SQLiteBlobJsonBuilder";constructor(e){super(e,"json","SQLiteBlobJson")}build(e){return new _9(e,this.config)}};_9=class _9 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(B$.decode(e))}mapToDriverValue(e){return Buffer.from(JSON.stringify(e))}};k9=class k9 extends Xt{static[J]="SQLiteBlobBufferBuilder";constructor(e){super(e,"buffer","SQLiteBlobBuffer")}build(e){return new E9(e,this.config)}};E9=class E9 extends At{static[J]="SQLiteBlobBuffer";mapFromDriverValue(e){if(Buffer.isBuffer(e))return e;return Buffer.from(e)}getSQLType(){return"blob"}}});function C9(e){return(t,r)=>{let{name:i,config:n}=_i(t,r);return new A9(i,n,e)}}var A9,T9;var Q$=x(()=>{De();qr();As();A9=class A9 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 T9(e,this.config)}};T9=class T9 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 Ir(e,t){let{name:r,config:i}=_i(e,t);if(i?.mode==="timestamp"||i?.mode==="timestamp_ms")return new R9(r,i.mode);if(i?.mode==="boolean")return new z9(r,i.mode);return new $9(r)}var hx,gx,$9,O9,R9,P9,z9,N9;var Y$=x(()=>{De();pr();qr();As();hx=class hx 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()}};gx=class gx extends At{static[J]="SQLiteBaseInteger";autoIncrement=this.config.autoIncrement;getSQLType(){return"integer"}};$9=class $9 extends hx{static[J]="SQLiteIntegerBuilder";constructor(e){super(e,"number","SQLiteInteger")}build(e){return new O9(e,this.config)}};O9=class O9 extends gx{static[J]="SQLiteInteger"};R9=class R9 extends hx{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 P9(e,this.config)}};P9=class P9 extends gx{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}};z9=class z9 extends hx{static[J]="SQLiteBooleanBuilder";constructor(e,t){super(e,"boolean","SQLiteBoolean");this.config.mode=t}build(e){return new N9(e,this.config)}};N9=class N9 extends gx{static[J]="SQLiteBoolean";mode=this.config.mode;mapFromDriverValue(e){return Number(e)===1}mapToDriverValue(e){return e?1:0}}});function M9(e,t){let{name:r,config:i}=_i(e,t),n=i?.mode;return n==="number"?new B9(r):n==="bigint"?new q9(r):new D9(r)}var D9,L9,B9,j9,q9,U9;var X$=x(()=>{De();qr();As();D9=class D9 extends Xt{static[J]="SQLiteNumericBuilder";constructor(e){super(e,"string","SQLiteNumeric")}build(e){return new L9(e,this.config)}};L9=class L9 extends At{static[J]="SQLiteNumeric";mapFromDriverValue(e){if(typeof e==="string")return e;return String(e)}getSQLType(){return"numeric"}};B9=class B9 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"}};q9=class q9 extends Xt{static[J]="SQLiteNumericBigIntBuilder";constructor(e){super(e,"bigint","SQLiteNumericBigInt")}build(e){return new U9(e,this.config)}};U9=class U9 extends At{static[J]="SQLiteNumericBigInt";mapFromDriverValue=BigInt;mapToDriverValue=String;getSQLType(){return"numeric"}}});function H9(e){return new F9(e??"")}var F9,Z9;var eO=x(()=>{De();As();F9=class F9 extends Xt{static[J]="SQLiteRealBuilder";constructor(e){super(e,"number","SQLiteReal")}build(e){return new Z9(e,this.config)}};Z9=class Z9 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 V9(r);return new K9(r,i)}var K9,J9,V9,W9;var tO=x(()=>{De();qr();As();K9=class K9 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 J9(e,this.config)}};J9=class J9 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})`:""}`}};V9=class V9 extends Xt{static[J]="SQLiteTextJsonBuilder";constructor(e){super(e,"json","SQLiteTextJson")}build(e){return new W9(e,this.config)}};W9=class W9 extends At{static[J]="SQLiteTextJson";getSQLType(){return"text"}mapFromDriverValue(e){return JSON.parse(e)}mapToDriverValue(e){return JSON.stringify(e)}}});function G9(){return{blob:I9,customType:C9,integer:Ir,numeric:M9,real:H9,text:mr}}var Q9=x(()=>{G$();Q$();Y$();X$();eO();tO()});function K_e(e,t,r,i,n=e){let o=new Ut(e,i,n),s=typeof t==="function"?t(G9()):t,a=Object.fromEntries(Object.entries(s).map(([l,u])=>{let d=u;d.setName(l);let p=d.build(o);return o[rO].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[Ut.Symbol.ExtraConfigBuilder]=r;return c}var rO,Ut,Lp=(e,t,r)=>K_e(e,t,r);var lo=x(()=>{De();Er();Q9();rO=Symbol.for("drizzle:SQLiteInlineForeignKeys");Ut=class Ut extends we{static[J]="SQLiteTable";static Symbol=Object.assign({},we.Symbol,{InlineForeignKeys:rO});[we.Symbol.Columns];[rO]=[];[we.Symbol.ExtraConfigBuilder]=void 0}});var J_e,Y9;var X9=x(()=>{De();J_e=class J_e{constructor(e,t){this.name=e,this.value=t}static[J]="SQLiteCheckBuilder";brand;build(e){return new Y9(e,this)}};Y9=class Y9{constructor(e,t){this.table=e,this.name=t.name,this.value=t.value}static[J]="SQLiteCheck";name;value}});function Wa(e){return new eV(e,!1)}var eV,tV,rV;var nV=x(()=>{De();eV=class eV{constructor(e,t){this.name=e,this.unique=t}static[J]="SQLiteIndexBuilderOn";on(...e){return new tV(this.name,e,this.unique)}};tV=class tV{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 rV(this.config,e)}};rV=class rV{static[J]="SQLiteIndex";config;constructor(e,t){this.config={...e,table:t}}}});var V_e,iV;var oV=x(()=>{De();lo();V_e=class V_e{static[J]="SQLitePrimaryKeyBuilder";columns;name;constructor(e,t){this.columns=e,this.name=t}build(e){return new iV(e,this.columns,this.name)}};iV=class iV{constructor(e,t,r){this.table=e,this.columns=t,this.name=r}static[J]="SQLitePrimaryKey";columns;name;getName(){return this.name??`${this.table[Ut.Symbol.Name]}_${this.columns.map((e)=>e.name).join("_")}_pk`}}});function Gn(e){if(ce(e,Ut))return[`${e[we.Symbol.BaseName]}`];if(ce(e,vt))return e._.usedTables??[];if(ce(e,Te))return e.usedTables??[];return[]}var wu=x(()=>{De();pr();Wn();Er();lo()});var yx;var sV=x(()=>{De();co();Va();lo();Er();qr();wu();yx=class yx extends Ur{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[Ut.Symbol.Columns]){return this.config.returning=$n(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:Gn(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 W_e(e){return(e.replace(/['\u2019]/g,"").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).map((r)=>r.toLowerCase()).join("_")}function G_e(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 Q_e(e){return e}var nO;var aV=x(()=>{De();Er();nO=class nO{static[J]="CasingCache";cache={};cachedTables={};convert;constructor(e){this.convert=e==="snake_case"?W_e:e==="camelCase"?G_e:Q_e}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 vu,uo,iO;var bx=x(()=>{De();vu=class vu extends Error{static[J]="DrizzleError";constructor({message:e,cause:t}){super(e);this.name="DrizzleError",this.cause=t}};uo=class uo extends Error{constructor(e,t,r){super(`Failed query: ${e}
440
+ `;return n;function o(s){return i.stack.push(s),a;function a(){i.stack.pop()}}}function rwe(e){throw Error("Cannot handle value `"+e+"`, expected node")}function nwe(e){throw Error("Cannot handle unknown node `"+e.type+"`")}function iwe(e,t){if(e.type==="definition"&&e.type===t.type)return 0}function owe(e,t){return M5(e,this,t)}function swe(e,t){return Z5(e,this,t)}function awe(e,t){return V5(this,e,t)}var Q5=x(()=>{q3();M3();z5();D5();B5();q5();F5();K5();W5()});var Y5=x(()=>{Q5()});function kb(e){let t=this;t.compiler=r;function r(i){return AC(i,{...t.data("settings"),...e,extensions:t.data("toMarkdownExtensions")||[]})}}var X5=x(()=>{Y5()});var e8=x(()=>{X5()});function TC(e){if(e)throw e}var l8=ee(function(A3e,c8){var Eb=Object.prototype.hasOwnProperty,a8=Object.prototype.toString,t8=Object.defineProperty,r8=Object.getOwnPropertyDescriptor,n8=function(t){if(typeof Array.isArray==="function")return Array.isArray(t);return a8.call(t)==="[object Array]"},i8=function(t){if(!t||a8.call(t)!=="[object Object]")return!1;var r=Eb.call(t,"constructor"),i=t.constructor&&t.constructor.prototype&&Eb.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!r&&!i)return!1;var n;for(n in t);return typeof n>"u"||Eb.call(t,n)},o8=function(t,r){if(t8&&r.name==="__proto__")t8(t,r.name,{enumerable:!0,configurable:!0,value:r.newValue,writable:!0});else t[r.name]=r.newValue},s8=function(t,r){if(r==="__proto__"){if(!Eb.call(t,r))return;else if(r8)return r8(t,r).value}return t[r]};c8.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=s8(a,r),n=s8(t,r),a!==n){if(u&&n&&(i8(n)||(o=n8(n)))){if(o)o=!1,s=i&&n8(i)?i:[];else s=i&&i8(i)?i:{};o8(a,{name:r,newValue:e(u,s,n)})}else if(typeof n<"u")o8(a,{name:r,newValue:n})}}return a}});function Yf(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 CC(){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)u8(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 u8(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 d8=()=>{};var ur;var f8=x(()=>{aC();ur=class ur 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=ls(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}};ur.prototype.file="";ur.prototype.name="";ur.prototype.reason="";ur.prototype.message="";ur.prototype.stack="";ur.prototype.column=void 0;ur.prototype.line=void 0;ur.prototype.ancestors=void 0;ur.prototype.cause=void 0;ur.prototype.fatal=void 0;ur.prototype.place=void 0;ur.prototype.ruleId=void 0;ur.prototype.source=void 0});var p8=x(()=>{f8()});import{default as Zn}from"path";var m8=()=>{};import{default as h8}from"process";var g8=()=>{};function Ib(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 y8}from"url";var b8=()=>{};class Ab{constructor(e){let t;if(!e)t={};else if(Ib(e))t={path:e};else if(typeof e==="string"||cwe(e))t={value:e};else t=e;this.cwd="cwd"in t?"":h8.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;while(++r<$C.length){let n=$C[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(!$C.includes(i))this[i]=t[i]}get basename(){return typeof this.path==="string"?Zn.basename(this.path):void 0}set basename(e){RC(e,"basename"),OC(e,"basename"),this.path=Zn.join(this.dirname||"",e)}get dirname(){return typeof this.path==="string"?Zn.dirname(this.path):void 0}set dirname(e){x8(this.basename,"dirname"),this.path=Zn.join(e||"",this.basename)}get extname(){return typeof this.path==="string"?Zn.extname(this.path):void 0}set extname(e){if(OC(e,"extname"),x8(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=Zn.join(this.dirname,this.stem+(e||""))}get path(){return this.history[this.history.length-1]}set path(e){if(Ib(e))e=y8(e);if(RC(e,"path"),this.path!==e)this.history.push(e)}get stem(){return typeof this.path==="string"?Zn.basename(this.path,this.extname):void 0}set stem(e){RC(e,"stem"),OC(e,"stem"),this.path=Zn.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 ur(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 OC(e,t){if(e&&e.includes(Zn.sep))throw Error("`"+t+"` cannot be a path: did not expect `"+Zn.sep+"`")}function RC(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function x8(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}function cwe(e){return Boolean(e&&typeof e==="object"&&"byteLength"in e&&"byteOffset"in e)}var $C;var S8=x(()=>{p8();m8();g8();b8();$C=["history","path","basename","stem","extname","dirname"]});var w8=x(()=>{S8()});var v8=function(e){let i=this.constructor.prototype,n=i[e],o=function(){return n.apply(o,arguments)};return Object.setPrototypeOf(o,i),o};function PC(e,t){if(typeof t!=="function")throw TypeError("Cannot `"+e+"` without `parser`")}function zC(e,t){if(typeof t!=="function")throw TypeError("Cannot `"+e+"` without `compiler`")}function NC(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 _8(e){if(!Yf(e)||typeof e.type!=="string")throw TypeError("Expected node, got `"+e+"`")}function k8(e,t,r){if(!r)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function Tb(e){return uwe(e)?e:new Ab(e)}function uwe(e){return Boolean(e&&typeof e==="object"&&"message"in e&&"messages"in e)}function dwe(e){return typeof e==="string"||fwe(e)}function fwe(e){return Boolean(e&&typeof e==="object"&&"byteLength"in e&&"byteOffset"in e)}var Cb,lwe,DC,LC;var E8=x(()=>{tt();d8();w8();Cb=rc(l8(),1),lwe={}.hasOwnProperty;DC=class DC extends v8{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=CC()}copy(){let e=new DC,t=-1;while(++t<this.attachers.length){let r=this.attachers[t];e.use(...r)}return e.data(Cb.default(!0,{},this.namespace)),e}data(e,t){if(typeof e==="string"){if(arguments.length===2)return NC("data",this.frozen),this.namespace[e]=t,this;return lwe.call(this.namespace,e)&&this.namespace[e]||void 0}if(e)return NC("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=Tb(e),r=this.parser||this.Parser;return PC("parse",r),r(String(t),t)}process(e,t){let r=this;return this.freeze(),PC("process",this.parser||this.Parser),zC("process",this.compiler||this.Compiler),t?i(void 0,t):new Promise(i);function i(n,o){let s=Tb(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(dwe(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(),PC("processSync",this.parser||this.Parser),zC("processSync",this.compiler||this.Compiler),this.process(e,i),k8("processSync","process",t),B(r,"we either bailed on an error or have a tree"),r;function i(n,o){t=!0,TC(n),r=o}}run(e,t,r){_8(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=Tb(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),k8("runSync","run",r),B(i,"we either bailed on an error or have a tree"),i;function n(o,s){TC(o),i=s,r=!0}}stringify(e,t){this.freeze();let r=Tb(t),i=this.compiler||this.Compiler;return zC("stringify",i),_8(e),i(e,r)}use(e,...t){let r=this.attachers,i=this.namespace;if(NC("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=Cb.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(Yf(y)&&Yf(p))p=Cb.default(!0,y,p);r[d]=[c,p,...m]}}}};LC=new DC().freeze()});var I8=x(()=>{E8()});var A8;var T8=x(()=>{L3();e8();I8();A8=LC().use(yb).use(kb).freeze()});var p5e;var C8=x(()=>{Re();p5e=f.record(f.string(),f.unknown())});var g5e;var $8=x(()=>{Re();Og();g5e=f.record(f.string(),f.unknown())});var O8=x(()=>{Og()});var R8=x(()=>{Nf();NU();rZ();nZ();C8();$8();O8();QA()});var wwe;var P8=x(()=>{Re();wwe=f.object({slug:f.string(),title:f.string(),type:f.string(),entityId:f.string(),contentHash:f.string()})});var jC=x(()=>{R8();P8()});var z8=x(()=>{jC();Re()});var N8=x(()=>{jC();Re()});var n8e;var D8=x(()=>{Jy();T8();n8e=A8()});var vwe,_we;var L8=x(()=>{D8();Re();GA();vwe=Py.omit({url:!0,analyticsScript:!0}),_we=vwe.extend({title:f.string().optional().describe("Optional site title override"),description:f.string().optional().describe("Optional site description override")})});function qC(e,t={}){let r=B8(e),i=B8(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 B8(e){return e.trim().replace(/^https?:\/\//i,"").replace(/\/$/,"").toLowerCase()}var j8=()=>{};var q8=x(()=>{j8()});function U8(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var kwe,Ewe;var M8=x(()=>{Re();JA();kwe=f.string(),Ewe=f.custom((e)=>{if(!U8(e))return!1;let{plugin:t,...r}=e;if(t!==void 0&&typeof t!=="function")return!1;return CU.safeParse(r).success})});var F8=x(()=>{VA();GA();z8();N8();L8();q8();M8()});function Z8(e,t={}){return qC(e,t)}var H8=x(()=>{F8()});var Y8={};tr(Y8,{assertPilotUsersRemoved:()=>Q8,createPilotOffboardDriver:()=>J8,offboardPilotUsers:()=>Owe});import{access as Iwe,readdir as Awe,readFile as Twe,rm as Xf,writeFile as Cwe}from"fs/promises";import{basename as $we,join as Xi}from"path";async function Owe(e,t){let r=[...new Set(t.handles.map((d)=>Dr.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 Zt(e),c=r.map((d)=>Rwe(a,d,o)),l=t.driver??J8({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(zwe(u),Nwe(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 Pwe(c,l,t.sleep??((d)=>new Promise((p)=>setTimeout(p,d)))),await Dwe(e,r),await Zo(e),await Q8(e,r),s(`Removed desired state for ${r.length} pilot user(s)`)}return{dryRun:i,handles:r,confirmation:n,plans:u}}function Rwe(e,t,r){let i=e.users.find((u)=>u.handle===t),n=`${t}${e.pilot.domainSuffix}`,o=i?.domain??n,s=Z8(o,{sharedDomain:e.pilot.domainSuffix}),a=i?.cloudflareZoneId??$b(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 Pwe(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 zwe(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 Nwe(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 Dwe(e,t){let r=new Set(t),i=Xi(e,"cohorts");for(let n of(await Awe(i)).filter((o)=>o.endsWith(".yaml"))){let o=Xi(i,n),s=await Twe(o,"utf8"),a=gi(s);if(a.errors.length>0)throw Error(`${n}: ${a.errors[0]?.message??"invalid YAML"}`);let c=a.get("members",!0);if(!FA(c))throw Error(`${n}: members must be a sequence`);let l=c.items.filter((u)=>!wl(u)||typeof u.value!=="string"||!r.has(u.value));if(l.length===c.items.length)continue;if(l.length===0){await Xf(o);continue}c.items=l,Un.parse(a.toJS()),await Cwe(o,a.toString())}for(let n of t)await Promise.all([Xf(Xi(e,"users",`${n}.yaml`),{force:!0}),Xf(Xi(e,"users",`${n}.secrets.yaml`),{force:!0}),Xf(Xi(e,"users",`${n}.secrets.yaml.age`),{force:!0}),Xf(Xi(e,"users",n),{recursive:!0,force:!0})])}function J8(e){let t=e.fetchImpl??fetch,r=$b(e.env,"HCLOUD_TOKEN"),i=$b(e.env,"CF_API_TOKEN"),n=$b(e.env,e.contentRepoTokenName);return{async inspect(o){let[s,a,c]=await Promise.all([Lwe(t,r,o.instanceName),Promise.all([o.domain,o.previewDomain,...o.wwwDomain?[o.wwwDomain]:[]].map((l)=>Bwe(t,i,o.cloudflareZoneId,l))).then((l)=>l.flat()),jwe(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 Hl(t,`https://api.github.com/repos/${o.contentRepo}`,{method:"PATCH",headers:V8(n),body:JSON.stringify({archived:!0})},"GitHub repository archive")},async deleteDnsRecord(o,s){if(Kl(await Hl(t,`https://api.cloudflare.com/client/v4/zones/${o.cloudflareZoneId}/dns_records/${s.id}`,{method:"DELETE",headers:W8(i)},"Cloudflare DNS delete")).success!==!0)throw Error(`Cloudflare DNS delete failed for ${s.name}`)},async deleteServer(o,s){await Hl(t,`https://api.hetzner.cloud/v1/servers/${s.id}`,{method:"DELETE",headers:{Authorization:`Bearer ${r}`}},"Hetzner server delete",!0)}}}async function Lwe(e,t,r){let i=new URL("https://api.hetzner.cloud/v1/servers");i.searchParams.set("label_selector",`brain=${r}`);let o=Kl(await Hl(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=Kl(s),c=K8(a.public_net),l=K8(c?.ipv4);return{id:qwe(a.id,"Hetzner server id"),name:ep(a.name,"Hetzner server name"),...typeof l?.ip==="string"?{ip:l.ip}:{}}})}async function Bwe(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=Kl(await Hl(e,n.toString(),{headers:W8(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=Kl(a),l=ep(c.type,"Cloudflare record type");if(l!=="A"&&l!=="CNAME")throw Error(`Unsupported Cloudflare record type ${l} for ${i}`);return{id:ep(c.id,"Cloudflare record id"),name:ep(c.name,"Cloudflare record name"),type:l,content:ep(c.content,"Cloudflare record content")}})}async function jwe(e,t,r){let i=Kl(await Hl(e,`https://api.github.com/repos/${r}`,{headers:V8(t)},"GitHub repository lookup"));if(typeof i.archived!=="boolean")throw Error(`Invalid repository archive state for ${r}`);return{archived:i.archived}}async function Hl(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 V8(e){return{Accept:"application/vnd.github+json",Authorization:`Bearer ${e}`,"Content-Type":"application/json","X-GitHub-Api-Version":"2022-11-28"}}function W8(e){return{Authorization:`Bearer ${e}`}}function $b(e,t){let r=e[t];if(!r)throw Error(`Missing required environment variable: ${t}`);return r}function G8(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function Kl(e){if(!G8(e))throw Error("Provider returned an unexpected payload");return e}function K8(e){return G8(e)?e:void 0}function ep(e,t){if(typeof e!=="string"||e.length===0)throw Error(`Missing ${t}`);return e}function qwe(e,t){if(typeof e!=="number")throw Error(`Missing ${t}`);return e}async function Uwe(e){try{return await Iwe(e),!0}catch{return!1}}async function Q8(e,t){for(let r of t)for(let i of[Xi(e,"users",`${r}.yaml`),Xi(e,"users",`${r}.secrets.yaml.age`),Xi(e,"users",r)])if(await Uwe(i))throw Error(`Offboarded user state remains: ${$we(i)}`)}var X8=x(()=>{Pf();pi();H8();af();fa()});var eH="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";import{webcrypto as tH}from"crypto";function Fwe(e){if(e<0)throw RangeError("Wrong ID size");try{if(!ds||ds.length<e)ds=Buffer.allocUnsafe(e*Mwe),tH.getRandomValues(ds),Jl=0;else if(Jl+e>ds.length)tH.getRandomValues(ds),Jl=0}catch(t){throw ds=void 0,t}Jl+=e}function rH(e=21){Fwe(e|=0);let t="";for(let r=Jl-e;r<Jl;r++)t+=eH[ds[r]&63];return t}var Mwe=128,ds,Jl;var nH=()=>{};function eo(e=12){return rH(e)}var tp=x(()=>{nH()});import{openSync as Zwe,writeSync as Hwe}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=Zwe(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{Hwe(this.fileHandle,n+`
441
+ `)}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,rHe;var UC=x(()=>{Da={SILLY:0,VERBOSE:1,DEBUG:2,INFO:3,WARN:4,ERROR:5,NONE:6};rHe=fn.getInstance()});var MC,Kwe,Vl,sHe;var rp=x(()=>{is();Re();MC=f.enum(["file_operations","content_operations","data_processing","batch_processing"]),Kwe=f.looseObject({pluginId:f.string().optional(),progressToken:f.union([f.string(),f.number()]).optional(),operationType:MC,operationTarget:f.string().optional(),interfaceType:f.string().optional(),conversationId:f.string().optional(),channelId:f.string().optional(),requestedByActor:zl.optional(),requestedByUserId:f.string().optional(),requestedByInterface:f.string().optional(),silent:f.boolean().optional(),provenance:ns.optional()}),Vl=f.looseObject({pluginId:f.string().optional(),progressToken:f.union([f.string(),f.number()]).optional(),operationType:MC,operationTarget:f.string().optional(),interfaceType:f.string().optional(),conversationId:f.string().optional(),channelId:f.string().optional(),requestedByActor:zl.optional(),requestedByUserId:f.string().optional(),requestedByInterface:f.string().optional(),silent:f.boolean().optional(),provenance:ns.optional(),rootJobId:f.string()}),sHe=f.enum(["none","skip","replace","coalesce"])});var Jwe,fs=15000;var np=x(()=>{rp();Re();Jwe=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:Vl,progress:f.custom((e)=>typeof e==="object"&&e!==null&&("progress"in e)&&typeof e.progress==="number").nullable(),result:f.unknown().nullable().optional()})});var FC,iH,He,Vwe,Wwe,oH,Gwe;var ps=x(()=>{Re();rp();FC=f.enum(["pending","processing","completed","failed"]),iH=f.enum(["completed","failed"]),He={PENDING:"pending",PROCESSING:"processing",COMPLETED:"completed",FAILED:"failed"},Vwe=f.object({id:f.string(),type:f.string(),status:FC,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()}),Wwe=f.object({jobId:f.string(),type:f.string(),status:iH,result:f.unknown().optional(),error:f.string().optional()}),oH=f.object({success:f.literal(!1),error:f.string().optional()}),Gwe=f.object({id:f.string(),type:f.enum(["job","batch"]),status:FC,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:Vl})});var je,dr;var Hn=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 sH(e){let t=Qwe.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?Ywe(r.authority):void 0,o=La(r.path),s=r.query!==void 0?e0e(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 Ywe(e){let t=Xwe.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 e0e(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 ip(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=t0e(t.host),o=r0e(t.port),a=`//${n0e(t.userinfo)}${n}${o}`,c=r.split("/").map(encodeURIComponent).join("/");if(c!==""&&!c.startsWith("/"))c="/"+c;return new URL(`${i}${a}${c}`)}function t0e(e){return e.includes(":")?`[${encodeURI(e)}]`:encodeURI(e)}function r0e(e){return e!==void 0?`:${e}`:""}function n0e(e){if(e===void 0)return"";let t=encodeURIComponent(e.username),r=e.password!==void 0?`:${encodeURIComponent(e.password)}`:"";return`${t}${r}@`}var Qwe,Xwe;var Ob=x(()=>{Hn();Qwe=(()=>new RegExp("^(?<scheme>[A-Za-z][A-Za-z.+-]*):(//(?<authority>[^/?#]*))?(?<path>[^?#]*)(\\?(?<query>[^#]*))?(#(?<fragment>.*))?$","su"))();Xwe=(()=>new RegExp("^((?<username>[^:]*)(:(?<password>.*))?@)?((?<host>[^:\\[\\]]*)|(\\[(?<host_br>[^\\[\\]]*)\\]))(:(?<port>[0-9]*))?$","su"))()});var Gl,aH,cH,op,Rb,i0e,fr,lH,fH=(e)=>e.replace(/=/g,"").replace(/[+\/]/g,(t)=>t=="+"?"-":"_"),pH=(e)=>e.replace(/[^A-Za-z0-9\+\/]/g,""),mH=(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+=op[t>>18&63]+op[t>>12&63]+op[t>>6&63]+op[t&63]}return s?o.slice(0,s-3)+"===".substring(s):o},KC,ZC,Pb=(e,t=!1)=>t?fH(ZC(e)):ZC(e),o0e=(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)}},s0e,hH=(e)=>e.replace(s0e,o0e),uH,Wl=(e,t=!1)=>t?fH(uH(e)):uH(e),dH=(e)=>Wl(e,!0),a0e,c0e=(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))}},gH=(e)=>e.replace(a0e,c0e),yH=(e)=>{if(e=e.replace(/\s+/g,""),!i0e.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=Rb[e.charAt(o++)]<<18|Rb[e.charAt(o++)]<<12|(r=Rb[e.charAt(o++)])<<6|(i=Rb[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("")},JC,bH,xH=(e)=>bH(SH(e)),l0e,SH=(e)=>pH(e.replace(/[-_]/g,(t)=>t=="-"?"+":"/")),HC=(e)=>l0e(SH(e)),u0e=(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)},wH=(e)=>({value:e,enumerable:!1,writable:!0,configurable:!0}),vH=function(){let e=(t,r)=>Object.defineProperty(String.prototype,t,wH(r));e("fromBase64",function(){return HC(this)}),e("toBase64",function(t){return Wl(this,t)}),e("toBase64URI",function(){return Wl(this,!0)}),e("toBase64URL",function(){return Wl(this,!0)}),e("toUint8Array",function(){return xH(this)})},_H=function(){let e=(t,r)=>Object.defineProperty(Uint8Array.prototype,t,wH(r));e("toBase64",function(t){return Pb(this,t)}),e("toBase64URI",function(){return Pb(this,!0)}),e("toBase64URL",function(){return Pb(this,!0)})},d0e=()=>{vH(),_H()},Ql;var zb=x(()=>{Gl=typeof Buffer==="function",aH=typeof TextDecoder==="function"?new TextDecoder("utf-8",{ignoreBOM:!0}):void 0,cH=typeof TextEncoder==="function"?new TextEncoder:void 0,op=Array.prototype.slice.call("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="),Rb=((e)=>{let t={};return e.forEach((r,i)=>t[r]=i),t})(op),i0e=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,fr=String.fromCharCode.bind(String),lH=typeof Uint8Array.from==="function"?Uint8Array.from.bind(Uint8Array):(e)=>new Uint8Array(Array.prototype.slice.call(e,0)),KC=typeof btoa==="function"?(e)=>btoa(e):Gl?(e)=>Buffer.from(e,"binary").toString("base64"):mH,ZC=Gl?(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 KC(r.join(""))},s0e=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,uH=Gl?(e)=>Buffer.from(e,"utf8").toString("base64"):cH?(e)=>ZC(cH.encode(e)):(e)=>KC(hH(e)),a0e=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,JC=typeof atob==="function"?(e)=>atob(pH(e)):Gl?(e)=>Buffer.from(e,"base64").toString("binary"):yH,bH=Gl?(e)=>lH(Buffer.from(e,"base64")):(e)=>lH(JC(e).split("").map((t)=>t.charCodeAt(0))),l0e=Gl?(e)=>Buffer.from(e,"base64").toString("utf8"):aH?(e)=>aH.decode(bH(e)):(e)=>gH(JC(e)),Ql={version:"3.8.0",VERSION:"3.8.0",atob:JC,atobPolyfill:yH,btoa:KC,btoaPolyfill:mH,fromBase64:HC,toBase64:Wl,encode:Wl,encodeURI:dH,encodeURL:dH,utob:hH,btou:gH,decode:HC,isValid:u0e,fromUint8Array:Pb,toUint8Array:xH,extendString:vH,extendUint8Array:_H,extendBuiltins:d0e}});function ms(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 Yl{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(f0e),rowsAffected:this.rowsAffected,lastInsertRowid:this.lastInsertRowid!==void 0?""+this.lastInsertRowid:null}}}function f0e(e){return Array.prototype.map.call(e,p0e)}function p0e(e){if(typeof e==="bigint")return""+e;else if(e instanceof ArrayBuffer)return Ql.fromUint8Array(new Uint8Array(e));else return e}var xi="https://github.com/libsql/libsql-client-ts#supported-urls";var Xl=x(()=>{zb()});function EH(e){return e.scheme==="file"&&(e.path===":memory:"||e.path.startsWith(":memory:?"))}function sp(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===kH)r="file::memory:";let c=sH(r),l=c.scheme.toLowerCase(),u=l==="file"&&c.path===kH&&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 kH=":memory:";var ap=x(()=>{Hn();Ob();Xl()});var AH=ee(function(In){var m0e=In&&In.__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]}),h0e=In&&In.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),IH=In&&In.__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))m0e(t,e,r)}return h0e(t,e),t};Object.defineProperty(In,"__esModule",{value:!0});In.load=In.currentTarget=void 0;var g0e=IH(Tt("path")),y0e=IH(Tt("fs"));function b0e(){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 x0e()?`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}`)}In.currentTarget=b0e;function x0e(){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 S0e(e){let t=g0e.join(e,"index.node");return y0e.existsSync(t)?Tt(t):null}In.load=S0e});var $H=ee(function(IHe,CH){var TH=()=>process.platform==="linux",VC=null,w0e=()=>{if(!VC)VC=TH()&&process.report?process.report.getReport():{};return VC};CH.exports={isLinux:TH,getReport:w0e}});var PH=ee(function(AHe,RH){var OH=Tt("fs"),v0e=(e)=>OH.readFileSync(e,"utf-8"),_0e=(e)=>new Promise((t,r)=>{OH.readFile(e,"utf-8",(i,n)=>{if(i)r(i);else t(n)})});RH.exports={LDD_PATH:"/usr/bin/ldd",readFileSync:v0e,readFile:_0e}});var GH=ee(function(THe,WH){var NH=Tt("child_process"),{isLinux:eu,getReport:DH}=$H(),{LDD_PATH:Nb,readFile:LH,readFileSync:BH}=PH(),Si,wi,hs="",jH=()=>{if(!hs)return new Promise((e)=>{NH.exec("getconf GNU_LIBC_VERSION 2>&1 || true; ldd --version 2>&1 || true",(t,r)=>{hs=t?" ":r,e(hs)})});return hs},qH=()=>{if(!hs)try{hs=NH.execSync("getconf GNU_LIBC_VERSION 2>&1 || true; ldd --version 2>&1 || true",{encoding:"utf8"})}catch(e){hs=" "}return hs},to="glibc",UH=/GLIBC\s(\d+\.\d+)/,Ba="musl",k0e=to.toUpperCase(),E0e=Ba.toLowerCase(),I0e=(e)=>e.includes("libc.musl-")||e.includes("ld-musl-"),MH=()=>{let e=DH();if(e.header&&e.header.glibcVersionRuntime)return to;if(Array.isArray(e.sharedObjects)){if(e.sharedObjects.some(I0e))return Ba}return null},FH=(e)=>{let[t,r]=e.split(/[\r\n]+/);if(t&&t.includes(to))return to;if(r&&r.includes(Ba))return Ba;return null},ZH=(e)=>{if(e.includes(E0e))return Ba;if(e.includes(k0e))return to;return null},A0e=async()=>{if(Si!==void 0)return Si;Si=null;try{let e=await LH(Nb);Si=ZH(e)}catch(e){}return Si},T0e=()=>{if(Si!==void 0)return Si;Si=null;try{let e=BH(Nb);Si=ZH(e)}catch(e){}return Si},HH=async()=>{let e=null;if(eu()){if(e=await A0e(),!e)e=MH();if(!e){let t=await jH();e=FH(t)}}return e},KH=()=>{let e=null;if(eu()){if(e=T0e(),!e)e=MH();if(!e){let t=qH();e=FH(t)}}return e},C0e=async()=>eu()&&await HH()!==to,$0e=()=>eu()&&KH()!==to,O0e=async()=>{if(wi!==void 0)return wi;wi=null;try{let t=(await LH(Nb)).match(UH);if(t)wi=t[1]}catch(e){}return wi},R0e=()=>{if(wi!==void 0)return wi;wi=null;try{let t=BH(Nb).match(UH);if(t)wi=t[1]}catch(e){}return wi},JH=()=>{let e=DH();if(e.header&&e.header.glibcVersionRuntime)return e.header.glibcVersionRuntime;return null},zH=(e)=>e.trim().split(/\s+/)[1],VH=(e)=>{let[t,r,i]=e.split(/[\r\n]+/);if(t&&t.includes(to))return zH(t);if(r&&i&&r.includes(Ba))return zH(i);return null},P0e=async()=>{let e=null;if(eu()){if(e=await O0e(),!e)e=JH();if(!e){let t=await jH();e=VH(t)}}return e},z0e=()=>{let e=null;if(eu()){if(e=R0e(),!e)e=JH();if(!e){let t=qH();e=VH(t)}}return e};WH.exports={GLIBC:to,MUSL:Ba,family:HH,familySync:KH,isNonGlibcLinux:C0e,isNonGlibcLinuxSync:$0e,version:P0e,versionSync:z0e}});var YH=ee(function(CHe,QH){var N0e={ALLOW:0,DENY:1};QH.exports=N0e});var eK=ee(function($He,XH){var WC={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),WC.value=""+e,Object.defineProperty(this,"message",WC),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",WC);XH.exports=ja});var cK=ee(function(OHe,Db){var __dirname="/home/runner/work/brains/brains/node_modules/libsql",{load:D0e,currentTarget:L0e}=AH(),{familySync:tK,GLIBC:B0e,MUSL:j0e}=GH();function q0e(){if(process.env.LIBSQL_JS_DEV)return D0e(__dirname);let e=L0e();if(tK()==B0e)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"&&tK()==j0e)e="linux-arm-musleabihf";return Tt(`@libsql/${e}`)}var{databaseOpen:U0e,databaseOpenWithSync:M0e,databaseInTransaction:F0e,databaseInterrupt:Z0e,databaseClose:H0e,databaseSyncSync:K0e,databaseSyncUntilSync:J0e,databaseExecSync:V0e,databasePrepareSync:W0e,databaseDefaultSafeIntegers:G0e,databaseAuthorizer:Q0e,databaseLoadExtension:Y0e,databaseMaxWriteReplicationIndex:X0e,statementRaw:eve,statementIsReader:tve,statementGet:rK,statementRun:nK,statementInterrupt:rve,statementRowsSync:iK,statementColumns:nve,statementSafeIntegers:ive,rowsNext:ove}=q0e(),sve=YH(),oK=eK();function tu(e){if(e.libsqlError)return new oK(e.message,e.code,e.rawCode);return e}class sK{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=M0e(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=U0e(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 F0e(n)}}})}sync(){return K0e.call(this.db)}syncUntil(e){return J0e.call(this.db,e)}prepare(e){try{let t=W0e.call(this.db,e);return new aK(t)}catch(t){throw tu(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){Q0e.call(this.db,e)}loadExtension(...e){Y0e.call(this.db,...e)}maxWriteReplicationIndex(){return X0e.call(this.db)}exec(e){try{V0e.call(this.db,e)}catch(t){throw tu(t)}}interrupt(){Z0e.call(this.db)}close(){H0e.call(this.db),this.open=!1}defaultSafeIntegers(e){return G0e.call(this.db,e??!0),this}unsafeMode(...e){throw Error("not implemented")}}class aK{constructor(e){this.stmt=e,this.pluckMode=!1}raw(e){return eve.call(this.stmt,e??!0),this}pluck(e){return this.pluckMode=e??!0,this}get reader(){return tve.call(this.stmt)}run(...e){try{if(e.length==1&&typeof e[0]==="object")return nK.call(this.stmt,e[0]);else return nK.call(this.stmt,e.flat())}catch(t){throw tu(t)}}get(...e){try{if(e.length==1&&typeof e[0]==="object")return rK.call(this.stmt,e[0]);else return rK.call(this.stmt,e.flat())}catch(t){throw tu(t)}}iterate(...e){var t=void 0;if(e.length==1&&typeof e[0]==="object")t=iK.call(this.stmt,e[0]);else t=iK.call(this.stmt,e.flat());return{nextRows:Array(100),nextRowIndex:100,next(){try{if(this.nextRowIndex===100)ove.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 tu(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 tu(t)}}interrupt(){rve.call(this.stmt)}columns(){return nve.call(this.stmt)}safeIntegers(e){return ive.call(this.stmt,e??!0),this}}Db.exports=sK;Db.exports.Authorization=sve;Db.exports.SqliteError=oK});import{Buffer as uK}from"buffer";function dK(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=EH(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 cp.default(i,n);return Jt(o,"SELECT 1 AS checkThatTheDatabaseCanBeOpened",e.intMode),new fK(i,n,o,e.intMode)}class fK{#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,ms(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,ms("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,ms(e),this.#n),this.#r=null,new pK(t,this.#n)}async executeMultiple(e){this.#i();let t=this.#o();try{return mK(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 cp.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 cp.default(this.#e,this.#t);return this.#r}}class pK{#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(),mK(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)=>lK(o,r));else{n={};for(let o in t.args){let s=o[0]==="@"||o[0]==="$"||o[0]===":"?o.substring(1):o;n[s]=lK(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)=>ave(p,a,r)),u=0,d=void 0;return new Yl(a,c,l,0,void 0)}else{let a=o.run(n),c=a.changes,l=BigInt(a.lastInsertRowid);return new Yl([],[],[],c,l)}}catch(o){throw hK(o)}}function ave(e,t,r){let i={};Object.defineProperty(i,"length",{value:e.length});for(let n=0;n<e.length;++n){let o=cve(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 cve(e,t){if(typeof e==="bigint")if(t==="number"){if(e<lve||e>uve)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 uK)return e.buffer;return e}function lK(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<dve||e>fve)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 uK.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 mK(e,t){try{e.exec(t)}catch(r){throw hK(r)}}function hK(e){if(e instanceof cp.default.SqliteError){let t=e.code,r=pve(e.rawCode);return new je(e.message,r,t,e.rawCode,e)}return e}function pve(e){if(e===void 0)return"SQLITE_UNKNOWN";let t=e&255;return mve[t]??`SQLITE_UNKNOWN_${t.toString()}`}var cp,lve,uve=9007199254740991n,dve,fve=9223372036854775807n,mve;var gK=x(()=>{Hn();ap();Xl();cp=rc(cK(),1);Hn();lve=-9007199254740991n;dve=-9223372036854775808n;mve={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 gs;var GC=x(()=>{if(typeof WebSocket<"u")gs=WebSocket;else if(typeof global<"u")gs=global.WebSocket;else if(typeof window<"u")gs=window.WebSocket;else if(typeof self<"u")gs=self.WebSocket});class ru{constructor(){this.intMode="number"}intMode}var st,qe,lp,Rt,up,nu,qa,Kn,_r,vi;var Pt=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"}};lp=class lp extends st{code;proto;constructor(e,t){super(e);this.name="ResponseError",this.code=t.code,this.proto=t,this.stack=void 0}};Rt=class Rt extends st{constructor(e,t){if(t!==void 0){super(`${e}: ${t}`);this.cause=t}else super(e);this.name="ClosedError"}};up=class up extends st{constructor(e){super(e);this.name="WebSocketUnsupportedError"}};nu=class nu 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"}};Kn=class Kn extends st{constructor(e){super(e);this.name="ProtocolVersionError"}};_r=class _r 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 iu(e,"string")}function pn(e){if(e===null||e===void 0)return;else if(typeof e==="string")return e;throw iu(e,"string or null")}function ro(e){if(typeof e==="number")return e;throw iu(e,"number")}function ys(e){if(typeof e==="boolean")return e;throw iu(e,"boolean")}function dp(e){if(Array.isArray(e))return e;throw iu(e,"array")}function qt(e){if(e!==null&&typeof e==="object"&&!Array.isArray(e))return e;throw iu(e,"object")}function Jn(e,t){return dp(e).map((r)=>t(qt(r)))}function iu(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(qt(e))}var ou=x(()=>{Pt()});class yK{#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 fp(e,t){let r=[],i=new yK(r);return i.begin(),t(i,e),i.end(),r.join("")}var Ma=0,pp=1,mp=2,bK=5;class xK{#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 SK{#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(mp);let e=this.#e.varint();return this.#e.bytes(e)}string(){return new TextDecoder().decode(this.bytes())}message(e){return bs(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(pp),this.#e.double()}maybeSkip(){if(this.#t<0)return;else if(this.#t===Ma)this.#e.skipVarint();else if(this.#t===pp)this.#e.skip(8);else if(this.#t===mp){let e=this.#e.varint();this.#e.skip(e)}else if(this.#t===bK)this.#e.skip(4);else throw new qe(`Unexpected wire type ${this.#t}`);this.#t=-1}}function bs(e,t){let r=new xK(e),i=new SK(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 QC=x(()=>{Pt()});class YC{#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,mp),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 YC;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,pp),this.#i(8),this.#r.setFloat64(this.#n,t,!0),this.#n+=8}data(){return new Uint8Array(this.#e,0,this.#n)}}function hp(e,t){let r=new YC;return t(r,e),r.data()}var wK=()=>{};var XC=x(()=>{ou();QC();wK()});class xs{#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 _r("Freeing an id that is not allocated");if(this.#t.delete(this.#e.size),e<this.#e.size)this.#t.add(e)}}var e$=x(()=>{Pt()});function rt(e,t){throw new _r(t)}var An=x(()=>{Pt()});function su(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<gve||e>yve)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 t$(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 gve,yve=9223372036854775807n;var r$=x(()=>{Pt();An();gve=-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 Bb(e,t){let r=Fa(e),i=e.rows.map((n)=>vK(r.columnNames,n,t));return{...r,rows:i}}function jb(e,t){let r=Fa(e),i;if(e.rows.length>0)i=vK(r.columnNames,e.rows[0],t);return{...r,row:i}}function qb(e,t){let r=Fa(e),i;if(e.rows.length>0&&r.columnNames.length>0)i=t$(e.rows[0][0],t);return{...r,value:i}}function vK(e,t,r){let i={};Object.defineProperty(i,"length",{value:t.length});for(let n=0;n<t.length;++n){let o=t$(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 no(e){return new lp(e.message,e)}var gp=x(()=>{Pt();r$()});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 Rt("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 yp(e,t){if(t instanceof Za)return{sqlId:t._getSqlId(e)};else return{sql:""+t}}var au=x(()=>{Pt()});class Ss{#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 bp{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(su(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]=su(t),this}bindName(e,t){return this._namedArgs.set(e,su(t)),this}unbindAll(){return this._args.length=0,this._namedArgs.clear(),this}}function Ub(e,t,r){let i,n=[],o=[];if(t instanceof bp){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)=>su(c));else o=Object.entries(t[1]).map(([c,l])=>({name:c,value:su(l)}));else i=t;let{sql:s,sqlId:a}=yp(e,i);return{sql:s,sqlId:a,args:n,namedArgs:o,wantRows:r}}var Mb=x(()=>{au();r$()});class Fb{_stream;#e;_steps;#t;constructor(e,t){this._stream=e,this.#e=t,this._steps=[],this.#t=!1}step(){return new n$(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 xve(this._stream,this._steps,e);else return bve(this._stream,this._steps,e)}}function bve(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 xve(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 no(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 n${_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,Bb)}queryRow(e){return this.#t(e,!0,jb)}queryValue(e){return this.#t(e,!0,qb)}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=Ub(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(no(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:_K(e)})}static error(e){return new wt(e._batch,{type:"error",step:_K(e)})}static not(e){return new wt(e._batch,{type:"not",cond:e._proto})}static and(e,t){for(let r of t)kK(e,r);return new wt(e,{type:"and",conds:t.map((r)=>r._proto)})}static or(e,t){for(let r of t)kK(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 _K(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 kK(e,t){if(t._batch!==e)throw new vi("Cannot mix BatchCond objects for different Batch objects")}var i$=x(()=>{Pt();gp();Mb();An()});function EK(e){return{paramNames:e.params.map((t)=>t.name),columns:e.cols,isExplain:e.isExplain,isReadonly:e.isReadonly}}class cu{constructor(e){this.intMode=e}query(e){return this.#e(e,!0,Bb)}queryRow(e){return this.#e(e,!0,jb)}queryValue(e){return this.#e(e,!0,qb)}run(e){return this.#e(e,!1,Fa)}#e(e,t,r){let i=Ub(this._sqlOwner(),e,t);return this._execute(i).then((n)=>r(n,this.intMode))}batch(e=!1){return new Fb(this,e)}describe(e){let t=yp(this._sqlOwner(),e);return this._describe(t).then(EK)}sequence(e){let t=yp(this._sqlOwner(),e);return this._sequence(t)}intMode}var Zb=x(()=>{i$();gp();au();Mb()});class xp{}var Sve=1000,wve=10,o$;var IK=x(()=>{Pt();o$=class o$ extends xp{#e;#t;#r;#n;#i;#o;#a;constructor(e,t,r){super();this.#e=e,this.#t=t,this.#r=r,this.#n=new Ss,this.#i=new Ss,this.#o=void 0,this.#a=!1}async next(){for(;;){if(this.#o!==void 0)throw new Rt("Cursor is closed",this.#o);while(!this.#a&&this.#i.length<wve)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:Sve}).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 Sp;var s$=x(()=>{Pt();Zb();IK();Sp=class Sp extends cu{#e;#t;#r;#n;#i;#o;static open(e){let t=e._streamIdAlloc.alloc(),r=new Sp(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 Ss,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 _r("Cursor not associated with the stream attempted to execute a request");return new Promise((r,i)=>{if(this.#o!==void 0)i(new Rt("Stream is closed",this.#o));else this.#e._sendRequest(t,{responseCallback:r,errorCallback:i})})}_cursorClosed(e){if(e!==this.#n)throw new _r("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 Rt("Stream is closed",this.#o));else if(this.#i)e.errorCallback(new Rt("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 o$(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 wp(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,AK),e.arrayObjects("named_args",t.namedArgs,vve),e.boolean("want_rows",t.wantRows)}function vve(e,t){e.string("name",t.name),e.object("value",t.value,AK)}function lu(e,t){e.arrayObjects("steps",t.steps,_ve)}function _ve(e,t){if(t.condition!==void 0)e.object("condition",t.condition,a$);e.object("stmt",t.stmt,wp)}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 AK(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",Ql.fromUint8Array(t));else if(t===void 0);else throw rt(t,"Impossible type of Value")}var c$=x(()=>{zb();An()});function TK(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,kve);else throw rt(t,"Impossible type of ClientMsg")}function kve(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,wp);else if(t.type==="batch")e.number("stream_id",t.streamId),e.object("batch",t.batch,lu);else if(t.type==="open_cursor")e.number("stream_id",t.streamId),e.number("cursor_id",t.cursorId),e.object("batch",t.batch,lu);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 CK=x(()=>{c$();An()});function vp(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,OK);for(let r of t.namedArgs)e.message(4,r,Eve);e.bool(5,t.wantRows)}function Eve(e,t){e.string(1,t.name),e.message(2,t.value,OK)}function uu(e,t){for(let r of t.steps)e.message(1,r,Ive)}function Ive(e,t){if(t.condition!==void 0)e.message(1,t.condition,l$);e.message(2,t.stmt,vp)}function l$(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,l$);else if(t.type==="and")e.message(4,t.conds,$K);else if(t.type==="or")e.message(5,t.conds,$K);else if(t.type==="is_autocommit")e.message(6,void 0,RK);else throw rt(t,"Impossible type of BatchCond")}function $K(e,t){for(let r of t)e.message(1,r,l$)}function OK(e,t){if(t===null)e.message(1,void 0,RK);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 RK(e,t){}var u$=x(()=>{An()});function PK(e,t){if(t.type==="hello")e.message(1,t,Ave);else if(t.type==="request")e.message(2,t,Tve);else throw rt(t,"Impossible type of ClientMsg")}function Ave(e,t){if(t.jwt!==void 0)e.string(1,t.jwt)}function Tve(e,t){e.int32(1,t.requestId);let r=t.request;if(r.type==="open_stream")e.message(2,r,Cve);else if(r.type==="close_stream")e.message(3,r,$ve);else if(r.type==="execute")e.message(4,r,Ove);else if(r.type==="batch")e.message(5,r,Rve);else if(r.type==="open_cursor")e.message(6,r,Pve);else if(r.type==="close_cursor")e.message(7,r,zve);else if(r.type==="fetch_cursor")e.message(8,r,Nve);else if(r.type==="sequence")e.message(9,r,Dve);else if(r.type==="describe")e.message(10,r,Lve);else if(r.type==="store_sql")e.message(11,r,Bve);else if(r.type==="close_sql")e.message(12,r,jve);else if(r.type==="get_autocommit")e.message(13,r,qve);else throw rt(r,"Impossible type of Request")}function Cve(e,t){e.int32(1,t.streamId)}function $ve(e,t){e.int32(1,t.streamId)}function Ove(e,t){e.int32(1,t.streamId),e.message(2,t.stmt,vp)}function Rve(e,t){e.int32(1,t.streamId),e.message(2,t.batch,uu)}function Pve(e,t){e.int32(1,t.streamId),e.int32(2,t.cursorId),e.message(3,t.batch,uu)}function zve(e,t){e.int32(1,t.cursorId)}function Nve(e,t){e.int32(1,t.cursorId),e.uint32(2,t.maxCount)}function Dve(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 Lve(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 Bve(e,t){e.int32(1,t.sqlId),e.string(2,t.sql)}function jve(e,t){e.int32(1,t.sqlId)}function qve(e,t){e.int32(1,t.streamId)}var zK=x(()=>{u$();An()});function ws(e){let t=Gr(e.message),r=pn(e.code);return{message:t,code:r}}function _p(e){let t=Jn(e.cols,NK),r=dp(e.rows).map((s)=>Jn(s,DK)),i=ro(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 NK(e){let t=pn(e.name),r=pn(e.decltype);return{name:t,decltype:r}}function Hb(e){let t=new Map;dp(e.step_results).forEach((i,n)=>{if(i!==null)t.set(n,_p(qt(i)))});let r=new Map;return dp(e.step_errors).forEach((i,n)=>{if(i!==null)r.set(n,ws(qt(i)))}),{stepResults:t,stepErrors:r}}function Kb(e){let t=Gr(e.type);if(t==="step_begin"){let r=ro(e.step),i=Jn(e.cols,NK);return{type:"step_begin",step:r,cols:i}}else if(t==="step_end"){let r=ro(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=ro(e.step),i=ws(qt(e.error));return{type:"step_error",step:r,error:i}}else if(t==="row")return{type:"row",row:Jn(e.row,DK)};else if(t==="error")return{type:"error",error:ws(qt(e.error))};else throw new qe("Unexpected type of CursorEntry")}function Jb(e){let t=Jn(e.params,Uve),r=Jn(e.cols,Mve),i=ys(e.is_explain),n=ys(e.is_readonly);return{params:t,cols:r,isExplain:i,isReadonly:n}}function Uve(e){return{name:pn(e.name)}}function Mve(e){let t=Gr(e.name),r=pn(e.decltype);return{name:t,decltype:r}}function DK(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 ro(e.value);else if(t==="text")return Gr(e.value);else if(t==="blob")return Ql.toUint8Array(Gr(e.base64));else throw new qe("Unexpected type of Value")}var Vb=x(()=>{zb();Pt();ou()});function LK(e){let t=Gr(e.type);if(t==="hello_ok")return{type:"hello_ok"};else if(t==="hello_error")return{type:"hello_error",error:ws(qt(e.error))};else if(t==="response_ok"){let r=ro(e.request_id),i=Fve(qt(e.response));return{type:"response_ok",requestId:r,response:i}}else if(t==="response_error"){let r=ro(e.request_id),i=ws(qt(e.error));return{type:"response_error",requestId:r,error:i}}else throw new qe("Unexpected type of ServerMsg")}function Fve(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:_p(qt(e.result))};else if(t==="batch")return{type:"batch",result:Hb(qt(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=Jn(e.entries,Kb),i=ys(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:Jb(qt(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:ys(e.is_autocommit)};else throw new qe("Unexpected type of Response")}var BK=x(()=>{Pt();ou();Vb()});var Tn,vs,jK,qK,du,Zve,Hve,Wb,Kve,Jve,Vve,fu,Wve,Gve,Qve;var Gb=x(()=>{Tn={default(){return{message:"",code:void 0}},1(e,t){t.message=e.string()},2(e,t){t.code=e.string()}},vs={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(qK))},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()}},qK={default(){return[]},1(e,t){t.push(e.message(Qve))}},du={default(){return{stepResults:new Map,stepErrors:new Map}},1(e,t){let[r,i]=e.message(Zve);t.stepResults.set(r,i)},2(e,t){let[r,i]=e.message(Hve);t.stepErrors.set(r,i)}},Zve={default(){return[0,vs.default()]},1(e,t){t[0]=e.uint32()},2(e,t){t[1]=e.message(vs)}},Hve={default(){return[0,Tn.default()]},1(e,t){t[0]=e.uint32()},2(e,t){t[1]=e.message(Tn)}},Wb={default(){return{type:"none"}},1(e){return e.message(Kve)},2(e){return e.message(Jve)},3(e){return e.message(Vve)},4(e){return{type:"row",row:e.message(qK)}},5(e){return{type:"error",error:e.message(Tn)}}},Kve={default(){return{type:"step_begin",step:0,cols:[]}},1(e,t){t.step=e.uint32()},2(e,t){t.cols.push(e.message(jK))}},Jve={default(){return{type:"step_end",affectedRowCount:0,lastInsertRowid:void 0}},1(e,t){t.affectedRowCount=e.uint32()},2(e,t){t.lastInsertRowid=e.uint64()}},Vve={default(){return{type:"step_error",step:0,error:Tn.default()}},1(e,t){t.step=e.uint32()},2(e,t){t.error=e.message(Tn)}},fu={default(){return{params:[],cols:[],isExplain:!1,isReadonly:!1}},1(e,t){t.params.push(e.message(Wve))},2(e,t){t.cols.push(e.message(Gve))},3(e,t){t.isExplain=e.bool()},4(e,t){t.isReadonly=e.bool()}},Wve={default(){return{name:void 0}},1(e,t){t.name=e.string()}},Gve={default(){return{name:"",decltype:void 0}},1(e,t){t.name=e.string()},2(e,t){t.decltype=e.string()}},Qve={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 UK,Yve,Xve,e_e,t_e,r_e,n_e,i_e,o_e;var MK=x(()=>{Gb();UK={default(){return{type:"none"}},1(e){return{type:"hello_ok"}},2(e){return e.message(Yve)},3(e){return e.message(e_e)},4(e){return e.message(Xve)}},Yve={default(){return{type:"hello_error",error:Tn.default()}},1(e,t){t.error=e.message(Tn)}},Xve={default(){return{type:"response_error",requestId:0,error:Tn.default()}},1(e,t){t.requestId=e.int32()},2(e,t){t.error=e.message(Tn)}},e_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(t_e)},5(e,t){t.response=e.message(r_e)},6(e,t){t.response={type:"open_cursor"}},7(e,t){t.response={type:"close_cursor"}},8(e,t){t.response=e.message(n_e)},9(e,t){t.response={type:"sequence"}},10(e,t){t.response=e.message(i_e)},11(e,t){t.response={type:"store_sql"}},12(e,t){t.response={type:"close_sql"}},13(e,t){t.response=e.message(o_e)}},t_e={default(){return{type:"execute",result:vs.default()}},1(e,t){t.result=e.message(vs)}},r_e={default(){return{type:"batch",result:du.default()}},1(e,t){t.result=e.message(du)}},n_e={default(){return{type:"fetch_cursor",entries:[],done:!1}},1(e,t){t.entries.push(e.message(Wb))},2(e,t){t.done=e.bool()}},i_e={default(){return{type:"describe",result:fu.default()}},1(e,t){t.result=e.message(fu)}},o_e={default(){return{type:"get_autocommit",isAutocommit:!1}},1(e,t){t.isAutocommit=e.bool()}}});var FK,d$,Qb;var Yb=x(()=>{XC();Pt();e$();gp();au();An();s$();CK();zK();BK();MK();FK=new Map([["hrana2",{version:2,encoding:"json"}],["hrana1",{version:1,encoding:"json"}]]),d$=new Map([["hrana3-protobuf",{version:3,encoding:"protobuf"}],["hrana3",{version:3,encoding:"json"}],["hrana2",{version:2,encoding:"json"}],["hrana1",{version:1,encoding:"json"}]]);Qb=class Qb extends ru{#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 xs,this._streamIdAlloc=new xs,this._cursorIdAlloc=new xs,this.#l=new xs,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 _r("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=d$.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=fp(e,TK);this.#e.send(r)}else if(t==="protobuf"){let r=hp(e,PK);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 Kn(`${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 Kn(`${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 Rt("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 nu(r))}#g(e){let t=`WebSocket was closed with code ${e.code}`;if(e.reason)t+=`: ${e.reason}`;this.#u(new nu(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),LK)}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=bs(new Uint8Array(e.data),UK)}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 no(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(no(e.error))}else throw rt(e,"Impossible ServerMsg type")}openStream(){return Sp.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 ZK=x(()=>{if(typeof queueMicrotask<"u")Ha=queueMicrotask;else{let e=Promise.resolve();Ha=(t)=>{e.then(t)}}});class f${#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 HK(e){let t=pn(e.baton),r=pn(e.base_url),i=Jn(e.results,s_e);return{baton:t,baseUrl:r,results:i}}function s_e(e){let t=Gr(e.type);if(t==="ok")return{type:"ok",response:a_e(qt(e.response))};else if(t==="error")return{type:"error",error:ws(qt(e.error))};else throw new qe("Unexpected type of StreamResult")}function a_e(e){let t=Gr(e.type);if(t==="close")return{type:"close"};else if(t==="execute")return{type:"execute",result:_p(qt(e.result))};else if(t==="batch")return{type:"batch",result:Hb(qt(e.result))};else if(t==="sequence")return{type:"sequence"};else if(t==="describe")return{type:"describe",result:Jb(qt(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:ys(e.is_autocommit)};else throw new qe("Unexpected type of StreamResponse")}function KK(e){let t=pn(e.baton),r=pn(e.base_url);return{baton:t,baseUrl:r}}var p$=x(()=>{Pt();ou();Vb()});var JK,c_e,l_e,u_e,d_e,f_e,p_e,VK;var m$=x(()=>{Gb();JK={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(c_e))}},c_e={default(){return{type:"none"}},1(e){return{type:"ok",response:e.message(l_e)}},2(e){return{type:"error",error:e.message(Tn)}}},l_e={default(){return{type:"none"}},1(e){return{type:"close"}},2(e){return e.message(u_e)},3(e){return e.message(d_e)},4(e){return{type:"sequence"}},5(e){return e.message(f_e)},6(e){return{type:"store_sql"}},7(e){return{type:"close_sql"}},8(e){return e.message(p_e)}},u_e={default(){return{type:"execute",result:vs.default()}},1(e,t){t.result=e.message(vs)}},d_e={default(){return{type:"batch",result:du.default()}},1(e,t){t.result=e.message(du)}},f_e={default(){return{type:"describe",result:fu.default()}},1(e,t){t.result=e.message(fu)}},p_e={default(){return{type:"get_autocommit",isAutocommit:!1}},1(e,t){t.isAutocommit=e.bool()}},VK={default(){return{baton:void 0,baseUrl:void 0}},1(e,t){t.baton=e.string()},2(e,t){t.baseUrl=e.string()}}});var h$;var WK=x(()=>{ou();QC();Pt();An();p$();m$();Vb();Gb();h$=class h$ extends xp{#e;#t;#r;#n;#i;#o;constructor(e,t){super();this.#e=e,this.#t=t,this.#r=void 0,this.#n=new f$(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(KK,VK);if(t===void 0)throw new qe("Empty response to cursor request");return t}next(){return this.#a(Kb,Wb)}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 Rt("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 bs(n,t)}else throw rt(this.#t,"Impossible encoding");if(this.#r===void 0)throw new _r("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 GK(e,t){if(t.baton!==void 0)e.string("baton",t.baton);e.arrayObjects("requests",t.requests,m_e)}function m_e(e,t){if(e.stringRaw("type",t.type),t.type==="close");else if(t.type==="execute")e.object("stmt",t.stmt,wp);else if(t.type==="batch")e.object("batch",t.batch,lu);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 QK(e,t){if(t.baton!==void 0)e.string("baton",t.baton);e.object("batch",t.batch,lu)}var g$=x(()=>{c$();An()});function YK(e,t){if(t.baton!==void 0)e.string(1,t.baton);for(let r of t.requests)e.message(2,r,h_e)}function h_e(e,t){if(t.type==="close")e.message(1,t,g_e);else if(t.type==="execute")e.message(2,t,y_e);else if(t.type==="batch")e.message(3,t,b_e);else if(t.type==="sequence")e.message(4,t,x_e);else if(t.type==="describe")e.message(5,t,S_e);else if(t.type==="store_sql")e.message(6,t,w_e);else if(t.type==="close_sql")e.message(7,t,v_e);else if(t.type==="get_autocommit")e.message(8,t,__e);else throw rt(t,"Impossible type of StreamRequest")}function g_e(e,t){}function y_e(e,t){e.message(1,t.stmt,vp)}function b_e(e,t){e.message(1,t.batch,uu)}function x_e(e,t){if(t.sql!==void 0)e.string(1,t.sql);if(t.sqlId!==void 0)e.int32(2,t.sqlId)}function S_e(e,t){if(t.sql!==void 0)e.string(1,t.sql);if(t.sqlId!==void 0)e.int32(2,t.sqlId)}function w_e(e,t){e.int32(1,t.sqlId),e.string(2,t.sql)}function v_e(e,t){e.int32(1,t.sqlId)}function __e(e,t){}function XK(e,t){if(t.baton!==void 0)e.string(1,t.baton);e.message(2,t.batch,uu)}var y$=x(()=>{u$();An()});function k_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(no(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 E_e(e,t){if(t==="json"){let r=await e.json();return Ua(r,HK)}if(t==="protobuf"){let r=await e.arrayBuffer();return bs(new Uint8Array(r),JK)}throw await e.body?.cancel(),rt(t,"Impossible encoding")}async function I_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 no(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 Xb;var b$=x(()=>{Pt();XC();e$();ZK();gp();au();Zb();An();WK();g$();y$();g$();y$();p$();m$();Xb=class Xb extends cu{#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 Ss,this.#s=!1,this.#l=!1,this.#d=!1,this.#f=void 0,this.#m=new xs}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 _r("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 Rt("Stream is closed",this.#f);else if(this.#l)throw new Rt("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)=>E_e(r,e.encoding),(r)=>r.baton,(r)=>r.baseUrl,(r)=>k_e(t,r),(r)=>t.forEach((i)=>i.errorCallback(r)))}#h(e,t){let r=new h$(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 I_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,GK,YK)}#w(e,t){if(t.cursorPath===void 0)throw new Kn(`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,QK,XK)}#S(e,t,r,i,n){let o,s;if(r==="json")o=fp(t,i),s="application/json";else if(r==="protobuf")o=hp(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 T_e(e,t){let r=e;for(let i of A_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 x$}var A_e,x$,ex;var S$=x(()=>{Pt();b$();A_e=[{versionPath:"v3-protobuf",pipelinePath:"v3-protobuf/pipeline",cursorPath:"v3-protobuf/cursor",version:3,encoding:"protobuf"}],x$={versionPath:"v2",pipelinePath:"v2/pipeline",cursorPath:void 0,version:2,encoding:"json"};ex=class ex extends ru{#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=T_e(this.#r,this.#e),this._endpointPromise.then((o)=>this._endpoint=o,(o)=>this.#a(o));else this._endpointPromise=Promise.resolve(x$),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<=x$.version)return;else if(this._endpoint===void 0)throw new Kn(`${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 Kn(`${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 Rt("Client is closed",this.#i);let e=new Xb(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 Rt("Client was closed",e))}}});var eJ=x(()=>{Pt()});function w$(e,t,r=2){if(typeof gs>"u")throw new up("WebSockets are not supported in this environment");var i=void 0;if(r==3)i=Array.from(d$.keys());else i=Array.from(FK.keys());let n=new gs(e,i);return new Qb(n,t)}function v$(e,t,r,i,n=2){return new ex(e instanceof URL?e:new URL(e),t,r,i,n)}var tx=x(()=>{GC();Yb();Pt();S$();Yb();GC();i$();eJ();au();Mb();Zb();S$();b$();Yb();s$();Pt()});class kp{#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(io),i;if(this.#r===void 0){this._getSqlCache().apply(r);let o=t.batch(this.#t>=3),s=o.step(),a=s.run(ms(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(mu(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(ms(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 pu(e,t,r,i,n=!1){if(n)r.step().run("PRAGMA foreign_keys=off");let o=r.step(),s=o.run(ms(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(mu(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 io(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 bp(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 mu(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 Yl(t,r,i,n,o)}function yt(e){if(e instanceof st){let t=tJ(e);return new je(e.message,t,void 0,void 0,e)}return e}function tJ(e){if(e instanceof lp&&e.code!==void 0)return e.code;else if(e instanceof qe)return"HRANA_PROTO_ERROR";else if(e instanceof Rt)return e.cause instanceof st?tJ(e.cause):"HRANA_CLOSED_ERROR";else if(e instanceof nu)return"HRANA_WEBSOCKET_ERROR";else if(e instanceof qa)return"SERVER_ERROR";else if(e instanceof Kn)return"PROTOCOL_VERSION_ERROR";else if(e instanceof _r)return"INTERNAL_ERROR";else return"UNKNOWN"}var k$=x(()=>{tx();Hn();Xl()});class hu{#e;#t;capacity;constructor(e,t){this.#e=e,this.#t=new rJ,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 rJ{#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 E$=ee(function(O9e,iJ){function C_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 $_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 nJ(e){return e.queue=0,e.map=$_e,e}iJ.exports=function(e){if(e)return nJ(C_e(e));else return nJ(function(t){return t()})}});function aJ(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=ip(e.scheme,e.authority,e.path),r;try{r=w$(t,e.authToken)}catch(i){if(i instanceof up){let n=e.scheme==="wss"?"https":"http",o=ip(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 cJ(r,t,e.authToken,e.intMode,e.concurrency)}class cJ{#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=sJ.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=io(r);i.conn.sqlCache.apply([n]);let o=i.stream.query(n);i.stream.closeGracefully();let s=await o;return mu(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(io),o=await r.conn.client.getVersion();r.conn.sqlCache.apply(n);let s=r.stream.batch(o>=3);return await pu(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(io),i=await t.conn.client.getVersion(),n=t.stream.batch(i>=3);return await pu("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 lJ(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()>O_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=oJ}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??=w$(this.#e,this.#t),{client:e,useSqlCache:void 0,sqlCache:new hu(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=oJ;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 sJ,O_e=60000,oJ=100,lJ;var uJ=x(()=>{tx();Hn();ap();k$();Ob();Xl();sJ=rc(E$(),1);Hn();lJ=class lJ extends kp{#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 fJ(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=ip(e.scheme,e.authority,e.path);return new mJ(t,e.authToken,e.intMode,e.fetch,e.concurrency,e.remoteEncryptionKey)}class mJ{#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=v$(this.#t,this.#o,this.#n,o),this.#e.intMode=this.#r,this.protocol="http",this.#s=dJ.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=io(r),n,o=this.#e.openStream();try{n=o.query(i)}finally{o.closeGracefully()}let s=await n;return mu(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(io),n=await this.#e.getVersion(),o,s=this.#e.openStream();try{new hu(s,pJ).apply(i);let l=s.batch(!1);o=pu(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(io),r=await this.#e.getVersion(),i,n=this.#e.openStream();try{let s=n.batch(!1);i=pu("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 hJ(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=v$(this.#t,this.#o,this.#n,this.#a),this.#e.intMode=this.#r}}get closed(){return this.#e.closed}}var dJ,pJ=30,hJ;var gJ=x(()=>{tx();Hn();ap();k$();Ob();Xl();dJ=rc(E$(),1);Hn();hJ=class hJ extends kp{#e;#t;constructor(e,t,r){super(t,r);this.#e=e,this.#t=new hu(e,pJ)}_getStream(){return this.#e}_getSqlCache(){return this.#t}close(){this.#e.close()}get closed(){return this.#e.closed}}});function gu(e){return R_e(sp(e,!0))}function R_e(e){if(e.scheme==="wss"||e.scheme==="ws")return aJ(e);else if(e.scheme==="https"||e.scheme==="http")return fJ(e);else return dK(e)}var I$=x(()=>{ap();gK();uJ();gJ();Hn()});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 Vn=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 Ep;var rx=x(()=>{De();Ep=class Ep{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 kr;var yu=x(()=>{kr=Symbol.for("drizzle:Name")});var A$,yJ;var bJ=x(()=>{De();yu();A$=class A${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 yJ(e,this)}};yJ=class yJ{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[kr],...i,r[0].table[kr],...n];return e??`${o.join("_")}_fk`}}});function nx(e,...t){return e(...t)}var T$=()=>{};function C$(e,t){return`${e[kr]}_${t.join("_")}_unique`}var xJ,P_e,SJ;var wJ=x(()=>{De();yu();xJ=class xJ{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 SJ(e,this.columns,this.nullsNotDistinctConfig,this.name)}};P_e=class P_e{static[J]="PgUniqueOnConstraintBuilder";name;constructor(e){this.name=e}on(...e){return new xJ(e,this.name)}};SJ=class SJ{constructor(e,t,r,i){this.table=e,this.columns=t,this.name=i??C$(this.table,this.columns.map((n)=>n.name)),this.nullsNotDistinct=r}static[J]="PgUniqueConstraint";columns;name;nullsNotDistinct=!1;getName(){return this.name}}});function vJ(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 _J(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]=vJ(e,i+1,!0);r.push(c),i=l;continue}if(o==="}")return[r,i+1];if(o==="{"){let[c,l]=_J(e,i+1);r.push(c),i=l;continue}let[s,a]=vJ(e,i,!1);r.push(s),i=a}return[r,i]}function kJ(e){let[t]=_J(e,1);return t}function $$(e){return`{${e.map((t)=>{if(Array.isArray(t))return $$(t);if(typeof t==="string")return`"${t.replace(/\\/g,"\\\\").replace(/"/g,"\\\"")}"`;return`${t}`}).join(",")}}`}var EJ=()=>{};var Ip,bu,IJ,z_e,AJ,O$;var TJ=x(()=>{rx();Vn();De();bJ();T$();wJ();EJ();Ip=class Ip extends Ep{foreignKeyConfigs=[];static[J]="PgColumnBuilder";array(e){return new AJ(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})=>nx((n,o)=>{let s=new A$(()=>{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 IJ(e,this.config)}};bu=class bu extends nt{constructor(e,t){if(!t.uniqueName)t.uniqueName=C$(e,[t.name]);super(e,t);this.table=e}static[J]="PgColumn"};IJ=class IJ extends bu{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}};z_e=class z_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};AJ=class AJ extends Ip{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 O$(e,this.config,t)}};O$=class O$ extends bu{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=kJ(e);return e.map((t)=>this.baseColumn.mapFromDriverValue(t))}mapToDriverValue(e,t=!1){let r=e.map((i)=>i===null?null:ce(this.baseColumn,O$)?this.baseColumn.mapToDriverValue(i,!0):this.baseColumn.mapToDriverValue(i));if(t)return r;return $$(r)}}});function OJ(e){return!!e&&typeof e==="function"&&CJ in e&&e[CJ]===!0}var N_e,$J,CJ,D_e,RJ;var PJ=x(()=>{De();TJ();N_e=class N_e extends Ip{static[J]="PgEnumObjectColumnBuilder";constructor(e,t){super(e,"string","PgEnumObjectColumn");this.config.enum=t}build(e){return new $J(e,this.config)}};$J=class $J extends bu{static[J]="PgEnumObjectColumn";enum;enumValues=this.config.enum.enumValues;constructor(e,t){super(e,t);this.enum=t.enum}getSQLType(){return this.enum.enumName}};CJ=Symbol.for("drizzle:isPgEnum");D_e=class D_e extends Ip{static[J]="PgEnumColumnBuilder";constructor(e,t){super(e,"string","PgEnumColumn");this.config.enum=t}build(e){return new RJ(e,this.config)}};RJ=class RJ extends bu{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,Ap;var Wn=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}}};Ap=class Ap extends vt{static[J]="WithSubquery"}});var zJ="0.45.2";var NJ=()=>{};var R$,P$,DJ;var LJ=x(()=>{T$();NJ();DJ={startActiveSpan(e,t){if(!R$)return t();if(!P$)P$=R$.trace.getTracer("drizzle-orm",zJ);return nx((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()}}),R$,P$)}}});var _t;var oo=x(()=>{_t=Symbol.for("drizzle:ViewBaseConfig")});function _s(e){return e[kr]}function Ka(e){return`${e[ix]??"public"}.${e[kr]}`}var ix,ox,BJ,z$,N$,Tp,jJ,L_e,we;var Er=x(()=>{De();yu();ix=Symbol.for("drizzle:Schema"),ox=Symbol.for("drizzle:Columns"),BJ=Symbol.for("drizzle:ExtraConfigColumns"),z$=Symbol.for("drizzle:OriginalName"),N$=Symbol.for("drizzle:BaseName"),Tp=Symbol.for("drizzle:IsAlias"),jJ=Symbol.for("drizzle:ExtraConfigBuilder"),L_e=Symbol.for("drizzle:IsDrizzleTable");we=class we{static[J]="Table";static Symbol={Name:kr,Schema:ix,OriginalName:z$,Columns:ox,ExtraConfigColumns:BJ,BaseName:N$,IsAlias:Tp,ExtraConfigBuilder:jJ};[kr];[z$];[ix];[ox];[BJ];[N$];[Tp]=!1;[L_e]=!0;[jJ]=void 0;constructor(e,t,r){this[kr]=this[z$]=e,this[ix]=t,this[N$]=r}}});function D$(e){return e!==null&&e!==void 0&&typeof e.getSQL==="function"}function j_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 qJ(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 Cp(e,t){return e.map((r)=>{if(ce(r,ks)){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,ks)){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 B_e,Vt,Te,sx,UJ,MJ,MVe,mn,ks,q_e,Cn;var pr=x(()=>{De();PJ();Wn();LJ();oo();Vn();Er();B_e=class B_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=UJ;shouldInlineParams=!1;usedTables=[];append(e){return this.queryChunks.push(...e.queryChunks),this}toQuery(e){return DJ.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 j_e(e.map((l)=>{if(ce(l,Vt))return{sql:l.value.join(""),params:[]};if(ce(l,sx))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[Tp]?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[Tp]||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,Cn)){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,ks))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,ks))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 sx(l._.alias)],r)}if(OJ(l)){if(l.schema)return{sql:n(l.schema)+"."+n(l.enumName),params:[]};return{sql:n(l.enumName),params:[]}}if(D$(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}};sx=class sx{constructor(e){this.value=e}static[J]="Name";brand;getSQL(){return new Te([this])}};UJ={mapFromDriverValue:(e)=>e},MJ={mapToDriverValue:(e)=>e},MVe={...UJ,...MJ};mn=class mn{constructor(e,t=MJ){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 sx(c)}e.identifier=o;function s(c){return new ks(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={}));ks=class ks{constructor(e){this.name=e}static[J]="Placeholder";getSQL(){return new Te([this])}};q_e=Symbol.for("drizzle:IsDrizzleView");Cn=class Cn{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 L$(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?_s(a.table):!1;else if(typeof i[g]==="string"&&i[g]!==_s(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 $n(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(...$n(n[we.Symbol.Columns],o));else r.push(...$n(n,o));return r},[])}function $p(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 ax(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 FJ(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 cx(e){return e[we.Symbol.Columns]}function Op(e){return ce(e,vt)?e._.alias:ce(e,Cn)?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 ZJ(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 B$;var qr=x(()=>{Vn();De();pr();Wn();Er();oo();B$=typeof TextDecoder>"u"?null:new TextDecoder});var HJ,j$,q$;var lx=x(()=>{De();HJ=class HJ{static[J]="ConsoleLogWriter";write(e){console.log(e)}};j$=class j${static[J]="DefaultLogger";writer;constructor(e){this.writer=e?.writer??new HJ}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}`)}};q$=class q${static[J]="NoopLogger";logQuery(){}}});var KJ,JJ,U$;var VJ=x(()=>{De();Er();KJ=Symbol.for("drizzle:PgInlineForeignKeys"),JJ=Symbol.for("drizzle:EnableRLS");U$=class U$ extends we{static[J]="PgTable";static Symbol=Object.assign({},we.Symbol,{InlineForeignKeys:KJ,EnableRLS:JJ});[KJ]=[];[JJ]=!1;[we.Symbol.ExtraConfigBuilder]=void 0;[we.Symbol.ExtraConfigColumns]={}}});var M$,WJ;var GJ=x(()=>{De();VJ();M$=class M${static[J]="PgPrimaryKeyBuilder";columns;name;constructor(e,t){this.columns=e,this.name=t}build(e){return new WJ(e,this.columns,this.name)}};WJ=class WJ{constructor(e,t,r){this.table=e,this.columns=t,this.name=r}static[J]="PgPrimaryKey";columns;name;getName(){return this.name??`${this.table[U$.Symbol.Name]}_${this.columns.map((e)=>e.name).join("_")}_pk`}}});function Qr(e,t){if(qJ(t)&&!D$(e)&&!ce(e,mn)&&!ce(e,ks)&&!ce(e,nt)&&!ce(e,we)&&!ce(e,Cn))return new mn(e,t);return e}function zt(...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 so(...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 YJ(e){return q`not ${e}`}function Es(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 t9(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 On(e){return q`${e} is null`}function r9(e){return q`${e} is not null`}function dx(e){return q`exists ${e}`}function fx(e){return q`not exists ${e}`}function n9(e,t,r){return q`${e} between ${Qr(t,e)} and ${Qr(r,e)}`}function i9(e,t,r){return q`${e} not between ${Qr(t,e)} and ${Qr(r,e)}`}function o9(e,t){return q`${e} like ${t}`}function s9(e,t){return q`${e} not like ${t}`}function a9(e,t){return q`${e} ilike ${t}`}function c9(e,t){return q`${e} not ilike ${t}`}var et=(e,t)=>q`${e} = ${Qr(t,e)}`,QJ=(e,t)=>q`${e} <> ${Qr(t,e)}`,ux=(e,t)=>q`${e} > ${Qr(t,e)}`,XJ=(e,t)=>q`${e} >= ${Qr(t,e)}`,e9=(e,t)=>q`${e} < ${Qr(t,e)}`,xu=(e,t)=>q`${e} <= ${Qr(t,e)}`;var l9=x(()=>{Vn();De();Er();pr()});function ao(e){return q`${e} asc`}function Ja(e){return q`${e} desc`}var u9=x(()=>{pr()});var F$=x(()=>{l9();u9()});function f9(){return{and:zt,between:n9,eq:et,exists:dx,gt:ux,gte:XJ,ilike:a9,inArray:Es,isNull:On,isNotNull:r9,like:o9,lt:e9,lte:xu,ne:QJ,not:YJ,notBetween:i9,notExists:fx,notLike:s9,notIlike:c9,notInArray:t9,or:so,sql:q}}function p9(){return{sql:q,asc:ao,desc:Ja}}function m9(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,M$))n[o].primaryKey.push(...u.columns)}}else if(ce(s,d9)){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 U_e(e){return function(r,i){return new Is(e,r,i,i?.fields.reduce((n,o)=>n&&o.notNull,!0)??!1)}}function M_e(e){return function(r,i){return new Rp(e,r,i)}}function h9(e,t,r){if(ce(r,Is)&&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],Is)&&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 g9(e){return{one:U_e(e),many:M_e(e)}}function px(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,Is)?u&&px(e,e[a.relationTableTsKey],u,a.selection,n):u.map((d)=>px(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 Z$,d9,Is,Rp;var Pp=x(()=>{Er();Vn();De();GJ();F$();pr();Z$=class Z${constructor(e,t,r){this.sourceTable=e,this.referencedTable=t,this.relationName=r,this.referencedTableName=t[we.Symbol.Name]}static[J]="Relation";referencedTableName;fieldName};d9=class d9{constructor(e,t){this.table=e,this.config=t}static[J]="Relations"};Is=class Is extends Z${constructor(e,t,r,i){super(e,t,r?.relationName);this.config=r,this.isNullable=i}static[J]="One";withFieldName(e){let t=new Is(this.sourceTable,this.referencedTable,this.config,this.isNullable);return t.fieldName=e,t}};Rp=class Rp extends Z${constructor(e,t,r){super(e,t,r?.relationName);this.config=r}static[J]="Many";withFieldName(e){let t=new Rp(this.sourceTable,this.referencedTable,this.config);return t.fieldName=e,t}}});function Np(e,t){return new Proxy(e,new zp(t,!1))}function ki(e,t){return new Proxy(e,new Su(new Proxy(e.table,new zp(t,!1))))}function H$(e,t){return new Te.Aliased(Dp(e.sql,t),e.fieldAlias)}function Dp(e,t){return q.join(e.queryChunks.map((r)=>{if(ce(r,nt))return ki(r,t);if(ce(r,Te))return Dp(r,t);if(ce(r,Te.Aliased))return H$(r,t);return r}))}var Su,zp,F_e;var mx=x(()=>{Vn();De();pr();Er();oo();Su=class Su{constructor(e){this.table=e}static[J]="ColumnAliasProxyHandler";get(e,t){if(t==="table")return this.table;return e[t]}};zp=class zp{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 Su(new Proxy(e,this)))}),n}let r=e[t];if(ce(r,nt))return new Proxy(r,new Su(new Proxy(e,this)));return r}};F_e=class F_e{constructor(e){this.alias=e}static[J]="RelationTableAliasProxyHandler";get(e,t){if(t==="sourceTable")return Np(e.sourceTable,this.alias);return e[t]}}});var bt;var Va=x(()=>{mx();Vn();De();pr();Wn();oo();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,Cn)?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 Su(new Proxy(i.table,new zp(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 Ur;var co=x(()=>{De();Ur=class Ur{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 K$,y9;var J$=x(()=>{De();yu();K$=class K${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 y9(e,this)}};y9=class y9{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[kr],...i,r[0].table[kr],...n];return e??`${o.join("_")}_fk`}}});function V$(e,t){return`${e[kr]}_${t.join("_")}_unique`}var b9,Z_e,x9;var W$=x(()=>{De();yu();b9=class b9{constructor(e,t){this.name=t,this.columns=e}static[J]="SQLiteUniqueConstraintBuilder";columns;build(e){return new x9(e,this.columns,this.name)}};Z_e=class Z_e{static[J]="SQLiteUniqueOnConstraintBuilder";name;constructor(e){this.name=e}on(...e){return new b9(e,this.name)}};x9=class x9{constructor(e,t,r){this.table=e,this.columns=t,this.name=r??V$(this.table,this.columns.map((i)=>i.name))}static[J]="SQLiteUniqueConstraint";columns;name;getName(){return this.name}}});var Xt,At;var As=x(()=>{rx();Vn();De();J$();W$();Xt=class Xt extends Ep{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 K$(()=>{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=V$(e,[t.name]);super(e,t);this.table=e}static[J]="SQLiteColumn"}});function I9(e,t){let{name:r,config:i}=_i(e,t);if(i?.mode==="json")return new v9(r);if(i?.mode==="bigint")return new S9(r);return new k9(r)}var S9,w9,v9,_9,k9,E9;var G$=x(()=>{De();qr();As();S9=class S9 extends Xt{static[J]="SQLiteBigIntBuilder";constructor(e){super(e,"bigint","SQLiteBigInt")}build(e){return new w9(e,this.config)}};w9=class w9 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(B$.decode(e))}mapToDriverValue(e){return Buffer.from(e.toString())}};v9=class v9 extends Xt{static[J]="SQLiteBlobJsonBuilder";constructor(e){super(e,"json","SQLiteBlobJson")}build(e){return new _9(e,this.config)}};_9=class _9 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(B$.decode(e))}mapToDriverValue(e){return Buffer.from(JSON.stringify(e))}};k9=class k9 extends Xt{static[J]="SQLiteBlobBufferBuilder";constructor(e){super(e,"buffer","SQLiteBlobBuffer")}build(e){return new E9(e,this.config)}};E9=class E9 extends At{static[J]="SQLiteBlobBuffer";mapFromDriverValue(e){if(Buffer.isBuffer(e))return e;return Buffer.from(e)}getSQLType(){return"blob"}}});function C9(e){return(t,r)=>{let{name:i,config:n}=_i(t,r);return new A9(i,n,e)}}var A9,T9;var Q$=x(()=>{De();qr();As();A9=class A9 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 T9(e,this.config)}};T9=class T9 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 Ir(e,t){let{name:r,config:i}=_i(e,t);if(i?.mode==="timestamp"||i?.mode==="timestamp_ms")return new R9(r,i.mode);if(i?.mode==="boolean")return new z9(r,i.mode);return new $9(r)}var hx,gx,$9,O9,R9,P9,z9,N9;var Y$=x(()=>{De();pr();qr();As();hx=class hx 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()}};gx=class gx extends At{static[J]="SQLiteBaseInteger";autoIncrement=this.config.autoIncrement;getSQLType(){return"integer"}};$9=class $9 extends hx{static[J]="SQLiteIntegerBuilder";constructor(e){super(e,"number","SQLiteInteger")}build(e){return new O9(e,this.config)}};O9=class O9 extends gx{static[J]="SQLiteInteger"};R9=class R9 extends hx{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 P9(e,this.config)}};P9=class P9 extends gx{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}};z9=class z9 extends hx{static[J]="SQLiteBooleanBuilder";constructor(e,t){super(e,"boolean","SQLiteBoolean");this.config.mode=t}build(e){return new N9(e,this.config)}};N9=class N9 extends gx{static[J]="SQLiteBoolean";mode=this.config.mode;mapFromDriverValue(e){return Number(e)===1}mapToDriverValue(e){return e?1:0}}});function M9(e,t){let{name:r,config:i}=_i(e,t),n=i?.mode;return n==="number"?new B9(r):n==="bigint"?new q9(r):new D9(r)}var D9,L9,B9,j9,q9,U9;var X$=x(()=>{De();qr();As();D9=class D9 extends Xt{static[J]="SQLiteNumericBuilder";constructor(e){super(e,"string","SQLiteNumeric")}build(e){return new L9(e,this.config)}};L9=class L9 extends At{static[J]="SQLiteNumeric";mapFromDriverValue(e){if(typeof e==="string")return e;return String(e)}getSQLType(){return"numeric"}};B9=class B9 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"}};q9=class q9 extends Xt{static[J]="SQLiteNumericBigIntBuilder";constructor(e){super(e,"bigint","SQLiteNumericBigInt")}build(e){return new U9(e,this.config)}};U9=class U9 extends At{static[J]="SQLiteNumericBigInt";mapFromDriverValue=BigInt;mapToDriverValue=String;getSQLType(){return"numeric"}}});function H9(e){return new F9(e??"")}var F9,Z9;var eO=x(()=>{De();As();F9=class F9 extends Xt{static[J]="SQLiteRealBuilder";constructor(e){super(e,"number","SQLiteReal")}build(e){return new Z9(e,this.config)}};Z9=class Z9 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 V9(r);return new K9(r,i)}var K9,J9,V9,W9;var tO=x(()=>{De();qr();As();K9=class K9 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 J9(e,this.config)}};J9=class J9 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})`:""}`}};V9=class V9 extends Xt{static[J]="SQLiteTextJsonBuilder";constructor(e){super(e,"json","SQLiteTextJson")}build(e){return new W9(e,this.config)}};W9=class W9 extends At{static[J]="SQLiteTextJson";getSQLType(){return"text"}mapFromDriverValue(e){return JSON.parse(e)}mapToDriverValue(e){return JSON.stringify(e)}}});function G9(){return{blob:I9,customType:C9,integer:Ir,numeric:M9,real:H9,text:mr}}var Q9=x(()=>{G$();Q$();Y$();X$();eO();tO()});function H_e(e,t,r,i,n=e){let o=new Ut(e,i,n),s=typeof t==="function"?t(G9()):t,a=Object.fromEntries(Object.entries(s).map(([l,u])=>{let d=u;d.setName(l);let p=d.build(o);return o[rO].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[Ut.Symbol.ExtraConfigBuilder]=r;return c}var rO,Ut,Lp=(e,t,r)=>H_e(e,t,r);var lo=x(()=>{De();Er();Q9();rO=Symbol.for("drizzle:SQLiteInlineForeignKeys");Ut=class Ut extends we{static[J]="SQLiteTable";static Symbol=Object.assign({},we.Symbol,{InlineForeignKeys:rO});[we.Symbol.Columns];[rO]=[];[we.Symbol.ExtraConfigBuilder]=void 0}});var K_e,Y9;var X9=x(()=>{De();K_e=class K_e{constructor(e,t){this.name=e,this.value=t}static[J]="SQLiteCheckBuilder";brand;build(e){return new Y9(e,this)}};Y9=class Y9{constructor(e,t){this.table=e,this.name=t.name,this.value=t.value}static[J]="SQLiteCheck";name;value}});function Wa(e){return new eV(e,!1)}var eV,tV,rV;var nV=x(()=>{De();eV=class eV{constructor(e,t){this.name=e,this.unique=t}static[J]="SQLiteIndexBuilderOn";on(...e){return new tV(this.name,e,this.unique)}};tV=class tV{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 rV(this.config,e)}};rV=class rV{static[J]="SQLiteIndex";config;constructor(e,t){this.config={...e,table:t}}}});var J_e,iV;var oV=x(()=>{De();lo();J_e=class J_e{static[J]="SQLitePrimaryKeyBuilder";columns;name;constructor(e,t){this.columns=e,this.name=t}build(e){return new iV(e,this.columns,this.name)}};iV=class iV{constructor(e,t,r){this.table=e,this.columns=t,this.name=r}static[J]="SQLitePrimaryKey";columns;name;getName(){return this.name??`${this.table[Ut.Symbol.Name]}_${this.columns.map((e)=>e.name).join("_")}_pk`}}});function Gn(e){if(ce(e,Ut))return[`${e[we.Symbol.BaseName]}`];if(ce(e,vt))return e._.usedTables??[];if(ce(e,Te))return e.usedTables??[];return[]}var wu=x(()=>{De();pr();Wn();Er();lo()});var yx;var sV=x(()=>{De();co();Va();lo();Er();qr();wu();yx=class yx extends Ur{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[Ut.Symbol.Columns]){return this.config.returning=$n(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:Gn(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 V_e(e){return(e.replace(/['\u2019]/g,"").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).map((r)=>r.toLowerCase()).join("_")}function W_e(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 G_e(e){return e}var nO;var aV=x(()=>{De();Er();nO=class nO{static[J]="CasingCache";cache={};cachedTables={};convert;constructor(e){this.convert=e==="snake_case"?V_e:e==="camelCase"?W_e:G_e}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 vu,uo,iO;var bx=x(()=>{De();vu=class vu extends Error{static[J]="DrizzleError";constructor({message:e,cause:t}){super(e);this.name="DrizzleError",this.cause=t}};uo=class uo extends Error{constructor(e,t,r){super(`Failed query: ${e}
443
442
  params: ${t}`);if(this.query=e,this.params=t,this.cause=r,Error.captureStackTrace(this,uo),r)this.cause=r}};iO=class iO extends vu{static[J]="TransactionRollbackError";constructor(){super({message:"Rollback"})}}});var cV=()=>{};var lV=()=>{};var uV=x(()=>{cV();lV()});var oO=x(()=>{F$();uV();pr()});var sO=x(()=>{G$();As();Q$();Y$();X$();eO();tO()});var fo;var Bp=x(()=>{De();pr();fo=class fo extends Cn{static[J]="SQLiteViewBase"}});var _u,aO,cO;var xx=x(()=>{mx();aV();Vn();De();bx();Pp();oO();pr();sO();lo();Wn();Er();qr();oo();Bp();_u=class _u{static[J]="SQLiteDialect";casing;constructor(e){this.casing=new nO(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,Ut)){let s=n[Ut.Symbol.Name],a=n[Ut.Symbol.Schema],c=n[Ut.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??$n(t);for(let P of m)if(ce(P.field,nt)&&_s(P.field.table)!==(ce(o,vt)?o._.alias:ce(o,fo)?o[_t].name:ce(o,Te)?void 0:_s(o))&&!((N)=>s?.some(({alias:I})=>I===(N[we.Symbol.IsAlias]?_s(N):N[we.Symbol.BaseName])))(P.field.table)){let N=_s(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,f9()):o.where;m=E&&Dp(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:H$(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,p9()):o.orderBy??[];if(!Array.isArray(j))j=[j];p=j.map((E)=>{if(ce(E,nt))return ki(E,s);return Dp(E,s)}),u=o.limit,d=o.offset;for(let{tsKey:E,queryConfig:Z,relation:D}of T){let H=h9(t,r,D),X=Ka(D.referencedTable),M=r[X],P=`${s}_${E}`,N=zt(...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,Is)?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 vu({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=zt(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,Rp))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:Np(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=Np(i,s);g=this.buildSelectQuery({table:ce(g,Ut)?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:Np(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 _u{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`
444
443
  CREATE TABLE IF NOT EXISTS ${q.identifier(i)} (
445
444
  id SERIAL PRIMARY KEY,
@@ -452,21 +451,21 @@ params: ${t}`);if(this.query=e,this.params=t,this.cause=r,Error.captureStackTrac
452
451
  hash text NOT NULL,
453
452
  created_at numeric
454
453
  )
455
- `;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 lO;var dV=x(()=>{De();lO=class lO{static[J]="TypedQueryBuilder";getSelectedFields(){return this._.selectedFields}}});function Sx(e,t){return(r,i,...n)=>{let o=[i,...n].map((s)=>({type:e,isAll:t,rightSelect:s}));for(let s of o)if(!$p(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 Qn,fV,uO,Y_e=()=>({union:X_e,unionAll:eke,intersect:tke,except:rke}),X_e,eke,tke,rke;var dO=x(()=>{De();dV();co();Va();pr();Wn();Er();qr();oo();wu();Bp();Qn=class Qn{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,fo))r=e[_t].selectedFields;else if(ce(e,Te))r={};else r=cx(e);return new uO({table:e,fields:r,isPartialSelect:t,session:this.session,dialect:this.dialect,withList:this.withList,distinct:this.distinct})}};fV=class fV extends lO{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=Op(e),this.joinsNotNullableMap=typeof this.tableName==="string"?{[this.tableName]:!0}:{};for(let a of Gn(e))this.usedTables.add(a)}getUsedTables(){return[...this.usedTables]}createJoin(e){return(t,r)=>{let i=this.tableName,n=Op(t);for(let o of Gn(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,Cn)?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(Y_e()):r;if(!$p(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(...Gn(this.config.table)),this.config.joins)for(let r of this.config.joins)t.push(...Gn(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}};uO=class uO extends fV{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=$n(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()}};FJ(uO,[Ur]);X_e=Sx("union",!1),eke=Sx("union",!0),tke=Sx("intersect",!1),rke=Sx("except",!1)});var Ga;var wx=x(()=>{De();Va();xx();Wn();dO();Ga=class Ga{static[J]="SQLiteQueryBuilder";dialect;dialectConfig;constructor(e){this.dialect=ce(e,_u)?e:void 0,this.dialectConfig=ce(e,_u)?void 0:e}$with=(e,t)=>{let r=this;return{as:(n)=>{if(typeof n==="function")n=n(r);return new Proxy(new Ap(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 Qn({fields:n??void 0,session:void 0,dialect:t.getDialect(),withList:e})}function i(n){return new Qn({fields:n??void 0,session:void 0,dialect:t.getDialect(),withList:e,distinct:!0})}return{select:r,selectDistinct:i}}select(e){return new Qn({fields:e??void 0,session:void 0,dialect:this.getDialect()})}selectDistinct(e){return new Qn({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 vx,fO;var pV=x(()=>{De();co();pr();lo();Er();qr();wu();wx();vx=class vx{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 fO(this.table,t,this.session,this.dialect,this.withList)}select(e){let t=typeof e==="function"?e(new Ga):e;if(!ce(t,Te)&&!$p(this.table[ox],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 fO(this.table,t,this.session,this.dialect,this.withList,!0)}};fO=class fO extends Ur{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[Ut.Symbol.Columns]){return this.config.returning=$n(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,ax(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:Gn(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 _x,mV;var hV=x(()=>{De();co();Va();lo();Wn();Er();qr();oo();wu();Bp();_x=class _x{constructor(e,t,r,i){this.table=e,this.session=t,this.dialect=r,this.withList=i}static[J]="SQLiteUpdateBuilder";set(e){return new mV(this.table,ax(this.table,e),this.session,this.dialect,this.withList)}};mV=class mV extends Ur{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=Op(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,Ut)?t[we.Symbol.Columns]:ce(t,vt)?t._.selectedFields:ce(t,fo)?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[Ut.Symbol.Columns]){return this.config.returning=$n(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:Gn(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(()=>{sV();pV();wx();dO();hV()});var jp;var gV=x(()=>{De();pr();jp=class jp extends Te{constructor(e){super(jp.buildEmbeddedCount(e.source,e.filters).queryChunks);this.params=e,this.session=e.session,this.sql=jp.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 hO,kx,mO;var yV=x(()=>{De();co();Pp();hO=class hO{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 mO(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e?e:{},"many"):new kx(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e?e:{},"many")}findFirst(e){return this.mode==="sync"?new mO(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e?{...e,limit:1}:{limit:1},"first"):new kx(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e?{...e,limit:1}:{limit:1},"first")}};kx=class kx extends Ur{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)=>px(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()}};mO=class mO extends kx{static[J]="SQLiteSyncRelationalQuery";sync(){return this.executeRaw()}}});var ku;var bV=x(()=>{De();co();ku=class ku extends Ur{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 qp;var Ex=x(()=>{De();Va();pr();pO();Wn();gV();yV();bV();qp=class qp{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 hO(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 Ap(n.getSQL(),t??("getSelectedFields"in n?n.getSelectedFields()??{}:{}),e,!0),new bt({alias:e,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}}};$count(e,t){return new jp({source:e,filters:t,session:this.session})}with(...e){let t=this;function r(a){return new Qn({fields:a??void 0,session:t.session,dialect:t.dialect,withList:e})}function i(a){return new Qn({fields:a??void 0,session:t.session,dialect:t.dialect,withList:e,distinct:!0})}function n(a){return new _x(a,t.session,t.dialect,e)}function o(a){return new vx(a,t.session,t.dialect,e)}function s(a){return new yx(a,t.session,t.dialect,e)}return{select:r,selectDistinct:i,update:n,insert:o,delete:s}}select(e){return new Qn({fields:e??void 0,session:this.session,dialect:this.dialect})}selectDistinct(e){return new Qn({fields:e??void 0,session:this.session,dialect:this.dialect,distinct:!0})}update(e){return new _x(e,this.session,this.dialect)}$cache;insert(e){return new vx(e,this.session,this.dialect)}delete(e){return new yx(e,this.session,this.dialect)}run(e){let t=typeof e==="string"?q.raw(e):e.getSQL();if(this.resultKind==="async")return new ku(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 ku(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 ku(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 ku(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 gO(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 xV,Up;var yO=x(()=>{De();xV=class xV{static[J]="Cache"};Up=class Up extends xV{strategy(){return"all"}static[J]="NoopCache";async get(e){return}async put(e,t,r,i){}async onMutate(e){}}});var SV=x(()=>{yO()});var wV=()=>{};var vV,bO,xO,SO;var wO=x(()=>{yO();De();bx();co();Ex();vV=class vV extends Ur{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,Up)||this.queryMetadata===void 0)try{return await r()}catch(i){throw new uo(e,t,i)}if(this.cacheConfig&&!this.cacheConfig.enable)try{return await r()}catch(i){throw new uo(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 uo(e,t,i)}if(!this.cacheConfig)try{return await r()}catch(i){throw new uo(e,t,i)}if(this.queryMetadata.type==="select"){let i=await this.cache.get(this.cacheConfig.tag??await gO(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 uo(e,t,o)}return await this.cache.put(this.cacheConfig.tag??await gO(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 uo(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 vV(()=>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)}}};xO=class xO{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 vu({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")}};SO=class SO extends qp{constructor(e,t,r,i,n=0){super(e,t,r,i);this.schema=i,this.nestedIndex=n}static[J]="SQLiteTransaction";rollback(){throw new iO}}});var vO,nke,ike,Ix;var _V=x(()=>{De();Va();qr();wx();lo();Bp();vO=class vO{constructor(e){this.name=e}static[J]="SQLiteViewBuilderCore";config={}};nke=class nke extends vO{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 Ix({config:{name:this.name,schema:void 0,selectedFields:r,query:e.getSQL().inlineParams()}}),t)}};ike=class ike extends vO{static[J]="SQLiteManualViewBuilder";columns;constructor(e,t){super(e);this.columns=cx(Lp(e,t))}existing(){return new Proxy(new Ix({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 Ix({config:{name:this.name,schema:void 0,selectedFields:this.columns,query:e.inlineParams()}}),new bt({alias:this.name,sqlBehavior:"error",sqlAliasedBehavior:"alias",replaceOriginalName:!0}))}};Ix=class Ix extends fo{static[J]="SQLiteView";constructor({config:e}){super(e)}}});var _O=x(()=>{wV();X9();sO();Ex();xx();J$();nV();oV();pO();wO();lo();W$();wu();_V()});function kV(e){return Object.keys(e).reduce((t,r)=>{if(Object.prototype.propertyIsEnumerable.call(e,r))t[r]=e[r];return t},{})}function Ax(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 Tx,kO,EV;var EO=x(()=>{SV();De();lx();pr();_O();wO();qr();Tx=class Tx extends xO{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 q$,this.cache=i.cache??new Up}static[J]="LibSQLSession";logger;cache;prepareQuery(e,t,r,i,n,o,s){return new EV(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 Tx(this.client,this.dialect,this.schema,this.options,r),n=new kO("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}};kO=class kO extends SO{static[J]="LibSQLTransaction";async transaction(e){let t=`sp${this.nestedIndex}`,r=new kO("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}}};EV=class EV 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=Cp(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=Cp(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)=>kV(r));if(this.customResultMapper)return this.customResultMapper(e,Ax);return e.map((r)=>L$(this.fields,Array.prototype.slice.call(r).map((i)=>Ax(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=Cp(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 kV(r);if(!r)return;if(this.customResultMapper)return this.customResultMapper(e,Ax);return L$(this.fields,Array.prototype.slice.call(r).map((i)=>Ax(i)),this.joinsNotNullableMap)}async values(e){let t=Cp(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 Eu(e,t={}){let r=new cO({casing:t.casing}),i;if(t.logger===!0)i=new j$;else if(t.logger!==!1)i=t.logger;let n;if(t.schema){let a=m9(t.schema,g9);n={fullSchema:t.schema,schema:a.tables,tableNamesMap:a.tableNamesMap}}let o=new Tx(e,r,n,{logger:i,cache:t.cache},void 0),s=new IV("async",r,o,n);if(s.$client=e,s.$cache=t.cache,s.$cache)s.$cache.invalidate=t.cache?.onMutate;return s}var IV;var AV=x(()=>{De();lx();Pp();Ex();xx();EO();IV=class IV extends qp{static[J]="LibSQLDatabase";async batch(e){return this.session.batch(e)}}});function Cx(...e){if(typeof e[0]==="string"){let t=gu({url:e[0]});return Eu(t,e[1])}if(ZJ(e[0])){let{connection:t,client:r,...i}=e[0];if(r)return Eu(r,i);let n=typeof t==="string"?gu({url:t}):gu(t);return Eu(n,i)}return Eu(e[0],e[1])}var TV=x(()=>{I$();qr();AV();((e)=>{function t(r){return Eu({},r)}e.mock=t})(Cx||(Cx={}))});var CV=x(()=>{TV();EO()});function $V(e){if(e.authToken!==void 0)return e.authToken;if(e.authTokenEnv===void 0)return;return process.env[e.authTokenEnv]}function cke(e){return e instanceof je&&/^SQLITE_(?:BUSY|LOCKED)$/u.test(e.code)}async function Mp(e,t){let r=Date.now()+(t.budgetMs??oke),i=async(n)=>{if(t.isClosed())throw new je("The client is closed","CLIENT_CLOSED");try{return await e()}catch(o){if(t.isClosed()||!cke(o))throw o;await t.afterRefusal?.();let s=Math.min(ske*2**(n-1),ake),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 IO(e,t={}){let r=gu({...e,...e.url.startsWith("file:")?{timeout:0}:{}});if(e.url.startsWith("file:")&&e.syncUrl===void 0){let u=function(d,p){return Mp(()=>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)=>Mp(()=>a(d,p),l),r.migrate=(d)=>Mp(()=>c(d),l),r.transaction=(d)=>Mp(()=>i(d),l)}return r}function $x(e){let{url:t,schema:r}=e,i=$V(e),n={contentionRetryBudgetMs:e.contentionRetryBudgetMs},o=i?IO({url:t,authToken:i},n):IO({url:t},n);return{db:Cx(o,{schema:r}),client:o,url:t}}async function Ox(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 Mp(()=>e.execute(i),{isClosed:r})}var oke=5000,ske=5,ake=40;var AO=x(()=>{I$();CV()});var OV=x(()=>{UC();AO()});var TO=x(()=>{AO();OV()});var oe,ft;var CO=x(()=>{_O();tp();oe=Lp("job_queue",{id:mr("id").primaryKey().$defaultFn(()=>eo()),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:Ir("priority").notNull().default(0),retryCount:Ir("retryCount").notNull().default(0),maxRetries:Ir("maxRetries").notNull().default(3),lastError:mr("lastError"),createdAt:Ir("createdAt").notNull().$defaultFn(()=>Date.now()),scheduledFor:Ir("scheduledFor").notNull().$defaultFn(()=>Date.now()),startedAt:Ir("startedAt"),completedAt:Ir("completedAt"),attemptId:mr("attemptId"),workerSlotId:mr("workerSlotId"),workerSessionId:mr("workerSessionId"),leaseExpiresAt:Ir("leaseExpiresAt"),attemptHeartbeatAt:Ir("attemptHeartbeatAt"),runtimeUpdatedAt:Ir("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=Lp("job_worker_sessions",{slotId:mr("slotId").primaryKey(),sessionId:mr("sessionId").notNull().unique(),startedAt:Ir("startedAt").notNull(),heartbeatAt:Ir("heartbeatAt").notNull(),expiresAt:Ir("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 RV(e){return $x({url:e.url,schema:{jobQueue:oe,jobWorkerSessions:ft},authToken:e.authToken,authTokenEnv:"JOB_QUEUE_DATABASE_AUTH_TOKEN",contentionRetryBudgetMs:0})}var PV=x(()=>{TO();CO()});class $O{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 zV=x(()=>{mx();rx();Vn();De();bx();lx();co();Pp();oO();Wn();Er();qr();oo()});class OO{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 RO{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=lke.safeParse(r.metadata);return i.success&&i.data.deduplicationKey===t})}}var lke;var NV=x(()=>{Re();ps();lke=f.looseObject({deduplicationKey:f.string().optional()})});class PO{db;transactionClient;databaseUrl;logger;deduplicator=new RO;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??uke}async insert(e){await this.write("insert",async()=>this.db.insert(oe).values(e))}async enqueueAtomic(e){return mke.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(dke*2**(i-1),fke),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=fs){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=fs){return(await this.write("heartbeat worker session",async()=>this.db.update(ft).set({heartbeatAt:r,expiresAt:r+i}).where(zt(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(zt(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(zt(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(zt(et(oe.id,e.jobId),et(oe.type,e.expectedType),so(et(oe.status,He.PENDING),et(oe.status,He.PROCESSING)),On(oe.attemptId),On(oe.workerSlotId),On(oe.workerSessionId),On(oe.leaseExpiresAt),On(oe.attemptHeartbeatAt),On(oe.progress),On(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(ao(oe.createdAt),ao(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=pke.parse(t);if(r===0)return[];return(await this.db.select().from(oe).where(q`(${oe.runtimeUpdatedAt}, ${oe.id}) > (${e.updatedAt}, ${e.jobId})`).orderBy(ao(oe.runtimeUpdatedAt),ao(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(zt(so(et(oe.status,He.COMPLETED),et(oe.status,He.FAILED)),xu(oe.completedAt,t))))).rowsAffected}async getActiveJobs(e){let t=so(et(oe.status,He.PENDING),et(oe.status,He.PROCESSING)),r=e&&e.length>0?zt(t,Es(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?Es(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?zt(t,Es(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(zt(et(ft.slotId,i),et(ft.sessionId,n),ux(ft.expiresAt,t))),c=this.db.select({slotId:ft.slotId}).from(ft).where(zt(et(ft.slotId,oe.workerSlotId),et(ft.sessionId,oe.workerSessionId))),l=zt(et(oe.status,He.PROCESSING),so(On(oe.attemptId),fx(c),xu(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(zt(Es(oe.type,s),so(zt(et(oe.status,He.PENDING),xu(oe.scheduledFor,t)),l))).orderBy(ao(oe.priority),ao(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(zt(Es(oe.id,d),dx(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?zt(et(oe.id,e),et(oe.status,He.PROCESSING),et(oe.attemptId,t)):zt(et(oe.id,e),On(oe.attemptId),so(et(oe.status,He.PENDING),et(oe.status,He.PROCESSING)))}}var uke=2000,dke=5,fke=40,pke,mke;var DV=x(()=>{zV();CO();Re();ps();np();NV();pke=f.number().int().min(0).max(1000),mke=new OO});import{AsyncLocalStorage as hke}from"async_hooks";class Fp{storage=new hke;static createFresh(){return new Fp}constructor(){}current(){return this.storage.getStore()}run(e,t,r){if(t.length===0)throw Error("Operation ID must not be empty");let i=ns.parse(e),n=gke(i);return this.storage.run(Object.freeze({provenance:n,operationId:t}),r)}}function gke(e){if(Object.freeze(e.projectionLineage),e.sourceEntity)Object.freeze(e.sourceEntity);return Object.freeze(e)}var zO=x(()=>{is()});class Zp{client;logger;handlerRegistry;repository;walInitialization=null;walInitializationSettled=!1;closeRequested=!1;clientClosed=!1;inFlightEnqueues=0;databaseUrl;operationContext;projectionAdmission;directWorkerSlotId=`direct:${eo()}`;directWorkerSessionId=eo();directLeaseDurationMs;directSessionStart=null;close(){this.closeRequested=!0,this.closeClientWhenReady()}static createFresh(e,t,r){return new Zp(e,t??fn.getInstance(),r)}constructor(e,t,r){let{db:i,client:n,url:o}=RV(e);this.client=n,this.databaseUrl=o,this.logger=t.child("JobQueueService"),this.operationContext=r?.operationContext??Fp.createFresh(),this.projectionAdmission=r?.projectionAdmission,this.handlerRegistry=new $O(this.logger,r?.handlerRegistrationMode??"combined"),this.repository=new PO(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 Ox(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=eo(),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 ns.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:eo(),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=fs){await this.repository.startWorkerSession(e,t,Date.now(),r)}heartbeatWorkerSession(e,t,r=fs){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 LV=x(()=>{tp();UC();np();ps();TO();PV();DV();is();zO()});var NO=()=>{};var BV=x(()=>{tp();ps();np();ps();NO();zO()});var jV=x(()=>{ps();NO()});var $et;var qV=x(()=>{is();Re();rp();$et=f.preprocess((e)=>{if(typeof e!=="string")return e;return JSON.parse(e)},f.record(f.string(),f.unknown()))});var Pet;var UV=x(()=>{Re();Pet=f.record(f.string(),f.unknown())});var MV=x(()=>{is();tp()});var FV=x(()=>{LV();BV();jV();qV();UV();np();ps();rp();MV()});var DO={};tr(DO,{LEGACY_PROJECTION_JOB_TYPES:()=>HV,LEGACY_PROJECTION_RETIREMENT_REASON:()=>JV,legacyProjectionJobTypeSchema:()=>KV,retireLegacyProjectionJob:()=>Eke});import{existsSync as vke}from"fs";import{resolve as _ke}from"path";function ZV(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 kke(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 Eke(e){let t=_ke(e.databasePath);if(!vke(t))throw Error(`Job database does not exist: ${t}`);let r=KV.parse(e.jobType),i=Zp.createFresh({url:`file:${t}`});try{let n=await i.getStatus(e.jobId);if(!n)throw Error(`Job not found: ${e.jobId}`);if(kke(n,r),e.dryRun){if(e.confirmation!==void 0)throw Error("Dry-run recovery must not include confirmation");return{databasePath:t,job:ZV(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:JV,now:e.now?.()??Date.now()});if(!s)throw Error(`Job ${n.id} changed or acquired ownership before retirement`);return{databasePath:t,job:ZV(s),retired:!0}}finally{i.close()}}var HV,KV,JV="Retired legacy projection job superseded by scheduler-owned projections";var LO=x(()=>{FV();Re();HV=["conversation-memory:project","skill:project","swot:derive","topic:project"],KV=f.enum(HV)});function er(e,t,r,i,n){return WV.parse({id:e,operation:t,count:r,targetProbeCount:i,settleMs:n})}function XV(e){return zx.parse(structuredClone($ke[e]))}function Nx(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 jO(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(),BO.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 BO.parse({timestamp:o.toISOString(),endpoint:new URL(e).pathname,status:0,durationMs:Math.max(0,i().getTime()-o.getTime()),ok:!1,error:Rke(c)})}finally{clearTimeout(a)}}async function e7(e,t){let r=zx.parse(e),i=[],n,o=await t.prepare(r),s,a;try{try{await t.startMonitoring()}catch(c){n=`monitor: ${Rx(c)}`}if(!n)for(let c of r.phases)try{let l=GV.parse(await t.executePhase(c,o));if(i.push(l),!l.success){n=`${c.id}: ${l.error??"phase failed"}`;break}}catch(l){let u=Rx(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=QV.parse(await t.cleanup(o)),!s.success&&!n)n=s.error??"cleanup failed"}catch(c){let l=Rx(c);s={success:!1,probesRemaining:0,error:l},n??=`cleanup: ${l}`}try{a=YV.parse(await t.stopMonitoring())}catch(c){let l=Rx(c);a={health:[],runtime:[]},n??=`monitor: ${l}`}}return n??=Oke(a,r.maximumExternalAiCalls??0),Cke.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 Oke(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 Rke(e){if(e instanceof Error)return`${e.name}: ${e.message}`;return String(e)}function Rx(e){return at(e)}var Px,VV,WV,zx,Ike,BO,Ake,GV,QV,Tke,YV,Cke,$ke;var qO=x(()=>{Re();Px=f.enum(["regression","load","stress"]),VV=f.enum(["add","update","rename","delete"]),WV=f.object({id:f.string().min(1),operation:VV,count:f.number().int().positive().max(700),targetProbeCount:f.number().int().min(0).max(700),settleMs:f.number().int().nonnegative().max(300000)}),zx=f.object({profile:Px,maximumProbeCount:f.number().int().positive().max(700),maximumExternalAiCalls:f.number().int().nonnegative().max(1e4).optional(),phases:f.array(WV).min(1)}),Ike=f.object({entities:f.number().int().nonnegative(),notes:f.number().int().nonnegative(),version:f.string().min(1)}),BO=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()}),Ake=f.object({timestamp:f.iso.datetime(),cpuPercent:f.number().nonnegative(),memoryPercent:f.number().nonnegative(),pids:f.number().int().nonnegative()}),GV=f.object({id:f.string().min(1),operation:VV,count:f.number().int().positive(),success:f.boolean(),commitLatencyMs:f.number().nonnegative().optional(),persistenceLatencyMs:f.number().nonnegative().optional(),error:f.string().optional()}),QV=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()}),Tke=f.object({status:f.string(),restartCount:f.number().int().nonnegative(),oomKilled:f.boolean()}),YV=f.object({health:f.array(BO),runtime:f.array(Ake),externalAiCalls:f.number().int().nonnegative().optional(),container:Tke.optional()}),Cke=f.object({profile:Px,success:f.boolean(),baseline:Ike,phases:f.array(GV),cleanup:QV,metrics:YV,failure:f.string().optional()}),$ke={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 Pke}from"child_process";async function t7(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 po=async(e,t,r={})=>new Promise((i,n)=>{let o=Pke(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 Hp=()=>{};class Iu{#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 Iu(e,r,i);return await t7(e,"git",["-c","credential.helper=","-c",`credential.helper=${r7}`,"clone","--branch","main","--single-branch",`https://github.com/${t}.git`,r],{env:n.environment()}),await n.run(["config","--local","credential.helper",r7]),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 r7='!f() { test "$1" = get && echo username=x-access-token && echo "password=$GH_TOKEN"; }; f';var n7=x(()=>{Hp()});function Kp(e){return e.entityCounts.find((t)=>t.entityType==="note")?.count??0}class UO{#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 jO(`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 zke.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||Kp(e)===t)&&(r===void 0||e.entities===r)}async#f(){while(!this.#i){for(let e of this.#n)this.#t.push(await jO(`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 zke;var i7=x(()=>{Re();qO();zke=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 Dx={};tr(Dx,{applyDirectorySyncStressPhase:()=>c7,cleanupDirectorySyncStress:()=>Zke,listProbeFiles:()=>Qa,parseStressRuntimeSample:()=>l7,removeProbeFiles:()=>VO,runDeployedDirectorySyncStress:()=>Mke,runStressCommand:()=>po,verifyDirectorySyncStressAccess:()=>Fke});import{chmod as Nke,mkdir as FO,mkdtemp as ZO,readFile as Dke,readdir as Lke,rename as Bke,rm as Vp,writeFile as Yn}from"fs/promises";import{tmpdir as HO}from"os";import{join as xt,resolve as KO}from"path";async function Mke(e){let t=e.now??(()=>new Date),r=t().toISOString(),i=WO(r),n=KO(e.artifactsDir??xt(e.rootDir,".brains-ops","stress",i));await FO(n,{recursive:!0});let{pilot:o,user:s}=await JO(e.rootDir,e.handle);Nx({handle:s.handle,domain:s.domain,contentRepo:s.contentRepo,confirmation:e.confirmation});let a=Px.parse(e.profile),c=e.plan?zx.parse(e.plan):XV(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)a7(s);let l=jke.parse(e.env??process.env),u=new s7({runId:i,artifactsDir:n,user:s,githubOrg:o.githubOrg,serverLabel:`${o.contentRepoPrefix}${s.handle}`,environment:l,fetchImpl:e.fetchImpl??fetch,commandRunner:e.commandRunner??po,logger:e.logger??console.info,now:t,sleep:e.sleep??Bun.sleep}),d;try{d=await e7(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 Jke(p),p}async function Fke(e){let r=(e.now??(()=>new Date))().toISOString(),i=WO(r),n=KO(e.artifactsDir??xt(e.rootDir,".brains-ops","stress",`access-check-${i}`));await FO(n,{recursive:!0});let{pilot:o,user:s}=await JO(e.rootDir,e.handle);Nx({handle:s.handle,domain:s.domain,contentRepo:s.contentRepo,confirmation:e.confirmation}),a7(s);let a=(e.env??process.env).CONTENT_REPO_ADMIN_TOKEN;if(!a)throw Error("Missing CONTENT_REPO_ADMIN_TOKEN");let c=await ZO(xt(HO(),"brains-ops-directory-sync-access-check-"));try{let l=await Iu.clone(e.commandRunner??po,`${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 Yn(xt(n,"access-check.json"),`${JSON.stringify(d,null,2)}
456
- `),d}finally{await Vp(c,{recursive:!0,force:!0})}}async function Zke(e){let t=e.now??(()=>new Date),r=KO(e.artifactsDir??xt(e.rootDir,".brains-ops","stress",`cleanup-${WO(t().toISOString())}`));await FO(r,{recursive:!0});let{pilot:i,user:n}=await JO(e.rootDir,e.handle);Nx({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??po,a=e.logger??console.info,c=await ZO(xt(HO(),"brains-ops-directory-sync-cleanup-")),l=xt(c,"content");try{let u=await Iu.clone(s,`${i.githubOrg}/${n.contentRepo}`,l,o),d=await VO(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 Yn(xt(r,"cleanup.json"),`${JSON.stringify(g,null,2)}
457
- `),g}finally{await Vp(c,{recursive:!0,force:!0})}}class s7{#e;#t;#r;#n;#i;#o;#a;#s;#c;#l;#d;constructor(e){this.#e=e,this.#t=new UO({domain:e.user.domain,fetchImpl:e.fetchImpl,now:e.now,sleep:e.sleep,sampleRuntime:()=>this.#y()})}async prepare(e){this.#r=await ZO(xt(HO(),"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 Yn(this.#i,Kke(this.#e.environment.KAMAL_SSH_PRIVATE_KEY),{mode:384}),await Nke(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 Yn(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 Iu.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 Yn(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:Kp(s),version:s.version}},null,2)}
454
+ `;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 lO;var dV=x(()=>{De();lO=class lO{static[J]="TypedQueryBuilder";getSelectedFields(){return this._.selectedFields}}});function Sx(e,t){return(r,i,...n)=>{let o=[i,...n].map((s)=>({type:e,isAll:t,rightSelect:s}));for(let s of o)if(!$p(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 Qn,fV,uO,Q_e=()=>({union:Y_e,unionAll:X_e,intersect:eke,except:tke}),Y_e,X_e,eke,tke;var dO=x(()=>{De();dV();co();Va();pr();Wn();Er();qr();oo();wu();Bp();Qn=class Qn{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,fo))r=e[_t].selectedFields;else if(ce(e,Te))r={};else r=cx(e);return new uO({table:e,fields:r,isPartialSelect:t,session:this.session,dialect:this.dialect,withList:this.withList,distinct:this.distinct})}};fV=class fV extends lO{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=Op(e),this.joinsNotNullableMap=typeof this.tableName==="string"?{[this.tableName]:!0}:{};for(let a of Gn(e))this.usedTables.add(a)}getUsedTables(){return[...this.usedTables]}createJoin(e){return(t,r)=>{let i=this.tableName,n=Op(t);for(let o of Gn(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,Cn)?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(Q_e()):r;if(!$p(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(...Gn(this.config.table)),this.config.joins)for(let r of this.config.joins)t.push(...Gn(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}};uO=class uO extends fV{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=$n(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()}};FJ(uO,[Ur]);Y_e=Sx("union",!1),X_e=Sx("union",!0),eke=Sx("intersect",!1),tke=Sx("except",!1)});var Ga;var wx=x(()=>{De();Va();xx();Wn();dO();Ga=class Ga{static[J]="SQLiteQueryBuilder";dialect;dialectConfig;constructor(e){this.dialect=ce(e,_u)?e:void 0,this.dialectConfig=ce(e,_u)?void 0:e}$with=(e,t)=>{let r=this;return{as:(n)=>{if(typeof n==="function")n=n(r);return new Proxy(new Ap(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 Qn({fields:n??void 0,session:void 0,dialect:t.getDialect(),withList:e})}function i(n){return new Qn({fields:n??void 0,session:void 0,dialect:t.getDialect(),withList:e,distinct:!0})}return{select:r,selectDistinct:i}}select(e){return new Qn({fields:e??void 0,session:void 0,dialect:this.getDialect()})}selectDistinct(e){return new Qn({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 vx,fO;var pV=x(()=>{De();co();pr();lo();Er();qr();wu();wx();vx=class vx{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 fO(this.table,t,this.session,this.dialect,this.withList)}select(e){let t=typeof e==="function"?e(new Ga):e;if(!ce(t,Te)&&!$p(this.table[ox],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 fO(this.table,t,this.session,this.dialect,this.withList,!0)}};fO=class fO extends Ur{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[Ut.Symbol.Columns]){return this.config.returning=$n(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,ax(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:Gn(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 _x,mV;var hV=x(()=>{De();co();Va();lo();Wn();Er();qr();oo();wu();Bp();_x=class _x{constructor(e,t,r,i){this.table=e,this.session=t,this.dialect=r,this.withList=i}static[J]="SQLiteUpdateBuilder";set(e){return new mV(this.table,ax(this.table,e),this.session,this.dialect,this.withList)}};mV=class mV extends Ur{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=Op(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,Ut)?t[we.Symbol.Columns]:ce(t,vt)?t._.selectedFields:ce(t,fo)?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[Ut.Symbol.Columns]){return this.config.returning=$n(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:Gn(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(()=>{sV();pV();wx();dO();hV()});var jp;var gV=x(()=>{De();pr();jp=class jp extends Te{constructor(e){super(jp.buildEmbeddedCount(e.source,e.filters).queryChunks);this.params=e,this.session=e.session,this.sql=jp.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 hO,kx,mO;var yV=x(()=>{De();co();Pp();hO=class hO{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 mO(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e?e:{},"many"):new kx(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e?e:{},"many")}findFirst(e){return this.mode==="sync"?new mO(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e?{...e,limit:1}:{limit:1},"first"):new kx(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e?{...e,limit:1}:{limit:1},"first")}};kx=class kx extends Ur{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)=>px(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()}};mO=class mO extends kx{static[J]="SQLiteSyncRelationalQuery";sync(){return this.executeRaw()}}});var ku;var bV=x(()=>{De();co();ku=class ku extends Ur{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 qp;var Ex=x(()=>{De();Va();pr();pO();Wn();gV();yV();bV();qp=class qp{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 hO(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 Ap(n.getSQL(),t??("getSelectedFields"in n?n.getSelectedFields()??{}:{}),e,!0),new bt({alias:e,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}}};$count(e,t){return new jp({source:e,filters:t,session:this.session})}with(...e){let t=this;function r(a){return new Qn({fields:a??void 0,session:t.session,dialect:t.dialect,withList:e})}function i(a){return new Qn({fields:a??void 0,session:t.session,dialect:t.dialect,withList:e,distinct:!0})}function n(a){return new _x(a,t.session,t.dialect,e)}function o(a){return new vx(a,t.session,t.dialect,e)}function s(a){return new yx(a,t.session,t.dialect,e)}return{select:r,selectDistinct:i,update:n,insert:o,delete:s}}select(e){return new Qn({fields:e??void 0,session:this.session,dialect:this.dialect})}selectDistinct(e){return new Qn({fields:e??void 0,session:this.session,dialect:this.dialect,distinct:!0})}update(e){return new _x(e,this.session,this.dialect)}$cache;insert(e){return new vx(e,this.session,this.dialect)}delete(e){return new yx(e,this.session,this.dialect)}run(e){let t=typeof e==="string"?q.raw(e):e.getSQL();if(this.resultKind==="async")return new ku(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 ku(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 ku(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 ku(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 gO(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 xV,Up;var yO=x(()=>{De();xV=class xV{static[J]="Cache"};Up=class Up extends xV{strategy(){return"all"}static[J]="NoopCache";async get(e){return}async put(e,t,r,i){}async onMutate(e){}}});var SV=x(()=>{yO()});var wV=()=>{};var vV,bO,xO,SO;var wO=x(()=>{yO();De();bx();co();Ex();vV=class vV extends Ur{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,Up)||this.queryMetadata===void 0)try{return await r()}catch(i){throw new uo(e,t,i)}if(this.cacheConfig&&!this.cacheConfig.enable)try{return await r()}catch(i){throw new uo(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 uo(e,t,i)}if(!this.cacheConfig)try{return await r()}catch(i){throw new uo(e,t,i)}if(this.queryMetadata.type==="select"){let i=await this.cache.get(this.cacheConfig.tag??await gO(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 uo(e,t,o)}return await this.cache.put(this.cacheConfig.tag??await gO(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 uo(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 vV(()=>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)}}};xO=class xO{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 vu({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")}};SO=class SO extends qp{constructor(e,t,r,i,n=0){super(e,t,r,i);this.schema=i,this.nestedIndex=n}static[J]="SQLiteTransaction";rollback(){throw new iO}}});var vO,rke,nke,Ix;var _V=x(()=>{De();Va();qr();wx();lo();Bp();vO=class vO{constructor(e){this.name=e}static[J]="SQLiteViewBuilderCore";config={}};rke=class rke extends vO{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 Ix({config:{name:this.name,schema:void 0,selectedFields:r,query:e.getSQL().inlineParams()}}),t)}};nke=class nke extends vO{static[J]="SQLiteManualViewBuilder";columns;constructor(e,t){super(e);this.columns=cx(Lp(e,t))}existing(){return new Proxy(new Ix({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 Ix({config:{name:this.name,schema:void 0,selectedFields:this.columns,query:e.inlineParams()}}),new bt({alias:this.name,sqlBehavior:"error",sqlAliasedBehavior:"alias",replaceOriginalName:!0}))}};Ix=class Ix extends fo{static[J]="SQLiteView";constructor({config:e}){super(e)}}});var _O=x(()=>{wV();X9();sO();Ex();xx();J$();nV();oV();pO();wO();lo();W$();wu();_V()});function kV(e){return Object.keys(e).reduce((t,r)=>{if(Object.prototype.propertyIsEnumerable.call(e,r))t[r]=e[r];return t},{})}function Ax(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 Tx,kO,EV;var EO=x(()=>{SV();De();lx();pr();_O();wO();qr();Tx=class Tx extends xO{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 q$,this.cache=i.cache??new Up}static[J]="LibSQLSession";logger;cache;prepareQuery(e,t,r,i,n,o,s){return new EV(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 Tx(this.client,this.dialect,this.schema,this.options,r),n=new kO("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}};kO=class kO extends SO{static[J]="LibSQLTransaction";async transaction(e){let t=`sp${this.nestedIndex}`,r=new kO("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}}};EV=class EV 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=Cp(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=Cp(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)=>kV(r));if(this.customResultMapper)return this.customResultMapper(e,Ax);return e.map((r)=>L$(this.fields,Array.prototype.slice.call(r).map((i)=>Ax(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=Cp(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 kV(r);if(!r)return;if(this.customResultMapper)return this.customResultMapper(e,Ax);return L$(this.fields,Array.prototype.slice.call(r).map((i)=>Ax(i)),this.joinsNotNullableMap)}async values(e){let t=Cp(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 Eu(e,t={}){let r=new cO({casing:t.casing}),i;if(t.logger===!0)i=new j$;else if(t.logger!==!1)i=t.logger;let n;if(t.schema){let a=m9(t.schema,g9);n={fullSchema:t.schema,schema:a.tables,tableNamesMap:a.tableNamesMap}}let o=new Tx(e,r,n,{logger:i,cache:t.cache},void 0),s=new IV("async",r,o,n);if(s.$client=e,s.$cache=t.cache,s.$cache)s.$cache.invalidate=t.cache?.onMutate;return s}var IV;var AV=x(()=>{De();lx();Pp();Ex();xx();EO();IV=class IV extends qp{static[J]="LibSQLDatabase";async batch(e){return this.session.batch(e)}}});function Cx(...e){if(typeof e[0]==="string"){let t=gu({url:e[0]});return Eu(t,e[1])}if(ZJ(e[0])){let{connection:t,client:r,...i}=e[0];if(r)return Eu(r,i);let n=typeof t==="string"?gu({url:t}):gu(t);return Eu(n,i)}return Eu(e[0],e[1])}var TV=x(()=>{I$();qr();AV();((e)=>{function t(r){return Eu({},r)}e.mock=t})(Cx||(Cx={}))});var CV=x(()=>{TV();EO()});function $V(e){if(e.authToken!==void 0)return e.authToken;if(e.authTokenEnv===void 0)return;return process.env[e.authTokenEnv]}function ake(e){return e instanceof je&&/^SQLITE_(?:BUSY|LOCKED)$/u.test(e.code)}async function Mp(e,t){let r=Date.now()+(t.budgetMs??ike),i=async(n)=>{if(t.isClosed())throw new je("The client is closed","CLIENT_CLOSED");try{return await e()}catch(o){if(t.isClosed()||!ake(o))throw o;await t.afterRefusal?.();let s=Math.min(oke*2**(n-1),ske),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 IO(e,t={}){let r=gu({...e,...e.url.startsWith("file:")?{timeout:0}:{}});if(e.url.startsWith("file:")&&e.syncUrl===void 0){let u=function(d,p){return Mp(()=>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)=>Mp(()=>a(d,p),l),r.migrate=(d)=>Mp(()=>c(d),l),r.transaction=(d)=>Mp(()=>i(d),l)}return r}function $x(e){let{url:t,schema:r}=e,i=$V(e),n={contentionRetryBudgetMs:e.contentionRetryBudgetMs},o=i?IO({url:t,authToken:i},n):IO({url:t},n);return{db:Cx(o,{schema:r}),client:o,url:t}}async function Ox(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 Mp(()=>e.execute(i),{isClosed:r})}var ike=5000,oke=5,ske=40;var AO=x(()=>{I$();CV()});var OV=x(()=>{UC();AO()});var TO=x(()=>{AO();OV()});var oe,ft;var CO=x(()=>{_O();tp();oe=Lp("job_queue",{id:mr("id").primaryKey().$defaultFn(()=>eo()),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:Ir("priority").notNull().default(0),retryCount:Ir("retryCount").notNull().default(0),maxRetries:Ir("maxRetries").notNull().default(3),lastError:mr("lastError"),createdAt:Ir("createdAt").notNull().$defaultFn(()=>Date.now()),scheduledFor:Ir("scheduledFor").notNull().$defaultFn(()=>Date.now()),startedAt:Ir("startedAt"),completedAt:Ir("completedAt"),attemptId:mr("attemptId"),workerSlotId:mr("workerSlotId"),workerSessionId:mr("workerSessionId"),leaseExpiresAt:Ir("leaseExpiresAt"),attemptHeartbeatAt:Ir("attemptHeartbeatAt"),runtimeUpdatedAt:Ir("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=Lp("job_worker_sessions",{slotId:mr("slotId").primaryKey(),sessionId:mr("sessionId").notNull().unique(),startedAt:Ir("startedAt").notNull(),heartbeatAt:Ir("heartbeatAt").notNull(),expiresAt:Ir("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 RV(e){return $x({url:e.url,schema:{jobQueue:oe,jobWorkerSessions:ft},authToken:e.authToken,authTokenEnv:"JOB_QUEUE_DATABASE_AUTH_TOKEN",contentionRetryBudgetMs:0})}var PV=x(()=>{TO();CO()});class $O{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 zV=x(()=>{mx();rx();Vn();De();bx();lx();co();Pp();oO();Wn();Er();qr();oo()});class OO{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 RO{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=cke.safeParse(r.metadata);return i.success&&i.data.deduplicationKey===t})}}var cke;var NV=x(()=>{Re();ps();cke=f.looseObject({deduplicationKey:f.string().optional()})});class PO{db;transactionClient;databaseUrl;logger;deduplicator=new RO;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??lke}async insert(e){await this.write("insert",async()=>this.db.insert(oe).values(e))}async enqueueAtomic(e){return pke.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(uke*2**(i-1),dke),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=fs){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=fs){return(await this.write("heartbeat worker session",async()=>this.db.update(ft).set({heartbeatAt:r,expiresAt:r+i}).where(zt(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(zt(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(zt(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(zt(et(oe.id,e.jobId),et(oe.type,e.expectedType),so(et(oe.status,He.PENDING),et(oe.status,He.PROCESSING)),On(oe.attemptId),On(oe.workerSlotId),On(oe.workerSessionId),On(oe.leaseExpiresAt),On(oe.attemptHeartbeatAt),On(oe.progress),On(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(ao(oe.createdAt),ao(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=fke.parse(t);if(r===0)return[];return(await this.db.select().from(oe).where(q`(${oe.runtimeUpdatedAt}, ${oe.id}) > (${e.updatedAt}, ${e.jobId})`).orderBy(ao(oe.runtimeUpdatedAt),ao(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(zt(so(et(oe.status,He.COMPLETED),et(oe.status,He.FAILED)),xu(oe.completedAt,t))))).rowsAffected}async getActiveJobs(e){let t=so(et(oe.status,He.PENDING),et(oe.status,He.PROCESSING)),r=e&&e.length>0?zt(t,Es(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?Es(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?zt(t,Es(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(zt(et(ft.slotId,i),et(ft.sessionId,n),ux(ft.expiresAt,t))),c=this.db.select({slotId:ft.slotId}).from(ft).where(zt(et(ft.slotId,oe.workerSlotId),et(ft.sessionId,oe.workerSessionId))),l=zt(et(oe.status,He.PROCESSING),so(On(oe.attemptId),fx(c),xu(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(zt(Es(oe.type,s),so(zt(et(oe.status,He.PENDING),xu(oe.scheduledFor,t)),l))).orderBy(ao(oe.priority),ao(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(zt(Es(oe.id,d),dx(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?zt(et(oe.id,e),et(oe.status,He.PROCESSING),et(oe.attemptId,t)):zt(et(oe.id,e),On(oe.attemptId),so(et(oe.status,He.PENDING),et(oe.status,He.PROCESSING)))}}var lke=2000,uke=5,dke=40,fke,pke;var DV=x(()=>{zV();CO();Re();ps();np();NV();fke=f.number().int().min(0).max(1000),pke=new OO});import{AsyncLocalStorage as mke}from"async_hooks";class Fp{storage=new mke;static createFresh(){return new Fp}constructor(){}current(){return this.storage.getStore()}run(e,t,r){if(t.length===0)throw Error("Operation ID must not be empty");let i=ns.parse(e),n=hke(i);return this.storage.run(Object.freeze({provenance:n,operationId:t}),r)}}function hke(e){if(Object.freeze(e.projectionLineage),e.sourceEntity)Object.freeze(e.sourceEntity);return Object.freeze(e)}var zO=x(()=>{is()});class Zp{client;logger;handlerRegistry;repository;walInitialization=null;walInitializationSettled=!1;closeRequested=!1;clientClosed=!1;inFlightEnqueues=0;databaseUrl;operationContext;projectionAdmission;directWorkerSlotId=`direct:${eo()}`;directWorkerSessionId=eo();directLeaseDurationMs;directSessionStart=null;close(){this.closeRequested=!0,this.closeClientWhenReady()}static createFresh(e,t,r){return new Zp(e,t??fn.getInstance(),r)}constructor(e,t,r){let{db:i,client:n,url:o}=RV(e);this.client=n,this.databaseUrl=o,this.logger=t.child("JobQueueService"),this.operationContext=r?.operationContext??Fp.createFresh(),this.projectionAdmission=r?.projectionAdmission,this.handlerRegistry=new $O(this.logger,r?.handlerRegistrationMode??"combined"),this.repository=new PO(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 Ox(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=eo(),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 ns.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:eo(),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=fs){await this.repository.startWorkerSession(e,t,Date.now(),r)}heartbeatWorkerSession(e,t,r=fs){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 LV=x(()=>{tp();UC();np();ps();TO();PV();DV();is();zO()});var NO=()=>{};var BV=x(()=>{tp();ps();np();ps();NO();zO()});var jV=x(()=>{ps();NO()});var Cet;var qV=x(()=>{is();Re();rp();Cet=f.preprocess((e)=>{if(typeof e!=="string")return e;return JSON.parse(e)},f.record(f.string(),f.unknown()))});var Ret;var UV=x(()=>{Re();Ret=f.record(f.string(),f.unknown())});var MV=x(()=>{is();tp()});var FV=x(()=>{LV();BV();jV();qV();UV();np();ps();rp();MV()});var DO={};tr(DO,{LEGACY_PROJECTION_JOB_TYPES:()=>HV,LEGACY_PROJECTION_RETIREMENT_REASON:()=>JV,legacyProjectionJobTypeSchema:()=>KV,retireLegacyProjectionJob:()=>kke});import{existsSync as wke}from"fs";import{resolve as vke}from"path";function ZV(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 _ke(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 kke(e){let t=vke(e.databasePath);if(!wke(t))throw Error(`Job database does not exist: ${t}`);let r=KV.parse(e.jobType),i=Zp.createFresh({url:`file:${t}`});try{let n=await i.getStatus(e.jobId);if(!n)throw Error(`Job not found: ${e.jobId}`);if(_ke(n,r),e.dryRun){if(e.confirmation!==void 0)throw Error("Dry-run recovery must not include confirmation");return{databasePath:t,job:ZV(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:JV,now:e.now?.()??Date.now()});if(!s)throw Error(`Job ${n.id} changed or acquired ownership before retirement`);return{databasePath:t,job:ZV(s),retired:!0}}finally{i.close()}}var HV,KV,JV="Retired legacy projection job superseded by scheduler-owned projections";var LO=x(()=>{FV();Re();HV=["conversation-memory:project","skill:project","swot:derive","topic:project"],KV=f.enum(HV)});function er(e,t,r,i,n){return WV.parse({id:e,operation:t,count:r,targetProbeCount:i,settleMs:n})}function XV(e){return zx.parse(structuredClone(Cke[e]))}function Nx(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 jO(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(),BO.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 BO.parse({timestamp:o.toISOString(),endpoint:new URL(e).pathname,status:0,durationMs:Math.max(0,i().getTime()-o.getTime()),ok:!1,error:Oke(c)})}finally{clearTimeout(a)}}async function e7(e,t){let r=zx.parse(e),i=[],n,o=await t.prepare(r),s,a;try{try{await t.startMonitoring()}catch(c){n=`monitor: ${Rx(c)}`}if(!n)for(let c of r.phases)try{let l=GV.parse(await t.executePhase(c,o));if(i.push(l),!l.success){n=`${c.id}: ${l.error??"phase failed"}`;break}}catch(l){let u=Rx(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=QV.parse(await t.cleanup(o)),!s.success&&!n)n=s.error??"cleanup failed"}catch(c){let l=Rx(c);s={success:!1,probesRemaining:0,error:l},n??=`cleanup: ${l}`}try{a=YV.parse(await t.stopMonitoring())}catch(c){let l=Rx(c);a={health:[],runtime:[]},n??=`monitor: ${l}`}}return n??=$ke(a,r.maximumExternalAiCalls??0),Tke.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 $ke(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 Oke(e){if(e instanceof Error)return`${e.name}: ${e.message}`;return String(e)}function Rx(e){return at(e)}var Px,VV,WV,zx,Eke,BO,Ike,GV,QV,Ake,YV,Tke,Cke;var qO=x(()=>{Re();Px=f.enum(["regression","load","stress"]),VV=f.enum(["add","update","rename","delete"]),WV=f.object({id:f.string().min(1),operation:VV,count:f.number().int().positive().max(700),targetProbeCount:f.number().int().min(0).max(700),settleMs:f.number().int().nonnegative().max(300000)}),zx=f.object({profile:Px,maximumProbeCount:f.number().int().positive().max(700),maximumExternalAiCalls:f.number().int().nonnegative().max(1e4).optional(),phases:f.array(WV).min(1)}),Eke=f.object({entities:f.number().int().nonnegative(),notes:f.number().int().nonnegative(),version:f.string().min(1)}),BO=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()}),Ike=f.object({timestamp:f.iso.datetime(),cpuPercent:f.number().nonnegative(),memoryPercent:f.number().nonnegative(),pids:f.number().int().nonnegative()}),GV=f.object({id:f.string().min(1),operation:VV,count:f.number().int().positive(),success:f.boolean(),commitLatencyMs:f.number().nonnegative().optional(),persistenceLatencyMs:f.number().nonnegative().optional(),error:f.string().optional()}),QV=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()}),Ake=f.object({status:f.string(),restartCount:f.number().int().nonnegative(),oomKilled:f.boolean()}),YV=f.object({health:f.array(BO),runtime:f.array(Ike),externalAiCalls:f.number().int().nonnegative().optional(),container:Ake.optional()}),Tke=f.object({profile:Px,success:f.boolean(),baseline:Eke,phases:f.array(GV),cleanup:QV,metrics:YV,failure:f.string().optional()}),Cke={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 Rke}from"child_process";async function t7(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 po=async(e,t,r={})=>new Promise((i,n)=>{let o=Rke(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 Hp=()=>{};class Iu{#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 Iu(e,r,i);return await t7(e,"git",["-c","credential.helper=","-c",`credential.helper=${r7}`,"clone","--branch","main","--single-branch",`https://github.com/${t}.git`,r],{env:n.environment()}),await n.run(["config","--local","credential.helper",r7]),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 r7='!f() { test "$1" = get && echo username=x-access-token && echo "password=$GH_TOKEN"; }; f';var n7=x(()=>{Hp()});function Kp(e){return e.entityCounts.find((t)=>t.entityType==="note")?.count??0}class UO{#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 jO(`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 Pke.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||Kp(e)===t)&&(r===void 0||e.entities===r)}async#f(){while(!this.#i){for(let e of this.#n)this.#t.push(await jO(`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 Pke;var i7=x(()=>{Re();qO();Pke=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 Dx={};tr(Dx,{applyDirectorySyncStressPhase:()=>c7,cleanupDirectorySyncStress:()=>Fke,listProbeFiles:()=>Qa,parseStressRuntimeSample:()=>l7,removeProbeFiles:()=>VO,runDeployedDirectorySyncStress:()=>Uke,runStressCommand:()=>po,verifyDirectorySyncStressAccess:()=>Mke});import{chmod as zke,mkdir as FO,mkdtemp as ZO,readFile as Nke,readdir as Dke,rename as Lke,rm as Vp,writeFile as Yn}from"fs/promises";import{tmpdir as HO}from"os";import{join as xt,resolve as KO}from"path";async function Uke(e){let t=e.now??(()=>new Date),r=t().toISOString(),i=WO(r),n=KO(e.artifactsDir??xt(e.rootDir,".brains-ops","stress",i));await FO(n,{recursive:!0});let{pilot:o,user:s}=await JO(e.rootDir,e.handle);Nx({handle:s.handle,domain:s.domain,contentRepo:s.contentRepo,confirmation:e.confirmation});let a=Px.parse(e.profile),c=e.plan?zx.parse(e.plan):XV(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)a7(s);let l=Bke.parse(e.env??process.env),u=new s7({runId:i,artifactsDir:n,user:s,githubOrg:o.githubOrg,serverLabel:`${o.contentRepoPrefix}${s.handle}`,environment:l,fetchImpl:e.fetchImpl??fetch,commandRunner:e.commandRunner??po,logger:e.logger??console.info,now:t,sleep:e.sleep??Bun.sleep}),d;try{d=await e7(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 Kke(p),p}async function Mke(e){let r=(e.now??(()=>new Date))().toISOString(),i=WO(r),n=KO(e.artifactsDir??xt(e.rootDir,".brains-ops","stress",`access-check-${i}`));await FO(n,{recursive:!0});let{pilot:o,user:s}=await JO(e.rootDir,e.handle);Nx({handle:s.handle,domain:s.domain,contentRepo:s.contentRepo,confirmation:e.confirmation}),a7(s);let a=(e.env??process.env).CONTENT_REPO_ADMIN_TOKEN;if(!a)throw Error("Missing CONTENT_REPO_ADMIN_TOKEN");let c=await ZO(xt(HO(),"brains-ops-directory-sync-access-check-"));try{let l=await Iu.clone(e.commandRunner??po,`${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 Yn(xt(n,"access-check.json"),`${JSON.stringify(d,null,2)}
455
+ `),d}finally{await Vp(c,{recursive:!0,force:!0})}}async function Fke(e){let t=e.now??(()=>new Date),r=KO(e.artifactsDir??xt(e.rootDir,".brains-ops","stress",`cleanup-${WO(t().toISOString())}`));await FO(r,{recursive:!0});let{pilot:i,user:n}=await JO(e.rootDir,e.handle);Nx({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??po,a=e.logger??console.info,c=await ZO(xt(HO(),"brains-ops-directory-sync-cleanup-")),l=xt(c,"content");try{let u=await Iu.clone(s,`${i.githubOrg}/${n.contentRepo}`,l,o),d=await VO(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 Yn(xt(r,"cleanup.json"),`${JSON.stringify(g,null,2)}
456
+ `),g}finally{await Vp(c,{recursive:!0,force:!0})}}class s7{#e;#t;#r;#n;#i;#o;#a;#s;#c;#l;#d;constructor(e){this.#e=e,this.#t=new UO({domain:e.user.domain,fetchImpl:e.fetchImpl,now:e.now,sleep:e.sleep,sampleRuntime:()=>this.#y()})}async prepare(e){this.#r=await ZO(xt(HO(),"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 Yn(this.#i,Hke(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 Yn(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 Iu.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 Yn(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:Kp(s),version:s.version}},null,2)}
458
457
  `),this.#e.logger(`Prepared ${e.profile} directory-sync stress run for ${this.#e.user.handle}`),{entities:s.entities,notes:Kp(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 Au(e,"health did not provide a drained queue before the phase");await c7(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 Au(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 Au(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 Au(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 Au(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 Au(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 VO(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:Kp(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 Yn(xt(this.#e.artifactsDir,"health-samples.json"),`${JSON.stringify(this.#t.healthSamples,null,2)}
459
- `);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 Yn(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 Vp(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=qke.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=Uke.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 l7(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 a7(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 JO(e,t){let r=await Zt(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 c7(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(Hke).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 Yn(xt(e,`directory-sync-stress-${a}.md`),["---",`title: "Directory Sync Stress ${a}"`,"---","",`Deterministic directory-sync stress probe ${a}.`,"Payload: abcdefghijklmnopqrstuvwxyz-0123456789-abcdefghijklmnopqrstuvwxyz.",""].join(`
460
- `))}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 Dke(n,"utf8");await Yn(n,`${o.trimEnd()}
458
+ `);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 Yn(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 Vp(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=jke.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=qke.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 l7(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 a7(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 JO(e,t){let r=await Zt(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 c7(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(Zke).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 Yn(xt(e,`directory-sync-stress-${a}.md`),["---",`title: "Directory Sync Stress ${a}"`,"---","",`Deterministic directory-sync stress probe ${a}.`,"Payload: abcdefghijklmnopqrstuvwxyz-0123456789-abcdefghijklmnopqrstuvwxyz.",""].join(`
459
+ `))}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 Nke(n,"utf8");await Yn(n,`${o.trimEnd()}
461
460
 
462
461
  Update marker: ${t.id}.
463
- `)}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 Bke(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)=>Vp(xt(e,i),{force:!0})));break}}}async function Qa(e){return(await Lke(e)).filter((r)=>/^directory-sync-stress-(?:renamed-)?\d+\.md$/.test(r)&&!r.includes("/")).sort()}async function VO(e){let t=await Qa(e);return await Promise.all(t.map((r)=>Vp(xt(e,r),{force:!0}))),t.length}function Hke(e){let t=e.match(/(\d+)\.md$/)?.[1];return t?Number.parseInt(t,10):void 0}function Au(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 l7(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 Kke(e){return`${e.replace(/\r\n/g,`
462
+ `)}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 Lke(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)=>Vp(xt(e,i),{force:!0})));break}}}async function Qa(e){return(await Dke(e)).filter((r)=>/^directory-sync-stress-(?:renamed-)?\d+\.md$/.test(r)&&!r.includes("/")).sort()}async function VO(e){let t=await Qa(e);return await Promise.all(t.map((r)=>Vp(xt(e,r),{force:!0}))),t.length}function Zke(e){let t=e.match(/(\d+)\.md$/)?.[1];return t?Number.parseInt(t,10):void 0}function Au(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 l7(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 Hke(e){return`${e.replace(/\r\n/g,`
464
463
  `).replace(/\\n/g,`
465
464
  `).trimEnd()}
466
- `}function WO(e){return e.replace(/[-:.TZ]/g,"").slice(0,14)}async function Jke(e){await Yn(xt(e.artifactsDir,"report.json"),`${JSON.stringify(e,null,2)}
467
- `),await Yn(xt(e.artifactsDir,"report.md"),Vke(e))}function Vke(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"}`} | ${o7(a.commitLatencyMs)} | ${o7(a.persistenceLatencyMs)} |`),"","## Runtime","",`- Samples: ${t.length}`,`- CPU p50/p95/p99/max: ${Jp(MO(i,0.5))} / ${Jp(MO(i,0.95))} / ${Jp(MO(i,0.99))} / ${Jp(i.at(-1))}`,`- Memory max: ${Jp(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(`
465
+ `}function WO(e){return e.replace(/[-:.TZ]/g,"").slice(0,14)}async function Kke(e){await Yn(xt(e.artifactsDir,"report.json"),`${JSON.stringify(e,null,2)}
466
+ `),await Yn(xt(e.artifactsDir,"report.md"),Jke(e))}function Jke(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"}`} | ${o7(a.commitLatencyMs)} | ${o7(a.persistenceLatencyMs)} |`),"","## Runtime","",`- Samples: ${t.length}`,`- CPU p50/p95/p99/max: ${Jp(MO(i,0.5))} / ${Jp(MO(i,0.95))} / ${Jp(MO(i,0.99))} / ${Jp(i.at(-1))}`,`- Memory max: ${Jp(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(`
468
467
  `)}
469
- `}function MO(e,t){if(e.length===0)return;let r=Math.max(0,Math.ceil(e.length*t)-1);return e[r]}function Jp(e){return e===void 0?"n/a":`${e.toFixed(2)}%`}function o7(e){return e===void 0?"n/a":`${(e/1000).toFixed(1)}s`}var jke,qke,Uke;var Lx=x(()=>{Re();qO();pi();Hp();n7();i7();Hp();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)}),qke=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)})})}))}),Uke=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 u7=x(()=>{Qs()});var Wke="/usr/local/sbin/brains-health-watchdog",Gke="ai.rizom.brain.watchdog",Qke="true",GO,d7,Ctt;var f7=x(async()=>{u7();GO=`${Gke}=${Qke}`,d7=`#!/usr/bin/env bash
468
+ `}function MO(e,t){if(e.length===0)return;let r=Math.max(0,Math.ceil(e.length*t)-1);return e[r]}function Jp(e){return e===void 0?"n/a":`${e.toFixed(2)}%`}function o7(e){return e===void 0?"n/a":`${(e/1000).toFixed(1)}s`}var Bke,jke,qke;var Lx=x(()=>{Re();qO();pi();Hp();n7();i7();Hp();Bke=f.object({HCLOUD_TOKEN:f.string().min(1),KAMAL_SSH_PRIVATE_KEY:f.string().min(1),CONTENT_REPO_ADMIN_TOKEN:f.string().min(1)}),jke=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)})})}))}),qke=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 u7=x(()=>{Qs()});var Vke="/usr/local/sbin/brains-health-watchdog",Wke="ai.rizom.brain.watchdog",Gke="true",GO,d7,Ttt;var f7=x(async()=>{u7();GO=`${Wke}=${Gke}`,d7=`#!/usr/bin/env bash
470
469
  set -euo pipefail
471
470
  umask 077
472
471
 
@@ -525,14 +524,14 @@ while read -r container_id; do
525
524
  logger -t brains-health-watchdog "restarting unhealthy container=$container_name service=$service_name incident=$incident_path"
526
525
  docker restart "$container_id"
527
526
  done < <(docker ps --filter health=unhealthy --filter label=${GO} --format '{{.ID}}')
528
- `,Ctt=`[Unit]
527
+ `,Ttt=`[Unit]
529
528
  Description=Restart persistently unhealthy Brain containers
530
529
  After=docker.service
531
530
  Requires=docker.service
532
531
 
533
532
  [Service]
534
533
  Type=oneshot
535
- ExecStart=${Wke}
534
+ ExecStart=${Vke}
536
535
  `});var m7=`#!/usr/bin/env bash
537
536
  set -euo pipefail
538
537
  umask 077
@@ -760,13 +759,13 @@ deployed_container_restarted=false
760
759
  EOF
761
760
  pass "fleet watchdog isolation smoke completed"
762
761
  printf 'REMOTE_ARTIFACT_DIR=%s\\n' "$remote_dir"
763
- `;var p7=()=>{};var eR={};tr(eR,{assertHealthWatchdogSmokeTarget:()=>XO,cleanupHealthWatchdogSmoke:()=>oEe,renderHealthWatchdogSmokeRemoteScript:()=>b7,runHealthWatchdogSmoke:()=>iEe});import{access as Xke,chmod as eEe,mkdir as h7,mkdtemp as tEe,rm as YO,writeFile as Tu}from"fs/promises";import{tmpdir as rEe}from"os";import{join as Ii,resolve as g7}from"path";function XO(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 b7(){return m7.replace("__WATCHDOG_PAYLOAD_BASE64__",Buffer.from(d7,"utf8").toString("base64")).replace("__WATCHDOG_LABEL_FILTER__",GO)}async function iEe(e){let t=g7(e.artifactsDir??Ii(e.rootDir,".brains-ops","watchdog-smoke",e.runId)),r=await x7(e.rootDir,e.handle);XO({handle:r.user.handle,domain:r.user.domain,confirmation:e.confirmation,runId:e.runId}),await h7(t,{recursive:!0});let i=y7.parse(e.env??process.env),n=e.commandRunner??po,o=e.logger??console.info,s=await S7({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 QO(s,"run",e.runId);if(await Bx(t,"remote",p),p.stdout.trim())o(p.stdout.trim());if(p.exitCode!==0)c=Ei("ssh",["watchdog-smoke","run"],p);let m=await sEe(s,a,t);if(await Bx(t,"scp",m),m.exitCode===0){if(l=await aEe(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 QO(s,"cleanup",e.runId);if(await Bx(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 YO(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 Tu(Ii(t,"result.json"),`${JSON.stringify(d,null,2)}
764
- `),d}async function oEe(e){let t=g7(e.artifactsDir??Ii(e.rootDir,".brains-ops","watchdog-smoke",`cleanup-${e.runId}`)),r=await x7(e.rootDir,e.handle);XO({handle:r.user.handle,domain:r.user.domain,confirmation:e.confirmation,runId:e.runId}),await h7(t,{recursive:!0});let i=y7.parse(e.env??process.env),n=await S7({target:r,environment:i,commandRunner:e.commandRunner??po,fetchImpl:e.fetchImpl??fetch});try{let s=await QO(n,"cleanup",e.runId);if(await Bx(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 YO(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 Tu(Ii(t,"result.json"),`${JSON.stringify(o,null,2)}
765
- `),o}async function x7(e,t){let r=await Zt(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 S7(e){let t=await tEe(Ii(rEe(),"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=nEe.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 Tu(r,cEe(e.environment.KAMAL_SSH_PRIVATE_KEY),{mode:384}),await eEe(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 Tu(i,c.stdout,{mode:384}),{temporaryRoot:t,sshKeyPath:r,knownHostsPath:i,serverIp:a.public_net.ipv4.ip,commandRunner:e.commandRunner}}catch(n){throw await YO(t,{recursive:!0,force:!0}),n}}async function QO(e,t,r){return e.commandRunner("ssh",[...w7(e),`root@${e.serverIp}`,"bash","-s","--",t,r],{stdin:b7()})}async function sEe(e,t,r){return e.commandRunner("scp",[...w7(e),"-r",`root@${e.serverIp}:${t}/.`,r])}function w7(e){return["-i",e.sshKeyPath,"-o","BatchMode=yes","-o","IdentitiesOnly=yes","-o","ConnectTimeout=10","-o","StrictHostKeyChecking=yes","-o",`UserKnownHostsFile=${e.knownHostsPath}`]}async function aEe(e){try{return await Xke(e),!0}catch{return!1}}async function Bx(e,t,r){await Promise.all([Tu(Ii(e,`${t}.stdout.log`),r.stdout),Tu(Ii(e,`${t}.stderr.log`),r.stderr)])}function cEe(e){return`${e.replace(/\r\n/g,`
762
+ `;var p7=()=>{};var eR={};tr(eR,{assertHealthWatchdogSmokeTarget:()=>XO,cleanupHealthWatchdogSmoke:()=>iEe,renderHealthWatchdogSmokeRemoteScript:()=>b7,runHealthWatchdogSmoke:()=>nEe});import{access as Yke,chmod as Xke,mkdir as h7,mkdtemp as eEe,rm as YO,writeFile as Tu}from"fs/promises";import{tmpdir as tEe}from"os";import{join as Ii,resolve as g7}from"path";function XO(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 b7(){return m7.replace("__WATCHDOG_PAYLOAD_BASE64__",Buffer.from(d7,"utf8").toString("base64")).replace("__WATCHDOG_LABEL_FILTER__",GO)}async function nEe(e){let t=g7(e.artifactsDir??Ii(e.rootDir,".brains-ops","watchdog-smoke",e.runId)),r=await x7(e.rootDir,e.handle);XO({handle:r.user.handle,domain:r.user.domain,confirmation:e.confirmation,runId:e.runId}),await h7(t,{recursive:!0});let i=y7.parse(e.env??process.env),n=e.commandRunner??po,o=e.logger??console.info,s=await S7({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 QO(s,"run",e.runId);if(await Bx(t,"remote",p),p.stdout.trim())o(p.stdout.trim());if(p.exitCode!==0)c=Ei("ssh",["watchdog-smoke","run"],p);let m=await oEe(s,a,t);if(await Bx(t,"scp",m),m.exitCode===0){if(l=await sEe(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 QO(s,"cleanup",e.runId);if(await Bx(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 YO(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 Tu(Ii(t,"result.json"),`${JSON.stringify(d,null,2)}
763
+ `),d}async function iEe(e){let t=g7(e.artifactsDir??Ii(e.rootDir,".brains-ops","watchdog-smoke",`cleanup-${e.runId}`)),r=await x7(e.rootDir,e.handle);XO({handle:r.user.handle,domain:r.user.domain,confirmation:e.confirmation,runId:e.runId}),await h7(t,{recursive:!0});let i=y7.parse(e.env??process.env),n=await S7({target:r,environment:i,commandRunner:e.commandRunner??po,fetchImpl:e.fetchImpl??fetch});try{let s=await QO(n,"cleanup",e.runId);if(await Bx(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 YO(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 Tu(Ii(t,"result.json"),`${JSON.stringify(o,null,2)}
764
+ `),o}async function x7(e,t){let r=await Zt(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 S7(e){let t=await eEe(Ii(tEe(),"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=rEe.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 Tu(r,aEe(e.environment.KAMAL_SSH_PRIVATE_KEY),{mode:384}),await Xke(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 Tu(i,c.stdout,{mode:384}),{temporaryRoot:t,sshKeyPath:r,knownHostsPath:i,serverIp:a.public_net.ipv4.ip,commandRunner:e.commandRunner}}catch(n){throw await YO(t,{recursive:!0,force:!0}),n}}async function QO(e,t,r){return e.commandRunner("ssh",[...w7(e),`root@${e.serverIp}`,"bash","-s","--",t,r],{stdin:b7()})}async function oEe(e,t,r){return e.commandRunner("scp",[...w7(e),"-r",`root@${e.serverIp}:${t}/.`,r])}function w7(e){return["-i",e.sshKeyPath,"-o","BatchMode=yes","-o","IdentitiesOnly=yes","-o","ConnectTimeout=10","-o","StrictHostKeyChecking=yes","-o",`UserKnownHostsFile=${e.knownHostsPath}`]}async function sEe(e){try{return await Yke(e),!0}catch{return!1}}async function Bx(e,t,r){await Promise.all([Tu(Ii(e,`${t}.stdout.log`),r.stdout),Tu(Ii(e,`${t}.stderr.log`),r.stderr)])}function aEe(e){return`${e.replace(/\r\n/g,`
766
765
  `).replace(/\\n/g,`
767
766
  `).trimEnd()}
768
- `}var y7,nEe;var tR=x(async()=>{Re();p7();pi();Hp();await f7();y7=f.object({HCLOUD_TOKEN:f.string().min(1),KAMAL_SSH_PRIVATE_KEY:f.string().min(1)}),nEe=f.object({servers:f.array(f.object({status:f.string(),public_net:f.object({ipv4:f.object({ip:f.string().min(1)})})}))})});import{parseArgs as nW}from"util";function mt(e){return e}class Gp extends Error{constructor(e){super(e);this.name="CliUsageError"}}function iW(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 oW(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 sW(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 oR(e,t){let r=iW(t.commands,t.globalFlags??{}),i,n;try{({values:i,positionals:n}=nW({args:e,options:oW(r),allowPositionals:!0,strict:t.strict??!0}))}catch(s){if(sW(s))throw new Gp(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 sR(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 aW(e){return sR(e.map((t)=>({label:t.usage?`${t.name} ${t.usage}`:t.name,description:t.description})))}function cW(e,t){let r=t.type==="string"?` ${t.placeholder??"<value>"}`:"",i=t.short!==void 0?`, -${t.short}`:"";return`--${e}${r}${i}`}function aR(e){return sR(Object.entries(e).map(([t,r])=>({label:cW(t,r),description:r.description})))}function cR(e,t){return`Usage: ${e} ${t.name}${t.usage?` ${t.usage}`:""}`}function lW(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 uW(e){let t=[],r=new Map;for(let n of e){let o=n.flags??{};if(Object.keys(o).length===0)continue;let s=lW(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(...aR(n.flags));return i}function lR(e){let t=[e.intro,"",`Usage: ${e.cliName} ${e.usage??"<command> [args]"}`,"","Commands:",...aW(e.commands)];if(e.globalFlags&&Object.keys(e.globalFlags).length>0)t.push("","Options:",...aR(e.globalFlags));return t.push(...uW(e.commands)),t.join(`
769
- `)}function uR(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 nc(e,t){let r=e[t];return typeof r==="boolean"?r:void 0}var Qp={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"};import{existsSync as jQ,mkdirSync as qQ,readFileSync as Tw,writeFileSync as Cw}from"fs";import{dirname as UQ,join as x2}from"path";function Mx(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function Ct(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 rr(e,t,r=""){let i=Mx(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 Ti(e){if(typeof e!=="function"||typeof e.create!=="function")throw TypeError("Hash must wrapped by utils.createHasher");if(Ct(e.outputLen),Ct(e.blockLen),e.outputLen<1)throw Error('"outputLen" must be >= 1');if(e.blockLen<1)throw Error('"blockLen" must be >= 1')}function ic(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 Yp(e,t){rr(e,void 0,"digestInto() output");let r=t.outputLen;if(e.length<r)throw RangeError('"digestInto() output" expected to be of length >='+r)}function Xp(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function Ar(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function oc(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Pn(e,t){return e<<32-t|e>>>t}function Qe(e,t){return e<<t|e>>>32-t>>>0}var fW=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)();function pW(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function mW(e){for(let t=0;t<e.length;t++)e[t]=pW(e[t]);return e}var Fx=fW?(e)=>e:mW,fR=(()=>typeof Uint8Array.from([]).toHex==="function"&&typeof Uint8Array.fromHex==="function")(),hW=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function em(e){if(rr(e),fR)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=hW[e[r]];return t}var Ai={_0:48,_9:57,A:65,F:70,a:97,f:102};function dR(e){if(e>=Ai._0&&e<=Ai._9)return e-Ai._0;if(e>=Ai.A&&e<=Ai.F)return e-(Ai.A-10);if(e>=Ai.a&&e<=Ai.f)return e-(Ai.a-10);return}function Pu(e){if(typeof e!=="string")throw TypeError("hex string expected, got "+typeof e);if(fR)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=dR(e.charCodeAt(o)),a=dR(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 gW(e){if(typeof e!=="string")throw TypeError("string expected");return new Uint8Array(new TextEncoder().encode(e))}function Zx(e,t=""){if(typeof e==="string")return gW(e);return rr(e,void 0,t)}function Hx(...e){let t=0;for(let i=0;i<e.length;i++){let n=e[i];rr(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 tm(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 Kx(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 Ci(e=32){Ct(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 Jx=(e)=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});class Vx{oHash;iHash;blockLen;outputLen;canXOF=!1;finished=!1;destroyed=!1;constructor(e,t){if(Ti(e),rr(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),Ar(i)}update(e){return ic(this),this.iHash.update(e),this}digestInto(e){ic(this),Yp(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 Xn=(()=>{let e=(t,r,i)=>new Vx(t,r).update(i).digest();return e.create=(t,r)=>new Vx(t,r),e})();function zu(e,t,r){if(Ti(e),r===void 0)r=new Uint8Array(e.outputLen);return Xn(e,r,t)}var Wx=Uint8Array.of(0),pR=Uint8Array.of();function Gx(e,t,r,i=32){Ti(e),Ct(i,"length"),rr(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=pR;else rr(r,void 0,"info");let s=new Uint8Array(o*n),a=Xn.create(e,t),c=a._cloneInto(),l=new Uint8Array(a.outputLen);for(let u=0;u<o;u++)Wx[0]=u+1,c.update(u===0?pR:l).update(r).update(Wx).digestInto(l),s.set(l,n*u),a._cloneInto(c);return a.destroy(),c.destroy(),Ar(l,Wx),s.slice(0,i)}var mo=(e,t,r,i,n)=>Gx(e,zu(e,t,r),i,n);function mR(e,t,r){return e&t^~e&r}function hR(e,t,r){return e&t^e&r^t&r}class rm{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=oc(this.buffer)}update(e){ic(this),rr(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=oc(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){ic(this),Yp(e,this),this.finished=!0;let{buffer:t,view:r,blockLen:i,isLE:n}=this,{pos:o}=this;if(t[o++]=128,Ar(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=oc(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 $i=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var nr=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var nm=BigInt(4294967295),gR=BigInt(32);function yW(e,t=!1){if(t)return{h:Number(e&nm),l:Number(e>>gR&nm)};return{h:Number(e>>gR&nm)|0,l:Number(e&nm)|0}}function yR(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}=yW(e[o],t);[i[o],n[o]]=[s,a]}return[i,n]}var Qx=(e,t,r)=>e>>>r,Yx=(e,t,r)=>e<<32-r|t>>>r,Cs=(e,t,r)=>e>>>r|t<<32-r,$s=(e,t,r)=>e<<32-r|t>>>r,Nu=(e,t,r)=>e<<64-r|t>>>r-32,Du=(e,t,r)=>e>>>r-32|t<<64-r;function ei(e,t,r,i){let n=(t>>>0)+(i>>>0);return{h:e+r+(n/4294967296|0)|0,l:n|0}}var bR=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),xR=(e,t,r,i)=>t+r+i+(e/4294967296|0)|0,SR=(e,t,r,i)=>(e>>>0)+(t>>>0)+(r>>>0)+(i>>>0),wR=(e,t,r,i,n)=>t+r+i+n+(e/4294967296|0)|0,vR=(e,t,r,i,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(i>>>0)+(n>>>0),_R=(e,t,r,i,n,o)=>t+r+i+n+o+(e/4294967296|0)|0;var xW=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]),ho=new Uint32Array(64);class kR extends rm{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)ho[u]=e.getUint32(t,!1);for(let u=16;u<64;u++){let d=ho[u-15],p=ho[u-2],m=Pn(d,7)^Pn(d,18)^d>>>3,y=Pn(p,17)^Pn(p,19)^p>>>10;ho[u]=y+ho[u-7]+m+ho[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=Pn(s,6)^Pn(s,11)^Pn(s,25),p=l+d+mR(s,a,c)+xW[u]+ho[u]|0,y=(Pn(r,2)^Pn(r,13)^Pn(r,22))+hR(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(){Ar(ho)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),Ar(this.buffer)}}class ER extends kR{A=$i[0]|0;B=$i[1]|0;C=$i[2]|0;D=$i[3]|0;E=$i[4]|0;F=$i[5]|0;G=$i[6]|0;H=$i[7]|0;constructor(){super(32)}}var IR=(()=>yR(["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))))(),SW=(()=>IR[0])(),wW=(()=>IR[1])(),go=new Uint32Array(80),yo=new Uint32Array(80);class AR extends rm{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)go[A]=e.getUint32(t),yo[A]=e.getUint32(t+=4);for(let A=16;A<80;A++){let T=go[A-15]|0,z=yo[A-15]|0,j=Cs(T,z,1)^Cs(T,z,8)^Qx(T,z,7),E=$s(T,z,1)^$s(T,z,8)^Yx(T,z,7),Z=go[A-2]|0,D=yo[A-2]|0,H=Cs(Z,D,19)^Nu(Z,D,61)^Qx(Z,D,6),X=$s(Z,D,19)^Du(Z,D,61)^Yx(Z,D,6),M=SR(E,X,yo[A-7],yo[A-16]),P=wR(M,j,H,go[A-7],go[A-16]);go[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=Cs(u,d,14)^Cs(u,d,18)^Nu(u,d,41),z=$s(u,d,14)^$s(u,d,18)^Du(u,d,41),j=u&p^~u&y,E=d&m^~d&g,Z=vR(v,z,E,wW[A],yo[A]),D=_R(Z,b,T,j,SW[A],go[A]),H=Z|0,X=Cs(r,i,28)^Nu(r,i,34)^Nu(r,i,39),M=$s(r,i,28)^Du(r,i,34)^Du(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}=ei(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=bR(H,M,N);r=xR(I,D,X,P),i=I|0}({h:r,l:i}=ei(this.Ah|0,this.Al|0,r|0,i|0)),{h:n,l:o}=ei(this.Bh|0,this.Bl|0,n|0,o|0),{h:s,l:a}=ei(this.Ch|0,this.Cl|0,s|0,a|0),{h:c,l}=ei(this.Dh|0,this.Dl|0,c|0,l|0),{h:u,l:d}=ei(this.Eh|0,this.El|0,u|0,d|0),{h:p,l:m}=ei(this.Fh|0,this.Fl|0,p|0,m|0),{h:y,l:g}=ei(this.Gh|0,this.Gl|0,y|0,g|0),{h:b,l:v}=ei(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(){Ar(go,yo)}destroy(){this.destroyed=!0,Ar(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class TR extends AR{Ah=nr[0]|0;Al=nr[1]|0;Bh=nr[2]|0;Bl=nr[3]|0;Ch=nr[4]|0;Cl=nr[5]|0;Dh=nr[6]|0;Dl=nr[7]|0;Eh=nr[8]|0;El=nr[9]|0;Fh=nr[10]|0;Fl=nr[11]|0;Gh=nr[12]|0;Gl=nr[13]|0;Hh=nr[14]|0;Hl=nr[15]|0;constructor(){super(64)}}var $t=Kx(()=>new ER,Jx(1));var im=Kx(()=>new TR,Jx(3));/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function lm(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function tS(e){if(!lm(e))throw TypeError("Uint8Array expected")}function PR(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 zR(e){if(typeof e!=="function")throw TypeError("function expected");return!0}function bo(e,t){if(typeof t!=="string")throw TypeError(`${e}: string expected`);return!0}function Bu(e){if(typeof e!=="number")throw TypeError(`number expected, got ${typeof e}`);if(!Number.isSafeInteger(e))throw RangeError(`invalid integer: ${e}`)}function sm(e){if(!Array.isArray(e))throw TypeError("array expected")}function am(e,t){if(!PR(!0,t))throw TypeError(`${e}: array of strings expected`)}function rS(e,t){if(!PR(!1,t))throw TypeError(`${e}: array of numbers expected`)}function en(...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 tn(e){let t=typeof e==="string"?e.split(""):e,r=t.length;am("alphabet",t);let i=new Map(t.map((n,o)=>[n,o]));return{encode:(n)=>(sm(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)=>(sm(n),n.map((o)=>{bo("alphabet.decode",o);let s=i.get(o);if(s===void 0)throw Error(`Unknown letter: "${o}". Allowed: ${e}`);return s}))}}function rn(e=""){return bo("join",e),{encode:(t)=>(am("join.decode",t),t.join(e)),decode:(t)=>(bo("join.decode",t),t.split(e))}}function um(e,t="="){return Bu(e),bo("padding",t),{encode(r){am("padding.encode",r);while(r.length*e%8)r.push(t);return r},decode(r){am("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 NR(e){return zR(e),{encode:(t)=>t,decode:(t)=>e(t)}}function CR(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(sm(e),!e.length)return[];let i=0,n=[],o=Array.from(e,(a)=>{if(Bu(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 DR=(e,t)=>t===0?e:DR(t,e%t),cm=(e,t)=>e+(t-DR(e,t)),om=(()=>{let e=[];for(let t=0;t<40;t++)e.push(2**t);return e})();function Xx(e,t,r,i){if(sm(e),t<=0||t>32)throw RangeError(`convertRadix2: wrong from=${t}`);if(r<=0||r>32)throw RangeError(`convertRadix2: wrong to=${r}`);if(cm(t,r)>32)throw Error(`convertRadix2: carry overflow from=${t} to=${r} carryBits=${cm(t,r)}`);let n=0,o=0,s=om[t],a=om[r]-1,c=[];for(let l of e){if(Bu(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=om[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 vW(e){Bu(e);let t=256;return{encode:(r)=>{if(!lm(r))throw TypeError("radix.encode input should be Uint8Array");return CR(Array.from(r),t,e)},decode:(r)=>(rS("radix.decode",r),Uint8Array.from(CR(r,e,t)))}}function gn(e,t=!1){if(Bu(e),e<=0||e>32)throw RangeError("radix2: bits should be in (0..32]");if(cm(8,e)>32||cm(e,8)>32)throw RangeError("radix2: carry overflow");return{encode:(r)=>{if(!lm(r))throw TypeError("radix2.encode input should be Uint8Array");return Xx(Array.from(r),8,e,!t)},decode:(r)=>(rS("radix2.decode",r),Uint8Array.from(Xx(r,e,8,t)))}}function $R(e){return zR(e),function(...t){try{return e.apply(null,t)}catch(r){}}}var $Ee=Object.freeze(en(gn(4),tn("0123456789ABCDEF"),rn(""))),OEe=Object.freeze(en(gn(5),tn("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),um(5),rn(""))),REe=Object.freeze(en(gn(5),tn("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),rn(""))),PEe=Object.freeze(en(gn(5),tn("0123456789ABCDEFGHIJKLMNOPQRSTUV"),um(5),rn(""))),zEe=Object.freeze(en(gn(5),tn("0123456789ABCDEFGHIJKLMNOPQRSTUV"),rn(""))),NEe=Object.freeze(en(gn(5),tn("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),rn(""),NR((e)=>e.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1")))),LR=(()=>typeof Uint8Array.from([]).toBase64==="function"&&typeof Uint8Array.fromBase64==="function")(),_W=/[\t\n\f\r ]/,BR=(e,t)=>{bo("base64",e);let r=t?"base64url":"base64";if(e.length>0&&_W.test(e))throw Error("invalid base64");return Uint8Array.fromBase64(e,{alphabet:r,lastChunkHandling:"strict"})},nS=Object.freeze(LR?{encode(e){return tS(e),e.toBase64()},decode(e){return BR(e,!1)}}:en(gn(6),tn("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),um(6),rn(""))),gr=Object.freeze(en(gn(6),tn("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),rn(""))),DEe=Object.freeze(LR?{encode(e){return tS(e),e.toBase64({alphabet:"base64url"})},decode(e){return BR(e,!0)}}:en(gn(6),tn("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),um(6),rn(""))),LEe=Object.freeze(en(gn(6),tn("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),rn(""))),iS=(e)=>en(vW(58),tn(e),rn("")),BEe=Object.freeze(iS("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")),jEe=Object.freeze(iS("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ")),qEe=Object.freeze(iS("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz"));var eS=en(tn("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),rn("")),OR=[996825010,642813549,513874426,1027748829,705979059];function Lu(e){let t=e>>25,r=(e&33554431)<<5;for(let i=0;i<OR.length;i++)if((t>>i&1)===1)r^=OR[i];return r}function RR(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=Lu(n)^s>>5}n=Lu(n);for(let o=0;o<i;o++)n=Lu(n)^e.charCodeAt(o)&31;for(let o of t)n=Lu(n)^o;for(let o=0;o<6;o++)n=Lu(n);return n^=r,eS.encode(Xx([n%om[30]],30,5,!1))}function jR(e){let t=e==="bech32"?1:734539939,r=gn(5),i=r.decode,n=r.encode,o=$R(i);function s(d,p,m=90){if(bo("bech32.encode prefix",d),lm(p))p=Array.from(p);rS("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=RR(b,p,t);return`${b}1${eS.encode(p)}${v}`}function a(d,p=90){bo("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=eS.decode(v).slice(0,-6),T=RR(b,A,t);if(!v.endsWith(T))throw Error(`Invalid checksum in ${d}: expected "${T}"`);return{prefix:b,words:A}}let c=$R(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 nn=Object.freeze(jR("bech32")),UEe=Object.freeze(jR("bech32m"));var kW=(()=>typeof Uint8Array.from([]).toHex==="function"&&typeof Uint8Array.fromHex==="function")(),EW={encode(e){return tS(e),e.toHex()},decode(e){return bo("hex",e),Uint8Array.fromHex(e)}},MEe=Object.freeze(kW?EW:en(gn(4),tn("0123456789abcdef"),rn(""),NR((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 AW(e,t,r,i){Ti(e);let n=tm({dkLen:32,asyncTick:10},i),{c:o,dkLen:s,asyncTick:a}=n;if(Ct(o,"c"),Ct(s,"dkLen"),Ct(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=Zx(t,"password"),l=Zx(r,"salt"),u=new Uint8Array(s),d=Xn.create(e,c),p=d._cloneInto().update(l);return{c:o,dkLen:s,asyncTick:a,DK:u,PRF:d,PRFSalt:p}}function TW(e,t,r,i,n){if(e.destroy(),t.destroy(),i)i.destroy();return Ar(n),r}function oS(e,t,r,i){let{c:n,dkLen:o,DK:s,PRF:a,PRFSalt:c}=AW(e,t,r,i),l,u=new Uint8Array(4),d=oc(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 TW(a,c,s,l,p)}function qR(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 sS(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(qR(r,s,e,t,r,o),a>0)s+=16;qR(r,o,e,t+=16,r,s)}}function CW(e,t,r){let i=tm({dkLen:32,asyncTick:10,maxmem:1073742848},r),{N:n,r:o,p:s,dkLen:a,asyncTick:c,maxmem:l,onProgress:u}=i;if(Ct(n,"N"),Ct(o,"r"),Ct(s,"p"),Ct(a,"dkLen"),Ct(c,"asyncTick"),Ct(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=oS($t,e,t,{c:1,dkLen:d*s}),b=Xp(g),v=Xp(new Uint8Array(d*n)),A=Xp(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 $W(e,t,r,i,n){let o=oS($t,e,r,{c:1,dkLen:t});return Ar(r,i,n),o}function aS(e,t,r){let{N:i,r:n,p:o,dkLen:s,blockSize32:a,V:c,B32:l,B:u,tmp:d,blockMixCb:p}=CW(e,t,r);Fx(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++)sS(c,b,c,b+=a,n),p();sS(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];sS(d,0,l,y,n),p()}}return Fx(l),$W(e,s,u,c,d)}/*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */function OW(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function dm(e){if(typeof e!=="boolean")throw TypeError(`boolean expected, not ${e}`)}function sc(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 Mt(e,t,r=""){let i=OW(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 cS(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 UR(e,t,r=!1){Mt(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&&!ac(e))throw Error("invalid output, must be aligned")}function ti(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function zn(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function RW(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}var Os=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)(),PW=(e)=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255;var zW=(e)=>{for(let t=0;t<e.length;t++)e[t]=PW(e[t]);return e},Oi=Os?(e)=>e:zW;function MR(e,t){if(t==null||typeof t!=="object")throw Error("options must be defined");return Object.assign(e,t)}function FR(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 ZR(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 HR=(e,t)=>{function r(i,...n){if(Mt(i,void 0,"key"),e.nonceLength!==void 0){let u=n[0];Mt(u,e.varSizeNonce?void 0:e.nonceLength,"nonce")}let o=e.tagLength;if(o&&n[1]!==void 0)Mt(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");Mt(d,void 0,"output")}},c=!1;return{encrypt(u,d){if(c)throw Error("cannot encrypt() twice with same key + nonce");return c=!0,Mt(u),a(s.encrypt.length,d),s.encrypt(u,d)},decrypt(u,d){if(Mt(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 ju(e,t,r=!0){if(t===void 0)return new Uint8Array(e);if(Mt(t,void 0,"output"),t.length!==e)throw Error('"output" expected Uint8Array of length '+e+", got: "+t.length);if(r&&!ac(t))throw Error("invalid output, must be aligned");return t}function KR(e,t,r){sc(e),sc(t),dm(r);let i=new Uint8Array(16),n=RW(i);return n.setBigUint64(0,BigInt(t),r),n.setBigUint64(8,BigInt(e),r),i}function ac(e){return e.byteOffset%4===0}function cc(e){return Uint8Array.from(Mt(e))}var VR=(e)=>Uint8Array.from(e.split(""),(t)=>t.charCodeAt(0)),NW=(()=>Oi(ti(VR("expand 16-byte k"))))(),DW=(()=>Oi(ti(VR("expand 32-byte k"))))();function Ye(e,t){return e<<t|e>>>32-t}var qu=64,LW=16,lS=(()=>4294967295)(),JR=Uint32Array.of();function BW(e,t,r,i,n,o,s,a){let c=n.length,l=new Uint8Array(qu),u=ti(l),d=Os&&ac(n)&&ac(o),p=d?ti(n):JR,m=d?ti(o):JR;if(!Os){for(let y=0;y<c;s++){if(e(t,r,i,u,s,a),Oi(u),s>=lS)throw Error("arx: counter overflow");let g=Math.min(qu,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>=lS)throw Error("arx: counter overflow");let g=Math.min(qu,c-y);if(d&&g===qu){let b=y/4;if(y%4!==0)throw Error("arx: invalid block position");for(let v=0,A;v<LW;v++)A=b+v,m[A]=p[A]^u[v];y+=qu;continue}for(let b=0,v;b<g;b++)v=y+b,o[v]=n[v]^l[b];y+=g}}function WR(e,t){let{allowShortKeys:r,extendNonceFn:i,counterLength:n,counterRight:o,rounds:s}=MR({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},t);if(typeof e!=="function")throw Error("core must be a function");return sc(n),sc(s),dm(o),dm(r),(a,c,l,u,d=0)=>{Mt(a,void 0,"key"),Mt(c,void 0,"nonce"),Mt(l,void 0,"data");let p=l.length;if(u=ju(p,u,!1),sc(d),d<0||d>=lS)throw Error("arx: counter overflow");let m=[],y=a.length,g,b;if(y===32)m.push(g=cc(a)),b=DW;else if(y===16&&r)g=new Uint8Array(32),g.set(a),g.set(a,16),b=NW,m.push(g);else throw Mt(a,32,"arx key"),Error("invalid key size");if(!Os||!ac(c))m.push(c=cc(c));let v=ti(g);if(i){if(c.length!==24)throw Error("arx: extended nonce must be 24 bytes");let z=c.subarray(0,16);if(Os)i(b,v,ti(z),v);else{let j=Oi(Uint32Array.from(b));i(j,v,ti(z),v),zn(j),Oi(v)}c=c.subarray(16)}else if(!Os)Oi(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=Oi(ti(c));try{return BW(e,b,v,T,l,u,d,s),u}finally{zn(...m)}}}function ir(e,t){return e[t++]&255|(e[t++]&255)<<8}class GR{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=cc(Mt(e,32,"key"));let t=ir(e,0),r=ir(e,2),i=ir(e,4),n=ir(e,6),o=ir(e,8),s=ir(e,10),a=ir(e,12),c=ir(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]=ir(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=ir(e,t+0),v=ir(e,t+2),A=ir(e,t+4),T=ir(e,t+6),z=ir(e,t+8),j=ir(e,t+10),E=ir(e,t+12),Z=ir(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;zn(r)}update(e){cS(this),Mt(e),e=cc(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,zn(this.h,this.r,this.buffer,this.pad)}digestInto(e){cS(this),UR(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 QR=ZR(32,(e)=>new GR(e));function jW(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 qW=WR(jW,{counterRight:!1,counterLength:4,allowShortKeys:!1});var UW=new Uint8Array(16),YR=(e,t)=>{e.update(t);let r=t.length%16;if(r)e.update(UW.subarray(r))},MW=new Uint8Array(32);function XR(e,t,r,i,n){if(n!==void 0)Mt(n,void 0,"AAD");let o=e(t,r,MW),s=KR(i.length,n?n.length:0,!0),a=QR.create(o);if(n)YR(a,n);YR(a,i),a.update(s);let c=a.digest();return zn(o,s),c}var FW=(e)=>(t,r,i)=>({encrypt(o,s){let a=o.length;s=ju(a+16,s,!1),s.set(o);let c=s.subarray(0,-16);e(t,r,c,c,1);let l=XR(e,t,r,c,i);return s.set(l,a),zn(l),s},decrypt(o,s){s=ju(o.length-16,s,!1);let a=o.subarray(0,-16),c=o.subarray(-16),l=XR(e,t,r,a,i);if(!FR(c,l))throw zn(l),Error("invalid tag");return s.set(o.subarray(0,-16)),e(t,r,s,s,1),zn(l),s}}),yn=HR({blockSize:64,nonceLength:12,tagLength:16},FW(qW));/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function lc(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Wt(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=lc(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 bn(e){if(typeof e!=="function"||typeof e.create!=="function")throw Error("Hash must wrapped by utils.createHasher");Wt(e.outputLen),Wt(e.blockLen)}function Pi(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 fm(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 pm(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function Mr(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function mm(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Nn(e,t){return e<<32-t|e>>>t}var ZW=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)();function HW(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function KW(e){for(let t=0;t<e.length;t++)e[t]=HW(e[t]);return e}var uS=ZW?(e)=>e:KW,tP=(()=>typeof Uint8Array.from([]).toHex==="function"&&typeof Uint8Array.fromHex==="function")(),JW=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Rs(e){if(Ne(e),tP)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=JW[e[r]];return t}var Ri={_0:48,_9:57,A:65,F:70,a:97,f:102};function eP(e){if(e>=Ri._0&&e<=Ri._9)return e-Ri._0;if(e>=Ri.A&&e<=Ri.F)return e-(Ri.A-10);if(e>=Ri.a&&e<=Ri.f)return e-(Ri.a-10);return}function Ps(e){if(typeof e!=="string")throw Error("hex string expected, got "+typeof e);if(tP)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=eP(e.charCodeAt(o)),a=eP(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 Lt(...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 uc(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 xo(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 So=(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 fS=BigInt(0),dS=BigInt(1);function Uu(e,t=""){if(typeof e!=="boolean"){let r=t&&`"${t}" `;throw Error(r+"expected boolean, got type="+typeof e)}return e}function rP(e){if(typeof e==="bigint"){if(!hm(e))throw Error("positive bigint expected, got "+e)}else Wt(e);return e}function Mu(e){let t=rP(e).toString(16);return t.length&1?"0"+t:t}function nP(e){if(typeof e!=="string")throw Error("hex string expected, got "+typeof e);return e===""?fS:BigInt("0x"+e)}function wo(e){return nP(Rs(e))}function vo(e){return nP(Rs(gm(Ne(e)).reverse()))}function dc(e,t){Wt(t),e=rP(e);let r=Ps(e.toString(16).padStart(t*2,"0"));if(r.length!==t)throw Error("number too large");return r}function Fu(e,t){return dc(e,t).reverse()}function gm(e){return Uint8Array.from(e)}function _o(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 hm=(e)=>typeof e==="bigint"&&fS<=e;function VW(e,t,r){return hm(e)&&hm(t)&&hm(r)&&t<=e&&e<r}function Zu(e,t,r,i){if(!VW(t,r,i))throw Error("expected valid "+e+": "+r+" <= n < "+i+", got "+t)}function pS(e){let t;for(t=0;e>fS;e>>=dS,t+=1);return t}var Hu=(e)=>(dS<<BigInt(e))-dS;function iP(e,t,r){if(Wt(e,"hashLen"),Wt(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,Lt(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 Lt(...v)};return(b,v)=>{d(),m(b);let A=void 0;while(!(A=v(y())))m();return d(),A}}function zs(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 mS(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 Cr=BigInt(0),yr=BigInt(1),Ns=BigInt(2),aP=BigInt(3),cP=BigInt(4),lP=BigInt(5),WW=BigInt(7),uP=BigInt(8),GW=BigInt(9),dP=BigInt(16);function Tr(e,t){let r=e%t;return r>=Cr?r:t+r}function xn(e,t,r){let i=e;while(t-- >Cr)i*=i,i%=r;return i}function oP(e,t){if(e===Cr)throw Error("invert: expected non-zero number");if(t<=Cr)throw Error("invert: expected positive modulus, got "+t);let r=Tr(e,t),i=t,n=Cr,o=yr,s=yr,a=Cr;while(r!==Cr){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!==yr)throw Error("invert: does not exist");return Tr(n,t)}function hS(e,t,r){if(!e.eql(e.sqr(t),r))throw Error("Cannot find square root")}function fP(e,t){let r=(e.ORDER+yr)/cP,i=e.pow(t,r);return hS(e,i,t),i}function QW(e,t){let r=(e.ORDER-lP)/uP,i=e.mul(t,Ns),n=e.pow(i,r),o=e.mul(t,n),s=e.mul(e.mul(o,Ns),n),a=e.mul(o,e.sub(s,e.ONE));return hS(e,a,t),a}function YW(e){let t=ym(e),r=pP(e),i=r(t,t.neg(t.ONE)),n=r(t,i),o=r(t,t.neg(i)),s=(e+WW)/dP;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 hS(a,b,c),b}}function pP(e){if(e<aP)throw Error("sqrt is not defined for small field");let t=e-yr,r=0;while(t%Ns===Cr)t/=Ns,r++;let i=Ns,n=ym(e);while(sP(n,i)===1)if(i++>1000)throw Error("Cannot find square root: probably non-prime P");if(r===1)return fP;let o=n.pow(i,t),s=(t+yr)/Ns;return function(c,l){if(c.is0(l))return l;if(sP(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=yr<<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 XW(e){if(e%cP===aP)return fP;if(e%uP===lP)return QW;if(e%dP===GW)return YW(e);return pP(e)}var eG=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function gS(e){let t={ORDER:"bigint",BYTES:"number",BITS:"number"},r=eG.reduce((i,n)=>(i[n]="function",i),t);return zs(e,r),e}function tG(e,t,r){if(r<Cr)throw Error("invalid exponent, negatives unsupported");if(r===Cr)return e.ONE;if(r===yr)return t;let i=e.ONE,n=t;while(r>Cr){if(r&yr)i=e.mul(i,n);n=e.sqr(n),r>>=yr}return i}function Ku(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 sP(e,t){let r=(e.ORDER-yr)/Ns,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 rG(e,t){if(t!==void 0)Wt(t);let r=t!==void 0?t:e.toString(2).length,i=Math.ceil(r/8);return{nBitLength:r,nByteLength:i}}class mP{ORDER;BITS;BYTES;isLE;ZERO=Cr;ONE=yr;_lengths;_sqrt;_mod;constructor(e,t={}){if(e<=Cr)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}=rG(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 Tr(e,this.ORDER)}isValid(e){if(typeof e!=="bigint")throw Error("invalid field element: expected bigint, got "+typeof e);return Cr<=e&&e<this.ORDER}is0(e){return e===Cr}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&yr)===yr}neg(e){return Tr(-e,this.ORDER)}eql(e,t){return e===t}sqr(e){return Tr(e*e,this.ORDER)}add(e,t){return Tr(e+t,this.ORDER)}sub(e,t){return Tr(e-t,this.ORDER)}mul(e,t){return Tr(e*t,this.ORDER)}pow(e,t){return tG(this,e,t)}div(e,t){return Tr(e*oP(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 oP(e,this.ORDER)}sqrt(e){if(!this._sqrt)this._sqrt=XW(this.ORDER);return this._sqrt(this,e)}toBytes(e){return this.isLE?Fu(e,this.BYTES):dc(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?vo(e):wo(e);if(s)a=Tr(a,o);if(!t){if(!this.isValid(a))throw Error("invalid field element: outside of range 0..ORDER")}return a}invertBatch(e){return Ku(this,e)}cmov(e,t,r){return r?t:e}}function ym(e,t={}){return new mP(e,t)}function hP(e){if(typeof e!=="bigint")throw Error("field order must be bigint");let t=e.toString(2).length;return Math.ceil(t/8)}function yS(e){let t=hP(e);return t+Math.ceil(t/2)}function gP(e,t,r=!1){Ne(e);let i=e.length,n=hP(t),o=yS(t);if(i<16||i<o||i>1024)throw Error("expected "+o+"-1024 bytes of input, got "+i);let s=r?vo(e):wo(e),a=Tr(s,t-yr)+yr;return r?Fu(a,n):dc(a,n)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var fc=BigInt(0),Ds=BigInt(1);function Ju(e,t){let r=t.negate();return e?r:t}function wS(e,t){let r=Ku(e.Fp,t.map((i)=>i.Z));return t.map((i,n)=>e.fromAffine(i.toAffine(r[n])))}function SP(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw Error("invalid window size, expected [1.."+t+"], got W="+e)}function bS(e,t){SP(e,t);let r=Math.ceil(t/e)+1,i=2**(e-1),n=2**e,o=Hu(e),s=BigInt(e);return{windows:r,windowSize:i,mask:o,maxNumber:n,shiftBy:s}}function yP(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+=Ds;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 xS=new WeakMap,wP=new WeakMap;function SS(e){return wP.get(e)||1}function bP(e){if(e!==fc)throw Error("invalid wNAF")}class vS{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>fc){if(t&Ds)r=r.add(i);i=i.double(),t>>=Ds}return r}precomputeWindow(e,t){let{windows:r,windowSize:i}=bS(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=bS(e,this.bits);for(let s=0;s<o.windows;s++){let{nextN:a,offset:c,isZero:l,isNeg:u,isNegF:d,offsetF:p}=yP(r,s,o);if(r=a,l)n=n.add(Ju(d,t[p]));else i=i.add(Ju(u,t[c]))}return bP(r),{p:i,f:n}}wNAFUnsafe(e,t,r,i=this.ZERO){let n=bS(e,this.bits);for(let o=0;o<n.windows;o++){if(r===fc)break;let{nextN:s,offset:a,isZero:c,isNeg:l}=yP(r,o,n);if(r=s,c)continue;else{let u=t[a];i=i.add(l?u.negate():u)}}return bP(r),i}getPrecomputes(e,t,r){let i=xS.get(t);if(!i){if(i=this.precomputeWindow(t,e),e!==1){if(typeof r==="function")i=r(i);xS.set(t,i)}}return i}cached(e,t,r){let i=SS(e);return this.wNAF(i,this.getPrecomputes(i,e,r),t)}unsafe(e,t,r,i){let n=SS(e);if(n===1)return this._unsafeLadder(e,t,i);return this.wNAFUnsafe(n,this.getPrecomputes(n,e,r),t,i)}createCache(e,t){SP(t,this.bits),wP.set(e,t),xS.delete(e)}hasCache(e){return SS(e)!==1}}function vP(e,t,r,i){let n=t,o=e.ZERO,s=e.ZERO;while(r>fc||i>fc){if(r&Ds)o=o.add(n);if(i&Ds)s=s.add(n);n=n.double(),r>>=Ds,i>>=Ds}return{p1:o,p2:s}}function xP(e,t,r){if(t){if(t.ORDER!==e)throw Error("Field.ORDER must match order: Fp == p, Fn == n");return gS(t),t}else return ym(e,{isLE:r})}function _P(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>fc))throw Error(`CURVE.${c} must be positive bigint`)}let n=xP(t.p,r.Fp,i),o=xP(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 bm(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 Vu=BigInt(0),pc=BigInt(1),xm=BigInt(2);function nG(e){return zs(e,{adjustScalarBytes:"function",powPminus2:"function"}),Object.freeze({...e})}function kP(e){let t=nG(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||xo,l=a?255:448,u=a?32:56,d=a?BigInt(9):BigInt(5),p=a?BigInt(121665):BigInt(39081),m=a?xm**BigInt(254):xm**BigInt(447),y=a?BigInt(8)*xm**BigInt(251)-pc:BigInt(4)*xm**BigInt(445)-pc,g=m+y+pc,b=(I)=>Tr(I,r),v=A(d);function A(I){return Fu(b(I),u)}function T(I){let R=gm(Ne(I,u,"uCoordinate"));if(a)R[31]&=127;return b(vo(R))}function z(I){return vo(n(gm(Ne(I,u,"scalar"))))}function j(I,R){let O=X(T(R),z(I));if(O===Vu)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){Zu("u",I,Vu,r),Zu("scalar",R,m,g);let O=R,F=I,L=pc,V=Vu,_=I,te=pc,ue=Vu;for(let Se=BigInt(l-1);Se>=Vu;Se--){let Ee=O>>Se&pc;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,Dt=b(St*$e),hr=b(Xe*_e),Yr=Dt+hr,Xr=Dt-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:bm(P,Z),getSharedSecret:D,getPublicKey:Z,scalarMult:j,scalarMultBase:E,utils:N,GuBytes:v.slice(),lengths:M})}class _S{oHash;iHash;blockLen;outputLen;finished=!1;destroyed=!1;constructor(e,t){if(bn(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),Mr(i)}update(e){return Pi(this),this.iHash.update(e),this}digestInto(e){Pi(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 mc=(e,t,r)=>new _S(e,t).update(r).digest();mc.create=(e,t)=>new _S(e,t);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var EP=(e,t)=>(e+(e>=0?t:-t)/AP)/t;function iG(e,t,r){let[[i,n],[o,s]]=t,a=EP(s*e,r),c=EP(-n*e,r),l=e-a*i-c*o,u=-a*n-c*s,d=l<zi,p=u<zi;if(d)l=-l;if(p)u=-u;let m=Hu(Math.ceil(pS(r)/2))+hc;if(l<zi||l>=m||u<zi||u>=m)throw Error("splitScalar (endomorphism): failed, k="+e);return{k1neg:d,k1:l,k2neg:p,k2:u}}function ES(e){if(!["compact","recovered","der"].includes(e))throw Error('Signature format must be "compact", "recovered", or "der"');return e}function kS(e,t){let r={};for(let i of Object.keys(t))r[i]=e[i]===void 0?t[i]:e[i];if(Uu(r.lowS,"lowS"),Uu(r.prehash,"prehash"),r.format!==void 0)ES(r.format);return r}class IP extends Error{constructor(e=""){super(e)}}var ko={Err:IP,_tlv:{encode:(e,t)=>{let{Err:r}=ko;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=Mu(i);if(n.length/2&128)throw new r("tlv.encode: long form length too big");let o=i>127?Mu(n.length/2|128):"";return Mu(e)+o+n+t},decode(e,t){let{Err:r}=ko,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}=ko;if(e<zi)throw new t("integer: negative integers are not allowed");let r=Mu(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}=ko;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 wo(e)}},toSig(e){let{Err:t,_int:r,_tlv:i}=ko,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}=ko,i=t.encode(2,r.encode(e.r)),n=t.encode(2,r.encode(e.s)),o=i+n;return t.encode(48,o)}},zi=BigInt(0),hc=BigInt(1),AP=BigInt(2),Sm=BigInt(3),oG=BigInt(4);function IS(e,t={}){let r=_P("weierstrass",e,t),{Fp:i,Fn:n}=r,o=r.CURVE,{h:s,n:a}=o;zs(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=CP(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(Uu(I,"isCompressed"),I){u();let L=!i.isOdd(O);return Lt(TP(L),F)}else return Lt(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,Sm),oG),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 iG(P,c.basises,n.ORDER)}let E=mS((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=mS((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=Ju(R,N),I=Ju(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(Ps(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(Sm);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,Sm),{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,Sm),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)=>wS(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 wS(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===zi||I.is0())return H.ZERO;if(P===hc)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:_}=vP(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===hc)return!0;if(P)return P(H,this);return M.unsafe(this,a).is0()}clearCofactor(){let{clearCofactor:P}=t;if(s===hc)return this;if(P)return P(H,this);return this.multiplyUnsafe(s)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}toBytes(P=!0){return Uu(P,"isCompressed"),this.assertValidity(),m(H,this,P)}toHex(P=!0){return Rs(this.toBytes(P))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let X=n.BITS,M=new vS(H,t.endo?Math.ceil(X/2):X);return H.BASE.precompute(8),H}function TP(e){return Uint8Array.of(e?2:3)}function CP(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function sG(e,t={}){let{Fn:r}=e,i=t.randomBytes||xo,n=Object.assign(CP(e.Fp,r),{seed:yS(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 gP(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(!lc(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=bm(a,c);return Object.freeze({getPublicKey:c,getSharedSecret:u,keygen:p,Point:e,utils:d,lengths:n})}function AS(e,t,r={}){bn(t),zs(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),r=Object.assign({},r);let i=r.randomBytes||xo,n=r.hmac||((I,R)=>mc(t,I,R)),{Fp:o,Fn:s}=e,{ORDER:a,BITS:c}=s,{keygen:l,getPublicKey:u,getSharedSecret:d,utils:p,lengths:m}=sG(e,r),y={prehash:!0,lowS:typeof r.lowS==="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},g=a*AP<o.ORDER;function b(I){let R=a>>hc;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){ES(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}=ko.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(Ps(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(Lt(TP((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(ES(I),I==="der")return Ps(ko.hexFromSig(this));let{r:R,s:O}=this,F=s.toBytes(R),L=s.toBytes(O);if(I==="recovered")return A(),Lt(Uint8Array.of(this.assertRecovery()),F,L);return Lt(F,L)}toHex(I){return Rs(this.toBytes(I))}}let j=r.bits2int||function(R){if(R.length>8192)throw Error("input is too large");let O=wo(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=Hu(c);function D(I){return Zu("num < 2^"+c,I,zi,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}=kS(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=Lt(...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===zi)return;let Xe=s.create(_e*s.create(Se+Ve*te));if(Xe===zi)return;let St=(ze.x===Ve?0:2)|Number(ze.y&hc),Dt=Xe;if(F&&b(Xe))Dt=s.neg(Xe),St^=1;return new z(Ve,Dt,g?void 0:St)}return{seed:C,k2sig:Ee}}function M(I,R,O={}){let{seed:F,k2sig:L}=X(I,R,O);return iP(t.outputLen,s.BYTES,n)(F,L).toBytes(O.format)}function P(I,R,O,F={}){let{lowS:L,prehash:V,format:_}=kS(F,y);if(O=Ne(O,void 0,"publicKey"),R=H(R,V),!lc(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}=kS(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 $P(e,t,r){return e&t^~e&r}function OP(e,t,r){return e&t^e&r^t&r}class wm{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=mm(this.buffer)}update(e){Pi(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=mm(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){Pi(this),fm(e,this),this.finished=!0;let{buffer:t,view:r,blockLen:i,isLE:n}=this,{pos:o}=this;if(t[o++]=128,Mr(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=mm(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 Ni=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var or=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]);var vm=BigInt(4294967295),RP=BigInt(32);function aG(e,t=!1){if(t)return{h:Number(e&vm),l:Number(e>>RP&vm)};return{h:Number(e>>RP&vm)|0,l:Number(e&vm)|0}}function _m(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}=aG(e[o],t);[i[o],n[o]]=[s,a]}return[i,n]}var TS=(e,t,r)=>e>>>r,CS=(e,t,r)=>e<<32-r|t>>>r,Ls=(e,t,r)=>e>>>r|t<<32-r,Bs=(e,t,r)=>e<<32-r|t>>>r,Wu=(e,t,r)=>e<<64-r|t>>>r-32,Gu=(e,t,r)=>e>>>r-32|t<<64-r;var PP=(e,t,r)=>e<<r|t>>>32-r,zP=(e,t,r)=>t<<r|e>>>32-r,NP=(e,t,r)=>t<<r-32|e>>>64-r,DP=(e,t,r)=>e<<r-32|t>>>64-r;function ri(e,t,r,i){let n=(t>>>0)+(i>>>0);return{h:e+r+(n/4294967296|0)|0,l:n|0}}var LP=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),BP=(e,t,r,i)=>t+r+i+(e/4294967296|0)|0,jP=(e,t,r,i)=>(e>>>0)+(t>>>0)+(r>>>0)+(i>>>0),qP=(e,t,r,i,n)=>t+r+i+n+(e/4294967296|0)|0,UP=(e,t,r,i,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(i>>>0)+(n>>>0),MP=(e,t,r,i,n,o)=>t+r+i+n+o+(e/4294967296|0)|0;var lG=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]),Eo=new Uint32Array(64);class FP extends wm{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)Eo[u]=e.getUint32(t,!1);for(let u=16;u<64;u++){let d=Eo[u-15],p=Eo[u-2],m=Nn(d,7)^Nn(d,18)^d>>>3,y=Nn(p,17)^Nn(p,19)^p>>>10;Eo[u]=y+Eo[u-7]+m+Eo[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=Nn(s,6)^Nn(s,11)^Nn(s,25),p=l+d+$P(s,a,c)+lG[u]+Eo[u]|0,y=(Nn(r,2)^Nn(r,13)^Nn(r,22))+OP(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(){Mr(Eo)}destroy(){this.set(0,0,0,0,0,0,0,0),Mr(this.buffer)}}class ZP extends FP{A=Ni[0]|0;B=Ni[1]|0;C=Ni[2]|0;D=Ni[3]|0;E=Ni[4]|0;F=Ni[5]|0;G=Ni[6]|0;H=Ni[7]|0;constructor(){super(32)}}var HP=(()=>_m(["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))))(),uG=(()=>HP[0])(),dG=(()=>HP[1])(),Io=new Uint32Array(80),Ao=new Uint32Array(80);class KP extends wm{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)Io[A]=e.getUint32(t),Ao[A]=e.getUint32(t+=4);for(let A=16;A<80;A++){let T=Io[A-15]|0,z=Ao[A-15]|0,j=Ls(T,z,1)^Ls(T,z,8)^TS(T,z,7),E=Bs(T,z,1)^Bs(T,z,8)^CS(T,z,7),Z=Io[A-2]|0,D=Ao[A-2]|0,H=Ls(Z,D,19)^Wu(Z,D,61)^TS(Z,D,6),X=Bs(Z,D,19)^Gu(Z,D,61)^CS(Z,D,6),M=jP(E,X,Ao[A-7],Ao[A-16]),P=qP(M,j,H,Io[A-7],Io[A-16]);Io[A]=P|0,Ao[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=Ls(u,d,14)^Ls(u,d,18)^Wu(u,d,41),z=Bs(u,d,14)^Bs(u,d,18)^Gu(u,d,41),j=u&p^~u&y,E=d&m^~d&g,Z=UP(v,z,E,dG[A],Ao[A]),D=MP(Z,b,T,j,uG[A],Io[A]),H=Z|0,X=Ls(r,i,28)^Wu(r,i,34)^Wu(r,i,39),M=Bs(r,i,28)^Gu(r,i,34)^Gu(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}=ri(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=LP(H,M,N);r=BP(I,D,X,P),i=I|0}({h:r,l:i}=ri(this.Ah|0,this.Al|0,r|0,i|0)),{h:n,l:o}=ri(this.Bh|0,this.Bl|0,n|0,o|0),{h:s,l:a}=ri(this.Ch|0,this.Cl|0,s|0,a|0),{h:c,l}=ri(this.Dh|0,this.Dl|0,c|0,l|0),{h:u,l:d}=ri(this.Eh|0,this.El|0,u|0,d|0),{h:p,l:m}=ri(this.Fh|0,this.Fl|0,p|0,m|0),{h:y,l:g}=ri(this.Gh|0,this.Gl|0,y|0,g|0),{h:b,l:v}=ri(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(){Mr(Io,Ao)}destroy(){Mr(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class JP extends KP{Ah=or[0]|0;Al=or[1]|0;Bh=or[2]|0;Bl=or[3]|0;Ch=or[4]|0;Cl=or[5]|0;Dh=or[6]|0;Dl=or[7]|0;Eh=or[8]|0;El=or[9]|0;Fh=or[10]|0;Fl=or[11]|0;Gh=or[12]|0;Gl=or[13]|0;Hh=or[14]|0;Hl=or[15]|0;constructor(){super(48)}}var km=uc(()=>new ZP,So(1));var VP=uc(()=>new JP,So(2));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var fG=BigInt(1),WP=BigInt(2),pG=BigInt(3),mG=BigInt(5),H1e=BigInt(8),GP=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed");function hG(e){let t=BigInt(10),r=BigInt(20),i=BigInt(40),n=BigInt(80),o=GP,a=e*e%o*e%o,c=xn(a,WP,o)*a%o,l=xn(c,fG,o)*e%o,u=xn(l,mG,o)*l%o,d=xn(u,t,o)*u%o,p=xn(d,r,o)*d%o,m=xn(p,i,o)*p%o,y=xn(m,n,o)*m%o,g=xn(y,n,o)*m%o,b=xn(g,t,o)*u%o;return{pow_p_5_8:xn(b,WP,o)*e%o,b2:a}}function gG(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var QP=(()=>{let e=GP;return kP({P:e,type:"x25519",powPminus2:(t)=>{let{pow_p_5_8:r,b2:i}=hG(t);return Tr(xn(r,pG,e)*i,e)},adjustScalarBytes:gG})})();/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var yG=(()=>({p:BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),h:BigInt(1),a:BigInt("0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc"),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")}))(),bG=(()=>({p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff"),n:BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973"),h:BigInt(1),a:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000fffffffc"),b:BigInt("0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef"),Gx:BigInt("0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7"),Gy:BigInt("0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f")}))();var xG=IS(yG),$S=AS(xG,km);var SG=IS(bG),YP=AS(SG,VP);function ez(e,t,r){if(bn(e),r===void 0)r=new Uint8Array(e.outputLen);return mc(e,r,t)}var OS=Uint8Array.of(0),XP=Uint8Array.of();function tz(e,t,r,i=32){bn(e),Wt(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=XP;else Ne(r,void 0,"info");let s=new Uint8Array(o*n),a=mc.create(e,t),c=a._cloneInto(),l=new Uint8Array(a.outputLen);for(let u=0;u<o;u++)OS[0]=u+1,c.update(u===0?XP:l).update(r).update(OS).digestInto(l),s.set(l,n*u),a._cloneInto(c);return a.destroy(),c.destroy(),Mr(l,OS),s.slice(0,i)}var wG=BigInt(0),Qu=BigInt(1),vG=BigInt(2),_G=BigInt(7),kG=BigInt(256),EG=BigInt(113),iz=[],oz=[],sz=[];for(let e=0,t=Qu,r=1,i=0;e<24;e++){[r,i]=[i,(2*r+3*i)%5],iz.push(2*(5*i+r)),oz.push((e+1)*(e+2)/2%64);let n=wG;for(let o=0;o<7;o++)if(t=(t<<Qu^(t>>_G)*EG)%kG,t&vG)n^=Qu<<(Qu<<BigInt(o))-Qu;sz.push(n)}var az=_m(sz,!0),IG=az[0],AG=az[1],rz=(e,t,r)=>r>32?NP(e,t,r):PP(e,t,r),nz=(e,t,r)=>r>32?DP(e,t,r):zP(e,t,r);function TG(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=rz(l,u,1)^r[a],p=nz(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=oz[s],c=rz(n,o,a),l=nz(n,o,a),u=iz[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]^=IG[i],e[1]^=AG[i]}Mr(r)}class Em{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,Wt(r,"outputLen"),!(0<e&&e<200))throw Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=pm(this.state)}clone(){return this._cloneInto()}keccak(){uS(this.state32),TG(this.state32,this.rounds),uS(this.state32),this.posOut=0,this.pos=0}update(e){Pi(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){Pi(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 Wt(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(fm(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,Mr(this.state)}_cloneInto(e){let{blockLen:t,suffix:r,outputLen:i,rounds:n,enableXOF:o}=this;return e||=new Em(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 cz=(e,t,r,i={})=>uc(()=>new Em(t,e,r),i);var js=cz(6,136,32,So(8));var lz=cz(6,72,64,So(10));var uz=(e,t,r,i={})=>uc((n={})=>new Em(t,e,n.dkLen===void 0?r:n.dkLen,!0),i),dz=uz(31,168,16,So(11)),ni=uz(31,136,32,So(12));function RS(e){if(!Number.isSafeInteger(e)||e<0||e>4294967295)throw Error("wrong u32 integer:"+e);return e}function pz(e){return RS(e),(e&e-1)===0&&e!==0}function PS(e,t){RS(e);let r=0;for(let i=0;i<t;i++,e>>>=1)r=r<<1|e&1;return r}function mz(e){return RS(e),31-Math.clz32(e)}function fz(e){let t=e.length;if(t<2||!pz(t))throw Error("n must be a power of 2 and greater than 1. Got "+t);let r=mz(t);for(let i=0;i<t;i++){let n=PS(i,r);if(i<n){let o=e[i];e[i]=e[n],e[n]=o}}return e}var zS=(e,t)=>{let{N:r,roots:i,dit:n,invertButterflies:o=!1,skipStages:s=0,brp:a=!0}=t,c=mz(r);if(!pz(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)fz(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)fz(u);return u}};/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */var ii=xo;function Im(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 hz(e){return Uint8Array.from(e)}function qs(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 Am(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 Ft(...e){for(let t of e)if(Array.isArray(t))for(let r of t)r.fill(0);else t.fill(0)}function NS(e){return(1<<e)-1}var sIe=Uint8Array.of();/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */var gz=(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=PS(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=zS(p,{dit:!1,...m}),g=zS(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=NS(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&NS(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}}}}},CG=(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(),Ft(o,i)}}},yz=CG(dz);/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */var br=256,Di=3329,$G=3303,OG=17,{mod:ed,nttZetas:RG,NTT:Us,bitsCoder:PG}=gz({N:br,Q:Di,F:$G,ROOT_OF_UNITY:OG,newPoly:(e)=>new Uint16Array(e),brvBits:7,isKyber:!0}),DS={512:{N:br,Q:Di,K:2,ETA1:3,ETA2:2,du:10,dv:4,RBGstrength:128},768:{N:br,Q:Di,K:3,ETA1:2,ETA2:2,du:10,dv:4,RBGstrength:192},1024:{N:br,Q:Di,K:4,ETA1:2,ETA2:2,du:11,dv:5,RBGstrength:256}},zG=(e)=>{if(e>=12)return{encode:(r)=>r,decode:(r)=>r};let t=2**(e-1);return{encode:(r)=>((r<<e)+Di/2)/Di,decode:(r)=>r*Di+t>>>e}},Yu=(e)=>PG(e,zG(e));function Ms(e,t){for(let r=0;r<br;r++)e[r]=ed(e[r]+t[r])}function NG(e,t){for(let r=0;r<br;r++)e[r]=ed(e[r]-t[r])}function DG(e,t,r,i,n){let o=ed(t*i*n+e*r),s=ed(e*i+t*r);return{c0:o,c1:s}}function Tm(e,t){for(let r=0;r<br/2;r++){let i=RG[64+(r>>1)];if(r&1)i=-i;let{c0:n,c1:o}=DG(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 bz(e){let t=new Uint16Array(br);for(let r=0;r<br;){let i=e();if(i.length%3)throw Error("SampleNTT: unaligned block");for(let n=0;r<br&&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<Di)t[r++]=o;if(r<br&&s<Di)t[r++]=s}}return t}function Xu(e,t,r,i){let n=e(i*br/4,t,r),o=new Uint16Array(br),s=pm(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++]=ed(d-u),u=0,a=0}if(a)throw Error(`sampleCBD: leftover bits: ${a}`);return o}var LG=(e)=>{let{K:t,PRF:r,XOF:i,HASH512:n,ETA1:o,ETA2:s,du:a,dv:c}=e,l=Yu(1),u=Yu(c),d=Yu(a),p=qs("publicKey",Am(Yu(12),t),32),m=Am(Yu(12),t),y=qs("ciphertext",Am(d,t),u),g=qs("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(Us.encode(Xu(r,z,H,o)));let Z=i(T);for(let H=0;H<t;H++){let X=Us.encode(Xu(r,z,t+H,o));for(let M=0;M<t;M++){let P=bz(Z.get(M,H));Ms(X,Tm(P,j[M]))}E.push(X)}Z.clean();let D={publicKey:p.encode([E,T]),secretKey:m.encode(j)};return Ft(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(Us.encode(Xu(r,A,M,o)));let E=i(z),Z=new Uint16Array(br),D=[];for(let M=0;M<t;M++){let P=Xu(r,A,t+M,s),N=new Uint16Array(br);for(let I=0;I<t;I++){let R=bz(E.get(M,I));Ms(N,Tm(R,j[I]))}Ms(P,Us.decode(N)),D.push(P),Ms(Z,Tm(T[M],j[M])),Ft(N)}E.clean();let H=Xu(r,A,2*t,s);Ms(H,Us.decode(Z));let X=l.decode(v);return Ms(X,H),Ft(T,j,Z,H),y.encode([D,X])},decrypt:(b,v)=>{let[A,T]=y.decode(b),z=m.decode(v),j=new Uint16Array(br);for(let E=0;E<t;E++)Ms(j,Tm(z[E],Us.encode(A[E])));return NG(T,Us.decode(j)),Ft(j,z,A),l.encode(T)}}};function LS(e){let t=LG(e),{HASH256:r,HASH512:i,KDF:n}=e,{secretCoder:o,lengths:s}=t,a=qs("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=ii(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 Ft(p,m),{publicKey:d,secretKey:y}},getPublicKey:(u)=>{let[d,p,m,y]=a.decode(u);return Uint8Array.from(p)},encapsulate:(u,d=ii(32))=>{Ne(u,s.publicKey,"publicKey"),Ne(d,32,"message");let p=u.subarray(0,384*e.K),m=o.encode(o.decode(hz(p)));if(!Im(m,p))throw Ft(m),Error("ML-KEM.encapsulate: wrong publicKey modulus");Ft(m);let y=i.create().update(d).update(r(u)).digest(),g=t.encrypt(u,d,y.subarray(32,64));return Ft(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(!Im(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=Im(u,E),D=n.create({dkLen:32}).update(A).update(u).digest();return Ft(T,E,!Z?j:D),Z?j:D}}}function BG(e,t,r){return ni.create({dkLen:e}).update(t).update(new Uint8Array([r])).digest()}var BS={HASH256:js,HASH512:lz,KDF:ni,XOF:yz,PRF:BG},yIe=LS({...BS,...DS[512]}),td=LS({...BS,...DS[768]}),xz=LS({...BS,...DS[1024]});/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */function jG(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=ii(r.seed))=>{Ne(s,r.seed,"seed");let a=o.isLE?vo(s):wo(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 jS(e,t=!1){let r=jG(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=ii(e.lengths.seed)){let o=this.keygen(n).secretKey,s=this.decapsulate(i,o),a=e.getPublicKey(o);return Ft(o),{sharedSecret:s,cipherText:a}},decapsulate(i,n){let o=e.getSharedSecret(n,i);return e.lengths.publicKeyHasPrefix?o.subarray(1):o}}}function rd(e,t){return qs(t,...e.map((r)=>{if(typeof r.lengths[t]!=="number")throw Error("wrong length: "+t);return r.lengths[t]}))}function qS(e){return(t,r)=>e(t,{dkLen:r})}function qG(e,t,...r){let i=rd(r,"seed"),n=rd(r,"publicKey");if(e===void 0)e=i.bytesLen;Wt(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=ii(e)){let{publicKey:a,secretKey:c}=o(s),l=n.encode(a);return Ft(a),Ft(c),{secretKey:s,publicKey:l}},expandDecapsulationKey:o,realSeedLen:e}}function Cm(e,t,r,i,...n){let o=qG(e,r,...n),s=rd(n,"cipherText"),a=rd(n,"publicKey"),c=rd(n,"msg");if(t===void 0)t=c.bytesLen;return Wt(t),{lengths:{...o.info.lengths,msg:t,msgRand:c.bytesLen,cipherText:s.bytesLen},getPublicKey:o.getPublicKey,keygen:o.keygen,encapsulate(l,u=ii(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 Ft(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 Sz(e,t,r,i,n){return bn(i),bn(n),Cm(32,32,qS(i),(o,s,a)=>n(Lt(a[0],a[1],s[1],o[1],_o(e))),t,r)}var TIe=Sz("QSF-KEM(ML-KEM-768,P-256)-XOF(SHAKE256)-KDF(SHA3-256)",td,jS($S,!0),ni,js),CIe=Sz("QSF-KEM(ML-KEM-1024,P-384)-XOF(SHAKE256)-KDF(SHA3-256)",xz,jS(YP,!0),ni,js);function UG(e,t,r,i,n){return bn(i),bn(n),Cm(32,32,qS(i),(o,s,a)=>{let c=Lt(a[0],a[1],s[0],o[0],s[1],o[1],_o(e)),l=32,u=Lt(_o("hybrid_prk"),c),d=ez(n,u),p=Lt(dc(32,2),_o("shared_secret"),_o("")),m=tz(n,d,p,32);return Ft(d,p,u,c),m},t,r)}var wz=jS(QP),$Ie=UG("KitchenSink-KEM(ML-KEM-768,X25519)-XOF(SHAKE256)-KDF(HKDF-SHA-256)",td,wz,ni,km),MG=(()=>Cm(32,32,qS(ni),(e,t,r)=>js(Lt(r[0],r[1],t[1],e[1],_o("\\.//^\\"))),td,wz))();function FG(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=ii(i)){return Ne(s,i,"seed"),o(s)},getPublicKey(s){return e.getPublicKey(s,!1)},encapsulate(s,a=ii(i)){Ne(a,i,"rand");let{secretKey:c}=o(a),l=this.decapsulate(s,c),u=e.getPublicKey(c,!1);return Ft(c),{sharedSecret:l,cipherText:u}},decapsulate(s,a){return e.getSharedSecret(a,s).subarray(1)}}}function ZG(e,t,r,i){let{secretKey:n,publicKeyUncompressed:o}=r.lengths;if(!n||!o)throw Error("wrong curve");let s=FG(r,n,o,i),a=64,c=a+i;return Cm(32,32,(l)=>{Ne(l,32);let u=ni(l,{dkLen:c}),d=u.subarray(0,a),p=u.subarray(a,c);return Lt(d,p)},(l,u,d)=>js(Lt(d[0],d[1],u[1],l[1],_o(e))),t,s)}var HG=(()=>ZG("MLKEM768-P256",td,$S,128))();var $m=MG,vz=HG;/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var ct=(e,t,r)=>rr(e,t,r),MS=Ct,gc=em,sr=(...e)=>Hx(...e),yc=(e)=>Pu(e),bc=Mx,xc=(e)=>Ci(e),Rm=BigInt(0),US=BigInt(1);function Li(e,t=""){if(typeof e!=="boolean"){let r=t&&`"${t}" `;throw TypeError(r+"expected boolean, got type="+typeof e)}return e}function Pm(e){if(typeof e==="bigint"){if(!Om(e))throw RangeError("positive bigint expected, got "+e)}else MS(e);return e}function oi(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 nd(e){let t=Pm(e).toString(16);return t.length&1?"0"+t:t}function _z(e){if(typeof e!=="string")throw TypeError("hex string expected, got "+typeof e);return e===""?Rm:BigInt("0x"+e)}function Fs(e){return _z(em(e))}function Dn(e){return _z(em(To(rr(e)).reverse()))}function zm(e,t){if(Ct(t),t===0)throw RangeError("zero length");e=Pm(e);let r=e.toString(16);if(r.length>t*2)throw RangeError("number too large");return Pu(r.padStart(t*2,"0"))}function id(e,t){return zm(e,t).reverse()}function kz(e,t){if(e=ct(e),t=ct(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 To(e){return Uint8Array.from(ct(e))}function Nm(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 Om=(e)=>typeof e==="bigint"&&Rm<=e;function KG(e,t,r){return Om(e)&&Om(t)&&Om(r)&&t<=e&&e<r}function Bi(e,t,r,i){if(!KG(t,r,i))throw RangeError("expected valid "+e+": "+r+" <= n < "+i+", got "+t)}function Sc(e){if(e<Rm)throw Error("expected non-negative bigint, got "+e);let t;for(t=0;e>Rm;e>>=US,t+=1);return t}var od=(e)=>(US<<BigInt(e))-US;function Ez(e,t,r){if(Ct(e,"hashLen"),Ct(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,sr(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 sr(...v)};return(b,v)=>{d(),m(b);let A=void 0;while((A=v(y()))===void 0)m();return d(),A}}function Sn(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 FS=()=>{throw Error("not implemented")};/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var ar=BigInt(0),kt=BigInt(1),Zs=BigInt(2),Cz=BigInt(3),$z=BigInt(4),Oz=BigInt(5),JG=BigInt(7),Rz=BigInt(8),VG=BigInt(9),Pz=BigInt(16);function gt(e,t){if(t<=ar)throw Error("mod: expected positive modulus, got "+t);let r=e%t;return r>=ar?r:t+r}function wn(e,t,r){if(t<ar)throw Error("pow2: expected non-negative exponent, got "+t);let i=e;while(t-- >ar)i*=i,i%=r;return i}function Iz(e,t){if(e===ar)throw Error("invert: expected non-zero number");if(t<=ar)throw Error("invert: expected positive modulus, got "+t);let r=gt(e,t),i=t,n=ar,o=kt,s=kt,a=ar;while(r!==ar){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!==kt)throw Error("invert: does not exist");return gt(n,t)}function ZS(e,t,r){let i=e;if(!i.eql(i.sqr(t),r))throw Error("Cannot find square root")}function zz(e,t){let r=e,i=(r.ORDER+kt)/$z,n=r.pow(t,i);return ZS(r,n,t),n}function WG(e,t){let r=e,i=(r.ORDER-Oz)/Rz,n=r.mul(t,Zs),o=r.pow(n,i),s=r.mul(t,o),a=r.mul(r.mul(s,Zs),o),c=r.mul(s,r.sub(a,r.ONE));return ZS(r,c,t),c}function GG(e){let t=Dm(e),r=Nz(e),i=r(t,t.neg(t.ONE)),n=r(t,i),o=r(t,t.neg(i)),s=(e+JG)/Pz;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 ZS(l,v,c),v}}function Nz(e){if(e<Cz)throw Error("sqrt is not defined for small field");let t=e-kt,r=0;while(t%Zs===ar)t/=Zs,r++;let i=Zs,n=Dm(e);while(Az(n,i)===1)if(i++>1000)throw Error("Cannot find square root: probably non-prime P");if(r===1)return zz;let o=n.pow(i,t),s=(t+kt)/Zs;return function(c,l){let u=c;if(u.is0(l))return l;if(Az(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=kt<<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 QG(e){if(e%$z===Cz)return zz;if(e%Rz===Oz)return WG;if(e%Pz===VG)return GG(e);return Nz(e)}var ji=(e,t)=>(gt(e,t)&kt)===kt,YG=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function HS(e){let t={ORDER:"bigint",BYTES:"number",BITS:"number"},r=YG.reduce((i,n)=>(i[n]="function",i),t);if(Sn(e,r),oi(e.BYTES,"BYTES"),oi(e.BITS,"BITS"),e.BYTES<1||e.BITS<1)throw Error("invalid field: expected BYTES/BITS > 0");if(e.ORDER<=kt)throw Error("invalid field: expected ORDER > 1, got "+e.ORDER);return e}function XG(e,t,r){let i=e;if(r<ar)throw Error("invalid exponent, negatives unsupported");if(r===ar)return i.ONE;if(r===kt)return t;let n=i.ONE,o=t;while(r>ar){if(r&kt)n=i.mul(n,o);o=i.sqr(o),r>>=kt}return n}function sd(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 Az(e,t){let r=e,i=(r.ORDER-kt)/Zs,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 eQ(e,t){if(t!==void 0)MS(t);if(e<=ar)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=Sc(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 Tz=new WeakMap;class KS{ORDER;BITS;BYTES;isLE;ZERO=ar;ONE=kt;_lengths;_mod;constructor(e,t={}){if(e<=kt)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}=eQ(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 ar<=e&&e<this.ORDER}is0(e){return e===ar}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&kt)===kt}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 XG(this,e,t)}div(e,t){return gt(e*Iz(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 Iz(e,this.ORDER)}sqrt(e){let t=Tz.get(this);if(!t)Tz.set(this,t=QG(this.ORDER));return t(this,e)}toBytes(e){return this.isLE?id(e,this.BYTES):zm(e,this.BYTES)}fromBytes(e,t=!1){ct(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?Dn(e):Fs(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 sd(this,e)}cmov(e,t,r){return Li(r,"condition"),r?t:e}}Object.freeze(KS.prototype);function Dm(e,t={}){return new KS(e,t)}function Dz(e){if(typeof e!=="bigint")throw Error("field order must be bigint");if(e<=kt)throw Error("field order must be greater than 1");let t=Sc(e-kt);return Math.ceil(t/8)}function JS(e){let t=Dz(e);return t+Math.ceil(t/2)}function Lz(e,t,r=!1){ct(e);let i=e.length,n=Dz(t),o=Math.max(JS(t),16);if(i<o||i>1024)throw Error("expected "+o+"-1024 bytes of input, got "+i);let s=r?Dn(e):Fs(e),a=gt(s,t-kt)+kt;return r?id(a,n):zm(a,n)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var wc=BigInt(0),Hs=BigInt(1);function ad(e,t){let r=t.negate();return e?r:t}function Ks(e,t){let r=sd(e.Fp,t.map((i)=>i.Z));return t.map((i,n)=>e.fromAffine(i.toAffine(r[n])))}function Uz(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw Error("invalid window size, expected [1.."+t+"], got W="+e)}function VS(e,t){Uz(e,t);let r=Math.ceil(t/e)+1,i=2**(e-1),n=2**e,o=od(e),s=BigInt(e);return{windows:r,windowSize:i,mask:o,maxNumber:n,shiftBy:s}}function Bz(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+=Hs;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 WS=new WeakMap,Mz=new WeakMap;function GS(e){return Mz.get(e)||1}function jz(e){if(e!==wc)throw Error("invalid wNAF")}class cd{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>wc){if(t&Hs)r=r.add(i);i=i.double(),t>>=Hs}return r}precomputeWindow(e,t){let{windows:r,windowSize:i}=VS(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=VS(e,this.bits);for(let s=0;s<o.windows;s++){let{nextN:a,offset:c,isZero:l,isNeg:u,isNegF:d,offsetF:p}=Bz(r,s,o);if(r=a,l)n=n.add(ad(d,t[p]));else i=i.add(ad(u,t[c]))}return jz(r),{p:i,f:n}}wNAFUnsafe(e,t,r,i=this.ZERO){let n=VS(e,this.bits);for(let o=0;o<n.windows;o++){if(r===wc)break;let{nextN:s,offset:a,isZero:c,isNeg:l}=Bz(r,o,n);if(r=s,c)continue;else{let u=t[a];i=i.add(l?u.negate():u)}}return jz(r),i}getPrecomputes(e,t,r){let i=WS.get(t);if(!i){if(i=this.precomputeWindow(t,e),e!==1){if(typeof r==="function")i=r(i);WS.set(t,i)}}return i}cached(e,t,r){let i=GS(e);return this.wNAF(i,this.getPrecomputes(i,e,r),t)}unsafe(e,t,r,i){let n=GS(e);if(n===1)return this._unsafeLadder(e,t,i);return this.wNAFUnsafe(n,this.getPrecomputes(n,e,r),t,i)}createCache(e,t){Uz(t,this.bits),Mz.set(e,t),WS.delete(e)}hasCache(e){return GS(e)!==1}}function Fz(e,t,r,i){let n=t,o=e.ZERO,s=e.ZERO;while(r>wc||i>wc){if(r&Hs)o=o.add(n);if(i&Hs)s=s.add(n);n=n.double(),r>>=Hs,i>>=Hs}return{p1:o,p2:s}}function qz(e,t,r){if(t){if(t.ORDER!==e)throw Error("Field.ORDER must match order: Fp == p, Fn == n");return HS(t),t}else return Dm(e,{isLE:r})}function Lm(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>wc))throw Error(`CURVE.${c} must be positive bigint`)}let n=qz(t.p,r.Fp,i),o=qz(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 ld(e,t){return function(i){let n=e(i);return{secretKey:n,publicKey:t(n)}}}function ud(e,t){if(oi(e),oi(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 tQ(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 rQ(e){if(!bc(e)&&typeof e!=="string")throw Error("DST must be Uint8Array or ascii string");let t=typeof e==="string"?Nm(e):e;if(t.length===0)throw Error("DST must be non-empty");return t}function QS(e,t,r,i){if(ct(e),oi(r),t=rQ(t),t.length>255)t=i(sr(Nm("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=sr(t,ud(t.length,1)),c=new Uint8Array(o),l=ud(r,2),u=Array(s),d=i(sr(c,e,l,ud(0,1),a));u[0]=i(sr(d,ud(1,1),a));for(let m=1;m<s;m++){let y=[tQ(d,u[m-1]),ud(m+1,1),a];u[m]=i(sr(...y))}return sr(...u).slice(0,r)}var Zz="HashToScalar-";/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var Hz=(e,t)=>(e+(e>=0?t:-t)/Jz)/t;function nQ(e,t,r){Bi("scalar",e,si,r);let[[i,n],[o,s]]=t,a=Hz(s*e,r),c=Hz(-n*e,r),l=e-a*i-c*o,u=-a*n-c*s,d=l<si,p=u<si;if(d)l=-l;if(p)u=-u;let m=od(Math.ceil(Sc(r)/2))+Co;if(l<si||l>=m||u<si||u>=m)throw Error("splitScalar (endomorphism): failed for k");return{k1neg:d,k1:l,k2neg:p,k2:u}}function XS(e){if(!["compact","recovered","der"].includes(e))throw Error('Signature format must be "compact", "recovered", or "der"');return e}function YS(e,t){Sn(e);let r={};for(let i of Object.keys(t))r[i]=e[i]===void 0?t[i]:e[i];if(Li(r.lowS,"lowS"),Li(r.prehash,"prehash"),r.format!==void 0)XS(r.format);return r}class Kz extends Error{constructor(e=""){super(e)}}var Ln={Err:Kz,_tlv:{encode:(e,t)=>{let{Err:r}=Ln;if(oi(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=nd(i);if(n.length/2&128)throw new r("tlv.encode: long form length too big");let o=i>127?nd(n.length/2|128):"";return nd(e)+o+n+t},decode(e,t){let{Err:r}=Ln;t=ct(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}=Ln;if(Pm(e),e<si)throw new t("integer: negative integers are not allowed");let r=nd(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}=Ln;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 Fs(e)}},toSig(e){let{Err:t,_int:r,_tlv:i}=Ln,n=ct(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}=Ln,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(Ln._tlv);Object.freeze(Ln._int);Object.freeze(Ln);var si=BigInt(0),Co=BigInt(1),Jz=BigInt(2),Bm=BigInt(3),iQ=BigInt(4);function Vz(e,t={}){let r=Lm("weierstrass",e,t),i=r.Fp,n=r.Fn,o=r.CURVE,{h:s,n:a}=o;Sn(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=Gz(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(Li(N,"isCompressed"),N){d();let F=!i.isOdd(R);return sr(Wz(F),O)}else return sr(Uint8Array.of(4),O,i.toBytes(R))}function m(M){ct(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,Bm),iQ),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 nQ(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=ad(I,P),N=ad(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(ct(M,void 0,"point")));return P.assertValidity(),P}static fromHex(M){return D.fromBytes(yc(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(Bm);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,Bm),{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,Bm),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)=>Ks(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 Ks(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===si||N.is0())return D.ZERO;if(I===Co)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:_}=Fz(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===Co)return!0;if(M)return M(D,this);return X.unsafe(this,a).is0()}clearCofactor(){let{clearCofactor:M}=t;if(s===Co)return this;if(M)return M(D,this);return this.multiplyUnsafe(s)}isSmallOrder(){if(s===Co)return this.is0();return this.clearCofactor().is0()}toBytes(M=!0){return Li(M,"isCompressed"),this.assertValidity(),y(D,this,M)}toHex(M=!0){return gc(this.toBytes(M))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let H=n.BITS,X=new cd(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 Wz(e){return Uint8Array.of(e?2:3)}function Gz(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function oQ(e,t={}){let{Fn:r}=e,i=t.randomBytes===void 0?xc:t.randomBytes,n=Object.assign(Gz(e.Fp,r),{seed:Math.max(JS(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,Lz(ct(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(!bc(m))return;let A=ct(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=ld(a,c);return Object.freeze(d),Object.freeze(n),Object.freeze({getPublicKey:c,getSharedSecret:u,keygen:p,Point:e,utils:d,lengths:n})}function Qz(e,t,r={}){let i=t;Ti(i),Sn(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),r=Object.assign({},r);let n=r.randomBytes===void 0?xc:r.randomBytes,o=r.hmac===void 0?(R,O)=>Xn(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}=oQ(e,r),g={prehash:!0,lowS:typeof r.lowS==="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},b=c*Jz+Co<s.ORDER;function v(R){let O=c>>Co;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){XS(O);let F=y.signature,L=O==="compact"?F:O==="recovered"?F+1:void 0;return ct(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}=Ln.toSig(ct(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(yc(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(sr(Wz((L&1)===0),_)),ue=a.inv(V),C=Z(ct(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(XS(R),R==="der")return yc(Ln.hexFromSig(this));let{r:O,s:F}=this,L=a.toBytes(O),V=a.toBytes(F);if(R==="recovered")return T(),sr(Uint8Array.of(this.assertRecovery()),L,V);return sr(L,V)}toHex(R){return gc(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=Fs(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=od(l);function H(R){return Bi("num < 2^"+l,R,si,D),a.toBytes(R)}function X(R,O){return ct(R,void 0,"message"),O?ct(i(R),void 0,"prehashed message"):R}function M(R,O,F){let{lowS:L,prehash:V,extraEntropy:_}=YS(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(ct(Ce,void 0,"extraEntropy"))}let Se=sr(...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===si)return;let St=a.create(ze*a.create(Ee+Xe*ue));if(St===si)return;let Dt=(Ve.x===Xe?0:2)|Number(Ve.y&Co),hr=St;if(L&&v(St))hr=a.neg(St),Dt^=1;return new j(Xe,hr,b?void 0:Dt)}return{seed:Se,k2sig:$e}}function P(R,O,F={}){let{seed:L,k2sig:V}=M(R,O,F);return Ez(i.outputLen,a.BYTES,o)(L,V).toBytes(F.format)}function N(R,O,F,L={}){let{lowS:V,prehash:_,format:te}=YS(L,g);if(F=ct(F,void 0,"publicKey"),O=X(O,_),!bc(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}=YS(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 sQ=(()=>({p:BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),h:BigInt(1),a:BigInt("0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc"),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")}))();var aQ=Vz(sQ),vc=Qz(aQ,$t);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var $o=BigInt(0),Fr=BigInt(1),ew=BigInt(2),cQ=BigInt(8);function lQ(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 Yz(e,t={}){let r=t,i=Lm("edwards",e,r,r.FpFnLE),{Fp:n,Fn:o}=i,s=i.CURVE,{h:a}=s;Sn(r,{},{uvRatio:"function"});let c=ew<<BigInt(o.BYTES*8)-Fr,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:$o}}}:r.uvRatio;if(!lQ(n,s,s.Gx,s.Gy))throw Error("bad curve params: generator point");function d(g,b,v=!1){let A=v?Fr:$o;return Bi("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,Fr,l(s.Gx*s.Gy));static ZERO=new m($o,Fr,Fr,$o);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,Fr,l(b*v))}static fromBytes(g,b=!1){let v=n.BYTES,{a:A,d:T}=s;g=To(ct(g,v,"point")),Li(b,"zip215");let z=To(g),j=g[v-1];z[v-1]=j&-129;let E=Dn(z),Z=b?c:n.ORDER;Bi("point.y",E,$o,Z);let D=l(E*E),H=l(D-Fr),X=l(T*D-A),{isValid:M,value:P}=u(H,X);if(!M)throw Error("bad point: invalid y coordinate");let N=(P&Fr)===Fr,I=(j&128)!==0;if(!b&&P===$o&&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(yc(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(ew);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(ew*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)=>Ks(m,A));return Ks(m,[b,v])[0]}multiplyUnsafe(g){if(!o.isValid(g))throw RangeError("invalid scalar: expected 0 <= sc < curve.n");if(g===$o)return m.ZERO;if(this.is0()||g===Fr)return this;return y.unsafe(this,g,(b)=>Ks(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?cQ:n.inv(z);let E=l(A*v),Z=l(T*v),D=n.mul(z,v);if(j)return{x:$o,y:Fr};if(D!==Fr)throw Error("invZ was invalid");return{x:E,y:Z}}clearCofactor(){if(a===Fr)return this;return this.multiplyUnsafe(a)}toBytes(){let{x:g,y:b}=this.toAffine(),v=n.toBytes(b);return v[v.length-1]|=g&Fr?128:0,v}toHex(){return gc(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let y=new cd(m,o.BITS);if(o.BITS>=8)m.BASE.precompute(8);return Object.freeze(m.prototype),Object.freeze(m),m}class tw{static BASE;static ZERO;static Fp;static Fn;ep;constructor(e){this.ep=e}static fromBytes(e){FS()}static fromHex(e){FS()}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 gc(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 dd=BigInt(0),_c=BigInt(1),jm=BigInt(2);function uQ(e){return Sn(e,{P:"bigint",type:"string",adjustScalarBytes:"function",powPminus2:"function"},{randomBytes:"function"}),Object.freeze({...e})}function Xz(e){let t=uQ(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?xc:s,l=a?255:448,u=a?32:56,d=a?BigInt(9):BigInt(5),p=a?BigInt(121665):BigInt(39081),m=a?jm**BigInt(254):jm**BigInt(447),y=a?BigInt(8)*jm**BigInt(251)-_c:BigInt(4)*jm**BigInt(445)-_c,g=m+y+_c,b=(I)=>gt(I,r),v=A(d);function A(I){return id(b(I),u)}function T(I){let R=To(ct(I,u,"uCoordinate"));if(a)R[31]&=127;return b(Dn(R))}function z(I){return Dn(n(To(ct(I,u,"scalar"))))}function j(I,R){let O=X(T(R),z(I));if(O===dd)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){Bi("u",I,dd,r),Bi("scalar",R,m,g);let O=R,F=I,L=_c,V=dd,_=I,te=_c,ue=dd;for(let Se=BigInt(l-1);Se>=dd;Se--){let Ee=O>>Se&_c;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,Dt=b(St*$e),hr=b(Xe*_e),Yr=Dt+hr,Xr=Dt-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,ct(I,M.seed,"seed"),I),N={randomSecretKey:P};return Object.freeze(M),Object.freeze(N),Object.freeze({keygen:ld(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 dQ=BigInt(0),qi=BigInt(1),e2=BigInt(2),fQ=BigInt(3),pQ=BigInt(5),mQ=BigInt(8),Vs=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),ow=(()=>({p:Vs,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:mQ,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")}))();function n2(e){let t=BigInt(10),r=BigInt(20),i=BigInt(40),n=BigInt(80),o=Vs,a=e*e%o*e%o,c=wn(a,e2,o)*a%o,l=wn(c,qi,o)*e%o,u=wn(l,pQ,o)*l%o,d=wn(u,t,o)*u%o,p=wn(d,r,o)*d%o,m=wn(p,i,o)*p%o,y=wn(m,n,o)*m%o,g=wn(y,n,o)*m%o,b=wn(g,t,o)*u%o;return{pow_p_5_8:wn(b,e2,o)*e%o,b2:a}}function hQ(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var rw=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function sw(e,t){let r=Vs,i=gt(t*t*t,r),n=gt(i*i*t,r),o=n2(e*n).pow_p_5_8,s=gt(e*i*o,r),a=gt(t*s*s,r),c=s,l=gt(s*rw,r),u=a===e,d=a===gt(-e,r),p=a===gt(-e*rw,r);if(u)s=c;if(d||p)s=l;if(ji(s,r))s=gt(-s,r);return{isValid:u||d,value:s}}var Js=Yz(ow,{uvRatio:sw}),Oo=(()=>Js.Fp)(),i2=(()=>Js.Fn)();var qm=(()=>{let e=Vs;return Xz({P:e,type:"x25519",powPminus2:(t)=>{let{pow_p_5_8:r,b2:i}=n2(t);return gt(wn(r,fQ,e)*i,e)},adjustScalarBytes:hQ})})();var nw=rw,gQ=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),yQ=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),bQ=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),xQ=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),t2=(e)=>sw(qi,e),SQ=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),iw=(e)=>Oo.create(Dn(e)&SQ);function r2(e){let{d:t}=ow,r=Vs,i=(v)=>Oo.create(v),n=i(nw*e*e),o=i((n+qi)*bQ),s=BigInt(-1),a=i((s-t*n)*i(n+t)),{isValid:c,value:l}=sw(o,a),u=i(l*e);if(!ji(u,r))u=i(-u);if(!c)l=u;if(!c)s=n;let d=i(s*(n-qi)*xQ-a),p=l*l,m=i((l+l)*a),y=i(d*gQ),g=i(qi-p),b=i(qi+p);return new Js(i(m*b),i(g*y),i(y*b),i(m*g))}class $r extends tw{static BASE=(()=>new $r(Js.BASE))();static ZERO=(()=>new $r(Js.ZERO))();static Fp=(()=>Oo)();static Fn=(()=>i2)();constructor(e){super(e)}static fromAffine(e){return new $r(Js.fromAffine(e))}assertSame(e){if(!(e instanceof $r))throw Error("RistrettoPoint expected")}init(e){return new $r(e)}static fromBytes(e){rr(e,32);let{a:t,d:r}=ow,i=Vs,n=(T)=>Oo.create(T),o=iw(e);if(!kz(Oo.toBytes(o),e)||ji(o,i))throw Error("invalid ristretto255 encoding 1");let s=n(o*o),a=n(qi+t*s),c=n(qi-t*s),l=n(a*a),u=n(c*c),d=n(t*r*l-u),{isValid:p,value:m}=t2(n(d*u)),y=n(m*c),g=n(m*y*d),b=n((o+o)*y);if(ji(b,i))b=n(-b);let v=n(a*g),A=n(b*v);if(!p||ji(A,i)||v===dQ)throw Error("invalid ristretto255 encoding 2");return new $r(new Js(b,v,qi,A))}static fromHex(e){return $r.fromBytes(Pu(e))}toBytes(){let{X:e,Y:t,Z:r,T:i}=this.ep,n=Vs,o=(g)=>Oo.create(g),s=o(o(r+t)*o(r-t)),a=o(e*t),c=o(a*a),{value:l}=t2(o(s*c)),u=o(l*s),d=o(l*a),p=o(u*d*i),m;if(ji(i*p,n)){let g=o(t*nw),b=o(e*nw);e=g,t=b,m=o(u*yQ)}else m=d;if(ji(e*p,n))t=o(-t);let y=o((r-t)*m);if(ji(y,n))y=o(-y);return Oo.toBytes(y)}equals(e){this.assertSame(e);let{X:t,Y:r}=this.ep,{X:i,Y:n}=e.ep,o=(c)=>Oo.create(c),s=o(t*n)===o(r*i),a=o(r*n)===o(t*i);return s||a}is0(){return this.equals($r.ZERO)}}Object.freeze($r.BASE);Object.freeze($r.ZERO);Object.freeze($r.prototype);Object.freeze($r);var wQ=Object.freeze({Point:$r,hashToCurve(e,t){let r=t?.DST===void 0?"ristretto255_XMD:SHA-512_R255MAP_RO_":t.DST,i=QS(e,r,64,im);return wQ.deriveToCurve(i)},hashToScalar(e,t={DST:Zz}){let r=QS(e,t.DST,64,im);return i2.create(Dn(r))},deriveToCurve(e){rr(e,64);let t=iw(e.subarray(0,32)),r=r2(t),i=iw(e.subarray(32,64)),n=r2(i);return new $r(r.add(n))}});var o2=!1,vQ=!1;async function s2(e,t){if(vQ)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 Um(e,t){return await s2(async()=>{let r=aw(e)?e:await kQ(e),i=await crypto.subtle.importKey("raw",EQ(t),{name:"X25519"},o2,[]);return new Uint8Array(await crypto.subtle.deriveBits({name:"X25519",public:i},r,256))},()=>{if(aw(e))throw Error("CryptoKey provided but X25519 WebCrypto is not supported");return qm.scalarMult(e,t)})}async function fd(e){return await s2(async()=>Um(e,qm.GuBytes),()=>{if(aw(e))throw Error("CryptoKey provided but X25519 WebCrypto is not supported");return qm.scalarMultBase(e)})}var _Q=new Uint8Array([48,46,2,1,0,48,5,6,3,43,101,110,4,34,4,32]);async function kQ(e){if(e.length!==32)throw Error("X25519 private key must be 32 bytes");let t=new Uint8Array([..._Q,...e]);return crypto.subtle.importKey("pkcs8",t,{name:"X25519"},o2,["deriveBits"])}function aw(e){return typeof CryptoKey<"u"&&e instanceof CryptoKey}function EQ(e){return e}class cw{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),AQ(Ws(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=Ws(e),null;this.buf=r.value}}close(){return this.s.releaseLock(),{rest:this.buf,transcript:Ws(this.transcript)}}}function AQ(e){return e.forEach((t)=>{if(t<32||t>126)throw Error("invalid non-ASCII byte in header")}),new TextDecoder().decode(e)}function Ws(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 kc(e,...t){return e.pipeThrough(new TransformStream({start(r){for(let i of t)r.enqueue(i)}}))}function Mm(e){return new ReadableStream({start(t){t.enqueue(e),t.close()}})}async function lw(e){if(!(e instanceof ReadableStream))throw Error("readAll expects a ReadableStream<Uint8Array>");return new Uint8Array(await new Response(e).arrayBuffer())}async function a2(e){if(!(e instanceof ReadableStream))throw Error("readAllString expects a ReadableStream<Uint8Array>");return await new Response(e).text()}async function c2(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=Ws(i),s=o.subarray(0,t),a=kc(e,o.subarray(t));return{data:s,rest:a}}class ai{args;body;constructor(e,t){this.args=e,this.body=t}}async function TQ(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=gr.decode(o);if(s.length>48)throw Error("invalid stanza");if(i.push(s),s.length<48)break}let n=Ws(i);return{s:new ai(r,n)}}async function l2(e){let t=new cw(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 TQ(t);if(n!==void 0){i.push(n);continue}if(!o.startsWith("--- "))throw Error("invalid header");let s=gr.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:kc(e,a)}}}function uw(e){let t=[];t.push(`age-encryption.org/v1
767
+ `}var y7,rEe;var tR=x(async()=>{Re();p7();pi();Hp();await f7();y7=f.object({HCLOUD_TOKEN:f.string().min(1),KAMAL_SSH_PRIVATE_KEY:f.string().min(1)}),rEe=f.object({servers:f.array(f.object({status:f.string(),public_net:f.object({ipv4:f.object({ip:f.string().min(1)})})}))})});import{parseArgs as nW}from"util";function mt(e){return e}class Gp extends Error{constructor(e){super(e);this.name="CliUsageError"}}function iW(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 oW(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 sW(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 oR(e,t){let r=iW(t.commands,t.globalFlags??{}),i,n;try{({values:i,positionals:n}=nW({args:e,options:oW(r),allowPositionals:!0,strict:t.strict??!0}))}catch(s){if(sW(s))throw new Gp(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 sR(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 aW(e){return sR(e.map((t)=>({label:t.usage?`${t.name} ${t.usage}`:t.name,description:t.description})))}function cW(e,t){let r=t.type==="string"?` ${t.placeholder??"<value>"}`:"",i=t.short!==void 0?`, -${t.short}`:"";return`--${e}${r}${i}`}function aR(e){return sR(Object.entries(e).map(([t,r])=>({label:cW(t,r),description:r.description})))}function cR(e,t){return`Usage: ${e} ${t.name}${t.usage?` ${t.usage}`:""}`}function lW(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 uW(e){let t=[],r=new Map;for(let n of e){let o=n.flags??{};if(Object.keys(o).length===0)continue;let s=lW(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(...aR(n.flags));return i}function lR(e){let t=[e.intro,"",`Usage: ${e.cliName} ${e.usage??"<command> [args]"}`,"","Commands:",...aW(e.commands)];if(e.globalFlags&&Object.keys(e.globalFlags).length>0)t.push("","Options:",...aR(e.globalFlags));return t.push(...uW(e.commands)),t.join(`
768
+ `)}function uR(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 nc(e,t){let r=e[t];return typeof r==="boolean"?r:void 0}var Qp={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"};import{existsSync as jQ,mkdirSync as qQ,readFileSync as Tw,writeFileSync as Cw}from"fs";import{dirname as UQ,join as x2}from"path";function Mx(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function Ct(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 rr(e,t,r=""){let i=Mx(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 Ti(e){if(typeof e!=="function"||typeof e.create!=="function")throw TypeError("Hash must wrapped by utils.createHasher");if(Ct(e.outputLen),Ct(e.blockLen),e.outputLen<1)throw Error('"outputLen" must be >= 1');if(e.blockLen<1)throw Error('"blockLen" must be >= 1')}function ic(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 Yp(e,t){rr(e,void 0,"digestInto() output");let r=t.outputLen;if(e.length<r)throw RangeError('"digestInto() output" expected to be of length >='+r)}function Xp(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function Ar(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function oc(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Pn(e,t){return e<<32-t|e>>>t}function Qe(e,t){return e<<t|e>>>32-t>>>0}var fW=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)();function pW(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function mW(e){for(let t=0;t<e.length;t++)e[t]=pW(e[t]);return e}var Fx=fW?(e)=>e:mW,fR=(()=>typeof Uint8Array.from([]).toHex==="function"&&typeof Uint8Array.fromHex==="function")(),hW=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function em(e){if(rr(e),fR)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=hW[e[r]];return t}var Ai={_0:48,_9:57,A:65,F:70,a:97,f:102};function dR(e){if(e>=Ai._0&&e<=Ai._9)return e-Ai._0;if(e>=Ai.A&&e<=Ai.F)return e-(Ai.A-10);if(e>=Ai.a&&e<=Ai.f)return e-(Ai.a-10);return}function Pu(e){if(typeof e!=="string")throw TypeError("hex string expected, got "+typeof e);if(fR)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=dR(e.charCodeAt(o)),a=dR(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 gW(e){if(typeof e!=="string")throw TypeError("string expected");return new Uint8Array(new TextEncoder().encode(e))}function Zx(e,t=""){if(typeof e==="string")return gW(e);return rr(e,void 0,t)}function Hx(...e){let t=0;for(let i=0;i<e.length;i++){let n=e[i];rr(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 tm(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 Kx(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 Ci(e=32){Ct(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 Jx=(e)=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});class Vx{oHash;iHash;blockLen;outputLen;canXOF=!1;finished=!1;destroyed=!1;constructor(e,t){if(Ti(e),rr(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),Ar(i)}update(e){return ic(this),this.iHash.update(e),this}digestInto(e){ic(this),Yp(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 Xn=(()=>{let e=(t,r,i)=>new Vx(t,r).update(i).digest();return e.create=(t,r)=>new Vx(t,r),e})();function zu(e,t,r){if(Ti(e),r===void 0)r=new Uint8Array(e.outputLen);return Xn(e,r,t)}var Wx=Uint8Array.of(0),pR=Uint8Array.of();function Gx(e,t,r,i=32){Ti(e),Ct(i,"length"),rr(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=pR;else rr(r,void 0,"info");let s=new Uint8Array(o*n),a=Xn.create(e,t),c=a._cloneInto(),l=new Uint8Array(a.outputLen);for(let u=0;u<o;u++)Wx[0]=u+1,c.update(u===0?pR:l).update(r).update(Wx).digestInto(l),s.set(l,n*u),a._cloneInto(c);return a.destroy(),c.destroy(),Ar(l,Wx),s.slice(0,i)}var mo=(e,t,r,i,n)=>Gx(e,zu(e,t,r),i,n);function mR(e,t,r){return e&t^~e&r}function hR(e,t,r){return e&t^e&r^t&r}class rm{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=oc(this.buffer)}update(e){ic(this),rr(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=oc(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){ic(this),Yp(e,this),this.finished=!0;let{buffer:t,view:r,blockLen:i,isLE:n}=this,{pos:o}=this;if(t[o++]=128,Ar(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=oc(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 $i=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var nr=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var nm=BigInt(4294967295),gR=BigInt(32);function yW(e,t=!1){if(t)return{h:Number(e&nm),l:Number(e>>gR&nm)};return{h:Number(e>>gR&nm)|0,l:Number(e&nm)|0}}function yR(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}=yW(e[o],t);[i[o],n[o]]=[s,a]}return[i,n]}var Qx=(e,t,r)=>e>>>r,Yx=(e,t,r)=>e<<32-r|t>>>r,Cs=(e,t,r)=>e>>>r|t<<32-r,$s=(e,t,r)=>e<<32-r|t>>>r,Nu=(e,t,r)=>e<<64-r|t>>>r-32,Du=(e,t,r)=>e>>>r-32|t<<64-r;function ei(e,t,r,i){let n=(t>>>0)+(i>>>0);return{h:e+r+(n/4294967296|0)|0,l:n|0}}var bR=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),xR=(e,t,r,i)=>t+r+i+(e/4294967296|0)|0,SR=(e,t,r,i)=>(e>>>0)+(t>>>0)+(r>>>0)+(i>>>0),wR=(e,t,r,i,n)=>t+r+i+n+(e/4294967296|0)|0,vR=(e,t,r,i,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(i>>>0)+(n>>>0),_R=(e,t,r,i,n,o)=>t+r+i+n+o+(e/4294967296|0)|0;var xW=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]),ho=new Uint32Array(64);class kR extends rm{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)ho[u]=e.getUint32(t,!1);for(let u=16;u<64;u++){let d=ho[u-15],p=ho[u-2],m=Pn(d,7)^Pn(d,18)^d>>>3,y=Pn(p,17)^Pn(p,19)^p>>>10;ho[u]=y+ho[u-7]+m+ho[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=Pn(s,6)^Pn(s,11)^Pn(s,25),p=l+d+mR(s,a,c)+xW[u]+ho[u]|0,y=(Pn(r,2)^Pn(r,13)^Pn(r,22))+hR(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(){Ar(ho)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),Ar(this.buffer)}}class ER extends kR{A=$i[0]|0;B=$i[1]|0;C=$i[2]|0;D=$i[3]|0;E=$i[4]|0;F=$i[5]|0;G=$i[6]|0;H=$i[7]|0;constructor(){super(32)}}var IR=(()=>yR(["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))))(),SW=(()=>IR[0])(),wW=(()=>IR[1])(),go=new Uint32Array(80),yo=new Uint32Array(80);class AR extends rm{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)go[A]=e.getUint32(t),yo[A]=e.getUint32(t+=4);for(let A=16;A<80;A++){let T=go[A-15]|0,z=yo[A-15]|0,j=Cs(T,z,1)^Cs(T,z,8)^Qx(T,z,7),E=$s(T,z,1)^$s(T,z,8)^Yx(T,z,7),Z=go[A-2]|0,D=yo[A-2]|0,H=Cs(Z,D,19)^Nu(Z,D,61)^Qx(Z,D,6),X=$s(Z,D,19)^Du(Z,D,61)^Yx(Z,D,6),M=SR(E,X,yo[A-7],yo[A-16]),P=wR(M,j,H,go[A-7],go[A-16]);go[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=Cs(u,d,14)^Cs(u,d,18)^Nu(u,d,41),z=$s(u,d,14)^$s(u,d,18)^Du(u,d,41),j=u&p^~u&y,E=d&m^~d&g,Z=vR(v,z,E,wW[A],yo[A]),D=_R(Z,b,T,j,SW[A],go[A]),H=Z|0,X=Cs(r,i,28)^Nu(r,i,34)^Nu(r,i,39),M=$s(r,i,28)^Du(r,i,34)^Du(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}=ei(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=bR(H,M,N);r=xR(I,D,X,P),i=I|0}({h:r,l:i}=ei(this.Ah|0,this.Al|0,r|0,i|0)),{h:n,l:o}=ei(this.Bh|0,this.Bl|0,n|0,o|0),{h:s,l:a}=ei(this.Ch|0,this.Cl|0,s|0,a|0),{h:c,l}=ei(this.Dh|0,this.Dl|0,c|0,l|0),{h:u,l:d}=ei(this.Eh|0,this.El|0,u|0,d|0),{h:p,l:m}=ei(this.Fh|0,this.Fl|0,p|0,m|0),{h:y,l:g}=ei(this.Gh|0,this.Gl|0,y|0,g|0),{h:b,l:v}=ei(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(){Ar(go,yo)}destroy(){this.destroyed=!0,Ar(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class TR extends AR{Ah=nr[0]|0;Al=nr[1]|0;Bh=nr[2]|0;Bl=nr[3]|0;Ch=nr[4]|0;Cl=nr[5]|0;Dh=nr[6]|0;Dl=nr[7]|0;Eh=nr[8]|0;El=nr[9]|0;Fh=nr[10]|0;Fl=nr[11]|0;Gh=nr[12]|0;Gl=nr[13]|0;Hh=nr[14]|0;Hl=nr[15]|0;constructor(){super(64)}}var $t=Kx(()=>new ER,Jx(1));var im=Kx(()=>new TR,Jx(3));/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function lm(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function tS(e){if(!lm(e))throw TypeError("Uint8Array expected")}function PR(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 zR(e){if(typeof e!=="function")throw TypeError("function expected");return!0}function bo(e,t){if(typeof t!=="string")throw TypeError(`${e}: string expected`);return!0}function Bu(e){if(typeof e!=="number")throw TypeError(`number expected, got ${typeof e}`);if(!Number.isSafeInteger(e))throw RangeError(`invalid integer: ${e}`)}function sm(e){if(!Array.isArray(e))throw TypeError("array expected")}function am(e,t){if(!PR(!0,t))throw TypeError(`${e}: array of strings expected`)}function rS(e,t){if(!PR(!1,t))throw TypeError(`${e}: array of numbers expected`)}function en(...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 tn(e){let t=typeof e==="string"?e.split(""):e,r=t.length;am("alphabet",t);let i=new Map(t.map((n,o)=>[n,o]));return{encode:(n)=>(sm(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)=>(sm(n),n.map((o)=>{bo("alphabet.decode",o);let s=i.get(o);if(s===void 0)throw Error(`Unknown letter: "${o}". Allowed: ${e}`);return s}))}}function rn(e=""){return bo("join",e),{encode:(t)=>(am("join.decode",t),t.join(e)),decode:(t)=>(bo("join.decode",t),t.split(e))}}function um(e,t="="){return Bu(e),bo("padding",t),{encode(r){am("padding.encode",r);while(r.length*e%8)r.push(t);return r},decode(r){am("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 NR(e){return zR(e),{encode:(t)=>t,decode:(t)=>e(t)}}function CR(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(sm(e),!e.length)return[];let i=0,n=[],o=Array.from(e,(a)=>{if(Bu(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 DR=(e,t)=>t===0?e:DR(t,e%t),cm=(e,t)=>e+(t-DR(e,t)),om=(()=>{let e=[];for(let t=0;t<40;t++)e.push(2**t);return e})();function Xx(e,t,r,i){if(sm(e),t<=0||t>32)throw RangeError(`convertRadix2: wrong from=${t}`);if(r<=0||r>32)throw RangeError(`convertRadix2: wrong to=${r}`);if(cm(t,r)>32)throw Error(`convertRadix2: carry overflow from=${t} to=${r} carryBits=${cm(t,r)}`);let n=0,o=0,s=om[t],a=om[r]-1,c=[];for(let l of e){if(Bu(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=om[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 vW(e){Bu(e);let t=256;return{encode:(r)=>{if(!lm(r))throw TypeError("radix.encode input should be Uint8Array");return CR(Array.from(r),t,e)},decode:(r)=>(rS("radix.decode",r),Uint8Array.from(CR(r,e,t)))}}function gn(e,t=!1){if(Bu(e),e<=0||e>32)throw RangeError("radix2: bits should be in (0..32]");if(cm(8,e)>32||cm(e,8)>32)throw RangeError("radix2: carry overflow");return{encode:(r)=>{if(!lm(r))throw TypeError("radix2.encode input should be Uint8Array");return Xx(Array.from(r),8,e,!t)},decode:(r)=>(rS("radix2.decode",r),Uint8Array.from(Xx(r,e,8,t)))}}function $R(e){return zR(e),function(...t){try{return e.apply(null,t)}catch(r){}}}var CEe=Object.freeze(en(gn(4),tn("0123456789ABCDEF"),rn(""))),$Ee=Object.freeze(en(gn(5),tn("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),um(5),rn(""))),OEe=Object.freeze(en(gn(5),tn("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),rn(""))),REe=Object.freeze(en(gn(5),tn("0123456789ABCDEFGHIJKLMNOPQRSTUV"),um(5),rn(""))),PEe=Object.freeze(en(gn(5),tn("0123456789ABCDEFGHIJKLMNOPQRSTUV"),rn(""))),zEe=Object.freeze(en(gn(5),tn("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),rn(""),NR((e)=>e.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1")))),LR=(()=>typeof Uint8Array.from([]).toBase64==="function"&&typeof Uint8Array.fromBase64==="function")(),_W=/[\t\n\f\r ]/,BR=(e,t)=>{bo("base64",e);let r=t?"base64url":"base64";if(e.length>0&&_W.test(e))throw Error("invalid base64");return Uint8Array.fromBase64(e,{alphabet:r,lastChunkHandling:"strict"})},nS=Object.freeze(LR?{encode(e){return tS(e),e.toBase64()},decode(e){return BR(e,!1)}}:en(gn(6),tn("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),um(6),rn(""))),gr=Object.freeze(en(gn(6),tn("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),rn(""))),NEe=Object.freeze(LR?{encode(e){return tS(e),e.toBase64({alphabet:"base64url"})},decode(e){return BR(e,!0)}}:en(gn(6),tn("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),um(6),rn(""))),DEe=Object.freeze(en(gn(6),tn("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),rn(""))),iS=(e)=>en(vW(58),tn(e),rn("")),LEe=Object.freeze(iS("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")),BEe=Object.freeze(iS("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ")),jEe=Object.freeze(iS("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz"));var eS=en(tn("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),rn("")),OR=[996825010,642813549,513874426,1027748829,705979059];function Lu(e){let t=e>>25,r=(e&33554431)<<5;for(let i=0;i<OR.length;i++)if((t>>i&1)===1)r^=OR[i];return r}function RR(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=Lu(n)^s>>5}n=Lu(n);for(let o=0;o<i;o++)n=Lu(n)^e.charCodeAt(o)&31;for(let o of t)n=Lu(n)^o;for(let o=0;o<6;o++)n=Lu(n);return n^=r,eS.encode(Xx([n%om[30]],30,5,!1))}function jR(e){let t=e==="bech32"?1:734539939,r=gn(5),i=r.decode,n=r.encode,o=$R(i);function s(d,p,m=90){if(bo("bech32.encode prefix",d),lm(p))p=Array.from(p);rS("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=RR(b,p,t);return`${b}1${eS.encode(p)}${v}`}function a(d,p=90){bo("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=eS.decode(v).slice(0,-6),T=RR(b,A,t);if(!v.endsWith(T))throw Error(`Invalid checksum in ${d}: expected "${T}"`);return{prefix:b,words:A}}let c=$R(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 nn=Object.freeze(jR("bech32")),qEe=Object.freeze(jR("bech32m"));var kW=(()=>typeof Uint8Array.from([]).toHex==="function"&&typeof Uint8Array.fromHex==="function")(),EW={encode(e){return tS(e),e.toHex()},decode(e){return bo("hex",e),Uint8Array.fromHex(e)}},UEe=Object.freeze(kW?EW:en(gn(4),tn("0123456789abcdef"),rn(""),NR((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 AW(e,t,r,i){Ti(e);let n=tm({dkLen:32,asyncTick:10},i),{c:o,dkLen:s,asyncTick:a}=n;if(Ct(o,"c"),Ct(s,"dkLen"),Ct(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=Zx(t,"password"),l=Zx(r,"salt"),u=new Uint8Array(s),d=Xn.create(e,c),p=d._cloneInto().update(l);return{c:o,dkLen:s,asyncTick:a,DK:u,PRF:d,PRFSalt:p}}function TW(e,t,r,i,n){if(e.destroy(),t.destroy(),i)i.destroy();return Ar(n),r}function oS(e,t,r,i){let{c:n,dkLen:o,DK:s,PRF:a,PRFSalt:c}=AW(e,t,r,i),l,u=new Uint8Array(4),d=oc(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 TW(a,c,s,l,p)}function qR(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 sS(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(qR(r,s,e,t,r,o),a>0)s+=16;qR(r,o,e,t+=16,r,s)}}function CW(e,t,r){let i=tm({dkLen:32,asyncTick:10,maxmem:1073742848},r),{N:n,r:o,p:s,dkLen:a,asyncTick:c,maxmem:l,onProgress:u}=i;if(Ct(n,"N"),Ct(o,"r"),Ct(s,"p"),Ct(a,"dkLen"),Ct(c,"asyncTick"),Ct(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=oS($t,e,t,{c:1,dkLen:d*s}),b=Xp(g),v=Xp(new Uint8Array(d*n)),A=Xp(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 $W(e,t,r,i,n){let o=oS($t,e,r,{c:1,dkLen:t});return Ar(r,i,n),o}function aS(e,t,r){let{N:i,r:n,p:o,dkLen:s,blockSize32:a,V:c,B32:l,B:u,tmp:d,blockMixCb:p}=CW(e,t,r);Fx(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++)sS(c,b,c,b+=a,n),p();sS(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];sS(d,0,l,y,n),p()}}return Fx(l),$W(e,s,u,c,d)}/*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */function OW(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function dm(e){if(typeof e!=="boolean")throw TypeError(`boolean expected, not ${e}`)}function sc(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 Mt(e,t,r=""){let i=OW(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 cS(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 UR(e,t,r=!1){Mt(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&&!ac(e))throw Error("invalid output, must be aligned")}function ti(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function zn(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function RW(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}var Os=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)(),PW=(e)=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255;var zW=(e)=>{for(let t=0;t<e.length;t++)e[t]=PW(e[t]);return e},Oi=Os?(e)=>e:zW;function MR(e,t){if(t==null||typeof t!=="object")throw Error("options must be defined");return Object.assign(e,t)}function FR(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 ZR(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 HR=(e,t)=>{function r(i,...n){if(Mt(i,void 0,"key"),e.nonceLength!==void 0){let u=n[0];Mt(u,e.varSizeNonce?void 0:e.nonceLength,"nonce")}let o=e.tagLength;if(o&&n[1]!==void 0)Mt(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");Mt(d,void 0,"output")}},c=!1;return{encrypt(u,d){if(c)throw Error("cannot encrypt() twice with same key + nonce");return c=!0,Mt(u),a(s.encrypt.length,d),s.encrypt(u,d)},decrypt(u,d){if(Mt(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 ju(e,t,r=!0){if(t===void 0)return new Uint8Array(e);if(Mt(t,void 0,"output"),t.length!==e)throw Error('"output" expected Uint8Array of length '+e+", got: "+t.length);if(r&&!ac(t))throw Error("invalid output, must be aligned");return t}function KR(e,t,r){sc(e),sc(t),dm(r);let i=new Uint8Array(16),n=RW(i);return n.setBigUint64(0,BigInt(t),r),n.setBigUint64(8,BigInt(e),r),i}function ac(e){return e.byteOffset%4===0}function cc(e){return Uint8Array.from(Mt(e))}var VR=(e)=>Uint8Array.from(e.split(""),(t)=>t.charCodeAt(0)),NW=(()=>Oi(ti(VR("expand 16-byte k"))))(),DW=(()=>Oi(ti(VR("expand 32-byte k"))))();function Ye(e,t){return e<<t|e>>>32-t}var qu=64,LW=16,lS=(()=>4294967295)(),JR=Uint32Array.of();function BW(e,t,r,i,n,o,s,a){let c=n.length,l=new Uint8Array(qu),u=ti(l),d=Os&&ac(n)&&ac(o),p=d?ti(n):JR,m=d?ti(o):JR;if(!Os){for(let y=0;y<c;s++){if(e(t,r,i,u,s,a),Oi(u),s>=lS)throw Error("arx: counter overflow");let g=Math.min(qu,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>=lS)throw Error("arx: counter overflow");let g=Math.min(qu,c-y);if(d&&g===qu){let b=y/4;if(y%4!==0)throw Error("arx: invalid block position");for(let v=0,A;v<LW;v++)A=b+v,m[A]=p[A]^u[v];y+=qu;continue}for(let b=0,v;b<g;b++)v=y+b,o[v]=n[v]^l[b];y+=g}}function WR(e,t){let{allowShortKeys:r,extendNonceFn:i,counterLength:n,counterRight:o,rounds:s}=MR({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},t);if(typeof e!=="function")throw Error("core must be a function");return sc(n),sc(s),dm(o),dm(r),(a,c,l,u,d=0)=>{Mt(a,void 0,"key"),Mt(c,void 0,"nonce"),Mt(l,void 0,"data");let p=l.length;if(u=ju(p,u,!1),sc(d),d<0||d>=lS)throw Error("arx: counter overflow");let m=[],y=a.length,g,b;if(y===32)m.push(g=cc(a)),b=DW;else if(y===16&&r)g=new Uint8Array(32),g.set(a),g.set(a,16),b=NW,m.push(g);else throw Mt(a,32,"arx key"),Error("invalid key size");if(!Os||!ac(c))m.push(c=cc(c));let v=ti(g);if(i){if(c.length!==24)throw Error("arx: extended nonce must be 24 bytes");let z=c.subarray(0,16);if(Os)i(b,v,ti(z),v);else{let j=Oi(Uint32Array.from(b));i(j,v,ti(z),v),zn(j),Oi(v)}c=c.subarray(16)}else if(!Os)Oi(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=Oi(ti(c));try{return BW(e,b,v,T,l,u,d,s),u}finally{zn(...m)}}}function ir(e,t){return e[t++]&255|(e[t++]&255)<<8}class GR{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=cc(Mt(e,32,"key"));let t=ir(e,0),r=ir(e,2),i=ir(e,4),n=ir(e,6),o=ir(e,8),s=ir(e,10),a=ir(e,12),c=ir(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]=ir(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=ir(e,t+0),v=ir(e,t+2),A=ir(e,t+4),T=ir(e,t+6),z=ir(e,t+8),j=ir(e,t+10),E=ir(e,t+12),Z=ir(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;zn(r)}update(e){cS(this),Mt(e),e=cc(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,zn(this.h,this.r,this.buffer,this.pad)}digestInto(e){cS(this),UR(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 QR=ZR(32,(e)=>new GR(e));function jW(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 qW=WR(jW,{counterRight:!1,counterLength:4,allowShortKeys:!1});var UW=new Uint8Array(16),YR=(e,t)=>{e.update(t);let r=t.length%16;if(r)e.update(UW.subarray(r))},MW=new Uint8Array(32);function XR(e,t,r,i,n){if(n!==void 0)Mt(n,void 0,"AAD");let o=e(t,r,MW),s=KR(i.length,n?n.length:0,!0),a=QR.create(o);if(n)YR(a,n);YR(a,i),a.update(s);let c=a.digest();return zn(o,s),c}var FW=(e)=>(t,r,i)=>({encrypt(o,s){let a=o.length;s=ju(a+16,s,!1),s.set(o);let c=s.subarray(0,-16);e(t,r,c,c,1);let l=XR(e,t,r,c,i);return s.set(l,a),zn(l),s},decrypt(o,s){s=ju(o.length-16,s,!1);let a=o.subarray(0,-16),c=o.subarray(-16),l=XR(e,t,r,a,i);if(!FR(c,l))throw zn(l),Error("invalid tag");return s.set(o.subarray(0,-16)),e(t,r,s,s,1),zn(l),s}}),yn=HR({blockSize:64,nonceLength:12,tagLength:16},FW(qW));/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function lc(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Wt(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=lc(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 bn(e){if(typeof e!=="function"||typeof e.create!=="function")throw Error("Hash must wrapped by utils.createHasher");Wt(e.outputLen),Wt(e.blockLen)}function Pi(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 fm(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 pm(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function Mr(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function mm(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Nn(e,t){return e<<32-t|e>>>t}var ZW=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)();function HW(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function KW(e){for(let t=0;t<e.length;t++)e[t]=HW(e[t]);return e}var uS=ZW?(e)=>e:KW,tP=(()=>typeof Uint8Array.from([]).toHex==="function"&&typeof Uint8Array.fromHex==="function")(),JW=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Rs(e){if(Ne(e),tP)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=JW[e[r]];return t}var Ri={_0:48,_9:57,A:65,F:70,a:97,f:102};function eP(e){if(e>=Ri._0&&e<=Ri._9)return e-Ri._0;if(e>=Ri.A&&e<=Ri.F)return e-(Ri.A-10);if(e>=Ri.a&&e<=Ri.f)return e-(Ri.a-10);return}function Ps(e){if(typeof e!=="string")throw Error("hex string expected, got "+typeof e);if(tP)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=eP(e.charCodeAt(o)),a=eP(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 Lt(...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 uc(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 xo(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 So=(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 fS=BigInt(0),dS=BigInt(1);function Uu(e,t=""){if(typeof e!=="boolean"){let r=t&&`"${t}" `;throw Error(r+"expected boolean, got type="+typeof e)}return e}function rP(e){if(typeof e==="bigint"){if(!hm(e))throw Error("positive bigint expected, got "+e)}else Wt(e);return e}function Mu(e){let t=rP(e).toString(16);return t.length&1?"0"+t:t}function nP(e){if(typeof e!=="string")throw Error("hex string expected, got "+typeof e);return e===""?fS:BigInt("0x"+e)}function wo(e){return nP(Rs(e))}function vo(e){return nP(Rs(gm(Ne(e)).reverse()))}function dc(e,t){Wt(t),e=rP(e);let r=Ps(e.toString(16).padStart(t*2,"0"));if(r.length!==t)throw Error("number too large");return r}function Fu(e,t){return dc(e,t).reverse()}function gm(e){return Uint8Array.from(e)}function _o(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 hm=(e)=>typeof e==="bigint"&&fS<=e;function VW(e,t,r){return hm(e)&&hm(t)&&hm(r)&&t<=e&&e<r}function Zu(e,t,r,i){if(!VW(t,r,i))throw Error("expected valid "+e+": "+r+" <= n < "+i+", got "+t)}function pS(e){let t;for(t=0;e>fS;e>>=dS,t+=1);return t}var Hu=(e)=>(dS<<BigInt(e))-dS;function iP(e,t,r){if(Wt(e,"hashLen"),Wt(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,Lt(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 Lt(...v)};return(b,v)=>{d(),m(b);let A=void 0;while(!(A=v(y())))m();return d(),A}}function zs(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 mS(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 Cr=BigInt(0),yr=BigInt(1),Ns=BigInt(2),aP=BigInt(3),cP=BigInt(4),lP=BigInt(5),WW=BigInt(7),uP=BigInt(8),GW=BigInt(9),dP=BigInt(16);function Tr(e,t){let r=e%t;return r>=Cr?r:t+r}function xn(e,t,r){let i=e;while(t-- >Cr)i*=i,i%=r;return i}function oP(e,t){if(e===Cr)throw Error("invert: expected non-zero number");if(t<=Cr)throw Error("invert: expected positive modulus, got "+t);let r=Tr(e,t),i=t,n=Cr,o=yr,s=yr,a=Cr;while(r!==Cr){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!==yr)throw Error("invert: does not exist");return Tr(n,t)}function hS(e,t,r){if(!e.eql(e.sqr(t),r))throw Error("Cannot find square root")}function fP(e,t){let r=(e.ORDER+yr)/cP,i=e.pow(t,r);return hS(e,i,t),i}function QW(e,t){let r=(e.ORDER-lP)/uP,i=e.mul(t,Ns),n=e.pow(i,r),o=e.mul(t,n),s=e.mul(e.mul(o,Ns),n),a=e.mul(o,e.sub(s,e.ONE));return hS(e,a,t),a}function YW(e){let t=ym(e),r=pP(e),i=r(t,t.neg(t.ONE)),n=r(t,i),o=r(t,t.neg(i)),s=(e+WW)/dP;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 hS(a,b,c),b}}function pP(e){if(e<aP)throw Error("sqrt is not defined for small field");let t=e-yr,r=0;while(t%Ns===Cr)t/=Ns,r++;let i=Ns,n=ym(e);while(sP(n,i)===1)if(i++>1000)throw Error("Cannot find square root: probably non-prime P");if(r===1)return fP;let o=n.pow(i,t),s=(t+yr)/Ns;return function(c,l){if(c.is0(l))return l;if(sP(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=yr<<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 XW(e){if(e%cP===aP)return fP;if(e%uP===lP)return QW;if(e%dP===GW)return YW(e);return pP(e)}var eG=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function gS(e){let t={ORDER:"bigint",BYTES:"number",BITS:"number"},r=eG.reduce((i,n)=>(i[n]="function",i),t);return zs(e,r),e}function tG(e,t,r){if(r<Cr)throw Error("invalid exponent, negatives unsupported");if(r===Cr)return e.ONE;if(r===yr)return t;let i=e.ONE,n=t;while(r>Cr){if(r&yr)i=e.mul(i,n);n=e.sqr(n),r>>=yr}return i}function Ku(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 sP(e,t){let r=(e.ORDER-yr)/Ns,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 rG(e,t){if(t!==void 0)Wt(t);let r=t!==void 0?t:e.toString(2).length,i=Math.ceil(r/8);return{nBitLength:r,nByteLength:i}}class mP{ORDER;BITS;BYTES;isLE;ZERO=Cr;ONE=yr;_lengths;_sqrt;_mod;constructor(e,t={}){if(e<=Cr)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}=rG(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 Tr(e,this.ORDER)}isValid(e){if(typeof e!=="bigint")throw Error("invalid field element: expected bigint, got "+typeof e);return Cr<=e&&e<this.ORDER}is0(e){return e===Cr}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&yr)===yr}neg(e){return Tr(-e,this.ORDER)}eql(e,t){return e===t}sqr(e){return Tr(e*e,this.ORDER)}add(e,t){return Tr(e+t,this.ORDER)}sub(e,t){return Tr(e-t,this.ORDER)}mul(e,t){return Tr(e*t,this.ORDER)}pow(e,t){return tG(this,e,t)}div(e,t){return Tr(e*oP(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 oP(e,this.ORDER)}sqrt(e){if(!this._sqrt)this._sqrt=XW(this.ORDER);return this._sqrt(this,e)}toBytes(e){return this.isLE?Fu(e,this.BYTES):dc(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?vo(e):wo(e);if(s)a=Tr(a,o);if(!t){if(!this.isValid(a))throw Error("invalid field element: outside of range 0..ORDER")}return a}invertBatch(e){return Ku(this,e)}cmov(e,t,r){return r?t:e}}function ym(e,t={}){return new mP(e,t)}function hP(e){if(typeof e!=="bigint")throw Error("field order must be bigint");let t=e.toString(2).length;return Math.ceil(t/8)}function yS(e){let t=hP(e);return t+Math.ceil(t/2)}function gP(e,t,r=!1){Ne(e);let i=e.length,n=hP(t),o=yS(t);if(i<16||i<o||i>1024)throw Error("expected "+o+"-1024 bytes of input, got "+i);let s=r?vo(e):wo(e),a=Tr(s,t-yr)+yr;return r?Fu(a,n):dc(a,n)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var fc=BigInt(0),Ds=BigInt(1);function Ju(e,t){let r=t.negate();return e?r:t}function wS(e,t){let r=Ku(e.Fp,t.map((i)=>i.Z));return t.map((i,n)=>e.fromAffine(i.toAffine(r[n])))}function SP(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw Error("invalid window size, expected [1.."+t+"], got W="+e)}function bS(e,t){SP(e,t);let r=Math.ceil(t/e)+1,i=2**(e-1),n=2**e,o=Hu(e),s=BigInt(e);return{windows:r,windowSize:i,mask:o,maxNumber:n,shiftBy:s}}function yP(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+=Ds;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 xS=new WeakMap,wP=new WeakMap;function SS(e){return wP.get(e)||1}function bP(e){if(e!==fc)throw Error("invalid wNAF")}class vS{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>fc){if(t&Ds)r=r.add(i);i=i.double(),t>>=Ds}return r}precomputeWindow(e,t){let{windows:r,windowSize:i}=bS(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=bS(e,this.bits);for(let s=0;s<o.windows;s++){let{nextN:a,offset:c,isZero:l,isNeg:u,isNegF:d,offsetF:p}=yP(r,s,o);if(r=a,l)n=n.add(Ju(d,t[p]));else i=i.add(Ju(u,t[c]))}return bP(r),{p:i,f:n}}wNAFUnsafe(e,t,r,i=this.ZERO){let n=bS(e,this.bits);for(let o=0;o<n.windows;o++){if(r===fc)break;let{nextN:s,offset:a,isZero:c,isNeg:l}=yP(r,o,n);if(r=s,c)continue;else{let u=t[a];i=i.add(l?u.negate():u)}}return bP(r),i}getPrecomputes(e,t,r){let i=xS.get(t);if(!i){if(i=this.precomputeWindow(t,e),e!==1){if(typeof r==="function")i=r(i);xS.set(t,i)}}return i}cached(e,t,r){let i=SS(e);return this.wNAF(i,this.getPrecomputes(i,e,r),t)}unsafe(e,t,r,i){let n=SS(e);if(n===1)return this._unsafeLadder(e,t,i);return this.wNAFUnsafe(n,this.getPrecomputes(n,e,r),t,i)}createCache(e,t){SP(t,this.bits),wP.set(e,t),xS.delete(e)}hasCache(e){return SS(e)!==1}}function vP(e,t,r,i){let n=t,o=e.ZERO,s=e.ZERO;while(r>fc||i>fc){if(r&Ds)o=o.add(n);if(i&Ds)s=s.add(n);n=n.double(),r>>=Ds,i>>=Ds}return{p1:o,p2:s}}function xP(e,t,r){if(t){if(t.ORDER!==e)throw Error("Field.ORDER must match order: Fp == p, Fn == n");return gS(t),t}else return ym(e,{isLE:r})}function _P(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>fc))throw Error(`CURVE.${c} must be positive bigint`)}let n=xP(t.p,r.Fp,i),o=xP(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 bm(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 Vu=BigInt(0),pc=BigInt(1),xm=BigInt(2);function nG(e){return zs(e,{adjustScalarBytes:"function",powPminus2:"function"}),Object.freeze({...e})}function kP(e){let t=nG(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||xo,l=a?255:448,u=a?32:56,d=a?BigInt(9):BigInt(5),p=a?BigInt(121665):BigInt(39081),m=a?xm**BigInt(254):xm**BigInt(447),y=a?BigInt(8)*xm**BigInt(251)-pc:BigInt(4)*xm**BigInt(445)-pc,g=m+y+pc,b=(I)=>Tr(I,r),v=A(d);function A(I){return Fu(b(I),u)}function T(I){let R=gm(Ne(I,u,"uCoordinate"));if(a)R[31]&=127;return b(vo(R))}function z(I){return vo(n(gm(Ne(I,u,"scalar"))))}function j(I,R){let O=X(T(R),z(I));if(O===Vu)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){Zu("u",I,Vu,r),Zu("scalar",R,m,g);let O=R,F=I,L=pc,V=Vu,_=I,te=pc,ue=Vu;for(let Se=BigInt(l-1);Se>=Vu;Se--){let Ee=O>>Se&pc;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,Dt=b(St*$e),hr=b(Xe*_e),Yr=Dt+hr,Xr=Dt-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:bm(P,Z),getSharedSecret:D,getPublicKey:Z,scalarMult:j,scalarMultBase:E,utils:N,GuBytes:v.slice(),lengths:M})}class _S{oHash;iHash;blockLen;outputLen;finished=!1;destroyed=!1;constructor(e,t){if(bn(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),Mr(i)}update(e){return Pi(this),this.iHash.update(e),this}digestInto(e){Pi(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 mc=(e,t,r)=>new _S(e,t).update(r).digest();mc.create=(e,t)=>new _S(e,t);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var EP=(e,t)=>(e+(e>=0?t:-t)/AP)/t;function iG(e,t,r){let[[i,n],[o,s]]=t,a=EP(s*e,r),c=EP(-n*e,r),l=e-a*i-c*o,u=-a*n-c*s,d=l<zi,p=u<zi;if(d)l=-l;if(p)u=-u;let m=Hu(Math.ceil(pS(r)/2))+hc;if(l<zi||l>=m||u<zi||u>=m)throw Error("splitScalar (endomorphism): failed, k="+e);return{k1neg:d,k1:l,k2neg:p,k2:u}}function ES(e){if(!["compact","recovered","der"].includes(e))throw Error('Signature format must be "compact", "recovered", or "der"');return e}function kS(e,t){let r={};for(let i of Object.keys(t))r[i]=e[i]===void 0?t[i]:e[i];if(Uu(r.lowS,"lowS"),Uu(r.prehash,"prehash"),r.format!==void 0)ES(r.format);return r}class IP extends Error{constructor(e=""){super(e)}}var ko={Err:IP,_tlv:{encode:(e,t)=>{let{Err:r}=ko;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=Mu(i);if(n.length/2&128)throw new r("tlv.encode: long form length too big");let o=i>127?Mu(n.length/2|128):"";return Mu(e)+o+n+t},decode(e,t){let{Err:r}=ko,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}=ko;if(e<zi)throw new t("integer: negative integers are not allowed");let r=Mu(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}=ko;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 wo(e)}},toSig(e){let{Err:t,_int:r,_tlv:i}=ko,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}=ko,i=t.encode(2,r.encode(e.r)),n=t.encode(2,r.encode(e.s)),o=i+n;return t.encode(48,o)}},zi=BigInt(0),hc=BigInt(1),AP=BigInt(2),Sm=BigInt(3),oG=BigInt(4);function IS(e,t={}){let r=_P("weierstrass",e,t),{Fp:i,Fn:n}=r,o=r.CURVE,{h:s,n:a}=o;zs(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=CP(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(Uu(I,"isCompressed"),I){u();let L=!i.isOdd(O);return Lt(TP(L),F)}else return Lt(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,Sm),oG),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 iG(P,c.basises,n.ORDER)}let E=mS((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=mS((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=Ju(R,N),I=Ju(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(Ps(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(Sm);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,Sm),{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,Sm),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)=>wS(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 wS(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===zi||I.is0())return H.ZERO;if(P===hc)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:_}=vP(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===hc)return!0;if(P)return P(H,this);return M.unsafe(this,a).is0()}clearCofactor(){let{clearCofactor:P}=t;if(s===hc)return this;if(P)return P(H,this);return this.multiplyUnsafe(s)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}toBytes(P=!0){return Uu(P,"isCompressed"),this.assertValidity(),m(H,this,P)}toHex(P=!0){return Rs(this.toBytes(P))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let X=n.BITS,M=new vS(H,t.endo?Math.ceil(X/2):X);return H.BASE.precompute(8),H}function TP(e){return Uint8Array.of(e?2:3)}function CP(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function sG(e,t={}){let{Fn:r}=e,i=t.randomBytes||xo,n=Object.assign(CP(e.Fp,r),{seed:yS(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 gP(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(!lc(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=bm(a,c);return Object.freeze({getPublicKey:c,getSharedSecret:u,keygen:p,Point:e,utils:d,lengths:n})}function AS(e,t,r={}){bn(t),zs(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),r=Object.assign({},r);let i=r.randomBytes||xo,n=r.hmac||((I,R)=>mc(t,I,R)),{Fp:o,Fn:s}=e,{ORDER:a,BITS:c}=s,{keygen:l,getPublicKey:u,getSharedSecret:d,utils:p,lengths:m}=sG(e,r),y={prehash:!0,lowS:typeof r.lowS==="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},g=a*AP<o.ORDER;function b(I){let R=a>>hc;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){ES(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}=ko.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(Ps(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(Lt(TP((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(ES(I),I==="der")return Ps(ko.hexFromSig(this));let{r:R,s:O}=this,F=s.toBytes(R),L=s.toBytes(O);if(I==="recovered")return A(),Lt(Uint8Array.of(this.assertRecovery()),F,L);return Lt(F,L)}toHex(I){return Rs(this.toBytes(I))}}let j=r.bits2int||function(R){if(R.length>8192)throw Error("input is too large");let O=wo(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=Hu(c);function D(I){return Zu("num < 2^"+c,I,zi,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}=kS(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=Lt(...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===zi)return;let Xe=s.create(_e*s.create(Se+Ve*te));if(Xe===zi)return;let St=(ze.x===Ve?0:2)|Number(ze.y&hc),Dt=Xe;if(F&&b(Xe))Dt=s.neg(Xe),St^=1;return new z(Ve,Dt,g?void 0:St)}return{seed:C,k2sig:Ee}}function M(I,R,O={}){let{seed:F,k2sig:L}=X(I,R,O);return iP(t.outputLen,s.BYTES,n)(F,L).toBytes(O.format)}function P(I,R,O,F={}){let{lowS:L,prehash:V,format:_}=kS(F,y);if(O=Ne(O,void 0,"publicKey"),R=H(R,V),!lc(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}=kS(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 $P(e,t,r){return e&t^~e&r}function OP(e,t,r){return e&t^e&r^t&r}class wm{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=mm(this.buffer)}update(e){Pi(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=mm(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){Pi(this),fm(e,this),this.finished=!0;let{buffer:t,view:r,blockLen:i,isLE:n}=this,{pos:o}=this;if(t[o++]=128,Mr(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=mm(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 Ni=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var or=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]);var vm=BigInt(4294967295),RP=BigInt(32);function aG(e,t=!1){if(t)return{h:Number(e&vm),l:Number(e>>RP&vm)};return{h:Number(e>>RP&vm)|0,l:Number(e&vm)|0}}function _m(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}=aG(e[o],t);[i[o],n[o]]=[s,a]}return[i,n]}var TS=(e,t,r)=>e>>>r,CS=(e,t,r)=>e<<32-r|t>>>r,Ls=(e,t,r)=>e>>>r|t<<32-r,Bs=(e,t,r)=>e<<32-r|t>>>r,Wu=(e,t,r)=>e<<64-r|t>>>r-32,Gu=(e,t,r)=>e>>>r-32|t<<64-r;var PP=(e,t,r)=>e<<r|t>>>32-r,zP=(e,t,r)=>t<<r|e>>>32-r,NP=(e,t,r)=>t<<r-32|e>>>64-r,DP=(e,t,r)=>e<<r-32|t>>>64-r;function ri(e,t,r,i){let n=(t>>>0)+(i>>>0);return{h:e+r+(n/4294967296|0)|0,l:n|0}}var LP=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),BP=(e,t,r,i)=>t+r+i+(e/4294967296|0)|0,jP=(e,t,r,i)=>(e>>>0)+(t>>>0)+(r>>>0)+(i>>>0),qP=(e,t,r,i,n)=>t+r+i+n+(e/4294967296|0)|0,UP=(e,t,r,i,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(i>>>0)+(n>>>0),MP=(e,t,r,i,n,o)=>t+r+i+n+o+(e/4294967296|0)|0;var lG=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]),Eo=new Uint32Array(64);class FP extends wm{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)Eo[u]=e.getUint32(t,!1);for(let u=16;u<64;u++){let d=Eo[u-15],p=Eo[u-2],m=Nn(d,7)^Nn(d,18)^d>>>3,y=Nn(p,17)^Nn(p,19)^p>>>10;Eo[u]=y+Eo[u-7]+m+Eo[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=Nn(s,6)^Nn(s,11)^Nn(s,25),p=l+d+$P(s,a,c)+lG[u]+Eo[u]|0,y=(Nn(r,2)^Nn(r,13)^Nn(r,22))+OP(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(){Mr(Eo)}destroy(){this.set(0,0,0,0,0,0,0,0),Mr(this.buffer)}}class ZP extends FP{A=Ni[0]|0;B=Ni[1]|0;C=Ni[2]|0;D=Ni[3]|0;E=Ni[4]|0;F=Ni[5]|0;G=Ni[6]|0;H=Ni[7]|0;constructor(){super(32)}}var HP=(()=>_m(["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))))(),uG=(()=>HP[0])(),dG=(()=>HP[1])(),Io=new Uint32Array(80),Ao=new Uint32Array(80);class KP extends wm{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)Io[A]=e.getUint32(t),Ao[A]=e.getUint32(t+=4);for(let A=16;A<80;A++){let T=Io[A-15]|0,z=Ao[A-15]|0,j=Ls(T,z,1)^Ls(T,z,8)^TS(T,z,7),E=Bs(T,z,1)^Bs(T,z,8)^CS(T,z,7),Z=Io[A-2]|0,D=Ao[A-2]|0,H=Ls(Z,D,19)^Wu(Z,D,61)^TS(Z,D,6),X=Bs(Z,D,19)^Gu(Z,D,61)^CS(Z,D,6),M=jP(E,X,Ao[A-7],Ao[A-16]),P=qP(M,j,H,Io[A-7],Io[A-16]);Io[A]=P|0,Ao[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=Ls(u,d,14)^Ls(u,d,18)^Wu(u,d,41),z=Bs(u,d,14)^Bs(u,d,18)^Gu(u,d,41),j=u&p^~u&y,E=d&m^~d&g,Z=UP(v,z,E,dG[A],Ao[A]),D=MP(Z,b,T,j,uG[A],Io[A]),H=Z|0,X=Ls(r,i,28)^Wu(r,i,34)^Wu(r,i,39),M=Bs(r,i,28)^Gu(r,i,34)^Gu(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}=ri(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=LP(H,M,N);r=BP(I,D,X,P),i=I|0}({h:r,l:i}=ri(this.Ah|0,this.Al|0,r|0,i|0)),{h:n,l:o}=ri(this.Bh|0,this.Bl|0,n|0,o|0),{h:s,l:a}=ri(this.Ch|0,this.Cl|0,s|0,a|0),{h:c,l}=ri(this.Dh|0,this.Dl|0,c|0,l|0),{h:u,l:d}=ri(this.Eh|0,this.El|0,u|0,d|0),{h:p,l:m}=ri(this.Fh|0,this.Fl|0,p|0,m|0),{h:y,l:g}=ri(this.Gh|0,this.Gl|0,y|0,g|0),{h:b,l:v}=ri(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(){Mr(Io,Ao)}destroy(){Mr(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class JP extends KP{Ah=or[0]|0;Al=or[1]|0;Bh=or[2]|0;Bl=or[3]|0;Ch=or[4]|0;Cl=or[5]|0;Dh=or[6]|0;Dl=or[7]|0;Eh=or[8]|0;El=or[9]|0;Fh=or[10]|0;Fl=or[11]|0;Gh=or[12]|0;Gl=or[13]|0;Hh=or[14]|0;Hl=or[15]|0;constructor(){super(48)}}var km=uc(()=>new ZP,So(1));var VP=uc(()=>new JP,So(2));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var fG=BigInt(1),WP=BigInt(2),pG=BigInt(3),mG=BigInt(5),Z1e=BigInt(8),GP=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed");function hG(e){let t=BigInt(10),r=BigInt(20),i=BigInt(40),n=BigInt(80),o=GP,a=e*e%o*e%o,c=xn(a,WP,o)*a%o,l=xn(c,fG,o)*e%o,u=xn(l,mG,o)*l%o,d=xn(u,t,o)*u%o,p=xn(d,r,o)*d%o,m=xn(p,i,o)*p%o,y=xn(m,n,o)*m%o,g=xn(y,n,o)*m%o,b=xn(g,t,o)*u%o;return{pow_p_5_8:xn(b,WP,o)*e%o,b2:a}}function gG(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var QP=(()=>{let e=GP;return kP({P:e,type:"x25519",powPminus2:(t)=>{let{pow_p_5_8:r,b2:i}=hG(t);return Tr(xn(r,pG,e)*i,e)},adjustScalarBytes:gG})})();/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var yG=(()=>({p:BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),h:BigInt(1),a:BigInt("0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc"),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")}))(),bG=(()=>({p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff"),n:BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973"),h:BigInt(1),a:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000fffffffc"),b:BigInt("0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef"),Gx:BigInt("0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7"),Gy:BigInt("0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f")}))();var xG=IS(yG),$S=AS(xG,km);var SG=IS(bG),YP=AS(SG,VP);function ez(e,t,r){if(bn(e),r===void 0)r=new Uint8Array(e.outputLen);return mc(e,r,t)}var OS=Uint8Array.of(0),XP=Uint8Array.of();function tz(e,t,r,i=32){bn(e),Wt(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=XP;else Ne(r,void 0,"info");let s=new Uint8Array(o*n),a=mc.create(e,t),c=a._cloneInto(),l=new Uint8Array(a.outputLen);for(let u=0;u<o;u++)OS[0]=u+1,c.update(u===0?XP:l).update(r).update(OS).digestInto(l),s.set(l,n*u),a._cloneInto(c);return a.destroy(),c.destroy(),Mr(l,OS),s.slice(0,i)}var wG=BigInt(0),Qu=BigInt(1),vG=BigInt(2),_G=BigInt(7),kG=BigInt(256),EG=BigInt(113),iz=[],oz=[],sz=[];for(let e=0,t=Qu,r=1,i=0;e<24;e++){[r,i]=[i,(2*r+3*i)%5],iz.push(2*(5*i+r)),oz.push((e+1)*(e+2)/2%64);let n=wG;for(let o=0;o<7;o++)if(t=(t<<Qu^(t>>_G)*EG)%kG,t&vG)n^=Qu<<(Qu<<BigInt(o))-Qu;sz.push(n)}var az=_m(sz,!0),IG=az[0],AG=az[1],rz=(e,t,r)=>r>32?NP(e,t,r):PP(e,t,r),nz=(e,t,r)=>r>32?DP(e,t,r):zP(e,t,r);function TG(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=rz(l,u,1)^r[a],p=nz(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=oz[s],c=rz(n,o,a),l=nz(n,o,a),u=iz[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]^=IG[i],e[1]^=AG[i]}Mr(r)}class Em{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,Wt(r,"outputLen"),!(0<e&&e<200))throw Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=pm(this.state)}clone(){return this._cloneInto()}keccak(){uS(this.state32),TG(this.state32,this.rounds),uS(this.state32),this.posOut=0,this.pos=0}update(e){Pi(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){Pi(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 Wt(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(fm(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,Mr(this.state)}_cloneInto(e){let{blockLen:t,suffix:r,outputLen:i,rounds:n,enableXOF:o}=this;return e||=new Em(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 cz=(e,t,r,i={})=>uc(()=>new Em(t,e,r),i);var js=cz(6,136,32,So(8));var lz=cz(6,72,64,So(10));var uz=(e,t,r,i={})=>uc((n={})=>new Em(t,e,n.dkLen===void 0?r:n.dkLen,!0),i),dz=uz(31,168,16,So(11)),ni=uz(31,136,32,So(12));function RS(e){if(!Number.isSafeInteger(e)||e<0||e>4294967295)throw Error("wrong u32 integer:"+e);return e}function pz(e){return RS(e),(e&e-1)===0&&e!==0}function PS(e,t){RS(e);let r=0;for(let i=0;i<t;i++,e>>>=1)r=r<<1|e&1;return r}function mz(e){return RS(e),31-Math.clz32(e)}function fz(e){let t=e.length;if(t<2||!pz(t))throw Error("n must be a power of 2 and greater than 1. Got "+t);let r=mz(t);for(let i=0;i<t;i++){let n=PS(i,r);if(i<n){let o=e[i];e[i]=e[n],e[n]=o}}return e}var zS=(e,t)=>{let{N:r,roots:i,dit:n,invertButterflies:o=!1,skipStages:s=0,brp:a=!0}=t,c=mz(r);if(!pz(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)fz(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)fz(u);return u}};/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */var ii=xo;function Im(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 hz(e){return Uint8Array.from(e)}function qs(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 Am(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 Ft(...e){for(let t of e)if(Array.isArray(t))for(let r of t)r.fill(0);else t.fill(0)}function NS(e){return(1<<e)-1}var oIe=Uint8Array.of();/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */var gz=(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=PS(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=zS(p,{dit:!1,...m}),g=zS(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=NS(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&NS(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}}}}},CG=(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(),Ft(o,i)}}},yz=CG(dz);/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */var br=256,Di=3329,$G=3303,OG=17,{mod:ed,nttZetas:RG,NTT:Us,bitsCoder:PG}=gz({N:br,Q:Di,F:$G,ROOT_OF_UNITY:OG,newPoly:(e)=>new Uint16Array(e),brvBits:7,isKyber:!0}),DS={512:{N:br,Q:Di,K:2,ETA1:3,ETA2:2,du:10,dv:4,RBGstrength:128},768:{N:br,Q:Di,K:3,ETA1:2,ETA2:2,du:10,dv:4,RBGstrength:192},1024:{N:br,Q:Di,K:4,ETA1:2,ETA2:2,du:11,dv:5,RBGstrength:256}},zG=(e)=>{if(e>=12)return{encode:(r)=>r,decode:(r)=>r};let t=2**(e-1);return{encode:(r)=>((r<<e)+Di/2)/Di,decode:(r)=>r*Di+t>>>e}},Yu=(e)=>PG(e,zG(e));function Ms(e,t){for(let r=0;r<br;r++)e[r]=ed(e[r]+t[r])}function NG(e,t){for(let r=0;r<br;r++)e[r]=ed(e[r]-t[r])}function DG(e,t,r,i,n){let o=ed(t*i*n+e*r),s=ed(e*i+t*r);return{c0:o,c1:s}}function Tm(e,t){for(let r=0;r<br/2;r++){let i=RG[64+(r>>1)];if(r&1)i=-i;let{c0:n,c1:o}=DG(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 bz(e){let t=new Uint16Array(br);for(let r=0;r<br;){let i=e();if(i.length%3)throw Error("SampleNTT: unaligned block");for(let n=0;r<br&&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<Di)t[r++]=o;if(r<br&&s<Di)t[r++]=s}}return t}function Xu(e,t,r,i){let n=e(i*br/4,t,r),o=new Uint16Array(br),s=pm(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++]=ed(d-u),u=0,a=0}if(a)throw Error(`sampleCBD: leftover bits: ${a}`);return o}var LG=(e)=>{let{K:t,PRF:r,XOF:i,HASH512:n,ETA1:o,ETA2:s,du:a,dv:c}=e,l=Yu(1),u=Yu(c),d=Yu(a),p=qs("publicKey",Am(Yu(12),t),32),m=Am(Yu(12),t),y=qs("ciphertext",Am(d,t),u),g=qs("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(Us.encode(Xu(r,z,H,o)));let Z=i(T);for(let H=0;H<t;H++){let X=Us.encode(Xu(r,z,t+H,o));for(let M=0;M<t;M++){let P=bz(Z.get(M,H));Ms(X,Tm(P,j[M]))}E.push(X)}Z.clean();let D={publicKey:p.encode([E,T]),secretKey:m.encode(j)};return Ft(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(Us.encode(Xu(r,A,M,o)));let E=i(z),Z=new Uint16Array(br),D=[];for(let M=0;M<t;M++){let P=Xu(r,A,t+M,s),N=new Uint16Array(br);for(let I=0;I<t;I++){let R=bz(E.get(M,I));Ms(N,Tm(R,j[I]))}Ms(P,Us.decode(N)),D.push(P),Ms(Z,Tm(T[M],j[M])),Ft(N)}E.clean();let H=Xu(r,A,2*t,s);Ms(H,Us.decode(Z));let X=l.decode(v);return Ms(X,H),Ft(T,j,Z,H),y.encode([D,X])},decrypt:(b,v)=>{let[A,T]=y.decode(b),z=m.decode(v),j=new Uint16Array(br);for(let E=0;E<t;E++)Ms(j,Tm(z[E],Us.encode(A[E])));return NG(T,Us.decode(j)),Ft(j,z,A),l.encode(T)}}};function LS(e){let t=LG(e),{HASH256:r,HASH512:i,KDF:n}=e,{secretCoder:o,lengths:s}=t,a=qs("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=ii(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 Ft(p,m),{publicKey:d,secretKey:y}},getPublicKey:(u)=>{let[d,p,m,y]=a.decode(u);return Uint8Array.from(p)},encapsulate:(u,d=ii(32))=>{Ne(u,s.publicKey,"publicKey"),Ne(d,32,"message");let p=u.subarray(0,384*e.K),m=o.encode(o.decode(hz(p)));if(!Im(m,p))throw Ft(m),Error("ML-KEM.encapsulate: wrong publicKey modulus");Ft(m);let y=i.create().update(d).update(r(u)).digest(),g=t.encrypt(u,d,y.subarray(32,64));return Ft(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(!Im(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=Im(u,E),D=n.create({dkLen:32}).update(A).update(u).digest();return Ft(T,E,!Z?j:D),Z?j:D}}}function BG(e,t,r){return ni.create({dkLen:e}).update(t).update(new Uint8Array([r])).digest()}var BS={HASH256:js,HASH512:lz,KDF:ni,XOF:yz,PRF:BG},gIe=LS({...BS,...DS[512]}),td=LS({...BS,...DS[768]}),xz=LS({...BS,...DS[1024]});/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */function jG(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=ii(r.seed))=>{Ne(s,r.seed,"seed");let a=o.isLE?vo(s):wo(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 jS(e,t=!1){let r=jG(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=ii(e.lengths.seed)){let o=this.keygen(n).secretKey,s=this.decapsulate(i,o),a=e.getPublicKey(o);return Ft(o),{sharedSecret:s,cipherText:a}},decapsulate(i,n){let o=e.getSharedSecret(n,i);return e.lengths.publicKeyHasPrefix?o.subarray(1):o}}}function rd(e,t){return qs(t,...e.map((r)=>{if(typeof r.lengths[t]!=="number")throw Error("wrong length: "+t);return r.lengths[t]}))}function qS(e){return(t,r)=>e(t,{dkLen:r})}function qG(e,t,...r){let i=rd(r,"seed"),n=rd(r,"publicKey");if(e===void 0)e=i.bytesLen;Wt(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=ii(e)){let{publicKey:a,secretKey:c}=o(s),l=n.encode(a);return Ft(a),Ft(c),{secretKey:s,publicKey:l}},expandDecapsulationKey:o,realSeedLen:e}}function Cm(e,t,r,i,...n){let o=qG(e,r,...n),s=rd(n,"cipherText"),a=rd(n,"publicKey"),c=rd(n,"msg");if(t===void 0)t=c.bytesLen;return Wt(t),{lengths:{...o.info.lengths,msg:t,msgRand:c.bytesLen,cipherText:s.bytesLen},getPublicKey:o.getPublicKey,keygen:o.keygen,encapsulate(l,u=ii(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 Ft(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 Sz(e,t,r,i,n){return bn(i),bn(n),Cm(32,32,qS(i),(o,s,a)=>n(Lt(a[0],a[1],s[1],o[1],_o(e))),t,r)}var AIe=Sz("QSF-KEM(ML-KEM-768,P-256)-XOF(SHAKE256)-KDF(SHA3-256)",td,jS($S,!0),ni,js),TIe=Sz("QSF-KEM(ML-KEM-1024,P-384)-XOF(SHAKE256)-KDF(SHA3-256)",xz,jS(YP,!0),ni,js);function UG(e,t,r,i,n){return bn(i),bn(n),Cm(32,32,qS(i),(o,s,a)=>{let c=Lt(a[0],a[1],s[0],o[0],s[1],o[1],_o(e)),l=32,u=Lt(_o("hybrid_prk"),c),d=ez(n,u),p=Lt(dc(32,2),_o("shared_secret"),_o("")),m=tz(n,d,p,32);return Ft(d,p,u,c),m},t,r)}var wz=jS(QP),CIe=UG("KitchenSink-KEM(ML-KEM-768,X25519)-XOF(SHAKE256)-KDF(HKDF-SHA-256)",td,wz,ni,km),MG=(()=>Cm(32,32,qS(ni),(e,t,r)=>js(Lt(r[0],r[1],t[1],e[1],_o("\\.//^\\"))),td,wz))();function FG(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=ii(i)){return Ne(s,i,"seed"),o(s)},getPublicKey(s){return e.getPublicKey(s,!1)},encapsulate(s,a=ii(i)){Ne(a,i,"rand");let{secretKey:c}=o(a),l=this.decapsulate(s,c),u=e.getPublicKey(c,!1);return Ft(c),{sharedSecret:l,cipherText:u}},decapsulate(s,a){return e.getSharedSecret(a,s).subarray(1)}}}function ZG(e,t,r,i){let{secretKey:n,publicKeyUncompressed:o}=r.lengths;if(!n||!o)throw Error("wrong curve");let s=FG(r,n,o,i),a=64,c=a+i;return Cm(32,32,(l)=>{Ne(l,32);let u=ni(l,{dkLen:c}),d=u.subarray(0,a),p=u.subarray(a,c);return Lt(d,p)},(l,u,d)=>js(Lt(d[0],d[1],u[1],l[1],_o(e))),t,s)}var HG=(()=>ZG("MLKEM768-P256",td,$S,128))();var $m=MG,vz=HG;/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var ct=(e,t,r)=>rr(e,t,r),MS=Ct,gc=em,sr=(...e)=>Hx(...e),yc=(e)=>Pu(e),bc=Mx,xc=(e)=>Ci(e),Rm=BigInt(0),US=BigInt(1);function Li(e,t=""){if(typeof e!=="boolean"){let r=t&&`"${t}" `;throw TypeError(r+"expected boolean, got type="+typeof e)}return e}function Pm(e){if(typeof e==="bigint"){if(!Om(e))throw RangeError("positive bigint expected, got "+e)}else MS(e);return e}function oi(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 nd(e){let t=Pm(e).toString(16);return t.length&1?"0"+t:t}function _z(e){if(typeof e!=="string")throw TypeError("hex string expected, got "+typeof e);return e===""?Rm:BigInt("0x"+e)}function Fs(e){return _z(em(e))}function Dn(e){return _z(em(To(rr(e)).reverse()))}function zm(e,t){if(Ct(t),t===0)throw RangeError("zero length");e=Pm(e);let r=e.toString(16);if(r.length>t*2)throw RangeError("number too large");return Pu(r.padStart(t*2,"0"))}function id(e,t){return zm(e,t).reverse()}function kz(e,t){if(e=ct(e),t=ct(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 To(e){return Uint8Array.from(ct(e))}function Nm(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 Om=(e)=>typeof e==="bigint"&&Rm<=e;function KG(e,t,r){return Om(e)&&Om(t)&&Om(r)&&t<=e&&e<r}function Bi(e,t,r,i){if(!KG(t,r,i))throw RangeError("expected valid "+e+": "+r+" <= n < "+i+", got "+t)}function Sc(e){if(e<Rm)throw Error("expected non-negative bigint, got "+e);let t;for(t=0;e>Rm;e>>=US,t+=1);return t}var od=(e)=>(US<<BigInt(e))-US;function Ez(e,t,r){if(Ct(e,"hashLen"),Ct(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,sr(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 sr(...v)};return(b,v)=>{d(),m(b);let A=void 0;while((A=v(y()))===void 0)m();return d(),A}}function Sn(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 FS=()=>{throw Error("not implemented")};/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var ar=BigInt(0),kt=BigInt(1),Zs=BigInt(2),Cz=BigInt(3),$z=BigInt(4),Oz=BigInt(5),JG=BigInt(7),Rz=BigInt(8),VG=BigInt(9),Pz=BigInt(16);function gt(e,t){if(t<=ar)throw Error("mod: expected positive modulus, got "+t);let r=e%t;return r>=ar?r:t+r}function wn(e,t,r){if(t<ar)throw Error("pow2: expected non-negative exponent, got "+t);let i=e;while(t-- >ar)i*=i,i%=r;return i}function Iz(e,t){if(e===ar)throw Error("invert: expected non-zero number");if(t<=ar)throw Error("invert: expected positive modulus, got "+t);let r=gt(e,t),i=t,n=ar,o=kt,s=kt,a=ar;while(r!==ar){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!==kt)throw Error("invert: does not exist");return gt(n,t)}function ZS(e,t,r){let i=e;if(!i.eql(i.sqr(t),r))throw Error("Cannot find square root")}function zz(e,t){let r=e,i=(r.ORDER+kt)/$z,n=r.pow(t,i);return ZS(r,n,t),n}function WG(e,t){let r=e,i=(r.ORDER-Oz)/Rz,n=r.mul(t,Zs),o=r.pow(n,i),s=r.mul(t,o),a=r.mul(r.mul(s,Zs),o),c=r.mul(s,r.sub(a,r.ONE));return ZS(r,c,t),c}function GG(e){let t=Dm(e),r=Nz(e),i=r(t,t.neg(t.ONE)),n=r(t,i),o=r(t,t.neg(i)),s=(e+JG)/Pz;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 ZS(l,v,c),v}}function Nz(e){if(e<Cz)throw Error("sqrt is not defined for small field");let t=e-kt,r=0;while(t%Zs===ar)t/=Zs,r++;let i=Zs,n=Dm(e);while(Az(n,i)===1)if(i++>1000)throw Error("Cannot find square root: probably non-prime P");if(r===1)return zz;let o=n.pow(i,t),s=(t+kt)/Zs;return function(c,l){let u=c;if(u.is0(l))return l;if(Az(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=kt<<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 QG(e){if(e%$z===Cz)return zz;if(e%Rz===Oz)return WG;if(e%Pz===VG)return GG(e);return Nz(e)}var ji=(e,t)=>(gt(e,t)&kt)===kt,YG=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function HS(e){let t={ORDER:"bigint",BYTES:"number",BITS:"number"},r=YG.reduce((i,n)=>(i[n]="function",i),t);if(Sn(e,r),oi(e.BYTES,"BYTES"),oi(e.BITS,"BITS"),e.BYTES<1||e.BITS<1)throw Error("invalid field: expected BYTES/BITS > 0");if(e.ORDER<=kt)throw Error("invalid field: expected ORDER > 1, got "+e.ORDER);return e}function XG(e,t,r){let i=e;if(r<ar)throw Error("invalid exponent, negatives unsupported");if(r===ar)return i.ONE;if(r===kt)return t;let n=i.ONE,o=t;while(r>ar){if(r&kt)n=i.mul(n,o);o=i.sqr(o),r>>=kt}return n}function sd(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 Az(e,t){let r=e,i=(r.ORDER-kt)/Zs,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 eQ(e,t){if(t!==void 0)MS(t);if(e<=ar)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=Sc(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 Tz=new WeakMap;class KS{ORDER;BITS;BYTES;isLE;ZERO=ar;ONE=kt;_lengths;_mod;constructor(e,t={}){if(e<=kt)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}=eQ(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 ar<=e&&e<this.ORDER}is0(e){return e===ar}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&kt)===kt}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 XG(this,e,t)}div(e,t){return gt(e*Iz(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 Iz(e,this.ORDER)}sqrt(e){let t=Tz.get(this);if(!t)Tz.set(this,t=QG(this.ORDER));return t(this,e)}toBytes(e){return this.isLE?id(e,this.BYTES):zm(e,this.BYTES)}fromBytes(e,t=!1){ct(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?Dn(e):Fs(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 sd(this,e)}cmov(e,t,r){return Li(r,"condition"),r?t:e}}Object.freeze(KS.prototype);function Dm(e,t={}){return new KS(e,t)}function Dz(e){if(typeof e!=="bigint")throw Error("field order must be bigint");if(e<=kt)throw Error("field order must be greater than 1");let t=Sc(e-kt);return Math.ceil(t/8)}function JS(e){let t=Dz(e);return t+Math.ceil(t/2)}function Lz(e,t,r=!1){ct(e);let i=e.length,n=Dz(t),o=Math.max(JS(t),16);if(i<o||i>1024)throw Error("expected "+o+"-1024 bytes of input, got "+i);let s=r?Dn(e):Fs(e),a=gt(s,t-kt)+kt;return r?id(a,n):zm(a,n)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var wc=BigInt(0),Hs=BigInt(1);function ad(e,t){let r=t.negate();return e?r:t}function Ks(e,t){let r=sd(e.Fp,t.map((i)=>i.Z));return t.map((i,n)=>e.fromAffine(i.toAffine(r[n])))}function Uz(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw Error("invalid window size, expected [1.."+t+"], got W="+e)}function VS(e,t){Uz(e,t);let r=Math.ceil(t/e)+1,i=2**(e-1),n=2**e,o=od(e),s=BigInt(e);return{windows:r,windowSize:i,mask:o,maxNumber:n,shiftBy:s}}function Bz(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+=Hs;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 WS=new WeakMap,Mz=new WeakMap;function GS(e){return Mz.get(e)||1}function jz(e){if(e!==wc)throw Error("invalid wNAF")}class cd{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>wc){if(t&Hs)r=r.add(i);i=i.double(),t>>=Hs}return r}precomputeWindow(e,t){let{windows:r,windowSize:i}=VS(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=VS(e,this.bits);for(let s=0;s<o.windows;s++){let{nextN:a,offset:c,isZero:l,isNeg:u,isNegF:d,offsetF:p}=Bz(r,s,o);if(r=a,l)n=n.add(ad(d,t[p]));else i=i.add(ad(u,t[c]))}return jz(r),{p:i,f:n}}wNAFUnsafe(e,t,r,i=this.ZERO){let n=VS(e,this.bits);for(let o=0;o<n.windows;o++){if(r===wc)break;let{nextN:s,offset:a,isZero:c,isNeg:l}=Bz(r,o,n);if(r=s,c)continue;else{let u=t[a];i=i.add(l?u.negate():u)}}return jz(r),i}getPrecomputes(e,t,r){let i=WS.get(t);if(!i){if(i=this.precomputeWindow(t,e),e!==1){if(typeof r==="function")i=r(i);WS.set(t,i)}}return i}cached(e,t,r){let i=GS(e);return this.wNAF(i,this.getPrecomputes(i,e,r),t)}unsafe(e,t,r,i){let n=GS(e);if(n===1)return this._unsafeLadder(e,t,i);return this.wNAFUnsafe(n,this.getPrecomputes(n,e,r),t,i)}createCache(e,t){Uz(t,this.bits),Mz.set(e,t),WS.delete(e)}hasCache(e){return GS(e)!==1}}function Fz(e,t,r,i){let n=t,o=e.ZERO,s=e.ZERO;while(r>wc||i>wc){if(r&Hs)o=o.add(n);if(i&Hs)s=s.add(n);n=n.double(),r>>=Hs,i>>=Hs}return{p1:o,p2:s}}function qz(e,t,r){if(t){if(t.ORDER!==e)throw Error("Field.ORDER must match order: Fp == p, Fn == n");return HS(t),t}else return Dm(e,{isLE:r})}function Lm(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>wc))throw Error(`CURVE.${c} must be positive bigint`)}let n=qz(t.p,r.Fp,i),o=qz(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 ld(e,t){return function(i){let n=e(i);return{secretKey:n,publicKey:t(n)}}}function ud(e,t){if(oi(e),oi(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 tQ(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 rQ(e){if(!bc(e)&&typeof e!=="string")throw Error("DST must be Uint8Array or ascii string");let t=typeof e==="string"?Nm(e):e;if(t.length===0)throw Error("DST must be non-empty");return t}function QS(e,t,r,i){if(ct(e),oi(r),t=rQ(t),t.length>255)t=i(sr(Nm("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=sr(t,ud(t.length,1)),c=new Uint8Array(o),l=ud(r,2),u=Array(s),d=i(sr(c,e,l,ud(0,1),a));u[0]=i(sr(d,ud(1,1),a));for(let m=1;m<s;m++){let y=[tQ(d,u[m-1]),ud(m+1,1),a];u[m]=i(sr(...y))}return sr(...u).slice(0,r)}var Zz="HashToScalar-";/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var Hz=(e,t)=>(e+(e>=0?t:-t)/Jz)/t;function nQ(e,t,r){Bi("scalar",e,si,r);let[[i,n],[o,s]]=t,a=Hz(s*e,r),c=Hz(-n*e,r),l=e-a*i-c*o,u=-a*n-c*s,d=l<si,p=u<si;if(d)l=-l;if(p)u=-u;let m=od(Math.ceil(Sc(r)/2))+Co;if(l<si||l>=m||u<si||u>=m)throw Error("splitScalar (endomorphism): failed for k");return{k1neg:d,k1:l,k2neg:p,k2:u}}function XS(e){if(!["compact","recovered","der"].includes(e))throw Error('Signature format must be "compact", "recovered", or "der"');return e}function YS(e,t){Sn(e);let r={};for(let i of Object.keys(t))r[i]=e[i]===void 0?t[i]:e[i];if(Li(r.lowS,"lowS"),Li(r.prehash,"prehash"),r.format!==void 0)XS(r.format);return r}class Kz extends Error{constructor(e=""){super(e)}}var Ln={Err:Kz,_tlv:{encode:(e,t)=>{let{Err:r}=Ln;if(oi(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=nd(i);if(n.length/2&128)throw new r("tlv.encode: long form length too big");let o=i>127?nd(n.length/2|128):"";return nd(e)+o+n+t},decode(e,t){let{Err:r}=Ln;t=ct(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}=Ln;if(Pm(e),e<si)throw new t("integer: negative integers are not allowed");let r=nd(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}=Ln;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 Fs(e)}},toSig(e){let{Err:t,_int:r,_tlv:i}=Ln,n=ct(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}=Ln,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(Ln._tlv);Object.freeze(Ln._int);Object.freeze(Ln);var si=BigInt(0),Co=BigInt(1),Jz=BigInt(2),Bm=BigInt(3),iQ=BigInt(4);function Vz(e,t={}){let r=Lm("weierstrass",e,t),i=r.Fp,n=r.Fn,o=r.CURVE,{h:s,n:a}=o;Sn(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=Gz(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(Li(N,"isCompressed"),N){d();let F=!i.isOdd(R);return sr(Wz(F),O)}else return sr(Uint8Array.of(4),O,i.toBytes(R))}function m(M){ct(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,Bm),iQ),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 nQ(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=ad(I,P),N=ad(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(ct(M,void 0,"point")));return P.assertValidity(),P}static fromHex(M){return D.fromBytes(yc(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(Bm);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,Bm),{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,Bm),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)=>Ks(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 Ks(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===si||N.is0())return D.ZERO;if(I===Co)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:_}=Fz(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===Co)return!0;if(M)return M(D,this);return X.unsafe(this,a).is0()}clearCofactor(){let{clearCofactor:M}=t;if(s===Co)return this;if(M)return M(D,this);return this.multiplyUnsafe(s)}isSmallOrder(){if(s===Co)return this.is0();return this.clearCofactor().is0()}toBytes(M=!0){return Li(M,"isCompressed"),this.assertValidity(),y(D,this,M)}toHex(M=!0){return gc(this.toBytes(M))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let H=n.BITS,X=new cd(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 Wz(e){return Uint8Array.of(e?2:3)}function Gz(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function oQ(e,t={}){let{Fn:r}=e,i=t.randomBytes===void 0?xc:t.randomBytes,n=Object.assign(Gz(e.Fp,r),{seed:Math.max(JS(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,Lz(ct(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(!bc(m))return;let A=ct(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=ld(a,c);return Object.freeze(d),Object.freeze(n),Object.freeze({getPublicKey:c,getSharedSecret:u,keygen:p,Point:e,utils:d,lengths:n})}function Qz(e,t,r={}){let i=t;Ti(i),Sn(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),r=Object.assign({},r);let n=r.randomBytes===void 0?xc:r.randomBytes,o=r.hmac===void 0?(R,O)=>Xn(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}=oQ(e,r),g={prehash:!0,lowS:typeof r.lowS==="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},b=c*Jz+Co<s.ORDER;function v(R){let O=c>>Co;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){XS(O);let F=y.signature,L=O==="compact"?F:O==="recovered"?F+1:void 0;return ct(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}=Ln.toSig(ct(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(yc(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(sr(Wz((L&1)===0),_)),ue=a.inv(V),C=Z(ct(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(XS(R),R==="der")return yc(Ln.hexFromSig(this));let{r:O,s:F}=this,L=a.toBytes(O),V=a.toBytes(F);if(R==="recovered")return T(),sr(Uint8Array.of(this.assertRecovery()),L,V);return sr(L,V)}toHex(R){return gc(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=Fs(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=od(l);function H(R){return Bi("num < 2^"+l,R,si,D),a.toBytes(R)}function X(R,O){return ct(R,void 0,"message"),O?ct(i(R),void 0,"prehashed message"):R}function M(R,O,F){let{lowS:L,prehash:V,extraEntropy:_}=YS(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(ct(Ce,void 0,"extraEntropy"))}let Se=sr(...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===si)return;let St=a.create(ze*a.create(Ee+Xe*ue));if(St===si)return;let Dt=(Ve.x===Xe?0:2)|Number(Ve.y&Co),hr=St;if(L&&v(St))hr=a.neg(St),Dt^=1;return new j(Xe,hr,b?void 0:Dt)}return{seed:Se,k2sig:$e}}function P(R,O,F={}){let{seed:L,k2sig:V}=M(R,O,F);return Ez(i.outputLen,a.BYTES,o)(L,V).toBytes(F.format)}function N(R,O,F,L={}){let{lowS:V,prehash:_,format:te}=YS(L,g);if(F=ct(F,void 0,"publicKey"),O=X(O,_),!bc(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}=YS(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 sQ=(()=>({p:BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),h:BigInt(1),a:BigInt("0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc"),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")}))();var aQ=Vz(sQ),vc=Qz(aQ,$t);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var $o=BigInt(0),Fr=BigInt(1),ew=BigInt(2),cQ=BigInt(8);function lQ(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 Yz(e,t={}){let r=t,i=Lm("edwards",e,r,r.FpFnLE),{Fp:n,Fn:o}=i,s=i.CURVE,{h:a}=s;Sn(r,{},{uvRatio:"function"});let c=ew<<BigInt(o.BYTES*8)-Fr,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:$o}}}:r.uvRatio;if(!lQ(n,s,s.Gx,s.Gy))throw Error("bad curve params: generator point");function d(g,b,v=!1){let A=v?Fr:$o;return Bi("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,Fr,l(s.Gx*s.Gy));static ZERO=new m($o,Fr,Fr,$o);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,Fr,l(b*v))}static fromBytes(g,b=!1){let v=n.BYTES,{a:A,d:T}=s;g=To(ct(g,v,"point")),Li(b,"zip215");let z=To(g),j=g[v-1];z[v-1]=j&-129;let E=Dn(z),Z=b?c:n.ORDER;Bi("point.y",E,$o,Z);let D=l(E*E),H=l(D-Fr),X=l(T*D-A),{isValid:M,value:P}=u(H,X);if(!M)throw Error("bad point: invalid y coordinate");let N=(P&Fr)===Fr,I=(j&128)!==0;if(!b&&P===$o&&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(yc(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(ew);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(ew*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)=>Ks(m,A));return Ks(m,[b,v])[0]}multiplyUnsafe(g){if(!o.isValid(g))throw RangeError("invalid scalar: expected 0 <= sc < curve.n");if(g===$o)return m.ZERO;if(this.is0()||g===Fr)return this;return y.unsafe(this,g,(b)=>Ks(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?cQ:n.inv(z);let E=l(A*v),Z=l(T*v),D=n.mul(z,v);if(j)return{x:$o,y:Fr};if(D!==Fr)throw Error("invZ was invalid");return{x:E,y:Z}}clearCofactor(){if(a===Fr)return this;return this.multiplyUnsafe(a)}toBytes(){let{x:g,y:b}=this.toAffine(),v=n.toBytes(b);return v[v.length-1]|=g&Fr?128:0,v}toHex(){return gc(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let y=new cd(m,o.BITS);if(o.BITS>=8)m.BASE.precompute(8);return Object.freeze(m.prototype),Object.freeze(m),m}class tw{static BASE;static ZERO;static Fp;static Fn;ep;constructor(e){this.ep=e}static fromBytes(e){FS()}static fromHex(e){FS()}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 gc(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 dd=BigInt(0),_c=BigInt(1),jm=BigInt(2);function uQ(e){return Sn(e,{P:"bigint",type:"string",adjustScalarBytes:"function",powPminus2:"function"},{randomBytes:"function"}),Object.freeze({...e})}function Xz(e){let t=uQ(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?xc:s,l=a?255:448,u=a?32:56,d=a?BigInt(9):BigInt(5),p=a?BigInt(121665):BigInt(39081),m=a?jm**BigInt(254):jm**BigInt(447),y=a?BigInt(8)*jm**BigInt(251)-_c:BigInt(4)*jm**BigInt(445)-_c,g=m+y+_c,b=(I)=>gt(I,r),v=A(d);function A(I){return id(b(I),u)}function T(I){let R=To(ct(I,u,"uCoordinate"));if(a)R[31]&=127;return b(Dn(R))}function z(I){return Dn(n(To(ct(I,u,"scalar"))))}function j(I,R){let O=X(T(R),z(I));if(O===dd)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){Bi("u",I,dd,r),Bi("scalar",R,m,g);let O=R,F=I,L=_c,V=dd,_=I,te=_c,ue=dd;for(let Se=BigInt(l-1);Se>=dd;Se--){let Ee=O>>Se&_c;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,Dt=b(St*$e),hr=b(Xe*_e),Yr=Dt+hr,Xr=Dt-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,ct(I,M.seed,"seed"),I),N={randomSecretKey:P};return Object.freeze(M),Object.freeze(N),Object.freeze({keygen:ld(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 dQ=BigInt(0),qi=BigInt(1),e2=BigInt(2),fQ=BigInt(3),pQ=BigInt(5),mQ=BigInt(8),Vs=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),ow=(()=>({p:Vs,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:mQ,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")}))();function n2(e){let t=BigInt(10),r=BigInt(20),i=BigInt(40),n=BigInt(80),o=Vs,a=e*e%o*e%o,c=wn(a,e2,o)*a%o,l=wn(c,qi,o)*e%o,u=wn(l,pQ,o)*l%o,d=wn(u,t,o)*u%o,p=wn(d,r,o)*d%o,m=wn(p,i,o)*p%o,y=wn(m,n,o)*m%o,g=wn(y,n,o)*m%o,b=wn(g,t,o)*u%o;return{pow_p_5_8:wn(b,e2,o)*e%o,b2:a}}function hQ(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var rw=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function sw(e,t){let r=Vs,i=gt(t*t*t,r),n=gt(i*i*t,r),o=n2(e*n).pow_p_5_8,s=gt(e*i*o,r),a=gt(t*s*s,r),c=s,l=gt(s*rw,r),u=a===e,d=a===gt(-e,r),p=a===gt(-e*rw,r);if(u)s=c;if(d||p)s=l;if(ji(s,r))s=gt(-s,r);return{isValid:u||d,value:s}}var Js=Yz(ow,{uvRatio:sw}),Oo=(()=>Js.Fp)(),i2=(()=>Js.Fn)();var qm=(()=>{let e=Vs;return Xz({P:e,type:"x25519",powPminus2:(t)=>{let{pow_p_5_8:r,b2:i}=n2(t);return gt(wn(r,fQ,e)*i,e)},adjustScalarBytes:hQ})})();var nw=rw,gQ=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),yQ=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),bQ=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),xQ=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),t2=(e)=>sw(qi,e),SQ=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),iw=(e)=>Oo.create(Dn(e)&SQ);function r2(e){let{d:t}=ow,r=Vs,i=(v)=>Oo.create(v),n=i(nw*e*e),o=i((n+qi)*bQ),s=BigInt(-1),a=i((s-t*n)*i(n+t)),{isValid:c,value:l}=sw(o,a),u=i(l*e);if(!ji(u,r))u=i(-u);if(!c)l=u;if(!c)s=n;let d=i(s*(n-qi)*xQ-a),p=l*l,m=i((l+l)*a),y=i(d*gQ),g=i(qi-p),b=i(qi+p);return new Js(i(m*b),i(g*y),i(y*b),i(m*g))}class $r extends tw{static BASE=(()=>new $r(Js.BASE))();static ZERO=(()=>new $r(Js.ZERO))();static Fp=(()=>Oo)();static Fn=(()=>i2)();constructor(e){super(e)}static fromAffine(e){return new $r(Js.fromAffine(e))}assertSame(e){if(!(e instanceof $r))throw Error("RistrettoPoint expected")}init(e){return new $r(e)}static fromBytes(e){rr(e,32);let{a:t,d:r}=ow,i=Vs,n=(T)=>Oo.create(T),o=iw(e);if(!kz(Oo.toBytes(o),e)||ji(o,i))throw Error("invalid ristretto255 encoding 1");let s=n(o*o),a=n(qi+t*s),c=n(qi-t*s),l=n(a*a),u=n(c*c),d=n(t*r*l-u),{isValid:p,value:m}=t2(n(d*u)),y=n(m*c),g=n(m*y*d),b=n((o+o)*y);if(ji(b,i))b=n(-b);let v=n(a*g),A=n(b*v);if(!p||ji(A,i)||v===dQ)throw Error("invalid ristretto255 encoding 2");return new $r(new Js(b,v,qi,A))}static fromHex(e){return $r.fromBytes(Pu(e))}toBytes(){let{X:e,Y:t,Z:r,T:i}=this.ep,n=Vs,o=(g)=>Oo.create(g),s=o(o(r+t)*o(r-t)),a=o(e*t),c=o(a*a),{value:l}=t2(o(s*c)),u=o(l*s),d=o(l*a),p=o(u*d*i),m;if(ji(i*p,n)){let g=o(t*nw),b=o(e*nw);e=g,t=b,m=o(u*yQ)}else m=d;if(ji(e*p,n))t=o(-t);let y=o((r-t)*m);if(ji(y,n))y=o(-y);return Oo.toBytes(y)}equals(e){this.assertSame(e);let{X:t,Y:r}=this.ep,{X:i,Y:n}=e.ep,o=(c)=>Oo.create(c),s=o(t*n)===o(r*i),a=o(r*n)===o(t*i);return s||a}is0(){return this.equals($r.ZERO)}}Object.freeze($r.BASE);Object.freeze($r.ZERO);Object.freeze($r.prototype);Object.freeze($r);var wQ=Object.freeze({Point:$r,hashToCurve(e,t){let r=t?.DST===void 0?"ristretto255_XMD:SHA-512_R255MAP_RO_":t.DST,i=QS(e,r,64,im);return wQ.deriveToCurve(i)},hashToScalar(e,t={DST:Zz}){let r=QS(e,t.DST,64,im);return i2.create(Dn(r))},deriveToCurve(e){rr(e,64);let t=iw(e.subarray(0,32)),r=r2(t),i=iw(e.subarray(32,64)),n=r2(i);return new $r(r.add(n))}});var o2=!1,vQ=!1;async function s2(e,t){if(vQ)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 Um(e,t){return await s2(async()=>{let r=aw(e)?e:await kQ(e),i=await crypto.subtle.importKey("raw",EQ(t),{name:"X25519"},o2,[]);return new Uint8Array(await crypto.subtle.deriveBits({name:"X25519",public:i},r,256))},()=>{if(aw(e))throw Error("CryptoKey provided but X25519 WebCrypto is not supported");return qm.scalarMult(e,t)})}async function fd(e){return await s2(async()=>Um(e,qm.GuBytes),()=>{if(aw(e))throw Error("CryptoKey provided but X25519 WebCrypto is not supported");return qm.scalarMultBase(e)})}var _Q=new Uint8Array([48,46,2,1,0,48,5,6,3,43,101,110,4,34,4,32]);async function kQ(e){if(e.length!==32)throw Error("X25519 private key must be 32 bytes");let t=new Uint8Array([..._Q,...e]);return crypto.subtle.importKey("pkcs8",t,{name:"X25519"},o2,["deriveBits"])}function aw(e){return typeof CryptoKey<"u"&&e instanceof CryptoKey}function EQ(e){return e}class cw{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),AQ(Ws(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=Ws(e),null;this.buf=r.value}}close(){return this.s.releaseLock(),{rest:this.buf,transcript:Ws(this.transcript)}}}function AQ(e){return e.forEach((t)=>{if(t<32||t>126)throw Error("invalid non-ASCII byte in header")}),new TextDecoder().decode(e)}function Ws(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 kc(e,...t){return e.pipeThrough(new TransformStream({start(r){for(let i of t)r.enqueue(i)}}))}function Mm(e){return new ReadableStream({start(t){t.enqueue(e),t.close()}})}async function lw(e){if(!(e instanceof ReadableStream))throw Error("readAll expects a ReadableStream<Uint8Array>");return new Uint8Array(await new Response(e).arrayBuffer())}async function a2(e){if(!(e instanceof ReadableStream))throw Error("readAllString expects a ReadableStream<Uint8Array>");return await new Response(e).text()}async function c2(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=Ws(i),s=o.subarray(0,t),a=kc(e,o.subarray(t));return{data:s,rest:a}}class ai{args;body;constructor(e,t){this.args=e,this.body=t}}async function TQ(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=gr.decode(o);if(s.length>48)throw Error("invalid stanza");if(i.push(s),s.length<48)break}let n=Ws(i);return{s:new ai(r,n)}}async function l2(e){let t=new cw(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 TQ(t);if(n!==void 0){i.push(n);continue}if(!o.startsWith("--- "))throw Error("invalid header");let s=gr.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:kc(e,a)}}}function uw(e){let t=[];t.push(`age-encryption.org/v1
770
769
  `);for(let r of e){t.push("-> "+r.args.join(" ")+`
771
770
  `);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(gr.encode(r.body.subarray(i,n))+`
772
771
  `)}if(r.body.length%48===0)t.push(`
@@ -836,13 +835,13 @@ writeSecretGitHubEnv("DISCORD_APPLICATION_ID", secrets["discordApplicationId"]);
836
835
  `];function xre(e,t){let r=(i)=>bre.reduce((n,o)=>n.replace(o,""),i);return r(e)===r(t)}function Sre(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 wre={".env.schema":yre,"deploy/Dockerfile":(e)=>O2(e),"deploy/kamal/deploy.yml":(e)=>fre.includes(e)||mre(e)||hre(e),"deploy/scripts/decrypt-user-secrets.ts":xre,"deploy/scripts/resolve-deploy-handles.ts":(e)=>Sre(e),"deploy/scripts/helpers.ts":Ki('"@rizom/ops/deploy"'),"deploy/scripts/resolve-user-config.ts":Ki("sitePackagesFor"),"deploy/scripts/resolve-missing-images.ts":Ki("runResolveMissingImages"),"deploy/scripts/sync-content-repo.ts":Ki("GIT_SYNC_TOKEN"),".github/workflows/build.yml":Ki("resolve-missing-images.ts"),".github/workflows/deploy.yml":Ki("install-health-watchdog.ts"),".github/workflows/offboard.yml":Ki("user:offboard"),".github/workflows/reconcile.yml":Ki("brains-ops reconcile"),".github/workflows/upgrade.yml":Ki("brains-ops upgrade")};function vre(e,t,r){let i=pre(e);if(i&&C2(i,t,r))return!0;return wre[e]?.(t,r)??!1}async function YB(e){await zg(e,{recursive:!0});let t=al(e,"views","users.md"),r=!0;try{await WB(t)}catch{r=!1}let i=!0;try{await WB(al(e,"pilot.yaml"))}catch{i=!1}await zg(al(e,"users"),{recursive:!0}),await zg(al(e,"cohorts"),{recursive:!0});let n=lre.filter((o)=>!(i&&ure.has(o))).map(async(o)=>{let s=al(e,o);await zg(are(s),{recursive:!0}),await _re(o,s)});if(await Promise.all(n),!r)await Zo(e)}async function _re(e,t){let r=await kre(e);try{if(await GB(t,r,{flag:"wx"}),wI.has(e))await SI(t,493);return}catch(n){if(!Ire(n,"EEXIST"))throw n}let i=await QB(t,"utf8");if(i===r){if(wI.has(e))await SI(t,493);return}if(!vre(e,i,r))return;if(await GB(t,r),wI.has(e))await SI(t,493)}async function kre(e){if(e===".gitignore")return`node_modules/
837
836
  .brains-ops/
838
837
  users/*.secrets.yaml
839
- `;if(e==="deploy/Dockerfile")return $2();if(e==="deploy/kamal/deploy.yml")return Jm({serviceName:"rover"});if(e===".kamal/hooks/pre-deploy")return $w({deployConfigPath:"deploy/kamal/deploy.yml",brainYamlPath:"${BRAIN_YAML_PATH:-brain.yaml}"});let t=al(dre,e),r=await QB(t,"utf8");return Ere(r)}function Ere(e){return e.replaceAll("__BRAINS_OPS_VERSION__",Qp.version).replaceAll("__BUN_VERSION__",Bun.version)}function Ire(e,t){return typeof e==="object"&&e!==null&&"code"in e&&e.code===t}import{lookup as Are}from"dns/promises";function ej(e={}){let t=e.fetchImpl??fetch,r=e.lookupHost??Are;return async function(n){let o=await Tre(n.domain,r),[s,a,c]=await Promise.all([XB(n.domain,"/health/ready",t),XB(n.domain,"/health/operate",t),Cre(n.domain,t)]);return{dnsStatus:o,serverStatus:s,deployStatus:a,mcpStatus:c}}}async function Tre(e,t){try{return(await t(e)).address?"ready":"failed"}catch{return"failed"}}async function XB(e,t,r){try{return(await tj(r,`https://${e}${t}`,{method:"GET"})).ok?"ready":"failed"}catch{return"failed"}}async function Cre(e,t){try{let r=await tj(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 tj(e,t,r){let i=new AbortController,n=setTimeout(()=>i.abort(),5000);try{return await e(t,{...r,signal:i.signal})}finally{clearTimeout(n)}}Hi();import{mkdir as Qre,writeFile as Yre}from"fs/promises";import{dirname as Xre,join as mj}from"path";import{isDeepStrictEqual as ene}from"util";Qs();Ui();import{mkdtemp as $re,mkdir as Ore,readFile as Rre,rm as Pre,writeFile as zre}from"fs/promises";import{tmpdir as Nre}from"os";import{dirname as Dre,join as oj}from"path";var Lre=["name: Your Name Here","Delete this and write your own"];async function sj(e,t,r,i,n={}){if(i.length===0)return;let o=n.env??process.env,s=Bn(e),a=nj(o,s,r.effectiveGitSyncToken),c=n.contentRepoAdminTokenSelector?nj(o,s,n.contentRepoAdminTokenSelector):void 0,l=_I(r.contentRepo,t),u=n.contentRepoRemoteResolver?.(r,t,a)??qre(l,a);if(!u)return;let d=await $re(oj(Nre(),`brains-ops-content-sync-${r.handle}-`)),p=n.runCommand??Zr,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 Ure(l,c,m)}await p("git",["clone",u,d]),await Mre(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 Bre(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 Pre(d,{recursive:!0,force:!0})}}async function Bre(e,t){let r=oj(e,t.path),i=await Rre(r,"utf8").catch(()=>{return});if(i===t.content)return!1;if(i!==void 0&&!jre(i))return!1;return await Ore(Dre(r),{recursive:!0}),await zre(r,t.content),!0}function jre(e){return Lre.some((t)=>e.includes(t))}function nj(e,t,r){return Gt(r,e,t)}function qre(e,t){if(!t)return;return`https://x-access-token:${encodeURIComponent(t)}@github.com/${e.org}/${e.name}.git`}async function Ure(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 ij(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 ij(l)}`)}async function ij(e){let t=await e.text();return t.trim().length===0?e.statusText:t}async function Mre(e,t){try{await t("git",["checkout","-B","main","origin/main"],{cwd:e})}catch{await t("git",["checkout","-B","main"],{cwd:e})}}EI();pi();async function cl(e,t,r,i,n={}){let o=Ng(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 II(e,s.handle,".env",u);if(l)await II(e,s.handle,"brain.yaml",l);await sj(e,t.pilot.githubOrg,s,d,{contentRepoAdminTokenSelector:t.pilot.contentRepoAdminToken,...n});for(let p of d)await II(e,s.handle,mj("content",p.path),p.content)}}async function II(e,t,r,i){let n=mj(e,"users",t,r),o=Bun.file(n);if(r==="brain.yaml"&&await o.exists()){let s=qn(await o.text()),a=qn(i);if(s.ok&&a.ok&&ene(s.data,a.data))return}await Qre(Xre(n),{recursive:!0}),await Yre(n,i)}async function Dg(e,t){let r=await Zt(e),i=r.users.find((n)=>n.handle===t);if(!i)throw Error(`Unknown user handle: ${t}`);return{registry:r,user:i}}async function hj(e,t){let r=await Zt(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 gj(e){let t=await Zt(e);return{registry:t,users:t.users}}async function yj(e,t,r,i={}){let{registry:n,user:o}=await Dg(e,t);await cl(e,n,[o],r,i)}async function Lg(e,t,r={}){let{registry:i,users:n}=await gj(e);await cl(e,i,n,t,r)}import{createHash as tne}from"crypto";import{cp as rne,lstat as nne,mkdtemp as ine,readFile as one,readdir as sne,readlink as ane,rm as cne}from"fs/promises";import{tmpdir as lne}from"os";import{basename as une,join as cf,relative as dne,resolve as fne,sep as pne}from"path";var mne=new Set([".git",".operator",".brains-ops",".turbo","dist","node_modules"]);async function Sj(e){let t=fne(e),r=await ine(cf(lne(),"brains-ops-reconcile-")),i=cf(r,"repo");try{await rne(t,i,{recursive:!0,errorOnExist:!0,force:!1,filter:(a)=>hne(t,a)});let n=await AI(i);await bj(i);let o=await AI(i);await bj(i);let s=await AI(i);return{firstPassChangedFiles:xj(n,o),secondPassChangedFiles:xj(o,s)}}finally{await cne(r,{recursive:!0,force:!0})}}function hne(e,t){let r=dne(e,t);if(r.length===0)return!0;if(r.split(pne).some((n)=>mne.has(n)))return!1;if(r===".env"||r===".env.local")return!1;return!une(r).endsWith(".secrets.yaml")}async function bj(e){await Lg(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 AI(e){let t=new Map;return await wj(e,"",t),t}async function wj(e,t,r){let i=cf(e,t),n=await sne(i,{withFileTypes:!0});n.sort((o,s)=>o.name.localeCompare(s.name));for(let o of n){let s=cf(t,o.name),a=cf(e,s);if(o.isDirectory()){await wj(e,s,r);continue}let l=(await nne(a)).isSymbolicLink()?`symlink:${await ane(a)}`:await one(a);r.set(s,tne("sha256").update(l).digest("hex"))}}function xj(e,t){return[...new Set([...e.keys(),...t.keys()])].filter((i)=>e.get(i)!==t.get(i)).sort()}async function vj(e,t,r,i={}){let{registry:n,users:o}=await hj(e,t);await cl(e,n,o,r,i)}af();import{readFileSync as lf}from"fs";import{access as gne,rm as yne,writeFile as Tj}from"fs/promises";import{join as TI,relative as kj}from"path";Qs();Hi();function _j(e){return Object.keys(e)}Re();var Cj=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 $j(e,t,r={}){let{registry:i,user:n}=await Dg(e,t),o=r.env??process.env,s=r.logger??console.log,a=Bn(e),c=TI(e,"users",`${t}.secrets.yaml.age`),l=TI(e,"users",`${t}.secrets.yaml`),u=Aj(kj(e,c)),d=Aj(kj(e,l)),p=Sne(l),m=await wne(c,e,o,a),y=await Oj(l),g={sharedAiApiKeySelector:i.pilot.aiApiKey,sharedGitSyncTokenSelector:i.pilot.gitSyncToken,effectiveAiApiKeySelector:n.effectiveAiApiKey,effectiveGitSyncTokenSelector:n.effectiveGitSyncToken,discordEnabled:n.discordEnabled},b;try{b=bne(e,o,a,p,m,g)}catch(E){if(!r.dryRun&&p===void 0&&E instanceof Error){let Z=kne(g);if(Z.length>0)throw await Ene(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=`${sl(b).trimEnd()}
840
- `;_ne(v,b);let A=_j(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 Ew;T.addRecipient(i.pilot.agePublicKey);let z=await T.encrypt(v),j=pd.encode(z);if(await Tj(c,j),await yne(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 bne(e,t,r,i,n,o){let s=Ej(e,t,r,i,n,"aiApiKey",o.effectiveAiApiKeySelector,o.sharedAiApiKeySelector),a=Ej(e,t,r,i,n,"gitSyncToken",o.effectiveGitSyncTokenSelector,o.sharedGitSyncTokenSelector),c=o.discordEnabled?Bg(e,t,r,i,n,"discordBotToken","DISCORD_BOT_TOKEN"):void 0,l=o.discordEnabled?Bg(e,t,r,i,n,"discordPublicKey","DISCORD_PUBLIC_KEY"):void 0,u=o.discordEnabled?Bg(e,t,r,i,n,"discordApplicationId","DISCORD_APPLICATION_ID"):void 0,d=jg(e,t,r,i,n,"atprotoAppPassword","ATPROTO_APP_PASSWORD"),p=Ij(jg(e,t,r,i,n,"certificatePem","CERTIFICATE_PEM")),m=Ij(jg(e,t,r,i,n,"privateKeyPem","PRIVATE_KEY_PEM"));return Cj.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 Ej(e,t,r,i,n,o,s,a){if(s===a)return;return Bg(e,t,r,i,n,o,s)}function Bg(e,t,r,i,n,o,s){let a=jg(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 Ij(e){return e?.replace(/\r\n?|\n/g,"\\n")}function jg(e,t,r,i,n,o,s){return xne(i,n,o,s,t,r,e)}function xne(e,t,r,i,n,o,s){let a=e?.[r];if(a!==void 0&&a.trim().length>0)return a;let c=Gt(`${i}_FILE`,n,o);if(c&&c.trim().length>0)return lf(Po(c,s),"utf8");let l=Gt(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 Sne(e){let t;try{t=lf(e,"utf8")}catch{return}try{return CI(t)}catch(r){throw Error(`Unable to parse plaintext secrets file ${e}: ${at(r)}`,{cause:r})}}async function wne(e,t,r,i){if(!await Oj(e))return;let n=vne(t,r,i);if(!n)return;let o;try{let s=lf(e,"utf8"),a=pd.decode(s),c=new Iw;c.addIdentity(n),o=await c.decrypt(a,"text")}catch{return}try{return CI(o)}catch(s){throw Error(`Unable to parse decrypted secrets from ${e}: ${at(s)}`,{cause:s})}}function vne(e,t,r){let i=Gt("AGE_SECRET_KEY_FILE",t,r);if(i&&i.trim().length>0)return md(lf(Po(i,e),"utf8"));let n=Gt("AGE_SECRET_KEY",t,r);if(n&&n.trim().length>0)return md(n);try{return md(lf(TI(e,".brains-ops","age","identity.txt"),"utf8"))}catch{return}}function CI(e){let t=jB(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 Cj.partial().parse(r)}function _ne(e,t){let r={...t},i={...CI(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 kne(e){return[...e.effectiveAiApiKeySelector!==e.sharedAiApiKeySelector?["aiApiKey"]:[],...e.effectiveGitSyncTokenSelector!==e.sharedGitSyncTokenSelector?["gitSyncToken"]:[],...e.discordEnabled?["discordBotToken","discordPublicKey","discordApplicationId"]:[]]}async function Ene(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(`
841
- `);await Tj(e,r,{flag:"wx"})}async function Oj(e){try{return await gne(e),!0}catch{return!1}}function Aj(e){return e.replaceAll("\\","/")}Qs();import{readFileSync as Ine}from"fs";Ui();async function Rj(e,t={}){let r=t.env??process.env,i=t.logger??console.log,n=Bn(e),o=Rw(`${e}/.env.schema`),s=Tne(o),a=[],c=[],l=new Map;for(let d of s){l.set(d.key,d.required);let p=Cne(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(", ")}`),Aw(i,c,u),{pushedKeys:a.map(([d])=>d),skippedKeys:c,dryRun:!0};return await Ro(a,{logger:i,runCommand:t.runCommand??Zr}),Aw(i,c,u),{pushedKeys:a.map(([d])=>d),skippedKeys:c}}var Ane=new Set(["DISCORD_BOT_TOKEN","DISCORD_PUBLIC_KEY","DISCORD_APPLICATION_ID"]);function Tne(e){return e.filter((t)=>!Ane.has(t.key)).map((t)=>({key:t.key,required:t.required}))}function Cne(e,t,r,i){let n=Gt(`${e}_FILE`,t,r);if(n&&n.trim().length>0)return Ine(Po(n,i),"utf8");let o=Gt(e,t,r);if(o===void 0||o.trim().length===0)return;return o}Re();import{execFileSync as Pj}from"child_process";import{chmodSync as $ne,existsSync as One,mkdirSync as Rne,readFileSync as zj,writeFileSync as Pne}from"fs";import{dirname as zne,join as Nne}from"path";import{homedir as Dne}from"os";zw();Ui();var Nj=f.object({id:f.number(),name:f.string(),public_key:f.string()}),Lne=f.object({ssh_keys:f.array(Nj)}),Bne={createEd25519KeyPair(e,t){Pj("ssh-keygen",["-t","ed25519","-f",e,"-C",t,"-N",""],{stdio:"ignore"})},derivePublicKey(e){return Pj("ssh-keygen",["-y","-f",e],{encoding:"utf-8",stdio:["ignore","pipe","inherit"]}).trim()}};async function $I(e,t={}){try{let r=await Dj(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 Dj(e,t={}){let r=t.env??process.env,i=Bn(e),n=t.logger??console.log,o=t.fetchImpl??fetch,s=t.sshKeygen??Bne,a=Gt("HCLOUD_TOKEN",r,i);if(!a)throw Error("Missing HCLOUD_TOKEN");let c=Gt("HCLOUD_SSH_KEY_NAME",r,i);if(!c)throw Error("Missing HCLOUD_SSH_KEY_NAME");let l=Gt("KAMAL_SSH_PRIVATE_KEY_FILE",r,i),u=l?Po(l,e):Nne(Dne(),".ssh",`${qne(c)}_ed25519`),d=`${u}.pub`,p=!1;if(!One(u))Rne(zne(u),{recursive:!0,mode:448}),s.createEd25519KeyPair(u,c),p=!0;$ne(u,384);let m;if(p)m=zj(d,"utf-8").trim();else m=s.derivePublicKey(u),Pne(d,`${m}
842
- `,"utf-8");if(m.length===0)throw Error(`Unable to derive a public key from ${u}`);let y=await jne({fetchImpl:o,hcloudToken:a,publicKey:m,sshKeyName:c}),g=Ec(t.pushTo);if(g)await Ro([["KAMAL_SSH_PRIVATE_KEY",zj(u,"utf-8")]],{logger:n,runCommand:t.runCommand??Zr});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 jne(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 Ac(r,Lne,{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 Ac(o,f.object({ssh_key:Nj}),{label:"Hetzner SSH key create failed"}),!0}function qne(e){return e.replace(/[^A-Za-z0-9._-]+/g,"_")}Hi();fa();import{access as Une,mkdir as Lj,readFile as Mne,writeFile as jj}from"fs/promises";import{basename as Fne,join as ll}from"path";async function qj(e,t,r){let i=Dr.parse(t),n=Dr.parse(r.cohort),o=ll(e,"users"),s=ll(e,"cohorts"),a=ll(o,`${i}.yaml`),c=ll(o,`${i}.secrets.yaml`),l=ll(o,`${i}.secrets.yaml.age`),u=ll(s,`${n}.yaml`);await Promise.all([Lj(o,{recursive:!0}),Lj(s,{recursive:!0})]);let d=await Bj(a,Kne(i,r.anchorId)),m=await Wne(l)?!1:await Bj(c,Jne(i)),{addedToCohort:y}=await Zne(u,i);return{handle:i,cohort:n,userPath:a,secretsTemplatePath:c,cohortPath:u,createdUser:d,createdSecretsTemplate:m,addedToCohort:y}}async function Zne(e,t){let r=await Hne(e);if(r.members.includes(t))return{addedToCohort:!1};let i={...r,members:[...r.members,t].sort()};return await jj(e,Vne(i)),{addedToCohort:!0}}async function Hne(e){try{let t=await Mne(e,"utf8"),r=qn(t,Un);if(!r.ok)throw Error(`${Fne(e)}: ${r.error}`);return r.data}catch(t){if(Qne(t))return{members:[]};throw t}}function Kne(e,t){return[`handle: ${e}`,"anchorProfile:",` name: ${Yne(e)}`,"discord:"," enabled: true",...t?[` anchorUserId: ${JSON.stringify(t)}`]:[],""].join(`
843
- `)}function Jne(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(`
844
- `)}function Vne(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(`
845
- `)}async function Bj(e,t){try{return await jj(e,t,{flag:"wx"}),!0}catch(r){if(Gne(r))return!1;throw r}}async function Wne(e){try{return await Une(e),!0}catch{return!1}}function Gne(e){return Uj(e,"EEXIST")}function Qne(e){return Uj(e,"ENOENT")}function Uj(e,t){return typeof e==="object"&&e!==null&&"code"in e&&e.code===t}function Yne(e){return e.split("-").filter((t)=>t.length>0).map((t)=>`${t[0]?.toUpperCase()??""}${t.slice(1)}`).join(" ")}Re();pi();var Xne=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 Fj(e,t,r={}){let i=r.fetchImpl??fetch,o=(await Zt(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 qg("health",()=>eie(i,s,l,u,d),a,c),await qg("mcp-auth-gate",()=>nie(i,s),a,c),o.bundles.includes("site"))await qg("site",()=>Mj(i,`${s}/`,"site"),a,c),await qg("studio",()=>Mj(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 qg(e,t,r,i){try{await t(),r.push(e)}catch(n){i.push({name:e,message:at(n)})}}async function eie(e,t,r,i,n){let o;for(let s=1;s<=r;s++)try{await tie(e,t);return}catch(a){if(o=a,s<r)await n(i)}throw o}async function tie(e,t){let i=await OI(e,`${t}/health/operate`,{method:"GET"}),n=await i.json().catch(()=>null),o=Xne.safeParse(n);if(!i.ok){let a=o.success?o.data.checks.filter((c)=>c.status!=="healthy").slice(0,10).map((c)=>`${c.name}: ${rie(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 rie(e){let t=e.replaceAll(/\s+/g," ").trim();return t.length<=300?t:`${t.slice(0,297)}...`}async function nie(e,t){let r=await OI(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 Mj(e,t,r){let i=await OI(e,t,{method:"GET"});if(i.status>=400)throw Error(`${r} ${t} returned ${i.status}, expected < 400`)}async function OI(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 _7="brains-ops",rR={type:"string",placeholder:"<target>",description:"Push target (`gh` or `github`)"},jx={type:"boolean",description:"Show what would happen without writing anything"};function Nt(e){return{success:!1,message:cR(_7,e)}}var k7=mt({name:"init",usage:"<repo>",description:"Create a pilot repo skeleton",run:async({args:e})=>{let t=e[0];if(!t)return Nt(k7);return await YB(t),{success:!0,message:`Initialized ${t}`}}}),E7=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 Nt(E7);let i=ht(t,"to"),{upgradePilotRepo:n}=await Promise.resolve().then(() => (Kj(),Hj)),{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`}}}),I7=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 Nt(I7);let{loadCapabilityBundleReview:o,loadReviewedSitePins:s,stageLegacyCrossover:a}=await Promise.resolve().then(() => (EU(),kU)),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}`}}}),A7=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 Nt(A7);let i=t.resolveStatus??ej({...t.fetchImpl?{fetchImpl:t.fetchImpl}:{},...t.lookupHost?{lookupHost:t.lookupHost}:{}});return await Zo(r,{resolveStatus:i}),{success:!0,message:`Rendered ${r}/views/users.md`}}}),T7=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 Nt(T7);let o=ht(t,"anchor-id");return await qj(r,i,{cohort:n,...o?{anchorId:o}:{}}),{success:!0,message:`Added ${i} to ${n}`}}}),C7=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 Nt(C7);let o=nc(t,"apply")??!1,s=ht(t,"confirm"),{offboardPilotUsers:a}=await Promise.resolve().then(() => (X8(),Y8)),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)`}}}),$7=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 Nt($7);return await yj(r,i,t.runner,{...t.env?{env:t.env}:{}}),{success:!0,message:`Onboarded ${i}`}}}),O7=mt({name:"age-key:bootstrap",usage:"<repo>",description:"Generate the pilot age key and optional GitHub secret",flags:{"push-to":rR},run:async({args:e,flags:t},r)=>{let i=e[0];if(!i)return Nt(O7);let n=ht(t,"push-to");return S2(i,{...r.logger?{logger:r.logger}:{},...n?{pushTo:n}:{},...r.bootstrapRunCommand?{runCommand:r.bootstrapRunCommand}:{}})}}),R7=mt({name:"ssh-key:bootstrap",usage:"<repo>",description:"Bootstrap a deploy SSH key and optional GitHub secret",flags:{"push-to":rR},run:async({args:e,flags:t},r)=>{let i=e[0];if(!i)return Nt(R7);let n=ht(t,"push-to");return $I(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}:{}})}}),P7=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":rR},run:async({args:e,flags:t},r)=>{let i=e[0];if(!i)return Nt(P7);let n=ht(t,"handle"),o=ht(t,"push-to");return JB(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}:{}})}}),z7=mt({name:"secrets:push",usage:"<repo>",description:"Push env-backed local secrets to GitHub Secrets",flags:{"dry-run":jx},run:async({args:e,flags:t},r)=>{let i=e[0];if(!i)return Nt(z7);let n=await Rj(i,{env:r.env,logger:r.logger,dryRun:nc(t,"dry-run")});return{success:!0,message:n.dryRun?`Dry run: would push ${n.pushedKeys.length} secrets`:`Pushed ${n.pushedKeys.length} secrets`}}}),N7=mt({name:"secrets:encrypt",usage:"<repo> <handle>",description:"Encrypt pilot secrets for a user with age",flags:{"dry-run":jx},run:async({args:e,flags:t},r)=>{let i=e[0],n=e[1];if(!i||!n)return Nt(N7);let o=await $j(i,n,{env:r.env,logger:r.logger,dryRun:nc(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}`}}}),D7=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":jx},run:async({args:e,flags:t},r)=>{let i=e[0],n=e[1],o=ht(t,"type"),s=ht(t,"confirm"),a=nc(t,"dry-run")??!1;if(!i||!n||!o||a===(s!==void 0))return Nt(D7);let{legacyProjectionJobTypeSchema:c}=await Promise.resolve().then(() => (LO(),DO)),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(() => (LO(),DO))).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)}`}}}}),L7=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 Nt(L7);let a=r.directorySyncStressRunner??(await Promise.resolve().then(() => (Lx(),Dx))).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}`}}}),B7=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 Nt(B7);let s=r.directorySyncStressAccessRunner??(await Promise.resolve().then(() => (Lx(),Dx))).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}`}}}),j7=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 Nt(j7);let s=r.directorySyncStressCleanupRunner??(await Promise.resolve().then(() => (Lx(),Dx))).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}`}}}),q7={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"}},U7=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:q7,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 Nt(U7);let a=r.healthWatchdogSmokeRunner??(await tR().then(() => eR)).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}`}}}),M7=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:q7,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 Nt(M7);let a=r.healthWatchdogSmokeCleanupRunner??(await tR().then(() => eR)).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}`}}}),F7=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 Nt(F7);let n=await Fj(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(`
838
+ `;if(e==="deploy/Dockerfile")return $2();if(e==="deploy/kamal/deploy.yml")return Jm({serviceName:"rover"});if(e===".kamal/hooks/pre-deploy")return $w({deployConfigPath:"deploy/kamal/deploy.yml",brainYamlPath:"${BRAIN_YAML_PATH:-brain.yaml}"});let t=al(dre,e),r=await QB(t,"utf8");return Ere(r)}function Ere(e){return e.replaceAll("__BRAINS_OPS_VERSION__",Qp.version).replaceAll("__BUN_VERSION__",Bun.version)}function Ire(e,t){return typeof e==="object"&&e!==null&&"code"in e&&e.code===t}import{lookup as Are}from"dns/promises";function e6(e={}){let t=e.fetchImpl??fetch,r=e.lookupHost??Are;return async function(n){let o=await Tre(n.domain,r),[s,a,c]=await Promise.all([XB(n.domain,"/health/ready",t),XB(n.domain,"/health/operate",t),Cre(n.domain,t)]);return{dnsStatus:o,serverStatus:s,deployStatus:a,mcpStatus:c}}}async function Tre(e,t){try{return(await t(e)).address?"ready":"failed"}catch{return"failed"}}async function XB(e,t,r){try{return(await t6(r,`https://${e}${t}`,{method:"GET"})).ok?"ready":"failed"}catch{return"failed"}}async function Cre(e,t){try{let r=await t6(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 t6(e,t,r){let i=new AbortController,n=setTimeout(()=>i.abort(),5000);try{return await e(t,{...r,signal:i.signal})}finally{clearTimeout(n)}}Hi();import{mkdir as Gre,writeFile as Qre}from"fs/promises";import{dirname as Yre,join as m6}from"path";import{isDeepStrictEqual as Xre}from"util";Qs();Ui();import{mkdtemp as $re,mkdir as Ore,readFile as Rre,rm as Pre,writeFile as zre}from"fs/promises";import{tmpdir as Nre}from"os";import{dirname as Dre,join as o6}from"path";var Lre=["name: Your Name Here","Delete this and write your own"];async function s6(e,t,r,i,n={}){if(i.length===0)return;let o=n.env??process.env,s=Bn(e),a=n6(o,s,r.effectiveGitSyncToken),c=n.contentRepoAdminTokenSelector?n6(o,s,n.contentRepoAdminTokenSelector):void 0,l=_I(r.contentRepo,t),u=n.contentRepoRemoteResolver?.(r,t,a)??qre(l,a);if(!u)return;let d=await $re(o6(Nre(),`brains-ops-content-sync-${r.handle}-`)),p=n.runCommand??Zr,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 Ure(l,c,m)}await p("git",["clone",u,d]),await Mre(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 Bre(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 Pre(d,{recursive:!0,force:!0})}}async function Bre(e,t){let r=o6(e,t.path),i=await Rre(r,"utf8").catch(()=>{return});if(i===t.content)return!1;if(i!==void 0&&!jre(i))return!1;return await Ore(Dre(r),{recursive:!0}),await zre(r,t.content),!0}function jre(e){return Lre.some((t)=>e.includes(t))}function n6(e,t,r){return Gt(r,e,t)}function qre(e,t){if(!t)return;return`https://x-access-token:${encodeURIComponent(t)}@github.com/${e.org}/${e.name}.git`}async function Ure(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 i6(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 i6(l)}`)}async function i6(e){let t=await e.text();return t.trim().length===0?e.statusText:t}async function Mre(e,t){try{await t("git",["checkout","-B","main","origin/main"],{cwd:e})}catch{await t("git",["checkout","-B","main"],{cwd:e})}}EI();pi();async function cl(e,t,r,i,n={}){let o=Ng(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 II(e,s.handle,".env",u);if(l)await II(e,s.handle,"brain.yaml",l);await s6(e,t.pilot.githubOrg,s,d,{contentRepoAdminTokenSelector:t.pilot.contentRepoAdminToken,...n});for(let p of d)await II(e,s.handle,m6("content",p.path),p.content)}}async function II(e,t,r,i){let n=m6(e,"users",t,r),o=Bun.file(n);if(r==="brain.yaml"&&await o.exists()){let s=qn(await o.text()),a=qn(i);if(s.ok&&a.ok&&Xre(s.data,a.data))return}await Gre(Yre(n),{recursive:!0}),await Qre(n,i)}async function Dg(e,t){let r=await Zt(e),i=r.users.find((n)=>n.handle===t);if(!i)throw Error(`Unknown user handle: ${t}`);return{registry:r,user:i}}async function h6(e,t){let r=await Zt(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 g6(e){let t=await Zt(e);return{registry:t,users:t.users}}async function y6(e,t,r,i={}){let{registry:n,user:o}=await Dg(e,t);await cl(e,n,[o],r,i)}async function Lg(e,t,r={}){let{registry:i,users:n}=await g6(e);await cl(e,i,n,t,r)}import{createHash as ene}from"crypto";import{cp as tne,lstat as rne,mkdtemp as nne,readFile as ine,readdir as one,readlink as sne,rm as ane}from"fs/promises";import{tmpdir as cne}from"os";import{basename as lne,join as cf,relative as une,resolve as dne,sep as fne}from"path";var pne=new Set([".git",".operator",".brains-ops",".turbo","dist","node_modules"]);async function S6(e){let t=dne(e),r=await nne(cf(cne(),"brains-ops-reconcile-")),i=cf(r,"repo");try{await tne(t,i,{recursive:!0,errorOnExist:!0,force:!1,filter:(a)=>mne(t,a)});let n=await AI(i);await b6(i);let o=await AI(i);await b6(i);let s=await AI(i);return{firstPassChangedFiles:x6(n,o),secondPassChangedFiles:x6(o,s)}}finally{await ane(r,{recursive:!0,force:!0})}}function mne(e,t){let r=une(e,t);if(r.length===0)return!0;if(r.split(fne).some((n)=>pne.has(n)))return!1;if(r===".env"||r===".env.local")return!1;return!lne(r).endsWith(".secrets.yaml")}async function b6(e){await Lg(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 AI(e){let t=new Map;return await w6(e,"",t),t}async function w6(e,t,r){let i=cf(e,t),n=await one(i,{withFileTypes:!0});n.sort((o,s)=>o.name.localeCompare(s.name));for(let o of n){let s=cf(t,o.name),a=cf(e,s);if(o.isDirectory()){await w6(e,s,r);continue}let l=(await rne(a)).isSymbolicLink()?`symlink:${await sne(a)}`:await ine(a);r.set(s,ene("sha256").update(l).digest("hex"))}}function x6(e,t){return[...new Set([...e.keys(),...t.keys()])].filter((i)=>e.get(i)!==t.get(i)).sort()}async function v6(e,t,r,i={}){let{registry:n,users:o}=await h6(e,t);await cl(e,n,o,r,i)}af();import{readFileSync as lf}from"fs";import{access as hne,rm as gne,writeFile as T6}from"fs/promises";import{join as TI,relative as k6}from"path";Qs();Hi();function _6(e){return Object.keys(e)}Re();var C6=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 $6(e,t,r={}){let{registry:i,user:n}=await Dg(e,t),o=r.env??process.env,s=r.logger??console.log,a=Bn(e),c=TI(e,"users",`${t}.secrets.yaml.age`),l=TI(e,"users",`${t}.secrets.yaml`),u=A6(k6(e,c)),d=A6(k6(e,l)),p=xne(l),m=await Sne(c,e,o,a),y=await O6(l),g={sharedAiApiKeySelector:i.pilot.aiApiKey,sharedGitSyncTokenSelector:i.pilot.gitSyncToken,effectiveAiApiKeySelector:n.effectiveAiApiKey,effectiveGitSyncTokenSelector:n.effectiveGitSyncToken,discordEnabled:n.discordEnabled},b;try{b=yne(e,o,a,p,m,g)}catch(E){if(!r.dryRun&&p===void 0&&E instanceof Error){let Z=_ne(g);if(Z.length>0)throw await kne(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=`${sl(b).trimEnd()}
839
+ `;vne(v,b);let A=_6(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 Ew;T.addRecipient(i.pilot.agePublicKey);let z=await T.encrypt(v),j=pd.encode(z);if(await T6(c,j),await gne(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 yne(e,t,r,i,n,o){let s=E6(e,t,r,i,n,"aiApiKey",o.effectiveAiApiKeySelector,o.sharedAiApiKeySelector),a=E6(e,t,r,i,n,"gitSyncToken",o.effectiveGitSyncTokenSelector,o.sharedGitSyncTokenSelector),c=o.discordEnabled?Bg(e,t,r,i,n,"discordBotToken","DISCORD_BOT_TOKEN"):void 0,l=o.discordEnabled?Bg(e,t,r,i,n,"discordPublicKey","DISCORD_PUBLIC_KEY"):void 0,u=o.discordEnabled?Bg(e,t,r,i,n,"discordApplicationId","DISCORD_APPLICATION_ID"):void 0,d=jg(e,t,r,i,n,"atprotoAppPassword","ATPROTO_APP_PASSWORD"),p=I6(jg(e,t,r,i,n,"certificatePem","CERTIFICATE_PEM")),m=I6(jg(e,t,r,i,n,"privateKeyPem","PRIVATE_KEY_PEM"));return C6.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 E6(e,t,r,i,n,o,s,a){if(s===a)return;return Bg(e,t,r,i,n,o,s)}function Bg(e,t,r,i,n,o,s){let a=jg(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 I6(e){return e?.replace(/\r\n?|\n/g,"\\n")}function jg(e,t,r,i,n,o,s){return bne(i,n,o,s,t,r,e)}function bne(e,t,r,i,n,o,s){let a=e?.[r];if(a!==void 0&&a.trim().length>0)return a;let c=Gt(`${i}_FILE`,n,o);if(c&&c.trim().length>0)return lf(Po(c,s),"utf8");let l=Gt(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 xne(e){let t;try{t=lf(e,"utf8")}catch{return}try{return CI(t)}catch(r){throw Error(`Unable to parse plaintext secrets file ${e}: ${at(r)}`,{cause:r})}}async function Sne(e,t,r,i){if(!await O6(e))return;let n=wne(t,r,i);if(!n)return;let o;try{let s=lf(e,"utf8"),a=pd.decode(s),c=new Iw;c.addIdentity(n),o=await c.decrypt(a,"text")}catch{return}try{return CI(o)}catch(s){throw Error(`Unable to parse decrypted secrets from ${e}: ${at(s)}`,{cause:s})}}function wne(e,t,r){let i=Gt("AGE_SECRET_KEY_FILE",t,r);if(i&&i.trim().length>0)return md(lf(Po(i,e),"utf8"));let n=Gt("AGE_SECRET_KEY",t,r);if(n&&n.trim().length>0)return md(n);try{return md(lf(TI(e,".brains-ops","age","identity.txt"),"utf8"))}catch{return}}function CI(e){let t=jB(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 C6.partial().parse(r)}function vne(e,t){let r={...t},i={...CI(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 _ne(e){return[...e.effectiveAiApiKeySelector!==e.sharedAiApiKeySelector?["aiApiKey"]:[],...e.effectiveGitSyncTokenSelector!==e.sharedGitSyncTokenSelector?["gitSyncToken"]:[],...e.discordEnabled?["discordBotToken","discordPublicKey","discordApplicationId"]:[]]}async function kne(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(`
840
+ `);await T6(e,r,{flag:"wx"})}async function O6(e){try{return await hne(e),!0}catch{return!1}}function A6(e){return e.replaceAll("\\","/")}Qs();import{readFileSync as Ene}from"fs";Ui();async function R6(e,t={}){let r=t.env??process.env,i=t.logger??console.log,n=Bn(e),o=Rw(`${e}/.env.schema`),s=Ane(o),a=[],c=[],l=new Map;for(let d of s){l.set(d.key,d.required);let p=Tne(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(", ")}`),Aw(i,c,u),{pushedKeys:a.map(([d])=>d),skippedKeys:c,dryRun:!0};return await Ro(a,{logger:i,runCommand:t.runCommand??Zr}),Aw(i,c,u),{pushedKeys:a.map(([d])=>d),skippedKeys:c}}var Ine=new Set(["DISCORD_BOT_TOKEN","DISCORD_PUBLIC_KEY","DISCORD_APPLICATION_ID"]);function Ane(e){return e.filter((t)=>!Ine.has(t.key)).map((t)=>({key:t.key,required:t.required}))}function Tne(e,t,r,i){let n=Gt(`${e}_FILE`,t,r);if(n&&n.trim().length>0)return Ene(Po(n,i),"utf8");let o=Gt(e,t,r);if(o===void 0||o.trim().length===0)return;return o}Re();import{execFileSync as P6}from"child_process";import{chmodSync as Cne,existsSync as $ne,mkdirSync as One,readFileSync as z6,writeFileSync as Rne}from"fs";import{dirname as Pne,join as zne}from"path";import{homedir as Nne}from"os";zw();Ui();var N6=f.object({id:f.number(),name:f.string(),public_key:f.string()}),Dne=f.object({ssh_keys:f.array(N6)}),Lne={createEd25519KeyPair(e,t){P6("ssh-keygen",["-t","ed25519","-f",e,"-C",t,"-N",""],{stdio:"ignore"})},derivePublicKey(e){return P6("ssh-keygen",["-y","-f",e],{encoding:"utf-8",stdio:["ignore","pipe","inherit"]}).trim()}};async function $I(e,t={}){try{let r=await D6(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 D6(e,t={}){let r=t.env??process.env,i=Bn(e),n=t.logger??console.log,o=t.fetchImpl??fetch,s=t.sshKeygen??Lne,a=Gt("HCLOUD_TOKEN",r,i);if(!a)throw Error("Missing HCLOUD_TOKEN");let c=Gt("HCLOUD_SSH_KEY_NAME",r,i);if(!c)throw Error("Missing HCLOUD_SSH_KEY_NAME");let l=Gt("KAMAL_SSH_PRIVATE_KEY_FILE",r,i),u=l?Po(l,e):zne(Nne(),".ssh",`${jne(c)}_ed25519`),d=`${u}.pub`,p=!1;if(!$ne(u))One(Pne(u),{recursive:!0,mode:448}),s.createEd25519KeyPair(u,c),p=!0;Cne(u,384);let m;if(p)m=z6(d,"utf-8").trim();else m=s.derivePublicKey(u),Rne(d,`${m}
841
+ `,"utf-8");if(m.length===0)throw Error(`Unable to derive a public key from ${u}`);let y=await Bne({fetchImpl:o,hcloudToken:a,publicKey:m,sshKeyName:c}),g=Ec(t.pushTo);if(g)await Ro([["KAMAL_SSH_PRIVATE_KEY",z6(u,"utf-8")]],{logger:n,runCommand:t.runCommand??Zr});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 Bne(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 Ac(r,Dne,{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 Ac(o,f.object({ssh_key:N6}),{label:"Hetzner SSH key create failed"}),!0}function jne(e){return e.replace(/[^A-Za-z0-9._-]+/g,"_")}Hi();fa();import{access as qne,mkdir as L6,readFile as Une,writeFile as j6}from"fs/promises";import{basename as Mne,join as ll}from"path";async function q6(e,t,r){let i=Dr.parse(t),n=Dr.parse(r.cohort),o=ll(e,"users"),s=ll(e,"cohorts"),a=ll(o,`${i}.yaml`),c=ll(o,`${i}.secrets.yaml`),l=ll(o,`${i}.secrets.yaml.age`),u=ll(s,`${n}.yaml`);await Promise.all([L6(o,{recursive:!0}),L6(s,{recursive:!0})]);let d=await B6(a,Hne(i,r.anchorId)),m=await Vne(l)?!1:await B6(c,Kne(i)),{addedToCohort:y}=await Fne(u,i);return{handle:i,cohort:n,userPath:a,secretsTemplatePath:c,cohortPath:u,createdUser:d,createdSecretsTemplate:m,addedToCohort:y}}async function Fne(e,t){let r=await Zne(e);if(r.members.includes(t))return{addedToCohort:!1};let i={...r,members:[...r.members,t].sort()};return await j6(e,Jne(i)),{addedToCohort:!0}}async function Zne(e){try{let t=await Une(e,"utf8"),r=qn(t,Un);if(!r.ok)throw Error(`${Mne(e)}: ${r.error}`);return r.data}catch(t){if(Gne(t))return{members:[]};throw t}}function Hne(e,t){return[`handle: ${e}`,"anchorProfile:",` name: ${Qne(e)}`,"discord:"," enabled: true",...t?[` anchorUserId: ${JSON.stringify(t)}`]:[],""].join(`
842
+ `)}function Kne(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(`
843
+ `)}function Jne(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(`
844
+ `)}async function B6(e,t){try{return await j6(e,t,{flag:"wx"}),!0}catch(r){if(Wne(r))return!1;throw r}}async function Vne(e){try{return await qne(e),!0}catch{return!1}}function Wne(e){return U6(e,"EEXIST")}function Gne(e){return U6(e,"ENOENT")}function U6(e,t){return typeof e==="object"&&e!==null&&"code"in e&&e.code===t}function Qne(e){return e.split("-").filter((t)=>t.length>0).map((t)=>`${t[0]?.toUpperCase()??""}${t.slice(1)}`).join(" ")}Re();pi();var Yne=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 F6(e,t,r={}){let i=r.fetchImpl??fetch,o=(await Zt(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 qg("health",()=>Xne(i,s,l,u,d),a,c),await qg("mcp-auth-gate",()=>rie(i,s),a,c),o.bundles.includes("site"))await qg("site",()=>M6(i,`${s}/`,"site"),a,c),await qg("studio",()=>M6(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 qg(e,t,r,i){try{await t(),r.push(e)}catch(n){i.push({name:e,message:at(n)})}}async function Xne(e,t,r,i,n){let o;for(let s=1;s<=r;s++)try{await eie(e,t);return}catch(a){if(o=a,s<r)await n(i)}throw o}async function eie(e,t){let i=await OI(e,`${t}/health/operate`,{method:"GET"}),n=await i.json().catch(()=>null),o=Yne.safeParse(n);if(!i.ok){let a=o.success?o.data.checks.filter((c)=>c.status!=="healthy").slice(0,10).map((c)=>`${c.name}: ${tie(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 tie(e){let t=e.replaceAll(/\s+/g," ").trim();return t.length<=300?t:`${t.slice(0,297)}...`}async function rie(e,t){let r=await OI(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 M6(e,t,r){let i=await OI(e,t,{method:"GET"});if(i.status>=400)throw Error(`${r} ${t} returned ${i.status}, expected < 400`)}async function OI(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 _7="brains-ops",rR={type:"string",placeholder:"<target>",description:"Push target (`gh` or `github`)"},jx={type:"boolean",description:"Show what would happen without writing anything"};function Nt(e){return{success:!1,message:cR(_7,e)}}var k7=mt({name:"init",usage:"<repo>",description:"Create a pilot repo skeleton",run:async({args:e})=>{let t=e[0];if(!t)return Nt(k7);return await YB(t),{success:!0,message:`Initialized ${t}`}}}),E7=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 Nt(E7);let i=ht(t,"to"),{upgradePilotRepo:n}=await Promise.resolve().then(() => (K6(),H6)),{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`}}}),I7=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 Nt(I7);let{loadCapabilityBundleReview:o,loadReviewedSitePins:s,stageLegacyCrossover:a}=await Promise.resolve().then(() => (EU(),kU)),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}`}}}),A7=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 Nt(A7);let i=t.resolveStatus??e6({...t.fetchImpl?{fetchImpl:t.fetchImpl}:{},...t.lookupHost?{lookupHost:t.lookupHost}:{}});return await Zo(r,{resolveStatus:i}),{success:!0,message:`Rendered ${r}/views/users.md`}}}),T7=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 Nt(T7);let o=ht(t,"anchor-id");return await q6(r,i,{cohort:n,...o?{anchorId:o}:{}}),{success:!0,message:`Added ${i} to ${n}`}}}),C7=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 Nt(C7);let o=nc(t,"apply")??!1,s=ht(t,"confirm"),{offboardPilotUsers:a}=await Promise.resolve().then(() => (X8(),Y8)),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)`}}}),$7=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 Nt($7);return await y6(r,i,t.runner,{...t.env?{env:t.env}:{}}),{success:!0,message:`Onboarded ${i}`}}}),O7=mt({name:"age-key:bootstrap",usage:"<repo>",description:"Generate the pilot age key and optional GitHub secret",flags:{"push-to":rR},run:async({args:e,flags:t},r)=>{let i=e[0];if(!i)return Nt(O7);let n=ht(t,"push-to");return S2(i,{...r.logger?{logger:r.logger}:{},...n?{pushTo:n}:{},...r.bootstrapRunCommand?{runCommand:r.bootstrapRunCommand}:{}})}}),R7=mt({name:"ssh-key:bootstrap",usage:"<repo>",description:"Bootstrap a deploy SSH key and optional GitHub secret",flags:{"push-to":rR},run:async({args:e,flags:t},r)=>{let i=e[0];if(!i)return Nt(R7);let n=ht(t,"push-to");return $I(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}:{}})}}),P7=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":rR},run:async({args:e,flags:t},r)=>{let i=e[0];if(!i)return Nt(P7);let n=ht(t,"handle"),o=ht(t,"push-to");return JB(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}:{}})}}),z7=mt({name:"secrets:push",usage:"<repo>",description:"Push env-backed local secrets to GitHub Secrets",flags:{"dry-run":jx},run:async({args:e,flags:t},r)=>{let i=e[0];if(!i)return Nt(z7);let n=await R6(i,{env:r.env,logger:r.logger,dryRun:nc(t,"dry-run")});return{success:!0,message:n.dryRun?`Dry run: would push ${n.pushedKeys.length} secrets`:`Pushed ${n.pushedKeys.length} secrets`}}}),N7=mt({name:"secrets:encrypt",usage:"<repo> <handle>",description:"Encrypt pilot secrets for a user with age",flags:{"dry-run":jx},run:async({args:e,flags:t},r)=>{let i=e[0],n=e[1];if(!i||!n)return Nt(N7);let o=await $6(i,n,{env:r.env,logger:r.logger,dryRun:nc(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}`}}}),D7=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":jx},run:async({args:e,flags:t},r)=>{let i=e[0],n=e[1],o=ht(t,"type"),s=ht(t,"confirm"),a=nc(t,"dry-run")??!1;if(!i||!n||!o||a===(s!==void 0))return Nt(D7);let{legacyProjectionJobTypeSchema:c}=await Promise.resolve().then(() => (LO(),DO)),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(() => (LO(),DO))).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)}`}}}}),L7=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 Nt(L7);let a=r.directorySyncStressRunner??(await Promise.resolve().then(() => (Lx(),Dx))).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}`}}}),B7=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 Nt(B7);let s=r.directorySyncStressAccessRunner??(await Promise.resolve().then(() => (Lx(),Dx))).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}`}}}),j7=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 Nt(j7);let s=r.directorySyncStressCleanupRunner??(await Promise.resolve().then(() => (Lx(),Dx))).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}`}}}),q7={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"}},U7=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:q7,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 Nt(U7);let a=r.healthWatchdogSmokeRunner??(await tR().then(() => eR)).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}`}}}),M7=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:q7,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 Nt(M7);let a=r.healthWatchdogSmokeCleanupRunner??(await tR().then(() => eR)).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}`}}}),F7=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 Nt(F7);let n=await F6(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(`
846
845
  `);return{success:!1,message:`Verified ${n.handle} (${n.bundles.join(",")}) at https://${n.domain}: passed ${o}; failed:
847
- ${s}`}}return{success:!0,message:`Verified ${n.handle} (${n.bundles.join(",")}) at https://${n.domain}: ${o}`}}}),Z7=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 Nt(Z7);return await vj(r,i,t.runner,{...t.env?{env:t.env}:{}}),{success:!0,message:`Reconciled cohort ${i}`}}});function v7(e,t){return[e,...t.length===0?["- (none)"]:t.map((r)=>`- ${r}`)]}var H7=mt({name:"reconcile-all",usage:"<repo> [--dry-run]",description:"Reconcile every cohort",flags:{"dry-run":jx},run:async({args:e,flags:t},r)=>{let i=e[0];if(!i)return Nt(H7);if(nc(t,"dry-run")){let n=await Sj(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)`}`,...v7("First-pass changed files:",n.firstPassChangedFiles),...v7("Second-pass changed files:",n.secondPassChangedFiles)].join(`
848
- `)}}return await Lg(i,r.runner,{...r.env?{env:r.env}:{}}),{success:!0,message:"Reconciled all cohorts"}}}),lEe=mt({name:"help",description:"Show this help message",run:()=>({success:!0,message:lR({cliName:_7,intro:"brains-ops \u2014 operator CLI for private brain fleet repos",commands:qx,globalFlags:nR})})}),uEe=mt({name:"version",description:"Show version",run:()=>({success:!0,message:`brains-ops ${Qp.version}`})}),nR={help:{type:"boolean",short:"h",description:"Show help"},version:{type:"boolean",short:"v",description:"Show version"}},qx=[k7,E7,I7,A7,T7,C7,$7,O7,R7,P7,z7,N7,D7,L7,B7,j7,U7,M7,F7,Z7,H7,lEe,uEe],dEe=uR(qx);async function K7(e,t={}){let r=dEe.get(e.command);if(!r)return{success:!1,message:`Unknown command: ${e.command}`};return r.run({args:e.args,flags:e.flags},t)}function J7(e){return oR(e,{commands:qx,globalFlags:nR})}var Wp;try{Wp=await K7(J7(process.argv.slice(2)))}catch(e){if(e instanceof Gp)console.error(e.message),process.exit(1);throw e}if(Wp.message)(Wp.success?console.info:console.error)(Wp.message);process.exit(Wp.success?0:1);
846
+ ${s}`}}return{success:!0,message:`Verified ${n.handle} (${n.bundles.join(",")}) at https://${n.domain}: ${o}`}}}),Z7=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 Nt(Z7);return await v6(r,i,t.runner,{...t.env?{env:t.env}:{}}),{success:!0,message:`Reconciled cohort ${i}`}}});function v7(e,t){return[e,...t.length===0?["- (none)"]:t.map((r)=>`- ${r}`)]}var H7=mt({name:"reconcile-all",usage:"<repo> [--dry-run]",description:"Reconcile every cohort",flags:{"dry-run":jx},run:async({args:e,flags:t},r)=>{let i=e[0];if(!i)return Nt(H7);if(nc(t,"dry-run")){let n=await S6(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)`}`,...v7("First-pass changed files:",n.firstPassChangedFiles),...v7("Second-pass changed files:",n.secondPassChangedFiles)].join(`
847
+ `)}}return await Lg(i,r.runner,{...r.env?{env:r.env}:{}}),{success:!0,message:"Reconciled all cohorts"}}}),cEe=mt({name:"help",description:"Show this help message",run:()=>({success:!0,message:lR({cliName:_7,intro:"brains-ops \u2014 operator CLI for private brain fleet repos",commands:qx,globalFlags:nR})})}),lEe=mt({name:"version",description:"Show version",run:()=>({success:!0,message:`brains-ops ${Qp.version}`})}),nR={help:{type:"boolean",short:"h",description:"Show help"},version:{type:"boolean",short:"v",description:"Show version"}},qx=[k7,E7,I7,A7,T7,C7,$7,O7,R7,P7,z7,N7,D7,L7,B7,j7,U7,M7,F7,Z7,H7,cEe,lEe],uEe=uR(qx);async function K7(e,t={}){let r=uEe.get(e.command);if(!r)return{success:!1,message:`Unknown command: ${e.command}`};return r.run({args:e.args,flags:e.flags},t)}function J7(e){return oR(e,{commands:qx,globalFlags:nR})}var Wp;try{Wp=await K7(J7(process.argv.slice(2)))}catch(e){if(e instanceof Gp)console.error(e.message),process.exit(1);throw e}if(Wp.message)(Wp.success?console.info:console.error)(Wp.message);process.exit(Wp.success?0:1);