yaml-flow 8.2.4 → 8.2.5

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,16 +1,16 @@
1
- 'use strict';var child_process=require('child_process'),T=require('fs'),Tn=require('os'),ie=require('path'),Ko=require('net'),url=require('url'),crypto=require('crypto'),module$1=require('module'),properLockfile=require('proper-lockfile'),Bg=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 T__namespace=/*#__PURE__*/_interopNamespace(T);var Tn__namespace=/*#__PURE__*/_interopNamespace(Tn);var ie__namespace=/*#__PURE__*/_interopNamespace(ie);var Ko__namespace=/*#__PURE__*/_interopNamespace(Ko);var Bg__default=/*#__PURE__*/_interopDefault(Bg);var jc=Object.create;var Lo=Object.defineProperty;var Nc=Object.getOwnPropertyDescriptor;var qc=Object.getOwnPropertyNames;var Dc=Object.getPrototypeOf,Fc=Object.prototype.hasOwnProperty;var x=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Mc=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of qc(t))!Fc.call(e,s)&&s!==r&&Lo(e,s,{get:()=>t[s],enumerable:!(n=Nc(t,s))||n.enumerable});return e};var Lc=(e,t,r)=>(r=e!=null?jc(Dc(e)):{},Mc(Lo(r,"default",{value:e,enumerable:true}),e));var Qt=x(W=>{Object.defineProperty(W,"__esModule",{value:true});W.regexpCode=W.getEsmExportName=W.getProperty=W.safeStringify=W.stringify=W.strConcat=W.addCodeArg=W.str=W._=W.nil=W._Code=W.Name=W.IDENTIFIER=W._CodeOrName=void 0;var Yt=class{};W._CodeOrName=Yt;W.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var gt=class extends Yt{constructor(t){if(super(),!W.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}}};W.Name=gt;var Ee=class extends Yt{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 gt&&(r[n.str]=(r[n.str]||0)+1),r),{})}};W._Code=Ee;W.nil=new Ee("");function ma(e,...t){let r=[e[0]],n=0;for(;n<t.length;)Bn(r,t[n]),r.push(e[++n]);return new Ee(r)}W._=ma;var Vn=new Ee("+");function ga(e,...t){let r=[Xt(e[0])],n=0;for(;n<t.length;)r.push(Vn),Bn(r,t[n]),r.push(Vn,Xt(e[++n]));return gd(r),new Ee(r)}W.str=ga;function Bn(e,t){t instanceof Ee?e.push(...t._items):t instanceof gt?e.push(t):e.push(vd(t));}W.addCodeArg=Bn;function gd(e){let t=1;for(;t<e.length-1;){if(e[t]===Vn){let r=hd(e[t-1],e[t+1]);if(r!==void 0){e.splice(t-1,3,r);continue}e[t++]="+";}t++;}}function hd(e,t){if(t==='""')return e;if(e==='""')return t;if(typeof e=="string")return t instanceof gt||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 gt))return `"${e}${t.slice(1)}`}function yd(e,t){return t.emptyStr()?e:e.emptyStr()?t:ga`${e}${t}`}W.strConcat=yd;function vd(e){return typeof e=="number"||typeof e=="boolean"||e===null?e:Xt(Array.isArray(e)?e.join(","):e)}function bd(e){return new Ee(Xt(e))}W.stringify=bd;function Xt(e){return JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}W.safeStringify=Xt;function kd(e){return typeof e=="string"&&W.IDENTIFIER.test(e)?new Ee(`.${e}`):ma`[${e}]`}W.getProperty=kd;function wd(e){if(typeof e=="string"&&W.IDENTIFIER.test(e))return new Ee(`${e}`);throw new Error(`CodeGen: invalid export name: ${e}, use explicit $id name mapping`)}W.getEsmExportName=wd;function Sd(e){return new Ee(e.toString())}W.regexpCode=Sd;});var Un=x(ve=>{Object.defineProperty(ve,"__esModule",{value:true});ve.ValueScope=ve.ValueScopeName=ve.Scope=ve.varKinds=ve.UsedValueState=void 0;var ye=Qt(),Gn=class extends Error{constructor(t){super(`CodeGen: "code" for ${t} not defined`),this.value=t.value;}},Dr;(function(e){e[e.Started=0]="Started",e[e.Completed=1]="Completed";})(Dr||(ve.UsedValueState=Dr={}));ve.varKinds={const:new ye.Name("const"),let:new ye.Name("let"),var:new ye.Name("var")};var Fr=class{constructor({prefixes:t,parent:r}={}){this._names={},this._prefixes=t,this._parent=r;}toName(t){return t instanceof ye.Name?t:this.name(t)}name(t){return new ye.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}}};ve.Scope=Fr;var Mr=class extends ye.Name{constructor(t,r){super(r),this.prefix=t;}setValue(t,{property:r,itemIndex:n}){this.value=t,this.scopePath=(0, ye._)`.${new ye.Name(r)}[${n}]`;}};ve.ValueScopeName=Mr;var _d=(0, ye._)`\n`,Kn=class extends Fr{constructor(t){super(t),this._values={},this._scope=t.scope,this.opts={...t,_n:t.lines?_d:ye.nil};}get(){return this._scope}name(t){return new Mr(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, ye._)`${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=ye.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,Dr.Started);let d=r(c);if(d){let l=this.opts.es5?ve.varKinds.var:ve.varKinds.const;o=(0, ye._)`${o}${l} ${c} = ${d};${this.opts._n}`;}else if(d=s?.(c))o=(0, ye._)`${o}${d}${this.opts._n}`;else throw new Gn(c);u.set(c,Dr.Completed);});}return o}};ve.ValueScope=Kn;});var B=x(V=>{Object.defineProperty(V,"__esModule",{value:true});V.or=V.and=V.not=V.CodeGen=V.operators=V.varKinds=V.ValueScopeName=V.ValueScope=V.Scope=V.Name=V.regexpCode=V.stringify=V.getProperty=V.nil=V.strConcat=V.str=V._=void 0;var J=Qt(),Ie=Un(),Ze=Qt();Object.defineProperty(V,"_",{enumerable:true,get:function(){return Ze._}});Object.defineProperty(V,"str",{enumerable:true,get:function(){return Ze.str}});Object.defineProperty(V,"strConcat",{enumerable:true,get:function(){return Ze.strConcat}});Object.defineProperty(V,"nil",{enumerable:true,get:function(){return Ze.nil}});Object.defineProperty(V,"getProperty",{enumerable:true,get:function(){return Ze.getProperty}});Object.defineProperty(V,"stringify",{enumerable:true,get:function(){return Ze.stringify}});Object.defineProperty(V,"regexpCode",{enumerable:true,get:function(){return Ze.regexpCode}});Object.defineProperty(V,"Name",{enumerable:true,get:function(){return Ze.Name}});var Gr=Un();Object.defineProperty(V,"Scope",{enumerable:true,get:function(){return Gr.Scope}});Object.defineProperty(V,"ValueScope",{enumerable:true,get:function(){return Gr.ValueScope}});Object.defineProperty(V,"ValueScopeName",{enumerable:true,get:function(){return Gr.ValueScopeName}});Object.defineProperty(V,"varKinds",{enumerable:true,get:function(){return Gr.varKinds}});V.operators={GT:new J._Code(">"),GTE:new J._Code(">="),LT:new J._Code("<"),LTE:new J._Code("<="),EQ:new J._Code("==="),NEQ:new J._Code("!=="),NOT:new J._Code("!"),OR:new J._Code("||"),AND:new J._Code("&&"),ADD:new J._Code("+")};var Be=class{optimizeNodes(){return this}optimizeNames(t,r){return this}},Jn=class extends Be{constructor(t,r,n){super(),this.varKind=t,this.name=r,this.rhs=n;}render({es5:t,_n:r}){let n=t?Ie.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=At(this.rhs,t,r)),this}get names(){return this.rhs instanceof J._CodeOrName?this.rhs.names:{}}},Lr=class extends Be{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 J.Name&&!t[this.lhs.str]&&!this.sideEffects))return this.rhs=At(this.rhs,t,r),this}get names(){let t=this.lhs instanceof J.Name?{}:{...this.lhs.names};return Br(t,this.rhs)}},zn=class extends Lr{constructor(t,r,n,s){super(t,n,s),this.op=r;}render({_n:t}){return `${this.lhs} ${this.op}= ${this.rhs};`+t}},Hn=class extends Be{constructor(t){super(),this.label=t,this.names={};}render({_n:t}){return `${this.label}:`+t}},Wn=class extends Be{constructor(t){super(),this.label=t,this.names={};}render({_n:t}){return `break${this.label?` ${this.label}`:""};`+t}},Yn=class extends Be{constructor(t){super(),this.error=t;}render({_n:t}){return `throw ${this.error};`+t}get names(){return this.error.names}},Xn=class extends Be{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=At(this.code,t,r),this}get names(){return this.code instanceof J._CodeOrName?this.code.names:{}}},Zt=class extends Be{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)||(Rd(t,o.names),n.splice(s,1));}return n.length>0?this:void 0}get names(){return this.nodes.reduce((t,r)=>vt(t,r.names),{})}},Ge=class extends Zt{render(t){return "{"+t._n+super.render(t)+"}"+t._n}},Qn=class extends Zt{},Tt=class extends Ge{};Tt.kind="else";var ht=class e extends Ge{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 Tt(n):n;}if(r)return t===false?r instanceof e?r:r.nodes:this.nodes.length?this:new e(ha(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=At(this.condition,t,r),this}get names(){let t=super.names;return Br(t,this.condition),this.else&&vt(t,this.else.names),t}};ht.kind="if";var yt=class extends Ge{};yt.kind="for";var Zn=class extends yt{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=At(this.iteration,t,r),this}get names(){return vt(super.names,this.iteration.names)}},es=class extends yt{constructor(t,r,n,s){super(),this.varKind=t,this.name=r,this.from=n,this.to=s;}render(t){let r=t.es5?Ie.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=Br(super.names,this.from);return Br(t,this.to)}},Vr=class extends yt{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=At(this.iterable,t,r),this}get names(){return vt(super.names,this.iterable.names)}},er=class extends Ge{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)}};er.kind="func";var tr=class extends Zt{render(t){return "return "+super.render(t)}};tr.kind="return";var ts=class extends Ge{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&&vt(t,this.catch.names),this.finally&&vt(t,this.finally.names),t}},rr=class extends Ge{constructor(t){super(),this.error=t;}render(t){return `catch(${this.error})`+super.render(t)}};rr.kind="catch";var nr=class extends Ge{render(t){return "finally"+super.render(t)}};nr.kind="finally";var rs=class{constructor(t,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
2
- `:""},this._extScope=t,this._scope=new Ie.Scope({parent:t}),this._nodes=[new Qn];}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 Jn(t,o,n)),o}const(t,r,n){return this._def(Ie.varKinds.const,t,r,n)}let(t,r,n){return this._def(Ie.varKinds.let,t,r,n)}var(t,r,n){return this._def(Ie.varKinds.var,t,r,n)}assign(t,r,n){return this._leafNode(new Lr(t,r,n))}add(t,r){return this._leafNode(new zn(t,V.operators.ADD,r))}code(t){return typeof t=="function"?t():t!==J.nil&&this._leafNode(new Xn(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, J.addCodeArg)(r,s));return r.push("}"),new J._Code(r)}if(t,r,n){if(this._blockNode(new ht(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 ht(t))}else(){return this._elseNode(new Tt)}endIf(){return this._endBlockNode(ht,Tt)}_for(t,r){return this._blockNode(t),r&&this.code(r).endFor(),this}for(t,r){return this._for(new Zn(t),r)}forRange(t,r,n,s,o=this.opts.es5?Ie.varKinds.var:Ie.varKinds.let){let a=this._scope.toName(t);return this._for(new es(o,a,r,n),()=>s(a))}forOf(t,r,n,s=Ie.varKinds.const){let o=this._scope.toName(t);if(this.opts.es5){let a=r instanceof J.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0, J._)`${a}.length`,i=>{this.var(o,(0, J._)`${a}[${i}]`),n(o);})}return this._for(new Vr("of",s,o,r),()=>n(o))}forIn(t,r,n,s=this.opts.es5?Ie.varKinds.var:Ie.varKinds.const){if(this.opts.ownProperties)return this.forOf(t,(0, J._)`Object.keys(${r})`,n);let o=this._scope.toName(t);return this._for(new Vr("in",s,o,r),()=>n(o))}endFor(){return this._endBlockNode(yt)}label(t){return this._leafNode(new Hn(t))}break(t){return this._leafNode(new Wn(t))}return(t){let r=new tr;if(this._blockNode(r),this.code(t),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(tr)}try(t,r,n){if(!r&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let s=new ts;if(this._blockNode(s),this.code(t),r){let o=this.name("e");this._currNode=s.catch=new rr(o),r(o);}return n&&(this._currNode=s.finally=new nr,this.code(n)),this._endBlockNode(rr,nr)}throw(t){return this._leafNode(new Yn(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=J.nil,n,s){return this._blockNode(new er(t,r,n)),s&&this.code(s).endFunc(),this}endFunc(){return this._endBlockNode(er)}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 ht))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;}};V.CodeGen=rs;function vt(e,t){for(let r in t)e[r]=(e[r]||0)+(t[r]||0);return e}function Br(e,t){return t instanceof J._CodeOrName?vt(e,t.names):e}function At(e,t,r){if(e instanceof J.Name)return n(e);if(!s(e))return e;return new J._Code(e._items.reduce((o,a)=>(a instanceof J.Name&&(a=n(a)),a instanceof J._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 J._Code&&o._items.some(a=>a instanceof J.Name&&t[a.str]===1&&r[a.str]!==void 0)}}function Rd(e,t){for(let r in t)e[r]=(e[r]||0)-(t[r]||0);}function ha(e){return typeof e=="boolean"||typeof e=="number"||e===null?!e:(0, J._)`!${ns(e)}`}V.not=ha;var Cd=ya(V.operators.AND);function $d(...e){return e.reduce(Cd)}V.and=$d;var Ed=ya(V.operators.OR);function xd(...e){return e.reduce(Ed)}V.or=xd;function ya(e){return (t,r)=>t===J.nil?r:r===J.nil?t:(0, J._)`${ns(t)} ${e} ${ns(r)}`}function ns(e){return e instanceof J.Name?e:(0, J._)`(${e})`}});var z=x(G=>{Object.defineProperty(G,"__esModule",{value:true});G.checkStrictMode=G.getErrorPath=G.Type=G.useFunc=G.setEvaluated=G.evaluatedPropsToName=G.mergeEvaluated=G.eachItem=G.unescapeJsonPointer=G.escapeJsonPointer=G.escapeFragment=G.unescapeFragment=G.schemaRefOrVal=G.schemaHasRulesButRef=G.schemaHasRules=G.checkUnknownRules=G.alwaysValidSchema=G.toHash=void 0;var Q=B(),Td=Qt();function Ad(e){let t={};for(let r of e)t[r]=true;return t}G.toHash=Ad;function Id(e,t){return typeof t=="boolean"?t:Object.keys(t).length===0?true:(ka(e,t),!wa(t,e.self.RULES.all))}G.alwaysValidSchema=Id;function ka(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]||Ra(e,`unknown keyword: "${o}"`);}G.checkUnknownRules=ka;function wa(e,t){if(typeof e=="boolean")return !e;for(let r in e)if(t[r])return true;return false}G.schemaHasRules=wa;function Pd(e,t){if(typeof e=="boolean")return !e;for(let r in e)if(r!=="$ref"&&t.all[r])return true;return false}G.schemaHasRulesButRef=Pd;function Od({topSchemaRef:e,schemaPath:t},r,n,s){if(!s){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return (0, Q._)`${r}`}return (0, Q._)`${e}${t}${(0, Q.getProperty)(n)}`}G.schemaRefOrVal=Od;function jd(e){return Sa(decodeURIComponent(e))}G.unescapeFragment=jd;function Nd(e){return encodeURIComponent(os(e))}G.escapeFragment=Nd;function os(e){return typeof e=="number"?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}G.escapeJsonPointer=os;function Sa(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}G.unescapeJsonPointer=Sa;function qd(e,t){if(Array.isArray(e))for(let r of e)t(r);else t(e);}G.eachItem=qd;function va({mergeNames:e,mergeToName:t,mergeValues:r,resultToName:n}){return (s,o,a,i)=>{let u=a===void 0?o:a instanceof Q.Name?(o instanceof Q.Name?e(s,o,a):t(s,o,a),a):o instanceof Q.Name?(t(s,a,o),o):r(o,a);return i===Q.Name&&!(u instanceof Q.Name)?n(s,u):u}}G.mergeEvaluated={props:va({mergeNames:(e,t,r)=>e.if((0, Q._)`${r} !== true && ${t} !== undefined`,()=>{e.if((0, Q._)`${t} === true`,()=>e.assign(r,true),()=>e.assign(r,(0, Q._)`${r} || {}`).code((0, Q._)`Object.assign(${r}, ${t})`));}),mergeToName:(e,t,r)=>e.if((0, Q._)`${r} !== true`,()=>{t===true?e.assign(r,true):(e.assign(r,(0, Q._)`${r} || {}`),as(e,r,t));}),mergeValues:(e,t)=>e===true?true:{...e,...t},resultToName:_a}),items:va({mergeNames:(e,t,r)=>e.if((0, Q._)`${r} !== true && ${t} !== undefined`,()=>e.assign(r,(0, Q._)`${t} === true ? true : ${r} > ${t} ? ${r} : ${t}`)),mergeToName:(e,t,r)=>e.if((0, Q._)`${r} !== true`,()=>e.assign(r,t===true?true:(0, Q._)`${r} > ${t} ? ${r} : ${t}`)),mergeValues:(e,t)=>e===true?true:Math.max(e,t),resultToName:(e,t)=>e.var("items",t)})};function _a(e,t){if(t===true)return e.var("props",true);let r=e.var("props",(0, Q._)`{}`);return t!==void 0&&as(e,r,t),r}G.evaluatedPropsToName=_a;function as(e,t,r){Object.keys(r).forEach(n=>e.assign((0, Q._)`${t}${(0, Q.getProperty)(n)}`,true));}G.setEvaluated=as;var ba={};function Dd(e,t){return e.scopeValue("func",{ref:t,code:ba[t.code]||(ba[t.code]=new Td._Code(t.code))})}G.useFunc=Dd;var ss;(function(e){e[e.Num=0]="Num",e[e.Str=1]="Str";})(ss||(G.Type=ss={}));function Fd(e,t,r){if(e instanceof Q.Name){let n=t===ss.Num;return r?n?(0, Q._)`"[" + ${e} + "]"`:(0, Q._)`"['" + ${e} + "']"`:n?(0, Q._)`"/" + ${e}`:(0, Q._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0, Q.getProperty)(e).toString():"/"+os(e)}G.getErrorPath=Fd;function Ra(e,t,r=e.opts.strictSchema){if(r){if(t=`strict mode: ${t}`,r===true)throw new Error(t);e.self.logger.warn(t);}}G.checkStrictMode=Ra;});var Ke=x(is=>{Object.defineProperty(is,"__esModule",{value:true});var fe=B(),Md={data:new fe.Name("data"),valCxt:new fe.Name("valCxt"),instancePath:new fe.Name("instancePath"),parentData:new fe.Name("parentData"),parentDataProperty:new fe.Name("parentDataProperty"),rootData:new fe.Name("rootData"),dynamicAnchors:new fe.Name("dynamicAnchors"),vErrors:new fe.Name("vErrors"),errors:new fe.Name("errors"),this:new fe.Name("this"),self:new fe.Name("self"),scope:new fe.Name("scope"),json:new fe.Name("json"),jsonPos:new fe.Name("jsonPos"),jsonLen:new fe.Name("jsonLen"),jsonPart:new fe.Name("jsonPart")};is.default=Md;});var sr=x(pe=>{Object.defineProperty(pe,"__esModule",{value:true});pe.extendErrors=pe.resetErrorsCount=pe.reportExtraError=pe.reportError=pe.keyword$DataError=pe.keywordError=void 0;var H=B(),Kr=z(),ge=Ke();pe.keywordError={message:({keyword:e})=>(0, H.str)`must pass "${e}" keyword validation`};pe.keyword$DataError={message:({keyword:e,schemaType:t})=>t?(0, H.str)`"${e}" keyword must be ${t} ($data)`:(0, H.str)`"${e}" keyword is invalid ($data)`};function Ld(e,t=pe.keywordError,r,n){let{it:s}=e,{gen:o,compositeRule:a,allErrors:i}=s,u=Ea(e,t,r);n??(a||i)?Ca(o,u):$a(s,(0, H._)`[${u}]`);}pe.reportError=Ld;function Vd(e,t=pe.keywordError,r){let{it:n}=e,{gen:s,compositeRule:o,allErrors:a}=n,i=Ea(e,t,r);Ca(s,i),o||a||$a(n,ge.default.vErrors);}pe.reportExtraError=Vd;function Bd(e,t){e.assign(ge.default.errors,t),e.if((0, H._)`${ge.default.vErrors} !== null`,()=>e.if(t,()=>e.assign((0, H._)`${ge.default.vErrors}.length`,t),()=>e.assign(ge.default.vErrors,null)));}pe.resetErrorsCount=Bd;function Gd({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,ge.default.errors,i=>{e.const(a,(0, H._)`${ge.default.vErrors}[${i}]`),e.if((0, H._)`${a}.instancePath === undefined`,()=>e.assign((0, H._)`${a}.instancePath`,(0, H.strConcat)(ge.default.instancePath,o.errorPath))),e.assign((0, H._)`${a}.schemaPath`,(0, H.str)`${o.errSchemaPath}/${t}`),o.opts.verbose&&(e.assign((0, H._)`${a}.schema`,r),e.assign((0, H._)`${a}.data`,n));});}pe.extendErrors=Gd;function Ca(e,t){let r=e.const("err",t);e.if((0, H._)`${ge.default.vErrors} === null`,()=>e.assign(ge.default.vErrors,(0, H._)`[${r}]`),(0, H._)`${ge.default.vErrors}.push(${r})`),e.code((0, H._)`${ge.default.errors}++`);}function $a(e,t){let{gen:r,validateName:n,schemaEnv:s}=e;s.$async?r.throw((0, H._)`new ${e.ValidationError}(${t})`):(r.assign((0, H._)`${n}.errors`,t),r.return(false));}var bt={keyword:new H.Name("keyword"),schemaPath:new H.Name("schemaPath"),params:new H.Name("params"),propertyName:new H.Name("propertyName"),message:new H.Name("message"),schema:new H.Name("schema"),parentSchema:new H.Name("parentSchema")};function Ea(e,t,r){let{createErrors:n}=e.it;return n===false?(0, H._)`{}`:Kd(e,t,r)}function Kd(e,t,r={}){let{gen:n,it:s}=e,o=[Ud(s,r),Jd(e,r)];return zd(e,t,o),n.object(...o)}function Ud({errorPath:e},{instancePath:t}){let r=t?(0, H.str)`${e}${(0, Kr.getErrorPath)(t,Kr.Type.Str)}`:e;return [ge.default.instancePath,(0, H.strConcat)(ge.default.instancePath,r)]}function Jd({keyword:e,it:{errSchemaPath:t}},{schemaPath:r,parentSchema:n}){let s=n?t:(0, H.str)`${t}/${e}`;return r&&(s=(0, H.str)`${s}${(0, Kr.getErrorPath)(r,Kr.Type.Str)}`),[bt.schemaPath,s]}function zd(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([bt.keyword,s],[bt.params,typeof t=="function"?t(e):t||(0, H._)`{}`]),u.messages&&n.push([bt.message,typeof r=="function"?r(e):r]),u.verbose&&n.push([bt.schema,a],[bt.parentSchema,(0, H._)`${d}${l}`],[ge.default.data,o]),c&&n.push([bt.propertyName,c]);}});var Ta=x(It=>{Object.defineProperty(It,"__esModule",{value:true});It.boolOrEmptySchema=It.topBoolOrEmptySchema=void 0;var Hd=sr(),Wd=B(),Yd=Ke(),Xd={message:"boolean schema is false"};function Qd(e){let{gen:t,schema:r,validateName:n}=e;r===false?xa(e,false):typeof r=="object"&&r.$async===true?t.return(Yd.default.data):(t.assign((0, Wd._)`${n}.errors`,null),t.return(true));}It.topBoolOrEmptySchema=Qd;function Zd(e,t){let{gen:r,schema:n}=e;n===false?(r.var(t,false),xa(e)):r.var(t,true);}It.boolOrEmptySchema=Zd;function xa(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, Hd.reportError)(s,Xd,void 0,t);}});var us=x(Pt=>{Object.defineProperty(Pt,"__esModule",{value:true});Pt.getRules=Pt.isJSONType=void 0;var el=["string","number","integer","boolean","null","object","array"],tl=new Set(el);function rl(e){return typeof e=="string"&&tl.has(e)}Pt.isJSONType=rl;function nl(){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:{}}}Pt.getRules=nl;});var cs=x(et=>{Object.defineProperty(et,"__esModule",{value:true});et.shouldUseRule=et.shouldUseGroup=et.schemaHasRulesForType=void 0;function sl({schema:e,self:t},r){let n=t.RULES.types[r];return n&&n!==true&&Aa(e,n)}et.schemaHasRulesForType=sl;function Aa(e,t){return t.rules.some(r=>Ia(e,r))}et.shouldUseGroup=Aa;function Ia(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))}et.shouldUseRule=Ia;});var or=x(me=>{Object.defineProperty(me,"__esModule",{value:true});me.reportTypeError=me.checkDataTypes=me.checkDataType=me.coerceAndCheckDataType=me.getJSONTypes=me.getSchemaTypes=me.DataType=void 0;var ol=us(),al=cs(),il=sr(),L=B(),Pa=z(),Ot;(function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong";})(Ot||(me.DataType=Ot={}));function ul(e){let t=Oa(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}me.getSchemaTypes=ul;function Oa(e){let t=Array.isArray(e)?e:e?[e]:[];if(t.every(ol.isJSONType))return t;throw new Error("type must be JSONType or JSONType[]: "+t.join(","))}me.getJSONTypes=Oa;function cl(e,t){let{gen:r,data:n,opts:s}=e,o=dl(t,s.coerceTypes),a=t.length>0&&!(o.length===0&&t.length===1&&(0, al.schemaHasRulesForType)(e,t[0]));if(a){let i=ls(t,n,s.strictNumbers,Ot.Wrong);r.if(i,()=>{o.length?ll(e,t,o):fs(e);});}return a}me.coerceAndCheckDataType=cl;var ja=new Set(["string","number","integer","boolean","null"]);function dl(e,t){return t?e.filter(r=>ja.has(r)||t==="array"&&r==="array"):[]}function ll(e,t,r){let{gen:n,data:s,opts:o}=e,a=n.let("dataType",(0, L._)`typeof ${s}`),i=n.let("coerced",(0, L._)`undefined`);o.coerceTypes==="array"&&n.if((0, L._)`${a} == 'object' && Array.isArray(${s}) && ${s}.length == 1`,()=>n.assign(s,(0, L._)`${s}[0]`).assign(a,(0, L._)`typeof ${s}`).if(ls(t,s,o.strictNumbers),()=>n.assign(i,s))),n.if((0, L._)`${i} !== undefined`);for(let c of r)(ja.has(c)||c==="array"&&o.coerceTypes==="array")&&u(c);n.else(),fs(e),n.endIf(),n.if((0, L._)`${i} !== undefined`,()=>{n.assign(s,i),fl(e,i);});function u(c){switch(c){case "string":n.elseIf((0, L._)`${a} == "number" || ${a} == "boolean"`).assign(i,(0, L._)`"" + ${s}`).elseIf((0, L._)`${s} === null`).assign(i,(0, L._)`""`);return;case "number":n.elseIf((0, L._)`${a} == "boolean" || ${s} === null
1
+ 'use strict';var child_process=require('child_process'),T=require('fs'),Tn=require('os'),ie=require('path'),Ko=require('net'),url=require('url'),crypto=require('crypto'),module$1=require('module'),properLockfile=require('proper-lockfile'),Gg=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 T__namespace=/*#__PURE__*/_interopNamespace(T);var Tn__namespace=/*#__PURE__*/_interopNamespace(Tn);var ie__namespace=/*#__PURE__*/_interopNamespace(ie);var Ko__namespace=/*#__PURE__*/_interopNamespace(Ko);var Gg__default=/*#__PURE__*/_interopDefault(Gg);var Nc=Object.create;var Lo=Object.defineProperty;var qc=Object.getOwnPropertyDescriptor;var Dc=Object.getOwnPropertyNames;var Fc=Object.getPrototypeOf,Mc=Object.prototype.hasOwnProperty;var x=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Lc=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Dc(t))!Mc.call(e,s)&&s!==r&&Lo(e,s,{get:()=>t[s],enumerable:!(n=qc(t,s))||n.enumerable});return e};var Vc=(e,t,r)=>(r=e!=null?Nc(Fc(e)):{},Lc(Lo(r,"default",{value:e,enumerable:true}),e));var Qt=x(W=>{Object.defineProperty(W,"__esModule",{value:true});W.regexpCode=W.getEsmExportName=W.getProperty=W.safeStringify=W.stringify=W.strConcat=W.addCodeArg=W.str=W._=W.nil=W._Code=W.Name=W.IDENTIFIER=W._CodeOrName=void 0;var Yt=class{};W._CodeOrName=Yt;W.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var gt=class extends Yt{constructor(t){if(super(),!W.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}}};W.Name=gt;var xe=class extends Yt{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 gt&&(r[n.str]=(r[n.str]||0)+1),r),{})}};W._Code=xe;W.nil=new xe("");function ma(e,...t){let r=[e[0]],n=0;for(;n<t.length;)Bn(r,t[n]),r.push(e[++n]);return new xe(r)}W._=ma;var Vn=new xe("+");function ga(e,...t){let r=[Xt(e[0])],n=0;for(;n<t.length;)r.push(Vn),Bn(r,t[n]),r.push(Vn,Xt(e[++n]));return hd(r),new xe(r)}W.str=ga;function Bn(e,t){t instanceof xe?e.push(...t._items):t instanceof gt?e.push(t):e.push(kd(t));}W.addCodeArg=Bn;function hd(e){let t=1;for(;t<e.length-1;){if(e[t]===Vn){let r=yd(e[t-1],e[t+1]);if(r!==void 0){e.splice(t-1,3,r);continue}e[t++]="+";}t++;}}function yd(e,t){if(t==='""')return e;if(e==='""')return t;if(typeof e=="string")return t instanceof gt||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 gt))return `"${e}${t.slice(1)}`}function vd(e,t){return t.emptyStr()?e:e.emptyStr()?t:ga`${e}${t}`}W.strConcat=vd;function kd(e){return typeof e=="number"||typeof e=="boolean"||e===null?e:Xt(Array.isArray(e)?e.join(","):e)}function bd(e){return new xe(Xt(e))}W.stringify=bd;function Xt(e){return JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}W.safeStringify=Xt;function Sd(e){return typeof e=="string"&&W.IDENTIFIER.test(e)?new xe(`.${e}`):ma`[${e}]`}W.getProperty=Sd;function wd(e){if(typeof e=="string"&&W.IDENTIFIER.test(e))return new xe(`${e}`);throw new Error(`CodeGen: invalid export name: ${e}, use explicit $id name mapping`)}W.getEsmExportName=wd;function _d(e){return new xe(e.toString())}W.regexpCode=_d;});var Un=x(ve=>{Object.defineProperty(ve,"__esModule",{value:true});ve.ValueScope=ve.ValueScopeName=ve.Scope=ve.varKinds=ve.UsedValueState=void 0;var ye=Qt(),Gn=class extends Error{constructor(t){super(`CodeGen: "code" for ${t} not defined`),this.value=t.value;}},Dr;(function(e){e[e.Started=0]="Started",e[e.Completed=1]="Completed";})(Dr||(ve.UsedValueState=Dr={}));ve.varKinds={const:new ye.Name("const"),let:new ye.Name("let"),var:new ye.Name("var")};var Fr=class{constructor({prefixes:t,parent:r}={}){this._names={},this._prefixes=t,this._parent=r;}toName(t){return t instanceof ye.Name?t:this.name(t)}name(t){return new ye.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}}};ve.Scope=Fr;var Mr=class extends ye.Name{constructor(t,r){super(r),this.prefix=t;}setValue(t,{property:r,itemIndex:n}){this.value=t,this.scopePath=(0, ye._)`.${new ye.Name(r)}[${n}]`;}};ve.ValueScopeName=Mr;var Rd=(0, ye._)`\n`,Kn=class extends Fr{constructor(t){super(t),this._values={},this._scope=t.scope,this.opts={...t,_n:t.lines?Rd:ye.nil};}get(){return this._scope}name(t){return new Mr(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, ye._)`${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=ye.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,Dr.Started);let d=r(c);if(d){let l=this.opts.es5?ve.varKinds.var:ve.varKinds.const;o=(0, ye._)`${o}${l} ${c} = ${d};${this.opts._n}`;}else if(d=s?.(c))o=(0, ye._)`${o}${d}${this.opts._n}`;else throw new Gn(c);u.set(c,Dr.Completed);});}return o}};ve.ValueScope=Kn;});var B=x(V=>{Object.defineProperty(V,"__esModule",{value:true});V.or=V.and=V.not=V.CodeGen=V.operators=V.varKinds=V.ValueScopeName=V.ValueScope=V.Scope=V.Name=V.regexpCode=V.stringify=V.getProperty=V.nil=V.strConcat=V.str=V._=void 0;var J=Qt(),Pe=Un(),Ze=Qt();Object.defineProperty(V,"_",{enumerable:true,get:function(){return Ze._}});Object.defineProperty(V,"str",{enumerable:true,get:function(){return Ze.str}});Object.defineProperty(V,"strConcat",{enumerable:true,get:function(){return Ze.strConcat}});Object.defineProperty(V,"nil",{enumerable:true,get:function(){return Ze.nil}});Object.defineProperty(V,"getProperty",{enumerable:true,get:function(){return Ze.getProperty}});Object.defineProperty(V,"stringify",{enumerable:true,get:function(){return Ze.stringify}});Object.defineProperty(V,"regexpCode",{enumerable:true,get:function(){return Ze.regexpCode}});Object.defineProperty(V,"Name",{enumerable:true,get:function(){return Ze.Name}});var Gr=Un();Object.defineProperty(V,"Scope",{enumerable:true,get:function(){return Gr.Scope}});Object.defineProperty(V,"ValueScope",{enumerable:true,get:function(){return Gr.ValueScope}});Object.defineProperty(V,"ValueScopeName",{enumerable:true,get:function(){return Gr.ValueScopeName}});Object.defineProperty(V,"varKinds",{enumerable:true,get:function(){return Gr.varKinds}});V.operators={GT:new J._Code(">"),GTE:new J._Code(">="),LT:new J._Code("<"),LTE:new J._Code("<="),EQ:new J._Code("==="),NEQ:new J._Code("!=="),NOT:new J._Code("!"),OR:new J._Code("||"),AND:new J._Code("&&"),ADD:new J._Code("+")};var Ve=class{optimizeNodes(){return this}optimizeNames(t,r){return this}},Jn=class extends Ve{constructor(t,r,n){super(),this.varKind=t,this.name=r,this.rhs=n;}render({es5:t,_n:r}){let n=t?Pe.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=At(this.rhs,t,r)),this}get names(){return this.rhs instanceof J._CodeOrName?this.rhs.names:{}}},Lr=class extends Ve{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 J.Name&&!t[this.lhs.str]&&!this.sideEffects))return this.rhs=At(this.rhs,t,r),this}get names(){let t=this.lhs instanceof J.Name?{}:{...this.lhs.names};return Br(t,this.rhs)}},zn=class extends Lr{constructor(t,r,n,s){super(t,n,s),this.op=r;}render({_n:t}){return `${this.lhs} ${this.op}= ${this.rhs};`+t}},Hn=class extends Ve{constructor(t){super(),this.label=t,this.names={};}render({_n:t}){return `${this.label}:`+t}},Wn=class extends Ve{constructor(t){super(),this.label=t,this.names={};}render({_n:t}){return `break${this.label?` ${this.label}`:""};`+t}},Yn=class extends Ve{constructor(t){super(),this.error=t;}render({_n:t}){return `throw ${this.error};`+t}get names(){return this.error.names}},Xn=class extends Ve{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=At(this.code,t,r),this}get names(){return this.code instanceof J._CodeOrName?this.code.names:{}}},Zt=class extends Ve{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)||(Cd(t,o.names),n.splice(s,1));}return n.length>0?this:void 0}get names(){return this.nodes.reduce((t,r)=>vt(t,r.names),{})}},Be=class extends Zt{render(t){return "{"+t._n+super.render(t)+"}"+t._n}},Qn=class extends Zt{},Tt=class extends Be{};Tt.kind="else";var ht=class e extends Be{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 Tt(n):n;}if(r)return t===false?r instanceof e?r:r.nodes:this.nodes.length?this:new e(ha(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=At(this.condition,t,r),this}get names(){let t=super.names;return Br(t,this.condition),this.else&&vt(t,this.else.names),t}};ht.kind="if";var yt=class extends Be{};yt.kind="for";var Zn=class extends yt{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=At(this.iteration,t,r),this}get names(){return vt(super.names,this.iteration.names)}},es=class extends yt{constructor(t,r,n,s){super(),this.varKind=t,this.name=r,this.from=n,this.to=s;}render(t){let r=t.es5?Pe.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=Br(super.names,this.from);return Br(t,this.to)}},Vr=class extends yt{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=At(this.iterable,t,r),this}get names(){return vt(super.names,this.iterable.names)}},er=class extends Be{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)}};er.kind="func";var tr=class extends Zt{render(t){return "return "+super.render(t)}};tr.kind="return";var ts=class extends Be{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&&vt(t,this.catch.names),this.finally&&vt(t,this.finally.names),t}},rr=class extends Be{constructor(t){super(),this.error=t;}render(t){return `catch(${this.error})`+super.render(t)}};rr.kind="catch";var nr=class extends Be{render(t){return "finally"+super.render(t)}};nr.kind="finally";var rs=class{constructor(t,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
2
+ `:""},this._extScope=t,this._scope=new Pe.Scope({parent:t}),this._nodes=[new Qn];}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 Jn(t,o,n)),o}const(t,r,n){return this._def(Pe.varKinds.const,t,r,n)}let(t,r,n){return this._def(Pe.varKinds.let,t,r,n)}var(t,r,n){return this._def(Pe.varKinds.var,t,r,n)}assign(t,r,n){return this._leafNode(new Lr(t,r,n))}add(t,r){return this._leafNode(new zn(t,V.operators.ADD,r))}code(t){return typeof t=="function"?t():t!==J.nil&&this._leafNode(new Xn(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, J.addCodeArg)(r,s));return r.push("}"),new J._Code(r)}if(t,r,n){if(this._blockNode(new ht(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 ht(t))}else(){return this._elseNode(new Tt)}endIf(){return this._endBlockNode(ht,Tt)}_for(t,r){return this._blockNode(t),r&&this.code(r).endFor(),this}for(t,r){return this._for(new Zn(t),r)}forRange(t,r,n,s,o=this.opts.es5?Pe.varKinds.var:Pe.varKinds.let){let a=this._scope.toName(t);return this._for(new es(o,a,r,n),()=>s(a))}forOf(t,r,n,s=Pe.varKinds.const){let o=this._scope.toName(t);if(this.opts.es5){let a=r instanceof J.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0, J._)`${a}.length`,i=>{this.var(o,(0, J._)`${a}[${i}]`),n(o);})}return this._for(new Vr("of",s,o,r),()=>n(o))}forIn(t,r,n,s=this.opts.es5?Pe.varKinds.var:Pe.varKinds.const){if(this.opts.ownProperties)return this.forOf(t,(0, J._)`Object.keys(${r})`,n);let o=this._scope.toName(t);return this._for(new Vr("in",s,o,r),()=>n(o))}endFor(){return this._endBlockNode(yt)}label(t){return this._leafNode(new Hn(t))}break(t){return this._leafNode(new Wn(t))}return(t){let r=new tr;if(this._blockNode(r),this.code(t),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(tr)}try(t,r,n){if(!r&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let s=new ts;if(this._blockNode(s),this.code(t),r){let o=this.name("e");this._currNode=s.catch=new rr(o),r(o);}return n&&(this._currNode=s.finally=new nr,this.code(n)),this._endBlockNode(rr,nr)}throw(t){return this._leafNode(new Yn(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=J.nil,n,s){return this._blockNode(new er(t,r,n)),s&&this.code(s).endFunc(),this}endFunc(){return this._endBlockNode(er)}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 ht))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;}};V.CodeGen=rs;function vt(e,t){for(let r in t)e[r]=(e[r]||0)+(t[r]||0);return e}function Br(e,t){return t instanceof J._CodeOrName?vt(e,t.names):e}function At(e,t,r){if(e instanceof J.Name)return n(e);if(!s(e))return e;return new J._Code(e._items.reduce((o,a)=>(a instanceof J.Name&&(a=n(a)),a instanceof J._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 J._Code&&o._items.some(a=>a instanceof J.Name&&t[a.str]===1&&r[a.str]!==void 0)}}function Cd(e,t){for(let r in t)e[r]=(e[r]||0)-(t[r]||0);}function ha(e){return typeof e=="boolean"||typeof e=="number"||e===null?!e:(0, J._)`!${ns(e)}`}V.not=ha;var $d=ya(V.operators.AND);function Ed(...e){return e.reduce($d)}V.and=Ed;var xd=ya(V.operators.OR);function Td(...e){return e.reduce(xd)}V.or=Td;function ya(e){return (t,r)=>t===J.nil?r:r===J.nil?t:(0, J._)`${ns(t)} ${e} ${ns(r)}`}function ns(e){return e instanceof J.Name?e:(0, J._)`(${e})`}});var z=x(G=>{Object.defineProperty(G,"__esModule",{value:true});G.checkStrictMode=G.getErrorPath=G.Type=G.useFunc=G.setEvaluated=G.evaluatedPropsToName=G.mergeEvaluated=G.eachItem=G.unescapeJsonPointer=G.escapeJsonPointer=G.escapeFragment=G.unescapeFragment=G.schemaRefOrVal=G.schemaHasRulesButRef=G.schemaHasRules=G.checkUnknownRules=G.alwaysValidSchema=G.toHash=void 0;var Q=B(),Ad=Qt();function Id(e){let t={};for(let r of e)t[r]=true;return t}G.toHash=Id;function Pd(e,t){return typeof t=="boolean"?t:Object.keys(t).length===0?true:(ba(e,t),!Sa(t,e.self.RULES.all))}G.alwaysValidSchema=Pd;function ba(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]||Ra(e,`unknown keyword: "${o}"`);}G.checkUnknownRules=ba;function Sa(e,t){if(typeof e=="boolean")return !e;for(let r in e)if(t[r])return true;return false}G.schemaHasRules=Sa;function Od(e,t){if(typeof e=="boolean")return !e;for(let r in e)if(r!=="$ref"&&t.all[r])return true;return false}G.schemaHasRulesButRef=Od;function jd({topSchemaRef:e,schemaPath:t},r,n,s){if(!s){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return (0, Q._)`${r}`}return (0, Q._)`${e}${t}${(0, Q.getProperty)(n)}`}G.schemaRefOrVal=jd;function Nd(e){return wa(decodeURIComponent(e))}G.unescapeFragment=Nd;function qd(e){return encodeURIComponent(os(e))}G.escapeFragment=qd;function os(e){return typeof e=="number"?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}G.escapeJsonPointer=os;function wa(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}G.unescapeJsonPointer=wa;function Dd(e,t){if(Array.isArray(e))for(let r of e)t(r);else t(e);}G.eachItem=Dd;function va({mergeNames:e,mergeToName:t,mergeValues:r,resultToName:n}){return (s,o,a,i)=>{let u=a===void 0?o:a instanceof Q.Name?(o instanceof Q.Name?e(s,o,a):t(s,o,a),a):o instanceof Q.Name?(t(s,a,o),o):r(o,a);return i===Q.Name&&!(u instanceof Q.Name)?n(s,u):u}}G.mergeEvaluated={props:va({mergeNames:(e,t,r)=>e.if((0, Q._)`${r} !== true && ${t} !== undefined`,()=>{e.if((0, Q._)`${t} === true`,()=>e.assign(r,true),()=>e.assign(r,(0, Q._)`${r} || {}`).code((0, Q._)`Object.assign(${r}, ${t})`));}),mergeToName:(e,t,r)=>e.if((0, Q._)`${r} !== true`,()=>{t===true?e.assign(r,true):(e.assign(r,(0, Q._)`${r} || {}`),as(e,r,t));}),mergeValues:(e,t)=>e===true?true:{...e,...t},resultToName:_a}),items:va({mergeNames:(e,t,r)=>e.if((0, Q._)`${r} !== true && ${t} !== undefined`,()=>e.assign(r,(0, Q._)`${t} === true ? true : ${r} > ${t} ? ${r} : ${t}`)),mergeToName:(e,t,r)=>e.if((0, Q._)`${r} !== true`,()=>e.assign(r,t===true?true:(0, Q._)`${r} > ${t} ? ${r} : ${t}`)),mergeValues:(e,t)=>e===true?true:Math.max(e,t),resultToName:(e,t)=>e.var("items",t)})};function _a(e,t){if(t===true)return e.var("props",true);let r=e.var("props",(0, Q._)`{}`);return t!==void 0&&as(e,r,t),r}G.evaluatedPropsToName=_a;function as(e,t,r){Object.keys(r).forEach(n=>e.assign((0, Q._)`${t}${(0, Q.getProperty)(n)}`,true));}G.setEvaluated=as;var ka={};function Fd(e,t){return e.scopeValue("func",{ref:t,code:ka[t.code]||(ka[t.code]=new Ad._Code(t.code))})}G.useFunc=Fd;var ss;(function(e){e[e.Num=0]="Num",e[e.Str=1]="Str";})(ss||(G.Type=ss={}));function Md(e,t,r){if(e instanceof Q.Name){let n=t===ss.Num;return r?n?(0, Q._)`"[" + ${e} + "]"`:(0, Q._)`"['" + ${e} + "']"`:n?(0, Q._)`"/" + ${e}`:(0, Q._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0, Q.getProperty)(e).toString():"/"+os(e)}G.getErrorPath=Md;function Ra(e,t,r=e.opts.strictSchema){if(r){if(t=`strict mode: ${t}`,r===true)throw new Error(t);e.self.logger.warn(t);}}G.checkStrictMode=Ra;});var Ge=x(is=>{Object.defineProperty(is,"__esModule",{value:true});var fe=B(),Ld={data:new fe.Name("data"),valCxt:new fe.Name("valCxt"),instancePath:new fe.Name("instancePath"),parentData:new fe.Name("parentData"),parentDataProperty:new fe.Name("parentDataProperty"),rootData:new fe.Name("rootData"),dynamicAnchors:new fe.Name("dynamicAnchors"),vErrors:new fe.Name("vErrors"),errors:new fe.Name("errors"),this:new fe.Name("this"),self:new fe.Name("self"),scope:new fe.Name("scope"),json:new fe.Name("json"),jsonPos:new fe.Name("jsonPos"),jsonLen:new fe.Name("jsonLen"),jsonPart:new fe.Name("jsonPart")};is.default=Ld;});var sr=x(pe=>{Object.defineProperty(pe,"__esModule",{value:true});pe.extendErrors=pe.resetErrorsCount=pe.reportExtraError=pe.reportError=pe.keyword$DataError=pe.keywordError=void 0;var H=B(),Kr=z(),ge=Ge();pe.keywordError={message:({keyword:e})=>(0, H.str)`must pass "${e}" keyword validation`};pe.keyword$DataError={message:({keyword:e,schemaType:t})=>t?(0, H.str)`"${e}" keyword must be ${t} ($data)`:(0, H.str)`"${e}" keyword is invalid ($data)`};function Vd(e,t=pe.keywordError,r,n){let{it:s}=e,{gen:o,compositeRule:a,allErrors:i}=s,u=Ea(e,t,r);n??(a||i)?Ca(o,u):$a(s,(0, H._)`[${u}]`);}pe.reportError=Vd;function Bd(e,t=pe.keywordError,r){let{it:n}=e,{gen:s,compositeRule:o,allErrors:a}=n,i=Ea(e,t,r);Ca(s,i),o||a||$a(n,ge.default.vErrors);}pe.reportExtraError=Bd;function Gd(e,t){e.assign(ge.default.errors,t),e.if((0, H._)`${ge.default.vErrors} !== null`,()=>e.if(t,()=>e.assign((0, H._)`${ge.default.vErrors}.length`,t),()=>e.assign(ge.default.vErrors,null)));}pe.resetErrorsCount=Gd;function Kd({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,ge.default.errors,i=>{e.const(a,(0, H._)`${ge.default.vErrors}[${i}]`),e.if((0, H._)`${a}.instancePath === undefined`,()=>e.assign((0, H._)`${a}.instancePath`,(0, H.strConcat)(ge.default.instancePath,o.errorPath))),e.assign((0, H._)`${a}.schemaPath`,(0, H.str)`${o.errSchemaPath}/${t}`),o.opts.verbose&&(e.assign((0, H._)`${a}.schema`,r),e.assign((0, H._)`${a}.data`,n));});}pe.extendErrors=Kd;function Ca(e,t){let r=e.const("err",t);e.if((0, H._)`${ge.default.vErrors} === null`,()=>e.assign(ge.default.vErrors,(0, H._)`[${r}]`),(0, H._)`${ge.default.vErrors}.push(${r})`),e.code((0, H._)`${ge.default.errors}++`);}function $a(e,t){let{gen:r,validateName:n,schemaEnv:s}=e;s.$async?r.throw((0, H._)`new ${e.ValidationError}(${t})`):(r.assign((0, H._)`${n}.errors`,t),r.return(false));}var kt={keyword:new H.Name("keyword"),schemaPath:new H.Name("schemaPath"),params:new H.Name("params"),propertyName:new H.Name("propertyName"),message:new H.Name("message"),schema:new H.Name("schema"),parentSchema:new H.Name("parentSchema")};function Ea(e,t,r){let{createErrors:n}=e.it;return n===false?(0, H._)`{}`:Ud(e,t,r)}function Ud(e,t,r={}){let{gen:n,it:s}=e,o=[Jd(s,r),zd(e,r)];return Hd(e,t,o),n.object(...o)}function Jd({errorPath:e},{instancePath:t}){let r=t?(0, H.str)`${e}${(0, Kr.getErrorPath)(t,Kr.Type.Str)}`:e;return [ge.default.instancePath,(0, H.strConcat)(ge.default.instancePath,r)]}function zd({keyword:e,it:{errSchemaPath:t}},{schemaPath:r,parentSchema:n}){let s=n?t:(0, H.str)`${t}/${e}`;return r&&(s=(0, H.str)`${s}${(0, Kr.getErrorPath)(r,Kr.Type.Str)}`),[kt.schemaPath,s]}function Hd(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([kt.keyword,s],[kt.params,typeof t=="function"?t(e):t||(0, H._)`{}`]),u.messages&&n.push([kt.message,typeof r=="function"?r(e):r]),u.verbose&&n.push([kt.schema,a],[kt.parentSchema,(0, H._)`${d}${l}`],[ge.default.data,o]),c&&n.push([kt.propertyName,c]);}});var Ta=x(It=>{Object.defineProperty(It,"__esModule",{value:true});It.boolOrEmptySchema=It.topBoolOrEmptySchema=void 0;var Wd=sr(),Yd=B(),Xd=Ge(),Qd={message:"boolean schema is false"};function Zd(e){let{gen:t,schema:r,validateName:n}=e;r===false?xa(e,false):typeof r=="object"&&r.$async===true?t.return(Xd.default.data):(t.assign((0, Yd._)`${n}.errors`,null),t.return(true));}It.topBoolOrEmptySchema=Zd;function el(e,t){let{gen:r,schema:n}=e;n===false?(r.var(t,false),xa(e)):r.var(t,true);}It.boolOrEmptySchema=el;function xa(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, Wd.reportError)(s,Qd,void 0,t);}});var us=x(Pt=>{Object.defineProperty(Pt,"__esModule",{value:true});Pt.getRules=Pt.isJSONType=void 0;var tl=["string","number","integer","boolean","null","object","array"],rl=new Set(tl);function nl(e){return typeof e=="string"&&rl.has(e)}Pt.isJSONType=nl;function sl(){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:{}}}Pt.getRules=sl;});var cs=x(et=>{Object.defineProperty(et,"__esModule",{value:true});et.shouldUseRule=et.shouldUseGroup=et.schemaHasRulesForType=void 0;function ol({schema:e,self:t},r){let n=t.RULES.types[r];return n&&n!==true&&Aa(e,n)}et.schemaHasRulesForType=ol;function Aa(e,t){return t.rules.some(r=>Ia(e,r))}et.shouldUseGroup=Aa;function Ia(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))}et.shouldUseRule=Ia;});var or=x(me=>{Object.defineProperty(me,"__esModule",{value:true});me.reportTypeError=me.checkDataTypes=me.checkDataType=me.coerceAndCheckDataType=me.getJSONTypes=me.getSchemaTypes=me.DataType=void 0;var al=us(),il=cs(),ul=sr(),L=B(),Pa=z(),Ot;(function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong";})(Ot||(me.DataType=Ot={}));function cl(e){let t=Oa(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}me.getSchemaTypes=cl;function Oa(e){let t=Array.isArray(e)?e:e?[e]:[];if(t.every(al.isJSONType))return t;throw new Error("type must be JSONType or JSONType[]: "+t.join(","))}me.getJSONTypes=Oa;function dl(e,t){let{gen:r,data:n,opts:s}=e,o=ll(t,s.coerceTypes),a=t.length>0&&!(o.length===0&&t.length===1&&(0, il.schemaHasRulesForType)(e,t[0]));if(a){let i=ls(t,n,s.strictNumbers,Ot.Wrong);r.if(i,()=>{o.length?fl(e,t,o):fs(e);});}return a}me.coerceAndCheckDataType=dl;var ja=new Set(["string","number","integer","boolean","null"]);function ll(e,t){return t?e.filter(r=>ja.has(r)||t==="array"&&r==="array"):[]}function fl(e,t,r){let{gen:n,data:s,opts:o}=e,a=n.let("dataType",(0, L._)`typeof ${s}`),i=n.let("coerced",(0, L._)`undefined`);o.coerceTypes==="array"&&n.if((0, L._)`${a} == 'object' && Array.isArray(${s}) && ${s}.length == 1`,()=>n.assign(s,(0, L._)`${s}[0]`).assign(a,(0, L._)`typeof ${s}`).if(ls(t,s,o.strictNumbers),()=>n.assign(i,s))),n.if((0, L._)`${i} !== undefined`);for(let c of r)(ja.has(c)||c==="array"&&o.coerceTypes==="array")&&u(c);n.else(),fs(e),n.endIf(),n.if((0, L._)`${i} !== undefined`,()=>{n.assign(s,i),pl(e,i);});function u(c){switch(c){case "string":n.elseIf((0, L._)`${a} == "number" || ${a} == "boolean"`).assign(i,(0, L._)`"" + ${s}`).elseIf((0, L._)`${s} === null`).assign(i,(0, L._)`""`);return;case "number":n.elseIf((0, L._)`${a} == "boolean" || ${s} === null
3
3
  || (${a} == "string" && ${s} && ${s} == +${s})`).assign(i,(0, L._)`+${s}`);return;case "integer":n.elseIf((0, L._)`${a} === "boolean" || ${s} === null
4
4
  || (${a} === "string" && ${s} && ${s} == +${s} && !(${s} % 1))`).assign(i,(0, L._)`+${s}`);return;case "boolean":n.elseIf((0, L._)`${s} === "false" || ${s} === 0 || ${s} === null`).assign(i,false).elseIf((0, L._)`${s} === "true" || ${s} === 1`).assign(i,true);return;case "null":n.elseIf((0, L._)`${s} === "" || ${s} === 0 || ${s} === false`),n.assign(i,null);return;case "array":n.elseIf((0, L._)`${a} === "string" || ${a} === "number"
5
- || ${a} === "boolean" || ${s} === null`).assign(i,(0, L._)`[${s}]`);}}}function fl({gen:e,parentData:t,parentDataProperty:r},n){e.if((0, L._)`${t} !== undefined`,()=>e.assign((0, L._)`${t}[${r}]`,n));}function ds(e,t,r,n=Ot.Correct){let s=n===Ot.Correct?L.operators.EQ:L.operators.NEQ,o;switch(e){case "null":return (0, L._)`${t} ${s} null`;case "array":o=(0, L._)`Array.isArray(${t})`;break;case "object":o=(0, L._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case "integer":o=a((0, L._)`!(${t} % 1) && !isNaN(${t})`);break;case "number":o=a();break;default:return (0, L._)`typeof ${t} ${s} ${e}`}return n===Ot.Correct?o:(0, L.not)(o);function a(i=L.nil){return (0, L.and)((0, L._)`typeof ${t} == "number"`,i,r?(0, L._)`isFinite(${t})`:L.nil)}}me.checkDataType=ds;function ls(e,t,r,n){if(e.length===1)return ds(e[0],t,r,n);let s,o=(0, Pa.toHash)(e);if(o.array&&o.object){let a=(0, L._)`typeof ${t} != "object"`;s=o.null?a:(0, L._)`!${t} || ${a}`,delete o.null,delete o.array,delete o.object;}else s=L.nil;o.number&&delete o.integer;for(let a in o)s=(0, L.and)(s,ds(a,t,r,n));return s}me.checkDataTypes=ls;var pl={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e=="string"?(0, L._)`{type: ${e}}`:(0, L._)`{type: ${t}}`};function fs(e){let t=ml(e);(0, il.reportError)(t,pl);}me.reportTypeError=fs;function ml(e){let{gen:t,data:r,schema:n}=e,s=(0, Pa.schemaRefOrVal)(e,n,"type");return {gen:t,keyword:"type",data:r,schema:n.type,schemaCode:s,schemaValue:s,parentSchema:n,params:{},it:e}}});var qa=x(Ur=>{Object.defineProperty(Ur,"__esModule",{value:true});Ur.assignDefaults=void 0;var jt=B(),gl=z();function hl(e,t){let{properties:r,items:n}=e.schema;if(t==="object"&&r)for(let s in r)Na(e,s,r[s].default);else t==="array"&&Array.isArray(n)&&n.forEach((s,o)=>Na(e,o,s.default));}Ur.assignDefaults=hl;function Na(e,t,r){let{gen:n,compositeRule:s,data:o,opts:a}=e;if(r===void 0)return;let i=(0, jt._)`${o}${(0, jt.getProperty)(t)}`;if(s){(0, gl.checkStrictMode)(e,`default is ignored for: ${i}`);return}let u=(0, jt._)`${i} === undefined`;a.useDefaults==="empty"&&(u=(0, jt._)`${u} || ${i} === null || ${i} === ""`),n.if(u,(0, jt._)`${i} = ${(0, jt.stringify)(r)}`);}});var xe=x(Y=>{Object.defineProperty(Y,"__esModule",{value:true});Y.validateUnion=Y.validateArray=Y.usePattern=Y.callValidateCode=Y.schemaProperties=Y.allSchemaProperties=Y.noPropertyInData=Y.propertyInData=Y.isOwnProperty=Y.hasPropFunc=Y.reportMissingProp=Y.checkMissingProp=Y.checkReportMissingProp=void 0;var re=B(),ps=z(),tt=Ke(),yl=z();function vl(e,t){let{gen:r,data:n,it:s}=e;r.if(gs(r,n,t,s.opts.ownProperties),()=>{e.setParams({missingProperty:(0, re._)`${t}`},true),e.error();});}Y.checkReportMissingProp=vl;function bl({gen:e,data:t,it:{opts:r}},n,s){return (0, re.or)(...n.map(o=>(0, re.and)(gs(e,t,o,r.ownProperties),(0, re._)`${s} = ${o}`)))}Y.checkMissingProp=bl;function kl(e,t){e.setParams({missingProperty:t},true),e.error();}Y.reportMissingProp=kl;function Da(e){return e.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0, re._)`Object.prototype.hasOwnProperty`})}Y.hasPropFunc=Da;function ms(e,t,r){return (0, re._)`${Da(e)}.call(${t}, ${r})`}Y.isOwnProperty=ms;function wl(e,t,r,n){let s=(0, re._)`${t}${(0, re.getProperty)(r)} !== undefined`;return n?(0, re._)`${s} && ${ms(e,t,r)}`:s}Y.propertyInData=wl;function gs(e,t,r,n){let s=(0, re._)`${t}${(0, re.getProperty)(r)} === undefined`;return n?(0, re.or)(s,(0, re.not)(ms(e,t,r))):s}Y.noPropertyInData=gs;function Fa(e){return e?Object.keys(e).filter(t=>t!=="__proto__"):[]}Y.allSchemaProperties=Fa;function Sl(e,t){return Fa(t).filter(r=>!(0, ps.alwaysValidSchema)(e,t[r]))}Y.schemaProperties=Sl;function _l({schemaCode:e,data:t,it:{gen:r,topSchemaRef:n,schemaPath:s,errorPath:o},it:a},i,u,c){let d=c?(0, re._)`${e}, ${t}, ${n}${s}`:t,l=[[tt.default.instancePath,(0, re.strConcat)(tt.default.instancePath,o)],[tt.default.parentData,a.parentData],[tt.default.parentDataProperty,a.parentDataProperty],[tt.default.rootData,tt.default.rootData]];a.opts.dynamicRef&&l.push([tt.default.dynamicAnchors,tt.default.dynamicAnchors]);let b=(0, re._)`${d}, ${r.object(...l)}`;return u!==re.nil?(0, re._)`${i}.call(${u}, ${b})`:(0, re._)`${i}(${b})`}Y.callValidateCode=_l;var Rl=(0, re._)`new RegExp`;function Cl({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, re._)`${s.code==="new RegExp"?Rl:(0, yl.useFunc)(e,s)}(${r}, ${n})`})}Y.usePattern=Cl;function $l(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, re._)`${r}.length`);t.forRange("i",0,u,c=>{e.subschema({keyword:n,dataProp:c,dataPropType:ps.Type.Num},o),t.if((0, re.not)(o),i);});}}Y.validateArray=$l;function El(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, ps.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, re._)`${a} || ${i}`),e.mergeValidEvaluated(d,i)||t.if((0, re.not)(a));})),e.result(a,()=>e.reset(),()=>e.error(true));}Y.validateUnion=El;});var Va=x(De=>{Object.defineProperty(De,"__esModule",{value:true});De.validateKeywordUsage=De.validSchemaType=De.funcKeywordCode=De.macroKeywordCode=void 0;var he=B(),kt=Ke(),xl=xe(),Tl=sr();function Al(e,t){let{gen:r,keyword:n,schema:s,parentSchema:o,it:a}=e,i=t.macro.call(a.self,s,o,a),u=La(r,n,i);a.opts.validateSchema!==false&&a.self.validateSchema(i,true);let c=r.name("valid");e.subschema({schema:i,schemaPath:he.nil,errSchemaPath:`${a.errSchemaPath}/${n}`,topSchemaRef:u,compositeRule:true},c),e.pass(c,()=>e.error(true));}De.macroKeywordCode=Al;function Il(e,t){var r;let{gen:n,keyword:s,schema:o,parentSchema:a,$data:i,it:u}=e;Ol(u,t);let c=!i&&t.compile?t.compile.call(u.self,o,a,u):t.validate,d=La(n,s,c),l=n.let("valid");e.block$data(l,b),e.ok((r=t.valid)!==null&&r!==void 0?r:l);function b(){if(t.errors===false)p(),t.modifying&&Ma(e),k(()=>e.error());else {let g=t.async?v():m();t.modifying&&Ma(e),k(()=>Pl(e,g));}}function v(){let g=n.let("ruleErrs",null);return n.try(()=>p((0, he._)`await `),f=>n.assign(l,false).if((0, he._)`${f} instanceof ${u.ValidationError}`,()=>n.assign(g,(0, he._)`${f}.errors`),()=>n.throw(f))),g}function m(){let g=(0, he._)`${d}.errors`;return n.assign(g,null),p(he.nil),g}function p(g=t.async?(0, he._)`await `:he.nil){let f=u.opts.passContext?kt.default.this:kt.default.self,y=!("compile"in t&&!i||t.schema===false);n.assign(l,(0, he._)`${g}${(0, xl.callValidateCode)(e,d,f,y)}`,t.modifying);}function k(g){var f;n.if((0, he.not)((f=t.valid)!==null&&f!==void 0?f:l),g);}}De.funcKeywordCode=Il;function Ma(e){let{gen:t,data:r,it:n}=e;t.if(n.parentData,()=>t.assign(r,(0, he._)`${n.parentData}[${n.parentDataProperty}]`));}function Pl(e,t){let{gen:r}=e;r.if((0, he._)`Array.isArray(${t})`,()=>{r.assign(kt.default.vErrors,(0, he._)`${kt.default.vErrors} === null ? ${t} : ${kt.default.vErrors}.concat(${t})`).assign(kt.default.errors,(0, he._)`${kt.default.vErrors}.length`),(0, Tl.extendErrors)(e);},()=>e.error());}function Ol({schemaEnv:e},t){if(t.async&&!e.$async)throw new Error("async keyword in sync schema")}function La(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, he.stringify)(r)})}function jl(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")}De.validSchemaType=jl;function Nl({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)}}De.validateKeywordUsage=Nl;});var Ga=x(rt=>{Object.defineProperty(rt,"__esModule",{value:true});rt.extendSubschemaMode=rt.extendSubschemaData=rt.getSubschema=void 0;var Fe=B(),Ba=z();function ql(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, Fe._)`${e.schemaPath}${(0, Fe.getProperty)(t)}`,errSchemaPath:`${e.errSchemaPath}/${t}`}:{schema:i[r],schemaPath:(0, Fe._)`${e.schemaPath}${(0, Fe.getProperty)(t)}${(0, Fe.getProperty)(r)}`,errSchemaPath:`${e.errSchemaPath}/${t}/${(0, Ba.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')}rt.getSubschema=ql;function Dl(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,b=i.let("data",(0, Fe._)`${t.data}${(0, Fe.getProperty)(r)}`,true);u(b),e.errorPath=(0, Fe.str)`${c}${(0, Ba.getErrorPath)(r,n,l.jsPropertySyntax)}`,e.parentDataProperty=(0, Fe._)`${r}`,e.dataPathArr=[...d,e.parentDataProperty];}if(s!==void 0){let c=s instanceof Fe.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];}}rt.extendSubschemaData=Dl;function Fl(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;}rt.extendSubschemaMode=Fl;});var hs=x((My,Ka)=>{Ka.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 Ja=x((Ly,Ua)=>{var nt=Ua.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(){};Jr(t,n,s,e,"",e);};nt.keywords={additionalItems:true,items:true,contains:true,additionalProperties:true,propertyNames:true,not:true,if:true,then:true,else:true};nt.arrayKeywords={items:true,allOf:true,anyOf:true,oneOf:true};nt.propsKeywords={$defs:true,definitions:true,properties:true,patternProperties:true,dependencies:true};nt.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 Jr(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 nt.arrayKeywords)for(var b=0;b<l.length;b++)Jr(e,t,r,l[b],s+"/"+d+"/"+b,o,s,d,n,b);}else if(d in nt.propsKeywords){if(l&&typeof l=="object")for(var v in l)Jr(e,t,r,l[v],s+"/"+d+"/"+Ml(v),o,s,d,n,v);}else (d in nt.keywords||e.allKeys&&!(d in nt.skipKeywords))&&Jr(e,t,r,l,s+"/"+d,o,s,d,n);}r(n,s,o,a,i,u,c);}}function Ml(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}});var ar=x(be=>{Object.defineProperty(be,"__esModule",{value:true});be.getSchemaRefs=be.resolveUrl=be.normalizeId=be._getFullPath=be.getFullPath=be.inlineRef=void 0;var Ll=z(),Vl=hs(),Bl=Ja(),Gl=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function Kl(e,t=true){return typeof e=="boolean"?true:t===true?!ys(e):t?za(e)<=t:false}be.inlineRef=Kl;var Ul=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function ys(e){for(let t in e){if(Ul.has(t))return true;let r=e[t];if(Array.isArray(r)&&r.some(ys)||typeof r=="object"&&ys(r))return true}return false}function za(e){let t=0;for(let r in e){if(r==="$ref")return 1/0;if(t++,!Gl.has(r)&&(typeof e[r]=="object"&&(0, Ll.eachItem)(e[r],n=>t+=za(n)),t===1/0))return 1/0}return t}function Ha(e,t="",r){r!==false&&(t=Nt(t));let n=e.parse(t);return Wa(e,n)}be.getFullPath=Ha;function Wa(e,t){return e.serialize(t).split("#")[0]+"#"}be._getFullPath=Wa;var Jl=/#\/?$/;function Nt(e){return e?e.replace(Jl,""):""}be.normalizeId=Nt;function zl(e,t,r){return r=Nt(r),e.resolve(t,r)}be.resolveUrl=zl;var Hl=/^[a-z_][-a-z0-9._]*$/i;function Wl(e,t){if(typeof e=="boolean")return {};let{schemaId:r,uriResolver:n}=this.opts,s=Nt(e[r]||t),o={"":s},a=Ha(n,s,false),i={},u=new Set;return Bl(e,{allKeys:true},(l,b,v,m)=>{if(m===void 0)return;let p=a+b,k=o[m];typeof l[r]=="string"&&(k=g.call(this,l[r])),f.call(this,l.$anchor),f.call(this,l.$dynamicAnchor),o[b]=k;function g(y){let _=this.opts.uriResolver.resolve;if(y=Nt(k?_(k,y):y),u.has(y))throw d(y);u.add(y);let w=this.refs[y];return typeof w=="string"&&(w=this.refs[w]),typeof w=="object"?c(l,w.schema,y):y!==Nt(p)&&(y[0]==="#"?(c(l,i[y],y),i[y]=l):this.refs[y]=p),y}function f(y){if(typeof y=="string"){if(!Hl.test(y))throw new Error(`invalid anchor "${y}"`);g.call(this,`#${y}`);}}}),i;function c(l,b,v){if(b!==void 0&&!Vl(l,b))throw d(v)}function d(l){return new Error(`reference "${l}" resolves to more than one schema`)}}be.getSchemaRefs=Wl;});var cr=x(st=>{Object.defineProperty(st,"__esModule",{value:true});st.getData=st.KeywordCxt=st.validateFunctionCode=void 0;var ei=Ta(),Ya=or(),bs=cs(),zr=or(),Yl=qa(),ur=Va(),vs=Ga(),I=B(),O=Ke(),Xl=ar(),Ue=z(),ir=sr();function Ql(e){if(ni(e)&&(si(e),ri(e))){tf(e);return}ti(e,()=>(0, ei.topBoolOrEmptySchema)(e));}st.validateFunctionCode=Ql;function ti({gen:e,validateName:t,schema:r,schemaEnv:n,opts:s},o){s.code.es5?e.func(t,(0, I._)`${O.default.data}, ${O.default.valCxt}`,n.$async,()=>{e.code((0, I._)`"use strict"; ${Xa(r,s)}`),ef(e,s),e.code(o);}):e.func(t,(0, I._)`${O.default.data}, ${Zl(s)}`,n.$async,()=>e.code(Xa(r,s)).code(o));}function Zl(e){return (0, I._)`{${O.default.instancePath}="", ${O.default.parentData}, ${O.default.parentDataProperty}, ${O.default.rootData}=${O.default.data}${e.dynamicRef?(0, I._)`, ${O.default.dynamicAnchors}={}`:I.nil}}={}`}function ef(e,t){e.if(O.default.valCxt,()=>{e.var(O.default.instancePath,(0, I._)`${O.default.valCxt}.${O.default.instancePath}`),e.var(O.default.parentData,(0, I._)`${O.default.valCxt}.${O.default.parentData}`),e.var(O.default.parentDataProperty,(0, I._)`${O.default.valCxt}.${O.default.parentDataProperty}`),e.var(O.default.rootData,(0, I._)`${O.default.valCxt}.${O.default.rootData}`),t.dynamicRef&&e.var(O.default.dynamicAnchors,(0, I._)`${O.default.valCxt}.${O.default.dynamicAnchors}`);},()=>{e.var(O.default.instancePath,(0, I._)`""`),e.var(O.default.parentData,(0, I._)`undefined`),e.var(O.default.parentDataProperty,(0, I._)`undefined`),e.var(O.default.rootData,O.default.data),t.dynamicRef&&e.var(O.default.dynamicAnchors,(0, I._)`{}`);});}function tf(e){let{schema:t,opts:r,gen:n}=e;ti(e,()=>{r.$comment&&t.$comment&&ai(e),af(e),n.let(O.default.vErrors,null),n.let(O.default.errors,0),r.unevaluated&&rf(e),oi(e),df(e);});}function rf(e){let{gen:t,validateName:r}=e;e.evaluated=t.const("evaluated",(0, I._)`${r}.evaluated`),t.if((0, I._)`${e.evaluated}.dynamicProps`,()=>t.assign((0, I._)`${e.evaluated}.props`,(0, I._)`undefined`)),t.if((0, I._)`${e.evaluated}.dynamicItems`,()=>t.assign((0, I._)`${e.evaluated}.items`,(0, I._)`undefined`));}function Xa(e,t){let r=typeof e=="object"&&e[t.schemaId];return r&&(t.code.source||t.code.process)?(0, I._)`/*# sourceURL=${r} */`:I.nil}function nf(e,t){if(ni(e)&&(si(e),ri(e))){sf(e,t);return}(0, ei.boolOrEmptySchema)(e,t);}function ri({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 ni(e){return typeof e.schema!="boolean"}function sf(e,t){let{schema:r,gen:n,opts:s}=e;s.$comment&&r.$comment&&ai(e),uf(e),cf(e);let o=n.const("_errs",O.default.errors);oi(e,o),n.var(t,(0, I._)`${o} === ${O.default.errors}`);}function si(e){(0, Ue.checkUnknownRules)(e),of(e);}function oi(e,t){if(e.opts.jtd)return Qa(e,[],false,t);let r=(0, Ya.getSchemaTypes)(e.schema),n=(0, Ya.coerceAndCheckDataType)(e,r);Qa(e,r,!n,t);}function of(e){let{schema:t,errSchemaPath:r,opts:n,self:s}=e;t.$ref&&n.ignoreKeywordsWithRef&&(0, Ue.schemaHasRulesButRef)(t,s.RULES)&&s.logger.warn(`$ref: keywords ignored in schema at path "${r}"`);}function af(e){let{schema:t,opts:r}=e;t.default!==void 0&&r.useDefaults&&r.strictSchema&&(0, Ue.checkStrictMode)(e,"default is ignored in the schema root");}function uf(e){let t=e.schema[e.opts.schemaId];t&&(e.baseId=(0, Xl.resolveUrl)(e.opts.uriResolver,e.baseId,t));}function cf(e){if(e.schema.$async&&!e.schemaEnv.$async)throw new Error("async schema in sync schema")}function ai({gen:e,schemaEnv:t,schema:r,errSchemaPath:n,opts:s}){let o=r.$comment;if(s.$comment===true)e.code((0, I._)`${O.default.self}.logger.log(${o})`);else if(typeof s.$comment=="function"){let a=(0, I.str)`${n}/$comment`,i=e.scopeValue("root",{ref:t.root});e.code((0, I._)`${O.default.self}.opts.$comment(${o}, ${a}, ${i}.schema)`);}}function df(e){let{gen:t,schemaEnv:r,validateName:n,ValidationError:s,opts:o}=e;r.$async?t.if((0, I._)`${O.default.errors} === 0`,()=>t.return(O.default.data),()=>t.throw((0, I._)`new ${s}(${O.default.vErrors})`)):(t.assign((0, I._)`${n}.errors`,O.default.vErrors),o.unevaluated&&lf(e),t.return((0, I._)`${O.default.errors} === 0`));}function lf({gen:e,evaluated:t,props:r,items:n}){r instanceof I.Name&&e.assign((0, I._)`${t}.props`,r),n instanceof I.Name&&e.assign((0, I._)`${t}.items`,n);}function Qa(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, Ue.schemaHasRulesButRef)(o,d))){s.block(()=>ui(e,"$ref",d.all.$ref.definition));return}u.jtd||ff(e,t),s.block(()=>{for(let b of d.rules)l(b);l(d.post);});function l(b){(0, bs.shouldUseGroup)(o,b)&&(b.type?(s.if((0, zr.checkDataType)(b.type,a,u.strictNumbers)),Za(e,b),t.length===1&&t[0]===b.type&&r&&(s.else(),(0, zr.reportTypeError)(e)),s.endIf()):Za(e,b),i||s.if((0, I._)`${O.default.errors} === ${n||0}`));}}function Za(e,t){let{gen:r,schema:n,opts:{useDefaults:s}}=e;s&&(0, Yl.assignDefaults)(e,t.type),r.block(()=>{for(let o of t.rules)(0, bs.shouldUseRule)(n,o)&&ui(e,o.keyword,o.definition,t.type);});}function ff(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(pf(e,t),e.opts.allowUnionTypes||mf(e,t),gf(e,e.dataTypes));}function pf(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(r=>{ii(e.dataTypes,r)||ks(e,`type "${r}" not allowed by context "${e.dataTypes.join(",")}"`);}),yf(e,t);}}function mf(e,t){t.length>1&&!(t.length===2&&t.includes("null"))&&ks(e,"use allowUnionTypes to allow union type keyword");}function gf(e,t){let r=e.self.RULES.all;for(let n in r){let s=r[n];if(typeof s=="object"&&(0, bs.shouldUseRule)(e.schema,s)){let{type:o}=s.definition;o.length&&!o.some(a=>hf(t,a))&&ks(e,`missing type "${o.join(",")}" for keyword "${n}"`);}}}function hf(e,t){return e.includes(t)||t==="number"&&e.includes("integer")}function ii(e,t){return e.includes(t)||t==="integer"&&e.includes("number")}function yf(e,t){let r=[];for(let n of e.dataTypes)ii(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, Ue.checkStrictMode)(e,t,e.opts.strictTypes);}var Hr=class{constructor(t,r,n){if((0, ur.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, Ue.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",ci(this.$data,t));else if(this.schemaCode=this.schemaValue,!(0, ur.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",O.default.errors));}result(t,r,n){this.failResult((0, I.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, I.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, I._)`${r} !== undefined && (${(0, I.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?ir.reportExtraError:ir.reportError)(this,this.def.error,r);}$dataError(){(0, ir.reportError)(this,this.def.$dataError||ir.keyword$DataError);}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0, ir.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=I.nil){this.gen.block(()=>{this.check$data(t,n),r();});}check$data(t=I.nil,r=I.nil){if(!this.$data)return;let{gen:n,schemaCode:s,schemaType:o,def:a}=this;n.if((0, I.or)((0, I._)`${s} === undefined`,r)),t!==I.nil&&n.assign(t,true),(o.length||a.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),t!==I.nil&&n.assign(t,false)),n.else();}invalid$data(){let{gen:t,schemaCode:r,schemaType:n,def:s,it:o}=this;return (0, I.or)(a(),i());function a(){if(n.length){if(!(r instanceof I.Name))throw new Error("ajv implementation error");let u=Array.isArray(n)?n:[n];return (0, I._)`${(0, zr.checkDataTypes)(u,r,o.opts.strictNumbers,zr.DataType.Wrong)}`}return I.nil}function i(){if(s.validateSchema){let u=t.scopeValue("validate$data",{ref:s.validateSchema});return (0, I._)`!${u}(${r})`}return I.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 nf(s,r),s}mergeEvaluated(t,r){let{it:n,gen:s}=this;n.opts.unevaluated&&(n.props!==true&&t.props!==void 0&&(n.props=Ue.mergeEvaluated.props(s,t.props,n.props,r)),n.items!==true&&t.items!==void 0&&(n.items=Ue.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,I.Name)),true}};st.KeywordCxt=Hr;function ui(e,t,r,n){let s=new Hr(e,r,t);"code"in r?r.code(s,n):s.$data&&r.validate?(0, ur.funcKeywordCode)(s,r):"macro"in r?(0, ur.macroKeywordCode)(s,r):(r.compile||r.validate)&&(0, ur.funcKeywordCode)(s,r);}var vf=/^\/(?:[^~]|~0|~1)*$/,bf=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function ci(e,{dataLevel:t,dataNames:r,dataPathArr:n}){let s,o;if(e==="")return O.default.rootData;if(e[0]==="/"){if(!vf.test(e))throw new Error(`Invalid JSON-pointer: ${e}`);s=e,o=O.default.rootData;}else {let c=bf.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, I._)`${o}${(0, I.getProperty)((0, Ue.unescapeJsonPointer)(c))}`,a=(0, I._)`${a} && ${o}`);return a;function u(c,d){return `Cannot access ${c} ${d} levels up, current level is ${t}`}}st.getData=ci;});var Wr=x(Ss=>{Object.defineProperty(Ss,"__esModule",{value:true});var ws=class extends Error{constructor(t){super("validation failed"),this.errors=t,this.ajv=this.validation=true;}};Ss.default=ws;});var dr=x(Cs=>{Object.defineProperty(Cs,"__esModule",{value:true});var _s=ar(),Rs=class extends Error{constructor(t,r,n,s){super(s||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0, _s.resolveUrl)(t,r,n),this.missingSchema=(0, _s.normalizeId)((0, _s.getFullPath)(t,this.missingRef));}};Cs.default=Rs;});var Xr=x(Te=>{Object.defineProperty(Te,"__esModule",{value:true});Te.resolveSchema=Te.getCompilingSchema=Te.resolveRef=Te.compileSchema=Te.SchemaEnv=void 0;var Pe=B(),kf=Wr(),wt=Ke(),Oe=ar(),di=z(),wf=cr(),qt=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, Oe.normalizeId)(n?.[t.schemaId||"$id"]),this.schemaPath=t.schemaPath,this.localRefs=t.localRefs,this.meta=t.meta,this.$async=n?.$async,this.refs={};}};Te.SchemaEnv=qt;function Es(e){let t=li.call(this,e);if(t)return t;let r=(0, Oe.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:n,lines:s}=this.opts.code,{ownProperties:o}=this.opts,a=new Pe.CodeGen(this.scope,{es5:n,lines:s,ownProperties:o}),i;e.$async&&(i=a.scopeValue("Error",{ref:kf.default,code:(0, Pe._)`require("ajv/dist/runtime/validation_error").default`}));let u=a.scopeName("validate");e.validateName=u;let c={gen:a,allErrors:this.opts.allErrors,data:wt.default.data,parentData:wt.default.parentData,parentDataProperty:wt.default.parentDataProperty,dataNames:[wt.default.data],dataPathArr:[Pe.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:a.scopeValue("schema",this.opts.code.source===true?{ref:e.schema,code:(0, Pe.stringify)(e.schema)}:{ref:e.schema}),validateName:u,ValidationError:i,schema:e.schema,schemaEnv:e,rootId:r,baseId:e.baseId||r,schemaPath:Pe.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0, Pe._)`""`,opts:this.opts,self:this},d;try{this._compilations.add(e),(0,wf.validateFunctionCode)(c),a.optimize(this.opts.code.optimize);let l=a.toString();d=`${a.scopeRefs(wt.default.scope)}return ${l}`,this.opts.code.process&&(d=this.opts.code.process(d,e));let v=new Function(`${wt.default.self}`,`${wt.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:m,items:p}=c;v.evaluated={props:m instanceof Pe.Name?void 0:m,items:p instanceof Pe.Name?void 0:p,dynamicProps:m instanceof Pe.Name,dynamicItems:p instanceof Pe.Name},v.source&&(v.source.evaluated=(0,Pe.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);}}Te.compileSchema=Es;function Sf(e,t,r){var n;r=(0, Oe.resolveUrl)(this.opts.uriResolver,t,r);let s=e.refs[r];if(s)return s;let o=Cf.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 qt({schema:a,schemaId:i,root:e,baseId:t}));}if(o!==void 0)return e.refs[r]=_f.call(this,o)}Te.resolveRef=Sf;function _f(e){return (0, Oe.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:Es.call(this,e)}function li(e){for(let t of this._compilations)if(Rf(t,e))return t}Te.getCompilingSchema=li;function Rf(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function Cf(e,t){let r;for(;typeof(r=this.refs[t])=="string";)t=r;return r||this.schemas[t]||Yr.call(this,e,t)}function Yr(e,t){let r=this.opts.uriResolver.parse(t),n=(0, Oe._getFullPath)(this.opts.uriResolver,r),s=(0, Oe.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&n===s)return $s.call(this,r,e);let o=(0, Oe.normalizeId)(n),a=this.refs[o]||this.schemas[o];if(typeof a=="string"){let i=Yr.call(this,e,a);return typeof i?.schema!="object"?void 0:$s.call(this,r,i)}if(typeof a?.schema=="object"){if(a.validate||Es.call(this,a),o===(0, Oe.normalizeId)(t)){let{schema:i}=a,{schemaId:u}=this.opts,c=i[u];return c&&(s=(0, Oe.resolveUrl)(this.opts.uriResolver,s,c)),new qt({schema:i,schemaId:u,root:e,baseId:s})}return $s.call(this,r,a)}}Te.resolveSchema=Yr;var $f=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function $s(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, di.unescapeFragment)(i)];if(u===void 0)return;r=u;let c=typeof r=="object"&&r[this.opts.schemaId];!$f.has(i)&&c&&(t=(0, Oe.resolveUrl)(this.opts.uriResolver,t,c));}let o;if(typeof r!="boolean"&&r.$ref&&!(0, di.schemaHasRulesButRef)(r,this.RULES)){let i=(0, Oe.resolveUrl)(this.opts.uriResolver,t,r.$ref);o=Yr.call(this,n,i);}let{schemaId:a}=this.opts;if(o=o||new qt({schema:r,schemaId:a,root:n,baseId:t}),o.schema!==o.root.schema)return o}});var fi=x((Jy,Ef)=>{Ef.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 Ts=x((zy,hi)=>{var xf=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),mi=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 xs(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 Tf=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function pi(e){return e.length=0,true}function Af(e,t,r){if(e.length){let n=xs(e);if(n!=="")t.push(n);else return r.error=true,false;e.length=0;}return true}function If(e){let t=0,r={error:false,address:"",zone:""},n=[],s=[],o=false,a=false,i=Af;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=pi;}else {s.push(c);continue}}return s.length&&(i===pi?r.zone=s.join(""):a?n.push(s.join("")):n.push(xs(s))),r.address=n.join(""),r}function gi(e){if(Pf(e,":")<2)return {host:e,isIPV6:false};let t=If(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 Pf(e,t){let r=0;for(let n=0;n<e.length;n++)e[n]===t&&r++;return r}function Of(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 jf(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 Nf(e){let t=[];if(e.userinfo!==void 0&&(t.push(e.userinfo),t.push("@")),e.host!==void 0){let r=unescape(e.host);if(!mi(r)){let n=gi(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}hi.exports={nonSimpleDomain:Tf,recomposeAuthority:Nf,normalizeComponentEncoding:jf,removeDotSegments:Of,isIPv4:mi,isUUID:xf,normalizeIPv6:gi,stringArrayToHexStripped:xs};});var wi=x((Hy,ki)=>{var{isUUID:qf}=Ts(),Df=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,Ff=["http","https","ws","wss","urn","urn:uuid"];function Mf(e){return Ff.indexOf(e)!==-1}function As(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 yi(e){return e.host||(e.error=e.error||"HTTP URIs must have a host."),e}function vi(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 Lf(e){return e.secure=As(e),e.resourceName=(e.path||"/")+(e.query?"?"+e.query:""),e.path=void 0,e.query=void 0,e}function Vf(e){if((e.port===(As(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 Bf(e,t){if(!e.path)return e.error="URN can not be parsed",e;let r=e.path.match(Df);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=Is(s);e.path=void 0,o&&(e=o.parse(e,t));}else e.error=e.error||"URN can not be parsed.";return e}function Gf(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=Is(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 Kf(e,t){let r=e;return r.uuid=r.nss,r.nss=void 0,!t.tolerant&&(!r.uuid||!qf(r.uuid))&&(r.error=r.error||"UUID is not valid."),r}function Uf(e){let t=e;return t.nss=(e.uuid||"").toLowerCase(),t}var bi={scheme:"http",domainHost:true,parse:yi,serialize:vi},Jf={scheme:"https",domainHost:bi.domainHost,parse:yi,serialize:vi},Qr={scheme:"ws",domainHost:true,parse:Lf,serialize:Vf},zf={scheme:"wss",domainHost:Qr.domainHost,parse:Qr.parse,serialize:Qr.serialize},Hf={scheme:"urn",parse:Bf,serialize:Gf,skipNormalize:true},Wf={scheme:"urn:uuid",parse:Kf,serialize:Uf,skipNormalize:true},Zr={http:bi,https:Jf,ws:Qr,wss:zf,urn:Hf,"urn:uuid":Wf};Object.setPrototypeOf(Zr,null);function Is(e){return e&&(Zr[e]||Zr[e.toLowerCase()])||void 0}ki.exports={wsIsSecure:As,SCHEMES:Zr,isValidSchemeName:Mf,getSchemeHandler:Is};});var Ri=x((Wy,tn)=>{var{normalizeIPv6:Yf,removeDotSegments:lr,recomposeAuthority:Xf,normalizeComponentEncoding:en,isIPv4:Qf,nonSimpleDomain:Zf}=Ts(),{SCHEMES:ep,getSchemeHandler:Si}=wi();function tp(e,t){return typeof e=="string"?e=Me(Je(e,t),t):typeof e=="object"&&(e=Je(Me(e,t),t)),e}function rp(e,t,r){let n=r?Object.assign({scheme:"null"},r):{scheme:"null"},s=_i(Je(e,n),Je(t,n),n,true);return n.skipEscape=true,Me(s,n)}function _i(e,t,r,n){let s={};return n||(e=Je(Me(e,r),r),t=Je(Me(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=lr(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=lr(t.path||""),s.query=t.query):(t.path?(t.path[0]==="/"?s.path=lr(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=lr(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 np(e,t,r){return typeof e=="string"?(e=unescape(e),e=Me(en(Je(e,r),true),{...r,skipEscape:true})):typeof e=="object"&&(e=Me(en(e,true),{...r,skipEscape:true})),typeof t=="string"?(t=unescape(t),t=Me(en(Je(t,r),true),{...r,skipEscape:true})):typeof t=="object"&&(t=Me(en(t,true),{...r,skipEscape:true})),e.toLowerCase()===t.toLowerCase()}function Me(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=Si(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=Xf(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=lr(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 sp=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function Je(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(sp);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(Qf(n.host)===false){let u=Yf(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=Si(r.scheme||n.scheme);if(!r.unicodeSupport&&(!a||!a.unicodeSupport)&&n.host&&(r.domainHost||a&&a.domainHost)&&s===false&&Zf(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 Ps={SCHEMES:ep,normalize:tp,resolve:rp,resolveComponent:_i,equal:np,serialize:Me,parse:Je};tn.exports=Ps;tn.exports.default=Ps;tn.exports.fastUri=Ps;});var $i=x(Os=>{Object.defineProperty(Os,"__esModule",{value:true});var Ci=Ri();Ci.code='require("ajv/dist/runtime/uri").default';Os.default=Ci;});var ji=x(ue=>{Object.defineProperty(ue,"__esModule",{value:true});ue.CodeGen=ue.Name=ue.nil=ue.stringify=ue.str=ue._=ue.KeywordCxt=void 0;var op=cr();Object.defineProperty(ue,"KeywordCxt",{enumerable:true,get:function(){return op.KeywordCxt}});var Dt=B();Object.defineProperty(ue,"_",{enumerable:true,get:function(){return Dt._}});Object.defineProperty(ue,"str",{enumerable:true,get:function(){return Dt.str}});Object.defineProperty(ue,"stringify",{enumerable:true,get:function(){return Dt.stringify}});Object.defineProperty(ue,"nil",{enumerable:true,get:function(){return Dt.nil}});Object.defineProperty(ue,"Name",{enumerable:true,get:function(){return Dt.Name}});Object.defineProperty(ue,"CodeGen",{enumerable:true,get:function(){return Dt.CodeGen}});var ap=Wr(),Ii=dr(),ip=us(),fr=Xr(),up=B(),pr=ar(),rn=or(),Ns=z(),Ei=fi(),cp=$i(),Pi=(e,t)=>new RegExp(e,t);Pi.code="new RegExp";var dp=["removeAdditional","useDefaults","coerceTypes"],lp=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),fp={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."},pp={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},xi=200;function mp(e){var t,r,n,s,o,a,i,u,c,d,l,b,v,m,p,k,g,f,y,_,w,C,R,E,N;let D=e.strict,M=(t=e.code)===null||t===void 0?void 0:t.optimize,te=M===true||M===void 0?1:M||0,U=(n=(r=e.code)===null||r===void 0?void 0:r.regExp)!==null&&n!==void 0?n:Pi,de=(s=e.uriResolver)!==null&&s!==void 0?s:cp.default;return {strictSchema:(a=(o=e.strictSchema)!==null&&o!==void 0?o:D)!==null&&a!==void 0?a:true,strictNumbers:(u=(i=e.strictNumbers)!==null&&i!==void 0?i:D)!==null&&u!==void 0?u:true,strictTypes:(d=(c=e.strictTypes)!==null&&c!==void 0?c:D)!==null&&d!==void 0?d:"log",strictTuples:(b=(l=e.strictTuples)!==null&&l!==void 0?l:D)!==null&&b!==void 0?b:"log",strictRequired:(m=(v=e.strictRequired)!==null&&v!==void 0?v:D)!==null&&m!==void 0?m:false,code:e.code?{...e.code,optimize:te,regExp:U}:{optimize:te,regExp:U},loopRequired:(p=e.loopRequired)!==null&&p!==void 0?p:xi,loopEnum:(k=e.loopEnum)!==null&&k!==void 0?k:xi,meta:(g=e.meta)!==null&&g!==void 0?g:true,messages:(f=e.messages)!==null&&f!==void 0?f:true,inlineRefs:(y=e.inlineRefs)!==null&&y!==void 0?y:true,schemaId:(_=e.schemaId)!==null&&_!==void 0?_:"$id",addUsedSchema:(w=e.addUsedSchema)!==null&&w!==void 0?w:true,validateSchema:(C=e.validateSchema)!==null&&C!==void 0?C:true,validateFormats:(R=e.validateFormats)!==null&&R!==void 0?R:true,unicodeRegExp:(E=e.unicodeRegExp)!==null&&E!==void 0?E:true,int32range:(N=e.int32range)!==null&&N!==void 0?N:true,uriResolver:de}}var mr=class{constructor(t={}){this.schemas={},this.refs={},this.formats={},this._compilations=new Set,this._loading={},this._cache=new Map,t=this.opts={...t,...mp(t)};let{es5:r,lines:n}=this.opts.code;this.scope=new up.ValueScope({scope:{},prefixes:lp,es5:r,lines:n}),this.logger=kp(t.logger);let s=t.validateFormats;t.validateFormats=false,this.RULES=(0, ip.getRules)(),Ti.call(this,fp,t,"NOT SUPPORTED"),Ti.call(this,pp,t,"DEPRECATED","warn"),this._metaOpts=vp.call(this),t.formats&&hp.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),t.keywords&&yp.call(this,t.keywords),typeof t.meta=="object"&&this.addMetaSchema(t.meta),gp.call(this),t.validateFormats=s;}_addVocabularies(){this.addKeyword("$async");}_addDefaultMetaSchema(){let{$data:t,meta:r,schemaId:n}=this.opts,s=Ei;n==="id"&&(s={...Ei},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 b=this._addSchema(d,l);return b.validate||a.call(this,b)}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 Ii.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, pr.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=Ai.call(this,t))=="string";)t=r;if(r===void 0){let{schemaId:n}=this.opts,s=new fr.SchemaEnv({schema:{},schemaId:n});if(r=fr.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=Ai.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, pr.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(Sp.call(this,n,r),!r)return (0, Ns.eachItem)(n,o=>js.call(this,o)),this;Rp.call(this,r);let s={...r,type:(0, rn.getJSONTypes)(r.type),schemaType:(0, rn.getJSONTypes)(r.schemaType)};return (0, Ns.eachItem)(n,s.type.length===0?o=>js.call(this,o,s):o=>s.type.forEach(a=>js.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]=Oi(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, pr.normalizeId)(a||n);let c=pr.getSchemaRefs.call(this,t,n);return u=new fr.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):fr.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{fr.compileSchema.call(this,t);}finally{this.opts=r;}}};mr.ValidationError=ap.default;mr.MissingRefError=Ii.default;ue.default=mr;function Ti(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 Ai(e){return e=(0, pr.normalizeId)(e),this.schemas[e]||this.refs[e]}function gp(){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 hp(){for(let e in this.opts.formats){let t=this.opts.formats[e];t&&this.addFormat(e,t);}}function yp(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 vp(){let e={...this.opts};for(let t of dp)delete e[t];return e}var bp={log(){},warn(){},error(){}};function kp(e){if(e===false)return bp;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 wp=/^[a-z_$][a-z0-9_$:-]*$/i;function Sp(e,t){let{RULES:r}=this;if((0, Ns.eachItem)(e,n=>{if(r.keywords[n])throw new Error(`Keyword ${n} is already defined`);if(!wp.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 js(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, rn.getJSONTypes)(t.type),schemaType:(0, rn.getJSONTypes)(t.schemaType)}};t.before?_p.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 _p(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 Rp(e){let{metaSchema:t}=e;t!==void 0&&(e.$data&&this.opts.$data&&(t=Oi(t)),e.validateSchema=this.compile(t,true));}var Cp={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function Oi(e){return {anyOf:[e,Cp]}}});var Ni=x(qs=>{Object.defineProperty(qs,"__esModule",{value:true});var $p={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};qs.default=$p;});var Mi=x(St=>{Object.defineProperty(St,"__esModule",{value:true});St.callRef=St.getValidate=void 0;var Ep=dr(),qi=xe(),ke=B(),Ft=Ke(),Di=Xr(),nn=z(),xp={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=Di.resolveRef.call(u,c,s,r);if(d===void 0)throw new Ep.default(n.opts.uriResolver,s,r);if(d instanceof Di.SchemaEnv)return b(d);return v(d);function l(){if(o===c)return sn(e,a,o,o.$async);let m=t.scopeValue("root",{ref:c});return sn(e,(0, ke._)`${m}.validate`,c,c.$async)}function b(m){let p=Fi(e,m);sn(e,p,m,m.$async);}function v(m){let p=t.scopeValue("schema",i.code.source===true?{ref:m,code:(0, ke.stringify)(m)}:{ref:m}),k=t.name("valid"),g=e.subschema({schema:m,dataTypes:[],schemaPath:ke.nil,topSchemaRef:p,errSchemaPath:r},k);e.mergeEvaluated(g),e.ok(k);}}};function Fi(e,t){let{gen:r}=e;return t.validate?r.scopeValue("validate",{ref:t.validate}):(0, ke._)`${r.scopeValue("wrapper",{ref:t})}.validate`}St.getValidate=Fi;function sn(e,t,r,n){let{gen:s,it:o}=e,{allErrors:a,schemaEnv:i,opts:u}=o,c=u.passContext?Ft.default.this:ke.nil;n?d():l();function d(){if(!i.$async)throw new Error("async schema referenced by sync schema");let m=s.let("valid");s.try(()=>{s.code((0, ke._)`await ${(0, qi.callValidateCode)(e,t,c)}`),v(t),a||s.assign(m,true);},p=>{s.if((0, ke._)`!(${p} instanceof ${o.ValidationError})`,()=>s.throw(p)),b(p),a||s.assign(m,false);}),e.ok(m);}function l(){e.result((0, qi.callValidateCode)(e,t,c),()=>v(t),()=>b(t));}function b(m){let p=(0, ke._)`${m}.errors`;s.assign(Ft.default.vErrors,(0, ke._)`${Ft.default.vErrors} === null ? ${p} : ${Ft.default.vErrors}.concat(${p})`),s.assign(Ft.default.errors,(0, ke._)`${Ft.default.vErrors}.length`);}function v(m){var p;if(!o.opts.unevaluated)return;let k=(p=r?.validate)===null||p===void 0?void 0:p.evaluated;if(o.props!==true)if(k&&!k.dynamicProps)k.props!==void 0&&(o.props=nn.mergeEvaluated.props(s,k.props,o.props));else {let g=s.var("props",(0, ke._)`${m}.evaluated.props`);o.props=nn.mergeEvaluated.props(s,g,o.props,ke.Name);}if(o.items!==true)if(k&&!k.dynamicItems)k.items!==void 0&&(o.items=nn.mergeEvaluated.items(s,k.items,o.items));else {let g=s.var("items",(0, ke._)`${m}.evaluated.items`);o.items=nn.mergeEvaluated.items(s,g,o.items,ke.Name);}}}St.callRef=sn;St.default=xp;});var Li=x(Ds=>{Object.defineProperty(Ds,"__esModule",{value:true});var Tp=Ni(),Ap=Mi(),Ip=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",Tp.default,Ap.default];Ds.default=Ip;});var Vi=x(Fs=>{Object.defineProperty(Fs,"__esModule",{value:true});var on=B(),ot=on.operators,an={maximum:{okStr:"<=",ok:ot.LTE,fail:ot.GT},minimum:{okStr:">=",ok:ot.GTE,fail:ot.LT},exclusiveMaximum:{okStr:"<",ok:ot.LT,fail:ot.GTE},exclusiveMinimum:{okStr:">",ok:ot.GT,fail:ot.LTE}},Pp={message:({keyword:e,schemaCode:t})=>(0, on.str)`must be ${an[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0, on._)`{comparison: ${an[e].okStr}, limit: ${t}}`},Op={keyword:Object.keys(an),type:"number",schemaType:"number",$data:true,error:Pp,code(e){let{keyword:t,data:r,schemaCode:n}=e;e.fail$data((0, on._)`${r} ${an[t].fail} ${n} || isNaN(${r})`);}};Fs.default=Op;});var Bi=x(Ms=>{Object.defineProperty(Ms,"__esModule",{value:true});var gr=B(),jp={message:({schemaCode:e})=>(0, gr.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0, gr._)`{multipleOf: ${e}}`},Np={keyword:"multipleOf",type:"number",schemaType:"number",$data:true,error:jp,code(e){let{gen:t,data:r,schemaCode:n,it:s}=e,o=s.opts.multipleOfPrecision,a=t.let("res"),i=o?(0, gr._)`Math.abs(Math.round(${a}) - ${a}) > 1e-${o}`:(0, gr._)`${a} !== parseInt(${a})`;e.fail$data((0, gr._)`(${n} === 0 || (${a} = ${r}/${n}, ${i}))`);}};Ms.default=Np;});var Ki=x(Ls=>{Object.defineProperty(Ls,"__esModule",{value:true});function Gi(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}Ls.default=Gi;Gi.code='require("ajv/dist/runtime/ucs2length").default';});var Ui=x(Vs=>{Object.defineProperty(Vs,"__esModule",{value:true});var _t=B(),qp=z(),Dp=Ki(),Fp={message({keyword:e,schemaCode:t}){let r=e==="maxLength"?"more":"fewer";return (0, _t.str)`must NOT have ${r} than ${t} characters`},params:({schemaCode:e})=>(0, _t._)`{limit: ${e}}`},Mp={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:true,error:Fp,code(e){let{keyword:t,data:r,schemaCode:n,it:s}=e,o=t==="maxLength"?_t.operators.GT:_t.operators.LT,a=s.opts.unicode===false?(0, _t._)`${r}.length`:(0, _t._)`${(0, qp.useFunc)(e.gen,Dp.default)}(${r})`;e.fail$data((0, _t._)`${a} ${o} ${n}`);}};Vs.default=Mp;});var Ji=x(Bs=>{Object.defineProperty(Bs,"__esModule",{value:true});var Lp=xe(),Vp=z(),Mt=B(),Bp={message:({schemaCode:e})=>(0, Mt.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0, Mt._)`{pattern: ${e}}`},Gp={keyword:"pattern",type:"string",schemaType:"string",$data:true,error:Bp,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, Mt._)`new RegExp`:(0, Vp.useFunc)(t,u),d=t.let("valid");t.try(()=>t.assign(d,(0, Mt._)`${c}(${o}, ${i}).test(${r})`),()=>t.assign(d,false)),e.fail$data((0, Mt._)`!${d}`);}else {let u=(0, Lp.usePattern)(e,s);e.fail$data((0, Mt._)`!${u}.test(${r})`);}}};Bs.default=Gp;});var zi=x(Gs=>{Object.defineProperty(Gs,"__esModule",{value:true});var hr=B(),Kp={message({keyword:e,schemaCode:t}){let r=e==="maxProperties"?"more":"fewer";return (0, hr.str)`must NOT have ${r} than ${t} properties`},params:({schemaCode:e})=>(0, hr._)`{limit: ${e}}`},Up={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:true,error:Kp,code(e){let{keyword:t,data:r,schemaCode:n}=e,s=t==="maxProperties"?hr.operators.GT:hr.operators.LT;e.fail$data((0, hr._)`Object.keys(${r}).length ${s} ${n}`);}};Gs.default=Up;});var Hi=x(Ks=>{Object.defineProperty(Ks,"__esModule",{value:true});var yr=xe(),vr=B(),Jp=z(),zp={message:({params:{missingProperty:e}})=>(0, vr.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0, vr._)`{missingProperty: ${e}}`},Hp={keyword:"required",type:"object",schemaType:"array",$data:true,error:zp,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:m}=e.it;for(let p of r)if(v?.[p]===void 0&&!m.has(p)){let k=a.schemaEnv.baseId+a.errSchemaPath,g=`required property "${p}" is not defined at "${k}" (strictRequired)`;(0, Jp.checkStrictMode)(a,g,a.opts.strictRequired);}}function c(){if(u||o)e.block$data(vr.nil,l);else for(let v of r)(0, yr.checkReportMissingProp)(e,v);}function d(){let v=t.let("missing");if(u||o){let m=t.let("valid",true);e.block$data(m,()=>b(v,m)),e.ok(m);}else t.if((0, yr.checkMissingProp)(e,r,v)),(0, yr.reportMissingProp)(e,v),t.else();}function l(){t.forOf("prop",n,v=>{e.setParams({missingProperty:v}),t.if((0, yr.noPropertyInData)(t,s,v,i.ownProperties),()=>e.error());});}function b(v,m){e.setParams({missingProperty:v}),t.forOf(v,n,()=>{t.assign(m,(0, yr.propertyInData)(t,s,v,i.ownProperties)),t.if((0, vr.not)(m),()=>{e.error(),t.break();});},vr.nil);}}};Ks.default=Hp;});var Wi=x(Us=>{Object.defineProperty(Us,"__esModule",{value:true});var br=B(),Wp={message({keyword:e,schemaCode:t}){let r=e==="maxItems"?"more":"fewer";return (0, br.str)`must NOT have ${r} than ${t} items`},params:({schemaCode:e})=>(0, br._)`{limit: ${e}}`},Yp={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:true,error:Wp,code(e){let{keyword:t,data:r,schemaCode:n}=e,s=t==="maxItems"?br.operators.GT:br.operators.LT;e.fail$data((0, br._)`${r}.length ${s} ${n}`);}};Us.default=Yp;});var un=x(Js=>{Object.defineProperty(Js,"__esModule",{value:true});var Yi=hs();Yi.code='require("ajv/dist/runtime/equal").default';Js.default=Yi;});var Xi=x(Hs=>{Object.defineProperty(Hs,"__esModule",{value:true});var zs=or(),ce=B(),Xp=z(),Qp=un(),Zp={message:({params:{i:e,j:t}})=>(0, ce.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0, ce._)`{i: ${e}, j: ${t}}`},em={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:true,error:Zp,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, zs.getSchemaTypes)(o.items):[];e.block$data(u,d,(0, ce._)`${a} === false`),e.ok(u);function d(){let m=t.let("i",(0, ce._)`${r}.length`),p=t.let("j");e.setParams({i:m,j:p}),t.assign(u,true),t.if((0, ce._)`${m} > 1`,()=>(l()?b:v)(m,p));}function l(){return c.length>0&&!c.some(m=>m==="object"||m==="array")}function b(m,p){let k=t.name("item"),g=(0, zs.checkDataTypes)(c,k,i.opts.strictNumbers,zs.DataType.Wrong),f=t.const("indices",(0, ce._)`{}`);t.for((0, ce._)`;${m}--;`,()=>{t.let(k,(0, ce._)`${r}[${m}]`),t.if(g,(0, ce._)`continue`),c.length>1&&t.if((0, ce._)`typeof ${k} == "string"`,(0, ce._)`${k} += "_"`),t.if((0, ce._)`typeof ${f}[${k}] == "number"`,()=>{t.assign(p,(0, ce._)`${f}[${k}]`),e.error(),t.assign(u,false).break();}).code((0, ce._)`${f}[${k}] = ${m}`);});}function v(m,p){let k=(0, Xp.useFunc)(t,Qp.default),g=t.name("outer");t.label(g).for((0, ce._)`;${m}--;`,()=>t.for((0, ce._)`${p} = ${m}; ${p}--;`,()=>t.if((0, ce._)`${k}(${r}[${m}], ${r}[${p}])`,()=>{e.error(),t.assign(u,false).break(g);})));}}};Hs.default=em;});var Qi=x(Ys=>{Object.defineProperty(Ys,"__esModule",{value:true});var Ws=B(),tm=z(),rm=un(),nm={message:"must be equal to constant",params:({schemaCode:e})=>(0, Ws._)`{allowedValue: ${e}}`},sm={keyword:"const",$data:true,error:nm,code(e){let{gen:t,data:r,$data:n,schemaCode:s,schema:o}=e;n||o&&typeof o=="object"?e.fail$data((0, Ws._)`!${(0, tm.useFunc)(t,rm.default)}(${r}, ${s})`):e.fail((0, Ws._)`${o} !== ${r}`);}};Ys.default=sm;});var Zi=x(Xs=>{Object.defineProperty(Xs,"__esModule",{value:true});var kr=B(),om=z(),am=un(),im={message:"must be equal to one of the allowed values",params:({schemaCode:e})=>(0, kr._)`{allowedValues: ${e}}`},um={keyword:"enum",schemaType:"array",$data:true,error:im,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, om.useFunc)(t,am.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, kr.or)(...s.map((m,p)=>b(v,p)));}e.pass(d);function l(){t.assign(d,false),t.forOf("v",o,v=>t.if((0, kr._)`${c()}(${r}, ${v})`,()=>t.assign(d,true).break()));}function b(v,m){let p=s[m];return typeof p=="object"&&p!==null?(0, kr._)`${c()}(${r}, ${v}[${m}])`:(0, kr._)`${r} === ${p}`}}};Xs.default=um;});var eu=x(Qs=>{Object.defineProperty(Qs,"__esModule",{value:true});var cm=Vi(),dm=Bi(),lm=Ui(),fm=Ji(),pm=zi(),mm=Hi(),gm=Wi(),hm=Xi(),ym=Qi(),vm=Zi(),bm=[cm.default,dm.default,lm.default,fm.default,pm.default,mm.default,gm.default,hm.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},ym.default,vm.default];Qs.default=bm;});var eo=x(wr=>{Object.defineProperty(wr,"__esModule",{value:true});wr.validateAdditionalItems=void 0;var Rt=B(),Zs=z(),km={message:({params:{len:e}})=>(0, Rt.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0, Rt._)`{limit: ${e}}`},wm={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:km,code(e){let{parentSchema:t,it:r}=e,{items:n}=t;if(!Array.isArray(n)){(0, Zs.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}tu(e,n);}};function tu(e,t){let{gen:r,schema:n,data:s,keyword:o,it:a}=e;a.items=true;let i=r.const("len",(0, Rt._)`${s}.length`);if(n===false)e.setParams({len:t.length}),e.pass((0, Rt._)`${i} <= ${t.length}`);else if(typeof n=="object"&&!(0, Zs.alwaysValidSchema)(a,n)){let c=r.var("valid",(0, Rt._)`${i} <= ${t.length}`);r.if((0, Rt.not)(c),()=>u(c)),e.ok(c);}function u(c){r.forRange("i",t.length,i,d=>{e.subschema({keyword:o,dataProp:d,dataPropType:Zs.Type.Num},c),a.allErrors||r.if((0, Rt.not)(c),()=>r.break());});}}wr.validateAdditionalItems=tu;wr.default=wm;});var to=x(Sr=>{Object.defineProperty(Sr,"__esModule",{value:true});Sr.validateTuple=void 0;var ru=B(),cn=z(),Sm=xe(),_m={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){let{schema:t,it:r}=e;if(Array.isArray(t))return nu(e,"additionalItems",t);r.items=true,!(0, cn.alwaysValidSchema)(r,t)&&e.ok((0, Sm.validateArray)(e));}};function nu(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=cn.mergeEvaluated.items(n,r.length,i.items));let u=n.name("valid"),c=n.const("len",(0, ru._)`${o}.length`);r.forEach((l,b)=>{(0, cn.alwaysValidSchema)(i,l)||(n.if((0, ru._)`${c} > ${b}`,()=>e.subschema({keyword:a,schemaProp:b,dataProp:b},u)),e.ok(u));});function d(l){let{opts:b,errSchemaPath:v}=i,m=r.length,p=m===l.minItems&&(m===l.maxItems||l[t]===false);if(b.strictTuples&&!p){let k=`"${a}" is ${m}-tuple, but minItems or maxItems/${t} are not specified or different at path "${v}"`;(0, cn.checkStrictMode)(i,k,b.strictTuples);}}}Sr.validateTuple=nu;Sr.default=_m;});var su=x(ro=>{Object.defineProperty(ro,"__esModule",{value:true});var Rm=to(),Cm={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:e=>(0, Rm.validateTuple)(e,"items")};ro.default=Cm;});var au=x(no=>{Object.defineProperty(no,"__esModule",{value:true});var ou=B(),$m=z(),Em=xe(),xm=eo(),Tm={message:({params:{len:e}})=>(0, ou.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0, ou._)`{limit: ${e}}`},Am={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:Tm,code(e){let{schema:t,parentSchema:r,it:n}=e,{prefixItems:s}=r;n.items=true,!(0, $m.alwaysValidSchema)(n,t)&&(s?(0, xm.validateAdditionalItems)(e,s):e.ok((0, Em.validateArray)(e)));}};no.default=Am;});var iu=x(so=>{Object.defineProperty(so,"__esModule",{value:true});var Ae=B(),dn=z(),Im={message:({params:{min:e,max:t}})=>t===void 0?(0, Ae.str)`must contain at least ${e} valid item(s)`:(0, Ae.str)`must contain at least ${e} and no more than ${t} valid item(s)`,params:({params:{min:e,max:t}})=>t===void 0?(0, Ae._)`{minContains: ${e}}`:(0, Ae._)`{minContains: ${e}, maxContains: ${t}}`},Pm={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:true,error:Im,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, Ae._)`${s}.length`);if(e.setParams({min:a,max:i}),i===void 0&&a===0){(0, dn.checkStrictMode)(o,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(i!==void 0&&a>i){(0, dn.checkStrictMode)(o,'"minContains" > "maxContains" is always invalid'),e.fail();return}if((0, dn.alwaysValidSchema)(o,r)){let p=(0, Ae._)`${d} >= ${a}`;i!==void 0&&(p=(0, Ae._)`${p} && ${d} <= ${i}`),e.pass(p);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, Ae._)`${s}.length > 0`,b)):(t.let(l,false),b()),e.result(l,()=>e.reset());function b(){let p=t.name("_valid"),k=t.let("count",0);v(p,()=>t.if(p,()=>m(k)));}function v(p,k){t.forRange("i",0,d,g=>{e.subschema({keyword:"contains",dataProp:g,dataPropType:dn.Type.Num,compositeRule:true},p),k();});}function m(p){t.code((0, Ae._)`${p}++`),i===void 0?t.if((0, Ae._)`${p} >= ${a}`,()=>t.assign(l,true).break()):(t.if((0, Ae._)`${p} > ${i}`,()=>t.assign(l,false).break()),a===1?t.assign(l,true):t.if((0, Ae._)`${p} >= ${a}`,()=>t.assign(l,true)));}}};so.default=Pm;});var du=x(Le=>{Object.defineProperty(Le,"__esModule",{value:true});Le.validateSchemaDeps=Le.validatePropertyDeps=Le.error=void 0;var oo=B(),Om=z(),_r=xe();Le.error={message:({params:{property:e,depsCount:t,deps:r}})=>{let n=t===1?"property":"properties";return (0, oo.str)`must have ${n} ${r} when property ${e} is present`},params:({params:{property:e,depsCount:t,deps:r,missingProperty:n}})=>(0, oo._)`{property: ${e},
5
+ || ${a} === "boolean" || ${s} === null`).assign(i,(0, L._)`[${s}]`);}}}function pl({gen:e,parentData:t,parentDataProperty:r},n){e.if((0, L._)`${t} !== undefined`,()=>e.assign((0, L._)`${t}[${r}]`,n));}function ds(e,t,r,n=Ot.Correct){let s=n===Ot.Correct?L.operators.EQ:L.operators.NEQ,o;switch(e){case "null":return (0, L._)`${t} ${s} null`;case "array":o=(0, L._)`Array.isArray(${t})`;break;case "object":o=(0, L._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case "integer":o=a((0, L._)`!(${t} % 1) && !isNaN(${t})`);break;case "number":o=a();break;default:return (0, L._)`typeof ${t} ${s} ${e}`}return n===Ot.Correct?o:(0, L.not)(o);function a(i=L.nil){return (0, L.and)((0, L._)`typeof ${t} == "number"`,i,r?(0, L._)`isFinite(${t})`:L.nil)}}me.checkDataType=ds;function ls(e,t,r,n){if(e.length===1)return ds(e[0],t,r,n);let s,o=(0, Pa.toHash)(e);if(o.array&&o.object){let a=(0, L._)`typeof ${t} != "object"`;s=o.null?a:(0, L._)`!${t} || ${a}`,delete o.null,delete o.array,delete o.object;}else s=L.nil;o.number&&delete o.integer;for(let a in o)s=(0, L.and)(s,ds(a,t,r,n));return s}me.checkDataTypes=ls;var ml={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e=="string"?(0, L._)`{type: ${e}}`:(0, L._)`{type: ${t}}`};function fs(e){let t=gl(e);(0, ul.reportError)(t,ml);}me.reportTypeError=fs;function gl(e){let{gen:t,data:r,schema:n}=e,s=(0, Pa.schemaRefOrVal)(e,n,"type");return {gen:t,keyword:"type",data:r,schema:n.type,schemaCode:s,schemaValue:s,parentSchema:n,params:{},it:e}}});var qa=x(Ur=>{Object.defineProperty(Ur,"__esModule",{value:true});Ur.assignDefaults=void 0;var jt=B(),hl=z();function yl(e,t){let{properties:r,items:n}=e.schema;if(t==="object"&&r)for(let s in r)Na(e,s,r[s].default);else t==="array"&&Array.isArray(n)&&n.forEach((s,o)=>Na(e,o,s.default));}Ur.assignDefaults=yl;function Na(e,t,r){let{gen:n,compositeRule:s,data:o,opts:a}=e;if(r===void 0)return;let i=(0, jt._)`${o}${(0, jt.getProperty)(t)}`;if(s){(0, hl.checkStrictMode)(e,`default is ignored for: ${i}`);return}let u=(0, jt._)`${i} === undefined`;a.useDefaults==="empty"&&(u=(0, jt._)`${u} || ${i} === null || ${i} === ""`),n.if(u,(0, jt._)`${i} = ${(0, jt.stringify)(r)}`);}});var Te=x(Y=>{Object.defineProperty(Y,"__esModule",{value:true});Y.validateUnion=Y.validateArray=Y.usePattern=Y.callValidateCode=Y.schemaProperties=Y.allSchemaProperties=Y.noPropertyInData=Y.propertyInData=Y.isOwnProperty=Y.hasPropFunc=Y.reportMissingProp=Y.checkMissingProp=Y.checkReportMissingProp=void 0;var re=B(),ps=z(),tt=Ge(),vl=z();function kl(e,t){let{gen:r,data:n,it:s}=e;r.if(gs(r,n,t,s.opts.ownProperties),()=>{e.setParams({missingProperty:(0, re._)`${t}`},true),e.error();});}Y.checkReportMissingProp=kl;function bl({gen:e,data:t,it:{opts:r}},n,s){return (0, re.or)(...n.map(o=>(0, re.and)(gs(e,t,o,r.ownProperties),(0, re._)`${s} = ${o}`)))}Y.checkMissingProp=bl;function Sl(e,t){e.setParams({missingProperty:t},true),e.error();}Y.reportMissingProp=Sl;function Da(e){return e.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0, re._)`Object.prototype.hasOwnProperty`})}Y.hasPropFunc=Da;function ms(e,t,r){return (0, re._)`${Da(e)}.call(${t}, ${r})`}Y.isOwnProperty=ms;function wl(e,t,r,n){let s=(0, re._)`${t}${(0, re.getProperty)(r)} !== undefined`;return n?(0, re._)`${s} && ${ms(e,t,r)}`:s}Y.propertyInData=wl;function gs(e,t,r,n){let s=(0, re._)`${t}${(0, re.getProperty)(r)} === undefined`;return n?(0, re.or)(s,(0, re.not)(ms(e,t,r))):s}Y.noPropertyInData=gs;function Fa(e){return e?Object.keys(e).filter(t=>t!=="__proto__"):[]}Y.allSchemaProperties=Fa;function _l(e,t){return Fa(t).filter(r=>!(0, ps.alwaysValidSchema)(e,t[r]))}Y.schemaProperties=_l;function Rl({schemaCode:e,data:t,it:{gen:r,topSchemaRef:n,schemaPath:s,errorPath:o},it:a},i,u,c){let d=c?(0, re._)`${e}, ${t}, ${n}${s}`:t,l=[[tt.default.instancePath,(0, re.strConcat)(tt.default.instancePath,o)],[tt.default.parentData,a.parentData],[tt.default.parentDataProperty,a.parentDataProperty],[tt.default.rootData,tt.default.rootData]];a.opts.dynamicRef&&l.push([tt.default.dynamicAnchors,tt.default.dynamicAnchors]);let k=(0, re._)`${d}, ${r.object(...l)}`;return u!==re.nil?(0, re._)`${i}.call(${u}, ${k})`:(0, re._)`${i}(${k})`}Y.callValidateCode=Rl;var Cl=(0, re._)`new RegExp`;function $l({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, re._)`${s.code==="new RegExp"?Cl:(0, vl.useFunc)(e,s)}(${r}, ${n})`})}Y.usePattern=$l;function El(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, re._)`${r}.length`);t.forRange("i",0,u,c=>{e.subschema({keyword:n,dataProp:c,dataPropType:ps.Type.Num},o),t.if((0, re.not)(o),i);});}}Y.validateArray=El;function xl(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, ps.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, re._)`${a} || ${i}`),e.mergeValidEvaluated(d,i)||t.if((0, re.not)(a));})),e.result(a,()=>e.reset(),()=>e.error(true));}Y.validateUnion=xl;});var Va=x(De=>{Object.defineProperty(De,"__esModule",{value:true});De.validateKeywordUsage=De.validSchemaType=De.funcKeywordCode=De.macroKeywordCode=void 0;var he=B(),bt=Ge(),Tl=Te(),Al=sr();function Il(e,t){let{gen:r,keyword:n,schema:s,parentSchema:o,it:a}=e,i=t.macro.call(a.self,s,o,a),u=La(r,n,i);a.opts.validateSchema!==false&&a.self.validateSchema(i,true);let c=r.name("valid");e.subschema({schema:i,schemaPath:he.nil,errSchemaPath:`${a.errSchemaPath}/${n}`,topSchemaRef:u,compositeRule:true},c),e.pass(c,()=>e.error(true));}De.macroKeywordCode=Il;function Pl(e,t){var r;let{gen:n,keyword:s,schema:o,parentSchema:a,$data:i,it:u}=e;jl(u,t);let c=!i&&t.compile?t.compile.call(u.self,o,a,u):t.validate,d=La(n,s,c),l=n.let("valid");e.block$data(l,k),e.ok((r=t.valid)!==null&&r!==void 0?r:l);function k(){if(t.errors===false)p(),t.modifying&&Ma(e),b(()=>e.error());else {let g=t.async?v():m();t.modifying&&Ma(e),b(()=>Ol(e,g));}}function v(){let g=n.let("ruleErrs",null);return n.try(()=>p((0, he._)`await `),f=>n.assign(l,false).if((0, he._)`${f} instanceof ${u.ValidationError}`,()=>n.assign(g,(0, he._)`${f}.errors`),()=>n.throw(f))),g}function m(){let g=(0, he._)`${d}.errors`;return n.assign(g,null),p(he.nil),g}function p(g=t.async?(0, he._)`await `:he.nil){let f=u.opts.passContext?bt.default.this:bt.default.self,y=!("compile"in t&&!i||t.schema===false);n.assign(l,(0, he._)`${g}${(0, Tl.callValidateCode)(e,d,f,y)}`,t.modifying);}function b(g){var f;n.if((0, he.not)((f=t.valid)!==null&&f!==void 0?f:l),g);}}De.funcKeywordCode=Pl;function Ma(e){let{gen:t,data:r,it:n}=e;t.if(n.parentData,()=>t.assign(r,(0, he._)`${n.parentData}[${n.parentDataProperty}]`));}function Ol(e,t){let{gen:r}=e;r.if((0, he._)`Array.isArray(${t})`,()=>{r.assign(bt.default.vErrors,(0, he._)`${bt.default.vErrors} === null ? ${t} : ${bt.default.vErrors}.concat(${t})`).assign(bt.default.errors,(0, he._)`${bt.default.vErrors}.length`),(0, Al.extendErrors)(e);},()=>e.error());}function jl({schemaEnv:e},t){if(t.async&&!e.$async)throw new Error("async keyword in sync schema")}function La(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, he.stringify)(r)})}function Nl(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")}De.validSchemaType=Nl;function ql({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)}}De.validateKeywordUsage=ql;});var Ga=x(rt=>{Object.defineProperty(rt,"__esModule",{value:true});rt.extendSubschemaMode=rt.extendSubschemaData=rt.getSubschema=void 0;var Fe=B(),Ba=z();function Dl(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, Fe._)`${e.schemaPath}${(0, Fe.getProperty)(t)}`,errSchemaPath:`${e.errSchemaPath}/${t}`}:{schema:i[r],schemaPath:(0, Fe._)`${e.schemaPath}${(0, Fe.getProperty)(t)}${(0, Fe.getProperty)(r)}`,errSchemaPath:`${e.errSchemaPath}/${t}/${(0, Ba.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')}rt.getSubschema=Dl;function Fl(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,k=i.let("data",(0, Fe._)`${t.data}${(0, Fe.getProperty)(r)}`,true);u(k),e.errorPath=(0, Fe.str)`${c}${(0, Ba.getErrorPath)(r,n,l.jsPropertySyntax)}`,e.parentDataProperty=(0, Fe._)`${r}`,e.dataPathArr=[...d,e.parentDataProperty];}if(s!==void 0){let c=s instanceof Fe.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];}}rt.extendSubschemaData=Fl;function Ml(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;}rt.extendSubschemaMode=Ml;});var hs=x((Ly,Ka)=>{Ka.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 Ja=x((Vy,Ua)=>{var nt=Ua.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(){};Jr(t,n,s,e,"",e);};nt.keywords={additionalItems:true,items:true,contains:true,additionalProperties:true,propertyNames:true,not:true,if:true,then:true,else:true};nt.arrayKeywords={items:true,allOf:true,anyOf:true,oneOf:true};nt.propsKeywords={$defs:true,definitions:true,properties:true,patternProperties:true,dependencies:true};nt.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 Jr(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 nt.arrayKeywords)for(var k=0;k<l.length;k++)Jr(e,t,r,l[k],s+"/"+d+"/"+k,o,s,d,n,k);}else if(d in nt.propsKeywords){if(l&&typeof l=="object")for(var v in l)Jr(e,t,r,l[v],s+"/"+d+"/"+Ll(v),o,s,d,n,v);}else (d in nt.keywords||e.allKeys&&!(d in nt.skipKeywords))&&Jr(e,t,r,l,s+"/"+d,o,s,d,n);}r(n,s,o,a,i,u,c);}}function Ll(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}});var ar=x(ke=>{Object.defineProperty(ke,"__esModule",{value:true});ke.getSchemaRefs=ke.resolveUrl=ke.normalizeId=ke._getFullPath=ke.getFullPath=ke.inlineRef=void 0;var Vl=z(),Bl=hs(),Gl=Ja(),Kl=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function Ul(e,t=true){return typeof e=="boolean"?true:t===true?!ys(e):t?za(e)<=t:false}ke.inlineRef=Ul;var Jl=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function ys(e){for(let t in e){if(Jl.has(t))return true;let r=e[t];if(Array.isArray(r)&&r.some(ys)||typeof r=="object"&&ys(r))return true}return false}function za(e){let t=0;for(let r in e){if(r==="$ref")return 1/0;if(t++,!Kl.has(r)&&(typeof e[r]=="object"&&(0, Vl.eachItem)(e[r],n=>t+=za(n)),t===1/0))return 1/0}return t}function Ha(e,t="",r){r!==false&&(t=Nt(t));let n=e.parse(t);return Wa(e,n)}ke.getFullPath=Ha;function Wa(e,t){return e.serialize(t).split("#")[0]+"#"}ke._getFullPath=Wa;var zl=/#\/?$/;function Nt(e){return e?e.replace(zl,""):""}ke.normalizeId=Nt;function Hl(e,t,r){return r=Nt(r),e.resolve(t,r)}ke.resolveUrl=Hl;var Wl=/^[a-z_][-a-z0-9._]*$/i;function Yl(e,t){if(typeof e=="boolean")return {};let{schemaId:r,uriResolver:n}=this.opts,s=Nt(e[r]||t),o={"":s},a=Ha(n,s,false),i={},u=new Set;return Gl(e,{allKeys:true},(l,k,v,m)=>{if(m===void 0)return;let p=a+k,b=o[m];typeof l[r]=="string"&&(b=g.call(this,l[r])),f.call(this,l.$anchor),f.call(this,l.$dynamicAnchor),o[k]=b;function g(y){let _=this.opts.uriResolver.resolve;if(y=Nt(b?_(b,y):y),u.has(y))throw d(y);u.add(y);let S=this.refs[y];return typeof S=="string"&&(S=this.refs[S]),typeof S=="object"?c(l,S.schema,y):y!==Nt(p)&&(y[0]==="#"?(c(l,i[y],y),i[y]=l):this.refs[y]=p),y}function f(y){if(typeof y=="string"){if(!Wl.test(y))throw new Error(`invalid anchor "${y}"`);g.call(this,`#${y}`);}}}),i;function c(l,k,v){if(k!==void 0&&!Bl(l,k))throw d(v)}function d(l){return new Error(`reference "${l}" resolves to more than one schema`)}}ke.getSchemaRefs=Yl;});var cr=x(st=>{Object.defineProperty(st,"__esModule",{value:true});st.getData=st.KeywordCxt=st.validateFunctionCode=void 0;var ei=Ta(),Ya=or(),ks=cs(),zr=or(),Xl=qa(),ur=Va(),vs=Ga(),A=B(),O=Ge(),Ql=ar(),Ke=z(),ir=sr();function Zl(e){if(ni(e)&&(si(e),ri(e))){rf(e);return}ti(e,()=>(0, ei.topBoolOrEmptySchema)(e));}st.validateFunctionCode=Zl;function ti({gen:e,validateName:t,schema:r,schemaEnv:n,opts:s},o){s.code.es5?e.func(t,(0, A._)`${O.default.data}, ${O.default.valCxt}`,n.$async,()=>{e.code((0, A._)`"use strict"; ${Xa(r,s)}`),tf(e,s),e.code(o);}):e.func(t,(0, A._)`${O.default.data}, ${ef(s)}`,n.$async,()=>e.code(Xa(r,s)).code(o));}function ef(e){return (0, A._)`{${O.default.instancePath}="", ${O.default.parentData}, ${O.default.parentDataProperty}, ${O.default.rootData}=${O.default.data}${e.dynamicRef?(0, A._)`, ${O.default.dynamicAnchors}={}`:A.nil}}={}`}function tf(e,t){e.if(O.default.valCxt,()=>{e.var(O.default.instancePath,(0, A._)`${O.default.valCxt}.${O.default.instancePath}`),e.var(O.default.parentData,(0, A._)`${O.default.valCxt}.${O.default.parentData}`),e.var(O.default.parentDataProperty,(0, A._)`${O.default.valCxt}.${O.default.parentDataProperty}`),e.var(O.default.rootData,(0, A._)`${O.default.valCxt}.${O.default.rootData}`),t.dynamicRef&&e.var(O.default.dynamicAnchors,(0, A._)`${O.default.valCxt}.${O.default.dynamicAnchors}`);},()=>{e.var(O.default.instancePath,(0, A._)`""`),e.var(O.default.parentData,(0, A._)`undefined`),e.var(O.default.parentDataProperty,(0, A._)`undefined`),e.var(O.default.rootData,O.default.data),t.dynamicRef&&e.var(O.default.dynamicAnchors,(0, A._)`{}`);});}function rf(e){let{schema:t,opts:r,gen:n}=e;ti(e,()=>{r.$comment&&t.$comment&&ai(e),uf(e),n.let(O.default.vErrors,null),n.let(O.default.errors,0),r.unevaluated&&nf(e),oi(e),lf(e);});}function nf(e){let{gen:t,validateName:r}=e;e.evaluated=t.const("evaluated",(0, A._)`${r}.evaluated`),t.if((0, A._)`${e.evaluated}.dynamicProps`,()=>t.assign((0, A._)`${e.evaluated}.props`,(0, A._)`undefined`)),t.if((0, A._)`${e.evaluated}.dynamicItems`,()=>t.assign((0, A._)`${e.evaluated}.items`,(0, A._)`undefined`));}function Xa(e,t){let r=typeof e=="object"&&e[t.schemaId];return r&&(t.code.source||t.code.process)?(0, A._)`/*# sourceURL=${r} */`:A.nil}function sf(e,t){if(ni(e)&&(si(e),ri(e))){of(e,t);return}(0, ei.boolOrEmptySchema)(e,t);}function ri({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 ni(e){return typeof e.schema!="boolean"}function of(e,t){let{schema:r,gen:n,opts:s}=e;s.$comment&&r.$comment&&ai(e),cf(e),df(e);let o=n.const("_errs",O.default.errors);oi(e,o),n.var(t,(0, A._)`${o} === ${O.default.errors}`);}function si(e){(0, Ke.checkUnknownRules)(e),af(e);}function oi(e,t){if(e.opts.jtd)return Qa(e,[],false,t);let r=(0, Ya.getSchemaTypes)(e.schema),n=(0, Ya.coerceAndCheckDataType)(e,r);Qa(e,r,!n,t);}function af(e){let{schema:t,errSchemaPath:r,opts:n,self:s}=e;t.$ref&&n.ignoreKeywordsWithRef&&(0, Ke.schemaHasRulesButRef)(t,s.RULES)&&s.logger.warn(`$ref: keywords ignored in schema at path "${r}"`);}function uf(e){let{schema:t,opts:r}=e;t.default!==void 0&&r.useDefaults&&r.strictSchema&&(0, Ke.checkStrictMode)(e,"default is ignored in the schema root");}function cf(e){let t=e.schema[e.opts.schemaId];t&&(e.baseId=(0, Ql.resolveUrl)(e.opts.uriResolver,e.baseId,t));}function df(e){if(e.schema.$async&&!e.schemaEnv.$async)throw new Error("async schema in sync schema")}function ai({gen:e,schemaEnv:t,schema:r,errSchemaPath:n,opts:s}){let o=r.$comment;if(s.$comment===true)e.code((0, A._)`${O.default.self}.logger.log(${o})`);else if(typeof s.$comment=="function"){let a=(0, A.str)`${n}/$comment`,i=e.scopeValue("root",{ref:t.root});e.code((0, A._)`${O.default.self}.opts.$comment(${o}, ${a}, ${i}.schema)`);}}function lf(e){let{gen:t,schemaEnv:r,validateName:n,ValidationError:s,opts:o}=e;r.$async?t.if((0, A._)`${O.default.errors} === 0`,()=>t.return(O.default.data),()=>t.throw((0, A._)`new ${s}(${O.default.vErrors})`)):(t.assign((0, A._)`${n}.errors`,O.default.vErrors),o.unevaluated&&ff(e),t.return((0, A._)`${O.default.errors} === 0`));}function ff({gen:e,evaluated:t,props:r,items:n}){r instanceof A.Name&&e.assign((0, A._)`${t}.props`,r),n instanceof A.Name&&e.assign((0, A._)`${t}.items`,n);}function Qa(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, Ke.schemaHasRulesButRef)(o,d))){s.block(()=>ui(e,"$ref",d.all.$ref.definition));return}u.jtd||pf(e,t),s.block(()=>{for(let k of d.rules)l(k);l(d.post);});function l(k){(0, ks.shouldUseGroup)(o,k)&&(k.type?(s.if((0, zr.checkDataType)(k.type,a,u.strictNumbers)),Za(e,k),t.length===1&&t[0]===k.type&&r&&(s.else(),(0, zr.reportTypeError)(e)),s.endIf()):Za(e,k),i||s.if((0, A._)`${O.default.errors} === ${n||0}`));}}function Za(e,t){let{gen:r,schema:n,opts:{useDefaults:s}}=e;s&&(0, Xl.assignDefaults)(e,t.type),r.block(()=>{for(let o of t.rules)(0, ks.shouldUseRule)(n,o)&&ui(e,o.keyword,o.definition,t.type);});}function pf(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(mf(e,t),e.opts.allowUnionTypes||gf(e,t),hf(e,e.dataTypes));}function mf(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(r=>{ii(e.dataTypes,r)||bs(e,`type "${r}" not allowed by context "${e.dataTypes.join(",")}"`);}),vf(e,t);}}function gf(e,t){t.length>1&&!(t.length===2&&t.includes("null"))&&bs(e,"use allowUnionTypes to allow union type keyword");}function hf(e,t){let r=e.self.RULES.all;for(let n in r){let s=r[n];if(typeof s=="object"&&(0, ks.shouldUseRule)(e.schema,s)){let{type:o}=s.definition;o.length&&!o.some(a=>yf(t,a))&&bs(e,`missing type "${o.join(",")}" for keyword "${n}"`);}}}function yf(e,t){return e.includes(t)||t==="number"&&e.includes("integer")}function ii(e,t){return e.includes(t)||t==="integer"&&e.includes("number")}function vf(e,t){let r=[];for(let n of e.dataTypes)ii(t,n)?r.push(n):t.includes("integer")&&n==="number"&&r.push("integer");e.dataTypes=r;}function bs(e,t){let r=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${r}" (strictTypes)`,(0, Ke.checkStrictMode)(e,t,e.opts.strictTypes);}var Hr=class{constructor(t,r,n){if((0, ur.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, Ke.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",ci(this.$data,t));else if(this.schemaCode=this.schemaValue,!(0, ur.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",O.default.errors));}result(t,r,n){this.failResult((0, A.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, A.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, A._)`${r} !== undefined && (${(0, A.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?ir.reportExtraError:ir.reportError)(this,this.def.error,r);}$dataError(){(0, ir.reportError)(this,this.def.$dataError||ir.keyword$DataError);}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0, ir.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=A.nil){this.gen.block(()=>{this.check$data(t,n),r();});}check$data(t=A.nil,r=A.nil){if(!this.$data)return;let{gen:n,schemaCode:s,schemaType:o,def:a}=this;n.if((0, A.or)((0, A._)`${s} === undefined`,r)),t!==A.nil&&n.assign(t,true),(o.length||a.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),t!==A.nil&&n.assign(t,false)),n.else();}invalid$data(){let{gen:t,schemaCode:r,schemaType:n,def:s,it:o}=this;return (0, A.or)(a(),i());function a(){if(n.length){if(!(r instanceof A.Name))throw new Error("ajv implementation error");let u=Array.isArray(n)?n:[n];return (0, A._)`${(0, zr.checkDataTypes)(u,r,o.opts.strictNumbers,zr.DataType.Wrong)}`}return A.nil}function i(){if(s.validateSchema){let u=t.scopeValue("validate$data",{ref:s.validateSchema});return (0, A._)`!${u}(${r})`}return A.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 sf(s,r),s}mergeEvaluated(t,r){let{it:n,gen:s}=this;n.opts.unevaluated&&(n.props!==true&&t.props!==void 0&&(n.props=Ke.mergeEvaluated.props(s,t.props,n.props,r)),n.items!==true&&t.items!==void 0&&(n.items=Ke.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,A.Name)),true}};st.KeywordCxt=Hr;function ui(e,t,r,n){let s=new Hr(e,r,t);"code"in r?r.code(s,n):s.$data&&r.validate?(0, ur.funcKeywordCode)(s,r):"macro"in r?(0, ur.macroKeywordCode)(s,r):(r.compile||r.validate)&&(0, ur.funcKeywordCode)(s,r);}var kf=/^\/(?:[^~]|~0|~1)*$/,bf=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function ci(e,{dataLevel:t,dataNames:r,dataPathArr:n}){let s,o;if(e==="")return O.default.rootData;if(e[0]==="/"){if(!kf.test(e))throw new Error(`Invalid JSON-pointer: ${e}`);s=e,o=O.default.rootData;}else {let c=bf.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, A._)`${o}${(0, A.getProperty)((0, Ke.unescapeJsonPointer)(c))}`,a=(0, A._)`${a} && ${o}`);return a;function u(c,d){return `Cannot access ${c} ${d} levels up, current level is ${t}`}}st.getData=ci;});var Wr=x(ws=>{Object.defineProperty(ws,"__esModule",{value:true});var Ss=class extends Error{constructor(t){super("validation failed"),this.errors=t,this.ajv=this.validation=true;}};ws.default=Ss;});var dr=x(Cs=>{Object.defineProperty(Cs,"__esModule",{value:true});var _s=ar(),Rs=class extends Error{constructor(t,r,n,s){super(s||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0, _s.resolveUrl)(t,r,n),this.missingSchema=(0, _s.normalizeId)((0, _s.getFullPath)(t,this.missingRef));}};Cs.default=Rs;});var Xr=x(Ae=>{Object.defineProperty(Ae,"__esModule",{value:true});Ae.resolveSchema=Ae.getCompilingSchema=Ae.resolveRef=Ae.compileSchema=Ae.SchemaEnv=void 0;var Oe=B(),Sf=Wr(),St=Ge(),je=ar(),di=z(),wf=cr(),qt=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, je.normalizeId)(n?.[t.schemaId||"$id"]),this.schemaPath=t.schemaPath,this.localRefs=t.localRefs,this.meta=t.meta,this.$async=n?.$async,this.refs={};}};Ae.SchemaEnv=qt;function Es(e){let t=li.call(this,e);if(t)return t;let r=(0, je.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:n,lines:s}=this.opts.code,{ownProperties:o}=this.opts,a=new Oe.CodeGen(this.scope,{es5:n,lines:s,ownProperties:o}),i;e.$async&&(i=a.scopeValue("Error",{ref:Sf.default,code:(0, Oe._)`require("ajv/dist/runtime/validation_error").default`}));let u=a.scopeName("validate");e.validateName=u;let c={gen:a,allErrors:this.opts.allErrors,data:St.default.data,parentData:St.default.parentData,parentDataProperty:St.default.parentDataProperty,dataNames:[St.default.data],dataPathArr:[Oe.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:a.scopeValue("schema",this.opts.code.source===true?{ref:e.schema,code:(0, Oe.stringify)(e.schema)}:{ref:e.schema}),validateName:u,ValidationError:i,schema:e.schema,schemaEnv:e,rootId:r,baseId:e.baseId||r,schemaPath:Oe.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0, Oe._)`""`,opts:this.opts,self:this},d;try{this._compilations.add(e),(0,wf.validateFunctionCode)(c),a.optimize(this.opts.code.optimize);let l=a.toString();d=`${a.scopeRefs(St.default.scope)}return ${l}`,this.opts.code.process&&(d=this.opts.code.process(d,e));let v=new Function(`${St.default.self}`,`${St.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:m,items:p}=c;v.evaluated={props:m instanceof Oe.Name?void 0:m,items:p instanceof Oe.Name?void 0:p,dynamicProps:m instanceof Oe.Name,dynamicItems:p instanceof Oe.Name},v.source&&(v.source.evaluated=(0,Oe.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);}}Ae.compileSchema=Es;function _f(e,t,r){var n;r=(0, je.resolveUrl)(this.opts.uriResolver,t,r);let s=e.refs[r];if(s)return s;let o=$f.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 qt({schema:a,schemaId:i,root:e,baseId:t}));}if(o!==void 0)return e.refs[r]=Rf.call(this,o)}Ae.resolveRef=_f;function Rf(e){return (0, je.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:Es.call(this,e)}function li(e){for(let t of this._compilations)if(Cf(t,e))return t}Ae.getCompilingSchema=li;function Cf(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function $f(e,t){let r;for(;typeof(r=this.refs[t])=="string";)t=r;return r||this.schemas[t]||Yr.call(this,e,t)}function Yr(e,t){let r=this.opts.uriResolver.parse(t),n=(0, je._getFullPath)(this.opts.uriResolver,r),s=(0, je.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&n===s)return $s.call(this,r,e);let o=(0, je.normalizeId)(n),a=this.refs[o]||this.schemas[o];if(typeof a=="string"){let i=Yr.call(this,e,a);return typeof i?.schema!="object"?void 0:$s.call(this,r,i)}if(typeof a?.schema=="object"){if(a.validate||Es.call(this,a),o===(0, je.normalizeId)(t)){let{schema:i}=a,{schemaId:u}=this.opts,c=i[u];return c&&(s=(0, je.resolveUrl)(this.opts.uriResolver,s,c)),new qt({schema:i,schemaId:u,root:e,baseId:s})}return $s.call(this,r,a)}}Ae.resolveSchema=Yr;var Ef=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function $s(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, di.unescapeFragment)(i)];if(u===void 0)return;r=u;let c=typeof r=="object"&&r[this.opts.schemaId];!Ef.has(i)&&c&&(t=(0, je.resolveUrl)(this.opts.uriResolver,t,c));}let o;if(typeof r!="boolean"&&r.$ref&&!(0, di.schemaHasRulesButRef)(r,this.RULES)){let i=(0, je.resolveUrl)(this.opts.uriResolver,t,r.$ref);o=Yr.call(this,n,i);}let{schemaId:a}=this.opts;if(o=o||new qt({schema:r,schemaId:a,root:n,baseId:t}),o.schema!==o.root.schema)return o}});var fi=x((zy,xf)=>{xf.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 Ts=x((Hy,hi)=>{var Tf=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),mi=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 xs(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 Af=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function pi(e){return e.length=0,true}function If(e,t,r){if(e.length){let n=xs(e);if(n!=="")t.push(n);else return r.error=true,false;e.length=0;}return true}function Pf(e){let t=0,r={error:false,address:"",zone:""},n=[],s=[],o=false,a=false,i=If;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=pi;}else {s.push(c);continue}}return s.length&&(i===pi?r.zone=s.join(""):a?n.push(s.join("")):n.push(xs(s))),r.address=n.join(""),r}function gi(e){if(Of(e,":")<2)return {host:e,isIPV6:false};let t=Pf(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 Of(e,t){let r=0;for(let n=0;n<e.length;n++)e[n]===t&&r++;return r}function jf(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 Nf(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 qf(e){let t=[];if(e.userinfo!==void 0&&(t.push(e.userinfo),t.push("@")),e.host!==void 0){let r=unescape(e.host);if(!mi(r)){let n=gi(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}hi.exports={nonSimpleDomain:Af,recomposeAuthority:qf,normalizeComponentEncoding:Nf,removeDotSegments:jf,isIPv4:mi,isUUID:Tf,normalizeIPv6:gi,stringArrayToHexStripped:xs};});var Si=x((Wy,bi)=>{var{isUUID:Df}=Ts(),Ff=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,Mf=["http","https","ws","wss","urn","urn:uuid"];function Lf(e){return Mf.indexOf(e)!==-1}function As(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 yi(e){return e.host||(e.error=e.error||"HTTP URIs must have a host."),e}function vi(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 Vf(e){return e.secure=As(e),e.resourceName=(e.path||"/")+(e.query?"?"+e.query:""),e.path=void 0,e.query=void 0,e}function Bf(e){if((e.port===(As(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 Gf(e,t){if(!e.path)return e.error="URN can not be parsed",e;let r=e.path.match(Ff);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=Is(s);e.path=void 0,o&&(e=o.parse(e,t));}else e.error=e.error||"URN can not be parsed.";return e}function Kf(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=Is(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 Uf(e,t){let r=e;return r.uuid=r.nss,r.nss=void 0,!t.tolerant&&(!r.uuid||!Df(r.uuid))&&(r.error=r.error||"UUID is not valid."),r}function Jf(e){let t=e;return t.nss=(e.uuid||"").toLowerCase(),t}var ki={scheme:"http",domainHost:true,parse:yi,serialize:vi},zf={scheme:"https",domainHost:ki.domainHost,parse:yi,serialize:vi},Qr={scheme:"ws",domainHost:true,parse:Vf,serialize:Bf},Hf={scheme:"wss",domainHost:Qr.domainHost,parse:Qr.parse,serialize:Qr.serialize},Wf={scheme:"urn",parse:Gf,serialize:Kf,skipNormalize:true},Yf={scheme:"urn:uuid",parse:Uf,serialize:Jf,skipNormalize:true},Zr={http:ki,https:zf,ws:Qr,wss:Hf,urn:Wf,"urn:uuid":Yf};Object.setPrototypeOf(Zr,null);function Is(e){return e&&(Zr[e]||Zr[e.toLowerCase()])||void 0}bi.exports={wsIsSecure:As,SCHEMES:Zr,isValidSchemeName:Lf,getSchemeHandler:Is};});var Ri=x((Yy,tn)=>{var{normalizeIPv6:Xf,removeDotSegments:lr,recomposeAuthority:Qf,normalizeComponentEncoding:en,isIPv4:Zf,nonSimpleDomain:ep}=Ts(),{SCHEMES:tp,getSchemeHandler:wi}=Si();function rp(e,t){return typeof e=="string"?e=Me(Ue(e,t),t):typeof e=="object"&&(e=Ue(Me(e,t),t)),e}function np(e,t,r){let n=r?Object.assign({scheme:"null"},r):{scheme:"null"},s=_i(Ue(e,n),Ue(t,n),n,true);return n.skipEscape=true,Me(s,n)}function _i(e,t,r,n){let s={};return n||(e=Ue(Me(e,r),r),t=Ue(Me(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=lr(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=lr(t.path||""),s.query=t.query):(t.path?(t.path[0]==="/"?s.path=lr(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=lr(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 sp(e,t,r){return typeof e=="string"?(e=unescape(e),e=Me(en(Ue(e,r),true),{...r,skipEscape:true})):typeof e=="object"&&(e=Me(en(e,true),{...r,skipEscape:true})),typeof t=="string"?(t=unescape(t),t=Me(en(Ue(t,r),true),{...r,skipEscape:true})):typeof t=="object"&&(t=Me(en(t,true),{...r,skipEscape:true})),e.toLowerCase()===t.toLowerCase()}function Me(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=Qf(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=lr(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 op=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function Ue(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(op);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(Zf(n.host)===false){let u=Xf(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&&ep(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 Ps={SCHEMES:tp,normalize:rp,resolve:np,resolveComponent:_i,equal:sp,serialize:Me,parse:Ue};tn.exports=Ps;tn.exports.default=Ps;tn.exports.fastUri=Ps;});var $i=x(Os=>{Object.defineProperty(Os,"__esModule",{value:true});var Ci=Ri();Ci.code='require("ajv/dist/runtime/uri").default';Os.default=Ci;});var ji=x(ue=>{Object.defineProperty(ue,"__esModule",{value:true});ue.CodeGen=ue.Name=ue.nil=ue.stringify=ue.str=ue._=ue.KeywordCxt=void 0;var ap=cr();Object.defineProperty(ue,"KeywordCxt",{enumerable:true,get:function(){return ap.KeywordCxt}});var Dt=B();Object.defineProperty(ue,"_",{enumerable:true,get:function(){return Dt._}});Object.defineProperty(ue,"str",{enumerable:true,get:function(){return Dt.str}});Object.defineProperty(ue,"stringify",{enumerable:true,get:function(){return Dt.stringify}});Object.defineProperty(ue,"nil",{enumerable:true,get:function(){return Dt.nil}});Object.defineProperty(ue,"Name",{enumerable:true,get:function(){return Dt.Name}});Object.defineProperty(ue,"CodeGen",{enumerable:true,get:function(){return Dt.CodeGen}});var ip=Wr(),Ii=dr(),up=us(),fr=Xr(),cp=B(),pr=ar(),rn=or(),Ns=z(),Ei=fi(),dp=$i(),Pi=(e,t)=>new RegExp(e,t);Pi.code="new RegExp";var lp=["removeAdditional","useDefaults","coerceTypes"],fp=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),pp={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."},mp={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},xi=200;function gp(e){var t,r,n,s,o,a,i,u,c,d,l,k,v,m,p,b,g,f,y,_,S,$,R,E,N;let D=e.strict,M=(t=e.code)===null||t===void 0?void 0:t.optimize,te=M===true||M===void 0?1:M||0,U=(n=(r=e.code)===null||r===void 0?void 0:r.regExp)!==null&&n!==void 0?n:Pi,de=(s=e.uriResolver)!==null&&s!==void 0?s:dp.default;return {strictSchema:(a=(o=e.strictSchema)!==null&&o!==void 0?o:D)!==null&&a!==void 0?a:true,strictNumbers:(u=(i=e.strictNumbers)!==null&&i!==void 0?i:D)!==null&&u!==void 0?u:true,strictTypes:(d=(c=e.strictTypes)!==null&&c!==void 0?c:D)!==null&&d!==void 0?d:"log",strictTuples:(k=(l=e.strictTuples)!==null&&l!==void 0?l:D)!==null&&k!==void 0?k:"log",strictRequired:(m=(v=e.strictRequired)!==null&&v!==void 0?v:D)!==null&&m!==void 0?m:false,code:e.code?{...e.code,optimize:te,regExp:U}:{optimize:te,regExp:U},loopRequired:(p=e.loopRequired)!==null&&p!==void 0?p:xi,loopEnum:(b=e.loopEnum)!==null&&b!==void 0?b:xi,meta:(g=e.meta)!==null&&g!==void 0?g:true,messages:(f=e.messages)!==null&&f!==void 0?f:true,inlineRefs:(y=e.inlineRefs)!==null&&y!==void 0?y:true,schemaId:(_=e.schemaId)!==null&&_!==void 0?_:"$id",addUsedSchema:(S=e.addUsedSchema)!==null&&S!==void 0?S:true,validateSchema:($=e.validateSchema)!==null&&$!==void 0?$:true,validateFormats:(R=e.validateFormats)!==null&&R!==void 0?R:true,unicodeRegExp:(E=e.unicodeRegExp)!==null&&E!==void 0?E:true,int32range:(N=e.int32range)!==null&&N!==void 0?N:true,uriResolver:de}}var mr=class{constructor(t={}){this.schemas={},this.refs={},this.formats={},this._compilations=new Set,this._loading={},this._cache=new Map,t=this.opts={...t,...gp(t)};let{es5:r,lines:n}=this.opts.code;this.scope=new cp.ValueScope({scope:{},prefixes:fp,es5:r,lines:n}),this.logger=Sp(t.logger);let s=t.validateFormats;t.validateFormats=false,this.RULES=(0, up.getRules)(),Ti.call(this,pp,t,"NOT SUPPORTED"),Ti.call(this,mp,t,"DEPRECATED","warn"),this._metaOpts=kp.call(this),t.formats&&yp.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),t.keywords&&vp.call(this,t.keywords),typeof t.meta=="object"&&this.addMetaSchema(t.meta),hp.call(this),t.validateFormats=s;}_addVocabularies(){this.addKeyword("$async");}_addDefaultMetaSchema(){let{$data:t,meta:r,schemaId:n}=this.opts,s=Ei;n==="id"&&(s={...Ei},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 k=this._addSchema(d,l);return k.validate||a.call(this,k)}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 Ii.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, pr.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=Ai.call(this,t))=="string";)t=r;if(r===void 0){let{schemaId:n}=this.opts,s=new fr.SchemaEnv({schema:{},schemaId:n});if(r=fr.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=Ai.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, pr.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(_p.call(this,n,r),!r)return (0, Ns.eachItem)(n,o=>js.call(this,o)),this;Cp.call(this,r);let s={...r,type:(0, rn.getJSONTypes)(r.type),schemaType:(0, rn.getJSONTypes)(r.schemaType)};return (0, Ns.eachItem)(n,s.type.length===0?o=>js.call(this,o,s):o=>s.type.forEach(a=>js.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]=Oi(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, pr.normalizeId)(a||n);let c=pr.getSchemaRefs.call(this,t,n);return u=new fr.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):fr.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{fr.compileSchema.call(this,t);}finally{this.opts=r;}}};mr.ValidationError=ip.default;mr.MissingRefError=Ii.default;ue.default=mr;function Ti(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 Ai(e){return e=(0, pr.normalizeId)(e),this.schemas[e]||this.refs[e]}function hp(){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 yp(){for(let e in this.opts.formats){let t=this.opts.formats[e];t&&this.addFormat(e,t);}}function vp(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 kp(){let e={...this.opts};for(let t of lp)delete e[t];return e}var bp={log(){},warn(){},error(){}};function Sp(e){if(e===false)return bp;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 wp=/^[a-z_$][a-z0-9_$:-]*$/i;function _p(e,t){let{RULES:r}=this;if((0, Ns.eachItem)(e,n=>{if(r.keywords[n])throw new Error(`Keyword ${n} is already defined`);if(!wp.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 js(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, rn.getJSONTypes)(t.type),schemaType:(0, rn.getJSONTypes)(t.schemaType)}};t.before?Rp.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 Rp(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 Cp(e){let{metaSchema:t}=e;t!==void 0&&(e.$data&&this.opts.$data&&(t=Oi(t)),e.validateSchema=this.compile(t,true));}var $p={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function Oi(e){return {anyOf:[e,$p]}}});var Ni=x(qs=>{Object.defineProperty(qs,"__esModule",{value:true});var Ep={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};qs.default=Ep;});var Mi=x(wt=>{Object.defineProperty(wt,"__esModule",{value:true});wt.callRef=wt.getValidate=void 0;var xp=dr(),qi=Te(),be=B(),Ft=Ge(),Di=Xr(),nn=z(),Tp={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=Di.resolveRef.call(u,c,s,r);if(d===void 0)throw new xp.default(n.opts.uriResolver,s,r);if(d instanceof Di.SchemaEnv)return k(d);return v(d);function l(){if(o===c)return sn(e,a,o,o.$async);let m=t.scopeValue("root",{ref:c});return sn(e,(0, be._)`${m}.validate`,c,c.$async)}function k(m){let p=Fi(e,m);sn(e,p,m,m.$async);}function v(m){let p=t.scopeValue("schema",i.code.source===true?{ref:m,code:(0, be.stringify)(m)}:{ref:m}),b=t.name("valid"),g=e.subschema({schema:m,dataTypes:[],schemaPath:be.nil,topSchemaRef:p,errSchemaPath:r},b);e.mergeEvaluated(g),e.ok(b);}}};function Fi(e,t){let{gen:r}=e;return t.validate?r.scopeValue("validate",{ref:t.validate}):(0, be._)`${r.scopeValue("wrapper",{ref:t})}.validate`}wt.getValidate=Fi;function sn(e,t,r,n){let{gen:s,it:o}=e,{allErrors:a,schemaEnv:i,opts:u}=o,c=u.passContext?Ft.default.this:be.nil;n?d():l();function d(){if(!i.$async)throw new Error("async schema referenced by sync schema");let m=s.let("valid");s.try(()=>{s.code((0, be._)`await ${(0, qi.callValidateCode)(e,t,c)}`),v(t),a||s.assign(m,true);},p=>{s.if((0, be._)`!(${p} instanceof ${o.ValidationError})`,()=>s.throw(p)),k(p),a||s.assign(m,false);}),e.ok(m);}function l(){e.result((0, qi.callValidateCode)(e,t,c),()=>v(t),()=>k(t));}function k(m){let p=(0, be._)`${m}.errors`;s.assign(Ft.default.vErrors,(0, be._)`${Ft.default.vErrors} === null ? ${p} : ${Ft.default.vErrors}.concat(${p})`),s.assign(Ft.default.errors,(0, be._)`${Ft.default.vErrors}.length`);}function v(m){var p;if(!o.opts.unevaluated)return;let b=(p=r?.validate)===null||p===void 0?void 0:p.evaluated;if(o.props!==true)if(b&&!b.dynamicProps)b.props!==void 0&&(o.props=nn.mergeEvaluated.props(s,b.props,o.props));else {let g=s.var("props",(0, be._)`${m}.evaluated.props`);o.props=nn.mergeEvaluated.props(s,g,o.props,be.Name);}if(o.items!==true)if(b&&!b.dynamicItems)b.items!==void 0&&(o.items=nn.mergeEvaluated.items(s,b.items,o.items));else {let g=s.var("items",(0, be._)`${m}.evaluated.items`);o.items=nn.mergeEvaluated.items(s,g,o.items,be.Name);}}}wt.callRef=sn;wt.default=Tp;});var Li=x(Ds=>{Object.defineProperty(Ds,"__esModule",{value:true});var Ap=Ni(),Ip=Mi(),Pp=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",Ap.default,Ip.default];Ds.default=Pp;});var Vi=x(Fs=>{Object.defineProperty(Fs,"__esModule",{value:true});var on=B(),ot=on.operators,an={maximum:{okStr:"<=",ok:ot.LTE,fail:ot.GT},minimum:{okStr:">=",ok:ot.GTE,fail:ot.LT},exclusiveMaximum:{okStr:"<",ok:ot.LT,fail:ot.GTE},exclusiveMinimum:{okStr:">",ok:ot.GT,fail:ot.LTE}},Op={message:({keyword:e,schemaCode:t})=>(0, on.str)`must be ${an[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0, on._)`{comparison: ${an[e].okStr}, limit: ${t}}`},jp={keyword:Object.keys(an),type:"number",schemaType:"number",$data:true,error:Op,code(e){let{keyword:t,data:r,schemaCode:n}=e;e.fail$data((0, on._)`${r} ${an[t].fail} ${n} || isNaN(${r})`);}};Fs.default=jp;});var Bi=x(Ms=>{Object.defineProperty(Ms,"__esModule",{value:true});var gr=B(),Np={message:({schemaCode:e})=>(0, gr.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0, gr._)`{multipleOf: ${e}}`},qp={keyword:"multipleOf",type:"number",schemaType:"number",$data:true,error:Np,code(e){let{gen:t,data:r,schemaCode:n,it:s}=e,o=s.opts.multipleOfPrecision,a=t.let("res"),i=o?(0, gr._)`Math.abs(Math.round(${a}) - ${a}) > 1e-${o}`:(0, gr._)`${a} !== parseInt(${a})`;e.fail$data((0, gr._)`(${n} === 0 || (${a} = ${r}/${n}, ${i}))`);}};Ms.default=qp;});var Ki=x(Ls=>{Object.defineProperty(Ls,"__esModule",{value:true});function Gi(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}Ls.default=Gi;Gi.code='require("ajv/dist/runtime/ucs2length").default';});var Ui=x(Vs=>{Object.defineProperty(Vs,"__esModule",{value:true});var _t=B(),Dp=z(),Fp=Ki(),Mp={message({keyword:e,schemaCode:t}){let r=e==="maxLength"?"more":"fewer";return (0, _t.str)`must NOT have ${r} than ${t} characters`},params:({schemaCode:e})=>(0, _t._)`{limit: ${e}}`},Lp={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:true,error:Mp,code(e){let{keyword:t,data:r,schemaCode:n,it:s}=e,o=t==="maxLength"?_t.operators.GT:_t.operators.LT,a=s.opts.unicode===false?(0, _t._)`${r}.length`:(0, _t._)`${(0, Dp.useFunc)(e.gen,Fp.default)}(${r})`;e.fail$data((0, _t._)`${a} ${o} ${n}`);}};Vs.default=Lp;});var Ji=x(Bs=>{Object.defineProperty(Bs,"__esModule",{value:true});var Vp=Te(),Bp=z(),Mt=B(),Gp={message:({schemaCode:e})=>(0, Mt.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0, Mt._)`{pattern: ${e}}`},Kp={keyword:"pattern",type:"string",schemaType:"string",$data:true,error:Gp,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, Mt._)`new RegExp`:(0, Bp.useFunc)(t,u),d=t.let("valid");t.try(()=>t.assign(d,(0, Mt._)`${c}(${o}, ${i}).test(${r})`),()=>t.assign(d,false)),e.fail$data((0, Mt._)`!${d}`);}else {let u=(0, Vp.usePattern)(e,s);e.fail$data((0, Mt._)`!${u}.test(${r})`);}}};Bs.default=Kp;});var zi=x(Gs=>{Object.defineProperty(Gs,"__esModule",{value:true});var hr=B(),Up={message({keyword:e,schemaCode:t}){let r=e==="maxProperties"?"more":"fewer";return (0, hr.str)`must NOT have ${r} than ${t} properties`},params:({schemaCode:e})=>(0, hr._)`{limit: ${e}}`},Jp={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:true,error:Up,code(e){let{keyword:t,data:r,schemaCode:n}=e,s=t==="maxProperties"?hr.operators.GT:hr.operators.LT;e.fail$data((0, hr._)`Object.keys(${r}).length ${s} ${n}`);}};Gs.default=Jp;});var Hi=x(Ks=>{Object.defineProperty(Ks,"__esModule",{value:true});var yr=Te(),vr=B(),zp=z(),Hp={message:({params:{missingProperty:e}})=>(0, vr.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0, vr._)`{missingProperty: ${e}}`},Wp={keyword:"required",type:"object",schemaType:"array",$data:true,error:Hp,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:m}=e.it;for(let p of r)if(v?.[p]===void 0&&!m.has(p)){let b=a.schemaEnv.baseId+a.errSchemaPath,g=`required property "${p}" is not defined at "${b}" (strictRequired)`;(0, zp.checkStrictMode)(a,g,a.opts.strictRequired);}}function c(){if(u||o)e.block$data(vr.nil,l);else for(let v of r)(0, yr.checkReportMissingProp)(e,v);}function d(){let v=t.let("missing");if(u||o){let m=t.let("valid",true);e.block$data(m,()=>k(v,m)),e.ok(m);}else t.if((0, yr.checkMissingProp)(e,r,v)),(0, yr.reportMissingProp)(e,v),t.else();}function l(){t.forOf("prop",n,v=>{e.setParams({missingProperty:v}),t.if((0, yr.noPropertyInData)(t,s,v,i.ownProperties),()=>e.error());});}function k(v,m){e.setParams({missingProperty:v}),t.forOf(v,n,()=>{t.assign(m,(0, yr.propertyInData)(t,s,v,i.ownProperties)),t.if((0, vr.not)(m),()=>{e.error(),t.break();});},vr.nil);}}};Ks.default=Wp;});var Wi=x(Us=>{Object.defineProperty(Us,"__esModule",{value:true});var kr=B(),Yp={message({keyword:e,schemaCode:t}){let r=e==="maxItems"?"more":"fewer";return (0, kr.str)`must NOT have ${r} than ${t} items`},params:({schemaCode:e})=>(0, kr._)`{limit: ${e}}`},Xp={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:true,error:Yp,code(e){let{keyword:t,data:r,schemaCode:n}=e,s=t==="maxItems"?kr.operators.GT:kr.operators.LT;e.fail$data((0, kr._)`${r}.length ${s} ${n}`);}};Us.default=Xp;});var un=x(Js=>{Object.defineProperty(Js,"__esModule",{value:true});var Yi=hs();Yi.code='require("ajv/dist/runtime/equal").default';Js.default=Yi;});var Xi=x(Hs=>{Object.defineProperty(Hs,"__esModule",{value:true});var zs=or(),ce=B(),Qp=z(),Zp=un(),em={message:({params:{i:e,j:t}})=>(0, ce.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0, ce._)`{i: ${e}, j: ${t}}`},tm={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:true,error:em,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, zs.getSchemaTypes)(o.items):[];e.block$data(u,d,(0, ce._)`${a} === false`),e.ok(u);function d(){let m=t.let("i",(0, ce._)`${r}.length`),p=t.let("j");e.setParams({i:m,j:p}),t.assign(u,true),t.if((0, ce._)`${m} > 1`,()=>(l()?k:v)(m,p));}function l(){return c.length>0&&!c.some(m=>m==="object"||m==="array")}function k(m,p){let b=t.name("item"),g=(0, zs.checkDataTypes)(c,b,i.opts.strictNumbers,zs.DataType.Wrong),f=t.const("indices",(0, ce._)`{}`);t.for((0, ce._)`;${m}--;`,()=>{t.let(b,(0, ce._)`${r}[${m}]`),t.if(g,(0, ce._)`continue`),c.length>1&&t.if((0, ce._)`typeof ${b} == "string"`,(0, ce._)`${b} += "_"`),t.if((0, ce._)`typeof ${f}[${b}] == "number"`,()=>{t.assign(p,(0, ce._)`${f}[${b}]`),e.error(),t.assign(u,false).break();}).code((0, ce._)`${f}[${b}] = ${m}`);});}function v(m,p){let b=(0, Qp.useFunc)(t,Zp.default),g=t.name("outer");t.label(g).for((0, ce._)`;${m}--;`,()=>t.for((0, ce._)`${p} = ${m}; ${p}--;`,()=>t.if((0, ce._)`${b}(${r}[${m}], ${r}[${p}])`,()=>{e.error(),t.assign(u,false).break(g);})));}}};Hs.default=tm;});var Qi=x(Ys=>{Object.defineProperty(Ys,"__esModule",{value:true});var Ws=B(),rm=z(),nm=un(),sm={message:"must be equal to constant",params:({schemaCode:e})=>(0, Ws._)`{allowedValue: ${e}}`},om={keyword:"const",$data:true,error:sm,code(e){let{gen:t,data:r,$data:n,schemaCode:s,schema:o}=e;n||o&&typeof o=="object"?e.fail$data((0, Ws._)`!${(0, rm.useFunc)(t,nm.default)}(${r}, ${s})`):e.fail((0, Ws._)`${o} !== ${r}`);}};Ys.default=om;});var Zi=x(Xs=>{Object.defineProperty(Xs,"__esModule",{value:true});var br=B(),am=z(),im=un(),um={message:"must be equal to one of the allowed values",params:({schemaCode:e})=>(0, br._)`{allowedValues: ${e}}`},cm={keyword:"enum",schemaType:"array",$data:true,error:um,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, am.useFunc)(t,im.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, br.or)(...s.map((m,p)=>k(v,p)));}e.pass(d);function l(){t.assign(d,false),t.forOf("v",o,v=>t.if((0, br._)`${c()}(${r}, ${v})`,()=>t.assign(d,true).break()));}function k(v,m){let p=s[m];return typeof p=="object"&&p!==null?(0, br._)`${c()}(${r}, ${v}[${m}])`:(0, br._)`${r} === ${p}`}}};Xs.default=cm;});var eu=x(Qs=>{Object.defineProperty(Qs,"__esModule",{value:true});var dm=Vi(),lm=Bi(),fm=Ui(),pm=Ji(),mm=zi(),gm=Hi(),hm=Wi(),ym=Xi(),vm=Qi(),km=Zi(),bm=[dm.default,lm.default,fm.default,pm.default,mm.default,gm.default,hm.default,ym.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},vm.default,km.default];Qs.default=bm;});var eo=x(Sr=>{Object.defineProperty(Sr,"__esModule",{value:true});Sr.validateAdditionalItems=void 0;var Rt=B(),Zs=z(),Sm={message:({params:{len:e}})=>(0, Rt.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0, Rt._)`{limit: ${e}}`},wm={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:Sm,code(e){let{parentSchema:t,it:r}=e,{items:n}=t;if(!Array.isArray(n)){(0, Zs.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}tu(e,n);}};function tu(e,t){let{gen:r,schema:n,data:s,keyword:o,it:a}=e;a.items=true;let i=r.const("len",(0, Rt._)`${s}.length`);if(n===false)e.setParams({len:t.length}),e.pass((0, Rt._)`${i} <= ${t.length}`);else if(typeof n=="object"&&!(0, Zs.alwaysValidSchema)(a,n)){let c=r.var("valid",(0, Rt._)`${i} <= ${t.length}`);r.if((0, Rt.not)(c),()=>u(c)),e.ok(c);}function u(c){r.forRange("i",t.length,i,d=>{e.subschema({keyword:o,dataProp:d,dataPropType:Zs.Type.Num},c),a.allErrors||r.if((0, Rt.not)(c),()=>r.break());});}}Sr.validateAdditionalItems=tu;Sr.default=wm;});var to=x(wr=>{Object.defineProperty(wr,"__esModule",{value:true});wr.validateTuple=void 0;var ru=B(),cn=z(),_m=Te(),Rm={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){let{schema:t,it:r}=e;if(Array.isArray(t))return nu(e,"additionalItems",t);r.items=true,!(0, cn.alwaysValidSchema)(r,t)&&e.ok((0, _m.validateArray)(e));}};function nu(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=cn.mergeEvaluated.items(n,r.length,i.items));let u=n.name("valid"),c=n.const("len",(0, ru._)`${o}.length`);r.forEach((l,k)=>{(0, cn.alwaysValidSchema)(i,l)||(n.if((0, ru._)`${c} > ${k}`,()=>e.subschema({keyword:a,schemaProp:k,dataProp:k},u)),e.ok(u));});function d(l){let{opts:k,errSchemaPath:v}=i,m=r.length,p=m===l.minItems&&(m===l.maxItems||l[t]===false);if(k.strictTuples&&!p){let b=`"${a}" is ${m}-tuple, but minItems or maxItems/${t} are not specified or different at path "${v}"`;(0, cn.checkStrictMode)(i,b,k.strictTuples);}}}wr.validateTuple=nu;wr.default=Rm;});var su=x(ro=>{Object.defineProperty(ro,"__esModule",{value:true});var Cm=to(),$m={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:e=>(0, Cm.validateTuple)(e,"items")};ro.default=$m;});var au=x(no=>{Object.defineProperty(no,"__esModule",{value:true});var ou=B(),Em=z(),xm=Te(),Tm=eo(),Am={message:({params:{len:e}})=>(0, ou.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0, ou._)`{limit: ${e}}`},Im={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:Am,code(e){let{schema:t,parentSchema:r,it:n}=e,{prefixItems:s}=r;n.items=true,!(0, Em.alwaysValidSchema)(n,t)&&(s?(0, Tm.validateAdditionalItems)(e,s):e.ok((0, xm.validateArray)(e)));}};no.default=Im;});var iu=x(so=>{Object.defineProperty(so,"__esModule",{value:true});var Ie=B(),dn=z(),Pm={message:({params:{min:e,max:t}})=>t===void 0?(0, Ie.str)`must contain at least ${e} valid item(s)`:(0, Ie.str)`must contain at least ${e} and no more than ${t} valid item(s)`,params:({params:{min:e,max:t}})=>t===void 0?(0, Ie._)`{minContains: ${e}}`:(0, Ie._)`{minContains: ${e}, maxContains: ${t}}`},Om={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:true,error:Pm,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, Ie._)`${s}.length`);if(e.setParams({min:a,max:i}),i===void 0&&a===0){(0, dn.checkStrictMode)(o,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(i!==void 0&&a>i){(0, dn.checkStrictMode)(o,'"minContains" > "maxContains" is always invalid'),e.fail();return}if((0, dn.alwaysValidSchema)(o,r)){let p=(0, Ie._)`${d} >= ${a}`;i!==void 0&&(p=(0, Ie._)`${p} && ${d} <= ${i}`),e.pass(p);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, Ie._)`${s}.length > 0`,k)):(t.let(l,false),k()),e.result(l,()=>e.reset());function k(){let p=t.name("_valid"),b=t.let("count",0);v(p,()=>t.if(p,()=>m(b)));}function v(p,b){t.forRange("i",0,d,g=>{e.subschema({keyword:"contains",dataProp:g,dataPropType:dn.Type.Num,compositeRule:true},p),b();});}function m(p){t.code((0, Ie._)`${p}++`),i===void 0?t.if((0, Ie._)`${p} >= ${a}`,()=>t.assign(l,true).break()):(t.if((0, Ie._)`${p} > ${i}`,()=>t.assign(l,false).break()),a===1?t.assign(l,true):t.if((0, Ie._)`${p} >= ${a}`,()=>t.assign(l,true)));}}};so.default=Om;});var du=x(Le=>{Object.defineProperty(Le,"__esModule",{value:true});Le.validateSchemaDeps=Le.validatePropertyDeps=Le.error=void 0;var oo=B(),jm=z(),_r=Te();Le.error={message:({params:{property:e,depsCount:t,deps:r}})=>{let n=t===1?"property":"properties";return (0, oo.str)`must have ${n} ${r} when property ${e} is present`},params:({params:{property:e,depsCount:t,deps:r,missingProperty:n}})=>(0, oo._)`{property: ${e},
6
6
  missingProperty: ${n},
7
7
  depsCount: ${t},
8
- deps: ${r}}`};var jm={keyword:"dependencies",type:"object",schemaType:"object",error:Le.error,code(e){let[t,r]=Nm(e);uu(e,t),cu(e,r);}};function Nm({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 uu(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, _r.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, _r.checkReportMissingProp)(e,c);}):(r.if((0, oo._)`${u} && (${(0, _r.checkMissingProp)(e,i,o)})`),(0, _r.reportMissingProp)(e,o),r.else());}}Le.validatePropertyDeps=uu;function cu(e,t=e.schema){let{gen:r,data:n,keyword:s,it:o}=e,a=r.name("valid");for(let i in t)(0, Om.alwaysValidSchema)(o,t[i])||(r.if((0, _r.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));}Le.validateSchemaDeps=cu;Le.default=jm;});var fu=x(ao=>{Object.defineProperty(ao,"__esModule",{value:true});var lu=B(),qm=z(),Dm={message:"property name must be valid",params:({params:e})=>(0, lu._)`{propertyName: ${e.propertyName}}`},Fm={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:Dm,code(e){let{gen:t,schema:r,data:n,it:s}=e;if((0, qm.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, lu.not)(o),()=>{e.error(true),s.allErrors||t.break();});}),e.ok(o);}};ao.default=Fm;});var uo=x(io=>{Object.defineProperty(io,"__esModule",{value:true});var ln=xe(),je=B(),Mm=Ke(),fn=z(),Lm={message:"must NOT have additional properties",params:({params:e})=>(0, je._)`{additionalProperty: ${e.additionalProperty}}`},Vm={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:true,trackErrors:true,error:Lm,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, fn.alwaysValidSchema)(a,r))return;let c=(0, ln.allSchemaProperties)(n.properties),d=(0, ln.allSchemaProperties)(n.patternProperties);l(),e.ok((0, je._)`${o} === ${Mm.default.errors}`);function l(){t.forIn("key",s,k=>{!c.length&&!d.length?m(k):t.if(b(k),()=>m(k));});}function b(k){let g;if(c.length>8){let f=(0, fn.schemaRefOrVal)(a,n.properties,"properties");g=(0, ln.isOwnProperty)(t,f,k);}else c.length?g=(0, je.or)(...c.map(f=>(0, je._)`${k} === ${f}`)):g=je.nil;return d.length&&(g=(0, je.or)(g,...d.map(f=>(0, je._)`${(0, ln.usePattern)(e,f)}.test(${k})`))),(0, je.not)(g)}function v(k){t.code((0, je._)`delete ${s}[${k}]`);}function m(k){if(u.removeAdditional==="all"||u.removeAdditional&&r===false){v(k);return}if(r===false){e.setParams({additionalProperty:k}),e.error(),i||t.break();return}if(typeof r=="object"&&!(0, fn.alwaysValidSchema)(a,r)){let g=t.name("valid");u.removeAdditional==="failing"?(p(k,g,false),t.if((0, je.not)(g),()=>{e.reset(),v(k);})):(p(k,g),i||t.if((0, je.not)(g),()=>t.break()));}}function p(k,g,f){let y={keyword:"additionalProperties",dataProp:k,dataPropType:fn.Type.Str};f===false&&Object.assign(y,{compositeRule:true,createErrors:false,allErrors:false}),e.subschema(y,g);}}};io.default=Vm;});var gu=x(lo=>{Object.defineProperty(lo,"__esModule",{value:true});var Bm=cr(),pu=xe(),co=z(),mu=uo(),Gm={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&&mu.default.code(new Bm.KeywordCxt(o,mu.default,"additionalProperties"));let a=(0, pu.allSchemaProperties)(r);for(let l of a)o.definedProperties.add(l);o.opts.unevaluated&&a.length&&o.props!==true&&(o.props=co.mergeEvaluated.props(t,(0, co.toHash)(a),o.props));let i=a.filter(l=>!(0, co.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, pu.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);}}};lo.default=Gm;});var bu=x(fo=>{Object.defineProperty(fo,"__esModule",{value:true});var hu=xe(),pn=B(),yu=z(),vu=z(),Km={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, hu.allSchemaProperties)(r),u=i.filter(p=>(0, yu.alwaysValidSchema)(o,r[p]));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, vu.evaluatedPropsToName)(t,o.props));let{props:l}=o;b();function b(){for(let p of i)c&&v(p),o.allErrors?m(p):(t.var(d,true),m(p),t.if(d));}function v(p){for(let k in c)new RegExp(p).test(k)&&(0, yu.checkStrictMode)(o,`property ${k} matches pattern ${p} (use allowMatchingProperties)`);}function m(p){t.forIn("key",n,k=>{t.if((0, pn._)`${(0, hu.usePattern)(e,p)}.test(${k})`,()=>{let g=u.includes(p);g||e.subschema({keyword:"patternProperties",schemaProp:p,dataProp:k,dataPropType:vu.Type.Str},d),o.opts.unevaluated&&l!==true?t.assign((0, pn._)`${l}[${k}]`,true):!g&&!o.allErrors&&t.if((0, pn.not)(d),()=>t.break());});});}}};fo.default=Km;});var ku=x(po=>{Object.defineProperty(po,"__esModule",{value:true});var Um=z(),Jm={keyword:"not",schemaType:["object","boolean"],trackErrors:true,code(e){let{gen:t,schema:r,it:n}=e;if((0, Um.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"}};po.default=Jm;});var wu=x(mo=>{Object.defineProperty(mo,"__esModule",{value:true});var zm=xe(),Hm={keyword:"anyOf",schemaType:"array",trackErrors:true,code:zm.validateUnion,error:{message:"must match a schema in anyOf"}};mo.default=Hm;});var Su=x(go=>{Object.defineProperty(go,"__esModule",{value:true});var mn=B(),Wm=z(),Ym={message:"must match exactly one schema in oneOf",params:({params:e})=>(0, mn._)`{passingSchemas: ${e.passing}}`},Xm={keyword:"oneOf",schemaType:"array",trackErrors:true,error:Ym,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 b;(0, Wm.alwaysValidSchema)(s,d)?t.var(u,true):b=e.subschema({keyword:"oneOf",schemaProp:l,compositeRule:true},u),l>0&&t.if((0, mn._)`${u} && ${a}`).assign(a,false).assign(i,(0, mn._)`[${i}, ${l}]`).else(),t.if(u,()=>{t.assign(a,true),t.assign(i,l),b&&e.mergeEvaluated(b,mn.Name);});});}}};go.default=Xm;});var _u=x(ho=>{Object.defineProperty(ho,"__esModule",{value:true});var Qm=z(),Zm={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, Qm.alwaysValidSchema)(n,o))return;let i=e.subschema({keyword:"allOf",schemaProp:a},s);e.ok(s),e.mergeEvaluated(i);});}};ho.default=Zm;});var $u=x(yo=>{Object.defineProperty(yo,"__esModule",{value:true});var gn=B(),Cu=z(),eg={message:({params:e})=>(0, gn.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0, gn._)`{failingKeyword: ${e.ifClause}}`},tg={keyword:"if",schemaType:["object","boolean"],trackErrors:true,error:eg,code(e){let{gen:t,parentSchema:r,it:n}=e;r.then===void 0&&r.else===void 0&&(0, Cu.checkStrictMode)(n,'"if" without "then" and "else" is ignored');let s=Ru(n,"then"),o=Ru(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, gn.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 b=e.subschema({keyword:d},i);t.assign(a,i),e.mergeValidEvaluated(b,a),l?t.assign(l,(0, gn._)`${d}`):e.setParams({ifClause:d});}}}};function Ru(e,t){let r=e.schema[t];return r!==void 0&&!(0, Cu.alwaysValidSchema)(e,r)}yo.default=tg;});var Eu=x(vo=>{Object.defineProperty(vo,"__esModule",{value:true});var rg=z(),ng={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:r}){t.if===void 0&&(0, rg.checkStrictMode)(r,`"${e}" without "if" is ignored`);}};vo.default=ng;});var xu=x(bo=>{Object.defineProperty(bo,"__esModule",{value:true});var sg=eo(),og=su(),ag=to(),ig=au(),ug=iu(),cg=du(),dg=fu(),lg=uo(),fg=gu(),pg=bu(),mg=ku(),gg=wu(),hg=Su(),yg=_u(),vg=$u(),bg=Eu();function kg(e=false){let t=[mg.default,gg.default,hg.default,yg.default,vg.default,bg.default,dg.default,lg.default,cg.default,fg.default,pg.default];return e?t.push(og.default,ig.default):t.push(sg.default,ag.default),t.push(ug.default),t}bo.default=kg;});var Tu=x(ko=>{Object.defineProperty(ko,"__esModule",{value:true});var ae=B(),wg={message:({schemaCode:e})=>(0, ae.str)`must match format "${e}"`,params:({schemaCode:e})=>(0, ae._)`{format: ${e}}`},Sg={keyword:"format",type:["number","string"],schemaType:"string",$data:true,error:wg,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?b():v();function b(){let m=r.scopeValue("formats",{ref:l.formats,code:u.code.formats}),p=r.const("fDef",(0, ae._)`${m}[${a}]`),k=r.let("fType"),g=r.let("format");r.if((0, ae._)`typeof ${p} == "object" && !(${p} instanceof RegExp)`,()=>r.assign(k,(0, ae._)`${p}.type || "string"`).assign(g,(0, ae._)`${p}.validate`),()=>r.assign(k,(0, ae._)`"string"`).assign(g,p)),e.fail$data((0, ae.or)(f(),y()));function f(){return u.strictSchema===false?ae.nil:(0, ae._)`${a} && !${g}`}function y(){let _=d.$async?(0, ae._)`(${p}.async ? await ${g}(${n}) : ${g}(${n}))`:(0, ae._)`${g}(${n})`,w=(0, ae._)`(typeof ${g} == "function" ? ${_} : ${g}.test(${n}))`;return (0, ae._)`${g} && ${g} !== true && ${k} === ${t} && !${w}`}}function v(){let m=l.formats[o];if(!m){f();return}if(m===true)return;let[p,k,g]=y(m);p===t&&e.pass(_());function f(){if(u.strictSchema===false){l.logger.warn(w());return}throw new Error(w());function w(){return `unknown format "${o}" ignored in schema at path "${c}"`}}function y(w){let C=w instanceof RegExp?(0, ae.regexpCode)(w):u.code.formats?(0, ae._)`${u.code.formats}${(0, ae.getProperty)(o)}`:void 0,R=r.scopeValue("formats",{key:o,ref:w,code:C});return typeof w=="object"&&!(w instanceof RegExp)?[w.type||"string",w.validate,(0, ae._)`${R}.validate`]:["string",w,R]}function _(){if(typeof m=="object"&&!(m instanceof RegExp)&&m.async){if(!d.$async)throw new Error("async format in sync schema");return (0, ae._)`await ${g}(${n})`}return typeof k=="function"?(0, ae._)`${g}(${n})`:(0, ae._)`${g}.test(${n})`}}}};ko.default=Sg;});var Au=x(wo=>{Object.defineProperty(wo,"__esModule",{value:true});var _g=Tu(),Rg=[_g.default];wo.default=Rg;});var Iu=x(Lt=>{Object.defineProperty(Lt,"__esModule",{value:true});Lt.contentVocabulary=Lt.metadataVocabulary=void 0;Lt.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];Lt.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"];});var Ou=x(So=>{Object.defineProperty(So,"__esModule",{value:true});var Cg=Li(),$g=eu(),Eg=xu(),xg=Au(),Pu=Iu(),Tg=[Cg.default,$g.default,(0, Eg.default)(),xg.default,Pu.metadataVocabulary,Pu.contentVocabulary];So.default=Tg;});var Nu=x(hn=>{Object.defineProperty(hn,"__esModule",{value:true});hn.DiscrError=void 0;var ju;(function(e){e.Tag="tag",e.Mapping="mapping";})(ju||(hn.DiscrError=ju={}));});var Du=x(Ro=>{Object.defineProperty(Ro,"__esModule",{value:true});var Vt=B(),_o=Nu(),qu=Xr(),Ag=dr(),Ig=z(),Pg={message:({params:{discrError:e,tagName:t}})=>e===_o.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:r}})=>(0, Vt._)`{error: ${e}, tag: ${r}, tagValue: ${t}}`},Og={keyword:"discriminator",type:"object",schemaType:"object",error:Pg,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, Vt._)`${r}${(0, Vt.getProperty)(i)}`);t.if((0, Vt._)`typeof ${c} == "string"`,()=>d(),()=>e.error(false,{discrError:_o.DiscrError.Tag,tag:c,tagName:i})),e.ok(u);function d(){let v=b();t.if(false);for(let m in v)t.elseIf((0, Vt._)`${c} === ${m}`),t.assign(u,l(v[m]));t.else(),e.error(false,{discrError:_o.DiscrError.Mapping,tag:c,tagName:i}),t.endIf();}function l(v){let m=t.name("valid"),p=e.subschema({keyword:"oneOf",schemaProp:v},m);return e.mergeEvaluated(p,Vt.Name),m}function b(){var v;let m={},p=g(s),k=true;for(let _=0;_<a.length;_++){let w=a[_];if(w?.$ref&&!(0, Ig.schemaHasRulesButRef)(w,o.self.RULES)){let R=w.$ref;if(w=qu.resolveRef.call(o.self,o.schemaEnv.root,o.baseId,R),w instanceof qu.SchemaEnv&&(w=w.schema),w===void 0)throw new Ag.default(o.opts.uriResolver,o.baseId,R)}let C=(v=w?.properties)===null||v===void 0?void 0:v[i];if(typeof C!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${i}"`);k=k&&(p||g(w)),f(C,_);}if(!k)throw new Error(`discriminator: "${i}" must be required`);return m;function g({required:_}){return Array.isArray(_)&&_.includes(i)}function f(_,w){if(_.const)y(_.const,w);else if(_.enum)for(let C of _.enum)y(C,w);else throw new Error(`discriminator: "properties/${i}" must have "const" or "enum"`)}function y(_,w){if(typeof _!="string"||_ in m)throw new Error(`discriminator: "${i}" values must be unique strings`);m[_]=w;}}}};Ro.default=Og;});var Fu=x((Dv,jg)=>{jg.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 Lu=x((ne,Co)=>{Object.defineProperty(ne,"__esModule",{value:true});ne.MissingRefError=ne.ValidationError=ne.CodeGen=ne.Name=ne.nil=ne.stringify=ne.str=ne._=ne.KeywordCxt=ne.Ajv=void 0;var Ng=ji(),qg=Ou(),Dg=Du(),Mu=Fu(),Fg=["/properties"],yn="http://json-schema.org/draft-07/schema",Bt=class extends Ng.default{_addVocabularies(){super._addVocabularies(),qg.default.forEach(t=>this.addVocabulary(t)),this.opts.discriminator&&this.addKeyword(Dg.default);}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let t=this.opts.$data?this.$dataMetaSchema(Mu,Fg):Mu;this.addMetaSchema(t,yn,false),this.refs["http://json-schema.org/schema"]=yn;}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(yn)?yn:void 0)}};ne.Ajv=Bt;Co.exports=ne=Bt;Co.exports.Ajv=Bt;Object.defineProperty(ne,"__esModule",{value:true});ne.default=Bt;var Mg=cr();Object.defineProperty(ne,"KeywordCxt",{enumerable:true,get:function(){return Mg.KeywordCxt}});var Gt=B();Object.defineProperty(ne,"_",{enumerable:true,get:function(){return Gt._}});Object.defineProperty(ne,"str",{enumerable:true,get:function(){return Gt.str}});Object.defineProperty(ne,"stringify",{enumerable:true,get:function(){return Gt.stringify}});Object.defineProperty(ne,"nil",{enumerable:true,get:function(){return Gt.nil}});Object.defineProperty(ne,"Name",{enumerable:true,get:function(){return Gt.Name}});Object.defineProperty(ne,"CodeGen",{enumerable:true,get:function(){return Gt.CodeGen}});var Lg=Wr();Object.defineProperty(ne,"ValidationError",{enumerable:true,get:function(){return Lg.default}});var Vg=dr();Object.defineProperty(ne,"MissingRefError",{enumerable:true,get:function(){return Vg.default}});});var Ir="b64:";function Vc(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 Bc(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 se(e){return `${Ir}${Vc(JSON.stringify(e))}`}function _e(e){if(!e.startsWith(Ir))throw new Error(`Invalid ref format (expected ${Ir}<base64url(json)>): ${e}`);let t;try{t=JSON.parse(Bc(e.slice(Ir.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 Vo(e,t,r){let n=e.tryAcquire();if(!n)return false;try{await t();}finally{n();}return r?.(),true}function Jt(e,t,r=".json"){let n=ie__namespace.join(e,".tmp");return T__namespace.mkdirSync(n,{recursive:true}),ie__namespace.join(n,`${t}-${Date.now()}-${Math.random().toString(36).slice(2,8)}${r}`)}function We(...e){return ie__namespace.join(...e)}function Uo(e){return ie__namespace.isAbsolute(e)}function An(){return crypto.randomUUID()}function Jo(e){return crypto.createHash("sha256").update(e).digest("hex")}function zo(e){return ie__namespace.dirname(url.fileURLToPath(e))}function Hc(e){if(typeof e=="object"&&e!==null){let{command:r,args:n=[],...s}=e,o=Go(r,n);return {...s,command:o.command,args:o.args}}let t=Ho(e);if(t.length===0)throw new Error(`Empty command spec: ${JSON.stringify(e)}`);return Go(t[0],t.slice(1))}function Go(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 Ho(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 In(e){return process.platform==="win32"&&/\.(cmd|bat)$/i.test(e)}function Wo(e,t){let{command:r,args:n=[],cwd:s,env:o,timeoutMs:a}=e;return child_process.execFileSync(r,n,{shell:In(r),timeout:a,encoding:t?.encoding??"utf-8",cwd:s,windowsHide:true,env:o?{...process.env,...o}:void 0,input:t?.input})}function Wc(e,t){let{command:r,args:n=[],cwd:s,env:o,timeoutMs:a=3e4}=e;child_process.execFile(r,n,{shell:In(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));}ie__namespace.join(Tn__namespace.tmpdir(),".board-live-cards-git-bash-cache.json");function Or(e){let{command:t,args:r=[]}=e;if(process.platform==="win32"){child_process.spawn(t,r,{detached:true,stdio:"ignore",windowsHide:true,shell:In(t)}).unref();return}child_process.spawn(t,r,{detached:true,stdio:"ignore"}).unref();}function Pn(e,t,r){let n=ie__namespace.join(e,"board-live-cards-cli.js");if(T__namespace.existsSync(n))return {cmd:process.execPath,args:[n,t,...r]};let s=ie__namespace.join(e,"board-live-cards-cli.ts"),o=ie__namespace.join(e,"..","..","node_modules","tsx","dist","cli.mjs"),a=ie__namespace.join(e,"..","..","node_modules",".bin","tsx"),i=T__namespace.existsSync(o)?o:a;return T__namespace.existsSync(s)&&T__namespace.existsSync(i)?{cmd:process.execPath,args:[i,s,t,...r]}:{cmd:process.platform==="win32"?"npx.cmd":"npx",args:["tsx",s,t,...r]}}function On(e){let t=ie__namespace.join(e,"..","..","..","dev","board-live-cards-cli.js");if(T__namespace.existsSync(t))return t;let r=ie__namespace.join(e,"..","..","dev","board-live-cards-cli.js");if(T__namespace.existsSync(r))return r;let n=ie__namespace.join(e,"board-live-cards-cli.js");if(T__namespace.existsSync(n))return n;throw new Error(`resolveBoardCliCallbackTarget: cannot find callback target in ${e} (expected dev/board-live-cards-cli.js wrapper or ${n})`)}function Yo(e,t,r){let n=["--base-ref",se(t)];r&&n.push("--notify-channel",r);let{cmd:s,args:o}=Pn(e,"process-accumulated-events",n);Or({command:s,args:o});}function Yc(e){return process.platform==="win32"?`\\\\.\\pipe\\${e}`:ie__namespace.join(Tn__namespace.tmpdir(),`${e}.sock`)}var Pr=new Map;function Xo(e,t,r){if(t.length===0)return;let n=t.map(i=>JSON.stringify(i)).join(`
8
+ deps: ${r}}`};var Nm={keyword:"dependencies",type:"object",schemaType:"object",error:Le.error,code(e){let[t,r]=qm(e);uu(e,t),cu(e,r);}};function qm({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 uu(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, _r.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, _r.checkReportMissingProp)(e,c);}):(r.if((0, oo._)`${u} && (${(0, _r.checkMissingProp)(e,i,o)})`),(0, _r.reportMissingProp)(e,o),r.else());}}Le.validatePropertyDeps=uu;function cu(e,t=e.schema){let{gen:r,data:n,keyword:s,it:o}=e,a=r.name("valid");for(let i in t)(0, jm.alwaysValidSchema)(o,t[i])||(r.if((0, _r.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));}Le.validateSchemaDeps=cu;Le.default=Nm;});var fu=x(ao=>{Object.defineProperty(ao,"__esModule",{value:true});var lu=B(),Dm=z(),Fm={message:"property name must be valid",params:({params:e})=>(0, lu._)`{propertyName: ${e.propertyName}}`},Mm={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:Fm,code(e){let{gen:t,schema:r,data:n,it:s}=e;if((0, Dm.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, lu.not)(o),()=>{e.error(true),s.allErrors||t.break();});}),e.ok(o);}};ao.default=Mm;});var uo=x(io=>{Object.defineProperty(io,"__esModule",{value:true});var ln=Te(),Ne=B(),Lm=Ge(),fn=z(),Vm={message:"must NOT have additional properties",params:({params:e})=>(0, Ne._)`{additionalProperty: ${e.additionalProperty}}`},Bm={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:true,trackErrors:true,error:Vm,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, fn.alwaysValidSchema)(a,r))return;let c=(0, ln.allSchemaProperties)(n.properties),d=(0, ln.allSchemaProperties)(n.patternProperties);l(),e.ok((0, Ne._)`${o} === ${Lm.default.errors}`);function l(){t.forIn("key",s,b=>{!c.length&&!d.length?m(b):t.if(k(b),()=>m(b));});}function k(b){let g;if(c.length>8){let f=(0, fn.schemaRefOrVal)(a,n.properties,"properties");g=(0, ln.isOwnProperty)(t,f,b);}else c.length?g=(0, Ne.or)(...c.map(f=>(0, Ne._)`${b} === ${f}`)):g=Ne.nil;return d.length&&(g=(0, Ne.or)(g,...d.map(f=>(0, Ne._)`${(0, ln.usePattern)(e,f)}.test(${b})`))),(0, Ne.not)(g)}function v(b){t.code((0, Ne._)`delete ${s}[${b}]`);}function m(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, fn.alwaysValidSchema)(a,r)){let g=t.name("valid");u.removeAdditional==="failing"?(p(b,g,false),t.if((0, Ne.not)(g),()=>{e.reset(),v(b);})):(p(b,g),i||t.if((0, Ne.not)(g),()=>t.break()));}}function p(b,g,f){let y={keyword:"additionalProperties",dataProp:b,dataPropType:fn.Type.Str};f===false&&Object.assign(y,{compositeRule:true,createErrors:false,allErrors:false}),e.subschema(y,g);}}};io.default=Bm;});var gu=x(lo=>{Object.defineProperty(lo,"__esModule",{value:true});var Gm=cr(),pu=Te(),co=z(),mu=uo(),Km={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&&mu.default.code(new Gm.KeywordCxt(o,mu.default,"additionalProperties"));let a=(0, pu.allSchemaProperties)(r);for(let l of a)o.definedProperties.add(l);o.opts.unevaluated&&a.length&&o.props!==true&&(o.props=co.mergeEvaluated.props(t,(0, co.toHash)(a),o.props));let i=a.filter(l=>!(0, co.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, pu.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);}}};lo.default=Km;});var ku=x(fo=>{Object.defineProperty(fo,"__esModule",{value:true});var hu=Te(),pn=B(),yu=z(),vu=z(),Um={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, hu.allSchemaProperties)(r),u=i.filter(p=>(0, yu.alwaysValidSchema)(o,r[p]));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, vu.evaluatedPropsToName)(t,o.props));let{props:l}=o;k();function k(){for(let p of i)c&&v(p),o.allErrors?m(p):(t.var(d,true),m(p),t.if(d));}function v(p){for(let b in c)new RegExp(p).test(b)&&(0, yu.checkStrictMode)(o,`property ${b} matches pattern ${p} (use allowMatchingProperties)`);}function m(p){t.forIn("key",n,b=>{t.if((0, pn._)`${(0, hu.usePattern)(e,p)}.test(${b})`,()=>{let g=u.includes(p);g||e.subschema({keyword:"patternProperties",schemaProp:p,dataProp:b,dataPropType:vu.Type.Str},d),o.opts.unevaluated&&l!==true?t.assign((0, pn._)`${l}[${b}]`,true):!g&&!o.allErrors&&t.if((0, pn.not)(d),()=>t.break());});});}}};fo.default=Um;});var bu=x(po=>{Object.defineProperty(po,"__esModule",{value:true});var Jm=z(),zm={keyword:"not",schemaType:["object","boolean"],trackErrors:true,code(e){let{gen:t,schema:r,it:n}=e;if((0, Jm.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"}};po.default=zm;});var Su=x(mo=>{Object.defineProperty(mo,"__esModule",{value:true});var Hm=Te(),Wm={keyword:"anyOf",schemaType:"array",trackErrors:true,code:Hm.validateUnion,error:{message:"must match a schema in anyOf"}};mo.default=Wm;});var wu=x(go=>{Object.defineProperty(go,"__esModule",{value:true});var mn=B(),Ym=z(),Xm={message:"must match exactly one schema in oneOf",params:({params:e})=>(0, mn._)`{passingSchemas: ${e.passing}}`},Qm={keyword:"oneOf",schemaType:"array",trackErrors:true,error:Xm,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 k;(0, Ym.alwaysValidSchema)(s,d)?t.var(u,true):k=e.subschema({keyword:"oneOf",schemaProp:l,compositeRule:true},u),l>0&&t.if((0, mn._)`${u} && ${a}`).assign(a,false).assign(i,(0, mn._)`[${i}, ${l}]`).else(),t.if(u,()=>{t.assign(a,true),t.assign(i,l),k&&e.mergeEvaluated(k,mn.Name);});});}}};go.default=Qm;});var _u=x(ho=>{Object.defineProperty(ho,"__esModule",{value:true});var Zm=z(),eg={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, Zm.alwaysValidSchema)(n,o))return;let i=e.subschema({keyword:"allOf",schemaProp:a},s);e.ok(s),e.mergeEvaluated(i);});}};ho.default=eg;});var $u=x(yo=>{Object.defineProperty(yo,"__esModule",{value:true});var gn=B(),Cu=z(),tg={message:({params:e})=>(0, gn.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0, gn._)`{failingKeyword: ${e.ifClause}}`},rg={keyword:"if",schemaType:["object","boolean"],trackErrors:true,error:tg,code(e){let{gen:t,parentSchema:r,it:n}=e;r.then===void 0&&r.else===void 0&&(0, Cu.checkStrictMode)(n,'"if" without "then" and "else" is ignored');let s=Ru(n,"then"),o=Ru(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, gn.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 k=e.subschema({keyword:d},i);t.assign(a,i),e.mergeValidEvaluated(k,a),l?t.assign(l,(0, gn._)`${d}`):e.setParams({ifClause:d});}}}};function Ru(e,t){let r=e.schema[t];return r!==void 0&&!(0, Cu.alwaysValidSchema)(e,r)}yo.default=rg;});var Eu=x(vo=>{Object.defineProperty(vo,"__esModule",{value:true});var ng=z(),sg={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:r}){t.if===void 0&&(0, ng.checkStrictMode)(r,`"${e}" without "if" is ignored`);}};vo.default=sg;});var xu=x(ko=>{Object.defineProperty(ko,"__esModule",{value:true});var og=eo(),ag=su(),ig=to(),ug=au(),cg=iu(),dg=du(),lg=fu(),fg=uo(),pg=gu(),mg=ku(),gg=bu(),hg=Su(),yg=wu(),vg=_u(),kg=$u(),bg=Eu();function Sg(e=false){let t=[gg.default,hg.default,yg.default,vg.default,kg.default,bg.default,lg.default,fg.default,dg.default,pg.default,mg.default];return e?t.push(ag.default,ug.default):t.push(og.default,ig.default),t.push(cg.default),t}ko.default=Sg;});var Tu=x(bo=>{Object.defineProperty(bo,"__esModule",{value:true});var ae=B(),wg={message:({schemaCode:e})=>(0, ae.str)`must match format "${e}"`,params:({schemaCode:e})=>(0, ae._)`{format: ${e}}`},_g={keyword:"format",type:["number","string"],schemaType:"string",$data:true,error:wg,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?k():v();function k(){let m=r.scopeValue("formats",{ref:l.formats,code:u.code.formats}),p=r.const("fDef",(0, ae._)`${m}[${a}]`),b=r.let("fType"),g=r.let("format");r.if((0, ae._)`typeof ${p} == "object" && !(${p} instanceof RegExp)`,()=>r.assign(b,(0, ae._)`${p}.type || "string"`).assign(g,(0, ae._)`${p}.validate`),()=>r.assign(b,(0, ae._)`"string"`).assign(g,p)),e.fail$data((0, ae.or)(f(),y()));function f(){return u.strictSchema===false?ae.nil:(0, ae._)`${a} && !${g}`}function y(){let _=d.$async?(0, ae._)`(${p}.async ? await ${g}(${n}) : ${g}(${n}))`:(0, ae._)`${g}(${n})`,S=(0, ae._)`(typeof ${g} == "function" ? ${_} : ${g}.test(${n}))`;return (0, ae._)`${g} && ${g} !== true && ${b} === ${t} && !${S}`}}function v(){let m=l.formats[o];if(!m){f();return}if(m===true)return;let[p,b,g]=y(m);p===t&&e.pass(_());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 y(S){let $=S instanceof RegExp?(0, ae.regexpCode)(S):u.code.formats?(0, ae._)`${u.code.formats}${(0, ae.getProperty)(o)}`:void 0,R=r.scopeValue("formats",{key:o,ref:S,code:$});return typeof S=="object"&&!(S instanceof RegExp)?[S.type||"string",S.validate,(0, ae._)`${R}.validate`]:["string",S,R]}function _(){if(typeof m=="object"&&!(m instanceof RegExp)&&m.async){if(!d.$async)throw new Error("async format in sync schema");return (0, ae._)`await ${g}(${n})`}return typeof b=="function"?(0, ae._)`${g}(${n})`:(0, ae._)`${g}.test(${n})`}}}};bo.default=_g;});var Au=x(So=>{Object.defineProperty(So,"__esModule",{value:true});var Rg=Tu(),Cg=[Rg.default];So.default=Cg;});var Iu=x(Lt=>{Object.defineProperty(Lt,"__esModule",{value:true});Lt.contentVocabulary=Lt.metadataVocabulary=void 0;Lt.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];Lt.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"];});var Ou=x(wo=>{Object.defineProperty(wo,"__esModule",{value:true});var $g=Li(),Eg=eu(),xg=xu(),Tg=Au(),Pu=Iu(),Ag=[$g.default,Eg.default,(0, xg.default)(),Tg.default,Pu.metadataVocabulary,Pu.contentVocabulary];wo.default=Ag;});var Nu=x(hn=>{Object.defineProperty(hn,"__esModule",{value:true});hn.DiscrError=void 0;var ju;(function(e){e.Tag="tag",e.Mapping="mapping";})(ju||(hn.DiscrError=ju={}));});var Du=x(Ro=>{Object.defineProperty(Ro,"__esModule",{value:true});var Vt=B(),_o=Nu(),qu=Xr(),Ig=dr(),Pg=z(),Og={message:({params:{discrError:e,tagName:t}})=>e===_o.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:r}})=>(0, Vt._)`{error: ${e}, tag: ${r}, tagValue: ${t}}`},jg={keyword:"discriminator",type:"object",schemaType:"object",error:Og,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, Vt._)`${r}${(0, Vt.getProperty)(i)}`);t.if((0, Vt._)`typeof ${c} == "string"`,()=>d(),()=>e.error(false,{discrError:_o.DiscrError.Tag,tag:c,tagName:i})),e.ok(u);function d(){let v=k();t.if(false);for(let m in v)t.elseIf((0, Vt._)`${c} === ${m}`),t.assign(u,l(v[m]));t.else(),e.error(false,{discrError:_o.DiscrError.Mapping,tag:c,tagName:i}),t.endIf();}function l(v){let m=t.name("valid"),p=e.subschema({keyword:"oneOf",schemaProp:v},m);return e.mergeEvaluated(p,Vt.Name),m}function k(){var v;let m={},p=g(s),b=true;for(let _=0;_<a.length;_++){let S=a[_];if(S?.$ref&&!(0, Pg.schemaHasRulesButRef)(S,o.self.RULES)){let R=S.$ref;if(S=qu.resolveRef.call(o.self,o.schemaEnv.root,o.baseId,R),S instanceof qu.SchemaEnv&&(S=S.schema),S===void 0)throw new Ig.default(o.opts.uriResolver,o.baseId,R)}let $=(v=S?.properties)===null||v===void 0?void 0:v[i];if(typeof $!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${i}"`);b=b&&(p||g(S)),f($,_);}if(!b)throw new Error(`discriminator: "${i}" must be required`);return m;function g({required:_}){return Array.isArray(_)&&_.includes(i)}function f(_,S){if(_.const)y(_.const,S);else if(_.enum)for(let $ of _.enum)y($,S);else throw new Error(`discriminator: "properties/${i}" must have "const" or "enum"`)}function y(_,S){if(typeof _!="string"||_ in m)throw new Error(`discriminator: "${i}" values must be unique strings`);m[_]=S;}}}};Ro.default=jg;});var Fu=x((Fv,Ng)=>{Ng.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 Lu=x((ne,Co)=>{Object.defineProperty(ne,"__esModule",{value:true});ne.MissingRefError=ne.ValidationError=ne.CodeGen=ne.Name=ne.nil=ne.stringify=ne.str=ne._=ne.KeywordCxt=ne.Ajv=void 0;var qg=ji(),Dg=Ou(),Fg=Du(),Mu=Fu(),Mg=["/properties"],yn="http://json-schema.org/draft-07/schema",Bt=class extends qg.default{_addVocabularies(){super._addVocabularies(),Dg.default.forEach(t=>this.addVocabulary(t)),this.opts.discriminator&&this.addKeyword(Fg.default);}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let t=this.opts.$data?this.$dataMetaSchema(Mu,Mg):Mu;this.addMetaSchema(t,yn,false),this.refs["http://json-schema.org/schema"]=yn;}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(yn)?yn:void 0)}};ne.Ajv=Bt;Co.exports=ne=Bt;Co.exports.Ajv=Bt;Object.defineProperty(ne,"__esModule",{value:true});ne.default=Bt;var Lg=cr();Object.defineProperty(ne,"KeywordCxt",{enumerable:true,get:function(){return Lg.KeywordCxt}});var Gt=B();Object.defineProperty(ne,"_",{enumerable:true,get:function(){return Gt._}});Object.defineProperty(ne,"str",{enumerable:true,get:function(){return Gt.str}});Object.defineProperty(ne,"stringify",{enumerable:true,get:function(){return Gt.stringify}});Object.defineProperty(ne,"nil",{enumerable:true,get:function(){return Gt.nil}});Object.defineProperty(ne,"Name",{enumerable:true,get:function(){return Gt.Name}});Object.defineProperty(ne,"CodeGen",{enumerable:true,get:function(){return Gt.CodeGen}});var Vg=Wr();Object.defineProperty(ne,"ValidationError",{enumerable:true,get:function(){return Vg.default}});var Bg=dr();Object.defineProperty(ne,"MissingRefError",{enumerable:true,get:function(){return Bg.default}});});var Ir="b64:";function Bc(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 Gc(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 se(e){return `${Ir}${Bc(JSON.stringify(e))}`}function Re(e){if(!e.startsWith(Ir))throw new Error(`Invalid ref format (expected ${Ir}<base64url(json)>): ${e}`);let t;try{t=JSON.parse(Gc(e.slice(Ir.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 Vo(e,t,r){let n=e.tryAcquire();if(!n)return false;try{await t();}finally{n();}return r?.(),true}function Jt(e,t,r=".json"){let n=ie__namespace.join(e,".tmp");return T__namespace.mkdirSync(n,{recursive:true}),ie__namespace.join(n,`${t}-${Date.now()}-${Math.random().toString(36).slice(2,8)}${r}`)}function We(...e){return ie__namespace.join(...e)}function Uo(e){return ie__namespace.isAbsolute(e)}function An(){return crypto.randomUUID()}function Jo(e){return crypto.createHash("sha256").update(e).digest("hex")}function zo(e){return ie__namespace.dirname(url.fileURLToPath(e))}function Wc(e){if(typeof e=="object"&&e!==null){let{command:r,args:n=[],...s}=e,o=Go(r,n);return {...s,command:o.command,args:o.args}}let t=Ho(e);if(t.length===0)throw new Error(`Empty command spec: ${JSON.stringify(e)}`);return Go(t[0],t.slice(1))}function Go(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 Ho(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 In(e){return process.platform==="win32"&&/\.(cmd|bat)$/i.test(e)}function Wo(e,t){let{command:r,args:n=[],cwd:s,env:o,timeoutMs:a}=e;return child_process.execFileSync(r,n,{shell:In(r),timeout:a,encoding:t?.encoding??"utf-8",cwd:s,windowsHide:true,env:o?{...process.env,...o}:void 0,input:t?.input})}function Yc(e,t){let{command:r,args:n=[],cwd:s,env:o,timeoutMs:a=3e4}=e;child_process.execFile(r,n,{shell:In(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));}ie__namespace.join(Tn__namespace.tmpdir(),".board-live-cards-git-bash-cache.json");function Or(e){let{command:t,args:r=[]}=e;if(process.platform==="win32"){child_process.spawn(t,r,{detached:true,stdio:"ignore",windowsHide:true,shell:In(t)}).unref();return}child_process.spawn(t,r,{detached:true,stdio:"ignore"}).unref();}function Pn(e,t,r){let n=ie__namespace.join(e,"board-live-cards-cli.js");if(T__namespace.existsSync(n))return {cmd:process.execPath,args:[n,t,...r]};let s=ie__namespace.join(e,"board-live-cards-cli.ts"),o=ie__namespace.join(e,"..","..","node_modules","tsx","dist","cli.mjs"),a=ie__namespace.join(e,"..","..","node_modules",".bin","tsx"),i=T__namespace.existsSync(o)?o:a;return T__namespace.existsSync(s)&&T__namespace.existsSync(i)?{cmd:process.execPath,args:[i,s,t,...r]}:{cmd:process.platform==="win32"?"npx.cmd":"npx",args:["tsx",s,t,...r]}}function On(e){let t=ie__namespace.join(e,"..","..","..","dev","board-live-cards-cli.js");if(T__namespace.existsSync(t))return t;let r=ie__namespace.join(e,"..","..","dev","board-live-cards-cli.js");if(T__namespace.existsSync(r))return r;let n=ie__namespace.join(e,"board-live-cards-cli.js");if(T__namespace.existsSync(n))return n;throw new Error(`resolveBoardCliCallbackTarget: cannot find callback target in ${e} (expected dev/board-live-cards-cli.js wrapper or ${n})`)}function Yo(e,t,r){let n=["--base-ref",se(t)];r&&n.push("--notify-channel",r);let{cmd:s,args:o}=Pn(e,"process-accumulated-events",n);Or({command:s,args:o});}function Xc(e){return process.platform==="win32"?`\\\\.\\pipe\\${e}`:ie__namespace.join(Tn__namespace.tmpdir(),`${e}.sock`)}var Pr=new Map;function Xo(e,t,r){if(t.length===0)return;let n=t.map(i=>JSON.stringify(i)).join(`
9
9
  `)+`
10
- `,s=Pr.get(e);if(s&&!s.socket.destroyed){s.ready?s.socket.write(n):s.queue.push(n);return}let o=Yc(e),a=Ko__namespace.createConnection(o);s={socket:a,ready:false,queue:[n]},Pr.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)}`),Pr.delete(e);}),a.on("close",()=>{Pr.delete(e);});}function jr(){return {executeSync(e,t,r){return Wo({command:e,args:t,cwd:r?.cwd,timeoutMs:r?.timeout,env:r?.env},{encoding:r?.encoding,input:r?.input})},executeAsync(e,t,r){Wc({command:e,args:t},r);},resolveInvocation(e,t){let r=Hc({command:e,args:t});return {cmd:r.command,args:r.args??[]}},splitCommand:Ho,spawnDetached(e,t){Or({command:e,args:t});}}}var Zo=ie.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)))),td=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 rd(){let e=ie.resolve(Zo,"./jsonata-sync.cjs");return T.existsSync(e)?e:ie.resolve(Zo,"../../card-compute/jsonata-sync.cjs")}var pt=td(rd());function jn(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{s.push(String(pt(o).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{n.stdin=pt(e.stdinTemplate).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{n.url=String(pt(e.urlTemplate).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=pt(e.headerTemplate).evaluate(t);if(typeof s!="object"||s===null)throw new Error(`headerTemplate must produce an object, got: ${JSON.stringify(s)}`);n.headers=s;}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{n.body=pt(e.bodyTemplate).evaluate(t);}catch(s){let o=s instanceof Error?s.message:String(s);throw new Error(`[${r}] argsMassaging.bodyTemplate failed: ${o}`)}return n}function nd(e,t){let r=typeof e=="object"?e.value:_e(e).value;switch(r){case "source-cli-task-executor":{let n=ie__namespace.join(t,"source-cli-task-executor.js");if(T__namespace.existsSync(n))return {command:process.execPath,args:[n]};let s=ie__namespace.join(t,"source-cli-task-executor.ts"),o=ie__namespace.join(t,"..","..","node_modules","tsx","dist","cli.mjs"),a=ie__namespace.join(t,"..","..","node_modules",".bin","tsx"),i=T__namespace.existsSync(o)?o:a;return T__namespace.existsSync(s)&&T__namespace.existsSync(i)?{command:process.execPath,args:[i,s]}:{command:process.execPath,args:[n]}}case "board-live-cards":{let{cmd:n,args:s}=Pn(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 ta(e,t){if(e.howToRun==="built-in"){let{command:n,args:s}=nd(e.whatToRun,t);return {command:n,baseArgs:s}}let r=typeof e.whatToRun=="object"?e.whatToRun.value:_e(e.whatToRun).value;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 sd(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 od(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 Nn(e,t){return ta(e,t)}function ra(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 na(e){let t=e.whatToRun;return typeof t=="object"?t.value:_e(t).value}function sa(e,t){return {...t,whatToRun:na(e),...e.extra?{extra:e.extra}:{}}}function qn(e,t,r="invokeExecutionRef"){return jn(e,t,r)}function oa(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 Xe(e){return {result:"failure",data:{error:e}}}function Ye(e,t,r){let n=r?.label??"invokeExecutionRefSync",s=r?.cliDir??r?.cwd??process.cwd(),o;try{o=qn(e.argsMassaging,sa(e,t),n);}catch(l){let b=l instanceof Error?l.message:String(l);return Xe(b)}let a;try{a=Nn(e,s);}catch(l){let b=l instanceof Error?l.message:String(l);return Xe(`[${n}] ref resolution failed: ${b}`)}let i=[...a.baseArgs,...o.cmdArgs??[]],u=JSON.stringify(o.stdin??t),c=jr(),d;try{d=c.executeSync(a.command,i,{timeout:r?.timeoutMs??3e4,encoding:"utf-8",cwd:r?.cwd,input:u});}catch(l){let b=l,v=(b.stderr?String(b.stderr):"").trim(),m=typeof b.status=="number"?b.status:"unknown",p=v||b.message;return Xe(`[${n}] ref exited with status ${m}${p?`: ${p}`:""}`)}try{return oa(ra(d))}catch{return {result:"success",data:{stdout:d.trim()}}}}async function ea(e,t,r){let n=r?.label??"invokeExecutionRef",s;try{s=qn(e.argsMassaging,sa(e,t),n);}catch(c){let d=c instanceof Error?c.message:String(c);return Xe(d)}let o=na(e),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,b])=>[l,String(b)]));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 Xe(`[${n}] HTTP ${c.status}${l?`: ${l}`:""}`)}let d=await c.text();if(!d.trim())return {result:"success",data:{}};try{return oa(ra(d))}catch{return {result:"success",data:{stdout:d.trim()}}}}catch(c){let d=c instanceof Error?c.message:String(c);return Xe(`[${n}] ${d}`)}}var ad={"local-node":async(e,t,r)=>Ye(e,t,r),"local-python":async(e,t,r)=>Ye(e,t,r),"local-process":async(e,t,r)=>Ye(e,t,r),"built-in":async(e,t,r)=>Ye(e,t,r),"http:post":ea,"http:get":ea},id={"local-node":Ye,"local-python":Ye,"local-process":Ye,"built-in":Ye};async function aa(e,t,r){let n=r?.transports?.[e.howToRun]??ad[e.howToRun];return n?n(e,t,r):Xe(`[${r?.label??"invokeExecutionRef"}] unsupported howToRun: ${e.howToRun}`)}function Dn(e,t,r){let n=r?.syncTransports?.[e.howToRun]??id[e.howToRun];return n?n(e,t,r):Xe(`[${r?.label??"invokeExecutionRefSync"}] unsupported sync howToRun: ${e.howToRun}`)}function ud(e){return {invoke(t,r){return aa(t,r,e)},invokeSync(t,r){return Dn(t,r,e)}}}function cd(e,t,r){return Dn(e,t,r)}async function dd(e,t){let r={...t,whatToRun:e.whatToRun},n=jn(e.argsMassaging,r,"_invokeTaskExecutorHttp"),s=n.url??(typeof e.whatToRun=="object"?e.whatToRun.value:_e(e.whatToRun).value),o=n.body?n.body:od(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 ia(e,t,r){if(e.howToRun==="http:post"||e.howToRun==="http:get"){dd(e,t).catch(i=>{console.error(`[dispatchTaskExecutorDetached] HTTP dispatch failed: ${i.message}`);});return}let{command:s,baseArgs:o}=ta(e,r),a=sd(t,e.extra);Or({command:s,args:[...o,...a]});}function ld(){return {read(e){if(!T__namespace.existsSync(e))return null;try{return T__namespace.readFileSync(e,"utf-8")}catch{return null}},write(e,t){T__namespace.mkdirSync(ie__namespace.dirname(e),{recursive:true}),T__namespace.writeFileSync(e,t,"utf-8");}}}function ua(e){return ld();}function Wt(e,t){if(process.platform!=="win32"){T__namespace.renameSync(e,t);return}let r=[10,20,40,80,160];for(let n=0;n<=r.length;n++)try{T__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 Nr(e){function t(s){return ie__namespace.join(e,...s.split("/"))}function r(s){return ie__namespace.relative(e,s).replace(/\\/g,"/")}function n(s,o){if(T__namespace.existsSync(s))for(let a of T__namespace.readdirSync(s,{withFileTypes:true})){let i=ie__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(!T__namespace.existsSync(o))return null;try{return T__namespace.readFileSync(o,"utf-8")}catch{return null}},write(s,o){let a=t(s),i=`${a}.${process.pid}.${crypto.randomUUID()}.tmp`;T__namespace.mkdirSync(ie__namespace.dirname(a),{recursive:true}),T__namespace.writeFileSync(i,o,"utf-8"),Wt(i,a);},exists(s){return T__namespace.existsSync(t(s))},remove(s){let o=t(s);try{T__namespace.existsSync(o)&&T__namespace.unlinkSync(o);}catch{}},readBytes(s){let o=t(s);if(!T__namespace.existsSync(o))return null;try{return new Uint8Array(T__namespace.readFileSync(o))}catch{return null}},writeBytes(s,o){let a=t(s),i=`${a}.${process.pid}.${crypto.randomUUID()}.tmp`;T__namespace.mkdirSync(ie__namespace.dirname(a),{recursive:true}),T__namespace.writeFileSync(i,Buffer.from(o)),Wt(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(!T__namespace.existsSync(o))return null;try{let a=T__namespace.statSync(o);return {key:s,size:Number(a.size||0),updatedAt:new Date(a.mtimeMs).toISOString()}}catch{return null}}}}function Ln(){return {read(e){if(!T__namespace.existsSync(e))return null;try{return T__namespace.readFileSync(e,"utf-8")}catch{return null}},write(e,t){let r=`${e}.${process.pid}.${crypto.randomUUID()}.tmp`;T__namespace.mkdirSync(ie__namespace.dirname(e),{recursive:true}),T__namespace.writeFileSync(r,t,"utf-8"),Wt(r,e);},exists(e){return T__namespace.existsSync(e)},remove(e){try{T__namespace.existsSync(e)&&T__namespace.unlinkSync(e);}catch{}},readBytes(e){if(!T__namespace.existsSync(e))return null;try{return new Uint8Array(T__namespace.readFileSync(e))}catch{return null}},writeBytes(e,t){let r=`${e}.${process.pid}.${crypto.randomUUID()}.tmp`;T__namespace.mkdirSync(ie__namespace.dirname(e),{recursive:true}),T__namespace.writeFileSync(r,Buffer.from(t)),Wt(r,e);},stat(e){if(!T__namespace.existsSync(e))return null;try{let t=T__namespace.statSync(e);return {key:e,size:Number(t.size||0),updatedAt:new Date(t.mtimeMs).toISOString()}}catch{return null}},listKeys(e){return []}}}function qr(e){function t(n){return ie__namespace.join(e,...n.split("/"))+".json"}function r(n,s,o,a){if(T__namespace.existsSync(n))for(let i of T__namespace.readdirSync(n,{withFileTypes:true})){let u=s?`${s}/${i.name}`:i.name;if(i.isDirectory()){r(ie__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(!T__namespace.existsSync(s))return null;try{return JSON.parse(T__namespace.readFileSync(s,"utf-8"))}catch{return null}},write(n,s){let o=t(n),a=`${o}.${process.pid}.${crypto.randomUUID()}.tmp`;T__namespace.mkdirSync(ie__namespace.dirname(o),{recursive:true}),T__namespace.writeFileSync(a,JSON.stringify(s,null,2),"utf-8"),Wt(a,o);},delete(n){let s=t(n);try{T__namespace.existsSync(s)&&T__namespace.unlinkSync(s);}catch{}},listKeys(n){let s=[];return r(e,"",n,s),s.sort()}}}function ca(e){function t(){if(!T__namespace.existsSync(e))return [];let r=T__namespace.readFileSync(e,"utf-8").trim();return r?r.split(`
10
+ `,s=Pr.get(e);if(s&&!s.socket.destroyed){s.ready?s.socket.write(n):s.queue.push(n);return}let o=Xc(e),a=Ko__namespace.createConnection(o);s={socket:a,ready:false,queue:[n]},Pr.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)}`),Pr.delete(e);}),a.on("close",()=>{Pr.delete(e);});}function jr(){return {executeSync(e,t,r){return Wo({command:e,args:t,cwd:r?.cwd,timeoutMs:r?.timeout,env:r?.env},{encoding:r?.encoding,input:r?.input})},executeAsync(e,t,r){Yc({command:e,args:t},r);},resolveInvocation(e,t){let r=Wc({command:e,args:t});return {cmd:r.command,args:r.args??[]}},splitCommand:Ho,spawnDetached(e,t){Or({command:e,args:t});}}}var Zo=ie.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)))),rd=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(){let e=ie.resolve(Zo,"./jsonata-sync.cjs");return T.existsSync(e)?e:ie.resolve(Zo,"../../card-compute/jsonata-sync.cjs")}var pt=rd(nd());function jn(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{s.push(String(pt(o).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{n.stdin=pt(e.stdinTemplate).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{n.url=String(pt(e.urlTemplate).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=pt(e.headerTemplate).evaluate(t);if(typeof s!="object"||s===null)throw new Error(`headerTemplate must produce an object, got: ${JSON.stringify(s)}`);n.headers=s;}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{n.body=pt(e.bodyTemplate).evaluate(t);}catch(s){let o=s instanceof Error?s.message:String(s);throw new Error(`[${r}] argsMassaging.bodyTemplate failed: ${o}`)}return n}function sd(e,t){let r=typeof e=="object"?e.value:Re(e).value;switch(r){case "source-cli-task-executor":{let n=ie__namespace.join(t,"source-cli-task-executor.js");if(T__namespace.existsSync(n))return {command:process.execPath,args:[n]};let s=ie__namespace.join(t,"source-cli-task-executor.ts"),o=ie__namespace.join(t,"..","..","node_modules","tsx","dist","cli.mjs"),a=ie__namespace.join(t,"..","..","node_modules",".bin","tsx"),i=T__namespace.existsSync(o)?o:a;return T__namespace.existsSync(s)&&T__namespace.existsSync(i)?{command:process.execPath,args:[i,s]}:{command:process.execPath,args:[n]}}case "board-live-cards":{let{cmd:n,args:s}=Pn(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 ta(e,t){if(e.howToRun==="built-in"){let{command:n,args:s}=sd(e.whatToRun,t);return {command:n,baseArgs:s}}let r=typeof e.whatToRun=="object"?e.whatToRun.value:Re(e.whatToRun).value;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 od(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 ad(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 Nn(e,t){return ta(e,t)}function ra(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 na(e){let t=e.whatToRun;return typeof t=="object"?t.value:Re(t).value}function sa(e,t){return {...t,whatToRun:na(e),...e.extra?{extra:e.extra}:{}}}function qn(e,t,r="invokeExecutionRef"){return jn(e,t,r)}function oa(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 Xe(e){return {result:"failure",data:{error:e}}}function Ye(e,t,r){let n=r?.label??"invokeExecutionRefSync",s=r?.cliDir??r?.cwd??process.cwd(),o;try{o=qn(e.argsMassaging,sa(e,t),n);}catch(l){let k=l instanceof Error?l.message:String(l);return Xe(k)}let a;try{a=Nn(e,s);}catch(l){let k=l instanceof Error?l.message:String(l);return Xe(`[${n}] ref resolution failed: ${k}`)}let i=[...a.baseArgs,...o.cmdArgs??[]],u=JSON.stringify(o.stdin??t),c=jr(),d;try{d=c.executeSync(a.command,i,{timeout:r?.timeoutMs??3e4,encoding:"utf-8",cwd:r?.cwd,input:u});}catch(l){let k=l,v=(k.stderr?String(k.stderr):"").trim(),m=typeof k.status=="number"?k.status:"unknown",p=v||k.message;return Xe(`[${n}] ref exited with status ${m}${p?`: ${p}`:""}`)}try{return oa(ra(d))}catch{return {result:"success",data:{stdout:d.trim()}}}}async function ea(e,t,r){let n=r?.label??"invokeExecutionRef",s;try{s=qn(e.argsMassaging,sa(e,t),n);}catch(c){let d=c instanceof Error?c.message:String(c);return Xe(d)}let o=na(e),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,k])=>[l,String(k)]));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 Xe(`[${n}] HTTP ${c.status}${l?`: ${l}`:""}`)}let d=await c.text();if(!d.trim())return {result:"success",data:{}};try{return oa(ra(d))}catch{return {result:"success",data:{stdout:d.trim()}}}}catch(c){let d=c instanceof Error?c.message:String(c);return Xe(`[${n}] ${d}`)}}var id={"local-node":async(e,t,r)=>Ye(e,t,r),"local-python":async(e,t,r)=>Ye(e,t,r),"local-process":async(e,t,r)=>Ye(e,t,r),"built-in":async(e,t,r)=>Ye(e,t,r),"http:post":ea,"http:get":ea},ud={"local-node":Ye,"local-python":Ye,"local-process":Ye,"built-in":Ye};async function aa(e,t,r){let n=r?.transports?.[e.howToRun]??id[e.howToRun];return n?n(e,t,r):Xe(`[${r?.label??"invokeExecutionRef"}] unsupported howToRun: ${e.howToRun}`)}function Dn(e,t,r){let n=r?.syncTransports?.[e.howToRun]??ud[e.howToRun];return n?n(e,t,r):Xe(`[${r?.label??"invokeExecutionRefSync"}] unsupported sync howToRun: ${e.howToRun}`)}function cd(e){return {invoke(t,r){return aa(t,r,e)},invokeSync(t,r){return Dn(t,r,e)}}}function dd(e,t,r){return Dn(e,t,r)}async function ld(e,t){let r={...t,whatToRun:e.whatToRun},n=jn(e.argsMassaging,r,"_invokeTaskExecutorHttp"),s=n.url??(typeof e.whatToRun=="object"?e.whatToRun.value:Re(e.whatToRun).value),o=n.body?n.body:ad(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 ia(e,t,r){if(e.howToRun==="http:post"||e.howToRun==="http:get"){ld(e,t).catch(i=>{console.error(`[dispatchTaskExecutorDetached] HTTP dispatch failed: ${i.message}`);});return}let{command:s,baseArgs:o}=ta(e,r),a=od(t,e.extra);Or({command:s,args:[...o,...a]});}function fd(){return {read(e){if(!T__namespace.existsSync(e))return null;try{return T__namespace.readFileSync(e,"utf-8")}catch{return null}},write(e,t){T__namespace.mkdirSync(ie__namespace.dirname(e),{recursive:true}),T__namespace.writeFileSync(e,t,"utf-8");}}}function ua(e){return fd();}function Wt(e,t){if(process.platform!=="win32"){T__namespace.renameSync(e,t);return}let r=[10,20,40,80,160];for(let n=0;n<=r.length;n++)try{T__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 Nr(e){function t(s){return ie__namespace.join(e,...s.split("/"))}function r(s){return ie__namespace.relative(e,s).replace(/\\/g,"/")}function n(s,o){if(T__namespace.existsSync(s))for(let a of T__namespace.readdirSync(s,{withFileTypes:true})){let i=ie__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(!T__namespace.existsSync(o))return null;try{return T__namespace.readFileSync(o,"utf-8")}catch{return null}},write(s,o){let a=t(s),i=`${a}.${process.pid}.${crypto.randomUUID()}.tmp`;T__namespace.mkdirSync(ie__namespace.dirname(a),{recursive:true}),T__namespace.writeFileSync(i,o,"utf-8"),Wt(i,a);},exists(s){return T__namespace.existsSync(t(s))},remove(s){let o=t(s);try{T__namespace.existsSync(o)&&T__namespace.unlinkSync(o);}catch{}},readBytes(s){let o=t(s);if(!T__namespace.existsSync(o))return null;try{return new Uint8Array(T__namespace.readFileSync(o))}catch{return null}},writeBytes(s,o){let a=t(s),i=`${a}.${process.pid}.${crypto.randomUUID()}.tmp`;T__namespace.mkdirSync(ie__namespace.dirname(a),{recursive:true}),T__namespace.writeFileSync(i,Buffer.from(o)),Wt(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(!T__namespace.existsSync(o))return null;try{let a=T__namespace.statSync(o);return {key:s,size:Number(a.size||0),updatedAt:new Date(a.mtimeMs).toISOString()}}catch{return null}}}}function Ln(){return {read(e){if(!T__namespace.existsSync(e))return null;try{return T__namespace.readFileSync(e,"utf-8")}catch{return null}},write(e,t){let r=`${e}.${process.pid}.${crypto.randomUUID()}.tmp`;T__namespace.mkdirSync(ie__namespace.dirname(e),{recursive:true}),T__namespace.writeFileSync(r,t,"utf-8"),Wt(r,e);},exists(e){return T__namespace.existsSync(e)},remove(e){try{T__namespace.existsSync(e)&&T__namespace.unlinkSync(e);}catch{}},readBytes(e){if(!T__namespace.existsSync(e))return null;try{return new Uint8Array(T__namespace.readFileSync(e))}catch{return null}},writeBytes(e,t){let r=`${e}.${process.pid}.${crypto.randomUUID()}.tmp`;T__namespace.mkdirSync(ie__namespace.dirname(e),{recursive:true}),T__namespace.writeFileSync(r,Buffer.from(t)),Wt(r,e);},stat(e){if(!T__namespace.existsSync(e))return null;try{let t=T__namespace.statSync(e);return {key:e,size:Number(t.size||0),updatedAt:new Date(t.mtimeMs).toISOString()}}catch{return null}},listKeys(e){return []}}}function qr(e){function t(n){return ie__namespace.join(e,...n.split("/"))+".json"}function r(n,s,o,a){if(T__namespace.existsSync(n))for(let i of T__namespace.readdirSync(n,{withFileTypes:true})){let u=s?`${s}/${i.name}`:i.name;if(i.isDirectory()){r(ie__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(!T__namespace.existsSync(s))return null;try{return JSON.parse(T__namespace.readFileSync(s,"utf-8"))}catch{return null}},write(n,s){let o=t(n),a=`${o}.${process.pid}.${crypto.randomUUID()}.tmp`;T__namespace.mkdirSync(ie__namespace.dirname(o),{recursive:true}),T__namespace.writeFileSync(a,JSON.stringify(s,null,2),"utf-8"),Wt(a,o);},delete(n){let s=t(n);try{T__namespace.existsSync(s)&&T__namespace.unlinkSync(s);}catch{}},listKeys(n){let s=[];return r(e,"",n,s),s.sort()}}}function ca(e){function t(){if(!T__namespace.existsSync(e))return [];let r=T__namespace.readFileSync(e,"utf-8").trim();return r?r.split(`
11
11
  `).filter(Boolean).map(n=>JSON.parse(n)):[]}return {append(r){let n={id:crypto.randomUUID(),payload:r};return T__namespace.mkdirSync(ie__namespace.dirname(e),{recursive:true}),T__namespace.appendFileSync(e,JSON.stringify(n)+`
12
12
  `,"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(){T__namespace.existsSync(e)&&T__namespace.truncateSync(e,0);}}}function Mn(e){if(e==null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return `[${e.map(Mn).join(",")}]`;let t=e;return `{${Object.keys(t).sort().map(n=>`${JSON.stringify(n)}:${Mn(t[n])}`).join(",")}}`}function da(e){return crypto.createHash("sha256").update(Mn(e)).digest("hex")}function la(e){let t=ie__namespace.join(e,"board-journal.jsonl");return {readAllEntries(){if(!T__namespace.existsSync(t))return [];let r=T__namespace.readFileSync(t,"utf-8").trim();return r?r.split(`
13
13
  `).filter(Boolean).map(n=>JSON.parse(n)):[]},appendEntry(r){T__namespace.appendFileSync(t,JSON.stringify(r)+`
14
- `,"utf-8");},generateId(){return crypto.randomUUID()}}}function fa(e){return {tryAcquire(){try{if(!T__namespace.existsSync(e)){T__namespace.mkdirSync(ie__namespace.dirname(e),{recursive:!0});try{T__namespace.writeFileSync(e,"{}",{flag:"wx"});}catch{}}return properLockfile.lockSync(e,{retries:0})}catch{return null}}}}var pa={$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"}},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 Gu=Lc(Lu());var Kg=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))),Ug=Kg("./jsonata-sync.cjs"),vn=null;var Vu=/\b(card_data|requires|fetched_sources|computed_values|source_defs)\b/g,Jg=/^\s*(card_data|requires|fetched_sources|computed_values|source_defs)(\.|$)/;function zg(e){let t=new Set,r;for(Vu.lastIndex=0;(r=Vu.exec(e))!==null;)t.add(r[1]);return t}function Ku(e){let t=Jg.exec(e);return t?t[1]:null}function Bu(e,t,r,n){try{Ug(e);}catch(o){let a=o instanceof Error?o.message:String(o);n.push(`${t}: invalid JSONata expression (${a})`);return}let s=zg(e);for(let o of s)r.has(o)||n.push(`${t}: disallowed namespace "${o}" in expression`);}function $o(e,t,r){if(Array.isArray(e)){e.forEach((s,o)=>{$o(s,`${t}/${o}`,r);});return}if(typeof e=="string"){let s=Ku(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))$o(o,`${t}/${s}`,r);}function Hg(){if(vn)return vn;let e=new Gu.default({allErrors:true});return Bg__default.default(e),vn=e.compile(pa),vn}function Uu(e){let t=Hg(),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 Ju(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||Bu(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 b=Ku(l);b===null?t.push(`/provides/${d}/ref: path "${l}" must start with a valid namespace (${[...s].join(", ")})`):s.has(b)||t.push(`/provides/${d}/ref: disallowed namespace "${b}" in path "${l}" (valid: ${[...s].join(", ")})`);});let a=r.view;a&&typeof a=="object"&&!Array.isArray(a)&&$o(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[b,v]of Object.entries(l))typeof v!="string"||v.trim().length===0||Bu(v,`/source_defs/${d}/projections/${b}`,i,t);}),{ok:t.length===0,errors:t}}function Eo(e){let t=Uu(e);if(!t.ok)return t;let r=Ju(e);return r.ok?{ok:true,errors:[]}:{ok:false,errors:r.errors}}function zu(e){return String(e).replace(/[^a-zA-Z0-9_-]/g,"_")}function Hu(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:[],updated_at:typeof t.updated_at=="string"?t.updated_at:""}}function xo(e,t){let r=s=>`chats/${zu(s)}/processing`,n=s=>`chats/${zu(s)}/config`;return {append(s,o,a,i=[]){return e(s).append({role:o,text:a,files:i,updated_at:new Date().toISOString()}).id},readAll(s){return e(s).readAll().map(Hu)},readAfter(s,o){let a=e(s).readAfter(o);return {records:a.entries.map(Hu),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 Wg(){let e=globalThis.crypto;return typeof e?.randomUUID=="function"?String(e.randomUUID()):`id-${Date.now()}-${Math.random().toString(36).slice(2)}`}function Yg(){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=[]){let i={id:Wg(),role:s,text:o,files:a,updated_at:new Date().toISOString()};return r(n).push(i),i.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 at={RUNNING:"running",COMPLETED:"completed",FAILED:"failed",INACTIVATED:"inactivated"};function Re(e){return e?Array.isArray(e.provides)?e.provides:[]:[]}function it(e){return e?Array.isArray(e.requires)?e.requires:[]:[]}function Wu(e){return e.tasks??{}}function To(e){return e?e.status===at.FAILED||e.status===at.INACTIVATED:false}function Yu(e,t){return e.refreshStrategy??t?.refreshStrategy??"data-changed"}function Xu(e){return e.maxExecutions}function Qu(e,t){let r=new Set;for(let[n,s]of Object.entries(t))if(s.status===at.COMPLETED){let o=e.tasks[n];o&&Re(o).forEach(i=>r.add(i));}return Array.from(r)}function Zu(e,t){let r={};return e.forEach(n=>{let s=t[n];if(!s)return;Re(s).forEach(a=>{r[a]||(r[a]=[]),r[a].push(n);});}),r}function ec(e,t,r){let n=e.tasks[t]??bn(),s={};if(r){let a=r.tasks[t],i=it(a);for(let u of i)for(let[c,d]of Object.entries(r.tasks))if(Re(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 tc(e,t,r,n,s,o){let a=e.tasks[r]??bn(),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=Re(i);let c=a.startConsumedHashes?{...a.startConsumedHashes}:{...a.lastConsumedHashes};if(!a.startConsumedHashes){let b=i.requires??[];for(let v of b)for(let[m,p]of Object.entries(t.tasks))if(Re(p).includes(v)){let k=e.tasks[m];k?.lastDataHash&&(c[v]=k.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 rc(e,t,r,n){let s=e.tasks[r]??bn(),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 nc(e,t,r,n){let s=e.tasks[t]??bn(),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 sc(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 bn(){return {status:"not-started",executionCount:0,retryCount:0,lastEpoch:0,messages:[],progress:null}}function kn(e,t){let r=`live-${Date.now()}`,n={};for(let o of Object.keys(e.tasks))n[o]=ac();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 Xg(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:ec(n,t.taskName,r)};case "task-completed":return {config:r,state:tc(n,r,t.taskName,t.result,t.dataHash,t.data)};case "task-failed":return {config:r,state:rc(n,r,t.taskName,t.error)};case "task-progress":return {config:r,state:nc(n,t.taskName,t.message,t.progress)};case "task-restart":return {config:r,state:sc(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:sh(n,t.action)};case "task-upsert":return Qg(e,t.taskName,t.taskConfig);case "task-removal":return Zg(e,t.taskName);case "node-requires-add":return eh(e,t.nodeName,t.tokens);case "node-requires-remove":return th(e,t.nodeName,t.tokens);case "node-provides-add":return rh(e,t.nodeName,t.tokens);case "node-provides-remove":return nh(e,t.nodeName,t.tokens);default:return e}}function oc(e,t){return t.reduce((r,n)=>Xg(r,n),e)}function Qg(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]:ac()},lastUpdated:new Date().toISOString()}}}function Zg(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 eh(e,t,r){let n=e.config.tasks[t];if(!n)return e;let s=it(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 th(e,t,r){let n=e.config.tasks[t];if(!n)return e;let s=it(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 rh(e,t,r){let n=e.config.tasks[t];if(!n)return e;let s=Re(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 nh(e,t,r){let n=e.config.tasks[t];if(!n)return e;let s=Re(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 Rr(e){return {version:1,config:e.config,state:e.state,snapshotAt:new Date().toISOString()}}function wn(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 ac(){return {status:"not-started",executionCount:0,retryCount:0,lastEpoch:0,messages:[],progress:null}}function sh(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 Cr(e){let{config:t,state:r}=e,n=Wu(t);if(Object.keys(n).length===0)return {eligible:[],pending:[],unresolved:[],blocked:[],conflicts:{}};let o=oh(n),a=Qu(t,r.tasks),i=new Set([...a,...r.availableOutputs]),u=[],c=[],d=[],l=[];for(let[v,m]of Object.entries(n)){let p=r.tasks[v],k=Yu(m,t.settings),g=k!=="once";if(p?.status===at.RUNNING||To(p))continue;let f=Xu(m);if(f!==void 0&&p&&p.executionCount>=f||m.circuit_breaker&&p&&p.executionCount>=m.circuit_breaker.max_executions||!g&&p?.status===at.COMPLETED)continue;if(g&&p?.status===at.COMPLETED){let R=it(m),E=false;switch(k){case "data-changed":{R.length>0&&R.some(D=>{for(let[M,te]of Object.entries(n))if(Re(te).includes(D)){let U=r.tasks[M];if(!U)continue;let de=p.lastConsumedHashes?.[D];return U.lastDataHash==null?U.executionCount>p.lastEpoch:U.lastDataHash!==de}return false})||(E=true);break}case "epoch-changed":{R.length>0&&R.some(D=>{for(let[M,te]of Object.entries(n))if(Re(te).includes(D)){let U=r.tasks[M];if(U&&U.executionCount>p.lastEpoch)return true}return false})||(E=true);break}case "time-based":{let N=m.refreshInterval??0;if(N<=0){E=true;break}let D=p.completedAt;if(!D){E=true;break}(Date.now()-Date.parse(D))/1e3<N&&(E=true);break}case "manual":E=true;break}if(E)continue}let y=it(m);if(y.length===0){u.push(v);continue}let _=[],w=[],C=[];for(let R of y){if(i.has(R))continue;let E=o[R]||[];E.length===0?_.push(R):E.every(D=>To(r.tasks[D]))?C.push({token:R,failedProducer:E[0]}):w.push(R);}_.length>0?d.push({taskName:v,missingTokens:_}):C.length>0?l.push({taskName:v,failedTokens:C.map(R=>R.token),failedProducers:[...new Set(C.map(R=>R.failedProducer))]}):w.length>0?c.push({taskName:v,waitingOn:w}):u.push(v);}let b={};if(u.length>1){let v=Zu(u,n);for(let[m,p]of Object.entries(v))p.length>1&&(b[m]=p);}return {eligible:u,pending:c,unresolved:d,blocked:l,conflicts:b}}function oh(e){let t={};for(let[r,n]of Object.entries(e)){for(let s of Re(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 $r=class{buffer=[];append(t){this.buffer.push(t);}drain(){let t=this.buffer;return this.buffer=[],t}get size(){return this.buffer.length}};function Ao(e){let t=Io(e);return ah(t)}function Io(e){if(e==null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return "["+e.map(Io).join(",")+"]";let t=e;return "{"+Object.keys(t).sort().map(n=>JSON.stringify(n)+":"+Io(t[n])).join(",")+"}"}function ah(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 ih(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 uh(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 ic(e){let t=JSON.stringify({t:e,n:Date.now().toString(36)+Math.random().toString(36).slice(2,6)});return ih(t)}function ch(e){try{let t=JSON.parse(uh(e));return typeof t?.t=="string"?{taskName:t.t}:null}catch{return null}}function uc(e,t,r){let{handlers:n,onDrain:s}=t,o=new $r,a="state"in e&&"config"in e?e:kn(e),i=false,u=new Set,c=new Map(Object.entries(n)),d=new $r,l=false,b=false;function v(){if(!i){if(l){b=true;return}l=true;try{do b=!1,m();while(b)}finally{l=false;}}}function m(){let f=d.drain(),y=o.drain(),_=[...f,...y];_.length>0&&(a=oc(a,_));let w=Cr(a);_.length>0&&s?.(_,a,w);for(let C of w.eligible)g(C);for(let C of _)if(C.type==="task-progress"){let{taskName:R,update:E}=C;if(!a.config.tasks[R])continue;let D=a.state.tasks[R];if(!D||D.status!=="running")continue;let M=ic(R),te=k(R,M,E).catch(U=>{i||(d.append({type:"task-failed",taskName:R,error:U.message??String(U),timestamp:new Date().toISOString()}),v());}).finally(()=>{u.delete(te);});u.add(te);}}function p(f){let _=a.config.tasks[f].requires??[],w=new Map;for(let[R,E]of Object.entries(a.config.tasks))for(let N of E.provides??[])w.set(N,R);let C={};for(let R of _){let E=w.get(R);E?C[R]=a.state.tasks[E]?.data:C[R]=void 0;}return C}async function k(f,y,_){let w=a.config.tasks[f],C=w.taskHandlers??[],R=p(f);for(let E of C){let N=c.get(E);if(!N)throw new Error(`Handler '${E}' not found in registry (task '${f}')`);let D={nodeId:f,state:R,taskState:a.state.tasks[f],config:w,callbackToken:y,update:_};if(await N(D)==="task-initiate-failure")throw new Error(`Handler '${E}' returned task-initiate-failure (task '${f}')`)}}function g(f){let _=a.config.tasks[f]?.taskHandlers;if(!_||_.length===0)return;d.append({type:"task-started",taskName:f,timestamp:new Date().toISOString()}),v();let w=ic(f),C=k(f,w).catch(R=>{i||(d.append({type:"task-failed",taskName:f,error:R.message??String(R),timestamp:new Date().toISOString()}),v());}).finally(()=>{u.delete(C);});u.add(C);}return {push(f){i||(f.type==="task-completed"&&f.data&&!f.dataHash&&(f={...f,dataHash:Ao(f.data)}),o.append(f),v());},pushAll(f){if(!i){for(let y of f)y.type==="task-completed"&&y.data&&!y.dataHash?o.append({...y,dataHash:Ao(y.data)}):o.append(y);v();}},resolveCallback(f,y,_){if(i)return;let w=ch(f);if(!w)return;let{taskName:C}=w;if(a.config.tasks[C]){if(_&&_.length>0)o.append({type:"task-failed",taskName:C,error:_.join("; "),timestamp:new Date().toISOString()});else {let R=y&&Object.keys(y).length>0?Ao(y):void 0;o.append({type:"task-completed",taskName:C,data:y,dataHash:R,timestamp:new Date().toISOString()});}v();}},addNode(f,y){i||(o.append({type:"task-upsert",taskName:f,taskConfig:y,timestamp:new Date().toISOString()}),v());},removeNode(f){i||(o.append({type:"task-removal",taskName:f,timestamp:new Date().toISOString()}),v());},addRequires(f,y){i||(o.append({type:"node-requires-add",nodeName:f,tokens:y,timestamp:new Date().toISOString()}),v());},removeRequires(f,y){i||(o.append({type:"node-requires-remove",nodeName:f,tokens:y,timestamp:new Date().toISOString()}),v());},addProvides(f,y){i||(o.append({type:"node-provides-add",nodeName:f,tokens:y,timestamp:new Date().toISOString()}),v());},removeProvides(f,y){i||(o.append({type:"node-provides-remove",nodeName:f,tokens:y,timestamp:new Date().toISOString()}),v());},registerHandler(f,y){c.set(f,y);},unregisterHandler(f){c.delete(f);},retrigger(f){i||a.config.tasks[f]&&(o.append({type:"task-restart",taskName:f,timestamp:new Date().toISOString()}),v());},retriggerAll(f){if(!i){for(let y of f)a.config.tasks[y]&&o.append({type:"task-restart",taskName:y,timestamp:new Date().toISOString()});v();}},snapshot(){return Rr(a)},getState(){return a},getSchedule(){return Cr(a)},async waitForHandlers(){u.size>0&&await Promise.allSettled([...u]);},async dispose(f){f?.wait&&u.size>0&&await Promise.allSettled([...u]),i=true;}}}var lh=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))),Sn=lh("./jsonata-sync.cjs"),lc=Sn;function cc(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 fc(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 fh(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 Sn(s.expr).evaluate(n);fc(e.computed_values,s.bindTo,o),n.computed_values=e.computed_values;}catch{}return e}function ph(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=lc(o.expr).evaluate(n);fc(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 mh(e,t,r){let n={...r??{},card_data:t.card_data??{},requires:t.requires??{},fetched_sources:t._sourcesData??{},computed_values:t.computed_values??{}};return Sn(e).evaluate(n)}function gh(e,t){return t.startsWith("fetched_sources.")?cc(e._sourcesData??{},t.slice(16)):cc(e,t)}var dc=new Set(["metric","table","editable-table","chart","form","filter","list","notes","todo","alert","narrative","badge","text","markdown","ref","custom","actions"]),hh=new Set(["id","meta","requires","provides","view","card_data","compute","source_defs"]);function yh(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))hh.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`):dc.has(s.kind)||t.push(`view.elements[${o}].kind: unknown kind "${s.kind}". Valid: ${[...dc].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 vh(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 Sn(a).evaluate(r);}catch{s[o]=void 0;}}return {...n,_projections:s}}))}function bh(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]=lc(a).evaluate(r);}catch{s[o]=void 0;}}return {...n,_projections:s}})}var ut={run:fh,runSync:ph,eval:mh,resolve:gh,validate:yh,enrichSources:vh,enrichSourcesSync:bh};function kh(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:se({kind:"fs-path",value:e}),...t?{extra:t}:{}}}function Po(e){return JSON.stringify(e)}function Oo(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 _n(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],b=c[l],v=b&&typeof b=="object"&&!Array.isArray(b)?{...b}:{};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();o[s]&&(delete o[s],e.writeIndex(o));},readIndex(){return r()}}}function jo(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}`)}}}function hc(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 yc(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 Er="v1",ct="board/graph",vc="board/lastJournalProcessedId";function pc(e){return `cards/${e}/runtime`}function bc(e){return {readRuntime(t){return e.read(pc(t))??{_sources:{}}},writeRuntime(t,r){e.write(pc(t),r);}}}function wh(e,t){let r={...e};for(let n of t.deleteKeys)delete r[n];return {...r,...t.shallowMerge}}function kc(e){return {readSnapshot(t){return e.readValues(t)},commitSnapshot(t,r){if(r.schemaVersion!==Er)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=wh(n.values,r);return {ok:true,newVersion:e.writeValues(t,s,r.deleteKeys)}}}}function No(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 Oo(r.trim())},writeTaskExecutorRef(r){e.write("task-executor",Po(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);}}}function wc(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 Sh(e){return e?.lastRequestedAt?!e.lastFetchedAt||e.lastFetchedAt<e.lastRequestedAt:false}function mc(e,t){return e?.lastRequestedAt?Sh(e)?"in-flight":!e.lastFetchedAt||e.lastFetchedAt<t?"dispatch":"idle":"dispatch"}function _h(e,t){let r={...e,lastFetchedAt:t};return delete r.lastError,r}function gc(e,t){let r={...e,lastError:t};return delete r.lastFetchedAt,r}function Rn(e,t){let r=t.state.tasks,n=t.config.tasks,s=Object.keys(r),o=Cr(t),a={completed:0,failed:0,in_progress:0,pending:0,blocked:0,unresolved:0},i=new Map;for(let m of o.pending)i.set(m.taskName,m.waitingOn);for(let m of o.unresolved)i.set(m.taskName,m.missingTokens);for(let m of o.blocked)i.set(m.taskName,m.failedTokens);let u=new Map;for(let[m,p]of Object.entries(n))for(let k of p.requires??[]){let g=u.get(k)??[];g.push(m),u.set(k,g);}let c=s.sort().map(m=>{let p=r[m],k=n[m]??{requires:[],provides:[]};p.status==="completed"?a.completed+=1:p.status==="failed"?a.failed+=1:p.status==="in-progress"&&(a.in_progress+=1);let g=k.requires??[],f=k.provides??[],y=Object.keys(p.data??{}).sort(),_=g.filter(D=>t.state.availableOutputs.includes(D)),w=g.filter(D=>!t.state.availableOutputs.includes(D)),C=i.get(m)??w,R=new Set;for(let D of f)for(let M of u.get(D)??[])M!==m&&R.add(M);let E=p.failedAt,N=p.error?{message:p.error,code:"TASK_FAILED",at:E,source:"task-runtime"}:void 0;return {name:m,status:p.status,error:N,requires:g,requires_satisfied:_,requires_missing:w,provides_declared:f,provides_runtime:y,blocked_by:C,unblocks:Array.from(R).sort(),runtime:{attempt_count:p.executionCount??0,restart_count:p.retryCount??0,in_progress_since:p.status==="in-progress"?p.startedAt??null:null,last_transition_at:p.lastUpdated??null,last_completed_at:p.completedAt??null,last_restarted_at:p.startedAt??null,status_age_ms:p.lastUpdated?0:null}}});a.pending=o.pending.length,a.blocked=o.blocked.length,a.unresolved=o.unresolved.length;let d=c.map(m=>({name:m.name,fanOut:m.unblocks.length})).sort((m,p)=>p.fanOut-m.fanOut||m.name.localeCompare(p.name)),l=d.length>0?d[0]:{name:null,fanOut:0},b=new Set;for(let m of Object.values(n))for(let p of m.requires??[])b.add(p);let v=0;for(let[m,p]of Object.entries(n)){let k=(p.requires??[]).length===0,f=(p.provides??[]).some(y=>(u.get(y)??[]).some(_=>_!==m));k&&!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(b).length,max_fan_out_card:l.name,max_fan_out:l.fanOut}},cards:c}}function Rh(){return new Date().toISOString()}function Sc(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??{},b=c.source_defs??[],v=b.filter(q=>q.optionalForCompletionGating!==true),m=r.cardRuntimeStore.readRuntime(d),p=false,k=()=>{p&&(r.cardRuntimeStore.writeRuntime(d,m),p=false);},g=q=>({...m._sources[q]??{}}),f=(q,S)=>{m._sources[q]=S,p=true;},y=i.taskState?.executionCount??0;if(m._lastExecutionCount!==y&&(m._sources={},m._lastExecutionCount=y,p=true),i.update){let q=i.update,S=q.outputFile;if(S){let h=g(S);if(q.failure)f(S,gc(h,q.reason??"unknown"));else {let $=q.rqt;if(!h.lastFetchedAt||$>h.lastFetchedAt){let A=typeof q.deliveryToken=="string"?q.deliveryToken:void 0,K=false;A&&(K=r.fetchedSourcesStore.commitSourceData(d,S,A)),K?f(S,_h(h,$)):f(S,gc(h,`source delivery commit failed for ${S} token=${String(A)}`));}}k();}}let w={};for(let q of b)if(q.outputFile){let S=r.fetchedSourcesStore.readSourceData(d,q.outputFile);S!==null&&(w[q.bindTo]=S);}let C={};for(let[q,S]of Object.entries(i.state??{}))if(S!==null&&typeof S=="object"&&!Array.isArray(S)){let h=S[q];C[q]=h!==void 0?h:S;}else C[q]=S;let R={id:d,card_data:{...l},requires:C,source_defs:b,compute:c.compute};R._sourcesData=w,c.compute&&ut.runSync(R,{sourcesData:w}),(o??r.outputStore.writeComputedValues.bind(r.outputStore))(d,R.computed_values??{});let E={...c},N=ut.enrichSourcesSync(Array.isArray(c.source_defs)?c.source_defs:void 0,{card_data:c.card_data,requires:C}),D=e.value;E.source_defs=Array.isArray(N)?N.map(q=>({...q,boardDir:typeof q.boardDir=="string"&&q.boardDir?q.boardDir:D})):N;let M=Rh(),te=i.update?void 0:M,U=v.filter(q=>{let S=q.outputFile;if(typeof S!="string"||!S)return true;let h=g(S);te&&(h={...h,queueRequestedAt:te},f(S,h));let $=h.queueRequestedAt??h.lastRequestedAt??M,A=mc(h,$);return A==="in-flight"?false:A==="dispatch"});if(k(),U.length>0){let q=false,S=M;for(let h of U){let $=h.outputFile;if(typeof $!="string"||!$)continue;let A=g($),K=A.queueRequestedAt??M;f($,{...A,lastRequestedAt:K}),S=K,q=true;}return q&&k(),q&&(u.push({taskKind:"source-fetch",payload:{boardRef:se(e),enrichedCard:E,callbackToken:i.callbackToken,rqt:S}}),r.executionRequestStore.appendEntries(t,u)),"task-initiated"}if(v.some(q=>{let S=q.outputFile;if(typeof S!="string"||!S)return false;let h=g(S);if(h.lastError)return false;let $=h.queueRequestedAt??h.lastRequestedAt??M;return mc(h,$)==="in-flight"}))return "task-initiated";let ze=c.provides??[],Ne={};for(let{bindTo:q,ref:S}of ze)Ne[q]=ut.resolve(R,S);return (a??r.outputStore.writeDataObjects.bind(r.outputStore))(Ne),b.filter(q=>{if(q.optionalForCompletionGating!==true)return false;let S=g(q.outputFile);return !S.lastRequestedAt||!S.lastFetchedAt?true:S.lastFetchedAt<=S.lastRequestedAt}).length>0&&u.push({taskKind:"source-fetch",payload:{boardRef:se(e),enrichedCard:E,callbackToken:i.callbackToken,rqt:M}}),n(i.nodeId,Ne),u.length>0&&r.executionRequestStore.appendEntries(t,u),"task-initiated"}}var Cn={settings:{completion:"manual",refreshStrategy:"data-changed"},tasks:{}};function _c(e){return {[ct]:e.graph,[vc]:e.lastDrainedJournalId}}function Rc(e){let t=e[ct],r=e[vc];if(!t||typeof t!="object")throw new Error(`State snapshot is missing required key: ${ct}`);return {graph:t,lastDrainedJournalId:typeof r=="string"?r:""}}function Cc(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 X(e){return e!==void 0?{status:"success",data:e}:{status:"success"}}function j(e){return {status:"fail",error:e}}function Z(e){return {status:"error",error:e instanceof Error?e.message:String(e)}}function Ch(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 Ec(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 $n(e){try{let t=JSON.parse(Ec(e));return typeof t?.t=="string"?{taskName:t.t}:null}catch{return null}}function $h(e){return Ch(JSON.stringify(e))}function $c(e){try{let t=JSON.parse(Ec(e));return typeof t?.cbk=="string"&&typeof t?.cid=="string"&&typeof t?.b=="string"&&typeof t?.d=="string"?t:null}catch{return null}}function Ce(){return new Date().toISOString()}function Eh(e,t){let r=t.onWarn??(()=>{}),n=se(e);function s(S){if(S.length!==0)try{let h=t.publishBoardChangeNotifications?.(S);h&&typeof h.catch=="function"&&h.catch($=>r(`[board-live-cards-public] publishBoardChangeNotifications failed: ${$ instanceof Error?$.message:String($)}`));}catch(h){r(`[board-live-cards-public] publishBoardChangeNotifications failed: ${h instanceof Error?h.message:String(h)}`);}}function o(){let S=i().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 h=t.kvStorageForRef(S);return {readIndex(){return h.read("_index")},writeIndex($){h.write("_index",$);},readCard($){return h.read($)},writeCard($,A){return h.write($,A),t.hashFn(A)},cardExists($){return h.read($)!==null},defaultCardKey($){return $}}}let a={readValues(S){let h=t.kvStorage("state-snapshot"),$=h.listKeys().sort();if($.length===0)return {version:null,values:{}};let A={};for(let K of $)A[K]=h.read(K);return {version:t.hashFn(A),values:A}},writeValues(S,h,$){let A=t.kvStorage("state-snapshot");for(let K of $)A.delete(K);for(let[K,ee]of Object.entries(h))A.write(K,ee);return t.hashFn(h)}},i=()=>No(t.kvStorage("config")),u=()=>kc(a),c=()=>hc(t.journalAdapter()),d=()=>_n(o(),r),l=()=>{let S=i().readOutputsStoreRef();if(!S)throw new Error(`Board at ${e.value} has no outputs store configured. Run: init --outputs-store-ref <b64-ref>`);return wc(t.kvStorageForRef(S))};function b(){return !!u().readSnapshot(e.value).values[ct]}function v(){let S=u().readSnapshot(e.value);if(!S.values[ct])throw new Error(`Board not initialized at ${e.value}`);return Rc(S.values)}function m(S,h){let $=u().commitSnapshot(e.value,{schemaVersion:Er,expectedVersion:h,commitId:t.genId(),committedAt:Ce(),deleteKeys:[],shallowMerge:_c(S)});if(!$.ok)throw new Error(`Snapshot commit failed (version mismatch): expected=${h??"null"} current=${$.currentVersion??"null"}`)}function p(S){c().appendEvent(S);}async function k(){let S=(P,F)=>{let oe=P.payload,He=(oe?.enrichedCard??{}).id??oe?.cardId??"unknown";p({type:"task-failed",taskName:He,error:F,timestamp:Ce()});},h=yc(t.kvStorage("execution-requests"),S),$=bc(t.kvStorage("card-runtime")),A=jo(t.blobStorage("sources"),P=>t.resolveBlob(P)),K=new Map,ee={readRuntime(P){return K.get(P)??$.readRuntime(P)},writeRuntime(P,F){K.set(P,F);}},we=[],Se=new Map,Ve={readSourceData(P,F){let oe=`${P}/${F}`;return Se.has(oe)?Se.get(oe):A.readSourceData(P,F)},ingestSourceDataStaged(P,F,oe,Et){A.ingestSourceDataStaged(P,F,oe,Et);},commitSourceData(P,F,oe){let Et=`${P}/.staged/${oe}/${F}`,Ar=t.blobStorage("sources").read(Et);if(Ar==null)return false;let xt=`${P}/${F}`,Mo=Ar.trim();try{Se.set(xt,JSON.parse(Mo));}catch{Se.set(xt,Mo);}return we.push({cardId:P,outputFile:F,deliveryToken:oe}),true},hasSource(P,F){let oe=`${P}/${F}`;return Se.has(oe)?true:A.hasSource(P,F)}},qe={cardStore:d(),cardRuntimeStore:ee,fetchedSourcesStore:Ve,outputStore:l(),executionRequestStore:h},dt=v(),lt=wn(dt.graph),{events:Ct,newCursor:$t}=c().readEntriesAfterCursor(dt.lastDrainedJournalId),ft=[],En=[],xn=[],qo=new Map,Ic=(P,F)=>{ft.push({type:"task-completed",taskName:P,data:F,timestamp:Ce()});},Do=(P,F)=>p({type:"task-failed",taskName:P,error:F,timestamp:Ce()}),xr=uc(lt,{handlers:{"card-handler":Sc(e,$t,qe,Ic,Do,(P,F)=>{En.push({cardId:P,values:F});},P=>{xn.push(P);})}});for(ft=Ct;ft.length>0;){let P=ft;ft=[];for(let F of P)if(F.type==="task-restart"){let oe=qe.cardStore.readCard(F.taskName);oe&&qo.set(F.taskName,oe);}xr.pushAll(P),await xr.waitForHandlers();}let Fo=xr.getState();await xr.dispose({wait:true});let Pc=u().readSnapshot(e.value).version;m({lastDrainedJournalId:$t,graph:Rr(Fo)},Pc);for(let{cardId:P,values:F}of En)qe.outputStore.writeComputedValues(P,F);for(let P of xn)qe.outputStore.writeDataObjects(P);for(let[P,F]of K)$.writeRuntime(P,F);for(let{cardId:P,outputFile:F,deliveryToken:oe}of we)A.commitSourceData(P,F,oe);let Tr;try{Tr=Rn(n,Fo),qe.outputStore.writeStatusSnapshot(Tr);}catch(P){r(`[board-live-cards-public] status publish failed: ${P instanceof Error?P.message:String(P)}`);}let Ut=[];for(let{cardId:P,values:F}of En)Ut.push({kind:"computed_values",cardId:P,values:F});for(let P of xn)for(let[F,oe]of Object.entries(P))F&&Ut.push({kind:"data_object",key:F,payload:oe});for(let[P,F]of qo)Ut.push({kind:"card_refreshed",cardId:P,card:F});Tr!==void 0&&Ut.push({kind:"status",status:Tr}),s(Ut);let Oc=i().readTaskExecutorRef()??{howToRun:"built-in",whatToRun:se({kind:"built-in",value:"source-cli-task-executor"})};h.dispatchEntriesForJournalId($t,P=>{if(P.taskKind!=="source-fetch"){r(`[process-accumulated-events] unknown taskKind "${P.taskKind}" \u2014 skipping`);return}let F=P.payload,oe=F.enrichedCard?.id??"unknown",Et=F.enrichedCard?.source_defs??[];for(let He of Et){if(!He.outputFile){r(`[dispatch] source "${He.bindTo}" has no outputFile \u2014 skipping`);continue}let Ar=$h({cbk:F.callbackToken,rg:e.value,br:se(e),cid:oe,b:He.bindTo,d:He.outputFile,cs:void 0,rqt:F.rqt});t.dispatchExecution(Oc,{source_def:He,base_ref:se(e),callback:{token:Ar,via:t.selfRef}}).catch(xt=>Do(oe,xt instanceof Error?xt.message:String(xt)));}});}async function g(){try{let S=()=>{let $=v(),{events:A}=c().readEntriesAfterCursor($.lastDrainedJournalId);A.length<=0||(g(),t.requestProcessAccumulated?.());},h=await Vo(t.lock,k,S);return X({ran:h!==!1})}catch(S){return Z(S)}}function f(S){try{let h=S.params?.cardStoreRef;if(!h)return j("init requires params.cardStoreRef \u2014 create a card store with card-store-cli and pass its ref here");if(!b()){let ee=kn(Cn);m({lastDrainedJournalId:"",graph:Rr(ee)},null);}let $=S.params?.outputsStoreRef;if(!$)return j("init requires params.outputsStoreRef \u2014 pass the outputs store ref here");let A=i();A.writeCardStoreRef(h),A.writeOutputsStoreRef($);let K=S.body??{};K["task-executor-ref"]&&A.writeTaskExecutorRef(K["task-executor-ref"]),Object.prototype.hasOwnProperty.call(K,"chat-handler-flow")&&A.writeChatHandlerFlow(K["chat-handler-flow"]);try{l().writeStatusSnapshot(Rn(n,wn(v().graph)));}catch{}return X()}catch(h){return Z(h)}}function y(S){try{let h=l().readStatusSnapshot();if(!h){h=Rn(n,wn(v().graph));try{l().writeStatusSnapshot(h);}catch{}}return X(h)}catch(h){return Z(h)}}function _(S){try{let h=S.params?.id;return h?(p({type:"task-removal",taskName:h,timestamp:Ce()}),g(),X()):j("removeCard requires params.id")}catch(h){return Z(h)}}function w(S){try{let h=S.params?.id;return h?(p({type:"task-restart",taskName:h,timestamp:Ce()}),g(),X()):j("retrigger requires params.id")}catch(h){return Z(h)}}async function C(S){return g()}function R(S){try{let h=S.params?.cardId,$=S.params?.all,A=!!S.params?.restart;if(!h&&!$)return j("upsertCard requires --card-id <id> or --all");let K=$?d().readAllCards().map(ee=>ee.id):[h];for(let ee of K)if(!d().readCard(ee))return j(`Card "${ee}" not found in board at ${e.value}`);for(let ee of K){let we=d().readCard(ee),Se=Cc(we),Ve=t.hashFn(Se),qe=t.kvStorage("card-upsert"),dt=qe.read(ee),lt=dt?.taskConfigHash!==Ve;if(!(!lt&&!A)){if(lt){let Ct=dt?.blobRef??d().readCardKey(ee)??ee;p({type:"task-upsert",taskName:ee,taskConfig:Se,timestamp:Ce()}),qe.write(ee,{blobRef:Ct,taskConfigHash:Ve,updatedAt:Ce()});}A&&p({type:"task-restart",taskName:ee,timestamp:Ce()});}}return g(),X()}catch(h){return Z(h)}}function E(S){try{let h=S.params?.token;if(!h)return j("taskFailed requires params.token");let $=S.params?.error??"unknown error",A=$n(h);return A?(p({type:"task-failed",taskName:A.taskName,error:$,timestamp:Ce()}),g(),X()):j("Invalid callback token")}catch(h){return Z(h)}}function N(S){try{let h=S.params?.token;if(!h)return j("taskProgress requires params.token");let A=(S.body??{}).update??{},K=$n(h);return K?(p({type:"task-progress",taskName:K.taskName,update:A,timestamp:Ce()}),g(),X()):j("Invalid callback token")}catch(h){return Z(h)}}function D(S){try{let h=S.params?.token,$=S.params?.ref;if(!h)return j("sourceDataFetched requires params.token");if(!$)return j("sourceDataFetched requires params.ref");let A=$c(h);if(!A)return j("Invalid source token");let{cbk:K,cid:ee,b:we,d:Se,cs:Ve,rqt:qe}=A,dt=jo(t.blobStorage("sources"),ft=>t.resolveBlob(ft)),lt=t.genId();dt.ingestSourceDataStaged(ee,Se,_e($),lt);let Ct=$n(K);if(!Ct)return j("Invalid callback token embedded in source token");let $t=Ce();return p({type:"task-progress",taskName:Ct.taskName,update:{bindTo:we,outputFile:Se,fetchedAt:$t,deliveryToken:lt,sourceChecksum:Ve,rqt:qe},timestamp:$t}),g(),X()}catch(h){return Z(h)}}function M(S){try{let h=S.params?.token,$=S.params?.reason??"unknown";if(!h)return j("sourceDataFetchFailure requires params.token");let A=$c(h);if(!A)return j("Invalid source token");let{cbk:K,b:ee,d:we,cs:Se}=A,Ve=$n(K);return Ve?(p({type:"task-progress",taskName:Ve.taskName,update:{bindTo:ee,outputFile:we,failure:!0,reason:$,sourceChecksum:Se},timestamp:Ce()}),g(),X()):j("Invalid callback token embedded in source token")}catch(h){return Z(h)}}function te(S){try{let h=i().readCardStoreRef();return h?X({storeRef:h}):j(`Board at ${e.value} has no card store configured`)}catch(h){return Z(h)}}function U(S){try{let h=i().readOutputsStoreRef();return h?X({storeRef:h}):j(`Board at ${e.value} has no outputs store configured`)}catch(h){return Z(h)}}function de(S){try{let h=S.params?.key;if(!h)return j("getConfig requires params.key");let $=i(),A;switch(h){case "task-executor":A=$.readTaskExecutorRef()??null;break;case "chat-handler-flow":A=$.readChatHandlerFlow()??null;break;case "card-store-ref":A=$.readCardStoreRef();break;case "outputs-store-ref":A=$.readOutputsStoreRef();break;default:return j(`getConfig: unknown key "${h}"`)}return X({value:A})}catch(h){return Z(h)}}function ze(S){try{let h=S.params?.key;if(!h)return j("getOutputsDataObject requires params.key");let $=l().readDataObject(h);return X($)}catch(h){return Z(h)}}function Ne(S){try{return X(l().readAllDataObjects())}catch(h){return Z(h)}}function Kt(S){try{let h=S.params?.key;if(!h)return j("getOutputsComputedValues requires params.key");let $=l().readComputedValues(h);return X($)}catch(h){return Z(h)}}function q(S){try{return X(l().readAllComputedValues())}catch(h){return Z(h)}}return {init:f,status:y,getCardStoreRef:te,getOutputsStoreRef:U,getConfig:de,getOutputsDataObject:ze,getAllOutputsDataObjects:Ne,getOutputsComputedValues:Kt,getAllOutputsComputedValues:q,removeCard:_,retrigger:w,processAccumulatedEvents:C,upsertCard:R,taskFailed:E,taskProgress:N,sourceDataFetched:D,sourceDataFetchFailure:M}}function xh(e,t){let r=()=>No(t.kvStorage("config"));function n(){let g=r().readCardStoreRef();if(!g)throw new Error(`Board at ${e.value} has no card store configured. Run: init --base-ref <ref> --store-ref <b64-ref>`);let f=t.kvStorageForRef(g);return {readIndex(){return f.read("_index")},writeIndex(y){f.write("_index",y);},readCard(y){return f.read(y)},writeCard(y,_){return f.write(y,_),t.hashFn(_)},cardExists(y){return f.read(y)!==null},defaultCardKey(y){return y}}}let s=()=>_n(n(),t.onWarn??(()=>{}));function o(g,f){let y=t.validateSchema(f),_=[],w=r().readTaskExecutorRef();if(w&&Array.isArray(f.source_defs))for(let R of f.source_defs){let E=typeof R.bindTo=="string"?R.bindTo:"(unknown)";try{let N;try{N=t.invokeExecutorSync(w,"validate-source-def",[],{timeout:t.executorTimeouts?.validationMs??1e4,input:JSON.stringify(R)});}catch(M){let te=M;if(N=typeof te?.stdout=="string"?te.stdout:"",!N.trim()){_.push(`source "${E}": executor validate-source-def failed \u2014 ${M instanceof Error?M.message:String(M)}`);continue}}let D=JSON.parse(N.trim());if(!D.ok&&Array.isArray(D.errors))for(let M of D.errors)_.push(`source "${E}": ${M}`);}catch(N){_.push(`source "${E}": executor validate-source-def failed \u2014 ${N instanceof Error?N.message:String(N)}`);}}let C=[...y.errors,..._];return X({cardId:g,isValid:C.length===0,issues:C})}function a(g,f,y){let _=r().readTaskExecutorRef();if(!_)return j("No task-executor registered for this board");let w=typeof g.bindTo=="string"?g.bindTo:"source",C=t.makeTempFilePath(`probe-in-${w}`),R=t.makeTempFilePath(`probe-out-${w}`),E=t.makeTempFilePath(`probe-err-${w}`,".txt"),N={...g,boardDir:e.value,_projections:f},D=se({kind:"fs-path",value:C}),M=se({kind:"fs-path",value:R}),te=se({kind:"fs-path",value:E});t.absoluteBlob.write(C,JSON.stringify(N,null,2));let U=null;try{if(t.invokeExecutorSync(_,"run-source-fetch",["--in-ref",D,"--out-ref",M,"--err-ref",te],{timeout:g.timeout??t.executorTimeouts?.probeMs??6e4}),U=t.absoluteBlob.read(R),U===null)return j("Executor produced no output file")}catch(de){let ze=t.absoluteBlob.read(E)?.trim()??(de instanceof Error?de.message:String(de));return j(`Probe failed: ${ze}`)}finally{try{t.absoluteBlob.remove(C);}catch{}try{t.absoluteBlob.remove(E);}catch{}}if(y){let de=_e(y);t.absoluteBlob.write(de.value,U);}else try{t.absoluteBlob.remove(R);}catch{}return X({bindTo:w,resultSizeBytes:U.length})}function i(g){try{let f=g.params?.cardId,y=g.params?.all;if(!f&&!y)return j("validateCard requires --card-id <id> or --all");let _=y?s().readAllCards().map(C=>C.id):[f],w=[];for(let C of _){let R=s().readCard(C);if(!R){w.push({cardId:C,isValid:!1,issues:[`Card "${C}" not found`]});continue}let E=o(C,R);if(E.status!=="success")return E;w.push(E.data);}return X(w)}catch(f){return Z(f)}}function u(g){try{if(!g.body||typeof g.body!="object"||Array.isArray(g.body))return j("validateCardPreflight requires card JSON object in body");let f=g.body,y=f["card-content"]??f,_=typeof y.id=="string"?y.id:"(unknown)",w=o(_,y),C=r().readTaskExecutorRef();if(C)try{let R=t.invokeExecutorSync(C,"validate-card-preflight",[],{timeout:t.executorTimeouts?.validationMs??1e4,input:JSON.stringify(y)}),E=JSON.parse(R.trim());if(!E.ok&&Array.isArray(E.errors)&&E.errors.length>0){let N=[...w.status==="success"?w.data.issues:[],...E.errors];return X({cardId:_,isValid:!1,issues:N})}}catch{}return w}catch(f){return Z(f)}}function c(g){try{let f=g.params?.cardId,y=g.params?.sourceIdx,_=g.params?.outRef;if(!f)return j("probeSource requires params.cardId");if(y===void 0)return j("probeSource requires params.sourceIdx");let C=(g.body??{})["mock-projections"]??{},R=s().readCard(f);if(!R)return j(`Card "${f}" not found`);let E=R.source_defs??[];return y<0||y>=E.length?j(`sourceIdx ${y} out of range (card has ${E.length} source(s))`):a(E[y],C,_)}catch(f){return Z(f)}}function d(g){try{let f=g.params?.outRef,y=g.body;if(!y)return j('probeTmpSource requires body with "source-def" and "mock-projections"');let _=y["source-def"],w=y["mock-projections"]??{};return _?a(_,w,f):j('probeTmpSource body requires "source-def"')}catch(f){return Z(f)}}function l(g){try{let f=g.params?.sourceIdx,y=g.params?.outRef;if(f===void 0)return j("probeSourcePreflight requires params.sourceIdx");if(!g.body||typeof g.body!="object"||Array.isArray(g.body))return j("probeSourcePreflight requires card JSON object in body");let _=g.body,w=_["card-content"]??_,C=_["mock-projections"]??{},R=w.source_defs??[];if(f<0||f>=R.length)return j(`sourceIdx ${f} out of range (card has ${R.length} source(s))`);let E=R[f],N=r().readTaskExecutorRef();if(N){let D=typeof E.bindTo=="string"?E.bindTo:"source";try{let M={...E,_projections:C},te=t.invokeExecutorSync(N,"probe-source-preflight",[],{timeout:E.timeout??t.executorTimeouts?.preflightMs??6e4,input:JSON.stringify(M)}),U=JSON.parse(te.trim());return U.ok?X({bindTo:D,reachable:U.reachable,latencyMs:U.latencyMs,note:U.note}):j(U.error??"Preflight probe failed")}catch{}}return a(E,C,y)}catch(f){return Z(f)}}function b(g){try{let f=r().readTaskExecutorRef();if(!f)return j("No task-executor registered for this board");let y=t.invokeExecutorSync(f,"describe-capabilities",[],{timeout:t.executorTimeouts?.describeMs??1e4});return X(JSON.parse(y.trim()))}catch(f){return Z(f)}}function v(g){try{let f=g.body;if(!f||!Array.isArray(f.ops))return j("updatesInCardStore requires body.ops array");let y=f.ops,_=s();for(let w of y){let C=w.op,R=w.id;if(!R)return j('op is missing "id"');if(C==="update"){let E=w["card-content"];if(!E)return j(`update op for "${R}" is missing "card-content"`);_.writeCard(R,E);}else return j(`Unknown op type: "${C??"(none)"}"`)}return X()}catch(f){return Z(f)}}function m(g){try{let f=g.body;if(!f||!Array.isArray(f.ids))return j("readFromCardStore requires body.ids array");let y=f.ids,_=s(),w=y.map(C=>({id:C,"card-content":_.readCard(C)}));return X({cards:w})}catch(f){return Z(f)}}function p(g){try{if(!g.body||typeof g.body!="object"||Array.isArray(g.body))return j("evalCardCompute requires a JSON object in body");let f=g.body,y=f["card-content"]??f,_=typeof y.id=="string"?y.id:"(unknown)",w=f["mock-fetched-sources"]??{},C=f["mock-requires"]??{},R=y.compute;if(!R||!Array.isArray(R)||R.length===0)return X({cardId:_,ok:!0,computed_values:{},errors:[]});let E={id:_,card_data:y.card_data??{},requires:C,source_defs:y.source_defs,compute:R},N=ut.runSync(E,{sourcesData:w}),D=N.node.computed_values??{},M=N.errors??[];return X({cardId:_,ok:M.length===0,computed_values:D,errors:M})}catch(f){return Z(f)}}function k(g){try{if(!g.body||typeof g.body!="object"||Array.isArray(g.body))return j("simulateCardCycle requires a JSON object in body");let f=g.body,y=f["card-content"]??f,_=typeof y.id=="string"?y.id:"(unknown)",w=f["mock-fetched-sources"]??{},C=f["mock-requires"]??{},R=o(_,y),E=R.status==="success"?{isValid:R.data.isValid,issues:R.data.issues}:{isValid:!1,issues:[R.status==="fail"?R.error:"internal error"]},N=y.source_defs??[],D=y.card_data??{},M=[],te=[];if(N.length>0){M=ut.enrichSourcesSync(N,{card_data:D,requires:C});for(let h of M){let $=h.projections,A=h._projections;if($&&A){for(let K of Object.keys($))if(A[K]===void 0){let ee=typeof h.bindTo=="string"?h.bindTo:"(unknown)";te.push({bindTo:ee,key:K,error:`Projection "${K}" resolved to undefined`});}}}}let U=[],de=f["task-executor-ref"],ze=(de?.howToRun&&de?.whatToRun?de:void 0)??r().readTaskExecutorRef();for(let h=0;h<M.length;h++){let $=M[h],A=typeof $.bindTo=="string"?$.bindTo:`source_${h}`;if(!ze){U.push({bindTo:A,skipped:!0,error:"No task executor configured"});continue}try{let K={...$},ee=t.invokeExecutorSync(ze,"probe-source-preflight",[],{timeout:$.timeout??t.executorTimeouts?.preflightMs??6e4,input:JSON.stringify(K)}),we=JSON.parse(ee.trim());U.push({bindTo:A,reachable:we.reachable,latencyMs:we.latencyMs,error:we.ok?void 0:we.error});}catch{U.push({bindTo:A,skipped:!0,error:"Executor does not support probe-source-preflight"});}}let Ne=y.compute,Kt={},q=[];if(Ne&&Array.isArray(Ne)&&Ne.length>0){let h={id:_,card_data:D,requires:C,source_defs:y.source_defs,compute:Ne},$=ut.runSync(h,{sourcesData:w});Kt=$.node.computed_values??{},q=$.errors??[];}let S=E.isValid&&te.length===0&&q.length===0&&U.every(h=>h.reachable!==!1);return X({cardId:_,ok:S,validation:E,source_probes:U,projection_errors:te,computed_values:Kt,compute_errors:q})}catch(f){return Z(f)}}return {validateCard:i,validateCardPreflight:u,probeSource:c,probeTmpSource:d,probeSourcePreflight:l,evalCardCompute:p,simulateCardCycle:k,describeTaskExecutorCapabilities:b,updatesInCardStore:v,readFromCardStore:m}}function Th(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 {get(s){try{let o=s.params?.id;if(o){let a=e.readCard(o);return a?t({cards:[a]}):r(`card "${o}" not found`)}return t({cards:e.readAllCards()})}catch(o){return n(o)}},set(s){try{let o=s.body;if(o==null)return r("set requires a body (card object or array of cards)");let a=Array.isArray(o)?o:[o];for(let i of a){if(typeof i.id!="string")return r("each card must have a string `id` field");e.writeCard(i.id,i);}return t({count:a.length})}catch(o){return n(o)}},del(s){try{let o=s.body?.ids??[],a=s.params?.id,i=a?[...o,a]:o;if(i.length===0)return r("del requires body.ids (string[]) or params.id");for(let u of i)e.removeCard(u);return t({count:i.length})}catch(o){return n(o)}},patch(s){try{let o=s.params?.id,a=s.params?.path;if(!o)return r("patch requires params.id");if(!a)return r("patch requires params.path");let i=s.body,u=i&&Object.prototype.hasOwnProperty.call(i,"value")?i.value:s.body;return e.patchCard(o,a,u),t({count:1})}catch(o){return n(o)}}}}function Ah(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 xc(){return new Date().toISOString()}function Tc(e){return new TextEncoder().encode(e).byteLength}function Ih(e){return e?{key:e.key,size:e.size,updatedAt:e.updatedAt,contentType:e.contentType}:null}function Ph(e){let t=String(e||"").match(/^(\d+)[-_]/);return t?parseInt(t[1],10):0}function Oh(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 jh(e){return String(e||"").toLowerCase().replace(/\s+/g,"_").replace(/[^a-z0-9_-]/g,"_").replace(/_+/g,"_").replace(/^_+|_+$/g,"")||"file"}function Nh(e){if(!e||e===".")return "";let t=String(e).replace(/^\./,"").toLowerCase().replace(/[^a-z0-9]/g,"");return t?`.${t}`:""}function qh(e){let t=Oh(e),r=t.lastIndexOf(".");return r<=0||r===t.length-1?{stem:t,ext:""}:{stem:t.slice(0,r),ext:t.slice(r)}}function Dh(e){let t=e.lastIndexOf("/");return t>=0?e.slice(t+1):e}function Fh(e){function t(r){let n=e.stat?Ih(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:Tc(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??xc(),o.size=o.size??Tc(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??xc(),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 Mh(e){function t(s,o){let a=0,i=[];Array.isArray(o)&&i.push(...o);for(let u of e.list(`${s}/`))i.push(Dh(u.key));for(let u of i){let c=Ph(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}=qh(s),d=Nh(c),l=jh(u),b=`${String(o).padStart(3,"0")}-`,v=d,m=i-b.length-v.length;m<1&&(v="",m=i-b.length);let p=l.slice(0,Math.max(1,m)),k=`${b}${p}${v}`;return k.length>i&&(k=k.slice(0,i).replace(/\.$/,"")),k}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 Lh(){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,path:typeof u.path=="string"?u.path:null,uploaded_at:typeof u.uploaded_at=="string"?u.uploaded_at:o||null});}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 jb(){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,a=typeof o=="string"?_e(o):o;a.kind==="fs-path"&&(r=a.value);}catch{r="";}if(!r)return {dispatched:false,error:"createNodeSpawnInvocationAdapter: could not resolve fs-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,n=typeof r=="string"?_e(r):r;n.kind==="fs-path"&&(t=n.value);}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 Gh=".board.lock";function Kh(e,t){return typeof e=="string"?{cliDir:e,opts:t}:{cliDir:void 0,opts:e}}function Uh(e,t){return typeof e=="string"?{cliDir:e,opts:t}:{cliDir:void 0,opts:e}}function Ac(e){if(e)return e;let t=zo((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,We(t,"..","cli","node"),We(t,"..","..","cli","node")];for(let n of r)try{return On(n),n}catch{}throw new Error(`createFsBoardPlatformAdapter: could not resolve a public CLI directory from module dir ${t}`)}function Jh(e,t,r){let{cliDir:n,opts:s}=Kh(t,r),o=Ac(n),a=e.value,i=s?.suppressSpawn?"":On(o),u={meta:"board-live-cards",howToRun:"local-node",whatToRun:i?se({kind:"fs-path",value:i}):"",...s?.notifyChannel?{extra:{notifyChannel:s.notifyChannel}}:{}};return {kvStorage:c=>qr(We(a,`.${c}`)),blobStorage:c=>c?Nr(We(a,c)):Nr(a),journalAdapter:()=>la(a),lock:fa(We(a,Gh)),selfRef:u,async dispatchExecution(c,d){if(s?.suppressSpawn)return {dispatched:false};try{let l=d.source_def?.bindTo??An().slice(0,8),b=Jt(a,`exec-in-${l}`),v=Jt(a,`exec-out-${l}`),m=Jt(a,`exec-err-${l}`,".txt"),p=se({kind:"fs-path",value:b}),k=se({kind:"fs-path",value:v}),g=se({kind:"fs-path",value:m});return ua({kind:"fs-path",value:b}).write(b,JSON.stringify(d,null,2)),ia(c,{subcommand:"run-source-fetch",inRef:p,outRef:k,errRef:g},o),{dispatched:!0}}catch(l){return {dispatched:false,error:l instanceof Error?l.message:String(l)}}},resolveBlob(c){let d=Uo(c.value)?Ln().read(c.value):Nr(a).read(c.value);if(d===null)throw new Error(`resolveBlob: blob not found: ::${c.kind}::${c.value}`);return d},hashFn:da,genId:()=>Jo(`${Date.now()}-${Math.random()}`).slice(0,32),kvStorageForRef:c=>qr(_e(c).value),requestProcessAccumulated(){s?.suppressSpawn||Yo(o,e,s?.notifyChannel);},publishBoardChangeNotifications(c){if(!s?.notifyChannel||c.length===0)return;let d=c.map(l=>({id:An(),ts:new Date().toISOString(),boardRef:se(e),notification:l}));Xo(s.notifyChannel,d,s.onWarn);},onWarn:s?.onWarn}}function Nb(e,t,r){let{cliDir:n,opts:s}=Uh(t,r),o=Ac(n),a=Jh(e,o,s),i=jr();return {...a,invokeExecutorSync(u,c,d,l){let{command:b,baseArgs:v}=Nn(u,o),m=u.extra?["--extra",Buffer.from(JSON.stringify(u.extra)).toString("base64")]:[];return i.executeSync(b,[...v,c,...d,...m],{timeout:l?.timeout??3e4,encoding:"utf-8",input:l?.input})},validateSchema(u){let c=Eo(u);return {ok:c.errors.length===0,errors:c.errors}},makeTempFilePath(u,c){return Jt(e.value,u,c)},absoluteBlob:Ln()}}function qb(e){let t=qr(We(e,".kv","chat"));return xo(r=>{let n=String(r).replace(/[^a-zA-Z0-9_-]/g,"_");return ca(We(e,"chats",`${n}.jsonl`))},t)}function Db(e){try{let t=JSON.parse(Buffer.from(e,"base64url").toString());return typeof t.br=="string"?t.br:null}catch{return null}}
15
- exports.BOARD_GRAPH_KEY=ct;exports.EMPTY_CONFIG=Cn;exports.SNAPSHOT_SCHEMA_VERSION_V1=Er;exports.createArtifactsStore=Fh;exports.createArtifactsStorePublic=Ah;exports.createBoardLiveCardsNonCorePublic=xh;exports.createBoardLiveCardsPublic=Eh;exports.createCardFileMetadataStore=Lh;exports.createCardStore=_n;exports.createCardStorePublic=Th;exports.createChatStorage=xo;exports.createExecutionRefInvoker=ud;exports.createFileArtifactsStore=Mh;exports.createFsBoardChatStorage=qb;exports.createFsBoardNonCorePlatformAdapter=Nb;exports.createFsBoardPlatformAdapter=Jh;exports.createInMemoryChatStorage=Yg;exports.createNodeSpawnInvocationAdapter=jb;exports.decodeBoardRefFromToken=Db;exports.evaluateArgsMassaging=qn;exports.executionRefFromScriptPath=kh;exports.invokeExecutionRef=aa;exports.invokeExecutionRefSync=Dn;exports.invokeRefSync=cd;exports.parseExecutionRef=Oo;exports.parseRef=_e;exports.serializeExecutionRef=Po;exports.serializeRef=se;//# sourceMappingURL=board-live-cards-node.cjs.map
14
+ `,"utf-8");},generateId(){return crypto.randomUUID()}}}function fa(e){return {tryAcquire(){try{if(!T__namespace.existsSync(e)){T__namespace.mkdirSync(ie__namespace.dirname(e),{recursive:!0});try{T__namespace.writeFileSync(e,"{}",{flag:"wx"});}catch{}}return properLockfile.lockSync(e,{retries:0})}catch{return null}}}}var pa={$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"}},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 Gu=Vc(Lu());var Ug=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))),Jg=Ug("./jsonata-sync.cjs"),vn=null;var Vu=/\b(card_data|requires|fetched_sources|computed_values|source_defs)\b/g,zg=/^\s*(card_data|requires|fetched_sources|computed_values|source_defs)(\.|$)/;function Hg(e){let t=new Set,r;for(Vu.lastIndex=0;(r=Vu.exec(e))!==null;)t.add(r[1]);return t}function Ku(e){let t=zg.exec(e);return t?t[1]:null}function Bu(e,t,r,n){try{Jg(e);}catch(o){let a=o instanceof Error?o.message:String(o);n.push(`${t}: invalid JSONata expression (${a})`);return}let s=Hg(e);for(let o of s)r.has(o)||n.push(`${t}: disallowed namespace "${o}" in expression`);}function $o(e,t,r){if(Array.isArray(e)){e.forEach((s,o)=>{$o(s,`${t}/${o}`,r);});return}if(typeof e=="string"){let s=Ku(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))$o(o,`${t}/${s}`,r);}function Wg(){if(vn)return vn;let e=new Gu.default({allErrors:true});return Gg__default.default(e),vn=e.compile(pa),vn}function Uu(e){let t=Wg(),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 Ju(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||Bu(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 k=Ku(l);k===null?t.push(`/provides/${d}/ref: path "${l}" must start with a valid namespace (${[...s].join(", ")})`):s.has(k)||t.push(`/provides/${d}/ref: disallowed namespace "${k}" in path "${l}" (valid: ${[...s].join(", ")})`);});let a=r.view;a&&typeof a=="object"&&!Array.isArray(a)&&$o(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[k,v]of Object.entries(l))typeof v!="string"||v.trim().length===0||Bu(v,`/source_defs/${d}/projections/${k}`,i,t);}),{ok:t.length===0,errors:t}}function Eo(e){let t=Uu(e);if(!t.ok)return t;let r=Ju(e);return r.ok?{ok:true,errors:[]}:{ok:false,errors:r.errors}}function zu(e){return String(e).replace(/[^a-zA-Z0-9_-]/g,"_")}function Hu(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:[],updated_at:typeof t.updated_at=="string"?t.updated_at:""}}function xo(e,t){let r=s=>`chats/${zu(s)}/processing`,n=s=>`chats/${zu(s)}/config`;return {append(s,o,a,i=[]){return e(s).append({role:o,text:a,files:i,updated_at:new Date().toISOString()}).id},readAll(s){return e(s).readAll().map(Hu)},readAfter(s,o){let a=e(s).readAfter(o);return {records:a.entries.map(Hu),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 Yg(){let e=globalThis.crypto;return typeof e?.randomUUID=="function"?String(e.randomUUID()):`id-${Date.now()}-${Math.random().toString(36).slice(2)}`}function Xg(){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=[]){let i={id:Yg(),role:s,text:o,files:a,updated_at:new Date().toISOString()};return r(n).push(i),i.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 at={RUNNING:"running",COMPLETED:"completed",FAILED:"failed",INACTIVATED:"inactivated"};function Ce(e){return e?Array.isArray(e.provides)?e.provides:[]:[]}function it(e){return e?Array.isArray(e.requires)?e.requires:[]:[]}function Wu(e){return e.tasks??{}}function To(e){return e?e.status===at.FAILED||e.status===at.INACTIVATED:false}function Yu(e,t){return e.refreshStrategy??t?.refreshStrategy??"data-changed"}function Xu(e){return e.maxExecutions}function Qu(e,t){let r=new Set;for(let[n,s]of Object.entries(t))if(s.status===at.COMPLETED){let o=e.tasks[n];o&&Ce(o).forEach(i=>r.add(i));}return Array.from(r)}function Zu(e,t){let r={};return e.forEach(n=>{let s=t[n];if(!s)return;Ce(s).forEach(a=>{r[a]||(r[a]=[]),r[a].push(n);});}),r}function ec(e,t,r){let n=e.tasks[t]??kn(),s={};if(r){let a=r.tasks[t],i=it(a);for(let u of i)for(let[c,d]of Object.entries(r.tasks))if(Ce(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 tc(e,t,r,n,s,o){let a=e.tasks[r]??kn(),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=Ce(i);let c=a.startConsumedHashes?{...a.startConsumedHashes}:{...a.lastConsumedHashes};if(!a.startConsumedHashes){let k=i.requires??[];for(let v of k)for(let[m,p]of Object.entries(t.tasks))if(Ce(p).includes(v)){let b=e.tasks[m];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 rc(e,t,r,n){let s=e.tasks[r]??kn(),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 nc(e,t,r,n){let s=e.tasks[t]??kn(),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 sc(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 kn(){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]=ac();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 Qg(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:ec(n,t.taskName,r)};case "task-completed":return {config:r,state:tc(n,r,t.taskName,t.result,t.dataHash,t.data)};case "task-failed":return {config:r,state:rc(n,r,t.taskName,t.error)};case "task-progress":return {config:r,state:nc(n,t.taskName,t.message,t.progress)};case "task-restart":return {config:r,state:sc(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:oh(n,t.action)};case "task-upsert":return Zg(e,t.taskName,t.taskConfig);case "task-removal":return eh(e,t.taskName);case "node-requires-add":return th(e,t.nodeName,t.tokens);case "node-requires-remove":return rh(e,t.nodeName,t.tokens);case "node-provides-add":return nh(e,t.nodeName,t.tokens);case "node-provides-remove":return sh(e,t.nodeName,t.tokens);default:return e}}function oc(e,t){return t.reduce((r,n)=>Qg(r,n),e)}function Zg(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]:ac()},lastUpdated:new Date().toISOString()}}}function eh(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 th(e,t,r){let n=e.config.tasks[t];if(!n)return e;let s=it(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 rh(e,t,r){let n=e.config.tasks[t];if(!n)return e;let s=it(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 nh(e,t,r){let n=e.config.tasks[t];if(!n)return e;let s=Ce(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 sh(e,t,r){let n=e.config.tasks[t];if(!n)return e;let s=Ce(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 Rr(e){return {version:1,config:e.config,state:e.state,snapshotAt:new Date().toISOString()}}function Sn(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 ac(){return {status:"not-started",executionCount:0,retryCount:0,lastEpoch:0,messages:[],progress:null}}function oh(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 Cr(e){let{config:t,state:r}=e,n=Wu(t);if(Object.keys(n).length===0)return {eligible:[],pending:[],unresolved:[],blocked:[],conflicts:{}};let o=ah(n),a=Qu(t,r.tasks),i=new Set([...a,...r.availableOutputs]),u=[],c=[],d=[],l=[];for(let[v,m]of Object.entries(n)){let p=r.tasks[v],b=Yu(m,t.settings),g=b!=="once";if(p?.status===at.RUNNING||To(p))continue;let f=Xu(m);if(f!==void 0&&p&&p.executionCount>=f||m.circuit_breaker&&p&&p.executionCount>=m.circuit_breaker.max_executions||!g&&p?.status===at.COMPLETED)continue;if(g&&p?.status===at.COMPLETED){let R=it(m),E=false;switch(b){case "data-changed":{R.length>0&&R.some(D=>{for(let[M,te]of Object.entries(n))if(Ce(te).includes(D)){let U=r.tasks[M];if(!U)continue;let de=p.lastConsumedHashes?.[D];return U.lastDataHash==null?U.executionCount>p.lastEpoch:U.lastDataHash!==de}return false})||(E=true);break}case "epoch-changed":{R.length>0&&R.some(D=>{for(let[M,te]of Object.entries(n))if(Ce(te).includes(D)){let U=r.tasks[M];if(U&&U.executionCount>p.lastEpoch)return true}return false})||(E=true);break}case "time-based":{let N=m.refreshInterval??0;if(N<=0){E=true;break}let D=p.completedAt;if(!D){E=true;break}(Date.now()-Date.parse(D))/1e3<N&&(E=true);break}case "manual":E=true;break}if(E)continue}let y=it(m);if(y.length===0){u.push(v);continue}let _=[],S=[],$=[];for(let R of y){if(i.has(R))continue;let E=o[R]||[];E.length===0?_.push(R):E.every(D=>To(r.tasks[D]))?$.push({token:R,failedProducer:E[0]}):S.push(R);}_.length>0?d.push({taskName:v,missingTokens:_}):$.length>0?l.push({taskName:v,failedTokens:$.map(R=>R.token),failedProducers:[...new Set($.map(R=>R.failedProducer))]}):S.length>0?c.push({taskName:v,waitingOn:S}):u.push(v);}let k={};if(u.length>1){let v=Zu(u,n);for(let[m,p]of Object.entries(v))p.length>1&&(k[m]=p);}return {eligible:u,pending:c,unresolved:d,blocked:l,conflicts:k}}function ah(e){let t={};for(let[r,n]of Object.entries(e)){for(let s of Ce(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 $r=class{buffer=[];append(t){this.buffer.push(t);}drain(){let t=this.buffer;return this.buffer=[],t}get size(){return this.buffer.length}};function Ao(e){let t=Io(e);return ih(t)}function Io(e){if(e==null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return "["+e.map(Io).join(",")+"]";let t=e;return "{"+Object.keys(t).sort().map(n=>JSON.stringify(n)+":"+Io(t[n])).join(",")+"}"}function ih(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 uh(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 ch(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 ic(e){let t=JSON.stringify({t:e,n:Date.now().toString(36)+Math.random().toString(36).slice(2,6)});return uh(t)}function dh(e){try{let t=JSON.parse(ch(e));return typeof t?.t=="string"?{taskName:t.t}:null}catch{return null}}function uc(e,t,r){let{handlers:n,onDrain:s}=t,o=new $r,a="state"in e&&"config"in e?e:bn(e),i=false,u=new Set,c=new Map(Object.entries(n)),d=new $r,l=false,k=false;function v(){if(!i){if(l){k=true;return}l=true;try{do k=!1,m();while(k)}finally{l=false;}}}function m(){let f=d.drain(),y=o.drain(),_=[...f,...y];_.length>0&&(a=oc(a,_));let S=Cr(a);_.length>0&&s?.(_,a,S);for(let $ of S.eligible)g($);for(let $ of _)if($.type==="task-progress"){let{taskName:R,update:E}=$;if(!a.config.tasks[R])continue;let D=a.state.tasks[R];if(!D||D.status!=="running")continue;let M=ic(R),te=b(R,M,E).catch(U=>{i||(d.append({type:"task-failed",taskName:R,error:U.message??String(U),timestamp:new Date().toISOString()}),v());}).finally(()=>{u.delete(te);});u.add(te);}}function p(f){let _=a.config.tasks[f].requires??[],S=new Map;for(let[R,E]of Object.entries(a.config.tasks))for(let N of E.provides??[])S.set(N,R);let $={};for(let R of _){let E=S.get(R);E?$[R]=a.state.tasks[E]?.data:$[R]=void 0;}return $}async function b(f,y,_){let S=a.config.tasks[f],$=S.taskHandlers??[],R=p(f);for(let E of $){let N=c.get(E);if(!N)throw new Error(`Handler '${E}' not found in registry (task '${f}')`);let D={nodeId:f,state:R,taskState:a.state.tasks[f],config:S,callbackToken:y,update:_};if(await N(D)==="task-initiate-failure")throw new Error(`Handler '${E}' returned task-initiate-failure (task '${f}')`)}}function g(f){let _=a.config.tasks[f]?.taskHandlers;if(!_||_.length===0)return;d.append({type:"task-started",taskName:f,timestamp:new Date().toISOString()}),v();let S=ic(f),$=b(f,S).catch(R=>{i||(d.append({type:"task-failed",taskName:f,error:R.message??String(R),timestamp:new Date().toISOString()}),v());}).finally(()=>{u.delete($);});u.add($);}return {push(f){i||(f.type==="task-completed"&&f.data&&!f.dataHash&&(f={...f,dataHash:Ao(f.data)}),o.append(f),v());},pushAll(f){if(!i){for(let y of f)y.type==="task-completed"&&y.data&&!y.dataHash?o.append({...y,dataHash:Ao(y.data)}):o.append(y);v();}},resolveCallback(f,y,_){if(i)return;let S=dh(f);if(!S)return;let{taskName:$}=S;if(a.config.tasks[$]){if(_&&_.length>0)o.append({type:"task-failed",taskName:$,error:_.join("; "),timestamp:new Date().toISOString()});else {let R=y&&Object.keys(y).length>0?Ao(y):void 0;o.append({type:"task-completed",taskName:$,data:y,dataHash:R,timestamp:new Date().toISOString()});}v();}},addNode(f,y){i||(o.append({type:"task-upsert",taskName:f,taskConfig:y,timestamp:new Date().toISOString()}),v());},removeNode(f){i||(o.append({type:"task-removal",taskName:f,timestamp:new Date().toISOString()}),v());},addRequires(f,y){i||(o.append({type:"node-requires-add",nodeName:f,tokens:y,timestamp:new Date().toISOString()}),v());},removeRequires(f,y){i||(o.append({type:"node-requires-remove",nodeName:f,tokens:y,timestamp:new Date().toISOString()}),v());},addProvides(f,y){i||(o.append({type:"node-provides-add",nodeName:f,tokens:y,timestamp:new Date().toISOString()}),v());},removeProvides(f,y){i||(o.append({type:"node-provides-remove",nodeName:f,tokens:y,timestamp:new Date().toISOString()}),v());},registerHandler(f,y){c.set(f,y);},unregisterHandler(f){c.delete(f);},retrigger(f){i||a.config.tasks[f]&&(o.append({type:"task-restart",taskName:f,timestamp:new Date().toISOString()}),v());},retriggerAll(f){if(!i){for(let y of f)a.config.tasks[y]&&o.append({type:"task-restart",taskName:y,timestamp:new Date().toISOString()});v();}},snapshot(){return Rr(a)},getState(){return a},getSchedule(){return Cr(a)},async waitForHandlers(){u.size>0&&await Promise.allSettled([...u]);},async dispose(f){f?.wait&&u.size>0&&await Promise.allSettled([...u]),i=true;}}}var fh=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))),wn=fh("./jsonata-sync.cjs"),lc=wn;function cc(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 fc(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 ph(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 wn(s.expr).evaluate(n);fc(e.computed_values,s.bindTo,o),n.computed_values=e.computed_values;}catch{}return e}function mh(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=lc(o.expr).evaluate(n);fc(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 gh(e,t,r){let n={...r??{},card_data:t.card_data??{},requires:t.requires??{},fetched_sources:t._sourcesData??{},computed_values:t.computed_values??{}};return wn(e).evaluate(n)}function hh(e,t){return t.startsWith("fetched_sources.")?cc(e._sourcesData??{},t.slice(16)):cc(e,t)}var dc=new Set(["metric","table","editable-table","chart","form","filter","list","notes","todo","alert","narrative","badge","text","markdown","ref","custom","actions"]),yh=new Set(["id","meta","requires","provides","view","card_data","compute","source_defs"]);function vh(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))yh.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`):dc.has(s.kind)||t.push(`view.elements[${o}].kind: unknown kind "${s.kind}". Valid: ${[...dc].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 kh(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 wn(a).evaluate(r);}catch{s[o]=void 0;}}return {...n,_projections:s}}))}function bh(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]=lc(a).evaluate(r);}catch{s[o]=void 0;}}return {...n,_projections:s}})}var ut={run:ph,runSync:mh,eval:gh,resolve:hh,validate:vh,enrichSources:kh,enrichSourcesSync:bh};function Sh(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:se({kind:"fs-path",value:e}),...t?{extra:t}:{}}}function Po(e){return JSON.stringify(e)}function Oo(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 _n(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],k=c[l],v=k&&typeof k=="object"&&!Array.isArray(k)?{...k}:{};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();o[s]&&(delete o[s],e.writeIndex(o));},readIndex(){return r()}}}function jo(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}`)}}}function yc(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 vc(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 Er="v1",ct="board/graph",kc="board/lastJournalProcessedId";function pc(e){return `cards/${e}/runtime`}function bc(e){return {readRuntime(t){return e.read(pc(t))??{_sources:{}}},writeRuntime(t,r){e.write(pc(t),r);}}}function wh(e,t){let r={...e};for(let n of t.deleteKeys)delete r[n];return {...r,...t.shallowMerge}}function Sc(e){return {readSnapshot(t){return e.readValues(t)},commitSnapshot(t,r){if(r.schemaVersion!==Er)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=wh(n.values,r);return {ok:true,newVersion:e.writeValues(t,s,r.deleteKeys)}}}}function No(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 Oo(r.trim())},writeTaskExecutorRef(r){e.write("task-executor",Po(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);}}}function wc(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 mc(e){return e?{lastRequestedToken:e.lastRequestedToken,lastCompletedToken:e.lastCompletedToken,lastCompletionStatus:e.lastCompletionStatus??(e.lastCompletedToken?"success":"not-started"),queueRequestedToken:e.queueRequestedToken}:{lastCompletionStatus:"not-started"}}function _h(e){return e?.lastRequestedToken?e.lastCompletedToken!==e.lastRequestedToken:false}function gc(e,t){return e?.lastRequestedToken?_h(e)?"in-flight":!e.lastCompletedToken||e.lastCompletedToken<t?"dispatch":"idle":"dispatch"}function Rh(e,t){return {...e,lastCompletedToken:t,lastCompletionStatus:"success"}}function hc(e,t){return {...e,lastCompletedToken:t,lastCompletionStatus:"failure"}}function Rn(e,t){let r=t.state.tasks,n=t.config.tasks,s=Object.keys(r),o=Cr(t),a={completed:0,failed:0,in_progress:0,pending:0,blocked:0,unresolved:0},i=new Map;for(let m of o.pending)i.set(m.taskName,m.waitingOn);for(let m of o.unresolved)i.set(m.taskName,m.missingTokens);for(let m of o.blocked)i.set(m.taskName,m.failedTokens);let u=new Map;for(let[m,p]of Object.entries(n))for(let b of p.requires??[]){let g=u.get(b)??[];g.push(m),u.set(b,g);}let c=s.sort().map(m=>{let p=r[m],b=n[m]??{requires:[],provides:[]};p.status==="completed"?a.completed+=1:p.status==="failed"?a.failed+=1:p.status==="in-progress"&&(a.in_progress+=1);let g=b.requires??[],f=b.provides??[],y=Object.keys(p.data??{}).sort(),_=g.filter(D=>t.state.availableOutputs.includes(D)),S=g.filter(D=>!t.state.availableOutputs.includes(D)),$=i.get(m)??S,R=new Set;for(let D of f)for(let M of u.get(D)??[])M!==m&&R.add(M);let E=p.failedAt,N=p.error?{message:p.error,code:"TASK_FAILED",at:E,source:"task-runtime"}:void 0;return {name:m,status:p.status,error:N,requires:g,requires_satisfied:_,requires_missing:S,provides_declared:f,provides_runtime:y,blocked_by:$,unblocks:Array.from(R).sort(),runtime:{attempt_count:p.executionCount??0,restart_count:p.retryCount??0,in_progress_since:p.status==="in-progress"?p.startedAt??null:null,last_transition_at:p.lastUpdated??null,last_completed_at:p.completedAt??null,last_restarted_at:p.startedAt??null,status_age_ms:p.lastUpdated?0:null}}});a.pending=o.pending.length,a.blocked=o.blocked.length,a.unresolved=o.unresolved.length;let d=c.map(m=>({name:m.name,fanOut:m.unblocks.length})).sort((m,p)=>p.fanOut-m.fanOut||m.name.localeCompare(p.name)),l=d.length>0?d[0]:{name:null,fanOut:0},k=new Set;for(let m of Object.values(n))for(let p of m.requires??[])k.add(p);let v=0;for(let[m,p]of Object.entries(n)){let b=(p.requires??[]).length===0,f=(p.provides??[]).some(y=>(u.get(y)??[]).some(_=>_!==m));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(k).length,max_fan_out_card:l.name,max_fan_out:l.fanOut}},cards:c}}function Ch(){return new Date().toISOString()}function _c(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??{},k=c.source_defs??[],v=k.filter(q=>q.optionalForCompletionGating!==true),m=r.cardRuntimeStore.readRuntime(d),p=false,b=()=>{p&&(r.cardRuntimeStore.writeRuntime(d,m),p=false);},g=q=>mc(m._sources[q]),f=(q,w)=>{m._sources[q]=mc(w),p=true;},y=i.taskState?.executionCount??0;if(m._lastExecutionCount!==y&&(m._sources={},m._lastExecutionCount=y,p=true),i.update){let q=i.update,w=q.outputFile;if(w){let h=g(w);if(q.failure){let C=q.rqt??h.lastRequestedToken??h.queueRequestedToken;C&&f(w,hc(h,C));}else {let C=q.rqt;if(!h.lastCompletedToken||C>h.lastCompletedToken){let I=typeof q.deliveryToken=="string"?q.deliveryToken:void 0,K=false;I&&(K=r.fetchedSourcesStore.commitSourceData(d,w,I)),K?f(w,Rh(h,C)):f(w,hc(h,C));}}b();}}let S={};for(let q of k)if(q.outputFile){let w=r.fetchedSourcesStore.readSourceData(d,q.outputFile);w!==null&&(S[q.bindTo]=w);}let $={};for(let[q,w]of Object.entries(i.state??{}))if(w!==null&&typeof w=="object"&&!Array.isArray(w)){let h=w[q];$[q]=h!==void 0?h:w;}else $[q]=w;let R={id:d,card_data:{...l},requires:$,source_defs:k,compute:c.compute};R._sourcesData=S,c.compute&&ut.runSync(R,{sourcesData:S}),(o??r.outputStore.writeComputedValues.bind(r.outputStore))(d,R.computed_values??{});let E={...c},N=ut.enrichSourcesSync(Array.isArray(c.source_defs)?c.source_defs:void 0,{card_data:c.card_data,requires:$}),D=e.value;E.source_defs=Array.isArray(N)?N.map(q=>({...q,boardDir:typeof q.boardDir=="string"&&q.boardDir?q.boardDir:D})):N;let M=Ch(),te=i.update?void 0:M,U=v.filter(q=>{let w=q.outputFile;if(typeof w!="string"||!w)return true;let h=g(w);te&&(h={...h,queueRequestedToken:te},f(w,h));let C=h.queueRequestedToken??h.lastRequestedToken??M,I=gc(h,C);return I==="in-flight"?false:I==="dispatch"});if(b(),U.length>0){let q=false,w=M;for(let h of U){let C=h.outputFile;if(typeof C!="string"||!C)continue;let I=g(C),K=I.queueRequestedToken??M;f(C,{...I,lastRequestedToken:K}),w=K,q=true;}return q&&b(),q&&(u.push({taskKind:"source-fetch",payload:{boardRef:se(e),enrichedCard:E,callbackToken:i.callbackToken,rqt:w}}),r.executionRequestStore.appendEntries(t,u)),"task-initiated"}if(v.some(q=>{let w=q.outputFile;if(typeof w!="string"||!w)return false;let h=g(w),C=h.queueRequestedToken??h.lastRequestedToken??M;return gc(h,C)==="in-flight"}))return "task-initiated";let Je=c.provides??[],qe={};for(let{bindTo:q,ref:w}of Je)qe[q]=ut.resolve(R,w);return (a??r.outputStore.writeDataObjects.bind(r.outputStore))(qe),k.filter(q=>{if(q.optionalForCompletionGating!==true)return false;let w=g(q.outputFile);return !w.lastRequestedToken||!w.lastCompletedToken?true:w.lastCompletedToken<=w.lastRequestedToken}).length>0&&u.push({taskKind:"source-fetch",payload:{boardRef:se(e),enrichedCard:E,callbackToken:i.callbackToken,rqt:M}}),n(i.nodeId,qe),u.length>0&&r.executionRequestStore.appendEntries(t,u),"task-initiated"}}var Cn={settings:{completion:"manual",refreshStrategy:"data-changed"},tasks:{}};function Rc(e){return {[ct]:e.graph,[kc]:e.lastDrainedJournalId}}function Cc(e){let t=e[ct],r=e[kc];if(!t||typeof t!="object")throw new Error(`State snapshot is missing required key: ${ct}`);return {graph:t,lastDrainedJournalId:typeof r=="string"?r:""}}function $c(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 X(e){return e!==void 0?{status:"success",data:e}:{status:"success"}}function j(e){return {status:"fail",error:e}}function Z(e){return {status:"error",error:e instanceof Error?e.message:String(e)}}function $h(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 xc(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 $n(e){try{let t=JSON.parse(xc(e));return typeof t?.t=="string"?{taskName:t.t}:null}catch{return null}}function Eh(e){return $h(JSON.stringify(e))}function Ec(e){try{let t=JSON.parse(xc(e));return typeof t?.cbk=="string"&&typeof t?.cid=="string"&&typeof t?.b=="string"&&typeof t?.d=="string"?t:null}catch{return null}}function $e(){return new Date().toISOString()}function xh(e,t){let r=t.onWarn??(()=>{}),n=se(e);function s(w){if(w.length!==0)try{let h=t.publishBoardChangeNotifications?.(w);h&&typeof h.catch=="function"&&h.catch(C=>r(`[board-live-cards-public] publishBoardChangeNotifications failed: ${C instanceof Error?C.message:String(C)}`));}catch(h){r(`[board-live-cards-public] publishBoardChangeNotifications failed: ${h instanceof Error?h.message:String(h)}`);}}function o(){let w=i().readCardStoreRef();if(!w)throw new Error(`Board at ${e.value} has no card store configured. Run: init --base-ref <ref> --store-ref <b64-ref>`);let h=t.kvStorageForRef(w);return {readIndex(){return h.read("_index")},writeIndex(C){h.write("_index",C);},readCard(C){return h.read(C)},writeCard(C,I){return h.write(C,I),t.hashFn(I)},cardExists(C){return h.read(C)!==null},defaultCardKey(C){return C}}}let a={readValues(w){let h=t.kvStorage("state-snapshot"),C=h.listKeys().sort();if(C.length===0)return {version:null,values:{}};let I={};for(let K of C)I[K]=h.read(K);return {version:t.hashFn(I),values:I}},writeValues(w,h,C){let I=t.kvStorage("state-snapshot");for(let K of C)I.delete(K);for(let[K,ee]of Object.entries(h))I.write(K,ee);return t.hashFn(h)}},i=()=>No(t.kvStorage("config")),u=()=>Sc(a),c=()=>yc(t.journalAdapter()),d=()=>_n(o(),r),l=()=>{let w=i().readOutputsStoreRef();if(!w)throw new Error(`Board at ${e.value} has no outputs store configured. Run: init --outputs-store-ref <b64-ref>`);return wc(t.kvStorageForRef(w))};function k(){return !!u().readSnapshot(e.value).values[ct]}function v(){let w=u().readSnapshot(e.value);if(!w.values[ct])throw new Error(`Board not initialized at ${e.value}`);return Cc(w.values)}function m(w,h){let C=u().commitSnapshot(e.value,{schemaVersion:Er,expectedVersion:h,commitId:t.genId(),committedAt:$e(),deleteKeys:[],shallowMerge:Rc(w)});if(!C.ok)throw new Error(`Snapshot commit failed (version mismatch): expected=${h??"null"} current=${C.currentVersion??"null"}`)}function p(w){c().appendEvent(w);}async function b(){let w=(P,F)=>{let oe=P.payload,He=(oe?.enrichedCard??{}).id??oe?.cardId??"unknown";p({type:"task-failed",taskName:He,error:F,timestamp:$e()});},h=vc(t.kvStorage("execution-requests"),w),C=bc(t.kvStorage("card-runtime")),I=jo(t.blobStorage("sources"),P=>t.resolveBlob(P)),K=new Map,ee={readRuntime(P){return K.get(P)??C.readRuntime(P)},writeRuntime(P,F){K.set(P,F);}},Se=[],we=new Map,ze={readSourceData(P,F){let oe=`${P}/${F}`;return we.has(oe)?we.get(oe):I.readSourceData(P,F)},ingestSourceDataStaged(P,F,oe,Et){I.ingestSourceDataStaged(P,F,oe,Et);},commitSourceData(P,F,oe){let Et=`${P}/.staged/${oe}/${F}`,Ar=t.blobStorage("sources").read(Et);if(Ar==null)return false;let xt=`${P}/${F}`,Mo=Ar.trim();try{we.set(xt,JSON.parse(Mo));}catch{we.set(xt,Mo);}return Se.push({cardId:P,outputFile:F,deliveryToken:oe}),true},hasSource(P,F){let oe=`${P}/${F}`;return we.has(oe)?true:I.hasSource(P,F)}},_e={cardStore:d(),cardRuntimeStore:ee,fetchedSourcesStore:ze,outputStore:l(),executionRequestStore:h},dt=v(),lt=Sn(dt.graph),{events:Ct,newCursor:$t}=c().readEntriesAfterCursor(dt.lastDrainedJournalId),ft=[],En=[],xn=[],qo=new Map,Pc=(P,F)=>{ft.push({type:"task-completed",taskName:P,data:F,timestamp:$e()});},Do=(P,F)=>p({type:"task-failed",taskName:P,error:F,timestamp:$e()}),xr=uc(lt,{handlers:{"card-handler":_c(e,$t,_e,Pc,Do,(P,F)=>{En.push({cardId:P,values:F});},P=>{xn.push(P);})}});for(ft=Ct;ft.length>0;){let P=ft;ft=[];for(let F of P)if(F.type==="task-restart"){let oe=_e.cardStore.readCard(F.taskName);oe&&qo.set(F.taskName,oe);}xr.pushAll(P),await xr.waitForHandlers();}let Fo=xr.getState();await xr.dispose({wait:true});let Oc=u().readSnapshot(e.value).version;m({lastDrainedJournalId:$t,graph:Rr(Fo)},Oc);for(let{cardId:P,values:F}of En)_e.outputStore.writeComputedValues(P,F);for(let P of xn)_e.outputStore.writeDataObjects(P);for(let[P,F]of K)C.writeRuntime(P,F);for(let{cardId:P,outputFile:F,deliveryToken:oe}of Se)I.commitSourceData(P,F,oe);let Tr;try{Tr=Rn(n,Fo),_e.outputStore.writeStatusSnapshot(Tr);}catch(P){r(`[board-live-cards-public] status publish failed: ${P instanceof Error?P.message:String(P)}`);}let Ut=[];for(let{cardId:P,values:F}of En)Ut.push({kind:"computed_values",cardId:P,values:F});for(let P of xn)for(let[F,oe]of Object.entries(P))F&&Ut.push({kind:"data_object",key:F,payload:oe});for(let[P,F]of qo)Ut.push({kind:"card_refreshed",cardId:P,card:F});Tr!==void 0&&Ut.push({kind:"status",status:Tr}),s(Ut);let jc=i().readTaskExecutorRef()??{howToRun:"built-in",whatToRun:se({kind:"built-in",value:"source-cli-task-executor"})};h.dispatchEntriesForJournalId($t,P=>{if(P.taskKind!=="source-fetch"){r(`[process-accumulated-events] unknown taskKind "${P.taskKind}" \u2014 skipping`);return}let F=P.payload,oe=F.enrichedCard?.id??"unknown",Et=F.enrichedCard?.source_defs??[];for(let He of Et){if(!He.outputFile){r(`[dispatch] source "${He.bindTo}" has no outputFile \u2014 skipping`);continue}let Ar=Eh({cbk:F.callbackToken,rg:e.value,br:se(e),cid:oe,b:He.bindTo,d:He.outputFile,cs:void 0,rqt:F.rqt});t.dispatchExecution(jc,{source_def:He,base_ref:se(e),callback:{token:Ar,via:t.selfRef}}).catch(xt=>Do(oe,xt instanceof Error?xt.message:String(xt)));}});}async function g(){try{let w=()=>{let C=v(),{events:I}=c().readEntriesAfterCursor(C.lastDrainedJournalId);I.length<=0||(g(),t.requestProcessAccumulated?.());},h=await Vo(t.lock,b,w);return X({ran:h!==!1})}catch(w){return Z(w)}}function f(w){try{let h=w.params?.cardStoreRef;if(!h)return j("init requires params.cardStoreRef \u2014 create a card store with card-store-cli and pass its ref here");if(!k()){let ee=bn(Cn);m({lastDrainedJournalId:"",graph:Rr(ee)},null);}let C=w.params?.outputsStoreRef;if(!C)return j("init requires params.outputsStoreRef \u2014 pass the outputs store ref here");let I=i();I.writeCardStoreRef(h),I.writeOutputsStoreRef(C);let K=w.body??{};K["task-executor-ref"]&&I.writeTaskExecutorRef(K["task-executor-ref"]),Object.prototype.hasOwnProperty.call(K,"chat-handler-flow")&&I.writeChatHandlerFlow(K["chat-handler-flow"]);try{l().writeStatusSnapshot(Rn(n,Sn(v().graph)));}catch{}return X()}catch(h){return Z(h)}}function y(w){try{let h=l().readStatusSnapshot();if(!h){h=Rn(n,Sn(v().graph));try{l().writeStatusSnapshot(h);}catch{}}return X(h)}catch(h){return Z(h)}}function _(w){try{let h=w.params?.id;return h?(p({type:"task-removal",taskName:h,timestamp:$e()}),g(),X()):j("removeCard requires params.id")}catch(h){return Z(h)}}function S(w){try{let h=w.params?.id;return h?(p({type:"task-restart",taskName:h,timestamp:$e()}),g(),X()):j("retrigger requires params.id")}catch(h){return Z(h)}}async function $(w){return g()}function R(w){try{let h=w.params?.cardId,C=w.params?.all,I=!!w.params?.restart;if(!h&&!C)return j("upsertCard requires --card-id <id> or --all");let K=C?d().readAllCards().map(ee=>ee.id):[h];for(let ee of K)if(!d().readCard(ee))return j(`Card "${ee}" not found in board at ${e.value}`);for(let ee of K){let Se=d().readCard(ee),we=$c(Se),ze=t.hashFn(we),_e=t.kvStorage("card-upsert"),dt=_e.read(ee),lt=dt?.taskConfigHash!==ze;if(!(!lt&&!I)){if(lt){let Ct=dt?.blobRef??d().readCardKey(ee)??ee;p({type:"task-upsert",taskName:ee,taskConfig:we,timestamp:$e()}),_e.write(ee,{blobRef:Ct,taskConfigHash:ze,updatedAt:$e()});}I&&p({type:"task-restart",taskName:ee,timestamp:$e()});}}return g(),X()}catch(h){return Z(h)}}function E(w){try{let h=w.params?.token;if(!h)return j("taskFailed requires params.token");let C=w.params?.error??"unknown error",I=$n(h);return I?(p({type:"task-failed",taskName:I.taskName,error:C,timestamp:$e()}),g(),X()):j("Invalid callback token")}catch(h){return Z(h)}}function N(w){try{let h=w.params?.token;if(!h)return j("taskProgress requires params.token");let I=(w.body??{}).update??{},K=$n(h);return K?(p({type:"task-progress",taskName:K.taskName,update:I,timestamp:$e()}),g(),X()):j("Invalid callback token")}catch(h){return Z(h)}}function D(w){try{let h=w.params?.token,C=w.params?.ref;if(!h)return j("sourceDataFetched requires params.token");if(!C)return j("sourceDataFetched requires params.ref");let I=Ec(h);if(!I)return j("Invalid source token");let{cbk:K,cid:ee,b:Se,d:we,cs:ze,rqt:_e}=I,dt=jo(t.blobStorage("sources"),ft=>t.resolveBlob(ft)),lt=t.genId();dt.ingestSourceDataStaged(ee,we,Re(C),lt);let Ct=$n(K);if(!Ct)return j("Invalid callback token embedded in source token");let $t=$e();return p({type:"task-progress",taskName:Ct.taskName,update:{bindTo:Se,outputFile:we,fetchedAt:$t,deliveryToken:lt,sourceChecksum:ze,rqt:_e},timestamp:$t}),g(),X()}catch(h){return Z(h)}}function M(w){try{let h=w.params?.token,C=w.params?.reason??"unknown";if(!h)return j("sourceDataFetchFailure requires params.token");let I=Ec(h);if(!I)return j("Invalid source token");let{cbk:K,b:ee,d:Se,cs:we,rqt:ze}=I,_e=$n(K);return _e?(p({type:"task-progress",taskName:_e.taskName,update:{bindTo:ee,outputFile:Se,failure:!0,reason:C,sourceChecksum:we,rqt:ze},timestamp:$e()}),g(),X()):j("Invalid callback token embedded in source token")}catch(h){return Z(h)}}function te(w){try{let h=i().readCardStoreRef();return h?X({storeRef:h}):j(`Board at ${e.value} has no card store configured`)}catch(h){return Z(h)}}function U(w){try{let h=i().readOutputsStoreRef();return h?X({storeRef:h}):j(`Board at ${e.value} has no outputs store configured`)}catch(h){return Z(h)}}function de(w){try{let h=w.params?.key;if(!h)return j("getConfig requires params.key");let C=i(),I;switch(h){case "task-executor":I=C.readTaskExecutorRef()??null;break;case "chat-handler-flow":I=C.readChatHandlerFlow()??null;break;case "card-store-ref":I=C.readCardStoreRef();break;case "outputs-store-ref":I=C.readOutputsStoreRef();break;default:return j(`getConfig: unknown key "${h}"`)}return X({value:I})}catch(h){return Z(h)}}function Je(w){try{let h=w.params?.key;if(!h)return j("getOutputsDataObject requires params.key");let C=l().readDataObject(h);return X(C)}catch(h){return Z(h)}}function qe(w){try{return X(l().readAllDataObjects())}catch(h){return Z(h)}}function Kt(w){try{let h=w.params?.key;if(!h)return j("getOutputsComputedValues requires params.key");let C=l().readComputedValues(h);return X(C)}catch(h){return Z(h)}}function q(w){try{return X(l().readAllComputedValues())}catch(h){return Z(h)}}return {init:f,status:y,getCardStoreRef:te,getOutputsStoreRef:U,getConfig:de,getOutputsDataObject:Je,getAllOutputsDataObjects:qe,getOutputsComputedValues:Kt,getAllOutputsComputedValues:q,removeCard:_,retrigger:S,processAccumulatedEvents:$,upsertCard:R,taskFailed:E,taskProgress:N,sourceDataFetched:D,sourceDataFetchFailure:M}}function Th(e,t){let r=()=>No(t.kvStorage("config"));function n(){let g=r().readCardStoreRef();if(!g)throw new Error(`Board at ${e.value} has no card store configured. Run: init --base-ref <ref> --store-ref <b64-ref>`);let f=t.kvStorageForRef(g);return {readIndex(){return f.read("_index")},writeIndex(y){f.write("_index",y);},readCard(y){return f.read(y)},writeCard(y,_){return f.write(y,_),t.hashFn(_)},cardExists(y){return f.read(y)!==null},defaultCardKey(y){return y}}}let s=()=>_n(n(),t.onWarn??(()=>{}));function o(g,f){let y=t.validateSchema(f),_=[],S=r().readTaskExecutorRef();if(S&&Array.isArray(f.source_defs))for(let R of f.source_defs){let E=typeof R.bindTo=="string"?R.bindTo:"(unknown)";try{let N;try{N=t.invokeExecutorSync(S,"validate-source-def",[],{timeout:t.executorTimeouts?.validationMs??1e4,input:JSON.stringify(R)});}catch(M){let te=M;if(N=typeof te?.stdout=="string"?te.stdout:"",!N.trim()){_.push(`source "${E}": executor validate-source-def failed \u2014 ${M instanceof Error?M.message:String(M)}`);continue}}let D=JSON.parse(N.trim());if(!D.ok&&Array.isArray(D.errors))for(let M of D.errors)_.push(`source "${E}": ${M}`);}catch(N){_.push(`source "${E}": executor validate-source-def failed \u2014 ${N instanceof Error?N.message:String(N)}`);}}let $=[...y.errors,..._];return X({cardId:g,isValid:$.length===0,issues:$})}function a(g,f,y){let _=r().readTaskExecutorRef();if(!_)return j("No task-executor registered for this board");let S=typeof g.bindTo=="string"?g.bindTo:"source",$=t.makeTempFilePath(`probe-in-${S}`),R=t.makeTempFilePath(`probe-out-${S}`),E=t.makeTempFilePath(`probe-err-${S}`,".txt"),N={...g,boardDir:e.value,_projections:f},D=se({kind:"fs-path",value:$}),M=se({kind:"fs-path",value:R}),te=se({kind:"fs-path",value:E});t.absoluteBlob.write($,JSON.stringify(N,null,2));let U=null;try{if(t.invokeExecutorSync(_,"run-source-fetch",["--in-ref",D,"--out-ref",M,"--err-ref",te],{timeout:g.timeout??t.executorTimeouts?.probeMs??6e4}),U=t.absoluteBlob.read(R),U===null)return j("Executor produced no output file")}catch(de){let Je=t.absoluteBlob.read(E)?.trim()??(de instanceof Error?de.message:String(de));return j(`Probe failed: ${Je}`)}finally{try{t.absoluteBlob.remove($);}catch{}try{t.absoluteBlob.remove(E);}catch{}}if(y){let de=Re(y);t.absoluteBlob.write(de.value,U);}else try{t.absoluteBlob.remove(R);}catch{}return X({bindTo:S,resultSizeBytes:U.length})}function i(g){try{let f=g.params?.cardId,y=g.params?.all;if(!f&&!y)return j("validateCard requires --card-id <id> or --all");let _=y?s().readAllCards().map($=>$.id):[f],S=[];for(let $ of _){let R=s().readCard($);if(!R){S.push({cardId:$,isValid:!1,issues:[`Card "${$}" not found`]});continue}let E=o($,R);if(E.status!=="success")return E;S.push(E.data);}return X(S)}catch(f){return Z(f)}}function u(g){try{if(!g.body||typeof g.body!="object"||Array.isArray(g.body))return j("validateCardPreflight requires card JSON object in body");let f=g.body,y=f["card-content"]??f,_=typeof y.id=="string"?y.id:"(unknown)",S=o(_,y),$=r().readTaskExecutorRef();if($)try{let R=t.invokeExecutorSync($,"validate-card-preflight",[],{timeout:t.executorTimeouts?.validationMs??1e4,input:JSON.stringify(y)}),E=JSON.parse(R.trim());if(!E.ok&&Array.isArray(E.errors)&&E.errors.length>0){let N=[...S.status==="success"?S.data.issues:[],...E.errors];return X({cardId:_,isValid:!1,issues:N})}}catch{}return S}catch(f){return Z(f)}}function c(g){try{let f=g.params?.cardId,y=g.params?.sourceIdx,_=g.params?.outRef;if(!f)return j("probeSource requires params.cardId");if(y===void 0)return j("probeSource requires params.sourceIdx");let $=(g.body??{})["mock-projections"]??{},R=s().readCard(f);if(!R)return j(`Card "${f}" not found`);let E=R.source_defs??[];return y<0||y>=E.length?j(`sourceIdx ${y} out of range (card has ${E.length} source(s))`):a(E[y],$,_)}catch(f){return Z(f)}}function d(g){try{let f=g.params?.outRef,y=g.body;if(!y)return j('probeTmpSource requires body with "source-def" and "mock-projections"');let _=y["source-def"],S=y["mock-projections"]??{};return _?a(_,S,f):j('probeTmpSource body requires "source-def"')}catch(f){return Z(f)}}function l(g){try{let f=g.params?.sourceIdx,y=g.params?.outRef;if(f===void 0)return j("probeSourcePreflight requires params.sourceIdx");if(!g.body||typeof g.body!="object"||Array.isArray(g.body))return j("probeSourcePreflight requires card JSON object in body");let _=g.body,S=_["card-content"]??_,$=_["mock-projections"]??{},R=S.source_defs??[];if(f<0||f>=R.length)return j(`sourceIdx ${f} out of range (card has ${R.length} source(s))`);let E=R[f],N=r().readTaskExecutorRef();if(N){let D=typeof E.bindTo=="string"?E.bindTo:"source";try{let M={...E,_projections:$},te=t.invokeExecutorSync(N,"probe-source-preflight",[],{timeout:E.timeout??t.executorTimeouts?.preflightMs??6e4,input:JSON.stringify(M)}),U=JSON.parse(te.trim());return U.ok?X({bindTo:D,reachable:U.reachable,latencyMs:U.latencyMs,note:U.note}):j(U.error??"Preflight probe failed")}catch{}}return a(E,$,y)}catch(f){return Z(f)}}function k(g){try{let f=r().readTaskExecutorRef();if(!f)return j("No task-executor registered for this board");let y=t.invokeExecutorSync(f,"describe-capabilities",[],{timeout:t.executorTimeouts?.describeMs??1e4});return X(JSON.parse(y.trim()))}catch(f){return Z(f)}}function v(g){try{let f=g.body;if(!f||!Array.isArray(f.ops))return j("updatesInCardStore requires body.ops array");let y=f.ops,_=s();for(let S of y){let $=S.op,R=S.id;if(!R)return j('op is missing "id"');if($==="update"){let E=S["card-content"];if(!E)return j(`update op for "${R}" is missing "card-content"`);_.writeCard(R,E);}else return j(`Unknown op type: "${$??"(none)"}"`)}return X()}catch(f){return Z(f)}}function m(g){try{let f=g.body;if(!f||!Array.isArray(f.ids))return j("readFromCardStore requires body.ids array");let y=f.ids,_=s(),S=y.map($=>({id:$,"card-content":_.readCard($)}));return X({cards:S})}catch(f){return Z(f)}}function p(g){try{if(!g.body||typeof g.body!="object"||Array.isArray(g.body))return j("evalCardCompute requires a JSON object in body");let f=g.body,y=f["card-content"]??f,_=typeof y.id=="string"?y.id:"(unknown)",S=f["mock-fetched-sources"]??{},$=f["mock-requires"]??{},R=y.compute;if(!R||!Array.isArray(R)||R.length===0)return X({cardId:_,ok:!0,computed_values:{},errors:[]});let E={id:_,card_data:y.card_data??{},requires:$,source_defs:y.source_defs,compute:R},N=ut.runSync(E,{sourcesData:S}),D=N.node.computed_values??{},M=N.errors??[];return X({cardId:_,ok:M.length===0,computed_values:D,errors:M})}catch(f){return Z(f)}}function b(g){try{if(!g.body||typeof g.body!="object"||Array.isArray(g.body))return j("simulateCardCycle requires a JSON object in body");let f=g.body,y=f["card-content"]??f,_=typeof y.id=="string"?y.id:"(unknown)",S=f["mock-fetched-sources"]??{},$=f["mock-requires"]??{},R=o(_,y),E=R.status==="success"?{isValid:R.data.isValid,issues:R.data.issues}:{isValid:!1,issues:[R.status==="fail"?R.error:"internal error"]},N=y.source_defs??[],D=y.card_data??{},M=[],te=[];if(N.length>0){M=ut.enrichSourcesSync(N,{card_data:D,requires:$});for(let h of M){let C=h.projections,I=h._projections;if(C&&I){for(let K of Object.keys(C))if(I[K]===void 0){let ee=typeof h.bindTo=="string"?h.bindTo:"(unknown)";te.push({bindTo:ee,key:K,error:`Projection "${K}" resolved to undefined`});}}}}let U=[],de=f["task-executor-ref"],Je=(de?.howToRun&&de?.whatToRun?de:void 0)??r().readTaskExecutorRef();for(let h=0;h<M.length;h++){let C=M[h],I=typeof C.bindTo=="string"?C.bindTo:`source_${h}`;if(!Je){U.push({bindTo:I,skipped:!0,error:"No task executor configured"});continue}try{let K={...C},ee=t.invokeExecutorSync(Je,"probe-source-preflight",[],{timeout:C.timeout??t.executorTimeouts?.preflightMs??6e4,input:JSON.stringify(K)}),Se=JSON.parse(ee.trim());U.push({bindTo:I,reachable:Se.reachable,latencyMs:Se.latencyMs,error:Se.ok?void 0:Se.error});}catch{U.push({bindTo:I,skipped:!0,error:"Executor does not support probe-source-preflight"});}}let qe=y.compute,Kt={},q=[];if(qe&&Array.isArray(qe)&&qe.length>0){let h={id:_,card_data:D,requires:$,source_defs:y.source_defs,compute:qe},C=ut.runSync(h,{sourcesData:S});Kt=C.node.computed_values??{},q=C.errors??[];}let w=E.isValid&&te.length===0&&q.length===0&&U.every(h=>h.reachable!==!1);return X({cardId:_,ok:w,validation:E,source_probes:U,projection_errors:te,computed_values:Kt,compute_errors:q})}catch(f){return Z(f)}}return {validateCard:i,validateCardPreflight:u,probeSource:c,probeTmpSource:d,probeSourcePreflight:l,evalCardCompute:p,simulateCardCycle:b,describeTaskExecutorCapabilities:k,updatesInCardStore:v,readFromCardStore:m}}function Ah(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 {get(s){try{let o=s.params?.id;if(o){let a=e.readCard(o);return a?t({cards:[a]}):r(`card "${o}" not found`)}return t({cards:e.readAllCards()})}catch(o){return n(o)}},set(s){try{let o=s.body;if(o==null)return r("set requires a body (card object or array of cards)");let a=Array.isArray(o)?o:[o];for(let i of a){if(typeof i.id!="string")return r("each card must have a string `id` field");e.writeCard(i.id,i);}return t({count:a.length})}catch(o){return n(o)}},del(s){try{let o=s.body?.ids??[],a=s.params?.id,i=a?[...o,a]:o;if(i.length===0)return r("del requires body.ids (string[]) or params.id");for(let u of i)e.removeCard(u);return t({count:i.length})}catch(o){return n(o)}},patch(s){try{let o=s.params?.id,a=s.params?.path;if(!o)return r("patch requires params.id");if(!a)return r("patch requires params.path");let i=s.body,u=i&&Object.prototype.hasOwnProperty.call(i,"value")?i.value:s.body;return e.patchCard(o,a,u),t({count:1})}catch(o){return n(o)}}}}function Ih(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 Tc(){return new Date().toISOString()}function Ac(e){return new TextEncoder().encode(e).byteLength}function Ph(e){return e?{key:e.key,size:e.size,updatedAt:e.updatedAt,contentType:e.contentType}:null}function Oh(e){let t=String(e||"").match(/^(\d+)[-_]/);return t?parseInt(t[1],10):0}function jh(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 Nh(e){return String(e||"").toLowerCase().replace(/\s+/g,"_").replace(/[^a-z0-9_-]/g,"_").replace(/_+/g,"_").replace(/^_+|_+$/g,"")||"file"}function qh(e){if(!e||e===".")return "";let t=String(e).replace(/^\./,"").toLowerCase().replace(/[^a-z0-9]/g,"");return t?`.${t}`:""}function Dh(e){let t=jh(e),r=t.lastIndexOf(".");return r<=0||r===t.length-1?{stem:t,ext:""}:{stem:t.slice(0,r),ext:t.slice(r)}}function Fh(e){let t=e.lastIndexOf("/");return t>=0?e.slice(t+1):e}function Mh(e){function t(r){let n=e.stat?Ph(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:Ac(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??Tc(),o.size=o.size??Ac(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??Tc(),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 Lh(e){function t(s,o){let a=0,i=[];Array.isArray(o)&&i.push(...o);for(let u of e.list(`${s}/`))i.push(Fh(u.key));for(let u of i){let c=Oh(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}=Dh(s),d=qh(c),l=Nh(u),k=`${String(o).padStart(3,"0")}-`,v=d,m=i-k.length-v.length;m<1&&(v="",m=i-k.length);let p=l.slice(0,Math.max(1,m)),b=`${k}${p}${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 Vh(){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,path:typeof u.path=="string"?u.path:null,uploaded_at:typeof u.uploaded_at=="string"?u.uploaded_at:o||null});}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 Nk(){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,a=typeof o=="string"?Re(o):o;a.kind==="fs-path"&&(r=a.value);}catch{r="";}if(!r)return {dispatched:false,error:"createNodeSpawnInvocationAdapter: could not resolve fs-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,n=typeof r=="string"?Re(r):r;n.kind==="fs-path"&&(t=n.value);}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 Kh=".board.lock";function Uh(e,t){return typeof e=="string"?{cliDir:e,opts:t}:{cliDir:void 0,opts:e}}function Jh(e,t){return typeof e=="string"?{cliDir:e,opts:t}:{cliDir:void 0,opts:e}}function Ic(e){if(e)return e;let t=zo((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,We(t,"..","cli","node"),We(t,"..","..","cli","node")];for(let n of r)try{return On(n),n}catch{}throw new Error(`createFsBoardPlatformAdapter: could not resolve a public CLI directory from module dir ${t}`)}function zh(e,t,r){let{cliDir:n,opts:s}=Uh(t,r),o=Ic(n),a=e.value,i=s?.suppressSpawn?"":On(o),u={meta:"board-live-cards",howToRun:"local-node",whatToRun:i?se({kind:"fs-path",value:i}):"",...s?.notifyChannel?{extra:{notifyChannel:s.notifyChannel}}:{}};return {kvStorage:c=>qr(We(a,`.${c}`)),blobStorage:c=>c?Nr(We(a,c)):Nr(a),journalAdapter:()=>la(a),lock:fa(We(a,Kh)),selfRef:u,async dispatchExecution(c,d){if(s?.suppressSpawn)return {dispatched:false};try{let l=d.source_def?.bindTo??An().slice(0,8),k=Jt(a,`exec-in-${l}`),v=Jt(a,`exec-out-${l}`),m=Jt(a,`exec-err-${l}`,".txt"),p=se({kind:"fs-path",value:k}),b=se({kind:"fs-path",value:v}),g=se({kind:"fs-path",value:m});return ua({kind:"fs-path",value:k}).write(k,JSON.stringify(d,null,2)),ia(c,{subcommand:"run-source-fetch",inRef:p,outRef:b,errRef:g},o),{dispatched:!0}}catch(l){return {dispatched:false,error:l instanceof Error?l.message:String(l)}}},resolveBlob(c){let d=Uo(c.value)?Ln().read(c.value):Nr(a).read(c.value);if(d===null)throw new Error(`resolveBlob: blob not found: ::${c.kind}::${c.value}`);return d},hashFn:da,genId:()=>Jo(`${Date.now()}-${Math.random()}`).slice(0,32),kvStorageForRef:c=>qr(Re(c).value),requestProcessAccumulated(){s?.suppressSpawn||Yo(o,e,s?.notifyChannel);},publishBoardChangeNotifications(c){if(!s?.notifyChannel||c.length===0)return;let d=c.map(l=>({id:An(),ts:new Date().toISOString(),boardRef:se(e),notification:l}));Xo(s.notifyChannel,d,s.onWarn);},onWarn:s?.onWarn}}function qk(e,t,r){let{cliDir:n,opts:s}=Jh(t,r),o=Ic(n),a=zh(e,o,s),i=jr();return {...a,invokeExecutorSync(u,c,d,l){let{command:k,baseArgs:v}=Nn(u,o),m=u.extra?["--extra",Buffer.from(JSON.stringify(u.extra)).toString("base64")]:[];return i.executeSync(k,[...v,c,...d,...m],{timeout:l?.timeout??3e4,encoding:"utf-8",input:l?.input})},validateSchema(u){let c=Eo(u);return {ok:c.errors.length===0,errors:c.errors}},makeTempFilePath(u,c){return Jt(e.value,u,c)},absoluteBlob:Ln()}}function Dk(e){let t=qr(We(e,".kv","chat"));return xo(r=>{let n=String(r).replace(/[^a-zA-Z0-9_-]/g,"_");return ca(We(e,"chats",`${n}.jsonl`))},t)}function Fk(e){try{let t=JSON.parse(Buffer.from(e,"base64url").toString());return typeof t.br=="string"?t.br:null}catch{return null}}
15
+ exports.BOARD_GRAPH_KEY=ct;exports.EMPTY_CONFIG=Cn;exports.SNAPSHOT_SCHEMA_VERSION_V1=Er;exports.createArtifactsStore=Mh;exports.createArtifactsStorePublic=Ih;exports.createBoardLiveCardsNonCorePublic=Th;exports.createBoardLiveCardsPublic=xh;exports.createCardFileMetadataStore=Vh;exports.createCardStore=_n;exports.createCardStorePublic=Ah;exports.createChatStorage=xo;exports.createExecutionRefInvoker=cd;exports.createFileArtifactsStore=Lh;exports.createFsBoardChatStorage=Dk;exports.createFsBoardNonCorePlatformAdapter=qk;exports.createFsBoardPlatformAdapter=zh;exports.createInMemoryChatStorage=Xg;exports.createNodeSpawnInvocationAdapter=Nk;exports.decodeBoardRefFromToken=Fk;exports.evaluateArgsMassaging=qn;exports.executionRefFromScriptPath=Sh;exports.invokeExecutionRef=aa;exports.invokeExecutionRefSync=Dn;exports.invokeRefSync=dd;exports.parseExecutionRef=Oo;exports.parseRef=Re;exports.serializeExecutionRef=Po;exports.serializeRef=se;//# sourceMappingURL=board-live-cards-node.cjs.map
16
16
  //# sourceMappingURL=board-live-cards-node.cjs.map