@adhd/backlog 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js DELETED
@@ -1,179 +0,0 @@
1
- "use strict";var hf=Object.create;var ci=Object.defineProperty;var mf=Object.getOwnPropertyDescriptor;var gf=Object.getOwnPropertyNames;var yf=Object.getPrototypeOf,vf=Object.prototype.hasOwnProperty;var $f=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of gf(e))!vf.call(t,s)&&s!==n&&ci(t,s,{get:()=>e[s],enumerable:!(r=mf(e,s))||r.enumerable});return t};var wf=(t,e,n)=>(n=t!=null?hf(yf(t)):{},$f(e||!t||!t.__esModule?ci(n,"default",{value:t,enumerable:!0}):n,t));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Y=require("node:fs"),bf=require("node:url"),q=require("node:path"),ui=require("ts-morph"),at=require("ts-json-schema-generator"),Ef=require("fastify"),We=require("pino"),Fa=require("ajv"),qa=require("ajv-formats"),li=require("node:http"),Sf=require("@modelcontextprotocol/sdk/server/index.js"),Nf=require("@modelcontextprotocol/sdk/server/stdio.js"),Of=require("@modelcontextprotocol/sdk/server/sse.js"),_f=require("@modelcontextprotocol/sdk/server/streamableHttp.js"),fi=require("@modelcontextprotocol/sdk/types.js"),kf=require("better-sqlite3"),If=require("@adhd/sox-graph-store"),Jn=require("node:os"),Af=require("node:crypto");var Rr=typeof document<"u"?document.currentScript:null;function Pf(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:()=>t[n]})}}return e.default=t,Object.freeze(e)}const jf=Pf(q),Ka=new Set(["FIXED","RESOLVED","DONE","SHIPPED","VERIFIED","REMOVED"]),za=new Set(["MITIGATED"]),Ga=new Set(["SUPERSEDED","INVALID","DUPLICATE","WONTFIX"]),Ps=new Set(["FIXED","RESOLVED","DONE","SHIPPED","VERIFIED","REMOVED","MITIGATED","SUPERSEDED","INVALID","DUPLICATE","WONTFIX"]);function je(t){return Ps.has(t)}function js(t){return Ka.has(t)||za.has(t)}function xs(t){return Ga.has(t)}class ye extends Error{constructor(e,n){super(`backlog item not found: ${e}::${n}`),this.name="BacklogItemNotFoundError"}}class Wa extends Error{constructor(e){super(`transition to terminal status "${e}" requires at least one citation (either already attached via addCitation or passed inline to transitionStatus/resolveItem) — per the global CLAUDE.md rule "No citation, no claim."`),this.name="CitationRequiredError"}}class Ha extends Error{constructor(e){super(`transition to terminal-dismissed status "${e}" requires a reason string`),this.name="ReasonRequiredError"}}class Ja extends Error{constructor(e,n){super(`item is claimed by "${e}" since ${n} (not stale) — cannot start work`),this.heldBy=e,this.heldSince=n,this.name="ClaimHeldError"}}class xf extends Error{constructor(e){super(`dependency cycle detected: ${e.join(" -> ")}`),this.cycle=e,this.name="DependencyCycleError"}}const Ie="backlog-item",di="backlog-plan",pi="backlog-assignee",Tf="adhd-backlog:";function rr(t){return t.split("-")[0]??t}function sr(t){return t.replace(/-\d+$/,"")}function Qa(t,e,n,r){return`${n}
2
-
3
- ${r}
4
-
5
- <!-- ${Tf}${t}::${e} -->`}function Ts(t,e){return`${t}::${e}`}function Cs(t){switch(t){case"CRITICAL":return 10;case"HIGH":return 8;case"MEDIUM":return 5;case"LOW":return 2;default:return 1}}function Ya(t,e,n=[]){return[...new Set([Ie,t,e,...n])]}function ct(t){return t.tags.includes(Ie)&&!t.isSuperseded}function re(t){const e=t.metadata??{},n=e.humanId??"",r=e.kind??rr(n),s=e.family??sr(n),o=new Set([Ie,r,s]);return{nodeId:t.id,humanId:n,kind:r,family:s,title:e.title??t.summary??"",body:e.body??"",status:e.status??"UNKNOWN",priority:e.priority,repo:e.repo??t.namespace,projectPath:e.projectPath,plan:e.plan,assignee:e.assignee,claimedBy:e.claimedBy,claimedAt:e.claimedAt,citations:e.citations??[],notes:e.notes??[],tags:t.tags.filter(i=>!o.has(i)),createdAt:e.createdAt??t.tCreated,updatedAt:e.updatedAt??e.createdAt??t.tCreated}}function Xa(t,e,n){return t.db.transaction(()=>{const r=t.graph.queryNodes({kind:"generic",tags:[Ie],namespace:e,metadata:{family:n}});let s=0;for(const o of r){const i=o.metadata,a=/-(\d+)$/.exec((i==null?void 0:i.humanId)??"");a&&(s=Math.max(s,Number(a[1])))}return`${n}-${String(s+1).padStart(3,"0")}`}).immediate()}const hi={CRITICAL:0,HIGH:1,MEDIUM:2,LOW:3};function mi(t){const e=[Ie];t.kind&&e.push(t.kind),t.tags&&e.push(...t.tags);const n={};t.family&&(n.family=t.family),t.priority&&(n.priority=t.priority),t.plan&&(n.plan=t.plan),t.assignee&&(n.assignee=t.assignee),t.claimedBy&&(n.claimedBy=t.claimedBy),t.status&&t.status!=="open"&&t.status!=="closed"&&(n.status=t.status);const r={kind:"generic",tags:e,tagsMatchAll:!0};return t.repo!==void 0&&(r.namespace=t.repo),t.projectPath!==void 0&&(r.projectPath=t.projectPath),Object.keys(n).length>0&&(r.metadata=n),r}function Cf(t,e){return e.status==="open"?t.filter(n=>!je(n.status)):e.status==="closed"?t.filter(n=>je(n.status)):t}function Za(t,e={}){if(e.grep){const s=mi({...e});let i=t.graph.searchNodes(e.grep,{limit:e.limit??1e3,filter:s}).filter(ct);return e.offset&&(i=i.slice(e.offset)),i}const n=mi(e);return e.limit!==void 0&&(n.limit=e.limit),e.offset!==void 0&&(n.offset=e.offset),t.graph.queryNodes(n).filter(ct)}function Ze(t,e={}){const r=Za(t,e).map(re);return Cf(r,e)}function Ve(t,e,n){const r=Ts(e,n),o=t.graph.queryNodes({kind:"generic",tags:[Ie],namespace:e,metadata:{humanId:n}}).filter(ct);return o.find(i=>i.name===r)??o[0]??null}function Gt(t,e){const n={};for(const r of t){const s=e(r);s&&(n[s]=(n[s]??0)+1)}return n}function Rf(t,e={}){const n=Ze(t,{repo:e.repo,projectPath:e.projectPath}),r=n.filter(o=>!je(o.status)),s=n.filter(o=>je(o.status));return{total:n.length,open:r.length,closed:s.length,byStatus:Gt(n,o=>o.status),byKind:Gt(n,o=>o.kind),byFamily:Gt(n,o=>o.family),byPriority:Gt(n,o=>o.priority),byRepo:e.repo===void 0?Gt(n,o=>o.repo):{}}}function Mf(t,e={},n=20){const s=Ze(t,{repo:e.repo,projectPath:e.projectPath,status:"open"}).filter(o=>o.priority!==void 0);return s.sort((o,i)=>{const a=hi[o.priority??""]??4,c=hi[i.priority??""]??4;return a-c||o.humanId.localeCompare(i.humanId)}),s.slice(0,n)}function ec(t,e){const n=t.graph.getEdges({src:e,rel:"DEPENDS_ON"}),r=[];for(const s of n){const o=t.graph.getNode(s.dst);o&&r.push(o)}return r}function Df(t,e,n){const r=Ve(t,e,n);return r?ec(t,r.id).filter(s=>!s.tInvalid).map(re).filter(s=>!je(s.status)):[]}function Lf(t,e={}){return Ze(t,{repo:e.repo,projectPath:e.projectPath,status:"open"}).filter(r=>{if(r.claimedBy)return!1;const s=Ve(t,r.repo,r.humanId);return s?ec(t,s.id).filter(i=>!i.tInvalid).every(i=>je(re(i).status)):!1})}function tc(t,e={}){const n=Ze(t,{repo:e.repo,projectPath:e.projectPath}),r=n.map(o=>({humanId:o.humanId,title:o.title,status:o.status})),s=[];for(const o of n){const i=Ve(t,o.repo,o.humanId);if(i)for(const a of["DEPENDS_ON","RELATES_TO","PART_OF"])for(const c of t.graph.getEdges({src:i.id,rel:a})){const u=t.graph.getNode(c.dst);if(!u||u.tInvalid)continue;const l=u.metadata;l!=null&&l.humanId&&s.push({from:o.humanId,to:l.humanId,rel:a})}}return{nodes:r,edges:s}}function Bf(t,e={}){var c;const n=tc(t,e),r=n.edges.filter(u=>u.rel==="DEPENDS_ON"),s=new Map;for(const u of n.nodes)s.set(u.humanId,new Set);for(const u of r)(c=s.get(u.from))==null||c.add(u.to);const o=new Set(n.nodes.map(u=>u.humanId)),i=[];let a=!0;for(;o.size>0&&a;){a=!1;for(const u of[...o].sort())[...s.get(u)??new Set].every(m=>!o.has(m))&&(i.push(u),o.delete(u),a=!0)}return o.size>0?{ok:!1,cycle:Uf([...o],s)}:{ok:!0,order:i}}function Uf(t,e){const n=new Set(t),r=new Set,s=[];function o(i){if(r.has(i)){const a=s.indexOf(i);return[...s.slice(a),i]}if(!n.has(i))return null;r.add(i),s.push(i);for(const a of e.get(i)??[]){const c=o(a);if(c)return c}return s.pop(),r.delete(i),null}for(const i of t){const a=o(i);if(a)return a}return t}function Vf(t,e,n={}){const r=Ze(t,{repo:n.repo,projectPath:n.projectPath}),s=e*6e4,o=Date.now();return r.filter(i=>!i.claimedBy||!i.claimedAt?!1:o-Date.parse(i.claimedAt)>s)}function Ff(t,e,n){var u,l,f,m;const r=Ve(t,e,n);if(!r)throw new ye(e,n);const s=re(r),o=[{at:s.createdAt,kind:"created",detail:{title:s.title,repo:s.repo}}];for(const p of s.citations)o.push({at:s.updatedAt,kind:"citation",detail:{...p}});for(const p of s.notes)o.push({at:p.at,kind:"note",detail:{by:p.by,text:p.text}});o.sort((p,d)=>p.at.localeCompare(d.at));const i=t.graph.getSupersessionChain(r.id);let a;if(i.length>1){const p=i.findIndex(g=>g.id===r.id),d=p>0?((l=(u=i[p-1])==null?void 0:u.metadata)==null?void 0:l.humanId)??void 0:void 0,v=p>=0&&p<i.length-1?((m=(f=i[p+1])==null?void 0:f.metadata)==null?void 0:m.humanId)??void 0:void 0;a={},d&&(a.supersedes=d),v&&(a.supersededBy=v)}const c={humanId:s.humanId,history:o};return a&&(c.supersessionChain=a),c}class qf extends Error{constructor(e){super(`backlog item not found or invalidated: node ${e}`),this.nodeId=e,this.name="NotFoundError"}}function ve(t,e,n){return t.db.transaction(()=>{const r=t.graph.getNode(e);if(!r||r.tInvalid)throw new qf(e);const s=r.metadata??{},o=n(s);return t.graph.touch(e,{metadata:o}),o}).immediate()}function Kf(t,e,n){const r=new Map;for(const o of t.graph.searchNodes(n.title,{limit:10,filter:{tags:[Ie],namespace:e}}))ct(o)&&r.set(o.id,o);const s=n.dedupeScan;if(s!=null&&s.symbol)for(const o of t.graph.queryNodes({kind:"generic",tags:[Ie],namespace:e,metadata:{dedupeSymbol:s.symbol}}))ct(o)&&r.set(o.id,o);if(s!=null&&s.path)for(const o of t.graph.queryNodes({kind:"generic",tags:[Ie],namespace:e,metadata:{dedupePath:s.path}}))ct(o)&&r.set(o.id,o);if(s!=null&&s.errorText)for(const o of t.graph.queryNodes({kind:"generic",tags:[Ie],namespace:e,metadata:{dedupeErrorText:s.errorText}}))ct(o)&&r.set(o.id,o);return[...r.values()].map(re)}function Rs(t,e){var l,f,m;if(e.idOverride){const p=Ve(t,e.repo,e.idOverride);if(p){const d=re(p);return{item:d,created:!1,duplicateCandidates:[d]}}}const n=e.force?[]:Kf(t,e.repo,e);if(n.length>0&&!e.force)return{item:n[0],created:!1,duplicateCandidates:n};const r=e.idOverride??Xa(t,e.repo,e.family),s=rr(r),o=sr(r),i=new Date().toISOString(),a={humanId:r,kind:s,family:o,title:e.title,body:e.body,status:"OPEN",repo:e.repo,citations:[],notes:[],createdAt:i,updatedAt:i};e.priority!==void 0&&(a.priority=e.priority),e.projectPath!==void 0&&(a.projectPath=e.projectPath),e.plan!==void 0&&(a.plan=e.plan),((l=e.dedupeScan)==null?void 0:l.symbol)!==void 0&&(a.dedupeSymbol=e.dedupeScan.symbol),((f=e.dedupeScan)==null?void 0:f.path)!==void 0&&(a.dedupePath=e.dedupeScan.path),((m=e.dedupeScan)==null?void 0:m.errorText)!==void 0&&(a.dedupeErrorText=e.dedupeScan.errorText);const c=t.graph.writeNode(Qa(e.repo,r,e.title,e.body),{kind:"generic",name:Ts(e.repo,r),summary:e.title,tags:Ya(s,o,e.tags),namespace:e.repo,importance:Cs(e.priority),confidence:"confirmed",...e.projectPath!==void 0?{projectPath:e.projectPath}:{},metadata:a}),u=t.graph.getNode(c);if(!u)throw new Error(`backlog: writeNode returned an id that does not resolve: ${c}`);return{item:re(u),created:!0,duplicateCandidates:[]}}function nc(t,e,n){const r=Ve(t,e,n);return r?re(r):null}function rc(t,e,n){const r=Ve(t,e,n);if(!r)throw new ye(e,n);return r}function zf(t,e,n,r){const s=rc(t,e,n);if(ve(t,s.id,i=>{const a={...i,updatedAt:new Date().toISOString()};return r.title!==void 0&&(a.title=r.title),r.body!==void 0&&(a.body=r.body),r.projectPath!==void 0&&(a.projectPath=r.projectPath),a}),r.title!==void 0||r.tags!==void 0||r.projectPath!==void 0){const i={};if(r.title!==void 0&&(i.summary=r.title),r.tags!==void 0){const a=rr(n),c=sr(n);i.tags=Ya(a,c,r.tags)}r.projectPath!==void 0&&(i.projectPath=r.projectPath),t.graph.touch(s.id,i)}const o=t.graph.getNode(s.id);if(!o)throw new ye(e,n);return re(o)}function Gf(t,e,n,r){const s=rc(t,e,n);t.graph.invalidate(s.id,r)}const Wf=30;class Hf extends Error{constructor(e,n){super(`cannot release claim held by "${e}" as "${n}" without force`),this.heldBy=e,this.name="ClaimContentionError"}}function sc(t,e,n,r={}){const s=(r.staleAfterMin??Wf)*6e4;let o;return ve(t,e,i=>{const a=Date.now(),c=new Date(a).toISOString();return!i.claimedBy||i.claimedBy===n?(o={status:i.claimedBy?"renewed":"claimed",claimedBy:n,claimedAt:c},{...i,claimedBy:n,claimedAt:c,updatedAt:c}):(i.claimedAt?a-Date.parse(i.claimedAt):Number.POSITIVE_INFINITY)<=s&&!r.force?(o={status:"held",claimedBy:n,claimedAt:c,heldBy:i.claimedBy,...i.claimedAt!==void 0?{heldSince:i.claimedAt}:{}},i):(o={status:"reclaimed-stale",claimedBy:n,claimedAt:c,previousClaimant:i.claimedBy},{...i,claimedBy:n,claimedAt:c,updatedAt:c})}),o}function Jf(t,e,n){let r;return ve(t,e,s=>{const o=new Date().toISOString();return r={status:s.claimedBy?"renewed":"claimed",claimedBy:n,claimedAt:o},{...s,claimedBy:n,claimedAt:o,updatedAt:o}}),r}function Qf(t,e,n,r={}){let s;return ve(t,e,o=>{if(!o.claimedBy)return s={status:"release-noop"},o;if(o.claimedBy!==n&&!r.force)throw new Hf(o.claimedBy,n);s={status:"released",wasClaimedBy:o.claimedBy};const a=new Date().toISOString(),c={...o,updatedAt:a};return delete c.claimedBy,delete c.claimedAt,c}),s}function or(t,e,n){const r=Ve(t,e,n);if(!r)throw new ye(e,n);return r}function ir(t,e,n,r,s){const o=or(t,e,n);ve(t,o.id,a=>{const c=s.citations&&s.citations.length>0?[...a.citations,...s.citations]:a.citations;if(js(r)&&c.length===0)throw new Wa(r);if(xs(r)&&!s.reason)throw new Ha(r);const u=new Date().toISOString(),l=[...a.notes];s.note&&l.push({by:s.by,at:u,text:s.note}),s.reason&&l.push({by:s.by,at:u,text:`[transition to ${r}] ${s.reason}`});const f={...a,status:r,citations:c,notes:l,updatedAt:u};return Ps.has(r)&&(delete f.claimedBy,delete f.claimedAt),f});const i=t.graph.getNode(o.id);if(!i)throw new ye(e,n);return re(i)}function Yf(t,e,n,r,s){return ir(t,e,n,r,s)}function Xf(t,e,n,r){const s=or(t,e,n),o=sc(t,s.id,r);if(o.status==="held")throw new Ja(o.heldBy??"unknown",o.heldSince??"unknown");return ir(t,e,n,"IN_PROGRESS",{by:r})}function Zf(t,e,n,r){const s=or(t,e,n);ve(t,s.id,i=>({...i,citations:[...i.citations,r],updatedAt:new Date().toISOString()}));const o=t.graph.getNode(s.id);if(!o)throw new ye(e,n);return re(o)}function ed(t,e,n,r,s){const o=or(t,e,n);ve(t,o.id,a=>{const c=new Date().toISOString();return{...a,notes:[...a.notes,{by:r,at:c,text:s}],updatedAt:c}});const i=t.graph.getNode(o.id);if(!i)throw new ye(e,n);return re(i)}function td(t,e,n={}){const r=new Set((n.exclude??[]).map(i=>i.toUpperCase())),s=Ze(t,{repo:e.repo,projectPath:e.projectPath,status:"closed"}),o=[];for(const i of s){if(r.has(i.humanId.toUpperCase())||!je(i.status))continue;const a=new Date().toISOString();ve(t,i.nodeId,u=>({...u,archivedAt:a,updatedAt:a}));const c=t.graph.getNode(i.nodeId);c&&o.push(re(c))}return o}function ge(t,e,n){const r=Ve(t,e,n);if(!r)throw new ye(e,n);return r}function nd(t,e,n,r){const s=ge(t,e,n),o=ge(t,e,r);t.graph.writeEdge(s.id,o.id,"DEPENDS_ON")}function rd(t,e,n,r){const s=ge(t,e,n),o=ge(t,e,r);t.db.prepare("DELETE FROM edge WHERE src = ? AND dst = ? AND rel = 'DEPENDS_ON'").run(s.id,o.id)}function sd(t,e,n,r){const s=ge(t,e,n),o=ge(t,e,r);t.graph.writeEdge(s.id,o.id,"RELATES_TO")}function od(t,e,n,r,s){const o=ge(t,e,n),i=r.idOverride??Xa(t,e,r.family),a=rr(i),c=sr(i),u=new Date().toISOString(),l={humanId:i,kind:a,family:c,title:r.title,body:r.body,status:"OPEN",repo:e,citations:[],notes:[],createdAt:u,updatedAt:u};r.priority!==void 0&&(l.priority=r.priority),r.projectPath!==void 0&&(l.projectPath=r.projectPath),r.plan!==void 0&&(l.plan=r.plan);const f=t.graph.supersede(o.id,Qa(e,i,r.title,r.body),{kind:"generic",name:Ts(e,i),summary:r.title,tags:["backlog-item",a,c,...r.tags??[]],namespace:e,importance:Cs(r.priority),confidence:"confirmed",...r.projectPath!==void 0?{projectPath:r.projectPath}:{},metadata:l});ve(t,o.id,p=>{const d=[...p.notes,{by:"system",at:u,text:`[superseded by ${i}] ${s}`}],v={...p,status:"SUPERSEDED",notes:d,updatedAt:u};return delete v.claimedBy,delete v.claimedAt,v}),t.graph.invalidate(o.id,s);const m=t.graph.getNode(f);if(!m)throw new Error(`backlog: supersede() returned an id that does not resolve: ${f}`);return re(m)}function id(t,e,n,r){const s=ge(t,e,n),o=[];for(const i of r){const a=Rs(t,{...i,repo:e});t.graph.writeEdge(a.item.nodeId,s.id,"PART_OF"),o.push(a.item)}return o}function ad(t,e,n,r,s){const o=ge(t,e,n),i=ge(t,e,r);ve(t,i.id,c=>{const u=new Date().toISOString(),l={...c,status:"DUPLICATE",notes:[...c.notes,{by:"system",at:u,text:`[merged into ${n}] ${s}`}],updatedAt:u};return delete l.claimedBy,delete l.claimedAt,l}),t.graph.writeEdge(i.id,o.id,"SAME_AS"),t.graph.invalidate(i.id,s);const a=t.graph.getNode(o.id);if(!a)throw new ye(e,n);return re(a)}function cd(t,e,n,r){const s=ge(t,e,n);ve(t,s.id,i=>({...i,priority:r,updatedAt:new Date().toISOString()})),t.graph.touch(s.id,{importance:Cs(r)});const o=t.graph.getNode(s.id);if(!o)throw new ye(e,n);return re(o)}function ud(t,e,n){const r=`${e}::plan:${n}`,o=t.graph.queryNodes({kind:"generic",tags:[di],namespace:e,metadata:{planSlug:n}}).find(i=>i.name===r&&!i.isSuperseded);return o?o.id:t.graph.writeNode(`plan:${n}`,{kind:"generic",name:r,summary:n,tags:[di],namespace:e,metadata:{planSlug:n}})}function ld(t,e,n,r){const s=ge(t,e,n),o=ud(t,e,r);ve(t,s.id,i=>({...i,plan:r,updatedAt:new Date().toISOString()})),t.graph.writeEdge(s.id,o,"MEMBER_OF")}function fd(t,e){const r=t.graph.queryNodes({kind:"entity",tags:[pi],metadata:{identity:e}}).find(s=>s.name===e&&!s.isSuperseded);return r?r.id:t.graph.writeNode(`assignee:${e}`,{kind:"entity",name:e,summary:e,tags:[pi],metadata:{identity:e}})}function dd(t,e,n,r,s){const o=ge(t,e,n),i=fd(t,r);ve(t,o.id,c=>{const u=new Date().toISOString();return{...c,assignee:r,notes:[...c.notes,{by:s,at:u,text:`assigned to ${r}`}],updatedAt:u}}),t.graph.writeEdge(o.id,i,"ASSIGNED_TO");const a=t.graph.getNode(o.id);if(!a)throw new ye(e,n);return re(a)}const gi=/^(#{2,3})\s+([A-Z][A-Z0-9]*(?:-[A-Z0-9]+)+)/,pd=["FIXED","RESOLVED","DONE","SHIPPED","VERIFIED","REMOVED","CLOSED"],hd=["MITIGATED"],md=["INVALID","SUPERSEDED","DUPLICATE","WONTFIX"],gd=new Set([...pd,...hd,...md]),yd=new Set(["OPEN","IN_PROGRESS","PARTIAL","OUTSTANDING","DEFERRED","BLOCKED","MIXED","UNKNOWN","FIXED","RESOLVED","DONE","SHIPPED","VERIFIED","REMOVED","MITIGATED","SUPERSEDED","INVALID","DUPLICATE","WONTFIX"]);function oc(t){const e=t.toUpperCase();return e==="IN-PROGRESS"?"IN_PROGRESS":e==="CLOSED"?"RESOLVED":yd.has(e)?e:"UNKNOWN"}function ic(t){var o;const e=(t??"").toLowerCase();if(!e.trim())return null;const n=i=>e.includes(i);if(n("outstanding"))return{label:"OUTSTANDING",open:!0};if(n("partially"))return{label:"PARTIAL",open:!0};if(n("in progress"))return{label:"IN-PROGRESS",open:!0};const r=n("shipped")&&"SHIPPED"||n("superseded")&&"SUPERSEDED"||n("invalid")&&"INVALID"||n("mitigated")&&"MITIGATED"||n("removed")&&!n("open")&&"REMOVED"||n("fixed")&&"FIXED"||n("resolved")&&"RESOLVED"||n("done")&&"DONE"||null,s=n("open")&&"OPEN"||(n("deferred")||n("defer"))&&"DEFERRED"||null;return r&&s?{label:"MIXED",open:!0}:r?{label:r,open:!1}:s?{label:s,open:!0}:n("downgraded")?{label:"OPEN",open:!0}:{label:((o=e.trim().split(/\s+/)[0])==null?void 0:o.toUpperCase().replace(/[^A-Z]/g,""))||"UNKNOWN",open:!0}}function ac(t,e){const n=e.match(/^\s*-?\s*\*\*Status:\*?\*?\s*([^\n]+)/im),r=n?ic(n[1]):null;if(r)return r;const s=t.toUpperCase();for(const o of["RESOLVED","FIXED","MITIGATED","DONE","CLOSED"])if(s.includes(o))return{label:o,open:!1};return{label:"UNKNOWN",open:!0}}function cc(t,e){const r=`${t}
6
- ${e}`.match(/\*{0,2}priority:?\*{0,2}\s*[:-]?\s*(CRITICAL|HIGH|MEDIUM|LOW)/i);return r?r[1].toUpperCase():/—\s*CRITICAL\b/i.test(t)||/\bCRITICAL\b/.test(t)?"CRITICAL":""}function uc(t){const e=t.split(`
7
- `),n=[];let r=null;const s=()=>{if(!r)return;const o=r.bodyLines.join(`
8
- `),i=ac(r.headerLine,o),a=cc(r.headerLine,o),{bodyLines:c,...u}=r,l=!gd.has(i.label);n.push({...u,status:i.label,open:l,terminal:!l,priority:a,body:o.trim()}),r=null};return e.forEach((o,i)=>{const a=o.match(gi),c=/^#{2,3}\s/.test(o);if(a&&/\d/.test(a[2])){s();const u=a[2],l=o.replace(gi,"").replace(/^\s*[—–-]\s*/,"").trim(),f=u.split("-");r={id:u,kind:f[0]??u,family:u.replace(/-\d+[a-z]?$/i,""),title:l,level:a[1].length,line:i+1,headerLine:o,bodyLines:[]}}else c?(s(),r=null):r&&r.bodyLines.push(o)}),s(),n}function vd(t){return`**Citations:** [${t.map(n=>{const r=n.lines?`${n.file}:${n.lines}`:n.file;return n.context?`${r} (${n.context})`:r}).join(", ")}]`}function $d(t){return t==="IN_PROGRESS"?"IN PROGRESS":t}function lc(t){const e=[];e.push(`### ${t.humanId} — ${t.title}`),e.push(""),e.push(`**Status:** ${$d(t.status)}`),t.priority&&e.push(`**Priority:** ${t.priority}`),t.assignee&&e.push(`**Assignee:** ${t.assignee}`),t.plan&&e.push(`**Plan:** ${t.plan}`),e.push(""),t.body&&e.push(t.body,""),t.citations.length>0&&e.push(vd(t.citations));for(const n of t.notes)e.push(`- Note (${n.by}, ${n.at}): ${n.text}`);return e.join(`
9
- `).trimEnd()}function fc(t){return t.length===0?"":`${t.map(lc).join(`
10
-
11
- `)}
12
- `}function wd(t){return t.split(`
13
- `).map(bd).join(`
14
- `)}function bd(t){return/^###\s/.test(t)?`##${t}`:/^##\s/.test(t)?`##${t}`:t}function dc(t,e){let n=`### Archived — resolved/terminal backlog items relocated in batch (${e})
15
-
16
- `;return n+="> Moved via `@adhd/backlog`'s `archiveResolved` (canonical terminal statuses: FIXED/RESOLVED/DONE/\n",n+=`> SHIPPED/VERIFIED/REMOVED/MITIGATED/SUPERSEDED/INVALID/DUPLICATE/WONTFIX). The graph node itself is
17
- `,n+=`> NEVER deleted — this is a rendered snapshot; full history remains queryable via auditTrail.
18
-
19
- `,n+=t.map(r=>wd(lc(r))).join(`
20
-
21
- `),n+=`
22
- `,n}function pc(t){return t.map(e=>{const n={humanId:e.id,title:e.title,body:e.body,status:oc(e.status)};return e.priority&&(e.priority==="CRITICAL"||e.priority==="HIGH"||e.priority==="MEDIUM"||e.priority==="LOW")&&(n.priority=e.priority),n})}function Ms(t,e,n){const r=nc(t.store,e,n);if(!r)throw new ye(e,n);return r}async function hc(t,e){return Rs(t.store,e)}async function mc(t,e,n){return nc(t.store,e,n)}async function gc(t,e,n,r){return zf(t.store,e,n,r)}async function yc(t,e){return Ze(t.store,e??{})}async function vc(t,e,n,r){Gf(t.store,e,n,r)}async function $c(t,e){return Rf(t.store,e??{})}async function wc(t,e,n){return Mf(t.store,e??{},n??20)}async function bc(t,e){return Lf(t.store,e??{})}async function Ec(t,e,n){return Df(t.store,e,n)}async function Sc(t,e){return tc(t.store,e??{})}async function Nc(t,e){return Bf(t.store,e??{})}async function Oc(t,e,n){return Vf(t.store,e,n??{})}async function _c(t,e,n,r,s){const o=Ms(t,e,n);return sc(t.store,o.nodeId,r,s??{})}async function kc(t,e,n,r){const s=Ms(t,e,n);return Jf(t.store,s.nodeId,r)}async function Ic(t,e,n,r,s){const o=Ms(t,e,n);return Qf(t.store,o.nodeId,r,s??{})}async function Ac(t,e,n,r,s){return dd(t.store,e,n,r,s)}async function Pc(t,e,n,r){return Xf(t.store,e,n,r)}async function jc(t,e,n,r,s){return ir(t.store,e,n,r,s)}async function xc(t,e,n,r){return Zf(t.store,e,n,r)}async function Tc(t,e,n,r,s){return ed(t.store,e,n,r,s)}async function Cc(t,e,n,r,s){return Yf(t.store,e,n,r,s)}async function Rc(t,e,n){const r=td(t.store,e,n??{}),s=r.length>0?dc(r,new Date().toISOString().slice(0,10)):"";return{archivedCount:r.length,changelogMarkdown:s}}async function Mc(t,e,n,r){nd(t.store,e,n,r)}async function Dc(t,e,n,r){rd(t.store,e,n,r)}async function Lc(t,e,n,r){sd(t.store,e,n,r)}async function Bc(t,e,n,r,s){return od(t.store,e,n,r,s)}async function Uc(t,e,n,r){return id(t.store,e,n,r)}async function Vc(t,e,n,r,s){return ad(t.store,e,n,r,s)}async function Fc(t,e,n,r){return cd(t.store,e,n,r)}async function qc(t,e,n,r){ld(t.store,e,n,r)}async function Kc(t,e){const n=Y.readFileSync(e.path,"utf8"),r=uc(n),s=pc(r),o={parsed:s.length,created:0,skippedDuplicates:0,errors:[]};if(e.dryRun)return o;for(const i of s)try{const a=Rs(t.store,{family:i.humanId.replace(/-\d+$/,""),idOverride:i.humanId,title:i.title,body:i.body,repo:e.repo,...e.projectPath!==void 0?{projectPath:e.projectPath}:{},...i.priority!==void 0?{priority:i.priority}:{},force:!0});a.created&&i.status!=="OPEN"&&ir(t.store,e.repo,i.humanId,i.status,{by:"system:importFromMarkdown",...js(i.status)?{citations:[{file:e.path}]}:{},...xs(i.status)?{reason:`imported from markdown at status ${i.status}`}:{}}),a.created?o.created+=1:o.skippedDuplicates+=1}catch(a){o.errors.push({humanId:i.humanId,message:a instanceof Error?a.message:String(a)})}return o}async function zc(t,e){let r=Za(t.store,e??{}).filter(s=>{var o;return!((o=s.metadata)!=null&&o.archivedAt)}).map(re);return(e==null?void 0:e.status)==="open"?r=r.filter(s=>!je(s.status)):(e==null?void 0:e.status)==="closed"&&(r=r.filter(s=>je(s.status))),fc(r)}async function Gc(t,e){return Ze(t.store,e??{})}async function Wc(t,e,n){return Ff(t.store,e,n)}const Ed=Object.freeze(Object.defineProperty({__proto__:null,addCitation:xc,addDependency:Mc,appendNote:Tc,archiveResolved:Rc,assignItem:Ac,attachToPlan:qc,auditTrail:Wc,blockers:Ec,claimItem:_c,createItem:hc,dependencyGraph:Sc,exportJson:Gc,getItem:mc,importFromMarkdown:Kc,linkRelated:Lc,listItems:yc,mergeItems:Vc,readyItems:bc,releaseClaim:Ic,removeDependency:Dc,renderToMarkdown:zc,renewClaim:kc,resolveItem:Cc,setPriority:Fc,softDeleteItem:vc,splitItem:Uc,spotlight:wc,staleClaims:Oc,startWork:Pc,stats:$c,supersedeItem:Bc,topoOrder:Nc,transitionStatus:jc,updateItem:gc},Symbol.toStringTag,{value:"Module"})),Hc=Symbol.for("adhd.apigen.extraction-session");function Jc(t,e){const n=[...t.getImportDeclarations().map(r=>r.getModuleSpecifierSourceFile()),...t.getExportDeclarations().map(r=>r.getModuleSpecifierSourceFile())];for(const r of n){if(!r)continue;const s=r.getFilePath();if(!s.includes("/node_modules/")&&!e.has(s)){e.add(s);try{r.refreshFromFileSystemSync()}catch{}Jc(r,e)}}}function Qc(t){try{const e=Y.statSync(t);return`${e.mtimeMs}:${e.size}`}catch{return"nostat"}}const Mn=new Map,yi=new Map;function Sd(t,e,n){const r=e??"",s=Mn.get(r);let o=n;if(s&&s.fileVersions.size>0){const c=[n],u=[...s.fileVersions.entries()].sort(([l],[f])=>l.localeCompare(f));for(const[l,f]of u)l!==t&&c.push(`${l}:${f}`);o=c.join("|")}const i=`${t}\0${e??""}`;let a=yi.get(i);return(!a||a.version!==o)&&(a={version:o,schemas:new Map},yi.set(i,a)),a.schemas}function Nd(){const t={projectsBuilt:0,generatorsBuilt:0,schemaCacheHits:0,schemaCacheMisses:0},e=new Map;let n=!1;return{[Hc]:!0,stats:t,schemaCache:new Map,aliasCache:new WeakMap,zodImportCache:new WeakMap,generatorCache:new Map,projectFor(r){if(n)throw new Error("apigen-core: ExtractionSession used after dispose()");const s=r??"",o=r?this.statVersion(r):"";let i=Mn.get(s);return i&&i.tsconfigVersion!==o&&(i=void 0),i||(i={project:r?new ui.Project({tsConfigFilePath:r,skipAddingFilesFromTsConfig:!0}):new ui.Project({skipAddingFilesFromTsConfig:!0}),tsconfigVersion:o,fileVersions:new Map},Mn.set(s,i),t.projectsBuilt++),i.project},sourceFileFor(r,s){const o=this.projectFor(s),i=Mn.get(s??""),a=this.statVersion(r);let c=o.getSourceFile(r);if(c===void 0?c=o.addSourceFileAtPath(r):i&&i.fileVersions.get(r)!==a&&c.refreshFromFileSystemSync(),i==null||i.fileVersions.set(r,a),i){const u=new Set([r]);Jc(c,u);for(const l of u)l!==r&&i.fileVersions.set(l,this.statVersion(l))}return c},statVersion(r){let s=e.get(r);return s===void 0&&(s=Qc(r),e.set(r,s)),s},dispose(){n=!0,this.schemaCache.clear(),this.generatorCache.clear(),e.clear()}}}function Od(t){const e=t;if(e[Hc]!==!0)throw new Error("apigen-core: unknown ExtractionSession implementation — create sessions with createExtractionSession()");return e}const Qn="x-apigen-logical";function vi(t,e){const n=new Set,r=[t];for(;r.length>0;){const s=r.pop();if(!s||n.has(s))continue;n.add(s);const o=s.$ref;if(typeof o=="string"){if(e){const f=e[o];if(!f){const m=Object.keys(e).join(", ")||"(none)";throw new Error(`[apigen-logical] $ref "${o}" cannot be resolved. Available $defs: ${m}`)}r.push(f)}continue}const i=s.oneOf;if(Array.isArray(i))for(const f of i)typeof f=="object"&&f!==null&&r.push(f);const a=s.properties;if(a)for(const f of Object.values(a))r.push(f);const c=s.items;if(Array.isArray(c))for(const f of c)typeof f=="object"&&f!==null&&r.push(f);else typeof c=="object"&&c!==null&&r.push(c);const u=s.additionalProperties;typeof u=="object"&&u!==null&&r.push(u);const l=s.propertyNames;typeof l=="object"&&l!==null&&r.push(l)}}const $i=new Set(["string","number","boolean","integer"]);function _d(t){if(typeof t!="object"||t===null)return!1;const e=t;if(e.$ref!==void 0||e.oneOf||e.anyOf||e.allOf)return!1;const{type:n}=e;return typeof n=="string"?$i.has(n):Array.isArray(n)?n.every(r=>$i.has(r)||r==="null"):Array.isArray(e.enum)&&e.enum.length>0?e.enum.every(r=>["string","number","boolean"].includes(typeof r)):!1}function kd(t){if(!t||typeof t!="object")return!1;const e=t.properties;return e===void 0||typeof e!="object"||e===null?!1:Object.values(e).every(_d)}function Id(t){const e={},n=r=>{for(const s of["definitions","$defs"]){const o=r[s];if(o)for(const[i,a]of Object.entries(o)){const c=i.startsWith("#/")?i:`#/${s}/${i}`;e[c]=a}}};for(const r of Object.values(t.schemas))n(r.input),n(r.output);if(Object.keys(e).length!==0)for(const[r,s]of Object.entries(t.schemas))try{vi(s.input,e),vi(s.output,e)}catch(o){throw new Error(`[apigen-core-client] Schema validation failed for function "${r}": ${o.message}`)}}function Ad(t,e){const n=['apigen calling convention: all domain parameters go inside a "data" envelope — e.g. { "data": { ... } }'+(e?".":" (an empty object for this zero-parameter tool).")];return t.length>0&&n.push(`Field(s) ${t.map(r=>`"${r}"`).join(", ")} are transport-level envelope metadata, NOT domain data — do not nest them under "data". Over MCP they are read from arguments._meta["x-<pluginId>-<field>"] (default pluginId "adhd"); see @adhd/apigen-engine-naming's envelopeMetaKey/envelopeCliFlag/envelopeEnvVar for the HTTP-header / CLI-flag / env-var equivalents.`),n.join(" ")}function Pd(t,e,n){Id(t);const r={};for(const[s,o]of Object.entries(t.schemas)){const i={},a=o.input.properties??{},c=o.input.required??[],u={},l=[];for(const v of e)if(v.envelope&&i[v.id]!==!1)for(const[g,y]of Object.entries(v.envelope))u[g]=y,l.includes(g)||l.push(g);const f={type:"object",properties:a,additionalProperties:!1,...c.length>0?{required:c}:{}},m=o.safe===!0||kd(o.input),p=o.input.definitions,d=o.input.$defs;r[s]={input:{type:"object",properties:{...u,data:f},required:[...l,...c.length>0?["data"]:[]],additionalProperties:!1,description:Ad(Object.keys(u),Object.keys(a).length>0),...p?{definitions:p}:{},...d?{$defs:d}:{}},output:o.output,...o.hasCtx?{hasCtx:!0}:{},"x-apigen-safe":m}}return r}const jd=8;function xd(t,e){try{return e?t.getText(e):t.getText()}catch{try{return t.getText()}catch{return}}}let Td=0;async function Cd(t,e,n,r){const s=`__ApigenProbe_${process.pid}_${Td++}`;let o;try{o=e.addTypeAlias({name:s,type:n});const i=o.getType();return await r(i)}catch{return}finally{try{o==null||o.remove()}catch{}}}async function Yc(t,e,n){if(n>jd)return{};if(t.isString()||t.isStringLiteral())return t.isStringLiteral()?{type:"string",enum:[t.getLiteralValue()]}:{type:"string"};if(t.isNumber()||t.isNumberLiteral())return t.isNumberLiteral()?{type:"number",enum:[t.getLiteralValue()]}:{type:"number"};if(t.isBoolean())return{type:"boolean"};if(t.isBooleanLiteral())return{type:"boolean"};if(t.isNull()||t.isUndefined()||t.isVoid())return{type:"null"};if(t.isUnion()){const r=t.getUnionTypes();if(r.every(i=>i.isStringLiteral())&&r.length>0)return{type:"string",enum:r.map(i=>i.getLiteralValue())};if(r.every(i=>i.isNumberLiteral())&&r.length>0)return{type:"number",enum:r.map(i=>i.getLiteralValue())};const s=await Promise.all(r.map(i=>Yc(i,e,n+1))),o=Ds(s);return{oneOf:s,...o?{discriminator:o}:{},[Qn]:"union"}}if(t.isArray()){const r=t.getArrayElementType();return{type:"array",items:r?await e(r.getText()):{}}}if(t.isTuple()){const r=t.getTupleElements(),s=await Promise.all(r.map(o=>e(o.getText())));return{type:"array",items:s,minItems:s.length,maxItems:s.length}}if(t.isObject()){const r=t.getStringIndexType(),s=t.getNumberIndexType(),o=r??s,i=t.getProperties();if(o&&i.length===0)return{type:"object",additionalProperties:await e(o.getText())};const a={};for(const c of i){const u=c.getName(),l=c.getDeclarations()[0];let f;if(l)try{f=c.getTypeAtLocation(l)}catch{f=void 0}if(f!==void 0&&f.getCallSignatures().length>0)continue;const m=f!==void 0?xd(f,l):void 0;a[u]=m!==void 0?await e(m):{}}return Object.keys(a).length>0?{type:"object",properties:a}:{}}return{}}function Ds(t){if(t.length<2)return;const e=[];for(const r of t){if(r.type!=="object")return;const s=r.properties;if(!s||typeof s!="object")return;e.push(s)}const n=Object.keys(e[0]).filter(r=>e.every(s=>Object.prototype.hasOwnProperty.call(s,r)));for(const r of n){const s=[];let o=!0;for(const a of e){const c=a[r],u=c&&(c.type==="string"||c.type==="number"),l=c==null?void 0:c.enum;if(!u||!Array.isArray(l)||l.length!==1){o=!1;break}s.push(String(l[0]))}if(!o||new Set(s).size!==s.length)continue;const i={};return s.forEach((a,c)=>{i[a]=`#/oneOf/${c}`}),{propertyName:r,mapping:i}}}function Dn(t,e,n){if(e>6)return{};const r=t.trim();if(r==="string")return{type:"string"};if(r==="number")return{type:"number"};if(r==="boolean")return{type:"boolean"};if(r==="null")return{type:"null"};if(r==="undefined")return{type:"null"};const s=Xr[r];if(s!==void 0)return s;if(n!=null&&n.size){const o=n.get(r);if(o!==void 0){const i=Xr[o];if(i!==void 0)return i}}if(r.endsWith("[]"))return{type:"array",items:Dn(r.slice(0,-2),e+1,n)};if(r.includes("|")){const o=r.split("|").map(c=>c.trim());if(o.every(c=>c.startsWith("'")))return{type:"string",enum:o.map(c=>c.replace(/'/g,""))};const i=o.map(c=>Dn(c,e+1,n)),a=Ds(i);return{oneOf:i,...a?{discriminator:a}:{},[Qn]:"union"}}if(r.startsWith("{")&&r.endsWith("}")){const o=r.slice(1,-1).trim(),i={};for(const a of o.split(";").filter(Boolean)){const[c,u]=a.split(":").map(l=>l.trim());c&&u&&(i[c.replace("?","")]=Dn(u,e+1,n))}return{type:"object",properties:i}}return{}}function Xc(t){const e=[];let n=0,r=0;for(let o=0;o<t.length;o++){const i=t[o];i==="<"||i==="["||i==="{"||i==="("?n++:i===">"||i==="]"||i==="}"||i===")"?n--:i===","&&n===0&&(e.push(t.slice(r,o).trim()),r=o+1)}const s=t.slice(r).trim();return s.length>0&&e.push(s),e}function Rd(t){const e=/^(?:Readonly)?Map<(.+)>$/.exec(t);return e?e[1]:void 0}function Md(t){const e=/^(?:Readonly)?Set<(.+)>$/.exec(t);return e?e[1]:void 0}function Dd(t){let e=t.trim();if(e.startsWith("readonly ")&&(e=e.slice(9).trim()),!e.startsWith("[")||!e.endsWith("]"))return;const n=e.slice(1,-1).trim();if(n.length!==0)return Xc(n)}async function Ld(t,e){const n=t.trim(),r=Rd(n);if(r!==void 0){const i=Xc(r);if(i.length===2){const[a,c]=await Promise.all([e(i[0]),e(i[1])]);return{type:"array",items:{type:"array",items:[a,c],minItems:2,maxItems:2}}}}const s=Md(n);if(s!==void 0)return{type:"array",items:await e(s),uniqueItems:!0};const o=Dd(n);if(o!==void 0){const i=await Promise.all(o.map(a=>e(a)));return{type:"array",items:i,minItems:i.length,maxItems:i.length}}}const Zc={"decimal.js":"Decimal"},Xr={Date:{type:"string",format:"date-time"},bigint:{type:"string",format:"int64"},Uint8Array:{type:"string",format:"byte"},Buffer:{type:"string",format:"byte"},URL:{type:"string",format:"uri"},RegExp:{type:"string",format:"regex"},Decimal:{type:"string",format:"decimal"}},wi={Uint8Array:"byte",Buffer:"byte",Decimal:"decimal"};function bi(t){var e;const n=new Map;for(const r of t.getImportDeclarations()){const s=r.getModuleSpecifierValue(),o=Zc[s];if(!o)continue;const i=r.getDefaultImport();if(i){const a=i.getText();a!==o&&n.set(a,o)}for(const a of r.getNamedImports()){const c=((e=a.getAliasNode())==null?void 0:e.getText())??a.getName();c!==o&&n.set(c,o)}}return n}function Bd(t,e){return n=>{n.addNodeParser({supportsNode(r){var s,o,i;if(r.kind!==e)return!1;const a=((s=r.typeName)==null?void 0:s.escapedText)??((i=(o=r.typeName)==null?void 0:o.right)==null?void 0:i.escapedText);return a!==void 0&&Object.prototype.hasOwnProperty.call(wi,a)},createType(r){var s,o,i;const a=((s=r.typeName)==null?void 0:s.escapedText)??((i=(o=r.typeName)==null?void 0:o.right)==null?void 0:i.escapedText);return new at.AnnotatedType(new at.StringType,{format:wi[a]},!1)}}),n.addNodeParser({supportsNode(r){return r.kind===t},createType(){return new at.AnnotatedType(new at.StringType,{format:"int64"},!1)}})}}let Wt;function Ud(){if(Wt)return Wt;try{const t=q.dirname(require.resolve("ts-json-schema-generator/package.json"));Wt=require(require.resolve("typescript",{paths:[t]}))}catch{Wt=require("typescript")}return Wt}const Ge=new Map;function Vd(){const t=process.env.APIGEN_PROGRAM_CACHE,e=t===void 0?NaN:Number(t);return Number.isFinite(e)&&e>=0?e:8}function Fd(t){const e=Ge.get(t);return e&&(Ge.delete(t),Ge.set(t,e)),e}function qd(t,e){const n=Vd();if(n!==0)for(Ge.delete(t),Ge.set(t,e);Ge.size>n;){const r=Ge.keys().next().value;Ge.delete(r)}}function Kd(t,e){return`${t}\0${e??""}`}const zd=new Set(["zod",/^zod\/./]);function Gd(t){for(const e of t.getImportDeclarations()){const n=e.getModuleSpecifierValue();for(const r of zd)if(typeof r=="string"){if(n===r)return!0}else if(r.test(n))return!0}return!1}function Wd(t){for(const e of["$defs","definitions"]){const n=t[e];if(!n||typeof n!="object")continue;const r=Object.keys(n);if(r.length===0)continue;const s=new Set(r.filter(o=>/zod/i.test(o)));for(const[o,i]of Object.entries(n)){if(s.has(o)||typeof i!="object"||i===null)continue;const a=i,c=typeof a.$ref=="string"?a.$ref:"";if(c){for(const u of s)if(c.includes(u)){s.add(o);break}}}for(const o of s)delete n[o]}Zr(t)}function Zr(t,e){if(!t||typeof t!="object")return;const n=e??new WeakSet;if(!n.has(t)){n.add(t);for(const r of Object.keys(t))if(r==="$ref"&&typeof t[r]=="string"){const s=t[r];/zod/i.test(s)&&delete t[r]}for(const[,r]of Object.entries(t))if(typeof r=="object"&&r!==null)if(Array.isArray(r))for(const s of r)typeof s=="object"&&s!==null&&Zr(s,n);else Zr(r,n)}}function Hd(t){const e=new Set;for(const r of["$defs","definitions"]){const s=t[r];if(s&&typeof s=="object")for(const o of Object.keys(s))e.add(o)}const n=es(t,e);if(n.length>0)throw new Error(`[apigen-core-client] Generated schema contains ${n.length} unresolvable $ref(s): ${n.join(", ")}. This usually means zod-internal definitions were stripped but $ref references to them remain. Check the source file's imports or the ts-json-schema-generator output.`)}function es(t,e){if(!t||typeof t!="object")return[];const n=[];for(const[r,s]of Object.entries(t))if(r==="$ref"&&typeof s=="string"){const o=s.match(/#\/(?:\$defs|definitions)\/(.+)$/);o&&!e.has(o[1])&&n.push(s)}else if(typeof s=="object"&&s!==null)if(Array.isArray(s))for(const o of s)typeof o=="object"&&o!==null&&n.push(...es(o,e));else n.push(...es(s,e));return n}function Jd(t){const e=t.anyOf;if(!Array.isArray(e)||e.length<2)return t;const n=e,r=Ds(n),s={...t};return delete s.anyOf,{...s,oneOf:n,...r?{discriminator:r}:{},[Qn]:s[Qn]??"union"}}function Qd(t,e,n){const{DEFAULT_CONFIG:r}=require("ts-json-schema-generator/dist/src/Config.js"),s={...r,...t},o=s.path,i=Kd(o,s.tsconfig);let a;a=n?n.statVersion(o):Qc(o);let c;if(i!==void 0){const l=(n==null?void 0:n.generatorCache.get(i))??Fd(i);l&&l.version===a&&(c=l.gen)}if(!c){const{createProgram:l}=require("ts-json-schema-generator/dist/factory/program.js"),f=Ud(),m=Bd(f.SyntaxKind.BigIntKeyword,f.SyntaxKind.TypeReference),p=l(s),d=at.createParser(p,s,m),v=at.createFormatter(s);if(c=new at.SchemaGenerator(p,d,v,s),n&&n.stats.generatorsBuilt++,i!==void 0&&a!==void 0){const g={version:a,gen:c};qd(i,g),n==null||n.generatorCache.set(i,g)}}const u=c.createSchema(s.type);return Wd(u),Hd(u),u}function Yd(t,e){let n=t.trim();if(n=tu(n),e!=null&&e.size){const s=e.get(n);if(s!==void 0)return s}const r=n.match(/^ReadonlyArray<(.+)>$/);for(r&&(n=`${r[1].trim()}[]`);n.startsWith("readonly ");)n=n.slice(9).trim();return n}function eu(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}const Xd=Object.entries(Zc).map(([t,e])=>({pattern:new RegExp(`import\\(["'][^"']*${eu(t)}[^"']*["']\\)\\.\\w+`,"g"),key:e}));function tu(t){let e=t;for(const{pattern:n,key:r}of Xd)e=e.replace(n,r);return e}function Zd(t,e){let n=tu(t);for(const[r,s]of e)n=n.replace(new RegExp(`\\b${eu(r)}\\b`,"g"),s);return n}async function un(t,e,n,r,s,o){const i=e.getFilePath(),a=`${i}\0${r??""}\0${n}`,c=o??new Set;if(c.has(a))return{};if(!s){const d=new Set(c);return d.add(a),Ei(t,e,n,r,void 0,d)}const u=s.schemaCache.get(a);if(u!==void 0)return s.stats.schemaCacheHits++,u;const l=Sd(i,r,s.statVersion(i)),f=l.get(n);if(f!==void 0)return s.stats.schemaCacheHits++,s.schemaCache.set(a,Promise.resolve(f)),f;s.stats.schemaCacheMisses++;const m=new Set(c);m.add(a);const p=Ei(t,e,n,r,s,m).then(d=>(l.set(n,d),d)).catch(d=>{throw s.schemaCache.delete(a),d});return s.schemaCache.set(a,p),p}async function Ei(t,e,n,r,s,o){if(["void","undefined","null","Promise<void>"].includes(n))return{type:"null"};let i;if(s){const m=s.aliasCache.get(e);i=m??bi(e),m||s.aliasCache.set(e,i)}else i=bi(e);const a=Yd(n,i),c=Xr[a];if(c!==void 0)return c;const u=await Ld(a,m=>un(t,e,m,r,s,o));if(u!==void 0)return u;const l=(s==null?void 0:s.zodImportCache.get(e))??Gd(e);if(s&&s.zodImportCache.set(e,l),!l)try{const m={path:e.getFilePath(),type:a,skipTypeCheck:!0,tsconfig:r,topRef:!1},p=Qd(m,!0,s);return Jd(p)}catch{}try{const m=await Cd(t,e,a,p=>Yc(p,d=>un(t,e,d,r,s,o),0));if(m!==void 0)return m}catch{}const f=Zd(a,i);return Dn(f,0,i)}function Ls(t,e,n){if(t!=null&&t.hasInitializer()){const r=t.getInitializer();if(r)return r.getText()}return ep(n,e)}function ep(t,e){var n;const r=t,s=((n=r==null?void 0:r.getJsDocs)==null?void 0:n.call(r))??[],o=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),i=new RegExp(`\\[\\s*${o}\\s*=\\s*([^\\]]+)\\]`);for(const a of s)for(const c of a.getTags()){if(c.getTagName()!=="param")continue;const u=c.getText().match(i);if(u)return u[1].trim()}}function tp(t){const e=t.trim(),n=e.match(/^(['"`])([\s\S]*)\1$/);if(n)return n[2];if(e==="true")return!0;if(e==="false")return!1;if(e==="null")return null;if(e!=="undefined"){if(/^-?\d+(\.\d+)?$/.test(e))return Number(e);try{return JSON.parse(e)}catch{return e}}}function np(t,e){const n=tp(e);if(n===void 0)return;t.default=n;const r=typeof n=="string"?n:JSON.stringify(n),s=typeof t.description=="string"?t.description:void 0;t.description=s?`${s} (default: ${r})`:`(default: ${r})`}async function rp(t){const e=t.session===void 0,n=Od(t.session??Nd());try{return await sp(t,n)}finally{e&&n.dispose()}}async function sp(t,e){const{sourceFile:n,namespace:r="",tsconfig:s}=t,o=e.projectFor(s),i=e.sourceFileFor(n,s),a=q.basename(n),c=Re(cp(a)),u=Re(r),l=[];for(const[p,d]of i.getExportedDeclarations()){if(p==="default"||Sn(p))continue;const v=lp(d);if(v){const S=v.getSignature(),N=Si(S,v),k=S.getReturnType().getText();l.push(await En(o,i,u,c,p,N,k,v.isAsync(),s,e));continue}const g=d.find(S=>S.getKindName()==="VariableDeclaration");if(!g)continue;const y=g.getInitializer(),$=y==null?void 0:y.getKindName();if(y&&["ArrowFunction","FunctionExpression"].includes($??"")){const S=g.getType().getCallSignatures();if(S.length===0)continue;const N=S[0],k=Ni(N,g,g.getVariableStatement()),C=N.getReturnType().getText(),F=y.isAsync();l.push(await En(o,i,u,c,p,k,C,F,s,e))}else if($==="ObjectLiteralExpression"){const S=g.getType();for(const N of S.getProperties()){const k=N.getName();if(Sn(k))continue;const C=N.getTypeAtLocation(g).getCallSignatures();if(C.length===0)continue;const F=C[0],ee=Ni(F,g,g.getVariableStatement()),ae=F.getReturnType().getText(),me=[c,Re(p),Re(k)];l.push(await Ln(o,i,u,me,k,ee,ae,!1,s,e))}}else{const S=g.getType(),N=S.getText();if(rt(S,g)){const k=await un(o,i,N,s,e);l.push(ip(u,c,p,k))}else console.warn(`[apigen-core] Skipping non-callable, non-serializable export: ${p}`)}}const f=i.getDefaultExportSymbol();if(f){const p=i.getExportAssignment(d=>!d.isExportEquals());if(p){const d=p.getExpression(),v=d.getKindName();if(["ArrowFunction","FunctionExpression"].includes(v)){const g=d.getType().getCallSignatures();if(g.length>0){const y=g[0],$=Mr(y,p),S=y.getReturnType().getText(),N=d.isAsync();l.push(await En(o,i,u,c,"default",$,S,N,s,e))}}else{const g=d.getType();for(const y of g.getProperties()){const $=y.getName();if(Sn($))continue;const S=y.getTypeAtLocation(p).getCallSignatures();if(S.length===0)continue;const N=S[0],k=Mr(N,p),C=N.getReturnType().getText(),F=[c,Re("default"),Re($)];l.push(await Ln(o,i,u,F,$,k,C,!1,s,e))}}}else{const d=f.getDeclarations();for(const v of d){if(v.getKindName()!=="FunctionDeclaration")continue;const g=v,y=g.getName(),$=y&&y.length>0?y:"default",S=g.getSignature(),N=Si(S,g),k=S.getReturnType().getText();l.push(await En(o,i,u,c,$,N,k,g.isAsync(),s,e))}}}const m=up(i);if(m.length>0)for(const{name:p,sig:d}of m){if(Sn(p))continue;const v=Mr(d),g=d.getReturnType().getText(),y=[c,Re(p)];l.push(await Ln(o,i,u,y,p,v,g,!1,s,e))}return l}function op(t,e,n,r){const s=new Set,o=i=>{if(Array.isArray(i))return i.map(o);if(!i||typeof i!="object"||s.has(i))return i;s.add(i);try{const a=i,c={};for(const[u,l]of Object.entries(a)){if(u==="definitions"||u==="$defs"){const f=u,m=e[f];for(const[p,d]of Object.entries(l)){const v=o(d),g=m[p];if(g!==void 0&&JSON.stringify(g)!==JSON.stringify(v))throw new Error(`[apigen-core-client] Function "${n}": param "${r}" contributes a "${f}.${p}" definition that conflicts with an identically-named definition already hoisted from another param/output in the same function. Two structurally different types share the same generated definition key, so apigen cannot safely merge them into one function-level schema.`);m[p]=v}continue}c[u]=o(l)}return c}finally{s.delete(i)}};return o(t)}async function En(t,e,n,r,s,o,i,a,c,u){const l=Re(s);return Ln(t,e,n,[r,l],s,o,i,a,c,u)}async function Ln(t,e,n,r,s,o,i,a,c,u){const l=o.length>0&&o[0].name==="ctx",f=o.filter($=>$.name!=="ctx"),m=f.filter($=>!$.optional).map($=>$.name),p={},d={definitions:{},$defs:{}};for(const $ of f){const S=await un(t,e,$.type,c,u),N=op(S,d,s,$.name);$.defaultValue!==void 0&&np(N,$.defaultValue),p[$.name]=N}const v=i.replace(/^Promise<(.+)>$/,"$1").trim(),g=await un(t,e,v,c,u),y={type:"object",properties:p,required:m,...Object.keys(d.definitions).length>0?{definitions:d.definitions}:{},...Object.keys(d.$defs).length>0?{$defs:d.$defs}:{}};return{id:nu(n,r),host:"ts",namespace:n,path:r,kind:"action",async:a,streaming:!1,safe:!1,input:y,output:g,envelope:{},typeText:{lang:"ts",input:fp(o),output:v},...l?{hasCtx:!0}:{}}}function ip(t,e,n,r){const s=Re(n),o=[e,s];return{id:nu(t,o),host:"ts",namespace:t,path:o,kind:"query",async:!1,streaming:!1,safe:!0,input:{type:"object",properties:{},required:[]},output:r,envelope:{},typeText:null}}function nu(t,e){return(t.raw?[t,...e]:e).map(n=>n.words.join("-")).join("/")}function ap(t){return t.split(/[-_.]+/).flatMap(e=>e.replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2").replace(/([a-z\d])([A-Z])/g,"$1_$2").split("_").filter(Boolean)).map(e=>e.toLowerCase()).filter(Boolean)}function Re(t){return{raw:t,words:ap(t)}}function cp(t){return t.replace(/\.[^.]+$/,"").replace(/[._]+/g,"-")}function up(t){const e=[];for(const n of t.getStatements()){if(n.getKindName()!=="ExpressionStatement")continue;const r=n.getExpression();if(r.getKindName()!=="BinaryExpression")continue;const s=r;if(s.getLeft().getText().trim()!=="module.exports"||s.getOperatorToken().getKindName()!=="EqualsToken")continue;const o=s.getRight(),i=o.getType();for(const a of i.getProperties()){const c=a.getTypeAtLocation(o).getCallSignatures();c.length!==0&&e.push({name:a.getName(),sig:c[0]})}}return e}function lp(t){let e;for(const n of t){if(n.getKindName()!=="FunctionDeclaration")continue;const r=n;if(e||(e=r),r.getBody())return r}return e}function Si(t,e){return t.getParameters().map(n=>{var r;const s=n.getDeclarations(),o=s.length>0&&s[0].getKindName()==="Parameter"?s[0]:null,i=n.isOptional()||((o==null?void 0:o.hasInitializer())??!1)||(((r=o==null?void 0:o.hasQuestionToken)==null?void 0:r.call(o))??!1);return{name:n.getName(),type:n.getTypeAtLocation(t.getDeclaration()).getText(),optional:i,defaultValue:Ls(o,n.getName(),e)}})}function Ni(t,e,n){return t.getParameters().map(r=>{var s;const o=r.getDeclarations(),i=o.length>0&&o[0].getKindName()==="Parameter"?o[0]:null,a=r.isOptional()||((i==null?void 0:i.hasInitializer())??!1)||(((s=i==null?void 0:i.hasQuestionToken)==null?void 0:s.call(i))??!1);return{name:r.getName(),type:r.getTypeAtLocation(e).getText(),optional:a,defaultValue:Ls(i,r.getName(),n??e)}})}function Mr(t,e){return t.getParameters().map(n=>{var r,s,o;const i=n.getDeclarations(),a=i.length>0&&i[0].getKindName()==="Parameter"?i[0]:null,c=n.isOptional()||((a==null?void 0:a.hasInitializer())??!1)||(((r=a==null?void 0:a.hasQuestionToken)==null?void 0:r.call(a))??!1);return{name:n.getName(),type:a?a.getType().getText():((o=(s=n.getValueDeclaration())==null?void 0:s.getType())==null?void 0:o.getText())??"unknown",optional:c,defaultValue:Ls(a,n.getName(),e)}})}function fp(t){const e=t.filter(n=>n.name!=="ctx");return e.length===0?"()":"("+e.map(n=>`${n.name}${n.optional?"?":""}: ${n.type}`).join(", ")+")"}function Sn(t){return!!(t==="__samples__"||t.startsWith("__"))}function rt(t,e,n=new Set){if(t.getCallSignatures().length>0||t.getConstructSignatures().length>0)return!1;if(t.isString()||t.isNumber()||t.isBoolean()||t.isNull()||t.isUndefined()||t.isStringLiteral()||t.isNumberLiteral()||t.isBooleanLiteral()||t.isEnumLiteral())return!0;if(t.isArray()||t.isReadonlyArray()){const r=t.getArrayElementType();return r?rt(r,e,n):!1}if(t.isTuple())return t.getTupleElements().every(r=>rt(r,e,n));if(t.isUnion())return t.getUnionTypes().every(r=>rt(r,e,n));if(t.isIntersection())return t.getIntersectionTypes().every(r=>rt(r,e,n));if(t.isObject()){const r=t.getText(e);if(n.has(r))return!0;n.add(r);const s=t.getStringIndexType(),o=t.getNumberIndexType();if(s||o)return[s,o].every(a=>!a||rt(a,e,n));const i=t.getProperties();return i.length===0?!0:i.every(a=>{const c=a.getTypeAtLocation(e);return rt(c,e,n)})}return!1}const Oi=new Set(["string","number","boolean","integer"]);function dp(t){if(typeof t!="object"||t===null)return!1;const e=t;if(e.$ref!==void 0||e.oneOf||e.anyOf||e.allOf)return!1;const{type:n}=e;return typeof n=="string"?Oi.has(n):Array.isArray(n)?n.every(r=>Oi.has(r)||r==="null"):Array.isArray(e.enum)&&e.enum.length>0?e.enum.every(r=>["string","number","boolean"].includes(typeof r)):!1}function pp(t){if(!t||typeof t!="object")return!1;const e=t.properties;return e===void 0||typeof e!="object"||e===null?!1:Object.values(e).every(dp)}const hp={"decimal.js":"Decimal"};function mp(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}Object.entries(hp).map(([t,e])=>({pattern:new RegExp(`import\\(["'][^"']*${mp(t)}[^"']*["']\\)\\.\\w+`,"g"),key:e}));function _i(t){return t.words.join("-")}function ki(t){return t.words.map(vp).join("")}function Ii(t){return t.words.join("_")}function gp(t,e={}){var n,r;const s=[t.namespace,...t.path],o=t.safe||pp(t.input)?"GET":"POST",i=((r=(n=e.http)==null?void 0:n.verb)==null?void 0:r[t.id])??o,a="/"+s.map(p=>_i(p)).join("/"),c=s.map(p=>Ii(p)).join("_"),u=s.map(p=>Ii(p)).slice(0,-1).join("."),l=ki(s[s.length-2]??s[0]),f=ki(s[s.length-1]),m=s.map(p=>_i(p));return{http:{verb:i,route:a},mcp:{name:c},grpc:{package:u,service:l,method:f},cli:{path:m}}}function yp(t,e){return`x-${t}-${e}`}function vp(t){return t.length===0?t:t[0].toUpperCase()+t.slice(1)}const $p=["invalid_argument","unauthenticated","permission_denied","not_found","internal"],wp={invalid_argument:400,unauthenticated:401,permission_denied:403,not_found:404,internal:500};function ru(t){return typeof t=="object"&&t!==null&&t.name==="ApiError"&&$p.includes(t.code)&&typeof t.toJSON=="function"}const bp={"decimal.js":"Decimal"};function Ep(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}Object.entries(bp).map(([t,e])=>({pattern:new RegExp(`import\\(["'][^"']*${Ep(t)}[^"']*["']\\)\\.\\w+`,"g"),key:e}));function ts(t){return t.split(/[-_.]+/).flatMap(e=>e.replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2").replace(/([a-z\d])([A-Z])/g,"$1_$2").split("_").filter(Boolean)).map(e=>e.toLowerCase()).filter(Boolean)}function Ai(t){return{raw:t,words:ts(t)}}function Sp(t,e,n,r){for(const s of r??[]){const o=s.path[s.path.length-1];if(s.namespace.raw===t&&(o==null?void 0:o.raw)===e)return s}return{id:`${ts(t).join("-")}/${ts(e).join("-")}`,host:"ts",namespace:Ai(t),path:[Ai(e)],kind:"action",async:!1,streaming:!1,safe:n["x-apigen-safe"]??!1,input:n.input??{},output:n.output??{},envelope:{},typeText:null}}function Np(t,e,n,r,s,o){const i=Sp(t,e,n,r),{route:a,verb:c}=gp(i,o).http;return{route:s+a,verb:c}}const ns="$apigen";let Pi=class extends Error{constructor(e){super(e),this.code="E_DUP_CODEC",this.name="CodecRegistryError"}};function Op(t){const e=new Map;return{register(n,r){if(e.has(n.id)&&!(r!=null&&r.override))throw new Pi(`E_DUP_CODEC: a codec is already registered for id "${n.id}"`);e.set(n.id,n)},resolve(n){for(const r of e.values())if(r.matches(n))return r},get(n){return e.get(n)},ids(){return[...e.keys()]},freeze(){const n=new Map(e),r={register(){throw new Pi("E_DUP_CODEC: registry is frozen and cannot accept new codecs")},resolve(s){for(const o of n.values())if(o.matches(s))return o},get(s){return n.get(s)},ids(){return[...n.keys()]},freeze(){return r}};return r}}}const Bs="x-apigen-logical",Us="x-apigen-codec",rs="x-apigen-ctor",ss="x-apigen-tojson",_p="0.1.0";function ji(t,e){return{registry:t,resolve:n=>{throw new Error(`[apigen-logical] $ref "${n}" cannot be resolved in run-mode without a descriptor root. Supply a resolve() in the ctx override to handle $ref.`)},seen:new WeakSet,path:"",mode:"strict",...e}}function St(t,e,n){const r=n.registry.resolve(e);if(r)return r.encode(t,e,n);const s=e.$ref;if(typeof s=="string"){const a=n.resolve(s);return St(t,a,n)}const o=e.oneOf;if(Array.isArray(o)){const a=su(t,o,e);return St(t,a,n)}const i=e.type;if(i==="array"){if(!Array.isArray(t))return Dr(t,e,n);const a=e.items;if(!a)return t.map(u=>ut(u));const c=n.path;return Array.isArray(a)?t.map((u,l)=>{const f=a[l];return f===void 0?ut(u):St(u,f,{...n,path:`${c}/${l}`})}):t.map((u,l)=>St(u,a,{...n,path:`${c}/${l}`}))}if(i==="object"){if(t===null||typeof t!="object"||Array.isArray(t))return Dr(t,e,n);const a=e.properties;if(!a)return ut(t);const c=n.path,u={};for(const[l,f]of Object.entries(a)){const m=t[l];m!==void 0&&(u[l]=St(m,f,{...n,path:`${c}/${l}`}))}return u}return i==null?Dr(t,e,n):ut(t)}function Nt(t,e,n){const r=n.registry.resolve(e);if(r)return r.decode(t,e,n);const s=e.$ref;if(typeof s=="string"){const a=n.resolve(s);return Nt(t,a,n)}const o=e.oneOf;if(Array.isArray(o)){const a=su(t,o,e);return Nt(t,a,n)}const i=e.type;if(i==="array"){if(!Array.isArray(t))return t;const a=e.items;if(!a)return t;const c=n.path;return Array.isArray(a)?t.map((u,l)=>{const f=a[l];return f===void 0?u:Nt(u,f,{...n,path:`${c}/${l}`})}):t.map((u,l)=>Nt(u,a,{...n,path:`${c}/${l}`}))}if(i==="object"){if(t===null||typeof t!="object"||Array.isArray(t))return t;const a=e.properties;if(!a)return t;const c=n.path,u={};for(const[l,f]of Object.entries(a)){const m=t[l];m!==void 0&&(u[l]=Nt(m,f,{...n,path:`${c}/${l}`}))}return u}return i==null?kp(t,n):t}function su(t,e,n,r){const s=n.discriminator;if(s!=null&&s.propertyName){const o=t!==null&&typeof t=="object"?t[s.propertyName]:void 0;if(typeof o=="string"&&s.mapping){const i=s.mapping[o];if(i){const a=e.find(c=>c.$ref===i);if(a)return a}}}return e[0]??{}}function Dr(t,e,n){for(const r of n.registry.ids()){const s=n.registry.get(r);if(s)try{const o=s.encode(t,s.schema,n);return{[ns]:r,v:o}}catch{}}return ut(t)}function kp(t,e){if(t!==null&&typeof t=="object"&&!Array.isArray(t)&&ns in t){const n=t,r=n[ns],s=e.registry.get(r);if(s)return s.decode(n.v,s.schema,e)}return t}function ut(t){if(t===null||typeof t=="string"||typeof t=="number"||typeof t=="boolean")return t;if(Array.isArray(t))return t.map(ut);if(typeof t=="object"){const e={};for(const[n,r]of Object.entries(t))r!==void 0&&(e[n]=ut(r));return e}return null}function Ip(t){return{encode(e,n,r){const s=ji(t,r);return St(e,n,s)},decode(e,n,r){const s=ji(t,r);return Nt(e,n,s)}}}const Vs={id:"date-time",kind:"scalar",schema:{type:"string",format:"date-time"},matches(t){return t.type==="string"&&t.format==="date-time"},encode(t,e,n){return t.toISOString()},decode(t,e,n){if(typeof t!="string"){if(n.mode==="strict")throw new TypeError(`[date-time] expected a string on the wire at "${n.path}", got ${typeof t}`);return new Date(String(t))}if(n.mode==="strict"&&Number.isNaN(new Date(t).getTime()))throw new TypeError(`[date-time] invalid date-time string at "${n.path}": ${JSON.stringify(t)}`);return new Date(t)}},Fs={id:"int64",kind:"scalar",schema:{type:"string",format:"int64"},matches(t){return t.type==="string"&&t.format==="int64"},encode(t,e,n){return String(t)},decode(t,e,n){if(typeof t!="string"){if(n.mode==="strict")throw new TypeError(`[int64] expected a string on the wire at "${n.path}", got ${typeof t}`);try{return BigInt(Math.trunc(Number(t)))}catch{return BigInt(0)}}if(n.mode==="strict")return BigInt(t);if(/^-?\d+$/.test(t))try{return BigInt(t)}catch{return BigInt(0)}return BigInt(0)}},qs={id:"decimal",kind:"scalar",schema:{type:"string",format:"decimal"},matches(t){return t.type==="string"&&t.format==="decimal"},encode(t,e,n){return t},decode(t,e,n){if(typeof t!="string"){if(n.mode==="strict")throw new TypeError(`[decimal] expected a string on the wire at "${n.path}", got ${typeof t}`);return String(t)}if(n.mode==="strict"&&!/^-?\d+(\.\d+)?$/.test(t))throw new TypeError(`[decimal] wire value "${t}" at "${n.path}" is not a valid decimal string`);return t}},Ks={id:"byte",kind:"scalar",schema:{type:"string",format:"byte"},matches(t){return t.type==="string"&&t.format==="byte"},encode(t,e,n){return Buffer.from(t).toString("base64")},decode(t,e,n){if(typeof t!="string"){if(n.mode==="strict")throw new TypeError(`[byte] expected a base64 string on the wire at "${n.path}", got ${typeof t}`);return new Uint8Array(0)}if(n.mode==="strict"&&!/^[A-Za-z0-9+/]*={0,2}$/.test(t))throw new TypeError(`[byte] wire value at "${n.path}" is not standard base64 (format:byte): "${t}"`);return new Uint8Array(Buffer.from(t,"base64"))}},Ap=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,zs={id:"uuid",kind:"scalar",schema:{type:"string",format:"uuid"},matches(t){return t.type==="string"&&t.format==="uuid"},encode(t,e,n){return t.toLowerCase()},decode(t,e,n){if(typeof t!="string"){if(n.mode==="strict")throw new TypeError(`[uuid] expected a string on the wire at "${n.path}", got ${typeof t}`);return String(t).toLowerCase()}if(n.mode==="strict"&&!Ap.test(t))throw new TypeError(`[uuid] wire value "${t}" at "${n.path}" is not a lowercase-hyphenated RFC 4122 UUID`);return t}},os="NaN",is="Infinity",as="-Infinity",Pp=new Set([os,is,as]),Gs={id:"number-special",kind:"scalar",schema:{type:"number"},matches(t){return t.type==="number"&&t.format===void 0},encode(t,e,n){return Number.isNaN(t)?os:t===1/0?is:t===-1/0?as:t},decode(t,e,n){if(typeof t=="number")return t;if(typeof t=="string"){if(t===os)return NaN;if(t===is)return 1/0;if(t===as)return-1/0;const r=Number(t);if(!Number.isNaN(r))return r}if(n.mode==="strict")throw new TypeError(`[number-special] unrecognized wire value at "${n.path}": ${JSON.stringify(t)}. Expected a number or one of ${[...Pp].join(", ")}.`);return NaN}},jp=[Vs,Fs,qs,Ks,zs,Gs];function xp(t,e={}){for(const n of jp)t.register(n,{override:e.override??!1})}Vs.id,Fs.id,qs.id,Ks.id,zs.id,Gs.id;const ou=Op();xp(ou);const iu=Ip(ou.freeze());function Tp(t,e){var n;const r=((n=t.input)==null?void 0:n.properties)??{};return e in r}function Cp(t){var e,n;const r=(n=(e=t.input)==null?void 0:e.properties)==null?void 0:n.data;return Object.keys((r==null?void 0:r.properties)??{})}function Rp(t,e){var n,r,s;const o=(s=(r=(n=t.input)==null?void 0:n.properties)==null?void 0:r.data)==null?void 0:s.properties,i=o==null?void 0:o[e];return i!==void 0?i:void 0}function Mp(t,e){return e===void 0||t===void 0?t:iu.decode(t,e)}function Lr(t,e){const n=e.output;return!n||Object.keys(n).length===0?t:iu.encode(t,n)}async function Dp(t,e,n,r,s,o){const i=Cp(n).map(c=>Mp(o[c],Rp(n,c)));if(Tp(n,"session")&&e){const c=await e({session:s.session}),u=await t[r](c,...i);return Lr(u,n)}if(n.hasCtx){const c=e?await e(s):void 0,u=await t[r](c,...i);return Lr(u,n)}const a=await t[r](...i);return Lr(a,n)}let Br=class{constructor(){this._map=new Map}set(e,n){this._map.set(e,n)}get(e){return this._map.get(e)}has(e){return this._map.has(e)}};function Lp(t=[]){return async function(e,n,r){const s=r.schemas[e];if(!s)throw new Error(`apigen/invoke: no schema found for operation "${e}"`);const o=()=>Dp(r.fns,r.createClient,s,e,n.envelope,n.domainArgs);return t.reduceRight((i,a)=>()=>a(n,i),o)()}}const Bp={"decimal.js":"Decimal"};function Up(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}Object.entries(Bp).map(([t,e])=>({pattern:new RegExp(`import\\(["'][^"']*${Up(t)}[^"']*["']\\)\\.\\w+`,"g"),key:e}));function Vp(t={}){const e=t.level??"info",n=typeof t.destination=="string"&&t.destination.length>0,r=!n&&!!process.stderr.isTTY,s=t.format??(r?"pretty":"json"),o={level:e};if(s==="pretty")return o.transport={target:"pino-pretty",options:{colorize:!n,translateTime:"SYS:HH:MM:ss.l",ignore:"pid,hostname",...n?{destination:t.destination,mkdir:!0}:{destination:2}}},We(o);const i=n?We.destination({dest:t.destination,mkdir:!0,sync:!0}):We.destination(2);return We(o,i)}function au(t){return t?t.type==="array"?`${au(t.items)}[]`:t.enum?"enum":t.$ref?String(t.$ref).split("/").pop()||"object":t.anyOf||t.oneOf?"union":t.type??"object":"unknown"}function Fp(t){var e;const n=(e=((t==null?void 0:t.input)??{}).properties)==null?void 0:e.data,r=(n==null?void 0:n.properties)??{},s=new Set((n==null?void 0:n.required)??[]),o=Object.entries(r).map(([a,c])=>({name:a,type:au(c),required:s.has(a)})),i=o.map(a=>`${a.name}${a.required?"":"?"}: ${a.type}`).join(", ");return{params:o,text:i}}function qp(t){let e;return Array.isArray(t)?e=t:t?e=[t]:e=[],e.find(n=>n==="number"||n==="integer"||n==="boolean")}function Kp(t,e){var n,r;const s=((r=(n=((e==null?void 0:e.input)??{}).properties)==null?void 0:n.data)==null?void 0:r.properties)??{},o={...t};for(const[i,a]of Object.entries(s)){const c=o[i];if(typeof c!="string")continue;const u=qp(a==null?void 0:a.type);if(u==="number"||u==="integer"){const l=Number(c);!Number.isNaN(l)&&c.trim()!==""&&(o[i]=l)}else u==="boolean"&&(c==="true"?o[i]=!0:c==="false"&&(o[i]=!1))}return o}let zp=class extends Error{constructor(e,n,r){super(n),this.name="ApiError",this.code=e,this.details=r,Object.setPrototypeOf(this,new.target.prototype)}toJSON(){const e={code:this.code,message:this.message};return this.details!==void 0&&(e.details=this.details),e}};const ar=new Fa({allErrors:!0});qa(ar);for(const t of[Bs,Us,rs,ss,"discriminator"])ar.addKeyword({keyword:t,valid:!0});ar.addFormat("decimal",/^[+-]?(?:\d+(?:\.\d+)?|\.\d+)$/);function Gp(t){return t.map(e=>`${e.instancePath||"(root)"} ${e.message??"failed schema check"}`).join("; ")}function Wp(t){return async function(e,n){const r=e.operation.id,s=t[r];if(s===void 0)return n();const o={data:e.domainArgs,...e.envelope},i=ar.compile(s.input);if(!i(o)){const a=i.errors??[];throw new zp("invalid_argument",`Validation failed: ${Gp(a)}`,a)}return n()}}class et extends Error{constructor(e,n){super(n),this.name="UnionCodecError",this.code=e}}function Ur(t){const e=t.discriminator;if(e===null||typeof e!="object"||Array.isArray(e))return;const n=e;if(typeof n.propertyName!="string")return;const r=n.mapping;if(!(r===null||typeof r!="object"||Array.isArray(r)))return{propertyName:n.propertyName,mapping:r}}function cu(t,e){const n=t[Us];if(typeof n=="string"){const r=e.registry.get(n);if(r)return r}return e.registry.resolve(t)}function Hp(t,e,n){const r=cu(e,n);return r?r.encode(t,e,n):t}function Jp(t,e,n){const r=cu(e,n);return r?r.decode(t,e,n):t}function Qp(t){const{id:e,schema:n}=t;return{id:e,kind:"union",schema:n,matches(r){if(r[Bs]==="union")return!0;const s=r.oneOf;return!Array.isArray(s)||s.length===0?!1:Ur(r)!==void 0},encode(r,s,o){const i=Ur(s);if(!i)throw new et("E_UNION_NO_DISCRIMINATOR",`[${e}] schema node at "${o.path}" has no discriminator.propertyName; cannot dispatch union branch.`);const{propertyName:a,mapping:c}=i,u=r[a];if(u==null)throw new et("E_UNION_NO_DISCRIMINATOR",`[${e}] value at "${o.path}" is missing the discriminator property "${a}".`);const l=String(u),f=c[l];if(!f)throw new et("E_UNION_UNKNOWN_TAG",`[${e}] discriminator tag "${l}" at "${o.path}" is not in the mapping (known: ${Object.keys(c).join(", ")}).`);const m=o.resolve(f);return Hp(r,m,{...o,path:`${o.path}[${l}]`})},decode(r,s,o){if(r===null||typeof r!="object"||Array.isArray(r)){let d;throw r===null?d="null":Array.isArray(r)?d="array":d=typeof r,new et("E_UNION_INVALID_WIRE",`[${e}] expected a JSON object on the wire at "${o.path}", got ${d}.`)}const i=r,a=Ur(s);if(!a)throw new et("E_UNION_NO_DISCRIMINATOR",`[${e}] schema node at "${o.path}" has no discriminator.propertyName; cannot dispatch union branch.`);const{propertyName:c,mapping:u}=a,l=i[c];if(l==null)throw new et("E_UNION_NO_DISCRIMINATOR",`[${e}] wire object at "${o.path}" is missing the discriminator property "${c}".`);const f=String(l),m=u[f];if(!m)throw new et("E_UNION_UNKNOWN_TAG",`[${e}] discriminator tag "${f}" on the wire at "${o.path}" is not in the mapping (known: ${Object.keys(u).join(", ")}).`);const p=o.resolve(m);return Jp(r,p,{...o,path:`${o.path}[${f}]`})}}}const Yp="x-apigen-instances";let Nn=class extends Error{constructor(e,n){super(n),this.name="NominalCodecError",this.code=e}};function xi(t){const e=t.properties;return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}function Xp(t){const e=t.required;return Array.isArray(e)?e.filter(n=>typeof n=="string"):[]}function Ti(t,e,n){if(e){const r=n.registry.resolve(e);if(r)return r.encode(t,e,n)}return t}function Zp(t,e,n){if(e){const r=n.registry.resolve(e);if(r)return r.decode(t,e,n)}return t}function eh(t){const{id:e,schema:n,ctor:r}=t;return{id:e,kind:"nominal",schema:n,matches(s){return s[Bs]==="nominal"?!0:s[Us]===e},encode(s,o,i){if(s===null||typeof s!="object")return s;if(i.seen.has(s)){if(i.mode==="strict")throw new Nn("E_NOMINAL_CYCLE",`[${e}] cycle detected at "${i.path}": a nominal instance references itself. Strict mode rejects cycles (DESIGN §8.3); break the cycle or use 'lossy' mode.`);return null}i.seen.add(s);try{const a=xi(o),c=typeof o[ss]=="string"?o[ss]:"toJSON",u=s[c];if(typeof u=="function"){const d=u.call(s);if(d!==null&&typeof d=="object"&&!Array.isArray(d)){const v={};for(const[g,y]of Object.entries(d))v[g]=Ti(y,a[g],{...i,path:`${i.path}/${g}`});return v}return d}const l={},f=Object.keys(a),m=s,p=f.length>0?f:Object.keys(m);for(const d of p){const v=m[d];v!==void 0&&(l[d]=Ti(v,a[d],{...i,path:`${i.path}/${d}`}))}return l}finally{i.seen.delete(s)}},decode(s,o,i){if(s===null||typeof s!="object"||Array.isArray(s)){let l;throw s===null?l="null":Array.isArray(s)?l="array":l=typeof s,new Nn("E_NOMINAL_INVALID_WIRE",`[${e}] expected a JSON object on the wire at "${i.path}", got ${l}.`)}const a=s;for(const l of Xp(o))if(!(l in a))throw new Nn("E_NOMINAL_INVALID_WIRE",`[${e}] required field "${l}" missing on the wire at "${i.path}".`);if(o[Yp]===!1)throw new Nn("E_NOMINAL_NONRECONSTRUCTABLE",`[${e}] is encode-only: the extractor marked it non-reconstructable (x-apigen-instances:false). It cannot be decoded back to a live instance.`);const c=xi(o),u={};for(const[l,f]of Object.entries(a))u[l]=Zp(f,c[l],{...i,path:`${i.path}/${l}`});if(r){const l=typeof o[rs]=="string"?o[rs]:"fromJSON",f=r[l];if(typeof f=="function")return f.call(r,u);const m=r;return new m(u)}return u}}}const th=[Vs,Fs,qs,Ks,zs,Gs],nh={type:"object","x-apigen-logical":"nominal","x-apigen-codec":"ts.NominalSentinel"},Ci=eh({id:"ts.NominalSentinel",schema:nh}),rh={oneOf:[],discriminator:{propertyName:"kind",mapping:{}},"x-apigen-logical":"union","x-apigen-codec":"ts.UnionSentinel"},Ri=Qp({id:"ts.UnionSentinel",schema:rh});function sh(){const t=[...th.map(e=>[e.id,e]),[Ci.id,Ci],[Ri.id,Ri]];return Object.freeze(new Map(t))}Object.freeze({host:"ts",logicalTypeVersion:_p,codecs:sh()});function Mi(t,e){var n;const r=((n=t.input)==null?void 0:n.properties)??{},s=t["x-apigen-envelope"],o={};for(const i of Object.keys(r)){if(i==="data")continue;const a=(s==null?void 0:s[i])??"adhd",c=yp(a,i),u=e[c];u!==void 0&&(o[i]=u)}return o}function oh(t){return ru(t)?wp[t.code]??500:500}function ih(t){const e=t.usePlugins;return Array.isArray(e)?e:[]}function ah(t){const e=t.useOptions;return e&&typeof e=="object"?e:{}}function ch(t){return async function(e,n){const r=Object.assign(e,{data:e.domainArgs});return await t.layer(r,n)}}function uh(t,e){var n;const r=[];for(const s of e){const o=(n=s.capabilities)==null?void 0:n.layer;o&&r.push(ch(o))}return r.push(Wp(t)),Lp(r)}function lh(t,e,n,r,s){var o;const i=[],a={host:n,operations:s};for(const c of t){const u=(o=c.capabilities)==null?void 0:o.mount;if(!u)continue;const l=u.operations(a,e[c.id]);for(const f of l)f.transports&&!f.transports.includes("http")||i.push({route:`${r}/${f.id}`,handler:f.handler})}return i}function Di(t,e){return t.type("application/json"),JSON.stringify(e===void 0?null:e)}async function fh(t){var e;const n=t.options.port??3e3,r=t.options.host??"127.0.0.1",s=t.options.routePrefix??"",o=t.options.projection??{},i=ih(t.options),a=ah(t.options),c=t.logger??Vp(),u=Ef({logger:c});u.setErrorHandler((p,d,v)=>{const g=oh(p),y=ru(p)?p.toJSON():{code:"internal",message:p.message??"Internal error"};v.status(g).send(y)});const l=[];for(const p of t.packages){const d=uh(p.schemas,i);if(!p.fns)throw new Error(`Package "${p.id}" is missing fns`);const v={fns:p.fns,createClient:p.createClient,schemas:p.schemas};for(const[g,y]of Object.entries(p.schemas)){const{route:$,verb:S}=Np(p.id,g,y,t.operations,s,o),{params:N,text:k}=Fp(y);l.push({method:S,route:$,text:k,params:N}),S==="GET"?u.get($,async(C,F)=>{const ee=Mi(y,C.headers),ae={operation:{id:g},ctx:new Br,envelope:ee,domainArgs:Kp(C.query,y),signal:t.signal};return Di(F,await d(g,ae,v))}):u.post($,async(C,F)=>{const{data:ee={}}=C.body??{},ae=Mi(y,C.headers),me={operation:{id:g},ctx:new Br,envelope:ae,domainArgs:ee,signal:t.signal};return Di(F,await d(g,me,v))})}}const f=((e=t.packages[0])==null?void 0:e.id)??"ts",m=lh(i,a,f,s,t.operations??[]);for(const p of m)l.push({method:"GET",route:p.route,text:"",params:[]}),u.get(p.route,async d=>{const v={operation:{id:p.route},data:{},envelope:{},ctx:new Br,transport:"http",signal:t.signal??new AbortController().signal,raw:d};return p.handler(v)});await u.listen({port:n,host:r}),c.info({host:r,port:n},`listening on http://${r}:${n}`);for(const p of l)c.info({method:p.method,route:p.route,body:{data:p.params}},`${p.method} ${p.route} body { data: {${p.text?` ${p.text} `:""}} }`);return new Promise(p=>{t.signal&&t.signal.addEventListener("abort",async()=>{await u.close(),p()})})}const dh={id:"api-fastify",run(t){return fh(t)}},Li=new Set(["string","number","boolean","integer"]);function ph(t){if(typeof t!="object"||t===null)return!1;const e=t;if(e.$ref!==void 0||e.oneOf||e.anyOf||e.allOf)return!1;const{type:n}=e;return typeof n=="string"?Li.has(n):Array.isArray(n)?n.every(r=>Li.has(r)||r==="null"):Array.isArray(e.enum)&&e.enum.length>0?e.enum.every(r=>["string","number","boolean"].includes(typeof r)):!1}function hh(t){if(!t||typeof t!="object")return!1;const e=t.properties;return e===void 0||typeof e!="object"||e===null?!1:Object.values(e).every(ph)}const mh={"decimal.js":"Decimal"};function gh(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}Object.entries(mh).map(([t,e])=>({pattern:new RegExp(`import\\(["'][^"']*${gh(t)}[^"']*["']\\)\\.\\w+`,"g"),key:e}));function Bi(t){return t.words.join("-")}function Ui(t){return t.words.map(vh).join("")}function Vi(t){return t.words.join("_")}function yh(t,e={}){var n,r;const s=[t.namespace,...t.path],o=t.safe||hh(t.input)?"GET":"POST",i=((r=(n=e.http)==null?void 0:n.verb)==null?void 0:r[t.id])??o,a="/"+s.map(p=>Bi(p)).join("/"),c=s.map(p=>Vi(p)).join("_"),u=s.map(p=>Vi(p)).slice(0,-1).join("."),l=Ui(s[s.length-2]??s[0]),f=Ui(s[s.length-1]),m=s.map(p=>Bi(p));return{http:{verb:i,route:a},mcp:{name:c},grpc:{package:u,service:l,method:f},cli:{path:m}}}function vh(t){return t.length===0?t:t[0].toUpperCase()+t.slice(1)}function $h(t,e={}){const n=e.title??"API",r=e.version??"0.0.0",s={};for(const o of t){const i=yh(o),{verb:a,route:c}=i.http,u=a.toLowerCase(),l={operationId:o.id,summary:o.id,responses:{200:wh(o.output)}};if(a==="GET")l.parameters=bh(o.input);else{const f=o.input;typeof f=="object"&&f!==null&&Object.keys(f).length>0&&(l.requestBody={required:!0,content:{"application/json":{schema:f}}})}s[c]===void 0&&(s[c]={}),s[c][u]=l}return{openapi:"3.1.0",info:{title:n,version:r},paths:s}}function wh(t){return typeof t=="object"&&t!==null&&Object.keys(t).length>0?{description:"Success",content:{"application/json":{schema:t}}}:{description:"Success"}}function bh(t){if(typeof t!="object"||t===null||typeof t.properties!="object"||t.properties===null)return[];const e=Array.isArray(t.required)?t.required:[],n=t.properties;return Object.entries(n).map(([r,s])=>({name:r,in:"query",required:e.includes(r),schema:s}))}function Fi(t){return{raw:t,words:t.split(/(?=[A-Z])|[-_]/).map(e=>e.toLowerCase()).filter(Boolean)}}function Eh(t,e={}){return[{id:"_meta/openapi",host:t.host,namespace:Fi("meta"),path:[Fi("openapi")],kind:"query",async:!1,streaming:!1,safe:!0,input:{},output:{type:"object"},envelope:{},typeText:null,transports:["http"],handler:n=>$h(t.operations,{title:e.title,version:e.version})}]}const Sh={id:"openapi",description:"Mount plugin: serves the OpenAPI 3.1 doc at GET /meta/openapi",language:"ts",optionsSchema:{type:"object",properties:{title:{type:"string",description:"OpenAPI info.title"},version:{type:"string",description:"OpenAPI info.version"}},additionalProperties:!1},capabilities:{mount:{operations(t,e){return Eh(t,e)}}}},cs="$apigen";let qi=class extends Error{constructor(e){super(e),this.code="E_DUP_CODEC",this.name="CodecRegistryError"}};function Nh(t){const e=new Map;return{register(n,r){if(e.has(n.id)&&!(r!=null&&r.override))throw new qi(`E_DUP_CODEC: a codec is already registered for id "${n.id}"`);e.set(n.id,n)},resolve(n){for(const r of e.values())if(r.matches(n))return r},get(n){return e.get(n)},ids(){return[...e.keys()]},freeze(){const n=new Map(e),r={register(){throw new qi("E_DUP_CODEC: registry is frozen and cannot accept new codecs")},resolve(s){for(const o of n.values())if(o.matches(s))return o},get(s){return n.get(s)},ids(){return[...n.keys()]},freeze(){return r}};return r}}}const Ws="x-apigen-logical",Hs="x-apigen-codec",us="x-apigen-ctor",ls="x-apigen-tojson",Oh="0.1.0";function Ki(t,e){return{registry:t,resolve:n=>{throw new Error(`[apigen-logical] $ref "${n}" cannot be resolved in run-mode without a descriptor root. Supply a resolve() in the ctx override to handle $ref.`)},seen:new WeakSet,path:"",mode:"strict",...e}}function Ot(t,e,n){const r=n.registry.resolve(e);if(r)return r.encode(t,e,n);const s=e.$ref;if(typeof s=="string"){const a=n.resolve(s);return Ot(t,a,n)}const o=e.oneOf;if(Array.isArray(o)){const a=uu(t,o,e);return Ot(t,a,n)}const i=e.type;if(i==="array"){if(!Array.isArray(t))return Vr(t,e,n);const a=e.items;if(!a)return t.map(u=>lt(u));const c=n.path;return Array.isArray(a)?t.map((u,l)=>{const f=a[l];return f===void 0?lt(u):Ot(u,f,{...n,path:`${c}/${l}`})}):t.map((u,l)=>Ot(u,a,{...n,path:`${c}/${l}`}))}if(i==="object"){if(t===null||typeof t!="object"||Array.isArray(t))return Vr(t,e,n);const a=e.properties;if(!a)return lt(t);const c=n.path,u={};for(const[l,f]of Object.entries(a)){const m=t[l];m!==void 0&&(u[l]=Ot(m,f,{...n,path:`${c}/${l}`}))}return u}return i==null?Vr(t,e,n):lt(t)}function _t(t,e,n){const r=n.registry.resolve(e);if(r)return r.decode(t,e,n);const s=e.$ref;if(typeof s=="string"){const a=n.resolve(s);return _t(t,a,n)}const o=e.oneOf;if(Array.isArray(o)){const a=uu(t,o,e);return _t(t,a,n)}const i=e.type;if(i==="array"){if(!Array.isArray(t))return t;const a=e.items;if(!a)return t;const c=n.path;return Array.isArray(a)?t.map((u,l)=>{const f=a[l];return f===void 0?u:_t(u,f,{...n,path:`${c}/${l}`})}):t.map((u,l)=>_t(u,a,{...n,path:`${c}/${l}`}))}if(i==="object"){if(t===null||typeof t!="object"||Array.isArray(t))return t;const a=e.properties;if(!a)return t;const c=n.path,u={};for(const[l,f]of Object.entries(a)){const m=t[l];m!==void 0&&(u[l]=_t(m,f,{...n,path:`${c}/${l}`}))}return u}return i==null?_h(t,n):t}function uu(t,e,n,r){const s=n.discriminator;if(s!=null&&s.propertyName){const o=t!==null&&typeof t=="object"?t[s.propertyName]:void 0;if(typeof o=="string"&&s.mapping){const i=s.mapping[o];if(i){const a=e.find(c=>c.$ref===i);if(a)return a}}}return e[0]??{}}function Vr(t,e,n){for(const r of n.registry.ids()){const s=n.registry.get(r);if(s)try{const o=s.encode(t,s.schema,n);return{[cs]:r,v:o}}catch{}}return lt(t)}function _h(t,e){if(t!==null&&typeof t=="object"&&!Array.isArray(t)&&cs in t){const n=t,r=n[cs],s=e.registry.get(r);if(s)return s.decode(n.v,s.schema,e)}return t}function lt(t){if(t===null||typeof t=="string"||typeof t=="number"||typeof t=="boolean")return t;if(Array.isArray(t))return t.map(lt);if(typeof t=="object"){const e={};for(const[n,r]of Object.entries(t))r!==void 0&&(e[n]=lt(r));return e}return null}function kh(t){return{encode(e,n,r){const s=Ki(t,r);return Ot(e,n,s)},decode(e,n,r){const s=Ki(t,r);return _t(e,n,s)}}}const Js={id:"date-time",kind:"scalar",schema:{type:"string",format:"date-time"},matches(t){return t.type==="string"&&t.format==="date-time"},encode(t,e,n){return t.toISOString()},decode(t,e,n){if(typeof t!="string"){if(n.mode==="strict")throw new TypeError(`[date-time] expected a string on the wire at "${n.path}", got ${typeof t}`);return new Date(String(t))}if(n.mode==="strict"&&Number.isNaN(new Date(t).getTime()))throw new TypeError(`[date-time] invalid date-time string at "${n.path}": ${JSON.stringify(t)}`);return new Date(t)}},Qs={id:"int64",kind:"scalar",schema:{type:"string",format:"int64"},matches(t){return t.type==="string"&&t.format==="int64"},encode(t,e,n){return String(t)},decode(t,e,n){if(typeof t!="string"){if(n.mode==="strict")throw new TypeError(`[int64] expected a string on the wire at "${n.path}", got ${typeof t}`);try{return BigInt(Math.trunc(Number(t)))}catch{return BigInt(0)}}if(n.mode==="strict")return BigInt(t);if(/^-?\d+$/.test(t))try{return BigInt(t)}catch{return BigInt(0)}return BigInt(0)}},Ys={id:"decimal",kind:"scalar",schema:{type:"string",format:"decimal"},matches(t){return t.type==="string"&&t.format==="decimal"},encode(t,e,n){return t},decode(t,e,n){if(typeof t!="string"){if(n.mode==="strict")throw new TypeError(`[decimal] expected a string on the wire at "${n.path}", got ${typeof t}`);return String(t)}if(n.mode==="strict"&&!/^-?\d+(\.\d+)?$/.test(t))throw new TypeError(`[decimal] wire value "${t}" at "${n.path}" is not a valid decimal string`);return t}},Xs={id:"byte",kind:"scalar",schema:{type:"string",format:"byte"},matches(t){return t.type==="string"&&t.format==="byte"},encode(t,e,n){return Buffer.from(t).toString("base64")},decode(t,e,n){if(typeof t!="string"){if(n.mode==="strict")throw new TypeError(`[byte] expected a base64 string on the wire at "${n.path}", got ${typeof t}`);return new Uint8Array(0)}if(n.mode==="strict"&&!/^[A-Za-z0-9+/]*={0,2}$/.test(t))throw new TypeError(`[byte] wire value at "${n.path}" is not standard base64 (format:byte): "${t}"`);return new Uint8Array(Buffer.from(t,"base64"))}},Ih=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,Zs={id:"uuid",kind:"scalar",schema:{type:"string",format:"uuid"},matches(t){return t.type==="string"&&t.format==="uuid"},encode(t,e,n){return t.toLowerCase()},decode(t,e,n){if(typeof t!="string"){if(n.mode==="strict")throw new TypeError(`[uuid] expected a string on the wire at "${n.path}", got ${typeof t}`);return String(t).toLowerCase()}if(n.mode==="strict"&&!Ih.test(t))throw new TypeError(`[uuid] wire value "${t}" at "${n.path}" is not a lowercase-hyphenated RFC 4122 UUID`);return t}},fs="NaN",ds="Infinity",ps="-Infinity",Ah=new Set([fs,ds,ps]),eo={id:"number-special",kind:"scalar",schema:{type:"number"},matches(t){return t.type==="number"&&t.format===void 0},encode(t,e,n){return Number.isNaN(t)?fs:t===1/0?ds:t===-1/0?ps:t},decode(t,e,n){if(typeof t=="number")return t;if(typeof t=="string"){if(t===fs)return NaN;if(t===ds)return 1/0;if(t===ps)return-1/0;const r=Number(t);if(!Number.isNaN(r))return r}if(n.mode==="strict")throw new TypeError(`[number-special] unrecognized wire value at "${n.path}": ${JSON.stringify(t)}. Expected a number or one of ${[...Ah].join(", ")}.`);return NaN}},Ph=[Js,Qs,Ys,Xs,Zs,eo];function jh(t,e={}){for(const n of Ph)t.register(n,{override:e.override??!1})}Js.id,Qs.id,Ys.id,Xs.id,Zs.id,eo.id;const lu=Nh();jh(lu);const fu=kh(lu.freeze());function xh(t,e){var n;const r=((n=t.input)==null?void 0:n.properties)??{};return e in r}function Th(t){var e,n;const r=(n=(e=t.input)==null?void 0:e.properties)==null?void 0:n.data;return Object.keys((r==null?void 0:r.properties)??{})}function Ch(t,e){var n,r,s;const o=(s=(r=(n=t.input)==null?void 0:n.properties)==null?void 0:r.data)==null?void 0:s.properties,i=o==null?void 0:o[e];return i!==void 0?i:void 0}function Rh(t,e){return e===void 0||t===void 0?t:fu.decode(t,e)}function Fr(t,e){const n=e.output;return!n||Object.keys(n).length===0?t:fu.encode(t,n)}async function Mh(t,e,n,r,s,o){const i=Th(n).map(c=>Rh(o[c],Ch(n,c)));if(xh(n,"session")&&e){const c=await e({session:s.session}),u=await t[r](c,...i);return Fr(u,n)}if(n.hasCtx){const c=e?await e(s):void 0,u=await t[r](c,...i);return Fr(u,n)}const a=await t[r](...i);return Fr(a,n)}const Dh={"decimal.js":"Decimal"};function Lh(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}Object.entries(Dh).map(([t,e])=>({pattern:new RegExp(`import\\(["'][^"']*${Lh(t)}[^"']*["']\\)\\.\\w+`,"g"),key:e}));function Bh(t={}){const e=t.level??"info",n=typeof t.destination=="string"&&t.destination.length>0,r=!n&&!!process.stderr.isTTY,s=t.format??(r?"pretty":"json"),o={level:e};if(s==="pretty")return o.transport={target:"pino-pretty",options:{colorize:!n,translateTime:"SYS:HH:MM:ss.l",ignore:"pid,hostname",...n?{destination:t.destination,mkdir:!0}:{destination:2}}},We(o);const i=n?We.destination({dest:t.destination,mkdir:!0,sync:!0}):We.destination(2);return We(o,i)}function du(t){return t?t.type==="array"?`${du(t.items)}[]`:t.enum?"enum":t.$ref?String(t.$ref).split("/").pop()||"object":t.anyOf||t.oneOf?"union":t.type??"object":"unknown"}function Uh(t){var e;const n=(e=((t==null?void 0:t.input)??{}).properties)==null?void 0:e.data,r=(n==null?void 0:n.properties)??{},s=new Set((n==null?void 0:n.required)??[]),o=Object.entries(r).map(([a,c])=>({name:a,type:du(c),required:s.has(a)})),i=o.map(a=>`${a.name}${a.required?"":"?"}: ${a.type}`).join(", ");return{params:o,text:i}}const to=new Fa({allErrors:!0});qa(to);for(const t of[Ws,Hs,us,ls,"discriminator"])to.addKeyword({keyword:t,valid:!0});to.addFormat("decimal",/^[+-]?(?:\d+(?:\.\d+)?|\.\d+)$/);class tt extends Error{constructor(e,n){super(n),this.name="UnionCodecError",this.code=e}}function qr(t){const e=t.discriminator;if(e===null||typeof e!="object"||Array.isArray(e))return;const n=e;if(typeof n.propertyName!="string")return;const r=n.mapping;if(!(r===null||typeof r!="object"||Array.isArray(r)))return{propertyName:n.propertyName,mapping:r}}function pu(t,e){const n=t[Hs];if(typeof n=="string"){const r=e.registry.get(n);if(r)return r}return e.registry.resolve(t)}function Vh(t,e,n){const r=pu(e,n);return r?r.encode(t,e,n):t}function Fh(t,e,n){const r=pu(e,n);return r?r.decode(t,e,n):t}function qh(t){const{id:e,schema:n}=t;return{id:e,kind:"union",schema:n,matches(r){if(r[Ws]==="union")return!0;const s=r.oneOf;return!Array.isArray(s)||s.length===0?!1:qr(r)!==void 0},encode(r,s,o){const i=qr(s);if(!i)throw new tt("E_UNION_NO_DISCRIMINATOR",`[${e}] schema node at "${o.path}" has no discriminator.propertyName; cannot dispatch union branch.`);const{propertyName:a,mapping:c}=i,u=r[a];if(u==null)throw new tt("E_UNION_NO_DISCRIMINATOR",`[${e}] value at "${o.path}" is missing the discriminator property "${a}".`);const l=String(u),f=c[l];if(!f)throw new tt("E_UNION_UNKNOWN_TAG",`[${e}] discriminator tag "${l}" at "${o.path}" is not in the mapping (known: ${Object.keys(c).join(", ")}).`);const m=o.resolve(f);return Vh(r,m,{...o,path:`${o.path}[${l}]`})},decode(r,s,o){if(r===null||typeof r!="object"||Array.isArray(r)){let d;throw r===null?d="null":Array.isArray(r)?d="array":d=typeof r,new tt("E_UNION_INVALID_WIRE",`[${e}] expected a JSON object on the wire at "${o.path}", got ${d}.`)}const i=r,a=qr(s);if(!a)throw new tt("E_UNION_NO_DISCRIMINATOR",`[${e}] schema node at "${o.path}" has no discriminator.propertyName; cannot dispatch union branch.`);const{propertyName:c,mapping:u}=a,l=i[c];if(l==null)throw new tt("E_UNION_NO_DISCRIMINATOR",`[${e}] wire object at "${o.path}" is missing the discriminator property "${c}".`);const f=String(l),m=u[f];if(!m)throw new tt("E_UNION_UNKNOWN_TAG",`[${e}] discriminator tag "${f}" on the wire at "${o.path}" is not in the mapping (known: ${Object.keys(u).join(", ")}).`);const p=o.resolve(m);return Fh(r,p,{...o,path:`${o.path}[${f}]`})}}}const Kh="x-apigen-instances";class On extends Error{constructor(e,n){super(n),this.name="NominalCodecError",this.code=e}}function zi(t){const e=t.properties;return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}function zh(t){const e=t.required;return Array.isArray(e)?e.filter(n=>typeof n=="string"):[]}function Gi(t,e,n){if(e){const r=n.registry.resolve(e);if(r)return r.encode(t,e,n)}return t}function Gh(t,e,n){if(e){const r=n.registry.resolve(e);if(r)return r.decode(t,e,n)}return t}function Wh(t){const{id:e,schema:n,ctor:r}=t;return{id:e,kind:"nominal",schema:n,matches(s){return s[Ws]==="nominal"?!0:s[Hs]===e},encode(s,o,i){if(s===null||typeof s!="object")return s;if(i.seen.has(s)){if(i.mode==="strict")throw new On("E_NOMINAL_CYCLE",`[${e}] cycle detected at "${i.path}": a nominal instance references itself. Strict mode rejects cycles (DESIGN §8.3); break the cycle or use 'lossy' mode.`);return null}i.seen.add(s);try{const a=zi(o),c=typeof o[ls]=="string"?o[ls]:"toJSON",u=s[c];if(typeof u=="function"){const d=u.call(s);if(d!==null&&typeof d=="object"&&!Array.isArray(d)){const v={};for(const[g,y]of Object.entries(d))v[g]=Gi(y,a[g],{...i,path:`${i.path}/${g}`});return v}return d}const l={},f=Object.keys(a),m=s,p=f.length>0?f:Object.keys(m);for(const d of p){const v=m[d];v!==void 0&&(l[d]=Gi(v,a[d],{...i,path:`${i.path}/${d}`}))}return l}finally{i.seen.delete(s)}},decode(s,o,i){if(s===null||typeof s!="object"||Array.isArray(s)){let l;throw s===null?l="null":Array.isArray(s)?l="array":l=typeof s,new On("E_NOMINAL_INVALID_WIRE",`[${e}] expected a JSON object on the wire at "${i.path}", got ${l}.`)}const a=s;for(const l of zh(o))if(!(l in a))throw new On("E_NOMINAL_INVALID_WIRE",`[${e}] required field "${l}" missing on the wire at "${i.path}".`);if(o[Kh]===!1)throw new On("E_NOMINAL_NONRECONSTRUCTABLE",`[${e}] is encode-only: the extractor marked it non-reconstructable (x-apigen-instances:false). It cannot be decoded back to a live instance.`);const c=zi(o),u={};for(const[l,f]of Object.entries(a))u[l]=Gh(f,c[l],{...i,path:`${i.path}/${l}`});if(r){const l=typeof o[us]=="string"?o[us]:"fromJSON",f=r[l];if(typeof f=="function")return f.call(r,u);const m=r;return new m(u)}return u}}}const Hh=[Js,Qs,Ys,Xs,Zs,eo],Jh={type:"object","x-apigen-logical":"nominal","x-apigen-codec":"ts.NominalSentinel"},Wi=Wh({id:"ts.NominalSentinel",schema:Jh}),Qh={oneOf:[],discriminator:{propertyName:"kind",mapping:{}},"x-apigen-logical":"union","x-apigen-codec":"ts.UnionSentinel"},Hi=qh({id:"ts.UnionSentinel",schema:Qh});function Yh(){const t=[...Hh.map(e=>[e.id,e]),[Wi.id,Wi],[Hi.id,Hi]];return Object.freeze(new Map(t))}Object.freeze({host:"ts",logicalTypeVersion:Oh,codecs:Yh()});function Xh(t,e,n){var r;const s=typeof((r=e==null?void 0:e.input)==null?void 0:r.description)=="string"?e.input.description:void 0,o=[n,s].filter(i=>typeof i=="string"&&i.length>0);return o.length>0?o.join(" — "):t}function Ji(t){if(!t||typeof t!="object"||Array.isArray(t)||Object.keys(t).length===0)return{outputSchema:void 0,wrapped:!1};const e=t;return e.type==="object"?{outputSchema:e,wrapped:!1}:{outputSchema:{type:"object",properties:{result:e},required:["result"]},wrapped:!0}}function Zh(t,e){return t?{result:e}:e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}const em={"decimal.js":"Decimal"};function tm(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}Object.entries(em).map(([t,e])=>({pattern:new RegExp(`import\\(["'][^"']*${tm(t)}[^"']*["']\\)\\.\\w+`,"g"),key:e}));function nm(t){return t.split(/[-_.]+/).flatMap(e=>e.replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2").replace(/([a-z\d])([A-Z])/g,"$1_$2").split("_").filter(Boolean)).map(e=>e.toLowerCase()).filter(Boolean)}const Qi=new Set(["string","number","boolean","integer"]);function rm(t){if(typeof t!="object"||t===null)return!1;const e=t;if(e.$ref!==void 0||e.oneOf||e.anyOf||e.allOf)return!1;const{type:n}=e;return typeof n=="string"?Qi.has(n):Array.isArray(n)?n.every(r=>Qi.has(r)||r==="null"):Array.isArray(e.enum)&&e.enum.length>0?e.enum.every(r=>["string","number","boolean"].includes(typeof r)):!1}function sm(t){if(!t||typeof t!="object")return!1;const e=t.properties;return e===void 0||typeof e!="object"||e===null?!1:Object.values(e).every(rm)}const om={"decimal.js":"Decimal"};function im(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}Object.entries(om).map(([t,e])=>({pattern:new RegExp(`import\\(["'][^"']*${im(t)}[^"']*["']\\)\\.\\w+`,"g"),key:e}));function Yi(t){return t.words.join("-")}function Xi(t){return t.words.map(lm).join("")}function Zi(t){return t.words.join("_")}function am(t){return t.replace(/\.[^.]+$/,"").replace(/[._]+/g,"-")}function ea(t,e={}){var n,r;const s=[t.namespace,...t.path],o=t.safe||sm(t.input)?"GET":"POST",i=((r=(n=e.http)==null?void 0:n.verb)==null?void 0:r[t.id])??o,a="/"+s.map(p=>Yi(p)).join("/"),c=s.map(p=>Zi(p)).join("_"),u=s.map(p=>Zi(p)).slice(0,-1).join("."),l=Xi(s[s.length-2]??s[0]),f=Xi(s[s.length-1]),m=s.map(p=>Yi(p));return{http:{verb:i,route:a},mcp:{name:c},grpc:{package:u,service:l,method:f},cli:{path:m}}}function cm(t,e){return`x-${t}-${e}`}const um=cm;function lm(t){return t.length===0?t:t[0].toUpperCase()+t.slice(1)}function hs(t){return{raw:t,words:nm(t)}}function fm(t,e,n){if(t)return t.find(r=>{var s;return r.kind==="action"&&r.namespace.raw===e&&((s=r.path[r.path.length-1])==null?void 0:s.raw)===n})}function dm(t){return hs(am(jf.basename(t)))}function pm(t,e,n){if(n){const s=fm(n,t.id,e);if(!s)throw new Error(`@adhd/apigen-plugin-mcp: no Operation found for package "${t.id}" fn "${e}" in the supplied operations[] — every fn in pkg.schemas must correspond to a real extracted Operation (orchestrator.ts buildDescriptor Step 5 invariant). This indicates a correlation bug, not a naming gap.`);return ea(s).mcp.name}const r={id:`${t.id}/${e}`,namespace:hs(t.id),path:[dm(t.importPath),hs(e)],safe:!1,input:{}};return ea(r).mcp.name}function hm(t,e){var n;const r=((n=t.input)==null?void 0:n.properties)??{},s=t["x-apigen-envelope"],o={};for(const i of Object.keys(r)){if(i==="data")continue;const a=(s==null?void 0:s[i])??"adhd",c=um(a,i),u=e[c];u!==void 0&&(o[i]=u)}return o}function ta(t,e){const n=t.options.toolDescriptions??{},r=new Sf.Server({name:"apigen-mcp",version:"1.0.0"},{capabilities:{tools:{}}}),s={};for(const o of t.packages)for(const i of Object.keys(o.schemas)){const a=pm({id:o.id,importPath:o.importPath},i,t.operations);s[a]={group:o.id,fnName:i,schema:o.schemas[i]}}return r.setRequestHandler(fi.ListToolsRequestSchema,async()=>({tools:Object.entries(s).map(([o,i])=>{const{outputSchema:a}=Ji(i.schema.output);return{name:o,description:Xh(o,i.schema,n[o]??n[i.fnName]),inputSchema:i.schema.input,...a?{outputSchema:a}:{}}})})),r.setRequestHandler(fi.CallToolRequestSchema,async o=>{const{name:i,arguments:a={}}=o.params,c=a._meta??{},u=s[i];if(!u)throw new Error(`Unknown tool: ${i}`);const l=t.packages.find(v=>v.id===u.group);if(!l)throw new Error(`Package not found: ${u.group}`);const f=u.schema,m=hm(f,c),p=a.data??{},d=Date.now();try{if(!l.fns)throw new Error(`Package ${l.id} has no functions`);const v=await Mh(l.fns,l.createClient,u.schema,u.fnName,m,p);e.info({tool:i,ms:Date.now()-d},`→ ${i}`);const{wrapped:g}=Ji(f.output),y=Zh(g,v);return{content:[{type:"text",text:JSON.stringify(v)}],...y?{structuredContent:y}:{}}}catch(v){throw e.error({tool:i,ms:Date.now()-d,err:v},`✗ ${i}`),v}}),{server:r,toolMetas:s}}async function mm(t){const e=t.options.transport??"stdio",n=t.options.port??3e3,r=t.options.host??"127.0.0.1",s=t.logger??Bh();s.info(`mcp server starting (${e})`);const{server:o,toolMetas:i}=ta(t,s),a=Object.keys(i);s.info({tools:a},`${a.length} tools available`);for(const[u,l]of Object.entries(i)){const{params:f,text:m}=Uh(l.schema);s.info({tool:u,args:{data:f}},`tool: ${u} args { data: {${m?` ${m} `:""}} }`)}if(e==="stdio"){const u=new Nf.StdioServerTransport;return await o.connect(u),s.info("stdio transport ready"),new Promise(l=>{t.signal&&t.signal.addEventListener("abort",()=>{s.info("mcp server shutting down"),l()})})}if(e==="sse"){const u=new Map,l=li.createServer(async(f,m)=>{try{const p=f.url??"";if(f.method==="GET"&&p==="/sse"){const d=new Of.SSEServerTransport("/messages",m);u.set(d.sessionId,d),d.onclose=()=>u.delete(d.sessionId),await o.connect(d)}else if(f.method==="POST"&&p.startsWith("/messages")){const d=new URLSearchParams(p.split("?")[1]??"").get("sessionId"),v=d?u.get(d):void 0;if(!v){m.writeHead(404),m.end("Session not found");return}await v.handlePostMessage(f,m)}else m.writeHead(404),m.end("Not found")}catch(p){s.error({err:p},"sse request handler error"),m.headersSent||m.writeHead(500),m.writableEnded||m.end("Internal Server Error")}});return l.listen(n,r,()=>{s.info({host:r,port:n},`listening on http://${r}:${n}`)}),new Promise(f=>{t.signal&&t.signal.addEventListener("abort",()=>{s.info("mcp server shutting down"),l.close(()=>f())})})}const c=li.createServer(async(u,l)=>{const{server:f}=ta(t,s),m=new _f.StreamableHTTPServerTransport({sessionIdGenerator:void 0});await f.connect(m),await m.handleRequest(u,l)});return c.listen(n,r,()=>{s.info({host:r,port:n},`listening on http://${r}:${n}`)}),new Promise(u=>{t.signal&&t.signal.addEventListener("abort",()=>{s.info("mcp server shutting down"),c.close(()=>u())})})}const gm={id:"mcp",run(t){return mm(t)}};function hu(t){t!==":memory:"&&Y.mkdirSync(q.dirname(t),{recursive:!0});const e=new kf(t);e.pragma("journal_mode = WAL"),e.pragma("busy_timeout = 5000");const n=If.createGraphBackend(e);return n.applySchema(),{db:e,graph:n}}function mu(t){t.db.close()}const ym=[".git",".adhd","adhd.environment.yaml"];function Kr(t){let e=q.resolve(t);const{root:n}=q.parse(e);for(;;){for(const s of ym)if(Y.existsSync(`${e}/${s}`))return e;if(e===n)return;const r=q.dirname(e);if(r===e)return;e=r}}const vm=new Set(["system","global","project"]);function $m(t,e){const n=t.cwd??process.cwd();if(t.scope)return t.scope==="project"?{scope:"project",projectRoot:Kr(n)??n}:{scope:t.scope};const r=e.ADHD_ENV_SCOPE;if(r!==void 0&&vm.has(r)){const o=r;return o==="project"?{scope:"project",projectRoot:Kr(n)??n}:{scope:o}}const s=Kr(n);return s?{scope:"project",projectRoot:s}:{scope:"global"}}function na(t){return`.${t}`}function wm(t){const e=Jn.homedir();if(process.platform==="darwin")return q.join(e,"Library","Application Support",t);if(process.platform==="win32"){const r=process.env.APPDATA??q.join(e,"AppData","Roaming");return q.join(r,t)}const n=process.env.XDG_DATA_HOME??q.join(e,".local","share");return q.join(n,t)}function bm(t){const e=t.orgNamespace,n=t.adhdRoot??q.join(Jn.homedir(),na(e)),r=t.adhdRoot??wm(e),s={system:q.join(r,t.project,t.namespace),global:q.join(n,t.project,t.namespace)};return t.projectRoot&&(s.project=q.join(t.projectRoot,na(e),t.project,t.namespace)),s}function gu(t,e){return e==="project"?t.project??t.global:t[e]}function Em(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Sm(t){if(t.__esModule)return t;var e=t.default;if(typeof e=="function"){var n=function r(){return this instanceof r?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach(function(r){var s=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(n,r,s.get?s:{enumerable:!0,get:function(){return t[r]}})}),n}const Z={ANCHOR:"&",COMMENT:"#",TAG:"!",DIRECTIVES_END:"-",DOCUMENT_END:"."},_={ALIAS:"ALIAS",BLANK_LINE:"BLANK_LINE",BLOCK_FOLDED:"BLOCK_FOLDED",BLOCK_LITERAL:"BLOCK_LITERAL",COMMENT:"COMMENT",DIRECTIVE:"DIRECTIVE",DOCUMENT:"DOCUMENT",FLOW_MAP:"FLOW_MAP",FLOW_SEQ:"FLOW_SEQ",MAP:"MAP",MAP_KEY:"MAP_KEY",MAP_VALUE:"MAP_VALUE",PLAIN:"PLAIN",QUOTE_DOUBLE:"QUOTE_DOUBLE",QUOTE_SINGLE:"QUOTE_SINGLE",SEQ:"SEQ",SEQ_ITEM:"SEQ_ITEM"},Bn="tag:yaml.org,2002:",He={MAP:"tag:yaml.org,2002:map",SEQ:"tag:yaml.org,2002:seq",STR:"tag:yaml.org,2002:str"};function ra(t){const e=[0];let n=t.indexOf(`
23
- `);for(;n!==-1;)n+=1,e.push(n),n=t.indexOf(`
24
- `,n);return e}function yu(t){let e,n;return typeof t=="string"?(e=ra(t),n=t):(Array.isArray(t)&&(t=t[0]),t&&t.context&&(t.lineStarts||(t.lineStarts=ra(t.context.src)),e=t.lineStarts,n=t.context.src)),{lineStarts:e,src:n}}function ms(t,e){if(typeof t!="number"||t<0)return null;const{lineStarts:n,src:r}=yu(e);if(!n||!r||t>r.length)return null;for(let o=0;o<n.length;++o){const i=n[o];if(t<i)return{line:o,col:t-n[o-1]+1};if(t===i)return{line:o+1,col:1}}const s=n.length;return{line:s,col:t-n[s-1]+1}}function Nm(t,e){const{lineStarts:n,src:r}=yu(e);if(!n||!(t>=1)||t>n.length)return null;const s=n[t-1];let o=n[t];for(;o&&o>s&&r[o-1]===`
25
- `;)--o;return r.slice(s,o)}function Om({start:t,end:e},n,r=80){let s=Nm(t.line,n);if(!s)return null;let{col:o}=t;if(s.length>r)if(o<=r-10)s=s.substr(0,r-1)+"…";else{const l=Math.round(r/2);s.length>o+l&&(s=s.substr(0,o+l-1)+"…"),o-=s.length-r,s="…"+s.substr(1-r)}let i=1,a="";e&&(e.line===t.line&&o+(e.col-t.col)<=r+1?i=e.col-t.col:(i=Math.min(s.length+1,r)-o,a="…"));const c=o>1?" ".repeat(o-1):"",u="^".repeat(i);return`${s}
26
- ${c}${u}${a}`}class H{static copy(e){return new H(e.start,e.end)}constructor(e,n){this.start=e,this.end=n||e}isEmpty(){return typeof this.start!="number"||!this.end||this.end<=this.start}setOrigRange(e,n){const{start:r,end:s}=this;if(e.length===0||s<=e[0])return this.origStart=r,this.origEnd=s,n;let o=n;for(;o<e.length&&!(e[o]>r);)++o;this.origStart=r+o;const i=o;for(;o<e.length&&!(e[o]>=s);)++o;return this.origEnd=s+o,i}}let A=class Ce{static addStringTerminator(e,n,r){if(r[r.length-1]===`
27
- `)return r;const s=Ce.endOfWhiteSpace(e,n);return s>=e.length||e[s]===`
28
- `?r+`
29
- `:r}static atDocumentBoundary(e,n,r){const s=e[n];if(!s)return!0;const o=e[n-1];if(o&&o!==`
30
- `)return!1;if(r){if(s!==r)return!1}else if(s!==Z.DIRECTIVES_END&&s!==Z.DOCUMENT_END)return!1;const i=e[n+1],a=e[n+2];if(i!==s||a!==s)return!1;const c=e[n+3];return!c||c===`
31
- `||c===" "||c===" "}static endOfIdentifier(e,n){let r=e[n];const s=r==="<",o=s?[`
32
- `," "," ",">"]:[`
33
- `," "," ","[","]","{","}",","];for(;r&&o.indexOf(r)===-1;)r=e[n+=1];return s&&r===">"&&(n+=1),n}static endOfIndent(e,n){let r=e[n];for(;r===" ";)r=e[n+=1];return n}static endOfLine(e,n){let r=e[n];for(;r&&r!==`
34
- `;)r=e[n+=1];return n}static endOfWhiteSpace(e,n){let r=e[n];for(;r===" "||r===" ";)r=e[n+=1];return n}static startOfLine(e,n){let r=e[n-1];if(r===`
35
- `)return n;for(;r&&r!==`
36
- `;)r=e[n-=1];return n+1}static endOfBlockIndent(e,n,r){const s=Ce.endOfIndent(e,r);if(s>r+n)return s;{const o=Ce.endOfWhiteSpace(e,s),i=e[o];if(!i||i===`
37
- `)return o}return null}static atBlank(e,n,r){const s=e[n];return s===`
38
- `||s===" "||s===" "||r&&!s}static nextNodeIsIndented(e,n,r){return!e||n<0?!1:n>0?!0:r&&e==="-"}static normalizeOffset(e,n){const r=e[n];return r?r!==`
39
- `&&e[n-1]===`
40
- `?n-1:Ce.endOfWhiteSpace(e,n):n}static foldNewline(e,n,r){let s=0,o=!1,i="",a=e[n+1];for(;a===" "||a===" "||a===`
41
- `;){switch(a){case`
42
- `:s=0,n+=1,i+=`
43
- `;break;case" ":s<=r&&(o=!0),n=Ce.endOfWhiteSpace(e,n+2)-1;break;case" ":s+=1,n+=1;break}a=e[n+1]}return i||(i=" "),a&&s<=r&&(o=!0),{fold:i,offset:n,error:o}}constructor(e,n,r){Object.defineProperty(this,"context",{value:r||null,writable:!0}),this.error=null,this.range=null,this.valueRange=null,this.props=n||[],this.type=e,this.value=null}getPropValue(e,n,r){if(!this.context)return null;const{src:s}=this.context,o=this.props[e];return o&&s[o.start]===n?s.slice(o.start+(r?1:0),o.end):null}get anchor(){for(let e=0;e<this.props.length;++e){const n=this.getPropValue(e,Z.ANCHOR,!0);if(n!=null)return n}return null}get comment(){const e=[];for(let n=0;n<this.props.length;++n){const r=this.getPropValue(n,Z.COMMENT,!0);r!=null&&e.push(r)}return e.length>0?e.join(`
44
- `):null}commentHasRequiredWhitespace(e){const{src:n}=this.context;if(this.header&&e===this.header.end||!this.valueRange)return!1;const{end:r}=this.valueRange;return e!==r||Ce.atBlank(n,r-1)}get hasComment(){if(this.context){const{src:e}=this.context;for(let n=0;n<this.props.length;++n)if(e[this.props[n].start]===Z.COMMENT)return!0}return!1}get hasProps(){if(this.context){const{src:e}=this.context;for(let n=0;n<this.props.length;++n)if(e[this.props[n].start]!==Z.COMMENT)return!0}return!1}get includesTrailingLines(){return!1}get jsonLike(){return[_.FLOW_MAP,_.FLOW_SEQ,_.QUOTE_DOUBLE,_.QUOTE_SINGLE].indexOf(this.type)!==-1}get rangeAsLinePos(){if(!this.range||!this.context)return;const e=ms(this.range.start,this.context.root);if(!e)return;const n=ms(this.range.end,this.context.root);return{start:e,end:n}}get rawValue(){if(!this.valueRange||!this.context)return null;const{start:e,end:n}=this.valueRange;return this.context.src.slice(e,n)}get tag(){for(let e=0;e<this.props.length;++e){const n=this.getPropValue(e,Z.TAG,!1);if(n!=null){if(n[1]==="<")return{verbatim:n.slice(2,-1)};{const[r,s,o]=n.match(/^(.*!)([^!]*)$/);return{handle:s,suffix:o}}}}return null}get valueRangeContainsNewline(){if(!this.valueRange||!this.context)return!1;const{start:e,end:n}=this.valueRange,{src:r}=this.context;for(let s=e;s<n;++s)if(r[s]===`
45
- `)return!0;return!1}parseComment(e){const{src:n}=this.context;if(n[e]===Z.COMMENT){const r=Ce.endOfLine(n,e+1),s=new H(e,r);return this.props.push(s),r}return e}setOrigRanges(e,n){return this.range&&(n=this.range.setOrigRange(e,n)),this.valueRange&&this.valueRange.setOrigRange(e,n),this.props.forEach(r=>r.setOrigRange(e,n)),n}toString(){const{context:{src:e},range:n,value:r}=this;if(r!=null)return r;const s=e.slice(n.start,n.end);return Ce.addStringTerminator(e,n.end,s)}};class pt extends Error{constructor(e,n,r){if(!r||!(n instanceof A))throw new Error(`Invalid arguments for new ${e}`);super(),this.name=e,this.message=r,this.source=n}makePretty(){if(!this.source)return;this.nodeType=this.source.type;const e=this.source.context&&this.source.context.root;if(typeof this.offset=="number"){this.range=new H(this.offset,this.offset+1);const n=e&&ms(this.offset,e);if(n){const r={line:n.line,col:n.col+1};this.linePos={start:n,end:r}}delete this.offset}else this.range=this.source.range,this.linePos=this.source.rangeAsLinePos;if(this.linePos){const{line:n,col:r}=this.linePos.start;this.message+=` at line ${n}, column ${r}`;const s=e&&Om(this.linePos,e);s&&(this.message+=`:
46
-
47
- ${s}
48
- `)}delete this.source}}class ln extends pt{constructor(e,n){super("YAMLReferenceError",e,n)}}class D extends pt{constructor(e,n){super("YAMLSemanticError",e,n)}}class ie extends pt{constructor(e,n){super("YAMLSyntaxError",e,n)}}class Dt extends pt{constructor(e,n){super("YAMLWarning",e,n)}}function ue(t,e,n){return(e=km(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function _m(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function km(t){var e=_m(t,"string");return typeof e=="symbol"?e:e+""}class fn extends A{static endOfLine(e,n,r){let s=e[n],o=n;for(;s&&s!==`
49
- `&&!(r&&(s==="["||s==="]"||s==="{"||s==="}"||s===","));){const i=e[o+1];if(s===":"&&(!i||i===`
50
- `||i===" "||i===" "||r&&i===",")||(s===" "||s===" ")&&i==="#")break;o+=1,s=i}return o}get strValue(){if(!this.valueRange||!this.context)return null;let{start:e,end:n}=this.valueRange;const{src:r}=this.context;let s=r[n-1];for(;e<n&&(s===`
51
- `||s===" "||s===" ");)s=r[--n-1];let o="";for(let a=e;a<n;++a){const c=r[a];if(c===`
52
- `){const{fold:u,offset:l}=A.foldNewline(r,a,-1);o+=u,a=l}else if(c===" "||c===" "){const u=a;let l=r[a+1];for(;a<n&&(l===" "||l===" ");)a+=1,l=r[a+1];l!==`
53
- `&&(o+=a>u?r.slice(u,a+1):c)}else o+=c}const i=r[e];switch(i){case" ":{const a="Plain value cannot start with a tab character";return{errors:[new D(this,a)],str:o}}case"@":case"`":{const a=`Plain value cannot start with reserved character ${i}`;return{errors:[new D(this,a)],str:o}}default:return o}}parseBlockValue(e){const{indent:n,inFlow:r,src:s}=this.context;let o=e,i=e;for(let a=s[o];a===`
54
- `&&!A.atDocumentBoundary(s,o+1);a=s[o]){const c=A.endOfBlockIndent(s,n,o+1);if(c===null||s[c]==="#")break;s[c]===`
55
- `?o=c:(i=fn.endOfLine(s,c,r),o=i)}return this.valueRange.isEmpty()&&(this.valueRange.start=e),this.valueRange.end=i,i}parse(e,n){this.context=e;const{inFlow:r,src:s}=e;let o=n;const i=s[o];return i&&i!=="#"&&i!==`
56
- `&&(o=fn.endOfLine(s,n,r)),this.valueRange=new H(n,o),o=A.endOfWhiteSpace(s,o),o=this.parseComment(o),(!this.hasComment||this.valueRange.isEmpty())&&(o=this.parseBlockValue(o)),o}}class dn extends A{constructor(){super(_.BLANK_LINE)}get includesTrailingLines(){return!0}parse(e,n){return this.context=e,this.range=new H(n,n+1),n+1}}class no extends A{constructor(e,n){super(e,n),this.node=null}get includesTrailingLines(){return!!this.node&&this.node.includesTrailingLines}parse(e,n){this.context=e;const{parseNode:r,src:s}=e;let{atLineStart:o,lineStart:i}=e;!o&&this.type===_.SEQ_ITEM&&(this.error=new D(this,"Sequence items must not have preceding content on the same line"));const a=o?n-i:e.indent;let c=A.endOfWhiteSpace(s,n+1),u=s[c];const l=u==="#",f=[];let m=null;for(;u===`
57
- `||u==="#";){if(u==="#"){const d=A.endOfLine(s,c+1);f.push(new H(c,d)),c=d}else{o=!0,i=c+1;const d=A.endOfWhiteSpace(s,i);s[d]===`
58
- `&&f.length===0&&(m=new dn,i=m.parse({src:s},i)),c=A.endOfIndent(s,i)}u=s[c]}if(A.nextNodeIsIndented(u,c-(i+a),this.type!==_.SEQ_ITEM)?this.node=r({atLineStart:o,inCollection:!1,indent:a,lineStart:i,parent:this},c):u&&i>n+1&&(c=i-1),this.node){if(m){const d=e.parent.items||e.parent.contents;d&&d.push(m)}f.length&&Array.prototype.push.apply(this.props,f),c=this.node.range.end}else if(l){const d=f[0];this.props.push(d),c=d.end}else c=A.endOfLine(s,n+1);const p=this.node?this.node.valueRange.end:c;return this.valueRange=new H(n,p),c}setOrigRanges(e,n){return n=super.setOrigRanges(e,n),this.node?this.node.setOrigRanges(e,n):n}toString(){const{context:{src:e},node:n,range:r,value:s}=this;if(s!=null)return s;const o=n?e.slice(r.start,n.range.start)+String(n):e.slice(r.start,r.end);return A.addStringTerminator(e,r.end,o)}}class en extends A{constructor(){super(_.COMMENT)}parse(e,n){this.context=e;const r=this.parseComment(n);return this.range=new H(n,r),r}}function gs(t){let e=t;for(;e instanceof no;)e=e.node;if(!(e instanceof vu))return null;const n=e.items.length;let r=-1;for(let i=n-1;i>=0;--i){const a=e.items[i];if(a.type===_.COMMENT){const{indent:c,lineStart:u}=a.context;if(c>0&&a.range.start>=u+c)break;r=i}else if(a.type===_.BLANK_LINE)r=i;else break}if(r===-1)return null;const s=e.items.splice(r,n-r),o=s[0].range.start;for(;e.range.end=o,e.valueRange&&e.valueRange.end>o&&(e.valueRange.end=o),e!==t;)e=e.context.parent;return s}let vu=class ys extends A{static nextContentHasIndent(e,n,r){const s=A.endOfLine(e,n)+1;n=A.endOfWhiteSpace(e,s);const o=e[n];return o?n>=s+r?!0:o!=="#"&&o!==`
59
- `?!1:ys.nextContentHasIndent(e,n,r):!1}constructor(e){super(e.type===_.SEQ_ITEM?_.SEQ:_.MAP);for(let r=e.props.length-1;r>=0;--r)if(e.props[r].start<e.context.lineStart){this.props=e.props.slice(0,r+1),e.props=e.props.slice(r+1);const s=e.props[0]||e.valueRange;e.range.start=s.start;break}this.items=[e];const n=gs(e);n&&Array.prototype.push.apply(this.items,n)}get includesTrailingLines(){return this.items.length>0}parse(e,n){this.context=e;const{parseNode:r,src:s}=e;let o=A.startOfLine(s,n);const i=this.items[0];i.context.parent=this,this.valueRange=H.copy(i.valueRange);const a=i.range.start-i.context.lineStart;let c=n;c=A.normalizeOffset(s,c);let u=s[c],l=A.endOfWhiteSpace(s,o)===c,f=!1;for(;u;){for(;u===`
60
- `||u==="#";){if(l&&u===`
61
- `&&!f){const d=new dn;if(c=d.parse({src:s},c),this.valueRange.end=c,c>=s.length){u=null;break}this.items.push(d),c-=1}else if(u==="#"){if(c<o+a&&!ys.nextContentHasIndent(s,c,a))return c;const d=new en;if(c=d.parse({indent:a,lineStart:o,src:s},c),this.items.push(d),this.valueRange.end=c,c>=s.length){u=null;break}}if(o=c+1,c=A.endOfIndent(s,o),A.atBlank(s,c)){const d=A.endOfWhiteSpace(s,c),v=s[d];(!v||v===`
62
- `||v==="#")&&(c=d)}u=s[c],l=!0}if(!u)break;if(c!==o+a&&(l||u!==":")){if(c<o+a){o>n&&(c=o);break}else if(!this.error){const d="All collection items must start at the same column";this.error=new ie(this,d)}}if(i.type===_.SEQ_ITEM){if(u!=="-"){o>n&&(c=o);break}}else if(u==="-"&&!this.error){const d=s[c+1];if(!d||d===`
63
- `||d===" "||d===" "){const v="A collection cannot be both a mapping and a sequence";this.error=new ie(this,v)}}const m=r({atLineStart:l,inCollection:!0,indent:a,lineStart:o,parent:this},c);if(!m)return c;if(this.items.push(m),this.valueRange.end=m.valueRange.end,c=A.normalizeOffset(s,m.range.end),u=s[c],l=!1,f=m.includesTrailingLines,u){let d=c-1,v=s[d];for(;v===" "||v===" ";)v=s[--d];v===`
64
- `&&(o=d+1,l=!0)}const p=gs(m);p&&Array.prototype.push.apply(this.items,p)}return c}setOrigRanges(e,n){return n=super.setOrigRanges(e,n),this.items.forEach(r=>{n=r.setOrigRanges(e,n)}),n}toString(){const{context:{src:e},items:n,range:r,value:s}=this;if(s!=null)return s;let o=e.slice(r.start,n[0].range.start)+String(n[0]);for(let i=1;i<n.length;++i){const a=n[i],{atLineStart:c,indent:u}=a.context;if(c)for(let l=0;l<u;++l)o+=" ";o+=String(a)}return A.addStringTerminator(e,r.end,o)}};class Im extends A{constructor(){super(_.DIRECTIVE),this.name=null}get parameters(){const e=this.rawValue;return e?e.trim().split(/[ \t]+/):[]}parseName(e){const{src:n}=this.context;let r=e,s=n[r];for(;s&&s!==`
65
- `&&s!==" "&&s!==" ";)s=n[r+=1];return this.name=n.slice(e,r),r}parseParameters(e){const{src:n}=this.context;let r=e,s=n[r];for(;s&&s!==`
66
- `&&s!=="#";)s=n[r+=1];return this.valueRange=new H(e,r),r}parse(e,n){this.context=e;let r=this.parseName(n+1);return r=this.parseParameters(r),r=this.parseComment(r),this.range=new H(n,r),r}}let Am=class vs extends A{static startCommentOrEndBlankLine(e,n){const r=A.endOfWhiteSpace(e,n),s=e[r];return s==="#"||s===`
67
- `?r:n}constructor(){super(_.DOCUMENT),this.directives=null,this.contents=null,this.directivesEndMarker=null,this.documentEndMarker=null}parseDirectives(e){const{src:n}=this.context;this.directives=[];let r=!0,s=!1,o=e;for(;!A.atDocumentBoundary(n,o,Z.DIRECTIVES_END);)switch(o=vs.startCommentOrEndBlankLine(n,o),n[o]){case`
68
- `:if(r){const i=new dn;o=i.parse({src:n},o),o<n.length&&this.directives.push(i)}else o+=1,r=!0;break;case"#":{const i=new en;o=i.parse({src:n},o),this.directives.push(i),r=!1}break;case"%":{const i=new Im;o=i.parse({parent:this,src:n},o),this.directives.push(i),s=!0,r=!1}break;default:return s?this.error=new D(this,"Missing directives-end indicator line"):this.directives.length>0&&(this.contents=this.directives,this.directives=[]),o}return n[o]?(this.directivesEndMarker=new H(o,o+3),o+3):(s?this.error=new D(this,"Missing directives-end indicator line"):this.directives.length>0&&(this.contents=this.directives,this.directives=[]),o)}parseContents(e){const{parseNode:n,src:r}=this.context;this.contents||(this.contents=[]);let s=e;for(;r[s-1]==="-";)s-=1;let o=A.endOfWhiteSpace(r,e),i=s===e;for(this.valueRange=new H(o);!A.atDocumentBoundary(r,o,Z.DOCUMENT_END);){switch(r[o]){case`
69
- `:if(i){const a=new dn;o=a.parse({src:r},o),o<r.length&&this.contents.push(a)}else o+=1,i=!0;s=o;break;case"#":{const a=new en;o=a.parse({src:r},o),this.contents.push(a),i=!1}break;default:{const a=A.endOfIndent(r,o),c=n({atLineStart:i,indent:-1,inFlow:!1,inCollection:!1,lineStart:s,parent:this},a);if(!c)return this.valueRange.end=a;this.contents.push(c),o=c.range.end,i=!1;const u=gs(c);u&&Array.prototype.push.apply(this.contents,u)}}o=vs.startCommentOrEndBlankLine(r,o)}if(this.valueRange.end=o,r[o]&&(this.documentEndMarker=new H(o,o+3),o+=3,r[o])){if(o=A.endOfWhiteSpace(r,o),r[o]==="#"){const a=new en;o=a.parse({src:r},o),this.contents.push(a)}switch(r[o]){case`
70
- `:o+=1;break;case void 0:break;default:this.error=new ie(this,"Document end marker line cannot have a non-comment suffix")}}return o}parse(e,n){e.root=this,this.context=e;const{src:r}=e;let s=r.charCodeAt(n)===65279?n+1:n;return s=this.parseDirectives(s),s=this.parseContents(s),s}setOrigRanges(e,n){return n=super.setOrigRanges(e,n),this.directives.forEach(r=>{n=r.setOrigRanges(e,n)}),this.directivesEndMarker&&(n=this.directivesEndMarker.setOrigRange(e,n)),this.contents.forEach(r=>{n=r.setOrigRanges(e,n)}),this.documentEndMarker&&(n=this.documentEndMarker.setOrigRange(e,n)),n}toString(){const{contents:e,directives:n,value:r}=this;if(r!=null)return r;let s=n.join("");return e.length>0&&((n.length>0||e[0].type===_.COMMENT)&&(s+=`---
71
- `),s+=e.join("")),s[s.length-1]!==`
72
- `&&(s+=`
73
- `),s}},Pm=class extends A{parse(t,e){this.context=t;const{src:n}=t;let r=A.endOfIdentifier(n,e+1);return this.valueRange=new H(e+1,r),r=A.endOfWhiteSpace(n,r),r=this.parseComment(r),r}};const qe={CLIP:"CLIP",KEEP:"KEEP",STRIP:"STRIP"};class jm extends A{constructor(e,n){super(e,n),this.blockIndent=null,this.chomping=qe.CLIP,this.header=null}get includesTrailingLines(){return this.chomping===qe.KEEP}get strValue(){if(!this.valueRange||!this.context)return null;let{start:e,end:n}=this.valueRange;const{indent:r,src:s}=this.context;if(this.valueRange.isEmpty())return"";let o=null,i=s[n-1];for(;i===`
74
- `||i===" "||i===" ";){if(n-=1,n<=e){if(this.chomping===qe.KEEP)break;return""}i===`
75
- `&&(o=n),i=s[n-1]}let a=n+1;o&&(this.chomping===qe.KEEP?(a=o,n=this.valueRange.end):n=o);const c=r+this.blockIndent,u=this.type===_.BLOCK_FOLDED;let l=!0,f="",m="",p=!1;for(let d=e;d<n;++d){for(let g=0;g<c&&s[d]===" ";++g)d+=1;const v=s[d];if(v===`
76
- `)m===`
77
- `?f+=`
78
- `:m=`
79
- `;else{const g=A.endOfLine(s,d),y=s.slice(d,g);d=g,u&&(v===" "||v===" ")&&d<a?(m===" "?m=`
80
- `:!p&&!l&&m===`
81
- `&&(m=`
82
-
83
- `),f+=m+y,m=g<n&&s[g]||"",p=!0):(f+=m+y,m=u&&d<a?" ":`
84
- `,p=!1),l&&y!==""&&(l=!1)}}return this.chomping===qe.STRIP?f:f+`
85
- `}parseBlockHeader(e){const{src:n}=this.context;let r=e+1,s="";for(;;){const o=n[r];switch(o){case"-":this.chomping=qe.STRIP;break;case"+":this.chomping=qe.KEEP;break;case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":s+=o;break;default:return this.blockIndent=Number(s)||null,this.header=new H(e,r),r}r+=1}}parseBlockValue(e){const{indent:n,src:r}=this.context,s=!!this.blockIndent;let o=e,i=e,a=1;for(let c=r[o];c===`
86
- `&&(o+=1,!A.atDocumentBoundary(r,o));c=r[o]){const u=A.endOfBlockIndent(r,n,o);if(u===null)break;const l=r[u],f=u-(o+n);if(this.blockIndent){if(l&&l!==`
87
- `&&f<this.blockIndent){if(r[u]==="#")break;if(!this.error){const m=`Block scalars must not be less indented than their ${s?"explicit indentation indicator":"first line"}`;this.error=new D(this,m)}}}else if(r[u]!==`
88
- `){if(f<a){const m="Block scalars with more-indented leading empty lines must use an explicit indentation indicator";this.error=new D(this,m)}this.blockIndent=f}else f>a&&(a=f);r[u]===`
89
- `?o=u:o=i=A.endOfLine(r,u)}return this.chomping!==qe.KEEP&&(o=r[i]?i+1:i),this.valueRange=new H(e+1,o),o}parse(e,n){this.context=e;const{src:r}=e;let s=this.parseBlockHeader(n);return s=A.endOfWhiteSpace(r,s),s=this.parseComment(s),s=this.parseBlockValue(s),s}setOrigRanges(e,n){return n=super.setOrigRanges(e,n),this.header?this.header.setOrigRange(e,n):n}}class xm extends A{constructor(e,n){super(e,n),this.items=null}prevNodeIsJsonLike(e=this.items.length){const n=this.items[e-1];return!!n&&(n.jsonLike||n.type===_.COMMENT&&this.prevNodeIsJsonLike(e-1))}parse(e,n){this.context=e;const{parseNode:r,src:s}=e;let{indent:o,lineStart:i}=e,a=s[n];this.items=[{char:a,offset:n}];let c=A.endOfWhiteSpace(s,n+1);for(a=s[c];a&&a!=="]"&&a!=="}";){switch(a){case`
90
- `:{i=c+1;const u=A.endOfWhiteSpace(s,i);if(s[u]===`
91
- `){const l=new dn;i=l.parse({src:s},i),this.items.push(l)}if(c=A.endOfIndent(s,i),c<=i+o&&(a=s[c],c<i+o||a!=="]"&&a!=="}")){const l="Insufficient indentation in flow collection";this.error=new D(this,l)}}break;case",":this.items.push({char:a,offset:c}),c+=1;break;case"#":{const u=new en;c=u.parse({src:s},c),this.items.push(u)}break;case"?":case":":{const u=s[c+1];if(u===`
92
- `||u===" "||u===" "||u===","||a===":"&&this.prevNodeIsJsonLike()){this.items.push({char:a,offset:c}),c+=1;break}}default:{const u=r({atLineStart:!1,inCollection:!1,inFlow:!0,indent:-1,lineStart:i,parent:this},c);if(!u)return this.valueRange=new H(n,c),c;this.items.push(u),c=A.normalizeOffset(s,u.range.end)}}c=A.endOfWhiteSpace(s,c),a=s[c]}return this.valueRange=new H(n,c+1),a&&(this.items.push({char:a,offset:c}),c=A.endOfWhiteSpace(s,c+1),c=this.parseComment(c)),c}setOrigRanges(e,n){return n=super.setOrigRanges(e,n),this.items.forEach(r=>{if(r instanceof A)n=r.setOrigRanges(e,n);else if(e.length===0)r.origOffset=r.offset;else{let s=n;for(;s<e.length&&!(e[s]>r.offset);)++s;r.origOffset=r.offset+s,n=s}}),n}toString(){const{context:{src:e},items:n,range:r,value:s}=this;if(s!=null)return s;const o=n.filter(c=>c instanceof A);let i="",a=r.start;return o.forEach(c=>{const u=e.slice(a,c.range.start);a=c.range.end,i+=u+String(c),i[i.length-1]===`
93
- `&&e[a-1]!==`
94
- `&&e[a]===`
95
- `&&(a+=1)}),i+=e.slice(a,r.end),A.addStringTerminator(e,r.end,i)}}class ro extends A{static endOfQuote(e,n){let r=e[n];for(;r&&r!=='"';)n+=r==="\\"?2:1,r=e[n];return n+1}get strValue(){if(!this.valueRange||!this.context)return null;const e=[],{start:n,end:r}=this.valueRange,{indent:s,src:o}=this.context;o[r-1]!=='"'&&e.push(new ie(this,'Missing closing "quote'));let i="";for(let a=n+1;a<r-1;++a){const c=o[a];if(c===`
96
- `){A.atDocumentBoundary(o,a+1)&&e.push(new D(this,"Document boundary indicators are not allowed within string values"));const{fold:u,offset:l,error:f}=A.foldNewline(o,a,s);i+=u,a=l,f&&e.push(new D(this,"Multi-line double-quoted string needs to be sufficiently indented"))}else if(c==="\\")switch(a+=1,o[a]){case"0":i+="\0";break;case"a":i+="\x07";break;case"b":i+="\b";break;case"e":i+="\x1B";break;case"f":i+="\f";break;case"n":i+=`
97
- `;break;case"r":i+="\r";break;case"t":i+=" ";break;case"v":i+="\v";break;case"N":i+="…";break;case"_":i+=" ";break;case"L":i+="\u2028";break;case"P":i+="\u2029";break;case" ":i+=" ";break;case'"':i+='"';break;case"/":i+="/";break;case"\\":i+="\\";break;case" ":i+=" ";break;case"x":i+=this.parseCharCode(a+1,2,e),a+=2;break;case"u":i+=this.parseCharCode(a+1,4,e),a+=4;break;case"U":i+=this.parseCharCode(a+1,8,e),a+=8;break;case`
98
- `:for(;o[a+1]===" "||o[a+1]===" ";)a+=1;break;default:e.push(new ie(this,`Invalid escape sequence ${o.substr(a-1,2)}`)),i+="\\"+o[a]}else if(c===" "||c===" "){const u=a;let l=o[a+1];for(;l===" "||l===" ";)a+=1,l=o[a+1];l!==`
99
- `&&(i+=a>u?o.slice(u,a+1):c)}else i+=c}return e.length>0?{errors:e,str:i}:i}parseCharCode(e,n,r){const{src:s}=this.context,o=s.substr(e,n),i=o.length===n&&/^[0-9a-fA-F]+$/.test(o)?parseInt(o,16):NaN;return isNaN(i)?(r.push(new ie(this,`Invalid escape sequence ${s.substr(e-2,n+2)}`)),s.substr(e-2,n+2)):String.fromCodePoint(i)}parse(e,n){this.context=e;const{src:r}=e;let s=ro.endOfQuote(r,n+1);return this.valueRange=new H(n,s),s=A.endOfWhiteSpace(r,s),s=this.parseComment(s),s}}class so extends A{static endOfQuote(e,n){let r=e[n];for(;r;)if(r==="'"){if(e[n+1]!=="'")break;r=e[n+=2]}else r=e[n+=1];return n+1}get strValue(){if(!this.valueRange||!this.context)return null;const e=[],{start:n,end:r}=this.valueRange,{indent:s,src:o}=this.context;o[r-1]!=="'"&&e.push(new ie(this,"Missing closing 'quote"));let i="";for(let a=n+1;a<r-1;++a){const c=o[a];if(c===`
100
- `){A.atDocumentBoundary(o,a+1)&&e.push(new D(this,"Document boundary indicators are not allowed within string values"));const{fold:u,offset:l,error:f}=A.foldNewline(o,a,s);i+=u,a=l,f&&e.push(new D(this,"Multi-line single-quoted string needs to be sufficiently indented"))}else if(c==="'")i+=c,a+=1,o[a]!=="'"&&e.push(new ie(this,"Unescaped single quote? This should not happen."));else if(c===" "||c===" "){const u=a;let l=o[a+1];for(;l===" "||l===" ";)a+=1,l=o[a+1];l!==`
101
- `&&(i+=a>u?o.slice(u,a+1):c)}else i+=c}return e.length>0?{errors:e,str:i}:i}parse(e,n){this.context=e;const{src:r}=e;let s=so.endOfQuote(r,n+1);return this.valueRange=new H(n,s),s=A.endOfWhiteSpace(r,s),s=this.parseComment(s),s}}function Tm(t,e){switch(t){case _.ALIAS:return new Pm(t,e);case _.BLOCK_FOLDED:case _.BLOCK_LITERAL:return new jm(t,e);case _.FLOW_MAP:case _.FLOW_SEQ:return new xm(t,e);case _.MAP_KEY:case _.MAP_VALUE:case _.SEQ_ITEM:return new no(t,e);case _.COMMENT:case _.PLAIN:return new fn(t,e);case _.QUOTE_DOUBLE:return new ro(t,e);case _.QUOTE_SINGLE:return new so(t,e);default:return null}}class tn{static parseType(e,n,r){switch(e[n]){case"*":return _.ALIAS;case">":return _.BLOCK_FOLDED;case"|":return _.BLOCK_LITERAL;case"{":return _.FLOW_MAP;case"[":return _.FLOW_SEQ;case"?":return!r&&A.atBlank(e,n+1,!0)?_.MAP_KEY:_.PLAIN;case":":return!r&&A.atBlank(e,n+1,!0)?_.MAP_VALUE:_.PLAIN;case"-":return!r&&A.atBlank(e,n+1,!0)?_.SEQ_ITEM:_.PLAIN;case'"':return _.QUOTE_DOUBLE;case"'":return _.QUOTE_SINGLE;default:return _.PLAIN}}constructor(e={},{atLineStart:n,inCollection:r,inFlow:s,indent:o,lineStart:i,parent:a}={}){ue(this,"parseNode",(c,u)=>{if(A.atDocumentBoundary(this.src,u))return null;const l=new tn(this,c),{props:f,type:m,valueStart:p}=l.parseProps(u),d=Tm(m,f);let v=u;try{v=d.parse(l,p)}catch(g){const y=g instanceof Error?g.message:String(g);d.error||(d.error=new ie(d,y))}if(d.range=new H(u,v),v<=u&&(d.error||(d.error=new Error("Node#parse consumed no characters")),d.error.parseEnd=v,d.error.source=d,d.range.end=u+1),l.nodeStartsCollection(d)){!d.error&&!l.atLineStart&&l.parent.type===_.DOCUMENT&&(d.error=new ie(d,"Block collection must not have preceding content here (e.g. directives-end indicator)"));const g=new vu(d);return v=g.parse(new tn(l),v),g.range=new H(u,v),g}return d}),this.atLineStart=n??(e.atLineStart||!1),this.inCollection=r??(e.inCollection||!1),this.inFlow=s??(e.inFlow||!1),this.indent=o??e.indent,this.lineStart=i??e.lineStart,this.parent=a??(e.parent||{}),this.root=e.root,this.src=e.src}nodeStartsCollection(e){const{inCollection:n,inFlow:r,src:s}=this;if(n||r)return!1;if(e instanceof no)return!0;let o=e.range.end;return s[o]===`
102
- `||s[o-1]===`
103
- `?!1:(o=A.endOfWhiteSpace(s,o),s[o]===":")}parseProps(e){const{inFlow:n,parent:r,src:s}=this,o=[];let i=!1;e=this.atLineStart?A.endOfIndent(s,e):A.endOfWhiteSpace(s,e);let a=s[e];for(;a===Z.ANCHOR||a===Z.COMMENT||a===Z.TAG||a===`
104
- `;){if(a===`
105
- `){let u=e,l;do l=u+1,u=A.endOfIndent(s,l);while(s[u]===`
106
- `);const f=u-(l+this.indent),m=r.type===_.SEQ_ITEM&&r.context.atLineStart;if(s[u]!=="#"&&!A.nextNodeIsIndented(s[u],f,!m))break;this.atLineStart=!0,this.lineStart=l,i=!1,e=u}else if(a===Z.COMMENT){const u=A.endOfLine(s,e+1);o.push(new H(e,u)),e=u}else{let u=A.endOfIdentifier(s,e+1);a===Z.TAG&&s[u]===","&&/^[a-zA-Z0-9-]+\.[a-zA-Z0-9-]+,\d\d\d\d(-\d\d){0,2}\/\S/.test(s.slice(e+1,u+13))&&(u=A.endOfIdentifier(s,u+5)),o.push(new H(e,u)),i=!0,e=A.endOfWhiteSpace(s,u)}a=s[e]}i&&a===":"&&A.atBlank(s,e+1,!0)&&(e-=1);const c=tn.parseType(s,e,n);return{props:o,type:c,valueStart:e}}}function oo(t){const e=[];t.indexOf("\r")!==-1&&(t=t.replace(/\r\n?/g,(s,o)=>(s.length>1&&e.push(o),`
107
- `)));const n=[];let r=0;do{const s=new Am,o=new tn({src:t});r=s.parse(o,r),n.push(s)}while(r<t.length);return n.setOrigRanges=()=>{if(e.length===0)return!1;for(let o=1;o<e.length;++o)e[o]-=o;let s=0;for(let o=0;o<n.length;++o)s=n[o].setOrigRanges(e,s);return e.splice(0,e.length),!0},n.toString=()=>n.join(`...
108
- `),n}function Cm(t,e,n){return n?`#${n.replace(/[\s\S]^/gm,`$&${e}#`)}
109
- ${e}${t}`:t}function It(t,e,n){return n?n.indexOf(`
110
- `)===-1?`${t} #${n}`:`${t}
111
- `+n.replace(/^/gm,`${e||""}#`):t}class de{}function Se(t,e,n){if(Array.isArray(t))return t.map((r,s)=>Se(r,String(s),n));if(t&&typeof t.toJSON=="function"){const r=n&&n.anchors&&n.anchors.get(t);r&&(n.onCreate=o=>{r.res=o,delete n.onCreate});const s=t.toJSON(e,n);return r&&n.onCreate&&n.onCreate(s),s}return(!n||!n.keep)&&typeof t=="bigint"?Number(t):t}class G extends de{constructor(e){super(),this.value=e}toJSON(e,n){return n&&n.keep?this.value:Se(this.value,e,n)}toString(){return String(this.value)}}function sa(t,e,n){let r=n;for(let s=e.length-1;s>=0;--s){const o=e[s];if(Number.isInteger(o)&&o>=0){const i=[];i[o]=r,r=i}else{const i={};Object.defineProperty(i,o,{value:r,writable:!0,enumerable:!0,configurable:!0}),r=i}}return t.createNode(r,!1)}const Qt=t=>t==null||typeof t=="object"&&t[Symbol.iterator]().next().done;class Q extends de{constructor(e){super(),ue(this,"items",[]),this.schema=e}addIn(e,n){if(Qt(e))this.add(n);else{const[r,...s]=e,o=this.get(r,!0);if(o instanceof Q)o.addIn(s,n);else if(o===void 0&&this.schema)this.set(r,sa(this.schema,s,n));else throw new Error(`Expected YAML collection at ${r}. Remaining path: ${s}`)}}deleteIn([e,...n]){if(n.length===0)return this.delete(e);const r=this.get(e,!0);if(r instanceof Q)return r.deleteIn(n);throw new Error(`Expected YAML collection at ${e}. Remaining path: ${n}`)}getIn([e,...n],r){const s=this.get(e,!0);return n.length===0?!r&&s instanceof G?s.value:s:s instanceof Q?s.getIn(n,r):void 0}hasAllNullValues(){return this.items.every(e=>{if(!e||e.type!=="PAIR")return!1;const n=e.value;return n==null||n instanceof G&&n.value==null&&!n.commentBefore&&!n.comment&&!n.tag})}hasIn([e,...n]){if(n.length===0)return this.has(e);const r=this.get(e,!0);return r instanceof Q?r.hasIn(n):!1}setIn([e,...n],r){if(n.length===0)this.set(e,r);else{const s=this.get(e,!0);if(s instanceof Q)s.setIn(n,r);else if(s===void 0&&this.schema)this.set(e,sa(this.schema,n,r));else throw new Error(`Expected YAML collection at ${e}. Remaining path: ${n}`)}}toJSON(){return null}toString(e,{blockItem:n,flowChars:r,isMap:s,itemIndent:o},i,a){const{indent:c,indentStep:u,stringify:l}=e,f=this.type===_.FLOW_MAP||this.type===_.FLOW_SEQ||e.inFlow;f&&(o+=u);const m=s&&this.hasAllNullValues();e=Object.assign({},e,{allNullValues:m,indent:o,inFlow:f,type:null});let p=!1,d=!1;const v=this.items.reduce((y,$,S)=>{let N;$&&(!p&&$.spaceBefore&&y.push({type:"comment",str:""}),$.commentBefore&&$.commentBefore.match(/^.*$/gm).forEach(C=>{y.push({type:"comment",str:`#${C}`})}),$.comment&&(N=$.comment),f&&(!p&&$.spaceBefore||$.commentBefore||$.comment||$.key&&($.key.commentBefore||$.key.comment)||$.value&&($.value.commentBefore||$.value.comment))&&(d=!0)),p=!1;let k=l($,e,()=>N=null,()=>p=!0);return f&&!d&&k.includes(`
112
- `)&&(d=!0),f&&S<this.items.length-1&&(k+=","),k=It(k,o,N),p&&(N||f)&&(p=!1),y.push({type:"item",str:k}),y},[]);let g;if(v.length===0)g=r.start+r.end;else if(f){const{start:y,end:$}=r,S=v.map(N=>N.str);if(d||S.reduce((N,k)=>N+k.length+2,2)>Q.maxFlowStringSingleLineLength){g=y;for(const N of S)g+=N?`
113
- ${u}${c}${N}`:`
114
- `;g+=`
115
- ${c}${$}`}else g=`${y} ${S.join(" ")} ${$}`}else{const y=v.map(n);g=y.shift();for(const $ of y)g+=$?`
116
- ${c}${$}`:`
117
- `}return this.comment?(g+=`
118
- `+this.comment.replace(/^/gm,`${c}#`),i&&i()):p&&a&&a(),g}}ue(Q,"maxFlowStringSingleLineLength",60);function _n(t){let e=t instanceof G?t.value:t;return e&&typeof e=="string"&&(e=Number(e)),Number.isInteger(e)&&e>=0?e:null}class Pe extends Q{add(e){this.items.push(e)}delete(e){const n=_n(e);return typeof n!="number"?!1:this.items.splice(n,1).length>0}get(e,n){const r=_n(e);if(typeof r!="number")return;const s=this.items[r];return!n&&s instanceof G?s.value:s}has(e){const n=_n(e);return typeof n=="number"&&n<this.items.length}set(e,n){const r=_n(e);if(typeof r!="number")throw new Error(`Expected a valid index, not ${e}.`);this.items[r]=n}toJSON(e,n){const r=[];n&&n.onCreate&&n.onCreate(r);let s=0;for(const o of this.items)r.push(Se(o,String(s++),n));return r}toString(e,n,r){return e?super.toString(e,{blockItem:s=>s.type==="comment"?s.str:`- ${s.str}`,flowChars:{start:"[",end:"]"},isMap:!1,itemIndent:(e.indent||"")+" "},n,r):JSON.stringify(this)}}const Rm=(t,e,n)=>e===null?"":typeof e!="object"?String(e):t instanceof de&&n&&n.doc?t.toString({anchors:Object.create(null),doc:n.doc,indent:"",indentStep:n.indentStep,inFlow:!0,inStringifyKey:!0,stringify:n.stringify}):JSON.stringify(e);class V extends de{constructor(e,n=null){super(),this.key=e,this.value=n,this.type=V.Type.PAIR}get commentBefore(){return this.key instanceof de?this.key.commentBefore:void 0}set commentBefore(e){if(this.key==null&&(this.key=new G(null)),this.key instanceof de)this.key.commentBefore=e;else{const n="Pair.commentBefore is an alias for Pair.key.commentBefore. To set it, the key must be a Node.";throw new Error(n)}}addToJSMap(e,n){const r=Se(this.key,"",e);if(n instanceof Map){const s=Se(this.value,r,e);n.set(r,s)}else if(n instanceof Set)n.add(r);else{const s=Rm(this.key,r,e),o=Se(this.value,s,e);s in n?Object.defineProperty(n,s,{value:o,writable:!0,enumerable:!0,configurable:!0}):n[s]=o}return n}toJSON(e,n){const r=n&&n.mapAsMap?new Map:{};return this.addToJSMap(n,r)}toString(e,n,r){if(!e||!e.doc)return JSON.stringify(this);const{indent:s,indentSeq:o,simpleKeys:i}=e.doc.options;let{key:a,value:c}=this,u=a instanceof de&&a.comment;if(i){if(u)throw new Error("With simple keys, key nodes cannot have comments");if(a instanceof Q){const k="With simple keys, collection cannot be used as a key value";throw new Error(k)}}let l=!i&&(!a||u||(a instanceof de?a instanceof Q||a.type===_.BLOCK_FOLDED||a.type===_.BLOCK_LITERAL:typeof a=="object"));const{doc:f,indent:m,indentStep:p,stringify:d}=e;e=Object.assign({},e,{implicitKey:!l,indent:m+p});let v=!1,g=d(a,e,()=>u=null,()=>v=!0);if(g=It(g,e.indent,u),!l&&g.length>1024){if(i)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");l=!0}if(e.allNullValues&&!i)return this.comment?(g=It(g,e.indent,this.comment),n&&n()):v&&!u&&r&&r(),e.inFlow&&!l?g:`? ${g}`;g=l?`? ${g}
119
- ${m}:`:`${g}:`,this.comment&&(g=It(g,e.indent,this.comment),n&&n());let y="",$=null;if(c instanceof de){if(c.spaceBefore&&(y=`
120
- `),c.commentBefore){const k=c.commentBefore.replace(/^/gm,`${e.indent}#`);y+=`
121
- ${k}`}$=c.comment}else c&&typeof c=="object"&&(c=f.schema.createNode(c,!0));e.implicitKey=!1,!l&&!this.comment&&c instanceof G&&(e.indentAtStart=g.length+1),v=!1,!o&&s>=2&&!e.inFlow&&!l&&c instanceof Pe&&c.type!==_.FLOW_SEQ&&!c.tag&&!f.anchors.getName(c)&&(e.indent=e.indent.substr(2));const S=d(c,e,()=>$=null,()=>v=!0);let N=" ";return y||this.comment?N=`${y}
122
- ${e.indent}`:!l&&c instanceof Q?(!(S[0]==="["||S[0]==="{")||S.includes(`
123
- `))&&(N=`
124
- ${e.indent}`):S[0]===`
125
- `&&(N=""),v&&!$&&r&&r(),It(g+N+S,e.indent,$)}}ue(V,"Type",{PAIR:"PAIR",MERGE_PAIR:"MERGE_PAIR"});const Un=(t,e)=>{if(t instanceof Oe){const n=e.get(t.source);return n.count*n.aliasCount}else if(t instanceof Q){let n=0;for(const r of t.items){const s=Un(r,e);s>n&&(n=s)}return n}else if(t instanceof V){const n=Un(t.key,e),r=Un(t.value,e);return Math.max(n,r)}return 1};class Oe extends de{static stringify({range:e,source:n},{anchors:r,doc:s,implicitKey:o,inStringifyKey:i}){let a=Object.keys(r).find(u=>r[u]===n);if(!a&&i&&(a=s.anchors.getName(n)||s.anchors.newName()),a)return`*${a}${o?" ":""}`;const c=s.anchors.getName(n)?"Alias node must be after source node":"Source node not found for alias node";throw new Error(`${c} [${e}]`)}constructor(e){super(),this.source=e,this.type=_.ALIAS}set tag(e){throw new Error("Alias nodes cannot have tags")}toJSON(e,n){if(!n)return Se(this.source,e,n);const{anchors:r,maxAliasCount:s}=n,o=r.get(this.source);if(!o||o.res===void 0){const i="This should not happen: Alias anchor was not resolved?";throw this.cstNode?new ln(this.cstNode,i):new ReferenceError(i)}if(s>=0&&(o.count+=1,o.aliasCount===0&&(o.aliasCount=Un(this.source,r)),o.count*o.aliasCount>s)){const i="Excessive alias count indicates a resource exhaustion attack";throw this.cstNode?new ln(this.cstNode,i):new ReferenceError(i)}return o.res}toString(e){return Oe.stringify(this,e)}}ue(Oe,"default",!0);function ft(t,e){const n=e instanceof G?e.value:e;for(const r of t)if(r instanceof V&&(r.key===e||r.key===n||r.key&&r.key.value===n))return r}class pe extends Q{add(e,n){e?e instanceof V||(e=new V(e.key||e,e.value)):e=new V(e);const r=ft(this.items,e.key),s=this.schema&&this.schema.sortMapEntries;if(r)if(n)r.value=e.value;else throw new Error(`Key ${e.key} already set`);else if(s){const o=this.items.findIndex(i=>s(e,i)<0);o===-1?this.items.push(e):this.items.splice(o,0,e)}else this.items.push(e)}delete(e){const n=ft(this.items,e);return n?this.items.splice(this.items.indexOf(n),1).length>0:!1}get(e,n){const r=ft(this.items,e),s=r&&r.value;return!n&&s instanceof G?s.value:s}has(e){return!!ft(this.items,e)}set(e,n){this.add(new V(e,n),!0)}toJSON(e,n,r){const s=r?new r:n&&n.mapAsMap?new Map:{};n&&n.onCreate&&n.onCreate(s);for(const o of this.items)o.addToJSMap(n,s);return s}toString(e,n,r){if(!e)return JSON.stringify(this);for(const s of this.items)if(!(s instanceof V))throw new Error(`Map items must all be pairs; found ${JSON.stringify(s)} instead`);return super.toString(e,{blockItem:s=>s.str,flowChars:{start:"{",end:"}"},isMap:!0,itemIndent:e.indent||""},n,r)}}const $u="<<";class wu extends V{constructor(e){if(e instanceof V){let n=e.value;n instanceof Pe||(n=new Pe,n.items.push(e.value),n.range=e.value.range),super(e.key,n),this.range=e.range}else super(new G($u),new Pe);this.type=V.Type.MERGE_PAIR}addToJSMap(e,n){for(const{source:r}of this.value.items){if(!(r instanceof pe))throw new Error("Merge sources must be maps");const s=r.toJSON(null,e,Map);for(const[o,i]of s)n instanceof Map?n.has(o)||n.set(o,i):n instanceof Set?n.add(o):Object.prototype.hasOwnProperty.call(n,o)||Object.defineProperty(n,o,{value:i,writable:!0,enumerable:!0,configurable:!0})}return n}toString(e,n){const r=this.value;if(r.items.length>1)return super.toString(e,n);this.value=r.items[0];const s=super.toString(e,n);return this.value=r,s}}const nn={defaultType:_.BLOCK_LITERAL,lineWidth:76},Me={trueStr:"true",falseStr:"false"},Xe={asBigInt:!1},xt={nullStr:"null"},Ue={defaultType:_.PLAIN,doubleQuoted:{jsonEncoding:!1,minMultiLineLength:40},fold:{lineWidth:80,minContentWidth:20}};function io(t,e,n){for(const{format:r,test:s,resolve:o}of e)if(s){const i=t.match(s);if(i){let a=o.apply(null,i);return a instanceof G||(a=new G(a)),r&&(a.format=r),a}}return n&&(t=n(t)),new G(t)}const bu="flow",$s="block",Vn="quoted",oa=(t,e)=>{let n=t[e+1];for(;n===" "||n===" ";){do n=t[e+=1];while(n&&n!==`
126
- `);n=t[e+1]}return e};function cr(t,e,n,{indentAtStart:r,lineWidth:s=80,minContentWidth:o=20,onFold:i,onOverflow:a}){if(!s||s<0)return t;const c=Math.max(1+o,1+s-e.length);if(t.length<=c)return t;const u=[],l={};let f=s-e.length;typeof r=="number"&&(r>s-Math.max(2,o)?u.push(0):f=s-r);let m,p,d=!1,v=-1,g=-1,y=-1;n===$s&&(v=oa(t,v),v!==-1&&(f=v+c));for(let S;S=t[v+=1];){if(n===Vn&&S==="\\"){switch(g=v,t[v+1]){case"x":v+=3;break;case"u":v+=5;break;case"U":v+=9;break;default:v+=1}y=v}if(S===`
127
- `)n===$s&&(v=oa(t,v)),f=v+c,m=void 0;else{if(S===" "&&p&&p!==" "&&p!==`
128
- `&&p!==" "){const N=t[v+1];N&&N!==" "&&N!==`
129
- `&&N!==" "&&(m=v)}if(v>=f)if(m)u.push(m),f=m+c,m=void 0;else if(n===Vn){for(;p===" "||p===" ";)p=S,S=t[v+=1],d=!0;const N=v>y+1?v-2:g-1;if(l[N])return t;u.push(N),l[N]=!0,f=N+c,m=void 0}else d=!0}p=S}if(d&&a&&a(),u.length===0)return t;i&&i();let $=t.slice(0,u[0]);for(let S=0;S<u.length;++S){const N=u[S],k=u[S+1]||t.length;N===0?$=`
130
- ${e}${t.slice(0,k)}`:(n===Vn&&l[N]&&($+=`${t[N]}\\`),$+=`
131
- ${e}${t.slice(N+1,k)}`)}return $}const ao=({indentAtStart:t})=>t?Object.assign({indentAtStart:t},Ue.fold):Ue.fold,ur=t=>/^(%|---|\.\.\.)/m.test(t);function Mm(t,e,n){if(!e||e<0)return!1;const r=e-n,s=t.length;if(s<=r)return!1;for(let o=0,i=0;o<s;++o)if(t[o]===`
132
- `){if(o-i>r)return!0;if(i=o+1,s-i<=r)return!1}return!0}function dt(t,e){const{implicitKey:n}=e,{jsonEncoding:r,minMultiLineLength:s}=Ue.doubleQuoted,o=JSON.stringify(t);if(r)return o;const i=e.indent||(ur(t)?" ":"");let a="",c=0;for(let u=0,l=o[u];l;l=o[++u])if(l===" "&&o[u+1]==="\\"&&o[u+2]==="n"&&(a+=o.slice(c,u)+"\\ ",u+=1,c=u,l="\\"),l==="\\")switch(o[u+1]){case"u":{a+=o.slice(c,u);const f=o.substr(u+2,4);switch(f){case"0000":a+="\\0";break;case"0007":a+="\\a";break;case"000b":a+="\\v";break;case"001b":a+="\\e";break;case"0085":a+="\\N";break;case"00a0":a+="\\_";break;case"2028":a+="\\L";break;case"2029":a+="\\P";break;default:f.substr(0,2)==="00"?a+="\\x"+f.substr(2):a+=o.substr(u,6)}u+=5,c=u+1}break;case"n":if(n||o[u+2]==='"'||o.length<s)u+=1;else{for(a+=o.slice(c,u)+`
133
-
134
- `;o[u+2]==="\\"&&o[u+3]==="n"&&o[u+4]!=='"';)a+=`
135
- `,u+=2;a+=i,o[u+2]===" "&&(a+="\\"),u+=1,c=u+1}break;default:u+=1}return a=c?a+o.slice(c):o,n?a:cr(a,i,Vn,ao(e))}function Eu(t,e){if(e.implicitKey){if(/\n/.test(t))return dt(t,e)}else if(/[ \t]\n|\n[ \t]/.test(t))return dt(t,e);const n=e.indent||(ur(t)?" ":""),r="'"+t.replace(/'/g,"''").replace(/\n+/g,`$&
136
- ${n}`)+"'";return e.implicitKey?r:cr(r,n,bu,ao(e))}function Fn({comment:t,type:e,value:n},r,s,o){if(/\n[\t ]+$/.test(n)||/^\s*$/.test(n))return dt(n,r);const i=r.indent||(r.forceBlockIndent||ur(n)?" ":""),a=i?"2":"1",c=e===_.BLOCK_FOLDED?!1:e===_.BLOCK_LITERAL?!0:!Mm(n,Ue.fold.lineWidth,i.length);let u=c?"|":">";if(!n)return u+`
137
- `;let l="",f="";if(n=n.replace(/[\n\t ]*$/,p=>{const d=p.indexOf(`
138
- `);return d===-1?u+="-":(n===p||d!==p.length-1)&&(u+="+",o&&o()),f=p.replace(/\n$/,""),""}).replace(/^[\n ]*/,p=>{p.indexOf(" ")!==-1&&(u+=a);const d=p.match(/ +$/);return d?(l=p.slice(0,-d[0].length),d[0]):(l=p,"")}),f&&(f=f.replace(/\n+(?!\n|$)/g,`$&${i}`)),l&&(l=l.replace(/\n+/g,`$&${i}`)),t&&(u+=" #"+t.replace(/ ?[\r\n]+/g," "),s&&s()),!n)return`${u}${a}
139
- ${i}${f}`;if(c)return n=n.replace(/\n+/g,`$&${i}`),`${u}
140
- ${i}${l}${n}${f}`;n=n.replace(/\n+/g,`
141
- $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${i}`);const m=cr(`${l}${n}${f}`,i,$s,Ue.fold);return`${u}
142
- ${i}${m}`}function Dm(t,e,n,r){const{comment:s,type:o,value:i}=t,{actualString:a,implicitKey:c,indent:u,inFlow:l}=e;if(c&&/[\n[\]{},]/.test(i)||l&&/[[\]{},]/.test(i))return dt(i,e);if(!i||/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(i))return c||l||i.indexOf(`
143
- `)===-1?i.indexOf('"')!==-1&&i.indexOf("'")===-1?Eu(i,e):dt(i,e):Fn(t,e,n,r);if(!c&&!l&&o!==_.PLAIN&&i.indexOf(`
144
- `)!==-1)return Fn(t,e,n,r);if(u===""&&ur(i))return e.forceBlockIndent=!0,Fn(t,e,n,r);const f=i.replace(/\n+/g,`$&
145
- ${u}`);if(a){const{tags:p}=e.doc.schema;if(typeof io(f,p,p.scalarFallback).value!="string")return dt(i,e)}const m=c?f:cr(f,u,bu,ao(e));return s&&!l&&(m.indexOf(`
146
- `)!==-1||s.indexOf(`
147
- `)!==-1)?(n&&n(),Cm(m,u,s)):m}function co(t,e,n,r){const{defaultType:s}=Ue,{implicitKey:o,inFlow:i}=e;let{type:a,value:c}=t;typeof c!="string"&&(c=String(c),t=Object.assign({},t,{value:c}));const u=f=>{switch(f){case _.BLOCK_FOLDED:case _.BLOCK_LITERAL:return Fn(t,e,n,r);case _.QUOTE_DOUBLE:return dt(c,e);case _.QUOTE_SINGLE:return Eu(c,e);case _.PLAIN:return Dm(t,e,n,r);default:return null}};(a!==_.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f]/.test(c)||(o||i)&&(a===_.BLOCK_FOLDED||a===_.BLOCK_LITERAL))&&(a=_.QUOTE_DOUBLE);let l=u(a);if(l===null&&(l=u(s),l===null))throw new Error(`Unsupported default string type ${s}`);return l}function De({format:t,minFractionDigits:e,tag:n,value:r}){if(typeof r=="bigint")return String(r);if(!isFinite(r))return isNaN(r)?".nan":r<0?"-.inf":".inf";let s=JSON.stringify(r);if(!t&&e&&(!n||n==="tag:yaml.org,2002:float")&&/^\d/.test(s)){let o=s.indexOf(".");o<0&&(o=s.length,s+=".");let i=e-(s.length-o-1);for(;i-- >0;)s+="0"}return s}function Su(t,e){let n,r;switch(e.type){case _.FLOW_MAP:n="}",r="flow map";break;case _.FLOW_SEQ:n="]",r="flow sequence";break;default:t.push(new D(e,"Not a flow collection!?"));return}let s;for(let o=e.items.length-1;o>=0;--o){const i=e.items[o];if(!i||i.type!==_.COMMENT){s=i;break}}if(s&&s.char!==n){const o=`Expected ${r} to end with ${n}`;let i;typeof s.offset=="number"?(i=new D(e,o),i.offset=s.offset+1):(i=new D(s,o),s.range&&s.range.end&&(i.offset=s.range.end-s.range.start)),t.push(i)}}function Nu(t,e){const n=e.context.src[e.range.start-1];if(n!==`
148
- `&&n!==" "&&n!==" "){const r="Comments must be separated from other tokens by white space characters";t.push(new D(e,r))}}function Ou(t,e){const n=String(e),r=n.substr(0,8)+"..."+n.substr(-8);return new D(t,`The "${r}" key is too long`)}function _u(t,e){for(const{afterKey:n,before:r,comment:s}of e){let o=t.items[r];o?(n&&o.value&&(o=o.value),s===void 0?(n||!o.commentBefore)&&(o.spaceBefore=!0):o.commentBefore?o.commentBefore+=`
149
- `+s:o.commentBefore=s):s!==void 0&&(t.comment?t.comment+=`
150
- `+s:t.comment=s)}}function gn(t,e){const n=e.strValue;return n?typeof n=="string"?n:(n.errors.forEach(r=>{r.source||(r.source=e),t.errors.push(r)}),n.str):""}function Lm(t,e){const{handle:n,suffix:r}=e.tag;let s=t.tagPrefixes.find(o=>o.handle===n);if(!s){const o=t.getDefaults().tagPrefixes;if(o&&(s=o.find(i=>i.handle===n)),!s)throw new D(e,`The ${n} tag handle is non-default and was not declared.`)}if(!r)throw new D(e,`The ${n} tag has no suffix.`);if(n==="!"&&(t.version||t.options.version)==="1.0"){if(r[0]==="^")return t.warnings.push(new Dt(e,"YAML 1.0 ^ tag expansion is not supported")),r;if(/[:/]/.test(r)){const o=r.match(/^([a-z0-9-]+)\/(.*)/i);return o?`tag:${o[1]}.yaml.org,2002:${o[2]}`:`tag:${r}`}}return s.prefix+decodeURIComponent(r)}function Bm(t,e){const{tag:n,type:r}=e;let s=!1;if(n){const{handle:o,suffix:i,verbatim:a}=n;if(a){if(a!=="!"&&a!=="!!")return a;const c=`Verbatim tags aren't resolved, so ${a} is invalid.`;t.errors.push(new D(e,c))}else if(o==="!"&&!i)s=!0;else try{return Lm(t,e)}catch(c){t.errors.push(c)}}switch(r){case _.BLOCK_FOLDED:case _.BLOCK_LITERAL:case _.QUOTE_DOUBLE:case _.QUOTE_SINGLE:return He.STR;case _.FLOW_MAP:case _.MAP:return He.MAP;case _.FLOW_SEQ:case _.SEQ:return He.SEQ;case _.PLAIN:return s?He.STR:null;default:return null}}function ia(t,e,n){const{tags:r}=t.schema,s=[];for(const i of r)if(i.tag===n)if(i.test)s.push(i);else{const a=i.resolve(t,e);return a instanceof Q?a:new G(a)}const o=gn(t,e);return typeof o=="string"&&s.length>0?io(o,s,r.scalarFallback):null}function Um({type:t}){switch(t){case _.FLOW_MAP:case _.MAP:return He.MAP;case _.FLOW_SEQ:case _.SEQ:return He.SEQ;default:return He.STR}}function Vm(t,e,n){try{const r=ia(t,e,n);if(r)return n&&e.tag&&(r.tag=n),r}catch(r){if(r instanceof pt)r.source||(r.source=e),t.errors.push(r);else{const s=r instanceof Error?r.message:String(r);t.errors.push(new D(e,s))}return null}try{const r=Um(e);if(!r)throw new Error(`The tag ${n} is unavailable`);const s=`The tag ${n} is unavailable, falling back to ${r}`;t.warnings.push(new Dt(e,s));const o=ia(t,e,r);return o.tag=n,o}catch(r){const s=new ln(e,r.message);return s.stack=r.stack,t.errors.push(s),null}}const Fm=t=>{if(!t)return!1;const{type:e}=t;return e===_.MAP_KEY||e===_.MAP_VALUE||e===_.SEQ_ITEM};function qm(t,e){const n={before:[],after:[]};let r=!1,s=!1;const o=Fm(e.context.parent)?e.context.parent.props.concat(e.props):e.props;for(const{start:i,end:a}of o)switch(e.context.src[i]){case Z.COMMENT:{if(!e.commentHasRequiredWhitespace(i)){const l="Comments must be separated from other tokens by white space characters";t.push(new D(e,l))}const{header:c,valueRange:u}=e;(u&&(i>u.start||c&&i>c.start)?n.after:n.before).push(e.context.src.slice(i+1,a));break}case Z.ANCHOR:if(r){const c="A node can have at most one anchor";t.push(new D(e,c))}r=!0;break;case Z.TAG:if(s){const c="A node can have at most one tag";t.push(new D(e,c))}s=!0;break}return{comments:n,hasAnchor:r,hasTag:s}}function Km(t,e){const{anchors:n,errors:r,schema:s}=t;if(e.type===_.ALIAS){const i=e.rawValue,a=n.getNode(i);if(!a){const u=`Aliased anchor not found: ${i}`;return r.push(new ln(e,u)),null}const c=new Oe(a);return n._cstAliases.push(c),c}const o=Bm(t,e);if(o)return Vm(t,e,o);if(e.type!==_.PLAIN){const i=`Failed to resolve ${e.type} node here`;return r.push(new ie(e,i)),null}try{const i=gn(t,e);return io(i,s.tags,s.tags.scalarFallback)}catch(i){return i.source||(i.source=e),r.push(i),null}}function Qe(t,e){if(!e)return null;e.error&&t.errors.push(e.error);const{comments:n,hasAnchor:r,hasTag:s}=qm(t.errors,e);if(r){const{anchors:i}=t,a=e.anchor,c=i.getNode(a);c&&(i.map[i.newName(a)]=c),i.map[a]=e}if(e.type===_.ALIAS&&(r||s)){const i="An alias node must not specify any properties";t.errors.push(new D(e,i))}const o=Km(t,e);if(o){o.range=[e.range.start,e.range.end],t.options.keepCstNodes&&(o.cstNode=e),t.options.keepNodeTypes&&(o.type=e.type);const i=n.before.join(`
151
- `);i&&(o.commentBefore=o.commentBefore?`${o.commentBefore}
152
- ${i}`:i);const a=n.after.join(`
153
- `);a&&(o.comment=o.comment?`${o.comment}
154
- ${a}`:a)}return e.resolved=o}function ku(t,e){if(e.type!==_.MAP&&e.type!==_.FLOW_MAP){const i=`A ${e.type} node cannot be resolved as a mapping`;return t.errors.push(new ie(e,i)),null}const{comments:n,items:r}=e.type===_.FLOW_MAP?Hm(t,e):Wm(t,e),s=new pe;s.items=r,_u(s,n);let o=!1;for(let i=0;i<r.length;++i){const{key:a}=r[i];if(a instanceof Q&&(o=!0),t.schema.merge&&a&&a.value===$u){r[i]=new wu(r[i]);const c=r[i].value.items;let u=null;c.some(l=>{if(l instanceof Oe){const{type:f}=l.source;return f===_.MAP||f===_.FLOW_MAP?!1:u="Merge nodes aliases can only point to maps"}return u="Merge nodes can only have Alias nodes as values"}),u&&t.errors.push(new D(e,u))}else for(let c=i+1;c<r.length;++c){const{key:u}=r[c];if(a===u||a&&u&&Object.prototype.hasOwnProperty.call(a,"value")&&a.value===u.value){const l=`Map keys must be unique; "${a}" is repeated`;t.errors.push(new D(e,l));break}}}if(o&&!t.options.mapAsMap){const i="Keys with collection values will be stringified as YAML due to JS Object restrictions. Use mapAsMap: true to avoid this.";t.warnings.push(new Dt(e,i))}return e.resolved=s,s}const zm=({context:{lineStart:t,node:e,src:n},props:r})=>{if(r.length===0)return!1;const{start:s}=r[0];if(e&&s>e.valueRange.start||n[s]!==Z.COMMENT)return!1;for(let o=t;o<s;++o)if(n[o]===`
155
- `)return!1;return!0};function Gm(t,e){if(!zm(t))return;const n=t.getPropValue(0,Z.COMMENT,!0);let r=!1;const s=e.value.commentBefore;if(s&&s.startsWith(n))e.value.commentBefore=s.substr(n.length+1),r=!0;else{const o=e.value.comment;!t.node&&o&&o.startsWith(n)&&(e.value.comment=o.substr(n.length+1),r=!0)}r&&(e.comment=n)}function Wm(t,e){const n=[],r=[];let s,o=null;for(let i=0;i<e.items.length;++i){const a=e.items[i];switch(a.type){case _.BLANK_LINE:n.push({afterKey:!!s,before:r.length});break;case _.COMMENT:n.push({afterKey:!!s,before:r.length,comment:a.comment});break;case _.MAP_KEY:s!==void 0&&r.push(new V(s)),a.error&&t.errors.push(a.error),s=Qe(t,a.node),o=null;break;case _.MAP_VALUE:{if(s===void 0&&(s=null),a.error&&t.errors.push(a.error),!a.context.atLineStart&&a.node&&a.node.type===_.MAP&&!a.node.context.atLineStart){const l="Nested mappings are not allowed in compact mappings";t.errors.push(new D(a.node,l))}let c=a.node;if(!c&&a.props.length>0){c=new fn(_.PLAIN,[]),c.context={parent:a,src:a.context.src};const l=a.range.start+1;if(c.range={start:l,end:l},c.valueRange={start:l,end:l},typeof a.range.origStart=="number"){const f=a.range.origStart+1;c.range.origStart=c.range.origEnd=f,c.valueRange.origStart=c.valueRange.origEnd=f}}const u=new V(s,Qe(t,c));Gm(a,u),r.push(u),s&&typeof o=="number"&&a.range.start>o+1024&&t.errors.push(Ou(e,s)),s=void 0,o=null}break;default:s!==void 0&&r.push(new V(s)),s=Qe(t,a),o=a.range.start,a.error&&t.errors.push(a.error);e:for(let c=i+1;;++c){const u=e.items[c];switch(u&&u.type){case _.BLANK_LINE:case _.COMMENT:continue e;case _.MAP_VALUE:break e;default:{const l="Implicit map keys need to be followed by map values";t.errors.push(new D(a,l));break e}}}if(a.valueRangeContainsNewline){const c="Implicit map keys need to be on a single line";t.errors.push(new D(a,c))}}}return s!==void 0&&r.push(new V(s)),{comments:n,items:r}}function Hm(t,e){const n=[],r=[];let s,o=!1,i="{";for(let a=0;a<e.items.length;++a){const c=e.items[a];if(typeof c.char=="string"){const{char:u,offset:l}=c;if(u==="?"&&s===void 0&&!o){o=!0,i=":";continue}if(u===":"){if(s===void 0&&(s=null),i===":"){i=",";continue}}else if(o&&(s===void 0&&u!==","&&(s=null),o=!1),s!==void 0&&(r.push(new V(s)),s=void 0,u===",")){i=":";continue}if(u==="}"){if(a===e.items.length-1)continue}else if(u===i){i=":";continue}const f=`Flow map contains an unexpected ${u}`,m=new ie(e,f);m.offset=l,t.errors.push(m)}else c.type===_.BLANK_LINE?n.push({afterKey:!!s,before:r.length}):c.type===_.COMMENT?(Nu(t.errors,c),n.push({afterKey:!!s,before:r.length,comment:c.comment})):s===void 0?(i===","&&t.errors.push(new D(c,"Separator , missing in flow map")),s=Qe(t,c)):(i!==","&&t.errors.push(new D(c,"Indicator : missing in flow map entry")),r.push(new V(s,Qe(t,c))),s=void 0,o=!1)}return Su(t.errors,e),s!==void 0&&r.push(new V(s)),{comments:n,items:r}}function Iu(t,e){if(e.type!==_.SEQ&&e.type!==_.FLOW_SEQ){const o=`A ${e.type} node cannot be resolved as a sequence`;return t.errors.push(new ie(e,o)),null}const{comments:n,items:r}=e.type===_.FLOW_SEQ?Qm(t,e):Jm(t,e),s=new Pe;if(s.items=r,_u(s,n),!t.options.mapAsMap&&r.some(o=>o instanceof V&&o.key instanceof Q)){const o="Keys with collection values will be stringified as YAML due to JS Object restrictions. Use mapAsMap: true to avoid this.";t.warnings.push(new Dt(e,o))}return e.resolved=s,s}function Jm(t,e){const n=[],r=[];for(let s=0;s<e.items.length;++s){const o=e.items[s];switch(o.type){case _.BLANK_LINE:n.push({before:r.length});break;case _.COMMENT:n.push({comment:o.comment,before:r.length});break;case _.SEQ_ITEM:if(o.error&&t.errors.push(o.error),r.push(Qe(t,o.node)),o.hasProps){const i="Sequence items cannot have tags or anchors before the - indicator";t.errors.push(new D(o,i))}break;default:o.error&&t.errors.push(o.error),t.errors.push(new ie(o,`Unexpected ${o.type} node in sequence`))}}return{comments:n,items:r}}function Qm(t,e){const n=[],r=[];let s=!1,o,i=null,a="[",c=null;for(let u=0;u<e.items.length;++u){const l=e.items[u];if(typeof l.char=="string"){const{char:f,offset:m}=l;if(f!==":"&&(s||o!==void 0)&&(s&&o===void 0&&(o=a?r.pop():null),r.push(new V(o)),s=!1,o=void 0,i=null),f===a)a=null;else if(!a&&f==="?")s=!0;else if(a!=="["&&f===":"&&o===void 0){if(a===","){if(o=r.pop(),o instanceof V){const p="Chaining flow sequence pairs is invalid",d=new D(e,p);d.offset=m,t.errors.push(d)}if(!s&&typeof i=="number"){const p=l.range?l.range.start:l.offset;p>i+1024&&t.errors.push(Ou(e,o));const{src:d}=c.context;for(let v=i;v<p;++v)if(d[v]===`
156
- `){const g="Implicit keys of flow sequence pairs need to be on a single line";t.errors.push(new D(c,g));break}}}else o=null;i=null,s=!1,a=null}else if(a==="["||f!=="]"||u<e.items.length-1){const p=`Flow sequence contains an unexpected ${f}`,d=new ie(e,p);d.offset=m,t.errors.push(d)}}else if(l.type===_.BLANK_LINE)n.push({before:r.length});else if(l.type===_.COMMENT)Nu(t.errors,l),n.push({comment:l.comment,before:r.length});else{if(a){const m=`Expected a ${a} in flow sequence`;t.errors.push(new D(l,m))}const f=Qe(t,l);o===void 0?(r.push(f),c=l):(r.push(new V(o,f)),o=void 0),i=l.range.start,a=","}}return Su(t.errors,e),o!==void 0&&r.push(new V(o)),{comments:n,items:r}}const Au={identify:t=>t instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve:(t,e)=>{const n=gn(t,e);if(typeof Buffer=="function")return Buffer.from(n,"base64");if(typeof atob=="function"){const r=atob(n.replace(/[\n\r]/g,"")),s=new Uint8Array(r.length);for(let o=0;o<r.length;++o)s[o]=r.charCodeAt(o);return s}else{const r="This environment does not support reading binary tags; either Buffer or atob is required";return t.errors.push(new ln(e,r)),null}},options:nn,stringify:({comment:t,type:e,value:n},r,s,o)=>{let i;if(typeof Buffer=="function")i=n instanceof Buffer?n.toString("base64"):Buffer.from(n.buffer).toString("base64");else if(typeof btoa=="function"){let a="";for(let c=0;c<n.length;++c)a+=String.fromCharCode(n[c]);i=btoa(a)}else throw new Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(e||(e=nn.defaultType),e===_.QUOTE_DOUBLE)n=i;else{const{lineWidth:a}=nn,c=Math.ceil(i.length/a),u=new Array(c);for(let l=0,f=0;l<c;++l,f+=a)u[l]=i.substr(f,a);n=u.join(e===_.BLOCK_LITERAL?`
157
- `:" ")}return co({comment:t,type:e,value:n},r,s,o)}};function Pu(t,e){const n=Iu(t,e);for(let r=0;r<n.items.length;++r){let s=n.items[r];if(!(s instanceof V)){if(s instanceof pe){if(s.items.length>1){const i="Each pair must have its own sequence indicator";throw new D(e,i)}const o=s.items[0]||new V;s.commentBefore&&(o.commentBefore=o.commentBefore?`${s.commentBefore}
158
- ${o.commentBefore}`:s.commentBefore),s.comment&&(o.comment=o.comment?`${s.comment}
159
- ${o.comment}`:s.comment),s=o}n.items[r]=s instanceof V?s:new V(s)}}return n}function ju(t,e,n){const r=new Pe(t);r.tag="tag:yaml.org,2002:pairs";for(const s of e){let o,i;if(Array.isArray(s))if(s.length===2)o=s[0],i=s[1];else throw new TypeError(`Expected [key, value] tuple: ${s}`);else if(s&&s instanceof Object){const c=Object.keys(s);if(c.length===1)o=c[0],i=s[o];else throw new TypeError(`Expected { key: value } tuple: ${s}`)}else o=s;const a=t.createPair(o,i,n);r.items.push(a)}return r}const xu={default:!1,tag:"tag:yaml.org,2002:pairs",resolve:Pu,createNode:ju};class Lt extends Pe{constructor(){super(),ue(this,"add",pe.prototype.add.bind(this)),ue(this,"delete",pe.prototype.delete.bind(this)),ue(this,"get",pe.prototype.get.bind(this)),ue(this,"has",pe.prototype.has.bind(this)),ue(this,"set",pe.prototype.set.bind(this)),this.tag=Lt.tag}toJSON(e,n){const r=new Map;n&&n.onCreate&&n.onCreate(r);for(const s of this.items){let o,i;if(s instanceof V?(o=Se(s.key,"",n),i=Se(s.value,o,n)):o=Se(s,"",n),r.has(o))throw new Error("Ordered maps must not include duplicate keys");r.set(o,i)}return r}}ue(Lt,"tag","tag:yaml.org,2002:omap");function Ym(t,e){const n=Pu(t,e),r=[];for(const{key:s}of n.items)if(s instanceof G)if(r.includes(s.value)){const o="Ordered maps must not include duplicate keys";throw new D(e,o)}else r.push(s.value);return Object.assign(new Lt,n)}function Xm(t,e,n){const r=ju(t,e,n),s=new Lt;return s.items=r.items,s}const Tu={identify:t=>t instanceof Map,nodeClass:Lt,default:!1,tag:"tag:yaml.org,2002:omap",resolve:Ym,createNode:Xm};class Bt extends pe{constructor(){super(),this.tag=Bt.tag}add(e){const n=e instanceof V?e:new V(e);ft(this.items,n.key)||this.items.push(n)}get(e,n){const r=ft(this.items,e);return!n&&r instanceof V?r.key instanceof G?r.key.value:r.key:r}set(e,n){if(typeof n!="boolean")throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof n}`);const r=ft(this.items,e);r&&!n?this.items.splice(this.items.indexOf(r),1):!r&&n&&this.items.push(new V(e))}toJSON(e,n){return super.toJSON(e,n,Set)}toString(e,n,r){if(!e)return JSON.stringify(this);if(this.hasAllNullValues())return super.toString(e,n,r);throw new Error("Set items must all have null values")}}ue(Bt,"tag","tag:yaml.org,2002:set");function Zm(t,e){const n=ku(t,e);if(!n.hasAllNullValues())throw new D(e,"Set items must all have null values");return Object.assign(new Bt,n)}function eg(t,e,n){const r=new Bt;for(const s of e)r.items.push(t.createPair(s,null,n));return r}const Cu={identify:t=>t instanceof Set,nodeClass:Bt,default:!1,tag:"tag:yaml.org,2002:set",resolve:Zm,createNode:eg},uo=(t,e)=>{const n=e.split(":").reduce((r,s)=>r*60+Number(s),0);return t==="-"?-n:n},Ru=({value:t})=>{if(isNaN(t)||!isFinite(t))return De(t);let e="";t<0&&(e="-",t=Math.abs(t));const n=[t%60];return t<60?n.unshift(0):(t=Math.round((t-n[0])/60),n.unshift(t%60),t>=60&&(t=Math.round((t-n[0])/60),n.unshift(t))),e+n.map(r=>r<10?"0"+String(r):String(r)).join(":").replace(/000000\d*$/,"")},Mu={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^([-+]?)([0-9][0-9_]*(?::[0-5]?[0-9])+)$/,resolve:(t,e,n)=>uo(e,n.replace(/_/g,"")),stringify:Ru},Du={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^([-+]?)([0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*)$/,resolve:(t,e,n)=>uo(e,n.replace(/_/g,"")),stringify:Ru},Lu={identify:t=>t 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:(t,e,n,r,s,o,i,a,c)=>{a&&(a=(a+"00").substr(1,3));let u=Date.UTC(e,n-1,r,s||0,o||0,i||0,a||0);if(c&&c!=="Z"){let l=uo(c[0],c.slice(1));Math.abs(l)<30&&(l*=60),u-=6e4*l}return new Date(u)},stringify:({value:t})=>t.toISOString().replace(/((T00:00)?:00)?\.000Z$/,"")};function Bu(t){const e=typeof process<"u"&&process.env||{};return t?typeof YAML_SILENCE_DEPRECATION_WARNINGS<"u"?!YAML_SILENCE_DEPRECATION_WARNINGS:!e.YAML_SILENCE_DEPRECATION_WARNINGS:typeof YAML_SILENCE_WARNINGS<"u"?!YAML_SILENCE_WARNINGS:!e.YAML_SILENCE_WARNINGS}function Uu(t,e){if(Bu(!1)){const n=typeof process<"u"&&process.emitWarning;n?n(t,e):console.warn(e?`${e}: ${t}`:t)}}const aa={};function tg(t,e){if(!aa[t]&&Bu(!0)){aa[t]=!0;let n=`The option '${t}' will be removed in a future release`;n+=`, use '${e}' instead.`,Uu(n,"DeprecationWarning")}}function ng(t,e,n){const r=new pe(t);if(e instanceof Map)for(const[s,o]of e)r.items.push(t.createPair(s,o,n));else if(e&&typeof e=="object")for(const s of Object.keys(e))r.items.push(t.createPair(s,e[s],n));return typeof t.sortMapEntries=="function"&&r.items.sort(t.sortMapEntries),r}const pn={createNode:ng,default:!0,nodeClass:pe,tag:"tag:yaml.org,2002:map",resolve:ku};function rg(t,e,n){const r=new Pe(t);if(e&&e[Symbol.iterator])for(const s of e){const o=t.createNode(s,n.wrapScalars,null,n);r.items.push(o)}return r}const lr={createNode:rg,default:!0,nodeClass:Pe,tag:"tag:yaml.org,2002:seq",resolve:Iu},sg={identify:t=>typeof t=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:gn,stringify(t,e,n,r){return e=Object.assign({actualString:!0},e),co(t,e,n,r)},options:Ue},lo=[pn,lr,sg],fr=t=>typeof t=="bigint"||Number.isInteger(t),fo=(t,e,n)=>Xe.asBigInt?BigInt(t):parseInt(e,n);function Vu(t,e,n){const{value:r}=t;return fr(r)&&r>=0?n+r.toString(e):De(t)}const Fu={identify:t=>t==null,createNode:(t,e,n)=>n.wrapScalars?new G(null):null,default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>null,options:xt,stringify:()=>xt.nullStr},qu={identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:t=>t[0]==="t"||t[0]==="T",options:Me,stringify:({value:t})=>t?Me.trueStr:Me.falseStr},Ku={identify:t=>fr(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o([0-7]+)$/,resolve:(t,e)=>fo(t,e,8),options:Xe,stringify:t=>Vu(t,8,"0o")},zu={identify:fr,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:t=>fo(t,t,10),options:Xe,stringify:De},Gu={identify:t=>fr(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x([0-9a-fA-F]+)$/,resolve:(t,e)=>fo(t,e,16),options:Xe,stringify:t=>Vu(t,16,"0x")},Wu={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.inf|(\.nan))$/i,resolve:(t,e)=>e?NaN:t[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:De},Hu={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:t=>parseFloat(t),stringify:({value:t})=>Number(t).toExponential()},Ju={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.([0-9]+)|[0-9]+\.([0-9]*))$/,resolve(t,e,n){const r=e||n,s=new G(parseFloat(t));return r&&r[r.length-1]==="0"&&(s.minFractionDigits=r.length),s},stringify:De},og=lo.concat([Fu,qu,Ku,zu,Gu,Wu,Hu,Ju]),ca=t=>typeof t=="bigint"||Number.isInteger(t),kn=({value:t})=>JSON.stringify(t),Qu=[pn,lr,{identify:t=>typeof t=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:gn,stringify:kn},{identify:t=>t==null,createNode:(t,e,n)=>n.wrapScalars?new G(null):null,default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:kn},{identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true|false$/,resolve:t=>t==="true",stringify:kn},{identify:ca,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:t=>Xe.asBigInt?BigInt(t):parseInt(t,10),stringify:({value:t})=>ca(t)?t.toString():JSON.stringify(t)},{identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:t=>parseFloat(t),stringify:kn}];Qu.scalarFallback=t=>{throw new SyntaxError(`Unresolved plain scalar ${JSON.stringify(t)}`)};const ua=({value:t})=>t?Me.trueStr:Me.falseStr,Yt=t=>typeof t=="bigint"||Number.isInteger(t);function In(t,e,n){let r=e.replace(/_/g,"");if(Xe.asBigInt){switch(n){case 2:r=`0b${r}`;break;case 8:r=`0o${r}`;break;case 16:r=`0x${r}`;break}const o=BigInt(r);return t==="-"?BigInt(-1)*o:o}const s=parseInt(r,n);return t==="-"?-1*s:s}function zr(t,e,n){const{value:r}=t;if(Yt(r)){const s=r.toString(e);return r<0?"-"+n+s.substr(1):n+s}return De(t)}const ig=lo.concat([{identify:t=>t==null,createNode:(t,e,n)=>n.wrapScalars?new G(null):null,default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>null,options:xt,stringify:()=>xt.nullStr},{identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>!0,options:Me,stringify:ua},{identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/i,resolve:()=>!1,options:Me,stringify:ua},{identify:Yt,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^([-+]?)0b([0-1_]+)$/,resolve:(t,e,n)=>In(e,n,2),stringify:t=>zr(t,2,"0b")},{identify:Yt,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^([-+]?)0([0-7_]+)$/,resolve:(t,e,n)=>In(e,n,8),stringify:t=>zr(t,8,"0")},{identify:Yt,default:!0,tag:"tag:yaml.org,2002:int",test:/^([-+]?)([0-9][0-9_]*)$/,resolve:(t,e,n)=>In(e,n,10),stringify:De},{identify:Yt,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^([-+]?)0x([0-9a-fA-F_]+)$/,resolve:(t,e,n)=>In(e,n,16),stringify:t=>zr(t,16,"0x")},{identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.inf|(\.nan))$/i,resolve:(t,e)=>e?NaN:t[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:De},{identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?([0-9][0-9_]*)?(\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:t=>parseFloat(t.replace(/_/g,"")),stringify:({value:t})=>Number(t).toExponential()},{identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.([0-9_]*)$/,resolve(t,e){const n=new G(parseFloat(t.replace(/_/g,"")));if(e){const r=e.replace(/_/g,"");r[r.length-1]==="0"&&(n.minFractionDigits=r.length)}return n},stringify:De}],Au,Tu,xu,Cu,Mu,Du,Lu),ag={core:og,failsafe:lo,json:Qu,yaml11:ig},cg={binary:Au,bool:qu,float:Ju,floatExp:Hu,floatNaN:Wu,floatTime:Du,int:zu,intHex:Gu,intOct:Ku,intTime:Mu,map:pn,null:Fu,omap:Tu,pairs:xu,seq:lr,set:Cu,timestamp:Lu};function ug(t,e,n){if(e){const r=n.filter(o=>o.tag===e),s=r.find(o=>!o.format)||r[0];if(!s)throw new Error(`Tag ${e} not found`);return s}return n.find(r=>(r.identify&&r.identify(t)||r.class&&t instanceof r.class)&&!r.format)}function lg(t,e,n){if(t instanceof de)return t;const{defaultPrefix:r,onTagObj:s,prevObjects:o,schema:i,wrapScalars:a}=n;e&&e.startsWith("!!")&&(e=r+e.slice(2));let c=ug(t,e,i.tags);if(!c){if(typeof t.toJSON=="function"&&(t=t.toJSON()),!t||typeof t!="object")return a?new G(t):t;c=t instanceof Map?pn:t[Symbol.iterator]?lr:pn}s&&(s(c),delete n.onTagObj);const u={value:void 0,node:void 0};if(t&&typeof t=="object"&&o){const l=o.get(t);if(l){const f=new Oe(l);return n.aliasNodes.push(f),f}u.value=t,o.set(t,u)}return u.node=c.createNode?c.createNode(n.schema,t,n):a?new G(t):t,e&&u.node instanceof de&&(u.node.tag=e),u.node}function fg(t,e,n,r){let s=t[r.replace(/\W/g,"")];if(!s){const o=Object.keys(t).map(i=>JSON.stringify(i)).join(", ");throw new Error(`Unknown schema "${r}"; use one of ${o}`)}if(Array.isArray(n))for(const o of n)s=s.concat(o);else typeof n=="function"&&(s=n(s.slice()));for(let o=0;o<s.length;++o){const i=s[o];if(typeof i=="string"){const a=e[i];if(!a){const c=Object.keys(e).map(u=>JSON.stringify(u)).join(", ");throw new Error(`Unknown custom tag "${i}"; use one of ${c}`)}s[o]=a}}return s}const dg=(t,e)=>t.key<e.key?-1:t.key>e.key?1:0;class ht{constructor({customTags:e,merge:n,schema:r,sortMapEntries:s,tags:o}){this.merge=!!n,this.name=r,this.sortMapEntries=s===!0?dg:s||null,!e&&o&&tg("tags","customTags"),this.tags=fg(ag,cg,e||o,r)}createNode(e,n,r,s){const o={defaultPrefix:ht.defaultPrefix,schema:this,wrapScalars:n},i=s?Object.assign(s,o):o;return lg(e,r,i)}createPair(e,n,r){r||(r={wrapScalars:!0});const s=this.createNode(e,r.wrapScalars,null,r),o=this.createNode(n,r.wrapScalars,null,r);return new V(s,o)}}ue(ht,"defaultPrefix",Bn);ue(ht,"defaultTags",He);const Yn={anchorPrefix:"a",customTags:null,indent:2,indentSeq:!0,keepCstNodes:!1,keepNodeTypes:!0,keepBlobsInJSON:!0,mapAsMap:!1,maxAliasCount:100,prettyErrors:!1,simpleKeys:!1,version:"1.2"},pg={get binary(){return nn},set binary(t){Object.assign(nn,t)},get bool(){return Me},set bool(t){Object.assign(Me,t)},get int(){return Xe},set int(t){Object.assign(Xe,t)},get null(){return xt},set null(t){Object.assign(xt,t)},get str(){return Ue},set str(t){Object.assign(Ue,t)}},Yu={"1.0":{schema:"yaml-1.1",merge:!0,tagPrefixes:[{handle:"!",prefix:Bn},{handle:"!!",prefix:"tag:private.yaml.org,2002:"}]},1.1:{schema:"yaml-1.1",merge:!0,tagPrefixes:[{handle:"!",prefix:"!"},{handle:"!!",prefix:Bn}]},1.2:{schema:"core",merge:!1,tagPrefixes:[{handle:"!",prefix:"!"},{handle:"!!",prefix:Bn}]}};function la(t,e){if((t.version||t.options.version)==="1.0"){const s=e.match(/^tag:private\.yaml\.org,2002:([^:/]+)$/);if(s)return"!"+s[1];const o=e.match(/^tag:([a-zA-Z0-9-]+)\.yaml\.org,2002:(.*)/);return o?`!${o[1]}/${o[2]}`:`!${e.replace(/^tag:/,"")}`}let n=t.tagPrefixes.find(s=>e.indexOf(s.prefix)===0);if(!n){const s=t.getDefaults().tagPrefixes;n=s&&s.find(o=>e.indexOf(o.prefix)===0)}if(!n)return e[0]==="!"?e:`!<${e}>`;const r=e.substr(n.prefix.length).replace(/[!,[\]{}]/g,s=>({"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"})[s]);return n.handle+r}function hg(t,e){if(e instanceof Oe)return Oe;if(e.tag){const s=t.filter(o=>o.tag===e.tag);if(s.length>0)return s.find(o=>o.format===e.format)||s[0]}let n,r;if(e instanceof G){r=e.value;const s=t.filter(o=>o.identify&&o.identify(r)||o.class&&r instanceof o.class);n=s.find(o=>o.format===e.format)||s.find(o=>!o.format)}else r=e,n=t.find(s=>s.nodeClass&&r instanceof s.nodeClass);if(!n){const s=r&&r.constructor?r.constructor.name:typeof r;throw new Error(`Tag not resolved for ${s} value`)}return n}function mg(t,e,{anchors:n,doc:r}){const s=[],o=r.anchors.getName(t);return o&&(n[o]=t,s.push(`&${o}`)),t.tag?s.push(la(r,t.tag)):e.default||s.push(la(r,e.tag)),s.join(" ")}function An(t,e,n,r){const{anchors:s,schema:o}=e.doc;let i;if(!(t instanceof de)){const u={aliasNodes:[],onTagObj:l=>i=l,prevObjects:new Map};t=o.createNode(t,!0,null,u);for(const l of u.aliasNodes){l.source=l.source.node;let f=s.getName(l.source);f||(f=s.newName(),s.map[f]=l.source)}}if(t instanceof V)return t.toString(e,n,r);i||(i=hg(o.tags,t));const a=mg(t,i,e);a.length>0&&(e.indentAtStart=(e.indentAtStart||0)+a.length+1);const c=typeof i.stringify=="function"?i.stringify(t,e,n,r):t instanceof G?co(t,e,n,r):t.toString(e,n,r);return a?t instanceof G||c[0]==="{"||c[0]==="["?`${a} ${c}`:`${a}
160
- ${e.indent}${c}`:c}class po{static validAnchorNode(e){return e instanceof G||e instanceof Pe||e instanceof pe}constructor(e){ue(this,"map",Object.create(null)),this.prefix=e}createAlias(e,n){return this.setAnchor(e,n),new Oe(e)}createMergePair(...e){const n=new wu;return n.value.items=e.map(r=>{if(r instanceof Oe){if(r.source instanceof pe)return r}else if(r instanceof pe)return this.createAlias(r);throw new Error("Merge sources must be Map nodes or their Aliases")}),n}getName(e){const{map:n}=this;return Object.keys(n).find(r=>n[r]===e)}getNames(){return Object.keys(this.map)}getNode(e){return this.map[e]}newName(e){e||(e=this.prefix);const n=Object.keys(this.map);for(let r=1;;++r){const s=`${e}${r}`;if(!n.includes(s))return s}}resolveNodes(){const{map:e,_cstAliases:n}=this;Object.keys(e).forEach(r=>{e[r]=e[r].resolved}),n.forEach(r=>{r.source=r.source.resolved}),delete this._cstAliases}setAnchor(e,n){if(e!=null&&!po.validAnchorNode(e))throw new Error("Anchors may only be set for Scalar, Seq and Map nodes");if(n&&/[\x00-\x19\s,[\]{}]/.test(n))throw new Error("Anchor names must not contain whitespace or control characters");const{map:r}=this,s=e&&Object.keys(r).find(o=>r[o]===e);if(s)if(n)s!==n&&(delete r[s],r[n]=e);else return s;else{if(!n){if(!e)return null;n=this.newName()}r[n]=e}return n}}const qn=(t,e)=>{if(t&&typeof t=="object"){const{tag:n}=t;t instanceof Q?(n&&(e[n]=!0),t.items.forEach(r=>qn(r,e))):t instanceof V?(qn(t.key,e),qn(t.value,e)):t instanceof G&&n&&(e[n]=!0)}return e},gg=t=>Object.keys(qn(t,{}));function yg(t,e){const n={before:[],after:[]};let r,s=!1;for(const o of e)if(o.valueRange){if(r!==void 0){const a="Document contains trailing content not separated by a ... or --- line";t.errors.push(new ie(o,a));break}const i=Qe(t,o);s&&(i.spaceBefore=!0,s=!1),r=i}else o.comment!==null?(r===void 0?n.before:n.after).push(o.comment):o.type===_.BLANK_LINE&&(s=!0,r===void 0&&n.before.length>0&&!t.commentBefore&&(t.commentBefore=n.before.join(`
161
- `),n.before=[]));if(t.contents=r||null,!r)t.comment=n.before.concat(n.after).join(`
162
- `)||null;else{const o=n.before.join(`
163
- `);if(o){const i=r instanceof Q&&r.items[0]?r.items[0]:r;i.commentBefore=i.commentBefore?`${o}
164
- ${i.commentBefore}`:o}t.comment=n.after.join(`
165
- `)||null}}function vg({tagPrefixes:t},e){const[n,r]=e.parameters;if(!n||!r){const s="Insufficient parameters given for %TAG directive";throw new D(e,s)}if(t.some(s=>s.handle===n)){const s="The %TAG directive must only be given at most once per handle in the same document.";throw new D(e,s)}return{handle:n,prefix:r}}function $g(t,e){let[n]=e.parameters;if(e.name==="YAML:1.0"&&(n="1.0"),!n){const r="Insufficient parameters given for %YAML directive";throw new D(e,r)}if(!Yu[n]){const r=`Document will be parsed as YAML ${t.version||t.options.version} rather than YAML ${n}`;t.warnings.push(new Dt(e,r))}return n}function wg(t,e,n){const r=[];let s=!1;for(const o of e){const{comment:i,name:a}=o;switch(a){case"TAG":try{t.tagPrefixes.push(vg(t,o))}catch(c){t.errors.push(c)}s=!0;break;case"YAML":case"YAML:1.0":if(t.version){const c="The %YAML directive must only be given at most once per document.";t.errors.push(new D(o,c))}try{t.version=$g(t,o)}catch(c){t.errors.push(c)}s=!0;break;default:if(a){const c=`YAML only supports %TAG and %YAML directives, and not %${a}`;t.warnings.push(new Dt(o,c))}}i&&r.push(i)}if(n&&!s&&(t.version||n.version||t.options.version)==="1.1"){const o=({handle:i,prefix:a})=>({handle:i,prefix:a});t.tagPrefixes=n.tagPrefixes.map(o),t.version=n.version}t.commentBefore=r.join(`
166
- `)||null}function wt(t){if(t instanceof Q)return!0;throw new Error("Expected a YAML collection as document contents")}class Tt{constructor(e){this.anchors=new po(e.anchorPrefix),this.commentBefore=null,this.comment=null,this.contents=null,this.directivesEndMarker=null,this.errors=[],this.options=e,this.schema=null,this.tagPrefixes=[],this.version=null,this.warnings=[]}add(e){return wt(this.contents),this.contents.add(e)}addIn(e,n){wt(this.contents),this.contents.addIn(e,n)}delete(e){return wt(this.contents),this.contents.delete(e)}deleteIn(e){return Qt(e)?this.contents==null?!1:(this.contents=null,!0):(wt(this.contents),this.contents.deleteIn(e))}getDefaults(){return Tt.defaults[this.version]||Tt.defaults[this.options.version]||{}}get(e,n){return this.contents instanceof Q?this.contents.get(e,n):void 0}getIn(e,n){return Qt(e)?!n&&this.contents instanceof G?this.contents.value:this.contents:this.contents instanceof Q?this.contents.getIn(e,n):void 0}has(e){return this.contents instanceof Q?this.contents.has(e):!1}hasIn(e){return Qt(e)?this.contents!==void 0:this.contents instanceof Q?this.contents.hasIn(e):!1}set(e,n){wt(this.contents),this.contents.set(e,n)}setIn(e,n){Qt(e)?this.contents=n:(wt(this.contents),this.contents.setIn(e,n))}setSchema(e,n){if(!e&&!n&&this.schema)return;typeof e=="number"&&(e=e.toFixed(1)),e==="1.0"||e==="1.1"||e==="1.2"?(this.version?this.version=e:this.options.version=e,delete this.options.schema):e&&typeof e=="string"&&(this.options.schema=e),Array.isArray(n)&&(this.options.customTags=n);const r=Object.assign({},this.getDefaults(),this.options);this.schema=new ht(r)}parse(e,n){this.options.keepCstNodes&&(this.cstNode=e),this.options.keepNodeTypes&&(this.type="DOCUMENT");const{directives:r=[],contents:s=[],directivesEndMarker:o,error:i,valueRange:a}=e;if(i&&(i.source||(i.source=this),this.errors.push(i)),wg(this,r,n),o&&(this.directivesEndMarker=!0),this.range=a?[a.start,a.end]:null,this.setSchema(),this.anchors._cstAliases=[],yg(this,s),this.anchors.resolveNodes(),this.options.prettyErrors){for(const c of this.errors)c instanceof pt&&c.makePretty();for(const c of this.warnings)c instanceof pt&&c.makePretty()}return this}listNonDefaultTags(){return gg(this.contents).filter(e=>e.indexOf(ht.defaultPrefix)!==0)}setTagPrefix(e,n){if(e[0]!=="!"||e[e.length-1]!=="!")throw new Error("Handle must start and end with !");if(n){const r=this.tagPrefixes.find(s=>s.handle===e);r?r.prefix=n:this.tagPrefixes.push({handle:e,prefix:n})}else this.tagPrefixes=this.tagPrefixes.filter(r=>r.handle!==e)}toJSON(e,n){const{keepBlobsInJSON:r,mapAsMap:s,maxAliasCount:o}=this.options,i=r&&(typeof e!="string"||!(this.contents instanceof G)),a={doc:this,indentStep:" ",keep:i,mapAsMap:i&&!!s,maxAliasCount:o,stringify:An},c=Object.keys(this.anchors.map);c.length>0&&(a.anchors=new Map(c.map(l=>[this.anchors.map[l],{alias:[],aliasCount:0,count:1}])));const u=Se(this.contents,e,a);if(typeof n=="function"&&a.anchors)for(const{count:l,res:f}of a.anchors.values())n(f,l);return u}toString(){if(this.errors.length>0)throw new Error("Document with errors cannot be stringified");const e=this.options.indent;if(!Number.isInteger(e)||e<=0){const c=JSON.stringify(e);throw new Error(`"indent" option must be a positive integer, not ${c}`)}this.setSchema();const n=[];let r=!1;if(this.version){let c="%YAML 1.2";this.schema.name==="yaml-1.1"&&(this.version==="1.0"?c="%YAML:1.0":this.version==="1.1"&&(c="%YAML 1.1")),n.push(c),r=!0}const s=this.listNonDefaultTags();this.tagPrefixes.forEach(({handle:c,prefix:u})=>{s.some(l=>l.indexOf(u)===0)&&(n.push(`%TAG ${c} ${u}`),r=!0)}),(r||this.directivesEndMarker)&&n.push("---"),this.commentBefore&&((r||!this.directivesEndMarker)&&n.unshift(""),n.unshift(this.commentBefore.replace(/^/gm,"#")));const o={anchors:Object.create(null),doc:this,indent:"",indentStep:" ".repeat(e),stringify:An};let i=!1,a=null;if(this.contents){this.contents instanceof de&&(this.contents.spaceBefore&&(r||this.directivesEndMarker)&&n.push(""),this.contents.commentBefore&&n.push(this.contents.commentBefore.replace(/^/gm,"#")),o.forceBlockIndent=!!this.comment,a=this.contents.comment);const c=a?null:()=>i=!0,u=An(this.contents,o,()=>a=null,c);n.push(It(u,"",a))}else this.contents!==void 0&&n.push(An(this.contents,o));return this.comment&&((!i||a)&&n[n.length-1]!==""&&n.push(""),n.push(this.comment.replace(/^/gm,"#"))),n.join(`
167
- `)+`
168
- `}}ue(Tt,"defaults",Yu);function bg(t,e=!0,n){n===void 0&&typeof e=="string"&&(n=e,e=!0);const r=Object.assign({},Tt.defaults[Yn.version],Yn);return new ht(r).createNode(t,e,n)}class dr extends Tt{constructor(e){super(Object.assign({},Yn,e))}}function Eg(t,e){const n=[];let r;for(const s of oo(t)){const o=new dr(e);o.parse(s,r),n.push(o),r=o}return n}function Xu(t,e){const n=oo(t),r=new dr(e).parse(n[0]);if(n.length>1){const s="Source contains multiple documents; please use YAML.parseAllDocuments()";r.errors.unshift(new D(n[1],s))}return r}function Sg(t,e){const n=Xu(t,e);if(n.warnings.forEach(r=>Uu(r)),n.errors.length>0)throw n.errors[0];return n.toJSON()}function Ng(t,e){const n=new dr(e);return n.contents=t,String(n)}const Og={createNode:bg,defaultOptions:Yn,Document:dr,parse:Sg,parseAllDocuments:Eg,parseCST:oo,parseDocument:Xu,scalarOptions:pg,stringify:Ng},_g=Object.freeze(Object.defineProperty({__proto__:null,YAML:Og},Symbol.toStringTag,{value:"Module"})),kg=Sm(_g);var Ig=kg.YAML;const Ag="1.0.0-redesign.1",Pg="adhd",jg="default",xg="adhd-environment.json",Gr="config.yaml",Tg="config.local.yaml",Cg={data:"shared",cache:"shared",state:"shared",config:"shared",run:"shared",logs:"per-instance",temp:"per-instance"};class fa extends Error{constructor(e,n){super(`contentHash: lone surrogate in ${e} (not well-formed Unicode)`),this.location=e,this.offending=n,this.name="LoneSurrogateError"}}function da(t){for(let e=0;e<t.length;e++){const n=t.charCodeAt(e);if(n>=55296&&n<=56319){const r=e+1<t.length?t.charCodeAt(e+1):0;if(r<56320||r>57343)return!0;e++}else if(n>=56320&&n<=57343)return!0}return!1}function Zu(t,e){const n=Array.from(t),r=Array.from(e),s=Math.min(n.length,r.length);for(let o=0;o<s;o++){const i=n[o].codePointAt(0)??0,a=r[o].codePointAt(0)??0;if(i!==a)return i<a?-1:1}return n.length===r.length?0:n.length<r.length?-1:1}function pa(t){return new TextEncoder().encode(t).length}function Rg(t){const e=Object.keys(t).sort(Zu);let n="";for(const r of e){const s=t[r];if(da(r))throw new fa("key",r);if(da(s))throw new fa("value",s);n+=`${pa(r)}:${r}=${pa(s)}:${s}
169
- `}return`sha256-${el(n)}`}function Mg(t){const e=[...t].sort((n,r)=>Zu(n.name,r.name)).map(n=>`${n.name}:${n.kind}:${n.scope}`).join(`
170
- `);return`sha256-${el(e)}`}function Dg(t){return`ADHD_${t.toUpperCase().replace(/[.-]/g,"_")}`}function Lg(t,e){return`${t}_${e.toUpperCase().replace(/[.-]/g,"_")}`}function Bg(t){const e={type:"object",properties:{}},n=t;for(const r of Object.keys(n)){const s=n[r],o=r.split(".");let i=e;o.forEach((a,c)=>{if(c===o.length-1){i.properties[a]=Ug(s);return}const u=i.properties[a];if(u===void 0){const l={type:"object",properties:{}};i.properties[a]=l,i=l}else i=u})}return e}function Ug(t){const e={type:t.type};return t.default!==void 0&&t.secret!==!0&&(e.default=t.default),t.description!==void 0&&(e.description=t.description),t.minimum!==void 0&&(e.minimum=t.minimum),t.maximum!==void 0&&(e.maximum=t.maximum),t.enum!==void 0&&(e.enum=t.enum),t.pattern!==void 0&&(e.pattern=t.pattern),t.minLength!==void 0&&(e.minLength=t.minLength),t.maxLength!==void 0&&(e.maxLength=t.maxLength),t.items!==void 0&&(e.items=t.items),e}const Vg="adhd-env-ref:";function Fg(t){return`${Vg}${t}`}const qg=[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],Kg=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225];function _e(t,e){return(t>>>e|t<<32-e)>>>0}function zg(t){const e=Uint32Array.from(Kg),n=t.length*8;let r=t.length+1;for(;r%64!==56;)r++;r+=8;const s=new Uint8Array(r);s.set(t),s[t.length]=128;const o=Math.floor(n/4294967296),i=n>>>0,a=new DataView(s.buffer);a.setUint32(r-8,o,!1),a.setUint32(r-4,i,!1);const c=new Uint32Array(64);for(let f=0;f<r;f+=64){for(let N=0;N<16;N++)c[N]=a.getUint32(f+N*4,!1);for(let N=16;N<64;N++){const k=c[N-15],C=c[N-2],F=_e(k,7)^_e(k,18)^k>>>3,ee=_e(C,17)^_e(C,19)^C>>>10;c[N]=c[N-16]+F+c[N-7]+ee>>>0}let m=e[0],p=e[1],d=e[2],v=e[3],g=e[4],y=e[5],$=e[6],S=e[7];for(let N=0;N<64;N++){const k=_e(g,6)^_e(g,11)^_e(g,25),C=g&y^~g&$,F=S+k+C+qg[N]+c[N]>>>0,ee=_e(m,2)^_e(m,13)^_e(m,22),ae=m&p^m&d^p&d,me=ee+ae>>>0;S=$,$=y,y=g,g=v+F>>>0,v=d,d=p,p=m,m=F+me>>>0}e[0]=e[0]+m>>>0,e[1]=e[1]+p>>>0,e[2]=e[2]+d>>>0,e[3]=e[3]+v>>>0,e[4]=e[4]+g>>>0,e[5]=e[5]+y>>>0,e[6]=e[6]+$>>>0,e[7]=e[7]+S>>>0}const u=new Uint8Array(32),l=new DataView(u.buffer);for(let f=0;f<8;f++)l.setUint32(f*4,e[f],!1);return u}function Gg(t){let e="";for(const n of t)e+=n.toString(16).padStart(2,"0");return e}function el(t){const e=new TextEncoder().encode(t);return Gg(zg(e))}function tl(t,e=""){const n={};if(t===null||typeof t!="object"||Array.isArray(t))return e&&(n[e]=t),n;for(const[r,s]of Object.entries(t)){const o=e?`${e}.${r}`:r;s!==null&&typeof s=="object"&&!Array.isArray(s)?Object.assign(n,tl(s,o)):n[o]=s}return n}function Pn(t){if(Y.existsSync(t))try{const e=Y.readFileSync(t,"utf8"),n=Ig.parse(e);return n===null||typeof n!="object"||Array.isArray(n)?void 0:tl(n)}catch{return}}function Wg(t){return{system:Pn(q.join(t.system,Gr)),global:Pn(q.join(t.global,Gr)),project:t.project?Pn(q.join(t.project,Gr)):void 0,local:t.project?Pn(q.join(t.project,Tg)):void 0}}function Hg(t){const e={source:t.source,scope:t.scope};return t.source==="env"&&t.env!==void 0&&(e.env=t.env),e}function ws(t,e){if(t===void 0)return t;switch(e){case"integer":{if(typeof t=="number")return t;const n=parseInt(String(t),10);return Number.isNaN(n)?t:n}case"number":{if(typeof t=="number")return t;const n=parseFloat(String(t));return Number.isNaN(n)?t:n}case"boolean":{if(typeof t=="boolean")return t;const n=String(t).toLowerCase();return n==="true"?!0:n==="false"?!1:t}case"array":return Array.isArray(t)?t:typeof t=="string"?t.length===0?[]:t.split(",").map(n=>n.trim()):t;case"string":return typeof t=="string"?t:String(t);default:return t}}function nl(t){const e={};for(const n of Object.keys(t)){const r=n.split(".");let s=e;r.forEach((o,i)=>{if(i===r.length-1){s[o]=t[n];return}const a=s[o];(typeof a!="object"||a===null||Array.isArray(a))&&(s[o]={}),s=s[o]})}return e}const Jg=[["system","system"],["global","global"],["project","project"],["local","local"]];function Qg(t,e,n,r){const s={},o={},i={},a={};for(const c of Object.keys(t)){const u=t[c],l=u.env&&u.env!==""?u.env:Lg(r.prefix,c),f=u.at==="runtime"||u.secret===!0,m=u.scope??r.activeScope;let p=u.default,d="default";for(const[S,N]of Jg){const k=e[S];k&&Object.prototype.hasOwnProperty.call(k,c)&&(p=ws(k[c],u.type),d=N)}const v=n[l];let g,y,$;v!==void 0?(g=ws(v,u.type),y="env",$=l):(g=p,y=d),s[c]=f?Fg(l):g,o[c]=g,i[c]=Hg(f?{source:"env",scope:m,env:l}:{source:y,scope:m,env:$}),a[c]={...u,env:l,live:f,fallbackValue:p}}return{raw:s,nested:nl(s),typedRaw:o,provenance:i,fields:a}}function Yg(t,e){return t.replace(/\$\{HOME\}/g,Jn.homedir()).replace(/\$HOME\b/g,Jn.homedir()).replace(/\$\{PROJECT_ROOT\}/g,e.projectRoot??process.cwd()).replace(/\$\{NAMESPACE\}/g,e.namespace)}function Xg(t,e){const n={};for(const[r,s]of Object.entries(t??{})){const o=s.scope??e.activeScope,i=s.share??Cg[s.kind],a=s.path?Yg(s.path,e):q.join(gu(e.roots,o),r),c=i==="per-instance"?q.join(a,e.instanceId):a;n[r]={name:r,kind:s.kind,path:c,scope:o,share:i}}return n}function Zg(t,e){const n={};for(const[r,s]of Object.entries(t??{})){const o=e[s.in];if(!o)throw new Error(`files.${r}.in references unknown dirs key "${s.in}"`);n[r]={name:r,in:s.in,path:q.join(o.path,s.name),share:s.share??"shared"}}return n}var bs={exports:{}},rl={},Ne={},Ct={},yn={},U={},hn={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.regexpCode=t.getEsmExportName=t.getProperty=t.safeStringify=t.stringify=t.strConcat=t.addCodeArg=t.str=t._=t.nil=t._Code=t.Name=t.IDENTIFIER=t._CodeOrName=void 0;class e{}t._CodeOrName=e,t.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;class n extends e{constructor($){if(super(),!t.IDENTIFIER.test($))throw new Error("CodeGen: name must be a valid identifier");this.str=$}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}}t.Name=n;class r extends e{constructor($){super(),this._items=typeof $=="string"?[$]:$}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;const $=this._items[0];return $===""||$==='""'}get str(){var $;return($=this._str)!==null&&$!==void 0?$:this._str=this._items.reduce((S,N)=>`${S}${N}`,"")}get names(){var $;return($=this._names)!==null&&$!==void 0?$:this._names=this._items.reduce((S,N)=>(N instanceof n&&(S[N.str]=(S[N.str]||0)+1),S),{})}}t._Code=r,t.nil=new r("");function s(y,...$){const S=[y[0]];let N=0;for(;N<$.length;)a(S,$[N]),S.push(y[++N]);return new r(S)}t._=s;const o=new r("+");function i(y,...$){const S=[p(y[0])];let N=0;for(;N<$.length;)S.push(o),a(S,$[N]),S.push(o,p(y[++N]));return c(S),new r(S)}t.str=i;function a(y,$){$ instanceof r?y.push(...$._items):$ instanceof n?y.push($):y.push(f($))}t.addCodeArg=a;function c(y){let $=1;for(;$<y.length-1;){if(y[$]===o){const S=u(y[$-1],y[$+1]);if(S!==void 0){y.splice($-1,3,S);continue}y[$++]="+"}$++}}function u(y,$){if($==='""')return y;if(y==='""')return $;if(typeof y=="string")return $ instanceof n||y[y.length-1]!=='"'?void 0:typeof $!="string"?`${y.slice(0,-1)}${$}"`:$[0]==='"'?y.slice(0,-1)+$.slice(1):void 0;if(typeof $=="string"&&$[0]==='"'&&!(y instanceof n))return`"${y}${$.slice(1)}`}function l(y,$){return $.emptyStr()?y:y.emptyStr()?$:i`${y}${$}`}t.strConcat=l;function f(y){return typeof y=="number"||typeof y=="boolean"||y===null?y:p(Array.isArray(y)?y.join(","):y)}function m(y){return new r(p(y))}t.stringify=m;function p(y){return JSON.stringify(y).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}t.safeStringify=p;function d(y){return typeof y=="string"&&t.IDENTIFIER.test(y)?new r(`.${y}`):s`[${y}]`}t.getProperty=d;function v(y){if(typeof y=="string"&&t.IDENTIFIER.test(y))return new r(`${y}`);throw new Error(`CodeGen: invalid export name: ${y}, use explicit $id name mapping`)}t.getEsmExportName=v;function g(y){return new r(y.toString())}t.regexpCode=g})(hn);var Es={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.ValueScope=t.ValueScopeName=t.Scope=t.varKinds=t.UsedValueState=void 0;const e=hn;class n extends Error{constructor(u){super(`CodeGen: "code" for ${u} not defined`),this.value=u.value}}var r;(function(c){c[c.Started=0]="Started",c[c.Completed=1]="Completed"})(r||(t.UsedValueState=r={})),t.varKinds={const:new e.Name("const"),let:new e.Name("let"),var:new e.Name("var")};class s{constructor({prefixes:u,parent:l}={}){this._names={},this._prefixes=u,this._parent=l}toName(u){return u instanceof e.Name?u:this.name(u)}name(u){return new e.Name(this._newName(u))}_newName(u){const l=this._names[u]||this._nameGroup(u);return`${u}${l.index++}`}_nameGroup(u){var l,f;if(!((f=(l=this._parent)===null||l===void 0?void 0:l._prefixes)===null||f===void 0)&&f.has(u)||this._prefixes&&!this._prefixes.has(u))throw new Error(`CodeGen: prefix "${u}" is not allowed in this scope`);return this._names[u]={prefix:u,index:0}}}t.Scope=s;class o extends e.Name{constructor(u,l){super(l),this.prefix=u}setValue(u,{property:l,itemIndex:f}){this.value=u,this.scopePath=(0,e._)`.${new e.Name(l)}[${f}]`}}t.ValueScopeName=o;const i=(0,e._)`\n`;class a extends s{constructor(u){super(u),this._values={},this._scope=u.scope,this.opts={...u,_n:u.lines?i:e.nil}}get(){return this._scope}name(u){return new o(u,this._newName(u))}value(u,l){var f;if(l.ref===void 0)throw new Error("CodeGen: ref must be passed in value");const m=this.toName(u),{prefix:p}=m,d=(f=l.key)!==null&&f!==void 0?f:l.ref;let v=this._values[p];if(v){const $=v.get(d);if($)return $}else v=this._values[p]=new Map;v.set(d,m);const g=this._scope[p]||(this._scope[p]=[]),y=g.length;return g[y]=l.ref,m.setValue(l,{property:p,itemIndex:y}),m}getValue(u,l){const f=this._values[u];if(f)return f.get(l)}scopeRefs(u,l=this._values){return this._reduceValues(l,f=>{if(f.scopePath===void 0)throw new Error(`CodeGen: name "${f}" has no value`);return(0,e._)`${u}${f.scopePath}`})}scopeCode(u=this._values,l,f){return this._reduceValues(u,m=>{if(m.value===void 0)throw new Error(`CodeGen: name "${m}" has no value`);return m.value.code},l,f)}_reduceValues(u,l,f={},m){let p=e.nil;for(const d in u){const v=u[d];if(!v)continue;const g=f[d]=f[d]||new Map;v.forEach(y=>{if(g.has(y))return;g.set(y,r.Started);let $=l(y);if($){const S=this.opts.es5?t.varKinds.var:t.varKinds.const;p=(0,e._)`${p}${S} ${y} = ${$};${this.opts._n}`}else if($=m==null?void 0:m(y))p=(0,e._)`${p}${$}${this.opts._n}`;else throw new n(y);g.set(y,r.Completed)})}return p}}t.ValueScope=a})(Es);(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.or=t.and=t.not=t.CodeGen=t.operators=t.varKinds=t.ValueScopeName=t.ValueScope=t.Scope=t.Name=t.regexpCode=t.stringify=t.getProperty=t.nil=t.strConcat=t.str=t._=void 0;const e=hn,n=Es;var r=hn;Object.defineProperty(t,"_",{enumerable:!0,get:function(){return r._}}),Object.defineProperty(t,"str",{enumerable:!0,get:function(){return r.str}}),Object.defineProperty(t,"strConcat",{enumerable:!0,get:function(){return r.strConcat}}),Object.defineProperty(t,"nil",{enumerable:!0,get:function(){return r.nil}}),Object.defineProperty(t,"getProperty",{enumerable:!0,get:function(){return r.getProperty}}),Object.defineProperty(t,"stringify",{enumerable:!0,get:function(){return r.stringify}}),Object.defineProperty(t,"regexpCode",{enumerable:!0,get:function(){return r.regexpCode}}),Object.defineProperty(t,"Name",{enumerable:!0,get:function(){return r.Name}});var s=Es;Object.defineProperty(t,"Scope",{enumerable:!0,get:function(){return s.Scope}}),Object.defineProperty(t,"ValueScope",{enumerable:!0,get:function(){return s.ValueScope}}),Object.defineProperty(t,"ValueScopeName",{enumerable:!0,get:function(){return s.ValueScopeName}}),Object.defineProperty(t,"varKinds",{enumerable:!0,get:function(){return s.varKinds}}),t.operators={GT:new e._Code(">"),GTE:new e._Code(">="),LT:new e._Code("<"),LTE:new e._Code("<="),EQ:new e._Code("==="),NEQ:new e._Code("!=="),NOT:new e._Code("!"),OR:new e._Code("||"),AND:new e._Code("&&"),ADD:new e._Code("+")};class o{optimizeNodes(){return this}optimizeNames(h,w){return this}}class i extends o{constructor(h,w,O){super(),this.varKind=h,this.name=w,this.rhs=O}render({es5:h,_n:w}){const O=h?n.varKinds.var:this.varKind,T=this.rhs===void 0?"":` = ${this.rhs}`;return`${O} ${this.name}${T};`+w}optimizeNames(h,w){if(h[this.name.str])return this.rhs&&(this.rhs=Fe(this.rhs,h,w)),this}get names(){return this.rhs instanceof e._CodeOrName?this.rhs.names:{}}}class a extends o{constructor(h,w,O){super(),this.lhs=h,this.rhs=w,this.sideEffects=O}render({_n:h}){return`${this.lhs} = ${this.rhs};`+h}optimizeNames(h,w){if(!(this.lhs instanceof e.Name&&!h[this.lhs.str]&&!this.sideEffects))return this.rhs=Fe(this.rhs,h,w),this}get names(){const h=this.lhs instanceof e.Name?{}:{...this.lhs.names};return vt(h,this.rhs)}}class c extends a{constructor(h,w,O,T){super(h,O,T),this.op=w}render({_n:h}){return`${this.lhs} ${this.op}= ${this.rhs};`+h}}class u extends o{constructor(h){super(),this.label=h,this.names={}}render({_n:h}){return`${this.label}:`+h}}class l extends o{constructor(h){super(),this.label=h,this.names={}}render({_n:h}){return`break${this.label?` ${this.label}`:""};`+h}}class f extends o{constructor(h){super(),this.error=h}render({_n:h}){return`throw ${this.error};`+h}get names(){return this.error.names}}class m extends o{constructor(h){super(),this.code=h}render({_n:h}){return`${this.code};`+h}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(h,w){return this.code=Fe(this.code,h,w),this}get names(){return this.code instanceof e._CodeOrName?this.code.names:{}}}class p extends o{constructor(h=[]){super(),this.nodes=h}render(h){return this.nodes.reduce((w,O)=>w+O.render(h),"")}optimizeNodes(){const{nodes:h}=this;let w=h.length;for(;w--;){const O=h[w].optimizeNodes();Array.isArray(O)?h.splice(w,1,...O):O?h[w]=O:h.splice(w,1)}return h.length>0?this:void 0}optimizeNames(h,w){const{nodes:O}=this;let T=O.length;for(;T--;){const R=O[T];R.optimizeNames(h,w)||(Kt(h,R.names),O.splice(T,1))}return O.length>0?this:void 0}get names(){return this.nodes.reduce((h,w)=>Te(h,w.names),{})}}class d extends p{render(h){return"{"+h._n+super.render(h)+"}"+h._n}}class v extends p{}class g extends d{}g.kind="else";class y extends d{constructor(h,w){super(w),this.condition=h}render(h){let w=`if(${this.condition})`+super.render(h);return this.else&&(w+="else "+this.else.render(h)),w}optimizeNodes(){super.optimizeNodes();const h=this.condition;if(h===!0)return this.nodes;let w=this.else;if(w){const O=w.optimizeNodes();w=this.else=Array.isArray(O)?new g(O):O}if(w)return h===!1?w instanceof y?w:w.nodes:this.nodes.length?this:new y(wn(h),w instanceof y?[w]:w.nodes);if(!(h===!1||!this.nodes.length))return this}optimizeNames(h,w){var O;if(this.else=(O=this.else)===null||O===void 0?void 0:O.optimizeNames(h,w),!!(super.optimizeNames(h,w)||this.else))return this.condition=Fe(this.condition,h,w),this}get names(){const h=super.names;return vt(h,this.condition),this.else&&Te(h,this.else.names),h}}y.kind="if";class $ extends d{}$.kind="for";class S extends ${constructor(h){super(),this.iteration=h}render(h){return`for(${this.iteration})`+super.render(h)}optimizeNames(h,w){if(super.optimizeNames(h,w))return this.iteration=Fe(this.iteration,h,w),this}get names(){return Te(super.names,this.iteration.names)}}class N extends ${constructor(h,w,O,T){super(),this.varKind=h,this.name=w,this.from=O,this.to=T}render(h){const w=h.es5?n.varKinds.var:this.varKind,{name:O,from:T,to:R}=this;return`for(${w} ${O}=${T}; ${O}<${R}; ${O}++)`+super.render(h)}get names(){const h=vt(super.names,this.from);return vt(h,this.to)}}class k extends ${constructor(h,w,O,T){super(),this.loop=h,this.varKind=w,this.name=O,this.iterable=T}render(h){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(h)}optimizeNames(h,w){if(super.optimizeNames(h,w))return this.iterable=Fe(this.iterable,h,w),this}get names(){return Te(super.names,this.iterable.names)}}class C extends d{constructor(h,w,O){super(),this.name=h,this.args=w,this.async=O}render(h){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(h)}}C.kind="func";class F extends p{render(h){return"return "+super.render(h)}}F.kind="return";class ee extends d{render(h){let w="try"+super.render(h);return this.catch&&(w+=this.catch.render(h)),this.finally&&(w+=this.finally.render(h)),w}optimizeNodes(){var h,w;return super.optimizeNodes(),(h=this.catch)===null||h===void 0||h.optimizeNodes(),(w=this.finally)===null||w===void 0||w.optimizeNodes(),this}optimizeNames(h,w){var O,T;return super.optimizeNames(h,w),(O=this.catch)===null||O===void 0||O.optimizeNames(h,w),(T=this.finally)===null||T===void 0||T.optimizeNames(h,w),this}get names(){const h=super.names;return this.catch&&Te(h,this.catch.names),this.finally&&Te(h,this.finally.names),h}}class ae extends d{constructor(h){super(),this.error=h}render(h){return`catch(${this.error})`+super.render(h)}}ae.kind="catch";class me extends d{render(h){return"finally"+super.render(h)}}me.kind="finally";class qt{constructor(h,w={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...w,_n:w.lines?`
171
- `:""},this._extScope=h,this._scope=new n.Scope({parent:h}),this._nodes=[new v]}toString(){return this._root.render(this.opts)}name(h){return this._scope.name(h)}scopeName(h){return this._extScope.name(h)}scopeValue(h,w){const O=this._extScope.value(h,w);return(this._values[O.prefix]||(this._values[O.prefix]=new Set)).add(O),O}getScopeValue(h,w){return this._extScope.getValue(h,w)}scopeRefs(h){return this._extScope.scopeRefs(h,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(h,w,O,T){const R=this._scope.toName(w);return O!==void 0&&T&&(this._constants[R.str]=O),this._leafNode(new i(h,R,O)),R}const(h,w,O){return this._def(n.varKinds.const,h,w,O)}let(h,w,O){return this._def(n.varKinds.let,h,w,O)}var(h,w,O){return this._def(n.varKinds.var,h,w,O)}assign(h,w,O){return this._leafNode(new a(h,w,O))}add(h,w){return this._leafNode(new c(h,t.operators.ADD,w))}code(h){return typeof h=="function"?h():h!==e.nil&&this._leafNode(new m(h)),this}object(...h){const w=["{"];for(const[O,T]of h)w.length>1&&w.push(","),w.push(O),(O!==T||this.opts.es5)&&(w.push(":"),(0,e.addCodeArg)(w,T));return w.push("}"),new e._Code(w)}if(h,w,O){if(this._blockNode(new y(h)),w&&O)this.code(w).else().code(O).endIf();else if(w)this.code(w).endIf();else if(O)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(h){return this._elseNode(new y(h))}else(){return this._elseNode(new g)}endIf(){return this._endBlockNode(y,g)}_for(h,w){return this._blockNode(h),w&&this.code(w).endFor(),this}for(h,w){return this._for(new S(h),w)}forRange(h,w,O,T,R=this.opts.es5?n.varKinds.var:n.varKinds.let){const z=this._scope.toName(h);return this._for(new N(R,z,w,O),()=>T(z))}forOf(h,w,O,T=n.varKinds.const){const R=this._scope.toName(h);if(this.opts.es5){const z=w instanceof e.Name?w:this.var("_arr",w);return this.forRange("_i",0,(0,e._)`${z}.length`,K=>{this.var(R,(0,e._)`${z}[${K}]`),O(R)})}return this._for(new k("of",T,R,w),()=>O(R))}forIn(h,w,O,T=this.opts.es5?n.varKinds.var:n.varKinds.const){if(this.opts.ownProperties)return this.forOf(h,(0,e._)`Object.keys(${w})`,O);const R=this._scope.toName(h);return this._for(new k("in",T,R,w),()=>O(R))}endFor(){return this._endBlockNode($)}label(h){return this._leafNode(new u(h))}break(h){return this._leafNode(new l(h))}return(h){const w=new F;if(this._blockNode(w),this.code(h),w.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(F)}try(h,w,O){if(!w&&!O)throw new Error('CodeGen: "try" without "catch" and "finally"');const T=new ee;if(this._blockNode(T),this.code(h),w){const R=this.name("e");this._currNode=T.catch=new ae(R),w(R)}return O&&(this._currNode=T.finally=new me,this.code(O)),this._endBlockNode(ae,me)}throw(h){return this._leafNode(new f(h))}block(h,w){return this._blockStarts.push(this._nodes.length),h&&this.code(h).endBlock(w),this}endBlock(h){const w=this._blockStarts.pop();if(w===void 0)throw new Error("CodeGen: not in self-balancing block");const O=this._nodes.length-w;if(O<0||h!==void 0&&O!==h)throw new Error(`CodeGen: wrong number of nodes: ${O} vs ${h} expected`);return this._nodes.length=w,this}func(h,w=e.nil,O,T){return this._blockNode(new C(h,w,O)),T&&this.code(T).endFunc(),this}endFunc(){return this._endBlockNode(C)}optimize(h=1){for(;h-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(h){return this._currNode.nodes.push(h),this}_blockNode(h){this._currNode.nodes.push(h),this._nodes.push(h)}_endBlockNode(h,w){const O=this._currNode;if(O instanceof h||w&&O instanceof w)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${w?`${h.kind}/${w.kind}`:h.kind}"`)}_elseNode(h){const w=this._currNode;if(!(w instanceof y))throw new Error('CodeGen: "else" without "if"');return this._currNode=w.else=h,this}get _root(){return this._nodes[0]}get _currNode(){const h=this._nodes;return h[h.length-1]}set _currNode(h){const w=this._nodes;w[w.length-1]=h}}t.CodeGen=qt;function Te(E,h){for(const w in h)E[w]=(E[w]||0)+(h[w]||0);return E}function vt(E,h){return h instanceof e._CodeOrName?Te(E,h.names):E}function Fe(E,h,w){if(E instanceof e.Name)return O(E);if(!T(E))return E;return new e._Code(E._items.reduce((R,z)=>(z instanceof e.Name&&(z=O(z)),z instanceof e._Code?R.push(...z._items):R.push(z),R),[]));function O(R){const z=w[R.str];return z===void 0||h[R.str]!==1?R:(delete h[R.str],z)}function T(R){return R instanceof e._Code&&R._items.some(z=>z instanceof e.Name&&h[z.str]===1&&w[z.str]!==void 0)}}function Kt(E,h){for(const w in h)E[w]=(E[w]||0)-(h[w]||0)}function wn(E){return typeof E=="boolean"||typeof E=="number"||E===null?!E:(0,e._)`!${I(E)}`}t.not=wn;const $r=b(t.operators.AND);function wr(...E){return E.reduce($r)}t.and=wr;const bn=b(t.operators.OR);function P(...E){return E.reduce(bn)}t.or=P;function b(E){return(h,w)=>h===e.nil?w:w===e.nil?h:(0,e._)`${I(h)} ${E} ${I(w)}`}function I(E){return E instanceof e.Name?E:(0,e._)`(${E})`}})(U);var j={};Object.defineProperty(j,"__esModule",{value:!0});j.checkStrictMode=j.getErrorPath=j.Type=j.useFunc=j.setEvaluated=j.evaluatedPropsToName=j.mergeEvaluated=j.eachItem=j.unescapeJsonPointer=j.escapeJsonPointer=j.escapeFragment=j.unescapeFragment=j.schemaRefOrVal=j.schemaHasRulesButRef=j.schemaHasRules=j.checkUnknownRules=j.alwaysValidSchema=j.toHash=void 0;const W=U,ey=hn;function ty(t){const e={};for(const n of t)e[n]=!0;return e}j.toHash=ty;function ny(t,e){return typeof e=="boolean"?e:Object.keys(e).length===0?!0:(sl(t,e),!ol(e,t.self.RULES.all))}j.alwaysValidSchema=ny;function sl(t,e=t.schema){const{opts:n,self:r}=t;if(!n.strictSchema||typeof e=="boolean")return;const s=r.RULES.keywords;for(const o in e)s[o]||cl(t,`unknown keyword: "${o}"`)}j.checkUnknownRules=sl;function ol(t,e){if(typeof t=="boolean")return!t;for(const n in t)if(e[n])return!0;return!1}j.schemaHasRules=ol;function ry(t,e){if(typeof t=="boolean")return!t;for(const n in t)if(n!=="$ref"&&e.all[n])return!0;return!1}j.schemaHasRulesButRef=ry;function sy({topSchemaRef:t,schemaPath:e},n,r,s){if(!s){if(typeof n=="number"||typeof n=="boolean")return n;if(typeof n=="string")return(0,W._)`${n}`}return(0,W._)`${t}${e}${(0,W.getProperty)(r)}`}j.schemaRefOrVal=sy;function oy(t){return il(decodeURIComponent(t))}j.unescapeFragment=oy;function iy(t){return encodeURIComponent(ho(t))}j.escapeFragment=iy;function ho(t){return typeof t=="number"?`${t}`:t.replace(/~/g,"~0").replace(/\//g,"~1")}j.escapeJsonPointer=ho;function il(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}j.unescapeJsonPointer=il;function ay(t,e){if(Array.isArray(t))for(const n of t)e(n);else e(t)}j.eachItem=ay;function ha({mergeNames:t,mergeToName:e,mergeValues:n,resultToName:r}){return(s,o,i,a)=>{const c=i===void 0?o:i instanceof W.Name?(o instanceof W.Name?t(s,o,i):e(s,o,i),i):o instanceof W.Name?(e(s,i,o),o):n(o,i);return a===W.Name&&!(c instanceof W.Name)?r(s,c):c}}j.mergeEvaluated={props:ha({mergeNames:(t,e,n)=>t.if((0,W._)`${n} !== true && ${e} !== undefined`,()=>{t.if((0,W._)`${e} === true`,()=>t.assign(n,!0),()=>t.assign(n,(0,W._)`${n} || {}`).code((0,W._)`Object.assign(${n}, ${e})`))}),mergeToName:(t,e,n)=>t.if((0,W._)`${n} !== true`,()=>{e===!0?t.assign(n,!0):(t.assign(n,(0,W._)`${n} || {}`),mo(t,n,e))}),mergeValues:(t,e)=>t===!0?!0:{...t,...e},resultToName:al}),items:ha({mergeNames:(t,e,n)=>t.if((0,W._)`${n} !== true && ${e} !== undefined`,()=>t.assign(n,(0,W._)`${e} === true ? true : ${n} > ${e} ? ${n} : ${e}`)),mergeToName:(t,e,n)=>t.if((0,W._)`${n} !== true`,()=>t.assign(n,e===!0?!0:(0,W._)`${n} > ${e} ? ${n} : ${e}`)),mergeValues:(t,e)=>t===!0?!0:Math.max(t,e),resultToName:(t,e)=>t.var("items",e)})};function al(t,e){if(e===!0)return t.var("props",!0);const n=t.var("props",(0,W._)`{}`);return e!==void 0&&mo(t,n,e),n}j.evaluatedPropsToName=al;function mo(t,e,n){Object.keys(n).forEach(r=>t.assign((0,W._)`${e}${(0,W.getProperty)(r)}`,!0))}j.setEvaluated=mo;const ma={};function cy(t,e){return t.scopeValue("func",{ref:e,code:ma[e.code]||(ma[e.code]=new ey._Code(e.code))})}j.useFunc=cy;var Ss;(function(t){t[t.Num=0]="Num",t[t.Str=1]="Str"})(Ss||(j.Type=Ss={}));function uy(t,e,n){if(t instanceof W.Name){const r=e===Ss.Num;return n?r?(0,W._)`"[" + ${t} + "]"`:(0,W._)`"['" + ${t} + "']"`:r?(0,W._)`"/" + ${t}`:(0,W._)`"/" + ${t}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return n?(0,W.getProperty)(t).toString():"/"+ho(t)}j.getErrorPath=uy;function cl(t,e,n=t.opts.strictSchema){if(n){if(e=`strict mode: ${e}`,n===!0)throw new Error(e);t.self.logger.warn(e)}}j.checkStrictMode=cl;var xe={};Object.defineProperty(xe,"__esModule",{value:!0});const ce=U,ly={data:new ce.Name("data"),valCxt:new ce.Name("valCxt"),instancePath:new ce.Name("instancePath"),parentData:new ce.Name("parentData"),parentDataProperty:new ce.Name("parentDataProperty"),rootData:new ce.Name("rootData"),dynamicAnchors:new ce.Name("dynamicAnchors"),vErrors:new ce.Name("vErrors"),errors:new ce.Name("errors"),this:new ce.Name("this"),self:new ce.Name("self"),scope:new ce.Name("scope"),json:new ce.Name("json"),jsonPos:new ce.Name("jsonPos"),jsonLen:new ce.Name("jsonLen"),jsonPart:new ce.Name("jsonPart")};xe.default=ly;(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.extendErrors=t.resetErrorsCount=t.reportExtraError=t.reportError=t.keyword$DataError=t.keywordError=void 0;const e=U,n=j,r=xe;t.keywordError={message:({keyword:g})=>(0,e.str)`must pass "${g}" keyword validation`},t.keyword$DataError={message:({keyword:g,schemaType:y})=>y?(0,e.str)`"${g}" keyword must be ${y} ($data)`:(0,e.str)`"${g}" keyword is invalid ($data)`};function s(g,y=t.keywordError,$,S){const{it:N}=g,{gen:k,compositeRule:C,allErrors:F}=N,ee=f(g,y,$);S??(C||F)?c(k,ee):u(N,(0,e._)`[${ee}]`)}t.reportError=s;function o(g,y=t.keywordError,$){const{it:S}=g,{gen:N,compositeRule:k,allErrors:C}=S,F=f(g,y,$);c(N,F),k||C||u(S,r.default.vErrors)}t.reportExtraError=o;function i(g,y){g.assign(r.default.errors,y),g.if((0,e._)`${r.default.vErrors} !== null`,()=>g.if(y,()=>g.assign((0,e._)`${r.default.vErrors}.length`,y),()=>g.assign(r.default.vErrors,null)))}t.resetErrorsCount=i;function a({gen:g,keyword:y,schemaValue:$,data:S,errsCount:N,it:k}){if(N===void 0)throw new Error("ajv implementation error");const C=g.name("err");g.forRange("i",N,r.default.errors,F=>{g.const(C,(0,e._)`${r.default.vErrors}[${F}]`),g.if((0,e._)`${C}.instancePath === undefined`,()=>g.assign((0,e._)`${C}.instancePath`,(0,e.strConcat)(r.default.instancePath,k.errorPath))),g.assign((0,e._)`${C}.schemaPath`,(0,e.str)`${k.errSchemaPath}/${y}`),k.opts.verbose&&(g.assign((0,e._)`${C}.schema`,$),g.assign((0,e._)`${C}.data`,S))})}t.extendErrors=a;function c(g,y){const $=g.const("err",y);g.if((0,e._)`${r.default.vErrors} === null`,()=>g.assign(r.default.vErrors,(0,e._)`[${$}]`),(0,e._)`${r.default.vErrors}.push(${$})`),g.code((0,e._)`${r.default.errors}++`)}function u(g,y){const{gen:$,validateName:S,schemaEnv:N}=g;N.$async?$.throw((0,e._)`new ${g.ValidationError}(${y})`):($.assign((0,e._)`${S}.errors`,y),$.return(!1))}const l={keyword:new e.Name("keyword"),schemaPath:new e.Name("schemaPath"),params:new e.Name("params"),propertyName:new e.Name("propertyName"),message:new e.Name("message"),schema:new e.Name("schema"),parentSchema:new e.Name("parentSchema")};function f(g,y,$){const{createErrors:S}=g.it;return S===!1?(0,e._)`{}`:m(g,y,$)}function m(g,y,$={}){const{gen:S,it:N}=g,k=[p(N,$),d(g,$)];return v(g,y,k),S.object(...k)}function p({errorPath:g},{instancePath:y}){const $=y?(0,e.str)`${g}${(0,n.getErrorPath)(y,n.Type.Str)}`:g;return[r.default.instancePath,(0,e.strConcat)(r.default.instancePath,$)]}function d({keyword:g,it:{errSchemaPath:y}},{schemaPath:$,parentSchema:S}){let N=S?y:(0,e.str)`${y}/${g}`;return $&&(N=(0,e.str)`${N}${(0,n.getErrorPath)($,n.Type.Str)}`),[l.schemaPath,N]}function v(g,{params:y,message:$},S){const{keyword:N,data:k,schemaValue:C,it:F}=g,{opts:ee,propertyName:ae,topSchemaRef:me,schemaPath:qt}=F;S.push([l.keyword,N],[l.params,typeof y=="function"?y(g):y||(0,e._)`{}`]),ee.messages&&S.push([l.message,typeof $=="function"?$(g):$]),ee.verbose&&S.push([l.schema,C],[l.parentSchema,(0,e._)`${me}${qt}`],[r.default.data,k]),ae&&S.push([l.propertyName,ae])}})(yn);Object.defineProperty(Ct,"__esModule",{value:!0});Ct.boolOrEmptySchema=Ct.topBoolOrEmptySchema=void 0;const fy=yn,dy=U,py=xe,hy={message:"boolean schema is false"};function my(t){const{gen:e,schema:n,validateName:r}=t;n===!1?ul(t,!1):typeof n=="object"&&n.$async===!0?e.return(py.default.data):(e.assign((0,dy._)`${r}.errors`,null),e.return(!0))}Ct.topBoolOrEmptySchema=my;function gy(t,e){const{gen:n,schema:r}=t;r===!1?(n.var(e,!1),ul(t)):n.var(e,!0)}Ct.boolOrEmptySchema=gy;function ul(t,e){const{gen:n,data:r}=t,s={gen:n,keyword:"false schema",data:r,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:t};(0,fy.reportError)(s,hy,void 0,e)}var te={},mt={};Object.defineProperty(mt,"__esModule",{value:!0});mt.getRules=mt.isJSONType=void 0;const yy=["string","number","integer","boolean","null","object","array"],vy=new Set(yy);function $y(t){return typeof t=="string"&&vy.has(t)}mt.isJSONType=$y;function wy(){const t={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...t,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},t.number,t.string,t.array,t.object],post:{rules:[]},all:{},keywords:{}}}mt.getRules=wy;var Le={};Object.defineProperty(Le,"__esModule",{value:!0});Le.shouldUseRule=Le.shouldUseGroup=Le.schemaHasRulesForType=void 0;function by({schema:t,self:e},n){const r=e.RULES.types[n];return r&&r!==!0&&ll(t,r)}Le.schemaHasRulesForType=by;function ll(t,e){return e.rules.some(n=>fl(t,n))}Le.shouldUseGroup=ll;function fl(t,e){var n;return t[e.keyword]!==void 0||((n=e.definition.implements)===null||n===void 0?void 0:n.some(r=>t[r]!==void 0))}Le.shouldUseRule=fl;Object.defineProperty(te,"__esModule",{value:!0});te.reportTypeError=te.checkDataTypes=te.checkDataType=te.coerceAndCheckDataType=te.getJSONTypes=te.getSchemaTypes=te.DataType=void 0;const Ey=mt,Sy=Le,Ny=yn,L=U,dl=j;var Pt;(function(t){t[t.Correct=0]="Correct",t[t.Wrong=1]="Wrong"})(Pt||(te.DataType=Pt={}));function Oy(t){const e=pl(t.type);if(e.includes("null")){if(t.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!e.length&&t.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');t.nullable===!0&&e.push("null")}return e}te.getSchemaTypes=Oy;function pl(t){const e=Array.isArray(t)?t:t?[t]:[];if(e.every(Ey.isJSONType))return e;throw new Error("type must be JSONType or JSONType[]: "+e.join(","))}te.getJSONTypes=pl;function _y(t,e){const{gen:n,data:r,opts:s}=t,o=ky(e,s.coerceTypes),i=e.length>0&&!(o.length===0&&e.length===1&&(0,Sy.schemaHasRulesForType)(t,e[0]));if(i){const a=go(e,r,s.strictNumbers,Pt.Wrong);n.if(a,()=>{o.length?Iy(t,e,o):yo(t)})}return i}te.coerceAndCheckDataType=_y;const hl=new Set(["string","number","integer","boolean","null"]);function ky(t,e){return e?t.filter(n=>hl.has(n)||e==="array"&&n==="array"):[]}function Iy(t,e,n){const{gen:r,data:s,opts:o}=t,i=r.let("dataType",(0,L._)`typeof ${s}`),a=r.let("coerced",(0,L._)`undefined`);o.coerceTypes==="array"&&r.if((0,L._)`${i} == 'object' && Array.isArray(${s}) && ${s}.length == 1`,()=>r.assign(s,(0,L._)`${s}[0]`).assign(i,(0,L._)`typeof ${s}`).if(go(e,s,o.strictNumbers),()=>r.assign(a,s))),r.if((0,L._)`${a} !== undefined`);for(const u of n)(hl.has(u)||u==="array"&&o.coerceTypes==="array")&&c(u);r.else(),yo(t),r.endIf(),r.if((0,L._)`${a} !== undefined`,()=>{r.assign(s,a),Ay(t,a)});function c(u){switch(u){case"string":r.elseIf((0,L._)`${i} == "number" || ${i} == "boolean"`).assign(a,(0,L._)`"" + ${s}`).elseIf((0,L._)`${s} === null`).assign(a,(0,L._)`""`);return;case"number":r.elseIf((0,L._)`${i} == "boolean" || ${s} === null
172
- || (${i} == "string" && ${s} && ${s} == +${s})`).assign(a,(0,L._)`+${s}`);return;case"integer":r.elseIf((0,L._)`${i} === "boolean" || ${s} === null
173
- || (${i} === "string" && ${s} && ${s} == +${s} && !(${s} % 1))`).assign(a,(0,L._)`+${s}`);return;case"boolean":r.elseIf((0,L._)`${s} === "false" || ${s} === 0 || ${s} === null`).assign(a,!1).elseIf((0,L._)`${s} === "true" || ${s} === 1`).assign(a,!0);return;case"null":r.elseIf((0,L._)`${s} === "" || ${s} === 0 || ${s} === false`),r.assign(a,null);return;case"array":r.elseIf((0,L._)`${i} === "string" || ${i} === "number"
174
- || ${i} === "boolean" || ${s} === null`).assign(a,(0,L._)`[${s}]`)}}}function Ay({gen:t,parentData:e,parentDataProperty:n},r){t.if((0,L._)`${e} !== undefined`,()=>t.assign((0,L._)`${e}[${n}]`,r))}function Ns(t,e,n,r=Pt.Correct){const s=r===Pt.Correct?L.operators.EQ:L.operators.NEQ;let o;switch(t){case"null":return(0,L._)`${e} ${s} null`;case"array":o=(0,L._)`Array.isArray(${e})`;break;case"object":o=(0,L._)`${e} && typeof ${e} == "object" && !Array.isArray(${e})`;break;case"integer":o=i((0,L._)`!(${e} % 1) && !isNaN(${e})`);break;case"number":o=i();break;default:return(0,L._)`typeof ${e} ${s} ${t}`}return r===Pt.Correct?o:(0,L.not)(o);function i(a=L.nil){return(0,L.and)((0,L._)`typeof ${e} == "number"`,a,n?(0,L._)`isFinite(${e})`:L.nil)}}te.checkDataType=Ns;function go(t,e,n,r){if(t.length===1)return Ns(t[0],e,n,r);let s;const o=(0,dl.toHash)(t);if(o.array&&o.object){const i=(0,L._)`typeof ${e} != "object"`;s=o.null?i:(0,L._)`!${e} || ${i}`,delete o.null,delete o.array,delete o.object}else s=L.nil;o.number&&delete o.integer;for(const i in o)s=(0,L.and)(s,Ns(i,e,n,r));return s}te.checkDataTypes=go;const Py={message:({schema:t})=>`must be ${t}`,params:({schema:t,schemaValue:e})=>typeof t=="string"?(0,L._)`{type: ${t}}`:(0,L._)`{type: ${e}}`};function yo(t){const e=jy(t);(0,Ny.reportError)(e,Py)}te.reportTypeError=yo;function jy(t){const{gen:e,data:n,schema:r}=t,s=(0,dl.schemaRefOrVal)(t,r,"type");return{gen:e,keyword:"type",data:n,schema:r.type,schemaCode:s,schemaValue:s,parentSchema:r,params:{},it:t}}var pr={};Object.defineProperty(pr,"__esModule",{value:!0});pr.assignDefaults=void 0;const bt=U,xy=j;function Ty(t,e){const{properties:n,items:r}=t.schema;if(e==="object"&&n)for(const s in n)ga(t,s,n[s].default);else e==="array"&&Array.isArray(r)&&r.forEach((s,o)=>ga(t,o,s.default))}pr.assignDefaults=Ty;function ga(t,e,n){const{gen:r,compositeRule:s,data:o,opts:i}=t;if(n===void 0)return;const a=(0,bt._)`${o}${(0,bt.getProperty)(e)}`;if(s){(0,xy.checkStrictMode)(t,`default is ignored for: ${a}`);return}let c=(0,bt._)`${a} === undefined`;i.useDefaults==="empty"&&(c=(0,bt._)`${c} || ${a} === null || ${a} === ""`),r.if(c,(0,bt._)`${a} = ${(0,bt.stringify)(n)}`)}var Ae={},B={};Object.defineProperty(B,"__esModule",{value:!0});B.validateUnion=B.validateArray=B.usePattern=B.callValidateCode=B.schemaProperties=B.allSchemaProperties=B.noPropertyInData=B.propertyInData=B.isOwnProperty=B.hasPropFunc=B.reportMissingProp=B.checkMissingProp=B.checkReportMissingProp=void 0;const J=U,vo=j,Ke=xe,Cy=j;function Ry(t,e){const{gen:n,data:r,it:s}=t;n.if(wo(n,r,e,s.opts.ownProperties),()=>{t.setParams({missingProperty:(0,J._)`${e}`},!0),t.error()})}B.checkReportMissingProp=Ry;function My({gen:t,data:e,it:{opts:n}},r,s){return(0,J.or)(...r.map(o=>(0,J.and)(wo(t,e,o,n.ownProperties),(0,J._)`${s} = ${o}`)))}B.checkMissingProp=My;function Dy(t,e){t.setParams({missingProperty:e},!0),t.error()}B.reportMissingProp=Dy;function ml(t){return t.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,J._)`Object.prototype.hasOwnProperty`})}B.hasPropFunc=ml;function $o(t,e,n){return(0,J._)`${ml(t)}.call(${e}, ${n})`}B.isOwnProperty=$o;function Ly(t,e,n,r){const s=(0,J._)`${e}${(0,J.getProperty)(n)} !== undefined`;return r?(0,J._)`${s} && ${$o(t,e,n)}`:s}B.propertyInData=Ly;function wo(t,e,n,r){const s=(0,J._)`${e}${(0,J.getProperty)(n)} === undefined`;return r?(0,J.or)(s,(0,J.not)($o(t,e,n))):s}B.noPropertyInData=wo;function gl(t){return t?Object.keys(t).filter(e=>e!=="__proto__"):[]}B.allSchemaProperties=gl;function By(t,e){return gl(e).filter(n=>!(0,vo.alwaysValidSchema)(t,e[n]))}B.schemaProperties=By;function Uy({schemaCode:t,data:e,it:{gen:n,topSchemaRef:r,schemaPath:s,errorPath:o},it:i},a,c,u){const l=u?(0,J._)`${t}, ${e}, ${r}${s}`:e,f=[[Ke.default.instancePath,(0,J.strConcat)(Ke.default.instancePath,o)],[Ke.default.parentData,i.parentData],[Ke.default.parentDataProperty,i.parentDataProperty],[Ke.default.rootData,Ke.default.rootData]];i.opts.dynamicRef&&f.push([Ke.default.dynamicAnchors,Ke.default.dynamicAnchors]);const m=(0,J._)`${l}, ${n.object(...f)}`;return c!==J.nil?(0,J._)`${a}.call(${c}, ${m})`:(0,J._)`${a}(${m})`}B.callValidateCode=Uy;const Vy=(0,J._)`new RegExp`;function Fy({gen:t,it:{opts:e}},n){const r=e.unicodeRegExp?"u":"",{regExp:s}=e.code,o=s(n,r);return t.scopeValue("pattern",{key:o.toString(),ref:o,code:(0,J._)`${s.code==="new RegExp"?Vy:(0,Cy.useFunc)(t,s)}(${n}, ${r})`})}B.usePattern=Fy;function qy(t){const{gen:e,data:n,keyword:r,it:s}=t,o=e.name("valid");if(s.allErrors){const a=e.let("valid",!0);return i(()=>e.assign(a,!1)),a}return e.var(o,!0),i(()=>e.break()),o;function i(a){const c=e.const("len",(0,J._)`${n}.length`);e.forRange("i",0,c,u=>{t.subschema({keyword:r,dataProp:u,dataPropType:vo.Type.Num},o),e.if((0,J.not)(o),a)})}}B.validateArray=qy;function Ky(t){const{gen:e,schema:n,keyword:r,it:s}=t;if(!Array.isArray(n))throw new Error("ajv implementation error");if(n.some(a=>(0,vo.alwaysValidSchema)(s,a))&&!s.opts.unevaluated)return;const o=e.let("valid",!1),i=e.name("_valid");e.block(()=>n.forEach((a,c)=>{const u=t.subschema({keyword:r,schemaProp:c,compositeRule:!0},i);e.assign(o,(0,J._)`${o} || ${i}`),t.mergeValidEvaluated(u,i)||e.if((0,J.not)(o))})),t.result(o,()=>t.reset(),()=>t.error(!0))}B.validateUnion=Ky;Object.defineProperty(Ae,"__esModule",{value:!0});Ae.validateKeywordUsage=Ae.validSchemaType=Ae.funcKeywordCode=Ae.macroKeywordCode=void 0;const le=U,st=xe,zy=B,Gy=yn;function Wy(t,e){const{gen:n,keyword:r,schema:s,parentSchema:o,it:i}=t,a=e.macro.call(i.self,s,o,i),c=yl(n,r,a);i.opts.validateSchema!==!1&&i.self.validateSchema(a,!0);const u=n.name("valid");t.subschema({schema:a,schemaPath:le.nil,errSchemaPath:`${i.errSchemaPath}/${r}`,topSchemaRef:c,compositeRule:!0},u),t.pass(u,()=>t.error(!0))}Ae.macroKeywordCode=Wy;function Hy(t,e){var n;const{gen:r,keyword:s,schema:o,parentSchema:i,$data:a,it:c}=t;Qy(c,e);const u=!a&&e.compile?e.compile.call(c.self,o,i,c):e.validate,l=yl(r,s,u),f=r.let("valid");t.block$data(f,m),t.ok((n=e.valid)!==null&&n!==void 0?n:f);function m(){if(e.errors===!1)v(),e.modifying&&ya(t),g(()=>t.error());else{const y=e.async?p():d();e.modifying&&ya(t),g(()=>Jy(t,y))}}function p(){const y=r.let("ruleErrs",null);return r.try(()=>v((0,le._)`await `),$=>r.assign(f,!1).if((0,le._)`${$} instanceof ${c.ValidationError}`,()=>r.assign(y,(0,le._)`${$}.errors`),()=>r.throw($))),y}function d(){const y=(0,le._)`${l}.errors`;return r.assign(y,null),v(le.nil),y}function v(y=e.async?(0,le._)`await `:le.nil){const $=c.opts.passContext?st.default.this:st.default.self,S=!("compile"in e&&!a||e.schema===!1);r.assign(f,(0,le._)`${y}${(0,zy.callValidateCode)(t,l,$,S)}`,e.modifying)}function g(y){var $;r.if((0,le.not)(($=e.valid)!==null&&$!==void 0?$:f),y)}}Ae.funcKeywordCode=Hy;function ya(t){const{gen:e,data:n,it:r}=t;e.if(r.parentData,()=>e.assign(n,(0,le._)`${r.parentData}[${r.parentDataProperty}]`))}function Jy(t,e){const{gen:n}=t;n.if((0,le._)`Array.isArray(${e})`,()=>{n.assign(st.default.vErrors,(0,le._)`${st.default.vErrors} === null ? ${e} : ${st.default.vErrors}.concat(${e})`).assign(st.default.errors,(0,le._)`${st.default.vErrors}.length`),(0,Gy.extendErrors)(t)},()=>t.error())}function Qy({schemaEnv:t},e){if(e.async&&!t.$async)throw new Error("async keyword in sync schema")}function yl(t,e,n){if(n===void 0)throw new Error(`keyword "${e}" failed to compile`);return t.scopeValue("keyword",typeof n=="function"?{ref:n}:{ref:n,code:(0,le.stringify)(n)})}function Yy(t,e,n=!1){return!e.length||e.some(r=>r==="array"?Array.isArray(t):r==="object"?t&&typeof t=="object"&&!Array.isArray(t):typeof t==r||n&&typeof t>"u")}Ae.validSchemaType=Yy;function Xy({schema:t,opts:e,self:n,errSchemaPath:r},s,o){if(Array.isArray(s.keyword)?!s.keyword.includes(o):s.keyword!==o)throw new Error("ajv implementation error");const i=s.dependencies;if(i!=null&&i.some(a=>!Object.prototype.hasOwnProperty.call(t,a)))throw new Error(`parent schema must have dependencies of ${o}: ${i.join(",")}`);if(s.validateSchema&&!s.validateSchema(t[o])){const a=`keyword "${o}" value is invalid at path "${r}": `+n.errorsText(s.validateSchema.errors);if(e.validateSchema==="log")n.logger.error(a);else throw new Error(a)}}Ae.validateKeywordUsage=Xy;var Ye={};Object.defineProperty(Ye,"__esModule",{value:!0});Ye.extendSubschemaMode=Ye.extendSubschemaData=Ye.getSubschema=void 0;const ke=U,vl=j;function Zy(t,{keyword:e,schemaProp:n,schema:r,schemaPath:s,errSchemaPath:o,topSchemaRef:i}){if(e!==void 0&&r!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(e!==void 0){const a=t.schema[e];return n===void 0?{schema:a,schemaPath:(0,ke._)`${t.schemaPath}${(0,ke.getProperty)(e)}`,errSchemaPath:`${t.errSchemaPath}/${e}`}:{schema:a[n],schemaPath:(0,ke._)`${t.schemaPath}${(0,ke.getProperty)(e)}${(0,ke.getProperty)(n)}`,errSchemaPath:`${t.errSchemaPath}/${e}/${(0,vl.escapeFragment)(n)}`}}if(r!==void 0){if(s===void 0||o===void 0||i===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:r,schemaPath:s,topSchemaRef:i,errSchemaPath:o}}throw new Error('either "keyword" or "schema" must be passed')}Ye.getSubschema=Zy;function ev(t,e,{dataProp:n,dataPropType:r,data:s,dataTypes:o,propertyName:i}){if(s!==void 0&&n!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');const{gen:a}=e;if(n!==void 0){const{errorPath:u,dataPathArr:l,opts:f}=e,m=a.let("data",(0,ke._)`${e.data}${(0,ke.getProperty)(n)}`,!0);c(m),t.errorPath=(0,ke.str)`${u}${(0,vl.getErrorPath)(n,r,f.jsPropertySyntax)}`,t.parentDataProperty=(0,ke._)`${n}`,t.dataPathArr=[...l,t.parentDataProperty]}if(s!==void 0){const u=s instanceof ke.Name?s:a.let("data",s,!0);c(u),i!==void 0&&(t.propertyName=i)}o&&(t.dataTypes=o);function c(u){t.data=u,t.dataLevel=e.dataLevel+1,t.dataTypes=[],e.definedProperties=new Set,t.parentData=e.data,t.dataNames=[...e.dataNames,u]}}Ye.extendSubschemaData=ev;function tv(t,{jtdDiscriminator:e,jtdMetadata:n,compositeRule:r,createErrors:s,allErrors:o}){r!==void 0&&(t.compositeRule=r),s!==void 0&&(t.createErrors=s),o!==void 0&&(t.allErrors=o),t.jtdDiscriminator=e,t.jtdMetadata=n}Ye.extendSubschemaMode=tv;var oe={},$l=function t(e,n){if(e===n)return!0;if(e&&n&&typeof e=="object"&&typeof n=="object"){if(e.constructor!==n.constructor)return!1;var r,s,o;if(Array.isArray(e)){if(r=e.length,r!=n.length)return!1;for(s=r;s--!==0;)if(!t(e[s],n[s]))return!1;return!0}if(e.constructor===RegExp)return e.source===n.source&&e.flags===n.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===n.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===n.toString();if(o=Object.keys(e),r=o.length,r!==Object.keys(n).length)return!1;for(s=r;s--!==0;)if(!Object.prototype.hasOwnProperty.call(n,o[s]))return!1;for(s=r;s--!==0;){var i=o[s];if(!t(e[i],n[i]))return!1}return!0}return e!==e&&n!==n},wl={exports:{}},Je=wl.exports=function(t,e,n){typeof e=="function"&&(n=e,e={}),n=e.cb||n;var r=typeof n=="function"?n:n.pre||function(){},s=n.post||function(){};Kn(e,r,s,t,"",t)};Je.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};Je.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};Je.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};Je.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function Kn(t,e,n,r,s,o,i,a,c,u){if(r&&typeof r=="object"&&!Array.isArray(r)){e(r,s,o,i,a,c,u);for(var l in r){var f=r[l];if(Array.isArray(f)){if(l in Je.arrayKeywords)for(var m=0;m<f.length;m++)Kn(t,e,n,f[m],s+"/"+l+"/"+m,o,s,l,r,m)}else if(l in Je.propsKeywords){if(f&&typeof f=="object")for(var p in f)Kn(t,e,n,f[p],s+"/"+l+"/"+nv(p),o,s,l,r,p)}else(l in Je.keywords||t.allKeys&&!(l in Je.skipKeywords))&&Kn(t,e,n,f,s+"/"+l,o,s,l,r)}n(r,s,o,i,a,c,u)}}function nv(t){return t.replace(/~/g,"~0").replace(/\//g,"~1")}var rv=wl.exports;Object.defineProperty(oe,"__esModule",{value:!0});oe.getSchemaRefs=oe.resolveUrl=oe.normalizeId=oe._getFullPath=oe.getFullPath=oe.inlineRef=void 0;const sv=j,ov=$l,iv=rv,av=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function cv(t,e=!0){return typeof t=="boolean"?!0:e===!0?!Os(t):e?bl(t)<=e:!1}oe.inlineRef=cv;const uv=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function Os(t){for(const e in t){if(uv.has(e))return!0;const n=t[e];if(Array.isArray(n)&&n.some(Os)||typeof n=="object"&&Os(n))return!0}return!1}function bl(t){let e=0;for(const n in t)if(n==="$ref"||(e++,!av.has(n)&&(typeof t[n]=="object"&&(0,sv.eachItem)(t[n],r=>e+=bl(r)),e===1/0)))return 1/0;return e}function El(t,e="",n){n!==!1&&(e=jt(e));const r=t.parse(e);return Sl(t,r)}oe.getFullPath=El;function Sl(t,e){return t.serialize(e).split("#")[0]+"#"}oe._getFullPath=Sl;const lv=/#\/?$/;function jt(t){return t?t.replace(lv,""):""}oe.normalizeId=jt;function fv(t,e,n){return n=jt(n),t.resolve(e,n)}oe.resolveUrl=fv;const dv=/^[a-z_][-a-z0-9._]*$/i;function pv(t,e){if(typeof t=="boolean")return{};const{schemaId:n,uriResolver:r}=this.opts,s=jt(t[n]||e),o={"":s},i=El(r,s,!1),a={},c=new Set;return iv(t,{allKeys:!0},(f,m,p,d)=>{if(d===void 0)return;const v=i+m;let g=o[d];typeof f[n]=="string"&&(g=y.call(this,f[n])),$.call(this,f.$anchor),$.call(this,f.$dynamicAnchor),o[m]=g;function y(S){const N=this.opts.uriResolver.resolve;if(S=jt(g?N(g,S):S),c.has(S))throw l(S);c.add(S);let k=this.refs[S];return typeof k=="string"&&(k=this.refs[k]),typeof k=="object"?u(f,k.schema,S):S!==jt(v)&&(S[0]==="#"?(u(f,a[S],S),a[S]=f):this.refs[S]=v),S}function $(S){if(typeof S=="string"){if(!dv.test(S))throw new Error(`invalid anchor "${S}"`);y.call(this,`#${S}`)}}}),a;function u(f,m,p){if(m!==void 0&&!ov(f,m))throw l(p)}function l(f){return new Error(`reference "${f}" resolves to more than one schema`)}}oe.getSchemaRefs=pv;Object.defineProperty(Ne,"__esModule",{value:!0});Ne.getData=Ne.KeywordCxt=Ne.validateFunctionCode=void 0;const Nl=Ct,va=te,bo=Le,Xn=te,hv=pr,rn=Ae,Wr=Ye,x=U,M=xe,mv=oe,Be=j,Ht=yn;function gv(t){if(kl(t)&&(Il(t),_l(t))){$v(t);return}Ol(t,()=>(0,Nl.topBoolOrEmptySchema)(t))}Ne.validateFunctionCode=gv;function Ol({gen:t,validateName:e,schema:n,schemaEnv:r,opts:s},o){s.code.es5?t.func(e,(0,x._)`${M.default.data}, ${M.default.valCxt}`,r.$async,()=>{t.code((0,x._)`"use strict"; ${$a(n,s)}`),vv(t,s),t.code(o)}):t.func(e,(0,x._)`${M.default.data}, ${yv(s)}`,r.$async,()=>t.code($a(n,s)).code(o))}function yv(t){return(0,x._)`{${M.default.instancePath}="", ${M.default.parentData}, ${M.default.parentDataProperty}, ${M.default.rootData}=${M.default.data}${t.dynamicRef?(0,x._)`, ${M.default.dynamicAnchors}={}`:x.nil}}={}`}function vv(t,e){t.if(M.default.valCxt,()=>{t.var(M.default.instancePath,(0,x._)`${M.default.valCxt}.${M.default.instancePath}`),t.var(M.default.parentData,(0,x._)`${M.default.valCxt}.${M.default.parentData}`),t.var(M.default.parentDataProperty,(0,x._)`${M.default.valCxt}.${M.default.parentDataProperty}`),t.var(M.default.rootData,(0,x._)`${M.default.valCxt}.${M.default.rootData}`),e.dynamicRef&&t.var(M.default.dynamicAnchors,(0,x._)`${M.default.valCxt}.${M.default.dynamicAnchors}`)},()=>{t.var(M.default.instancePath,(0,x._)`""`),t.var(M.default.parentData,(0,x._)`undefined`),t.var(M.default.parentDataProperty,(0,x._)`undefined`),t.var(M.default.rootData,M.default.data),e.dynamicRef&&t.var(M.default.dynamicAnchors,(0,x._)`{}`)})}function $v(t){const{schema:e,opts:n,gen:r}=t;Ol(t,()=>{n.$comment&&e.$comment&&Pl(t),Nv(t),r.let(M.default.vErrors,null),r.let(M.default.errors,0),n.unevaluated&&wv(t),Al(t),kv(t)})}function wv(t){const{gen:e,validateName:n}=t;t.evaluated=e.const("evaluated",(0,x._)`${n}.evaluated`),e.if((0,x._)`${t.evaluated}.dynamicProps`,()=>e.assign((0,x._)`${t.evaluated}.props`,(0,x._)`undefined`)),e.if((0,x._)`${t.evaluated}.dynamicItems`,()=>e.assign((0,x._)`${t.evaluated}.items`,(0,x._)`undefined`))}function $a(t,e){const n=typeof t=="object"&&t[e.schemaId];return n&&(e.code.source||e.code.process)?(0,x._)`/*# sourceURL=${n} */`:x.nil}function bv(t,e){if(kl(t)&&(Il(t),_l(t))){Ev(t,e);return}(0,Nl.boolOrEmptySchema)(t,e)}function _l({schema:t,self:e}){if(typeof t=="boolean")return!t;for(const n in t)if(e.RULES.all[n])return!0;return!1}function kl(t){return typeof t.schema!="boolean"}function Ev(t,e){const{schema:n,gen:r,opts:s}=t;s.$comment&&n.$comment&&Pl(t),Ov(t),_v(t);const o=r.const("_errs",M.default.errors);Al(t,o),r.var(e,(0,x._)`${o} === ${M.default.errors}`)}function Il(t){(0,Be.checkUnknownRules)(t),Sv(t)}function Al(t,e){if(t.opts.jtd)return wa(t,[],!1,e);const n=(0,va.getSchemaTypes)(t.schema),r=(0,va.coerceAndCheckDataType)(t,n);wa(t,n,!r,e)}function Sv(t){const{schema:e,errSchemaPath:n,opts:r,self:s}=t;e.$ref&&r.ignoreKeywordsWithRef&&(0,Be.schemaHasRulesButRef)(e,s.RULES)&&s.logger.warn(`$ref: keywords ignored in schema at path "${n}"`)}function Nv(t){const{schema:e,opts:n}=t;e.default!==void 0&&n.useDefaults&&n.strictSchema&&(0,Be.checkStrictMode)(t,"default is ignored in the schema root")}function Ov(t){const e=t.schema[t.opts.schemaId];e&&(t.baseId=(0,mv.resolveUrl)(t.opts.uriResolver,t.baseId,e))}function _v(t){if(t.schema.$async&&!t.schemaEnv.$async)throw new Error("async schema in sync schema")}function Pl({gen:t,schemaEnv:e,schema:n,errSchemaPath:r,opts:s}){const o=n.$comment;if(s.$comment===!0)t.code((0,x._)`${M.default.self}.logger.log(${o})`);else if(typeof s.$comment=="function"){const i=(0,x.str)`${r}/$comment`,a=t.scopeValue("root",{ref:e.root});t.code((0,x._)`${M.default.self}.opts.$comment(${o}, ${i}, ${a}.schema)`)}}function kv(t){const{gen:e,schemaEnv:n,validateName:r,ValidationError:s,opts:o}=t;n.$async?e.if((0,x._)`${M.default.errors} === 0`,()=>e.return(M.default.data),()=>e.throw((0,x._)`new ${s}(${M.default.vErrors})`)):(e.assign((0,x._)`${r}.errors`,M.default.vErrors),o.unevaluated&&Iv(t),e.return((0,x._)`${M.default.errors} === 0`))}function Iv({gen:t,evaluated:e,props:n,items:r}){n instanceof x.Name&&t.assign((0,x._)`${e}.props`,n),r instanceof x.Name&&t.assign((0,x._)`${e}.items`,r)}function wa(t,e,n,r){const{gen:s,schema:o,data:i,allErrors:a,opts:c,self:u}=t,{RULES:l}=u;if(o.$ref&&(c.ignoreKeywordsWithRef||!(0,Be.schemaHasRulesButRef)(o,l))){s.block(()=>Tl(t,"$ref",l.all.$ref.definition));return}c.jtd||Av(t,e),s.block(()=>{for(const m of l.rules)f(m);f(l.post)});function f(m){(0,bo.shouldUseGroup)(o,m)&&(m.type?(s.if((0,Xn.checkDataType)(m.type,i,c.strictNumbers)),ba(t,m),e.length===1&&e[0]===m.type&&n&&(s.else(),(0,Xn.reportTypeError)(t)),s.endIf()):ba(t,m),a||s.if((0,x._)`${M.default.errors} === ${r||0}`))}}function ba(t,e){const{gen:n,schema:r,opts:{useDefaults:s}}=t;s&&(0,hv.assignDefaults)(t,e.type),n.block(()=>{for(const o of e.rules)(0,bo.shouldUseRule)(r,o)&&Tl(t,o.keyword,o.definition,e.type)})}function Av(t,e){t.schemaEnv.meta||!t.opts.strictTypes||(Pv(t,e),t.opts.allowUnionTypes||jv(t,e),xv(t,t.dataTypes))}function Pv(t,e){if(e.length){if(!t.dataTypes.length){t.dataTypes=e;return}e.forEach(n=>{jl(t.dataTypes,n)||Eo(t,`type "${n}" not allowed by context "${t.dataTypes.join(",")}"`)}),Cv(t,e)}}function jv(t,e){e.length>1&&!(e.length===2&&e.includes("null"))&&Eo(t,"use allowUnionTypes to allow union type keyword")}function xv(t,e){const n=t.self.RULES.all;for(const r in n){const s=n[r];if(typeof s=="object"&&(0,bo.shouldUseRule)(t.schema,s)){const{type:o}=s.definition;o.length&&!o.some(i=>Tv(e,i))&&Eo(t,`missing type "${o.join(",")}" for keyword "${r}"`)}}}function Tv(t,e){return t.includes(e)||e==="number"&&t.includes("integer")}function jl(t,e){return t.includes(e)||e==="integer"&&t.includes("number")}function Cv(t,e){const n=[];for(const r of t.dataTypes)jl(e,r)?n.push(r):e.includes("integer")&&r==="number"&&n.push("integer");t.dataTypes=n}function Eo(t,e){const n=t.schemaEnv.baseId+t.errSchemaPath;e+=` at "${n}" (strictTypes)`,(0,Be.checkStrictMode)(t,e,t.opts.strictTypes)}class xl{constructor(e,n,r){if((0,rn.validateKeywordUsage)(e,n,r),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=r,this.data=e.data,this.schema=e.schema[r],this.$data=n.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,Be.schemaRefOrVal)(e,this.schema,r,this.$data),this.schemaType=n.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=n,this.$data)this.schemaCode=e.gen.const("vSchema",Cl(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,rn.validSchemaType)(this.schema,n.schemaType,n.allowUndefined))throw new Error(`${r} value must be ${JSON.stringify(n.schemaType)}`);("code"in n?n.trackErrors:n.errors!==!1)&&(this.errsCount=e.gen.const("_errs",M.default.errors))}result(e,n,r){this.failResult((0,x.not)(e),n,r)}failResult(e,n,r){this.gen.if(e),r?r():this.error(),n?(this.gen.else(),n(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(e,n){this.failResult((0,x.not)(e),void 0,n)}fail(e){if(e===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(e),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(e){if(!this.$data)return this.fail(e);const{schemaCode:n}=this;this.fail((0,x._)`${n} !== undefined && (${(0,x.or)(this.invalid$data(),e)})`)}error(e,n,r){if(n){this.setParams(n),this._error(e,r),this.setParams({});return}this._error(e,r)}_error(e,n){(e?Ht.reportExtraError:Ht.reportError)(this,this.def.error,n)}$dataError(){(0,Ht.reportError)(this,this.def.$dataError||Ht.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,Ht.resetErrorsCount)(this.gen,this.errsCount)}ok(e){this.allErrors||this.gen.if(e)}setParams(e,n){n?Object.assign(this.params,e):this.params=e}block$data(e,n,r=x.nil){this.gen.block(()=>{this.check$data(e,r),n()})}check$data(e=x.nil,n=x.nil){if(!this.$data)return;const{gen:r,schemaCode:s,schemaType:o,def:i}=this;r.if((0,x.or)((0,x._)`${s} === undefined`,n)),e!==x.nil&&r.assign(e,!0),(o.length||i.validateSchema)&&(r.elseIf(this.invalid$data()),this.$dataError(),e!==x.nil&&r.assign(e,!1)),r.else()}invalid$data(){const{gen:e,schemaCode:n,schemaType:r,def:s,it:o}=this;return(0,x.or)(i(),a());function i(){if(r.length){if(!(n instanceof x.Name))throw new Error("ajv implementation error");const c=Array.isArray(r)?r:[r];return(0,x._)`${(0,Xn.checkDataTypes)(c,n,o.opts.strictNumbers,Xn.DataType.Wrong)}`}return x.nil}function a(){if(s.validateSchema){const c=e.scopeValue("validate$data",{ref:s.validateSchema});return(0,x._)`!${c}(${n})`}return x.nil}}subschema(e,n){const r=(0,Wr.getSubschema)(this.it,e);(0,Wr.extendSubschemaData)(r,this.it,e),(0,Wr.extendSubschemaMode)(r,e);const s={...this.it,...r,items:void 0,props:void 0};return bv(s,n),s}mergeEvaluated(e,n){const{it:r,gen:s}=this;r.opts.unevaluated&&(r.props!==!0&&e.props!==void 0&&(r.props=Be.mergeEvaluated.props(s,e.props,r.props,n)),r.items!==!0&&e.items!==void 0&&(r.items=Be.mergeEvaluated.items(s,e.items,r.items,n)))}mergeValidEvaluated(e,n){const{it:r,gen:s}=this;if(r.opts.unevaluated&&(r.props!==!0||r.items!==!0))return s.if(n,()=>this.mergeEvaluated(e,x.Name)),!0}}Ne.KeywordCxt=xl;function Tl(t,e,n,r){const s=new xl(t,n,e);"code"in n?n.code(s,r):s.$data&&n.validate?(0,rn.funcKeywordCode)(s,n):"macro"in n?(0,rn.macroKeywordCode)(s,n):(n.compile||n.validate)&&(0,rn.funcKeywordCode)(s,n)}const Rv=/^\/(?:[^~]|~0|~1)*$/,Mv=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function Cl(t,{dataLevel:e,dataNames:n,dataPathArr:r}){let s,o;if(t==="")return M.default.rootData;if(t[0]==="/"){if(!Rv.test(t))throw new Error(`Invalid JSON-pointer: ${t}`);s=t,o=M.default.rootData}else{const u=Mv.exec(t);if(!u)throw new Error(`Invalid JSON-pointer: ${t}`);const l=+u[1];if(s=u[2],s==="#"){if(l>=e)throw new Error(c("property/index",l));return r[e-l]}if(l>e)throw new Error(c("data",l));if(o=n[e-l],!s)return o}let i=o;const a=s.split("/");for(const u of a)u&&(o=(0,x._)`${o}${(0,x.getProperty)((0,Be.unescapeJsonPointer)(u))}`,i=(0,x._)`${i} && ${o}`);return i;function c(u,l){return`Cannot access ${u} ${l} levels up, current level is ${e}`}}Ne.getData=Cl;var vn={};Object.defineProperty(vn,"__esModule",{value:!0});let Dv=class extends Error{constructor(t){super("validation failed"),this.errors=t,this.ajv=this.validation=!0}};vn.default=Dv;var Ut={};Object.defineProperty(Ut,"__esModule",{value:!0});const Hr=oe;class Lv extends Error{constructor(e,n,r,s){super(s||`can't resolve reference ${r} from id ${n}`),this.missingRef=(0,Hr.resolveUrl)(e,n,r),this.missingSchema=(0,Hr.normalizeId)((0,Hr.getFullPath)(e,this.missingRef))}}Ut.default=Lv;var he={};Object.defineProperty(he,"__esModule",{value:!0});he.resolveSchema=he.getCompilingSchema=he.resolveRef=he.compileSchema=he.SchemaEnv=void 0;const we=U,Bv=vn,nt=xe,Ee=oe,Ea=j,Uv=Ne;class hr{constructor(e){var n;this.refs={},this.dynamicAnchors={};let r;typeof e.schema=="object"&&(r=e.schema),this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=(n=e.baseId)!==null&&n!==void 0?n:(0,Ee.normalizeId)(r==null?void 0:r[e.schemaId||"$id"]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=r==null?void 0:r.$async,this.refs={}}}he.SchemaEnv=hr;function So(t){const e=Rl.call(this,t);if(e)return e;const n=(0,Ee.getFullPath)(this.opts.uriResolver,t.root.baseId),{es5:r,lines:s}=this.opts.code,{ownProperties:o}=this.opts,i=new we.CodeGen(this.scope,{es5:r,lines:s,ownProperties:o});let a;t.$async&&(a=i.scopeValue("Error",{ref:Bv.default,code:(0,we._)`require("ajv/dist/runtime/validation_error").default`}));const c=i.scopeName("validate");t.validateName=c;const u={gen:i,allErrors:this.opts.allErrors,data:nt.default.data,parentData:nt.default.parentData,parentDataProperty:nt.default.parentDataProperty,dataNames:[nt.default.data],dataPathArr:[we.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:i.scopeValue("schema",this.opts.code.source===!0?{ref:t.schema,code:(0,we.stringify)(t.schema)}:{ref:t.schema}),validateName:c,ValidationError:a,schema:t.schema,schemaEnv:t,rootId:n,baseId:t.baseId||n,schemaPath:we.nil,errSchemaPath:t.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,we._)`""`,opts:this.opts,self:this};let l;try{this._compilations.add(t),(0,Uv.validateFunctionCode)(u),i.optimize(this.opts.code.optimize);const f=i.toString();l=`${i.scopeRefs(nt.default.scope)}return ${f}`,this.opts.code.process&&(l=this.opts.code.process(l,t));const m=new Function(`${nt.default.self}`,`${nt.default.scope}`,l)(this,this.scope.get());if(this.scope.value(c,{ref:m}),m.errors=null,m.schema=t.schema,m.schemaEnv=t,t.$async&&(m.$async=!0),this.opts.code.source===!0&&(m.source={validateName:c,validateCode:f,scopeValues:i._values}),this.opts.unevaluated){const{props:p,items:d}=u;m.evaluated={props:p instanceof we.Name?void 0:p,items:d instanceof we.Name?void 0:d,dynamicProps:p instanceof we.Name,dynamicItems:d instanceof we.Name},m.source&&(m.source.evaluated=(0,we.stringify)(m.evaluated))}return t.validate=m,t}catch(f){throw delete t.validate,delete t.validateName,l&&this.logger.error("Error compiling schema, function code:",l),f}finally{this._compilations.delete(t)}}he.compileSchema=So;function Vv(t,e,n){var r;n=(0,Ee.resolveUrl)(this.opts.uriResolver,e,n);const s=t.refs[n];if(s)return s;let o=Kv.call(this,t,n);if(o===void 0){const i=(r=t.localRefs)===null||r===void 0?void 0:r[n],{schemaId:a}=this.opts;i&&(o=new hr({schema:i,schemaId:a,root:t,baseId:e}))}if(o!==void 0)return t.refs[n]=Fv.call(this,o)}he.resolveRef=Vv;function Fv(t){return(0,Ee.inlineRef)(t.schema,this.opts.inlineRefs)?t.schema:t.validate?t:So.call(this,t)}function Rl(t){for(const e of this._compilations)if(qv(e,t))return e}he.getCompilingSchema=Rl;function qv(t,e){return t.schema===e.schema&&t.root===e.root&&t.baseId===e.baseId}function Kv(t,e){let n;for(;typeof(n=this.refs[e])=="string";)e=n;return n||this.schemas[e]||mr.call(this,t,e)}function mr(t,e){const n=this.opts.uriResolver.parse(e),r=(0,Ee._getFullPath)(this.opts.uriResolver,n);let s=(0,Ee.getFullPath)(this.opts.uriResolver,t.baseId,void 0);if(Object.keys(t.schema).length>0&&r===s)return Jr.call(this,n,t);const o=(0,Ee.normalizeId)(r),i=this.refs[o]||this.schemas[o];if(typeof i=="string"){const a=mr.call(this,t,i);return typeof(a==null?void 0:a.schema)!="object"?void 0:Jr.call(this,n,a)}if(typeof(i==null?void 0:i.schema)=="object"){if(i.validate||So.call(this,i),o===(0,Ee.normalizeId)(e)){const{schema:a}=i,{schemaId:c}=this.opts,u=a[c];return u&&(s=(0,Ee.resolveUrl)(this.opts.uriResolver,s,u)),new hr({schema:a,schemaId:c,root:t,baseId:s})}return Jr.call(this,n,i)}}he.resolveSchema=mr;const zv=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function Jr(t,{baseId:e,schema:n,root:r}){var s;if(((s=t.fragment)===null||s===void 0?void 0:s[0])!=="/")return;for(const a of t.fragment.slice(1).split("/")){if(typeof n=="boolean")return;const c=n[(0,Ea.unescapeFragment)(a)];if(c===void 0)return;n=c;const u=typeof n=="object"&&n[this.opts.schemaId];!zv.has(a)&&u&&(e=(0,Ee.resolveUrl)(this.opts.uriResolver,e,u))}let o;if(typeof n!="boolean"&&n.$ref&&!(0,Ea.schemaHasRulesButRef)(n,this.RULES)){const a=(0,Ee.resolveUrl)(this.opts.uriResolver,e,n.$ref);o=mr.call(this,r,a)}const{schemaId:i}=this.opts;if(o=o||new hr({schema:n,schemaId:i,root:r,baseId:e}),o.schema!==o.root.schema)return o}const Gv="https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",Wv="Meta-schema for $data reference (JSON AnySchema extension proposal)",Hv="object",Jv=["$data"],Qv={$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},Yv=!1,Xv={$id:Gv,description:Wv,type:Hv,required:Jv,properties:Qv,additionalProperties:Yv};var No={},gr={exports:{}};const Zv=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),Ml=RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u),Oo=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),Dl=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),e0=RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);function Ll(t){let e="",n=0,r=0;for(r=0;r<t.length;r++)if(n=t[r].charCodeAt(0),n!==48){if(!(n>=48&&n<=57||n>=65&&n<=70||n>=97&&n<=102))return"";e+=t[r];break}for(r+=1;r<t.length;r++){if(n=t[r].charCodeAt(0),!(n>=48&&n<=57||n>=65&&n<=70||n>=97&&n<=102))return"";e+=t[r]}return e}const t0=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function Sa(t){return t.length=0,!0}function n0(t,e,n){if(t.length){const r=Ll(t);if(r!=="")e.push(r);else return n.error=!0,!1;t.length=0}return!0}function r0(t){let e=0;const n={error:!1,address:"",zone:""},r=[],s=[];let o=!1,i=!1,a=n0;for(let c=0;c<t.length;c++){const u=t[c];if(!(u==="["||u==="]"))if(u===":"){if(o===!0&&(i=!0),!a(s,r,n))break;if(++e>7){n.error=!0;break}c>0&&t[c-1]===":"&&(o=!0),r.push(":");continue}else if(u==="%"){if(!a(s,r,n))break;a=Sa}else{s.push(u);continue}}return s.length&&(a===Sa?n.zone=s.join(""):i?r.push(s.join("")):r.push(Ll(s))),n.address=r.join(""),n}function Bl(t){if(s0(t,":")<2)return{host:t,isIPV6:!1};const e=r0(t);if(e.error)return{host:t,isIPV6:!1};{let n=e.address,r=e.address;return e.zone&&(n+="%"+e.zone,r+="%25"+e.zone),{host:n,isIPV6:!0,escapedHost:r}}}function s0(t,e){let n=0;for(let r=0;r<t.length;r++)t[r]===e&&n++;return n}function o0(t){let e=t;const n=[];let r=-1,s=0;for(;s=e.length;){if(s===1){if(e===".")break;if(e==="/"){n.push("/");break}else{n.push(e);break}}else if(s===2){if(e[0]==="."){if(e[1]===".")break;if(e[1]==="/"){e=e.slice(2);continue}}else if(e[0]==="/"&&(e[1]==="."||e[1]==="/")){n.push("/");break}}else if(s===3&&e==="/.."){n.length!==0&&n.pop(),n.push("/");break}if(e[0]==="."){if(e[1]==="."){if(e[2]==="/"){e=e.slice(3);continue}}else if(e[1]==="/"){e=e.slice(2);continue}}else if(e[0]==="/"&&e[1]==="."){if(e[2]==="/"){e=e.slice(2);continue}else if(e[2]==="."&&e[3]==="/"){e=e.slice(3),n.length!==0&&n.pop();continue}}if((r=e.indexOf("/",1))===-1){n.push(e);break}else n.push(e.slice(0,r)),e=e.slice(r)}return n.join("")}const i0={"@":"%40","/":"%2F","?":"%3F","#":"%23",":":"%3A"},a0=/[@/?#:]/g,c0=/[@/?#]/g;function Ul(t,e){const n=e?c0:a0;return n.lastIndex=0,t.replace(n,r=>i0[r])}function u0(t,e=!1){if(t.indexOf("%")===-1)return t;let n="";for(let r=0;r<t.length;r++){if(t[r]==="%"&&r+2<t.length){const s=t.slice(r+1,r+3);if(Oo(s)){const o=s.toUpperCase(),i=String.fromCharCode(parseInt(o,16));e&&Dl(i)?n+=i:n+="%"+o,r+=2;continue}}n+=t[r]}return n}function l0(t){let e="";for(let n=0;n<t.length;n++){if(t[n]==="%"&&n+2<t.length){const r=t.slice(n+1,n+3);if(Oo(r)){const s=r.toUpperCase(),o=String.fromCharCode(parseInt(s,16));o!=="."&&Dl(o)?e+=o:e+="%"+s,n+=2;continue}}e0(t[n])?e+=t[n]:e+=escape(t[n])}return e}function f0(t){let e="";for(let n=0;n<t.length;n++){if(t[n]==="%"&&n+2<t.length){const r=t.slice(n+1,n+3);if(Oo(r)){e+="%"+r.toUpperCase(),n+=2;continue}}e+=escape(t[n])}return e}function d0(t){const e=[];if(t.userinfo!==void 0&&(e.push(t.userinfo),e.push("@")),t.host!==void 0){let n=unescape(t.host);if(!Ml(n)){const r=Bl(n);r.isIPV6===!0?n=`[${r.escapedHost}]`:n=Ul(n,!1)}e.push(n)}return(typeof t.port=="number"||typeof t.port=="string")&&(e.push(":"),e.push(String(t.port))),e.length?e.join(""):void 0}var Vl={nonSimpleDomain:t0,recomposeAuthority:d0,reescapeHostDelimiters:Ul,normalizePercentEncoding:u0,normalizePathEncoding:l0,escapePreservingEscapes:f0,removeDotSegments:o0,isIPv4:Ml,isUUID:Zv,normalizeIPv6:Bl};const{isUUID:p0}=Vl,h0=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu;function Fl(t){return t.secure===!0?!0:t.secure===!1?!1:t.scheme?t.scheme.length===3&&(t.scheme[0]==="w"||t.scheme[0]==="W")&&(t.scheme[1]==="s"||t.scheme[1]==="S")&&(t.scheme[2]==="s"||t.scheme[2]==="S"):!1}function ql(t){return t.host||(t.error=t.error||"HTTP URIs must have a host."),t}function Kl(t){const e=String(t.scheme).toLowerCase()==="https";return(t.port===(e?443:80)||t.port==="")&&(t.port=void 0),t.path||(t.path="/"),t}function m0(t){return t.secure=Fl(t),t.resourceName=(t.path||"/")+(t.query?"?"+t.query:""),t.path=void 0,t.query=void 0,t}function g0(t){if((t.port===(Fl(t)?443:80)||t.port==="")&&(t.port=void 0),typeof t.secure=="boolean"&&(t.scheme=t.secure?"wss":"ws",t.secure=void 0),t.resourceName){const[e,n]=t.resourceName.split("?");t.path=e&&e!=="/"?e:void 0,t.query=n,t.resourceName=void 0}return t.fragment=void 0,t}function y0(t,e){if(!t.path)return t.error="URN can not be parsed",t;const n=t.path.match(h0);if(n){const r=e.scheme||t.scheme||"urn";t.nid=n[1].toLowerCase(),t.nss=n[2];const s=`${r}:${e.nid||t.nid}`,o=_o(s);t.path=void 0,o&&(t=o.parse(t,e))}else t.error=t.error||"URN can not be parsed.";return t}function v0(t,e){if(t.nid===void 0)throw new Error("URN without nid cannot be serialized");const n=e.scheme||t.scheme||"urn",r=t.nid.toLowerCase(),s=`${n}:${e.nid||r}`,o=_o(s);o&&(t=o.serialize(t,e));const i=t,a=t.nss;return i.path=`${r||e.nid}:${a}`,e.skipEscape=!0,i}function $0(t,e){const n=t;return n.uuid=n.nss,n.nss=void 0,!e.tolerant&&(!n.uuid||!p0(n.uuid))&&(n.error=n.error||"UUID is not valid."),n}function w0(t){const e=t;return e.nss=(t.uuid||"").toLowerCase(),e}const zl={scheme:"http",domainHost:!0,parse:ql,serialize:Kl},b0={scheme:"https",domainHost:zl.domainHost,parse:ql,serialize:Kl},zn={scheme:"ws",domainHost:!0,parse:m0,serialize:g0},E0={scheme:"wss",domainHost:zn.domainHost,parse:zn.parse,serialize:zn.serialize},S0={scheme:"urn",parse:y0,serialize:v0,skipNormalize:!0},N0={scheme:"urn:uuid",parse:$0,serialize:w0,skipNormalize:!0},Zn={http:zl,https:b0,ws:zn,wss:E0,urn:S0,"urn:uuid":N0};Object.setPrototypeOf(Zn,null);function _o(t){return t&&(Zn[t]||Zn[t.toLowerCase()])||void 0}var O0={SCHEMES:Zn,getSchemeHandler:_o};const{normalizeIPv6:_0,removeDotSegments:Xt,recomposeAuthority:k0,normalizePercentEncoding:I0,normalizePathEncoding:A0,escapePreservingEscapes:P0,reescapeHostDelimiters:j0,isIPv4:x0,nonSimpleDomain:T0}=Vl,{SCHEMES:C0,getSchemeHandler:Gl}=O0;function R0(t,e){return typeof t=="string"?t=U0(t,e):typeof t=="object"&&(t=Rt(gt(t,e),e)),t}function M0(t,e,n){const r=n?Object.assign({scheme:"null"},n):{scheme:"null"},s=Wl(Rt(t,r),Rt(e,r),r,!0);return r.skipEscape=!0,gt(s,r)}function Wl(t,e,n,r){const s={};return r||(t=Rt(gt(t,n),n),e=Rt(gt(e,n),n)),n=n||{},!n.tolerant&&e.scheme?(s.scheme=e.scheme,s.userinfo=e.userinfo,s.host=e.host,s.port=e.port,s.path=Xt(e.path||""),s.query=e.query):(e.userinfo!==void 0||e.host!==void 0||e.port!==void 0?(s.userinfo=e.userinfo,s.host=e.host,s.port=e.port,s.path=Xt(e.path||""),s.query=e.query):(e.path?(e.path[0]==="/"?s.path=Xt(e.path):((t.userinfo!==void 0||t.host!==void 0||t.port!==void 0)&&!t.path?s.path="/"+e.path:t.path?s.path=t.path.slice(0,t.path.lastIndexOf("/")+1)+e.path:s.path=e.path,s.path=Xt(s.path)),s.query=e.query):(s.path=t.path,e.query!==void 0?s.query=e.query:s.query=t.query),s.userinfo=t.userinfo,s.host=t.host,s.port=t.port),s.scheme=t.scheme),s.fragment=e.fragment,s}function D0(t,e,n){const r=Na(t,n),s=Na(e,n);return r!==void 0&&s!==void 0&&r.toLowerCase()===s.toLowerCase()}function gt(t,e){const n={host:t.host,scheme:t.scheme,userinfo:t.userinfo,port:t.port,path:t.path,query:t.query,nid:t.nid,nss:t.nss,uuid:t.uuid,fragment:t.fragment,reference:t.reference,resourceName:t.resourceName,secure:t.secure,error:""},r=Object.assign({},e),s=[],o=Gl(r.scheme||n.scheme);o&&o.serialize&&o.serialize(n,r),n.path!==void 0&&(r.skipEscape?n.path=I0(n.path):(n.path=P0(n.path),n.scheme!==void 0&&(n.path=n.path.split("%3A").join(":")))),r.reference!=="suffix"&&n.scheme&&s.push(n.scheme,":");const i=k0(n);if(i!==void 0&&(r.reference!=="suffix"&&s.push("//"),s.push(i),n.path&&n.path[0]!=="/"&&s.push("/")),n.path!==void 0){let a=n.path;!r.absolutePath&&(!o||!o.absolutePath)&&(a=Xt(a)),i===void 0&&a[0]==="/"&&a[1]==="/"&&(a="/%2F"+a.slice(2)),s.push(a)}return n.query!==void 0&&s.push("?",n.query),n.fragment!==void 0&&s.push("#",n.fragment),s.join("")}const L0=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function B0(t,e){if(e[2]!==void 0&&t.path&&t.path[0]!=="/")return'URI path must start with "/" when authority is present.';if(typeof t.port=="number"&&(t.port<0||t.port>65535))return"URI port is malformed."}function Hl(t,e){const n=Object.assign({},e),r={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0};let s=!1,o=!1;n.reference==="suffix"&&(n.scheme?t=n.scheme+":"+t:t="//"+t);const i=t.match(L0);if(i){r.scheme=i[1],r.userinfo=i[3],r.host=i[4],r.port=parseInt(i[5],10),r.path=i[6]||"",r.query=i[7],r.fragment=i[8],isNaN(r.port)&&(r.port=i[5]);const a=B0(r,i);if(a!==void 0&&(r.error=r.error||a,s=!0),r.host)if(x0(r.host)===!1){const u=_0(r.host);r.host=u.host.toLowerCase(),o=u.isIPV6}else o=!0;r.scheme===void 0&&r.userinfo===void 0&&r.host===void 0&&r.port===void 0&&r.query===void 0&&!r.path?r.reference="same-document":r.scheme===void 0?r.reference="relative":r.fragment===void 0?r.reference="absolute":r.reference="uri",n.reference&&n.reference!=="suffix"&&n.reference!==r.reference&&(r.error=r.error||"URI is not a "+n.reference+" reference.");const c=Gl(n.scheme||r.scheme);if(!n.unicodeSupport&&(!c||!c.unicodeSupport)&&r.host&&(n.domainHost||c&&c.domainHost)&&o===!1&&T0(r.host))try{r.host=new URL("http://"+r.host).hostname}catch(u){r.error=r.error||"Host's domain name can not be converted to ASCII: "+u}if((!c||c&&!c.skipNormalize)&&(t.indexOf("%")!==-1&&(r.scheme!==void 0&&(r.scheme=unescape(r.scheme)),r.host!==void 0&&(r.host=j0(unescape(r.host),o))),r.path&&(r.path=A0(r.path)),r.fragment))try{r.fragment=encodeURI(decodeURIComponent(r.fragment))}catch{r.error=r.error||"URI malformed"}c&&c.parse&&c.parse(r,n)}else r.error=r.error||"URI can not be parsed.";return{parsed:r,malformedAuthorityOrPort:s}}function Rt(t,e){return Hl(t,e).parsed}function U0(t,e){return Jl(t,e).normalized}function Jl(t,e){const{parsed:n,malformedAuthorityOrPort:r}=Hl(t,e);return{normalized:r?t:gt(n,e),malformedAuthorityOrPort:r}}function Na(t,e){if(typeof t=="string"){const{normalized:n,malformedAuthorityOrPort:r}=Jl(t,e);return r?void 0:n}if(typeof t=="object")return gt(t,e)}const ko={SCHEMES:C0,normalize:R0,resolve:M0,resolveComponent:Wl,equal:D0,serialize:gt,parse:Rt};gr.exports=ko;gr.exports.default=ko;gr.exports.fastUri=ko;var V0=gr.exports;Object.defineProperty(No,"__esModule",{value:!0});const Ql=V0;Ql.code='require("ajv/dist/runtime/uri").default';No.default=Ql;(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.CodeGen=t.Name=t.nil=t.stringify=t.str=t._=t.KeywordCxt=void 0;var e=Ne;Object.defineProperty(t,"KeywordCxt",{enumerable:!0,get:function(){return e.KeywordCxt}});var n=U;Object.defineProperty(t,"_",{enumerable:!0,get:function(){return n._}}),Object.defineProperty(t,"str",{enumerable:!0,get:function(){return n.str}}),Object.defineProperty(t,"stringify",{enumerable:!0,get:function(){return n.stringify}}),Object.defineProperty(t,"nil",{enumerable:!0,get:function(){return n.nil}}),Object.defineProperty(t,"Name",{enumerable:!0,get:function(){return n.Name}}),Object.defineProperty(t,"CodeGen",{enumerable:!0,get:function(){return n.CodeGen}});const r=vn,s=Ut,o=mt,i=he,a=U,c=oe,u=te,l=j,f=Xv,m=No,p=(P,b)=>new RegExp(P,b);p.code="new RegExp";const d=["removeAdditional","useDefaults","coerceTypes"],v=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),g={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},y={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},$=200;function S(P){var b,I,E,h,w,O,T,R,z,K,ne,$t,br,Er,Sr,Nr,Or,_r,kr,Ir,Ar,Pr,jr,xr,Tr;const zt=P.strict,Cr=(b=P.code)===null||b===void 0?void 0:b.optimize,ii=Cr===!0||Cr===void 0?1:Cr||0,ai=(E=(I=P.code)===null||I===void 0?void 0:I.regExp)!==null&&E!==void 0?E:p,pf=(h=P.uriResolver)!==null&&h!==void 0?h:m.default;return{strictSchema:(O=(w=P.strictSchema)!==null&&w!==void 0?w:zt)!==null&&O!==void 0?O:!0,strictNumbers:(R=(T=P.strictNumbers)!==null&&T!==void 0?T:zt)!==null&&R!==void 0?R:!0,strictTypes:(K=(z=P.strictTypes)!==null&&z!==void 0?z:zt)!==null&&K!==void 0?K:"log",strictTuples:($t=(ne=P.strictTuples)!==null&&ne!==void 0?ne:zt)!==null&&$t!==void 0?$t:"log",strictRequired:(Er=(br=P.strictRequired)!==null&&br!==void 0?br:zt)!==null&&Er!==void 0?Er:!1,code:P.code?{...P.code,optimize:ii,regExp:ai}:{optimize:ii,regExp:ai},loopRequired:(Sr=P.loopRequired)!==null&&Sr!==void 0?Sr:$,loopEnum:(Nr=P.loopEnum)!==null&&Nr!==void 0?Nr:$,meta:(Or=P.meta)!==null&&Or!==void 0?Or:!0,messages:(_r=P.messages)!==null&&_r!==void 0?_r:!0,inlineRefs:(kr=P.inlineRefs)!==null&&kr!==void 0?kr:!0,schemaId:(Ir=P.schemaId)!==null&&Ir!==void 0?Ir:"$id",addUsedSchema:(Ar=P.addUsedSchema)!==null&&Ar!==void 0?Ar:!0,validateSchema:(Pr=P.validateSchema)!==null&&Pr!==void 0?Pr:!0,validateFormats:(jr=P.validateFormats)!==null&&jr!==void 0?jr:!0,unicodeRegExp:(xr=P.unicodeRegExp)!==null&&xr!==void 0?xr:!0,int32range:(Tr=P.int32range)!==null&&Tr!==void 0?Tr:!0,uriResolver:pf}}class N{constructor(b={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,b=this.opts={...b,...S(b)};const{es5:I,lines:E}=this.opts.code;this.scope=new a.ValueScope({scope:{},prefixes:v,es5:I,lines:E}),this.logger=Te(b.logger);const h=b.validateFormats;b.validateFormats=!1,this.RULES=(0,o.getRules)(),k.call(this,g,b,"NOT SUPPORTED"),k.call(this,y,b,"DEPRECATED","warn"),this._metaOpts=me.call(this),b.formats&&ee.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),b.keywords&&ae.call(this,b.keywords),typeof b.meta=="object"&&this.addMetaSchema(b.meta),F.call(this),b.validateFormats=h}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){const{$data:b,meta:I,schemaId:E}=this.opts;let h=f;E==="id"&&(h={...f},h.id=h.$id,delete h.$id),I&&b&&this.addMetaSchema(h,h[E],!1)}defaultMeta(){const{meta:b,schemaId:I}=this.opts;return this.opts.defaultMeta=typeof b=="object"?b[I]||b:void 0}validate(b,I){let E;if(typeof b=="string"){if(E=this.getSchema(b),!E)throw new Error(`no schema with key or ref "${b}"`)}else E=this.compile(b);const h=E(I);return"$async"in E||(this.errors=E.errors),h}compile(b,I){const E=this._addSchema(b,I);return E.validate||this._compileSchemaEnv(E)}compileAsync(b,I){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");const{loadSchema:E}=this.opts;return h.call(this,b,I);async function h(K,ne){await w.call(this,K.$schema);const $t=this._addSchema(K,ne);return $t.validate||O.call(this,$t)}async function w(K){K&&!this.getSchema(K)&&await h.call(this,{$ref:K},!0)}async function O(K){try{return this._compileSchemaEnv(K)}catch(ne){if(!(ne instanceof s.default))throw ne;return T.call(this,ne),await R.call(this,ne.missingSchema),O.call(this,K)}}function T({missingSchema:K,missingRef:ne}){if(this.refs[K])throw new Error(`AnySchema ${K} is loaded but ${ne} cannot be resolved`)}async function R(K){const ne=await z.call(this,K);this.refs[K]||await w.call(this,ne.$schema),this.refs[K]||this.addSchema(ne,K,I)}async function z(K){const ne=this._loading[K];if(ne)return ne;try{return await(this._loading[K]=E(K))}finally{delete this._loading[K]}}}addSchema(b,I,E,h=this.opts.validateSchema){if(Array.isArray(b)){for(const O of b)this.addSchema(O,void 0,E,h);return this}let w;if(typeof b=="object"){const{schemaId:O}=this.opts;if(w=b[O],w!==void 0&&typeof w!="string")throw new Error(`schema ${O} must be string`)}return I=(0,c.normalizeId)(I||w),this._checkUnique(I),this.schemas[I]=this._addSchema(b,E,I,h,!0),this}addMetaSchema(b,I,E=this.opts.validateSchema){return this.addSchema(b,I,!0,E),this}validateSchema(b,I){if(typeof b=="boolean")return!0;let E;if(E=b.$schema,E!==void 0&&typeof E!="string")throw new Error("$schema must be a string");if(E=E||this.opts.defaultMeta||this.defaultMeta(),!E)return this.logger.warn("meta-schema not available"),this.errors=null,!0;const h=this.validate(E,b);if(!h&&I){const w="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(w);else throw new Error(w)}return h}getSchema(b){let I;for(;typeof(I=C.call(this,b))=="string";)b=I;if(I===void 0){const{schemaId:E}=this.opts,h=new i.SchemaEnv({schema:{},schemaId:E});if(I=i.resolveSchema.call(this,h,b),!I)return;this.refs[b]=I}return I.validate||this._compileSchemaEnv(I)}removeSchema(b){if(b instanceof RegExp)return this._removeAllSchemas(this.schemas,b),this._removeAllSchemas(this.refs,b),this;switch(typeof b){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{const I=C.call(this,b);return typeof I=="object"&&this._cache.delete(I.schema),delete this.schemas[b],delete this.refs[b],this}case"object":{const I=b;this._cache.delete(I);let E=b[this.opts.schemaId];return E&&(E=(0,c.normalizeId)(E),delete this.schemas[E],delete this.refs[E]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(b){for(const I of b)this.addKeyword(I);return this}addKeyword(b,I){let E;if(typeof b=="string")E=b,typeof I=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),I.keyword=E);else if(typeof b=="object"&&I===void 0){if(I=b,E=I.keyword,Array.isArray(E)&&!E.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(Fe.call(this,E,I),!I)return(0,l.eachItem)(E,w=>Kt.call(this,w)),this;$r.call(this,I);const h={...I,type:(0,u.getJSONTypes)(I.type),schemaType:(0,u.getJSONTypes)(I.schemaType)};return(0,l.eachItem)(E,h.type.length===0?w=>Kt.call(this,w,h):w=>h.type.forEach(O=>Kt.call(this,w,h,O))),this}getKeyword(b){const I=this.RULES.all[b];return typeof I=="object"?I.definition:!!I}removeKeyword(b){const{RULES:I}=this;delete I.keywords[b],delete I.all[b];for(const E of I.rules){const h=E.rules.findIndex(w=>w.keyword===b);h>=0&&E.rules.splice(h,1)}return this}addFormat(b,I){return typeof I=="string"&&(I=new RegExp(I)),this.formats[b]=I,this}errorsText(b=this.errors,{separator:I=", ",dataVar:E="data"}={}){return!b||b.length===0?"No errors":b.map(h=>`${E}${h.instancePath} ${h.message}`).reduce((h,w)=>h+I+w)}$dataMetaSchema(b,I){const E=this.RULES.all;b=JSON.parse(JSON.stringify(b));for(const h of I){const w=h.split("/").slice(1);let O=b;for(const T of w)O=O[T];for(const T in E){const R=E[T];if(typeof R!="object")continue;const{$data:z}=R.definition,K=O[T];z&&K&&(O[T]=bn(K))}}return b}_removeAllSchemas(b,I){for(const E in b){const h=b[E];(!I||I.test(E))&&(typeof h=="string"?delete b[E]:h&&!h.meta&&(this._cache.delete(h.schema),delete b[E]))}}_addSchema(b,I,E,h=this.opts.validateSchema,w=this.opts.addUsedSchema){let O;const{schemaId:T}=this.opts;if(typeof b=="object")O=b[T];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof b!="boolean")throw new Error("schema must be object or boolean")}let R=this._cache.get(b);if(R!==void 0)return R;E=(0,c.normalizeId)(O||E);const z=c.getSchemaRefs.call(this,b,E);return R=new i.SchemaEnv({schema:b,schemaId:T,meta:I,baseId:E,localRefs:z}),this._cache.set(R.schema,R),w&&!E.startsWith("#")&&(E&&this._checkUnique(E),this.refs[E]=R),h&&this.validateSchema(b,!0),R}_checkUnique(b){if(this.schemas[b]||this.refs[b])throw new Error(`schema with key or id "${b}" already exists`)}_compileSchemaEnv(b){if(b.meta?this._compileMetaSchema(b):i.compileSchema.call(this,b),!b.validate)throw new Error("ajv implementation error");return b.validate}_compileMetaSchema(b){const I=this.opts;this.opts=this._metaOpts;try{i.compileSchema.call(this,b)}finally{this.opts=I}}}N.ValidationError=r.default,N.MissingRefError=s.default,t.default=N;function k(P,b,I,E="error"){for(const h in P){const w=h;w in b&&this.logger[E](`${I}: option ${h}. ${P[w]}`)}}function C(P){return P=(0,c.normalizeId)(P),this.schemas[P]||this.refs[P]}function F(){const P=this.opts.schemas;if(P)if(Array.isArray(P))this.addSchema(P);else for(const b in P)this.addSchema(P[b],b)}function ee(){for(const P in this.opts.formats){const b=this.opts.formats[P];b&&this.addFormat(P,b)}}function ae(P){if(Array.isArray(P)){this.addVocabulary(P);return}this.logger.warn("keywords option as map is deprecated, pass array");for(const b in P){const I=P[b];I.keyword||(I.keyword=b),this.addKeyword(I)}}function me(){const P={...this.opts};for(const b of d)delete P[b];return P}const qt={log(){},warn(){},error(){}};function Te(P){if(P===!1)return qt;if(P===void 0)return console;if(P.log&&P.warn&&P.error)return P;throw new Error("logger must implement log, warn and error methods")}const vt=/^[a-z_$][a-z0-9_$:-]*$/i;function Fe(P,b){const{RULES:I}=this;if((0,l.eachItem)(P,E=>{if(I.keywords[E])throw new Error(`Keyword ${E} is already defined`);if(!vt.test(E))throw new Error(`Keyword ${E} has invalid name`)}),!!b&&b.$data&&!("code"in b||"validate"in b))throw new Error('$data keyword must have "code" or "validate" function')}function Kt(P,b,I){var E;const h=b==null?void 0:b.post;if(I&&h)throw new Error('keyword with "post" flag cannot have "type"');const{RULES:w}=this;let O=h?w.post:w.rules.find(({type:R})=>R===I);if(O||(O={type:I,rules:[]},w.rules.push(O)),w.keywords[P]=!0,!b)return;const T={keyword:P,definition:{...b,type:(0,u.getJSONTypes)(b.type),schemaType:(0,u.getJSONTypes)(b.schemaType)}};b.before?wn.call(this,O,T,b.before):O.rules.push(T),w.all[P]=T,(E=b.implements)===null||E===void 0||E.forEach(R=>this.addKeyword(R))}function wn(P,b,I){const E=P.rules.findIndex(h=>h.keyword===I);E>=0?P.rules.splice(E,0,b):(P.rules.push(b),this.logger.warn(`rule ${I} is not defined`))}function $r(P){let{metaSchema:b}=P;b!==void 0&&(P.$data&&this.opts.$data&&(b=bn(b)),P.validateSchema=this.compile(b,!0))}const wr={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function bn(P){return{anyOf:[P,wr]}}})(rl);var Io={},Ao={},Po={};Object.defineProperty(Po,"__esModule",{value:!0});const F0={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};Po.default=F0;var yt={};Object.defineProperty(yt,"__esModule",{value:!0});yt.callRef=yt.getValidate=void 0;const q0=Ut,Oa=B,fe=U,Et=xe,_a=he,jn=j,K0={keyword:"$ref",schemaType:"string",code(t){const{gen:e,schema:n,it:r}=t,{baseId:s,schemaEnv:o,validateName:i,opts:a,self:c}=r,{root:u}=o;if((n==="#"||n==="#/")&&s===u.baseId)return f();const l=_a.resolveRef.call(c,u,s,n);if(l===void 0)throw new q0.default(r.opts.uriResolver,s,n);if(l instanceof _a.SchemaEnv)return m(l);return p(l);function f(){if(o===u)return Gn(t,i,o,o.$async);const d=e.scopeValue("root",{ref:u});return Gn(t,(0,fe._)`${d}.validate`,u,u.$async)}function m(d){const v=Yl(t,d);Gn(t,v,d,d.$async)}function p(d){const v=e.scopeValue("schema",a.code.source===!0?{ref:d,code:(0,fe.stringify)(d)}:{ref:d}),g=e.name("valid"),y=t.subschema({schema:d,dataTypes:[],schemaPath:fe.nil,topSchemaRef:v,errSchemaPath:n},g);t.mergeEvaluated(y),t.ok(g)}}};function Yl(t,e){const{gen:n}=t;return e.validate?n.scopeValue("validate",{ref:e.validate}):(0,fe._)`${n.scopeValue("wrapper",{ref:e})}.validate`}yt.getValidate=Yl;function Gn(t,e,n,r){const{gen:s,it:o}=t,{allErrors:i,schemaEnv:a,opts:c}=o,u=c.passContext?Et.default.this:fe.nil;r?l():f();function l(){if(!a.$async)throw new Error("async schema referenced by sync schema");const d=s.let("valid");s.try(()=>{s.code((0,fe._)`await ${(0,Oa.callValidateCode)(t,e,u)}`),p(e),i||s.assign(d,!0)},v=>{s.if((0,fe._)`!(${v} instanceof ${o.ValidationError})`,()=>s.throw(v)),m(v),i||s.assign(d,!1)}),t.ok(d)}function f(){t.result((0,Oa.callValidateCode)(t,e,u),()=>p(e),()=>m(e))}function m(d){const v=(0,fe._)`${d}.errors`;s.assign(Et.default.vErrors,(0,fe._)`${Et.default.vErrors} === null ? ${v} : ${Et.default.vErrors}.concat(${v})`),s.assign(Et.default.errors,(0,fe._)`${Et.default.vErrors}.length`)}function p(d){var v;if(!o.opts.unevaluated)return;const g=(v=n==null?void 0:n.validate)===null||v===void 0?void 0:v.evaluated;if(o.props!==!0)if(g&&!g.dynamicProps)g.props!==void 0&&(o.props=jn.mergeEvaluated.props(s,g.props,o.props));else{const y=s.var("props",(0,fe._)`${d}.evaluated.props`);o.props=jn.mergeEvaluated.props(s,y,o.props,fe.Name)}if(o.items!==!0)if(g&&!g.dynamicItems)g.items!==void 0&&(o.items=jn.mergeEvaluated.items(s,g.items,o.items));else{const y=s.var("items",(0,fe._)`${d}.evaluated.items`);o.items=jn.mergeEvaluated.items(s,y,o.items,fe.Name)}}}yt.callRef=Gn;yt.default=K0;Object.defineProperty(Ao,"__esModule",{value:!0});const z0=Po,G0=yt,W0=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",z0.default,G0.default];Ao.default=W0;var jo={},xo={};Object.defineProperty(xo,"__esModule",{value:!0});const er=U,ze=er.operators,tr={maximum:{okStr:"<=",ok:ze.LTE,fail:ze.GT},minimum:{okStr:">=",ok:ze.GTE,fail:ze.LT},exclusiveMaximum:{okStr:"<",ok:ze.LT,fail:ze.GTE},exclusiveMinimum:{okStr:">",ok:ze.GT,fail:ze.LTE}},H0={message:({keyword:t,schemaCode:e})=>(0,er.str)`must be ${tr[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0,er._)`{comparison: ${tr[t].okStr}, limit: ${e}}`},J0={keyword:Object.keys(tr),type:"number",schemaType:"number",$data:!0,error:H0,code(t){const{keyword:e,data:n,schemaCode:r}=t;t.fail$data((0,er._)`${n} ${tr[e].fail} ${r} || isNaN(${n})`)}};xo.default=J0;var To={};Object.defineProperty(To,"__esModule",{value:!0});const sn=U,Q0={message:({schemaCode:t})=>(0,sn.str)`must be multiple of ${t}`,params:({schemaCode:t})=>(0,sn._)`{multipleOf: ${t}}`},Y0={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:Q0,code(t){const{gen:e,data:n,schemaCode:r,it:s}=t,o=s.opts.multipleOfPrecision,i=e.let("res"),a=o?(0,sn._)`Math.abs(Math.round(${i}) - ${i}) > 1e-${o}`:(0,sn._)`${i} !== parseInt(${i})`;t.fail$data((0,sn._)`(${r} === 0 || (${i} = ${n}/${r}, ${a}))`)}};To.default=Y0;var Co={},Ro={};Object.defineProperty(Ro,"__esModule",{value:!0});function Xl(t){const e=t.length;let n=0,r=0,s;for(;r<e;)n++,s=t.charCodeAt(r++),s>=55296&&s<=56319&&r<e&&(s=t.charCodeAt(r),(s&64512)===56320&&r++);return n}Ro.default=Xl;Xl.code='require("ajv/dist/runtime/ucs2length").default';Object.defineProperty(Co,"__esModule",{value:!0});const ot=U,X0=j,Z0=Ro,e$={message({keyword:t,schemaCode:e}){const n=t==="maxLength"?"more":"fewer";return(0,ot.str)`must NOT have ${n} than ${e} characters`},params:({schemaCode:t})=>(0,ot._)`{limit: ${t}}`},t$={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:e$,code(t){const{keyword:e,data:n,schemaCode:r,it:s}=t,o=e==="maxLength"?ot.operators.GT:ot.operators.LT,i=s.opts.unicode===!1?(0,ot._)`${n}.length`:(0,ot._)`${(0,X0.useFunc)(t.gen,Z0.default)}(${n})`;t.fail$data((0,ot._)`${i} ${o} ${r}`)}};Co.default=t$;var Mo={};Object.defineProperty(Mo,"__esModule",{value:!0});const n$=B,r$=j,At=U,s$={message:({schemaCode:t})=>(0,At.str)`must match pattern "${t}"`,params:({schemaCode:t})=>(0,At._)`{pattern: ${t}}`},o$={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:s$,code(t){const{gen:e,data:n,$data:r,schema:s,schemaCode:o,it:i}=t,a=i.opts.unicodeRegExp?"u":"";if(r){const{regExp:c}=i.opts.code,u=c.code==="new RegExp"?(0,At._)`new RegExp`:(0,r$.useFunc)(e,c),l=e.let("valid");e.try(()=>e.assign(l,(0,At._)`${u}(${o}, ${a}).test(${n})`),()=>e.assign(l,!1)),t.fail$data((0,At._)`!${l}`)}else{const c=(0,n$.usePattern)(t,s);t.fail$data((0,At._)`!${c}.test(${n})`)}}};Mo.default=o$;var Do={};Object.defineProperty(Do,"__esModule",{value:!0});const on=U,i$={message({keyword:t,schemaCode:e}){const n=t==="maxProperties"?"more":"fewer";return(0,on.str)`must NOT have ${n} than ${e} properties`},params:({schemaCode:t})=>(0,on._)`{limit: ${t}}`},a$={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:i$,code(t){const{keyword:e,data:n,schemaCode:r}=t,s=e==="maxProperties"?on.operators.GT:on.operators.LT;t.fail$data((0,on._)`Object.keys(${n}).length ${s} ${r}`)}};Do.default=a$;var Lo={};Object.defineProperty(Lo,"__esModule",{value:!0});const Jt=B,an=U,c$=j,u$={message:({params:{missingProperty:t}})=>(0,an.str)`must have required property '${t}'`,params:({params:{missingProperty:t}})=>(0,an._)`{missingProperty: ${t}}`},l$={keyword:"required",type:"object",schemaType:"array",$data:!0,error:u$,code(t){const{gen:e,schema:n,schemaCode:r,data:s,$data:o,it:i}=t,{opts:a}=i;if(!o&&n.length===0)return;const c=n.length>=a.loopRequired;if(i.allErrors?u():l(),a.strictRequired){const p=t.parentSchema.properties,{definedProperties:d}=t.it;for(const v of n)if((p==null?void 0:p[v])===void 0&&!d.has(v)){const g=i.schemaEnv.baseId+i.errSchemaPath,y=`required property "${v}" is not defined at "${g}" (strictRequired)`;(0,c$.checkStrictMode)(i,y,i.opts.strictRequired)}}function u(){if(c||o)t.block$data(an.nil,f);else for(const p of n)(0,Jt.checkReportMissingProp)(t,p)}function l(){const p=e.let("missing");if(c||o){const d=e.let("valid",!0);t.block$data(d,()=>m(p,d)),t.ok(d)}else e.if((0,Jt.checkMissingProp)(t,n,p)),(0,Jt.reportMissingProp)(t,p),e.else()}function f(){e.forOf("prop",r,p=>{t.setParams({missingProperty:p}),e.if((0,Jt.noPropertyInData)(e,s,p,a.ownProperties),()=>t.error())})}function m(p,d){t.setParams({missingProperty:p}),e.forOf(p,r,()=>{e.assign(d,(0,Jt.propertyInData)(e,s,p,a.ownProperties)),e.if((0,an.not)(d),()=>{t.error(),e.break()})},an.nil)}}};Lo.default=l$;var Bo={};Object.defineProperty(Bo,"__esModule",{value:!0});const cn=U,f$={message({keyword:t,schemaCode:e}){const n=t==="maxItems"?"more":"fewer";return(0,cn.str)`must NOT have ${n} than ${e} items`},params:({schemaCode:t})=>(0,cn._)`{limit: ${t}}`},d$={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:f$,code(t){const{keyword:e,data:n,schemaCode:r}=t,s=e==="maxItems"?cn.operators.GT:cn.operators.LT;t.fail$data((0,cn._)`${n}.length ${s} ${r}`)}};Bo.default=d$;var Uo={},$n={};Object.defineProperty($n,"__esModule",{value:!0});const Zl=$l;Zl.code='require("ajv/dist/runtime/equal").default';$n.default=Zl;Object.defineProperty(Uo,"__esModule",{value:!0});const Qr=te,se=U,p$=j,h$=$n,m$={message:({params:{i:t,j:e}})=>(0,se.str)`must NOT have duplicate items (items ## ${e} and ${t} are identical)`,params:({params:{i:t,j:e}})=>(0,se._)`{i: ${t}, j: ${e}}`},g$={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:m$,code(t){const{gen:e,data:n,$data:r,schema:s,parentSchema:o,schemaCode:i,it:a}=t;if(!r&&!s)return;const c=e.let("valid"),u=o.items?(0,Qr.getSchemaTypes)(o.items):[];t.block$data(c,l,(0,se._)`${i} === false`),t.ok(c);function l(){const d=e.let("i",(0,se._)`${n}.length`),v=e.let("j");t.setParams({i:d,j:v}),e.assign(c,!0),e.if((0,se._)`${d} > 1`,()=>(f()?m:p)(d,v))}function f(){return u.length>0&&!u.some(d=>d==="object"||d==="array")}function m(d,v){const g=e.name("item"),y=(0,Qr.checkDataTypes)(u,g,a.opts.strictNumbers,Qr.DataType.Wrong),$=e.const("indices",(0,se._)`{}`);e.for((0,se._)`;${d}--;`,()=>{e.let(g,(0,se._)`${n}[${d}]`),e.if(y,(0,se._)`continue`),u.length>1&&e.if((0,se._)`typeof ${g} == "string"`,(0,se._)`${g} += "_"`),e.if((0,se._)`typeof ${$}[${g}] == "number"`,()=>{e.assign(v,(0,se._)`${$}[${g}]`),t.error(),e.assign(c,!1).break()}).code((0,se._)`${$}[${g}] = ${d}`)})}function p(d,v){const g=(0,p$.useFunc)(e,h$.default),y=e.name("outer");e.label(y).for((0,se._)`;${d}--;`,()=>e.for((0,se._)`${v} = ${d}; ${v}--;`,()=>e.if((0,se._)`${g}(${n}[${d}], ${n}[${v}])`,()=>{t.error(),e.assign(c,!1).break(y)})))}}};Uo.default=g$;var Vo={};Object.defineProperty(Vo,"__esModule",{value:!0});const _s=U,y$=j,v$=$n,$$={message:"must be equal to constant",params:({schemaCode:t})=>(0,_s._)`{allowedValue: ${t}}`},w$={keyword:"const",$data:!0,error:$$,code(t){const{gen:e,data:n,$data:r,schemaCode:s,schema:o}=t;r||o&&typeof o=="object"?t.fail$data((0,_s._)`!${(0,y$.useFunc)(e,v$.default)}(${n}, ${s})`):t.fail((0,_s._)`${o} !== ${n}`)}};Vo.default=w$;var Fo={};Object.defineProperty(Fo,"__esModule",{value:!0});const Zt=U,b$=j,E$=$n,S$={message:"must be equal to one of the allowed values",params:({schemaCode:t})=>(0,Zt._)`{allowedValues: ${t}}`},N$={keyword:"enum",schemaType:"array",$data:!0,error:S$,code(t){const{gen:e,data:n,$data:r,schema:s,schemaCode:o,it:i}=t;if(!r&&s.length===0)throw new Error("enum must have non-empty array");const a=s.length>=i.opts.loopEnum;let c;const u=()=>c??(c=(0,b$.useFunc)(e,E$.default));let l;if(a||r)l=e.let("valid"),t.block$data(l,f);else{if(!Array.isArray(s))throw new Error("ajv implementation error");const p=e.const("vSchema",o);l=(0,Zt.or)(...s.map((d,v)=>m(p,v)))}t.pass(l);function f(){e.assign(l,!1),e.forOf("v",o,p=>e.if((0,Zt._)`${u()}(${n}, ${p})`,()=>e.assign(l,!0).break()))}function m(p,d){const v=s[d];return typeof v=="object"&&v!==null?(0,Zt._)`${u()}(${n}, ${p}[${d}])`:(0,Zt._)`${n} === ${v}`}}};Fo.default=N$;Object.defineProperty(jo,"__esModule",{value:!0});const O$=xo,_$=To,k$=Co,I$=Mo,A$=Do,P$=Lo,j$=Bo,x$=Uo,T$=Vo,C$=Fo,R$=[O$.default,_$.default,k$.default,I$.default,A$.default,P$.default,j$.default,x$.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},T$.default,C$.default];jo.default=R$;var qo={},Vt={};Object.defineProperty(Vt,"__esModule",{value:!0});Vt.validateAdditionalItems=void 0;const it=U,ks=j,M$={message:({params:{len:t}})=>(0,it.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,it._)`{limit: ${t}}`},D$={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:M$,code(t){const{parentSchema:e,it:n}=t,{items:r}=e;if(!Array.isArray(r)){(0,ks.checkStrictMode)(n,'"additionalItems" is ignored when "items" is not an array of schemas');return}ef(t,r)}};function ef(t,e){const{gen:n,schema:r,data:s,keyword:o,it:i}=t;i.items=!0;const a=n.const("len",(0,it._)`${s}.length`);if(r===!1)t.setParams({len:e.length}),t.pass((0,it._)`${a} <= ${e.length}`);else if(typeof r=="object"&&!(0,ks.alwaysValidSchema)(i,r)){const u=n.var("valid",(0,it._)`${a} <= ${e.length}`);n.if((0,it.not)(u),()=>c(u)),t.ok(u)}function c(u){n.forRange("i",e.length,a,l=>{t.subschema({keyword:o,dataProp:l,dataPropType:ks.Type.Num},u),i.allErrors||n.if((0,it.not)(u),()=>n.break())})}}Vt.validateAdditionalItems=ef;Vt.default=D$;var Ko={},Ft={};Object.defineProperty(Ft,"__esModule",{value:!0});Ft.validateTuple=void 0;const ka=U,Wn=j,L$=B,B$={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(t){const{schema:e,it:n}=t;if(Array.isArray(e))return tf(t,"additionalItems",e);n.items=!0,!(0,Wn.alwaysValidSchema)(n,e)&&t.ok((0,L$.validateArray)(t))}};function tf(t,e,n=t.schema){const{gen:r,parentSchema:s,data:o,keyword:i,it:a}=t;l(s),a.opts.unevaluated&&n.length&&a.items!==!0&&(a.items=Wn.mergeEvaluated.items(r,n.length,a.items));const c=r.name("valid"),u=r.const("len",(0,ka._)`${o}.length`);n.forEach((f,m)=>{(0,Wn.alwaysValidSchema)(a,f)||(r.if((0,ka._)`${u} > ${m}`,()=>t.subschema({keyword:i,schemaProp:m,dataProp:m},c)),t.ok(c))});function l(f){const{opts:m,errSchemaPath:p}=a,d=n.length,v=d===f.minItems&&(d===f.maxItems||f[e]===!1);if(m.strictTuples&&!v){const g=`"${i}" is ${d}-tuple, but minItems or maxItems/${e} are not specified or different at path "${p}"`;(0,Wn.checkStrictMode)(a,g,m.strictTuples)}}}Ft.validateTuple=tf;Ft.default=B$;Object.defineProperty(Ko,"__esModule",{value:!0});const U$=Ft,V$={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:t=>(0,U$.validateTuple)(t,"items")};Ko.default=V$;var zo={};Object.defineProperty(zo,"__esModule",{value:!0});const Ia=U,F$=j,q$=B,K$=Vt,z$={message:({params:{len:t}})=>(0,Ia.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,Ia._)`{limit: ${t}}`},G$={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:z$,code(t){const{schema:e,parentSchema:n,it:r}=t,{prefixItems:s}=n;r.items=!0,!(0,F$.alwaysValidSchema)(r,e)&&(s?(0,K$.validateAdditionalItems)(t,s):t.ok((0,q$.validateArray)(t)))}};zo.default=G$;var Go={};Object.defineProperty(Go,"__esModule",{value:!0});const $e=U,xn=j,W$={message:({params:{min:t,max:e}})=>e===void 0?(0,$e.str)`must contain at least ${t} valid item(s)`:(0,$e.str)`must contain at least ${t} and no more than ${e} valid item(s)`,params:({params:{min:t,max:e}})=>e===void 0?(0,$e._)`{minContains: ${t}}`:(0,$e._)`{minContains: ${t}, maxContains: ${e}}`},H$={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:W$,code(t){const{gen:e,schema:n,parentSchema:r,data:s,it:o}=t;let i,a;const{minContains:c,maxContains:u}=r;o.opts.next?(i=c===void 0?1:c,a=u):i=1;const l=e.const("len",(0,$e._)`${s}.length`);if(t.setParams({min:i,max:a}),a===void 0&&i===0){(0,xn.checkStrictMode)(o,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&i>a){(0,xn.checkStrictMode)(o,'"minContains" > "maxContains" is always invalid'),t.fail();return}if((0,xn.alwaysValidSchema)(o,n)){let v=(0,$e._)`${l} >= ${i}`;a!==void 0&&(v=(0,$e._)`${v} && ${l} <= ${a}`),t.pass(v);return}o.items=!0;const f=e.name("valid");a===void 0&&i===1?p(f,()=>e.if(f,()=>e.break())):i===0?(e.let(f,!0),a!==void 0&&e.if((0,$e._)`${s}.length > 0`,m)):(e.let(f,!1),m()),t.result(f,()=>t.reset());function m(){const v=e.name("_valid"),g=e.let("count",0);p(v,()=>e.if(v,()=>d(g)))}function p(v,g){e.forRange("i",0,l,y=>{t.subschema({keyword:"contains",dataProp:y,dataPropType:xn.Type.Num,compositeRule:!0},v),g()})}function d(v){e.code((0,$e._)`${v}++`),a===void 0?e.if((0,$e._)`${v} >= ${i}`,()=>e.assign(f,!0).break()):(e.if((0,$e._)`${v} > ${a}`,()=>e.assign(f,!1).break()),i===1?e.assign(f,!0):e.if((0,$e._)`${v} >= ${i}`,()=>e.assign(f,!0)))}}};Go.default=H$;var nf={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.validateSchemaDeps=t.validatePropertyDeps=t.error=void 0;const e=U,n=j,r=B;t.error={message:({params:{property:c,depsCount:u,deps:l}})=>{const f=u===1?"property":"properties";return(0,e.str)`must have ${f} ${l} when property ${c} is present`},params:({params:{property:c,depsCount:u,deps:l,missingProperty:f}})=>(0,e._)`{property: ${c},
175
- missingProperty: ${f},
176
- depsCount: ${u},
177
- deps: ${l}}`};const s={keyword:"dependencies",type:"object",schemaType:"object",error:t.error,code(c){const[u,l]=o(c);i(c,u),a(c,l)}};function o({schema:c}){const u={},l={};for(const f in c){if(f==="__proto__")continue;const m=Array.isArray(c[f])?u:l;m[f]=c[f]}return[u,l]}function i(c,u=c.schema){const{gen:l,data:f,it:m}=c;if(Object.keys(u).length===0)return;const p=l.let("missing");for(const d in u){const v=u[d];if(v.length===0)continue;const g=(0,r.propertyInData)(l,f,d,m.opts.ownProperties);c.setParams({property:d,depsCount:v.length,deps:v.join(", ")}),m.allErrors?l.if(g,()=>{for(const y of v)(0,r.checkReportMissingProp)(c,y)}):(l.if((0,e._)`${g} && (${(0,r.checkMissingProp)(c,v,p)})`),(0,r.reportMissingProp)(c,p),l.else())}}t.validatePropertyDeps=i;function a(c,u=c.schema){const{gen:l,data:f,keyword:m,it:p}=c,d=l.name("valid");for(const v in u)(0,n.alwaysValidSchema)(p,u[v])||(l.if((0,r.propertyInData)(l,f,v,p.opts.ownProperties),()=>{const g=c.subschema({keyword:m,schemaProp:v},d);c.mergeValidEvaluated(g,d)},()=>l.var(d,!0)),c.ok(d))}t.validateSchemaDeps=a,t.default=s})(nf);var Wo={};Object.defineProperty(Wo,"__esModule",{value:!0});const rf=U,J$=j,Q$={message:"property name must be valid",params:({params:t})=>(0,rf._)`{propertyName: ${t.propertyName}}`},Y$={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:Q$,code(t){const{gen:e,schema:n,data:r,it:s}=t;if((0,J$.alwaysValidSchema)(s,n))return;const o=e.name("valid");e.forIn("key",r,i=>{t.setParams({propertyName:i}),t.subschema({keyword:"propertyNames",data:i,dataTypes:["string"],propertyName:i,compositeRule:!0},o),e.if((0,rf.not)(o),()=>{t.error(!0),s.allErrors||e.break()})}),t.ok(o)}};Wo.default=Y$;var yr={};Object.defineProperty(yr,"__esModule",{value:!0});const Tn=B,be=U,X$=xe,Cn=j,Z$={message:"must NOT have additional properties",params:({params:t})=>(0,be._)`{additionalProperty: ${t.additionalProperty}}`},ew={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:Z$,code(t){const{gen:e,schema:n,parentSchema:r,data:s,errsCount:o,it:i}=t;if(!o)throw new Error("ajv implementation error");const{allErrors:a,opts:c}=i;if(i.props=!0,c.removeAdditional!=="all"&&(0,Cn.alwaysValidSchema)(i,n))return;const u=(0,Tn.allSchemaProperties)(r.properties),l=(0,Tn.allSchemaProperties)(r.patternProperties);f(),t.ok((0,be._)`${o} === ${X$.default.errors}`);function f(){e.forIn("key",s,g=>{!u.length&&!l.length?d(g):e.if(m(g),()=>d(g))})}function m(g){let y;if(u.length>8){const $=(0,Cn.schemaRefOrVal)(i,r.properties,"properties");y=(0,Tn.isOwnProperty)(e,$,g)}else u.length?y=(0,be.or)(...u.map($=>(0,be._)`${g} === ${$}`)):y=be.nil;return l.length&&(y=(0,be.or)(y,...l.map($=>(0,be._)`${(0,Tn.usePattern)(t,$)}.test(${g})`))),(0,be.not)(y)}function p(g){e.code((0,be._)`delete ${s}[${g}]`)}function d(g){if(c.removeAdditional==="all"||c.removeAdditional&&n===!1){p(g);return}if(n===!1){t.setParams({additionalProperty:g}),t.error(),a||e.break();return}if(typeof n=="object"&&!(0,Cn.alwaysValidSchema)(i,n)){const y=e.name("valid");c.removeAdditional==="failing"?(v(g,y,!1),e.if((0,be.not)(y),()=>{t.reset(),p(g)})):(v(g,y),a||e.if((0,be.not)(y),()=>e.break()))}}function v(g,y,$){const S={keyword:"additionalProperties",dataProp:g,dataPropType:Cn.Type.Str};$===!1&&Object.assign(S,{compositeRule:!0,createErrors:!1,allErrors:!1}),t.subschema(S,y)}}};yr.default=ew;var Ho={};Object.defineProperty(Ho,"__esModule",{value:!0});const tw=Ne,Aa=B,Yr=j,Pa=yr,nw={keyword:"properties",type:"object",schemaType:"object",code(t){const{gen:e,schema:n,parentSchema:r,data:s,it:o}=t;o.opts.removeAdditional==="all"&&r.additionalProperties===void 0&&Pa.default.code(new tw.KeywordCxt(o,Pa.default,"additionalProperties"));const i=(0,Aa.allSchemaProperties)(n);for(const f of i)o.definedProperties.add(f);o.opts.unevaluated&&i.length&&o.props!==!0&&(o.props=Yr.mergeEvaluated.props(e,(0,Yr.toHash)(i),o.props));const a=i.filter(f=>!(0,Yr.alwaysValidSchema)(o,n[f]));if(a.length===0)return;const c=e.name("valid");for(const f of a)u(f)?l(f):(e.if((0,Aa.propertyInData)(e,s,f,o.opts.ownProperties)),l(f),o.allErrors||e.else().var(c,!0),e.endIf()),t.it.definedProperties.add(f),t.ok(c);function u(f){return o.opts.useDefaults&&!o.compositeRule&&n[f].default!==void 0}function l(f){t.subschema({keyword:"properties",schemaProp:f,dataProp:f},c)}}};Ho.default=nw;var Jo={};Object.defineProperty(Jo,"__esModule",{value:!0});const ja=B,Rn=U,xa=j,Ta=j,rw={keyword:"patternProperties",type:"object",schemaType:"object",code(t){const{gen:e,schema:n,data:r,parentSchema:s,it:o}=t,{opts:i}=o,a=(0,ja.allSchemaProperties)(n),c=a.filter(v=>(0,xa.alwaysValidSchema)(o,n[v]));if(a.length===0||c.length===a.length&&(!o.opts.unevaluated||o.props===!0))return;const u=i.strictSchema&&!i.allowMatchingProperties&&s.properties,l=e.name("valid");o.props!==!0&&!(o.props instanceof Rn.Name)&&(o.props=(0,Ta.evaluatedPropsToName)(e,o.props));const{props:f}=o;m();function m(){for(const v of a)u&&p(v),o.allErrors?d(v):(e.var(l,!0),d(v),e.if(l))}function p(v){for(const g in u)new RegExp(v).test(g)&&(0,xa.checkStrictMode)(o,`property ${g} matches pattern ${v} (use allowMatchingProperties)`)}function d(v){e.forIn("key",r,g=>{e.if((0,Rn._)`${(0,ja.usePattern)(t,v)}.test(${g})`,()=>{const y=c.includes(v);y||t.subschema({keyword:"patternProperties",schemaProp:v,dataProp:g,dataPropType:Ta.Type.Str},l),o.opts.unevaluated&&f!==!0?e.assign((0,Rn._)`${f}[${g}]`,!0):!y&&!o.allErrors&&e.if((0,Rn.not)(l),()=>e.break())})})}}};Jo.default=rw;var Qo={};Object.defineProperty(Qo,"__esModule",{value:!0});const sw=j,ow={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(t){const{gen:e,schema:n,it:r}=t;if((0,sw.alwaysValidSchema)(r,n)){t.fail();return}const s=e.name("valid");t.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},s),t.failResult(s,()=>t.reset(),()=>t.error())},error:{message:"must NOT be valid"}};Qo.default=ow;var Yo={};Object.defineProperty(Yo,"__esModule",{value:!0});const iw=B,aw={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:iw.validateUnion,error:{message:"must match a schema in anyOf"}};Yo.default=aw;var Xo={};Object.defineProperty(Xo,"__esModule",{value:!0});const Hn=U,cw=j,uw={message:"must match exactly one schema in oneOf",params:({params:t})=>(0,Hn._)`{passingSchemas: ${t.passing}}`},lw={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:uw,code(t){const{gen:e,schema:n,parentSchema:r,it:s}=t;if(!Array.isArray(n))throw new Error("ajv implementation error");if(s.opts.discriminator&&r.discriminator)return;const o=n,i=e.let("valid",!1),a=e.let("passing",null),c=e.name("_valid");t.setParams({passing:a}),e.block(u),t.result(i,()=>t.reset(),()=>t.error(!0));function u(){o.forEach((l,f)=>{let m;(0,cw.alwaysValidSchema)(s,l)?e.var(c,!0):m=t.subschema({keyword:"oneOf",schemaProp:f,compositeRule:!0},c),f>0&&e.if((0,Hn._)`${c} && ${i}`).assign(i,!1).assign(a,(0,Hn._)`[${a}, ${f}]`).else(),e.if(c,()=>{e.assign(i,!0),e.assign(a,f),m&&t.mergeEvaluated(m,Hn.Name)})})}}};Xo.default=lw;var Zo={};Object.defineProperty(Zo,"__esModule",{value:!0});const fw=j,dw={keyword:"allOf",schemaType:"array",code(t){const{gen:e,schema:n,it:r}=t;if(!Array.isArray(n))throw new Error("ajv implementation error");const s=e.name("valid");n.forEach((o,i)=>{if((0,fw.alwaysValidSchema)(r,o))return;const a=t.subschema({keyword:"allOf",schemaProp:i},s);t.ok(s),t.mergeEvaluated(a)})}};Zo.default=dw;var ei={};Object.defineProperty(ei,"__esModule",{value:!0});const nr=U,sf=j,pw={message:({params:t})=>(0,nr.str)`must match "${t.ifClause}" schema`,params:({params:t})=>(0,nr._)`{failingKeyword: ${t.ifClause}}`},hw={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:pw,code(t){const{gen:e,parentSchema:n,it:r}=t;n.then===void 0&&n.else===void 0&&(0,sf.checkStrictMode)(r,'"if" without "then" and "else" is ignored');const s=Ca(r,"then"),o=Ca(r,"else");if(!s&&!o)return;const i=e.let("valid",!0),a=e.name("_valid");if(c(),t.reset(),s&&o){const l=e.let("ifClause");t.setParams({ifClause:l}),e.if(a,u("then",l),u("else",l))}else s?e.if(a,u("then")):e.if((0,nr.not)(a),u("else"));t.pass(i,()=>t.error(!0));function c(){const l=t.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},a);t.mergeEvaluated(l)}function u(l,f){return()=>{const m=t.subschema({keyword:l},a);e.assign(i,a),t.mergeValidEvaluated(m,i),f?e.assign(f,(0,nr._)`${l}`):t.setParams({ifClause:l})}}}};function Ca(t,e){const n=t.schema[e];return n!==void 0&&!(0,sf.alwaysValidSchema)(t,n)}ei.default=hw;var ti={};Object.defineProperty(ti,"__esModule",{value:!0});const mw=j,gw={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:t,parentSchema:e,it:n}){e.if===void 0&&(0,mw.checkStrictMode)(n,`"${t}" without "if" is ignored`)}};ti.default=gw;Object.defineProperty(qo,"__esModule",{value:!0});const yw=Vt,vw=Ko,$w=Ft,ww=zo,bw=Go,Ew=nf,Sw=Wo,Nw=yr,Ow=Ho,_w=Jo,kw=Qo,Iw=Yo,Aw=Xo,Pw=Zo,jw=ei,xw=ti;function Tw(t=!1){const e=[kw.default,Iw.default,Aw.default,Pw.default,jw.default,xw.default,Sw.default,Nw.default,Ew.default,Ow.default,_w.default];return t?e.push(vw.default,ww.default):e.push(yw.default,$w.default),e.push(bw.default),e}qo.default=Tw;var ni={},ri={};Object.defineProperty(ri,"__esModule",{value:!0});const X=U,Cw={message:({schemaCode:t})=>(0,X.str)`must match format "${t}"`,params:({schemaCode:t})=>(0,X._)`{format: ${t}}`},Rw={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:Cw,code(t,e){const{gen:n,data:r,$data:s,schema:o,schemaCode:i,it:a}=t,{opts:c,errSchemaPath:u,schemaEnv:l,self:f}=a;if(!c.validateFormats)return;s?m():p();function m(){const d=n.scopeValue("formats",{ref:f.formats,code:c.code.formats}),v=n.const("fDef",(0,X._)`${d}[${i}]`),g=n.let("fType"),y=n.let("format");n.if((0,X._)`typeof ${v} == "object" && !(${v} instanceof RegExp)`,()=>n.assign(g,(0,X._)`${v}.type || "string"`).assign(y,(0,X._)`${v}.validate`),()=>n.assign(g,(0,X._)`"string"`).assign(y,v)),t.fail$data((0,X.or)($(),S()));function $(){return c.strictSchema===!1?X.nil:(0,X._)`${i} && !${y}`}function S(){const N=l.$async?(0,X._)`(${v}.async ? await ${y}(${r}) : ${y}(${r}))`:(0,X._)`${y}(${r})`,k=(0,X._)`(typeof ${y} == "function" ? ${N} : ${y}.test(${r}))`;return(0,X._)`${y} && ${y} !== true && ${g} === ${e} && !${k}`}}function p(){const d=f.formats[o];if(!d){$();return}if(d===!0)return;const[v,g,y]=S(d);v===e&&t.pass(N());function $(){if(c.strictSchema===!1){f.logger.warn(k());return}throw new Error(k());function k(){return`unknown format "${o}" ignored in schema at path "${u}"`}}function S(k){const C=k instanceof RegExp?(0,X.regexpCode)(k):c.code.formats?(0,X._)`${c.code.formats}${(0,X.getProperty)(o)}`:void 0,F=n.scopeValue("formats",{key:o,ref:k,code:C});return typeof k=="object"&&!(k instanceof RegExp)?[k.type||"string",k.validate,(0,X._)`${F}.validate`]:["string",k,F]}function N(){if(typeof d=="object"&&!(d instanceof RegExp)&&d.async){if(!l.$async)throw new Error("async format in sync schema");return(0,X._)`await ${y}(${r})`}return typeof g=="function"?(0,X._)`${y}(${r})`:(0,X._)`${y}.test(${r})`}}}};ri.default=Rw;Object.defineProperty(ni,"__esModule",{value:!0});const Mw=ri,Dw=[Mw.default];ni.default=Dw;var Mt={};Object.defineProperty(Mt,"__esModule",{value:!0});Mt.contentVocabulary=Mt.metadataVocabulary=void 0;Mt.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];Mt.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"];Object.defineProperty(Io,"__esModule",{value:!0});const Lw=Ao,Bw=jo,Uw=qo,Vw=ni,Ra=Mt,Fw=[Lw.default,Bw.default,(0,Uw.default)(),Vw.default,Ra.metadataVocabulary,Ra.contentVocabulary];Io.default=Fw;var si={},vr={};Object.defineProperty(vr,"__esModule",{value:!0});vr.DiscrError=void 0;var Ma;(function(t){t.Tag="tag",t.Mapping="mapping"})(Ma||(vr.DiscrError=Ma={}));Object.defineProperty(si,"__esModule",{value:!0});const kt=U,Is=vr,Da=he,qw=Ut,Kw=j,zw={message:({params:{discrError:t,tagName:e}})=>t===Is.DiscrError.Tag?`tag "${e}" must be string`:`value of tag "${e}" must be in oneOf`,params:({params:{discrError:t,tag:e,tagName:n}})=>(0,kt._)`{error: ${t}, tag: ${n}, tagValue: ${e}}`},Gw={keyword:"discriminator",type:"object",schemaType:"object",error:zw,code(t){const{gen:e,data:n,schema:r,parentSchema:s,it:o}=t,{oneOf:i}=s;if(!o.opts.discriminator)throw new Error("discriminator: requires discriminator option");const a=r.propertyName;if(typeof a!="string")throw new Error("discriminator: requires propertyName");if(r.mapping)throw new Error("discriminator: mapping is not supported");if(!i)throw new Error("discriminator: requires oneOf keyword");const c=e.let("valid",!1),u=e.const("tag",(0,kt._)`${n}${(0,kt.getProperty)(a)}`);e.if((0,kt._)`typeof ${u} == "string"`,()=>l(),()=>t.error(!1,{discrError:Is.DiscrError.Tag,tag:u,tagName:a})),t.ok(c);function l(){const p=m();e.if(!1);for(const d in p)e.elseIf((0,kt._)`${u} === ${d}`),e.assign(c,f(p[d]));e.else(),t.error(!1,{discrError:Is.DiscrError.Mapping,tag:u,tagName:a}),e.endIf()}function f(p){const d=e.name("valid"),v=t.subschema({keyword:"oneOf",schemaProp:p},d);return t.mergeEvaluated(v,kt.Name),d}function m(){var p;const d={},v=y(s);let g=!0;for(let N=0;N<i.length;N++){let k=i[N];if(k!=null&&k.$ref&&!(0,Kw.schemaHasRulesButRef)(k,o.self.RULES)){const F=k.$ref;if(k=Da.resolveRef.call(o.self,o.schemaEnv.root,o.baseId,F),k instanceof Da.SchemaEnv&&(k=k.schema),k===void 0)throw new qw.default(o.opts.uriResolver,o.baseId,F)}const C=(p=k==null?void 0:k.properties)===null||p===void 0?void 0:p[a];if(typeof C!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`);g=g&&(v||y(k)),$(C,N)}if(!g)throw new Error(`discriminator: "${a}" must be required`);return d;function y({required:N}){return Array.isArray(N)&&N.includes(a)}function $(N,k){if(N.const)S(N.const,k);else if(N.enum)for(const C of N.enum)S(C,k);else throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function S(N,k){if(typeof N!="string"||N in d)throw new Error(`discriminator: "${a}" values must be unique strings`);d[N]=k}}}};si.default=Gw;const Ww="http://json-schema.org/draft-07/schema#",Hw="http://json-schema.org/draft-07/schema#",Jw="Core schema meta-schema",Qw={schemaArray:{type:"array",minItems:1,items:{$ref:"#"}},nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:"#/definitions/nonNegativeInteger"},{default:0}]},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:!0,default:[]}},Yw=["object","boolean"],Xw={$id:{type:"string",format:"uri-reference"},$schema:{type:"string",format:"uri"},$ref:{type:"string",format:"uri-reference"},$comment:{type:"string"},title:{type:"string"},description:{type:"string"},default:!0,readOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0},multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/definitions/nonNegativeInteger"},minLength:{$ref:"#/definitions/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},additionalItems:{$ref:"#"},items:{anyOf:[{$ref:"#"},{$ref:"#/definitions/schemaArray"}],default:!0},maxItems:{$ref:"#/definitions/nonNegativeInteger"},minItems:{$ref:"#/definitions/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},contains:{$ref:"#"},maxProperties:{$ref:"#/definitions/nonNegativeInteger"},minProperties:{$ref:"#/definitions/nonNegativeIntegerDefault0"},required:{$ref:"#/definitions/stringArray"},additionalProperties:{$ref:"#"},definitions:{type:"object",additionalProperties:{$ref:"#"},default:{}},properties:{type:"object",additionalProperties:{$ref:"#"},default:{}},patternProperties:{type:"object",additionalProperties:{$ref:"#"},propertyNames:{format:"regex"},default:{}},dependencies:{type:"object",additionalProperties:{anyOf:[{$ref:"#"},{$ref:"#/definitions/stringArray"}]}},propertyNames:{$ref:"#"},const:!0,enum:{type:"array",items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:"#/definitions/simpleTypes"},{type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:!0}]},format:{type:"string"},contentMediaType:{type:"string"},contentEncoding:{type:"string"},if:{$ref:"#"},then:{$ref:"#"},else:{$ref:"#"},allOf:{$ref:"#/definitions/schemaArray"},anyOf:{$ref:"#/definitions/schemaArray"},oneOf:{$ref:"#/definitions/schemaArray"},not:{$ref:"#"}},Zw={$schema:Ww,$id:Hw,title:Jw,definitions:Qw,type:Yw,properties:Xw,default:!0};(function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.MissingRefError=e.ValidationError=e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=e.Ajv=void 0;const n=rl,r=Io,s=si,o=Zw,i=["/properties"],a="http://json-schema.org/draft-07/schema";class c extends n.default{_addVocabularies(){super._addVocabularies(),r.default.forEach(d=>this.addVocabulary(d)),this.opts.discriminator&&this.addKeyword(s.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;const d=this.opts.$data?this.$dataMetaSchema(o,i):o;this.addMetaSchema(d,a,!1),this.refs["http://json-schema.org/schema"]=a}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(a)?a:void 0)}}e.Ajv=c,t.exports=e=c,t.exports.Ajv=c,Object.defineProperty(e,"__esModule",{value:!0}),e.default=c;var u=Ne;Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return u.KeywordCxt}});var l=U;Object.defineProperty(e,"_",{enumerable:!0,get:function(){return l._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return l.str}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return l.stringify}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return l.nil}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return l.Name}}),Object.defineProperty(e,"CodeGen",{enumerable:!0,get:function(){return l.CodeGen}});var f=vn;Object.defineProperty(e,"ValidationError",{enumerable:!0,get:function(){return f.default}});var m=Ut;Object.defineProperty(e,"MissingRefError",{enumerable:!0,get:function(){return m.default}})})(bs,bs.exports);var eb=bs.exports;const tb=Em(eb);class of extends Error{constructor(e){super(e.length>0?`Config validation failed: ${e.map(n=>`${n.field} ${n.message}`).join("; ")}`:"Config validation failed"),this.fieldErrors=e,this.name="ValidationError"}}function nb(t,e){if(!e)return;const n=e,r=n.properties;if(r!==void 0&&Object.keys(r).length===0)return;const s=new tb({allErrors:!0,strict:!1}).compile(n);if(!s(t))throw new of(rb(s.errors??[]))}function rb(t){return t.map(e=>({field:sb(e),message:e.message??"is invalid",keyword:e.keyword}))}function sb(t){var e;return(t.instancePath??"").replace(/^\//,"").replace(/\//g,".")||(((e=t.params)==null?void 0:e.missingProperty)??"(root)")}function ob(t,e){return q.join(gu(t,e),xg)}const ib=384,ab=448;function cb(t,e,n={}){const r=n.mode??ib,s=n.dirMode??ab,o=q.dirname(t);Y.mkdirSync(o,{recursive:!0,mode:s}),Y.chmodSync(o,s);const i=`${t}.tmp`,a=typeof e=="string"?e:JSON.stringify(e,null,2);try{Y.writeFileSync(i,a,{encoding:"utf8",mode:r}),Y.chmodSync(i,r),Y.renameSync(i,t),Y.chmodSync(t,r)}catch(c){try{Y.existsSync(i)&&Y.unlinkSync(i)}catch{}throw c}}const ub="0.1.0";function La(t,e){if(!t||t==="."||t===".."||t.includes("/")||t.includes("\\")||t.includes("\0"))throw new Error(`${e} must be a non-empty path segment with no '.', '..', path separators, or NUL: ${JSON.stringify(t)}`)}function lb(){return`${process.pid}-${Af.randomBytes(3).toString("hex")}`}function af(t,e,n={}){if(!t)throw new Error("Environment requires a non-empty 'project' name");La(t,"project");const r=e.orgNamespace??Pg,s=e.envPrefixOverride??Dg(t),o=e.namespaces&&e.namespaces.length>0?e.namespaces:[jg],i=n.namespace??o[0];if(!o.includes(i))throw new Error(`Namespace "${i}" is not declared for project "${t}" (declared: ${o.join(", ")})`);La(i,"namespace");const a=n.processEnv??process.env,{scope:c,projectRoot:u}=$m({scope:n.scope,cwd:n.cwd},a),l=bm({project:t,namespace:i,orgNamespace:r,projectRoot:u,adhdRoot:n.adhdRoot});return{project:t,namespace:i,orgNamespace:r,envPrefix:s,scope:c,projectRoot:u,roots:l}}function fb(t,e,n={}){const{namespace:r,orgNamespace:s,envPrefix:o,scope:i,projectRoot:a,roots:c}=af(t,e,n),u=n.processEnv??process.env,l=Wg(c),f=n.instanceId??lb(),{raw:m,nested:p,typedRaw:d,provenance:v,fields:g}=Qg(e.config,l,u,{prefix:o,activeScope:i}),y={};for(const k of Object.keys(g)){const C=g[k];C.live&&(y[k]={env:C.env,type:C.type,fallback:C.secret===!0?void 0:C.fallbackValue})}const $=Bg(e.config);nb(nl(d),$);const S=Xg(e.dirs,{roots:c,activeScope:i,instanceId:f,projectRoot:a,namespace:r}),N=Zg(e.files,S);return{version:Ag,libraryVersion:ub,generatedAt:new Date().toISOString(),project:t,namespace:r,orgNamespace:s,envPrefix:o,scope:i,instanceId:f,config:p,raw:m,liveFields:y,fieldSchema:$,configHash:Rg(Object.fromEntries(Object.entries(d).map(([k,C])=>[k,String(C)]))),structureHash:Mg(Object.values(S).map(k=>({name:k.name,kind:k.kind,scope:k.scope}))),dirs:Object.values(S),files:Object.values(N),provenance:v}}class mn extends Error{constructor(e){super(e),this.name="EnvironmentError"}}class db extends mn{constructor(e){super(`adhd-environment snapshot not found: ${e}`),this.snapshotPath=e,this.name="SnapshotNotFoundError"}}class pb extends mn{constructor(e,n){super(`lock "${e}" is already held (${n})`),this.lockName=e,this.lockPath=n,this.name="LockHeldError"}}function hb(t,e){let n=t;for(const r of e.split("."))if(n!==null&&typeof n=="object"&&r in n)n=n[r];else return;return n}function As(t){if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(n=>As(n));const e={};for(const[n,r]of Object.entries(t))e[n]=As(r);return e}function mb(t,e){const n=As(t);for(const r of Object.keys(e)){const s=e[r],o=r.split(".");let i=n;for(let c=0;c<o.length-1;c++){const u=o[c],l=i[u];(typeof l!="object"||l===null||Array.isArray(l))&&(i[u]={}),i=i[u]}const a=o[o.length-1];Object.defineProperty(i,a,{enumerable:!0,configurable:!0,get(){const c=process.env[s.env];return c!==void 0?ws(c,s.type):s.fallback}})}return n}function gb(t){if(!t||t==="."||t===".."||t.includes("/")||t.includes("\\")||t.includes("\0"))throw new mn(`lock name must be a non-empty path segment with no path separators: ${JSON.stringify(t)}`)}class oi{constructor(e,n,r={}){let s,o;try{s=fb(e,n,r);const i=af(e,n,r);o=ob(i.roots,s.scope)}catch(i){throw i instanceof of||i instanceof mn?i:new mn(i instanceof Error?i.message:String(i))}return Ba(this,s,o)}static fromSnapshot(e){if(!Y.existsSync(e))throw new db(e);const n=JSON.parse(Y.readFileSync(e,"utf8")),r=Object.create(oi.prototype);return Ba(r,n,e)}get(e){const n=e.indexOf(".");if(n===-1)return;const r=e.slice(0,n),s=e.slice(n+1);switch(r){case"config":return hb(this.config,s);case"path":return this.paths[s];case"env":return this.resolveEnvName(s);case"provenance":return this._data.provenance[s];default:return}}isEnvNameAllowed(e){return e.startsWith(this.prefix)}resolveEnvName(e){if(this.isEnvNameAllowed(e))return process.env[e]}lock(e="singleton"){gb(e);const n=this.paths.run??this._runDirFallback();Y.mkdirSync(n,{recursive:!0});const r=q.join(n,`${e}.lock`);let s;try{s=Y.openSync(r,"wx")}catch(i){throw(i==null?void 0:i.code)==="EEXIST"?new pb(e,r):i}Y.writeSync(s,`${process.pid}
178
- ${this.instanceId}
179
- `),Y.closeSync(s);let o=!1;return()=>{if(!o){o=!0;try{Y.unlinkSync(r)}catch{}}}}_runDirFallback(){return q.join(q.dirname(this.snapshotPath),"run")}ensureDirs(){for(const e of Object.values(this.paths))Y.mkdirSync(e,{recursive:!0})}write(){return cb(this.snapshotPath,this._data),this.snapshotPath}toJSON(){return Object.freeze(JSON.parse(JSON.stringify(this._data)))}}function Ba(t,e,n){const r={};for(const i of e.dirs)r[i.name]=i.path;const s={};for(const i of e.files)s[i.name]=i.path;const o=mb(e.config,e.liveFields??{});return Object.defineProperties(t,{project:{value:e.project,enumerable:!0},namespace:{value:e.namespace,enumerable:!0},orgNamespace:{value:e.orgNamespace,enumerable:!0},scope:{value:e.scope,enumerable:!0},prefix:{value:e.envPrefix,enumerable:!0},instanceId:{value:e.instanceId,enumerable:!0},hash:{value:e.configHash,enumerable:!0},version:{value:{configHash:e.configHash,structureHash:e.structureHash,generatedAt:e.generatedAt,libraryVersion:e.libraryVersion},enumerable:!0},provenance:{value:e.provenance,enumerable:!0},dirs:{value:e.dirs,enumerable:!0},snapshotPath:{value:n,enumerable:!0},config:{value:o,enumerable:!0},paths:{value:r,enumerable:!0},files:{value:s,enumerable:!0},_data:{value:e,enumerable:!1}}),new Proxy(t,{get(i,a,c){return typeof a=="string"&&!(a in i)?i.get(a):Reflect.get(i,a,c)}})}const cf={envPrefixOverride:"ADHD_BACKLOG",namespaces:["production"],dirs:{data:{kind:"data"}},files:{db:{in:"data",name:"backlog.db"}},config:{"db.path":{type:"string",env:"ADHD_BACKLOG_DATABASE_PATH",description:"SQLite backlog-graph DB path. Unset ⇒ falls back to env.files.db under the resolved scope root."},"logging.level":{type:"string",env:"ADHD_BACKLOG_LOG_LEVEL",default:"info",enum:["trace","debug","info","warn","error","fatal","silent"]}}};function uf(t){if(t)return t;const e=process.env.ADHD_BACKLOG_SCOPE;if(e)return e;const n=process.env.ADHD_ENV_SCOPE;return n||"global"}function lf(t={}){const e={namespace:"production",scope:uf(t.scope)};return t.adhdRoot!==void 0&&(e.adhdRoot=t.adhdRoot),t.cwd!==void 0&&(e.cwd=t.cwd),t.instanceId!==void 0&&(e.instanceId=t.instanceId),new oi("backlog",cf,e)}function yb(t,e){return`${t}:${e}`}function Ua(t){if(!t.run)throw new Error(`@adhd/backlog: apigen plugin "${t.id}" declares no run() — cannot mount live`);return t.run}function ff(){return q.join(q.dirname(bf.fileURLToPath(typeof document>"u"?require("url").pathToFileURL(__filename).href:Rr&&Rr.tagName.toUpperCase()==="SCRIPT"&&Rr.src||new URL("index.js",document.baseURI).href)),"..","dist")}function Va(t){if(!t||typeof t!="object")return t;const e={},n=s=>{if(Array.isArray(s)){for(const i of s)n(i);return}if(!s||typeof s!="object")return;const o=s;for(const i of["definitions","$defs"]){const a=o[i];if(a&&typeof a=="object"&&!Array.isArray(a))for(const[c,u]of Object.entries(a))c in e||(e[c]=u)}for(const[i,a]of Object.entries(o))i==="definitions"||i==="$defs"||n(a)};if(n(t),n(e),Object.keys(e).length===0)return t;const r=(s,o)=>{if(Array.isArray(s))return s.map(u=>r(u,o));if(!s||typeof s!="object")return s;const i=s,a=i.$ref;if(typeof a=="string"){const u=a.replace(/^#\/(?:definitions|\$defs)\//,"");return o.has(u)||!(u in e)?{}:r(e[u],new Set([...o,u]))}const c={};for(const[u,l]of Object.entries(i))u==="definitions"||u==="$defs"||(c[u]=r(l,o));return c};return r(t,new Set)}async function vb(){const t=q.join(ff(),"client.d.ts");if(!Y.existsSync(t))throw new Error(`@adhd/backlog: cannot mount — ${t} does not exist. Run "nx build backlog" first (extract() needs the built .d.ts for type information).`);return rp({sourceFile:t,namespace:"backlog"})}async function df(t){const e=await vb(),n={schemas:Object.fromEntries(e.filter(s=>s.kind==="action").map(s=>{var o;return[((o=s.path[s.path.length-1])==null?void 0:o.raw)??"",{input:Va(s.input),output:Va(s.output),hasCtx:s.hasCtx,safe:s.safe}]}))};return{pkg:{id:"backlog",schemas:Pd(n,[]),importPath:q.join(ff(),"client.js"),fns:Ed,createClient:async()=>t},operations:e}}async function $b(t){const e=lf({scope:t.scope,adhdRoot:t.adhdRoot,cwd:t.cwd});e.ensureDirs();const n=hu(e.files.db),r={store:n,env:e},{pkg:s,operations:o}=await df(r),i=[];(t.transport==="http"||t.transport==="both")&&i.push(Ua(dh)({packages:[s],outputDir:"",options:{port:t.port??3300,host:t.host??"127.0.0.1",usePlugins:[Sh]},signal:t.signal,operations:o})),(t.transport==="mcp"||t.transport==="both")&&i.push(Ua(gm)({packages:[s],outputDir:"",options:{transport:"stdio"},signal:t.signal,operations:o}));try{await Promise.all(i)}finally{mu(n)}}exports.BacklogItemNotFoundError=ye;exports.CitationRequiredError=Wa;exports.ClaimHeldError=Ja;exports.DependencyCycleError=xf;exports.ReasonRequiredError=Ha;exports.TERMINAL_DISMISSED_STATUSES=Ga;exports.TERMINAL_DONE_STATUSES=Ka;exports.TERMINAL_STATUSES=Ps;exports.TERMINAL_WORKAROUND_STATUSES=za;exports.addCitation=xc;exports.addDependency=Mc;exports.appendNote=Tc;exports.archiveResolved=Rc;exports.assignItem=Ac;exports.attachToPlan=qc;exports.auditTrail=Wc;exports.backlogEnvironmentSpec=cf;exports.blockers=Ec;exports.buildBacklogApigenPackage=df;exports.buildBacklogEnv=lf;exports.buildChangelogSection=dc;exports.claimItem=_c;exports.classifyStatus=ic;exports.closeGraphBacklogStore=mu;exports.createItem=hc;exports.dependencyGraph=Sc;exports.detectPriority=cc;exports.detectStatus=ac;exports.exportJson=Gc;exports.getItem=mc;exports.importFromMarkdown=Kc;exports.isTerminalStatus=je;exports.linkRelated=Lc;exports.listItems=yc;exports.mergeItems=Vc;exports.normalizeLegacyStatus=oc;exports.openGraphBacklogStore=hu;exports.parseBacklogMarkdown=uc;exports.readyItems=bc;exports.releaseClaim=Ic;exports.removeDependency=Dc;exports.renderItemsToMarkdown=fc;exports.renderToMarkdown=zc;exports.renewClaim=kc;exports.requiresCitation=js;exports.requiresReason=xs;exports.resolveBacklogScope=uf;exports.resolveItem=Cc;exports.setPriority=Fc;exports.softDeleteItem=vc;exports.splitItem=Uc;exports.spotlight=wc;exports.staleClaims=Oc;exports.startBacklogServer=$b;exports.startWork=Pc;exports.stats=$c;exports.suggestClaimantIdentity=yb;exports.supersedeItem=Bc;exports.toImportItems=pc;exports.topoOrder=Nc;exports.transitionStatus=jc;exports.updateItem=gc;