yaml-flow 8.5.3 → 8.6.1
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 +3 -3
- package/examples/board/demo-shell-with-server.html +2 -2
- package/examples/board/doc.html +2 -2
- package/examples/board/server/board-server.js +266 -5
- package/examples/board/server/board-worker/task-executor.js +166 -51
- package/examples/board/server/chat-flow/copilot-chat/assistant.js +25 -12
- package/examples/board/server/chat-flow/copilot-chat/probe.js +7 -0
- package/examples/board/server/chat-flow/copilot-chat/shared.js +97 -0
- package/examples/board/server/chat-flow/flow-steps.json +109 -51
- package/examples/board/server-config.json +1 -0
- package/examples/board/test/server-http-test.js +870 -67
- package/examples/board-local/demo-shell-localstorage.html +3 -3
- package/lib/{artifacts-store-lib-D-k-E8Vy.d.ts → artifacts-store-lib-C1rtrkxm.d.ts} +1 -1
- package/lib/{artifacts-store-lib-CVgtQrNZ.d.cts → artifacts-store-lib-CLOtsiav.d.cts} +1 -1
- package/lib/artifacts-store-public.cjs +1 -1
- package/lib/artifacts-store-public.d.cts +3 -3
- package/lib/artifacts-store-public.d.ts +3 -3
- package/lib/artifacts-store-public.js +1 -1
- package/lib/batch/index.cjs +1 -1
- package/lib/batch/index.js +1 -1
- package/lib/board-live-cards-mcp.cjs +1 -1
- package/lib/board-live-cards-mcp.d.cts +35 -15
- package/lib/board-live-cards-mcp.d.ts +35 -15
- package/lib/board-live-cards-mcp.js +1 -1
- package/lib/board-live-cards-node.cjs +8 -16
- package/lib/board-live-cards-node.d.cts +32 -12
- package/lib/board-live-cards-node.d.ts +32 -12
- package/lib/board-live-cards-node.js +8 -16
- package/lib/{board-live-cards-public-BGS22cMb.d.ts → board-live-cards-public-CBVjm327.d.ts} +59 -24
- package/lib/{board-live-cards-public-B13InXhC.d.cts → board-live-cards-public-CPJy-aGW.d.cts} +59 -24
- package/lib/board-live-cards-public.cjs +1 -2
- package/lib/board-live-cards-public.d.cts +2 -2
- package/lib/board-live-cards-public.d.ts +2 -2
- package/lib/board-live-cards-public.js +1 -2
- package/lib/board-live-cards-server-runtime.cjs +1 -7
- package/lib/board-live-cards-server-runtime.d.cts +5 -5
- package/lib/board-live-cards-server-runtime.d.ts +5 -5
- package/lib/board-live-cards-server-runtime.js +1 -7
- package/lib/board-livegraph-runtime/index.cjs +1 -2
- package/lib/board-livegraph-runtime/index.js +1 -2
- package/lib/board-worker-adapter.cjs +21 -7
- package/lib/board-worker-adapter.d.cts +17 -2
- package/lib/board-worker-adapter.d.ts +17 -2
- package/lib/board-worker-adapter.js +21 -7
- package/lib/card-compute/index.cjs +1 -9
- package/lib/card-compute/index.js +1 -9
- package/lib/card-store-public.cjs +1 -1
- package/lib/card-store-public.d.cts +2 -2
- package/lib/card-store-public.d.ts +2 -2
- package/lib/card-store-public.js +1 -1
- package/lib/card-validation.cjs +1 -9
- package/lib/card-validation.js +1 -9
- package/lib/{chat-storage-lib-CJn7a6OH.d.ts → chat-storage-lib-Bce-xx6l.d.ts} +1 -1
- package/lib/{chat-storage-lib-0imhRX3l.d.cts → chat-storage-lib-CKylihjm.d.cts} +1 -1
- package/lib/chat-store-public.cjs +1 -1
- package/lib/chat-store-public.d.cts +3 -3
- package/lib/chat-store-public.d.ts +3 -3
- package/lib/chat-store-public.js +1 -1
- package/lib/chunk-2MZUYY65.cjs +2 -0
- package/lib/chunk-5DB54ZX2.cjs +2 -0
- package/lib/chunk-5EA2ESS4.cjs +16 -0
- package/lib/chunk-6APH25VI.js +2 -0
- package/lib/chunk-76ON3V7R.js +2 -0
- package/lib/chunk-7BKNHFNH.js +2 -0
- package/lib/chunk-CWREBRXS.js +3 -0
- package/lib/chunk-DAXACY63.js +2 -0
- package/lib/chunk-FW4363Y4.js +2 -0
- package/lib/chunk-FZ2SBU5M.js +3 -0
- package/lib/chunk-G4XXRHL2.cjs +3 -0
- package/lib/chunk-GNFE24S7.cjs +2 -0
- package/lib/chunk-GYQXDNNI.cjs +2 -0
- package/lib/chunk-H5KD3JPY.cjs +2 -0
- package/lib/chunk-HLJH7LGW.js +16 -0
- package/lib/chunk-I4WH5U5D.cjs +2 -0
- package/lib/chunk-IXZG74EW.cjs +2 -0
- package/lib/chunk-JAL25FGA.cjs +2 -0
- package/lib/chunk-JM5EKT57.js +2 -0
- package/lib/chunk-JMDHDY6M.js +2 -0
- package/lib/chunk-KBELAKIY.js +2 -0
- package/lib/chunk-KHJABJ45.cjs +3 -0
- package/lib/chunk-KLRUISRY.cjs +2 -0
- package/lib/chunk-KNFFDVLD.cjs +2 -0
- package/lib/chunk-LBMEVV4U.js +2 -0
- package/lib/chunk-LDAP75GN.js +2 -0
- package/lib/chunk-LODXIALE.cjs +2 -0
- package/lib/chunk-LVNQCE5X.cjs +3 -0
- package/lib/chunk-M7EQRS6W.js +3 -0
- package/lib/chunk-MNEOJWPS.js +10 -0
- package/lib/chunk-NJJ7WEDT.cjs +2 -0
- package/lib/chunk-NMZ6XNLB.cjs +3 -0
- package/lib/chunk-OPNGCSXJ.js +2 -0
- package/lib/chunk-P64UKI3L.cjs +8 -0
- package/lib/chunk-P7ZCDICS.cjs +2 -0
- package/lib/chunk-Q6H7NINN.cjs +5 -0
- package/lib/chunk-Q6VSL327.js +8 -0
- package/lib/chunk-QWBNDVUA.js +5 -0
- package/lib/chunk-S6DRP2HX.cjs +2 -0
- package/lib/chunk-UJ7ZTV4J.cjs +10 -0
- package/lib/chunk-UVE65IPR.cjs +3 -0
- package/lib/chunk-VCCTAUIG.js +2 -0
- package/lib/chunk-VGT3TRQG.js +3 -0
- package/lib/chunk-VLBB3D6B.js +3 -0
- package/lib/chunk-WDPOGXTY.js +2 -0
- package/lib/chunk-X3LC4LII.js +2 -0
- package/lib/chunk-YGKDQLYP.js +2 -0
- package/lib/chunk-YMEIPKLW.cjs +2 -0
- package/lib/config/index.cjs +1 -1
- package/lib/config/index.js +1 -1
- package/lib/continuous-event-graph/index.cjs +1 -2
- package/lib/continuous-event-graph/index.js +1 -2
- package/lib/event-graph/index.cjs +1 -22
- package/lib/event-graph/index.js +1 -22
- package/lib/execution-refs.cjs +1 -2
- package/lib/execution-refs.d.cts +3 -2
- package/lib/execution-refs.d.ts +3 -2
- package/lib/execution-refs.js +1 -2
- package/lib/index.cjs +2 -24
- package/lib/index.d.cts +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +2 -24
- package/lib/server-runtime/index.cjs +1 -7
- package/lib/server-runtime/index.d.cts +6 -6
- package/lib/server-runtime/index.d.ts +6 -6
- package/lib/server-runtime/index.js +1 -7
- package/lib/step-machine/index.cjs +1 -11
- package/lib/step-machine/index.js +1 -11
- package/lib/step-machine-public/index.cjs +1 -4
- package/lib/step-machine-public/index.d.cts +1 -1
- package/lib/step-machine-public/index.d.ts +1 -1
- package/lib/step-machine-public/index.js +1 -4
- package/lib/{storage-interface-B2WD9D5n.d.cts → storage-interface-Ct-C4tlz.d.cts} +28 -1
- package/lib/{storage-interface-B2WD9D5n.d.ts → storage-interface-Ct-C4tlz.d.ts} +28 -1
- package/lib/stores/index.cjs +1 -2
- package/lib/stores/index.d.cts +1 -1
- package/lib/stores/index.d.ts +1 -1
- package/lib/stores/index.js +1 -2
- package/lib/stores/kv.cjs +1 -2
- package/lib/stores/kv.d.cts +1 -1
- package/lib/stores/kv.d.ts +1 -1
- package/lib/stores/kv.js +1 -2
- package/lib/stores/memory.cjs +1 -1
- package/lib/stores/memory.js +1 -1
- package/lib/{types-30R357js.d.ts → types-BuK2UMxk.d.ts} +4 -4
- package/lib/{types-CIgsh56O.d.cts → types-DRl0Hy_p.d.cts} +4 -4
- package/package.json +2 -16
- package/cli/board-live-cards-lib-COi4bSpk.d.ts +0 -322
- package/cli/browser-api/board-live-cards-browser-adapter.d.ts +0 -36
- package/cli/browser-api/board-live-cards-browser-adapter.js +0 -4
- package/cli/browser-api/card-store-browser-api.d.ts +0 -25
- package/cli/browser-api/card-store-browser-api.js +0 -2
- package/cli/browser-api/jsonata-sync.cjs +0 -7623
- package/cli/bundled/artifacts-store-cli.mjs +0 -12
- package/cli/bundled/batch-runner-cli.mjs +0 -3
- package/cli/bundled/board-live-cards-cli.mjs +0 -29
- package/cli/bundled/card-store-cli.mjs +0 -154
- package/cli/bundled/chat-store-cli.mjs +0 -16
- package/cli/bundled/jsonata-sync.cjs +0 -7623
- package/cli/bundled/step-machine-cli.mjs +0 -150
- package/cli/execution-interface-BCIhu1gO.d.ts +0 -442
- package/cli/types-H3EMBPY2.d.ts +0 -398
- package/examples/board/server/README-mcp-api.md +0 -690
- package/examples/board/test/server-http-mcp-test.js +0 -1280
- package/lib/board-livegraph-runtime/jsonata-sync.cjs +0 -7623
- package/lib/card-compute/jsonata-sync.cjs +0 -7623
- package/lib/continuous-event-graph/jsonata-sync.cjs +0 -7623
- package/lib/server-runtime/jsonata-sync.cjs +0 -7623
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import {a}from'./chunk-FW4363Y4.js';var Qe=a(I=>{Object.defineProperty(I,"__esModule",{value:true});I.regexpCode=I.getEsmExportName=I.getProperty=I.safeStringify=I.stringify=I.strConcat=I.addCodeArg=I.str=I._=I.nil=I._Code=I.Name=I.IDENTIFIER=I._CodeOrName=void 0;var Je=class{};I._CodeOrName=Je;I.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var we=class extends Je{constructor(e){if(super(),!I.IDENTIFIER.test(e))throw new Error("CodeGen: name must be a valid identifier");this.str=e;}toString(){return this.str}emptyStr(){return false}get names(){return {[this.str]:1}}};I.Name=we;var Q=class extends Je{constructor(e){super(),this._items=typeof e=="string"?[e]:e;}toString(){return this.str}emptyStr(){if(this._items.length>1)return false;let e=this._items[0];return e===""||e==='""'}get str(){var e;return (e=this._str)!==null&&e!==void 0?e:this._str=this._items.reduce((r,s)=>`${r}${s}`,"")}get names(){var e;return (e=this._names)!==null&&e!==void 0?e:this._names=this._items.reduce((r,s)=>(s instanceof we&&(r[s.str]=(r[s.str]||0)+1),r),{})}};I._Code=Q;I.nil=new Q("");function Ls(t,...e){let r=[t[0]],s=0;for(;s<e.length;)or(r,e[s]),r.push(t[++s]);return new Q(r)}I._=Ls;var nr=new Q("+");function Hs(t,...e){let r=[We(t[0])],s=0;for(;s<e.length;)r.push(nr),or(r,e[s]),r.push(nr,We(t[++s]));return $a(r),new Q(r)}I.str=Hs;function or(t,e){e instanceof Q?t.push(...e._items):e instanceof we?t.push(e):t.push(ba(e));}I.addCodeArg=or;function $a(t){let e=1;for(;e<t.length-1;){if(t[e]===nr){let r=va(t[e-1],t[e+1]);if(r!==void 0){t.splice(e-1,3,r);continue}t[e++]="+";}e++;}}function va(t,e){if(e==='""')return t;if(t==='""')return e;if(typeof t=="string")return e instanceof we||t[t.length-1]!=='"'?void 0:typeof e!="string"?`${t.slice(0,-1)}${e}"`:e[0]==='"'?t.slice(0,-1)+e.slice(1):void 0;if(typeof e=="string"&&e[0]==='"'&&!(t instanceof we))return `"${t}${e.slice(1)}`}function wa(t,e){return e.emptyStr()?t:t.emptyStr()?e:Hs`${t}${e}`}I.strConcat=wa;function ba(t){return typeof t=="number"||typeof t=="boolean"||t===null?t:We(Array.isArray(t)?t.join(","):t)}function Ea(t){return new Q(We(t))}I.stringify=Ea;function We(t){return JSON.stringify(t).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}I.safeStringify=We;function Sa(t){return typeof t=="string"&&I.IDENTIFIER.test(t)?new Q(`.${t}`):Ls`[${t}]`}I.getProperty=Sa;function Pa(t){if(typeof t=="string"&&I.IDENTIFIER.test(t))return new Q(`${t}`);throw new Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}I.getEsmExportName=Pa;function Na(t){return new Q(t.toString())}I.regexpCode=Na;});var cr=a(G=>{Object.defineProperty(G,"__esModule",{value:true});G.ValueScope=G.ValueScopeName=G.Scope=G.varKinds=G.UsedValueState=void 0;var H=Qe(),ar=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value;}},wt;(function(t){t[t.Started=0]="Started",t[t.Completed=1]="Completed";})(wt||(G.UsedValueState=wt={}));G.varKinds={const:new H.Name("const"),let:new H.Name("let"),var:new H.Name("var")};var bt=class{constructor({prefixes:e,parent:r}={}){this._names={},this._prefixes=e,this._parent=r;}toName(e){return e instanceof H.Name?e:this.name(e)}name(e){return new H.Name(this._newName(e))}_newName(e){let r=this._names[e]||this._nameGroup(e);return `${e}${r.index++}`}_nameGroup(e){var r,s;if(!((s=(r=this._parent)===null||r===void 0?void 0:r._prefixes)===null||s===void 0)&&s.has(e)||this._prefixes&&!this._prefixes.has(e))throw new Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};G.Scope=bt;var Et=class extends H.Name{constructor(e,r){super(r),this.prefix=e;}setValue(e,{property:r,itemIndex:s}){this.value=e,this.scopePath=(0, H._)`.${new H.Name(r)}[${s}]`;}};G.ValueScopeName=Et;var ka=(0, H._)`\n`,ir=class extends bt{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?ka:H.nil};}get(){return this._scope}name(e){return new Et(e,this._newName(e))}value(e,r){var s;if(r.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let n=this.toName(e),{prefix:o}=n,a=(s=r.key)!==null&&s!==void 0?s:r.ref,i=this._values[o];if(i){let u=i.get(a);if(u)return u}else i=this._values[o]=new Map;i.set(a,n);let c=this._scope[o]||(this._scope[o]=[]),l=c.length;return c[l]=r.ref,n.setValue(r,{property:o,itemIndex:l}),n}getValue(e,r){let s=this._values[e];if(s)return s.get(r)}scopeRefs(e,r=this._values){return this._reduceValues(r,s=>{if(s.scopePath===void 0)throw new Error(`CodeGen: name "${s}" has no value`);return (0, H._)`${e}${s.scopePath}`})}scopeCode(e=this._values,r,s){return this._reduceValues(e,n=>{if(n.value===void 0)throw new Error(`CodeGen: name "${n}" has no value`);return n.value.code},r,s)}_reduceValues(e,r,s={},n){let o=H.nil;for(let a in e){let i=e[a];if(!i)continue;let c=s[a]=s[a]||new Map;i.forEach(l=>{if(c.has(l))return;c.set(l,wt.Started);let u=r(l);if(u){let d=this.opts.es5?G.varKinds.var:G.varKinds.const;o=(0, H._)`${o}${d} ${l} = ${u};${this.opts._n}`;}else if(u=n?.(l))o=(0, H._)`${o}${u}${this.opts._n}`;else throw new ar(l);c.set(l,wt.Completed);});}return o}};G.ValueScope=ir;});var S=a(E=>{Object.defineProperty(E,"__esModule",{value:true});E.or=E.and=E.not=E.CodeGen=E.operators=E.varKinds=E.ValueScopeName=E.ValueScope=E.Scope=E.Name=E.regexpCode=E.stringify=E.getProperty=E.nil=E.strConcat=E.str=E._=void 0;var k=Qe(),Z=cr(),pe=Qe();Object.defineProperty(E,"_",{enumerable:true,get:function(){return pe._}});Object.defineProperty(E,"str",{enumerable:true,get:function(){return pe.str}});Object.defineProperty(E,"strConcat",{enumerable:true,get:function(){return pe.strConcat}});Object.defineProperty(E,"nil",{enumerable:true,get:function(){return pe.nil}});Object.defineProperty(E,"getProperty",{enumerable:true,get:function(){return pe.getProperty}});Object.defineProperty(E,"stringify",{enumerable:true,get:function(){return pe.stringify}});Object.defineProperty(E,"regexpCode",{enumerable:true,get:function(){return pe.regexpCode}});Object.defineProperty(E,"Name",{enumerable:true,get:function(){return pe.Name}});var kt=cr();Object.defineProperty(E,"Scope",{enumerable:true,get:function(){return kt.Scope}});Object.defineProperty(E,"ValueScope",{enumerable:true,get:function(){return kt.ValueScope}});Object.defineProperty(E,"ValueScopeName",{enumerable:true,get:function(){return kt.ValueScopeName}});Object.defineProperty(E,"varKinds",{enumerable:true,get:function(){return kt.varKinds}});E.operators={GT:new k._Code(">"),GTE:new k._Code(">="),LT:new k._Code("<"),LTE:new k._Code("<="),EQ:new k._Code("==="),NEQ:new k._Code("!=="),NOT:new k._Code("!"),OR:new k._Code("||"),AND:new k._Code("&&"),ADD:new k._Code("+")};var ue=class{optimizeNodes(){return this}optimizeNames(e,r){return this}},ur=class extends ue{constructor(e,r,s){super(),this.varKind=e,this.name=r,this.rhs=s;}render({es5:e,_n:r}){let s=e?Z.varKinds.var:this.varKind,n=this.rhs===void 0?"":` = ${this.rhs}`;return `${s} ${this.name}${n};`+r}optimizeNames(e,r){if(e[this.name.str])return this.rhs&&(this.rhs=Re(this.rhs,e,r)),this}get names(){return this.rhs instanceof k._CodeOrName?this.rhs.names:{}}},St=class extends ue{constructor(e,r,s){super(),this.lhs=e,this.rhs=r,this.sideEffects=s;}render({_n:e}){return `${this.lhs} = ${this.rhs};`+e}optimizeNames(e,r){if(!(this.lhs instanceof k.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=Re(this.rhs,e,r),this}get names(){let e=this.lhs instanceof k.Name?{}:{...this.lhs.names};return Nt(e,this.rhs)}},lr=class extends St{constructor(e,r,s,n){super(e,s,n),this.op=r;}render({_n:e}){return `${this.lhs} ${this.op}= ${this.rhs};`+e}},dr=class extends ue{constructor(e){super(),this.label=e,this.names={};}render({_n:e}){return `${this.label}:`+e}},fr=class extends ue{constructor(e){super(),this.label=e,this.names={};}render({_n:e}){return `break${this.label?` ${this.label}`:""};`+e}},hr=class extends ue{constructor(e){super(),this.error=e;}render({_n:e}){return `throw ${this.error};`+e}get names(){return this.error.names}},pr=class extends ue{constructor(e){super(),this.code=e;}render({_n:e}){return `${this.code};`+e}optimizeNodes(){return `${this.code}`?this:void 0}optimizeNames(e,r){return this.code=Re(this.code,e,r),this}get names(){return this.code instanceof k._CodeOrName?this.code.names:{}}},Be=class extends ue{constructor(e=[]){super(),this.nodes=e;}render(e){return this.nodes.reduce((r,s)=>r+s.render(e),"")}optimizeNodes(){let{nodes:e}=this,r=e.length;for(;r--;){let s=e[r].optimizeNodes();Array.isArray(s)?e.splice(r,1,...s):s?e[r]=s:e.splice(r,1);}return e.length>0?this:void 0}optimizeNames(e,r){let{nodes:s}=this,n=s.length;for(;n--;){let o=s[n];o.optimizeNames(e,r)||(qa(e,o.names),s.splice(n,1));}return s.length>0?this:void 0}get names(){return this.nodes.reduce((e,r)=>Se(e,r.names),{})}},le=class extends Be{render(e){return "{"+e._n+super.render(e)+"}"+e._n}},mr=class extends Be{},Ie=class extends le{};Ie.kind="else";var be=class t extends le{constructor(e,r){super(r),this.condition=e;}render(e){let r=`if(${this.condition})`+super.render(e);return this.else&&(r+="else "+this.else.render(e)),r}optimizeNodes(){super.optimizeNodes();let e=this.condition;if(e===true)return this.nodes;let r=this.else;if(r){let s=r.optimizeNodes();r=this.else=Array.isArray(s)?new Ie(s):s;}if(r)return e===false?r instanceof t?r:r.nodes:this.nodes.length?this:new t(Gs(e),r instanceof t?[r]:r.nodes);if(!(e===false||!this.nodes.length))return this}optimizeNames(e,r){var s;if(this.else=(s=this.else)===null||s===void 0?void 0:s.optimizeNames(e,r),!!(super.optimizeNames(e,r)||this.else))return this.condition=Re(this.condition,e,r),this}get names(){let e=super.names;return Nt(e,this.condition),this.else&&Se(e,this.else.names),e}};be.kind="if";var Ee=class extends le{};Ee.kind="for";var yr=class extends Ee{constructor(e){super(),this.iteration=e;}render(e){return `for(${this.iteration})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iteration=Re(this.iteration,e,r),this}get names(){return Se(super.names,this.iteration.names)}},_r=class extends Ee{constructor(e,r,s,n){super(),this.varKind=e,this.name=r,this.from=s,this.to=n;}render(e){let r=e.es5?Z.varKinds.var:this.varKind,{name:s,from:n,to:o}=this;return `for(${r} ${s}=${n}; ${s}<${o}; ${s}++)`+super.render(e)}get names(){let e=Nt(super.names,this.from);return Nt(e,this.to)}},Pt=class extends Ee{constructor(e,r,s,n){super(),this.loop=e,this.varKind=r,this.name=s,this.iterable=n;}render(e){return `for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iterable=Re(this.iterable,e,r),this}get names(){return Se(super.names,this.iterable.names)}},Xe=class extends le{constructor(e,r,s){super(),this.name=e,this.args=r,this.async=s;}render(e){return `${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(e)}};Xe.kind="func";var Ye=class extends Be{render(e){return "return "+super.render(e)}};Ye.kind="return";var gr=class extends le{render(e){let r="try"+super.render(e);return this.catch&&(r+=this.catch.render(e)),this.finally&&(r+=this.finally.render(e)),r}optimizeNodes(){var e,r;return super.optimizeNodes(),(e=this.catch)===null||e===void 0||e.optimizeNodes(),(r=this.finally)===null||r===void 0||r.optimizeNodes(),this}optimizeNames(e,r){var s,n;return super.optimizeNames(e,r),(s=this.catch)===null||s===void 0||s.optimizeNames(e,r),(n=this.finally)===null||n===void 0||n.optimizeNames(e,r),this}get names(){let e=super.names;return this.catch&&Se(e,this.catch.names),this.finally&&Se(e,this.finally.names),e}},Ze=class extends le{constructor(e){super(),this.error=e;}render(e){return `catch(${this.error})`+super.render(e)}};Ze.kind="catch";var et=class extends le{render(e){return "finally"+super.render(e)}};et.kind="finally";var $r=class{constructor(e,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
|
|
2
|
+
`:""},this._extScope=e,this._scope=new Z.Scope({parent:e}),this._nodes=[new mr];}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,r){let s=this._extScope.value(e,r);return (this._values[s.prefix]||(this._values[s.prefix]=new Set)).add(s),s}getScopeValue(e,r){return this._extScope.getValue(e,r)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,r,s,n){let o=this._scope.toName(r);return s!==void 0&&n&&(this._constants[o.str]=s),this._leafNode(new ur(e,o,s)),o}const(e,r,s){return this._def(Z.varKinds.const,e,r,s)}let(e,r,s){return this._def(Z.varKinds.let,e,r,s)}var(e,r,s){return this._def(Z.varKinds.var,e,r,s)}assign(e,r,s){return this._leafNode(new St(e,r,s))}add(e,r){return this._leafNode(new lr(e,E.operators.ADD,r))}code(e){return typeof e=="function"?e():e!==k.nil&&this._leafNode(new pr(e)),this}object(...e){let r=["{"];for(let[s,n]of e)r.length>1&&r.push(","),r.push(s),(s!==n||this.opts.es5)&&(r.push(":"),(0, k.addCodeArg)(r,n));return r.push("}"),new k._Code(r)}if(e,r,s){if(this._blockNode(new be(e)),r&&s)this.code(r).else().code(s).endIf();else if(r)this.code(r).endIf();else if(s)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(e){return this._elseNode(new be(e))}else(){return this._elseNode(new Ie)}endIf(){return this._endBlockNode(be,Ie)}_for(e,r){return this._blockNode(e),r&&this.code(r).endFor(),this}for(e,r){return this._for(new yr(e),r)}forRange(e,r,s,n,o=this.opts.es5?Z.varKinds.var:Z.varKinds.let){let a=this._scope.toName(e);return this._for(new _r(o,a,r,s),()=>n(a))}forOf(e,r,s,n=Z.varKinds.const){let o=this._scope.toName(e);if(this.opts.es5){let a=r instanceof k.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0, k._)`${a}.length`,i=>{this.var(o,(0, k._)`${a}[${i}]`),s(o);})}return this._for(new Pt("of",n,o,r),()=>s(o))}forIn(e,r,s,n=this.opts.es5?Z.varKinds.var:Z.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0, k._)`Object.keys(${r})`,s);let o=this._scope.toName(e);return this._for(new Pt("in",n,o,r),()=>s(o))}endFor(){return this._endBlockNode(Ee)}label(e){return this._leafNode(new dr(e))}break(e){return this._leafNode(new fr(e))}return(e){let r=new Ye;if(this._blockNode(r),this.code(e),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(Ye)}try(e,r,s){if(!r&&!s)throw new Error('CodeGen: "try" without "catch" and "finally"');let n=new gr;if(this._blockNode(n),this.code(e),r){let o=this.name("e");this._currNode=n.catch=new Ze(o),r(o);}return s&&(this._currNode=n.finally=new et,this.code(s)),this._endBlockNode(Ze,et)}throw(e){return this._leafNode(new hr(e))}block(e,r){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(r),this}endBlock(e){let r=this._blockStarts.pop();if(r===void 0)throw new Error("CodeGen: not in self-balancing block");let s=this._nodes.length-r;if(s<0||e!==void 0&&s!==e)throw new Error(`CodeGen: wrong number of nodes: ${s} vs ${e} expected`);return this._nodes.length=r,this}func(e,r=k.nil,s,n){return this._blockNode(new Xe(e,r,s)),n&&this.code(n).endFunc(),this}endFunc(){return this._endBlockNode(Xe)}optimize(e=1){for(;e-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants);}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e);}_endBlockNode(e,r){let s=this._currNode;if(s instanceof e||r&&s instanceof r)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${r?`${e.kind}/${r.kind}`:e.kind}"`)}_elseNode(e){let r=this._currNode;if(!(r instanceof be))throw new Error('CodeGen: "else" without "if"');return this._currNode=r.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let r=this._nodes;r[r.length-1]=e;}};E.CodeGen=$r;function Se(t,e){for(let r in e)t[r]=(t[r]||0)+(e[r]||0);return t}function Nt(t,e){return e instanceof k._CodeOrName?Se(t,e.names):t}function Re(t,e,r){if(t instanceof k.Name)return s(t);if(!n(t))return t;return new k._Code(t._items.reduce((o,a)=>(a instanceof k.Name&&(a=s(a)),a instanceof k._Code?o.push(...a._items):o.push(a),o),[]));function s(o){let a=r[o.str];return a===void 0||e[o.str]!==1?o:(delete e[o.str],a)}function n(o){return o instanceof k._Code&&o._items.some(a=>a instanceof k.Name&&e[a.str]===1&&r[a.str]!==void 0)}}function qa(t,e){for(let r in e)t[r]=(t[r]||0)-(e[r]||0);}function Gs(t){return typeof t=="boolean"||typeof t=="number"||t===null?!t:(0, k._)`!${vr(t)}`}E.not=Gs;var ja=Js(E.operators.AND);function Oa(...t){return t.reduce(ja)}E.and=Oa;var Ia=Js(E.operators.OR);function Ra(...t){return t.reduce(Ia)}E.or=Ra;function Js(t){return (e,r)=>e===k.nil?r:r===k.nil?e:(0, k._)`${vr(e)} ${t} ${vr(r)}`}function vr(t){return t instanceof k.Name?t:(0, k._)`(${t})`}});var j=a(P=>{Object.defineProperty(P,"__esModule",{value:true});P.checkStrictMode=P.getErrorPath=P.Type=P.useFunc=P.setEvaluated=P.evaluatedPropsToName=P.mergeEvaluated=P.eachItem=P.unescapeJsonPointer=P.escapeJsonPointer=P.escapeFragment=P.unescapeFragment=P.schemaRefOrVal=P.schemaHasRulesButRef=P.schemaHasRules=P.checkUnknownRules=P.alwaysValidSchema=P.toHash=void 0;var T=S(),Ta=Qe();function Ca(t){let e={};for(let r of t)e[r]=true;return e}P.toHash=Ca;function Ma(t,e){return typeof e=="boolean"?e:Object.keys(e).length===0?true:(Bs(t,e),!Xs(e,t.self.RULES.all))}P.alwaysValidSchema=Ma;function Bs(t,e=t.schema){let{opts:r,self:s}=t;if(!r.strictSchema||typeof e=="boolean")return;let n=s.RULES.keywords;for(let o in e)n[o]||en(t,`unknown keyword: "${o}"`);}P.checkUnknownRules=Bs;function Xs(t,e){if(typeof t=="boolean")return !t;for(let r in t)if(e[r])return true;return false}P.schemaHasRules=Xs;function Aa(t,e){if(typeof t=="boolean")return !t;for(let r in t)if(r!=="$ref"&&e.all[r])return true;return false}P.schemaHasRulesButRef=Aa;function Da({topSchemaRef:t,schemaPath:e},r,s,n){if(!n){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return (0, T._)`${r}`}return (0, T._)`${t}${e}${(0, T.getProperty)(s)}`}P.schemaRefOrVal=Da;function Va(t){return Ys(decodeURIComponent(t))}P.unescapeFragment=Va;function za(t){return encodeURIComponent(br(t))}P.escapeFragment=za;function br(t){return typeof t=="number"?`${t}`:t.replace(/~/g,"~0").replace(/\//g,"~1")}P.escapeJsonPointer=br;function Ys(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}P.unescapeJsonPointer=Ys;function Ua(t,e){if(Array.isArray(t))for(let r of t)e(r);else e(t);}P.eachItem=Ua;function Ws({mergeNames:t,mergeToName:e,mergeValues:r,resultToName:s}){return (n,o,a,i)=>{let c=a===void 0?o:a instanceof T.Name?(o instanceof T.Name?t(n,o,a):e(n,o,a),a):o instanceof T.Name?(e(n,a,o),o):r(o,a);return i===T.Name&&!(c instanceof T.Name)?s(n,c):c}}P.mergeEvaluated={props:Ws({mergeNames:(t,e,r)=>t.if((0, T._)`${r} !== true && ${e} !== undefined`,()=>{t.if((0, T._)`${e} === true`,()=>t.assign(r,true),()=>t.assign(r,(0, T._)`${r} || {}`).code((0, T._)`Object.assign(${r}, ${e})`));}),mergeToName:(t,e,r)=>t.if((0, T._)`${r} !== true`,()=>{e===true?t.assign(r,true):(t.assign(r,(0, T._)`${r} || {}`),Er(t,r,e));}),mergeValues:(t,e)=>t===true?true:{...t,...e},resultToName:Zs}),items:Ws({mergeNames:(t,e,r)=>t.if((0, T._)`${r} !== true && ${e} !== undefined`,()=>t.assign(r,(0, T._)`${e} === true ? true : ${r} > ${e} ? ${r} : ${e}`)),mergeToName:(t,e,r)=>t.if((0, T._)`${r} !== true`,()=>t.assign(r,e===true?true:(0, T._)`${r} > ${e} ? ${r} : ${e}`)),mergeValues:(t,e)=>t===true?true:Math.max(t,e),resultToName:(t,e)=>t.var("items",e)})};function Zs(t,e){if(e===true)return t.var("props",true);let r=t.var("props",(0, T._)`{}`);return e!==void 0&&Er(t,r,e),r}P.evaluatedPropsToName=Zs;function Er(t,e,r){Object.keys(r).forEach(s=>t.assign((0, T._)`${e}${(0, T.getProperty)(s)}`,true));}P.setEvaluated=Er;var Qs={};function Ka(t,e){return t.scopeValue("func",{ref:e,code:Qs[e.code]||(Qs[e.code]=new Ta._Code(e.code))})}P.useFunc=Ka;var wr;(function(t){t[t.Num=0]="Num",t[t.Str=1]="Str";})(wr||(P.Type=wr={}));function Fa(t,e,r){if(t instanceof T.Name){let s=e===wr.Num;return r?s?(0, T._)`"[" + ${t} + "]"`:(0, T._)`"['" + ${t} + "']"`:s?(0, T._)`"/" + ${t}`:(0, T._)`"/" + ${t}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0, T.getProperty)(t).toString():"/"+br(t)}P.getErrorPath=Fa;function en(t,e,r=t.opts.strictSchema){if(r){if(e=`strict mode: ${e}`,r===true)throw new Error(e);t.self.logger.warn(e);}}P.checkStrictMode=en;});var de=a(Sr=>{Object.defineProperty(Sr,"__esModule",{value:true});var U=S(),xa={data:new U.Name("data"),valCxt:new U.Name("valCxt"),instancePath:new U.Name("instancePath"),parentData:new U.Name("parentData"),parentDataProperty:new U.Name("parentDataProperty"),rootData:new U.Name("rootData"),dynamicAnchors:new U.Name("dynamicAnchors"),vErrors:new U.Name("vErrors"),errors:new U.Name("errors"),this:new U.Name("this"),self:new U.Name("self"),scope:new U.Name("scope"),json:new U.Name("json"),jsonPos:new U.Name("jsonPos"),jsonLen:new U.Name("jsonLen"),jsonPart:new U.Name("jsonPart")};Sr.default=xa;});var tt=a(K=>{Object.defineProperty(K,"__esModule",{value:true});K.extendErrors=K.resetErrorsCount=K.reportExtraError=K.reportError=K.keyword$DataError=K.keywordError=void 0;var O=S(),qt=j(),x=de();K.keywordError={message:({keyword:t})=>(0, O.str)`must pass "${t}" keyword validation`};K.keyword$DataError={message:({keyword:t,schemaType:e})=>e?(0, O.str)`"${t}" keyword must be ${e} ($data)`:(0, O.str)`"${t}" keyword is invalid ($data)`};function La(t,e=K.keywordError,r,s){let{it:n}=t,{gen:o,compositeRule:a,allErrors:i}=n,c=sn(t,e,r);s??(a||i)?tn(o,c):rn(n,(0, O._)`[${c}]`);}K.reportError=La;function Ha(t,e=K.keywordError,r){let{it:s}=t,{gen:n,compositeRule:o,allErrors:a}=s,i=sn(t,e,r);tn(n,i),o||a||rn(s,x.default.vErrors);}K.reportExtraError=Ha;function Ga(t,e){t.assign(x.default.errors,e),t.if((0, O._)`${x.default.vErrors} !== null`,()=>t.if(e,()=>t.assign((0, O._)`${x.default.vErrors}.length`,e),()=>t.assign(x.default.vErrors,null)));}K.resetErrorsCount=Ga;function Ja({gen:t,keyword:e,schemaValue:r,data:s,errsCount:n,it:o}){if(n===void 0)throw new Error("ajv implementation error");let a=t.name("err");t.forRange("i",n,x.default.errors,i=>{t.const(a,(0, O._)`${x.default.vErrors}[${i}]`),t.if((0, O._)`${a}.instancePath === undefined`,()=>t.assign((0, O._)`${a}.instancePath`,(0, O.strConcat)(x.default.instancePath,o.errorPath))),t.assign((0, O._)`${a}.schemaPath`,(0, O.str)`${o.errSchemaPath}/${e}`),o.opts.verbose&&(t.assign((0, O._)`${a}.schema`,r),t.assign((0, O._)`${a}.data`,s));});}K.extendErrors=Ja;function tn(t,e){let r=t.const("err",e);t.if((0, O._)`${x.default.vErrors} === null`,()=>t.assign(x.default.vErrors,(0, O._)`[${r}]`),(0, O._)`${x.default.vErrors}.push(${r})`),t.code((0, O._)`${x.default.errors}++`);}function rn(t,e){let{gen:r,validateName:s,schemaEnv:n}=t;n.$async?r.throw((0, O._)`new ${t.ValidationError}(${e})`):(r.assign((0, O._)`${s}.errors`,e),r.return(false));}var Pe={keyword:new O.Name("keyword"),schemaPath:new O.Name("schemaPath"),params:new O.Name("params"),propertyName:new O.Name("propertyName"),message:new O.Name("message"),schema:new O.Name("schema"),parentSchema:new O.Name("parentSchema")};function sn(t,e,r){let{createErrors:s}=t.it;return s===false?(0, O._)`{}`:Wa(t,e,r)}function Wa(t,e,r={}){let{gen:s,it:n}=t,o=[Qa(n,r),Ba(t,r)];return Xa(t,e,o),s.object(...o)}function Qa({errorPath:t},{instancePath:e}){let r=e?(0, O.str)`${t}${(0, qt.getErrorPath)(e,qt.Type.Str)}`:t;return [x.default.instancePath,(0, O.strConcat)(x.default.instancePath,r)]}function Ba({keyword:t,it:{errSchemaPath:e}},{schemaPath:r,parentSchema:s}){let n=s?e:(0, O.str)`${e}/${t}`;return r&&(n=(0, O.str)`${n}${(0, qt.getErrorPath)(r,qt.Type.Str)}`),[Pe.schemaPath,n]}function Xa(t,{params:e,message:r},s){let{keyword:n,data:o,schemaValue:a,it:i}=t,{opts:c,propertyName:l,topSchemaRef:u,schemaPath:d}=i;s.push([Pe.keyword,n],[Pe.params,typeof e=="function"?e(t):e||(0, O._)`{}`]),c.messages&&s.push([Pe.message,typeof r=="function"?r(t):r]),c.verbose&&s.push([Pe.schema,a],[Pe.parentSchema,(0, O._)`${u}${d}`],[x.default.data,o]),l&&s.push([Pe.propertyName,l]);}});var on=a(Te=>{Object.defineProperty(Te,"__esModule",{value:true});Te.boolOrEmptySchema=Te.topBoolOrEmptySchema=void 0;var Ya=tt(),Za=S(),ei=de(),ti={message:"boolean schema is false"};function ri(t){let{gen:e,schema:r,validateName:s}=t;r===false?nn(t,false):typeof r=="object"&&r.$async===true?e.return(ei.default.data):(e.assign((0, Za._)`${s}.errors`,null),e.return(true));}Te.topBoolOrEmptySchema=ri;function si(t,e){let{gen:r,schema:s}=t;s===false?(r.var(e,false),nn(t)):r.var(e,true);}Te.boolOrEmptySchema=si;function nn(t,e){let{gen:r,data:s}=t,n={gen:r,keyword:"false schema",data:s,schema:false,schemaCode:false,schemaValue:false,params:{},it:t};(0, Ya.reportError)(n,ti,void 0,e);}});var Pr=a(Ce=>{Object.defineProperty(Ce,"__esModule",{value:true});Ce.getRules=Ce.isJSONType=void 0;var ni=["string","number","integer","boolean","null","object","array"],oi=new Set(ni);function ai(t){return typeof t=="string"&&oi.has(t)}Ce.isJSONType=ai;function ii(){let t={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return {types:{...t,integer:true,boolean:true,null:true},rules:[{rules:[]},t.number,t.string,t.array,t.object],post:{rules:[]},all:{},keywords:{}}}Ce.getRules=ii;});var Nr=a(me=>{Object.defineProperty(me,"__esModule",{value:true});me.shouldUseRule=me.shouldUseGroup=me.schemaHasRulesForType=void 0;function ci({schema:t,self:e},r){let s=e.RULES.types[r];return s&&s!==true&&an(t,s)}me.schemaHasRulesForType=ci;function an(t,e){return e.rules.some(r=>cn(t,r))}me.shouldUseGroup=an;function cn(t,e){var r;return t[e.keyword]!==void 0||((r=e.definition.implements)===null||r===void 0?void 0:r.some(s=>t[s]!==void 0))}me.shouldUseRule=cn;});var rt=a(F=>{Object.defineProperty(F,"__esModule",{value:true});F.reportTypeError=F.checkDataTypes=F.checkDataType=F.coerceAndCheckDataType=F.getJSONTypes=F.getSchemaTypes=F.DataType=void 0;var ui=Pr(),li=Nr(),di=tt(),b=S(),un=j(),Me;(function(t){t[t.Correct=0]="Correct",t[t.Wrong=1]="Wrong";})(Me||(F.DataType=Me={}));function fi(t){let e=ln(t.type);if(e.includes("null")){if(t.nullable===false)throw new Error("type: null contradicts nullable: false")}else {if(!e.length&&t.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');t.nullable===true&&e.push("null");}return e}F.getSchemaTypes=fi;function ln(t){let e=Array.isArray(t)?t:t?[t]:[];if(e.every(ui.isJSONType))return e;throw new Error("type must be JSONType or JSONType[]: "+e.join(","))}F.getJSONTypes=ln;function hi(t,e){let{gen:r,data:s,opts:n}=t,o=pi(e,n.coerceTypes),a=e.length>0&&!(o.length===0&&e.length===1&&(0, li.schemaHasRulesForType)(t,e[0]));if(a){let i=qr(e,s,n.strictNumbers,Me.Wrong);r.if(i,()=>{o.length?mi(t,e,o):jr(t);});}return a}F.coerceAndCheckDataType=hi;var dn=new Set(["string","number","integer","boolean","null"]);function pi(t,e){return e?t.filter(r=>dn.has(r)||e==="array"&&r==="array"):[]}function mi(t,e,r){let{gen:s,data:n,opts:o}=t,a=s.let("dataType",(0, b._)`typeof ${n}`),i=s.let("coerced",(0, b._)`undefined`);o.coerceTypes==="array"&&s.if((0, b._)`${a} == 'object' && Array.isArray(${n}) && ${n}.length == 1`,()=>s.assign(n,(0, b._)`${n}[0]`).assign(a,(0, b._)`typeof ${n}`).if(qr(e,n,o.strictNumbers),()=>s.assign(i,n))),s.if((0, b._)`${i} !== undefined`);for(let l of r)(dn.has(l)||l==="array"&&o.coerceTypes==="array")&&c(l);s.else(),jr(t),s.endIf(),s.if((0, b._)`${i} !== undefined`,()=>{s.assign(n,i),yi(t,i);});function c(l){switch(l){case "string":s.elseIf((0, b._)`${a} == "number" || ${a} == "boolean"`).assign(i,(0, b._)`"" + ${n}`).elseIf((0, b._)`${n} === null`).assign(i,(0, b._)`""`);return;case "number":s.elseIf((0, b._)`${a} == "boolean" || ${n} === null
|
|
3
|
+
|| (${a} == "string" && ${n} && ${n} == +${n})`).assign(i,(0, b._)`+${n}`);return;case "integer":s.elseIf((0, b._)`${a} === "boolean" || ${n} === null
|
|
4
|
+
|| (${a} === "string" && ${n} && ${n} == +${n} && !(${n} % 1))`).assign(i,(0, b._)`+${n}`);return;case "boolean":s.elseIf((0, b._)`${n} === "false" || ${n} === 0 || ${n} === null`).assign(i,false).elseIf((0, b._)`${n} === "true" || ${n} === 1`).assign(i,true);return;case "null":s.elseIf((0, b._)`${n} === "" || ${n} === 0 || ${n} === false`),s.assign(i,null);return;case "array":s.elseIf((0, b._)`${a} === "string" || ${a} === "number"
|
|
5
|
+
|| ${a} === "boolean" || ${n} === null`).assign(i,(0, b._)`[${n}]`);}}}function yi({gen:t,parentData:e,parentDataProperty:r},s){t.if((0, b._)`${e} !== undefined`,()=>t.assign((0, b._)`${e}[${r}]`,s));}function kr(t,e,r,s=Me.Correct){let n=s===Me.Correct?b.operators.EQ:b.operators.NEQ,o;switch(t){case "null":return (0, b._)`${e} ${n} null`;case "array":o=(0, b._)`Array.isArray(${e})`;break;case "object":o=(0, b._)`${e} && typeof ${e} == "object" && !Array.isArray(${e})`;break;case "integer":o=a((0, b._)`!(${e} % 1) && !isNaN(${e})`);break;case "number":o=a();break;default:return (0, b._)`typeof ${e} ${n} ${t}`}return s===Me.Correct?o:(0, b.not)(o);function a(i=b.nil){return (0, b.and)((0, b._)`typeof ${e} == "number"`,i,r?(0, b._)`isFinite(${e})`:b.nil)}}F.checkDataType=kr;function qr(t,e,r,s){if(t.length===1)return kr(t[0],e,r,s);let n,o=(0, un.toHash)(t);if(o.array&&o.object){let a=(0, b._)`typeof ${e} != "object"`;n=o.null?a:(0, b._)`!${e} || ${a}`,delete o.null,delete o.array,delete o.object;}else n=b.nil;o.number&&delete o.integer;for(let a in o)n=(0, b.and)(n,kr(a,e,r,s));return n}F.checkDataTypes=qr;var _i={message:({schema:t})=>`must be ${t}`,params:({schema:t,schemaValue:e})=>typeof t=="string"?(0, b._)`{type: ${t}}`:(0, b._)`{type: ${e}}`};function jr(t){let e=gi(t);(0, di.reportError)(e,_i);}F.reportTypeError=jr;function gi(t){let{gen:e,data:r,schema:s}=t,n=(0, un.schemaRefOrVal)(t,s,"type");return {gen:e,keyword:"type",data:r,schema:s.type,schemaCode:n,schemaValue:n,parentSchema:s,params:{},it:t}}});var hn=a(jt=>{Object.defineProperty(jt,"__esModule",{value:true});jt.assignDefaults=void 0;var Ae=S(),$i=j();function vi(t,e){let{properties:r,items:s}=t.schema;if(e==="object"&&r)for(let n in r)fn(t,n,r[n].default);else e==="array"&&Array.isArray(s)&&s.forEach((n,o)=>fn(t,o,n.default));}jt.assignDefaults=vi;function fn(t,e,r){let{gen:s,compositeRule:n,data:o,opts:a}=t;if(r===void 0)return;let i=(0, Ae._)`${o}${(0, Ae.getProperty)(e)}`;if(n){(0, $i.checkStrictMode)(t,`default is ignored for: ${i}`);return}let c=(0, Ae._)`${i} === undefined`;a.useDefaults==="empty"&&(c=(0, Ae._)`${c} || ${i} === null || ${i} === ""`),s.if(c,(0, Ae._)`${i} = ${(0, Ae.stringify)(r)}`);}});var B=a(R=>{Object.defineProperty(R,"__esModule",{value:true});R.validateUnion=R.validateArray=R.usePattern=R.callValidateCode=R.schemaProperties=R.allSchemaProperties=R.noPropertyInData=R.propertyInData=R.isOwnProperty=R.hasPropFunc=R.reportMissingProp=R.checkMissingProp=R.checkReportMissingProp=void 0;var M=S(),Or=j(),ye=de(),wi=j();function bi(t,e){let{gen:r,data:s,it:n}=t;r.if(Rr(r,s,e,n.opts.ownProperties),()=>{t.setParams({missingProperty:(0, M._)`${e}`},true),t.error();});}R.checkReportMissingProp=bi;function Ei({gen:t,data:e,it:{opts:r}},s,n){return (0, M.or)(...s.map(o=>(0, M.and)(Rr(t,e,o,r.ownProperties),(0, M._)`${n} = ${o}`)))}R.checkMissingProp=Ei;function Si(t,e){t.setParams({missingProperty:e},true),t.error();}R.reportMissingProp=Si;function pn(t){return t.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0, M._)`Object.prototype.hasOwnProperty`})}R.hasPropFunc=pn;function Ir(t,e,r){return (0, M._)`${pn(t)}.call(${e}, ${r})`}R.isOwnProperty=Ir;function Pi(t,e,r,s){let n=(0, M._)`${e}${(0, M.getProperty)(r)} !== undefined`;return s?(0, M._)`${n} && ${Ir(t,e,r)}`:n}R.propertyInData=Pi;function Rr(t,e,r,s){let n=(0, M._)`${e}${(0, M.getProperty)(r)} === undefined`;return s?(0, M.or)(n,(0, M.not)(Ir(t,e,r))):n}R.noPropertyInData=Rr;function mn(t){return t?Object.keys(t).filter(e=>e!=="__proto__"):[]}R.allSchemaProperties=mn;function Ni(t,e){return mn(e).filter(r=>!(0, Or.alwaysValidSchema)(t,e[r]))}R.schemaProperties=Ni;function ki({schemaCode:t,data:e,it:{gen:r,topSchemaRef:s,schemaPath:n,errorPath:o},it:a},i,c,l){let u=l?(0, M._)`${t}, ${e}, ${s}${n}`:e,d=[[ye.default.instancePath,(0, M.strConcat)(ye.default.instancePath,o)],[ye.default.parentData,a.parentData],[ye.default.parentDataProperty,a.parentDataProperty],[ye.default.rootData,ye.default.rootData]];a.opts.dynamicRef&&d.push([ye.default.dynamicAnchors,ye.default.dynamicAnchors]);let y=(0, M._)`${u}, ${r.object(...d)}`;return c!==M.nil?(0, M._)`${i}.call(${c}, ${y})`:(0, M._)`${i}(${y})`}R.callValidateCode=ki;var qi=(0, M._)`new RegExp`;function ji({gen:t,it:{opts:e}},r){let s=e.unicodeRegExp?"u":"",{regExp:n}=e.code,o=n(r,s);return t.scopeValue("pattern",{key:o.toString(),ref:o,code:(0, M._)`${n.code==="new RegExp"?qi:(0, wi.useFunc)(t,n)}(${r}, ${s})`})}R.usePattern=ji;function Oi(t){let{gen:e,data:r,keyword:s,it:n}=t,o=e.name("valid");if(n.allErrors){let i=e.let("valid",true);return a(()=>e.assign(i,false)),i}return e.var(o,true),a(()=>e.break()),o;function a(i){let c=e.const("len",(0, M._)`${r}.length`);e.forRange("i",0,c,l=>{t.subschema({keyword:s,dataProp:l,dataPropType:Or.Type.Num},o),e.if((0, M.not)(o),i);});}}R.validateArray=Oi;function Ii(t){let{gen:e,schema:r,keyword:s,it:n}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(r.some(c=>(0, Or.alwaysValidSchema)(n,c))&&!n.opts.unevaluated)return;let a=e.let("valid",false),i=e.name("_valid");e.block(()=>r.forEach((c,l)=>{let u=t.subschema({keyword:s,schemaProp:l,compositeRule:true},i);e.assign(a,(0, M._)`${a} || ${i}`),t.mergeValidEvaluated(u,i)||e.if((0, M.not)(a));})),t.result(a,()=>t.reset(),()=>t.error(true));}R.validateUnion=Ii;});var gn=a(ne=>{Object.defineProperty(ne,"__esModule",{value:true});ne.validateKeywordUsage=ne.validSchemaType=ne.funcKeywordCode=ne.macroKeywordCode=void 0;var L=S(),Ne=de(),Ri=B(),Ti=tt();function Ci(t,e){let{gen:r,keyword:s,schema:n,parentSchema:o,it:a}=t,i=e.macro.call(a.self,n,o,a),c=_n(r,s,i);a.opts.validateSchema!==false&&a.self.validateSchema(i,true);let l=r.name("valid");t.subschema({schema:i,schemaPath:L.nil,errSchemaPath:`${a.errSchemaPath}/${s}`,topSchemaRef:c,compositeRule:true},l),t.pass(l,()=>t.error(true));}ne.macroKeywordCode=Ci;function Mi(t,e){var r;let{gen:s,keyword:n,schema:o,parentSchema:a,$data:i,it:c}=t;Di(c,e);let l=!i&&e.compile?e.compile.call(c.self,o,a,c):e.validate,u=_n(s,n,l),d=s.let("valid");t.block$data(d,y),t.ok((r=e.valid)!==null&&r!==void 0?r:d);function y(){if(e.errors===false)f(),e.modifying&&yn(t),p(()=>t.error());else {let _=e.async?m():h();e.modifying&&yn(t),p(()=>Ai(t,_));}}function m(){let _=s.let("ruleErrs",null);return s.try(()=>f((0, L._)`await `),q=>s.assign(d,false).if((0, L._)`${q} instanceof ${c.ValidationError}`,()=>s.assign(_,(0, L._)`${q}.errors`),()=>s.throw(q))),_}function h(){let _=(0, L._)`${u}.errors`;return s.assign(_,null),f(L.nil),_}function f(_=e.async?(0, L._)`await `:L.nil){let q=c.opts.passContext?Ne.default.this:Ne.default.self,N=!("compile"in e&&!i||e.schema===false);s.assign(d,(0, L._)`${_}${(0, Ri.callValidateCode)(t,u,q,N)}`,e.modifying);}function p(_){var q;s.if((0, L.not)((q=e.valid)!==null&&q!==void 0?q:d),_);}}ne.funcKeywordCode=Mi;function yn(t){let{gen:e,data:r,it:s}=t;e.if(s.parentData,()=>e.assign(r,(0, L._)`${s.parentData}[${s.parentDataProperty}]`));}function Ai(t,e){let{gen:r}=t;r.if((0, L._)`Array.isArray(${e})`,()=>{r.assign(Ne.default.vErrors,(0, L._)`${Ne.default.vErrors} === null ? ${e} : ${Ne.default.vErrors}.concat(${e})`).assign(Ne.default.errors,(0, L._)`${Ne.default.vErrors}.length`),(0, Ti.extendErrors)(t);},()=>t.error());}function Di({schemaEnv:t},e){if(e.async&&!t.$async)throw new Error("async keyword in sync schema")}function _n(t,e,r){if(r===void 0)throw new Error(`keyword "${e}" failed to compile`);return t.scopeValue("keyword",typeof r=="function"?{ref:r}:{ref:r,code:(0, L.stringify)(r)})}function Vi(t,e,r=false){return !e.length||e.some(s=>s==="array"?Array.isArray(t):s==="object"?t&&typeof t=="object"&&!Array.isArray(t):typeof t==s||r&&typeof t>"u")}ne.validSchemaType=Vi;function zi({schema:t,opts:e,self:r,errSchemaPath:s},n,o){if(Array.isArray(n.keyword)?!n.keyword.includes(o):n.keyword!==o)throw new Error("ajv implementation error");let a=n.dependencies;if(a?.some(i=>!Object.prototype.hasOwnProperty.call(t,i)))throw new Error(`parent schema must have dependencies of ${o}: ${a.join(",")}`);if(n.validateSchema&&!n.validateSchema(t[o])){let c=`keyword "${o}" value is invalid at path "${s}": `+r.errorsText(n.validateSchema.errors);if(e.validateSchema==="log")r.logger.error(c);else throw new Error(c)}}ne.validateKeywordUsage=zi;});var vn=a(_e=>{Object.defineProperty(_e,"__esModule",{value:true});_e.extendSubschemaMode=_e.extendSubschemaData=_e.getSubschema=void 0;var oe=S(),$n=j();function Ui(t,{keyword:e,schemaProp:r,schema:s,schemaPath:n,errSchemaPath:o,topSchemaRef:a}){if(e!==void 0&&s!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(e!==void 0){let i=t.schema[e];return r===void 0?{schema:i,schemaPath:(0, oe._)`${t.schemaPath}${(0, oe.getProperty)(e)}`,errSchemaPath:`${t.errSchemaPath}/${e}`}:{schema:i[r],schemaPath:(0, oe._)`${t.schemaPath}${(0, oe.getProperty)(e)}${(0, oe.getProperty)(r)}`,errSchemaPath:`${t.errSchemaPath}/${e}/${(0, $n.escapeFragment)(r)}`}}if(s!==void 0){if(n===void 0||o===void 0||a===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return {schema:s,schemaPath:n,topSchemaRef:a,errSchemaPath:o}}throw new Error('either "keyword" or "schema" must be passed')}_e.getSubschema=Ui;function Ki(t,e,{dataProp:r,dataPropType:s,data:n,dataTypes:o,propertyName:a}){if(n!==void 0&&r!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');let{gen:i}=e;if(r!==void 0){let{errorPath:l,dataPathArr:u,opts:d}=e,y=i.let("data",(0, oe._)`${e.data}${(0, oe.getProperty)(r)}`,true);c(y),t.errorPath=(0, oe.str)`${l}${(0, $n.getErrorPath)(r,s,d.jsPropertySyntax)}`,t.parentDataProperty=(0, oe._)`${r}`,t.dataPathArr=[...u,t.parentDataProperty];}if(n!==void 0){let l=n instanceof oe.Name?n:i.let("data",n,true);c(l),a!==void 0&&(t.propertyName=a);}o&&(t.dataTypes=o);function c(l){t.data=l,t.dataLevel=e.dataLevel+1,t.dataTypes=[],e.definedProperties=new Set,t.parentData=e.data,t.dataNames=[...e.dataNames,l];}}_e.extendSubschemaData=Ki;function Fi(t,{jtdDiscriminator:e,jtdMetadata:r,compositeRule:s,createErrors:n,allErrors:o}){s!==void 0&&(t.compositeRule=s),n!==void 0&&(t.createErrors=n),o!==void 0&&(t.allErrors=o),t.jtdDiscriminator=e,t.jtdMetadata=r;}_e.extendSubschemaMode=Fi;});var Tr=a((af,wn)=>{wn.exports=function t(e,r){if(e===r)return true;if(e&&r&&typeof e=="object"&&typeof r=="object"){if(e.constructor!==r.constructor)return false;var s,n,o;if(Array.isArray(e)){if(s=e.length,s!=r.length)return false;for(n=s;n--!==0;)if(!t(e[n],r[n]))return false;return true}if(e.constructor===RegExp)return e.source===r.source&&e.flags===r.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===r.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===r.toString();if(o=Object.keys(e),s=o.length,s!==Object.keys(r).length)return false;for(n=s;n--!==0;)if(!Object.prototype.hasOwnProperty.call(r,o[n]))return false;for(n=s;n--!==0;){var a=o[n];if(!t(e[a],r[a]))return false}return true}return e!==e&&r!==r};});var En=a((cf,bn)=>{var ge=bn.exports=function(t,e,r){typeof e=="function"&&(r=e,e={}),r=e.cb||r;var s=typeof r=="function"?r:r.pre||function(){},n=r.post||function(){};Ot(e,s,n,t,"",t);};ge.keywords={additionalItems:true,items:true,contains:true,additionalProperties:true,propertyNames:true,not:true,if:true,then:true,else:true};ge.arrayKeywords={items:true,allOf:true,anyOf:true,oneOf:true};ge.propsKeywords={$defs:true,definitions:true,properties:true,patternProperties:true,dependencies:true};ge.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 Ot(t,e,r,s,n,o,a,i,c,l){if(s&&typeof s=="object"&&!Array.isArray(s)){e(s,n,o,a,i,c,l);for(var u in s){var d=s[u];if(Array.isArray(d)){if(u in ge.arrayKeywords)for(var y=0;y<d.length;y++)Ot(t,e,r,d[y],n+"/"+u+"/"+y,o,n,u,s,y);}else if(u in ge.propsKeywords){if(d&&typeof d=="object")for(var m in d)Ot(t,e,r,d[m],n+"/"+u+"/"+xi(m),o,n,u,s,m);}else (u in ge.keywords||t.allKeys&&!(u in ge.skipKeywords))&&Ot(t,e,r,d,n+"/"+u,o,n,u,s);}r(s,n,o,a,i,c,l);}}function xi(t){return t.replace(/~/g,"~0").replace(/\//g,"~1")}});var st=a(J=>{Object.defineProperty(J,"__esModule",{value:true});J.getSchemaRefs=J.resolveUrl=J.normalizeId=J._getFullPath=J.getFullPath=J.inlineRef=void 0;var Li=j(),Hi=Tr(),Gi=En(),Ji=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function Wi(t,e=true){return typeof t=="boolean"?true:e===true?!Cr(t):e?Sn(t)<=e:false}J.inlineRef=Wi;var Qi=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function Cr(t){for(let e in t){if(Qi.has(e))return true;let r=t[e];if(Array.isArray(r)&&r.some(Cr)||typeof r=="object"&&Cr(r))return true}return false}function Sn(t){let e=0;for(let r in t){if(r==="$ref")return 1/0;if(e++,!Ji.has(r)&&(typeof t[r]=="object"&&(0, Li.eachItem)(t[r],s=>e+=Sn(s)),e===1/0))return 1/0}return e}function Pn(t,e="",r){r!==false&&(e=De(e));let s=t.parse(e);return Nn(t,s)}J.getFullPath=Pn;function Nn(t,e){return t.serialize(e).split("#")[0]+"#"}J._getFullPath=Nn;var Bi=/#\/?$/;function De(t){return t?t.replace(Bi,""):""}J.normalizeId=De;function Xi(t,e,r){return r=De(r),t.resolve(e,r)}J.resolveUrl=Xi;var Yi=/^[a-z_][-a-z0-9._]*$/i;function Zi(t,e){if(typeof t=="boolean")return {};let{schemaId:r,uriResolver:s}=this.opts,n=De(t[r]||e),o={"":n},a=Pn(s,n,false),i={},c=new Set;return Gi(t,{allKeys:true},(d,y,m,h)=>{if(h===void 0)return;let f=a+y,p=o[h];typeof d[r]=="string"&&(p=_.call(this,d[r])),q.call(this,d.$anchor),q.call(this,d.$dynamicAnchor),o[y]=p;function _(N){let C=this.opts.uriResolver.resolve;if(N=De(p?C(p,N):N),c.has(N))throw u(N);c.add(N);let w=this.refs[N];return typeof w=="string"&&(w=this.refs[w]),typeof w=="object"?l(d,w.schema,N):N!==De(f)&&(N[0]==="#"?(l(d,i[N],N),i[N]=d):this.refs[N]=f),N}function q(N){if(typeof N=="string"){if(!Yi.test(N))throw new Error(`invalid anchor "${N}"`);_.call(this,`#${N}`);}}}),i;function l(d,y,m){if(y!==void 0&&!Hi(d,y))throw u(m)}function u(d){return new Error(`reference "${d}" resolves to more than one schema`)}}J.getSchemaRefs=Zi;});var at=a($e=>{Object.defineProperty($e,"__esModule",{value:true});$e.getData=$e.KeywordCxt=$e.validateFunctionCode=void 0;var In=on(),kn=rt(),Ar=Nr(),It=rt(),ec=hn(),ot=gn(),Mr=vn(),$=S(),v=de(),tc=st(),fe=j(),nt=tt();function rc(t){if(Cn(t)&&(Mn(t),Tn(t))){oc(t);return}Rn(t,()=>(0, In.topBoolOrEmptySchema)(t));}$e.validateFunctionCode=rc;function Rn({gen:t,validateName:e,schema:r,schemaEnv:s,opts:n},o){n.code.es5?t.func(e,(0, $._)`${v.default.data}, ${v.default.valCxt}`,s.$async,()=>{t.code((0, $._)`"use strict"; ${qn(r,n)}`),nc(t,n),t.code(o);}):t.func(e,(0, $._)`${v.default.data}, ${sc(n)}`,s.$async,()=>t.code(qn(r,n)).code(o));}function sc(t){return (0, $._)`{${v.default.instancePath}="", ${v.default.parentData}, ${v.default.parentDataProperty}, ${v.default.rootData}=${v.default.data}${t.dynamicRef?(0, $._)`, ${v.default.dynamicAnchors}={}`:$.nil}}={}`}function nc(t,e){t.if(v.default.valCxt,()=>{t.var(v.default.instancePath,(0, $._)`${v.default.valCxt}.${v.default.instancePath}`),t.var(v.default.parentData,(0, $._)`${v.default.valCxt}.${v.default.parentData}`),t.var(v.default.parentDataProperty,(0, $._)`${v.default.valCxt}.${v.default.parentDataProperty}`),t.var(v.default.rootData,(0, $._)`${v.default.valCxt}.${v.default.rootData}`),e.dynamicRef&&t.var(v.default.dynamicAnchors,(0, $._)`${v.default.valCxt}.${v.default.dynamicAnchors}`);},()=>{t.var(v.default.instancePath,(0, $._)`""`),t.var(v.default.parentData,(0, $._)`undefined`),t.var(v.default.parentDataProperty,(0, $._)`undefined`),t.var(v.default.rootData,v.default.data),e.dynamicRef&&t.var(v.default.dynamicAnchors,(0, $._)`{}`);});}function oc(t){let{schema:e,opts:r,gen:s}=t;Rn(t,()=>{r.$comment&&e.$comment&&Dn(t),lc(t),s.let(v.default.vErrors,null),s.let(v.default.errors,0),r.unevaluated&&ac(t),An(t),hc(t);});}function ac(t){let{gen:e,validateName:r}=t;t.evaluated=e.const("evaluated",(0, $._)`${r}.evaluated`),e.if((0, $._)`${t.evaluated}.dynamicProps`,()=>e.assign((0, $._)`${t.evaluated}.props`,(0, $._)`undefined`)),e.if((0, $._)`${t.evaluated}.dynamicItems`,()=>e.assign((0, $._)`${t.evaluated}.items`,(0, $._)`undefined`));}function qn(t,e){let r=typeof t=="object"&&t[e.schemaId];return r&&(e.code.source||e.code.process)?(0, $._)`/*# sourceURL=${r} */`:$.nil}function ic(t,e){if(Cn(t)&&(Mn(t),Tn(t))){cc(t,e);return}(0, In.boolOrEmptySchema)(t,e);}function Tn({schema:t,self:e}){if(typeof t=="boolean")return !t;for(let r in t)if(e.RULES.all[r])return true;return false}function Cn(t){return typeof t.schema!="boolean"}function cc(t,e){let{schema:r,gen:s,opts:n}=t;n.$comment&&r.$comment&&Dn(t),dc(t),fc(t);let o=s.const("_errs",v.default.errors);An(t,o),s.var(e,(0, $._)`${o} === ${v.default.errors}`);}function Mn(t){(0, fe.checkUnknownRules)(t),uc(t);}function An(t,e){if(t.opts.jtd)return jn(t,[],false,e);let r=(0, kn.getSchemaTypes)(t.schema),s=(0, kn.coerceAndCheckDataType)(t,r);jn(t,r,!s,e);}function uc(t){let{schema:e,errSchemaPath:r,opts:s,self:n}=t;e.$ref&&s.ignoreKeywordsWithRef&&(0, fe.schemaHasRulesButRef)(e,n.RULES)&&n.logger.warn(`$ref: keywords ignored in schema at path "${r}"`);}function lc(t){let{schema:e,opts:r}=t;e.default!==void 0&&r.useDefaults&&r.strictSchema&&(0, fe.checkStrictMode)(t,"default is ignored in the schema root");}function dc(t){let e=t.schema[t.opts.schemaId];e&&(t.baseId=(0, tc.resolveUrl)(t.opts.uriResolver,t.baseId,e));}function fc(t){if(t.schema.$async&&!t.schemaEnv.$async)throw new Error("async schema in sync schema")}function Dn({gen:t,schemaEnv:e,schema:r,errSchemaPath:s,opts:n}){let o=r.$comment;if(n.$comment===true)t.code((0, $._)`${v.default.self}.logger.log(${o})`);else if(typeof n.$comment=="function"){let a=(0, $.str)`${s}/$comment`,i=t.scopeValue("root",{ref:e.root});t.code((0, $._)`${v.default.self}.opts.$comment(${o}, ${a}, ${i}.schema)`);}}function hc(t){let{gen:e,schemaEnv:r,validateName:s,ValidationError:n,opts:o}=t;r.$async?e.if((0, $._)`${v.default.errors} === 0`,()=>e.return(v.default.data),()=>e.throw((0, $._)`new ${n}(${v.default.vErrors})`)):(e.assign((0, $._)`${s}.errors`,v.default.vErrors),o.unevaluated&&pc(t),e.return((0, $._)`${v.default.errors} === 0`));}function pc({gen:t,evaluated:e,props:r,items:s}){r instanceof $.Name&&t.assign((0, $._)`${e}.props`,r),s instanceof $.Name&&t.assign((0, $._)`${e}.items`,s);}function jn(t,e,r,s){let{gen:n,schema:o,data:a,allErrors:i,opts:c,self:l}=t,{RULES:u}=l;if(o.$ref&&(c.ignoreKeywordsWithRef||!(0, fe.schemaHasRulesButRef)(o,u))){n.block(()=>zn(t,"$ref",u.all.$ref.definition));return}c.jtd||mc(t,e),n.block(()=>{for(let y of u.rules)d(y);d(u.post);});function d(y){(0, Ar.shouldUseGroup)(o,y)&&(y.type?(n.if((0, It.checkDataType)(y.type,a,c.strictNumbers)),On(t,y),e.length===1&&e[0]===y.type&&r&&(n.else(),(0, It.reportTypeError)(t)),n.endIf()):On(t,y),i||n.if((0, $._)`${v.default.errors} === ${s||0}`));}}function On(t,e){let{gen:r,schema:s,opts:{useDefaults:n}}=t;n&&(0, ec.assignDefaults)(t,e.type),r.block(()=>{for(let o of e.rules)(0, Ar.shouldUseRule)(s,o)&&zn(t,o.keyword,o.definition,e.type);});}function mc(t,e){t.schemaEnv.meta||!t.opts.strictTypes||(yc(t,e),t.opts.allowUnionTypes||_c(t,e),gc(t,t.dataTypes));}function yc(t,e){if(e.length){if(!t.dataTypes.length){t.dataTypes=e;return}e.forEach(r=>{Vn(t.dataTypes,r)||Dr(t,`type "${r}" not allowed by context "${t.dataTypes.join(",")}"`);}),vc(t,e);}}function _c(t,e){e.length>1&&!(e.length===2&&e.includes("null"))&&Dr(t,"use allowUnionTypes to allow union type keyword");}function gc(t,e){let r=t.self.RULES.all;for(let s in r){let n=r[s];if(typeof n=="object"&&(0, Ar.shouldUseRule)(t.schema,n)){let{type:o}=n.definition;o.length&&!o.some(a=>$c(e,a))&&Dr(t,`missing type "${o.join(",")}" for keyword "${s}"`);}}}function $c(t,e){return t.includes(e)||e==="number"&&t.includes("integer")}function Vn(t,e){return t.includes(e)||e==="integer"&&t.includes("number")}function vc(t,e){let r=[];for(let s of t.dataTypes)Vn(e,s)?r.push(s):e.includes("integer")&&s==="number"&&r.push("integer");t.dataTypes=r;}function Dr(t,e){let r=t.schemaEnv.baseId+t.errSchemaPath;e+=` at "${r}" (strictTypes)`,(0, fe.checkStrictMode)(t,e,t.opts.strictTypes);}var Rt=class{constructor(e,r,s){if((0, ot.validateKeywordUsage)(e,r,s),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=s,this.data=e.data,this.schema=e.schema[s],this.$data=r.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0, fe.schemaRefOrVal)(e,this.schema,s,this.$data),this.schemaType=r.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=r,this.$data)this.schemaCode=e.gen.const("vSchema",Un(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0, ot.validSchemaType)(this.schema,r.schemaType,r.allowUndefined))throw new Error(`${s} value must be ${JSON.stringify(r.schemaType)}`);("code"in r?r.trackErrors:r.errors!==false)&&(this.errsCount=e.gen.const("_errs",v.default.errors));}result(e,r,s){this.failResult((0, $.not)(e),r,s);}failResult(e,r,s){this.gen.if(e),s?s():this.error(),r?(this.gen.else(),r(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else();}pass(e,r){this.failResult((0, $.not)(e),void 0,r);}fail(e){if(e===void 0){this.error(),this.allErrors||this.gen.if(false);return}this.gen.if(e),this.error(),this.allErrors?this.gen.endIf():this.gen.else();}fail$data(e){if(!this.$data)return this.fail(e);let{schemaCode:r}=this;this.fail((0, $._)`${r} !== undefined && (${(0, $.or)(this.invalid$data(),e)})`);}error(e,r,s){if(r){this.setParams(r),this._error(e,s),this.setParams({});return}this._error(e,s);}_error(e,r){(e?nt.reportExtraError:nt.reportError)(this,this.def.error,r);}$dataError(){(0, nt.reportError)(this,this.def.$dataError||nt.keyword$DataError);}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0, nt.resetErrorsCount)(this.gen,this.errsCount);}ok(e){this.allErrors||this.gen.if(e);}setParams(e,r){r?Object.assign(this.params,e):this.params=e;}block$data(e,r,s=$.nil){this.gen.block(()=>{this.check$data(e,s),r();});}check$data(e=$.nil,r=$.nil){if(!this.$data)return;let{gen:s,schemaCode:n,schemaType:o,def:a}=this;s.if((0, $.or)((0, $._)`${n} === undefined`,r)),e!==$.nil&&s.assign(e,true),(o.length||a.validateSchema)&&(s.elseIf(this.invalid$data()),this.$dataError(),e!==$.nil&&s.assign(e,false)),s.else();}invalid$data(){let{gen:e,schemaCode:r,schemaType:s,def:n,it:o}=this;return (0, $.or)(a(),i());function a(){if(s.length){if(!(r instanceof $.Name))throw new Error("ajv implementation error");let c=Array.isArray(s)?s:[s];return (0, $._)`${(0, It.checkDataTypes)(c,r,o.opts.strictNumbers,It.DataType.Wrong)}`}return $.nil}function i(){if(n.validateSchema){let c=e.scopeValue("validate$data",{ref:n.validateSchema});return (0, $._)`!${c}(${r})`}return $.nil}}subschema(e,r){let s=(0, Mr.getSubschema)(this.it,e);(0, Mr.extendSubschemaData)(s,this.it,e),(0, Mr.extendSubschemaMode)(s,e);let n={...this.it,...s,items:void 0,props:void 0};return ic(n,r),n}mergeEvaluated(e,r){let{it:s,gen:n}=this;s.opts.unevaluated&&(s.props!==true&&e.props!==void 0&&(s.props=fe.mergeEvaluated.props(n,e.props,s.props,r)),s.items!==true&&e.items!==void 0&&(s.items=fe.mergeEvaluated.items(n,e.items,s.items,r)));}mergeValidEvaluated(e,r){let{it:s,gen:n}=this;if(s.opts.unevaluated&&(s.props!==true||s.items!==true))return n.if(r,()=>this.mergeEvaluated(e,$.Name)),true}};$e.KeywordCxt=Rt;function zn(t,e,r,s){let n=new Rt(t,r,e);"code"in r?r.code(n,s):n.$data&&r.validate?(0, ot.funcKeywordCode)(n,r):"macro"in r?(0, ot.macroKeywordCode)(n,r):(r.compile||r.validate)&&(0, ot.funcKeywordCode)(n,r);}var wc=/^\/(?:[^~]|~0|~1)*$/,bc=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function Un(t,{dataLevel:e,dataNames:r,dataPathArr:s}){let n,o;if(t==="")return v.default.rootData;if(t[0]==="/"){if(!wc.test(t))throw new Error(`Invalid JSON-pointer: ${t}`);n=t,o=v.default.rootData;}else {let l=bc.exec(t);if(!l)throw new Error(`Invalid JSON-pointer: ${t}`);let u=+l[1];if(n=l[2],n==="#"){if(u>=e)throw new Error(c("property/index",u));return s[e-u]}if(u>e)throw new Error(c("data",u));if(o=r[e-u],!n)return o}let a=o,i=n.split("/");for(let l of i)l&&(o=(0, $._)`${o}${(0, $.getProperty)((0, fe.unescapeJsonPointer)(l))}`,a=(0, $._)`${a} && ${o}`);return a;function c(l,u){return `Cannot access ${l} ${u} levels up, current level is ${e}`}}$e.getData=Un;});var Tt=a(zr=>{Object.defineProperty(zr,"__esModule",{value:true});var Vr=class extends Error{constructor(e){super("validation failed"),this.errors=e,this.ajv=this.validation=true;}};zr.default=Vr;});var it=a(Fr=>{Object.defineProperty(Fr,"__esModule",{value:true});var Ur=st(),Kr=class extends Error{constructor(e,r,s,n){super(n||`can't resolve reference ${s} from id ${r}`),this.missingRef=(0, Ur.resolveUrl)(e,r,s),this.missingSchema=(0, Ur.normalizeId)((0, Ur.getFullPath)(e,this.missingRef));}};Fr.default=Kr;});var Mt=a(X=>{Object.defineProperty(X,"__esModule",{value:true});X.resolveSchema=X.getCompilingSchema=X.resolveRef=X.compileSchema=X.SchemaEnv=void 0;var ee=S(),Ec=Tt(),ke=de(),te=st(),Kn=j(),Sc=at(),Ve=class{constructor(e){var r;this.refs={},this.dynamicAnchors={};let s;typeof e.schema=="object"&&(s=e.schema),this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=(r=e.baseId)!==null&&r!==void 0?r:(0, te.normalizeId)(s?.[e.schemaId||"$id"]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=s?.$async,this.refs={};}};X.SchemaEnv=Ve;function Lr(t){let e=Fn.call(this,t);if(e)return e;let r=(0, te.getFullPath)(this.opts.uriResolver,t.root.baseId),{es5:s,lines:n}=this.opts.code,{ownProperties:o}=this.opts,a=new ee.CodeGen(this.scope,{es5:s,lines:n,ownProperties:o}),i;t.$async&&(i=a.scopeValue("Error",{ref:Ec.default,code:(0, ee._)`require("ajv/dist/runtime/validation_error").default`}));let c=a.scopeName("validate");t.validateName=c;let l={gen:a,allErrors:this.opts.allErrors,data:ke.default.data,parentData:ke.default.parentData,parentDataProperty:ke.default.parentDataProperty,dataNames:[ke.default.data],dataPathArr:[ee.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:a.scopeValue("schema",this.opts.code.source===true?{ref:t.schema,code:(0, ee.stringify)(t.schema)}:{ref:t.schema}),validateName:c,ValidationError:i,schema:t.schema,schemaEnv:t,rootId:r,baseId:t.baseId||r,schemaPath:ee.nil,errSchemaPath:t.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0, ee._)`""`,opts:this.opts,self:this},u;try{this._compilations.add(t),(0,Sc.validateFunctionCode)(l),a.optimize(this.opts.code.optimize);let d=a.toString();u=`${a.scopeRefs(ke.default.scope)}return ${d}`,this.opts.code.process&&(u=this.opts.code.process(u,t));let m=new Function(`${ke.default.self}`,`${ke.default.scope}`,u)(this,this.scope.get());if(this.scope.value(c,{ref:m}),m.errors=null,m.schema=t.schema,m.schemaEnv=t,t.$async&&(m.$async=!0),this.opts.code.source===!0&&(m.source={validateName:c,validateCode:d,scopeValues:a._values}),this.opts.unevaluated){let{props:h,items:f}=l;m.evaluated={props:h instanceof ee.Name?void 0:h,items:f instanceof ee.Name?void 0:f,dynamicProps:h instanceof ee.Name,dynamicItems:f instanceof ee.Name},m.source&&(m.source.evaluated=(0,ee.stringify)(m.evaluated));}return t.validate=m,t}catch(d){throw delete t.validate,delete t.validateName,u&&this.logger.error("Error compiling schema, function code:",u),d}finally{this._compilations.delete(t);}}X.compileSchema=Lr;function Pc(t,e,r){var s;r=(0, te.resolveUrl)(this.opts.uriResolver,e,r);let n=t.refs[r];if(n)return n;let o=qc.call(this,t,r);if(o===void 0){let a=(s=t.localRefs)===null||s===void 0?void 0:s[r],{schemaId:i}=this.opts;a&&(o=new Ve({schema:a,schemaId:i,root:t,baseId:e}));}if(o!==void 0)return t.refs[r]=Nc.call(this,o)}X.resolveRef=Pc;function Nc(t){return (0, te.inlineRef)(t.schema,this.opts.inlineRefs)?t.schema:t.validate?t:Lr.call(this,t)}function Fn(t){for(let e of this._compilations)if(kc(e,t))return e}X.getCompilingSchema=Fn;function kc(t,e){return t.schema===e.schema&&t.root===e.root&&t.baseId===e.baseId}function qc(t,e){let r;for(;typeof(r=this.refs[e])=="string";)e=r;return r||this.schemas[e]||Ct.call(this,t,e)}function Ct(t,e){let r=this.opts.uriResolver.parse(e),s=(0, te._getFullPath)(this.opts.uriResolver,r),n=(0, te.getFullPath)(this.opts.uriResolver,t.baseId,void 0);if(Object.keys(t.schema).length>0&&s===n)return xr.call(this,r,t);let o=(0, te.normalizeId)(s),a=this.refs[o]||this.schemas[o];if(typeof a=="string"){let i=Ct.call(this,t,a);return typeof i?.schema!="object"?void 0:xr.call(this,r,i)}if(typeof a?.schema=="object"){if(a.validate||Lr.call(this,a),o===(0, te.normalizeId)(e)){let{schema:i}=a,{schemaId:c}=this.opts,l=i[c];return l&&(n=(0, te.resolveUrl)(this.opts.uriResolver,n,l)),new Ve({schema:i,schemaId:c,root:t,baseId:n})}return xr.call(this,r,a)}}X.resolveSchema=Ct;var jc=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function xr(t,{baseId:e,schema:r,root:s}){var n;if(((n=t.fragment)===null||n===void 0?void 0:n[0])!=="/")return;for(let i of t.fragment.slice(1).split("/")){if(typeof r=="boolean")return;let c=r[(0, Kn.unescapeFragment)(i)];if(c===void 0)return;r=c;let l=typeof r=="object"&&r[this.opts.schemaId];!jc.has(i)&&l&&(e=(0, te.resolveUrl)(this.opts.uriResolver,e,l));}let o;if(typeof r!="boolean"&&r.$ref&&!(0, Kn.schemaHasRulesButRef)(r,this.RULES)){let i=(0, te.resolveUrl)(this.opts.uriResolver,e,r.$ref);o=Ct.call(this,s,i);}let{schemaId:a}=this.opts;if(o=o||new Ve({schema:r,schemaId:a,root:s,baseId:e}),o.schema!==o.root.schema)return o}});var xn=a((pf,Oc)=>{Oc.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 Gr=a((mf,Jn)=>{var Ic=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),Hn=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 Hr(t){let e="",r=0,s=0;for(s=0;s<t.length;s++)if(r=t[s].charCodeAt(0),r!==48){if(!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return "";e+=t[s];break}for(s+=1;s<t.length;s++){if(r=t[s].charCodeAt(0),!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return "";e+=t[s];}return e}var Rc=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function Ln(t){return t.length=0,true}function Tc(t,e,r){if(t.length){let s=Hr(t);if(s!=="")e.push(s);else return r.error=true,false;t.length=0;}return true}function Cc(t){let e=0,r={error:false,address:"",zone:""},s=[],n=[],o=false,a=false,i=Tc;for(let c=0;c<t.length;c++){let l=t[c];if(!(l==="["||l==="]"))if(l===":"){if(o===true&&(a=true),!i(n,s,r))break;if(++e>7){r.error=true;break}c>0&&t[c-1]===":"&&(o=true),s.push(":");continue}else if(l==="%"){if(!i(n,s,r))break;i=Ln;}else {n.push(l);continue}}return n.length&&(i===Ln?r.zone=n.join(""):a?s.push(n.join("")):s.push(Hr(n))),r.address=s.join(""),r}function Gn(t){if(Mc(t,":")<2)return {host:t,isIPV6:false};let e=Cc(t);if(e.error)return {host:t,isIPV6:false};{let r=e.address,s=e.address;return e.zone&&(r+="%"+e.zone,s+="%25"+e.zone),{host:r,isIPV6:true,escapedHost:s}}}function Mc(t,e){let r=0;for(let s=0;s<t.length;s++)t[s]===e&&r++;return r}function Ac(t){let e=t,r=[],s=-1,n=0;for(;n=e.length;){if(n===1){if(e===".")break;if(e==="/"){r.push("/");break}else {r.push(e);break}}else if(n===2){if(e[0]==="."){if(e[1]===".")break;if(e[1]==="/"){e=e.slice(2);continue}}else if(e[0]==="/"&&(e[1]==="."||e[1]==="/")){r.push("/");break}}else if(n===3&&e==="/.."){r.length!==0&&r.pop(),r.push("/");break}if(e[0]==="."){if(e[1]==="."){if(e[2]==="/"){e=e.slice(3);continue}}else if(e[1]==="/"){e=e.slice(2);continue}}else if(e[0]==="/"&&e[1]==="."){if(e[2]==="/"){e=e.slice(2);continue}else if(e[2]==="."&&e[3]==="/"){e=e.slice(3),r.length!==0&&r.pop();continue}}if((s=e.indexOf("/",1))===-1){r.push(e);break}else r.push(e.slice(0,s)),e=e.slice(s);}return r.join("")}function Dc(t,e){let r=e!==true?escape:unescape;return t.scheme!==void 0&&(t.scheme=r(t.scheme)),t.userinfo!==void 0&&(t.userinfo=r(t.userinfo)),t.host!==void 0&&(t.host=r(t.host)),t.path!==void 0&&(t.path=r(t.path)),t.query!==void 0&&(t.query=r(t.query)),t.fragment!==void 0&&(t.fragment=r(t.fragment)),t}function Vc(t){let e=[];if(t.userinfo!==void 0&&(e.push(t.userinfo),e.push("@")),t.host!==void 0){let r=unescape(t.host);if(!Hn(r)){let s=Gn(r);s.isIPV6===true?r=`[${s.escapedHost}]`:r=t.host;}e.push(r);}return (typeof t.port=="number"||typeof t.port=="string")&&(e.push(":"),e.push(String(t.port))),e.length?e.join(""):void 0}Jn.exports={nonSimpleDomain:Rc,recomposeAuthority:Vc,normalizeComponentEncoding:Dc,removeDotSegments:Ac,isIPv4:Hn,isUUID:Ic,normalizeIPv6:Gn,stringArrayToHexStripped:Hr};});var Yn=a((yf,Xn)=>{var{isUUID:zc}=Gr(),Uc=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,Kc=["http","https","ws","wss","urn","urn:uuid"];function Fc(t){return Kc.indexOf(t)!==-1}function Jr(t){return t.secure===true?true:t.secure===false?false:t.scheme?t.scheme.length===3&&(t.scheme[0]==="w"||t.scheme[0]==="W")&&(t.scheme[1]==="s"||t.scheme[1]==="S")&&(t.scheme[2]==="s"||t.scheme[2]==="S"):false}function Wn(t){return t.host||(t.error=t.error||"HTTP URIs must have a host."),t}function Qn(t){let e=String(t.scheme).toLowerCase()==="https";return (t.port===(e?443:80)||t.port==="")&&(t.port=void 0),t.path||(t.path="/"),t}function xc(t){return t.secure=Jr(t),t.resourceName=(t.path||"/")+(t.query?"?"+t.query:""),t.path=void 0,t.query=void 0,t}function Lc(t){if((t.port===(Jr(t)?443:80)||t.port==="")&&(t.port=void 0),typeof t.secure=="boolean"&&(t.scheme=t.secure?"wss":"ws",t.secure=void 0),t.resourceName){let[e,r]=t.resourceName.split("?");t.path=e&&e!=="/"?e:void 0,t.query=r,t.resourceName=void 0;}return t.fragment=void 0,t}function Hc(t,e){if(!t.path)return t.error="URN can not be parsed",t;let r=t.path.match(Uc);if(r){let s=e.scheme||t.scheme||"urn";t.nid=r[1].toLowerCase(),t.nss=r[2];let n=`${s}:${e.nid||t.nid}`,o=Wr(n);t.path=void 0,o&&(t=o.parse(t,e));}else t.error=t.error||"URN can not be parsed.";return t}function Gc(t,e){if(t.nid===void 0)throw new Error("URN without nid cannot be serialized");let r=e.scheme||t.scheme||"urn",s=t.nid.toLowerCase(),n=`${r}:${e.nid||s}`,o=Wr(n);o&&(t=o.serialize(t,e));let a=t,i=t.nss;return a.path=`${s||e.nid}:${i}`,e.skipEscape=true,a}function Jc(t,e){let r=t;return r.uuid=r.nss,r.nss=void 0,!e.tolerant&&(!r.uuid||!zc(r.uuid))&&(r.error=r.error||"UUID is not valid."),r}function Wc(t){let e=t;return e.nss=(t.uuid||"").toLowerCase(),e}var Bn={scheme:"http",domainHost:true,parse:Wn,serialize:Qn},Qc={scheme:"https",domainHost:Bn.domainHost,parse:Wn,serialize:Qn},At={scheme:"ws",domainHost:true,parse:xc,serialize:Lc},Bc={scheme:"wss",domainHost:At.domainHost,parse:At.parse,serialize:At.serialize},Xc={scheme:"urn",parse:Hc,serialize:Gc,skipNormalize:true},Yc={scheme:"urn:uuid",parse:Jc,serialize:Wc,skipNormalize:true},Dt={http:Bn,https:Qc,ws:At,wss:Bc,urn:Xc,"urn:uuid":Yc};Object.setPrototypeOf(Dt,null);function Wr(t){return t&&(Dt[t]||Dt[t.toLowerCase()])||void 0}Xn.exports={wsIsSecure:Jr,SCHEMES:Dt,isValidSchemeName:Fc,getSchemeHandler:Wr};});var to=a((_f,zt)=>{var{normalizeIPv6:Zc,removeDotSegments:ct,recomposeAuthority:eu,normalizeComponentEncoding:Vt,isIPv4:tu,nonSimpleDomain:ru}=Gr(),{SCHEMES:su,getSchemeHandler:Zn}=Yn();function nu(t,e){return typeof t=="string"?t=ae(he(t,e),e):typeof t=="object"&&(t=he(ae(t,e),e)),t}function ou(t,e,r){let s=r?Object.assign({scheme:"null"},r):{scheme:"null"},n=eo(he(t,s),he(e,s),s,true);return s.skipEscape=true,ae(n,s)}function eo(t,e,r,s){let n={};return s||(t=he(ae(t,r),r),e=he(ae(e,r),r)),r=r||{},!r.tolerant&&e.scheme?(n.scheme=e.scheme,n.userinfo=e.userinfo,n.host=e.host,n.port=e.port,n.path=ct(e.path||""),n.query=e.query):(e.userinfo!==void 0||e.host!==void 0||e.port!==void 0?(n.userinfo=e.userinfo,n.host=e.host,n.port=e.port,n.path=ct(e.path||""),n.query=e.query):(e.path?(e.path[0]==="/"?n.path=ct(e.path):((t.userinfo!==void 0||t.host!==void 0||t.port!==void 0)&&!t.path?n.path="/"+e.path:t.path?n.path=t.path.slice(0,t.path.lastIndexOf("/")+1)+e.path:n.path=e.path,n.path=ct(n.path)),n.query=e.query):(n.path=t.path,e.query!==void 0?n.query=e.query:n.query=t.query),n.userinfo=t.userinfo,n.host=t.host,n.port=t.port),n.scheme=t.scheme),n.fragment=e.fragment,n}function au(t,e,r){return typeof t=="string"?(t=unescape(t),t=ae(Vt(he(t,r),true),{...r,skipEscape:true})):typeof t=="object"&&(t=ae(Vt(t,true),{...r,skipEscape:true})),typeof e=="string"?(e=unescape(e),e=ae(Vt(he(e,r),true),{...r,skipEscape:true})):typeof e=="object"&&(e=ae(Vt(e,true),{...r,skipEscape:true})),t.toLowerCase()===e.toLowerCase()}function ae(t,e){let r={host:t.host,scheme:t.scheme,userinfo:t.userinfo,port:t.port,path:t.path,query:t.query,nid:t.nid,nss:t.nss,uuid:t.uuid,fragment:t.fragment,reference:t.reference,resourceName:t.resourceName,secure:t.secure,error:""},s=Object.assign({},e),n=[],o=Zn(s.scheme||r.scheme);o&&o.serialize&&o.serialize(r,s),r.path!==void 0&&(s.skipEscape?r.path=unescape(r.path):(r.path=escape(r.path),r.scheme!==void 0&&(r.path=r.path.split("%3A").join(":")))),s.reference!=="suffix"&&r.scheme&&n.push(r.scheme,":");let a=eu(r);if(a!==void 0&&(s.reference!=="suffix"&&n.push("//"),n.push(a),r.path&&r.path[0]!=="/"&&n.push("/")),r.path!==void 0){let i=r.path;!s.absolutePath&&(!o||!o.absolutePath)&&(i=ct(i)),a===void 0&&i[0]==="/"&&i[1]==="/"&&(i="/%2F"+i.slice(2)),n.push(i);}return r.query!==void 0&&n.push("?",r.query),r.fragment!==void 0&&n.push("#",r.fragment),n.join("")}var iu=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function he(t,e){let r=Object.assign({},e),s={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},n=false;r.reference==="suffix"&&(r.scheme?t=r.scheme+":"+t:t="//"+t);let o=t.match(iu);if(o){if(s.scheme=o[1],s.userinfo=o[3],s.host=o[4],s.port=parseInt(o[5],10),s.path=o[6]||"",s.query=o[7],s.fragment=o[8],isNaN(s.port)&&(s.port=o[5]),s.host)if(tu(s.host)===false){let c=Zc(s.host);s.host=c.host.toLowerCase(),n=c.isIPV6;}else n=true;s.scheme===void 0&&s.userinfo===void 0&&s.host===void 0&&s.port===void 0&&s.query===void 0&&!s.path?s.reference="same-document":s.scheme===void 0?s.reference="relative":s.fragment===void 0?s.reference="absolute":s.reference="uri",r.reference&&r.reference!=="suffix"&&r.reference!==s.reference&&(s.error=s.error||"URI is not a "+r.reference+" reference.");let a=Zn(r.scheme||s.scheme);if(!r.unicodeSupport&&(!a||!a.unicodeSupport)&&s.host&&(r.domainHost||a&&a.domainHost)&&n===false&&ru(s.host))try{s.host=URL.domainToASCII(s.host.toLowerCase());}catch(i){s.error=s.error||"Host's domain name can not be converted to ASCII: "+i;}(!a||a&&!a.skipNormalize)&&(t.indexOf("%")!==-1&&(s.scheme!==void 0&&(s.scheme=unescape(s.scheme)),s.host!==void 0&&(s.host=unescape(s.host))),s.path&&(s.path=escape(unescape(s.path))),s.fragment&&(s.fragment=encodeURI(decodeURIComponent(s.fragment)))),a&&a.parse&&a.parse(s,r);}else s.error=s.error||"URI can not be parsed.";return s}var Qr={SCHEMES:su,normalize:nu,resolve:ou,resolveComponent:eo,equal:au,serialize:ae,parse:he};zt.exports=Qr;zt.exports.default=Qr;zt.exports.fastUri=Qr;});var so=a(Br=>{Object.defineProperty(Br,"__esModule",{value:true});var ro=to();ro.code='require("ajv/dist/runtime/uri").default';Br.default=ro;});var fo=a(V=>{Object.defineProperty(V,"__esModule",{value:true});V.CodeGen=V.Name=V.nil=V.stringify=V.str=V._=V.KeywordCxt=void 0;var cu=at();Object.defineProperty(V,"KeywordCxt",{enumerable:true,get:function(){return cu.KeywordCxt}});var ze=S();Object.defineProperty(V,"_",{enumerable:true,get:function(){return ze._}});Object.defineProperty(V,"str",{enumerable:true,get:function(){return ze.str}});Object.defineProperty(V,"stringify",{enumerable:true,get:function(){return ze.stringify}});Object.defineProperty(V,"nil",{enumerable:true,get:function(){return ze.nil}});Object.defineProperty(V,"Name",{enumerable:true,get:function(){return ze.Name}});Object.defineProperty(V,"CodeGen",{enumerable:true,get:function(){return ze.CodeGen}});var uu=Tt(),co=it(),lu=Pr(),ut=Mt(),du=S(),lt=st(),Ut=rt(),Yr=j(),no=xn(),fu=so(),uo=(t,e)=>new RegExp(t,e);uo.code="new RegExp";var hu=["removeAdditional","useDefaults","coerceTypes"],pu=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),mu={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."},yu={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},oo=200;function _u(t){var e,r,s,n,o,a,i,c,l,u,d,y,m,h,f,p,_,q,N,C,w,se,ce,tr,rr;let Ge=t.strict,sr=(e=t.code)===null||e===void 0?void 0:e.optimize,Fs=sr===true||sr===void 0?1:sr||0,xs=(s=(r=t.code)===null||r===void 0?void 0:r.regExp)!==null&&s!==void 0?s:uo,ga=(n=t.uriResolver)!==null&&n!==void 0?n:fu.default;return {strictSchema:(a=(o=t.strictSchema)!==null&&o!==void 0?o:Ge)!==null&&a!==void 0?a:true,strictNumbers:(c=(i=t.strictNumbers)!==null&&i!==void 0?i:Ge)!==null&&c!==void 0?c:true,strictTypes:(u=(l=t.strictTypes)!==null&&l!==void 0?l:Ge)!==null&&u!==void 0?u:"log",strictTuples:(y=(d=t.strictTuples)!==null&&d!==void 0?d:Ge)!==null&&y!==void 0?y:"log",strictRequired:(h=(m=t.strictRequired)!==null&&m!==void 0?m:Ge)!==null&&h!==void 0?h:false,code:t.code?{...t.code,optimize:Fs,regExp:xs}:{optimize:Fs,regExp:xs},loopRequired:(f=t.loopRequired)!==null&&f!==void 0?f:oo,loopEnum:(p=t.loopEnum)!==null&&p!==void 0?p:oo,meta:(_=t.meta)!==null&&_!==void 0?_:true,messages:(q=t.messages)!==null&&q!==void 0?q:true,inlineRefs:(N=t.inlineRefs)!==null&&N!==void 0?N:true,schemaId:(C=t.schemaId)!==null&&C!==void 0?C:"$id",addUsedSchema:(w=t.addUsedSchema)!==null&&w!==void 0?w:true,validateSchema:(se=t.validateSchema)!==null&&se!==void 0?se:true,validateFormats:(ce=t.validateFormats)!==null&&ce!==void 0?ce:true,unicodeRegExp:(tr=t.unicodeRegExp)!==null&&tr!==void 0?tr:true,int32range:(rr=t.int32range)!==null&&rr!==void 0?rr:true,uriResolver:ga}}var dt=class{constructor(e={}){this.schemas={},this.refs={},this.formats={},this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,..._u(e)};let{es5:r,lines:s}=this.opts.code;this.scope=new du.ValueScope({scope:{},prefixes:pu,es5:r,lines:s}),this.logger=Eu(e.logger);let n=e.validateFormats;e.validateFormats=false,this.RULES=(0, lu.getRules)(),ao.call(this,mu,e,"NOT SUPPORTED"),ao.call(this,yu,e,"DEPRECATED","warn"),this._metaOpts=wu.call(this),e.formats&&$u.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&vu.call(this,e.keywords),typeof e.meta=="object"&&this.addMetaSchema(e.meta),gu.call(this),e.validateFormats=n;}_addVocabularies(){this.addKeyword("$async");}_addDefaultMetaSchema(){let{$data:e,meta:r,schemaId:s}=this.opts,n=no;s==="id"&&(n={...no},n.id=n.$id,delete n.$id),r&&e&&this.addMetaSchema(n,n[s],false);}defaultMeta(){let{meta:e,schemaId:r}=this.opts;return this.opts.defaultMeta=typeof e=="object"?e[r]||e:void 0}validate(e,r){let s;if(typeof e=="string"){if(s=this.getSchema(e),!s)throw new Error(`no schema with key or ref "${e}"`)}else s=this.compile(e);let n=s(r);return "$async"in s||(this.errors=s.errors),n}compile(e,r){let s=this._addSchema(e,r);return s.validate||this._compileSchemaEnv(s)}compileAsync(e,r){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");let{loadSchema:s}=this.opts;return n.call(this,e,r);async function n(u,d){await o.call(this,u.$schema);let y=this._addSchema(u,d);return y.validate||a.call(this,y)}async function o(u){u&&!this.getSchema(u)&&await n.call(this,{$ref:u},true);}async function a(u){try{return this._compileSchemaEnv(u)}catch(d){if(!(d instanceof co.default))throw d;return i.call(this,d),await c.call(this,d.missingSchema),a.call(this,u)}}function i({missingSchema:u,missingRef:d}){if(this.refs[u])throw new Error(`AnySchema ${u} is loaded but ${d} cannot be resolved`)}async function c(u){let d=await l.call(this,u);this.refs[u]||await o.call(this,d.$schema),this.refs[u]||this.addSchema(d,u,r);}async function l(u){let d=this._loading[u];if(d)return d;try{return await(this._loading[u]=s(u))}finally{delete this._loading[u];}}}addSchema(e,r,s,n=this.opts.validateSchema){if(Array.isArray(e)){for(let a of e)this.addSchema(a,void 0,s,n);return this}let o;if(typeof e=="object"){let{schemaId:a}=this.opts;if(o=e[a],o!==void 0&&typeof o!="string")throw new Error(`schema ${a} must be string`)}return r=(0, lt.normalizeId)(r||o),this._checkUnique(r),this.schemas[r]=this._addSchema(e,s,r,n,true),this}addMetaSchema(e,r,s=this.opts.validateSchema){return this.addSchema(e,r,true,s),this}validateSchema(e,r){if(typeof e=="boolean")return true;let s;if(s=e.$schema,s!==void 0&&typeof s!="string")throw new Error("$schema must be a string");if(s=s||this.opts.defaultMeta||this.defaultMeta(),!s)return this.logger.warn("meta-schema not available"),this.errors=null,true;let n=this.validate(s,e);if(!n&&r){let o="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(o);else throw new Error(o)}return n}getSchema(e){let r;for(;typeof(r=io.call(this,e))=="string";)e=r;if(r===void 0){let{schemaId:s}=this.opts,n=new ut.SchemaEnv({schema:{},schemaId:s});if(r=ut.resolveSchema.call(this,n,e),!r)return;this.refs[e]=r;}return r.validate||this._compileSchemaEnv(r)}removeSchema(e){if(e instanceof RegExp)return this._removeAllSchemas(this.schemas,e),this._removeAllSchemas(this.refs,e),this;switch(typeof e){case "undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case "string":{let r=io.call(this,e);return typeof r=="object"&&this._cache.delete(r.schema),delete this.schemas[e],delete this.refs[e],this}case "object":{let r=e;this._cache.delete(r);let s=e[this.opts.schemaId];return s&&(s=(0, lt.normalizeId)(s),delete this.schemas[s],delete this.refs[s]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(e){for(let r of e)this.addKeyword(r);return this}addKeyword(e,r){let s;if(typeof e=="string")s=e,typeof r=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),r.keyword=s);else if(typeof e=="object"&&r===void 0){if(r=e,s=r.keyword,Array.isArray(s)&&!s.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(Pu.call(this,s,r),!r)return (0, Yr.eachItem)(s,o=>Xr.call(this,o)),this;ku.call(this,r);let n={...r,type:(0, Ut.getJSONTypes)(r.type),schemaType:(0, Ut.getJSONTypes)(r.schemaType)};return (0, Yr.eachItem)(s,n.type.length===0?o=>Xr.call(this,o,n):o=>n.type.forEach(a=>Xr.call(this,o,n,a))),this}getKeyword(e){let r=this.RULES.all[e];return typeof r=="object"?r.definition:!!r}removeKeyword(e){let{RULES:r}=this;delete r.keywords[e],delete r.all[e];for(let s of r.rules){let n=s.rules.findIndex(o=>o.keyword===e);n>=0&&s.rules.splice(n,1);}return this}addFormat(e,r){return typeof r=="string"&&(r=new RegExp(r)),this.formats[e]=r,this}errorsText(e=this.errors,{separator:r=", ",dataVar:s="data"}={}){return !e||e.length===0?"No errors":e.map(n=>`${s}${n.instancePath} ${n.message}`).reduce((n,o)=>n+r+o)}$dataMetaSchema(e,r){let s=this.RULES.all;e=JSON.parse(JSON.stringify(e));for(let n of r){let o=n.split("/").slice(1),a=e;for(let i of o)a=a[i];for(let i in s){let c=s[i];if(typeof c!="object")continue;let{$data:l}=c.definition,u=a[i];l&&u&&(a[i]=lo(u));}}return e}_removeAllSchemas(e,r){for(let s in e){let n=e[s];(!r||r.test(s))&&(typeof n=="string"?delete e[s]:n&&!n.meta&&(this._cache.delete(n.schema),delete e[s]));}}_addSchema(e,r,s,n=this.opts.validateSchema,o=this.opts.addUsedSchema){let a,{schemaId:i}=this.opts;if(typeof e=="object")a=e[i];else {if(this.opts.jtd)throw new Error("schema must be object");if(typeof e!="boolean")throw new Error("schema must be object or boolean")}let c=this._cache.get(e);if(c!==void 0)return c;s=(0, lt.normalizeId)(a||s);let l=lt.getSchemaRefs.call(this,e,s);return c=new ut.SchemaEnv({schema:e,schemaId:i,meta:r,baseId:s,localRefs:l}),this._cache.set(c.schema,c),o&&!s.startsWith("#")&&(s&&this._checkUnique(s),this.refs[s]=c),n&&this.validateSchema(e,true),c}_checkUnique(e){if(this.schemas[e]||this.refs[e])throw new Error(`schema with key or id "${e}" already exists`)}_compileSchemaEnv(e){if(e.meta?this._compileMetaSchema(e):ut.compileSchema.call(this,e),!e.validate)throw new Error("ajv implementation error");return e.validate}_compileMetaSchema(e){let r=this.opts;this.opts=this._metaOpts;try{ut.compileSchema.call(this,e);}finally{this.opts=r;}}};dt.ValidationError=uu.default;dt.MissingRefError=co.default;V.default=dt;function ao(t,e,r,s="error"){for(let n in t){let o=n;o in e&&this.logger[s](`${r}: option ${n}. ${t[o]}`);}}function io(t){return t=(0, lt.normalizeId)(t),this.schemas[t]||this.refs[t]}function gu(){let t=this.opts.schemas;if(t)if(Array.isArray(t))this.addSchema(t);else for(let e in t)this.addSchema(t[e],e);}function $u(){for(let t in this.opts.formats){let e=this.opts.formats[t];e&&this.addFormat(t,e);}}function vu(t){if(Array.isArray(t)){this.addVocabulary(t);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let e in t){let r=t[e];r.keyword||(r.keyword=e),this.addKeyword(r);}}function wu(){let t={...this.opts};for(let e of hu)delete t[e];return t}var bu={log(){},warn(){},error(){}};function Eu(t){if(t===false)return bu;if(t===void 0)return console;if(t.log&&t.warn&&t.error)return t;throw new Error("logger must implement log, warn and error methods")}var Su=/^[a-z_$][a-z0-9_$:-]*$/i;function Pu(t,e){let{RULES:r}=this;if((0, Yr.eachItem)(t,s=>{if(r.keywords[s])throw new Error(`Keyword ${s} is already defined`);if(!Su.test(s))throw new Error(`Keyword ${s} has invalid name`)}),!!e&&e.$data&&!("code"in e||"validate"in e))throw new Error('$data keyword must have "code" or "validate" function')}function Xr(t,e,r){var s;let n=e?.post;if(r&&n)throw new Error('keyword with "post" flag cannot have "type"');let{RULES:o}=this,a=n?o.post:o.rules.find(({type:c})=>c===r);if(a||(a={type:r,rules:[]},o.rules.push(a)),o.keywords[t]=true,!e)return;let i={keyword:t,definition:{...e,type:(0, Ut.getJSONTypes)(e.type),schemaType:(0, Ut.getJSONTypes)(e.schemaType)}};e.before?Nu.call(this,a,i,e.before):a.rules.push(i),o.all[t]=i,(s=e.implements)===null||s===void 0||s.forEach(c=>this.addKeyword(c));}function Nu(t,e,r){let s=t.rules.findIndex(n=>n.keyword===r);s>=0?t.rules.splice(s,0,e):(t.rules.push(e),this.logger.warn(`rule ${r} is not defined`));}function ku(t){let{metaSchema:e}=t;e!==void 0&&(t.$data&&this.opts.$data&&(e=lo(e)),t.validateSchema=this.compile(e,true));}var qu={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function lo(t){return {anyOf:[t,qu]}}});var ho=a(Zr=>{Object.defineProperty(Zr,"__esModule",{value:true});var ju={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};Zr.default=ju;});var _o=a(qe=>{Object.defineProperty(qe,"__esModule",{value:true});qe.callRef=qe.getValidate=void 0;var Ou=it(),po=B(),W=S(),Ue=de(),mo=Mt(),Kt=j(),Iu={keyword:"$ref",schemaType:"string",code(t){let{gen:e,schema:r,it:s}=t,{baseId:n,schemaEnv:o,validateName:a,opts:i,self:c}=s,{root:l}=o;if((r==="#"||r==="#/")&&n===l.baseId)return d();let u=mo.resolveRef.call(c,l,n,r);if(u===void 0)throw new Ou.default(s.opts.uriResolver,n,r);if(u instanceof mo.SchemaEnv)return y(u);return m(u);function d(){if(o===l)return Ft(t,a,o,o.$async);let h=e.scopeValue("root",{ref:l});return Ft(t,(0, W._)`${h}.validate`,l,l.$async)}function y(h){let f=yo(t,h);Ft(t,f,h,h.$async);}function m(h){let f=e.scopeValue("schema",i.code.source===true?{ref:h,code:(0, W.stringify)(h)}:{ref:h}),p=e.name("valid"),_=t.subschema({schema:h,dataTypes:[],schemaPath:W.nil,topSchemaRef:f,errSchemaPath:r},p);t.mergeEvaluated(_),t.ok(p);}}};function yo(t,e){let{gen:r}=t;return e.validate?r.scopeValue("validate",{ref:e.validate}):(0, W._)`${r.scopeValue("wrapper",{ref:e})}.validate`}qe.getValidate=yo;function Ft(t,e,r,s){let{gen:n,it:o}=t,{allErrors:a,schemaEnv:i,opts:c}=o,l=c.passContext?Ue.default.this:W.nil;s?u():d();function u(){if(!i.$async)throw new Error("async schema referenced by sync schema");let h=n.let("valid");n.try(()=>{n.code((0, W._)`await ${(0, po.callValidateCode)(t,e,l)}`),m(e),a||n.assign(h,true);},f=>{n.if((0, W._)`!(${f} instanceof ${o.ValidationError})`,()=>n.throw(f)),y(f),a||n.assign(h,false);}),t.ok(h);}function d(){t.result((0, po.callValidateCode)(t,e,l),()=>m(e),()=>y(e));}function y(h){let f=(0, W._)`${h}.errors`;n.assign(Ue.default.vErrors,(0, W._)`${Ue.default.vErrors} === null ? ${f} : ${Ue.default.vErrors}.concat(${f})`),n.assign(Ue.default.errors,(0, W._)`${Ue.default.vErrors}.length`);}function m(h){var f;if(!o.opts.unevaluated)return;let p=(f=r?.validate)===null||f===void 0?void 0:f.evaluated;if(o.props!==true)if(p&&!p.dynamicProps)p.props!==void 0&&(o.props=Kt.mergeEvaluated.props(n,p.props,o.props));else {let _=n.var("props",(0, W._)`${h}.evaluated.props`);o.props=Kt.mergeEvaluated.props(n,_,o.props,W.Name);}if(o.items!==true)if(p&&!p.dynamicItems)p.items!==void 0&&(o.items=Kt.mergeEvaluated.items(n,p.items,o.items));else {let _=n.var("items",(0, W._)`${h}.evaluated.items`);o.items=Kt.mergeEvaluated.items(n,_,o.items,W.Name);}}}qe.callRef=Ft;qe.default=Iu;});var go=a(es=>{Object.defineProperty(es,"__esModule",{value:true});var Ru=ho(),Tu=_o(),Cu=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",Ru.default,Tu.default];es.default=Cu;});var $o=a(ts=>{Object.defineProperty(ts,"__esModule",{value:true});var xt=S(),ve=xt.operators,Lt={maximum:{okStr:"<=",ok:ve.LTE,fail:ve.GT},minimum:{okStr:">=",ok:ve.GTE,fail:ve.LT},exclusiveMaximum:{okStr:"<",ok:ve.LT,fail:ve.GTE},exclusiveMinimum:{okStr:">",ok:ve.GT,fail:ve.LTE}},Mu={message:({keyword:t,schemaCode:e})=>(0, xt.str)`must be ${Lt[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0, xt._)`{comparison: ${Lt[t].okStr}, limit: ${e}}`},Au={keyword:Object.keys(Lt),type:"number",schemaType:"number",$data:true,error:Mu,code(t){let{keyword:e,data:r,schemaCode:s}=t;t.fail$data((0, xt._)`${r} ${Lt[e].fail} ${s} || isNaN(${r})`);}};ts.default=Au;});var vo=a(rs=>{Object.defineProperty(rs,"__esModule",{value:true});var ft=S(),Du={message:({schemaCode:t})=>(0, ft.str)`must be multiple of ${t}`,params:({schemaCode:t})=>(0, ft._)`{multipleOf: ${t}}`},Vu={keyword:"multipleOf",type:"number",schemaType:"number",$data:true,error:Du,code(t){let{gen:e,data:r,schemaCode:s,it:n}=t,o=n.opts.multipleOfPrecision,a=e.let("res"),i=o?(0, ft._)`Math.abs(Math.round(${a}) - ${a}) > 1e-${o}`:(0, ft._)`${a} !== parseInt(${a})`;t.fail$data((0, ft._)`(${s} === 0 || (${a} = ${r}/${s}, ${i}))`);}};rs.default=Vu;});var bo=a(ss=>{Object.defineProperty(ss,"__esModule",{value:true});function wo(t){let e=t.length,r=0,s=0,n;for(;s<e;)r++,n=t.charCodeAt(s++),n>=55296&&n<=56319&&s<e&&(n=t.charCodeAt(s),(n&64512)===56320&&s++);return r}ss.default=wo;wo.code='require("ajv/dist/runtime/ucs2length").default';});var Eo=a(ns=>{Object.defineProperty(ns,"__esModule",{value:true});var je=S(),zu=j(),Uu=bo(),Ku={message({keyword:t,schemaCode:e}){let r=t==="maxLength"?"more":"fewer";return (0, je.str)`must NOT have ${r} than ${e} characters`},params:({schemaCode:t})=>(0, je._)`{limit: ${t}}`},Fu={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:true,error:Ku,code(t){let{keyword:e,data:r,schemaCode:s,it:n}=t,o=e==="maxLength"?je.operators.GT:je.operators.LT,a=n.opts.unicode===false?(0, je._)`${r}.length`:(0, je._)`${(0, zu.useFunc)(t.gen,Uu.default)}(${r})`;t.fail$data((0, je._)`${a} ${o} ${s}`);}};ns.default=Fu;});var So=a(os=>{Object.defineProperty(os,"__esModule",{value:true});var xu=B(),Lu=j(),Ke=S(),Hu={message:({schemaCode:t})=>(0, Ke.str)`must match pattern "${t}"`,params:({schemaCode:t})=>(0, Ke._)`{pattern: ${t}}`},Gu={keyword:"pattern",type:"string",schemaType:"string",$data:true,error:Hu,code(t){let{gen:e,data:r,$data:s,schema:n,schemaCode:o,it:a}=t,i=a.opts.unicodeRegExp?"u":"";if(s){let{regExp:c}=a.opts.code,l=c.code==="new RegExp"?(0, Ke._)`new RegExp`:(0, Lu.useFunc)(e,c),u=e.let("valid");e.try(()=>e.assign(u,(0, Ke._)`${l}(${o}, ${i}).test(${r})`),()=>e.assign(u,false)),t.fail$data((0, Ke._)`!${u}`);}else {let c=(0, xu.usePattern)(t,n);t.fail$data((0, Ke._)`!${c}.test(${r})`);}}};os.default=Gu;});var Po=a(as=>{Object.defineProperty(as,"__esModule",{value:true});var ht=S(),Ju={message({keyword:t,schemaCode:e}){let r=t==="maxProperties"?"more":"fewer";return (0, ht.str)`must NOT have ${r} than ${e} properties`},params:({schemaCode:t})=>(0, ht._)`{limit: ${t}}`},Wu={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:true,error:Ju,code(t){let{keyword:e,data:r,schemaCode:s}=t,n=e==="maxProperties"?ht.operators.GT:ht.operators.LT;t.fail$data((0, ht._)`Object.keys(${r}).length ${n} ${s}`);}};as.default=Wu;});var No=a(is=>{Object.defineProperty(is,"__esModule",{value:true});var pt=B(),mt=S(),Qu=j(),Bu={message:({params:{missingProperty:t}})=>(0, mt.str)`must have required property '${t}'`,params:({params:{missingProperty:t}})=>(0, mt._)`{missingProperty: ${t}}`},Xu={keyword:"required",type:"object",schemaType:"array",$data:true,error:Bu,code(t){let{gen:e,schema:r,schemaCode:s,data:n,$data:o,it:a}=t,{opts:i}=a;if(!o&&r.length===0)return;let c=r.length>=i.loopRequired;if(a.allErrors?l():u(),i.strictRequired){let m=t.parentSchema.properties,{definedProperties:h}=t.it;for(let f of r)if(m?.[f]===void 0&&!h.has(f)){let p=a.schemaEnv.baseId+a.errSchemaPath,_=`required property "${f}" is not defined at "${p}" (strictRequired)`;(0, Qu.checkStrictMode)(a,_,a.opts.strictRequired);}}function l(){if(c||o)t.block$data(mt.nil,d);else for(let m of r)(0, pt.checkReportMissingProp)(t,m);}function u(){let m=e.let("missing");if(c||o){let h=e.let("valid",true);t.block$data(h,()=>y(m,h)),t.ok(h);}else e.if((0, pt.checkMissingProp)(t,r,m)),(0, pt.reportMissingProp)(t,m),e.else();}function d(){e.forOf("prop",s,m=>{t.setParams({missingProperty:m}),e.if((0, pt.noPropertyInData)(e,n,m,i.ownProperties),()=>t.error());});}function y(m,h){t.setParams({missingProperty:m}),e.forOf(m,s,()=>{e.assign(h,(0, pt.propertyInData)(e,n,m,i.ownProperties)),e.if((0, mt.not)(h),()=>{t.error(),e.break();});},mt.nil);}}};is.default=Xu;});var ko=a(cs=>{Object.defineProperty(cs,"__esModule",{value:true});var yt=S(),Yu={message({keyword:t,schemaCode:e}){let r=t==="maxItems"?"more":"fewer";return (0, yt.str)`must NOT have ${r} than ${e} items`},params:({schemaCode:t})=>(0, yt._)`{limit: ${t}}`},Zu={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:true,error:Yu,code(t){let{keyword:e,data:r,schemaCode:s}=t,n=e==="maxItems"?yt.operators.GT:yt.operators.LT;t.fail$data((0, yt._)`${r}.length ${n} ${s}`);}};cs.default=Zu;});var Ht=a(us=>{Object.defineProperty(us,"__esModule",{value:true});var qo=Tr();qo.code='require("ajv/dist/runtime/equal").default';us.default=qo;});var jo=a(ds=>{Object.defineProperty(ds,"__esModule",{value:true});var ls=rt(),z=S(),el=j(),tl=Ht(),rl={message:({params:{i:t,j:e}})=>(0, z.str)`must NOT have duplicate items (items ## ${e} and ${t} are identical)`,params:({params:{i:t,j:e}})=>(0, z._)`{i: ${t}, j: ${e}}`},sl={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:true,error:rl,code(t){let{gen:e,data:r,$data:s,schema:n,parentSchema:o,schemaCode:a,it:i}=t;if(!s&&!n)return;let c=e.let("valid"),l=o.items?(0, ls.getSchemaTypes)(o.items):[];t.block$data(c,u,(0, z._)`${a} === false`),t.ok(c);function u(){let h=e.let("i",(0, z._)`${r}.length`),f=e.let("j");t.setParams({i:h,j:f}),e.assign(c,true),e.if((0, z._)`${h} > 1`,()=>(d()?y:m)(h,f));}function d(){return l.length>0&&!l.some(h=>h==="object"||h==="array")}function y(h,f){let p=e.name("item"),_=(0, ls.checkDataTypes)(l,p,i.opts.strictNumbers,ls.DataType.Wrong),q=e.const("indices",(0, z._)`{}`);e.for((0, z._)`;${h}--;`,()=>{e.let(p,(0, z._)`${r}[${h}]`),e.if(_,(0, z._)`continue`),l.length>1&&e.if((0, z._)`typeof ${p} == "string"`,(0, z._)`${p} += "_"`),e.if((0, z._)`typeof ${q}[${p}] == "number"`,()=>{e.assign(f,(0, z._)`${q}[${p}]`),t.error(),e.assign(c,false).break();}).code((0, z._)`${q}[${p}] = ${h}`);});}function m(h,f){let p=(0, el.useFunc)(e,tl.default),_=e.name("outer");e.label(_).for((0, z._)`;${h}--;`,()=>e.for((0, z._)`${f} = ${h}; ${f}--;`,()=>e.if((0, z._)`${p}(${r}[${h}], ${r}[${f}])`,()=>{t.error(),e.assign(c,false).break(_);})));}}};ds.default=sl;});var Oo=a(hs=>{Object.defineProperty(hs,"__esModule",{value:true});var fs=S(),nl=j(),ol=Ht(),al={message:"must be equal to constant",params:({schemaCode:t})=>(0, fs._)`{allowedValue: ${t}}`},il={keyword:"const",$data:true,error:al,code(t){let{gen:e,data:r,$data:s,schemaCode:n,schema:o}=t;s||o&&typeof o=="object"?t.fail$data((0, fs._)`!${(0, nl.useFunc)(e,ol.default)}(${r}, ${n})`):t.fail((0, fs._)`${o} !== ${r}`);}};hs.default=il;});var Io=a(ps=>{Object.defineProperty(ps,"__esModule",{value:true});var _t=S(),cl=j(),ul=Ht(),ll={message:"must be equal to one of the allowed values",params:({schemaCode:t})=>(0, _t._)`{allowedValues: ${t}}`},dl={keyword:"enum",schemaType:"array",$data:true,error:ll,code(t){let{gen:e,data:r,$data:s,schema:n,schemaCode:o,it:a}=t;if(!s&&n.length===0)throw new Error("enum must have non-empty array");let i=n.length>=a.opts.loopEnum,c,l=()=>c??(c=(0, cl.useFunc)(e,ul.default)),u;if(i||s)u=e.let("valid"),t.block$data(u,d);else {if(!Array.isArray(n))throw new Error("ajv implementation error");let m=e.const("vSchema",o);u=(0, _t.or)(...n.map((h,f)=>y(m,f)));}t.pass(u);function d(){e.assign(u,false),e.forOf("v",o,m=>e.if((0, _t._)`${l()}(${r}, ${m})`,()=>e.assign(u,true).break()));}function y(m,h){let f=n[h];return typeof f=="object"&&f!==null?(0, _t._)`${l()}(${r}, ${m}[${h}])`:(0, _t._)`${r} === ${f}`}}};ps.default=dl;});var Ro=a(ms=>{Object.defineProperty(ms,"__esModule",{value:true});var fl=$o(),hl=vo(),pl=Eo(),ml=So(),yl=Po(),_l=No(),gl=ko(),$l=jo(),vl=Oo(),wl=Io(),bl=[fl.default,hl.default,pl.default,ml.default,yl.default,_l.default,gl.default,$l.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},vl.default,wl.default];ms.default=bl;});var _s=a(gt=>{Object.defineProperty(gt,"__esModule",{value:true});gt.validateAdditionalItems=void 0;var Oe=S(),ys=j(),El={message:({params:{len:t}})=>(0, Oe.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0, Oe._)`{limit: ${t}}`},Sl={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:El,code(t){let{parentSchema:e,it:r}=t,{items:s}=e;if(!Array.isArray(s)){(0, ys.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}To(t,s);}};function To(t,e){let{gen:r,schema:s,data:n,keyword:o,it:a}=t;a.items=true;let i=r.const("len",(0, Oe._)`${n}.length`);if(s===false)t.setParams({len:e.length}),t.pass((0, Oe._)`${i} <= ${e.length}`);else if(typeof s=="object"&&!(0, ys.alwaysValidSchema)(a,s)){let l=r.var("valid",(0, Oe._)`${i} <= ${e.length}`);r.if((0, Oe.not)(l),()=>c(l)),t.ok(l);}function c(l){r.forRange("i",e.length,i,u=>{t.subschema({keyword:o,dataProp:u,dataPropType:ys.Type.Num},l),a.allErrors||r.if((0, Oe.not)(l),()=>r.break());});}}gt.validateAdditionalItems=To;gt.default=Sl;});var gs=a($t=>{Object.defineProperty($t,"__esModule",{value:true});$t.validateTuple=void 0;var Co=S(),Gt=j(),Pl=B(),Nl={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(t){let{schema:e,it:r}=t;if(Array.isArray(e))return Mo(t,"additionalItems",e);r.items=true,!(0, Gt.alwaysValidSchema)(r,e)&&t.ok((0, Pl.validateArray)(t));}};function Mo(t,e,r=t.schema){let{gen:s,parentSchema:n,data:o,keyword:a,it:i}=t;u(n),i.opts.unevaluated&&r.length&&i.items!==true&&(i.items=Gt.mergeEvaluated.items(s,r.length,i.items));let c=s.name("valid"),l=s.const("len",(0, Co._)`${o}.length`);r.forEach((d,y)=>{(0, Gt.alwaysValidSchema)(i,d)||(s.if((0, Co._)`${l} > ${y}`,()=>t.subschema({keyword:a,schemaProp:y,dataProp:y},c)),t.ok(c));});function u(d){let{opts:y,errSchemaPath:m}=i,h=r.length,f=h===d.minItems&&(h===d.maxItems||d[e]===false);if(y.strictTuples&&!f){let p=`"${a}" is ${h}-tuple, but minItems or maxItems/${e} are not specified or different at path "${m}"`;(0, Gt.checkStrictMode)(i,p,y.strictTuples);}}}$t.validateTuple=Mo;$t.default=Nl;});var Ao=a($s=>{Object.defineProperty($s,"__esModule",{value:true});var kl=gs(),ql={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:t=>(0, kl.validateTuple)(t,"items")};$s.default=ql;});var Vo=a(vs=>{Object.defineProperty(vs,"__esModule",{value:true});var Do=S(),jl=j(),Ol=B(),Il=_s(),Rl={message:({params:{len:t}})=>(0, Do.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0, Do._)`{limit: ${t}}`},Tl={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:Rl,code(t){let{schema:e,parentSchema:r,it:s}=t,{prefixItems:n}=r;s.items=true,!(0, jl.alwaysValidSchema)(s,e)&&(n?(0, Il.validateAdditionalItems)(t,n):t.ok((0, Ol.validateArray)(t)));}};vs.default=Tl;});var zo=a(ws=>{Object.defineProperty(ws,"__esModule",{value:true});var Y=S(),Jt=j(),Cl={message:({params:{min:t,max:e}})=>e===void 0?(0, Y.str)`must contain at least ${t} valid item(s)`:(0, Y.str)`must contain at least ${t} and no more than ${e} valid item(s)`,params:({params:{min:t,max:e}})=>e===void 0?(0, Y._)`{minContains: ${t}}`:(0, Y._)`{minContains: ${t}, maxContains: ${e}}`},Ml={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:true,error:Cl,code(t){let{gen:e,schema:r,parentSchema:s,data:n,it:o}=t,a,i,{minContains:c,maxContains:l}=s;o.opts.next?(a=c===void 0?1:c,i=l):a=1;let u=e.const("len",(0, Y._)`${n}.length`);if(t.setParams({min:a,max:i}),i===void 0&&a===0){(0, Jt.checkStrictMode)(o,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(i!==void 0&&a>i){(0, Jt.checkStrictMode)(o,'"minContains" > "maxContains" is always invalid'),t.fail();return}if((0, Jt.alwaysValidSchema)(o,r)){let f=(0, Y._)`${u} >= ${a}`;i!==void 0&&(f=(0, Y._)`${f} && ${u} <= ${i}`),t.pass(f);return}o.items=true;let d=e.name("valid");i===void 0&&a===1?m(d,()=>e.if(d,()=>e.break())):a===0?(e.let(d,true),i!==void 0&&e.if((0, Y._)`${n}.length > 0`,y)):(e.let(d,false),y()),t.result(d,()=>t.reset());function y(){let f=e.name("_valid"),p=e.let("count",0);m(f,()=>e.if(f,()=>h(p)));}function m(f,p){e.forRange("i",0,u,_=>{t.subschema({keyword:"contains",dataProp:_,dataPropType:Jt.Type.Num,compositeRule:true},f),p();});}function h(f){e.code((0, Y._)`${f}++`),i===void 0?e.if((0, Y._)`${f} >= ${a}`,()=>e.assign(d,true).break()):(e.if((0, Y._)`${f} > ${i}`,()=>e.assign(d,false).break()),a===1?e.assign(d,true):e.if((0, Y._)`${f} >= ${a}`,()=>e.assign(d,true)));}}};ws.default=Ml;});var Fo=a(ie=>{Object.defineProperty(ie,"__esModule",{value:true});ie.validateSchemaDeps=ie.validatePropertyDeps=ie.error=void 0;var bs=S(),Al=j(),vt=B();ie.error={message:({params:{property:t,depsCount:e,deps:r}})=>{let s=e===1?"property":"properties";return (0, bs.str)`must have ${s} ${r} when property ${t} is present`},params:({params:{property:t,depsCount:e,deps:r,missingProperty:s}})=>(0, bs._)`{property: ${t},
|
|
6
|
+
missingProperty: ${s},
|
|
7
|
+
depsCount: ${e},
|
|
8
|
+
deps: ${r}}`};var Dl={keyword:"dependencies",type:"object",schemaType:"object",error:ie.error,code(t){let[e,r]=Vl(t);Uo(t,e),Ko(t,r);}};function Vl({schema:t}){let e={},r={};for(let s in t){if(s==="__proto__")continue;let n=Array.isArray(t[s])?e:r;n[s]=t[s];}return [e,r]}function Uo(t,e=t.schema){let{gen:r,data:s,it:n}=t;if(Object.keys(e).length===0)return;let o=r.let("missing");for(let a in e){let i=e[a];if(i.length===0)continue;let c=(0, vt.propertyInData)(r,s,a,n.opts.ownProperties);t.setParams({property:a,depsCount:i.length,deps:i.join(", ")}),n.allErrors?r.if(c,()=>{for(let l of i)(0, vt.checkReportMissingProp)(t,l);}):(r.if((0, bs._)`${c} && (${(0, vt.checkMissingProp)(t,i,o)})`),(0, vt.reportMissingProp)(t,o),r.else());}}ie.validatePropertyDeps=Uo;function Ko(t,e=t.schema){let{gen:r,data:s,keyword:n,it:o}=t,a=r.name("valid");for(let i in e)(0, Al.alwaysValidSchema)(o,e[i])||(r.if((0, vt.propertyInData)(r,s,i,o.opts.ownProperties),()=>{let c=t.subschema({keyword:n,schemaProp:i},a);t.mergeValidEvaluated(c,a);},()=>r.var(a,true)),t.ok(a));}ie.validateSchemaDeps=Ko;ie.default=Dl;});var Lo=a(Es=>{Object.defineProperty(Es,"__esModule",{value:true});var xo=S(),zl=j(),Ul={message:"property name must be valid",params:({params:t})=>(0, xo._)`{propertyName: ${t.propertyName}}`},Kl={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:Ul,code(t){let{gen:e,schema:r,data:s,it:n}=t;if((0, zl.alwaysValidSchema)(n,r))return;let o=e.name("valid");e.forIn("key",s,a=>{t.setParams({propertyName:a}),t.subschema({keyword:"propertyNames",data:a,dataTypes:["string"],propertyName:a,compositeRule:true},o),e.if((0, xo.not)(o),()=>{t.error(true),n.allErrors||e.break();});}),t.ok(o);}};Es.default=Kl;});var Ps=a(Ss=>{Object.defineProperty(Ss,"__esModule",{value:true});var Wt=B(),re=S(),Fl=de(),Qt=j(),xl={message:"must NOT have additional properties",params:({params:t})=>(0, re._)`{additionalProperty: ${t.additionalProperty}}`},Ll={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:true,trackErrors:true,error:xl,code(t){let{gen:e,schema:r,parentSchema:s,data:n,errsCount:o,it:a}=t;if(!o)throw new Error("ajv implementation error");let{allErrors:i,opts:c}=a;if(a.props=true,c.removeAdditional!=="all"&&(0, Qt.alwaysValidSchema)(a,r))return;let l=(0, Wt.allSchemaProperties)(s.properties),u=(0, Wt.allSchemaProperties)(s.patternProperties);d(),t.ok((0, re._)`${o} === ${Fl.default.errors}`);function d(){e.forIn("key",n,p=>{!l.length&&!u.length?h(p):e.if(y(p),()=>h(p));});}function y(p){let _;if(l.length>8){let q=(0, Qt.schemaRefOrVal)(a,s.properties,"properties");_=(0, Wt.isOwnProperty)(e,q,p);}else l.length?_=(0, re.or)(...l.map(q=>(0, re._)`${p} === ${q}`)):_=re.nil;return u.length&&(_=(0, re.or)(_,...u.map(q=>(0, re._)`${(0, Wt.usePattern)(t,q)}.test(${p})`))),(0, re.not)(_)}function m(p){e.code((0, re._)`delete ${n}[${p}]`);}function h(p){if(c.removeAdditional==="all"||c.removeAdditional&&r===false){m(p);return}if(r===false){t.setParams({additionalProperty:p}),t.error(),i||e.break();return}if(typeof r=="object"&&!(0, Qt.alwaysValidSchema)(a,r)){let _=e.name("valid");c.removeAdditional==="failing"?(f(p,_,false),e.if((0, re.not)(_),()=>{t.reset(),m(p);})):(f(p,_),i||e.if((0, re.not)(_),()=>e.break()));}}function f(p,_,q){let N={keyword:"additionalProperties",dataProp:p,dataPropType:Qt.Type.Str};q===false&&Object.assign(N,{compositeRule:true,createErrors:false,allErrors:false}),t.subschema(N,_);}}};Ss.default=Ll;});var Jo=a(ks=>{Object.defineProperty(ks,"__esModule",{value:true});var Hl=at(),Ho=B(),Ns=j(),Go=Ps(),Gl={keyword:"properties",type:"object",schemaType:"object",code(t){let{gen:e,schema:r,parentSchema:s,data:n,it:o}=t;o.opts.removeAdditional==="all"&&s.additionalProperties===void 0&&Go.default.code(new Hl.KeywordCxt(o,Go.default,"additionalProperties"));let a=(0, Ho.allSchemaProperties)(r);for(let d of a)o.definedProperties.add(d);o.opts.unevaluated&&a.length&&o.props!==true&&(o.props=Ns.mergeEvaluated.props(e,(0, Ns.toHash)(a),o.props));let i=a.filter(d=>!(0, Ns.alwaysValidSchema)(o,r[d]));if(i.length===0)return;let c=e.name("valid");for(let d of i)l(d)?u(d):(e.if((0, Ho.propertyInData)(e,n,d,o.opts.ownProperties)),u(d),o.allErrors||e.else().var(c,true),e.endIf()),t.it.definedProperties.add(d),t.ok(c);function l(d){return o.opts.useDefaults&&!o.compositeRule&&r[d].default!==void 0}function u(d){t.subschema({keyword:"properties",schemaProp:d,dataProp:d},c);}}};ks.default=Gl;});var Xo=a(qs=>{Object.defineProperty(qs,"__esModule",{value:true});var Wo=B(),Bt=S(),Qo=j(),Bo=j(),Jl={keyword:"patternProperties",type:"object",schemaType:"object",code(t){let{gen:e,schema:r,data:s,parentSchema:n,it:o}=t,{opts:a}=o,i=(0, Wo.allSchemaProperties)(r),c=i.filter(f=>(0, Qo.alwaysValidSchema)(o,r[f]));if(i.length===0||c.length===i.length&&(!o.opts.unevaluated||o.props===true))return;let l=a.strictSchema&&!a.allowMatchingProperties&&n.properties,u=e.name("valid");o.props!==true&&!(o.props instanceof Bt.Name)&&(o.props=(0, Bo.evaluatedPropsToName)(e,o.props));let{props:d}=o;y();function y(){for(let f of i)l&&m(f),o.allErrors?h(f):(e.var(u,true),h(f),e.if(u));}function m(f){for(let p in l)new RegExp(f).test(p)&&(0, Qo.checkStrictMode)(o,`property ${p} matches pattern ${f} (use allowMatchingProperties)`);}function h(f){e.forIn("key",s,p=>{e.if((0, Bt._)`${(0, Wo.usePattern)(t,f)}.test(${p})`,()=>{let _=c.includes(f);_||t.subschema({keyword:"patternProperties",schemaProp:f,dataProp:p,dataPropType:Bo.Type.Str},u),o.opts.unevaluated&&d!==true?e.assign((0, Bt._)`${d}[${p}]`,true):!_&&!o.allErrors&&e.if((0, Bt.not)(u),()=>e.break());});});}}};qs.default=Jl;});var Yo=a(js=>{Object.defineProperty(js,"__esModule",{value:true});var Wl=j(),Ql={keyword:"not",schemaType:["object","boolean"],trackErrors:true,code(t){let{gen:e,schema:r,it:s}=t;if((0, Wl.alwaysValidSchema)(s,r)){t.fail();return}let n=e.name("valid");t.subschema({keyword:"not",compositeRule:true,createErrors:false,allErrors:false},n),t.failResult(n,()=>t.reset(),()=>t.error());},error:{message:"must NOT be valid"}};js.default=Ql;});var Zo=a(Os=>{Object.defineProperty(Os,"__esModule",{value:true});var Bl=B(),Xl={keyword:"anyOf",schemaType:"array",trackErrors:true,code:Bl.validateUnion,error:{message:"must match a schema in anyOf"}};Os.default=Xl;});var ea=a(Is=>{Object.defineProperty(Is,"__esModule",{value:true});var Xt=S(),Yl=j(),Zl={message:"must match exactly one schema in oneOf",params:({params:t})=>(0, Xt._)`{passingSchemas: ${t.passing}}`},ed={keyword:"oneOf",schemaType:"array",trackErrors:true,error:Zl,code(t){let{gen:e,schema:r,parentSchema:s,it:n}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(n.opts.discriminator&&s.discriminator)return;let o=r,a=e.let("valid",false),i=e.let("passing",null),c=e.name("_valid");t.setParams({passing:i}),e.block(l),t.result(a,()=>t.reset(),()=>t.error(true));function l(){o.forEach((u,d)=>{let y;(0, Yl.alwaysValidSchema)(n,u)?e.var(c,true):y=t.subschema({keyword:"oneOf",schemaProp:d,compositeRule:true},c),d>0&&e.if((0, Xt._)`${c} && ${a}`).assign(a,false).assign(i,(0, Xt._)`[${i}, ${d}]`).else(),e.if(c,()=>{e.assign(a,true),e.assign(i,d),y&&t.mergeEvaluated(y,Xt.Name);});});}}};Is.default=ed;});var ta=a(Rs=>{Object.defineProperty(Rs,"__esModule",{value:true});var td=j(),rd={keyword:"allOf",schemaType:"array",code(t){let{gen:e,schema:r,it:s}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");let n=e.name("valid");r.forEach((o,a)=>{if((0, td.alwaysValidSchema)(s,o))return;let i=t.subschema({keyword:"allOf",schemaProp:a},n);t.ok(n),t.mergeEvaluated(i);});}};Rs.default=rd;});var na=a(Ts=>{Object.defineProperty(Ts,"__esModule",{value:true});var Yt=S(),sa=j(),sd={message:({params:t})=>(0, Yt.str)`must match "${t.ifClause}" schema`,params:({params:t})=>(0, Yt._)`{failingKeyword: ${t.ifClause}}`},nd={keyword:"if",schemaType:["object","boolean"],trackErrors:true,error:sd,code(t){let{gen:e,parentSchema:r,it:s}=t;r.then===void 0&&r.else===void 0&&(0, sa.checkStrictMode)(s,'"if" without "then" and "else" is ignored');let n=ra(s,"then"),o=ra(s,"else");if(!n&&!o)return;let a=e.let("valid",true),i=e.name("_valid");if(c(),t.reset(),n&&o){let u=e.let("ifClause");t.setParams({ifClause:u}),e.if(i,l("then",u),l("else",u));}else n?e.if(i,l("then")):e.if((0, Yt.not)(i),l("else"));t.pass(a,()=>t.error(true));function c(){let u=t.subschema({keyword:"if",compositeRule:true,createErrors:false,allErrors:false},i);t.mergeEvaluated(u);}function l(u,d){return ()=>{let y=t.subschema({keyword:u},i);e.assign(a,i),t.mergeValidEvaluated(y,a),d?e.assign(d,(0, Yt._)`${u}`):t.setParams({ifClause:u});}}}};function ra(t,e){let r=t.schema[e];return r!==void 0&&!(0, sa.alwaysValidSchema)(t,r)}Ts.default=nd;});var oa=a(Cs=>{Object.defineProperty(Cs,"__esModule",{value:true});var od=j(),ad={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:t,parentSchema:e,it:r}){e.if===void 0&&(0, od.checkStrictMode)(r,`"${t}" without "if" is ignored`);}};Cs.default=ad;});var aa=a(Ms=>{Object.defineProperty(Ms,"__esModule",{value:true});var id=_s(),cd=Ao(),ud=gs(),ld=Vo(),dd=zo(),fd=Fo(),hd=Lo(),pd=Ps(),md=Jo(),yd=Xo(),_d=Yo(),gd=Zo(),$d=ea(),vd=ta(),wd=na(),bd=oa();function Ed(t=false){let e=[_d.default,gd.default,$d.default,vd.default,wd.default,bd.default,hd.default,pd.default,fd.default,md.default,yd.default];return t?e.push(cd.default,ld.default):e.push(id.default,ud.default),e.push(dd.default),e}Ms.default=Ed;});var ia=a(As=>{Object.defineProperty(As,"__esModule",{value:true});var D=S(),Sd={message:({schemaCode:t})=>(0, D.str)`must match format "${t}"`,params:({schemaCode:t})=>(0, D._)`{format: ${t}}`},Pd={keyword:"format",type:["number","string"],schemaType:"string",$data:true,error:Sd,code(t,e){let{gen:r,data:s,$data:n,schema:o,schemaCode:a,it:i}=t,{opts:c,errSchemaPath:l,schemaEnv:u,self:d}=i;if(!c.validateFormats)return;n?y():m();function y(){let h=r.scopeValue("formats",{ref:d.formats,code:c.code.formats}),f=r.const("fDef",(0, D._)`${h}[${a}]`),p=r.let("fType"),_=r.let("format");r.if((0, D._)`typeof ${f} == "object" && !(${f} instanceof RegExp)`,()=>r.assign(p,(0, D._)`${f}.type || "string"`).assign(_,(0, D._)`${f}.validate`),()=>r.assign(p,(0, D._)`"string"`).assign(_,f)),t.fail$data((0, D.or)(q(),N()));function q(){return c.strictSchema===false?D.nil:(0, D._)`${a} && !${_}`}function N(){let C=u.$async?(0, D._)`(${f}.async ? await ${_}(${s}) : ${_}(${s}))`:(0, D._)`${_}(${s})`,w=(0, D._)`(typeof ${_} == "function" ? ${C} : ${_}.test(${s}))`;return (0, D._)`${_} && ${_} !== true && ${p} === ${e} && !${w}`}}function m(){let h=d.formats[o];if(!h){q();return}if(h===true)return;let[f,p,_]=N(h);f===e&&t.pass(C());function q(){if(c.strictSchema===false){d.logger.warn(w());return}throw new Error(w());function w(){return `unknown format "${o}" ignored in schema at path "${l}"`}}function N(w){let se=w instanceof RegExp?(0, D.regexpCode)(w):c.code.formats?(0, D._)`${c.code.formats}${(0, D.getProperty)(o)}`:void 0,ce=r.scopeValue("formats",{key:o,ref:w,code:se});return typeof w=="object"&&!(w instanceof RegExp)?[w.type||"string",w.validate,(0, D._)`${ce}.validate`]:["string",w,ce]}function C(){if(typeof h=="object"&&!(h instanceof RegExp)&&h.async){if(!u.$async)throw new Error("async format in sync schema");return (0, D._)`await ${_}(${s})`}return typeof p=="function"?(0, D._)`${_}(${s})`:(0, D._)`${_}.test(${s})`}}}};As.default=Pd;});var ca=a(Ds=>{Object.defineProperty(Ds,"__esModule",{value:true});var Nd=ia(),kd=[Nd.default];Ds.default=kd;});var ua=a(Fe=>{Object.defineProperty(Fe,"__esModule",{value:true});Fe.contentVocabulary=Fe.metadataVocabulary=void 0;Fe.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];Fe.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"];});var da=a(Vs=>{Object.defineProperty(Vs,"__esModule",{value:true});var qd=go(),jd=Ro(),Od=aa(),Id=ca(),la=ua(),Rd=[qd.default,jd.default,(0, Od.default)(),Id.default,la.metadataVocabulary,la.contentVocabulary];Vs.default=Rd;});var ha=a(Zt=>{Object.defineProperty(Zt,"__esModule",{value:true});Zt.DiscrError=void 0;var fa;(function(t){t.Tag="tag",t.Mapping="mapping";})(fa||(Zt.DiscrError=fa={}));});var ma=a(Us=>{Object.defineProperty(Us,"__esModule",{value:true});var xe=S(),zs=ha(),pa=Mt(),Td=it(),Cd=j(),Md={message:({params:{discrError:t,tagName:e}})=>t===zs.DiscrError.Tag?`tag "${e}" must be string`:`value of tag "${e}" must be in oneOf`,params:({params:{discrError:t,tag:e,tagName:r}})=>(0, xe._)`{error: ${t}, tag: ${r}, tagValue: ${e}}`},Ad={keyword:"discriminator",type:"object",schemaType:"object",error:Md,code(t){let{gen:e,data:r,schema:s,parentSchema:n,it:o}=t,{oneOf:a}=n;if(!o.opts.discriminator)throw new Error("discriminator: requires discriminator option");let i=s.propertyName;if(typeof i!="string")throw new Error("discriminator: requires propertyName");if(s.mapping)throw new Error("discriminator: mapping is not supported");if(!a)throw new Error("discriminator: requires oneOf keyword");let c=e.let("valid",false),l=e.const("tag",(0, xe._)`${r}${(0, xe.getProperty)(i)}`);e.if((0, xe._)`typeof ${l} == "string"`,()=>u(),()=>t.error(false,{discrError:zs.DiscrError.Tag,tag:l,tagName:i})),t.ok(c);function u(){let m=y();e.if(false);for(let h in m)e.elseIf((0, xe._)`${l} === ${h}`),e.assign(c,d(m[h]));e.else(),t.error(false,{discrError:zs.DiscrError.Mapping,tag:l,tagName:i}),e.endIf();}function d(m){let h=e.name("valid"),f=t.subschema({keyword:"oneOf",schemaProp:m},h);return t.mergeEvaluated(f,xe.Name),h}function y(){var m;let h={},f=_(n),p=true;for(let C=0;C<a.length;C++){let w=a[C];if(w?.$ref&&!(0, Cd.schemaHasRulesButRef)(w,o.self.RULES)){let ce=w.$ref;if(w=pa.resolveRef.call(o.self,o.schemaEnv.root,o.baseId,ce),w instanceof pa.SchemaEnv&&(w=w.schema),w===void 0)throw new Td.default(o.opts.uriResolver,o.baseId,ce)}let se=(m=w?.properties)===null||m===void 0?void 0:m[i];if(typeof se!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${i}"`);p=p&&(f||_(w)),q(se,C);}if(!p)throw new Error(`discriminator: "${i}" must be required`);return h;function _({required:C}){return Array.isArray(C)&&C.includes(i)}function q(C,w){if(C.const)N(C.const,w);else if(C.enum)for(let se of C.enum)N(se,w);else throw new Error(`discriminator: "properties/${i}" must have "const" or "enum"`)}function N(C,w){if(typeof C!="string"||C in h)throw new Error(`discriminator: "${i}" values must be unique strings`);h[C]=w;}}}};Us.default=Ad;});var ya=a((oh,Dd)=>{Dd.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 Hd=a((A,Ks)=>{Object.defineProperty(A,"__esModule",{value:true});A.MissingRefError=A.ValidationError=A.CodeGen=A.Name=A.nil=A.stringify=A.str=A._=A.KeywordCxt=A.Ajv=void 0;var Vd=fo(),zd=da(),Ud=ma(),_a=ya(),Kd=["/properties"],er="http://json-schema.org/draft-07/schema",Le=class extends Vd.default{_addVocabularies(){super._addVocabularies(),zd.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(Ud.default);}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let e=this.opts.$data?this.$dataMetaSchema(_a,Kd):_a;this.addMetaSchema(e,er,false),this.refs["http://json-schema.org/schema"]=er;}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(er)?er:void 0)}};A.Ajv=Le;Ks.exports=A=Le;Ks.exports.Ajv=Le;Object.defineProperty(A,"__esModule",{value:true});A.default=Le;var Fd=at();Object.defineProperty(A,"KeywordCxt",{enumerable:true,get:function(){return Fd.KeywordCxt}});var He=S();Object.defineProperty(A,"_",{enumerable:true,get:function(){return He._}});Object.defineProperty(A,"str",{enumerable:true,get:function(){return He.str}});Object.defineProperty(A,"stringify",{enumerable:true,get:function(){return He.stringify}});Object.defineProperty(A,"nil",{enumerable:true,get:function(){return He.nil}});Object.defineProperty(A,"Name",{enumerable:true,get:function(){return He.Name}});Object.defineProperty(A,"CodeGen",{enumerable:true,get:function(){return He.CodeGen}});var xd=Tt();Object.defineProperty(A,"ValidationError",{enumerable:true,get:function(){return xd.default}});var Ld=it();Object.defineProperty(A,"MissingRefError",{enumerable:true,get:function(){return Ld.default}});});
|
|
9
|
+
export{S as a,j as b,de as c,at as d,Tt as e,it as f,Mt as g,fo as h,_o as i,go as j,Ro as k,Fo as l,aa as m,ca as n,ua as o,ma as p,Hd as q};//# sourceMappingURL=chunk-MNEOJWPS.js.map
|
|
10
|
+
//# sourceMappingURL=chunk-MNEOJWPS.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';function p(e){return String(e).replace(/[^a-zA-Z0-9_-]/g,"_")}function m(e){let n=e.payload??{};return {id:e.id,role:typeof n.role=="string"?n.role:"system",text:typeof n.text=="string"?n.text:"",files:Array.isArray(n.files)?n.files:[],turn:typeof n.turn=="string"?n.turn:"",updated_at:typeof n.updated_at=="string"?n.updated_at:""}}function R(e,n){let a=t=>`chats/${p(t)}/processing`,r=t=>`chats/${p(t)}/config`;return {append(t,i,o,u=[],s=""){return e(t).append({role:i,text:o,files:u,turn:s,updated_at:new Date().toISOString()}).id},readAll(t){return e(t).readAll().map(m)},readAfter(t,i){let o=e(t).readAfter(i);return {records:o.entries.map(m),cursor:o.newCursor}},clear(t){e(t).clear?.();},setProcessing(t,i){i?n.write(a(t),true):n.delete(a(t));},isProcessing(t){return n.read(a(t))===true},getConfig(t){return n.read(r(t))??{}},setConfig(t,i){let o=n.read(r(t))??{};n.write(r(t),{...o,...i});}}}function S(){let e=globalThis.crypto;return typeof e?.randomUUID=="function"?String(e.randomUUID()):`id-${Date.now()}-${Math.random().toString(36).slice(2)}`}function $(){let e=new Map,n=new Map;function a(r){return e.has(r)||e.set(r,[]),e.get(r)}return {append(r,t,i,o=[],u=""){let s={id:S(),role:t,text:i,files:o,turn:u,updated_at:new Date().toISOString()};return a(r).push(s),s.id},readAll(r){return a(r).slice()},readAfter(r,t){let i=a(r);if(!t)return {records:i.slice(),cursor:i.length>0?i[i.length-1].id:null};let o=i.findIndex(s=>s.id===t),u=o===-1?i.slice():i.slice(o+1);return {records:u,cursor:u.length>0?u[u.length-1].id:t}},clear(r){e.set(r,[]);},setProcessing(r,t){t?n.set(`p:${r}`,true):n.delete(`p:${r}`);},isProcessing(r){return n.get(`p:${r}`)===true},getConfig(r){return n.get(`c:${r}`)??{}},setConfig(r,t){let i=n.get(`c:${r}`)??{};n.set(`c:${r}`,{...i,...t});}}}function y(){return new Date().toISOString()}function x(e){return new TextEncoder().encode(e).byteLength}function A(e){return e?{key:e.key,size:e.size,updatedAt:e.updatedAt,contentType:e.contentType}:null}function w(e){let n=String(e||"").match(/^(\d+)[-_]/);return n?parseInt(n[1],10):0}function I(e){let n=String(e||"").trim();if(!n)return "upload.bin";let a=Math.max(n.lastIndexOf("/"),n.lastIndexOf("\\"));return (a>=0?n.slice(a+1):n)||"upload.bin"}function k(e){return String(e||"").toLowerCase().replace(/\s+/g,"_").replace(/[^a-z0-9_-]/g,"_").replace(/_+/g,"_").replace(/^_+|_+$/g,"")||"file"}function z(e){if(!e||e===".")return "";let n=String(e).replace(/^\./,"").toLowerCase().replace(/[^a-z0-9]/g,"");return n?`.${n}`:""}function F(e){let n=I(e),a=n.lastIndexOf(".");return a<=0||a===n.length-1?{stem:n,ext:""}:{stem:n.slice(0,a),ext:n.slice(a)}}function M(e){let n=e.lastIndexOf("/");return n>=0?e.slice(n+1):e}function L(e){function n(a){let r=e.stat?A(e.stat(a)):null;if(r)return r;if(!e.exists(a))return null;let t=e.read(a);return t===null?{key:a}:{key:a,size:x(t)}}return {exists(a){return e.exists(a)},putText(a,r,t="text/plain; charset=utf-8"){e.write(a,r);let i=n(a)??{key:a};return i.contentType=t,i.updatedAt=i.updatedAt??y(),i.size=i.size??x(r),i},putBytes(a,r,t="application/octet-stream"){if(e.writeBytes)e.writeBytes(a,r);else {let o=JSON.stringify({__kind:"bytes-array",data:[...r]});e.write(a,o);}let i=n(a)??{key:a};return i.contentType=t,i.updatedAt=i.updatedAt??y(),i.size=i.size??r.byteLength,i},getText(a){let r=e.read(a);if(r===null){if(!e.readBytes)return null;let t=e.readBytes(a);return t===null?null:Buffer.from(t).toString("utf-8")}try{let t=JSON.parse(r);if(t&&t.__kind==="bytes-array"&&Array.isArray(t.data))return new TextDecoder("utf-8").decode(new Uint8Array(t.data))}catch{}return r},getBytes(a){if(e.readBytes){let t=e.readBytes(a);if(t!==null)return t}let r=e.read(a);if(r===null)return null;try{let t=JSON.parse(r);if(t&&t.__kind==="bytes-array"&&Array.isArray(t.data))return new Uint8Array(t.data)}catch{}return new TextEncoder().encode(r)},head:n,list(a=""){return e.listKeys(a).map(r=>n(r)??{key:r}).sort((r,t)=>r.key.localeCompare(t.key))},remove(a){e.remove(a);}}}function b(e){function n(t,i){let o=0,u=[];Array.isArray(i)&&u.push(...i);for(let s of e.list(`${t}/`))u.push(M(s.key));for(let s of u){let l=w(s);Number.isFinite(l)&&l>o&&(o=l);}return o+1}function a(t,i,o){let u=Number(o?.maxLen||32),{stem:s,ext:l}=F(t),h=z(l),C=k(s),d=`${String(i).padStart(3,"0")}-`,g=h,f=u-d.length-g.length;f<1&&(g="",f=u-d.length);let _=C.slice(0,Math.max(1,f)),c=`${d}${_}${g}`;return c.length>u&&(c=c.slice(0,u).replace(/\.$/,"")),c}function r(t,i,o){let u=n(t,o?.seedNames),s=a(i,u,{maxLen:o?.maxLen});for(;e.exists(`${t}/${s}`);)u+=1,s=a(i,u,{maxLen:o?.maxLen});return s}return {nextSerial:n,buildStoredName:a,allocateStoredName:r}}function N(){function e(t,i){if(!Array.isArray(t))return [];let o=[];for(let u of t){if(!u||typeof u!="object")continue;let s=u;typeof s.stored_name=="string"&&o.push({name:typeof s.name=="string"?s.name:s.stored_name,stored_name:s.stored_name,size:typeof s.size=="number"&&Number.isFinite(s.size)?s.size:null,mime_type:typeof s.mime_type=="string"?s.mime_type:null,uploaded_at:typeof s.uploaded_at=="string"?s.uploaded_at:i||null,chat:s.chat===true});}return o}function n(t){return !t||typeof t!="object"?[]:e(t.files,void 0)}function a(t,i){let o=n(t);if(i.length===0)return t.files=o,o;let u=new Set(o.map(s=>s.stored_name));for(let s of i)u.has(s.stored_name)||(o.push(s),u.add(s.stored_name));return t.files=o,o}function r(t,i,o){let u=n(t);if(!Number.isInteger(i)||i<0||i>=u.length)return {ok:false,reason:"index_out_of_range"};let s=u[i];return !s||!s.stored_name?{ok:false,reason:"missing_stored_name"}:o&&o!==s.stored_name?{ok:false,reason:"stale_reference"}:{ok:true,file:s}}return {read:n,normalizeIncoming:e,merge:a,resolve:r}}exports.a=R;exports.b=$;exports.c=L;exports.d=b;exports.e=N;//# sourceMappingURL=chunk-NJJ7WEDT.cjs.map
|
|
2
|
+
//# sourceMappingURL=chunk-NJJ7WEDT.cjs.map
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
'use strict';var chunkUJ7ZTV4J_cjs=require('./chunk-UJ7ZTV4J.cjs'),chunkGNFE24S7_cjs=require('./chunk-GNFE24S7.cjs'),A=require('ajv-formats'),module$1=require('module');var _documentCurrentScript=typeof document!=='undefined'?document.currentScript:null;function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var A__default=/*#__PURE__*/_interopDefault(A);var h={$schema:"http://json-schema.org/draft-07/schema#",$id:"https://nsreehari.github.io/boards/live-cards.schema.json",definitions:{bind_ref:{description:"A card data path reference, e.g. 'card_data.raw_quotes' or 'requires.upstream'",type:"string",pattern:"^(card_data|requires|fetched_sources|computed_values)(\\.|$)"},bind_or_literal:{description:"A literal value or a bind reference object",oneOf:[{type:"string"},{type:"number"},{type:"boolean"},{type:"array"},{type:"object",properties:{bind:{$ref:"#/definitions/bind_ref"}},required:["bind"]}]},compute_expr:{description:"A declarative JSON compute expression",type:"object",required:["fn"],properties:{fn:{type:"string",description:"Function name from the built-in vocabulary",enum:["sum","avg","min","max","count","first","last","add","sub","mul","div","round","abs","mod","gt","gte","lt","lte","eq","neq","if","and","or","not","concat","upper","lower","template","filter","pluck","map","sort","slice","flat","unique","group","get","default","now","diff_days","format_date"]},input:{description:"card_data.path, literal, array of inputs, or nested compute_expr",oneOf:[{type:"string"},{type:"number"},{type:"boolean"},{type:"array"},{$ref:"#/definitions/compute_expr"}]},field:{type:"string",description:"For pluck/sum/group \u2014 the object key to extract"},where:{$ref:"#/definitions/compute_expr",description:"For filter \u2014 predicate expression ($ = current item)"},cond:{$ref:"#/definitions/compute_expr",description:"For if \u2014 condition expression"},then:{description:"For if \u2014 value when cond is truthy"},else:{description:"For if \u2014 value when cond is falsy"},format:{type:"string",description:"For format_date \u2014 date format string"}}},meta:{type:"object",properties:{title:{type:"string"},tags:{type:"array",items:{type:"string"}}}},requires:{type:"array",items:{type:"string"},description:"IDs of upstream nodes this node depends on"},provides:{type:"array",items:{type:"object",required:["bindTo","ref"],properties:{bindTo:{type:"string",description:"Token name published downstream"},ref:{type:"string",description:"Path to read value from (card_data.*, requires.*, fetched_sources.*, computed_values.*)"}}},description:"Explicit bindings exposing computed or card_data values downstream as named tokens"},compute_step:{description:"A single ordered compute step: reads card_data.*/requires.*/computed_values.*, writes to computed_values[bindTo]",type:"object",required:["bindTo","expr"],properties:{bindTo:{type:"string",description:"Key in computed_values to write result"},expr:{type:"string",description:"JSONata expression evaluated against { card_data, requires, fetched_sources, computed_values }"}}},source_def:{description:"One source entry. The engine requires 'bindTo' (compute namespace key) and 'outputFile' (delivery signal path). bindTo and outputFile must be unique across all source_defs in a card. Every other property is yours \u2014 add whatever your task-executor needs: kind, url, headers, mailbox, channel, model, query, etc. The full object is passed verbatim as the --in JSON to the executor.",type:"object",required:["bindTo","outputFile"],additionalProperties:true,properties:{bindTo:{type:"string",description:"Key under fetched_sources.* available in compute expressions"},outputFile:{type:"string",description:"Board-relative path the executor writes its JSON result to. Presence of this file signals delivery."},projections:{type:"object",description:"Named data projections from card_data or requires, evaluated before the executor is called. Each key is a ref name; each value is a JSONata expression rooted at card_data or requires. The resolved values are passed to the executor as _projections. fetched_sources, computed_values, and source_defs are not accessible here \u2014 sources run before those exist.",additionalProperties:{type:"string"}},optionalForCompletionGating:{type:"boolean",default:false,description:"When true this source does not gate card completion. Default false when absent, so source_defs are completion-gating by default."},timeout:{type:"integer",minimum:0,default:12e4,description:"Executor/script timeout in ms. Default: 120 000 (2 min)."},script:{type:"string",description:"Legacy direct-run: shell command executed when no .task-executor is registered. stdout is captured as the result."}}},render_element:{type:"object",required:["kind"],properties:{id:{type:"string",description:"Optional element ID for targeted updates"},kind:{enum:["metric","table","editable-table","chart","form","filter","list","notes","todo","alert","narrative","badge","text","markdown","ref","custom","actions"]},label:{type:"string",description:"Heading above this element"},className:{type:"string",description:"Bootstrap grid class, e.g. 'col-12 col-md-6'"},visible:{type:"string",description:"card_data/requires/fetched_sources/computed_values path \u2014 element shown only if truthy"},data:{type:"object",properties:{bind:{$ref:"#/definitions/bind_ref",description:"card_data/requires/fetched_sources/computed_values path to read data from"},writeTo:{$ref:"#/definitions/bind_ref",description:"card_data path for user input (form, filter, todo, notes)"},columns:{type:"array",items:{type:"string"},description:"table: visible columns"},maxRows:{type:"integer",description:"table/list: max rows to display"},sortable:{type:"boolean",default:true,description:"table: enable click-to-sort"},placeholder:{type:"string",description:"Empty-state message"},chartType:{enum:["bar","line","pie","doughnut"]},chartOptions:{type:"object",description:"Chart.js options passthrough"},fields:{type:"object",description:"JSON Schema for form/filter fields"},thresholds:{type:"object",properties:{green:{type:"string"},amber:{type:"string"}}},colorMap:{type:"object",description:"badge: value \u2192 Bootstrap color"},style:{enum:["heading","muted","default"],description:"text: display style"},upload:{type:"boolean",default:true,description:"file-upload: show drop zone (false = read-only file list)"},accept:{type:"array",items:{type:"string"},description:"file-upload: allowed extensions"},multiple:{type:"boolean",default:true,description:"file-upload: allow multiple files"},fileAttach:{type:"boolean",default:false,description:"chat: enable inline file attachments"},fileAccept:{type:"array",items:{type:"string"},description:"chat: allowed attachment extensions"},buttons:{type:"array",description:"actions: button definitions",items:{type:"object",required:["id","label"],properties:{id:{type:"string"},label:{type:"string"},style:{type:"string",description:"Bootstrap button variant, e.g. 'success', 'outline-danger'"},size:{type:"string",default:"sm"},disabled:{oneOf:[{type:"boolean"},{type:"string",description:"card_data/requires/fetched_sources/computed_values path \u2014 truthy = disabled"}]}}}}}}}},view:{type:"object",required:["elements"],properties:{elements:{type:"array",minItems:1,items:{$ref:"#/definitions/render_element"}},layout:{type:"object",properties:{board:{type:"object",properties:{col:{type:"integer",minimum:1,maximum:12},order:{type:"integer"}}},canvas:{type:"object",properties:{x:{type:"number"},y:{type:"number"},w:{type:"number"},h:{type:"number"}}}}},features:{type:"object",properties:{chat:{type:"boolean",default:false},notes:{type:"boolean",default:false},refresh:{type:"boolean",default:true}}}}}},title:"LiveCard",description:"A unified card node. Behavior depends on which sections are present (source_defs, compute, view, etc.)",type:"object",required:["id"],additionalProperties:false,properties:{id:{type:"string"},requires:{$ref:"#/definitions/requires"},provides:{$ref:"#/definitions/provides"},meta:{$ref:"#/definitions/meta"},view:{$ref:"#/definitions/view"},card_data:{type:"object",description:"Authored card data and runtime metadata. Includes uploaded-file metadata maintained by host handlers and inference evaluation results.",properties:{files:{type:"array",description:"Optional uploaded-file metadata maintained by host handlers. Stored name is normalized and serial-prefixed (for example 001-my_file.pdf).",items:{type:"object",required:["name","stored_name"],properties:{name:{type:"string",minLength:1},stored_name:{type:"string",minLength:5,maxLength:32,pattern:"^[0-9]{3,}-[a-z0-9._-]+$"},size:{oneOf:[{type:"integer",minimum:0},{type:"null"}]},mime_type:{type:"string"},path:{type:"string",pattern:"^[^\\s]+/files/[0-9]{3,}-[a-z0-9._-]+$"},uploaded_at:{type:"string",format:"date-time"},chat:{type:"boolean",description:"Whether this file entry is associated with a chat interaction"}},additionalProperties:false}}},additionalProperties:true},source_defs:{type:"array",description:"Source entries. Each entry is passed verbatim to the board's .task-executor (registered via init --task-executor) as the --in JSON file. The executor fetches/generates the data and writes JSON to --out. If no executor is registered, the built-in executor runs the entry's 'cli' command directly. Sources gate completion by default. Set optionalForCompletionGating: true for enrichment-only source_defs that should not block task-completed.",items:{$ref:"#/definitions/source_def"}},compute:{type:"array",description:"Ordered array of compute steps. Each reads card_data.*/requires.*/fetched_sources.*/computed_values.* and writes to ephemeral computed_values[bindTo].",items:{$ref:"#/definitions/compute_step"}}}};var _=chunkGNFE24S7_cjs.b(chunkUJ7ZTV4J_cjs.q(),1);var $=module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-NMZ6XNLB.cjs', document.baseURI).href))),q=$("./jsonata-sync.cjs"),f=null;var b=/\b(card_data|requires|fetched_sources|computed_values|source_defs)\b/g,N=/^\s*(card_data|requires|fetched_sources|computed_values|source_defs)(\.|$)/;function E(e){let t=new Set,o;for(b.lastIndex=0;(o=b.exec(e))!==null;)t.add(o[1]);return t}function v(e){let t=N.exec(e);return t?t[1]:null}function g(e,t,o,a){try{q(e);}catch(s){let d=s instanceof Error?s.message:String(s);a.push(`${t}: invalid JSONata expression (${d})`);return}let i=E(e);for(let s of i)o.has(s)||a.push(`${t}: disallowed namespace "${s}" in expression`);}function y(e,t,o){if(Array.isArray(e)){e.forEach((i,s)=>{y(i,`${t}/${s}`,o);});return}if(typeof e=="string"){let i=v(e);if(!i)return;new Set(["card_data","requires","computed_values"]).has(i)||o.push(`${t}: disallowed namespace "${i}" in view reference`);return}if(!e||typeof e!="object")return;let a=e;for(let[i,s]of Object.entries(a))y(s,`${t}/${i}`,o);}function S(){if(f)return f;let e=new _.default({allErrors:true});return A__default.default(e),f=e.compile(h),f}function R(e){let t=S(),o=t(e),a=(t.errors??[]).map(i=>`${i.instancePath||"/"}: ${i.message??"unknown error"}`);if(e&&typeof e=="object"&&!Array.isArray(e)){let i=e.source_defs;if(Array.isArray(i)){let s=new Set,d=new Set;i.forEach((c,u)=>{if(!c||typeof c!="object"||Array.isArray(c))return;let r=c;typeof r.bindTo=="string"&&r.bindTo&&(s.has(r.bindTo)&&a.push(`/source_defs/${u}/bindTo: bindTo "${r.bindTo}" must be unique across all source_defs`),s.add(r.bindTo)),typeof r.outputFile=="string"&&r.outputFile&&(d.has(r.outputFile)&&a.push(`/source_defs/${u}/outputFile: outputFile "${r.outputFile}" must be unique across all source_defs`),d.add(r.outputFile));});}}return !o||a.length>0?{ok:false,errors:a}:{ok:true,errors:[]}}function T(e){let t=[];if(!e||typeof e!="object"||Array.isArray(e))return {ok:true,errors:[]};let o=e,a=o.compute;Array.isArray(a)&&a.forEach((r,p)=>{if(!r||typeof r!="object"||Array.isArray(r))return;let n=r.expr;typeof n!="string"||n.trim().length===0||g(n,`/compute/${p}/expr`,new Set(["card_data","requires","fetched_sources","computed_values"]),t);});let i=new Set(["card_data","requires","fetched_sources","computed_values"]),s=o.provides;Array.isArray(s)&&s.forEach((r,p)=>{if(!r||typeof r!="object"||Array.isArray(r))return;let n=r.ref;if(typeof n!="string"||n.trim().length===0)return;let l=v(n);l===null?t.push(`/provides/${p}/ref: path "${n}" must start with a valid namespace (${[...i].join(", ")})`):i.has(l)||t.push(`/provides/${p}/ref: disallowed namespace "${l}" in path "${n}" (valid: ${[...i].join(", ")})`);});let d=o.view;d&&typeof d=="object"&&!Array.isArray(d)&&y(d,"/view",t);let c=new Set(["card_data","requires"]),u=o.source_defs;return Array.isArray(u)&&u.forEach((r,p)=>{if(!r||typeof r!="object"||Array.isArray(r))return;let n=r.projections;if(!(!n||typeof n!="object"||Array.isArray(n)))for(let[l,m]of Object.entries(n))typeof m!="string"||m.trim().length===0||g(m,`/source_defs/${p}/projections/${l}`,c,t);}),{ok:t.length===0,errors:t}}function V(e){return O(e)}function O(e){let t=R(e);if(!t.ok)return t;let o=T(e);return o.ok?{ok:true,errors:[]}:{ok:false,errors:o.errors}}
|
|
2
|
+
exports.a=R;exports.b=T;exports.c=V;exports.d=O;//# sourceMappingURL=chunk-NMZ6XNLB.cjs.map
|
|
3
|
+
//# sourceMappingURL=chunk-NMZ6XNLB.cjs.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {c,n,m,l as l$1,k,j,i as i$1,h as h$1,g as g$1,f,e,d,u}from'./chunk-VGT3TRQG.js';import {i,a,g,h,l}from'./chunk-WDPOGXTY.js';import {a as a$1}from'./chunk-JMDHDY6M.js';import {exec,execFile}from'child_process';function z(s){let{config:e,state:o}=s,a$1=i(e),i$1=Object.keys(a$1),d=0,c=0,l=0,f=0,t=0,r=0;for(let h of i$1){let T=o.tasks[h];if(!T||T.status===a.NOT_STARTED)t++;else switch(T.status){case a.RUNNING:d++;break;case a.COMPLETED:c++;break;case a.FAILED:l++;break;case "inactivated":r++;break;default:f++;}}let n={};for(let[h,T]of Object.entries(a$1)){for(let R of g(T))n[R]||(n[R]=[]),n[R].push(h);if(T.on)for(let R of Object.values(T.on))for(let g of R)n[g]||(n[g]=[]),n[g].includes(h)||n[g].push(h);if(T.on_failure)for(let R of T.on_failure)n[R]||(n[R]=[]),n[R].includes(h)||n[R].push(h);}let u=new Set,p=0,k=0;for(let[h$1,T]of Object.entries(a$1)){let R=o.tasks[h$1];if(R?.status===a.COMPLETED||R?.status===a.RUNNING)continue;let g=false,H=false;for(let x of h(T)){let q=n[x]||[];q.length===0?(u.add(x),g=true):q.every(Y=>{let W=o.tasks[Y];return W?.status===a.FAILED||W?.status==="inactivated"})&&(H=true);}g&&p++,H&&!g&&k++;}let m=[];for(let[h,T]of Object.entries(n))T.length>1&&m.push(h);let v=Q(a$1,n),b=Z(i$1,v);return {totalNodes:i$1.length,running:d,completed:c,failed:l,waiting:f,notStarted:t,disabled:r,unresolvedCount:p,blockedCount:k,openDependencies:[...u],cycles:b,conflictTokens:m}}function Q(s,e){let o={};for(let[a,i]of Object.entries(s)){o[a]=new Set;for(let d of h(i))for(let c of e[d]||[])c!==a&&o[a].add(c);}return o}function Z(s,e){let d={},c={},l=[];for(let t of s)d[t]=0,c[t]=null;function f(t){d[t]=1;for(let r of e[t]||[])if(d[r]===1){let n=[r],u=t;for(;u!==r;)n.push(u),u=c[u];n.push(r),n.reverse(),l.push(n);}else d[r]===0&&(c[r]=t,f(r));d[t]=2;}for(let t of s)d[t]===0&&f(t);return l}function B(s){let e={};for(let[o,a]of Object.entries(s)){for(let i of g(a))e[i]||(e[i]=[]),e[i].push(o);if(a.on)for(let i of Object.values(a.on))for(let d of i)e[d]||(e[d]=[]),e[d].includes(o)||e[d].push(o);if(a.on_failure)for(let i of a.on_failure)e[i]||(e[i]=[]),e[i].includes(o)||e[i].push(o);}return e}function V(s){let{config:e,state:o}=s,a=i(e),i$1=B(a),d=new Set([...o.availableOutputs]);for(let[n,u]of Object.entries(o.tasks))if(u.status==="completed"){let p=a[n];p&&g(p).forEach(k=>d.add(k));}let c=new Set;for(let n of Object.values(a))for(let u of h(n))c.add(u);let l$1=new Set,f=new Set;for(let n of c){if(d.has(n))continue;(i$1[n]||[]).length===0&&l$1.add(n);}let t=true;for(;t;){t=false;for(let[n,u]of Object.entries(a)){if(f.has(n))continue;let p=o.tasks[n];if(p?.status==="completed")continue;let k=l(p),v=h(u).some(b=>l$1.has(b));(k||v)&&(f.has(n)||(f.add(n),t=true));}for(let n of c){if(l$1.has(n)||d.has(n))continue;let u=i$1[n]||[],p=u.length>0&&u.every(k=>f.has(k)||l(o.tasks[k]));(u.length===0||p)&&(l$1.has(n)||(l$1.add(n),t=true));}}let r=[];for(let n of l$1){let u=i$1[n]||[],p;u.length===0?p="no-producer":p=u.every(m=>l(o.tasks[m]))?"all-producers-failed":"transitive",r.push({token:n,reason:p,producers:u});}return {tokens:r}}function ee(s){let{config:e,state:o}=s,a=i(e),{tokens:i$1}=V(s),d=new Set(i$1.map(l=>l.token)),c=[];for(let[l$1,f]of Object.entries(a)){let t=o.tasks[l$1];if(t?.status==="completed")continue;let n=h(f).filter(u=>d.has(u));n.length>0?c.push({nodeName:l$1,missingTokens:n}):l(t)&&c.push({nodeName:l$1,missingTokens:[]});}return {nodes:c}}function te(s,e){let o=i(s.config);if(!o[e])return {nodeName:e,nodes:[],tokens:[]};let a=B(o),i$1=new Set,d=new Set,c=new Map;function l(t){let r=o[t];if(r)for(let n of h(r)){let u=a[n]||[];for(let p of u)p!==e&&(d.add(n),c.has(p)||c.set(p,new Set),c.get(p).add(n),i$1.has(p)||(i$1.add(p),l(p)));}}l(e);let f=[...c.entries()].map(([t,r])=>({nodeName:t,providesTokens:[...r]}));return {nodeName:e,nodes:f,tokens:[...d]}}function ne(s,e){let o=i(s.config);if(!o[e])return {nodeName:e,nodes:[],tokens:[]};let a={};for(let[t,r]of Object.entries(o))for(let n of h(r))a[n]||(a[n]=[]),a[n].push(t);let i$1=new Set,d=new Set,c=new Map;function l(t){let r=o[t];if(r)for(let n of g(r)){let u=a[n]||[];for(let p of u)p!==e&&(d.add(n),c.has(p)||c.set(p,new Set),c.get(p).add(n),i$1.has(p)||(i$1.add(p),l(p)));}}l(e);let f=[...c.entries()].map(([t,r])=>({nodeName:t,requiresTokens:[...r]}));return {nodeName:e,nodes:f,tokens:[...d]}}function K(s){let e=[],{config:o,state:a$1}=s,i$1=i(o),d=Object.keys(i$1);for(let t of d)a$1.tasks[t]||e.push({severity:"error",code:"MISSING_STATE",message:`Task "${t}" exists in config but has no state entry`,tasks:[t]});for(let t of Object.keys(a$1.tasks))i$1[t]||e.push({severity:"warning",code:"ORPHAN_STATE",message:`State entry "${t}" has no corresponding task config`,tasks:[t]});for(let t of d){let r=a$1.tasks[t];r&&(r.status===a.RUNNING&&!r.startedAt&&e.push({severity:"warning",code:"RUNNING_WITHOUT_START",message:`Task "${t}" is running but has no startedAt timestamp`,tasks:[t]}),r.status===a.COMPLETED&&!r.completedAt&&e.push({severity:"warning",code:"COMPLETED_WITHOUT_TIMESTAMP",message:`Task "${t}" is completed but has no completedAt timestamp`,tasks:[t]}),r.status===a.FAILED&&(r.failedAt||e.push({severity:"warning",code:"FAILED_WITHOUT_INFO",message:`Task "${t}" is failed but has no failedAt timestamp`,tasks:[t]}),r.error||e.push({severity:"info",code:"FAILED_WITHOUT_INFO",message:`Task "${t}" is failed but has no error message`,tasks:[t]})));}let c=new Set;for(let t of d)if(a$1.tasks[t]?.status===a.COMPLETED)for(let n of g(i$1[t]))c.add(n);let l=new Set(a$1.availableOutputs),f=new Set;for(let t of Object.values(i$1)){for(let r of g(t))f.add(r);if(t.on)for(let r of Object.values(t.on))for(let n of r)f.add(n);if(t.on_failure)for(let r of t.on_failure)f.add(r);}for(let t of l)!c.has(t)&&!f.has(t)&&e.push({severity:"info",code:"INJECTED_TOKEN",message:`Token "${t}" is available but no task in the graph can produce it (likely injected)`,tokens:[t]});for(let t of c)l.has(t)||e.push({severity:"warning",code:"MISSING_OUTPUT",message:`Token "${t}" should be available (its producer completed) but is not in availableOutputs`,tokens:[t]});for(let t of d){let r=a$1.tasks[t];if(!r)continue;r.executionCount<0&&e.push({severity:"error",code:"INVALID_EXECUTION_COUNT",message:`Task "${t}" has negative execution count: ${r.executionCount}`,tasks:[t]});let n=i$1[t].maxExecutions;n!==void 0&&r.executionCount>n&&e.push({severity:"error",code:"EXCEEDED_MAX_EXECUTIONS",message:`Task "${t}" executed ${r.executionCount} times, exceeding maxExecutions of ${n}`,tasks:[t]});}return J(e)}function se(s){let{graph:e,handlers:o}=s,a=e.getState(),i$1=[],d=i(a.config),c=Object.keys(d),l=new Set(Object.keys(o)),f=new Set;for(let r of c){let n=d[r].taskHandlers;if(n)for(let u of n)f.add(u);}for(let r of c){let n=d[r].taskHandlers;if(n)for(let u of n)o[u]||i$1.push({severity:"error",code:"MISSING_HANDLER",message:`Task "${r}" references handler "${u}" but it is not in the registry`,tasks:[r]});}for(let r of l)f.has(r)||i$1.push({severity:"warning",code:"ORPHAN_HANDLER",message:`Handler "${r}" is registered but not referenced by any task's taskHandlers`,tasks:[r]});let t=K(a);return i$1.push(...t.issues),J(i$1)}function J(s){let e=s.filter(a=>a.severity==="error"),o=s.filter(a=>a.severity==="warning");return {valid:e.length===0,issues:s,errors:e,warnings:o}}function re(s,e){let o=s;for(let a of e)o=oe(o,a);return o}function oe(s,e$1){switch(e$1.type){case "add-node":return d(s,e$1.name,e$1.config);case "remove-node":return e(s,e$1.name);case "add-requires":return f(s,e$1.taskName,e$1.tokens);case "remove-requires":return g$1(s,e$1.taskName,e$1.tokens);case "add-provides":return h$1(s,e$1.taskName,e$1.tokens);case "remove-provides":return i$1(s,e$1.taskName,e$1.tokens);case "inject-tokens":return j(s,e$1.tokens);case "drain-tokens":return k(s,e$1.tokens);case "reset-node":return l$1(s,e$1.name);case "disable-node":return m(s,e$1.name);case "enable-node":return n(s,e$1.name);case "apply-events":return c(s,e$1.events);default:throw new Error(`Unknown mutation type: ${e$1.type}`)}}function ce(s,e){return async o=>{let{callbackToken:a}=o;return Promise.resolve(s(o)).then(i=>e()(a,i)).catch(i=>e()(a,{},[i instanceof Error?i.message:String(i)])),"task-initiated"}}function de(s,e){return async o=>{let{callbackToken:a}=o;return Promise.resolve(s(o)).then(()=>e()(a,{})).catch(()=>e()(a,{})),"task-initiated"}}function ue(s){let{command:e,cwd:o,env:a,timeoutMs:i=3e4,exitCodeMap:d,captureOutput:c=false,getResolve:l}=s;return async f=>{let{callbackToken:t,nodeId:r}=f,n=e.replace(/\$\{taskName\}/g,r);return exec(n,{cwd:o,env:a?{...process.env,...a}:void 0,timeout:i,maxBuffer:10*1024*1024},(u,p,k)=>{let m=u?.code??(u?1:0);if(m!==0&&!d?.[m]){l()(t,{},[`Command exited with code ${m}: ${k||u?.message}`]);return}let v={};c&&(v.stdout=p,v.stderr=k,v.exitCode=m),l()(t,v);}),"task-initiated"}}function X(s){let{command:e,args:o=[],cwd:a,env:i,timeoutMs:d=3e4,exitCodeMap:c,captureOutput:l=false,getResolve:f}=s;return async t=>{let{callbackToken:r,nodeId:n}=t,u=e.replace(/\$\{taskName\}/g,n),p=o.map(k=>k.replace(/\$\{taskName\}/g,n));return execFile(u,p,{cwd:a,env:i?{...process.env,...i}:void 0,timeout:d,maxBuffer:10*1024*1024,encoding:"utf8",windowsHide:true},(k,m,v)=>{let b=k?.code??(k?1:0);if(b!==0&&!c?.[b]){f()(r,{},[`Process exited with code ${b}: ${v||k?.message}`]);return}let h={};l&&(h.stdout=m,h.stderr=v,h.exitCode=b),f()(r,h);}),"task-initiated"}}function le(s){return s.endsWith(".js")||s.endsWith(".mjs")||s.endsWith(".ts")?"node":s.endsWith(".py")?"python3":(s.endsWith(".sh"),"bash")}function pe(s){let{scriptPath:e,runtime:o,args:a=[],cwd:i,timeoutMs:d=6e4,captureOutput:c=false,getResolve:l}=s,f=o??le(e),t=f==="node"?process.execPath:f;return X({command:t,args:[e,"${taskName}",...a],cwd:i,timeoutMs:d,captureOutput:c,getResolve:l})}function fe(s){let{url:e,method:o="POST",headers:a={},timeoutMs:i=3e4,failOnNon2xx:d=true,getResolve:c}=s;return async l=>{let{callbackToken:f,nodeId:t,config:r}=l,n=e.replace(/\$\{taskName\}/g,t),u=JSON.stringify({taskName:t,callbackToken:f,config:r}),p=new AbortController,k=setTimeout(()=>p.abort(),i);return fetch(n,{method:o,headers:{"Content-Type":"application/json",...a},body:u,signal:p.signal}).then(async m=>{if(clearTimeout(k),d&&!m.ok){let b=await m.text().catch(()=>"");c()(f,{},[`HTTP ${m.status}: ${b}`]);return}let v=await m.json().catch(()=>({}));c()(f,v);}).catch(m=>{clearTimeout(k),c()(f,{},[m instanceof Error?m.message:String(m)]);}),"task-initiated"}}function ge(s,e){return async o=>(s()(o.callbackToken,e??{}),"task-initiated")}function ke(s,e={}){let o,a={},i;if(!Array.isArray(s)&&"nodes"in s){let g=s;o=g.nodes,i=g.id,a=g.settings??{};}else o=s;let{sourceHandlers:d={},defaultSourceHandler:c,cardHandlers:l={},reactiveOptions:f={},graphSettings:t={},executionId:r}=e,n=new Map;for(let g of o){if(n.has(g.id))throw new Error(`Duplicate card ID: "${g.id}"`);n.set(g.id,g);}let u$1=e.sharedState??new Map,p={},k=new Set,m=new Map;for(let g of o)for(let H of g.provides??[{bindTo:g.id,ref:"card_data"}])k.add(H.bindTo),m.set(H.bindTo,g.id);for(let g of o){let H=g.requires??[];for(let x of H)if(!k.has(x))throw new Error(`Card "${g.id}" requires "${x}" but no card provides that token`);p[g.id]={requires:H.length>0?H:void 0,provides:(g.provides??[{bindTo:g.id,ref:"card_data"}]).map(x=>x.bindTo),taskHandlers:[g.id],description:g.meta?.title??g.id};}let v={id:i??`live-cards-${Date.now()}`,settings:{completion:"manual",execution_mode:"eligibility-mode",...a,...t},tasks:p},b={},h=null,T=()=>(g,H,x)=>{h.resolveCallback(g,H,x);};for(let g of o)g.source_defs&&g.source_defs.length>0?b[g.id]=me(g,d,c,u$1,T):b[g.id]=he(g,l,u$1,n,m,T);let R=u(v,{...f,handlers:b},r);return h=R,{graph:R,config:v,handlers:b,cards:n,sharedState:u$1}}function me(s,e,o,a,i){if(e[s.id]){let d=e[s.id];return async c=>d(c)}if(o){let d=o(s);return async c=>d(c)}return async d=>{let c={...s.card_data};return a.set(s.id,c),i()(d.callbackToken,c),"task-initiated"}}function he(s,e,o,a,i,d){if(e[s.id]){let c=e[s.id];return async l=>c(l)}return async c=>{let l={},f=s.requires??[];for(let u of f){let p=i.get(u)??u,k=o.get(p);k&&(l[u]=k[u]??k);}let t={id:s.id,card_data:{...s.card_data},requires:l,compute:s.compute};await a$1.run(t);let r;if(s.provides&&s.provides.length>0){r={};for(let{bindTo:u,ref:p}of s.provides)r[u]=a$1.resolve(t,p);}else r={...t.card_data,...t.computed_values};let n={...t.card_data,...t.computed_values};return o.set(s.id,n),d()(c.callbackToken,r),"task-initiated"}}export{z as a,V as b,ee as c,te as d,ne as e,K as f,se as g,re as h,ce as i,de as j,ue as k,X as l,pe as m,fe as n,ge as o,ke as p};//# sourceMappingURL=chunk-OPNGCSXJ.js.map
|
|
2
|
+
//# sourceMappingURL=chunk-OPNGCSXJ.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
'use strict';var chunkNJJ7WEDT_cjs=require('./chunk-NJJ7WEDT.cjs'),chunkLVNQCE5X_cjs=require('./chunk-LVNQCE5X.cjs'),chunkUVE65IPR_cjs=require('./chunk-UVE65IPR.cjs'),chunkKNFFDVLD_cjs=require('./chunk-KNFFDVLD.cjs'),chunkYMEIPKLW_cjs=require('./chunk-YMEIPKLW.cjs'),chunkGYQXDNNI_cjs=require('./chunk-GYQXDNNI.cjs');var be={"Access-Control-Allow-Origin":"*","Access-Control-Allow-Headers":"content-type,x-file-name","Access-Control-Allow-Methods":"GET,POST,PATCH,OPTIONS"},Ye=32;function tr(){return {status:null,computedValues:{},dataObjects:{},cards:{}}}function we(m){if(!m||typeof m!="object")return false;let y=m.summary;return !y||typeof y!="object"?false:Number(y.card_count||0)>0}function Ce(m,y){if(!y||typeof y!="object")return;let w=y;if(w.kind==="notification-batch"&&Array.isArray(w.notifications)){for(let _ of w.notifications)Ce(m,_);return}w.kind==="status"&&we(w.status)&&(m.status=w.status),w.kind==="computed_values"&&w.cardId&&(m.computedValues[w.cardId]=w.values),w.kind==="data_object"&&w.key&&(m.dataObjects[w.key]=w.payload),w.kind==="card_refreshed"&&w.cardId&&(m.cards[w.cardId]=w.card),w.kind==="card_removed"&&w.cardId&&(delete m.cards[w.cardId],delete m.computedValues[w.cardId]);}function lr(m){let y=String(m.apiBasePath||"/api/board").replace(/\/$/,""),w={...be,...m.corsHeaders||{}},_=m.boardId||"",j=m.logger||{info:console.log,warn:console.warn,error:console.error},z=m.invocationAdapter,st=m.chatFlowRunner||null,B=m.chatStorage??chunkNJJ7WEDT_cjs.b(),at=chunkGYQXDNNI_cjs.a(B),it=m.notificationTransport||null,Y=m.serverUrl||null,J=m.executionExtra||{},Ct=m.onSseClientConnected,Rt=m.onSseClientDisconnected,kt=m.onChannelSubscribed,St=m.onChannelUnsubscribed,p=new Map,k=new Map,I=new Map,$=null;function M(t){let e=chunkLVNQCE5X_cjs.e(t.baseRef,t.boardAdapter),r=t.nonCoreAdapter??(K(t.boardAdapter)?t.boardAdapter:null),n=r?chunkLVNQCE5X_cjs.f(t.baseRef,r):null,o=t.boardAdapter.kvStorageForRef(t.cardStoreRef),a=chunkYMEIPKLW_cjs.a(chunkLVNQCE5X_cjs.a({readIndex:()=>o.read("_index"),writeIndex:b=>o.write("_index",b),readCard:b=>o.read(b),writeCard:(b,O)=>(o.write(b,O),b),removeCard:b=>{o.delete(b);},cardExists:b=>o.read(b)!==null,defaultCardKey:b=>b},j.warn)),i=t.artifactsAdapter||t.boardAdapter,u=t.filesArtifactsStore??null,C=t.artifactsAdapter?i.blobStorage(""):i.blobStorage("files"),h=null;return {label:t.label,board:e,nonCore:n,cardStore:a,get filesArtifacts(){return h??=u??chunkNJJ7WEDT_cjs.c(C)},boardAdapter:t.boardAdapter,cardStoreRef:t.cardStoreRef,outputsStoreRef:t.outputsStoreRef,artifactsStoreRef:t.artifactsStoreRef,scratchStoreRef:t.scratchStoreRef,archiveStoreRef:t.archiveStoreRef,notifyRef:t.notifyRef,taskExecutorRef:t.taskExecutorRef,chatHandlerRef:t.chatHandlerRef,chatHandlerFlow:t.chatHandlerFlow,inferenceAdapterRef:t.inferenceAdapterRef,notification:tr(),notificationTeardown:null,initialized:false,cardsBootstrapped:false}}let S=m.boards.map(M),G=new Map;function N(t){return G.get(t)??0}function K(t){let e=t;return typeof e.invokeExecutor=="function"&&typeof e.validateSchema=="function"}function tt(t){let e=S[N(t)];return {files:e?e.filesArtifacts:null}}function At(t){let e=tt(t);return e.files?chunkNJJ7WEDT_cjs.d(e.files):null}function D(){return chunkNJJ7WEDT_cjs.e()}function L(t){return String(t||"").replace(/[^a-zA-Z0-9_-]/g,"_")||"unknown-card"}async function ct(t){if(!t||t.notificationTeardown||!it||!t.notifyRef)return;let e=await it.subscribe(t.notifyRef,r=>{Ce(t.notification,r);let n=r.kind==="notification-batch"?r.notifications:[r];oe(n);});t.notificationTeardown=e;}async function Re(t){if(!t||t.initialized)return;let e={cardStoreRef:t.cardStoreRef,outputsStoreRef:t.outputsStoreRef};t.artifactsStoreRef&&(e.artifactsStoreRef=t.artifactsStoreRef),t.scratchStoreRef&&(e.scratchStoreRef=t.scratchStoreRef),t.archiveStoreRef&&(e.archiveStoreRef=t.archiveStoreRef);let r={};t.taskExecutorRef&&(r["task-executor-ref"]=t.taskExecutorRef),t.chatHandlerFlow!==void 0&&(r["chat-handler-flow"]=t.chatHandlerFlow),t.inferenceAdapterRef&&(r["inference-adapter-ref"]=t.inferenceAdapterRef);let n=t.board.init({params:e,body:r});if(n.status!=="success")throw Object.assign(new Error(n.error||`init failed for ${t.label}`),{statusCode:500});if(await ct(t),!t.chatHandlerFlow&&t.chatHandlerRef&&z.describe)try{let o=await z.describe(t.chatHandlerRef);o&&o.kind!=="chat-handler"?j.warn(`[init] chat-handler describe returned kind="${o.kind}", expected "chat-handler" for ${t.label}`):o&&j.info(`[init] chat-handler validated: ${o.name} (protocol ${o.protocolVersion}) for ${t.label}`);}catch(o){j.warn(`[init] chat-handler describe failed for ${t.label}: ${o?.message||String(o)}`);}t.initialized=true;}function Ft(t){if(!t.boardAdapter.publishBoardChangeNotifications)return;let e=[],r=t.board.status({});r.status==="success"&&r.data!=null&&we(r.data)&&e.push({kind:"status",status:r.data});let n=t.board.getAllOutputsDataObjects({});if(n.status==="success"&&n.data!=null)for(let[s,a]of Object.entries(n.data))s&&e.push({kind:"data_object",key:s,payload:a});let o=t.board.getAllOutputsComputedValues({});if(o.status==="success"&&o.data!=null)for(let[s,a]of Object.entries(o.data))s&&e.push({kind:"computed_values",cardId:s,values:a});e.length>0&&t.boardAdapter.publishBoardChangeNotifications(e);}function Mt(t,e){if(!t||t.cardsBootstrapped)return;let r=t.cardStore.get({}),n=r.status==="success"&&Array.isArray(r.data?.cards)?r.data.cards:[];for(let o of n)typeof o.id=="string"&&(G.set(o.id,e),t.board.upsertCard({params:{cardId:o.id}}));t.cardsBootstrapped=true;}async function ft(){for(let t of S)await Re(t);}async function E(){await ft();for(let t=0;t<S.length;t++)Ft(S[t]),Mt(S[t],t);}function T(t){return S[N(t)]??null}function rt(t){let e=T(t);if(!e)return null;let r=e.cardStore.get({params:{id:t}});if(r.status!=="success")return null;let n=Array.isArray(r.data?.cards)?r.data.cards:[];return n.length>0?n[0]:null}function Nt(){let t=r=>{if(!r||!r.cardStore)return [];let n=r.cardStore.get({});return n.status!=="success"||!Array.isArray(n.data?.cards)?[]:n.data.cards},e=[];for(let r of S)e.push(...t(r));return e}function H(){return S[0]??null}function ke(){return {status(){let t=Ht();return t==null?{status:"fail",error:"Board status is unavailable"}:{status:"success",data:t}},getOutputsDataObject(t){let e=t?.params?.key;return e?{status:"success",data:zt()[e]}:{status:"fail",error:"getOutputsDataObject requires params.key"}},getOutputsComputedValues(t){let e=t?.params?.key;return e?{status:"success",data:Vt()[e]?.computed_values}:{status:"fail",error:"getOutputsComputedValues requires params.key"}},getOutputsFetchedSources(t){let e=t?.params?.key;if(!e)return {status:"fail",error:"getOutputsFetchedSources requires params.key"};let r=T(e)??H();return r?r.board.getOutputsFetchedSources({params:{key:e}}):{status:"fail",error:"Board context is unavailable"}},removeCard(t){let e=t?.params?.id;if(!e)return {status:"fail",error:"removeCard requires params.id"};let r=T(e)??H();return r?r.board.removeCard({params:{id:e}}):{status:"fail",error:"Board context is unavailable"}},cardRefreshedNotify(t){let e=t?.params?.cardId;if(!e)return {status:"fail",error:"cardRefreshedNotify requires params.cardId"};let r=T(e)??H();return r?r.board.cardRefreshedNotify({params:{cardId:e}}):{status:"fail",error:"Board context is unavailable"}},upsertCard(t){let e=t?.params?.cardId;if(!e)return {status:"fail",error:"upsertCard requires params.cardId"};let r=T(e)??H();return r?r.board.upsertCard({params:{cardId:e,restart:t.params.restart===true}}):{status:"fail",error:"Board context is unavailable"}}}}function Se(){let t=()=>{let e=H();if(!e?.nonCore)throw new Error("Board non-core adapter is not configured for MCP preflight/discovery tools");return e.nonCore};return {describeTaskExecutorCapabilities(e){return t().describeTaskExecutorCapabilities(e)},validateCardPreflight(e){return t().validateCardPreflight(e)},evalCardCompute(e){return t().evalCardCompute(e)},probeSourcePreflight(e){return t().probeSourcePreflight(e)},runSourcePreflight(e){return t().runSourcePreflight(e)},simulateCardCycle(e){return t().simulateCardCycle(e)}}}function gt(){return {get(t){let e=typeof t.params?.id=="string"?t.params.id:void 0;if(e){let r=rt(e);return r?{status:"success",data:{cards:[r]}}:{status:"success",data:{cards:[]}}}return {status:"success",data:{cards:Nt()}}},set(t){let e=t.body;if(e==null)return {status:"fail",error:"set requires a body (card object or array of cards)"};let r=Array.isArray(e)?e:[e];for(let n of r){let o=n,s=typeof o.id=="string"?o.id:"";if(!s)return {status:"fail",error:"each card must have a string `id` field"};let a=G.get(s)??0,i=S[a]??H();if(!i)return {status:"fail",error:"Board context is unavailable"};let u=i.cardStore.set({body:o});if(u.status!=="success")return u;G.set(s,a);}return {status:"success",data:{count:r.length}}},del(t){let e=[t.params?.id,...t.body?.ids??[]].filter(r=>typeof r=="string"&&!!r);if(e.length===0)return {status:"fail",error:"del requires body.ids (string[]) or params.id"};for(let r of e){let n=T(r)??H();if(!n)return {status:"fail",error:"Board context is unavailable"};let o=n.cardStore.del({params:{id:r}});if(o.status!=="success")return o;G.delete(r);}return {status:"success",data:{count:e.length}}},patch(t){let e=typeof t.params?.id=="string"?t.params.id:void 0,r=typeof t.params?.path=="string"?t.params.path:void 0;if(!e||!r)return {status:"fail",error:"patch requires params.id and params.path"};let n=T(e)??H();return n?n.cardStore.patch(t):{status:"fail",error:"Board context is unavailable"}},appendFiles(t){let e=typeof t.params?.id=="string"?t.params.id:void 0;if(!e)return {status:"fail",error:"appendFiles requires params.id"};let r=T(e)??H();return r?r.cardStore.appendFiles(t):{status:"fail",error:"Board context is unavailable"}}}}function V(){return chunkKNFFDVLD_cjs.a({board:ke(),nonCore:Se(),cardStore:gt(),chatStore:at,uploadCardFile({cardId:t,fileName:e,contentType:r,bytes:n}){return xt(t,e,r,n,{inChat:false})},buildFileDownloadUrl({cardId:t,fileIdx:e,storedName:r}){let n=`${Y||""}${y}/cards/${encodeURIComponent(t)}/files/${e}`;return r?`${n}?sn=${encodeURIComponent(r)}`:n},readFetchedSourceJsonByRef({cardId:t,ref:e}){let r=T(t)??H();if(!r)return null;let o=r.boardAdapter.resolveBlob(chunkUVE65IPR_cjs.b(e)).trim();return o?JSON.parse(o):null}})}function A(t,...e){for(let r of e)if(typeof t[r]=="string")return String(t[r]);return ""}function W(t,...e){for(let r of e)if(t[r]!==void 0)return Number(t[r])}function dt(t,...e){for(let r of e){let n=t[r];if(n&&typeof n=="object"&&!Array.isArray(n))return n}return {}}function Z(t,e,...r){for(let n of r){let o=t[n];if(o&&typeof o=="object"&&!Array.isArray(o))return o}throw Object.assign(new Error(`MCP tool requires ${e}`),{statusCode:400})}function vt(t,e,...r){for(let n of r){let o=t[n];if(o!==void 0){let s=Number(o);if(Number.isFinite(s))return s}}throw Object.assign(new Error(`MCP tool requires ${e}`),{statusCode:400})}function Ae(t){if(Array.isArray(t.bytes))return new Uint8Array(t.bytes.map(e=>Math.max(0,Math.min(255,Number(e)||0))));if(typeof t.text=="string")return new TextEncoder().encode(t.text);if(typeof t.base64=="string"){let e=String(t.base64).replace(/-/g,"+").replace(/_/g,"/"),r=e+"=".repeat((4-e.length%4)%4),n=atob(r);return Uint8Array.from(n,o=>o.charCodeAt(0))}return null}function Ut(t,e){let r=A(t,"board_id"),n=A(t,"card_id");if(!r)throw Object.assign(new Error("MCP tool requires board_id"),{statusCode:400});if(!n)throw Object.assign(new Error("MCP tool requires card_id"),{statusCode:400});if(r!==_)throw Object.assign(new Error(`Unknown board_id: ${r}`),{statusCode:400});return V().setChatProcessing({cardId:n,active:e}),{status:"success",data:{boardId:_,cardId:n,active:e}}}function pt(t){let e=A(t,"board_id"),r=A(t,"card_id");if(!e)throw Object.assign(new Error("MCP tool requires board_id"),{statusCode:400});if(!r)throw Object.assign(new Error("MCP tool requires card_id"),{statusCode:400});if(e!==_)throw Object.assign(new Error(`Unknown board_id: ${e}`),{statusCode:400});return {cardId:r}}function _t(t,e){if(t?.status==="success")return Object.prototype.hasOwnProperty.call(t,"data")?t.data:void 0;throw t?.status==="fail"||t?.status==="error"?Object.assign(new Error(t.error||`${e} failed`),{statusCode:400}):Object.assign(new Error(`${e} returned an unexpected response`),{statusCode:500})}function qt(t){let e=A(t,"key");if(!e)throw Object.assign(new Error("MCP tool requires key"),{statusCode:400});let r=e.split(".");if(!(r.length>=2&&r[0]==="chat"&&r.every(o=>/^[A-Za-z_][A-Za-z0-9_]*$/.test(o))))throw Object.assign(new Error("MCP tool only supports card meta keys under chat.*"),{statusCode:400});return e}function Dt(t,e){let r=t.meta;for(let n of e.split(".")){if(!r||typeof r!="object"||Array.isArray(r)||!Object.prototype.hasOwnProperty.call(r,n))return {exists:false,value:null};r=r[n];}return {exists:true,value:r}}function ve(t){let{cardId:e}=pt(t),r=V().getChatProcessing({cardId:e});return {status:"success",data:{boardId:_,cardId:e,active:r.active}}}function _e(t){let{cardId:e}=pt(t),r=qt(t);if(!Object.prototype.hasOwnProperty.call(t,"value"))throw Object.assign(new Error("MCP tool requires value"),{statusCode:400});if(r.split(".").includes("__visible_controlplane_only")){let n=_t(gt().get({params:{id:e}}),"cardStore.get"),o=Array.isArray(n.cards)&&n.cards.length>0&&typeof n.cards[0]=="object"&&!Array.isArray(n.cards[0])?n.cards[0]:null,s=o?Dt(o,"__visible_controlplane_only").value:void 0;if(t.value!==s)throw Object.assign(new Error("MCP tool cannot change the reserved meta flag __visible_controlplane_only"),{statusCode:403});return {status:"success",data:{boardId:_,cardId:e,key:r}}}return _t(gt().patch({params:{id:e,path:`meta.${r}`},body:{value:t.value}}),"cardStore.patch"),{status:"success",data:{boardId:_,cardId:e,key:r}}}function Be(t){let{cardId:e}=pt(t),r=qt(t),n=_t(gt().get({params:{id:e}}),"cardStore.get"),o=Array.isArray(n.cards)&&n.cards.length>0&&n.cards[0]&&typeof n.cards[0]=="object"&&!Array.isArray(n.cards[0])?n.cards[0]:null;if(!o)throw Object.assign(new Error(`Card "${e}" not found`),{statusCode:404});let s=Dt(o,r);return {status:"success",data:{boardId:_,cardId:e,key:r,exists:s.exists,value:s.value}}}function Ie(t){return {"discover.source-kinds":()=>t.discoverSourceKinds(),"inspect.board-runtime-status":()=>t.inspectBoardRuntimeStatus(),"inspect.card-definition-and-runtime":e=>t.inspectCardDefinitionAndRuntime({cardId:A(e,"card_id")}),"inspect.chat-messages-on-cards":e=>{let r=W(e,"tail_turns"),n=W(e,"tail"),o=A(e,"turn_id"),s=e.all_turns===true,a=A(e,"tail_turns_before_id");return t.inspectChatMessagesOnCards({cardId:A(e,"card_id"),...r!==void 0?{lastUserTurns:r}:{},...n!==void 0?{tail:n}:{},...o?{turnId:o}:{},...s?{allTurns:true}:{},...a?{tailTurnsBeforeId:a}:{}})},"inspect.file-contents":e=>t.inspectFileContents({cardId:A(e,"card_id"),fileIdx:Number(W(e,"file_idx"))}),"preflight.validate-candidate-card-definition":e=>t.preflightValidateCandidateCardDefinition({candidateCardContent:Z(e,"candidate_card_content","candidate_card_content")}),"preflight.materialize-candidate-card":e=>t.preflightMaterializeCandidateCard({candidateCardContent:Z(e,"candidate_card_content","candidate_card_content"),mockRequires:Z(e,"mock_requires","mock_requires"),mockFetchedSources:Z(e,"mock_fetched_sources","mock_fetched_sources")}),"preflight.probe-single-source-in-candidate-card":e=>t.preflightProbeSingleSourceInCandidateCard({candidateCardContent:Z(e,"candidate_card_content","candidate_card_content"),mockProjections:dt(e,"mock_projections"),sourceIdx:vt(e,"source_idx","source_idx")}),"preflight.run-single-source-in-candidate-card":e=>t.preflightRunSingleSourceInCandidateCard({candidateCardContent:Z(e,"candidate_card_content","candidate_card_content"),mockProjections:dt(e,"mock_projections"),sourceIdx:vt(e,"source_idx","source_idx")}),"preflight.run-single-source-in-live-card":e=>t.preflightRunSingleSourceInLiveCard({cardId:A(e,"card_id"),sourceIdx:vt(e,"source_idx","source_idx"),mockRequires:Z(e,"mock_requires","mock_requires")}),"preflight.run-one-cycle-with-candidate-card":e=>t.preflightRunOneCycleWithCandidateCard({candidateCardContent:Z(e,"candidate_card_content","candidate_card_content"),mockRequires:dt(e,"mock_requires")}),"manage.read-card":e=>t.manageReadCard({cardId:A(e,"card_id")}),"stage-ai-response-and-any-attachments":e=>{let r=A(e,"turn_id");if(!r)throw Object.assign(new Error("stage-ai-response-and-any-attachments requires a non-empty turn_id"),{statusCode:400});return t.manageAddChatEntryAndAnyAttachments({cardId:A(e,"card_id"),role:"assistant",...typeof e.text=="string"?{text:e.text}:{},...r?{turn:r}:{},...Array.isArray(e.files)?{files:e.files}:{}})},"manage.upsert-card":e=>t.manageUpsertCard({cardId:A(e,"card_id"),candidateCardContent:dt(e,"candidate_card_content")}),"manage.remove-card":e=>t.manageRemoveCard({cardId:A(e,"card_id")})}}function xe(){return {"getstate.is-chat-processing":t=>ve(t),"setstate.chat-processing-started":t=>Ut(t,true),"setstate.chat-processing-done":t=>Ut(t,false),"getstate.card-meta":t=>Be(t),"setstate.card-meta":t=>_e(t),"manage.upload-card-file":t=>{let e=A(t,"board_id"),r=A(t,"card_id"),n=A(t,"file_name"),o=A(t,"content_type")||"application/octet-stream",s=Ae(t);if(!e)throw Object.assign(new Error("manage.upload-card-file requires board_id"),{statusCode:400});if(e!==_)throw Object.assign(new Error(`Unknown board_id: ${e}`),{statusCode:400});if(!r)throw Object.assign(new Error("manage.upload-card-file requires card_id"),{statusCode:400});if(!n)throw Object.assign(new Error("manage.upload-card-file requires file_name"),{statusCode:400});if(!s)throw Object.assign(new Error("manage.upload-card-file requires args.bytes, args.text, or args.base64"),{statusCode:400});return xt(r,n,o,s,{inChat:false})},"manage.admin-read-card":t=>{let{cardId:e}=pt(t);return {status:"success",data:{cards:V().adminReadCard({cardId:e})}}},"manage.admin-upsert-card":t=>{let e=A(t,"board_id"),r=A(t,"card_id");if(!e)throw Object.assign(new Error("manage.admin-upsert-card requires board_id"),{statusCode:400});if(!r)throw Object.assign(new Error("manage.admin-upsert-card requires card_id"),{statusCode:400});if(e!==_)throw Object.assign(new Error(`Unknown board_id: ${e}`),{statusCode:400});return V().adminUpsertCard({cardId:r,candidateCardContent:dt(t,"candidate_card_content")})}}}async function Lt(t,e,r){let n=r[t];if(!n)throw Object.assign(new Error(`Unknown MCP tool: ${t}`),{statusCode:400});let o=await n(e);if(o&&typeof o=="object"&&!Array.isArray(o)){let s=o,a=s.status;if(a==="success")return Object.prototype.hasOwnProperty.call(s,"data")?o:{status:"success",data:{}};if(a==="fail"||a==="error")return o}return {status:"success",data:o}}function mt(t,e){if(!t||typeof t!="object"||Array.isArray(t))return e;let r=t;if(typeof r.error=="string"&&r.error.trim())return r.error;if(r.step==="validate"){let n=r.validation;if(n&&typeof n=="object"&&!Array.isArray(n)){let s=n.data;if(s&&typeof s=="object"&&!Array.isArray(s)){let a=s.issues;if(Array.isArray(a)){let u=a.find(C=>typeof C=="string"&&C.trim());if(typeof u=="string")return `Validation failed: ${u}`}let i=s.errors;if(Array.isArray(i)&&i.length>0)return "Validation failed"}}return "Validation failed"}return e}function Ht(){let t=S.map(s=>{try{let i=s.boardAdapter.kvStorageForRef(s.outputsStoreRef).read("status");if(i!=null)return i}catch{}return s.notification.status}).filter(Boolean);if(t.length===0)return null;if(t.length===1)return t[0];let e=[],r=["completed","eligible","pending","blocked","unresolved","failed","in_progress","orphan_cards"],n={};for(let s of r)n[s]=0;for(let s of t){let a=s,i=Array.isArray(a.cards)?a.cards:[];e.push(...i);for(let u of r)n[u]+=Number(a?.summary?.[u]||0);}let o=t[0];return {...o,cards:e,summary:{...o.summary||{},card_count:e.length,...n}}}function Vt(){let t={},e=r=>{for(let[n,o]of Object.entries(r.notification.computedValues)){let s=r.notification.cards[n];t[n]={schema_version:"v1",card_id:n,card_data:s?.card_data??{},computed_values:o??{}};}};for(let r of S)e(r);return t}function zt(){let t={};for(let e of S)Object.assign(t,e.notification.dataObjects||{});return t}function yt(){let t=Nt(),e=Vt(),r=zt(),n={};for(let s of t){if(!s?.id)continue;let a=s.id,i=e[a]||{},u={...i.card_data&&typeof i.card_data=="object"?i.card_data:s.card_data&&typeof s.card_data=="object"?s.card_data:{}};n[a]={schema_version:i.schema_version||"v1",card_id:i.card_id||a,card_data:u,computed_values:i.computed_values&&typeof i.computed_values=="object"?i.computed_values:{}};}let o={};for(let s of t){if(!s?.id)continue;let a=s.id;try{let i=It(a),u=V().getChatProcessing({cardId:a}).active;(i.length>0||u)&&(o[a]={messages:i.map(C=>({role:String(C.role||"system"),text:String(C.text||""),files:Array.isArray(C.files)?C.files:[]})),receiving:!1,processing:u});}catch{}}return {boardId:_,cardDefinitions:t,statusSnapshot:Ht(),dataObjectsByToken:r,cardRuntimeById:n,cardChatsByCardId:o}}function Bt(t,e,r){let n=r?.syncBoard!==false,o=r?.restartOnlyIfChanged===true,s=T(t);if(!s)throw Object.assign(new Error(`Card not found: ${t}`),{statusCode:404});let a=rt(t);if(!a)throw Object.assign(new Error(`Card not found: ${t}`),{statusCode:404});let i=o?JSON.stringify(a):null,u=e(a)||a;if(o&&JSON.stringify(u)===i)return;let C=s.cardStore.set({body:u});if(C.status!=="success")throw Object.assign(new Error(C.error||`Failed to persist card: ${t}`),{statusCode:500});if(n){let h=s.board.upsertCard({params:{cardId:t,restart:true}});if(h.status!=="success")throw Object.assign(new Error(h.error||`Failed to upsert card: ${t}`),{statusCode:500})}}function je(t,e){Bt(t,e,{syncBoard:true});}function Jt(t,e){Bt(t,e,{syncBoard:false});}function Oe(t){let e=T(t);if(!e)throw Object.assign(new Error(`Card not found: ${t}`),{statusCode:404});if(!rt(t))throw Object.assign(new Error(`Card not found: ${t}`),{statusCode:404});let n=e.board.upsertCard({params:{cardId:t,restart:true}});if(n.status!=="success")throw Object.assign(new Error(n.error||`Failed to retrigger card: ${t}`),{statusCode:500})}function $e(t,e){Bt(t,r=>{if(!e||typeof e!="object"||Object.keys(e).length===0)return r;function n(o,s,a){let i=String(s||"").split(".").filter(Boolean);if(!i.length)return;let u=o;for(let C=0;C<i.length-1;C++){let h=i[C];(!u[h]||typeof u[h]!="object")&&(u[h]={}),u=u[h];}u[i[i.length-1]]=a;}if(e.fieldValues!==void 0&&e.fieldValues!==null){let o=null,s=r.view;if(s&&Array.isArray(s.elements)){for(let a of s.elements)if(a?.data&&a.data.writeTo){o=a.data.writeTo;break}}o?n(r,o,e.fieldValues):typeof e.fieldValues=="object"&&!Array.isArray(e.fieldValues)&&(r.card_data={...r.card_data||{},...e.fieldValues});}else {if(Array.isArray(e._stagedFiles)&&e._stagedFiles.length>0)return r;for(let[o,s]of Object.entries(e))o!=="_stagedFiles"&&(s!==null&&typeof s=="object"&&!Array.isArray(s)&&r[o]!==null&&typeof r[o]=="object"&&!Array.isArray(r[o])?r[o]={...r[o],...s}:r[o]=s);}return r},{syncBoard:true,restartOnlyIfChanged:true});}function Ee(t){let e=String(t||"").trim();if(!e)return "upload.bin";let r=Math.max(e.lastIndexOf("/"),e.lastIndexOf("\\"));return (r>=0?e.slice(r+1):e)||"upload.bin"}function Pe(t){B.clear(t);try{V().setChatProcessing({cardId:t,active:!1});}catch{}}function Te(t,e,r,n,o=""){let s=typeof r=="string"?r.trim():"";return B.append(t,e,s,n,o)}function It(t){return B.readAll(t)}function Fe(t){let e=[];try{let r=rt(t);if(!r)return e;let n=D().read(r.card_data&&typeof r.card_data=="object"?r.card_data:null);for(let o of n)e.push(o.stored_name);}catch{}return e}function Me(t,e,r,n){let o=L(t),s=tt(t),a=Ee(e),i=At(t),u=i?i.allocateStoredName(o,a,{seedNames:Fe(t),maxLen:Ye}):`${String(Date.now())}-${a}`;return s.files&&s.files.putBytes(`${o}/${u}`,new Uint8Array(n),r||"application/octet-stream"),{name:a,stored_name:u,size:n.length,mime_type:r||"application/octet-stream",uploaded_at:new Date().toISOString()}}function xt(t,e,r,n,o){if(!n.length)throw Object.assign(new Error("Empty upload body"),{statusCode:400});let s=o?.inChat===true,a=Me(t,e,r,n),i=null;if(Jt(t,u=>{let C=new Date().toISOString(),h=u.card_data&&typeof u.card_data=="object"?u.card_data:{};u.card_data=h;let b=D().normalizeIncoming([{name:a.name,stored_name:a.stored_name,size:a.size,mime_type:a.mime_type,uploaded_at:a.uploaded_at||C,chat:s}],C);return i=D().merge(h,b).findIndex(nt=>nt.stored_name===a.stored_name),u}),s){let u=typeof i=="number"&&i>=0?` #${i}`:"";Te(t,"system",`file uploaded: ${a.name} as ${a.stored_name}${u}`,[],o?.turnId??"");}return {ok:true,file:a}}function Gt(t){let e=T(t);if(!e)return null;let r=e.board.getConfig({params:{key:"chat-handler-flow"}}),n=r.status==="success"?r.data?.value:null,o=e.chatHandlerRef;return n==null&&(!o||typeof o!="object")?null:{ctx:e,handlerFlow:n,handlerRef:o}}function Ne(t,e,r=false,n=""){let o=Gt(t);if(!o)return;let{ctx:s,handlerFlow:a,handlerRef:i}=o;if(!r)try{V().setChatProcessing({cardId:t,active:!0});}catch{}let u={boardId:_,cardId:String(t),lastChatEntryId:e,...n?{turnId:n}:{},...J,...Y?{serverUrl:Y}:{}};if(!st&&a!=null){try{V().setChatProcessing({cardId:t,active:!1});}catch{}j.warn(`[chat-handler-flow] configured for card "${t}" but no chatFlowRunner was provided`);return}if(a!=null){let h=st;if(!h)return;h.run(a,u,{boardId:_,cardId:String(t),label:s.label,logger:j,serverUrl:Y,executionExtra:J}).then(b=>{if(b.dispatched)j.info(`[chat-handler-flow] invoked for card "${t}" (boardId: "${_}")`);else {try{B.setProcessing(t,!1);}catch{}j.warn(`[chat-handler-flow] dispatch failed for card "${t}": ${b.error||"unknown"}`);}},b=>{try{B.setProcessing(t,!1);}catch{}j.warn(`[chat-handler-flow] invoke failed for card "${t}": ${b?.message||String(b)}`);});return}let C=i;C&&z.invoke(C,u).then(h=>{if(h.dispatched)j.info(`[chat-handler] invoked for card "${t}" (boardId: "${_}")`);else {try{B.setProcessing(t,!1);}catch{}j.warn(`[chat-handler] dispatch failed for card "${t}": ${h.error||"unknown"}`);}},h=>{try{B.setProcessing(t,!1);}catch{}j.warn(`[chat-handler] invoke failed for card "${t}": ${h?.message||String(h)}`);});}function Ue(t,e,r){let n=e==="chat-send"?Jt:je,o;n(t,s=>{let a=new Date().toISOString(),i=s.card_data&&typeof s.card_data=="object"?s.card_data:{};if(s.card_data=i,e==="chat-send"){let u=r&&typeof r.text=="string"?r.text.trim():"",C=r&&typeof r["turn-id"]=="string"?r["turn-id"]:r&&typeof r.turnId=="string"?r.turnId:r&&typeof r.turn=="string"?r.turn:"",h=[];if(Array.isArray(r?.files)){for(let b of r.files)if(b){if(typeof b=="string"){h.push({name:b});continue}if(typeof b=="object"){let O=b;typeof O.name=="string"&&h.push({name:O.name,size:O.size,mime_type:O.mime_type,uploaded_at:O.uploaded_at,stored_name:O.stored_name,chat:O.chat===true});}}}if(u||h.length>0){let b=at.runBatch({cardId:t,commands:[{command:"append",role:"user",text:u,files:h,turn:C},{command:"set-processing",active:true}]});if(b.status!=="success")throw new Error(b.error);let O=b.data.results[0]?.data?.id;if(typeof O!="string"||!O)throw new Error(`chat-send did not return an append id for card ${t}`);o={cardId:t,lastEntryId:O,processingAlreadySet:true,turnId:C};try{let bt=It(t);oe([{kind:"card_chats",cardId:t,messages:bt.map(X=>({role:String(X.role||"system"),text:String(X.text||""),files:Array.isArray(X.files)?X.files:[]})),receiving:!0,processing:B.isProcessing(t)}]);}catch{}}return s}if(e==="file-upload"){let u=D().normalizeIncoming(r?.files,a);return u.length>0&&D().merge(i,u),s}if(e==="action"){let u=r&&typeof r.buttonId=="string"?r.buttonId:"";if(!u)return s;i.lastAction={buttonId:u,at:a},i.lastActionText=`${u} @ ${a}`;}return s}),o&&Ne(o.cardId,o.lastEntryId,o.processingAlreadySet,o.turnId??"");}function f(t,e,r){let n=JSON.stringify(r),o=typeof Buffer<"u"?Buffer.byteLength(n):new TextEncoder().encode(n).length;t.writeHead(e,{...w,"Content-Type":"application/json; charset=utf-8","Content-Length":o}),t.end(n);}function Kt(t,e,r){let n=rt(t);if(!n)throw Object.assign(new Error("Card not found"),{statusCode:404});let o=D().resolve(n.card_data,e,r);if(!o.ok&&o.reason==="stale_reference")throw Object.assign(new Error("File reference is stale. Refresh and try again."),{statusCode:409});if(!o.ok)throw Object.assign(new Error("File not found"),{statusCode:404});let s=o.file,a=L(t),i=tt(t),u=String(s.stored_name||""),C=`${a}/${u}`,h=i.files?i.files.getBytes(C):null;if(!h)throw Object.assign(new Error("File not found"),{statusCode:404});return {fileRecord:s,bytes:h}}function qe(t,e,r,n){let{fileRecord:o,bytes:s}=Kt(e,r,n),a=String(o.name||o.stored_name||"download.bin"),i=String(o.mime_type||"application/octet-stream");t.writeHead(200,{"Content-Type":i,"Content-Disposition":`attachment; filename="${a}"`,"Content-Length":s.length}),t.end(s);}function De(t){let e=String(t||"").toLowerCase();return e.startsWith("text/")||e.includes("json")||e.includes("xml")||e.includes("javascript")||e.includes("typescript")||e.includes("yaml")||e.includes("csv")}function Wt(t,e,r){let n=t.split(/\r?\n/);return (e==="head"?n.slice(0,r):n.slice(-r)).join(`
|
|
2
|
+
`)}async function U(t){let e=[];for await(let n of t)e.push(n);let r=typeof Buffer<"u"?Buffer.concat(e).toString("utf-8").trim():new TextDecoder().decode(Zt(e)).trim();return r?JSON.parse(r):{}}async function Le(t){let e=[];for await(let r of t)e.push(r);return typeof Buffer<"u"?Buffer.concat(e):Zt(e)}function Zt(t){let e=t.reduce((o,s)=>o+s.length,0),r=new Uint8Array(e),n=0;for(let o of t)r.set(o,n),n+=o.length;return r}function Xt(t,e){let r=typeof e.ref=="string"?e.ref.trim():"";if(!r)return {status:"fail",error:"board-worker success callback requires body.ref"};let n=S[0];return n?n.board.sourceDataFetched({params:{token:t,ref:r}}):{status:"fail",error:"no board context"}}function Qt(t,e){let r=typeof e.reason=="string"&&e.reason.trim()?e.reason:"unknown",n=S[0];return n?n.board.sourceDataFetchFailure({params:{token:t,reason:r}}):{status:"fail",error:"no board context"}}function He(t,e,r){let n=String(t||"").trim();if(!n)return {statusCode:400,body:{error:"callback token is required"}};let o=e==="success"?Xt(n,r):Qt(n,r);return o.status==="success"?{statusCode:200,body:o}:o.status==="fail"?{statusCode:400,body:{error:o.error}}:{statusCode:500,body:{error:o.error}}}let Yt=0;function te(t){let e=JSON.stringify(t);return Yt++,`id: ${Yt}
|
|
3
|
+
data: ${e}
|
|
4
|
+
|
|
5
|
+
`}function ee(t){let e=t;try{e.flushHeaders?.();}catch{}try{e.flush?.();}catch{}try{e.socket?.setNoDelay?.(!0);}catch{}try{e.socket?.uncork?.();}catch{}}function jt(t,e){let r=p.get(t);if(r&&!(e&&r.res!==e)){p.delete(t),Et();try{Rt?.(t);}catch{}try{r.res.end();}catch{}}}function ht(t,e){let r=p.get(t);if(!r)return;let n=te(e);try{r.res.write(n),ee(r.res);}catch{jt(t,r.res);}}function re(t,e,r,n,o){if(!p.has(e)){f(t,404,{error:`SSE client not connected: ${e}`});return}o?kt?.(e,r,n):St?.(e,r,n),f(t,200,{ok:true,clientId:e,channelName:r,...n.cardId?{cardId:n.cardId}:{},subscribed:o});}function Ot(){let t=new Set;for(let e of p.values())for(let r of e.subscribedChatCardIds)t.add(r);return Array.from(t)}function Ve(t){let e=k.has(t)?k.get(t):null,{cursor:r}=B.readAfter(t,e),n=B.isProcessing(t),o=n!==(I.get(t)??false),s=r!==e;return s&&k.set(t,r),I.set(t,n),s||o}function ne(t,e=true){let r=It(t),n=Date.now();return {kind:"card_chats",cardId:t,sentAt:new Date(n).toISOString(),sentAtMs:n,messages:r.map(o=>({role:String(o.role||"system"),text:String(o.text||""),files:Array.isArray(o.files)?o.files:[]})),receiving:e,processing:B.isProcessing(t)}}function $t(t,e=true){let r={kind:"notification-batch",notifications:[ne(t,e)]};for(let[n,o]of p.entries())o.subscribedChatCardIds.has(t)&&ht(n,r);}function Et(){Ot().length>0||($&&(clearInterval($),$=null),k.clear(),I.clear());}function ze(){if($)return;let t=()=>{let e=Ot();if(e.length===0){Et();return}let r=new Set(e);for(let n of Array.from(k.keys()))r.has(n)||k.delete(n);for(let n of Array.from(I.keys()))r.has(n)||I.delete(n);for(let n of e)Ve(n)&&$t(n,true);};t(),$=setInterval(t,1e3);}function Je(t,e){let r=p.get(t);if(!r)return false;r.subscribedChatCardIds.add(e);let{cursor:n}=B.readAfter(e,null);return k.set(e,n),I.set(e,B.isProcessing(e)),ze(),ht(t,{kind:"notification-batch",notifications:[ne(e,true)]}),true}function Ge(t,e){let r=p.get(t);return r?(r.subscribedChatCardIds.delete(e),Ot().includes(e)||(k.delete(e),I.delete(e)),Et(),true):false}function Ke(t){if(!t||typeof t!="object")return false;let e=t.kind;return e==="card_chats"||e==="chat_messages"}function oe(t){if(!t||t.length===0)return;let e=[],r=new Set;for(let n of t)Ke(n)&&typeof n.cardId=="string"?r.add(String(n.cardId)):e.push(n);if(e.length>0){let n={kind:"notification-batch",notifications:e};for(let o of p.keys())ht(o,n);}for(let n of r)$t(n,true);}function We(t,e,r){let n=p.get(r),o=n?new Set(n.subscribedChatCardIds):new Set;n&&jt(r,n.res),e.writeHead(200,{...w,"Content-Type":"text/event-stream","Cache-Control":"no-cache",Connection:"keep-alive"}),ee(e),p.set(r,{res:e,subscribedChatCardIds:o});let s=yt(),a=te(s);e.write(a);try{Ct?.(r,u=>{ht(r,u);});}catch{}let i=setInterval(()=>{try{e.write(`: keepalive
|
|
6
|
+
|
|
7
|
+
`);}catch{}},15e3);t.on("close",()=>{clearInterval(i),jt(r,e);});}async function Ze(t,e,r){let n=t.method||"GET",o=r,s=o.pathname;try{if(n==="GET"&&s===`${y}/init-board`)return await ft(),f(e,200,yt()),!0;if(n==="GET"&&s===`${y}/sse`){await ft();let d=String(o.searchParams.get("clientId")||"").trim();if(!d)return f(e,400,{error:"clientId query param is required for SSE"}),!0;We(t,e,d);for(let c=0;c<S.length;c++)Ft(S[c]),Mt(S[c],c);return !0}if(n==="GET"&&s===`${y}/board-status`)return f(e,200,yt()),!0;let a=s.match(new RegExp(`^${F(y)}/callback/board-worker/([^/]+)/(success|failure)$`));if(n==="POST"&&a){await ft();let d=decodeURIComponent(a[1]),c=a[2],g=await U(t),l=He(d,c,g);return f(e,l.statusCode,l.body),!0}if(n==="POST"&&s===`${y}/mcp`){await E();let d=await U(t),c=typeof d.tool=="string"?d.tool.trim():"",g=d.args&&typeof d.args=="object"&&!Array.isArray(d.args)?d.args:{};if(!c)return f(e,400,{error:"tool is required"}),!0;if(c==="inspect.file-contents")return f(e,400,{error:"inspect.file-contents is only available on /mcp-raw"}),!0;try{let l=await Lt(c,g,Ie(V()));if(l&&typeof l=="object"&&!Array.isArray(l)){let R=l;if(R.status==="fail")return f(e,400,{error:mt(l,"Request failed")}),!0;if(R.status==="error")return f(e,500,{error:mt(l,"Internal error")}),!0}f(e,200,l);}catch(l){let R=typeof l?.statusCode=="number"?Number(l.statusCode):500,x=l instanceof Error?l.message:String(l);f(e,R,{error:x});}return !0}if(n==="POST"&&s===`${y}/mcp-controlplane`){await E();let d=await U(t),c=typeof d.tool=="string"?d.tool.trim():"",g=d.args&&typeof d.args=="object"&&!Array.isArray(d.args)?d.args:{};if(!c)return f(e,400,{error:"tool is required"}),!0;try{let l=await Lt(c,g,xe());if(l&&typeof l=="object"&&!Array.isArray(l)){let R=l;if(R.status==="fail")return f(e,400,{error:mt(l,"Request failed")}),!0;if(R.status==="error")return f(e,500,{error:mt(l,"Internal error")}),!0}f(e,200,l);}catch(l){let R=typeof l?.statusCode=="number"?Number(l.statusCode):500,x=l instanceof Error?l.message:String(l);f(e,R,{error:x});}return !0}if(n==="POST"&&s===`${y}/mcp-raw`){await E();let d=await U(t),c=typeof d.tool=="string"?d.tool.trim():"",g=d.args&&typeof d.args=="object"&&!Array.isArray(d.args)?d.args:{};if(!c)return f(e,400,{error:"tool is required"}),!0;if(c!=="inspect.file-contents")return f(e,400,{error:`Tool does not support raw response: ${c}`}),!0;let l=A(g,"card_id","cardId"),R=W(g,"file_idx","fileIdx"),x=W(g,"head-lines","headLines"),v=W(g,"tail-lines","tailLines"),P=W(g,"head-bytes","headBytes"),et=W(g,"tail-bytes","tailBytes");if(!l)return f(e,400,{error:"inspect.file-contents requires card_id"}),!0;if(R===void 0||!Number.isInteger(R)||R<0)return f(e,400,{error:"inspect.file-contents requires file_idx to be a non-negative integer"}),!0;if([x,v,P,et].filter(q=>q!==void 0).length>1)return f(e,400,{error:"inspect.file-contents accepts at most one of head-lines, tail-lines, head-bytes, tail-bytes"}),!0;for(let[q,ot]of [["head-lines",x],["tail-lines",v],["head-bytes",P],["tail-bytes",et]])if(ot!==void 0&&(!Number.isInteger(ot)||ot<0))return f(e,400,{error:`inspect.file-contents requires ${q} to be a non-negative integer`}),!0;let se=V().inspectFileContents({cardId:l,fileIdx:R}),Xe=typeof se?.stored_name=="string"?se.stored_name:null,{fileRecord:Pt,bytes:lt}=Kt(l,R,Xe),ae=String(Pt.name||Pt.stored_name||"download.bin"),Tt=String(Pt.mime_type||"application/octet-stream"),wt=(o.searchParams.get("resp")||"").trim().toLowerCase();if(wt&&wt!=="json-b64")return f(e,400,{error:`unsupported resp mode: ${wt}`}),!0;let Qe=wt==="json-b64",Q;if(x!==void 0||v!==void 0){if(!De(Tt))return f(e,400,{error:"head-lines/tail-lines are only supported for text-like files; use head-bytes/tail-bytes for binary content"}),!0;let q=new TextDecoder().decode(lt),ot=x!==void 0?Wt(q,"head",x):Wt(q,"tail",v);Q=typeof Buffer<"u"?Buffer.from(ot,"utf8"):new TextEncoder().encode(ot);}else if(P!==void 0||et!==void 0){let q=P??et;Q=P!==void 0?lt.slice(0,q):lt.slice(Math.max(0,lt.length-q));}else Q=lt;if(Qe){let q=typeof Buffer<"u"?Buffer.from(Q).toString("base64"):btoa(String.fromCharCode(...Q));return f(e,200,{bodyBase64:q,mimeType:Tt,filename:ae,byteLength:Q.length}),!0}return e.writeHead(200,{"Content-Type":Tt,"Content-Disposition":`attachment; filename="${ae}"`,"Content-Length":Q.length}),e.end(Q),!0}let i=s.match(new RegExp(`^${F(y)}/cards/([^/]+)$`));if(n==="GET"&&i){await E();let d=decodeURIComponent(i[1]),c=rt(d);return c?(f(e,200,c),!0):(f(e,404,{error:`card not found: ${d}`}),!0)}if(n==="PATCH"&&i){await E();let d=decodeURIComponent(i[1]),c=await U(t);return $e(d,c),f(e,200,{ok:!0}),!0}let u=s.match(new RegExp(`^${F(y)}/cards/([^/]+)/retrigger$`));if(n==="POST"&&u){await E();let d=decodeURIComponent(u[1]);return Oe(d),f(e,200,{ok:!0}),!0}let C=s.match(new RegExp(`^${F(y)}/cards/([^/]+)/actions$`));if(n==="POST"&&C){await E();let d=decodeURIComponent(C[1]),c=Date.now(),g=new Date(c).toISOString(),l=await U(t),R=l?.actionType;if(R==="chat-send"&&!Gt(d)){let v=Date.now();return f(e,409,{error:`chat handler is not configured for card: ${d}`,requestReceivedAt:g,requestReceivedAtMs:c,responseSentAt:new Date(v).toISOString(),responseSentAtMs:v,responseStatus:409}),!0}if(R==="chat-send"){let v=l?.payload??{},P=typeof v["turn-id"]=="string"?v["turn-id"]:typeof v.turnId=="string"?v.turnId:typeof v.turn=="string"?v.turn:"";if(!P||!String(P).trim()){let et=Date.now();return f(e,400,{error:`chat-send requires a non-empty 'turn-id' (or 'turnId'/'turn') in payload for card: ${d}`,requestReceivedAt:g,requestReceivedAtMs:c,responseSentAt:new Date(et).toISOString(),responseSentAtMs:et,responseStatus:400}),!0}}Ue(d,R,l?.payload);let x=Date.now();return f(e,200,{ok:!0,requestReceivedAt:g,requestReceivedAtMs:c,responseSentAt:new Date(x).toISOString(),responseSentAtMs:x,responseStatus:200}),!0}let h=s.match(new RegExp(`^${F(y)}/cards/([^/]+)/chats$`));if(n==="GET"&&h){await E();let d=decodeURIComponent(h[1]),c=String(o.searchParams.get("turn-id")||""),g=String(o.searchParams.get("all-turns")||"").toLowerCase()==="true",l=String(o.searchParams.get("tail-turns-before-id")||""),R=o.searchParams.get("tail-turns"),x=R==null||R===""?g||c?void 0:1:Number.parseInt(R,10),v=at.readAll({params:{cardId:d},body:{...x===void 0?{}:{tailTurns:x},...c?{turnId:c}:{},...g?{allTurns:!0}:{},...l?{tailTurnsBeforeId:l}:{}}});if(v.status!=="success")return f(e,400,{error:v.error||"Failed to read chats"}),!0;let P=v.data.records;return f(e,200,{ok:!0,messages:P}),!0}if(n==="POST"&&h){await E();let d=decodeURIComponent(h[1]),c=await U(t),g=typeof c?.role=="string"?c.role:"assistant",l=typeof c?.text=="string"?c.text:"",R=Array.isArray(c?.files)?c.files:[],x=typeof c?.turn=="string"?c.turn:typeof c?.["turn-id"]=="string"?c["turn-id"]:typeof c?.turnId=="string"?c.turnId:"",v=c?.done===!0,P=B.append(d,g,l,R,x);return v&&B.setProcessing(d,!1),$t(d,!v),f(e,200,{ok:!0,id:P}),!0}let b=s.match(new RegExp(`^${F(y)}/cards/([^/]+)/chats/subscribe-sse$`));if(n==="POST"&&b){await E();let d=decodeURIComponent(b[1]),c=await U(t),g=typeof c?.clientId=="string"?c.clientId.trim():"";return g?Je(g,d)?(f(e,200,{ok:!0,clientId:g,cardId:d,subscribed:!0}),!0):(f(e,404,{error:`SSE client not connected: ${g}`}),!0):(f(e,400,{error:"clientId is required"}),!0)}let O=s.match(new RegExp(`^${F(y)}/cards/([^/]+)/chats/unsubscribe-sse$`));if(n==="POST"&&O){await E();let d=decodeURIComponent(O[1]),c=await U(t),g=typeof c?.clientId=="string"?c.clientId.trim():"";return g?Ge(g,d)?(f(e,200,{ok:!0,clientId:g,cardId:d,subscribed:!1}),!0):(f(e,404,{error:`SSE client not connected: ${g}`}),!0):(f(e,400,{error:"clientId is required"}),!0)}let nt=s.match(new RegExp(`^${F(y)}/watch-channel/([^/]+)/(subscribe|unsubscribe)-sse$`));if(n==="POST"&&nt){await E();let d=decodeURIComponent(nt[1]),c=nt[2]==="subscribe",g=await U(t),l=typeof g?.clientId=="string"?g.clientId.trim():"";return l?(re(e,l,d,{},c),!0):(f(e,400,{error:"clientId is required"}),!0)}let ut=s.match(new RegExp(`^${F(y)}/cards/([^/]+)/watch-channel/([^/]+)/(subscribe|unsubscribe)-sse$`));if(n==="POST"&&ut){await E();let d=decodeURIComponent(ut[1]),c=decodeURIComponent(ut[2]),g=ut[3]==="subscribe",l=await U(t),R=typeof l?.clientId=="string"?l.clientId.trim():"";return R?(re(e,R,c,{cardId:d},g),!0):(f(e,400,{error:"clientId is required"}),!0)}let bt=s.match(new RegExp(`^${F(y)}/cards/([^/]+)/files$`));if(n==="POST"&&bt){await E();let d=decodeURIComponent(bt[1]),c=String(o.searchParams.get("inChat")||"").toLowerCase()==="true",g=String(o.searchParams.get("turn-id")||"").trim();if(c&&!g)return f(e,400,{error:`file upload with inChat=true requires a non-empty 'turn-id' query parameter for card: ${d}`}),!0;let l=t.headers["x-file-name"],R=String(t.headers["content-type"]||"application/octet-stream"),x=Array.isArray(l)?l[0]:l,v=x?decodeURIComponent(String(x)):"upload.bin",P=await Le(t);return f(e,200,xt(d,v,R,P,{inChat:c,turnId:g})),!0}let X=s.match(new RegExp(`^${F(y)}/cards/([^/]+)/files/(\\d+)$`));if(n==="GET"&&X){let d=decodeURIComponent(X[1]),c=parseInt(X[2],10),g=o.searchParams.get("sn");return qe(e,d,c,g),!0}return !1}catch(a){let i=a?.statusCode||500;return f(e,i,{error:String(a?.message||a)}),true}}return {get apiBasePath(){return y},get corsHeaders(){return w},handleRuntimeApi:Ze,buildPublishedRuntimePayload:yt,clearChatRecords:Pe,reportSourceFetched(t,e){return Xt(t,{ref:e})},reportSourceFetchFailure(t,e){return Qt(t,{reason:e})},get cardStore(){return S[0]?.cardStore??{set(){return {status:"fail",error:"no board context"}}}}}}function fr(m){let y=String(m.apiBasePath||"/api/boards").replace(/\/$/,""),w={...be,...m.corsHeaders||{}},_=m.serverMetaStore,j=m.boardRuntimeFactory,z=new Map,st="boards-config.json";function B(){let p=_.getText(st);if(!p)return {boards:[{id:"default",label:"Default Board"}]};try{return JSON.parse(p)}catch{return {boards:[{id:"default",label:"Default Board"}]}}}function at(p){_.putText(st,JSON.stringify(p,null,2));}function it(p){let k=String(p||"").replace(/[^a-zA-Z0-9_-]/g,"_").replace(/^_+|_+$/g,"");return k.length>0&&k.length<=64?k:null}function Y(p){if(z.has(p))return z.get(p);let I=B().boards.find(M=>M.id===p)||{},$=j(p,I);return z.set(p,$),$}function J(p,k,I){let $=JSON.stringify(I),M=typeof Buffer<"u"?Buffer.byteLength($):new TextEncoder().encode($).length;p.writeHead(k,{...w,"Content-Type":"application/json; charset=utf-8","Content-Length":M}),p.end($);}async function Ct(p,k,I){let $=p.method||"GET",M=I.pathname;if($==="GET"&&M===y)return J(k,200,{ok:true,boards:B().boards}),true;if($==="POST"&&M===y){let S=[];for await(let L of p)S.push(L);let G=typeof Buffer<"u"?Buffer.concat(S).toString("utf-8").trim():new TextDecoder().decode(er(S)).trim(),N={};try{N=G?JSON.parse(G):{};}catch{N={};}let K=it(N.id);if(!K)return J(k,400,{error:"board id must be 1-64 alphanumeric/dash/underscore characters"}),true;let tt=B();if(tt.boards.some(L=>L.id===K))return J(k,409,{error:`Board "${K}" is already registered`}),true;let At=typeof N.label=="string"&&N.label.trim()?N.label.trim():K,D={id:K,label:At};for(let[L,ct]of Object.entries(N))L==="id"||L==="label"||ct!=null&&(D[L]=ct);return tt.boards.push(D),at(tt),J(k,200,{ok:true,board:D}),true}return false}async function Rt(p,k,I){let M=I.pathname.match(new RegExp(`^${F(y)}/([^/]+)(/|$)`));if(!M)return false;let S=it(decodeURIComponent(M[1]));return S?B().boards.some(K=>K.id===S)?!!await Y(S).handleRuntimeApi(p,k,I):(J(k,404,{error:`Board "${S}" not registered. POST ${y} with {id} to register it first.`}),true):(J(k,400,{error:"Invalid board id"}),true)}async function kt(p,k,I){return !!(await Ct(p,k,I)||await Rt(p,k,I))}function St(p){if(!B().boards.some(I=>I.id===p))throw Object.assign(new Error(`Board "${p}" not registered`),{statusCode:404});return {service:Y(p)}}return {get apiBasePath(){return y},get corsHeaders(){return w},handleApi:kt,requireBoardService:St}}function F(m){return m.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function er(m){let y=m.reduce((j,z)=>j+z.length,0),w=new Uint8Array(y),_=0;for(let j of m)w.set(j,_),_+=j.length;return w}exports.a=lr;exports.b=fr;//# sourceMappingURL=chunk-P64UKI3L.cjs.map
|
|
8
|
+
//# sourceMappingURL=chunk-P64UKI3L.cjs.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';function f(r){function a(e){return {status:"success",data:e}}function s(e){return {status:"fail",error:e}}function u(e){return {status:"error",error:e instanceof Error?e.message:String(e)}}return {list(e){try{let t=e.params?.prefix??"";return a({artifacts:r.list(t)})}catch(t){return u(t)}},head(e){try{let t=e.params?.key;return t?a({artifact:r.head(t)}):s("head requires params.key")}catch(t){return u(t)}},put(e){try{let t=e.params?.key,i=e.params?.contentType;if(!t)return s("put requires params.key");let n=e.body;if(typeof n=="string")return a({artifact:r.putText(t,n,i)});if(n&&typeof n=="object"&&typeof n.text=="string")return a({artifact:r.putText(t,n.text,i)});if(n&&typeof n=="object"&&Array.isArray(n.bytes)){let o=n.bytes,m=new Uint8Array(o.map(c=>Math.max(0,Math.min(255,Number(c)||0))));return a({artifact:r.putBytes(t,m,i)})}return s("put requires body as string, {text}, or {bytes:number[]}")}catch(t){return u(t)}},get(e){try{let t=e.params?.key,i=e.params?.as??"base64";if(!t)return s("get requires params.key");let n=r.head(t);if(!n)return s(`artifact "${t}" not found`);if(i==="text"){let m=r.getText(t);return m===null?s(`artifact "${t}" not found`):a({key:t,contentType:n.contentType,size:n.size,text:m})}let o=r.getBytes(t);return o===null?s(`artifact "${t}" not found`):a({key:t,contentType:n.contentType,size:n.size,bytes:[...o]})}catch(t){return u(t)}},del(e){try{let t=e.params?.key;return t?(r.remove(t),a({ok:!0})):s("del requires params.key")}catch(t){return u(t)}}}}exports.a=f;//# sourceMappingURL=chunk-P7ZCDICS.cjs.map
|
|
2
|
+
//# sourceMappingURL=chunk-P7ZCDICS.cjs.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
'use strict';var chunkH5KD3JPY_cjs=require('./chunk-H5KD3JPY.cjs'),chunkUJ7ZTV4J_cjs=require('./chunk-UJ7ZTV4J.cjs'),chunkGNFE24S7_cjs=require('./chunk-GNFE24S7.cjs'),L=require('ajv-formats');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var L__default=/*#__PURE__*/_interopDefault(L);function w(r,t,e,i){let s=r.steps[e];if(!s)throw new Error(`Step "${e}" not found in flow configuration`);if(i.result==="failure"&&s.retry){let o=t.retryCounts[e]??0;if(o<s.retry.max_attempts)return {newState:{...t,retryCounts:{...t.retryCounts,[e]:o+1},updatedAt:Date.now()},nextStep:e,isTerminal:false,isCircuitBroken:false,shouldRetry:true}}let n=s.failure_transitions?.[i.result]??s.transitions[i.result];if(!n)throw new Error(`No transition defined for result "${i.result}" in step "${e}"`);let p=!!r.terminal_states[n];return {newState:{...t,currentStep:n,stepHistory:[...t.stepHistory,e],retryCounts:{...t.retryCounts,[e]:0},updatedAt:Date.now()},nextStep:n,isTerminal:p,isCircuitBroken:false,shouldRetry:false}}function S(r,t,e){let i=r.steps[e];if(!i?.circuit_breaker)return {broken:false,newState:{...t,iterationCounts:{...t.iterationCounts,[e]:(t.iterationCounts[e]??0)+1},updatedAt:Date.now()}};let s=t.iterationCounts[e]??0;return s>=i.circuit_breaker.max_iterations?{broken:true,redirectStep:i.circuit_breaker.on_open,newState:{...t,currentStep:i.circuit_breaker.on_open,updatedAt:Date.now()}}:{broken:false,newState:{...t,iterationCounts:{...t.iterationCounts,[e]:s+1},updatedAt:Date.now()}}}function h(r,t,e){let i=r.steps[t];if(!i)throw new Error(`Step "${t}" not found`);if(i.expects_data){let s={};for(let n of i.expects_data)s[n]=e[n];return s}return {...e}}function g(r,t){if(r===false||r===void 0)return {};if(typeof r=="string")return {[r]:t[r]};if(Array.isArray(r)){let e={};for(let i of r)e[i]=t[i];return e}return {}}function y(r,t){let e=Date.now();return {runId:t,flowId:r.id??"unnamed",currentStep:r.settings.start_step,status:"running",stepHistory:[],iterationCounts:{},retryCounts:{},startedAt:e,updatedAt:e}}function $(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,r=>{let t=Math.random()*16|0;return (r==="x"?t:t&3|8).toString(16)})}var u=class{flow;handlers;store;components;options;listeners=new Map;aborted=false;constructor(t,e,i={}){this.flow=t,this.handlers=new Map(Object.entries(e)),this.store=i.store??new chunkH5KD3JPY_cjs.a,this.components=i.components??{},this.options=i,i.signal&&i.signal.addEventListener("abort",()=>{this.aborted=true;}),this.validateFlow();}validateFlow(){let{settings:t,steps:e,terminal_states:i}=this.flow;if(!t?.start_step)throw new Error("Flow must have settings.start_step defined");if(!e||Object.keys(e).length===0)throw new Error("Flow must have at least one step defined");if(!i||Object.keys(i).length===0)throw new Error("Flow must have at least one terminal_state defined");if(!e[t.start_step]&&!i[t.start_step])throw new Error(`Start step "${t.start_step}" not found`);for(let[s,n]of Object.entries(e)){for(let[p,o]of Object.entries(n.transitions))if(!e[o]&&!i[o])throw new Error(`Step "${s}" transition "${p}" points to unknown step "${o}"`);if(n.failure_transitions){for(let[p,o]of Object.entries(n.failure_transitions))if(!e[o]&&!i[o])throw new Error(`Step "${s}" failure_transition "${p}" points to unknown step "${o}"`)}}}on(t,e){this.listeners.has(t)||this.listeners.set(t,new Set),this.listeners.get(t).add(e);}off(t,e){this.listeners.get(t)?.delete(e);}emit(t){let e=this.listeners.get(t.type);if(e)for(let i of e)try{i(t);}catch{}}sleep(t){return new Promise(e=>setTimeout(e,t))}async run(t){let e=$(),i=y(this.flow,e);if(await this.store.saveRunState(e,i),t)for(let[s,n]of Object.entries(t))await this.store.setData(e,s,n);this.emit({type:"flow:start",runId:e,timestamp:i.startedAt,data:{initialData:t??{}}});try{return await this.executeLoop(e,i)}catch(s){let n=s instanceof Error?s:new Error(String(s));return this.emit({type:"flow:error",runId:e,timestamp:Date.now(),data:{error:n.message}}),this.options.onError?.(n),i={...i,status:"failed",updatedAt:Date.now()},await this.store.saveRunState(e,i),{runId:e,status:"failed",data:await this.store.getAllData(e),finalStep:i.currentStep,stepHistory:i.stepHistory,durationMs:Date.now()-i.startedAt,error:n}}}async resume(t){let e=await this.store.loadRunState(t);if(!e)throw new Error(`No run found with ID: ${t}`);if(e.status==="completed"||e.status==="failed")throw new Error(`Cannot resume a ${e.status} run`);let i={...e,status:"running",pausedAt:void 0,updatedAt:Date.now()};return await this.store.saveRunState(t,i),this.emit({type:"flow:resumed",runId:t,timestamp:Date.now(),data:{currentStep:i.currentStep}}),this.executeLoop(t,i)}async pause(t){let e=await this.store.loadRunState(t);if(!e)throw new Error(`No run found with ID: ${t}`);let i={...e,status:"paused",pausedAt:Date.now(),updatedAt:Date.now()};await this.store.saveRunState(t,i),this.emit({type:"flow:paused",runId:t,timestamp:Date.now(),data:{currentStep:i.currentStep}});}async executeLoop(t,e){let i=this.flow.settings.max_total_steps??1e6,s=this.flow.settings.timeout_ms,n=e,p=0;for(;p<i;){if(this.aborted)return n={...n,status:"cancelled",updatedAt:Date.now()},await this.store.saveRunState(t,n),{runId:t,status:"cancelled",data:await this.store.getAllData(t),finalStep:n.currentStep,stepHistory:n.stepHistory,durationMs:Date.now()-n.startedAt};if(s&&Date.now()-n.startedAt>s)return n={...n,status:"completed",updatedAt:Date.now()},await this.store.saveRunState(t,n),{runId:t,status:"timeout",intent:"timeout",data:await this.store.getAllData(t),finalStep:n.currentStep,stepHistory:n.stepHistory,durationMs:Date.now()-n.startedAt};let o=n.currentStep,d=this.flow.terminal_states[o];if(d){n={...n,status:"completed",updatedAt:Date.now()},await this.store.saveRunState(t,n);let a=await this.store.getAllData(t),c={runId:t,status:"completed",intent:d.return_intent,data:g(d.return_artifacts,a),finalStep:o,stepHistory:n.stepHistory,durationMs:Date.now()-n.startedAt};return this.emit({type:"flow:complete",runId:t,timestamp:Date.now(),data:{...c}}),this.options.onComplete?.(c),c}let m=S(this.flow,n,o);if(m.broken){n=m.newState,await this.store.saveRunState(t,n),p++;continue}n=m.newState;let F=await this.store.getAllData(t),_=h(this.flow,o,F),j={runId:t,stepName:o,components:this.components,store:this.store,signal:this.options.signal,emit:(a,c)=>{this.emit({type:"step:complete",runId:t,timestamp:Date.now(),data:{event:a,payload:c}});}};this.emit({type:"step:start",runId:t,timestamp:Date.now(),data:{step:o,input:_}});let l;try{let a=this.handlers.get(o);if(!a)throw new Error(`No handler registered for step "${o}"`);l=await a(_,j);}catch(a){let c=a instanceof Error?a:new Error(String(a));this.emit({type:"step:error",runId:t,timestamp:Date.now(),data:{step:o,error:c.message}}),l={result:"failure",data:{error:c.message}};}if(l.data)for(let[a,c]of Object.entries(l.data))await this.store.setData(t,a,c);this.emit({type:"step:complete",runId:t,timestamp:Date.now(),data:{step:o,result:l.result}}),this.options.onStep?.(o,l);let b=w(this.flow,n,o,l);if(n=b.newState,b.shouldRetry){await this.store.saveRunState(t,n);let a=this.flow.steps[o];if(a.retry?.delay_ms){let c=n.retryCounts[o]??0,D=a.retry.backoff_multiplier?a.retry.delay_ms*Math.pow(a.retry.backoff_multiplier,c-1):a.retry.delay_ms;await this.sleep(D);}p++;continue}await this.store.saveRunState(t,n),this.emit({type:"transition",runId:t,timestamp:Date.now(),data:{from:o,to:n.currentStep,result:l.result}}),this.options.onTransition?.(o,n.currentStep),p++;}return n={...n,status:"completed",updatedAt:Date.now()},await this.store.saveRunState(t,n),{runId:t,status:"max_iterations",intent:"max_iterations",data:await this.store.getAllData(t),finalStep:n.currentStep,stepHistory:n.stepHistory,durationMs:Date.now()-n.startedAt}}};function A(r,t,e){return new u(r,t,e)}async function x(r){return (await import('yaml')).parse(r)}async function P(r){let t=await fetch(r);if(!t.ok)throw new Error(`Failed to load flow from ${r}: ${t.statusText}`);let e=t.headers.get("content-type")??"",i=await t.text();return e.includes("json")||r.endsWith(".json")?JSON.parse(i):x(i)}async function H(r){let e=await(await import('fs/promises')).readFile(r,"utf-8");return r.endsWith(".json")?JSON.parse(e):x(e)}function k(r){let t=[];if(!r||typeof r!="object")return ["Flow must be an object"];let e=r;if(!e.settings||typeof e.settings!="object"?t.push('Flow must have a "settings" object'):typeof e.settings.start_step!="string"&&t.push("settings.start_step must be a string"),!e.steps||typeof e.steps!="object")t.push('Flow must have a "steps" object');else {let i=e.steps;for(let[s,n]of Object.entries(i)){if(!n||typeof n!="object"){t.push(`Step "${s}" must be an object`);continue}let p=n;(!p.transitions||typeof p.transitions!="object")&&t.push(`Step "${s}" must have a "transitions" object`),p.failure_transitions!==void 0&&typeof p.failure_transitions!="object"&&t.push(`Step "${s}" failure_transitions must be an object when provided`);}}if(!e.terminal_states||typeof e.terminal_states!="object")t.push('Flow must have a "terminal_states" object');else {let i=e.terminal_states;for(let[s,n]of Object.entries(i)){if(!n||typeof n!="object"){t.push(`Terminal state "${s}" must be an object`);continue}typeof n.return_intent!="string"&&t.push(`Terminal state "${s}" must have a "return_intent" string`);}}return t}async function O(r){let t;typeof r=="string"?r.startsWith("http://")||r.startsWith("https://")?t=await P(r):r.includes("{")?t=JSON.parse(r):t=await H(r):t=r;let e=k(t);if(e.length>0)throw new Error(`Invalid step flow configuration:
|
|
2
|
+
- ${e.join(`
|
|
3
|
+
- `)}`);return t}var C={$schema:"http://json-schema.org/draft-07/schema#",$id:"https://github.com/yaml-flow/schema/flow.json",title:"YamlFlow Configuration",description:"Schema for yaml-flow workflow definitions",type:"object",required:["settings","steps","terminal_states"],properties:{id:{type:"string",description:"Optional flow identifier"},settings:{type:"object",description:"Flow-level settings",required:["start_step"],properties:{start_step:{type:"string",description:"Step to start execution from"},max_total_steps:{type:"integer",minimum:1,default:1e6,description:"Maximum steps before forced termination"},timeout_ms:{type:"integer",minimum:0,description:"Flow timeout in milliseconds"},invoke_timeout_ms:{type:"integer",minimum:0,description:"Per-ref invocation timeout in milliseconds"}},additionalProperties:false},steps:{type:"object",description:"Step definitions",minProperties:1,additionalProperties:{$ref:"#/definitions/step"}},terminal_states:{type:"object",description:"Terminal state definitions",minProperties:1,additionalProperties:{$ref:"#/definitions/terminal_state"}}},additionalProperties:false,definitions:{step:{type:"object",description:"Individual step configuration",required:["transitions"],properties:{description:{type:"string",description:"Human-readable description"},expects_data:{type:"array",items:{type:"string"},description:"Data keys this step expects as input"},produces_data:{type:"array",items:{type:"string"},description:"Data keys this step produces as output"},transitions:{type:"object",description:"Mapping of result -> next step name",additionalProperties:{type:"string"},minProperties:1},failure_transitions:{type:"object",description:"Mapping of failure-like results (e.g. failure, timeout) -> next step name",additionalProperties:{type:"string"}},retry:{$ref:"#/definitions/retry_config"},circuit_breaker:{$ref:"#/definitions/circuit_breaker_config"}},additionalProperties:false},terminal_state:{type:"object",description:"Terminal state configuration",required:["return_intent"],properties:{description:{type:"string",description:"Human-readable description"},return_intent:{type:"string",description:"Intent/status to return (e.g., 'success', 'error')"},return_artifacts:{oneOf:[{type:"string"},{type:"array",items:{type:"string"}},{type:"boolean",const:false}],description:"Data key(s) to include in result, or false to exclude"},expects_data:{type:"array",items:{type:"string"},description:"Data keys this terminal state expects"}},additionalProperties:false},retry_config:{type:"object",description:"Retry configuration for step failures",required:["max_attempts"],properties:{max_attempts:{type:"integer",minimum:1,description:"Maximum retry attempts"},delay_ms:{type:"integer",minimum:0,description:"Delay between retries in ms"},backoff_multiplier:{type:"number",minimum:1,description:"Backoff multiplier (e.g., 2 for exponential)"}},additionalProperties:false},circuit_breaker_config:{type:"object",description:"Circuit breaker configuration for loops",required:["max_iterations","on_open"],properties:{max_iterations:{type:"integer",minimum:1,description:"Maximum iterations before circuit opens"},on_open:{type:"string",description:"Step to transition to when circuit opens"}},additionalProperties:false}}};var R=chunkGNFE24S7_cjs.b(chunkUJ7ZTV4J_cjs.q(),1);var f=null;function B(){if(f)return f;let r=new R.default({allErrors:true});return L__default.default(r),f=r.compile(C),f}function q(r){let t=B();return t(r)?{ok:true,errors:[]}:{ok:false,errors:(t.errors??[]).map(s=>`${s.instancePath||"/"}: ${s.message??"unknown error"}`)}}
|
|
4
|
+
exports.a=w;exports.b=S;exports.c=h;exports.d=g;exports.e=y;exports.f=u;exports.g=A;exports.h=x;exports.i=k;exports.j=O;exports.k=q;//# sourceMappingURL=chunk-Q6H7NINN.cjs.map
|
|
5
|
+
//# sourceMappingURL=chunk-Q6H7NINN.cjs.map
|