yaml-flow 8.5.1 → 8.5.3

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.
@@ -1,20 +1,20 @@
1
- 'use strict';var child_process=require('child_process'),$=require('fs'),Qn=require('os'),se=require('path'),ya=require('net'),url=require('url'),crypto=require('crypto'),module$1=require('module'),properLockfile=require('proper-lockfile'),$h=require('ajv-formats');var _documentCurrentScript=typeof document!=='undefined'?document.currentScript:null;function _interopDefault(e){return e&&e.__esModule?e:{default:e}}function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var $__namespace=/*#__PURE__*/_interopNamespace($);var Qn__namespace=/*#__PURE__*/_interopNamespace(Qn);var se__namespace=/*#__PURE__*/_interopNamespace(se);var ya__namespace=/*#__PURE__*/_interopNamespace(ya);var $h__default=/*#__PURE__*/_interopDefault($h);var dd=Object.create;var pa=Object.defineProperty;var ld=Object.getOwnPropertyDescriptor;var fd=Object.getOwnPropertyNames;var pd=Object.getPrototypeOf,md=Object.prototype.hasOwnProperty;var O=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var gd=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of fd(t))!md.call(e,s)&&s!==r&&pa(e,s,{get:()=>t[s],enumerable:!(n=ld(t,s))||n.enumerable});return e};var hd=(e,t,r)=>(r=e!=null?dd(pd(e)):{},gd(pa(r,"default",{value:e,enumerable:true}),e));var mr=O(ue=>{Object.defineProperty(ue,"__esModule",{value:true});ue.regexpCode=ue.getEsmExportName=ue.getProperty=ue.safeStringify=ue.stringify=ue.strConcat=ue.addCodeArg=ue.str=ue._=ue.nil=ue._Code=ue.Name=ue.IDENTIFIER=ue._CodeOrName=void 0;var fr=class{};ue._CodeOrName=fr;ue.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var Pt=class extends fr{constructor(t){if(super(),!ue.IDENTIFIER.test(t))throw new Error("CodeGen: name must be a valid identifier");this.str=t;}toString(){return this.str}emptyStr(){return false}get names(){return {[this.str]:1}}};ue.Name=Pt;var Ke=class extends fr{constructor(t){super(),this._items=typeof t=="string"?[t]:t;}toString(){return this.str}emptyStr(){if(this._items.length>1)return false;let t=this._items[0];return t===""||t==='""'}get str(){var t;return (t=this._str)!==null&&t!==void 0?t:this._str=this._items.reduce((r,n)=>`${r}${n}`,"")}get names(){var t;return (t=this._names)!==null&&t!==void 0?t:this._names=this._items.reduce((r,n)=>(n instanceof Pt&&(r[n.str]=(r[n.str]||0)+1),r),{})}};ue._Code=Ke;ue.nil=new Ke("");function Ba(e,...t){let r=[e[0]],n=0;for(;n<t.length;)fs(r,t[n]),r.push(e[++n]);return new Ke(r)}ue._=Ba;var ls=new Ke("+");function Va(e,...t){let r=[pr(e[0])],n=0;for(;n<t.length;)r.push(ls),fs(r,t[n]),r.push(ls,pr(e[++n]));return Zd(r),new Ke(r)}ue.str=Va;function fs(e,t){t instanceof Ke?e.push(...t._items):t instanceof Pt?e.push(t):e.push(rl(t));}ue.addCodeArg=fs;function Zd(e){let t=1;for(;t<e.length-1;){if(e[t]===ls){let r=el(e[t-1],e[t+1]);if(r!==void 0){e.splice(t-1,3,r);continue}e[t++]="+";}t++;}}function el(e,t){if(t==='""')return e;if(e==='""')return t;if(typeof e=="string")return t instanceof Pt||e[e.length-1]!=='"'?void 0:typeof t!="string"?`${e.slice(0,-1)}${t}"`:t[0]==='"'?e.slice(0,-1)+t.slice(1):void 0;if(typeof t=="string"&&t[0]==='"'&&!(e instanceof Pt))return `"${e}${t.slice(1)}`}function tl(e,t){return t.emptyStr()?e:e.emptyStr()?t:Va`${e}${t}`}ue.strConcat=tl;function rl(e){return typeof e=="number"||typeof e=="boolean"||e===null?e:pr(Array.isArray(e)?e.join(","):e)}function nl(e){return new Ke(pr(e))}ue.stringify=nl;function pr(e){return JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}ue.safeStringify=pr;function sl(e){return typeof e=="string"&&ue.IDENTIFIER.test(e)?new Ke(`.${e}`):Ba`[${e}]`}ue.getProperty=sl;function ol(e){if(typeof e=="string"&&ue.IDENTIFIER.test(e))return new Ke(`${e}`);throw new Error(`CodeGen: invalid export name: ${e}, use explicit $id name mapping`)}ue.getEsmExportName=ol;function al(e){return new Ke(e.toString())}ue.regexpCode=al;});var gs=O(Fe=>{Object.defineProperty(Fe,"__esModule",{value:true});Fe.ValueScope=Fe.ValueScopeName=Fe.Scope=Fe.varKinds=Fe.UsedValueState=void 0;var qe=mr(),ps=class extends Error{constructor(t){super(`CodeGen: "code" for ${t} not defined`),this.value=t.value;}},sn;(function(e){e[e.Started=0]="Started",e[e.Completed=1]="Completed";})(sn||(Fe.UsedValueState=sn={}));Fe.varKinds={const:new qe.Name("const"),let:new qe.Name("let"),var:new qe.Name("var")};var on=class{constructor({prefixes:t,parent:r}={}){this._names={},this._prefixes=t,this._parent=r;}toName(t){return t instanceof qe.Name?t:this.name(t)}name(t){return new qe.Name(this._newName(t))}_newName(t){let r=this._names[t]||this._nameGroup(t);return `${t}${r.index++}`}_nameGroup(t){var r,n;if(!((n=(r=this._parent)===null||r===void 0?void 0:r._prefixes)===null||n===void 0)&&n.has(t)||this._prefixes&&!this._prefixes.has(t))throw new Error(`CodeGen: prefix "${t}" is not allowed in this scope`);return this._names[t]={prefix:t,index:0}}};Fe.Scope=on;var an=class extends qe.Name{constructor(t,r){super(r),this.prefix=t;}setValue(t,{property:r,itemIndex:n}){this.value=t,this.scopePath=(0, qe._)`.${new qe.Name(r)}[${n}]`;}};Fe.ValueScopeName=an;var il=(0, qe._)`\n`,ms=class extends on{constructor(t){super(t),this._values={},this._scope=t.scope,this.opts={...t,_n:t.lines?il:qe.nil};}get(){return this._scope}name(t){return new an(t,this._newName(t))}value(t,r){var n;if(r.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let s=this.toName(t),{prefix:o}=s,a=(n=r.key)!==null&&n!==void 0?n:r.ref,i=this._values[o];if(i){let d=i.get(a);if(d)return d}else i=this._values[o]=new Map;i.set(a,s);let u=this._scope[o]||(this._scope[o]=[]),c=u.length;return u[c]=r.ref,s.setValue(r,{property:o,itemIndex:c}),s}getValue(t,r){let n=this._values[t];if(n)return n.get(r)}scopeRefs(t,r=this._values){return this._reduceValues(r,n=>{if(n.scopePath===void 0)throw new Error(`CodeGen: name "${n}" has no value`);return (0, qe._)`${t}${n.scopePath}`})}scopeCode(t=this._values,r,n){return this._reduceValues(t,s=>{if(s.value===void 0)throw new Error(`CodeGen: name "${s}" has no value`);return s.value.code},r,n)}_reduceValues(t,r,n={},s){let o=qe.nil;for(let a in t){let i=t[a];if(!i)continue;let u=n[a]=n[a]||new Map;i.forEach(c=>{if(u.has(c))return;u.set(c,sn.Started);let d=r(c);if(d){let l=this.opts.es5?Fe.varKinds.var:Fe.varKinds.const;o=(0, qe._)`${o}${l} ${c} = ${d};${this.opts._n}`;}else if(d=s?.(c))o=(0, qe._)`${o}${d}${this.opts._n}`;else throw new ps(c);u.set(c,sn.Completed);});}return o}};Fe.ValueScope=ms;});var W=O(H=>{Object.defineProperty(H,"__esModule",{value:true});H.or=H.and=H.not=H.CodeGen=H.operators=H.varKinds=H.ValueScopeName=H.ValueScope=H.Scope=H.Name=H.regexpCode=H.stringify=H.getProperty=H.nil=H.strConcat=H.str=H._=void 0;var re=mr(),Qe=gs(),vt=mr();Object.defineProperty(H,"_",{enumerable:true,get:function(){return vt._}});Object.defineProperty(H,"str",{enumerable:true,get:function(){return vt.str}});Object.defineProperty(H,"strConcat",{enumerable:true,get:function(){return vt.strConcat}});Object.defineProperty(H,"nil",{enumerable:true,get:function(){return vt.nil}});Object.defineProperty(H,"getProperty",{enumerable:true,get:function(){return vt.getProperty}});Object.defineProperty(H,"stringify",{enumerable:true,get:function(){return vt.stringify}});Object.defineProperty(H,"regexpCode",{enumerable:true,get:function(){return vt.regexpCode}});Object.defineProperty(H,"Name",{enumerable:true,get:function(){return vt.Name}});var ln=gs();Object.defineProperty(H,"Scope",{enumerable:true,get:function(){return ln.Scope}});Object.defineProperty(H,"ValueScope",{enumerable:true,get:function(){return ln.ValueScope}});Object.defineProperty(H,"ValueScopeName",{enumerable:true,get:function(){return ln.ValueScopeName}});Object.defineProperty(H,"varKinds",{enumerable:true,get:function(){return ln.varKinds}});H.operators={GT:new re._Code(">"),GTE:new re._Code(">="),LT:new re._Code("<"),LTE:new re._Code("<="),EQ:new re._Code("==="),NEQ:new re._Code("!=="),NOT:new re._Code("!"),OR:new re._Code("||"),AND:new re._Code("&&"),ADD:new re._Code("+")};var dt=class{optimizeNodes(){return this}optimizeNames(t,r){return this}},hs=class extends dt{constructor(t,r,n){super(),this.varKind=t,this.name=r,this.rhs=n;}render({es5:t,_n:r}){let n=t?Qe.varKinds.var:this.varKind,s=this.rhs===void 0?"":` = ${this.rhs}`;return `${n} ${this.name}${s};`+r}optimizeNames(t,r){if(t[this.name.str])return this.rhs&&(this.rhs=Xt(this.rhs,t,r)),this}get names(){return this.rhs instanceof re._CodeOrName?this.rhs.names:{}}},cn=class extends dt{constructor(t,r,n){super(),this.lhs=t,this.rhs=r,this.sideEffects=n;}render({_n:t}){return `${this.lhs} = ${this.rhs};`+t}optimizeNames(t,r){if(!(this.lhs instanceof re.Name&&!t[this.lhs.str]&&!this.sideEffects))return this.rhs=Xt(this.rhs,t,r),this}get names(){let t=this.lhs instanceof re.Name?{}:{...this.lhs.names};return dn(t,this.rhs)}},ys=class extends cn{constructor(t,r,n,s){super(t,n,s),this.op=r;}render({_n:t}){return `${this.lhs} ${this.op}= ${this.rhs};`+t}},vs=class extends dt{constructor(t){super(),this.label=t,this.names={};}render({_n:t}){return `${this.label}:`+t}},Ss=class extends dt{constructor(t){super(),this.label=t,this.names={};}render({_n:t}){return `break${this.label?` ${this.label}`:""};`+t}},ws=class extends dt{constructor(t){super(),this.error=t;}render({_n:t}){return `throw ${this.error};`+t}get names(){return this.error.names}},ks=class extends dt{constructor(t){super(),this.code=t;}render({_n:t}){return `${this.code};`+t}optimizeNodes(){return `${this.code}`?this:void 0}optimizeNames(t,r){return this.code=Xt(this.code,t,r),this}get names(){return this.code instanceof re._CodeOrName?this.code.names:{}}},gr=class extends dt{constructor(t=[]){super(),this.nodes=t;}render(t){return this.nodes.reduce((r,n)=>r+n.render(t),"")}optimizeNodes(){let{nodes:t}=this,r=t.length;for(;r--;){let n=t[r].optimizeNodes();Array.isArray(n)?t.splice(r,1,...n):n?t[r]=n:t.splice(r,1);}return t.length>0?this:void 0}optimizeNames(t,r){let{nodes:n}=this,s=n.length;for(;s--;){let o=n[s];o.optimizeNames(t,r)||(cl(t,o.names),n.splice(s,1));}return n.length>0?this:void 0}get names(){return this.nodes.reduce((t,r)=>Ft(t,r.names),{})}},lt=class extends gr{render(t){return "{"+t._n+super.render(t)+"}"+t._n}},bs=class extends gr{},Yt=class extends lt{};Yt.kind="else";var Nt=class e extends lt{constructor(t,r){super(r),this.condition=t;}render(t){let r=`if(${this.condition})`+super.render(t);return this.else&&(r+="else "+this.else.render(t)),r}optimizeNodes(){super.optimizeNodes();let t=this.condition;if(t===true)return this.nodes;let r=this.else;if(r){let n=r.optimizeNodes();r=this.else=Array.isArray(n)?new Yt(n):n;}if(r)return t===false?r instanceof e?r:r.nodes:this.nodes.length?this:new e(Ua(t),r instanceof e?[r]:r.nodes);if(!(t===false||!this.nodes.length))return this}optimizeNames(t,r){var n;if(this.else=(n=this.else)===null||n===void 0?void 0:n.optimizeNames(t,r),!!(super.optimizeNames(t,r)||this.else))return this.condition=Xt(this.condition,t,r),this}get names(){let t=super.names;return dn(t,this.condition),this.else&&Ft(t,this.else.names),t}};Nt.kind="if";var qt=class extends lt{};qt.kind="for";var Rs=class extends qt{constructor(t){super(),this.iteration=t;}render(t){return `for(${this.iteration})`+super.render(t)}optimizeNames(t,r){if(super.optimizeNames(t,r))return this.iteration=Xt(this.iteration,t,r),this}get names(){return Ft(super.names,this.iteration.names)}},_s=class extends qt{constructor(t,r,n,s){super(),this.varKind=t,this.name=r,this.from=n,this.to=s;}render(t){let r=t.es5?Qe.varKinds.var:this.varKind,{name:n,from:s,to:o}=this;return `for(${r} ${n}=${s}; ${n}<${o}; ${n}++)`+super.render(t)}get names(){let t=dn(super.names,this.from);return dn(t,this.to)}},un=class extends qt{constructor(t,r,n,s){super(),this.loop=t,this.varKind=r,this.name=n,this.iterable=s;}render(t){return `for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(t)}optimizeNames(t,r){if(super.optimizeNames(t,r))return this.iterable=Xt(this.iterable,t,r),this}get names(){return Ft(super.names,this.iterable.names)}},hr=class extends lt{constructor(t,r,n){super(),this.name=t,this.args=r,this.async=n;}render(t){return `${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(t)}};hr.kind="func";var yr=class extends gr{render(t){return "return "+super.render(t)}};yr.kind="return";var Cs=class extends lt{render(t){let r="try"+super.render(t);return this.catch&&(r+=this.catch.render(t)),this.finally&&(r+=this.finally.render(t)),r}optimizeNodes(){var t,r;return super.optimizeNodes(),(t=this.catch)===null||t===void 0||t.optimizeNodes(),(r=this.finally)===null||r===void 0||r.optimizeNodes(),this}optimizeNames(t,r){var n,s;return super.optimizeNames(t,r),(n=this.catch)===null||n===void 0||n.optimizeNames(t,r),(s=this.finally)===null||s===void 0||s.optimizeNames(t,r),this}get names(){let t=super.names;return this.catch&&Ft(t,this.catch.names),this.finally&&Ft(t,this.finally.names),t}},vr=class extends lt{constructor(t){super(),this.error=t;}render(t){return `catch(${this.error})`+super.render(t)}};vr.kind="catch";var Sr=class extends lt{render(t){return "finally"+super.render(t)}};Sr.kind="finally";var $s=class{constructor(t,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
2
- `:""},this._extScope=t,this._scope=new Qe.Scope({parent:t}),this._nodes=[new bs];}toString(){return this._root.render(this.opts)}name(t){return this._scope.name(t)}scopeName(t){return this._extScope.name(t)}scopeValue(t,r){let n=this._extScope.value(t,r);return (this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(t,r){return this._extScope.getValue(t,r)}scopeRefs(t){return this._extScope.scopeRefs(t,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(t,r,n,s){let o=this._scope.toName(r);return n!==void 0&&s&&(this._constants[o.str]=n),this._leafNode(new hs(t,o,n)),o}const(t,r,n){return this._def(Qe.varKinds.const,t,r,n)}let(t,r,n){return this._def(Qe.varKinds.let,t,r,n)}var(t,r,n){return this._def(Qe.varKinds.var,t,r,n)}assign(t,r,n){return this._leafNode(new cn(t,r,n))}add(t,r){return this._leafNode(new ys(t,H.operators.ADD,r))}code(t){return typeof t=="function"?t():t!==re.nil&&this._leafNode(new ks(t)),this}object(...t){let r=["{"];for(let[n,s]of t)r.length>1&&r.push(","),r.push(n),(n!==s||this.opts.es5)&&(r.push(":"),(0, re.addCodeArg)(r,s));return r.push("}"),new re._Code(r)}if(t,r,n){if(this._blockNode(new Nt(t)),r&&n)this.code(r).else().code(n).endIf();else if(r)this.code(r).endIf();else if(n)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(t){return this._elseNode(new Nt(t))}else(){return this._elseNode(new Yt)}endIf(){return this._endBlockNode(Nt,Yt)}_for(t,r){return this._blockNode(t),r&&this.code(r).endFor(),this}for(t,r){return this._for(new Rs(t),r)}forRange(t,r,n,s,o=this.opts.es5?Qe.varKinds.var:Qe.varKinds.let){let a=this._scope.toName(t);return this._for(new _s(o,a,r,n),()=>s(a))}forOf(t,r,n,s=Qe.varKinds.const){let o=this._scope.toName(t);if(this.opts.es5){let a=r instanceof re.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0, re._)`${a}.length`,i=>{this.var(o,(0, re._)`${a}[${i}]`),n(o);})}return this._for(new un("of",s,o,r),()=>n(o))}forIn(t,r,n,s=this.opts.es5?Qe.varKinds.var:Qe.varKinds.const){if(this.opts.ownProperties)return this.forOf(t,(0, re._)`Object.keys(${r})`,n);let o=this._scope.toName(t);return this._for(new un("in",s,o,r),()=>n(o))}endFor(){return this._endBlockNode(qt)}label(t){return this._leafNode(new vs(t))}break(t){return this._leafNode(new Ss(t))}return(t){let r=new yr;if(this._blockNode(r),this.code(t),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(yr)}try(t,r,n){if(!r&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let s=new Cs;if(this._blockNode(s),this.code(t),r){let o=this.name("e");this._currNode=s.catch=new vr(o),r(o);}return n&&(this._currNode=s.finally=new Sr,this.code(n)),this._endBlockNode(vr,Sr)}throw(t){return this._leafNode(new ws(t))}block(t,r){return this._blockStarts.push(this._nodes.length),t&&this.code(t).endBlock(r),this}endBlock(t){let r=this._blockStarts.pop();if(r===void 0)throw new Error("CodeGen: not in self-balancing block");let n=this._nodes.length-r;if(n<0||t!==void 0&&n!==t)throw new Error(`CodeGen: wrong number of nodes: ${n} vs ${t} expected`);return this._nodes.length=r,this}func(t,r=re.nil,n,s){return this._blockNode(new hr(t,r,n)),s&&this.code(s).endFunc(),this}endFunc(){return this._endBlockNode(hr)}optimize(t=1){for(;t-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants);}_leafNode(t){return this._currNode.nodes.push(t),this}_blockNode(t){this._currNode.nodes.push(t),this._nodes.push(t);}_endBlockNode(t,r){let n=this._currNode;if(n instanceof t||r&&n instanceof r)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${r?`${t.kind}/${r.kind}`:t.kind}"`)}_elseNode(t){let r=this._currNode;if(!(r instanceof Nt))throw new Error('CodeGen: "else" without "if"');return this._currNode=r.else=t,this}get _root(){return this._nodes[0]}get _currNode(){let t=this._nodes;return t[t.length-1]}set _currNode(t){let r=this._nodes;r[r.length-1]=t;}};H.CodeGen=$s;function Ft(e,t){for(let r in t)e[r]=(e[r]||0)+(t[r]||0);return e}function dn(e,t){return t instanceof re._CodeOrName?Ft(e,t.names):e}function Xt(e,t,r){if(e instanceof re.Name)return n(e);if(!s(e))return e;return new re._Code(e._items.reduce((o,a)=>(a instanceof re.Name&&(a=n(a)),a instanceof re._Code?o.push(...a._items):o.push(a),o),[]));function n(o){let a=r[o.str];return a===void 0||t[o.str]!==1?o:(delete t[o.str],a)}function s(o){return o instanceof re._Code&&o._items.some(a=>a instanceof re.Name&&t[a.str]===1&&r[a.str]!==void 0)}}function cl(e,t){for(let r in t)e[r]=(e[r]||0)-(t[r]||0);}function Ua(e){return typeof e=="boolean"||typeof e=="number"||e===null?!e:(0, re._)`!${Es(e)}`}H.not=Ua;var ul=Ka(H.operators.AND);function dl(...e){return e.reduce(ul)}H.and=dl;var ll=Ka(H.operators.OR);function fl(...e){return e.reduce(ll)}H.or=fl;function Ka(e){return (t,r)=>t===re.nil?r:r===re.nil?t:(0, re._)`${Es(t)} ${e} ${Es(r)}`}function Es(e){return e instanceof re.Name?e:(0, re._)`(${e})`}});var oe=O(Y=>{Object.defineProperty(Y,"__esModule",{value:true});Y.checkStrictMode=Y.getErrorPath=Y.Type=Y.useFunc=Y.setEvaluated=Y.evaluatedPropsToName=Y.mergeEvaluated=Y.eachItem=Y.unescapeJsonPointer=Y.escapeJsonPointer=Y.escapeFragment=Y.unescapeFragment=Y.schemaRefOrVal=Y.schemaHasRulesButRef=Y.schemaHasRules=Y.checkUnknownRules=Y.alwaysValidSchema=Y.toHash=void 0;var fe=W(),pl=mr();function ml(e){let t={};for(let r of e)t[r]=true;return t}Y.toHash=ml;function gl(e,t){return typeof t=="boolean"?t:Object.keys(t).length===0?true:(za(e,t),!Ha(t,e.self.RULES.all))}Y.alwaysValidSchema=gl;function za(e,t=e.schema){let{opts:r,self:n}=e;if(!r.strictSchema||typeof t=="boolean")return;let s=n.RULES.keywords;for(let o in t)s[o]||Xa(e,`unknown keyword: "${o}"`);}Y.checkUnknownRules=za;function Ha(e,t){if(typeof e=="boolean")return !e;for(let r in e)if(t[r])return true;return false}Y.schemaHasRules=Ha;function hl(e,t){if(typeof e=="boolean")return !e;for(let r in e)if(r!=="$ref"&&t.all[r])return true;return false}Y.schemaHasRulesButRef=hl;function yl({topSchemaRef:e,schemaPath:t},r,n,s){if(!s){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return (0, fe._)`${r}`}return (0, fe._)`${e}${t}${(0, fe.getProperty)(n)}`}Y.schemaRefOrVal=yl;function vl(e){return Wa(decodeURIComponent(e))}Y.unescapeFragment=vl;function Sl(e){return encodeURIComponent(As(e))}Y.escapeFragment=Sl;function As(e){return typeof e=="number"?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}Y.escapeJsonPointer=As;function Wa(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}Y.unescapeJsonPointer=Wa;function wl(e,t){if(Array.isArray(e))for(let r of e)t(r);else t(e);}Y.eachItem=wl;function Ga({mergeNames:e,mergeToName:t,mergeValues:r,resultToName:n}){return (s,o,a,i)=>{let u=a===void 0?o:a instanceof fe.Name?(o instanceof fe.Name?e(s,o,a):t(s,o,a),a):o instanceof fe.Name?(t(s,a,o),o):r(o,a);return i===fe.Name&&!(u instanceof fe.Name)?n(s,u):u}}Y.mergeEvaluated={props:Ga({mergeNames:(e,t,r)=>e.if((0, fe._)`${r} !== true && ${t} !== undefined`,()=>{e.if((0, fe._)`${t} === true`,()=>e.assign(r,true),()=>e.assign(r,(0, fe._)`${r} || {}`).code((0, fe._)`Object.assign(${r}, ${t})`));}),mergeToName:(e,t,r)=>e.if((0, fe._)`${r} !== true`,()=>{t===true?e.assign(r,true):(e.assign(r,(0, fe._)`${r} || {}`),Ts(e,r,t));}),mergeValues:(e,t)=>e===true?true:{...e,...t},resultToName:Ya}),items:Ga({mergeNames:(e,t,r)=>e.if((0, fe._)`${r} !== true && ${t} !== undefined`,()=>e.assign(r,(0, fe._)`${t} === true ? true : ${r} > ${t} ? ${r} : ${t}`)),mergeToName:(e,t,r)=>e.if((0, fe._)`${r} !== true`,()=>e.assign(r,t===true?true:(0, fe._)`${r} > ${t} ? ${r} : ${t}`)),mergeValues:(e,t)=>e===true?true:Math.max(e,t),resultToName:(e,t)=>e.var("items",t)})};function Ya(e,t){if(t===true)return e.var("props",true);let r=e.var("props",(0, fe._)`{}`);return t!==void 0&&Ts(e,r,t),r}Y.evaluatedPropsToName=Ya;function Ts(e,t,r){Object.keys(r).forEach(n=>e.assign((0, fe._)`${t}${(0, fe.getProperty)(n)}`,true));}Y.setEvaluated=Ts;var Ja={};function kl(e,t){return e.scopeValue("func",{ref:t,code:Ja[t.code]||(Ja[t.code]=new pl._Code(t.code))})}Y.useFunc=kl;var xs;(function(e){e[e.Num=0]="Num",e[e.Str=1]="Str";})(xs||(Y.Type=xs={}));function bl(e,t,r){if(e instanceof fe.Name){let n=t===xs.Num;return r?n?(0, fe._)`"[" + ${e} + "]"`:(0, fe._)`"['" + ${e} + "']"`:n?(0, fe._)`"/" + ${e}`:(0, fe._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0, fe.getProperty)(e).toString():"/"+As(e)}Y.getErrorPath=bl;function Xa(e,t,r=e.opts.strictSchema){if(r){if(t=`strict mode: ${t}`,r===true)throw new Error(t);e.self.logger.warn(t);}}Y.checkStrictMode=Xa;});var ft=O(Is=>{Object.defineProperty(Is,"__esModule",{value:true});var Ce=W(),Rl={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")};Is.default=Rl;});var wr=O($e=>{Object.defineProperty($e,"__esModule",{value:true});$e.extendErrors=$e.resetErrorsCount=$e.reportExtraError=$e.reportError=$e.keyword$DataError=$e.keywordError=void 0;var ae=W(),fn=oe(),Te=ft();$e.keywordError={message:({keyword:e})=>(0, ae.str)`must pass "${e}" keyword validation`};$e.keyword$DataError={message:({keyword:e,schemaType:t})=>t?(0, ae.str)`"${e}" keyword must be ${t} ($data)`:(0, ae.str)`"${e}" keyword is invalid ($data)`};function _l(e,t=$e.keywordError,r,n){let{it:s}=e,{gen:o,compositeRule:a,allErrors:i}=s,u=ei(e,t,r);n??(a||i)?Qa(o,u):Za(s,(0, ae._)`[${u}]`);}$e.reportError=_l;function Cl(e,t=$e.keywordError,r){let{it:n}=e,{gen:s,compositeRule:o,allErrors:a}=n,i=ei(e,t,r);Qa(s,i),o||a||Za(n,Te.default.vErrors);}$e.reportExtraError=Cl;function $l(e,t){e.assign(Te.default.errors,t),e.if((0, ae._)`${Te.default.vErrors} !== null`,()=>e.if(t,()=>e.assign((0, ae._)`${Te.default.vErrors}.length`,t),()=>e.assign(Te.default.vErrors,null)));}$e.resetErrorsCount=$l;function El({gen:e,keyword:t,schemaValue:r,data:n,errsCount:s,it:o}){if(s===void 0)throw new Error("ajv implementation error");let a=e.name("err");e.forRange("i",s,Te.default.errors,i=>{e.const(a,(0, ae._)`${Te.default.vErrors}[${i}]`),e.if((0, ae._)`${a}.instancePath === undefined`,()=>e.assign((0, ae._)`${a}.instancePath`,(0, ae.strConcat)(Te.default.instancePath,o.errorPath))),e.assign((0, ae._)`${a}.schemaPath`,(0, ae.str)`${o.errSchemaPath}/${t}`),o.opts.verbose&&(e.assign((0, ae._)`${a}.schema`,r),e.assign((0, ae._)`${a}.data`,n));});}$e.extendErrors=El;function Qa(e,t){let r=e.const("err",t);e.if((0, ae._)`${Te.default.vErrors} === null`,()=>e.assign(Te.default.vErrors,(0, ae._)`[${r}]`),(0, ae._)`${Te.default.vErrors}.push(${r})`),e.code((0, ae._)`${Te.default.errors}++`);}function Za(e,t){let{gen:r,validateName:n,schemaEnv:s}=e;s.$async?r.throw((0, ae._)`new ${e.ValidationError}(${t})`):(r.assign((0, ae._)`${n}.errors`,t),r.return(false));}var Mt={keyword:new ae.Name("keyword"),schemaPath:new ae.Name("schemaPath"),params:new ae.Name("params"),propertyName:new ae.Name("propertyName"),message:new ae.Name("message"),schema:new ae.Name("schema"),parentSchema:new ae.Name("parentSchema")};function ei(e,t,r){let{createErrors:n}=e.it;return n===false?(0, ae._)`{}`:xl(e,t,r)}function xl(e,t,r={}){let{gen:n,it:s}=e,o=[Al(s,r),Tl(e,r)];return Il(e,t,o),n.object(...o)}function Al({errorPath:e},{instancePath:t}){let r=t?(0, ae.str)`${e}${(0, fn.getErrorPath)(t,fn.Type.Str)}`:e;return [Te.default.instancePath,(0, ae.strConcat)(Te.default.instancePath,r)]}function Tl({keyword:e,it:{errSchemaPath:t}},{schemaPath:r,parentSchema:n}){let s=n?t:(0, ae.str)`${t}/${e}`;return r&&(s=(0, ae.str)`${s}${(0, fn.getErrorPath)(r,fn.Type.Str)}`),[Mt.schemaPath,s]}function Il(e,{params:t,message:r},n){let{keyword:s,data:o,schemaValue:a,it:i}=e,{opts:u,propertyName:c,topSchemaRef:d,schemaPath:l}=i;n.push([Mt.keyword,s],[Mt.params,typeof t=="function"?t(e):t||(0, ae._)`{}`]),u.messages&&n.push([Mt.message,typeof r=="function"?r(e):r]),u.verbose&&n.push([Mt.schema,a],[Mt.parentSchema,(0, ae._)`${d}${l}`],[Te.default.data,o]),c&&n.push([Mt.propertyName,c]);}});var ri=O(Qt=>{Object.defineProperty(Qt,"__esModule",{value:true});Qt.boolOrEmptySchema=Qt.topBoolOrEmptySchema=void 0;var jl=wr(),Ol=W(),Pl=ft(),Nl={message:"boolean schema is false"};function ql(e){let{gen:t,schema:r,validateName:n}=e;r===false?ti(e,false):typeof r=="object"&&r.$async===true?t.return(Pl.default.data):(t.assign((0, Ol._)`${n}.errors`,null),t.return(true));}Qt.topBoolOrEmptySchema=ql;function Fl(e,t){let{gen:r,schema:n}=e;n===false?(r.var(t,false),ti(e)):r.var(t,true);}Qt.boolOrEmptySchema=Fl;function ti(e,t){let{gen:r,data:n}=e,s={gen:r,keyword:"false schema",data:n,schema:false,schemaCode:false,schemaValue:false,params:{},it:e};(0, jl.reportError)(s,Nl,void 0,t);}});var js=O(Zt=>{Object.defineProperty(Zt,"__esModule",{value:true});Zt.getRules=Zt.isJSONType=void 0;var Ml=["string","number","integer","boolean","null","object","array"],Dl=new Set(Ml);function Ll(e){return typeof e=="string"&&Dl.has(e)}Zt.isJSONType=Ll;function Bl(){let e={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return {types:{...e,integer:true,boolean:true,null:true},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}Zt.getRules=Bl;});var Os=O(St=>{Object.defineProperty(St,"__esModule",{value:true});St.shouldUseRule=St.shouldUseGroup=St.schemaHasRulesForType=void 0;function Vl({schema:e,self:t},r){let n=t.RULES.types[r];return n&&n!==true&&ni(e,n)}St.schemaHasRulesForType=Vl;function ni(e,t){return t.rules.some(r=>si(e,r))}St.shouldUseGroup=ni;function si(e,t){var r;return e[t.keyword]!==void 0||((r=t.definition.implements)===null||r===void 0?void 0:r.some(n=>e[n]!==void 0))}St.shouldUseRule=si;});var kr=O(Ee=>{Object.defineProperty(Ee,"__esModule",{value:true});Ee.reportTypeError=Ee.checkDataTypes=Ee.checkDataType=Ee.coerceAndCheckDataType=Ee.getJSONTypes=Ee.getSchemaTypes=Ee.DataType=void 0;var Ul=js(),Kl=Os(),Gl=wr(),J=W(),oi=oe(),er;(function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong";})(er||(Ee.DataType=er={}));function Jl(e){let t=ai(e.type);if(t.includes("null")){if(e.nullable===false)throw new Error("type: null contradicts nullable: false")}else {if(!t.length&&e.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');e.nullable===true&&t.push("null");}return t}Ee.getSchemaTypes=Jl;function ai(e){let t=Array.isArray(e)?e:e?[e]:[];if(t.every(Ul.isJSONType))return t;throw new Error("type must be JSONType or JSONType[]: "+t.join(","))}Ee.getJSONTypes=ai;function zl(e,t){let{gen:r,data:n,opts:s}=e,o=Hl(t,s.coerceTypes),a=t.length>0&&!(o.length===0&&t.length===1&&(0, Kl.schemaHasRulesForType)(e,t[0]));if(a){let i=Ns(t,n,s.strictNumbers,er.Wrong);r.if(i,()=>{o.length?Wl(e,t,o):qs(e);});}return a}Ee.coerceAndCheckDataType=zl;var ii=new Set(["string","number","integer","boolean","null"]);function Hl(e,t){return t?e.filter(r=>ii.has(r)||t==="array"&&r==="array"):[]}function Wl(e,t,r){let{gen:n,data:s,opts:o}=e,a=n.let("dataType",(0, J._)`typeof ${s}`),i=n.let("coerced",(0, J._)`undefined`);o.coerceTypes==="array"&&n.if((0, J._)`${a} == 'object' && Array.isArray(${s}) && ${s}.length == 1`,()=>n.assign(s,(0, J._)`${s}[0]`).assign(a,(0, J._)`typeof ${s}`).if(Ns(t,s,o.strictNumbers),()=>n.assign(i,s))),n.if((0, J._)`${i} !== undefined`);for(let c of r)(ii.has(c)||c==="array"&&o.coerceTypes==="array")&&u(c);n.else(),qs(e),n.endIf(),n.if((0, J._)`${i} !== undefined`,()=>{n.assign(s,i),Yl(e,i);});function u(c){switch(c){case "string":n.elseIf((0, J._)`${a} == "number" || ${a} == "boolean"`).assign(i,(0, J._)`"" + ${s}`).elseIf((0, J._)`${s} === null`).assign(i,(0, J._)`""`);return;case "number":n.elseIf((0, J._)`${a} == "boolean" || ${s} === null
1
+ 'use strict';var child_process=require('child_process'),$=require('fs'),Qn=require('os'),oe=require('path'),ya=require('net'),url=require('url'),crypto=require('crypto'),module$1=require('module'),properLockfile=require('proper-lockfile'),$h=require('ajv-formats');var _documentCurrentScript=typeof document!=='undefined'?document.currentScript:null;function _interopDefault(e){return e&&e.__esModule?e:{default:e}}function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var $__namespace=/*#__PURE__*/_interopNamespace($);var Qn__namespace=/*#__PURE__*/_interopNamespace(Qn);var oe__namespace=/*#__PURE__*/_interopNamespace(oe);var ya__namespace=/*#__PURE__*/_interopNamespace(ya);var $h__default=/*#__PURE__*/_interopDefault($h);var dd=Object.create;var pa=Object.defineProperty;var ld=Object.getOwnPropertyDescriptor;var fd=Object.getOwnPropertyNames;var pd=Object.getPrototypeOf,md=Object.prototype.hasOwnProperty;var O=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var gd=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of fd(t))!md.call(e,s)&&s!==r&&pa(e,s,{get:()=>t[s],enumerable:!(n=ld(t,s))||n.enumerable});return e};var hd=(e,t,r)=>(r=e!=null?dd(pd(e)):{},gd(pa(r,"default",{value:e,enumerable:true}),e));var mr=O(ce=>{Object.defineProperty(ce,"__esModule",{value:true});ce.regexpCode=ce.getEsmExportName=ce.getProperty=ce.safeStringify=ce.stringify=ce.strConcat=ce.addCodeArg=ce.str=ce._=ce.nil=ce._Code=ce.Name=ce.IDENTIFIER=ce._CodeOrName=void 0;var fr=class{};ce._CodeOrName=fr;ce.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var Pt=class extends fr{constructor(t){if(super(),!ce.IDENTIFIER.test(t))throw new Error("CodeGen: name must be a valid identifier");this.str=t;}toString(){return this.str}emptyStr(){return false}get names(){return {[this.str]:1}}};ce.Name=Pt;var ze=class extends fr{constructor(t){super(),this._items=typeof t=="string"?[t]:t;}toString(){return this.str}emptyStr(){if(this._items.length>1)return false;let t=this._items[0];return t===""||t==='""'}get str(){var t;return (t=this._str)!==null&&t!==void 0?t:this._str=this._items.reduce((r,n)=>`${r}${n}`,"")}get names(){var t;return (t=this._names)!==null&&t!==void 0?t:this._names=this._items.reduce((r,n)=>(n instanceof Pt&&(r[n.str]=(r[n.str]||0)+1),r),{})}};ce._Code=ze;ce.nil=new ze("");function Ba(e,...t){let r=[e[0]],n=0;for(;n<t.length;)fs(r,t[n]),r.push(e[++n]);return new ze(r)}ce._=Ba;var ls=new ze("+");function Va(e,...t){let r=[pr(e[0])],n=0;for(;n<t.length;)r.push(ls),fs(r,t[n]),r.push(ls,pr(e[++n]));return Zd(r),new ze(r)}ce.str=Va;function fs(e,t){t instanceof ze?e.push(...t._items):t instanceof Pt?e.push(t):e.push(rl(t));}ce.addCodeArg=fs;function Zd(e){let t=1;for(;t<e.length-1;){if(e[t]===ls){let r=el(e[t-1],e[t+1]);if(r!==void 0){e.splice(t-1,3,r);continue}e[t++]="+";}t++;}}function el(e,t){if(t==='""')return e;if(e==='""')return t;if(typeof e=="string")return t instanceof Pt||e[e.length-1]!=='"'?void 0:typeof t!="string"?`${e.slice(0,-1)}${t}"`:t[0]==='"'?e.slice(0,-1)+t.slice(1):void 0;if(typeof t=="string"&&t[0]==='"'&&!(e instanceof Pt))return `"${e}${t.slice(1)}`}function tl(e,t){return t.emptyStr()?e:e.emptyStr()?t:Va`${e}${t}`}ce.strConcat=tl;function rl(e){return typeof e=="number"||typeof e=="boolean"||e===null?e:pr(Array.isArray(e)?e.join(","):e)}function nl(e){return new ze(pr(e))}ce.stringify=nl;function pr(e){return JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}ce.safeStringify=pr;function sl(e){return typeof e=="string"&&ce.IDENTIFIER.test(e)?new ze(`.${e}`):Ba`[${e}]`}ce.getProperty=sl;function ol(e){if(typeof e=="string"&&ce.IDENTIFIER.test(e))return new ze(`${e}`);throw new Error(`CodeGen: invalid export name: ${e}, use explicit $id name mapping`)}ce.getEsmExportName=ol;function al(e){return new ze(e.toString())}ce.regexpCode=al;});var gs=O(Me=>{Object.defineProperty(Me,"__esModule",{value:true});Me.ValueScope=Me.ValueScopeName=Me.Scope=Me.varKinds=Me.UsedValueState=void 0;var Fe=mr(),ps=class extends Error{constructor(t){super(`CodeGen: "code" for ${t} not defined`),this.value=t.value;}},sn;(function(e){e[e.Started=0]="Started",e[e.Completed=1]="Completed";})(sn||(Me.UsedValueState=sn={}));Me.varKinds={const:new Fe.Name("const"),let:new Fe.Name("let"),var:new Fe.Name("var")};var on=class{constructor({prefixes:t,parent:r}={}){this._names={},this._prefixes=t,this._parent=r;}toName(t){return t instanceof Fe.Name?t:this.name(t)}name(t){return new Fe.Name(this._newName(t))}_newName(t){let r=this._names[t]||this._nameGroup(t);return `${t}${r.index++}`}_nameGroup(t){var r,n;if(!((n=(r=this._parent)===null||r===void 0?void 0:r._prefixes)===null||n===void 0)&&n.has(t)||this._prefixes&&!this._prefixes.has(t))throw new Error(`CodeGen: prefix "${t}" is not allowed in this scope`);return this._names[t]={prefix:t,index:0}}};Me.Scope=on;var an=class extends Fe.Name{constructor(t,r){super(r),this.prefix=t;}setValue(t,{property:r,itemIndex:n}){this.value=t,this.scopePath=(0, Fe._)`.${new Fe.Name(r)}[${n}]`;}};Me.ValueScopeName=an;var il=(0, Fe._)`\n`,ms=class extends on{constructor(t){super(t),this._values={},this._scope=t.scope,this.opts={...t,_n:t.lines?il:Fe.nil};}get(){return this._scope}name(t){return new an(t,this._newName(t))}value(t,r){var n;if(r.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let s=this.toName(t),{prefix:o}=s,a=(n=r.key)!==null&&n!==void 0?n:r.ref,i=this._values[o];if(i){let d=i.get(a);if(d)return d}else i=this._values[o]=new Map;i.set(a,s);let u=this._scope[o]||(this._scope[o]=[]),c=u.length;return u[c]=r.ref,s.setValue(r,{property:o,itemIndex:c}),s}getValue(t,r){let n=this._values[t];if(n)return n.get(r)}scopeRefs(t,r=this._values){return this._reduceValues(r,n=>{if(n.scopePath===void 0)throw new Error(`CodeGen: name "${n}" has no value`);return (0, Fe._)`${t}${n.scopePath}`})}scopeCode(t=this._values,r,n){return this._reduceValues(t,s=>{if(s.value===void 0)throw new Error(`CodeGen: name "${s}" has no value`);return s.value.code},r,n)}_reduceValues(t,r,n={},s){let o=Fe.nil;for(let a in t){let i=t[a];if(!i)continue;let u=n[a]=n[a]||new Map;i.forEach(c=>{if(u.has(c))return;u.set(c,sn.Started);let d=r(c);if(d){let l=this.opts.es5?Me.varKinds.var:Me.varKinds.const;o=(0, Fe._)`${o}${l} ${c} = ${d};${this.opts._n}`;}else if(d=s?.(c))o=(0, Fe._)`${o}${d}${this.opts._n}`;else throw new ps(c);u.set(c,sn.Completed);});}return o}};Me.ValueScope=ms;});var W=O(z=>{Object.defineProperty(z,"__esModule",{value:true});z.or=z.and=z.not=z.CodeGen=z.operators=z.varKinds=z.ValueScopeName=z.ValueScope=z.Scope=z.Name=z.regexpCode=z.stringify=z.getProperty=z.nil=z.strConcat=z.str=z._=void 0;var re=mr(),tt=gs(),St=mr();Object.defineProperty(z,"_",{enumerable:true,get:function(){return St._}});Object.defineProperty(z,"str",{enumerable:true,get:function(){return St.str}});Object.defineProperty(z,"strConcat",{enumerable:true,get:function(){return St.strConcat}});Object.defineProperty(z,"nil",{enumerable:true,get:function(){return St.nil}});Object.defineProperty(z,"getProperty",{enumerable:true,get:function(){return St.getProperty}});Object.defineProperty(z,"stringify",{enumerable:true,get:function(){return St.stringify}});Object.defineProperty(z,"regexpCode",{enumerable:true,get:function(){return St.regexpCode}});Object.defineProperty(z,"Name",{enumerable:true,get:function(){return St.Name}});var ln=gs();Object.defineProperty(z,"Scope",{enumerable:true,get:function(){return ln.Scope}});Object.defineProperty(z,"ValueScope",{enumerable:true,get:function(){return ln.ValueScope}});Object.defineProperty(z,"ValueScopeName",{enumerable:true,get:function(){return ln.ValueScopeName}});Object.defineProperty(z,"varKinds",{enumerable:true,get:function(){return ln.varKinds}});z.operators={GT:new re._Code(">"),GTE:new re._Code(">="),LT:new re._Code("<"),LTE:new re._Code("<="),EQ:new re._Code("==="),NEQ:new re._Code("!=="),NOT:new re._Code("!"),OR:new re._Code("||"),AND:new re._Code("&&"),ADD:new re._Code("+")};var lt=class{optimizeNodes(){return this}optimizeNames(t,r){return this}},hs=class extends lt{constructor(t,r,n){super(),this.varKind=t,this.name=r,this.rhs=n;}render({es5:t,_n:r}){let n=t?tt.varKinds.var:this.varKind,s=this.rhs===void 0?"":` = ${this.rhs}`;return `${n} ${this.name}${s};`+r}optimizeNames(t,r){if(t[this.name.str])return this.rhs&&(this.rhs=Xt(this.rhs,t,r)),this}get names(){return this.rhs instanceof re._CodeOrName?this.rhs.names:{}}},cn=class extends lt{constructor(t,r,n){super(),this.lhs=t,this.rhs=r,this.sideEffects=n;}render({_n:t}){return `${this.lhs} = ${this.rhs};`+t}optimizeNames(t,r){if(!(this.lhs instanceof re.Name&&!t[this.lhs.str]&&!this.sideEffects))return this.rhs=Xt(this.rhs,t,r),this}get names(){let t=this.lhs instanceof re.Name?{}:{...this.lhs.names};return dn(t,this.rhs)}},ys=class extends cn{constructor(t,r,n,s){super(t,n,s),this.op=r;}render({_n:t}){return `${this.lhs} ${this.op}= ${this.rhs};`+t}},vs=class extends lt{constructor(t){super(),this.label=t,this.names={};}render({_n:t}){return `${this.label}:`+t}},Ss=class extends lt{constructor(t){super(),this.label=t,this.names={};}render({_n:t}){return `break${this.label?` ${this.label}`:""};`+t}},ws=class extends lt{constructor(t){super(),this.error=t;}render({_n:t}){return `throw ${this.error};`+t}get names(){return this.error.names}},ks=class extends lt{constructor(t){super(),this.code=t;}render({_n:t}){return `${this.code};`+t}optimizeNodes(){return `${this.code}`?this:void 0}optimizeNames(t,r){return this.code=Xt(this.code,t,r),this}get names(){return this.code instanceof re._CodeOrName?this.code.names:{}}},gr=class extends lt{constructor(t=[]){super(),this.nodes=t;}render(t){return this.nodes.reduce((r,n)=>r+n.render(t),"")}optimizeNodes(){let{nodes:t}=this,r=t.length;for(;r--;){let n=t[r].optimizeNodes();Array.isArray(n)?t.splice(r,1,...n):n?t[r]=n:t.splice(r,1);}return t.length>0?this:void 0}optimizeNames(t,r){let{nodes:n}=this,s=n.length;for(;s--;){let o=n[s];o.optimizeNames(t,r)||(cl(t,o.names),n.splice(s,1));}return n.length>0?this:void 0}get names(){return this.nodes.reduce((t,r)=>Ft(t,r.names),{})}},ft=class extends gr{render(t){return "{"+t._n+super.render(t)+"}"+t._n}},bs=class extends gr{},Yt=class extends ft{};Yt.kind="else";var Nt=class e extends ft{constructor(t,r){super(r),this.condition=t;}render(t){let r=`if(${this.condition})`+super.render(t);return this.else&&(r+="else "+this.else.render(t)),r}optimizeNodes(){super.optimizeNodes();let t=this.condition;if(t===true)return this.nodes;let r=this.else;if(r){let n=r.optimizeNodes();r=this.else=Array.isArray(n)?new Yt(n):n;}if(r)return t===false?r instanceof e?r:r.nodes:this.nodes.length?this:new e(Ua(t),r instanceof e?[r]:r.nodes);if(!(t===false||!this.nodes.length))return this}optimizeNames(t,r){var n;if(this.else=(n=this.else)===null||n===void 0?void 0:n.optimizeNames(t,r),!!(super.optimizeNames(t,r)||this.else))return this.condition=Xt(this.condition,t,r),this}get names(){let t=super.names;return dn(t,this.condition),this.else&&Ft(t,this.else.names),t}};Nt.kind="if";var qt=class extends ft{};qt.kind="for";var Rs=class extends qt{constructor(t){super(),this.iteration=t;}render(t){return `for(${this.iteration})`+super.render(t)}optimizeNames(t,r){if(super.optimizeNames(t,r))return this.iteration=Xt(this.iteration,t,r),this}get names(){return Ft(super.names,this.iteration.names)}},_s=class extends qt{constructor(t,r,n,s){super(),this.varKind=t,this.name=r,this.from=n,this.to=s;}render(t){let r=t.es5?tt.varKinds.var:this.varKind,{name:n,from:s,to:o}=this;return `for(${r} ${n}=${s}; ${n}<${o}; ${n}++)`+super.render(t)}get names(){let t=dn(super.names,this.from);return dn(t,this.to)}},un=class extends qt{constructor(t,r,n,s){super(),this.loop=t,this.varKind=r,this.name=n,this.iterable=s;}render(t){return `for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(t)}optimizeNames(t,r){if(super.optimizeNames(t,r))return this.iterable=Xt(this.iterable,t,r),this}get names(){return Ft(super.names,this.iterable.names)}},hr=class extends ft{constructor(t,r,n){super(),this.name=t,this.args=r,this.async=n;}render(t){return `${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(t)}};hr.kind="func";var yr=class extends gr{render(t){return "return "+super.render(t)}};yr.kind="return";var Cs=class extends ft{render(t){let r="try"+super.render(t);return this.catch&&(r+=this.catch.render(t)),this.finally&&(r+=this.finally.render(t)),r}optimizeNodes(){var t,r;return super.optimizeNodes(),(t=this.catch)===null||t===void 0||t.optimizeNodes(),(r=this.finally)===null||r===void 0||r.optimizeNodes(),this}optimizeNames(t,r){var n,s;return super.optimizeNames(t,r),(n=this.catch)===null||n===void 0||n.optimizeNames(t,r),(s=this.finally)===null||s===void 0||s.optimizeNames(t,r),this}get names(){let t=super.names;return this.catch&&Ft(t,this.catch.names),this.finally&&Ft(t,this.finally.names),t}},vr=class extends ft{constructor(t){super(),this.error=t;}render(t){return `catch(${this.error})`+super.render(t)}};vr.kind="catch";var Sr=class extends ft{render(t){return "finally"+super.render(t)}};Sr.kind="finally";var $s=class{constructor(t,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
2
+ `:""},this._extScope=t,this._scope=new tt.Scope({parent:t}),this._nodes=[new bs];}toString(){return this._root.render(this.opts)}name(t){return this._scope.name(t)}scopeName(t){return this._extScope.name(t)}scopeValue(t,r){let n=this._extScope.value(t,r);return (this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(t,r){return this._extScope.getValue(t,r)}scopeRefs(t){return this._extScope.scopeRefs(t,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(t,r,n,s){let o=this._scope.toName(r);return n!==void 0&&s&&(this._constants[o.str]=n),this._leafNode(new hs(t,o,n)),o}const(t,r,n){return this._def(tt.varKinds.const,t,r,n)}let(t,r,n){return this._def(tt.varKinds.let,t,r,n)}var(t,r,n){return this._def(tt.varKinds.var,t,r,n)}assign(t,r,n){return this._leafNode(new cn(t,r,n))}add(t,r){return this._leafNode(new ys(t,z.operators.ADD,r))}code(t){return typeof t=="function"?t():t!==re.nil&&this._leafNode(new ks(t)),this}object(...t){let r=["{"];for(let[n,s]of t)r.length>1&&r.push(","),r.push(n),(n!==s||this.opts.es5)&&(r.push(":"),(0, re.addCodeArg)(r,s));return r.push("}"),new re._Code(r)}if(t,r,n){if(this._blockNode(new Nt(t)),r&&n)this.code(r).else().code(n).endIf();else if(r)this.code(r).endIf();else if(n)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(t){return this._elseNode(new Nt(t))}else(){return this._elseNode(new Yt)}endIf(){return this._endBlockNode(Nt,Yt)}_for(t,r){return this._blockNode(t),r&&this.code(r).endFor(),this}for(t,r){return this._for(new Rs(t),r)}forRange(t,r,n,s,o=this.opts.es5?tt.varKinds.var:tt.varKinds.let){let a=this._scope.toName(t);return this._for(new _s(o,a,r,n),()=>s(a))}forOf(t,r,n,s=tt.varKinds.const){let o=this._scope.toName(t);if(this.opts.es5){let a=r instanceof re.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0, re._)`${a}.length`,i=>{this.var(o,(0, re._)`${a}[${i}]`),n(o);})}return this._for(new un("of",s,o,r),()=>n(o))}forIn(t,r,n,s=this.opts.es5?tt.varKinds.var:tt.varKinds.const){if(this.opts.ownProperties)return this.forOf(t,(0, re._)`Object.keys(${r})`,n);let o=this._scope.toName(t);return this._for(new un("in",s,o,r),()=>n(o))}endFor(){return this._endBlockNode(qt)}label(t){return this._leafNode(new vs(t))}break(t){return this._leafNode(new Ss(t))}return(t){let r=new yr;if(this._blockNode(r),this.code(t),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(yr)}try(t,r,n){if(!r&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let s=new Cs;if(this._blockNode(s),this.code(t),r){let o=this.name("e");this._currNode=s.catch=new vr(o),r(o);}return n&&(this._currNode=s.finally=new Sr,this.code(n)),this._endBlockNode(vr,Sr)}throw(t){return this._leafNode(new ws(t))}block(t,r){return this._blockStarts.push(this._nodes.length),t&&this.code(t).endBlock(r),this}endBlock(t){let r=this._blockStarts.pop();if(r===void 0)throw new Error("CodeGen: not in self-balancing block");let n=this._nodes.length-r;if(n<0||t!==void 0&&n!==t)throw new Error(`CodeGen: wrong number of nodes: ${n} vs ${t} expected`);return this._nodes.length=r,this}func(t,r=re.nil,n,s){return this._blockNode(new hr(t,r,n)),s&&this.code(s).endFunc(),this}endFunc(){return this._endBlockNode(hr)}optimize(t=1){for(;t-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants);}_leafNode(t){return this._currNode.nodes.push(t),this}_blockNode(t){this._currNode.nodes.push(t),this._nodes.push(t);}_endBlockNode(t,r){let n=this._currNode;if(n instanceof t||r&&n instanceof r)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${r?`${t.kind}/${r.kind}`:t.kind}"`)}_elseNode(t){let r=this._currNode;if(!(r instanceof Nt))throw new Error('CodeGen: "else" without "if"');return this._currNode=r.else=t,this}get _root(){return this._nodes[0]}get _currNode(){let t=this._nodes;return t[t.length-1]}set _currNode(t){let r=this._nodes;r[r.length-1]=t;}};z.CodeGen=$s;function Ft(e,t){for(let r in t)e[r]=(e[r]||0)+(t[r]||0);return e}function dn(e,t){return t instanceof re._CodeOrName?Ft(e,t.names):e}function Xt(e,t,r){if(e instanceof re.Name)return n(e);if(!s(e))return e;return new re._Code(e._items.reduce((o,a)=>(a instanceof re.Name&&(a=n(a)),a instanceof re._Code?o.push(...a._items):o.push(a),o),[]));function n(o){let a=r[o.str];return a===void 0||t[o.str]!==1?o:(delete t[o.str],a)}function s(o){return o instanceof re._Code&&o._items.some(a=>a instanceof re.Name&&t[a.str]===1&&r[a.str]!==void 0)}}function cl(e,t){for(let r in t)e[r]=(e[r]||0)-(t[r]||0);}function Ua(e){return typeof e=="boolean"||typeof e=="number"||e===null?!e:(0, re._)`!${Es(e)}`}z.not=Ua;var ul=Ka(z.operators.AND);function dl(...e){return e.reduce(ul)}z.and=dl;var ll=Ka(z.operators.OR);function fl(...e){return e.reduce(ll)}z.or=fl;function Ka(e){return (t,r)=>t===re.nil?r:r===re.nil?t:(0, re._)`${Es(t)} ${e} ${Es(r)}`}function Es(e){return e instanceof re.Name?e:(0, re._)`(${e})`}});var ae=O(Y=>{Object.defineProperty(Y,"__esModule",{value:true});Y.checkStrictMode=Y.getErrorPath=Y.Type=Y.useFunc=Y.setEvaluated=Y.evaluatedPropsToName=Y.mergeEvaluated=Y.eachItem=Y.unescapeJsonPointer=Y.escapeJsonPointer=Y.escapeFragment=Y.unescapeFragment=Y.schemaRefOrVal=Y.schemaHasRulesButRef=Y.schemaHasRules=Y.checkUnknownRules=Y.alwaysValidSchema=Y.toHash=void 0;var fe=W(),pl=mr();function ml(e){let t={};for(let r of e)t[r]=true;return t}Y.toHash=ml;function gl(e,t){return typeof t=="boolean"?t:Object.keys(t).length===0?true:(za(e,t),!Ha(t,e.self.RULES.all))}Y.alwaysValidSchema=gl;function za(e,t=e.schema){let{opts:r,self:n}=e;if(!r.strictSchema||typeof t=="boolean")return;let s=n.RULES.keywords;for(let o in t)s[o]||Xa(e,`unknown keyword: "${o}"`);}Y.checkUnknownRules=za;function Ha(e,t){if(typeof e=="boolean")return !e;for(let r in e)if(t[r])return true;return false}Y.schemaHasRules=Ha;function hl(e,t){if(typeof e=="boolean")return !e;for(let r in e)if(r!=="$ref"&&t.all[r])return true;return false}Y.schemaHasRulesButRef=hl;function yl({topSchemaRef:e,schemaPath:t},r,n,s){if(!s){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return (0, fe._)`${r}`}return (0, fe._)`${e}${t}${(0, fe.getProperty)(n)}`}Y.schemaRefOrVal=yl;function vl(e){return Wa(decodeURIComponent(e))}Y.unescapeFragment=vl;function Sl(e){return encodeURIComponent(As(e))}Y.escapeFragment=Sl;function As(e){return typeof e=="number"?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}Y.escapeJsonPointer=As;function Wa(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}Y.unescapeJsonPointer=Wa;function wl(e,t){if(Array.isArray(e))for(let r of e)t(r);else t(e);}Y.eachItem=wl;function Ga({mergeNames:e,mergeToName:t,mergeValues:r,resultToName:n}){return (s,o,a,i)=>{let u=a===void 0?o:a instanceof fe.Name?(o instanceof fe.Name?e(s,o,a):t(s,o,a),a):o instanceof fe.Name?(t(s,a,o),o):r(o,a);return i===fe.Name&&!(u instanceof fe.Name)?n(s,u):u}}Y.mergeEvaluated={props:Ga({mergeNames:(e,t,r)=>e.if((0, fe._)`${r} !== true && ${t} !== undefined`,()=>{e.if((0, fe._)`${t} === true`,()=>e.assign(r,true),()=>e.assign(r,(0, fe._)`${r} || {}`).code((0, fe._)`Object.assign(${r}, ${t})`));}),mergeToName:(e,t,r)=>e.if((0, fe._)`${r} !== true`,()=>{t===true?e.assign(r,true):(e.assign(r,(0, fe._)`${r} || {}`),Ts(e,r,t));}),mergeValues:(e,t)=>e===true?true:{...e,...t},resultToName:Ya}),items:Ga({mergeNames:(e,t,r)=>e.if((0, fe._)`${r} !== true && ${t} !== undefined`,()=>e.assign(r,(0, fe._)`${t} === true ? true : ${r} > ${t} ? ${r} : ${t}`)),mergeToName:(e,t,r)=>e.if((0, fe._)`${r} !== true`,()=>e.assign(r,t===true?true:(0, fe._)`${r} > ${t} ? ${r} : ${t}`)),mergeValues:(e,t)=>e===true?true:Math.max(e,t),resultToName:(e,t)=>e.var("items",t)})};function Ya(e,t){if(t===true)return e.var("props",true);let r=e.var("props",(0, fe._)`{}`);return t!==void 0&&Ts(e,r,t),r}Y.evaluatedPropsToName=Ya;function Ts(e,t,r){Object.keys(r).forEach(n=>e.assign((0, fe._)`${t}${(0, fe.getProperty)(n)}`,true));}Y.setEvaluated=Ts;var Ja={};function kl(e,t){return e.scopeValue("func",{ref:t,code:Ja[t.code]||(Ja[t.code]=new pl._Code(t.code))})}Y.useFunc=kl;var xs;(function(e){e[e.Num=0]="Num",e[e.Str=1]="Str";})(xs||(Y.Type=xs={}));function bl(e,t,r){if(e instanceof fe.Name){let n=t===xs.Num;return r?n?(0, fe._)`"[" + ${e} + "]"`:(0, fe._)`"['" + ${e} + "']"`:n?(0, fe._)`"/" + ${e}`:(0, fe._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0, fe.getProperty)(e).toString():"/"+As(e)}Y.getErrorPath=bl;function Xa(e,t,r=e.opts.strictSchema){if(r){if(t=`strict mode: ${t}`,r===true)throw new Error(t);e.self.logger.warn(t);}}Y.checkStrictMode=Xa;});var pt=O(Is=>{Object.defineProperty(Is,"__esModule",{value:true});var Ee=W(),Rl={data:new Ee.Name("data"),valCxt:new Ee.Name("valCxt"),instancePath:new Ee.Name("instancePath"),parentData:new Ee.Name("parentData"),parentDataProperty:new Ee.Name("parentDataProperty"),rootData:new Ee.Name("rootData"),dynamicAnchors:new Ee.Name("dynamicAnchors"),vErrors:new Ee.Name("vErrors"),errors:new Ee.Name("errors"),this:new Ee.Name("this"),self:new Ee.Name("self"),scope:new Ee.Name("scope"),json:new Ee.Name("json"),jsonPos:new Ee.Name("jsonPos"),jsonLen:new Ee.Name("jsonLen"),jsonPart:new Ee.Name("jsonPart")};Is.default=Rl;});var wr=O(xe=>{Object.defineProperty(xe,"__esModule",{value:true});xe.extendErrors=xe.resetErrorsCount=xe.reportExtraError=xe.reportError=xe.keyword$DataError=xe.keywordError=void 0;var ie=W(),fn=ae(),je=pt();xe.keywordError={message:({keyword:e})=>(0, ie.str)`must pass "${e}" keyword validation`};xe.keyword$DataError={message:({keyword:e,schemaType:t})=>t?(0, ie.str)`"${e}" keyword must be ${t} ($data)`:(0, ie.str)`"${e}" keyword is invalid ($data)`};function _l(e,t=xe.keywordError,r,n){let{it:s}=e,{gen:o,compositeRule:a,allErrors:i}=s,u=ei(e,t,r);n??(a||i)?Qa(o,u):Za(s,(0, ie._)`[${u}]`);}xe.reportError=_l;function Cl(e,t=xe.keywordError,r){let{it:n}=e,{gen:s,compositeRule:o,allErrors:a}=n,i=ei(e,t,r);Qa(s,i),o||a||Za(n,je.default.vErrors);}xe.reportExtraError=Cl;function $l(e,t){e.assign(je.default.errors,t),e.if((0, ie._)`${je.default.vErrors} !== null`,()=>e.if(t,()=>e.assign((0, ie._)`${je.default.vErrors}.length`,t),()=>e.assign(je.default.vErrors,null)));}xe.resetErrorsCount=$l;function El({gen:e,keyword:t,schemaValue:r,data:n,errsCount:s,it:o}){if(s===void 0)throw new Error("ajv implementation error");let a=e.name("err");e.forRange("i",s,je.default.errors,i=>{e.const(a,(0, ie._)`${je.default.vErrors}[${i}]`),e.if((0, ie._)`${a}.instancePath === undefined`,()=>e.assign((0, ie._)`${a}.instancePath`,(0, ie.strConcat)(je.default.instancePath,o.errorPath))),e.assign((0, ie._)`${a}.schemaPath`,(0, ie.str)`${o.errSchemaPath}/${t}`),o.opts.verbose&&(e.assign((0, ie._)`${a}.schema`,r),e.assign((0, ie._)`${a}.data`,n));});}xe.extendErrors=El;function Qa(e,t){let r=e.const("err",t);e.if((0, ie._)`${je.default.vErrors} === null`,()=>e.assign(je.default.vErrors,(0, ie._)`[${r}]`),(0, ie._)`${je.default.vErrors}.push(${r})`),e.code((0, ie._)`${je.default.errors}++`);}function Za(e,t){let{gen:r,validateName:n,schemaEnv:s}=e;s.$async?r.throw((0, ie._)`new ${e.ValidationError}(${t})`):(r.assign((0, ie._)`${n}.errors`,t),r.return(false));}var Mt={keyword:new ie.Name("keyword"),schemaPath:new ie.Name("schemaPath"),params:new ie.Name("params"),propertyName:new ie.Name("propertyName"),message:new ie.Name("message"),schema:new ie.Name("schema"),parentSchema:new ie.Name("parentSchema")};function ei(e,t,r){let{createErrors:n}=e.it;return n===false?(0, ie._)`{}`:xl(e,t,r)}function xl(e,t,r={}){let{gen:n,it:s}=e,o=[Al(s,r),Tl(e,r)];return Il(e,t,o),n.object(...o)}function Al({errorPath:e},{instancePath:t}){let r=t?(0, ie.str)`${e}${(0, fn.getErrorPath)(t,fn.Type.Str)}`:e;return [je.default.instancePath,(0, ie.strConcat)(je.default.instancePath,r)]}function Tl({keyword:e,it:{errSchemaPath:t}},{schemaPath:r,parentSchema:n}){let s=n?t:(0, ie.str)`${t}/${e}`;return r&&(s=(0, ie.str)`${s}${(0, fn.getErrorPath)(r,fn.Type.Str)}`),[Mt.schemaPath,s]}function Il(e,{params:t,message:r},n){let{keyword:s,data:o,schemaValue:a,it:i}=e,{opts:u,propertyName:c,topSchemaRef:d,schemaPath:l}=i;n.push([Mt.keyword,s],[Mt.params,typeof t=="function"?t(e):t||(0, ie._)`{}`]),u.messages&&n.push([Mt.message,typeof r=="function"?r(e):r]),u.verbose&&n.push([Mt.schema,a],[Mt.parentSchema,(0, ie._)`${d}${l}`],[je.default.data,o]),c&&n.push([Mt.propertyName,c]);}});var ri=O(Qt=>{Object.defineProperty(Qt,"__esModule",{value:true});Qt.boolOrEmptySchema=Qt.topBoolOrEmptySchema=void 0;var jl=wr(),Ol=W(),Pl=pt(),Nl={message:"boolean schema is false"};function ql(e){let{gen:t,schema:r,validateName:n}=e;r===false?ti(e,false):typeof r=="object"&&r.$async===true?t.return(Pl.default.data):(t.assign((0, Ol._)`${n}.errors`,null),t.return(true));}Qt.topBoolOrEmptySchema=ql;function Fl(e,t){let{gen:r,schema:n}=e;n===false?(r.var(t,false),ti(e)):r.var(t,true);}Qt.boolOrEmptySchema=Fl;function ti(e,t){let{gen:r,data:n}=e,s={gen:r,keyword:"false schema",data:n,schema:false,schemaCode:false,schemaValue:false,params:{},it:e};(0, jl.reportError)(s,Nl,void 0,t);}});var js=O(Zt=>{Object.defineProperty(Zt,"__esModule",{value:true});Zt.getRules=Zt.isJSONType=void 0;var Ml=["string","number","integer","boolean","null","object","array"],Dl=new Set(Ml);function Ll(e){return typeof e=="string"&&Dl.has(e)}Zt.isJSONType=Ll;function Bl(){let e={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return {types:{...e,integer:true,boolean:true,null:true},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}Zt.getRules=Bl;});var Os=O(wt=>{Object.defineProperty(wt,"__esModule",{value:true});wt.shouldUseRule=wt.shouldUseGroup=wt.schemaHasRulesForType=void 0;function Vl({schema:e,self:t},r){let n=t.RULES.types[r];return n&&n!==true&&ni(e,n)}wt.schemaHasRulesForType=Vl;function ni(e,t){return t.rules.some(r=>si(e,r))}wt.shouldUseGroup=ni;function si(e,t){var r;return e[t.keyword]!==void 0||((r=t.definition.implements)===null||r===void 0?void 0:r.some(n=>e[n]!==void 0))}wt.shouldUseRule=si;});var kr=O(Ae=>{Object.defineProperty(Ae,"__esModule",{value:true});Ae.reportTypeError=Ae.checkDataTypes=Ae.checkDataType=Ae.coerceAndCheckDataType=Ae.getJSONTypes=Ae.getSchemaTypes=Ae.DataType=void 0;var Ul=js(),Kl=Os(),Gl=wr(),J=W(),oi=ae(),er;(function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong";})(er||(Ae.DataType=er={}));function Jl(e){let t=ai(e.type);if(t.includes("null")){if(e.nullable===false)throw new Error("type: null contradicts nullable: false")}else {if(!t.length&&e.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');e.nullable===true&&t.push("null");}return t}Ae.getSchemaTypes=Jl;function ai(e){let t=Array.isArray(e)?e:e?[e]:[];if(t.every(Ul.isJSONType))return t;throw new Error("type must be JSONType or JSONType[]: "+t.join(","))}Ae.getJSONTypes=ai;function zl(e,t){let{gen:r,data:n,opts:s}=e,o=Hl(t,s.coerceTypes),a=t.length>0&&!(o.length===0&&t.length===1&&(0, Kl.schemaHasRulesForType)(e,t[0]));if(a){let i=Ns(t,n,s.strictNumbers,er.Wrong);r.if(i,()=>{o.length?Wl(e,t,o):qs(e);});}return a}Ae.coerceAndCheckDataType=zl;var ii=new Set(["string","number","integer","boolean","null"]);function Hl(e,t){return t?e.filter(r=>ii.has(r)||t==="array"&&r==="array"):[]}function Wl(e,t,r){let{gen:n,data:s,opts:o}=e,a=n.let("dataType",(0, J._)`typeof ${s}`),i=n.let("coerced",(0, J._)`undefined`);o.coerceTypes==="array"&&n.if((0, J._)`${a} == 'object' && Array.isArray(${s}) && ${s}.length == 1`,()=>n.assign(s,(0, J._)`${s}[0]`).assign(a,(0, J._)`typeof ${s}`).if(Ns(t,s,o.strictNumbers),()=>n.assign(i,s))),n.if((0, J._)`${i} !== undefined`);for(let c of r)(ii.has(c)||c==="array"&&o.coerceTypes==="array")&&u(c);n.else(),qs(e),n.endIf(),n.if((0, J._)`${i} !== undefined`,()=>{n.assign(s,i),Yl(e,i);});function u(c){switch(c){case "string":n.elseIf((0, J._)`${a} == "number" || ${a} == "boolean"`).assign(i,(0, J._)`"" + ${s}`).elseIf((0, J._)`${s} === null`).assign(i,(0, J._)`""`);return;case "number":n.elseIf((0, J._)`${a} == "boolean" || ${s} === null
3
3
  || (${a} == "string" && ${s} && ${s} == +${s})`).assign(i,(0, J._)`+${s}`);return;case "integer":n.elseIf((0, J._)`${a} === "boolean" || ${s} === null
4
4
  || (${a} === "string" && ${s} && ${s} == +${s} && !(${s} % 1))`).assign(i,(0, J._)`+${s}`);return;case "boolean":n.elseIf((0, J._)`${s} === "false" || ${s} === 0 || ${s} === null`).assign(i,false).elseIf((0, J._)`${s} === "true" || ${s} === 1`).assign(i,true);return;case "null":n.elseIf((0, J._)`${s} === "" || ${s} === 0 || ${s} === false`),n.assign(i,null);return;case "array":n.elseIf((0, J._)`${a} === "string" || ${a} === "number"
5
- || ${a} === "boolean" || ${s} === null`).assign(i,(0, J._)`[${s}]`);}}}function Yl({gen:e,parentData:t,parentDataProperty:r},n){e.if((0, J._)`${t} !== undefined`,()=>e.assign((0, J._)`${t}[${r}]`,n));}function Ps(e,t,r,n=er.Correct){let s=n===er.Correct?J.operators.EQ:J.operators.NEQ,o;switch(e){case "null":return (0, J._)`${t} ${s} null`;case "array":o=(0, J._)`Array.isArray(${t})`;break;case "object":o=(0, J._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case "integer":o=a((0, J._)`!(${t} % 1) && !isNaN(${t})`);break;case "number":o=a();break;default:return (0, J._)`typeof ${t} ${s} ${e}`}return n===er.Correct?o:(0, J.not)(o);function a(i=J.nil){return (0, J.and)((0, J._)`typeof ${t} == "number"`,i,r?(0, J._)`isFinite(${t})`:J.nil)}}Ee.checkDataType=Ps;function Ns(e,t,r,n){if(e.length===1)return Ps(e[0],t,r,n);let s,o=(0, oi.toHash)(e);if(o.array&&o.object){let a=(0, J._)`typeof ${t} != "object"`;s=o.null?a:(0, J._)`!${t} || ${a}`,delete o.null,delete o.array,delete o.object;}else s=J.nil;o.number&&delete o.integer;for(let a in o)s=(0, J.and)(s,Ps(a,t,r,n));return s}Ee.checkDataTypes=Ns;var Xl={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e=="string"?(0, J._)`{type: ${e}}`:(0, J._)`{type: ${t}}`};function qs(e){let t=Ql(e);(0, Gl.reportError)(t,Xl);}Ee.reportTypeError=qs;function Ql(e){let{gen:t,data:r,schema:n}=e,s=(0, oi.schemaRefOrVal)(e,n,"type");return {gen:t,keyword:"type",data:r,schema:n.type,schemaCode:s,schemaValue:s,parentSchema:n,params:{},it:e}}});var ui=O(pn=>{Object.defineProperty(pn,"__esModule",{value:true});pn.assignDefaults=void 0;var tr=W(),Zl=oe();function ef(e,t){let{properties:r,items:n}=e.schema;if(t==="object"&&r)for(let s in r)ci(e,s,r[s].default);else t==="array"&&Array.isArray(n)&&n.forEach((s,o)=>ci(e,o,s.default));}pn.assignDefaults=ef;function ci(e,t,r){let{gen:n,compositeRule:s,data:o,opts:a}=e;if(r===void 0)return;let i=(0, tr._)`${o}${(0, tr.getProperty)(t)}`;if(s){(0, Zl.checkStrictMode)(e,`default is ignored for: ${i}`);return}let u=(0, tr._)`${i} === undefined`;a.useDefaults==="empty"&&(u=(0, tr._)`${u} || ${i} === null || ${i} === ""`),n.if(u,(0, tr._)`${i} = ${(0, tr.stringify)(r)}`);}});var Ge=O(le=>{Object.defineProperty(le,"__esModule",{value:true});le.validateUnion=le.validateArray=le.usePattern=le.callValidateCode=le.schemaProperties=le.allSchemaProperties=le.noPropertyInData=le.propertyInData=le.isOwnProperty=le.hasPropFunc=le.reportMissingProp=le.checkMissingProp=le.checkReportMissingProp=void 0;var ge=W(),Fs=oe(),wt=ft(),tf=oe();function rf(e,t){let{gen:r,data:n,it:s}=e;r.if(Ds(r,n,t,s.opts.ownProperties),()=>{e.setParams({missingProperty:(0, ge._)`${t}`},true),e.error();});}le.checkReportMissingProp=rf;function nf({gen:e,data:t,it:{opts:r}},n,s){return (0, ge.or)(...n.map(o=>(0, ge.and)(Ds(e,t,o,r.ownProperties),(0, ge._)`${s} = ${o}`)))}le.checkMissingProp=nf;function sf(e,t){e.setParams({missingProperty:t},true),e.error();}le.reportMissingProp=sf;function di(e){return e.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0, ge._)`Object.prototype.hasOwnProperty`})}le.hasPropFunc=di;function Ms(e,t,r){return (0, ge._)`${di(e)}.call(${t}, ${r})`}le.isOwnProperty=Ms;function of(e,t,r,n){let s=(0, ge._)`${t}${(0, ge.getProperty)(r)} !== undefined`;return n?(0, ge._)`${s} && ${Ms(e,t,r)}`:s}le.propertyInData=of;function Ds(e,t,r,n){let s=(0, ge._)`${t}${(0, ge.getProperty)(r)} === undefined`;return n?(0, ge.or)(s,(0, ge.not)(Ms(e,t,r))):s}le.noPropertyInData=Ds;function li(e){return e?Object.keys(e).filter(t=>t!=="__proto__"):[]}le.allSchemaProperties=li;function af(e,t){return li(t).filter(r=>!(0, Fs.alwaysValidSchema)(e,t[r]))}le.schemaProperties=af;function cf({schemaCode:e,data:t,it:{gen:r,topSchemaRef:n,schemaPath:s,errorPath:o},it:a},i,u,c){let d=c?(0, ge._)`${e}, ${t}, ${n}${s}`:t,l=[[wt.default.instancePath,(0, ge.strConcat)(wt.default.instancePath,o)],[wt.default.parentData,a.parentData],[wt.default.parentDataProperty,a.parentDataProperty],[wt.default.rootData,wt.default.rootData]];a.opts.dynamicRef&&l.push([wt.default.dynamicAnchors,wt.default.dynamicAnchors]);let g=(0, ge._)`${d}, ${r.object(...l)}`;return u!==ge.nil?(0, ge._)`${i}.call(${u}, ${g})`:(0, ge._)`${i}(${g})`}le.callValidateCode=cf;var uf=(0, ge._)`new RegExp`;function df({gen:e,it:{opts:t}},r){let n=t.unicodeRegExp?"u":"",{regExp:s}=t.code,o=s(r,n);return e.scopeValue("pattern",{key:o.toString(),ref:o,code:(0, ge._)`${s.code==="new RegExp"?uf:(0, tf.useFunc)(e,s)}(${r}, ${n})`})}le.usePattern=df;function lf(e){let{gen:t,data:r,keyword:n,it:s}=e,o=t.name("valid");if(s.allErrors){let i=t.let("valid",true);return a(()=>t.assign(i,false)),i}return t.var(o,true),a(()=>t.break()),o;function a(i){let u=t.const("len",(0, ge._)`${r}.length`);t.forRange("i",0,u,c=>{e.subschema({keyword:n,dataProp:c,dataPropType:Fs.Type.Num},o),t.if((0, ge.not)(o),i);});}}le.validateArray=lf;function ff(e){let{gen:t,schema:r,keyword:n,it:s}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(r.some(u=>(0, Fs.alwaysValidSchema)(s,u))&&!s.opts.unevaluated)return;let a=t.let("valid",false),i=t.name("_valid");t.block(()=>r.forEach((u,c)=>{let d=e.subschema({keyword:n,schemaProp:c,compositeRule:true},i);t.assign(a,(0, ge._)`${a} || ${i}`),e.mergeValidEvaluated(d,i)||t.if((0, ge.not)(a));})),e.result(a,()=>e.reset(),()=>e.error(true));}le.validateUnion=ff;});var mi=O(st=>{Object.defineProperty(st,"__esModule",{value:true});st.validateKeywordUsage=st.validSchemaType=st.funcKeywordCode=st.macroKeywordCode=void 0;var Ie=W(),Dt=ft(),pf=Ge(),mf=wr();function gf(e,t){let{gen:r,keyword:n,schema:s,parentSchema:o,it:a}=e,i=t.macro.call(a.self,s,o,a),u=pi(r,n,i);a.opts.validateSchema!==false&&a.self.validateSchema(i,true);let c=r.name("valid");e.subschema({schema:i,schemaPath:Ie.nil,errSchemaPath:`${a.errSchemaPath}/${n}`,topSchemaRef:u,compositeRule:true},c),e.pass(c,()=>e.error(true));}st.macroKeywordCode=gf;function hf(e,t){var r;let{gen:n,keyword:s,schema:o,parentSchema:a,$data:i,it:u}=e;vf(u,t);let c=!i&&t.compile?t.compile.call(u.self,o,a,u):t.validate,d=pi(n,s,c),l=n.let("valid");e.block$data(l,g),e.ok((r=t.valid)!==null&&r!==void 0?r:l);function g(){if(t.errors===false)m(),t.modifying&&fi(e),b(()=>e.error());else {let C=t.async?v():f();t.modifying&&fi(e),b(()=>yf(e,C));}}function v(){let C=n.let("ruleErrs",null);return n.try(()=>m((0, Ie._)`await `),F=>n.assign(l,false).if((0, Ie._)`${F} instanceof ${u.ValidationError}`,()=>n.assign(C,(0, Ie._)`${F}.errors`),()=>n.throw(F))),C}function f(){let C=(0, Ie._)`${d}.errors`;return n.assign(C,null),m(Ie.nil),C}function m(C=t.async?(0, Ie._)`await `:Ie.nil){let F=u.opts.passContext?Dt.default.this:Dt.default.self,_=!("compile"in t&&!i||t.schema===false);n.assign(l,(0, Ie._)`${C}${(0, pf.callValidateCode)(e,d,F,_)}`,t.modifying);}function b(C){var F;n.if((0, Ie.not)((F=t.valid)!==null&&F!==void 0?F:l),C);}}st.funcKeywordCode=hf;function fi(e){let{gen:t,data:r,it:n}=e;t.if(n.parentData,()=>t.assign(r,(0, Ie._)`${n.parentData}[${n.parentDataProperty}]`));}function yf(e,t){let{gen:r}=e;r.if((0, Ie._)`Array.isArray(${t})`,()=>{r.assign(Dt.default.vErrors,(0, Ie._)`${Dt.default.vErrors} === null ? ${t} : ${Dt.default.vErrors}.concat(${t})`).assign(Dt.default.errors,(0, Ie._)`${Dt.default.vErrors}.length`),(0, mf.extendErrors)(e);},()=>e.error());}function vf({schemaEnv:e},t){if(t.async&&!e.$async)throw new Error("async keyword in sync schema")}function pi(e,t,r){if(r===void 0)throw new Error(`keyword "${t}" failed to compile`);return e.scopeValue("keyword",typeof r=="function"?{ref:r}:{ref:r,code:(0, Ie.stringify)(r)})}function Sf(e,t,r=false){return !t.length||t.some(n=>n==="array"?Array.isArray(e):n==="object"?e&&typeof e=="object"&&!Array.isArray(e):typeof e==n||r&&typeof e>"u")}st.validSchemaType=Sf;function wf({schema:e,opts:t,self:r,errSchemaPath:n},s,o){if(Array.isArray(s.keyword)?!s.keyword.includes(o):s.keyword!==o)throw new Error("ajv implementation error");let a=s.dependencies;if(a?.some(i=>!Object.prototype.hasOwnProperty.call(e,i)))throw new Error(`parent schema must have dependencies of ${o}: ${a.join(",")}`);if(s.validateSchema&&!s.validateSchema(e[o])){let u=`keyword "${o}" value is invalid at path "${n}": `+r.errorsText(s.validateSchema.errors);if(t.validateSchema==="log")r.logger.error(u);else throw new Error(u)}}st.validateKeywordUsage=wf;});var hi=O(kt=>{Object.defineProperty(kt,"__esModule",{value:true});kt.extendSubschemaMode=kt.extendSubschemaData=kt.getSubschema=void 0;var ot=W(),gi=oe();function kf(e,{keyword:t,schemaProp:r,schema:n,schemaPath:s,errSchemaPath:o,topSchemaRef:a}){if(t!==void 0&&n!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(t!==void 0){let i=e.schema[t];return r===void 0?{schema:i,schemaPath:(0, ot._)`${e.schemaPath}${(0, ot.getProperty)(t)}`,errSchemaPath:`${e.errSchemaPath}/${t}`}:{schema:i[r],schemaPath:(0, ot._)`${e.schemaPath}${(0, ot.getProperty)(t)}${(0, ot.getProperty)(r)}`,errSchemaPath:`${e.errSchemaPath}/${t}/${(0, gi.escapeFragment)(r)}`}}if(n!==void 0){if(s===void 0||o===void 0||a===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return {schema:n,schemaPath:s,topSchemaRef:a,errSchemaPath:o}}throw new Error('either "keyword" or "schema" must be passed')}kt.getSubschema=kf;function bf(e,t,{dataProp:r,dataPropType:n,data:s,dataTypes:o,propertyName:a}){if(s!==void 0&&r!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');let{gen:i}=t;if(r!==void 0){let{errorPath:c,dataPathArr:d,opts:l}=t,g=i.let("data",(0, ot._)`${t.data}${(0, ot.getProperty)(r)}`,true);u(g),e.errorPath=(0, ot.str)`${c}${(0, gi.getErrorPath)(r,n,l.jsPropertySyntax)}`,e.parentDataProperty=(0, ot._)`${r}`,e.dataPathArr=[...d,e.parentDataProperty];}if(s!==void 0){let c=s instanceof ot.Name?s:i.let("data",s,true);u(c),a!==void 0&&(e.propertyName=a);}o&&(e.dataTypes=o);function u(c){e.data=c,e.dataLevel=t.dataLevel+1,e.dataTypes=[],t.definedProperties=new Set,e.parentData=t.data,e.dataNames=[...t.dataNames,c];}}kt.extendSubschemaData=bf;function Rf(e,{jtdDiscriminator:t,jtdMetadata:r,compositeRule:n,createErrors:s,allErrors:o}){n!==void 0&&(e.compositeRule=n),s!==void 0&&(e.createErrors=s),o!==void 0&&(e.allErrors=o),e.jtdDiscriminator=t,e.jtdMetadata=r;}kt.extendSubschemaMode=Rf;});var Ls=O((_v,yi)=>{yi.exports=function e(t,r){if(t===r)return true;if(t&&r&&typeof t=="object"&&typeof r=="object"){if(t.constructor!==r.constructor)return false;var n,s,o;if(Array.isArray(t)){if(n=t.length,n!=r.length)return false;for(s=n;s--!==0;)if(!e(t[s],r[s]))return false;return true}if(t.constructor===RegExp)return t.source===r.source&&t.flags===r.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===r.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===r.toString();if(o=Object.keys(t),n=o.length,n!==Object.keys(r).length)return false;for(s=n;s--!==0;)if(!Object.prototype.hasOwnProperty.call(r,o[s]))return false;for(s=n;s--!==0;){var a=o[s];if(!e(t[a],r[a]))return false}return true}return t!==t&&r!==r};});var Si=O((Cv,vi)=>{var bt=vi.exports=function(e,t,r){typeof t=="function"&&(r=t,t={}),r=t.cb||r;var n=typeof r=="function"?r:r.pre||function(){},s=r.post||function(){};mn(t,n,s,e,"",e);};bt.keywords={additionalItems:true,items:true,contains:true,additionalProperties:true,propertyNames:true,not:true,if:true,then:true,else:true};bt.arrayKeywords={items:true,allOf:true,anyOf:true,oneOf:true};bt.propsKeywords={$defs:true,definitions:true,properties:true,patternProperties:true,dependencies:true};bt.skipKeywords={default:true,enum:true,const:true,required:true,maximum:true,minimum:true,exclusiveMaximum:true,exclusiveMinimum:true,multipleOf:true,maxLength:true,minLength:true,pattern:true,format:true,maxItems:true,minItems:true,uniqueItems:true,maxProperties:true,minProperties:true};function mn(e,t,r,n,s,o,a,i,u,c){if(n&&typeof n=="object"&&!Array.isArray(n)){t(n,s,o,a,i,u,c);for(var d in n){var l=n[d];if(Array.isArray(l)){if(d in bt.arrayKeywords)for(var g=0;g<l.length;g++)mn(e,t,r,l[g],s+"/"+d+"/"+g,o,s,d,n,g);}else if(d in bt.propsKeywords){if(l&&typeof l=="object")for(var v in l)mn(e,t,r,l[v],s+"/"+d+"/"+_f(v),o,s,d,n,v);}else (d in bt.keywords||e.allKeys&&!(d in bt.skipKeywords))&&mn(e,t,r,l,s+"/"+d,o,s,d,n);}r(n,s,o,a,i,u,c);}}function _f(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}});var br=O(Me=>{Object.defineProperty(Me,"__esModule",{value:true});Me.getSchemaRefs=Me.resolveUrl=Me.normalizeId=Me._getFullPath=Me.getFullPath=Me.inlineRef=void 0;var Cf=oe(),$f=Ls(),Ef=Si(),xf=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function Af(e,t=true){return typeof e=="boolean"?true:t===true?!Bs(e):t?wi(e)<=t:false}Me.inlineRef=Af;var Tf=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function Bs(e){for(let t in e){if(Tf.has(t))return true;let r=e[t];if(Array.isArray(r)&&r.some(Bs)||typeof r=="object"&&Bs(r))return true}return false}function wi(e){let t=0;for(let r in e){if(r==="$ref")return 1/0;if(t++,!xf.has(r)&&(typeof e[r]=="object"&&(0, Cf.eachItem)(e[r],n=>t+=wi(n)),t===1/0))return 1/0}return t}function ki(e,t="",r){r!==false&&(t=rr(t));let n=e.parse(t);return bi(e,n)}Me.getFullPath=ki;function bi(e,t){return e.serialize(t).split("#")[0]+"#"}Me._getFullPath=bi;var If=/#\/?$/;function rr(e){return e?e.replace(If,""):""}Me.normalizeId=rr;function jf(e,t,r){return r=rr(r),e.resolve(t,r)}Me.resolveUrl=jf;var Of=/^[a-z_][-a-z0-9._]*$/i;function Pf(e,t){if(typeof e=="boolean")return {};let{schemaId:r,uriResolver:n}=this.opts,s=rr(e[r]||t),o={"":s},a=ki(n,s,false),i={},u=new Set;return Ef(e,{allKeys:true},(l,g,v,f)=>{if(f===void 0)return;let m=a+g,b=o[f];typeof l[r]=="string"&&(b=C.call(this,l[r])),F.call(this,l.$anchor),F.call(this,l.$dynamicAnchor),o[g]=b;function C(_){let I=this.opts.uriResolver.resolve;if(_=rr(b?I(b,_):_),u.has(_))throw d(_);u.add(_);let S=this.refs[_];return typeof S=="string"&&(S=this.refs[S]),typeof S=="object"?c(l,S.schema,_):_!==rr(m)&&(_[0]==="#"?(c(l,i[_],_),i[_]=l):this.refs[_]=m),_}function F(_){if(typeof _=="string"){if(!Of.test(_))throw new Error(`invalid anchor "${_}"`);C.call(this,`#${_}`);}}}),i;function c(l,g,v){if(g!==void 0&&!$f(l,g))throw d(v)}function d(l){return new Error(`reference "${l}" resolves to more than one schema`)}}Me.getSchemaRefs=Pf;});var Cr=O(Rt=>{Object.defineProperty(Rt,"__esModule",{value:true});Rt.getData=Rt.KeywordCxt=Rt.validateFunctionCode=void 0;var Ei=ri(),Ri=kr(),Us=Os(),gn=kr(),Nf=ui(),_r=mi(),Vs=hi(),M=W(),G=ft(),qf=br(),pt=oe(),Rr=wr();function Ff(e){if(Ti(e)&&(Ii(e),Ai(e))){Lf(e);return}xi(e,()=>(0, Ei.topBoolOrEmptySchema)(e));}Rt.validateFunctionCode=Ff;function xi({gen:e,validateName:t,schema:r,schemaEnv:n,opts:s},o){s.code.es5?e.func(t,(0, M._)`${G.default.data}, ${G.default.valCxt}`,n.$async,()=>{e.code((0, M._)`"use strict"; ${_i(r,s)}`),Df(e,s),e.code(o);}):e.func(t,(0, M._)`${G.default.data}, ${Mf(s)}`,n.$async,()=>e.code(_i(r,s)).code(o));}function Mf(e){return (0, M._)`{${G.default.instancePath}="", ${G.default.parentData}, ${G.default.parentDataProperty}, ${G.default.rootData}=${G.default.data}${e.dynamicRef?(0, M._)`, ${G.default.dynamicAnchors}={}`:M.nil}}={}`}function Df(e,t){e.if(G.default.valCxt,()=>{e.var(G.default.instancePath,(0, M._)`${G.default.valCxt}.${G.default.instancePath}`),e.var(G.default.parentData,(0, M._)`${G.default.valCxt}.${G.default.parentData}`),e.var(G.default.parentDataProperty,(0, M._)`${G.default.valCxt}.${G.default.parentDataProperty}`),e.var(G.default.rootData,(0, M._)`${G.default.valCxt}.${G.default.rootData}`),t.dynamicRef&&e.var(G.default.dynamicAnchors,(0, M._)`${G.default.valCxt}.${G.default.dynamicAnchors}`);},()=>{e.var(G.default.instancePath,(0, M._)`""`),e.var(G.default.parentData,(0, M._)`undefined`),e.var(G.default.parentDataProperty,(0, M._)`undefined`),e.var(G.default.rootData,G.default.data),t.dynamicRef&&e.var(G.default.dynamicAnchors,(0, M._)`{}`);});}function Lf(e){let{schema:t,opts:r,gen:n}=e;xi(e,()=>{r.$comment&&t.$comment&&Oi(e),Gf(e),n.let(G.default.vErrors,null),n.let(G.default.errors,0),r.unevaluated&&Bf(e),ji(e),Hf(e);});}function Bf(e){let{gen:t,validateName:r}=e;e.evaluated=t.const("evaluated",(0, M._)`${r}.evaluated`),t.if((0, M._)`${e.evaluated}.dynamicProps`,()=>t.assign((0, M._)`${e.evaluated}.props`,(0, M._)`undefined`)),t.if((0, M._)`${e.evaluated}.dynamicItems`,()=>t.assign((0, M._)`${e.evaluated}.items`,(0, M._)`undefined`));}function _i(e,t){let r=typeof e=="object"&&e[t.schemaId];return r&&(t.code.source||t.code.process)?(0, M._)`/*# sourceURL=${r} */`:M.nil}function Vf(e,t){if(Ti(e)&&(Ii(e),Ai(e))){Uf(e,t);return}(0, Ei.boolOrEmptySchema)(e,t);}function Ai({schema:e,self:t}){if(typeof e=="boolean")return !e;for(let r in e)if(t.RULES.all[r])return true;return false}function Ti(e){return typeof e.schema!="boolean"}function Uf(e,t){let{schema:r,gen:n,opts:s}=e;s.$comment&&r.$comment&&Oi(e),Jf(e),zf(e);let o=n.const("_errs",G.default.errors);ji(e,o),n.var(t,(0, M._)`${o} === ${G.default.errors}`);}function Ii(e){(0, pt.checkUnknownRules)(e),Kf(e);}function ji(e,t){if(e.opts.jtd)return Ci(e,[],false,t);let r=(0, Ri.getSchemaTypes)(e.schema),n=(0, Ri.coerceAndCheckDataType)(e,r);Ci(e,r,!n,t);}function Kf(e){let{schema:t,errSchemaPath:r,opts:n,self:s}=e;t.$ref&&n.ignoreKeywordsWithRef&&(0, pt.schemaHasRulesButRef)(t,s.RULES)&&s.logger.warn(`$ref: keywords ignored in schema at path "${r}"`);}function Gf(e){let{schema:t,opts:r}=e;t.default!==void 0&&r.useDefaults&&r.strictSchema&&(0, pt.checkStrictMode)(e,"default is ignored in the schema root");}function Jf(e){let t=e.schema[e.opts.schemaId];t&&(e.baseId=(0, qf.resolveUrl)(e.opts.uriResolver,e.baseId,t));}function zf(e){if(e.schema.$async&&!e.schemaEnv.$async)throw new Error("async schema in sync schema")}function Oi({gen:e,schemaEnv:t,schema:r,errSchemaPath:n,opts:s}){let o=r.$comment;if(s.$comment===true)e.code((0, M._)`${G.default.self}.logger.log(${o})`);else if(typeof s.$comment=="function"){let a=(0, M.str)`${n}/$comment`,i=e.scopeValue("root",{ref:t.root});e.code((0, M._)`${G.default.self}.opts.$comment(${o}, ${a}, ${i}.schema)`);}}function Hf(e){let{gen:t,schemaEnv:r,validateName:n,ValidationError:s,opts:o}=e;r.$async?t.if((0, M._)`${G.default.errors} === 0`,()=>t.return(G.default.data),()=>t.throw((0, M._)`new ${s}(${G.default.vErrors})`)):(t.assign((0, M._)`${n}.errors`,G.default.vErrors),o.unevaluated&&Wf(e),t.return((0, M._)`${G.default.errors} === 0`));}function Wf({gen:e,evaluated:t,props:r,items:n}){r instanceof M.Name&&e.assign((0, M._)`${t}.props`,r),n instanceof M.Name&&e.assign((0, M._)`${t}.items`,n);}function Ci(e,t,r,n){let{gen:s,schema:o,data:a,allErrors:i,opts:u,self:c}=e,{RULES:d}=c;if(o.$ref&&(u.ignoreKeywordsWithRef||!(0, pt.schemaHasRulesButRef)(o,d))){s.block(()=>Ni(e,"$ref",d.all.$ref.definition));return}u.jtd||Yf(e,t),s.block(()=>{for(let g of d.rules)l(g);l(d.post);});function l(g){(0, Us.shouldUseGroup)(o,g)&&(g.type?(s.if((0, gn.checkDataType)(g.type,a,u.strictNumbers)),$i(e,g),t.length===1&&t[0]===g.type&&r&&(s.else(),(0, gn.reportTypeError)(e)),s.endIf()):$i(e,g),i||s.if((0, M._)`${G.default.errors} === ${n||0}`));}}function $i(e,t){let{gen:r,schema:n,opts:{useDefaults:s}}=e;s&&(0, Nf.assignDefaults)(e,t.type),r.block(()=>{for(let o of t.rules)(0, Us.shouldUseRule)(n,o)&&Ni(e,o.keyword,o.definition,t.type);});}function Yf(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(Xf(e,t),e.opts.allowUnionTypes||Qf(e,t),Zf(e,e.dataTypes));}function Xf(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(r=>{Pi(e.dataTypes,r)||Ks(e,`type "${r}" not allowed by context "${e.dataTypes.join(",")}"`);}),tp(e,t);}}function Qf(e,t){t.length>1&&!(t.length===2&&t.includes("null"))&&Ks(e,"use allowUnionTypes to allow union type keyword");}function Zf(e,t){let r=e.self.RULES.all;for(let n in r){let s=r[n];if(typeof s=="object"&&(0, Us.shouldUseRule)(e.schema,s)){let{type:o}=s.definition;o.length&&!o.some(a=>ep(t,a))&&Ks(e,`missing type "${o.join(",")}" for keyword "${n}"`);}}}function ep(e,t){return e.includes(t)||t==="number"&&e.includes("integer")}function Pi(e,t){return e.includes(t)||t==="integer"&&e.includes("number")}function tp(e,t){let r=[];for(let n of e.dataTypes)Pi(t,n)?r.push(n):t.includes("integer")&&n==="number"&&r.push("integer");e.dataTypes=r;}function Ks(e,t){let r=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${r}" (strictTypes)`,(0, pt.checkStrictMode)(e,t,e.opts.strictTypes);}var hn=class{constructor(t,r,n){if((0, _r.validateKeywordUsage)(t,r,n),this.gen=t.gen,this.allErrors=t.allErrors,this.keyword=n,this.data=t.data,this.schema=t.schema[n],this.$data=r.$data&&t.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0, pt.schemaRefOrVal)(t,this.schema,n,this.$data),this.schemaType=r.schemaType,this.parentSchema=t.schema,this.params={},this.it=t,this.def=r,this.$data)this.schemaCode=t.gen.const("vSchema",qi(this.$data,t));else if(this.schemaCode=this.schemaValue,!(0, _r.validSchemaType)(this.schema,r.schemaType,r.allowUndefined))throw new Error(`${n} value must be ${JSON.stringify(r.schemaType)}`);("code"in r?r.trackErrors:r.errors!==false)&&(this.errsCount=t.gen.const("_errs",G.default.errors));}result(t,r,n){this.failResult((0, M.not)(t),r,n);}failResult(t,r,n){this.gen.if(t),n?n():this.error(),r?(this.gen.else(),r(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else();}pass(t,r){this.failResult((0, M.not)(t),void 0,r);}fail(t){if(t===void 0){this.error(),this.allErrors||this.gen.if(false);return}this.gen.if(t),this.error(),this.allErrors?this.gen.endIf():this.gen.else();}fail$data(t){if(!this.$data)return this.fail(t);let{schemaCode:r}=this;this.fail((0, M._)`${r} !== undefined && (${(0, M.or)(this.invalid$data(),t)})`);}error(t,r,n){if(r){this.setParams(r),this._error(t,n),this.setParams({});return}this._error(t,n);}_error(t,r){(t?Rr.reportExtraError:Rr.reportError)(this,this.def.error,r);}$dataError(){(0, Rr.reportError)(this,this.def.$dataError||Rr.keyword$DataError);}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0, Rr.resetErrorsCount)(this.gen,this.errsCount);}ok(t){this.allErrors||this.gen.if(t);}setParams(t,r){r?Object.assign(this.params,t):this.params=t;}block$data(t,r,n=M.nil){this.gen.block(()=>{this.check$data(t,n),r();});}check$data(t=M.nil,r=M.nil){if(!this.$data)return;let{gen:n,schemaCode:s,schemaType:o,def:a}=this;n.if((0, M.or)((0, M._)`${s} === undefined`,r)),t!==M.nil&&n.assign(t,true),(o.length||a.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),t!==M.nil&&n.assign(t,false)),n.else();}invalid$data(){let{gen:t,schemaCode:r,schemaType:n,def:s,it:o}=this;return (0, M.or)(a(),i());function a(){if(n.length){if(!(r instanceof M.Name))throw new Error("ajv implementation error");let u=Array.isArray(n)?n:[n];return (0, M._)`${(0, gn.checkDataTypes)(u,r,o.opts.strictNumbers,gn.DataType.Wrong)}`}return M.nil}function i(){if(s.validateSchema){let u=t.scopeValue("validate$data",{ref:s.validateSchema});return (0, M._)`!${u}(${r})`}return M.nil}}subschema(t,r){let n=(0, Vs.getSubschema)(this.it,t);(0, Vs.extendSubschemaData)(n,this.it,t),(0, Vs.extendSubschemaMode)(n,t);let s={...this.it,...n,items:void 0,props:void 0};return Vf(s,r),s}mergeEvaluated(t,r){let{it:n,gen:s}=this;n.opts.unevaluated&&(n.props!==true&&t.props!==void 0&&(n.props=pt.mergeEvaluated.props(s,t.props,n.props,r)),n.items!==true&&t.items!==void 0&&(n.items=pt.mergeEvaluated.items(s,t.items,n.items,r)));}mergeValidEvaluated(t,r){let{it:n,gen:s}=this;if(n.opts.unevaluated&&(n.props!==true||n.items!==true))return s.if(r,()=>this.mergeEvaluated(t,M.Name)),true}};Rt.KeywordCxt=hn;function Ni(e,t,r,n){let s=new hn(e,r,t);"code"in r?r.code(s,n):s.$data&&r.validate?(0, _r.funcKeywordCode)(s,r):"macro"in r?(0, _r.macroKeywordCode)(s,r):(r.compile||r.validate)&&(0, _r.funcKeywordCode)(s,r);}var rp=/^\/(?:[^~]|~0|~1)*$/,np=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function qi(e,{dataLevel:t,dataNames:r,dataPathArr:n}){let s,o;if(e==="")return G.default.rootData;if(e[0]==="/"){if(!rp.test(e))throw new Error(`Invalid JSON-pointer: ${e}`);s=e,o=G.default.rootData;}else {let c=np.exec(e);if(!c)throw new Error(`Invalid JSON-pointer: ${e}`);let d=+c[1];if(s=c[2],s==="#"){if(d>=t)throw new Error(u("property/index",d));return n[t-d]}if(d>t)throw new Error(u("data",d));if(o=r[t-d],!s)return o}let a=o,i=s.split("/");for(let c of i)c&&(o=(0, M._)`${o}${(0, M.getProperty)((0, pt.unescapeJsonPointer)(c))}`,a=(0, M._)`${a} && ${o}`);return a;function u(c,d){return `Cannot access ${c} ${d} levels up, current level is ${t}`}}Rt.getData=qi;});var yn=O(Js=>{Object.defineProperty(Js,"__esModule",{value:true});var Gs=class extends Error{constructor(t){super("validation failed"),this.errors=t,this.ajv=this.validation=true;}};Js.default=Gs;});var $r=O(Ws=>{Object.defineProperty(Ws,"__esModule",{value:true});var zs=br(),Hs=class extends Error{constructor(t,r,n,s){super(s||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0, zs.resolveUrl)(t,r,n),this.missingSchema=(0, zs.normalizeId)((0, zs.getFullPath)(t,this.missingRef));}};Ws.default=Hs;});var Sn=O(Je=>{Object.defineProperty(Je,"__esModule",{value:true});Je.resolveSchema=Je.getCompilingSchema=Je.resolveRef=Je.compileSchema=Je.SchemaEnv=void 0;var Ze=W(),sp=yn(),Lt=ft(),et=br(),Fi=oe(),op=Cr(),nr=class{constructor(t){var r;this.refs={},this.dynamicAnchors={};let n;typeof t.schema=="object"&&(n=t.schema),this.schema=t.schema,this.schemaId=t.schemaId,this.root=t.root||this,this.baseId=(r=t.baseId)!==null&&r!==void 0?r:(0, et.normalizeId)(n?.[t.schemaId||"$id"]),this.schemaPath=t.schemaPath,this.localRefs=t.localRefs,this.meta=t.meta,this.$async=n?.$async,this.refs={};}};Je.SchemaEnv=nr;function Xs(e){let t=Mi.call(this,e);if(t)return t;let r=(0, et.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:n,lines:s}=this.opts.code,{ownProperties:o}=this.opts,a=new Ze.CodeGen(this.scope,{es5:n,lines:s,ownProperties:o}),i;e.$async&&(i=a.scopeValue("Error",{ref:sp.default,code:(0, Ze._)`require("ajv/dist/runtime/validation_error").default`}));let u=a.scopeName("validate");e.validateName=u;let c={gen:a,allErrors:this.opts.allErrors,data:Lt.default.data,parentData:Lt.default.parentData,parentDataProperty:Lt.default.parentDataProperty,dataNames:[Lt.default.data],dataPathArr:[Ze.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:a.scopeValue("schema",this.opts.code.source===true?{ref:e.schema,code:(0, Ze.stringify)(e.schema)}:{ref:e.schema}),validateName:u,ValidationError:i,schema:e.schema,schemaEnv:e,rootId:r,baseId:e.baseId||r,schemaPath:Ze.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0, Ze._)`""`,opts:this.opts,self:this},d;try{this._compilations.add(e),(0,op.validateFunctionCode)(c),a.optimize(this.opts.code.optimize);let l=a.toString();d=`${a.scopeRefs(Lt.default.scope)}return ${l}`,this.opts.code.process&&(d=this.opts.code.process(d,e));let v=new Function(`${Lt.default.self}`,`${Lt.default.scope}`,d)(this,this.scope.get());if(this.scope.value(u,{ref:v}),v.errors=null,v.schema=e.schema,v.schemaEnv=e,e.$async&&(v.$async=!0),this.opts.code.source===!0&&(v.source={validateName:u,validateCode:l,scopeValues:a._values}),this.opts.unevaluated){let{props:f,items:m}=c;v.evaluated={props:f instanceof Ze.Name?void 0:f,items:m instanceof Ze.Name?void 0:m,dynamicProps:f instanceof Ze.Name,dynamicItems:m instanceof Ze.Name},v.source&&(v.source.evaluated=(0,Ze.stringify)(v.evaluated));}return e.validate=v,e}catch(l){throw delete e.validate,delete e.validateName,d&&this.logger.error("Error compiling schema, function code:",d),l}finally{this._compilations.delete(e);}}Je.compileSchema=Xs;function ap(e,t,r){var n;r=(0, et.resolveUrl)(this.opts.uriResolver,t,r);let s=e.refs[r];if(s)return s;let o=up.call(this,e,r);if(o===void 0){let a=(n=e.localRefs)===null||n===void 0?void 0:n[r],{schemaId:i}=this.opts;a&&(o=new nr({schema:a,schemaId:i,root:e,baseId:t}));}if(o!==void 0)return e.refs[r]=ip.call(this,o)}Je.resolveRef=ap;function ip(e){return (0, et.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:Xs.call(this,e)}function Mi(e){for(let t of this._compilations)if(cp(t,e))return t}Je.getCompilingSchema=Mi;function cp(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function up(e,t){let r;for(;typeof(r=this.refs[t])=="string";)t=r;return r||this.schemas[t]||vn.call(this,e,t)}function vn(e,t){let r=this.opts.uriResolver.parse(t),n=(0, et._getFullPath)(this.opts.uriResolver,r),s=(0, et.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&n===s)return Ys.call(this,r,e);let o=(0, et.normalizeId)(n),a=this.refs[o]||this.schemas[o];if(typeof a=="string"){let i=vn.call(this,e,a);return typeof i?.schema!="object"?void 0:Ys.call(this,r,i)}if(typeof a?.schema=="object"){if(a.validate||Xs.call(this,a),o===(0, et.normalizeId)(t)){let{schema:i}=a,{schemaId:u}=this.opts,c=i[u];return c&&(s=(0, et.resolveUrl)(this.opts.uriResolver,s,c)),new nr({schema:i,schemaId:u,root:e,baseId:s})}return Ys.call(this,r,a)}}Je.resolveSchema=vn;var dp=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function Ys(e,{baseId:t,schema:r,root:n}){var s;if(((s=e.fragment)===null||s===void 0?void 0:s[0])!=="/")return;for(let i of e.fragment.slice(1).split("/")){if(typeof r=="boolean")return;let u=r[(0, Fi.unescapeFragment)(i)];if(u===void 0)return;r=u;let c=typeof r=="object"&&r[this.opts.schemaId];!dp.has(i)&&c&&(t=(0, et.resolveUrl)(this.opts.uriResolver,t,c));}let o;if(typeof r!="boolean"&&r.$ref&&!(0, Fi.schemaHasRulesButRef)(r,this.RULES)){let i=(0, et.resolveUrl)(this.opts.uriResolver,t,r.$ref);o=vn.call(this,n,i);}let{schemaId:a}=this.opts;if(o=o||new nr({schema:r,schemaId:a,root:n,baseId:t}),o.schema!==o.root.schema)return o}});var Di=O((Iv,lp)=>{lp.exports={$id:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",description:"Meta-schema for $data reference (JSON AnySchema extension proposal)",type:"object",required:["$data"],properties:{$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},additionalProperties:false};});var Zs=O((jv,Ui)=>{var fp=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),Bi=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);function Qs(e){let t="",r=0,n=0;for(n=0;n<e.length;n++)if(r=e[n].charCodeAt(0),r!==48){if(!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return "";t+=e[n];break}for(n+=1;n<e.length;n++){if(r=e[n].charCodeAt(0),!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return "";t+=e[n];}return t}var pp=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function Li(e){return e.length=0,true}function mp(e,t,r){if(e.length){let n=Qs(e);if(n!=="")t.push(n);else return r.error=true,false;e.length=0;}return true}function gp(e){let t=0,r={error:false,address:"",zone:""},n=[],s=[],o=false,a=false,i=mp;for(let u=0;u<e.length;u++){let c=e[u];if(!(c==="["||c==="]"))if(c===":"){if(o===true&&(a=true),!i(s,n,r))break;if(++t>7){r.error=true;break}u>0&&e[u-1]===":"&&(o=true),n.push(":");continue}else if(c==="%"){if(!i(s,n,r))break;i=Li;}else {s.push(c);continue}}return s.length&&(i===Li?r.zone=s.join(""):a?n.push(s.join("")):n.push(Qs(s))),r.address=n.join(""),r}function Vi(e){if(hp(e,":")<2)return {host:e,isIPV6:false};let t=gp(e);if(t.error)return {host:e,isIPV6:false};{let r=t.address,n=t.address;return t.zone&&(r+="%"+t.zone,n+="%25"+t.zone),{host:r,isIPV6:true,escapedHost:n}}}function hp(e,t){let r=0;for(let n=0;n<e.length;n++)e[n]===t&&r++;return r}function yp(e){let t=e,r=[],n=-1,s=0;for(;s=t.length;){if(s===1){if(t===".")break;if(t==="/"){r.push("/");break}else {r.push(t);break}}else if(s===2){if(t[0]==="."){if(t[1]===".")break;if(t[1]==="/"){t=t.slice(2);continue}}else if(t[0]==="/"&&(t[1]==="."||t[1]==="/")){r.push("/");break}}else if(s===3&&t==="/.."){r.length!==0&&r.pop(),r.push("/");break}if(t[0]==="."){if(t[1]==="."){if(t[2]==="/"){t=t.slice(3);continue}}else if(t[1]==="/"){t=t.slice(2);continue}}else if(t[0]==="/"&&t[1]==="."){if(t[2]==="/"){t=t.slice(2);continue}else if(t[2]==="."&&t[3]==="/"){t=t.slice(3),r.length!==0&&r.pop();continue}}if((n=t.indexOf("/",1))===-1){r.push(t);break}else r.push(t.slice(0,n)),t=t.slice(n);}return r.join("")}function vp(e,t){let r=t!==true?escape:unescape;return e.scheme!==void 0&&(e.scheme=r(e.scheme)),e.userinfo!==void 0&&(e.userinfo=r(e.userinfo)),e.host!==void 0&&(e.host=r(e.host)),e.path!==void 0&&(e.path=r(e.path)),e.query!==void 0&&(e.query=r(e.query)),e.fragment!==void 0&&(e.fragment=r(e.fragment)),e}function Sp(e){let t=[];if(e.userinfo!==void 0&&(t.push(e.userinfo),t.push("@")),e.host!==void 0){let r=unescape(e.host);if(!Bi(r)){let n=Vi(r);n.isIPV6===true?r=`[${n.escapedHost}]`:r=e.host;}t.push(r);}return (typeof e.port=="number"||typeof e.port=="string")&&(t.push(":"),t.push(String(e.port))),t.length?t.join(""):void 0}Ui.exports={nonSimpleDomain:pp,recomposeAuthority:Sp,normalizeComponentEncoding:vp,removeDotSegments:yp,isIPv4:Bi,isUUID:fp,normalizeIPv6:Vi,stringArrayToHexStripped:Qs};});var Hi=O((Ov,zi)=>{var{isUUID:wp}=Zs(),kp=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,bp=["http","https","ws","wss","urn","urn:uuid"];function Rp(e){return bp.indexOf(e)!==-1}function eo(e){return e.secure===true?true:e.secure===false?false:e.scheme?e.scheme.length===3&&(e.scheme[0]==="w"||e.scheme[0]==="W")&&(e.scheme[1]==="s"||e.scheme[1]==="S")&&(e.scheme[2]==="s"||e.scheme[2]==="S"):false}function Ki(e){return e.host||(e.error=e.error||"HTTP URIs must have a host."),e}function Gi(e){let t=String(e.scheme).toLowerCase()==="https";return (e.port===(t?443:80)||e.port==="")&&(e.port=void 0),e.path||(e.path="/"),e}function _p(e){return e.secure=eo(e),e.resourceName=(e.path||"/")+(e.query?"?"+e.query:""),e.path=void 0,e.query=void 0,e}function Cp(e){if((e.port===(eo(e)?443:80)||e.port==="")&&(e.port=void 0),typeof e.secure=="boolean"&&(e.scheme=e.secure?"wss":"ws",e.secure=void 0),e.resourceName){let[t,r]=e.resourceName.split("?");e.path=t&&t!=="/"?t:void 0,e.query=r,e.resourceName=void 0;}return e.fragment=void 0,e}function $p(e,t){if(!e.path)return e.error="URN can not be parsed",e;let r=e.path.match(kp);if(r){let n=t.scheme||e.scheme||"urn";e.nid=r[1].toLowerCase(),e.nss=r[2];let s=`${n}:${t.nid||e.nid}`,o=to(s);e.path=void 0,o&&(e=o.parse(e,t));}else e.error=e.error||"URN can not be parsed.";return e}function Ep(e,t){if(e.nid===void 0)throw new Error("URN without nid cannot be serialized");let r=t.scheme||e.scheme||"urn",n=e.nid.toLowerCase(),s=`${r}:${t.nid||n}`,o=to(s);o&&(e=o.serialize(e,t));let a=e,i=e.nss;return a.path=`${n||t.nid}:${i}`,t.skipEscape=true,a}function xp(e,t){let r=e;return r.uuid=r.nss,r.nss=void 0,!t.tolerant&&(!r.uuid||!wp(r.uuid))&&(r.error=r.error||"UUID is not valid."),r}function Ap(e){let t=e;return t.nss=(e.uuid||"").toLowerCase(),t}var Ji={scheme:"http",domainHost:true,parse:Ki,serialize:Gi},Tp={scheme:"https",domainHost:Ji.domainHost,parse:Ki,serialize:Gi},wn={scheme:"ws",domainHost:true,parse:_p,serialize:Cp},Ip={scheme:"wss",domainHost:wn.domainHost,parse:wn.parse,serialize:wn.serialize},jp={scheme:"urn",parse:$p,serialize:Ep,skipNormalize:true},Op={scheme:"urn:uuid",parse:xp,serialize:Ap,skipNormalize:true},kn={http:Ji,https:Tp,ws:wn,wss:Ip,urn:jp,"urn:uuid":Op};Object.setPrototypeOf(kn,null);function to(e){return e&&(kn[e]||kn[e.toLowerCase()])||void 0}zi.exports={wsIsSecure:eo,SCHEMES:kn,isValidSchemeName:Rp,getSchemeHandler:to};});var Xi=O((Pv,Rn)=>{var{normalizeIPv6:Pp,removeDotSegments:Er,recomposeAuthority:Np,normalizeComponentEncoding:bn,isIPv4:qp,nonSimpleDomain:Fp}=Zs(),{SCHEMES:Mp,getSchemeHandler:Wi}=Hi();function Dp(e,t){return typeof e=="string"?e=at(mt(e,t),t):typeof e=="object"&&(e=mt(at(e,t),t)),e}function Lp(e,t,r){let n=r?Object.assign({scheme:"null"},r):{scheme:"null"},s=Yi(mt(e,n),mt(t,n),n,true);return n.skipEscape=true,at(s,n)}function Yi(e,t,r,n){let s={};return n||(e=mt(at(e,r),r),t=mt(at(t,r),r)),r=r||{},!r.tolerant&&t.scheme?(s.scheme=t.scheme,s.userinfo=t.userinfo,s.host=t.host,s.port=t.port,s.path=Er(t.path||""),s.query=t.query):(t.userinfo!==void 0||t.host!==void 0||t.port!==void 0?(s.userinfo=t.userinfo,s.host=t.host,s.port=t.port,s.path=Er(t.path||""),s.query=t.query):(t.path?(t.path[0]==="/"?s.path=Er(t.path):((e.userinfo!==void 0||e.host!==void 0||e.port!==void 0)&&!e.path?s.path="/"+t.path:e.path?s.path=e.path.slice(0,e.path.lastIndexOf("/")+1)+t.path:s.path=t.path,s.path=Er(s.path)),s.query=t.query):(s.path=e.path,t.query!==void 0?s.query=t.query:s.query=e.query),s.userinfo=e.userinfo,s.host=e.host,s.port=e.port),s.scheme=e.scheme),s.fragment=t.fragment,s}function Bp(e,t,r){return typeof e=="string"?(e=unescape(e),e=at(bn(mt(e,r),true),{...r,skipEscape:true})):typeof e=="object"&&(e=at(bn(e,true),{...r,skipEscape:true})),typeof t=="string"?(t=unescape(t),t=at(bn(mt(t,r),true),{...r,skipEscape:true})):typeof t=="object"&&(t=at(bn(t,true),{...r,skipEscape:true})),e.toLowerCase()===t.toLowerCase()}function at(e,t){let r={host:e.host,scheme:e.scheme,userinfo:e.userinfo,port:e.port,path:e.path,query:e.query,nid:e.nid,nss:e.nss,uuid:e.uuid,fragment:e.fragment,reference:e.reference,resourceName:e.resourceName,secure:e.secure,error:""},n=Object.assign({},t),s=[],o=Wi(n.scheme||r.scheme);o&&o.serialize&&o.serialize(r,n),r.path!==void 0&&(n.skipEscape?r.path=unescape(r.path):(r.path=escape(r.path),r.scheme!==void 0&&(r.path=r.path.split("%3A").join(":")))),n.reference!=="suffix"&&r.scheme&&s.push(r.scheme,":");let a=Np(r);if(a!==void 0&&(n.reference!=="suffix"&&s.push("//"),s.push(a),r.path&&r.path[0]!=="/"&&s.push("/")),r.path!==void 0){let i=r.path;!n.absolutePath&&(!o||!o.absolutePath)&&(i=Er(i)),a===void 0&&i[0]==="/"&&i[1]==="/"&&(i="/%2F"+i.slice(2)),s.push(i);}return r.query!==void 0&&s.push("?",r.query),r.fragment!==void 0&&s.push("#",r.fragment),s.join("")}var Vp=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function mt(e,t){let r=Object.assign({},t),n={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},s=false;r.reference==="suffix"&&(r.scheme?e=r.scheme+":"+e:e="//"+e);let o=e.match(Vp);if(o){if(n.scheme=o[1],n.userinfo=o[3],n.host=o[4],n.port=parseInt(o[5],10),n.path=o[6]||"",n.query=o[7],n.fragment=o[8],isNaN(n.port)&&(n.port=o[5]),n.host)if(qp(n.host)===false){let u=Pp(n.host);n.host=u.host.toLowerCase(),s=u.isIPV6;}else s=true;n.scheme===void 0&&n.userinfo===void 0&&n.host===void 0&&n.port===void 0&&n.query===void 0&&!n.path?n.reference="same-document":n.scheme===void 0?n.reference="relative":n.fragment===void 0?n.reference="absolute":n.reference="uri",r.reference&&r.reference!=="suffix"&&r.reference!==n.reference&&(n.error=n.error||"URI is not a "+r.reference+" reference.");let a=Wi(r.scheme||n.scheme);if(!r.unicodeSupport&&(!a||!a.unicodeSupport)&&n.host&&(r.domainHost||a&&a.domainHost)&&s===false&&Fp(n.host))try{n.host=URL.domainToASCII(n.host.toLowerCase());}catch(i){n.error=n.error||"Host's domain name can not be converted to ASCII: "+i;}(!a||a&&!a.skipNormalize)&&(e.indexOf("%")!==-1&&(n.scheme!==void 0&&(n.scheme=unescape(n.scheme)),n.host!==void 0&&(n.host=unescape(n.host))),n.path&&(n.path=escape(unescape(n.path))),n.fragment&&(n.fragment=encodeURI(decodeURIComponent(n.fragment)))),a&&a.parse&&a.parse(n,r);}else n.error=n.error||"URI can not be parsed.";return n}var ro={SCHEMES:Mp,normalize:Dp,resolve:Lp,resolveComponent:Yi,equal:Bp,serialize:at,parse:mt};Rn.exports=ro;Rn.exports.default=ro;Rn.exports.fastUri=ro;});var Zi=O(no=>{Object.defineProperty(no,"__esModule",{value:true});var Qi=Xi();Qi.code='require("ajv/dist/runtime/uri").default';no.default=Qi;});var ic=O(be=>{Object.defineProperty(be,"__esModule",{value:true});be.CodeGen=be.Name=be.nil=be.stringify=be.str=be._=be.KeywordCxt=void 0;var Up=Cr();Object.defineProperty(be,"KeywordCxt",{enumerable:true,get:function(){return Up.KeywordCxt}});var sr=W();Object.defineProperty(be,"_",{enumerable:true,get:function(){return sr._}});Object.defineProperty(be,"str",{enumerable:true,get:function(){return sr.str}});Object.defineProperty(be,"stringify",{enumerable:true,get:function(){return sr.stringify}});Object.defineProperty(be,"nil",{enumerable:true,get:function(){return sr.nil}});Object.defineProperty(be,"Name",{enumerable:true,get:function(){return sr.Name}});Object.defineProperty(be,"CodeGen",{enumerable:true,get:function(){return sr.CodeGen}});var Kp=yn(),sc=$r(),Gp=js(),xr=Sn(),Jp=W(),Ar=br(),_n=kr(),oo=oe(),ec=Di(),zp=Zi(),oc=(e,t)=>new RegExp(e,t);oc.code="new RegExp";var Hp=["removeAdditional","useDefaults","coerceTypes"],Wp=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),Yp={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."},Xp={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},tc=200;function Qp(e){var t,r,n,s,o,a,i,u,c,d,l,g,v,f,m,b,C,F,_,I,S,k,w,p,h;let R=e.strict,x=(t=e.code)===null||t===void 0?void 0:t.optimize,A=x===true||x===void 0?1:x||0,T=(n=(r=e.code)===null||r===void 0?void 0:r.regExp)!==null&&n!==void 0?n:oc,B=(s=e.uriResolver)!==null&&s!==void 0?s:zp.default;return {strictSchema:(a=(o=e.strictSchema)!==null&&o!==void 0?o:R)!==null&&a!==void 0?a:true,strictNumbers:(u=(i=e.strictNumbers)!==null&&i!==void 0?i:R)!==null&&u!==void 0?u:true,strictTypes:(d=(c=e.strictTypes)!==null&&c!==void 0?c:R)!==null&&d!==void 0?d:"log",strictTuples:(g=(l=e.strictTuples)!==null&&l!==void 0?l:R)!==null&&g!==void 0?g:"log",strictRequired:(f=(v=e.strictRequired)!==null&&v!==void 0?v:R)!==null&&f!==void 0?f:false,code:e.code?{...e.code,optimize:A,regExp:T}:{optimize:A,regExp:T},loopRequired:(m=e.loopRequired)!==null&&m!==void 0?m:tc,loopEnum:(b=e.loopEnum)!==null&&b!==void 0?b:tc,meta:(C=e.meta)!==null&&C!==void 0?C:true,messages:(F=e.messages)!==null&&F!==void 0?F:true,inlineRefs:(_=e.inlineRefs)!==null&&_!==void 0?_:true,schemaId:(I=e.schemaId)!==null&&I!==void 0?I:"$id",addUsedSchema:(S=e.addUsedSchema)!==null&&S!==void 0?S:true,validateSchema:(k=e.validateSchema)!==null&&k!==void 0?k:true,validateFormats:(w=e.validateFormats)!==null&&w!==void 0?w:true,unicodeRegExp:(p=e.unicodeRegExp)!==null&&p!==void 0?p:true,int32range:(h=e.int32range)!==null&&h!==void 0?h:true,uriResolver:B}}var Tr=class{constructor(t={}){this.schemas={},this.refs={},this.formats={},this._compilations=new Set,this._loading={},this._cache=new Map,t=this.opts={...t,...Qp(t)};let{es5:r,lines:n}=this.opts.code;this.scope=new Jp.ValueScope({scope:{},prefixes:Wp,es5:r,lines:n}),this.logger=sm(t.logger);let s=t.validateFormats;t.validateFormats=false,this.RULES=(0, Gp.getRules)(),rc.call(this,Yp,t,"NOT SUPPORTED"),rc.call(this,Xp,t,"DEPRECATED","warn"),this._metaOpts=rm.call(this),t.formats&&em.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),t.keywords&&tm.call(this,t.keywords),typeof t.meta=="object"&&this.addMetaSchema(t.meta),Zp.call(this),t.validateFormats=s;}_addVocabularies(){this.addKeyword("$async");}_addDefaultMetaSchema(){let{$data:t,meta:r,schemaId:n}=this.opts,s=ec;n==="id"&&(s={...ec},s.id=s.$id,delete s.$id),r&&t&&this.addMetaSchema(s,s[n],false);}defaultMeta(){let{meta:t,schemaId:r}=this.opts;return this.opts.defaultMeta=typeof t=="object"?t[r]||t:void 0}validate(t,r){let n;if(typeof t=="string"){if(n=this.getSchema(t),!n)throw new Error(`no schema with key or ref "${t}"`)}else n=this.compile(t);let s=n(r);return "$async"in n||(this.errors=n.errors),s}compile(t,r){let n=this._addSchema(t,r);return n.validate||this._compileSchemaEnv(n)}compileAsync(t,r){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");let{loadSchema:n}=this.opts;return s.call(this,t,r);async function s(d,l){await o.call(this,d.$schema);let g=this._addSchema(d,l);return g.validate||a.call(this,g)}async function o(d){d&&!this.getSchema(d)&&await s.call(this,{$ref:d},true);}async function a(d){try{return this._compileSchemaEnv(d)}catch(l){if(!(l instanceof sc.default))throw l;return i.call(this,l),await u.call(this,l.missingSchema),a.call(this,d)}}function i({missingSchema:d,missingRef:l}){if(this.refs[d])throw new Error(`AnySchema ${d} is loaded but ${l} cannot be resolved`)}async function u(d){let l=await c.call(this,d);this.refs[d]||await o.call(this,l.$schema),this.refs[d]||this.addSchema(l,d,r);}async function c(d){let l=this._loading[d];if(l)return l;try{return await(this._loading[d]=n(d))}finally{delete this._loading[d];}}}addSchema(t,r,n,s=this.opts.validateSchema){if(Array.isArray(t)){for(let a of t)this.addSchema(a,void 0,n,s);return this}let o;if(typeof t=="object"){let{schemaId:a}=this.opts;if(o=t[a],o!==void 0&&typeof o!="string")throw new Error(`schema ${a} must be string`)}return r=(0, Ar.normalizeId)(r||o),this._checkUnique(r),this.schemas[r]=this._addSchema(t,n,r,s,true),this}addMetaSchema(t,r,n=this.opts.validateSchema){return this.addSchema(t,r,true,n),this}validateSchema(t,r){if(typeof t=="boolean")return true;let n;if(n=t.$schema,n!==void 0&&typeof n!="string")throw new Error("$schema must be a string");if(n=n||this.opts.defaultMeta||this.defaultMeta(),!n)return this.logger.warn("meta-schema not available"),this.errors=null,true;let s=this.validate(n,t);if(!s&&r){let o="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(o);else throw new Error(o)}return s}getSchema(t){let r;for(;typeof(r=nc.call(this,t))=="string";)t=r;if(r===void 0){let{schemaId:n}=this.opts,s=new xr.SchemaEnv({schema:{},schemaId:n});if(r=xr.resolveSchema.call(this,s,t),!r)return;this.refs[t]=r;}return r.validate||this._compileSchemaEnv(r)}removeSchema(t){if(t instanceof RegExp)return this._removeAllSchemas(this.schemas,t),this._removeAllSchemas(this.refs,t),this;switch(typeof t){case "undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case "string":{let r=nc.call(this,t);return typeof r=="object"&&this._cache.delete(r.schema),delete this.schemas[t],delete this.refs[t],this}case "object":{let r=t;this._cache.delete(r);let n=t[this.opts.schemaId];return n&&(n=(0, Ar.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(t){for(let r of t)this.addKeyword(r);return this}addKeyword(t,r){let n;if(typeof t=="string")n=t,typeof r=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),r.keyword=n);else if(typeof t=="object"&&r===void 0){if(r=t,n=r.keyword,Array.isArray(n)&&!n.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(am.call(this,n,r),!r)return (0, oo.eachItem)(n,o=>so.call(this,o)),this;cm.call(this,r);let s={...r,type:(0, _n.getJSONTypes)(r.type),schemaType:(0, _n.getJSONTypes)(r.schemaType)};return (0, oo.eachItem)(n,s.type.length===0?o=>so.call(this,o,s):o=>s.type.forEach(a=>so.call(this,o,s,a))),this}getKeyword(t){let r=this.RULES.all[t];return typeof r=="object"?r.definition:!!r}removeKeyword(t){let{RULES:r}=this;delete r.keywords[t],delete r.all[t];for(let n of r.rules){let s=n.rules.findIndex(o=>o.keyword===t);s>=0&&n.rules.splice(s,1);}return this}addFormat(t,r){return typeof r=="string"&&(r=new RegExp(r)),this.formats[t]=r,this}errorsText(t=this.errors,{separator:r=", ",dataVar:n="data"}={}){return !t||t.length===0?"No errors":t.map(s=>`${n}${s.instancePath} ${s.message}`).reduce((s,o)=>s+r+o)}$dataMetaSchema(t,r){let n=this.RULES.all;t=JSON.parse(JSON.stringify(t));for(let s of r){let o=s.split("/").slice(1),a=t;for(let i of o)a=a[i];for(let i in n){let u=n[i];if(typeof u!="object")continue;let{$data:c}=u.definition,d=a[i];c&&d&&(a[i]=ac(d));}}return t}_removeAllSchemas(t,r){for(let n in t){let s=t[n];(!r||r.test(n))&&(typeof s=="string"?delete t[n]:s&&!s.meta&&(this._cache.delete(s.schema),delete t[n]));}}_addSchema(t,r,n,s=this.opts.validateSchema,o=this.opts.addUsedSchema){let a,{schemaId:i}=this.opts;if(typeof t=="object")a=t[i];else {if(this.opts.jtd)throw new Error("schema must be object");if(typeof t!="boolean")throw new Error("schema must be object or boolean")}let u=this._cache.get(t);if(u!==void 0)return u;n=(0, Ar.normalizeId)(a||n);let c=Ar.getSchemaRefs.call(this,t,n);return u=new xr.SchemaEnv({schema:t,schemaId:i,meta:r,baseId:n,localRefs:c}),this._cache.set(u.schema,u),o&&!n.startsWith("#")&&(n&&this._checkUnique(n),this.refs[n]=u),s&&this.validateSchema(t,true),u}_checkUnique(t){if(this.schemas[t]||this.refs[t])throw new Error(`schema with key or id "${t}" already exists`)}_compileSchemaEnv(t){if(t.meta?this._compileMetaSchema(t):xr.compileSchema.call(this,t),!t.validate)throw new Error("ajv implementation error");return t.validate}_compileMetaSchema(t){let r=this.opts;this.opts=this._metaOpts;try{xr.compileSchema.call(this,t);}finally{this.opts=r;}}};Tr.ValidationError=Kp.default;Tr.MissingRefError=sc.default;be.default=Tr;function rc(e,t,r,n="error"){for(let s in e){let o=s;o in t&&this.logger[n](`${r}: option ${s}. ${e[o]}`);}}function nc(e){return e=(0, Ar.normalizeId)(e),this.schemas[e]||this.refs[e]}function Zp(){let e=this.opts.schemas;if(e)if(Array.isArray(e))this.addSchema(e);else for(let t in e)this.addSchema(e[t],t);}function em(){for(let e in this.opts.formats){let t=this.opts.formats[e];t&&this.addFormat(e,t);}}function tm(e){if(Array.isArray(e)){this.addVocabulary(e);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let t in e){let r=e[t];r.keyword||(r.keyword=t),this.addKeyword(r);}}function rm(){let e={...this.opts};for(let t of Hp)delete e[t];return e}var nm={log(){},warn(){},error(){}};function sm(e){if(e===false)return nm;if(e===void 0)return console;if(e.log&&e.warn&&e.error)return e;throw new Error("logger must implement log, warn and error methods")}var om=/^[a-z_$][a-z0-9_$:-]*$/i;function am(e,t){let{RULES:r}=this;if((0, oo.eachItem)(e,n=>{if(r.keywords[n])throw new Error(`Keyword ${n} is already defined`);if(!om.test(n))throw new Error(`Keyword ${n} has invalid name`)}),!!t&&t.$data&&!("code"in t||"validate"in t))throw new Error('$data keyword must have "code" or "validate" function')}function so(e,t,r){var n;let s=t?.post;if(r&&s)throw new Error('keyword with "post" flag cannot have "type"');let{RULES:o}=this,a=s?o.post:o.rules.find(({type:u})=>u===r);if(a||(a={type:r,rules:[]},o.rules.push(a)),o.keywords[e]=true,!t)return;let i={keyword:e,definition:{...t,type:(0, _n.getJSONTypes)(t.type),schemaType:(0, _n.getJSONTypes)(t.schemaType)}};t.before?im.call(this,a,i,t.before):a.rules.push(i),o.all[e]=i,(n=t.implements)===null||n===void 0||n.forEach(u=>this.addKeyword(u));}function im(e,t,r){let n=e.rules.findIndex(s=>s.keyword===r);n>=0?e.rules.splice(n,0,t):(e.rules.push(t),this.logger.warn(`rule ${r} is not defined`));}function cm(e){let{metaSchema:t}=e;t!==void 0&&(e.$data&&this.opts.$data&&(t=ac(t)),e.validateSchema=this.compile(t,true));}var um={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function ac(e){return {anyOf:[e,um]}}});var cc=O(ao=>{Object.defineProperty(ao,"__esModule",{value:true});var dm={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};ao.default=dm;});var fc=O(Bt=>{Object.defineProperty(Bt,"__esModule",{value:true});Bt.callRef=Bt.getValidate=void 0;var lm=$r(),uc=Ge(),De=W(),or=ft(),dc=Sn(),Cn=oe(),fm={keyword:"$ref",schemaType:"string",code(e){let{gen:t,schema:r,it:n}=e,{baseId:s,schemaEnv:o,validateName:a,opts:i,self:u}=n,{root:c}=o;if((r==="#"||r==="#/")&&s===c.baseId)return l();let d=dc.resolveRef.call(u,c,s,r);if(d===void 0)throw new lm.default(n.opts.uriResolver,s,r);if(d instanceof dc.SchemaEnv)return g(d);return v(d);function l(){if(o===c)return $n(e,a,o,o.$async);let f=t.scopeValue("root",{ref:c});return $n(e,(0, De._)`${f}.validate`,c,c.$async)}function g(f){let m=lc(e,f);$n(e,m,f,f.$async);}function v(f){let m=t.scopeValue("schema",i.code.source===true?{ref:f,code:(0, De.stringify)(f)}:{ref:f}),b=t.name("valid"),C=e.subschema({schema:f,dataTypes:[],schemaPath:De.nil,topSchemaRef:m,errSchemaPath:r},b);e.mergeEvaluated(C),e.ok(b);}}};function lc(e,t){let{gen:r}=e;return t.validate?r.scopeValue("validate",{ref:t.validate}):(0, De._)`${r.scopeValue("wrapper",{ref:t})}.validate`}Bt.getValidate=lc;function $n(e,t,r,n){let{gen:s,it:o}=e,{allErrors:a,schemaEnv:i,opts:u}=o,c=u.passContext?or.default.this:De.nil;n?d():l();function d(){if(!i.$async)throw new Error("async schema referenced by sync schema");let f=s.let("valid");s.try(()=>{s.code((0, De._)`await ${(0, uc.callValidateCode)(e,t,c)}`),v(t),a||s.assign(f,true);},m=>{s.if((0, De._)`!(${m} instanceof ${o.ValidationError})`,()=>s.throw(m)),g(m),a||s.assign(f,false);}),e.ok(f);}function l(){e.result((0, uc.callValidateCode)(e,t,c),()=>v(t),()=>g(t));}function g(f){let m=(0, De._)`${f}.errors`;s.assign(or.default.vErrors,(0, De._)`${or.default.vErrors} === null ? ${m} : ${or.default.vErrors}.concat(${m})`),s.assign(or.default.errors,(0, De._)`${or.default.vErrors}.length`);}function v(f){var m;if(!o.opts.unevaluated)return;let b=(m=r?.validate)===null||m===void 0?void 0:m.evaluated;if(o.props!==true)if(b&&!b.dynamicProps)b.props!==void 0&&(o.props=Cn.mergeEvaluated.props(s,b.props,o.props));else {let C=s.var("props",(0, De._)`${f}.evaluated.props`);o.props=Cn.mergeEvaluated.props(s,C,o.props,De.Name);}if(o.items!==true)if(b&&!b.dynamicItems)b.items!==void 0&&(o.items=Cn.mergeEvaluated.items(s,b.items,o.items));else {let C=s.var("items",(0, De._)`${f}.evaluated.items`);o.items=Cn.mergeEvaluated.items(s,C,o.items,De.Name);}}}Bt.callRef=$n;Bt.default=fm;});var pc=O(io=>{Object.defineProperty(io,"__esModule",{value:true});var pm=cc(),mm=fc(),gm=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",pm.default,mm.default];io.default=gm;});var mc=O(co=>{Object.defineProperty(co,"__esModule",{value:true});var En=W(),_t=En.operators,xn={maximum:{okStr:"<=",ok:_t.LTE,fail:_t.GT},minimum:{okStr:">=",ok:_t.GTE,fail:_t.LT},exclusiveMaximum:{okStr:"<",ok:_t.LT,fail:_t.GTE},exclusiveMinimum:{okStr:">",ok:_t.GT,fail:_t.LTE}},hm={message:({keyword:e,schemaCode:t})=>(0, En.str)`must be ${xn[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0, En._)`{comparison: ${xn[e].okStr}, limit: ${t}}`},ym={keyword:Object.keys(xn),type:"number",schemaType:"number",$data:true,error:hm,code(e){let{keyword:t,data:r,schemaCode:n}=e;e.fail$data((0, En._)`${r} ${xn[t].fail} ${n} || isNaN(${r})`);}};co.default=ym;});var gc=O(uo=>{Object.defineProperty(uo,"__esModule",{value:true});var Ir=W(),vm={message:({schemaCode:e})=>(0, Ir.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0, Ir._)`{multipleOf: ${e}}`},Sm={keyword:"multipleOf",type:"number",schemaType:"number",$data:true,error:vm,code(e){let{gen:t,data:r,schemaCode:n,it:s}=e,o=s.opts.multipleOfPrecision,a=t.let("res"),i=o?(0, Ir._)`Math.abs(Math.round(${a}) - ${a}) > 1e-${o}`:(0, Ir._)`${a} !== parseInt(${a})`;e.fail$data((0, Ir._)`(${n} === 0 || (${a} = ${r}/${n}, ${i}))`);}};uo.default=Sm;});var yc=O(lo=>{Object.defineProperty(lo,"__esModule",{value:true});function hc(e){let t=e.length,r=0,n=0,s;for(;n<t;)r++,s=e.charCodeAt(n++),s>=55296&&s<=56319&&n<t&&(s=e.charCodeAt(n),(s&64512)===56320&&n++);return r}lo.default=hc;hc.code='require("ajv/dist/runtime/ucs2length").default';});var vc=O(fo=>{Object.defineProperty(fo,"__esModule",{value:true});var Vt=W(),wm=oe(),km=yc(),bm={message({keyword:e,schemaCode:t}){let r=e==="maxLength"?"more":"fewer";return (0, Vt.str)`must NOT have ${r} than ${t} characters`},params:({schemaCode:e})=>(0, Vt._)`{limit: ${e}}`},Rm={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:true,error:bm,code(e){let{keyword:t,data:r,schemaCode:n,it:s}=e,o=t==="maxLength"?Vt.operators.GT:Vt.operators.LT,a=s.opts.unicode===false?(0, Vt._)`${r}.length`:(0, Vt._)`${(0, wm.useFunc)(e.gen,km.default)}(${r})`;e.fail$data((0, Vt._)`${a} ${o} ${n}`);}};fo.default=Rm;});var Sc=O(po=>{Object.defineProperty(po,"__esModule",{value:true});var _m=Ge(),Cm=oe(),ar=W(),$m={message:({schemaCode:e})=>(0, ar.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0, ar._)`{pattern: ${e}}`},Em={keyword:"pattern",type:"string",schemaType:"string",$data:true,error:$m,code(e){let{gen:t,data:r,$data:n,schema:s,schemaCode:o,it:a}=e,i=a.opts.unicodeRegExp?"u":"";if(n){let{regExp:u}=a.opts.code,c=u.code==="new RegExp"?(0, ar._)`new RegExp`:(0, Cm.useFunc)(t,u),d=t.let("valid");t.try(()=>t.assign(d,(0, ar._)`${c}(${o}, ${i}).test(${r})`),()=>t.assign(d,false)),e.fail$data((0, ar._)`!${d}`);}else {let u=(0, _m.usePattern)(e,s);e.fail$data((0, ar._)`!${u}.test(${r})`);}}};po.default=Em;});var wc=O(mo=>{Object.defineProperty(mo,"__esModule",{value:true});var jr=W(),xm={message({keyword:e,schemaCode:t}){let r=e==="maxProperties"?"more":"fewer";return (0, jr.str)`must NOT have ${r} than ${t} properties`},params:({schemaCode:e})=>(0, jr._)`{limit: ${e}}`},Am={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:true,error:xm,code(e){let{keyword:t,data:r,schemaCode:n}=e,s=t==="maxProperties"?jr.operators.GT:jr.operators.LT;e.fail$data((0, jr._)`Object.keys(${r}).length ${s} ${n}`);}};mo.default=Am;});var kc=O(go=>{Object.defineProperty(go,"__esModule",{value:true});var Or=Ge(),Pr=W(),Tm=oe(),Im={message:({params:{missingProperty:e}})=>(0, Pr.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0, Pr._)`{missingProperty: ${e}}`},jm={keyword:"required",type:"object",schemaType:"array",$data:true,error:Im,code(e){let{gen:t,schema:r,schemaCode:n,data:s,$data:o,it:a}=e,{opts:i}=a;if(!o&&r.length===0)return;let u=r.length>=i.loopRequired;if(a.allErrors?c():d(),i.strictRequired){let v=e.parentSchema.properties,{definedProperties:f}=e.it;for(let m of r)if(v?.[m]===void 0&&!f.has(m)){let b=a.schemaEnv.baseId+a.errSchemaPath,C=`required property "${m}" is not defined at "${b}" (strictRequired)`;(0, Tm.checkStrictMode)(a,C,a.opts.strictRequired);}}function c(){if(u||o)e.block$data(Pr.nil,l);else for(let v of r)(0, Or.checkReportMissingProp)(e,v);}function d(){let v=t.let("missing");if(u||o){let f=t.let("valid",true);e.block$data(f,()=>g(v,f)),e.ok(f);}else t.if((0, Or.checkMissingProp)(e,r,v)),(0, Or.reportMissingProp)(e,v),t.else();}function l(){t.forOf("prop",n,v=>{e.setParams({missingProperty:v}),t.if((0, Or.noPropertyInData)(t,s,v,i.ownProperties),()=>e.error());});}function g(v,f){e.setParams({missingProperty:v}),t.forOf(v,n,()=>{t.assign(f,(0, Or.propertyInData)(t,s,v,i.ownProperties)),t.if((0, Pr.not)(f),()=>{e.error(),t.break();});},Pr.nil);}}};go.default=jm;});var bc=O(ho=>{Object.defineProperty(ho,"__esModule",{value:true});var Nr=W(),Om={message({keyword:e,schemaCode:t}){let r=e==="maxItems"?"more":"fewer";return (0, Nr.str)`must NOT have ${r} than ${t} items`},params:({schemaCode:e})=>(0, Nr._)`{limit: ${e}}`},Pm={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:true,error:Om,code(e){let{keyword:t,data:r,schemaCode:n}=e,s=t==="maxItems"?Nr.operators.GT:Nr.operators.LT;e.fail$data((0, Nr._)`${r}.length ${s} ${n}`);}};ho.default=Pm;});var An=O(yo=>{Object.defineProperty(yo,"__esModule",{value:true});var Rc=Ls();Rc.code='require("ajv/dist/runtime/equal").default';yo.default=Rc;});var _c=O(So=>{Object.defineProperty(So,"__esModule",{value:true});var vo=kr(),Re=W(),Nm=oe(),qm=An(),Fm={message:({params:{i:e,j:t}})=>(0, Re.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0, Re._)`{i: ${e}, j: ${t}}`},Mm={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:true,error:Fm,code(e){let{gen:t,data:r,$data:n,schema:s,parentSchema:o,schemaCode:a,it:i}=e;if(!n&&!s)return;let u=t.let("valid"),c=o.items?(0, vo.getSchemaTypes)(o.items):[];e.block$data(u,d,(0, Re._)`${a} === false`),e.ok(u);function d(){let f=t.let("i",(0, Re._)`${r}.length`),m=t.let("j");e.setParams({i:f,j:m}),t.assign(u,true),t.if((0, Re._)`${f} > 1`,()=>(l()?g:v)(f,m));}function l(){return c.length>0&&!c.some(f=>f==="object"||f==="array")}function g(f,m){let b=t.name("item"),C=(0, vo.checkDataTypes)(c,b,i.opts.strictNumbers,vo.DataType.Wrong),F=t.const("indices",(0, Re._)`{}`);t.for((0, Re._)`;${f}--;`,()=>{t.let(b,(0, Re._)`${r}[${f}]`),t.if(C,(0, Re._)`continue`),c.length>1&&t.if((0, Re._)`typeof ${b} == "string"`,(0, Re._)`${b} += "_"`),t.if((0, Re._)`typeof ${F}[${b}] == "number"`,()=>{t.assign(m,(0, Re._)`${F}[${b}]`),e.error(),t.assign(u,false).break();}).code((0, Re._)`${F}[${b}] = ${f}`);});}function v(f,m){let b=(0, Nm.useFunc)(t,qm.default),C=t.name("outer");t.label(C).for((0, Re._)`;${f}--;`,()=>t.for((0, Re._)`${m} = ${f}; ${m}--;`,()=>t.if((0, Re._)`${b}(${r}[${f}], ${r}[${m}])`,()=>{e.error(),t.assign(u,false).break(C);})));}}};So.default=Mm;});var Cc=O(ko=>{Object.defineProperty(ko,"__esModule",{value:true});var wo=W(),Dm=oe(),Lm=An(),Bm={message:"must be equal to constant",params:({schemaCode:e})=>(0, wo._)`{allowedValue: ${e}}`},Vm={keyword:"const",$data:true,error:Bm,code(e){let{gen:t,data:r,$data:n,schemaCode:s,schema:o}=e;n||o&&typeof o=="object"?e.fail$data((0, wo._)`!${(0, Dm.useFunc)(t,Lm.default)}(${r}, ${s})`):e.fail((0, wo._)`${o} !== ${r}`);}};ko.default=Vm;});var $c=O(bo=>{Object.defineProperty(bo,"__esModule",{value:true});var qr=W(),Um=oe(),Km=An(),Gm={message:"must be equal to one of the allowed values",params:({schemaCode:e})=>(0, qr._)`{allowedValues: ${e}}`},Jm={keyword:"enum",schemaType:"array",$data:true,error:Gm,code(e){let{gen:t,data:r,$data:n,schema:s,schemaCode:o,it:a}=e;if(!n&&s.length===0)throw new Error("enum must have non-empty array");let i=s.length>=a.opts.loopEnum,u,c=()=>u??(u=(0, Um.useFunc)(t,Km.default)),d;if(i||n)d=t.let("valid"),e.block$data(d,l);else {if(!Array.isArray(s))throw new Error("ajv implementation error");let v=t.const("vSchema",o);d=(0, qr.or)(...s.map((f,m)=>g(v,m)));}e.pass(d);function l(){t.assign(d,false),t.forOf("v",o,v=>t.if((0, qr._)`${c()}(${r}, ${v})`,()=>t.assign(d,true).break()));}function g(v,f){let m=s[f];return typeof m=="object"&&m!==null?(0, qr._)`${c()}(${r}, ${v}[${f}])`:(0, qr._)`${r} === ${m}`}}};bo.default=Jm;});var Ec=O(Ro=>{Object.defineProperty(Ro,"__esModule",{value:true});var zm=mc(),Hm=gc(),Wm=vc(),Ym=Sc(),Xm=wc(),Qm=kc(),Zm=bc(),eg=_c(),tg=Cc(),rg=$c(),ng=[zm.default,Hm.default,Wm.default,Ym.default,Xm.default,Qm.default,Zm.default,eg.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},tg.default,rg.default];Ro.default=ng;});var Co=O(Fr=>{Object.defineProperty(Fr,"__esModule",{value:true});Fr.validateAdditionalItems=void 0;var Ut=W(),_o=oe(),sg={message:({params:{len:e}})=>(0, Ut.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0, Ut._)`{limit: ${e}}`},og={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:sg,code(e){let{parentSchema:t,it:r}=e,{items:n}=t;if(!Array.isArray(n)){(0, _o.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}xc(e,n);}};function xc(e,t){let{gen:r,schema:n,data:s,keyword:o,it:a}=e;a.items=true;let i=r.const("len",(0, Ut._)`${s}.length`);if(n===false)e.setParams({len:t.length}),e.pass((0, Ut._)`${i} <= ${t.length}`);else if(typeof n=="object"&&!(0, _o.alwaysValidSchema)(a,n)){let c=r.var("valid",(0, Ut._)`${i} <= ${t.length}`);r.if((0, Ut.not)(c),()=>u(c)),e.ok(c);}function u(c){r.forRange("i",t.length,i,d=>{e.subschema({keyword:o,dataProp:d,dataPropType:_o.Type.Num},c),a.allErrors||r.if((0, Ut.not)(c),()=>r.break());});}}Fr.validateAdditionalItems=xc;Fr.default=og;});var $o=O(Mr=>{Object.defineProperty(Mr,"__esModule",{value:true});Mr.validateTuple=void 0;var Ac=W(),Tn=oe(),ag=Ge(),ig={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){let{schema:t,it:r}=e;if(Array.isArray(t))return Tc(e,"additionalItems",t);r.items=true,!(0, Tn.alwaysValidSchema)(r,t)&&e.ok((0, ag.validateArray)(e));}};function Tc(e,t,r=e.schema){let{gen:n,parentSchema:s,data:o,keyword:a,it:i}=e;d(s),i.opts.unevaluated&&r.length&&i.items!==true&&(i.items=Tn.mergeEvaluated.items(n,r.length,i.items));let u=n.name("valid"),c=n.const("len",(0, Ac._)`${o}.length`);r.forEach((l,g)=>{(0, Tn.alwaysValidSchema)(i,l)||(n.if((0, Ac._)`${c} > ${g}`,()=>e.subschema({keyword:a,schemaProp:g,dataProp:g},u)),e.ok(u));});function d(l){let{opts:g,errSchemaPath:v}=i,f=r.length,m=f===l.minItems&&(f===l.maxItems||l[t]===false);if(g.strictTuples&&!m){let b=`"${a}" is ${f}-tuple, but minItems or maxItems/${t} are not specified or different at path "${v}"`;(0, Tn.checkStrictMode)(i,b,g.strictTuples);}}}Mr.validateTuple=Tc;Mr.default=ig;});var Ic=O(Eo=>{Object.defineProperty(Eo,"__esModule",{value:true});var cg=$o(),ug={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:e=>(0, cg.validateTuple)(e,"items")};Eo.default=ug;});var Oc=O(xo=>{Object.defineProperty(xo,"__esModule",{value:true});var jc=W(),dg=oe(),lg=Ge(),fg=Co(),pg={message:({params:{len:e}})=>(0, jc.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0, jc._)`{limit: ${e}}`},mg={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:pg,code(e){let{schema:t,parentSchema:r,it:n}=e,{prefixItems:s}=r;n.items=true,!(0, dg.alwaysValidSchema)(n,t)&&(s?(0, fg.validateAdditionalItems)(e,s):e.ok((0, lg.validateArray)(e)));}};xo.default=mg;});var Pc=O(Ao=>{Object.defineProperty(Ao,"__esModule",{value:true});var ze=W(),In=oe(),gg={message:({params:{min:e,max:t}})=>t===void 0?(0, ze.str)`must contain at least ${e} valid item(s)`:(0, ze.str)`must contain at least ${e} and no more than ${t} valid item(s)`,params:({params:{min:e,max:t}})=>t===void 0?(0, ze._)`{minContains: ${e}}`:(0, ze._)`{minContains: ${e}, maxContains: ${t}}`},hg={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:true,error:gg,code(e){let{gen:t,schema:r,parentSchema:n,data:s,it:o}=e,a,i,{minContains:u,maxContains:c}=n;o.opts.next?(a=u===void 0?1:u,i=c):a=1;let d=t.const("len",(0, ze._)`${s}.length`);if(e.setParams({min:a,max:i}),i===void 0&&a===0){(0, In.checkStrictMode)(o,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(i!==void 0&&a>i){(0, In.checkStrictMode)(o,'"minContains" > "maxContains" is always invalid'),e.fail();return}if((0, In.alwaysValidSchema)(o,r)){let m=(0, ze._)`${d} >= ${a}`;i!==void 0&&(m=(0, ze._)`${m} && ${d} <= ${i}`),e.pass(m);return}o.items=true;let l=t.name("valid");i===void 0&&a===1?v(l,()=>t.if(l,()=>t.break())):a===0?(t.let(l,true),i!==void 0&&t.if((0, ze._)`${s}.length > 0`,g)):(t.let(l,false),g()),e.result(l,()=>e.reset());function g(){let m=t.name("_valid"),b=t.let("count",0);v(m,()=>t.if(m,()=>f(b)));}function v(m,b){t.forRange("i",0,d,C=>{e.subschema({keyword:"contains",dataProp:C,dataPropType:In.Type.Num,compositeRule:true},m),b();});}function f(m){t.code((0, ze._)`${m}++`),i===void 0?t.if((0, ze._)`${m} >= ${a}`,()=>t.assign(l,true).break()):(t.if((0, ze._)`${m} > ${i}`,()=>t.assign(l,false).break()),a===1?t.assign(l,true):t.if((0, ze._)`${m} >= ${a}`,()=>t.assign(l,true)));}}};Ao.default=hg;});var Fc=O(it=>{Object.defineProperty(it,"__esModule",{value:true});it.validateSchemaDeps=it.validatePropertyDeps=it.error=void 0;var To=W(),yg=oe(),Dr=Ge();it.error={message:({params:{property:e,depsCount:t,deps:r}})=>{let n=t===1?"property":"properties";return (0, To.str)`must have ${n} ${r} when property ${e} is present`},params:({params:{property:e,depsCount:t,deps:r,missingProperty:n}})=>(0, To._)`{property: ${e},
5
+ || ${a} === "boolean" || ${s} === null`).assign(i,(0, J._)`[${s}]`);}}}function Yl({gen:e,parentData:t,parentDataProperty:r},n){e.if((0, J._)`${t} !== undefined`,()=>e.assign((0, J._)`${t}[${r}]`,n));}function Ps(e,t,r,n=er.Correct){let s=n===er.Correct?J.operators.EQ:J.operators.NEQ,o;switch(e){case "null":return (0, J._)`${t} ${s} null`;case "array":o=(0, J._)`Array.isArray(${t})`;break;case "object":o=(0, J._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case "integer":o=a((0, J._)`!(${t} % 1) && !isNaN(${t})`);break;case "number":o=a();break;default:return (0, J._)`typeof ${t} ${s} ${e}`}return n===er.Correct?o:(0, J.not)(o);function a(i=J.nil){return (0, J.and)((0, J._)`typeof ${t} == "number"`,i,r?(0, J._)`isFinite(${t})`:J.nil)}}Ae.checkDataType=Ps;function Ns(e,t,r,n){if(e.length===1)return Ps(e[0],t,r,n);let s,o=(0, oi.toHash)(e);if(o.array&&o.object){let a=(0, J._)`typeof ${t} != "object"`;s=o.null?a:(0, J._)`!${t} || ${a}`,delete o.null,delete o.array,delete o.object;}else s=J.nil;o.number&&delete o.integer;for(let a in o)s=(0, J.and)(s,Ps(a,t,r,n));return s}Ae.checkDataTypes=Ns;var Xl={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e=="string"?(0, J._)`{type: ${e}}`:(0, J._)`{type: ${t}}`};function qs(e){let t=Ql(e);(0, Gl.reportError)(t,Xl);}Ae.reportTypeError=qs;function Ql(e){let{gen:t,data:r,schema:n}=e,s=(0, oi.schemaRefOrVal)(e,n,"type");return {gen:t,keyword:"type",data:r,schema:n.type,schemaCode:s,schemaValue:s,parentSchema:n,params:{},it:e}}});var ui=O(pn=>{Object.defineProperty(pn,"__esModule",{value:true});pn.assignDefaults=void 0;var tr=W(),Zl=ae();function ef(e,t){let{properties:r,items:n}=e.schema;if(t==="object"&&r)for(let s in r)ci(e,s,r[s].default);else t==="array"&&Array.isArray(n)&&n.forEach((s,o)=>ci(e,o,s.default));}pn.assignDefaults=ef;function ci(e,t,r){let{gen:n,compositeRule:s,data:o,opts:a}=e;if(r===void 0)return;let i=(0, tr._)`${o}${(0, tr.getProperty)(t)}`;if(s){(0, Zl.checkStrictMode)(e,`default is ignored for: ${i}`);return}let u=(0, tr._)`${i} === undefined`;a.useDefaults==="empty"&&(u=(0, tr._)`${u} || ${i} === null || ${i} === ""`),n.if(u,(0, tr._)`${i} = ${(0, tr.stringify)(r)}`);}});var He=O(le=>{Object.defineProperty(le,"__esModule",{value:true});le.validateUnion=le.validateArray=le.usePattern=le.callValidateCode=le.schemaProperties=le.allSchemaProperties=le.noPropertyInData=le.propertyInData=le.isOwnProperty=le.hasPropFunc=le.reportMissingProp=le.checkMissingProp=le.checkReportMissingProp=void 0;var ge=W(),Fs=ae(),kt=pt(),tf=ae();function rf(e,t){let{gen:r,data:n,it:s}=e;r.if(Ds(r,n,t,s.opts.ownProperties),()=>{e.setParams({missingProperty:(0, ge._)`${t}`},true),e.error();});}le.checkReportMissingProp=rf;function nf({gen:e,data:t,it:{opts:r}},n,s){return (0, ge.or)(...n.map(o=>(0, ge.and)(Ds(e,t,o,r.ownProperties),(0, ge._)`${s} = ${o}`)))}le.checkMissingProp=nf;function sf(e,t){e.setParams({missingProperty:t},true),e.error();}le.reportMissingProp=sf;function di(e){return e.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0, ge._)`Object.prototype.hasOwnProperty`})}le.hasPropFunc=di;function Ms(e,t,r){return (0, ge._)`${di(e)}.call(${t}, ${r})`}le.isOwnProperty=Ms;function of(e,t,r,n){let s=(0, ge._)`${t}${(0, ge.getProperty)(r)} !== undefined`;return n?(0, ge._)`${s} && ${Ms(e,t,r)}`:s}le.propertyInData=of;function Ds(e,t,r,n){let s=(0, ge._)`${t}${(0, ge.getProperty)(r)} === undefined`;return n?(0, ge.or)(s,(0, ge.not)(Ms(e,t,r))):s}le.noPropertyInData=Ds;function li(e){return e?Object.keys(e).filter(t=>t!=="__proto__"):[]}le.allSchemaProperties=li;function af(e,t){return li(t).filter(r=>!(0, Fs.alwaysValidSchema)(e,t[r]))}le.schemaProperties=af;function cf({schemaCode:e,data:t,it:{gen:r,topSchemaRef:n,schemaPath:s,errorPath:o},it:a},i,u,c){let d=c?(0, ge._)`${e}, ${t}, ${n}${s}`:t,l=[[kt.default.instancePath,(0, ge.strConcat)(kt.default.instancePath,o)],[kt.default.parentData,a.parentData],[kt.default.parentDataProperty,a.parentDataProperty],[kt.default.rootData,kt.default.rootData]];a.opts.dynamicRef&&l.push([kt.default.dynamicAnchors,kt.default.dynamicAnchors]);let g=(0, ge._)`${d}, ${r.object(...l)}`;return u!==ge.nil?(0, ge._)`${i}.call(${u}, ${g})`:(0, ge._)`${i}(${g})`}le.callValidateCode=cf;var uf=(0, ge._)`new RegExp`;function df({gen:e,it:{opts:t}},r){let n=t.unicodeRegExp?"u":"",{regExp:s}=t.code,o=s(r,n);return e.scopeValue("pattern",{key:o.toString(),ref:o,code:(0, ge._)`${s.code==="new RegExp"?uf:(0, tf.useFunc)(e,s)}(${r}, ${n})`})}le.usePattern=df;function lf(e){let{gen:t,data:r,keyword:n,it:s}=e,o=t.name("valid");if(s.allErrors){let i=t.let("valid",true);return a(()=>t.assign(i,false)),i}return t.var(o,true),a(()=>t.break()),o;function a(i){let u=t.const("len",(0, ge._)`${r}.length`);t.forRange("i",0,u,c=>{e.subschema({keyword:n,dataProp:c,dataPropType:Fs.Type.Num},o),t.if((0, ge.not)(o),i);});}}le.validateArray=lf;function ff(e){let{gen:t,schema:r,keyword:n,it:s}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(r.some(u=>(0, Fs.alwaysValidSchema)(s,u))&&!s.opts.unevaluated)return;let a=t.let("valid",false),i=t.name("_valid");t.block(()=>r.forEach((u,c)=>{let d=e.subschema({keyword:n,schemaProp:c,compositeRule:true},i);t.assign(a,(0, ge._)`${a} || ${i}`),e.mergeValidEvaluated(d,i)||t.if((0, ge.not)(a));})),e.result(a,()=>e.reset(),()=>e.error(true));}le.validateUnion=ff;});var mi=O(ot=>{Object.defineProperty(ot,"__esModule",{value:true});ot.validateKeywordUsage=ot.validSchemaType=ot.funcKeywordCode=ot.macroKeywordCode=void 0;var Oe=W(),Dt=pt(),pf=He(),mf=wr();function gf(e,t){let{gen:r,keyword:n,schema:s,parentSchema:o,it:a}=e,i=t.macro.call(a.self,s,o,a),u=pi(r,n,i);a.opts.validateSchema!==false&&a.self.validateSchema(i,true);let c=r.name("valid");e.subschema({schema:i,schemaPath:Oe.nil,errSchemaPath:`${a.errSchemaPath}/${n}`,topSchemaRef:u,compositeRule:true},c),e.pass(c,()=>e.error(true));}ot.macroKeywordCode=gf;function hf(e,t){var r;let{gen:n,keyword:s,schema:o,parentSchema:a,$data:i,it:u}=e;vf(u,t);let c=!i&&t.compile?t.compile.call(u.self,o,a,u):t.validate,d=pi(n,s,c),l=n.let("valid");e.block$data(l,g),e.ok((r=t.valid)!==null&&r!==void 0?r:l);function g(){if(t.errors===false)m(),t.modifying&&fi(e),b(()=>e.error());else {let C=t.async?v():f();t.modifying&&fi(e),b(()=>yf(e,C));}}function v(){let C=n.let("ruleErrs",null);return n.try(()=>m((0, Oe._)`await `),q=>n.assign(l,false).if((0, Oe._)`${q} instanceof ${u.ValidationError}`,()=>n.assign(C,(0, Oe._)`${q}.errors`),()=>n.throw(q))),C}function f(){let C=(0, Oe._)`${d}.errors`;return n.assign(C,null),m(Oe.nil),C}function m(C=t.async?(0, Oe._)`await `:Oe.nil){let q=u.opts.passContext?Dt.default.this:Dt.default.self,_=!("compile"in t&&!i||t.schema===false);n.assign(l,(0, Oe._)`${C}${(0, pf.callValidateCode)(e,d,q,_)}`,t.modifying);}function b(C){var q;n.if((0, Oe.not)((q=t.valid)!==null&&q!==void 0?q:l),C);}}ot.funcKeywordCode=hf;function fi(e){let{gen:t,data:r,it:n}=e;t.if(n.parentData,()=>t.assign(r,(0, Oe._)`${n.parentData}[${n.parentDataProperty}]`));}function yf(e,t){let{gen:r}=e;r.if((0, Oe._)`Array.isArray(${t})`,()=>{r.assign(Dt.default.vErrors,(0, Oe._)`${Dt.default.vErrors} === null ? ${t} : ${Dt.default.vErrors}.concat(${t})`).assign(Dt.default.errors,(0, Oe._)`${Dt.default.vErrors}.length`),(0, mf.extendErrors)(e);},()=>e.error());}function vf({schemaEnv:e},t){if(t.async&&!e.$async)throw new Error("async keyword in sync schema")}function pi(e,t,r){if(r===void 0)throw new Error(`keyword "${t}" failed to compile`);return e.scopeValue("keyword",typeof r=="function"?{ref:r}:{ref:r,code:(0, Oe.stringify)(r)})}function Sf(e,t,r=false){return !t.length||t.some(n=>n==="array"?Array.isArray(e):n==="object"?e&&typeof e=="object"&&!Array.isArray(e):typeof e==n||r&&typeof e>"u")}ot.validSchemaType=Sf;function wf({schema:e,opts:t,self:r,errSchemaPath:n},s,o){if(Array.isArray(s.keyword)?!s.keyword.includes(o):s.keyword!==o)throw new Error("ajv implementation error");let a=s.dependencies;if(a?.some(i=>!Object.prototype.hasOwnProperty.call(e,i)))throw new Error(`parent schema must have dependencies of ${o}: ${a.join(",")}`);if(s.validateSchema&&!s.validateSchema(e[o])){let u=`keyword "${o}" value is invalid at path "${n}": `+r.errorsText(s.validateSchema.errors);if(t.validateSchema==="log")r.logger.error(u);else throw new Error(u)}}ot.validateKeywordUsage=wf;});var hi=O(bt=>{Object.defineProperty(bt,"__esModule",{value:true});bt.extendSubschemaMode=bt.extendSubschemaData=bt.getSubschema=void 0;var at=W(),gi=ae();function kf(e,{keyword:t,schemaProp:r,schema:n,schemaPath:s,errSchemaPath:o,topSchemaRef:a}){if(t!==void 0&&n!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(t!==void 0){let i=e.schema[t];return r===void 0?{schema:i,schemaPath:(0, at._)`${e.schemaPath}${(0, at.getProperty)(t)}`,errSchemaPath:`${e.errSchemaPath}/${t}`}:{schema:i[r],schemaPath:(0, at._)`${e.schemaPath}${(0, at.getProperty)(t)}${(0, at.getProperty)(r)}`,errSchemaPath:`${e.errSchemaPath}/${t}/${(0, gi.escapeFragment)(r)}`}}if(n!==void 0){if(s===void 0||o===void 0||a===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return {schema:n,schemaPath:s,topSchemaRef:a,errSchemaPath:o}}throw new Error('either "keyword" or "schema" must be passed')}bt.getSubschema=kf;function bf(e,t,{dataProp:r,dataPropType:n,data:s,dataTypes:o,propertyName:a}){if(s!==void 0&&r!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');let{gen:i}=t;if(r!==void 0){let{errorPath:c,dataPathArr:d,opts:l}=t,g=i.let("data",(0, at._)`${t.data}${(0, at.getProperty)(r)}`,true);u(g),e.errorPath=(0, at.str)`${c}${(0, gi.getErrorPath)(r,n,l.jsPropertySyntax)}`,e.parentDataProperty=(0, at._)`${r}`,e.dataPathArr=[...d,e.parentDataProperty];}if(s!==void 0){let c=s instanceof at.Name?s:i.let("data",s,true);u(c),a!==void 0&&(e.propertyName=a);}o&&(e.dataTypes=o);function u(c){e.data=c,e.dataLevel=t.dataLevel+1,e.dataTypes=[],t.definedProperties=new Set,e.parentData=t.data,e.dataNames=[...t.dataNames,c];}}bt.extendSubschemaData=bf;function Rf(e,{jtdDiscriminator:t,jtdMetadata:r,compositeRule:n,createErrors:s,allErrors:o}){n!==void 0&&(e.compositeRule=n),s!==void 0&&(e.createErrors=s),o!==void 0&&(e.allErrors=o),e.jtdDiscriminator=t,e.jtdMetadata=r;}bt.extendSubschemaMode=Rf;});var Ls=O((_v,yi)=>{yi.exports=function e(t,r){if(t===r)return true;if(t&&r&&typeof t=="object"&&typeof r=="object"){if(t.constructor!==r.constructor)return false;var n,s,o;if(Array.isArray(t)){if(n=t.length,n!=r.length)return false;for(s=n;s--!==0;)if(!e(t[s],r[s]))return false;return true}if(t.constructor===RegExp)return t.source===r.source&&t.flags===r.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===r.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===r.toString();if(o=Object.keys(t),n=o.length,n!==Object.keys(r).length)return false;for(s=n;s--!==0;)if(!Object.prototype.hasOwnProperty.call(r,o[s]))return false;for(s=n;s--!==0;){var a=o[s];if(!e(t[a],r[a]))return false}return true}return t!==t&&r!==r};});var Si=O((Cv,vi)=>{var Rt=vi.exports=function(e,t,r){typeof t=="function"&&(r=t,t={}),r=t.cb||r;var n=typeof r=="function"?r:r.pre||function(){},s=r.post||function(){};mn(t,n,s,e,"",e);};Rt.keywords={additionalItems:true,items:true,contains:true,additionalProperties:true,propertyNames:true,not:true,if:true,then:true,else:true};Rt.arrayKeywords={items:true,allOf:true,anyOf:true,oneOf:true};Rt.propsKeywords={$defs:true,definitions:true,properties:true,patternProperties:true,dependencies:true};Rt.skipKeywords={default:true,enum:true,const:true,required:true,maximum:true,minimum:true,exclusiveMaximum:true,exclusiveMinimum:true,multipleOf:true,maxLength:true,minLength:true,pattern:true,format:true,maxItems:true,minItems:true,uniqueItems:true,maxProperties:true,minProperties:true};function mn(e,t,r,n,s,o,a,i,u,c){if(n&&typeof n=="object"&&!Array.isArray(n)){t(n,s,o,a,i,u,c);for(var d in n){var l=n[d];if(Array.isArray(l)){if(d in Rt.arrayKeywords)for(var g=0;g<l.length;g++)mn(e,t,r,l[g],s+"/"+d+"/"+g,o,s,d,n,g);}else if(d in Rt.propsKeywords){if(l&&typeof l=="object")for(var v in l)mn(e,t,r,l[v],s+"/"+d+"/"+_f(v),o,s,d,n,v);}else (d in Rt.keywords||e.allKeys&&!(d in Rt.skipKeywords))&&mn(e,t,r,l,s+"/"+d,o,s,d,n);}r(n,s,o,a,i,u,c);}}function _f(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}});var br=O(De=>{Object.defineProperty(De,"__esModule",{value:true});De.getSchemaRefs=De.resolveUrl=De.normalizeId=De._getFullPath=De.getFullPath=De.inlineRef=void 0;var Cf=ae(),$f=Ls(),Ef=Si(),xf=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function Af(e,t=true){return typeof e=="boolean"?true:t===true?!Bs(e):t?wi(e)<=t:false}De.inlineRef=Af;var Tf=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function Bs(e){for(let t in e){if(Tf.has(t))return true;let r=e[t];if(Array.isArray(r)&&r.some(Bs)||typeof r=="object"&&Bs(r))return true}return false}function wi(e){let t=0;for(let r in e){if(r==="$ref")return 1/0;if(t++,!xf.has(r)&&(typeof e[r]=="object"&&(0, Cf.eachItem)(e[r],n=>t+=wi(n)),t===1/0))return 1/0}return t}function ki(e,t="",r){r!==false&&(t=rr(t));let n=e.parse(t);return bi(e,n)}De.getFullPath=ki;function bi(e,t){return e.serialize(t).split("#")[0]+"#"}De._getFullPath=bi;var If=/#\/?$/;function rr(e){return e?e.replace(If,""):""}De.normalizeId=rr;function jf(e,t,r){return r=rr(r),e.resolve(t,r)}De.resolveUrl=jf;var Of=/^[a-z_][-a-z0-9._]*$/i;function Pf(e,t){if(typeof e=="boolean")return {};let{schemaId:r,uriResolver:n}=this.opts,s=rr(e[r]||t),o={"":s},a=ki(n,s,false),i={},u=new Set;return Ef(e,{allKeys:true},(l,g,v,f)=>{if(f===void 0)return;let m=a+g,b=o[f];typeof l[r]=="string"&&(b=C.call(this,l[r])),q.call(this,l.$anchor),q.call(this,l.$dynamicAnchor),o[g]=b;function C(_){let I=this.opts.uriResolver.resolve;if(_=rr(b?I(b,_):_),u.has(_))throw d(_);u.add(_);let S=this.refs[_];return typeof S=="string"&&(S=this.refs[S]),typeof S=="object"?c(l,S.schema,_):_!==rr(m)&&(_[0]==="#"?(c(l,i[_],_),i[_]=l):this.refs[_]=m),_}function q(_){if(typeof _=="string"){if(!Of.test(_))throw new Error(`invalid anchor "${_}"`);C.call(this,`#${_}`);}}}),i;function c(l,g,v){if(g!==void 0&&!$f(l,g))throw d(v)}function d(l){return new Error(`reference "${l}" resolves to more than one schema`)}}De.getSchemaRefs=Pf;});var Cr=O(_t=>{Object.defineProperty(_t,"__esModule",{value:true});_t.getData=_t.KeywordCxt=_t.validateFunctionCode=void 0;var Ei=ri(),Ri=kr(),Us=Os(),gn=kr(),Nf=ui(),_r=mi(),Vs=hi(),M=W(),G=pt(),qf=br(),mt=ae(),Rr=wr();function Ff(e){if(Ti(e)&&(Ii(e),Ai(e))){Lf(e);return}xi(e,()=>(0, Ei.topBoolOrEmptySchema)(e));}_t.validateFunctionCode=Ff;function xi({gen:e,validateName:t,schema:r,schemaEnv:n,opts:s},o){s.code.es5?e.func(t,(0, M._)`${G.default.data}, ${G.default.valCxt}`,n.$async,()=>{e.code((0, M._)`"use strict"; ${_i(r,s)}`),Df(e,s),e.code(o);}):e.func(t,(0, M._)`${G.default.data}, ${Mf(s)}`,n.$async,()=>e.code(_i(r,s)).code(o));}function Mf(e){return (0, M._)`{${G.default.instancePath}="", ${G.default.parentData}, ${G.default.parentDataProperty}, ${G.default.rootData}=${G.default.data}${e.dynamicRef?(0, M._)`, ${G.default.dynamicAnchors}={}`:M.nil}}={}`}function Df(e,t){e.if(G.default.valCxt,()=>{e.var(G.default.instancePath,(0, M._)`${G.default.valCxt}.${G.default.instancePath}`),e.var(G.default.parentData,(0, M._)`${G.default.valCxt}.${G.default.parentData}`),e.var(G.default.parentDataProperty,(0, M._)`${G.default.valCxt}.${G.default.parentDataProperty}`),e.var(G.default.rootData,(0, M._)`${G.default.valCxt}.${G.default.rootData}`),t.dynamicRef&&e.var(G.default.dynamicAnchors,(0, M._)`${G.default.valCxt}.${G.default.dynamicAnchors}`);},()=>{e.var(G.default.instancePath,(0, M._)`""`),e.var(G.default.parentData,(0, M._)`undefined`),e.var(G.default.parentDataProperty,(0, M._)`undefined`),e.var(G.default.rootData,G.default.data),t.dynamicRef&&e.var(G.default.dynamicAnchors,(0, M._)`{}`);});}function Lf(e){let{schema:t,opts:r,gen:n}=e;xi(e,()=>{r.$comment&&t.$comment&&Oi(e),Gf(e),n.let(G.default.vErrors,null),n.let(G.default.errors,0),r.unevaluated&&Bf(e),ji(e),Hf(e);});}function Bf(e){let{gen:t,validateName:r}=e;e.evaluated=t.const("evaluated",(0, M._)`${r}.evaluated`),t.if((0, M._)`${e.evaluated}.dynamicProps`,()=>t.assign((0, M._)`${e.evaluated}.props`,(0, M._)`undefined`)),t.if((0, M._)`${e.evaluated}.dynamicItems`,()=>t.assign((0, M._)`${e.evaluated}.items`,(0, M._)`undefined`));}function _i(e,t){let r=typeof e=="object"&&e[t.schemaId];return r&&(t.code.source||t.code.process)?(0, M._)`/*# sourceURL=${r} */`:M.nil}function Vf(e,t){if(Ti(e)&&(Ii(e),Ai(e))){Uf(e,t);return}(0, Ei.boolOrEmptySchema)(e,t);}function Ai({schema:e,self:t}){if(typeof e=="boolean")return !e;for(let r in e)if(t.RULES.all[r])return true;return false}function Ti(e){return typeof e.schema!="boolean"}function Uf(e,t){let{schema:r,gen:n,opts:s}=e;s.$comment&&r.$comment&&Oi(e),Jf(e),zf(e);let o=n.const("_errs",G.default.errors);ji(e,o),n.var(t,(0, M._)`${o} === ${G.default.errors}`);}function Ii(e){(0, mt.checkUnknownRules)(e),Kf(e);}function ji(e,t){if(e.opts.jtd)return Ci(e,[],false,t);let r=(0, Ri.getSchemaTypes)(e.schema),n=(0, Ri.coerceAndCheckDataType)(e,r);Ci(e,r,!n,t);}function Kf(e){let{schema:t,errSchemaPath:r,opts:n,self:s}=e;t.$ref&&n.ignoreKeywordsWithRef&&(0, mt.schemaHasRulesButRef)(t,s.RULES)&&s.logger.warn(`$ref: keywords ignored in schema at path "${r}"`);}function Gf(e){let{schema:t,opts:r}=e;t.default!==void 0&&r.useDefaults&&r.strictSchema&&(0, mt.checkStrictMode)(e,"default is ignored in the schema root");}function Jf(e){let t=e.schema[e.opts.schemaId];t&&(e.baseId=(0, qf.resolveUrl)(e.opts.uriResolver,e.baseId,t));}function zf(e){if(e.schema.$async&&!e.schemaEnv.$async)throw new Error("async schema in sync schema")}function Oi({gen:e,schemaEnv:t,schema:r,errSchemaPath:n,opts:s}){let o=r.$comment;if(s.$comment===true)e.code((0, M._)`${G.default.self}.logger.log(${o})`);else if(typeof s.$comment=="function"){let a=(0, M.str)`${n}/$comment`,i=e.scopeValue("root",{ref:t.root});e.code((0, M._)`${G.default.self}.opts.$comment(${o}, ${a}, ${i}.schema)`);}}function Hf(e){let{gen:t,schemaEnv:r,validateName:n,ValidationError:s,opts:o}=e;r.$async?t.if((0, M._)`${G.default.errors} === 0`,()=>t.return(G.default.data),()=>t.throw((0, M._)`new ${s}(${G.default.vErrors})`)):(t.assign((0, M._)`${n}.errors`,G.default.vErrors),o.unevaluated&&Wf(e),t.return((0, M._)`${G.default.errors} === 0`));}function Wf({gen:e,evaluated:t,props:r,items:n}){r instanceof M.Name&&e.assign((0, M._)`${t}.props`,r),n instanceof M.Name&&e.assign((0, M._)`${t}.items`,n);}function Ci(e,t,r,n){let{gen:s,schema:o,data:a,allErrors:i,opts:u,self:c}=e,{RULES:d}=c;if(o.$ref&&(u.ignoreKeywordsWithRef||!(0, mt.schemaHasRulesButRef)(o,d))){s.block(()=>Ni(e,"$ref",d.all.$ref.definition));return}u.jtd||Yf(e,t),s.block(()=>{for(let g of d.rules)l(g);l(d.post);});function l(g){(0, Us.shouldUseGroup)(o,g)&&(g.type?(s.if((0, gn.checkDataType)(g.type,a,u.strictNumbers)),$i(e,g),t.length===1&&t[0]===g.type&&r&&(s.else(),(0, gn.reportTypeError)(e)),s.endIf()):$i(e,g),i||s.if((0, M._)`${G.default.errors} === ${n||0}`));}}function $i(e,t){let{gen:r,schema:n,opts:{useDefaults:s}}=e;s&&(0, Nf.assignDefaults)(e,t.type),r.block(()=>{for(let o of t.rules)(0, Us.shouldUseRule)(n,o)&&Ni(e,o.keyword,o.definition,t.type);});}function Yf(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(Xf(e,t),e.opts.allowUnionTypes||Qf(e,t),Zf(e,e.dataTypes));}function Xf(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(r=>{Pi(e.dataTypes,r)||Ks(e,`type "${r}" not allowed by context "${e.dataTypes.join(",")}"`);}),tp(e,t);}}function Qf(e,t){t.length>1&&!(t.length===2&&t.includes("null"))&&Ks(e,"use allowUnionTypes to allow union type keyword");}function Zf(e,t){let r=e.self.RULES.all;for(let n in r){let s=r[n];if(typeof s=="object"&&(0, Us.shouldUseRule)(e.schema,s)){let{type:o}=s.definition;o.length&&!o.some(a=>ep(t,a))&&Ks(e,`missing type "${o.join(",")}" for keyword "${n}"`);}}}function ep(e,t){return e.includes(t)||t==="number"&&e.includes("integer")}function Pi(e,t){return e.includes(t)||t==="integer"&&e.includes("number")}function tp(e,t){let r=[];for(let n of e.dataTypes)Pi(t,n)?r.push(n):t.includes("integer")&&n==="number"&&r.push("integer");e.dataTypes=r;}function Ks(e,t){let r=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${r}" (strictTypes)`,(0, mt.checkStrictMode)(e,t,e.opts.strictTypes);}var hn=class{constructor(t,r,n){if((0, _r.validateKeywordUsage)(t,r,n),this.gen=t.gen,this.allErrors=t.allErrors,this.keyword=n,this.data=t.data,this.schema=t.schema[n],this.$data=r.$data&&t.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0, mt.schemaRefOrVal)(t,this.schema,n,this.$data),this.schemaType=r.schemaType,this.parentSchema=t.schema,this.params={},this.it=t,this.def=r,this.$data)this.schemaCode=t.gen.const("vSchema",qi(this.$data,t));else if(this.schemaCode=this.schemaValue,!(0, _r.validSchemaType)(this.schema,r.schemaType,r.allowUndefined))throw new Error(`${n} value must be ${JSON.stringify(r.schemaType)}`);("code"in r?r.trackErrors:r.errors!==false)&&(this.errsCount=t.gen.const("_errs",G.default.errors));}result(t,r,n){this.failResult((0, M.not)(t),r,n);}failResult(t,r,n){this.gen.if(t),n?n():this.error(),r?(this.gen.else(),r(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else();}pass(t,r){this.failResult((0, M.not)(t),void 0,r);}fail(t){if(t===void 0){this.error(),this.allErrors||this.gen.if(false);return}this.gen.if(t),this.error(),this.allErrors?this.gen.endIf():this.gen.else();}fail$data(t){if(!this.$data)return this.fail(t);let{schemaCode:r}=this;this.fail((0, M._)`${r} !== undefined && (${(0, M.or)(this.invalid$data(),t)})`);}error(t,r,n){if(r){this.setParams(r),this._error(t,n),this.setParams({});return}this._error(t,n);}_error(t,r){(t?Rr.reportExtraError:Rr.reportError)(this,this.def.error,r);}$dataError(){(0, Rr.reportError)(this,this.def.$dataError||Rr.keyword$DataError);}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0, Rr.resetErrorsCount)(this.gen,this.errsCount);}ok(t){this.allErrors||this.gen.if(t);}setParams(t,r){r?Object.assign(this.params,t):this.params=t;}block$data(t,r,n=M.nil){this.gen.block(()=>{this.check$data(t,n),r();});}check$data(t=M.nil,r=M.nil){if(!this.$data)return;let{gen:n,schemaCode:s,schemaType:o,def:a}=this;n.if((0, M.or)((0, M._)`${s} === undefined`,r)),t!==M.nil&&n.assign(t,true),(o.length||a.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),t!==M.nil&&n.assign(t,false)),n.else();}invalid$data(){let{gen:t,schemaCode:r,schemaType:n,def:s,it:o}=this;return (0, M.or)(a(),i());function a(){if(n.length){if(!(r instanceof M.Name))throw new Error("ajv implementation error");let u=Array.isArray(n)?n:[n];return (0, M._)`${(0, gn.checkDataTypes)(u,r,o.opts.strictNumbers,gn.DataType.Wrong)}`}return M.nil}function i(){if(s.validateSchema){let u=t.scopeValue("validate$data",{ref:s.validateSchema});return (0, M._)`!${u}(${r})`}return M.nil}}subschema(t,r){let n=(0, Vs.getSubschema)(this.it,t);(0, Vs.extendSubschemaData)(n,this.it,t),(0, Vs.extendSubschemaMode)(n,t);let s={...this.it,...n,items:void 0,props:void 0};return Vf(s,r),s}mergeEvaluated(t,r){let{it:n,gen:s}=this;n.opts.unevaluated&&(n.props!==true&&t.props!==void 0&&(n.props=mt.mergeEvaluated.props(s,t.props,n.props,r)),n.items!==true&&t.items!==void 0&&(n.items=mt.mergeEvaluated.items(s,t.items,n.items,r)));}mergeValidEvaluated(t,r){let{it:n,gen:s}=this;if(n.opts.unevaluated&&(n.props!==true||n.items!==true))return s.if(r,()=>this.mergeEvaluated(t,M.Name)),true}};_t.KeywordCxt=hn;function Ni(e,t,r,n){let s=new hn(e,r,t);"code"in r?r.code(s,n):s.$data&&r.validate?(0, _r.funcKeywordCode)(s,r):"macro"in r?(0, _r.macroKeywordCode)(s,r):(r.compile||r.validate)&&(0, _r.funcKeywordCode)(s,r);}var rp=/^\/(?:[^~]|~0|~1)*$/,np=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function qi(e,{dataLevel:t,dataNames:r,dataPathArr:n}){let s,o;if(e==="")return G.default.rootData;if(e[0]==="/"){if(!rp.test(e))throw new Error(`Invalid JSON-pointer: ${e}`);s=e,o=G.default.rootData;}else {let c=np.exec(e);if(!c)throw new Error(`Invalid JSON-pointer: ${e}`);let d=+c[1];if(s=c[2],s==="#"){if(d>=t)throw new Error(u("property/index",d));return n[t-d]}if(d>t)throw new Error(u("data",d));if(o=r[t-d],!s)return o}let a=o,i=s.split("/");for(let c of i)c&&(o=(0, M._)`${o}${(0, M.getProperty)((0, mt.unescapeJsonPointer)(c))}`,a=(0, M._)`${a} && ${o}`);return a;function u(c,d){return `Cannot access ${c} ${d} levels up, current level is ${t}`}}_t.getData=qi;});var yn=O(Js=>{Object.defineProperty(Js,"__esModule",{value:true});var Gs=class extends Error{constructor(t){super("validation failed"),this.errors=t,this.ajv=this.validation=true;}};Js.default=Gs;});var $r=O(Ws=>{Object.defineProperty(Ws,"__esModule",{value:true});var zs=br(),Hs=class extends Error{constructor(t,r,n,s){super(s||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0, zs.resolveUrl)(t,r,n),this.missingSchema=(0, zs.normalizeId)((0, zs.getFullPath)(t,this.missingRef));}};Ws.default=Hs;});var Sn=O(We=>{Object.defineProperty(We,"__esModule",{value:true});We.resolveSchema=We.getCompilingSchema=We.resolveRef=We.compileSchema=We.SchemaEnv=void 0;var rt=W(),sp=yn(),Lt=pt(),nt=br(),Fi=ae(),op=Cr(),nr=class{constructor(t){var r;this.refs={},this.dynamicAnchors={};let n;typeof t.schema=="object"&&(n=t.schema),this.schema=t.schema,this.schemaId=t.schemaId,this.root=t.root||this,this.baseId=(r=t.baseId)!==null&&r!==void 0?r:(0, nt.normalizeId)(n?.[t.schemaId||"$id"]),this.schemaPath=t.schemaPath,this.localRefs=t.localRefs,this.meta=t.meta,this.$async=n?.$async,this.refs={};}};We.SchemaEnv=nr;function Xs(e){let t=Mi.call(this,e);if(t)return t;let r=(0, nt.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:n,lines:s}=this.opts.code,{ownProperties:o}=this.opts,a=new rt.CodeGen(this.scope,{es5:n,lines:s,ownProperties:o}),i;e.$async&&(i=a.scopeValue("Error",{ref:sp.default,code:(0, rt._)`require("ajv/dist/runtime/validation_error").default`}));let u=a.scopeName("validate");e.validateName=u;let c={gen:a,allErrors:this.opts.allErrors,data:Lt.default.data,parentData:Lt.default.parentData,parentDataProperty:Lt.default.parentDataProperty,dataNames:[Lt.default.data],dataPathArr:[rt.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:a.scopeValue("schema",this.opts.code.source===true?{ref:e.schema,code:(0, rt.stringify)(e.schema)}:{ref:e.schema}),validateName:u,ValidationError:i,schema:e.schema,schemaEnv:e,rootId:r,baseId:e.baseId||r,schemaPath:rt.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0, rt._)`""`,opts:this.opts,self:this},d;try{this._compilations.add(e),(0,op.validateFunctionCode)(c),a.optimize(this.opts.code.optimize);let l=a.toString();d=`${a.scopeRefs(Lt.default.scope)}return ${l}`,this.opts.code.process&&(d=this.opts.code.process(d,e));let v=new Function(`${Lt.default.self}`,`${Lt.default.scope}`,d)(this,this.scope.get());if(this.scope.value(u,{ref:v}),v.errors=null,v.schema=e.schema,v.schemaEnv=e,e.$async&&(v.$async=!0),this.opts.code.source===!0&&(v.source={validateName:u,validateCode:l,scopeValues:a._values}),this.opts.unevaluated){let{props:f,items:m}=c;v.evaluated={props:f instanceof rt.Name?void 0:f,items:m instanceof rt.Name?void 0:m,dynamicProps:f instanceof rt.Name,dynamicItems:m instanceof rt.Name},v.source&&(v.source.evaluated=(0,rt.stringify)(v.evaluated));}return e.validate=v,e}catch(l){throw delete e.validate,delete e.validateName,d&&this.logger.error("Error compiling schema, function code:",d),l}finally{this._compilations.delete(e);}}We.compileSchema=Xs;function ap(e,t,r){var n;r=(0, nt.resolveUrl)(this.opts.uriResolver,t,r);let s=e.refs[r];if(s)return s;let o=up.call(this,e,r);if(o===void 0){let a=(n=e.localRefs)===null||n===void 0?void 0:n[r],{schemaId:i}=this.opts;a&&(o=new nr({schema:a,schemaId:i,root:e,baseId:t}));}if(o!==void 0)return e.refs[r]=ip.call(this,o)}We.resolveRef=ap;function ip(e){return (0, nt.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:Xs.call(this,e)}function Mi(e){for(let t of this._compilations)if(cp(t,e))return t}We.getCompilingSchema=Mi;function cp(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function up(e,t){let r;for(;typeof(r=this.refs[t])=="string";)t=r;return r||this.schemas[t]||vn.call(this,e,t)}function vn(e,t){let r=this.opts.uriResolver.parse(t),n=(0, nt._getFullPath)(this.opts.uriResolver,r),s=(0, nt.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&n===s)return Ys.call(this,r,e);let o=(0, nt.normalizeId)(n),a=this.refs[o]||this.schemas[o];if(typeof a=="string"){let i=vn.call(this,e,a);return typeof i?.schema!="object"?void 0:Ys.call(this,r,i)}if(typeof a?.schema=="object"){if(a.validate||Xs.call(this,a),o===(0, nt.normalizeId)(t)){let{schema:i}=a,{schemaId:u}=this.opts,c=i[u];return c&&(s=(0, nt.resolveUrl)(this.opts.uriResolver,s,c)),new nr({schema:i,schemaId:u,root:e,baseId:s})}return Ys.call(this,r,a)}}We.resolveSchema=vn;var dp=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function Ys(e,{baseId:t,schema:r,root:n}){var s;if(((s=e.fragment)===null||s===void 0?void 0:s[0])!=="/")return;for(let i of e.fragment.slice(1).split("/")){if(typeof r=="boolean")return;let u=r[(0, Fi.unescapeFragment)(i)];if(u===void 0)return;r=u;let c=typeof r=="object"&&r[this.opts.schemaId];!dp.has(i)&&c&&(t=(0, nt.resolveUrl)(this.opts.uriResolver,t,c));}let o;if(typeof r!="boolean"&&r.$ref&&!(0, Fi.schemaHasRulesButRef)(r,this.RULES)){let i=(0, nt.resolveUrl)(this.opts.uriResolver,t,r.$ref);o=vn.call(this,n,i);}let{schemaId:a}=this.opts;if(o=o||new nr({schema:r,schemaId:a,root:n,baseId:t}),o.schema!==o.root.schema)return o}});var Di=O((Iv,lp)=>{lp.exports={$id:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",description:"Meta-schema for $data reference (JSON AnySchema extension proposal)",type:"object",required:["$data"],properties:{$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},additionalProperties:false};});var Zs=O((jv,Ui)=>{var fp=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),Bi=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);function Qs(e){let t="",r=0,n=0;for(n=0;n<e.length;n++)if(r=e[n].charCodeAt(0),r!==48){if(!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return "";t+=e[n];break}for(n+=1;n<e.length;n++){if(r=e[n].charCodeAt(0),!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return "";t+=e[n];}return t}var pp=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function Li(e){return e.length=0,true}function mp(e,t,r){if(e.length){let n=Qs(e);if(n!=="")t.push(n);else return r.error=true,false;e.length=0;}return true}function gp(e){let t=0,r={error:false,address:"",zone:""},n=[],s=[],o=false,a=false,i=mp;for(let u=0;u<e.length;u++){let c=e[u];if(!(c==="["||c==="]"))if(c===":"){if(o===true&&(a=true),!i(s,n,r))break;if(++t>7){r.error=true;break}u>0&&e[u-1]===":"&&(o=true),n.push(":");continue}else if(c==="%"){if(!i(s,n,r))break;i=Li;}else {s.push(c);continue}}return s.length&&(i===Li?r.zone=s.join(""):a?n.push(s.join("")):n.push(Qs(s))),r.address=n.join(""),r}function Vi(e){if(hp(e,":")<2)return {host:e,isIPV6:false};let t=gp(e);if(t.error)return {host:e,isIPV6:false};{let r=t.address,n=t.address;return t.zone&&(r+="%"+t.zone,n+="%25"+t.zone),{host:r,isIPV6:true,escapedHost:n}}}function hp(e,t){let r=0;for(let n=0;n<e.length;n++)e[n]===t&&r++;return r}function yp(e){let t=e,r=[],n=-1,s=0;for(;s=t.length;){if(s===1){if(t===".")break;if(t==="/"){r.push("/");break}else {r.push(t);break}}else if(s===2){if(t[0]==="."){if(t[1]===".")break;if(t[1]==="/"){t=t.slice(2);continue}}else if(t[0]==="/"&&(t[1]==="."||t[1]==="/")){r.push("/");break}}else if(s===3&&t==="/.."){r.length!==0&&r.pop(),r.push("/");break}if(t[0]==="."){if(t[1]==="."){if(t[2]==="/"){t=t.slice(3);continue}}else if(t[1]==="/"){t=t.slice(2);continue}}else if(t[0]==="/"&&t[1]==="."){if(t[2]==="/"){t=t.slice(2);continue}else if(t[2]==="."&&t[3]==="/"){t=t.slice(3),r.length!==0&&r.pop();continue}}if((n=t.indexOf("/",1))===-1){r.push(t);break}else r.push(t.slice(0,n)),t=t.slice(n);}return r.join("")}function vp(e,t){let r=t!==true?escape:unescape;return e.scheme!==void 0&&(e.scheme=r(e.scheme)),e.userinfo!==void 0&&(e.userinfo=r(e.userinfo)),e.host!==void 0&&(e.host=r(e.host)),e.path!==void 0&&(e.path=r(e.path)),e.query!==void 0&&(e.query=r(e.query)),e.fragment!==void 0&&(e.fragment=r(e.fragment)),e}function Sp(e){let t=[];if(e.userinfo!==void 0&&(t.push(e.userinfo),t.push("@")),e.host!==void 0){let r=unescape(e.host);if(!Bi(r)){let n=Vi(r);n.isIPV6===true?r=`[${n.escapedHost}]`:r=e.host;}t.push(r);}return (typeof e.port=="number"||typeof e.port=="string")&&(t.push(":"),t.push(String(e.port))),t.length?t.join(""):void 0}Ui.exports={nonSimpleDomain:pp,recomposeAuthority:Sp,normalizeComponentEncoding:vp,removeDotSegments:yp,isIPv4:Bi,isUUID:fp,normalizeIPv6:Vi,stringArrayToHexStripped:Qs};});var Hi=O((Ov,zi)=>{var{isUUID:wp}=Zs(),kp=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,bp=["http","https","ws","wss","urn","urn:uuid"];function Rp(e){return bp.indexOf(e)!==-1}function eo(e){return e.secure===true?true:e.secure===false?false:e.scheme?e.scheme.length===3&&(e.scheme[0]==="w"||e.scheme[0]==="W")&&(e.scheme[1]==="s"||e.scheme[1]==="S")&&(e.scheme[2]==="s"||e.scheme[2]==="S"):false}function Ki(e){return e.host||(e.error=e.error||"HTTP URIs must have a host."),e}function Gi(e){let t=String(e.scheme).toLowerCase()==="https";return (e.port===(t?443:80)||e.port==="")&&(e.port=void 0),e.path||(e.path="/"),e}function _p(e){return e.secure=eo(e),e.resourceName=(e.path||"/")+(e.query?"?"+e.query:""),e.path=void 0,e.query=void 0,e}function Cp(e){if((e.port===(eo(e)?443:80)||e.port==="")&&(e.port=void 0),typeof e.secure=="boolean"&&(e.scheme=e.secure?"wss":"ws",e.secure=void 0),e.resourceName){let[t,r]=e.resourceName.split("?");e.path=t&&t!=="/"?t:void 0,e.query=r,e.resourceName=void 0;}return e.fragment=void 0,e}function $p(e,t){if(!e.path)return e.error="URN can not be parsed",e;let r=e.path.match(kp);if(r){let n=t.scheme||e.scheme||"urn";e.nid=r[1].toLowerCase(),e.nss=r[2];let s=`${n}:${t.nid||e.nid}`,o=to(s);e.path=void 0,o&&(e=o.parse(e,t));}else e.error=e.error||"URN can not be parsed.";return e}function Ep(e,t){if(e.nid===void 0)throw new Error("URN without nid cannot be serialized");let r=t.scheme||e.scheme||"urn",n=e.nid.toLowerCase(),s=`${r}:${t.nid||n}`,o=to(s);o&&(e=o.serialize(e,t));let a=e,i=e.nss;return a.path=`${n||t.nid}:${i}`,t.skipEscape=true,a}function xp(e,t){let r=e;return r.uuid=r.nss,r.nss=void 0,!t.tolerant&&(!r.uuid||!wp(r.uuid))&&(r.error=r.error||"UUID is not valid."),r}function Ap(e){let t=e;return t.nss=(e.uuid||"").toLowerCase(),t}var Ji={scheme:"http",domainHost:true,parse:Ki,serialize:Gi},Tp={scheme:"https",domainHost:Ji.domainHost,parse:Ki,serialize:Gi},wn={scheme:"ws",domainHost:true,parse:_p,serialize:Cp},Ip={scheme:"wss",domainHost:wn.domainHost,parse:wn.parse,serialize:wn.serialize},jp={scheme:"urn",parse:$p,serialize:Ep,skipNormalize:true},Op={scheme:"urn:uuid",parse:xp,serialize:Ap,skipNormalize:true},kn={http:Ji,https:Tp,ws:wn,wss:Ip,urn:jp,"urn:uuid":Op};Object.setPrototypeOf(kn,null);function to(e){return e&&(kn[e]||kn[e.toLowerCase()])||void 0}zi.exports={wsIsSecure:eo,SCHEMES:kn,isValidSchemeName:Rp,getSchemeHandler:to};});var Xi=O((Pv,Rn)=>{var{normalizeIPv6:Pp,removeDotSegments:Er,recomposeAuthority:Np,normalizeComponentEncoding:bn,isIPv4:qp,nonSimpleDomain:Fp}=Zs(),{SCHEMES:Mp,getSchemeHandler:Wi}=Hi();function Dp(e,t){return typeof e=="string"?e=it(gt(e,t),t):typeof e=="object"&&(e=gt(it(e,t),t)),e}function Lp(e,t,r){let n=r?Object.assign({scheme:"null"},r):{scheme:"null"},s=Yi(gt(e,n),gt(t,n),n,true);return n.skipEscape=true,it(s,n)}function Yi(e,t,r,n){let s={};return n||(e=gt(it(e,r),r),t=gt(it(t,r),r)),r=r||{},!r.tolerant&&t.scheme?(s.scheme=t.scheme,s.userinfo=t.userinfo,s.host=t.host,s.port=t.port,s.path=Er(t.path||""),s.query=t.query):(t.userinfo!==void 0||t.host!==void 0||t.port!==void 0?(s.userinfo=t.userinfo,s.host=t.host,s.port=t.port,s.path=Er(t.path||""),s.query=t.query):(t.path?(t.path[0]==="/"?s.path=Er(t.path):((e.userinfo!==void 0||e.host!==void 0||e.port!==void 0)&&!e.path?s.path="/"+t.path:e.path?s.path=e.path.slice(0,e.path.lastIndexOf("/")+1)+t.path:s.path=t.path,s.path=Er(s.path)),s.query=t.query):(s.path=e.path,t.query!==void 0?s.query=t.query:s.query=e.query),s.userinfo=e.userinfo,s.host=e.host,s.port=e.port),s.scheme=e.scheme),s.fragment=t.fragment,s}function Bp(e,t,r){return typeof e=="string"?(e=unescape(e),e=it(bn(gt(e,r),true),{...r,skipEscape:true})):typeof e=="object"&&(e=it(bn(e,true),{...r,skipEscape:true})),typeof t=="string"?(t=unescape(t),t=it(bn(gt(t,r),true),{...r,skipEscape:true})):typeof t=="object"&&(t=it(bn(t,true),{...r,skipEscape:true})),e.toLowerCase()===t.toLowerCase()}function it(e,t){let r={host:e.host,scheme:e.scheme,userinfo:e.userinfo,port:e.port,path:e.path,query:e.query,nid:e.nid,nss:e.nss,uuid:e.uuid,fragment:e.fragment,reference:e.reference,resourceName:e.resourceName,secure:e.secure,error:""},n=Object.assign({},t),s=[],o=Wi(n.scheme||r.scheme);o&&o.serialize&&o.serialize(r,n),r.path!==void 0&&(n.skipEscape?r.path=unescape(r.path):(r.path=escape(r.path),r.scheme!==void 0&&(r.path=r.path.split("%3A").join(":")))),n.reference!=="suffix"&&r.scheme&&s.push(r.scheme,":");let a=Np(r);if(a!==void 0&&(n.reference!=="suffix"&&s.push("//"),s.push(a),r.path&&r.path[0]!=="/"&&s.push("/")),r.path!==void 0){let i=r.path;!n.absolutePath&&(!o||!o.absolutePath)&&(i=Er(i)),a===void 0&&i[0]==="/"&&i[1]==="/"&&(i="/%2F"+i.slice(2)),s.push(i);}return r.query!==void 0&&s.push("?",r.query),r.fragment!==void 0&&s.push("#",r.fragment),s.join("")}var Vp=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function gt(e,t){let r=Object.assign({},t),n={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},s=false;r.reference==="suffix"&&(r.scheme?e=r.scheme+":"+e:e="//"+e);let o=e.match(Vp);if(o){if(n.scheme=o[1],n.userinfo=o[3],n.host=o[4],n.port=parseInt(o[5],10),n.path=o[6]||"",n.query=o[7],n.fragment=o[8],isNaN(n.port)&&(n.port=o[5]),n.host)if(qp(n.host)===false){let u=Pp(n.host);n.host=u.host.toLowerCase(),s=u.isIPV6;}else s=true;n.scheme===void 0&&n.userinfo===void 0&&n.host===void 0&&n.port===void 0&&n.query===void 0&&!n.path?n.reference="same-document":n.scheme===void 0?n.reference="relative":n.fragment===void 0?n.reference="absolute":n.reference="uri",r.reference&&r.reference!=="suffix"&&r.reference!==n.reference&&(n.error=n.error||"URI is not a "+r.reference+" reference.");let a=Wi(r.scheme||n.scheme);if(!r.unicodeSupport&&(!a||!a.unicodeSupport)&&n.host&&(r.domainHost||a&&a.domainHost)&&s===false&&Fp(n.host))try{n.host=URL.domainToASCII(n.host.toLowerCase());}catch(i){n.error=n.error||"Host's domain name can not be converted to ASCII: "+i;}(!a||a&&!a.skipNormalize)&&(e.indexOf("%")!==-1&&(n.scheme!==void 0&&(n.scheme=unescape(n.scheme)),n.host!==void 0&&(n.host=unescape(n.host))),n.path&&(n.path=escape(unescape(n.path))),n.fragment&&(n.fragment=encodeURI(decodeURIComponent(n.fragment)))),a&&a.parse&&a.parse(n,r);}else n.error=n.error||"URI can not be parsed.";return n}var ro={SCHEMES:Mp,normalize:Dp,resolve:Lp,resolveComponent:Yi,equal:Bp,serialize:it,parse:gt};Rn.exports=ro;Rn.exports.default=ro;Rn.exports.fastUri=ro;});var Zi=O(no=>{Object.defineProperty(no,"__esModule",{value:true});var Qi=Xi();Qi.code='require("ajv/dist/runtime/uri").default';no.default=Qi;});var ic=O(Ce=>{Object.defineProperty(Ce,"__esModule",{value:true});Ce.CodeGen=Ce.Name=Ce.nil=Ce.stringify=Ce.str=Ce._=Ce.KeywordCxt=void 0;var Up=Cr();Object.defineProperty(Ce,"KeywordCxt",{enumerable:true,get:function(){return Up.KeywordCxt}});var sr=W();Object.defineProperty(Ce,"_",{enumerable:true,get:function(){return sr._}});Object.defineProperty(Ce,"str",{enumerable:true,get:function(){return sr.str}});Object.defineProperty(Ce,"stringify",{enumerable:true,get:function(){return sr.stringify}});Object.defineProperty(Ce,"nil",{enumerable:true,get:function(){return sr.nil}});Object.defineProperty(Ce,"Name",{enumerable:true,get:function(){return sr.Name}});Object.defineProperty(Ce,"CodeGen",{enumerable:true,get:function(){return sr.CodeGen}});var Kp=yn(),sc=$r(),Gp=js(),xr=Sn(),Jp=W(),Ar=br(),_n=kr(),oo=ae(),ec=Di(),zp=Zi(),oc=(e,t)=>new RegExp(e,t);oc.code="new RegExp";var Hp=["removeAdditional","useDefaults","coerceTypes"],Wp=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),Yp={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."},Xp={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},tc=200;function Qp(e){var t,r,n,s,o,a,i,u,c,d,l,g,v,f,m,b,C,q,_,I,S,k,w,p,h;let R=e.strict,E=(t=e.code)===null||t===void 0?void 0:t.optimize,A=E===true||E===void 0?1:E||0,T=(n=(r=e.code)===null||r===void 0?void 0:r.regExp)!==null&&n!==void 0?n:oc,V=(s=e.uriResolver)!==null&&s!==void 0?s:zp.default;return {strictSchema:(a=(o=e.strictSchema)!==null&&o!==void 0?o:R)!==null&&a!==void 0?a:true,strictNumbers:(u=(i=e.strictNumbers)!==null&&i!==void 0?i:R)!==null&&u!==void 0?u:true,strictTypes:(d=(c=e.strictTypes)!==null&&c!==void 0?c:R)!==null&&d!==void 0?d:"log",strictTuples:(g=(l=e.strictTuples)!==null&&l!==void 0?l:R)!==null&&g!==void 0?g:"log",strictRequired:(f=(v=e.strictRequired)!==null&&v!==void 0?v:R)!==null&&f!==void 0?f:false,code:e.code?{...e.code,optimize:A,regExp:T}:{optimize:A,regExp:T},loopRequired:(m=e.loopRequired)!==null&&m!==void 0?m:tc,loopEnum:(b=e.loopEnum)!==null&&b!==void 0?b:tc,meta:(C=e.meta)!==null&&C!==void 0?C:true,messages:(q=e.messages)!==null&&q!==void 0?q:true,inlineRefs:(_=e.inlineRefs)!==null&&_!==void 0?_:true,schemaId:(I=e.schemaId)!==null&&I!==void 0?I:"$id",addUsedSchema:(S=e.addUsedSchema)!==null&&S!==void 0?S:true,validateSchema:(k=e.validateSchema)!==null&&k!==void 0?k:true,validateFormats:(w=e.validateFormats)!==null&&w!==void 0?w:true,unicodeRegExp:(p=e.unicodeRegExp)!==null&&p!==void 0?p:true,int32range:(h=e.int32range)!==null&&h!==void 0?h:true,uriResolver:V}}var Tr=class{constructor(t={}){this.schemas={},this.refs={},this.formats={},this._compilations=new Set,this._loading={},this._cache=new Map,t=this.opts={...t,...Qp(t)};let{es5:r,lines:n}=this.opts.code;this.scope=new Jp.ValueScope({scope:{},prefixes:Wp,es5:r,lines:n}),this.logger=sm(t.logger);let s=t.validateFormats;t.validateFormats=false,this.RULES=(0, Gp.getRules)(),rc.call(this,Yp,t,"NOT SUPPORTED"),rc.call(this,Xp,t,"DEPRECATED","warn"),this._metaOpts=rm.call(this),t.formats&&em.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),t.keywords&&tm.call(this,t.keywords),typeof t.meta=="object"&&this.addMetaSchema(t.meta),Zp.call(this),t.validateFormats=s;}_addVocabularies(){this.addKeyword("$async");}_addDefaultMetaSchema(){let{$data:t,meta:r,schemaId:n}=this.opts,s=ec;n==="id"&&(s={...ec},s.id=s.$id,delete s.$id),r&&t&&this.addMetaSchema(s,s[n],false);}defaultMeta(){let{meta:t,schemaId:r}=this.opts;return this.opts.defaultMeta=typeof t=="object"?t[r]||t:void 0}validate(t,r){let n;if(typeof t=="string"){if(n=this.getSchema(t),!n)throw new Error(`no schema with key or ref "${t}"`)}else n=this.compile(t);let s=n(r);return "$async"in n||(this.errors=n.errors),s}compile(t,r){let n=this._addSchema(t,r);return n.validate||this._compileSchemaEnv(n)}compileAsync(t,r){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");let{loadSchema:n}=this.opts;return s.call(this,t,r);async function s(d,l){await o.call(this,d.$schema);let g=this._addSchema(d,l);return g.validate||a.call(this,g)}async function o(d){d&&!this.getSchema(d)&&await s.call(this,{$ref:d},true);}async function a(d){try{return this._compileSchemaEnv(d)}catch(l){if(!(l instanceof sc.default))throw l;return i.call(this,l),await u.call(this,l.missingSchema),a.call(this,d)}}function i({missingSchema:d,missingRef:l}){if(this.refs[d])throw new Error(`AnySchema ${d} is loaded but ${l} cannot be resolved`)}async function u(d){let l=await c.call(this,d);this.refs[d]||await o.call(this,l.$schema),this.refs[d]||this.addSchema(l,d,r);}async function c(d){let l=this._loading[d];if(l)return l;try{return await(this._loading[d]=n(d))}finally{delete this._loading[d];}}}addSchema(t,r,n,s=this.opts.validateSchema){if(Array.isArray(t)){for(let a of t)this.addSchema(a,void 0,n,s);return this}let o;if(typeof t=="object"){let{schemaId:a}=this.opts;if(o=t[a],o!==void 0&&typeof o!="string")throw new Error(`schema ${a} must be string`)}return r=(0, Ar.normalizeId)(r||o),this._checkUnique(r),this.schemas[r]=this._addSchema(t,n,r,s,true),this}addMetaSchema(t,r,n=this.opts.validateSchema){return this.addSchema(t,r,true,n),this}validateSchema(t,r){if(typeof t=="boolean")return true;let n;if(n=t.$schema,n!==void 0&&typeof n!="string")throw new Error("$schema must be a string");if(n=n||this.opts.defaultMeta||this.defaultMeta(),!n)return this.logger.warn("meta-schema not available"),this.errors=null,true;let s=this.validate(n,t);if(!s&&r){let o="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(o);else throw new Error(o)}return s}getSchema(t){let r;for(;typeof(r=nc.call(this,t))=="string";)t=r;if(r===void 0){let{schemaId:n}=this.opts,s=new xr.SchemaEnv({schema:{},schemaId:n});if(r=xr.resolveSchema.call(this,s,t),!r)return;this.refs[t]=r;}return r.validate||this._compileSchemaEnv(r)}removeSchema(t){if(t instanceof RegExp)return this._removeAllSchemas(this.schemas,t),this._removeAllSchemas(this.refs,t),this;switch(typeof t){case "undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case "string":{let r=nc.call(this,t);return typeof r=="object"&&this._cache.delete(r.schema),delete this.schemas[t],delete this.refs[t],this}case "object":{let r=t;this._cache.delete(r);let n=t[this.opts.schemaId];return n&&(n=(0, Ar.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(t){for(let r of t)this.addKeyword(r);return this}addKeyword(t,r){let n;if(typeof t=="string")n=t,typeof r=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),r.keyword=n);else if(typeof t=="object"&&r===void 0){if(r=t,n=r.keyword,Array.isArray(n)&&!n.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(am.call(this,n,r),!r)return (0, oo.eachItem)(n,o=>so.call(this,o)),this;cm.call(this,r);let s={...r,type:(0, _n.getJSONTypes)(r.type),schemaType:(0, _n.getJSONTypes)(r.schemaType)};return (0, oo.eachItem)(n,s.type.length===0?o=>so.call(this,o,s):o=>s.type.forEach(a=>so.call(this,o,s,a))),this}getKeyword(t){let r=this.RULES.all[t];return typeof r=="object"?r.definition:!!r}removeKeyword(t){let{RULES:r}=this;delete r.keywords[t],delete r.all[t];for(let n of r.rules){let s=n.rules.findIndex(o=>o.keyword===t);s>=0&&n.rules.splice(s,1);}return this}addFormat(t,r){return typeof r=="string"&&(r=new RegExp(r)),this.formats[t]=r,this}errorsText(t=this.errors,{separator:r=", ",dataVar:n="data"}={}){return !t||t.length===0?"No errors":t.map(s=>`${n}${s.instancePath} ${s.message}`).reduce((s,o)=>s+r+o)}$dataMetaSchema(t,r){let n=this.RULES.all;t=JSON.parse(JSON.stringify(t));for(let s of r){let o=s.split("/").slice(1),a=t;for(let i of o)a=a[i];for(let i in n){let u=n[i];if(typeof u!="object")continue;let{$data:c}=u.definition,d=a[i];c&&d&&(a[i]=ac(d));}}return t}_removeAllSchemas(t,r){for(let n in t){let s=t[n];(!r||r.test(n))&&(typeof s=="string"?delete t[n]:s&&!s.meta&&(this._cache.delete(s.schema),delete t[n]));}}_addSchema(t,r,n,s=this.opts.validateSchema,o=this.opts.addUsedSchema){let a,{schemaId:i}=this.opts;if(typeof t=="object")a=t[i];else {if(this.opts.jtd)throw new Error("schema must be object");if(typeof t!="boolean")throw new Error("schema must be object or boolean")}let u=this._cache.get(t);if(u!==void 0)return u;n=(0, Ar.normalizeId)(a||n);let c=Ar.getSchemaRefs.call(this,t,n);return u=new xr.SchemaEnv({schema:t,schemaId:i,meta:r,baseId:n,localRefs:c}),this._cache.set(u.schema,u),o&&!n.startsWith("#")&&(n&&this._checkUnique(n),this.refs[n]=u),s&&this.validateSchema(t,true),u}_checkUnique(t){if(this.schemas[t]||this.refs[t])throw new Error(`schema with key or id "${t}" already exists`)}_compileSchemaEnv(t){if(t.meta?this._compileMetaSchema(t):xr.compileSchema.call(this,t),!t.validate)throw new Error("ajv implementation error");return t.validate}_compileMetaSchema(t){let r=this.opts;this.opts=this._metaOpts;try{xr.compileSchema.call(this,t);}finally{this.opts=r;}}};Tr.ValidationError=Kp.default;Tr.MissingRefError=sc.default;Ce.default=Tr;function rc(e,t,r,n="error"){for(let s in e){let o=s;o in t&&this.logger[n](`${r}: option ${s}. ${e[o]}`);}}function nc(e){return e=(0, Ar.normalizeId)(e),this.schemas[e]||this.refs[e]}function Zp(){let e=this.opts.schemas;if(e)if(Array.isArray(e))this.addSchema(e);else for(let t in e)this.addSchema(e[t],t);}function em(){for(let e in this.opts.formats){let t=this.opts.formats[e];t&&this.addFormat(e,t);}}function tm(e){if(Array.isArray(e)){this.addVocabulary(e);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let t in e){let r=e[t];r.keyword||(r.keyword=t),this.addKeyword(r);}}function rm(){let e={...this.opts};for(let t of Hp)delete e[t];return e}var nm={log(){},warn(){},error(){}};function sm(e){if(e===false)return nm;if(e===void 0)return console;if(e.log&&e.warn&&e.error)return e;throw new Error("logger must implement log, warn and error methods")}var om=/^[a-z_$][a-z0-9_$:-]*$/i;function am(e,t){let{RULES:r}=this;if((0, oo.eachItem)(e,n=>{if(r.keywords[n])throw new Error(`Keyword ${n} is already defined`);if(!om.test(n))throw new Error(`Keyword ${n} has invalid name`)}),!!t&&t.$data&&!("code"in t||"validate"in t))throw new Error('$data keyword must have "code" or "validate" function')}function so(e,t,r){var n;let s=t?.post;if(r&&s)throw new Error('keyword with "post" flag cannot have "type"');let{RULES:o}=this,a=s?o.post:o.rules.find(({type:u})=>u===r);if(a||(a={type:r,rules:[]},o.rules.push(a)),o.keywords[e]=true,!t)return;let i={keyword:e,definition:{...t,type:(0, _n.getJSONTypes)(t.type),schemaType:(0, _n.getJSONTypes)(t.schemaType)}};t.before?im.call(this,a,i,t.before):a.rules.push(i),o.all[e]=i,(n=t.implements)===null||n===void 0||n.forEach(u=>this.addKeyword(u));}function im(e,t,r){let n=e.rules.findIndex(s=>s.keyword===r);n>=0?e.rules.splice(n,0,t):(e.rules.push(t),this.logger.warn(`rule ${r} is not defined`));}function cm(e){let{metaSchema:t}=e;t!==void 0&&(e.$data&&this.opts.$data&&(t=ac(t)),e.validateSchema=this.compile(t,true));}var um={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function ac(e){return {anyOf:[e,um]}}});var cc=O(ao=>{Object.defineProperty(ao,"__esModule",{value:true});var dm={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};ao.default=dm;});var fc=O(Bt=>{Object.defineProperty(Bt,"__esModule",{value:true});Bt.callRef=Bt.getValidate=void 0;var lm=$r(),uc=He(),Le=W(),or=pt(),dc=Sn(),Cn=ae(),fm={keyword:"$ref",schemaType:"string",code(e){let{gen:t,schema:r,it:n}=e,{baseId:s,schemaEnv:o,validateName:a,opts:i,self:u}=n,{root:c}=o;if((r==="#"||r==="#/")&&s===c.baseId)return l();let d=dc.resolveRef.call(u,c,s,r);if(d===void 0)throw new lm.default(n.opts.uriResolver,s,r);if(d instanceof dc.SchemaEnv)return g(d);return v(d);function l(){if(o===c)return $n(e,a,o,o.$async);let f=t.scopeValue("root",{ref:c});return $n(e,(0, Le._)`${f}.validate`,c,c.$async)}function g(f){let m=lc(e,f);$n(e,m,f,f.$async);}function v(f){let m=t.scopeValue("schema",i.code.source===true?{ref:f,code:(0, Le.stringify)(f)}:{ref:f}),b=t.name("valid"),C=e.subschema({schema:f,dataTypes:[],schemaPath:Le.nil,topSchemaRef:m,errSchemaPath:r},b);e.mergeEvaluated(C),e.ok(b);}}};function lc(e,t){let{gen:r}=e;return t.validate?r.scopeValue("validate",{ref:t.validate}):(0, Le._)`${r.scopeValue("wrapper",{ref:t})}.validate`}Bt.getValidate=lc;function $n(e,t,r,n){let{gen:s,it:o}=e,{allErrors:a,schemaEnv:i,opts:u}=o,c=u.passContext?or.default.this:Le.nil;n?d():l();function d(){if(!i.$async)throw new Error("async schema referenced by sync schema");let f=s.let("valid");s.try(()=>{s.code((0, Le._)`await ${(0, uc.callValidateCode)(e,t,c)}`),v(t),a||s.assign(f,true);},m=>{s.if((0, Le._)`!(${m} instanceof ${o.ValidationError})`,()=>s.throw(m)),g(m),a||s.assign(f,false);}),e.ok(f);}function l(){e.result((0, uc.callValidateCode)(e,t,c),()=>v(t),()=>g(t));}function g(f){let m=(0, Le._)`${f}.errors`;s.assign(or.default.vErrors,(0, Le._)`${or.default.vErrors} === null ? ${m} : ${or.default.vErrors}.concat(${m})`),s.assign(or.default.errors,(0, Le._)`${or.default.vErrors}.length`);}function v(f){var m;if(!o.opts.unevaluated)return;let b=(m=r?.validate)===null||m===void 0?void 0:m.evaluated;if(o.props!==true)if(b&&!b.dynamicProps)b.props!==void 0&&(o.props=Cn.mergeEvaluated.props(s,b.props,o.props));else {let C=s.var("props",(0, Le._)`${f}.evaluated.props`);o.props=Cn.mergeEvaluated.props(s,C,o.props,Le.Name);}if(o.items!==true)if(b&&!b.dynamicItems)b.items!==void 0&&(o.items=Cn.mergeEvaluated.items(s,b.items,o.items));else {let C=s.var("items",(0, Le._)`${f}.evaluated.items`);o.items=Cn.mergeEvaluated.items(s,C,o.items,Le.Name);}}}Bt.callRef=$n;Bt.default=fm;});var pc=O(io=>{Object.defineProperty(io,"__esModule",{value:true});var pm=cc(),mm=fc(),gm=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",pm.default,mm.default];io.default=gm;});var mc=O(co=>{Object.defineProperty(co,"__esModule",{value:true});var En=W(),Ct=En.operators,xn={maximum:{okStr:"<=",ok:Ct.LTE,fail:Ct.GT},minimum:{okStr:">=",ok:Ct.GTE,fail:Ct.LT},exclusiveMaximum:{okStr:"<",ok:Ct.LT,fail:Ct.GTE},exclusiveMinimum:{okStr:">",ok:Ct.GT,fail:Ct.LTE}},hm={message:({keyword:e,schemaCode:t})=>(0, En.str)`must be ${xn[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0, En._)`{comparison: ${xn[e].okStr}, limit: ${t}}`},ym={keyword:Object.keys(xn),type:"number",schemaType:"number",$data:true,error:hm,code(e){let{keyword:t,data:r,schemaCode:n}=e;e.fail$data((0, En._)`${r} ${xn[t].fail} ${n} || isNaN(${r})`);}};co.default=ym;});var gc=O(uo=>{Object.defineProperty(uo,"__esModule",{value:true});var Ir=W(),vm={message:({schemaCode:e})=>(0, Ir.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0, Ir._)`{multipleOf: ${e}}`},Sm={keyword:"multipleOf",type:"number",schemaType:"number",$data:true,error:vm,code(e){let{gen:t,data:r,schemaCode:n,it:s}=e,o=s.opts.multipleOfPrecision,a=t.let("res"),i=o?(0, Ir._)`Math.abs(Math.round(${a}) - ${a}) > 1e-${o}`:(0, Ir._)`${a} !== parseInt(${a})`;e.fail$data((0, Ir._)`(${n} === 0 || (${a} = ${r}/${n}, ${i}))`);}};uo.default=Sm;});var yc=O(lo=>{Object.defineProperty(lo,"__esModule",{value:true});function hc(e){let t=e.length,r=0,n=0,s;for(;n<t;)r++,s=e.charCodeAt(n++),s>=55296&&s<=56319&&n<t&&(s=e.charCodeAt(n),(s&64512)===56320&&n++);return r}lo.default=hc;hc.code='require("ajv/dist/runtime/ucs2length").default';});var vc=O(fo=>{Object.defineProperty(fo,"__esModule",{value:true});var Vt=W(),wm=ae(),km=yc(),bm={message({keyword:e,schemaCode:t}){let r=e==="maxLength"?"more":"fewer";return (0, Vt.str)`must NOT have ${r} than ${t} characters`},params:({schemaCode:e})=>(0, Vt._)`{limit: ${e}}`},Rm={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:true,error:bm,code(e){let{keyword:t,data:r,schemaCode:n,it:s}=e,o=t==="maxLength"?Vt.operators.GT:Vt.operators.LT,a=s.opts.unicode===false?(0, Vt._)`${r}.length`:(0, Vt._)`${(0, wm.useFunc)(e.gen,km.default)}(${r})`;e.fail$data((0, Vt._)`${a} ${o} ${n}`);}};fo.default=Rm;});var Sc=O(po=>{Object.defineProperty(po,"__esModule",{value:true});var _m=He(),Cm=ae(),ar=W(),$m={message:({schemaCode:e})=>(0, ar.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0, ar._)`{pattern: ${e}}`},Em={keyword:"pattern",type:"string",schemaType:"string",$data:true,error:$m,code(e){let{gen:t,data:r,$data:n,schema:s,schemaCode:o,it:a}=e,i=a.opts.unicodeRegExp?"u":"";if(n){let{regExp:u}=a.opts.code,c=u.code==="new RegExp"?(0, ar._)`new RegExp`:(0, Cm.useFunc)(t,u),d=t.let("valid");t.try(()=>t.assign(d,(0, ar._)`${c}(${o}, ${i}).test(${r})`),()=>t.assign(d,false)),e.fail$data((0, ar._)`!${d}`);}else {let u=(0, _m.usePattern)(e,s);e.fail$data((0, ar._)`!${u}.test(${r})`);}}};po.default=Em;});var wc=O(mo=>{Object.defineProperty(mo,"__esModule",{value:true});var jr=W(),xm={message({keyword:e,schemaCode:t}){let r=e==="maxProperties"?"more":"fewer";return (0, jr.str)`must NOT have ${r} than ${t} properties`},params:({schemaCode:e})=>(0, jr._)`{limit: ${e}}`},Am={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:true,error:xm,code(e){let{keyword:t,data:r,schemaCode:n}=e,s=t==="maxProperties"?jr.operators.GT:jr.operators.LT;e.fail$data((0, jr._)`Object.keys(${r}).length ${s} ${n}`);}};mo.default=Am;});var kc=O(go=>{Object.defineProperty(go,"__esModule",{value:true});var Or=He(),Pr=W(),Tm=ae(),Im={message:({params:{missingProperty:e}})=>(0, Pr.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0, Pr._)`{missingProperty: ${e}}`},jm={keyword:"required",type:"object",schemaType:"array",$data:true,error:Im,code(e){let{gen:t,schema:r,schemaCode:n,data:s,$data:o,it:a}=e,{opts:i}=a;if(!o&&r.length===0)return;let u=r.length>=i.loopRequired;if(a.allErrors?c():d(),i.strictRequired){let v=e.parentSchema.properties,{definedProperties:f}=e.it;for(let m of r)if(v?.[m]===void 0&&!f.has(m)){let b=a.schemaEnv.baseId+a.errSchemaPath,C=`required property "${m}" is not defined at "${b}" (strictRequired)`;(0, Tm.checkStrictMode)(a,C,a.opts.strictRequired);}}function c(){if(u||o)e.block$data(Pr.nil,l);else for(let v of r)(0, Or.checkReportMissingProp)(e,v);}function d(){let v=t.let("missing");if(u||o){let f=t.let("valid",true);e.block$data(f,()=>g(v,f)),e.ok(f);}else t.if((0, Or.checkMissingProp)(e,r,v)),(0, Or.reportMissingProp)(e,v),t.else();}function l(){t.forOf("prop",n,v=>{e.setParams({missingProperty:v}),t.if((0, Or.noPropertyInData)(t,s,v,i.ownProperties),()=>e.error());});}function g(v,f){e.setParams({missingProperty:v}),t.forOf(v,n,()=>{t.assign(f,(0, Or.propertyInData)(t,s,v,i.ownProperties)),t.if((0, Pr.not)(f),()=>{e.error(),t.break();});},Pr.nil);}}};go.default=jm;});var bc=O(ho=>{Object.defineProperty(ho,"__esModule",{value:true});var Nr=W(),Om={message({keyword:e,schemaCode:t}){let r=e==="maxItems"?"more":"fewer";return (0, Nr.str)`must NOT have ${r} than ${t} items`},params:({schemaCode:e})=>(0, Nr._)`{limit: ${e}}`},Pm={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:true,error:Om,code(e){let{keyword:t,data:r,schemaCode:n}=e,s=t==="maxItems"?Nr.operators.GT:Nr.operators.LT;e.fail$data((0, Nr._)`${r}.length ${s} ${n}`);}};ho.default=Pm;});var An=O(yo=>{Object.defineProperty(yo,"__esModule",{value:true});var Rc=Ls();Rc.code='require("ajv/dist/runtime/equal").default';yo.default=Rc;});var _c=O(So=>{Object.defineProperty(So,"__esModule",{value:true});var vo=kr(),$e=W(),Nm=ae(),qm=An(),Fm={message:({params:{i:e,j:t}})=>(0, $e.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0, $e._)`{i: ${e}, j: ${t}}`},Mm={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:true,error:Fm,code(e){let{gen:t,data:r,$data:n,schema:s,parentSchema:o,schemaCode:a,it:i}=e;if(!n&&!s)return;let u=t.let("valid"),c=o.items?(0, vo.getSchemaTypes)(o.items):[];e.block$data(u,d,(0, $e._)`${a} === false`),e.ok(u);function d(){let f=t.let("i",(0, $e._)`${r}.length`),m=t.let("j");e.setParams({i:f,j:m}),t.assign(u,true),t.if((0, $e._)`${f} > 1`,()=>(l()?g:v)(f,m));}function l(){return c.length>0&&!c.some(f=>f==="object"||f==="array")}function g(f,m){let b=t.name("item"),C=(0, vo.checkDataTypes)(c,b,i.opts.strictNumbers,vo.DataType.Wrong),q=t.const("indices",(0, $e._)`{}`);t.for((0, $e._)`;${f}--;`,()=>{t.let(b,(0, $e._)`${r}[${f}]`),t.if(C,(0, $e._)`continue`),c.length>1&&t.if((0, $e._)`typeof ${b} == "string"`,(0, $e._)`${b} += "_"`),t.if((0, $e._)`typeof ${q}[${b}] == "number"`,()=>{t.assign(m,(0, $e._)`${q}[${b}]`),e.error(),t.assign(u,false).break();}).code((0, $e._)`${q}[${b}] = ${f}`);});}function v(f,m){let b=(0, Nm.useFunc)(t,qm.default),C=t.name("outer");t.label(C).for((0, $e._)`;${f}--;`,()=>t.for((0, $e._)`${m} = ${f}; ${m}--;`,()=>t.if((0, $e._)`${b}(${r}[${f}], ${r}[${m}])`,()=>{e.error(),t.assign(u,false).break(C);})));}}};So.default=Mm;});var Cc=O(ko=>{Object.defineProperty(ko,"__esModule",{value:true});var wo=W(),Dm=ae(),Lm=An(),Bm={message:"must be equal to constant",params:({schemaCode:e})=>(0, wo._)`{allowedValue: ${e}}`},Vm={keyword:"const",$data:true,error:Bm,code(e){let{gen:t,data:r,$data:n,schemaCode:s,schema:o}=e;n||o&&typeof o=="object"?e.fail$data((0, wo._)`!${(0, Dm.useFunc)(t,Lm.default)}(${r}, ${s})`):e.fail((0, wo._)`${o} !== ${r}`);}};ko.default=Vm;});var $c=O(bo=>{Object.defineProperty(bo,"__esModule",{value:true});var qr=W(),Um=ae(),Km=An(),Gm={message:"must be equal to one of the allowed values",params:({schemaCode:e})=>(0, qr._)`{allowedValues: ${e}}`},Jm={keyword:"enum",schemaType:"array",$data:true,error:Gm,code(e){let{gen:t,data:r,$data:n,schema:s,schemaCode:o,it:a}=e;if(!n&&s.length===0)throw new Error("enum must have non-empty array");let i=s.length>=a.opts.loopEnum,u,c=()=>u??(u=(0, Um.useFunc)(t,Km.default)),d;if(i||n)d=t.let("valid"),e.block$data(d,l);else {if(!Array.isArray(s))throw new Error("ajv implementation error");let v=t.const("vSchema",o);d=(0, qr.or)(...s.map((f,m)=>g(v,m)));}e.pass(d);function l(){t.assign(d,false),t.forOf("v",o,v=>t.if((0, qr._)`${c()}(${r}, ${v})`,()=>t.assign(d,true).break()));}function g(v,f){let m=s[f];return typeof m=="object"&&m!==null?(0, qr._)`${c()}(${r}, ${v}[${f}])`:(0, qr._)`${r} === ${m}`}}};bo.default=Jm;});var Ec=O(Ro=>{Object.defineProperty(Ro,"__esModule",{value:true});var zm=mc(),Hm=gc(),Wm=vc(),Ym=Sc(),Xm=wc(),Qm=kc(),Zm=bc(),eg=_c(),tg=Cc(),rg=$c(),ng=[zm.default,Hm.default,Wm.default,Ym.default,Xm.default,Qm.default,Zm.default,eg.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},tg.default,rg.default];Ro.default=ng;});var Co=O(Fr=>{Object.defineProperty(Fr,"__esModule",{value:true});Fr.validateAdditionalItems=void 0;var Ut=W(),_o=ae(),sg={message:({params:{len:e}})=>(0, Ut.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0, Ut._)`{limit: ${e}}`},og={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:sg,code(e){let{parentSchema:t,it:r}=e,{items:n}=t;if(!Array.isArray(n)){(0, _o.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}xc(e,n);}};function xc(e,t){let{gen:r,schema:n,data:s,keyword:o,it:a}=e;a.items=true;let i=r.const("len",(0, Ut._)`${s}.length`);if(n===false)e.setParams({len:t.length}),e.pass((0, Ut._)`${i} <= ${t.length}`);else if(typeof n=="object"&&!(0, _o.alwaysValidSchema)(a,n)){let c=r.var("valid",(0, Ut._)`${i} <= ${t.length}`);r.if((0, Ut.not)(c),()=>u(c)),e.ok(c);}function u(c){r.forRange("i",t.length,i,d=>{e.subschema({keyword:o,dataProp:d,dataPropType:_o.Type.Num},c),a.allErrors||r.if((0, Ut.not)(c),()=>r.break());});}}Fr.validateAdditionalItems=xc;Fr.default=og;});var $o=O(Mr=>{Object.defineProperty(Mr,"__esModule",{value:true});Mr.validateTuple=void 0;var Ac=W(),Tn=ae(),ag=He(),ig={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){let{schema:t,it:r}=e;if(Array.isArray(t))return Tc(e,"additionalItems",t);r.items=true,!(0, Tn.alwaysValidSchema)(r,t)&&e.ok((0, ag.validateArray)(e));}};function Tc(e,t,r=e.schema){let{gen:n,parentSchema:s,data:o,keyword:a,it:i}=e;d(s),i.opts.unevaluated&&r.length&&i.items!==true&&(i.items=Tn.mergeEvaluated.items(n,r.length,i.items));let u=n.name("valid"),c=n.const("len",(0, Ac._)`${o}.length`);r.forEach((l,g)=>{(0, Tn.alwaysValidSchema)(i,l)||(n.if((0, Ac._)`${c} > ${g}`,()=>e.subschema({keyword:a,schemaProp:g,dataProp:g},u)),e.ok(u));});function d(l){let{opts:g,errSchemaPath:v}=i,f=r.length,m=f===l.minItems&&(f===l.maxItems||l[t]===false);if(g.strictTuples&&!m){let b=`"${a}" is ${f}-tuple, but minItems or maxItems/${t} are not specified or different at path "${v}"`;(0, Tn.checkStrictMode)(i,b,g.strictTuples);}}}Mr.validateTuple=Tc;Mr.default=ig;});var Ic=O(Eo=>{Object.defineProperty(Eo,"__esModule",{value:true});var cg=$o(),ug={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:e=>(0, cg.validateTuple)(e,"items")};Eo.default=ug;});var Oc=O(xo=>{Object.defineProperty(xo,"__esModule",{value:true});var jc=W(),dg=ae(),lg=He(),fg=Co(),pg={message:({params:{len:e}})=>(0, jc.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0, jc._)`{limit: ${e}}`},mg={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:pg,code(e){let{schema:t,parentSchema:r,it:n}=e,{prefixItems:s}=r;n.items=true,!(0, dg.alwaysValidSchema)(n,t)&&(s?(0, fg.validateAdditionalItems)(e,s):e.ok((0, lg.validateArray)(e)));}};xo.default=mg;});var Pc=O(Ao=>{Object.defineProperty(Ao,"__esModule",{value:true});var Ye=W(),In=ae(),gg={message:({params:{min:e,max:t}})=>t===void 0?(0, Ye.str)`must contain at least ${e} valid item(s)`:(0, Ye.str)`must contain at least ${e} and no more than ${t} valid item(s)`,params:({params:{min:e,max:t}})=>t===void 0?(0, Ye._)`{minContains: ${e}}`:(0, Ye._)`{minContains: ${e}, maxContains: ${t}}`},hg={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:true,error:gg,code(e){let{gen:t,schema:r,parentSchema:n,data:s,it:o}=e,a,i,{minContains:u,maxContains:c}=n;o.opts.next?(a=u===void 0?1:u,i=c):a=1;let d=t.const("len",(0, Ye._)`${s}.length`);if(e.setParams({min:a,max:i}),i===void 0&&a===0){(0, In.checkStrictMode)(o,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(i!==void 0&&a>i){(0, In.checkStrictMode)(o,'"minContains" > "maxContains" is always invalid'),e.fail();return}if((0, In.alwaysValidSchema)(o,r)){let m=(0, Ye._)`${d} >= ${a}`;i!==void 0&&(m=(0, Ye._)`${m} && ${d} <= ${i}`),e.pass(m);return}o.items=true;let l=t.name("valid");i===void 0&&a===1?v(l,()=>t.if(l,()=>t.break())):a===0?(t.let(l,true),i!==void 0&&t.if((0, Ye._)`${s}.length > 0`,g)):(t.let(l,false),g()),e.result(l,()=>e.reset());function g(){let m=t.name("_valid"),b=t.let("count",0);v(m,()=>t.if(m,()=>f(b)));}function v(m,b){t.forRange("i",0,d,C=>{e.subschema({keyword:"contains",dataProp:C,dataPropType:In.Type.Num,compositeRule:true},m),b();});}function f(m){t.code((0, Ye._)`${m}++`),i===void 0?t.if((0, Ye._)`${m} >= ${a}`,()=>t.assign(l,true).break()):(t.if((0, Ye._)`${m} > ${i}`,()=>t.assign(l,false).break()),a===1?t.assign(l,true):t.if((0, Ye._)`${m} >= ${a}`,()=>t.assign(l,true)));}}};Ao.default=hg;});var Fc=O(ct=>{Object.defineProperty(ct,"__esModule",{value:true});ct.validateSchemaDeps=ct.validatePropertyDeps=ct.error=void 0;var To=W(),yg=ae(),Dr=He();ct.error={message:({params:{property:e,depsCount:t,deps:r}})=>{let n=t===1?"property":"properties";return (0, To.str)`must have ${n} ${r} when property ${e} is present`},params:({params:{property:e,depsCount:t,deps:r,missingProperty:n}})=>(0, To._)`{property: ${e},
6
6
  missingProperty: ${n},
7
7
  depsCount: ${t},
8
- deps: ${r}}`};var vg={keyword:"dependencies",type:"object",schemaType:"object",error:it.error,code(e){let[t,r]=Sg(e);Nc(e,t),qc(e,r);}};function Sg({schema:e}){let t={},r={};for(let n in e){if(n==="__proto__")continue;let s=Array.isArray(e[n])?t:r;s[n]=e[n];}return [t,r]}function Nc(e,t=e.schema){let{gen:r,data:n,it:s}=e;if(Object.keys(t).length===0)return;let o=r.let("missing");for(let a in t){let i=t[a];if(i.length===0)continue;let u=(0, Dr.propertyInData)(r,n,a,s.opts.ownProperties);e.setParams({property:a,depsCount:i.length,deps:i.join(", ")}),s.allErrors?r.if(u,()=>{for(let c of i)(0, Dr.checkReportMissingProp)(e,c);}):(r.if((0, To._)`${u} && (${(0, Dr.checkMissingProp)(e,i,o)})`),(0, Dr.reportMissingProp)(e,o),r.else());}}it.validatePropertyDeps=Nc;function qc(e,t=e.schema){let{gen:r,data:n,keyword:s,it:o}=e,a=r.name("valid");for(let i in t)(0, yg.alwaysValidSchema)(o,t[i])||(r.if((0, Dr.propertyInData)(r,n,i,o.opts.ownProperties),()=>{let u=e.subschema({keyword:s,schemaProp:i},a);e.mergeValidEvaluated(u,a);},()=>r.var(a,true)),e.ok(a));}it.validateSchemaDeps=qc;it.default=vg;});var Dc=O(Io=>{Object.defineProperty(Io,"__esModule",{value:true});var Mc=W(),wg=oe(),kg={message:"property name must be valid",params:({params:e})=>(0, Mc._)`{propertyName: ${e.propertyName}}`},bg={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:kg,code(e){let{gen:t,schema:r,data:n,it:s}=e;if((0, wg.alwaysValidSchema)(s,r))return;let o=t.name("valid");t.forIn("key",n,a=>{e.setParams({propertyName:a}),e.subschema({keyword:"propertyNames",data:a,dataTypes:["string"],propertyName:a,compositeRule:true},o),t.if((0, Mc.not)(o),()=>{e.error(true),s.allErrors||t.break();});}),e.ok(o);}};Io.default=bg;});var Oo=O(jo=>{Object.defineProperty(jo,"__esModule",{value:true});var jn=Ge(),tt=W(),Rg=ft(),On=oe(),_g={message:"must NOT have additional properties",params:({params:e})=>(0, tt._)`{additionalProperty: ${e.additionalProperty}}`},Cg={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:true,trackErrors:true,error:_g,code(e){let{gen:t,schema:r,parentSchema:n,data:s,errsCount:o,it:a}=e;if(!o)throw new Error("ajv implementation error");let{allErrors:i,opts:u}=a;if(a.props=true,u.removeAdditional!=="all"&&(0, On.alwaysValidSchema)(a,r))return;let c=(0, jn.allSchemaProperties)(n.properties),d=(0, jn.allSchemaProperties)(n.patternProperties);l(),e.ok((0, tt._)`${o} === ${Rg.default.errors}`);function l(){t.forIn("key",s,b=>{!c.length&&!d.length?f(b):t.if(g(b),()=>f(b));});}function g(b){let C;if(c.length>8){let F=(0, On.schemaRefOrVal)(a,n.properties,"properties");C=(0, jn.isOwnProperty)(t,F,b);}else c.length?C=(0, tt.or)(...c.map(F=>(0, tt._)`${b} === ${F}`)):C=tt.nil;return d.length&&(C=(0, tt.or)(C,...d.map(F=>(0, tt._)`${(0, jn.usePattern)(e,F)}.test(${b})`))),(0, tt.not)(C)}function v(b){t.code((0, tt._)`delete ${s}[${b}]`);}function f(b){if(u.removeAdditional==="all"||u.removeAdditional&&r===false){v(b);return}if(r===false){e.setParams({additionalProperty:b}),e.error(),i||t.break();return}if(typeof r=="object"&&!(0, On.alwaysValidSchema)(a,r)){let C=t.name("valid");u.removeAdditional==="failing"?(m(b,C,false),t.if((0, tt.not)(C),()=>{e.reset(),v(b);})):(m(b,C),i||t.if((0, tt.not)(C),()=>t.break()));}}function m(b,C,F){let _={keyword:"additionalProperties",dataProp:b,dataPropType:On.Type.Str};F===false&&Object.assign(_,{compositeRule:true,createErrors:false,allErrors:false}),e.subschema(_,C);}}};jo.default=Cg;});var Vc=O(No=>{Object.defineProperty(No,"__esModule",{value:true});var $g=Cr(),Lc=Ge(),Po=oe(),Bc=Oo(),Eg={keyword:"properties",type:"object",schemaType:"object",code(e){let{gen:t,schema:r,parentSchema:n,data:s,it:o}=e;o.opts.removeAdditional==="all"&&n.additionalProperties===void 0&&Bc.default.code(new $g.KeywordCxt(o,Bc.default,"additionalProperties"));let a=(0, Lc.allSchemaProperties)(r);for(let l of a)o.definedProperties.add(l);o.opts.unevaluated&&a.length&&o.props!==true&&(o.props=Po.mergeEvaluated.props(t,(0, Po.toHash)(a),o.props));let i=a.filter(l=>!(0, Po.alwaysValidSchema)(o,r[l]));if(i.length===0)return;let u=t.name("valid");for(let l of i)c(l)?d(l):(t.if((0, Lc.propertyInData)(t,s,l,o.opts.ownProperties)),d(l),o.allErrors||t.else().var(u,true),t.endIf()),e.it.definedProperties.add(l),e.ok(u);function c(l){return o.opts.useDefaults&&!o.compositeRule&&r[l].default!==void 0}function d(l){e.subschema({keyword:"properties",schemaProp:l,dataProp:l},u);}}};No.default=Eg;});var Jc=O(qo=>{Object.defineProperty(qo,"__esModule",{value:true});var Uc=Ge(),Pn=W(),Kc=oe(),Gc=oe(),xg={keyword:"patternProperties",type:"object",schemaType:"object",code(e){let{gen:t,schema:r,data:n,parentSchema:s,it:o}=e,{opts:a}=o,i=(0, Uc.allSchemaProperties)(r),u=i.filter(m=>(0, Kc.alwaysValidSchema)(o,r[m]));if(i.length===0||u.length===i.length&&(!o.opts.unevaluated||o.props===true))return;let c=a.strictSchema&&!a.allowMatchingProperties&&s.properties,d=t.name("valid");o.props!==true&&!(o.props instanceof Pn.Name)&&(o.props=(0, Gc.evaluatedPropsToName)(t,o.props));let{props:l}=o;g();function g(){for(let m of i)c&&v(m),o.allErrors?f(m):(t.var(d,true),f(m),t.if(d));}function v(m){for(let b in c)new RegExp(m).test(b)&&(0, Kc.checkStrictMode)(o,`property ${b} matches pattern ${m} (use allowMatchingProperties)`);}function f(m){t.forIn("key",n,b=>{t.if((0, Pn._)`${(0, Uc.usePattern)(e,m)}.test(${b})`,()=>{let C=u.includes(m);C||e.subschema({keyword:"patternProperties",schemaProp:m,dataProp:b,dataPropType:Gc.Type.Str},d),o.opts.unevaluated&&l!==true?t.assign((0, Pn._)`${l}[${b}]`,true):!C&&!o.allErrors&&t.if((0, Pn.not)(d),()=>t.break());});});}}};qo.default=xg;});var zc=O(Fo=>{Object.defineProperty(Fo,"__esModule",{value:true});var Ag=oe(),Tg={keyword:"not",schemaType:["object","boolean"],trackErrors:true,code(e){let{gen:t,schema:r,it:n}=e;if((0, Ag.alwaysValidSchema)(n,r)){e.fail();return}let s=t.name("valid");e.subschema({keyword:"not",compositeRule:true,createErrors:false,allErrors:false},s),e.failResult(s,()=>e.reset(),()=>e.error());},error:{message:"must NOT be valid"}};Fo.default=Tg;});var Hc=O(Mo=>{Object.defineProperty(Mo,"__esModule",{value:true});var Ig=Ge(),jg={keyword:"anyOf",schemaType:"array",trackErrors:true,code:Ig.validateUnion,error:{message:"must match a schema in anyOf"}};Mo.default=jg;});var Wc=O(Do=>{Object.defineProperty(Do,"__esModule",{value:true});var Nn=W(),Og=oe(),Pg={message:"must match exactly one schema in oneOf",params:({params:e})=>(0, Nn._)`{passingSchemas: ${e.passing}}`},Ng={keyword:"oneOf",schemaType:"array",trackErrors:true,error:Pg,code(e){let{gen:t,schema:r,parentSchema:n,it:s}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(s.opts.discriminator&&n.discriminator)return;let o=r,a=t.let("valid",false),i=t.let("passing",null),u=t.name("_valid");e.setParams({passing:i}),t.block(c),e.result(a,()=>e.reset(),()=>e.error(true));function c(){o.forEach((d,l)=>{let g;(0, Og.alwaysValidSchema)(s,d)?t.var(u,true):g=e.subschema({keyword:"oneOf",schemaProp:l,compositeRule:true},u),l>0&&t.if((0, Nn._)`${u} && ${a}`).assign(a,false).assign(i,(0, Nn._)`[${i}, ${l}]`).else(),t.if(u,()=>{t.assign(a,true),t.assign(i,l),g&&e.mergeEvaluated(g,Nn.Name);});});}}};Do.default=Ng;});var Yc=O(Lo=>{Object.defineProperty(Lo,"__esModule",{value:true});var qg=oe(),Fg={keyword:"allOf",schemaType:"array",code(e){let{gen:t,schema:r,it:n}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");let s=t.name("valid");r.forEach((o,a)=>{if((0, qg.alwaysValidSchema)(n,o))return;let i=e.subschema({keyword:"allOf",schemaProp:a},s);e.ok(s),e.mergeEvaluated(i);});}};Lo.default=Fg;});var Zc=O(Bo=>{Object.defineProperty(Bo,"__esModule",{value:true});var qn=W(),Qc=oe(),Mg={message:({params:e})=>(0, qn.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0, qn._)`{failingKeyword: ${e.ifClause}}`},Dg={keyword:"if",schemaType:["object","boolean"],trackErrors:true,error:Mg,code(e){let{gen:t,parentSchema:r,it:n}=e;r.then===void 0&&r.else===void 0&&(0, Qc.checkStrictMode)(n,'"if" without "then" and "else" is ignored');let s=Xc(n,"then"),o=Xc(n,"else");if(!s&&!o)return;let a=t.let("valid",true),i=t.name("_valid");if(u(),e.reset(),s&&o){let d=t.let("ifClause");e.setParams({ifClause:d}),t.if(i,c("then",d),c("else",d));}else s?t.if(i,c("then")):t.if((0, qn.not)(i),c("else"));e.pass(a,()=>e.error(true));function u(){let d=e.subschema({keyword:"if",compositeRule:true,createErrors:false,allErrors:false},i);e.mergeEvaluated(d);}function c(d,l){return ()=>{let g=e.subschema({keyword:d},i);t.assign(a,i),e.mergeValidEvaluated(g,a),l?t.assign(l,(0, qn._)`${d}`):e.setParams({ifClause:d});}}}};function Xc(e,t){let r=e.schema[t];return r!==void 0&&!(0, Qc.alwaysValidSchema)(e,r)}Bo.default=Dg;});var eu=O(Vo=>{Object.defineProperty(Vo,"__esModule",{value:true});var Lg=oe(),Bg={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:r}){t.if===void 0&&(0, Lg.checkStrictMode)(r,`"${e}" without "if" is ignored`);}};Vo.default=Bg;});var tu=O(Uo=>{Object.defineProperty(Uo,"__esModule",{value:true});var Vg=Co(),Ug=Ic(),Kg=$o(),Gg=Oc(),Jg=Pc(),zg=Fc(),Hg=Dc(),Wg=Oo(),Yg=Vc(),Xg=Jc(),Qg=zc(),Zg=Hc(),eh=Wc(),th=Yc(),rh=Zc(),nh=eu();function sh(e=false){let t=[Qg.default,Zg.default,eh.default,th.default,rh.default,nh.default,Hg.default,Wg.default,zg.default,Yg.default,Xg.default];return e?t.push(Ug.default,Gg.default):t.push(Vg.default,Kg.default),t.push(Jg.default),t}Uo.default=sh;});var ru=O(Ko=>{Object.defineProperty(Ko,"__esModule",{value:true});var ve=W(),oh={message:({schemaCode:e})=>(0, ve.str)`must match format "${e}"`,params:({schemaCode:e})=>(0, ve._)`{format: ${e}}`},ah={keyword:"format",type:["number","string"],schemaType:"string",$data:true,error:oh,code(e,t){let{gen:r,data:n,$data:s,schema:o,schemaCode:a,it:i}=e,{opts:u,errSchemaPath:c,schemaEnv:d,self:l}=i;if(!u.validateFormats)return;s?g():v();function g(){let f=r.scopeValue("formats",{ref:l.formats,code:u.code.formats}),m=r.const("fDef",(0, ve._)`${f}[${a}]`),b=r.let("fType"),C=r.let("format");r.if((0, ve._)`typeof ${m} == "object" && !(${m} instanceof RegExp)`,()=>r.assign(b,(0, ve._)`${m}.type || "string"`).assign(C,(0, ve._)`${m}.validate`),()=>r.assign(b,(0, ve._)`"string"`).assign(C,m)),e.fail$data((0, ve.or)(F(),_()));function F(){return u.strictSchema===false?ve.nil:(0, ve._)`${a} && !${C}`}function _(){let I=d.$async?(0, ve._)`(${m}.async ? await ${C}(${n}) : ${C}(${n}))`:(0, ve._)`${C}(${n})`,S=(0, ve._)`(typeof ${C} == "function" ? ${I} : ${C}.test(${n}))`;return (0, ve._)`${C} && ${C} !== true && ${b} === ${t} && !${S}`}}function v(){let f=l.formats[o];if(!f){F();return}if(f===true)return;let[m,b,C]=_(f);m===t&&e.pass(I());function F(){if(u.strictSchema===false){l.logger.warn(S());return}throw new Error(S());function S(){return `unknown format "${o}" ignored in schema at path "${c}"`}}function _(S){let k=S instanceof RegExp?(0, ve.regexpCode)(S):u.code.formats?(0, ve._)`${u.code.formats}${(0, ve.getProperty)(o)}`:void 0,w=r.scopeValue("formats",{key:o,ref:S,code:k});return typeof S=="object"&&!(S instanceof RegExp)?[S.type||"string",S.validate,(0, ve._)`${w}.validate`]:["string",S,w]}function I(){if(typeof f=="object"&&!(f instanceof RegExp)&&f.async){if(!d.$async)throw new Error("async format in sync schema");return (0, ve._)`await ${C}(${n})`}return typeof b=="function"?(0, ve._)`${C}(${n})`:(0, ve._)`${C}.test(${n})`}}}};Ko.default=ah;});var nu=O(Go=>{Object.defineProperty(Go,"__esModule",{value:true});var ih=ru(),ch=[ih.default];Go.default=ch;});var su=O(ir=>{Object.defineProperty(ir,"__esModule",{value:true});ir.contentVocabulary=ir.metadataVocabulary=void 0;ir.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];ir.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"];});var au=O(Jo=>{Object.defineProperty(Jo,"__esModule",{value:true});var uh=pc(),dh=Ec(),lh=tu(),fh=nu(),ou=su(),ph=[uh.default,dh.default,(0, lh.default)(),fh.default,ou.metadataVocabulary,ou.contentVocabulary];Jo.default=ph;});var cu=O(Fn=>{Object.defineProperty(Fn,"__esModule",{value:true});Fn.DiscrError=void 0;var iu;(function(e){e.Tag="tag",e.Mapping="mapping";})(iu||(Fn.DiscrError=iu={}));});var du=O(Ho=>{Object.defineProperty(Ho,"__esModule",{value:true});var cr=W(),zo=cu(),uu=Sn(),mh=$r(),gh=oe(),hh={message:({params:{discrError:e,tagName:t}})=>e===zo.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:r}})=>(0, cr._)`{error: ${e}, tag: ${r}, tagValue: ${t}}`},yh={keyword:"discriminator",type:"object",schemaType:"object",error:hh,code(e){let{gen:t,data:r,schema:n,parentSchema:s,it:o}=e,{oneOf:a}=s;if(!o.opts.discriminator)throw new Error("discriminator: requires discriminator option");let i=n.propertyName;if(typeof i!="string")throw new Error("discriminator: requires propertyName");if(n.mapping)throw new Error("discriminator: mapping is not supported");if(!a)throw new Error("discriminator: requires oneOf keyword");let u=t.let("valid",false),c=t.const("tag",(0, cr._)`${r}${(0, cr.getProperty)(i)}`);t.if((0, cr._)`typeof ${c} == "string"`,()=>d(),()=>e.error(false,{discrError:zo.DiscrError.Tag,tag:c,tagName:i})),e.ok(u);function d(){let v=g();t.if(false);for(let f in v)t.elseIf((0, cr._)`${c} === ${f}`),t.assign(u,l(v[f]));t.else(),e.error(false,{discrError:zo.DiscrError.Mapping,tag:c,tagName:i}),t.endIf();}function l(v){let f=t.name("valid"),m=e.subschema({keyword:"oneOf",schemaProp:v},f);return e.mergeEvaluated(m,cr.Name),f}function g(){var v;let f={},m=C(s),b=true;for(let I=0;I<a.length;I++){let S=a[I];if(S?.$ref&&!(0, gh.schemaHasRulesButRef)(S,o.self.RULES)){let w=S.$ref;if(S=uu.resolveRef.call(o.self,o.schemaEnv.root,o.baseId,w),S instanceof uu.SchemaEnv&&(S=S.schema),S===void 0)throw new mh.default(o.opts.uriResolver,o.baseId,w)}let k=(v=S?.properties)===null||v===void 0?void 0:v[i];if(typeof k!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${i}"`);b=b&&(m||C(S)),F(k,I);}if(!b)throw new Error(`discriminator: "${i}" must be required`);return f;function C({required:I}){return Array.isArray(I)&&I.includes(i)}function F(I,S){if(I.const)_(I.const,S);else if(I.enum)for(let k of I.enum)_(k,S);else throw new Error(`discriminator: "properties/${i}" must have "const" or "enum"`)}function _(I,S){if(typeof I!="string"||I in f)throw new Error(`discriminator: "${i}" values must be unique strings`);f[I]=S;}}}};Ho.default=yh;});var lu=O((bS,vh)=>{vh.exports={$schema:"http://json-schema.org/draft-07/schema#",$id:"http://json-schema.org/draft-07/schema#",title:"Core schema meta-schema",definitions:{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:true,default:[]}},type:["object","boolean"],properties:{$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:true,readOnly:{type:"boolean",default:false},examples:{type:"array",items:true},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:true},maxItems:{$ref:"#/definitions/nonNegativeInteger"},minItems:{$ref:"#/definitions/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:false},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:true,enum:{type:"array",items:true,minItems:1,uniqueItems:true},type:{anyOf:[{$ref:"#/definitions/simpleTypes"},{type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:true}]},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:"#"}},default:true};});var pu=O((he,Wo)=>{Object.defineProperty(he,"__esModule",{value:true});he.MissingRefError=he.ValidationError=he.CodeGen=he.Name=he.nil=he.stringify=he.str=he._=he.KeywordCxt=he.Ajv=void 0;var Sh=ic(),wh=au(),kh=du(),fu=lu(),bh=["/properties"],Mn="http://json-schema.org/draft-07/schema",ur=class extends Sh.default{_addVocabularies(){super._addVocabularies(),wh.default.forEach(t=>this.addVocabulary(t)),this.opts.discriminator&&this.addKeyword(kh.default);}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let t=this.opts.$data?this.$dataMetaSchema(fu,bh):fu;this.addMetaSchema(t,Mn,false),this.refs["http://json-schema.org/schema"]=Mn;}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(Mn)?Mn:void 0)}};he.Ajv=ur;Wo.exports=he=ur;Wo.exports.Ajv=ur;Object.defineProperty(he,"__esModule",{value:true});he.default=ur;var Rh=Cr();Object.defineProperty(he,"KeywordCxt",{enumerable:true,get:function(){return Rh.KeywordCxt}});var dr=W();Object.defineProperty(he,"_",{enumerable:true,get:function(){return dr._}});Object.defineProperty(he,"str",{enumerable:true,get:function(){return dr.str}});Object.defineProperty(he,"stringify",{enumerable:true,get:function(){return dr.stringify}});Object.defineProperty(he,"nil",{enumerable:true,get:function(){return dr.nil}});Object.defineProperty(he,"Name",{enumerable:true,get:function(){return dr.Name}});Object.defineProperty(he,"CodeGen",{enumerable:true,get:function(){return dr.CodeGen}});var _h=yn();Object.defineProperty(he,"ValidationError",{enumerable:true,get:function(){return _h.default}});var Ch=$r();Object.defineProperty(he,"MissingRefError",{enumerable:true,get:function(){return Ch.default}});});var Hr="b64:";function yd(e){let t=new TextEncoder().encode(e),r=globalThis.Buffer,n;if(r)n=r.from(t).toString("base64");else if(typeof btoa=="function"){let s="";for(let o of t)s+=String.fromCharCode(o);n=btoa(s);}else throw new Error("No base64 encoder available in this runtime");return n.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function vd(e){let t=e.replace(/-/g,"+").replace(/_/g,"/")+"=".repeat((4-e.length%4)%4),r=globalThis.Buffer;if(r)return r.from(t,"base64").toString("utf8");if(typeof atob=="function"){let n=atob(t),s=new Uint8Array(n.length);for(let o=0;o<n.length;o+=1)s[o]=n.charCodeAt(o);return new TextDecoder().decode(s)}throw new Error("No base64 decoder available in this runtime")}function pe(e){return `${Hr}${yd(JSON.stringify(e))}`}function We(e){if(!e.startsWith(Hr))throw new Error(`Invalid ref format (expected ${Hr}<base64url(json)>): ${e}`);let t;try{t=JSON.parse(vd(e.slice(Hr.length)));}catch{throw new Error(`Invalid ref format (malformed base64url/json): ${e}`)}if(!t||typeof t!="object")throw new Error(`Invalid ref format (expected object payload): ${e}`);let r=t;if(typeof r.kind!="string"||typeof r.value!="string")throw new Error(`Invalid ref format (payload must contain string kind/value): ${e}`);return {kind:r.kind,value:r.value}}async function ma(e,t,r){let n=e.tryAcquire();if(!n)return false;try{await t();}finally{n();}return r?.(),true}function Ne(...e){return se__namespace.join(...e)}function va(e){return se__namespace.isAbsolute(e)}function Zn(){return crypto.randomUUID()}function Sa(e){return crypto.createHash("sha256").update(e).digest("hex")}function wa(e){return se__namespace.dirname(url.fileURLToPath(e))}function _d(e){if(typeof e=="object"&&e!==null){let{command:r,args:n=[],...s}=e,o=ha(r,n);return {...s,command:o.command,args:o.args}}let t=ka(e);if(t.length===0)throw new Error(`Empty command spec: ${JSON.stringify(e)}`);return ha(t[0],t.slice(1))}function ha(e,t){return /^(node|node\.exe)$/i.test(e)?{command:process.execPath,args:t}:/\.m?js$/i.test(e)?{command:process.execPath,args:[e,...t]}:{command:e,args:t}}function ka(e){let t=[],r="",n=null;for(let s of e.trim()){if(n){s===n?n=null:r+=s;continue}if(s==='"'||s==="'"){n=s;continue}if(/\s/.test(s)){r&&(t.push(r),r="");continue}r+=s;}if(n)throw new Error(`Unterminated quote in command: ${e}`);return r&&t.push(r),t}function es(e){return process.platform==="win32"&&/\.(cmd|bat)$/i.test(e)}function ba(e,t){let{command:r,args:n=[],cwd:s,env:o,timeoutMs:a}=e;return child_process.execFileSync(r,n,{shell:es(r),timeout:a,encoding:t?.encoding??"utf-8",cwd:s,windowsHide:true,env:o?{...process.env,...o}:void 0,input:t?.input})}function Cd(e,t){let{command:r,args:n=[],cwd:s,env:o,timeoutMs:a=3e4}=e;child_process.execFile(r,n,{shell:es(r),encoding:"utf8",windowsHide:true,timeout:a,maxBuffer:10*1024*1024,cwd:s,env:o?{...process.env,...o}:void 0},(i,u,c)=>t(i??null,u,c));}se__namespace.join(Qn__namespace.tmpdir(),".board-live-cards-git-bash-cache.json");function Yr(e){let{command:t,args:r=[]}=e;if(process.platform==="win32"){child_process.spawn(t,r,{stdio:"ignore",windowsHide:true,shell:es(t)}).unref();return}child_process.spawn(t,r,{detached:true,stdio:"ignore"}).unref();}function ts(e,t,r){let n=se__namespace.join(e,"board-live-cards-cli.js");if($__namespace.existsSync(n))return {cmd:process.execPath,args:[n,t,...r]};let s=se__namespace.join(e,"board-live-cards-cli.ts"),a=[se__namespace.join(e,"..","..","..","node_modules","tsx","dist","cli.mjs"),se__namespace.join(e,"..","..","node_modules","tsx","dist","cli.mjs"),se__namespace.join(e,"..","..","..","node_modules",".bin","tsx"),se__namespace.join(e,"..","..","node_modules",".bin","tsx")].find(u=>$__namespace.existsSync(u));return $__namespace.existsSync(s)&&$__namespace.existsSync(a)?{cmd:process.execPath,args:[a,s,t,...r]}:{cmd:process.platform==="win32"?"npx.cmd":"npx",args:["tsx",s,t,...r]}}function rs(e){let t=se__namespace.join(e,"board-live-cards-cli.mjs");if($__namespace.existsSync(t))return t;let r=se__namespace.join(e,"..","..","..","dev","board-live-cards-cli.js");if($__namespace.existsSync(r))return r;let n=se__namespace.join(e,"..","..","dev","board-live-cards-cli.js");if($__namespace.existsSync(n))return n;let s=se__namespace.join(e,"board-live-cards-cli.js");if($__namespace.existsSync(s))return s;throw new Error(`resolveBoardCliCallbackTarget: cannot find callback target in ${e} (expected dev/board-live-cards-cli.js wrapper, ${s}, or ${t})`)}function Ra(e,t,r){let n=["--base-ref",pe(t)];r&&n.push("--notify-channel",r);let{cmd:s,args:o}=ts(e,"process-accumulated-events",n);Yr({command:s,args:o});}function $d(e){return process.platform==="win32"?`\\\\.\\pipe\\${e}`:se__namespace.join(Qn__namespace.tmpdir(),`${e}.sock`)}var Wr=new Map;function _a(e,t,r){if(t.length===0)return;let n=t.map(i=>JSON.stringify(i)).join(`
8
+ deps: ${r}}`};var vg={keyword:"dependencies",type:"object",schemaType:"object",error:ct.error,code(e){let[t,r]=Sg(e);Nc(e,t),qc(e,r);}};function Sg({schema:e}){let t={},r={};for(let n in e){if(n==="__proto__")continue;let s=Array.isArray(e[n])?t:r;s[n]=e[n];}return [t,r]}function Nc(e,t=e.schema){let{gen:r,data:n,it:s}=e;if(Object.keys(t).length===0)return;let o=r.let("missing");for(let a in t){let i=t[a];if(i.length===0)continue;let u=(0, Dr.propertyInData)(r,n,a,s.opts.ownProperties);e.setParams({property:a,depsCount:i.length,deps:i.join(", ")}),s.allErrors?r.if(u,()=>{for(let c of i)(0, Dr.checkReportMissingProp)(e,c);}):(r.if((0, To._)`${u} && (${(0, Dr.checkMissingProp)(e,i,o)})`),(0, Dr.reportMissingProp)(e,o),r.else());}}ct.validatePropertyDeps=Nc;function qc(e,t=e.schema){let{gen:r,data:n,keyword:s,it:o}=e,a=r.name("valid");for(let i in t)(0, yg.alwaysValidSchema)(o,t[i])||(r.if((0, Dr.propertyInData)(r,n,i,o.opts.ownProperties),()=>{let u=e.subschema({keyword:s,schemaProp:i},a);e.mergeValidEvaluated(u,a);},()=>r.var(a,true)),e.ok(a));}ct.validateSchemaDeps=qc;ct.default=vg;});var Dc=O(Io=>{Object.defineProperty(Io,"__esModule",{value:true});var Mc=W(),wg=ae(),kg={message:"property name must be valid",params:({params:e})=>(0, Mc._)`{propertyName: ${e.propertyName}}`},bg={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:kg,code(e){let{gen:t,schema:r,data:n,it:s}=e;if((0, wg.alwaysValidSchema)(s,r))return;let o=t.name("valid");t.forIn("key",n,a=>{e.setParams({propertyName:a}),e.subschema({keyword:"propertyNames",data:a,dataTypes:["string"],propertyName:a,compositeRule:true},o),t.if((0, Mc.not)(o),()=>{e.error(true),s.allErrors||t.break();});}),e.ok(o);}};Io.default=bg;});var Oo=O(jo=>{Object.defineProperty(jo,"__esModule",{value:true});var jn=He(),st=W(),Rg=pt(),On=ae(),_g={message:"must NOT have additional properties",params:({params:e})=>(0, st._)`{additionalProperty: ${e.additionalProperty}}`},Cg={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:true,trackErrors:true,error:_g,code(e){let{gen:t,schema:r,parentSchema:n,data:s,errsCount:o,it:a}=e;if(!o)throw new Error("ajv implementation error");let{allErrors:i,opts:u}=a;if(a.props=true,u.removeAdditional!=="all"&&(0, On.alwaysValidSchema)(a,r))return;let c=(0, jn.allSchemaProperties)(n.properties),d=(0, jn.allSchemaProperties)(n.patternProperties);l(),e.ok((0, st._)`${o} === ${Rg.default.errors}`);function l(){t.forIn("key",s,b=>{!c.length&&!d.length?f(b):t.if(g(b),()=>f(b));});}function g(b){let C;if(c.length>8){let q=(0, On.schemaRefOrVal)(a,n.properties,"properties");C=(0, jn.isOwnProperty)(t,q,b);}else c.length?C=(0, st.or)(...c.map(q=>(0, st._)`${b} === ${q}`)):C=st.nil;return d.length&&(C=(0, st.or)(C,...d.map(q=>(0, st._)`${(0, jn.usePattern)(e,q)}.test(${b})`))),(0, st.not)(C)}function v(b){t.code((0, st._)`delete ${s}[${b}]`);}function f(b){if(u.removeAdditional==="all"||u.removeAdditional&&r===false){v(b);return}if(r===false){e.setParams({additionalProperty:b}),e.error(),i||t.break();return}if(typeof r=="object"&&!(0, On.alwaysValidSchema)(a,r)){let C=t.name("valid");u.removeAdditional==="failing"?(m(b,C,false),t.if((0, st.not)(C),()=>{e.reset(),v(b);})):(m(b,C),i||t.if((0, st.not)(C),()=>t.break()));}}function m(b,C,q){let _={keyword:"additionalProperties",dataProp:b,dataPropType:On.Type.Str};q===false&&Object.assign(_,{compositeRule:true,createErrors:false,allErrors:false}),e.subschema(_,C);}}};jo.default=Cg;});var Vc=O(No=>{Object.defineProperty(No,"__esModule",{value:true});var $g=Cr(),Lc=He(),Po=ae(),Bc=Oo(),Eg={keyword:"properties",type:"object",schemaType:"object",code(e){let{gen:t,schema:r,parentSchema:n,data:s,it:o}=e;o.opts.removeAdditional==="all"&&n.additionalProperties===void 0&&Bc.default.code(new $g.KeywordCxt(o,Bc.default,"additionalProperties"));let a=(0, Lc.allSchemaProperties)(r);for(let l of a)o.definedProperties.add(l);o.opts.unevaluated&&a.length&&o.props!==true&&(o.props=Po.mergeEvaluated.props(t,(0, Po.toHash)(a),o.props));let i=a.filter(l=>!(0, Po.alwaysValidSchema)(o,r[l]));if(i.length===0)return;let u=t.name("valid");for(let l of i)c(l)?d(l):(t.if((0, Lc.propertyInData)(t,s,l,o.opts.ownProperties)),d(l),o.allErrors||t.else().var(u,true),t.endIf()),e.it.definedProperties.add(l),e.ok(u);function c(l){return o.opts.useDefaults&&!o.compositeRule&&r[l].default!==void 0}function d(l){e.subschema({keyword:"properties",schemaProp:l,dataProp:l},u);}}};No.default=Eg;});var Jc=O(qo=>{Object.defineProperty(qo,"__esModule",{value:true});var Uc=He(),Pn=W(),Kc=ae(),Gc=ae(),xg={keyword:"patternProperties",type:"object",schemaType:"object",code(e){let{gen:t,schema:r,data:n,parentSchema:s,it:o}=e,{opts:a}=o,i=(0, Uc.allSchemaProperties)(r),u=i.filter(m=>(0, Kc.alwaysValidSchema)(o,r[m]));if(i.length===0||u.length===i.length&&(!o.opts.unevaluated||o.props===true))return;let c=a.strictSchema&&!a.allowMatchingProperties&&s.properties,d=t.name("valid");o.props!==true&&!(o.props instanceof Pn.Name)&&(o.props=(0, Gc.evaluatedPropsToName)(t,o.props));let{props:l}=o;g();function g(){for(let m of i)c&&v(m),o.allErrors?f(m):(t.var(d,true),f(m),t.if(d));}function v(m){for(let b in c)new RegExp(m).test(b)&&(0, Kc.checkStrictMode)(o,`property ${b} matches pattern ${m} (use allowMatchingProperties)`);}function f(m){t.forIn("key",n,b=>{t.if((0, Pn._)`${(0, Uc.usePattern)(e,m)}.test(${b})`,()=>{let C=u.includes(m);C||e.subschema({keyword:"patternProperties",schemaProp:m,dataProp:b,dataPropType:Gc.Type.Str},d),o.opts.unevaluated&&l!==true?t.assign((0, Pn._)`${l}[${b}]`,true):!C&&!o.allErrors&&t.if((0, Pn.not)(d),()=>t.break());});});}}};qo.default=xg;});var zc=O(Fo=>{Object.defineProperty(Fo,"__esModule",{value:true});var Ag=ae(),Tg={keyword:"not",schemaType:["object","boolean"],trackErrors:true,code(e){let{gen:t,schema:r,it:n}=e;if((0, Ag.alwaysValidSchema)(n,r)){e.fail();return}let s=t.name("valid");e.subschema({keyword:"not",compositeRule:true,createErrors:false,allErrors:false},s),e.failResult(s,()=>e.reset(),()=>e.error());},error:{message:"must NOT be valid"}};Fo.default=Tg;});var Hc=O(Mo=>{Object.defineProperty(Mo,"__esModule",{value:true});var Ig=He(),jg={keyword:"anyOf",schemaType:"array",trackErrors:true,code:Ig.validateUnion,error:{message:"must match a schema in anyOf"}};Mo.default=jg;});var Wc=O(Do=>{Object.defineProperty(Do,"__esModule",{value:true});var Nn=W(),Og=ae(),Pg={message:"must match exactly one schema in oneOf",params:({params:e})=>(0, Nn._)`{passingSchemas: ${e.passing}}`},Ng={keyword:"oneOf",schemaType:"array",trackErrors:true,error:Pg,code(e){let{gen:t,schema:r,parentSchema:n,it:s}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(s.opts.discriminator&&n.discriminator)return;let o=r,a=t.let("valid",false),i=t.let("passing",null),u=t.name("_valid");e.setParams({passing:i}),t.block(c),e.result(a,()=>e.reset(),()=>e.error(true));function c(){o.forEach((d,l)=>{let g;(0, Og.alwaysValidSchema)(s,d)?t.var(u,true):g=e.subschema({keyword:"oneOf",schemaProp:l,compositeRule:true},u),l>0&&t.if((0, Nn._)`${u} && ${a}`).assign(a,false).assign(i,(0, Nn._)`[${i}, ${l}]`).else(),t.if(u,()=>{t.assign(a,true),t.assign(i,l),g&&e.mergeEvaluated(g,Nn.Name);});});}}};Do.default=Ng;});var Yc=O(Lo=>{Object.defineProperty(Lo,"__esModule",{value:true});var qg=ae(),Fg={keyword:"allOf",schemaType:"array",code(e){let{gen:t,schema:r,it:n}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");let s=t.name("valid");r.forEach((o,a)=>{if((0, qg.alwaysValidSchema)(n,o))return;let i=e.subschema({keyword:"allOf",schemaProp:a},s);e.ok(s),e.mergeEvaluated(i);});}};Lo.default=Fg;});var Zc=O(Bo=>{Object.defineProperty(Bo,"__esModule",{value:true});var qn=W(),Qc=ae(),Mg={message:({params:e})=>(0, qn.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0, qn._)`{failingKeyword: ${e.ifClause}}`},Dg={keyword:"if",schemaType:["object","boolean"],trackErrors:true,error:Mg,code(e){let{gen:t,parentSchema:r,it:n}=e;r.then===void 0&&r.else===void 0&&(0, Qc.checkStrictMode)(n,'"if" without "then" and "else" is ignored');let s=Xc(n,"then"),o=Xc(n,"else");if(!s&&!o)return;let a=t.let("valid",true),i=t.name("_valid");if(u(),e.reset(),s&&o){let d=t.let("ifClause");e.setParams({ifClause:d}),t.if(i,c("then",d),c("else",d));}else s?t.if(i,c("then")):t.if((0, qn.not)(i),c("else"));e.pass(a,()=>e.error(true));function u(){let d=e.subschema({keyword:"if",compositeRule:true,createErrors:false,allErrors:false},i);e.mergeEvaluated(d);}function c(d,l){return ()=>{let g=e.subschema({keyword:d},i);t.assign(a,i),e.mergeValidEvaluated(g,a),l?t.assign(l,(0, qn._)`${d}`):e.setParams({ifClause:d});}}}};function Xc(e,t){let r=e.schema[t];return r!==void 0&&!(0, Qc.alwaysValidSchema)(e,r)}Bo.default=Dg;});var eu=O(Vo=>{Object.defineProperty(Vo,"__esModule",{value:true});var Lg=ae(),Bg={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:r}){t.if===void 0&&(0, Lg.checkStrictMode)(r,`"${e}" without "if" is ignored`);}};Vo.default=Bg;});var tu=O(Uo=>{Object.defineProperty(Uo,"__esModule",{value:true});var Vg=Co(),Ug=Ic(),Kg=$o(),Gg=Oc(),Jg=Pc(),zg=Fc(),Hg=Dc(),Wg=Oo(),Yg=Vc(),Xg=Jc(),Qg=zc(),Zg=Hc(),eh=Wc(),th=Yc(),rh=Zc(),nh=eu();function sh(e=false){let t=[Qg.default,Zg.default,eh.default,th.default,rh.default,nh.default,Hg.default,Wg.default,zg.default,Yg.default,Xg.default];return e?t.push(Ug.default,Gg.default):t.push(Vg.default,Kg.default),t.push(Jg.default),t}Uo.default=sh;});var ru=O(Ko=>{Object.defineProperty(Ko,"__esModule",{value:true});var Se=W(),oh={message:({schemaCode:e})=>(0, Se.str)`must match format "${e}"`,params:({schemaCode:e})=>(0, Se._)`{format: ${e}}`},ah={keyword:"format",type:["number","string"],schemaType:"string",$data:true,error:oh,code(e,t){let{gen:r,data:n,$data:s,schema:o,schemaCode:a,it:i}=e,{opts:u,errSchemaPath:c,schemaEnv:d,self:l}=i;if(!u.validateFormats)return;s?g():v();function g(){let f=r.scopeValue("formats",{ref:l.formats,code:u.code.formats}),m=r.const("fDef",(0, Se._)`${f}[${a}]`),b=r.let("fType"),C=r.let("format");r.if((0, Se._)`typeof ${m} == "object" && !(${m} instanceof RegExp)`,()=>r.assign(b,(0, Se._)`${m}.type || "string"`).assign(C,(0, Se._)`${m}.validate`),()=>r.assign(b,(0, Se._)`"string"`).assign(C,m)),e.fail$data((0, Se.or)(q(),_()));function q(){return u.strictSchema===false?Se.nil:(0, Se._)`${a} && !${C}`}function _(){let I=d.$async?(0, Se._)`(${m}.async ? await ${C}(${n}) : ${C}(${n}))`:(0, Se._)`${C}(${n})`,S=(0, Se._)`(typeof ${C} == "function" ? ${I} : ${C}.test(${n}))`;return (0, Se._)`${C} && ${C} !== true && ${b} === ${t} && !${S}`}}function v(){let f=l.formats[o];if(!f){q();return}if(f===true)return;let[m,b,C]=_(f);m===t&&e.pass(I());function q(){if(u.strictSchema===false){l.logger.warn(S());return}throw new Error(S());function S(){return `unknown format "${o}" ignored in schema at path "${c}"`}}function _(S){let k=S instanceof RegExp?(0, Se.regexpCode)(S):u.code.formats?(0, Se._)`${u.code.formats}${(0, Se.getProperty)(o)}`:void 0,w=r.scopeValue("formats",{key:o,ref:S,code:k});return typeof S=="object"&&!(S instanceof RegExp)?[S.type||"string",S.validate,(0, Se._)`${w}.validate`]:["string",S,w]}function I(){if(typeof f=="object"&&!(f instanceof RegExp)&&f.async){if(!d.$async)throw new Error("async format in sync schema");return (0, Se._)`await ${C}(${n})`}return typeof b=="function"?(0, Se._)`${C}(${n})`:(0, Se._)`${C}.test(${n})`}}}};Ko.default=ah;});var nu=O(Go=>{Object.defineProperty(Go,"__esModule",{value:true});var ih=ru(),ch=[ih.default];Go.default=ch;});var su=O(ir=>{Object.defineProperty(ir,"__esModule",{value:true});ir.contentVocabulary=ir.metadataVocabulary=void 0;ir.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];ir.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"];});var au=O(Jo=>{Object.defineProperty(Jo,"__esModule",{value:true});var uh=pc(),dh=Ec(),lh=tu(),fh=nu(),ou=su(),ph=[uh.default,dh.default,(0, lh.default)(),fh.default,ou.metadataVocabulary,ou.contentVocabulary];Jo.default=ph;});var cu=O(Fn=>{Object.defineProperty(Fn,"__esModule",{value:true});Fn.DiscrError=void 0;var iu;(function(e){e.Tag="tag",e.Mapping="mapping";})(iu||(Fn.DiscrError=iu={}));});var du=O(Ho=>{Object.defineProperty(Ho,"__esModule",{value:true});var cr=W(),zo=cu(),uu=Sn(),mh=$r(),gh=ae(),hh={message:({params:{discrError:e,tagName:t}})=>e===zo.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:r}})=>(0, cr._)`{error: ${e}, tag: ${r}, tagValue: ${t}}`},yh={keyword:"discriminator",type:"object",schemaType:"object",error:hh,code(e){let{gen:t,data:r,schema:n,parentSchema:s,it:o}=e,{oneOf:a}=s;if(!o.opts.discriminator)throw new Error("discriminator: requires discriminator option");let i=n.propertyName;if(typeof i!="string")throw new Error("discriminator: requires propertyName");if(n.mapping)throw new Error("discriminator: mapping is not supported");if(!a)throw new Error("discriminator: requires oneOf keyword");let u=t.let("valid",false),c=t.const("tag",(0, cr._)`${r}${(0, cr.getProperty)(i)}`);t.if((0, cr._)`typeof ${c} == "string"`,()=>d(),()=>e.error(false,{discrError:zo.DiscrError.Tag,tag:c,tagName:i})),e.ok(u);function d(){let v=g();t.if(false);for(let f in v)t.elseIf((0, cr._)`${c} === ${f}`),t.assign(u,l(v[f]));t.else(),e.error(false,{discrError:zo.DiscrError.Mapping,tag:c,tagName:i}),t.endIf();}function l(v){let f=t.name("valid"),m=e.subschema({keyword:"oneOf",schemaProp:v},f);return e.mergeEvaluated(m,cr.Name),f}function g(){var v;let f={},m=C(s),b=true;for(let I=0;I<a.length;I++){let S=a[I];if(S?.$ref&&!(0, gh.schemaHasRulesButRef)(S,o.self.RULES)){let w=S.$ref;if(S=uu.resolveRef.call(o.self,o.schemaEnv.root,o.baseId,w),S instanceof uu.SchemaEnv&&(S=S.schema),S===void 0)throw new mh.default(o.opts.uriResolver,o.baseId,w)}let k=(v=S?.properties)===null||v===void 0?void 0:v[i];if(typeof k!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${i}"`);b=b&&(m||C(S)),q(k,I);}if(!b)throw new Error(`discriminator: "${i}" must be required`);return f;function C({required:I}){return Array.isArray(I)&&I.includes(i)}function q(I,S){if(I.const)_(I.const,S);else if(I.enum)for(let k of I.enum)_(k,S);else throw new Error(`discriminator: "properties/${i}" must have "const" or "enum"`)}function _(I,S){if(typeof I!="string"||I in f)throw new Error(`discriminator: "${i}" values must be unique strings`);f[I]=S;}}}};Ho.default=yh;});var lu=O((bS,vh)=>{vh.exports={$schema:"http://json-schema.org/draft-07/schema#",$id:"http://json-schema.org/draft-07/schema#",title:"Core schema meta-schema",definitions:{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:true,default:[]}},type:["object","boolean"],properties:{$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:true,readOnly:{type:"boolean",default:false},examples:{type:"array",items:true},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:true},maxItems:{$ref:"#/definitions/nonNegativeInteger"},minItems:{$ref:"#/definitions/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:false},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:true,enum:{type:"array",items:true,minItems:1,uniqueItems:true},type:{anyOf:[{$ref:"#/definitions/simpleTypes"},{type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:true}]},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:"#"}},default:true};});var pu=O((he,Wo)=>{Object.defineProperty(he,"__esModule",{value:true});he.MissingRefError=he.ValidationError=he.CodeGen=he.Name=he.nil=he.stringify=he.str=he._=he.KeywordCxt=he.Ajv=void 0;var Sh=ic(),wh=au(),kh=du(),fu=lu(),bh=["/properties"],Mn="http://json-schema.org/draft-07/schema",ur=class extends Sh.default{_addVocabularies(){super._addVocabularies(),wh.default.forEach(t=>this.addVocabulary(t)),this.opts.discriminator&&this.addKeyword(kh.default);}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let t=this.opts.$data?this.$dataMetaSchema(fu,bh):fu;this.addMetaSchema(t,Mn,false),this.refs["http://json-schema.org/schema"]=Mn;}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(Mn)?Mn:void 0)}};he.Ajv=ur;Wo.exports=he=ur;Wo.exports.Ajv=ur;Object.defineProperty(he,"__esModule",{value:true});he.default=ur;var Rh=Cr();Object.defineProperty(he,"KeywordCxt",{enumerable:true,get:function(){return Rh.KeywordCxt}});var dr=W();Object.defineProperty(he,"_",{enumerable:true,get:function(){return dr._}});Object.defineProperty(he,"str",{enumerable:true,get:function(){return dr.str}});Object.defineProperty(he,"stringify",{enumerable:true,get:function(){return dr.stringify}});Object.defineProperty(he,"nil",{enumerable:true,get:function(){return dr.nil}});Object.defineProperty(he,"Name",{enumerable:true,get:function(){return dr.Name}});Object.defineProperty(he,"CodeGen",{enumerable:true,get:function(){return dr.CodeGen}});var _h=yn();Object.defineProperty(he,"ValidationError",{enumerable:true,get:function(){return _h.default}});var Ch=$r();Object.defineProperty(he,"MissingRefError",{enumerable:true,get:function(){return Ch.default}});});var Hr="b64:";function yd(e){let t=new TextEncoder().encode(e),r=globalThis.Buffer,n;if(r)n=r.from(t).toString("base64");else if(typeof btoa=="function"){let s="";for(let o of t)s+=String.fromCharCode(o);n=btoa(s);}else throw new Error("No base64 encoder available in this runtime");return n.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function vd(e){let t=e.replace(/-/g,"+").replace(/_/g,"/")+"=".repeat((4-e.length%4)%4),r=globalThis.Buffer;if(r)return r.from(t,"base64").toString("utf8");if(typeof atob=="function"){let n=atob(t),s=new Uint8Array(n.length);for(let o=0;o<n.length;o+=1)s[o]=n.charCodeAt(o);return new TextDecoder().decode(s)}throw new Error("No base64 decoder available in this runtime")}function pe(e){return `${Hr}${yd(JSON.stringify(e))}`}function Qe(e){if(!e.startsWith(Hr))throw new Error(`Invalid ref format (expected ${Hr}<base64url(json)>): ${e}`);let t;try{t=JSON.parse(vd(e.slice(Hr.length)));}catch{throw new Error(`Invalid ref format (malformed base64url/json): ${e}`)}if(!t||typeof t!="object")throw new Error(`Invalid ref format (expected object payload): ${e}`);let r=t;if(typeof r.kind!="string"||typeof r.value!="string")throw new Error(`Invalid ref format (payload must contain string kind/value): ${e}`);return {kind:r.kind,value:r.value}}async function ma(e,t,r){let n=e.tryAcquire();if(!n)return false;try{await t();}finally{n();}return r?.(),true}function qe(...e){return oe__namespace.join(...e)}function va(e){return oe__namespace.isAbsolute(e)}function Zn(){return crypto.randomUUID()}function Sa(e){return crypto.createHash("sha256").update(e).digest("hex")}function wa(e){return oe__namespace.dirname(url.fileURLToPath(e))}function _d(e){if(typeof e=="object"&&e!==null){let{command:r,args:n=[],...s}=e,o=ha(r,n);return {...s,command:o.command,args:o.args}}let t=ka(e);if(t.length===0)throw new Error(`Empty command spec: ${JSON.stringify(e)}`);return ha(t[0],t.slice(1))}function ha(e,t){return /^(node|node\.exe)$/i.test(e)?{command:process.execPath,args:t}:/\.m?js$/i.test(e)?{command:process.execPath,args:[e,...t]}:{command:e,args:t}}function ka(e){let t=[],r="",n=null;for(let s of e.trim()){if(n){s===n?n=null:r+=s;continue}if(s==='"'||s==="'"){n=s;continue}if(/\s/.test(s)){r&&(t.push(r),r="");continue}r+=s;}if(n)throw new Error(`Unterminated quote in command: ${e}`);return r&&t.push(r),t}function es(e){return process.platform==="win32"&&/\.(cmd|bat)$/i.test(e)}function ba(e,t){let{command:r,args:n=[],cwd:s,env:o,timeoutMs:a}=e;return child_process.execFileSync(r,n,{shell:es(r),timeout:a,encoding:t?.encoding??"utf-8",cwd:s,windowsHide:true,env:o?{...process.env,...o}:void 0,input:t?.input})}function Cd(e,t){let{command:r,args:n=[],cwd:s,env:o,timeoutMs:a=3e4}=e;child_process.execFile(r,n,{shell:es(r),encoding:"utf8",windowsHide:true,timeout:a,maxBuffer:10*1024*1024,cwd:s,env:o?{...process.env,...o}:void 0},(i,u,c)=>t(i??null,u,c));}oe__namespace.join(Qn__namespace.tmpdir(),".board-live-cards-git-bash-cache.json");function Yr(e){let{command:t,args:r=[]}=e;if(process.platform==="win32"){child_process.spawn(t,r,{stdio:"ignore",windowsHide:true,shell:es(t)}).unref();return}child_process.spawn(t,r,{detached:true,stdio:"ignore"}).unref();}function ts(e,t,r){let n=oe__namespace.join(e,"board-live-cards-cli.js");if($__namespace.existsSync(n))return {cmd:process.execPath,args:[n,t,...r]};let s=oe__namespace.join(e,"board-live-cards-cli.ts"),a=[oe__namespace.join(e,"..","..","..","node_modules","tsx","dist","cli.mjs"),oe__namespace.join(e,"..","..","node_modules","tsx","dist","cli.mjs"),oe__namespace.join(e,"..","..","..","node_modules",".bin","tsx"),oe__namespace.join(e,"..","..","node_modules",".bin","tsx")].find(u=>$__namespace.existsSync(u));return $__namespace.existsSync(s)&&$__namespace.existsSync(a)?{cmd:process.execPath,args:[a,s,t,...r]}:{cmd:process.platform==="win32"?"npx.cmd":"npx",args:["tsx",s,t,...r]}}function rs(e){let t=oe__namespace.join(e,"board-live-cards-cli.mjs");if($__namespace.existsSync(t))return t;let r=oe__namespace.join(e,"..","..","..","dev","board-live-cards-cli.js");if($__namespace.existsSync(r))return r;let n=oe__namespace.join(e,"..","..","dev","board-live-cards-cli.js");if($__namespace.existsSync(n))return n;let s=oe__namespace.join(e,"board-live-cards-cli.js");if($__namespace.existsSync(s))return s;throw new Error(`resolveBoardCliCallbackTarget: cannot find callback target in ${e} (expected dev/board-live-cards-cli.js wrapper, ${s}, or ${t})`)}function Ra(e,t,r){let n=["--base-ref",pe(t)];r&&n.push("--notify-channel",r);let{cmd:s,args:o}=ts(e,"process-accumulated-events",n);Yr({command:s,args:o});}function $d(e){return process.platform==="win32"?`\\\\.\\pipe\\${e}`:oe__namespace.join(Qn__namespace.tmpdir(),`${e}.sock`)}var Wr=new Map;function _a(e,t,r){if(t.length===0)return;let n=t.map(i=>JSON.stringify(i)).join(`
9
9
  `)+`
10
- `,s=Wr.get(e);if(s&&!s.socket.destroyed){s.ready?s.socket.write(n):s.queue.push(n);return}let o=$d(e),a=ya__namespace.createConnection(o);s={socket:a,ready:false,queue:[n]},Wr.set(e,s),a.on("connect",()=>{s.ready=true;for(let i of s.queue)a.write(i);s.queue.length=0;}),a.on("error",i=>{r?.(`[named-pipe publish] ${o}: ${i instanceof Error?i.message:String(i)}`),Wr.delete(e);}),a.on("close",()=>{Wr.delete(e);});}function Xr(){return {executeSync(e,t,r){return ba({command:e,args:t,cwd:r?.cwd,timeoutMs:r?.timeout,env:r?.env},{encoding:r?.encoding,input:r?.input})},executeAsync(e,t,r){Cd({command:e,args:t},r);},resolveInvocation(e,t){let r=_d({command:e,args:t});return {cmd:r.command,args:r.args??[]}},splitCommand:ka,spawnDetached(e,t){Yr({command:e,args:t});}}}var $a=se.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('board-live-cards-node.cjs', document.baseURI).href)))),Id=module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('board-live-cards-node.cjs', document.baseURI).href)));function jd(){let e=se.resolve($a,"./jsonata-sync.cjs");return $.existsSync(e)?e:se.resolve($a,"../../card-compute/jsonata-sync.cjs")}var jt=Id(jd());function lr(e){e.registerFunction("fsPathRef",t=>pe({kind:"fs-path",value:String(t)}),"<s:s>");}function ns(e,t,r){if(!e||typeof e!="object")return {};let n={};if(Array.isArray(e.cmdTemplate)){let s=[];for(let o of e.cmdTemplate)try{let a=jt(o);lr(a),s.push(String(a.evaluate(t)));}catch(a){let i=a instanceof Error?a.message:String(a);throw new Error(`[${r}] argsMassaging.cmdTemplate failed on "${o}": ${i}`)}n.cmdArgs=s;}if(typeof e.stdinTemplate=="string")try{let s=jt(e.stdinTemplate);lr(s),n.stdin=s.evaluate(t);}catch(s){let o=s instanceof Error?s.message:String(s);throw new Error(`[${r}] argsMassaging.stdinTemplate failed: ${o}`)}if(typeof e.urlTemplate=="string")try{let s=jt(e.urlTemplate);lr(s),n.url=String(s.evaluate(t));}catch(s){let o=s instanceof Error?s.message:String(s);throw new Error(`[${r}] argsMassaging.urlTemplate failed: ${o}`)}if(typeof e.headerTemplate=="string")try{let s=jt(e.headerTemplate);lr(s);let o=s.evaluate(t);if(typeof o!="object"||o===null)throw new Error(`headerTemplate must produce an object, got: ${JSON.stringify(o)}`);n.headers=o;}catch(s){let o=s instanceof Error?s.message:String(s);throw new Error(`[${r}] argsMassaging.headerTemplate failed: ${o}`)}if(typeof e.bodyTemplate=="string")try{let s=jt(e.bodyTemplate);lr(s),n.body=s.evaluate(t);}catch(s){let o=s instanceof Error?s.message:String(s);throw new Error(`[${r}] argsMassaging.bodyTemplate failed: ${o}`)}return n}var Pd=module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('board-live-cards-node.cjs', document.baseURI).href)));function Nd(e){return typeof e=="object"?e:We(e)}function xa(e){let t=se__namespace.basename(String(e||"").trim());if(!t)throw new Error(`resolveYamlFlowCliPath: expected non-empty cli file name, got ${JSON.stringify(e)}`);let r=se__namespace.dirname(Pd.resolve("yaml-flow/package.json")),n=t.replace(/\.[^.]+$/,""),s=se__namespace.join(r,"cli","bundled",`${n}.mjs`);if($__namespace.existsSync(s))return s;let o=se__namespace.join(r,"cli","node",t);if($__namespace.existsSync(o))return o;throw new Error(`resolveYamlFlowCliPath: could not find ${t} under cli/bundled or cli/node in ${r}`)}function Xe(e){let t=Nd(e);return t.kind==="yaml-flow-cli"?xa(t.value):t.value}function qd(e,t){let r=Xe(e);switch(r){case "source-cli-task-executor":{let n=se__namespace.join(t,"source-cli-task-executor.js");if($__namespace.existsSync(n))return {command:process.execPath,args:[n]};let s=se__namespace.join(t,"source-cli-task-executor.ts"),o=se__namespace.join(t,"..","..","node_modules","tsx","dist","cli.mjs"),a=se__namespace.join(t,"..","..","node_modules",".bin","tsx"),i=$__namespace.existsSync(o)?o:a;return $__namespace.existsSync(s)&&$__namespace.existsSync(i)?{command:process.execPath,args:[i,s]}:{command:process.execPath,args:[n]}}case "board-live-cards":{let{cmd:n,args:s}=ts(t,"_",[]);return {command:n,args:s}}default:throw new Error(`resolveBuiltIn: unknown built-in name "${r}". Supported: source-cli-task-executor, board-live-cards`)}}function Aa(e,t){if(e.howToRun==="built-in"){let{command:n,args:s}=qd(e.whatToRun,t);return {command:n,baseArgs:s}}let r=(typeof e.whatToRun=="object",Xe(e.whatToRun));switch(e.howToRun){case "local-node":return {command:process.execPath,baseArgs:[r]};case "local-python":return {command:process.platform==="win32"?"python":"python3",baseArgs:[r]};case "local-process":return {command:r,baseArgs:[]};default:throw new Error(`resolveBaseInvocation: howToRun "${e.howToRun}" is not a local transport`)}}function Fd(e,t){let r=[e.subcommand];return e.inRef&&r.push("--in-ref",e.inRef),e.outRef&&r.push("--out-ref",e.outRef),e.errRef&&r.push("--err-ref",e.errRef),t&&r.push("--extra",Buffer.from(JSON.stringify(t)).toString("base64")),r}function Md(e,t){return {subcommand:e.subcommand,...e.inRef?{inRef:e.inRef}:{},...e.outRef?{outRef:e.outRef}:{},...e.errRef?{errRef:e.errRef}:{},...t?{extra:t}:{}}}function Qr(e,t){return Aa(e,t)}function Ta(e){let t=e.trim();if(!t)throw new Error("empty stdout");try{return JSON.parse(t)}catch{let r=t.split(/\r?\n/).filter(Boolean),n=r[r.length-1];return JSON.parse(n)}}function Ia(e,t){return {...t,whatToRun:Xe(e.whatToRun),...e.extra?{extra:e.extra}:{}}}function ss(e,t,r="invokeExecutionRef"){return ns(e,t,r)}function ja(e){return e&&typeof e=="object"&&!Array.isArray(e)&&typeof e.result=="string"&&e.data&&typeof e.data=="object"&&!Array.isArray(e.data)?e:{result:"success",data:e&&typeof e=="object"&&!Array.isArray(e)?e:{stdout:e}}}function yt(e){return {result:"failure",data:{error:e}}}function ht(e,t,r){let n=r?.label??"invokeExecutionRefSync",s=r?.cliDir??r?.cwd??process.cwd(),o;try{o=ss(e.argsMassaging,Ia(e,t),n);}catch(l){let g=l instanceof Error?l.message:String(l);return yt(g)}let a;try{a=Qr(e,s);}catch(l){let g=l instanceof Error?l.message:String(l);return yt(`[${n}] ref resolution failed: ${g}`)}let i=[...a.baseArgs,...o.cmdArgs??[]],u=JSON.stringify(o.stdin??t),c=Xr(),d;try{d=c.executeSync(a.command,i,{timeout:r?.timeoutMs??3e4,encoding:"utf-8",cwd:r?.cwd,input:u});}catch(l){let g=l,v=(g.stderr?String(g.stderr):"").trim(),f=typeof g.status=="number"?g.status:"unknown",m=v||g.message;return yt(`[${n}] ref exited with status ${f}${m?`: ${m}`:""}`)}try{return ja(Ta(d))}catch{return {result:"success",data:{stdout:d.trim()}}}}async function Ea(e,t,r){let n=r?.label??"invokeExecutionRef",s;try{s=ss(e.argsMassaging,Ia(e,t),n);}catch(c){let d=c instanceof Error?c.message:String(c);return yt(d)}let o=Xe(e.whatToRun),a=s.headers?{"Content-Type":"application/json",...s.headers}:{"Content-Type":"application/json"},i=s.url??o,u;if(e.howToRun==="http:get"){let c=s.body&&typeof s.body=="object"&&!Array.isArray(s.body)?s.body:t,d=new URLSearchParams(Object.entries(c).filter(([,l])=>l!=null).map(([l,g])=>[l,String(g)]));d.size>0&&(i=`${i}${i.includes("?")?"&":"?"}${d.toString()}`);}else u=JSON.stringify(s.body??t);try{let c=await fetch(i,{method:e.howToRun==="http:get"?"GET":"POST",headers:a,body:u});if(!c.ok){let l=await c.text().catch(()=>"");return yt(`[${n}] HTTP ${c.status}${l?`: ${l}`:""}`)}let d=await c.text();if(!d.trim())return {result:"success",data:{}};try{return ja(Ta(d))}catch{return {result:"success",data:{stdout:d.trim()}}}}catch(c){let d=c instanceof Error?c.message:String(c);return yt(`[${n}] ${d}`)}}var Dd={"local-node":async(e,t,r)=>ht(e,t,r),"local-python":async(e,t,r)=>ht(e,t,r),"local-process":async(e,t,r)=>ht(e,t,r),"built-in":async(e,t,r)=>ht(e,t,r),"http:post":Ea,"http:get":Ea},Ld={"local-node":ht,"local-python":ht,"local-process":ht,"built-in":ht};async function Oa(e,t,r){let n=r?.transports?.[e.howToRun]??Dd[e.howToRun];return n?n(e,t,r):yt(`[${r?.label??"invokeExecutionRef"}] unsupported howToRun: ${e.howToRun}`)}function os(e,t,r){let n=r?.syncTransports?.[e.howToRun]??Ld[e.howToRun];return n?n(e,t,r):yt(`[${r?.label??"invokeExecutionRefSync"}] unsupported sync howToRun: ${e.howToRun}`)}function Bd(e){return {invoke(t,r){return Oa(t,r,e)},invokeSync(t,r){return os(t,r,e)}}}function Vd(e,t,r){return os(e,t,r)}async function Ud(e,t){let r={...t,whatToRun:Xe(e.whatToRun)},n=ns(e.argsMassaging,r,"_invokeTaskExecutorHttp"),s=n.url??Xe(e.whatToRun),o=n.body?n.body:Md(t,e.extra),a={"Content-Type":"application/json"},i=n.headers?{...a,...n.headers}:a,u=await fetch(s,{method:e.howToRun==="http:get"?"GET":"POST",headers:i,body:JSON.stringify(o)});if(!u.ok){let d=await u.text().catch(()=>"");return {status:"error",error:`HTTP ${u.status}: ${d}`}}let c=await u.json().catch(()=>null);return c&&typeof c.status=="string"?c:{status:"success"}}function Pa(e,t,r){if(e.howToRun==="http:post"||e.howToRun==="http:get"){Ud(e,t).catch(i=>{console.error(`[dispatchTaskExecutorDetached] HTTP dispatch failed: ${i.message}`);});return}let{command:s,baseArgs:o}=Aa(e,r),a=Fd(t,e.extra);Yr({command:s,args:[...o,...a]});}function ut(e,t){if(process.platform!=="win32"){$__namespace.renameSync(e,t);return}let r=[10,20,40,80,160];for(let n=0;n<=r.length;n++)try{$__namespace.renameSync(e,t);return}catch(s){let o=s.code;if((o==="EPERM"||o==="EBUSY")&&n<r.length){Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,r[n]);continue}throw s}}function Wt(e){function t(s){return se__namespace.join(e,...s.split("/"))}function r(s){return se__namespace.relative(e,s).replace(/\\/g,"/")}function n(s,o){if($__namespace.existsSync(s))for(let a of $__namespace.readdirSync(s,{withFileTypes:true})){let i=se__namespace.join(s,a.name);if(a.isDirectory()){n(i,o);continue}a.isFile()&&o.push(r(i));}}return {read(s){let o=t(s);if(!$__namespace.existsSync(o))return null;try{return $__namespace.readFileSync(o,"utf-8")}catch{return null}},write(s,o){let a=t(s),i=`${a}.${process.pid}.${crypto.randomUUID()}.tmp`;$__namespace.mkdirSync(se__namespace.dirname(a),{recursive:true}),$__namespace.writeFileSync(i,o,"utf-8"),ut(i,a);},exists(s){return $__namespace.existsSync(t(s))},remove(s){let o=t(s);try{$__namespace.existsSync(o)&&$__namespace.unlinkSync(o);}catch{}},readBytes(s){let o=t(s);if(!$__namespace.existsSync(o))return null;try{return new Uint8Array($__namespace.readFileSync(o))}catch{return null}},writeBytes(s,o){let a=t(s),i=`${a}.${process.pid}.${crypto.randomUUID()}.tmp`;$__namespace.mkdirSync(se__namespace.dirname(a),{recursive:true}),$__namespace.writeFileSync(i,Buffer.from(o)),ut(i,a);},listKeys(s){let o=[];n(e,o);let a=o.sort();return s?a.filter(i=>i.startsWith(s)):a},stat(s){let o=t(s);if(!$__namespace.existsSync(o))return null;try{let a=$__namespace.statSync(o);return {key:s,size:Number(a.size||0),updatedAt:new Date(a.mtimeMs).toISOString()}}catch{return null}},keyRef(s){return {kind:"fs-path",value:t(s)}}}}function us(){return {read(e){if(!$__namespace.existsSync(e))return null;try{return $__namespace.readFileSync(e,"utf-8")}catch{return null}},write(e,t){let r=`${e}.${process.pid}.${crypto.randomUUID()}.tmp`;$__namespace.mkdirSync(se__namespace.dirname(e),{recursive:true}),$__namespace.writeFileSync(r,t,"utf-8"),ut(r,e);},exists(e){return $__namespace.existsSync(e)},remove(e){try{$__namespace.existsSync(e)&&$__namespace.unlinkSync(e);}catch{}},readBytes(e){if(!$__namespace.existsSync(e))return null;try{return new Uint8Array($__namespace.readFileSync(e))}catch{return null}},writeBytes(e,t){let r=`${e}.${process.pid}.${crypto.randomUUID()}.tmp`;$__namespace.mkdirSync(se__namespace.dirname(e),{recursive:true}),$__namespace.writeFileSync(r,Buffer.from(t)),ut(r,e);},stat(e){if(!$__namespace.existsSync(e))return null;try{let t=$__namespace.statSync(e);return {key:e,size:Number(t.size||0),updatedAt:new Date(t.mtimeMs).toISOString()}}catch{return null}},listKeys(e){return []}}}var as="__scratch-marker",is="__scratch-config.json",Jd=1440*60*1e3,zd=720*60*1e3,Hd=500;function Na(e,t){if(!e)return t;let r=e.replace(/[^A-Za-z0-9._-]/g,"_");return r.length>0?r:t}function tn(e){$__namespace.mkdirSync(e,{recursive:true});let t=se__namespace.join(e,as),r=se__namespace.join(e,is),n=!$__namespace.existsSync(t);if(n)try{$__namespace.writeFileSync(t,`scratch-store
10
+ `,s=Wr.get(e);if(s&&!s.socket.destroyed){s.ready?s.socket.write(n):s.queue.push(n);return}let o=$d(e),a=ya__namespace.createConnection(o);s={socket:a,ready:false,queue:[n]},Wr.set(e,s),a.on("connect",()=>{s.ready=true;for(let i of s.queue)a.write(i);s.queue.length=0;}),a.on("error",i=>{r?.(`[named-pipe publish] ${o}: ${i instanceof Error?i.message:String(i)}`),Wr.delete(e);}),a.on("close",()=>{Wr.delete(e);});}function Xr(){return {executeSync(e,t,r){return ba({command:e,args:t,cwd:r?.cwd,timeoutMs:r?.timeout,env:r?.env},{encoding:r?.encoding,input:r?.input})},executeAsync(e,t,r){Cd({command:e,args:t},r);},resolveInvocation(e,t){let r=_d({command:e,args:t});return {cmd:r.command,args:r.args??[]}},splitCommand:ka,spawnDetached(e,t){Yr({command:e,args:t});}}}var $a=oe.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('board-live-cards-node.cjs', document.baseURI).href)))),Id=module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('board-live-cards-node.cjs', document.baseURI).href)));function jd(){let e=oe.resolve($a,"./jsonata-sync.cjs");return $.existsSync(e)?e:oe.resolve($a,"../../card-compute/jsonata-sync.cjs")}var jt=Id(jd());function lr(e){e.registerFunction("fsPathRef",t=>pe({kind:"fs-path",value:String(t)}),"<s:s>");}function ns(e,t,r){if(!e||typeof e!="object")return {};let n={};if(Array.isArray(e.cmdTemplate)){let s=[];for(let o of e.cmdTemplate)try{let a=jt(o);lr(a),s.push(String(a.evaluate(t)));}catch(a){let i=a instanceof Error?a.message:String(a);throw new Error(`[${r}] argsMassaging.cmdTemplate failed on "${o}": ${i}`)}n.cmdArgs=s;}if(typeof e.stdinTemplate=="string")try{let s=jt(e.stdinTemplate);lr(s),n.stdin=s.evaluate(t);}catch(s){let o=s instanceof Error?s.message:String(s);throw new Error(`[${r}] argsMassaging.stdinTemplate failed: ${o}`)}if(typeof e.urlTemplate=="string")try{let s=jt(e.urlTemplate);lr(s),n.url=String(s.evaluate(t));}catch(s){let o=s instanceof Error?s.message:String(s);throw new Error(`[${r}] argsMassaging.urlTemplate failed: ${o}`)}if(typeof e.headerTemplate=="string")try{let s=jt(e.headerTemplate);lr(s);let o=s.evaluate(t);if(typeof o!="object"||o===null)throw new Error(`headerTemplate must produce an object, got: ${JSON.stringify(o)}`);n.headers=o;}catch(s){let o=s instanceof Error?s.message:String(s);throw new Error(`[${r}] argsMassaging.headerTemplate failed: ${o}`)}if(typeof e.bodyTemplate=="string")try{let s=jt(e.bodyTemplate);lr(s),n.body=s.evaluate(t);}catch(s){let o=s instanceof Error?s.message:String(s);throw new Error(`[${r}] argsMassaging.bodyTemplate failed: ${o}`)}return n}var Pd=module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('board-live-cards-node.cjs', document.baseURI).href)));function Nd(e){return typeof e=="object"?e:Qe(e)}function xa(e){let t=oe__namespace.basename(String(e||"").trim());if(!t)throw new Error(`resolveYamlFlowCliPath: expected non-empty cli file name, got ${JSON.stringify(e)}`);let r=oe__namespace.dirname(Pd.resolve("yaml-flow/package.json")),n=t.replace(/\.[^.]+$/,""),s=oe__namespace.join(r,"cli","bundled",`${n}.mjs`);if($__namespace.existsSync(s))return s;let o=oe__namespace.join(r,"cli","node",t);if($__namespace.existsSync(o))return o;throw new Error(`resolveYamlFlowCliPath: could not find ${t} under cli/bundled or cli/node in ${r}`)}function et(e){let t=Nd(e);return t.kind==="yaml-flow-cli"?xa(t.value):t.value}function qd(e,t){let r=et(e);switch(r){case "source-cli-task-executor":{let n=oe__namespace.join(t,"source-cli-task-executor.js");if($__namespace.existsSync(n))return {command:process.execPath,args:[n]};let s=oe__namespace.join(t,"source-cli-task-executor.ts"),o=oe__namespace.join(t,"..","..","node_modules","tsx","dist","cli.mjs"),a=oe__namespace.join(t,"..","..","node_modules",".bin","tsx"),i=$__namespace.existsSync(o)?o:a;return $__namespace.existsSync(s)&&$__namespace.existsSync(i)?{command:process.execPath,args:[i,s]}:{command:process.execPath,args:[n]}}case "board-live-cards":{let{cmd:n,args:s}=ts(t,"_",[]);return {command:n,args:s}}default:throw new Error(`resolveBuiltIn: unknown built-in name "${r}". Supported: source-cli-task-executor, board-live-cards`)}}function Aa(e,t){if(e.howToRun==="built-in"){let{command:n,args:s}=qd(e.whatToRun,t);return {command:n,baseArgs:s}}let r=(typeof e.whatToRun=="object",et(e.whatToRun));switch(e.howToRun){case "local-node":return {command:process.execPath,baseArgs:[r]};case "local-python":return {command:process.platform==="win32"?"python":"python3",baseArgs:[r]};case "local-process":return {command:r,baseArgs:[]};default:throw new Error(`resolveBaseInvocation: howToRun "${e.howToRun}" is not a local transport`)}}function Fd(e,t){let r=[e.subcommand];return e.inRef&&r.push("--in-ref",e.inRef),e.outRef&&r.push("--out-ref",e.outRef),e.errRef&&r.push("--err-ref",e.errRef),t&&r.push("--extra",Buffer.from(JSON.stringify(t)).toString("base64")),r}function Md(e,t){return {subcommand:e.subcommand,...e.inRef?{inRef:e.inRef}:{},...e.outRef?{outRef:e.outRef}:{},...e.errRef?{errRef:e.errRef}:{},...t?{extra:t}:{}}}function Qr(e,t){return Aa(e,t)}function Ta(e){let t=e.trim();if(!t)throw new Error("empty stdout");try{return JSON.parse(t)}catch{let r=t.split(/\r?\n/).filter(Boolean),n=r[r.length-1];return JSON.parse(n)}}function Ia(e,t){return {...t,whatToRun:et(e.whatToRun),...e.extra?{extra:e.extra}:{}}}function ss(e,t,r="invokeExecutionRef"){return ns(e,t,r)}function ja(e){return e&&typeof e=="object"&&!Array.isArray(e)&&typeof e.result=="string"&&e.data&&typeof e.data=="object"&&!Array.isArray(e.data)?e:{result:"success",data:e&&typeof e=="object"&&!Array.isArray(e)?e:{stdout:e}}}function vt(e){return {result:"failure",data:{error:e}}}function yt(e,t,r){let n=r?.label??"invokeExecutionRefSync",s=r?.cliDir??r?.cwd??process.cwd(),o;try{o=ss(e.argsMassaging,Ia(e,t),n);}catch(l){let g=l instanceof Error?l.message:String(l);return vt(g)}let a;try{a=Qr(e,s);}catch(l){let g=l instanceof Error?l.message:String(l);return vt(`[${n}] ref resolution failed: ${g}`)}let i=[...a.baseArgs,...o.cmdArgs??[]],u=JSON.stringify(o.stdin??t),c=Xr(),d;try{d=c.executeSync(a.command,i,{timeout:r?.timeoutMs??3e4,encoding:"utf-8",cwd:r?.cwd,input:u});}catch(l){let g=l,v=(g.stderr?String(g.stderr):"").trim(),f=typeof g.status=="number"?g.status:"unknown",m=v||g.message;return vt(`[${n}] ref exited with status ${f}${m?`: ${m}`:""}`)}try{return ja(Ta(d))}catch{return {result:"success",data:{stdout:d.trim()}}}}async function Ea(e,t,r){let n=r?.label??"invokeExecutionRef",s;try{s=ss(e.argsMassaging,Ia(e,t),n);}catch(c){let d=c instanceof Error?c.message:String(c);return vt(d)}let o=et(e.whatToRun),a=s.headers?{"Content-Type":"application/json",...s.headers}:{"Content-Type":"application/json"},i=s.url??o,u;if(e.howToRun==="http:get"){let c=s.body&&typeof s.body=="object"&&!Array.isArray(s.body)?s.body:t,d=new URLSearchParams(Object.entries(c).filter(([,l])=>l!=null).map(([l,g])=>[l,String(g)]));d.size>0&&(i=`${i}${i.includes("?")?"&":"?"}${d.toString()}`);}else u=JSON.stringify(s.body??t);try{let c=await fetch(i,{method:e.howToRun==="http:get"?"GET":"POST",headers:a,body:u});if(!c.ok){let l=await c.text().catch(()=>"");return vt(`[${n}] HTTP ${c.status}${l?`: ${l}`:""}`)}let d=await c.text();if(!d.trim())return {result:"success",data:{}};try{return ja(Ta(d))}catch{return {result:"success",data:{stdout:d.trim()}}}}catch(c){let d=c instanceof Error?c.message:String(c);return vt(`[${n}] ${d}`)}}var Dd={"local-node":async(e,t,r)=>yt(e,t,r),"local-python":async(e,t,r)=>yt(e,t,r),"local-process":async(e,t,r)=>yt(e,t,r),"built-in":async(e,t,r)=>yt(e,t,r),"http:post":Ea,"http:get":Ea},Ld={"local-node":yt,"local-python":yt,"local-process":yt,"built-in":yt};async function Oa(e,t,r){let n=r?.transports?.[e.howToRun]??Dd[e.howToRun];return n?n(e,t,r):vt(`[${r?.label??"invokeExecutionRef"}] unsupported howToRun: ${e.howToRun}`)}function os(e,t,r){let n=r?.syncTransports?.[e.howToRun]??Ld[e.howToRun];return n?n(e,t,r):vt(`[${r?.label??"invokeExecutionRefSync"}] unsupported sync howToRun: ${e.howToRun}`)}function Bd(e){return {invoke(t,r){return Oa(t,r,e)},invokeSync(t,r){return os(t,r,e)}}}function Vd(e,t,r){return os(e,t,r)}async function Ud(e,t){let r={...t,whatToRun:et(e.whatToRun)},n=ns(e.argsMassaging,r,"_invokeTaskExecutorHttp"),s=n.url??et(e.whatToRun),o=n.body?n.body:Md(t,e.extra),a={"Content-Type":"application/json"},i=n.headers?{...a,...n.headers}:a,u=await fetch(s,{method:e.howToRun==="http:get"?"GET":"POST",headers:i,body:JSON.stringify(o)});if(!u.ok){let d=await u.text().catch(()=>"");return {status:"error",error:`HTTP ${u.status}: ${d}`}}let c=await u.json().catch(()=>null);return c&&typeof c.status=="string"?c:{status:"success"}}function Pa(e,t,r){if(e.howToRun==="http:post"||e.howToRun==="http:get"){Ud(e,t).catch(i=>{console.error(`[dispatchTaskExecutorDetached] HTTP dispatch failed: ${i.message}`);});return}let{command:s,baseArgs:o}=Aa(e,r),a=Fd(t,e.extra);Yr({command:s,args:[...o,...a]});}function dt(e,t){if(process.platform!=="win32"){$__namespace.renameSync(e,t);return}let r=[10,20,40,80,160];for(let n=0;n<=r.length;n++)try{$__namespace.renameSync(e,t);return}catch(s){let o=s.code;if((o==="EPERM"||o==="EBUSY")&&n<r.length){Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,r[n]);continue}throw s}}function Wt(e){function t(s){return oe__namespace.join(e,...s.split("/"))}function r(s){return oe__namespace.relative(e,s).replace(/\\/g,"/")}function n(s,o){if($__namespace.existsSync(s))for(let a of $__namespace.readdirSync(s,{withFileTypes:true})){let i=oe__namespace.join(s,a.name);if(a.isDirectory()){n(i,o);continue}a.isFile()&&o.push(r(i));}}return {read(s){let o=t(s);if(!$__namespace.existsSync(o))return null;try{return $__namespace.readFileSync(o,"utf-8")}catch{return null}},write(s,o){let a=t(s),i=`${a}.${process.pid}.${crypto.randomUUID()}.tmp`;$__namespace.mkdirSync(oe__namespace.dirname(a),{recursive:true}),$__namespace.writeFileSync(i,o,"utf-8"),dt(i,a);},exists(s){return $__namespace.existsSync(t(s))},remove(s){let o=t(s);try{$__namespace.existsSync(o)&&$__namespace.unlinkSync(o);}catch{}},readBytes(s){let o=t(s);if(!$__namespace.existsSync(o))return null;try{return new Uint8Array($__namespace.readFileSync(o))}catch{return null}},writeBytes(s,o){let a=t(s),i=`${a}.${process.pid}.${crypto.randomUUID()}.tmp`;$__namespace.mkdirSync(oe__namespace.dirname(a),{recursive:true}),$__namespace.writeFileSync(i,Buffer.from(o)),dt(i,a);},listKeys(s){let o=[];n(e,o);let a=o.sort();return s?a.filter(i=>i.startsWith(s)):a},stat(s){let o=t(s);if(!$__namespace.existsSync(o))return null;try{let a=$__namespace.statSync(o);return {key:s,size:Number(a.size||0),updatedAt:new Date(a.mtimeMs).toISOString()}}catch{return null}},keyRef(s){return {kind:"fs-path",value:t(s)}}}}function us(){return {read(e){if(!$__namespace.existsSync(e))return null;try{return $__namespace.readFileSync(e,"utf-8")}catch{return null}},write(e,t){let r=`${e}.${process.pid}.${crypto.randomUUID()}.tmp`;$__namespace.mkdirSync(oe__namespace.dirname(e),{recursive:true}),$__namespace.writeFileSync(r,t,"utf-8"),dt(r,e);},exists(e){return $__namespace.existsSync(e)},remove(e){try{$__namespace.existsSync(e)&&$__namespace.unlinkSync(e);}catch{}},readBytes(e){if(!$__namespace.existsSync(e))return null;try{return new Uint8Array($__namespace.readFileSync(e))}catch{return null}},writeBytes(e,t){let r=`${e}.${process.pid}.${crypto.randomUUID()}.tmp`;$__namespace.mkdirSync(oe__namespace.dirname(e),{recursive:true}),$__namespace.writeFileSync(r,Buffer.from(t)),dt(r,e);},stat(e){if(!$__namespace.existsSync(e))return null;try{let t=$__namespace.statSync(e);return {key:e,size:Number(t.size||0),updatedAt:new Date(t.mtimeMs).toISOString()}}catch{return null}},listKeys(e){return []}}}var as="__scratch-marker",is="__scratch-config.json",Jd=1440*60*1e3,zd=720*60*1e3,Hd=500;function Na(e,t){if(!e)return t;let r=e.replace(/[^A-Za-z0-9._-]/g,"_");return r.length>0?r:t}function tn(e){$__namespace.mkdirSync(e,{recursive:true});let t=oe__namespace.join(e,as),r=oe__namespace.join(e,is),n=!$__namespace.existsSync(t);if(n)try{$__namespace.writeFileSync(t,`scratch-store
11
11
  ${new Date().toISOString()}
12
- `,"utf-8");}catch{}function s(){if(!$__namespace.existsSync(r))return {};try{let c=$__namespace.readFileSync(r,"utf-8"),d=JSON.parse(c);return d&&typeof d=="object"&&!Array.isArray(d)?d:{}}catch{return {}}}function o(c){let d=`${r}.${process.pid}.${crypto.randomUUID()}.tmp`;try{$__namespace.writeFileSync(d,JSON.stringify(c,null,2),"utf-8"),ut(d,r);}catch{}}if(n){let c=s();typeof c["retention.lastSweepAt"]!="number"&&(c["retention.lastSweepAt"]=Date.now(),o(c));}function a(){if(!$__namespace.existsSync(t))return;let c=s(),d=typeof c["retention.maxAgeMs"]=="number"?c["retention.maxAgeMs"]:Jd,l=typeof c["retention.sweepIntervalMs"]=="number"?c["retention.sweepIntervalMs"]:zd;if(d<=0||l<=0)return;let g=typeof c["retention.lastSweepAt"]=="number"?c["retention.lastSweepAt"]:0,v=Date.now();if(v-g<l)return;c["retention.lastSweepAt"]=v,o(c);let f=v;try{let m=$__namespace.readdirSync(e,{withFileTypes:!0});for(let b of m){if(Date.now()-f>Hd)break;if(!b.isFile()||b.name===as||b.name===is)continue;let C=se__namespace.join(e,b.name);try{let F=$__namespace.statSync(C);if(v-F.mtimeMs>d)try{$__namespace.unlinkSync(C);}catch{}}catch{}}}catch{}}function i(c,d){let l=Na(c,"scratch"),g=Na(d,".json"),v=g.startsWith(".")?g:`.${g}`,f=`${l}-${Date.now()}-${crypto.randomUUID().slice(0,8)}${v}`;return se__namespace.join(e,f)}function u(c,d){let l=`${c}.${process.pid}.${crypto.randomUUID()}.tmp`;$__namespace.mkdirSync(se__namespace.dirname(c),{recursive:true}),$__namespace.writeFileSync(l,d,"utf-8"),ut(l,c);}return {read(c){if(!$__namespace.existsSync(c))return null;try{return $__namespace.readFileSync(c,"utf-8")}catch{return null}},write(c,d){u(c,d);try{a();}catch{}},exists(c){return $__namespace.existsSync(c)},remove(c){try{$__namespace.existsSync(c)&&$__namespace.unlinkSync(c);}catch{}},readBytes(c){if(!$__namespace.existsSync(c))return null;try{return new Uint8Array($__namespace.readFileSync(c))}catch{return null}},writeBytes(c,d){let l=`${c}.${process.pid}.${crypto.randomUUID()}.tmp`;$__namespace.mkdirSync(se__namespace.dirname(c),{recursive:true}),$__namespace.writeFileSync(l,Buffer.from(d)),ut(l,c);try{a();}catch{}},stat(c){if(!$__namespace.existsSync(c))return null;try{let d=$__namespace.statSync(c);return {key:c,size:Number(d.size||0),updatedAt:new Date(d.mtimeMs).toISOString()}}catch{return null}},listKeys(c){try{let d=$__namespace.readdirSync(e,{withFileTypes:!0}),l=[];for(let g of d){if(!g.isFile()||g.name===as||g.name===is)continue;let v=se__namespace.join(e,g.name);(!c||v.startsWith(c))&&l.push(v);}return l.sort()}catch{return []}},getUniqueKey(c,d){return i(c,d)},create(c,d,l){let g=i(d,l);u(g,c);try{a();}catch{}return g},keyRef(c){return {kind:"fs-path",value:c}},config:{get(c){return s()[c]??null},set(c,d){let l=s();d==null?delete l[c]:l[c]=d,o(l);}}}}var Wd="__archive-marker",Yd="__archive-config.json",Zr="streams",en="blobs",Xd=500;function qa(e){let t=e.replace(/[^A-Za-z0-9._-]/g,"_");if(!t)throw new Error("Archive segment name cannot be empty after sanitization");return t}function rn(e){$__namespace.mkdirSync(e,{recursive:true}),$__namespace.mkdirSync(se__namespace.join(e,Zr),{recursive:true}),$__namespace.mkdirSync(se__namespace.join(e,en),{recursive:true});let t=se__namespace.join(e,Wd),r=se__namespace.join(e,Yd);if(!$__namespace.existsSync(t))try{$__namespace.writeFileSync(t,`archive-store
12
+ `,"utf-8");}catch{}function s(){if(!$__namespace.existsSync(r))return {};try{let c=$__namespace.readFileSync(r,"utf-8"),d=JSON.parse(c);return d&&typeof d=="object"&&!Array.isArray(d)?d:{}}catch{return {}}}function o(c){let d=`${r}.${process.pid}.${crypto.randomUUID()}.tmp`;try{$__namespace.writeFileSync(d,JSON.stringify(c,null,2),"utf-8"),dt(d,r);}catch{}}if(n){let c=s();typeof c["retention.lastSweepAt"]!="number"&&(c["retention.lastSweepAt"]=Date.now(),o(c));}function a(){if(!$__namespace.existsSync(t))return;let c=s(),d=typeof c["retention.maxAgeMs"]=="number"?c["retention.maxAgeMs"]:Jd,l=typeof c["retention.sweepIntervalMs"]=="number"?c["retention.sweepIntervalMs"]:zd;if(d<=0||l<=0)return;let g=typeof c["retention.lastSweepAt"]=="number"?c["retention.lastSweepAt"]:0,v=Date.now();if(v-g<l)return;c["retention.lastSweepAt"]=v,o(c);let f=v;try{let m=$__namespace.readdirSync(e,{withFileTypes:!0});for(let b of m){if(Date.now()-f>Hd)break;if(!b.isFile()||b.name===as||b.name===is)continue;let C=oe__namespace.join(e,b.name);try{let q=$__namespace.statSync(C);if(v-q.mtimeMs>d)try{$__namespace.unlinkSync(C);}catch{}}catch{}}}catch{}}function i(c,d){let l=Na(c,"scratch"),g=Na(d,".json"),v=g.startsWith(".")?g:`.${g}`,f=`${l}-${Date.now()}-${crypto.randomUUID().slice(0,8)}${v}`;return oe__namespace.join(e,f)}function u(c,d){let l=`${c}.${process.pid}.${crypto.randomUUID()}.tmp`;$__namespace.mkdirSync(oe__namespace.dirname(c),{recursive:true}),$__namespace.writeFileSync(l,d,"utf-8"),dt(l,c);}return {read(c){if(!$__namespace.existsSync(c))return null;try{return $__namespace.readFileSync(c,"utf-8")}catch{return null}},write(c,d){u(c,d);try{a();}catch{}},exists(c){return $__namespace.existsSync(c)},remove(c){try{$__namespace.existsSync(c)&&$__namespace.unlinkSync(c);}catch{}},readBytes(c){if(!$__namespace.existsSync(c))return null;try{return new Uint8Array($__namespace.readFileSync(c))}catch{return null}},writeBytes(c,d){let l=`${c}.${process.pid}.${crypto.randomUUID()}.tmp`;$__namespace.mkdirSync(oe__namespace.dirname(c),{recursive:true}),$__namespace.writeFileSync(l,Buffer.from(d)),dt(l,c);try{a();}catch{}},stat(c){if(!$__namespace.existsSync(c))return null;try{let d=$__namespace.statSync(c);return {key:c,size:Number(d.size||0),updatedAt:new Date(d.mtimeMs).toISOString()}}catch{return null}},listKeys(c){try{let d=$__namespace.readdirSync(e,{withFileTypes:!0}),l=[];for(let g of d){if(!g.isFile()||g.name===as||g.name===is)continue;let v=oe__namespace.join(e,g.name);(!c||v.startsWith(c))&&l.push(v);}return l.sort()}catch{return []}},getUniqueKey(c,d){return i(c,d)},create(c,d,l){let g=i(d,l);u(g,c);try{a();}catch{}return g},keyRef(c){return {kind:"fs-path",value:c}},config:{get(c){return s()[c]??null},set(c,d){let l=s();d==null?delete l[c]:l[c]=d,o(l);}}}}var Wd="__archive-marker",Yd="__archive-config.json",Zr="streams",en="blobs",Xd=500;function qa(e){let t=e.replace(/[^A-Za-z0-9._-]/g,"_");if(!t)throw new Error("Archive segment name cannot be empty after sanitization");return t}function rn(e){$__namespace.mkdirSync(e,{recursive:true}),$__namespace.mkdirSync(oe__namespace.join(e,Zr),{recursive:true}),$__namespace.mkdirSync(oe__namespace.join(e,en),{recursive:true});let t=oe__namespace.join(e,Wd),r=oe__namespace.join(e,Yd);if(!$__namespace.existsSync(t))try{$__namespace.writeFileSync(t,`archive-store
13
13
  ${new Date().toISOString()}
14
- `,"utf-8");}catch{}function n(){if(!$__namespace.existsSync(r))return {};try{let a=$__namespace.readFileSync(r,"utf-8"),i=JSON.parse(a);return i&&typeof i=="object"&&!Array.isArray(i)?i:{}}catch{return {}}}function s(a){let i=`${r}.${process.pid}.${crypto.randomUUID()}.tmp`;try{$__namespace.writeFileSync(i,JSON.stringify(a,null,2),"utf-8"),ut(i,r);}catch{}}function o(){if(!$__namespace.existsSync(t))return;let a=n(),i=typeof a["retention.maxAgeMs"]=="number"?a["retention.maxAgeMs"]:0,u=typeof a["retention.sweepIntervalMs"]=="number"?a["retention.sweepIntervalMs"]:0;if(i<=0||u<=0)return;let c=typeof a["retention.lastSweepAt"]=="number"?a["retention.lastSweepAt"]:0,d=Date.now();if(d-c<u)return;a["retention.lastSweepAt"]=d,s(a);let l=d,g=v=>{let f;try{f=$__namespace.readdirSync(v,{withFileTypes:!0});}catch{return}for(let m of f){if(Date.now()-l>Xd)return;let b=se__namespace.join(v,m.name);if(m.isDirectory()){g(b);continue}if(m.isFile())try{let C=$__namespace.statSync(b);if(d-C.mtimeMs>i)try{$__namespace.unlinkSync(b);}catch{}}catch{}}};g(se__namespace.join(e,Zr)),g(se__namespace.join(e,en));}return {stream(a){let i=qa(a),u=se__namespace.join(e,Zr,`${i}.jsonl`),c=ds(u);return {append(d){let l=c.append(d);try{o();}catch{}return l},readAll:()=>c.readAll(),readAfter:d=>c.readAfter(d),clear:()=>{c.clear&&c.clear();}}},blob(a){let i=qa(a),u=se__namespace.join(e,en,i);$__namespace.mkdirSync(u,{recursive:true});let c=Wt(u);return {read:d=>c.read(d),write:(d,l)=>{c.write(d,l);try{o();}catch{}},exists:d=>c.exists(d),remove:d=>c.remove(d),readBytes:c.readBytes?d=>c.readBytes(d):void 0,writeBytes:c.writeBytes?(d,l)=>{c.writeBytes(d,l);try{o();}catch{}}:void 0,listKeys:d=>c.listKeys(d),stat:c.stat?d=>c.stat(d):void 0}},listStreams(a){let i=se__namespace.join(e,Zr);try{return $__namespace.readdirSync(i,{withFileTypes:!0}).filter(u=>u.isFile()&&u.name.endsWith(".jsonl")).map(u=>u.name.slice(0,-6)).filter(u=>!a||u.startsWith(a)).sort()}catch{return []}},listBlobs(a){let i=se__namespace.join(e,en);try{return $__namespace.readdirSync(i,{withFileTypes:!0}).filter(u=>u.isDirectory()).map(u=>u.name).filter(u=>!a||u.startsWith(a)).sort()}catch{return []}},config:{get(a){return n()[a]??null},set(a,i){let u=n();i==null?delete u[a]:u[a]=i,s(u);}}}}function nn(e){function t(n){return se__namespace.join(e,...n.split("/"))+".json"}function r(n,s,o,a){if($__namespace.existsSync(n))for(let i of $__namespace.readdirSync(n,{withFileTypes:true})){let u=s?`${s}/${i.name}`:i.name;if(i.isDirectory()){r(se__namespace.join(n,i.name),u,o,a);continue}if(!i.isFile()||!i.name.endsWith(".json"))continue;let c=u.replace(/\.json$/,"");(!o||c.startsWith(o))&&a.push(c);}}return {read(n){let s=t(n);if(!$__namespace.existsSync(s))return null;try{return JSON.parse($__namespace.readFileSync(s,"utf-8"))}catch{return null}},write(n,s){let o=t(n),a=`${o}.${process.pid}.${crypto.randomUUID()}.tmp`;$__namespace.mkdirSync(se__namespace.dirname(o),{recursive:true}),$__namespace.writeFileSync(a,JSON.stringify(s,null,2),"utf-8"),ut(a,o);},delete(n){let s=t(n);try{$__namespace.existsSync(s)&&$__namespace.unlinkSync(s);}catch{}},listKeys(n){let s=[];return r(e,"",n,s),s.sort()}}}function ds(e){function t(){if(!$__namespace.existsSync(e))return [];let r=$__namespace.readFileSync(e,"utf-8").trim();return r?r.split(`
15
- `).filter(Boolean).map(n=>JSON.parse(n)):[]}return {append(r){let n={id:crypto.randomUUID(),payload:r};return $__namespace.mkdirSync(se__namespace.dirname(e),{recursive:true}),$__namespace.appendFileSync(e,JSON.stringify(n)+`
16
- `,"utf-8"),n},readAll(){return t()},readAfter(r){let n=t();if(!r)return {entries:n,newCursor:n.length>0?n[n.length-1].id:null};let s=n.findIndex(a=>a.id===r),o=s===-1?n:n.slice(s+1);return {entries:o,newCursor:o.length>0?o[o.length-1].id:r}},clear(){$__namespace.existsSync(e)&&$__namespace.truncateSync(e,0);}}}function cs(e){if(e==null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return `[${e.map(cs).join(",")}]`;let t=e;return `{${Object.keys(t).sort().map(n=>`${JSON.stringify(n)}:${cs(t[n])}`).join(",")}}`}function Fa(e){return crypto.createHash("sha256").update(cs(e)).digest("hex")}function Ma(e){let t=se__namespace.join(e,"board-journal.jsonl");return {readAllEntries(){if(!$__namespace.existsSync(t))return [];let r=$__namespace.readFileSync(t,"utf-8").trim();return r?r.split(`
14
+ `,"utf-8");}catch{}function n(){if(!$__namespace.existsSync(r))return {};try{let a=$__namespace.readFileSync(r,"utf-8"),i=JSON.parse(a);return i&&typeof i=="object"&&!Array.isArray(i)?i:{}}catch{return {}}}function s(a){let i=`${r}.${process.pid}.${crypto.randomUUID()}.tmp`;try{$__namespace.writeFileSync(i,JSON.stringify(a,null,2),"utf-8"),dt(i,r);}catch{}}function o(){if(!$__namespace.existsSync(t))return;let a=n(),i=typeof a["retention.maxAgeMs"]=="number"?a["retention.maxAgeMs"]:0,u=typeof a["retention.sweepIntervalMs"]=="number"?a["retention.sweepIntervalMs"]:0;if(i<=0||u<=0)return;let c=typeof a["retention.lastSweepAt"]=="number"?a["retention.lastSweepAt"]:0,d=Date.now();if(d-c<u)return;a["retention.lastSweepAt"]=d,s(a);let l=d,g=v=>{let f;try{f=$__namespace.readdirSync(v,{withFileTypes:!0});}catch{return}for(let m of f){if(Date.now()-l>Xd)return;let b=oe__namespace.join(v,m.name);if(m.isDirectory()){g(b);continue}if(m.isFile())try{let C=$__namespace.statSync(b);if(d-C.mtimeMs>i)try{$__namespace.unlinkSync(b);}catch{}}catch{}}};g(oe__namespace.join(e,Zr)),g(oe__namespace.join(e,en));}return {stream(a){let i=qa(a),u=oe__namespace.join(e,Zr,`${i}.jsonl`),c=ds(u);return {append(d){let l=c.append(d);try{o();}catch{}return l},readAll:()=>c.readAll(),readAfter:d=>c.readAfter(d),clear:()=>{c.clear&&c.clear();}}},blob(a){let i=qa(a),u=oe__namespace.join(e,en,i);$__namespace.mkdirSync(u,{recursive:true});let c=Wt(u);return {read:d=>c.read(d),write:(d,l)=>{c.write(d,l);try{o();}catch{}},exists:d=>c.exists(d),remove:d=>c.remove(d),readBytes:c.readBytes?d=>c.readBytes(d):void 0,writeBytes:c.writeBytes?(d,l)=>{c.writeBytes(d,l);try{o();}catch{}}:void 0,listKeys:d=>c.listKeys(d),stat:c.stat?d=>c.stat(d):void 0}},listStreams(a){let i=oe__namespace.join(e,Zr);try{return $__namespace.readdirSync(i,{withFileTypes:!0}).filter(u=>u.isFile()&&u.name.endsWith(".jsonl")).map(u=>u.name.slice(0,-6)).filter(u=>!a||u.startsWith(a)).sort()}catch{return []}},listBlobs(a){let i=oe__namespace.join(e,en);try{return $__namespace.readdirSync(i,{withFileTypes:!0}).filter(u=>u.isDirectory()).map(u=>u.name).filter(u=>!a||u.startsWith(a)).sort()}catch{return []}},config:{get(a){return n()[a]??null},set(a,i){let u=n();i==null?delete u[a]:u[a]=i,s(u);}}}}function nn(e){function t(n){return oe__namespace.join(e,...n.split("/"))+".json"}function r(n,s,o,a){if($__namespace.existsSync(n))for(let i of $__namespace.readdirSync(n,{withFileTypes:true})){let u=s?`${s}/${i.name}`:i.name;if(i.isDirectory()){r(oe__namespace.join(n,i.name),u,o,a);continue}if(!i.isFile()||!i.name.endsWith(".json"))continue;let c=u.replace(/\.json$/,"");(!o||c.startsWith(o))&&a.push(c);}}return {read(n){let s=t(n);if(!$__namespace.existsSync(s))return null;try{return JSON.parse($__namespace.readFileSync(s,"utf-8"))}catch{return null}},write(n,s){let o=t(n),a=`${o}.${process.pid}.${crypto.randomUUID()}.tmp`;$__namespace.mkdirSync(oe__namespace.dirname(o),{recursive:true}),$__namespace.writeFileSync(a,JSON.stringify(s,null,2),"utf-8"),dt(a,o);},delete(n){let s=t(n);try{$__namespace.existsSync(s)&&$__namespace.unlinkSync(s);}catch{}},listKeys(n){let s=[];return r(e,"",n,s),s.sort()}}}function ds(e){function t(){if(!$__namespace.existsSync(e))return [];let r=$__namespace.readFileSync(e,"utf-8").trim();return r?r.split(`
15
+ `).filter(Boolean).map(n=>JSON.parse(n)):[]}return {append(r){let n={id:crypto.randomUUID(),payload:r};return $__namespace.mkdirSync(oe__namespace.dirname(e),{recursive:true}),$__namespace.appendFileSync(e,JSON.stringify(n)+`
16
+ `,"utf-8"),n},readAll(){return t()},readAfter(r){let n=t();if(!r)return {entries:n,newCursor:n.length>0?n[n.length-1].id:null};let s=n.findIndex(a=>a.id===r),o=s===-1?n:n.slice(s+1);return {entries:o,newCursor:o.length>0?o[o.length-1].id:r}},clear(){$__namespace.existsSync(e)&&$__namespace.truncateSync(e,0);}}}function cs(e){if(e==null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return `[${e.map(cs).join(",")}]`;let t=e;return `{${Object.keys(t).sort().map(n=>`${JSON.stringify(n)}:${cs(t[n])}`).join(",")}}`}function Fa(e){return crypto.createHash("sha256").update(cs(e)).digest("hex")}function Ma(e){let t=oe__namespace.join(e,"board-journal.jsonl");return {readAllEntries(){if(!$__namespace.existsSync(t))return [];let r=$__namespace.readFileSync(t,"utf-8").trim();return r?r.split(`
17
17
  `).filter(Boolean).map(n=>JSON.parse(n)):[]},appendEntry(r){$__namespace.appendFileSync(t,JSON.stringify(r)+`
18
- `,"utf-8");},generateId(){return crypto.randomUUID()}}}function Da(e){return {tryAcquire(){try{if(!$__namespace.existsSync(e)){$__namespace.mkdirSync(se__namespace.dirname(e),{recursive:!0});try{$__namespace.writeFileSync(e,"{}",{flag:"wx"});}catch{}}return properLockfile.lockSync(e,{retries:0})}catch{return null}}}}var La={$schema:"http://json-schema.org/draft-07/schema#",$id:"https://nsreehari.github.io/boards/live-cards.schema.json",definitions:{bind_ref:{description:"A card data path reference, e.g. 'card_data.raw_quotes' or 'requires.upstream'",type:"string",pattern:"^(card_data|requires|fetched_sources|computed_values)(\\.|$)"},bind_or_literal:{description:"A literal value or a bind reference object",oneOf:[{type:"string"},{type:"number"},{type:"boolean"},{type:"array"},{type:"object",properties:{bind:{$ref:"#/definitions/bind_ref"}},required:["bind"]}]},compute_expr:{description:"A declarative JSON compute expression",type:"object",required:["fn"],properties:{fn:{type:"string",description:"Function name from the built-in vocabulary",enum:["sum","avg","min","max","count","first","last","add","sub","mul","div","round","abs","mod","gt","gte","lt","lte","eq","neq","if","and","or","not","concat","upper","lower","template","filter","pluck","map","sort","slice","flat","unique","group","get","default","now","diff_days","format_date"]},input:{description:"card_data.path, literal, array of inputs, or nested compute_expr",oneOf:[{type:"string"},{type:"number"},{type:"boolean"},{type:"array"},{$ref:"#/definitions/compute_expr"}]},field:{type:"string",description:"For pluck/sum/group \u2014 the object key to extract"},where:{$ref:"#/definitions/compute_expr",description:"For filter \u2014 predicate expression ($ = current item)"},cond:{$ref:"#/definitions/compute_expr",description:"For if \u2014 condition expression"},then:{description:"For if \u2014 value when cond is truthy"},else:{description:"For if \u2014 value when cond is falsy"},format:{type:"string",description:"For format_date \u2014 date format string"}}},meta:{type:"object",properties:{title:{type:"string"},tags:{type:"array",items:{type:"string"}}}},requires:{type:"array",items:{type:"string"},description:"IDs of upstream nodes this node depends on"},provides:{type:"array",items:{type:"object",required:["bindTo","ref"],properties:{bindTo:{type:"string",description:"Token name published downstream"},ref:{type:"string",description:"Path to read value from (card_data.*, requires.*, fetched_sources.*, computed_values.*)"}}},description:"Explicit bindings exposing computed or card_data values downstream as named tokens"},compute_step:{description:"A single ordered compute step: reads card_data.*/requires.*/computed_values.*, writes to computed_values[bindTo]",type:"object",required:["bindTo","expr"],properties:{bindTo:{type:"string",description:"Key in computed_values to write result"},expr:{type:"string",description:"JSONata expression evaluated against { card_data, requires, fetched_sources, computed_values }"}}},source_def:{description:"One source entry. The engine requires 'bindTo' (compute namespace key) and 'outputFile' (delivery signal path). bindTo and outputFile must be unique across all source_defs in a card. Every other property is yours \u2014 add whatever your task-executor needs: kind, url, headers, mailbox, channel, model, query, etc. The full object is passed verbatim as the --in JSON to the executor.",type:"object",required:["bindTo","outputFile"],additionalProperties:true,properties:{bindTo:{type:"string",description:"Key under fetched_sources.* available in compute expressions"},outputFile:{type:"string",description:"Board-relative path the executor writes its JSON result to. Presence of this file signals delivery."},projections:{type:"object",description:"Named data projections from card_data or requires, evaluated before the executor is called. Each key is a ref name; each value is a JSONata expression rooted at card_data or requires. The resolved values are passed to the executor as _projections. fetched_sources, computed_values, and source_defs are not accessible here \u2014 sources run before those exist.",additionalProperties:{type:"string"}},optionalForCompletionGating:{type:"boolean",default:false,description:"When true this source does not gate card completion. Default false when absent, so source_defs are completion-gating by default."},timeout:{type:"integer",minimum:0,default:12e4,description:"Executor/script timeout in ms. Default: 120 000 (2 min)."},script:{type:"string",description:"Legacy direct-run: shell command executed when no .task-executor is registered. stdout is captured as the result."}}},render_element:{type:"object",required:["kind"],properties:{id:{type:"string",description:"Optional element ID for targeted updates"},kind:{enum:["metric","table","editable-table","chart","form","filter","list","notes","todo","alert","narrative","badge","text","markdown","ref","custom","actions"]},label:{type:"string",description:"Heading above this element"},className:{type:"string",description:"Bootstrap grid class, e.g. 'col-12 col-md-6'"},visible:{type:"string",description:"card_data/requires/fetched_sources/computed_values path \u2014 element shown only if truthy"},data:{type:"object",properties:{bind:{$ref:"#/definitions/bind_ref",description:"card_data/requires/fetched_sources/computed_values path to read data from"},writeTo:{$ref:"#/definitions/bind_ref",description:"card_data path for user input (form, filter, todo, notes)"},columns:{type:"array",items:{type:"string"},description:"table: visible columns"},maxRows:{type:"integer",description:"table/list: max rows to display"},sortable:{type:"boolean",default:true,description:"table: enable click-to-sort"},placeholder:{type:"string",description:"Empty-state message"},chartType:{enum:["bar","line","pie","doughnut"]},chartOptions:{type:"object",description:"Chart.js options passthrough"},fields:{type:"object",description:"JSON Schema for form/filter fields"},thresholds:{type:"object",properties:{green:{type:"string"},amber:{type:"string"}}},colorMap:{type:"object",description:"badge: value \u2192 Bootstrap color"},style:{enum:["heading","muted","default"],description:"text: display style"},upload:{type:"boolean",default:true,description:"file-upload: show drop zone (false = read-only file list)"},accept:{type:"array",items:{type:"string"},description:"file-upload: allowed extensions"},multiple:{type:"boolean",default:true,description:"file-upload: allow multiple files"},fileAttach:{type:"boolean",default:false,description:"chat: enable inline file attachments"},fileAccept:{type:"array",items:{type:"string"},description:"chat: allowed attachment extensions"},buttons:{type:"array",description:"actions: button definitions",items:{type:"object",required:["id","label"],properties:{id:{type:"string"},label:{type:"string"},style:{type:"string",description:"Bootstrap button variant, e.g. 'success', 'outline-danger'"},size:{type:"string",default:"sm"},disabled:{oneOf:[{type:"boolean"},{type:"string",description:"card_data/requires/fetched_sources/computed_values path \u2014 truthy = disabled"}]}}}}}}}},view:{type:"object",required:["elements"],properties:{elements:{type:"array",minItems:1,items:{$ref:"#/definitions/render_element"}},layout:{type:"object",properties:{board:{type:"object",properties:{col:{type:"integer",minimum:1,maximum:12},order:{type:"integer"}}},canvas:{type:"object",properties:{x:{type:"number"},y:{type:"number"},w:{type:"number"},h:{type:"number"}}}}},features:{type:"object",properties:{chat:{type:"boolean",default:false},notes:{type:"boolean",default:false},refresh:{type:"boolean",default:true}}}}}},title:"LiveCard",description:"A unified card node. Behavior depends on which sections are present (source_defs, compute, view, etc.)",type:"object",required:["id"],additionalProperties:false,properties:{id:{type:"string"},requires:{$ref:"#/definitions/requires"},provides:{$ref:"#/definitions/provides"},meta:{$ref:"#/definitions/meta"},view:{$ref:"#/definitions/view"},card_data:{type:"object",description:"Authored card data and runtime metadata. Includes uploaded-file metadata maintained by host handlers and inference evaluation results.",properties:{files:{type:"array",description:"Optional uploaded-file metadata maintained by host handlers. Stored name is normalized and serial-prefixed (for example 001-my_file.pdf).",items:{type:"object",required:["name","stored_name"],properties:{name:{type:"string",minLength:1},stored_name:{type:"string",minLength:5,maxLength:32,pattern:"^[0-9]{3,}-[a-z0-9._-]+$"},size:{oneOf:[{type:"integer",minimum:0},{type:"null"}]},mime_type:{type:"string"},path:{type:"string",pattern:"^[^\\s]+/files/[0-9]{3,}-[a-z0-9._-]+$"},uploaded_at:{type:"string",format:"date-time"},chat:{type:"boolean",description:"Whether this file entry is associated with a chat interaction"}},additionalProperties:false}}},additionalProperties:true},source_defs:{type:"array",description:"Source entries. Each entry is passed verbatim to the board's .task-executor (registered via init --task-executor) as the --in JSON file. The executor fetches/generates the data and writes JSON to --out. If no executor is registered, the built-in executor runs the entry's 'cli' command directly. Sources gate completion by default. Set optionalForCompletionGating: true for enrichment-only source_defs that should not block task-completed.",items:{$ref:"#/definitions/source_def"}},compute:{type:"array",description:"Ordered array of compute steps. Each reads card_data.*/requires.*/fetched_sources.*/computed_values.* and writes to ephemeral computed_values[bindTo].",items:{$ref:"#/definitions/compute_step"}}}};var hu=hd(pu());var xh=module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('board-live-cards-node.cjs', document.baseURI).href))),Ah=xh("./jsonata-sync.cjs"),Dn=null;var mu=/\b(card_data|requires|fetched_sources|computed_values|source_defs)\b/g,Th=/^\s*(card_data|requires|fetched_sources|computed_values|source_defs)(\.|$)/;function Ih(e){let t=new Set,r;for(mu.lastIndex=0;(r=mu.exec(e))!==null;)t.add(r[1]);return t}function yu(e){let t=Th.exec(e);return t?t[1]:null}function gu(e,t,r,n){try{Ah(e);}catch(o){let a=o instanceof Error?o.message:String(o);n.push(`${t}: invalid JSONata expression (${a})`);return}let s=Ih(e);for(let o of s)r.has(o)||n.push(`${t}: disallowed namespace "${o}" in expression`);}function Yo(e,t,r){if(Array.isArray(e)){e.forEach((s,o)=>{Yo(s,`${t}/${o}`,r);});return}if(typeof e=="string"){let s=yu(e);if(!s)return;new Set(["card_data","requires","computed_values"]).has(s)||r.push(`${t}: disallowed namespace "${s}" in view reference`);return}if(!e||typeof e!="object")return;let n=e;for(let[s,o]of Object.entries(n))Yo(o,`${t}/${s}`,r);}function jh(){if(Dn)return Dn;let e=new hu.default({allErrors:true});return $h__default.default(e),Dn=e.compile(La),Dn}function vu(e){let t=jh(),r=t(e),n=(t.errors??[]).map(s=>`${s.instancePath||"/"}: ${s.message??"unknown error"}`);if(e&&typeof e=="object"&&!Array.isArray(e)){let s=e.source_defs;if(Array.isArray(s)){let o=new Set,a=new Set;s.forEach((i,u)=>{if(!i||typeof i!="object"||Array.isArray(i))return;let c=i;typeof c.bindTo=="string"&&c.bindTo&&(o.has(c.bindTo)&&n.push(`/source_defs/${u}/bindTo: bindTo "${c.bindTo}" must be unique across all source_defs`),o.add(c.bindTo)),typeof c.outputFile=="string"&&c.outputFile&&(a.has(c.outputFile)&&n.push(`/source_defs/${u}/outputFile: outputFile "${c.outputFile}" must be unique across all source_defs`),a.add(c.outputFile));});}}return !r||n.length>0?{ok:false,errors:n}:{ok:true,errors:[]}}function Su(e){let t=[];if(!e||typeof e!="object"||Array.isArray(e))return {ok:true,errors:[]};let r=e,n=r.compute;Array.isArray(n)&&n.forEach((c,d)=>{if(!c||typeof c!="object"||Array.isArray(c))return;let l=c.expr;typeof l!="string"||l.trim().length===0||gu(l,`/compute/${d}/expr`,new Set(["card_data","requires","fetched_sources","computed_values"]),t);});let s=new Set(["card_data","requires","fetched_sources","computed_values"]),o=r.provides;Array.isArray(o)&&o.forEach((c,d)=>{if(!c||typeof c!="object"||Array.isArray(c))return;let l=c.ref;if(typeof l!="string"||l.trim().length===0)return;let g=yu(l);g===null?t.push(`/provides/${d}/ref: path "${l}" must start with a valid namespace (${[...s].join(", ")})`):s.has(g)||t.push(`/provides/${d}/ref: disallowed namespace "${g}" in path "${l}" (valid: ${[...s].join(", ")})`);});let a=r.view;a&&typeof a=="object"&&!Array.isArray(a)&&Yo(a,"/view",t);let i=new Set(["card_data","requires"]),u=r.source_defs;return Array.isArray(u)&&u.forEach((c,d)=>{if(!c||typeof c!="object"||Array.isArray(c))return;let l=c.projections;if(!(!l||typeof l!="object"||Array.isArray(l)))for(let[g,v]of Object.entries(l))typeof v!="string"||v.trim().length===0||gu(v,`/source_defs/${d}/projections/${g}`,i,t);}),{ok:t.length===0,errors:t}}function Xo(e){let t=vu(e);if(!t.ok)return t;let r=Su(e);return r.ok?{ok:true,errors:[]}:{ok:false,errors:r.errors}}function wu(e){return String(e).replace(/[^a-zA-Z0-9_-]/g,"_")}function ku(e){let t=e.payload??{};return {id:e.id,role:typeof t.role=="string"?t.role:"system",text:typeof t.text=="string"?t.text:"",files:Array.isArray(t.files)?t.files:[],turn:typeof t.turn=="string"?t.turn:"",updated_at:typeof t.updated_at=="string"?t.updated_at:""}}function Qo(e,t){let r=s=>`chats/${wu(s)}/processing`,n=s=>`chats/${wu(s)}/config`;return {append(s,o,a,i=[],u=""){return e(s).append({role:o,text:a,files:i,turn:u,updated_at:new Date().toISOString()}).id},readAll(s){return e(s).readAll().map(ku)},readAfter(s,o){let a=e(s).readAfter(o);return {records:a.entries.map(ku),cursor:a.newCursor}},clear(s){e(s).clear?.();},setProcessing(s,o){o?t.write(r(s),true):t.delete(r(s));},isProcessing(s){return t.read(r(s))===true},getConfig(s){return t.read(n(s))??{}},setConfig(s,o){let a=t.read(n(s))??{};t.write(n(s),{...a,...o});}}}function Oh(){let e=globalThis.crypto;return typeof e?.randomUUID=="function"?String(e.randomUUID()):`id-${Date.now()}-${Math.random().toString(36).slice(2)}`}function Ph(){let e=new Map,t=new Map;function r(n){return e.has(n)||e.set(n,[]),e.get(n)}return {append(n,s,o,a=[],i=""){let u={id:Oh(),role:s,text:o,files:a,turn:i,updated_at:new Date().toISOString()};return r(n).push(u),u.id},readAll(n){return r(n).slice()},readAfter(n,s){let o=r(n);if(!s)return {records:o.slice(),cursor:o.length>0?o[o.length-1].id:null};let a=o.findIndex(u=>u.id===s),i=a===-1?o.slice():o.slice(a+1);return {records:i,cursor:i.length>0?i[i.length-1].id:s}},clear(n){e.set(n,[]);},setProcessing(n,s){s?t.set(`p:${n}`,true):t.delete(`p:${n}`);},isProcessing(n){return t.get(`p:${n}`)===true},getConfig(n){return t.get(`c:${n}`)??{}},setConfig(n,s){let o=t.get(`c:${n}`)??{};t.set(`c:${n}`,{...o,...s});}}}var Ct={RUNNING:"running",COMPLETED:"completed",FAILED:"failed",INACTIVATED:"inactivated"};function Be(e){return e?Array.isArray(e.provides)?e.provides:[]:[]}function $t(e){return e?Array.isArray(e.requires)?e.requires:[]:[]}function bu(e){return e.tasks??{}}function Zo(e){return e?e.status===Ct.FAILED||e.status===Ct.INACTIVATED:false}function Ru(e,t){return e.refreshStrategy??t?.refreshStrategy??"data-changed"}function _u(e){return e.maxExecutions}function Cu(e,t){let r=new Set;for(let[n,s]of Object.entries(t))if(s.status===Ct.COMPLETED){let o=e.tasks[n];o&&Be(o).forEach(i=>r.add(i));}return Array.from(r)}function $u(e,t){let r={};return e.forEach(n=>{let s=t[n];if(!s)return;Be(s).forEach(a=>{r[a]||(r[a]=[]),r[a].push(n);});}),r}function Eu(e,t,r){let n=e.tasks[t]??Ln(),s={};if(r){let a=r.tasks[t],i=$t(a);for(let u of i)for(let[c,d]of Object.entries(r.tasks))if(Be(d).includes(u)){let l=e.tasks[c];l?.lastDataHash&&(s[u]=l.lastDataHash);break}}let o={...n,status:"running",startedAt:new Date().toISOString(),lastUpdated:new Date().toISOString(),progress:0,error:void 0,startConsumedHashes:s};return {...e,tasks:{...e.tasks,[t]:o},lastUpdated:new Date().toISOString()}}function xu(e,t,r,n,s,o){let a=e.tasks[r]??Ln(),i=t.tasks[r];if(!i)throw new Error(`Task "${r}" not found in graph`);let u;n&&i.on&&i.on[n]?u=i.on[n]:u=Be(i);let c=a.startConsumedHashes?{...a.startConsumedHashes}:{...a.lastConsumedHashes};if(!a.startConsumedHashes){let g=i.requires??[];for(let v of g)for(let[f,m]of Object.entries(t.tasks))if(Be(m).includes(v)){let b=e.tasks[f];b?.lastDataHash&&(c[v]=b.lastDataHash);break}}let d={...a,status:"completed",completedAt:new Date().toISOString(),lastUpdated:new Date().toISOString(),executionCount:a.executionCount+1,lastEpoch:a.executionCount+1,lastDataHash:s,data:o,lastConsumedHashes:c,error:void 0},l=[...new Set([...e.availableOutputs,...u])];return {...e,tasks:{...e.tasks,[r]:d},availableOutputs:l,lastUpdated:new Date().toISOString()}}function Au(e,t,r,n){let s=e.tasks[r]??Ln(),o=t.tasks[r];if(o?.retry){let u=s.retryCount+1;if(u<=o.retry.max_attempts){let c={...s,status:"not-started",retryCount:u,lastUpdated:new Date().toISOString(),error:n};return {...e,tasks:{...e.tasks,[r]:c},lastUpdated:new Date().toISOString()}}}let a={...s,status:"failed",failedAt:new Date().toISOString(),lastUpdated:new Date().toISOString(),error:n,executionCount:s.executionCount+1},i=e.availableOutputs;if(o?.on_failure&&o.on_failure.length>0&&(i=[...new Set([...e.availableOutputs,...o.on_failure])]),o?.circuit_breaker&&a.executionCount>=o.circuit_breaker.max_executions){let u=o.circuit_breaker.on_break;i=[...new Set([...i,...u])];}return {...e,tasks:{...e.tasks,[r]:a},availableOutputs:i,lastUpdated:new Date().toISOString()}}function Tu(e,t,r,n){let s=e.tasks[t]??Ln(),o={...s,progress:typeof n=="number"?n:s.progress,messages:[...s.messages??[],...r?[{message:r,timestamp:new Date().toISOString(),status:s.status}]:[]],lastUpdated:new Date().toISOString()};return {...e,tasks:{...e.tasks,[t]:o},lastUpdated:new Date().toISOString()}}function Iu(e,t){let r=e.tasks[t];if(!r)return e;let n={...r,status:"not-started",startedAt:void 0,completedAt:void 0,failedAt:void 0,error:void 0,data:void 0,progress:null,lastUpdated:new Date().toISOString()};return {...e,tasks:{...e.tasks,[t]:n},lastUpdated:new Date().toISOString()}}function Ln(){return {status:"not-started",executionCount:0,retryCount:0,lastEpoch:0,messages:[],progress:null}}function Bn(e,t){let r=`live-${Date.now()}`,n={};for(let o of Object.keys(e.tasks))n[o]=Ou();let s={status:"running",tasks:n,availableOutputs:[],stuckDetection:{is_stuck:false,stuck_description:null,outputs_unresolvable:[],tasks_blocked:[]},lastUpdated:new Date().toISOString(),executionId:r,executionConfig:{executionMode:e.settings.execution_mode??"eligibility-mode",conflictStrategy:e.settings.conflict_strategy??"alphabetical",completionStrategy:e.settings.completion}};return {config:e,state:s}}function Nh(e,t){let{config:r,state:n}=e;if("executionId"in t&&t.executionId&&t.executionId!==n.executionId)return e;switch(t.type){case "task-started":return {config:r,state:Eu(n,t.taskName,r)};case "task-completed":return {config:r,state:xu(n,r,t.taskName,t.result,t.dataHash,t.data)};case "task-failed":return {config:r,state:Au(n,r,t.taskName,t.error)};case "task-progress":return {config:r,state:Tu(n,t.taskName,t.message,t.progress)};case "task-restart":return {config:r,state:Iu(n,t.taskName)};case "inject-tokens":return {config:r,state:{...n,availableOutputs:[...new Set([...n.availableOutputs,...t.tokens])],lastUpdated:new Date().toISOString()}};case "agent-action":return {config:r,state:Vh(n,t.action)};case "task-upsert":return qh(e,t.taskName,t.taskConfig);case "task-removal":return Fh(e,t.taskName);case "node-requires-add":return Mh(e,t.nodeName,t.tokens);case "node-requires-remove":return Dh(e,t.nodeName,t.tokens);case "node-provides-add":return Lh(e,t.nodeName,t.tokens);case "node-provides-remove":return Bh(e,t.nodeName,t.tokens);default:return e}}function ju(e,t){return t.reduce((r,n)=>Nh(r,n),e)}function qh(e,t,r){let n=!!e.config.tasks[t];return {config:{...e.config,tasks:{...e.config.tasks,[t]:r}},state:{...e.state,tasks:{...e.state.tasks,[t]:n?e.state.tasks[t]:Ou()},lastUpdated:new Date().toISOString()}}}function Fh(e,t){if(!e.config.tasks[t])return e;let{[t]:r,...n}=e.config.tasks,{[t]:s,...o}=e.state.tasks;return {config:{...e.config,tasks:n},state:{...e.state,tasks:o,lastUpdated:new Date().toISOString()}}}function Mh(e,t,r){let n=e.config.tasks[t];if(!n)return e;let s=$t(n),o=r.filter(a=>!s.includes(a));return o.length===0?e:{config:{...e.config,tasks:{...e.config.tasks,[t]:{...n,requires:[...s,...o]}}},state:e.state}}function Dh(e,t,r){let n=e.config.tasks[t];if(!n)return e;let s=$t(n),o=s.filter(a=>!r.includes(a));return o.length===s.length?e:{config:{...e.config,tasks:{...e.config.tasks,[t]:{...n,requires:o}}},state:e.state}}function Lh(e,t,r){let n=e.config.tasks[t];if(!n)return e;let s=Be(n),o=r.filter(a=>!s.includes(a));return o.length===0?e:{config:{...e.config,tasks:{...e.config.tasks,[t]:{...n,provides:[...s,...o]}}},state:e.state}}function Bh(e,t,r){let n=e.config.tasks[t];if(!n)return e;let s=Be(n),o=s.filter(a=>!r.includes(a));return o.length===s.length?e:{config:{...e.config,tasks:{...e.config.tasks,[t]:{...n,provides:o}}},state:e.state}}function Lr(e){return {version:1,config:e.config,state:e.state,snapshotAt:new Date().toISOString()}}function Vn(e){if(!e||typeof e!="object")throw new Error("Invalid snapshot: expected an object");let t=e;if(!t.config||typeof t.config!="object")throw new Error('Invalid snapshot: missing or invalid "config"');if(!t.state||typeof t.state!="object")throw new Error('Invalid snapshot: missing or invalid "state"');let r=t.config,n=t.state;if(!r.settings||typeof r.settings!="object")throw new Error("Invalid snapshot: config.settings missing");if(!r.tasks||typeof r.tasks!="object")throw new Error("Invalid snapshot: config.tasks missing");if(!n.tasks||typeof n.tasks!="object")throw new Error("Invalid snapshot: state.tasks missing");if(!Array.isArray(n.availableOutputs))throw new Error("Invalid snapshot: state.availableOutputs must be an array");return {config:r,state:n}}function Ou(){return {status:"not-started",executionCount:0,retryCount:0,lastEpoch:0,messages:[],progress:null}}function Vh(e,t){let r=new Date().toISOString();switch(t){case "stop":return {...e,status:"stopped",lastUpdated:r};case "pause":return {...e,status:"paused",lastUpdated:r};case "resume":return {...e,status:"running",lastUpdated:r};default:return e}}function Br(e){let{config:t,state:r}=e,n=bu(t);if(Object.keys(n).length===0)return {eligible:[],pending:[],unresolved:[],blocked:[],conflicts:{}};let o=Uh(n),a=Cu(t,r.tasks),i=new Set([...a,...r.availableOutputs]),u=[],c=[],d=[],l=[];for(let[v,f]of Object.entries(n)){let m=r.tasks[v],b=Ru(f,t.settings),C=b!=="once";if(m?.status===Ct.RUNNING||Zo(m))continue;let F=_u(f);if(F!==void 0&&m&&m.executionCount>=F||f.circuit_breaker&&m&&m.executionCount>=f.circuit_breaker.max_executions||!C&&m?.status===Ct.COMPLETED)continue;if(C&&m?.status===Ct.COMPLETED){let w=$t(f),p=false;switch(b){case "data-changed":{w.length>0&&w.some(R=>{for(let[x,A]of Object.entries(n))if(Be(A).includes(R)){let T=r.tasks[x];if(!T)continue;let B=m.lastConsumedHashes?.[R];return T.lastDataHash==null?T.executionCount>m.lastEpoch:T.lastDataHash!==B}return false})||(p=true);break}case "epoch-changed":{w.length>0&&w.some(R=>{for(let[x,A]of Object.entries(n))if(Be(A).includes(R)){let T=r.tasks[x];if(T&&T.executionCount>m.lastEpoch)return true}return false})||(p=true);break}case "time-based":{let h=f.refreshInterval??0;if(h<=0){p=true;break}let R=m.completedAt;if(!R){p=true;break}(Date.now()-Date.parse(R))/1e3<h&&(p=true);break}case "manual":p=true;break}if(p)continue}let _=$t(f);if(_.length===0){u.push(v);continue}let I=[],S=[],k=[];for(let w of _){if(i.has(w))continue;let p=o[w]||[];p.length===0?I.push(w):p.every(R=>Zo(r.tasks[R]))?k.push({token:w,failedProducer:p[0]}):S.push(w);}I.length>0?d.push({taskName:v,missingTokens:I}):k.length>0?l.push({taskName:v,failedTokens:k.map(w=>w.token),failedProducers:[...new Set(k.map(w=>w.failedProducer))]}):S.length>0?c.push({taskName:v,waitingOn:S}):u.push(v);}let g={};if(u.length>1){let v=$u(u,n);for(let[f,m]of Object.entries(v))m.length>1&&(g[f]=m);}return {eligible:u,pending:c,unresolved:d,blocked:l,conflicts:g}}function Uh(e){let t={};for(let[r,n]of Object.entries(e)){for(let s of Be(n))t[s]||(t[s]=[]),t[s].push(r);if(n.on)for(let s of Object.values(n.on))for(let o of s)t[o]||(t[o]=[]),t[o].includes(r)||t[o].push(r);if(n.on_failure)for(let s of n.on_failure)t[s]||(t[s]=[]),t[s].includes(r)||t[s].push(r);}return t}var Vr=class{buffer=[];append(t){this.buffer.push(t);}drain(){let t=this.buffer;return this.buffer=[],t}get size(){return this.buffer.length}};function ea(e){let t=ta(e);return Kh(t)}function ta(e){if(e==null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return "["+e.map(ta).join(",")+"]";let t=e;return "{"+Object.keys(t).sort().map(n=>JSON.stringify(n)+":"+ta(t[n])).join(",")+"}"}function Kh(e){let t=0xcbf29ce484222325n,r=0x100000001b3n,n=0xffffffffffffffffn;for(let s=0;s<e.length;s++)t^=BigInt(e.charCodeAt(s)),t=t*r&n;return t.toString(16).padStart(16,"0")}function Gh(e){if(typeof Buffer<"u")return Buffer.from(e,"utf8").toString("base64url");if(typeof btoa=="function"){let t=new TextEncoder().encode(e),r="";for(let n of t)r+=String.fromCharCode(n);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}throw new Error("No base64 encoder available in this runtime")}function Jh(e){if(typeof Buffer<"u")return Buffer.from(e,"base64url").toString("utf8");if(typeof atob=="function"){let t=e.replace(/-/g,"+").replace(/_/g,"/"),r=t+"=".repeat((4-t.length%4)%4),n=atob(r),s=new Uint8Array(n.length);for(let o=0;o<n.length;o++)s[o]=n.charCodeAt(o);return new TextDecoder().decode(s)}throw new Error("No base64 decoder available in this runtime")}function Pu(e){let t=JSON.stringify({t:e,n:Date.now().toString(36)+Math.random().toString(36).slice(2,6)});return Gh(t)}function zh(e){try{let t=JSON.parse(Jh(e));return typeof t?.t=="string"?{taskName:t.t}:null}catch{return null}}function Nu(e,t,r){let{handlers:n,onNodeRemoved:s,onDrain:o}=t,a=new Vr,i="state"in e&&"config"in e?e:Bn(e),u=false,c=new Set,d=new Map(Object.entries(n)),l=new Vr,g=false,v=false;function f(){if(!u){if(g){v=true;return}g=true;try{do v=!1,m();while(v)}finally{g=false;}}}function m(){let _=l.drain(),I=a.drain(),S=[..._,...I];if(S.length>0&&(i=ju(i,S),s)){for(let w of S)if(w.type==="task-removal")try{s(w.taskName);}catch(p){console.warn("[reactive] onNodeRemoved failed:",p instanceof Error?p.message:String(p));}}let k=Br(i);S.length>0&&o?.(S,i,k);for(let w of k.eligible)F(w);for(let w of S)if(w.type==="task-progress"){let{taskName:p,update:h}=w;if(!i.config.tasks[p])continue;let x=i.state.tasks[p];if(!x||x.status!=="running")continue;let A=Pu(p),T=C(p,A,h).catch(B=>{u||(l.append({type:"task-failed",taskName:p,error:B.message??String(B),timestamp:new Date().toISOString()}),f());}).finally(()=>{c.delete(T);});c.add(T);}}function b(_){let S=i.config.tasks[_].requires??[],k=new Map;for(let[p,h]of Object.entries(i.config.tasks))for(let R of h.provides??[])k.set(R,p);let w={};for(let p of S){let h=k.get(p);h?w[p]=i.state.tasks[h]?.data:w[p]=void 0;}return w}async function C(_,I,S){let k=i.config.tasks[_],w=k.taskHandlers??[],p=b(_);for(let h of w){let R=d.get(h);if(!R)throw new Error(`Handler '${h}' not found in registry (task '${_}')`);let x={nodeId:_,state:p,taskState:i.state.tasks[_],config:k,callbackToken:I,update:S};if(await R(x)==="task-initiate-failure")throw new Error(`Handler '${h}' returned task-initiate-failure (task '${_}')`)}}function F(_){let S=i.config.tasks[_]?.taskHandlers;if(!S||S.length===0)return;l.append({type:"task-started",taskName:_,timestamp:new Date().toISOString()}),f();let k=Pu(_),w=C(_,k).catch(p=>{u||(l.append({type:"task-failed",taskName:_,error:p.message??String(p),timestamp:new Date().toISOString()}),f());}).finally(()=>{c.delete(w);});c.add(w);}return {push(_){u||(_.type==="task-completed"&&_.data&&!_.dataHash&&(_={..._,dataHash:ea(_.data)}),a.append(_),f());},pushAll(_){if(!u){for(let I of _)I.type==="task-completed"&&I.data&&!I.dataHash?a.append({...I,dataHash:ea(I.data)}):a.append(I);f();}},resolveCallback(_,I,S){if(u)return;let k=zh(_);if(!k)return;let{taskName:w}=k;if(i.config.tasks[w]){if(S&&S.length>0)a.append({type:"task-failed",taskName:w,error:S.join("; "),timestamp:new Date().toISOString()});else {let p=I&&Object.keys(I).length>0?ea(I):void 0;a.append({type:"task-completed",taskName:w,data:I,dataHash:p,timestamp:new Date().toISOString()});}f();}},addNode(_,I){u||(a.append({type:"task-upsert",taskName:_,taskConfig:I,timestamp:new Date().toISOString()}),f());},removeNode(_){u||(a.append({type:"task-removal",taskName:_,timestamp:new Date().toISOString()}),f());},addRequires(_,I){u||(a.append({type:"node-requires-add",nodeName:_,tokens:I,timestamp:new Date().toISOString()}),f());},removeRequires(_,I){u||(a.append({type:"node-requires-remove",nodeName:_,tokens:I,timestamp:new Date().toISOString()}),f());},addProvides(_,I){u||(a.append({type:"node-provides-add",nodeName:_,tokens:I,timestamp:new Date().toISOString()}),f());},removeProvides(_,I){u||(a.append({type:"node-provides-remove",nodeName:_,tokens:I,timestamp:new Date().toISOString()}),f());},registerHandler(_,I){d.set(_,I);},unregisterHandler(_){d.delete(_);},retrigger(_){u||i.config.tasks[_]&&(a.append({type:"task-restart",taskName:_,timestamp:new Date().toISOString()}),f());},retriggerAll(_){if(!u){for(let I of _)i.config.tasks[I]&&a.append({type:"task-restart",taskName:I,timestamp:new Date().toISOString()});f();}},snapshot(){return Lr(i)},getState(){return i},getSchedule(){return Br(i)},async waitForHandlers(){c.size>0&&await Promise.allSettled([...c]);},async dispose(_){_?.wait&&c.size>0&&await Promise.allSettled([...c]),u=true;}}}var Wh=module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('board-live-cards-node.cjs', document.baseURI).href))),Un=Wh("./jsonata-sync.cjs"),Mu=Un;function qu(e,t){if(!t||!e)return;let r=t.split("."),n=e;for(let s=0;s<r.length;s++){if(n==null)return;n=n[r[s]];}return n}function Du(e,t,r){let n=t.split("."),s=e;for(let o=0;o<n.length-1;o++)(s[n[o]]==null||typeof s[n[o]]!="object")&&(s[n[o]]={}),s=s[n[o]];s[n[n.length-1]]=r;}async function Yh(e,t){if(!e?.compute?.length)return e;e.card_data||(e.card_data={}),e.computed_values={},e._sourcesData=t?.sourcesData??{};let r=e.requires??{},n={card_data:e.card_data,requires:r,expects_data:r,fetched_sources:e._sourcesData,data:e.computed_values,computed_values:e.computed_values};for(let s of e.compute)try{let o=await Un(s.expr).evaluate(n);Du(e.computed_values,s.bindTo,o),n.computed_values=e.computed_values;}catch{}return e}function Xh(e,t){if(!e?.compute?.length)return {ok:true,node:e};e.card_data||(e.card_data={}),e.computed_values={},e._sourcesData=t?.sourcesData??{};let r=e.requires??{},n={card_data:e.card_data,requires:r,expects_data:r,fetched_sources:e._sourcesData,data:e.computed_values,computed_values:e.computed_values},s=[];for(let o of e.compute)try{let a=Mu(o.expr).evaluate(n);Du(e.computed_values,o.bindTo,a),n.computed_values=e.computed_values;}catch(a){let i=a instanceof Error?a.message:String(a);s.push({bindTo:o.bindTo,error:i});}return s.length>0?{ok:true,node:e,errors:s}:{ok:true,node:e}}async function Qh(e,t,r){let n={...r??{},card_data:t.card_data??{},requires:t.requires??{},fetched_sources:t._sourcesData??{},computed_values:t.computed_values??{}};return Un(e).evaluate(n)}function Zh(e,t){return t.startsWith("fetched_sources.")?qu(e._sourcesData??{},t.slice(16)):qu(e,t)}var Fu=new Set(["metric","table","editable-table","chart","form","filter","list","notes","todo","alert","narrative","badge","text","markdown","ref","custom","actions"]),ey=new Set(["id","meta","requires","provides","view","card_data","compute","source_defs"]);function ty(e){let t=[];if(!e||typeof e!="object"||Array.isArray(e))return {ok:false,errors:["Node must be a non-null object"]};let r=e;(typeof r.id!="string"||!r.id)&&t.push("id: required, must be a non-empty string");for(let n of Object.keys(r))ey.has(n)||t.push(`Unknown top-level key: "${n}"`);if((r.card_data==null||typeof r.card_data!="object"||Array.isArray(r.card_data))&&t.push("card_data: required, must be an object"),r.meta!=null)if(typeof r.meta!="object"||Array.isArray(r.meta))t.push("meta: must be an object");else {let n=r.meta;n.title!=null&&typeof n.title!="string"&&t.push("meta.title: must be a string"),n.tags!=null&&!Array.isArray(n.tags)&&t.push("meta.tags: must be an array");}if(r.requires!=null&&!Array.isArray(r.requires)&&t.push("requires: must be an array of strings"),r.provides!=null&&(Array.isArray(r.provides)?r.provides.forEach((n,s)=>{if(!n||typeof n!="object"||Array.isArray(n))t.push(`provides[${s}]: must be an object with bindTo and ref`);else {let o=n;(typeof o.bindTo!="string"||!o.bindTo)&&t.push(`provides[${s}]: missing required "bindTo" string`),(typeof o.ref!="string"||!o.ref)&&t.push(`provides[${s}]: missing required "ref" string`);}}):t.push("provides: must be an array of { bindTo, ref } bindings")),r.compute!=null&&(Array.isArray(r.compute)?r.compute.forEach((n,s)=>{if(!n||typeof n!="object"||Array.isArray(n))t.push(`compute[${s}]: must be a compute step object`);else {let o=n;(typeof o.bindTo!="string"||!o.bindTo)&&t.push(`compute[${s}]: missing required "bindTo" property`),(typeof o.expr!="string"||!o.expr)&&t.push(`compute[${s}]: missing required "expr" string (JSONata expression)`);}}):t.push("compute: must be an array of compute steps")),r.source_defs!=null)if(!Array.isArray(r.source_defs))t.push("source_defs: must be an array");else {let n=new Set,s=new Set;r.source_defs.forEach((o,a)=>{if(!o||typeof o!="object"||Array.isArray(o))t.push(`source_defs[${a}]: must be an object`);else {let i=o;typeof i.bindTo!="string"||!i.bindTo?t.push(`source_defs[${a}]: missing required "bindTo" property`):(n.has(i.bindTo)&&t.push(`source_defs[${a}]: bindTo "${i.bindTo}" is not unique across source_defs`),n.add(i.bindTo)),typeof i.outputFile!="string"||!i.outputFile?t.push(`source_defs[${a}]: missing required "outputFile" property`):(s.has(i.outputFile)&&t.push(`source_defs[${a}]: outputFile "${i.outputFile}" is not unique across source_defs`),s.add(i.outputFile)),i.optionalForCompletionGating!=null&&typeof i.optionalForCompletionGating!="boolean"&&t.push(`source_defs[${a}]: optionalForCompletionGating must be a boolean`);}});}if(r.view!=null)if(typeof r.view!="object"||Array.isArray(r.view))t.push("view: must be an object");else {let n=r.view;!Array.isArray(n.elements)||n.elements.length===0?t.push("view.elements: required, must be a non-empty array"):n.elements.forEach((s,o)=>{if(!s||typeof s!="object"){t.push(`view.elements[${o}]: must be an object`);return}!s.kind||typeof s.kind!="string"?t.push(`view.elements[${o}].kind: required, must be a string`):Fu.has(s.kind)||t.push(`view.elements[${o}].kind: unknown kind "${s.kind}". Valid: ${[...Fu].join(", ")}`),s.data!=null&&(typeof s.data!="object"||Array.isArray(s.data))&&t.push(`view.elements[${o}].data: must be an object`);}),n.layout!=null&&(typeof n.layout!="object"||Array.isArray(n.layout))&&t.push("view.layout: must be an object"),n.features!=null&&(typeof n.features!="object"||Array.isArray(n.features))&&t.push("view.features: must be an object");}return {ok:t.length===0,errors:t}}async function ry(e,t){if(!e||e.length===0)return [];let r={card_data:t.card_data??{},requires:t.requires??{}};return Promise.all(e.map(async n=>{let s={};if(n.projections&&typeof n.projections=="object"&&!Array.isArray(n.projections)){for(let[o,a]of Object.entries(n.projections))if(typeof a=="string"&&a.trim().length>0)try{s[o]=await Un(a).evaluate(r);}catch{s[o]=void 0;}}return {...n,_projections:s}}))}function ny(e,t){if(!e||e.length===0)return [];let r={card_data:t.card_data??{},requires:t.requires??{}};return e.map(n=>{let s={};if(n.projections&&typeof n.projections=="object"&&!Array.isArray(n.projections)){for(let[o,a]of Object.entries(n.projections))if(typeof a=="string"&&a.trim().length>0)try{s[o]=Mu(a).evaluate(r);}catch{s[o]=void 0;}}return {...n,_projections:s}})}var ct={run:Yh,runSync:Xh,eval:Qh,resolve:Zh,validate:ty,enrichSources:ry,enrichSourcesSync:ny};function sy(e,t){let r;return /\.m?js$/i.test(e)?r="local-node":/\.py$/i.test(e)?r="local-python":r="local-process",{meta:"task-executor",howToRun:r,whatToRun:pe({kind:"fs-path",value:e}),...t?{extra:t}:{}}}function ra(e){return JSON.stringify(e)}function na(e){let t;try{t=JSON.parse(e);}catch{throw new Error(`parseExecutionRef: invalid JSON \u2014 ${e}`)}if(typeof t!="object"||t===null||typeof t.howToRun!="string"||typeof t.whatToRun!="string")throw new Error(`parseExecutionRef: missing required fields howToRun/whatToRun \u2014 ${e}`);return t}function Kn(e,t){function r(){return e.readIndex()??{}}function n(s,o,a){let i=String(o||"").split(".").filter(Boolean);if(i.length===0)return a&&typeof a=="object"&&!Array.isArray(a)?a:{value:a};let u={...s},c=u;for(let d=0;d<i.length-1;d++){let l=i[d],g=c[l],v=g&&typeof g=="object"&&!Array.isArray(g)?{...g}:{};c[l]=v,c=v;}return c[i[i.length-1]]=a,u}return {readCard(s){let o=r()[s];return !o||!e.cardExists(o.key)?null:e.readCard(o.key)},readCardKey(s){return r()[s]?.key??null},readAllCards(){let s=[];for(let[o,a]of Object.entries(r())){if(!e.cardExists(a.key))continue;let i=e.readCard(a.key);i?s.push(i):t?.(`[card-store] could not read card "${o}" at key "${a.key}"`);}return s},readChecksumIndex(){let s={};for(let[o,a]of Object.entries(r()))s[o]=a.checksum;return s},changedSince(s){let o=r(),a=[];for(let[i,u]of Object.entries(o))s[i]!==u.checksum&&a.push(i);for(let i of Object.keys(s))o[i]||a.push(i);return a},validateUpsert(s,o){let a=r(),i=a[s],u=Object.entries(a).find(([,c])=>c.key===o);return i&&i.key!==o?{ok:false,error:`Card id "${s}" is already mapped to key "${i.key}", cannot remap to "${o}"`}:u&&u[0]!==s?{ok:false,error:`Key "${o}" is already mapped to card id "${u[0]}", cannot remap to "${s}"`}:{ok:true}},writeCard(s,o,a){let i=r(),u=a??i[s]?.key??e.defaultCardKey(s),c=e.writeCard(u,o);i[s]={key:u,checksum:c,updatedAt:new Date().toISOString()},e.writeIndex(i);},patchCard(s,o,a){let i=r(),u=i[s];if(!u||!e.cardExists(u.key))throw new Error(`card "${s}" not found`);let c=e.readCard(u.key);if(!c||typeof c!="object"||Array.isArray(c))throw new Error(`card "${s}" is not patchable`);let d=n(c,o,a),l=e.writeCard(u.key,d);i[s]={key:u.key,checksum:l,updatedAt:new Date().toISOString()},e.writeIndex(i);},removeCard(s){let o=r(),a=o[s];a&&(e.removeCard(a.key),delete o[s],e.writeIndex(o));},readIndex(){return r()}}}function Gn(e,t){return {readSourceData(r,n){let s=e.read(`${r}/${n}`);if(s==null)return null;let o=s.trim();if(!o)return null;try{return JSON.parse(o)}catch{return o}},ingestSourceDataStaged(r,n,s,o){let a=t(s);e.write(`${r}/.staged/${o}/${n}`,a);},commitSourceData(r,n,s){let o=`${r}/.staged/${s}/${n}`,a=e.read(o);return a==null?false:(e.write(`${r}/${n}`,a),e.remove(o),true)},hasSource(r,n){return e.exists(`${r}/${n}`)},listSources(r){return e.listKeys(`${r}/`).filter(n=>!n.includes("/.staged/")).map(n=>n.slice(`${r}/`.length))}}}function Ku(e){function t(r){let n=e.readAllEntries();if(!r)return n;let s=n.findIndex(o=>o.id===r);return s===-1?n:n.slice(s+1)}return {readEntriesAfterCursor(r){let n=t(r);return n.length===0?{events:[],newCursor:r}:{events:n.map(s=>s.event),newCursor:n[n.length-1].id}},pendingCount(r){return t(r).length},appendEvent(r){e.appendEntry({id:e.generateId(),event:r});}}}function Gu(e,t){return {appendEntries(r,n){if(!r||n.length===0)return;let s=e.read(r)??[];e.write(r,[...s,...n]);},dispatchEntriesForJournalId(r,n){if(!r)return;let s=e.read(r);if(!(!s||s.length===0)){for(let o of s)try{n(o);}catch(a){let i=a instanceof Error?a.message:String(a);try{t(o,i);}catch{}}e.delete(r);}}}}var Ur="v1",Et="board/graph",Ju="board/lastJournalProcessedId";function Lu(e){return `cards/${e}/runtime`}function zu(e){return {readRuntime(t){return e.read(Lu(t))??{_sources:{}}},writeRuntime(t,r){e.write(Lu(t),r);}}}function oy(e,t){let r={...e};for(let n of t.deleteKeys)delete r[n];return {...r,...t.shallowMerge}}function Hu(e){return {readSnapshot(t){return e.readValues(t)},commitSnapshot(t,r){if(r.schemaVersion!==Ur)throw new Error(`Unsupported snapshot schema version: ${r.schemaVersion}`);let n=e.readValues(t);if(n.version!==r.expectedVersion)return {ok:false,reason:"version-mismatch",currentVersion:n.version};let s=oy(n.values,r);return {ok:true,newVersion:e.writeValues(t,s,r.deleteKeys)}}}}function sa(e){function t(r){let n=e.read(r);return n==null?null:typeof n=="string"?n:JSON.stringify(n)}return {readTaskExecutorRef(){let r=t("task-executor");if(r?.trim())return na(r.trim())},writeTaskExecutorRef(r){e.write("task-executor",ra(r));},readChatHandlerFlow(){return e.read("chat-handler-flow")},writeChatHandlerFlow(r){e.write("chat-handler-flow",r);},readCardStoreRef(){return t("card-store-ref")},writeCardStoreRef(r){e.write("card-store-ref",r);},readOutputsStoreRef(){return t("outputs-store-ref")},writeOutputsStoreRef(r){e.write("outputs-store-ref",r);},readScratchStoreRef(){return t("scratch-store-ref")},writeScratchStoreRef(r){e.write("scratch-store-ref",r);},readArchiveStoreRef(){return t("archive-store-ref")},writeArchiveStoreRef(r){e.write("archive-store-ref",r);},readChatStoreRef(){return t("chat-store-ref")},writeChatStoreRef(r){e.write("chat-store-ref",r);},readArtifactsStoreRef(){return t("artifacts-store-ref")},writeArtifactsStoreRef(r){e.write("artifacts-store-ref",r);}}}function Wu(e){return {writeComputedValues(t,r){e.write(`cards/${t}/computed_values`,r);},readComputedValues(t){return e.read(`cards/${t}/computed_values`)},readAllComputedValues(){let t={};for(let r of e.listKeys("cards/")){let n=r.match(/^cards\/([^/]+)\/computed_values$/);n&&(t[n[1]]=e.read(r));}return t},writeDataObjects(t){for(let[r,n]of Object.entries(t))r&&e.write(`data-objects/${r}`,n);},readDataObject(t){return e.read(`data-objects/${t}`)},readAllDataObjects(){let t={};for(let r of e.listKeys("data-objects/"))t[r.slice(13)]=e.read(r);return t},writeStatusSnapshot(t){e.write("status",t);},readStatusSnapshot(){return e.read("status")}}}function Bu(e){return e?{lastRequestedToken:e.lastRequestedToken,lastCompletedToken:e.lastCompletedToken,lastCompletionStatus:e.lastCompletionStatus??(e.lastCompletedToken?"success":"not-started"),queueRequestedToken:e.queueRequestedToken}:{lastCompletionStatus:"not-started"}}function ay(e){return e?.lastRequestedToken?e.lastCompletedToken!==e.lastRequestedToken:false}function Vu(e,t){return e?.lastRequestedToken?ay(e)?"in-flight":!e.lastCompletedToken||e.lastCompletedToken<t?"dispatch":"idle":"dispatch"}function iy(e,t){return {...e,lastCompletedToken:t,lastCompletionStatus:"success"}}function Uu(e,t){return {...e,lastCompletedToken:t,lastCompletionStatus:"failure"}}function Jn(e,t){let r=t.state.tasks,n=t.config.tasks,s=Object.keys(r),o=Br(t),a={completed:0,failed:0,in_progress:0,pending:0,blocked:0,unresolved:0},i=new Map;for(let f of o.pending)i.set(f.taskName,f.waitingOn);for(let f of o.unresolved)i.set(f.taskName,f.missingTokens);for(let f of o.blocked)i.set(f.taskName,f.failedTokens);let u=new Map;for(let[f,m]of Object.entries(n))for(let b of m.requires??[]){let C=u.get(b)??[];C.push(f),u.set(b,C);}let c=s.sort().map(f=>{let m=r[f],b=n[f]??{requires:[],provides:[]};m.status==="completed"?a.completed+=1:m.status==="failed"?a.failed+=1:m.status==="in-progress"&&(a.in_progress+=1);let C=b.requires??[],F=b.provides??[],_=Object.keys(m.data??{}).sort(),I=C.filter(R=>t.state.availableOutputs.includes(R)),S=C.filter(R=>!t.state.availableOutputs.includes(R)),k=i.get(f)??S,w=new Set;for(let R of F)for(let x of u.get(R)??[])x!==f&&w.add(x);let p=m.failedAt,h=m.error?{message:m.error,code:"TASK_FAILED",at:p,source:"task-runtime"}:void 0;return {name:f,status:m.status,error:h,requires:C,requires_satisfied:I,requires_missing:S,provides_declared:F,provides_runtime:_,blocked_by:k,unblocks:Array.from(w).sort(),runtime:{attempt_count:m.executionCount??0,restart_count:m.retryCount??0,in_progress_since:m.status==="in-progress"?m.startedAt??null:null,last_transition_at:m.lastUpdated??null,last_completed_at:m.completedAt??null,last_restarted_at:m.startedAt??null,status_age_ms:m.lastUpdated?0:null}}});a.pending=o.pending.length,a.blocked=o.blocked.length,a.unresolved=o.unresolved.length;let d=c.map(f=>({name:f.name,fanOut:f.unblocks.length})).sort((f,m)=>m.fanOut-f.fanOut||f.name.localeCompare(m.name)),l=d.length>0?d[0]:{name:null,fanOut:0},g=new Set;for(let f of Object.values(n))for(let m of f.requires??[])g.add(m);let v=0;for(let[f,m]of Object.entries(n)){let b=(m.requires??[]).length===0,F=(m.provides??[]).some(_=>(u.get(_)??[]).some(I=>I!==f));b&&!F&&(v+=1);}return {schema_version:"v1",meta:{board:{path:e}},summary:{card_count:s.length,completed:a.completed,eligible:o.eligible.length,pending:a.pending,blocked:a.blocked,unresolved:a.unresolved,failed:a.failed,in_progress:a.in_progress,orphan_cards:v,topology:{edge_count:Array.from(g).length,max_fan_out_card:l.name,max_fan_out:l.fanOut}},cards:c}}function cy(){return new Date().toISOString()}function Yu(e,t,r,n,s,o,a){return async i=>{let u=[],c=r.cardStore.readCard(i.nodeId);if(!c)return "task-initiate-failure";let d=c.id,l=c.card_data??{},g=c.source_defs??[],v=g.filter(P=>P.optionalForCompletionGating!==true),f=r.cardRuntimeStore.readRuntime(d),m=false,b=()=>{m&&(r.cardRuntimeStore.writeRuntime(d,f),m=false);},C=P=>Bu(f._sources[P]),F=(P,N)=>{f._sources[P]=Bu(N),m=true;},_=i.taskState?.executionCount??0;if(f._lastExecutionCount!==_&&(f._sources={},f._lastExecutionCount=_,m=true),i.update){let P=i.update,N=P.outputFile;if(N){let z=C(N);if(P.failure){let ce=P.rqt??z.lastRequestedToken??z.queueRequestedToken;ce&&F(N,Uu(z,ce));}else {let ce=P.rqt;if(!z.lastCompletedToken||ce>z.lastCompletedToken){let ne=typeof P.deliveryToken=="string"?P.deliveryToken:void 0,je=false;ne&&(je=r.fetchedSourcesStore.commitSourceData(d,N,ne)),je?F(N,iy(z,ce)):F(N,Uu(z,ce));}}b();}}let S={};for(let P of g)if(P.outputFile){let N=r.fetchedSourcesStore.readSourceData(d,P.outputFile);N!==null&&(S[P.bindTo]=N);}let k={};for(let[P,N]of Object.entries(i.state??{}))if(N!==null&&typeof N=="object"&&!Array.isArray(N)){let z=N[P];k[P]=z!==void 0?z:N;}else k[P]=N;let w={id:d,card_data:{...l},requires:k,source_defs:g,compute:c.compute};w._sourcesData=S,c.compute&&ct.runSync(w,{sourcesData:S}),(o??r.outputStore.writeComputedValues.bind(r.outputStore))(d,w.computed_values??{});let p={...c},h=ct.enrichSourcesSync(Array.isArray(c.source_defs)?c.source_defs:void 0,{card_data:c.card_data,requires:k}),R=e.value;p.source_defs=Array.isArray(h)?h.map(P=>({...P,boardDir:typeof P.boardDir=="string"&&P.boardDir?P.boardDir:R})):h;let x=cy(),A=i.update?void 0:x,T=v.filter(P=>{let N=P.outputFile;if(typeof N!="string"||!N)return true;let z=C(N);A&&(z={...z,queueRequestedToken:A},F(N,z));let ce=z.queueRequestedToken??z.lastRequestedToken??x,ne=Vu(z,ce);return ne==="in-flight"?false:ne==="dispatch"});if(b(),T.length>0){let P=false,N=x;for(let z of T){let ce=z.outputFile;if(typeof ce!="string"||!ce)continue;let ne=C(ce),je=ne.queueRequestedToken??x;F(ce,{...ne,lastRequestedToken:je}),N=je,P=true;}return P&&b(),P&&(u.push({taskKind:"source-fetch",payload:{boardRef:pe(e),enrichedCard:p,callbackToken:i.callbackToken,rqt:N}}),r.executionRequestStore.appendEntries(t,u)),"task-initiated"}if(v.some(P=>{let N=P.outputFile;if(typeof N!="string"||!N)return false;let z=C(N),ce=z.queueRequestedToken??z.lastRequestedToken??x;return Vu(z,ce)==="in-flight"}))return "task-initiated";let Q=c.provides??[],Z={};for(let{bindTo:P,ref:N}of Q)Z[P]=ct.resolve(w,N);return (a??r.outputStore.writeDataObjects.bind(r.outputStore))(Z),g.filter(P=>{if(P.optionalForCompletionGating!==true)return false;let N=C(P.outputFile);return !N.lastRequestedToken||!N.lastCompletedToken?true:N.lastCompletedToken<=N.lastRequestedToken}).length>0&&u.push({taskKind:"source-fetch",payload:{boardRef:pe(e),enrichedCard:p,callbackToken:i.callbackToken,rqt:x}}),n(i.nodeId,Z),u.length>0&&r.executionRequestStore.appendEntries(t,u),"task-initiated"}}var zn={settings:{completion:"manual",refreshStrategy:"data-changed"},tasks:{}};function Xu(e){return {[Et]:e.graph,[Ju]:e.lastDrainedJournalId}}function Qu(e){let t=e[Et],r=e[Ju];if(!t||typeof t!="object")throw new Error(`State snapshot is missing required key: ${Et}`);return {graph:t,lastDrainedJournalId:typeof r=="string"?r:""}}function Zu(e){let t=e.requires,r=e.provides?.map(n=>n.bindTo)??[];return {requires:t&&t.length>0?t:void 0,provides:r,taskHandlers:["card-handler"],description:e.meta?.title??e.id}}function oa(e){function t(o){return {status:"success",data:o}}function r(o){return {status:"fail",error:o}}function n(o){return {status:"error",error:o instanceof Error?o.message:String(o)}}function s(o){if(Array.isArray(o))return o;if(o&&typeof o=="object"){let a=o;return Array.isArray(a.files)?a.files:[o]}return null}return {get(o){try{let a=o.params?.id;if(a){let i=e.readCard(a);return i?t({cards:[i]}):r(`card "${a}" not found`)}return t({cards:e.readAllCards()})}catch(a){return n(a)}},set(o){try{let a=o.body;if(a==null)return r("set requires a body (card object or array of cards)");let i=Array.isArray(a)?a:[a];for(let u of i){if(typeof u.id!="string")return r("each card must have a string `id` field");e.writeCard(u.id,u);}return t({count:i.length})}catch(a){return n(a)}},del(o){try{let a=o.body?.ids??[],i=o.params?.id,u=i?[...a,i]:a;if(u.length===0)return r("del requires body.ids (string[]) or params.id");for(let c of u)e.removeCard(c);return t({count:u.length})}catch(a){return n(a)}},patch(o){try{let a=o.params?.id,i=o.params?.path;if(!a)return r("patch requires params.id");if(!i)return r("patch requires params.path");let u=o.body,c=u&&Object.prototype.hasOwnProperty.call(u,"value")?u.value:o.body;return e.patchCard(a,i,c),t({count:1})}catch(a){return n(a)}},appendFiles(o){try{let a=o.params?.id;if(!a)return r("appendFiles requires params.id");let i=e.readCard(a);if(!i)return r(`card "${a}" not found`);let u=s(o.body);if(!u||u.length===0)return r("appendFiles requires a file metadata object, array, or body.files array");let c=i.card_data&&typeof i.card_data=="object"&&!Array.isArray(i.card_data)?i.card_data:{},d=Array.isArray(c.files)?c.files:[],l=[...d,...u],g=u.map((f,m)=>({idx:d.length+m,entry:f})),v=this.patch({params:{id:a,path:"card_data.files"},body:{value:l}});return v.status!=="success"?v:t({files_added:g})}catch(a){return n(a)}}}}function X(e){return e!==void 0?{status:"success",data:e}:{status:"success"}}function L(e){return {status:"fail",error:e}}function te(e){return {status:"error",error:e instanceof Error?e.message:String(e)}}function uy(e){let t=new TextEncoder().encode(e),r=Array.from(t,n=>String.fromCharCode(n)).join("");return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function td(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),r=t+"=".repeat((4-t.length%4)%4),n=atob(r),s=Uint8Array.from(n,o=>o.charCodeAt(0));return new TextDecoder().decode(s)}function Hn(e){try{let t=JSON.parse(td(e));return typeof t?.t=="string"?{taskName:t.t}:null}catch{return null}}function dy(e){return uy(JSON.stringify(e))}function ed(e){try{let t=JSON.parse(td(e));return typeof t?.cbk=="string"&&typeof t?.cid=="string"&&typeof t?.b=="string"&&typeof t?.d=="string"?t:null}catch{return null}}function xe(){return new Date().toISOString()}function ly(e,t){let r=t.onWarn??(()=>{}),n=pe(e);function s(E){if(E.length!==0)try{let y=t.publishBoardChangeNotifications?.(E);y&&typeof y.catch=="function"&&y.catch(j=>r(`[board-live-cards-public] publishBoardChangeNotifications failed: ${j instanceof Error?j.message:String(j)}`));}catch(y){r(`[board-live-cards-public] publishBoardChangeNotifications failed: ${y instanceof Error?y.message:String(y)}`);}}function o(){let E=i().readCardStoreRef();if(!E)throw new Error(`Board at ${e.value} has no card store configured. Run: init --base-ref <ref> --store-ref <b64-ref>`);let y=t.kvStorageForRef(E);return {readIndex(){return y.read("_index")},writeIndex(j){y.write("_index",j);},readCard(j){return y.read(j)},writeCard(j,D){return y.write(j,D),t.hashFn(D)},removeCard(j){y.delete(j);},cardExists(j){return y.read(j)!==null},defaultCardKey(j){return j}}}let a={readValues(E){let y=t.kvStorage("state-snapshot"),j=y.listKeys().sort();if(j.length===0)return {version:null,values:{}};let D={};for(let ee of j)D[ee]=y.read(ee);return {version:t.hashFn(D),values:D}},writeValues(E,y,j){let D=t.kvStorage("state-snapshot");for(let ee of j)D.delete(ee);for(let[ee,de]of Object.entries(y))D.write(ee,de);return t.hashFn(y)}},i=()=>sa(t.kvStorage("config")),u=()=>Hu(a),c=()=>Ku(t.journalAdapter()),d=()=>Kn(o(),r),l=()=>{let E=i().readOutputsStoreRef();if(!E)throw new Error(`Board at ${e.value} has no outputs store configured. Run: init --outputs-store-ref <b64-ref>`);return Wu(t.kvStorageForRef(E))},g=()=>{let E=i().readArchiveStoreRef();return E?t.archiveFactoryForRef(E):t.archiveFactory()};function v(){return !!u().readSnapshot(e.value).values[Et]}function f(){let E=u().readSnapshot(e.value);if(!E.values[Et])throw new Error(`Board not initialized at ${e.value}`);return Qu(E.values)}function m(E,y){let j=u().commitSnapshot(e.value,{schemaVersion:Ur,expectedVersion:y,commitId:t.genId(),committedAt:xe(),deleteKeys:[],shallowMerge:Xu(E)});if(!j.ok)throw new Error(`Snapshot commit failed (version mismatch): expected=${y??"null"} current=${j.currentVersion??"null"}`)}function b(E){c().appendEvent(E);}async function C(){let E=(q,K)=>{let me=q.payload,He=(me?.enrichedCard??{}).id??me?.cardId??"unknown";b({type:"task-failed",taskName:He,error:K,timestamp:xe()});},y=Gu(t.kvStorage("execution-requests"),E),j=zu(t.kvStorage("card-runtime")),D=Gn(t.blobStorage("sources"),q=>t.resolveBlob(q)),ee=new Map,de={readRuntime(q){return ee.get(q)??j.readRuntime(q)},writeRuntime(q,K){ee.set(q,K);}},Pe=[],ye=new Map,Le={readSourceData(q,K){let me=`${q}/${K}`;return ye.has(me)?ye.get(me):D.readSourceData(q,K)},ingestSourceDataStaged(q,K,me,gt){D.ingestSourceDataStaged(q,K,me,gt);},commitSourceData(q,K,me){let gt=`${q}/.staged/${me}/${K}`,zr=t.blobStorage("sources").read(gt);if(zr==null)return false;let Ht=`${q}/${K}`,fa=zr.trim();try{ye.set(Ht,JSON.parse(fa));}catch{ye.set(Ht,fa);}return Pe.push({cardId:q,outputFile:K,deliveryToken:me}),true},hasSource(q,K){let me=`${q}/${K}`;return ye.has(me)?true:D.hasSource(q,K)},listSources(q){let K=D.listSources(q),me=new Set;for(let He of ye.keys())He.startsWith(`${q}/`)&&me.add(He.slice(`${q}/`.length));let gt=new Set([...K,...me]);return Array.from(gt)}},Ae={cardStore:d(),cardRuntimeStore:de,fetchedSourcesStore:Le,outputStore:l(),executionRequestStore:y},At=f(),Tt=Vn(At.graph),{events:Gt,newCursor:Jt}=c().readEntriesAfterCursor(At.lastDrainedJournalId),It=[],Wn=[],Yn=[],Xn=new Map,ua=new Set,id=(q,K)=>{It.push({type:"task-completed",taskName:q,data:K,timestamp:xe()});try{g().stream("exec-history").append({taskName:q,status:"completed",completedAt:xe()});}catch{}},da=(q,K)=>{b({type:"task-failed",taskName:q,error:K,timestamp:xe()});try{g().stream("exec-history").append({taskName:q,status:"failed",error:K,completedAt:xe()});}catch{}},Gr=Nu(Tt,{handlers:{"card-handler":Yu(e,Jt,Ae,id,da,(q,K)=>{Wn.push({cardId:q,values:K});},q=>{Yn.push(q);})},onNodeRemoved:q=>{Xn.delete(q),ee.delete(q),ua.add(q);}});for(It=Gt;It.length>0;){let q=It;It=[];for(let K of q)if(K.type==="task-restart"){let me=Ae.cardStore.readCard(K.taskName);me&&Xn.set(K.taskName,me);}Gr.pushAll(q),await Gr.waitForHandlers();}let la=Gr.getState();await Gr.dispose({wait:true});let cd=u().readSnapshot(e.value).version;m({lastDrainedJournalId:Jt,graph:Lr(la)},cd);for(let{cardId:q,values:K}of Wn)Ae.outputStore.writeComputedValues(q,K);for(let q of Yn)Ae.outputStore.writeDataObjects(q);for(let[q,K]of ee)j.writeRuntime(q,K);for(let{cardId:q,outputFile:K,deliveryToken:me}of Pe)D.commitSourceData(q,K,me);let Jr;try{Jr=Jn(n,la),Ae.outputStore.writeStatusSnapshot(Jr);}catch(q){r(`[board-live-cards-public] status publish failed: ${q instanceof Error?q.message:String(q)}`);}let zt=[];for(let{cardId:q,values:K}of Wn)zt.push({kind:"computed_values",cardId:q,values:K});for(let q of Yn)for(let[K,me]of Object.entries(q))K&&zt.push({kind:"data_object",key:K,payload:me});for(let[q,K]of Xn)zt.push({kind:"card_refreshed",cardId:q,card:K});for(let q of ua)zt.push({kind:"card_removed",cardId:q});Jr!==void 0&&zt.push({kind:"status",status:Jr}),s(zt);let ud=i().readTaskExecutorRef()??{howToRun:"built-in",whatToRun:pe({kind:"built-in",value:"source-cli-task-executor"})};y.dispatchEntriesForJournalId(Jt,q=>{if(q.taskKind!=="source-fetch"){r(`[process-accumulated-events] unknown taskKind "${q.taskKind}" \u2014 skipping`);return}let K=q.payload,me=K.enrichedCard?.id??"unknown",gt=K.enrichedCard?.source_defs??[];for(let He of gt){if(!He.outputFile){r(`[dispatch] source "${He.bindTo}" has no outputFile \u2014 skipping`);continue}let zr=dy({cbk:K.callbackToken,rg:e.value,br:pe(e),cid:me,b:He.bindTo,d:He.outputFile,cs:void 0,rqt:K.rqt});t.dispatchExecution(ud,{source_def:He,base_ref:pe(e),callback:{token:zr,via:t.selfRef}}).catch(Ht=>da(me,Ht instanceof Error?Ht.message:String(Ht)));}});}async function F(){try{let E=()=>{let j=f(),{events:D}=c().readEntriesAfterCursor(j.lastDrainedJournalId);D.length<=0||(F(),t.requestProcessAccumulated?.());},y=await ma(t.lock,C,E);return X({ran:y!==!1})}catch(E){return te(E)}}function _(){F(),t.requestProcessAccumulated?.();}function I(E){try{let y=E.params?.cardStoreRef;if(!y)return L("init requires params.cardStoreRef \u2014 create a card store with card-store-cli and pass its ref here");if(!v()){let Ae=Bn(zn);m({lastDrainedJournalId:"",graph:Lr(Ae)},null);}let j=E.params?.outputsStoreRef;if(!j)return L("init requires params.outputsStoreRef \u2014 pass the outputs store ref here");let D=E.params?.scratchStoreRef,ee=E.params?.archiveStoreRef,de=E.params?.chatStoreRef,Pe=E.params?.artifactsStoreRef,ye=i();ye.writeCardStoreRef(y),ye.writeOutputsStoreRef(j),D&&ye.writeScratchStoreRef(D),ee&&ye.writeArchiveStoreRef(ee),de&&ye.writeChatStoreRef(de),Pe&&ye.writeArtifactsStoreRef(Pe);let Le=E.body??{};Le["task-executor-ref"]&&ye.writeTaskExecutorRef(Le["task-executor-ref"]),Object.prototype.hasOwnProperty.call(Le,"chat-handler-flow")&&ye.writeChatHandlerFlow(Le["chat-handler-flow"]);try{l().writeStatusSnapshot(Jn(n,Vn(f().graph)));}catch{}return X()}catch(y){return te(y)}}function S(E){try{let y=l().readStatusSnapshot();if(!y){y=Jn(n,Vn(f().graph));try{l().writeStatusSnapshot(y);}catch{}}return X(y)}catch(y){return te(y)}}function k(E){try{let y=E.params?.id;return y?(b({type:"task-removal",taskName:y,timestamp:xe()}),_(),X()):L("removeCard requires params.id")}catch(y){return te(y)}}function w(E){try{let y=E.params?.cardId;if(!y)return L("addCardFiles requires params.cardId");let j=oa(d()).appendFiles({params:{id:y},body:E.body});if(j.status!=="success")return j;let D=p({params:{cardId:y}});return D.status!=="success"?D:X({cardId:y,files_added:j.data.files_added,notified:!0})}catch(y){return te(y)}}function p(E){try{let y=E.params?.cardId;if(!y)return L("cardRefreshedNotify requires params.cardId");let j=d().readCard(y);return j?(s([{kind:"card_refreshed",cardId:y,card:j}]),X({cardId:y,notified:!0})):L(`Card "${y}" not found in board at ${e.value}`)}catch(y){return te(y)}}function h(E){try{let y=E.params?.id;return y?(b({type:"task-restart",taskName:y,timestamp:xe()}),_(),X()):L("retrigger requires params.id")}catch(y){return te(y)}}async function R(E){return F()}function x(E){try{let y=E.params?.cardId,j=E.params?.all,D=!!E.params?.restart;if(!y&&!j)return L("upsertCard requires --card-id <id> or --all");let ee=j?d().readAllCards().map(de=>de.id):[y];for(let de of ee)if(!d().readCard(de))return L(`Card "${de}" not found in board at ${e.value}`);for(let de of ee){let Pe=d().readCard(de),ye=Zu(Pe),Le=t.hashFn(ye),Ae=t.kvStorage("card-upsert"),At=Ae.read(de),Tt=At?.taskConfigHash!==Le;if(!(!Tt&&!D)){if(Tt){let Gt=At?.blobRef??d().readCardKey(de)??de;b({type:"task-upsert",taskName:de,taskConfig:ye,timestamp:xe()}),Ae.write(de,{blobRef:Gt,taskConfigHash:Le,updatedAt:xe()});}D&&b({type:"task-restart",taskName:de,timestamp:xe()});}}return _(),X()}catch(y){return te(y)}}function A(E){try{let y=E.params?.token;if(!y)return L("taskFailed requires params.token");let j=E.params?.error??"unknown error",D=Hn(y);if(!D)return L("Invalid callback token");b({type:"task-failed",taskName:D.taskName,error:j,timestamp:xe()});try{g().stream("exec-history").append({taskName:D.taskName,status:"failed",error:j,completedAt:xe()});}catch{}return _(),X()}catch(y){return te(y)}}function T(E){try{let y=E.params?.token;if(!y)return L("taskProgress requires params.token");let D=(E.body??{}).update??{},ee=Hn(y);return ee?(b({type:"task-progress",taskName:ee.taskName,update:D,timestamp:xe()}),_(),X()):L("Invalid callback token")}catch(y){return te(y)}}function B(E){try{let y=E.params?.token,j=E.params?.ref;if(!y)return L("sourceDataFetched requires params.token");if(!j)return L("sourceDataFetched requires params.ref");let D=ed(y);if(!D)return L("Invalid source token");let{cbk:ee,cid:de,b:Pe,d:ye,cs:Le,rqt:Ae}=D,At=Gn(t.blobStorage("sources"),It=>t.resolveBlob(It)),Tt=t.genId();At.ingestSourceDataStaged(de,ye,We(j),Tt);let Gt=Hn(ee);if(!Gt)return L("Invalid callback token embedded in source token");let Jt=xe();return b({type:"task-progress",taskName:Gt.taskName,update:{bindTo:Pe,outputFile:ye,fetchedAt:Jt,deliveryToken:Tt,sourceChecksum:Le,rqt:Ae},timestamp:Jt}),_(),X()}catch(y){return te(y)}}function Q(E){try{let y=E.params?.token,j=E.params?.reason??"unknown";if(!y)return L("sourceDataFetchFailure requires params.token");let D=ed(y);if(!D)return L("Invalid source token");let{cbk:ee,b:de,d:Pe,cs:ye,rqt:Le}=D,Ae=Hn(ee);return Ae?(b({type:"task-progress",taskName:Ae.taskName,update:{bindTo:de,outputFile:Pe,failure:!0,reason:j,sourceChecksum:ye,rqt:Le},timestamp:xe()}),_(),X()):L("Invalid callback token embedded in source token")}catch(y){return te(y)}}function Z(E){try{let y=i().readCardStoreRef();return y?X({storeRef:y}):L(`Board at ${e.value} has no card store configured`)}catch(y){return te(y)}}function ie(E){try{let y=i().readOutputsStoreRef();return y?X({storeRef:y}):L(`Board at ${e.value} has no outputs store configured`)}catch(y){return te(y)}}function P(E){try{let y=i().readScratchStoreRef();return X({storeRef:y})}catch(y){return te(y)}}function N(E){try{let y=i().readArchiveStoreRef();return X({storeRef:y})}catch(y){return te(y)}}function z(E){try{let y=i().readChatStoreRef();return X({storeRef:y})}catch(y){return te(y)}}function ce(E){try{let y=i().readArtifactsStoreRef();return X({storeRef:y})}catch(y){return te(y)}}function ne(E){try{let y=E.params?.key;if(!y)return L("getConfig requires params.key");let j=i(),D;switch(y){case "task-executor":D=j.readTaskExecutorRef()??null;break;case "chat-handler-flow":D=j.readChatHandlerFlow()??null;break;case "card-store-ref":D=j.readCardStoreRef();break;case "outputs-store-ref":D=j.readOutputsStoreRef();break;case "scratch-store-ref":D=j.readScratchStoreRef();break;case "archive-store-ref":D=j.readArchiveStoreRef();break;case "chat-store-ref":D=j.readChatStoreRef();break;case "artifacts-store-ref":D=j.readArtifactsStoreRef();break;default:return L(`getConfig: unknown key "${y}"`)}return X({value:D})}catch(y){return te(y)}}function je(E){try{let y=E.params?.key;if(!y)return L("getOutputsDataObject requires params.key");let j=l().readDataObject(y);return X(j)}catch(y){return te(y)}}function U(E){try{return X(l().readAllDataObjects())}catch(y){return te(y)}}function we(E){try{let y=E.params?.key;if(!y)return L("getOutputsComputedValues requires params.key");let j=l().readComputedValues(y);return X(j)}catch(y){return te(y)}}function Oe(E){try{return X(l().readAllComputedValues())}catch(y){return te(y)}}function rt(){return Gn(t.blobStorage("sources"),E=>t.resolveBlob(E))}function nt(E){let y=t.blobStorage("sources").keyRef?.(E);return y?pe(y):E}function xt(E){try{let y=E.params?.key;if(!y)return L("getOutputsFetchedSources requires params.key");let j=rt().listSources(y),D={};for(let ee of j)D[ee]=nt(`${y}/${ee}`);return X(D)}catch(y){return te(y)}}function Kt(E){try{let y=rt(),j=new Set;for(let ee of t.blobStorage("sources").listKeys()){let de=ee.indexOf("/");de>0&&!ee.includes("/.staged/")&&j.add(ee.slice(0,de));}let D={};for(let ee of j){let de=y.listSources(ee);if(de.length>0){D[ee]={};for(let Pe of de)D[ee][Pe]=nt(`${ee}/${Pe}`);}}return X(D)}catch(y){return te(y)}}return {init:I,status:S,getCardStoreRef:Z,getOutputsStoreRef:ie,getScratchStoreRef:P,getArchiveStoreRef:N,getChatStoreRef:z,getArtifactsStoreRef:ce,getConfig:ne,getOutputsDataObject:je,getAllOutputsDataObjects:U,getOutputsComputedValues:we,getAllOutputsComputedValues:Oe,getOutputsFetchedSources:xt,getAllOutputsFetchedSources:Kt,removeCard:k,addCardFiles:w,cardRefreshedNotify:p,retrigger:h,processAccumulatedEvents:R,upsertCard:x,taskFailed:A,taskProgress:T,sourceDataFetched:B,sourceDataFetchFailure:Q}}function fy(e,t){let r=()=>sa(t.kvStorage("config"));function n(){let S=r().readCardStoreRef();if(!S)throw new Error(`Board at ${e.value} has no card store configured. Run: init --base-ref <ref> --store-ref <b64-ref>`);let k=t.kvStorageForRef(S);return {readIndex(){return k.read("_index")},writeIndex(w){k.write("_index",w);},readCard(w){return k.read(w)},writeCard(w,p){return k.write(w,p),t.hashFn(p)},removeCard(w){k.delete(w);},cardExists(w){return k.read(w)!==null},defaultCardKey(w){return w}}}let s=()=>Kn(n(),t.onWarn??(()=>{})),o=()=>{let S=r().readScratchStoreRef();return S?t.scratchStorageForRef(S):t.scratchStorage()};function a(S,k){let w=t.validateSchema(k),p=[],h=r().readTaskExecutorRef();if(h&&Array.isArray(k.source_defs))for(let x of k.source_defs){let A=typeof x.bindTo=="string"?x.bindTo:"(unknown)";try{let T;try{T=t.invokeExecutorSync(h,"validate-source-def",[],{timeout:t.executorTimeouts?.validationMs??1e4,input:JSON.stringify(x)});}catch(Q){let Z=Q;if(T=typeof Z?.stdout=="string"?Z.stdout:"",!T.trim()){p.push(`source "${A}": executor validate-source-def failed \u2014 ${Q instanceof Error?Q.message:String(Q)}`);continue}}let B=JSON.parse(T.trim());if(!B.ok&&Array.isArray(B.errors))for(let Q of B.errors)p.push(`source "${A}": ${Q}`);}catch(T){p.push(`source "${A}": executor validate-source-def failed \u2014 ${T instanceof Error?T.message:String(T)}`);}}let R=[...w.errors,...p];return X({cardId:S,isValid:R.length===0,issues:R})}function i(S,k){let w=r().readTaskExecutorRef();if(!w)throw new Error("No task-executor registered for this board");let p=typeof S.bindTo=="string"?S.bindTo:"source",h=o(),R={...S,boardDir:e.value,_projections:k},x=h.create(JSON.stringify(R,null,2),`probe-in-${p}`,".json"),A=h.getUniqueKey(`probe-out-${p}`,".json"),T=h.getUniqueKey(`probe-err-${p}`,".txt"),B=pe(h.keyRef(x)),Q=pe(h.keyRef(A)),Z=pe(h.keyRef(T)),ie=null;try{if(t.invokeExecutorSync(w,"run-source-fetch",["--in-ref",B,"--out-ref",Q,"--err-ref",Z],{timeout:S.timeout??t.executorTimeouts?.probeMs??6e4}),ie=h.read(A),ie===null)throw new Error("Executor produced no output file")}catch(P){let N=h.read(T)?.trim()??(P instanceof Error?P.message:String(P));throw new Error(`Probe failed: ${N}`)}finally{try{h.remove(x);}catch{}try{h.remove(T);}catch{}}return {bindTo:p,result:ie}}function u(S,k,w){let p;try{p=i(S,k);}catch(h){return L(h instanceof Error?h.message:String(h))}if(w){let h=We(w);t.absoluteBlob.write(h.value,p.result);}return X({bindTo:p.bindTo,resultSizeBytes:p.result.length})}function c(S,k){let w=S.params?.sourceIdx,p=S.params?.outRef;if(w===void 0)return L(`${k} requires params.sourceIdx`);if(!S.body||typeof S.body!="object"||Array.isArray(S.body))return L(`${k} requires card JSON object in body`);let h=S.body,R=h["card-content"]??h,x=h["mock-projections"]??{},A=R.source_defs??[];if(w<0||w>=A.length)return L(`sourceIdx ${w} out of range (card has ${A.length} source(s))`);let T=A[w],B=typeof T.bindTo=="string"?T.bindTo:"source";return {src:T,bindTo:B,outRef:p,mockProjections:x}}function d(S){try{let k=S.params?.cardId,w=S.params?.all;if(!k&&!w)return L("validateCard requires --card-id <id> or --all");let p=w?s().readAllCards().map(R=>R.id):[k],h=[];for(let R of p){let x=s().readCard(R);if(!x){h.push({cardId:R,isValid:!1,issues:[`Card "${R}" not found`]});continue}let A=a(R,x);if(A.status!=="success")return A;h.push(A.data);}return X(h)}catch(k){return te(k)}}function l(S){try{if(!S.body||typeof S.body!="object"||Array.isArray(S.body))return L("validateCardPreflight requires card JSON object in body");let k=S.body,w=k["card-content"]??k,p=typeof w.id=="string"?w.id:"(unknown)";return a(p,w)}catch(k){return te(k)}}function g(S){try{let k=S.params?.cardId,w=S.params?.sourceIdx,p=S.params?.outRef;if(!k)return L("probeSource requires params.cardId");if(w===void 0)return L("probeSource requires params.sourceIdx");let R=(S.body??{})["mock-projections"]??{},x=s().readCard(k);if(!x)return L(`Card "${k}" not found`);let A=x.source_defs??[];return w<0||w>=A.length?L(`sourceIdx ${w} out of range (card has ${A.length} source(s))`):u(A[w],R,p)}catch(k){return te(k)}}function v(S){try{let k=S.params?.outRef,w=S.body;if(!w)return L('probeTmpSource requires body with "source-def" and "mock-projections"');let p=w["source-def"],h=w["mock-projections"]??{};return p?u(p,h,k):L('probeTmpSource body requires "source-def"')}catch(k){return te(k)}}function f(S){try{let k=c(S,"probeSourcePreflight");if("status"in k)return k;let w=r().readTaskExecutorRef();if(!w)return L("No task-executor registered for this board");try{let p={...k.src,_projections:k.mockProjections},h=t.invokeExecutorSync(w,"probe-source-preflight",[],{timeout:k.src.timeout??t.executorTimeouts?.preflightMs??6e4,input:JSON.stringify(p)}),R=JSON.parse(h.trim());return R.ok?X({bindTo:k.bindTo,reachable:R.reachable,latencyMs:R.latencyMs,note:R.note}):L(R.error??"Preflight probe failed")}catch{return L("Executor does not support probe-source-preflight")}}catch(k){return te(k)}}function m(S){try{let k=c(S,"runSourcePreflight");if("status"in k)return k;try{let w=i(k.src,k.mockProjections);if(k.outRef){let h=We(k.outRef);t.absoluteBlob.write(h.value,w.result);}let p=w.result;try{p=JSON.parse(w.result);}catch{}return X({bindTo:w.bindTo,ok:!0,result:p,issues:[]})}catch(w){let p=w instanceof Error?w.message:String(w);return p==="No task-executor registered for this board"?L(p):X({bindTo:k.bindTo,ok:!1,result:null,issues:[p]})}}catch(k){return te(k)}}function b(S){try{let k=r().readTaskExecutorRef();if(!k)return L("No task-executor registered for this board");let w=t.invokeExecutorSync(k,"describe-capabilities",[],{timeout:t.executorTimeouts?.describeMs??1e4});return X(JSON.parse(w.trim()))}catch(k){return te(k)}}function C(S){try{let k=S.body;if(!k||!Array.isArray(k.ops))return L("updatesInCardStore requires body.ops array");let w=k.ops,p=s();for(let h of w){let R=h.op,x=h.id;if(!x)return L('op is missing "id"');if(R==="update"){let A=h["card-content"];if(!A)return L(`update op for "${x}" is missing "card-content"`);p.writeCard(x,A);}else return L(`Unknown op type: "${R??"(none)"}"`)}return X()}catch(k){return te(k)}}function F(S){try{let k=S.body;if(!k||!Array.isArray(k.ids))return L("readFromCardStore requires body.ids array");let w=k.ids,p=s(),h=w.map(R=>({id:R,"card-content":p.readCard(R)}));return X({cards:h})}catch(k){return te(k)}}function _(S){try{if(!S.body||typeof S.body!="object"||Array.isArray(S.body))return L("evalCardCompute requires a JSON object in body");let k=S.body,w=k["card-content"]??k,p=typeof w.id=="string"?w.id:"(unknown)",h=k["mock-fetched-sources"]??{},R=k["mock-requires"]??{},x=w.compute;if(!x||!Array.isArray(x)||x.length===0)return X({cardId:p,ok:!0,computed_values:{},errors:[]});let A={id:p,card_data:w.card_data??{},requires:R,source_defs:w.source_defs,compute:x},T=ct.runSync(A,{sourcesData:h}),B=T.node.computed_values??{},Q=T.errors??[];return X({cardId:p,ok:Q.length===0,computed_values:B,errors:Q})}catch(k){return te(k)}}function I(S){try{if(!S.body||typeof S.body!="object"||Array.isArray(S.body))return L("simulateCardCycle requires a JSON object in body");let k=S.body,w=k["card-content"]??k,p=typeof w.id=="string"?w.id:"(unknown)",h=k["mock-fetched-sources"]??{},R=k["mock-requires"]??{},x=a(p,w),A=x.status==="success"?{isValid:x.data.isValid,issues:x.data.issues}:{isValid:!1,issues:[x.status==="fail"?x.error:"internal error"]},T=w.source_defs??[],B=w.card_data??{},Q=[],Z=[];if(T.length>0){Q=ct.enrichSourcesSync(T,{card_data:B,requires:R});for(let U of Q){let we=U.projections,Oe=U._projections;if(we&&Oe){for(let rt of Object.keys(we))if(Oe[rt]===void 0){let nt=typeof U.bindTo=="string"?U.bindTo:"(unknown)";Z.push({bindTo:nt,key:rt,error:`Projection "${rt}" resolved to undefined`});}}}}let ie=[],P=k["task-executor-ref"],N=(P?.howToRun&&P?.whatToRun?P:void 0)??r().readTaskExecutorRef();for(let U=0;U<Q.length;U++){let we=Q[U],Oe=typeof we.bindTo=="string"?we.bindTo:`source_${U}`;if(!N){ie.push({bindTo:Oe,skipped:!0,error:"No task executor configured"});continue}try{let rt={...we},nt=t.invokeExecutorSync(N,"run-source-preflight",[],{timeout:we.timeout??t.executorTimeouts?.preflightMs??6e4,input:JSON.stringify(rt)}),xt=JSON.parse(nt.trim());ie.push({bindTo:Oe,reachable:xt.reachable,latencyMs:xt.latencyMs,error:xt.ok?void 0:xt.error});}catch{ie.push({bindTo:Oe,skipped:!0,error:"Executor does not support run-source-preflight"});}}let z=w.compute,ce={},ne=[];if(z&&Array.isArray(z)&&z.length>0){let U={id:p,card_data:B,requires:R,source_defs:w.source_defs,compute:z},we=ct.runSync(U,{sourcesData:h});ce=we.node.computed_values??{},ne=we.errors??[];}let je=A.isValid&&Z.length===0&&ne.length===0&&ie.every(U=>U.reachable!==!1);return X({cardId:p,ok:je,validation:A,source_probes:ie,projection_errors:Z,computed_values:ce,compute_errors:ne})}catch(k){return te(k)}}return {validateCard:d,validateCardPreflight:l,probeSource:g,probeTmpSource:v,probeSourcePreflight:f,runSourcePreflight:m,evalCardCompute:_,simulateCardCycle:I,describeTaskExecutorCapabilities:b,updatesInCardStore:C,readFromCardStore:F}}function _e(e,t){if(e?.status==="success")return Object.prototype.hasOwnProperty.call(e,"data")?e.data:void 0;throw e?.status==="fail"||e?.status==="error"?new Error(e.error||`${t} failed`):new Error(`${t} returned an unexpected response`)}function py(e,t){if(e?.status==="success"&&Object.prototype.hasOwnProperty.call(e,"data"))return e.data;throw e?.status==="success"?new Error(`${t} returned success without data`):e?.status==="fail"||e?.status==="error"?new Error(e.error||`${t} failed`):new Error(`${t} returned an unexpected response`)}function V(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}function Se(e){return Array.isArray(e)?e:[]}function ia(e,t){if(typeof t!="string"||t.length===0)return;let r=e,n=t;n.startsWith("fetched_sources.")&&(r=V(e).fetched_sources,n=n.slice(16));for(let s of n.split(".")){if(r==null||typeof r!="object")return;r=r[s];}return r}function aa(e,t){let r=V(e.view),n=Se(r.elements);return {layout:r.layout,features:r.features,elements:n.map((s,o)=>{let a=V(s),i=V(a.data),u=typeof a.visible=="string"?!!ia(t,a.visible):true,c=typeof i.bind=="string"?i.bind:void 0,d=c?ia(t,c):void 0,l={id:typeof a.id=="string"&&a.id?a.id:`element-${o}`,kind:a.kind,label:a.label,visible:u};return c&&(l.bind=c),Array.isArray(i.columns)&&(l.columns=i.columns),typeof i.maxRows=="number"&&(l.maxRows=i.maxRows),d!==void 0&&(l.resolved=Array.isArray(d)&&typeof l.maxRows=="number"?d.slice(0,l.maxRows):d),l})}}function rd(e,t){let r=typeof e.id=="string"&&e.id?e.id:"card",n=Se(e.provides),s=n.length>0?n:[{bindTo:r,ref:"card_data"}],o={};for(let a of s){let i=V(a),u=typeof i.bindTo=="string"?i.bindTo:"",c=typeof i.ref=="string"?i.ref:"";if(!u||!c)continue;let d=ia(t,c);d!==void 0&&(o[u]=d);}return o}function my(e){if(typeof e!="string"||!e.trim())return null;let t=/^(file uploaded|AI generated|AI geneterated):\s*.*?#(\d+)\s*$/i.exec(e.trim());if(!t)return null;let r=Number.parseInt(t[2],10);return !Number.isInteger(r)||r<0?null:r}function gy(e){return {"card-content":e}}function Kr(e,t){let r=_e(e.get({params:{id:t}}),"cardStore.get"),n=Array.isArray(r?.cards)?r.cards:[];if(n.length===0)throw new Error(`Card "${t}" not found`);return n[0]}function hy(e){let{board:t,nonCore:r,cardStore:n,chatStore:s,uploadCardFile:o,buildFileDownloadUrl:a,readFetchedSourceJsonByRef:i}=e;function u(p){if(Array.isArray(p.bytes))return new Uint8Array(p.bytes.map(h=>Math.max(0,Math.min(255,Number(h)||0))));if(typeof p.text=="string")return new TextEncoder().encode(p.text);if(typeof p.base64=="string"){let h=String(p.base64).replace(/-/g,"+").replace(/_/g,"/"),R=h+"=".repeat((4-h.length%4)%4),x=atob(R);return Uint8Array.from(x,A=>A.charCodeAt(0))}throw new Error("file entry requires bytes, text, or base64")}function c(){let p=V(_e(r.describeTaskExecutorCapabilities({}),"describeTaskExecutorCapabilities"));return {version:p.version,commonSourceFields:V(p.commonSourceDefFields),sourceKinds:V(p.sourceKinds)}}function d(){let p=V(_e(t.status({}),"status")),h=V(p.summary),R=Se(p.cards);return {meta:V(p.meta),summary:{card_count:typeof h.card_count=="number"?h.card_count:0,completed:typeof h.completed=="number"?h.completed:0,eligible:typeof h.eligible=="number"?h.eligible:0,pending:typeof h.pending=="number"?h.pending:0,blocked:typeof h.blocked=="number"?h.blocked:0,in_progress:typeof h.in_progress=="number"?h.in_progress:0,failed:typeof h.failed=="number"?h.failed:0,unresolved:typeof h.unresolved=="number"?h.unresolved:0},cards:R.map(x=>{let A=V(x);return {"card-id":typeof A.name=="string"?A.name:null,status:A.status??null,error:A.error??null,requires:Se(A.requires),requires_satisfied:Se(A.requires_satisfied),requires_missing:Se(A.requires_missing),provides_declared:Se(A.provides_declared),provides_runtime:Se(A.provides_runtime)}})}}function l(p){let h=String(p.cardId||"").trim();if(!h)throw new Error("inspectCardDefinitionAndRuntime requires cardId");let R=V(_e(t.status({}),"status")),A=Se(R.cards).map(V).find(U=>U.name===h);if(!A)throw new Error(`card "${h}" not found in board status`);let T=V(Kr(n,h)),B=Se(A.requires_satisfied).filter(U=>typeof U=="string"&&!!U),Q=Se(A.provides_runtime).filter(U=>typeof U=="string"&&!!U),Z=Object.fromEntries(B.map(U=>[U,_e(t.getOutputsDataObject({params:{key:U}}),`getOutputsDataObject(${U})`)])),ie=Object.fromEntries(Q.map(U=>[U,_e(t.getOutputsDataObject({params:{key:U}}),`getOutputsDataObject(${U})`)])),P=V(_e(t.getOutputsComputedValues({params:{key:h}}),"getOutputsComputedValues")),N=_e(t.getOutputsFetchedSources({params:{key:h}}),"getOutputsFetchedSources"),z=Se(T.source_defs).map(V),ce={};for(let U of z)typeof U.bindTo=="string"&&typeof U.outputFile=="string"&&(ce[U.outputFile]=U.bindTo);let ne={};for(let[U,we]of Object.entries(N)){let Oe=ce[U]??U;if(!i||typeof we!="string"){ne[Oe]=null;continue}try{ne[Oe]=i({cardId:h,ref:we});}catch{ne[Oe]=null;}}let je={card_data:V(T.card_data),requires:Z,fetched_sources:ne,computed_values:P};return {cardId:h,card_status_in_board:A,card_definition_and_static_data:T,refs_for_fetched_source_files:N,runtime_data:{requires:Z,provides:ie,computed_values:P,rendered_view:aa(T,je)}}}function g(p){let h=String(p.cardId||"").trim();if(!h)throw new Error("inspectChatMessagesOnCards requires cardId");let R=typeof p.turnId=="string"?p.turnId:"",x=p.allTurns===true,A=typeof p.tailTurnsBeforeId=="string"?p.tailTurnsBeforeId:"",T=x?void 0:p.lastUserTurns??(R?void 0:1),B=p.tail,Q={...T===void 0?{}:{tailTurns:T},...R?{turnId:R}:{},...x?{allTurns:true}:{},...A?{tailTurnsBeforeId:A}:{}},Z=Object.keys(Q).length>0?{params:{cardId:h},body:Q}:{params:{cardId:h}},ie=_e(s.readAll(Z),"chatStore.readAll"),P=V(Kr(n,h)),N=Se(V(P.card_data).files).map((ne,je)=>({idx:je,stored_name:V(ne).stored_name})).filter(ne=>typeof ne.stored_name=="string"&&ne.stored_name.length>0),ce=(Array.isArray(ie.records)?ie.records:[]).map(ne=>{let U=V(ne.payload),we={...ne},Oe=typeof ne?.role=="string"?ne.role:typeof U.role=="string"?String(U.role):"",rt=typeof ne?.text=="string"?ne.text:typeof U.text=="string"?String(U.text):"";if(Oe==="system"){let nt=my(rt);if(nt!==null&&N.some(Kt=>Kt.idx===nt)){let Kt=`Retrieve using inspect-file-contents --card-id ${h} --file-idx ${nt}`;we.retrieval_hint=Kt,Object.keys(U).length>0&&typeof ne.role!="string"&&(we.payload={...U,retrieval_hint:Kt});}}return we});return {cardId:h,messages:typeof B=="number"&&B>=0?ce.slice(-B):ce}}function v(p){let h=String(p.cardId||"").trim(),R=Number(p.fileIdx);if(!h)throw new Error("inspectFileContents requires cardId");if(!Number.isInteger(R)||R<0)throw new Error("inspectFileContents requires fileIdx to be a non-negative integer");let x=V(Kr(n,h)),A=Se(V(x.card_data).files).map(V);if(R>=A.length)throw new Error(`attachment index ${R} is out of range for card "${h}"`);let T=A[R],B=typeof T.stored_name=="string"?T.stored_name:null;return {cardId:h,fileIdx:R,downloadUrl:a({cardId:h,fileIdx:R,storedName:B}),...typeof T.name=="string"?{name:T.name}:{},...typeof T.stored_name=="string"?{stored_name:T.stored_name}:{},...typeof T.mime_type=="string"?{mime_type:T.mime_type}:{},...typeof T.size=="number"?{size:T.size}:{},...typeof T.uploaded_at=="string"?{uploaded_at:T.uploaded_at}:{}}}function f(p){return r.validateCardPreflight({body:gy(p.candidateCardContent)})}function m(p){if(!p.mockRequires||typeof p.mockRequires!="object"||Array.isArray(p.mockRequires))throw new Error("preflightMaterializeCandidateCard requires mockRequires");if(!p.mockFetchedSources||typeof p.mockFetchedSources!="object"||Array.isArray(p.mockFetchedSources))throw new Error("preflightMaterializeCandidateCard requires mockFetchedSources");let h=r.evalCardCompute({body:{"card-content":p.candidateCardContent,"mock-requires":p.mockRequires,"mock-fetched-sources":p.mockFetchedSources}});if(h.status!=="success")return h;let R=V(py(h,"evalCardCompute")),x=V(p.candidateCardContent),A={card_data:V(x.card_data),requires:V(p.mockRequires),fetched_sources:V(p.mockFetchedSources),computed_values:V(R.computed_values)};return {status:"success",data:{cardId:typeof R.cardId=="string"?R.cardId:typeof x.id=="string"?x.id:"(unknown)",ok:R.ok===true,computed_values:V(R.computed_values),errors:Se(R.errors).map(T=>{let B=V(T);return {bindTo:typeof B.bindTo=="string"?B.bindTo:"",error:typeof B.error=="string"?B.error:""}}),provides_outputs:rd(x,A),rendered_view:aa(x,A)}}}function b(p){return r.probeSourcePreflight({params:{sourceIdx:p.sourceIdx},body:{"card-content":p.candidateCardContent,"mock-projections":p.mockProjections}})}function C(p){return r.runSourcePreflight({params:{sourceIdx:p.sourceIdx},body:{"card-content":p.candidateCardContent,"mock-projections":p.mockProjections}})}function F(p){let h=String(p.cardId||"").trim();if(!h)throw new Error("preflightRunSingleSourceInLiveCard requires cardId");if(!p.mockRequires||typeof p.mockRequires!="object"||Array.isArray(p.mockRequires))throw new Error("preflightRunSingleSourceInLiveCard requires mockRequires");let R=V(Kr(n,h)),x=Se(R.source_defs).filter(T=>!!T&&typeof T=="object"&&!Array.isArray(T)),A={};if(p.sourceIdx>=0&&p.sourceIdx<x.length){let T=x[p.sourceIdx],B=ct.enrichSourcesSync([T],{card_data:V(R.card_data),requires:p.mockRequires});Array.isArray(B)&&B.length>0&&(A=V(B[0]._projections));}return r.runSourcePreflight({params:{sourceIdx:p.sourceIdx},body:{"card-content":R,"mock-requires":p.mockRequires,"mock-projections":A}})}function _(p){let h=V(_e(r.simulateCardCycle({body:{"card-content":p.candidateCardContent,"mock-requires":p.mockRequires}}),"simulateCardCycle")),R=V(p.candidateCardContent),x=V(h.validation),A=Se(h.source_probes),T=Se(h.projection_errors),B=Se(h.compute_errors),Q=V(h.computed_values),Z={card_data:V(R.card_data),requires:p.mockRequires,fetched_sources:{},computed_values:Q},ie=[];for(let P of Se(x.issues))typeof P=="string"&&P&&ie.push(P);for(let P of A){let N=V(P),z=typeof N.bindTo=="string"?N.bindTo:"source",ce=typeof N.error=="string"?N.error:"";ce&&ie.push(`${z}: ${ce}`);}for(let P of T){let N=V(P),z=typeof N.bindTo=="string"?N.bindTo:"source",ce=typeof N.key=="string"?N.key:"projection",ne=typeof N.error=="string"?N.error:"projection failed";ie.push(`${z}.${ce}: ${ne}`);}for(let P of B){let N=V(P),z=typeof N.bindTo=="string"?N.bindTo:"compute",ce=typeof N.error=="string"?N.error:"compute failed";ie.push(`${z}: ${ce}`);}return {status:"success",data:{cardId:typeof h.cardId=="string"?h.cardId:"(unknown)",ok:h.ok===true,issues:ie,provides_outputs:rd(R,Z),rendered_view:aa(R,Z)}}}function I(p){let h=String(p.cardId||"").trim();if(!h)throw new Error("manageReadCard requires cardId");let R=_e(n.get({params:{id:h}}),"cardStore.get");return Array.isArray(R.cards)?R.cards:[]}function S(p){let h=String(p.cardId||"").trim(),R=String(p.role||"").trim(),x=typeof p.text=="string"?p.text:"",A=typeof p.turn=="string"?p.turn:"";if(!h)throw new Error("manageAddChatEntryAndAnyAttachments requires cardId");if(!R)throw new Error("manageAddChatEntryAndAnyAttachments requires role");let T=Se(p.files).map(Q=>{let Z=V(Q),ie=String(Z.file_name??Z.fileName??Z.name??"").trim(),P=String(Z.content_type??Z.contentType??"application/octet-stream");if(!ie)throw new Error("file entry requires file_name");return o({cardId:h,fileName:ie,contentType:P,bytes:u(Z)}).file});T.forEach((Q,Z)=>{let ie=R==="assistant"?`AI generated: ${String(Q.name||"")} as ${String(Q.stored_name||"")} #${Z}`:`file uploaded: ${String(Q.name||"")} as ${String(Q.stored_name||"")} #${Z}`;_e(s.append({params:{cardId:h},body:{role:"system",text:ie,files:[],turn:A}}),"chatStore.append(system attachment message)");});let B=_e(s.append({params:{cardId:h},body:{role:R,text:x,files:T,turn:A}}),"chatStore.append");return {status:"success",data:{cardId:h,id:String(B.id),role:R,turn:A,files:T}}}function k(p){let h=String(p.cardId||"").trim(),R=V(p.candidateCardContent);if(!h)throw new Error("manageUpsertCard requires cardId");if(typeof R.id!="string"||!R.id.trim())throw new Error("candidateCardContent.id must be a non-empty string");if(R.id!==h)throw new Error(`candidateCardContent.id must match cardId (${h})`);let x=f({candidateCardContent:R}),A=V(x),T=V(A.data);if(A.status!=="success"||T.isValid!==true)return {status:"fail",step:"validate",validation:x};let B=null;try{B=Kr(n,h);}catch{B=null;}let Q=n.set({body:R});_e(Q,"cardStore.set");let Z;try{Z=t.upsertCard({params:{cardId:h,restart:!0}}),_e(Z,"upsertCard");}catch(P){try{B&&n.set({body:B});}catch{}throw P}let ie=null;try{ie=t.cardRefreshedNotify({params:{cardId:h}}),_e(ie,"cardRefreshedNotify");}catch{ie=null;}return {status:"success",data:{validation:x,card_saved:null,board_result:Z,refresh_notify:ie}}}function w(p){let h=String(p.cardId||"").trim();if(!h)throw new Error("manageDeprecate requires cardId");let R=t.removeCard({params:{id:h}});return _e(R,"removeCard"),R}return {discoverSourceKinds:c,inspectBoardRuntimeStatus:d,inspectCardDefinitionAndRuntime:l,inspectChatMessagesOnCards:g,inspectFileContents:v,preflightValidateCandidateCardDefinition:f,preflightMaterializeCandidateCard:m,preflightProbeSingleSourceInCandidateCard:b,preflightRunSingleSourceInCandidateCard:C,preflightRunSingleSourceInLiveCard:F,preflightRunOneCycleWithCandidateCard:_,manageReadCard:I,manageAddChatEntryAndAnyAttachments:S,manageUpsertCard:k,manageDeprecate:w}}function yy(e){function t(s){return {status:"success",data:s}}function r(s){return {status:"fail",error:s}}function n(s){return {status:"error",error:s instanceof Error?s.message:String(s)}}return {list(s){try{let o=s.params?.prefix??"";return t({artifacts:e.list(o)})}catch(o){return n(o)}},head(s){try{let o=s.params?.key;return o?t({artifact:e.head(o)}):r("head requires params.key")}catch(o){return n(o)}},put(s){try{let o=s.params?.key,a=s.params?.contentType;if(!o)return r("put requires params.key");let i=s.body;if(typeof i=="string")return t({artifact:e.putText(o,i,a)});if(i&&typeof i=="object"&&typeof i.text=="string")return t({artifact:e.putText(o,i.text,a)});if(i&&typeof i=="object"&&Array.isArray(i.bytes)){let u=i.bytes,c=new Uint8Array(u.map(d=>Math.max(0,Math.min(255,Number(d)||0))));return t({artifact:e.putBytes(o,c,a)})}return r("put requires body as string, {text}, or {bytes:number[]}")}catch(o){return n(o)}},get(s){try{let o=s.params?.key,a=s.params?.as??"base64";if(!o)return r("get requires params.key");let i=e.head(o);if(!i)return r(`artifact "${o}" not found`);if(a==="text"){let c=e.getText(o);return c===null?r(`artifact "${o}" not found`):t({key:o,contentType:i.contentType,size:i.size,text:c})}let u=e.getBytes(o);return u===null?r(`artifact "${o}" not found`):t({key:o,contentType:i.contentType,size:i.size,bytes:[...u]})}catch(o){return n(o)}},del(s){try{let o=s.params?.key;return o?(e.remove(o),t({ok:!0})):r("del requires params.key")}catch(o){return n(o)}}}}function nd(){return new Date().toISOString()}function sd(e){return new TextEncoder().encode(e).byteLength}function vy(e){return e?{key:e.key,size:e.size,updatedAt:e.updatedAt,contentType:e.contentType}:null}function Sy(e){let t=String(e||"").match(/^(\d+)[-_]/);return t?parseInt(t[1],10):0}function wy(e){let t=String(e||"").trim();if(!t)return "upload.bin";let r=Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\"));return (r>=0?t.slice(r+1):t)||"upload.bin"}function ky(e){return String(e||"").toLowerCase().replace(/\s+/g,"_").replace(/[^a-z0-9_-]/g,"_").replace(/_+/g,"_").replace(/^_+|_+$/g,"")||"file"}function by(e){if(!e||e===".")return "";let t=String(e).replace(/^\./,"").toLowerCase().replace(/[^a-z0-9]/g,"");return t?`.${t}`:""}function Ry(e){let t=wy(e),r=t.lastIndexOf(".");return r<=0||r===t.length-1?{stem:t,ext:""}:{stem:t.slice(0,r),ext:t.slice(r)}}function _y(e){let t=e.lastIndexOf("/");return t>=0?e.slice(t+1):e}function ca(e){function t(r){let n=e.stat?vy(e.stat(r)):null;if(n)return n;if(!e.exists(r))return null;let s=e.read(r);return s===null?{key:r}:{key:r,size:sd(s)}}return {exists(r){return e.exists(r)},putText(r,n,s="text/plain; charset=utf-8"){e.write(r,n);let o=t(r)??{key:r};return o.contentType=s,o.updatedAt=o.updatedAt??nd(),o.size=o.size??sd(n),o},putBytes(r,n,s="application/octet-stream"){if(e.writeBytes)e.writeBytes(r,n);else {let a=JSON.stringify({__kind:"bytes-array",data:[...n]});e.write(r,a);}let o=t(r)??{key:r};return o.contentType=s,o.updatedAt=o.updatedAt??nd(),o.size=o.size??n.byteLength,o},getText(r){let n=e.read(r);if(n===null){if(!e.readBytes)return null;let s=e.readBytes(r);return s===null?null:Buffer.from(s).toString("utf-8")}try{let s=JSON.parse(n);if(s&&s.__kind==="bytes-array"&&Array.isArray(s.data))return new TextDecoder("utf-8").decode(new Uint8Array(s.data))}catch{}return n},getBytes(r){if(e.readBytes){let s=e.readBytes(r);if(s!==null)return s}let n=e.read(r);if(n===null)return null;try{let s=JSON.parse(n);if(s&&s.__kind==="bytes-array"&&Array.isArray(s.data))return new Uint8Array(s.data)}catch{}return new TextEncoder().encode(n)},head:t,list(r=""){return e.listKeys(r).map(n=>t(n)??{key:n}).sort((n,s)=>n.key.localeCompare(s.key))},remove(r){e.remove(r);}}}function Cy(e){function t(s,o){let a=0,i=[];Array.isArray(o)&&i.push(...o);for(let u of e.list(`${s}/`))i.push(_y(u.key));for(let u of i){let c=Sy(u);Number.isFinite(c)&&c>a&&(a=c);}return a+1}function r(s,o,a){let i=Number(a?.maxLen||32),{stem:u,ext:c}=Ry(s),d=by(c),l=ky(u),g=`${String(o).padStart(3,"0")}-`,v=d,f=i-g.length-v.length;f<1&&(v="",f=i-g.length);let m=l.slice(0,Math.max(1,f)),b=`${g}${m}${v}`;return b.length>i&&(b=b.slice(0,i).replace(/\.$/,"")),b}function n(s,o,a){let i=t(s,a?.seedNames),u=r(o,i,{maxLen:a?.maxLen});for(;e.exists(`${s}/${u}`);)i+=1,u=r(o,i,{maxLen:a?.maxLen});return u}return {nextSerial:t,buildStoredName:r,allocateStoredName:n}}function $y(){function e(s,o){if(!Array.isArray(s))return [];let a=[];for(let i of s){if(!i||typeof i!="object")continue;let u=i;typeof u.stored_name=="string"&&a.push({name:typeof u.name=="string"?u.name:u.stored_name,stored_name:u.stored_name,size:typeof u.size=="number"&&Number.isFinite(u.size)?u.size:null,mime_type:typeof u.mime_type=="string"?u.mime_type:null,uploaded_at:typeof u.uploaded_at=="string"?u.uploaded_at:o||null,chat:u.chat===true});}return a}function t(s){return !s||typeof s!="object"?[]:e(s.files,void 0)}function r(s,o){let a=t(s);if(o.length===0)return s.files=a,a;let i=new Set(a.map(u=>u.stored_name));for(let u of o)i.has(u.stored_name)||(a.push(u),i.add(u.stored_name));return s.files=a,a}function n(s,o,a){let i=t(s);if(!Number.isInteger(o)||o<0||o>=i.length)return {ok:false,reason:"index_out_of_range"};let u=i[o];return !u||!u.stored_name?{ok:false,reason:"missing_stored_name"}:a&&a!==u.stored_name?{ok:false,reason:"stale_reference"}:{ok:true,file:u}}return {read:t,normalizeIncoming:e,merge:r,resolve:n}}function bw(){return {async invoke(e,t){if(e.howToRun!=="local-node")return {dispatched:false,error:`createNodeSpawnInvocationAdapter: unsupported howToRun "${e.howToRun}"`};let r="";try{let o=e.whatToRun;r=Xe(o);}catch{r="";}if(!r)return {dispatched:false,error:"createNodeSpawnInvocationAdapter: could not resolve executable path from whatToRun"};let n={...t},s=Buffer.from(JSON.stringify(n)).toString("base64");try{return child_process.spawn(process.execPath,[r,"--boardId",String(t.boardId??""),"--cardId",String(t.cardId??""),"--extraEncJson",s],{stdio:"ignore",windowsHide:!0}).unref(),{dispatched:!0}}catch(o){return {dispatched:false,error:o instanceof Error?o.message:String(o)}}},async describe(e){if(e.howToRun!=="local-node")return null;let t="";try{let r=e.whatToRun;t=Xe(r);}catch{t="";}if(!t)return null;try{let r=child_process.spawnSync(process.execPath,[t,"describe"],{timeout:5e3,encoding:"utf-8",windowsHide:!0});return r.status!==0?null:JSON.parse(String(r.stdout).trim())}catch{return null}}}}var Ay=".board.lock";function od(e,t){if(!e||!t)return false;let r=String(e).replace(/[\\/]+$/,"").split(/[\\/]+/).filter(Boolean);return r.length>0&&r[r.length-1]===t}function Ty(e,t){return typeof e=="string"?{cliDir:e,opts:t}:{cliDir:void 0,opts:e}}function Iy(e,t){return typeof e=="string"?{cliDir:e,opts:t}:{cliDir:void 0,opts:e}}function ad(e){if(e)return e;let t=wa((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('board-live-cards-node.cjs', document.baseURI).href))),r=[t,Ne(t,"..","cli","node"),Ne(t,"..","..","cli","node")];for(let n of r)try{return rs(n),n}catch{}throw new Error(`createFsBoardPlatformAdapter: could not resolve a public CLI directory from module dir ${t}`)}function jy(e,t,r){let{cliDir:n,opts:s}=Ty(t,r),o=ad(n),a=e.value,u={meta:"board-live-cards",howToRun:"local-node",whatToRun:(s?.suppressSpawn?"":rs(o))?pe({kind:"yaml-flow-cli",value:"board-live-cards-cli.js"}):"",...s?.notifyChannel?{extra:{notifyChannel:s.notifyChannel}}:{}};return {kvStorage:c=>nn(Ne(a,`.${c}`)),blobStorage:c=>c?Wt(Ne(a,c)):Wt(a),scratchStorage:()=>tn(Ne(a,".tmp")),scratchStorageForRef:c=>tn(We(c).value),archiveFactory:()=>rn(Ne(a,"archive")),archiveFactoryForRef:c=>rn(We(c).value),journalAdapter:()=>Ma(a),lock:Da(Ne(a,Ay)),selfRef:u,async dispatchExecution(c,d){if(s?.suppressSpawn)return {dispatched:false};try{let l=d.source_def?.bindTo??Zn().slice(0,8),g=tn(Ne(a,".tmp")),v=g.create(JSON.stringify(d,null,2),`exec-in-${l}`,".json"),f=g.getUniqueKey(`exec-out-${l}`,".json"),m=g.getUniqueKey(`exec-err-${l}`,".txt"),b=pe(g.keyRef(v)),C=pe(g.keyRef(f)),F=pe(g.keyRef(m));return Pa(c,{subcommand:"run-source-fetch",inRef:b,outRef:C,errRef:F},o),{dispatched:!0}}catch(l){let g=l instanceof Error?l.message:String(l);try{let v=rn(Ne(a,"archive")),f=new Date().toISOString().replace(/[:.]/g,"-"),m=d.source_def?.bindTo??"unknown";v.blob("exec-failures").write(`${f}-${m}.json`,JSON.stringify({error:g,args:d,ref:c,at:new Date().toISOString()},null,2));}catch{}return {dispatched:false,error:g}}},resolveBlob(c){let d=va(c.value)?us().read(c.value):Wt(a).read(c.value);if(d===null)throw new Error(`resolveBlob: blob not found: ::${c.kind}::${c.value}`);return d},hashFn:Fa,genId:()=>Sa(`${Date.now()}-${Math.random()}`).slice(0,32),kvStorageForRef:c=>nn(We(c).value),requestProcessAccumulated(){s?.suppressSpawn||Ra(o,e,s?.notifyChannel);},publishBoardChangeNotifications(c){if(!s?.notifyChannel||c.length===0)return;let d=c.map(l=>({id:Zn(),ts:new Date().toISOString(),boardRef:pe(e),notification:l}));_a(s.notifyChannel,d,s.onWarn);},onWarn:s?.onWarn}}function Rw(e,t,r){let{cliDir:n,opts:s}=Iy(t,r),o=ad(n),a=jy(e,o,s),i=Xr();return {...a,invokeExecutorSync(u,c,d,l){let{command:g,baseArgs:v}=Qr(u,o),f=u.extra?["--extra",Buffer.from(JSON.stringify(u.extra)).toString("base64")]:[];return i.executeSync(g,[...v,c,...d,...f],{timeout:l?.timeout??3e4,encoding:"utf-8",input:l?.input})},validateSchema(u){let c=Xo(u);return {ok:c.errors.length===0,errors:c.errors}},absoluteBlob:us()}}function _w(e,t={}){let r=t.chatsSubdir??"chats",n=t.kvSubdir??".kv",s=n?[n,"chat"]:["chat"],o=r&&!od(e,r)?Ne(e,r):e,a=nn(Ne(e,...s));return Qo(i=>{let c=`${String(i).replace(/[^a-zA-Z0-9_-]/g,"_")}.jsonl`,d=Ne(o,c);return ds(d)},a)}function Cw(e,t={}){let r=t.filesSubdir??"files",n=r&&!od(e,r)?Ne(e,r):e;return ca(Wt(n))}function $w(e){try{let t=JSON.parse(Buffer.from(e,"base64url").toString());return typeof t.br=="string"?t.br:null}catch{return null}}
19
- exports.BOARD_GRAPH_KEY=Et;exports.EMPTY_CONFIG=zn;exports.SNAPSHOT_SCHEMA_VERSION_V1=Ur;exports.buildLocalBaseSpec=Qr;exports.createArtifactsStore=ca;exports.createArtifactsStorePublic=yy;exports.createBoardLiveCardsMcp=hy;exports.createBoardLiveCardsNonCorePublic=fy;exports.createBoardLiveCardsPublic=ly;exports.createCardFileMetadataStore=$y;exports.createCardStore=Kn;exports.createCardStorePublic=oa;exports.createChatStorage=Qo;exports.createExecutionRefInvoker=Bd;exports.createFileArtifactsStore=Cy;exports.createFsBoardChatStorage=_w;exports.createFsBoardFileArtifactsStore=Cw;exports.createFsBoardNonCorePlatformAdapter=Rw;exports.createFsBoardPlatformAdapter=jy;exports.createInMemoryChatStorage=Ph;exports.createNodeSpawnInvocationAdapter=bw;exports.decodeBoardRefFromToken=$w;exports.evaluateArgsMassaging=ss;exports.executionRefFromScriptPath=sy;exports.invokeExecutionRef=Oa;exports.invokeExecutionRefSync=os;exports.invokeRefSync=Vd;exports.parseExecutionRef=na;exports.parseRef=We;exports.resolveWhatToRunValue=Xe;exports.resolveYamlFlowCliPath=xa;exports.serializeExecutionRef=ra;exports.serializeRef=pe;//# sourceMappingURL=board-live-cards-node.cjs.map
18
+ `,"utf-8");},generateId(){return crypto.randomUUID()}}}function Da(e){return {tryAcquire(){try{if(!$__namespace.existsSync(e)){$__namespace.mkdirSync(oe__namespace.dirname(e),{recursive:!0});try{$__namespace.writeFileSync(e,"{}",{flag:"wx"});}catch{}}return properLockfile.lockSync(e,{retries:0})}catch{return null}}}}var La={$schema:"http://json-schema.org/draft-07/schema#",$id:"https://nsreehari.github.io/boards/live-cards.schema.json",definitions:{bind_ref:{description:"A card data path reference, e.g. 'card_data.raw_quotes' or 'requires.upstream'",type:"string",pattern:"^(card_data|requires|fetched_sources|computed_values)(\\.|$)"},bind_or_literal:{description:"A literal value or a bind reference object",oneOf:[{type:"string"},{type:"number"},{type:"boolean"},{type:"array"},{type:"object",properties:{bind:{$ref:"#/definitions/bind_ref"}},required:["bind"]}]},compute_expr:{description:"A declarative JSON compute expression",type:"object",required:["fn"],properties:{fn:{type:"string",description:"Function name from the built-in vocabulary",enum:["sum","avg","min","max","count","first","last","add","sub","mul","div","round","abs","mod","gt","gte","lt","lte","eq","neq","if","and","or","not","concat","upper","lower","template","filter","pluck","map","sort","slice","flat","unique","group","get","default","now","diff_days","format_date"]},input:{description:"card_data.path, literal, array of inputs, or nested compute_expr",oneOf:[{type:"string"},{type:"number"},{type:"boolean"},{type:"array"},{$ref:"#/definitions/compute_expr"}]},field:{type:"string",description:"For pluck/sum/group \u2014 the object key to extract"},where:{$ref:"#/definitions/compute_expr",description:"For filter \u2014 predicate expression ($ = current item)"},cond:{$ref:"#/definitions/compute_expr",description:"For if \u2014 condition expression"},then:{description:"For if \u2014 value when cond is truthy"},else:{description:"For if \u2014 value when cond is falsy"},format:{type:"string",description:"For format_date \u2014 date format string"}}},meta:{type:"object",properties:{title:{type:"string"},tags:{type:"array",items:{type:"string"}}}},requires:{type:"array",items:{type:"string"},description:"IDs of upstream nodes this node depends on"},provides:{type:"array",items:{type:"object",required:["bindTo","ref"],properties:{bindTo:{type:"string",description:"Token name published downstream"},ref:{type:"string",description:"Path to read value from (card_data.*, requires.*, fetched_sources.*, computed_values.*)"}}},description:"Explicit bindings exposing computed or card_data values downstream as named tokens"},compute_step:{description:"A single ordered compute step: reads card_data.*/requires.*/computed_values.*, writes to computed_values[bindTo]",type:"object",required:["bindTo","expr"],properties:{bindTo:{type:"string",description:"Key in computed_values to write result"},expr:{type:"string",description:"JSONata expression evaluated against { card_data, requires, fetched_sources, computed_values }"}}},source_def:{description:"One source entry. The engine requires 'bindTo' (compute namespace key) and 'outputFile' (delivery signal path). bindTo and outputFile must be unique across all source_defs in a card. Every other property is yours \u2014 add whatever your task-executor needs: kind, url, headers, mailbox, channel, model, query, etc. The full object is passed verbatim as the --in JSON to the executor.",type:"object",required:["bindTo","outputFile"],additionalProperties:true,properties:{bindTo:{type:"string",description:"Key under fetched_sources.* available in compute expressions"},outputFile:{type:"string",description:"Board-relative path the executor writes its JSON result to. Presence of this file signals delivery."},projections:{type:"object",description:"Named data projections from card_data or requires, evaluated before the executor is called. Each key is a ref name; each value is a JSONata expression rooted at card_data or requires. The resolved values are passed to the executor as _projections. fetched_sources, computed_values, and source_defs are not accessible here \u2014 sources run before those exist.",additionalProperties:{type:"string"}},optionalForCompletionGating:{type:"boolean",default:false,description:"When true this source does not gate card completion. Default false when absent, so source_defs are completion-gating by default."},timeout:{type:"integer",minimum:0,default:12e4,description:"Executor/script timeout in ms. Default: 120 000 (2 min)."},script:{type:"string",description:"Legacy direct-run: shell command executed when no .task-executor is registered. stdout is captured as the result."}}},render_element:{type:"object",required:["kind"],properties:{id:{type:"string",description:"Optional element ID for targeted updates"},kind:{enum:["metric","table","editable-table","chart","form","filter","list","notes","todo","alert","narrative","badge","text","markdown","ref","custom","actions"]},label:{type:"string",description:"Heading above this element"},className:{type:"string",description:"Bootstrap grid class, e.g. 'col-12 col-md-6'"},visible:{type:"string",description:"card_data/requires/fetched_sources/computed_values path \u2014 element shown only if truthy"},data:{type:"object",properties:{bind:{$ref:"#/definitions/bind_ref",description:"card_data/requires/fetched_sources/computed_values path to read data from"},writeTo:{$ref:"#/definitions/bind_ref",description:"card_data path for user input (form, filter, todo, notes)"},columns:{type:"array",items:{type:"string"},description:"table: visible columns"},maxRows:{type:"integer",description:"table/list: max rows to display"},sortable:{type:"boolean",default:true,description:"table: enable click-to-sort"},placeholder:{type:"string",description:"Empty-state message"},chartType:{enum:["bar","line","pie","doughnut"]},chartOptions:{type:"object",description:"Chart.js options passthrough"},fields:{type:"object",description:"JSON Schema for form/filter fields"},thresholds:{type:"object",properties:{green:{type:"string"},amber:{type:"string"}}},colorMap:{type:"object",description:"badge: value \u2192 Bootstrap color"},style:{enum:["heading","muted","default"],description:"text: display style"},upload:{type:"boolean",default:true,description:"file-upload: show drop zone (false = read-only file list)"},accept:{type:"array",items:{type:"string"},description:"file-upload: allowed extensions"},multiple:{type:"boolean",default:true,description:"file-upload: allow multiple files"},fileAttach:{type:"boolean",default:false,description:"chat: enable inline file attachments"},fileAccept:{type:"array",items:{type:"string"},description:"chat: allowed attachment extensions"},buttons:{type:"array",description:"actions: button definitions",items:{type:"object",required:["id","label"],properties:{id:{type:"string"},label:{type:"string"},style:{type:"string",description:"Bootstrap button variant, e.g. 'success', 'outline-danger'"},size:{type:"string",default:"sm"},disabled:{oneOf:[{type:"boolean"},{type:"string",description:"card_data/requires/fetched_sources/computed_values path \u2014 truthy = disabled"}]}}}}}}}},view:{type:"object",required:["elements"],properties:{elements:{type:"array",minItems:1,items:{$ref:"#/definitions/render_element"}},layout:{type:"object",properties:{board:{type:"object",properties:{col:{type:"integer",minimum:1,maximum:12},order:{type:"integer"}}},canvas:{type:"object",properties:{x:{type:"number"},y:{type:"number"},w:{type:"number"},h:{type:"number"}}}}},features:{type:"object",properties:{chat:{type:"boolean",default:false},notes:{type:"boolean",default:false},refresh:{type:"boolean",default:true}}}}}},title:"LiveCard",description:"A unified card node. Behavior depends on which sections are present (source_defs, compute, view, etc.)",type:"object",required:["id"],additionalProperties:false,properties:{id:{type:"string"},requires:{$ref:"#/definitions/requires"},provides:{$ref:"#/definitions/provides"},meta:{$ref:"#/definitions/meta"},view:{$ref:"#/definitions/view"},card_data:{type:"object",description:"Authored card data and runtime metadata. Includes uploaded-file metadata maintained by host handlers and inference evaluation results.",properties:{files:{type:"array",description:"Optional uploaded-file metadata maintained by host handlers. Stored name is normalized and serial-prefixed (for example 001-my_file.pdf).",items:{type:"object",required:["name","stored_name"],properties:{name:{type:"string",minLength:1},stored_name:{type:"string",minLength:5,maxLength:32,pattern:"^[0-9]{3,}-[a-z0-9._-]+$"},size:{oneOf:[{type:"integer",minimum:0},{type:"null"}]},mime_type:{type:"string"},path:{type:"string",pattern:"^[^\\s]+/files/[0-9]{3,}-[a-z0-9._-]+$"},uploaded_at:{type:"string",format:"date-time"},chat:{type:"boolean",description:"Whether this file entry is associated with a chat interaction"}},additionalProperties:false}}},additionalProperties:true},source_defs:{type:"array",description:"Source entries. Each entry is passed verbatim to the board's .task-executor (registered via init --task-executor) as the --in JSON file. The executor fetches/generates the data and writes JSON to --out. If no executor is registered, the built-in executor runs the entry's 'cli' command directly. Sources gate completion by default. Set optionalForCompletionGating: true for enrichment-only source_defs that should not block task-completed.",items:{$ref:"#/definitions/source_def"}},compute:{type:"array",description:"Ordered array of compute steps. Each reads card_data.*/requires.*/fetched_sources.*/computed_values.* and writes to ephemeral computed_values[bindTo].",items:{$ref:"#/definitions/compute_step"}}}};var hu=hd(pu());var xh=module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('board-live-cards-node.cjs', document.baseURI).href))),Ah=xh("./jsonata-sync.cjs"),Dn=null;var mu=/\b(card_data|requires|fetched_sources|computed_values|source_defs)\b/g,Th=/^\s*(card_data|requires|fetched_sources|computed_values|source_defs)(\.|$)/;function Ih(e){let t=new Set,r;for(mu.lastIndex=0;(r=mu.exec(e))!==null;)t.add(r[1]);return t}function yu(e){let t=Th.exec(e);return t?t[1]:null}function gu(e,t,r,n){try{Ah(e);}catch(o){let a=o instanceof Error?o.message:String(o);n.push(`${t}: invalid JSONata expression (${a})`);return}let s=Ih(e);for(let o of s)r.has(o)||n.push(`${t}: disallowed namespace "${o}" in expression`);}function Yo(e,t,r){if(Array.isArray(e)){e.forEach((s,o)=>{Yo(s,`${t}/${o}`,r);});return}if(typeof e=="string"){let s=yu(e);if(!s)return;new Set(["card_data","requires","computed_values"]).has(s)||r.push(`${t}: disallowed namespace "${s}" in view reference`);return}if(!e||typeof e!="object")return;let n=e;for(let[s,o]of Object.entries(n))Yo(o,`${t}/${s}`,r);}function jh(){if(Dn)return Dn;let e=new hu.default({allErrors:true});return $h__default.default(e),Dn=e.compile(La),Dn}function vu(e){let t=jh(),r=t(e),n=(t.errors??[]).map(s=>`${s.instancePath||"/"}: ${s.message??"unknown error"}`);if(e&&typeof e=="object"&&!Array.isArray(e)){let s=e.source_defs;if(Array.isArray(s)){let o=new Set,a=new Set;s.forEach((i,u)=>{if(!i||typeof i!="object"||Array.isArray(i))return;let c=i;typeof c.bindTo=="string"&&c.bindTo&&(o.has(c.bindTo)&&n.push(`/source_defs/${u}/bindTo: bindTo "${c.bindTo}" must be unique across all source_defs`),o.add(c.bindTo)),typeof c.outputFile=="string"&&c.outputFile&&(a.has(c.outputFile)&&n.push(`/source_defs/${u}/outputFile: outputFile "${c.outputFile}" must be unique across all source_defs`),a.add(c.outputFile));});}}return !r||n.length>0?{ok:false,errors:n}:{ok:true,errors:[]}}function Su(e){let t=[];if(!e||typeof e!="object"||Array.isArray(e))return {ok:true,errors:[]};let r=e,n=r.compute;Array.isArray(n)&&n.forEach((c,d)=>{if(!c||typeof c!="object"||Array.isArray(c))return;let l=c.expr;typeof l!="string"||l.trim().length===0||gu(l,`/compute/${d}/expr`,new Set(["card_data","requires","fetched_sources","computed_values"]),t);});let s=new Set(["card_data","requires","fetched_sources","computed_values"]),o=r.provides;Array.isArray(o)&&o.forEach((c,d)=>{if(!c||typeof c!="object"||Array.isArray(c))return;let l=c.ref;if(typeof l!="string"||l.trim().length===0)return;let g=yu(l);g===null?t.push(`/provides/${d}/ref: path "${l}" must start with a valid namespace (${[...s].join(", ")})`):s.has(g)||t.push(`/provides/${d}/ref: disallowed namespace "${g}" in path "${l}" (valid: ${[...s].join(", ")})`);});let a=r.view;a&&typeof a=="object"&&!Array.isArray(a)&&Yo(a,"/view",t);let i=new Set(["card_data","requires"]),u=r.source_defs;return Array.isArray(u)&&u.forEach((c,d)=>{if(!c||typeof c!="object"||Array.isArray(c))return;let l=c.projections;if(!(!l||typeof l!="object"||Array.isArray(l)))for(let[g,v]of Object.entries(l))typeof v!="string"||v.trim().length===0||gu(v,`/source_defs/${d}/projections/${g}`,i,t);}),{ok:t.length===0,errors:t}}function Xo(e){let t=vu(e);if(!t.ok)return t;let r=Su(e);return r.ok?{ok:true,errors:[]}:{ok:false,errors:r.errors}}function wu(e){return String(e).replace(/[^a-zA-Z0-9_-]/g,"_")}function ku(e){let t=e.payload??{};return {id:e.id,role:typeof t.role=="string"?t.role:"system",text:typeof t.text=="string"?t.text:"",files:Array.isArray(t.files)?t.files:[],turn:typeof t.turn=="string"?t.turn:"",updated_at:typeof t.updated_at=="string"?t.updated_at:""}}function Qo(e,t){let r=s=>`chats/${wu(s)}/processing`,n=s=>`chats/${wu(s)}/config`;return {append(s,o,a,i=[],u=""){return e(s).append({role:o,text:a,files:i,turn:u,updated_at:new Date().toISOString()}).id},readAll(s){return e(s).readAll().map(ku)},readAfter(s,o){let a=e(s).readAfter(o);return {records:a.entries.map(ku),cursor:a.newCursor}},clear(s){e(s).clear?.();},setProcessing(s,o){o?t.write(r(s),true):t.delete(r(s));},isProcessing(s){return t.read(r(s))===true},getConfig(s){return t.read(n(s))??{}},setConfig(s,o){let a=t.read(n(s))??{};t.write(n(s),{...a,...o});}}}function Oh(){let e=globalThis.crypto;return typeof e?.randomUUID=="function"?String(e.randomUUID()):`id-${Date.now()}-${Math.random().toString(36).slice(2)}`}function Ph(){let e=new Map,t=new Map;function r(n){return e.has(n)||e.set(n,[]),e.get(n)}return {append(n,s,o,a=[],i=""){let u={id:Oh(),role:s,text:o,files:a,turn:i,updated_at:new Date().toISOString()};return r(n).push(u),u.id},readAll(n){return r(n).slice()},readAfter(n,s){let o=r(n);if(!s)return {records:o.slice(),cursor:o.length>0?o[o.length-1].id:null};let a=o.findIndex(u=>u.id===s),i=a===-1?o.slice():o.slice(a+1);return {records:i,cursor:i.length>0?i[i.length-1].id:s}},clear(n){e.set(n,[]);},setProcessing(n,s){s?t.set(`p:${n}`,true):t.delete(`p:${n}`);},isProcessing(n){return t.get(`p:${n}`)===true},getConfig(n){return t.get(`c:${n}`)??{}},setConfig(n,s){let o=t.get(`c:${n}`)??{};t.set(`c:${n}`,{...o,...s});}}}var $t={RUNNING:"running",COMPLETED:"completed",FAILED:"failed",INACTIVATED:"inactivated"};function Ue(e){return e?Array.isArray(e.provides)?e.provides:[]:[]}function Et(e){return e?Array.isArray(e.requires)?e.requires:[]:[]}function bu(e){return e.tasks??{}}function Zo(e){return e?e.status===$t.FAILED||e.status===$t.INACTIVATED:false}function Ru(e,t){return e.refreshStrategy??t?.refreshStrategy??"data-changed"}function _u(e){return e.maxExecutions}function Cu(e,t){let r=new Set;for(let[n,s]of Object.entries(t))if(s.status===$t.COMPLETED){let o=e.tasks[n];o&&Ue(o).forEach(i=>r.add(i));}return Array.from(r)}function $u(e,t){let r={};return e.forEach(n=>{let s=t[n];if(!s)return;Ue(s).forEach(a=>{r[a]||(r[a]=[]),r[a].push(n);});}),r}function Eu(e,t,r){let n=e.tasks[t]??Ln(),s={};if(r){let a=r.tasks[t],i=Et(a);for(let u of i)for(let[c,d]of Object.entries(r.tasks))if(Ue(d).includes(u)){let l=e.tasks[c];l?.lastDataHash&&(s[u]=l.lastDataHash);break}}let o={...n,status:"running",startedAt:new Date().toISOString(),lastUpdated:new Date().toISOString(),progress:0,error:void 0,startConsumedHashes:s};return {...e,tasks:{...e.tasks,[t]:o},lastUpdated:new Date().toISOString()}}function xu(e,t,r,n,s,o){let a=e.tasks[r]??Ln(),i=t.tasks[r];if(!i)throw new Error(`Task "${r}" not found in graph`);let u;n&&i.on&&i.on[n]?u=i.on[n]:u=Ue(i);let c=a.startConsumedHashes?{...a.startConsumedHashes}:{...a.lastConsumedHashes};if(!a.startConsumedHashes){let g=i.requires??[];for(let v of g)for(let[f,m]of Object.entries(t.tasks))if(Ue(m).includes(v)){let b=e.tasks[f];b?.lastDataHash&&(c[v]=b.lastDataHash);break}}let d={...a,status:"completed",completedAt:new Date().toISOString(),lastUpdated:new Date().toISOString(),executionCount:a.executionCount+1,lastEpoch:a.executionCount+1,lastDataHash:s,data:o,lastConsumedHashes:c,error:void 0},l=[...new Set([...e.availableOutputs,...u])];return {...e,tasks:{...e.tasks,[r]:d},availableOutputs:l,lastUpdated:new Date().toISOString()}}function Au(e,t,r,n){let s=e.tasks[r]??Ln(),o=t.tasks[r];if(o?.retry){let u=s.retryCount+1;if(u<=o.retry.max_attempts){let c={...s,status:"not-started",retryCount:u,lastUpdated:new Date().toISOString(),error:n};return {...e,tasks:{...e.tasks,[r]:c},lastUpdated:new Date().toISOString()}}}let a={...s,status:"failed",failedAt:new Date().toISOString(),lastUpdated:new Date().toISOString(),error:n,executionCount:s.executionCount+1},i=e.availableOutputs;if(o?.on_failure&&o.on_failure.length>0&&(i=[...new Set([...e.availableOutputs,...o.on_failure])]),o?.circuit_breaker&&a.executionCount>=o.circuit_breaker.max_executions){let u=o.circuit_breaker.on_break;i=[...new Set([...i,...u])];}return {...e,tasks:{...e.tasks,[r]:a},availableOutputs:i,lastUpdated:new Date().toISOString()}}function Tu(e,t,r,n){let s=e.tasks[t]??Ln(),o={...s,progress:typeof n=="number"?n:s.progress,messages:[...s.messages??[],...r?[{message:r,timestamp:new Date().toISOString(),status:s.status}]:[]],lastUpdated:new Date().toISOString()};return {...e,tasks:{...e.tasks,[t]:o},lastUpdated:new Date().toISOString()}}function Iu(e,t){let r=e.tasks[t];if(!r)return e;let n={...r,status:"not-started",startedAt:void 0,completedAt:void 0,failedAt:void 0,error:void 0,data:void 0,progress:null,lastUpdated:new Date().toISOString()};return {...e,tasks:{...e.tasks,[t]:n},lastUpdated:new Date().toISOString()}}function Ln(){return {status:"not-started",executionCount:0,retryCount:0,lastEpoch:0,messages:[],progress:null}}function Bn(e,t){let r=`live-${Date.now()}`,n={};for(let o of Object.keys(e.tasks))n[o]=Ou();let s={status:"running",tasks:n,availableOutputs:[],stuckDetection:{is_stuck:false,stuck_description:null,outputs_unresolvable:[],tasks_blocked:[]},lastUpdated:new Date().toISOString(),executionId:r,executionConfig:{executionMode:e.settings.execution_mode??"eligibility-mode",conflictStrategy:e.settings.conflict_strategy??"alphabetical",completionStrategy:e.settings.completion}};return {config:e,state:s}}function Nh(e,t){let{config:r,state:n}=e;if("executionId"in t&&t.executionId&&t.executionId!==n.executionId)return e;switch(t.type){case "task-started":return {config:r,state:Eu(n,t.taskName,r)};case "task-completed":return {config:r,state:xu(n,r,t.taskName,t.result,t.dataHash,t.data)};case "task-failed":return {config:r,state:Au(n,r,t.taskName,t.error)};case "task-progress":return {config:r,state:Tu(n,t.taskName,t.message,t.progress)};case "task-restart":return {config:r,state:Iu(n,t.taskName)};case "inject-tokens":return {config:r,state:{...n,availableOutputs:[...new Set([...n.availableOutputs,...t.tokens])],lastUpdated:new Date().toISOString()}};case "agent-action":return {config:r,state:Vh(n,t.action)};case "task-upsert":return qh(e,t.taskName,t.taskConfig);case "task-removal":return Fh(e,t.taskName);case "node-requires-add":return Mh(e,t.nodeName,t.tokens);case "node-requires-remove":return Dh(e,t.nodeName,t.tokens);case "node-provides-add":return Lh(e,t.nodeName,t.tokens);case "node-provides-remove":return Bh(e,t.nodeName,t.tokens);default:return e}}function ju(e,t){return t.reduce((r,n)=>Nh(r,n),e)}function qh(e,t,r){let n=!!e.config.tasks[t];return {config:{...e.config,tasks:{...e.config.tasks,[t]:r}},state:{...e.state,tasks:{...e.state.tasks,[t]:n?e.state.tasks[t]:Ou()},lastUpdated:new Date().toISOString()}}}function Fh(e,t){if(!e.config.tasks[t])return e;let{[t]:r,...n}=e.config.tasks,{[t]:s,...o}=e.state.tasks;return {config:{...e.config,tasks:n},state:{...e.state,tasks:o,lastUpdated:new Date().toISOString()}}}function Mh(e,t,r){let n=e.config.tasks[t];if(!n)return e;let s=Et(n),o=r.filter(a=>!s.includes(a));return o.length===0?e:{config:{...e.config,tasks:{...e.config.tasks,[t]:{...n,requires:[...s,...o]}}},state:e.state}}function Dh(e,t,r){let n=e.config.tasks[t];if(!n)return e;let s=Et(n),o=s.filter(a=>!r.includes(a));return o.length===s.length?e:{config:{...e.config,tasks:{...e.config.tasks,[t]:{...n,requires:o}}},state:e.state}}function Lh(e,t,r){let n=e.config.tasks[t];if(!n)return e;let s=Ue(n),o=r.filter(a=>!s.includes(a));return o.length===0?e:{config:{...e.config,tasks:{...e.config.tasks,[t]:{...n,provides:[...s,...o]}}},state:e.state}}function Bh(e,t,r){let n=e.config.tasks[t];if(!n)return e;let s=Ue(n),o=s.filter(a=>!r.includes(a));return o.length===s.length?e:{config:{...e.config,tasks:{...e.config.tasks,[t]:{...n,provides:o}}},state:e.state}}function Lr(e){return {version:1,config:e.config,state:e.state,snapshotAt:new Date().toISOString()}}function Vn(e){if(!e||typeof e!="object")throw new Error("Invalid snapshot: expected an object");let t=e;if(!t.config||typeof t.config!="object")throw new Error('Invalid snapshot: missing or invalid "config"');if(!t.state||typeof t.state!="object")throw new Error('Invalid snapshot: missing or invalid "state"');let r=t.config,n=t.state;if(!r.settings||typeof r.settings!="object")throw new Error("Invalid snapshot: config.settings missing");if(!r.tasks||typeof r.tasks!="object")throw new Error("Invalid snapshot: config.tasks missing");if(!n.tasks||typeof n.tasks!="object")throw new Error("Invalid snapshot: state.tasks missing");if(!Array.isArray(n.availableOutputs))throw new Error("Invalid snapshot: state.availableOutputs must be an array");return {config:r,state:n}}function Ou(){return {status:"not-started",executionCount:0,retryCount:0,lastEpoch:0,messages:[],progress:null}}function Vh(e,t){let r=new Date().toISOString();switch(t){case "stop":return {...e,status:"stopped",lastUpdated:r};case "pause":return {...e,status:"paused",lastUpdated:r};case "resume":return {...e,status:"running",lastUpdated:r};default:return e}}function Br(e){let{config:t,state:r}=e,n=bu(t);if(Object.keys(n).length===0)return {eligible:[],pending:[],unresolved:[],blocked:[],conflicts:{}};let o=Uh(n),a=Cu(t,r.tasks),i=new Set([...a,...r.availableOutputs]),u=[],c=[],d=[],l=[];for(let[v,f]of Object.entries(n)){let m=r.tasks[v],b=Ru(f,t.settings),C=b!=="once";if(m?.status===$t.RUNNING||Zo(m))continue;let q=_u(f);if(q!==void 0&&m&&m.executionCount>=q||f.circuit_breaker&&m&&m.executionCount>=f.circuit_breaker.max_executions||!C&&m?.status===$t.COMPLETED)continue;if(C&&m?.status===$t.COMPLETED){let w=Et(f),p=false;switch(b){case "data-changed":{w.length>0&&w.some(R=>{for(let[E,A]of Object.entries(n))if(Ue(A).includes(R)){let T=r.tasks[E];if(!T)continue;let V=m.lastConsumedHashes?.[R];return T.lastDataHash==null?T.executionCount>m.lastEpoch:T.lastDataHash!==V}return false})||(p=true);break}case "epoch-changed":{w.length>0&&w.some(R=>{for(let[E,A]of Object.entries(n))if(Ue(A).includes(R)){let T=r.tasks[E];if(T&&T.executionCount>m.lastEpoch)return true}return false})||(p=true);break}case "time-based":{let h=f.refreshInterval??0;if(h<=0){p=true;break}let R=m.completedAt;if(!R){p=true;break}(Date.now()-Date.parse(R))/1e3<h&&(p=true);break}case "manual":p=true;break}if(p)continue}let _=Et(f);if(_.length===0){u.push(v);continue}let I=[],S=[],k=[];for(let w of _){if(i.has(w))continue;let p=o[w]||[];p.length===0?I.push(w):p.every(R=>Zo(r.tasks[R]))?k.push({token:w,failedProducer:p[0]}):S.push(w);}I.length>0?d.push({taskName:v,missingTokens:I}):k.length>0?l.push({taskName:v,failedTokens:k.map(w=>w.token),failedProducers:[...new Set(k.map(w=>w.failedProducer))]}):S.length>0?c.push({taskName:v,waitingOn:S}):u.push(v);}let g={};if(u.length>1){let v=$u(u,n);for(let[f,m]of Object.entries(v))m.length>1&&(g[f]=m);}return {eligible:u,pending:c,unresolved:d,blocked:l,conflicts:g}}function Uh(e){let t={};for(let[r,n]of Object.entries(e)){for(let s of Ue(n))t[s]||(t[s]=[]),t[s].push(r);if(n.on)for(let s of Object.values(n.on))for(let o of s)t[o]||(t[o]=[]),t[o].includes(r)||t[o].push(r);if(n.on_failure)for(let s of n.on_failure)t[s]||(t[s]=[]),t[s].includes(r)||t[s].push(r);}return t}var Vr=class{buffer=[];append(t){this.buffer.push(t);}drain(){let t=this.buffer;return this.buffer=[],t}get size(){return this.buffer.length}};function ea(e){let t=ta(e);return Kh(t)}function ta(e){if(e==null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return "["+e.map(ta).join(",")+"]";let t=e;return "{"+Object.keys(t).sort().map(n=>JSON.stringify(n)+":"+ta(t[n])).join(",")+"}"}function Kh(e){let t=0xcbf29ce484222325n,r=0x100000001b3n,n=0xffffffffffffffffn;for(let s=0;s<e.length;s++)t^=BigInt(e.charCodeAt(s)),t=t*r&n;return t.toString(16).padStart(16,"0")}function Gh(e){if(typeof Buffer<"u")return Buffer.from(e,"utf8").toString("base64url");if(typeof btoa=="function"){let t=new TextEncoder().encode(e),r="";for(let n of t)r+=String.fromCharCode(n);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}throw new Error("No base64 encoder available in this runtime")}function Jh(e){if(typeof Buffer<"u")return Buffer.from(e,"base64url").toString("utf8");if(typeof atob=="function"){let t=e.replace(/-/g,"+").replace(/_/g,"/"),r=t+"=".repeat((4-t.length%4)%4),n=atob(r),s=new Uint8Array(n.length);for(let o=0;o<n.length;o++)s[o]=n.charCodeAt(o);return new TextDecoder().decode(s)}throw new Error("No base64 decoder available in this runtime")}function Pu(e){let t=JSON.stringify({t:e,n:Date.now().toString(36)+Math.random().toString(36).slice(2,6)});return Gh(t)}function zh(e){try{let t=JSON.parse(Jh(e));return typeof t?.t=="string"?{taskName:t.t}:null}catch{return null}}function Nu(e,t,r){let{handlers:n,onNodeRemoved:s,onDrain:o}=t,a=new Vr,i="state"in e&&"config"in e?e:Bn(e),u=false,c=new Set,d=new Map(Object.entries(n)),l=new Vr,g=false,v=false;function f(){if(!u){if(g){v=true;return}g=true;try{do v=!1,m();while(v)}finally{g=false;}}}function m(){let _=l.drain(),I=a.drain(),S=[..._,...I];if(S.length>0&&(i=ju(i,S),s)){for(let w of S)if(w.type==="task-removal")try{s(w.taskName);}catch(p){console.warn("[reactive] onNodeRemoved failed:",p instanceof Error?p.message:String(p));}}let k=Br(i);S.length>0&&o?.(S,i,k);for(let w of k.eligible)q(w);for(let w of S)if(w.type==="task-progress"){let{taskName:p,update:h}=w;if(!i.config.tasks[p])continue;let E=i.state.tasks[p];if(!E||E.status!=="running")continue;let A=Pu(p),T=C(p,A,h).catch(V=>{u||(l.append({type:"task-failed",taskName:p,error:V.message??String(V),timestamp:new Date().toISOString()}),f());}).finally(()=>{c.delete(T);});c.add(T);}}function b(_){let S=i.config.tasks[_].requires??[],k=new Map;for(let[p,h]of Object.entries(i.config.tasks))for(let R of h.provides??[])k.set(R,p);let w={};for(let p of S){let h=k.get(p);h?w[p]=i.state.tasks[h]?.data:w[p]=void 0;}return w}async function C(_,I,S){let k=i.config.tasks[_],w=k.taskHandlers??[],p=b(_);for(let h of w){let R=d.get(h);if(!R)throw new Error(`Handler '${h}' not found in registry (task '${_}')`);let E={nodeId:_,state:p,taskState:i.state.tasks[_],config:k,callbackToken:I,update:S};if(await R(E)==="task-initiate-failure")throw new Error(`Handler '${h}' returned task-initiate-failure (task '${_}')`)}}function q(_){let S=i.config.tasks[_]?.taskHandlers;if(!S||S.length===0)return;l.append({type:"task-started",taskName:_,timestamp:new Date().toISOString()}),f();let k=Pu(_),w=C(_,k).catch(p=>{u||(l.append({type:"task-failed",taskName:_,error:p.message??String(p),timestamp:new Date().toISOString()}),f());}).finally(()=>{c.delete(w);});c.add(w);}return {push(_){u||(_.type==="task-completed"&&_.data&&!_.dataHash&&(_={..._,dataHash:ea(_.data)}),a.append(_),f());},pushAll(_){if(!u){for(let I of _)I.type==="task-completed"&&I.data&&!I.dataHash?a.append({...I,dataHash:ea(I.data)}):a.append(I);f();}},resolveCallback(_,I,S){if(u)return;let k=zh(_);if(!k)return;let{taskName:w}=k;if(i.config.tasks[w]){if(S&&S.length>0)a.append({type:"task-failed",taskName:w,error:S.join("; "),timestamp:new Date().toISOString()});else {let p=I&&Object.keys(I).length>0?ea(I):void 0;a.append({type:"task-completed",taskName:w,data:I,dataHash:p,timestamp:new Date().toISOString()});}f();}},addNode(_,I){u||(a.append({type:"task-upsert",taskName:_,taskConfig:I,timestamp:new Date().toISOString()}),f());},removeNode(_){u||(a.append({type:"task-removal",taskName:_,timestamp:new Date().toISOString()}),f());},addRequires(_,I){u||(a.append({type:"node-requires-add",nodeName:_,tokens:I,timestamp:new Date().toISOString()}),f());},removeRequires(_,I){u||(a.append({type:"node-requires-remove",nodeName:_,tokens:I,timestamp:new Date().toISOString()}),f());},addProvides(_,I){u||(a.append({type:"node-provides-add",nodeName:_,tokens:I,timestamp:new Date().toISOString()}),f());},removeProvides(_,I){u||(a.append({type:"node-provides-remove",nodeName:_,tokens:I,timestamp:new Date().toISOString()}),f());},registerHandler(_,I){d.set(_,I);},unregisterHandler(_){d.delete(_);},retrigger(_){u||i.config.tasks[_]&&(a.append({type:"task-restart",taskName:_,timestamp:new Date().toISOString()}),f());},retriggerAll(_){if(!u){for(let I of _)i.config.tasks[I]&&a.append({type:"task-restart",taskName:I,timestamp:new Date().toISOString()});f();}},snapshot(){return Lr(i)},getState(){return i},getSchedule(){return Br(i)},async waitForHandlers(){c.size>0&&await Promise.allSettled([...c]);},async dispose(_){_?.wait&&c.size>0&&await Promise.allSettled([...c]),u=true;}}}var Wh=module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('board-live-cards-node.cjs', document.baseURI).href))),Un=Wh("./jsonata-sync.cjs"),Mu=Un;function qu(e,t){if(!t||!e)return;let r=t.split("."),n=e;for(let s=0;s<r.length;s++){if(n==null)return;n=n[r[s]];}return n}function Du(e,t,r){let n=t.split("."),s=e;for(let o=0;o<n.length-1;o++)(s[n[o]]==null||typeof s[n[o]]!="object")&&(s[n[o]]={}),s=s[n[o]];s[n[n.length-1]]=r;}async function Yh(e,t){if(!e?.compute?.length)return e;e.card_data||(e.card_data={}),e.computed_values={},e._sourcesData=t?.sourcesData??{};let r=e.requires??{},n={card_data:e.card_data,requires:r,expects_data:r,fetched_sources:e._sourcesData,data:e.computed_values,computed_values:e.computed_values};for(let s of e.compute)try{let o=await Un(s.expr).evaluate(n);Du(e.computed_values,s.bindTo,o),n.computed_values=e.computed_values;}catch{}return e}function Xh(e,t){if(!e?.compute?.length)return {ok:true,node:e};e.card_data||(e.card_data={}),e.computed_values={},e._sourcesData=t?.sourcesData??{};let r=e.requires??{},n={card_data:e.card_data,requires:r,expects_data:r,fetched_sources:e._sourcesData,data:e.computed_values,computed_values:e.computed_values},s=[];for(let o of e.compute)try{let a=Mu(o.expr).evaluate(n);Du(e.computed_values,o.bindTo,a),n.computed_values=e.computed_values;}catch(a){let i=a instanceof Error?a.message:String(a);s.push({bindTo:o.bindTo,error:i});}return s.length>0?{ok:true,node:e,errors:s}:{ok:true,node:e}}async function Qh(e,t,r){let n={...r??{},card_data:t.card_data??{},requires:t.requires??{},fetched_sources:t._sourcesData??{},computed_values:t.computed_values??{}};return Un(e).evaluate(n)}function Zh(e,t){return t.startsWith("fetched_sources.")?qu(e._sourcesData??{},t.slice(16)):qu(e,t)}var Fu=new Set(["metric","table","editable-table","chart","form","filter","list","notes","todo","alert","narrative","badge","text","markdown","ref","custom","actions"]),ey=new Set(["id","meta","requires","provides","view","card_data","compute","source_defs"]);function ty(e){let t=[];if(!e||typeof e!="object"||Array.isArray(e))return {ok:false,errors:["Node must be a non-null object"]};let r=e;(typeof r.id!="string"||!r.id)&&t.push("id: required, must be a non-empty string");for(let n of Object.keys(r))ey.has(n)||t.push(`Unknown top-level key: "${n}"`);if((r.card_data==null||typeof r.card_data!="object"||Array.isArray(r.card_data))&&t.push("card_data: required, must be an object"),r.meta!=null)if(typeof r.meta!="object"||Array.isArray(r.meta))t.push("meta: must be an object");else {let n=r.meta;n.title!=null&&typeof n.title!="string"&&t.push("meta.title: must be a string"),n.tags!=null&&!Array.isArray(n.tags)&&t.push("meta.tags: must be an array");}if(r.requires!=null&&!Array.isArray(r.requires)&&t.push("requires: must be an array of strings"),r.provides!=null&&(Array.isArray(r.provides)?r.provides.forEach((n,s)=>{if(!n||typeof n!="object"||Array.isArray(n))t.push(`provides[${s}]: must be an object with bindTo and ref`);else {let o=n;(typeof o.bindTo!="string"||!o.bindTo)&&t.push(`provides[${s}]: missing required "bindTo" string`),(typeof o.ref!="string"||!o.ref)&&t.push(`provides[${s}]: missing required "ref" string`);}}):t.push("provides: must be an array of { bindTo, ref } bindings")),r.compute!=null&&(Array.isArray(r.compute)?r.compute.forEach((n,s)=>{if(!n||typeof n!="object"||Array.isArray(n))t.push(`compute[${s}]: must be a compute step object`);else {let o=n;(typeof o.bindTo!="string"||!o.bindTo)&&t.push(`compute[${s}]: missing required "bindTo" property`),(typeof o.expr!="string"||!o.expr)&&t.push(`compute[${s}]: missing required "expr" string (JSONata expression)`);}}):t.push("compute: must be an array of compute steps")),r.source_defs!=null)if(!Array.isArray(r.source_defs))t.push("source_defs: must be an array");else {let n=new Set,s=new Set;r.source_defs.forEach((o,a)=>{if(!o||typeof o!="object"||Array.isArray(o))t.push(`source_defs[${a}]: must be an object`);else {let i=o;typeof i.bindTo!="string"||!i.bindTo?t.push(`source_defs[${a}]: missing required "bindTo" property`):(n.has(i.bindTo)&&t.push(`source_defs[${a}]: bindTo "${i.bindTo}" is not unique across source_defs`),n.add(i.bindTo)),typeof i.outputFile!="string"||!i.outputFile?t.push(`source_defs[${a}]: missing required "outputFile" property`):(s.has(i.outputFile)&&t.push(`source_defs[${a}]: outputFile "${i.outputFile}" is not unique across source_defs`),s.add(i.outputFile)),i.optionalForCompletionGating!=null&&typeof i.optionalForCompletionGating!="boolean"&&t.push(`source_defs[${a}]: optionalForCompletionGating must be a boolean`);}});}if(r.view!=null)if(typeof r.view!="object"||Array.isArray(r.view))t.push("view: must be an object");else {let n=r.view;!Array.isArray(n.elements)||n.elements.length===0?t.push("view.elements: required, must be a non-empty array"):n.elements.forEach((s,o)=>{if(!s||typeof s!="object"){t.push(`view.elements[${o}]: must be an object`);return}!s.kind||typeof s.kind!="string"?t.push(`view.elements[${o}].kind: required, must be a string`):Fu.has(s.kind)||t.push(`view.elements[${o}].kind: unknown kind "${s.kind}". Valid: ${[...Fu].join(", ")}`),s.data!=null&&(typeof s.data!="object"||Array.isArray(s.data))&&t.push(`view.elements[${o}].data: must be an object`);}),n.layout!=null&&(typeof n.layout!="object"||Array.isArray(n.layout))&&t.push("view.layout: must be an object"),n.features!=null&&(typeof n.features!="object"||Array.isArray(n.features))&&t.push("view.features: must be an object");}return {ok:t.length===0,errors:t}}async function ry(e,t){if(!e||e.length===0)return [];let r={card_data:t.card_data??{},requires:t.requires??{}};return Promise.all(e.map(async n=>{let s={};if(n.projections&&typeof n.projections=="object"&&!Array.isArray(n.projections)){for(let[o,a]of Object.entries(n.projections))if(typeof a=="string"&&a.trim().length>0)try{s[o]=await Un(a).evaluate(r);}catch{s[o]=void 0;}}return {...n,_projections:s}}))}function ny(e,t){if(!e||e.length===0)return [];let r={card_data:t.card_data??{},requires:t.requires??{}};return e.map(n=>{let s={};if(n.projections&&typeof n.projections=="object"&&!Array.isArray(n.projections)){for(let[o,a]of Object.entries(n.projections))if(typeof a=="string"&&a.trim().length>0)try{s[o]=Mu(a).evaluate(r);}catch{s[o]=void 0;}}return {...n,_projections:s}})}var ut={run:Yh,runSync:Xh,eval:Qh,resolve:Zh,validate:ty,enrichSources:ry,enrichSourcesSync:ny};function sy(e,t){let r;return /\.m?js$/i.test(e)?r="local-node":/\.py$/i.test(e)?r="local-python":r="local-process",{meta:"task-executor",howToRun:r,whatToRun:pe({kind:"fs-path",value:e}),...t?{extra:t}:{}}}function ra(e){return JSON.stringify(e)}function na(e){let t;try{t=JSON.parse(e);}catch{throw new Error(`parseExecutionRef: invalid JSON \u2014 ${e}`)}if(typeof t!="object"||t===null||typeof t.howToRun!="string"||typeof t.whatToRun!="string")throw new Error(`parseExecutionRef: missing required fields howToRun/whatToRun \u2014 ${e}`);return t}function Kn(e,t){function r(){return e.readIndex()??{}}function n(s,o,a){let i=String(o||"").split(".").filter(Boolean);if(i.length===0)return a&&typeof a=="object"&&!Array.isArray(a)?a:{value:a};let u={...s},c=u;for(let d=0;d<i.length-1;d++){let l=i[d],g=c[l],v=g&&typeof g=="object"&&!Array.isArray(g)?{...g}:{};c[l]=v,c=v;}return c[i[i.length-1]]=a,u}return {readCard(s){let o=r()[s];return !o||!e.cardExists(o.key)?null:e.readCard(o.key)},readCardKey(s){return r()[s]?.key??null},readAllCards(){let s=[];for(let[o,a]of Object.entries(r())){if(!e.cardExists(a.key))continue;let i=e.readCard(a.key);i?s.push(i):t?.(`[card-store] could not read card "${o}" at key "${a.key}"`);}return s},readChecksumIndex(){let s={};for(let[o,a]of Object.entries(r()))s[o]=a.checksum;return s},changedSince(s){let o=r(),a=[];for(let[i,u]of Object.entries(o))s[i]!==u.checksum&&a.push(i);for(let i of Object.keys(s))o[i]||a.push(i);return a},validateUpsert(s,o){let a=r(),i=a[s],u=Object.entries(a).find(([,c])=>c.key===o);return i&&i.key!==o?{ok:false,error:`Card id "${s}" is already mapped to key "${i.key}", cannot remap to "${o}"`}:u&&u[0]!==s?{ok:false,error:`Key "${o}" is already mapped to card id "${u[0]}", cannot remap to "${s}"`}:{ok:true}},writeCard(s,o,a){let i=r(),u=a??i[s]?.key??e.defaultCardKey(s),c=e.writeCard(u,o);i[s]={key:u,checksum:c,updatedAt:new Date().toISOString()},e.writeIndex(i);},patchCard(s,o,a){let i=r(),u=i[s];if(!u||!e.cardExists(u.key))throw new Error(`card "${s}" not found`);let c=e.readCard(u.key);if(!c||typeof c!="object"||Array.isArray(c))throw new Error(`card "${s}" is not patchable`);let d=n(c,o,a),l=e.writeCard(u.key,d);i[s]={key:u.key,checksum:l,updatedAt:new Date().toISOString()},e.writeIndex(i);},removeCard(s){let o=r(),a=o[s];a&&(e.removeCard(a.key),delete o[s],e.writeIndex(o));},readIndex(){return r()}}}function Gn(e,t){return {readSourceData(r,n){let s=e.read(`${r}/${n}`);if(s==null)return null;let o=s.trim();if(!o)return null;try{return JSON.parse(o)}catch{return o}},ingestSourceDataStaged(r,n,s,o){let a=t(s);e.write(`${r}/.staged/${o}/${n}`,a);},commitSourceData(r,n,s){let o=`${r}/.staged/${s}/${n}`,a=e.read(o);return a==null?false:(e.write(`${r}/${n}`,a),e.remove(o),true)},hasSource(r,n){return e.exists(`${r}/${n}`)},listSources(r){return e.listKeys(`${r}/`).filter(n=>!n.includes("/.staged/")).map(n=>n.slice(`${r}/`.length))}}}function Ku(e){function t(r){let n=e.readAllEntries();if(!r)return n;let s=n.findIndex(o=>o.id===r);return s===-1?n:n.slice(s+1)}return {readEntriesAfterCursor(r){let n=t(r);return n.length===0?{events:[],newCursor:r}:{events:n.map(s=>s.event),newCursor:n[n.length-1].id}},pendingCount(r){return t(r).length},appendEvent(r){e.appendEntry({id:e.generateId(),event:r});}}}function Gu(e,t){return {appendEntries(r,n){if(!r||n.length===0)return;let s=e.read(r)??[];e.write(r,[...s,...n]);},dispatchEntriesForJournalId(r,n){if(!r)return;let s=e.read(r);if(!(!s||s.length===0)){for(let o of s)try{n(o);}catch(a){let i=a instanceof Error?a.message:String(a);try{t(o,i);}catch{}}e.delete(r);}}}}var Ur="v1",xt="board/graph",Ju="board/lastJournalProcessedId";function Lu(e){return `cards/${e}/runtime`}function zu(e){return {readRuntime(t){return e.read(Lu(t))??{_sources:{}}},writeRuntime(t,r){e.write(Lu(t),r);}}}function oy(e,t){let r={...e};for(let n of t.deleteKeys)delete r[n];return {...r,...t.shallowMerge}}function Hu(e){return {readSnapshot(t){return e.readValues(t)},commitSnapshot(t,r){if(r.schemaVersion!==Ur)throw new Error(`Unsupported snapshot schema version: ${r.schemaVersion}`);let n=e.readValues(t);if(n.version!==r.expectedVersion)return {ok:false,reason:"version-mismatch",currentVersion:n.version};let s=oy(n.values,r);return {ok:true,newVersion:e.writeValues(t,s,r.deleteKeys)}}}}function sa(e){function t(r){let n=e.read(r);return n==null?null:typeof n=="string"?n:JSON.stringify(n)}return {readTaskExecutorRef(){let r=t("task-executor");if(r?.trim())return na(r.trim())},writeTaskExecutorRef(r){e.write("task-executor",ra(r));},readChatHandlerFlow(){return e.read("chat-handler-flow")},writeChatHandlerFlow(r){e.write("chat-handler-flow",r);},readCardStoreRef(){return t("card-store-ref")},writeCardStoreRef(r){e.write("card-store-ref",r);},readOutputsStoreRef(){return t("outputs-store-ref")},writeOutputsStoreRef(r){e.write("outputs-store-ref",r);},readScratchStoreRef(){return t("scratch-store-ref")},writeScratchStoreRef(r){e.write("scratch-store-ref",r);},readArchiveStoreRef(){return t("archive-store-ref")},writeArchiveStoreRef(r){e.write("archive-store-ref",r);},readChatStoreRef(){return t("chat-store-ref")},writeChatStoreRef(r){e.write("chat-store-ref",r);},readArtifactsStoreRef(){return t("artifacts-store-ref")},writeArtifactsStoreRef(r){e.write("artifacts-store-ref",r);}}}function Wu(e){return {writeComputedValues(t,r){e.write(`cards/${t}/computed_values`,r);},readComputedValues(t){return e.read(`cards/${t}/computed_values`)},readAllComputedValues(){let t={};for(let r of e.listKeys("cards/")){let n=r.match(/^cards\/([^/]+)\/computed_values$/);n&&(t[n[1]]=e.read(r));}return t},writeDataObjects(t){for(let[r,n]of Object.entries(t))r&&e.write(`data-objects/${r}`,n);},readDataObject(t){return e.read(`data-objects/${t}`)},readAllDataObjects(){let t={};for(let r of e.listKeys("data-objects/"))t[r.slice(13)]=e.read(r);return t},writeStatusSnapshot(t){e.write("status",t);},readStatusSnapshot(){return e.read("status")}}}function Bu(e){return e?{lastRequestedToken:e.lastRequestedToken,lastCompletedToken:e.lastCompletedToken,lastCompletionStatus:e.lastCompletionStatus??(e.lastCompletedToken?"success":"not-started"),queueRequestedToken:e.queueRequestedToken}:{lastCompletionStatus:"not-started"}}function ay(e){return e?.lastRequestedToken?e.lastCompletedToken!==e.lastRequestedToken:false}function Vu(e,t){return e?.lastRequestedToken?ay(e)?"in-flight":!e.lastCompletedToken||e.lastCompletedToken<t?"dispatch":"idle":"dispatch"}function iy(e,t){return {...e,lastCompletedToken:t,lastCompletionStatus:"success"}}function Uu(e,t){return {...e,lastCompletedToken:t,lastCompletionStatus:"failure"}}function Jn(e,t){let r=t.state.tasks,n=t.config.tasks,s=Object.keys(r),o=Br(t),a={completed:0,failed:0,in_progress:0,pending:0,blocked:0,unresolved:0},i=new Map;for(let f of o.pending)i.set(f.taskName,f.waitingOn);for(let f of o.unresolved)i.set(f.taskName,f.missingTokens);for(let f of o.blocked)i.set(f.taskName,f.failedTokens);let u=new Map;for(let[f,m]of Object.entries(n))for(let b of m.requires??[]){let C=u.get(b)??[];C.push(f),u.set(b,C);}let c=s.sort().map(f=>{let m=r[f],b=n[f]??{requires:[],provides:[]};m.status==="completed"?a.completed+=1:m.status==="failed"?a.failed+=1:m.status==="in-progress"&&(a.in_progress+=1);let C=b.requires??[],q=b.provides??[],_=Object.keys(m.data??{}).sort(),I=C.filter(R=>t.state.availableOutputs.includes(R)),S=C.filter(R=>!t.state.availableOutputs.includes(R)),k=i.get(f)??S,w=new Set;for(let R of q)for(let E of u.get(R)??[])E!==f&&w.add(E);let p=m.failedAt,h=m.error?{message:m.error,code:"TASK_FAILED",at:p,source:"task-runtime"}:void 0;return {name:f,status:m.status,error:h,requires:C,requires_satisfied:I,requires_missing:S,provides_declared:q,provides_runtime:_,blocked_by:k,unblocks:Array.from(w).sort(),runtime:{attempt_count:m.executionCount??0,restart_count:m.retryCount??0,in_progress_since:m.status==="in-progress"?m.startedAt??null:null,last_transition_at:m.lastUpdated??null,last_completed_at:m.completedAt??null,last_restarted_at:m.startedAt??null,status_age_ms:m.lastUpdated?0:null}}});a.pending=o.pending.length,a.blocked=o.blocked.length,a.unresolved=o.unresolved.length;let d=c.map(f=>({name:f.name,fanOut:f.unblocks.length})).sort((f,m)=>m.fanOut-f.fanOut||f.name.localeCompare(m.name)),l=d.length>0?d[0]:{name:null,fanOut:0},g=new Set;for(let f of Object.values(n))for(let m of f.requires??[])g.add(m);let v=0;for(let[f,m]of Object.entries(n)){let b=(m.requires??[]).length===0,q=(m.provides??[]).some(_=>(u.get(_)??[]).some(I=>I!==f));b&&!q&&(v+=1);}return {schema_version:"v1",meta:{board:{path:e}},summary:{card_count:s.length,completed:a.completed,eligible:o.eligible.length,pending:a.pending,blocked:a.blocked,unresolved:a.unresolved,failed:a.failed,in_progress:a.in_progress,orphan_cards:v,topology:{edge_count:Array.from(g).length,max_fan_out_card:l.name,max_fan_out:l.fanOut}},cards:c}}function cy(){return new Date().toISOString()}function Yu(e,t,r,n,s,o,a){return async i=>{let u=[],c=r.cardStore.readCard(i.nodeId);if(!c)return "task-initiate-failure";let d=c.id,l=c.card_data??{},g=c.source_defs??[],v=g.filter(N=>N.optionalForCompletionGating!==true),f=r.cardRuntimeStore.readRuntime(d),m=false,b=()=>{m&&(r.cardRuntimeStore.writeRuntime(d,f),m=false);},C=N=>Bu(f._sources[N]),q=(N,F)=>{f._sources[N]=Bu(F),m=true;},_=i.taskState?.executionCount??0;if(f._lastExecutionCount!==_&&(f._sources={},f._lastExecutionCount=_,m=true),i.update){let N=i.update,F=N.outputFile;if(F){let U=C(F);if(N.failure){let ne=N.rqt??U.lastRequestedToken??U.queueRequestedToken;ne&&q(F,Uu(U,ne));}else {let ne=N.rqt;if(!U.lastCompletedToken||ne>U.lastCompletedToken){let H=typeof N.deliveryToken=="string"?N.deliveryToken:void 0,be=false;H&&(be=r.fetchedSourcesStore.commitSourceData(d,F,H)),be?q(F,iy(U,ne)):q(F,Uu(U,ne));}}b();}}let S={};for(let N of g)if(N.outputFile){let F=r.fetchedSourcesStore.readSourceData(d,N.outputFile);F!==null&&(S[N.bindTo]=F);}let k={};for(let[N,F]of Object.entries(i.state??{}))if(F!==null&&typeof F=="object"&&!Array.isArray(F)){let U=F[N];k[N]=U!==void 0?U:F;}else k[N]=F;let w={id:d,card_data:{...l},requires:k,source_defs:g,compute:c.compute};w._sourcesData=S,c.compute&&ut.runSync(w,{sourcesData:S}),(o??r.outputStore.writeComputedValues.bind(r.outputStore))(d,w.computed_values??{});let p={...c},h=ut.enrichSourcesSync(Array.isArray(c.source_defs)?c.source_defs:void 0,{card_data:c.card_data,requires:k}),R=e.value;p.source_defs=Array.isArray(h)?h.map(N=>({...N,boardDir:typeof N.boardDir=="string"&&N.boardDir?N.boardDir:R})):h;let E=cy(),A=i.update?void 0:E,T=v.filter(N=>{let F=N.outputFile;if(typeof F!="string"||!F)return true;let U=C(F);A&&(U={...U,queueRequestedToken:A},q(F,U));let ne=U.queueRequestedToken??U.lastRequestedToken??E,H=Vu(U,ne);return H==="in-flight"?false:H==="dispatch"});if(b(),T.length>0){let N=false,F=E;for(let U of T){let ne=U.outputFile;if(typeof ne!="string"||!ne)continue;let H=C(ne),be=H.queueRequestedToken??E;q(ne,{...H,lastRequestedToken:be}),F=be,N=true;}return N&&b(),N&&(u.push({taskKind:"source-fetch",payload:{boardRef:pe(e),enrichedCard:p,callbackToken:i.callbackToken,rqt:F}}),r.executionRequestStore.appendEntries(t,u)),"task-initiated"}if(v.some(N=>{let F=N.outputFile;if(typeof F!="string"||!F)return false;let U=C(F),ne=U.queueRequestedToken??U.lastRequestedToken??E;return Vu(U,ne)==="in-flight"}))return "task-initiated";let Q=c.provides??[],te={};for(let{bindTo:N,ref:F}of Q)te[N]=ut.resolve(w,F);return (a??r.outputStore.writeDataObjects.bind(r.outputStore))(te),g.filter(N=>{if(N.optionalForCompletionGating!==true)return false;let F=C(N.outputFile);return !F.lastRequestedToken||!F.lastCompletedToken?true:F.lastCompletedToken<=F.lastRequestedToken}).length>0&&u.push({taskKind:"source-fetch",payload:{boardRef:pe(e),enrichedCard:p,callbackToken:i.callbackToken,rqt:E}}),n(i.nodeId,te),u.length>0&&r.executionRequestStore.appendEntries(t,u),"task-initiated"}}var zn={settings:{completion:"manual",refreshStrategy:"data-changed"},tasks:{}};function Xu(e){return {[xt]:e.graph,[Ju]:e.lastDrainedJournalId}}function Qu(e){let t=e[xt],r=e[Ju];if(!t||typeof t!="object")throw new Error(`State snapshot is missing required key: ${xt}`);return {graph:t,lastDrainedJournalId:typeof r=="string"?r:""}}function Zu(e){let t=e.requires,r=e.provides?.map(n=>n.bindTo)??[];return {requires:t&&t.length>0?t:void 0,provides:r,taskHandlers:["card-handler"],description:e.meta?.title??e.id}}function oa(e){function t(o){return {status:"success",data:o}}function r(o){return {status:"fail",error:o}}function n(o){return {status:"error",error:o instanceof Error?o.message:String(o)}}function s(o){if(Array.isArray(o))return o;if(o&&typeof o=="object"){let a=o;return Array.isArray(a.files)?a.files:[o]}return null}return {get(o){try{let a=o.params?.id;if(a){let i=e.readCard(a);return i?t({cards:[i]}):r(`card "${a}" not found`)}return t({cards:e.readAllCards()})}catch(a){return n(a)}},set(o){try{let a=o.body;if(a==null)return r("set requires a body (card object or array of cards)");let i=Array.isArray(a)?a:[a];for(let u of i){if(typeof u.id!="string")return r("each card must have a string `id` field");e.writeCard(u.id,u);}return t({count:i.length})}catch(a){return n(a)}},del(o){try{let a=o.body?.ids??[],i=o.params?.id,u=i?[...a,i]:a;if(u.length===0)return r("del requires body.ids (string[]) or params.id");for(let c of u)e.removeCard(c);return t({count:u.length})}catch(a){return n(a)}},patch(o){try{let a=o.params?.id,i=o.params?.path;if(!a)return r("patch requires params.id");if(!i)return r("patch requires params.path");let u=o.body,c=u&&Object.prototype.hasOwnProperty.call(u,"value")?u.value:o.body;return e.patchCard(a,i,c),t({count:1})}catch(a){return n(a)}},appendFiles(o){try{let a=o.params?.id;if(!a)return r("appendFiles requires params.id");let i=e.readCard(a);if(!i)return r(`card "${a}" not found`);let u=s(o.body);if(!u||u.length===0)return r("appendFiles requires a file metadata object, array, or body.files array");let c=i.card_data&&typeof i.card_data=="object"&&!Array.isArray(i.card_data)?i.card_data:{},d=Array.isArray(c.files)?c.files:[],l=[...d,...u],g=u.map((f,m)=>({idx:d.length+m,entry:f})),v=this.patch({params:{id:a,path:"card_data.files"},body:{value:l}});return v.status!=="success"?v:t({files_added:g})}catch(a){return n(a)}}}}function X(e){return e!==void 0?{status:"success",data:e}:{status:"success"}}function L(e){return {status:"fail",error:e}}function ee(e){return {status:"error",error:e instanceof Error?e.message:String(e)}}function uy(e){let t=new TextEncoder().encode(e),r=Array.from(t,n=>String.fromCharCode(n)).join("");return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function td(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),r=t+"=".repeat((4-t.length%4)%4),n=atob(r),s=Uint8Array.from(n,o=>o.charCodeAt(0));return new TextDecoder().decode(s)}function Hn(e){try{let t=JSON.parse(td(e));return typeof t?.t=="string"?{taskName:t.t}:null}catch{return null}}function dy(e){return uy(JSON.stringify(e))}function ed(e){try{let t=JSON.parse(td(e));return typeof t?.cbk=="string"&&typeof t?.cid=="string"&&typeof t?.b=="string"&&typeof t?.d=="string"?t:null}catch{return null}}function Te(){return new Date().toISOString()}function ly(e,t){let r=t.onWarn??(()=>{}),n=pe(e);function s(x){if(x.length!==0)try{let y=t.publishBoardChangeNotifications?.(x);y&&typeof y.catch=="function"&&y.catch(j=>r(`[board-live-cards-public] publishBoardChangeNotifications failed: ${j instanceof Error?j.message:String(j)}`));}catch(y){r(`[board-live-cards-public] publishBoardChangeNotifications failed: ${y instanceof Error?y.message:String(y)}`);}}function o(){let x=i().readCardStoreRef();if(!x)throw new Error(`Board at ${e.value} has no card store configured. Run: init --base-ref <ref> --store-ref <b64-ref>`);let y=t.kvStorageForRef(x);return {readIndex(){return y.read("_index")},writeIndex(j){y.write("_index",j);},readCard(j){return y.read(j)},writeCard(j,D){return y.write(j,D),t.hashFn(D)},removeCard(j){y.delete(j);},cardExists(j){return y.read(j)!==null},defaultCardKey(j){return j}}}let a={readValues(x){let y=t.kvStorage("state-snapshot"),j=y.listKeys().sort();if(j.length===0)return {version:null,values:{}};let D={};for(let Z of j)D[Z]=y.read(Z);return {version:t.hashFn(D),values:D}},writeValues(x,y,j){let D=t.kvStorage("state-snapshot");for(let Z of j)D.delete(Z);for(let[Z,de]of Object.entries(y))D.write(Z,de);return t.hashFn(y)}},i=()=>sa(t.kvStorage("config")),u=()=>Hu(a),c=()=>Ku(t.journalAdapter()),d=()=>Kn(o(),r),l=()=>{let x=i().readOutputsStoreRef();if(!x)throw new Error(`Board at ${e.value} has no outputs store configured. Run: init --outputs-store-ref <b64-ref>`);return Wu(t.kvStorageForRef(x))},g=()=>{let x=i().readArchiveStoreRef();return x?t.archiveFactoryForRef(x):t.archiveFactory()};function v(){return !!u().readSnapshot(e.value).values[xt]}function f(){let x=u().readSnapshot(e.value);if(!x.values[xt])throw new Error(`Board not initialized at ${e.value}`);return Qu(x.values)}function m(x,y){let j=u().commitSnapshot(e.value,{schemaVersion:Ur,expectedVersion:y,commitId:t.genId(),committedAt:Te(),deleteKeys:[],shallowMerge:Xu(x)});if(!j.ok)throw new Error(`Snapshot commit failed (version mismatch): expected=${y??"null"} current=${j.currentVersion??"null"}`)}function b(x){c().appendEvent(x);}async function C(){let x=(P,K)=>{let me=P.payload,Xe=(me?.enrichedCard??{}).id??me?.cardId??"unknown";b({type:"task-failed",taskName:Xe,error:K,timestamp:Te()});},y=Gu(t.kvStorage("execution-requests"),x),j=zu(t.kvStorage("card-runtime")),D=Gn(t.blobStorage("sources"),P=>t.resolveBlob(P)),Z=new Map,de={readRuntime(P){return Z.get(P)??j.readRuntime(P)},writeRuntime(P,K){Z.set(P,K);}},Ne=[],ye=new Map,Ve={readSourceData(P,K){let me=`${P}/${K}`;return ye.has(me)?ye.get(me):D.readSourceData(P,K)},ingestSourceDataStaged(P,K,me,ht){D.ingestSourceDataStaged(P,K,me,ht);},commitSourceData(P,K,me){let ht=`${P}/.staged/${me}/${K}`,zr=t.blobStorage("sources").read(ht);if(zr==null)return false;let Ht=`${P}/${K}`,fa=zr.trim();try{ye.set(Ht,JSON.parse(fa));}catch{ye.set(Ht,fa);}return Ne.push({cardId:P,outputFile:K,deliveryToken:me}),true},hasSource(P,K){let me=`${P}/${K}`;return ye.has(me)?true:D.hasSource(P,K)},listSources(P){let K=D.listSources(P),me=new Set;for(let Xe of ye.keys())Xe.startsWith(`${P}/`)&&me.add(Xe.slice(`${P}/`.length));let ht=new Set([...K,...me]);return Array.from(ht)}},Ie={cardStore:d(),cardRuntimeStore:de,fetchedSourcesStore:Ve,outputStore:l(),executionRequestStore:y},At=f(),Tt=Vn(At.graph),{events:Gt,newCursor:Jt}=c().readEntriesAfterCursor(At.lastDrainedJournalId),It=[],Wn=[],Yn=[],Xn=new Map,ua=new Set,id=(P,K)=>{It.push({type:"task-completed",taskName:P,data:K,timestamp:Te()});try{g().stream("exec-history").append({taskName:P,status:"completed",completedAt:Te()});}catch{}},da=(P,K)=>{b({type:"task-failed",taskName:P,error:K,timestamp:Te()});try{g().stream("exec-history").append({taskName:P,status:"failed",error:K,completedAt:Te()});}catch{}},Gr=Nu(Tt,{handlers:{"card-handler":Yu(e,Jt,Ie,id,da,(P,K)=>{Wn.push({cardId:P,values:K});},P=>{Yn.push(P);})},onNodeRemoved:P=>{Xn.delete(P),Z.delete(P),ua.add(P);}});for(It=Gt;It.length>0;){let P=It;It=[];for(let K of P)if(K.type==="task-restart"){let me=Ie.cardStore.readCard(K.taskName);me&&Xn.set(K.taskName,me);}Gr.pushAll(P),await Gr.waitForHandlers();}let la=Gr.getState();await Gr.dispose({wait:true});let cd=u().readSnapshot(e.value).version;m({lastDrainedJournalId:Jt,graph:Lr(la)},cd);for(let{cardId:P,values:K}of Wn)Ie.outputStore.writeComputedValues(P,K);for(let P of Yn)Ie.outputStore.writeDataObjects(P);for(let[P,K]of Z)j.writeRuntime(P,K);for(let{cardId:P,outputFile:K,deliveryToken:me}of Ne)D.commitSourceData(P,K,me);let Jr;try{Jr=Jn(n,la),Ie.outputStore.writeStatusSnapshot(Jr);}catch(P){r(`[board-live-cards-public] status publish failed: ${P instanceof Error?P.message:String(P)}`);}let zt=[];for(let{cardId:P,values:K}of Wn)zt.push({kind:"computed_values",cardId:P,values:K});for(let P of Yn)for(let[K,me]of Object.entries(P))K&&zt.push({kind:"data_object",key:K,payload:me});for(let[P,K]of Xn)zt.push({kind:"card_refreshed",cardId:P,card:K});for(let P of ua)zt.push({kind:"card_removed",cardId:P});Jr!==void 0&&zt.push({kind:"status",status:Jr}),s(zt);let ud=i().readTaskExecutorRef()??{howToRun:"built-in",whatToRun:pe({kind:"built-in",value:"source-cli-task-executor"})};y.dispatchEntriesForJournalId(Jt,P=>{if(P.taskKind!=="source-fetch"){r(`[process-accumulated-events] unknown taskKind "${P.taskKind}" \u2014 skipping`);return}let K=P.payload,me=K.enrichedCard?.id??"unknown",ht=K.enrichedCard?.source_defs??[];for(let Xe of ht){if(!Xe.outputFile){r(`[dispatch] source "${Xe.bindTo}" has no outputFile \u2014 skipping`);continue}let zr=dy({cbk:K.callbackToken,rg:e.value,br:pe(e),cid:me,b:Xe.bindTo,d:Xe.outputFile,cs:void 0,rqt:K.rqt});t.dispatchExecution(ud,{source_def:Xe,base_ref:pe(e),callback:{token:zr,via:t.selfRef}}).catch(Ht=>da(me,Ht instanceof Error?Ht.message:String(Ht)));}});}async function q(){try{let x=()=>{let j=f(),{events:D}=c().readEntriesAfterCursor(j.lastDrainedJournalId);D.length<=0||(q(),t.requestProcessAccumulated?.());},y=await ma(t.lock,C,x);return X({ran:y!==!1})}catch(x){return ee(x)}}function _(){q(),t.requestProcessAccumulated?.();}function I(x){try{let y=x.params?.cardStoreRef;if(!y)return L("init requires params.cardStoreRef \u2014 create a card store with card-store-cli and pass its ref here");if(!v()){let Ie=Bn(zn);m({lastDrainedJournalId:"",graph:Lr(Ie)},null);}let j=x.params?.outputsStoreRef;if(!j)return L("init requires params.outputsStoreRef \u2014 pass the outputs store ref here");let D=x.params?.scratchStoreRef,Z=x.params?.archiveStoreRef,de=x.params?.chatStoreRef,Ne=x.params?.artifactsStoreRef,ye=i();ye.writeCardStoreRef(y),ye.writeOutputsStoreRef(j),D&&ye.writeScratchStoreRef(D),Z&&ye.writeArchiveStoreRef(Z),de&&ye.writeChatStoreRef(de),Ne&&ye.writeArtifactsStoreRef(Ne);let Ve=x.body??{};Ve["task-executor-ref"]&&ye.writeTaskExecutorRef(Ve["task-executor-ref"]),Object.prototype.hasOwnProperty.call(Ve,"chat-handler-flow")&&ye.writeChatHandlerFlow(Ve["chat-handler-flow"]);try{l().writeStatusSnapshot(Jn(n,Vn(f().graph)));}catch{}return X()}catch(y){return ee(y)}}function S(x){try{let y=l().readStatusSnapshot();if(!y){y=Jn(n,Vn(f().graph));try{l().writeStatusSnapshot(y);}catch{}}return X(y)}catch(y){return ee(y)}}function k(x){try{let y=x.params?.id;if(!y)return L("removeCard requires params.id");try{t.kvStorage("card-upsert").delete(y);}catch{}return b({type:"task-removal",taskName:y,timestamp:Te()}),_(),X()}catch(y){return ee(y)}}function w(x){try{let y=x.params?.cardId;if(!y)return L("addCardFiles requires params.cardId");let j=oa(d()).appendFiles({params:{id:y},body:x.body});if(j.status!=="success")return j;let D=p({params:{cardId:y}});return D.status!=="success"?D:X({cardId:y,files_added:j.data.files_added,notified:!0})}catch(y){return ee(y)}}function p(x){try{let y=x.params?.cardId;if(!y)return L("cardRefreshedNotify requires params.cardId");let j=d().readCard(y);return j?(s([{kind:"card_refreshed",cardId:y,card:j}]),X({cardId:y,notified:!0})):L(`Card "${y}" not found in board at ${e.value}`)}catch(y){return ee(y)}}function h(x){try{let y=x.params?.id;return y?(b({type:"task-restart",taskName:y,timestamp:Te()}),_(),X()):L("retrigger requires params.id")}catch(y){return ee(y)}}async function R(x){return q()}function E(x){try{let y=x.params?.cardId,j=x.params?.all,D=!!x.params?.restart;if(!y&&!j)return L("upsertCard requires --card-id <id> or --all");let Z=j?d().readAllCards().map(de=>de.id):[y];for(let de of Z)if(!d().readCard(de))return L(`Card "${de}" not found in board at ${e.value}`);for(let de of Z){let Ne=d().readCard(de),ye=Zu(Ne),Ve=t.hashFn(ye),Ie=t.kvStorage("card-upsert"),At=Ie.read(de),Tt=At?.taskConfigHash!==Ve;if(!(!Tt&&!D)){if(Tt){let Gt=At?.blobRef??d().readCardKey(de)??de;b({type:"task-upsert",taskName:de,taskConfig:ye,timestamp:Te()}),Ie.write(de,{blobRef:Gt,taskConfigHash:Ve,updatedAt:Te()});}D&&b({type:"task-restart",taskName:de,timestamp:Te()});}}return _(),X()}catch(y){return ee(y)}}function A(x){try{let y=x.params?.token;if(!y)return L("taskFailed requires params.token");let j=x.params?.error??"unknown error",D=Hn(y);if(!D)return L("Invalid callback token");b({type:"task-failed",taskName:D.taskName,error:j,timestamp:Te()});try{g().stream("exec-history").append({taskName:D.taskName,status:"failed",error:j,completedAt:Te()});}catch{}return _(),X()}catch(y){return ee(y)}}function T(x){try{let y=x.params?.token;if(!y)return L("taskProgress requires params.token");let D=(x.body??{}).update??{},Z=Hn(y);return Z?(b({type:"task-progress",taskName:Z.taskName,update:D,timestamp:Te()}),_(),X()):L("Invalid callback token")}catch(y){return ee(y)}}function V(x){try{let y=x.params?.token,j=x.params?.ref;if(!y)return L("sourceDataFetched requires params.token");if(!j)return L("sourceDataFetched requires params.ref");let D=ed(y);if(!D)return L("Invalid source token");let{cbk:Z,cid:de,b:Ne,d:ye,cs:Ve,rqt:Ie}=D,At=Gn(t.blobStorage("sources"),It=>t.resolveBlob(It)),Tt=t.genId();At.ingestSourceDataStaged(de,ye,Qe(j),Tt);let Gt=Hn(Z);if(!Gt)return L("Invalid callback token embedded in source token");let Jt=Te();return b({type:"task-progress",taskName:Gt.taskName,update:{bindTo:Ne,outputFile:ye,fetchedAt:Jt,deliveryToken:Tt,sourceChecksum:Ve,rqt:Ie},timestamp:Jt}),_(),X()}catch(y){return ee(y)}}function Q(x){try{let y=x.params?.token,j=x.params?.reason??"unknown";if(!y)return L("sourceDataFetchFailure requires params.token");let D=ed(y);if(!D)return L("Invalid source token");let{cbk:Z,b:de,d:Ne,cs:ye,rqt:Ve}=D,Ie=Hn(Z);return Ie?(b({type:"task-progress",taskName:Ie.taskName,update:{bindTo:de,outputFile:Ne,failure:!0,reason:j,sourceChecksum:ye,rqt:Ve},timestamp:Te()}),_(),X()):L("Invalid callback token embedded in source token")}catch(y){return ee(y)}}function te(x){try{let y=i().readCardStoreRef();return y?X({storeRef:y}):L(`Board at ${e.value} has no card store configured`)}catch(y){return ee(y)}}function ue(x){try{let y=i().readOutputsStoreRef();return y?X({storeRef:y}):L(`Board at ${e.value} has no outputs store configured`)}catch(y){return ee(y)}}function N(x){try{let y=i().readScratchStoreRef();return X({storeRef:y})}catch(y){return ee(y)}}function F(x){try{let y=i().readArchiveStoreRef();return X({storeRef:y})}catch(y){return ee(y)}}function U(x){try{let y=i().readChatStoreRef();return X({storeRef:y})}catch(y){return ee(y)}}function ne(x){try{let y=i().readArtifactsStoreRef();return X({storeRef:y})}catch(y){return ee(y)}}function H(x){try{let y=x.params?.key;if(!y)return L("getConfig requires params.key");let j=i(),D;switch(y){case "task-executor":D=j.readTaskExecutorRef()??null;break;case "chat-handler-flow":D=j.readChatHandlerFlow()??null;break;case "card-store-ref":D=j.readCardStoreRef();break;case "outputs-store-ref":D=j.readOutputsStoreRef();break;case "scratch-store-ref":D=j.readScratchStoreRef();break;case "archive-store-ref":D=j.readArchiveStoreRef();break;case "chat-store-ref":D=j.readChatStoreRef();break;case "artifacts-store-ref":D=j.readArtifactsStoreRef();break;default:return L(`getConfig: unknown key "${y}"`)}return X({value:D})}catch(y){return ee(y)}}function be(x){try{let y=x.params?.key;if(!y)return L("getOutputsDataObject requires params.key");let j=l().readDataObject(y);return X(j)}catch(y){return ee(y)}}function se(x){try{return X(l().readAllDataObjects())}catch(y){return ee(y)}}function ve(x){try{let y=x.params?.key;if(!y)return L("getOutputsComputedValues requires params.key");let j=l().readComputedValues(y);return X(j)}catch(y){return ee(y)}}function Re(x){try{return X(l().readAllComputedValues())}catch(y){return ee(y)}}function Be(){return Gn(t.blobStorage("sources"),x=>t.resolveBlob(x))}function Ke(x){let y=t.blobStorage("sources").keyRef?.(x);return y?pe(y):x}function Kt(x){try{let y=x.params?.key;if(!y)return L("getOutputsFetchedSources requires params.key");let j=Be().listSources(y),D={};for(let Z of j)D[Z]=Ke(`${y}/${Z}`);return X(D)}catch(y){return ee(y)}}function Pe(x){try{let y=Be(),j=new Set;for(let Z of t.blobStorage("sources").listKeys()){let de=Z.indexOf("/");de>0&&!Z.includes("/.staged/")&&j.add(Z.slice(0,de));}let D={};for(let Z of j){let de=y.listSources(Z);if(de.length>0){D[Z]={};for(let Ne of de)D[Z][Ne]=Ke(`${Z}/${Ne}`);}}return X(D)}catch(y){return ee(y)}}return {init:I,status:S,getCardStoreRef:te,getOutputsStoreRef:ue,getScratchStoreRef:N,getArchiveStoreRef:F,getChatStoreRef:U,getArtifactsStoreRef:ne,getConfig:H,getOutputsDataObject:be,getAllOutputsDataObjects:se,getOutputsComputedValues:ve,getAllOutputsComputedValues:Re,getOutputsFetchedSources:Kt,getAllOutputsFetchedSources:Pe,removeCard:k,addCardFiles:w,cardRefreshedNotify:p,retrigger:h,processAccumulatedEvents:R,upsertCard:E,taskFailed:A,taskProgress:T,sourceDataFetched:V,sourceDataFetchFailure:Q}}function fy(e,t){let r=()=>sa(t.kvStorage("config"));function n(){let S=r().readCardStoreRef();if(!S)throw new Error(`Board at ${e.value} has no card store configured. Run: init --base-ref <ref> --store-ref <b64-ref>`);let k=t.kvStorageForRef(S);return {readIndex(){return k.read("_index")},writeIndex(w){k.write("_index",w);},readCard(w){return k.read(w)},writeCard(w,p){return k.write(w,p),t.hashFn(p)},removeCard(w){k.delete(w);},cardExists(w){return k.read(w)!==null},defaultCardKey(w){return w}}}let s=()=>Kn(n(),t.onWarn??(()=>{})),o=()=>{let S=r().readScratchStoreRef();return S?t.scratchStorageForRef(S):t.scratchStorage()};function a(S,k){let w=t.validateSchema(k),p=[],h=r().readTaskExecutorRef();if(h&&Array.isArray(k.source_defs))for(let E of k.source_defs){let A=typeof E.bindTo=="string"?E.bindTo:"(unknown)";try{let T;try{T=t.invokeExecutorSync(h,"validate-source-def",[],{timeout:t.executorTimeouts?.validationMs??1e4,input:JSON.stringify(E)});}catch(Q){let te=Q;if(T=typeof te?.stdout=="string"?te.stdout:"",!T.trim()){p.push(`source "${A}": executor validate-source-def failed \u2014 ${Q instanceof Error?Q.message:String(Q)}`);continue}}let V=JSON.parse(T.trim());if(!V.ok&&Array.isArray(V.errors))for(let Q of V.errors)p.push(`source "${A}": ${Q}`);}catch(T){p.push(`source "${A}": executor validate-source-def failed \u2014 ${T instanceof Error?T.message:String(T)}`);}}let R=[...w.errors,...p];return X({cardId:S,isValid:R.length===0,issues:R})}function i(S,k){let w=r().readTaskExecutorRef();if(!w)throw new Error("No task-executor registered for this board");let p=typeof S.bindTo=="string"?S.bindTo:"source",h=o(),R={...S,boardDir:e.value,_projections:k},E=h.create(JSON.stringify(R,null,2),`probe-in-${p}`,".json"),A=h.getUniqueKey(`probe-out-${p}`,".json"),T=h.getUniqueKey(`probe-err-${p}`,".txt"),V=pe(h.keyRef(E)),Q=pe(h.keyRef(A)),te=pe(h.keyRef(T)),ue=null;try{if(t.invokeExecutorSync(w,"run-source-fetch",["--in-ref",V,"--out-ref",Q,"--err-ref",te],{timeout:S.timeout??t.executorTimeouts?.probeMs??6e4}),ue=h.read(A),ue===null)throw new Error("Executor produced no output file")}catch(N){let F=h.read(T)?.trim()??(N instanceof Error?N.message:String(N));throw new Error(`Probe failed: ${F}`)}finally{try{h.remove(E);}catch{}try{h.remove(T);}catch{}}return {bindTo:p,result:ue}}function u(S,k,w){let p;try{p=i(S,k);}catch(h){return L(h instanceof Error?h.message:String(h))}if(w){let h=Qe(w);t.absoluteBlob.write(h.value,p.result);}return X({bindTo:p.bindTo,resultSizeBytes:p.result.length})}function c(S,k){let w=S.params?.sourceIdx,p=S.params?.outRef;if(w===void 0)return L(`${k} requires params.sourceIdx`);if(!S.body||typeof S.body!="object"||Array.isArray(S.body))return L(`${k} requires card JSON object in body`);let h=S.body,R=h["card-content"]??h,E=h["mock-projections"]??{},A=R.source_defs??[];if(w<0||w>=A.length)return L(`sourceIdx ${w} out of range (card has ${A.length} source(s))`);let T=A[w],V=typeof T.bindTo=="string"?T.bindTo:"source";return {src:T,bindTo:V,outRef:p,mockProjections:E}}function d(S){try{let k=S.params?.cardId,w=S.params?.all;if(!k&&!w)return L("validateCard requires --card-id <id> or --all");let p=w?s().readAllCards().map(R=>R.id):[k],h=[];for(let R of p){let E=s().readCard(R);if(!E){h.push({cardId:R,isValid:!1,issues:[`Card "${R}" not found`]});continue}let A=a(R,E);if(A.status!=="success")return A;h.push(A.data);}return X(h)}catch(k){return ee(k)}}function l(S){try{if(!S.body||typeof S.body!="object"||Array.isArray(S.body))return L("validateCardPreflight requires card JSON object in body");let k=S.body,w=k["card-content"]??k,p=typeof w.id=="string"?w.id:"(unknown)";return a(p,w)}catch(k){return ee(k)}}function g(S){try{let k=S.params?.cardId,w=S.params?.sourceIdx,p=S.params?.outRef;if(!k)return L("probeSource requires params.cardId");if(w===void 0)return L("probeSource requires params.sourceIdx");let R=(S.body??{})["mock-projections"]??{},E=s().readCard(k);if(!E)return L(`Card "${k}" not found`);let A=E.source_defs??[];return w<0||w>=A.length?L(`sourceIdx ${w} out of range (card has ${A.length} source(s))`):u(A[w],R,p)}catch(k){return ee(k)}}function v(S){try{let k=S.params?.outRef,w=S.body;if(!w)return L('probeTmpSource requires body with "source-def" and "mock-projections"');let p=w["source-def"],h=w["mock-projections"]??{};return p?u(p,h,k):L('probeTmpSource body requires "source-def"')}catch(k){return ee(k)}}function f(S){try{let k=c(S,"probeSourcePreflight");if("status"in k)return k;let w=r().readTaskExecutorRef();if(!w)return L("No task-executor registered for this board");try{let p={...k.src,_projections:k.mockProjections},h=t.invokeExecutorSync(w,"probe-source-preflight",[],{timeout:k.src.timeout??t.executorTimeouts?.preflightMs??6e4,input:JSON.stringify(p)}),R=JSON.parse(h.trim());return R.ok?X({bindTo:k.bindTo,reachable:R.reachable,latencyMs:R.latencyMs,note:R.note}):L(R.error??"Preflight probe failed")}catch{return L("Executor does not support probe-source-preflight")}}catch(k){return ee(k)}}function m(S){try{let k=c(S,"runSourcePreflight");if("status"in k)return k;try{let w=i(k.src,k.mockProjections);if(k.outRef){let h=Qe(k.outRef);t.absoluteBlob.write(h.value,w.result);}let p=w.result;try{p=JSON.parse(w.result);}catch{}return X({bindTo:w.bindTo,ok:!0,result:p,issues:[]})}catch(w){let p=w instanceof Error?w.message:String(w);return p==="No task-executor registered for this board"?L(p):X({bindTo:k.bindTo,ok:!1,result:null,issues:[p]})}}catch(k){return ee(k)}}function b(S){try{let k=r().readTaskExecutorRef();if(!k)return L("No task-executor registered for this board");let w=t.invokeExecutorSync(k,"describe-capabilities",[],{timeout:t.executorTimeouts?.describeMs??1e4});return X(JSON.parse(w.trim()))}catch(k){return ee(k)}}function C(S){try{let k=S.body;if(!k||!Array.isArray(k.ops))return L("updatesInCardStore requires body.ops array");let w=k.ops,p=s();for(let h of w){let R=h.op,E=h.id;if(!E)return L('op is missing "id"');if(R==="update"){let A=h["card-content"];if(!A)return L(`update op for "${E}" is missing "card-content"`);p.writeCard(E,A);}else return L(`Unknown op type: "${R??"(none)"}"`)}return X()}catch(k){return ee(k)}}function q(S){try{let k=S.body;if(!k||!Array.isArray(k.ids))return L("readFromCardStore requires body.ids array");let w=k.ids,p=s(),h=w.map(R=>({id:R,"card-content":p.readCard(R)}));return X({cards:h})}catch(k){return ee(k)}}function _(S){try{if(!S.body||typeof S.body!="object"||Array.isArray(S.body))return L("evalCardCompute requires a JSON object in body");let k=S.body,w=k["card-content"]??k,p=typeof w.id=="string"?w.id:"(unknown)",h=k["mock-fetched-sources"]??{},R=k["mock-requires"]??{},E=w.compute;if(!E||!Array.isArray(E)||E.length===0)return X({cardId:p,ok:!0,computed_values:{},errors:[]});let A={id:p,card_data:w.card_data??{},requires:R,source_defs:w.source_defs,compute:E},T=ut.runSync(A,{sourcesData:h}),V=T.node.computed_values??{},Q=T.errors??[];return X({cardId:p,ok:Q.length===0,computed_values:V,errors:Q})}catch(k){return ee(k)}}function I(S){try{if(!S.body||typeof S.body!="object"||Array.isArray(S.body))return L("simulateCardCycle requires a JSON object in body");let k=S.body,w=k["card-content"]??k,p=typeof w.id=="string"?w.id:"(unknown)",h=k["mock-fetched-sources"]??{},R=k["mock-requires"]??{},E=a(p,w),A=E.status==="success"?{isValid:E.data.isValid,issues:E.data.issues}:{isValid:!1,issues:[E.status==="fail"?E.error:"internal error"]},T=w.source_defs??[],V=w.card_data??{},Q=[],te=[];if(T.length>0){Q=ut.enrichSourcesSync(T,{card_data:V,requires:R});for(let ve of Q){let Re=ve.projections,Be=ve._projections;if(Re&&Be){for(let Ke of Object.keys(Re))if(Be[Ke]===void 0){let Kt=typeof ve.bindTo=="string"?ve.bindTo:"(unknown)";te.push({bindTo:Kt,key:Ke,error:`Projection "${Ke}" resolved to undefined`});}}}}let ue=[],N={...h},F=k["task-executor-ref"],U=(F?.howToRun&&F?.whatToRun?F:void 0)??r().readTaskExecutorRef();for(let ve=0;ve<Q.length;ve++){let Re=Q[ve],Be=typeof Re.bindTo=="string"?Re.bindTo:`source_${ve}`;if(!U){ue.push({bindTo:Be,skipped:!0,error:"No task executor configured"});continue}try{let Ke={...Re},Kt=t.invokeExecutorSync(U,"run-source-preflight",[],{timeout:Re.timeout??t.executorTimeouts?.preflightMs??6e4,input:JSON.stringify(Ke)}),Pe=JSON.parse(Kt.trim());Pe.ok&&!Object.prototype.hasOwnProperty.call(h,Be)&&Object.prototype.hasOwnProperty.call(Pe,"resultValue")&&(N[Be]=Pe.resultValue),ue.push({bindTo:Be,reachable:Pe.reachable,latencyMs:Pe.latencyMs,error:Pe.ok?void 0:Pe.error});}catch{ue.push({bindTo:Be,skipped:!0,error:"Executor does not support run-source-preflight"});}}let ne=w.compute,H={},be=[];if(ne&&Array.isArray(ne)&&ne.length>0){let ve={id:p,card_data:V,requires:R,source_defs:w.source_defs,compute:ne},Re=ut.runSync(ve,{sourcesData:N});H=Re.node.computed_values??{},be=Re.errors??[];}let se=A.isValid&&te.length===0&&be.length===0&&ue.every(ve=>ve.reachable!==!1);return X({cardId:p,ok:se,validation:A,source_probes:ue,projection_errors:te,fetched_sources:N,computed_values:H,compute_errors:be})}catch(k){return ee(k)}}return {validateCard:d,validateCardPreflight:l,probeSource:g,probeTmpSource:v,probeSourcePreflight:f,runSourcePreflight:m,evalCardCompute:_,simulateCardCycle:I,describeTaskExecutorCapabilities:b,updatesInCardStore:C,readFromCardStore:q}}function _e(e,t){if(e?.status==="success")return Object.prototype.hasOwnProperty.call(e,"data")?e.data:void 0;throw e?.status==="fail"||e?.status==="error"?new Error(e.error||`${t} failed`):new Error(`${t} returned an unexpected response`)}function py(e,t){if(e?.status==="success"&&Object.prototype.hasOwnProperty.call(e,"data"))return e.data;throw e?.status==="success"?new Error(`${t} returned success without data`):e?.status==="fail"||e?.status==="error"?new Error(e.error||`${t} failed`):new Error(`${t} returned an unexpected response`)}function B(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}function we(e){return Array.isArray(e)?e:[]}function ia(e,t){if(typeof t!="string"||t.length===0)return;let r=e,n=t;n.startsWith("fetched_sources.")&&(r=B(e).fetched_sources,n=n.slice(16));for(let s of n.split(".")){if(r==null||typeof r!="object")return;r=r[s];}return r}function aa(e,t){let r=B(e.view),n=we(r.elements);return {layout:r.layout,features:r.features,elements:n.map((s,o)=>{let a=B(s),i=B(a.data),u=typeof a.visible=="string"?!!ia(t,a.visible):true,c=typeof i.bind=="string"?i.bind:void 0,d=typeof i.maxRows=="number"?i.maxRows:void 0,l=c?ia(t,c):void 0,g={id:typeof a.id=="string"&&a.id?a.id:`element-${o}`,kind:a.kind,label:a.label,visible:u};return l!==void 0&&(g.resolved=Array.isArray(l)&&typeof d=="number"?l.slice(0,d):l),g})}}function rd(e,t){let r=typeof e.id=="string"&&e.id?e.id:"card",n=we(e.provides),s=n.length>0?n:[{bindTo:r,ref:"card_data"}],o={};for(let a of s){let i=B(a),u=typeof i.bindTo=="string"?i.bindTo:"",c=typeof i.ref=="string"?i.ref:"";if(!u||!c)continue;let d=ia(t,c);d!==void 0&&(o[u]=d);}return o}function my(e){if(typeof e!="string"||!e.trim())return null;let t=/^(file uploaded|AI generated|AI geneterated):\s*.*?#(\d+)\s*$/i.exec(e.trim());if(!t)return null;let r=Number.parseInt(t[2],10);return !Number.isInteger(r)||r<0?null:r}function gy(e){return {"card-content":e}}function Kr(e,t){let r=_e(e.get({params:{id:t}}),"cardStore.get"),n=Array.isArray(r?.cards)?r.cards:[];if(n.length===0)throw new Error(`Card "${t}" not found`);return n[0]}function hy(e){let{board:t,nonCore:r,cardStore:n,chatStore:s,uploadCardFile:o,buildFileDownloadUrl:a,readFetchedSourceJsonByRef:i}=e;function u(p){if(Array.isArray(p.bytes))return new Uint8Array(p.bytes.map(h=>Math.max(0,Math.min(255,Number(h)||0))));if(typeof p.text=="string")return new TextEncoder().encode(p.text);if(typeof p.base64=="string"){let h=String(p.base64).replace(/-/g,"+").replace(/_/g,"/"),R=h+"=".repeat((4-h.length%4)%4),E=atob(R);return Uint8Array.from(E,A=>A.charCodeAt(0))}throw new Error("file entry requires bytes, text, or base64")}function c(){let p=B(_e(r.describeTaskExecutorCapabilities({}),"describeTaskExecutorCapabilities"));return {version:p.version,commonSourceFields:B(p.commonSourceDefFields),sourceKinds:B(p.sourceKinds)}}function d(){let p=B(_e(t.status({}),"status")),h=B(p.summary),R=we(p.cards);return {meta:B(p.meta),summary:{card_count:typeof h.card_count=="number"?h.card_count:0,completed:typeof h.completed=="number"?h.completed:0,eligible:typeof h.eligible=="number"?h.eligible:0,pending:typeof h.pending=="number"?h.pending:0,blocked:typeof h.blocked=="number"?h.blocked:0,in_progress:typeof h.in_progress=="number"?h.in_progress:0,failed:typeof h.failed=="number"?h.failed:0,unresolved:typeof h.unresolved=="number"?h.unresolved:0},cards:R.map(E=>{let A=B(E);return {"card-id":typeof A.name=="string"?A.name:null,status:A.status??null,error:A.error??null,requires:we(A.requires),requires_satisfied:we(A.requires_satisfied),requires_missing:we(A.requires_missing),provides_declared:we(A.provides_declared),provides_runtime:we(A.provides_runtime)}})}}function l(p){let h=String(p.cardId||"").trim();if(!h)throw new Error("inspectCardDefinitionAndRuntime requires cardId");let R=B(_e(t.status({}),"status")),A=we(R.cards).map(B).find(se=>se.name===h);if(!A)throw new Error(`card "${h}" not found in board status`);let T=B(Kr(n,h)),V=we(A.requires_satisfied).filter(se=>typeof se=="string"&&!!se),Q=we(A.provides_runtime).filter(se=>typeof se=="string"&&!!se),te=Object.fromEntries(V.map(se=>[se,_e(t.getOutputsDataObject({params:{key:se}}),`getOutputsDataObject(${se})`)])),ue=Object.fromEntries(Q.map(se=>[se,_e(t.getOutputsDataObject({params:{key:se}}),`getOutputsDataObject(${se})`)])),N=B(_e(t.getOutputsComputedValues({params:{key:h}}),"getOutputsComputedValues")),F=_e(t.getOutputsFetchedSources({params:{key:h}}),"getOutputsFetchedSources"),U=we(T.source_defs).map(B),ne={};for(let se of U)typeof se.bindTo=="string"&&typeof se.outputFile=="string"&&(ne[se.outputFile]=se.bindTo);let H={};for(let[se,ve]of Object.entries(F)){let Re=ne[se]??se;if(!i||typeof ve!="string"){H[Re]=null;continue}try{H[Re]=i({cardId:h,ref:ve});}catch{H[Re]=null;}}let be={card_data:B(T.card_data),requires:te,fetched_sources:H,computed_values:N};return {cardId:h,card_status_in_board:A,card_definition_and_static_data:T,refs_for_fetched_source_files:F,runtime_data:{requires:te,provides:ue,computed_values:N,rendered_view:aa(T,be)}}}function g(p){let h=String(p.cardId||"").trim();if(!h)throw new Error("inspectChatMessagesOnCards requires cardId");let R=typeof p.turnId=="string"?p.turnId:"",E=p.allTurns===true,A=typeof p.tailTurnsBeforeId=="string"?p.tailTurnsBeforeId:"",T=E?void 0:p.lastUserTurns??(R?void 0:1),V=p.tail,Q={...T===void 0?{}:{tailTurns:T},...R?{turnId:R}:{},...E?{allTurns:true}:{},...A?{tailTurnsBeforeId:A}:{}},te=Object.keys(Q).length>0?{params:{cardId:h},body:Q}:{params:{cardId:h}},ue=_e(s.readAll(te),"chatStore.readAll"),N=B(Kr(n,h)),F=we(B(N.card_data).files).map((H,be)=>({idx:be,stored_name:B(H).stored_name})).filter(H=>typeof H.stored_name=="string"&&H.stored_name.length>0),ne=(Array.isArray(ue.records)?ue.records:[]).map(H=>{let se=B(H.payload),ve={...H},Re=typeof H?.role=="string"?H.role:typeof se.role=="string"?String(se.role):"",Be=typeof H?.text=="string"?H.text:typeof se.text=="string"?String(se.text):"";if(Re==="system"){let Ke=my(Be);if(Ke!==null&&F.some(Pe=>Pe.idx===Ke)){let Pe=`Retrieve using inspect-file-contents --card-id ${h} --file-idx ${Ke}`;ve.retrieval_hint=Pe,Object.keys(se).length>0&&typeof H.role!="string"&&(ve.payload={...se,retrieval_hint:Pe});}}return ve});return {cardId:h,messages:typeof V=="number"&&V>=0?ne.slice(-V):ne}}function v(p){let h=String(p.cardId||"").trim(),R=Number(p.fileIdx);if(!h)throw new Error("inspectFileContents requires cardId");if(!Number.isInteger(R)||R<0)throw new Error("inspectFileContents requires fileIdx to be a non-negative integer");let E=B(Kr(n,h)),A=we(B(E.card_data).files).map(B);if(R>=A.length)throw new Error(`attachment index ${R} is out of range for card "${h}"`);let T=A[R],V=typeof T.stored_name=="string"?T.stored_name:null;return {cardId:h,fileIdx:R,downloadUrl:a({cardId:h,fileIdx:R,storedName:V}),...typeof T.name=="string"?{name:T.name}:{},...typeof T.stored_name=="string"?{stored_name:T.stored_name}:{},...typeof T.mime_type=="string"?{mime_type:T.mime_type}:{},...typeof T.size=="number"?{size:T.size}:{},...typeof T.uploaded_at=="string"?{uploaded_at:T.uploaded_at}:{}}}function f(p){return r.validateCardPreflight({body:gy(p.candidateCardContent)})}function m(p){if(!p.mockRequires||typeof p.mockRequires!="object"||Array.isArray(p.mockRequires))throw new Error("preflightMaterializeCandidateCard requires mockRequires");if(!p.mockFetchedSources||typeof p.mockFetchedSources!="object"||Array.isArray(p.mockFetchedSources))throw new Error("preflightMaterializeCandidateCard requires mockFetchedSources");let h=r.evalCardCompute({body:{"card-content":p.candidateCardContent,"mock-requires":p.mockRequires,"mock-fetched-sources":p.mockFetchedSources}});if(h.status!=="success")return h;let R=B(py(h,"evalCardCompute")),E=B(p.candidateCardContent),A={card_data:B(E.card_data),requires:B(p.mockRequires),fetched_sources:B(p.mockFetchedSources),computed_values:B(R.computed_values)};return {status:"success",data:{cardId:typeof R.cardId=="string"?R.cardId:typeof E.id=="string"?E.id:"(unknown)",ok:R.ok===true,computed_values:B(R.computed_values),errors:we(R.errors).map(T=>{let V=B(T);return {bindTo:typeof V.bindTo=="string"?V.bindTo:"",error:typeof V.error=="string"?V.error:""}}),provides_outputs:rd(E,A),rendered_view:aa(E,A)}}}function b(p){return r.probeSourcePreflight({params:{sourceIdx:p.sourceIdx},body:{"card-content":p.candidateCardContent,"mock-projections":p.mockProjections}})}function C(p){return r.runSourcePreflight({params:{sourceIdx:p.sourceIdx},body:{"card-content":p.candidateCardContent,"mock-projections":p.mockProjections}})}function q(p){let h=String(p.cardId||"").trim();if(!h)throw new Error("preflightRunSingleSourceInLiveCard requires cardId");if(!p.mockRequires||typeof p.mockRequires!="object"||Array.isArray(p.mockRequires))throw new Error("preflightRunSingleSourceInLiveCard requires mockRequires");let R=B(Kr(n,h)),E=we(R.source_defs).filter(T=>!!T&&typeof T=="object"&&!Array.isArray(T)),A={};if(p.sourceIdx>=0&&p.sourceIdx<E.length){let T=E[p.sourceIdx],V=ut.enrichSourcesSync([T],{card_data:B(R.card_data),requires:p.mockRequires});Array.isArray(V)&&V.length>0&&(A=B(V[0]._projections));}return r.runSourcePreflight({params:{sourceIdx:p.sourceIdx},body:{"card-content":R,"mock-requires":p.mockRequires,"mock-projections":A}})}function _(p){let h=B(_e(r.simulateCardCycle({body:{"card-content":p.candidateCardContent,"mock-requires":p.mockRequires}}),"simulateCardCycle")),R=B(p.candidateCardContent),E=B(h.validation),A=we(h.source_probes),T=we(h.projection_errors),V=B(h.fetched_sources),Q=we(h.compute_errors),te=B(h.computed_values),ue={card_data:B(R.card_data),requires:p.mockRequires,fetched_sources:V,computed_values:te},N=[];for(let F of we(E.issues))typeof F=="string"&&F&&N.push(F);for(let F of A){let U=B(F),ne=typeof U.bindTo=="string"?U.bindTo:"source",H=typeof U.error=="string"?U.error:"";H&&N.push(`${ne}: ${H}`);}for(let F of T){let U=B(F),ne=typeof U.bindTo=="string"?U.bindTo:"source",H=typeof U.key=="string"?U.key:"projection",be=typeof U.error=="string"?U.error:"projection failed";N.push(`${ne}.${H}: ${be}`);}for(let F of Q){let U=B(F),ne=typeof U.bindTo=="string"?U.bindTo:"compute",H=typeof U.error=="string"?U.error:"compute failed";N.push(`${ne}: ${H}`);}return {status:"success",data:{cardId:typeof h.cardId=="string"?h.cardId:"(unknown)",ok:h.ok===true,issues:N,provides_outputs:rd(R,ue),rendered_view:aa(R,ue)}}}function I(p){let h=String(p.cardId||"").trim();if(!h)throw new Error("manageReadCard requires cardId");let R=_e(n.get({params:{id:h}}),"cardStore.get");return Array.isArray(R.cards)?R.cards:[]}function S(p){let h=String(p.cardId||"").trim(),R=String(p.role||"").trim(),E=typeof p.text=="string"?p.text:"",A=typeof p.turn=="string"?p.turn:"";if(!h)throw new Error("manageAddChatEntryAndAnyAttachments requires cardId");if(!R)throw new Error("manageAddChatEntryAndAnyAttachments requires role");let T=we(p.files).map(Q=>{let te=B(Q),ue=String(te.file_name??te.fileName??te.name??"").trim(),N=String(te.content_type??te.contentType??"application/octet-stream");if(!ue)throw new Error("file entry requires file_name");return o({cardId:h,fileName:ue,contentType:N,bytes:u(te)}).file});T.forEach((Q,te)=>{let ue=R==="assistant"?`AI generated: ${String(Q.name||"")} as ${String(Q.stored_name||"")} #${te}`:`file uploaded: ${String(Q.name||"")} as ${String(Q.stored_name||"")} #${te}`;_e(s.append({params:{cardId:h},body:{role:"system",text:ue,files:[],turn:A}}),"chatStore.append(system attachment message)");});let V=_e(s.append({params:{cardId:h},body:{role:R,text:E,files:T,turn:A}}),"chatStore.append");return {status:"success",data:{cardId:h,id:String(V.id),role:R,turn:A,files:T}}}function k(p){let h=String(p.cardId||"").trim(),R=B(p.candidateCardContent);if(!h)throw new Error("manageUpsertCard requires cardId");if(typeof R.id!="string"||!R.id.trim())throw new Error("candidateCardContent.id must be a non-empty string");if(R.id!==h)throw new Error(`candidateCardContent.id must match cardId (${h})`);let E=f({candidateCardContent:R}),A=B(E),T=B(A.data);if(A.status!=="success"||T.isValid!==true)return {status:"fail",step:"validate",validation:E};let V=null;try{V=Kr(n,h);}catch{V=null;}let Q=n.set({body:R});_e(Q,"cardStore.set");let te;try{te=t.upsertCard({params:{cardId:h,restart:!0}}),_e(te,"upsertCard");}catch(N){try{V&&n.set({body:V});}catch{}throw N}let ue=null;try{ue=t.cardRefreshedNotify({params:{cardId:h}}),_e(ue,"cardRefreshedNotify");}catch{ue=null;}return {status:"success",data:{validation:E,card_saved:null,board_result:te,refresh_notify:ue}}}function w(p){let h=String(p.cardId||"").trim();if(!h)throw new Error("manageRemoveCard requires cardId");let R=t.removeCard({params:{id:h}});_e(R,"removeCard");let E=n.del({params:{id:h}});return _e(E,"cardStore.del"),{status:"success",data:{board_result:R,store_result:E}}}return {discoverSourceKinds:c,inspectBoardRuntimeStatus:d,inspectCardDefinitionAndRuntime:l,inspectChatMessagesOnCards:g,inspectFileContents:v,preflightValidateCandidateCardDefinition:f,preflightMaterializeCandidateCard:m,preflightProbeSingleSourceInCandidateCard:b,preflightRunSingleSourceInCandidateCard:C,preflightRunSingleSourceInLiveCard:q,preflightRunOneCycleWithCandidateCard:_,manageReadCard:I,manageAddChatEntryAndAnyAttachments:S,manageUpsertCard:k,manageRemoveCard:w}}function yy(e){function t(s){return {status:"success",data:s}}function r(s){return {status:"fail",error:s}}function n(s){return {status:"error",error:s instanceof Error?s.message:String(s)}}return {list(s){try{let o=s.params?.prefix??"";return t({artifacts:e.list(o)})}catch(o){return n(o)}},head(s){try{let o=s.params?.key;return o?t({artifact:e.head(o)}):r("head requires params.key")}catch(o){return n(o)}},put(s){try{let o=s.params?.key,a=s.params?.contentType;if(!o)return r("put requires params.key");let i=s.body;if(typeof i=="string")return t({artifact:e.putText(o,i,a)});if(i&&typeof i=="object"&&typeof i.text=="string")return t({artifact:e.putText(o,i.text,a)});if(i&&typeof i=="object"&&Array.isArray(i.bytes)){let u=i.bytes,c=new Uint8Array(u.map(d=>Math.max(0,Math.min(255,Number(d)||0))));return t({artifact:e.putBytes(o,c,a)})}return r("put requires body as string, {text}, or {bytes:number[]}")}catch(o){return n(o)}},get(s){try{let o=s.params?.key,a=s.params?.as??"base64";if(!o)return r("get requires params.key");let i=e.head(o);if(!i)return r(`artifact "${o}" not found`);if(a==="text"){let c=e.getText(o);return c===null?r(`artifact "${o}" not found`):t({key:o,contentType:i.contentType,size:i.size,text:c})}let u=e.getBytes(o);return u===null?r(`artifact "${o}" not found`):t({key:o,contentType:i.contentType,size:i.size,bytes:[...u]})}catch(o){return n(o)}},del(s){try{let o=s.params?.key;return o?(e.remove(o),t({ok:!0})):r("del requires params.key")}catch(o){return n(o)}}}}function nd(){return new Date().toISOString()}function sd(e){return new TextEncoder().encode(e).byteLength}function vy(e){return e?{key:e.key,size:e.size,updatedAt:e.updatedAt,contentType:e.contentType}:null}function Sy(e){let t=String(e||"").match(/^(\d+)[-_]/);return t?parseInt(t[1],10):0}function wy(e){let t=String(e||"").trim();if(!t)return "upload.bin";let r=Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\"));return (r>=0?t.slice(r+1):t)||"upload.bin"}function ky(e){return String(e||"").toLowerCase().replace(/\s+/g,"_").replace(/[^a-z0-9_-]/g,"_").replace(/_+/g,"_").replace(/^_+|_+$/g,"")||"file"}function by(e){if(!e||e===".")return "";let t=String(e).replace(/^\./,"").toLowerCase().replace(/[^a-z0-9]/g,"");return t?`.${t}`:""}function Ry(e){let t=wy(e),r=t.lastIndexOf(".");return r<=0||r===t.length-1?{stem:t,ext:""}:{stem:t.slice(0,r),ext:t.slice(r)}}function _y(e){let t=e.lastIndexOf("/");return t>=0?e.slice(t+1):e}function ca(e){function t(r){let n=e.stat?vy(e.stat(r)):null;if(n)return n;if(!e.exists(r))return null;let s=e.read(r);return s===null?{key:r}:{key:r,size:sd(s)}}return {exists(r){return e.exists(r)},putText(r,n,s="text/plain; charset=utf-8"){e.write(r,n);let o=t(r)??{key:r};return o.contentType=s,o.updatedAt=o.updatedAt??nd(),o.size=o.size??sd(n),o},putBytes(r,n,s="application/octet-stream"){if(e.writeBytes)e.writeBytes(r,n);else {let a=JSON.stringify({__kind:"bytes-array",data:[...n]});e.write(r,a);}let o=t(r)??{key:r};return o.contentType=s,o.updatedAt=o.updatedAt??nd(),o.size=o.size??n.byteLength,o},getText(r){let n=e.read(r);if(n===null){if(!e.readBytes)return null;let s=e.readBytes(r);return s===null?null:Buffer.from(s).toString("utf-8")}try{let s=JSON.parse(n);if(s&&s.__kind==="bytes-array"&&Array.isArray(s.data))return new TextDecoder("utf-8").decode(new Uint8Array(s.data))}catch{}return n},getBytes(r){if(e.readBytes){let s=e.readBytes(r);if(s!==null)return s}let n=e.read(r);if(n===null)return null;try{let s=JSON.parse(n);if(s&&s.__kind==="bytes-array"&&Array.isArray(s.data))return new Uint8Array(s.data)}catch{}return new TextEncoder().encode(n)},head:t,list(r=""){return e.listKeys(r).map(n=>t(n)??{key:n}).sort((n,s)=>n.key.localeCompare(s.key))},remove(r){e.remove(r);}}}function Cy(e){function t(s,o){let a=0,i=[];Array.isArray(o)&&i.push(...o);for(let u of e.list(`${s}/`))i.push(_y(u.key));for(let u of i){let c=Sy(u);Number.isFinite(c)&&c>a&&(a=c);}return a+1}function r(s,o,a){let i=Number(a?.maxLen||32),{stem:u,ext:c}=Ry(s),d=by(c),l=ky(u),g=`${String(o).padStart(3,"0")}-`,v=d,f=i-g.length-v.length;f<1&&(v="",f=i-g.length);let m=l.slice(0,Math.max(1,f)),b=`${g}${m}${v}`;return b.length>i&&(b=b.slice(0,i).replace(/\.$/,"")),b}function n(s,o,a){let i=t(s,a?.seedNames),u=r(o,i,{maxLen:a?.maxLen});for(;e.exists(`${s}/${u}`);)i+=1,u=r(o,i,{maxLen:a?.maxLen});return u}return {nextSerial:t,buildStoredName:r,allocateStoredName:n}}function $y(){function e(s,o){if(!Array.isArray(s))return [];let a=[];for(let i of s){if(!i||typeof i!="object")continue;let u=i;typeof u.stored_name=="string"&&a.push({name:typeof u.name=="string"?u.name:u.stored_name,stored_name:u.stored_name,size:typeof u.size=="number"&&Number.isFinite(u.size)?u.size:null,mime_type:typeof u.mime_type=="string"?u.mime_type:null,uploaded_at:typeof u.uploaded_at=="string"?u.uploaded_at:o||null,chat:u.chat===true});}return a}function t(s){return !s||typeof s!="object"?[]:e(s.files,void 0)}function r(s,o){let a=t(s);if(o.length===0)return s.files=a,a;let i=new Set(a.map(u=>u.stored_name));for(let u of o)i.has(u.stored_name)||(a.push(u),i.add(u.stored_name));return s.files=a,a}function n(s,o,a){let i=t(s);if(!Number.isInteger(o)||o<0||o>=i.length)return {ok:false,reason:"index_out_of_range"};let u=i[o];return !u||!u.stored_name?{ok:false,reason:"missing_stored_name"}:a&&a!==u.stored_name?{ok:false,reason:"stale_reference"}:{ok:true,file:u}}return {read:t,normalizeIncoming:e,merge:r,resolve:n}}function bw(){return {async invoke(e,t){if(e.howToRun!=="local-node")return {dispatched:false,error:`createNodeSpawnInvocationAdapter: unsupported howToRun "${e.howToRun}"`};let r="";try{let o=e.whatToRun;r=et(o);}catch{r="";}if(!r)return {dispatched:false,error:"createNodeSpawnInvocationAdapter: could not resolve executable path from whatToRun"};let n={...t},s=Buffer.from(JSON.stringify(n)).toString("base64");try{return child_process.spawn(process.execPath,[r,"--boardId",String(t.boardId??""),"--cardId",String(t.cardId??""),"--extraEncJson",s],{stdio:"ignore",windowsHide:!0}).unref(),{dispatched:!0}}catch(o){return {dispatched:false,error:o instanceof Error?o.message:String(o)}}},async describe(e){if(e.howToRun!=="local-node")return null;let t="";try{let r=e.whatToRun;t=et(r);}catch{t="";}if(!t)return null;try{let r=child_process.spawnSync(process.execPath,[t,"describe"],{timeout:5e3,encoding:"utf-8",windowsHide:!0});return r.status!==0?null:JSON.parse(String(r.stdout).trim())}catch{return null}}}}var Ay=".board.lock";function od(e,t){if(!e||!t)return false;let r=String(e).replace(/[\\/]+$/,"").split(/[\\/]+/).filter(Boolean);return r.length>0&&r[r.length-1]===t}function Ty(e,t){return typeof e=="string"?{cliDir:e,opts:t}:{cliDir:void 0,opts:e}}function Iy(e,t){return typeof e=="string"?{cliDir:e,opts:t}:{cliDir:void 0,opts:e}}function ad(e){if(e)return e;let t=wa((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('board-live-cards-node.cjs', document.baseURI).href))),r=[t,qe(t,"..","cli","node"),qe(t,"..","..","cli","node")];for(let n of r)try{return rs(n),n}catch{}throw new Error(`createFsBoardPlatformAdapter: could not resolve a public CLI directory from module dir ${t}`)}function jy(e,t,r){let{cliDir:n,opts:s}=Ty(t,r),o=ad(n),a=e.value,u={meta:"board-live-cards",howToRun:"local-node",whatToRun:(s?.suppressSpawn?"":rs(o))?pe({kind:"yaml-flow-cli",value:"board-live-cards-cli.js"}):"",...s?.notifyChannel?{extra:{notifyChannel:s.notifyChannel}}:{}};return {kvStorage:c=>nn(qe(a,`.${c}`)),blobStorage:c=>c?Wt(qe(a,c)):Wt(a),scratchStorage:()=>tn(qe(a,".tmp")),scratchStorageForRef:c=>tn(Qe(c).value),archiveFactory:()=>rn(qe(a,"archive")),archiveFactoryForRef:c=>rn(Qe(c).value),journalAdapter:()=>Ma(a),lock:Da(qe(a,Ay)),selfRef:u,async dispatchExecution(c,d){if(s?.suppressSpawn)return {dispatched:false};try{let l=d.source_def?.bindTo??Zn().slice(0,8),g=tn(qe(a,".tmp")),v=g.create(JSON.stringify(d,null,2),`exec-in-${l}`,".json"),f=g.getUniqueKey(`exec-out-${l}`,".json"),m=g.getUniqueKey(`exec-err-${l}`,".txt"),b=pe(g.keyRef(v)),C=pe(g.keyRef(f)),q=pe(g.keyRef(m));return Pa(c,{subcommand:"run-source-fetch",inRef:b,outRef:C,errRef:q},o),{dispatched:!0}}catch(l){let g=l instanceof Error?l.message:String(l);try{let v=rn(qe(a,"archive")),f=new Date().toISOString().replace(/[:.]/g,"-"),m=d.source_def?.bindTo??"unknown";v.blob("exec-failures").write(`${f}-${m}.json`,JSON.stringify({error:g,args:d,ref:c,at:new Date().toISOString()},null,2));}catch{}return {dispatched:false,error:g}}},resolveBlob(c){let d=va(c.value)?us().read(c.value):Wt(a).read(c.value);if(d===null)throw new Error(`resolveBlob: blob not found: ::${c.kind}::${c.value}`);return d},hashFn:Fa,genId:()=>Sa(`${Date.now()}-${Math.random()}`).slice(0,32),kvStorageForRef:c=>nn(Qe(c).value),requestProcessAccumulated(){s?.suppressSpawn||Ra(o,e,s?.notifyChannel);},publishBoardChangeNotifications(c){if(!s?.notifyChannel||c.length===0)return;let d=c.map(l=>({id:Zn(),ts:new Date().toISOString(),boardRef:pe(e),notification:l}));_a(s.notifyChannel,d,s.onWarn);},onWarn:s?.onWarn}}function Rw(e,t,r){let{cliDir:n,opts:s}=Iy(t,r),o=ad(n),a=jy(e,o,s),i=Xr();return {...a,invokeExecutorSync(u,c,d,l){let{command:g,baseArgs:v}=Qr(u,o),f=u.extra?["--extra",Buffer.from(JSON.stringify(u.extra)).toString("base64")]:[];return i.executeSync(g,[...v,c,...d,...f],{timeout:l?.timeout??3e4,encoding:"utf-8",input:l?.input})},validateSchema(u){let c=Xo(u);return {ok:c.errors.length===0,errors:c.errors}},absoluteBlob:us()}}function _w(e,t={}){let r=t.chatsSubdir??"chats",n=t.kvSubdir??".kv",s=n?[n,"chat"]:["chat"],o=r&&!od(e,r)?qe(e,r):e,a=nn(qe(e,...s));return Qo(i=>{let c=`${String(i).replace(/[^a-zA-Z0-9_-]/g,"_")}.jsonl`,d=qe(o,c);return ds(d)},a)}function Cw(e,t={}){let r=t.filesSubdir??"files",n=r&&!od(e,r)?qe(e,r):e;return ca(Wt(n))}function $w(e){try{let t=JSON.parse(Buffer.from(e,"base64url").toString());return typeof t.br=="string"?t.br:null}catch{return null}}
19
+ exports.BOARD_GRAPH_KEY=xt;exports.EMPTY_CONFIG=zn;exports.SNAPSHOT_SCHEMA_VERSION_V1=Ur;exports.buildLocalBaseSpec=Qr;exports.createArtifactsStore=ca;exports.createArtifactsStorePublic=yy;exports.createBoardLiveCardsMcp=hy;exports.createBoardLiveCardsNonCorePublic=fy;exports.createBoardLiveCardsPublic=ly;exports.createCardFileMetadataStore=$y;exports.createCardStore=Kn;exports.createCardStorePublic=oa;exports.createChatStorage=Qo;exports.createExecutionRefInvoker=Bd;exports.createFileArtifactsStore=Cy;exports.createFsBoardChatStorage=_w;exports.createFsBoardFileArtifactsStore=Cw;exports.createFsBoardNonCorePlatformAdapter=Rw;exports.createFsBoardPlatformAdapter=jy;exports.createInMemoryChatStorage=Ph;exports.createNodeSpawnInvocationAdapter=bw;exports.decodeBoardRefFromToken=$w;exports.evaluateArgsMassaging=ss;exports.executionRefFromScriptPath=sy;exports.invokeExecutionRef=Oa;exports.invokeExecutionRefSync=os;exports.invokeRefSync=Vd;exports.parseExecutionRef=na;exports.parseRef=Qe;exports.resolveWhatToRunValue=et;exports.resolveYamlFlowCliPath=xa;exports.serializeExecutionRef=ra;exports.serializeRef=pe;//# sourceMappingURL=board-live-cards-node.cjs.map
20
20
  //# sourceMappingURL=board-live-cards-node.cjs.map