yaml-flow 8.0.1 → 8.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser/asset-integrity.json +2 -2
- package/browser/board-livecards-localstorage.js +3 -3
- package/cli/browser-api/board-live-cards-browser-adapter.d.ts +1 -1
- package/cli/node/board-live-cards-cli.js +6 -6
- package/cli/node/fs-board-adapter.d.ts +2 -2
- package/cli/node/fs-board-adapter.js +6 -6
- package/cli/{types-C2YQXFwo.d.ts → types-D2XnLbBj.d.ts} +15 -0
- package/examples/ARCHITECTURE.md +188 -0
- package/examples/board/demo-shell-with-server.html +2 -2
- package/examples/board/demo-task-executor.js +29 -32
- package/examples/board-local/demo-shell-localstorage.html +3 -3
- package/examples/step-machine-cli/json/double-handler.js +20 -0
- package/examples/step-machine-cli/json/mixed-handlers.flow.json +118 -0
- package/examples/step-machine-cli/json/mixed-handlers.input.json +5 -0
- package/examples/step-machine-cli/json/scale-handler.js +13 -0
- package/examples/step-machine-cli/yaml/double-handler.js +20 -0
- package/examples/step-machine-cli/yaml/mixed-handlers.flow.yaml +94 -0
- package/examples/step-machine-cli/yaml/mixed-handlers.input.json +5 -0
- package/examples/step-machine-cli/yaml/scale-handler.js +13 -0
- package/lib/{artifacts-store-lib-public-BABrgFkV.d.ts → artifacts-store-lib-public-BWC3YuLa.d.ts} +1 -1
- package/lib/{artifacts-store-lib-public-DGa8BpJT.d.cts → artifacts-store-lib-public-DBICnGL6.d.cts} +1 -1
- package/lib/artifacts-store-public.d.cts +2 -2
- package/lib/artifacts-store-public.d.ts +2 -2
- package/lib/board-live-cards-node.cjs +6 -6
- package/lib/board-live-cards-node.d.cts +5 -5
- package/lib/board-live-cards-node.d.ts +5 -5
- package/lib/board-live-cards-node.js +6 -6
- package/lib/{board-live-cards-public-BnmRAbQV.d.cts → board-live-cards-public-BF9FP0mL.d.cts} +15 -0
- package/lib/{board-live-cards-public-CsmYrvpd.d.ts → board-live-cards-public-dJAl5IL-.d.ts} +15 -0
- package/lib/board-live-cards-public.cjs +1 -1
- package/lib/board-live-cards-public.d.cts +1 -1
- package/lib/board-live-cards-public.d.ts +1 -1
- package/lib/board-live-cards-public.js +1 -1
- package/lib/board-live-cards-server-runtime.cjs +4 -4
- package/lib/board-live-cards-server-runtime.d.cts +2 -2
- package/lib/board-live-cards-server-runtime.d.ts +2 -2
- package/lib/board-live-cards-server-runtime.js +4 -4
- package/lib/card-store-public.d.cts +1 -1
- package/lib/card-store-public.d.ts +1 -1
- package/lib/server-runtime/index.cjs +4 -4
- package/lib/server-runtime/index.d.cts +3 -3
- package/lib/server-runtime/index.d.ts +3 -3
- package/lib/server-runtime/index.js +4 -4
- package/lib/{types-DkFvgxwq.d.cts → types-CXBzvC0s.d.cts} +1 -1
- package/lib/{types-CBxkYuLY.d.ts → types-D48hpnTR.d.ts} +1 -1
- package/package.json +4 -4
- package/examples/board/.demo-setup/run-1778665078572-3466-a8ay4k/board-default/gandalf-runtime/.config/card-store-ref.json +0 -1
- package/examples/board/.demo-setup/run-1778665078572-3466-a8ay4k/board-default/gandalf-runtime/.config/chat-handler.json +0 -1
- package/examples/board/.demo-setup/run-1778665078572-3466-a8ay4k/board-default/gandalf-runtime/.config/outputs-store-ref.json +0 -1
- package/examples/board/.demo-setup/run-1778665078572-3466-a8ay4k/board-default/gandalf-runtime/.config/task-executor.json +0 -1
- package/examples/board/.demo-setup/run-1778665078572-3466-a8ay4k/board-default/gandalf-runtime/.state-snapshot/board/graph.json +0 -29
- package/examples/board/.demo-setup/run-1778665078572-3466-a8ay4k/board-default/gandalf-runtime/.state-snapshot/board/lastJournalProcessedId.json +0 -1
- package/examples/board/.demo-setup/run-1778665078572-3466-a8ay4k/board-default/gandalf-runtime-out/.outputs/status.json +0 -25
- package/examples/board/.demo-setup/run-1778665078572-3466-a8ay4k/board-default/runtime-out/.outputs/cards/card-market-prices/computed_values.json +0 -67
- package/examples/board/.demo-setup/run-1778665078572-3466-a8ay4k/board-default/runtime-out/.outputs/cards/card-portfolio/computed_values.json +0 -1
- package/examples/board/.demo-setup/run-1778665078572-3466-a8ay4k/board-default/runtime-out/.outputs/cards/card-portfolio-value/computed_values.json +0 -52
- package/examples/board/.demo-setup/run-1778665078572-3466-a8ay4k/board-default/runtime-out/.outputs/data-objects/holdings.json +0 -22
- package/examples/board/.demo-setup/run-1778665078572-3466-a8ay4k/board-default/runtime-out/.outputs/data-objects/positions.json +0 -46
- package/examples/board/.demo-setup/run-1778665078572-3466-a8ay4k/board-default/runtime-out/.outputs/data-objects/quotes.json +0 -35
- package/examples/board/.demo-setup/run-1778665078572-3466-a8ay4k/board-default/runtime-out/.outputs/status.json +0 -113
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
'use strict';var child_process=require('child_process'),P=require('fs'),Pn=require('os'),ue=require('path'),Ho=require('net'),url=require('url'),crypto=require('crypto'),module$1=require('module'),properLockfile=require('proper-lockfile'),Bh=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 P__namespace=/*#__PURE__*/_interopNamespace(P);var Pn__namespace=/*#__PURE__*/_interopNamespace(Pn);var ue__namespace=/*#__PURE__*/_interopNamespace(ue);var Ho__namespace=/*#__PURE__*/_interopNamespace(Ho);var Bh__default=/*#__PURE__*/_interopDefault(Bh);var jc=Object.create;var Go=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&&Go(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(Go(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 ht=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=ht;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 ht&&(r[n.str]=(r[n.str]||0)+1),r),{})}};W._Code=xe;W.nil=new xe("");function ga(e,...t){let r=[e[0]],n=0;for(;n<t.length;)Jn(r,t[n]),r.push(e[++n]);return new xe(r)}W._=ga;var Un=new xe("+");function ya(e,...t){let r=[Xt(e[0])],n=0;for(;n<t.length;)r.push(Un),Jn(r,t[n]),r.push(Un,Xt(e[++n]));return hd(r),new xe(r)}W.str=ya;function Jn(e,t){t instanceof xe?e.push(...t._items):t instanceof ht?e.push(t):e.push(vd(t));}W.addCodeArg=Jn;function hd(e){let t=1;for(;t<e.length-1;){if(e[t]===Un){let r=gd(e[t-1],e[t+1]);if(r!==void 0){e.splice(t-1,3,r);continue}e[t++]="+";}t++;}}function gd(e,t){if(t==='""')return e;if(e==='""')return t;if(typeof e=="string")return t instanceof ht||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 ht))return `"${e}${t.slice(1)}`}function yd(e,t){return t.emptyStr()?e:e.emptyStr()?t:ya`${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 kd(e){return new xe(Xt(e))}W.stringify=kd;function Xt(e){return JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}W.safeStringify=Xt;function bd(e){return typeof e=="string"&&W.IDENTIFIER.test(e)?new xe(`.${e}`):ga`[${e}]`}W.getProperty=bd;function Sd(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=Sd;function wd(e){return new xe(e.toString())}W.regexpCode=wd;});var Wn=x(ke=>{Object.defineProperty(ke,"__esModule",{value:true});ke.ValueScope=ke.ValueScopeName=ke.Scope=ke.varKinds=ke.UsedValueState=void 0;var ve=Qt(),Hn=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||(ke.UsedValueState=Dr={}));ke.varKinds={const:new ve.Name("const"),let:new ve.Name("let"),var:new ve.Name("var")};var Fr=class{constructor({prefixes:t,parent:r}={}){this._names={},this._prefixes=t,this._parent=r;}toName(t){return t instanceof ve.Name?t:this.name(t)}name(t){return new ve.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}}};ke.Scope=Fr;var Mr=class extends ve.Name{constructor(t,r){super(r),this.prefix=t;}setValue(t,{property:r,itemIndex:n}){this.value=t,this.scopePath=(0, ve._)`.${new ve.Name(r)}[${n}]`;}};ke.ValueScopeName=Mr;var _d=(0, ve._)`\n`,zn=class extends Fr{constructor(t){super(t),this._values={},this._scope=t.scope,this.opts={...t,_n:t.lines?_d:ve.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 l=i.get(a);if(l)return l}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, ve._)`${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=ve.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 l=r(c);if(l){let d=this.opts.es5?ke.varKinds.var:ke.varKinds.const;o=(0, ve._)`${o}${d} ${c} = ${l};${this.opts._n}`;}else if(l=s?.(c))o=(0, ve._)`${o}${l}${this.opts._n}`;else throw new Hn(c);u.set(c,Dr.Completed);});}return o}};ke.ValueScope=zn;});var G=x(B=>{Object.defineProperty(B,"__esModule",{value:true});B.or=B.and=B.not=B.CodeGen=B.operators=B.varKinds=B.ValueScopeName=B.ValueScope=B.Scope=B.Name=B.regexpCode=B.stringify=B.getProperty=B.nil=B.strConcat=B.str=B._=void 0;var J=Qt(),Pe=Wn(),Qe=Qt();Object.defineProperty(B,"_",{enumerable:true,get:function(){return Qe._}});Object.defineProperty(B,"str",{enumerable:true,get:function(){return Qe.str}});Object.defineProperty(B,"strConcat",{enumerable:true,get:function(){return Qe.strConcat}});Object.defineProperty(B,"nil",{enumerable:true,get:function(){return Qe.nil}});Object.defineProperty(B,"getProperty",{enumerable:true,get:function(){return Qe.getProperty}});Object.defineProperty(B,"stringify",{enumerable:true,get:function(){return Qe.stringify}});Object.defineProperty(B,"regexpCode",{enumerable:true,get:function(){return Qe.regexpCode}});Object.defineProperty(B,"Name",{enumerable:true,get:function(){return Qe.Name}});var Gr=Wn();Object.defineProperty(B,"Scope",{enumerable:true,get:function(){return Gr.Scope}});Object.defineProperty(B,"ValueScope",{enumerable:true,get:function(){return Gr.ValueScope}});Object.defineProperty(B,"ValueScopeName",{enumerable:true,get:function(){return Gr.ValueScopeName}});Object.defineProperty(B,"varKinds",{enumerable:true,get:function(){return Gr.varKinds}});B.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 Ge=class{optimizeNodes(){return this}optimizeNames(t,r){return this}},Yn=class extends Ge{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=It(this.rhs,t,r)),this}get names(){return this.rhs instanceof J._CodeOrName?this.rhs.names:{}}},Lr=class extends Ge{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=It(this.rhs,t,r),this}get names(){let t=this.lhs instanceof J.Name?{}:{...this.lhs.names};return Br(t,this.rhs)}},Xn=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}},Qn=class extends Ge{constructor(t){super(),this.label=t,this.names={};}render({_n:t}){return `${this.label}:`+t}},Zn=class extends Ge{constructor(t){super(),this.label=t,this.names={};}render({_n:t}){return `break${this.label?` ${this.label}`:""};`+t}},es=class extends Ge{constructor(t){super(),this.error=t;}render({_n:t}){return `throw ${this.error};`+t}get names(){return this.error.names}},ts=class extends Ge{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=It(this.code,t,r),this}get names(){return this.code instanceof J._CodeOrName?this.code.names:{}}},Zt=class extends Ge{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),{})}},Ke=class extends Zt{render(t){return "{"+t._n+super.render(t)+"}"+t._n}},rs=class extends Zt{},At=class extends Ke{};At.kind="else";var gt=class e extends Ke{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 At(n):n;}if(r)return t===false?r instanceof e?r:r.nodes:this.nodes.length?this:new e(va(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=It(this.condition,t,r),this}get names(){let t=super.names;return Br(t,this.condition),this.else&&vt(t,this.else.names),t}};gt.kind="if";var yt=class extends Ke{};yt.kind="for";var ns=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=It(this.iteration,t,r),this}get names(){return vt(super.names,this.iteration.names)}},ss=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=It(this.iterable,t,r),this}get names(){return vt(super.names,this.iterable.names)}},er=class extends Ke{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 os=class extends Ke{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 Ke{constructor(t){super(),this.error=t;}render(t){return `catch(${this.error})`+super.render(t)}};rr.kind="catch";var nr=class extends Ke{render(t){return "finally"+super.render(t)}};nr.kind="finally";var as=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 rs];}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 Yn(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 Xn(t,B.operators.ADD,r))}code(t){return typeof t=="function"?t():t!==J.nil&&this._leafNode(new ts(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 gt(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 gt(t))}else(){return this._elseNode(new At)}endIf(){return this._endBlockNode(gt,At)}_for(t,r){return this._blockNode(t),r&&this.code(r).endFor(),this}for(t,r){return this._for(new ns(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 ss(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 Qn(t))}break(t){return this._leafNode(new Zn(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 os;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 es(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 gt))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;}};B.CodeGen=as;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 It(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 va(e){return typeof e=="boolean"||typeof e=="number"||e===null?!e:(0, J._)`!${is(e)}`}B.not=va;var $d=ka(B.operators.AND);function Cd(...e){return e.reduce($d)}B.and=Cd;var Ed=ka(B.operators.OR);function xd(...e){return e.reduce(Ed)}B.or=xd;function ka(e){return (t,r)=>t===J.nil?r:r===J.nil?t:(0, J._)`${is(t)} ${e} ${is(r)}`}function is(e){return e instanceof J.Name?e:(0, J._)`(${e})`}});var H=x(K=>{Object.defineProperty(K,"__esModule",{value:true});K.checkStrictMode=K.getErrorPath=K.Type=K.useFunc=K.setEvaluated=K.evaluatedPropsToName=K.mergeEvaluated=K.eachItem=K.unescapeJsonPointer=K.escapeJsonPointer=K.escapeFragment=K.unescapeFragment=K.schemaRefOrVal=K.schemaHasRulesButRef=K.schemaHasRules=K.checkUnknownRules=K.alwaysValidSchema=K.toHash=void 0;var Z=G(),Td=Qt();function Ad(e){let t={};for(let r of e)t[r]=true;return t}K.toHash=Ad;function Id(e,t){return typeof t=="boolean"?t:Object.keys(t).length===0?true:(wa(e,t),!_a(t,e.self.RULES.all))}K.alwaysValidSchema=Id;function wa(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]||Ca(e,`unknown keyword: "${o}"`);}K.checkUnknownRules=wa;function _a(e,t){if(typeof e=="boolean")return !e;for(let r in e)if(t[r])return true;return false}K.schemaHasRules=_a;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}K.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, Z._)`${r}`}return (0, Z._)`${e}${t}${(0, Z.getProperty)(n)}`}K.schemaRefOrVal=Od;function jd(e){return Ra(decodeURIComponent(e))}K.unescapeFragment=jd;function Nd(e){return encodeURIComponent(cs(e))}K.escapeFragment=Nd;function cs(e){return typeof e=="number"?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}K.escapeJsonPointer=cs;function Ra(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}K.unescapeJsonPointer=Ra;function qd(e,t){if(Array.isArray(e))for(let r of e)t(r);else t(e);}K.eachItem=qd;function ba({mergeNames:e,mergeToName:t,mergeValues:r,resultToName:n}){return (s,o,a,i)=>{let u=a===void 0?o:a instanceof Z.Name?(o instanceof Z.Name?e(s,o,a):t(s,o,a),a):o instanceof Z.Name?(t(s,a,o),o):r(o,a);return i===Z.Name&&!(u instanceof Z.Name)?n(s,u):u}}K.mergeEvaluated={props:ba({mergeNames:(e,t,r)=>e.if((0, Z._)`${r} !== true && ${t} !== undefined`,()=>{e.if((0, Z._)`${t} === true`,()=>e.assign(r,true),()=>e.assign(r,(0, Z._)`${r} || {}`).code((0, Z._)`Object.assign(${r}, ${t})`));}),mergeToName:(e,t,r)=>e.if((0, Z._)`${r} !== true`,()=>{t===true?e.assign(r,true):(e.assign(r,(0, Z._)`${r} || {}`),ds(e,r,t));}),mergeValues:(e,t)=>e===true?true:{...e,...t},resultToName:$a}),items:ba({mergeNames:(e,t,r)=>e.if((0, Z._)`${r} !== true && ${t} !== undefined`,()=>e.assign(r,(0, Z._)`${t} === true ? true : ${r} > ${t} ? ${r} : ${t}`)),mergeToName:(e,t,r)=>e.if((0, Z._)`${r} !== true`,()=>e.assign(r,t===true?true:(0, Z._)`${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, Z._)`{}`);return t!==void 0&&ds(e,r,t),r}K.evaluatedPropsToName=$a;function ds(e,t,r){Object.keys(r).forEach(n=>e.assign((0, Z._)`${t}${(0, Z.getProperty)(n)}`,true));}K.setEvaluated=ds;var Sa={};function Dd(e,t){return e.scopeValue("func",{ref:t,code:Sa[t.code]||(Sa[t.code]=new Td._Code(t.code))})}K.useFunc=Dd;var us;(function(e){e[e.Num=0]="Num",e[e.Str=1]="Str";})(us||(K.Type=us={}));function Fd(e,t,r){if(e instanceof Z.Name){let n=t===us.Num;return r?n?(0, Z._)`"[" + ${e} + "]"`:(0, Z._)`"['" + ${e} + "']"`:n?(0, Z._)`"/" + ${e}`:(0, Z._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0, Z.getProperty)(e).toString():"/"+cs(e)}K.getErrorPath=Fd;function Ca(e,t,r=e.opts.strictSchema){if(r){if(t=`strict mode: ${t}`,r===true)throw new Error(t);e.self.logger.warn(t);}}K.checkStrictMode=Ca;});var Ue=x(ls=>{Object.defineProperty(ls,"__esModule",{value:true});var fe=G(),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")};ls.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 z=G(),Kr=H(),ge=Ue();pe.keywordError={message:({keyword:e})=>(0, z.str)`must pass "${e}" keyword validation`};pe.keyword$DataError={message:({keyword:e,schemaType:t})=>t?(0, z.str)`"${e}" keyword must be ${t} ($data)`:(0, z.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=Ta(e,t,r);n??(a||i)?Ea(o,u):xa(s,(0, z._)`[${u}]`);}pe.reportError=Ld;function Vd(e,t=pe.keywordError,r){let{it:n}=e,{gen:s,compositeRule:o,allErrors:a}=n,i=Ta(e,t,r);Ea(s,i),o||a||xa(n,ge.default.vErrors);}pe.reportExtraError=Vd;function Bd(e,t){e.assign(ge.default.errors,t),e.if((0, z._)`${ge.default.vErrors} !== null`,()=>e.if(t,()=>e.assign((0, z._)`${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, z._)`${ge.default.vErrors}[${i}]`),e.if((0, z._)`${a}.instancePath === undefined`,()=>e.assign((0, z._)`${a}.instancePath`,(0, z.strConcat)(ge.default.instancePath,o.errorPath))),e.assign((0, z._)`${a}.schemaPath`,(0, z.str)`${o.errSchemaPath}/${t}`),o.opts.verbose&&(e.assign((0, z._)`${a}.schema`,r),e.assign((0, z._)`${a}.data`,n));});}pe.extendErrors=Gd;function Ea(e,t){let r=e.const("err",t);e.if((0, z._)`${ge.default.vErrors} === null`,()=>e.assign(ge.default.vErrors,(0, z._)`[${r}]`),(0, z._)`${ge.default.vErrors}.push(${r})`),e.code((0, z._)`${ge.default.errors}++`);}function xa(e,t){let{gen:r,validateName:n,schemaEnv:s}=e;s.$async?r.throw((0, z._)`new ${e.ValidationError}(${t})`):(r.assign((0, z._)`${n}.errors`,t),r.return(false));}var kt={keyword:new z.Name("keyword"),schemaPath:new z.Name("schemaPath"),params:new z.Name("params"),propertyName:new z.Name("propertyName"),message:new z.Name("message"),schema:new z.Name("schema"),parentSchema:new z.Name("parentSchema")};function Ta(e,t,r){let{createErrors:n}=e.it;return n===false?(0, z._)`{}`:Kd(e,t,r)}function Kd(e,t,r={}){let{gen:n,it:s}=e,o=[Ud(s,r),Jd(e,r)];return Hd(e,t,o),n.object(...o)}function Ud({errorPath:e},{instancePath:t}){let r=t?(0, z.str)`${e}${(0, Kr.getErrorPath)(t,Kr.Type.Str)}`:e;return [ge.default.instancePath,(0, z.strConcat)(ge.default.instancePath,r)]}function Jd({keyword:e,it:{errSchemaPath:t}},{schemaPath:r,parentSchema:n}){let s=n?t:(0, z.str)`${t}/${e}`;return r&&(s=(0, z.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:l,schemaPath:d}=i;n.push([kt.keyword,s],[kt.params,typeof t=="function"?t(e):t||(0, z._)`{}`]),u.messages&&n.push([kt.message,typeof r=="function"?r(e):r]),u.verbose&&n.push([kt.schema,a],[kt.parentSchema,(0, z._)`${l}${d}`],[ge.default.data,o]),c&&n.push([kt.propertyName,c]);}});var Ia=x(Pt=>{Object.defineProperty(Pt,"__esModule",{value:true});Pt.boolOrEmptySchema=Pt.topBoolOrEmptySchema=void 0;var zd=sr(),Wd=G(),Yd=Ue(),Xd={message:"boolean schema is false"};function Qd(e){let{gen:t,schema:r,validateName:n}=e;r===false?Aa(e,false):typeof r=="object"&&r.$async===true?t.return(Yd.default.data):(t.assign((0, Wd._)`${n}.errors`,null),t.return(true));}Pt.topBoolOrEmptySchema=Qd;function Zd(e,t){let{gen:r,schema:n}=e;n===false?(r.var(t,false),Aa(e)):r.var(t,true);}Pt.boolOrEmptySchema=Zd;function Aa(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, zd.reportError)(s,Xd,void 0,t);}});var fs=x(Ot=>{Object.defineProperty(Ot,"__esModule",{value:true});Ot.getRules=Ot.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)}Ot.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:{}}}Ot.getRules=nl;});var ps=x(Ze=>{Object.defineProperty(Ze,"__esModule",{value:true});Ze.shouldUseRule=Ze.shouldUseGroup=Ze.schemaHasRulesForType=void 0;function sl({schema:e,self:t},r){let n=t.RULES.types[r];return n&&n!==true&&Pa(e,n)}Ze.schemaHasRulesForType=sl;function Pa(e,t){return t.rules.some(r=>Oa(e,r))}Ze.shouldUseGroup=Pa;function Oa(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))}Ze.shouldUseRule=Oa;});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=fs(),al=ps(),il=sr(),L=G(),ja=H(),jt;(function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong";})(jt||(me.DataType=jt={}));function ul(e){let t=Na(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 Na(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=Na;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=hs(t,n,s.strictNumbers,jt.Wrong);r.if(i,()=>{o.length?ll(e,t,o):gs(e);});}return a}me.coerceAndCheckDataType=cl;var qa=new Set(["string","number","integer","boolean","null"]);function dl(e,t){return t?e.filter(r=>qa.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(hs(t,s,o.strictNumbers),()=>n.assign(i,s))),n.if((0, L._)`${i} !== undefined`);for(let c of r)(qa.has(c)||c==="array"&&o.coerceTypes==="array")&&u(c);n.else(),gs(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'),P=require('fs'),Pn=require('os'),ue=require('path'),Ho=require('net'),url=require('url'),crypto=require('crypto'),module$1=require('module'),properLockfile=require('proper-lockfile'),Bh=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 P__namespace=/*#__PURE__*/_interopNamespace(P);var Pn__namespace=/*#__PURE__*/_interopNamespace(Pn);var ue__namespace=/*#__PURE__*/_interopNamespace(ue);var Ho__namespace=/*#__PURE__*/_interopNamespace(Ho);var Bh__default=/*#__PURE__*/_interopDefault(Bh);var jc=Object.create;var Go=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&&Go(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(Go(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 ht=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=ht;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 ht&&(r[n.str]=(r[n.str]||0)+1),r),{})}};W._Code=xe;W.nil=new xe("");function ga(e,...t){let r=[e[0]],n=0;for(;n<t.length;)Jn(r,t[n]),r.push(e[++n]);return new xe(r)}W._=ga;var Un=new xe("+");function ya(e,...t){let r=[Xt(e[0])],n=0;for(;n<t.length;)r.push(Un),Jn(r,t[n]),r.push(Un,Xt(e[++n]));return hd(r),new xe(r)}W.str=ya;function Jn(e,t){t instanceof xe?e.push(...t._items):t instanceof ht?e.push(t):e.push(vd(t));}W.addCodeArg=Jn;function hd(e){let t=1;for(;t<e.length-1;){if(e[t]===Un){let r=gd(e[t-1],e[t+1]);if(r!==void 0){e.splice(t-1,3,r);continue}e[t++]="+";}t++;}}function gd(e,t){if(t==='""')return e;if(e==='""')return t;if(typeof e=="string")return t instanceof ht||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 ht))return `"${e}${t.slice(1)}`}function yd(e,t){return t.emptyStr()?e:e.emptyStr()?t:ya`${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 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 kd(e){return typeof e=="string"&&W.IDENTIFIER.test(e)?new xe(`.${e}`):ga`[${e}]`}W.getProperty=kd;function Sd(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=Sd;function wd(e){return new xe(e.toString())}W.regexpCode=wd;});var Wn=x(be=>{Object.defineProperty(be,"__esModule",{value:true});be.ValueScope=be.ValueScopeName=be.Scope=be.varKinds=be.UsedValueState=void 0;var ve=Qt(),Hn=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||(be.UsedValueState=Dr={}));be.varKinds={const:new ve.Name("const"),let:new ve.Name("let"),var:new ve.Name("var")};var Fr=class{constructor({prefixes:t,parent:r}={}){this._names={},this._prefixes=t,this._parent=r;}toName(t){return t instanceof ve.Name?t:this.name(t)}name(t){return new ve.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}}};be.Scope=Fr;var Mr=class extends ve.Name{constructor(t,r){super(r),this.prefix=t;}setValue(t,{property:r,itemIndex:n}){this.value=t,this.scopePath=(0, ve._)`.${new ve.Name(r)}[${n}]`;}};be.ValueScopeName=Mr;var _d=(0, ve._)`\n`,zn=class extends Fr{constructor(t){super(t),this._values={},this._scope=t.scope,this.opts={...t,_n:t.lines?_d:ve.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 l=i.get(a);if(l)return l}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, ve._)`${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=ve.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 l=r(c);if(l){let d=this.opts.es5?be.varKinds.var:be.varKinds.const;o=(0, ve._)`${o}${d} ${c} = ${l};${this.opts._n}`;}else if(l=s?.(c))o=(0, ve._)`${o}${l}${this.opts._n}`;else throw new Hn(c);u.set(c,Dr.Completed);});}return o}};be.ValueScope=zn;});var G=x(B=>{Object.defineProperty(B,"__esModule",{value:true});B.or=B.and=B.not=B.CodeGen=B.operators=B.varKinds=B.ValueScopeName=B.ValueScope=B.Scope=B.Name=B.regexpCode=B.stringify=B.getProperty=B.nil=B.strConcat=B.str=B._=void 0;var J=Qt(),Pe=Wn(),Qe=Qt();Object.defineProperty(B,"_",{enumerable:true,get:function(){return Qe._}});Object.defineProperty(B,"str",{enumerable:true,get:function(){return Qe.str}});Object.defineProperty(B,"strConcat",{enumerable:true,get:function(){return Qe.strConcat}});Object.defineProperty(B,"nil",{enumerable:true,get:function(){return Qe.nil}});Object.defineProperty(B,"getProperty",{enumerable:true,get:function(){return Qe.getProperty}});Object.defineProperty(B,"stringify",{enumerable:true,get:function(){return Qe.stringify}});Object.defineProperty(B,"regexpCode",{enumerable:true,get:function(){return Qe.regexpCode}});Object.defineProperty(B,"Name",{enumerable:true,get:function(){return Qe.Name}});var Gr=Wn();Object.defineProperty(B,"Scope",{enumerable:true,get:function(){return Gr.Scope}});Object.defineProperty(B,"ValueScope",{enumerable:true,get:function(){return Gr.ValueScope}});Object.defineProperty(B,"ValueScopeName",{enumerable:true,get:function(){return Gr.ValueScopeName}});Object.defineProperty(B,"varKinds",{enumerable:true,get:function(){return Gr.varKinds}});B.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 Ge=class{optimizeNodes(){return this}optimizeNames(t,r){return this}},Yn=class extends Ge{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=It(this.rhs,t,r)),this}get names(){return this.rhs instanceof J._CodeOrName?this.rhs.names:{}}},Lr=class extends Ge{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=It(this.rhs,t,r),this}get names(){let t=this.lhs instanceof J.Name?{}:{...this.lhs.names};return Br(t,this.rhs)}},Xn=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}},Qn=class extends Ge{constructor(t){super(),this.label=t,this.names={};}render({_n:t}){return `${this.label}:`+t}},Zn=class extends Ge{constructor(t){super(),this.label=t,this.names={};}render({_n:t}){return `break${this.label?` ${this.label}`:""};`+t}},es=class extends Ge{constructor(t){super(),this.error=t;}render({_n:t}){return `throw ${this.error};`+t}get names(){return this.error.names}},ts=class extends Ge{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=It(this.code,t,r),this}get names(){return this.code instanceof J._CodeOrName?this.code.names:{}}},Zt=class extends Ge{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),{})}},Ke=class extends Zt{render(t){return "{"+t._n+super.render(t)+"}"+t._n}},rs=class extends Zt{},At=class extends Ke{};At.kind="else";var gt=class e extends Ke{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 At(n):n;}if(r)return t===false?r instanceof e?r:r.nodes:this.nodes.length?this:new e(va(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=It(this.condition,t,r),this}get names(){let t=super.names;return Br(t,this.condition),this.else&&vt(t,this.else.names),t}};gt.kind="if";var yt=class extends Ke{};yt.kind="for";var ns=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=It(this.iteration,t,r),this}get names(){return vt(super.names,this.iteration.names)}},ss=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=It(this.iterable,t,r),this}get names(){return vt(super.names,this.iterable.names)}},er=class extends Ke{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 os=class extends Ke{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 Ke{constructor(t){super(),this.error=t;}render(t){return `catch(${this.error})`+super.render(t)}};rr.kind="catch";var nr=class extends Ke{render(t){return "finally"+super.render(t)}};nr.kind="finally";var as=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 rs];}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 Yn(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 Xn(t,B.operators.ADD,r))}code(t){return typeof t=="function"?t():t!==J.nil&&this._leafNode(new ts(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 gt(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 gt(t))}else(){return this._elseNode(new At)}endIf(){return this._endBlockNode(gt,At)}_for(t,r){return this._blockNode(t),r&&this.code(r).endFor(),this}for(t,r){return this._for(new ns(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 ss(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 Qn(t))}break(t){return this._leafNode(new Zn(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 os;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 es(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 gt))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;}};B.CodeGen=as;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 It(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 va(e){return typeof e=="boolean"||typeof e=="number"||e===null?!e:(0, J._)`!${is(e)}`}B.not=va;var $d=ba(B.operators.AND);function Cd(...e){return e.reduce($d)}B.and=Cd;var Ed=ba(B.operators.OR);function xd(...e){return e.reduce(Ed)}B.or=xd;function ba(e){return (t,r)=>t===J.nil?r:r===J.nil?t:(0, J._)`${is(t)} ${e} ${is(r)}`}function is(e){return e instanceof J.Name?e:(0, J._)`(${e})`}});var H=x(K=>{Object.defineProperty(K,"__esModule",{value:true});K.checkStrictMode=K.getErrorPath=K.Type=K.useFunc=K.setEvaluated=K.evaluatedPropsToName=K.mergeEvaluated=K.eachItem=K.unescapeJsonPointer=K.escapeJsonPointer=K.escapeFragment=K.unescapeFragment=K.schemaRefOrVal=K.schemaHasRulesButRef=K.schemaHasRules=K.checkUnknownRules=K.alwaysValidSchema=K.toHash=void 0;var Z=G(),Td=Qt();function Ad(e){let t={};for(let r of e)t[r]=true;return t}K.toHash=Ad;function Id(e,t){return typeof t=="boolean"?t:Object.keys(t).length===0?true:(wa(e,t),!_a(t,e.self.RULES.all))}K.alwaysValidSchema=Id;function wa(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]||Ca(e,`unknown keyword: "${o}"`);}K.checkUnknownRules=wa;function _a(e,t){if(typeof e=="boolean")return !e;for(let r in e)if(t[r])return true;return false}K.schemaHasRules=_a;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}K.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, Z._)`${r}`}return (0, Z._)`${e}${t}${(0, Z.getProperty)(n)}`}K.schemaRefOrVal=Od;function jd(e){return Ra(decodeURIComponent(e))}K.unescapeFragment=jd;function Nd(e){return encodeURIComponent(cs(e))}K.escapeFragment=Nd;function cs(e){return typeof e=="number"?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}K.escapeJsonPointer=cs;function Ra(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}K.unescapeJsonPointer=Ra;function qd(e,t){if(Array.isArray(e))for(let r of e)t(r);else t(e);}K.eachItem=qd;function ka({mergeNames:e,mergeToName:t,mergeValues:r,resultToName:n}){return (s,o,a,i)=>{let u=a===void 0?o:a instanceof Z.Name?(o instanceof Z.Name?e(s,o,a):t(s,o,a),a):o instanceof Z.Name?(t(s,a,o),o):r(o,a);return i===Z.Name&&!(u instanceof Z.Name)?n(s,u):u}}K.mergeEvaluated={props:ka({mergeNames:(e,t,r)=>e.if((0, Z._)`${r} !== true && ${t} !== undefined`,()=>{e.if((0, Z._)`${t} === true`,()=>e.assign(r,true),()=>e.assign(r,(0, Z._)`${r} || {}`).code((0, Z._)`Object.assign(${r}, ${t})`));}),mergeToName:(e,t,r)=>e.if((0, Z._)`${r} !== true`,()=>{t===true?e.assign(r,true):(e.assign(r,(0, Z._)`${r} || {}`),ds(e,r,t));}),mergeValues:(e,t)=>e===true?true:{...e,...t},resultToName:$a}),items:ka({mergeNames:(e,t,r)=>e.if((0, Z._)`${r} !== true && ${t} !== undefined`,()=>e.assign(r,(0, Z._)`${t} === true ? true : ${r} > ${t} ? ${r} : ${t}`)),mergeToName:(e,t,r)=>e.if((0, Z._)`${r} !== true`,()=>e.assign(r,t===true?true:(0, Z._)`${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, Z._)`{}`);return t!==void 0&&ds(e,r,t),r}K.evaluatedPropsToName=$a;function ds(e,t,r){Object.keys(r).forEach(n=>e.assign((0, Z._)`${t}${(0, Z.getProperty)(n)}`,true));}K.setEvaluated=ds;var Sa={};function Dd(e,t){return e.scopeValue("func",{ref:t,code:Sa[t.code]||(Sa[t.code]=new Td._Code(t.code))})}K.useFunc=Dd;var us;(function(e){e[e.Num=0]="Num",e[e.Str=1]="Str";})(us||(K.Type=us={}));function Fd(e,t,r){if(e instanceof Z.Name){let n=t===us.Num;return r?n?(0, Z._)`"[" + ${e} + "]"`:(0, Z._)`"['" + ${e} + "']"`:n?(0, Z._)`"/" + ${e}`:(0, Z._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0, Z.getProperty)(e).toString():"/"+cs(e)}K.getErrorPath=Fd;function Ca(e,t,r=e.opts.strictSchema){if(r){if(t=`strict mode: ${t}`,r===true)throw new Error(t);e.self.logger.warn(t);}}K.checkStrictMode=Ca;});var Ue=x(ls=>{Object.defineProperty(ls,"__esModule",{value:true});var fe=G(),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")};ls.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 z=G(),Kr=H(),ge=Ue();pe.keywordError={message:({keyword:e})=>(0, z.str)`must pass "${e}" keyword validation`};pe.keyword$DataError={message:({keyword:e,schemaType:t})=>t?(0, z.str)`"${e}" keyword must be ${t} ($data)`:(0, z.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=Ta(e,t,r);n??(a||i)?Ea(o,u):xa(s,(0, z._)`[${u}]`);}pe.reportError=Ld;function Vd(e,t=pe.keywordError,r){let{it:n}=e,{gen:s,compositeRule:o,allErrors:a}=n,i=Ta(e,t,r);Ea(s,i),o||a||xa(n,ge.default.vErrors);}pe.reportExtraError=Vd;function Bd(e,t){e.assign(ge.default.errors,t),e.if((0, z._)`${ge.default.vErrors} !== null`,()=>e.if(t,()=>e.assign((0, z._)`${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, z._)`${ge.default.vErrors}[${i}]`),e.if((0, z._)`${a}.instancePath === undefined`,()=>e.assign((0, z._)`${a}.instancePath`,(0, z.strConcat)(ge.default.instancePath,o.errorPath))),e.assign((0, z._)`${a}.schemaPath`,(0, z.str)`${o.errSchemaPath}/${t}`),o.opts.verbose&&(e.assign((0, z._)`${a}.schema`,r),e.assign((0, z._)`${a}.data`,n));});}pe.extendErrors=Gd;function Ea(e,t){let r=e.const("err",t);e.if((0, z._)`${ge.default.vErrors} === null`,()=>e.assign(ge.default.vErrors,(0, z._)`[${r}]`),(0, z._)`${ge.default.vErrors}.push(${r})`),e.code((0, z._)`${ge.default.errors}++`);}function xa(e,t){let{gen:r,validateName:n,schemaEnv:s}=e;s.$async?r.throw((0, z._)`new ${e.ValidationError}(${t})`):(r.assign((0, z._)`${n}.errors`,t),r.return(false));}var bt={keyword:new z.Name("keyword"),schemaPath:new z.Name("schemaPath"),params:new z.Name("params"),propertyName:new z.Name("propertyName"),message:new z.Name("message"),schema:new z.Name("schema"),parentSchema:new z.Name("parentSchema")};function Ta(e,t,r){let{createErrors:n}=e.it;return n===false?(0, z._)`{}`:Kd(e,t,r)}function Kd(e,t,r={}){let{gen:n,it:s}=e,o=[Ud(s,r),Jd(e,r)];return Hd(e,t,o),n.object(...o)}function Ud({errorPath:e},{instancePath:t}){let r=t?(0, z.str)`${e}${(0, Kr.getErrorPath)(t,Kr.Type.Str)}`:e;return [ge.default.instancePath,(0, z.strConcat)(ge.default.instancePath,r)]}function Jd({keyword:e,it:{errSchemaPath:t}},{schemaPath:r,parentSchema:n}){let s=n?t:(0, z.str)`${t}/${e}`;return r&&(s=(0, z.str)`${s}${(0, Kr.getErrorPath)(r,Kr.Type.Str)}`),[bt.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:l,schemaPath:d}=i;n.push([bt.keyword,s],[bt.params,typeof t=="function"?t(e):t||(0, z._)`{}`]),u.messages&&n.push([bt.message,typeof r=="function"?r(e):r]),u.verbose&&n.push([bt.schema,a],[bt.parentSchema,(0, z._)`${l}${d}`],[ge.default.data,o]),c&&n.push([bt.propertyName,c]);}});var Ia=x(Pt=>{Object.defineProperty(Pt,"__esModule",{value:true});Pt.boolOrEmptySchema=Pt.topBoolOrEmptySchema=void 0;var zd=sr(),Wd=G(),Yd=Ue(),Xd={message:"boolean schema is false"};function Qd(e){let{gen:t,schema:r,validateName:n}=e;r===false?Aa(e,false):typeof r=="object"&&r.$async===true?t.return(Yd.default.data):(t.assign((0, Wd._)`${n}.errors`,null),t.return(true));}Pt.topBoolOrEmptySchema=Qd;function Zd(e,t){let{gen:r,schema:n}=e;n===false?(r.var(t,false),Aa(e)):r.var(t,true);}Pt.boolOrEmptySchema=Zd;function Aa(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, zd.reportError)(s,Xd,void 0,t);}});var fs=x(Ot=>{Object.defineProperty(Ot,"__esModule",{value:true});Ot.getRules=Ot.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)}Ot.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:{}}}Ot.getRules=nl;});var ps=x(Ze=>{Object.defineProperty(Ze,"__esModule",{value:true});Ze.shouldUseRule=Ze.shouldUseGroup=Ze.schemaHasRulesForType=void 0;function sl({schema:e,self:t},r){let n=t.RULES.types[r];return n&&n!==true&&Pa(e,n)}Ze.schemaHasRulesForType=sl;function Pa(e,t){return t.rules.some(r=>Oa(e,r))}Ze.shouldUseGroup=Pa;function Oa(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))}Ze.shouldUseRule=Oa;});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=fs(),al=ps(),il=sr(),L=G(),ja=H(),jt;(function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong";})(jt||(me.DataType=jt={}));function ul(e){let t=Na(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 Na(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=Na;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=hs(t,n,s.strictNumbers,jt.Wrong);r.if(i,()=>{o.length?ll(e,t,o):gs(e);});}return a}me.coerceAndCheckDataType=cl;var qa=new Set(["string","number","integer","boolean","null"]);function dl(e,t){return t?e.filter(r=>qa.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(hs(t,s,o.strictNumbers),()=>n.assign(i,s))),n.if((0, L._)`${i} !== undefined`);for(let c of r)(qa.has(c)||c==="array"&&o.coerceTypes==="array")&&u(c);n.else(),gs(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
|
|
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 ms(e,t,r,n=jt.Correct){let s=n===jt.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===jt.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=ms;function hs(e,t,r,n){if(e.length===1)return ms(e[0],t,r,n);let s,o=(0, ja.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,ms(a,t,r,n));return s}me.checkDataTypes=hs;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 gs(e){let t=ml(e);(0, il.reportError)(t,pl);}me.reportTypeError=gs;function ml(e){let{gen:t,data:r,schema:n}=e,s=(0, ja.schemaRefOrVal)(e,n,"type");return {gen:t,keyword:"type",data:r,schema:n.type,schemaCode:s,schemaValue:s,parentSchema:n,params:{},it:e}}});var Fa=x(Ur=>{Object.defineProperty(Ur,"__esModule",{value:true});Ur.assignDefaults=void 0;var Nt=G(),hl=H();function gl(e,t){let{properties:r,items:n}=e.schema;if(t==="object"&&r)for(let s in r)Da(e,s,r[s].default);else t==="array"&&Array.isArray(n)&&n.forEach((s,o)=>Da(e,o,s.default));}Ur.assignDefaults=gl;function Da(e,t,r){let{gen:n,compositeRule:s,data:o,opts:a}=e;if(r===void 0)return;let i=(0, Nt._)`${o}${(0, Nt.getProperty)(t)}`;if(s){(0, hl.checkStrictMode)(e,`default is ignored for: ${i}`);return}let u=(0, Nt._)`${i} === undefined`;a.useDefaults==="empty"&&(u=(0, Nt._)`${u} || ${i} === null || ${i} === ""`),n.if(u,(0, Nt._)`${i} = ${(0, Nt.stringify)(r)}`);}});var Te=x(X=>{Object.defineProperty(X,"__esModule",{value:true});X.validateUnion=X.validateArray=X.usePattern=X.callValidateCode=X.schemaProperties=X.allSchemaProperties=X.noPropertyInData=X.propertyInData=X.isOwnProperty=X.hasPropFunc=X.reportMissingProp=X.checkMissingProp=X.checkReportMissingProp=void 0;var ne=G(),ys=H(),et=Ue(),yl=H();function vl(e,t){let{gen:r,data:n,it:s}=e;r.if(ks(r,n,t,s.opts.ownProperties),()=>{e.setParams({missingProperty:(0, ne._)`${t}`},true),e.error();});}X.checkReportMissingProp=vl;function kl({gen:e,data:t,it:{opts:r}},n,s){return (0, ne.or)(...n.map(o=>(0, ne.and)(ks(e,t,o,r.ownProperties),(0, ne._)`${s} = ${o}`)))}X.checkMissingProp=kl;function bl(e,t){e.setParams({missingProperty:t},true),e.error();}X.reportMissingProp=bl;function Ma(e){return e.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0, ne._)`Object.prototype.hasOwnProperty`})}X.hasPropFunc=Ma;function vs(e,t,r){return (0, ne._)`${Ma(e)}.call(${t}, ${r})`}X.isOwnProperty=vs;function Sl(e,t,r,n){let s=(0, ne._)`${t}${(0, ne.getProperty)(r)} !== undefined`;return n?(0, ne._)`${s} && ${vs(e,t,r)}`:s}X.propertyInData=Sl;function ks(e,t,r,n){let s=(0, ne._)`${t}${(0, ne.getProperty)(r)} === undefined`;return n?(0, ne.or)(s,(0, ne.not)(vs(e,t,r))):s}X.noPropertyInData=ks;function La(e){return e?Object.keys(e).filter(t=>t!=="__proto__"):[]}X.allSchemaProperties=La;function wl(e,t){return La(t).filter(r=>!(0, ys.alwaysValidSchema)(e,t[r]))}X.schemaProperties=wl;function _l({schemaCode:e,data:t,it:{gen:r,topSchemaRef:n,schemaPath:s,errorPath:o},it:a},i,u,c){let l=c?(0, ne._)`${e}, ${t}, ${n}${s}`:t,d=[[et.default.instancePath,(0, ne.strConcat)(et.default.instancePath,o)],[et.default.parentData,a.parentData],[et.default.parentDataProperty,a.parentDataProperty],[et.default.rootData,et.default.rootData]];a.opts.dynamicRef&&d.push([et.default.dynamicAnchors,et.default.dynamicAnchors]);let y=(0, ne._)`${l}, ${r.object(...d)}`;return u!==ne.nil?(0, ne._)`${i}.call(${u}, ${y})`:(0, ne._)`${i}(${y})`}X.callValidateCode=_l;var Rl=(0, ne._)`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, ne._)`${s.code==="new RegExp"?Rl:(0, yl.useFunc)(e,s)}(${r}, ${n})`})}X.usePattern=$l;function Cl(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, ne._)`${r}.length`);t.forRange("i",0,u,c=>{e.subschema({keyword:n,dataProp:c,dataPropType:ys.Type.Num},o),t.if((0, ne.not)(o),i);});}}X.validateArray=Cl;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, ys.alwaysValidSchema)(s,u))&&!s.opts.unevaluated)return;let a=t.let("valid",false),i=t.name("_valid");t.block(()=>r.forEach((u,c)=>{let l=e.subschema({keyword:n,schemaProp:c,compositeRule:true},i);t.assign(a,(0, ne._)`${a} || ${i}`),e.mergeValidEvaluated(l,i)||t.if((0, ne.not)(a));})),e.result(a,()=>e.reset(),()=>e.error(true));}X.validateUnion=El;});var Ga=x(Fe=>{Object.defineProperty(Fe,"__esModule",{value:true});Fe.validateKeywordUsage=Fe.validSchemaType=Fe.funcKeywordCode=Fe.macroKeywordCode=void 0;var ye=G(),bt=Ue(),xl=Te(),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=Ba(r,n,i);a.opts.validateSchema!==false&&a.self.validateSchema(i,true);let c=r.name("valid");e.subschema({schema:i,schemaPath:ye.nil,errSchemaPath:`${a.errSchemaPath}/${n}`,topSchemaRef:u,compositeRule:true},c),e.pass(c,()=>e.error(true));}Fe.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,l=Ba(n,s,c),d=n.let("valid");e.block$data(d,y),e.ok((r=t.valid)!==null&&r!==void 0?r:d);function y(){if(t.errors===false)p(),t.modifying&&Va(e),b(()=>e.error());else {let h=t.async?g():f();t.modifying&&Va(e),b(()=>Pl(e,h));}}function g(){let h=n.let("ruleErrs",null);return n.try(()=>p((0, ye._)`await `),m=>n.assign(d,false).if((0, ye._)`${m} instanceof ${u.ValidationError}`,()=>n.assign(h,(0, ye._)`${m}.errors`),()=>n.throw(m))),h}function f(){let h=(0, ye._)`${l}.errors`;return n.assign(h,null),p(ye.nil),h}function p(h=t.async?(0, ye._)`await `:ye.nil){let m=u.opts.passContext?bt.default.this:bt.default.self,v=!("compile"in t&&!i||t.schema===false);n.assign(d,(0, ye._)`${h}${(0, xl.callValidateCode)(e,l,m,v)}`,t.modifying);}function b(h){var m;n.if((0, ye.not)((m=t.valid)!==null&&m!==void 0?m:d),h);}}Fe.funcKeywordCode=Il;function Va(e){let{gen:t,data:r,it:n}=e;t.if(n.parentData,()=>t.assign(r,(0, ye._)`${n.parentData}[${n.parentDataProperty}]`));}function Pl(e,t){let{gen:r}=e;r.if((0, ye._)`Array.isArray(${t})`,()=>{r.assign(bt.default.vErrors,(0, ye._)`${bt.default.vErrors} === null ? ${t} : ${bt.default.vErrors}.concat(${t})`).assign(bt.default.errors,(0, ye._)`${bt.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 Ba(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, ye.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")}Fe.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)}}Fe.validateKeywordUsage=Nl;});var Ua=x(tt=>{Object.defineProperty(tt,"__esModule",{value:true});tt.extendSubschemaMode=tt.extendSubschemaData=tt.getSubschema=void 0;var Me=G(),Ka=H();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, Me._)`${e.schemaPath}${(0, Me.getProperty)(t)}`,errSchemaPath:`${e.errSchemaPath}/${t}`}:{schema:i[r],schemaPath:(0, Me._)`${e.schemaPath}${(0, Me.getProperty)(t)}${(0, Me.getProperty)(r)}`,errSchemaPath:`${e.errSchemaPath}/${t}/${(0, Ka.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')}tt.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:l,opts:d}=t,y=i.let("data",(0, Me._)`${t.data}${(0, Me.getProperty)(r)}`,true);u(y),e.errorPath=(0, Me.str)`${c}${(0, Ka.getErrorPath)(r,n,d.jsPropertySyntax)}`,e.parentDataProperty=(0, Me._)`${r}`,e.dataPathArr=[...l,e.parentDataProperty];}if(s!==void 0){let c=s instanceof Me.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];}}tt.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;}tt.extendSubschemaMode=Fl;});var bs=x((Fy,Ja)=>{Ja.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 za=x((My,Ha)=>{var rt=Ha.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);};rt.keywords={additionalItems:true,items:true,contains:true,additionalProperties:true,propertyNames:true,not:true,if:true,then:true,else:true};rt.arrayKeywords={items:true,allOf:true,anyOf:true,oneOf:true};rt.propsKeywords={$defs:true,definitions:true,properties:true,patternProperties:true,dependencies:true};rt.skipKeywords={default:true,enum:true,const:true,required:true,maximum:true,minimum:true,exclusiveMaximum:true,exclusiveMinimum:true,multipleOf:true,maxLength:true,minLength:true,pattern:true,format:true,maxItems:true,minItems:true,uniqueItems:true,maxProperties:true,minProperties:true};function 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 l in n){var d=n[l];if(Array.isArray(d)){if(l in rt.arrayKeywords)for(var y=0;y<d.length;y++)Jr(e,t,r,d[y],s+"/"+l+"/"+y,o,s,l,n,y);}else if(l in rt.propsKeywords){if(d&&typeof d=="object")for(var g in d)Jr(e,t,r,d[g],s+"/"+l+"/"+Ml(g),o,s,l,n,g);}else (l in rt.keywords||e.allKeys&&!(l in rt.skipKeywords))&&Jr(e,t,r,d,s+"/"+l,o,s,l,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=H(),Vl=bs(),Bl=za(),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?!Ss(e):t?Wa(e)<=t:false}be.inlineRef=Kl;var Ul=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function Ss(e){for(let t in e){if(Ul.has(t))return true;let r=e[t];if(Array.isArray(r)&&r.some(Ss)||typeof r=="object"&&Ss(r))return true}return false}function Wa(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+=Wa(n)),t===1/0))return 1/0}return t}function Ya(e,t="",r){r!==false&&(t=qt(t));let n=e.parse(t);return Xa(e,n)}be.getFullPath=Ya;function Xa(e,t){return e.serialize(t).split("#")[0]+"#"}be._getFullPath=Xa;var Jl=/#\/?$/;function qt(e){return e?e.replace(Jl,""):""}be.normalizeId=qt;function Hl(e,t,r){return r=qt(r),e.resolve(t,r)}be.resolveUrl=Hl;var zl=/^[a-z_][-a-z0-9._]*$/i;function Wl(e,t){if(typeof e=="boolean")return {};let{schemaId:r,uriResolver:n}=this.opts,s=qt(e[r]||t),o={"":s},a=Ya(n,s,false),i={},u=new Set;return Bl(e,{allKeys:true},(d,y,g,f)=>{if(f===void 0)return;let p=a+y,b=o[f];typeof d[r]=="string"&&(b=h.call(this,d[r])),m.call(this,d.$anchor),m.call(this,d.$dynamicAnchor),o[y]=b;function h(v){let w=this.opts.uriResolver.resolve;if(v=qt(b?w(b,v):v),u.has(v))throw l(v);u.add(v);let S=this.refs[v];return typeof S=="string"&&(S=this.refs[S]),typeof S=="object"?c(d,S.schema,v):v!==qt(p)&&(v[0]==="#"?(c(d,i[v],v),i[v]=d):this.refs[v]=p),v}function m(v){if(typeof v=="string"){if(!zl.test(v))throw new Error(`invalid anchor "${v}"`);h.call(this,`#${v}`);}}}),i;function c(d,y,g){if(y!==void 0&&!Vl(d,y))throw l(g)}function l(d){return new Error(`reference "${d}" resolves to more than one schema`)}}be.getSchemaRefs=Wl;});var cr=x(nt=>{Object.defineProperty(nt,"__esModule",{value:true});nt.getData=nt.KeywordCxt=nt.validateFunctionCode=void 0;var ri=Ia(),Qa=or(),_s=ps(),Hr=or(),Yl=Fa(),ur=Ga(),ws=Ua(),T=G(),O=Ue(),Xl=ar(),Je=H(),ir=sr();function Ql(e){if(oi(e)&&(ai(e),si(e))){tf(e);return}ni(e,()=>(0, ri.topBoolOrEmptySchema)(e));}nt.validateFunctionCode=Ql;function ni({gen:e,validateName:t,schema:r,schemaEnv:n,opts:s},o){s.code.es5?e.func(t,(0, T._)`${O.default.data}, ${O.default.valCxt}`,n.$async,()=>{e.code((0, T._)`"use strict"; ${Za(r,s)}`),ef(e,s),e.code(o);}):e.func(t,(0, T._)`${O.default.data}, ${Zl(s)}`,n.$async,()=>e.code(Za(r,s)).code(o));}function Zl(e){return (0, T._)`{${O.default.instancePath}="", ${O.default.parentData}, ${O.default.parentDataProperty}, ${O.default.rootData}=${O.default.data}${e.dynamicRef?(0, T._)`, ${O.default.dynamicAnchors}={}`:T.nil}}={}`}function ef(e,t){e.if(O.default.valCxt,()=>{e.var(O.default.instancePath,(0, T._)`${O.default.valCxt}.${O.default.instancePath}`),e.var(O.default.parentData,(0, T._)`${O.default.valCxt}.${O.default.parentData}`),e.var(O.default.parentDataProperty,(0, T._)`${O.default.valCxt}.${O.default.parentDataProperty}`),e.var(O.default.rootData,(0, T._)`${O.default.valCxt}.${O.default.rootData}`),t.dynamicRef&&e.var(O.default.dynamicAnchors,(0, T._)`${O.default.valCxt}.${O.default.dynamicAnchors}`);},()=>{e.var(O.default.instancePath,(0, T._)`""`),e.var(O.default.parentData,(0, T._)`undefined`),e.var(O.default.parentDataProperty,(0, T._)`undefined`),e.var(O.default.rootData,O.default.data),t.dynamicRef&&e.var(O.default.dynamicAnchors,(0, T._)`{}`);});}function tf(e){let{schema:t,opts:r,gen:n}=e;ni(e,()=>{r.$comment&&t.$comment&&ui(e),af(e),n.let(O.default.vErrors,null),n.let(O.default.errors,0),r.unevaluated&&rf(e),ii(e),df(e);});}function rf(e){let{gen:t,validateName:r}=e;e.evaluated=t.const("evaluated",(0, T._)`${r}.evaluated`),t.if((0, T._)`${e.evaluated}.dynamicProps`,()=>t.assign((0, T._)`${e.evaluated}.props`,(0, T._)`undefined`)),t.if((0, T._)`${e.evaluated}.dynamicItems`,()=>t.assign((0, T._)`${e.evaluated}.items`,(0, T._)`undefined`));}function Za(e,t){let r=typeof e=="object"&&e[t.schemaId];return r&&(t.code.source||t.code.process)?(0, T._)`/*# sourceURL=${r} */`:T.nil}function nf(e,t){if(oi(e)&&(ai(e),si(e))){sf(e,t);return}(0, ri.boolOrEmptySchema)(e,t);}function si({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 oi(e){return typeof e.schema!="boolean"}function sf(e,t){let{schema:r,gen:n,opts:s}=e;s.$comment&&r.$comment&&ui(e),uf(e),cf(e);let o=n.const("_errs",O.default.errors);ii(e,o),n.var(t,(0, T._)`${o} === ${O.default.errors}`);}function ai(e){(0, Je.checkUnknownRules)(e),of(e);}function ii(e,t){if(e.opts.jtd)return ei(e,[],false,t);let r=(0, Qa.getSchemaTypes)(e.schema),n=(0, Qa.coerceAndCheckDataType)(e,r);ei(e,r,!n,t);}function of(e){let{schema:t,errSchemaPath:r,opts:n,self:s}=e;t.$ref&&n.ignoreKeywordsWithRef&&(0, Je.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, Je.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 ui({gen:e,schemaEnv:t,schema:r,errSchemaPath:n,opts:s}){let o=r.$comment;if(s.$comment===true)e.code((0, T._)`${O.default.self}.logger.log(${o})`);else if(typeof s.$comment=="function"){let a=(0, T.str)`${n}/$comment`,i=e.scopeValue("root",{ref:t.root});e.code((0, T._)`${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, T._)`${O.default.errors} === 0`,()=>t.return(O.default.data),()=>t.throw((0, T._)`new ${s}(${O.default.vErrors})`)):(t.assign((0, T._)`${n}.errors`,O.default.vErrors),o.unevaluated&&lf(e),t.return((0, T._)`${O.default.errors} === 0`));}function lf({gen:e,evaluated:t,props:r,items:n}){r instanceof T.Name&&e.assign((0, T._)`${t}.props`,r),n instanceof T.Name&&e.assign((0, T._)`${t}.items`,n);}function ei(e,t,r,n){let{gen:s,schema:o,data:a,allErrors:i,opts:u,self:c}=e,{RULES:l}=c;if(o.$ref&&(u.ignoreKeywordsWithRef||!(0, Je.schemaHasRulesButRef)(o,l))){s.block(()=>di(e,"$ref",l.all.$ref.definition));return}u.jtd||ff(e,t),s.block(()=>{for(let y of l.rules)d(y);d(l.post);});function d(y){(0, _s.shouldUseGroup)(o,y)&&(y.type?(s.if((0, Hr.checkDataType)(y.type,a,u.strictNumbers)),ti(e,y),t.length===1&&t[0]===y.type&&r&&(s.else(),(0, Hr.reportTypeError)(e)),s.endIf()):ti(e,y),i||s.if((0, T._)`${O.default.errors} === ${n||0}`));}}function ti(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, _s.shouldUseRule)(n,o)&&di(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),hf(e,e.dataTypes));}function pf(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(r=>{ci(e.dataTypes,r)||Rs(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"))&&Rs(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, _s.shouldUseRule)(e.schema,s)){let{type:o}=s.definition;o.length&&!o.some(a=>gf(t,a))&&Rs(e,`missing type "${o.join(",")}" for keyword "${n}"`);}}}function gf(e,t){return e.includes(t)||t==="number"&&e.includes("integer")}function ci(e,t){return e.includes(t)||t==="integer"&&e.includes("number")}function yf(e,t){let r=[];for(let n of e.dataTypes)ci(t,n)?r.push(n):t.includes("integer")&&n==="number"&&r.push("integer");e.dataTypes=r;}function Rs(e,t){let r=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${r}" (strictTypes)`,(0, Je.checkStrictMode)(e,t,e.opts.strictTypes);}var zr=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, Je.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",li(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, T.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, T.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, T._)`${r} !== undefined && (${(0, T.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=T.nil){this.gen.block(()=>{this.check$data(t,n),r();});}check$data(t=T.nil,r=T.nil){if(!this.$data)return;let{gen:n,schemaCode:s,schemaType:o,def:a}=this;n.if((0, T.or)((0, T._)`${s} === undefined`,r)),t!==T.nil&&n.assign(t,true),(o.length||a.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),t!==T.nil&&n.assign(t,false)),n.else();}invalid$data(){let{gen:t,schemaCode:r,schemaType:n,def:s,it:o}=this;return (0, T.or)(a(),i());function a(){if(n.length){if(!(r instanceof T.Name))throw new Error("ajv implementation error");let u=Array.isArray(n)?n:[n];return (0, T._)`${(0, Hr.checkDataTypes)(u,r,o.opts.strictNumbers,Hr.DataType.Wrong)}`}return T.nil}function i(){if(s.validateSchema){let u=t.scopeValue("validate$data",{ref:s.validateSchema});return (0, T._)`!${u}(${r})`}return T.nil}}subschema(t,r){let n=(0, ws.getSubschema)(this.it,t);(0, ws.extendSubschemaData)(n,this.it,t),(0, ws.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=Je.mergeEvaluated.props(s,t.props,n.props,r)),n.items!==true&&t.items!==void 0&&(n.items=Je.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,T.Name)),true}};nt.KeywordCxt=zr;function di(e,t,r,n){let s=new zr(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)*$/,kf=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function li(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=kf.exec(e);if(!c)throw new Error(`Invalid JSON-pointer: ${e}`);let l=+c[1];if(s=c[2],s==="#"){if(l>=t)throw new Error(u("property/index",l));return n[t-l]}if(l>t)throw new Error(u("data",l));if(o=r[t-l],!s)return o}let a=o,i=s.split("/");for(let c of i)c&&(o=(0, T._)`${o}${(0, T.getProperty)((0, Je.unescapeJsonPointer)(c))}`,a=(0, T._)`${a} && ${o}`);return a;function u(c,l){return `Cannot access ${c} ${l} levels up, current level is ${t}`}}nt.getData=li;});var Wr=x(Cs=>{Object.defineProperty(Cs,"__esModule",{value:true});var $s=class extends Error{constructor(t){super("validation failed"),this.errors=t,this.ajv=this.validation=true;}};Cs.default=$s;});var dr=x(Ts=>{Object.defineProperty(Ts,"__esModule",{value:true});var Es=ar(),xs=class extends Error{constructor(t,r,n,s){super(s||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0, Es.resolveUrl)(t,r,n),this.missingSchema=(0, Es.normalizeId)((0, Es.getFullPath)(t,this.missingRef));}};Ts.default=xs;});var Xr=x(Ae=>{Object.defineProperty(Ae,"__esModule",{value:true});Ae.resolveSchema=Ae.getCompilingSchema=Ae.resolveRef=Ae.compileSchema=Ae.SchemaEnv=void 0;var Oe=G(),bf=Wr(),St=Ue(),je=ar(),fi=H(),Sf=cr(),Dt=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=Dt;function Is(e){let t=pi.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:bf.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},l;try{this._compilations.add(e),(0,Sf.validateFunctionCode)(c),a.optimize(this.opts.code.optimize);let d=a.toString();l=`${a.scopeRefs(St.default.scope)}return ${d}`,this.opts.code.process&&(l=this.opts.code.process(l,e));let g=new Function(`${St.default.self}`,`${St.default.scope}`,l)(this,this.scope.get());if(this.scope.value(u,{ref:g}),g.errors=null,g.schema=e.schema,g.schemaEnv=e,e.$async&&(g.$async=!0),this.opts.code.source===!0&&(g.source={validateName:u,validateCode:d,scopeValues:a._values}),this.opts.unevaluated){let{props:f,items:p}=c;g.evaluated={props:f instanceof Oe.Name?void 0:f,items:p instanceof Oe.Name?void 0:p,dynamicProps:f instanceof Oe.Name,dynamicItems:p instanceof Oe.Name},g.source&&(g.source.evaluated=(0,Oe.stringify)(g.evaluated));}return e.validate=g,e}catch(d){throw delete e.validate,delete e.validateName,l&&this.logger.error("Error compiling schema, function code:",l),d}finally{this._compilations.delete(e);}}Ae.compileSchema=Is;function wf(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 Dt({schema:a,schemaId:i,root:e,baseId:t}));}if(o!==void 0)return e.refs[r]=_f.call(this,o)}Ae.resolveRef=wf;function _f(e){return (0, je.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:Is.call(this,e)}function pi(e){for(let t of this._compilations)if(Rf(t,e))return t}Ae.getCompilingSchema=pi;function Rf(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 As.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:As.call(this,r,i)}if(typeof a?.schema=="object"){if(a.validate||Is.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 Dt({schema:i,schemaId:u,root:e,baseId:s})}return As.call(this,r,a)}}Ae.resolveSchema=Yr;var Cf=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function As(e,{baseId:t,schema:r,root:n}){var s;if(((s=e.fragment)===null||s===void 0?void 0:s[0])!=="/")return;for(let i of e.fragment.slice(1).split("/")){if(typeof r=="boolean")return;let u=r[(0, fi.unescapeFragment)(i)];if(u===void 0)return;r=u;let c=typeof r=="object"&&r[this.opts.schemaId];!Cf.has(i)&&c&&(t=(0, je.resolveUrl)(this.opts.uriResolver,t,c));}let o;if(typeof r!="boolean"&&r.$ref&&!(0, fi.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 Dt({schema:r,schemaId:a,root:n,baseId:t}),o.schema!==o.root.schema)return o}});var mi=x((Uy,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 Os=x((Jy,vi)=>{var xf=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),gi=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 Ps(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 hi(e){return e.length=0,true}function Af(e,t,r){if(e.length){let n=Ps(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=hi;}else {s.push(c);continue}}return s.length&&(i===hi?r.zone=s.join(""):a?n.push(s.join("")):n.push(Ps(s))),r.address=n.join(""),r}function yi(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(!gi(r)){let n=yi(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}vi.exports={nonSimpleDomain:Tf,recomposeAuthority:Nf,normalizeComponentEncoding:jf,removeDotSegments:Of,isIPv4:gi,isUUID:xf,normalizeIPv6:yi,stringArrayToHexStripped:Ps};});var _i=x((Hy,wi)=>{var{isUUID:qf}=Os(),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 js(e){return e.secure===true?true:e.secure===false?false:e.scheme?e.scheme.length===3&&(e.scheme[0]==="w"||e.scheme[0]==="W")&&(e.scheme[1]==="s"||e.scheme[1]==="S")&&(e.scheme[2]==="s"||e.scheme[2]==="S"):false}function ki(e){return e.host||(e.error=e.error||"HTTP URIs must have a host."),e}function bi(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=js(e),e.resourceName=(e.path||"/")+(e.query?"?"+e.query:""),e.path=void 0,e.query=void 0,e}function Vf(e){if((e.port===(js(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=Ns(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=Ns(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 Si={scheme:"http",domainHost:true,parse:ki,serialize:bi},Jf={scheme:"https",domainHost:Si.domainHost,parse:ki,serialize:bi},Qr={scheme:"ws",domainHost:true,parse:Lf,serialize:Vf},Hf={scheme:"wss",domainHost:Qr.domainHost,parse:Qr.parse,serialize:Qr.serialize},zf={scheme:"urn",parse:Bf,serialize:Gf,skipNormalize:true},Wf={scheme:"urn:uuid",parse:Kf,serialize:Uf,skipNormalize:true},Zr={http:Si,https:Jf,ws:Qr,wss:Hf,urn:zf,"urn:uuid":Wf};Object.setPrototypeOf(Zr,null);function Ns(e){return e&&(Zr[e]||Zr[e.toLowerCase()])||void 0}wi.exports={wsIsSecure:js,SCHEMES:Zr,isValidSchemeName:Mf,getSchemeHandler:Ns};});var Ci=x((zy,tn)=>{var{normalizeIPv6:Yf,removeDotSegments:lr,recomposeAuthority:Xf,normalizeComponentEncoding:en,isIPv4:Qf,nonSimpleDomain:Zf}=Os(),{SCHEMES:ep,getSchemeHandler:Ri}=_i();function tp(e,t){return typeof e=="string"?e=Le(He(e,t),t):typeof e=="object"&&(e=He(Le(e,t),t)),e}function rp(e,t,r){let n=r?Object.assign({scheme:"null"},r):{scheme:"null"},s=$i(He(e,n),He(t,n),n,true);return n.skipEscape=true,Le(s,n)}function $i(e,t,r,n){let s={};return n||(e=He(Le(e,r),r),t=He(Le(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=Le(en(He(e,r),true),{...r,skipEscape:true})):typeof e=="object"&&(e=Le(en(e,true),{...r,skipEscape:true})),typeof t=="string"?(t=unescape(t),t=Le(en(He(t,r),true),{...r,skipEscape:true})):typeof t=="object"&&(t=Le(en(t,true),{...r,skipEscape:true})),e.toLowerCase()===t.toLowerCase()}function Le(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=Ri(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 He(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=Ri(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 qs={SCHEMES:ep,normalize:tp,resolve:rp,resolveComponent:$i,equal:np,serialize:Le,parse:He};tn.exports=qs;tn.exports.default=qs;tn.exports.fastUri=qs;});var xi=x(Ds=>{Object.defineProperty(Ds,"__esModule",{value:true});var Ei=Ci();Ei.code='require("ajv/dist/runtime/uri").default';Ds.default=Ei;});var qi=x(de=>{Object.defineProperty(de,"__esModule",{value:true});de.CodeGen=de.Name=de.nil=de.stringify=de.str=de._=de.KeywordCxt=void 0;var op=cr();Object.defineProperty(de,"KeywordCxt",{enumerable:true,get:function(){return op.KeywordCxt}});var Ft=G();Object.defineProperty(de,"_",{enumerable:true,get:function(){return Ft._}});Object.defineProperty(de,"str",{enumerable:true,get:function(){return Ft.str}});Object.defineProperty(de,"stringify",{enumerable:true,get:function(){return Ft.stringify}});Object.defineProperty(de,"nil",{enumerable:true,get:function(){return Ft.nil}});Object.defineProperty(de,"Name",{enumerable:true,get:function(){return Ft.Name}});Object.defineProperty(de,"CodeGen",{enumerable:true,get:function(){return Ft.CodeGen}});var ap=Wr(),Oi=dr(),ip=fs(),fr=Xr(),up=G(),pr=ar(),rn=or(),Ms=H(),Ti=mi(),cp=xi(),ji=(e,t)=>new RegExp(e,t);ji.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.'},Ai=200;function mp(e){var t,r,n,s,o,a,i,u,c,l,d,y,g,f,p,b,h,m,v,w,S,$,_,C,N;let q=e.strict,F=(t=e.code)===null||t===void 0?void 0:t.optimize,re=F===true||F===void 0?1:F||0,U=(n=(r=e.code)===null||r===void 0?void 0:r.regExp)!==null&&n!==void 0?n:ji,ce=(s=e.uriResolver)!==null&&s!==void 0?s:cp.default;return {strictSchema:(a=(o=e.strictSchema)!==null&&o!==void 0?o:q)!==null&&a!==void 0?a:true,strictNumbers:(u=(i=e.strictNumbers)!==null&&i!==void 0?i:q)!==null&&u!==void 0?u:true,strictTypes:(l=(c=e.strictTypes)!==null&&c!==void 0?c:q)!==null&&l!==void 0?l:"log",strictTuples:(y=(d=e.strictTuples)!==null&&d!==void 0?d:q)!==null&&y!==void 0?y:"log",strictRequired:(f=(g=e.strictRequired)!==null&&g!==void 0?g:q)!==null&&f!==void 0?f:false,code:e.code?{...e.code,optimize:re,regExp:U}:{optimize:re,regExp:U},loopRequired:(p=e.loopRequired)!==null&&p!==void 0?p:Ai,loopEnum:(b=e.loopEnum)!==null&&b!==void 0?b:Ai,meta:(h=e.meta)!==null&&h!==void 0?h:true,messages:(m=e.messages)!==null&&m!==void 0?m:true,inlineRefs:(v=e.inlineRefs)!==null&&v!==void 0?v:true,schemaId:(w=e.schemaId)!==null&&w!==void 0?w:"$id",addUsedSchema:(S=e.addUsedSchema)!==null&&S!==void 0?S:true,validateSchema:($=e.validateSchema)!==null&&$!==void 0?$:true,validateFormats:(_=e.validateFormats)!==null&&_!==void 0?_:true,unicodeRegExp:(C=e.unicodeRegExp)!==null&&C!==void 0?C:true,int32range:(N=e.int32range)!==null&&N!==void 0?N:true,uriResolver:ce}}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=bp(t.logger);let s=t.validateFormats;t.validateFormats=false,this.RULES=(0, ip.getRules)(),Ii.call(this,fp,t,"NOT SUPPORTED"),Ii.call(this,pp,t,"DEPRECATED","warn"),this._metaOpts=vp.call(this),t.formats&&gp.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),t.keywords&&yp.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=Ti;n==="id"&&(s={...Ti},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(l,d){await o.call(this,l.$schema);let y=this._addSchema(l,d);return y.validate||a.call(this,y)}async function o(l){l&&!this.getSchema(l)&&await s.call(this,{$ref:l},true);}async function a(l){try{return this._compileSchemaEnv(l)}catch(d){if(!(d instanceof Oi.default))throw d;return i.call(this,d),await u.call(this,d.missingSchema),a.call(this,l)}}function i({missingSchema:l,missingRef:d}){if(this.refs[l])throw new Error(`AnySchema ${l} is loaded but ${d} cannot be resolved`)}async function u(l){let d=await c.call(this,l);this.refs[l]||await o.call(this,d.$schema),this.refs[l]||this.addSchema(d,l,r);}async function c(l){let d=this._loading[l];if(d)return d;try{return await(this._loading[l]=n(l))}finally{delete this._loading[l];}}}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=Pi.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=Pi.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(wp.call(this,n,r),!r)return (0, Ms.eachItem)(n,o=>Fs.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, Ms.eachItem)(n,s.type.length===0?o=>Fs.call(this,o,s):o=>s.type.forEach(a=>Fs.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,l=a[i];c&&l&&(a[i]=Ni(l));}}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=Oi.default;de.default=mr;function Ii(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 Pi(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 gp(){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 kp={log(){},warn(){},error(){}};function bp(e){if(e===false)return kp;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 Sp=/^[a-z_$][a-z0-9_$:-]*$/i;function wp(e,t){let{RULES:r}=this;if((0, Ms.eachItem)(e,n=>{if(r.keywords[n])throw new Error(`Keyword ${n} is already defined`);if(!Sp.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 Fs(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=Ni(t)),e.validateSchema=this.compile(t,true));}var $p={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function Ni(e){return {anyOf:[e,$p]}}});var Di=x(Ls=>{Object.defineProperty(Ls,"__esModule",{value:true});var Cp={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};Ls.default=Cp;});var Vi=x(wt=>{Object.defineProperty(wt,"__esModule",{value:true});wt.callRef=wt.getValidate=void 0;var Ep=dr(),Fi=Te(),Se=G(),Mt=Ue(),Mi=Xr(),nn=H(),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 d();let l=Mi.resolveRef.call(u,c,s,r);if(l===void 0)throw new Ep.default(n.opts.uriResolver,s,r);if(l instanceof Mi.SchemaEnv)return y(l);return g(l);function d(){if(o===c)return sn(e,a,o,o.$async);let f=t.scopeValue("root",{ref:c});return sn(e,(0, Se._)`${f}.validate`,c,c.$async)}function y(f){let p=Li(e,f);sn(e,p,f,f.$async);}function g(f){let p=t.scopeValue("schema",i.code.source===true?{ref:f,code:(0, Se.stringify)(f)}:{ref:f}),b=t.name("valid"),h=e.subschema({schema:f,dataTypes:[],schemaPath:Se.nil,topSchemaRef:p,errSchemaPath:r},b);e.mergeEvaluated(h),e.ok(b);}}};function Li(e,t){let{gen:r}=e;return t.validate?r.scopeValue("validate",{ref:t.validate}):(0, Se._)`${r.scopeValue("wrapper",{ref:t})}.validate`}wt.getValidate=Li;function sn(e,t,r,n){let{gen:s,it:o}=e,{allErrors:a,schemaEnv:i,opts:u}=o,c=u.passContext?Mt.default.this:Se.nil;n?l():d();function l(){if(!i.$async)throw new Error("async schema referenced by sync schema");let f=s.let("valid");s.try(()=>{s.code((0, Se._)`await ${(0, Fi.callValidateCode)(e,t,c)}`),g(t),a||s.assign(f,true);},p=>{s.if((0, Se._)`!(${p} instanceof ${o.ValidationError})`,()=>s.throw(p)),y(p),a||s.assign(f,false);}),e.ok(f);}function d(){e.result((0, Fi.callValidateCode)(e,t,c),()=>g(t),()=>y(t));}function y(f){let p=(0, Se._)`${f}.errors`;s.assign(Mt.default.vErrors,(0, Se._)`${Mt.default.vErrors} === null ? ${p} : ${Mt.default.vErrors}.concat(${p})`),s.assign(Mt.default.errors,(0, Se._)`${Mt.default.vErrors}.length`);}function g(f){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 h=s.var("props",(0, Se._)`${f}.evaluated.props`);o.props=nn.mergeEvaluated.props(s,h,o.props,Se.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 h=s.var("items",(0, Se._)`${f}.evaluated.items`);o.items=nn.mergeEvaluated.items(s,h,o.items,Se.Name);}}}wt.callRef=sn;wt.default=xp;});var Bi=x(Vs=>{Object.defineProperty(Vs,"__esModule",{value:true});var Tp=Di(),Ap=Vi(),Ip=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",Tp.default,Ap.default];Vs.default=Ip;});var Gi=x(Bs=>{Object.defineProperty(Bs,"__esModule",{value:true});var on=G(),st=on.operators,an={maximum:{okStr:"<=",ok:st.LTE,fail:st.GT},minimum:{okStr:">=",ok:st.GTE,fail:st.LT},exclusiveMaximum:{okStr:"<",ok:st.LT,fail:st.GTE},exclusiveMinimum:{okStr:">",ok:st.GT,fail:st.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})`);}};Bs.default=Op;});var Ki=x(Gs=>{Object.defineProperty(Gs,"__esModule",{value:true});var hr=G(),jp={message:({schemaCode:e})=>(0, hr.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0, hr._)`{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, hr._)`Math.abs(Math.round(${a}) - ${a}) > 1e-${o}`:(0, hr._)`${a} !== parseInt(${a})`;e.fail$data((0, hr._)`(${n} === 0 || (${a} = ${r}/${n}, ${i}))`);}};Gs.default=Np;});var Ji=x(Ks=>{Object.defineProperty(Ks,"__esModule",{value:true});function Ui(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}Ks.default=Ui;Ui.code='require("ajv/dist/runtime/ucs2length").default';});var Hi=x(Us=>{Object.defineProperty(Us,"__esModule",{value:true});var _t=G(),qp=H(),Dp=Ji(),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}`);}};Us.default=Mp;});var zi=x(Js=>{Object.defineProperty(Js,"__esModule",{value:true});var Lp=Te(),Vp=H(),Lt=G(),Bp={message:({schemaCode:e})=>(0, Lt.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0, Lt._)`{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, Lt._)`new RegExp`:(0, Vp.useFunc)(t,u),l=t.let("valid");t.try(()=>t.assign(l,(0, Lt._)`${c}(${o}, ${i}).test(${r})`),()=>t.assign(l,false)),e.fail$data((0, Lt._)`!${l}`);}else {let u=(0, Lp.usePattern)(e,s);e.fail$data((0, Lt._)`!${u}.test(${r})`);}}};Js.default=Gp;});var Wi=x(Hs=>{Object.defineProperty(Hs,"__esModule",{value:true});var gr=G(),Kp={message({keyword:e,schemaCode:t}){let r=e==="maxProperties"?"more":"fewer";return (0, gr.str)`must NOT have ${r} than ${t} properties`},params:({schemaCode:e})=>(0, gr._)`{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"?gr.operators.GT:gr.operators.LT;e.fail$data((0, gr._)`Object.keys(${r}).length ${s} ${n}`);}};Hs.default=Up;});var Yi=x(zs=>{Object.defineProperty(zs,"__esModule",{value:true});var yr=Te(),vr=G(),Jp=H(),Hp={message:({params:{missingProperty:e}})=>(0, vr.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0, vr._)`{missingProperty: ${e}}`},zp={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():l(),i.strictRequired){let g=e.parentSchema.properties,{definedProperties:f}=e.it;for(let p of r)if(g?.[p]===void 0&&!f.has(p)){let b=a.schemaEnv.baseId+a.errSchemaPath,h=`required property "${p}" is not defined at "${b}" (strictRequired)`;(0, Jp.checkStrictMode)(a,h,a.opts.strictRequired);}}function c(){if(u||o)e.block$data(vr.nil,d);else for(let g of r)(0, yr.checkReportMissingProp)(e,g);}function l(){let g=t.let("missing");if(u||o){let f=t.let("valid",true);e.block$data(f,()=>y(g,f)),e.ok(f);}else t.if((0, yr.checkMissingProp)(e,r,g)),(0, yr.reportMissingProp)(e,g),t.else();}function d(){t.forOf("prop",n,g=>{e.setParams({missingProperty:g}),t.if((0, yr.noPropertyInData)(t,s,g,i.ownProperties),()=>e.error());});}function y(g,f){e.setParams({missingProperty:g}),t.forOf(g,n,()=>{t.assign(f,(0, yr.propertyInData)(t,s,g,i.ownProperties)),t.if((0, vr.not)(f),()=>{e.error(),t.break();});},vr.nil);}}};zs.default=zp;});var Xi=x(Ws=>{Object.defineProperty(Ws,"__esModule",{value:true});var kr=G(),Wp={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}}`},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"?kr.operators.GT:kr.operators.LT;e.fail$data((0, kr._)`${r}.length ${s} ${n}`);}};Ws.default=Yp;});var un=x(Ys=>{Object.defineProperty(Ys,"__esModule",{value:true});var Qi=bs();Qi.code='require("ajv/dist/runtime/equal").default';Ys.default=Qi;});var Zi=x(Qs=>{Object.defineProperty(Qs,"__esModule",{value:true});var Xs=or(),le=G(),Xp=H(),Qp=un(),Zp={message:({params:{i:e,j:t}})=>(0, le.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0, le._)`{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, Xs.getSchemaTypes)(o.items):[];e.block$data(u,l,(0, le._)`${a} === false`),e.ok(u);function l(){let f=t.let("i",(0, le._)`${r}.length`),p=t.let("j");e.setParams({i:f,j:p}),t.assign(u,true),t.if((0, le._)`${f} > 1`,()=>(d()?y:g)(f,p));}function d(){return c.length>0&&!c.some(f=>f==="object"||f==="array")}function y(f,p){let b=t.name("item"),h=(0, Xs.checkDataTypes)(c,b,i.opts.strictNumbers,Xs.DataType.Wrong),m=t.const("indices",(0, le._)`{}`);t.for((0, le._)`;${f}--;`,()=>{t.let(b,(0, le._)`${r}[${f}]`),t.if(h,(0, le._)`continue`),c.length>1&&t.if((0, le._)`typeof ${b} == "string"`,(0, le._)`${b} += "_"`),t.if((0, le._)`typeof ${m}[${b}] == "number"`,()=>{t.assign(p,(0, le._)`${m}[${b}]`),e.error(),t.assign(u,false).break();}).code((0, le._)`${m}[${b}] = ${f}`);});}function g(f,p){let b=(0, Xp.useFunc)(t,Qp.default),h=t.name("outer");t.label(h).for((0, le._)`;${f}--;`,()=>t.for((0, le._)`${p} = ${f}; ${p}--;`,()=>t.if((0, le._)`${b}(${r}[${f}], ${r}[${p}])`,()=>{e.error(),t.assign(u,false).break(h);})));}}};Qs.default=em;});var eu=x(eo=>{Object.defineProperty(eo,"__esModule",{value:true});var Zs=G(),tm=H(),rm=un(),nm={message:"must be equal to constant",params:({schemaCode:e})=>(0, Zs._)`{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, Zs._)`!${(0, tm.useFunc)(t,rm.default)}(${r}, ${s})`):e.fail((0, Zs._)`${o} !== ${r}`);}};eo.default=sm;});var tu=x(to=>{Object.defineProperty(to,"__esModule",{value:true});var br=G(),om=H(),am=un(),im={message:"must be equal to one of the allowed values",params:({schemaCode:e})=>(0, br._)`{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)),l;if(i||n)l=t.let("valid"),e.block$data(l,d);else {if(!Array.isArray(s))throw new Error("ajv implementation error");let g=t.const("vSchema",o);l=(0, br.or)(...s.map((f,p)=>y(g,p)));}e.pass(l);function d(){t.assign(l,false),t.forOf("v",o,g=>t.if((0, br._)`${c()}(${r}, ${g})`,()=>t.assign(l,true).break()));}function y(g,f){let p=s[f];return typeof p=="object"&&p!==null?(0, br._)`${c()}(${r}, ${g}[${f}])`:(0, br._)`${r} === ${p}`}}};to.default=um;});var ru=x(ro=>{Object.defineProperty(ro,"__esModule",{value:true});var cm=Gi(),dm=Ki(),lm=Hi(),fm=zi(),pm=Wi(),mm=Yi(),hm=Xi(),gm=Zi(),ym=eu(),vm=tu(),km=[cm.default,dm.default,lm.default,fm.default,pm.default,mm.default,hm.default,gm.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},ym.default,vm.default];ro.default=km;});var so=x(Sr=>{Object.defineProperty(Sr,"__esModule",{value:true});Sr.validateAdditionalItems=void 0;var Rt=G(),no=H(),bm={message:({params:{len:e}})=>(0, Rt.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0, Rt._)`{limit: ${e}}`},Sm={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:bm,code(e){let{parentSchema:t,it:r}=e,{items:n}=t;if(!Array.isArray(n)){(0, no.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}nu(e,n);}};function nu(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, no.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,l=>{e.subschema({keyword:o,dataProp:l,dataPropType:no.Type.Num},c),a.allErrors||r.if((0, Rt.not)(c),()=>r.break());});}}Sr.validateAdditionalItems=nu;Sr.default=Sm;});var oo=x(wr=>{Object.defineProperty(wr,"__esModule",{value:true});wr.validateTuple=void 0;var su=G(),cn=H(),wm=Te(),_m={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){let{schema:t,it:r}=e;if(Array.isArray(t))return ou(e,"additionalItems",t);r.items=true,!(0, cn.alwaysValidSchema)(r,t)&&e.ok((0, wm.validateArray)(e));}};function ou(e,t,r=e.schema){let{gen:n,parentSchema:s,data:o,keyword:a,it:i}=e;l(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, su._)`${o}.length`);r.forEach((d,y)=>{(0, cn.alwaysValidSchema)(i,d)||(n.if((0, su._)`${c} > ${y}`,()=>e.subschema({keyword:a,schemaProp:y,dataProp:y},u)),e.ok(u));});function l(d){let{opts:y,errSchemaPath:g}=i,f=r.length,p=f===d.minItems&&(f===d.maxItems||d[t]===false);if(y.strictTuples&&!p){let b=`"${a}" is ${f}-tuple, but minItems or maxItems/${t} are not specified or different at path "${g}"`;(0, cn.checkStrictMode)(i,b,y.strictTuples);}}}wr.validateTuple=ou;wr.default=_m;});var au=x(ao=>{Object.defineProperty(ao,"__esModule",{value:true});var Rm=oo(),$m={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:e=>(0, Rm.validateTuple)(e,"items")};ao.default=$m;});var uu=x(io=>{Object.defineProperty(io,"__esModule",{value:true});var iu=G(),Cm=H(),Em=Te(),xm=so(),Tm={message:({params:{len:e}})=>(0, iu.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0, iu._)`{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, Cm.alwaysValidSchema)(n,t)&&(s?(0, xm.validateAdditionalItems)(e,s):e.ok((0, Em.validateArray)(e)));}};io.default=Am;});var cu=x(uo=>{Object.defineProperty(uo,"__esModule",{value:true});var Ie=G(),dn=H(),Im={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}}`},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 l=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._)`${l} >= ${a}`;i!==void 0&&(p=(0, Ie._)`${p} && ${l} <= ${i}`),e.pass(p);return}o.items=true;let d=t.name("valid");i===void 0&&a===1?g(d,()=>t.if(d,()=>t.break())):a===0?(t.let(d,true),i!==void 0&&t.if((0, Ie._)`${s}.length > 0`,y)):(t.let(d,false),y()),e.result(d,()=>e.reset());function y(){let p=t.name("_valid"),b=t.let("count",0);g(p,()=>t.if(p,()=>f(b)));}function g(p,b){t.forRange("i",0,l,h=>{e.subschema({keyword:"contains",dataProp:h,dataPropType:dn.Type.Num,compositeRule:true},p),b();});}function f(p){t.code((0, Ie._)`${p}++`),i===void 0?t.if((0, Ie._)`${p} >= ${a}`,()=>t.assign(d,true).break()):(t.if((0, Ie._)`${p} > ${i}`,()=>t.assign(d,false).break()),a===1?t.assign(d,true):t.if((0, Ie._)`${p} >= ${a}`,()=>t.assign(d,true)));}}};uo.default=Pm;});var fu=x(Ve=>{Object.defineProperty(Ve,"__esModule",{value:true});Ve.validateSchemaDeps=Ve.validatePropertyDeps=Ve.error=void 0;var co=G(),Om=H(),_r=Te();Ve.error={message:({params:{property:e,depsCount:t,deps:r}})=>{let n=t===1?"property":"properties";return (0, co.str)`must have ${n} ${r} when property ${e} is present`},params:({params:{property:e,depsCount:t,deps:r,missingProperty:n}})=>(0, co._)`{property: ${e},
|
|
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 ms(e,t,r,n=jt.Correct){let s=n===jt.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===jt.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=ms;function hs(e,t,r,n){if(e.length===1)return ms(e[0],t,r,n);let s,o=(0, ja.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,ms(a,t,r,n));return s}me.checkDataTypes=hs;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 gs(e){let t=ml(e);(0, il.reportError)(t,pl);}me.reportTypeError=gs;function ml(e){let{gen:t,data:r,schema:n}=e,s=(0, ja.schemaRefOrVal)(e,n,"type");return {gen:t,keyword:"type",data:r,schema:n.type,schemaCode:s,schemaValue:s,parentSchema:n,params:{},it:e}}});var Fa=x(Ur=>{Object.defineProperty(Ur,"__esModule",{value:true});Ur.assignDefaults=void 0;var Nt=G(),hl=H();function gl(e,t){let{properties:r,items:n}=e.schema;if(t==="object"&&r)for(let s in r)Da(e,s,r[s].default);else t==="array"&&Array.isArray(n)&&n.forEach((s,o)=>Da(e,o,s.default));}Ur.assignDefaults=gl;function Da(e,t,r){let{gen:n,compositeRule:s,data:o,opts:a}=e;if(r===void 0)return;let i=(0, Nt._)`${o}${(0, Nt.getProperty)(t)}`;if(s){(0, hl.checkStrictMode)(e,`default is ignored for: ${i}`);return}let u=(0, Nt._)`${i} === undefined`;a.useDefaults==="empty"&&(u=(0, Nt._)`${u} || ${i} === null || ${i} === ""`),n.if(u,(0, Nt._)`${i} = ${(0, Nt.stringify)(r)}`);}});var Te=x(X=>{Object.defineProperty(X,"__esModule",{value:true});X.validateUnion=X.validateArray=X.usePattern=X.callValidateCode=X.schemaProperties=X.allSchemaProperties=X.noPropertyInData=X.propertyInData=X.isOwnProperty=X.hasPropFunc=X.reportMissingProp=X.checkMissingProp=X.checkReportMissingProp=void 0;var ne=G(),ys=H(),et=Ue(),yl=H();function vl(e,t){let{gen:r,data:n,it:s}=e;r.if(bs(r,n,t,s.opts.ownProperties),()=>{e.setParams({missingProperty:(0, ne._)`${t}`},true),e.error();});}X.checkReportMissingProp=vl;function bl({gen:e,data:t,it:{opts:r}},n,s){return (0, ne.or)(...n.map(o=>(0, ne.and)(bs(e,t,o,r.ownProperties),(0, ne._)`${s} = ${o}`)))}X.checkMissingProp=bl;function kl(e,t){e.setParams({missingProperty:t},true),e.error();}X.reportMissingProp=kl;function Ma(e){return e.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0, ne._)`Object.prototype.hasOwnProperty`})}X.hasPropFunc=Ma;function vs(e,t,r){return (0, ne._)`${Ma(e)}.call(${t}, ${r})`}X.isOwnProperty=vs;function Sl(e,t,r,n){let s=(0, ne._)`${t}${(0, ne.getProperty)(r)} !== undefined`;return n?(0, ne._)`${s} && ${vs(e,t,r)}`:s}X.propertyInData=Sl;function bs(e,t,r,n){let s=(0, ne._)`${t}${(0, ne.getProperty)(r)} === undefined`;return n?(0, ne.or)(s,(0, ne.not)(vs(e,t,r))):s}X.noPropertyInData=bs;function La(e){return e?Object.keys(e).filter(t=>t!=="__proto__"):[]}X.allSchemaProperties=La;function wl(e,t){return La(t).filter(r=>!(0, ys.alwaysValidSchema)(e,t[r]))}X.schemaProperties=wl;function _l({schemaCode:e,data:t,it:{gen:r,topSchemaRef:n,schemaPath:s,errorPath:o},it:a},i,u,c){let l=c?(0, ne._)`${e}, ${t}, ${n}${s}`:t,d=[[et.default.instancePath,(0, ne.strConcat)(et.default.instancePath,o)],[et.default.parentData,a.parentData],[et.default.parentDataProperty,a.parentDataProperty],[et.default.rootData,et.default.rootData]];a.opts.dynamicRef&&d.push([et.default.dynamicAnchors,et.default.dynamicAnchors]);let y=(0, ne._)`${l}, ${r.object(...d)}`;return u!==ne.nil?(0, ne._)`${i}.call(${u}, ${y})`:(0, ne._)`${i}(${y})`}X.callValidateCode=_l;var Rl=(0, ne._)`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, ne._)`${s.code==="new RegExp"?Rl:(0, yl.useFunc)(e,s)}(${r}, ${n})`})}X.usePattern=$l;function Cl(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, ne._)`${r}.length`);t.forRange("i",0,u,c=>{e.subschema({keyword:n,dataProp:c,dataPropType:ys.Type.Num},o),t.if((0, ne.not)(o),i);});}}X.validateArray=Cl;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, ys.alwaysValidSchema)(s,u))&&!s.opts.unevaluated)return;let a=t.let("valid",false),i=t.name("_valid");t.block(()=>r.forEach((u,c)=>{let l=e.subschema({keyword:n,schemaProp:c,compositeRule:true},i);t.assign(a,(0, ne._)`${a} || ${i}`),e.mergeValidEvaluated(l,i)||t.if((0, ne.not)(a));})),e.result(a,()=>e.reset(),()=>e.error(true));}X.validateUnion=El;});var Ga=x(Fe=>{Object.defineProperty(Fe,"__esModule",{value:true});Fe.validateKeywordUsage=Fe.validSchemaType=Fe.funcKeywordCode=Fe.macroKeywordCode=void 0;var ye=G(),kt=Ue(),xl=Te(),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=Ba(r,n,i);a.opts.validateSchema!==false&&a.self.validateSchema(i,true);let c=r.name("valid");e.subschema({schema:i,schemaPath:ye.nil,errSchemaPath:`${a.errSchemaPath}/${n}`,topSchemaRef:u,compositeRule:true},c),e.pass(c,()=>e.error(true));}Fe.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,l=Ba(n,s,c),d=n.let("valid");e.block$data(d,y),e.ok((r=t.valid)!==null&&r!==void 0?r:d);function y(){if(t.errors===false)p(),t.modifying&&Va(e),k(()=>e.error());else {let h=t.async?g():f();t.modifying&&Va(e),k(()=>Pl(e,h));}}function g(){let h=n.let("ruleErrs",null);return n.try(()=>p((0, ye._)`await `),m=>n.assign(d,false).if((0, ye._)`${m} instanceof ${u.ValidationError}`,()=>n.assign(h,(0, ye._)`${m}.errors`),()=>n.throw(m))),h}function f(){let h=(0, ye._)`${l}.errors`;return n.assign(h,null),p(ye.nil),h}function p(h=t.async?(0, ye._)`await `:ye.nil){let m=u.opts.passContext?kt.default.this:kt.default.self,v=!("compile"in t&&!i||t.schema===false);n.assign(d,(0, ye._)`${h}${(0, xl.callValidateCode)(e,l,m,v)}`,t.modifying);}function k(h){var m;n.if((0, ye.not)((m=t.valid)!==null&&m!==void 0?m:d),h);}}Fe.funcKeywordCode=Il;function Va(e){let{gen:t,data:r,it:n}=e;t.if(n.parentData,()=>t.assign(r,(0, ye._)`${n.parentData}[${n.parentDataProperty}]`));}function Pl(e,t){let{gen:r}=e;r.if((0, ye._)`Array.isArray(${t})`,()=>{r.assign(kt.default.vErrors,(0, ye._)`${kt.default.vErrors} === null ? ${t} : ${kt.default.vErrors}.concat(${t})`).assign(kt.default.errors,(0, ye._)`${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 Ba(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, ye.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")}Fe.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)}}Fe.validateKeywordUsage=Nl;});var Ua=x(tt=>{Object.defineProperty(tt,"__esModule",{value:true});tt.extendSubschemaMode=tt.extendSubschemaData=tt.getSubschema=void 0;var Me=G(),Ka=H();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, Me._)`${e.schemaPath}${(0, Me.getProperty)(t)}`,errSchemaPath:`${e.errSchemaPath}/${t}`}:{schema:i[r],schemaPath:(0, Me._)`${e.schemaPath}${(0, Me.getProperty)(t)}${(0, Me.getProperty)(r)}`,errSchemaPath:`${e.errSchemaPath}/${t}/${(0, Ka.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')}tt.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:l,opts:d}=t,y=i.let("data",(0, Me._)`${t.data}${(0, Me.getProperty)(r)}`,true);u(y),e.errorPath=(0, Me.str)`${c}${(0, Ka.getErrorPath)(r,n,d.jsPropertySyntax)}`,e.parentDataProperty=(0, Me._)`${r}`,e.dataPathArr=[...l,e.parentDataProperty];}if(s!==void 0){let c=s instanceof Me.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];}}tt.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;}tt.extendSubschemaMode=Fl;});var ks=x((Fy,Ja)=>{Ja.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 za=x((My,Ha)=>{var rt=Ha.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);};rt.keywords={additionalItems:true,items:true,contains:true,additionalProperties:true,propertyNames:true,not:true,if:true,then:true,else:true};rt.arrayKeywords={items:true,allOf:true,anyOf:true,oneOf:true};rt.propsKeywords={$defs:true,definitions:true,properties:true,patternProperties:true,dependencies:true};rt.skipKeywords={default:true,enum:true,const:true,required:true,maximum:true,minimum:true,exclusiveMaximum:true,exclusiveMinimum:true,multipleOf:true,maxLength:true,minLength:true,pattern:true,format:true,maxItems:true,minItems:true,uniqueItems:true,maxProperties:true,minProperties:true};function 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 l in n){var d=n[l];if(Array.isArray(d)){if(l in rt.arrayKeywords)for(var y=0;y<d.length;y++)Jr(e,t,r,d[y],s+"/"+l+"/"+y,o,s,l,n,y);}else if(l in rt.propsKeywords){if(d&&typeof d=="object")for(var g in d)Jr(e,t,r,d[g],s+"/"+l+"/"+Ml(g),o,s,l,n,g);}else (l in rt.keywords||e.allKeys&&!(l in rt.skipKeywords))&&Jr(e,t,r,d,s+"/"+l,o,s,l,n);}r(n,s,o,a,i,u,c);}}function Ml(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 Ll=H(),Vl=ks(),Bl=za(),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?!Ss(e):t?Wa(e)<=t:false}ke.inlineRef=Kl;var Ul=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function Ss(e){for(let t in e){if(Ul.has(t))return true;let r=e[t];if(Array.isArray(r)&&r.some(Ss)||typeof r=="object"&&Ss(r))return true}return false}function Wa(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+=Wa(n)),t===1/0))return 1/0}return t}function Ya(e,t="",r){r!==false&&(t=qt(t));let n=e.parse(t);return Xa(e,n)}ke.getFullPath=Ya;function Xa(e,t){return e.serialize(t).split("#")[0]+"#"}ke._getFullPath=Xa;var Jl=/#\/?$/;function qt(e){return e?e.replace(Jl,""):""}ke.normalizeId=qt;function Hl(e,t,r){return r=qt(r),e.resolve(t,r)}ke.resolveUrl=Hl;var zl=/^[a-z_][-a-z0-9._]*$/i;function Wl(e,t){if(typeof e=="boolean")return {};let{schemaId:r,uriResolver:n}=this.opts,s=qt(e[r]||t),o={"":s},a=Ya(n,s,false),i={},u=new Set;return Bl(e,{allKeys:true},(d,y,g,f)=>{if(f===void 0)return;let p=a+y,k=o[f];typeof d[r]=="string"&&(k=h.call(this,d[r])),m.call(this,d.$anchor),m.call(this,d.$dynamicAnchor),o[y]=k;function h(v){let w=this.opts.uriResolver.resolve;if(v=qt(k?w(k,v):v),u.has(v))throw l(v);u.add(v);let S=this.refs[v];return typeof S=="string"&&(S=this.refs[S]),typeof S=="object"?c(d,S.schema,v):v!==qt(p)&&(v[0]==="#"?(c(d,i[v],v),i[v]=d):this.refs[v]=p),v}function m(v){if(typeof v=="string"){if(!zl.test(v))throw new Error(`invalid anchor "${v}"`);h.call(this,`#${v}`);}}}),i;function c(d,y,g){if(y!==void 0&&!Vl(d,y))throw l(g)}function l(d){return new Error(`reference "${d}" resolves to more than one schema`)}}ke.getSchemaRefs=Wl;});var cr=x(nt=>{Object.defineProperty(nt,"__esModule",{value:true});nt.getData=nt.KeywordCxt=nt.validateFunctionCode=void 0;var ri=Ia(),Qa=or(),_s=ps(),Hr=or(),Yl=Fa(),ur=Ga(),ws=Ua(),T=G(),O=Ue(),Xl=ar(),Je=H(),ir=sr();function Ql(e){if(oi(e)&&(ai(e),si(e))){tf(e);return}ni(e,()=>(0, ri.topBoolOrEmptySchema)(e));}nt.validateFunctionCode=Ql;function ni({gen:e,validateName:t,schema:r,schemaEnv:n,opts:s},o){s.code.es5?e.func(t,(0, T._)`${O.default.data}, ${O.default.valCxt}`,n.$async,()=>{e.code((0, T._)`"use strict"; ${Za(r,s)}`),ef(e,s),e.code(o);}):e.func(t,(0, T._)`${O.default.data}, ${Zl(s)}`,n.$async,()=>e.code(Za(r,s)).code(o));}function Zl(e){return (0, T._)`{${O.default.instancePath}="", ${O.default.parentData}, ${O.default.parentDataProperty}, ${O.default.rootData}=${O.default.data}${e.dynamicRef?(0, T._)`, ${O.default.dynamicAnchors}={}`:T.nil}}={}`}function ef(e,t){e.if(O.default.valCxt,()=>{e.var(O.default.instancePath,(0, T._)`${O.default.valCxt}.${O.default.instancePath}`),e.var(O.default.parentData,(0, T._)`${O.default.valCxt}.${O.default.parentData}`),e.var(O.default.parentDataProperty,(0, T._)`${O.default.valCxt}.${O.default.parentDataProperty}`),e.var(O.default.rootData,(0, T._)`${O.default.valCxt}.${O.default.rootData}`),t.dynamicRef&&e.var(O.default.dynamicAnchors,(0, T._)`${O.default.valCxt}.${O.default.dynamicAnchors}`);},()=>{e.var(O.default.instancePath,(0, T._)`""`),e.var(O.default.parentData,(0, T._)`undefined`),e.var(O.default.parentDataProperty,(0, T._)`undefined`),e.var(O.default.rootData,O.default.data),t.dynamicRef&&e.var(O.default.dynamicAnchors,(0, T._)`{}`);});}function tf(e){let{schema:t,opts:r,gen:n}=e;ni(e,()=>{r.$comment&&t.$comment&&ui(e),af(e),n.let(O.default.vErrors,null),n.let(O.default.errors,0),r.unevaluated&&rf(e),ii(e),df(e);});}function rf(e){let{gen:t,validateName:r}=e;e.evaluated=t.const("evaluated",(0, T._)`${r}.evaluated`),t.if((0, T._)`${e.evaluated}.dynamicProps`,()=>t.assign((0, T._)`${e.evaluated}.props`,(0, T._)`undefined`)),t.if((0, T._)`${e.evaluated}.dynamicItems`,()=>t.assign((0, T._)`${e.evaluated}.items`,(0, T._)`undefined`));}function Za(e,t){let r=typeof e=="object"&&e[t.schemaId];return r&&(t.code.source||t.code.process)?(0, T._)`/*# sourceURL=${r} */`:T.nil}function nf(e,t){if(oi(e)&&(ai(e),si(e))){sf(e,t);return}(0, ri.boolOrEmptySchema)(e,t);}function si({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 oi(e){return typeof e.schema!="boolean"}function sf(e,t){let{schema:r,gen:n,opts:s}=e;s.$comment&&r.$comment&&ui(e),uf(e),cf(e);let o=n.const("_errs",O.default.errors);ii(e,o),n.var(t,(0, T._)`${o} === ${O.default.errors}`);}function ai(e){(0, Je.checkUnknownRules)(e),of(e);}function ii(e,t){if(e.opts.jtd)return ei(e,[],false,t);let r=(0, Qa.getSchemaTypes)(e.schema),n=(0, Qa.coerceAndCheckDataType)(e,r);ei(e,r,!n,t);}function of(e){let{schema:t,errSchemaPath:r,opts:n,self:s}=e;t.$ref&&n.ignoreKeywordsWithRef&&(0, Je.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, Je.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 ui({gen:e,schemaEnv:t,schema:r,errSchemaPath:n,opts:s}){let o=r.$comment;if(s.$comment===true)e.code((0, T._)`${O.default.self}.logger.log(${o})`);else if(typeof s.$comment=="function"){let a=(0, T.str)`${n}/$comment`,i=e.scopeValue("root",{ref:t.root});e.code((0, T._)`${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, T._)`${O.default.errors} === 0`,()=>t.return(O.default.data),()=>t.throw((0, T._)`new ${s}(${O.default.vErrors})`)):(t.assign((0, T._)`${n}.errors`,O.default.vErrors),o.unevaluated&&lf(e),t.return((0, T._)`${O.default.errors} === 0`));}function lf({gen:e,evaluated:t,props:r,items:n}){r instanceof T.Name&&e.assign((0, T._)`${t}.props`,r),n instanceof T.Name&&e.assign((0, T._)`${t}.items`,n);}function ei(e,t,r,n){let{gen:s,schema:o,data:a,allErrors:i,opts:u,self:c}=e,{RULES:l}=c;if(o.$ref&&(u.ignoreKeywordsWithRef||!(0, Je.schemaHasRulesButRef)(o,l))){s.block(()=>di(e,"$ref",l.all.$ref.definition));return}u.jtd||ff(e,t),s.block(()=>{for(let y of l.rules)d(y);d(l.post);});function d(y){(0, _s.shouldUseGroup)(o,y)&&(y.type?(s.if((0, Hr.checkDataType)(y.type,a,u.strictNumbers)),ti(e,y),t.length===1&&t[0]===y.type&&r&&(s.else(),(0, Hr.reportTypeError)(e)),s.endIf()):ti(e,y),i||s.if((0, T._)`${O.default.errors} === ${n||0}`));}}function ti(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, _s.shouldUseRule)(n,o)&&di(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),hf(e,e.dataTypes));}function pf(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(r=>{ci(e.dataTypes,r)||Rs(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"))&&Rs(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, _s.shouldUseRule)(e.schema,s)){let{type:o}=s.definition;o.length&&!o.some(a=>gf(t,a))&&Rs(e,`missing type "${o.join(",")}" for keyword "${n}"`);}}}function gf(e,t){return e.includes(t)||t==="number"&&e.includes("integer")}function ci(e,t){return e.includes(t)||t==="integer"&&e.includes("number")}function yf(e,t){let r=[];for(let n of e.dataTypes)ci(t,n)?r.push(n):t.includes("integer")&&n==="number"&&r.push("integer");e.dataTypes=r;}function Rs(e,t){let r=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${r}" (strictTypes)`,(0, Je.checkStrictMode)(e,t,e.opts.strictTypes);}var zr=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, Je.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",li(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, T.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, T.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, T._)`${r} !== undefined && (${(0, T.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=T.nil){this.gen.block(()=>{this.check$data(t,n),r();});}check$data(t=T.nil,r=T.nil){if(!this.$data)return;let{gen:n,schemaCode:s,schemaType:o,def:a}=this;n.if((0, T.or)((0, T._)`${s} === undefined`,r)),t!==T.nil&&n.assign(t,true),(o.length||a.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),t!==T.nil&&n.assign(t,false)),n.else();}invalid$data(){let{gen:t,schemaCode:r,schemaType:n,def:s,it:o}=this;return (0, T.or)(a(),i());function a(){if(n.length){if(!(r instanceof T.Name))throw new Error("ajv implementation error");let u=Array.isArray(n)?n:[n];return (0, T._)`${(0, Hr.checkDataTypes)(u,r,o.opts.strictNumbers,Hr.DataType.Wrong)}`}return T.nil}function i(){if(s.validateSchema){let u=t.scopeValue("validate$data",{ref:s.validateSchema});return (0, T._)`!${u}(${r})`}return T.nil}}subschema(t,r){let n=(0, ws.getSubschema)(this.it,t);(0, ws.extendSubschemaData)(n,this.it,t),(0, ws.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=Je.mergeEvaluated.props(s,t.props,n.props,r)),n.items!==true&&t.items!==void 0&&(n.items=Je.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,T.Name)),true}};nt.KeywordCxt=zr;function di(e,t,r,n){let s=new zr(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 li(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 l=+c[1];if(s=c[2],s==="#"){if(l>=t)throw new Error(u("property/index",l));return n[t-l]}if(l>t)throw new Error(u("data",l));if(o=r[t-l],!s)return o}let a=o,i=s.split("/");for(let c of i)c&&(o=(0, T._)`${o}${(0, T.getProperty)((0, Je.unescapeJsonPointer)(c))}`,a=(0, T._)`${a} && ${o}`);return a;function u(c,l){return `Cannot access ${c} ${l} levels up, current level is ${t}`}}nt.getData=li;});var Wr=x(Cs=>{Object.defineProperty(Cs,"__esModule",{value:true});var $s=class extends Error{constructor(t){super("validation failed"),this.errors=t,this.ajv=this.validation=true;}};Cs.default=$s;});var dr=x(Ts=>{Object.defineProperty(Ts,"__esModule",{value:true});var Es=ar(),xs=class extends Error{constructor(t,r,n,s){super(s||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0, Es.resolveUrl)(t,r,n),this.missingSchema=(0, Es.normalizeId)((0, Es.getFullPath)(t,this.missingRef));}};Ts.default=xs;});var Xr=x(Ae=>{Object.defineProperty(Ae,"__esModule",{value:true});Ae.resolveSchema=Ae.getCompilingSchema=Ae.resolveRef=Ae.compileSchema=Ae.SchemaEnv=void 0;var Oe=G(),kf=Wr(),St=Ue(),je=ar(),fi=H(),Sf=cr(),Dt=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=Dt;function Is(e){let t=pi.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:kf.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},l;try{this._compilations.add(e),(0,Sf.validateFunctionCode)(c),a.optimize(this.opts.code.optimize);let d=a.toString();l=`${a.scopeRefs(St.default.scope)}return ${d}`,this.opts.code.process&&(l=this.opts.code.process(l,e));let g=new Function(`${St.default.self}`,`${St.default.scope}`,l)(this,this.scope.get());if(this.scope.value(u,{ref:g}),g.errors=null,g.schema=e.schema,g.schemaEnv=e,e.$async&&(g.$async=!0),this.opts.code.source===!0&&(g.source={validateName:u,validateCode:d,scopeValues:a._values}),this.opts.unevaluated){let{props:f,items:p}=c;g.evaluated={props:f instanceof Oe.Name?void 0:f,items:p instanceof Oe.Name?void 0:p,dynamicProps:f instanceof Oe.Name,dynamicItems:p instanceof Oe.Name},g.source&&(g.source.evaluated=(0,Oe.stringify)(g.evaluated));}return e.validate=g,e}catch(d){throw delete e.validate,delete e.validateName,l&&this.logger.error("Error compiling schema, function code:",l),d}finally{this._compilations.delete(e);}}Ae.compileSchema=Is;function wf(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 Dt({schema:a,schemaId:i,root:e,baseId:t}));}if(o!==void 0)return e.refs[r]=_f.call(this,o)}Ae.resolveRef=wf;function _f(e){return (0, je.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:Is.call(this,e)}function pi(e){for(let t of this._compilations)if(Rf(t,e))return t}Ae.getCompilingSchema=pi;function Rf(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 As.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:As.call(this,r,i)}if(typeof a?.schema=="object"){if(a.validate||Is.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 Dt({schema:i,schemaId:u,root:e,baseId:s})}return As.call(this,r,a)}}Ae.resolveSchema=Yr;var Cf=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function As(e,{baseId:t,schema:r,root:n}){var s;if(((s=e.fragment)===null||s===void 0?void 0:s[0])!=="/")return;for(let i of e.fragment.slice(1).split("/")){if(typeof r=="boolean")return;let u=r[(0, fi.unescapeFragment)(i)];if(u===void 0)return;r=u;let c=typeof r=="object"&&r[this.opts.schemaId];!Cf.has(i)&&c&&(t=(0, je.resolveUrl)(this.opts.uriResolver,t,c));}let o;if(typeof r!="boolean"&&r.$ref&&!(0, fi.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 Dt({schema:r,schemaId:a,root:n,baseId:t}),o.schema!==o.root.schema)return o}});var mi=x((Uy,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 Os=x((Jy,vi)=>{var xf=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),gi=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 Ps(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 hi(e){return e.length=0,true}function Af(e,t,r){if(e.length){let n=Ps(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=hi;}else {s.push(c);continue}}return s.length&&(i===hi?r.zone=s.join(""):a?n.push(s.join("")):n.push(Ps(s))),r.address=n.join(""),r}function yi(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(!gi(r)){let n=yi(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}vi.exports={nonSimpleDomain:Tf,recomposeAuthority:Nf,normalizeComponentEncoding:jf,removeDotSegments:Of,isIPv4:gi,isUUID:xf,normalizeIPv6:yi,stringArrayToHexStripped:Ps};});var _i=x((Hy,wi)=>{var{isUUID:qf}=Os(),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 js(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 bi(e){return e.host||(e.error=e.error||"HTTP URIs must have a host."),e}function ki(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=js(e),e.resourceName=(e.path||"/")+(e.query?"?"+e.query:""),e.path=void 0,e.query=void 0,e}function Vf(e){if((e.port===(js(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=Ns(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=Ns(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 Si={scheme:"http",domainHost:true,parse:bi,serialize:ki},Jf={scheme:"https",domainHost:Si.domainHost,parse:bi,serialize:ki},Qr={scheme:"ws",domainHost:true,parse:Lf,serialize:Vf},Hf={scheme:"wss",domainHost:Qr.domainHost,parse:Qr.parse,serialize:Qr.serialize},zf={scheme:"urn",parse:Bf,serialize:Gf,skipNormalize:true},Wf={scheme:"urn:uuid",parse:Kf,serialize:Uf,skipNormalize:true},Zr={http:Si,https:Jf,ws:Qr,wss:Hf,urn:zf,"urn:uuid":Wf};Object.setPrototypeOf(Zr,null);function Ns(e){return e&&(Zr[e]||Zr[e.toLowerCase()])||void 0}wi.exports={wsIsSecure:js,SCHEMES:Zr,isValidSchemeName:Mf,getSchemeHandler:Ns};});var Ci=x((zy,tn)=>{var{normalizeIPv6:Yf,removeDotSegments:lr,recomposeAuthority:Xf,normalizeComponentEncoding:en,isIPv4:Qf,nonSimpleDomain:Zf}=Os(),{SCHEMES:ep,getSchemeHandler:Ri}=_i();function tp(e,t){return typeof e=="string"?e=Le(He(e,t),t):typeof e=="object"&&(e=He(Le(e,t),t)),e}function rp(e,t,r){let n=r?Object.assign({scheme:"null"},r):{scheme:"null"},s=$i(He(e,n),He(t,n),n,true);return n.skipEscape=true,Le(s,n)}function $i(e,t,r,n){let s={};return n||(e=He(Le(e,r),r),t=He(Le(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=Le(en(He(e,r),true),{...r,skipEscape:true})):typeof e=="object"&&(e=Le(en(e,true),{...r,skipEscape:true})),typeof t=="string"?(t=unescape(t),t=Le(en(He(t,r),true),{...r,skipEscape:true})):typeof t=="object"&&(t=Le(en(t,true),{...r,skipEscape:true})),e.toLowerCase()===t.toLowerCase()}function Le(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=Ri(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 He(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=Ri(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 qs={SCHEMES:ep,normalize:tp,resolve:rp,resolveComponent:$i,equal:np,serialize:Le,parse:He};tn.exports=qs;tn.exports.default=qs;tn.exports.fastUri=qs;});var xi=x(Ds=>{Object.defineProperty(Ds,"__esModule",{value:true});var Ei=Ci();Ei.code='require("ajv/dist/runtime/uri").default';Ds.default=Ei;});var qi=x(de=>{Object.defineProperty(de,"__esModule",{value:true});de.CodeGen=de.Name=de.nil=de.stringify=de.str=de._=de.KeywordCxt=void 0;var op=cr();Object.defineProperty(de,"KeywordCxt",{enumerable:true,get:function(){return op.KeywordCxt}});var Ft=G();Object.defineProperty(de,"_",{enumerable:true,get:function(){return Ft._}});Object.defineProperty(de,"str",{enumerable:true,get:function(){return Ft.str}});Object.defineProperty(de,"stringify",{enumerable:true,get:function(){return Ft.stringify}});Object.defineProperty(de,"nil",{enumerable:true,get:function(){return Ft.nil}});Object.defineProperty(de,"Name",{enumerable:true,get:function(){return Ft.Name}});Object.defineProperty(de,"CodeGen",{enumerable:true,get:function(){return Ft.CodeGen}});var ap=Wr(),Oi=dr(),ip=fs(),fr=Xr(),up=G(),pr=ar(),rn=or(),Ms=H(),Ti=mi(),cp=xi(),ji=(e,t)=>new RegExp(e,t);ji.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.'},Ai=200;function mp(e){var t,r,n,s,o,a,i,u,c,l,d,y,g,f,p,k,h,m,v,w,S,$,_,C,N;let q=e.strict,F=(t=e.code)===null||t===void 0?void 0:t.optimize,re=F===true||F===void 0?1:F||0,U=(n=(r=e.code)===null||r===void 0?void 0:r.regExp)!==null&&n!==void 0?n:ji,ce=(s=e.uriResolver)!==null&&s!==void 0?s:cp.default;return {strictSchema:(a=(o=e.strictSchema)!==null&&o!==void 0?o:q)!==null&&a!==void 0?a:true,strictNumbers:(u=(i=e.strictNumbers)!==null&&i!==void 0?i:q)!==null&&u!==void 0?u:true,strictTypes:(l=(c=e.strictTypes)!==null&&c!==void 0?c:q)!==null&&l!==void 0?l:"log",strictTuples:(y=(d=e.strictTuples)!==null&&d!==void 0?d:q)!==null&&y!==void 0?y:"log",strictRequired:(f=(g=e.strictRequired)!==null&&g!==void 0?g:q)!==null&&f!==void 0?f:false,code:e.code?{...e.code,optimize:re,regExp:U}:{optimize:re,regExp:U},loopRequired:(p=e.loopRequired)!==null&&p!==void 0?p:Ai,loopEnum:(k=e.loopEnum)!==null&&k!==void 0?k:Ai,meta:(h=e.meta)!==null&&h!==void 0?h:true,messages:(m=e.messages)!==null&&m!==void 0?m:true,inlineRefs:(v=e.inlineRefs)!==null&&v!==void 0?v:true,schemaId:(w=e.schemaId)!==null&&w!==void 0?w:"$id",addUsedSchema:(S=e.addUsedSchema)!==null&&S!==void 0?S:true,validateSchema:($=e.validateSchema)!==null&&$!==void 0?$:true,validateFormats:(_=e.validateFormats)!==null&&_!==void 0?_:true,unicodeRegExp:(C=e.unicodeRegExp)!==null&&C!==void 0?C:true,int32range:(N=e.int32range)!==null&&N!==void 0?N:true,uriResolver:ce}}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)(),Ii.call(this,fp,t,"NOT SUPPORTED"),Ii.call(this,pp,t,"DEPRECATED","warn"),this._metaOpts=vp.call(this),t.formats&&gp.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),t.keywords&&yp.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=Ti;n==="id"&&(s={...Ti},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(l,d){await o.call(this,l.$schema);let y=this._addSchema(l,d);return y.validate||a.call(this,y)}async function o(l){l&&!this.getSchema(l)&&await s.call(this,{$ref:l},true);}async function a(l){try{return this._compileSchemaEnv(l)}catch(d){if(!(d instanceof Oi.default))throw d;return i.call(this,d),await u.call(this,d.missingSchema),a.call(this,l)}}function i({missingSchema:l,missingRef:d}){if(this.refs[l])throw new Error(`AnySchema ${l} is loaded but ${d} cannot be resolved`)}async function u(l){let d=await c.call(this,l);this.refs[l]||await o.call(this,d.$schema),this.refs[l]||this.addSchema(d,l,r);}async function c(l){let d=this._loading[l];if(d)return d;try{return await(this._loading[l]=n(l))}finally{delete this._loading[l];}}}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=Pi.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=Pi.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(wp.call(this,n,r),!r)return (0, Ms.eachItem)(n,o=>Fs.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, Ms.eachItem)(n,s.type.length===0?o=>Fs.call(this,o,s):o=>s.type.forEach(a=>Fs.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,l=a[i];c&&l&&(a[i]=Ni(l));}}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=Oi.default;de.default=mr;function Ii(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 Pi(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 gp(){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 Sp=/^[a-z_$][a-z0-9_$:-]*$/i;function wp(e,t){let{RULES:r}=this;if((0, Ms.eachItem)(e,n=>{if(r.keywords[n])throw new Error(`Keyword ${n} is already defined`);if(!Sp.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 Fs(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=Ni(t)),e.validateSchema=this.compile(t,true));}var $p={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function Ni(e){return {anyOf:[e,$p]}}});var Di=x(Ls=>{Object.defineProperty(Ls,"__esModule",{value:true});var Cp={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};Ls.default=Cp;});var Vi=x(wt=>{Object.defineProperty(wt,"__esModule",{value:true});wt.callRef=wt.getValidate=void 0;var Ep=dr(),Fi=Te(),Se=G(),Mt=Ue(),Mi=Xr(),nn=H(),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 d();let l=Mi.resolveRef.call(u,c,s,r);if(l===void 0)throw new Ep.default(n.opts.uriResolver,s,r);if(l instanceof Mi.SchemaEnv)return y(l);return g(l);function d(){if(o===c)return sn(e,a,o,o.$async);let f=t.scopeValue("root",{ref:c});return sn(e,(0, Se._)`${f}.validate`,c,c.$async)}function y(f){let p=Li(e,f);sn(e,p,f,f.$async);}function g(f){let p=t.scopeValue("schema",i.code.source===true?{ref:f,code:(0, Se.stringify)(f)}:{ref:f}),k=t.name("valid"),h=e.subschema({schema:f,dataTypes:[],schemaPath:Se.nil,topSchemaRef:p,errSchemaPath:r},k);e.mergeEvaluated(h),e.ok(k);}}};function Li(e,t){let{gen:r}=e;return t.validate?r.scopeValue("validate",{ref:t.validate}):(0, Se._)`${r.scopeValue("wrapper",{ref:t})}.validate`}wt.getValidate=Li;function sn(e,t,r,n){let{gen:s,it:o}=e,{allErrors:a,schemaEnv:i,opts:u}=o,c=u.passContext?Mt.default.this:Se.nil;n?l():d();function l(){if(!i.$async)throw new Error("async schema referenced by sync schema");let f=s.let("valid");s.try(()=>{s.code((0, Se._)`await ${(0, Fi.callValidateCode)(e,t,c)}`),g(t),a||s.assign(f,true);},p=>{s.if((0, Se._)`!(${p} instanceof ${o.ValidationError})`,()=>s.throw(p)),y(p),a||s.assign(f,false);}),e.ok(f);}function d(){e.result((0, Fi.callValidateCode)(e,t,c),()=>g(t),()=>y(t));}function y(f){let p=(0, Se._)`${f}.errors`;s.assign(Mt.default.vErrors,(0, Se._)`${Mt.default.vErrors} === null ? ${p} : ${Mt.default.vErrors}.concat(${p})`),s.assign(Mt.default.errors,(0, Se._)`${Mt.default.vErrors}.length`);}function g(f){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 h=s.var("props",(0, Se._)`${f}.evaluated.props`);o.props=nn.mergeEvaluated.props(s,h,o.props,Se.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 h=s.var("items",(0, Se._)`${f}.evaluated.items`);o.items=nn.mergeEvaluated.items(s,h,o.items,Se.Name);}}}wt.callRef=sn;wt.default=xp;});var Bi=x(Vs=>{Object.defineProperty(Vs,"__esModule",{value:true});var Tp=Di(),Ap=Vi(),Ip=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",Tp.default,Ap.default];Vs.default=Ip;});var Gi=x(Bs=>{Object.defineProperty(Bs,"__esModule",{value:true});var on=G(),st=on.operators,an={maximum:{okStr:"<=",ok:st.LTE,fail:st.GT},minimum:{okStr:">=",ok:st.GTE,fail:st.LT},exclusiveMaximum:{okStr:"<",ok:st.LT,fail:st.GTE},exclusiveMinimum:{okStr:">",ok:st.GT,fail:st.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})`);}};Bs.default=Op;});var Ki=x(Gs=>{Object.defineProperty(Gs,"__esModule",{value:true});var hr=G(),jp={message:({schemaCode:e})=>(0, hr.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0, hr._)`{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, hr._)`Math.abs(Math.round(${a}) - ${a}) > 1e-${o}`:(0, hr._)`${a} !== parseInt(${a})`;e.fail$data((0, hr._)`(${n} === 0 || (${a} = ${r}/${n}, ${i}))`);}};Gs.default=Np;});var Ji=x(Ks=>{Object.defineProperty(Ks,"__esModule",{value:true});function Ui(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}Ks.default=Ui;Ui.code='require("ajv/dist/runtime/ucs2length").default';});var Hi=x(Us=>{Object.defineProperty(Us,"__esModule",{value:true});var _t=G(),qp=H(),Dp=Ji(),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}`);}};Us.default=Mp;});var zi=x(Js=>{Object.defineProperty(Js,"__esModule",{value:true});var Lp=Te(),Vp=H(),Lt=G(),Bp={message:({schemaCode:e})=>(0, Lt.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0, Lt._)`{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, Lt._)`new RegExp`:(0, Vp.useFunc)(t,u),l=t.let("valid");t.try(()=>t.assign(l,(0, Lt._)`${c}(${o}, ${i}).test(${r})`),()=>t.assign(l,false)),e.fail$data((0, Lt._)`!${l}`);}else {let u=(0, Lp.usePattern)(e,s);e.fail$data((0, Lt._)`!${u}.test(${r})`);}}};Js.default=Gp;});var Wi=x(Hs=>{Object.defineProperty(Hs,"__esModule",{value:true});var gr=G(),Kp={message({keyword:e,schemaCode:t}){let r=e==="maxProperties"?"more":"fewer";return (0, gr.str)`must NOT have ${r} than ${t} properties`},params:({schemaCode:e})=>(0, gr._)`{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"?gr.operators.GT:gr.operators.LT;e.fail$data((0, gr._)`Object.keys(${r}).length ${s} ${n}`);}};Hs.default=Up;});var Yi=x(zs=>{Object.defineProperty(zs,"__esModule",{value:true});var yr=Te(),vr=G(),Jp=H(),Hp={message:({params:{missingProperty:e}})=>(0, vr.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0, vr._)`{missingProperty: ${e}}`},zp={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():l(),i.strictRequired){let g=e.parentSchema.properties,{definedProperties:f}=e.it;for(let p of r)if(g?.[p]===void 0&&!f.has(p)){let k=a.schemaEnv.baseId+a.errSchemaPath,h=`required property "${p}" is not defined at "${k}" (strictRequired)`;(0, Jp.checkStrictMode)(a,h,a.opts.strictRequired);}}function c(){if(u||o)e.block$data(vr.nil,d);else for(let g of r)(0, yr.checkReportMissingProp)(e,g);}function l(){let g=t.let("missing");if(u||o){let f=t.let("valid",true);e.block$data(f,()=>y(g,f)),e.ok(f);}else t.if((0, yr.checkMissingProp)(e,r,g)),(0, yr.reportMissingProp)(e,g),t.else();}function d(){t.forOf("prop",n,g=>{e.setParams({missingProperty:g}),t.if((0, yr.noPropertyInData)(t,s,g,i.ownProperties),()=>e.error());});}function y(g,f){e.setParams({missingProperty:g}),t.forOf(g,n,()=>{t.assign(f,(0, yr.propertyInData)(t,s,g,i.ownProperties)),t.if((0, vr.not)(f),()=>{e.error(),t.break();});},vr.nil);}}};zs.default=zp;});var Xi=x(Ws=>{Object.defineProperty(Ws,"__esModule",{value:true});var br=G(),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}`);}};Ws.default=Yp;});var un=x(Ys=>{Object.defineProperty(Ys,"__esModule",{value:true});var Qi=ks();Qi.code='require("ajv/dist/runtime/equal").default';Ys.default=Qi;});var Zi=x(Qs=>{Object.defineProperty(Qs,"__esModule",{value:true});var Xs=or(),le=G(),Xp=H(),Qp=un(),Zp={message:({params:{i:e,j:t}})=>(0, le.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0, le._)`{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, Xs.getSchemaTypes)(o.items):[];e.block$data(u,l,(0, le._)`${a} === false`),e.ok(u);function l(){let f=t.let("i",(0, le._)`${r}.length`),p=t.let("j");e.setParams({i:f,j:p}),t.assign(u,true),t.if((0, le._)`${f} > 1`,()=>(d()?y:g)(f,p));}function d(){return c.length>0&&!c.some(f=>f==="object"||f==="array")}function y(f,p){let k=t.name("item"),h=(0, Xs.checkDataTypes)(c,k,i.opts.strictNumbers,Xs.DataType.Wrong),m=t.const("indices",(0, le._)`{}`);t.for((0, le._)`;${f}--;`,()=>{t.let(k,(0, le._)`${r}[${f}]`),t.if(h,(0, le._)`continue`),c.length>1&&t.if((0, le._)`typeof ${k} == "string"`,(0, le._)`${k} += "_"`),t.if((0, le._)`typeof ${m}[${k}] == "number"`,()=>{t.assign(p,(0, le._)`${m}[${k}]`),e.error(),t.assign(u,false).break();}).code((0, le._)`${m}[${k}] = ${f}`);});}function g(f,p){let k=(0, Xp.useFunc)(t,Qp.default),h=t.name("outer");t.label(h).for((0, le._)`;${f}--;`,()=>t.for((0, le._)`${p} = ${f}; ${p}--;`,()=>t.if((0, le._)`${k}(${r}[${f}], ${r}[${p}])`,()=>{e.error(),t.assign(u,false).break(h);})));}}};Qs.default=em;});var eu=x(eo=>{Object.defineProperty(eo,"__esModule",{value:true});var Zs=G(),tm=H(),rm=un(),nm={message:"must be equal to constant",params:({schemaCode:e})=>(0, Zs._)`{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, Zs._)`!${(0, tm.useFunc)(t,rm.default)}(${r}, ${s})`):e.fail((0, Zs._)`${o} !== ${r}`);}};eo.default=sm;});var tu=x(to=>{Object.defineProperty(to,"__esModule",{value:true});var kr=G(),om=H(),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)),l;if(i||n)l=t.let("valid"),e.block$data(l,d);else {if(!Array.isArray(s))throw new Error("ajv implementation error");let g=t.const("vSchema",o);l=(0, kr.or)(...s.map((f,p)=>y(g,p)));}e.pass(l);function d(){t.assign(l,false),t.forOf("v",o,g=>t.if((0, kr._)`${c()}(${r}, ${g})`,()=>t.assign(l,true).break()));}function y(g,f){let p=s[f];return typeof p=="object"&&p!==null?(0, kr._)`${c()}(${r}, ${g}[${f}])`:(0, kr._)`${r} === ${p}`}}};to.default=um;});var ru=x(ro=>{Object.defineProperty(ro,"__esModule",{value:true});var cm=Gi(),dm=Ki(),lm=Hi(),fm=zi(),pm=Wi(),mm=Yi(),hm=Xi(),gm=Zi(),ym=eu(),vm=tu(),bm=[cm.default,dm.default,lm.default,fm.default,pm.default,mm.default,hm.default,gm.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},ym.default,vm.default];ro.default=bm;});var so=x(Sr=>{Object.defineProperty(Sr,"__esModule",{value:true});Sr.validateAdditionalItems=void 0;var Rt=G(),no=H(),km={message:({params:{len:e}})=>(0, Rt.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0, Rt._)`{limit: ${e}}`},Sm={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, no.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}nu(e,n);}};function nu(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, no.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,l=>{e.subschema({keyword:o,dataProp:l,dataPropType:no.Type.Num},c),a.allErrors||r.if((0, Rt.not)(c),()=>r.break());});}}Sr.validateAdditionalItems=nu;Sr.default=Sm;});var oo=x(wr=>{Object.defineProperty(wr,"__esModule",{value:true});wr.validateTuple=void 0;var su=G(),cn=H(),wm=Te(),_m={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){let{schema:t,it:r}=e;if(Array.isArray(t))return ou(e,"additionalItems",t);r.items=true,!(0, cn.alwaysValidSchema)(r,t)&&e.ok((0, wm.validateArray)(e));}};function ou(e,t,r=e.schema){let{gen:n,parentSchema:s,data:o,keyword:a,it:i}=e;l(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, su._)`${o}.length`);r.forEach((d,y)=>{(0, cn.alwaysValidSchema)(i,d)||(n.if((0, su._)`${c} > ${y}`,()=>e.subschema({keyword:a,schemaProp:y,dataProp:y},u)),e.ok(u));});function l(d){let{opts:y,errSchemaPath:g}=i,f=r.length,p=f===d.minItems&&(f===d.maxItems||d[t]===false);if(y.strictTuples&&!p){let k=`"${a}" is ${f}-tuple, but minItems or maxItems/${t} are not specified or different at path "${g}"`;(0, cn.checkStrictMode)(i,k,y.strictTuples);}}}wr.validateTuple=ou;wr.default=_m;});var au=x(ao=>{Object.defineProperty(ao,"__esModule",{value:true});var Rm=oo(),$m={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:e=>(0, Rm.validateTuple)(e,"items")};ao.default=$m;});var uu=x(io=>{Object.defineProperty(io,"__esModule",{value:true});var iu=G(),Cm=H(),Em=Te(),xm=so(),Tm={message:({params:{len:e}})=>(0, iu.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0, iu._)`{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, Cm.alwaysValidSchema)(n,t)&&(s?(0, xm.validateAdditionalItems)(e,s):e.ok((0, Em.validateArray)(e)));}};io.default=Am;});var cu=x(uo=>{Object.defineProperty(uo,"__esModule",{value:true});var Ie=G(),dn=H(),Im={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}}`},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 l=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._)`${l} >= ${a}`;i!==void 0&&(p=(0, Ie._)`${p} && ${l} <= ${i}`),e.pass(p);return}o.items=true;let d=t.name("valid");i===void 0&&a===1?g(d,()=>t.if(d,()=>t.break())):a===0?(t.let(d,true),i!==void 0&&t.if((0, Ie._)`${s}.length > 0`,y)):(t.let(d,false),y()),e.result(d,()=>e.reset());function y(){let p=t.name("_valid"),k=t.let("count",0);g(p,()=>t.if(p,()=>f(k)));}function g(p,k){t.forRange("i",0,l,h=>{e.subschema({keyword:"contains",dataProp:h,dataPropType:dn.Type.Num,compositeRule:true},p),k();});}function f(p){t.code((0, Ie._)`${p}++`),i===void 0?t.if((0, Ie._)`${p} >= ${a}`,()=>t.assign(d,true).break()):(t.if((0, Ie._)`${p} > ${i}`,()=>t.assign(d,false).break()),a===1?t.assign(d,true):t.if((0, Ie._)`${p} >= ${a}`,()=>t.assign(d,true)));}}};uo.default=Pm;});var fu=x(Ve=>{Object.defineProperty(Ve,"__esModule",{value:true});Ve.validateSchemaDeps=Ve.validatePropertyDeps=Ve.error=void 0;var co=G(),Om=H(),_r=Te();Ve.error={message:({params:{property:e,depsCount:t,deps:r}})=>{let n=t===1?"property":"properties";return (0, co.str)`must have ${n} ${r} when property ${e} is present`},params:({params:{property:e,depsCount:t,deps:r,missingProperty:n}})=>(0, co._)`{property: ${e},
|
|
6
6
|
missingProperty: ${n},
|
|
7
7
|
depsCount: ${t},
|
|
8
|
-
deps: ${r}}`};var jm={keyword:"dependencies",type:"object",schemaType:"object",error:Ve.error,code(e){let[t,r]=Nm(e);du(e,t),lu(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 du(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, co._)`${u} && (${(0, _r.checkMissingProp)(e,i,o)})`),(0, _r.reportMissingProp)(e,o),r.else());}}Ve.validatePropertyDeps=du;function lu(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));}Ve.validateSchemaDeps=lu;Ve.default=jm;});var mu=x(lo=>{Object.defineProperty(lo,"__esModule",{value:true});var pu=G(),qm=H(),Dm={message:"property name must be valid",params:({params:e})=>(0, pu._)`{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, pu.not)(o),()=>{e.error(true),s.allErrors||t.break();});}),e.ok(o);}};lo.default=Fm;});var po=x(fo=>{Object.defineProperty(fo,"__esModule",{value:true});var ln=Te(),Ne=G(),Mm=Ue(),fn=H(),Lm={message:"must NOT have additional properties",params:({params:e})=>(0, Ne._)`{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),l=(0, ln.allSchemaProperties)(n.patternProperties);d(),e.ok((0, Ne._)`${o} === ${Mm.default.errors}`);function d(){t.forIn("key",s,b=>{!c.length&&!l.length?f(b):t.if(y(b),()=>f(b));});}function y(b){let h;if(c.length>8){let m=(0, fn.schemaRefOrVal)(a,n.properties,"properties");h=(0, ln.isOwnProperty)(t,m,b);}else c.length?h=(0, Ne.or)(...c.map(m=>(0, Ne._)`${b} === ${m}`)):h=Ne.nil;return l.length&&(h=(0, Ne.or)(h,...l.map(m=>(0, Ne._)`${(0, ln.usePattern)(e,m)}.test(${b})`))),(0, Ne.not)(h)}function g(b){t.code((0, Ne._)`delete ${s}[${b}]`);}function f(b){if(u.removeAdditional==="all"||u.removeAdditional&&r===false){g(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 h=t.name("valid");u.removeAdditional==="failing"?(p(b,h,false),t.if((0, Ne.not)(h),()=>{e.reset(),g(b);})):(p(b,h),i||t.if((0, Ne.not)(h),()=>t.break()));}}function p(b,h,m){let v={keyword:"additionalProperties",dataProp:b,dataPropType:fn.Type.Str};m===false&&Object.assign(v,{compositeRule:true,createErrors:false,allErrors:false}),e.subschema(v,h);}}};fo.default=Vm;});var yu=x(ho=>{Object.defineProperty(ho,"__esModule",{value:true});var Bm=cr(),hu=Te(),mo=H(),gu=po(),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&&gu.default.code(new Bm.KeywordCxt(o,gu.default,"additionalProperties"));let a=(0, hu.allSchemaProperties)(r);for(let d of a)o.definedProperties.add(d);o.opts.unevaluated&&a.length&&o.props!==true&&(o.props=mo.mergeEvaluated.props(t,(0, mo.toHash)(a),o.props));let i=a.filter(d=>!(0, mo.alwaysValidSchema)(o,r[d]));if(i.length===0)return;let u=t.name("valid");for(let d of i)c(d)?l(d):(t.if((0, hu.propertyInData)(t,s,d,o.opts.ownProperties)),l(d),o.allErrors||t.else().var(u,true),t.endIf()),e.it.definedProperties.add(d),e.ok(u);function c(d){return o.opts.useDefaults&&!o.compositeRule&&r[d].default!==void 0}function l(d){e.subschema({keyword:"properties",schemaProp:d,dataProp:d},u);}}};ho.default=Gm;});var Su=x(go=>{Object.defineProperty(go,"__esModule",{value:true});var vu=Te(),pn=G(),ku=H(),bu=H(),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, vu.allSchemaProperties)(r),u=i.filter(p=>(0, ku.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,l=t.name("valid");o.props!==true&&!(o.props instanceof pn.Name)&&(o.props=(0, bu.evaluatedPropsToName)(t,o.props));let{props:d}=o;y();function y(){for(let p of i)c&&g(p),o.allErrors?f(p):(t.var(l,true),f(p),t.if(l));}function g(p){for(let b in c)new RegExp(p).test(b)&&(0, ku.checkStrictMode)(o,`property ${b} matches pattern ${p} (use allowMatchingProperties)`);}function f(p){t.forIn("key",n,b=>{t.if((0, pn._)`${(0, vu.usePattern)(e,p)}.test(${b})`,()=>{let h=u.includes(p);h||e.subschema({keyword:"patternProperties",schemaProp:p,dataProp:b,dataPropType:bu.Type.Str},l),o.opts.unevaluated&&d!==true?t.assign((0, pn._)`${d}[${b}]`,true):!h&&!o.allErrors&&t.if((0, pn.not)(l),()=>t.break());});});}}};go.default=Km;});var wu=x(yo=>{Object.defineProperty(yo,"__esModule",{value:true});var Um=H(),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"}};yo.default=Jm;});var _u=x(vo=>{Object.defineProperty(vo,"__esModule",{value:true});var Hm=Te(),zm={keyword:"anyOf",schemaType:"array",trackErrors:true,code:Hm.validateUnion,error:{message:"must match a schema in anyOf"}};vo.default=zm;});var Ru=x(ko=>{Object.defineProperty(ko,"__esModule",{value:true});var mn=G(),Wm=H(),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((l,d)=>{let y;(0, Wm.alwaysValidSchema)(s,l)?t.var(u,true):y=e.subschema({keyword:"oneOf",schemaProp:d,compositeRule:true},u),d>0&&t.if((0, mn._)`${u} && ${a}`).assign(a,false).assign(i,(0, mn._)`[${i}, ${d}]`).else(),t.if(u,()=>{t.assign(a,true),t.assign(i,d),y&&e.mergeEvaluated(y,mn.Name);});});}}};ko.default=Xm;});var $u=x(bo=>{Object.defineProperty(bo,"__esModule",{value:true});var Qm=H(),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);});}};bo.default=Zm;});var xu=x(So=>{Object.defineProperty(So,"__esModule",{value:true});var hn=G(),Eu=H(),eh={message:({params:e})=>(0, hn.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0, hn._)`{failingKeyword: ${e.ifClause}}`},th={keyword:"if",schemaType:["object","boolean"],trackErrors:true,error:eh,code(e){let{gen:t,parentSchema:r,it:n}=e;r.then===void 0&&r.else===void 0&&(0, Eu.checkStrictMode)(n,'"if" without "then" and "else" is ignored');let s=Cu(n,"then"),o=Cu(n,"else");if(!s&&!o)return;let a=t.let("valid",true),i=t.name("_valid");if(u(),e.reset(),s&&o){let l=t.let("ifClause");e.setParams({ifClause:l}),t.if(i,c("then",l),c("else",l));}else s?t.if(i,c("then")):t.if((0, hn.not)(i),c("else"));e.pass(a,()=>e.error(true));function u(){let l=e.subschema({keyword:"if",compositeRule:true,createErrors:false,allErrors:false},i);e.mergeEvaluated(l);}function c(l,d){return ()=>{let y=e.subschema({keyword:l},i);t.assign(a,i),e.mergeValidEvaluated(y,a),d?t.assign(d,(0, hn._)`${l}`):e.setParams({ifClause:l});}}}};function Cu(e,t){let r=e.schema[t];return r!==void 0&&!(0, Eu.alwaysValidSchema)(e,r)}So.default=th;});var Tu=x(wo=>{Object.defineProperty(wo,"__esModule",{value:true});var rh=H(),nh={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:r}){t.if===void 0&&(0, rh.checkStrictMode)(r,`"${e}" without "if" is ignored`);}};wo.default=nh;});var Au=x(_o=>{Object.defineProperty(_o,"__esModule",{value:true});var sh=so(),oh=au(),ah=oo(),ih=uu(),uh=cu(),ch=fu(),dh=mu(),lh=po(),fh=yu(),ph=Su(),mh=wu(),hh=_u(),gh=Ru(),yh=$u(),vh=xu(),kh=Tu();function bh(e=false){let t=[mh.default,hh.default,gh.default,yh.default,vh.default,kh.default,dh.default,lh.default,ch.default,fh.default,ph.default];return e?t.push(oh.default,ih.default):t.push(sh.default,ah.default),t.push(uh.default),t}_o.default=bh;});var Iu=x(Ro=>{Object.defineProperty(Ro,"__esModule",{value:true});var ie=G(),Sh={message:({schemaCode:e})=>(0, ie.str)`must match format "${e}"`,params:({schemaCode:e})=>(0, ie._)`{format: ${e}}`},wh={keyword:"format",type:["number","string"],schemaType:"string",$data:true,error:Sh,code(e,t){let{gen:r,data:n,$data:s,schema:o,schemaCode:a,it:i}=e,{opts:u,errSchemaPath:c,schemaEnv:l,self:d}=i;if(!u.validateFormats)return;s?y():g();function y(){let f=r.scopeValue("formats",{ref:d.formats,code:u.code.formats}),p=r.const("fDef",(0, ie._)`${f}[${a}]`),b=r.let("fType"),h=r.let("format");r.if((0, ie._)`typeof ${p} == "object" && !(${p} instanceof RegExp)`,()=>r.assign(b,(0, ie._)`${p}.type || "string"`).assign(h,(0, ie._)`${p}.validate`),()=>r.assign(b,(0, ie._)`"string"`).assign(h,p)),e.fail$data((0, ie.or)(m(),v()));function m(){return u.strictSchema===false?ie.nil:(0, ie._)`${a} && !${h}`}function v(){let w=l.$async?(0, ie._)`(${p}.async ? await ${h}(${n}) : ${h}(${n}))`:(0, ie._)`${h}(${n})`,S=(0, ie._)`(typeof ${h} == "function" ? ${w} : ${h}.test(${n}))`;return (0, ie._)`${h} && ${h} !== true && ${b} === ${t} && !${S}`}}function g(){let f=d.formats[o];if(!f){m();return}if(f===true)return;let[p,b,h]=v(f);p===t&&e.pass(w());function m(){if(u.strictSchema===false){d.logger.warn(S());return}throw new Error(S());function S(){return `unknown format "${o}" ignored in schema at path "${c}"`}}function v(S){let $=S instanceof RegExp?(0, ie.regexpCode)(S):u.code.formats?(0, ie._)`${u.code.formats}${(0, ie.getProperty)(o)}`:void 0,_=r.scopeValue("formats",{key:o,ref:S,code:$});return typeof S=="object"&&!(S instanceof RegExp)?[S.type||"string",S.validate,(0, ie._)`${_}.validate`]:["string",S,_]}function w(){if(typeof f=="object"&&!(f instanceof RegExp)&&f.async){if(!l.$async)throw new Error("async format in sync schema");return (0, ie._)`await ${h}(${n})`}return typeof b=="function"?(0, ie._)`${h}(${n})`:(0, ie._)`${h}.test(${n})`}}}};Ro.default=wh;});var Pu=x($o=>{Object.defineProperty($o,"__esModule",{value:true});var _h=Iu(),Rh=[_h.default];$o.default=Rh;});var Ou=x(Vt=>{Object.defineProperty(Vt,"__esModule",{value:true});Vt.contentVocabulary=Vt.metadataVocabulary=void 0;Vt.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];Vt.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"];});var Nu=x(Co=>{Object.defineProperty(Co,"__esModule",{value:true});var $h=Bi(),Ch=ru(),Eh=Au(),xh=Pu(),ju=Ou(),Th=[$h.default,Ch.default,(0, Eh.default)(),xh.default,ju.metadataVocabulary,ju.contentVocabulary];Co.default=Th;});var Du=x(gn=>{Object.defineProperty(gn,"__esModule",{value:true});gn.DiscrError=void 0;var qu;(function(e){e.Tag="tag",e.Mapping="mapping";})(qu||(gn.DiscrError=qu={}));});var Mu=x(xo=>{Object.defineProperty(xo,"__esModule",{value:true});var Bt=G(),Eo=Du(),Fu=Xr(),Ah=dr(),Ih=H(),Ph={message:({params:{discrError:e,tagName:t}})=>e===Eo.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:r}})=>(0, Bt._)`{error: ${e}, tag: ${r}, tagValue: ${t}}`},Oh={keyword:"discriminator",type:"object",schemaType:"object",error:Ph,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, Bt._)`${r}${(0, Bt.getProperty)(i)}`);t.if((0, Bt._)`typeof ${c} == "string"`,()=>l(),()=>e.error(false,{discrError:Eo.DiscrError.Tag,tag:c,tagName:i})),e.ok(u);function l(){let g=y();t.if(false);for(let f in g)t.elseIf((0, Bt._)`${c} === ${f}`),t.assign(u,d(g[f]));t.else(),e.error(false,{discrError:Eo.DiscrError.Mapping,tag:c,tagName:i}),t.endIf();}function d(g){let f=t.name("valid"),p=e.subschema({keyword:"oneOf",schemaProp:g},f);return e.mergeEvaluated(p,Bt.Name),f}function y(){var g;let f={},p=h(s),b=true;for(let w=0;w<a.length;w++){let S=a[w];if(S?.$ref&&!(0, Ih.schemaHasRulesButRef)(S,o.self.RULES)){let _=S.$ref;if(S=Fu.resolveRef.call(o.self,o.schemaEnv.root,o.baseId,_),S instanceof Fu.SchemaEnv&&(S=S.schema),S===void 0)throw new Ah.default(o.opts.uriResolver,o.baseId,_)}let $=(g=S?.properties)===null||g===void 0?void 0:g[i];if(typeof $!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${i}"`);b=b&&(p||h(S)),m($,w);}if(!b)throw new Error(`discriminator: "${i}" must be required`);return f;function h({required:w}){return Array.isArray(w)&&w.includes(i)}function m(w,S){if(w.const)v(w.const,S);else if(w.enum)for(let $ of w.enum)v($,S);else throw new Error(`discriminator: "properties/${i}" must have "const" or "enum"`)}function v(w,S){if(typeof w!="string"||w in f)throw new Error(`discriminator: "${i}" values must be unique strings`);f[w]=S;}}}};xo.default=Oh;});var Lu=x((qv,jh)=>{jh.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 Bu=x((se,To)=>{Object.defineProperty(se,"__esModule",{value:true});se.MissingRefError=se.ValidationError=se.CodeGen=se.Name=se.nil=se.stringify=se.str=se._=se.KeywordCxt=se.Ajv=void 0;var Nh=qi(),qh=Nu(),Dh=Mu(),Vu=Lu(),Fh=["/properties"],yn="http://json-schema.org/draft-07/schema",Gt=class extends Nh.default{_addVocabularies(){super._addVocabularies(),qh.default.forEach(t=>this.addVocabulary(t)),this.opts.discriminator&&this.addKeyword(Dh.default);}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let t=this.opts.$data?this.$dataMetaSchema(Vu,Fh):Vu;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)}};se.Ajv=Gt;To.exports=se=Gt;To.exports.Ajv=Gt;Object.defineProperty(se,"__esModule",{value:true});se.default=Gt;var Mh=cr();Object.defineProperty(se,"KeywordCxt",{enumerable:true,get:function(){return Mh.KeywordCxt}});var Kt=G();Object.defineProperty(se,"_",{enumerable:true,get:function(){return Kt._}});Object.defineProperty(se,"str",{enumerable:true,get:function(){return Kt.str}});Object.defineProperty(se,"stringify",{enumerable:true,get:function(){return Kt.stringify}});Object.defineProperty(se,"nil",{enumerable:true,get:function(){return Kt.nil}});Object.defineProperty(se,"Name",{enumerable:true,get:function(){return Kt.Name}});Object.defineProperty(se,"CodeGen",{enumerable:true,get:function(){return Kt.CodeGen}});var Lh=Wr();Object.defineProperty(se,"ValidationError",{enumerable:true,get:function(){return Lh.default}});var Vh=dr();Object.defineProperty(se,"MissingRefError",{enumerable:true,get:function(){return Vh.default}});});var Pr="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 oe(e){return `${Pr}${Vc(JSON.stringify(e))}`}function Re(e){if(!e.startsWith(Pr))throw new Error(`Invalid ref format (expected ${Pr}<base64url(json)>): ${e}`);let t;try{t=JSON.parse(Bc(e.slice(Pr.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 Ko(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=ue__namespace.join(e,".tmp");return P__namespace.mkdirSync(n,{recursive:true}),ue__namespace.join(n,`${t}-${Date.now()}-${Math.random().toString(36).slice(2,8)}${r}`)}function pt(...e){return ue__namespace.join(...e)}function zo(e){return ue__namespace.isAbsolute(e)}function On(){return crypto.randomUUID()}function Wo(e){return crypto.createHash("sha256").update(e).digest("hex")}function Yo(e){return ue__namespace.dirname(url.fileURLToPath(e))}function zc(e){if(typeof e=="object"&&e!==null){let{command:r,args:n=[],...s}=e,o=Jo(r,n);return {...s,command:o.command,args:o.args}}let t=Xo(e);if(t.length===0)throw new Error(`Empty command spec: ${JSON.stringify(e)}`);return Jo(t[0],t.slice(1))}function Jo(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 Xo(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 jn(e){return process.platform==="win32"&&/\.(cmd|bat)$/i.test(e)}function Qo(e,t){let{command:r,args:n=[],cwd:s,env:o,timeoutMs:a}=e;return child_process.execFileSync(r,n,{shell:jn(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:jn(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));}ue__namespace.join(Pn__namespace.tmpdir(),".board-live-cards-git-bash-cache.json");function jr(e){let{command:t,args:r=[]}=e;if(process.platform==="win32"){child_process.spawn(t,r,{detached:true,stdio:"ignore",windowsHide:true,shell:jn(t)}).unref();return}child_process.spawn(t,r,{detached:true,stdio:"ignore"}).unref();}function Nn(e,t,r){let n=ue__namespace.join(e,"board-live-cards-cli.js");if(P__namespace.existsSync(n))return {cmd:process.execPath,args:[n,t,...r]};let s=ue__namespace.join(e,"board-live-cards-cli.ts"),o=ue__namespace.join(e,"..","..","node_modules","tsx","dist","cli.mjs"),a=ue__namespace.join(e,"..","..","node_modules",".bin","tsx"),i=P__namespace.existsSync(o)?o:a;return P__namespace.existsSync(s)&&P__namespace.existsSync(i)?{cmd:process.execPath,args:[i,s,t,...r]}:{cmd:process.platform==="win32"?"npx.cmd":"npx",args:["tsx",s,t,...r]}}function qn(e){let t=ue__namespace.join(e,"..","..","..","dev","board-live-cards-cli.js");if(P__namespace.existsSync(t))return t;let r=ue__namespace.join(e,"..","..","dev","board-live-cards-cli.js");if(P__namespace.existsSync(r))return r;let n=ue__namespace.join(e,"board-live-cards-cli.js");if(P__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 Zo(e,t,r){let n=["--base-ref",oe(t)];r&&n.push("--notify-channel",r);let{cmd:s,args:o}=Nn(e,"process-accumulated-events",n);jr({command:s,args:o});}function Yc(e){return process.platform==="win32"?`\\\\.\\pipe\\${e}`:ue__namespace.join(Pn__namespace.tmpdir(),`${e}.sock`)}var Or=new Map;function ea(e,t,r){if(t.length===0)return;let n=t.map(i=>JSON.stringify(i)).join(`
|
|
8
|
+
deps: ${r}}`};var jm={keyword:"dependencies",type:"object",schemaType:"object",error:Ve.error,code(e){let[t,r]=Nm(e);du(e,t),lu(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 du(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, co._)`${u} && (${(0, _r.checkMissingProp)(e,i,o)})`),(0, _r.reportMissingProp)(e,o),r.else());}}Ve.validatePropertyDeps=du;function lu(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));}Ve.validateSchemaDeps=lu;Ve.default=jm;});var mu=x(lo=>{Object.defineProperty(lo,"__esModule",{value:true});var pu=G(),qm=H(),Dm={message:"property name must be valid",params:({params:e})=>(0, pu._)`{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, pu.not)(o),()=>{e.error(true),s.allErrors||t.break();});}),e.ok(o);}};lo.default=Fm;});var po=x(fo=>{Object.defineProperty(fo,"__esModule",{value:true});var ln=Te(),Ne=G(),Mm=Ue(),fn=H(),Lm={message:"must NOT have additional properties",params:({params:e})=>(0, Ne._)`{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),l=(0, ln.allSchemaProperties)(n.patternProperties);d(),e.ok((0, Ne._)`${o} === ${Mm.default.errors}`);function d(){t.forIn("key",s,k=>{!c.length&&!l.length?f(k):t.if(y(k),()=>f(k));});}function y(k){let h;if(c.length>8){let m=(0, fn.schemaRefOrVal)(a,n.properties,"properties");h=(0, ln.isOwnProperty)(t,m,k);}else c.length?h=(0, Ne.or)(...c.map(m=>(0, Ne._)`${k} === ${m}`)):h=Ne.nil;return l.length&&(h=(0, Ne.or)(h,...l.map(m=>(0, Ne._)`${(0, ln.usePattern)(e,m)}.test(${k})`))),(0, Ne.not)(h)}function g(k){t.code((0, Ne._)`delete ${s}[${k}]`);}function f(k){if(u.removeAdditional==="all"||u.removeAdditional&&r===false){g(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 h=t.name("valid");u.removeAdditional==="failing"?(p(k,h,false),t.if((0, Ne.not)(h),()=>{e.reset(),g(k);})):(p(k,h),i||t.if((0, Ne.not)(h),()=>t.break()));}}function p(k,h,m){let v={keyword:"additionalProperties",dataProp:k,dataPropType:fn.Type.Str};m===false&&Object.assign(v,{compositeRule:true,createErrors:false,allErrors:false}),e.subschema(v,h);}}};fo.default=Vm;});var yu=x(ho=>{Object.defineProperty(ho,"__esModule",{value:true});var Bm=cr(),hu=Te(),mo=H(),gu=po(),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&&gu.default.code(new Bm.KeywordCxt(o,gu.default,"additionalProperties"));let a=(0, hu.allSchemaProperties)(r);for(let d of a)o.definedProperties.add(d);o.opts.unevaluated&&a.length&&o.props!==true&&(o.props=mo.mergeEvaluated.props(t,(0, mo.toHash)(a),o.props));let i=a.filter(d=>!(0, mo.alwaysValidSchema)(o,r[d]));if(i.length===0)return;let u=t.name("valid");for(let d of i)c(d)?l(d):(t.if((0, hu.propertyInData)(t,s,d,o.opts.ownProperties)),l(d),o.allErrors||t.else().var(u,true),t.endIf()),e.it.definedProperties.add(d),e.ok(u);function c(d){return o.opts.useDefaults&&!o.compositeRule&&r[d].default!==void 0}function l(d){e.subschema({keyword:"properties",schemaProp:d,dataProp:d},u);}}};ho.default=Gm;});var Su=x(go=>{Object.defineProperty(go,"__esModule",{value:true});var vu=Te(),pn=G(),bu=H(),ku=H(),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, vu.allSchemaProperties)(r),u=i.filter(p=>(0, bu.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,l=t.name("valid");o.props!==true&&!(o.props instanceof pn.Name)&&(o.props=(0, ku.evaluatedPropsToName)(t,o.props));let{props:d}=o;y();function y(){for(let p of i)c&&g(p),o.allErrors?f(p):(t.var(l,true),f(p),t.if(l));}function g(p){for(let k in c)new RegExp(p).test(k)&&(0, bu.checkStrictMode)(o,`property ${k} matches pattern ${p} (use allowMatchingProperties)`);}function f(p){t.forIn("key",n,k=>{t.if((0, pn._)`${(0, vu.usePattern)(e,p)}.test(${k})`,()=>{let h=u.includes(p);h||e.subschema({keyword:"patternProperties",schemaProp:p,dataProp:k,dataPropType:ku.Type.Str},l),o.opts.unevaluated&&d!==true?t.assign((0, pn._)`${d}[${k}]`,true):!h&&!o.allErrors&&t.if((0, pn.not)(l),()=>t.break());});});}}};go.default=Km;});var wu=x(yo=>{Object.defineProperty(yo,"__esModule",{value:true});var Um=H(),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"}};yo.default=Jm;});var _u=x(vo=>{Object.defineProperty(vo,"__esModule",{value:true});var Hm=Te(),zm={keyword:"anyOf",schemaType:"array",trackErrors:true,code:Hm.validateUnion,error:{message:"must match a schema in anyOf"}};vo.default=zm;});var Ru=x(bo=>{Object.defineProperty(bo,"__esModule",{value:true});var mn=G(),Wm=H(),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((l,d)=>{let y;(0, Wm.alwaysValidSchema)(s,l)?t.var(u,true):y=e.subschema({keyword:"oneOf",schemaProp:d,compositeRule:true},u),d>0&&t.if((0, mn._)`${u} && ${a}`).assign(a,false).assign(i,(0, mn._)`[${i}, ${d}]`).else(),t.if(u,()=>{t.assign(a,true),t.assign(i,d),y&&e.mergeEvaluated(y,mn.Name);});});}}};bo.default=Xm;});var $u=x(ko=>{Object.defineProperty(ko,"__esModule",{value:true});var Qm=H(),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);});}};ko.default=Zm;});var xu=x(So=>{Object.defineProperty(So,"__esModule",{value:true});var hn=G(),Eu=H(),eh={message:({params:e})=>(0, hn.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0, hn._)`{failingKeyword: ${e.ifClause}}`},th={keyword:"if",schemaType:["object","boolean"],trackErrors:true,error:eh,code(e){let{gen:t,parentSchema:r,it:n}=e;r.then===void 0&&r.else===void 0&&(0, Eu.checkStrictMode)(n,'"if" without "then" and "else" is ignored');let s=Cu(n,"then"),o=Cu(n,"else");if(!s&&!o)return;let a=t.let("valid",true),i=t.name("_valid");if(u(),e.reset(),s&&o){let l=t.let("ifClause");e.setParams({ifClause:l}),t.if(i,c("then",l),c("else",l));}else s?t.if(i,c("then")):t.if((0, hn.not)(i),c("else"));e.pass(a,()=>e.error(true));function u(){let l=e.subschema({keyword:"if",compositeRule:true,createErrors:false,allErrors:false},i);e.mergeEvaluated(l);}function c(l,d){return ()=>{let y=e.subschema({keyword:l},i);t.assign(a,i),e.mergeValidEvaluated(y,a),d?t.assign(d,(0, hn._)`${l}`):e.setParams({ifClause:l});}}}};function Cu(e,t){let r=e.schema[t];return r!==void 0&&!(0, Eu.alwaysValidSchema)(e,r)}So.default=th;});var Tu=x(wo=>{Object.defineProperty(wo,"__esModule",{value:true});var rh=H(),nh={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:r}){t.if===void 0&&(0, rh.checkStrictMode)(r,`"${e}" without "if" is ignored`);}};wo.default=nh;});var Au=x(_o=>{Object.defineProperty(_o,"__esModule",{value:true});var sh=so(),oh=au(),ah=oo(),ih=uu(),uh=cu(),ch=fu(),dh=mu(),lh=po(),fh=yu(),ph=Su(),mh=wu(),hh=_u(),gh=Ru(),yh=$u(),vh=xu(),bh=Tu();function kh(e=false){let t=[mh.default,hh.default,gh.default,yh.default,vh.default,bh.default,dh.default,lh.default,ch.default,fh.default,ph.default];return e?t.push(oh.default,ih.default):t.push(sh.default,ah.default),t.push(uh.default),t}_o.default=kh;});var Iu=x(Ro=>{Object.defineProperty(Ro,"__esModule",{value:true});var ie=G(),Sh={message:({schemaCode:e})=>(0, ie.str)`must match format "${e}"`,params:({schemaCode:e})=>(0, ie._)`{format: ${e}}`},wh={keyword:"format",type:["number","string"],schemaType:"string",$data:true,error:Sh,code(e,t){let{gen:r,data:n,$data:s,schema:o,schemaCode:a,it:i}=e,{opts:u,errSchemaPath:c,schemaEnv:l,self:d}=i;if(!u.validateFormats)return;s?y():g();function y(){let f=r.scopeValue("formats",{ref:d.formats,code:u.code.formats}),p=r.const("fDef",(0, ie._)`${f}[${a}]`),k=r.let("fType"),h=r.let("format");r.if((0, ie._)`typeof ${p} == "object" && !(${p} instanceof RegExp)`,()=>r.assign(k,(0, ie._)`${p}.type || "string"`).assign(h,(0, ie._)`${p}.validate`),()=>r.assign(k,(0, ie._)`"string"`).assign(h,p)),e.fail$data((0, ie.or)(m(),v()));function m(){return u.strictSchema===false?ie.nil:(0, ie._)`${a} && !${h}`}function v(){let w=l.$async?(0, ie._)`(${p}.async ? await ${h}(${n}) : ${h}(${n}))`:(0, ie._)`${h}(${n})`,S=(0, ie._)`(typeof ${h} == "function" ? ${w} : ${h}.test(${n}))`;return (0, ie._)`${h} && ${h} !== true && ${k} === ${t} && !${S}`}}function g(){let f=d.formats[o];if(!f){m();return}if(f===true)return;let[p,k,h]=v(f);p===t&&e.pass(w());function m(){if(u.strictSchema===false){d.logger.warn(S());return}throw new Error(S());function S(){return `unknown format "${o}" ignored in schema at path "${c}"`}}function v(S){let $=S instanceof RegExp?(0, ie.regexpCode)(S):u.code.formats?(0, ie._)`${u.code.formats}${(0, ie.getProperty)(o)}`:void 0,_=r.scopeValue("formats",{key:o,ref:S,code:$});return typeof S=="object"&&!(S instanceof RegExp)?[S.type||"string",S.validate,(0, ie._)`${_}.validate`]:["string",S,_]}function w(){if(typeof f=="object"&&!(f instanceof RegExp)&&f.async){if(!l.$async)throw new Error("async format in sync schema");return (0, ie._)`await ${h}(${n})`}return typeof k=="function"?(0, ie._)`${h}(${n})`:(0, ie._)`${h}.test(${n})`}}}};Ro.default=wh;});var Pu=x($o=>{Object.defineProperty($o,"__esModule",{value:true});var _h=Iu(),Rh=[_h.default];$o.default=Rh;});var Ou=x(Vt=>{Object.defineProperty(Vt,"__esModule",{value:true});Vt.contentVocabulary=Vt.metadataVocabulary=void 0;Vt.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];Vt.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"];});var Nu=x(Co=>{Object.defineProperty(Co,"__esModule",{value:true});var $h=Bi(),Ch=ru(),Eh=Au(),xh=Pu(),ju=Ou(),Th=[$h.default,Ch.default,(0, Eh.default)(),xh.default,ju.metadataVocabulary,ju.contentVocabulary];Co.default=Th;});var Du=x(gn=>{Object.defineProperty(gn,"__esModule",{value:true});gn.DiscrError=void 0;var qu;(function(e){e.Tag="tag",e.Mapping="mapping";})(qu||(gn.DiscrError=qu={}));});var Mu=x(xo=>{Object.defineProperty(xo,"__esModule",{value:true});var Bt=G(),Eo=Du(),Fu=Xr(),Ah=dr(),Ih=H(),Ph={message:({params:{discrError:e,tagName:t}})=>e===Eo.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:r}})=>(0, Bt._)`{error: ${e}, tag: ${r}, tagValue: ${t}}`},Oh={keyword:"discriminator",type:"object",schemaType:"object",error:Ph,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, Bt._)`${r}${(0, Bt.getProperty)(i)}`);t.if((0, Bt._)`typeof ${c} == "string"`,()=>l(),()=>e.error(false,{discrError:Eo.DiscrError.Tag,tag:c,tagName:i})),e.ok(u);function l(){let g=y();t.if(false);for(let f in g)t.elseIf((0, Bt._)`${c} === ${f}`),t.assign(u,d(g[f]));t.else(),e.error(false,{discrError:Eo.DiscrError.Mapping,tag:c,tagName:i}),t.endIf();}function d(g){let f=t.name("valid"),p=e.subschema({keyword:"oneOf",schemaProp:g},f);return e.mergeEvaluated(p,Bt.Name),f}function y(){var g;let f={},p=h(s),k=true;for(let w=0;w<a.length;w++){let S=a[w];if(S?.$ref&&!(0, Ih.schemaHasRulesButRef)(S,o.self.RULES)){let _=S.$ref;if(S=Fu.resolveRef.call(o.self,o.schemaEnv.root,o.baseId,_),S instanceof Fu.SchemaEnv&&(S=S.schema),S===void 0)throw new Ah.default(o.opts.uriResolver,o.baseId,_)}let $=(g=S?.properties)===null||g===void 0?void 0:g[i];if(typeof $!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${i}"`);k=k&&(p||h(S)),m($,w);}if(!k)throw new Error(`discriminator: "${i}" must be required`);return f;function h({required:w}){return Array.isArray(w)&&w.includes(i)}function m(w,S){if(w.const)v(w.const,S);else if(w.enum)for(let $ of w.enum)v($,S);else throw new Error(`discriminator: "properties/${i}" must have "const" or "enum"`)}function v(w,S){if(typeof w!="string"||w in f)throw new Error(`discriminator: "${i}" values must be unique strings`);f[w]=S;}}}};xo.default=Oh;});var Lu=x((qv,jh)=>{jh.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 Bu=x((se,To)=>{Object.defineProperty(se,"__esModule",{value:true});se.MissingRefError=se.ValidationError=se.CodeGen=se.Name=se.nil=se.stringify=se.str=se._=se.KeywordCxt=se.Ajv=void 0;var Nh=qi(),qh=Nu(),Dh=Mu(),Vu=Lu(),Fh=["/properties"],yn="http://json-schema.org/draft-07/schema",Gt=class extends Nh.default{_addVocabularies(){super._addVocabularies(),qh.default.forEach(t=>this.addVocabulary(t)),this.opts.discriminator&&this.addKeyword(Dh.default);}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let t=this.opts.$data?this.$dataMetaSchema(Vu,Fh):Vu;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)}};se.Ajv=Gt;To.exports=se=Gt;To.exports.Ajv=Gt;Object.defineProperty(se,"__esModule",{value:true});se.default=Gt;var Mh=cr();Object.defineProperty(se,"KeywordCxt",{enumerable:true,get:function(){return Mh.KeywordCxt}});var Kt=G();Object.defineProperty(se,"_",{enumerable:true,get:function(){return Kt._}});Object.defineProperty(se,"str",{enumerable:true,get:function(){return Kt.str}});Object.defineProperty(se,"stringify",{enumerable:true,get:function(){return Kt.stringify}});Object.defineProperty(se,"nil",{enumerable:true,get:function(){return Kt.nil}});Object.defineProperty(se,"Name",{enumerable:true,get:function(){return Kt.Name}});Object.defineProperty(se,"CodeGen",{enumerable:true,get:function(){return Kt.CodeGen}});var Lh=Wr();Object.defineProperty(se,"ValidationError",{enumerable:true,get:function(){return Lh.default}});var Vh=dr();Object.defineProperty(se,"MissingRefError",{enumerable:true,get:function(){return Vh.default}});});var Pr="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 oe(e){return `${Pr}${Vc(JSON.stringify(e))}`}function Re(e){if(!e.startsWith(Pr))throw new Error(`Invalid ref format (expected ${Pr}<base64url(json)>): ${e}`);let t;try{t=JSON.parse(Bc(e.slice(Pr.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 Ko(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=ue__namespace.join(e,".tmp");return P__namespace.mkdirSync(n,{recursive:true}),ue__namespace.join(n,`${t}-${Date.now()}-${Math.random().toString(36).slice(2,8)}${r}`)}function pt(...e){return ue__namespace.join(...e)}function zo(e){return ue__namespace.isAbsolute(e)}function On(){return crypto.randomUUID()}function Wo(e){return crypto.createHash("sha256").update(e).digest("hex")}function Yo(e){return ue__namespace.dirname(url.fileURLToPath(e))}function zc(e){if(typeof e=="object"&&e!==null){let{command:r,args:n=[],...s}=e,o=Jo(r,n);return {...s,command:o.command,args:o.args}}let t=Xo(e);if(t.length===0)throw new Error(`Empty command spec: ${JSON.stringify(e)}`);return Jo(t[0],t.slice(1))}function Jo(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 Xo(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 jn(e){return process.platform==="win32"&&/\.(cmd|bat)$/i.test(e)}function Qo(e,t){let{command:r,args:n=[],cwd:s,env:o,timeoutMs:a}=e;return child_process.execFileSync(r,n,{shell:jn(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:jn(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));}ue__namespace.join(Pn__namespace.tmpdir(),".board-live-cards-git-bash-cache.json");function jr(e){let{command:t,args:r=[]}=e;if(process.platform==="win32"){child_process.spawn(t,r,{detached:true,stdio:"ignore",windowsHide:true,shell:jn(t)}).unref();return}child_process.spawn(t,r,{detached:true,stdio:"ignore"}).unref();}function Nn(e,t,r){let n=ue__namespace.join(e,"board-live-cards-cli.js");if(P__namespace.existsSync(n))return {cmd:process.execPath,args:[n,t,...r]};let s=ue__namespace.join(e,"board-live-cards-cli.ts"),o=ue__namespace.join(e,"..","..","node_modules","tsx","dist","cli.mjs"),a=ue__namespace.join(e,"..","..","node_modules",".bin","tsx"),i=P__namespace.existsSync(o)?o:a;return P__namespace.existsSync(s)&&P__namespace.existsSync(i)?{cmd:process.execPath,args:[i,s,t,...r]}:{cmd:process.platform==="win32"?"npx.cmd":"npx",args:["tsx",s,t,...r]}}function qn(e){let t=ue__namespace.join(e,"..","..","..","dev","board-live-cards-cli.js");if(P__namespace.existsSync(t))return t;let r=ue__namespace.join(e,"..","..","dev","board-live-cards-cli.js");if(P__namespace.existsSync(r))return r;let n=ue__namespace.join(e,"board-live-cards-cli.js");if(P__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 Zo(e,t,r){let n=["--base-ref",oe(t)];r&&n.push("--notify-channel",r);let{cmd:s,args:o}=Nn(e,"process-accumulated-events",n);jr({command:s,args:o});}function Yc(e){return process.platform==="win32"?`\\\\.\\pipe\\${e}`:ue__namespace.join(Pn__namespace.tmpdir(),`${e}.sock`)}var Or=new Map;function ea(e,t,r){if(t.length===0)return;let n=t.map(i=>JSON.stringify(i)).join(`
|
|
9
9
|
`)+`
|
|
10
10
|
`,s=Or.get(e);if(s&&!s.socket.destroyed){s.ready?s.socket.write(n):s.queue.push(n);return}let o=Yc(e),a=Ho__namespace.createConnection(o);s={socket:a,ready:false,queue:[n]},Or.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)}`),Or.delete(e);}),a.on("close",()=>{Or.delete(e);});}function Nr(){return {executeSync(e,t,r){return Qo({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=zc({command:e,args:t});return {cmd:r.command,args:r.args??[]}},splitCommand:Xo,spawnDetached(e,t){jr({command:e,args:t});}}}var ra=ue.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=ue.resolve(ra,"./jsonata-sync.cjs");return P.existsSync(e)?e:ue.resolve(ra,"../../card-compute/jsonata-sync.cjs")}var mt=td(rd());function Dn(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(mt(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=mt(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(mt(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=mt(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=mt(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:Re(e).value;switch(r){case "source-cli-task-executor":{let n=ue__namespace.join(t,"source-cli-task-executor.js");if(P__namespace.existsSync(n))return {command:process.execPath,args:[n]};let s=ue__namespace.join(t,"source-cli-task-executor.ts"),o=ue__namespace.join(t,"..","..","node_modules","tsx","dist","cli.mjs"),a=ue__namespace.join(t,"..","..","node_modules",".bin","tsx"),i=P__namespace.existsSync(o)?o:a;return P__namespace.existsSync(s)&&P__namespace.existsSync(i)?{command:process.execPath,args:[i,s]}:{command:process.execPath,args:[n]}}case "board-live-cards":{let{cmd:n,args:s}=Nn(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 sa(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: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 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 Fn(e,t){return sa(e,t)}function oa(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 aa(e){let t=e.whatToRun;return typeof t=="object"?t.value:Re(t).value}function ia(e,t){return {...t,whatToRun:aa(e),...e.extra?{extra:e.extra}:{}}}function Mn(e,t,r="invokeExecutionRef"){return Dn(e,t,r)}function ua(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 Ye(e){return {result:"failure",data:{error:e}}}function We(e,t,r){let n=r?.label??"invokeExecutionRefSync",s=r?.cliDir??r?.cwd??process.cwd(),o;try{o=Mn(e.argsMassaging,ia(e,t),n);}catch(d){let y=d instanceof Error?d.message:String(d);return Ye(y)}let a;try{a=Fn(e,s);}catch(d){let y=d instanceof Error?d.message:String(d);return Ye(`[${n}] ref resolution failed: ${y}`)}let i=[...a.baseArgs,...o.cmdArgs??[]],u=JSON.stringify(o.stdin??t),c=Nr(),l;try{l=c.executeSync(a.command,i,{timeout:r?.timeoutMs??3e4,encoding:"utf-8",cwd:r?.cwd,input:u});}catch(d){let y=d,g=(y.stderr?String(y.stderr):"").trim(),f=typeof y.status=="number"?y.status:"unknown",p=g||y.message;return Ye(`[${n}] ref exited with status ${f}${p?`: ${p}`:""}`)}try{return ua(oa(l))}catch{return {result:"success",data:{stdout:l.trim()}}}}async function na(e,t,r){let n=r?.label??"invokeExecutionRef",s;try{s=Mn(e.argsMassaging,ia(e,t),n);}catch(c){let l=c instanceof Error?c.message:String(c);return Ye(l)}let o=aa(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,l=new URLSearchParams(Object.entries(c).filter(([,d])=>d!=null).map(([d,y])=>[d,String(y)]));l.size>0&&(i=`${i}${i.includes("?")?"&":"?"}${l.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 d=await c.text().catch(()=>"");return Ye(`[${n}] HTTP ${c.status}${d?`: ${d}`:""}`)}let l=await c.text();if(!l.trim())return {result:"success",data:{}};try{return ua(oa(l))}catch{return {result:"success",data:{stdout:l.trim()}}}}catch(c){let l=c instanceof Error?c.message:String(c);return Ye(`[${n}] ${l}`)}}var ad={"local-node":async(e,t,r)=>We(e,t,r),"local-python":async(e,t,r)=>We(e,t,r),"local-process":async(e,t,r)=>We(e,t,r),"built-in":async(e,t,r)=>We(e,t,r),"http:post":na,"http:get":na},id={"local-node":We,"local-python":We,"local-process":We,"built-in":We};async function ca(e,t,r){let n=r?.transports?.[e.howToRun]??ad[e.howToRun];return n?n(e,t,r):Ye(`[${r?.label??"invokeExecutionRef"}] unsupported howToRun: ${e.howToRun}`)}function Ln(e,t,r){let n=r?.syncTransports?.[e.howToRun]??id[e.howToRun];return n?n(e,t,r):Ye(`[${r?.label??"invokeExecutionRefSync"}] unsupported sync howToRun: ${e.howToRun}`)}function ud(e){return {invoke(t,r){return ca(t,r,e)},invokeSync(t,r){return Ln(t,r,e)}}}function cd(e,t,r){return Ln(e,t,r)}async function dd(e,t){let r={...t,whatToRun:e.whatToRun},n=Dn(e.argsMassaging,r,"_invokeTaskExecutorHttp"),s=n.url??(typeof e.whatToRun=="object"?e.whatToRun.value:Re(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 l=await u.text().catch(()=>"");return {status:"error",error:`HTTP ${u.status}: ${l}`}}let c=await u.json().catch(()=>null);return c&&typeof c.status=="string"?c:{status:"success"}}function da(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}=sa(e,r),a=sd(t,e.extra);jr({command:s,args:[...o,...a]});}function ld(){return {read(e){if(!P__namespace.existsSync(e))return null;try{return P__namespace.readFileSync(e,"utf-8")}catch{return null}},write(e,t){P__namespace.mkdirSync(ue__namespace.dirname(e),{recursive:true}),P__namespace.writeFileSync(e,t,"utf-8");}}}function la(e){return ld();}function Wt(e,t){if(process.platform!=="win32"){P__namespace.renameSync(e,t);return}let r=[10,20,40,80,160];for(let n=0;n<=r.length;n++)try{P__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 qr(e){function t(s){return ue__namespace.join(e,...s.split("/"))}function r(s){return ue__namespace.relative(e,s).replace(/\\/g,"/")}function n(s,o){if(P__namespace.existsSync(s))for(let a of P__namespace.readdirSync(s,{withFileTypes:true})){let i=ue__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(!P__namespace.existsSync(o))return null;try{return P__namespace.readFileSync(o,"utf-8")}catch{return null}},write(s,o){let a=t(s),i=`${a}.${process.pid}.${crypto.randomUUID()}.tmp`;P__namespace.mkdirSync(ue__namespace.dirname(a),{recursive:true}),P__namespace.writeFileSync(i,o,"utf-8"),Wt(i,a);},exists(s){return P__namespace.existsSync(t(s))},remove(s){let o=t(s);try{P__namespace.existsSync(o)&&P__namespace.unlinkSync(o);}catch{}},readBytes(s){let o=t(s);if(!P__namespace.existsSync(o))return null;try{return new Uint8Array(P__namespace.readFileSync(o))}catch{return null}},writeBytes(s,o){let a=t(s),i=`${a}.${process.pid}.${crypto.randomUUID()}.tmp`;P__namespace.mkdirSync(ue__namespace.dirname(a),{recursive:true}),P__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(!P__namespace.existsSync(o))return null;try{let a=P__namespace.statSync(o);return {key:s,size:Number(a.size||0),updatedAt:new Date(a.mtimeMs).toISOString()}}catch{return null}}}}function Gn(){return {read(e){if(!P__namespace.existsSync(e))return null;try{return P__namespace.readFileSync(e,"utf-8")}catch{return null}},write(e,t){let r=`${e}.${process.pid}.${crypto.randomUUID()}.tmp`;P__namespace.mkdirSync(ue__namespace.dirname(e),{recursive:true}),P__namespace.writeFileSync(r,t,"utf-8"),Wt(r,e);},exists(e){return P__namespace.existsSync(e)},remove(e){try{P__namespace.existsSync(e)&&P__namespace.unlinkSync(e);}catch{}},readBytes(e){if(!P__namespace.existsSync(e))return null;try{return new Uint8Array(P__namespace.readFileSync(e))}catch{return null}},writeBytes(e,t){let r=`${e}.${process.pid}.${crypto.randomUUID()}.tmp`;P__namespace.mkdirSync(ue__namespace.dirname(e),{recursive:true}),P__namespace.writeFileSync(r,Buffer.from(t)),Wt(r,e);},stat(e){if(!P__namespace.existsSync(e))return null;try{let t=P__namespace.statSync(e);return {key:e,size:Number(t.size||0),updatedAt:new Date(t.mtimeMs).toISOString()}}catch{return null}}}}function Kn(e){function t(n){return ue__namespace.join(e,...n.split("/"))+".json"}function r(n,s,o,a){if(P__namespace.existsSync(n))for(let i of P__namespace.readdirSync(n,{withFileTypes:true})){let u=s?`${s}/${i.name}`:i.name;if(i.isDirectory()){r(ue__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(!P__namespace.existsSync(s))return null;try{return JSON.parse(P__namespace.readFileSync(s,"utf-8"))}catch{return null}},write(n,s){let o=t(n),a=`${o}.${process.pid}.${crypto.randomUUID()}.tmp`;P__namespace.mkdirSync(ue__namespace.dirname(o),{recursive:true}),P__namespace.writeFileSync(a,JSON.stringify(s,null,2),"utf-8"),Wt(a,o);},delete(n){let s=t(n);try{P__namespace.existsSync(s)&&P__namespace.unlinkSync(s);}catch{}},listKeys(n){let s=[];return r(e,"",n,s),s.sort()}}}function Bn(e){if(e==null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return `[${e.map(Bn).join(",")}]`;let t=e;return `{${Object.keys(t).sort().map(n=>`${JSON.stringify(n)}:${Bn(t[n])}`).join(",")}}`}function fa(e){return crypto.createHash("sha256").update(Bn(e)).digest("hex")}function pa(e){let t=ue__namespace.join(e,"board-journal.jsonl");return {readAllEntries(){if(!P__namespace.existsSync(t))return [];let r=P__namespace.readFileSync(t,"utf-8").trim();return r?r.split(`
|
|
11
11
|
`).filter(Boolean).map(n=>JSON.parse(n)):[]},appendEntry(r){P__namespace.appendFileSync(t,JSON.stringify(r)+`
|
|
12
|
-
`,"utf-8");},generateId(){return crypto.randomUUID()}}}function ma(e){return {tryAcquire(){try{if(!P__namespace.existsSync(e)){P__namespace.mkdirSync(ue__namespace.dirname(e),{recursive:!0});try{P__namespace.writeFileSync(e,"{}",{flag:"wx"});}catch{}}return properLockfile.lockSync(e,{retries:0})}catch{return null}}}}var ha={$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 Uu=Lc(Bu());var Kh=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))),Uh=Kh("./jsonata-sync.cjs"),vn=null;var Gu=/\b(card_data|requires|fetched_sources|computed_values|source_defs)\b/g,Jh=/^\s*(card_data|requires|fetched_sources|computed_values|source_defs)(\.|$)/;function Hh(e){let t=new Set,r;for(Gu.lastIndex=0;(r=Gu.exec(e))!==null;)t.add(r[1]);return t}function Ju(e){let t=Jh.exec(e);return t?t[1]:null}function Ku(e,t,r,n){try{Uh(e);}catch(o){let a=o instanceof Error?o.message:String(o);n.push(`${t}: invalid JSONata expression (${a})`);return}let s=Hh(e);for(let o of s)r.has(o)||n.push(`${t}: disallowed namespace "${o}" in expression`);}function Ao(e,t,r){if(Array.isArray(e)){e.forEach((s,o)=>{Ao(s,`${t}/${o}`,r);});return}if(typeof e=="string"){let s=Ju(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))Ao(o,`${t}/${s}`,r);}function zh(){if(vn)return vn;let e=new Uu.default({allErrors:true});return Bh__default.default(e),vn=e.compile(ha),vn}function Hu(e){let t=zh(),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 zu(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,l)=>{if(!c||typeof c!="object"||Array.isArray(c))return;let d=c.expr;typeof d!="string"||d.trim().length===0||Ku(d,`/compute/${l}/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,l)=>{if(!c||typeof c!="object"||Array.isArray(c))return;let d=c.ref;if(typeof d!="string"||d.trim().length===0)return;let y=Ju(d);y===null?t.push(`/provides/${l}/ref: path "${d}" must start with a valid namespace (${[...s].join(", ")})`):s.has(y)||t.push(`/provides/${l}/ref: disallowed namespace "${y}" in path "${d}" (valid: ${[...s].join(", ")})`);});let a=r.view;a&&typeof a=="object"&&!Array.isArray(a)&&Ao(a,"/view",t);let i=new Set(["card_data","requires"]),u=r.source_defs;return Array.isArray(u)&&u.forEach((c,l)=>{if(!c||typeof c!="object"||Array.isArray(c))return;let d=c.projections;if(!(!d||typeof d!="object"||Array.isArray(d)))for(let[y,g]of Object.entries(d))typeof g!="string"||g.trim().length===0||Ku(g,`/source_defs/${l}/projections/${y}`,i,t);}),{ok:t.length===0,errors:t}}function Io(e){let t=Hu(e);if(!t.ok)return t;let r=zu(e);return r.ok?{ok:true,errors:[]}:{ok:false,errors:r.errors}}var ot={RUNNING:"running",COMPLETED:"completed",FAILED:"failed",INACTIVATED:"inactivated"};function $e(e){return e?Array.isArray(e.provides)?e.provides:[]:[]}function at(e){return e?Array.isArray(e.requires)?e.requires:[]:[]}function Wu(e){return e.tasks??{}}function Po(e){return e?e.status===ot.FAILED||e.status===ot.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===ot.COMPLETED){let o=e.tasks[n];o&&$e(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;$e(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=at(a);for(let u of i)for(let[c,l]of Object.entries(r.tasks))if($e(l).includes(u)){let d=e.tasks[c];d?.lastDataHash&&(s[u]=d.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=$e(i);let c=a.startConsumedHashes?{...a.startConsumedHashes}:{...a.lastConsumedHashes};if(!a.startConsumedHashes){let y=i.requires??[];for(let g of y)for(let[f,p]of Object.entries(t.tasks))if($e(p).includes(g)){let b=e.tasks[f];b?.lastDataHash&&(c[g]=b.lastDataHash);break}}let l={...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},d=[...new Set([...e.availableOutputs,...u])];return {...e,tasks:{...e.tasks,[r]:l},availableOutputs:d,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 Wh(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:rg(n,t.action)};case "task-upsert":return Yh(e,t.taskName,t.taskConfig);case "task-removal":return Xh(e,t.taskName);case "node-requires-add":return Qh(e,t.nodeName,t.tokens);case "node-requires-remove":return Zh(e,t.nodeName,t.tokens);case "node-provides-add":return eg(e,t.nodeName,t.tokens);case "node-provides-remove":return tg(e,t.nodeName,t.tokens);default:return e}}function oc(e,t){return t.reduce((r,n)=>Wh(r,n),e)}function Yh(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 Xh(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 Qh(e,t,r){let n=e.config.tasks[t];if(!n)return e;let s=at(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 Zh(e,t,r){let n=e.config.tasks[t];if(!n)return e;let s=at(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 eg(e,t,r){let n=e.config.tasks[t];if(!n)return e;let s=$e(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 tg(e,t,r){let n=e.config.tasks[t];if(!n)return e;let s=$e(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 rg(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 $r(e){let{config:t,state:r}=e,n=Wu(t);if(Object.keys(n).length===0)return {eligible:[],pending:[],unresolved:[],blocked:[],conflicts:{}};let o=ng(n),a=Qu(t,r.tasks),i=new Set([...a,...r.availableOutputs]),u=[],c=[],l=[],d=[];for(let[g,f]of Object.entries(n)){let p=r.tasks[g],b=Yu(f,t.settings),h=b!=="once";if(p?.status===ot.RUNNING||Po(p))continue;let m=Xu(f);if(m!==void 0&&p&&p.executionCount>=m||f.circuit_breaker&&p&&p.executionCount>=f.circuit_breaker.max_executions||!h&&p?.status===ot.COMPLETED)continue;if(h&&p?.status===ot.COMPLETED){let _=at(f),C=false;switch(b){case "data-changed":{_.length>0&&_.some(q=>{for(let[F,re]of Object.entries(n))if($e(re).includes(q)){let U=r.tasks[F];if(!U)continue;let ce=p.lastConsumedHashes?.[q];return U.lastDataHash==null?U.executionCount>p.lastEpoch:U.lastDataHash!==ce}return false})||(C=true);break}case "epoch-changed":{_.length>0&&_.some(q=>{for(let[F,re]of Object.entries(n))if($e(re).includes(q)){let U=r.tasks[F];if(U&&U.executionCount>p.lastEpoch)return true}return false})||(C=true);break}case "time-based":{let N=f.refreshInterval??0;if(N<=0){C=true;break}let q=p.completedAt;if(!q){C=true;break}(Date.now()-Date.parse(q))/1e3<N&&(C=true);break}case "manual":C=true;break}if(C)continue}let v=at(f);if(v.length===0){u.push(g);continue}let w=[],S=[],$=[];for(let _ of v){if(i.has(_))continue;let C=o[_]||[];C.length===0?w.push(_):C.every(q=>Po(r.tasks[q]))?$.push({token:_,failedProducer:C[0]}):S.push(_);}w.length>0?l.push({taskName:g,missingTokens:w}):$.length>0?d.push({taskName:g,failedTokens:$.map(_=>_.token),failedProducers:[...new Set($.map(_=>_.failedProducer))]}):S.length>0?c.push({taskName:g,waitingOn:S}):u.push(g);}let y={};if(u.length>1){let g=Zu(u,n);for(let[f,p]of Object.entries(g))p.length>1&&(y[f]=p);}return {eligible:u,pending:c,unresolved:l,blocked:d,conflicts:y}}function ng(e){let t={};for(let[r,n]of Object.entries(e)){for(let s of $e(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 Cr=class{buffer=[];append(t){this.buffer.push(t);}drain(){let t=this.buffer;return this.buffer=[],t}get size(){return this.buffer.length}};function Oo(e){let t=jo(e);return sg(t)}function jo(e){if(e==null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return "["+e.map(jo).join(",")+"]";let t=e;return "{"+Object.keys(t).sort().map(n=>JSON.stringify(n)+":"+jo(t[n])).join(",")+"}"}function sg(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 og(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 ag(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 og(t)}function ig(e){try{let t=JSON.parse(ag(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 Cr,a="state"in e&&"config"in e?e:bn(e),i=false,u=new Set,c=new Map(Object.entries(n)),l=new Cr,d=false,y=false;function g(){if(!i){if(d){y=true;return}d=true;try{do y=!1,f();while(y)}finally{d=false;}}}function f(){let m=l.drain(),v=o.drain(),w=[...m,...v];w.length>0&&(a=oc(a,w));let S=$r(a);w.length>0&&s?.(w,a,S);for(let $ of S.eligible)h($);for(let $ of w)if($.type==="task-progress"){let{taskName:_,update:C}=$;if(!a.config.tasks[_])continue;let q=a.state.tasks[_];if(!q||q.status!=="running")continue;let F=ic(_),re=b(_,F,C).catch(U=>{i||(l.append({type:"task-failed",taskName:_,error:U.message??String(U),timestamp:new Date().toISOString()}),g());}).finally(()=>{u.delete(re);});u.add(re);}}function p(m){let w=a.config.tasks[m].requires??[],S=new Map;for(let[_,C]of Object.entries(a.config.tasks))for(let N of C.provides??[])S.set(N,_);let $={};for(let _ of w){let C=S.get(_);C?$[_]=a.state.tasks[C]?.data:$[_]=void 0;}return $}async function b(m,v,w){let S=a.config.tasks[m],$=S.taskHandlers??[],_=p(m);for(let C of $){let N=c.get(C);if(!N)throw new Error(`Handler '${C}' not found in registry (task '${m}')`);let q={nodeId:m,state:_,taskState:a.state.tasks[m],config:S,callbackToken:v,update:w};if(await N(q)==="task-initiate-failure")throw new Error(`Handler '${C}' returned task-initiate-failure (task '${m}')`)}}function h(m){let w=a.config.tasks[m]?.taskHandlers;if(!w||w.length===0)return;l.append({type:"task-started",taskName:m,timestamp:new Date().toISOString()}),g();let S=ic(m),$=b(m,S).catch(_=>{i||(l.append({type:"task-failed",taskName:m,error:_.message??String(_),timestamp:new Date().toISOString()}),g());}).finally(()=>{u.delete($);});u.add($);}return {push(m){i||(m.type==="task-completed"&&m.data&&!m.dataHash&&(m={...m,dataHash:Oo(m.data)}),o.append(m),g());},pushAll(m){if(!i){for(let v of m)v.type==="task-completed"&&v.data&&!v.dataHash?o.append({...v,dataHash:Oo(v.data)}):o.append(v);g();}},resolveCallback(m,v,w){if(i)return;let S=ig(m);if(!S)return;let{taskName:$}=S;if(a.config.tasks[$]){if(w&&w.length>0)o.append({type:"task-failed",taskName:$,error:w.join("; "),timestamp:new Date().toISOString()});else {let _=v&&Object.keys(v).length>0?Oo(v):void 0;o.append({type:"task-completed",taskName:$,data:v,dataHash:_,timestamp:new Date().toISOString()});}g();}},addNode(m,v){i||(o.append({type:"task-upsert",taskName:m,taskConfig:v,timestamp:new Date().toISOString()}),g());},removeNode(m){i||(o.append({type:"task-removal",taskName:m,timestamp:new Date().toISOString()}),g());},addRequires(m,v){i||(o.append({type:"node-requires-add",nodeName:m,tokens:v,timestamp:new Date().toISOString()}),g());},removeRequires(m,v){i||(o.append({type:"node-requires-remove",nodeName:m,tokens:v,timestamp:new Date().toISOString()}),g());},addProvides(m,v){i||(o.append({type:"node-provides-add",nodeName:m,tokens:v,timestamp:new Date().toISOString()}),g());},removeProvides(m,v){i||(o.append({type:"node-provides-remove",nodeName:m,tokens:v,timestamp:new Date().toISOString()}),g());},registerHandler(m,v){c.set(m,v);},unregisterHandler(m){c.delete(m);},retrigger(m){i||a.config.tasks[m]&&(o.append({type:"task-restart",taskName:m,timestamp:new Date().toISOString()}),g());},retriggerAll(m){if(!i){for(let v of m)a.config.tasks[v]&&o.append({type:"task-restart",taskName:v,timestamp:new Date().toISOString()});g();}},snapshot(){return Rr(a)},getState(){return a},getSchedule(){return $r(a)},async waitForHandlers(){u.size>0&&await Promise.allSettled([...u]);},async dispose(m){m?.wait&&u.size>0&&await Promise.allSettled([...u]),i=true;}}}var cg=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=cg("./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 dg(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 lg(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 fg(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 pg(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"]),mg=new Set(["id","meta","requires","provides","view","card_data","compute","source_defs"]);function hg(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))mg.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 gg(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 yg(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 it={run:dg,runSync:lg,eval:fg,resolve:pg,validate:hg,enrichSources:gg,enrichSourcesSync:yg};function vg(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:oe({kind:"fs-path",value:e}),...t?{extra:t}:{}}}function _n(e){return JSON.stringify(e)}function Rn(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 l=0;l<i.length-1;l++){let d=i[l],y=c[d],g=y&&typeof y=="object"&&!Array.isArray(y)?{...y}:{};c[d]=g,c=g;}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 l=n(c,o,a),d=e.writeCard(u.key,l);i[s]={key:u.key,checksum:d,updatedAt:new Date().toISOString()},e.writeIndex(i);},removeCard(s){let o=r();o[s]&&(delete o[s],e.writeIndex(o));},readIndex(){return r()}}}function No(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 gc(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",ut="board/graph",yc="board/lastJournalProcessedId";function pc(e){return `cards/${e}/runtime`}function vc(e){return {readRuntime(t){return e.read(pc(t))??{_sources:{}}},writeRuntime(t,r){e.write(pc(t),r);}}}function kg(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=kg(n.values,r);return {ok:true,newVersion:e.writeValues(t,s,r.deleteKeys)}}}}function qo(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 Rn(r.trim())},writeTaskExecutorRef(r){e.write("task-executor",_n(r));},readChatHandlerRef(){let r=t("chat-handler");if(r?.trim())return Rn(r.trim())},writeChatHandlerRef(r){e.write("chat-handler",_n(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);},readChatHandler(){return t("chat-handler")?.trim()||void 0},writeChatHandler(r){e.write("chat-handler",r);}}}function bc(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 bg(e){return e?.lastRequestedAt?!e.lastFetchedAt||e.lastFetchedAt<e.lastRequestedAt:false}function Sg(e,t){return e?.lastRequestedAt?bg(e)?"in-flight":!e.lastFetchedAt||e.lastFetchedAt<t?"dispatch":"idle":"dispatch"}function wg(e,t){let r={...e,lastFetchedAt:t};return delete r.lastError,r}function mc(e,t){let r={...e,lastError:t};return delete r.lastFetchedAt,r}function Cn(e,t){let r=t.state.tasks,n=t.config.tasks,s=Object.keys(r),o=$r(t),a={completed:0,failed:0,in_progress:0,pending:0,blocked:0,unresolved:0},i=new Map;for(let f of o.pending)i.set(f.taskName,f.waitingOn);for(let f of o.unresolved)i.set(f.taskName,f.missingTokens);for(let f of o.blocked)i.set(f.taskName,f.failedTokens);let u=new Map;for(let[f,p]of Object.entries(n))for(let b of p.requires??[]){let h=u.get(b)??[];h.push(f),u.set(b,h);}let c=s.sort().map(f=>{let p=r[f],b=n[f]??{requires:[],provides:[]};p.status==="completed"?a.completed+=1:p.status==="failed"?a.failed+=1:p.status==="in-progress"&&(a.in_progress+=1);let h=b.requires??[],m=b.provides??[],v=Object.keys(p.data??{}).sort(),w=h.filter(q=>t.state.availableOutputs.includes(q)),S=h.filter(q=>!t.state.availableOutputs.includes(q)),$=i.get(f)??S,_=new Set;for(let q of m)for(let F of u.get(q)??[])F!==f&&_.add(F);let C=p.failedAt,N=p.error?{message:p.error,code:"TASK_FAILED",at:C,source:"task-runtime"}:void 0;return {name:f,status:p.status,error:N,requires:h,requires_satisfied:w,requires_missing:S,provides_declared:m,provides_runtime:v,blocked_by:$,unblocks:Array.from(_).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 l=c.map(f=>({name:f.name,fanOut:f.unblocks.length})).sort((f,p)=>p.fanOut-f.fanOut||f.name.localeCompare(p.name)),d=l.length>0?l[0]:{name:null,fanOut:0},y=new Set;for(let f of Object.values(n))for(let p of f.requires??[])y.add(p);let g=0;for(let[f,p]of Object.entries(n)){let b=(p.requires??[]).length===0,m=(p.provides??[]).some(v=>(u.get(v)??[]).some(w=>w!==f));b&&!m&&(g+=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:g,topology:{edge_count:Array.from(y).length,max_fan_out_card:d.name,max_fan_out:d.fanOut}},cards:c}}function _g(){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 l=c.id,d=c.card_data??{},y=c.source_defs??[],g=y.filter(M=>M.optionalForCompletionGating!==true),f=r.cardRuntimeStore.readRuntime(l),p=false,b=()=>{p&&(r.cardRuntimeStore.writeRuntime(l,f),p=false);},h=M=>({...f._sources[M]??{}}),m=(M,V)=>{f._sources[M]=V,p=true;},v=i.taskState?.executionCount??0,w=f._lastExecutionCount;if(typeof w=="number"&&w!==v&&(f._sources={},p=true),w!==v&&(f._lastExecutionCount=v,p=true),i.update){let M=i.update,V=M.outputFile;if(V){let R=h(V);if(M.failure)m(V,mc(R,M.reason??"unknown"));else {let k=M.rqt;if(!R.lastFetchedAt||k>R.lastFetchedAt){let E=typeof M.deliveryToken=="string"?M.deliveryToken:void 0,A=false;E&&(A=r.fetchedSourcesStore.commitSourceData(l,V,E)),A?m(V,wg(R,k)):m(V,mc(R,`source delivery commit failed for ${V} token=${String(E)}`));}}b();}}let S={};for(let M of y)if(M.outputFile){let V=r.fetchedSourcesStore.readSourceData(l,M.outputFile);V!==null&&(S[M.bindTo]=V);}let $={};for(let[M,V]of Object.entries(i.state??{}))if(V!==null&&typeof V=="object"&&!Array.isArray(V)){let R=V[M];$[M]=R!==void 0?R:V;}else $[M]=V;let _={id:l,card_data:{...d},requires:$,source_defs:y,compute:c.compute};_._sourcesData=S,c.compute&&it.runSync(_,{sourcesData:S}),(o??r.outputStore.writeComputedValues.bind(r.outputStore))(l,_.computed_values??{});let C={...c},N=it.enrichSourcesSync(Array.isArray(c.source_defs)?c.source_defs:void 0,{card_data:c.card_data,requires:$}),q=e.value;C.source_defs=Array.isArray(N)?N.map(M=>({...M,boardDir:typeof M.boardDir=="string"&&M.boardDir?M.boardDir:q})):N;let F=_g(),re=i.update?void 0:F,U=g.filter(M=>{let V=M.outputFile;if(typeof V!="string"||!V)return true;let R=h(V);re&&(R={...R,queueRequestedAt:re},m(V,R));let k=R.queueRequestedAt??R.lastRequestedAt??F,E=Sg(R,k);return E==="in-flight"?false:E==="dispatch"});if(b(),U.length>0){let M=false,V=F;for(let R of U){let k=R.outputFile;if(typeof k!="string"||!k)continue;let E=h(k),A=E.queueRequestedAt??F;m(k,{...E,lastRequestedAt:A}),V=A,M=true;}return M&&b(),M&&(u.push({taskKind:"source-fetch",payload:{boardRef:oe(e),enrichedCard:C,callbackToken:i.callbackToken,rqt:V}}),r.executionRequestStore.appendEntries(t,u)),"task-initiated"}let ce=c.provides??[],qe={};for(let{bindTo:M,ref:V}of ce)qe[M]=it.resolve(_,V);return (a??r.outputStore.writeDataObjects.bind(r.outputStore))(qe),y.filter(M=>{if(M.optionalForCompletionGating!==true)return false;let V=h(M.outputFile);return !V.lastRequestedAt||!V.lastFetchedAt?true:V.lastFetchedAt<=V.lastRequestedAt}).length>0&&u.push({taskKind:"source-fetch",payload:{boardRef:oe(e),enrichedCard:C,callbackToken:i.callbackToken,rqt:F}}),n(i.nodeId,qe),u.length>0&&r.executionRequestStore.appendEntries(t,u),"task-initiated"}}var En={settings:{completion:"manual",refreshStrategy:"data-changed"},tasks:{}};function wc(e){return {[ut]:e.graph,[yc]:e.lastDrainedJournalId}}function _c(e){let t=e[ut],r=e[yc];if(!t||typeof t!="object")throw new Error(`State snapshot is missing required key: ${ut}`);return {graph:t,lastDrainedJournalId:typeof r=="string"?r:""}}function Rc(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 Q(e){return e!==void 0?{status:"success",data:e}:{status:"success"}}function j(e){return {status:"fail",error:e}}function ee(e){return {status:"error",error:e instanceof Error?e.message:String(e)}}function Rg(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 Cc(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 xn(e){try{let t=JSON.parse(Cc(e));return typeof t?.t=="string"?{taskName:t.t}:null}catch{return null}}function $g(e){return Rg(JSON.stringify(e))}function $c(e){try{let t=JSON.parse(Cc(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 Cg(e,t){let r=t.onWarn??(()=>{}),n=oe(e);function s(R){if(R.length!==0)try{let k=t.publishBoardChangeNotifications?.(R);k&&typeof k.catch=="function"&&k.catch(E=>r(`[board-live-cards-public] publishBoardChangeNotifications failed: ${E instanceof Error?E.message:String(E)}`));}catch(k){r(`[board-live-cards-public] publishBoardChangeNotifications failed: ${k instanceof Error?k.message:String(k)}`);}}function o(){let R=i().readCardStoreRef();if(!R)throw new Error(`Board at ${e.value} has no card store configured. Run: init --base-ref <ref> --store-ref <b64-ref>`);let k=t.kvStorageForRef(R);return {readIndex(){return k.read("_index")},writeIndex(E){k.write("_index",E);},readCard(E){return k.read(E)},writeCard(E,A){return k.write(E,A),t.hashFn(A)},cardExists(E){return k.read(E)!==null},defaultCardKey(E){return E}}}let a={readValues(R){let k=t.kvStorage("state-snapshot"),E=k.listKeys().sort();if(E.length===0)return {version:null,values:{}};let A={};for(let Y of E)A[Y]=k.read(Y);return {version:t.hashFn(A),values:A}},writeValues(R,k,E){let A=t.kvStorage("state-snapshot");for(let Y of E)A.delete(Y);for(let[Y,te]of Object.entries(k))A.write(Y,te);return t.hashFn(k)}},i=()=>qo(t.kvStorage("config")),u=()=>kc(a),c=()=>hc(t.journalAdapter()),l=()=>$n(o(),r),d=()=>{let R=i().readOutputsStoreRef();if(!R)throw new Error(`Board at ${e.value} has no outputs store configured. Run: init --outputs-store-ref <b64-ref>`);return bc(t.kvStorageForRef(R))};function y(){return !!u().readSnapshot(e.value).values[ut]}function g(){let R=u().readSnapshot(e.value);if(!R.values[ut])throw new Error(`Board not initialized at ${e.value}`);return _c(R.values)}function f(R,k){let E=u().commitSnapshot(e.value,{schemaVersion:Er,expectedVersion:k,commitId:t.genId(),committedAt:Ce(),deleteKeys:[],shallowMerge:wc(R)});if(!E.ok)throw new Error(`Snapshot commit failed (version mismatch): expected=${k??"null"} current=${E.currentVersion??"null"}`)}function p(R){c().appendEvent(R);}async function b(){let R=(I,D)=>{let ae=I.payload,ze=(ae?.enrichedCard??{}).id??ae?.cardId??"unknown";p({type:"task-failed",taskName:ze,error:D,timestamp:Ce()});},k=gc(t.kvStorage("execution-requests"),R),E=vc(t.kvStorage("card-runtime")),A=No(t.blobStorage("sources"),I=>t.resolveBlob(I)),Y=new Map,te={readRuntime(I){return Y.get(I)??E.readRuntime(I)},writeRuntime(I,D){Y.set(I,D);}},we=[],_e=new Map,Be={readSourceData(I,D){let ae=`${I}/${D}`;return _e.has(ae)?_e.get(ae):A.readSourceData(I,D)},ingestSourceDataStaged(I,D,ae,Et){A.ingestSourceDataStaged(I,D,ae,Et);},commitSourceData(I,D,ae){let Et=`${I}/.staged/${ae}/${D}`,Ir=t.blobStorage("sources").read(Et);if(Ir==null)return false;let xt=`${I}/${D}`,Bo=Ir.trim();try{_e.set(xt,JSON.parse(Bo));}catch{_e.set(xt,Bo);}return we.push({cardId:I,outputFile:D,deliveryToken:ae}),true},hasSource(I,D){let ae=`${I}/${D}`;return _e.has(ae)?true:A.hasSource(I,D)}},De={cardStore:l(),cardRuntimeStore:te,fetchedSourcesStore:Be,outputStore:d(),executionRequestStore:k},dt=g(),lt=Sn(dt.graph),{events:$t,newCursor:Ct}=c().readEntriesAfterCursor(dt.lastDrainedJournalId),ft=[],An=[],In=[],Mo=new Map,Ic=(I,D)=>{ft.push({type:"task-completed",taskName:I,data:D,timestamp:Ce()});},Lo=(I,D)=>p({type:"task-failed",taskName:I,error:D,timestamp:Ce()}),Tr=uc(lt,{handlers:{"card-handler":Sc(e,Ct,De,Ic,Lo,(I,D)=>{An.push({cardId:I,values:D});},I=>{In.push(I);})}});for(ft=$t;ft.length>0;){let I=ft;ft=[];for(let D of I)if(D.type==="task-restart"){let ae=De.cardStore.readCard(D.taskName);ae&&Mo.set(D.taskName,ae);}Tr.pushAll(I),await Tr.waitForHandlers();}let Vo=Tr.getState();await Tr.dispose({wait:true});let Pc=u().readSnapshot(e.value).version;f({lastDrainedJournalId:Ct,graph:Rr(Vo)},Pc);for(let{cardId:I,values:D}of An)De.outputStore.writeComputedValues(I,D);for(let I of In)De.outputStore.writeDataObjects(I);for(let[I,D]of Y)E.writeRuntime(I,D);for(let{cardId:I,outputFile:D,deliveryToken:ae}of we)A.commitSourceData(I,D,ae);let Ar;try{Ar=Cn(n,Vo),De.outputStore.writeStatusSnapshot(Ar);}catch(I){r(`[board-live-cards-public] status publish failed: ${I instanceof Error?I.message:String(I)}`);}let Ut=[];for(let{cardId:I,values:D}of An)Ut.push({kind:"computed_values",cardId:I,values:D});for(let I of In)for(let[D,ae]of Object.entries(I))D&&Ut.push({kind:"data_object",key:D,payload:ae});for(let[I,D]of Mo)Ut.push({kind:"card_refreshed",cardId:I,card:D});Ar!==void 0&&Ut.push({kind:"status",status:Ar}),s(Ut);let Oc=i().readTaskExecutorRef()??{howToRun:"built-in",whatToRun:oe({kind:"built-in",value:"source-cli-task-executor"})};k.dispatchEntriesForJournalId(Ct,I=>{if(I.taskKind!=="source-fetch"){r(`[process-accumulated-events] unknown taskKind "${I.taskKind}" \u2014 skipping`);return}let D=I.payload,ae=D.enrichedCard?.id??"unknown",Et=D.enrichedCard?.source_defs??[];for(let ze of Et){if(!ze.outputFile){r(`[dispatch] source "${ze.bindTo}" has no outputFile \u2014 skipping`);continue}let Ir=$g({cbk:D.callbackToken,rg:e.value,br:oe(e),cid:ae,b:ze.bindTo,d:ze.outputFile,cs:void 0,rqt:D.rqt});t.dispatchExecution(Oc,{source_def:ze,base_ref:oe(e),callback:{token:Ir,via:t.selfRef}}).catch(xt=>Lo(ae,xt instanceof Error?xt.message:String(xt)));}});}async function h(){try{let R=()=>{let E=g(),{events:A}=c().readEntriesAfterCursor(E.lastDrainedJournalId);A.length<=0||(h(),t.requestProcessAccumulated?.());},k=await Ko(t.lock,b,R);return Q({ran:k!==!1})}catch(R){return ee(R)}}function m(R){try{let k=R.params?.cardStoreRef;if(!k)return j("init requires params.cardStoreRef \u2014 create a card store with card-store-cli and pass its ref here");if(!y()){let te=bn(En);f({lastDrainedJournalId:"",graph:Rr(te)},null);}let E=R.params?.outputsStoreRef;if(!E)return j("init requires params.outputsStoreRef \u2014 pass the outputs store ref here");let A=i();A.writeCardStoreRef(k),A.writeOutputsStoreRef(E);let Y=R.body??{};Y["task-executor-ref"]&&A.writeTaskExecutorRef(Y["task-executor-ref"]),Y["chat-handler-ref"]&&A.writeChatHandlerRef(Y["chat-handler-ref"]);try{d().writeStatusSnapshot(Cn(n,Sn(g().graph)));}catch{}return Q()}catch(k){return ee(k)}}function v(R){try{let k=d().readStatusSnapshot();if(!k){k=Cn(n,Sn(g().graph));try{d().writeStatusSnapshot(k);}catch{}}return Q(k)}catch(k){return ee(k)}}function w(R){try{let k=R.params?.id;return k?(p({type:"task-removal",taskName:k,timestamp:Ce()}),h(),Q()):j("removeCard requires params.id")}catch(k){return ee(k)}}function S(R){try{let k=R.params?.id;return k?(p({type:"task-restart",taskName:k,timestamp:Ce()}),h(),Q()):j("retrigger requires params.id")}catch(k){return ee(k)}}async function $(R){return h()}function _(R){try{let k=R.params?.cardId,E=R.params?.all,A=!!R.params?.restart;if(!k&&!E)return j("upsertCard requires --card-id <id> or --all");let Y=E?l().readAllCards().map(te=>te.id):[k];for(let te of Y)if(!l().readCard(te))return j(`Card "${te}" not found in board at ${e.value}`);for(let te of Y){let we=l().readCard(te),_e=Rc(we),Be=t.hashFn(_e),De=t.kvStorage("card-upsert"),dt=De.read(te),lt=dt?.taskConfigHash!==Be;if(!(!lt&&!A)){if(lt){let $t=dt?.blobRef??l().readCardKey(te)??te;p({type:"task-upsert",taskName:te,taskConfig:_e,timestamp:Ce()}),De.write(te,{blobRef:$t,taskConfigHash:Be,updatedAt:Ce()});}A&&p({type:"task-restart",taskName:te,timestamp:Ce()});}}return h(),Q()}catch(k){return ee(k)}}function C(R){try{let k=R.params?.token;if(!k)return j("taskFailed requires params.token");let E=R.params?.error??"unknown error",A=xn(k);return A?(p({type:"task-failed",taskName:A.taskName,error:E,timestamp:Ce()}),h(),Q()):j("Invalid callback token")}catch(k){return ee(k)}}function N(R){try{let k=R.params?.token;if(!k)return j("taskProgress requires params.token");let A=(R.body??{}).update??{},Y=xn(k);return Y?(p({type:"task-progress",taskName:Y.taskName,update:A,timestamp:Ce()}),h(),Q()):j("Invalid callback token")}catch(k){return ee(k)}}function q(R){try{let k=R.params?.token,E=R.params?.ref;if(!k)return j("sourceDataFetched requires params.token");if(!E)return j("sourceDataFetched requires params.ref");let A=$c(k);if(!A)return j("Invalid source token");let{cbk:Y,cid:te,b:we,d:_e,cs:Be,rqt:De}=A,dt=No(t.blobStorage("sources"),ft=>t.resolveBlob(ft)),lt=t.genId();dt.ingestSourceDataStaged(te,_e,Re(E),lt);let $t=xn(Y);if(!$t)return j("Invalid callback token embedded in source token");let Ct=Ce();return p({type:"task-progress",taskName:$t.taskName,update:{bindTo:we,outputFile:_e,fetchedAt:Ct,deliveryToken:lt,sourceChecksum:Be,rqt:De},timestamp:Ct}),h(),Q()}catch(k){return ee(k)}}function F(R){try{let k=R.params?.token,E=R.params?.reason??"unknown";if(!k)return j("sourceDataFetchFailure requires params.token");let A=$c(k);if(!A)return j("Invalid source token");let{cbk:Y,b:te,d:we,cs:_e}=A,Be=xn(Y);return Be?(p({type:"task-progress",taskName:Be.taskName,update:{bindTo:te,outputFile:we,failure:!0,reason:E,sourceChecksum:_e},timestamp:Ce()}),h(),Q()):j("Invalid callback token embedded in source token")}catch(k){return ee(k)}}function re(R){try{let k=i().readCardStoreRef();return k?Q({storeRef:k}):j(`Board at ${e.value} has no card store configured`)}catch(k){return ee(k)}}function U(R){try{let k=i().readOutputsStoreRef();return k?Q({storeRef:k}):j(`Board at ${e.value} has no outputs store configured`)}catch(k){return ee(k)}}function ce(R){try{let k=R.params?.key;if(!k)return j("getConfig requires params.key");let E=i(),A;switch(k){case "task-executor":A=E.readTaskExecutorRef()??null;break;case "chat-handler":A=E.readChatHandlerRef()??null;break;case "card-store-ref":A=E.readCardStoreRef();break;case "outputs-store-ref":A=E.readOutputsStoreRef();break;default:return j(`getConfig: unknown key "${k}"`)}return Q({value:A})}catch(k){return ee(k)}}function qe(R){try{let k=R.params?.key;if(!k)return j("getOutputsDataObject requires params.key");let E=d().readDataObject(k);return Q(E)}catch(k){return ee(k)}}function ct(R){try{return Q(d().readAllDataObjects())}catch(k){return ee(k)}}function M(R){try{let k=R.params?.key;if(!k)return j("getOutputsComputedValues requires params.key");let E=d().readComputedValues(k);return Q(E)}catch(k){return ee(k)}}function V(R){try{return Q(d().readAllComputedValues())}catch(k){return ee(k)}}return {init:m,status:v,getCardStoreRef:re,getOutputsStoreRef:U,getConfig:ce,getOutputsDataObject:qe,getAllOutputsDataObjects:ct,getOutputsComputedValues:M,getAllOutputsComputedValues:V,removeCard:w,retrigger:S,processAccumulatedEvents:$,upsertCard:_,taskFailed:C,taskProgress:N,sourceDataFetched:q,sourceDataFetchFailure:F}}function Eg(e,t){let r=()=>qo(t.kvStorage("config"));function n(){let h=r().readCardStoreRef();if(!h)throw new Error(`Board at ${e.value} has no card store configured. Run: init --base-ref <ref> --store-ref <b64-ref>`);let m=t.kvStorageForRef(h);return {readIndex(){return m.read("_index")},writeIndex(v){m.write("_index",v);},readCard(v){return m.read(v)},writeCard(v,w){return m.write(v,w),t.hashFn(w)},cardExists(v){return m.read(v)!==null},defaultCardKey(v){return v}}}let s=()=>$n(n(),t.onWarn??(()=>{}));function o(h,m){let v=t.validateSchema(m),w=[],S=r().readTaskExecutorRef();if(S&&Array.isArray(m.source_defs))for(let _ of m.source_defs){let C=typeof _.bindTo=="string"?_.bindTo:"(unknown)";try{let N;try{N=t.invokeExecutorSync(S,"validate-source-def",[],{timeout:1e4,input:JSON.stringify(_)});}catch(F){let re=F;if(N=typeof re?.stdout=="string"?re.stdout:"",!N.trim()){w.push(`source "${C}": executor validate-source-def failed \u2014 ${F instanceof Error?F.message:String(F)}`);continue}}let q=JSON.parse(N.trim());if(!q.ok&&Array.isArray(q.errors))for(let F of q.errors)w.push(`source "${C}": ${F}`);}catch(N){w.push(`source "${C}": executor validate-source-def failed \u2014 ${N instanceof Error?N.message:String(N)}`);}}let $=[...v.errors,...w];return Q({cardId:h,isValid:$.length===0,issues:$})}function a(h,m,v){let w=r().readTaskExecutorRef();if(!w)return j("No task-executor registered for this board");let S=typeof h.bindTo=="string"?h.bindTo:"source",$=t.makeTempFilePath(`probe-in-${S}`),_=t.makeTempFilePath(`probe-out-${S}`),C=t.makeTempFilePath(`probe-err-${S}`,".txt"),N={...h,boardDir:e.value,_projections:m},q=oe({kind:"fs-path",value:$}),F=oe({kind:"fs-path",value:_}),re=oe({kind:"fs-path",value:C});t.absoluteBlob.write($,JSON.stringify(N,null,2));let U=null;try{if(t.invokeExecutorSync(w,"run-source-fetch",["--in-ref",q,"--out-ref",F,"--err-ref",re],{timeout:h.timeout??3e4}),U=t.absoluteBlob.read(_),U===null)return j("Executor produced no output file")}catch(ce){let qe=t.absoluteBlob.read(C)?.trim()??(ce instanceof Error?ce.message:String(ce));return j(`Probe failed: ${qe}`)}finally{try{t.absoluteBlob.remove($);}catch{}try{t.absoluteBlob.remove(C);}catch{}}if(v){let ce=Re(v);t.absoluteBlob.write(ce.value,U);}else try{t.absoluteBlob.remove(_);}catch{}return Q({bindTo:S,resultSizeBytes:U.length})}function i(h){try{let m=h.params?.cardId,v=h.params?.all;if(!m&&!v)return j("validateCard requires --card-id <id> or --all");let w=v?s().readAllCards().map($=>$.id):[m],S=[];for(let $ of w){let _=s().readCard($);if(!_){S.push({cardId:$,isValid:!1,issues:[`Card "${$}" not found`]});continue}let C=o($,_);if(C.status!=="success")return C;S.push(C.data);}return Q(S)}catch(m){return ee(m)}}function u(h){try{if(!h.body||typeof h.body!="object"||Array.isArray(h.body))return j("validateCardPreflight requires card JSON object in body");let m=h.body,v=m["card-content"]??m,w=typeof v.id=="string"?v.id:"(unknown)",S=o(w,v),$=r().readTaskExecutorRef();if($)try{let _=t.invokeExecutorSync($,"validate-card-preflight",[],{timeout:1e4,input:JSON.stringify(v)}),C=JSON.parse(_.trim());if(!C.ok&&Array.isArray(C.errors)&&C.errors.length>0){let N=[...S.status==="success"?S.data.issues:[],...C.errors];return Q({cardId:w,isValid:!1,issues:N})}}catch{}return S}catch(m){return ee(m)}}function c(h){try{let m=h.params?.cardId,v=h.params?.sourceIdx,w=h.params?.outRef;if(!m)return j("probeSource requires params.cardId");if(v===void 0)return j("probeSource requires params.sourceIdx");let $=(h.body??{})["mock-projections"]??{},_=s().readCard(m);if(!_)return j(`Card "${m}" not found`);let C=_.source_defs??[];return v<0||v>=C.length?j(`sourceIdx ${v} out of range (card has ${C.length} source(s))`):a(C[v],$,w)}catch(m){return ee(m)}}function l(h){try{let m=h.params?.outRef,v=h.body;if(!v)return j('probeTmpSource requires body with "source-def" and "mock-projections"');let w=v["source-def"],S=v["mock-projections"]??{};return w?a(w,S,m):j('probeTmpSource body requires "source-def"')}catch(m){return ee(m)}}function d(h){try{let m=h.params?.sourceIdx,v=h.params?.outRef;if(m===void 0)return j("probeSourcePreflight requires params.sourceIdx");if(!h.body||typeof h.body!="object"||Array.isArray(h.body))return j("probeSourcePreflight requires card JSON object in body");let w=h.body,S=w["card-content"]??w,$=w["mock-projections"]??{},_=S.source_defs??[];if(m<0||m>=_.length)return j(`sourceIdx ${m} out of range (card has ${_.length} source(s))`);let C=_[m],N=r().readTaskExecutorRef();if(N){let q=typeof C.bindTo=="string"?C.bindTo:"source";try{let F={...C,_projections:$},re=t.invokeExecutorSync(N,"probe-source-preflight",[],{timeout:C.timeout??1e4,input:JSON.stringify(F)}),U=JSON.parse(re.trim());return U.ok?Q({bindTo:q,reachable:U.reachable,latencyMs:U.latencyMs,note:U.note}):j(U.error??"Preflight probe failed")}catch{}}return a(C,$,v)}catch(m){return ee(m)}}function y(h){try{let m=r().readTaskExecutorRef();if(!m)return j("No task-executor registered for this board");let v=t.invokeExecutorSync(m,"describe-capabilities",[],{timeout:1e4});return Q(JSON.parse(v.trim()))}catch(m){return ee(m)}}function g(h){try{let m=h.body;if(!m||!Array.isArray(m.ops))return j("updatesInCardStore requires body.ops array");let v=m.ops,w=s();for(let S of v){let $=S.op,_=S.id;if(!_)return j('op is missing "id"');if($==="update"){let C=S["card-content"];if(!C)return j(`update op for "${_}" is missing "card-content"`);w.writeCard(_,C);}else return j(`Unknown op type: "${$??"(none)"}"`)}return Q()}catch(m){return ee(m)}}function f(h){try{let m=h.body;if(!m||!Array.isArray(m.ids))return j("readFromCardStore requires body.ids array");let v=m.ids,w=s(),S=v.map($=>({id:$,"card-content":w.readCard($)}));return Q({cards:S})}catch(m){return ee(m)}}function p(h){try{if(!h.body||typeof h.body!="object"||Array.isArray(h.body))return j("evalCardCompute requires a JSON object in body");let m=h.body,v=m["card-content"]??m,w=typeof v.id=="string"?v.id:"(unknown)",S=m["mock-fetched-sources"]??{},$=m["mock-requires"]??{},_=v.compute;if(!_||!Array.isArray(_)||_.length===0)return Q({cardId:w,ok:!0,computed_values:{},errors:[]});let C={id:w,card_data:v.card_data??{},requires:$,source_defs:v.source_defs,compute:_},N=it.runSync(C,{sourcesData:S}),q=N.node.computed_values??{},F=N.errors??[];return Q({cardId:w,ok:F.length===0,computed_values:q,errors:F})}catch(m){return ee(m)}}function b(h){try{if(!h.body||typeof h.body!="object"||Array.isArray(h.body))return j("simulateCardCycle requires a JSON object in body");let m=h.body,v=m["card-content"]??m,w=typeof v.id=="string"?v.id:"(unknown)",S=m["mock-fetched-sources"]??{},$=m["mock-requires"]??{},_=o(w,v),C=_.status==="success"?{isValid:_.data.isValid,issues:_.data.issues}:{isValid:!1,issues:[_.status==="fail"?_.error:"internal error"]},N=v.source_defs??[],q=v.card_data??{},F=[],re=[];if(N.length>0){F=it.enrichSourcesSync(N,{card_data:q,requires:$});for(let k of F){let E=k.projections,A=k._projections;if(E&&A){for(let Y of Object.keys(E))if(A[Y]===void 0){let te=typeof k.bindTo=="string"?k.bindTo:"(unknown)";re.push({bindTo:te,key:Y,error:`Projection "${Y}" resolved to undefined`});}}}}let U=[],ce=m["task-executor-ref"],qe=(ce?.howToRun&&ce?.whatToRun?ce:void 0)??r().readTaskExecutorRef();for(let k=0;k<F.length;k++){let E=F[k],A=typeof E.bindTo=="string"?E.bindTo:`source_${k}`;if(!qe){U.push({bindTo:A,skipped:!0,error:"No task executor configured"});continue}try{let Y={...E},te=t.invokeExecutorSync(qe,"probe-source-preflight",[],{timeout:E.timeout??1e4,input:JSON.stringify(Y)}),we=JSON.parse(te.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 ct=v.compute,M={},V=[];if(ct&&Array.isArray(ct)&&ct.length>0){let k={id:w,card_data:q,requires:$,source_defs:v.source_defs,compute:ct},E=it.runSync(k,{sourcesData:S});M=E.node.computed_values??{},V=E.errors??[];}let R=C.isValid&&re.length===0&&V.length===0&&U.every(k=>k.reachable!==!1);return Q({cardId:w,ok:R,validation:C,source_probes:U,projection_errors:re,computed_values:M,compute_errors:V})}catch(m){return ee(m)}}return {validateCard:i,validateCardPreflight:u,probeSource:c,probeTmpSource:l,probeSourcePreflight:d,evalCardCompute:p,simulateCardCycle:b,describeTaskExecutorCapabilities:y,updatesInCardStore:g,readFromCardStore:f}}function xg(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 Tg(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(l=>Math.max(0,Math.min(255,Number(l)||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)}}}}var Tn=".artifacts-index.json";function Ec(){return new Date().toISOString()}function xc(e){return new TextEncoder().encode(e).byteLength}function xr(e){let t=e.read(Tn);if(!t)return {entries:{}};try{let r=JSON.parse(t);if(r&&r.entries&&typeof r.entries=="object")return r}catch{}return {entries:{}}}function Do(e,t){e.write(Tn,JSON.stringify(t,null,2));}function Ag(e){return e?{key:e.key,size:e.size,updatedAt:e.updatedAt,contentType:e.contentType}:null}function Tc(e,t,r){e.entries[t]={key:t,size:r.size,updatedAt:r.updatedAt,contentType:r.contentType};}function Fo(e){let t=String(e||"").match(/^(\d+)[-_]/);return t?parseInt(t[1],10):0}function Ig(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 Pg(e){return String(e||"").toLowerCase().replace(/\s+/g,"_").replace(/[^a-z0-9_-]/g,"_").replace(/_+/g,"_").replace(/^_+|_+$/g,"")||"file"}function Og(e){if(!e||e===".")return "";let t=String(e).replace(/^\./,"").toLowerCase().replace(/[^a-z0-9]/g,"");return t?`.${t}`:""}function jg(e){let t=Ig(e),r=t.lastIndexOf(".");return r<=0||r===t.length-1?{stem:t,ext:""}:{stem:t.slice(0,r),ext:t.slice(r)}}function Ng(e){let t=e.lastIndexOf("/");return t>=0?e.slice(t+1):e}function qg(e){function t(r){let n=e.stat?Ag(e.stat(r)):null;if(n)return n;let o=xr(e).entries[r];if(o)return {...o};if(!e.exists(r))return null;let a=e.read(r);return a===null?{key:r}:{key:r,size:xc(a)}}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};o.contentType=s,o.updatedAt=o.updatedAt??Ec(),o.size=o.size??xc(n);let a=xr(e);return Tc(a,r,o),Do(e,a),o},putBytes(r,n,s="application/octet-stream"){if(e.writeBytes)e.writeBytes(r,n);else {let i=JSON.stringify({__kind:"bytes-array",data:[...n]});e.write(r,i);}let o=t(r)??{key:r};o.contentType=s,o.updatedAt=o.updatedAt??Ec(),o.size=o.size??n.byteLength;let a=xr(e);return Tc(a,r,o),Do(e,a),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=""){let n=new Map;if(e.listKeys)for(let o of e.listKeys(r)){if(o===Tn)continue;let a=t(o)??{key:o};n.set(o,a);}let s=xr(e);for(let[o,a]of Object.entries(s.entries))o===Tn||r&&!o.startsWith(r)||n.has(o)||n.set(o,{...a});return [...n.values()].sort((o,a)=>o.key.localeCompare(a.key))},remove(r){e.remove(r);let n=xr(e);delete n.entries[r],Do(e,n);}}}function Dg(e,t){let r=t?.indexFileName||".index.json";function n(d){return `${d}/${r}`}function s(d){let y=e.getText(n(d));if(!y)return [];try{let g=JSON.parse(y);return Array.isArray(g)?g.filter(f=>f&&typeof f.stored_name=="string").map(f=>({serial:Number(f.serial||Fo(String(f.stored_name))||0),role:String(f.role||"system").toLowerCase(),stored_name:String(f.stored_name),path:typeof f.path=="string"?f.path:`${d}/chats/${String(f.stored_name)}`,updated_at:typeof f.updated_at=="string"?f.updated_at:null})):[]}catch{return []}}function o(d,y){e.putText(n(d),JSON.stringify(y,null,2),"application/json; charset=utf-8");}function a(d){let y=s(d),g=0;for(let f of y){let p=Number(f.serial||0);Number.isFinite(p)&&p>g&&(g=p);}return g+1}function i(d,y){let g=s(d);g.push(y),o(d,g);}function u(d){let y=s(d),g=[];for(let f of y){let p=`${d}/${f.stored_name}`,b=e.getText(p);b!==null&&g.push({serial:Number(f.serial||Fo(f.stored_name)||0),role:String(f.role||"system").toLowerCase(),text:b,path:typeof f.path=="string"?f.path:`${d}/chats/${f.stored_name}`,stored_name:f.stored_name,updated_at:f.updated_at||null});}return g.sort((f,p)=>f.serial-p.serial||f.stored_name.localeCompare(p.stored_name)),g}function c(d){let y=`${d}/`;for(let g of e.list(y))e.remove(g.key);}function l(d){let y=`${d}/`,g=e.list(y),f=0,p=0,b=false;for(let h of g){let m=h.key.slice(y.length);if(m===".processing"){b=true;continue}if(!/^(\d+)[-_]([a-z0-9_-]+)\.txt$/i.test(m))continue;f+=1;let v=h.updatedAt?Number(new Date(h.updatedAt).getTime()||0):0;v>p&&(p=v);}return {count:f,latest_mtime_ms:p,processing:b}}return {indexKey:n,loadIndex:s,saveIndex:o,nextSerial:a,appendIndexRecord:i,readRecords:u,clear:c,readSignal:l}}function Fg(e){function t(s,o){let a=0,i=[];Array.isArray(o)&&i.push(...o);for(let u of e.list(`${s}/`))i.push(Ng(u.key));for(let u of i){let c=Fo(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}=jg(s),l=Og(c),d=Pg(u),y=`${String(o).padStart(3,"0")}-`,g=l,f=i-y.length-g.length;f<1&&(g="",f=i-y.length);let p=d.slice(0,Math.max(1,f)),b=`${y}${p}${g}`;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 Mg(){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 Ik(){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};if(n.chatsKeyPrefix&&n.chatsBlobBasePath){let o=String(n.chatsKeyPrefix).split("/")[0];n.chatDir=pt(String(n.chatsBlobBasePath),o);}delete n.chatsKeyPrefix,delete n.chatsBlobBasePath;let 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 Bg=".board.lock";function Gg(e,t){return typeof e=="string"?{cliDir:e,opts:t}:{cliDir:void 0,opts:e}}function Kg(e,t){return typeof e=="string"?{cliDir:e,opts:t}:{cliDir:void 0,opts:e}}function Ac(e){if(e)return e;let t=Yo((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,pt(t,"..","cli","node"),pt(t,"..","..","cli","node")];for(let n of r)try{return qn(n),n}catch{}throw new Error(`createFsBoardPlatformAdapter: could not resolve a public CLI directory from module dir ${t}`)}function Ug(e,t,r){let{cliDir:n,opts:s}=Gg(t,r),o=Ac(n),a=e.value,i=s?.suppressSpawn?"":qn(o),u={meta:"board-live-cards",howToRun:"local-node",whatToRun:i?oe({kind:"fs-path",value:i}):"",...s?.notifyChannel?{extra:{notifyChannel:s.notifyChannel}}:{}};return {kvStorage:c=>Kn(pt(a,`.${c}`)),blobStorage:c=>c?qr(pt(a,c)):qr(a),journalAdapter:()=>pa(a),lock:ma(pt(a,Bg)),selfRef:u,async dispatchExecution(c,l){if(s?.suppressSpawn)return {dispatched:false};try{let d=l.source_def?.bindTo??On().slice(0,8),y=Jt(a,`exec-in-${d}`),g=Jt(a,`exec-out-${d}`),f=Jt(a,`exec-err-${d}`,".txt"),p=oe({kind:"fs-path",value:y}),b=oe({kind:"fs-path",value:g}),h=oe({kind:"fs-path",value:f});return la({kind:"fs-path",value:y}).write(y,JSON.stringify(l,null,2)),da(c,{subcommand:"run-source-fetch",inRef:p,outRef:b,errRef:h},o),{dispatched:!0}}catch(d){return {dispatched:false,error:d instanceof Error?d.message:String(d)}}},resolveBlob(c){let l=zo(c.value)?Gn().read(c.value):qr(a).read(c.value);if(l===null)throw new Error(`resolveBlob: blob not found: ::${c.kind}::${c.value}`);return l},hashFn:fa,genId:()=>Wo(`${Date.now()}-${Math.random()}`).slice(0,32),kvStorageForRef:c=>Kn(Re(c).value),requestProcessAccumulated(){s?.suppressSpawn||Zo(o,e,s?.notifyChannel);},publishBoardChangeNotifications(c){if(!s?.notifyChannel||c.length===0)return;let l=c.map(d=>({id:On(),ts:new Date().toISOString(),boardRef:oe(e),notification:d}));ea(s.notifyChannel,l,s.onWarn);},onWarn:s?.onWarn}}function Pk(e,t,r){let{cliDir:n,opts:s}=Kg(t,r),o=Ac(n),a=Ug(e,o,s),i=Nr();return {...a,invokeExecutorSync(u,c,l,d){let{command:y,baseArgs:g}=Fn(u,o);return i.executeSync(y,[...g,c,...l],{timeout:d?.timeout??3e4,encoding:"utf-8",input:d?.input})},validateSchema(u){let c=Io(u);return {ok:c.errors.length===0,errors:c.errors}},makeTempFilePath(u,c){return Jt(e.value,u,c)},absoluteBlob:Gn()}}function Ok(e){try{let t=JSON.parse(Buffer.from(e,"base64url").toString());return typeof t.br=="string"?t.br:null}catch{return null}}
|
|
13
|
-
exports.BOARD_GRAPH_KEY=ut;exports.EMPTY_CONFIG=En;exports.SNAPSHOT_SCHEMA_VERSION_V1=Er;exports.createArtifactsStore=qg;exports.createArtifactsStorePublic=Tg;exports.createBoardLiveCardsNonCorePublic=Eg;exports.createBoardLiveCardsPublic=Cg;exports.createCardFileMetadataStore=Mg;exports.createCardStore=$n;exports.createCardStorePublic=xg;exports.createChatArtifactsStore=Dg;exports.createExecutionRefInvoker=ud;exports.createFileArtifactsStore=Fg;exports.createFsBoardNonCorePlatformAdapter=
|
|
12
|
+
`,"utf-8");},generateId(){return crypto.randomUUID()}}}function ma(e){return {tryAcquire(){try{if(!P__namespace.existsSync(e)){P__namespace.mkdirSync(ue__namespace.dirname(e),{recursive:!0});try{P__namespace.writeFileSync(e,"{}",{flag:"wx"});}catch{}}return properLockfile.lockSync(e,{retries:0})}catch{return null}}}}var ha={$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 Uu=Lc(Bu());var Kh=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))),Uh=Kh("./jsonata-sync.cjs"),vn=null;var Gu=/\b(card_data|requires|fetched_sources|computed_values|source_defs)\b/g,Jh=/^\s*(card_data|requires|fetched_sources|computed_values|source_defs)(\.|$)/;function Hh(e){let t=new Set,r;for(Gu.lastIndex=0;(r=Gu.exec(e))!==null;)t.add(r[1]);return t}function Ju(e){let t=Jh.exec(e);return t?t[1]:null}function Ku(e,t,r,n){try{Uh(e);}catch(o){let a=o instanceof Error?o.message:String(o);n.push(`${t}: invalid JSONata expression (${a})`);return}let s=Hh(e);for(let o of s)r.has(o)||n.push(`${t}: disallowed namespace "${o}" in expression`);}function Ao(e,t,r){if(Array.isArray(e)){e.forEach((s,o)=>{Ao(s,`${t}/${o}`,r);});return}if(typeof e=="string"){let s=Ju(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))Ao(o,`${t}/${s}`,r);}function zh(){if(vn)return vn;let e=new Uu.default({allErrors:true});return Bh__default.default(e),vn=e.compile(ha),vn}function Hu(e){let t=zh(),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 zu(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,l)=>{if(!c||typeof c!="object"||Array.isArray(c))return;let d=c.expr;typeof d!="string"||d.trim().length===0||Ku(d,`/compute/${l}/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,l)=>{if(!c||typeof c!="object"||Array.isArray(c))return;let d=c.ref;if(typeof d!="string"||d.trim().length===0)return;let y=Ju(d);y===null?t.push(`/provides/${l}/ref: path "${d}" must start with a valid namespace (${[...s].join(", ")})`):s.has(y)||t.push(`/provides/${l}/ref: disallowed namespace "${y}" in path "${d}" (valid: ${[...s].join(", ")})`);});let a=r.view;a&&typeof a=="object"&&!Array.isArray(a)&&Ao(a,"/view",t);let i=new Set(["card_data","requires"]),u=r.source_defs;return Array.isArray(u)&&u.forEach((c,l)=>{if(!c||typeof c!="object"||Array.isArray(c))return;let d=c.projections;if(!(!d||typeof d!="object"||Array.isArray(d)))for(let[y,g]of Object.entries(d))typeof g!="string"||g.trim().length===0||Ku(g,`/source_defs/${l}/projections/${y}`,i,t);}),{ok:t.length===0,errors:t}}function Io(e){let t=Hu(e);if(!t.ok)return t;let r=zu(e);return r.ok?{ok:true,errors:[]}:{ok:false,errors:r.errors}}var ot={RUNNING:"running",COMPLETED:"completed",FAILED:"failed",INACTIVATED:"inactivated"};function $e(e){return e?Array.isArray(e.provides)?e.provides:[]:[]}function at(e){return e?Array.isArray(e.requires)?e.requires:[]:[]}function Wu(e){return e.tasks??{}}function Po(e){return e?e.status===ot.FAILED||e.status===ot.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===ot.COMPLETED){let o=e.tasks[n];o&&$e(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;$e(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=at(a);for(let u of i)for(let[c,l]of Object.entries(r.tasks))if($e(l).includes(u)){let d=e.tasks[c];d?.lastDataHash&&(s[u]=d.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=$e(i);let c=a.startConsumedHashes?{...a.startConsumedHashes}:{...a.lastConsumedHashes};if(!a.startConsumedHashes){let y=i.requires??[];for(let g of y)for(let[f,p]of Object.entries(t.tasks))if($e(p).includes(g)){let k=e.tasks[f];k?.lastDataHash&&(c[g]=k.lastDataHash);break}}let l={...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},d=[...new Set([...e.availableOutputs,...u])];return {...e,tasks:{...e.tasks,[r]:l},availableOutputs:d,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 Wh(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:rg(n,t.action)};case "task-upsert":return Yh(e,t.taskName,t.taskConfig);case "task-removal":return Xh(e,t.taskName);case "node-requires-add":return Qh(e,t.nodeName,t.tokens);case "node-requires-remove":return Zh(e,t.nodeName,t.tokens);case "node-provides-add":return eg(e,t.nodeName,t.tokens);case "node-provides-remove":return tg(e,t.nodeName,t.tokens);default:return e}}function oc(e,t){return t.reduce((r,n)=>Wh(r,n),e)}function Yh(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 Xh(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 Qh(e,t,r){let n=e.config.tasks[t];if(!n)return e;let s=at(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 Zh(e,t,r){let n=e.config.tasks[t];if(!n)return e;let s=at(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 eg(e,t,r){let n=e.config.tasks[t];if(!n)return e;let s=$e(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 tg(e,t,r){let n=e.config.tasks[t];if(!n)return e;let s=$e(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 rg(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 $r(e){let{config:t,state:r}=e,n=Wu(t);if(Object.keys(n).length===0)return {eligible:[],pending:[],unresolved:[],blocked:[],conflicts:{}};let o=ng(n),a=Qu(t,r.tasks),i=new Set([...a,...r.availableOutputs]),u=[],c=[],l=[],d=[];for(let[g,f]of Object.entries(n)){let p=r.tasks[g],k=Yu(f,t.settings),h=k!=="once";if(p?.status===ot.RUNNING||Po(p))continue;let m=Xu(f);if(m!==void 0&&p&&p.executionCount>=m||f.circuit_breaker&&p&&p.executionCount>=f.circuit_breaker.max_executions||!h&&p?.status===ot.COMPLETED)continue;if(h&&p?.status===ot.COMPLETED){let _=at(f),C=false;switch(k){case "data-changed":{_.length>0&&_.some(q=>{for(let[F,re]of Object.entries(n))if($e(re).includes(q)){let U=r.tasks[F];if(!U)continue;let ce=p.lastConsumedHashes?.[q];return U.lastDataHash==null?U.executionCount>p.lastEpoch:U.lastDataHash!==ce}return false})||(C=true);break}case "epoch-changed":{_.length>0&&_.some(q=>{for(let[F,re]of Object.entries(n))if($e(re).includes(q)){let U=r.tasks[F];if(U&&U.executionCount>p.lastEpoch)return true}return false})||(C=true);break}case "time-based":{let N=f.refreshInterval??0;if(N<=0){C=true;break}let q=p.completedAt;if(!q){C=true;break}(Date.now()-Date.parse(q))/1e3<N&&(C=true);break}case "manual":C=true;break}if(C)continue}let v=at(f);if(v.length===0){u.push(g);continue}let w=[],S=[],$=[];for(let _ of v){if(i.has(_))continue;let C=o[_]||[];C.length===0?w.push(_):C.every(q=>Po(r.tasks[q]))?$.push({token:_,failedProducer:C[0]}):S.push(_);}w.length>0?l.push({taskName:g,missingTokens:w}):$.length>0?d.push({taskName:g,failedTokens:$.map(_=>_.token),failedProducers:[...new Set($.map(_=>_.failedProducer))]}):S.length>0?c.push({taskName:g,waitingOn:S}):u.push(g);}let y={};if(u.length>1){let g=Zu(u,n);for(let[f,p]of Object.entries(g))p.length>1&&(y[f]=p);}return {eligible:u,pending:c,unresolved:l,blocked:d,conflicts:y}}function ng(e){let t={};for(let[r,n]of Object.entries(e)){for(let s of $e(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 Cr=class{buffer=[];append(t){this.buffer.push(t);}drain(){let t=this.buffer;return this.buffer=[],t}get size(){return this.buffer.length}};function Oo(e){let t=jo(e);return sg(t)}function jo(e){if(e==null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return "["+e.map(jo).join(",")+"]";let t=e;return "{"+Object.keys(t).sort().map(n=>JSON.stringify(n)+":"+jo(t[n])).join(",")+"}"}function sg(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 og(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 ag(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 og(t)}function ig(e){try{let t=JSON.parse(ag(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 Cr,a="state"in e&&"config"in e?e:kn(e),i=false,u=new Set,c=new Map(Object.entries(n)),l=new Cr,d=false,y=false;function g(){if(!i){if(d){y=true;return}d=true;try{do y=!1,f();while(y)}finally{d=false;}}}function f(){let m=l.drain(),v=o.drain(),w=[...m,...v];w.length>0&&(a=oc(a,w));let S=$r(a);w.length>0&&s?.(w,a,S);for(let $ of S.eligible)h($);for(let $ of w)if($.type==="task-progress"){let{taskName:_,update:C}=$;if(!a.config.tasks[_])continue;let q=a.state.tasks[_];if(!q||q.status!=="running")continue;let F=ic(_),re=k(_,F,C).catch(U=>{i||(l.append({type:"task-failed",taskName:_,error:U.message??String(U),timestamp:new Date().toISOString()}),g());}).finally(()=>{u.delete(re);});u.add(re);}}function p(m){let w=a.config.tasks[m].requires??[],S=new Map;for(let[_,C]of Object.entries(a.config.tasks))for(let N of C.provides??[])S.set(N,_);let $={};for(let _ of w){let C=S.get(_);C?$[_]=a.state.tasks[C]?.data:$[_]=void 0;}return $}async function k(m,v,w){let S=a.config.tasks[m],$=S.taskHandlers??[],_=p(m);for(let C of $){let N=c.get(C);if(!N)throw new Error(`Handler '${C}' not found in registry (task '${m}')`);let q={nodeId:m,state:_,taskState:a.state.tasks[m],config:S,callbackToken:v,update:w};if(await N(q)==="task-initiate-failure")throw new Error(`Handler '${C}' returned task-initiate-failure (task '${m}')`)}}function h(m){let w=a.config.tasks[m]?.taskHandlers;if(!w||w.length===0)return;l.append({type:"task-started",taskName:m,timestamp:new Date().toISOString()}),g();let S=ic(m),$=k(m,S).catch(_=>{i||(l.append({type:"task-failed",taskName:m,error:_.message??String(_),timestamp:new Date().toISOString()}),g());}).finally(()=>{u.delete($);});u.add($);}return {push(m){i||(m.type==="task-completed"&&m.data&&!m.dataHash&&(m={...m,dataHash:Oo(m.data)}),o.append(m),g());},pushAll(m){if(!i){for(let v of m)v.type==="task-completed"&&v.data&&!v.dataHash?o.append({...v,dataHash:Oo(v.data)}):o.append(v);g();}},resolveCallback(m,v,w){if(i)return;let S=ig(m);if(!S)return;let{taskName:$}=S;if(a.config.tasks[$]){if(w&&w.length>0)o.append({type:"task-failed",taskName:$,error:w.join("; "),timestamp:new Date().toISOString()});else {let _=v&&Object.keys(v).length>0?Oo(v):void 0;o.append({type:"task-completed",taskName:$,data:v,dataHash:_,timestamp:new Date().toISOString()});}g();}},addNode(m,v){i||(o.append({type:"task-upsert",taskName:m,taskConfig:v,timestamp:new Date().toISOString()}),g());},removeNode(m){i||(o.append({type:"task-removal",taskName:m,timestamp:new Date().toISOString()}),g());},addRequires(m,v){i||(o.append({type:"node-requires-add",nodeName:m,tokens:v,timestamp:new Date().toISOString()}),g());},removeRequires(m,v){i||(o.append({type:"node-requires-remove",nodeName:m,tokens:v,timestamp:new Date().toISOString()}),g());},addProvides(m,v){i||(o.append({type:"node-provides-add",nodeName:m,tokens:v,timestamp:new Date().toISOString()}),g());},removeProvides(m,v){i||(o.append({type:"node-provides-remove",nodeName:m,tokens:v,timestamp:new Date().toISOString()}),g());},registerHandler(m,v){c.set(m,v);},unregisterHandler(m){c.delete(m);},retrigger(m){i||a.config.tasks[m]&&(o.append({type:"task-restart",taskName:m,timestamp:new Date().toISOString()}),g());},retriggerAll(m){if(!i){for(let v of m)a.config.tasks[v]&&o.append({type:"task-restart",taskName:v,timestamp:new Date().toISOString()});g();}},snapshot(){return Rr(a)},getState(){return a},getSchedule(){return $r(a)},async waitForHandlers(){u.size>0&&await Promise.allSettled([...u]);},async dispose(m){m?.wait&&u.size>0&&await Promise.allSettled([...u]),i=true;}}}var cg=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=cg("./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 dg(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 lg(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 fg(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 pg(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"]),mg=new Set(["id","meta","requires","provides","view","card_data","compute","source_defs"]);function hg(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))mg.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 gg(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 yg(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 it={run:dg,runSync:lg,eval:fg,resolve:pg,validate:hg,enrichSources:gg,enrichSourcesSync:yg};function vg(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:oe({kind:"fs-path",value:e}),...t?{extra:t}:{}}}function _n(e){return JSON.stringify(e)}function Rn(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 l=0;l<i.length-1;l++){let d=i[l],y=c[d],g=y&&typeof y=="object"&&!Array.isArray(y)?{...y}:{};c[d]=g,c=g;}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 l=n(c,o,a),d=e.writeCard(u.key,l);i[s]={key:u.key,checksum:d,updatedAt:new Date().toISOString()},e.writeIndex(i);},removeCard(s){let o=r();o[s]&&(delete o[s],e.writeIndex(o));},readIndex(){return r()}}}function No(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 gc(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",ut="board/graph",yc="board/lastJournalProcessedId";function pc(e){return `cards/${e}/runtime`}function vc(e){return {readRuntime(t){return e.read(pc(t))??{_sources:{}}},writeRuntime(t,r){e.write(pc(t),r);}}}function bg(e,t){let r={...e};for(let n of t.deleteKeys)delete r[n];return {...r,...t.shallowMerge}}function bc(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=bg(n.values,r);return {ok:true,newVersion:e.writeValues(t,s,r.deleteKeys)}}}}function qo(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 Rn(r.trim())},writeTaskExecutorRef(r){e.write("task-executor",_n(r));},readChatHandlerRef(){let r=t("chat-handler");if(r?.trim())return Rn(r.trim())},writeChatHandlerRef(r){e.write("chat-handler",_n(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);},readChatHandler(){return t("chat-handler")?.trim()||void 0},writeChatHandler(r){e.write("chat-handler",r);}}}function kc(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 kg(e){return e?.lastRequestedAt?!e.lastFetchedAt||e.lastFetchedAt<e.lastRequestedAt:false}function Sg(e,t){return e?.lastRequestedAt?kg(e)?"in-flight":!e.lastFetchedAt||e.lastFetchedAt<t?"dispatch":"idle":"dispatch"}function wg(e,t){let r={...e,lastFetchedAt:t};return delete r.lastError,r}function mc(e,t){let r={...e,lastError:t};return delete r.lastFetchedAt,r}function Cn(e,t){let r=t.state.tasks,n=t.config.tasks,s=Object.keys(r),o=$r(t),a={completed:0,failed:0,in_progress:0,pending:0,blocked:0,unresolved:0},i=new Map;for(let f of o.pending)i.set(f.taskName,f.waitingOn);for(let f of o.unresolved)i.set(f.taskName,f.missingTokens);for(let f of o.blocked)i.set(f.taskName,f.failedTokens);let u=new Map;for(let[f,p]of Object.entries(n))for(let k of p.requires??[]){let h=u.get(k)??[];h.push(f),u.set(k,h);}let c=s.sort().map(f=>{let p=r[f],k=n[f]??{requires:[],provides:[]};p.status==="completed"?a.completed+=1:p.status==="failed"?a.failed+=1:p.status==="in-progress"&&(a.in_progress+=1);let h=k.requires??[],m=k.provides??[],v=Object.keys(p.data??{}).sort(),w=h.filter(q=>t.state.availableOutputs.includes(q)),S=h.filter(q=>!t.state.availableOutputs.includes(q)),$=i.get(f)??S,_=new Set;for(let q of m)for(let F of u.get(q)??[])F!==f&&_.add(F);let C=p.failedAt,N=p.error?{message:p.error,code:"TASK_FAILED",at:C,source:"task-runtime"}:void 0;return {name:f,status:p.status,error:N,requires:h,requires_satisfied:w,requires_missing:S,provides_declared:m,provides_runtime:v,blocked_by:$,unblocks:Array.from(_).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 l=c.map(f=>({name:f.name,fanOut:f.unblocks.length})).sort((f,p)=>p.fanOut-f.fanOut||f.name.localeCompare(p.name)),d=l.length>0?l[0]:{name:null,fanOut:0},y=new Set;for(let f of Object.values(n))for(let p of f.requires??[])y.add(p);let g=0;for(let[f,p]of Object.entries(n)){let k=(p.requires??[]).length===0,m=(p.provides??[]).some(v=>(u.get(v)??[]).some(w=>w!==f));k&&!m&&(g+=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:g,topology:{edge_count:Array.from(y).length,max_fan_out_card:d.name,max_fan_out:d.fanOut}},cards:c}}function _g(){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 l=c.id,d=c.card_data??{},y=c.source_defs??[],g=y.filter(M=>M.optionalForCompletionGating!==true),f=r.cardRuntimeStore.readRuntime(l),p=false,k=()=>{p&&(r.cardRuntimeStore.writeRuntime(l,f),p=false);},h=M=>({...f._sources[M]??{}}),m=(M,V)=>{f._sources[M]=V,p=true;},v=i.taskState?.executionCount??0,w=f._lastExecutionCount;if(typeof w=="number"&&w!==v&&(f._sources={},p=true),w!==v&&(f._lastExecutionCount=v,p=true),i.update){let M=i.update,V=M.outputFile;if(V){let R=h(V);if(M.failure)m(V,mc(R,M.reason??"unknown"));else {let b=M.rqt;if(!R.lastFetchedAt||b>R.lastFetchedAt){let E=typeof M.deliveryToken=="string"?M.deliveryToken:void 0,A=false;E&&(A=r.fetchedSourcesStore.commitSourceData(l,V,E)),A?m(V,wg(R,b)):m(V,mc(R,`source delivery commit failed for ${V} token=${String(E)}`));}}k();}}let S={};for(let M of y)if(M.outputFile){let V=r.fetchedSourcesStore.readSourceData(l,M.outputFile);V!==null&&(S[M.bindTo]=V);}let $={};for(let[M,V]of Object.entries(i.state??{}))if(V!==null&&typeof V=="object"&&!Array.isArray(V)){let R=V[M];$[M]=R!==void 0?R:V;}else $[M]=V;let _={id:l,card_data:{...d},requires:$,source_defs:y,compute:c.compute};_._sourcesData=S,c.compute&&it.runSync(_,{sourcesData:S}),(o??r.outputStore.writeComputedValues.bind(r.outputStore))(l,_.computed_values??{});let C={...c},N=it.enrichSourcesSync(Array.isArray(c.source_defs)?c.source_defs:void 0,{card_data:c.card_data,requires:$}),q=e.value;C.source_defs=Array.isArray(N)?N.map(M=>({...M,boardDir:typeof M.boardDir=="string"&&M.boardDir?M.boardDir:q})):N;let F=_g(),re=i.update?void 0:F,U=g.filter(M=>{let V=M.outputFile;if(typeof V!="string"||!V)return true;let R=h(V);re&&(R={...R,queueRequestedAt:re},m(V,R));let b=R.queueRequestedAt??R.lastRequestedAt??F,E=Sg(R,b);return E==="in-flight"?false:E==="dispatch"});if(k(),U.length>0){let M=false,V=F;for(let R of U){let b=R.outputFile;if(typeof b!="string"||!b)continue;let E=h(b),A=E.queueRequestedAt??F;m(b,{...E,lastRequestedAt:A}),V=A,M=true;}return M&&k(),M&&(u.push({taskKind:"source-fetch",payload:{boardRef:oe(e),enrichedCard:C,callbackToken:i.callbackToken,rqt:V}}),r.executionRequestStore.appendEntries(t,u)),"task-initiated"}let ce=c.provides??[],qe={};for(let{bindTo:M,ref:V}of ce)qe[M]=it.resolve(_,V);return (a??r.outputStore.writeDataObjects.bind(r.outputStore))(qe),y.filter(M=>{if(M.optionalForCompletionGating!==true)return false;let V=h(M.outputFile);return !V.lastRequestedAt||!V.lastFetchedAt?true:V.lastFetchedAt<=V.lastRequestedAt}).length>0&&u.push({taskKind:"source-fetch",payload:{boardRef:oe(e),enrichedCard:C,callbackToken:i.callbackToken,rqt:F}}),n(i.nodeId,qe),u.length>0&&r.executionRequestStore.appendEntries(t,u),"task-initiated"}}var En={settings:{completion:"manual",refreshStrategy:"data-changed"},tasks:{}};function wc(e){return {[ut]:e.graph,[yc]:e.lastDrainedJournalId}}function _c(e){let t=e[ut],r=e[yc];if(!t||typeof t!="object")throw new Error(`State snapshot is missing required key: ${ut}`);return {graph:t,lastDrainedJournalId:typeof r=="string"?r:""}}function Rc(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 Q(e){return e!==void 0?{status:"success",data:e}:{status:"success"}}function j(e){return {status:"fail",error:e}}function ee(e){return {status:"error",error:e instanceof Error?e.message:String(e)}}function Rg(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 Cc(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 xn(e){try{let t=JSON.parse(Cc(e));return typeof t?.t=="string"?{taskName:t.t}:null}catch{return null}}function $g(e){return Rg(JSON.stringify(e))}function $c(e){try{let t=JSON.parse(Cc(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 Cg(e,t){let r=t.onWarn??(()=>{}),n=oe(e);function s(R){if(R.length!==0)try{let b=t.publishBoardChangeNotifications?.(R);b&&typeof b.catch=="function"&&b.catch(E=>r(`[board-live-cards-public] publishBoardChangeNotifications failed: ${E instanceof Error?E.message:String(E)}`));}catch(b){r(`[board-live-cards-public] publishBoardChangeNotifications failed: ${b instanceof Error?b.message:String(b)}`);}}function o(){let R=i().readCardStoreRef();if(!R)throw new Error(`Board at ${e.value} has no card store configured. Run: init --base-ref <ref> --store-ref <b64-ref>`);let b=t.kvStorageForRef(R);return {readIndex(){return b.read("_index")},writeIndex(E){b.write("_index",E);},readCard(E){return b.read(E)},writeCard(E,A){return b.write(E,A),t.hashFn(A)},cardExists(E){return b.read(E)!==null},defaultCardKey(E){return E}}}let a={readValues(R){let b=t.kvStorage("state-snapshot"),E=b.listKeys().sort();if(E.length===0)return {version:null,values:{}};let A={};for(let Y of E)A[Y]=b.read(Y);return {version:t.hashFn(A),values:A}},writeValues(R,b,E){let A=t.kvStorage("state-snapshot");for(let Y of E)A.delete(Y);for(let[Y,te]of Object.entries(b))A.write(Y,te);return t.hashFn(b)}},i=()=>qo(t.kvStorage("config")),u=()=>bc(a),c=()=>hc(t.journalAdapter()),l=()=>$n(o(),r),d=()=>{let R=i().readOutputsStoreRef();if(!R)throw new Error(`Board at ${e.value} has no outputs store configured. Run: init --outputs-store-ref <b64-ref>`);return kc(t.kvStorageForRef(R))};function y(){return !!u().readSnapshot(e.value).values[ut]}function g(){let R=u().readSnapshot(e.value);if(!R.values[ut])throw new Error(`Board not initialized at ${e.value}`);return _c(R.values)}function f(R,b){let E=u().commitSnapshot(e.value,{schemaVersion:Er,expectedVersion:b,commitId:t.genId(),committedAt:Ce(),deleteKeys:[],shallowMerge:wc(R)});if(!E.ok)throw new Error(`Snapshot commit failed (version mismatch): expected=${b??"null"} current=${E.currentVersion??"null"}`)}function p(R){c().appendEvent(R);}async function k(){let R=(I,D)=>{let ae=I.payload,ze=(ae?.enrichedCard??{}).id??ae?.cardId??"unknown";p({type:"task-failed",taskName:ze,error:D,timestamp:Ce()});},b=gc(t.kvStorage("execution-requests"),R),E=vc(t.kvStorage("card-runtime")),A=No(t.blobStorage("sources"),I=>t.resolveBlob(I)),Y=new Map,te={readRuntime(I){return Y.get(I)??E.readRuntime(I)},writeRuntime(I,D){Y.set(I,D);}},we=[],_e=new Map,Be={readSourceData(I,D){let ae=`${I}/${D}`;return _e.has(ae)?_e.get(ae):A.readSourceData(I,D)},ingestSourceDataStaged(I,D,ae,Et){A.ingestSourceDataStaged(I,D,ae,Et);},commitSourceData(I,D,ae){let Et=`${I}/.staged/${ae}/${D}`,Ir=t.blobStorage("sources").read(Et);if(Ir==null)return false;let xt=`${I}/${D}`,Bo=Ir.trim();try{_e.set(xt,JSON.parse(Bo));}catch{_e.set(xt,Bo);}return we.push({cardId:I,outputFile:D,deliveryToken:ae}),true},hasSource(I,D){let ae=`${I}/${D}`;return _e.has(ae)?true:A.hasSource(I,D)}},De={cardStore:l(),cardRuntimeStore:te,fetchedSourcesStore:Be,outputStore:d(),executionRequestStore:b},dt=g(),lt=Sn(dt.graph),{events:$t,newCursor:Ct}=c().readEntriesAfterCursor(dt.lastDrainedJournalId),ft=[],An=[],In=[],Mo=new Map,Ic=(I,D)=>{ft.push({type:"task-completed",taskName:I,data:D,timestamp:Ce()});},Lo=(I,D)=>p({type:"task-failed",taskName:I,error:D,timestamp:Ce()}),Tr=uc(lt,{handlers:{"card-handler":Sc(e,Ct,De,Ic,Lo,(I,D)=>{An.push({cardId:I,values:D});},I=>{In.push(I);})}});for(ft=$t;ft.length>0;){let I=ft;ft=[];for(let D of I)if(D.type==="task-restart"){let ae=De.cardStore.readCard(D.taskName);ae&&Mo.set(D.taskName,ae);}Tr.pushAll(I),await Tr.waitForHandlers();}let Vo=Tr.getState();await Tr.dispose({wait:true});let Pc=u().readSnapshot(e.value).version;f({lastDrainedJournalId:Ct,graph:Rr(Vo)},Pc);for(let{cardId:I,values:D}of An)De.outputStore.writeComputedValues(I,D);for(let I of In)De.outputStore.writeDataObjects(I);for(let[I,D]of Y)E.writeRuntime(I,D);for(let{cardId:I,outputFile:D,deliveryToken:ae}of we)A.commitSourceData(I,D,ae);let Ar;try{Ar=Cn(n,Vo),De.outputStore.writeStatusSnapshot(Ar);}catch(I){r(`[board-live-cards-public] status publish failed: ${I instanceof Error?I.message:String(I)}`);}let Ut=[];for(let{cardId:I,values:D}of An)Ut.push({kind:"computed_values",cardId:I,values:D});for(let I of In)for(let[D,ae]of Object.entries(I))D&&Ut.push({kind:"data_object",key:D,payload:ae});for(let[I,D]of Mo)Ut.push({kind:"card_refreshed",cardId:I,card:D});Ar!==void 0&&Ut.push({kind:"status",status:Ar}),s(Ut);let Oc=i().readTaskExecutorRef()??{howToRun:"built-in",whatToRun:oe({kind:"built-in",value:"source-cli-task-executor"})};b.dispatchEntriesForJournalId(Ct,I=>{if(I.taskKind!=="source-fetch"){r(`[process-accumulated-events] unknown taskKind "${I.taskKind}" \u2014 skipping`);return}let D=I.payload,ae=D.enrichedCard?.id??"unknown",Et=D.enrichedCard?.source_defs??[];for(let ze of Et){if(!ze.outputFile){r(`[dispatch] source "${ze.bindTo}" has no outputFile \u2014 skipping`);continue}let Ir=$g({cbk:D.callbackToken,rg:e.value,br:oe(e),cid:ae,b:ze.bindTo,d:ze.outputFile,cs:void 0,rqt:D.rqt});t.dispatchExecution(Oc,{source_def:ze,base_ref:oe(e),callback:{token:Ir,via:t.selfRef}}).catch(xt=>Lo(ae,xt instanceof Error?xt.message:String(xt)));}});}async function h(){try{let R=()=>{let E=g(),{events:A}=c().readEntriesAfterCursor(E.lastDrainedJournalId);A.length<=0||(h(),t.requestProcessAccumulated?.());},b=await Ko(t.lock,k,R);return Q({ran:b!==!1})}catch(R){return ee(R)}}function m(R){try{let b=R.params?.cardStoreRef;if(!b)return j("init requires params.cardStoreRef \u2014 create a card store with card-store-cli and pass its ref here");if(!y()){let te=kn(En);f({lastDrainedJournalId:"",graph:Rr(te)},null);}let E=R.params?.outputsStoreRef;if(!E)return j("init requires params.outputsStoreRef \u2014 pass the outputs store ref here");let A=i();A.writeCardStoreRef(b),A.writeOutputsStoreRef(E);let Y=R.body??{};Y["task-executor-ref"]&&A.writeTaskExecutorRef(Y["task-executor-ref"]),Y["chat-handler-ref"]&&A.writeChatHandlerRef(Y["chat-handler-ref"]);try{d().writeStatusSnapshot(Cn(n,Sn(g().graph)));}catch{}return Q()}catch(b){return ee(b)}}function v(R){try{let b=d().readStatusSnapshot();if(!b){b=Cn(n,Sn(g().graph));try{d().writeStatusSnapshot(b);}catch{}}return Q(b)}catch(b){return ee(b)}}function w(R){try{let b=R.params?.id;return b?(p({type:"task-removal",taskName:b,timestamp:Ce()}),h(),Q()):j("removeCard requires params.id")}catch(b){return ee(b)}}function S(R){try{let b=R.params?.id;return b?(p({type:"task-restart",taskName:b,timestamp:Ce()}),h(),Q()):j("retrigger requires params.id")}catch(b){return ee(b)}}async function $(R){return h()}function _(R){try{let b=R.params?.cardId,E=R.params?.all,A=!!R.params?.restart;if(!b&&!E)return j("upsertCard requires --card-id <id> or --all");let Y=E?l().readAllCards().map(te=>te.id):[b];for(let te of Y)if(!l().readCard(te))return j(`Card "${te}" not found in board at ${e.value}`);for(let te of Y){let we=l().readCard(te),_e=Rc(we),Be=t.hashFn(_e),De=t.kvStorage("card-upsert"),dt=De.read(te),lt=dt?.taskConfigHash!==Be;if(!(!lt&&!A)){if(lt){let $t=dt?.blobRef??l().readCardKey(te)??te;p({type:"task-upsert",taskName:te,taskConfig:_e,timestamp:Ce()}),De.write(te,{blobRef:$t,taskConfigHash:Be,updatedAt:Ce()});}A&&p({type:"task-restart",taskName:te,timestamp:Ce()});}}return h(),Q()}catch(b){return ee(b)}}function C(R){try{let b=R.params?.token;if(!b)return j("taskFailed requires params.token");let E=R.params?.error??"unknown error",A=xn(b);return A?(p({type:"task-failed",taskName:A.taskName,error:E,timestamp:Ce()}),h(),Q()):j("Invalid callback token")}catch(b){return ee(b)}}function N(R){try{let b=R.params?.token;if(!b)return j("taskProgress requires params.token");let A=(R.body??{}).update??{},Y=xn(b);return Y?(p({type:"task-progress",taskName:Y.taskName,update:A,timestamp:Ce()}),h(),Q()):j("Invalid callback token")}catch(b){return ee(b)}}function q(R){try{let b=R.params?.token,E=R.params?.ref;if(!b)return j("sourceDataFetched requires params.token");if(!E)return j("sourceDataFetched requires params.ref");let A=$c(b);if(!A)return j("Invalid source token");let{cbk:Y,cid:te,b:we,d:_e,cs:Be,rqt:De}=A,dt=No(t.blobStorage("sources"),ft=>t.resolveBlob(ft)),lt=t.genId();dt.ingestSourceDataStaged(te,_e,Re(E),lt);let $t=xn(Y);if(!$t)return j("Invalid callback token embedded in source token");let Ct=Ce();return p({type:"task-progress",taskName:$t.taskName,update:{bindTo:we,outputFile:_e,fetchedAt:Ct,deliveryToken:lt,sourceChecksum:Be,rqt:De},timestamp:Ct}),h(),Q()}catch(b){return ee(b)}}function F(R){try{let b=R.params?.token,E=R.params?.reason??"unknown";if(!b)return j("sourceDataFetchFailure requires params.token");let A=$c(b);if(!A)return j("Invalid source token");let{cbk:Y,b:te,d:we,cs:_e}=A,Be=xn(Y);return Be?(p({type:"task-progress",taskName:Be.taskName,update:{bindTo:te,outputFile:we,failure:!0,reason:E,sourceChecksum:_e},timestamp:Ce()}),h(),Q()):j("Invalid callback token embedded in source token")}catch(b){return ee(b)}}function re(R){try{let b=i().readCardStoreRef();return b?Q({storeRef:b}):j(`Board at ${e.value} has no card store configured`)}catch(b){return ee(b)}}function U(R){try{let b=i().readOutputsStoreRef();return b?Q({storeRef:b}):j(`Board at ${e.value} has no outputs store configured`)}catch(b){return ee(b)}}function ce(R){try{let b=R.params?.key;if(!b)return j("getConfig requires params.key");let E=i(),A;switch(b){case "task-executor":A=E.readTaskExecutorRef()??null;break;case "chat-handler":A=E.readChatHandlerRef()??null;break;case "card-store-ref":A=E.readCardStoreRef();break;case "outputs-store-ref":A=E.readOutputsStoreRef();break;default:return j(`getConfig: unknown key "${b}"`)}return Q({value:A})}catch(b){return ee(b)}}function qe(R){try{let b=R.params?.key;if(!b)return j("getOutputsDataObject requires params.key");let E=d().readDataObject(b);return Q(E)}catch(b){return ee(b)}}function ct(R){try{return Q(d().readAllDataObjects())}catch(b){return ee(b)}}function M(R){try{let b=R.params?.key;if(!b)return j("getOutputsComputedValues requires params.key");let E=d().readComputedValues(b);return Q(E)}catch(b){return ee(b)}}function V(R){try{return Q(d().readAllComputedValues())}catch(b){return ee(b)}}return {init:m,status:v,getCardStoreRef:re,getOutputsStoreRef:U,getConfig:ce,getOutputsDataObject:qe,getAllOutputsDataObjects:ct,getOutputsComputedValues:M,getAllOutputsComputedValues:V,removeCard:w,retrigger:S,processAccumulatedEvents:$,upsertCard:_,taskFailed:C,taskProgress:N,sourceDataFetched:q,sourceDataFetchFailure:F}}function Eg(e,t){let r=()=>qo(t.kvStorage("config"));function n(){let h=r().readCardStoreRef();if(!h)throw new Error(`Board at ${e.value} has no card store configured. Run: init --base-ref <ref> --store-ref <b64-ref>`);let m=t.kvStorageForRef(h);return {readIndex(){return m.read("_index")},writeIndex(v){m.write("_index",v);},readCard(v){return m.read(v)},writeCard(v,w){return m.write(v,w),t.hashFn(w)},cardExists(v){return m.read(v)!==null},defaultCardKey(v){return v}}}let s=()=>$n(n(),t.onWarn??(()=>{}));function o(h,m){let v=t.validateSchema(m),w=[],S=r().readTaskExecutorRef();if(S&&Array.isArray(m.source_defs))for(let _ of m.source_defs){let C=typeof _.bindTo=="string"?_.bindTo:"(unknown)";try{let N;try{N=t.invokeExecutorSync(S,"validate-source-def",[],{timeout:t.executorTimeouts?.validationMs??1e4,input:JSON.stringify(_)});}catch(F){let re=F;if(N=typeof re?.stdout=="string"?re.stdout:"",!N.trim()){w.push(`source "${C}": executor validate-source-def failed \u2014 ${F instanceof Error?F.message:String(F)}`);continue}}let q=JSON.parse(N.trim());if(!q.ok&&Array.isArray(q.errors))for(let F of q.errors)w.push(`source "${C}": ${F}`);}catch(N){w.push(`source "${C}": executor validate-source-def failed \u2014 ${N instanceof Error?N.message:String(N)}`);}}let $=[...v.errors,...w];return Q({cardId:h,isValid:$.length===0,issues:$})}function a(h,m,v){let w=r().readTaskExecutorRef();if(!w)return j("No task-executor registered for this board");let S=typeof h.bindTo=="string"?h.bindTo:"source",$=t.makeTempFilePath(`probe-in-${S}`),_=t.makeTempFilePath(`probe-out-${S}`),C=t.makeTempFilePath(`probe-err-${S}`,".txt"),N={...h,boardDir:e.value,_projections:m},q=oe({kind:"fs-path",value:$}),F=oe({kind:"fs-path",value:_}),re=oe({kind:"fs-path",value:C});t.absoluteBlob.write($,JSON.stringify(N,null,2));let U=null;try{if(t.invokeExecutorSync(w,"run-source-fetch",["--in-ref",q,"--out-ref",F,"--err-ref",re],{timeout:h.timeout??t.executorTimeouts?.probeMs??6e4}),U=t.absoluteBlob.read(_),U===null)return j("Executor produced no output file")}catch(ce){let qe=t.absoluteBlob.read(C)?.trim()??(ce instanceof Error?ce.message:String(ce));return j(`Probe failed: ${qe}`)}finally{try{t.absoluteBlob.remove($);}catch{}try{t.absoluteBlob.remove(C);}catch{}}if(v){let ce=Re(v);t.absoluteBlob.write(ce.value,U);}else try{t.absoluteBlob.remove(_);}catch{}return Q({bindTo:S,resultSizeBytes:U.length})}function i(h){try{let m=h.params?.cardId,v=h.params?.all;if(!m&&!v)return j("validateCard requires --card-id <id> or --all");let w=v?s().readAllCards().map($=>$.id):[m],S=[];for(let $ of w){let _=s().readCard($);if(!_){S.push({cardId:$,isValid:!1,issues:[`Card "${$}" not found`]});continue}let C=o($,_);if(C.status!=="success")return C;S.push(C.data);}return Q(S)}catch(m){return ee(m)}}function u(h){try{if(!h.body||typeof h.body!="object"||Array.isArray(h.body))return j("validateCardPreflight requires card JSON object in body");let m=h.body,v=m["card-content"]??m,w=typeof v.id=="string"?v.id:"(unknown)",S=o(w,v),$=r().readTaskExecutorRef();if($)try{let _=t.invokeExecutorSync($,"validate-card-preflight",[],{timeout:t.executorTimeouts?.validationMs??1e4,input:JSON.stringify(v)}),C=JSON.parse(_.trim());if(!C.ok&&Array.isArray(C.errors)&&C.errors.length>0){let N=[...S.status==="success"?S.data.issues:[],...C.errors];return Q({cardId:w,isValid:!1,issues:N})}}catch{}return S}catch(m){return ee(m)}}function c(h){try{let m=h.params?.cardId,v=h.params?.sourceIdx,w=h.params?.outRef;if(!m)return j("probeSource requires params.cardId");if(v===void 0)return j("probeSource requires params.sourceIdx");let $=(h.body??{})["mock-projections"]??{},_=s().readCard(m);if(!_)return j(`Card "${m}" not found`);let C=_.source_defs??[];return v<0||v>=C.length?j(`sourceIdx ${v} out of range (card has ${C.length} source(s))`):a(C[v],$,w)}catch(m){return ee(m)}}function l(h){try{let m=h.params?.outRef,v=h.body;if(!v)return j('probeTmpSource requires body with "source-def" and "mock-projections"');let w=v["source-def"],S=v["mock-projections"]??{};return w?a(w,S,m):j('probeTmpSource body requires "source-def"')}catch(m){return ee(m)}}function d(h){try{let m=h.params?.sourceIdx,v=h.params?.outRef;if(m===void 0)return j("probeSourcePreflight requires params.sourceIdx");if(!h.body||typeof h.body!="object"||Array.isArray(h.body))return j("probeSourcePreflight requires card JSON object in body");let w=h.body,S=w["card-content"]??w,$=w["mock-projections"]??{},_=S.source_defs??[];if(m<0||m>=_.length)return j(`sourceIdx ${m} out of range (card has ${_.length} source(s))`);let C=_[m],N=r().readTaskExecutorRef();if(N){let q=typeof C.bindTo=="string"?C.bindTo:"source";try{let F={...C,_projections:$},re=t.invokeExecutorSync(N,"probe-source-preflight",[],{timeout:C.timeout??t.executorTimeouts?.preflightMs??6e4,input:JSON.stringify(F)}),U=JSON.parse(re.trim());return U.ok?Q({bindTo:q,reachable:U.reachable,latencyMs:U.latencyMs,note:U.note}):j(U.error??"Preflight probe failed")}catch{}}return a(C,$,v)}catch(m){return ee(m)}}function y(h){try{let m=r().readTaskExecutorRef();if(!m)return j("No task-executor registered for this board");let v=t.invokeExecutorSync(m,"describe-capabilities",[],{timeout:t.executorTimeouts?.describeMs??1e4});return Q(JSON.parse(v.trim()))}catch(m){return ee(m)}}function g(h){try{let m=h.body;if(!m||!Array.isArray(m.ops))return j("updatesInCardStore requires body.ops array");let v=m.ops,w=s();for(let S of v){let $=S.op,_=S.id;if(!_)return j('op is missing "id"');if($==="update"){let C=S["card-content"];if(!C)return j(`update op for "${_}" is missing "card-content"`);w.writeCard(_,C);}else return j(`Unknown op type: "${$??"(none)"}"`)}return Q()}catch(m){return ee(m)}}function f(h){try{let m=h.body;if(!m||!Array.isArray(m.ids))return j("readFromCardStore requires body.ids array");let v=m.ids,w=s(),S=v.map($=>({id:$,"card-content":w.readCard($)}));return Q({cards:S})}catch(m){return ee(m)}}function p(h){try{if(!h.body||typeof h.body!="object"||Array.isArray(h.body))return j("evalCardCompute requires a JSON object in body");let m=h.body,v=m["card-content"]??m,w=typeof v.id=="string"?v.id:"(unknown)",S=m["mock-fetched-sources"]??{},$=m["mock-requires"]??{},_=v.compute;if(!_||!Array.isArray(_)||_.length===0)return Q({cardId:w,ok:!0,computed_values:{},errors:[]});let C={id:w,card_data:v.card_data??{},requires:$,source_defs:v.source_defs,compute:_},N=it.runSync(C,{sourcesData:S}),q=N.node.computed_values??{},F=N.errors??[];return Q({cardId:w,ok:F.length===0,computed_values:q,errors:F})}catch(m){return ee(m)}}function k(h){try{if(!h.body||typeof h.body!="object"||Array.isArray(h.body))return j("simulateCardCycle requires a JSON object in body");let m=h.body,v=m["card-content"]??m,w=typeof v.id=="string"?v.id:"(unknown)",S=m["mock-fetched-sources"]??{},$=m["mock-requires"]??{},_=o(w,v),C=_.status==="success"?{isValid:_.data.isValid,issues:_.data.issues}:{isValid:!1,issues:[_.status==="fail"?_.error:"internal error"]},N=v.source_defs??[],q=v.card_data??{},F=[],re=[];if(N.length>0){F=it.enrichSourcesSync(N,{card_data:q,requires:$});for(let b of F){let E=b.projections,A=b._projections;if(E&&A){for(let Y of Object.keys(E))if(A[Y]===void 0){let te=typeof b.bindTo=="string"?b.bindTo:"(unknown)";re.push({bindTo:te,key:Y,error:`Projection "${Y}" resolved to undefined`});}}}}let U=[],ce=m["task-executor-ref"],qe=(ce?.howToRun&&ce?.whatToRun?ce:void 0)??r().readTaskExecutorRef();for(let b=0;b<F.length;b++){let E=F[b],A=typeof E.bindTo=="string"?E.bindTo:`source_${b}`;if(!qe){U.push({bindTo:A,skipped:!0,error:"No task executor configured"});continue}try{let Y={...E},te=t.invokeExecutorSync(qe,"probe-source-preflight",[],{timeout:E.timeout??1e4,input:JSON.stringify(Y)}),we=JSON.parse(te.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 ct=v.compute,M={},V=[];if(ct&&Array.isArray(ct)&&ct.length>0){let b={id:w,card_data:q,requires:$,source_defs:v.source_defs,compute:ct},E=it.runSync(b,{sourcesData:S});M=E.node.computed_values??{},V=E.errors??[];}let R=C.isValid&&re.length===0&&V.length===0&&U.every(b=>b.reachable!==!1);return Q({cardId:w,ok:R,validation:C,source_probes:U,projection_errors:re,computed_values:M,compute_errors:V})}catch(m){return ee(m)}}return {validateCard:i,validateCardPreflight:u,probeSource:c,probeTmpSource:l,probeSourcePreflight:d,evalCardCompute:p,simulateCardCycle:k,describeTaskExecutorCapabilities:y,updatesInCardStore:g,readFromCardStore:f}}function xg(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 Tg(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(l=>Math.max(0,Math.min(255,Number(l)||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)}}}}var Tn=".artifacts-index.json";function Ec(){return new Date().toISOString()}function xc(e){return new TextEncoder().encode(e).byteLength}function xr(e){let t=e.read(Tn);if(!t)return {entries:{}};try{let r=JSON.parse(t);if(r&&r.entries&&typeof r.entries=="object")return r}catch{}return {entries:{}}}function Do(e,t){e.write(Tn,JSON.stringify(t,null,2));}function Ag(e){return e?{key:e.key,size:e.size,updatedAt:e.updatedAt,contentType:e.contentType}:null}function Tc(e,t,r){e.entries[t]={key:t,size:r.size,updatedAt:r.updatedAt,contentType:r.contentType};}function Fo(e){let t=String(e||"").match(/^(\d+)[-_]/);return t?parseInt(t[1],10):0}function Ig(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 Pg(e){return String(e||"").toLowerCase().replace(/\s+/g,"_").replace(/[^a-z0-9_-]/g,"_").replace(/_+/g,"_").replace(/^_+|_+$/g,"")||"file"}function Og(e){if(!e||e===".")return "";let t=String(e).replace(/^\./,"").toLowerCase().replace(/[^a-z0-9]/g,"");return t?`.${t}`:""}function jg(e){let t=Ig(e),r=t.lastIndexOf(".");return r<=0||r===t.length-1?{stem:t,ext:""}:{stem:t.slice(0,r),ext:t.slice(r)}}function Ng(e){let t=e.lastIndexOf("/");return t>=0?e.slice(t+1):e}function qg(e){function t(r){let n=e.stat?Ag(e.stat(r)):null;if(n)return n;let o=xr(e).entries[r];if(o)return {...o};if(!e.exists(r))return null;let a=e.read(r);return a===null?{key:r}:{key:r,size:xc(a)}}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};o.contentType=s,o.updatedAt=o.updatedAt??Ec(),o.size=o.size??xc(n);let a=xr(e);return Tc(a,r,o),Do(e,a),o},putBytes(r,n,s="application/octet-stream"){if(e.writeBytes)e.writeBytes(r,n);else {let i=JSON.stringify({__kind:"bytes-array",data:[...n]});e.write(r,i);}let o=t(r)??{key:r};o.contentType=s,o.updatedAt=o.updatedAt??Ec(),o.size=o.size??n.byteLength;let a=xr(e);return Tc(a,r,o),Do(e,a),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=""){let n=new Map;if(e.listKeys)for(let o of e.listKeys(r)){if(o===Tn)continue;let a=t(o)??{key:o};n.set(o,a);}let s=xr(e);for(let[o,a]of Object.entries(s.entries))o===Tn||r&&!o.startsWith(r)||n.has(o)||n.set(o,{...a});return [...n.values()].sort((o,a)=>o.key.localeCompare(a.key))},remove(r){e.remove(r);let n=xr(e);delete n.entries[r],Do(e,n);}}}function Dg(e,t){let r=t?.indexFileName||".index.json";function n(d){return `${d}/${r}`}function s(d){let y=e.getText(n(d));if(!y)return [];try{let g=JSON.parse(y);return Array.isArray(g)?g.filter(f=>f&&typeof f.stored_name=="string").map(f=>({serial:Number(f.serial||Fo(String(f.stored_name))||0),role:String(f.role||"system").toLowerCase(),stored_name:String(f.stored_name),path:typeof f.path=="string"?f.path:`${d}/chats/${String(f.stored_name)}`,updated_at:typeof f.updated_at=="string"?f.updated_at:null})):[]}catch{return []}}function o(d,y){e.putText(n(d),JSON.stringify(y,null,2),"application/json; charset=utf-8");}function a(d){let y=s(d),g=0;for(let f of y){let p=Number(f.serial||0);Number.isFinite(p)&&p>g&&(g=p);}return g+1}function i(d,y){let g=s(d);g.push(y),o(d,g);}function u(d){let y=s(d),g=[];for(let f of y){let p=`${d}/${f.stored_name}`,k=e.getText(p);k!==null&&g.push({serial:Number(f.serial||Fo(f.stored_name)||0),role:String(f.role||"system").toLowerCase(),text:k,path:typeof f.path=="string"?f.path:`${d}/chats/${f.stored_name}`,stored_name:f.stored_name,updated_at:f.updated_at||null});}return g.sort((f,p)=>f.serial-p.serial||f.stored_name.localeCompare(p.stored_name)),g}function c(d){let y=`${d}/`;for(let g of e.list(y))e.remove(g.key);}function l(d){let y=`${d}/`,g=e.list(y),f=0,p=0,k=false;for(let h of g){let m=h.key.slice(y.length);if(m===".processing"){k=true;continue}if(!/^(\d+)[-_]([a-z0-9_-]+)\.txt$/i.test(m))continue;f+=1;let v=h.updatedAt?Number(new Date(h.updatedAt).getTime()||0):0;v>p&&(p=v);}return {count:f,latest_mtime_ms:p,processing:k}}return {indexKey:n,loadIndex:s,saveIndex:o,nextSerial:a,appendIndexRecord:i,readRecords:u,clear:c,readSignal:l}}function Fg(e){function t(s,o){let a=0,i=[];Array.isArray(o)&&i.push(...o);for(let u of e.list(`${s}/`))i.push(Ng(u.key));for(let u of i){let c=Fo(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}=jg(s),l=Og(c),d=Pg(u),y=`${String(o).padStart(3,"0")}-`,g=l,f=i-y.length-g.length;f<1&&(g="",f=i-y.length);let p=d.slice(0,Math.max(1,f)),k=`${y}${p}${g}`;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 Mg(){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 Ib(){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};if(n.chatsKeyPrefix&&n.chatsBlobBasePath){let o=String(n.chatsKeyPrefix).split("/")[0];n.chatDir=pt(String(n.chatsBlobBasePath),o);}delete n.chatsKeyPrefix,delete n.chatsBlobBasePath;let 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 Bg=".board.lock";function Gg(e,t){return typeof e=="string"?{cliDir:e,opts:t}:{cliDir:void 0,opts:e}}function Kg(e,t){return typeof e=="string"?{cliDir:e,opts:t}:{cliDir:void 0,opts:e}}function Ac(e){if(e)return e;let t=Yo((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,pt(t,"..","cli","node"),pt(t,"..","..","cli","node")];for(let n of r)try{return qn(n),n}catch{}throw new Error(`createFsBoardPlatformAdapter: could not resolve a public CLI directory from module dir ${t}`)}function Ug(e,t,r){let{cliDir:n,opts:s}=Gg(t,r),o=Ac(n),a=e.value,i=s?.suppressSpawn?"":qn(o),u={meta:"board-live-cards",howToRun:"local-node",whatToRun:i?oe({kind:"fs-path",value:i}):"",...s?.notifyChannel?{extra:{notifyChannel:s.notifyChannel}}:{}};return {kvStorage:c=>Kn(pt(a,`.${c}`)),blobStorage:c=>c?qr(pt(a,c)):qr(a),journalAdapter:()=>pa(a),lock:ma(pt(a,Bg)),selfRef:u,async dispatchExecution(c,l){if(s?.suppressSpawn)return {dispatched:false};try{let d=l.source_def?.bindTo??On().slice(0,8),y=Jt(a,`exec-in-${d}`),g=Jt(a,`exec-out-${d}`),f=Jt(a,`exec-err-${d}`,".txt"),p=oe({kind:"fs-path",value:y}),k=oe({kind:"fs-path",value:g}),h=oe({kind:"fs-path",value:f});return la({kind:"fs-path",value:y}).write(y,JSON.stringify(l,null,2)),da(c,{subcommand:"run-source-fetch",inRef:p,outRef:k,errRef:h},o),{dispatched:!0}}catch(d){return {dispatched:false,error:d instanceof Error?d.message:String(d)}}},resolveBlob(c){let l=zo(c.value)?Gn().read(c.value):qr(a).read(c.value);if(l===null)throw new Error(`resolveBlob: blob not found: ::${c.kind}::${c.value}`);return l},hashFn:fa,genId:()=>Wo(`${Date.now()}-${Math.random()}`).slice(0,32),kvStorageForRef:c=>Kn(Re(c).value),requestProcessAccumulated(){s?.suppressSpawn||Zo(o,e,s?.notifyChannel);},publishBoardChangeNotifications(c){if(!s?.notifyChannel||c.length===0)return;let l=c.map(d=>({id:On(),ts:new Date().toISOString(),boardRef:oe(e),notification:d}));ea(s.notifyChannel,l,s.onWarn);},onWarn:s?.onWarn}}function Pb(e,t,r){let{cliDir:n,opts:s}=Kg(t,r),o=Ac(n),a=Ug(e,o,s),i=Nr();return {...a,invokeExecutorSync(u,c,l,d){let{command:y,baseArgs:g}=Fn(u,o),f=u.extra?["--extra",Buffer.from(JSON.stringify(u.extra)).toString("base64")]:[];return i.executeSync(y,[...g,c,...l,...f],{timeout:d?.timeout??3e4,encoding:"utf-8",input:d?.input})},validateSchema(u){let c=Io(u);return {ok:c.errors.length===0,errors:c.errors}},makeTempFilePath(u,c){return Jt(e.value,u,c)},absoluteBlob:Gn()}}function Ob(e){try{let t=JSON.parse(Buffer.from(e,"base64url").toString());return typeof t.br=="string"?t.br:null}catch{return null}}
|
|
13
|
+
exports.BOARD_GRAPH_KEY=ut;exports.EMPTY_CONFIG=En;exports.SNAPSHOT_SCHEMA_VERSION_V1=Er;exports.createArtifactsStore=qg;exports.createArtifactsStorePublic=Tg;exports.createBoardLiveCardsNonCorePublic=Eg;exports.createBoardLiveCardsPublic=Cg;exports.createCardFileMetadataStore=Mg;exports.createCardStore=$n;exports.createCardStorePublic=xg;exports.createChatArtifactsStore=Dg;exports.createExecutionRefInvoker=ud;exports.createFileArtifactsStore=Fg;exports.createFsBoardNonCorePlatformAdapter=Pb;exports.createFsBoardPlatformAdapter=Ug;exports.createNodeSpawnInvocationAdapter=Ib;exports.decodeBoardRefFromToken=Ob;exports.evaluateArgsMassaging=Mn;exports.executionRefFromScriptPath=vg;exports.invokeExecutionRef=ca;exports.invokeExecutionRefSync=Ln;exports.invokeRefSync=cd;exports.parseExecutionRef=Rn;exports.parseRef=Re;exports.serializeExecutionRef=_n;exports.serializeRef=oe;//# sourceMappingURL=board-live-cards-node.cjs.map
|
|
14
14
|
//# sourceMappingURL=board-live-cards-node.cjs.map
|