@flowcast/mcp 0.1.0
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/LICENSE +16 -0
- package/README.md +213 -0
- package/THIRD-PARTY-NOTICES +11 -0
- package/flowcast.mjs +265 -0
- package/package.json +27 -0
- package/player/_player-bundle.3d.gz.b64 +1 -0
- package/player/_player-bundle.gz.b64 +1 -0
- package/player/_player-bundle.map.gz.b64 +1 -0
- package/player/_player-bundle.min.gz.b64 +1 -0
- package/player/_player-bundle.noterm.gz.b64 +1 -0
- package/player/_player-bundle.slim.gz.b64 +1 -0
package/flowcast.mjs
ADDED
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
var U3=Object.create;var vu=Object.defineProperty;var G3=Object.getOwnPropertyDescriptor;var Y3=Object.getOwnPropertyNames;var X3=Object.getPrototypeOf,W3=Object.prototype.hasOwnProperty;var Ie=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),wu=(t,e)=>{for(var r in e)vu(t,r,{get:e[r],enumerable:!0})},K3=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Y3(e))!W3.call(t,s)&&s!==r&&vu(t,s,{get:()=>e[s],enumerable:!(n=G3(e,s))||n.enumerable});return t};var T1=(t,e,r)=>(r=t!=null?U3(X3(t)):{},K3(e||!t||!t.__esModule?vu(r,"default",{value:t,enumerable:!0}):r,t));var Wi=Ie(yt=>{"use strict";Object.defineProperty(yt,"__esModule",{value:!0});yt.regexpCode=yt.getEsmExportName=yt.getProperty=yt.safeStringify=yt.stringify=yt.strConcat=yt.addCodeArg=yt.str=yt._=yt.nil=yt._Code=yt.Name=yt.IDENTIFIER=yt._CodeOrName=void 0;var Yi=class{};yt._CodeOrName=Yi;yt.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var Hs=class extends Yi{constructor(e){if(super(),!yt.IDENTIFIER.test(e))throw new Error("CodeGen: name must be a valid identifier");this.str=e}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};yt.Name=Hs;var Wr=class extends Yi{constructor(e){super(),this._items=typeof e=="string"?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;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,n)=>`${r}${n}`,"")}get names(){var e;return(e=this._names)!==null&&e!==void 0?e:this._names=this._items.reduce((r,n)=>(n instanceof Hs&&(r[n.str]=(r[n.str]||0)+1),r),{})}};yt._Code=Wr;yt.nil=new Wr("");function x_(t,...e){let r=[t[0]],n=0;for(;n<e.length;)sh(r,e[n]),r.push(t[++n]);return new Wr(r)}yt._=x_;var nh=new Wr("+");function k_(t,...e){let r=[Xi(t[0])],n=0;for(;n<e.length;)r.push(nh),sh(r,e[n]),r.push(nh,Xi(t[++n]));return K6(r),new Wr(r)}yt.str=k_;function sh(t,e){e instanceof Wr?t.push(...e._items):e instanceof Hs?t.push(e):t.push(eS(e))}yt.addCodeArg=sh;function K6(t){let e=1;for(;e<t.length-1;){if(t[e]===nh){let r=J6(t[e-1],t[e+1]);if(r!==void 0){t.splice(e-1,3,r);continue}t[e++]="+"}e++}}function J6(t,e){if(e==='""')return t;if(t==='""')return e;if(typeof t=="string")return e instanceof Hs||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 Hs))return`"${t}${e.slice(1)}`}function Q6(t,e){return e.emptyStr()?t:t.emptyStr()?e:k_`${t}${e}`}yt.strConcat=Q6;function eS(t){return typeof t=="number"||typeof t=="boolean"||t===null?t:Xi(Array.isArray(t)?t.join(","):t)}function tS(t){return new Wr(Xi(t))}yt.stringify=tS;function Xi(t){return JSON.stringify(t).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}yt.safeStringify=Xi;function rS(t){return typeof t=="string"&&yt.IDENTIFIER.test(t)?new Wr(`.${t}`):x_`[${t}]`}yt.getProperty=rS;function nS(t){if(typeof t=="string"&&yt.IDENTIFIER.test(t))return new Wr(`${t}`);throw new Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}yt.getEsmExportName=nS;function sS(t){return new Wr(t.toString())}yt.regexpCode=sS});var ah=Ie(Tr=>{"use strict";Object.defineProperty(Tr,"__esModule",{value:!0});Tr.ValueScope=Tr.ValueScopeName=Tr.Scope=Tr.varKinds=Tr.UsedValueState=void 0;var Er=Wi(),oh=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},Vc;(function(t){t[t.Started=0]="Started",t[t.Completed=1]="Completed"})(Vc||(Tr.UsedValueState=Vc={}));Tr.varKinds={const:new Er.Name("const"),let:new Er.Name("let"),var:new Er.Name("var")};var Fc=class{constructor({prefixes:e,parent:r}={}){this._names={},this._prefixes=e,this._parent=r}toName(e){return e instanceof Er.Name?e:this.name(e)}name(e){return new Er.Name(this._newName(e))}_newName(e){let r=this._names[e]||this._nameGroup(e);return`${e}${r.index++}`}_nameGroup(e){var r,n;if(!((n=(r=this._parent)===null||r===void 0?void 0:r._prefixes)===null||n===void 0)&&n.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}}};Tr.Scope=Fc;var Hc=class extends Er.Name{constructor(e,r){super(r),this.prefix=e}setValue(e,{property:r,itemIndex:n}){this.value=e,this.scopePath=(0,Er._)`.${new Er.Name(r)}[${n}]`}};Tr.ValueScopeName=Hc;var oS=(0,Er._)`\n`,ih=class extends Fc{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?oS:Er.nil}}get(){return this._scope}name(e){return new Hc(e,this._newName(e))}value(e,r){var n;if(r.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let s=this.toName(e),{prefix:o}=s,i=(n=r.key)!==null&&n!==void 0?n:r.ref,a=this._values[o];if(a){let l=a.get(i);if(l)return l}else a=this._values[o]=new Map;a.set(i,s);let c=this._scope[o]||(this._scope[o]=[]),d=c.length;return c[d]=r.ref,s.setValue(r,{property:o,itemIndex:d}),s}getValue(e,r){let n=this._values[e];if(n)return n.get(r)}scopeRefs(e,r=this._values){return this._reduceValues(r,n=>{if(n.scopePath===void 0)throw new Error(`CodeGen: name "${n}" has no value`);return(0,Er._)`${e}${n.scopePath}`})}scopeCode(e=this._values,r,n){return this._reduceValues(e,s=>{if(s.value===void 0)throw new Error(`CodeGen: name "${s}" has no value`);return s.value.code},r,n)}_reduceValues(e,r,n={},s){let o=Er.nil;for(let i in e){let a=e[i];if(!a)continue;let c=n[i]=n[i]||new Map;a.forEach(d=>{if(c.has(d))return;c.set(d,Vc.Started);let l=r(d);if(l){let u=this.opts.es5?Tr.varKinds.var:Tr.varKinds.const;o=(0,Er._)`${o}${u} ${d} = ${l};${this.opts._n}`}else if(l=s?.(d))o=(0,Er._)`${o}${l}${this.opts._n}`;else throw new oh(d);c.set(d,Vc.Completed)})}return o}};Tr.ValueScope=ih});var it=Ie(at=>{"use strict";Object.defineProperty(at,"__esModule",{value:!0});at.or=at.and=at.not=at.CodeGen=at.operators=at.varKinds=at.ValueScopeName=at.ValueScope=at.Scope=at.Name=at.regexpCode=at.stringify=at.getProperty=at.nil=at.strConcat=at.str=at._=void 0;var ht=Wi(),hn=ah(),ns=Wi();Object.defineProperty(at,"_",{enumerable:!0,get:function(){return ns._}});Object.defineProperty(at,"str",{enumerable:!0,get:function(){return ns.str}});Object.defineProperty(at,"strConcat",{enumerable:!0,get:function(){return ns.strConcat}});Object.defineProperty(at,"nil",{enumerable:!0,get:function(){return ns.nil}});Object.defineProperty(at,"getProperty",{enumerable:!0,get:function(){return ns.getProperty}});Object.defineProperty(at,"stringify",{enumerable:!0,get:function(){return ns.stringify}});Object.defineProperty(at,"regexpCode",{enumerable:!0,get:function(){return ns.regexpCode}});Object.defineProperty(at,"Name",{enumerable:!0,get:function(){return ns.Name}});var Xc=ah();Object.defineProperty(at,"Scope",{enumerable:!0,get:function(){return Xc.Scope}});Object.defineProperty(at,"ValueScope",{enumerable:!0,get:function(){return Xc.ValueScope}});Object.defineProperty(at,"ValueScopeName",{enumerable:!0,get:function(){return Xc.ValueScopeName}});Object.defineProperty(at,"varKinds",{enumerable:!0,get:function(){return Xc.varKinds}});at.operators={GT:new ht._Code(">"),GTE:new ht._Code(">="),LT:new ht._Code("<"),LTE:new ht._Code("<="),EQ:new ht._Code("==="),NEQ:new ht._Code("!=="),NOT:new ht._Code("!"),OR:new ht._Code("||"),AND:new ht._Code("&&"),ADD:new ht._Code("+")};var Zn=class{optimizeNodes(){return this}optimizeNames(e,r){return this}},ch=class extends Zn{constructor(e,r,n){super(),this.varKind=e,this.name=r,this.rhs=n}render({es5:e,_n:r}){let n=e?hn.varKinds.var:this.varKind,s=this.rhs===void 0?"":` = ${this.rhs}`;return`${n} ${this.name}${s};`+r}optimizeNames(e,r){if(e[this.name.str])return this.rhs&&(this.rhs=No(this.rhs,e,r)),this}get names(){return this.rhs instanceof ht._CodeOrName?this.rhs.names:{}}},Uc=class extends Zn{constructor(e,r,n){super(),this.lhs=e,this.rhs=r,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,r){if(!(this.lhs instanceof ht.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=No(this.rhs,e,r),this}get names(){let e=this.lhs instanceof ht.Name?{}:{...this.lhs.names};return Yc(e,this.rhs)}},lh=class extends Uc{constructor(e,r,n,s){super(e,n,s),this.op=r}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},uh=class extends Zn{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},dh=class extends Zn{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:""};`+e}},fh=class extends Zn{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},hh=class extends Zn{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=No(this.code,e,r),this}get names(){return this.code instanceof ht._CodeOrName?this.code.names:{}}},Ki=class extends Zn{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((r,n)=>r+n.render(e),"")}optimizeNodes(){let{nodes:e}=this,r=e.length;for(;r--;){let n=e[r].optimizeNodes();Array.isArray(n)?e.splice(r,1,...n):n?e[r]=n:e.splice(r,1)}return e.length>0?this:void 0}optimizeNames(e,r){let{nodes:n}=this,s=n.length;for(;s--;){let o=n[s];o.optimizeNames(e,r)||(iS(e,o.names),n.splice(s,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,r)=>Ys(e,r.names),{})}},Bn=class extends Ki{render(e){return"{"+e._n+super.render(e)+"}"+e._n}},ph=class extends Ki{},Ao=class extends Bn{};Ao.kind="else";var Us=class t extends Bn{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===!0)return this.nodes;let r=this.else;if(r){let n=r.optimizeNodes();r=this.else=Array.isArray(n)?new Ao(n):n}if(r)return e===!1?r instanceof t?r:r.nodes:this.nodes.length?this:new t(S_(e),r instanceof t?[r]:r.nodes);if(!(e===!1||!this.nodes.length))return this}optimizeNames(e,r){var n;if(this.else=(n=this.else)===null||n===void 0?void 0:n.optimizeNames(e,r),!!(super.optimizeNames(e,r)||this.else))return this.condition=No(this.condition,e,r),this}get names(){let e=super.names;return Yc(e,this.condition),this.else&&Ys(e,this.else.names),e}};Us.kind="if";var Gs=class extends Bn{};Gs.kind="for";var mh=class extends Gs{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=No(this.iteration,e,r),this}get names(){return Ys(super.names,this.iteration.names)}},gh=class extends Gs{constructor(e,r,n,s){super(),this.varKind=e,this.name=r,this.from=n,this.to=s}render(e){let r=e.es5?hn.varKinds.var:this.varKind,{name:n,from:s,to:o}=this;return`for(${r} ${n}=${s}; ${n}<${o}; ${n}++)`+super.render(e)}get names(){let e=Yc(super.names,this.from);return Yc(e,this.to)}},Gc=class extends Gs{constructor(e,r,n,s){super(),this.loop=e,this.varKind=r,this.name=n,this.iterable=s}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=No(this.iterable,e,r),this}get names(){return Ys(super.names,this.iterable.names)}},Ji=class extends Bn{constructor(e,r,n){super(),this.name=e,this.args=r,this.async=n}render(e){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(e)}};Ji.kind="func";var Qi=class extends Ki{render(e){return"return "+super.render(e)}};Qi.kind="return";var _h=class extends Bn{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 n,s;return super.optimizeNames(e,r),(n=this.catch)===null||n===void 0||n.optimizeNames(e,r),(s=this.finally)===null||s===void 0||s.optimizeNames(e,r),this}get names(){let e=super.names;return this.catch&&Ys(e,this.catch.names),this.finally&&Ys(e,this.finally.names),e}},ea=class extends Bn{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};ea.kind="catch";var ta=class extends Bn{render(e){return"finally"+super.render(e)}};ta.kind="finally";var bh=class{constructor(e,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
|
|
3
|
+
`:""},this._extScope=e,this._scope=new hn.Scope({parent:e}),this._nodes=[new ph]}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 n=this._extScope.value(e,r);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}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,n,s){let o=this._scope.toName(r);return n!==void 0&&s&&(this._constants[o.str]=n),this._leafNode(new ch(e,o,n)),o}const(e,r,n){return this._def(hn.varKinds.const,e,r,n)}let(e,r,n){return this._def(hn.varKinds.let,e,r,n)}var(e,r,n){return this._def(hn.varKinds.var,e,r,n)}assign(e,r,n){return this._leafNode(new Uc(e,r,n))}add(e,r){return this._leafNode(new lh(e,at.operators.ADD,r))}code(e){return typeof e=="function"?e():e!==ht.nil&&this._leafNode(new hh(e)),this}object(...e){let r=["{"];for(let[n,s]of e)r.length>1&&r.push(","),r.push(n),(n!==s||this.opts.es5)&&(r.push(":"),(0,ht.addCodeArg)(r,s));return r.push("}"),new ht._Code(r)}if(e,r,n){if(this._blockNode(new Us(e)),r&&n)this.code(r).else().code(n).endIf();else if(r)this.code(r).endIf();else if(n)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(e){return this._elseNode(new Us(e))}else(){return this._elseNode(new Ao)}endIf(){return this._endBlockNode(Us,Ao)}_for(e,r){return this._blockNode(e),r&&this.code(r).endFor(),this}for(e,r){return this._for(new mh(e),r)}forRange(e,r,n,s,o=this.opts.es5?hn.varKinds.var:hn.varKinds.let){let i=this._scope.toName(e);return this._for(new gh(o,i,r,n),()=>s(i))}forOf(e,r,n,s=hn.varKinds.const){let o=this._scope.toName(e);if(this.opts.es5){let i=r instanceof ht.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,ht._)`${i}.length`,a=>{this.var(o,(0,ht._)`${i}[${a}]`),n(o)})}return this._for(new Gc("of",s,o,r),()=>n(o))}forIn(e,r,n,s=this.opts.es5?hn.varKinds.var:hn.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,ht._)`Object.keys(${r})`,n);let o=this._scope.toName(e);return this._for(new Gc("in",s,o,r),()=>n(o))}endFor(){return this._endBlockNode(Gs)}label(e){return this._leafNode(new uh(e))}break(e){return this._leafNode(new dh(e))}return(e){let r=new Qi;if(this._blockNode(r),this.code(e),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(Qi)}try(e,r,n){if(!r&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let s=new _h;if(this._blockNode(s),this.code(e),r){let o=this.name("e");this._currNode=s.catch=new ea(o),r(o)}return n&&(this._currNode=s.finally=new ta,this.code(n)),this._endBlockNode(ea,ta)}throw(e){return this._leafNode(new fh(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 n=this._nodes.length-r;if(n<0||e!==void 0&&n!==e)throw new Error(`CodeGen: wrong number of nodes: ${n} vs ${e} expected`);return this._nodes.length=r,this}func(e,r=ht.nil,n,s){return this._blockNode(new Ji(e,r,n)),s&&this.code(s).endFunc(),this}endFunc(){return this._endBlockNode(Ji)}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 n=this._currNode;if(n instanceof e||r&&n 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 Us))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}};at.CodeGen=bh;function Ys(t,e){for(let r in e)t[r]=(t[r]||0)+(e[r]||0);return t}function Yc(t,e){return e instanceof ht._CodeOrName?Ys(t,e.names):t}function No(t,e,r){if(t instanceof ht.Name)return n(t);if(!s(t))return t;return new ht._Code(t._items.reduce((o,i)=>(i instanceof ht.Name&&(i=n(i)),i instanceof ht._Code?o.push(...i._items):o.push(i),o),[]));function n(o){let i=r[o.str];return i===void 0||e[o.str]!==1?o:(delete e[o.str],i)}function s(o){return o instanceof ht._Code&&o._items.some(i=>i instanceof ht.Name&&e[i.str]===1&&r[i.str]!==void 0)}}function iS(t,e){for(let r in e)t[r]=(t[r]||0)-(e[r]||0)}function S_(t){return typeof t=="boolean"||typeof t=="number"||t===null?!t:(0,ht._)`!${yh(t)}`}at.not=S_;var aS=E_(at.operators.AND);function cS(...t){return t.reduce(aS)}at.and=cS;var lS=E_(at.operators.OR);function uS(...t){return t.reduce(lS)}at.or=uS;function E_(t){return(e,r)=>e===ht.nil?r:r===ht.nil?e:(0,ht._)`${yh(e)} ${t} ${yh(r)}`}function yh(t){return t instanceof ht.Name?t:(0,ht._)`(${t})`}});var mt=Ie(ct=>{"use strict";Object.defineProperty(ct,"__esModule",{value:!0});ct.checkStrictMode=ct.getErrorPath=ct.Type=ct.useFunc=ct.setEvaluated=ct.evaluatedPropsToName=ct.mergeEvaluated=ct.eachItem=ct.unescapeJsonPointer=ct.escapeJsonPointer=ct.escapeFragment=ct.unescapeFragment=ct.schemaRefOrVal=ct.schemaHasRulesButRef=ct.schemaHasRules=ct.checkUnknownRules=ct.alwaysValidSchema=ct.toHash=void 0;var Et=it(),dS=Wi();function fS(t){let e={};for(let r of t)e[r]=!0;return e}ct.toHash=fS;function hS(t,e){return typeof e=="boolean"?e:Object.keys(e).length===0?!0:(R_(t,e),!P_(e,t.self.RULES.all))}ct.alwaysValidSchema=hS;function R_(t,e=t.schema){let{opts:r,self:n}=t;if(!r.strictSchema||typeof e=="boolean")return;let s=n.RULES.keywords;for(let o in e)s[o]||I_(t,`unknown keyword: "${o}"`)}ct.checkUnknownRules=R_;function P_(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(e[r])return!0;return!1}ct.schemaHasRules=P_;function pS(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(r!=="$ref"&&e.all[r])return!0;return!1}ct.schemaHasRulesButRef=pS;function mS({topSchemaRef:t,schemaPath:e},r,n,s){if(!s){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,Et._)`${r}`}return(0,Et._)`${t}${e}${(0,Et.getProperty)(n)}`}ct.schemaRefOrVal=mS;function gS(t){return M_(decodeURIComponent(t))}ct.unescapeFragment=gS;function _S(t){return encodeURIComponent(wh(t))}ct.escapeFragment=_S;function wh(t){return typeof t=="number"?`${t}`:t.replace(/~/g,"~0").replace(/\//g,"~1")}ct.escapeJsonPointer=wh;function M_(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}ct.unescapeJsonPointer=M_;function bS(t,e){if(Array.isArray(t))for(let r of t)e(r);else e(t)}ct.eachItem=bS;function T_({mergeNames:t,mergeToName:e,mergeValues:r,resultToName:n}){return(s,o,i,a)=>{let c=i===void 0?o:i instanceof Et.Name?(o instanceof Et.Name?t(s,o,i):e(s,o,i),i):o instanceof Et.Name?(e(s,i,o),o):r(o,i);return a===Et.Name&&!(c instanceof Et.Name)?n(s,c):c}}ct.mergeEvaluated={props:T_({mergeNames:(t,e,r)=>t.if((0,Et._)`${r} !== true && ${e} !== undefined`,()=>{t.if((0,Et._)`${e} === true`,()=>t.assign(r,!0),()=>t.assign(r,(0,Et._)`${r} || {}`).code((0,Et._)`Object.assign(${r}, ${e})`))}),mergeToName:(t,e,r)=>t.if((0,Et._)`${r} !== true`,()=>{e===!0?t.assign(r,!0):(t.assign(r,(0,Et._)`${r} || {}`),xh(t,r,e))}),mergeValues:(t,e)=>t===!0?!0:{...t,...e},resultToName:z_}),items:T_({mergeNames:(t,e,r)=>t.if((0,Et._)`${r} !== true && ${e} !== undefined`,()=>t.assign(r,(0,Et._)`${e} === true ? true : ${r} > ${e} ? ${r} : ${e}`)),mergeToName:(t,e,r)=>t.if((0,Et._)`${r} !== true`,()=>t.assign(r,e===!0?!0:(0,Et._)`${r} > ${e} ? ${r} : ${e}`)),mergeValues:(t,e)=>t===!0?!0:Math.max(t,e),resultToName:(t,e)=>t.var("items",e)})};function z_(t,e){if(e===!0)return t.var("props",!0);let r=t.var("props",(0,Et._)`{}`);return e!==void 0&&xh(t,r,e),r}ct.evaluatedPropsToName=z_;function xh(t,e,r){Object.keys(r).forEach(n=>t.assign((0,Et._)`${e}${(0,Et.getProperty)(n)}`,!0))}ct.setEvaluated=xh;var $_={};function yS(t,e){return t.scopeValue("func",{ref:e,code:$_[e.code]||($_[e.code]=new dS._Code(e.code))})}ct.useFunc=yS;var vh;(function(t){t[t.Num=0]="Num",t[t.Str=1]="Str"})(vh||(ct.Type=vh={}));function vS(t,e,r){if(t instanceof Et.Name){let n=e===vh.Num;return r?n?(0,Et._)`"[" + ${t} + "]"`:(0,Et._)`"['" + ${t} + "']"`:n?(0,Et._)`"/" + ${t}`:(0,Et._)`"/" + ${t}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,Et.getProperty)(t).toString():"/"+wh(t)}ct.getErrorPath=vS;function I_(t,e,r=t.opts.strictSchema){if(r){if(e=`strict mode: ${e}`,r===!0)throw new Error(e);t.self.logger.warn(e)}}ct.checkStrictMode=I_});var qn=Ie(kh=>{"use strict";Object.defineProperty(kh,"__esModule",{value:!0});var lr=it(),wS={data:new lr.Name("data"),valCxt:new lr.Name("valCxt"),instancePath:new lr.Name("instancePath"),parentData:new lr.Name("parentData"),parentDataProperty:new lr.Name("parentDataProperty"),rootData:new lr.Name("rootData"),dynamicAnchors:new lr.Name("dynamicAnchors"),vErrors:new lr.Name("vErrors"),errors:new lr.Name("errors"),this:new lr.Name("this"),self:new lr.Name("self"),scope:new lr.Name("scope"),json:new lr.Name("json"),jsonPos:new lr.Name("jsonPos"),jsonLen:new lr.Name("jsonLen"),jsonPart:new lr.Name("jsonPart")};kh.default=wS});var ra=Ie(ur=>{"use strict";Object.defineProperty(ur,"__esModule",{value:!0});ur.extendErrors=ur.resetErrorsCount=ur.reportExtraError=ur.reportError=ur.keyword$DataError=ur.keywordError=void 0;var gt=it(),Wc=mt(),gr=qn();ur.keywordError={message:({keyword:t})=>(0,gt.str)`must pass "${t}" keyword validation`};ur.keyword$DataError={message:({keyword:t,schemaType:e})=>e?(0,gt.str)`"${t}" keyword must be ${e} ($data)`:(0,gt.str)`"${t}" keyword is invalid ($data)`};function xS(t,e=ur.keywordError,r,n){let{it:s}=t,{gen:o,compositeRule:i,allErrors:a}=s,c=N_(t,e,r);n??(i||a)?O_(o,c):A_(s,(0,gt._)`[${c}]`)}ur.reportError=xS;function kS(t,e=ur.keywordError,r){let{it:n}=t,{gen:s,compositeRule:o,allErrors:i}=n,a=N_(t,e,r);O_(s,a),o||i||A_(n,gr.default.vErrors)}ur.reportExtraError=kS;function SS(t,e){t.assign(gr.default.errors,e),t.if((0,gt._)`${gr.default.vErrors} !== null`,()=>t.if(e,()=>t.assign((0,gt._)`${gr.default.vErrors}.length`,e),()=>t.assign(gr.default.vErrors,null)))}ur.resetErrorsCount=SS;function ES({gen:t,keyword:e,schemaValue:r,data:n,errsCount:s,it:o}){if(s===void 0)throw new Error("ajv implementation error");let i=t.name("err");t.forRange("i",s,gr.default.errors,a=>{t.const(i,(0,gt._)`${gr.default.vErrors}[${a}]`),t.if((0,gt._)`${i}.instancePath === undefined`,()=>t.assign((0,gt._)`${i}.instancePath`,(0,gt.strConcat)(gr.default.instancePath,o.errorPath))),t.assign((0,gt._)`${i}.schemaPath`,(0,gt.str)`${o.errSchemaPath}/${e}`),o.opts.verbose&&(t.assign((0,gt._)`${i}.schema`,r),t.assign((0,gt._)`${i}.data`,n))})}ur.extendErrors=ES;function O_(t,e){let r=t.const("err",e);t.if((0,gt._)`${gr.default.vErrors} === null`,()=>t.assign(gr.default.vErrors,(0,gt._)`[${r}]`),(0,gt._)`${gr.default.vErrors}.push(${r})`),t.code((0,gt._)`${gr.default.errors}++`)}function A_(t,e){let{gen:r,validateName:n,schemaEnv:s}=t;s.$async?r.throw((0,gt._)`new ${t.ValidationError}(${e})`):(r.assign((0,gt._)`${n}.errors`,e),r.return(!1))}var Xs={keyword:new gt.Name("keyword"),schemaPath:new gt.Name("schemaPath"),params:new gt.Name("params"),propertyName:new gt.Name("propertyName"),message:new gt.Name("message"),schema:new gt.Name("schema"),parentSchema:new gt.Name("parentSchema")};function N_(t,e,r){let{createErrors:n}=t.it;return n===!1?(0,gt._)`{}`:TS(t,e,r)}function TS(t,e,r={}){let{gen:n,it:s}=t,o=[$S(s,r),RS(t,r)];return PS(t,e,o),n.object(...o)}function $S({errorPath:t},{instancePath:e}){let r=e?(0,gt.str)`${t}${(0,Wc.getErrorPath)(e,Wc.Type.Str)}`:t;return[gr.default.instancePath,(0,gt.strConcat)(gr.default.instancePath,r)]}function RS({keyword:t,it:{errSchemaPath:e}},{schemaPath:r,parentSchema:n}){let s=n?e:(0,gt.str)`${e}/${t}`;return r&&(s=(0,gt.str)`${s}${(0,Wc.getErrorPath)(r,Wc.Type.Str)}`),[Xs.schemaPath,s]}function PS(t,{params:e,message:r},n){let{keyword:s,data:o,schemaValue:i,it:a}=t,{opts:c,propertyName:d,topSchemaRef:l,schemaPath:u}=a;n.push([Xs.keyword,s],[Xs.params,typeof e=="function"?e(t):e||(0,gt._)`{}`]),c.messages&&n.push([Xs.message,typeof r=="function"?r(t):r]),c.verbose&&n.push([Xs.schema,i],[Xs.parentSchema,(0,gt._)`${l}${u}`],[gr.default.data,o]),d&&n.push([Xs.propertyName,d])}});var j_=Ie(Co=>{"use strict";Object.defineProperty(Co,"__esModule",{value:!0});Co.boolOrEmptySchema=Co.topBoolOrEmptySchema=void 0;var MS=ra(),zS=it(),IS=qn(),OS={message:"boolean schema is false"};function AS(t){let{gen:e,schema:r,validateName:n}=t;r===!1?C_(t,!1):typeof r=="object"&&r.$async===!0?e.return(IS.default.data):(e.assign((0,zS._)`${n}.errors`,null),e.return(!0))}Co.topBoolOrEmptySchema=AS;function NS(t,e){let{gen:r,schema:n}=t;n===!1?(r.var(e,!1),C_(t)):r.var(e,!0)}Co.boolOrEmptySchema=NS;function C_(t,e){let{gen:r,data:n}=t,s={gen:r,keyword:"false schema",data:n,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:t};(0,MS.reportError)(s,OS,void 0,e)}});var Sh=Ie(jo=>{"use strict";Object.defineProperty(jo,"__esModule",{value:!0});jo.getRules=jo.isJSONType=void 0;var CS=["string","number","integer","boolean","null","object","array"],jS=new Set(CS);function DS(t){return typeof t=="string"&&jS.has(t)}jo.isJSONType=DS;function LS(){let t={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...t,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},t.number,t.string,t.array,t.object],post:{rules:[]},all:{},keywords:{}}}jo.getRules=LS});var Eh=Ie(ss=>{"use strict";Object.defineProperty(ss,"__esModule",{value:!0});ss.shouldUseRule=ss.shouldUseGroup=ss.schemaHasRulesForType=void 0;function ZS({schema:t,self:e},r){let n=e.RULES.types[r];return n&&n!==!0&&D_(t,n)}ss.schemaHasRulesForType=ZS;function D_(t,e){return e.rules.some(r=>L_(t,r))}ss.shouldUseGroup=D_;function L_(t,e){var r;return t[e.keyword]!==void 0||((r=e.definition.implements)===null||r===void 0?void 0:r.some(n=>t[n]!==void 0))}ss.shouldUseRule=L_});var na=Ie(dr=>{"use strict";Object.defineProperty(dr,"__esModule",{value:!0});dr.reportTypeError=dr.checkDataTypes=dr.checkDataType=dr.coerceAndCheckDataType=dr.getJSONTypes=dr.getSchemaTypes=dr.DataType=void 0;var BS=Sh(),qS=Eh(),VS=ra(),st=it(),Z_=mt(),Do;(function(t){t[t.Correct=0]="Correct",t[t.Wrong=1]="Wrong"})(Do||(dr.DataType=Do={}));function FS(t){let e=B_(t.type);if(e.includes("null")){if(t.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!e.length&&t.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');t.nullable===!0&&e.push("null")}return e}dr.getSchemaTypes=FS;function B_(t){let e=Array.isArray(t)?t:t?[t]:[];if(e.every(BS.isJSONType))return e;throw new Error("type must be JSONType or JSONType[]: "+e.join(","))}dr.getJSONTypes=B_;function HS(t,e){let{gen:r,data:n,opts:s}=t,o=US(e,s.coerceTypes),i=e.length>0&&!(o.length===0&&e.length===1&&(0,qS.schemaHasRulesForType)(t,e[0]));if(i){let a=$h(e,n,s.strictNumbers,Do.Wrong);r.if(a,()=>{o.length?GS(t,e,o):Rh(t)})}return i}dr.coerceAndCheckDataType=HS;var q_=new Set(["string","number","integer","boolean","null"]);function US(t,e){return e?t.filter(r=>q_.has(r)||e==="array"&&r==="array"):[]}function GS(t,e,r){let{gen:n,data:s,opts:o}=t,i=n.let("dataType",(0,st._)`typeof ${s}`),a=n.let("coerced",(0,st._)`undefined`);o.coerceTypes==="array"&&n.if((0,st._)`${i} == 'object' && Array.isArray(${s}) && ${s}.length == 1`,()=>n.assign(s,(0,st._)`${s}[0]`).assign(i,(0,st._)`typeof ${s}`).if($h(e,s,o.strictNumbers),()=>n.assign(a,s))),n.if((0,st._)`${a} !== undefined`);for(let d of r)(q_.has(d)||d==="array"&&o.coerceTypes==="array")&&c(d);n.else(),Rh(t),n.endIf(),n.if((0,st._)`${a} !== undefined`,()=>{n.assign(s,a),YS(t,a)});function c(d){switch(d){case"string":n.elseIf((0,st._)`${i} == "number" || ${i} == "boolean"`).assign(a,(0,st._)`"" + ${s}`).elseIf((0,st._)`${s} === null`).assign(a,(0,st._)`""`);return;case"number":n.elseIf((0,st._)`${i} == "boolean" || ${s} === null
|
|
4
|
+
|| (${i} == "string" && ${s} && ${s} == +${s})`).assign(a,(0,st._)`+${s}`);return;case"integer":n.elseIf((0,st._)`${i} === "boolean" || ${s} === null
|
|
5
|
+
|| (${i} === "string" && ${s} && ${s} == +${s} && !(${s} % 1))`).assign(a,(0,st._)`+${s}`);return;case"boolean":n.elseIf((0,st._)`${s} === "false" || ${s} === 0 || ${s} === null`).assign(a,!1).elseIf((0,st._)`${s} === "true" || ${s} === 1`).assign(a,!0);return;case"null":n.elseIf((0,st._)`${s} === "" || ${s} === 0 || ${s} === false`),n.assign(a,null);return;case"array":n.elseIf((0,st._)`${i} === "string" || ${i} === "number"
|
|
6
|
+
|| ${i} === "boolean" || ${s} === null`).assign(a,(0,st._)`[${s}]`)}}}function YS({gen:t,parentData:e,parentDataProperty:r},n){t.if((0,st._)`${e} !== undefined`,()=>t.assign((0,st._)`${e}[${r}]`,n))}function Th(t,e,r,n=Do.Correct){let s=n===Do.Correct?st.operators.EQ:st.operators.NEQ,o;switch(t){case"null":return(0,st._)`${e} ${s} null`;case"array":o=(0,st._)`Array.isArray(${e})`;break;case"object":o=(0,st._)`${e} && typeof ${e} == "object" && !Array.isArray(${e})`;break;case"integer":o=i((0,st._)`!(${e} % 1) && !isNaN(${e})`);break;case"number":o=i();break;default:return(0,st._)`typeof ${e} ${s} ${t}`}return n===Do.Correct?o:(0,st.not)(o);function i(a=st.nil){return(0,st.and)((0,st._)`typeof ${e} == "number"`,a,r?(0,st._)`isFinite(${e})`:st.nil)}}dr.checkDataType=Th;function $h(t,e,r,n){if(t.length===1)return Th(t[0],e,r,n);let s,o=(0,Z_.toHash)(t);if(o.array&&o.object){let i=(0,st._)`typeof ${e} != "object"`;s=o.null?i:(0,st._)`!${e} || ${i}`,delete o.null,delete o.array,delete o.object}else s=st.nil;o.number&&delete o.integer;for(let i in o)s=(0,st.and)(s,Th(i,e,r,n));return s}dr.checkDataTypes=$h;var XS={message:({schema:t})=>`must be ${t}`,params:({schema:t,schemaValue:e})=>typeof t=="string"?(0,st._)`{type: ${t}}`:(0,st._)`{type: ${e}}`};function Rh(t){let e=WS(t);(0,VS.reportError)(e,XS)}dr.reportTypeError=Rh;function WS(t){let{gen:e,data:r,schema:n}=t,s=(0,Z_.schemaRefOrVal)(t,n,"type");return{gen:e,keyword:"type",data:r,schema:n.type,schemaCode:s,schemaValue:s,parentSchema:n,params:{},it:t}}});var F_=Ie(Kc=>{"use strict";Object.defineProperty(Kc,"__esModule",{value:!0});Kc.assignDefaults=void 0;var Lo=it(),KS=mt();function JS(t,e){let{properties:r,items:n}=t.schema;if(e==="object"&&r)for(let s in r)V_(t,s,r[s].default);else e==="array"&&Array.isArray(n)&&n.forEach((s,o)=>V_(t,o,s.default))}Kc.assignDefaults=JS;function V_(t,e,r){let{gen:n,compositeRule:s,data:o,opts:i}=t;if(r===void 0)return;let a=(0,Lo._)`${o}${(0,Lo.getProperty)(e)}`;if(s){(0,KS.checkStrictMode)(t,`default is ignored for: ${a}`);return}let c=(0,Lo._)`${a} === undefined`;i.useDefaults==="empty"&&(c=(0,Lo._)`${c} || ${a} === null || ${a} === ""`),n.if(c,(0,Lo._)`${a} = ${(0,Lo.stringify)(r)}`)}});var Kr=Ie(kt=>{"use strict";Object.defineProperty(kt,"__esModule",{value:!0});kt.validateUnion=kt.validateArray=kt.usePattern=kt.callValidateCode=kt.schemaProperties=kt.allSchemaProperties=kt.noPropertyInData=kt.propertyInData=kt.isOwnProperty=kt.hasPropFunc=kt.reportMissingProp=kt.checkMissingProp=kt.checkReportMissingProp=void 0;var zt=it(),Ph=mt(),os=qn(),QS=mt();function e9(t,e){let{gen:r,data:n,it:s}=t;r.if(zh(r,n,e,s.opts.ownProperties),()=>{t.setParams({missingProperty:(0,zt._)`${e}`},!0),t.error()})}kt.checkReportMissingProp=e9;function t9({gen:t,data:e,it:{opts:r}},n,s){return(0,zt.or)(...n.map(o=>(0,zt.and)(zh(t,e,o,r.ownProperties),(0,zt._)`${s} = ${o}`)))}kt.checkMissingProp=t9;function r9(t,e){t.setParams({missingProperty:e},!0),t.error()}kt.reportMissingProp=r9;function H_(t){return t.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,zt._)`Object.prototype.hasOwnProperty`})}kt.hasPropFunc=H_;function Mh(t,e,r){return(0,zt._)`${H_(t)}.call(${e}, ${r})`}kt.isOwnProperty=Mh;function n9(t,e,r,n){let s=(0,zt._)`${e}${(0,zt.getProperty)(r)} !== undefined`;return n?(0,zt._)`${s} && ${Mh(t,e,r)}`:s}kt.propertyInData=n9;function zh(t,e,r,n){let s=(0,zt._)`${e}${(0,zt.getProperty)(r)} === undefined`;return n?(0,zt.or)(s,(0,zt.not)(Mh(t,e,r))):s}kt.noPropertyInData=zh;function U_(t){return t?Object.keys(t).filter(e=>e!=="__proto__"):[]}kt.allSchemaProperties=U_;function s9(t,e){return U_(e).filter(r=>!(0,Ph.alwaysValidSchema)(t,e[r]))}kt.schemaProperties=s9;function o9({schemaCode:t,data:e,it:{gen:r,topSchemaRef:n,schemaPath:s,errorPath:o},it:i},a,c,d){let l=d?(0,zt._)`${t}, ${e}, ${n}${s}`:e,u=[[os.default.instancePath,(0,zt.strConcat)(os.default.instancePath,o)],[os.default.parentData,i.parentData],[os.default.parentDataProperty,i.parentDataProperty],[os.default.rootData,os.default.rootData]];i.opts.dynamicRef&&u.push([os.default.dynamicAnchors,os.default.dynamicAnchors]);let h=(0,zt._)`${l}, ${r.object(...u)}`;return c!==zt.nil?(0,zt._)`${a}.call(${c}, ${h})`:(0,zt._)`${a}(${h})`}kt.callValidateCode=o9;var i9=(0,zt._)`new RegExp`;function a9({gen:t,it:{opts:e}},r){let n=e.unicodeRegExp?"u":"",{regExp:s}=e.code,o=s(r,n);return t.scopeValue("pattern",{key:o.toString(),ref:o,code:(0,zt._)`${s.code==="new RegExp"?i9:(0,QS.useFunc)(t,s)}(${r}, ${n})`})}kt.usePattern=a9;function c9(t){let{gen:e,data:r,keyword:n,it:s}=t,o=e.name("valid");if(s.allErrors){let a=e.let("valid",!0);return i(()=>e.assign(a,!1)),a}return e.var(o,!0),i(()=>e.break()),o;function i(a){let c=e.const("len",(0,zt._)`${r}.length`);e.forRange("i",0,c,d=>{t.subschema({keyword:n,dataProp:d,dataPropType:Ph.Type.Num},o),e.if((0,zt.not)(o),a)})}}kt.validateArray=c9;function l9(t){let{gen:e,schema:r,keyword:n,it:s}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(r.some(c=>(0,Ph.alwaysValidSchema)(s,c))&&!s.opts.unevaluated)return;let i=e.let("valid",!1),a=e.name("_valid");e.block(()=>r.forEach((c,d)=>{let l=t.subschema({keyword:n,schemaProp:d,compositeRule:!0},a);e.assign(i,(0,zt._)`${i} || ${a}`),t.mergeValidEvaluated(l,a)||e.if((0,zt.not)(i))})),t.result(i,()=>t.reset(),()=>t.error(!0))}kt.validateUnion=l9});var X_=Ie(Rn=>{"use strict";Object.defineProperty(Rn,"__esModule",{value:!0});Rn.validateKeywordUsage=Rn.validSchemaType=Rn.funcKeywordCode=Rn.macroKeywordCode=void 0;var _r=it(),Ws=qn(),u9=Kr(),d9=ra();function f9(t,e){let{gen:r,keyword:n,schema:s,parentSchema:o,it:i}=t,a=e.macro.call(i.self,s,o,i),c=Y_(r,n,a);i.opts.validateSchema!==!1&&i.self.validateSchema(a,!0);let d=r.name("valid");t.subschema({schema:a,schemaPath:_r.nil,errSchemaPath:`${i.errSchemaPath}/${n}`,topSchemaRef:c,compositeRule:!0},d),t.pass(d,()=>t.error(!0))}Rn.macroKeywordCode=f9;function h9(t,e){var r;let{gen:n,keyword:s,schema:o,parentSchema:i,$data:a,it:c}=t;m9(c,e);let d=!a&&e.compile?e.compile.call(c.self,o,i,c):e.validate,l=Y_(n,s,d),u=n.let("valid");t.block$data(u,h),t.ok((r=e.valid)!==null&&r!==void 0?r:u);function h(){if(e.errors===!1)x(),e.modifying&&G_(t),S(()=>t.error());else{let k=e.async?p():g();e.modifying&&G_(t),S(()=>p9(t,k))}}function p(){let k=n.let("ruleErrs",null);return n.try(()=>x((0,_r._)`await `),_=>n.assign(u,!1).if((0,_r._)`${_} instanceof ${c.ValidationError}`,()=>n.assign(k,(0,_r._)`${_}.errors`),()=>n.throw(_))),k}function g(){let k=(0,_r._)`${l}.errors`;return n.assign(k,null),x(_r.nil),k}function x(k=e.async?(0,_r._)`await `:_r.nil){let _=c.opts.passContext?Ws.default.this:Ws.default.self,m=!("compile"in e&&!a||e.schema===!1);n.assign(u,(0,_r._)`${k}${(0,u9.callValidateCode)(t,l,_,m)}`,e.modifying)}function S(k){var _;n.if((0,_r.not)((_=e.valid)!==null&&_!==void 0?_:u),k)}}Rn.funcKeywordCode=h9;function G_(t){let{gen:e,data:r,it:n}=t;e.if(n.parentData,()=>e.assign(r,(0,_r._)`${n.parentData}[${n.parentDataProperty}]`))}function p9(t,e){let{gen:r}=t;r.if((0,_r._)`Array.isArray(${e})`,()=>{r.assign(Ws.default.vErrors,(0,_r._)`${Ws.default.vErrors} === null ? ${e} : ${Ws.default.vErrors}.concat(${e})`).assign(Ws.default.errors,(0,_r._)`${Ws.default.vErrors}.length`),(0,d9.extendErrors)(t)},()=>t.error())}function m9({schemaEnv:t},e){if(e.async&&!t.$async)throw new Error("async keyword in sync schema")}function Y_(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,_r.stringify)(r)})}function g9(t,e,r=!1){return!e.length||e.some(n=>n==="array"?Array.isArray(t):n==="object"?t&&typeof t=="object"&&!Array.isArray(t):typeof t==n||r&&typeof t>"u")}Rn.validSchemaType=g9;function _9({schema:t,opts:e,self:r,errSchemaPath:n},s,o){if(Array.isArray(s.keyword)?!s.keyword.includes(o):s.keyword!==o)throw new Error("ajv implementation error");let i=s.dependencies;if(i?.some(a=>!Object.prototype.hasOwnProperty.call(t,a)))throw new Error(`parent schema must have dependencies of ${o}: ${i.join(",")}`);if(s.validateSchema&&!s.validateSchema(t[o])){let c=`keyword "${o}" value is invalid at path "${n}": `+r.errorsText(s.validateSchema.errors);if(e.validateSchema==="log")r.logger.error(c);else throw new Error(c)}}Rn.validateKeywordUsage=_9});var K_=Ie(is=>{"use strict";Object.defineProperty(is,"__esModule",{value:!0});is.extendSubschemaMode=is.extendSubschemaData=is.getSubschema=void 0;var Pn=it(),W_=mt();function b9(t,{keyword:e,schemaProp:r,schema:n,schemaPath:s,errSchemaPath:o,topSchemaRef:i}){if(e!==void 0&&n!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(e!==void 0){let a=t.schema[e];return r===void 0?{schema:a,schemaPath:(0,Pn._)`${t.schemaPath}${(0,Pn.getProperty)(e)}`,errSchemaPath:`${t.errSchemaPath}/${e}`}:{schema:a[r],schemaPath:(0,Pn._)`${t.schemaPath}${(0,Pn.getProperty)(e)}${(0,Pn.getProperty)(r)}`,errSchemaPath:`${t.errSchemaPath}/${e}/${(0,W_.escapeFragment)(r)}`}}if(n!==void 0){if(s===void 0||o===void 0||i===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:n,schemaPath:s,topSchemaRef:i,errSchemaPath:o}}throw new Error('either "keyword" or "schema" must be passed')}is.getSubschema=b9;function y9(t,e,{dataProp:r,dataPropType:n,data:s,dataTypes:o,propertyName:i}){if(s!==void 0&&r!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');let{gen:a}=e;if(r!==void 0){let{errorPath:d,dataPathArr:l,opts:u}=e,h=a.let("data",(0,Pn._)`${e.data}${(0,Pn.getProperty)(r)}`,!0);c(h),t.errorPath=(0,Pn.str)`${d}${(0,W_.getErrorPath)(r,n,u.jsPropertySyntax)}`,t.parentDataProperty=(0,Pn._)`${r}`,t.dataPathArr=[...l,t.parentDataProperty]}if(s!==void 0){let d=s instanceof Pn.Name?s:a.let("data",s,!0);c(d),i!==void 0&&(t.propertyName=i)}o&&(t.dataTypes=o);function c(d){t.data=d,t.dataLevel=e.dataLevel+1,t.dataTypes=[],e.definedProperties=new Set,t.parentData=e.data,t.dataNames=[...e.dataNames,d]}}is.extendSubschemaData=y9;function v9(t,{jtdDiscriminator:e,jtdMetadata:r,compositeRule:n,createErrors:s,allErrors:o}){n!==void 0&&(t.compositeRule=n),s!==void 0&&(t.createErrors=s),o!==void 0&&(t.allErrors=o),t.jtdDiscriminator=e,t.jtdMetadata=r}is.extendSubschemaMode=v9});var Ih=Ie((tL,J_)=>{"use strict";J_.exports=function t(e,r){if(e===r)return!0;if(e&&r&&typeof e=="object"&&typeof r=="object"){if(e.constructor!==r.constructor)return!1;var n,s,o;if(Array.isArray(e)){if(n=e.length,n!=r.length)return!1;for(s=n;s--!==0;)if(!t(e[s],r[s]))return!1;return!0}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),n=o.length,n!==Object.keys(r).length)return!1;for(s=n;s--!==0;)if(!Object.prototype.hasOwnProperty.call(r,o[s]))return!1;for(s=n;s--!==0;){var i=o[s];if(!t(e[i],r[i]))return!1}return!0}return e!==e&&r!==r}});var e2=Ie((rL,Q_)=>{"use strict";var as=Q_.exports=function(t,e,r){typeof e=="function"&&(r=e,e={}),r=e.cb||r;var n=typeof r=="function"?r:r.pre||function(){},s=r.post||function(){};Jc(e,n,s,t,"",t)};as.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};as.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};as.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};as.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function Jc(t,e,r,n,s,o,i,a,c,d){if(n&&typeof n=="object"&&!Array.isArray(n)){e(n,s,o,i,a,c,d);for(var l in n){var u=n[l];if(Array.isArray(u)){if(l in as.arrayKeywords)for(var h=0;h<u.length;h++)Jc(t,e,r,u[h],s+"/"+l+"/"+h,o,s,l,n,h)}else if(l in as.propsKeywords){if(u&&typeof u=="object")for(var p in u)Jc(t,e,r,u[p],s+"/"+l+"/"+w9(p),o,s,l,n,p)}else(l in as.keywords||t.allKeys&&!(l in as.skipKeywords))&&Jc(t,e,r,u,s+"/"+l,o,s,l,n)}r(n,s,o,i,a,c,d)}}function w9(t){return t.replace(/~/g,"~0").replace(/\//g,"~1")}});var sa=Ie($r=>{"use strict";Object.defineProperty($r,"__esModule",{value:!0});$r.getSchemaRefs=$r.resolveUrl=$r.normalizeId=$r._getFullPath=$r.getFullPath=$r.inlineRef=void 0;var x9=mt(),k9=Ih(),S9=e2(),E9=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function T9(t,e=!0){return typeof t=="boolean"?!0:e===!0?!Oh(t):e?t2(t)<=e:!1}$r.inlineRef=T9;var $9=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function Oh(t){for(let e in t){if($9.has(e))return!0;let r=t[e];if(Array.isArray(r)&&r.some(Oh)||typeof r=="object"&&Oh(r))return!0}return!1}function t2(t){let e=0;for(let r in t){if(r==="$ref")return 1/0;if(e++,!E9.has(r)&&(typeof t[r]=="object"&&(0,x9.eachItem)(t[r],n=>e+=t2(n)),e===1/0))return 1/0}return e}function r2(t,e="",r){r!==!1&&(e=Zo(e));let n=t.parse(e);return n2(t,n)}$r.getFullPath=r2;function n2(t,e){return t.serialize(e).split("#")[0]+"#"}$r._getFullPath=n2;var R9=/#\/?$/;function Zo(t){return t?t.replace(R9,""):""}$r.normalizeId=Zo;function P9(t,e,r){return r=Zo(r),t.resolve(e,r)}$r.resolveUrl=P9;var M9=/^[a-z_][-a-z0-9._]*$/i;function z9(t,e){if(typeof t=="boolean")return{};let{schemaId:r,uriResolver:n}=this.opts,s=Zo(t[r]||e),o={"":s},i=r2(n,s,!1),a={},c=new Set;return S9(t,{allKeys:!0},(u,h,p,g)=>{if(g===void 0)return;let x=i+h,S=o[g];typeof u[r]=="string"&&(S=k.call(this,u[r])),_.call(this,u.$anchor),_.call(this,u.$dynamicAnchor),o[h]=S;function k(m){let $=this.opts.uriResolver.resolve;if(m=Zo(S?$(S,m):m),c.has(m))throw l(m);c.add(m);let f=this.refs[m];return typeof f=="string"&&(f=this.refs[f]),typeof f=="object"?d(u,f.schema,m):m!==Zo(x)&&(m[0]==="#"?(d(u,a[m],m),a[m]=u):this.refs[m]=x),m}function _(m){if(typeof m=="string"){if(!M9.test(m))throw new Error(`invalid anchor "${m}"`);k.call(this,`#${m}`)}}}),a;function d(u,h,p){if(h!==void 0&&!k9(u,h))throw l(p)}function l(u){return new Error(`reference "${u}" resolves to more than one schema`)}}$r.getSchemaRefs=z9});var aa=Ie(cs=>{"use strict";Object.defineProperty(cs,"__esModule",{value:!0});cs.getData=cs.KeywordCxt=cs.validateFunctionCode=void 0;var c2=j_(),s2=na(),Nh=Eh(),Qc=na(),I9=F_(),ia=X_(),Ah=K_(),Fe=it(),Je=qn(),O9=sa(),Vn=mt(),oa=ra();function A9(t){if(d2(t)&&(f2(t),u2(t))){j9(t);return}l2(t,()=>(0,c2.topBoolOrEmptySchema)(t))}cs.validateFunctionCode=A9;function l2({gen:t,validateName:e,schema:r,schemaEnv:n,opts:s},o){s.code.es5?t.func(e,(0,Fe._)`${Je.default.data}, ${Je.default.valCxt}`,n.$async,()=>{t.code((0,Fe._)`"use strict"; ${o2(r,s)}`),C9(t,s),t.code(o)}):t.func(e,(0,Fe._)`${Je.default.data}, ${N9(s)}`,n.$async,()=>t.code(o2(r,s)).code(o))}function N9(t){return(0,Fe._)`{${Je.default.instancePath}="", ${Je.default.parentData}, ${Je.default.parentDataProperty}, ${Je.default.rootData}=${Je.default.data}${t.dynamicRef?(0,Fe._)`, ${Je.default.dynamicAnchors}={}`:Fe.nil}}={}`}function C9(t,e){t.if(Je.default.valCxt,()=>{t.var(Je.default.instancePath,(0,Fe._)`${Je.default.valCxt}.${Je.default.instancePath}`),t.var(Je.default.parentData,(0,Fe._)`${Je.default.valCxt}.${Je.default.parentData}`),t.var(Je.default.parentDataProperty,(0,Fe._)`${Je.default.valCxt}.${Je.default.parentDataProperty}`),t.var(Je.default.rootData,(0,Fe._)`${Je.default.valCxt}.${Je.default.rootData}`),e.dynamicRef&&t.var(Je.default.dynamicAnchors,(0,Fe._)`${Je.default.valCxt}.${Je.default.dynamicAnchors}`)},()=>{t.var(Je.default.instancePath,(0,Fe._)`""`),t.var(Je.default.parentData,(0,Fe._)`undefined`),t.var(Je.default.parentDataProperty,(0,Fe._)`undefined`),t.var(Je.default.rootData,Je.default.data),e.dynamicRef&&t.var(Je.default.dynamicAnchors,(0,Fe._)`{}`)})}function j9(t){let{schema:e,opts:r,gen:n}=t;l2(t,()=>{r.$comment&&e.$comment&&p2(t),q9(t),n.let(Je.default.vErrors,null),n.let(Je.default.errors,0),r.unevaluated&&D9(t),h2(t),H9(t)})}function D9(t){let{gen:e,validateName:r}=t;t.evaluated=e.const("evaluated",(0,Fe._)`${r}.evaluated`),e.if((0,Fe._)`${t.evaluated}.dynamicProps`,()=>e.assign((0,Fe._)`${t.evaluated}.props`,(0,Fe._)`undefined`)),e.if((0,Fe._)`${t.evaluated}.dynamicItems`,()=>e.assign((0,Fe._)`${t.evaluated}.items`,(0,Fe._)`undefined`))}function o2(t,e){let r=typeof t=="object"&&t[e.schemaId];return r&&(e.code.source||e.code.process)?(0,Fe._)`/*# sourceURL=${r} */`:Fe.nil}function L9(t,e){if(d2(t)&&(f2(t),u2(t))){Z9(t,e);return}(0,c2.boolOrEmptySchema)(t,e)}function u2({schema:t,self:e}){if(typeof t=="boolean")return!t;for(let r in t)if(e.RULES.all[r])return!0;return!1}function d2(t){return typeof t.schema!="boolean"}function Z9(t,e){let{schema:r,gen:n,opts:s}=t;s.$comment&&r.$comment&&p2(t),V9(t),F9(t);let o=n.const("_errs",Je.default.errors);h2(t,o),n.var(e,(0,Fe._)`${o} === ${Je.default.errors}`)}function f2(t){(0,Vn.checkUnknownRules)(t),B9(t)}function h2(t,e){if(t.opts.jtd)return i2(t,[],!1,e);let r=(0,s2.getSchemaTypes)(t.schema),n=(0,s2.coerceAndCheckDataType)(t,r);i2(t,r,!n,e)}function B9(t){let{schema:e,errSchemaPath:r,opts:n,self:s}=t;e.$ref&&n.ignoreKeywordsWithRef&&(0,Vn.schemaHasRulesButRef)(e,s.RULES)&&s.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function q9(t){let{schema:e,opts:r}=t;e.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,Vn.checkStrictMode)(t,"default is ignored in the schema root")}function V9(t){let e=t.schema[t.opts.schemaId];e&&(t.baseId=(0,O9.resolveUrl)(t.opts.uriResolver,t.baseId,e))}function F9(t){if(t.schema.$async&&!t.schemaEnv.$async)throw new Error("async schema in sync schema")}function p2({gen:t,schemaEnv:e,schema:r,errSchemaPath:n,opts:s}){let o=r.$comment;if(s.$comment===!0)t.code((0,Fe._)`${Je.default.self}.logger.log(${o})`);else if(typeof s.$comment=="function"){let i=(0,Fe.str)`${n}/$comment`,a=t.scopeValue("root",{ref:e.root});t.code((0,Fe._)`${Je.default.self}.opts.$comment(${o}, ${i}, ${a}.schema)`)}}function H9(t){let{gen:e,schemaEnv:r,validateName:n,ValidationError:s,opts:o}=t;r.$async?e.if((0,Fe._)`${Je.default.errors} === 0`,()=>e.return(Je.default.data),()=>e.throw((0,Fe._)`new ${s}(${Je.default.vErrors})`)):(e.assign((0,Fe._)`${n}.errors`,Je.default.vErrors),o.unevaluated&&U9(t),e.return((0,Fe._)`${Je.default.errors} === 0`))}function U9({gen:t,evaluated:e,props:r,items:n}){r instanceof Fe.Name&&t.assign((0,Fe._)`${e}.props`,r),n instanceof Fe.Name&&t.assign((0,Fe._)`${e}.items`,n)}function i2(t,e,r,n){let{gen:s,schema:o,data:i,allErrors:a,opts:c,self:d}=t,{RULES:l}=d;if(o.$ref&&(c.ignoreKeywordsWithRef||!(0,Vn.schemaHasRulesButRef)(o,l))){s.block(()=>g2(t,"$ref",l.all.$ref.definition));return}c.jtd||G9(t,e),s.block(()=>{for(let h of l.rules)u(h);u(l.post)});function u(h){(0,Nh.shouldUseGroup)(o,h)&&(h.type?(s.if((0,Qc.checkDataType)(h.type,i,c.strictNumbers)),a2(t,h),e.length===1&&e[0]===h.type&&r&&(s.else(),(0,Qc.reportTypeError)(t)),s.endIf()):a2(t,h),a||s.if((0,Fe._)`${Je.default.errors} === ${n||0}`))}}function a2(t,e){let{gen:r,schema:n,opts:{useDefaults:s}}=t;s&&(0,I9.assignDefaults)(t,e.type),r.block(()=>{for(let o of e.rules)(0,Nh.shouldUseRule)(n,o)&&g2(t,o.keyword,o.definition,e.type)})}function G9(t,e){t.schemaEnv.meta||!t.opts.strictTypes||(Y9(t,e),t.opts.allowUnionTypes||X9(t,e),W9(t,t.dataTypes))}function Y9(t,e){if(e.length){if(!t.dataTypes.length){t.dataTypes=e;return}e.forEach(r=>{m2(t.dataTypes,r)||Ch(t,`type "${r}" not allowed by context "${t.dataTypes.join(",")}"`)}),J9(t,e)}}function X9(t,e){e.length>1&&!(e.length===2&&e.includes("null"))&&Ch(t,"use allowUnionTypes to allow union type keyword")}function W9(t,e){let r=t.self.RULES.all;for(let n in r){let s=r[n];if(typeof s=="object"&&(0,Nh.shouldUseRule)(t.schema,s)){let{type:o}=s.definition;o.length&&!o.some(i=>K9(e,i))&&Ch(t,`missing type "${o.join(",")}" for keyword "${n}"`)}}}function K9(t,e){return t.includes(e)||e==="number"&&t.includes("integer")}function m2(t,e){return t.includes(e)||e==="integer"&&t.includes("number")}function J9(t,e){let r=[];for(let n of t.dataTypes)m2(e,n)?r.push(n):e.includes("integer")&&n==="number"&&r.push("integer");t.dataTypes=r}function Ch(t,e){let r=t.schemaEnv.baseId+t.errSchemaPath;e+=` at "${r}" (strictTypes)`,(0,Vn.checkStrictMode)(t,e,t.opts.strictTypes)}var el=class{constructor(e,r,n){if((0,ia.validateKeywordUsage)(e,r,n),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=n,this.data=e.data,this.schema=e.schema[n],this.$data=r.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,Vn.schemaRefOrVal)(e,this.schema,n,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",_2(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,ia.validSchemaType)(this.schema,r.schemaType,r.allowUndefined))throw new Error(`${n} value must be ${JSON.stringify(r.schemaType)}`);("code"in r?r.trackErrors:r.errors!==!1)&&(this.errsCount=e.gen.const("_errs",Je.default.errors))}result(e,r,n){this.failResult((0,Fe.not)(e),r,n)}failResult(e,r,n){this.gen.if(e),n?n():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,Fe.not)(e),void 0,r)}fail(e){if(e===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(e),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(e){if(!this.$data)return this.fail(e);let{schemaCode:r}=this;this.fail((0,Fe._)`${r} !== undefined && (${(0,Fe.or)(this.invalid$data(),e)})`)}error(e,r,n){if(r){this.setParams(r),this._error(e,n),this.setParams({});return}this._error(e,n)}_error(e,r){(e?oa.reportExtraError:oa.reportError)(this,this.def.error,r)}$dataError(){(0,oa.reportError)(this,this.def.$dataError||oa.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,oa.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,n=Fe.nil){this.gen.block(()=>{this.check$data(e,n),r()})}check$data(e=Fe.nil,r=Fe.nil){if(!this.$data)return;let{gen:n,schemaCode:s,schemaType:o,def:i}=this;n.if((0,Fe.or)((0,Fe._)`${s} === undefined`,r)),e!==Fe.nil&&n.assign(e,!0),(o.length||i.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),e!==Fe.nil&&n.assign(e,!1)),n.else()}invalid$data(){let{gen:e,schemaCode:r,schemaType:n,def:s,it:o}=this;return(0,Fe.or)(i(),a());function i(){if(n.length){if(!(r instanceof Fe.Name))throw new Error("ajv implementation error");let c=Array.isArray(n)?n:[n];return(0,Fe._)`${(0,Qc.checkDataTypes)(c,r,o.opts.strictNumbers,Qc.DataType.Wrong)}`}return Fe.nil}function a(){if(s.validateSchema){let c=e.scopeValue("validate$data",{ref:s.validateSchema});return(0,Fe._)`!${c}(${r})`}return Fe.nil}}subschema(e,r){let n=(0,Ah.getSubschema)(this.it,e);(0,Ah.extendSubschemaData)(n,this.it,e),(0,Ah.extendSubschemaMode)(n,e);let s={...this.it,...n,items:void 0,props:void 0};return L9(s,r),s}mergeEvaluated(e,r){let{it:n,gen:s}=this;n.opts.unevaluated&&(n.props!==!0&&e.props!==void 0&&(n.props=Vn.mergeEvaluated.props(s,e.props,n.props,r)),n.items!==!0&&e.items!==void 0&&(n.items=Vn.mergeEvaluated.items(s,e.items,n.items,r)))}mergeValidEvaluated(e,r){let{it:n,gen:s}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return s.if(r,()=>this.mergeEvaluated(e,Fe.Name)),!0}};cs.KeywordCxt=el;function g2(t,e,r,n){let s=new el(t,r,e);"code"in r?r.code(s,n):s.$data&&r.validate?(0,ia.funcKeywordCode)(s,r):"macro"in r?(0,ia.macroKeywordCode)(s,r):(r.compile||r.validate)&&(0,ia.funcKeywordCode)(s,r)}var Q9=/^\/(?:[^~]|~0|~1)*$/,e8=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function _2(t,{dataLevel:e,dataNames:r,dataPathArr:n}){let s,o;if(t==="")return Je.default.rootData;if(t[0]==="/"){if(!Q9.test(t))throw new Error(`Invalid JSON-pointer: ${t}`);s=t,o=Je.default.rootData}else{let d=e8.exec(t);if(!d)throw new Error(`Invalid JSON-pointer: ${t}`);let l=+d[1];if(s=d[2],s==="#"){if(l>=e)throw new Error(c("property/index",l));return n[e-l]}if(l>e)throw new Error(c("data",l));if(o=r[e-l],!s)return o}let i=o,a=s.split("/");for(let d of a)d&&(o=(0,Fe._)`${o}${(0,Fe.getProperty)((0,Vn.unescapeJsonPointer)(d))}`,i=(0,Fe._)`${i} && ${o}`);return i;function c(d,l){return`Cannot access ${d} ${l} levels up, current level is ${e}`}}cs.getData=_2});var tl=Ie(Dh=>{"use strict";Object.defineProperty(Dh,"__esModule",{value:!0});var jh=class extends Error{constructor(e){super("validation failed"),this.errors=e,this.ajv=this.validation=!0}};Dh.default=jh});var ca=Ie(Bh=>{"use strict";Object.defineProperty(Bh,"__esModule",{value:!0});var Lh=sa(),Zh=class extends Error{constructor(e,r,n,s){super(s||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,Lh.resolveUrl)(e,r,n),this.missingSchema=(0,Lh.normalizeId)((0,Lh.getFullPath)(e,this.missingRef))}};Bh.default=Zh});var nl=Ie(Jr=>{"use strict";Object.defineProperty(Jr,"__esModule",{value:!0});Jr.resolveSchema=Jr.getCompilingSchema=Jr.resolveRef=Jr.compileSchema=Jr.SchemaEnv=void 0;var pn=it(),t8=tl(),Ks=qn(),mn=sa(),b2=mt(),r8=aa(),Bo=class{constructor(e){var r;this.refs={},this.dynamicAnchors={};let n;typeof e.schema=="object"&&(n=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,mn.normalizeId)(n?.[e.schemaId||"$id"]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=n?.$async,this.refs={}}};Jr.SchemaEnv=Bo;function Vh(t){let e=y2.call(this,t);if(e)return e;let r=(0,mn.getFullPath)(this.opts.uriResolver,t.root.baseId),{es5:n,lines:s}=this.opts.code,{ownProperties:o}=this.opts,i=new pn.CodeGen(this.scope,{es5:n,lines:s,ownProperties:o}),a;t.$async&&(a=i.scopeValue("Error",{ref:t8.default,code:(0,pn._)`require("ajv/dist/runtime/validation_error").default`}));let c=i.scopeName("validate");t.validateName=c;let d={gen:i,allErrors:this.opts.allErrors,data:Ks.default.data,parentData:Ks.default.parentData,parentDataProperty:Ks.default.parentDataProperty,dataNames:[Ks.default.data],dataPathArr:[pn.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:i.scopeValue("schema",this.opts.code.source===!0?{ref:t.schema,code:(0,pn.stringify)(t.schema)}:{ref:t.schema}),validateName:c,ValidationError:a,schema:t.schema,schemaEnv:t,rootId:r,baseId:t.baseId||r,schemaPath:pn.nil,errSchemaPath:t.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,pn._)`""`,opts:this.opts,self:this},l;try{this._compilations.add(t),(0,r8.validateFunctionCode)(d),i.optimize(this.opts.code.optimize);let u=i.toString();l=`${i.scopeRefs(Ks.default.scope)}return ${u}`,this.opts.code.process&&(l=this.opts.code.process(l,t));let p=new Function(`${Ks.default.self}`,`${Ks.default.scope}`,l)(this,this.scope.get());if(this.scope.value(c,{ref:p}),p.errors=null,p.schema=t.schema,p.schemaEnv=t,t.$async&&(p.$async=!0),this.opts.code.source===!0&&(p.source={validateName:c,validateCode:u,scopeValues:i._values}),this.opts.unevaluated){let{props:g,items:x}=d;p.evaluated={props:g instanceof pn.Name?void 0:g,items:x instanceof pn.Name?void 0:x,dynamicProps:g instanceof pn.Name,dynamicItems:x instanceof pn.Name},p.source&&(p.source.evaluated=(0,pn.stringify)(p.evaluated))}return t.validate=p,t}catch(u){throw delete t.validate,delete t.validateName,l&&this.logger.error("Error compiling schema, function code:",l),u}finally{this._compilations.delete(t)}}Jr.compileSchema=Vh;function n8(t,e,r){var n;r=(0,mn.resolveUrl)(this.opts.uriResolver,e,r);let s=t.refs[r];if(s)return s;let o=i8.call(this,t,r);if(o===void 0){let i=(n=t.localRefs)===null||n===void 0?void 0:n[r],{schemaId:a}=this.opts;i&&(o=new Bo({schema:i,schemaId:a,root:t,baseId:e}))}if(o!==void 0)return t.refs[r]=s8.call(this,o)}Jr.resolveRef=n8;function s8(t){return(0,mn.inlineRef)(t.schema,this.opts.inlineRefs)?t.schema:t.validate?t:Vh.call(this,t)}function y2(t){for(let e of this._compilations)if(o8(e,t))return e}Jr.getCompilingSchema=y2;function o8(t,e){return t.schema===e.schema&&t.root===e.root&&t.baseId===e.baseId}function i8(t,e){let r;for(;typeof(r=this.refs[e])=="string";)e=r;return r||this.schemas[e]||rl.call(this,t,e)}function rl(t,e){let r=this.opts.uriResolver.parse(e),n=(0,mn._getFullPath)(this.opts.uriResolver,r),s=(0,mn.getFullPath)(this.opts.uriResolver,t.baseId,void 0);if(Object.keys(t.schema).length>0&&n===s)return qh.call(this,r,t);let o=(0,mn.normalizeId)(n),i=this.refs[o]||this.schemas[o];if(typeof i=="string"){let a=rl.call(this,t,i);return typeof a?.schema!="object"?void 0:qh.call(this,r,a)}if(typeof i?.schema=="object"){if(i.validate||Vh.call(this,i),o===(0,mn.normalizeId)(e)){let{schema:a}=i,{schemaId:c}=this.opts,d=a[c];return d&&(s=(0,mn.resolveUrl)(this.opts.uriResolver,s,d)),new Bo({schema:a,schemaId:c,root:t,baseId:s})}return qh.call(this,r,i)}}Jr.resolveSchema=rl;var a8=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function qh(t,{baseId:e,schema:r,root:n}){var s;if(((s=t.fragment)===null||s===void 0?void 0:s[0])!=="/")return;for(let a of t.fragment.slice(1).split("/")){if(typeof r=="boolean")return;let c=r[(0,b2.unescapeFragment)(a)];if(c===void 0)return;r=c;let d=typeof r=="object"&&r[this.opts.schemaId];!a8.has(a)&&d&&(e=(0,mn.resolveUrl)(this.opts.uriResolver,e,d))}let o;if(typeof r!="boolean"&&r.$ref&&!(0,b2.schemaHasRulesButRef)(r,this.RULES)){let a=(0,mn.resolveUrl)(this.opts.uriResolver,e,r.$ref);o=rl.call(this,n,a)}let{schemaId:i}=this.opts;if(o=o||new Bo({schema:r,schemaId:i,root:n,baseId:e}),o.schema!==o.root.schema)return o}});var v2=Ie((cL,c8)=>{c8.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:!1}});var Uh=Ie((lL,T2)=>{"use strict";var l8=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),x2=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),Fh=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),k2=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),u8=RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);function Hh(t){let e="",r=0,n=0;for(n=0;n<t.length;n++)if(r=t[n].charCodeAt(0),r!==48){if(!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";e+=t[n];break}for(n+=1;n<t.length;n++){if(r=t[n].charCodeAt(0),!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";e+=t[n]}return e}var d8=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function w2(t){return t.length=0,!0}function f8(t,e,r){if(t.length){let n=Hh(t);if(n!=="")e.push(n);else return r.error=!0,!1;t.length=0}return!0}function h8(t){let e=0,r={error:!1,address:"",zone:""},n=[],s=[],o=!1,i=!1,a=f8;for(let c=0;c<t.length;c++){let d=t[c];if(!(d==="["||d==="]"))if(d===":"){if(o===!0&&(i=!0),!a(s,n,r))break;if(++e>7){r.error=!0;break}c>0&&t[c-1]===":"&&(o=!0),n.push(":");continue}else if(d==="%"){if(!a(s,n,r))break;a=w2}else{s.push(d);continue}}return s.length&&(a===w2?r.zone=s.join(""):i?n.push(s.join("")):n.push(Hh(s))),r.address=n.join(""),r}function S2(t){if(p8(t,":")<2)return{host:t,isIPV6:!1};let e=h8(t);if(e.error)return{host:t,isIPV6:!1};{let r=e.address,n=e.address;return e.zone&&(r+="%"+e.zone,n+="%25"+e.zone),{host:r,isIPV6:!0,escapedHost:n}}}function p8(t,e){let r=0;for(let n=0;n<t.length;n++)t[n]===e&&r++;return r}function m8(t){let e=t,r=[],n=-1,s=0;for(;s=e.length;){if(s===1){if(e===".")break;if(e==="/"){r.push("/");break}else{r.push(e);break}}else if(s===2){if(e[0]==="."){if(e[1]===".")break;if(e[1]==="/"){e=e.slice(2);continue}}else if(e[0]==="/"&&(e[1]==="."||e[1]==="/")){r.push("/");break}}else if(s===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((n=e.indexOf("/",1))===-1){r.push(e);break}else r.push(e.slice(0,n)),e=e.slice(n)}return r.join("")}var g8={"@":"%40","/":"%2F","?":"%3F","#":"%23",":":"%3A"},_8=/[@/?#:]/g,b8=/[@/?#]/g;function E2(t,e){let r=e?b8:_8;return r.lastIndex=0,t.replace(r,n=>g8[n])}function y8(t,e=!1){if(t.indexOf("%")===-1)return t;let r="";for(let n=0;n<t.length;n++){if(t[n]==="%"&&n+2<t.length){let s=t.slice(n+1,n+3);if(Fh(s)){let o=s.toUpperCase(),i=String.fromCharCode(parseInt(o,16));e&&k2(i)?r+=i:r+="%"+o,n+=2;continue}}r+=t[n]}return r}function v8(t){let e="";for(let r=0;r<t.length;r++){if(t[r]==="%"&&r+2<t.length){let n=t.slice(r+1,r+3);if(Fh(n)){let s=n.toUpperCase(),o=String.fromCharCode(parseInt(s,16));o!=="."&&k2(o)?e+=o:e+="%"+s,r+=2;continue}}u8(t[r])?e+=t[r]:e+=escape(t[r])}return e}function w8(t){let e="";for(let r=0;r<t.length;r++){if(t[r]==="%"&&r+2<t.length){let n=t.slice(r+1,r+3);if(Fh(n)){e+="%"+n.toUpperCase(),r+=2;continue}}e+=escape(t[r])}return e}function x8(t){let e=[];if(t.userinfo!==void 0&&(e.push(t.userinfo),e.push("@")),t.host!==void 0){let r=unescape(t.host);if(!x2(r)){let n=S2(r);n.isIPV6===!0?r=`[${n.escapedHost}]`:r=E2(r,!1)}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}T2.exports={nonSimpleDomain:d8,recomposeAuthority:x8,reescapeHostDelimiters:E2,normalizePercentEncoding:y8,normalizePathEncoding:v8,escapePreservingEscapes:w8,removeDotSegments:m8,isIPv4:x2,isUUID:l8,normalizeIPv6:S2,stringArrayToHexStripped:Hh}});var z2=Ie((uL,M2)=>{"use strict";var{isUUID:k8}=Uh(),S8=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,E8=["http","https","ws","wss","urn","urn:uuid"];function T8(t){return E8.indexOf(t)!==-1}function Gh(t){return t.secure===!0?!0:t.secure===!1?!1:t.scheme?t.scheme.length===3&&(t.scheme[0]==="w"||t.scheme[0]==="W")&&(t.scheme[1]==="s"||t.scheme[1]==="S")&&(t.scheme[2]==="s"||t.scheme[2]==="S"):!1}function $2(t){return t.host||(t.error=t.error||"HTTP URIs must have a host."),t}function R2(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 $8(t){return t.secure=Gh(t),t.resourceName=(t.path||"/")+(t.query?"?"+t.query:""),t.path=void 0,t.query=void 0,t}function R8(t){if((t.port===(Gh(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 P8(t,e){if(!t.path)return t.error="URN can not be parsed",t;let r=t.path.match(S8);if(r){let n=e.scheme||t.scheme||"urn";t.nid=r[1].toLowerCase(),t.nss=r[2];let s=`${n}:${e.nid||t.nid}`,o=Yh(s);t.path=void 0,o&&(t=o.parse(t,e))}else t.error=t.error||"URN can not be parsed.";return t}function M8(t,e){if(t.nid===void 0)throw new Error("URN without nid cannot be serialized");let r=e.scheme||t.scheme||"urn",n=t.nid.toLowerCase(),s=`${r}:${e.nid||n}`,o=Yh(s);o&&(t=o.serialize(t,e));let i=t,a=t.nss;return i.path=`${n||e.nid}:${a}`,e.skipEscape=!0,i}function z8(t,e){let r=t;return r.uuid=r.nss,r.nss=void 0,!e.tolerant&&(!r.uuid||!k8(r.uuid))&&(r.error=r.error||"UUID is not valid."),r}function I8(t){let e=t;return e.nss=(t.uuid||"").toLowerCase(),e}var P2={scheme:"http",domainHost:!0,parse:$2,serialize:R2},O8={scheme:"https",domainHost:P2.domainHost,parse:$2,serialize:R2},sl={scheme:"ws",domainHost:!0,parse:$8,serialize:R8},A8={scheme:"wss",domainHost:sl.domainHost,parse:sl.parse,serialize:sl.serialize},N8={scheme:"urn",parse:P8,serialize:M8,skipNormalize:!0},C8={scheme:"urn:uuid",parse:z8,serialize:I8,skipNormalize:!0},ol={http:P2,https:O8,ws:sl,wss:A8,urn:N8,"urn:uuid":C8};Object.setPrototypeOf(ol,null);function Yh(t){return t&&(ol[t]||ol[t.toLowerCase()])||void 0}M2.exports={wsIsSecure:Gh,SCHEMES:ol,isValidSchemeName:T8,getSchemeHandler:Yh}});var j2=Ie((dL,il)=>{"use strict";var{normalizeIPv6:j8,removeDotSegments:la,recomposeAuthority:D8,normalizePercentEncoding:L8,normalizePathEncoding:Z8,escapePreservingEscapes:B8,reescapeHostDelimiters:q8,isIPv4:V8,nonSimpleDomain:F8}=Uh(),{SCHEMES:H8,getSchemeHandler:O2}=z2();function U8(t,e){return typeof t=="string"?t=K8(t,e):typeof t=="object"&&(t=qo(Js(t,e),e)),t}function G8(t,e,r){let n=r?Object.assign({scheme:"null"},r):{scheme:"null"},s=A2(qo(t,n),qo(e,n),n,!0);return n.skipEscape=!0,Js(s,n)}function A2(t,e,r,n){let s={};return n||(t=qo(Js(t,r),r),e=qo(Js(e,r),r)),r=r||{},!r.tolerant&&e.scheme?(s.scheme=e.scheme,s.userinfo=e.userinfo,s.host=e.host,s.port=e.port,s.path=la(e.path||""),s.query=e.query):(e.userinfo!==void 0||e.host!==void 0||e.port!==void 0?(s.userinfo=e.userinfo,s.host=e.host,s.port=e.port,s.path=la(e.path||""),s.query=e.query):(e.path?(e.path[0]==="/"?s.path=la(e.path):((t.userinfo!==void 0||t.host!==void 0||t.port!==void 0)&&!t.path?s.path="/"+e.path:t.path?s.path=t.path.slice(0,t.path.lastIndexOf("/")+1)+e.path:s.path=e.path,s.path=la(s.path)),s.query=e.query):(s.path=t.path,e.query!==void 0?s.query=e.query:s.query=t.query),s.userinfo=t.userinfo,s.host=t.host,s.port=t.port),s.scheme=t.scheme),s.fragment=e.fragment,s}function Y8(t,e,r){let n=I2(t,r),s=I2(e,r);return n!==void 0&&s!==void 0&&n.toLowerCase()===s.toLowerCase()}function Js(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:""},n=Object.assign({},e),s=[],o=O2(n.scheme||r.scheme);o&&o.serialize&&o.serialize(r,n),r.path!==void 0&&(n.skipEscape?r.path=L8(r.path):(r.path=B8(r.path),r.scheme!==void 0&&(r.path=r.path.split("%3A").join(":")))),n.reference!=="suffix"&&r.scheme&&s.push(r.scheme,":");let i=D8(r);if(i!==void 0&&(n.reference!=="suffix"&&s.push("//"),s.push(i),r.path&&r.path[0]!=="/"&&s.push("/")),r.path!==void 0){let a=r.path;!n.absolutePath&&(!o||!o.absolutePath)&&(a=la(a)),i===void 0&&a[0]==="/"&&a[1]==="/"&&(a="/%2F"+a.slice(2)),s.push(a)}return r.query!==void 0&&s.push("?",r.query),r.fragment!==void 0&&s.push("#",r.fragment),s.join("")}var X8=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function W8(t,e){if(e[2]!==void 0&&t.path&&t.path[0]!=="/")return'URI path must start with "/" when authority is present.';if(typeof t.port=="number"&&(t.port<0||t.port>65535))return"URI port is malformed."}function N2(t,e){let r=Object.assign({},e),n={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},s=!1,o=!1;r.reference==="suffix"&&(r.scheme?t=r.scheme+":"+t:t="//"+t);let i=t.match(X8);if(i){n.scheme=i[1],n.userinfo=i[3],n.host=i[4],n.port=parseInt(i[5],10),n.path=i[6]||"",n.query=i[7],n.fragment=i[8],isNaN(n.port)&&(n.port=i[5]);let a=W8(n,i);if(a!==void 0&&(n.error=n.error||a,s=!0),n.host)if(V8(n.host)===!1){let l=j8(n.host);n.host=l.host.toLowerCase(),o=l.isIPV6}else o=!0;n.scheme===void 0&&n.userinfo===void 0&&n.host===void 0&&n.port===void 0&&n.query===void 0&&!n.path?n.reference="same-document":n.scheme===void 0?n.reference="relative":n.fragment===void 0?n.reference="absolute":n.reference="uri",r.reference&&r.reference!=="suffix"&&r.reference!==n.reference&&(n.error=n.error||"URI is not a "+r.reference+" reference.");let c=O2(r.scheme||n.scheme);if(!r.unicodeSupport&&(!c||!c.unicodeSupport)&&n.host&&(r.domainHost||c&&c.domainHost)&&o===!1&&F8(n.host))try{n.host=URL.domainToASCII(n.host.toLowerCase())}catch(d){n.error=n.error||"Host's domain name can not be converted to ASCII: "+d}if((!c||c&&!c.skipNormalize)&&(t.indexOf("%")!==-1&&(n.scheme!==void 0&&(n.scheme=unescape(n.scheme)),n.host!==void 0&&(n.host=q8(unescape(n.host),o))),n.path&&(n.path=Z8(n.path)),n.fragment))try{n.fragment=encodeURI(decodeURIComponent(n.fragment))}catch{n.error=n.error||"URI malformed"}c&&c.parse&&c.parse(n,r)}else n.error=n.error||"URI can not be parsed.";return{parsed:n,malformedAuthorityOrPort:s}}function qo(t,e){return N2(t,e).parsed}function K8(t,e){return C2(t,e).normalized}function C2(t,e){let{parsed:r,malformedAuthorityOrPort:n}=N2(t,e);return{normalized:n?t:Js(r,e),malformedAuthorityOrPort:n}}function I2(t,e){if(typeof t=="string"){let{normalized:r,malformedAuthorityOrPort:n}=C2(t,e);return n?void 0:r}if(typeof t=="object")return Js(t,e)}var Xh={SCHEMES:H8,normalize:U8,resolve:G8,resolveComponent:A2,equal:Y8,serialize:Js,parse:qo};il.exports=Xh;il.exports.default=Xh;il.exports.fastUri=Xh});var L2=Ie(Wh=>{"use strict";Object.defineProperty(Wh,"__esModule",{value:!0});var D2=j2();D2.code='require("ajv/dist/runtime/uri").default';Wh.default=D2});var G2=Ie(or=>{"use strict";Object.defineProperty(or,"__esModule",{value:!0});or.CodeGen=or.Name=or.nil=or.stringify=or.str=or._=or.KeywordCxt=void 0;var J8=aa();Object.defineProperty(or,"KeywordCxt",{enumerable:!0,get:function(){return J8.KeywordCxt}});var Vo=it();Object.defineProperty(or,"_",{enumerable:!0,get:function(){return Vo._}});Object.defineProperty(or,"str",{enumerable:!0,get:function(){return Vo.str}});Object.defineProperty(or,"stringify",{enumerable:!0,get:function(){return Vo.stringify}});Object.defineProperty(or,"nil",{enumerable:!0,get:function(){return Vo.nil}});Object.defineProperty(or,"Name",{enumerable:!0,get:function(){return Vo.Name}});Object.defineProperty(or,"CodeGen",{enumerable:!0,get:function(){return Vo.CodeGen}});var Q8=tl(),F2=ca(),eE=Sh(),ua=nl(),tE=it(),da=sa(),al=na(),Jh=mt(),Z2=v2(),rE=L2(),H2=(t,e)=>new RegExp(t,e);H2.code="new RegExp";var nE=["removeAdditional","useDefaults","coerceTypes"],sE=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),oE={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."},iE={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},B2=200;function aE(t){var e,r,n,s,o,i,a,c,d,l,u,h,p,g,x,S,k,_,m,$,f,E,N,B,U;let C=t.strict,q=(e=t.code)===null||e===void 0?void 0:e.optimize,de=q===!0||q===void 0?1:q||0,A=(n=(r=t.code)===null||r===void 0?void 0:r.regExp)!==null&&n!==void 0?n:H2,b=(s=t.uriResolver)!==null&&s!==void 0?s:rE.default;return{strictSchema:(i=(o=t.strictSchema)!==null&&o!==void 0?o:C)!==null&&i!==void 0?i:!0,strictNumbers:(c=(a=t.strictNumbers)!==null&&a!==void 0?a:C)!==null&&c!==void 0?c:!0,strictTypes:(l=(d=t.strictTypes)!==null&&d!==void 0?d:C)!==null&&l!==void 0?l:"log",strictTuples:(h=(u=t.strictTuples)!==null&&u!==void 0?u:C)!==null&&h!==void 0?h:"log",strictRequired:(g=(p=t.strictRequired)!==null&&p!==void 0?p:C)!==null&&g!==void 0?g:!1,code:t.code?{...t.code,optimize:de,regExp:A}:{optimize:de,regExp:A},loopRequired:(x=t.loopRequired)!==null&&x!==void 0?x:B2,loopEnum:(S=t.loopEnum)!==null&&S!==void 0?S:B2,meta:(k=t.meta)!==null&&k!==void 0?k:!0,messages:(_=t.messages)!==null&&_!==void 0?_:!0,inlineRefs:(m=t.inlineRefs)!==null&&m!==void 0?m:!0,schemaId:($=t.schemaId)!==null&&$!==void 0?$:"$id",addUsedSchema:(f=t.addUsedSchema)!==null&&f!==void 0?f:!0,validateSchema:(E=t.validateSchema)!==null&&E!==void 0?E:!0,validateFormats:(N=t.validateFormats)!==null&&N!==void 0?N:!0,unicodeRegExp:(B=t.unicodeRegExp)!==null&&B!==void 0?B:!0,int32range:(U=t.int32range)!==null&&U!==void 0?U:!0,uriResolver:b}}var fa=class{constructor(e={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,...aE(e)};let{es5:r,lines:n}=this.opts.code;this.scope=new tE.ValueScope({scope:{},prefixes:sE,es5:r,lines:n}),this.logger=hE(e.logger);let s=e.validateFormats;e.validateFormats=!1,this.RULES=(0,eE.getRules)(),q2.call(this,oE,e,"NOT SUPPORTED"),q2.call(this,iE,e,"DEPRECATED","warn"),this._metaOpts=dE.call(this),e.formats&&lE.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&uE.call(this,e.keywords),typeof e.meta=="object"&&this.addMetaSchema(e.meta),cE.call(this),e.validateFormats=s}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:e,meta:r,schemaId:n}=this.opts,s=Z2;n==="id"&&(s={...Z2},s.id=s.$id,delete s.$id),r&&e&&this.addMetaSchema(s,s[n],!1)}defaultMeta(){let{meta:e,schemaId:r}=this.opts;return this.opts.defaultMeta=typeof e=="object"?e[r]||e:void 0}validate(e,r){let n;if(typeof e=="string"){if(n=this.getSchema(e),!n)throw new Error(`no schema with key or ref "${e}"`)}else n=this.compile(e);let s=n(r);return"$async"in n||(this.errors=n.errors),s}compile(e,r){let n=this._addSchema(e,r);return n.validate||this._compileSchemaEnv(n)}compileAsync(e,r){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");let{loadSchema:n}=this.opts;return s.call(this,e,r);async function s(l,u){await o.call(this,l.$schema);let h=this._addSchema(l,u);return h.validate||i.call(this,h)}async function o(l){l&&!this.getSchema(l)&&await s.call(this,{$ref:l},!0)}async function i(l){try{return this._compileSchemaEnv(l)}catch(u){if(!(u instanceof F2.default))throw u;return a.call(this,u),await c.call(this,u.missingSchema),i.call(this,l)}}function a({missingSchema:l,missingRef:u}){if(this.refs[l])throw new Error(`AnySchema ${l} is loaded but ${u} cannot be resolved`)}async function c(l){let u=await d.call(this,l);this.refs[l]||await o.call(this,u.$schema),this.refs[l]||this.addSchema(u,l,r)}async function d(l){let u=this._loading[l];if(u)return u;try{return await(this._loading[l]=n(l))}finally{delete this._loading[l]}}}addSchema(e,r,n,s=this.opts.validateSchema){if(Array.isArray(e)){for(let i of e)this.addSchema(i,void 0,n,s);return this}let o;if(typeof e=="object"){let{schemaId:i}=this.opts;if(o=e[i],o!==void 0&&typeof o!="string")throw new Error(`schema ${i} must be string`)}return r=(0,da.normalizeId)(r||o),this._checkUnique(r),this.schemas[r]=this._addSchema(e,n,r,s,!0),this}addMetaSchema(e,r,n=this.opts.validateSchema){return this.addSchema(e,r,!0,n),this}validateSchema(e,r){if(typeof e=="boolean")return!0;let n;if(n=e.$schema,n!==void 0&&typeof n!="string")throw new Error("$schema must be a string");if(n=n||this.opts.defaultMeta||this.defaultMeta(),!n)return this.logger.warn("meta-schema not available"),this.errors=null,!0;let s=this.validate(n,e);if(!s&&r){let o="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(o);else throw new Error(o)}return s}getSchema(e){let r;for(;typeof(r=V2.call(this,e))=="string";)e=r;if(r===void 0){let{schemaId:n}=this.opts,s=new ua.SchemaEnv({schema:{},schemaId:n});if(r=ua.resolveSchema.call(this,s,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=V2.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 n=e[this.opts.schemaId];return n&&(n=(0,da.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),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 n;if(typeof e=="string")n=e,typeof r=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),r.keyword=n);else if(typeof e=="object"&&r===void 0){if(r=e,n=r.keyword,Array.isArray(n)&&!n.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(mE.call(this,n,r),!r)return(0,Jh.eachItem)(n,o=>Kh.call(this,o)),this;_E.call(this,r);let s={...r,type:(0,al.getJSONTypes)(r.type),schemaType:(0,al.getJSONTypes)(r.schemaType)};return(0,Jh.eachItem)(n,s.type.length===0?o=>Kh.call(this,o,s):o=>s.type.forEach(i=>Kh.call(this,o,s,i))),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 n of r.rules){let s=n.rules.findIndex(o=>o.keyword===e);s>=0&&n.rules.splice(s,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:n="data"}={}){return!e||e.length===0?"No errors":e.map(s=>`${n}${s.instancePath} ${s.message}`).reduce((s,o)=>s+r+o)}$dataMetaSchema(e,r){let n=this.RULES.all;e=JSON.parse(JSON.stringify(e));for(let s of r){let o=s.split("/").slice(1),i=e;for(let a of o)i=i[a];for(let a in n){let c=n[a];if(typeof c!="object")continue;let{$data:d}=c.definition,l=i[a];d&&l&&(i[a]=U2(l))}}return e}_removeAllSchemas(e,r){for(let n in e){let s=e[n];(!r||r.test(n))&&(typeof s=="string"?delete e[n]:s&&!s.meta&&(this._cache.delete(s.schema),delete e[n]))}}_addSchema(e,r,n,s=this.opts.validateSchema,o=this.opts.addUsedSchema){let i,{schemaId:a}=this.opts;if(typeof e=="object")i=e[a];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;n=(0,da.normalizeId)(i||n);let d=da.getSchemaRefs.call(this,e,n);return c=new ua.SchemaEnv({schema:e,schemaId:a,meta:r,baseId:n,localRefs:d}),this._cache.set(c.schema,c),o&&!n.startsWith("#")&&(n&&this._checkUnique(n),this.refs[n]=c),s&&this.validateSchema(e,!0),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):ua.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{ua.compileSchema.call(this,e)}finally{this.opts=r}}};fa.ValidationError=Q8.default;fa.MissingRefError=F2.default;or.default=fa;function q2(t,e,r,n="error"){for(let s in t){let o=s;o in e&&this.logger[n](`${r}: option ${s}. ${t[o]}`)}}function V2(t){return t=(0,da.normalizeId)(t),this.schemas[t]||this.refs[t]}function cE(){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 lE(){for(let t in this.opts.formats){let e=this.opts.formats[t];e&&this.addFormat(t,e)}}function uE(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 dE(){let t={...this.opts};for(let e of nE)delete t[e];return t}var fE={log(){},warn(){},error(){}};function hE(t){if(t===!1)return fE;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 pE=/^[a-z_$][a-z0-9_$:-]*$/i;function mE(t,e){let{RULES:r}=this;if((0,Jh.eachItem)(t,n=>{if(r.keywords[n])throw new Error(`Keyword ${n} is already defined`);if(!pE.test(n))throw new Error(`Keyword ${n} has invalid name`)}),!!e&&e.$data&&!("code"in e||"validate"in e))throw new Error('$data keyword must have "code" or "validate" function')}function Kh(t,e,r){var n;let s=e?.post;if(r&&s)throw new Error('keyword with "post" flag cannot have "type"');let{RULES:o}=this,i=s?o.post:o.rules.find(({type:c})=>c===r);if(i||(i={type:r,rules:[]},o.rules.push(i)),o.keywords[t]=!0,!e)return;let a={keyword:t,definition:{...e,type:(0,al.getJSONTypes)(e.type),schemaType:(0,al.getJSONTypes)(e.schemaType)}};e.before?gE.call(this,i,a,e.before):i.rules.push(a),o.all[t]=a,(n=e.implements)===null||n===void 0||n.forEach(c=>this.addKeyword(c))}function gE(t,e,r){let n=t.rules.findIndex(s=>s.keyword===r);n>=0?t.rules.splice(n,0,e):(t.rules.push(e),this.logger.warn(`rule ${r} is not defined`))}function _E(t){let{metaSchema:e}=t;e!==void 0&&(t.$data&&this.opts.$data&&(e=U2(e)),t.validateSchema=this.compile(e,!0))}var bE={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function U2(t){return{anyOf:[t,bE]}}});var Y2=Ie(Qh=>{"use strict";Object.defineProperty(Qh,"__esModule",{value:!0});var yE={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};Qh.default=yE});var J2=Ie(Qs=>{"use strict";Object.defineProperty(Qs,"__esModule",{value:!0});Qs.callRef=Qs.getValidate=void 0;var vE=ca(),X2=Kr(),Rr=it(),Fo=qn(),W2=nl(),cl=mt(),wE={keyword:"$ref",schemaType:"string",code(t){let{gen:e,schema:r,it:n}=t,{baseId:s,schemaEnv:o,validateName:i,opts:a,self:c}=n,{root:d}=o;if((r==="#"||r==="#/")&&s===d.baseId)return u();let l=W2.resolveRef.call(c,d,s,r);if(l===void 0)throw new vE.default(n.opts.uriResolver,s,r);if(l instanceof W2.SchemaEnv)return h(l);return p(l);function u(){if(o===d)return ll(t,i,o,o.$async);let g=e.scopeValue("root",{ref:d});return ll(t,(0,Rr._)`${g}.validate`,d,d.$async)}function h(g){let x=K2(t,g);ll(t,x,g,g.$async)}function p(g){let x=e.scopeValue("schema",a.code.source===!0?{ref:g,code:(0,Rr.stringify)(g)}:{ref:g}),S=e.name("valid"),k=t.subschema({schema:g,dataTypes:[],schemaPath:Rr.nil,topSchemaRef:x,errSchemaPath:r},S);t.mergeEvaluated(k),t.ok(S)}}};function K2(t,e){let{gen:r}=t;return e.validate?r.scopeValue("validate",{ref:e.validate}):(0,Rr._)`${r.scopeValue("wrapper",{ref:e})}.validate`}Qs.getValidate=K2;function ll(t,e,r,n){let{gen:s,it:o}=t,{allErrors:i,schemaEnv:a,opts:c}=o,d=c.passContext?Fo.default.this:Rr.nil;n?l():u();function l(){if(!a.$async)throw new Error("async schema referenced by sync schema");let g=s.let("valid");s.try(()=>{s.code((0,Rr._)`await ${(0,X2.callValidateCode)(t,e,d)}`),p(e),i||s.assign(g,!0)},x=>{s.if((0,Rr._)`!(${x} instanceof ${o.ValidationError})`,()=>s.throw(x)),h(x),i||s.assign(g,!1)}),t.ok(g)}function u(){t.result((0,X2.callValidateCode)(t,e,d),()=>p(e),()=>h(e))}function h(g){let x=(0,Rr._)`${g}.errors`;s.assign(Fo.default.vErrors,(0,Rr._)`${Fo.default.vErrors} === null ? ${x} : ${Fo.default.vErrors}.concat(${x})`),s.assign(Fo.default.errors,(0,Rr._)`${Fo.default.vErrors}.length`)}function p(g){var x;if(!o.opts.unevaluated)return;let S=(x=r?.validate)===null||x===void 0?void 0:x.evaluated;if(o.props!==!0)if(S&&!S.dynamicProps)S.props!==void 0&&(o.props=cl.mergeEvaluated.props(s,S.props,o.props));else{let k=s.var("props",(0,Rr._)`${g}.evaluated.props`);o.props=cl.mergeEvaluated.props(s,k,o.props,Rr.Name)}if(o.items!==!0)if(S&&!S.dynamicItems)S.items!==void 0&&(o.items=cl.mergeEvaluated.items(s,S.items,o.items));else{let k=s.var("items",(0,Rr._)`${g}.evaluated.items`);o.items=cl.mergeEvaluated.items(s,k,o.items,Rr.Name)}}}Qs.callRef=ll;Qs.default=wE});var Q2=Ie(ep=>{"use strict";Object.defineProperty(ep,"__esModule",{value:!0});var xE=Y2(),kE=J2(),SE=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",xE.default,kE.default];ep.default=SE});var eb=Ie(tp=>{"use strict";Object.defineProperty(tp,"__esModule",{value:!0});var ul=it(),ls=ul.operators,dl={maximum:{okStr:"<=",ok:ls.LTE,fail:ls.GT},minimum:{okStr:">=",ok:ls.GTE,fail:ls.LT},exclusiveMaximum:{okStr:"<",ok:ls.LT,fail:ls.GTE},exclusiveMinimum:{okStr:">",ok:ls.GT,fail:ls.LTE}},EE={message:({keyword:t,schemaCode:e})=>(0,ul.str)`must be ${dl[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0,ul._)`{comparison: ${dl[t].okStr}, limit: ${e}}`},TE={keyword:Object.keys(dl),type:"number",schemaType:"number",$data:!0,error:EE,code(t){let{keyword:e,data:r,schemaCode:n}=t;t.fail$data((0,ul._)`${r} ${dl[e].fail} ${n} || isNaN(${r})`)}};tp.default=TE});var tb=Ie(rp=>{"use strict";Object.defineProperty(rp,"__esModule",{value:!0});var ha=it(),$E={message:({schemaCode:t})=>(0,ha.str)`must be multiple of ${t}`,params:({schemaCode:t})=>(0,ha._)`{multipleOf: ${t}}`},RE={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:$E,code(t){let{gen:e,data:r,schemaCode:n,it:s}=t,o=s.opts.multipleOfPrecision,i=e.let("res"),a=o?(0,ha._)`Math.abs(Math.round(${i}) - ${i}) > 1e-${o}`:(0,ha._)`${i} !== parseInt(${i})`;t.fail$data((0,ha._)`(${n} === 0 || (${i} = ${r}/${n}, ${a}))`)}};rp.default=RE});var nb=Ie(np=>{"use strict";Object.defineProperty(np,"__esModule",{value:!0});function rb(t){let e=t.length,r=0,n=0,s;for(;n<e;)r++,s=t.charCodeAt(n++),s>=55296&&s<=56319&&n<e&&(s=t.charCodeAt(n),(s&64512)===56320&&n++);return r}np.default=rb;rb.code='require("ajv/dist/runtime/ucs2length").default'});var sb=Ie(sp=>{"use strict";Object.defineProperty(sp,"__esModule",{value:!0});var eo=it(),PE=mt(),ME=nb(),zE={message({keyword:t,schemaCode:e}){let r=t==="maxLength"?"more":"fewer";return(0,eo.str)`must NOT have ${r} than ${e} characters`},params:({schemaCode:t})=>(0,eo._)`{limit: ${t}}`},IE={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:zE,code(t){let{keyword:e,data:r,schemaCode:n,it:s}=t,o=e==="maxLength"?eo.operators.GT:eo.operators.LT,i=s.opts.unicode===!1?(0,eo._)`${r}.length`:(0,eo._)`${(0,PE.useFunc)(t.gen,ME.default)}(${r})`;t.fail$data((0,eo._)`${i} ${o} ${n}`)}};sp.default=IE});var ob=Ie(op=>{"use strict";Object.defineProperty(op,"__esModule",{value:!0});var OE=Kr(),AE=mt(),Ho=it(),NE={message:({schemaCode:t})=>(0,Ho.str)`must match pattern "${t}"`,params:({schemaCode:t})=>(0,Ho._)`{pattern: ${t}}`},CE={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:NE,code(t){let{gen:e,data:r,$data:n,schema:s,schemaCode:o,it:i}=t,a=i.opts.unicodeRegExp?"u":"";if(n){let{regExp:c}=i.opts.code,d=c.code==="new RegExp"?(0,Ho._)`new RegExp`:(0,AE.useFunc)(e,c),l=e.let("valid");e.try(()=>e.assign(l,(0,Ho._)`${d}(${o}, ${a}).test(${r})`),()=>e.assign(l,!1)),t.fail$data((0,Ho._)`!${l}`)}else{let c=(0,OE.usePattern)(t,s);t.fail$data((0,Ho._)`!${c}.test(${r})`)}}};op.default=CE});var ib=Ie(ip=>{"use strict";Object.defineProperty(ip,"__esModule",{value:!0});var pa=it(),jE={message({keyword:t,schemaCode:e}){let r=t==="maxProperties"?"more":"fewer";return(0,pa.str)`must NOT have ${r} than ${e} properties`},params:({schemaCode:t})=>(0,pa._)`{limit: ${t}}`},DE={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:jE,code(t){let{keyword:e,data:r,schemaCode:n}=t,s=e==="maxProperties"?pa.operators.GT:pa.operators.LT;t.fail$data((0,pa._)`Object.keys(${r}).length ${s} ${n}`)}};ip.default=DE});var ab=Ie(ap=>{"use strict";Object.defineProperty(ap,"__esModule",{value:!0});var ma=Kr(),ga=it(),LE=mt(),ZE={message:({params:{missingProperty:t}})=>(0,ga.str)`must have required property '${t}'`,params:({params:{missingProperty:t}})=>(0,ga._)`{missingProperty: ${t}}`},BE={keyword:"required",type:"object",schemaType:"array",$data:!0,error:ZE,code(t){let{gen:e,schema:r,schemaCode:n,data:s,$data:o,it:i}=t,{opts:a}=i;if(!o&&r.length===0)return;let c=r.length>=a.loopRequired;if(i.allErrors?d():l(),a.strictRequired){let p=t.parentSchema.properties,{definedProperties:g}=t.it;for(let x of r)if(p?.[x]===void 0&&!g.has(x)){let S=i.schemaEnv.baseId+i.errSchemaPath,k=`required property "${x}" is not defined at "${S}" (strictRequired)`;(0,LE.checkStrictMode)(i,k,i.opts.strictRequired)}}function d(){if(c||o)t.block$data(ga.nil,u);else for(let p of r)(0,ma.checkReportMissingProp)(t,p)}function l(){let p=e.let("missing");if(c||o){let g=e.let("valid",!0);t.block$data(g,()=>h(p,g)),t.ok(g)}else e.if((0,ma.checkMissingProp)(t,r,p)),(0,ma.reportMissingProp)(t,p),e.else()}function u(){e.forOf("prop",n,p=>{t.setParams({missingProperty:p}),e.if((0,ma.noPropertyInData)(e,s,p,a.ownProperties),()=>t.error())})}function h(p,g){t.setParams({missingProperty:p}),e.forOf(p,n,()=>{e.assign(g,(0,ma.propertyInData)(e,s,p,a.ownProperties)),e.if((0,ga.not)(g),()=>{t.error(),e.break()})},ga.nil)}}};ap.default=BE});var cb=Ie(cp=>{"use strict";Object.defineProperty(cp,"__esModule",{value:!0});var _a=it(),qE={message({keyword:t,schemaCode:e}){let r=t==="maxItems"?"more":"fewer";return(0,_a.str)`must NOT have ${r} than ${e} items`},params:({schemaCode:t})=>(0,_a._)`{limit: ${t}}`},VE={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:qE,code(t){let{keyword:e,data:r,schemaCode:n}=t,s=e==="maxItems"?_a.operators.GT:_a.operators.LT;t.fail$data((0,_a._)`${r}.length ${s} ${n}`)}};cp.default=VE});var fl=Ie(lp=>{"use strict";Object.defineProperty(lp,"__esModule",{value:!0});var lb=Ih();lb.code='require("ajv/dist/runtime/equal").default';lp.default=lb});var ub=Ie(dp=>{"use strict";Object.defineProperty(dp,"__esModule",{value:!0});var up=na(),ir=it(),FE=mt(),HE=fl(),UE={message:({params:{i:t,j:e}})=>(0,ir.str)`must NOT have duplicate items (items ## ${e} and ${t} are identical)`,params:({params:{i:t,j:e}})=>(0,ir._)`{i: ${t}, j: ${e}}`},GE={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:UE,code(t){let{gen:e,data:r,$data:n,schema:s,parentSchema:o,schemaCode:i,it:a}=t;if(!n&&!s)return;let c=e.let("valid"),d=o.items?(0,up.getSchemaTypes)(o.items):[];t.block$data(c,l,(0,ir._)`${i} === false`),t.ok(c);function l(){let g=e.let("i",(0,ir._)`${r}.length`),x=e.let("j");t.setParams({i:g,j:x}),e.assign(c,!0),e.if((0,ir._)`${g} > 1`,()=>(u()?h:p)(g,x))}function u(){return d.length>0&&!d.some(g=>g==="object"||g==="array")}function h(g,x){let S=e.name("item"),k=(0,up.checkDataTypes)(d,S,a.opts.strictNumbers,up.DataType.Wrong),_=e.const("indices",(0,ir._)`{}`);e.for((0,ir._)`;${g}--;`,()=>{e.let(S,(0,ir._)`${r}[${g}]`),e.if(k,(0,ir._)`continue`),d.length>1&&e.if((0,ir._)`typeof ${S} == "string"`,(0,ir._)`${S} += "_"`),e.if((0,ir._)`typeof ${_}[${S}] == "number"`,()=>{e.assign(x,(0,ir._)`${_}[${S}]`),t.error(),e.assign(c,!1).break()}).code((0,ir._)`${_}[${S}] = ${g}`)})}function p(g,x){let S=(0,FE.useFunc)(e,HE.default),k=e.name("outer");e.label(k).for((0,ir._)`;${g}--;`,()=>e.for((0,ir._)`${x} = ${g}; ${x}--;`,()=>e.if((0,ir._)`${S}(${r}[${g}], ${r}[${x}])`,()=>{t.error(),e.assign(c,!1).break(k)})))}}};dp.default=GE});var db=Ie(hp=>{"use strict";Object.defineProperty(hp,"__esModule",{value:!0});var fp=it(),YE=mt(),XE=fl(),WE={message:"must be equal to constant",params:({schemaCode:t})=>(0,fp._)`{allowedValue: ${t}}`},KE={keyword:"const",$data:!0,error:WE,code(t){let{gen:e,data:r,$data:n,schemaCode:s,schema:o}=t;n||o&&typeof o=="object"?t.fail$data((0,fp._)`!${(0,YE.useFunc)(e,XE.default)}(${r}, ${s})`):t.fail((0,fp._)`${o} !== ${r}`)}};hp.default=KE});var fb=Ie(pp=>{"use strict";Object.defineProperty(pp,"__esModule",{value:!0});var ba=it(),JE=mt(),QE=fl(),e7={message:"must be equal to one of the allowed values",params:({schemaCode:t})=>(0,ba._)`{allowedValues: ${t}}`},t7={keyword:"enum",schemaType:"array",$data:!0,error:e7,code(t){let{gen:e,data:r,$data:n,schema:s,schemaCode:o,it:i}=t;if(!n&&s.length===0)throw new Error("enum must have non-empty array");let a=s.length>=i.opts.loopEnum,c,d=()=>c??(c=(0,JE.useFunc)(e,QE.default)),l;if(a||n)l=e.let("valid"),t.block$data(l,u);else{if(!Array.isArray(s))throw new Error("ajv implementation error");let p=e.const("vSchema",o);l=(0,ba.or)(...s.map((g,x)=>h(p,x)))}t.pass(l);function u(){e.assign(l,!1),e.forOf("v",o,p=>e.if((0,ba._)`${d()}(${r}, ${p})`,()=>e.assign(l,!0).break()))}function h(p,g){let x=s[g];return typeof x=="object"&&x!==null?(0,ba._)`${d()}(${r}, ${p}[${g}])`:(0,ba._)`${r} === ${x}`}}};pp.default=t7});var hb=Ie(mp=>{"use strict";Object.defineProperty(mp,"__esModule",{value:!0});var r7=eb(),n7=tb(),s7=sb(),o7=ob(),i7=ib(),a7=ab(),c7=cb(),l7=ub(),u7=db(),d7=fb(),f7=[r7.default,n7.default,s7.default,o7.default,i7.default,a7.default,c7.default,l7.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},u7.default,d7.default];mp.default=f7});var _p=Ie(ya=>{"use strict";Object.defineProperty(ya,"__esModule",{value:!0});ya.validateAdditionalItems=void 0;var to=it(),gp=mt(),h7={message:({params:{len:t}})=>(0,to.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,to._)`{limit: ${t}}`},p7={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:h7,code(t){let{parentSchema:e,it:r}=t,{items:n}=e;if(!Array.isArray(n)){(0,gp.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}pb(t,n)}};function pb(t,e){let{gen:r,schema:n,data:s,keyword:o,it:i}=t;i.items=!0;let a=r.const("len",(0,to._)`${s}.length`);if(n===!1)t.setParams({len:e.length}),t.pass((0,to._)`${a} <= ${e.length}`);else if(typeof n=="object"&&!(0,gp.alwaysValidSchema)(i,n)){let d=r.var("valid",(0,to._)`${a} <= ${e.length}`);r.if((0,to.not)(d),()=>c(d)),t.ok(d)}function c(d){r.forRange("i",e.length,a,l=>{t.subschema({keyword:o,dataProp:l,dataPropType:gp.Type.Num},d),i.allErrors||r.if((0,to.not)(d),()=>r.break())})}}ya.validateAdditionalItems=pb;ya.default=p7});var bp=Ie(va=>{"use strict";Object.defineProperty(va,"__esModule",{value:!0});va.validateTuple=void 0;var mb=it(),hl=mt(),m7=Kr(),g7={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(t){let{schema:e,it:r}=t;if(Array.isArray(e))return gb(t,"additionalItems",e);r.items=!0,!(0,hl.alwaysValidSchema)(r,e)&&t.ok((0,m7.validateArray)(t))}};function gb(t,e,r=t.schema){let{gen:n,parentSchema:s,data:o,keyword:i,it:a}=t;l(s),a.opts.unevaluated&&r.length&&a.items!==!0&&(a.items=hl.mergeEvaluated.items(n,r.length,a.items));let c=n.name("valid"),d=n.const("len",(0,mb._)`${o}.length`);r.forEach((u,h)=>{(0,hl.alwaysValidSchema)(a,u)||(n.if((0,mb._)`${d} > ${h}`,()=>t.subschema({keyword:i,schemaProp:h,dataProp:h},c)),t.ok(c))});function l(u){let{opts:h,errSchemaPath:p}=a,g=r.length,x=g===u.minItems&&(g===u.maxItems||u[e]===!1);if(h.strictTuples&&!x){let S=`"${i}" is ${g}-tuple, but minItems or maxItems/${e} are not specified or different at path "${p}"`;(0,hl.checkStrictMode)(a,S,h.strictTuples)}}}va.validateTuple=gb;va.default=g7});var _b=Ie(yp=>{"use strict";Object.defineProperty(yp,"__esModule",{value:!0});var _7=bp(),b7={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:t=>(0,_7.validateTuple)(t,"items")};yp.default=b7});var yb=Ie(vp=>{"use strict";Object.defineProperty(vp,"__esModule",{value:!0});var bb=it(),y7=mt(),v7=Kr(),w7=_p(),x7={message:({params:{len:t}})=>(0,bb.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,bb._)`{limit: ${t}}`},k7={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:x7,code(t){let{schema:e,parentSchema:r,it:n}=t,{prefixItems:s}=r;n.items=!0,!(0,y7.alwaysValidSchema)(n,e)&&(s?(0,w7.validateAdditionalItems)(t,s):t.ok((0,v7.validateArray)(t)))}};vp.default=k7});var vb=Ie(wp=>{"use strict";Object.defineProperty(wp,"__esModule",{value:!0});var Qr=it(),pl=mt(),S7={message:({params:{min:t,max:e}})=>e===void 0?(0,Qr.str)`must contain at least ${t} valid item(s)`:(0,Qr.str)`must contain at least ${t} and no more than ${e} valid item(s)`,params:({params:{min:t,max:e}})=>e===void 0?(0,Qr._)`{minContains: ${t}}`:(0,Qr._)`{minContains: ${t}, maxContains: ${e}}`},E7={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:S7,code(t){let{gen:e,schema:r,parentSchema:n,data:s,it:o}=t,i,a,{minContains:c,maxContains:d}=n;o.opts.next?(i=c===void 0?1:c,a=d):i=1;let l=e.const("len",(0,Qr._)`${s}.length`);if(t.setParams({min:i,max:a}),a===void 0&&i===0){(0,pl.checkStrictMode)(o,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&i>a){(0,pl.checkStrictMode)(o,'"minContains" > "maxContains" is always invalid'),t.fail();return}if((0,pl.alwaysValidSchema)(o,r)){let x=(0,Qr._)`${l} >= ${i}`;a!==void 0&&(x=(0,Qr._)`${x} && ${l} <= ${a}`),t.pass(x);return}o.items=!0;let u=e.name("valid");a===void 0&&i===1?p(u,()=>e.if(u,()=>e.break())):i===0?(e.let(u,!0),a!==void 0&&e.if((0,Qr._)`${s}.length > 0`,h)):(e.let(u,!1),h()),t.result(u,()=>t.reset());function h(){let x=e.name("_valid"),S=e.let("count",0);p(x,()=>e.if(x,()=>g(S)))}function p(x,S){e.forRange("i",0,l,k=>{t.subschema({keyword:"contains",dataProp:k,dataPropType:pl.Type.Num,compositeRule:!0},x),S()})}function g(x){e.code((0,Qr._)`${x}++`),a===void 0?e.if((0,Qr._)`${x} >= ${i}`,()=>e.assign(u,!0).break()):(e.if((0,Qr._)`${x} > ${a}`,()=>e.assign(u,!1).break()),i===1?e.assign(u,!0):e.if((0,Qr._)`${x} >= ${i}`,()=>e.assign(u,!0)))}}};wp.default=E7});var kb=Ie(Mn=>{"use strict";Object.defineProperty(Mn,"__esModule",{value:!0});Mn.validateSchemaDeps=Mn.validatePropertyDeps=Mn.error=void 0;var xp=it(),T7=mt(),wa=Kr();Mn.error={message:({params:{property:t,depsCount:e,deps:r}})=>{let n=e===1?"property":"properties";return(0,xp.str)`must have ${n} ${r} when property ${t} is present`},params:({params:{property:t,depsCount:e,deps:r,missingProperty:n}})=>(0,xp._)`{property: ${t},
|
|
7
|
+
missingProperty: ${n},
|
|
8
|
+
depsCount: ${e},
|
|
9
|
+
deps: ${r}}`};var $7={keyword:"dependencies",type:"object",schemaType:"object",error:Mn.error,code(t){let[e,r]=R7(t);wb(t,e),xb(t,r)}};function R7({schema:t}){let e={},r={};for(let n in t){if(n==="__proto__")continue;let s=Array.isArray(t[n])?e:r;s[n]=t[n]}return[e,r]}function wb(t,e=t.schema){let{gen:r,data:n,it:s}=t;if(Object.keys(e).length===0)return;let o=r.let("missing");for(let i in e){let a=e[i];if(a.length===0)continue;let c=(0,wa.propertyInData)(r,n,i,s.opts.ownProperties);t.setParams({property:i,depsCount:a.length,deps:a.join(", ")}),s.allErrors?r.if(c,()=>{for(let d of a)(0,wa.checkReportMissingProp)(t,d)}):(r.if((0,xp._)`${c} && (${(0,wa.checkMissingProp)(t,a,o)})`),(0,wa.reportMissingProp)(t,o),r.else())}}Mn.validatePropertyDeps=wb;function xb(t,e=t.schema){let{gen:r,data:n,keyword:s,it:o}=t,i=r.name("valid");for(let a in e)(0,T7.alwaysValidSchema)(o,e[a])||(r.if((0,wa.propertyInData)(r,n,a,o.opts.ownProperties),()=>{let c=t.subschema({keyword:s,schemaProp:a},i);t.mergeValidEvaluated(c,i)},()=>r.var(i,!0)),t.ok(i))}Mn.validateSchemaDeps=xb;Mn.default=$7});var Eb=Ie(kp=>{"use strict";Object.defineProperty(kp,"__esModule",{value:!0});var Sb=it(),P7=mt(),M7={message:"property name must be valid",params:({params:t})=>(0,Sb._)`{propertyName: ${t.propertyName}}`},z7={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:M7,code(t){let{gen:e,schema:r,data:n,it:s}=t;if((0,P7.alwaysValidSchema)(s,r))return;let o=e.name("valid");e.forIn("key",n,i=>{t.setParams({propertyName:i}),t.subschema({keyword:"propertyNames",data:i,dataTypes:["string"],propertyName:i,compositeRule:!0},o),e.if((0,Sb.not)(o),()=>{t.error(!0),s.allErrors||e.break()})}),t.ok(o)}};kp.default=z7});var Ep=Ie(Sp=>{"use strict";Object.defineProperty(Sp,"__esModule",{value:!0});var ml=Kr(),gn=it(),I7=qn(),gl=mt(),O7={message:"must NOT have additional properties",params:({params:t})=>(0,gn._)`{additionalProperty: ${t.additionalProperty}}`},A7={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:O7,code(t){let{gen:e,schema:r,parentSchema:n,data:s,errsCount:o,it:i}=t;if(!o)throw new Error("ajv implementation error");let{allErrors:a,opts:c}=i;if(i.props=!0,c.removeAdditional!=="all"&&(0,gl.alwaysValidSchema)(i,r))return;let d=(0,ml.allSchemaProperties)(n.properties),l=(0,ml.allSchemaProperties)(n.patternProperties);u(),t.ok((0,gn._)`${o} === ${I7.default.errors}`);function u(){e.forIn("key",s,S=>{!d.length&&!l.length?g(S):e.if(h(S),()=>g(S))})}function h(S){let k;if(d.length>8){let _=(0,gl.schemaRefOrVal)(i,n.properties,"properties");k=(0,ml.isOwnProperty)(e,_,S)}else d.length?k=(0,gn.or)(...d.map(_=>(0,gn._)`${S} === ${_}`)):k=gn.nil;return l.length&&(k=(0,gn.or)(k,...l.map(_=>(0,gn._)`${(0,ml.usePattern)(t,_)}.test(${S})`))),(0,gn.not)(k)}function p(S){e.code((0,gn._)`delete ${s}[${S}]`)}function g(S){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){p(S);return}if(r===!1){t.setParams({additionalProperty:S}),t.error(),a||e.break();return}if(typeof r=="object"&&!(0,gl.alwaysValidSchema)(i,r)){let k=e.name("valid");c.removeAdditional==="failing"?(x(S,k,!1),e.if((0,gn.not)(k),()=>{t.reset(),p(S)})):(x(S,k),a||e.if((0,gn.not)(k),()=>e.break()))}}function x(S,k,_){let m={keyword:"additionalProperties",dataProp:S,dataPropType:gl.Type.Str};_===!1&&Object.assign(m,{compositeRule:!0,createErrors:!1,allErrors:!1}),t.subschema(m,k)}}};Sp.default=A7});var Rb=Ie($p=>{"use strict";Object.defineProperty($p,"__esModule",{value:!0});var N7=aa(),Tb=Kr(),Tp=mt(),$b=Ep(),C7={keyword:"properties",type:"object",schemaType:"object",code(t){let{gen:e,schema:r,parentSchema:n,data:s,it:o}=t;o.opts.removeAdditional==="all"&&n.additionalProperties===void 0&&$b.default.code(new N7.KeywordCxt(o,$b.default,"additionalProperties"));let i=(0,Tb.allSchemaProperties)(r);for(let u of i)o.definedProperties.add(u);o.opts.unevaluated&&i.length&&o.props!==!0&&(o.props=Tp.mergeEvaluated.props(e,(0,Tp.toHash)(i),o.props));let a=i.filter(u=>!(0,Tp.alwaysValidSchema)(o,r[u]));if(a.length===0)return;let c=e.name("valid");for(let u of a)d(u)?l(u):(e.if((0,Tb.propertyInData)(e,s,u,o.opts.ownProperties)),l(u),o.allErrors||e.else().var(c,!0),e.endIf()),t.it.definedProperties.add(u),t.ok(c);function d(u){return o.opts.useDefaults&&!o.compositeRule&&r[u].default!==void 0}function l(u){t.subschema({keyword:"properties",schemaProp:u,dataProp:u},c)}}};$p.default=C7});var Ib=Ie(Rp=>{"use strict";Object.defineProperty(Rp,"__esModule",{value:!0});var Pb=Kr(),_l=it(),Mb=mt(),zb=mt(),j7={keyword:"patternProperties",type:"object",schemaType:"object",code(t){let{gen:e,schema:r,data:n,parentSchema:s,it:o}=t,{opts:i}=o,a=(0,Pb.allSchemaProperties)(r),c=a.filter(x=>(0,Mb.alwaysValidSchema)(o,r[x]));if(a.length===0||c.length===a.length&&(!o.opts.unevaluated||o.props===!0))return;let d=i.strictSchema&&!i.allowMatchingProperties&&s.properties,l=e.name("valid");o.props!==!0&&!(o.props instanceof _l.Name)&&(o.props=(0,zb.evaluatedPropsToName)(e,o.props));let{props:u}=o;h();function h(){for(let x of a)d&&p(x),o.allErrors?g(x):(e.var(l,!0),g(x),e.if(l))}function p(x){for(let S in d)new RegExp(x).test(S)&&(0,Mb.checkStrictMode)(o,`property ${S} matches pattern ${x} (use allowMatchingProperties)`)}function g(x){e.forIn("key",n,S=>{e.if((0,_l._)`${(0,Pb.usePattern)(t,x)}.test(${S})`,()=>{let k=c.includes(x);k||t.subschema({keyword:"patternProperties",schemaProp:x,dataProp:S,dataPropType:zb.Type.Str},l),o.opts.unevaluated&&u!==!0?e.assign((0,_l._)`${u}[${S}]`,!0):!k&&!o.allErrors&&e.if((0,_l.not)(l),()=>e.break())})})}}};Rp.default=j7});var Ob=Ie(Pp=>{"use strict";Object.defineProperty(Pp,"__esModule",{value:!0});var D7=mt(),L7={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(t){let{gen:e,schema:r,it:n}=t;if((0,D7.alwaysValidSchema)(n,r)){t.fail();return}let s=e.name("valid");t.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},s),t.failResult(s,()=>t.reset(),()=>t.error())},error:{message:"must NOT be valid"}};Pp.default=L7});var Ab=Ie(Mp=>{"use strict";Object.defineProperty(Mp,"__esModule",{value:!0});var Z7=Kr(),B7={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:Z7.validateUnion,error:{message:"must match a schema in anyOf"}};Mp.default=B7});var Nb=Ie(zp=>{"use strict";Object.defineProperty(zp,"__esModule",{value:!0});var bl=it(),q7=mt(),V7={message:"must match exactly one schema in oneOf",params:({params:t})=>(0,bl._)`{passingSchemas: ${t.passing}}`},F7={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:V7,code(t){let{gen:e,schema:r,parentSchema:n,it:s}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(s.opts.discriminator&&n.discriminator)return;let o=r,i=e.let("valid",!1),a=e.let("passing",null),c=e.name("_valid");t.setParams({passing:a}),e.block(d),t.result(i,()=>t.reset(),()=>t.error(!0));function d(){o.forEach((l,u)=>{let h;(0,q7.alwaysValidSchema)(s,l)?e.var(c,!0):h=t.subschema({keyword:"oneOf",schemaProp:u,compositeRule:!0},c),u>0&&e.if((0,bl._)`${c} && ${i}`).assign(i,!1).assign(a,(0,bl._)`[${a}, ${u}]`).else(),e.if(c,()=>{e.assign(i,!0),e.assign(a,u),h&&t.mergeEvaluated(h,bl.Name)})})}}};zp.default=F7});var Cb=Ie(Ip=>{"use strict";Object.defineProperty(Ip,"__esModule",{value:!0});var H7=mt(),U7={keyword:"allOf",schemaType:"array",code(t){let{gen:e,schema:r,it:n}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");let s=e.name("valid");r.forEach((o,i)=>{if((0,H7.alwaysValidSchema)(n,o))return;let a=t.subschema({keyword:"allOf",schemaProp:i},s);t.ok(s),t.mergeEvaluated(a)})}};Ip.default=U7});var Lb=Ie(Op=>{"use strict";Object.defineProperty(Op,"__esModule",{value:!0});var yl=it(),Db=mt(),G7={message:({params:t})=>(0,yl.str)`must match "${t.ifClause}" schema`,params:({params:t})=>(0,yl._)`{failingKeyword: ${t.ifClause}}`},Y7={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:G7,code(t){let{gen:e,parentSchema:r,it:n}=t;r.then===void 0&&r.else===void 0&&(0,Db.checkStrictMode)(n,'"if" without "then" and "else" is ignored');let s=jb(n,"then"),o=jb(n,"else");if(!s&&!o)return;let i=e.let("valid",!0),a=e.name("_valid");if(c(),t.reset(),s&&o){let l=e.let("ifClause");t.setParams({ifClause:l}),e.if(a,d("then",l),d("else",l))}else s?e.if(a,d("then")):e.if((0,yl.not)(a),d("else"));t.pass(i,()=>t.error(!0));function c(){let l=t.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},a);t.mergeEvaluated(l)}function d(l,u){return()=>{let h=t.subschema({keyword:l},a);e.assign(i,a),t.mergeValidEvaluated(h,i),u?e.assign(u,(0,yl._)`${l}`):t.setParams({ifClause:l})}}}};function jb(t,e){let r=t.schema[e];return r!==void 0&&!(0,Db.alwaysValidSchema)(t,r)}Op.default=Y7});var Zb=Ie(Ap=>{"use strict";Object.defineProperty(Ap,"__esModule",{value:!0});var X7=mt(),W7={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:t,parentSchema:e,it:r}){e.if===void 0&&(0,X7.checkStrictMode)(r,`"${t}" without "if" is ignored`)}};Ap.default=W7});var Bb=Ie(Np=>{"use strict";Object.defineProperty(Np,"__esModule",{value:!0});var K7=_p(),J7=_b(),Q7=bp(),eT=yb(),tT=vb(),rT=kb(),nT=Eb(),sT=Ep(),oT=Rb(),iT=Ib(),aT=Ob(),cT=Ab(),lT=Nb(),uT=Cb(),dT=Lb(),fT=Zb();function hT(t=!1){let e=[aT.default,cT.default,lT.default,uT.default,dT.default,fT.default,nT.default,sT.default,rT.default,oT.default,iT.default];return t?e.push(J7.default,eT.default):e.push(K7.default,Q7.default),e.push(tT.default),e}Np.default=hT});var qb=Ie(Cp=>{"use strict";Object.defineProperty(Cp,"__esModule",{value:!0});var Ht=it(),pT={message:({schemaCode:t})=>(0,Ht.str)`must match format "${t}"`,params:({schemaCode:t})=>(0,Ht._)`{format: ${t}}`},mT={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:pT,code(t,e){let{gen:r,data:n,$data:s,schema:o,schemaCode:i,it:a}=t,{opts:c,errSchemaPath:d,schemaEnv:l,self:u}=a;if(!c.validateFormats)return;s?h():p();function h(){let g=r.scopeValue("formats",{ref:u.formats,code:c.code.formats}),x=r.const("fDef",(0,Ht._)`${g}[${i}]`),S=r.let("fType"),k=r.let("format");r.if((0,Ht._)`typeof ${x} == "object" && !(${x} instanceof RegExp)`,()=>r.assign(S,(0,Ht._)`${x}.type || "string"`).assign(k,(0,Ht._)`${x}.validate`),()=>r.assign(S,(0,Ht._)`"string"`).assign(k,x)),t.fail$data((0,Ht.or)(_(),m()));function _(){return c.strictSchema===!1?Ht.nil:(0,Ht._)`${i} && !${k}`}function m(){let $=l.$async?(0,Ht._)`(${x}.async ? await ${k}(${n}) : ${k}(${n}))`:(0,Ht._)`${k}(${n})`,f=(0,Ht._)`(typeof ${k} == "function" ? ${$} : ${k}.test(${n}))`;return(0,Ht._)`${k} && ${k} !== true && ${S} === ${e} && !${f}`}}function p(){let g=u.formats[o];if(!g){_();return}if(g===!0)return;let[x,S,k]=m(g);x===e&&t.pass($());function _(){if(c.strictSchema===!1){u.logger.warn(f());return}throw new Error(f());function f(){return`unknown format "${o}" ignored in schema at path "${d}"`}}function m(f){let E=f instanceof RegExp?(0,Ht.regexpCode)(f):c.code.formats?(0,Ht._)`${c.code.formats}${(0,Ht.getProperty)(o)}`:void 0,N=r.scopeValue("formats",{key:o,ref:f,code:E});return typeof f=="object"&&!(f instanceof RegExp)?[f.type||"string",f.validate,(0,Ht._)`${N}.validate`]:["string",f,N]}function $(){if(typeof g=="object"&&!(g instanceof RegExp)&&g.async){if(!l.$async)throw new Error("async format in sync schema");return(0,Ht._)`await ${k}(${n})`}return typeof S=="function"?(0,Ht._)`${k}(${n})`:(0,Ht._)`${k}.test(${n})`}}}};Cp.default=mT});var Vb=Ie(jp=>{"use strict";Object.defineProperty(jp,"__esModule",{value:!0});var gT=qb(),_T=[gT.default];jp.default=_T});var Fb=Ie(Uo=>{"use strict";Object.defineProperty(Uo,"__esModule",{value:!0});Uo.contentVocabulary=Uo.metadataVocabulary=void 0;Uo.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];Uo.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var Ub=Ie(Dp=>{"use strict";Object.defineProperty(Dp,"__esModule",{value:!0});var bT=Q2(),yT=hb(),vT=Bb(),wT=Vb(),Hb=Fb(),xT=[bT.default,yT.default,(0,vT.default)(),wT.default,Hb.metadataVocabulary,Hb.contentVocabulary];Dp.default=xT});var Yb=Ie(vl=>{"use strict";Object.defineProperty(vl,"__esModule",{value:!0});vl.DiscrError=void 0;var Gb;(function(t){t.Tag="tag",t.Mapping="mapping"})(Gb||(vl.DiscrError=Gb={}))});var Wb=Ie(Zp=>{"use strict";Object.defineProperty(Zp,"__esModule",{value:!0});var Go=it(),Lp=Yb(),Xb=nl(),kT=ca(),ST=mt(),ET={message:({params:{discrError:t,tagName:e}})=>t===Lp.DiscrError.Tag?`tag "${e}" must be string`:`value of tag "${e}" must be in oneOf`,params:({params:{discrError:t,tag:e,tagName:r}})=>(0,Go._)`{error: ${t}, tag: ${r}, tagValue: ${e}}`},TT={keyword:"discriminator",type:"object",schemaType:"object",error:ET,code(t){let{gen:e,data:r,schema:n,parentSchema:s,it:o}=t,{oneOf:i}=s;if(!o.opts.discriminator)throw new Error("discriminator: requires discriminator option");let a=n.propertyName;if(typeof a!="string")throw new Error("discriminator: requires propertyName");if(n.mapping)throw new Error("discriminator: mapping is not supported");if(!i)throw new Error("discriminator: requires oneOf keyword");let c=e.let("valid",!1),d=e.const("tag",(0,Go._)`${r}${(0,Go.getProperty)(a)}`);e.if((0,Go._)`typeof ${d} == "string"`,()=>l(),()=>t.error(!1,{discrError:Lp.DiscrError.Tag,tag:d,tagName:a})),t.ok(c);function l(){let p=h();e.if(!1);for(let g in p)e.elseIf((0,Go._)`${d} === ${g}`),e.assign(c,u(p[g]));e.else(),t.error(!1,{discrError:Lp.DiscrError.Mapping,tag:d,tagName:a}),e.endIf()}function u(p){let g=e.name("valid"),x=t.subschema({keyword:"oneOf",schemaProp:p},g);return t.mergeEvaluated(x,Go.Name),g}function h(){var p;let g={},x=k(s),S=!0;for(let $=0;$<i.length;$++){let f=i[$];if(f?.$ref&&!(0,ST.schemaHasRulesButRef)(f,o.self.RULES)){let N=f.$ref;if(f=Xb.resolveRef.call(o.self,o.schemaEnv.root,o.baseId,N),f instanceof Xb.SchemaEnv&&(f=f.schema),f===void 0)throw new kT.default(o.opts.uriResolver,o.baseId,N)}let E=(p=f?.properties)===null||p===void 0?void 0:p[a];if(typeof E!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`);S=S&&(x||k(f)),_(E,$)}if(!S)throw new Error(`discriminator: "${a}" must be required`);return g;function k({required:$}){return Array.isArray($)&&$.includes(a)}function _($,f){if($.const)m($.const,f);else if($.enum)for(let E of $.enum)m(E,f);else throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function m($,f){if(typeof $!="string"||$ in g)throw new Error(`discriminator: "${a}" values must be unique strings`);g[$]=f}}}};Zp.default=TT});var Kb=Ie((QL,$T)=>{$T.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:!0,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:!0,readOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0},multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/definitions/nonNegativeInteger"},minLength:{$ref:"#/definitions/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},additionalItems:{$ref:"#"},items:{anyOf:[{$ref:"#"},{$ref:"#/definitions/schemaArray"}],default:!0},maxItems:{$ref:"#/definitions/nonNegativeInteger"},minItems:{$ref:"#/definitions/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},contains:{$ref:"#"},maxProperties:{$ref:"#/definitions/nonNegativeInteger"},minProperties:{$ref:"#/definitions/nonNegativeIntegerDefault0"},required:{$ref:"#/definitions/stringArray"},additionalProperties:{$ref:"#"},definitions:{type:"object",additionalProperties:{$ref:"#"},default:{}},properties:{type:"object",additionalProperties:{$ref:"#"},default:{}},patternProperties:{type:"object",additionalProperties:{$ref:"#"},propertyNames:{format:"regex"},default:{}},dependencies:{type:"object",additionalProperties:{anyOf:[{$ref:"#"},{$ref:"#/definitions/stringArray"}]}},propertyNames:{$ref:"#"},const:!0,enum:{type:"array",items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:"#/definitions/simpleTypes"},{type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:!0}]},format:{type:"string"},contentMediaType:{type:"string"},contentEncoding:{type:"string"},if:{$ref:"#"},then:{$ref:"#"},else:{$ref:"#"},allOf:{$ref:"#/definitions/schemaArray"},anyOf:{$ref:"#/definitions/schemaArray"},oneOf:{$ref:"#/definitions/schemaArray"},not:{$ref:"#"}},default:!0}});var qp=Ie((It,Bp)=>{"use strict";Object.defineProperty(It,"__esModule",{value:!0});It.MissingRefError=It.ValidationError=It.CodeGen=It.Name=It.nil=It.stringify=It.str=It._=It.KeywordCxt=It.Ajv=void 0;var RT=G2(),PT=Ub(),MT=Wb(),Jb=Kb(),zT=["/properties"],wl="http://json-schema.org/draft-07/schema",Yo=class extends RT.default{_addVocabularies(){super._addVocabularies(),PT.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(MT.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let e=this.opts.$data?this.$dataMetaSchema(Jb,zT):Jb;this.addMetaSchema(e,wl,!1),this.refs["http://json-schema.org/schema"]=wl}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(wl)?wl:void 0)}};It.Ajv=Yo;Bp.exports=It=Yo;Bp.exports.Ajv=Yo;Object.defineProperty(It,"__esModule",{value:!0});It.default=Yo;var IT=aa();Object.defineProperty(It,"KeywordCxt",{enumerable:!0,get:function(){return IT.KeywordCxt}});var Xo=it();Object.defineProperty(It,"_",{enumerable:!0,get:function(){return Xo._}});Object.defineProperty(It,"str",{enumerable:!0,get:function(){return Xo.str}});Object.defineProperty(It,"stringify",{enumerable:!0,get:function(){return Xo.stringify}});Object.defineProperty(It,"nil",{enumerable:!0,get:function(){return Xo.nil}});Object.defineProperty(It,"Name",{enumerable:!0,get:function(){return Xo.Name}});Object.defineProperty(It,"CodeGen",{enumerable:!0,get:function(){return Xo.CodeGen}});var OT=tl();Object.defineProperty(It,"ValidationError",{enumerable:!0,get:function(){return OT.default}});var AT=ca();Object.defineProperty(It,"MissingRefError",{enumerable:!0,get:function(){return AT.default}})});var iy=Ie(In=>{"use strict";Object.defineProperty(In,"__esModule",{value:!0});In.formatNames=In.fastFormats=In.fullFormats=void 0;function zn(t,e){return{validate:t,compare:e}}In.fullFormats={date:zn(ry,Up),time:zn(Fp(!0),Gp),"date-time":zn(Qb(!0),sy),"iso-time":zn(Fp(),ny),"iso-date-time":zn(Qb(),oy),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:ZT,"uri-reference":/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,"uri-template":/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,url:/^(?:https?|ftp):\/\/(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/,ipv6:/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,regex:GT,uuid:/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,"json-pointer":/^(?:\/(?:[^~/]|~0|~1)*)*$/,"json-pointer-uri-fragment":/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,"relative-json-pointer":/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,byte:BT,int32:{type:"number",validate:FT},int64:{type:"number",validate:HT},float:{type:"number",validate:ty},double:{type:"number",validate:ty},password:!0,binary:!0};In.fastFormats={...In.fullFormats,date:zn(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,Up),time:zn(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,Gp),"date-time":zn(/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,sy),"iso-time":zn(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,ny),"iso-date-time":zn(/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,oy),uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,email:/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i};In.formatNames=Object.keys(In.fullFormats);function NT(t){return t%4===0&&(t%100!==0||t%400===0)}var CT=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,jT=[0,31,28,31,30,31,30,31,31,30,31,30,31];function ry(t){let e=CT.exec(t);if(!e)return!1;let r=+e[1],n=+e[2],s=+e[3];return n>=1&&n<=12&&s>=1&&s<=(n===2&&NT(r)?29:jT[n])}function Up(t,e){if(t&&e)return t>e?1:t<e?-1:0}var Vp=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function Fp(t){return function(r){let n=Vp.exec(r);if(!n)return!1;let s=+n[1],o=+n[2],i=+n[3],a=n[4],c=n[5]==="-"?-1:1,d=+(n[6]||0),l=+(n[7]||0);if(d>23||l>59||t&&!a)return!1;if(s<=23&&o<=59&&i<60)return!0;let u=o-l*c,h=s-d*c-(u<0?1:0);return(h===23||h===-1)&&(u===59||u===-1)&&i<61}}function Gp(t,e){if(!(t&&e))return;let r=new Date("2020-01-01T"+t).valueOf(),n=new Date("2020-01-01T"+e).valueOf();if(r&&n)return r-n}function ny(t,e){if(!(t&&e))return;let r=Vp.exec(t),n=Vp.exec(e);if(r&&n)return t=r[1]+r[2]+r[3],e=n[1]+n[2]+n[3],t>e?1:t<e?-1:0}var Hp=/t|\s/i;function Qb(t){let e=Fp(t);return function(n){let s=n.split(Hp);return s.length===2&&ry(s[0])&&e(s[1])}}function sy(t,e){if(!(t&&e))return;let r=new Date(t).valueOf(),n=new Date(e).valueOf();if(r&&n)return r-n}function oy(t,e){if(!(t&&e))return;let[r,n]=t.split(Hp),[s,o]=e.split(Hp),i=Up(r,s);if(i!==void 0)return i||Gp(n,o)}var DT=/\/|:/,LT=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function ZT(t){return DT.test(t)&<.test(t)}var ey=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function BT(t){return ey.lastIndex=0,ey.test(t)}var qT=-(2**31),VT=2**31-1;function FT(t){return Number.isInteger(t)&&t<=VT&&t>=qT}function HT(t){return Number.isInteger(t)}function ty(){return!0}var UT=/[^\\]\\Z/;function GT(t){if(UT.test(t))return!1;try{return new RegExp(t),!0}catch{return!1}}});var ay=Ie(Wo=>{"use strict";Object.defineProperty(Wo,"__esModule",{value:!0});Wo.formatLimitDefinition=void 0;var YT=qp(),_n=it(),us=_n.operators,xl={formatMaximum:{okStr:"<=",ok:us.LTE,fail:us.GT},formatMinimum:{okStr:">=",ok:us.GTE,fail:us.LT},formatExclusiveMaximum:{okStr:"<",ok:us.LT,fail:us.GTE},formatExclusiveMinimum:{okStr:">",ok:us.GT,fail:us.LTE}},XT={message:({keyword:t,schemaCode:e})=>(0,_n.str)`should be ${xl[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0,_n._)`{comparison: ${xl[t].okStr}, limit: ${e}}`};Wo.formatLimitDefinition={keyword:Object.keys(xl),type:"string",schemaType:"string",$data:!0,error:XT,code(t){let{gen:e,data:r,schemaCode:n,keyword:s,it:o}=t,{opts:i,self:a}=o;if(!i.validateFormats)return;let c=new YT.KeywordCxt(o,a.RULES.all.format.definition,"format");c.$data?d():l();function d(){let h=e.scopeValue("formats",{ref:a.formats,code:i.code.formats}),p=e.const("fmt",(0,_n._)`${h}[${c.schemaCode}]`);t.fail$data((0,_n.or)((0,_n._)`typeof ${p} != "object"`,(0,_n._)`${p} instanceof RegExp`,(0,_n._)`typeof ${p}.compare != "function"`,u(p)))}function l(){let h=c.schema,p=a.formats[h];if(!p||p===!0)return;if(typeof p!="object"||p instanceof RegExp||typeof p.compare!="function")throw new Error(`"${s}": format "${h}" does not define "compare" function`);let g=e.scopeValue("formats",{key:h,ref:p,code:i.code.formats?(0,_n._)`${i.code.formats}${(0,_n.getProperty)(h)}`:void 0});t.fail$data(u(g))}function u(h){return(0,_n._)`${h}.compare(${r}, ${n}) ${xl[s].fail} 0`}},dependencies:["format"]};var WT=t=>(t.addKeyword(Wo.formatLimitDefinition),t);Wo.default=WT});var dy=Ie((xa,uy)=>{"use strict";Object.defineProperty(xa,"__esModule",{value:!0});var Ko=iy(),KT=ay(),Yp=it(),cy=new Yp.Name("fullFormats"),JT=new Yp.Name("fastFormats"),Xp=(t,e={keywords:!0})=>{if(Array.isArray(e))return ly(t,e,Ko.fullFormats,cy),t;let[r,n]=e.mode==="fast"?[Ko.fastFormats,JT]:[Ko.fullFormats,cy],s=e.formats||Ko.formatNames;return ly(t,s,r,n),e.keywords&&(0,KT.default)(t),t};Xp.get=(t,e="full")=>{let n=(e==="fast"?Ko.fastFormats:Ko.fullFormats)[t];if(!n)throw new Error(`Unknown format "${t}"`);return n};function ly(t,e,r,n){var s,o;(s=(o=t.opts.code).formats)!==null&&s!==void 0||(o.formats=(0,Yp._)`require("ajv-formats/dist/formats").${n}`);for(let i of e)t.addFormat(i,r[i])}uy.exports=xa=Xp;Object.defineProperty(xa,"__esModule",{value:!0});xa.default=Xp});var G={};wu(G,{BRAND:()=>k4,DIRTY:()=>xs,EMPTY_PATH:()=>t4,INVALID:()=>Ye,NEVER:()=>i5,OK:()=>cr,ParseStatus:()=>tr,Schema:()=>ot,ZodAny:()=>Xn,ZodArray:()=>Dn,ZodBigInt:()=>Ss,ZodBoolean:()=>Es,ZodBranded:()=>wi,ZodCatch:()=>Cs,ZodDate:()=>Ts,ZodDefault:()=>Ns,ZodDiscriminatedUnion:()=>Ha,ZodEffects:()=>Ur,ZodEnum:()=>Os,ZodError:()=>wr,ZodFirstPartyTypeKind:()=>be,ZodFunction:()=>Ga,ZodIntersection:()=>Ms,ZodIssueCode:()=>_e,ZodLazy:()=>zs,ZodLiteral:()=>Is,ZodMap:()=>xo,ZodNaN:()=>So,ZodNativeEnum:()=>As,ZodNever:()=>ln,ZodNull:()=>Rs,ZodNullable:()=>Tn,ZodNumber:()=>ks,ZodObject:()=>kr,ZodOptional:()=>xr,ZodParsedType:()=>Oe,ZodPipeline:()=>xi,ZodPromise:()=>Wn,ZodReadonly:()=>js,ZodRecord:()=>Ua,ZodSchema:()=>ot,ZodSet:()=>ko,ZodString:()=>Yn,ZodSymbol:()=>vo,ZodTransformer:()=>Ur,ZodTuple:()=>En,ZodType:()=>ot,ZodUndefined:()=>$s,ZodUnion:()=>Ps,ZodUnknown:()=>jn,ZodVoid:()=>wo,addIssueToContext:()=>Ee,any:()=>I4,array:()=>C4,bigint:()=>$4,boolean:()=>j1,coerce:()=>o5,custom:()=>A1,date:()=>R4,datetimeRegex:()=>I1,defaultErrorMap:()=>Nn,discriminatedUnion:()=>L4,effect:()=>K4,enum:()=>Y4,function:()=>H4,getErrorMap:()=>_o,getParsedType:()=>Sn,instanceof:()=>E4,intersection:()=>Z4,isAborted:()=>Va,isAsync:()=>bo,isDirty:()=>Fa,isValid:()=>Gn,late:()=>S4,lazy:()=>U4,literal:()=>G4,makeIssue:()=>vi,map:()=>V4,nan:()=>T4,nativeEnum:()=>X4,never:()=>A4,null:()=>z4,nullable:()=>Q4,number:()=>C1,object:()=>Eu,objectUtil:()=>xu,oboolean:()=>s5,onumber:()=>n5,optional:()=>J4,ostring:()=>r5,pipeline:()=>t5,preprocess:()=>e5,promise:()=>W4,quotelessJson:()=>J3,record:()=>q4,set:()=>F4,setErrorMap:()=>e4,strictObject:()=>j4,string:()=>N1,symbol:()=>P4,transformer:()=>K4,tuple:()=>B4,undefined:()=>M4,union:()=>D4,unknown:()=>O4,util:()=>lt,void:()=>N4});var lt;(function(t){t.assertEqual=s=>{};function e(s){}t.assertIs=e;function r(s){throw new Error}t.assertNever=r,t.arrayToEnum=s=>{let o={};for(let i of s)o[i]=i;return o},t.getValidEnumValues=s=>{let o=t.objectKeys(s).filter(a=>typeof s[s[a]]!="number"),i={};for(let a of o)i[a]=s[a];return t.objectValues(i)},t.objectValues=s=>t.objectKeys(s).map(function(o){return s[o]}),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{let o=[];for(let i in s)Object.prototype.hasOwnProperty.call(s,i)&&o.push(i);return o},t.find=(s,o)=>{for(let i of s)if(o(i))return i},t.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function n(s,o=" | "){return s.map(i=>typeof i=="string"?`'${i}'`:i).join(o)}t.joinValues=n,t.jsonStringifyReplacer=(s,o)=>typeof o=="bigint"?o.toString():o})(lt||(lt={}));var xu;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(xu||(xu={}));var Oe=lt.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Sn=t=>{switch(typeof t){case"undefined":return Oe.undefined;case"string":return Oe.string;case"number":return Number.isNaN(t)?Oe.nan:Oe.number;case"boolean":return Oe.boolean;case"function":return Oe.function;case"bigint":return Oe.bigint;case"symbol":return Oe.symbol;case"object":return Array.isArray(t)?Oe.array:t===null?Oe.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?Oe.promise:typeof Map<"u"&&t instanceof Map?Oe.map:typeof Set<"u"&&t instanceof Set?Oe.set:typeof Date<"u"&&t instanceof Date?Oe.date:Oe.object;default:return Oe.unknown}};var _e=lt.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),J3=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),wr=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}format(e){let r=e||function(o){return o.message},n={_errors:[]},s=o=>{for(let i of o.issues)if(i.code==="invalid_union")i.unionErrors.map(s);else if(i.code==="invalid_return_type")s(i.returnTypeError);else if(i.code==="invalid_arguments")s(i.argumentsError);else if(i.path.length===0)n._errors.push(r(i));else{let a=n,c=0;for(;c<i.path.length;){let d=i.path[c];c===i.path.length-1?(a[d]=a[d]||{_errors:[]},a[d]._errors.push(r(i))):a[d]=a[d]||{_errors:[]},a=a[d],c++}}};return s(this),n}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,lt.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){let r={},n=[];for(let s of this.issues)if(s.path.length>0){let o=s.path[0];r[o]=r[o]||[],r[o].push(e(s))}else n.push(e(s));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};wr.create=t=>new wr(t);var Q3=(t,e)=>{let r;switch(t.code){case _e.invalid_type:t.received===Oe.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case _e.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,lt.jsonStringifyReplacer)}`;break;case _e.unrecognized_keys:r=`Unrecognized key(s) in object: ${lt.joinValues(t.keys,", ")}`;break;case _e.invalid_union:r="Invalid input";break;case _e.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${lt.joinValues(t.options)}`;break;case _e.invalid_enum_value:r=`Invalid enum value. Expected ${lt.joinValues(t.options)}, received '${t.received}'`;break;case _e.invalid_arguments:r="Invalid function arguments";break;case _e.invalid_return_type:r="Invalid function return type";break;case _e.invalid_date:r="Invalid date";break;case _e.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:lt.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case _e.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case _e.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case _e.custom:r="Invalid input";break;case _e.invalid_intersection_types:r="Intersection results could not be merged";break;case _e.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case _e.not_finite:r="Number must be finite";break;default:r=e.defaultError,lt.assertNever(t)}return{message:r}},Nn=Q3;var $1=Nn;function e4(t){$1=t}function _o(){return $1}var vi=t=>{let{data:e,path:r,errorMaps:n,issueData:s}=t,o=[...r,...s.path||[]],i={...s,path:o};if(s.message!==void 0)return{...s,path:o,message:s.message};let a="",c=n.filter(d=>!!d).slice().reverse();for(let d of c)a=d(i,{data:e,defaultError:a}).message;return{...s,path:o,message:a}},t4=[];function Ee(t,e){let r=_o(),n=vi({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===Nn?void 0:Nn].filter(s=>!!s)});t.common.issues.push(n)}var tr=class t{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){let n=[];for(let s of r){if(s.status==="aborted")return Ye;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,r){let n=[];for(let s of r){let o=await s.key,i=await s.value;n.push({key:o,value:i})}return t.mergeObjectSync(e,n)}static mergeObjectSync(e,r){let n={};for(let s of r){let{key:o,value:i}=s;if(o.status==="aborted"||i.status==="aborted")return Ye;o.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),o.value!=="__proto__"&&(typeof i.value<"u"||s.alwaysSet)&&(n[o.value]=i.value)}return{status:e.value,value:n}}},Ye=Object.freeze({status:"aborted"}),xs=t=>({status:"dirty",value:t}),cr=t=>({status:"valid",value:t}),Va=t=>t.status==="aborted",Fa=t=>t.status==="dirty",Gn=t=>t.status==="valid",bo=t=>typeof Promise<"u"&&t instanceof Promise;var Le;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(Le||(Le={}));var Hr=class{constructor(e,r,n,s){this._cachedPath=[],this.parent=e,this.data=r,this._path=n,this._key=s}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},R1=(t,e)=>{if(Gn(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new wr(t.common.issues);return this._error=r,this._error}}};function nt(t){if(!t)return{};let{errorMap:e,invalid_type_error:r,required_error:n,description:s}=t;if(e&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(i,a)=>{let{message:c}=t;return i.code==="invalid_enum_value"?{message:c??a.defaultError}:typeof a.data>"u"?{message:c??n??a.defaultError}:i.code!=="invalid_type"?{message:a.defaultError}:{message:c??r??a.defaultError}},description:s}}var ot=class{get description(){return this._def.description}_getType(e){return Sn(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:Sn(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new tr,ctx:{common:e.parent.common,data:e.data,parsedType:Sn(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let r=this._parse(e);if(bo(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){let r=this._parse(e);return Promise.resolve(r)}parse(e,r){let n=this.safeParse(e,r);if(n.success)return n.data;throw n.error}safeParse(e,r){let n={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Sn(e)},s=this._parseSync({data:e,path:n.path,parent:n});return R1(n,s)}"~validate"(e){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Sn(e)};if(!this["~standard"].async)try{let n=this._parseSync({data:e,path:[],parent:r});return Gn(n)?{value:n.value}:{issues:r.common.issues}}catch(n){n?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:r}).then(n=>Gn(n)?{value:n.value}:{issues:r.common.issues})}async parseAsync(e,r){let n=await this.safeParseAsync(e,r);if(n.success)return n.data;throw n.error}async safeParseAsync(e,r){let n={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Sn(e)},s=this._parse({data:e,path:n.path,parent:n}),o=await(bo(s)?s:Promise.resolve(s));return R1(n,o)}refine(e,r){let n=s=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(s):r;return this._refinement((s,o)=>{let i=e(s),a=()=>o.addIssue({code:_e.custom,...n(s)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(a(),!1)):i?!0:(a(),!1)})}refinement(e,r){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof r=="function"?r(n,s):r),!1))}_refinement(e){return new Ur({schema:this,typeName:be.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:r=>this["~validate"](r)}}optional(){return xr.create(this,this._def)}nullable(){return Tn.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Dn.create(this)}promise(){return Wn.create(this,this._def)}or(e){return Ps.create([this,e],this._def)}and(e){return Ms.create(this,e,this._def)}transform(e){return new Ur({...nt(this._def),schema:this,typeName:be.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let r=typeof e=="function"?e:()=>e;return new Ns({...nt(this._def),innerType:this,defaultValue:r,typeName:be.ZodDefault})}brand(){return new wi({typeName:be.ZodBranded,type:this,...nt(this._def)})}catch(e){let r=typeof e=="function"?e:()=>e;return new Cs({...nt(this._def),innerType:this,catchValue:r,typeName:be.ZodCatch})}describe(e){let r=this.constructor;return new r({...this._def,description:e})}pipe(e){return xi.create(this,e)}readonly(){return js.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},r4=/^c[^\s-]{8,}$/i,n4=/^[0-9a-z]+$/,s4=/^[0-9A-HJKMNP-TV-Z]{26}$/i,o4=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,i4=/^[a-z0-9_-]{21}$/i,a4=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,c4=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,l4=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,u4="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",ku,d4=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,f4=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,h4=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,p4=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,m4=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,g4=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,M1="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",_4=new RegExp(`^${M1}$`);function z1(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let r=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${r}`}function b4(t){return new RegExp(`^${z1(t)}$`)}function I1(t){let e=`${M1}T${z1(t)}`,r=[];return r.push(t.local?"Z?":"Z"),t.offset&&r.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${r.join("|")})`,new RegExp(`^${e}$`)}function y4(t,e){return!!((e==="v4"||!e)&&d4.test(t)||(e==="v6"||!e)&&h4.test(t))}function v4(t,e){if(!a4.test(t))return!1;try{let[r]=t.split(".");if(!r)return!1;let n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),s=JSON.parse(atob(n));return!(typeof s!="object"||s===null||"typ"in s&&s?.typ!=="JWT"||!s.alg||e&&s.alg!==e)}catch{return!1}}function w4(t,e){return!!((e==="v4"||!e)&&f4.test(t)||(e==="v6"||!e)&&p4.test(t))}var Yn=class t extends ot{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==Oe.string){let o=this._getOrReturnCtx(e);return Ee(o,{code:_e.invalid_type,expected:Oe.string,received:o.parsedType}),Ye}let n=new tr,s;for(let o of this._def.checks)if(o.kind==="min")e.data.length<o.value&&(s=this._getOrReturnCtx(e,s),Ee(s,{code:_e.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),n.dirty());else if(o.kind==="max")e.data.length>o.value&&(s=this._getOrReturnCtx(e,s),Ee(s,{code:_e.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),n.dirty());else if(o.kind==="length"){let i=e.data.length>o.value,a=e.data.length<o.value;(i||a)&&(s=this._getOrReturnCtx(e,s),i?Ee(s,{code:_e.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}):a&&Ee(s,{code:_e.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}),n.dirty())}else if(o.kind==="email")l4.test(e.data)||(s=this._getOrReturnCtx(e,s),Ee(s,{validation:"email",code:_e.invalid_string,message:o.message}),n.dirty());else if(o.kind==="emoji")ku||(ku=new RegExp(u4,"u")),ku.test(e.data)||(s=this._getOrReturnCtx(e,s),Ee(s,{validation:"emoji",code:_e.invalid_string,message:o.message}),n.dirty());else if(o.kind==="uuid")o4.test(e.data)||(s=this._getOrReturnCtx(e,s),Ee(s,{validation:"uuid",code:_e.invalid_string,message:o.message}),n.dirty());else if(o.kind==="nanoid")i4.test(e.data)||(s=this._getOrReturnCtx(e,s),Ee(s,{validation:"nanoid",code:_e.invalid_string,message:o.message}),n.dirty());else if(o.kind==="cuid")r4.test(e.data)||(s=this._getOrReturnCtx(e,s),Ee(s,{validation:"cuid",code:_e.invalid_string,message:o.message}),n.dirty());else if(o.kind==="cuid2")n4.test(e.data)||(s=this._getOrReturnCtx(e,s),Ee(s,{validation:"cuid2",code:_e.invalid_string,message:o.message}),n.dirty());else if(o.kind==="ulid")s4.test(e.data)||(s=this._getOrReturnCtx(e,s),Ee(s,{validation:"ulid",code:_e.invalid_string,message:o.message}),n.dirty());else if(o.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),Ee(s,{validation:"url",code:_e.invalid_string,message:o.message}),n.dirty()}else o.kind==="regex"?(o.regex.lastIndex=0,o.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),Ee(s,{validation:"regex",code:_e.invalid_string,message:o.message}),n.dirty())):o.kind==="trim"?e.data=e.data.trim():o.kind==="includes"?e.data.includes(o.value,o.position)||(s=this._getOrReturnCtx(e,s),Ee(s,{code:_e.invalid_string,validation:{includes:o.value,position:o.position},message:o.message}),n.dirty()):o.kind==="toLowerCase"?e.data=e.data.toLowerCase():o.kind==="toUpperCase"?e.data=e.data.toUpperCase():o.kind==="startsWith"?e.data.startsWith(o.value)||(s=this._getOrReturnCtx(e,s),Ee(s,{code:_e.invalid_string,validation:{startsWith:o.value},message:o.message}),n.dirty()):o.kind==="endsWith"?e.data.endsWith(o.value)||(s=this._getOrReturnCtx(e,s),Ee(s,{code:_e.invalid_string,validation:{endsWith:o.value},message:o.message}),n.dirty()):o.kind==="datetime"?I1(o).test(e.data)||(s=this._getOrReturnCtx(e,s),Ee(s,{code:_e.invalid_string,validation:"datetime",message:o.message}),n.dirty()):o.kind==="date"?_4.test(e.data)||(s=this._getOrReturnCtx(e,s),Ee(s,{code:_e.invalid_string,validation:"date",message:o.message}),n.dirty()):o.kind==="time"?b4(o).test(e.data)||(s=this._getOrReturnCtx(e,s),Ee(s,{code:_e.invalid_string,validation:"time",message:o.message}),n.dirty()):o.kind==="duration"?c4.test(e.data)||(s=this._getOrReturnCtx(e,s),Ee(s,{validation:"duration",code:_e.invalid_string,message:o.message}),n.dirty()):o.kind==="ip"?y4(e.data,o.version)||(s=this._getOrReturnCtx(e,s),Ee(s,{validation:"ip",code:_e.invalid_string,message:o.message}),n.dirty()):o.kind==="jwt"?v4(e.data,o.alg)||(s=this._getOrReturnCtx(e,s),Ee(s,{validation:"jwt",code:_e.invalid_string,message:o.message}),n.dirty()):o.kind==="cidr"?w4(e.data,o.version)||(s=this._getOrReturnCtx(e,s),Ee(s,{validation:"cidr",code:_e.invalid_string,message:o.message}),n.dirty()):o.kind==="base64"?m4.test(e.data)||(s=this._getOrReturnCtx(e,s),Ee(s,{validation:"base64",code:_e.invalid_string,message:o.message}),n.dirty()):o.kind==="base64url"?g4.test(e.data)||(s=this._getOrReturnCtx(e,s),Ee(s,{validation:"base64url",code:_e.invalid_string,message:o.message}),n.dirty()):lt.assertNever(o);return{status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(s=>e.test(s),{validation:r,code:_e.invalid_string,...Le.errToObj(n)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Le.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Le.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Le.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Le.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...Le.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Le.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Le.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Le.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...Le.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...Le.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...Le.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Le.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...Le.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...Le.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...Le.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...Le.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...Le.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r?.position,...Le.errToObj(r?.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...Le.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...Le.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...Le.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...Le.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...Le.errToObj(r)})}nonempty(e){return this.min(1,Le.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};Yn.create=t=>new Yn({checks:[],typeName:be.ZodString,coerce:t?.coerce??!1,...nt(t)});function x4(t,e){let r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=r>n?r:n,o=Number.parseInt(t.toFixed(s).replace(".","")),i=Number.parseInt(e.toFixed(s).replace(".",""));return o%i/10**s}var ks=class t extends ot{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==Oe.number){let o=this._getOrReturnCtx(e);return Ee(o,{code:_e.invalid_type,expected:Oe.number,received:o.parsedType}),Ye}let n,s=new tr;for(let o of this._def.checks)o.kind==="int"?lt.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),Ee(n,{code:_e.invalid_type,expected:"integer",received:"float",message:o.message}),s.dirty()):o.kind==="min"?(o.inclusive?e.data<o.value:e.data<=o.value)&&(n=this._getOrReturnCtx(e,n),Ee(n,{code:_e.too_small,minimum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),s.dirty()):o.kind==="max"?(o.inclusive?e.data>o.value:e.data>=o.value)&&(n=this._getOrReturnCtx(e,n),Ee(n,{code:_e.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),s.dirty()):o.kind==="multipleOf"?x4(e.data,o.value)!==0&&(n=this._getOrReturnCtx(e,n),Ee(n,{code:_e.not_multiple_of,multipleOf:o.value,message:o.message}),s.dirty()):o.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),Ee(n,{code:_e.not_finite,message:o.message}),s.dirty()):lt.assertNever(o);return{status:s.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,Le.toString(r))}gt(e,r){return this.setLimit("min",e,!1,Le.toString(r))}lte(e,r){return this.setLimit("max",e,!0,Le.toString(r))}lt(e,r){return this.setLimit("max",e,!1,Le.toString(r))}setLimit(e,r,n,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:Le.toString(s)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Le.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Le.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Le.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Le.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Le.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:Le.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:Le.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Le.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Le.toString(e)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&<.isInteger(e.value))}get isFinite(){let e=null,r=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(r)&&Number.isFinite(e)}};ks.create=t=>new ks({checks:[],typeName:be.ZodNumber,coerce:t?.coerce||!1,...nt(t)});var Ss=class t extends ot{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==Oe.bigint)return this._getInvalidInput(e);let n,s=new tr;for(let o of this._def.checks)o.kind==="min"?(o.inclusive?e.data<o.value:e.data<=o.value)&&(n=this._getOrReturnCtx(e,n),Ee(n,{code:_e.too_small,type:"bigint",minimum:o.value,inclusive:o.inclusive,message:o.message}),s.dirty()):o.kind==="max"?(o.inclusive?e.data>o.value:e.data>=o.value)&&(n=this._getOrReturnCtx(e,n),Ee(n,{code:_e.too_big,type:"bigint",maximum:o.value,inclusive:o.inclusive,message:o.message}),s.dirty()):o.kind==="multipleOf"?e.data%o.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),Ee(n,{code:_e.not_multiple_of,multipleOf:o.value,message:o.message}),s.dirty()):lt.assertNever(o);return{status:s.value,value:e.data}}_getInvalidInput(e){let r=this._getOrReturnCtx(e);return Ee(r,{code:_e.invalid_type,expected:Oe.bigint,received:r.parsedType}),Ye}gte(e,r){return this.setLimit("min",e,!0,Le.toString(r))}gt(e,r){return this.setLimit("min",e,!1,Le.toString(r))}lte(e,r){return this.setLimit("max",e,!0,Le.toString(r))}lt(e,r){return this.setLimit("max",e,!1,Le.toString(r))}setLimit(e,r,n,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:Le.toString(s)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Le.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Le.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Le.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Le.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:Le.toString(r)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};Ss.create=t=>new Ss({checks:[],typeName:be.ZodBigInt,coerce:t?.coerce??!1,...nt(t)});var Es=class extends ot{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==Oe.boolean){let n=this._getOrReturnCtx(e);return Ee(n,{code:_e.invalid_type,expected:Oe.boolean,received:n.parsedType}),Ye}return cr(e.data)}};Es.create=t=>new Es({typeName:be.ZodBoolean,coerce:t?.coerce||!1,...nt(t)});var Ts=class t extends ot{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==Oe.date){let o=this._getOrReturnCtx(e);return Ee(o,{code:_e.invalid_type,expected:Oe.date,received:o.parsedType}),Ye}if(Number.isNaN(e.data.getTime())){let o=this._getOrReturnCtx(e);return Ee(o,{code:_e.invalid_date}),Ye}let n=new tr,s;for(let o of this._def.checks)o.kind==="min"?e.data.getTime()<o.value&&(s=this._getOrReturnCtx(e,s),Ee(s,{code:_e.too_small,message:o.message,inclusive:!0,exact:!1,minimum:o.value,type:"date"}),n.dirty()):o.kind==="max"?e.data.getTime()>o.value&&(s=this._getOrReturnCtx(e,s),Ee(s,{code:_e.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),n.dirty()):lt.assertNever(o);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:Le.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:Le.toString(r)})}get minDate(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}};Ts.create=t=>new Ts({checks:[],coerce:t?.coerce||!1,typeName:be.ZodDate,...nt(t)});var vo=class extends ot{_parse(e){if(this._getType(e)!==Oe.symbol){let n=this._getOrReturnCtx(e);return Ee(n,{code:_e.invalid_type,expected:Oe.symbol,received:n.parsedType}),Ye}return cr(e.data)}};vo.create=t=>new vo({typeName:be.ZodSymbol,...nt(t)});var $s=class extends ot{_parse(e){if(this._getType(e)!==Oe.undefined){let n=this._getOrReturnCtx(e);return Ee(n,{code:_e.invalid_type,expected:Oe.undefined,received:n.parsedType}),Ye}return cr(e.data)}};$s.create=t=>new $s({typeName:be.ZodUndefined,...nt(t)});var Rs=class extends ot{_parse(e){if(this._getType(e)!==Oe.null){let n=this._getOrReturnCtx(e);return Ee(n,{code:_e.invalid_type,expected:Oe.null,received:n.parsedType}),Ye}return cr(e.data)}};Rs.create=t=>new Rs({typeName:be.ZodNull,...nt(t)});var Xn=class extends ot{constructor(){super(...arguments),this._any=!0}_parse(e){return cr(e.data)}};Xn.create=t=>new Xn({typeName:be.ZodAny,...nt(t)});var jn=class extends ot{constructor(){super(...arguments),this._unknown=!0}_parse(e){return cr(e.data)}};jn.create=t=>new jn({typeName:be.ZodUnknown,...nt(t)});var ln=class extends ot{_parse(e){let r=this._getOrReturnCtx(e);return Ee(r,{code:_e.invalid_type,expected:Oe.never,received:r.parsedType}),Ye}};ln.create=t=>new ln({typeName:be.ZodNever,...nt(t)});var wo=class extends ot{_parse(e){if(this._getType(e)!==Oe.undefined){let n=this._getOrReturnCtx(e);return Ee(n,{code:_e.invalid_type,expected:Oe.void,received:n.parsedType}),Ye}return cr(e.data)}};wo.create=t=>new wo({typeName:be.ZodVoid,...nt(t)});var Dn=class t extends ot{_parse(e){let{ctx:r,status:n}=this._processInputParams(e),s=this._def;if(r.parsedType!==Oe.array)return Ee(r,{code:_e.invalid_type,expected:Oe.array,received:r.parsedType}),Ye;if(s.exactLength!==null){let i=r.data.length>s.exactLength.value,a=r.data.length<s.exactLength.value;(i||a)&&(Ee(r,{code:i?_e.too_big:_e.too_small,minimum:a?s.exactLength.value:void 0,maximum:i?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&r.data.length<s.minLength.value&&(Ee(r,{code:_e.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&r.data.length>s.maxLength.value&&(Ee(r,{code:_e.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((i,a)=>s.type._parseAsync(new Hr(r,i,r.path,a)))).then(i=>tr.mergeArray(n,i));let o=[...r.data].map((i,a)=>s.type._parseSync(new Hr(r,i,r.path,a)));return tr.mergeArray(n,o)}get element(){return this._def.type}min(e,r){return new t({...this._def,minLength:{value:e,message:Le.toString(r)}})}max(e,r){return new t({...this._def,maxLength:{value:e,message:Le.toString(r)}})}length(e,r){return new t({...this._def,exactLength:{value:e,message:Le.toString(r)}})}nonempty(e){return this.min(1,e)}};Dn.create=(t,e)=>new Dn({type:t,minLength:null,maxLength:null,exactLength:null,typeName:be.ZodArray,...nt(e)});function yo(t){if(t instanceof kr){let e={};for(let r in t.shape){let n=t.shape[r];e[r]=xr.create(yo(n))}return new kr({...t._def,shape:()=>e})}else return t instanceof Dn?new Dn({...t._def,type:yo(t.element)}):t instanceof xr?xr.create(yo(t.unwrap())):t instanceof Tn?Tn.create(yo(t.unwrap())):t instanceof En?En.create(t.items.map(e=>yo(e))):t}var kr=class t extends ot{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),r=lt.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==Oe.object){let d=this._getOrReturnCtx(e);return Ee(d,{code:_e.invalid_type,expected:Oe.object,received:d.parsedType}),Ye}let{status:n,ctx:s}=this._processInputParams(e),{shape:o,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof ln&&this._def.unknownKeys==="strip"))for(let d in s.data)i.includes(d)||a.push(d);let c=[];for(let d of i){let l=o[d],u=s.data[d];c.push({key:{status:"valid",value:d},value:l._parse(new Hr(s,u,s.path,d)),alwaysSet:d in s.data})}if(this._def.catchall instanceof ln){let d=this._def.unknownKeys;if(d==="passthrough")for(let l of a)c.push({key:{status:"valid",value:l},value:{status:"valid",value:s.data[l]}});else if(d==="strict")a.length>0&&(Ee(s,{code:_e.unrecognized_keys,keys:a}),n.dirty());else if(d!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let d=this._def.catchall;for(let l of a){let u=s.data[l];c.push({key:{status:"valid",value:l},value:d._parse(new Hr(s,u,s.path,l)),alwaysSet:l in s.data})}}return s.common.async?Promise.resolve().then(async()=>{let d=[];for(let l of c){let u=await l.key,h=await l.value;d.push({key:u,value:h,alwaysSet:l.alwaysSet})}return d}).then(d=>tr.mergeObjectSync(n,d)):tr.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return Le.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,n)=>{let s=this._def.errorMap?.(r,n).message??n.defaultError;return r.code==="unrecognized_keys"?{message:Le.errToObj(e).message??s}:{message:s}}}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:be.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let r={};for(let n of lt.objectKeys(e))e[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}omit(e){let r={};for(let n of lt.objectKeys(this.shape))e[n]||(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}deepPartial(){return yo(this)}partial(e){let r={};for(let n of lt.objectKeys(this.shape)){let s=this.shape[n];e&&!e[n]?r[n]=s:r[n]=s.optional()}return new t({...this._def,shape:()=>r})}required(e){let r={};for(let n of lt.objectKeys(this.shape))if(e&&!e[n])r[n]=this.shape[n];else{let o=this.shape[n];for(;o instanceof xr;)o=o._def.innerType;r[n]=o}return new t({...this._def,shape:()=>r})}keyof(){return O1(lt.objectKeys(this.shape))}};kr.create=(t,e)=>new kr({shape:()=>t,unknownKeys:"strip",catchall:ln.create(),typeName:be.ZodObject,...nt(e)});kr.strictCreate=(t,e)=>new kr({shape:()=>t,unknownKeys:"strict",catchall:ln.create(),typeName:be.ZodObject,...nt(e)});kr.lazycreate=(t,e)=>new kr({shape:t,unknownKeys:"strip",catchall:ln.create(),typeName:be.ZodObject,...nt(e)});var Ps=class extends ot{_parse(e){let{ctx:r}=this._processInputParams(e),n=this._def.options;function s(o){for(let a of o)if(a.result.status==="valid")return a.result;for(let a of o)if(a.result.status==="dirty")return r.common.issues.push(...a.ctx.common.issues),a.result;let i=o.map(a=>new wr(a.ctx.common.issues));return Ee(r,{code:_e.invalid_union,unionErrors:i}),Ye}if(r.common.async)return Promise.all(n.map(async o=>{let i={...r,common:{...r.common,issues:[]},parent:null};return{result:await o._parseAsync({data:r.data,path:r.path,parent:i}),ctx:i}})).then(s);{let o,i=[];for(let c of n){let d={...r,common:{...r.common,issues:[]},parent:null},l=c._parseSync({data:r.data,path:r.path,parent:d});if(l.status==="valid")return l;l.status==="dirty"&&!o&&(o={result:l,ctx:d}),d.common.issues.length&&i.push(d.common.issues)}if(o)return r.common.issues.push(...o.ctx.common.issues),o.result;let a=i.map(c=>new wr(c));return Ee(r,{code:_e.invalid_union,unionErrors:a}),Ye}}get options(){return this._def.options}};Ps.create=(t,e)=>new Ps({options:t,typeName:be.ZodUnion,...nt(e)});var Cn=t=>t instanceof zs?Cn(t.schema):t instanceof Ur?Cn(t.innerType()):t instanceof Is?[t.value]:t instanceof Os?t.options:t instanceof As?lt.objectValues(t.enum):t instanceof Ns?Cn(t._def.innerType):t instanceof $s?[void 0]:t instanceof Rs?[null]:t instanceof xr?[void 0,...Cn(t.unwrap())]:t instanceof Tn?[null,...Cn(t.unwrap())]:t instanceof wi||t instanceof js?Cn(t.unwrap()):t instanceof Cs?Cn(t._def.innerType):[],Ha=class t extends ot{_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==Oe.object)return Ee(r,{code:_e.invalid_type,expected:Oe.object,received:r.parsedType}),Ye;let n=this.discriminator,s=r.data[n],o=this.optionsMap.get(s);return o?r.common.async?o._parseAsync({data:r.data,path:r.path,parent:r}):o._parseSync({data:r.data,path:r.path,parent:r}):(Ee(r,{code:_e.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),Ye)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,n){let s=new Map;for(let o of r){let i=Cn(o.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let a of i){if(s.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);s.set(a,o)}}return new t({typeName:be.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:s,...nt(n)})}};function Su(t,e){let r=Sn(t),n=Sn(e);if(t===e)return{valid:!0,data:t};if(r===Oe.object&&n===Oe.object){let s=lt.objectKeys(e),o=lt.objectKeys(t).filter(a=>s.indexOf(a)!==-1),i={...t,...e};for(let a of o){let c=Su(t[a],e[a]);if(!c.valid)return{valid:!1};i[a]=c.data}return{valid:!0,data:i}}else if(r===Oe.array&&n===Oe.array){if(t.length!==e.length)return{valid:!1};let s=[];for(let o=0;o<t.length;o++){let i=t[o],a=e[o],c=Su(i,a);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return r===Oe.date&&n===Oe.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}var Ms=class extends ot{_parse(e){let{status:r,ctx:n}=this._processInputParams(e),s=(o,i)=>{if(Va(o)||Va(i))return Ye;let a=Su(o.value,i.value);return a.valid?((Fa(o)||Fa(i))&&r.dirty(),{status:r.value,value:a.data}):(Ee(n,{code:_e.invalid_intersection_types}),Ye)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([o,i])=>s(o,i)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};Ms.create=(t,e,r)=>new Ms({left:t,right:e,typeName:be.ZodIntersection,...nt(r)});var En=class t extends ot{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==Oe.array)return Ee(n,{code:_e.invalid_type,expected:Oe.array,received:n.parsedType}),Ye;if(n.data.length<this._def.items.length)return Ee(n,{code:_e.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Ye;!this._def.rest&&n.data.length>this._def.items.length&&(Ee(n,{code:_e.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let o=[...n.data].map((i,a)=>{let c=this._def.items[a]||this._def.rest;return c?c._parse(new Hr(n,i,n.path,a)):null}).filter(i=>!!i);return n.common.async?Promise.all(o).then(i=>tr.mergeArray(r,i)):tr.mergeArray(r,o)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};En.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new En({items:t,typeName:be.ZodTuple,rest:null,...nt(e)})};var Ua=class t extends ot{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==Oe.object)return Ee(n,{code:_e.invalid_type,expected:Oe.object,received:n.parsedType}),Ye;let s=[],o=this._def.keyType,i=this._def.valueType;for(let a in n.data)s.push({key:o._parse(new Hr(n,a,n.path,a)),value:i._parse(new Hr(n,n.data[a],n.path,a)),alwaysSet:a in n.data});return n.common.async?tr.mergeObjectAsync(r,s):tr.mergeObjectSync(r,s)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof ot?new t({keyType:e,valueType:r,typeName:be.ZodRecord,...nt(n)}):new t({keyType:Yn.create(),valueType:e,typeName:be.ZodRecord,...nt(r)})}},xo=class extends ot{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==Oe.map)return Ee(n,{code:_e.invalid_type,expected:Oe.map,received:n.parsedType}),Ye;let s=this._def.keyType,o=this._def.valueType,i=[...n.data.entries()].map(([a,c],d)=>({key:s._parse(new Hr(n,a,n.path,[d,"key"])),value:o._parse(new Hr(n,c,n.path,[d,"value"]))}));if(n.common.async){let a=new Map;return Promise.resolve().then(async()=>{for(let c of i){let d=await c.key,l=await c.value;if(d.status==="aborted"||l.status==="aborted")return Ye;(d.status==="dirty"||l.status==="dirty")&&r.dirty(),a.set(d.value,l.value)}return{status:r.value,value:a}})}else{let a=new Map;for(let c of i){let d=c.key,l=c.value;if(d.status==="aborted"||l.status==="aborted")return Ye;(d.status==="dirty"||l.status==="dirty")&&r.dirty(),a.set(d.value,l.value)}return{status:r.value,value:a}}}};xo.create=(t,e,r)=>new xo({valueType:e,keyType:t,typeName:be.ZodMap,...nt(r)});var ko=class t extends ot{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==Oe.set)return Ee(n,{code:_e.invalid_type,expected:Oe.set,received:n.parsedType}),Ye;let s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(Ee(n,{code:_e.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),r.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(Ee(n,{code:_e.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),r.dirty());let o=this._def.valueType;function i(c){let d=new Set;for(let l of c){if(l.status==="aborted")return Ye;l.status==="dirty"&&r.dirty(),d.add(l.value)}return{status:r.value,value:d}}let a=[...n.data.values()].map((c,d)=>o._parse(new Hr(n,c,n.path,d)));return n.common.async?Promise.all(a).then(c=>i(c)):i(a)}min(e,r){return new t({...this._def,minSize:{value:e,message:Le.toString(r)}})}max(e,r){return new t({...this._def,maxSize:{value:e,message:Le.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}};ko.create=(t,e)=>new ko({valueType:t,minSize:null,maxSize:null,typeName:be.ZodSet,...nt(e)});var Ga=class t extends ot{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==Oe.function)return Ee(r,{code:_e.invalid_type,expected:Oe.function,received:r.parsedType}),Ye;function n(a,c){return vi({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,_o(),Nn].filter(d=>!!d),issueData:{code:_e.invalid_arguments,argumentsError:c}})}function s(a,c){return vi({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,_o(),Nn].filter(d=>!!d),issueData:{code:_e.invalid_return_type,returnTypeError:c}})}let o={errorMap:r.common.contextualErrorMap},i=r.data;if(this._def.returns instanceof Wn){let a=this;return cr(async function(...c){let d=new wr([]),l=await a._def.args.parseAsync(c,o).catch(p=>{throw d.addIssue(n(c,p)),d}),u=await Reflect.apply(i,this,l);return await a._def.returns._def.type.parseAsync(u,o).catch(p=>{throw d.addIssue(s(u,p)),d})})}else{let a=this;return cr(function(...c){let d=a._def.args.safeParse(c,o);if(!d.success)throw new wr([n(c,d.error)]);let l=Reflect.apply(i,this,d.data),u=a._def.returns.safeParse(l,o);if(!u.success)throw new wr([s(l,u.error)]);return u.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:En.create(e).rest(jn.create())})}returns(e){return new t({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,n){return new t({args:e||En.create([]).rest(jn.create()),returns:r||jn.create(),typeName:be.ZodFunction,...nt(n)})}},zs=class extends ot{get schema(){return this._def.getter()}_parse(e){let{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};zs.create=(t,e)=>new zs({getter:t,typeName:be.ZodLazy,...nt(e)});var Is=class extends ot{_parse(e){if(e.data!==this._def.value){let r=this._getOrReturnCtx(e);return Ee(r,{received:r.data,code:_e.invalid_literal,expected:this._def.value}),Ye}return{status:"valid",value:e.data}}get value(){return this._def.value}};Is.create=(t,e)=>new Is({value:t,typeName:be.ZodLiteral,...nt(e)});function O1(t,e){return new Os({values:t,typeName:be.ZodEnum,...nt(e)})}var Os=class t extends ot{_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),n=this._def.values;return Ee(r,{expected:lt.joinValues(n),received:r.parsedType,code:_e.invalid_type}),Ye}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let r=this._getOrReturnCtx(e),n=this._def.values;return Ee(r,{received:r.data,code:_e.invalid_enum_value,options:n}),Ye}return cr(e.data)}get options(){return this._def.values}get enum(){let e={};for(let r of this._def.values)e[r]=r;return e}get Values(){let e={};for(let r of this._def.values)e[r]=r;return e}get Enum(){let e={};for(let r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return t.create(e,{...this._def,...r})}exclude(e,r=this._def){return t.create(this.options.filter(n=>!e.includes(n)),{...this._def,...r})}};Os.create=O1;var As=class extends ot{_parse(e){let r=lt.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==Oe.string&&n.parsedType!==Oe.number){let s=lt.objectValues(r);return Ee(n,{expected:lt.joinValues(s),received:n.parsedType,code:_e.invalid_type}),Ye}if(this._cache||(this._cache=new Set(lt.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let s=lt.objectValues(r);return Ee(n,{received:n.data,code:_e.invalid_enum_value,options:s}),Ye}return cr(e.data)}get enum(){return this._def.values}};As.create=(t,e)=>new As({values:t,typeName:be.ZodNativeEnum,...nt(e)});var Wn=class extends ot{unwrap(){return this._def.type}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==Oe.promise&&r.common.async===!1)return Ee(r,{code:_e.invalid_type,expected:Oe.promise,received:r.parsedType}),Ye;let n=r.parsedType===Oe.promise?r.data:Promise.resolve(r.data);return cr(n.then(s=>this._def.type.parseAsync(s,{path:r.path,errorMap:r.common.contextualErrorMap})))}};Wn.create=(t,e)=>new Wn({type:t,typeName:be.ZodPromise,...nt(e)});var Ur=class extends ot{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===be.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:r,ctx:n}=this._processInputParams(e),s=this._def.effect||null,o={addIssue:i=>{Ee(n,i),i.fatal?r.abort():r.dirty()},get path(){return n.path}};if(o.addIssue=o.addIssue.bind(o),s.type==="preprocess"){let i=s.transform(n.data,o);if(n.common.async)return Promise.resolve(i).then(async a=>{if(r.value==="aborted")return Ye;let c=await this._def.schema._parseAsync({data:a,path:n.path,parent:n});return c.status==="aborted"?Ye:c.status==="dirty"?xs(c.value):r.value==="dirty"?xs(c.value):c});{if(r.value==="aborted")return Ye;let a=this._def.schema._parseSync({data:i,path:n.path,parent:n});return a.status==="aborted"?Ye:a.status==="dirty"?xs(a.value):r.value==="dirty"?xs(a.value):a}}if(s.type==="refinement"){let i=a=>{let c=s.refinement(a,o);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(n.common.async===!1){let a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?Ye:(a.status==="dirty"&&r.dirty(),i(a.value),{status:r.value,value:a.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>a.status==="aborted"?Ye:(a.status==="dirty"&&r.dirty(),i(a.value).then(()=>({status:r.value,value:a.value}))))}if(s.type==="transform")if(n.common.async===!1){let i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Gn(i))return Ye;let a=s.transform(i.value,o);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:a}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>Gn(i)?Promise.resolve(s.transform(i.value,o)).then(a=>({status:r.value,value:a})):Ye);lt.assertNever(s)}};Ur.create=(t,e,r)=>new Ur({schema:t,typeName:be.ZodEffects,effect:e,...nt(r)});Ur.createWithPreprocess=(t,e,r)=>new Ur({schema:e,effect:{type:"preprocess",transform:t},typeName:be.ZodEffects,...nt(r)});var xr=class extends ot{_parse(e){return this._getType(e)===Oe.undefined?cr(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};xr.create=(t,e)=>new xr({innerType:t,typeName:be.ZodOptional,...nt(e)});var Tn=class extends ot{_parse(e){return this._getType(e)===Oe.null?cr(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Tn.create=(t,e)=>new Tn({innerType:t,typeName:be.ZodNullable,...nt(e)});var Ns=class extends ot{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return r.parsedType===Oe.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};Ns.create=(t,e)=>new Ns({innerType:t,typeName:be.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...nt(e)});var Cs=class extends ot{_parse(e){let{ctx:r}=this._processInputParams(e),n={...r,common:{...r.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return bo(s)?s.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new wr(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new wr(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};Cs.create=(t,e)=>new Cs({innerType:t,typeName:be.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...nt(e)});var So=class extends ot{_parse(e){if(this._getType(e)!==Oe.nan){let n=this._getOrReturnCtx(e);return Ee(n,{code:_e.invalid_type,expected:Oe.nan,received:n.parsedType}),Ye}return{status:"valid",value:e.data}}};So.create=t=>new So({typeName:be.ZodNaN,...nt(t)});var k4=Symbol("zod_brand"),wi=class extends ot{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}},xi=class t extends ot{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let o=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?Ye:o.status==="dirty"?(r.dirty(),xs(o.value)):this._def.out._parseAsync({data:o.value,path:n.path,parent:n})})();{let s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?Ye:s.status==="dirty"?(r.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,r){return new t({in:e,out:r,typeName:be.ZodPipeline})}},js=class extends ot{_parse(e){let r=this._def.innerType._parse(e),n=s=>(Gn(s)&&(s.value=Object.freeze(s.value)),s);return bo(r)?r.then(s=>n(s)):n(r)}unwrap(){return this._def.innerType}};js.create=(t,e)=>new js({innerType:t,typeName:be.ZodReadonly,...nt(e)});function P1(t,e){let r=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof r=="string"?{message:r}:r}function A1(t,e={},r){return t?Xn.create().superRefine((n,s)=>{let o=t(n);if(o instanceof Promise)return o.then(i=>{if(!i){let a=P1(e,n),c=a.fatal??r??!0;s.addIssue({code:"custom",...a,fatal:c})}});if(!o){let i=P1(e,n),a=i.fatal??r??!0;s.addIssue({code:"custom",...i,fatal:a})}}):Xn.create()}var S4={object:kr.lazycreate},be;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(be||(be={}));var E4=(t,e={message:`Input not instance of ${t.name}`})=>A1(r=>r instanceof t,e),N1=Yn.create,C1=ks.create,T4=So.create,$4=Ss.create,j1=Es.create,R4=Ts.create,P4=vo.create,M4=$s.create,z4=Rs.create,I4=Xn.create,O4=jn.create,A4=ln.create,N4=wo.create,C4=Dn.create,Eu=kr.create,j4=kr.strictCreate,D4=Ps.create,L4=Ha.create,Z4=Ms.create,B4=En.create,q4=Ua.create,V4=xo.create,F4=ko.create,H4=Ga.create,U4=zs.create,G4=Is.create,Y4=Os.create,X4=As.create,W4=Wn.create,K4=Ur.create,J4=xr.create,Q4=Tn.create,e5=Ur.createWithPreprocess,t5=xi.create,r5=()=>N1().optional(),n5=()=>C1().optional(),s5=()=>j1().optional(),o5={string:t=>Yn.create({...t,coerce:!0}),number:t=>ks.create({...t,coerce:!0}),boolean:t=>Es.create({...t,coerce:!0}),bigint:t=>Ss.create({...t,coerce:!0}),date:t=>Ts.create({...t,coerce:!0})};var i5=Ye;var a5=Object.freeze({status:"aborted"});function le(t,e,r){function n(a,c){var d;Object.defineProperty(a,"_zod",{value:a._zod??{},enumerable:!1}),(d=a._zod).traits??(d.traits=new Set),a._zod.traits.add(t),e(a,c);for(let l in i.prototype)l in a||Object.defineProperty(a,l,{value:i.prototype[l].bind(a)});a._zod.constr=i,a._zod.def=c}let s=r?.Parent??Object;class o extends s{}Object.defineProperty(o,"name",{value:t});function i(a){var c;let d=r?.Parent?new o:this;n(d,a),(c=d._zod).deferred??(c.deferred=[]);for(let l of d._zod.deferred)l();return d}return Object.defineProperty(i,"init",{value:n}),Object.defineProperty(i,Symbol.hasInstance,{value:a=>r?.Parent&&a instanceof r.Parent?!0:a?._zod?.traits?.has(t)}),Object.defineProperty(i,"name",{value:t}),i}var c5=Symbol("zod_brand"),Ln=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},Ya={};function Cr(t){return t&&Object.assign(Ya,t),Ya}var ut={};wu(ut,{BIGINT_FORMAT_RANGES:()=>L1,Class:()=>$u,NUMBER_FORMAT_RANGES:()=>Au,aborted:()=>Ls,allowsEval:()=>zu,assert:()=>h5,assertEqual:()=>l5,assertIs:()=>d5,assertNever:()=>f5,assertNotEqual:()=>u5,assignProp:()=>Mu,cached:()=>Ei,captureStackTrace:()=>Wa,cleanEnum:()=>T5,cleanRegex:()=>$i,clone:()=>jr,createTransparentProxy:()=>y5,defineLazy:()=>$t,esc:()=>Ds,escapeRegex:()=>Kn,extend:()=>x5,finalizeIssue:()=>un,floatSafeRemainder:()=>Pu,getElementAtPath:()=>p5,getEnumValues:()=>Si,getLengthableOrigin:()=>Ri,getParsedType:()=>b5,getSizableOrigin:()=>Z1,isObject:()=>Eo,isPlainObject:()=>To,issue:()=>Nu,joinValues:()=>Xa,jsonStringifyReplacer:()=>Ru,merge:()=>k5,normalizeParams:()=>Xe,nullish:()=>Ti,numKeys:()=>_5,omit:()=>w5,optionalKeys:()=>Ou,partial:()=>S5,pick:()=>v5,prefixIssues:()=>$n,primitiveTypes:()=>D1,promiseAllObject:()=>m5,propertyKeyTypes:()=>Iu,randomString:()=>g5,required:()=>E5,stringifyPrimitive:()=>Ka,unwrapMessage:()=>ki});function l5(t){return t}function u5(t){return t}function d5(t){}function f5(t){throw new Error}function h5(t){}function Si(t){let e=Object.values(t).filter(n=>typeof n=="number");return Object.entries(t).filter(([n,s])=>e.indexOf(+n)===-1).map(([n,s])=>s)}function Xa(t,e="|"){return t.map(r=>Ka(r)).join(e)}function Ru(t,e){return typeof e=="bigint"?e.toString():e}function Ei(t){return{get value(){{let r=t();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function Ti(t){return t==null}function $i(t){let e=t.startsWith("^")?1:0,r=t.endsWith("$")?t.length-1:t.length;return t.slice(e,r)}function Pu(t,e){let r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=r>n?r:n,o=Number.parseInt(t.toFixed(s).replace(".","")),i=Number.parseInt(e.toFixed(s).replace(".",""));return o%i/10**s}function $t(t,e,r){Object.defineProperty(t,e,{get(){{let s=r();return t[e]=s,s}throw new Error("cached value already set")},set(s){Object.defineProperty(t,e,{value:s})},configurable:!0})}function Mu(t,e,r){Object.defineProperty(t,e,{value:r,writable:!0,enumerable:!0,configurable:!0})}function p5(t,e){return e?e.reduce((r,n)=>r?.[n],t):t}function m5(t){let e=Object.keys(t),r=e.map(n=>t[n]);return Promise.all(r).then(n=>{let s={};for(let o=0;o<e.length;o++)s[e[o]]=n[o];return s})}function g5(t=10){let e="abcdefghijklmnopqrstuvwxyz",r="";for(let n=0;n<t;n++)r+=e[Math.floor(Math.random()*e.length)];return r}function Ds(t){return JSON.stringify(t)}var Wa=Error.captureStackTrace?Error.captureStackTrace:(...t)=>{};function Eo(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}var zu=Ei(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let t=Function;return new t(""),!0}catch{return!1}});function To(t){if(Eo(t)===!1)return!1;let e=t.constructor;if(e===void 0)return!0;let r=e.prototype;return!(Eo(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function _5(t){let e=0;for(let r in t)Object.prototype.hasOwnProperty.call(t,r)&&e++;return e}var b5=t=>{let e=typeof t;switch(e){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(t)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(t)?"array":t===null?"null":t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?"promise":typeof Map<"u"&&t instanceof Map?"map":typeof Set<"u"&&t instanceof Set?"set":typeof Date<"u"&&t instanceof Date?"date":typeof File<"u"&&t instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${e}`)}},Iu=new Set(["string","number","symbol"]),D1=new Set(["string","number","bigint","boolean","symbol","undefined"]);function Kn(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function jr(t,e,r){let n=new t._zod.constr(e??t._zod.def);return(!e||r?.parent)&&(n._zod.parent=t),n}function Xe(t){let e=t;if(!e)return{};if(typeof e=="string")return{error:()=>e};if(e?.message!==void 0){if(e?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");e.error=e.message}return delete e.message,typeof e.error=="string"?{...e,error:()=>e.error}:e}function y5(t){let e;return new Proxy({},{get(r,n,s){return e??(e=t()),Reflect.get(e,n,s)},set(r,n,s,o){return e??(e=t()),Reflect.set(e,n,s,o)},has(r,n){return e??(e=t()),Reflect.has(e,n)},deleteProperty(r,n){return e??(e=t()),Reflect.deleteProperty(e,n)},ownKeys(r){return e??(e=t()),Reflect.ownKeys(e)},getOwnPropertyDescriptor(r,n){return e??(e=t()),Reflect.getOwnPropertyDescriptor(e,n)},defineProperty(r,n,s){return e??(e=t()),Reflect.defineProperty(e,n,s)}})}function Ka(t){return typeof t=="bigint"?t.toString()+"n":typeof t=="string"?`"${t}"`:`${t}`}function Ou(t){return Object.keys(t).filter(e=>t[e]._zod.optin==="optional"&&t[e]._zod.optout==="optional")}var Au={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},L1={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function v5(t,e){let r={},n=t._zod.def;for(let s in e){if(!(s in n.shape))throw new Error(`Unrecognized key: "${s}"`);e[s]&&(r[s]=n.shape[s])}return jr(t,{...t._zod.def,shape:r,checks:[]})}function w5(t,e){let r={...t._zod.def.shape},n=t._zod.def;for(let s in e){if(!(s in n.shape))throw new Error(`Unrecognized key: "${s}"`);e[s]&&delete r[s]}return jr(t,{...t._zod.def,shape:r,checks:[]})}function x5(t,e){if(!To(e))throw new Error("Invalid input to extend: expected a plain object");let r={...t._zod.def,get shape(){let n={...t._zod.def.shape,...e};return Mu(this,"shape",n),n},checks:[]};return jr(t,r)}function k5(t,e){return jr(t,{...t._zod.def,get shape(){let r={...t._zod.def.shape,...e._zod.def.shape};return Mu(this,"shape",r),r},catchall:e._zod.def.catchall,checks:[]})}function S5(t,e,r){let n=e._zod.def.shape,s={...n};if(r)for(let o in r){if(!(o in n))throw new Error(`Unrecognized key: "${o}"`);r[o]&&(s[o]=t?new t({type:"optional",innerType:n[o]}):n[o])}else for(let o in n)s[o]=t?new t({type:"optional",innerType:n[o]}):n[o];return jr(e,{...e._zod.def,shape:s,checks:[]})}function E5(t,e,r){let n=e._zod.def.shape,s={...n};if(r)for(let o in r){if(!(o in s))throw new Error(`Unrecognized key: "${o}"`);r[o]&&(s[o]=new t({type:"nonoptional",innerType:n[o]}))}else for(let o in n)s[o]=new t({type:"nonoptional",innerType:n[o]});return jr(e,{...e._zod.def,shape:s,checks:[]})}function Ls(t,e=0){for(let r=e;r<t.issues.length;r++)if(t.issues[r]?.continue!==!0)return!0;return!1}function $n(t,e){return e.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(t),r})}function ki(t){return typeof t=="string"?t:t?.message}function un(t,e,r){let n={...t,path:t.path??[]};if(!t.message){let s=ki(t.inst?._zod.def?.error?.(t))??ki(e?.error?.(t))??ki(r.customError?.(t))??ki(r.localeError?.(t))??"Invalid input";n.message=s}return delete n.inst,delete n.continue,e?.reportInput||delete n.input,n}function Z1(t){return t instanceof Set?"set":t instanceof Map?"map":t instanceof File?"file":"unknown"}function Ri(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}function Nu(...t){let[e,r,n]=t;return typeof e=="string"?{message:e,code:"custom",input:r,inst:n}:{...e}}function T5(t){return Object.entries(t).filter(([e,r])=>Number.isNaN(Number.parseInt(e,10))).map(e=>e[1])}var $u=class{constructor(...e){}};var B1=(t,e)=>{t.name="$ZodError",Object.defineProperty(t,"_zod",{value:t._zod,enumerable:!1}),Object.defineProperty(t,"issues",{value:e,enumerable:!1}),Object.defineProperty(t,"message",{get(){return JSON.stringify(e,Ru,2)},enumerable:!0}),Object.defineProperty(t,"toString",{value:()=>t.message,enumerable:!1})},Ja=le("$ZodError",B1),Pi=le("$ZodError",B1,{Parent:Error});function Cu(t,e=r=>r.message){let r={},n=[];for(let s of t.issues)s.path.length>0?(r[s.path[0]]=r[s.path[0]]||[],r[s.path[0]].push(e(s))):n.push(e(s));return{formErrors:n,fieldErrors:r}}function ju(t,e){let r=e||function(o){return o.message},n={_errors:[]},s=o=>{for(let i of o.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(a=>s({issues:a}));else if(i.code==="invalid_key")s({issues:i.issues});else if(i.code==="invalid_element")s({issues:i.issues});else if(i.path.length===0)n._errors.push(r(i));else{let a=n,c=0;for(;c<i.path.length;){let d=i.path[c];c===i.path.length-1?(a[d]=a[d]||{_errors:[]},a[d]._errors.push(r(i))):a[d]=a[d]||{_errors:[]},a=a[d],c++}}};return s(t),n}var Du=t=>(e,r,n,s)=>{let o=n?Object.assign(n,{async:!1}):{async:!1},i=e._zod.run({value:r,issues:[]},o);if(i instanceof Promise)throw new Ln;if(i.issues.length){let a=new(s?.Err??t)(i.issues.map(c=>un(c,o,Cr())));throw Wa(a,s?.callee),a}return i.value},Lu=Du(Pi),Zu=t=>async(e,r,n,s)=>{let o=n?Object.assign(n,{async:!0}):{async:!0},i=e._zod.run({value:r,issues:[]},o);if(i instanceof Promise&&(i=await i),i.issues.length){let a=new(s?.Err??t)(i.issues.map(c=>un(c,o,Cr())));throw Wa(a,s?.callee),a}return i.value},Bu=Zu(Pi),qu=t=>(e,r,n)=>{let s=n?{...n,async:!1}:{async:!1},o=e._zod.run({value:r,issues:[]},s);if(o instanceof Promise)throw new Ln;return o.issues.length?{success:!1,error:new(t??Ja)(o.issues.map(i=>un(i,s,Cr())))}:{success:!0,data:o.value}},Zs=qu(Pi),Vu=t=>async(e,r,n)=>{let s=n?Object.assign(n,{async:!0}):{async:!0},o=e._zod.run({value:r,issues:[]},s);return o instanceof Promise&&(o=await o),o.issues.length?{success:!1,error:new t(o.issues.map(i=>un(i,s,Cr())))}:{success:!0,data:o.value}},Bs=Vu(Pi);var q1=/^[cC][^\s-]{8,}$/,V1=/^[0-9a-z]+$/,F1=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,H1=/^[0-9a-vA-V]{20}$/,U1=/^[A-Za-z0-9]{27}$/,G1=/^[a-zA-Z0-9_-]{21}$/,Y1=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var X1=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Fu=t=>t?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${t}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$/;var W1=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var R5="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function K1(){return new RegExp(R5,"u")}var J1=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Q1=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})$/,e0=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,t0=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,r0=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Hu=/^[A-Za-z0-9_-]*$/,n0=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/;var s0=/^\+(?:[0-9]){6,14}[0-9]$/,o0="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",i0=new RegExp(`^${o0}$`);function a0(t){let e="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof t.precision=="number"?t.precision===-1?`${e}`:t.precision===0?`${e}:[0-5]\\d`:`${e}:[0-5]\\d\\.\\d{${t.precision}}`:`${e}(?::[0-5]\\d(?:\\.\\d+)?)?`}function c0(t){return new RegExp(`^${a0(t)}$`)}function l0(t){let e=a0({precision:t.precision}),r=["Z"];t.local&&r.push(""),t.offset&&r.push("([+-]\\d{2}:\\d{2})");let n=`${e}(?:${r.join("|")})`;return new RegExp(`^${o0}T(?:${n})$`)}var u0=t=>{let e=t?`[\\s\\S]{${t?.minimum??0},${t?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)};var d0=/^\d+$/,f0=/^-?\d+(?:\.\d+)?/i,h0=/true|false/i,p0=/null/i;var m0=/^[^A-Z]*$/,g0=/^[^a-z]*$/;var rr=le("$ZodCheck",(t,e)=>{var r;t._zod??(t._zod={}),t._zod.def=e,(r=t._zod).onattach??(r.onattach=[])}),_0={number:"number",bigint:"bigint",object:"date"},Uu=le("$ZodCheckLessThan",(t,e)=>{rr.init(t,e);let r=_0[typeof e.value];t._zod.onattach.push(n=>{let s=n._zod.bag,o=(e.inclusive?s.maximum:s.exclusiveMaximum)??Number.POSITIVE_INFINITY;e.value<o&&(e.inclusive?s.maximum=e.value:s.exclusiveMaximum=e.value)}),t._zod.check=n=>{(e.inclusive?n.value<=e.value:n.value<e.value)||n.issues.push({origin:r,code:"too_big",maximum:e.value,input:n.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),Gu=le("$ZodCheckGreaterThan",(t,e)=>{rr.init(t,e);let r=_0[typeof e.value];t._zod.onattach.push(n=>{let s=n._zod.bag,o=(e.inclusive?s.minimum:s.exclusiveMinimum)??Number.NEGATIVE_INFINITY;e.value>o&&(e.inclusive?s.minimum=e.value:s.exclusiveMinimum=e.value)}),t._zod.check=n=>{(e.inclusive?n.value>=e.value:n.value>e.value)||n.issues.push({origin:r,code:"too_small",minimum:e.value,input:n.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),b0=le("$ZodCheckMultipleOf",(t,e)=>{rr.init(t,e),t._zod.onattach.push(r=>{var n;(n=r._zod.bag).multipleOf??(n.multipleOf=e.value)}),t._zod.check=r=>{if(typeof r.value!=typeof e.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%e.value===BigInt(0):Pu(r.value,e.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:e.value,input:r.value,inst:t,continue:!e.abort})}}),y0=le("$ZodCheckNumberFormat",(t,e)=>{rr.init(t,e),e.format=e.format||"float64";let r=e.format?.includes("int"),n=r?"int":"number",[s,o]=Au[e.format];t._zod.onattach.push(i=>{let a=i._zod.bag;a.format=e.format,a.minimum=s,a.maximum=o,r&&(a.pattern=d0)}),t._zod.check=i=>{let a=i.value;if(r){if(!Number.isInteger(a)){i.issues.push({expected:n,format:e.format,code:"invalid_type",input:a,inst:t});return}if(!Number.isSafeInteger(a)){a>0?i.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:n,continue:!e.abort}):i.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:n,continue:!e.abort});return}}a<s&&i.issues.push({origin:"number",input:a,code:"too_small",minimum:s,inclusive:!0,inst:t,continue:!e.abort}),a>o&&i.issues.push({origin:"number",input:a,code:"too_big",maximum:o,inst:t})}});var v0=le("$ZodCheckMaxLength",(t,e)=>{var r;rr.init(t,e),(r=t._zod.def).when??(r.when=n=>{let s=n.value;return!Ti(s)&&s.length!==void 0}),t._zod.onattach.push(n=>{let s=n._zod.bag.maximum??Number.POSITIVE_INFINITY;e.maximum<s&&(n._zod.bag.maximum=e.maximum)}),t._zod.check=n=>{let s=n.value;if(s.length<=e.maximum)return;let i=Ri(s);n.issues.push({origin:i,code:"too_big",maximum:e.maximum,inclusive:!0,input:s,inst:t,continue:!e.abort})}}),w0=le("$ZodCheckMinLength",(t,e)=>{var r;rr.init(t,e),(r=t._zod.def).when??(r.when=n=>{let s=n.value;return!Ti(s)&&s.length!==void 0}),t._zod.onattach.push(n=>{let s=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;e.minimum>s&&(n._zod.bag.minimum=e.minimum)}),t._zod.check=n=>{let s=n.value;if(s.length>=e.minimum)return;let i=Ri(s);n.issues.push({origin:i,code:"too_small",minimum:e.minimum,inclusive:!0,input:s,inst:t,continue:!e.abort})}}),x0=le("$ZodCheckLengthEquals",(t,e)=>{var r;rr.init(t,e),(r=t._zod.def).when??(r.when=n=>{let s=n.value;return!Ti(s)&&s.length!==void 0}),t._zod.onattach.push(n=>{let s=n._zod.bag;s.minimum=e.length,s.maximum=e.length,s.length=e.length}),t._zod.check=n=>{let s=n.value,o=s.length;if(o===e.length)return;let i=Ri(s),a=o>e.length;n.issues.push({origin:i,...a?{code:"too_big",maximum:e.length}:{code:"too_small",minimum:e.length},inclusive:!0,exact:!0,input:n.value,inst:t,continue:!e.abort})}}),Mi=le("$ZodCheckStringFormat",(t,e)=>{var r,n;rr.init(t,e),t._zod.onattach.push(s=>{let o=s._zod.bag;o.format=e.format,e.pattern&&(o.patterns??(o.patterns=new Set),o.patterns.add(e.pattern))}),e.pattern?(r=t._zod).check??(r.check=s=>{e.pattern.lastIndex=0,!e.pattern.test(s.value)&&s.issues.push({origin:"string",code:"invalid_format",format:e.format,input:s.value,...e.pattern?{pattern:e.pattern.toString()}:{},inst:t,continue:!e.abort})}):(n=t._zod).check??(n.check=()=>{})}),k0=le("$ZodCheckRegex",(t,e)=>{Mi.init(t,e),t._zod.check=r=>{e.pattern.lastIndex=0,!e.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:e.pattern.toString(),inst:t,continue:!e.abort})}}),S0=le("$ZodCheckLowerCase",(t,e)=>{e.pattern??(e.pattern=m0),Mi.init(t,e)}),E0=le("$ZodCheckUpperCase",(t,e)=>{e.pattern??(e.pattern=g0),Mi.init(t,e)}),T0=le("$ZodCheckIncludes",(t,e)=>{rr.init(t,e);let r=Kn(e.includes),n=new RegExp(typeof e.position=="number"?`^.{${e.position}}${r}`:r);e.pattern=n,t._zod.onattach.push(s=>{let o=s._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),t._zod.check=s=>{s.value.includes(e.includes,e.position)||s.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:e.includes,input:s.value,inst:t,continue:!e.abort})}}),$0=le("$ZodCheckStartsWith",(t,e)=>{rr.init(t,e);let r=new RegExp(`^${Kn(e.prefix)}.*`);e.pattern??(e.pattern=r),t._zod.onattach.push(n=>{let s=n._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),t._zod.check=n=>{n.value.startsWith(e.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:e.prefix,input:n.value,inst:t,continue:!e.abort})}}),R0=le("$ZodCheckEndsWith",(t,e)=>{rr.init(t,e);let r=new RegExp(`.*${Kn(e.suffix)}$`);e.pattern??(e.pattern=r),t._zod.onattach.push(n=>{let s=n._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),t._zod.check=n=>{n.value.endsWith(e.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:e.suffix,input:n.value,inst:t,continue:!e.abort})}});var P0=le("$ZodCheckOverwrite",(t,e)=>{rr.init(t,e),t._zod.check=r=>{r.value=e.tx(r.value)}});var ec=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e=="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let n=e.split(`
|
|
10
|
+
`).filter(i=>i),s=Math.min(...n.map(i=>i.length-i.trimStart().length)),o=n.map(i=>i.slice(s)).map(i=>" ".repeat(this.indent*2)+i);for(let i of o)this.content.push(i)}compile(){let e=Function,r=this?.args,s=[...(this?.content??[""]).map(o=>` ${o}`)];return new e(...r,s.join(`
|
|
11
|
+
`))}};var z0={major:4,minor:0,patch:0};var xt=le("$ZodType",(t,e)=>{var r;t??(t={}),t._zod.def=e,t._zod.bag=t._zod.bag||{},t._zod.version=z0;let n=[...t._zod.def.checks??[]];t._zod.traits.has("$ZodCheck")&&n.unshift(t);for(let s of n)for(let o of s._zod.onattach)o(t);if(n.length===0)(r=t._zod).deferred??(r.deferred=[]),t._zod.deferred?.push(()=>{t._zod.run=t._zod.parse});else{let s=(o,i,a)=>{let c=Ls(o),d;for(let l of i){if(l._zod.def.when){if(!l._zod.def.when(o))continue}else if(c)continue;let u=o.issues.length,h=l._zod.check(o);if(h instanceof Promise&&a?.async===!1)throw new Ln;if(d||h instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await h,o.issues.length!==u&&(c||(c=Ls(o,u)))});else{if(o.issues.length===u)continue;c||(c=Ls(o,u))}}return d?d.then(()=>o):o};t._zod.run=(o,i)=>{let a=t._zod.parse(o,i);if(a instanceof Promise){if(i.async===!1)throw new Ln;return a.then(c=>s(c,n,i))}return s(a,n,i)}}t["~standard"]={validate:s=>{try{let o=Zs(t,s);return o.success?{value:o.data}:{issues:o.error?.issues}}catch{return Bs(t,s).then(i=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}}),zi=le("$ZodString",(t,e)=>{xt.init(t,e),t._zod.pattern=[...t?._zod.bag?.patterns??[]].pop()??u0(t._zod.bag),t._zod.parse=(r,n)=>{if(e.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:t}),r}}),Rt=le("$ZodStringFormat",(t,e)=>{Mi.init(t,e),zi.init(t,e)}),Xu=le("$ZodGUID",(t,e)=>{e.pattern??(e.pattern=X1),Rt.init(t,e)}),Wu=le("$ZodUUID",(t,e)=>{if(e.version){let n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[e.version];if(n===void 0)throw new Error(`Invalid UUID version: "${e.version}"`);e.pattern??(e.pattern=Fu(n))}else e.pattern??(e.pattern=Fu());Rt.init(t,e)}),Ku=le("$ZodEmail",(t,e)=>{e.pattern??(e.pattern=W1),Rt.init(t,e)}),Ju=le("$ZodURL",(t,e)=>{Rt.init(t,e),t._zod.check=r=>{try{let n=r.value,s=new URL(n),o=s.href;e.hostname&&(e.hostname.lastIndex=0,e.hostname.test(s.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:n0.source,input:r.value,inst:t,continue:!e.abort})),e.protocol&&(e.protocol.lastIndex=0,e.protocol.test(s.protocol.endsWith(":")?s.protocol.slice(0,-1):s.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:e.protocol.source,input:r.value,inst:t,continue:!e.abort})),!n.endsWith("/")&&o.endsWith("/")?r.value=o.slice(0,-1):r.value=o;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:t,continue:!e.abort})}}}),Qu=le("$ZodEmoji",(t,e)=>{e.pattern??(e.pattern=K1()),Rt.init(t,e)}),ed=le("$ZodNanoID",(t,e)=>{e.pattern??(e.pattern=G1),Rt.init(t,e)}),td=le("$ZodCUID",(t,e)=>{e.pattern??(e.pattern=q1),Rt.init(t,e)}),rd=le("$ZodCUID2",(t,e)=>{e.pattern??(e.pattern=V1),Rt.init(t,e)}),nd=le("$ZodULID",(t,e)=>{e.pattern??(e.pattern=F1),Rt.init(t,e)}),sd=le("$ZodXID",(t,e)=>{e.pattern??(e.pattern=H1),Rt.init(t,e)}),od=le("$ZodKSUID",(t,e)=>{e.pattern??(e.pattern=U1),Rt.init(t,e)}),B0=le("$ZodISODateTime",(t,e)=>{e.pattern??(e.pattern=l0(e)),Rt.init(t,e)}),q0=le("$ZodISODate",(t,e)=>{e.pattern??(e.pattern=i0),Rt.init(t,e)}),V0=le("$ZodISOTime",(t,e)=>{e.pattern??(e.pattern=c0(e)),Rt.init(t,e)}),F0=le("$ZodISODuration",(t,e)=>{e.pattern??(e.pattern=Y1),Rt.init(t,e)}),id=le("$ZodIPv4",(t,e)=>{e.pattern??(e.pattern=J1),Rt.init(t,e),t._zod.onattach.push(r=>{let n=r._zod.bag;n.format="ipv4"})}),ad=le("$ZodIPv6",(t,e)=>{e.pattern??(e.pattern=Q1),Rt.init(t,e),t._zod.onattach.push(r=>{let n=r._zod.bag;n.format="ipv6"}),t._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:t,continue:!e.abort})}}}),cd=le("$ZodCIDRv4",(t,e)=>{e.pattern??(e.pattern=e0),Rt.init(t,e)}),ld=le("$ZodCIDRv6",(t,e)=>{e.pattern??(e.pattern=t0),Rt.init(t,e),t._zod.check=r=>{let[n,s]=r.value.split("/");try{if(!s)throw new Error;let o=Number(s);if(`${o}`!==s)throw new Error;if(o<0||o>128)throw new Error;new URL(`http://[${n}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:t,continue:!e.abort})}}});function H0(t){if(t==="")return!0;if(t.length%4!==0)return!1;try{return atob(t),!0}catch{return!1}}var ud=le("$ZodBase64",(t,e)=>{e.pattern??(e.pattern=r0),Rt.init(t,e),t._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64"}),t._zod.check=r=>{H0(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:t,continue:!e.abort})}});function P5(t){if(!Hu.test(t))return!1;let e=t.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=e.padEnd(Math.ceil(e.length/4)*4,"=");return H0(r)}var dd=le("$ZodBase64URL",(t,e)=>{e.pattern??(e.pattern=Hu),Rt.init(t,e),t._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64url"}),t._zod.check=r=>{P5(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:t,continue:!e.abort})}}),fd=le("$ZodE164",(t,e)=>{e.pattern??(e.pattern=s0),Rt.init(t,e)});function M5(t,e=null){try{let r=t.split(".");if(r.length!==3)return!1;let[n]=r;if(!n)return!1;let s=JSON.parse(atob(n));return!("typ"in s&&s?.typ!=="JWT"||!s.alg||e&&(!("alg"in s)||s.alg!==e))}catch{return!1}}var hd=le("$ZodJWT",(t,e)=>{Rt.init(t,e),t._zod.check=r=>{M5(r.value,e.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:t,continue:!e.abort})}});var rc=le("$ZodNumber",(t,e)=>{xt.init(t,e),t._zod.pattern=t._zod.bag.pattern??f0,t._zod.parse=(r,n)=>{if(e.coerce)try{r.value=Number(r.value)}catch{}let s=r.value;if(typeof s=="number"&&!Number.isNaN(s)&&Number.isFinite(s))return r;let o=typeof s=="number"?Number.isNaN(s)?"NaN":Number.isFinite(s)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:s,inst:t,...o?{received:o}:{}}),r}}),pd=le("$ZodNumber",(t,e)=>{y0.init(t,e),rc.init(t,e)}),md=le("$ZodBoolean",(t,e)=>{xt.init(t,e),t._zod.pattern=h0,t._zod.parse=(r,n)=>{if(e.coerce)try{r.value=!!r.value}catch{}let s=r.value;return typeof s=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:s,inst:t}),r}});var gd=le("$ZodNull",(t,e)=>{xt.init(t,e),t._zod.pattern=p0,t._zod.values=new Set([null]),t._zod.parse=(r,n)=>{let s=r.value;return s===null||r.issues.push({expected:"null",code:"invalid_type",input:s,inst:t}),r}});var _d=le("$ZodUnknown",(t,e)=>{xt.init(t,e),t._zod.parse=r=>r}),bd=le("$ZodNever",(t,e)=>{xt.init(t,e),t._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:t}),r)});function I0(t,e,r){t.issues.length&&e.issues.push(...$n(r,t.issues)),e.value[r]=t.value}var yd=le("$ZodArray",(t,e)=>{xt.init(t,e),t._zod.parse=(r,n)=>{let s=r.value;if(!Array.isArray(s))return r.issues.push({expected:"array",code:"invalid_type",input:s,inst:t}),r;r.value=Array(s.length);let o=[];for(let i=0;i<s.length;i++){let a=s[i],c=e.element._zod.run({value:a,issues:[]},n);c instanceof Promise?o.push(c.then(d=>I0(d,r,i))):I0(c,r,i)}return o.length?Promise.all(o).then(()=>r):r}});function tc(t,e,r){t.issues.length&&e.issues.push(...$n(r,t.issues)),e.value[r]=t.value}function O0(t,e,r,n){t.issues.length?n[r]===void 0?r in n?e.value[r]=void 0:e.value[r]=t.value:e.issues.push(...$n(r,t.issues)):t.value===void 0?r in n&&(e.value[r]=void 0):e.value[r]=t.value}var nc=le("$ZodObject",(t,e)=>{xt.init(t,e);let r=Ei(()=>{let u=Object.keys(e.shape);for(let p of u)if(!(e.shape[p]instanceof xt))throw new Error(`Invalid element at key "${p}": expected a Zod schema`);let h=Ou(e.shape);return{shape:e.shape,keys:u,keySet:new Set(u),numKeys:u.length,optionalKeys:new Set(h)}});$t(t._zod,"propValues",()=>{let u=e.shape,h={};for(let p in u){let g=u[p]._zod;if(g.values){h[p]??(h[p]=new Set);for(let x of g.values)h[p].add(x)}}return h});let n=u=>{let h=new ec(["shape","payload","ctx"]),p=r.value,g=_=>{let m=Ds(_);return`shape[${m}]._zod.run({ value: input[${m}], issues: [] }, ctx)`};h.write("const input = payload.value;");let x=Object.create(null),S=0;for(let _ of p.keys)x[_]=`key_${S++}`;h.write("const newResult = {}");for(let _ of p.keys)if(p.optionalKeys.has(_)){let m=x[_];h.write(`const ${m} = ${g(_)};`);let $=Ds(_);h.write(`
|
|
12
|
+
if (${m}.issues.length) {
|
|
13
|
+
if (input[${$}] === undefined) {
|
|
14
|
+
if (${$} in input) {
|
|
15
|
+
newResult[${$}] = undefined;
|
|
16
|
+
}
|
|
17
|
+
} else {
|
|
18
|
+
payload.issues = payload.issues.concat(
|
|
19
|
+
${m}.issues.map((iss) => ({
|
|
20
|
+
...iss,
|
|
21
|
+
path: iss.path ? [${$}, ...iss.path] : [${$}],
|
|
22
|
+
}))
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
} else if (${m}.value === undefined) {
|
|
26
|
+
if (${$} in input) newResult[${$}] = undefined;
|
|
27
|
+
} else {
|
|
28
|
+
newResult[${$}] = ${m}.value;
|
|
29
|
+
}
|
|
30
|
+
`)}else{let m=x[_];h.write(`const ${m} = ${g(_)};`),h.write(`
|
|
31
|
+
if (${m}.issues.length) payload.issues = payload.issues.concat(${m}.issues.map(iss => ({
|
|
32
|
+
...iss,
|
|
33
|
+
path: iss.path ? [${Ds(_)}, ...iss.path] : [${Ds(_)}]
|
|
34
|
+
})));`),h.write(`newResult[${Ds(_)}] = ${m}.value`)}h.write("payload.value = newResult;"),h.write("return payload;");let k=h.compile();return(_,m)=>k(u,_,m)},s,o=Eo,i=!Ya.jitless,c=i&&zu.value,d=e.catchall,l;t._zod.parse=(u,h)=>{l??(l=r.value);let p=u.value;if(!o(p))return u.issues.push({expected:"object",code:"invalid_type",input:p,inst:t}),u;let g=[];if(i&&c&&h?.async===!1&&h.jitless!==!0)s||(s=n(e.shape)),u=s(u,h);else{u.value={};let m=l.shape;for(let $ of l.keys){let f=m[$],E=f._zod.run({value:p[$],issues:[]},h),N=f._zod.optin==="optional"&&f._zod.optout==="optional";E instanceof Promise?g.push(E.then(B=>N?O0(B,u,$,p):tc(B,u,$))):N?O0(E,u,$,p):tc(E,u,$)}}if(!d)return g.length?Promise.all(g).then(()=>u):u;let x=[],S=l.keySet,k=d._zod,_=k.def.type;for(let m of Object.keys(p)){if(S.has(m))continue;if(_==="never"){x.push(m);continue}let $=k.run({value:p[m],issues:[]},h);$ instanceof Promise?g.push($.then(f=>tc(f,u,m))):tc($,u,m)}return x.length&&u.issues.push({code:"unrecognized_keys",keys:x,input:p,inst:t}),g.length?Promise.all(g).then(()=>u):u}});function A0(t,e,r,n){for(let s of t)if(s.issues.length===0)return e.value=s.value,e;return e.issues.push({code:"invalid_union",input:e.value,inst:r,errors:t.map(s=>s.issues.map(o=>un(o,n,Cr())))}),e}var sc=le("$ZodUnion",(t,e)=>{xt.init(t,e),$t(t._zod,"optin",()=>e.options.some(r=>r._zod.optin==="optional")?"optional":void 0),$t(t._zod,"optout",()=>e.options.some(r=>r._zod.optout==="optional")?"optional":void 0),$t(t._zod,"values",()=>{if(e.options.every(r=>r._zod.values))return new Set(e.options.flatMap(r=>Array.from(r._zod.values)))}),$t(t._zod,"pattern",()=>{if(e.options.every(r=>r._zod.pattern)){let r=e.options.map(n=>n._zod.pattern);return new RegExp(`^(${r.map(n=>$i(n.source)).join("|")})$`)}}),t._zod.parse=(r,n)=>{let s=!1,o=[];for(let i of e.options){let a=i._zod.run({value:r.value,issues:[]},n);if(a instanceof Promise)o.push(a),s=!0;else{if(a.issues.length===0)return a;o.push(a)}}return s?Promise.all(o).then(i=>A0(i,r,t,n)):A0(o,r,t,n)}}),vd=le("$ZodDiscriminatedUnion",(t,e)=>{sc.init(t,e);let r=t._zod.parse;$t(t._zod,"propValues",()=>{let s={};for(let o of e.options){let i=o._zod.propValues;if(!i||Object.keys(i).length===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(o)}"`);for(let[a,c]of Object.entries(i)){s[a]||(s[a]=new Set);for(let d of c)s[a].add(d)}}return s});let n=Ei(()=>{let s=e.options,o=new Map;for(let i of s){let a=i._zod.propValues[e.discriminator];if(!a||a.size===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(i)}"`);for(let c of a){if(o.has(c))throw new Error(`Duplicate discriminator value "${String(c)}"`);o.set(c,i)}}return o});t._zod.parse=(s,o)=>{let i=s.value;if(!Eo(i))return s.issues.push({code:"invalid_type",expected:"object",input:i,inst:t}),s;let a=n.value.get(i?.[e.discriminator]);return a?a._zod.run(s,o):e.unionFallback?r(s,o):(s.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",input:i,path:[e.discriminator],inst:t}),s)}}),wd=le("$ZodIntersection",(t,e)=>{xt.init(t,e),t._zod.parse=(r,n)=>{let s=r.value,o=e.left._zod.run({value:s,issues:[]},n),i=e.right._zod.run({value:s,issues:[]},n);return o instanceof Promise||i instanceof Promise?Promise.all([o,i]).then(([c,d])=>N0(r,c,d)):N0(r,o,i)}});function Yu(t,e){if(t===e)return{valid:!0,data:t};if(t instanceof Date&&e instanceof Date&&+t==+e)return{valid:!0,data:t};if(To(t)&&To(e)){let r=Object.keys(e),n=Object.keys(t).filter(o=>r.indexOf(o)!==-1),s={...t,...e};for(let o of n){let i=Yu(t[o],e[o]);if(!i.valid)return{valid:!1,mergeErrorPath:[o,...i.mergeErrorPath]};s[o]=i.data}return{valid:!0,data:s}}if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let n=0;n<t.length;n++){let s=t[n],o=e[n],i=Yu(s,o);if(!i.valid)return{valid:!1,mergeErrorPath:[n,...i.mergeErrorPath]};r.push(i.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function N0(t,e,r){if(e.issues.length&&t.issues.push(...e.issues),r.issues.length&&t.issues.push(...r.issues),Ls(t))return t;let n=Yu(e.value,r.value);if(!n.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(n.mergeErrorPath)}`);return t.value=n.data,t}var xd=le("$ZodRecord",(t,e)=>{xt.init(t,e),t._zod.parse=(r,n)=>{let s=r.value;if(!To(s))return r.issues.push({expected:"record",code:"invalid_type",input:s,inst:t}),r;let o=[];if(e.keyType._zod.values){let i=e.keyType._zod.values;r.value={};for(let c of i)if(typeof c=="string"||typeof c=="number"||typeof c=="symbol"){let d=e.valueType._zod.run({value:s[c],issues:[]},n);d instanceof Promise?o.push(d.then(l=>{l.issues.length&&r.issues.push(...$n(c,l.issues)),r.value[c]=l.value})):(d.issues.length&&r.issues.push(...$n(c,d.issues)),r.value[c]=d.value)}let a;for(let c in s)i.has(c)||(a=a??[],a.push(c));a&&a.length>0&&r.issues.push({code:"unrecognized_keys",input:s,inst:t,keys:a})}else{r.value={};for(let i of Reflect.ownKeys(s)){if(i==="__proto__")continue;let a=e.keyType._zod.run({value:i,issues:[]},n);if(a instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(a.issues.length){r.issues.push({origin:"record",code:"invalid_key",issues:a.issues.map(d=>un(d,n,Cr())),input:i,path:[i],inst:t}),r.value[a.value]=a.value;continue}let c=e.valueType._zod.run({value:s[i],issues:[]},n);c instanceof Promise?o.push(c.then(d=>{d.issues.length&&r.issues.push(...$n(i,d.issues)),r.value[a.value]=d.value})):(c.issues.length&&r.issues.push(...$n(i,c.issues)),r.value[a.value]=c.value)}}return o.length?Promise.all(o).then(()=>r):r}});var kd=le("$ZodEnum",(t,e)=>{xt.init(t,e);let r=Si(e.entries);t._zod.values=new Set(r),t._zod.pattern=new RegExp(`^(${r.filter(n=>Iu.has(typeof n)).map(n=>typeof n=="string"?Kn(n):n.toString()).join("|")})$`),t._zod.parse=(n,s)=>{let o=n.value;return t._zod.values.has(o)||n.issues.push({code:"invalid_value",values:r,input:o,inst:t}),n}}),Sd=le("$ZodLiteral",(t,e)=>{xt.init(t,e),t._zod.values=new Set(e.values),t._zod.pattern=new RegExp(`^(${e.values.map(r=>typeof r=="string"?Kn(r):r?r.toString():String(r)).join("|")})$`),t._zod.parse=(r,n)=>{let s=r.value;return t._zod.values.has(s)||r.issues.push({code:"invalid_value",values:e.values,input:s,inst:t}),r}});var Ed=le("$ZodTransform",(t,e)=>{xt.init(t,e),t._zod.parse=(r,n)=>{let s=e.transform(r.value,r);if(n.async)return(s instanceof Promise?s:Promise.resolve(s)).then(i=>(r.value=i,r));if(s instanceof Promise)throw new Ln;return r.value=s,r}}),Td=le("$ZodOptional",(t,e)=>{xt.init(t,e),t._zod.optin="optional",t._zod.optout="optional",$t(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,void 0]):void 0),$t(t._zod,"pattern",()=>{let r=e.innerType._zod.pattern;return r?new RegExp(`^(${$i(r.source)})?$`):void 0}),t._zod.parse=(r,n)=>e.innerType._zod.optin==="optional"?e.innerType._zod.run(r,n):r.value===void 0?r:e.innerType._zod.run(r,n)}),$d=le("$ZodNullable",(t,e)=>{xt.init(t,e),$t(t._zod,"optin",()=>e.innerType._zod.optin),$t(t._zod,"optout",()=>e.innerType._zod.optout),$t(t._zod,"pattern",()=>{let r=e.innerType._zod.pattern;return r?new RegExp(`^(${$i(r.source)}|null)$`):void 0}),$t(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,null]):void 0),t._zod.parse=(r,n)=>r.value===null?r:e.innerType._zod.run(r,n)}),Rd=le("$ZodDefault",(t,e)=>{xt.init(t,e),t._zod.optin="optional",$t(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(r,n)=>{if(r.value===void 0)return r.value=e.defaultValue,r;let s=e.innerType._zod.run(r,n);return s instanceof Promise?s.then(o=>C0(o,e)):C0(s,e)}});function C0(t,e){return t.value===void 0&&(t.value=e.defaultValue),t}var Pd=le("$ZodPrefault",(t,e)=>{xt.init(t,e),t._zod.optin="optional",$t(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(r,n)=>(r.value===void 0&&(r.value=e.defaultValue),e.innerType._zod.run(r,n))}),Md=le("$ZodNonOptional",(t,e)=>{xt.init(t,e),$t(t._zod,"values",()=>{let r=e.innerType._zod.values;return r?new Set([...r].filter(n=>n!==void 0)):void 0}),t._zod.parse=(r,n)=>{let s=e.innerType._zod.run(r,n);return s instanceof Promise?s.then(o=>j0(o,t)):j0(s,t)}});function j0(t,e){return!t.issues.length&&t.value===void 0&&t.issues.push({code:"invalid_type",expected:"nonoptional",input:t.value,inst:e}),t}var zd=le("$ZodCatch",(t,e)=>{xt.init(t,e),t._zod.optin="optional",$t(t._zod,"optout",()=>e.innerType._zod.optout),$t(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(r,n)=>{let s=e.innerType._zod.run(r,n);return s instanceof Promise?s.then(o=>(r.value=o.value,o.issues.length&&(r.value=e.catchValue({...r,error:{issues:o.issues.map(i=>un(i,n,Cr()))},input:r.value}),r.issues=[]),r)):(r.value=s.value,s.issues.length&&(r.value=e.catchValue({...r,error:{issues:s.issues.map(o=>un(o,n,Cr()))},input:r.value}),r.issues=[]),r)}});var Id=le("$ZodPipe",(t,e)=>{xt.init(t,e),$t(t._zod,"values",()=>e.in._zod.values),$t(t._zod,"optin",()=>e.in._zod.optin),$t(t._zod,"optout",()=>e.out._zod.optout),t._zod.parse=(r,n)=>{let s=e.in._zod.run(r,n);return s instanceof Promise?s.then(o=>D0(o,e,n)):D0(s,e,n)}});function D0(t,e,r){return Ls(t)?t:e.out._zod.run({value:t.value,issues:t.issues},r)}var Od=le("$ZodReadonly",(t,e)=>{xt.init(t,e),$t(t._zod,"propValues",()=>e.innerType._zod.propValues),$t(t._zod,"values",()=>e.innerType._zod.values),$t(t._zod,"optin",()=>e.innerType._zod.optin),$t(t._zod,"optout",()=>e.innerType._zod.optout),t._zod.parse=(r,n)=>{let s=e.innerType._zod.run(r,n);return s instanceof Promise?s.then(L0):L0(s)}});function L0(t){return t.value=Object.freeze(t.value),t}var Ad=le("$ZodCustom",(t,e)=>{rr.init(t,e),xt.init(t,e),t._zod.parse=(r,n)=>r,t._zod.check=r=>{let n=r.value,s=e.fn(n);if(s instanceof Promise)return s.then(o=>Z0(o,r,n,t));Z0(s,r,n,t)}});function Z0(t,e,r,n){if(!t){let s={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(s.params=n._zod.def.params),e.issues.push(Nu(s))}}var z5=t=>{let e=typeof t;switch(e){case"number":return Number.isNaN(t)?"NaN":"number";case"object":{if(Array.isArray(t))return"array";if(t===null)return"null";if(Object.getPrototypeOf(t)!==Object.prototype&&t.constructor)return t.constructor.name}}return e},I5=()=>{let t={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"}};function e(n){return t[n]??null}let r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"};return n=>{switch(n.code){case"invalid_type":return`Invalid input: expected ${n.expected}, received ${z5(n.input)}`;case"invalid_value":return n.values.length===1?`Invalid input: expected ${Ka(n.values[0])}`:`Invalid option: expected one of ${Xa(n.values,"|")}`;case"too_big":{let s=n.inclusive?"<=":"<",o=e(n.origin);return o?`Too big: expected ${n.origin??"value"} to have ${s}${n.maximum.toString()} ${o.unit??"elements"}`:`Too big: expected ${n.origin??"value"} to be ${s}${n.maximum.toString()}`}case"too_small":{let s=n.inclusive?">=":">",o=e(n.origin);return o?`Too small: expected ${n.origin} to have ${s}${n.minimum.toString()} ${o.unit}`:`Too small: expected ${n.origin} to be ${s}${n.minimum.toString()}`}case"invalid_format":{let s=n;return s.format==="starts_with"?`Invalid string: must start with "${s.prefix}"`:s.format==="ends_with"?`Invalid string: must end with "${s.suffix}"`:s.format==="includes"?`Invalid string: must include "${s.includes}"`:s.format==="regex"?`Invalid string: must match pattern ${s.pattern}`:`Invalid ${r[s.format]??n.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${n.divisor}`;case"unrecognized_keys":return`Unrecognized key${n.keys.length>1?"s":""}: ${Xa(n.keys,", ")}`;case"invalid_key":return`Invalid key in ${n.origin}`;case"invalid_union":return"Invalid input";case"invalid_element":return`Invalid value in ${n.origin}`;default:return"Invalid input"}}};function U0(){return{localeError:I5()}}var O5=Symbol("ZodOutput"),A5=Symbol("ZodInput"),Ii=class{constructor(){this._map=new Map,this._idmap=new Map}add(e,...r){let n=r[0];if(this._map.set(e,n),n&&typeof n=="object"&&"id"in n){if(this._idmap.has(n.id))throw new Error(`ID ${n.id} already exists in the registry`);this._idmap.set(n.id,e)}return this}clear(){return this._map=new Map,this._idmap=new Map,this}remove(e){let r=this._map.get(e);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(e),this}get(e){let r=e._zod.parent;if(r){let n={...this.get(r)??{}};return delete n.id,{...n,...this._map.get(e)}}return this._map.get(e)}has(e){return this._map.has(e)}};function G0(){return new Ii}var Jn=G0();function Nd(t,e){return new t({type:"string",...Xe(e)})}function Cd(t,e){return new t({type:"string",format:"email",check:"string_format",abort:!1,...Xe(e)})}function oc(t,e){return new t({type:"string",format:"guid",check:"string_format",abort:!1,...Xe(e)})}function jd(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,...Xe(e)})}function Dd(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...Xe(e)})}function Ld(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...Xe(e)})}function Zd(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...Xe(e)})}function Bd(t,e){return new t({type:"string",format:"url",check:"string_format",abort:!1,...Xe(e)})}function qd(t,e){return new t({type:"string",format:"emoji",check:"string_format",abort:!1,...Xe(e)})}function Vd(t,e){return new t({type:"string",format:"nanoid",check:"string_format",abort:!1,...Xe(e)})}function Fd(t,e){return new t({type:"string",format:"cuid",check:"string_format",abort:!1,...Xe(e)})}function Hd(t,e){return new t({type:"string",format:"cuid2",check:"string_format",abort:!1,...Xe(e)})}function Ud(t,e){return new t({type:"string",format:"ulid",check:"string_format",abort:!1,...Xe(e)})}function Gd(t,e){return new t({type:"string",format:"xid",check:"string_format",abort:!1,...Xe(e)})}function Yd(t,e){return new t({type:"string",format:"ksuid",check:"string_format",abort:!1,...Xe(e)})}function Xd(t,e){return new t({type:"string",format:"ipv4",check:"string_format",abort:!1,...Xe(e)})}function Wd(t,e){return new t({type:"string",format:"ipv6",check:"string_format",abort:!1,...Xe(e)})}function Kd(t,e){return new t({type:"string",format:"cidrv4",check:"string_format",abort:!1,...Xe(e)})}function Jd(t,e){return new t({type:"string",format:"cidrv6",check:"string_format",abort:!1,...Xe(e)})}function Qd(t,e){return new t({type:"string",format:"base64",check:"string_format",abort:!1,...Xe(e)})}function ef(t,e){return new t({type:"string",format:"base64url",check:"string_format",abort:!1,...Xe(e)})}function tf(t,e){return new t({type:"string",format:"e164",check:"string_format",abort:!1,...Xe(e)})}function rf(t,e){return new t({type:"string",format:"jwt",check:"string_format",abort:!1,...Xe(e)})}function Y0(t,e){return new t({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...Xe(e)})}function X0(t,e){return new t({type:"string",format:"date",check:"string_format",...Xe(e)})}function W0(t,e){return new t({type:"string",format:"time",check:"string_format",precision:null,...Xe(e)})}function K0(t,e){return new t({type:"string",format:"duration",check:"string_format",...Xe(e)})}function nf(t,e){return new t({type:"number",checks:[],...Xe(e)})}function sf(t,e){return new t({type:"number",check:"number_format",abort:!1,format:"safeint",...Xe(e)})}function of(t,e){return new t({type:"boolean",...Xe(e)})}function af(t,e){return new t({type:"null",...Xe(e)})}function cf(t){return new t({type:"unknown"})}function lf(t,e){return new t({type:"never",...Xe(e)})}function ic(t,e){return new Uu({check:"less_than",...Xe(e),value:t,inclusive:!1})}function Oi(t,e){return new Uu({check:"less_than",...Xe(e),value:t,inclusive:!0})}function ac(t,e){return new Gu({check:"greater_than",...Xe(e),value:t,inclusive:!1})}function Ai(t,e){return new Gu({check:"greater_than",...Xe(e),value:t,inclusive:!0})}function cc(t,e){return new b0({check:"multiple_of",...Xe(e),value:t})}function lc(t,e){return new v0({check:"max_length",...Xe(e),maximum:t})}function $o(t,e){return new w0({check:"min_length",...Xe(e),minimum:t})}function uc(t,e){return new x0({check:"length_equals",...Xe(e),length:t})}function uf(t,e){return new k0({check:"string_format",format:"regex",...Xe(e),pattern:t})}function df(t){return new S0({check:"string_format",format:"lowercase",...Xe(t)})}function ff(t){return new E0({check:"string_format",format:"uppercase",...Xe(t)})}function hf(t,e){return new T0({check:"string_format",format:"includes",...Xe(e),includes:t})}function pf(t,e){return new $0({check:"string_format",format:"starts_with",...Xe(e),prefix:t})}function mf(t,e){return new R0({check:"string_format",format:"ends_with",...Xe(e),suffix:t})}function qs(t){return new P0({check:"overwrite",tx:t})}function gf(t){return qs(e=>e.normalize(t))}function _f(){return qs(t=>t.trim())}function bf(){return qs(t=>t.toLowerCase())}function yf(){return qs(t=>t.toUpperCase())}function J0(t,e,r){return new t({type:"array",element:e,...Xe(r)})}function vf(t,e,r){let n=Xe(r);return n.abort??(n.abort=!0),new t({type:"custom",check:"custom",fn:e,...n})}function wf(t,e,r){return new t({type:"custom",check:"custom",fn:e,...Xe(r)})}var dc=class{constructor(e){this.counter=0,this.metadataRegistry=e?.metadata??Jn,this.target=e?.target??"draft-2020-12",this.unrepresentable=e?.unrepresentable??"throw",this.override=e?.override??(()=>{}),this.io=e?.io??"output",this.seen=new Map}process(e,r={path:[],schemaPath:[]}){var n;let s=e._zod.def,o={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},i=this.seen.get(e);if(i)return i.count++,r.schemaPath.includes(e)&&(i.cycle=r.path),i.schema;let a={schema:{},count:1,cycle:void 0,path:r.path};this.seen.set(e,a);let c=e._zod.toJSONSchema?.();if(c)a.schema=c;else{let u={...r,schemaPath:[...r.schemaPath,e],path:r.path},h=e._zod.parent;if(h)a.ref=h,this.process(h,u),this.seen.get(h).isParent=!0;else{let p=a.schema;switch(s.type){case"string":{let g=p;g.type="string";let{minimum:x,maximum:S,format:k,patterns:_,contentEncoding:m}=e._zod.bag;if(typeof x=="number"&&(g.minLength=x),typeof S=="number"&&(g.maxLength=S),k&&(g.format=o[k]??k,g.format===""&&delete g.format),m&&(g.contentEncoding=m),_&&_.size>0){let $=[..._];$.length===1?g.pattern=$[0].source:$.length>1&&(a.schema.allOf=[...$.map(f=>({...this.target==="draft-7"?{type:"string"}:{},pattern:f.source}))])}break}case"number":{let g=p,{minimum:x,maximum:S,format:k,multipleOf:_,exclusiveMaximum:m,exclusiveMinimum:$}=e._zod.bag;typeof k=="string"&&k.includes("int")?g.type="integer":g.type="number",typeof $=="number"&&(g.exclusiveMinimum=$),typeof x=="number"&&(g.minimum=x,typeof $=="number"&&($>=x?delete g.minimum:delete g.exclusiveMinimum)),typeof m=="number"&&(g.exclusiveMaximum=m),typeof S=="number"&&(g.maximum=S,typeof m=="number"&&(m<=S?delete g.maximum:delete g.exclusiveMaximum)),typeof _=="number"&&(g.multipleOf=_);break}case"boolean":{let g=p;g.type="boolean";break}case"bigint":{if(this.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema");break}case"symbol":{if(this.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema");break}case"null":{p.type="null";break}case"any":break;case"unknown":break;case"undefined":{if(this.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema");break}case"void":{if(this.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema");break}case"never":{p.not={};break}case"date":{if(this.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema");break}case"array":{let g=p,{minimum:x,maximum:S}=e._zod.bag;typeof x=="number"&&(g.minItems=x),typeof S=="number"&&(g.maxItems=S),g.type="array",g.items=this.process(s.element,{...u,path:[...u.path,"items"]});break}case"object":{let g=p;g.type="object",g.properties={};let x=s.shape;for(let _ in x)g.properties[_]=this.process(x[_],{...u,path:[...u.path,"properties",_]});let S=new Set(Object.keys(x)),k=new Set([...S].filter(_=>{let m=s.shape[_]._zod;return this.io==="input"?m.optin===void 0:m.optout===void 0}));k.size>0&&(g.required=Array.from(k)),s.catchall?._zod.def.type==="never"?g.additionalProperties=!1:s.catchall?s.catchall&&(g.additionalProperties=this.process(s.catchall,{...u,path:[...u.path,"additionalProperties"]})):this.io==="output"&&(g.additionalProperties=!1);break}case"union":{let g=p;g.anyOf=s.options.map((x,S)=>this.process(x,{...u,path:[...u.path,"anyOf",S]}));break}case"intersection":{let g=p,x=this.process(s.left,{...u,path:[...u.path,"allOf",0]}),S=this.process(s.right,{...u,path:[...u.path,"allOf",1]}),k=m=>"allOf"in m&&Object.keys(m).length===1,_=[...k(x)?x.allOf:[x],...k(S)?S.allOf:[S]];g.allOf=_;break}case"tuple":{let g=p;g.type="array";let x=s.items.map((_,m)=>this.process(_,{...u,path:[...u.path,"prefixItems",m]}));if(this.target==="draft-2020-12"?g.prefixItems=x:g.items=x,s.rest){let _=this.process(s.rest,{...u,path:[...u.path,"items"]});this.target==="draft-2020-12"?g.items=_:g.additionalItems=_}s.rest&&(g.items=this.process(s.rest,{...u,path:[...u.path,"items"]}));let{minimum:S,maximum:k}=e._zod.bag;typeof S=="number"&&(g.minItems=S),typeof k=="number"&&(g.maxItems=k);break}case"record":{let g=p;g.type="object",g.propertyNames=this.process(s.keyType,{...u,path:[...u.path,"propertyNames"]}),g.additionalProperties=this.process(s.valueType,{...u,path:[...u.path,"additionalProperties"]});break}case"map":{if(this.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema");break}case"set":{if(this.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema");break}case"enum":{let g=p,x=Si(s.entries);x.every(S=>typeof S=="number")&&(g.type="number"),x.every(S=>typeof S=="string")&&(g.type="string"),g.enum=x;break}case"literal":{let g=p,x=[];for(let S of s.values)if(S===void 0){if(this.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof S=="bigint"){if(this.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");x.push(Number(S))}else x.push(S);if(x.length!==0)if(x.length===1){let S=x[0];g.type=S===null?"null":typeof S,g.const=S}else x.every(S=>typeof S=="number")&&(g.type="number"),x.every(S=>typeof S=="string")&&(g.type="string"),x.every(S=>typeof S=="boolean")&&(g.type="string"),x.every(S=>S===null)&&(g.type="null"),g.enum=x;break}case"file":{let g=p,x={type:"string",format:"binary",contentEncoding:"binary"},{minimum:S,maximum:k,mime:_}=e._zod.bag;S!==void 0&&(x.minLength=S),k!==void 0&&(x.maxLength=k),_?_.length===1?(x.contentMediaType=_[0],Object.assign(g,x)):g.anyOf=_.map(m=>({...x,contentMediaType:m})):Object.assign(g,x);break}case"transform":{if(this.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema");break}case"nullable":{let g=this.process(s.innerType,u);p.anyOf=[g,{type:"null"}];break}case"nonoptional":{this.process(s.innerType,u),a.ref=s.innerType;break}case"success":{let g=p;g.type="boolean";break}case"default":{this.process(s.innerType,u),a.ref=s.innerType,p.default=JSON.parse(JSON.stringify(s.defaultValue));break}case"prefault":{this.process(s.innerType,u),a.ref=s.innerType,this.io==="input"&&(p._prefault=JSON.parse(JSON.stringify(s.defaultValue)));break}case"catch":{this.process(s.innerType,u),a.ref=s.innerType;let g;try{g=s.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}p.default=g;break}case"nan":{if(this.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema");break}case"template_literal":{let g=p,x=e._zod.pattern;if(!x)throw new Error("Pattern not found in template literal");g.type="string",g.pattern=x.source;break}case"pipe":{let g=this.io==="input"?s.in._zod.def.type==="transform"?s.out:s.in:s.out;this.process(g,u),a.ref=g;break}case"readonly":{this.process(s.innerType,u),a.ref=s.innerType,p.readOnly=!0;break}case"promise":{this.process(s.innerType,u),a.ref=s.innerType;break}case"optional":{this.process(s.innerType,u),a.ref=s.innerType;break}case"lazy":{let g=e._zod.innerType;this.process(g,u),a.ref=g;break}case"custom":{if(this.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema");break}default:}}}let d=this.metadataRegistry.get(e);return d&&Object.assign(a.schema,d),this.io==="input"&&Xt(e)&&(delete a.schema.examples,delete a.schema.default),this.io==="input"&&a.schema._prefault&&((n=a.schema).default??(n.default=a.schema._prefault)),delete a.schema._prefault,this.seen.get(e).schema}emit(e,r){let n={cycles:r?.cycles??"ref",reused:r?.reused??"inline",external:r?.external??void 0},s=this.seen.get(e);if(!s)throw new Error("Unprocessed schema. This is a bug in Zod.");let o=l=>{let u=this.target==="draft-2020-12"?"$defs":"definitions";if(n.external){let x=n.external.registry.get(l[0])?.id,S=n.external.uri??(_=>_);if(x)return{ref:S(x)};let k=l[1].defId??l[1].schema.id??`schema${this.counter++}`;return l[1].defId=k,{defId:k,ref:`${S("__shared")}#/${u}/${k}`}}if(l[1]===s)return{ref:"#"};let p=`#/${u}/`,g=l[1].schema.id??`__schema${this.counter++}`;return{defId:g,ref:p+g}},i=l=>{if(l[1].schema.$ref)return;let u=l[1],{ref:h,defId:p}=o(l);u.def={...u.schema},p&&(u.defId=p);let g=u.schema;for(let x in g)delete g[x];g.$ref=h};if(n.cycles==="throw")for(let l of this.seen.entries()){let u=l[1];if(u.cycle)throw new Error(`Cycle detected: #/${u.cycle?.join("/")}/<root>
|
|
35
|
+
|
|
36
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let l of this.seen.entries()){let u=l[1];if(e===l[0]){i(l);continue}if(n.external){let p=n.external.registry.get(l[0])?.id;if(e!==l[0]&&p){i(l);continue}}if(this.metadataRegistry.get(l[0])?.id){i(l);continue}if(u.cycle){i(l);continue}if(u.count>1&&n.reused==="ref"){i(l);continue}}let a=(l,u)=>{let h=this.seen.get(l),p=h.def??h.schema,g={...p};if(h.ref===null)return;let x=h.ref;if(h.ref=null,x){a(x,u);let S=this.seen.get(x).schema;S.$ref&&u.target==="draft-7"?(p.allOf=p.allOf??[],p.allOf.push(S)):(Object.assign(p,S),Object.assign(p,g))}h.isParent||this.override({zodSchema:l,jsonSchema:p,path:h.path??[]})};for(let l of[...this.seen.entries()].reverse())a(l[0],{target:this.target});let c={};if(this.target==="draft-2020-12"?c.$schema="https://json-schema.org/draft/2020-12/schema":this.target==="draft-7"?c.$schema="http://json-schema.org/draft-07/schema#":console.warn(`Invalid target: ${this.target}`),n.external?.uri){let l=n.external.registry.get(e)?.id;if(!l)throw new Error("Schema is missing an `id` property");c.$id=n.external.uri(l)}Object.assign(c,s.def);let d=n.external?.defs??{};for(let l of this.seen.entries()){let u=l[1];u.def&&u.defId&&(d[u.defId]=u.def)}n.external||Object.keys(d).length>0&&(this.target==="draft-2020-12"?c.$defs=d:c.definitions=d);try{return JSON.parse(JSON.stringify(c))}catch{throw new Error("Error converting schema to JSON.")}}};function xf(t,e){if(t instanceof Ii){let n=new dc(e),s={};for(let a of t._idmap.entries()){let[c,d]=a;n.process(d)}let o={},i={registry:t,uri:e?.uri,defs:s};for(let a of t._idmap.entries()){let[c,d]=a;o[c]=n.emit(d,{...e,external:i})}if(Object.keys(s).length>0){let a=n.target==="draft-2020-12"?"$defs":"definitions";o.__shared={[a]:s}}return{schemas:o}}let r=new dc(e);return r.process(t),r.emit(t,e)}function Xt(t,e){let r=e??{seen:new Set};if(r.seen.has(t))return!1;r.seen.add(t);let s=t._zod.def;switch(s.type){case"string":case"number":case"bigint":case"boolean":case"date":case"symbol":case"undefined":case"null":case"any":case"unknown":case"never":case"void":case"literal":case"enum":case"nan":case"file":case"template_literal":return!1;case"array":return Xt(s.element,r);case"object":{for(let o in s.shape)if(Xt(s.shape[o],r))return!0;return!1}case"union":{for(let o of s.options)if(Xt(o,r))return!0;return!1}case"intersection":return Xt(s.left,r)||Xt(s.right,r);case"tuple":{for(let o of s.items)if(Xt(o,r))return!0;return!!(s.rest&&Xt(s.rest,r))}case"record":return Xt(s.keyType,r)||Xt(s.valueType,r);case"map":return Xt(s.keyType,r)||Xt(s.valueType,r);case"set":return Xt(s.valueType,r);case"promise":case"optional":case"nonoptional":case"nullable":case"readonly":return Xt(s.innerType,r);case"lazy":return Xt(s.getter(),r);case"default":return Xt(s.innerType,r);case"prefault":return Xt(s.innerType,r);case"custom":return!1;case"transform":return!0;case"pipe":return Xt(s.in,r)||Xt(s.out,r);case"success":return!1;case"catch":return!1;default:}throw new Error(`Unknown schema type: ${s.type}`)}var mx=le("ZodMiniType",(t,e)=>{if(!t._zod)throw new Error("Uninitialized schema in ZodMiniType.");xt.init(t,e),t.def=e,t.parse=(r,n)=>Lu(t,r,n,{callee:t.parse}),t.safeParse=(r,n)=>Zs(t,r,n),t.parseAsync=async(r,n)=>Bu(t,r,n,{callee:t.parseAsync}),t.safeParseAsync=async(r,n)=>Bs(t,r,n),t.check=(...r)=>t.clone({...e,checks:[...e.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),t.clone=(r,n)=>jr(t,r,n),t.brand=()=>t,t.register=(r,n)=>(r.add(t,n),t)});var gx=le("ZodMiniObject",(t,e)=>{nc.init(t,e),mx.init(t,e),ut.defineLazy(t,"shape",()=>e.shape)});function kf(t,e){let r={type:"object",get shape(){return ut.assignProp(this,"shape",{...t}),this.shape},...ut.normalizeParams(e)};return new gx(r)}function Gr(t){return!!t._zod}function Fs(t){let e=Object.values(t);if(e.length===0)return kf({});let r=e.every(Gr),n=e.every(s=>!Gr(s));if(r)return kf(t);if(n)return Eu(t);throw new Error("Mixed Zod versions detected in object shape.")}function Qn(t,e){return Gr(t)?Zs(t,e):t.safeParse(e)}async function fc(t,e){return Gr(t)?await Bs(t,e):await t.safeParseAsync(e)}function es(t){if(!t)return;let e;if(Gr(t)?e=t._zod?.def?.shape:e=t.shape,!!e){if(typeof e=="function")try{return e()}catch{return}return e}}function Ro(t){if(t){if(typeof t=="object"){let e=t,r=t;if(!e._def&&!r._zod){let n=Object.values(t);if(n.length>0&&n.every(s=>typeof s=="object"&&s!==null&&(s._def!==void 0||s._zod!==void 0||typeof s.parse=="function")))return Fs(t)}}if(Gr(t)){let r=t._zod?.def;if(r&&(r.type==="object"||r.shape!==void 0))return t}else if(t.shape!==void 0)return t}}function hc(t){if(t&&typeof t=="object"){if("message"in t&&typeof t.message=="string")return t.message;if("issues"in t&&Array.isArray(t.issues)&&t.issues.length>0){let e=t.issues[0];if(e&&typeof e=="object"&&"message"in e)return String(e.message)}try{return JSON.stringify(t)}catch{return String(t)}}return String(t)}function eg(t){return t.description}function tg(t){if(Gr(t))return t._zod?.def?.type==="optional";let e=t;return typeof t.isOptional=="function"?t.isOptional():e._def?.typeName==="ZodOptional"}function pc(t){if(Gr(t)){let o=t._zod?.def;if(o){if(o.value!==void 0)return o.value;if(Array.isArray(o.values)&&o.values.length>0)return o.values[0]}}let r=t._def;if(r){if(r.value!==void 0)return r.value;if(Array.isArray(r.values)&&r.values.length>0)return r.values[0]}let n=t.value;if(n!==void 0)return n}var Ni={};wu(Ni,{ZodISODate:()=>ng,ZodISODateTime:()=>rg,ZodISODuration:()=>og,ZodISOTime:()=>sg,date:()=>Ef,datetime:()=>Sf,duration:()=>$f,time:()=>Tf});var rg=le("ZodISODateTime",(t,e)=>{B0.init(t,e),Ct.init(t,e)});function Sf(t){return Y0(rg,t)}var ng=le("ZodISODate",(t,e)=>{q0.init(t,e),Ct.init(t,e)});function Ef(t){return X0(ng,t)}var sg=le("ZodISOTime",(t,e)=>{V0.init(t,e),Ct.init(t,e)});function Tf(t){return W0(sg,t)}var og=le("ZodISODuration",(t,e)=>{F0.init(t,e),Ct.init(t,e)});function $f(t){return K0(og,t)}var ig=(t,e)=>{Ja.init(t,e),t.name="ZodError",Object.defineProperties(t,{format:{value:r=>ju(t,r)},flatten:{value:r=>Cu(t,r)},addIssue:{value:r=>t.issues.push(r)},addIssues:{value:r=>t.issues.push(...r)},isEmpty:{get(){return t.issues.length===0}}})},mN=le("ZodError",ig),Ci=le("ZodError",ig,{Parent:Error});var ag=Du(Ci),cg=Zu(Ci),lg=qu(Ci),ug=Vu(Ci);var Bt=le("ZodType",(t,e)=>(xt.init(t,e),t.def=e,Object.defineProperty(t,"_def",{value:e}),t.check=(...r)=>t.clone({...e,checks:[...e.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),t.clone=(r,n)=>jr(t,r,n),t.brand=()=>t,t.register=(r,n)=>(r.add(t,n),t),t.parse=(r,n)=>ag(t,r,n,{callee:t.parse}),t.safeParse=(r,n)=>lg(t,r,n),t.parseAsync=async(r,n)=>cg(t,r,n,{callee:t.parseAsync}),t.safeParseAsync=async(r,n)=>ug(t,r,n),t.spa=t.safeParseAsync,t.refine=(r,n)=>t.check(hk(r,n)),t.superRefine=r=>t.check(pk(r)),t.overwrite=r=>t.check(qs(r)),t.optional=()=>Dt(t),t.nullable=()=>hg(t),t.nullish=()=>Dt(hg(t)),t.nonoptional=r=>ik(t,r),t.array=()=>dt(t),t.or=r=>Mt([t,r]),t.and=r=>gc(t,r),t.transform=r=>Pf(t,yg(r)),t.default=r=>nk(t,r),t.prefault=r=>ok(t,r),t.catch=r=>ck(t,r),t.pipe=r=>Pf(t,r),t.readonly=()=>dk(t),t.describe=r=>{let n=t.clone();return Jn.add(n,{description:r}),n},Object.defineProperty(t,"description",{get(){return Jn.get(t)?.description},configurable:!0}),t.meta=(...r)=>{if(r.length===0)return Jn.get(t);let n=t.clone();return Jn.add(n,r[0]),n},t.isOptional=()=>t.safeParse(void 0).success,t.isNullable=()=>t.safeParse(null).success,t)),pg=le("_ZodString",(t,e)=>{zi.init(t,e),Bt.init(t,e);let r=t._zod.bag;t.format=r.format??null,t.minLength=r.minimum??null,t.maxLength=r.maximum??null,t.regex=(...n)=>t.check(uf(...n)),t.includes=(...n)=>t.check(hf(...n)),t.startsWith=(...n)=>t.check(pf(...n)),t.endsWith=(...n)=>t.check(mf(...n)),t.min=(...n)=>t.check($o(...n)),t.max=(...n)=>t.check(lc(...n)),t.length=(...n)=>t.check(uc(...n)),t.nonempty=(...n)=>t.check($o(1,...n)),t.lowercase=n=>t.check(df(n)),t.uppercase=n=>t.check(ff(n)),t.trim=()=>t.check(_f()),t.normalize=(...n)=>t.check(gf(...n)),t.toLowerCase=()=>t.check(bf()),t.toUpperCase=()=>t.check(yf())}),Ex=le("ZodString",(t,e)=>{zi.init(t,e),pg.init(t,e),t.email=r=>t.check(Cd(Tx,r)),t.url=r=>t.check(Bd($x,r)),t.jwt=r=>t.check(rf(qx,r)),t.emoji=r=>t.check(qd(Rx,r)),t.guid=r=>t.check(oc(dg,r)),t.uuid=r=>t.check(jd(mc,r)),t.uuidv4=r=>t.check(Dd(mc,r)),t.uuidv6=r=>t.check(Ld(mc,r)),t.uuidv7=r=>t.check(Zd(mc,r)),t.nanoid=r=>t.check(Vd(Px,r)),t.guid=r=>t.check(oc(dg,r)),t.cuid=r=>t.check(Fd(Mx,r)),t.cuid2=r=>t.check(Hd(zx,r)),t.ulid=r=>t.check(Ud(Ix,r)),t.base64=r=>t.check(Qd(Lx,r)),t.base64url=r=>t.check(ef(Zx,r)),t.xid=r=>t.check(Gd(Ox,r)),t.ksuid=r=>t.check(Yd(Ax,r)),t.ipv4=r=>t.check(Xd(Nx,r)),t.ipv6=r=>t.check(Wd(Cx,r)),t.cidrv4=r=>t.check(Kd(jx,r)),t.cidrv6=r=>t.check(Jd(Dx,r)),t.e164=r=>t.check(tf(Bx,r)),t.datetime=r=>t.check(Sf(r)),t.date=r=>t.check(Ef(r)),t.time=r=>t.check(Tf(r)),t.duration=r=>t.check($f(r))});function ce(t){return Nd(Ex,t)}var Ct=le("ZodStringFormat",(t,e)=>{Rt.init(t,e),pg.init(t,e)}),Tx=le("ZodEmail",(t,e)=>{Ku.init(t,e),Ct.init(t,e)});var dg=le("ZodGUID",(t,e)=>{Xu.init(t,e),Ct.init(t,e)});var mc=le("ZodUUID",(t,e)=>{Wu.init(t,e),Ct.init(t,e)});var $x=le("ZodURL",(t,e)=>{Ju.init(t,e),Ct.init(t,e)});var Rx=le("ZodEmoji",(t,e)=>{Qu.init(t,e),Ct.init(t,e)});var Px=le("ZodNanoID",(t,e)=>{ed.init(t,e),Ct.init(t,e)});var Mx=le("ZodCUID",(t,e)=>{td.init(t,e),Ct.init(t,e)});var zx=le("ZodCUID2",(t,e)=>{rd.init(t,e),Ct.init(t,e)});var Ix=le("ZodULID",(t,e)=>{nd.init(t,e),Ct.init(t,e)});var Ox=le("ZodXID",(t,e)=>{sd.init(t,e),Ct.init(t,e)});var Ax=le("ZodKSUID",(t,e)=>{od.init(t,e),Ct.init(t,e)});var Nx=le("ZodIPv4",(t,e)=>{id.init(t,e),Ct.init(t,e)});var Cx=le("ZodIPv6",(t,e)=>{ad.init(t,e),Ct.init(t,e)});var jx=le("ZodCIDRv4",(t,e)=>{cd.init(t,e),Ct.init(t,e)});var Dx=le("ZodCIDRv6",(t,e)=>{ld.init(t,e),Ct.init(t,e)});var Lx=le("ZodBase64",(t,e)=>{ud.init(t,e),Ct.init(t,e)});var Zx=le("ZodBase64URL",(t,e)=>{dd.init(t,e),Ct.init(t,e)});var Bx=le("ZodE164",(t,e)=>{fd.init(t,e),Ct.init(t,e)});var qx=le("ZodJWT",(t,e)=>{hd.init(t,e),Ct.init(t,e)});var mg=le("ZodNumber",(t,e)=>{rc.init(t,e),Bt.init(t,e),t.gt=(n,s)=>t.check(ac(n,s)),t.gte=(n,s)=>t.check(Ai(n,s)),t.min=(n,s)=>t.check(Ai(n,s)),t.lt=(n,s)=>t.check(ic(n,s)),t.lte=(n,s)=>t.check(Oi(n,s)),t.max=(n,s)=>t.check(Oi(n,s)),t.int=n=>t.check(fg(n)),t.safe=n=>t.check(fg(n)),t.positive=n=>t.check(ac(0,n)),t.nonnegative=n=>t.check(Ai(0,n)),t.negative=n=>t.check(ic(0,n)),t.nonpositive=n=>t.check(Oi(0,n)),t.multipleOf=(n,s)=>t.check(cc(n,s)),t.step=(n,s)=>t.check(cc(n,s)),t.finite=()=>t;let r=t._zod.bag;t.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,t.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,t.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),t.isFinite=!0,t.format=r.format??null});function wt(t){return nf(mg,t)}var Vx=le("ZodNumberFormat",(t,e)=>{pd.init(t,e),mg.init(t,e)});function fg(t){return sf(Vx,t)}var Fx=le("ZodBoolean",(t,e)=>{md.init(t,e),Bt.init(t,e)});function er(t){return of(Fx,t)}var Hx=le("ZodNull",(t,e)=>{gd.init(t,e),Bt.init(t,e)});function gg(t){return af(Hx,t)}var Ux=le("ZodUnknown",(t,e)=>{_d.init(t,e),Bt.init(t,e)});function jt(){return cf(Ux)}var Gx=le("ZodNever",(t,e)=>{bd.init(t,e),Bt.init(t,e)});function Yx(t){return lf(Gx,t)}var Xx=le("ZodArray",(t,e)=>{yd.init(t,e),Bt.init(t,e),t.element=e.element,t.min=(r,n)=>t.check($o(r,n)),t.nonempty=r=>t.check($o(1,r)),t.max=(r,n)=>t.check(lc(r,n)),t.length=(r,n)=>t.check(uc(r,n)),t.unwrap=()=>t.element});function dt(t,e){return J0(Xx,t,e)}var _g=le("ZodObject",(t,e)=>{nc.init(t,e),Bt.init(t,e),ut.defineLazy(t,"shape",()=>e.shape),t.keyof=()=>Sr(Object.keys(t._zod.def.shape)),t.catchall=r=>t.clone({...t._zod.def,catchall:r}),t.passthrough=()=>t.clone({...t._zod.def,catchall:jt()}),t.loose=()=>t.clone({...t._zod.def,catchall:jt()}),t.strict=()=>t.clone({...t._zod.def,catchall:Yx()}),t.strip=()=>t.clone({...t._zod.def,catchall:void 0}),t.extend=r=>ut.extend(t,r),t.merge=r=>ut.merge(t,r),t.pick=r=>ut.pick(t,r),t.omit=r=>ut.omit(t,r),t.partial=(...r)=>ut.partial(vg,t,r[0]),t.required=(...r)=>ut.required(wg,t,r[0])});function Ae(t,e){let r={type:"object",get shape(){return ut.assignProp(this,"shape",{...t}),this.shape},...ut.normalizeParams(e)};return new _g(r)}function pr(t,e){return new _g({type:"object",get shape(){return ut.assignProp(this,"shape",{...t}),this.shape},catchall:jt(),...ut.normalizeParams(e)})}var bg=le("ZodUnion",(t,e)=>{sc.init(t,e),Bt.init(t,e),t.options=e.options});function Mt(t,e){return new bg({type:"union",options:t,...ut.normalizeParams(e)})}var Wx=le("ZodDiscriminatedUnion",(t,e)=>{bg.init(t,e),vd.init(t,e)});function Mf(t,e,r){return new Wx({type:"union",options:e,discriminator:t,...ut.normalizeParams(r)})}var Kx=le("ZodIntersection",(t,e)=>{wd.init(t,e),Bt.init(t,e)});function gc(t,e){return new Kx({type:"intersection",left:t,right:e})}var Jx=le("ZodRecord",(t,e)=>{xd.init(t,e),Bt.init(t,e),t.keyType=e.keyType,t.valueType=e.valueType});function Pt(t,e,r){return new Jx({type:"record",keyType:t,valueType:e,...ut.normalizeParams(r)})}var Rf=le("ZodEnum",(t,e)=>{kd.init(t,e),Bt.init(t,e),t.enum=e.entries,t.options=Object.values(e.entries);let r=new Set(Object.keys(e.entries));t.extract=(n,s)=>{let o={};for(let i of n)if(r.has(i))o[i]=e.entries[i];else throw new Error(`Key ${i} not found in enum`);return new Rf({...e,checks:[],...ut.normalizeParams(s),entries:o})},t.exclude=(n,s)=>{let o={...e.entries};for(let i of n)if(r.has(i))delete o[i];else throw new Error(`Key ${i} not found in enum`);return new Rf({...e,checks:[],...ut.normalizeParams(s),entries:o})}});function Sr(t,e){let r=Array.isArray(t)?Object.fromEntries(t.map(n=>[n,n])):t;return new Rf({type:"enum",entries:r,...ut.normalizeParams(e)})}var Qx=le("ZodLiteral",(t,e)=>{Sd.init(t,e),Bt.init(t,e),t.values=new Set(e.values),Object.defineProperty(t,"value",{get(){if(e.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return e.values[0]}})});function Ve(t,e){return new Qx({type:"literal",values:Array.isArray(t)?t:[t],...ut.normalizeParams(e)})}var ek=le("ZodTransform",(t,e)=>{Ed.init(t,e),Bt.init(t,e),t._zod.parse=(r,n)=>{r.addIssue=o=>{if(typeof o=="string")r.issues.push(ut.issue(o,r.value,e));else{let i=o;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=r.value),i.inst??(i.inst=t),i.continue??(i.continue=!0),r.issues.push(ut.issue(i))}};let s=e.transform(r.value,r);return s instanceof Promise?s.then(o=>(r.value=o,r)):(r.value=s,r)}});function yg(t){return new ek({type:"transform",transform:t})}var vg=le("ZodOptional",(t,e)=>{Td.init(t,e),Bt.init(t,e),t.unwrap=()=>t._zod.def.innerType});function Dt(t){return new vg({type:"optional",innerType:t})}var tk=le("ZodNullable",(t,e)=>{$d.init(t,e),Bt.init(t,e),t.unwrap=()=>t._zod.def.innerType});function hg(t){return new tk({type:"nullable",innerType:t})}var rk=le("ZodDefault",(t,e)=>{Rd.init(t,e),Bt.init(t,e),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});function nk(t,e){return new rk({type:"default",innerType:t,get defaultValue(){return typeof e=="function"?e():e}})}var sk=le("ZodPrefault",(t,e)=>{Pd.init(t,e),Bt.init(t,e),t.unwrap=()=>t._zod.def.innerType});function ok(t,e){return new sk({type:"prefault",innerType:t,get defaultValue(){return typeof e=="function"?e():e}})}var wg=le("ZodNonOptional",(t,e)=>{Md.init(t,e),Bt.init(t,e),t.unwrap=()=>t._zod.def.innerType});function ik(t,e){return new wg({type:"nonoptional",innerType:t,...ut.normalizeParams(e)})}var ak=le("ZodCatch",(t,e)=>{zd.init(t,e),Bt.init(t,e),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});function ck(t,e){return new ak({type:"catch",innerType:t,catchValue:typeof e=="function"?e:()=>e})}var lk=le("ZodPipe",(t,e)=>{Id.init(t,e),Bt.init(t,e),t.in=e.in,t.out=e.out});function Pf(t,e){return new lk({type:"pipe",in:t,out:e})}var uk=le("ZodReadonly",(t,e)=>{Od.init(t,e),Bt.init(t,e)});function dk(t){return new uk({type:"readonly",innerType:t})}var xg=le("ZodCustom",(t,e)=>{Ad.init(t,e),Bt.init(t,e)});function fk(t){let e=new rr({check:"custom"});return e._zod.check=t,e}function kg(t,e){return vf(xg,t??(()=>!0),e)}function hk(t,e={}){return wf(xg,t,e)}function pk(t){let e=fk(r=>(r.addIssue=n=>{if(typeof n=="string")r.issues.push(ut.issue(n,r.value,e._zod.def));else{let s=n;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=r.value),s.inst??(s.inst=e),s.continue??(s.continue=!e._zod.def.abort),r.issues.push(ut.issue(s))}},t(r.value,r)));return e}function zf(t,e){return Pf(yg(t),e)}Cr(U0());var Of="2025-11-25";var Sg=[Of,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],ts="io.modelcontextprotocol/related-task",bc="2.0",Wt=kg(t=>t!==null&&(typeof t=="object"||typeof t=="function")),Eg=Mt([ce(),wt().int()]),Tg=ce(),PN=pr({ttl:wt().optional(),pollInterval:wt().optional()}),mk=Ae({ttl:wt().optional()}),gk=Ae({taskId:ce()}),Af=pr({progressToken:Eg.optional(),[ts]:gk.optional()}),Dr=Ae({_meta:Af.optional()}),ji=Dr.extend({task:mk.optional()}),$g=t=>ji.safeParse(t).success,nr=Ae({method:ce(),params:Dr.loose().optional()}),Yr=Ae({_meta:Af.optional()}),Xr=Ae({method:ce(),params:Yr.loose().optional()}),sr=pr({_meta:Af.optional()}),yc=Mt([ce(),wt().int()]),Rg=Ae({jsonrpc:Ve(bc),id:yc,...nr.shape}).strict(),Nf=t=>Rg.safeParse(t).success,Pg=Ae({jsonrpc:Ve(bc),...Xr.shape}).strict(),Mg=t=>Pg.safeParse(t).success,Cf=Ae({jsonrpc:Ve(bc),id:yc,result:sr}).strict(),Di=t=>Cf.safeParse(t).success;var Ue;(function(t){t[t.ConnectionClosed=-32e3]="ConnectionClosed",t[t.RequestTimeout=-32001]="RequestTimeout",t[t.ParseError=-32700]="ParseError",t[t.InvalidRequest=-32600]="InvalidRequest",t[t.MethodNotFound=-32601]="MethodNotFound",t[t.InvalidParams=-32602]="InvalidParams",t[t.InternalError=-32603]="InternalError",t[t.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(Ue||(Ue={}));var jf=Ae({jsonrpc:Ve(bc),id:yc.optional(),error:Ae({code:wt().int(),message:ce(),data:jt().optional()})}).strict();var zg=t=>jf.safeParse(t).success;var Ig=Mt([Rg,Pg,Cf,jf]),MN=Mt([Cf,jf]),vc=sr.strict(),_k=Yr.extend({requestId:yc.optional(),reason:ce().optional()}),wc=Xr.extend({method:Ve("notifications/cancelled"),params:_k}),bk=Ae({src:ce(),mimeType:ce().optional(),sizes:dt(ce()).optional(),theme:Sr(["light","dark"]).optional()}),Li=Ae({icons:dt(bk).optional()}),Po=Ae({name:ce(),title:ce().optional()}),Og=Po.extend({...Po.shape,...Li.shape,version:ce(),websiteUrl:ce().optional(),description:ce().optional()}),yk=gc(Ae({applyDefaults:er().optional()}),Pt(ce(),jt())),vk=zf(t=>t&&typeof t=="object"&&!Array.isArray(t)&&Object.keys(t).length===0?{form:{}}:t,gc(Ae({form:yk.optional(),url:Wt.optional()}),Pt(ce(),jt()).optional())),wk=pr({list:Wt.optional(),cancel:Wt.optional(),requests:pr({sampling:pr({createMessage:Wt.optional()}).optional(),elicitation:pr({create:Wt.optional()}).optional()}).optional()}),xk=pr({list:Wt.optional(),cancel:Wt.optional(),requests:pr({tools:pr({call:Wt.optional()}).optional()}).optional()}),kk=Ae({experimental:Pt(ce(),Wt).optional(),sampling:Ae({context:Wt.optional(),tools:Wt.optional()}).optional(),elicitation:vk.optional(),roots:Ae({listChanged:er().optional()}).optional(),tasks:wk.optional(),extensions:Pt(ce(),Wt).optional()}),Sk=Dr.extend({protocolVersion:ce(),capabilities:kk,clientInfo:Og}),Df=nr.extend({method:Ve("initialize"),params:Sk});var Ek=Ae({experimental:Pt(ce(),Wt).optional(),logging:Wt.optional(),completions:Wt.optional(),prompts:Ae({listChanged:er().optional()}).optional(),resources:Ae({subscribe:er().optional(),listChanged:er().optional()}).optional(),tools:Ae({listChanged:er().optional()}).optional(),tasks:xk.optional(),extensions:Pt(ce(),Wt).optional()}),Tk=sr.extend({protocolVersion:ce(),capabilities:Ek,serverInfo:Og,instructions:ce().optional()}),Lf=Xr.extend({method:Ve("notifications/initialized"),params:Yr.optional()});var xc=nr.extend({method:Ve("ping"),params:Dr.optional()}),$k=Ae({progress:wt(),total:Dt(wt()),message:Dt(ce())}),Rk=Ae({...Yr.shape,...$k.shape,progressToken:Eg}),kc=Xr.extend({method:Ve("notifications/progress"),params:Rk}),Pk=Dr.extend({cursor:Tg.optional()}),Zi=nr.extend({params:Pk.optional()}),Bi=sr.extend({nextCursor:Tg.optional()}),Mk=Sr(["working","input_required","completed","failed","cancelled"]),qi=Ae({taskId:ce(),status:Mk,ttl:Mt([wt(),gg()]),createdAt:ce(),lastUpdatedAt:ce(),pollInterval:Dt(wt()),statusMessage:Dt(ce())}),Mo=sr.extend({task:qi}),zk=Yr.merge(qi),Vi=Xr.extend({method:Ve("notifications/tasks/status"),params:zk}),Sc=nr.extend({method:Ve("tasks/get"),params:Dr.extend({taskId:ce()})}),Ec=sr.merge(qi),Tc=nr.extend({method:Ve("tasks/result"),params:Dr.extend({taskId:ce()})}),zN=sr.loose(),$c=Zi.extend({method:Ve("tasks/list")}),Rc=Bi.extend({tasks:dt(qi)}),Pc=nr.extend({method:Ve("tasks/cancel"),params:Dr.extend({taskId:ce()})}),Ag=sr.merge(qi),Ng=Ae({uri:ce(),mimeType:Dt(ce()),_meta:Pt(ce(),jt()).optional()}),Cg=Ng.extend({text:ce()}),Zf=ce().refine(t=>{try{return atob(t),!0}catch{return!1}},{message:"Invalid Base64 string"}),jg=Ng.extend({blob:Zf}),Fi=Sr(["user","assistant"]),zo=Ae({audience:dt(Fi).optional(),priority:wt().min(0).max(1).optional(),lastModified:Ni.datetime({offset:!0}).optional()}),Dg=Ae({...Po.shape,...Li.shape,uri:ce(),description:Dt(ce()),mimeType:Dt(ce()),size:Dt(wt()),annotations:zo.optional(),_meta:Dt(pr({}))}),Ik=Ae({...Po.shape,...Li.shape,uriTemplate:ce(),description:Dt(ce()),mimeType:Dt(ce()),annotations:zo.optional(),_meta:Dt(pr({}))}),Mc=Zi.extend({method:Ve("resources/list")}),Ok=Bi.extend({resources:dt(Dg)}),zc=Zi.extend({method:Ve("resources/templates/list")}),Ak=Bi.extend({resourceTemplates:dt(Ik)}),Bf=Dr.extend({uri:ce()}),Nk=Bf,Ic=nr.extend({method:Ve("resources/read"),params:Nk}),Ck=sr.extend({contents:dt(Mt([Cg,jg]))}),jk=Xr.extend({method:Ve("notifications/resources/list_changed"),params:Yr.optional()}),Dk=Bf,Lk=nr.extend({method:Ve("resources/subscribe"),params:Dk}),Zk=Bf,Bk=nr.extend({method:Ve("resources/unsubscribe"),params:Zk}),qk=Yr.extend({uri:ce()}),Vk=Xr.extend({method:Ve("notifications/resources/updated"),params:qk}),Fk=Ae({name:ce(),description:Dt(ce()),required:Dt(er())}),Hk=Ae({...Po.shape,...Li.shape,description:Dt(ce()),arguments:Dt(dt(Fk)),_meta:Dt(pr({}))}),Oc=Zi.extend({method:Ve("prompts/list")}),Uk=Bi.extend({prompts:dt(Hk)}),Gk=Dr.extend({name:ce(),arguments:Pt(ce(),ce()).optional()}),Ac=nr.extend({method:Ve("prompts/get"),params:Gk}),qf=Ae({type:Ve("text"),text:ce(),annotations:zo.optional(),_meta:Pt(ce(),jt()).optional()}),Vf=Ae({type:Ve("image"),data:Zf,mimeType:ce(),annotations:zo.optional(),_meta:Pt(ce(),jt()).optional()}),Ff=Ae({type:Ve("audio"),data:Zf,mimeType:ce(),annotations:zo.optional(),_meta:Pt(ce(),jt()).optional()}),Yk=Ae({type:Ve("tool_use"),name:ce(),id:ce(),input:Pt(ce(),jt()),_meta:Pt(ce(),jt()).optional()}),Xk=Ae({type:Ve("resource"),resource:Mt([Cg,jg]),annotations:zo.optional(),_meta:Pt(ce(),jt()).optional()}),Wk=Dg.extend({type:Ve("resource_link")}),Hf=Mt([qf,Vf,Ff,Wk,Xk]),Kk=Ae({role:Fi,content:Hf}),Jk=sr.extend({description:ce().optional(),messages:dt(Kk)}),Qk=Xr.extend({method:Ve("notifications/prompts/list_changed"),params:Yr.optional()}),e6=Ae({title:ce().optional(),readOnlyHint:er().optional(),destructiveHint:er().optional(),idempotentHint:er().optional(),openWorldHint:er().optional()}),t6=Ae({taskSupport:Sr(["required","optional","forbidden"]).optional()}),Lg=Ae({...Po.shape,...Li.shape,description:ce().optional(),inputSchema:Ae({type:Ve("object"),properties:Pt(ce(),Wt).optional(),required:dt(ce()).optional()}).catchall(jt()),outputSchema:Ae({type:Ve("object"),properties:Pt(ce(),Wt).optional(),required:dt(ce()).optional()}).catchall(jt()).optional(),annotations:e6.optional(),execution:t6.optional(),_meta:Pt(ce(),jt()).optional()}),Nc=Zi.extend({method:Ve("tools/list")}),r6=Bi.extend({tools:dt(Lg)}),Cc=sr.extend({content:dt(Hf).default([]),structuredContent:Pt(ce(),jt()).optional(),isError:er().optional()}),IN=Cc.or(sr.extend({toolResult:jt()})),n6=ji.extend({name:ce(),arguments:Pt(ce(),jt()).optional()}),Io=nr.extend({method:Ve("tools/call"),params:n6}),s6=Xr.extend({method:Ve("notifications/tools/list_changed"),params:Yr.optional()}),ON=Ae({autoRefresh:er().default(!0),debounceMs:wt().int().nonnegative().default(300)}),Hi=Sr(["debug","info","notice","warning","error","critical","alert","emergency"]),o6=Dr.extend({level:Hi}),Uf=nr.extend({method:Ve("logging/setLevel"),params:o6}),i6=Yr.extend({level:Hi,logger:ce().optional(),data:jt()}),a6=Xr.extend({method:Ve("notifications/message"),params:i6}),c6=Ae({name:ce().optional()}),l6=Ae({hints:dt(c6).optional(),costPriority:wt().min(0).max(1).optional(),speedPriority:wt().min(0).max(1).optional(),intelligencePriority:wt().min(0).max(1).optional()}),u6=Ae({mode:Sr(["auto","required","none"]).optional()}),d6=Ae({type:Ve("tool_result"),toolUseId:ce().describe("The unique identifier for the corresponding tool call."),content:dt(Hf).default([]),structuredContent:Ae({}).loose().optional(),isError:er().optional(),_meta:Pt(ce(),jt()).optional()}),f6=Mf("type",[qf,Vf,Ff]),_c=Mf("type",[qf,Vf,Ff,Yk,d6]),h6=Ae({role:Fi,content:Mt([_c,dt(_c)]),_meta:Pt(ce(),jt()).optional()}),p6=ji.extend({messages:dt(h6),modelPreferences:l6.optional(),systemPrompt:ce().optional(),includeContext:Sr(["none","thisServer","allServers"]).optional(),temperature:wt().optional(),maxTokens:wt().int(),stopSequences:dt(ce()).optional(),metadata:Wt.optional(),tools:dt(Lg).optional(),toolChoice:u6.optional()}),m6=nr.extend({method:Ve("sampling/createMessage"),params:p6}),Ui=sr.extend({model:ce(),stopReason:Dt(Sr(["endTurn","stopSequence","maxTokens"]).or(ce())),role:Fi,content:f6}),Gf=sr.extend({model:ce(),stopReason:Dt(Sr(["endTurn","stopSequence","maxTokens","toolUse"]).or(ce())),role:Fi,content:Mt([_c,dt(_c)])}),g6=Ae({type:Ve("boolean"),title:ce().optional(),description:ce().optional(),default:er().optional()}),_6=Ae({type:Ve("string"),title:ce().optional(),description:ce().optional(),minLength:wt().optional(),maxLength:wt().optional(),format:Sr(["email","uri","date","date-time"]).optional(),default:ce().optional()}),b6=Ae({type:Sr(["number","integer"]),title:ce().optional(),description:ce().optional(),minimum:wt().optional(),maximum:wt().optional(),default:wt().optional()}),y6=Ae({type:Ve("string"),title:ce().optional(),description:ce().optional(),enum:dt(ce()),default:ce().optional()}),v6=Ae({type:Ve("string"),title:ce().optional(),description:ce().optional(),oneOf:dt(Ae({const:ce(),title:ce()})),default:ce().optional()}),w6=Ae({type:Ve("string"),title:ce().optional(),description:ce().optional(),enum:dt(ce()),enumNames:dt(ce()).optional(),default:ce().optional()}),x6=Mt([y6,v6]),k6=Ae({type:Ve("array"),title:ce().optional(),description:ce().optional(),minItems:wt().optional(),maxItems:wt().optional(),items:Ae({type:Ve("string"),enum:dt(ce())}),default:dt(ce()).optional()}),S6=Ae({type:Ve("array"),title:ce().optional(),description:ce().optional(),minItems:wt().optional(),maxItems:wt().optional(),items:Ae({anyOf:dt(Ae({const:ce(),title:ce()}))}),default:dt(ce()).optional()}),E6=Mt([k6,S6]),T6=Mt([w6,x6,E6]),$6=Mt([T6,g6,_6,b6]),R6=ji.extend({mode:Ve("form").optional(),message:ce(),requestedSchema:Ae({type:Ve("object"),properties:Pt(ce(),$6),required:dt(ce()).optional()})}),P6=ji.extend({mode:Ve("url"),message:ce(),elicitationId:ce(),url:ce().url()}),M6=Mt([R6,P6]),z6=nr.extend({method:Ve("elicitation/create"),params:M6}),I6=Yr.extend({elicitationId:ce()}),O6=Xr.extend({method:Ve("notifications/elicitation/complete"),params:I6}),Oo=sr.extend({action:Sr(["accept","decline","cancel"]),content:zf(t=>t===null?void 0:t,Pt(ce(),Mt([ce(),wt(),er(),dt(ce())])).optional())}),A6=Ae({type:Ve("ref/resource"),uri:ce()});var N6=Ae({type:Ve("ref/prompt"),name:ce()}),C6=Dr.extend({ref:Mt([N6,A6]),argument:Ae({name:ce(),value:ce()}),context:Ae({arguments:Pt(ce(),ce()).optional()}).optional()}),jc=nr.extend({method:Ve("completion/complete"),params:C6});function Zg(t){if(t.params.ref.type!=="ref/prompt")throw new TypeError(`Expected CompleteRequestPrompt, but got ${t.params.ref.type}`)}function Bg(t){if(t.params.ref.type!=="ref/resource")throw new TypeError(`Expected CompleteRequestResourceTemplate, but got ${t.params.ref.type}`)}var j6=sr.extend({completion:pr({values:dt(ce()).max(100),total:Dt(wt().int()),hasMore:Dt(er())})}),D6=Ae({uri:ce().startsWith("file://"),name:ce().optional(),_meta:Pt(ce(),jt()).optional()}),L6=nr.extend({method:Ve("roots/list"),params:Dr.optional()}),Yf=sr.extend({roots:dt(D6)}),Z6=Xr.extend({method:Ve("notifications/roots/list_changed"),params:Yr.optional()}),AN=Mt([xc,Df,jc,Uf,Ac,Oc,Mc,zc,Ic,Lk,Bk,Io,Nc,Sc,Tc,$c,Pc]),NN=Mt([wc,kc,Lf,Z6,Vi]),CN=Mt([vc,Ui,Gf,Oo,Yf,Ec,Rc,Mo]),jN=Mt([xc,m6,z6,L6,Sc,Tc,$c,Pc]),DN=Mt([wc,kc,a6,Vk,jk,s6,Qk,Vi,O6]),LN=Mt([vc,Tk,j6,Jk,Uk,Ok,Ak,Ck,Cc,r6,Ec,Rc,Mo]),Ze=class t extends Error{constructor(e,r,n){super(`MCP error ${e}: ${r}`),this.code=e,this.data=n,this.name="McpError"}static fromError(e,r,n){if(e===Ue.UrlElicitationRequired&&n){let s=n;if(s.elicitations)return new If(s.elicitations,r)}return new t(e,r,n)}},If=class extends Ze{constructor(e,r=`URL elicitation${e.length>1?"s":""} required`){super(Ue.UrlElicitationRequired,r,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}};function rs(t){return t==="completed"||t==="failed"||t==="cancelled"}var Vg=Symbol("Let zodToJsonSchema decide on which parser to use");var qg={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref",openAiAnyTypeName:"OpenAiAnyType"},Fg=t=>typeof t=="string"?{...qg,name:t}:{...qg,...t};var Hg=t=>{let e=Fg(t),r=e.name!==void 0?[...e.basePath,e.definitionPath,e.name]:e.basePath;return{...e,flags:{hasReferencedOpenAiAnyType:!1},currentPath:r,propertyPath:void 0,seen:new Map(Object.entries(e.definitions).map(([n,s])=>[s._def,{def:s._def,path:[...e.basePath,e.definitionPath,n],jsonSchema:void 0}]))}};function Xf(t,e,r,n){n?.errorMessages&&r&&(t.errorMessage={...t.errorMessage,[e]:r})}function ft(t,e,r,n,s){t[e]=r,Xf(t,e,n,s)}var Dc=(t,e)=>{let r=0;for(;r<t.length&&r<e.length&&t[r]===e[r];r++);return[(t.length-r).toString(),...e.slice(r)].join("/")};function Lt(t){if(t.target!=="openAi")return{};let e=[...t.basePath,t.definitionPath,t.openAiAnyTypeName];return t.flags.hasReferencedOpenAiAnyType=!0,{$ref:t.$refStrategy==="relative"?Dc(e,t.currentPath):e.join("/")}}function Ug(t,e){let r={type:"array"};return t.type?._def&&t.type?._def?.typeName!==be.ZodAny&&(r.items=We(t.type._def,{...e,currentPath:[...e.currentPath,"items"]})),t.minLength&&ft(r,"minItems",t.minLength.value,t.minLength.message,e),t.maxLength&&ft(r,"maxItems",t.maxLength.value,t.maxLength.message,e),t.exactLength&&(ft(r,"minItems",t.exactLength.value,t.exactLength.message,e),ft(r,"maxItems",t.exactLength.value,t.exactLength.message,e)),r}function Gg(t,e){let r={type:"integer",format:"int64"};if(!t.checks)return r;for(let n of t.checks)switch(n.kind){case"min":e.target==="jsonSchema7"?n.inclusive?ft(r,"minimum",n.value,n.message,e):ft(r,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(r.exclusiveMinimum=!0),ft(r,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?ft(r,"maximum",n.value,n.message,e):ft(r,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(r.exclusiveMaximum=!0),ft(r,"maximum",n.value,n.message,e));break;case"multipleOf":ft(r,"multipleOf",n.value,n.message,e);break}return r}function Yg(){return{type:"boolean"}}function Lc(t,e){return We(t.type._def,e)}var Xg=(t,e)=>We(t.innerType._def,e);function Wf(t,e,r){let n=r??e.dateStrategy;if(Array.isArray(n))return{anyOf:n.map((s,o)=>Wf(t,e,s))};switch(n){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return B6(t,e)}}var B6=(t,e)=>{let r={type:"integer",format:"unix-time"};if(e.target==="openApi3")return r;for(let n of t.checks)switch(n.kind){case"min":ft(r,"minimum",n.value,n.message,e);break;case"max":ft(r,"maximum",n.value,n.message,e);break}return r};function Wg(t,e){return{...We(t.innerType._def,e),default:t.defaultValue()}}function Kg(t,e){return e.effectStrategy==="input"?We(t.schema._def,e):Lt(e)}function Jg(t){return{type:"string",enum:Array.from(t.values)}}var q6=t=>"type"in t&&t.type==="string"?!1:"allOf"in t;function Qg(t,e){let r=[We(t.left._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),We(t.right._def,{...e,currentPath:[...e.currentPath,"allOf","1"]})].filter(o=>!!o),n=e.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,s=[];return r.forEach(o=>{if(q6(o))s.push(...o.allOf),o.unevaluatedProperties===void 0&&(n=void 0);else{let i=o;if("additionalProperties"in o&&o.additionalProperties===!1){let{additionalProperties:a,...c}=o;i=c}else n=void 0;s.push(i)}}),s.length?{allOf:s,...n}:void 0}function e_(t,e){let r=typeof t.value;return r!=="bigint"&&r!=="number"&&r!=="boolean"&&r!=="string"?{type:Array.isArray(t.value)?"array":"object"}:e.target==="openApi3"?{type:r==="bigint"?"integer":r,enum:[t.value]}:{type:r==="bigint"?"integer":r,const:t.value}}var Kf,dn={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(Kf===void 0&&(Kf=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Kf),uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ipv4Cidr:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function Zc(t,e){let r={type:"string"};if(t.checks)for(let n of t.checks)switch(n.kind){case"min":ft(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value,n.message,e);break;case"max":ft(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,n.value):n.value,n.message,e);break;case"email":switch(e.emailStrategy){case"format:email":fn(r,"email",n.message,e);break;case"format:idn-email":fn(r,"idn-email",n.message,e);break;case"pattern:zod":mr(r,dn.email,n.message,e);break}break;case"url":fn(r,"uri",n.message,e);break;case"uuid":fn(r,"uuid",n.message,e);break;case"regex":mr(r,n.regex,n.message,e);break;case"cuid":mr(r,dn.cuid,n.message,e);break;case"cuid2":mr(r,dn.cuid2,n.message,e);break;case"startsWith":mr(r,RegExp(`^${Jf(n.value,e)}`),n.message,e);break;case"endsWith":mr(r,RegExp(`${Jf(n.value,e)}$`),n.message,e);break;case"datetime":fn(r,"date-time",n.message,e);break;case"date":fn(r,"date",n.message,e);break;case"time":fn(r,"time",n.message,e);break;case"duration":fn(r,"duration",n.message,e);break;case"length":ft(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value,n.message,e),ft(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,n.value):n.value,n.message,e);break;case"includes":{mr(r,RegExp(Jf(n.value,e)),n.message,e);break}case"ip":{n.version!=="v6"&&fn(r,"ipv4",n.message,e),n.version!=="v4"&&fn(r,"ipv6",n.message,e);break}case"base64url":mr(r,dn.base64url,n.message,e);break;case"jwt":mr(r,dn.jwt,n.message,e);break;case"cidr":{n.version!=="v6"&&mr(r,dn.ipv4Cidr,n.message,e),n.version!=="v4"&&mr(r,dn.ipv6Cidr,n.message,e);break}case"emoji":mr(r,dn.emoji(),n.message,e);break;case"ulid":{mr(r,dn.ulid,n.message,e);break}case"base64":{switch(e.base64Strategy){case"format:binary":{fn(r,"binary",n.message,e);break}case"contentEncoding:base64":{ft(r,"contentEncoding","base64",n.message,e);break}case"pattern:zod":{mr(r,dn.base64,n.message,e);break}}break}case"nanoid":mr(r,dn.nanoid,n.message,e);case"toLowerCase":case"toUpperCase":case"trim":break;default:}return r}function Jf(t,e){return e.patternStrategy==="escape"?F6(t):t}var V6=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function F6(t){let e="";for(let r=0;r<t.length;r++)V6.has(t[r])||(e+="\\"),e+=t[r];return e}function fn(t,e,r,n){t.format||t.anyOf?.some(s=>s.format)?(t.anyOf||(t.anyOf=[]),t.format&&(t.anyOf.push({format:t.format,...t.errorMessage&&n.errorMessages&&{errorMessage:{format:t.errorMessage.format}}}),delete t.format,t.errorMessage&&(delete t.errorMessage.format,Object.keys(t.errorMessage).length===0&&delete t.errorMessage)),t.anyOf.push({format:e,...r&&n.errorMessages&&{errorMessage:{format:r}}})):ft(t,"format",e,r,n)}function mr(t,e,r,n){t.pattern||t.allOf?.some(s=>s.pattern)?(t.allOf||(t.allOf=[]),t.pattern&&(t.allOf.push({pattern:t.pattern,...t.errorMessage&&n.errorMessages&&{errorMessage:{pattern:t.errorMessage.pattern}}}),delete t.pattern,t.errorMessage&&(delete t.errorMessage.pattern,Object.keys(t.errorMessage).length===0&&delete t.errorMessage)),t.allOf.push({pattern:t_(e,n),...r&&n.errorMessages&&{errorMessage:{pattern:r}}})):ft(t,"pattern",t_(e,n),r,n)}function t_(t,e){if(!e.applyRegexFlags||!t.flags)return t.source;let r={i:t.flags.includes("i"),m:t.flags.includes("m"),s:t.flags.includes("s")},n=r.i?t.source.toLowerCase():t.source,s="",o=!1,i=!1,a=!1;for(let c=0;c<n.length;c++){if(o){s+=n[c],o=!1;continue}if(r.i){if(i){if(n[c].match(/[a-z]/)){a?(s+=n[c],s+=`${n[c-2]}-${n[c]}`.toUpperCase(),a=!1):n[c+1]==="-"&&n[c+2]?.match(/[a-z]/)?(s+=n[c],a=!0):s+=`${n[c]}${n[c].toUpperCase()}`;continue}}else if(n[c].match(/[a-z]/)){s+=`[${n[c]}${n[c].toUpperCase()}]`;continue}}if(r.m){if(n[c]==="^"){s+=`(^|(?<=[\r
|
|
37
|
+
]))`;continue}else if(n[c]==="$"){s+=`($|(?=[\r
|
|
38
|
+
]))`;continue}}if(r.s&&n[c]==="."){s+=i?`${n[c]}\r
|
|
39
|
+
`:`[${n[c]}\r
|
|
40
|
+
]`;continue}s+=n[c],n[c]==="\\"?o=!0:i&&n[c]==="]"?i=!1:!i&&n[c]==="["&&(i=!0)}try{new RegExp(s)}catch{return console.warn(`Could not convert regex pattern at ${e.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),t.source}return s}function Bc(t,e){if(e.target==="openAi"&&console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead."),e.target==="openApi3"&&t.keyType?._def.typeName===be.ZodEnum)return{type:"object",required:t.keyType._def.values,properties:t.keyType._def.values.reduce((n,s)=>({...n,[s]:We(t.valueType._def,{...e,currentPath:[...e.currentPath,"properties",s]})??Lt(e)}),{}),additionalProperties:e.rejectedAdditionalProperties};let r={type:"object",additionalProperties:We(t.valueType._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]})??e.allowedAdditionalProperties};if(e.target==="openApi3")return r;if(t.keyType?._def.typeName===be.ZodString&&t.keyType._def.checks?.length){let{type:n,...s}=Zc(t.keyType._def,e);return{...r,propertyNames:s}}else{if(t.keyType?._def.typeName===be.ZodEnum)return{...r,propertyNames:{enum:t.keyType._def.values}};if(t.keyType?._def.typeName===be.ZodBranded&&t.keyType._def.type._def.typeName===be.ZodString&&t.keyType._def.type._def.checks?.length){let{type:n,...s}=Lc(t.keyType._def,e);return{...r,propertyNames:s}}}return r}function r_(t,e){if(e.mapStrategy==="record")return Bc(t,e);let r=We(t.keyType._def,{...e,currentPath:[...e.currentPath,"items","items","0"]})||Lt(e),n=We(t.valueType._def,{...e,currentPath:[...e.currentPath,"items","items","1"]})||Lt(e);return{type:"array",maxItems:125,items:{type:"array",items:[r,n],minItems:2,maxItems:2}}}function n_(t){let e=t.values,n=Object.keys(t.values).filter(o=>typeof e[e[o]]!="number").map(o=>e[o]),s=Array.from(new Set(n.map(o=>typeof o)));return{type:s.length===1?s[0]==="string"?"string":"number":["string","number"],enum:n}}function s_(t){return t.target==="openAi"?void 0:{not:Lt({...t,currentPath:[...t.currentPath,"not"]})}}function o_(t){return t.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}var Gi={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function a_(t,e){if(e.target==="openApi3")return i_(t,e);let r=t.options instanceof Map?Array.from(t.options.values()):t.options;if(r.every(n=>n._def.typeName in Gi&&(!n._def.checks||!n._def.checks.length))){let n=r.reduce((s,o)=>{let i=Gi[o._def.typeName];return i&&!s.includes(i)?[...s,i]:s},[]);return{type:n.length>1?n:n[0]}}else if(r.every(n=>n._def.typeName==="ZodLiteral"&&!n.description)){let n=r.reduce((s,o)=>{let i=typeof o._def.value;switch(i){case"string":case"number":case"boolean":return[...s,i];case"bigint":return[...s,"integer"];case"object":if(o._def.value===null)return[...s,"null"];case"symbol":case"undefined":case"function":default:return s}},[]);if(n.length===r.length){let s=n.filter((o,i,a)=>a.indexOf(o)===i);return{type:s.length>1?s:s[0],enum:r.reduce((o,i)=>o.includes(i._def.value)?o:[...o,i._def.value],[])}}}else if(r.every(n=>n._def.typeName==="ZodEnum"))return{type:"string",enum:r.reduce((n,s)=>[...n,...s._def.values.filter(o=>!n.includes(o))],[])};return i_(t,e)}var i_=(t,e)=>{let r=(t.options instanceof Map?Array.from(t.options.values()):t.options).map((n,s)=>We(n._def,{...e,currentPath:[...e.currentPath,"anyOf",`${s}`]})).filter(n=>!!n&&(!e.strictUnions||typeof n=="object"&&Object.keys(n).length>0));return r.length?{anyOf:r}:void 0};function c_(t,e){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(t.innerType._def.typeName)&&(!t.innerType._def.checks||!t.innerType._def.checks.length))return e.target==="openApi3"?{type:Gi[t.innerType._def.typeName],nullable:!0}:{type:[Gi[t.innerType._def.typeName],"null"]};if(e.target==="openApi3"){let n=We(t.innerType._def,{...e,currentPath:[...e.currentPath]});return n&&"$ref"in n?{allOf:[n],nullable:!0}:n&&{...n,nullable:!0}}let r=We(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","0"]});return r&&{anyOf:[r,{type:"null"}]}}function l_(t,e){let r={type:"number"};if(!t.checks)return r;for(let n of t.checks)switch(n.kind){case"int":r.type="integer",Xf(r,"type",n.message,e);break;case"min":e.target==="jsonSchema7"?n.inclusive?ft(r,"minimum",n.value,n.message,e):ft(r,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(r.exclusiveMinimum=!0),ft(r,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?ft(r,"maximum",n.value,n.message,e):ft(r,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(r.exclusiveMaximum=!0),ft(r,"maximum",n.value,n.message,e));break;case"multipleOf":ft(r,"multipleOf",n.value,n.message,e);break}return r}function u_(t,e){let r=e.target==="openAi",n={type:"object",properties:{}},s=[],o=t.shape();for(let a in o){let c=o[a];if(c===void 0||c._def===void 0)continue;let d=U6(c);d&&r&&(c._def.typeName==="ZodOptional"&&(c=c._def.innerType),c.isNullable()||(c=c.nullable()),d=!1);let l=We(c._def,{...e,currentPath:[...e.currentPath,"properties",a],propertyPath:[...e.currentPath,"properties",a]});l!==void 0&&(n.properties[a]=l,d||s.push(a))}s.length&&(n.required=s);let i=H6(t,e);return i!==void 0&&(n.additionalProperties=i),n}function H6(t,e){if(t.catchall._def.typeName!=="ZodNever")return We(t.catchall._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]});switch(t.unknownKeys){case"passthrough":return e.allowedAdditionalProperties;case"strict":return e.rejectedAdditionalProperties;case"strip":return e.removeAdditionalStrategy==="strict"?e.allowedAdditionalProperties:e.rejectedAdditionalProperties}}function U6(t){try{return t.isOptional()}catch{return!0}}var d_=(t,e)=>{if(e.currentPath.toString()===e.propertyPath?.toString())return We(t.innerType._def,e);let r=We(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","1"]});return r?{anyOf:[{not:Lt(e)},r]}:Lt(e)};var f_=(t,e)=>{if(e.pipeStrategy==="input")return We(t.in._def,e);if(e.pipeStrategy==="output")return We(t.out._def,e);let r=We(t.in._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),n=We(t.out._def,{...e,currentPath:[...e.currentPath,"allOf",r?"1":"0"]});return{allOf:[r,n].filter(s=>s!==void 0)}};function h_(t,e){return We(t.type._def,e)}function p_(t,e){let n={type:"array",uniqueItems:!0,items:We(t.valueType._def,{...e,currentPath:[...e.currentPath,"items"]})};return t.minSize&&ft(n,"minItems",t.minSize.value,t.minSize.message,e),t.maxSize&&ft(n,"maxItems",t.maxSize.value,t.maxSize.message,e),n}function m_(t,e){return t.rest?{type:"array",minItems:t.items.length,items:t.items.map((r,n)=>We(r._def,{...e,currentPath:[...e.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[]),additionalItems:We(t.rest._def,{...e,currentPath:[...e.currentPath,"additionalItems"]})}:{type:"array",minItems:t.items.length,maxItems:t.items.length,items:t.items.map((r,n)=>We(r._def,{...e,currentPath:[...e.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[])}}function g_(t){return{not:Lt(t)}}function __(t){return Lt(t)}var b_=(t,e)=>We(t.innerType._def,e);var y_=(t,e,r)=>{switch(e){case be.ZodString:return Zc(t,r);case be.ZodNumber:return l_(t,r);case be.ZodObject:return u_(t,r);case be.ZodBigInt:return Gg(t,r);case be.ZodBoolean:return Yg();case be.ZodDate:return Wf(t,r);case be.ZodUndefined:return g_(r);case be.ZodNull:return o_(r);case be.ZodArray:return Ug(t,r);case be.ZodUnion:case be.ZodDiscriminatedUnion:return a_(t,r);case be.ZodIntersection:return Qg(t,r);case be.ZodTuple:return m_(t,r);case be.ZodRecord:return Bc(t,r);case be.ZodLiteral:return e_(t,r);case be.ZodEnum:return Jg(t);case be.ZodNativeEnum:return n_(t);case be.ZodNullable:return c_(t,r);case be.ZodOptional:return d_(t,r);case be.ZodMap:return r_(t,r);case be.ZodSet:return p_(t,r);case be.ZodLazy:return()=>t.getter()._def;case be.ZodPromise:return h_(t,r);case be.ZodNaN:case be.ZodNever:return s_(r);case be.ZodEffects:return Kg(t,r);case be.ZodAny:return Lt(r);case be.ZodUnknown:return __(r);case be.ZodDefault:return Wg(t,r);case be.ZodBranded:return Lc(t,r);case be.ZodReadonly:return b_(t,r);case be.ZodCatch:return Xg(t,r);case be.ZodPipeline:return f_(t,r);case be.ZodFunction:case be.ZodVoid:case be.ZodSymbol:return;default:return(n=>{})(e)}};function We(t,e,r=!1){let n=e.seen.get(t);if(e.override){let a=e.override?.(t,e,n,r);if(a!==Vg)return a}if(n&&!r){let a=G6(n,e);if(a!==void 0)return a}let s={def:t,path:e.currentPath,jsonSchema:void 0};e.seen.set(t,s);let o=y_(t,t.typeName,e),i=typeof o=="function"?We(o(),e):o;if(i&&Y6(t,e,i),e.postProcess){let a=e.postProcess(i,t,e);return s.jsonSchema=i,a}return s.jsonSchema=i,i}var G6=(t,e)=>{switch(e.$refStrategy){case"root":return{$ref:t.path.join("/")};case"relative":return{$ref:Dc(e.currentPath,t.path)};case"none":case"seen":return t.path.length<e.currentPath.length&&t.path.every((r,n)=>e.currentPath[n]===r)?(console.warn(`Recursive reference detected at ${e.currentPath.join("/")}! Defaulting to any`),Lt(e)):e.$refStrategy==="seen"?Lt(e):void 0}},Y6=(t,e,r)=>(t.description&&(r.description=t.description,e.markdownDescription&&(r.markdownDescription=t.description)),r);var Qf=(t,e)=>{let r=Hg(e),n=typeof e=="object"&&e.definitions?Object.entries(e.definitions).reduce((c,[d,l])=>({...c,[d]:We(l._def,{...r,currentPath:[...r.basePath,r.definitionPath,d]},!0)??Lt(r)}),{}):void 0,s=typeof e=="string"?e:e?.nameStrategy==="title"?void 0:e?.name,o=We(t._def,s===void 0?r:{...r,currentPath:[...r.basePath,r.definitionPath,s]},!1)??Lt(r),i=typeof e=="object"&&e.name!==void 0&&e.nameStrategy==="title"?e.name:void 0;i!==void 0&&(o.title=i),r.flags.hasReferencedOpenAiAnyType&&(n||(n={}),n[r.openAiAnyTypeName]||(n[r.openAiAnyTypeName]={type:["string","number","integer","boolean","array","null"],items:{$ref:r.$refStrategy==="relative"?"1":[...r.basePath,r.definitionPath,r.openAiAnyTypeName].join("/")}}));let a=s===void 0?n?{...o,[r.definitionPath]:n}:o:{$ref:[...r.$refStrategy==="relative"?[]:r.basePath,r.definitionPath,s].join("/"),[r.definitionPath]:{...n,[s]:o}};return r.target==="jsonSchema7"?a.$schema="http://json-schema.org/draft-07/schema#":(r.target==="jsonSchema2019-09"||r.target==="openAi")&&(a.$schema="https://json-schema.org/draft/2019-09/schema#"),r.target==="openAi"&&("anyOf"in a||"oneOf"in a||"allOf"in a||"type"in a&&Array.isArray(a.type))&&console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property."),a};function X6(t){return!t||t==="jsonSchema7"||t==="draft-7"?"draft-7":t==="jsonSchema2019-09"||t==="draft-2020-12"?"draft-2020-12":"draft-7"}function eh(t,e){return Gr(t)?xf(t,{target:X6(e?.target),io:e?.pipeStrategy??"input"}):Qf(t,{strictUnions:e?.strictUnions??!0,pipeStrategy:e?.pipeStrategy??"input"})}function th(t){let r=es(t)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=pc(r);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}function rh(t,e){let r=Qn(t,e);if(!r.success)throw r.error;return r.data}var W6=6e4,qc=class{constructor(e){this._options=e,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(wc,r=>{this._oncancel(r)}),this.setNotificationHandler(kc,r=>{this._onprogress(r)}),this.setRequestHandler(xc,r=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(Sc,async(r,n)=>{let s=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!s)throw new Ze(Ue.InvalidParams,"Failed to retrieve task: Task not found");return{...s}}),this.setRequestHandler(Tc,async(r,n)=>{let s=async()=>{let o=r.params.taskId;if(this._taskMessageQueue){let a;for(;a=await this._taskMessageQueue.dequeue(o,n.sessionId);){if(a.type==="response"||a.type==="error"){let c=a.message,d=c.id,l=this._requestResolvers.get(d);if(l)if(this._requestResolvers.delete(d),a.type==="response")l(c);else{let u=c,h=new Ze(u.error.code,u.error.message,u.error.data);l(h)}else{let u=a.type==="response"?"Response":"Error";this._onerror(new Error(`${u} handler missing for request ${d}`))}continue}await this._transport?.send(a.message,{relatedRequestId:n.requestId})}}let i=await this._taskStore.getTask(o,n.sessionId);if(!i)throw new Ze(Ue.InvalidParams,`Task not found: ${o}`);if(!rs(i.status))return await this._waitForTaskUpdate(o,n.signal),await s();if(rs(i.status)){let a=await this._taskStore.getTaskResult(o,n.sessionId);return this._clearTaskQueue(o),{...a,_meta:{...a._meta,[ts]:{taskId:o}}}}return await s()};return await s()}),this.setRequestHandler($c,async(r,n)=>{try{let{tasks:s,nextCursor:o}=await this._taskStore.listTasks(r.params?.cursor,n.sessionId);return{tasks:s,nextCursor:o,_meta:{}}}catch(s){throw new Ze(Ue.InvalidParams,`Failed to list tasks: ${s instanceof Error?s.message:String(s)}`)}}),this.setRequestHandler(Pc,async(r,n)=>{try{let s=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!s)throw new Ze(Ue.InvalidParams,`Task not found: ${r.params.taskId}`);if(rs(s.status))throw new Ze(Ue.InvalidParams,`Cannot cancel task in terminal status: ${s.status}`);await this._taskStore.updateTaskStatus(r.params.taskId,"cancelled","Client cancelled task execution.",n.sessionId),this._clearTaskQueue(r.params.taskId);let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new Ze(Ue.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...o}}catch(s){throw s instanceof Ze?s:new Ze(Ue.InvalidRequest,`Failed to cancel task: ${s instanceof Error?s.message:String(s)}`)}}))}async _oncancel(e){if(!e.params.requestId)return;this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,r,n,s,o=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(s,r),startTime:Date.now(),timeout:r,maxTotalTimeout:n,resetTimeoutOnProgress:o,onTimeout:s})}_resetTimeout(e){let r=this._timeoutInfo.get(e);if(!r)return!1;let n=Date.now()-r.startTime;if(r.maxTotalTimeout&&n>=r.maxTotalTimeout)throw this._timeoutInfo.delete(e),Ze.fromError(Ue.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:r.maxTotalTimeout,totalElapsed:n});return clearTimeout(r.timeoutId),r.timeoutId=setTimeout(r.onTimeout,r.timeout),!0}_cleanupTimeout(e){let r=this._timeoutInfo.get(e);r&&(clearTimeout(r.timeoutId),this._timeoutInfo.delete(e))}async connect(e){if(this._transport)throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=e;let r=this.transport?.onclose;this._transport.onclose=()=>{r?.(),this._onclose()};let n=this.transport?.onerror;this._transport.onerror=o=>{n?.(o),this._onerror(o)};let s=this._transport?.onmessage;this._transport.onmessage=(o,i)=>{s?.(o,i),Di(o)||zg(o)?this._onresponse(o):Nf(o)?this._onrequest(o,i):Mg(o)?this._onnotification(o):this._onerror(new Error(`Unknown message type: ${JSON.stringify(o)}`))},await this._transport.start()}_onclose(){let e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let n of this._timeoutInfo.values())clearTimeout(n.timeoutId);this._timeoutInfo.clear();for(let n of this._requestHandlerAbortControllers.values())n.abort();this._requestHandlerAbortControllers.clear();let r=Ze.fromError(Ue.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(let n of e.values())n(r)}_onerror(e){this.onerror?.(e)}_onnotification(e){let r=this._notificationHandlers.get(e.method)??this.fallbackNotificationHandler;r!==void 0&&Promise.resolve().then(()=>r(e)).catch(n=>this._onerror(new Error(`Uncaught error in notification handler: ${n}`)))}_onrequest(e,r){let n=this._requestHandlers.get(e.method)??this.fallbackRequestHandler,s=this._transport,o=e.params?._meta?.[ts]?.taskId;if(n===void 0){let l={jsonrpc:"2.0",id:e.id,error:{code:Ue.MethodNotFound,message:"Method not found"}};o&&this._taskMessageQueue?this._enqueueTaskMessage(o,{type:"error",message:l,timestamp:Date.now()},s?.sessionId).catch(u=>this._onerror(new Error(`Failed to enqueue error response: ${u}`))):s?.send(l).catch(u=>this._onerror(new Error(`Failed to send an error response: ${u}`)));return}let i=new AbortController;this._requestHandlerAbortControllers.set(e.id,i);let a=$g(e.params)?e.params.task:void 0,c=this._taskStore?this.requestTaskStore(e,s?.sessionId):void 0,d={signal:i.signal,sessionId:s?.sessionId,_meta:e.params?._meta,sendNotification:async l=>{if(i.signal.aborted)return;let u={relatedRequestId:e.id};o&&(u.relatedTask={taskId:o}),await this.notification(l,u)},sendRequest:async(l,u,h)=>{if(i.signal.aborted)throw new Ze(Ue.ConnectionClosed,"Request was cancelled");let p={...h,relatedRequestId:e.id};o&&!p.relatedTask&&(p.relatedTask={taskId:o});let g=p.relatedTask?.taskId??o;return g&&c&&await c.updateTaskStatus(g,"input_required"),await this.request(l,u,p)},authInfo:r?.authInfo,requestId:e.id,requestInfo:r?.requestInfo,taskId:o,taskStore:c,taskRequestedTtl:a?.ttl,closeSSEStream:r?.closeSSEStream,closeStandaloneSSEStream:r?.closeStandaloneSSEStream};Promise.resolve().then(()=>{a&&this.assertTaskHandlerCapability(e.method)}).then(()=>n(e,d)).then(async l=>{if(i.signal.aborted)return;let u={result:l,jsonrpc:"2.0",id:e.id};o&&this._taskMessageQueue?await this._enqueueTaskMessage(o,{type:"response",message:u,timestamp:Date.now()},s?.sessionId):await s?.send(u)},async l=>{if(i.signal.aborted)return;let u={jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(l.code)?l.code:Ue.InternalError,message:l.message??"Internal error",...l.data!==void 0&&{data:l.data}}};o&&this._taskMessageQueue?await this._enqueueTaskMessage(o,{type:"error",message:u,timestamp:Date.now()},s?.sessionId):await s?.send(u)}).catch(l=>this._onerror(new Error(`Failed to send response: ${l}`))).finally(()=>{this._requestHandlerAbortControllers.get(e.id)===i&&this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){let{progressToken:r,...n}=e.params,s=Number(r),o=this._progressHandlers.get(s);if(!o){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let i=this._responseHandlers.get(s),a=this._timeoutInfo.get(s);if(a&&i&&a.resetTimeoutOnProgress)try{this._resetTimeout(s)}catch(c){this._responseHandlers.delete(s),this._progressHandlers.delete(s),this._cleanupTimeout(s),i(c);return}o(n)}_onresponse(e){let r=Number(e.id),n=this._requestResolvers.get(r);if(n){if(this._requestResolvers.delete(r),Di(e))n(e);else{let i=new Ze(e.error.code,e.error.message,e.error.data);n(i)}return}let s=this._responseHandlers.get(r);if(s===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(r),this._cleanupTimeout(r);let o=!1;if(Di(e)&&e.result&&typeof e.result=="object"){let i=e.result;if(i.task&&typeof i.task=="object"){let a=i.task;typeof a.taskId=="string"&&(o=!0,this._taskProgressTokens.set(a.taskId,r))}}if(o||this._progressHandlers.delete(r),Di(e))s(e);else{let i=Ze.fromError(e.error.code,e.error.message,e.error.data);s(i)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(e,r,n){let{task:s}=n??{};if(!s){try{yield{type:"result",result:await this.request(e,r,n)}}catch(i){yield{type:"error",error:i instanceof Ze?i:new Ze(Ue.InternalError,String(i))}}return}let o;try{let i=await this.request(e,Mo,n);if(i.task)o=i.task.taskId,yield{type:"taskCreated",task:i.task};else throw new Ze(Ue.InternalError,"Task creation did not return a task");for(;;){let a=await this.getTask({taskId:o},n);if(yield{type:"taskStatus",task:a},rs(a.status)){a.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:o},r,n)}:a.status==="failed"?yield{type:"error",error:new Ze(Ue.InternalError,`Task ${o} failed`)}:a.status==="cancelled"&&(yield{type:"error",error:new Ze(Ue.InternalError,`Task ${o} was cancelled`)});return}if(a.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:o},r,n)};return}let c=a.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(d=>setTimeout(d,c)),n?.signal?.throwIfAborted()}}catch(i){yield{type:"error",error:i instanceof Ze?i:new Ze(Ue.InternalError,String(i))}}}request(e,r,n){let{relatedRequestId:s,resumptionToken:o,onresumptiontoken:i,task:a,relatedTask:c}=n??{};return new Promise((d,l)=>{let u=_=>{l(_)};if(!this._transport){u(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(e.method),a&&this.assertTaskCapability(e.method)}catch(_){u(_);return}n?.signal?.throwIfAborted();let h=this._requestMessageId++,p={...e,jsonrpc:"2.0",id:h};n?.onprogress&&(this._progressHandlers.set(h,n.onprogress),p.params={...e.params,_meta:{...e.params?._meta||{},progressToken:h}}),a&&(p.params={...p.params,task:a}),c&&(p.params={...p.params,_meta:{...p.params?._meta||{},[ts]:c}});let g=_=>{this._responseHandlers.delete(h),this._progressHandlers.delete(h),this._cleanupTimeout(h),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:h,reason:String(_)}},{relatedRequestId:s,resumptionToken:o,onresumptiontoken:i}).catch($=>this._onerror(new Error(`Failed to send cancellation: ${$}`)));let m=_ instanceof Ze?_:new Ze(Ue.RequestTimeout,String(_));l(m)};this._responseHandlers.set(h,_=>{if(!n?.signal?.aborted){if(_ instanceof Error)return l(_);try{let m=Qn(r,_.result);m.success?d(m.data):l(m.error)}catch(m){l(m)}}}),n?.signal?.addEventListener("abort",()=>{g(n?.signal?.reason)});let x=n?.timeout??W6,S=()=>g(Ze.fromError(Ue.RequestTimeout,"Request timed out",{timeout:x}));this._setupTimeout(h,x,n?.maxTotalTimeout,S,n?.resetTimeoutOnProgress??!1);let k=c?.taskId;if(k){let _=m=>{let $=this._responseHandlers.get(h);$?$(m):this._onerror(new Error(`Response handler missing for side-channeled request ${h}`))};this._requestResolvers.set(h,_),this._enqueueTaskMessage(k,{type:"request",message:p,timestamp:Date.now()}).catch(m=>{this._cleanupTimeout(h),l(m)})}else this._transport.send(p,{relatedRequestId:s,resumptionToken:o,onresumptiontoken:i}).catch(_=>{this._cleanupTimeout(h),l(_)})})}async getTask(e,r){return this.request({method:"tasks/get",params:e},Ec,r)}async getTaskResult(e,r,n){return this.request({method:"tasks/result",params:e},r,n)}async listTasks(e,r){return this.request({method:"tasks/list",params:e},Rc,r)}async cancelTask(e,r){return this.request({method:"tasks/cancel",params:e},Ag,r)}async notification(e,r){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(e.method);let n=r?.relatedTask?.taskId;if(n){let a={...e,jsonrpc:"2.0",params:{...e.params,_meta:{...e.params?._meta||{},[ts]:r.relatedTask}}};await this._enqueueTaskMessage(n,{type:"notification",message:a,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(e.method)&&!e.params&&!r?.relatedRequestId&&!r?.relatedTask){if(this._pendingDebouncedNotifications.has(e.method))return;this._pendingDebouncedNotifications.add(e.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;let a={...e,jsonrpc:"2.0"};r?.relatedTask&&(a={...a,params:{...a.params,_meta:{...a.params?._meta||{},[ts]:r.relatedTask}}}),this._transport?.send(a,r).catch(c=>this._onerror(c))});return}let i={...e,jsonrpc:"2.0"};r?.relatedTask&&(i={...i,params:{...i.params,_meta:{...i.params?._meta||{},[ts]:r.relatedTask}}}),await this._transport.send(i,r)}setRequestHandler(e,r){let n=th(e);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(s,o)=>{let i=rh(e,s);return Promise.resolve(r(i,o))})}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw new Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,r){let n=th(e);this._notificationHandlers.set(n,s=>{let o=rh(e,s);return Promise.resolve(r(o))})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}_cleanupTaskProgressHandler(e){let r=this._taskProgressTokens.get(e);r!==void 0&&(this._progressHandlers.delete(r),this._taskProgressTokens.delete(e))}async _enqueueTaskMessage(e,r,n){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");let s=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(e,r,n,s)}async _clearTaskQueue(e,r){if(this._taskMessageQueue){let n=await this._taskMessageQueue.dequeueAll(e,r);for(let s of n)if(s.type==="request"&&Nf(s.message)){let o=s.message.id,i=this._requestResolvers.get(o);i?(i(new Ze(Ue.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(o)):this._onerror(new Error(`Resolver missing for request ${o} during task ${e} cleanup`))}}}async _waitForTaskUpdate(e,r){let n=this._options?.defaultTaskPollInterval??1e3;try{let s=await this._taskStore?.getTask(e);s?.pollInterval&&(n=s.pollInterval)}catch{}return new Promise((s,o)=>{if(r.aborted){o(new Ze(Ue.InvalidRequest,"Request cancelled"));return}let i=setTimeout(s,n);r.addEventListener("abort",()=>{clearTimeout(i),o(new Ze(Ue.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(e,r){let n=this._taskStore;if(!n)throw new Error("No task store configured");return{createTask:async s=>{if(!e)throw new Error("No request provided");return await n.createTask(s,e.id,{method:e.method,params:e.params},r)},getTask:async s=>{let o=await n.getTask(s,r);if(!o)throw new Ze(Ue.InvalidParams,"Failed to retrieve task: Task not found");return o},storeTaskResult:async(s,o,i)=>{await n.storeTaskResult(s,o,i,r);let a=await n.getTask(s,r);if(a){let c=Vi.parse({method:"notifications/tasks/status",params:a});await this.notification(c),rs(a.status)&&this._cleanupTaskProgressHandler(s)}},getTaskResult:s=>n.getTaskResult(s,r),updateTaskStatus:async(s,o,i)=>{let a=await n.getTask(s,r);if(!a)throw new Ze(Ue.InvalidParams,`Task "${s}" not found - it may have been cleaned up`);if(rs(a.status))throw new Ze(Ue.InvalidParams,`Cannot update task "${s}" from terminal status "${a.status}" to "${o}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await n.updateTaskStatus(s,o,i,r);let c=await n.getTask(s,r);if(c){let d=Vi.parse({method:"notifications/tasks/status",params:c});await this.notification(d),rs(c.status)&&this._cleanupTaskProgressHandler(s)}},listTasks:s=>n.listTasks(s,r)}}};function v_(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function w_(t,e){let r={...t};for(let n in e){let s=n,o=e[s];if(o===void 0)continue;let i=r[s];v_(i)&&v_(o)?r[s]={...i,...o}:r[s]=o}return r}var fy=T1(qp(),1),hy=T1(dy(),1);function QT(){let t=new fy.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,hy.default)(t),t}var kl=class{constructor(e){this._ajv=e??QT()}getValidator(e){let r="$id"in e&&typeof e.$id=="string"?this._ajv.getSchema(e.$id)??this._ajv.compile(e):this._ajv.compile(e);return n=>r(n)?{valid:!0,data:n,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(r.errors)}}};var Sl=class{constructor(e){this._server=e}requestStream(e,r,n){return this._server.requestStream(e,r,n)}createMessageStream(e,r){let n=this._server.getClientCapabilities();if((e.tools||e.toolChoice)&&!n?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(e.messages.length>0){let s=e.messages[e.messages.length-1],o=Array.isArray(s.content)?s.content:[s.content],i=o.some(l=>l.type==="tool_result"),a=e.messages.length>1?e.messages[e.messages.length-2]:void 0,c=a?Array.isArray(a.content)?a.content:[a.content]:[],d=c.some(l=>l.type==="tool_use");if(i){if(o.some(l=>l.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!d)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(d){let l=new Set(c.filter(h=>h.type==="tool_use").map(h=>h.id)),u=new Set(o.filter(h=>h.type==="tool_result").map(h=>h.toolUseId));if(l.size!==u.size||![...l].every(h=>u.has(h)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return this.requestStream({method:"sampling/createMessage",params:e},Ui,r)}elicitInputStream(e,r){let n=this._server.getClientCapabilities(),s=e.mode??"form";switch(s){case"url":{if(!n?.elicitation?.url)throw new Error("Client does not support url elicitation.");break}case"form":{if(!n?.elicitation?.form)throw new Error("Client does not support form elicitation.");break}}let o=s==="form"&&e.mode===void 0?{...e,mode:"form"}:e;return this.requestStream({method:"elicitation/create",params:o},Oo,r)}async getTask(e,r){return this._server.getTask({taskId:e},r)}async getTaskResult(e,r,n){return this._server.getTaskResult({taskId:e},r,n)}async listTasks(e,r){return this._server.listTasks(e?{cursor:e}:void 0,r)}async cancelTask(e,r){return this._server.cancelTask({taskId:e},r)}};function py(t,e,r){if(!t)throw new Error(`${r} does not support task creation (required for ${e})`);switch(e){case"tools/call":if(!t.tools?.call)throw new Error(`${r} does not support task creation for tools/call (required for ${e})`);break;default:break}}function my(t,e,r){if(!t)throw new Error(`${r} does not support task creation (required for ${e})`);switch(e){case"sampling/createMessage":if(!t.sampling?.createMessage)throw new Error(`${r} does not support task creation for sampling/createMessage (required for ${e})`);break;case"elicitation/create":if(!t.elicitation?.create)throw new Error(`${r} does not support task creation for elicitation/create (required for ${e})`);break;default:break}}var El=class extends qc{constructor(e,r){super(r),this._serverInfo=e,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(Hi.options.map((n,s)=>[n,s])),this.isMessageIgnored=(n,s)=>{let o=this._loggingLevels.get(s);return o?this.LOG_LEVEL_SEVERITY.get(n)<this.LOG_LEVEL_SEVERITY.get(o):!1},this._capabilities=r?.capabilities??{},this._instructions=r?.instructions,this._jsonSchemaValidator=r?.jsonSchemaValidator??new kl,this.setRequestHandler(Df,n=>this._oninitialize(n)),this.setNotificationHandler(Lf,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(Uf,async(n,s)=>{let o=s.sessionId||s.requestInfo?.headers["mcp-session-id"]||void 0,{level:i}=n.params,a=Hi.safeParse(i);return a.success&&this._loggingLevels.set(o,a.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new Sl(this)}),this._experimental}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=w_(this._capabilities,e)}setRequestHandler(e,r){let s=es(e)?.method;if(!s)throw new Error("Schema is missing a method literal");let o;if(Gr(s)){let a=s;o=a._zod?.def?.value??a.value}else{let a=s;o=a._def?.value??a.value}if(typeof o!="string")throw new Error("Schema method literal must be a string");if(o==="tools/call"){let a=async(c,d)=>{let l=Qn(Io,c);if(!l.success){let g=l.error instanceof Error?l.error.message:String(l.error);throw new Ze(Ue.InvalidParams,`Invalid tools/call request: ${g}`)}let{params:u}=l.data,h=await Promise.resolve(r(c,d));if(u.task){let g=Qn(Mo,h);if(!g.success){let x=g.error instanceof Error?g.error.message:String(g.error);throw new Ze(Ue.InvalidParams,`Invalid task creation result: ${x}`)}return g.data}let p=Qn(Cc,h);if(!p.success){let g=p.error instanceof Error?p.error.message:String(p.error);throw new Ze(Ue.InvalidParams,`Invalid tools/call result: ${g}`)}return p.data};return super.setRequestHandler(e,a)}return super.setRequestHandler(e,r)}assertCapabilityForMethod(e){switch(e){case"sampling/createMessage":if(!this._clientCapabilities?.sampling)throw new Error(`Client does not support sampling (required for ${e})`);break;case"elicitation/create":if(!this._clientCapabilities?.elicitation)throw new Error(`Client does not support elicitation (required for ${e})`);break;case"roots/list":if(!this._clientCapabilities?.roots)throw new Error(`Client does not support listing roots (required for ${e})`);break;case"ping":break}}assertNotificationCapability(e){switch(e){case"notifications/message":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${e})`);break;case"notifications/resources/updated":case"notifications/resources/list_changed":if(!this._capabilities.resources)throw new Error(`Server does not support notifying about resources (required for ${e})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw new Error(`Server does not support notifying of tool list changes (required for ${e})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw new Error(`Server does not support notifying of prompt list changes (required for ${e})`);break;case"notifications/elicitation/complete":if(!this._clientCapabilities?.elicitation?.url)throw new Error(`Client does not support URL elicitation (required for ${e})`);break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(e){if(this._capabilities)switch(e){case"completion/complete":if(!this._capabilities.completions)throw new Error(`Server does not support completions (required for ${e})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw new Error(`Server does not support prompts (required for ${e})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw new Error(`Server does not support resources (required for ${e})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw new Error(`Server does not support tools (required for ${e})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw new Error(`Server does not support tasks capability (required for ${e})`);break;case"ping":case"initialize":break}}assertTaskCapability(e){my(this._clientCapabilities?.tasks?.requests,e,"Client")}assertTaskHandlerCapability(e){this._capabilities&&py(this._capabilities.tasks?.requests,e,"Server")}async _oninitialize(e){let r=e.params.protocolVersion;return this._clientCapabilities=e.params.capabilities,this._clientVersion=e.params.clientInfo,{protocolVersion:Sg.includes(r)?r:Of,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}getClientCapabilities(){return this._clientCapabilities}getClientVersion(){return this._clientVersion}getCapabilities(){return this._capabilities}async ping(){return this.request({method:"ping"},vc)}async createMessage(e,r){if((e.tools||e.toolChoice)&&!this._clientCapabilities?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(e.messages.length>0){let n=e.messages[e.messages.length-1],s=Array.isArray(n.content)?n.content:[n.content],o=s.some(d=>d.type==="tool_result"),i=e.messages.length>1?e.messages[e.messages.length-2]:void 0,a=i?Array.isArray(i.content)?i.content:[i.content]:[],c=a.some(d=>d.type==="tool_use");if(o){if(s.some(d=>d.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!c)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(c){let d=new Set(a.filter(u=>u.type==="tool_use").map(u=>u.id)),l=new Set(s.filter(u=>u.type==="tool_result").map(u=>u.toolUseId));if(d.size!==l.size||![...d].every(u=>l.has(u)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return e.tools?this.request({method:"sampling/createMessage",params:e},Gf,r):this.request({method:"sampling/createMessage",params:e},Ui,r)}async elicitInput(e,r){switch(e.mode??"form"){case"url":{if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support url elicitation.");let s=e;return this.request({method:"elicitation/create",params:s},Oo,r)}case"form":{if(!this._clientCapabilities?.elicitation?.form)throw new Error("Client does not support form elicitation.");let s=e.mode==="form"?e:{...e,mode:"form"},o=await this.request({method:"elicitation/create",params:s},Oo,r);if(o.action==="accept"&&o.content&&s.requestedSchema)try{let a=this._jsonSchemaValidator.getValidator(s.requestedSchema)(o.content);if(!a.valid)throw new Ze(Ue.InvalidParams,`Elicitation response content does not match requested schema: ${a.errorMessage}`)}catch(i){throw i instanceof Ze?i:new Ze(Ue.InternalError,`Error validating elicitation response: ${i instanceof Error?i.message:String(i)}`)}return o}}}createElicitationCompletionNotifier(e,r){if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support URL elicitation (required for notifications/elicitation/complete)");return()=>this.notification({method:"notifications/elicitation/complete",params:{elicitationId:e}},r)}async listRoots(e,r){return this.request({method:"roots/list",params:e},Yf,r)}async sendLoggingMessage(e,r){if(this._capabilities.logging&&!this.isMessageIgnored(e.level,r))return this.notification({method:"notifications/message",params:e})}async sendResourceUpdated(e){return this.notification({method:"notifications/resources/updated",params:e})}async sendResourceListChanged(){return this.notification({method:"notifications/resources/list_changed"})}async sendToolListChanged(){return this.notification({method:"notifications/tools/list_changed"})}async sendPromptListChanged(){return this.notification({method:"notifications/prompts/list_changed"})}};var _y=Symbol.for("mcp.completable");function Wp(t){return!!t&&typeof t=="object"&&_y in t}function by(t){return t[_y]?.complete}var gy;(function(t){t.Completable="McpCompletable"})(gy||(gy={}));var Tl=class t{static isTemplate(e){return/\{[^}\s]+\}/.test(e)}static validateLength(e,r,n){if(e.length>r)throw new Error(`${n} exceeds maximum length of ${r} characters (got ${e.length})`)}get variableNames(){return this.parts.flatMap(e=>typeof e=="string"?[]:e.names)}constructor(e){t.validateLength(e,1e6,"Template"),this.template=e,this.parts=this.parse(e)}toString(){return this.template}parse(e){let r=[],n="",s=0,o=0;for(;s<e.length;)if(e[s]==="{"){n&&(r.push(n),n="");let i=e.indexOf("}",s);if(i===-1)throw new Error("Unclosed template expression");if(o++,o>1e4)throw new Error("Template contains too many expressions (max 10000)");let a=e.slice(s+1,i),c=this.getOperator(a),d=a.includes("*"),l=this.getNames(a),u=l[0];for(let h of l)t.validateLength(h,1e6,"Variable name");r.push({name:u,operator:c,names:l,exploded:d}),s=i+1}else n+=e[s],s++;return n&&r.push(n),r}getOperator(e){return["+","#",".","/","?","&"].find(n=>e.startsWith(n))||""}getNames(e){let r=this.getOperator(e);return e.slice(r.length).split(",").map(n=>n.replace("*","").trim()).filter(n=>n.length>0)}encodeValue(e,r){return t.validateLength(e,1e6,"Variable value"),r==="+"||r==="#"?encodeURI(e):encodeURIComponent(e)}expandPart(e,r){if(e.operator==="?"||e.operator==="&"){let i=e.names.map(c=>{let d=r[c];if(d===void 0)return"";let l=Array.isArray(d)?d.map(u=>this.encodeValue(u,e.operator)).join(","):this.encodeValue(d.toString(),e.operator);return`${c}=${l}`}).filter(c=>c.length>0);return i.length===0?"":(e.operator==="?"?"?":"&")+i.join("&")}if(e.names.length>1){let i=e.names.map(a=>r[a]).filter(a=>a!==void 0);return i.length===0?"":i.map(a=>Array.isArray(a)?a[0]:a).join(",")}let n=r[e.name];if(n===void 0)return"";let o=(Array.isArray(n)?n:[n]).map(i=>this.encodeValue(i,e.operator));switch(e.operator){case"":return o.join(",");case"+":return o.join(",");case"#":return"#"+o.join(",");case".":return"."+o.join(".");case"/":return"/"+o.join("/");default:return o.join(",")}}expand(e){let r="",n=!1;for(let s of this.parts){if(typeof s=="string"){r+=s;continue}let o=this.expandPart(s,e);o&&((s.operator==="?"||s.operator==="&")&&n?r+=o.replace("?","&"):r+=o,(s.operator==="?"||s.operator==="&")&&(n=!0))}return r}escapeRegExp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}partToRegExp(e){let r=[];for(let o of e.names)t.validateLength(o,1e6,"Variable name");if(e.operator==="?"||e.operator==="&"){for(let o=0;o<e.names.length;o++){let i=e.names[o],a=o===0?"\\"+e.operator:"&";r.push({pattern:a+this.escapeRegExp(i)+"=([^&]+)",name:i})}return r}let n,s=e.name;switch(e.operator){case"":n=e.exploded?"([^/,]+(?:,[^/,]+)*)":"([^/,]+)";break;case"+":case"#":n="(.+)";break;case".":n="\\.([^/,]+)";break;case"/":n="/"+(e.exploded?"([^/,]+(?:,[^/,]+)*)":"([^/,]+)");break;default:n="([^/]+)"}return r.push({pattern:n,name:s}),r}match(e){t.validateLength(e,1e6,"URI");let r="^",n=[];for(let a of this.parts)if(typeof a=="string")r+=this.escapeRegExp(a);else{let c=this.partToRegExp(a);for(let{pattern:d,name:l}of c)r+=d,n.push({name:l,exploded:a.exploded})}r+="$",t.validateLength(r,1e6,"Generated regex pattern");let s=new RegExp(r),o=e.match(s);if(!o)return null;let i={};for(let a=0;a<n.length;a++){let{name:c,exploded:d}=n[a],l=o[a+1],u=c.replace("*","");d&&l.includes(",")?i[u]=l.split(","):i[u]=l}return i}};var e$=/^[A-Za-z0-9._-]{1,128}$/;function t$(t){let e=[];if(t.length===0)return{isValid:!1,warnings:["Tool name cannot be empty"]};if(t.length>128)return{isValid:!1,warnings:[`Tool name exceeds maximum length of 128 characters (current: ${t.length})`]};if(t.includes(" ")&&e.push("Tool name contains spaces, which may cause parsing issues"),t.includes(",")&&e.push("Tool name contains commas, which may cause parsing issues"),(t.startsWith("-")||t.endsWith("-"))&&e.push("Tool name starts or ends with a dash, which may cause parsing issues in some contexts"),(t.startsWith(".")||t.endsWith("."))&&e.push("Tool name starts or ends with a dot, which may cause parsing issues in some contexts"),!e$.test(t)){let r=t.split("").filter(n=>!/[A-Za-z0-9._-]/.test(n)).filter((n,s,o)=>o.indexOf(n)===s);return e.push(`Tool name contains invalid characters: ${r.map(n=>`"${n}"`).join(", ")}`,"Allowed characters are: A-Z, a-z, 0-9, underscore (_), dash (-), and dot (.)"),{isValid:!1,warnings:e}}return{isValid:!0,warnings:e}}function r$(t,e){if(e.length>0){console.warn(`Tool name validation warning for "${t}":`);for(let r of e)console.warn(` - ${r}`);console.warn("Tool registration will proceed, but this may cause compatibility issues."),console.warn("Consider updating the tool name to conform to the MCP tool naming standard."),console.warn("See SEP: Specify Format for Tool Names (https://github.com/modelcontextprotocol/modelcontextprotocol/issues/986) for more details.")}}function Kp(t){let e=t$(t);return r$(t,e.warnings),e.isValid}var $l=class{constructor(e){this._mcpServer=e}registerToolTask(e,r,n){let s={taskSupport:"required",...r.execution};if(s.taskSupport==="forbidden")throw new Error(`Cannot register task-based tool '${e}' with taskSupport 'forbidden'. Use registerTool() instead.`);return this._mcpServer._createRegisteredTool(e,r.title,r.description,r.inputSchema,r.outputSchema,r.annotations,s,r._meta,n)}};var Rl=class{constructor(e,r){this._registeredResources={},this._registeredResourceTemplates={},this._registeredTools={},this._registeredPrompts={},this._toolHandlersInitialized=!1,this._completionHandlerInitialized=!1,this._resourceHandlersInitialized=!1,this._promptHandlersInitialized=!1,this.server=new El(e,r)}get experimental(){return this._experimental||(this._experimental={tasks:new $l(this)}),this._experimental}async connect(e){return await this.server.connect(e)}async close(){await this.server.close()}setToolRequestHandlers(){this._toolHandlersInitialized||(this.server.assertCanSetRequestHandler(ds(Nc)),this.server.assertCanSetRequestHandler(ds(Io)),this.server.registerCapabilities({tools:{listChanged:!0}}),this.server.setRequestHandler(Nc,()=>({tools:Object.entries(this._registeredTools).filter(([,e])=>e.enabled).map(([e,r])=>{let n={name:e,title:r.title,description:r.description,inputSchema:(()=>{let s=Ro(r.inputSchema);return s?eh(s,{strictUnions:!0,pipeStrategy:"input"}):n$})(),annotations:r.annotations,execution:r.execution,_meta:r._meta};if(r.outputSchema){let s=Ro(r.outputSchema);s&&(n.outputSchema=eh(s,{strictUnions:!0,pipeStrategy:"output"}))}return n})})),this.server.setRequestHandler(Io,async(e,r)=>{try{let n=this._registeredTools[e.params.name];if(!n)throw new Ze(Ue.InvalidParams,`Tool ${e.params.name} not found`);if(!n.enabled)throw new Ze(Ue.InvalidParams,`Tool ${e.params.name} disabled`);let s=!!e.params.task,o=n.execution?.taskSupport,i="createTask"in n.handler;if((o==="required"||o==="optional")&&!i)throw new Ze(Ue.InternalError,`Tool ${e.params.name} has taskSupport '${o}' but was not registered with registerToolTask`);if(o==="required"&&!s)throw new Ze(Ue.MethodNotFound,`Tool ${e.params.name} requires task augmentation (taskSupport: 'required')`);if(o==="optional"&&!s&&i)return await this.handleAutomaticTaskPolling(n,e,r);let a=await this.validateToolInput(n,e.params.arguments,e.params.name),c=await this.executeToolHandler(n,a,r);return s||await this.validateToolOutput(n,c,e.params.name),c}catch(n){if(n instanceof Ze&&n.code===Ue.UrlElicitationRequired)throw n;return this.createToolError(n instanceof Error?n.message:String(n))}}),this._toolHandlersInitialized=!0)}createToolError(e){return{content:[{type:"text",text:e}],isError:!0}}async validateToolInput(e,r,n){if(!e.inputSchema)return;let o=Ro(e.inputSchema)??e.inputSchema,i=await fc(o,r);if(!i.success){let a="error"in i?i.error:"Unknown error",c=hc(a);throw new Ze(Ue.InvalidParams,`Input validation error: Invalid arguments for tool ${n}: ${c}`)}return i.data}async validateToolOutput(e,r,n){if(!e.outputSchema||!("content"in r)||r.isError)return;if(!r.structuredContent)throw new Ze(Ue.InvalidParams,`Output validation error: Tool ${n} has an output schema but no structured content was provided`);let s=Ro(e.outputSchema),o=await fc(s,r.structuredContent);if(!o.success){let i="error"in o?o.error:"Unknown error",a=hc(i);throw new Ze(Ue.InvalidParams,`Output validation error: Invalid structured content for tool ${n}: ${a}`)}}async executeToolHandler(e,r,n){let s=e.handler;if("createTask"in s){if(!n.taskStore)throw new Error("No task store provided.");let i={...n,taskStore:n.taskStore};if(e.inputSchema){let a=s;return await Promise.resolve(a.createTask(r,i))}else{let a=s;return await Promise.resolve(a.createTask(i))}}if(e.inputSchema){let i=s;return await Promise.resolve(i(r,n))}else{let i=s;return await Promise.resolve(i(n))}}async handleAutomaticTaskPolling(e,r,n){if(!n.taskStore)throw new Error("No task store provided for task-capable tool.");let s=await this.validateToolInput(e,r.params.arguments,r.params.name),o=e.handler,i={...n,taskStore:n.taskStore},a=s?await Promise.resolve(o.createTask(s,i)):await Promise.resolve(o.createTask(i)),c=a.task.taskId,d=a.task,l=d.pollInterval??5e3;for(;d.status!=="completed"&&d.status!=="failed"&&d.status!=="cancelled";){await new Promise(h=>setTimeout(h,l));let u=await n.taskStore.getTask(c);if(!u)throw new Ze(Ue.InternalError,`Task ${c} not found during polling`);d=u}return await n.taskStore.getTaskResult(c)}setCompletionRequestHandler(){this._completionHandlerInitialized||(this.server.assertCanSetRequestHandler(ds(jc)),this.server.registerCapabilities({completions:{}}),this.server.setRequestHandler(jc,async e=>{switch(e.params.ref.type){case"ref/prompt":return Zg(e),this.handlePromptCompletion(e,e.params.ref);case"ref/resource":return Bg(e),this.handleResourceCompletion(e,e.params.ref);default:throw new Ze(Ue.InvalidParams,`Invalid completion reference: ${e.params.ref}`)}}),this._completionHandlerInitialized=!0)}async handlePromptCompletion(e,r){let n=this._registeredPrompts[r.name];if(!n)throw new Ze(Ue.InvalidParams,`Prompt ${r.name} not found`);if(!n.enabled)throw new Ze(Ue.InvalidParams,`Prompt ${r.name} disabled`);if(!n.argsSchema)return ka;let o=es(n.argsSchema)?.[e.params.argument.name];if(!Wp(o))return ka;let i=by(o);if(!i)return ka;let a=await i(e.params.argument.value,e.params.context);return vy(a)}async handleResourceCompletion(e,r){let n=Object.values(this._registeredResourceTemplates).find(i=>i.resourceTemplate.uriTemplate.toString()===r.uri);if(!n){if(this._registeredResources[r.uri])return ka;throw new Ze(Ue.InvalidParams,`Resource template ${e.params.ref.uri} not found`)}let s=n.resourceTemplate.completeCallback(e.params.argument.name);if(!s)return ka;let o=await s(e.params.argument.value,e.params.context);return vy(o)}setResourceRequestHandlers(){this._resourceHandlersInitialized||(this.server.assertCanSetRequestHandler(ds(Mc)),this.server.assertCanSetRequestHandler(ds(zc)),this.server.assertCanSetRequestHandler(ds(Ic)),this.server.registerCapabilities({resources:{listChanged:!0}}),this.server.setRequestHandler(Mc,async(e,r)=>{let n=Object.entries(this._registeredResources).filter(([o,i])=>i.enabled).map(([o,i])=>({uri:o,name:i.name,...i.metadata})),s=[];for(let o of Object.values(this._registeredResourceTemplates)){if(!o.resourceTemplate.listCallback)continue;let i=await o.resourceTemplate.listCallback(r);for(let a of i.resources)s.push({...o.metadata,...a})}return{resources:[...n,...s]}}),this.server.setRequestHandler(zc,async()=>({resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([r,n])=>({name:r,uriTemplate:n.resourceTemplate.uriTemplate.toString(),...n.metadata}))})),this.server.setRequestHandler(Ic,async(e,r)=>{let n=new URL(e.params.uri),s=this._registeredResources[n.toString()];if(s){if(!s.enabled)throw new Ze(Ue.InvalidParams,`Resource ${n} disabled`);return s.readCallback(n,r)}for(let o of Object.values(this._registeredResourceTemplates)){let i=o.resourceTemplate.uriTemplate.match(n.toString());if(i)return o.readCallback(n,i,r)}throw new Ze(Ue.InvalidParams,`Resource ${n} not found`)}),this._resourceHandlersInitialized=!0)}setPromptRequestHandlers(){this._promptHandlersInitialized||(this.server.assertCanSetRequestHandler(ds(Oc)),this.server.assertCanSetRequestHandler(ds(Ac)),this.server.registerCapabilities({prompts:{listChanged:!0}}),this.server.setRequestHandler(Oc,()=>({prompts:Object.entries(this._registeredPrompts).filter(([,e])=>e.enabled).map(([e,r])=>({name:e,title:r.title,description:r.description,arguments:r.argsSchema?s$(r.argsSchema):void 0}))})),this.server.setRequestHandler(Ac,async(e,r)=>{let n=this._registeredPrompts[e.params.name];if(!n)throw new Ze(Ue.InvalidParams,`Prompt ${e.params.name} not found`);if(!n.enabled)throw new Ze(Ue.InvalidParams,`Prompt ${e.params.name} disabled`);if(n.argsSchema){let s=Ro(n.argsSchema),o=await fc(s,e.params.arguments);if(!o.success){let c="error"in o?o.error:"Unknown error",d=hc(c);throw new Ze(Ue.InvalidParams,`Invalid arguments for prompt ${e.params.name}: ${d}`)}let i=o.data,a=n.callback;return await Promise.resolve(a(i,r))}else{let s=n.callback;return await Promise.resolve(s(r))}}),this._promptHandlersInitialized=!0)}resource(e,r,...n){let s;typeof n[0]=="object"&&(s=n.shift());let o=n[0];if(typeof r=="string"){if(this._registeredResources[r])throw new Error(`Resource ${r} is already registered`);let i=this._createRegisteredResource(e,void 0,r,s,o);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),i}else{if(this._registeredResourceTemplates[e])throw new Error(`Resource template ${e} is already registered`);let i=this._createRegisteredResourceTemplate(e,void 0,r,s,o);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),i}}registerResource(e,r,n,s){if(typeof r=="string"){if(this._registeredResources[r])throw new Error(`Resource ${r} is already registered`);let o=this._createRegisteredResource(e,n.title,r,n,s);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),o}else{if(this._registeredResourceTemplates[e])throw new Error(`Resource template ${e} is already registered`);let o=this._createRegisteredResourceTemplate(e,n.title,r,n,s);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),o}}_createRegisteredResource(e,r,n,s,o){let i={name:e,title:r,metadata:s,readCallback:o,enabled:!0,disable:()=>i.update({enabled:!1}),enable:()=>i.update({enabled:!0}),remove:()=>i.update({uri:null}),update:a=>{typeof a.uri<"u"&&a.uri!==n&&(delete this._registeredResources[n],a.uri&&(this._registeredResources[a.uri]=i)),typeof a.name<"u"&&(i.name=a.name),typeof a.title<"u"&&(i.title=a.title),typeof a.metadata<"u"&&(i.metadata=a.metadata),typeof a.callback<"u"&&(i.readCallback=a.callback),typeof a.enabled<"u"&&(i.enabled=a.enabled),this.sendResourceListChanged()}};return this._registeredResources[n]=i,i}_createRegisteredResourceTemplate(e,r,n,s,o){let i={resourceTemplate:n,title:r,metadata:s,readCallback:o,enabled:!0,disable:()=>i.update({enabled:!1}),enable:()=>i.update({enabled:!0}),remove:()=>i.update({name:null}),update:d=>{typeof d.name<"u"&&d.name!==e&&(delete this._registeredResourceTemplates[e],d.name&&(this._registeredResourceTemplates[d.name]=i)),typeof d.title<"u"&&(i.title=d.title),typeof d.template<"u"&&(i.resourceTemplate=d.template),typeof d.metadata<"u"&&(i.metadata=d.metadata),typeof d.callback<"u"&&(i.readCallback=d.callback),typeof d.enabled<"u"&&(i.enabled=d.enabled),this.sendResourceListChanged()}};this._registeredResourceTemplates[e]=i;let a=n.uriTemplate.variableNames;return Array.isArray(a)&&a.some(d=>!!n.completeCallback(d))&&this.setCompletionRequestHandler(),i}_createRegisteredPrompt(e,r,n,s,o){let i={title:r,description:n,argsSchema:s===void 0?void 0:Fs(s),callback:o,enabled:!0,disable:()=>i.update({enabled:!1}),enable:()=>i.update({enabled:!0}),remove:()=>i.update({name:null}),update:a=>{typeof a.name<"u"&&a.name!==e&&(delete this._registeredPrompts[e],a.name&&(this._registeredPrompts[a.name]=i)),typeof a.title<"u"&&(i.title=a.title),typeof a.description<"u"&&(i.description=a.description),typeof a.argsSchema<"u"&&(i.argsSchema=Fs(a.argsSchema)),typeof a.callback<"u"&&(i.callback=a.callback),typeof a.enabled<"u"&&(i.enabled=a.enabled),this.sendPromptListChanged()}};return this._registeredPrompts[e]=i,s&&Object.values(s).some(c=>{let d=c instanceof xr?c._def?.innerType:c;return Wp(d)})&&this.setCompletionRequestHandler(),i}_createRegisteredTool(e,r,n,s,o,i,a,c,d){Kp(e);let l={title:r,description:n,inputSchema:yy(s),outputSchema:yy(o),annotations:i,execution:a,_meta:c,handler:d,enabled:!0,disable:()=>l.update({enabled:!1}),enable:()=>l.update({enabled:!0}),remove:()=>l.update({name:null}),update:u=>{typeof u.name<"u"&&u.name!==e&&(typeof u.name=="string"&&Kp(u.name),delete this._registeredTools[e],u.name&&(this._registeredTools[u.name]=l)),typeof u.title<"u"&&(l.title=u.title),typeof u.description<"u"&&(l.description=u.description),typeof u.paramsSchema<"u"&&(l.inputSchema=Fs(u.paramsSchema)),typeof u.outputSchema<"u"&&(l.outputSchema=Fs(u.outputSchema)),typeof u.callback<"u"&&(l.handler=u.callback),typeof u.annotations<"u"&&(l.annotations=u.annotations),typeof u._meta<"u"&&(l._meta=u._meta),typeof u.enabled<"u"&&(l.enabled=u.enabled),this.sendToolListChanged()}};return this._registeredTools[e]=l,this.setToolRequestHandlers(),this.sendToolListChanged(),l}tool(e,...r){if(this._registeredTools[e])throw new Error(`Tool ${e} is already registered`);let n,s,o,i;if(typeof r[0]=="string"&&(n=r.shift()),r.length>1){let c=r[0];if(Jp(c))s=r.shift(),r.length>1&&typeof r[0]=="object"&&r[0]!==null&&!Jp(r[0])&&(i=r.shift());else if(typeof c=="object"&&c!==null){if(Object.values(c).some(d=>typeof d=="object"&&d!==null))throw new Error(`Tool ${e} expected a Zod schema or ToolAnnotations, but received an unrecognized object`);i=r.shift()}}let a=r[0];return this._createRegisteredTool(e,void 0,n,s,o,i,{taskSupport:"forbidden"},void 0,a)}registerTool(e,r,n){if(this._registeredTools[e])throw new Error(`Tool ${e} is already registered`);let{title:s,description:o,inputSchema:i,outputSchema:a,annotations:c,_meta:d}=r;return this._createRegisteredTool(e,s,o,i,a,c,{taskSupport:"forbidden"},d,n)}prompt(e,...r){if(this._registeredPrompts[e])throw new Error(`Prompt ${e} is already registered`);let n;typeof r[0]=="string"&&(n=r.shift());let s;r.length>1&&(s=r.shift());let o=r[0],i=this._createRegisteredPrompt(e,void 0,n,s,o);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),i}registerPrompt(e,r,n){if(this._registeredPrompts[e])throw new Error(`Prompt ${e} is already registered`);let{title:s,description:o,argsSchema:i}=r,a=this._createRegisteredPrompt(e,s,o,i,n);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),a}isConnected(){return this.server.transport!==void 0}async sendLoggingMessage(e,r){return this.server.sendLoggingMessage(e,r)}sendResourceListChanged(){this.isConnected()&&this.server.sendResourceListChanged()}sendToolListChanged(){this.isConnected()&&this.server.sendToolListChanged()}sendPromptListChanged(){this.isConnected()&&this.server.sendPromptListChanged()}},Pl=class{constructor(e,r){this._callbacks=r,this._uriTemplate=typeof e=="string"?new Tl(e):e}get uriTemplate(){return this._uriTemplate}get listCallback(){return this._callbacks.list}completeCallback(e){return this._callbacks.complete?.[e]}},n$={type:"object",properties:{}};function wy(t){return t!==null&&typeof t=="object"&&"parse"in t&&typeof t.parse=="function"&&"safeParse"in t&&typeof t.safeParse=="function"}function xy(t){return"_def"in t||"_zod"in t||wy(t)}function Jp(t){return typeof t!="object"||t===null||xy(t)?!1:Object.keys(t).length===0?!0:Object.values(t).some(wy)}function yy(t){if(t){if(Jp(t))return Fs(t);if(!xy(t))throw new Error("inputSchema must be a Zod schema or raw shape, received an unrecognized object");return t}}function s$(t){let e=es(t);return e?Object.entries(e).map(([r,n])=>{let s=eg(n),o=tg(n);return{name:r,description:s,required:!o}}):[]}function ds(t){let r=es(t)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=pc(r);if(typeof n=="string")return n;throw new Error("Schema method literal must be a string")}function vy(t){return{completion:{values:t.slice(0,100),total:t.length,hasMore:t.length>100}}}var ka={completion:{values:[],hasMore:!1}};import Sy from"node:process";var Ml=class{append(e){this._buffer=this._buffer?Buffer.concat([this._buffer,e]):e}readMessage(){if(!this._buffer)return null;let e=this._buffer.indexOf(`
|
|
41
|
+
`);if(e===-1)return null;let r=this._buffer.toString("utf8",0,e).replace(/\r$/,"");return this._buffer=this._buffer.subarray(e+1),o$(r)}clear(){this._buffer=void 0}};function o$(t){return Ig.parse(JSON.parse(t))}function ky(t){return JSON.stringify(t)+`
|
|
42
|
+
`}var zl=class{constructor(e=Sy.stdin,r=Sy.stdout){this._stdin=e,this._stdout=r,this._readBuffer=new Ml,this._started=!1,this._ondata=n=>{this._readBuffer.append(n),this.processReadBuffer()},this._onerror=n=>{this.onerror?.(n)}}async start(){if(this._started)throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){for(;;)try{let e=this._readBuffer.readMessage();if(e===null)break;this.onmessage?.(e)}catch(e){this.onerror?.(e)}}async close(){this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0&&this._stdin.pause(),this._readBuffer.clear(),this.onclose?.()}send(e){return new Promise(r=>{let n=ky(e);this._stdout.write(n)?r():this._stdout.once("drain",r)})}};import{accessSync as kO,constants as SO,writeFileSync as EO,mkdirSync as L3}from"node:fs";import{fileURLToPath as TO,pathToFileURL as Z3}from"node:url";import{tmpdir as j3}from"node:os";import{createServer as $O}from"node:http";import*as Jt from"node:path";var Lr=["alloy","ash","ballad","coral","echo","fable","marin","nova","onyx","sage","shimmer","verse","cedar"],i$="cedar",fs={alloy:"neutral, balanced",ash:"warm, expressive",ballad:"soft, mellow",coral:"bright, friendly",echo:"calm, measured",fable:"storytelling, animated",marin:"natural, conversational",nova:"energetic, upbeat",onyx:"deep, authoritative",sage:"steady, thoughtful",shimmer:"light, gentle",verse:"lively, dynamic",cedar:"warm, natural (default)"};function Ey(t){return t&&Lr.includes(t)?t:i$}var a$="TTS voice to narrate with \u2014 pick the one that best fits the topic/audience. Defaults to cedar (warm, natural). Options: "+Lr.map(t=>`${t} (${fs[t]})`).join(", ")+".",c$=G.object({find:G.string().min(1).describe('An EXACT snippet that currently exists in the file, used to anchor the change. Use the SMALLEST text that is unique in the file (whitespace must match exactly). To INSERT, keep the anchor in both sides, e.g. find "return x" \u2192 replace "// note\\nreturn x". To DELETE, set replace to "".'),replace:G.string().describe("What `find` becomes. Only its changed region types out \u2014 not the whole file."),occurrence:G.number().int().positive().optional().describe("1-based index of WHICH occurrence of `find` to target when it appears more than once. Required if `find` is not unique; defaults to 1.")}),l$=G.object({say:G.string().optional().describe('Narration for this step \u2014 ONE SHORT BEAT: a single idea, roughly 4\u201314 words (one breath). Shown as a synced caption and spoken aloud. Write the whole walkthrough as one continuous spoken script and chop it into these little beats: read in order, every `say` should flow as one natural explanation, each beat CONTINUING the previous (use connectors like "so", "then", "now", "and", "but"). Do NOT write a long self-contained sentence \u2014 if it has an "and"/comma joining two ideas, split it into two steps. The highlight appears in sync with the START of this beat, so one beat = one subject.'),file:G.string().optional().describe('Path of the file to show this step, e.g. "src/debounce.ts". Created if new and made the active editor tab. If omitted, the previously shown file stays active. Switch files with a step that just sets `file` (+ `say`/`highlight`) and NO code \u2014 like a person clicking a tab.'),code:G.string().optional().describe("Full contents of `file`, used ONLY to INTRODUCE a file the first time. The file is shown INSTANTLY (not typed out) \u2014 initial files, especially big ones, just appear. To CHANGE an already-written file, use `edits` (small find/replace deltas that DO type out) \u2014 do NOT resend the whole file. To just explain or point at existing code, use a step with `say` + `highlight` and NO `code`. For a deliberate full rewrite of an existing file, set `rewrite: true`."),edits:G.array(c$).optional().describe("Small find/replace edits to the CURRENT file \u2014 the granular, human way to change already-written code. Prefer this over resending `code`. Each edit types out only its changed region. Keep each step to one small edit (or a few closely-related ones). A step uses EITHER `code` OR `edits`, never both."),rewrite:G.boolean().optional().describe("Set true ONLY for a deliberate full-file rewrite via `code` on a file that already has content. Normally use `edits` instead."),typing:G.boolean().optional().describe("Animate `edits` as typing (default true). Set false to make an edit appear instantly. (`code` is always shown instantly regardless.)"),highlightCode:G.string().optional().describe("PREFERRED way to point at code: an EXACT snippet of the current file to highlight. The server finds this exact text AS IT STANDS at this step and highlights precisely those characters (and scrolls + glows it into view), so it never drifts when edits shift line numbers. MATCH the snippet to what you are explaining: pass a SINGLE token/line when you name one thing, or an ENTIRE multi-line block (newlines included) \u2014 a function body, useEffect, JSX element, if/try/map \u2014 when you explain that whole block. Do not shrink a multi-line subject to one line. The snippet must be UNIQUE in the file (it errors if missing or appearing more than once); if a short snippet is not unique, extend it rather than narrowing your intended highlight. Prefer this over `highlight` whenever the file has been edited."),highlight:G.tuple([G.number(),G.number()]).optional().describe("Highlight a precise line range [startLine, endLine] (1-based, inclusive) in the current file. Prefer `highlightCode` (snippet) when the file has been edited, since line numbers drift. Use this for highlighting a whole block by line range. It appears in sync with the narration start. On an `edits` step the highlight defaults to the edited region if neither is given."),terminal:G.string().optional().describe('Text to append to the terminal panel this step \u2014 e.g. a command and its output ("$ npm test\\n\u2713 3 passed").'),chapter:G.string().optional().describe("If set, starts a named chapter at this step, shown as a labelled marker on the timeline."),holdMs:G.number().optional().describe("How long this step lasts, in milliseconds. Defaults to a duration derived from the narration and amount of typing.")}),Qp={title:G.string().describe("Title of the walkthrough (shown in the player header and used for the filename)."),outputPath:G.string().optional().describe("Where to write the .html (absolute, or relative to the server cwd). Defaults to <cwd>/<slug>.html, falling back to /mnt/user-data/outputs or the OS temp dir if cwd is read-only. If set to /mnt/user-data/outputs/<file>, local MCP servers map it to a writable server-local output path: FLOWCAST_OUTPUT_DIR, non-root cwd, package workspace root, then temp. The tool returns a file:// resource_link to the written file when possible, plus a ui:// MCP resource_link."),voiceName:G.enum(Lr).optional().describe(a$),voiceTone:G.string().optional().describe("How the narrator should SOUND, matched to the topic \u2014 steers the TTS voice. One or two phrases describing affect/emotion, e.g. 'upbeat and encouraging, like a friendly bootcamp instructor' for a beginner tutorial, 'calm, precise, and reassuring' for a tricky debugging or security topic, 'energetic and curious' for a fun feature demo. Leave unset for the default relaxed-senior-engineer tone. (A natural, human delivery is always applied on top.)"),intro:G.string().optional().describe("Opening line spoken BEFORE the first step \u2014 a one- or two-sentence hook: greet, say what we'll build and why it matters. The server adds it as the first beat (voiced + captioned), so DON'T also write your own welcome step. Defaults to a title-based welcome; set to '' to skip."),outro:G.string().optional().describe("Closing line spoken AFTER the last step \u2014 a quick recap + sign-off, held on the final code. The server adds it as the last beat, so DON'T write your own. Defaults to a title-based wrap-up; set to '' to skip."),files:G.array(G.object({path:G.string(),content:G.string().optional()})).optional().describe('Pre-existing files, present in FULL from t=0 \u2014 put EXISTING/already-written code here with its complete `content`. Steps then just `show` (`file`) and `highlight` them, with no typing. Use this for "explain this existing code" walkthroughs; use step `code` only for code written live.'),steps:G.array(l$).min(1).describe('The ordered timeline, shaped as a LESSON: open on the PROBLEM/why (not "here is a file"), build ONE idea at a time grouped into chapters named after the sub-goal, show it working, then recap. Say the intent before the code. Use as MANY short steps as the material needs \u2014 lean HIGH (a small feature is often 20\u201350 steps, not 6). Every line of code or distinct idea is its own beat: a short `say` (4\u201314 words) + a tight `highlightCode`, and the `say` lines must read as one continuous script when concatenated. Introduce a file once (shown instantly), then mostly switch files, point/highlight, and make small `edits`. Prefer 40 four-second beats over 6 thirty-second monologues.')},jZ=G.object(Qp);var tm=[],Py=[];(()=>{let t="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,r=0;e<t.length;e++)(e%2?Py:tm).push(r=r+t[e])})();function u$(t){if(t<768)return!1;for(let e=0,r=tm.length;;){let n=e+r>>1;if(t<tm[n])r=n;else if(t>=Py[n])e=n+1;else return!0;if(e==r)return!1}}function Ty(t){return t>=127462&&t<=127487}var $y=8205;function My(t,e,r=!0,n=!0){return(r?zy:d$)(t,e,n)}function zy(t,e,r){if(e==t.length)return e;e&&Iy(t.charCodeAt(e))&&Oy(t.charCodeAt(e-1))&&e--;let n=em(t,e);for(e+=Ry(n);e<t.length;){let s=em(t,e);if(n==$y||s==$y||r&&u$(s))e+=Ry(s),n=s;else if(Ty(s)){let o=0,i=e-2;for(;i>=0&&Ty(em(t,i));)o++,i-=2;if(o%2==0)break;e+=2}else break}return e}function d$(t,e,r){for(;e>0;){let n=zy(t,e-2,r);if(n<e)return n;e--}return 0}function em(t,e){let r=t.charCodeAt(e);if(!Oy(r)||e+1==t.length)return r;let n=t.charCodeAt(e+1);return Iy(n)?(r-55296<<10)+(n-56320)+65536:r}function Iy(t){return t>=56320&&t<57344}function Oy(t){return t>=55296&&t<56320}function Ry(t){return t<65536?1:2}var Kt=class t{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,r,n){[e,r]=ri(this,e,r);let s=[];return this.decompose(0,e,s,2),n.length&&n.decompose(0,n.length,s,3),this.decompose(r,this.length,s,1),Qo.from(s,this.length-(r-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,r=this.length){[e,r]=ri(this,e,r);let n=[];return this.decompose(e,r,n,0),Qo.from(n,r-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let r=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),s=new so(this),o=new so(e);for(let i=r,a=r;;){if(s.next(i),o.next(i),i=0,s.lineBreak!=o.lineBreak||s.done!=o.done||s.value!=o.value)return!1;if(a+=s.value.length,s.done||a>=n)return!0}}iter(e=1){return new so(this,e)}iterRange(e,r=this.length){return new Cl(this,e,r)}iterLines(e,r){let n;if(e==null)n=this.iter();else{r==null&&(r=this.lines+1);let s=this.line(e).from;n=this.iterRange(s,Math.max(s,r==this.lines+1?this.length:r<=1?0:this.line(r-1).to))}return new jl(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?t.empty:e.length<=32?new Zr(e):Qo.from(Zr.split(e,[]))}},Zr=class t extends Kt{constructor(e,r=f$(e)){super(),this.text=e,this.length=r}get lines(){return this.text.length}get children(){return null}lineInner(e,r,n,s){for(let o=0;;o++){let i=this.text[o],a=s+i.length;if((r?n:a)>=e)return new nm(s,a,n,i);s=a+1,n++}}decompose(e,r,n,s){let o=e<=0&&r>=this.length?this:new t(Ay(this.text,e,r),Math.min(r,this.length)-Math.max(0,e));if(s&1){let i=n.pop(),a=Nl(o.text,i.text.slice(),0,o.length);if(a.length<=32)n.push(new t(a,i.length+o.length));else{let c=a.length>>1;n.push(new t(a.slice(0,c)),new t(a.slice(c)))}}else n.push(o)}replace(e,r,n){if(!(n instanceof t))return super.replace(e,r,n);[e,r]=ri(this,e,r);let s=Nl(this.text,Nl(n.text,Ay(this.text,0,e)),r),o=this.length+n.length-(r-e);return s.length<=32?new t(s,o):Qo.from(t.split(s,[]),o)}sliceString(e,r=this.length,n=`
|
|
43
|
+
`){[e,r]=ri(this,e,r);let s="";for(let o=0,i=0;o<=r&&i<this.text.length;i++){let a=this.text[i],c=o+a.length;o>e&&i&&(s+=n),e<c&&r>o&&(s+=a.slice(Math.max(0,e-o),r-o)),o=c+1}return s}flatten(e){for(let r of this.text)e.push(r)}scanIdentical(){return 0}static split(e,r){let n=[],s=-1;for(let o of e)n.push(o),s+=o.length+1,n.length==32&&(r.push(new t(n,s)),n=[],s=-1);return s>-1&&r.push(new t(n,s)),r}},Qo=class t extends Kt{constructor(e,r){super(),this.children=e,this.length=r,this.lines=0;for(let n of e)this.lines+=n.lines}lineInner(e,r,n,s){for(let o=0;;o++){let i=this.children[o],a=s+i.length,c=n+i.lines-1;if((r?c:a)>=e)return i.lineInner(e,r,n,s);s=a+1,n=c+1}}decompose(e,r,n,s){for(let o=0,i=0;i<=r&&o<this.children.length;o++){let a=this.children[o],c=i+a.length;if(e<=c&&r>=i){let d=s&((i<=e?1:0)|(c>=r?2:0));i>=e&&c<=r&&!d?n.push(a):a.decompose(e-i,r-i,n,d)}i=c+1}}replace(e,r,n){if([e,r]=ri(this,e,r),n.lines<this.lines)for(let s=0,o=0;s<this.children.length;s++){let i=this.children[s],a=o+i.length;if(e>=o&&r<=a){let c=i.replace(e-o,r-o,n),d=this.lines-i.lines+c.lines;if(c.lines<d>>4&&c.lines>d>>6){let l=this.children.slice();return l[s]=c,new t(l,this.length-(r-e)+n.length)}return super.replace(o,a,c)}o=a+1}return super.replace(e,r,n)}sliceString(e,r=this.length,n=`
|
|
44
|
+
`){[e,r]=ri(this,e,r);let s="";for(let o=0,i=0;o<this.children.length&&i<=r;o++){let a=this.children[o],c=i+a.length;i>e&&o&&(s+=n),e<c&&r>i&&(s+=a.sliceString(e-i,r-i,n)),i=c+1}return s}flatten(e){for(let r of this.children)r.flatten(e)}scanIdentical(e,r){if(!(e instanceof t))return 0;let n=0,[s,o,i,a]=r>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;s+=r,o+=r){if(s==i||o==a)return n;let c=this.children[s],d=e.children[o];if(c!=d)return n+c.scanIdentical(d,r);n+=c.length+1}}static from(e,r=e.reduce((n,s)=>n+s.length+1,-1)){let n=0;for(let p of e)n+=p.lines;if(n<32){let p=[];for(let g of e)g.flatten(p);return new Zr(p,r)}let s=Math.max(32,n>>5),o=s<<1,i=s>>1,a=[],c=0,d=-1,l=[];function u(p){let g;if(p.lines>o&&p instanceof t)for(let x of p.children)u(x);else p.lines>i&&(c>i||!c)?(h(),a.push(p)):p instanceof Zr&&c&&(g=l[l.length-1])instanceof Zr&&p.lines+g.lines<=32?(c+=p.lines,d+=p.length+1,l[l.length-1]=new Zr(g.text.concat(p.text),g.length+1+p.length)):(c+p.lines>s&&h(),c+=p.lines,d+=p.length+1,l.push(p))}function h(){c!=0&&(a.push(l.length==1?l[0]:t.from(l,d)),d=-1,c=l.length=0)}for(let p of e)u(p);return h(),a.length==1?a[0]:new t(a,r)}};Kt.empty=new Zr([""],0);function f$(t){let e=-1;for(let r of t)e+=r.length+1;return e}function Nl(t,e,r=0,n=1e9){for(let s=0,o=0,i=!0;o<t.length&&s<=n;o++){let a=t[o],c=s+a.length;c>=r&&(c>n&&(a=a.slice(0,n-s)),s<r&&(a=a.slice(r-s)),i?(e[e.length-1]+=a,i=!1):e.push(a)),s=c+1}return e}function Ay(t,e,r){return Nl(t,[""],e,r)}var so=class{constructor(e,r=1){this.dir=r,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[r>0?1:(e instanceof Zr?e.text.length:e.children.length)<<1]}nextInner(e,r){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,s=this.nodes[n],o=this.offsets[n],i=o>>1,a=s instanceof Zr?s.text.length:s.children.length;if(i==(r>0?a:0)){if(n==0)return this.done=!0,this.value="",this;r>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((o&1)==(r>0?0:1)){if(this.offsets[n]+=r,e==0)return this.lineBreak=!0,this.value=`
|
|
45
|
+
`,this;e--}else if(s instanceof Zr){let c=s.text[i+(r<0?-1:0)];if(this.offsets[n]+=r,c.length>Math.max(0,e))return this.value=e==0?c:r>0?c.slice(e):c.slice(0,c.length-e),this;e-=c.length}else{let c=s.children[i+(r<0?-1:0)];e>c.length?(e-=c.length,this.offsets[n]+=r):(r<0&&this.offsets[n]--,this.nodes.push(c),this.offsets.push(r>0?1:(c instanceof Zr?c.text.length:c.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}},Cl=class{constructor(e,r,n){this.value="",this.done=!1,this.cursor=new so(e,r>n?-1:1),this.pos=r>n?e.length:0,this.from=Math.min(r,n),this.to=Math.max(r,n)}nextInner(e,r){if(r<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,r<0?this.pos-this.to:this.from-this.pos);let n=r<0?this.pos-this.from:this.to-this.pos;e>n&&(e=n),n-=e;let{value:s}=this.cursor.next(e);return this.pos+=(s.length+e)*r,this.value=s.length<=n?s:r<0?s.slice(s.length-n):s.slice(0,n),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}},jl=class{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:r,lineBreak:n,value:s}=this.inner.next(e);return r&&this.afterBreak?(this.value="",this.afterBreak=!1):r?(this.done=!0,this.value=""):n?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=s,this.afterBreak=!1),this}get lineBreak(){return!1}};typeof Symbol<"u"&&(Kt.prototype[Symbol.iterator]=function(){return this.iter()},so.prototype[Symbol.iterator]=Cl.prototype[Symbol.iterator]=jl.prototype[Symbol.iterator]=function(){return this});var nm=class{constructor(e,r,n,s){this.from=e,this.to=r,this.number=n,this.text=s}get length(){return this.to-this.from}};function ri(t,e,r){return e=Math.max(0,Math.min(t.length,e)),[e,Math.max(e,Math.min(t.length,r))]}function Ny(t,e,r=!0,n=!0){return My(t,e,r,n)}var sm=/\r\n?|\n/,hs=function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t}(hs||(hs={})),oo=class t{constructor(e){this.sections=e}get length(){let e=0;for(let r=0;r<this.sections.length;r+=2)e+=this.sections[r];return e}get newLength(){let e=0;for(let r=0;r<this.sections.length;r+=2){let n=this.sections[r+1];e+=n<0?this.sections[r]:n}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let r=0,n=0,s=0;r<this.sections.length;){let o=this.sections[r++],i=this.sections[r++];i<0?(e(n,s,o),s+=o):s+=i,n+=o}}iterChangedRanges(e,r=!1){om(this,e,r)}get invertedDesc(){let e=[];for(let r=0;r<this.sections.length;){let n=this.sections[r++],s=this.sections[r++];s<0?e.push(n,s):e.push(s,n)}return new t(e)}composeDesc(e){return this.empty?e:e.empty?this:Zy(this,e)}mapDesc(e,r=!1){return e.empty?this:im(this,e,r)}mapPos(e,r=-1,n=hs.Simple){let s=0,o=0;for(let i=0;i<this.sections.length;){let a=this.sections[i++],c=this.sections[i++],d=s+a;if(c<0){if(d>e)return o+(e-s);o+=a}else{if(n!=hs.Simple&&d>=e&&(n==hs.TrackDel&&s<e&&d>e||n==hs.TrackBefore&&s<e||n==hs.TrackAfter&&d>e))return null;if(d>e||d==e&&r<0&&!a)return e==s||r<0?o:o+c;o+=c}s=d}if(e>s)throw new RangeError(`Position ${e} is out of range for changeset of length ${s}`);return o}touchesRange(e,r=e){for(let n=0,s=0;n<this.sections.length&&s<=r;){let o=this.sections[n++],i=this.sections[n++],a=s+o;if(i>=0&&s<=r&&a>=e)return s<e&&a>r?"cover":!0;s=a}return!1}toString(){let e="";for(let r=0;r<this.sections.length;){let n=this.sections[r++],s=this.sections[r++];e+=(e?" ":"")+n+(s>=0?":"+s:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(r=>typeof r!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new t(e)}static create(e){return new t(e)}},tn=class t extends oo{constructor(e,r){super(e),this.inserted=r}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return om(this,(r,n,s,o,i)=>e=e.replace(s,s+(n-r),i),!1),e}mapDesc(e,r=!1){return im(this,e,r,!0)}invert(e){let r=this.sections.slice(),n=[];for(let s=0,o=0;s<r.length;s+=2){let i=r[s],a=r[s+1];if(a>=0){r[s]=a,r[s+1]=i;let c=s>>1;for(;n.length<c;)n.push(Kt.empty);n.push(i?e.slice(o,o+i):Kt.empty)}o+=i}return new t(r,n)}compose(e){return this.empty?e:e.empty?this:Zy(this,e,!0)}map(e,r=!1){return e.empty?this:im(this,e,r,!0)}iterChanges(e,r=!1){om(this,e,r)}get desc(){return oo.create(this.sections)}filter(e){let r=[],n=[],s=[],o=new io(this);e:for(let i=0,a=0;;){let c=i==e.length?1e9:e[i++];for(;a<c||a==c&&o.len==0;){if(o.done)break e;let l=Math.min(o.len,c-a);fr(s,l,-1);let u=o.ins==-1?-1:o.off==0?o.ins:0;fr(r,l,u),u>0&&ps(n,r,o.text),o.forward(l),a+=l}let d=e[i++];for(;a<d;){if(o.done)break e;let l=Math.min(o.len,d-a);fr(r,l,-1),fr(s,l,o.ins==-1?-1:o.off==0?o.ins:0),o.forward(l),a+=l}}return{changes:new t(r,n),filtered:oo.create(s)}}toJSON(){let e=[];for(let r=0;r<this.sections.length;r+=2){let n=this.sections[r],s=this.sections[r+1];s<0?e.push(n):s==0?e.push([n]):e.push([n].concat(this.inserted[r>>1].toJSON()))}return e}static of(e,r,n){let s=[],o=[],i=0,a=null;function c(l=!1){if(!l&&!s.length)return;i<r&&fr(s,r-i,-1);let u=new t(s,o);a=a?a.compose(u.map(a)):u,s=[],o=[],i=0}function d(l){if(Array.isArray(l))for(let u of l)d(u);else if(l instanceof t){if(l.length!=r)throw new RangeError(`Mismatched change set length (got ${l.length}, expected ${r})`);c(),a=a?a.compose(l.map(a)):l}else{let{from:u,to:h=u,insert:p}=l;if(u>h||u<0||h>r)throw new RangeError(`Invalid change range ${u} to ${h} (in doc of length ${r})`);let g=p?typeof p=="string"?Kt.of(p.split(n||sm)):p:Kt.empty,x=g.length;if(u==h&&x==0)return;u<i&&c(),u>i&&fr(s,u-i,-1),fr(s,h-u,x),ps(o,s,g),i=h}}return d(e),c(!a),a}static empty(e){return new t(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let r=[],n=[];for(let s=0;s<e.length;s++){let o=e[s];if(typeof o=="number")r.push(o,-1);else{if(!Array.isArray(o)||typeof o[0]!="number"||o.some((i,a)=>a&&typeof i!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(o.length==1)r.push(o[0],0);else{for(;n.length<s;)n.push(Kt.empty);n[s]=Kt.of(o.slice(1)),r.push(o[0],n[s].length)}}}return new t(r,n)}static createSet(e,r){return new t(e,r)}};function fr(t,e,r,n=!1){if(e==0&&r<=0)return;let s=t.length-2;s>=0&&r<=0&&r==t[s+1]?t[s]+=e:s>=0&&e==0&&t[s]==0?t[s+1]+=r:n?(t[s]+=e,t[s+1]+=r):t.push(e,r)}function ps(t,e,r){if(r.length==0)return;let n=e.length-2>>1;if(n<t.length)t[t.length-1]=t[t.length-1].append(r);else{for(;t.length<n;)t.push(Kt.empty);t.push(r)}}function om(t,e,r){let n=t.inserted;for(let s=0,o=0,i=0;i<t.sections.length;){let a=t.sections[i++],c=t.sections[i++];if(c<0)s+=a,o+=a;else{let d=s,l=o,u=Kt.empty;for(;d+=a,l+=c,c&&n&&(u=u.append(n[i-2>>1])),!(r||i==t.sections.length||t.sections[i+1]<0);)a=t.sections[i++],c=t.sections[i++];e(s,d,o,l,u),s=d,o=l}}}function im(t,e,r,n=!1){let s=[],o=n?[]:null,i=new io(t),a=new io(e);for(let c=-1;;){if(i.done&&a.len||a.done&&i.len)throw new Error("Mismatched change set lengths");if(i.ins==-1&&a.ins==-1){let d=Math.min(i.len,a.len);fr(s,d,-1),i.forward(d),a.forward(d)}else if(a.ins>=0&&(i.ins<0||c==i.i||i.off==0&&(a.len<i.len||a.len==i.len&&!r))){let d=a.len;for(fr(s,a.ins,-1);d;){let l=Math.min(i.len,d);i.ins>=0&&c<i.i&&i.len<=l&&(fr(s,0,i.ins),o&&ps(o,s,i.text),c=i.i),i.forward(l),d-=l}a.next()}else if(i.ins>=0){let d=0,l=i.len;for(;l;)if(a.ins==-1){let u=Math.min(l,a.len);d+=u,l-=u,a.forward(u)}else if(a.ins==0&&a.len<l)l-=a.len,a.next();else break;fr(s,d,c<i.i?i.ins:0),o&&c<i.i&&ps(o,s,i.text),c=i.i,i.forward(i.len-l)}else{if(i.done&&a.done)return o?tn.createSet(s,o):oo.create(s);throw new Error("Mismatched change set lengths")}}}function Zy(t,e,r=!1){let n=[],s=r?[]:null,o=new io(t),i=new io(e);for(let a=!1;;){if(o.done&&i.done)return s?tn.createSet(n,s):oo.create(n);if(o.ins==0)fr(n,o.len,0,a),o.next();else if(i.len==0&&!i.done)fr(n,0,i.ins,a),s&&ps(s,n,i.text),i.next();else{if(o.done||i.done)throw new Error("Mismatched change set lengths");{let c=Math.min(o.len2,i.len),d=n.length;if(o.ins==-1){let l=i.ins==-1?-1:i.off?0:i.ins;fr(n,c,l,a),s&&l&&ps(s,n,i.text)}else i.ins==-1?(fr(n,o.off?0:o.len,c,a),s&&ps(s,n,o.textBit(c))):(fr(n,o.off?0:o.len,i.off?0:i.ins,a),s&&!i.off&&ps(s,n,i.text));a=(o.ins>c||i.ins>=0&&i.len>c)&&(a||n.length>d),o.forward2(c),i.forward(c)}}}}var io=class{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,r=this.i-2>>1;return r>=e.length?Kt.empty:e[r]}textBit(e){let{inserted:r}=this.set,n=this.i-2>>1;return n>=r.length&&!e?Kt.empty:r[n].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}},Jo=class t{constructor(e,r,n){this.from=e,this.to=r,this.flags=n}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}get goalColumn(){let e=this.flags>>6;return e==16777215?void 0:e}map(e,r=-1){let n,s;return this.empty?n=s=e.mapPos(this.from,r):(n=e.mapPos(this.from,1),s=e.mapPos(this.to,-1)),n==this.from&&s==this.to?this:new t(n,s,this.flags)}extend(e,r=e,n=0){if(e<=this.anchor&&r>=this.anchor)return Pr.range(e,r,void 0,void 0,n);let s=Math.abs(e-this.anchor)>Math.abs(r-this.anchor)?e:r;return Pr.range(this.anchor,s,void 0,void 0,n)}eq(e,r=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!r||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return Pr.range(e.anchor,e.head)}static create(e,r,n){return new t(e,r,n)}},Pr=class t{constructor(e,r){this.ranges=e,this.mainIndex=r}map(e,r=-1){return e.empty?this:t.create(this.ranges.map(n=>n.map(e,r)),this.mainIndex)}eq(e,r=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let n=0;n<this.ranges.length;n++)if(!this.ranges[n].eq(e.ranges[n],r))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new t([this.main],0)}addRange(e,r=!0){return t.create([e].concat(this.ranges),r?0:this.mainIndex+1)}replaceRange(e,r=this.mainIndex){let n=this.ranges.slice();return n[r]=e,t.create(n,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new t(e.ranges.map(r=>Jo.fromJSON(r)),e.main)}static single(e,r=e){return new t([t.range(e,r)],0)}static create(e,r=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let n=0,s=0;s<e.length;s++){let o=e[s];if(o.empty?o.from<=n:o.from<n)return t.normalized(e.slice(),r);n=o.to}return new t(e,r)}static cursor(e,r=0,n,s){return Jo.create(e,e,(r==0?0:r<0?8:16)|(n==null?7:Math.min(6,n))|(s??16777215)<<6)}static range(e,r,n,s,o){let i=(n??16777215)<<6|(s==null?7:Math.min(6,s));return!o&&e!=r&&(o=r<e?1:-1),r<e?Jo.create(r,e,48|i):Jo.create(e,r,(o?o<0?8:16:0)|i)}static normalized(e,r=0){let n=e[r];e.sort((s,o)=>s.from-o.from),r=e.indexOf(n);for(let s=1;s<e.length;s++){let o=e[s],i=e[s-1];if(o.empty?o.from<=i.to:o.from<i.to){let a=i.from,c=Math.max(o.to,i.to);s<=r&&r--,e.splice(--s,2,o.anchor>o.head?t.range(c,a):t.range(a,c))}}return new t(e,r)}};function By(t,e){for(let r of t.ranges)if(r.to>e)throw new RangeError("Selection points outside of document")}var gm=0,Br=class t{constructor(e,r,n,s,o){this.combine=e,this.compareInput=r,this.compare=n,this.isStatic=s,this.id=gm++,this.default=e([]),this.extensions=typeof o=="function"?o(this):o}get reader(){return this}static define(e={}){return new t(e.combine||(r=>r),e.compareInput||((r,n)=>r===n),e.compare||(e.combine?(r,n)=>r===n:_m),!!e.static,e.enables)}of(e){return new ei([],this,0,e)}compute(e,r){if(this.isStatic)throw new Error("Can't compute a static facet");return new ei(e,this,1,r)}computeN(e,r){if(this.isStatic)throw new Error("Can't compute a static facet");return new ei(e,this,2,r)}from(e,r){return r||(r=n=>n),this.compute([e],n=>r(n.field(e)))}};function _m(t,e){return t==e||t.length==e.length&&t.every((r,n)=>r===e[n])}var ei=class{constructor(e,r,n,s){this.dependencies=e,this.facet=r,this.type=n,this.value=s,this.id=gm++}dynamicSlot(e){var r;let n=this.value,s=this.facet.compareInput,o=this.id,i=e[o]>>1,a=this.type==2,c=!1,d=!1,l=[];for(let u of this.dependencies)u=="doc"?c=!0:u=="selection"?d=!0:((r=e[u.id])!==null&&r!==void 0?r:1)&1||l.push(e[u.id]);return{create(u){return u.values[i]=n(u),1},update(u,h){if(c&&h.docChanged||d&&(h.docChanged||h.selection)||am(u,l)){let p=n(u);if(a?!Cy(p,u.values[i],s):!s(p,u.values[i]))return u.values[i]=p,1}return 0},reconfigure:(u,h)=>{let p,g=h.config.address[o];if(g!=null){let x=Bl(h,g);if(this.dependencies.every(S=>S instanceof Br?h.facet(S)===u.facet(S):S instanceof ni?h.field(S,!1)==u.field(S,!1):!0)||(a?Cy(p=n(u),x,s):s(p=n(u),x)))return u.values[i]=x,0}else p=n(u);return u.values[i]=p,1}}}};function Cy(t,e,r){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!r(t[n],e[n]))return!1;return!0}function am(t,e){let r=!1;for(let n of e)Ea(t,n)&1&&(r=!0);return r}function h$(t,e,r){let n=r.map(c=>t[c.id]),s=r.map(c=>c.type),o=n.filter(c=>!(c&1)),i=t[e.id]>>1;function a(c){let d=[];for(let l=0;l<n.length;l++){let u=Bl(c,n[l]);if(s[l]==2)for(let h of u)d.push(h);else d.push(u)}return e.combine(d)}return{create(c){for(let d of n)Ea(c,d);return c.values[i]=a(c),1},update(c,d){if(!am(c,o))return 0;let l=a(c);return e.compare(l,c.values[i])?0:(c.values[i]=l,1)},reconfigure(c,d){let l=am(c,n),u=d.config.facets[e.id],h=d.facet(e);if(u&&!l&&_m(r,u))return c.values[i]=h,0;let p=a(c);return e.compare(p,h)?(c.values[i]=h,0):(c.values[i]=p,1)}}}var Il=Br.define({static:!0}),ni=class t{constructor(e,r,n,s,o){this.id=e,this.createF=r,this.updateF=n,this.compareF=s,this.spec=o,this.provides=void 0}static define(e){let r=new t(gm++,e.create,e.update,e.compare||((n,s)=>n===s),e);return e.provide&&(r.provides=e.provide(r)),r}create(e){let r=e.facet(Il).find(n=>n.field==this);return(r?.create||this.createF)(e)}slot(e){let r=e[this.id]>>1;return{create:n=>(n.values[r]=this.create(n),1),update:(n,s)=>{let o=n.values[r],i=this.updateF(o,s);return this.compareF(o,i)?0:(n.values[r]=i,1)},reconfigure:(n,s)=>{let o=n.facet(Il),i=s.facet(Il),a;return(a=o.find(c=>c.field==this))&&a!=i.find(c=>c.field==this)?(n.values[r]=a.create(n),1):s.config.address[this.id]!=null?(n.values[r]=s.field(this),0):(n.values[r]=this.create(n),1)}}}init(e){return[this,Il.of({field:this,create:e})]}get extension(){return this}},ro={lowest:4,low:3,default:2,high:1,highest:0};function Sa(t){return e=>new Dl(e,t)}var BZ={highest:Sa(ro.highest),high:Sa(ro.high),default:Sa(ro.default),low:Sa(ro.low),lowest:Sa(ro.lowest)},Dl=class{constructor(e,r){this.inner=e,this.prec=r}},Ll=class t{of(e){return new Ta(this,e)}reconfigure(e){return t.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}},Ta=class{constructor(e,r){this.compartment=e,this.inner=r}},Zl=class t{constructor(e,r,n,s,o,i){for(this.base=e,this.compartments=r,this.dynamicSlots=n,this.address=s,this.staticValues=o,this.facets=i,this.statusTemplate=[];this.statusTemplate.length<n.length;)this.statusTemplate.push(0)}staticFacet(e){let r=this.address[e.id];return r==null?e.default:this.staticValues[r>>1]}static resolve(e,r,n){let s=[],o=Object.create(null),i=new Map;for(let h of p$(e,r,i))h instanceof ni?s.push(h):(o[h.facet.id]||(o[h.facet.id]=[])).push(h);let a=Object.create(null),c=[],d=[];for(let h of s)a[h.id]=d.length<<1,d.push(p=>h.slot(p));let l=n?.config.facets;for(let h in o){let p=o[h],g=p[0].facet,x=l&&l[h]||[];if(p.every(S=>S.type==0))if(a[g.id]=c.length<<1|1,_m(x,p))c.push(n.facet(g));else{let S=g.combine(p.map(k=>k.value));c.push(n&&g.compare(S,n.facet(g))?n.facet(g):S)}else{for(let S of p)S.type==0?(a[S.id]=c.length<<1|1,c.push(S.value)):(a[S.id]=d.length<<1,d.push(k=>S.dynamicSlot(k)));a[g.id]=d.length<<1,d.push(S=>h$(S,g,p))}}let u=d.map(h=>h(a));return new t(e,i,u,a,c,o)}};function p$(t,e,r){let n=[[],[],[],[],[]],s=new Map;function o(i,a){let c=s.get(i);if(c!=null){if(c<=a)return;let d=n[c].indexOf(i);d>-1&&n[c].splice(d,1),i instanceof Ta&&r.delete(i.compartment)}if(s.set(i,a),Array.isArray(i))for(let d of i)o(d,a);else if(i instanceof Ta){if(r.has(i.compartment))throw new RangeError("Duplicate use of compartment in extensions");let d=e.get(i.compartment)||i.inner;r.set(i.compartment,d),o(d,a)}else if(i instanceof Dl)o(i.inner,i.prec);else if(i instanceof ni)n[a].push(i),i.provides&&o(i.provides,a);else if(i instanceof ei)n[a].push(i),i.facet.extensions&&o(i.facet.extensions,ro.default);else{let d=i.extension;if(!d)throw new Error(`Unrecognized extension value in extension set (${i}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);o(d,a)}}return o(t,ro.default),n.reduce((i,a)=>i.concat(a))}function Ea(t,e){if(e&1)return 2;let r=e>>1,n=t.status[r];if(n==4)throw new Error("Cyclic dependency between fields and/or facets");if(n&2)return n;t.status[r]=4;let s=t.computeSlot(t,t.config.dynamicSlots[r]);return t.status[r]=2|s}function Bl(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}var qy=Br.define(),cm=Br.define({combine:t=>t.some(e=>e),static:!0}),Vy=Br.define({combine:t=>t.length?t[0]:void 0,static:!0}),Fy=Br.define(),Hy=Br.define(),Uy=Br.define(),Gy=Br.define({combine:t=>t.length?t[0]:!1}),ao=class{constructor(e,r){this.type=e,this.value=r}static define(){return new lm}},lm=class{of(e){return new ao(this,e)}},um=class{constructor(e){this.map=e}of(e){return new br(this,e)}},br=class t{constructor(e,r){this.type=e,this.value=r}map(e){let r=this.type.map(this.value,e);return r===void 0?void 0:r==this.value?this:new t(this.type,r)}is(e){return this.type==e}static define(e={}){return new um(e.map||(r=>r))}static mapEffects(e,r){if(!e.length)return e;let n=[];for(let s of e){let o=s.map(r);o&&n.push(o)}return n}};br.reconfigure=br.define();br.appendConfig=br.define();var en=class t{constructor(e,r,n,s,o,i){this.startState=e,this.changes=r,this.selection=n,this.effects=s,this.annotations=o,this.scrollIntoView=i,this._doc=null,this._state=null,n&&By(n,r.newLength),o.some(a=>a.type==t.time)||(this.annotations=o.concat(t.time.of(Date.now())))}static create(e,r,n,s,o,i){return new t(e,r,n,s,o,i)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let r of this.annotations)if(r.type==e)return r.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let r=this.annotation(t.userEvent);return!!(r&&(r==e||r.length>e.length&&r.slice(0,e.length)==e&&r[e.length]=="."))}};en.time=ao.define();en.userEvent=ao.define();en.addToHistory=ao.define();en.remote=ao.define();function m$(t,e){let r=[];for(let n=0,s=0;;){let o,i;if(n<t.length&&(s==e.length||e[s]>=t[n]))o=t[n++],i=t[n++];else if(s<e.length)o=e[s++],i=e[s++];else return r;!r.length||r[r.length-1]<o?r.push(o,i):r[r.length-1]<i&&(r[r.length-1]=i)}}function Yy(t,e,r){var n;let s,o,i;return r?(s=e.changes,o=tn.empty(e.changes.length),i=t.changes.compose(e.changes)):(s=e.changes.map(t.changes),o=t.changes.mapDesc(e.changes,!0),i=t.changes.compose(s)),{changes:i,selection:e.selection?e.selection.map(o):(n=t.selection)===null||n===void 0?void 0:n.map(s),effects:br.mapEffects(t.effects,s).concat(br.mapEffects(e.effects,o)),annotations:t.annotations.length?t.annotations.concat(e.annotations):e.annotations,scrollIntoView:t.scrollIntoView||e.scrollIntoView}}function dm(t,e,r){let n=e.selection,s=ti(e.annotations);return e.userEvent&&(s=s.concat(en.userEvent.of(e.userEvent))),{changes:e.changes instanceof tn?e.changes:tn.of(e.changes||[],r,t.facet(Vy)),selection:n&&(n instanceof Pr?n:Pr.single(n.anchor,n.head)),effects:ti(e.effects),annotations:s,scrollIntoView:!!e.scrollIntoView}}function Xy(t,e,r){let n=dm(t,e.length?e[0]:{},t.doc.length);e.length&&e[0].filter===!1&&(r=!1);for(let o=1;o<e.length;o++){e[o].filter===!1&&(r=!1);let i=!!e[o].sequential;n=Yy(n,dm(t,e[o],i?n.changes.newLength:t.doc.length),i)}let s=en.create(t,n.changes,n.selection,n.effects,n.annotations,n.scrollIntoView);return _$(r?g$(s):s)}function g$(t){let e=t.startState,r=!0;for(let s of e.facet(Fy)){let o=s(t);if(o===!1){r=!1;break}Array.isArray(o)&&(r=r===!0?o:m$(r,o))}if(r!==!0){let s,o;if(r===!1)o=t.changes.invertedDesc,s=tn.empty(e.doc.length);else{let i=t.changes.filter(r);s=i.changes,o=i.filtered.mapDesc(i.changes).invertedDesc}t=en.create(e,s,t.selection&&t.selection.map(o),br.mapEffects(t.effects,o),t.annotations,t.scrollIntoView)}let n=e.facet(Hy);for(let s=n.length-1;s>=0;s--){let o=n[s](t);o instanceof en?t=o:Array.isArray(o)&&o.length==1&&o[0]instanceof en?t=o[0]:t=Xy(e,ti(o),!1)}return t}function _$(t){let e=t.startState,r=e.facet(Uy),n=t;for(let s=r.length-1;s>=0;s--){let o=r[s](t);o&&Object.keys(o).length&&(n=Yy(n,dm(e,o,t.changes.newLength),!0))}return n==t?t:en.create(e,t.changes,t.selection,n.effects,n.annotations,n.scrollIntoView)}var b$=[];function ti(t){return t==null?b$:Array.isArray(t)?t:[t]}var ms=function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t}(ms||(ms={})),y$=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,fm;try{fm=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function v$(t){if(fm)return fm.test(t);for(let e=0;e<t.length;e++){let r=t[e];if(/\w/.test(r)||r>"\x80"&&(r.toUpperCase()!=r.toLowerCase()||y$.test(r)))return!0}return!1}function w$(t){return e=>{if(!/\S/.test(e))return ms.Space;if(v$(e))return ms.Word;for(let r=0;r<t.length;r++)if(e.indexOf(t[r])>-1)return ms.Word;return ms.Other}}var bn=class t{constructor(e,r,n,s,o,i){this.config=e,this.doc=r,this.selection=n,this.values=s,this.status=e.statusTemplate.slice(),this.computeSlot=o,i&&(i._state=this);for(let a=0;a<this.config.dynamicSlots.length;a++)Ea(this,a<<1);this.computeSlot=null}field(e,r=!0){let n=this.config.address[e.id];if(n==null){if(r)throw new RangeError("Field is not present in this state");return}return Ea(this,n),Bl(this,n)}update(...e){return Xy(this,e,!0)}applyTransaction(e){let r=this.config,{base:n,compartments:s}=r;for(let a of e.effects)a.is(Ll.reconfigure)?(r&&(s=new Map,r.compartments.forEach((c,d)=>s.set(d,c)),r=null),s.set(a.value.compartment,a.value.extension)):a.is(br.reconfigure)?(r=null,n=a.value):a.is(br.appendConfig)&&(r=null,n=ti(n).concat(a.value));let o;r?o=e.startState.values.slice():(r=Zl.resolve(n,s,this),o=new t(r,this.doc,this.selection,r.dynamicSlots.map(()=>null),(c,d)=>d.reconfigure(c,this),null).values);let i=e.startState.facet(cm)?e.newSelection:e.newSelection.asSingle();new t(r,e.newDoc,i,o,(a,c)=>c.update(a,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:e},range:Pr.cursor(r.from+e.length)}))}changeByRange(e){let r=this.selection,n=e(r.ranges[0]),s=this.changes(n.changes),o=[n.range],i=ti(n.effects);for(let a=1;a<r.ranges.length;a++){let c=e(r.ranges[a]),d=this.changes(c.changes),l=d.map(s);for(let h=0;h<a;h++)o[h]=o[h].map(l);let u=s.mapDesc(d,!0);o.push(c.range.map(u)),s=s.compose(l),i=br.mapEffects(i,l).concat(br.mapEffects(ti(c.effects),u))}return{changes:s,selection:Pr.create(o,r.mainIndex),effects:i}}changes(e=[]){return e instanceof tn?e:tn.of(e,this.doc.length,this.facet(t.lineSeparator))}toText(e){return Kt.of(e.split(this.facet(t.lineSeparator)||sm))}sliceDoc(e=0,r=this.doc.length){return this.doc.sliceString(e,r,this.lineBreak)}facet(e){let r=this.config.address[e.id];return r==null?e.default:(Ea(this,r),Bl(this,r))}toJSON(e){let r={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let n in e){let s=e[n];s instanceof ni&&this.config.address[s.id]!=null&&(r[n]=s.spec.toJSON(this.field(e[n]),this))}return r}static fromJSON(e,r={},n){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let s=[];if(n){for(let o in n)if(Object.prototype.hasOwnProperty.call(e,o)){let i=n[o],a=e[o];s.push(i.init(c=>i.spec.fromJSON(a,c)))}}return t.create({doc:e.doc,selection:Pr.fromJSON(e.selection),extensions:r.extensions?s.concat([r.extensions]):s})}static create(e={}){let r=Zl.resolve(e.extensions||[],new Map),n=e.doc instanceof Kt?e.doc:Kt.of((e.doc||"").split(r.staticFacet(t.lineSeparator)||sm)),s=e.selection?e.selection instanceof Pr?e.selection:Pr.single(e.selection.anchor,e.selection.head):Pr.single(0);return By(s,n.length),r.staticFacet(cm)||(s=s.asSingle()),new t(r,n,s,r.dynamicSlots.map(()=>null),(o,i)=>i.create(o),null)}get tabSize(){return this.facet(t.tabSize)}get lineBreak(){return this.facet(t.lineSeparator)||`
|
|
46
|
+
`}get readOnly(){return this.facet(Gy)}phrase(e,...r){for(let n of this.facet(t.phrases))if(Object.prototype.hasOwnProperty.call(n,e)){e=n[e];break}return r.length&&(e=e.replace(/\$(\$|\d*)/g,(n,s)=>{if(s=="$")return"$";let o=+(s||1);return!o||o>r.length?n:r[o-1]})),e}languageDataAt(e,r,n=-1){let s=[];for(let o of this.facet(qy))for(let i of o(this,r,n))Object.prototype.hasOwnProperty.call(i,e)&&s.push(i[e]);return s}charCategorizer(e){let r=this.languageDataAt("wordChars",e);return w$(r.length?r[0]:"")}wordAt(e){let{text:r,from:n,length:s}=this.doc.lineAt(e),o=this.charCategorizer(e),i=e-n,a=e-n;for(;i>0;){let c=Ny(r,i,!1);if(o(r.slice(c,i))!=ms.Word)break;i=c}for(;a<s;){let c=Ny(r,a);if(o(r.slice(a,c))!=ms.Word)break;a=c}return i==a?null:Pr.range(i+n,a+n)}};bn.allowMultipleSelections=cm;bn.tabSize=Br.define({combine:t=>t.length?t[0]:4});bn.lineSeparator=Vy;bn.readOnly=Gy;bn.phrases=Br.define({compare(t,e){let r=Object.keys(t),n=Object.keys(e);return r.length==n.length&&r.every(s=>t[s]==e[s])}});bn.languageData=qy;bn.changeFilter=Fy;bn.transactionFilter=Hy;bn.transactionExtender=Uy;Ll.reconfigure=br.define();var si=class{eq(e){return this==e}range(e,r=e){return $a.create(e,r,this)}};si.prototype.startSide=si.prototype.endSide=0;si.prototype.point=!1;si.prototype.mapMode=hs.TrackDel;function bm(t,e){return t==e||t.constructor==e.constructor&&t.eq(e)}var $a=class t{constructor(e,r,n){this.from=e,this.to=r,this.value=n}static create(e,r,n){return new t(e,r,n)}};function hm(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}var pm=class t{constructor(e,r,n,s){this.from=e,this.to=r,this.value=n,this.maxPoint=s}get length(){return this.to[this.to.length-1]}findIndex(e,r,n,s=0){let o=n?this.to:this.from;for(let i=s,a=o.length;;){if(i==a)return i;let c=i+a>>1,d=o[c]-e||(n?this.value[c].endSide:this.value[c].startSide)-r;if(c==i)return d>=0?i:a;d>=0?a=c:i=c+1}}between(e,r,n,s){for(let o=this.findIndex(r,-1e9,!0),i=this.findIndex(n,1e9,!1,o);o<i;o++)if(s(this.from[o]+e,this.to[o]+e,this.value[o])===!1)return!1}map(e,r){let n=[],s=[],o=[],i=-1,a=-1;for(let c=0;c<this.value.length;c++){let d=this.value[c],l=this.from[c]+e,u=this.to[c]+e,h,p;if(l==u){let g=r.mapPos(l,d.startSide,d.mapMode);if(g==null||(h=p=g,d.startSide!=d.endSide&&(p=r.mapPos(l,d.endSide),p<h)))continue}else if(h=r.mapPos(l,d.startSide),p=r.mapPos(u,d.endSide),h>p||h==p&&d.startSide>0&&d.endSide<=0)continue;(p-h||d.endSide-d.startSide)<0||(i<0&&(i=h),d.point&&(a=Math.max(a,p-h)),n.push(d),s.push(h-i),o.push(p-i))}return{mapped:n.length?new t(s,o,n,a):null,pos:i}}},gs=class t{constructor(e,r,n,s){this.chunkPos=e,this.chunk=r,this.nextLayer=n,this.maxPoint=s}static create(e,r,n,s){return new t(e,r,n,s)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let r of this.chunk)e+=r.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:r=[],sort:n=!1,filterFrom:s=0,filterTo:o=this.length}=e,i=e.filter;if(r.length==0&&!i)return this;if(n&&(r=r.slice().sort(hm)),this.isEmpty)return r.length?t.of(r):this;let a=new Vl(this,null,-1).goto(0),c=0,d=[],l=new ql;for(;a.value||c<r.length;)if(c<r.length&&(a.from-r[c].from||a.startSide-r[c].value.startSide)>=0){let u=r[c++];l.addInner(u.from,u.to,u.value)||d.push(u)}else a.rangeIndex==1&&a.chunkIndex<this.chunk.length&&(c==r.length||this.chunkEnd(a.chunkIndex)<r[c].from)&&(!i||s>this.chunkEnd(a.chunkIndex)||o<this.chunkPos[a.chunkIndex])&&l.addChunk(this.chunkPos[a.chunkIndex],this.chunk[a.chunkIndex])?a.nextChunk():((!i||s>a.to||o<a.from||i(a.from,a.to,a.value))&&(l.addInner(a.from,a.to,a.value)||d.push($a.create(a.from,a.to,a.value))),a.next());return l.finishInner(this.nextLayer.isEmpty&&!d.length?t.empty:this.nextLayer.update({add:d,filter:i,filterFrom:s,filterTo:o}))}map(e){if(e.empty||this.isEmpty)return this;let r=[],n=[],s=-1;for(let i=0;i<this.chunk.length;i++){let a=this.chunkPos[i],c=this.chunk[i],d=e.touchesRange(a,a+c.length);if(d===!1)s=Math.max(s,c.maxPoint),r.push(c),n.push(e.mapPos(a));else if(d===!0){let{mapped:l,pos:u}=c.map(a,e);l&&(s=Math.max(s,l.maxPoint),r.push(l),n.push(u))}}let o=this.nextLayer.map(e);return r.length==0?o:new t(n,r,o||t.empty,s)}between(e,r,n){if(!this.isEmpty){for(let s=0;s<this.chunk.length;s++){let o=this.chunkPos[s],i=this.chunk[s];if(r>=o&&e<=o+i.length&&i.between(o,e-o,r-o,n)===!1)return}this.nextLayer.between(e,r,n)}}iter(e=0){return Ra.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,r=0){return Ra.from(e).goto(r)}static compare(e,r,n,s,o=-1){let i=e.filter(u=>u.maxPoint>0||!u.isEmpty&&u.maxPoint>=o),a=r.filter(u=>u.maxPoint>0||!u.isEmpty&&u.maxPoint>=o),c=jy(i,a,n),d=new no(i,c,o),l=new no(a,c,o);n.iterGaps((u,h,p)=>Dy(d,u,l,h,p,s)),n.empty&&n.length==0&&Dy(d,0,l,0,0,s)}static eq(e,r,n=0,s){s==null&&(s=999999999);let o=e.filter(l=>!l.isEmpty&&r.indexOf(l)<0),i=r.filter(l=>!l.isEmpty&&e.indexOf(l)<0);if(o.length!=i.length)return!1;if(!o.length)return!0;let a=jy(o,i),c=new no(o,a,0).goto(n),d=new no(i,a,0).goto(n);for(;;){if(c.to!=d.to||!mm(c.active,d.active)||c.point&&(!d.point||!bm(c.point,d.point)))return!1;if(c.to>s)return!0;c.next(),d.next()}}static spans(e,r,n,s,o=-1){let i=new no(e,null,o).goto(r),a=r,c=i.openStart;for(;;){let d=Math.min(i.to,n);if(i.point){let l=i.activeForPoint(i.to),u=i.pointFrom<r?l.length+1:i.point.startSide<0?l.length:Math.min(l.length,c);s.point(a,d,i.point,l,u,i.pointRank),c=Math.min(i.openEnd(d),l.length)}else d>a&&(s.span(a,d,i.active,c),c=i.openEnd(d));if(i.to>n)return c+(i.point&&i.to>n?1:0);a=i.to,i.next()}}static of(e,r=!1){let n=new ql;for(let s of e instanceof $a?[e]:r?x$(e):e)n.add(s.from,s.to,s.value);return n.finish()}static join(e){if(!e.length)return t.empty;let r=e[e.length-1];for(let n=e.length-2;n>=0;n--)for(let s=e[n];s!=t.empty;s=s.nextLayer)r=new t(s.chunkPos,s.chunk,r,Math.max(s.maxPoint,r.maxPoint));return r}};gs.empty=new gs([],[],null,-1);function x$(t){if(t.length>1)for(let e=t[0],r=1;r<t.length;r++){let n=t[r];if(hm(e,n)>0)return t.slice().sort(hm);e=n}return t}gs.empty.nextLayer=gs.empty;var ql=class t{finishChunk(e){this.chunks.push(new pm(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,r,n){this.addInner(e,r,n)||(this.nextLayer||(this.nextLayer=new t)).add(e,r,n)}addInner(e,r,n){let s=e-this.lastTo||n.startSide-this.last.endSide;if(s<=0&&(e-this.lastFrom||n.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return s<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(r-this.chunkStart),this.last=n,this.lastFrom=e,this.lastTo=r,this.value.push(n),n.point&&(this.maxPoint=Math.max(this.maxPoint,r-e)),!0)}addChunk(e,r){if((e-this.lastTo||r.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,r.maxPoint),this.chunks.push(r),this.chunkPos.push(e);let n=r.value.length-1;return this.last=r.value[n],this.lastFrom=r.from[n]+e,this.lastTo=r.to[n]+e,!0}finish(){return this.finishInner(gs.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let r=gs.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,r}};function jy(t,e,r){let n=new Map;for(let o of t)for(let i=0;i<o.chunk.length;i++)o.chunk[i].maxPoint<=0&&n.set(o.chunk[i],o.chunkPos[i]);let s=new Set;for(let o of e)for(let i=0;i<o.chunk.length;i++){let a=n.get(o.chunk[i]);a!=null&&(r?r.mapPos(a):a)==o.chunkPos[i]&&!r?.touchesRange(a,a+o.chunk[i].length)&&s.add(o.chunk[i])}return s}var Vl=class{constructor(e,r,n,s=0){this.layer=e,this.skip=r,this.minPoint=n,this.rank=s}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(e,r=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(e,r,!1),this}gotoInner(e,r,n){for(;this.chunkIndex<this.layer.chunk.length;){let s=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(s)||this.layer.chunkEnd(this.chunkIndex)<e||s.maxPoint<this.minPoint))break;this.chunkIndex++,n=!1}if(this.chunkIndex<this.layer.chunk.length){let s=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],r,!0);(!n||this.rangeIndex<s)&&this.setRangeIndex(s)}this.next()}forward(e,r){(this.to-e||this.endSide-r)<0&&this.gotoInner(e,r,!0)}next(){for(;;)if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}else{let e=this.layer.chunkPos[this.chunkIndex],r=this.layer.chunk[this.chunkIndex],n=e+r.from[this.rangeIndex];if(this.from=n,this.to=e+r.to[this.rangeIndex],this.value=r.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=e}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(e){return this.from-e.from||this.startSide-e.startSide||this.rank-e.rank||this.to-e.to||this.endSide-e.endSide}},Ra=class t{constructor(e){this.heap=e}static from(e,r=null,n=-1){let s=[];for(let o=0;o<e.length;o++)for(let i=e[o];!i.isEmpty;i=i.nextLayer)i.maxPoint>=n&&s.push(new Vl(i,r,n,o));return s.length==1?s[0]:new t(s)}get startSide(){return this.value?this.value.startSide:0}goto(e,r=-1e9){for(let n of this.heap)n.goto(e,r);for(let n=this.heap.length>>1;n>=0;n--)rm(this.heap,n);return this.next(),this}forward(e,r){for(let n of this.heap)n.forward(e,r);for(let n=this.heap.length>>1;n>=0;n--)rm(this.heap,n);(this.to-e||this.value.endSide-r)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),rm(this.heap,0)}}};function rm(t,e){for(let r=t[e];;){let n=(e<<1)+1;if(n>=t.length)break;let s=t[n];if(n+1<t.length&&s.compare(t[n+1])>=0&&(s=t[n+1],n++),r.compare(s)<0)break;t[n]=r,t[e]=s,e=n}}var no=class{constructor(e,r,n){this.minPoint=n,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=Ra.from(e,r,n)}goto(e,r=-1e9){return this.cursor.goto(e,r),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=r,this.openStart=-1,this.next(),this}forward(e,r){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-r)<0;)this.removeActive(this.minActive);this.cursor.forward(e,r)}removeActive(e){Ol(this.active,e),Ol(this.activeTo,e),Ol(this.activeRank,e),this.minActive=Ly(this.active,this.activeTo)}addActive(e){let r=0,{value:n,to:s,rank:o}=this.cursor;for(;r<this.activeRank.length&&(o-this.activeRank[r]||s-this.activeTo[r])>0;)r++;Al(this.active,r,n),Al(this.activeTo,r,s),Al(this.activeRank,r,o),e&&Al(e,r,this.cursor.from),this.minActive=Ly(this.active,this.activeTo)}next(){let e=this.to,r=this.point;this.point=null;let n=this.openStart<0?[]:null;for(;;){let s=this.minActive;if(s>-1&&(this.activeTo[s]-this.cursor.from||this.active[s].endSide-this.cursor.startSide)<0){if(this.activeTo[s]>e){this.to=this.activeTo[s],this.endSide=this.active[s].endSide;break}this.removeActive(s),n&&Ol(n,s)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let o=this.cursor.value;if(!o.point)this.addActive(n),this.cursor.next();else if(r&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)this.cursor.next();else{this.point=o,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=o.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}}else{this.to=this.endSide=1e9;break}}if(n){this.openStart=0;for(let s=n.length-1;s>=0&&n[s]<e;s--)this.openStart++}}activeForPoint(e){if(!this.active.length)return this.active;let r=[];for(let n=this.active.length-1;n>=0&&!(this.activeRank[n]<this.pointRank);n--)(this.activeTo[n]>e||this.activeTo[n]==e&&this.active[n].endSide>=this.point.endSide)&&r.push(this.active[n]);return r.reverse()}openEnd(e){let r=0;for(let n=this.activeTo.length-1;n>=0&&this.activeTo[n]>e;n--)r++;return r}};function Dy(t,e,r,n,s,o){t.goto(e),r.goto(n);let i=n+s,a=n,c=n-e,d=!!o.boundChange;for(let l=!1;;){let u=t.to+c-r.to,h=u||t.endSide-r.endSide,p=h<0?t.to+c:r.to,g=Math.min(p,i);if(t.point||r.point?(t.point&&r.point&&bm(t.point,r.point)&&mm(t.activeForPoint(t.to),r.activeForPoint(r.to))||o.comparePoint(a,g,t.point,r.point),l=!1):(l&&o.boundChange(a),g>a&&!mm(t.active,r.active)&&o.compareRange(a,g,t.active,r.active),d&&g<i&&(u||t.openEnd(p)!=r.openEnd(p))&&(l=!0)),p>i)break;a=p,h<=0&&t.next(),h>=0&&r.next()}}function mm(t,e){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(t[r]!=e[r]&&!bm(t[r],e[r]))return!1;return!0}function Ol(t,e){for(let r=e,n=t.length-1;r<n;r++)t[r]=t[r+1];t.pop()}function Al(t,e,r){for(let n=t.length-1;n>=e;n--)t[n+1]=t[n];t[e]=r}function Ly(t,e){let r=-1,n=1e9;for(let s=0;s<e.length;s++)(e[s]-n||t[s].endSide-t[r].endSide)<0&&(r=s,n=e[s]);return r}var k$=350,S$=26,E$=60,T$=120,$$=600,R$=450;function P$(t){return Math.max(1,t.trim().split(/\s+/).length)}function M$(t){return Math.max(1500,P$(t)*k$)}function Wy(t){return t<=0?0:Math.min(6e3,Math.max(350,t*S$))}function Ky(t,e){let r=Math.min(t.length,e.length),n=0;for(;n<r&&t[n]===e[n];)n++;return n}function Jy(t,e,r){let n=Math.min(t.length,e.length)-r,s=0;for(;s<n&&t[t.length-1-s]===e[e.length-1-s];)s++;return s}function z$(t,e){let r=Math.max(1,Math.ceil(t.length/e)),n=[];for(let s=0;s<t.length;s+=r)n.push(t.slice(s,s+r));return n}function I$(t,e,r){let n=t.split(`
|
|
47
|
+
`),s=Math.max(1,Math.min(e,n.length)),o=Math.max(s,Math.min(r,n.length)),i=0;for(let c=0;c<s-1;c++)i+=n[c].length+1;let a=i;for(let c=s-1;c<o;c++)a+=n[c].length+(c<n.length-1?1:0);return[i,a]}function O$(t,e,r){let n=t.trim().split(/\s+/).filter(Boolean);if(!n.length)return[];let s=r/n.length;return n.map((o,i)=>({t:Math.round(e+s*i),text:o}))}function Qy(t,e,r,n,s,o,i,a){let c=(x,S,k,_)=>tn.of([{from:x,to:S,insert:k}],_).toJSON(),d=(x,S)=>({t:S,type:"editor.selection",path:t,ranges:[[x,x]]});if(!a||s.length===0)return[{t:o,type:"editor.change",path:t,changes:c(r,n,s,e)},d(r+s.length,o)];let l=[d(r,o)],u=e;n>r&&(l.push({t:o,type:"editor.change",path:t,changes:c(r,n,"",u)}),u-=n-r);let h=z$(s,E$),p=i/h.length,g=r;return h.forEach((x,S)=>{let k=Math.round(o+p*(S+1));l.push({t:k,type:"editor.change",path:t,changes:c(g,g,x,u)}),g+=x.length,u+=x.length,l.push(d(g,k))}),l}function A$(t,e,r,n,s,o){let i=Ky(e,r),a=Jy(e,r,i);return Qy(t,e.length,i,e.length-a,r.slice(i,r.length-a),n,s,o)}function N$(t,e,r,n){let s=[];for(let i=t.indexOf(e);i>=0;i=t.indexOf(e,i+Math.max(1,e.length)))s.push(i);let o=e.length>40?`${e.slice(0,40)}\u2026`:e;if(s.length===0)throw new Error(`Step ${n}: edit \`find\` not found in the file: ${JSON.stringify(o)}. The snippet must match the current contents exactly (including whitespace).`);if(r==null){if(s.length>1)throw new Error(`Step ${n}: edit \`find\` ${JSON.stringify(o)} appears ${s.length} times \u2014 set \`occurrence\` (1-based) to pick one.`);return s[0]}if(r<1||r>s.length)throw new Error(`Step ${n}: edit \`occurrence\` ${r} is out of range \u2014 \`find\` ${JSON.stringify(o)} appears ${s.length} time(s).`);return s[r-1]}function C$(t,e,r){let n=t.indexOf(e),s=e.length>40?`${e.slice(0,40)}\u2026`:e;if(n<0)throw new Error(`Step ${r}: \`highlightCode\` snippet not found in the file: ${JSON.stringify(s)}. It must match the file's current contents exactly (including whitespace).`);if(t.indexOf(e,n+Math.max(1,e.length))>=0)throw new Error(`Step ${r}: \`highlightCode\` snippet ${JSON.stringify(s)} appears more than once \u2014 extend it until it is unique in the file.`);return n}function j$(t,e,r,n,s,o,i){let a=Math.max(1,r.reduce((p,g)=>p+g.replace.length,0)),c=[],d=e,l=n,u=null,h=0;for(let p of r){let g=N$(d,p.find,p.occurrence,i),x=Ky(p.find,p.replace),S=Jy(p.find,p.replace,x),k=p.replace.slice(x,p.replace.length-S),_=g+x,m=g+p.find.length-S,$=s*(Math.max(1,k.length)/a);c.push(...Qy(t,d.length,_,m,k,l,$,o)),d=d.slice(0,g)+p.replace+d.slice(g+p.find.length),l+=$,h+=k.length,u=k.length>0?[_,_+k.length]:null}return{events:c,content:d,lastRange:u,inserted:h}}function ev(t,e={}){let r={};for(let u of t.files??[])r[u.path]=u.content??"";let n=t.files?.[0]?.path??null,s={...r},o=new Set(Object.keys(r)),i=[],a=[],c=n,d=1;t.steps.forEach((u,h)=>{let p=u.file??c??void 0,g=!1;p&&(o.has(p)||(i.push({t:d,type:"fs.create",path:p}),o.add(p),s[p]=s[p]??""),c!==p&&(i.push({t:d,type:"editor.switch",path:p}),c=p,g=!0));let x=Math.max(g?$$:0,u.chapter?R$:0),S=d+x,k=h+1,_=p&&s[p]||"",m=p!=null&&u.code!=null,$=p!=null&&(u.edits?.length??0)>0;if(u.code!=null&&u.edits?.length)throw new Error(`Step ${k}: use either \`code\` or \`edits\`, not both.`);if(m&&_.length>0&&!u.rewrite)throw new Error(`Step ${k}: "${p}" already has code \u2014 use \`edits\` (small find/replace) to change it, or a \`say\`+\`highlight\` step (no code) to explain it. For a deliberate full rewrite set \`rewrite: true\`.`);if($&&_.length===0)throw new Error(`Step ${k}: \`edits\` target "${p}" which has no code yet \u2014 introduce it first with top-level \`files\` or a \`code\` step.`);let f=$?u.edits.reduce((C,q)=>C+q.replace.length,0):0,E=Math.max(u.say?M$(u.say):0,Wy(f),u.terminal?1400:0,1200),N=u.holdMs??e.sayDurationsMs?.[h]??E,B=f>0?Math.min(Wy(f),Math.round(N*.7)):0,U=null;if(m&&p)i.push(...A$(p,_,u.code,S,0,!1)),s[p]=u.code;else if($&&p){let C=j$(p,_,u.edits,S,B,u.typing!==!1,k);i.push(...C.events),s[p]=C.content,U=C.lastRange}if(p){let C;if(u.highlightCode!=null){let q=C$(s[p]??"",u.highlightCode,k);C=[q,q+u.highlightCode.length]}else u.highlight?C=I$(s[p]??"",u.highlight[0],u.highlight[1]):C=U;C&&i.push({t:Math.round(S+B),type:"editor.selection",path:p,ranges:[C]})}if(u.terminal){let C=u.terminal.replace(/\r?\n/g,`\r
|
|
48
|
+
`);i.push({t:Math.round(S+Math.min(300,N*.2)),type:"term.data",data:C.endsWith(`\r
|
|
49
|
+
`)?C:C+`\r
|
|
50
|
+
`})}u.chapter&&i.push({t:d,type:"marker",label:u.chapter}),u.say&&a.push({t:S,dur:N,text:u.say,words:O$(u.say,S,N)}),d=S+N+T$}),i.sort((u,h)=>u.t-h.t);let l=[{t:0,vfs:{...r},activeFile:n,terminalState:""}];return{manifest:{version:2,title:t.title,createdAt:e.createdAt??new Date().toISOString(),durationMs:Math.max(d,1e3)},events:i,snapshots:l,captions:a.length?a:void 0}}var tv=`Render an interactive code walkthrough into ONE self-contained .html file.
|
|
51
|
+
|
|
52
|
+
You (the agent) are the author: gather the code and explanation yourself, then describe the walkthrough as an ordered list of \`steps\`. The server turns it into a standalone page that replays inside a real CodeMirror editor \u2014 the viewer scrubs a timeline, watches the code TYPE OUT in sync with narration, pauses anywhere, and can edit/run the code. No server, no dependencies; opens in any browser.
|
|
53
|
+
|
|
54
|
+
There's a sibling tool, create_whiteboard_walkthrough, for CONCEPTUAL explanations drawn as a diagram on a board (architecture, data flow, mental models). If the user hasn't indicated whether they want a code walkthrough or a whiteboard one \u2014 or whether to include voice (pass voice:false to skip narration) \u2014 ASK them before authoring.
|
|
55
|
+
|
|
56
|
+
Author it like a TEACHER in a real video course \u2014 explaining, not rushing. The goal is the feel of a screencast: introduce a file, then mostly point at things and explain them, switching files and making small edits as you go.
|
|
57
|
+
|
|
58
|
+
HOW TO TEACH IT \u2014 this is a LESSON, built the way people actually learn (cognitive load theory + worked examples). Two layers: the ARC of the whole lesson, and how you EXPLAIN each piece.
|
|
59
|
+
|
|
60
|
+
The arc \u2014 tell a story, don't tour files:
|
|
61
|
+
- HOOK first. Open on the PROBLEM or the "why", never "here's a file". Make the viewer feel the pain the code solves (e.g. show the naive version that fires on every keystroke and hammers the server). Curiosity is what makes them watch.
|
|
62
|
+
- ORIENT. Say what they'll have by the end, and connect to what they already know.
|
|
63
|
+
- BUILD it one idea at a time, in a logical order. Group beats into CHAPTERS named after the SUB-GOAL you're achieving ("Cancel the stale timer"), not generic labels ("Step 2").
|
|
64
|
+
- PAY IT OFF. Show it actually working \u2014 a terminal run, a result \u2014 so the idea lands and feels earned.
|
|
65
|
+
- RECAP. End with one beat that names the key takeaway.
|
|
66
|
+
|
|
67
|
+
Explaining each piece \u2014 protect the viewer's attention (don't overload it):
|
|
68
|
+
- INTENT before code: say WHY, then WHAT ("we don't want a request on every keystroke" \u2192 THEN highlight/type the fix). A line of code with a reason sticks; without one it's noise.
|
|
69
|
+
- ONE new idea per beat. Never introduce two concepts at once \u2014 split them. This is the single biggest thing that keeps a lesson learnable.
|
|
70
|
+
- Surface the reasoning that isn't obvious from the code ("this returns a NEW array, so React re-renders") \u2014 that insight is the part viewers actually came to learn.
|
|
71
|
+
- Each beat builds on the last, like a worked example unfolding \u2014 no leaps.
|
|
72
|
+
- Cut anything that isn't teaching: don't show or highlight code irrelevant to the current beat.
|
|
73
|
+
|
|
74
|
+
GRANULARITY \u2014 MANY SMALL BEATS, NOT A FEW MONOLOGUES (this is the #1 thing to get right):
|
|
75
|
+
- Use as MANY steps as the material needs \u2014 lean HIGH. Even a small feature is usually 20\u201350 steps, not 6. Every line of code, every distinct idea, every "and then\u2026" is its OWN step.
|
|
76
|
+
- Each \`say\` is ONE SHORT BEAT \u2014 a single idea, roughly 4\u201314 words (one breath). If a sentence contains an "and", a comma joining two ideas, or two facts, SPLIT it into two steps.
|
|
77
|
+
- Write the narration as ONE continuous spoken script, then chop it into these little beats. Read in order, the \`say\` lines MUST flow as a single natural explanation \u2014 each beat continues the one before it (lead with connectors like "so", "then", "now", "which means", "but"). Do NOT write each step as an isolated, self-contained sentence.
|
|
78
|
+
- Every beat carries its OWN tight highlight, so the pointer moves with the words. Short beat + tight highlight + the matching code, over and over.
|
|
79
|
+
- Rule of thumb: prefer 40 four-second beats over 6 thirty-second monologues. If a step's \`say\` is longer than ~15 words, it's two steps.
|
|
80
|
+
|
|
81
|
+
HIGHLIGHTING IS THE OTHER HALF. It's how the viewer knows what each beat is about \u2014 without it, a big file on screen is meaningless. EVERY step that shows or discusses code MUST point at the exact part with \`highlightCode\` (the player scrolls it into view and makes it glow).
|
|
82
|
+
|
|
83
|
+
Three kinds of step:
|
|
84
|
+
1. INTRODUCE a file (once): \`file\` + \`code\` (full initial contents \u2014 types out). Or declare already-existing files in top-level \`files\` so they appear in full at t=0 with no typing.
|
|
85
|
+
2. SHOW / explain (no code!): \`file\` (to switch tabs) + \`say\` + \`highlight\`. This is the MOST COMMON step \u2014 talk about code that is already on screen. Do NOT resend \`code\` to highlight it.
|
|
86
|
+
3. EDIT a small piece: \`edits: [{ find, replace }]\` \u2014 a find/replace delta that types out only its changed region. Use this instead of re-sending the whole file. \`find\` must match the current contents exactly; add \`occurrence\` if the snippet isn't unique.
|
|
87
|
+
|
|
88
|
+
Hard rules (the server enforces these):
|
|
89
|
+
- After a file is introduced, NEVER send \`code\` for it again \u2014 use \`edits\` to change it, or a SHOW step to explain it. (Sending whole-file \`code\` to an existing file is rejected unless you set \`rewrite: true\`.)
|
|
90
|
+
- A step uses EITHER \`code\` OR \`edits\`, never both.
|
|
91
|
+
- Switch files with a code-less SHOW step (just \`file\` + \`say\`/\`highlight\`), like clicking a tab.
|
|
92
|
+
|
|
93
|
+
Voice/highlight sync: each step's highlight appears in sync with the START of its narration, so keep every step to ONE subject. MATCH the highlight to that subject's scope \u2014 a single token/line when you name one thing, or the WHOLE multi-line block when you explain a block.
|
|
94
|
+
|
|
95
|
+
Voice: pick \`voiceName\` (the narrator's voice \u2014 e.g. cedar, nova, onyx, sage, shimmer \u2026; see the field for the full list and their character) and set \`voiceTone\` to fit the TOPIC and audience \u2014 e.g. "upbeat and encouraging, like a friendly bootcamp instructor" for a beginner tutorial, "calm, precise, and reassuring" for a tricky debugging/security topic, "energetic and curious" for a fun feature demo. The tone steers how the narrator sounds; a natural human delivery is always layered on top.
|
|
96
|
+
|
|
97
|
+
Intro & outro: the server automatically frames the walkthrough with a spoken intro beat and outro beat, so DON'T write your own welcome or sign-off steps \u2014 start your steps at the first real content. Customize the wording via \`intro\`/\`outro\` (a tailored hook + recap read better than the title-based defaults).
|
|
98
|
+
|
|
99
|
+
Highlighting \u2014 light up exactly what you're explaining (no more, no less):
|
|
100
|
+
- PREFER \`highlightCode\`: paste the EXACT code you're talking about. The server finds it in the current file and highlights precisely those characters (and scrolls + glows it into view); it never drifts when edits move line numbers.
|
|
101
|
+
- \`highlightCode\` can be ONE line OR MANY. If you're explaining a whole construct \u2014 a function body, a \`useEffect\`, a JSX element, an \`if\`/\`try\`/\`map\` block \u2014 pass that ENTIRE block as the snippet (newlines and all) so the whole thing lights up. If you're naming one specific thing \u2014 a variable, a prop, a condition, a return \u2014 pass just that. Don't shrink a multi-line subject down to a single line.
|
|
102
|
+
- The snippet must be UNIQUE in the file. If a short one isn't, EXTEND it (include a surrounding line) until it is \u2014 never shrink your intended highlight just to disambiguate.
|
|
103
|
+
- Every step that discusses already-written code should point at it this way.
|
|
104
|
+
- On an \`edits\` step the code you just wrote is highlighted automatically once it finishes typing \u2014 do NOT add a \`highlightCode\` for code you're writing this step (it isn't on screen yet). Only one thing is highlighted at a time, and any prior highlight clears the moment you start typing.
|
|
105
|
+
|
|
106
|
+
Worked shape (note: snippet highlights, and how few steps carry code):
|
|
107
|
+
files: [{ path: "useDebounce.ts", content: "<the existing hook in full>" }]
|
|
108
|
+
steps: // SHORT beats \u2014 read top-to-bottom they form one continuous explanation
|
|
109
|
+
- { file: "useDebounce.ts", chapter: "The hook", say: "Here's the hook.", highlightCode: "export function useDebounce(value, delay)" }
|
|
110
|
+
- { say: "It takes a value,", highlightCode: "value" }
|
|
111
|
+
- { say: "and a delay.", highlightCode: "delay" }
|
|
112
|
+
- { say: "First, state to hold the debounced copy.", highlightCode: "useState(value)" }
|
|
113
|
+
- { say: "Then an effect, which is the engine.", highlightCode: "useEffect(() => {\\n const id = setTimeout(() => setDebounced(value), delay);\\n return () => clearTimeout(id);\\n }, [value, delay])" }
|
|
114
|
+
- { say: "It starts a timer,", highlightCode: "setTimeout(() => setDebounced(value), delay)" }
|
|
115
|
+
- { say: "that updates the value after the delay.", highlightCode: "setDebounced(value)" }
|
|
116
|
+
- { say: "And here's the trick:", highlightCode: "return () => clearTimeout(id)" }
|
|
117
|
+
- { say: "the cleanup cancels it if the value changes first.", highlightCode: "clearTimeout(id)" }
|
|
118
|
+
- { file: "SearchInput.tsx", chapter: "Using it", say: "Now, over in the component.", highlightCode: "const query = useState" }
|
|
119
|
+
- { say: "We wrap the live query.", edits: [{ find: "const debounced = query", replace: "const debounced = useDebounce(query, 400)" }] }
|
|
120
|
+
// Concatenated: "Here's the hook. It takes a value, and a delay. First, state to hold the
|
|
121
|
+
// debounced copy. Then an effect, which is the engine. It starts a timer, that updates the
|
|
122
|
+
// value after the delay. And here's the trick: the cleanup cancels it if the value changes
|
|
123
|
+
// first. Now, over in the component. We wrap the live query." \u2014 one natural, flowing script.
|
|
124
|
+
|
|
125
|
+
How to surface the result:
|
|
126
|
+
- The PRIMARY deliverable is a URL on the local server: http://127.0.0.1:<port>/<id>.html (returned as a resource_link). Give this link to the USER to open the full interactive player \u2014 voice included \u2014 in their browser. Present it as a plain clickable link; do NOT wrap it in an iframe or save it as a file.
|
|
127
|
+
- A ui://flowcast/<id> resource_link is also returned for resource-aware hosts; resources/read on it returns the full self-contained HTML (the offline fallback for hosts that can't reach the loopback URL).
|
|
128
|
+
- If no local server is available, the tool inlines the full self-contained HTML instead (or points you at the ui:// resource for large pages) \u2014 save that to your outputs dir and present it.
|
|
129
|
+
|
|
130
|
+
Only pass outputPath if you specifically want the server to ALSO write the .html to a path (e.g. a local Claude Code workspace); a file:// link is returned only then.`;var D$={id:"code",tool:{name:"create_walkthrough",title:"Create interactive code walkthrough",description:tv},promptLine:"\u2022 CODE \u2014 real code types out in an editor with synced highlights \u2192 create_walkthrough",schema:Qp,makeBeat:t=>({say:t}),forceOutro:!1,compile:(t,e)=>ev(t,e)},rv=D$;var L$="TTS voice to narrate with \u2014 pick the one that best fits the topic/audience. Defaults to cedar (warm, natural). Options: "+Lr.map(t=>`${t} (${fs[t]})`).join(", ")+".",Z$=G.object({say:G.string().optional().describe("Narration for this beat \u2014 ONE short idea (4\u201314 words), spoken aloud. Write the beats so that, read in order, they form one continuous explanation."),show:G.union([G.string(),G.array(G.string())]).optional().describe("Mermaid node id(s) to REVEAL on the board this beat (drawn in, with any edges to already-shown nodes). The camera pans/zooms to it as you introduce it. Reveal one node per beat for a natural build-up."),point:G.union([G.string(),G.array(G.string())]).optional().describe("Mermaid node id(s) to highlight + zoom to this beat (already revealed) \u2014 like tapping the board when you refer back to something."),chapter:G.string().optional().describe("If set, starts a named chapter at this beat (timeline marker)."),holdMs:G.number().optional().describe("Beat duration in ms. Defaults to a duration derived from the narration.")}),ym={title:G.string().describe("Title of the whiteboard walkthrough (header + filename)."),outputPath:G.string().optional().describe("Optional path to also write the .html to (same mapping as create_walkthrough)."),voiceName:G.enum(Lr).optional().describe(L$),voiceTone:G.string().optional().describe("How the narrator should SOUND, matched to the topic \u2014 steers the TTS voice. One or two phrases describing affect/emotion, e.g. 'upbeat and encouraging, like a friendly bootcamp instructor' for a beginner concept, 'calm, precise, and reassuring' for a security or infra topic, 'energetic and curious' for a fun explainer. Leave unset for the default relaxed-senior-engineer tone. (A natural, human delivery is always applied on top.)"),intro:G.string().optional().describe("Opening line spoken BEFORE the diagram starts \u2014 a one- or two-sentence hook (greet + what this explains + why). The server shows it as a title card and adds it as the first beat (voiced), so DON'T write your own welcome step. Defaults to a title-based welcome; set to '' to skip."),outro:G.string().optional().describe("Closing line spoken AFTER the last beat \u2014 a short CONCLUSION that wraps up: one or two sentences recapping the big idea + a sign-off, while the camera pulls back to the whole diagram. EVERY whiteboard gets this wrap-up automatically (it can't be turned off), so DON'T write your own ending beat \u2014 just set the wording here. Defaults to a title-based wrap-up."),mermaid:G.string().describe("A Mermaid flowchart describing the diagram, e.g.:\n flowchart LR\n A[Browser] -->|request| B[Server]\n B -->|query| C[(Database)]\nSupports flowchart/graph with directions LR/RL/TB/BT, node shapes [], (), ([]), (()), {}, {{}}, [[]], [()], and edges -->, ---, -.->, ==> with |labels|.\nCOLOR (pastel): tint nodes with Mermaid styling \u2014 either `A[Label]:::pink` / `class A,B blue` using a built-in pastel tone (pink, rose, peach, amber, yellow, green, mint, teal, sky, blue, indigo, purple, lavender, gray, slate), or `style A fill:#dfe6fb,stroke:#8a9ef0,color:#2b3a80` for a custom soft fill. Use color to GROUP related nodes or flag ONE key node \u2014 sparingly, 2\u20133 tones max, never a different color per node (a rainbow board reads as noise). Default is clean WHITE shapes. Use clear node ids \u2014 the beats reference them."),theme:G.enum(["mono","pastel"]).default("mono").describe("'mono' (default, PREFERRED): clean white shapes \u2014 use this for almost every board. 'pastel': auto-tints EVERY node a rotating pastel \u2014 only for boards that genuinely ARE a color-coded category map; it usually looks like noise otherwise. Prefer leaving it 'mono' and adding color to a FEW nodes by hand. Per-node Mermaid colors always win over the theme."),appearance:G.enum(["system","light","dark"]).default("system").describe("Light/dark theme of the BOARD (separate from `theme`'s node coloring). 'system' (default) follows the viewer's OS and they can toggle; 'light'/'dark' pin it. Dark mode shows white/mono shapes as dark cards; your explicit colors are kept."),icons:G.record(G.string()).optional().describe("Optional map of node id \u2192 glyph drawn above the label, to make a node instantly recognizable. Value is a built-in icon name (database, server, cloud, user, users, lock, key, globe, gear, bolt, check, warning, file, folder, code, api, browser, mobile, mail, search, heart, star, clock, money, box, cart, shield, flag, send, rocket) OR a custom SVG path `d` string on a 24\xD724 grid (outline style). Only add icons when they aid recognition."),shapes:G.record(G.string()).optional().describe("Optional map of node id \u2192 SHAPE, overriding the node's bracket shape. Names: rect, round/rounded, stadium/pill, circle, diamond, hexagon, subroutine, cylinder/database, plus stack (offset stacked rectangles \u2014 collections/replicas/layers) and cloud (internet / cloud service). You can also set a shape inline in the mermaid via `id@{ shape: stack }`. Use a non-default shape only when it carries meaning."),images:G.record(G.string().url()).optional().describe("Optional map of node id \u2192 IMAGE URL (http/https). The server fetches each, downscales it (longest side ~520px), re-encodes to a compact WebP, and bakes it into the HTML as a data URI \u2014 so the node shows a real screenshot/diagram/logo with its label as a caption. Use only when a picture genuinely helps, and keep it to a FEW (each image still adds weight). A URL that fails to load just falls back to a normal box."),steps:G.array(Z$).min(1).describe("The ordered timeline as a LESSON: open on the problem/why, then reveal the diagram ONE node at a time while explaining, point back at earlier nodes, and recap. MANY short beats; the `say` lines must read as one continuous script.")},JZ=G.object(ym);var gv=Object.defineProperty,B$=(t,e,r)=>e in t?gv(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,q$=(t,e)=>{for(var r in e)gv(t,r,{get:e[r],enumerable:!0})},V$=(t,e,r)=>B$(t,typeof e!="symbol"?e+"":e,r),_v={};q$(_v,{Graph:()=>rn,alg:()=>$m,json:()=>yv,version:()=>U$});var F$=Object.defineProperty,bv=(t,e)=>{for(var r in e)F$(t,r,{get:e[r],enumerable:!0})},rn=class{constructor(t){this._isDirected=!0,this._isMultigraph=!1,this._isCompound=!1,this._nodes={},this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={},this._nodeCount=0,this._edgeCount=0,this._defaultNodeLabelFn=()=>{},this._defaultEdgeLabelFn=()=>{},t&&(this._isDirected="directed"in t?t.directed:!0,this._isMultigraph="multigraph"in t?t.multigraph:!1,this._isCompound="compound"in t?t.compound:!1),this._isCompound&&(this._parent={},this._children={},this._children["\0"]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(t){return this._label=t,this}graph(){return this._label}setDefaultNodeLabel(t){return typeof t!="function"?this._defaultNodeLabelFn=()=>t:this._defaultNodeLabelFn=t,this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){return this.nodes().filter(t=>Object.keys(this._in[t]).length===0)}sinks(){return this.nodes().filter(t=>Object.keys(this._out[t]).length===0)}setNodes(t,e){return t.forEach(r=>{e!==void 0?this.setNode(r,e):this.setNode(r)}),this}setNode(t,e){return t in this._nodes?(arguments.length>1&&(this._nodes[t]=e),this):(this._nodes[t]=arguments.length>1?e:this._defaultNodeLabelFn(t),this._isCompound&&(this._parent[t]="\0",this._children[t]={},this._children["\0"][t]=!0),this._in[t]={},this._preds[t]={},this._out[t]={},this._sucs[t]={},++this._nodeCount,this)}node(t){return this._nodes[t]}hasNode(t){return t in this._nodes}removeNode(t){if(t in this._nodes){let e=r=>this.removeEdge(this._edgeObjs[r]);delete this._nodes[t],this._isCompound&&(this._removeFromParentsChildList(t),delete this._parent[t],this.children(t).forEach(r=>{this.setParent(r)}),delete this._children[t]),Object.keys(this._in[t]).forEach(e),delete this._in[t],delete this._preds[t],Object.keys(this._out[t]).forEach(e),delete this._out[t],delete this._sucs[t],--this._nodeCount}return this}setParent(t,e){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e===void 0)e="\0";else{e+="";for(let r=e;r!==void 0;r=this.parent(r))if(r===t)throw new Error("Setting "+e+" as parent of "+t+" would create a cycle");this.setNode(e)}return this.setNode(t),this._removeFromParentsChildList(t),this._parent[t]=e,this._children[e][t]=!0,this}parent(t){if(this._isCompound){let e=this._parent[t];if(e!=="\0")return e}}children(t="\0"){if(this._isCompound){let e=this._children[t];if(e)return Object.keys(e)}else{if(t==="\0")return this.nodes();if(this.hasNode(t))return[]}return[]}predecessors(t){let e=this._preds[t];if(e)return Object.keys(e)}successors(t){let e=this._sucs[t];if(e)return Object.keys(e)}neighbors(t){let e=this.predecessors(t);if(e){let r=new Set(e);for(let n of this.successors(t))r.add(n);return Array.from(r.values())}}isLeaf(t){let e;return this.isDirected()?e=this.successors(t):e=this.neighbors(t),e.length===0}filterNodes(t){let e=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});e.setGraph(this.graph()),Object.entries(this._nodes).forEach(([s,o])=>{t(s)&&e.setNode(s,o)}),Object.values(this._edgeObjs).forEach(s=>{e.hasNode(s.v)&&e.hasNode(s.w)&&e.setEdge(s,this.edge(s))});let r={},n=s=>{let o=this.parent(s);return!o||e.hasNode(o)?(r[s]=o??void 0,o??void 0):o in r?r[o]:n(o)};return this._isCompound&&e.nodes().forEach(s=>e.setParent(s,n(s))),e}setDefaultEdgeLabel(t){return typeof t!="function"?this._defaultEdgeLabelFn=()=>t:this._defaultEdgeLabelFn=t,this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(t,e){return t.reduce((r,n)=>(e!==void 0?this.setEdge(r,n,e):this.setEdge(r,n),n)),this}setEdge(t,e,r,n){let s,o,i,a,c=!1;typeof t=="object"&&t!==null&&"v"in t?(s=t.v,o=t.w,i=t.name,arguments.length===2&&(a=e,c=!0)):(s=t,o=e,i=n,arguments.length>2&&(a=r,c=!0)),s=""+s,o=""+o,i!==void 0&&(i=""+i);let d=Pa(this._isDirected,s,o,i);if(d in this._edgeLabels)return c&&(this._edgeLabels[d]=a),this;if(i!==void 0&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(s),this.setNode(o),this._edgeLabels[d]=c?a:this._defaultEdgeLabelFn(s,o,i);let l=H$(this._isDirected,s,o,i);return s=l.v,o=l.w,Object.freeze(l),this._edgeObjs[d]=l,nv(this._preds[o],s),nv(this._sucs[s],o),this._in[o][d]=l,this._out[s][d]=l,this._edgeCount++,this}edge(t,e,r){let n=arguments.length===1?vm(this._isDirected,t):Pa(this._isDirected,t,e,r);return this._edgeLabels[n]}edgeAsObj(t,e,r){let n=arguments.length===1?this.edge(t):this.edge(t,e,r);return typeof n!="object"?{label:n}:n}hasEdge(t,e,r){return(arguments.length===1?vm(this._isDirected,t):Pa(this._isDirected,t,e,r))in this._edgeLabels}removeEdge(t,e,r){let n=arguments.length===1?vm(this._isDirected,t):Pa(this._isDirected,t,e,r),s=this._edgeObjs[n];if(s){let o=s.v,i=s.w;delete this._edgeLabels[n],delete this._edgeObjs[n],sv(this._preds[i],o),sv(this._sucs[o],i),delete this._in[i][n],delete this._out[o][n],this._edgeCount--}return this}inEdges(t,e){return this.isDirected()?this.filterEdges(this._in[t],t,e):this.nodeEdges(t,e)}outEdges(t,e){return this.isDirected()?this.filterEdges(this._out[t],t,e):this.nodeEdges(t,e)}nodeEdges(t,e){if(t in this._nodes)return this.filterEdges({...this._in[t],...this._out[t]},t,e)}_removeFromParentsChildList(t){delete this._children[this._parent[t]][t]}filterEdges(t,e,r){if(!t)return;let n=Object.values(t);return r?n.filter(s=>s.v===e&&s.w===r||s.v===r&&s.w===e):n}};function nv(t,e){t[e]?t[e]++:t[e]=1}function sv(t,e){t[e]!==void 0&&!--t[e]&&delete t[e]}function Pa(t,e,r,n){let s=""+e,o=""+r;if(!t&&s>o){let i=s;s=o,o=i}return s+""+o+""+(n===void 0?"\0":n)}function H$(t,e,r,n){let s=""+e,o=""+r;if(!t&&s>o){let a=s;s=o,o=a}let i={v:s,w:o};return n&&(i.name=n),i}function vm(t,e){return Pa(t,e.v,e.w,e.name)}var U$="4.0.1",yv={};bv(yv,{read:()=>W$,write:()=>G$});function G$(t){let e={options:{directed:t.isDirected(),multigraph:t.isMultigraph(),compound:t.isCompound()},nodes:Y$(t),edges:X$(t)},r=t.graph();return r!==void 0&&(e.value=structuredClone(r)),e}function Y$(t){return t.nodes().map(e=>{let r=t.node(e),n=t.parent(e),s={v:e};return r!==void 0&&(s.value=r),n!==void 0&&(s.parent=n),s})}function X$(t){return t.edges().map(e=>{let r=t.edge(e),n={v:e.v,w:e.w};return e.name!==void 0&&(n.name=e.name),r!==void 0&&(n.value=r),n})}function W$(t){let e=new rn(t.options);return t.value!==void 0&&e.setGraph(t.value),t.nodes.forEach(r=>{e.setNode(r.v,r.value),r.parent&&e.setParent(r.v,r.parent)}),t.edges.forEach(r=>{e.setEdge({v:r.v,w:r.w,name:r.name},r.value)}),e}var $m={};bv($m,{CycleException:()=>Hl,bellmanFord:()=>vv,components:()=>Q$,dijkstra:()=>Fl,dijkstraAll:()=>rR,findCycles:()=>nR,floydWarshall:()=>oR,isAcyclic:()=>aR,postorder:()=>lR,preorder:()=>uR,prim:()=>dR,shortestPaths:()=>fR,tarjan:()=>xv,topsort:()=>kv});var K$=()=>1;function vv(t,e,r,n){return J$(t,String(e),r||K$,n||function(s){return t.outEdges(s)})}function J$(t,e,r,n){let s={},o,i=0,a=t.nodes(),c=function(u){let h=r(u);s[u.v].distance+h<s[u.w].distance&&(s[u.w]={distance:s[u.v].distance+h,predecessor:u.v},o=!0)},d=function(){a.forEach(function(u){n(u).forEach(function(h){let p=h.v===u?h.v:h.w,g=p===h.v?h.w:h.v;c({v:p,w:g})})})};a.forEach(function(u){let h=u===e?0:Number.POSITIVE_INFINITY;s[u]={distance:h,predecessor:""}});let l=a.length;for(let u=1;u<l&&(o=!1,i++,d(),!!o);u++);if(i===l-1&&(o=!1,d(),o))throw new Error("The graph contains a negative weight cycle");return s}function Q$(t){let e={},r=[],n;function s(o){o in e||(e[o]=!0,n.push(o),t.successors(o).forEach(s),t.predecessors(o).forEach(s))}return t.nodes().forEach(function(o){n=[],s(o),n.length&&r.push(n)}),r}var wv=class{constructor(){this._arr=[],this._keyIndices={}}size(){return this._arr.length}keys(){return this._arr.map(t=>t.key)}has(t){return t in this._keyIndices}priority(t){let e=this._keyIndices[t];if(e!==void 0)return this._arr[e].priority}min(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key}add(t,e){let r=this._keyIndices,n=String(t);if(!(n in r)){let s=this._arr,o=s.length;return r[n]=o,s.push({key:n,priority:e}),this._decrease(o),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);let t=this._arr.pop();return delete this._keyIndices[t.key],this._heapify(0),t.key}decrease(t,e){let r=this._keyIndices[t];if(r===void 0)throw new Error(`Key not found: ${t}`);let n=this._arr[r].priority;if(e>n)throw new Error(`New priority is greater than current priority. Key: ${t} Old: ${n} New: ${e}`);this._arr[r].priority=e,this._decrease(r)}_heapify(t){let e=this._arr,r=2*t,n=r+1,s=t;r<e.length&&(s=e[r].priority<e[s].priority?r:s,n<e.length&&(s=e[n].priority<e[s].priority?n:s),s!==t&&(this._swap(t,s),this._heapify(s)))}_decrease(t){let e=this._arr,r=e[t].priority,n;for(;t!==0&&(n=t>>1,!(e[n].priority<r));)this._swap(t,n),t=n}_swap(t,e){let r=this._arr,n=this._keyIndices,s=r[t],o=r[e];r[t]=o,r[e]=s,n[o.key]=t,n[s.key]=e}},eR=()=>1;function Fl(t,e,r,n){let s=function(o){return t.outEdges(o)};return tR(t,String(e),r||eR,n||s)}function tR(t,e,r,n){let s={},o=new wv,i,a,c=function(d){let l=d.v!==i?d.v:d.w,u=s[l],h=r(d),p=a.distance+h;if(h<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+d+" Weight: "+h);p<u.distance&&(u.distance=p,u.predecessor=i,o.decrease(l,p))};for(t.nodes().forEach(function(d){let l=d===e?0:Number.POSITIVE_INFINITY;s[d]={distance:l,predecessor:""},o.add(d,l)});o.size()>0&&(i=o.removeMin(),a=s[i],a.distance!==Number.POSITIVE_INFINITY);)n(i).forEach(c);return s}function rR(t,e,r){return t.nodes().reduce(function(n,s){return n[s]=Fl(t,s,e,r),n},{})}function xv(t){let e=0,r=[],n={},s=[];function o(i){let a=n[i]={onStack:!0,lowlink:e,index:e++};if(r.push(i),t.successors(i).forEach(function(c){c in n?n[c].onStack&&(a.lowlink=Math.min(a.lowlink,n[c].index)):(o(c),a.lowlink=Math.min(a.lowlink,n[c].lowlink))}),a.lowlink===a.index){let c=[],d;do d=r.pop(),n[d].onStack=!1,c.push(d);while(i!==d);s.push(c)}}return t.nodes().forEach(function(i){i in n||o(i)}),s}function nR(t){return xv(t).filter(function(e){return e.length>1||e.length===1&&t.hasEdge(e[0],e[0])})}var sR=()=>1;function oR(t,e,r){return iR(t,e||sR,r||function(n){return t.outEdges(n)})}function iR(t,e,r){let n={},s=t.nodes();return s.forEach(function(o){n[o]={},n[o][o]={distance:0,predecessor:""},s.forEach(function(i){o!==i&&(n[o][i]={distance:Number.POSITIVE_INFINITY,predecessor:""})}),r(o).forEach(function(i){let a=i.v===o?i.w:i.v,c=e(i);n[o][a]={distance:c,predecessor:o}})}),s.forEach(function(o){let i=n[o];s.forEach(function(a){let c=n[a];s.forEach(function(d){let l=c[o],u=i[d],h=c[d],p=l.distance+u.distance;p<h.distance&&(h.distance=p,h.predecessor=u.predecessor)})})}),n}var Hl=class extends Error{constructor(...t){super(...t)}};function kv(t){let e={},r={},n=[];function s(o){if(o in r)throw new Hl;o in e||(r[o]=!0,e[o]=!0,t.predecessors(o).forEach(s),delete r[o],n.push(o))}if(t.sinks().forEach(s),Object.keys(e).length!==t.nodeCount())throw new Hl;return n}function aR(t){try{kv(t)}catch(e){if(e instanceof Hl)return!1;throw e}return!0}function cR(t,e,r,n,s){Array.isArray(e)||(e=[e]);let o=a=>{var c;return(c=t.isDirected()?t.successors(a):t.neighbors(a))!=null?c:[]},i={};return e.forEach(function(a){if(!t.hasNode(a))throw new Error("Graph does not have node: "+a);s=Sv(t,a,r==="post",i,o,n,s)}),s}function Sv(t,e,r,n,s,o,i){return e in n||(n[e]=!0,r||(i=o(i,e)),s(e).forEach(function(a){i=Sv(t,a,r,n,s,o,i)}),r&&(i=o(i,e))),i}function Ev(t,e,r){return cR(t,e,r,function(n,s){return n.push(s),n},[])}function lR(t,e){return Ev(t,e,"post")}function uR(t,e){return Ev(t,e,"pre")}function dR(t,e){let r=new rn,n={},s=new wv,o;function i(c){let d=c.v===o?c.w:c.v,l=s.priority(d);if(l!==void 0){let u=e(c);u<l&&(n[d]=o,s.decrease(d,u))}}if(t.nodeCount()===0)return r;t.nodes().forEach(function(c){s.add(c,Number.POSITIVE_INFINITY),r.setNode(c)}),s.decrease(t.nodes()[0],0);let a=!1;for(;s.size()>0;){if(o=s.removeMin(),o in n)r.setEdge(o,n[o]);else{if(a)throw new Error("Input graph is not connected: "+t);a=!0}t.nodeEdges(o).forEach(i)}return r}function fR(t,e,r,n){return hR(t,e,r,n??(s=>{let o=t.outEdges(s);return o??[]}))}function hR(t,e,r,n){if(r===void 0)return Fl(t,e,r,n);let s=!1,o=t.nodes();for(let i=0;i<o.length;i++){let a=n(o[i]);for(let c=0;c<a.length;c++){let d=a[c],l=d.v===o[i]?d.v:d.w,u=l===d.v?d.w:d.v;r({v:l,w:u})<0&&(s=!0)}if(s)return vv(t,e,r,n)}return Fl(t,e,r,n)}function ii(t,e,r,n){let s=n;for(;t.hasNode(s);)s=Rm(n);return r.dummy=e,t.setNode(s,r),s}function pR(t){let e=new rn().setGraph(t.graph());return t.nodes().forEach(r=>e.setNode(r,t.node(r))),t.edges().forEach(r=>{let n=e.edge(r.v,r.w)||{weight:0,minlen:1},s=t.edge(r);e.setEdge(r.v,r.w,{weight:n.weight+s.weight,minlen:Math.max(n.minlen,s.minlen)})}),e}function Tv(t){let e=new rn({multigraph:t.isMultigraph()}).setGraph(t.graph());return t.nodes().forEach(r=>{t.children(r).length||e.setNode(r,t.node(r))}),t.edges().forEach(r=>{e.setEdge(r,t.edge(r))}),e}function ov(t,e){let r=t.x,n=t.y,s=e.x-r,o=e.y-n,i=t.width/2,a=t.height/2;if(!s&&!o)throw new Error("Not possible to find intersection inside of the rectangle");let c,d;return Math.abs(o)*i>Math.abs(s)*a?(o<0&&(a=-a),c=a*s/o,d=a):(s<0&&(i=-i),c=i,d=i*o/s),{x:r+c,y:n+d}}function za(t){let e=Ma(Rv(t)+1).map(()=>[]);return t.nodes().forEach(r=>{let n=t.node(r),s=n.rank;s!==void 0&&(e[s]||(e[s]=[]),e[s][n.order]=r)}),e}function mR(t){let e=t.nodes().map(n=>{let s=t.node(n).rank;return s===void 0?Number.MAX_VALUE:s}),r=On(Math.min,e);t.nodes().forEach(n=>{let s=t.node(n);Object.hasOwn(s,"rank")&&(s.rank-=r)})}function gR(t){let e=t.nodes().map(i=>t.node(i).rank).filter(i=>i!==void 0),r=On(Math.min,e),n=[];t.nodes().forEach(i=>{let a=t.node(i).rank-r;n[a]||(n[a]=[]),n[a].push(i)});let s=0,o=t.graph().nodeRankFactor;Array.from(n).forEach((i,a)=>{i===void 0&&a%o!==0?--s:i!==void 0&&s&&i.forEach(c=>t.node(c).rank+=s)})}function iv(t,e,r,n){let s={width:0,height:0};return arguments.length>=4&&(s.rank=r,s.order=n),ii(t,"border",s,e)}function _R(t,e=$v){let r=[];for(let n=0;n<t.length;n+=e){let s=t.slice(n,n+e);r.push(s)}return r}var $v=65535;function On(t,e){if(e.length>$v){let r=_R(e);return t(...r.map(n=>t(...n)))}else return t(...e)}function Rv(t){let e=t.nodes().map(r=>{let n=t.node(r).rank;return n===void 0?Number.MIN_VALUE:n});return On(Math.max,e)}function bR(t,e){let r={lhs:[],rhs:[]};return t.forEach(n=>{e(n)?r.lhs.push(n):r.rhs.push(n)}),r}function Pv(t,e){let r=Date.now();try{return e()}finally{console.log(t+" time: "+(Date.now()-r)+"ms")}}function Mv(t,e){return e()}var yR=0;function Rm(t){let e=++yR;return t+(""+e)}function Ma(t,e,r=1){e==null&&(e=t,t=0);let n=o=>o<e;r<0&&(n=o=>e<o);let s=[];for(let o=t;n(o);o+=r)s.push(o);return s}function Ul(t,e){let r={};for(let n of e)t[n]!==void 0&&(r[n]=t[n]);return r}function Gl(t,e){let r;return typeof e=="string"?r=n=>n[e]:r=e,Object.entries(t).reduce((n,[s,o])=>(n[s]=r(o,s),n),{})}function vR(t,e){return t.reduce((r,n,s)=>(r[n]=e[s],r),{})}var Yl="\0",wR="3.0.0",xR=class{constructor(){V$(this,"_sentinel");let t={};t._next=t._prev=t,this._sentinel=t}dequeue(){let t=this._sentinel,e=t._prev;if(e!==t)return av(e),e}enqueue(t){let e=this._sentinel;t._prev&&t._next&&av(t),t._next=e._next,e._next._prev=t,e._next=t,t._prev=e}toString(){let t=[],e=this._sentinel,r=e._prev;for(;r!==e;)t.push(JSON.stringify(r,kR)),r=r._prev;return"["+t.join(", ")+"]"}};function av(t){t._prev._next=t._next,t._next._prev=t._prev,delete t._next,delete t._prev}function kR(t,e){if(t!=="_next"&&t!=="_prev")return e}var SR=xR,ER=()=>1;function TR(t,e){if(t.nodeCount()<=1)return[];let r=RR(t,e||ER);return $R(r.graph,r.buckets,r.zeroIdx).flatMap(n=>t.outEdges(n.v,n.w)||[])}function $R(t,e,r){var n;let s=[],o=e[e.length-1],i=e[0],a;for(;t.nodeCount();){for(;a=i.dequeue();)wm(t,e,r,a);for(;a=o.dequeue();)wm(t,e,r,a);if(t.nodeCount()){for(let c=e.length-2;c>0;--c)if(a=(n=e[c])==null?void 0:n.dequeue(),a){s=s.concat(wm(t,e,r,a,!0)||[]);break}}}return s}function wm(t,e,r,n,s){let o=[],i=s?o:void 0;return(t.inEdges(n.v)||[]).forEach(a=>{let c=t.edge(a),d=t.node(a.v);s&&o.push({v:a.v,w:a.w}),d.out-=c,Tm(e,r,d)}),(t.outEdges(n.v)||[]).forEach(a=>{let c=t.edge(a),d=a.w,l=t.node(d);l.in-=c,Tm(e,r,l)}),t.removeNode(n.v),i}function RR(t,e){let r=new rn,n=0,s=0;t.nodes().forEach(a=>{r.setNode(a,{v:a,in:0,out:0})}),t.edges().forEach(a=>{let c=r.edge(a.v,a.w)||0,d=e(a),l=c+d;r.setEdge(a.v,a.w,l);let u=r.node(a.v),h=r.node(a.w);s=Math.max(s,u.out+=d),n=Math.max(n,h.in+=d)});let o=PR(s+n+3).map(()=>new SR),i=n+1;return r.nodes().forEach(a=>{Tm(o,i,r.node(a))}),{graph:r,buckets:o,zeroIdx:i}}function Tm(t,e,r){var n,s,o;r.out?r.in?(o=t[r.out-r.in+e])==null||o.enqueue(r):(s=t[t.length-1])==null||s.enqueue(r):(n=t[0])==null||n.enqueue(r)}function PR(t){let e=[];for(let r=0;r<t;r++)e.push(r);return e}function MR(t){(t.graph().acyclicer==="greedy"?TR(t,e(t)):zR(t)).forEach(r=>{let n=t.edge(r);t.removeEdge(r),n.forwardName=r.name,n.reversed=!0,t.setEdge(r.w,r.v,n,Rm("rev"))});function e(r){return n=>r.edge(n).weight}}function zR(t){let e=[],r={},n={};function s(o){Object.hasOwn(n,o)||(n[o]=!0,r[o]=!0,t.outEdges(o).forEach(i=>{Object.hasOwn(r,i.w)?e.push(i):s(i.w)}),delete r[o])}return t.nodes().forEach(s),e}function IR(t){t.edges().forEach(e=>{let r=t.edge(e);if(r.reversed){t.removeEdge(e);let n=r.forwardName;delete r.reversed,delete r.forwardName,t.setEdge(e.w,e.v,r,n)}})}function OR(t){t.graph().dummyChains=[],t.edges().forEach(e=>AR(t,e))}function AR(t,e){let r=e.v,n=t.node(r).rank,s=e.w,o=t.node(s).rank,i=e.name,a=t.edge(e),c=a.labelRank;if(o===n+1)return;t.removeEdge(e);let d,l,u;for(u=0,++n;n<o;++u,++n)a.points=[],l={width:0,height:0,edgeLabel:a,edgeObj:e,rank:n},d=ii(t,"edge",l,"_d"),n===c&&(l.width=a.width,l.height=a.height,l.dummy="edge-label",l.labelpos=a.labelpos),t.setEdge(r,d,{weight:a.weight},i),u===0&&t.graph().dummyChains.push(d),r=d;t.setEdge(r,s,{weight:a.weight},i)}function NR(t){t.graph().dummyChains.forEach(e=>{let r=t.node(e),n=r.edgeLabel,s;for(t.setEdge(r.edgeObj,n);r.dummy;)s=t.successors(e)[0],t.removeNode(e),n.points.push({x:r.x,y:r.y}),r.dummy==="edge-label"&&(n.x=r.x,n.y=r.y,n.width=r.width,n.height=r.height),e=s,r=t.node(e)})}function Pm(t){let e={};function r(n){let s=t.node(n);if(Object.hasOwn(e,n))return s.rank;e[n]=!0;let o=t.outEdges(n),i=o?o.map(c=>c==null?Number.POSITIVE_INFINITY:r(c.w)-t.edge(c).minlen):[],a=On(Math.min,i);return a===Number.POSITIVE_INFINITY&&(a=0),s.rank=a}t.sources().forEach(r)}function oi(t,e){return t.node(e.w).rank-t.node(e.v).rank-t.edge(e).minlen}var zv=CR;function CR(t){let e=new rn({directed:!1}),r=t.nodes();if(r.length===0)throw new Error("Graph must have at least one node");let n=r[0],s=t.nodeCount();e.setNode(n,{});let o,i;for(;jR(e,t)<s&&(o=DR(e,t),!!o);)i=e.hasNode(o.v)?oi(t,o):-oi(t,o),LR(e,t,i);return e}function jR(t,e){function r(n){let s=e.nodeEdges(n);s&&s.forEach(o=>{let i=o.v,a=n===i?o.w:i;!t.hasNode(a)&&!oi(e,o)&&(t.setNode(a,{}),t.setEdge(n,a,{}),r(a))})}return t.nodes().forEach(r),t.nodeCount()}function DR(t,e){return e.edges().reduce((r,n)=>{let s=Number.POSITIVE_INFINITY;return t.hasNode(n.v)!==t.hasNode(n.w)&&(s=oi(e,n)),s<r[0]?[s,n]:r},[Number.POSITIVE_INFINITY,null])[1]}function LR(t,e,r){t.nodes().forEach(n=>e.node(n).rank+=r)}var{preorder:ZR,postorder:BR}=$m,qR=co;co.initLowLimValues=zm;co.initCutValues=Mm;co.calcCutValue=Iv;co.leaveEdge=Av;co.enterEdge=Nv;co.exchangeEdges=Cv;function co(t){t=pR(t),Pm(t);let e=zv(t);zm(e),Mm(e,t);let r,n;for(;r=Av(e);)n=Nv(e,t,r),Cv(e,t,r,n)}function Mm(t,e){let r=BR(t,t.nodes());r=r.slice(0,r.length-1),r.forEach(n=>VR(t,e,n))}function VR(t,e,r){let n=t.node(r).parent,s=t.edge(r,n);s.cutvalue=Iv(t,e,r)}function Iv(t,e,r){let n=t.node(r).parent,s=!0,o=e.edge(r,n),i=0;o||(s=!1,o=e.edge(n,r)),i=o.weight;let a=e.nodeEdges(r);return a&&a.forEach(c=>{let d=c.v===r,l=d?c.w:c.v;if(l!==n){let u=d===s,h=e.edge(c).weight;if(i+=u?h:-h,HR(t,r,l)){let p=t.edge(r,l).cutvalue;i+=u?-p:p}}}),i}function zm(t,e){arguments.length<2&&(e=t.nodes()[0]),Ov(t,{},1,e)}function Ov(t,e,r,n,s){let o=r,i=t.node(n);e[n]=!0;let a=t.neighbors(n);return a&&a.forEach(c=>{Object.hasOwn(e,c)||(r=Ov(t,e,r,c,n))}),i.low=o,i.lim=r++,s?i.parent=s:delete i.parent,r}function Av(t){return t.edges().find(e=>t.edge(e).cutvalue<0)}function Nv(t,e,r){let n=r.v,s=r.w;e.hasEdge(n,s)||(n=r.w,s=r.v);let o=t.node(n),i=t.node(s),a=o,c=!1;return o.lim>i.lim&&(a=i,c=!0),e.edges().filter(d=>c===cv(t,t.node(d.v),a)&&c!==cv(t,t.node(d.w),a)).reduce((d,l)=>oi(e,l)<oi(e,d)?l:d)}function Cv(t,e,r,n){let s=r.v,o=r.w;t.removeEdge(s,o),t.setEdge(n.v,n.w,{}),zm(t),Mm(t,e),FR(t,e)}function FR(t,e){let r=t.nodes().find(s=>!t.node(s).parent);if(!r)return;let n=ZR(t,[r]);n=n.slice(1),n.forEach(s=>{let o=t.node(s).parent,i=e.edge(s,o),a=!1;i||(i=e.edge(o,s),a=!0),e.node(s).rank=e.node(o).rank+(a?i.minlen:-i.minlen)})}function HR(t,e,r){return t.hasEdge(e,r)}function cv(t,e,r){return r.low<=e.lim&&e.lim<=r.lim}var UR=GR;function GR(t){let e=t.graph().ranker;if(typeof e=="function")return e(t);switch(e){case"network-simplex":lv(t);break;case"tight-tree":XR(t);break;case"longest-path":YR(t);break;case"none":break;default:lv(t)}}var YR=Pm;function XR(t){Pm(t),zv(t)}function lv(t){qR(t)}var WR=KR;function KR(t){let e=QR(t);t.graph().dummyChains.forEach(r=>{let n=t.node(r),s=n.edgeObj,o=JR(t,e,s.v,s.w),i=o.path,a=o.lca,c=0,d=i[c],l=!0;for(;r!==s.w;){if(n=t.node(r),l){for(;(d=i[c])!==a&&t.node(d).maxRank<n.rank;)c++;d===a&&(l=!1)}if(!l){for(;c<i.length-1&&t.node(i[c+1]).minRank<=n.rank;)c++;d=i[c]}d!==void 0&&t.setParent(r,d),r=t.successors(r)[0]}})}function JR(t,e,r,n){let s=[],o=[],i=Math.min(e[r].low,e[n].low),a=Math.max(e[r].lim,e[n].lim),c;c=r;do c=t.parent(c),s.push(c);while(c&&(e[c].low>i||a>e[c].lim));let d=c,l=n;for(;(l=t.parent(l))!==d;)o.push(l);return{path:s.concat(o.reverse()),lca:d}}function QR(t){let e={},r=0;function n(s){let o=r;t.children(s).forEach(n),e[s]={low:o,lim:r++}}return t.children(Yl).forEach(n),e}function eP(t){let e=ii(t,"root",{},"_root"),r=tP(t),n=Object.values(r),s=On(Math.max,n)-1,o=2*s+1;t.graph().nestingRoot=e,t.edges().forEach(a=>t.edge(a).minlen*=o);let i=rP(t)+1;t.children(Yl).forEach(a=>jv(t,e,o,i,s,r,a)),t.graph().nodeRankFactor=o}function jv(t,e,r,n,s,o,i){var a;let c=t.children(i);if(!c.length){i!==e&&t.setEdge(e,i,{weight:0,minlen:r});return}let d=iv(t,"_bt"),l=iv(t,"_bb"),u=t.node(i);t.setParent(d,i),u.borderTop=d,t.setParent(l,i),u.borderBottom=l,c.forEach(h=>{var p;jv(t,e,r,n,s,o,h);let g=t.node(h),x=g.borderTop?g.borderTop:h,S=g.borderBottom?g.borderBottom:h,k=g.borderTop?n:2*n,_=x!==S?1:s-((p=o[i])!=null?p:0)+1;t.setEdge(d,x,{weight:k,minlen:_,nestingEdge:!0}),t.setEdge(S,l,{weight:k,minlen:_,nestingEdge:!0})}),t.parent(i)||t.setEdge(e,d,{weight:0,minlen:s+((a=o[i])!=null?a:0)})}function tP(t){let e={};function r(n,s){let o=t.children(n);o&&o.length&&o.forEach(i=>r(i,s+1)),e[n]=s}return t.children(Yl).forEach(n=>r(n,1)),e}function rP(t){return t.edges().reduce((e,r)=>e+t.edge(r).weight,0)}function nP(t){let e=t.graph();t.removeNode(e.nestingRoot),delete e.nestingRoot,t.edges().forEach(r=>{t.edge(r).nestingEdge&&t.removeEdge(r)})}var sP=oP;function oP(t){function e(r){let n=t.children(r),s=t.node(r);if(n.length&&n.forEach(e),Object.hasOwn(s,"minRank")){s.borderLeft=[],s.borderRight=[];for(let o=s.minRank,i=s.maxRank+1;o<i;++o)uv(t,"borderLeft","_bl",r,s,o),uv(t,"borderRight","_br",r,s,o)}}t.children(Yl).forEach(e)}function uv(t,e,r,n,s,o){let i={width:0,height:0,rank:o,borderType:e},a=s[e][o-1],c=ii(t,"border",i,r);s[e][o]=c,t.setParent(c,n),a&&t.setEdge(a,c,{weight:1})}function iP(t){var e;let r=(e=t.graph().rankdir)==null?void 0:e.toLowerCase();(r==="lr"||r==="rl")&&Dv(t)}function aP(t){var e;let r=(e=t.graph().rankdir)==null?void 0:e.toLowerCase();(r==="bt"||r==="rl")&&cP(t),(r==="lr"||r==="rl")&&(lP(t),Dv(t))}function Dv(t){t.nodes().forEach(e=>dv(t.node(e))),t.edges().forEach(e=>dv(t.edge(e)))}function dv(t){let e=t.width;t.width=t.height,t.height=e}function cP(t){t.nodes().forEach(e=>xm(t.node(e))),t.edges().forEach(e=>{var r;let n=t.edge(e);(r=n.points)==null||r.forEach(xm),Object.hasOwn(n,"y")&&xm(n)})}function xm(t){t.y=-t.y}function lP(t){t.nodes().forEach(e=>km(t.node(e))),t.edges().forEach(e=>{var r;let n=t.edge(e);(r=n.points)==null||r.forEach(km),Object.hasOwn(n,"x")&&km(n)})}function km(t){let e=t.x;t.x=t.y,t.y=e}function uP(t){let e={},r=t.nodes().filter(a=>!t.children(a).length),n=r.map(a=>t.node(a).rank),s=On(Math.max,n),o=Ma(s+1).map(()=>[]);function i(a){if(e[a])return;e[a]=!0;let c=t.node(a);o[c.rank].push(a);let d=t.successors(a);d&&d.forEach(i)}return r.sort((a,c)=>t.node(a).rank-t.node(c).rank).forEach(i),o}function dP(t,e){let r=0;for(let n=1;n<e.length;++n)r+=fP(t,e[n-1],e[n]);return r}function fP(t,e,r){let n=vR(r,r.map((d,l)=>l)),s=e.flatMap(d=>{let l=t.outEdges(d);return l?l.map(u=>({pos:n[u.w],weight:t.edge(u).weight})).sort((u,h)=>u.pos-h.pos):[]}),o=1;for(;o<r.length;)o<<=1;let i=2*o-1;o-=1;let a=new Array(i).fill(0),c=0;return s.forEach(d=>{let l=d.pos+o;a[l]+=d.weight;let u=0;for(;l>0;)l%2&&(u+=a[l+1]),l=l-1>>1,a[l]+=d.weight;c+=d.weight*u}),c}function hP(t,e=[]){return e.map(r=>{let n=t.inEdges(r);if(!n||!n.length)return{v:r};{let s=n.reduce((o,i)=>{let a=t.edge(i),c=t.node(i.v);return{sum:o.sum+a.weight*c.order,weight:o.weight+a.weight}},{sum:0,weight:0});return{v:r,barycenter:s.sum/s.weight,weight:s.weight}}})}function pP(t,e){let r={};t.forEach((s,o)=>{let i={indegree:0,in:[],out:[],vs:[s.v],i:o};s.barycenter!==void 0&&(i.barycenter=s.barycenter,i.weight=s.weight),r[s.v]=i}),e.edges().forEach(s=>{let o=r[s.v],i=r[s.w];o!==void 0&&i!==void 0&&(i.indegree++,o.out.push(i))});let n=Object.values(r).filter(s=>!s.indegree);return mP(n)}function mP(t){let e=[];function r(s){return o=>{o.merged||(o.barycenter===void 0||s.barycenter===void 0||o.barycenter>=s.barycenter)&&gP(s,o)}}function n(s){return o=>{o.in.push(s),--o.indegree===0&&t.push(o)}}for(;t.length;){let s=t.pop();e.push(s),s.in.reverse().forEach(r(s)),s.out.forEach(n(s))}return e.filter(s=>!s.merged).map(s=>Ul(s,["vs","i","barycenter","weight"]))}function gP(t,e){let r=0,n=0;t.weight&&(r+=t.barycenter*t.weight,n+=t.weight),e.weight&&(r+=e.barycenter*e.weight,n+=e.weight),t.vs=e.vs.concat(t.vs),t.barycenter=r/n,t.weight=n,t.i=Math.min(e.i,t.i),e.merged=!0}function _P(t,e){let r=bR(t,l=>Object.hasOwn(l,"barycenter")),n=r.lhs,s=r.rhs.sort((l,u)=>u.i-l.i),o=[],i=0,a=0,c=0;n.sort(bP(!!e)),c=fv(o,s,c),n.forEach(l=>{c+=l.vs.length,o.push(l.vs),i+=l.barycenter*l.weight,a+=l.weight,c=fv(o,s,c)});let d={vs:o.flat(1)};return a&&(d.barycenter=i/a,d.weight=a),d}function fv(t,e,r){let n;for(;e.length&&(n=e[e.length-1]).i<=r;)e.pop(),t.push(n.vs),r++;return r}function bP(t){return(e,r)=>e.barycenter<r.barycenter?-1:e.barycenter>r.barycenter?1:t?r.i-e.i:e.i-r.i}function Lv(t,e,r,n){let s=t.children(e),o=t.node(e),i=o?o.borderLeft:void 0,a=o?o.borderRight:void 0,c={};i&&(s=s.filter(h=>h!==i&&h!==a));let d=hP(t,s);d.forEach(h=>{if(t.children(h.v).length){let p=Lv(t,h.v,r,n);c[h.v]=p,Object.hasOwn(p,"barycenter")&&vP(h,p)}});let l=pP(d,r);yP(l,c);let u=_P(l,n);if(i&&a){u.vs=[i,u.vs,a].flat(1);let h=t.predecessors(i);if(h&&h.length){let p=t.node(h[0]),g=t.predecessors(a),x=t.node(g[0]);Object.hasOwn(u,"barycenter")||(u.barycenter=0,u.weight=0),u.barycenter=(u.barycenter*u.weight+p.order+x.order)/(u.weight+2),u.weight+=2}}return u}function yP(t,e){t.forEach(r=>{r.vs=r.vs.flatMap(n=>e[n]?e[n].vs:n)})}function vP(t,e){t.barycenter!==void 0?(t.barycenter=(t.barycenter*t.weight+e.barycenter*e.weight)/(t.weight+e.weight),t.weight+=e.weight):(t.barycenter=e.barycenter,t.weight=e.weight)}function wP(t,e,r,n){n||(n=t.nodes());let s=xP(t),o=new rn({compound:!0}).setGraph({root:s}).setDefaultNodeLabel(i=>t.node(i));return n.forEach(i=>{let a=t.node(i),c=t.parent(i);if(a.rank===e||a.minRank<=e&&e<=a.maxRank){o.setNode(i),o.setParent(i,c||s);let d=t[r](i);d&&d.forEach(l=>{let u=l.v===i?l.w:l.v,h=o.edge(u,i),p=h!==void 0?h.weight:0;o.setEdge(u,i,{weight:t.edge(l).weight+p})}),Object.hasOwn(a,"minRank")&&o.setNode(i,{borderLeft:a.borderLeft[e],borderRight:a.borderRight[e]})}}),o}function xP(t){let e;for(;t.hasNode(e=Rm("_root")););return e}function kP(t,e,r){let n={},s;r.forEach(o=>{let i=t.parent(o),a,c;for(;i;){if(a=t.parent(i),a?(c=n[a],n[a]=i):(c=s,s=i),c&&c!==i){e.setEdge(c,i);return}i=a}})}function Zv(t,e={}){if(typeof e.customOrder=="function"){e.customOrder(t,Zv);return}let r=Rv(t),n=hv(t,Ma(1,r+1),"inEdges"),s=hv(t,Ma(r-1,-1,-1),"outEdges"),o=uP(t);if(pv(t,o),e.disableOptimalOrderHeuristic)return;let i=Number.POSITIVE_INFINITY,a,c=e.constraints||[];for(let d=0,l=0;l<4;++d,++l){SP(d%2?n:s,d%4>=2,c),o=za(t);let u=dP(t,o);u<i?(l=0,a=Object.assign({},o),i=u):u===i&&(a=structuredClone(o))}pv(t,a)}function hv(t,e,r){let n=new Map,s=(o,i)=>{n.has(o)||n.set(o,[]),n.get(o).push(i)};for(let o of t.nodes()){let i=t.node(o);if(typeof i.rank=="number"&&s(i.rank,o),typeof i.minRank=="number"&&typeof i.maxRank=="number")for(let a=i.minRank;a<=i.maxRank;a++)a!==i.rank&&s(a,o)}return e.map(function(o){return wP(t,o,r,n.get(o)||[])})}function SP(t,e,r){let n=new rn;t.forEach(function(s){r.forEach(a=>n.setEdge(a.left,a.right));let o=s.graph().root,i=Lv(s,o,n,e);i.vs.forEach((a,c)=>s.node(a).order=c),kP(s,n,i.vs)})}function pv(t,e){Object.values(e).forEach(r=>r.forEach((n,s)=>t.node(n).order=s))}function EP(t,e){let r={};function n(s,o){let i=0,a=0,c=s.length,d=o[o.length-1];return o.forEach((l,u)=>{let h=$P(t,l),p=h?t.node(h).order:c;(h||l===d)&&(o.slice(a,u+1).forEach(g=>{let x=t.predecessors(g);x&&x.forEach(S=>{let k=t.node(S),_=k.order;(_<i||p<_)&&!(k.dummy&&t.node(g).dummy)&&Bv(r,S,g)})}),a=u+1,i=p)}),o}return e.length&&e.reduce(n),r}function TP(t,e){let r={};function n(o,i,a,c,d){Ma(i,a).forEach(l=>{let u=o[l];if(u!==void 0&&t.node(u).dummy){let h=t.predecessors(u);h&&h.forEach(p=>{if(p===void 0)return;let g=t.node(p);g.dummy&&(g.order<c||g.order>d)&&Bv(r,p,u)})}})}function s(o,i){let a=-1,c=-1,d=0;return i.forEach((l,u)=>{if(t.node(l).dummy==="border"){let h=t.predecessors(l);if(h&&h.length){let p=h[0];if(p===void 0)return;c=t.node(p).order,n(i,d,u,a,c),d=u,a=c}}n(i,d,i.length,c,o.length)}),i}return e.length&&e.reduce(s),r}function $P(t,e){if(t.node(e).dummy){let r=t.predecessors(e);if(r)return r.find(n=>t.node(n).dummy)}}function Bv(t,e,r){if(e>r){let s=e;e=r,r=s}let n=t[e];n||(t[e]=n={}),n[r]=!0}function RP(t,e,r){if(e>r){let s=e;e=r,r=s}let n=t[e];return n!==void 0&&Object.hasOwn(n,r)}function PP(t,e,r,n){let s={},o={},i={};return e.forEach(a=>{a.forEach((c,d)=>{s[c]=c,o[c]=c,i[c]=d})}),e.forEach(a=>{let c=-1;a.forEach(d=>{let l=n(d);if(l&&l.length){let u=l.sort((p,g)=>{let x=i[p],S=i[g];return(x!==void 0?x:0)-(S!==void 0?S:0)}),h=(u.length-1)/2;for(let p=Math.floor(h),g=Math.ceil(h);p<=g;++p){let x=u[p];if(x===void 0)continue;let S=i[x];if(S!==void 0&&o[d]===d&&c<S&&!RP(r,d,x)){let k=s[x];k!==void 0&&(o[x]=d,o[d]=s[d]=k,c=S)}}}})}),{root:s,align:o}}function MP(t,e,r,n,s=!1){let o={},i=zP(t,e,r,s),a=s?"borderLeft":"borderRight";function c(p,g){let x=i.nodes().slice(),S={},k=x.pop();for(;k;){if(S[k])p(k);else{S[k]=!0,x.push(k);for(let _ of g(k))x.push(_)}k=x.pop()}}function d(p){let g=i.inEdges(p);g?o[p]=g.reduce((x,S)=>{var k;let _=(k=o[S.v])!=null?k:0,m=i.edge(S);return Math.max(x,_+(m!==void 0?m:0))},0):o[p]=0}function l(p){let g=i.outEdges(p),x=Number.POSITIVE_INFINITY;g&&(x=g.reduce((k,_)=>{let m=o[_.w],$=i.edge(_);return Math.min(k,(m!==void 0?m:0)-($!==void 0?$:0))},Number.POSITIVE_INFINITY));let S=t.node(p);x!==Number.POSITIVE_INFINITY&&S.borderType!==a&&(o[p]=Math.max(o[p]!==void 0?o[p]:0,x))}function u(p){return i.predecessors(p)||[]}function h(p){return i.successors(p)||[]}return c(d,u),c(l,h),Object.keys(n).forEach(p=>{var g;let x=r[p];x!==void 0&&(o[p]=(g=o[x])!=null?g:0)}),o}function zP(t,e,r,n){let s=new rn,o=t.graph(),i=CP(o.nodesep,o.edgesep,n);return e.forEach(a=>{let c;a.forEach(d=>{let l=r[d];if(l!==void 0){if(s.setNode(l),c!==void 0){let u=r[c];if(u!==void 0){let h=s.edge(u,l);s.setEdge(u,l,Math.max(i(t,d,c),h||0))}}c=d}})}),s}function IP(t,e){return Object.values(e).reduce((r,n)=>{let s=Number.NEGATIVE_INFINITY,o=Number.POSITIVE_INFINITY;Object.entries(n).forEach(([a,c])=>{let d=jP(t,a)/2;s=Math.max(c+d,s),o=Math.min(c-d,o)});let i=s-o;return i<r[0]&&(r=[i,n]),r},[Number.POSITIVE_INFINITY,null])[1]}function OP(t,e){let r=Object.values(e),n=On(Math.min,r),s=On(Math.max,r);["u","d"].forEach(o=>{["l","r"].forEach(i=>{let a=o+i,c=t[a];if(!c||c===e)return;let d=Object.values(c),l=n-On(Math.min,d);i!=="l"&&(l=s-On(Math.max,d)),l&&(t[a]=Gl(c,u=>u+l))})})}function AP(t,e=void 0){let r=t.ul;return r?Gl(r,(n,s)=>{var o,i;if(e){let c=e.toLowerCase(),d=t[c];if(d&&d[s]!==void 0)return d[s]}let a=Object.values(t).map(c=>{let d=c[s];return d!==void 0?d:0}).sort((c,d)=>c-d);return(((o=a[1])!=null?o:0)+((i=a[2])!=null?i:0))/2}):{}}function NP(t){let e=za(t),r=Object.assign(EP(t,e),TP(t,e)),n={},s;["u","d"].forEach(i=>{s=i==="u"?e:Object.values(e).reverse(),["l","r"].forEach(a=>{a==="r"&&(s=s.map(l=>Object.values(l).reverse()));let c=PP(t,s,r,l=>(i==="u"?t.predecessors(l):t.successors(l))||[]),d=MP(t,s,c.root,c.align,a==="r");a==="r"&&(d=Gl(d,l=>-l)),n[i+a]=d})});let o=IP(t,n);return OP(n,o),AP(n,t.graph().align)}function CP(t,e,r){return(n,s,o)=>{let i=n.node(s),a=n.node(o),c=0,d;if(c+=i.width/2,Object.hasOwn(i,"labelpos"))switch(i.labelpos.toLowerCase()){case"l":d=-i.width/2;break;case"r":d=i.width/2;break}if(d&&(c+=r?d:-d),d=void 0,c+=(i.dummy?e:t)/2,c+=(a.dummy?e:t)/2,c+=a.width/2,Object.hasOwn(a,"labelpos"))switch(a.labelpos.toLowerCase()){case"l":d=a.width/2;break;case"r":d=-a.width/2;break}return d&&(c+=r?d:-d),c}}function jP(t,e){return t.node(e).width}function DP(t){t=Tv(t),LP(t),Object.entries(NP(t)).forEach(([e,r])=>t.node(e).x=r)}function LP(t){let e=za(t),r=t.graph(),n=r.ranksep,s=r.rankalign,o=0;e.forEach(i=>{let a=i.reduce((c,d)=>{var l;let u=(l=t.node(d).height)!=null?l:0;return c>u?c:u},0);i.forEach(c=>{let d=t.node(c);s==="top"?d.y=o+d.height/2:s==="bottom"?d.y=o+a-d.height/2:d.y=o+a/2}),o+=a+n})}function ZP(t,e={}){let r=e.debugTiming?Pv:Mv;return r("layout",()=>{let n=r(" buildLayoutGraph",()=>WP(t));return r(" runLayout",()=>BP(n,r,e)),r(" updateInputGraph",()=>qP(t,n)),n})}function BP(t,e,r){e(" makeSpaceForEdgeLabels",()=>KP(t)),e(" removeSelfEdges",()=>iM(t)),e(" acyclic",()=>MR(t)),e(" nestingGraph.run",()=>eP(t)),e(" rank",()=>UR(Tv(t))),e(" injectEdgeLabelProxies",()=>JP(t)),e(" removeEmptyRanks",()=>gR(t)),e(" nestingGraph.cleanup",()=>nP(t)),e(" normalizeRanks",()=>mR(t)),e(" assignRankMinMax",()=>QP(t)),e(" removeEdgeLabelProxies",()=>eM(t)),e(" normalize.run",()=>OR(t)),e(" parentDummyChains",()=>WR(t)),e(" addBorderSegments",()=>sP(t)),e(" order",()=>Zv(t,r)),e(" insertSelfEdges",()=>aM(t)),e(" adjustCoordinateSystem",()=>iP(t)),e(" position",()=>DP(t)),e(" positionSelfEdges",()=>cM(t)),e(" removeBorderNodes",()=>oM(t)),e(" normalize.undo",()=>NR(t)),e(" fixupEdgeLabelCoords",()=>nM(t)),e(" undoCoordinateSystem",()=>aP(t)),e(" translateGraph",()=>tM(t)),e(" assignNodeIntersects",()=>rM(t)),e(" reversePoints",()=>sM(t)),e(" acyclic.undo",()=>IR(t))}function qP(t,e){t.nodes().forEach(r=>{let n=t.node(r),s=e.node(r);n&&(n.x=s.x,n.y=s.y,n.order=s.order,n.rank=s.rank,e.children(r).length&&(n.width=s.width,n.height=s.height))}),t.edges().forEach(r=>{let n=t.edge(r),s=e.edge(r);n.points=s.points,Object.hasOwn(s,"x")&&(n.x=s.x,n.y=s.y)}),t.graph().width=e.graph().width,t.graph().height=e.graph().height}var VP=["nodesep","edgesep","ranksep","marginx","marginy"],FP={ranksep:50,edgesep:20,nodesep:50,rankdir:"TB",rankalign:"center"},HP=["acyclicer","ranker","rankdir","align","rankalign"],UP=["width","height","rank"],mv={width:0,height:0},GP=["minlen","weight","width","height","labeloffset"],YP={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},XP=["labelpos"];function WP(t){let e=new rn({multigraph:!0,compound:!0}),r=Em(t.graph());return e.setGraph(Object.assign({},FP,Sm(r,VP),Ul(r,HP))),t.nodes().forEach(n=>{let s=Em(t.node(n)),o=Sm(s,UP);Object.keys(mv).forEach(a=>{o[a]===void 0&&(o[a]=mv[a])}),e.setNode(n,o);let i=t.parent(n);i!==void 0&&e.setParent(n,i)}),t.edges().forEach(n=>{let s=Em(t.edge(n));e.setEdge(n,Object.assign({},YP,Sm(s,GP),Ul(s,XP)))}),e}function KP(t){let e=t.graph();e.ranksep/=2,t.edges().forEach(r=>{let n=t.edge(r);n.minlen*=2,n.labelpos.toLowerCase()!=="c"&&(e.rankdir==="TB"||e.rankdir==="BT"?n.width+=n.labeloffset:n.height+=n.labeloffset)})}function JP(t){t.edges().forEach(e=>{let r=t.edge(e);if(r.width&&r.height){let n=t.node(e.v),s={rank:(t.node(e.w).rank-n.rank)/2+n.rank,e};ii(t,"edge-proxy",s,"_ep")}})}function QP(t){let e=0;t.nodes().forEach(r=>{let n=t.node(r);n.borderTop&&(n.minRank=t.node(n.borderTop).rank,n.maxRank=t.node(n.borderBottom).rank,e=Math.max(e,n.maxRank))}),t.graph().maxRank=e}function eM(t){t.nodes().forEach(e=>{let r=t.node(e);if(r.dummy==="edge-proxy"){let n=r;t.edge(n.e).labelRank=r.rank,t.removeNode(e)}})}function tM(t){let e=Number.POSITIVE_INFINITY,r=0,n=Number.POSITIVE_INFINITY,s=0,o=t.graph(),i=o.marginx||0,a=o.marginy||0;function c(d){let l=d.x,u=d.y,h=d.width,p=d.height;e=Math.min(e,l-h/2),r=Math.max(r,l+h/2),n=Math.min(n,u-p/2),s=Math.max(s,u+p/2)}t.nodes().forEach(d=>c(t.node(d))),t.edges().forEach(d=>{let l=t.edge(d);Object.hasOwn(l,"x")&&c(l)}),e-=i,n-=a,t.nodes().forEach(d=>{let l=t.node(d);l.x-=e,l.y-=n}),t.edges().forEach(d=>{let l=t.edge(d);l.points.forEach(u=>{u.x-=e,u.y-=n}),Object.hasOwn(l,"x")&&(l.x-=e),Object.hasOwn(l,"y")&&(l.y-=n)}),o.width=r-e+i,o.height=s-n+a}function rM(t){t.edges().forEach(e=>{let r=t.edge(e),n=t.node(e.v),s=t.node(e.w),o,i;r.points?(o=r.points[0],i=r.points[r.points.length-1]):(r.points=[],o=s,i=n),r.points.unshift(ov(n,o)),r.points.push(ov(s,i))})}function nM(t){t.edges().forEach(e=>{let r=t.edge(e);if(Object.hasOwn(r,"x"))switch((r.labelpos==="l"||r.labelpos==="r")&&(r.width-=r.labeloffset),r.labelpos){case"l":r.x-=r.width/2+r.labeloffset;break;case"r":r.x+=r.width/2+r.labeloffset;break}})}function sM(t){t.edges().forEach(e=>{let r=t.edge(e);r.reversed&&r.points.reverse()})}function oM(t){t.nodes().forEach(e=>{if(t.children(e).length){let r=t.node(e),n=t.node(r.borderTop),s=t.node(r.borderBottom),o=t.node(r.borderLeft[r.borderLeft.length-1]),i=t.node(r.borderRight[r.borderRight.length-1]);r.width=Math.abs(i.x-o.x),r.height=Math.abs(s.y-n.y),r.x=o.x+r.width/2,r.y=n.y+r.height/2}}),t.nodes().forEach(e=>{t.node(e).dummy==="border"&&t.removeNode(e)})}function iM(t){t.edges().forEach(e=>{if(e.v===e.w){let r=t.node(e.v);r.selfEdges||(r.selfEdges=[]),r.selfEdges.push({e,label:t.edge(e)}),t.removeEdge(e)}})}function aM(t){za(t).forEach(e=>{let r=0;e.forEach((n,s)=>{let o=t.node(n);o.order=s+r,(o.selfEdges||[]).forEach(i=>{ii(t,"selfedge",{width:i.label.width,height:i.label.height,rank:o.rank,order:s+ ++r,e:i.e,label:i.label},"_se")}),delete o.selfEdges})})}function cM(t){t.nodes().forEach(e=>{let r=t.node(e);if(r.dummy==="selfedge"){let n=r,s=t.node(n.e.v),o=s.x+s.width/2,i=s.y,a=r.x-o,c=s.height/2;t.setEdge(n.e,n.label),t.removeNode(e),n.label.points=[{x:o+2*a/3,y:i-c},{x:o+5*a/6,y:i-c},{x:o+a,y:i},{x:o+5*a/6,y:i+c},{x:o+2*a/3,y:i+c}],n.label.x=r.x,n.label.y=r.y}})}function Sm(t,e){return Gl(Ul(t,e),Number)}function Em(t){let e={};return t&&Object.entries(t).forEach(([r,n])=>{typeof r=="string"&&(r=r.toLowerCase()),e[r]=n}),e}function lM(t){let e=za(t),r=new rn({compound:!0,multigraph:!0}).setGraph({});return t.nodes().forEach(n=>{r.setNode(n,{label:n}),r.setParent(n,"layer"+t.node(n).rank)}),t.edges().forEach(n=>r.setEdge(n.v,n.w,{},n.name)),e.forEach((n,s)=>{let o="layer"+s;r.setNode(o,{rank:"same"}),n.reduce((i,a)=>(r.setEdge(i,a,{style:"invis"}),a))}),r}var uM={graphlib:_v,version:wR,layout:ZP,debug:lM,util:{time:Pv,notime:Mv}},Im=uM;var dM={stack:"stack",layers:"stack",stacked:"stack",cloud:"cloud",rect:"rect",rectangle:"rect",box:"rect",round:"round",rounded:"round",stadium:"stadium",pill:"stadium",circle:"circle",diamond:"diamond",decision:"diamond",hexagon:"hexagon",hex:"hexagon",subroutine:"subroutine",module:"subroutine",cylinder:"cylinder",database:"cylinder",db:"cylinder"};function Nm(t){return t?dM[t.trim().toLowerCase()]:void 0}var Xl={pink:{fill:"#fde4ef",stroke:"#e57aa9",color:"#7d2950"},rose:{fill:"#ffe1e0",stroke:"#f0918c",color:"#7d2c2a"},peach:{fill:"#ffe7d4",stroke:"#f0a875",color:"#7d4a1f"},amber:{fill:"#fdeec3",stroke:"#e3bd6b",color:"#6f5314"},yellow:{fill:"#fbf3c9",stroke:"#dcc863",color:"#665b16"},green:{fill:"#d8f3df",stroke:"#7ec894",color:"#1f5b35"},mint:{fill:"#d4f3ea",stroke:"#76cdb6",color:"#1c5a4c"},teal:{fill:"#d3eef2",stroke:"#74c1cc",color:"#1c5057"},sky:{fill:"#d9ecfd",stroke:"#7db8ea",color:"#1d4d75"},blue:{fill:"#dfe6fb",stroke:"#8a9ef0",color:"#2b3a80"},indigo:{fill:"#e3e0fb",stroke:"#9b91ee",color:"#3a2f80"},purple:{fill:"#ecdffa",stroke:"#b58ee8",color:"#54287d"},lavender:{fill:"#eee9fb",stroke:"#b3a6ec",color:"#473a80"},gray:{fill:"#eceef1",stroke:"#aab2bd",color:"#3b424c"},slate:{fill:"#e6eaef",stroke:"#9aa6b4",color:"#33404f"}},qv=["sky","green","amber","pink","purple","teal","peach","indigo","mint","rose"];function Hv(t){return Xl[qv[t%qv.length]]}var fM=[["([","])","stadium"],["[[","]]","subroutine"],["[(",")]","cylinder"],["((","))","circle"],["{{","}}","hexagon"],["[","]","rect"],["(",")","round"],["{","}","diamond"]];function Om(t){let e=t.trim();return e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'")?e.slice(1,-1):e}function Am(t){return t.replace(/\\n/g,`
|
|
131
|
+
`).replace(/\\t/g," ").replace(/<br\s*\/?>/gi,`
|
|
132
|
+
`).replace(/<\/?(?:span|small|sub|sup|mark|font)\b[^>]*>/gi,"").replace(/[ \t]+\n/g,`
|
|
133
|
+
`).trim()}function hM(t){return t.replace(/<\/?(?:b|strong|i|em|u|code)\b[^>]*>/gi,"").replace(/\t/g," ")}function Vv(t){let e=t.match(/^([A-Za-z0-9_.-]+)/);if(!e)return null;let r=e[1],n=t.slice(r.length),s={id:r,label:r,shape:"rect"};for(let[a,c,d]of fM)if(n.startsWith(a)){let l=n.indexOf(c,a.length);if(l>=0){let u=Am(Om(n.slice(a.length,l)));s={id:r,label:u||r,shape:d},n=n.slice(l+c.length);break}}let o=n.match(/^:::([A-Za-z0-9_-]+)/),i;return o&&(i=o[1],n=n.slice(o[0].length)),{node:s,className:i,rest:n}}function Fv(t){let e={};for(let r of t.split(",")){let[n,...s]=r.split(":"),o=n.trim().toLowerCase(),i=s.join(":").trim();i&&(o==="fill"?e.fill=i:o==="stroke"?e.stroke=i:o==="color"&&(e.color=i))}return e}var pM=/^\s*(-\.->|-->|---|-\.-|==>|===|--o|--x)\s*/;function Uv(t){let e=t.replace(/\r/g,"").split(/[\n;]/).map(l=>l.trim()).filter(l=>l&&!l.startsWith("%%")),r="LR",n=new Map,s=[],o=l=>{let u=n.get(l.id);(!u||u.label===u.id&&l.label!==l.id)&&n.set(l.id,l)},i=new Map(Object.entries(Xl)),a=new Map,c=new Map,d=new Map;for(let l of e){let u=l.match(/^(flowchart|graph)\s+(LR|RL|TB|TD|BT)/i);if(u){let m=u[2].toUpperCase();if(r=m==="TD"?"TB":m,l=l.slice(u[0].length).trim(),!l)continue}let h=l.match(/^classDef\s+([A-Za-z0-9_-]+)\s+(.+)$/i);if(h){i.set(h[1],{...i.get(h[1]),...Fv(h[2])});continue}let p=l.match(/^class\s+([A-Za-z0-9_.,\s-]+?)\s+([A-Za-z0-9_-]+)\s*$/i);if(p){for(let m of p[1].split(",").map($=>$.trim()).filter(Boolean))a.set(m,p[2]);continue}let g=l.match(/^style\s+([A-Za-z0-9_.-]+)\s+(.+)$/i);if(g){c.set(g[1],{...c.get(g[1]),...Fv(g[2])});continue}let x=l.match(/^([A-Za-z0-9_.-]+)@\{(.+)\}\s*$/);if(x){let m=x[2].match(/\bshape\s*:\s*["']?([A-Za-z0-9_-]+)/i),$=Nm(m?.[1]);$&&(d.set(x[1],$),o({id:x[1],label:x[1],shape:$}));continue}if(/^(subgraph|end|linkStyle|click)\b/i.test(l))continue;let S=l,k=Vv(S);if(!k)continue;o(k.node),k.className&&a.set(k.node.id,k.className);let _=k.node.id;for(S=k.rest.trim();S;){let m,$=S.match(/^(--|-\.|==)\s*([^->|]+?)\s*(--?>|\.->|==>|---)/);$&&(m=Am(Om($[2])),S="-"+S.slice($[1].length+$[2].length).replace(/^\s+/,""));let f=S.match(pM);if(!f)break;let E=f[1];S=S.slice(f[0].length);let N=S.match(/^\|([^|]*)\|\s*/);N&&(m=Am(Om(N[1])),S=S.slice(N[0].length));let B=Vv(S.trim());if(!B)break;o(B.node),B.className&&a.set(B.node.id,B.className),s.push({from:_,to:B.node.id,label:m,arrow:!/^---$|^-\.-$|^===$/.test(E),dashed:E.includes(".")}),_=B.node.id,S=B.rest.trim()}}for(let l of n.values()){let u=a.get(l.id),h=u?i.get(u):void 0,p=c.get(l.id),g={...h,...p};g.fill&&(l.fill=g.fill),g.stroke&&(l.stroke=g.stroke),g.color&&(l.color=g.color);let x=d.get(l.id);x&&(l.shape=x)}return{direction:r,nodes:[...n.values()],edges:s}}function mM(t){if(t.image){let i=Math.min(248,t.image.w),a=t.image.h/t.image.w*i,c=t.label&&t.label!==t.id;return{w:Math.round(i+16),h:Math.round(a+(c?28:0)+16)}}let e=hM(t.label),r=Math.max(...e.split(`
|
|
134
|
+
`).map(i=>i.length),1),n=e.split(`
|
|
135
|
+
`).length,s=Math.max(70,r*8.6+34),o=Math.max(44,n*20+24);if(t.icon&&(o+=26),t.shape==="circle"){let i=Math.max(s,o);s=i,o=i}return(t.shape==="diamond"||t.shape==="hexagon")&&(s+=26,o+=14),t.shape==="stack"&&(s+=14,o+=16),t.shape==="cloud"&&(s+=36,o+=26),{w:s,h:o}}function Gv(t){let e=new Im.graphlib.Graph({multigraph:!0});e.setGraph({rankdir:t.direction,nodesep:46,ranksep:78,marginx:16,marginy:16}),e.setDefaultEdgeLabel(()=>({}));let r=new Map;for(let d of t.nodes){let l=mM(d);r.set(d.id,l),e.setNode(d.id,{width:l.w,height:l.h})}t.edges.forEach((d,l)=>e.setEdge(d.from,d.to,{labelpos:"c",width:d.label?d.label.length*7:0,height:d.label?16:0},`e${l}`)),Im.layout(e);let n=t.nodes.map(d=>{let l=e.node(d.id),u=r.get(d.id);return{...d,x:l.x-u.w/2,y:l.y-u.h/2,w:u.w,h:u.h}}),s=t.edges.map((d,l)=>{let h=(e.edge(d.from,d.to,`e${l}`)?.points??[]).map(p=>[p.x,p.y]);return{...d,points:h}}),o=1/0,i=1/0,a=-1/0,c=-1/0;for(let d of n)o=Math.min(o,d.x),i=Math.min(i,d.y),a=Math.max(a,d.x+d.w),c=Math.max(c,d.y+d.h);return isFinite(o)||(o=0,i=0,a=1,c=1),{nodes:n,edges:s,bounds:{minX:o,minY:i,maxX:a,maxY:c}}}var Cm={database:"M4 6c0-1.7 3.6-3 8-3s8 1.3 8 3-3.6 3-8 3-8-1.3-8-3M4 6v12c0 1.7 3.6 3 8 3s8-1.3 8-3V6M4 12c0 1.7 3.6 3 8 3s8-1.3 8-3",server:"M3 4h18v6H3zM3 14h18v6H3zM7 7h.01M7 17h.01",cloud:"M17.5 19a4.5 4.5 0 0 0 .5-9 6 6 0 0 0-11.7-1.5A4 4 0 0 0 6 19z",user:"M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2M12 11a4 4 0 1 0 0-8 4 4 0 0 0 0 8z",users:"M17 21v-2a4 4 0 0 0-3-3.87M9 21v-2a4 4 0 0 1 3-3.87M9 11a4 4 0 1 0 0-8 4 4 0 0 0 0 8zM19 8a3 3 0 0 1 0 6",lock:"M5 11h14v10H5zM8 11V7a4 4 0 0 1 8 0v4",key:"M21 2l-2 2m-3 3 3-3M10.5 13.5a4.5 4.5 0 1 1-2-2l8-8 2 2-2 2 2 2-3 3-2-2-3 3z",globe:"M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18zM3 12h18M12 3c2.5 2.5 3.5 6 3.5 9s-1 6.5-3.5 9c-2.5-2.5-3.5-6-3.5-9s1-6.5 3.5-9z",gear:"M12 15.5a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7zM19.4 15a1.6 1.6 0 0 0 .3 1.8l.1.1a2 2 0 1 1-2.8 2.8l-.1-.1a1.6 1.6 0 0 0-2.7 1.1V21a2 2 0 1 1-4 0v-.1A1.6 1.6 0 0 0 6.6 19.4l-.1.1a2 2 0 1 1-2.8-2.8l.1-.1a1.6 1.6 0 0 0-1.1-2.7H2a2 2 0 1 1 0-4h.1A1.6 1.6 0 0 0 4.6 6.6l-.1-.1a2 2 0 1 1 2.8-2.8l.1.1a1.6 1.6 0 0 0 1.8.3H9.4A1.6 1.6 0 0 0 10.5 2.6V2a2 2 0 1 1 4 0v.1a1.6 1.6 0 0 0 2.7 1.1l.1-.1a2 2 0 1 1 2.8 2.8l-.1.1a1.6 1.6 0 0 0-.3 1.8V9.4a1.6 1.6 0 0 0 1.5 1.1H21a2 2 0 1 1 0 4h-.1a1.6 1.6 0 0 0-1.5 1z",bolt:"M13 2 3 14h9l-1 8 10-12h-9z",zap:"M13 2 3 14h9l-1 8 10-12h-9z",check:"M20 6 9 17l-5-5",warning:"M12 2 2 20h20zM12 9v4M12 17h.01",alert:"M12 2 2 20h20zM12 9v4M12 17h.01",file:"M14 3H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9zM14 3v6h6",folder:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",code:"M16 18l6-6-6-6M8 6l-6 6 6 6",api:"M16 18l6-6-6-6M8 6l-6 6 6 6M13 4l-2 16",browser:"M3 4h18v16H3zM3 9h18M7 6.5h.01M10 6.5h.01",window:"M3 4h18v16H3zM3 9h18M7 6.5h.01M10 6.5h.01",mobile:"M7 3h10a1 1 0 0 1 1 1v16a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1zM11 18h2",phone:"M7 3h10a1 1 0 0 1 1 1v16a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1zM11 18h2",mail:"M3 5h18v14H3zM3 6l9 7 9-7",search:"M11 19a8 8 0 1 0 0-16 8 8 0 0 0 0 16zM21 21l-4.3-4.3",heart:"M19 14c1.5-1.5 3-3.3 3-5.5A4.5 4.5 0 0 0 12 5 4.5 4.5 0 0 0 2 8.5c0 2.2 1.5 4 3 5.5l7 7z",star:"M12 2l3 7 7 .5-5.3 4.6L18.5 22 12 18l-6.5 4 1.8-7.9L2 9.5 9 9z",clock:"M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18zM12 7v5l3 2",time:"M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18zM12 7v5l3 2",money:"M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18zM12 7v10M9.5 9.5a2.5 2 0 0 1 2.5-1.5c1.4 0 2.5.7 2.5 1.8s-1.1 1.7-2.5 1.7-2.5.7-2.5 1.8S10.6 16 12 16a2.5 2 0 0 0 2.5-1.5",box:"M21 8 12 3 3 8v8l9 5 9-5zM3 8l9 5 9-5M12 13v8",cart:"M3 4h2l2.5 12h11l2-8H6M9 20a1 1 0 1 0 0 2 1 1 0 0 0 0-2zM18 20a1 1 0 1 0 0 2 1 1 0 0 0 0-2z",shield:"M12 2 4 5v6c0 5 3.4 8.5 8 10 4.6-1.5 8-5 8-10V5z",flag:"M5 21V4M5 4h12l-2 4 2 4H5",send:"M22 2 11 13M22 2l-7 20-4-9-9-4z",rocket:"M5 16c-1.5 1.5-2 5-2 5s3.5-.5 5-2a2.8 2.8 0 0 0-3-3zM12 15l-3-3a16 16 0 0 1 7-8c3 0 4 1 4 4a16 16 0 0 1-8 7zM15 9h.01"};function gM(t){let e=t.trim();return!e||e.length>4e3||!/^[MmLlHhVvCcSsQqTtAaZz0-9.,\-+eE\s]+$/.test(e)||!/^[Mm]/.test(e)?null:e}function Yv(t){if(!t)return null;let e=t.trim().toLowerCase();return Cm[e]?Cm[e]:gM(t)}var aB=Object.keys(Cm);var yn="board.wb",_M=285,jm=140,bM=320,yM=280,vM=400,wM={rect:"rectangle",round:"roundRectangle",stadium:"roundRectangle",circle:"ellipse",diamond:"diamond",hexagon:"hexagon",subroutine:"rectangle",cylinder:"cylinder",stack:"stack",cloud:"cloud"},Xv=Object.fromEntries(Object.entries(Xl).map(([t,e])=>[e.fill,t]));function xM(t){return Math.max(1,t.trim().split(/\s+/).length)}function kM(t){return Math.max(1500,xM(t)*_M)}function Ia(t){return{children:[{text:t}]}}function Dm(t,e,r){let n=t.trim().split(/\s+/).filter(Boolean);if(!n.length)return[];let s=r/n.length;return n.map((o,i)=>({t:Math.round(e+s*i),text:o}))}function SM(t,e,r){let n=t.nodes.find(o=>o.id===e),s=n.label&&n.label!==n.id;return n.image?{id:e,type:"image",points:[[n.x,n.y],[n.x+n.w,n.y+n.h]],href:n.image.href,text:Ia(s?n.label:""),revealAt:r}:{id:e,type:"geometry",shape:wM[n.shape]??"rectangle",points:[[n.x,n.y],[n.x+n.w,n.y+n.h]],...n.stroke?{strokeColor:n.stroke}:{},strokeWidth:2,...n.fill?{fill:n.fill}:{},...n.color?{textColor:n.color}:{},...n.fill&&Xv[n.fill]?{tone:Xv[n.fill]}:{},...n.icon?{icon:n.icon}:{},text:Ia(n.label),revealAt:r}}function EM(t,e){let r=e.length,n=e[r-1],s=e[r-2]??e[0],o=n[0]-s[0],i=n[1]-s[1],a=Math.hypot(o,i)||1,c=o/a,d=i/a,l=12,u=6.5,h=n[0]-c*l,p=n[1]-d*l,g=-d,x=c;return{id:t,type:"arrow-head",points:[n,[h+g*u,p+x*u],[h-g*u,p-x*u]]}}function Wv(t,e={}){let r=Uv(t.mermaid),n=t.icons??{},s=e.images??{},o=t.shapes??{};r.nodes.forEach((m,$)=>{if(s[m.id]){m.image=s[m.id];return}let f=Nm(o[m.id]);f&&(m.shape=f);let E=Yv(n[m.id]);if(E&&(m.icon=E),t.theme==="pastel"&&!m.fill){let N=Hv($);m.fill=N.fill,m.stroke=N.stroke,m.color=N.color}});let i=Gv(r),a=new Map(i.nodes.map(m=>[m.id,m])),c=new Set(i.nodes.map(m=>m.id)),d=i.edges.map((m,$)=>{let f=`${m.from}__${m.to}__${$}`,E=m.points.length>=2,N=[m.from,m.to],B={id:f,type:"arrow-line",points:E?m.points:[],strokeWidth:2,dashed:m.dashed,target:{marker:"none"},ends:N},U=m.arrow&&E?{...EM(f+"__h",m.points),ends:N}:null,C=null;if(m.label&&m.points.length){let q=m.points[Math.floor(m.points.length/2)];C={id:f+"__l",type:"edge-label",points:[[q[0],q[1]]],text:Ia(m.label),ends:N}}return{from:m.from,to:m.to,lineEl:B,headEl:U,labelEl:C}}),l=[],u=[],h=1;l.push({t:h,type:"editor.switch",path:yn});let p=i.bounds,g={id:"__frame",type:"frame",points:[[p.minX-24,p.minY-24],[p.maxX+24,p.maxY+24]]};l.push({t:h,type:"wb.snapshot",path:yn,scene:[g]});let x=new Set,S=new Set,k=m=>m==null?[]:Array.isArray(m)?m:[m];t.steps.forEach((m,$)=>{let f=m.card,E=m.chapter?bM:0,N=h+E,B=m.holdMs??e.sayDurationsMs?.[$]??Math.max(m.say?kM(m.say):0,1400);if(m.chapter&&l.push({t:h,type:"marker",label:m.chapter}),f==="intro"){let A=(p.minX+p.maxX)/2,b=(p.minY+p.maxY)/2,D=Math.max(280,t.title.length*17),I=92,Y={id:"__title",type:"geometry",shape:"text",fontSize:30,points:[[A-D/2,b-I/2],[A+D/2,b+I/2]],text:Ia(t.title)};l.push({t:Math.round(N),type:"wb.delta",path:yn,changed:[Y],deleted:[]}),l.push({t:Math.round(N),type:"wb.selection",path:yn,ids:["__title"]});let V=N+B;l.push({t:Math.round(V),type:"wb.delta",path:yn,changed:[],deleted:["__title"]}),l.push({t:Math.round(V),type:"wb.selection",path:yn,ids:[]}),m.say&&u.push({t:N,dur:B,text:m.say,words:Dm(m.say,N,B)}),h=V+jm;return}if(f==="outro"){l.push({t:Math.round(N),type:"wb.selection",path:yn,ids:["__recap"]}),m.say&&u.push({t:N,dur:B,text:m.say,words:Dm(m.say,N,B)}),h=N+B+jm;return}let U=N,C=(A,...b)=>{l.push({t:Math.round(A),type:"wb.delta",path:yn,changed:b,deleted:[]}),U=Math.max(U,A)},q=k(m.show).filter(A=>c.has(A)&&!x.has(A));for(let A of q)C(N,SM(i,A,N)),x.add(A);for(let A of d){if(S.has(A.lineEl.id)||!x.has(A.from)||!x.has(A.to))continue;S.add(A.lineEl.id);let b=N+yM;C(b,A.lineEl);let D=[A.headEl,A.labelEl].filter(Boolean);D.length&&C(b+vM,...D)}let de=(k(m.point).length?k(m.point):k(m.show)).filter(A=>c.has(A));l.push({t:Math.round(N),type:"wb.selection",path:yn,ids:de}),m.say&&u.push({t:N,dur:B,text:m.say,words:Dm(m.say,N,B)}),h=Math.max(N+B,U+90)+jm}),l.sort((m,$)=>m.t-$.t);let _=[{t:0,vfs:{[yn]:""},activeFile:yn,terminalState:""}];return{manifest:{version:2,title:t.title,createdAt:e.createdAt??new Date().toISOString(),durationMs:Math.max(h,1500),appearance:t.appearance??"system"},events:l,snapshots:_,captions:u.length?u:void 0}}var Kv='Render a WHITEBOARD walkthrough: the author draws a diagram on a board \u2014 boxes, arrows, labels \u2014 sketching it on piece by piece while NARRATING, like a teacher explaining a concept at a whiteboard. Produces ONE self-contained interactive HTML (scrubbable, with voice). Use this for CONCEPTUAL explanations \u2014 architecture, data flow, how something works, mental models \u2014 where a drawn diagram teaches better than code. (For code, use create_walkthrough.)\n\nYou describe the diagram as a MERMAID flowchart (which you\'re great at) \u2014 NO coordinates; the server lays it out automatically with dagre. Then an ordered list of `steps` (beats) reveals and explains it.\n\n- mermaid: a flowchart, e.g. `flowchart LR\\n browser[Browser] -->|request| server[Server]\\n server -->|query| db[(Database)]`\n - directions: LR / RL / TB / BT\n - node shapes: [box] (round) ([stadium]) ((circle)) {diamond} {{hexagon}} [[subroutine]] [(cylinder)]\n - extra shapes \u2014 set via `shapes:{ id:"stack" }` or inline `id@{ shape: stack }`: stack (offset stacked rectangles \u2014 collections/replicas/layers) and cloud (internet / cloud service). Use a non-default shape only when it carries meaning.\n - edges: `-->` `---` `-.->` (dashed) `==>` (thick), with `|label|` or `-- label -->`\n - give every node a clear id \u2014 the beats reference those ids.\n- steps: each beat has a short `say` plus usually one `show` (a node id to reveal now; its edges to already-shown nodes draw in automatically) or `point` (id(s) to zoom to / highlight). The camera pans + zooms to whatever the beat is about. Nodes and arrows fade in with subtle micro-animations automatically \u2014 you don\'t author motion, just reveal one node per beat.\n\nKEEP IT CLEAN AND STYLISH \u2014 restraint reads as polish. A cohesive, mostly-neutral board beats a noisy one:\n- SHAPE: stick to ONE consistent node shape (usually plain boxes). Only use a different shape when it carries real meaning \u2014 a diamond for a decision, a cylinder/database for storage. Don\'t mix shapes for variety.\n- COLOR: WHITE shapes are the DEFAULT and the right choice for almost every board. Use color RARELY and with intent \u2014 only to highlight the ONE most important node, or to GROUP a few genuinely-related nodes (same color = same group). NEVER tint every node or mix many colors: a rainbow board (like every box a different pastel) reads as noise, not meaning. Cap it at 2\u20133 tones total. Tints: `A[Label]:::blue` / `class A,B blue` (blue, sky, green, mint, amber, peach, purple, lavender, rose, pink, teal, indigo, gray, slate) or `style A fill:#\u2026,stroke:#\u2026,color:#\u2026`. Do NOT use `theme:"pastel"` unless the content genuinely IS a color-coded category map \u2014 it auto-tints EVERY node and usually looks worse.\n- ICONS: optional and RARE \u2014 only when a glyph truly aids recognition (e.g. a database or user node). `icons: { db: "database" }` (built-ins: database, server, cloud, user, lock, globe, gear, bolt, code, api, browser, mobile, mail, search, money, shield, rocket \u2026 or a custom 24\xD724 SVG path). Don\'t icon every node; an un-iconed clean box is fine.\n- IMAGES: when a real picture helps (a screenshot, UI mockup, photo, logo), give that node an image URL via `images: { nodeId: "https://\u2026" }`. The server downscales it and bakes a compact WebP into the file, captioned with the node\'s label. Use a FEW at most \u2014 each adds weight; a bad URL just falls back to a plain box.\n\nTeach it like a real lesson (same principles as create_walkthrough):\n- HOOK on the problem/why, then build the picture ONE node at a time, in a logical order, then recap.\n- MANY short beats. Each `say` is one short idea (4\u201314 words); read in order the beats must flow as one continuous spoken explanation.\n- Reveal the node you\'re talking about AS you talk about it (one `show` per beat), then `point` at earlier nodes when you refer back to them.\n\nWorked shape \u2014 read top to bottom it\'s one flowing explanation (clean boxes, no decoration):\n mermaid: |\n flowchart LR\n browser[Browser] -->|request| server[Server]\n server -->|query| db[(Database)]\n steps:\n - { chapter:"The flow", say:"Say we\'ve got a browser.", show:"browser" }\n - { say:"It sends a request to a server,", show:"server" } // the browser\u2192server arrow + its "request" label draw in automatically\n - { say:"which owns the database,", show:"db" }\n - { say:"and queries it for data.", point:"db" }\n - { say:"So the browser never touches the database directly.", point:["browser","db"] }\n\nVOICE: pick `voiceName` (the narrator\'s voice \u2014 cedar, nova, onyx, sage, shimmer \u2026; see the field for the full list) and set `voiceTone` to match the topic \u2014 e.g. "warm and clear, like a patient teacher at a whiteboard" for a concept, "calm and precise" for an architecture/security walk-through, "energetic and curious" for a fun explainer. The tone steers how the narrator sounds (a natural human delivery is always layered on top).\n\nINTRO & OUTRO: the server auto-frames the board with a spoken intro (shown as a title card) and ALWAYS ends with a short wrap-up CONCLUSION spoken over the finished diagram (camera pulls back to show the whole thing). So DON\'T author your own welcome/sign-off beats; begin your steps at the first real node and let the last content beat be the last real point. Customize the wording with `intro`/`outro` \u2014 the outro should be a one/two-sentence recap of the big idea plus a sign-off.\n\nDelivery is identical to create_walkthrough: the PRIMARY result is a http://127.0.0.1:<port>/<id>.html URL (a resource_link) \u2014 give that link to the user to open in their browser.';import TM from"sharp";var Jv=520,$M=70,RM=12*1024*1024,PM=15e3;async function Lm(t){if(!/^https?:\/\//i.test(t))return null;try{let e=await fetch(t,{signal:AbortSignal.timeout(PM),redirect:"follow"});if(!e.ok)return null;let r=e.headers.get("content-type")||"";if(r&&!/^image\//i.test(r))return null;let n=Buffer.from(await e.arrayBuffer());if(!n.length||n.length>RM)return null;let s=await TM(n,{failOn:"none",animated:!1}).rotate().resize({width:Jv,height:Jv,fit:"inside",withoutEnlargement:!0}).webp({quality:$M}).toBuffer({resolveWithObject:!0});return{href:`data:image/webp;base64,${s.data.toString("base64")}`,w:s.info.width,h:s.info.height}}catch{return null}}async function Qv(t){let e={};return await Promise.all(Object.entries(t).map(async([r,n])=>{let s=await Lm(n);s&&(e[r]=s)})),e}var MM={id:"whiteboard",tool:{name:"create_whiteboard_walkthrough",title:"Create a narrated whiteboard diagram",description:Kv},promptLine:"\u2022 WHITEBOARD \u2014 a diagram drawn on a board (concepts, architecture, data flow) \u2192 create_whiteboard_walkthrough",schema:ym,makeBeat:(t,e)=>({say:t,card:e}),forceOutro:!0,async prepare(t){let e=t.images&&Object.keys(t.images).length?await Qv(t.images):{};return Object.keys(e).length?{images:e}:{}},compile:(t,e)=>Wv(t,e)},ew=MM;var zM="TTS voice to narrate with. Defaults to cedar (warm, natural). Options: "+Lr.map(t=>`${t} (${fs[t]})`).join(", ")+".",IM=G.object({say:G.string().optional().describe("Narration for this beat \u2014 ONE short idea (4\u201314 words), spoken aloud. Read in order, the beats form one continuous explanation."),marker:G.string().optional().describe('A place name to drop a labeled pin on this beat (e.g. "Eiffel Tower, Paris"). The camera flies to it unless `goTo` overrides. Reveal one place per beat.'),goTo:G.string().optional().describe('A place/area name to FLY the camera to this beat without necessarily dropping a pin (e.g. "the Alps", "France") \u2014 for establishing/overview shots.'),zoom:G.number().min(1).max(19).optional().describe("Map zoom level for this beat (1 = whole world, ~5 = country, ~11 = city, ~15 = streets). Defaults to a sensible level for a marker vs an overview."),route:G.array(G.string()).min(2).optional().describe('Draw a road/route through these place names in order (2+), e.g. ["Paris","Lyon","Marseille"]. Drawn as an animated line; the camera frames it.'),region:G.array(G.string()).min(3).optional().describe('Highlight an area by connecting these place names into a polygon (3+ corners), e.g. ["Lisbon","Madrid","Barcelona"].'),chapter:G.string().optional().describe("If set, starts a named chapter at this beat (timeline marker)."),holdMs:G.number().optional().describe("Beat duration in ms. Defaults to a duration derived from the narration.")}),Zm={title:G.string().describe("Title of the map walkthrough (header + filename)."),outputPath:G.string().optional().describe("Optional path to also write the .html to (same mapping as create_walkthrough)."),voiceName:G.enum(Lr).optional().describe(zM),voiceTone:G.string().optional().describe('How the narrator should SOUND, matched to the topic (e.g. "warm and adventurous" for a travel story). A natural human delivery is always layered on top.'),intro:G.string().optional().describe("Opening line spoken before the tour. Defaults to a title-based welcome; set to '' to skip."),outro:G.string().optional().describe("Closing wrap-up line spoken at the end (always added). Customize the wording here."),tiles:G.enum(["streets","light","dark","satellite"]).default("streets").describe("Basemap style: 'streets' (default OSM), 'light'/'dark' (minimal Carto), or 'satellite' (Esri imagery). Pick what fits the topic."),steps:G.array(IM).min(1).describe("The ordered tour as a STORY: open on the big picture, then move place to place \u2014 drop a pin, draw a route, highlight a region \u2014 narrating throughout. MANY short beats; the `say` lines must read as one continuous script.")},xB=G.object(Zm);var OM=t=>Math.max(1,t.trim().split(/\s+/).length),AM=t=>Math.max(1600,OM(t)*350);function NM(t,e,r){let n=t.trim().split(/\s+/).filter(Boolean);if(!n.length)return[];let s=r/n.length;return n.map((o,i)=>({t:Math.round(e+s*i),text:o}))}function Bm(t){if(!t.length)return null;let e=1/0,r=1/0,n=-1/0,s=-1/0;for(let[o,i]of t)e=Math.min(e,o),n=Math.max(n,o),r=Math.min(r,i),s=Math.max(s,i);return[[e,r],[n,s]]}function CM(){return 13}function tw(t,e={}){let r=e.geo??{},n=e.routes??{},s=x=>x&&r[x]?r[x]:null,o=Object.values(r).map(x=>[x.lat,x.lng]),i=Bm(o),a=o.length?{lat:o.reduce((x,S)=>x+S[0],0)/o.length,lng:o.reduce((x,S)=>x+S[1],0)/o.length}:{lat:20,lng:0},c=i?{lat:a.lat,lng:a.lng,zoom:4,bounds:i}:{lat:20,lng:0,zoom:2},d=[],l=[],u=[],h=1;t.steps.forEach((x,S)=>{let k=x.chapter?450:0,_=h+k,m=x.holdMs??e.sayDurationsMs?.[S]??Math.max(x.say?AM(x.say):0,1600);x.chapter&&u.push({t:h,type:"marker",label:x.chapter});let $={t:Math.round(_)};if(x.card==="intro"||x.card==="outro")$.camera=c;else{let f=[],E=s(x.marker);if(E){let U={lat:E.lat,lng:E.lng,label:x.marker};f.push(U)}f.length&&($.markers=f);let N=n[S];if(N&&N.length>=2){$.route=N;let U=Bm(N);U&&($.camera={lat:(U[0][0]+U[1][0])/2,lng:(U[0][1]+U[1][1])/2,zoom:6,bounds:U})}if(x.region){let U=x.region.map(s).filter(Boolean).map(C=>[C.lat,C.lng]);if(U.length>=3){$.region=U;let C=Bm(U);C&&($.camera={lat:(C[0][0]+C[1][0])/2,lng:(C[0][1]+C[1][1])/2,zoom:6,bounds:C})}}let B=s(x.goTo);B?$.camera={lat:B.lat,lng:B.lng,zoom:x.zoom??7}:E&&!$.route&&!$.region?$.camera={lat:E.lat,lng:E.lng,zoom:x.zoom??CM()}:x.zoom&&$.camera&&($.camera.zoom=x.zoom)}d.push($),x.say&&l.push({t:_,dur:m,text:x.say,words:NM(x.say,_,m)}),h=_+m+250});let p={tiles:t.tiles??"streets",beats:d},g=[{t:0,vfs:{},activeFile:null,terminalState:""}];return{manifest:{version:2,title:t.title,createdAt:e.createdAt??new Date().toISOString(),durationMs:Math.max(h,1500),mode:"map"},events:u,snapshots:g,captions:l.length?l:void 0,map:p}}var rw=`Render a MAP walkthrough: a narrated tour over a real map \u2014 drop pins on places, draw routes between them, highlight regions, and fly the camera, like a travel/geography/history storyteller. Produces ONE self-contained interactive HTML (scrubbable, with voice; the map fetches tiles live, so it needs internet to view). Use this for anything geographic \u2014 travel, history, logistics, "where things are," expansion/spread over a map.
|
|
136
|
+
|
|
137
|
+
You write PLACE NAMES (your strength) \u2014 the server geocodes them to coordinates and routes roads automatically. Never write lat/long.
|
|
138
|
+
|
|
139
|
+
- tiles: basemap style \u2014 "streets" (default), "light", "dark", or "satellite". Pick what fits.
|
|
140
|
+
- steps: each beat has a short \`say\` plus one map action:
|
|
141
|
+
- \`marker\`: a place name \u2192 drops a labeled pin and flies there ("Eiffel Tower, Paris")
|
|
142
|
+
- \`goTo\`: fly to an area/overview without a pin ("the Alps")
|
|
143
|
+
- \`zoom\`: 1 (world) \u2026 5 (country) \u2026 11 (city) \u2026 15 (streets)
|
|
144
|
+
- \`route\`: ["Paris","Lyon","Marseille"] \u2192 draws the road and frames it
|
|
145
|
+
- \`region\`: ["Lisbon","Madrid","Barcelona"] \u2192 highlights the area
|
|
146
|
+
- Teach it like a STORY: open wide, then move place to place, one beat each, narrating continuously. MANY short beats; the \`say\` lines read as one script.
|
|
147
|
+
- VOICE: pick \`voiceName\` + \`voiceTone\` to fit the topic (e.g. "warm and adventurous" for travel).
|
|
148
|
+
- INTRO & OUTRO are auto-added (an opening overview + a wrap-up recap), so don't author your own welcome/sign-off beats.
|
|
149
|
+
|
|
150
|
+
Worked shape:
|
|
151
|
+
tiles: "streets"
|
|
152
|
+
steps:
|
|
153
|
+
- { chapter:"The route", say:"Our journey starts in Paris.", marker:"Paris, France" }
|
|
154
|
+
- { say:"We head south to Lyon,", marker:"Lyon, France" }
|
|
155
|
+
- { say:"then on to the coast at Marseille.", marker:"Marseille, France" }
|
|
156
|
+
- { say:"This is the whole drive.", route:["Paris, France","Lyon, France","Marseille, France"] }
|
|
157
|
+
|
|
158
|
+
Delivery is identical to the other tools: the PRIMARY result is a http://127.0.0.1:<port>/<id>.html URL (a resource_link) \u2014 give that link to the user.`;var jM="https://nominatim.openstreetmap.org/search",DM="https://router.project-osrm.org/route/v1/driving",nw="FlowCast/0.1 (map walkthrough generator)";var qm=new Map;async function LM(t){let e=t.trim().toLowerCase();if(!e)return null;if(qm.has(e))return qm.get(e);let r=null;try{let n=`${jM}?q=${encodeURIComponent(t)}&format=json&limit=1`,s=await fetch(n,{headers:{"user-agent":nw,accept:"application/json"},signal:AbortSignal.timeout(12e3)});if(s.ok){let o=await s.json();o?.length&&(r={lat:Number(o[0].lat),lng:Number(o[0].lon)})}}catch{}return qm.set(e,r),r}async function sw(t){let e={};return await Promise.all([...new Set(t)].map(async r=>{let n=await LM(r);n&&(e[r]=n)})),e}async function ow(t){if(t.length<2)return null;let e=t.map(r=>`${r.lng},${r.lat}`).join(";");try{let r=`${DM}/${e}?overview=full&geometries=geojson`,n=await fetch(r,{headers:{"user-agent":nw},signal:AbortSignal.timeout(12e3)});if(n.ok){let o=(await n.json()).routes?.[0]?.geometry?.coordinates;if(o?.length)return o.map(([i,a])=>[a,i])}}catch{}return t.map(r=>[r.lat,r.lng])}var ZM={id:"map",tool:{name:"create_map_walkthrough",title:"Map walkthrough",description:rw},promptLine:"\u2022 MAP \u2014 a narrated tour over a real map (travel, geography, history, logistics) \u2192 create_map_walkthrough",schema:Zm,mode:"map",makeBeat:(t,e)=>({say:t,card:e}),forceOutro:!0,async prepare(t){let e=new Set;for(let s of t.steps)s.marker&&e.add(s.marker),s.goTo&&e.add(s.goTo),(s.route??[]).forEach(o=>e.add(o)),(s.region??[]).forEach(o=>e.add(o));let r=await sw([...e]),n={};return await Promise.all(t.steps.map(async(s,o)=>{if(!s.route)return;let i=s.route.map(a=>r[a]).filter(Boolean);if(i.length>=2){let a=await ow(i);a&&(n[o]=a)}})),{geo:r,routes:n}},compile:(t,e)=>tw(t,e)},iw=ZM;var BM="TTS voice to narrate with. Defaults to cedar (warm, natural). Options: "+Lr.map(t=>`${t} (${fs[t]})`).join(", ")+".",aw=["box","sphere","cylinder","cone","plane","torus","icosahedron","pyramid","wedge","disc","ring","tube","dome"],cw="Primitives: box (rounded), sphere, cylinder, cone, pyramid, wedge, disc, ring, torus, tube, dome, icosahedron, plane. cylinder = database/tank/disk; sphere = node/user/planet; cone/pyramid = rocket-nose/tent/peak; disc = coin/plate/platform; ring/torus = loop/orbit/network; tube = pipe/connector; dome = hill/cap; icosahedron = crystal/core; box = service/building/block (and stat bars: box + tall Y scale).",qM=G.object({shape:G.enum(aw).default("box").describe("Primitive for this piece. "+cw),at:G.tuple([G.number(),G.number(),G.number()]).default([0,0,0]).describe("LOCAL offset [x,y,z] from the object center (x=right, y=up, z=depth). Stack/arrange parts to form the shape."),size:G.union([G.number(),G.tuple([G.number(),G.number(),G.number()])]).default(1).describe("Size of this piece \u2014 a single number or [x,y,z]. Relative to the object (parts ~0.2\u20132)."),color:G.string().optional().describe("CSS color for this piece. Defaults to the object color."),rotation:G.tuple([G.number(),G.number(),G.number()]).optional().describe("Optional local rotation [x,y,z] in RADIANS.")}),VM=G.object({id:G.string().describe("Unique id the beats reference."),shape:G.enum(aw).default("box").describe("A basic geometric PRIMITIVE \u2014 use ONLY when the object genuinely is one (a sphere node, a cylinder tank, a box/stat-bar). For anything recognizable or non-geometric, use `svg` instead (extruded), not a primitive. "+cw),parts:G.array(qM).max(10).optional().describe('FALLBACK only \u2014 prefer `svg` for custom objects (it looks far better). Use `parts` just for blocky/technical assemblies that are awkward as a 2D silhouette (e.g. a stack of server racks, a layered diagram). If you do use it: use 5\u20139 parts, NOT 2 \u2014 a 2-part object looks crude. Give it correct proportions, VARY the colors (a base color + 1\u20132 accents + dark detail), and add small DETAIL parts (windows, a door, a stripe, a light, trim) so it reads as a real object, not a blob. Stack parts precisely in LOCAL space (origin = its base on the floor). Examples: tree = tall cylinder trunk (brown) + 2\u20133 stacked cones of slightly different greens; house = box walls (light) + pyramid roof (terracotta) + small box door + 2 small box windows (blue); rocket = tall cylinder body (white) + cone nose (red) + 3 box fins + a small disc window + cone exhaust; server = box chassis (dark) + 3\u20134 thin box "slot" plates + 2 tiny glowing spheres (LEDs); person = sphere head + capsule torso + 2 thin cylinder arms + a small box base. Avoid: a single box, or 2 plain same-colored parts. The whole object is auto-scaled + grounded, so just lay parts around the origin.'),svg:G.string().optional().describe('Inline SVG for a SIMPLE SOLID ICON that the server extrudes into 3D \u2014 use it for a single recognizable silhouette (a pin, leaf, heart, arrow, gear, key, star, simple logo). Keep it ONE clean filled shape (a single `<path>`/`<polygon>` is ideal); the `fill` becomes the color. Do NOT build complex multi-color artwork (flags, detailed logos, scenes) as SVG \u2014 use `image` for those. Any viewBox is fine (auto-scaled/centered/grounded). Example: \'<svg viewBox="0 0 100 100"><path fill="#7cc6ff" d="M50 4 ... Z"/></svg>\'.'),image:G.string().optional().describe("An IMAGE URL (https://\u2026) for anything complex or detailed \u2014 a flag, photo, detailed logo, map, diagram, or real picture. The server fetches it, optimizes it (resized webp) and embeds it, then renders it as a clean textured panel standing in the scene with EXACT colors. Use this instead of `svg`/`parts` whenever the visual is intricate or must look real."),model:G.string().optional().describe("Advanced: a glTF/GLB URL (https://\u2026) or a local .glb/.gltf path to embed a REAL imported 3D model. Use for true volumetric objects."),label:G.string().optional().describe("Floating label shown next to the object (with a leader line pointing at it)."),value:G.number().optional().describe('A numeric value shown UNDER the label, counting up from 0 when the object appears. Great for stats/charts (pair with shape:"box" + scale:[1, value, 1]).'),valueSuffix:G.string().optional().describe('Unit appended to the counted value, e.g. "M", "%", "ms", "k". Prefix like "$" works too if you put it here as the suffix renders verbatim.'),color:G.string().optional().describe('CSS color (e.g. "#7cc6ff" or "tomato"). Defaults to a pleasant auto color.'),size:G.number().optional().describe("Relative size (default 1). 2 = twice as big."),scale:G.union([G.number(),G.tuple([G.number(),G.number(),G.number()])]).optional().describe('Non-uniform scale \u2014 a single number, or [x, y, z]. Use a tall Y for a STAT BAR (e.g. shape:"box", scale:[1, 4, 1] makes a bar 4\xD7 tall so HEIGHT encodes the value). Combines with `size`.'),finish:G.enum(["matte","glossy","metal","gradient","matcap","glass","iridescent"]).optional().describe("Surface material: 'matte', 'glossy', 'metal', 'gradient' (top-lit gradient), 'matcap' (baked sheen), 'glass' (frosted translucent), 'iridescent' (oil-slick sheen). Glass/iridescent catch the light beautifully."),path:G.array(G.tuple([G.number(),G.number(),G.number()])).optional().describe("CINEMATIC: a poly-line of [x,y,z] points the object travels along over the tour (e.g. a dot tracing a route, a probe flying a trajectory). 2+ points; the server smooths it into a curve."),pedestal:G.boolean().optional().describe("Place a subtle round platform under the object so it feels seated on the floor (nice for showcased items)."),reveal:G.enum(["grow","pop","fade","drop","rise"]).optional().describe("Entrance animation: 'grow' rises from the floor (stat bars/charts), 'pop' scales in, 'fade' fades in, 'drop' drops in with a bounce, 'rise' emerges upward. Default 'pop'."),motion:G.enum(["none","spin","bob","orbit"]).optional().describe("Idle motion. Default 'none' \u2014 the object rests still ON THE FLOOR. 'spin' = slow turntable (stays grounded), 'bob' = gentle float (lifts off the floor \u2014 use sparingly), 'orbit' = circle the scene center and float (e.g. a planet)."),at:G.tuple([G.number(),G.number(),G.number()]).optional().describe("Optional explicit position [x, y, z] (x=right, y=up, z=depth). Omit for an automatic presentation layout. Only set this when spatial arrangement carries meaning.")}),FM=G.object({say:G.string().optional().describe("Narration for this beat \u2014 ONE short idea (4\u201314 words), spoken aloud. Read in order, the beats form one continuous explanation."),show:G.union([G.string(),G.array(G.string())]).optional().describe("Object id(s) to REVEAL on this beat (they scale into the scene). Reveal one per beat for a natural build-up."),focus:G.string().optional().describe("Object id to move the camera to and frame this beat (like walking up to it)."),overview:G.boolean().optional().describe("Frame the whole staged scene this beat. Overview beats reveal the full model so the tour never opens on an empty canvas."),orbit:G.boolean().optional().describe("Slowly orbit around the focused object during this beat (a turntable look)."),showcase:G.string().optional().describe("Hero-SHOWCASE this object id (Apple product-reveal style): frame it on a plinth and slowly rotate it on a turntable while its label appears. Great for presenting one key object."),highlight:G.array(G.string()).optional().describe("Object/chart ids to SPOTLIGHT this beat while everything else recedes \u2014 great for comparing 2\u20133 items."),filter:G.array(G.string()).optional().describe("Object ids to KEEP this beat \u2014 everything else fades almost out (a stronger focus than highlight, for isolating a subset)."),callout:G.object({target:G.string(),text:G.string()}).optional().describe('Pin an annotation note (leader line + short text) onto an object/chart this beat, e.g. { target:"sales", text:"record high" }.'),set:G.object({target:G.string(),values:G.array(G.number())}).optional().describe("Change a CHART's data on this beat (before\u2192after): bars/segments animate to the new `values` and a delta badge (\u25B2/\u25BC) shows the change. `target` is the chart id; `values` matches its data length."),chapter:G.string().optional().describe("If set, starts a named chapter at this beat (timeline marker)."),holdMs:G.number().optional().describe("Beat duration in ms. Defaults to a duration derived from the narration.")}),HM=G.object({label:G.string().optional().describe("Category label (axis tick / segment label)."),value:G.number().describe("The numeric value."),color:G.string().optional().describe("Optional per-datum color (else the chart accent).")}),UM=G.object({id:G.string().describe("Unique id beats reference via show/focus (a chart behaves like an object)."),type:G.enum(["bar","line","area","pie","donut","ring"]).describe("Chart kind: 'bar' (columns grow + count up), 'line'/'area' (time-series drawn left\u2192right with point markers), 'pie'/'donut' (segments sweep in), 'ring' (a single % gauge \u2014 value vs max)."),data:G.array(HM).min(1).describe("The data points. For a ring use a single datum (value vs max = the %)."),at:G.tuple([G.number(),G.number(),G.number()]).optional().describe("Position [x,y,z]; omit to auto-place. The chart sits on the floor."),width:G.number().optional().describe("Horizontal extent (default ~6)."),height:G.number().optional().describe("Vertical extent \u2014 the value mapped to `max` (default ~4)."),max:G.number().optional().describe("Value mapped to full height/percent (defaults to the largest data value)."),unit:G.string().optional().describe('Unit appended to value labels (e.g. "%", "M", "ms").'),color:G.string().optional().describe("Accent color for series without their own color."),label:G.string().optional().describe("Chart title shown above it.")}),Vm={title:G.string().describe("Title of the 3D walkthrough (header + filename)."),pace:G.enum(["calm","normal","snappy"]).optional().describe("Animation tempo (default 'normal'): 'calm' = slower, cinematic; 'normal' = brisk, tight pacing; 'snappy' = fastest reveals + camera. Affects all entrance/transition/camera timings."),outputPath:G.string().optional().describe("Optional path to also write the .html to (same mapping as create_walkthrough)."),voiceName:G.enum(Lr).optional().describe(BM),voiceTone:G.string().optional().describe("How the narrator should SOUND, matched to the topic. A natural human delivery is always layered on top."),intro:G.string().optional().describe("Opening line spoken before the tour. Defaults to a title-based welcome; set to '' to skip."),outro:G.string().optional().describe("Closing wrap-up line spoken at the end (always added). Customize the wording here."),background:G.string().optional().describe('Solid scene background CSS color (default a dark studio backdrop). It is a clean solid color + a grid floor \u2014 a real 3D stage, not outer space. Prefer a deep, slightly-not-black color (e.g. "#0d1018", "#10131c").'),floor:G.string().optional().describe("Optional floor color (defaults to a shade just off the background so the ground/horizon reads). Use a related dark tone."),template:G.enum(["solar-system","molecule","network","stack"]).optional().describe("Optional ready-made scene the server builds for you: 'solar-system' (sun + planets that orbit, on a starfield), 'molecule' (atoms + bonds), 'network' (nodes + links), 'stack' (layered plates). When set, you can omit `objects` (the template generates them) or add a few of your own; your beats still drive the tour."),connections:G.array(G.object({from:G.string(),to:G.string(),label:G.string().optional()})).optional().describe('Relationships drawn as glowing beams between objects, with energy flowing from\u2192to. Great for showing how parts connect (e.g. { from:"gateway", to:"service" }).'),charts:G.array(UM).max(8).optional().describe("Animated CHARTS (infographic style). Each chart has an id beats reveal via `show`/`focus`. Bars grow + count up, lines/areas draw left\u2192right in story order, pie/donut sweep, ring fills. Add an axis automatically."),objects:G.array(VM).max(14).optional().describe("The objects in the scene. Keep it focused: 3-8 labeled objects usually works best. GEOMETRY PRIORITY: (1) basic geometric form \u2192 `shape` primitive; (2) a simple recognizable icon/silhouette \u2192 `svg` (single solid path, extruded); (3) anything complex/detailed/real (flag, photo, detailed logo, map) \u2192 `image` URL (embedded as a textured panel); (4) blocky technical assembly \u2192 `parts`; (5) true 3D mesh \u2192 `model` glTF. SPACING: omit `at` for auto layout; objects always sit on/above the floor."),steps:G.array(FM).min(1).describe("The ordered tour as a STORY: open with an overview, then reveal/focus ONE object at a time while explaining, orbit the important one, then recap. MANY short beats; the `say` lines must read as one continuous script.")},AB=G.object(Vm);import{readFile as GM,stat as YM}from"node:fs/promises";var XM=new Set(["planet","moon","sun","star","satellite","atom","molecule","server","database","db","cloud","gear","cog","rocket","building","tree","person","user","cube","box","ring","coin","pin"]);function Fm(t){return!!t&&XM.has(t.trim().toLowerCase())}var WM=16*1024*1024,KM=2e4,uw=t=>/\.(glb|gltf)(\?|$)/i.test(t);function lw(t,e){return!t.length||t.length>WM?null:`data:${/\.glb(\?|$)/i.test(e)||t.subarray(0,4).toString("binary")==="glTF"?"model/gltf-binary":"model/gltf+json"};base64,${t.toString("base64")}`}async function JM(t){let e=t.trim();try{if(/^https?:\/\//i.test(e)){let s=await fetch(e,{signal:AbortSignal.timeout(KM),redirect:"follow"});return s.ok?lw(Buffer.from(await s.arrayBuffer()),e):null}let r=e.startsWith("file://")?new URL(e).pathname:e;if(!uw(r))return null;let n=await YM(r).catch(()=>null);return!n||!n.isFile()?null:lw(await GM(r),r)}catch{return null}}function QM(t){return!t||Fm(t)?!1:/^https?:\/\//i.test(t)||t.startsWith("file://")||uw(t)}async function dw(t){let e={};return await Promise.all(t.map(async r=>{if(QM(r.model)){let n=await JM(r.model);n&&(e[r.id]=n)}})),e}var ez=285,tz={calm:{gap:250,chapter:450},normal:{gap:140,chapter:320},snappy:{gap:90,chapter:240}},Wl=["#7cc6ff","#9be08b","#ffd166","#ff8c69","#c89bff","#5ad1c4","#ff9ecb","#a0d8ef"],rz=t=>Math.max(1,t.trim().split(/\s+/).length),nz=t=>Math.max(1600,rz(t)*ez);function sz(t,e,r){let n=t.trim().split(/\s+/).filter(Boolean);if(!n.length)return[];let s=r/n.length;return n.map((o,i)=>({t:Math.round(e+s*i),text:o}))}var Oa=(t,e)=>[t[0]+e[0],t[1]+e[1],t[2]+e[2]],fw=(t,e)=>Math.hypot(t[0]-e[0],t[1]-e[1],t[2]-e[2]),oz=t=>t==null?[]:Array.isArray(t)?t:[t];function iz(t,e){if(e<=1)return[0,0,0];if(e<=5)return[(t-(e-1)/2)*5.2,0,0];let r=Math.ceil(Math.sqrt(e)),n=Math.ceil(e/r);return[(t%r-(r-1)/2)*5,0,(Math.floor(t/r)-(n-1)/2)*-4.2]}var Hm=(t,e,r,n=0)=>{let s=t/Math.max(1,e)*Math.PI*2;return[Math.cos(s)*r,n,Math.sin(s)*r]};function az(t,e){let r=u=>u.model?Fm(u.model)?u.model.trim().toLowerCase():e[u.id]:void 0,n=u=>u==null?[1,1,1]:typeof u=="number"?[u,u,u]:u,s=u=>u==null?[1,1,1]:typeof u=="number"?[u,u,u]:u,o=(u,h)=>u.parts?.length?u.parts.map(p=>({shape:p.shape??"box",pos:p.at??[0,0,0],size:s(p.size),color:p.color||h,...p.rotation?{rotation:p.rotation}:{}})):void 0,i=(u,h,p,g={})=>{let x=u.color||Wl[h%Wl.length],S=o(u,x);return{id:u.id,shape:u.shape??"box",pos:p,size:u.size??1,scale:n(u.scale),color:x,...u.label?{label:u.label}:{},...u.value!=null?{value:u.value}:{},...u.valueSuffix?{valueSuffix:u.valueSuffix}:{},...S?{parts:S}:{},...u.svg&&!S?{svg:u.svg}:{},...!S&&r(u)?{model:r(u)}:{},...u.reveal?{reveal:u.reveal}:{},...u.finish?{finish:u.finish}:{},...u.pedestal?{pedestal:!0}:{},...u.path?.length?{path:u.path}:{},motion:u.motion??"none",...g}},a=t.objects??[],c=[...t.connections??[]],d=!1;t.template==="solar-system"&&a.length===0?a=[{id:"sun",shape:"sphere",label:"Sun",color:"#ffcf5a",size:2.4},{id:"mercury",shape:"sphere",label:"Mercury",color:"#b7a18a",size:.5},{id:"venus",shape:"sphere",label:"Venus",color:"#e6c07a",size:.8},{id:"earth",shape:"sphere",label:"Earth",color:"#6bb6ff",size:.85},{id:"mars",shape:"sphere",label:"Mars",color:"#e07a5f",size:.7}]:t.template==="molecule"&&a.length===0&&(a=[{id:"o",shape:"sphere",label:"O",color:"#ff6b6b",size:1.2},{id:"h1",shape:"sphere",label:"H",color:"#dfe6ee",size:.7},{id:"h2",shape:"sphere",label:"H",color:"#dfe6ee",size:.7}]);let l;if(t.template==="solar-system")d=!0,l=a.map((u,h)=>{if(h===0)return i(u,h,[0,0,0],{glow:!0,motion:u.motion??"spin",shape:u.shape??"sphere"});let p=5+(h-1)*3.2;return i(u,h,Hm(h-1,Math.max(3,a.length-1),p),{shape:u.shape??"sphere",motion:"orbit",orbit:{radius:p,speed:.18/Math.sqrt(h),phase:h/a.length*Math.PI*2}})});else if(t.template==="molecule"){if(l=a.map((u,h)=>h===0?i(u,h,[0,0,0],{shape:u.shape??"sphere"}):i(u,h,Hm(h-1,a.length-1,2.6,(h%2?1:-1)*.6),{shape:u.shape??"sphere"})),c.length===0)for(let u=1;u<a.length;u++)c.push({from:a[0].id,to:a[u].id})}else t.template==="network"?l=a.map((u,h)=>i(u,h,Hm(h,a.length,Math.max(4,a.length*.9),(h%2?1:-1)*.8))):t.template==="stack"?l=a.map((u,h)=>i(u,h,[0,(a.length-1)/2-h,0],{shape:u.shape??"box",motion:u.motion??"none",size:u.size??1.6})):l=a.map((u,h)=>i(u,h,u.at?u.at:iz(h,a.length)));return{objects:l,connections:c,starfield:d}}function hw(t,e={}){let{objects:r,connections:n,starfield:s}=az(t,e.models??{}),o=new Map(r.map(I=>[I.id,I]));for(let I of r){let Y=e.images?.[I.id];Y&&(I.image=Y.href,I.imageAspect=Y.h>0?Y.w/Y.h:1)}let i=t.charts??[],a=4.5,c=i.map(I=>I.width??6),l=-(c.reduce((I,Y)=>I+Y,0)+a*Math.max(0,i.length-1))/2,u=r.map(I=>I.pos[2]),h=r.length?Math.min(0,...u)-9:0,p=i.map((I,Y)=>{let V=c[Y],ee=I.height??4,L=l+V/2;l+=V+a;let T=I.at?I.at:[L,0,h];return{id:I.id,type:I.type,pos:T,width:V,height:ee,data:I.data.map(y=>({...y.label?{label:y.label}:{},value:y.value,...y.color?{color:y.color}:{}})),max:I.max??Math.max(...I.data.map(y=>y.value),1),...I.unit?{unit:I.unit}:{},color:I.color||Wl[(r.length+Y)%Wl.length],...I.label?{label:I.label}:{}}}),g=new Map(p.map(I=>[I.id,I])),x=I=>o.has(I)||g.has(I),S=[...r.map(I=>I.pos),...p.map(I=>I.pos)],k=S.length,_=k?[S.reduce((I,Y)=>I+Y[0],0)/k,S.reduce((I,Y)=>I+Y[1],0)/k,S.reduce((I,Y)=>I+Y[2],0)/k]:[0,0,0],m=Math.max(5,...r.map(I=>fw(I.pos,_)+I.size*1.6),...p.map(I=>fw(I.pos,_)+Math.max(I.width,I.height))),$=()=>({pos:Oa(_,[0,m*.7,m*2.7]),look:_}),f=()=>({pos:Oa(_,[m*1.9,m*.55,m*1.9]),look:_}),E=(I,Y)=>{let V=o.get(I);if(V){let L=V.size*4.6+6;return{pos:Oa(V.pos,[L*.34,L*.3,L*1.05]),look:V.pos,...Y?{orbit:!0}:{}}}let ee=g.get(I);if(ee){let L=Math.max(ee.width,ee.height)*1.5+6;return{pos:Oa(ee.pos,[L*.2,L*.5,L*1.1]),look:Oa(ee.pos,[0,ee.height/2,0])}}return null},N=t.pace??"normal",{gap:B,chapter:U}=tz[N],C=[],q=[],de=[],A=1;t.steps.forEach((I,Y)=>{let V=I.chapter?U:0,ee=A+V,L=I.holdMs??e.sayDurationsMs?.[Y]??Math.max(I.say?nz(I.say):0,1600);I.chapter&&de.push({t:A,type:"marker",label:I.chapter});let T={t:Math.round(ee)};if(I.card==="intro")T.camera=f();else if(I.card==="outro")T.camera=$();else{let R=oz(I.show).filter(x);R.length&&(T.show=R),I.overview&&(T.camera=$());let O=I.focus??(R.length===1?R[0]:void 0);if(O&&!I.overview){T.focus=O;let K=E(O,I.orbit);K&&(T.camera=K)}}if(I.showcase&&o.has(I.showcase)){T.focus=I.showcase,T.showcase=!0;let R=E(I.showcase);R&&(T.camera=R);let O=o.get(I.showcase);O&&(O.pedestal=!0)}let y=(I.highlight??[]).filter(x);y.length&&(T.highlight=y);let v=(I.filter??[]).filter(x);v.length&&(T.filter=v),I.callout&&x(I.callout.target)&&(T.callout=I.callout),I.set&&g.has(I.set.target)&&(T.set=I.set),C.push(T),I.say&&q.push({t:ee,dur:L,text:I.say,words:sz(I.say,ee,L)}),A=ee+L+B});let b={objects:r,beats:C,...n.length?{connections:n}:{},...s?{starfield:!0}:{},...t.background?{background:t.background}:{},...t.floor?{floor:t.floor}:{},style:"infographic",...p.length?{charts:p}:{},pace:N},D=[{t:0,vfs:{},activeFile:null,terminalState:""}];return{manifest:{version:2,title:t.title,createdAt:e.createdAt??new Date().toISOString(),durationMs:Math.max(A,1500),mode:"3d"},events:de,snapshots:D,captions:q.length?q:void 0,scene3d:b}}var pw='Render a 3D walkthrough: a narrated, animated INFOGRAPHIC MOTION TOUR through a staged 3D model \u2014 primitive objects arranged in space, revealed and focused beat by beat with a spline camera glide, staggered reveals, kinetic narration, depth-of-field + grain, and animated `charts`/`callouts`. Produces ONE self-contained interactive HTML (scrubbable, with voice) in the same FlowCast player shell as code and whiteboard walkthroughs. Use this when SPATIAL/3D structure helps \u2014 comparing sizes, arrangement, layers, a showcase of parts, or a data story.\n\nYou list OBJECTS + beats; the server lays out the model and the player auto-frames visible/focused objects, so you never do camera math. There is a single visual style (the infographic motion tour) \u2014 you don\'t pick one.\n\n- `charts`: [{ id, type:"bar"|"line"|"area"|"pie"|"donut"|"ring", data:[{label,value,color?}], unit?, max?, label?, at? }] \u2014 referenced by beats via show/focus like objects. Bars grow+count, line/area draw in order, pie/donut sweep, ring is a % gauge. `pace`: "calm"|"snappy". Beats accept `highlight:[ids]` (spotlight a subset), `filter:[ids]` (fade everything else almost out), `callout:{target,text}` (annotation), and `set:{target,values}` (animate a chart to new values + \u25B2/\u25BC delta badges). Charts auto-layout in a non-overlapping row; honors `prefers-reduced-motion`.\n\n- objects: [{ id, shape | svg | parts | model, label?, color?, size?, scale?, finish?, pedestal?, reveal?, motion?, at? }]. Use 3-8 labeled objects. Omit `at` for auto layout with GENEROUS spacing (\u22485+ between neighbours). Objects sit on/above the floor.\n- GEOMETRY \u2014 PICK IN THIS ORDER:\n 1. `shape` PRIMITIVE \u2014 ONLY if the object genuinely is a basic form (sphere node, cylinder tank, box/stat-bar). box/sphere/cylinder/cone/pyramid/wedge/disc/ring/torus/tube/dome/icosahedron/plane.\n 2. `svg` \u2014 a SIMPLE SOLID ICON (single filled path/polygon): pin, leaf, heart, arrow, gear, key, star, simple logo. We extrude it; the `fill` is the color. Keep it ONE clean shape \u2014 not complex artwork.\n 3. `image` \u2014 an IMAGE URL for anything COMPLEX or detailed (a flag, photo, detailed logo, map, diagram). We fetch + optimize (webp) + embed it and render a textured panel with exact colors. Use this for flags/logos/photos instead of svg/parts.\n 4. `parts` (composed primitives) \u2014 fallback only, for blocky technical assemblies. 5\u20139 parts, varied colors.\n 5. `model` \u2014 a real glTF/GLB URL or local path (true 3D mesh).\n `finish`: matte/glossy/metal/gradient/matcap/glass/iridescent. `pedestal:true` seats it on a platform.\n- STAT BARS: `shape:"box"`, `scale:[1, value, 1]`, `reveal:"grow"`, plus `value` + `valueSuffix` (e.g. value:155, valueSuffix:"M") to show a number that COUNTS UP in a chip beside the bar. `reveal` also: "pop", "fade", "drop" (bounce), "rise"; `motion`: none/spin/bob/orbit.\n- The scene is a clean 3D STAGE: a solid `background` color + a grid floor + soft shadows (no starfield/space). Prefer a deep near-black background; set `floor` for the ground tone.\n- steps: each beat has a short `say` plus an action:\n - `show`: object id(s) to reveal now (they scale in)\n - `focus`: object id to move the camera to and frame\n - `overview`: frame the whole staged scene\n - `orbit`: slowly circle the focused object (turntable)\n - `showcase`: object id to HERO-showcase \u2014 frames it on a plinth and slowly rotates it (Apple-style product reveal)\n The viewer can also PAUSE to free-orbit the scene, hover objects for a tooltip, and click an object to jump to its beat. Imported glTF models play their built-in animations.\n- Teach it like a STORY: open with an overview of the model, focus ONE object per beat while explaining, orbit only a key object, recap with another overview. MANY short beats reading as one script.\n- Avoid huge size differences and avoid more than 8 objects unless the spatial grouping is essential; clutter makes the camera less useful.\n- VOICE: pick `voiceName` + `voiceTone` to fit the topic.\n- INTRO & OUTRO auto-added (opening overview + wrap-up) \u2014 don\'t author your own.\n\nWorked shape:\n objects:\n - { id:"core", shape:"icosahedron", label:"Core", color:"#7cc6ff" }\n - { id:"cache", shape:"box", label:"Cache", color:"#9be08b" }\n - { id:"db", shape:"cylinder", label:"Database", color:"#ffd166" }\n steps:\n - { chapter:"The system", say:"At the center is the core.", show:"core", focus:"core" }\n - { say:"It keeps a cache nearby.", show:"cache", focus:"cache" }\n - { say:"And persists to a database.", show:"db", focus:"db" }\n - { say:"Here\'s how it all sits together.", overview:true }\n\nDelivery is identical to the other tools: the PRIMARY result is a http://127.0.0.1:<port>/<id>.html URL (a resource_link) \u2014 give that link to the user.';var cz={id:"3d",tool:{name:"create_3d_walkthrough",aliases:["create_three_d_walkthrough"],title:"Create a narrated 3D tour",description:pw},promptLine:"\u2022 3D \u2014 a narrated tour through a 3D scene (spatial structure, a showcase of parts) \u2192 create_3d_walkthrough",schema:Vm,mode:"3d",makeBeat:(t,e)=>({say:t,card:e}),forceOutro:!0,async prepare(t){let e=await dw(t.objects??[]),r={};return await Promise.all((t.objects??[]).map(async n=>{if(!n.image||!/^https?:\/\//i.test(n.image))return;let s=await Lm(n.image);s&&(r[n.id]={href:s.href,w:s.w,h:s.h})})),{...Object.keys(e).length?{models:e}:{},...Object.keys(r).length?{images:r}:{}}},compile:(t,e)=>hw(t,e)},mw=cz;var Kl=[rv,ew,iw,mw];var lz=t=>`Welcome! In this walkthrough, we'll look at ${t}. Let's dive in.`,gw=t=>`And that's ${t}. Thanks for watching \u2014 see you in the next one.`;function _w(t,e,r,n,s,o=!1){let i=r===void 0?lz(e):r,a=n===void 0?gw(e):n;o&&!a.trim()&&(a=gw(e));let c=[...t];return a.trim()&&c.push(s(a,"outro")),i.trim()&&c.unshift(s(i,"intro")),c}import{gzipSync as uz}from"node:zlib";import{readFileSync as dz,existsSync as fz}from"node:fs";import{fileURLToPath as hz}from"node:url";import*as ai from"node:path";function bw(t,e,r,n){return`<!doctype html>
|
|
159
|
+
<html lang="en">
|
|
160
|
+
<head>
|
|
161
|
+
<meta charset="utf-8" />
|
|
162
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
163
|
+
<meta name="color-scheme" content="dark" />
|
|
164
|
+
<title>${(o=>o.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"))(t)} \u2014 FlowCast</title>
|
|
165
|
+
<style>html,body{height:100%;margin:0;background:#0a0a0c}</style>
|
|
166
|
+
</head>
|
|
167
|
+
<body>
|
|
168
|
+
<div id="app"></div>
|
|
169
|
+
<script type="text/plain" id="blazy-data-gz">${e}</script>
|
|
170
|
+
<script type="text/plain" id="blazy-audio">${r}</script>
|
|
171
|
+
<script type="text/plain" id="blazy-player-gz">${n}</script>
|
|
172
|
+
<script>
|
|
173
|
+
(async function(){
|
|
174
|
+
var app=document.getElementById('app');
|
|
175
|
+
if(typeof DecompressionStream==='undefined'){app.textContent='This player needs a modern browser (2023+).';return;}
|
|
176
|
+
function unb64(s){return Uint8Array.from(atob(s),function(c){return c.charCodeAt(0);});}
|
|
177
|
+
async function inflate(b64){
|
|
178
|
+
var ds=new DecompressionStream('gzip');
|
|
179
|
+
return await new Response(new Blob([unb64(b64)]).stream().pipeThrough(ds)).text();
|
|
180
|
+
}
|
|
181
|
+
try{
|
|
182
|
+
var js=await inflate(document.getElementById('blazy-player-gz').textContent.trim());
|
|
183
|
+
new Function(js)(); // defines window.BlazyPlayer
|
|
184
|
+
var data=JSON.parse(await inflate(document.getElementById('blazy-data-gz').textContent.trim()));
|
|
185
|
+
var audio=document.getElementById('blazy-audio').textContent.trim();
|
|
186
|
+
data.audio=audio||null;
|
|
187
|
+
BlazyPlayer.mount(app, data);
|
|
188
|
+
}catch(e){app.textContent='Failed to start player: '+e;}
|
|
189
|
+
})();
|
|
190
|
+
</script>
|
|
191
|
+
</body>
|
|
192
|
+
</html>`}function yw(t){return!!t.preview}function vw(t){return t.events.some(e=>e.type==="term.data"||e.type==="term.resize")}var pz=ai.dirname(hz(import.meta.url));function mz(t){let e=ai.join(t,"player");return fz(e)?e:ai.join(t,"../../../../packages/player/dist")}var ww=mz(pz);function gz(t){let e;if(t.manifest.mode)e=`_player-bundle.${t.manifest.mode}.gz.b64`;else{let r=yw(t),n=vw(t);e=r&&n?"_player-bundle.gz.b64":r?"_player-bundle.noterm.gz.b64":n?"_player-bundle.slim.gz.b64":"_player-bundle.min.gz.b64"}try{return dz(ai.join(ww,e),"utf8").trim()}catch{throw new Error(`Player bundle "${e}" not found in ${ww} (run pnpm build:player).`)}}function xw(t,e=""){let r=uz(Buffer.from(JSON.stringify({...t,audio:null}),"utf8"),{level:9}).toString("base64"),n=gz(t);return bw(t.manifest.title,r,e,n)}var Xw={};function _z(t){return new Int8Array(t)}function Ww(t){return new Int16Array(t)}function Kw(t){return new Int32Array(t)}function Jw(t){return new Float32Array(t)}function bz(t){return new Float64Array(t)}function Qw(t){if(t.length==1)return Jw(t[0]);var e=t[0];t=t.slice(1);for(var r=[],n=0;n<e;n++)r.push(Qw(t));return r}function e3(t){if(t.length==1)return Kw(t[0]);var e=t[0];t=t.slice(1);for(var r=[],n=0;n<e;n++)r.push(e3(t));return r}function t3(t){if(t.length==1)return Ww(t[0]);var e=t[0];t=t.slice(1);for(var r=[],n=0;n<e;n++)r.push(t3(t));return r}function r3(t){if(t.length==1)return new Array(t[0]);var e=t[0];t=t.slice(1);for(var r=[],n=0;n<e;n++)r.push(r3(t));return r}var n3={};n3.fill=function(t,e,r,n){if(arguments.length==2)for(var s=0;s<t.length;s++)t[s]=arguments[1];else for(var s=e;s<r;s++)t[s]=n};var ja={};ja.arraycopy=function(t,e,r,n,s){for(var o=e+s;e<o;)r[n++]=t[e++]};ja.out={};ja.out.println=function(t){console.log(t)};ja.out.printf=function(){console.log.apply(console,arguments)};var nu={};nu.SQRT2=1.4142135623730951;nu.FAST_LOG10=function(t){return Math.log10(t)};nu.FAST_LOG10_X=function(t,e){return Math.log10(t)*e};function Hn(t){this.ordinal=t}Hn.short_block_allowed=new Hn(0);Hn.short_block_coupled=new Hn(1);Hn.short_block_dispensed=new Hn(2);Hn.short_block_forced=new Hn(3);var s3={};s3.MAX_VALUE=34028235e31;function qr(t){this.ordinal=t}qr.vbr_off=new qr(0);qr.vbr_mt=new qr(1);qr.vbr_rh=new qr(2);qr.vbr_abr=new qr(3);qr.vbr_mtrh=new qr(4);qr.vbr_default=qr.vbr_mtrh;var yz=function(t){},Zt={System:ja,VbrMode:qr,Float:s3,ShortBlock:Hn,Util:nu,Arrays:n3,new_array_n:r3,new_byte:_z,new_double:bz,new_float:Jw,new_float_n:Qw,new_int:Kw,new_int_n:e3,new_short:Ww,new_short_n:t3,assert:yz},Um,kw;function vz(){if(kw)return Um;kw=1;var t=Zt,e=t.System,r=t.Util,n=t.Arrays,s=t.new_float,o=hr();function i(){var a=[-.1482523854003001,32.308141959636465,296.40344946382766,883.1344870032432,11113.947376231741,1057.2713659324597,305.7402417275812,30.825928907280012,3.8533188138216365,59.42900443849514,709.5899960123345,5281.91112291017,-5829.66483675846,-817.6293103748613,-76.91656988279972,-4.594269939176596,.9063471690191471,.1960342806591213,-.15466694054279598,34.324387823855965,301.8067566458425,817.599602898885,11573.795901679885,1181.2520595540152,321.59731579894424,31.232021761053772,3.7107095756221318,53.650946155329365,684.167428119626,5224.56624370173,-6366.391851890084,-908.9766368219582,-89.83068876699639,-5.411397422890401,.8206787908286602,.3901806440322567,-.16070888947830023,36.147034243915876,304.11815768187864,732.7429163887613,11989.60988270091,1300.012278487897,335.28490093152146,31.48816102859945,3.373875931311736,47.232241542899175,652.7371796173471,5132.414255594984,-6909.087078780055,-1001.9990371107289,-103.62185754286375,-6.104916304710272,.7416505462720353,.5805693545089249,-.16636367662261495,37.751650073343995,303.01103387567713,627.9747488785183,12358.763425278165,1412.2779918482834,346.7496836825721,31.598286663170416,3.1598635433980946,40.57878626349686,616.1671130880391,5007.833007176154,-7454.040671756168,-1095.7960341867115,-118.24411666465777,-6.818469345853504,.6681786379192989,.7653668647301797,-.1716176790982088,39.11551877123304,298.3413246578966,503.5259106886539,12679.589408408976,1516.5821921214542,355.9850766329023,31.395241710249053,2.9164211881972335,33.79716964664243,574.8943997801362,4853.234992253242,-7997.57021486075,-1189.7624067269965,-133.6444792601766,-7.7202770609839915,.5993769336819237,.9427934736519954,-.17645823955292173,40.21879108166477,289.9982036694474,359.3226160751053,12950.259102786438,1612.1013903507662,362.85067106591504,31.045922092242872,2.822222032597987,26.988862316190684,529.8996541764288,4671.371946949588,-8535.899136645805,-1282.5898586244496,-149.58553632943463,-8.643494270763135,.5345111359507916,1.111140466039205,-.36174739330527045,41.04429910497807,277.5463268268618,195.6386023135583,13169.43812144731,1697.6433561479398,367.40983966190305,30.557037410382826,2.531473372857427,20.070154905927314,481.50208566532336,4464.970341588308,-9065.36882077239,-1373.62841526722,-166.1660487028118,-9.58289321133207,.4729647758913199,1.268786568327291,-.36970682634889585,41.393213350082036,261.2935935556502,12.935476055240873,13336.131683328815,1772.508612059496,369.76534388639965,29.751323653701338,2.4023193045459172,13.304795348228817,430.5615775526625,4237.0568611071185,-9581.931701634761,-1461.6913552409758,-183.12733958476446,-10.718010163869403,.41421356237309503,1.414213562373095,-.37677560326535325,41.619486213528496,241.05423794991074,-187.94665032361226,13450.063605744153,1836.153896465782,369.4908799925761,29.001847876923147,2.0714759319987186,6.779591200894186,377.7767837205709,3990.386575512536,-10081.709459700915,-1545.947424837898,-200.3762958015653,-11.864482073055006,.3578057213145241,1.546020906725474,-.3829366947518991,41.1516456456653,216.47684307105183,-406.1569483347166,13511.136535077321,1887.8076599260432,367.3025214564151,28.136213436723654,1.913880671464418,.3829366947518991,323.85365704338597,3728.1472257487526,-10561.233882199509,-1625.2025997821418,-217.62525175416,-13.015432208941645,.3033466836073424,1.66293922460509,-.5822628872992417,40.35639251440489,188.20071124269245,-640.2706748618148,13519.21490106562,1927.6022433578062,362.8197642637487,26.968821921868447,1.7463817695935329,-5.62650678237171,269.3016715297017,3453.386536448852,-11016.145278780888,-1698.6569643425091,-234.7658734267683,-14.16351421663124,.2504869601913055,1.76384252869671,-.5887180101749253,39.23429103868072,155.76096234403798,-889.2492977967378,13475.470561874661,1955.0535223723712,356.4450994756727,25.894952980042156,1.5695032905781554,-11.181939564328772,214.80884394039484,3169.1640829158237,-11443.321309975563,-1765.1588461316153,-251.68908574481912,-15.49755935939164,.198912367379658,1.847759065022573,-.7912582233652842,37.39369355329111,119.699486012458,-1151.0956593239027,13380.446257078214,1970.3952110853447,348.01959814116185,24.731487364283044,1.3850130831637748,-16.421408865300393,161.05030052864092,2878.3322807850063,-11838.991423510031,-1823.985884688674,-268.2854986386903,-16.81724543849939,.1483359875383474,1.913880671464418,-.7960642926861912,35.2322109610459,80.01928065061526,-1424.0212633405113,13235.794061869668,1973.804052543835,337.9908651258184,23.289159354463873,1.3934255946442087,-21.099669467133474,108.48348407242611,2583.700758091299,-12199.726194855148,-1874.2780658979746,-284.2467154529415,-18.11369784385905,.09849140335716425,1.961570560806461,-.998795456205172,32.56307803611191,36.958364584370486,-1706.075448829146,13043.287458812016,1965.3831106103316,326.43182772364605,22.175018750622293,1.198638339011324,-25.371248002043963,57.53505923036915,2288.41886619975,-12522.674544337233,-1914.8400385312243,-299.26241273417224,-19.37805630698734,.04912684976946725,1.990369453344394,.035780907*r.SQRT2*.5/2384e-9,.017876148*r.SQRT2*.5/2384e-9,.003134727*r.SQRT2*.5/2384e-9,.002457142*r.SQRT2*.5/2384e-9,971317e-9*r.SQRT2*.5/2384e-9,218868e-9*r.SQRT2*.5/2384e-9,101566e-9*r.SQRT2*.5/2384e-9,13828e-9*r.SQRT2*.5/2384e-9,12804.797818791945,1945.5515939597317,313.4244966442953,20.801593959731544,1995.1556208053692,9.000838926174497,-29.20218120805369],c=12,d=36,l=[[2382191739347913e-28,6423305872147834e-28,9400849094049688e-28,1122435026096556e-27,1183840321267481e-27,1122435026096556e-27,940084909404969e-27,6423305872147839e-28,2382191739347918e-28,5456116108943412e-27,4878985199565852e-27,4240448995017367e-27,3559909094758252e-27,2858043359288075e-27,2156177623817898e-27,1475637723558783e-27,8371015190102974e-28,2599706096327376e-28,-5456116108943412e-27,-4878985199565852e-27,-4240448995017367e-27,-3559909094758252e-27,-2858043359288076e-27,-2156177623817898e-27,-1475637723558783e-27,-8371015190102975e-28,-2599706096327376e-28,-2382191739347923e-28,-6423305872147843e-28,-9400849094049696e-28,-1122435026096556e-27,-1183840321267481e-27,-1122435026096556e-27,-9400849094049694e-28,-642330587214784e-27,-2382191739347918e-28],[2382191739347913e-28,6423305872147834e-28,9400849094049688e-28,1122435026096556e-27,1183840321267481e-27,1122435026096556e-27,9400849094049688e-28,6423305872147841e-28,2382191739347918e-28,5456116108943413e-27,4878985199565852e-27,4240448995017367e-27,3559909094758253e-27,2858043359288075e-27,2156177623817898e-27,1475637723558782e-27,8371015190102975e-28,2599706096327376e-28,-5461314069809755e-27,-4921085770524055e-27,-4343405037091838e-27,-3732668368707687e-27,-3093523840190885e-27,-2430835727329465e-27,-1734679010007751e-27,-974825365660928e-27,-2797435120168326e-28,0,0,0,0,0,0,-2283748241799531e-28,-4037858874020686e-28,-2146547464825323e-28],[.1316524975873958,.414213562373095,.7673269879789602,1.091308501069271,1.303225372841206,1.56968557711749,1.920982126971166,2.414213562373094,3.171594802363212,4.510708503662055,7.595754112725146,22.90376554843115,.984807753012208,.6427876096865394,.3420201433256688,.9396926207859084,-.1736481776669303,-.7660444431189779,.8660254037844387,.5,-.5144957554275265,-.4717319685649723,-.3133774542039019,-.1819131996109812,-.09457419252642064,-.04096558288530405,-.01419856857247115,-.003699974673760037,.8574929257125442,.8817419973177052,.9496286491027329,.9833145924917901,.9955178160675857,.9991605581781475,.999899195244447,.9999931550702802],[0,0,0,0,0,0,2283748241799531e-28,4037858874020686e-28,2146547464825323e-28,5461314069809755e-27,4921085770524055e-27,4343405037091838e-27,3732668368707687e-27,3093523840190885e-27,2430835727329466e-27,1734679010007751e-27,974825365660928e-27,2797435120168326e-28,-5456116108943413e-27,-4878985199565852e-27,-4240448995017367e-27,-3559909094758253e-27,-2858043359288075e-27,-2156177623817898e-27,-1475637723558782e-27,-8371015190102975e-28,-2599706096327376e-28,-2382191739347913e-28,-6423305872147834e-28,-9400849094049688e-28,-1122435026096556e-27,-1183840321267481e-27,-1122435026096556e-27,-9400849094049688e-28,-6423305872147841e-28,-2382191739347918e-28]],u=l[o.SHORT_TYPE],h=l[o.SHORT_TYPE],p=l[o.SHORT_TYPE],g=l[o.SHORT_TYPE],x=[0,1,16,17,8,9,24,25,4,5,20,21,12,13,28,29,2,3,18,19,10,11,26,27,6,7,22,23,14,15,30,31];function S(m,$,f){for(var E=10,N=$+238-14-286,B=-15;B<0;B++){var U,C,q;U=a[E+-10],C=m[N+-224]*U,q=m[$+224]*U,U=a[E+-9],C+=m[N+-160]*U,q+=m[$+160]*U,U=a[E+-8],C+=m[N+-96]*U,q+=m[$+96]*U,U=a[E+-7],C+=m[N+-32]*U,q+=m[$+32]*U,U=a[E+-6],C+=m[N+32]*U,q+=m[$+-32]*U,U=a[E+-5],C+=m[N+96]*U,q+=m[$+-96]*U,U=a[E+-4],C+=m[N+160]*U,q+=m[$+-160]*U,U=a[E+-3],C+=m[N+224]*U,q+=m[$+-224]*U,U=a[E+-2],C+=m[$+-256]*U,q-=m[N+256]*U,U=a[E+-1],C+=m[$+-192]*U,q-=m[N+192]*U,U=a[E+0],C+=m[$+-128]*U,q-=m[N+128]*U,U=a[E+1],C+=m[$+-64]*U,q-=m[N+64]*U,U=a[E+2],C+=m[$+0]*U,q-=m[N+0]*U,U=a[E+3],C+=m[$+64]*U,q-=m[N+-64]*U,U=a[E+4],C+=m[$+128]*U,q-=m[N+-128]*U,U=a[E+5],C+=m[$+192]*U,q-=m[N+-192]*U,C*=a[E+6],U=q-C,f[30+B*2]=q+C,f[31+B*2]=a[E+7]*U,E+=18,$--,N++}{var C,q,de,A;q=m[$+-16]*a[E+-10],C=m[$+-32]*a[E+-2],q+=(m[$+-48]-m[$+16])*a[E+-9],C+=m[$+-96]*a[E+-1],q+=(m[$+-80]+m[$+48])*a[E+-8],C+=m[$+-160]*a[E+0],q+=(m[$+-112]-m[$+80])*a[E+-7],C+=m[$+-224]*a[E+1],q+=(m[$+-144]+m[$+112])*a[E+-6],C-=m[$+32]*a[E+2],q+=(m[$+-176]-m[$+144])*a[E+-5],C-=m[$+96]*a[E+3],q+=(m[$+-208]+m[$+176])*a[E+-4],C-=m[$+160]*a[E+4],q+=(m[$+-240]-m[$+208])*a[E+-3],C-=m[$+224],de=C-q,A=C+q,q=f[14],C=f[15]-q,f[31]=A+q,f[30]=de+C,f[15]=de-C,f[14]=A-q}{var b;b=f[28]-f[0],f[0]+=f[28],f[28]=b*a[E+-2*18+7],b=f[29]-f[1],f[1]+=f[29],f[29]=b*a[E+-2*18+7],b=f[26]-f[2],f[2]+=f[26],f[26]=b*a[E+-4*18+7],b=f[27]-f[3],f[3]+=f[27],f[27]=b*a[E+-4*18+7],b=f[24]-f[4],f[4]+=f[24],f[24]=b*a[E+-6*18+7],b=f[25]-f[5],f[5]+=f[25],f[25]=b*a[E+-6*18+7],b=f[22]-f[6],f[6]+=f[22],f[22]=b*r.SQRT2,b=f[23]-f[7],f[7]+=f[23],f[23]=b*r.SQRT2-f[7],f[7]-=f[6],f[22]-=f[7],f[23]-=f[22],b=f[6],f[6]=f[31]-b,f[31]=f[31]+b,b=f[7],f[7]=f[30]-b,f[30]=f[30]+b,b=f[22],f[22]=f[15]-b,f[15]=f[15]+b,b=f[23],f[23]=f[14]-b,f[14]=f[14]+b,b=f[20]-f[8],f[8]+=f[20],f[20]=b*a[E+-10*18+7],b=f[21]-f[9],f[9]+=f[21],f[21]=b*a[E+-10*18+7],b=f[18]-f[10],f[10]+=f[18],f[18]=b*a[E+-12*18+7],b=f[19]-f[11],f[11]+=f[19],f[19]=b*a[E+-12*18+7],b=f[16]-f[12],f[12]+=f[16],f[16]=b*a[E+-14*18+7],b=f[17]-f[13],f[13]+=f[17],f[17]=b*a[E+-14*18+7],b=-f[20]+f[24],f[20]+=f[24],f[24]=b*a[E+-12*18+7],b=-f[21]+f[25],f[21]+=f[25],f[25]=b*a[E+-12*18+7],b=f[4]-f[8],f[4]+=f[8],f[8]=b*a[E+-12*18+7],b=f[5]-f[9],f[5]+=f[9],f[9]=b*a[E+-12*18+7],b=f[0]-f[12],f[0]+=f[12],f[12]=b*a[E+-4*18+7],b=f[1]-f[13],f[1]+=f[13],f[13]=b*a[E+-4*18+7],b=f[16]-f[28],f[16]+=f[28],f[28]=b*a[E+-4*18+7],b=-f[17]+f[29],f[17]+=f[29],f[29]=b*a[E+-4*18+7],b=r.SQRT2*(f[2]-f[10]),f[2]+=f[10],f[10]=b,b=r.SQRT2*(f[3]-f[11]),f[3]+=f[11],f[11]=b,b=r.SQRT2*(-f[18]+f[26]),f[18]+=f[26],f[26]=b-f[18],b=r.SQRT2*(-f[19]+f[27]),f[19]+=f[27],f[27]=b-f[19],b=f[2],f[19]-=f[3],f[3]-=b,f[2]=f[31]-b,f[31]+=b,b=f[3],f[11]-=f[19],f[18]-=b,f[3]=f[30]-b,f[30]+=b,b=f[18],f[27]-=f[11],f[19]-=b,f[18]=f[15]-b,f[15]+=b,b=f[19],f[10]-=b,f[19]=f[14]-b,f[14]+=b,b=f[10],f[11]-=b,f[10]=f[23]-b,f[23]+=b,b=f[11],f[26]-=b,f[11]=f[22]-b,f[22]+=b,b=f[26],f[27]-=b,f[26]=f[7]-b,f[7]+=b,b=f[27],f[27]=f[6]-b,f[6]+=b,b=r.SQRT2*(f[0]-f[4]),f[0]+=f[4],f[4]=b,b=r.SQRT2*(f[1]-f[5]),f[1]+=f[5],f[5]=b,b=r.SQRT2*(f[16]-f[20]),f[16]+=f[20],f[20]=b,b=r.SQRT2*(f[17]-f[21]),f[17]+=f[21],f[21]=b,b=-r.SQRT2*(f[8]-f[12]),f[8]+=f[12],f[12]=b-f[8],b=-r.SQRT2*(f[9]-f[13]),f[9]+=f[13],f[13]=b-f[9],b=-r.SQRT2*(f[25]-f[29]),f[25]+=f[29],f[29]=b-f[25],b=-r.SQRT2*(f[24]+f[28]),f[24]-=f[28],f[28]=b-f[24],b=f[24]-f[16],f[24]=b,b=f[20]-b,f[20]=b,b=f[28]-b,f[28]=b,b=f[25]-f[17],f[25]=b,b=f[21]-b,f[21]=b,b=f[29]-b,f[29]=b,b=f[17]-f[1],f[17]=b,b=f[9]-b,f[9]=b,b=f[25]-b,f[25]=b,b=f[5]-b,f[5]=b,b=f[21]-b,f[21]=b,b=f[13]-b,f[13]=b,b=f[29]-b,f[29]=b,b=f[1]-f[0],f[1]=b,b=f[16]-b,f[16]=b,b=f[17]-b,f[17]=b,b=f[8]-b,f[8]=b,b=f[9]-b,f[9]=b,b=f[24]-b,f[24]=b,b=f[25]-b,f[25]=b,b=f[4]-b,f[4]=b,b=f[5]-b,f[5]=b,b=f[20]-b,f[20]=b,b=f[21]-b,f[21]=b,b=f[12]-b,f[12]=b,b=f[13]-b,f[13]=b,b=f[28]-b,f[28]=b,b=f[29]-b,f[29]=b,b=f[0],f[0]+=f[31],f[31]-=b,b=f[1],f[1]+=f[30],f[30]-=b,b=f[16],f[16]+=f[15],f[15]-=b,b=f[17],f[17]+=f[14],f[14]-=b,b=f[8],f[8]+=f[23],f[23]-=b,b=f[9],f[9]+=f[22],f[22]-=b,b=f[24],f[24]+=f[7],f[7]-=b,b=f[25],f[25]+=f[6],f[6]-=b,b=f[4],f[4]+=f[27],f[27]-=b,b=f[5],f[5]+=f[26],f[26]-=b,b=f[20],f[20]+=f[11],f[11]-=b,b=f[21],f[21]+=f[10],f[10]-=b,b=f[12],f[12]+=f[19],f[19]-=b,b=f[13],f[13]+=f[18],f[18]-=b,b=f[28],f[28]+=f[3],f[3]-=b,b=f[29],f[29]+=f[2],f[2]-=b}}function k(m,$){for(var f=0;f<3;f++){var E,N,B,U,C,q;U=m[$+2*3]*l[o.SHORT_TYPE][0]-m[$+5*3],E=m[$+0*3]*l[o.SHORT_TYPE][2]-m[$+3*3],N=U+E,B=U-E,U=m[$+5*3]*l[o.SHORT_TYPE][0]+m[$+2*3],E=m[$+3*3]*l[o.SHORT_TYPE][2]+m[$+0*3],C=U+E,q=-U+E,E=(m[$+1*3]*l[o.SHORT_TYPE][1]-m[$+4*3])*2069978111953089e-26,U=(m[$+4*3]*l[o.SHORT_TYPE][1]+m[$+1*3])*2069978111953089e-26,m[$+3*0]=N*190752519173728e-25+E,m[$+3*5]=-C*190752519173728e-25+U,B=B*.8660254037844387*1907525191737281e-26,C=C*.5*1907525191737281e-26+U,m[$+3*1]=B-C,m[$+3*2]=B+C,N=N*.5*1907525191737281e-26-E,q=q*.8660254037844387*1907525191737281e-26,m[$+3*3]=N+q,m[$+3*4]=N-q,$++}}function _(m,$,f){var E,N;{var B,U,C,q,de,A,b,D;B=f[17]-f[9],C=f[15]-f[11],q=f[14]-f[12],de=f[0]+f[8],A=f[1]+f[7],b=f[2]+f[6],D=f[3]+f[5],m[$+17]=de+b-D-(A-f[4]),N=(de+b-D)*h[19]+(A-f[4]),E=(B-C-q)*h[18],m[$+5]=E+N,m[$+6]=E-N,U=(f[16]-f[10])*h[18],A=A*h[19]+f[4],E=B*h[12]+U+C*h[13]+q*h[14],N=-de*h[16]+A-b*h[17]+D*h[15],m[$+1]=E+N,m[$+2]=E-N,E=B*h[13]-U-C*h[14]+q*h[12],N=-de*h[17]+A-b*h[15]+D*h[16],m[$+9]=E+N,m[$+10]=E-N,E=B*h[14]-U+C*h[12]-q*h[13],N=de*h[15]-A+b*h[16]-D*h[17],m[$+13]=E+N,m[$+14]=E-N}{var I,Y,V,ee,L,T,y,v;I=f[8]-f[0],V=f[6]-f[2],ee=f[5]-f[3],L=f[17]+f[9],T=f[16]+f[10],y=f[15]+f[11],v=f[14]+f[12],m[$+0]=L+y+v+(T+f[13]),E=(L+y+v)*h[19]-(T+f[13]),N=(I-V+ee)*h[18],m[$+11]=E+N,m[$+12]=E-N,Y=(f[7]-f[1])*h[18],T=f[13]-T*h[19],E=L*h[15]-T+y*h[16]+v*h[17],N=I*h[14]+Y+V*h[12]+ee*h[13],m[$+3]=E+N,m[$+4]=E-N,E=-L*h[17]+T-y*h[15]-v*h[16],N=I*h[13]+Y-V*h[14]-ee*h[12],m[$+7]=E+N,m[$+8]=E-N,E=-L*h[16]+T-y*h[17]-v*h[15],N=I*h[12]-Y+V*h[13]-ee*h[14],m[$+15]=E+N,m[$+16]=E-N}}this.mdct_sub48=function(m,$,f){for(var E=$,N=286,B=0;B<m.channels_out;B++){for(var U=0;U<m.mode_gr;U++){for(var C,q=m.l3_side.tt[U][B],de=q.xr,A=0,b=m.sb_sample[B][1-U],D=0,I=0;I<18/2;I++)for(S(E,N,b[D]),S(E,N+32,b[D+1]),D+=2,N+=64,C=1;C<32;C+=2)b[D-1][C]*=-1;for(C=0;C<32;C++,A+=18){var Y=q.block_type,V=m.sb_sample[B][U],ee=m.sb_sample[B][1-U];if(q.mixed_block_flag!=0&&C<2&&(Y=0),m.amp_filter[C]<1e-12)n.fill(de,A+0,A+18,0);else{if(m.amp_filter[C]<1)for(var I=0;I<18;I++)ee[I][x[C]]*=m.amp_filter[C];if(Y==o.SHORT_TYPE){for(var I=-c/4;I<0;I++){var L=l[o.SHORT_TYPE][I+3];de[A+I*3+9]=V[9+I][x[C]]*L-V[8-I][x[C]],de[A+I*3+18]=V[14-I][x[C]]*L+V[15+I][x[C]],de[A+I*3+10]=V[15+I][x[C]]*L-V[14-I][x[C]],de[A+I*3+19]=ee[2-I][x[C]]*L+ee[3+I][x[C]],de[A+I*3+11]=ee[3+I][x[C]]*L-ee[2-I][x[C]],de[A+I*3+20]=ee[8-I][x[C]]*L+ee[9+I][x[C]]}k(de,A)}else{for(var T=s(18),I=-d/4;I<0;I++){var y,v;y=l[Y][I+27]*ee[I+9][x[C]]+l[Y][I+36]*ee[8-I][x[C]],v=l[Y][I+9]*V[I+9][x[C]]-l[Y][I+18]*V[8-I][x[C]],T[I+9]=y-v*u[3+I+9],T[I+18]=y*u[3+I+9]+v}_(de,A,T)}}if(Y!=o.SHORT_TYPE&&C!=0)for(var I=7;I>=0;--I){var R,O;R=de[A+I]*p[20+I]+de[A+-1-I]*g[28+I],O=de[A+I]*g[28+I]-de[A+-1-I]*p[20+I],de[A+-1-I]=R,de[A+I]=O}}}if(E=f,N=286,m.mode_gr==1)for(var K=0;K<18;K++)e.arraycopy(m.sb_sample[B][1][K],0,m.sb_sample[B][0][K],0,32)}}}return Um=i,Um}var Gm,Sw;function o3(){if(Sw)return Gm;Sw=1;var t=hr(),e=Zt,r=e.System,n=e.new_float,s=e.new_float_n;function o(){this.l=n(t.SBMAX_l),this.s=s([t.SBMAX_s,3]);var i=this;this.assign=function(a){r.arraycopy(a.l,0,i.l,0,t.SBMAX_l);for(var c=0;c<t.SBMAX_s;c++)for(var d=0;d<3;d++)i.s[c][d]=a.s[c][d]}}return Gm=o,Gm}var Ym,Ew;function wz(){if(Ew)return Ym;Ew=1;var t=o3();function e(){this.thm=new t,this.en=new t}return Ym=e,Ym}function xn(t){var e=t;this.ordinal=function(){return e}}xn.STEREO=new xn(0);xn.JOINT_STEREO=new xn(1);xn.DUAL_CHANNEL=new xn(2);xn.MONO=new xn(3);xn.NOT_SET=new xn(4);var Da=xn,Xm,Tw;function hr(){if(Tw)return Xm;Tw=1;var t=Zt,e=t.System,r=t.VbrMode,n=t.new_array_n,s=t.new_float,o=t.new_float_n,i=t.new_int,a=t.assert;c.ENCDELAY=576,c.POSTDELAY=1152,c.MDCTDELAY=48,c.FFTOFFSET=224+c.MDCTDELAY,c.DECDELAY=528,c.SBLIMIT=32,c.CBANDS=64,c.SBPSY_l=21,c.SBPSY_s=12,c.SBMAX_l=22,c.SBMAX_s=13,c.PSFB21=6,c.PSFB12=6,c.BLKSIZE=1024,c.HBLKSIZE=c.BLKSIZE/2+1,c.BLKSIZE_s=256,c.HBLKSIZE_s=c.BLKSIZE_s/2+1,c.NORM_TYPE=0,c.START_TYPE=1,c.SHORT_TYPE=2,c.STOP_TYPE=3,c.MPG_MD_LR_LR=0,c.MPG_MD_LR_I=1,c.MPG_MD_MS_LR=2,c.MPG_MD_MS_I=3,c.fircoef=[-.0207887*5,-.0378413*5,-.0432472*5,-.031183*5,779609e-23*5,.0467745*5,.10091*5,.151365*5,.187098*5];function c(){var d=vz(),l=wz(),u=Da,h=c.FFTOFFSET,p=c.MPG_MD_MS_LR,g=null;this.psy=null;var x=null,S=null,k=null;this.setModules=function(E,N,B,U){g=E,this.psy=N,x=N,S=U,k=B};var _=new d;function m(E){var N,B;if(E.ATH.useAdjust==0){E.ATH.adjust=1;return}if(B=E.loudness_sq[0][0],N=E.loudness_sq[1][0],E.channels_out==2?(B+=E.loudness_sq[0][1],N+=E.loudness_sq[1][1]):(B+=B,N+=N),E.mode_gr==2&&(B=Math.max(B,N)),B*=.5,B*=E.ATH.aaSensitivityP,B>.03125)E.ATH.adjust>=1?E.ATH.adjust=1:E.ATH.adjust<E.ATH.adjustLimit&&(E.ATH.adjust=E.ATH.adjustLimit),E.ATH.adjustLimit=1;else{var U=31.98*B+625e-6;E.ATH.adjust>=U?(E.ATH.adjust*=U*.075+.925,E.ATH.adjust<U&&(E.ATH.adjust=U)):E.ATH.adjustLimit>=U?E.ATH.adjust=U:E.ATH.adjust<E.ATH.adjustLimit&&(E.ATH.adjust=E.ATH.adjustLimit),E.ATH.adjustLimit=U}}function $(E){var N,B;for(a(0<=E.bitrate_index&&E.bitrate_index<16),a(0<=E.mode_ext&&E.mode_ext<4),E.bitrate_stereoMode_Hist[E.bitrate_index][4]++,E.bitrate_stereoMode_Hist[15][4]++,E.channels_out==2&&(E.bitrate_stereoMode_Hist[E.bitrate_index][E.mode_ext]++,E.bitrate_stereoMode_Hist[15][E.mode_ext]++),N=0;N<E.mode_gr;++N)for(B=0;B<E.channels_out;++B){var U=E.l3_side.tt[N][B].block_type|0;E.l3_side.tt[N][B].mixed_block_flag!=0&&(U=4),E.bitrate_blockType_Hist[E.bitrate_index][U]++,E.bitrate_blockType_Hist[E.bitrate_index][5]++,E.bitrate_blockType_Hist[15][U]++,E.bitrate_blockType_Hist[15][5]++}}function f(E,N){var B=E.internal_flags,U,C;if(B.lame_encode_frame_init==0){var q,de,A=s(2014),b=s(2014);for(B.lame_encode_frame_init=1,q=0,de=0;q<286+576*(1+B.mode_gr);++q)q<576*B.mode_gr?(A[q]=0,B.channels_out==2&&(b[q]=0)):(A[q]=N[0][de],B.channels_out==2&&(b[q]=N[1][de]),++de);for(C=0;C<B.mode_gr;C++)for(U=0;U<B.channels_out;U++)B.l3_side.tt[C][U].block_type=c.SHORT_TYPE;_.mdct_sub48(B,A,b),a(576>=c.FFTOFFSET),a(B.mf_size>=c.BLKSIZE+E.framesize-c.FFTOFFSET),a(B.mf_size>=512+E.framesize-32)}}this.lame_encode_mp3_frame=function(E,N,B,U,C,q){var de,A=n([2,2]);A[0][0]=new l,A[0][1]=new l,A[1][0]=new l,A[1][1]=new l;var b=n([2,2]);b[0][0]=new l,b[0][1]=new l,b[1][0]=new l,b[1][1]=new l;var D,I=[null,null],Y=E.internal_flags,V=o([2,4]),ee=[.5,.5],L=[[0,0],[0,0]],T=[[0,0],[0,0]],y,v,R;if(I[0]=N,I[1]=B,Y.lame_encode_frame_init==0&&f(E,I),Y.padding=0,(Y.slot_lag-=Y.frac_SpF)<0&&(Y.slot_lag+=E.out_samplerate,Y.padding=1),Y.psymodel!=0){var O,K=[null,null],se=0,F=i(2);for(R=0;R<Y.mode_gr;R++){for(v=0;v<Y.channels_out;v++)K[v]=I[v],se=576+R*576-c.FFTOFFSET;if(E.VBR==r.vbr_mtrh||E.VBR==r.vbr_mt?O=x.L3psycho_anal_vbr(E,K,se,R,A,b,L[R],T[R],V[R],F):O=x.L3psycho_anal_ns(E,K,se,R,A,b,L[R],T[R],V[R],F),O!=0)return-4;for(E.mode==u.JOINT_STEREO&&(ee[R]=V[R][2]+V[R][3],ee[R]>0&&(ee[R]=V[R][3]/ee[R])),v=0;v<Y.channels_out;v++){var Q=Y.l3_side.tt[R][v];Q.block_type=F[v],Q.mixed_block_flag=0}}}else for(R=0;R<Y.mode_gr;R++)for(v=0;v<Y.channels_out;v++)Y.l3_side.tt[R][v].block_type=c.NORM_TYPE,Y.l3_side.tt[R][v].mixed_block_flag=0,T[R][v]=L[R][v]=700;if(m(Y),_.mdct_sub48(Y,I[0],I[1]),Y.mode_ext=c.MPG_MD_LR_LR,E.force_ms)Y.mode_ext=c.MPG_MD_MS_LR;else if(E.mode==u.JOINT_STEREO){var ue=0,ge=0;for(R=0;R<Y.mode_gr;R++)for(v=0;v<Y.channels_out;v++)ue+=T[R][v],ge+=L[R][v];if(ue<=1*ge){var ke=Y.l3_side.tt[0],Re=Y.l3_side.tt[Y.mode_gr-1];ke[0].block_type==ke[1].block_type&&Re[0].block_type==Re[1].block_type&&(Y.mode_ext=c.MPG_MD_MS_LR)}}if(Y.mode_ext==p?(D=b,y=T):(D=A,y=L),E.analysis&&Y.pinfo!=null)for(R=0;R<Y.mode_gr;R++)for(v=0;v<Y.channels_out;v++)Y.pinfo.ms_ratio[R]=Y.ms_ratio[R],Y.pinfo.ms_ener_ratio[R]=ee[R],Y.pinfo.blocktype[R][v]=Y.l3_side.tt[R][v].block_type,Y.pinfo.pe[R][v]=y[R][v],e.arraycopy(Y.l3_side.tt[R][v].xr,0,Y.pinfo.xr[R][v],0,576),Y.mode_ext==p&&(Y.pinfo.ers[R][v]=Y.pinfo.ers[R][v+2],e.arraycopy(Y.pinfo.energy[R][v+2],0,Y.pinfo.energy[R][v],0,Y.pinfo.energy[R][v].length));if(E.VBR==r.vbr_off||E.VBR==r.vbr_abr){var Te,Se;for(Te=0;Te<18;Te++)Y.nsPsy.pefirbuf[Te]=Y.nsPsy.pefirbuf[Te+1];for(Se=0,R=0;R<Y.mode_gr;R++)for(v=0;v<Y.channels_out;v++)Se+=y[R][v];for(Y.nsPsy.pefirbuf[18]=Se,Se=Y.nsPsy.pefirbuf[9],Te=0;Te<9;Te++)Se+=(Y.nsPsy.pefirbuf[Te]+Y.nsPsy.pefirbuf[18-Te])*c.fircoef[Te];for(Se=670*5*Y.mode_gr*Y.channels_out/Se,R=0;R<Y.mode_gr;R++)for(v=0;v<Y.channels_out;v++)y[R][v]*=Se}if(Y.iteration_loop.iteration_loop(E,y,ee,D),g.format_bitstream(E),de=g.copy_buffer(Y,U,C,q,1),E.bWriteVbrTag&&S.addVbrFrame(E),E.analysis&&Y.pinfo!=null){for(v=0;v<Y.channels_out;v++){var Ce;for(Ce=0;Ce<h;Ce++)Y.pinfo.pcmdata[v][Ce]=Y.pinfo.pcmdata[v][Ce+E.framesize];for(Ce=h;Ce<1600;Ce++)Y.pinfo.pcmdata[v][Ce]=I[v][Ce-h]}k.set_frame_pinfo(E,D)}return $(Y),de}}return Xm=c,Xm}var i3=Zt,$w=i3.Util,Rw=i3.new_float,Ut=hr();function xz(){var t=Rw(Ut.BLKSIZE),e=Rw(Ut.BLKSIZE_s/2),r=[.9238795325112867,.3826834323650898,.9951847266721969,.0980171403295606,.9996988186962042,.02454122852291229,.9999811752826011,.006135884649154475];function n(o,i,a){var c=0,d,l,u;a<<=1;var h=i+a;d=4;do{var p,g,x,S,k,_,m;m=d>>1,S=d,k=d<<1,_=k+S,d=k<<1,l=i,u=l+m;do{var $,f,E,N;f=o[l+0]-o[l+S],$=o[l+0]+o[l+S],N=o[l+k]-o[l+_],E=o[l+k]+o[l+_],o[l+k]=$-E,o[l+0]=$+E,o[l+_]=f-N,o[l+S]=f+N,f=o[u+0]-o[u+S],$=o[u+0]+o[u+S],N=$w.SQRT2*o[u+_],E=$w.SQRT2*o[u+k],o[u+k]=$-E,o[u+0]=$+E,o[u+_]=f-N,o[u+S]=f+N,u+=d,l+=d}while(l<h);for(g=r[c+0],p=r[c+1],x=1;x<m;x++){var B,U;B=1-2*p*p,U=2*p*g,l=i+x,u=i+S-x;do{var C,q,de,$,f,A,E,b,N,D;q=U*o[l+S]-B*o[u+S],C=B*o[l+S]+U*o[u+S],f=o[l+0]-C,$=o[l+0]+C,A=o[u+0]-q,de=o[u+0]+q,q=U*o[l+_]-B*o[u+_],C=B*o[l+_]+U*o[u+_],N=o[l+k]-C,E=o[l+k]+C,D=o[u+k]-q,b=o[u+k]+q,q=p*E-g*D,C=g*E+p*D,o[l+k]=$-C,o[l+0]=$+C,o[u+_]=A-q,o[u+S]=A+q,q=g*b-p*N,C=p*b+g*N,o[u+k]=de-C,o[u+0]=de+C,o[l+_]=f-q,o[l+S]=f+q,u+=d,l+=d}while(l<h);B=g,g=B*r[c+0]-p*r[c+1],p=B*r[c+1]+p*r[c+0]}c+=2}while(d<a)}var s=[0,128,64,192,32,160,96,224,16,144,80,208,48,176,112,240,8,136,72,200,40,168,104,232,24,152,88,216,56,184,120,248,4,132,68,196,36,164,100,228,20,148,84,212,52,180,116,244,12,140,76,204,44,172,108,236,28,156,92,220,60,188,124,252,2,130,66,194,34,162,98,226,18,146,82,210,50,178,114,242,10,138,74,202,42,170,106,234,26,154,90,218,58,186,122,250,6,134,70,198,38,166,102,230,22,150,86,214,54,182,118,246,14,142,78,206,46,174,110,238,30,158,94,222,62,190,126,254];this.fft_short=function(o,i,a,c,d){for(var l=0;l<3;l++){var u=Ut.BLKSIZE_s/2,h=65535&576/3*(l+1),p=Ut.BLKSIZE_s/8-1;do{var g,x,S,k,_,m=s[p<<2]&255;g=e[m]*c[a][d+m+h],_=e[127-m]*c[a][d+m+h+128],x=g-_,g=g+_,S=e[m+64]*c[a][d+m+h+64],_=e[63-m]*c[a][d+m+h+192],k=S-_,S=S+_,u-=4,i[l][u+0]=g+S,i[l][u+2]=g-S,i[l][u+1]=x+k,i[l][u+3]=x-k,g=e[m+1]*c[a][d+m+h+1],_=e[126-m]*c[a][d+m+h+129],x=g-_,g=g+_,S=e[m+65]*c[a][d+m+h+65],_=e[62-m]*c[a][d+m+h+193],k=S-_,S=S+_,i[l][u+Ut.BLKSIZE_s/2+0]=g+S,i[l][u+Ut.BLKSIZE_s/2+2]=g-S,i[l][u+Ut.BLKSIZE_s/2+1]=x+k,i[l][u+Ut.BLKSIZE_s/2+3]=x-k}while(--p>=0);n(i[l],u,Ut.BLKSIZE_s/2)}},this.fft_long=function(o,i,a,c,d){var l=Ut.BLKSIZE/8-1,u=Ut.BLKSIZE/2;do{var h,p,g,x,S,k=s[l]&255;h=t[k]*c[a][d+k],S=t[k+512]*c[a][d+k+512],p=h-S,h=h+S,g=t[k+256]*c[a][d+k+256],S=t[k+768]*c[a][d+k+768],x=g-S,g=g+S,u-=4,i[u+0]=h+g,i[u+2]=h-g,i[u+1]=p+x,i[u+3]=p-x,h=t[k+1]*c[a][d+k+1],S=t[k+513]*c[a][d+k+513],p=h-S,h=h+S,g=t[k+257]*c[a][d+k+257],S=t[k+769]*c[a][d+k+769],x=g-S,g=g+S,i[u+Ut.BLKSIZE/2+0]=h+g,i[u+Ut.BLKSIZE/2+2]=h-g,i[u+Ut.BLKSIZE/2+1]=p+x,i[u+Ut.BLKSIZE/2+3]=p-x}while(--l>=0);n(i,u,Ut.BLKSIZE/2)},this.init_fft=function(o){for(var i=0;i<Ut.BLKSIZE;i++)t[i]=.42-.5*Math.cos(2*Math.PI*(i+.5)/Ut.BLKSIZE)+.08*Math.cos(4*Math.PI*(i+.5)/Ut.BLKSIZE);for(var i=0;i<Ut.BLKSIZE_s/2;i++)e[i]=.5*(1-Math.cos(2*Math.PI*(i+.5)/Ut.BLKSIZE_s))}}var kz=xz,Un=Zt,ci=Un.VbrMode,Pw=Un.Float,li=Un.ShortBlock,Mr=Un.Util,Sz=Un.Arrays,Gt=Un.new_float,nn=Un.new_float_n,lo=Un.new_int,Qe=Un.assert,Ez=kz,ae=hr();function Tz(){var t=Da,e=new Ez,r=2.302585092994046,n=2,s=16,o=2,i=16,a=.34,c=1/(14752*14752)/(ae.BLKSIZE/2),d=.01,l=.8,u=.6,h=.3,p=3.5,g=21,x=.2302585093;function S(M){return M}function k(M,z){for(var Z=0,H=0;H<ae.BLKSIZE/2;++H)Z+=M[H]*z.ATH.eql_w[H];return Z*=c,Z}function _(M,z,Z,H,J,j,X,te,W,oe,re){var ie=M.internal_flags;if(W<2)e.fft_long(ie,H[J],W,oe,re),e.fft_short(ie,j[X],W,oe,re);else if(W==2){for(var ye=ae.BLKSIZE-1;ye>=0;--ye){var Be=H[J+0][ye],fe=H[J+1][ye];H[J+0][ye]=(Be+fe)*Mr.SQRT2*.5,H[J+1][ye]=(Be-fe)*Mr.SQRT2*.5}for(var De=2;De>=0;--De)for(var ye=ae.BLKSIZE_s-1;ye>=0;--ye){var Be=j[X+0][De][ye],fe=j[X+1][De][ye];j[X+0][De][ye]=(Be+fe)*Mr.SQRT2*.5,j[X+1][De][ye]=(Be-fe)*Mr.SQRT2*.5}}z[0]=H[J+0][0],z[0]*=z[0];for(var ye=ae.BLKSIZE/2-1;ye>=0;--ye){var ne=H[J+0][ae.BLKSIZE/2-ye],$e=H[J+0][ae.BLKSIZE/2+ye];z[ae.BLKSIZE/2-ye]=(ne*ne+$e*$e)*.5}for(var De=2;De>=0;--De){Z[De][0]=j[X+0][De][0],Z[De][0]*=Z[De][0];for(var ye=ae.BLKSIZE_s/2-1;ye>=0;--ye){var ne=j[X+0][De][ae.BLKSIZE_s/2-ye],$e=j[X+0][De][ae.BLKSIZE_s/2+ye];Z[De][ae.BLKSIZE_s/2-ye]=(ne*ne+$e*$e)*.5}}{for(var tt=0,ye=11;ye<ae.HBLKSIZE;ye++)tt+=z[ye];ie.tot_ener[W]=tt}if(M.analysis){for(var ye=0;ye<ae.HBLKSIZE;ye++)ie.pinfo.energy[te][W][ye]=ie.pinfo.energy_save[W][ye],ie.pinfo.energy_save[W][ye]=z[ye];ie.pinfo.pe[te][W]=ie.pe[W]}M.athaa_loudapprox==2&&W<2&&(ie.loudness_sq[te][W]=ie.loudness_sq_save[W],ie.loudness_sq_save[W]=k(z,ie))}var m=8,$=23,f=15,E,N,B,U=[1,.79433,.63096,.63096,.63096,.63096,.63096,.25119,.11749];function C(){E=Math.pow(10,(m+1)/16),N=Math.pow(10,($+1)/16),B=Math.pow(10,f/10)}var q=[3.3246*3.3246,3.23837*3.23837,3.15437*3.15437,3.00412*3.00412,2.86103*2.86103,2.65407*2.65407,2.46209*2.46209,2.284*2.284,2.11879*2.11879,1.96552*1.96552,1.82335*1.82335,1.69146*1.69146,1.56911*1.56911,1.46658*1.46658,1.37074*1.37074,1.31036*1.31036,1.25264*1.25264,1.20648*1.20648,1.16203*1.16203,1.12765*1.12765,1.09428*1.09428,1.0659*1.0659,1.03826*1.03826,1.01895*1.01895,1],de=[1.33352*1.33352,1.35879*1.35879,1.38454*1.38454,1.39497*1.39497,1.40548*1.40548,1.3537*1.3537,1.30382*1.30382,1.22321*1.22321,1.14758*1.14758,1],A=[2.35364*2.35364,2.29259*2.29259,2.23313*2.23313,2.12675*2.12675,2.02545*2.02545,1.87894*1.87894,1.74303*1.74303,1.61695*1.61695,1.49999*1.49999,1.39148*1.39148,1.29083*1.29083,1.19746*1.19746,1.11084*1.11084,1.03826*1.03826];function b(M,z,Z,H,J,j){var X;if(z>M)if(z<M*N)X=z/M;else return M+z;else{if(M>=z*N)return M+z;X=M/z}if(M+=z,H+3<=6){if(X>=E)return M;var te=0|Mr.FAST_LOG10_X(X,16);return M*de[te]}var te=0|Mr.FAST_LOG10_X(X,16);if(j!=0?z=J.ATH.cb_s[Z]*J.ATH.adjust:z=J.ATH.cb_l[Z]*J.ATH.adjust,M<B*z){if(M>z){var W,oe;return W=1,te<=13&&(W=A[te]),oe=Mr.FAST_LOG10_X(M/z,10/15),M*((q[te]-W)*oe+W)}return te>13?M:M*A[te]}return M*q[te]}var D=[1.33352*1.33352,1.35879*1.35879,1.38454*1.38454,1.39497*1.39497,1.40548*1.40548,1.3537*1.3537,1.30382*1.30382,1.22321*1.22321,1.14758*1.14758,1];function I(M,z,Z){var H;if(M<0&&(M=0),z<0&&(z=0),M<=0)return z;if(z<=0)return M;if(z>M?H=z/M:H=M/z,-2<=Z&&Z<=2){if(H>=E)return M+z;var J=0|Mr.FAST_LOG10_X(H,16);return(M+z)*D[J]}return H<N?M+z:(M<z&&(M=z),M)}function Y(M,z){var Z=M.internal_flags;if(Z.channels_out>1){for(var H=0;H<ae.SBMAX_l;H++){var J=Z.thm[0].l[H],j=Z.thm[1].l[H];Z.thm[0].l[H]+=j*z,Z.thm[1].l[H]+=J*z}for(var H=0;H<ae.SBMAX_s;H++)for(var X=0;X<3;X++){var J=Z.thm[0].s[H][X],j=Z.thm[1].s[H][X];Z.thm[0].s[H][X]+=j*z,Z.thm[1].s[H][X]+=J*z}}}function V(M){for(var z=0;z<ae.SBMAX_l;z++)if(!(M.thm[0].l[z]>1.58*M.thm[1].l[z]||M.thm[1].l[z]>1.58*M.thm[0].l[z])){var Z=M.mld_l[z]*M.en[3].l[z],H=Math.max(M.thm[2].l[z],Math.min(M.thm[3].l[z],Z));Z=M.mld_l[z]*M.en[2].l[z];var J=Math.max(M.thm[3].l[z],Math.min(M.thm[2].l[z],Z));M.thm[2].l[z]=H,M.thm[3].l[z]=J}for(var z=0;z<ae.SBMAX_s;z++)for(var j=0;j<3;j++)if(!(M.thm[0].s[z][j]>1.58*M.thm[1].s[z][j]||M.thm[1].s[z][j]>1.58*M.thm[0].s[z][j])){var Z=M.mld_s[z]*M.en[3].s[z][j],H=Math.max(M.thm[2].s[z][j],Math.min(M.thm[3].s[z][j],Z));Z=M.mld_s[z]*M.en[2].s[z][j];var J=Math.max(M.thm[3].s[z][j],Math.min(M.thm[2].s[z][j],Z));M.thm[2].s[z][j]=H,M.thm[3].s[z][j]=J}}function ee(M,z,Z){var H=z,J=Math.pow(10,Z);z*=2,H*=2;for(var j=0;j<ae.SBMAX_l;j++){var X,te,W,oe;if(oe=M.ATH.cb_l[M.bm_l[j]]*J,X=Math.min(Math.max(M.thm[0].l[j],oe),Math.max(M.thm[1].l[j],oe)),te=Math.max(M.thm[2].l[j],oe),W=Math.max(M.thm[3].l[j],oe),X*z<te+W){var re=X*H/(te+W);te*=re,W*=re}M.thm[2].l[j]=Math.min(te,M.thm[2].l[j]),M.thm[3].l[j]=Math.min(W,M.thm[3].l[j])}J*=ae.BLKSIZE_s/ae.BLKSIZE;for(var j=0;j<ae.SBMAX_s;j++)for(var ie=0;ie<3;ie++){var X,te,W,oe;if(oe=M.ATH.cb_s[M.bm_s[j]]*J,X=Math.min(Math.max(M.thm[0].s[j][ie],oe),Math.max(M.thm[1].s[j][ie],oe)),te=Math.max(M.thm[2].s[j][ie],oe),W=Math.max(M.thm[3].s[j][ie],oe),X*z<te+W){var re=X*z/(te+W);te*=re,W*=re}M.thm[2].s[j][ie]=Math.min(M.thm[2].s[j][ie],te),M.thm[3].s[j][ie]=Math.min(M.thm[3].s[j][ie],W)}}function L(M,z,Z,H,J){var j,X,te=0,W=0;for(j=X=0;j<ae.SBMAX_s;++X,++j){for(var oe=M.bo_s[j],re=M.npart_s,ie=oe<re?oe:re;X<ie;)Qe(z[X]>=0),Qe(Z[X]>=0),te+=z[X],W+=Z[X],X++;if(M.en[H].s[j][J]=te,M.thm[H].s[j][J]=W,X>=re){++j;break}Qe(z[X]>=0),Qe(Z[X]>=0);{var ye=M.PSY.bo_s_weight[j],Be=1-ye;te=ye*z[X],W=ye*Z[X],M.en[H].s[j][J]+=te,M.thm[H].s[j][J]+=W,te=Be*z[X],W=Be*Z[X]}}for(;j<ae.SBMAX_s;++j)M.en[H].s[j][J]=0,M.thm[H].s[j][J]=0}function T(M,z,Z,H){var J,j,X=0,te=0;for(J=j=0;J<ae.SBMAX_l;++j,++J){for(var W=M.bo_l[J],oe=M.npart_l,re=W<oe?W:oe;j<re;)Qe(z[j]>=0),Qe(Z[j]>=0),X+=z[j],te+=Z[j],j++;if(M.en[H].l[J]=X,M.thm[H].l[J]=te,j>=oe){++J;break}Qe(z[j]>=0),Qe(Z[j]>=0);{var ie=M.PSY.bo_l_weight[J],ye=1-ie;X=ie*z[j],te=ie*Z[j],M.en[H].l[J]+=X,M.thm[H].l[J]+=te,X=ye*z[j],te=ye*Z[j]}}for(;J<ae.SBMAX_l;++J)M.en[H].l[J]=0,M.thm[H].l[J]=0}function y(M,z,Z,H,J,j){var X=M.internal_flags,te,W;for(W=te=0;W<X.npart_s;++W){for(var oe=0,re=X.numlines_s[W],ie=0;ie<re;++ie,++te){var ye=z[j][te];oe+=ye}Z[W]=oe}for(Qe(W==X.npart_s),te=W=0;W<X.npart_s;W++){var Be=X.s3ind_s[W][0],fe=X.s3_ss[te++]*Z[Be];for(++Be;Be<=X.s3ind_s[W][1];)fe+=X.s3_ss[te]*Z[Be],++te,++Be;{var De=o*X.nb_s1[J][W];H[W]=Math.min(fe,De)}if(X.blocktype_old[J&1]==ae.SHORT_TYPE){var De=i*X.nb_s2[J][W],ne=H[W];H[W]=Math.min(De,ne)}X.nb_s2[J][W]=X.nb_s1[J][W],X.nb_s1[J][W]=fe,Qe(H[W]>=0)}for(;W<=ae.CBANDS;++W)Z[W]=0,H[W]=0}function v(M,z,Z,H){var J=M.internal_flags;M.short_blocks==li.short_block_coupled&&!(z[0]!=0&&z[1]!=0)&&(z[0]=z[1]=0);for(var j=0;j<J.channels_out;j++)H[j]=ae.NORM_TYPE,M.short_blocks==li.short_block_dispensed&&(z[j]=1),M.short_blocks==li.short_block_forced&&(z[j]=0),z[j]!=0?(Qe(J.blocktype_old[j]!=ae.START_TYPE),J.blocktype_old[j]==ae.SHORT_TYPE&&(H[j]=ae.STOP_TYPE)):(H[j]=ae.SHORT_TYPE,J.blocktype_old[j]==ae.NORM_TYPE&&(J.blocktype_old[j]=ae.START_TYPE),J.blocktype_old[j]==ae.STOP_TYPE&&(J.blocktype_old[j]=ae.SHORT_TYPE)),Z[j]=J.blocktype_old[j],J.blocktype_old[j]=H[j]}function R(M,z,Z){return Z>=1?M:Z<=0?z:z>0?Math.pow(M/z,Z)*z:0}var O=[11.8,13.6,17.2,32,46.5,51.3,57.5,67.1,71.5,84.6,97.6,130];function K(M,z){for(var Z=309.07,H=0;H<ae.SBMAX_s-1;H++)for(var J=0;J<3;J++){var j=M.thm.s[H][J];if(j>0){var X=j*z,te=M.en.s[H][J];te>X&&(te>X*1e10?Z+=O[H]*(10*r):Z+=O[H]*Mr.FAST_LOG10(te/X))}}return Z}var se=[6.8,5.8,5.8,6.4,6.5,9.9,12.1,14.4,15,18.9,21.6,26.9,34.2,40.2,46.8,56.5,60.7,73.9,85.7,93.4,126.1];function F(M,z){for(var Z=281.0575,H=0;H<ae.SBMAX_l-1;H++){var J=M.thm.l[H];if(J>0){var j=J*z,X=M.en.l[H];X>j&&(X>j*1e10?Z+=se[H]*(10*r):Z+=se[H]*Mr.FAST_LOG10(X/j))}}return Z}function Q(M,z,Z,H,J){var j,X;for(j=X=0;j<M.npart_l;++j){var te=0,W=0,oe;for(oe=0;oe<M.numlines_l[j];++oe,++X){var re=z[X];te+=re,W<re&&(W=re)}Z[j]=te,H[j]=W,J[j]=te*M.rnumlines_l[j],Qe(M.rnumlines_l[j]>=0),Qe(Z[j]>=0),Qe(H[j]>=0),Qe(J[j]>=0)}}function ue(M,z,Z,H){var J=U.length-1,j=0,X=Z[j]+Z[j+1];if(X>0){var te=z[j];te<z[j+1]&&(te=z[j+1]),Qe(M.numlines_l[j]+M.numlines_l[j+1]-1>0),X=20*(te*2-X)/(X*(M.numlines_l[j]+M.numlines_l[j+1]-1));var W=0|X;W>J&&(W=J),H[j]=W}else H[j]=0;for(j=1;j<M.npart_l-1;j++)if(X=Z[j-1]+Z[j]+Z[j+1],X>0){var te=z[j-1];te<z[j]&&(te=z[j]),te<z[j+1]&&(te=z[j+1]),Qe(M.numlines_l[j-1]+M.numlines_l[j]+M.numlines_l[j+1]-1>0),X=20*(te*3-X)/(X*(M.numlines_l[j-1]+M.numlines_l[j]+M.numlines_l[j+1]-1));var W=0|X;W>J&&(W=J),H[j]=W}else H[j]=0;if(Qe(j==M.npart_l-1),X=Z[j-1]+Z[j],X>0){var te=z[j-1];te<z[j]&&(te=z[j]),Qe(M.numlines_l[j-1]+M.numlines_l[j]-1>0),X=20*(te*2-X)/(X*(M.numlines_l[j-1]+M.numlines_l[j]-1));var W=0|X;W>J&&(W=J),H[j]=W}else H[j]=0;Qe(j==M.npart_l-1)}var ge=[-865163e-23*2,-.00851586*2,-674764e-23*2,.0209036*2,-336639e-22*2,-.0438162*2,-154175e-22*2,.0931738*2,-552212e-22*2,-.313819*2];this.L3psycho_anal_ns=function(M,z,Z,H,J,j,X,te,W,oe){var re=M.internal_flags,ie=nn([2,ae.BLKSIZE]),ye=nn([2,3,ae.BLKSIZE_s]),Be=Gt(ae.CBANDS+1),fe=Gt(ae.CBANDS+1),De=Gt(ae.CBANDS+2),ne=lo(2),$e=lo(2),tt,he,Me,pe,qe,Tt,we,Ke,rt=nn([2,576]),Ot,Or=lo(ae.CBANDS+2),Ft=lo(ae.CBANDS+2);for(Sz.fill(Ft,0),tt=re.channels_out,M.mode==t.JOINT_STEREO&&(tt=4),M.VBR==ci.vbr_off?Ot=re.ResvMax==0?0:re.ResvSize/re.ResvMax*.5:M.VBR==ci.vbr_rh||M.VBR==ci.vbr_mtrh||M.VBR==ci.vbr_mt?Ot=.6:Ot=1,he=0;he<re.channels_out;he++){var At=z[he],yr=Z+576-350-g+192;for(pe=0;pe<576;pe++){var Ar,Nr;for(Ar=At[yr+pe+10],Nr=0,qe=0;qe<(g-1)/2-1;qe+=2)Ar+=ge[qe]*(At[yr+pe+qe]+At[yr+pe+g-qe]),Nr+=ge[qe+1]*(At[yr+pe+qe+1]+At[yr+pe+g-qe-1]);rt[he][pe]=Ar+Nr}J[H][he].en.assign(re.en[he]),J[H][he].thm.assign(re.thm[he]),tt>2&&(j[H][he].en.assign(re.en[he+2]),j[H][he].thm.assign(re.thm[he+2]))}for(he=0;he<tt;he++){var an,cn,ar=Gt(12),kn=[0,0,0,0],go=Gt(12),fu=1,v1,w1=Gt(ae.CBANDS),x1=Gt(ae.CBANDS),Nt=[0,0,0,0],k1=Gt(ae.HBLKSIZE),S1=nn([3,ae.HBLKSIZE_s]);for(Qe(re.npart_s<=ae.CBANDS),Qe(re.npart_l<=ae.CBANDS),pe=0;pe<3;pe++)ar[pe]=re.nsPsy.last_en_subshort[he][pe+6],Qe(re.nsPsy.last_en_subshort[he][pe+4]>0),go[pe]=ar[pe]/re.nsPsy.last_en_subshort[he][pe+4],kn[0]+=ar[pe];if(he==2)for(pe=0;pe<576;pe++){var hu,pu;hu=rt[0][pe],pu=rt[1][pe],rt[0][pe]=hu+pu,rt[1][pe]=hu-pu}{var E1=rt[he&1],gi=0;for(pe=0;pe<9;pe++){for(var H3=gi+64,Qt=1;gi<H3;gi++)Qt<Math.abs(E1[gi])&&(Qt=Math.abs(E1[gi]));re.nsPsy.last_en_subshort[he][pe]=ar[pe+3]=Qt,kn[1+pe/3]+=Qt,Qt>ar[pe+3-2]?(Qe(ar[pe+3-2]>0),Qt=Qt/ar[pe+3-2]):ar[pe+3-2]>Qt*10?Qt=ar[pe+3-2]/(Qt*10):Qt=0,go[pe+3]=Qt}}if(M.analysis){var mu=go[0];for(pe=1;pe<12;pe++)mu<go[pe]&&(mu=go[pe]);re.pinfo.ers[H][he]=re.pinfo.ers_save[he],re.pinfo.ers_save[he]=mu}for(v1=he==3?re.nsPsy.attackthre_s:re.nsPsy.attackthre,pe=0;pe<12;pe++)Nt[pe/3]==0&&go[pe]>v1&&(Nt[pe/3]=pe%3+1);for(pe=1;pe<4;pe++){var gu;kn[pe-1]>kn[pe]?(Qe(kn[pe]>0),gu=kn[pe-1]/kn[pe]):(Qe(kn[pe-1]>0),gu=kn[pe]/kn[pe-1]),gu<1.7&&(Nt[pe]=0,pe==1&&(Nt[0]=0))}for(Nt[0]!=0&&re.nsPsy.lastAttacks[he]!=0&&(Nt[0]=0),(re.nsPsy.lastAttacks[he]==3||Nt[0]+Nt[1]+Nt[2]+Nt[3]!=0)&&(fu=0,Nt[1]!=0&&Nt[0]!=0&&(Nt[1]=0),Nt[2]!=0&&Nt[1]!=0&&(Nt[2]=0),Nt[3]!=0&&Nt[2]!=0&&(Nt[3]=0)),he<2?$e[he]=fu:fu==0&&($e[0]=$e[1]=0),W[he]=re.tot_ener[he],cn=ye,an=ie,_(M,k1,S1,an,he&1,cn,he&1,H,he,z,Z),Q(re,k1,Be,w1,x1),ue(re,w1,x1,Or),Ke=0;Ke<3;Ke++){var _u,vr;for(y(M,S1,fe,De,he,Ke),L(re,fe,De,he,Ke),we=0;we<ae.SBMAX_s;we++){if(vr=re.thm[he].s[we][Ke],vr*=l,Nt[Ke]>=2||Nt[Ke+1]==1){var _i=Ke!=0?Ke-1:2,Qt=R(re.thm[he].s[we][_i],vr,u*Ot);vr=Math.min(vr,Qt)}if(Nt[Ke]==1){var _i=Ke!=0?Ke-1:2,Qt=R(re.thm[he].s[we][_i],vr,h*Ot);vr=Math.min(vr,Qt)}else if(Ke!=0&&Nt[Ke-1]==3||Ke==0&&re.nsPsy.lastAttacks[he]==3){var _i=Ke!=2?Ke+1:0,Qt=R(re.thm[he].s[we][_i],vr,h*Ot);vr=Math.min(vr,Qt)}_u=ar[Ke*3+3]+ar[Ke*3+4]+ar[Ke*3+5],ar[Ke*3+5]*6<_u&&(vr*=.5,ar[Ke*3+4]*6<_u&&(vr*=.5)),re.thm[he].s[we][Ke]=vr}}for(re.nsPsy.lastAttacks[he]=Nt[2],Tt=0,Me=0;Me<re.npart_l;Me++){for(var vs=re.s3ind[Me][0],bu=Be[vs]*U[Or[vs]],ws=re.s3_ll[Tt++]*bu;++vs<=re.s3ind[Me][1];)bu=Be[vs]*U[Or[vs]],ws=b(ws,re.s3_ll[Tt++]*bu,vs,vs-Me,re,0);ws*=.158489319246111,re.blocktype_old[he&1]==ae.SHORT_TYPE?De[Me]=ws:De[Me]=R(Math.min(ws,Math.min(n*re.nb_1[he][Me],s*re.nb_2[he][Me])),ws,Ot),re.nb_2[he][Me]=re.nb_1[he][Me],re.nb_1[he][Me]=ws}for(;Me<=ae.CBANDS;++Me)Be[Me]=0,De[Me]=0;T(re,Be,De,he)}if((M.mode==t.STEREO||M.mode==t.JOINT_STEREO)&&M.interChRatio>0&&Y(M,M.interChRatio),M.mode==t.JOINT_STEREO){var yu;V(re),yu=M.msfix,Math.abs(yu)>0&&ee(re,yu,M.ATHlower*re.ATH.adjust)}for(v(M,$e,oe,ne),he=0;he<tt;he++){var bi,yi=0,Ba,qa;he>1?(bi=te,yi=-2,Ba=ae.NORM_TYPE,(oe[0]==ae.SHORT_TYPE||oe[1]==ae.SHORT_TYPE)&&(Ba=ae.SHORT_TYPE),qa=j[H][he-2]):(bi=X,yi=0,Ba=oe[he],qa=J[H][he]),Ba==ae.SHORT_TYPE?bi[yi+he]=K(qa,re.masking_lower):bi[yi+he]=F(qa,re.masking_lower),M.analysis&&(re.pinfo.pe[H][he]=bi[yi+he])}return 0};function ke(M,z,Z,H,J,j,X,te){var W=M.internal_flags;if(H<2)e.fft_long(W,X[te],H,z,Z);else if(H==2)for(var oe=ae.BLKSIZE-1;oe>=0;--oe){var re=X[te+0][oe],ie=X[te+1][oe];X[te+0][oe]=(re+ie)*Mr.SQRT2*.5,X[te+1][oe]=(re-ie)*Mr.SQRT2*.5}j[0]=X[te+0][0],j[0]*=j[0];for(var oe=ae.BLKSIZE/2-1;oe>=0;--oe){var ye=X[te+0][ae.BLKSIZE/2-oe],Be=X[te+0][ae.BLKSIZE/2+oe];j[ae.BLKSIZE/2-oe]=(ye*ye+Be*Be)*.5}{for(var fe=0,oe=11;oe<ae.HBLKSIZE;oe++)fe+=j[oe];W.tot_ener[H]=fe}if(M.analysis){for(var oe=0;oe<ae.HBLKSIZE;oe++)W.pinfo.energy[J][H][oe]=W.pinfo.energy_save[H][oe],W.pinfo.energy_save[H][oe]=j[oe];W.pinfo.pe[J][H]=W.pe[H]}}function Re(M,z,Z,H,J,j,X,te){var W=M.internal_flags;if(J==0&&H<2&&e.fft_short(W,X[te],H,z,Z),H==2)for(var oe=ae.BLKSIZE_s-1;oe>=0;--oe){var re=X[te+0][J][oe],ie=X[te+1][J][oe];X[te+0][J][oe]=(re+ie)*Mr.SQRT2*.5,X[te+1][J][oe]=(re-ie)*Mr.SQRT2*.5}j[J][0]=X[te+0][J][0],j[J][0]*=j[J][0];for(var oe=ae.BLKSIZE_s/2-1;oe>=0;--oe){var ye=X[te+0][J][ae.BLKSIZE_s/2-oe],Be=X[te+0][J][ae.BLKSIZE_s/2+oe];j[J][ae.BLKSIZE_s/2-oe]=(ye*ye+Be*Be)*.5}}function Te(M,z,Z,H){var J=M.internal_flags;M.athaa_loudapprox==2&&Z<2&&(J.loudness_sq[z][Z]=J.loudness_sq_save[Z],J.loudness_sq_save[Z]=k(H,J))}var Se=[-865163e-23*2,-.00851586*2,-674764e-23*2,.0209036*2,-336639e-22*2,-.0438162*2,-154175e-22*2,.0931738*2,-552212e-22*2,-.313819*2];function Ce(M,z,Z,H,J,j,X,te,W,oe){for(var re=nn([2,576]),ie=M.internal_flags,ye=ie.channels_out,Be=M.mode==t.JOINT_STEREO?4:ye,fe=0;fe<ye;fe++){firbuf=z[fe];for(var De=Z+576-350-g+192,ne=0;ne<576;ne++){var $e,tt;$e=firbuf[De+ne+10],tt=0;for(var he=0;he<(g-1)/2-1;he+=2)$e+=Se[he]*(firbuf[De+ne+he]+firbuf[De+ne+g-he]),tt+=Se[he+1]*(firbuf[De+ne+he+1]+firbuf[De+ne+g-he-1]);re[fe][ne]=$e+tt}J[H][fe].en.assign(ie.en[fe]),J[H][fe].thm.assign(ie.thm[fe]),Be>2&&(j[H][fe].en.assign(ie.en[fe+2]),j[H][fe].thm.assign(ie.thm[fe+2]))}for(var fe=0;fe<Be;fe++){var Me=Gt(12),pe=Gt(12),qe=[0,0,0,0],Tt=re[fe&1],we=0,Ke=fe==3?ie.nsPsy.attackthre_s:ie.nsPsy.attackthre,rt=1;if(fe==2)for(var ne=0,he=576;he>0;++ne,--he){var Ot=re[0][ne],Or=re[1][ne];re[0][ne]=Ot+Or,re[1][ne]=Ot-Or}for(var ne=0;ne<3;ne++)pe[ne]=ie.nsPsy.last_en_subshort[fe][ne+6],Qe(ie.nsPsy.last_en_subshort[fe][ne+4]>0),Me[ne]=pe[ne]/ie.nsPsy.last_en_subshort[fe][ne+4],qe[0]+=pe[ne];for(var ne=0;ne<9;ne++){for(var Ft=we+64,At=1;we<Ft;we++)At<Math.abs(Tt[we])&&(At=Math.abs(Tt[we]));ie.nsPsy.last_en_subshort[fe][ne]=pe[ne+3]=At,qe[1+ne/3]+=At,At>pe[ne+3-2]?(Qe(pe[ne+3-2]>0),At=At/pe[ne+3-2]):pe[ne+3-2]>At*10?At=pe[ne+3-2]/(At*10):At=0,Me[ne+3]=At}for(var ne=0;ne<3;++ne){var yr=pe[ne*3+3]+pe[ne*3+4]+pe[ne*3+5],Ar=1;pe[ne*3+5]*6<yr&&(Ar*=.5,pe[ne*3+4]*6<yr&&(Ar*=.5)),te[fe][ne]=Ar}if(M.analysis){for(var Nr=Me[0],ne=1;ne<12;ne++)Nr<Me[ne]&&(Nr=Me[ne]);ie.pinfo.ers[H][fe]=ie.pinfo.ers_save[fe],ie.pinfo.ers_save[fe]=Nr}for(var ne=0;ne<12;ne++)W[fe][ne/3]==0&&Me[ne]>Ke&&(W[fe][ne/3]=ne%3+1);for(var ne=1;ne<4;ne++){var an=qe[ne-1],cn=qe[ne],ar=Math.max(an,cn);ar<4e4&&an<1.7*cn&&cn<1.7*an&&(ne==1&&W[fe][0]<=W[fe][ne]&&(W[fe][0]=0),W[fe][ne]=0)}W[fe][0]<=ie.nsPsy.lastAttacks[fe]&&(W[fe][0]=0),(ie.nsPsy.lastAttacks[fe]==3||W[fe][0]+W[fe][1]+W[fe][2]+W[fe][3]!=0)&&(rt=0,W[fe][1]!=0&&W[fe][0]!=0&&(W[fe][1]=0),W[fe][2]!=0&&W[fe][1]!=0&&(W[fe][2]=0),W[fe][3]!=0&&W[fe][2]!=0&&(W[fe][3]=0)),fe<2?oe[fe]=rt:rt==0&&(oe[0]=oe[1]=0),X[fe]=ie.tot_ener[fe]}}function St(M,z,Z){if(Z==0)for(var H=0;H<M.npart_s;H++)M.nb_s2[z][H]=M.nb_s1[z][H],M.nb_s1[z][H]=0}function Fr(M,z){for(var Z=0;Z<M.npart_l;Z++)M.nb_2[z][Z]=M.nb_1[z][Z],M.nb_1[z][Z]=0}function w(M,z,Z,H){var J=U.length-1,j=0,X=Z[j]+Z[j+1];if(X>0){var te=z[j];te<z[j+1]&&(te=z[j+1]),Qe(M.numlines_s[j]+M.numlines_s[j+1]-1>0),X=20*(te*2-X)/(X*(M.numlines_s[j]+M.numlines_s[j+1]-1));var W=0|X;W>J&&(W=J),H[j]=W}else H[j]=0;for(j=1;j<M.npart_s-1;j++)if(X=Z[j-1]+Z[j]+Z[j+1],Qe(j+1<M.npart_s),X>0){var te=z[j-1];te<z[j]&&(te=z[j]),te<z[j+1]&&(te=z[j+1]),Qe(M.numlines_s[j-1]+M.numlines_s[j]+M.numlines_s[j+1]-1>0),X=20*(te*3-X)/(X*(M.numlines_s[j-1]+M.numlines_s[j]+M.numlines_s[j+1]-1));var W=0|X;W>J&&(W=J),H[j]=W}else H[j]=0;if(Qe(j==M.npart_s-1),X=Z[j-1]+Z[j],X>0){var te=z[j-1];te<z[j]&&(te=z[j]),Qe(M.numlines_s[j-1]+M.numlines_s[j]-1>0),X=20*(te*2-X)/(X*(M.numlines_s[j-1]+M.numlines_s[j]-1));var W=0|X;W>J&&(W=J),H[j]=W}else H[j]=0;Qe(j==M.npart_s-1)}function P(M,z,Z,H,J,j){var X=M.internal_flags,te=new float[ae.CBANDS],W=Gt(ae.CBANDS),oe,re,ie,ye=new int[ae.CBANDS];for(ie=re=0;ie<X.npart_s;++ie){var Be=0,fe=0,De=X.numlines_s[ie];for(oe=0;oe<De;++oe,++re){var ne=z[j][re];Be+=ne,fe<ne&&(fe=ne)}Z[ie]=Be,te[ie]=fe,W[ie]=Be/De,Qe(W[ie]>=0)}for(Qe(ie==X.npart_s);ie<ae.CBANDS;++ie)te[ie]=0,W[ie]=0;for(w(X,te,W,ye),re=ie=0;ie<X.npart_s;ie++){var $e=X.s3ind_s[ie][0],tt=X.s3ind_s[ie][1],he,Me,pe,qe,Tt;for(he=ye[$e],Me=1,qe=X.s3_ss[re]*Z[$e]*U[ye[$e]],++re,++$e;$e<=tt;)he+=ye[$e],Me+=1,pe=X.s3_ss[re]*Z[$e]*U[ye[$e]],qe=I(qe,pe,$e-ie),++re,++$e;he=(1+2*he)/(2*Me),Tt=U[he]*.5,qe*=Tt,H[ie]=qe,X.nb_s2[J][ie]=X.nb_s1[J][ie],X.nb_s1[J][ie]=qe,pe=te[ie],pe*=X.minval_s[ie],pe*=Tt,H[ie]>pe&&(H[ie]=pe),X.masking_lower>1&&(H[ie]*=X.masking_lower),H[ie]>Z[ie]&&(H[ie]=Z[ie]),X.masking_lower<1&&(H[ie]*=X.masking_lower),Qe(H[ie]>=0)}for(;ie<ae.CBANDS;++ie)Z[ie]=0,H[ie]=0}function xe(M,z,Z,H,J){var j=Gt(ae.CBANDS),X=Gt(ae.CBANDS),te=lo(ae.CBANDS+2),W;Q(M,z,Z,j,X),ue(M,j,X,te);var oe=0;for(W=0;W<M.npart_l;W++){var re,ie,ye,Be,fe=M.s3ind[W][0],De=M.s3ind[W][1],ne=0,$e=0;for(ne=te[fe],$e+=1,ie=M.s3_ll[oe]*Z[fe]*U[te[fe]],++oe,++fe;fe<=De;)ne+=te[fe],$e+=1,re=M.s3_ll[oe]*Z[fe]*U[te[fe]],Be=I(ie,re,fe-W),ie=Be,++oe,++fe;if(ne=(1+2*ne)/(2*$e),ye=U[ne]*.5,ie*=ye,M.blocktype_old[J&1]==ae.SHORT_TYPE){var tt=n*M.nb_1[J][W];tt>0?H[W]=Math.min(ie,tt):H[W]=Math.min(ie,Z[W]*h)}else{var he=s*M.nb_2[J][W],Me=n*M.nb_1[J][W],tt;he<=0&&(he=ie),Me<=0&&(Me=ie),M.blocktype_old[J&1]==ae.NORM_TYPE?tt=Math.min(Me,he):tt=Me,H[W]=Math.min(ie,tt)}M.nb_2[J][W]=M.nb_1[J][W],M.nb_1[J][W]=ie,re=j[W],re*=M.minval_l[W],re*=ye,H[W]>re&&(H[W]=re),M.masking_lower>1&&(H[W]*=M.masking_lower),H[W]>Z[W]&&(H[W]=Z[W]),M.masking_lower<1&&(H[W]*=M.masking_lower),Qe(H[W]>=0)}for(;W<ae.CBANDS;++W)Z[W]=0,H[W]=0}function Pe(M,z){var Z=M.internal_flags;M.short_blocks==li.short_block_coupled&&!(z[0]!=0&&z[1]!=0)&&(z[0]=z[1]=0);for(var H=0;H<Z.channels_out;H++)M.short_blocks==li.short_block_dispensed&&(z[H]=1),M.short_blocks==li.short_block_forced&&(z[H]=0)}function Ge(M,z,Z){for(var H=M.internal_flags,J=0;J<H.channels_out;J++){var j=ae.NORM_TYPE;z[J]!=0?(Qe(H.blocktype_old[J]!=ae.START_TYPE),H.blocktype_old[J]==ae.SHORT_TYPE&&(j=ae.STOP_TYPE)):(j=ae.SHORT_TYPE,H.blocktype_old[J]==ae.NORM_TYPE&&(H.blocktype_old[J]=ae.START_TYPE),H.blocktype_old[J]==ae.STOP_TYPE&&(H.blocktype_old[J]=ae.SHORT_TYPE)),Z[J]=H.blocktype_old[J],H.blocktype_old[J]=j}}function He(M,z,Z,H,J,j,X){for(var te=j*2,W=j>0?Math.pow(10,J):1,oe,re,ie=0;ie<X;++ie){var ye=M[2][ie],Be=M[3][ie],fe=z[0][ie],De=z[1][ie],ne=z[2][ie],$e=z[3][ie];if(fe<=1.58*De&&De<=1.58*fe){var tt=Z[ie]*Be,he=Z[ie]*ye;re=Math.max(ne,Math.min($e,tt)),oe=Math.max($e,Math.min(ne,he))}else re=ne,oe=$e;if(j>0){var Me,pe,qe=H[ie]*W;if(Me=Math.min(Math.max(fe,qe),Math.max(De,qe)),ne=Math.max(re,qe),$e=Math.max(oe,qe),pe=ne+$e,pe>0&&Me*te<pe){var Tt=Me*te/pe;ne*=Tt,$e*=Tt}re=Math.min(ne,re),oe=Math.min($e,oe)}re>ye&&(re=ye),oe>Be&&(oe=Be),z[2][ie]=re,z[3][ie]=oe}}this.L3psycho_anal_vbr=function(M,z,Z,H,J,j,X,te,W,oe){var re=M.internal_flags,ie,ye,Be=Gt(ae.HBLKSIZE),fe=nn([3,ae.HBLKSIZE_s]),De=nn([2,ae.BLKSIZE]),ne=nn([2,3,ae.BLKSIZE_s]),$e=nn([4,ae.CBANDS]),tt=nn([4,ae.CBANDS]),he=nn([4,3]),Me=.6,pe=[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]],qe=lo(2),Tt=M.mode==t.JOINT_STEREO?4:re.channels_out;Ce(M,z,Z,H,J,j,W,he,pe,qe),Pe(M,qe);{for(var we=0;we<Tt;we++){var Ke=we&1;ie=De,ke(M,z,Z,we,H,Be,ie,Ke),Te(M,H,we,Be),qe[Ke]!=0?xe(re,Be,$e[we],tt[we],we):Fr(re,we)}qe[0]+qe[1]==2&&M.mode==t.JOINT_STEREO&&He($e,tt,re.mld_cb_l,re.ATH.cb_l,M.ATHlower*re.ATH.adjust,M.msfix,re.npart_l);for(var we=0;we<Tt;we++){var Ke=we&1;qe[Ke]!=0&&T(re,$e[we],tt[we],we)}}{for(var rt=0;rt<3;rt++){for(var we=0;we<Tt;++we){var Ke=we&1;qe[Ke]!=0?St(re,we,rt):(ye=ne,Re(M,z,Z,we,rt,fe,ye,Ke),P(M,fe,$e[we],tt[we],we,rt))}qe[0]+qe[1]==0&&M.mode==t.JOINT_STEREO&&He($e,tt,re.mld_cb_s,re.ATH.cb_s,M.ATHlower*re.ATH.adjust,M.msfix,re.npart_s);for(var we=0;we<Tt;++we){var Ke=we&1;qe[Ke]==0&&L(re,$e[we],tt[we],we,rt)}}for(var we=0;we<Tt;we++){var Ke=we&1;if(qe[Ke]==0)for(var Ot=0;Ot<ae.SBMAX_s;Ot++){for(var Or=Gt(3),rt=0;rt<3;rt++){var Ft=re.thm[we].s[Ot][rt];if(Ft*=l,pe[we][rt]>=2||pe[we][rt+1]==1){var At=rt!=0?rt-1:2,yr=R(re.thm[we].s[Ot][At],Ft,u*Me);Ft=Math.min(Ft,yr)}else if(pe[we][rt]==1){var At=rt!=0?rt-1:2,yr=R(re.thm[we].s[Ot][At],Ft,h*Me);Ft=Math.min(Ft,yr)}else if(rt!=0&&pe[we][rt-1]==3||rt==0&&re.nsPsy.lastAttacks[we]==3){var At=rt!=2?rt+1:0,yr=R(re.thm[we].s[Ot][At],Ft,h*Me);Ft=Math.min(Ft,yr)}Ft*=he[we][rt],Or[rt]=Ft}for(var rt=0;rt<3;rt++)re.thm[we].s[Ot][rt]=Or[rt]}}}for(var we=0;we<Tt;we++)re.nsPsy.lastAttacks[we]=pe[we][2];Ge(M,qe,oe);for(var we=0;we<Tt;we++){var Ar,Nr,an,cn;we>1?(Ar=te,Nr=-2,an=ae.NORM_TYPE,(oe[0]==ae.SHORT_TYPE||oe[1]==ae.SHORT_TYPE)&&(an=ae.SHORT_TYPE),cn=j[H][we-2]):(Ar=X,Nr=0,an=oe[we],cn=J[H][we]),an==ae.SHORT_TYPE?Ar[Nr+we]=K(cn,re.masking_lower):Ar[Nr+we]=F(cn,re.masking_lower),M.analysis&&(re.pinfo.pe[H][we]=Ar[Nr+we])}return 0};function Ne(M,z){var Z=M,H;return Z>=0?H=-Z*27:H=Z*z,H<=-72?0:Math.exp(H*x)}function ze(M){var z=0,Z=0;{var H=0,J,j;for(H=0;Ne(H,M)>1e-20;H-=1);for(J=H,j=0;Math.abs(j-J)>1e-12;)H=(j+J)/2,Ne(H,M)>0?j=H:J=H;z=J}{var H=0,J,j;for(H=0;Ne(H,M)>1e-20;H+=1);for(J=0,j=H;Math.abs(j-J)>1e-12;)H=(j+J)/2,Ne(H,M)>0?J=H:j=H;Z=j}{var X=0,te=1e3,W;for(W=0;W<=te;++W){var H=z+W*(Z-z)/te,oe=Ne(H,M);X+=oe}{var re=(te+1)/(X*(Z-z));return re}}}function et(M){var z,Z,H,J;return z=M,z>=0?z*=3:z*=1.5,z>=.5&&z<=2.5?(J=z-.5,Z=8*(J*J-2*J)):Z=0,z+=.474,H=15.811389+7.5*z-17.5*Math.sqrt(1+z*z),H<=-60?0:(z=Math.exp((Z+H)*x),z/=.6609193,z)}function je(M){return M<0&&(M=0),M=M*.001,13*Math.atan(.76*M)+3.5*Math.atan(M*M/(7.5*7.5))}function ve(M,z,Z,H,J,j,X,te,W,oe,re,ie){var ye=Gt(ae.CBANDS+1),Be=te/(ie>15?2*576:2*192),fe=lo(ae.HBLKSIZE),De;te/=W;var ne=0,$e=0;for(De=0;De<ae.CBANDS;De++){var tt,he;for(tt=je(te*ne),ye[De]=te*ne,he=ne;je(te*he)-tt<a&&he<=W/2;he++);for(M[De]=he-ne,$e=De+1;ne<he;)Qe(ne<ae.HBLKSIZE),fe[ne++]=De;if(ne>W/2){ne=W/2,++De;break}}Qe(De<ae.CBANDS),ye[De]=te*ne;for(var Me=0;Me<ie;Me++){var pe,qe,Tt,we,Ke;Tt=oe[Me],we=oe[Me+1],pe=0|Math.floor(.5+re*(Tt-.5)),pe<0&&(pe=0),qe=0|Math.floor(.5+re*(we-.5)),qe>W/2&&(qe=W/2),Z[Me]=(fe[pe]+fe[qe])/2,z[Me]=fe[qe];var rt=Be*we;X[Me]=(rt-ye[z[Me]])/(ye[z[Me]+1]-ye[z[Me]]),X[Me]<0?X[Me]=0:X[Me]>1&&(X[Me]=1),Ke=je(te*oe[Me]*re),Ke=Math.min(Ke,15.5)/15.5,j[Me]=Math.pow(10,1.25*(1-Math.cos(Math.PI*Ke))-2.5)}ne=0;for(var Ot=0;Ot<$e;Ot++){var Or=M[Ot],tt,Ft;tt=je(te*ne),Ft=je(te*(ne+Or-1)),H[Ot]=.5*(tt+Ft),tt=je(te*(ne-.5)),Ft=je(te*(ne+Or-.5)),J[Ot]=Ft-tt,ne+=Or}return $e}function vt(M,z,Z,H,J,j){var X=nn([ae.CBANDS,ae.CBANDS]),te,W=0;if(j)for(var oe=0;oe<z;oe++)for(te=0;te<z;te++){var re=et(Z[oe]-Z[te])*H[te];X[oe][te]=re*J[oe]}else for(te=0;te<z;te++)for(var ie=15+Math.min(21/Z[te],12),ye=ze(ie),oe=0;oe<z;oe++){var re=ye*Ne(Z[oe]-Z[te],ie)*H[te];X[oe][te]=re*J[oe]}for(var oe=0;oe<z;oe++){for(te=0;te<z&&!(X[oe][te]>0);te++);for(M[oe][0]=te,te=z-1;te>0&&!(X[oe][te]>0);te--);M[oe][1]=te,W+=M[oe][1]-M[oe][0]+1}for(var Be=Gt(W),fe=0,oe=0;oe<z;oe++)for(te=M[oe][0];te<=M[oe][1];te++)Be[fe++]=X[oe][te];return Be}function Yt(M){var z=je(M);return z=Math.min(z,15.5)/15.5,Math.pow(10,1.25*(1-Math.cos(Math.PI*z))-2.5)}this.psymodel_init=function(M){var z=M.internal_flags,Z,H=!0,J=13,j=24,X=0,te=0,W=-8.25,oe=-4.5,re=Gt(ae.CBANDS),ie=Gt(ae.CBANDS),ye=Gt(ae.CBANDS),Be=M.out_samplerate;switch(M.experimentalZ){default:case 0:H=!0;break;case 1:H=!(M.VBR==ci.vbr_mtrh||M.VBR==ci.vbr_mt);break;case 2:H=!1;break;case 3:J=8,X=-1.75,te=-.0125,W=-8.25,oe=-2.25;break}for(z.ms_ener_ratio_old=.25,z.blocktype_old[0]=z.blocktype_old[1]=ae.NORM_TYPE,Z=0;Z<4;++Z){for(var ne=0;ne<ae.CBANDS;++ne)z.nb_1[Z][ne]=1e20,z.nb_2[Z][ne]=1e20,z.nb_s1[Z][ne]=z.nb_s2[Z][ne]=1;for(var fe=0;fe<ae.SBMAX_l;fe++)z.en[Z].l[fe]=1e20,z.thm[Z].l[fe]=1e20;for(var ne=0;ne<3;++ne){for(var fe=0;fe<ae.SBMAX_s;fe++)z.en[Z].s[fe][ne]=1e20,z.thm[Z].s[fe][ne]=1e20;z.nsPsy.lastAttacks[Z]=0}for(var ne=0;ne<9;ne++)z.nsPsy.last_en_subshort[Z][ne]=10}for(z.loudness_sq_save[0]=z.loudness_sq_save[1]=0,z.npart_l=ve(z.numlines_l,z.bo_l,z.bm_l,re,ie,z.mld_l,z.PSY.bo_l_weight,Be,ae.BLKSIZE,z.scalefac_band.l,ae.BLKSIZE/(2*576),ae.SBMAX_l),Qe(z.npart_l<ae.CBANDS),Z=0;Z<z.npart_l;Z++){var De=X;re[Z]>=J&&(De=te*(re[Z]-J)/(j-J)+X*(j-re[Z])/(j-J)),ye[Z]=Math.pow(10,De/10),z.numlines_l[Z]>0?z.rnumlines_l[Z]=1/z.numlines_l[Z]:z.rnumlines_l[Z]=0}z.s3_ll=vt(z.s3ind,z.npart_l,re,ie,ye,H);var ne=0;for(Z=0;Z<z.npart_l;Z++){var $e;$e=Pw.MAX_VALUE;for(var tt=0;tt<z.numlines_l[Z];tt++,ne++){var he=Be*ne/(1e3*ae.BLKSIZE),Me;Me=this.ATHformula(he*1e3,M)-20,Me=Math.pow(10,.1*Me),Me*=z.numlines_l[Z],$e>Me&&($e=Me)}z.ATH.cb_l[Z]=$e,$e=-20+re[Z]*20/10,$e>6&&($e=100),$e<-15&&($e=-15),$e-=8,z.minval_l[Z]=Math.pow(10,$e/10)*z.numlines_l[Z]}for(z.npart_s=ve(z.numlines_s,z.bo_s,z.bm_s,re,ie,z.mld_s,z.PSY.bo_s_weight,Be,ae.BLKSIZE_s,z.scalefac_band.s,ae.BLKSIZE_s/(2*192),ae.SBMAX_s),Qe(z.npart_s<ae.CBANDS),ne=0,Z=0;Z<z.npart_s;Z++){var $e,De=W;re[Z]>=J&&(De=oe*(re[Z]-J)/(j-J)+W*(j-re[Z])/(j-J)),ye[Z]=Math.pow(10,De/10),$e=Pw.MAX_VALUE;for(var tt=0;tt<z.numlines_s[Z];tt++,ne++){var he=Be*ne/(1e3*ae.BLKSIZE_s),Me;Me=this.ATHformula(he*1e3,M)-20,Me=Math.pow(10,.1*Me),Me*=z.numlines_s[Z],$e>Me&&($e=Me)}z.ATH.cb_s[Z]=$e,$e=-7+re[Z]*7/12,re[Z]>12&&($e*=1+Math.log(1+$e)*3.1),re[Z]<12&&($e*=1+Math.log(1-$e)*2.3),$e<-15&&($e=-15),$e-=8,z.minval_s[Z]=Math.pow(10,$e/10)*z.numlines_s[Z]}z.s3_ss=vt(z.s3ind_s,z.npart_s,re,ie,ye,H),C(),e.init_fft(z),z.decay=Math.exp(-1*r/(d*Be/192));{var pe;pe=p,M.exp_nspsytune&2&&(pe=1),Math.abs(M.msfix)>0&&(pe=M.msfix),M.msfix=pe;for(var qe=0;qe<z.npart_l;qe++)z.s3ind[qe][1]>z.npart_l-1&&(z.s3ind[qe][1]=z.npart_l-1)}var Tt=576*z.mode_gr/Be;if(z.ATH.decay=Math.pow(10,-12/10*Tt),z.ATH.adjust=.01,z.ATH.adjustLimit=1,Qe(z.bo_l[ae.SBMAX_l-1]<=z.npart_l),Qe(z.bo_s[ae.SBMAX_s-1]<=z.npart_s),M.ATHtype!=-1){var he,we=M.out_samplerate/ae.BLKSIZE,Ke=0;for(he=0,Z=0;Z<ae.BLKSIZE/2;++Z)he+=we,z.ATH.eql_w[Z]=1/Math.pow(10,this.ATHformula(he,M)/10),Ke+=z.ATH.eql_w[Z];for(Ke=1/Ke,Z=ae.BLKSIZE/2;--Z>=0;)z.ATH.eql_w[Z]*=Ke}{for(var qe=ne=0;qe<z.npart_s;++qe)for(Z=0;Z<z.numlines_s[qe];++Z)++ne;for(var qe=ne=0;qe<z.npart_l;++qe)for(Z=0;Z<z.numlines_l[qe];++Z)++ne}for(ne=0,Z=0;Z<z.npart_l;Z++){var he=Be*(ne+z.numlines_l[Z]/2)/(1*ae.BLKSIZE);z.mld_cb_l[Z]=Yt(he),ne+=z.numlines_l[Z]}for(;Z<ae.CBANDS;++Z)z.mld_cb_l[Z]=1;for(ne=0,Z=0;Z<z.npart_s;Z++){var he=Be*(ne+z.numlines_s[Z]/2)/(1*ae.BLKSIZE_s);z.mld_cb_s[Z]=Yt(he),ne+=z.numlines_s[Z]}for(;Z<ae.CBANDS;++Z)z.mld_cb_s[Z]=1;return 0};function pt(M,z){M<-.3&&(M=3410),M/=1e3,M=Math.max(.1,M);var Z=3.64*Math.pow(M,-.8)-6.8*Math.exp(-.6*Math.pow(M-3.4,2))+6*Math.exp(-.15*Math.pow(M-8.7,2))+(.6+.04*z)*.001*Math.pow(M,4);return Z}this.ATHformula=function(M,z){var Z;switch(z.ATHtype){case 0:Z=pt(M,9);break;case 1:Z=pt(M,-1);break;case 2:Z=pt(M,0);break;case 3:Z=pt(M,1)+6;break;case 4:Z=pt(M,z.ATHcurve);break;default:Z=pt(M,0);break}return Z}}var $z=Tz,Rz=Da;function Pz(){this.class_id=0,this.num_samples=0,this.num_channels=0,this.in_samplerate=0,this.out_samplerate=0,this.scale=0,this.scale_left=0,this.scale_right=0,this.analysis=!1,this.bWriteVbrTag=!1,this.decode_only=!1,this.quality=0,this.mode=Rz.STEREO,this.force_ms=!1,this.free_format=!1,this.findReplayGain=!1,this.decode_on_the_fly=!1,this.write_id3tag_automatic=!1,this.brate=0,this.compression_ratio=0,this.copyright=0,this.original=0,this.extension=0,this.emphasis=0,this.error_protection=0,this.strict_ISO=!1,this.disable_reservoir=!1,this.quant_comp=0,this.quant_comp_short=0,this.experimentalY=!1,this.experimentalZ=0,this.exp_nspsytune=0,this.preset=0,this.VBR=null,this.VBR_q_frac=0,this.VBR_q=0,this.VBR_mean_bitrate_kbps=0,this.VBR_min_bitrate_kbps=0,this.VBR_max_bitrate_kbps=0,this.VBR_hard_min=0,this.lowpassfreq=0,this.highpassfreq=0,this.lowpasswidth=0,this.highpasswidth=0,this.maskingadjust=0,this.maskingadjust_short=0,this.ATHonly=!1,this.ATHshort=!1,this.noATH=!1,this.ATHtype=0,this.ATHcurve=0,this.ATHlower=0,this.athaa_type=0,this.athaa_loudapprox=0,this.athaa_sensitivity=0,this.short_blocks=null,this.useTemporal=!1,this.interChRatio=0,this.msfix=0,this.tune=!1,this.tune_value_a=0,this.version=0,this.encoder_delay=0,this.encoder_padding=0,this.framesize=0,this.frameNum=0,this.lame_allocated_gfp=0,this.internal_flags=null}var Mz=Pz,zz=hr(),a3={};a3.SFBMAX=zz.SBMAX_s*3;var su=a3,c3=Zt,Iz=c3.new_float,uo=c3.new_int,Wm=su;function Oz(){this.xr=Iz(576),this.l3_enc=uo(576),this.scalefac=uo(Wm.SFBMAX),this.xrpow_max=0,this.part2_3_length=0,this.big_values=0,this.count1=0,this.global_gain=0,this.scalefac_compress=0,this.block_type=0,this.mixed_block_flag=0,this.table_select=uo(3),this.subblock_gain=uo(4),this.region0_count=0,this.region1_count=0,this.preflag=0,this.scalefac_scale=0,this.count1table_select=0,this.part2_length=0,this.sfb_lmax=0,this.sfb_smin=0,this.psy_lmax=0,this.sfbmax=0,this.psymax=0,this.sfbdivide=0,this.width=uo(Wm.SFBMAX),this.window=uo(Wm.SFBMAX),this.count1bits=0,this.sfb_partition_table=null,this.slen=uo(4),this.max_nonzero_coeff=0;var t=this;function e(n){return new Int32Array(n)}function r(n){return new Float32Array(n)}this.assign=function(n){t.xr=r(n.xr),t.l3_enc=e(n.l3_enc),t.scalefac=e(n.scalefac),t.xrpow_max=n.xrpow_max,t.part2_3_length=n.part2_3_length,t.big_values=n.big_values,t.count1=n.count1,t.global_gain=n.global_gain,t.scalefac_compress=n.scalefac_compress,t.block_type=n.block_type,t.mixed_block_flag=n.mixed_block_flag,t.table_select=e(n.table_select),t.subblock_gain=e(n.subblock_gain),t.region0_count=n.region0_count,t.region1_count=n.region1_count,t.preflag=n.preflag,t.scalefac_scale=n.scalefac_scale,t.count1table_select=n.count1table_select,t.part2_length=n.part2_length,t.sfb_lmax=n.sfb_lmax,t.sfb_smin=n.sfb_smin,t.psy_lmax=n.psy_lmax,t.sfbmax=n.sfbmax,t.psymax=n.psymax,t.sfbdivide=n.sfbdivide,t.width=e(n.width),t.window=e(n.window),t.count1bits=n.count1bits,t.sfb_partition_table=n.sfb_partition_table.slice(0),t.slen=e(n.slen),t.max_nonzero_coeff=n.max_nonzero_coeff}}var o1=Oz,Az=Zt,Mw=Az.new_int,Nz=o1;function Cz(){this.tt=[[null,null],[null,null]],this.main_data_begin=0,this.private_bits=0,this.resvDrain_pre=0,this.resvDrain_post=0,this.scfsi=[Mw(4),Mw(4)];for(var t=0;t<2;t++)for(var e=0;e<2;e++)this.tt[t][e]=new Nz}var jz=Cz,l3=Zt,Jl=l3.System,Ql=l3.new_int,eu=hr();function Dz(t,e,r,n){this.l=Ql(1+eu.SBMAX_l),this.s=Ql(1+eu.SBMAX_s),this.psfb21=Ql(1+eu.PSFB21),this.psfb12=Ql(1+eu.PSFB12);var s=this.l,o=this.s;arguments.length==4&&(this.arrL=arguments[0],this.arrS=arguments[1],this.arr21=arguments[2],this.arr12=arguments[3],Jl.arraycopy(this.arrL,0,s,0,Math.min(this.arrL.length,this.l.length)),Jl.arraycopy(this.arrS,0,o,0,Math.min(this.arrS.length,this.s.length)),Jl.arraycopy(this.arr21,0,this.psfb21,0,Math.min(this.arr21.length,this.psfb21.length)),Jl.arraycopy(this.arr12,0,this.psfb12,0,Math.min(this.arr12.length,this.psfb12.length)))}var u3=Dz,i1=Zt,Km=i1.new_float,Lz=i1.new_float_n,Zz=i1.new_int,zw=hr();function Bz(){this.last_en_subshort=Lz([4,9]),this.lastAttacks=Zz(4),this.pefirbuf=Km(19),this.longfact=Km(zw.SBMAX_l),this.shortfact=Km(zw.SBMAX_s),this.attackthre=0,this.attackthre_s=0}var qz=Bz;function Vz(){this.sum=0,this.seen=0,this.want=0,this.pos=0,this.size=0,this.bag=null,this.nVbrNumFrames=0,this.nBytesWritten=0,this.TotalFrameSize=0}var Fz=Vz,fi=Zt,Hz=fi.new_byte,Uz=fi.new_double,sn=fi.new_float,fo=fi.new_float_n,vn=fi.new_int,tu=fi.new_int_n,Gz=jz,Yz=u3,Xz=qz,Wz=Fz,Iw=o3(),qt=hr(),Kz=su;Fn.MFSIZE=3*1152+qt.ENCDELAY-qt.MDCTDELAY;Fn.MAX_HEADER_BUF=256;Fn.MAX_BITS_PER_CHANNEL=4095;Fn.MAX_BITS_PER_GRANULE=7680;Fn.BPC=320;function Fn(){var t=40;this.Class_ID=0,this.lame_encode_frame_init=0,this.iteration_init_init=0,this.fill_buffer_resample_init=0,this.mfbuf=fo([2,Fn.MFSIZE]),this.mode_gr=0,this.channels_in=0,this.channels_out=0,this.resample_ratio=0,this.mf_samples_to_encode=0,this.mf_size=0,this.VBR_min_bitrate=0,this.VBR_max_bitrate=0,this.bitrate_index=0,this.samplerate_index=0,this.mode_ext=0,this.lowpass1=0,this.lowpass2=0,this.highpass1=0,this.highpass2=0,this.noise_shaping=0,this.noise_shaping_amp=0,this.substep_shaping=0,this.psymodel=0,this.noise_shaping_stop=0,this.subblock_gain=0,this.use_best_huffman=0,this.full_outer_loop=0,this.l3_side=new Gz,this.ms_ratio=sn(2),this.padding=0,this.frac_SpF=0,this.slot_lag=0,this.tag_spec=null,this.nMusicCRC=0,this.OldValue=vn(2),this.CurrentStep=vn(2),this.masking_lower=0,this.bv_scf=vn(576),this.pseudohalf=vn(Kz.SFBMAX),this.sfb21_extra=!1,this.inbuf_old=new Array(2),this.blackfilt=new Array(2*Fn.BPC+1),this.itime=Uz(2),this.sideinfo_len=0,this.sb_sample=fo([2,2,18,qt.SBLIMIT]),this.amp_filter=sn(32);function e(){this.write_timing=0,this.ptr=0,this.buf=Hz(t)}this.header=new Array(Fn.MAX_HEADER_BUF),this.h_ptr=0,this.w_ptr=0,this.ancillary_flag=0,this.ResvSize=0,this.ResvMax=0,this.scalefac_band=new Yz,this.minval_l=sn(qt.CBANDS),this.minval_s=sn(qt.CBANDS),this.nb_1=fo([4,qt.CBANDS]),this.nb_2=fo([4,qt.CBANDS]),this.nb_s1=fo([4,qt.CBANDS]),this.nb_s2=fo([4,qt.CBANDS]),this.s3_ss=null,this.s3_ll=null,this.decay=0,this.thm=new Array(4),this.en=new Array(4),this.tot_ener=sn(4),this.loudness_sq=fo([2,2]),this.loudness_sq_save=sn(2),this.mld_l=sn(qt.SBMAX_l),this.mld_s=sn(qt.SBMAX_s),this.bm_l=vn(qt.SBMAX_l),this.bo_l=vn(qt.SBMAX_l),this.bm_s=vn(qt.SBMAX_s),this.bo_s=vn(qt.SBMAX_s),this.npart_l=0,this.npart_s=0,this.s3ind=tu([qt.CBANDS,2]),this.s3ind_s=tu([qt.CBANDS,2]),this.numlines_s=vn(qt.CBANDS),this.numlines_l=vn(qt.CBANDS),this.rnumlines_l=sn(qt.CBANDS),this.mld_cb_l=sn(qt.CBANDS),this.mld_cb_s=sn(qt.CBANDS),this.numlines_s_num1=0,this.numlines_l_num1=0,this.pe=sn(4),this.ms_ratio_s_old=0,this.ms_ratio_l_old=0,this.ms_ener_ratio_old=0,this.blocktype_old=vn(2),this.nsPsy=new Xz,this.VBR_seek_table=new Wz,this.ATH=null,this.PSY=null,this.nogap_total=0,this.nogap_current=0,this.decode_on_the_fly=!0,this.findReplayGain=!0,this.findPeakSample=!0,this.PeakSample=0,this.RadioGain=0,this.AudiophileGain=0,this.rgdata=null,this.noclipGainChange=0,this.noclipScale=0,this.bitrate_stereoMode_Hist=tu([16,5]),this.bitrate_blockType_Hist=tu([16,6]),this.pinfo=null,this.hip=null,this.in_buffer_nsamples=0,this.in_buffer_0=null,this.in_buffer_1=null,this.iteration_loop=null;for(var r=0;r<this.en.length;r++)this.en[r]=new Iw;for(var r=0;r<this.thm.length;r++)this.thm[r]=new Iw;for(var r=0;r<this.header.length;r++)this.header[r]=new e}var ou=Fn,Jz=Zt,ho=Jz.new_float,po=hr();function Qz(){this.useAdjust=0,this.aaSensitivityP=0,this.adjust=0,this.adjustLimit=0,this.decay=0,this.floor=0,this.l=ho(po.SBMAX_l),this.s=ho(po.SBMAX_s),this.psfb21=ho(po.PSFB21),this.psfb12=ho(po.PSFB12),this.cb_l=ho(po.CBANDS),this.cb_s=ho(po.CBANDS),this.eql_w=ho(po.BLKSIZE/2)}var eI=Qz,d3=Zt,zr=d3.System,Ow=d3.Arrays;Vt.STEPS_per_dB=100;Vt.MAX_dB=120;Vt.GAIN_NOT_ENOUGH_SAMPLES=-24601;Vt.GAIN_ANALYSIS_ERROR=0;Vt.GAIN_ANALYSIS_OK=1;Vt.INIT_GAIN_ANALYSIS_ERROR=0;Vt.INIT_GAIN_ANALYSIS_OK=1;Vt.YULE_ORDER=10;Vt.MAX_ORDER=Vt.YULE_ORDER;Vt.MAX_SAMP_FREQ=48e3;Vt.RMS_WINDOW_TIME_NUMERATOR=1;Vt.RMS_WINDOW_TIME_DENOMINATOR=20;Vt.MAX_SAMPLES_PER_WINDOW=Vt.MAX_SAMP_FREQ*Vt.RMS_WINDOW_TIME_NUMERATOR/Vt.RMS_WINDOW_TIME_DENOMINATOR+1;function Vt(){var t=64.82,e=.95,r=Vt.RMS_WINDOW_TIME_NUMERATOR,n=Vt.RMS_WINDOW_TIME_DENOMINATOR,s=[[.038575994352,-3.84664617118067,-.02160367184185,7.81501653005538,-.00123395316851,-11.34170355132042,-9291677959e-14,13.05504219327545,-.01655260341619,-12.28759895145294,.02161526843274,9.4829380631979,-.02074045215285,-5.87257861775999,.00594298065125,2.75465861874613,.00306428023191,-.86984376593551,.00012025322027,.13919314567432,.00288463683916],[.0541865640643,-3.47845948550071,-.02911007808948,6.36317777566148,-.00848709379851,-8.54751527471874,-.00851165645469,9.4769360780128,-.00834990904936,-8.81498681370155,.02245293253339,6.85401540936998,-.02596338512915,-4.39470996079559,.01624864962975,2.19611684890774,-.00240879051584,-.75104302451432,.00674613682247,.13149317958808,-.00187763777362],[.15457299681924,-2.37898834973084,-.09331049056315,2.84868151156327,-.06247880153653,-2.64577170229825,.02163541888798,2.23697657451713,-.05588393329856,-1.67148153367602,.04781476674921,1.00595954808547,.00222312597743,-.45953458054983,.03174092540049,.16378164858596,-.01390589421898,-.05032077717131,.00651420667831,.0234789740702,-.00881362733839],[.30296907319327,-1.61273165137247,-.22613988682123,1.0797749225997,-.08587323730772,-.2565625775407,.03282930172664,-.1627671912044,-.00915702933434,-.22638893773906,-.02364141202522,.39120800788284,-.00584456039913,-.22138138954925,.06276101321749,.04500235387352,-828086748e-14,.02005851806501,.00205861885564,.00302439095741,-.02950134983287],[.33642304856132,-1.49858979367799,-.2557224142557,.87350271418188,-.11828570177555,.12205022308084,.11921148675203,-.80774944671438,-.07834489609479,.47854794562326,-.0046997791438,-.12453458140019,-.0058950022444,-.04067510197014,.05724228140351,.08333755284107,.00832043980773,-.04237348025746,-.0163538138454,.02977207319925,-.0176017656815],[.4491525660845,-.62820619233671,-.14351757464547,.29661783706366,-.22784394429749,-.372563729424,-.01419140100551,.00213767857124,.04078262797139,-.42029820170918,-.12398163381748,.22199650564824,.04097565135648,.00613424350682,.10478503600251,.06747620744683,-.01863887810927,.05784820375801,-.03193428438915,.03222754072173,.00541907748707],[.56619470757641,-1.04800335126349,-.75464456939302,.29156311971249,.1624213774223,-.26806001042947,.16744243493672,.00819999645858,-.18901604199609,.45054734505008,.3093178284183,-.33032403314006,-.27562961986224,.0673936833311,.00647310677246,-.04784254229033,.08647503780351,.01639907836189,-.0378898455484,.01807364323573,-.00588215443421],[.58100494960553,-.51035327095184,-.53174909058578,-.31863563325245,-.14289799034253,-.20256413484477,.17520704835522,.1472815413433,.02377945217615,.38952639978999,.15558449135573,-.23313271880868,-.25344790059353,-.05246019024463,.01628462406333,-.02505961724053,.06920467763959,.02442357316099,-.03721611395801,.01818801111503,-.00749618797172],[.53648789255105,-.2504987195602,-.42163034350696,-.43193942311114,-.00275953611929,-.03424681017675,.04267842219415,-.04678328784242,-.10214864179676,.26408300200955,.14590772289388,.15113130533216,-.02459864859345,-.17556493366449,-.11202315195388,-.18823009262115,-.04060034127,.05477720428674,.0478866554818,.0470440968812,-.02217936801134]],o=[[.98621192462708,-1.97223372919527,-1.97242384925416,.97261396931306,.98621192462708],[.98500175787242,-1.96977855582618,-1.97000351574484,.9702284756635,.98500175787242],[.97938932735214,-1.95835380975398,-1.95877865470428,.95920349965459,.97938932735214],[.97531843204928,-1.95002759149878,-1.95063686409857,.95124613669835,.97531843204928],[.97316523498161,-1.94561023566527,-1.94633046996323,.94705070426118,.97316523498161],[.96454515552826,-1.92783286977036,-1.92909031105652,.93034775234268,.96454515552826],[.96009142950541,-1.91858953033784,-1.92018285901082,.92177618768381,.96009142950541],[.95856916599601,-1.9154210807478,-1.91713833199203,.91885558323625,.95856916599601],[.94597685600279,-1.88903307939452,-1.89195371200558,.89487434461664,.94597685600279]];function i(u,h,p,g,x,S){for(;x--!=0;)p[g]=1e-10+u[h+0]*S[0]-p[g-1]*S[1]+u[h-1]*S[2]-p[g-2]*S[3]+u[h-2]*S[4]-p[g-3]*S[5]+u[h-3]*S[6]-p[g-4]*S[7]+u[h-4]*S[8]-p[g-5]*S[9]+u[h-5]*S[10]-p[g-6]*S[11]+u[h-6]*S[12]-p[g-7]*S[13]+u[h-7]*S[14]-p[g-8]*S[15]+u[h-8]*S[16]-p[g-9]*S[17]+u[h-9]*S[18]-p[g-10]*S[19]+u[h-10]*S[20],++g,++h}function a(u,h,p,g,x,S){for(;x--!=0;)p[g]=u[h+0]*S[0]-p[g-1]*S[1]+u[h-1]*S[2]-p[g-2]*S[3]+u[h-2]*S[4],++g,++h}function c(u,h){for(var p=0;p<MAX_ORDER;p++)u.linprebuf[p]=u.lstepbuf[p]=u.loutbuf[p]=u.rinprebuf[p]=u.rstepbuf[p]=u.routbuf[p]=0;switch(0|h){case 48e3:u.reqindex=0;break;case 44100:u.reqindex=1;break;case 32e3:u.reqindex=2;break;case 24e3:u.reqindex=3;break;case 22050:u.reqindex=4;break;case 16e3:u.reqindex=5;break;case 12e3:u.reqindex=6;break;case 11025:u.reqindex=7;break;case 8e3:u.reqindex=8;break;default:return INIT_GAIN_ANALYSIS_ERROR}return u.sampleWindow=0|(h*r+n-1)/n,u.lsum=0,u.rsum=0,u.totsamp=0,Ow.ill(u.A,0),INIT_GAIN_ANALYSIS_OK}this.InitGainAnalysis=function(u,h){return c(u,h)!=INIT_GAIN_ANALYSIS_OK?INIT_GAIN_ANALYSIS_ERROR:(u.linpre=MAX_ORDER,u.rinpre=MAX_ORDER,u.lstep=MAX_ORDER,u.rstep=MAX_ORDER,u.lout=MAX_ORDER,u.rout=MAX_ORDER,Ow.fill(u.B,0),INIT_GAIN_ANALYSIS_OK)};function d(u){return u*u}this.AnalyzeSamples=function(u,h,p,g,x,S,k){var _,m,$,f,E,N,B;if(S==0)return GAIN_ANALYSIS_OK;switch(B=0,E=S,k){case 1:g=h,x=p;break;case 2:break;default:return GAIN_ANALYSIS_ERROR}for(S<MAX_ORDER?(zr.arraycopy(h,p,u.linprebuf,MAX_ORDER,S),zr.arraycopy(g,x,u.rinprebuf,MAX_ORDER,S)):(zr.arraycopy(h,p,u.linprebuf,MAX_ORDER,MAX_ORDER),zr.arraycopy(g,x,u.rinprebuf,MAX_ORDER,MAX_ORDER));E>0;){N=E>u.sampleWindow-u.totsamp?u.sampleWindow-u.totsamp:E,B<MAX_ORDER?(_=u.linpre+B,m=u.linprebuf,$=u.rinpre+B,f=u.rinprebuf,N>MAX_ORDER-B&&(N=MAX_ORDER-B)):(_=p+B,m=h,$=x+B,f=g),i(m,_,u.lstepbuf,u.lstep+u.totsamp,N,s[u.reqindex]),i(f,$,u.rstepbuf,u.rstep+u.totsamp,N,s[u.reqindex]),a(u.lstepbuf,u.lstep+u.totsamp,u.loutbuf,u.lout+u.totsamp,N,o[u.reqindex]),a(u.rstepbuf,u.rstep+u.totsamp,u.routbuf,u.rout+u.totsamp,N,o[u.reqindex]),_=u.lout+u.totsamp,m=u.loutbuf,$=u.rout+u.totsamp,f=u.routbuf;for(var U=N%8;U--!=0;)u.lsum+=d(m[_++]),u.rsum+=d(f[$++]);for(U=N/8;U--!=0;)u.lsum+=d(m[_+0])+d(m[_+1])+d(m[_+2])+d(m[_+3])+d(m[_+4])+d(m[_+5])+d(m[_+6])+d(m[_+7]),_+=8,u.rsum+=d(f[$+0])+d(f[$+1])+d(f[$+2])+d(f[$+3])+d(f[$+4])+d(f[$+5])+d(f[$+6])+d(f[$+7]),$+=8;if(E-=N,B+=N,u.totsamp+=N,u.totsamp==u.sampleWindow){var C=Vt.STEPS_per_dB*10*Math.log10((u.lsum+u.rsum)/u.totsamp*.5+1e-37),q=C<=0?0:0|C;q>=u.A.length&&(q=u.A.length-1),u.A[q]++,u.lsum=u.rsum=0,zr.arraycopy(u.loutbuf,u.totsamp,u.loutbuf,0,MAX_ORDER),zr.arraycopy(u.routbuf,u.totsamp,u.routbuf,0,MAX_ORDER),zr.arraycopy(u.lstepbuf,u.totsamp,u.lstepbuf,0,MAX_ORDER),zr.arraycopy(u.rstepbuf,u.totsamp,u.rstepbuf,0,MAX_ORDER),u.totsamp=0}if(u.totsamp>u.sampleWindow)return GAIN_ANALYSIS_ERROR}return S<MAX_ORDER?(zr.arraycopy(u.linprebuf,S,u.linprebuf,0,MAX_ORDER-S),zr.arraycopy(u.rinprebuf,S,u.rinprebuf,0,MAX_ORDER-S),zr.arraycopy(h,p,u.linprebuf,MAX_ORDER-S,S),zr.arraycopy(g,x,u.rinprebuf,MAX_ORDER-S,S)):(zr.arraycopy(h,p+S-MAX_ORDER,u.linprebuf,0,MAX_ORDER),zr.arraycopy(g,x+S-MAX_ORDER,u.rinprebuf,0,MAX_ORDER)),GAIN_ANALYSIS_OK};function l(u,h){var p,g=0;for(p=0;p<h;p++)g+=u[p];if(g==0)return GAIN_NOT_ENOUGH_SAMPLES;var x=0|Math.ceil(g*(1-e));for(p=h;p-- >0&&!((x-=u[p])<=0););return t-p/Vt.STEPS_per_dB}this.GetTitleGain=function(u){for(var h=l(u.A,u.A.length),p=0;p<u.A.length;p++)u.B[p]+=u.A[p],u.A[p]=0;for(var p=0;p<MAX_ORDER;p++)u.linprebuf[p]=u.lstepbuf[p]=u.loutbuf[p]=u.rinprebuf[p]=u.rstepbuf[p]=u.routbuf[p]=0;return u.totsamp=0,u.lsum=u.rsum=0,h}}var f3=Vt,h3=Zt,ui=h3.new_float,Aw=h3.new_int,Ir=f3;function tI(){this.linprebuf=ui(Ir.MAX_ORDER*2),this.linpre=0,this.lstepbuf=ui(Ir.MAX_SAMPLES_PER_WINDOW+Ir.MAX_ORDER),this.lstep=0,this.loutbuf=ui(Ir.MAX_SAMPLES_PER_WINDOW+Ir.MAX_ORDER),this.lout=0,this.rinprebuf=ui(Ir.MAX_ORDER*2),this.rinpre=0,this.rstepbuf=ui(Ir.MAX_SAMPLES_PER_WINDOW+Ir.MAX_ORDER),this.rstep=0,this.routbuf=ui(Ir.MAX_SAMPLES_PER_WINDOW+Ir.MAX_ORDER),this.rout=0,this.sampleWindow=0,this.totsamp=0,this.lsum=0,this.rsum=0,this.freqindex=0,this.first=0,this.A=Aw(0|Ir.STEPS_per_dB*Ir.MAX_dB),this.B=Aw(0|Ir.STEPS_per_dB*Ir.MAX_dB)}var rI=tI;function nI(t){this.bits=t}var p3=nI,a1=Zt,Nw=a1.new_float,sI=a1.new_int,Cw=a1.assert,oI=p3,jw=hr(),iI=su,aI=ou;function cI(t){var e=t;this.quantize=e,this.iteration_loop=function(r,n,s,o){var i=r.internal_flags,a=Nw(iI.SFBMAX),c=Nw(576),d=sI(2),l=0,u,h=i.l3_side,p=new oI(l);this.quantize.rv.ResvFrameBegin(r,p),l=p.bits;for(var g=0;g<i.mode_gr;g++){u=this.quantize.qupvt.on_pe(r,n,d,l,g,g),i.mode_ext==jw.MPG_MD_MS_LR&&(this.quantize.ms_convert(i.l3_side,g),this.quantize.qupvt.reduce_side(d,s[g],l,u));for(var x=0;x<i.channels_out;x++){var S,k,_=h.tt[g][x];_.block_type!=jw.SHORT_TYPE?(S=0,k=i.PSY.mask_adjust-S):(S=0,k=i.PSY.mask_adjust_short-S),i.masking_lower=Math.pow(10,k*.1),this.quantize.init_outer_loop(i,_),this.quantize.init_xrpow(i,_,c)&&(this.quantize.qupvt.calc_xmin(r,o[g][x],_,a),this.quantize.outer_loop(r,_,a,c,x,d[x])),this.quantize.iteration_finish_one(i,g,x),Cw(_.part2_3_length<=aI.MAX_BITS_PER_CHANNEL),Cw(_.part2_3_length<=d[x])}}this.quantize.rv.ResvFrameEnd(i,l)}}var lI=cI;function _t(t,e,r,n){this.xlen=t,this.linmax=e,this.table=r,this.hlen=n}var me={};me.t1HB=[1,1,1,0];me.t2HB=[1,2,1,3,1,1,3,2,0];me.t3HB=[3,2,1,1,1,1,3,2,0];me.t5HB=[1,2,6,5,3,1,4,4,7,5,7,1,6,1,1,0];me.t6HB=[7,3,5,1,6,2,3,2,5,4,4,1,3,3,2,0];me.t7HB=[1,2,10,19,16,10,3,3,7,10,5,3,11,4,13,17,8,4,12,11,18,15,11,2,7,6,9,14,3,1,6,4,5,3,2,0];me.t8HB=[3,4,6,18,12,5,5,1,2,16,9,3,7,3,5,14,7,3,19,17,15,13,10,4,13,5,8,11,5,1,12,4,4,1,1,0];me.t9HB=[7,5,9,14,15,7,6,4,5,5,6,7,7,6,8,8,8,5,15,6,9,10,5,1,11,7,9,6,4,1,14,4,6,2,6,0];me.t10HB=[1,2,10,23,35,30,12,17,3,3,8,12,18,21,12,7,11,9,15,21,32,40,19,6,14,13,22,34,46,23,18,7,20,19,33,47,27,22,9,3,31,22,41,26,21,20,5,3,14,13,10,11,16,6,5,1,9,8,7,8,4,4,2,0];me.t11HB=[3,4,10,24,34,33,21,15,5,3,4,10,32,17,11,10,11,7,13,18,30,31,20,5,25,11,19,59,27,18,12,5,35,33,31,58,30,16,7,5,28,26,32,19,17,15,8,14,14,12,9,13,14,9,4,1,11,4,6,6,6,3,2,0];me.t12HB=[9,6,16,33,41,39,38,26,7,5,6,9,23,16,26,11,17,7,11,14,21,30,10,7,17,10,15,12,18,28,14,5,32,13,22,19,18,16,9,5,40,17,31,29,17,13,4,2,27,12,11,15,10,7,4,1,27,12,8,12,6,3,1,0];me.t13HB=[1,5,14,21,34,51,46,71,42,52,68,52,67,44,43,19,3,4,12,19,31,26,44,33,31,24,32,24,31,35,22,14,15,13,23,36,59,49,77,65,29,40,30,40,27,33,42,16,22,20,37,61,56,79,73,64,43,76,56,37,26,31,25,14,35,16,60,57,97,75,114,91,54,73,55,41,48,53,23,24,58,27,50,96,76,70,93,84,77,58,79,29,74,49,41,17,47,45,78,74,115,94,90,79,69,83,71,50,59,38,36,15,72,34,56,95,92,85,91,90,86,73,77,65,51,44,43,42,43,20,30,44,55,78,72,87,78,61,46,54,37,30,20,16,53,25,41,37,44,59,54,81,66,76,57,54,37,18,39,11,35,33,31,57,42,82,72,80,47,58,55,21,22,26,38,22,53,25,23,38,70,60,51,36,55,26,34,23,27,14,9,7,34,32,28,39,49,75,30,52,48,40,52,28,18,17,9,5,45,21,34,64,56,50,49,45,31,19,12,15,10,7,6,3,48,23,20,39,36,35,53,21,16,23,13,10,6,1,4,2,16,15,17,27,25,20,29,11,17,12,16,8,1,1,0,1];me.t15HB=[7,12,18,53,47,76,124,108,89,123,108,119,107,81,122,63,13,5,16,27,46,36,61,51,42,70,52,83,65,41,59,36,19,17,15,24,41,34,59,48,40,64,50,78,62,80,56,33,29,28,25,43,39,63,55,93,76,59,93,72,54,75,50,29,52,22,42,40,67,57,95,79,72,57,89,69,49,66,46,27,77,37,35,66,58,52,91,74,62,48,79,63,90,62,40,38,125,32,60,56,50,92,78,65,55,87,71,51,73,51,70,30,109,53,49,94,88,75,66,122,91,73,56,42,64,44,21,25,90,43,41,77,73,63,56,92,77,66,47,67,48,53,36,20,71,34,67,60,58,49,88,76,67,106,71,54,38,39,23,15,109,53,51,47,90,82,58,57,48,72,57,41,23,27,62,9,86,42,40,37,70,64,52,43,70,55,42,25,29,18,11,11,118,68,30,55,50,46,74,65,49,39,24,16,22,13,14,7,91,44,39,38,34,63,52,45,31,52,28,19,14,8,9,3,123,60,58,53,47,43,32,22,37,24,17,12,15,10,2,1,71,37,34,30,28,20,17,26,21,16,10,6,8,6,2,0];me.t16HB=[1,5,14,44,74,63,110,93,172,149,138,242,225,195,376,17,3,4,12,20,35,62,53,47,83,75,68,119,201,107,207,9,15,13,23,38,67,58,103,90,161,72,127,117,110,209,206,16,45,21,39,69,64,114,99,87,158,140,252,212,199,387,365,26,75,36,68,65,115,101,179,164,155,264,246,226,395,382,362,9,66,30,59,56,102,185,173,265,142,253,232,400,388,378,445,16,111,54,52,100,184,178,160,133,257,244,228,217,385,366,715,10,98,48,91,88,165,157,148,261,248,407,397,372,380,889,884,8,85,84,81,159,156,143,260,249,427,401,392,383,727,713,708,7,154,76,73,141,131,256,245,426,406,394,384,735,359,710,352,11,139,129,67,125,247,233,229,219,393,743,737,720,885,882,439,4,243,120,118,115,227,223,396,746,742,736,721,712,706,223,436,6,202,224,222,218,216,389,386,381,364,888,443,707,440,437,1728,4,747,211,210,208,370,379,734,723,714,1735,883,877,876,3459,865,2,377,369,102,187,726,722,358,711,709,866,1734,871,3458,870,434,0,12,10,7,11,10,17,11,9,13,12,10,7,5,3,1,3];me.t24HB=[15,13,46,80,146,262,248,434,426,669,653,649,621,517,1032,88,14,12,21,38,71,130,122,216,209,198,327,345,319,297,279,42,47,22,41,74,68,128,120,221,207,194,182,340,315,295,541,18,81,39,75,70,134,125,116,220,204,190,178,325,311,293,271,16,147,72,69,135,127,118,112,210,200,188,352,323,306,285,540,14,263,66,129,126,119,114,214,202,192,180,341,317,301,281,262,12,249,123,121,117,113,215,206,195,185,347,330,308,291,272,520,10,435,115,111,109,211,203,196,187,353,332,313,298,283,531,381,17,427,212,208,205,201,193,186,177,169,320,303,286,268,514,377,16,335,199,197,191,189,181,174,333,321,305,289,275,521,379,371,11,668,184,183,179,175,344,331,314,304,290,277,530,383,373,366,10,652,346,171,168,164,318,309,299,287,276,263,513,375,368,362,6,648,322,316,312,307,302,292,284,269,261,512,376,370,364,359,4,620,300,296,294,288,282,273,266,515,380,374,369,365,361,357,2,1033,280,278,274,267,264,259,382,378,372,367,363,360,358,356,0,43,20,19,17,15,13,11,9,7,6,4,7,5,3,1,3];me.t32HB=[1,10,8,20,12,20,16,32,14,12,24,0,28,16,24,16];me.t33HB=[15,28,26,48,22,40,36,64,14,24,20,32,12,16,8,0];me.t1l=[1,4,3,5];me.t2l=[1,4,7,4,5,7,6,7,8];me.t3l=[2,3,7,4,4,7,6,7,8];me.t5l=[1,4,7,8,4,5,8,9,7,8,9,10,8,8,9,10];me.t6l=[3,4,6,8,4,4,6,7,5,6,7,8,7,7,8,9];me.t7l=[1,4,7,9,9,10,4,6,8,9,9,10,7,7,9,10,10,11,8,9,10,11,11,11,8,9,10,11,11,12,9,10,11,12,12,12];me.t8l=[2,4,7,9,9,10,4,4,6,10,10,10,7,6,8,10,10,11,9,10,10,11,11,12,9,9,10,11,12,12,10,10,11,11,13,13];me.t9l=[3,4,6,7,9,10,4,5,6,7,8,10,5,6,7,8,9,10,7,7,8,9,9,10,8,8,9,9,10,11,9,9,10,10,11,11];me.t10l=[1,4,7,9,10,10,10,11,4,6,8,9,10,11,10,10,7,8,9,10,11,12,11,11,8,9,10,11,12,12,11,12,9,10,11,12,12,12,12,12,10,11,12,12,13,13,12,13,9,10,11,12,12,12,13,13,10,10,11,12,12,13,13,13];me.t11l=[2,4,6,8,9,10,9,10,4,5,6,8,10,10,9,10,6,7,8,9,10,11,10,10,8,8,9,11,10,12,10,11,9,10,10,11,11,12,11,12,9,10,11,12,12,13,12,13,9,9,9,10,11,12,12,12,9,9,10,11,12,12,12,12];me.t12l=[4,4,6,8,9,10,10,10,4,5,6,7,9,9,10,10,6,6,7,8,9,10,9,10,7,7,8,8,9,10,10,10,8,8,9,9,10,10,10,11,9,9,10,10,10,11,10,11,9,9,9,10,10,11,11,12,10,10,10,11,11,11,11,12];me.t13l=[1,5,7,8,9,10,10,11,10,11,12,12,13,13,14,14,4,6,8,9,10,10,11,11,11,11,12,12,13,14,14,14,7,8,9,10,11,11,12,12,11,12,12,13,13,14,15,15,8,9,10,11,11,12,12,12,12,13,13,13,13,14,15,15,9,9,11,11,12,12,13,13,12,13,13,14,14,15,15,16,10,10,11,12,12,12,13,13,13,13,14,13,15,15,16,16,10,11,12,12,13,13,13,13,13,14,14,14,15,15,16,16,11,11,12,13,13,13,14,14,14,14,15,15,15,16,18,18,10,10,11,12,12,13,13,14,14,14,14,15,15,16,17,17,11,11,12,12,13,13,13,15,14,15,15,16,16,16,18,17,11,12,12,13,13,14,14,15,14,15,16,15,16,17,18,19,12,12,12,13,14,14,14,14,15,15,15,16,17,17,17,18,12,13,13,14,14,15,14,15,16,16,17,17,17,18,18,18,13,13,14,15,15,15,16,16,16,16,16,17,18,17,18,18,14,14,14,15,15,15,17,16,16,19,17,17,17,19,18,18,13,14,15,16,16,16,17,16,17,17,18,18,21,20,21,18];me.t15l=[3,5,6,8,8,9,10,10,10,11,11,12,12,12,13,14,5,5,7,8,9,9,10,10,10,11,11,12,12,12,13,13,6,7,7,8,9,9,10,10,10,11,11,12,12,13,13,13,7,8,8,9,9,10,10,11,11,11,12,12,12,13,13,13,8,8,9,9,10,10,11,11,11,11,12,12,12,13,13,13,9,9,9,10,10,10,11,11,11,11,12,12,13,13,13,14,10,9,10,10,10,11,11,11,11,12,12,12,13,13,14,14,10,10,10,11,11,11,11,12,12,12,12,12,13,13,13,14,10,10,10,11,11,11,11,12,12,12,12,13,13,14,14,14,10,10,11,11,11,11,12,12,12,13,13,13,13,14,14,14,11,11,11,11,12,12,12,12,12,13,13,13,13,14,15,14,11,11,11,11,12,12,12,12,13,13,13,13,14,14,14,15,12,12,11,12,12,12,13,13,13,13,13,13,14,14,15,15,12,12,12,12,12,13,13,13,13,14,14,14,14,14,15,15,13,13,13,13,13,13,13,13,14,14,14,14,15,15,14,15,13,13,13,13,13,13,13,14,14,14,14,14,15,15,15,15];me.t16_5l=[1,5,7,9,10,10,11,11,12,12,12,13,13,13,14,11,4,6,8,9,10,11,11,11,12,12,12,13,14,13,14,11,7,8,9,10,11,11,12,12,13,12,13,13,13,14,14,12,9,9,10,11,11,12,12,12,13,13,14,14,14,15,15,13,10,10,11,11,12,12,13,13,13,14,14,14,15,15,15,12,10,10,11,11,12,13,13,14,13,14,14,15,15,15,16,13,11,11,11,12,13,13,13,13,14,14,14,14,15,15,16,13,11,11,12,12,13,13,13,14,14,15,15,15,15,17,17,13,11,12,12,13,13,13,14,14,15,15,15,15,16,16,16,13,12,12,12,13,13,14,14,15,15,15,15,16,15,16,15,14,12,13,12,13,14,14,14,14,15,16,16,16,17,17,16,13,13,13,13,13,14,14,15,16,16,16,16,16,16,15,16,14,13,14,14,14,14,15,15,15,15,17,16,16,16,16,18,14,15,14,14,14,15,15,16,16,16,18,17,17,17,19,17,14,14,15,13,14,16,16,15,16,16,17,18,17,19,17,16,14,11,11,11,12,12,13,13,13,14,14,14,14,14,14,14,12];me.t16l=[1,5,7,9,10,10,11,11,12,12,12,13,13,13,14,10,4,6,8,9,10,11,11,11,12,12,12,13,14,13,14,10,7,8,9,10,11,11,12,12,13,12,13,13,13,14,14,11,9,9,10,11,11,12,12,12,13,13,14,14,14,15,15,12,10,10,11,11,12,12,13,13,13,14,14,14,15,15,15,11,10,10,11,11,12,13,13,14,13,14,14,15,15,15,16,12,11,11,11,12,13,13,13,13,14,14,14,14,15,15,16,12,11,11,12,12,13,13,13,14,14,15,15,15,15,17,17,12,11,12,12,13,13,13,14,14,15,15,15,15,16,16,16,12,12,12,12,13,13,14,14,15,15,15,15,16,15,16,15,13,12,13,12,13,14,14,14,14,15,16,16,16,17,17,16,12,13,13,13,13,14,14,15,16,16,16,16,16,16,15,16,13,13,14,14,14,14,15,15,15,15,17,16,16,16,16,18,13,15,14,14,14,15,15,16,16,16,18,17,17,17,19,17,13,14,15,13,14,16,16,15,16,16,17,18,17,19,17,16,13,10,10,10,11,11,12,12,12,13,13,13,13,13,13,13,10];me.t24l=[4,5,7,8,9,10,10,11,11,12,12,12,12,12,13,10,5,6,7,8,9,10,10,11,11,11,12,12,12,12,12,10,7,7,8,9,9,10,10,11,11,11,11,12,12,12,13,9,8,8,9,9,10,10,10,11,11,11,11,12,12,12,12,9,9,9,9,10,10,10,10,11,11,11,12,12,12,12,13,9,10,9,10,10,10,10,11,11,11,11,12,12,12,12,12,9,10,10,10,10,10,11,11,11,11,12,12,12,12,12,13,9,11,10,10,10,11,11,11,11,12,12,12,12,12,13,13,10,11,11,11,11,11,11,11,11,11,12,12,12,12,13,13,10,11,11,11,11,11,11,11,12,12,12,12,12,13,13,13,10,12,11,11,11,11,12,12,12,12,12,12,13,13,13,13,10,12,12,11,11,11,12,12,12,12,12,12,13,13,13,13,10,12,12,12,12,12,12,12,12,12,12,13,13,13,13,13,10,12,12,12,12,12,12,12,12,13,13,13,13,13,13,13,10,13,12,12,12,12,12,12,13,13,13,13,13,13,13,13,10,9,9,9,9,9,9,9,9,9,9,9,10,10,10,10,6];me.t32l=[1,5,5,7,5,8,7,9,5,7,7,9,7,9,9,10];me.t33l=[4,5,5,6,5,6,6,7,5,6,6,7,6,7,7,8];me.ht=[new _t(0,0,null,null),new _t(2,0,me.t1HB,me.t1l),new _t(3,0,me.t2HB,me.t2l),new _t(3,0,me.t3HB,me.t3l),new _t(0,0,null,null),new _t(4,0,me.t5HB,me.t5l),new _t(4,0,me.t6HB,me.t6l),new _t(6,0,me.t7HB,me.t7l),new _t(6,0,me.t8HB,me.t8l),new _t(6,0,me.t9HB,me.t9l),new _t(8,0,me.t10HB,me.t10l),new _t(8,0,me.t11HB,me.t11l),new _t(8,0,me.t12HB,me.t12l),new _t(16,0,me.t13HB,me.t13l),new _t(0,0,null,me.t16_5l),new _t(16,0,me.t15HB,me.t15l),new _t(1,1,me.t16HB,me.t16l),new _t(2,3,me.t16HB,me.t16l),new _t(3,7,me.t16HB,me.t16l),new _t(4,15,me.t16HB,me.t16l),new _t(6,63,me.t16HB,me.t16l),new _t(8,255,me.t16HB,me.t16l),new _t(10,1023,me.t16HB,me.t16l),new _t(13,8191,me.t16HB,me.t16l),new _t(4,15,me.t24HB,me.t24l),new _t(5,31,me.t24HB,me.t24l),new _t(6,63,me.t24HB,me.t24l),new _t(7,127,me.t24HB,me.t24l),new _t(8,255,me.t24HB,me.t24l),new _t(9,511,me.t24HB,me.t24l),new _t(11,2047,me.t24HB,me.t24l),new _t(13,8191,me.t24HB,me.t24l),new _t(0,0,me.t32HB,me.t32l),new _t(0,0,me.t33HB,me.t33l)];me.largetbl=[65540,327685,458759,589832,655369,655370,720906,720907,786443,786444,786444,851980,851980,851980,917517,655370,262149,393222,524295,589832,655369,720906,720906,720907,786443,786443,786444,851980,917516,851980,917516,655370,458759,524295,589832,655369,720905,720906,786442,786443,851979,786443,851979,851980,851980,917516,917517,720905,589832,589832,655369,720905,720906,786442,786442,786443,851979,851979,917515,917516,917516,983052,983052,786441,655369,655369,720905,720906,786442,786442,851978,851979,851979,917515,917516,917516,983052,983052,983053,720905,655370,655369,720906,720906,786442,851978,851979,917515,851979,917515,917516,983052,983052,983052,1048588,786441,720906,720906,720906,786442,851978,851979,851979,851979,917515,917516,917516,917516,983052,983052,1048589,786441,720907,720906,786442,786442,851979,851979,851979,917515,917516,983052,983052,983052,983052,1114125,1114125,786442,720907,786443,786443,851979,851979,851979,917515,917515,983051,983052,983052,983052,1048588,1048589,1048589,786442,786443,786443,786443,851979,851979,917515,917515,983052,983052,983052,983052,1048588,983053,1048589,983053,851978,786444,851979,786443,851979,917515,917516,917516,917516,983052,1048588,1048588,1048589,1114125,1114125,1048589,786442,851980,851980,851979,851979,917515,917516,983052,1048588,1048588,1048588,1048588,1048589,1048589,983053,1048589,851978,851980,917516,917516,917516,917516,983052,983052,983052,983052,1114124,1048589,1048589,1048589,1048589,1179661,851978,983052,917516,917516,917516,983052,983052,1048588,1048588,1048589,1179661,1114125,1114125,1114125,1245197,1114125,851978,917517,983052,851980,917516,1048588,1048588,983052,1048589,1048589,1114125,1179661,1114125,1245197,1114125,1048589,851978,655369,655369,655369,720905,720905,786441,786441,786441,851977,851977,851977,851978,851978,851978,851978,655366];me.table23=[65538,262147,458759,262148,327684,458759,393222,458759,524296];me.table56=[65539,262148,458758,524296,262148,327684,524294,589831,458757,524294,589831,655368,524295,524295,589832,655369];me.bitrate_table=[[0,8,16,24,32,40,48,56,64,80,96,112,128,144,160,-1],[0,32,40,48,56,64,80,96,112,128,160,192,224,256,320,-1],[0,8,16,24,32,40,48,56,64,-1,-1,-1,-1,-1,-1,-1]];me.samplerate_table=[[22050,24e3,16e3,-1],[44100,48e3,32e3,-1],[11025,12e3,8e3,-1]];me.scfsi_band=[0,6,11,16,21];var c1=me,Jm,Dw;function m3(){if(Dw)return Jm;Dw=1;var t=u3,e=Zt,r=e.VbrMode,n=e.Float,s=e.Util,o=e.new_float,i=e.new_int,a=e.assert,c=hr(),d=p3,l=ou;u.Q_MAX=257,u.Q_MAX2=116,u.LARGE_BITS=1e5,u.IXMAX_VAL=8206;function u(){var h=l1(),p=null,g=null,x=null;this.setModules=function(D,I,Y){p=D,g=I,x=Y};function S(D){return a(0<=D+u.Q_MAX2&&D<u.Q_MAX),B[D+u.Q_MAX2]}this.IPOW20=function(D){return a(0<=D&&D<u.Q_MAX),U[D]};var k=2220446049250313e-31,_=u.IXMAX_VAL,m=_+2,$=u.Q_MAX,f=u.Q_MAX2;u.LARGE_BITS;var E=100;this.nr_of_sfb_block=[[[6,5,5,5],[9,9,9,9],[6,9,9,9]],[[6,5,7,3],[9,9,12,6],[6,9,12,6]],[[11,10,0,0],[18,18,0,0],[15,18,0,0]],[[7,7,7,0],[12,12,12,0],[6,15,12,0]],[[6,6,6,3],[12,9,9,6],[6,12,9,6]],[[8,8,5,0],[15,12,9,0],[6,18,9,0]]];var N=[0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,2,2,3,3,3,2,0];this.pretab=N,this.sfBandIndex=[new t([0,6,12,18,24,30,36,44,54,66,80,96,116,140,168,200,238,284,336,396,464,522,576],[0,4,8,12,18,24,32,42,56,74,100,132,174,192],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0]),new t([0,6,12,18,24,30,36,44,54,66,80,96,114,136,162,194,232,278,332,394,464,540,576],[0,4,8,12,18,26,36,48,62,80,104,136,180,192],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0]),new t([0,6,12,18,24,30,36,44,54,66,80,96,116,140,168,200,238,284,336,396,464,522,576],[0,4,8,12,18,26,36,48,62,80,104,134,174,192],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0]),new t([0,4,8,12,16,20,24,30,36,44,52,62,74,90,110,134,162,196,238,288,342,418,576],[0,4,8,12,16,22,30,40,52,66,84,106,136,192],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0]),new t([0,4,8,12,16,20,24,30,36,42,50,60,72,88,106,128,156,190,230,276,330,384,576],[0,4,8,12,16,22,28,38,50,64,80,100,126,192],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0]),new t([0,4,8,12,16,20,24,30,36,44,54,66,82,102,126,156,194,240,296,364,448,550,576],[0,4,8,12,16,22,30,42,58,78,104,138,180,192],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0]),new t([0,6,12,18,24,30,36,44,54,66,80,96,116,140,168,200,238,284,336,396,464,522,576],[0/3,12/3,24/3,36/3,54/3,78/3,108/3,144/3,186/3,240/3,312/3,402/3,522/3,576/3],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0]),new t([0,6,12,18,24,30,36,44,54,66,80,96,116,140,168,200,238,284,336,396,464,522,576],[0/3,12/3,24/3,36/3,54/3,78/3,108/3,144/3,186/3,240/3,312/3,402/3,522/3,576/3],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0]),new t([0,12,24,36,48,60,72,88,108,132,160,192,232,280,336,400,476,566,568,570,572,574,576],[0/3,24/3,48/3,72/3,108/3,156/3,216/3,288/3,372/3,480/3,486/3,492/3,498/3,576/3],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0])];var B=o($+f+1),U=o($),C=o(m),q=o(m);this.adj43=q;function de(D,I){var Y=x.ATHformula(I,D);return Y-=E,Y=Math.pow(10,Y/10+D.ATHlower),Y}function A(D){for(var I=D.internal_flags.ATH.l,Y=D.internal_flags.ATH.psfb21,V=D.internal_flags.ATH.s,ee=D.internal_flags.ATH.psfb12,L=D.internal_flags,T=D.out_samplerate,y=0;y<c.SBMAX_l;y++){var v=L.scalefac_band.l[y],R=L.scalefac_band.l[y+1];I[y]=n.MAX_VALUE;for(var O=v;O<R;O++){var K=O*T/1152,se=de(D,K);I[y]=Math.min(I[y],se)}}for(var y=0;y<c.PSFB21;y++){var v=L.scalefac_band.psfb21[y],R=L.scalefac_band.psfb21[y+1];Y[y]=n.MAX_VALUE;for(var O=v;O<R;O++){var K=O*T/1152,se=de(D,K);Y[y]=Math.min(Y[y],se)}}for(var y=0;y<c.SBMAX_s;y++){var v=L.scalefac_band.s[y],R=L.scalefac_band.s[y+1];V[y]=n.MAX_VALUE;for(var O=v;O<R;O++){var K=O*T/384,se=de(D,K);V[y]=Math.min(V[y],se)}V[y]*=L.scalefac_band.s[y+1]-L.scalefac_band.s[y]}for(var y=0;y<c.PSFB12;y++){var v=L.scalefac_band.psfb12[y],R=L.scalefac_band.psfb12[y+1];ee[y]=n.MAX_VALUE;for(var O=v;O<R;O++){var K=O*T/384,se=de(D,K);ee[y]=Math.min(ee[y],se)}ee[y]*=L.scalefac_band.s[13]-L.scalefac_band.s[12]}if(D.noATH){for(var y=0;y<c.SBMAX_l;y++)I[y]=1e-20;for(var y=0;y<c.PSFB21;y++)Y[y]=1e-20;for(var y=0;y<c.SBMAX_s;y++)V[y]=1e-20;for(var y=0;y<c.PSFB12;y++)ee[y]=1e-20}L.ATH.floor=10*Math.log10(de(D,-1))}this.iteration_init=function(D){var I=D.internal_flags,Y=I.l3_side,V;if(I.iteration_init_init==0){for(I.iteration_init_init=1,Y.main_data_begin=0,A(D),C[0]=0,V=1;V<m;V++)C[V]=Math.pow(V,4/3);for(V=0;V<m-1;V++)q[V]=V+1-Math.pow(.5*(C[V]+C[V+1]),.75);for(q[V]=.5,V=0;V<$;V++)U[V]=Math.pow(2,(V-210)*-.1875);for(V=0;V<=$+f;V++)B[V]=Math.pow(2,(V-210-f)*.25);p.huffman_init(I);{var ee,L,T,y;for(V=D.exp_nspsytune>>2&63,V>=32&&(V-=64),ee=Math.pow(10,V/4/10),V=D.exp_nspsytune>>8&63,V>=32&&(V-=64),L=Math.pow(10,V/4/10),V=D.exp_nspsytune>>14&63,V>=32&&(V-=64),T=Math.pow(10,V/4/10),V=D.exp_nspsytune>>20&63,V>=32&&(V-=64),y=T*Math.pow(10,V/4/10),V=0;V<c.SBMAX_l;V++){var v;V<=6?v=ee:V<=13?v=L:V<=20?v=T:v=y,I.nsPsy.longfact[V]=v}for(V=0;V<c.SBMAX_s;V++){var v;V<=5?v=ee:V<=10?v=L:V<=11?v=T:v=y,I.nsPsy.shortfact[V]=v}}}},this.on_pe=function(D,I,Y,V,ee,L){var T=D.internal_flags,y=0,v,R=i(2),O,K=new d(y),se=g.ResvMaxBits(D,V,K,L);y=K.bits;var F=y+se;for(F>l.MAX_BITS_PER_GRANULE&&(F=l.MAX_BITS_PER_GRANULE),v=0,O=0;O<T.channels_out;++O)Y[O]=Math.min(l.MAX_BITS_PER_CHANNEL,y/T.channels_out),R[O]=0|Y[O]*I[ee][O]/700-Y[O],R[O]>V*3/4&&(R[O]=V*3/4),R[O]<0&&(R[O]=0),R[O]+Y[O]>l.MAX_BITS_PER_CHANNEL&&(R[O]=Math.max(0,l.MAX_BITS_PER_CHANNEL-Y[O])),v+=R[O];if(v>se)for(O=0;O<T.channels_out;++O)R[O]=se*R[O]/v;for(O=0;O<T.channels_out;++O)Y[O]+=R[O],se-=R[O];for(v=0,O=0;O<T.channels_out;++O)v+=Y[O];if(v>l.MAX_BITS_PER_GRANULE){var Q=0;for(O=0;O<T.channels_out;++O)Y[O]*=l.MAX_BITS_PER_GRANULE,Y[O]/=v,Q+=Y[O]}return F},this.reduce_side=function(D,I,Y,V){a(D[0]+D[1]<=l.MAX_BITS_PER_GRANULE);var ee=.33*(.5-I)/.5;ee<0&&(ee=0),ee>.5&&(ee=.5);var L=0|ee*.5*(D[0]+D[1]);L>l.MAX_BITS_PER_CHANNEL-D[0]&&(L=l.MAX_BITS_PER_CHANNEL-D[0]),L<0&&(L=0),D[1]>=125&&(D[1]-L>125?(D[0]<Y&&(D[0]+=L),D[1]-=L):(D[0]+=D[1]-125,D[1]=125)),L=D[0]+D[1],L>V&&(D[0]=V*D[0]/L,D[1]=V*D[1]/L),a(D[0]<=l.MAX_BITS_PER_CHANNEL),a(D[1]<=l.MAX_BITS_PER_CHANNEL),a(D[0]+D[1]<=l.MAX_BITS_PER_GRANULE)},this.athAdjust=function(D,I,Y){var V=90.30873362,ee=94.82444863,L=s.FAST_LOG10_X(I,10),T=D*D,y=0;return L-=Y,T>1e-20&&(y=1+s.FAST_LOG10_X(T,10/V)),y<0&&(y=0),L*=y,L+=Y+V-ee,Math.pow(10,.1*L)},this.calc_xmin=function(D,I,Y,V){var ee=0,L=D.internal_flags,T,y=0,v=0,R=L.ATH,O=Y.xr,K=D.VBR==r.vbr_mtrh?1:0,se=L.masking_lower;for((D.VBR==r.vbr_mtrh||D.VBR==r.vbr_mt)&&(se=1),T=0;T<Y.psy_lmax;T++){var F,Q,ue,ge,ke,Re;D.VBR==r.vbr_rh||D.VBR==r.vbr_mtrh?Q=athAdjust(R.adjust,R.l[T],R.floor):Q=R.adjust*R.l[T],ke=Y.width[T],ue=Q/ke,ge=k,Re=ke>>1,F=0;do{var Te,Se;Te=O[y]*O[y],F+=Te,ge+=Te<ue?Te:ue,y++,Se=O[y]*O[y],F+=Se,ge+=Se<ue?Se:ue,y++}while(--Re>0);if(F>Q&&v++,T==c.SBPSY_l){var Ce=Q*L.nsPsy.longfact[T];ge<Ce&&(ge=Ce)}if(K!=0&&(Q=ge),!D.ATHonly){var St=I.en.l[T];if(St>0){var Ce;Ce=F*I.thm.l[T]*se/St,K!=0&&(Ce*=L.nsPsy.longfact[T]),Q<Ce&&(Q=Ce)}}K!=0?V[ee++]=Q:V[ee++]=Q*L.nsPsy.longfact[T]}var Fr=575;if(Y.block_type!=c.SHORT_TYPE)for(var w=576;w--!=0&&h.EQ(O[w],0);)Fr=w;Y.max_nonzero_coeff=Fr;for(var P=Y.sfb_smin;T<Y.psymax;P++,T+=3){var ke,xe,Pe;for(D.VBR==r.vbr_rh||D.VBR==r.vbr_mtrh?Pe=athAdjust(R.adjust,R.s[P],R.floor):Pe=R.adjust*R.s[P],ke=Y.width[T],xe=0;xe<3;xe++){var F=0,Q,ue,ge,Re=ke>>1;ue=Pe/ke,ge=k;do{var Te,Se;Te=O[y]*O[y],F+=Te,ge+=Te<ue?Te:ue,y++,Se=O[y]*O[y],F+=Se,ge+=Se<ue?Se:ue,y++}while(--Re>0);if(F>Pe&&v++,P==c.SBPSY_s){var Ce=Pe*L.nsPsy.shortfact[P];ge<Ce&&(ge=Ce)}if(K!=0?Q=ge:Q=Pe,!D.ATHonly&&!D.ATHshort){var St=I.en.s[P][xe];if(St>0){var Ce;Ce=F*I.thm.s[P][xe]*se/St,K!=0&&(Ce*=L.nsPsy.shortfact[P]),Q<Ce&&(Q=Ce)}}K!=0?V[ee++]=Q:V[ee++]=Q*L.nsPsy.shortfact[P]}D.useTemporal&&(V[ee-3]>V[ee-3+1]&&(V[ee-3+1]+=(V[ee-3]-V[ee-3+1])*L.decay),V[ee-3+1]>V[ee-3+2]&&(V[ee-3+2]+=(V[ee-3+1]-V[ee-3+2])*L.decay))}return v};function b(D){this.s=D}this.calc_noise_core=function(D,I,Y,V){var ee=0,L=I.s,T=D.l3_enc;if(L>D.count1)for(;Y--!=0;){var y;y=D.xr[L],L++,ee+=y*y,y=D.xr[L],L++,ee+=y*y}else if(L>D.big_values){var v=o(2);for(v[0]=0,v[1]=V;Y--!=0;){var y;y=Math.abs(D.xr[L])-v[T[L]],L++,ee+=y*y,y=Math.abs(D.xr[L])-v[T[L]],L++,ee+=y*y}}else for(;Y--!=0;){var y;y=Math.abs(D.xr[L])-C[T[L]]*V,L++,ee+=y*y,y=Math.abs(D.xr[L])-C[T[L]]*V,L++,ee+=y*y}return I.s=L,ee},this.calc_noise=function(D,I,Y,V,ee){var L=0,T=0,y,v,R=0,O=0,K=0,se=-20,F=0,Q=D.scalefac,ue=0;for(V.over_SSD=0,y=0;y<D.psymax;y++){var ge=D.global_gain-(Q[ue++]+(D.preflag!=0?N[y]:0)<<D.scalefac_scale+1)-D.subblock_gain[D.window[y]]*8,ke=0;if(ee!=null&&ee.step[y]==ge)ke=ee.noise[y],F+=D.width[y],Y[L++]=ke/I[T++],ke=ee.noise_log[y];else{var Re=S(ge);if(v=D.width[y]>>1,F+D.width[y]>D.max_nonzero_coeff){var Te;Te=D.max_nonzero_coeff-F+1,Te>0?v=Te>>1:v=0}var Se=new b(F);ke=this.calc_noise_core(D,Se,v,Re),F=Se.s,ee!=null&&(ee.step[y]=ge,ee.noise[y]=ke),ke=Y[L++]=ke/I[T++],ke=s.FAST_LOG10(Math.max(ke,1e-20)),ee!=null&&(ee.noise_log[y]=ke)}if(ee!=null&&(ee.global_gain=D.global_gain),K+=ke,ke>0){var Ce;Ce=Math.max(0|ke*10+.5,1),V.over_SSD+=Ce*Ce,R++,O+=ke}se=Math.max(se,ke)}return V.over_count=R,V.tot_noise=K,V.over_noise=O,V.max_noise=se,R},this.set_pinfo=function(D,I,Y,V,ee){var L=D.internal_flags,T,y,v,R,O,K=I.scalefac_scale==0?.5:1,se=I.scalefac,F=o(L3Side.SFBMAX),Q=o(L3Side.SFBMAX),ue=new CalcNoiseResult;calc_xmin(D,Y,I,F),calc_noise(I,F,Q,ue,null);var ge=0;for(y=I.sfb_lmax,I.block_type!=c.SHORT_TYPE&&I.mixed_block_flag==0&&(y=22),T=0;T<y;T++){var ke=L.scalefac_band.l[T],Re=L.scalefac_band.l[T+1],Te=Re-ke;for(R=0;ge<Re;ge++)R+=I.xr[ge]*I.xr[ge];R/=Te,O=1e15,L.pinfo.en[V][ee][T]=O*R,L.pinfo.xfsf[V][ee][T]=O*F[T]*Q[T]/Te,Y.en.l[T]>0&&!D.ATHonly?R=R/Y.en.l[T]:R=0,L.pinfo.thr[V][ee][T]=O*Math.max(R*Y.thm.l[T],L.ATH.l[T]),L.pinfo.LAMEsfb[V][ee][T]=0,I.preflag!=0&&T>=11&&(L.pinfo.LAMEsfb[V][ee][T]=-K*N[T]),T<c.SBPSY_l&&(a(se[T]>=0),L.pinfo.LAMEsfb[V][ee][T]-=K*se[T])}if(I.block_type==c.SHORT_TYPE)for(y=T,T=I.sfb_smin;T<c.SBMAX_s;T++)for(var ke=L.scalefac_band.s[T],Re=L.scalefac_band.s[T+1],Te=Re-ke,Se=0;Se<3;Se++){for(R=0,v=ke;v<Re;v++)R+=I.xr[ge]*I.xr[ge],ge++;R=Math.max(R/Te,1e-20),O=1e15,L.pinfo.en_s[V][ee][3*T+Se]=O*R,L.pinfo.xfsf_s[V][ee][3*T+Se]=O*F[y]*Q[y]/Te,Y.en.s[T][Se]>0?R=R/Y.en.s[T][Se]:R=0,(D.ATHonly||D.ATHshort)&&(R=0),L.pinfo.thr_s[V][ee][3*T+Se]=O*Math.max(R*Y.thm.s[T][Se],L.ATH.s[T]),L.pinfo.LAMEsfb_s[V][ee][3*T+Se]=-2*I.subblock_gain[Se],T<c.SBPSY_s&&(L.pinfo.LAMEsfb_s[V][ee][3*T+Se]-=K*se[y]),y++}L.pinfo.LAMEqss[V][ee]=I.global_gain,L.pinfo.LAMEmainbits[V][ee]=I.part2_3_length+I.part2_length,L.pinfo.LAMEsfbits[V][ee]=I.part2_length,L.pinfo.over[V][ee]=ue.over_count,L.pinfo.max_noise[V][ee]=ue.max_noise*10,L.pinfo.over_noise[V][ee]=ue.over_noise*10,L.pinfo.tot_noise[V][ee]=ue.tot_noise*10,L.pinfo.over_SSD[V][ee]=ue.over_SSD}}return Jm=u,Jm}var Qm,Lw;function g3(){if(Lw)return Qm;Lw=1;var t=Zt,e=t.System,r=t.Arrays,n=t.new_int,s=t.assert,o=hr(),i=c1,a=o1,c=m3();function d(){var l=null;this.qupvt=null,this.setModules=function(L){this.qupvt=L,l=L};function u(L){this.bits=0|L}var h=[[0,0],[0,0],[0,0],[0,0],[0,0],[0,1],[1,1],[1,1],[1,2],[2,2],[2,3],[2,3],[3,4],[3,4],[3,4],[4,5],[4,5],[4,6],[5,6],[5,6],[5,7],[6,7],[6,7]];function p(L,T,y,v,R,O){var K=.5946/T;for(L=L>>1;L--!=0;)R[O++]=K>y[v++]?0:1,R[O++]=K>y[v++]?0:1}function g(L,T,y,v,R,O){L=L>>1;var K=L%2;for(L=L>>1;L--!=0;){var se,F,Q,ue,ge,ke,Re,Te;se=y[v++]*T,F=y[v++]*T,ge=0|se,Q=y[v++]*T,ke=0|F,ue=y[v++]*T,Re=0|Q,se+=l.adj43[ge],Te=0|ue,F+=l.adj43[ke],R[O++]=0|se,Q+=l.adj43[Re],R[O++]=0|F,ue+=l.adj43[Te],R[O++]=0|Q,R[O++]=0|ue}if(K!=0){var se,F,ge,ke;se=y[v++]*T,F=y[v++]*T,ge=0|se,ke=0|F,se+=l.adj43[ge],F+=l.adj43[ke],R[O++]=0|se,R[O++]=0|F}}function x(L,T,y,v,R){var O,K,se=0,F,Q=0,ue=0,ge=0,ke=T,Re=0,Te=ke,Se=0,Ce=L,St=0;for(F=R!=null&&v.global_gain==R.global_gain,v.block_type==o.SHORT_TYPE?K=38:K=21,O=0;O<=K;O++){var Fr=-1;if((F||v.block_type==o.NORM_TYPE)&&(Fr=v.global_gain-(v.scalefac[O]+(v.preflag!=0?l.pretab[O]:0)<<v.scalefac_scale+1)-v.subblock_gain[v.window[O]]*8),s(v.width[O]>=0),F&&R.step[O]==Fr)Q!=0&&(g(Q,y,Ce,St,Te,Se),Q=0),ue!=0&&(p(ue,y,Ce,St,Te,Se),ue=0);else{var w=v.width[O];if(se+v.width[O]>v.max_nonzero_coeff){var P;P=v.max_nonzero_coeff-se+1,r.fill(T,v.max_nonzero_coeff,576,0),w=P,w<0&&(w=0),O=K+1}if(Q==0&&ue==0&&(Te=ke,Se=Re,Ce=L,St=ge),R!=null&&R.sfb_count1>0&&O>=R.sfb_count1&&R.step[O]>0&&Fr>=R.step[O]?(Q!=0&&(g(Q,y,Ce,St,Te,Se),Q=0,Te=ke,Se=Re,Ce=L,St=ge),ue+=w):(ue!=0&&(p(ue,y,Ce,St,Te,Se),ue=0,Te=ke,Se=Re,Ce=L,St=ge),Q+=w),w<=0){ue!=0&&(p(ue,y,Ce,St,Te,Se),ue=0),Q!=0&&(g(Q,y,Ce,St,Te,Se),Q=0);break}}O<=K&&(Re+=v.width[O],ge+=v.width[O],se+=v.width[O])}Q!=0&&(g(Q,y,Ce,St,Te,Se),Q=0),ue!=0&&(p(ue,y,Ce,St,Te,Se),ue=0)}function S(L,T,y){var v=0,R=0;do{var O=L[T++],K=L[T++];v<O&&(v=O),R<K&&(R=K)}while(T<y);return v<R&&(v=R),v}function k(L,T,y,v,R,O){var K=i.ht[v].xlen*65536+i.ht[R].xlen,se=0,F;do{var Q=L[T++],ue=L[T++];Q!=0&&(Q>14&&(Q=15,se+=K),Q*=16),ue!=0&&(ue>14&&(ue=15,se+=K),Q+=ue),se+=i.largetbl[Q]}while(T<y);return F=se&65535,se>>=16,se>F&&(se=F,v=R),O.bits+=se,v}function _(L,T,y,v){var R=0,O=i.ht[1].hlen;do{var K=L[T+0]*2+L[T+1];T+=2,R+=O[K]}while(T<y);return v.bits+=R,1}function m(L,T,y,v,R){var O=0,K,se=i.ht[v].xlen,F;v==2?F=i.table23:F=i.table56;do{var Q=L[T+0]*se+L[T+1];T+=2,O+=F[Q]}while(T<y);return K=O&65535,O>>=16,O>K&&(O=K,v++),R.bits+=O,v}function $(L,T,y,v,R){var O=0,K=0,se=0,F=i.ht[v].xlen,Q=i.ht[v].hlen,ue=i.ht[v+1].hlen,ge=i.ht[v+2].hlen;do{var ke=L[T+0]*F+L[T+1];T+=2,O+=Q[ke],K+=ue[ke],se+=ge[ke]}while(T<y);var Re=v;return O>K&&(O=K,Re++),O>se&&(O=se,Re=v+2),R.bits+=O,Re}var f=[1,2,5,7,7,10,10,13,13,13,13,13,13,13,13];function E(L,T,y,v){var R=S(L,T,y);switch(R){case 0:return R;case 1:return _(L,T,y,v);case 2:case 3:return m(L,T,y,f[R-1],v);case 4:case 5:case 6:case 7:case 8:case 9:case 10:case 11:case 12:case 13:case 14:case 15:return $(L,T,y,f[R-1],v);default:if(R>c.IXMAX_VAL)return v.bits=c.LARGE_BITS,-1;R-=15;var O;for(O=24;O<32&&!(i.ht[O].linmax>=R);O++);var K;for(K=O-8;K<24&&!(i.ht[K].linmax>=R);K++);return k(L,T,y,K,O,v)}}this.noquant_count_bits=function(L,T,y){var v=T.l3_enc,R=Math.min(576,T.max_nonzero_coeff+2>>1<<1);for(y!=null&&(y.sfb_count1=0);R>1&&!(v[R-1]|v[R-2]);R-=2);T.count1=R;for(var O=0,K=0;R>3;R-=4){var se;if(((v[R-1]|v[R-2]|v[R-3]|v[R-4])&2147483647)>1)break;se=((v[R-4]*2+v[R-3])*2+v[R-2])*2+v[R-1],O+=i.t32l[se],K+=i.t33l[se]}var F=O;if(T.count1table_select=0,O>K&&(F=K,T.count1table_select=1),T.count1bits=F,T.big_values=R,R==0)return F;if(T.block_type==o.SHORT_TYPE)O=3*L.scalefac_band.s[3],O>T.big_values&&(O=T.big_values),K=T.big_values;else if(T.block_type==o.NORM_TYPE){if(O=T.region0_count=L.bv_scf[R-2],K=T.region1_count=L.bv_scf[R-1],s(O+K+2<o.SBPSY_l),K=L.scalefac_band.l[O+K+2],O=L.scalefac_band.l[O+1],K<R){var Q=new u(F);T.table_select[2]=E(v,K,R,Q),F=Q.bits}}else T.region0_count=7,T.region1_count=o.SBMAX_l-1-7-1,O=L.scalefac_band.l[8],K=R,O>K&&(O=K);if(O=Math.min(O,R),K=Math.min(K,R),0<O){var Q=new u(F);T.table_select[0]=E(v,0,O,Q),F=Q.bits}if(O<K){var Q=new u(F);T.table_select[1]=E(v,O,K,Q),F=Q.bits}if(L.use_best_huffman==2&&(T.part2_3_length=F,best_huffman_divide(L,T),F=T.part2_3_length),y!=null&&T.block_type==o.NORM_TYPE){for(var ue=0;L.scalefac_band.l[ue]<T.big_values;)ue++;y.sfb_count1=ue}return F},this.count_bits=function(L,T,y,v){var R=y.l3_enc,O=c.IXMAX_VAL/l.IPOW20(y.global_gain);if(y.xrpow_max>O)return c.LARGE_BITS;if(x(T,R,l.IPOW20(y.global_gain),y,v),L.substep_shaping&2)for(var K=0,se=y.global_gain+y.scalefac_scale,F=.634521682242439/l.IPOW20(se),Q=0;Q<y.sfbmax;Q++){var ue=y.width[Q];if(L.pseudohalf[Q]==0)K+=ue;else{var ge;for(ge=K,K+=ue;ge<K;++ge)R[ge]=T[ge]>=F?R[ge]:0}}return this.noquant_count_bits(L,y,v)};function N(L,T,y,v,R,O,K){for(var se=T.big_values,F=0;F<=22;F++)v[F]=c.LARGE_BITS;for(var F=0;F<16;F++){var Q=L.scalefac_band.l[F+1];if(Q>=se)break;var ue=0,ge=new u(ue),ke=E(y,0,Q,ge);ue=ge.bits;for(var Re=0;Re<8;Re++){var Te=L.scalefac_band.l[F+Re+2];if(Te>=se)break;var Se=ue;ge=new u(Se);var Ce=E(y,Q,Te,ge);Se=ge.bits,v[F+Re]>Se&&(v[F+Re]=Se,R[F+Re]=F,O[F+Re]=ke,K[F+Re]=Ce)}}}function B(L,T,y,v,R,O,K,se){for(var F=T.big_values,Q=2;Q<o.SBMAX_l+1;Q++){var ue=L.scalefac_band.l[Q];if(ue>=F)break;var ge=R[Q-2]+T.count1bits;if(y.part2_3_length<=ge)break;var ke=new u(ge),Re=E(v,ue,F,ke);ge=ke.bits,!(y.part2_3_length<=ge)&&(y.assign(T),y.part2_3_length=ge,y.region0_count=O[Q-2],y.region1_count=Q-2-O[Q-2],y.table_select[0]=K[Q-2],y.table_select[1]=se[Q-2],y.table_select[2]=Re)}}this.best_huffman_divide=function(L,T){var y=new a,v=T.l3_enc,R=n(23),O=n(23),K=n(23),se=n(23);if(!(T.block_type==o.SHORT_TYPE&&L.mode_gr==1)){y.assign(T),T.block_type==o.NORM_TYPE&&(N(L,T,v,R,O,K,se),B(L,y,T,v,R,O,K,se));var F=y.big_values;if(!(F==0||(v[F-2]|v[F-1])>1)&&(F=T.count1+2,!(F>576))){y.assign(T),y.count1=F;for(var Q=0,ue=0;F>y.big_values;F-=4){var ge=((v[F-4]*2+v[F-3])*2+v[F-2])*2+v[F-1];Q+=i.t32l[ge],ue+=i.t33l[ge]}if(y.big_values=F,y.count1table_select=0,Q>ue&&(Q=ue,y.count1table_select=1),y.count1bits=Q,y.block_type==o.NORM_TYPE)B(L,y,T,v,R,O,K,se);else{if(y.part2_3_length=Q,Q=L.scalefac_band.l[8],Q>F&&(Q=F),Q>0){var ke=new u(y.part2_3_length);y.table_select[0]=E(v,0,Q,ke),y.part2_3_length=ke.bits}if(F>Q){var ke=new u(y.part2_3_length);y.table_select[1]=E(v,Q,F,ke),y.part2_3_length=ke.bits}T.part2_3_length>y.part2_3_length&&T.assign(y)}}}};var U=[1,1,1,1,8,2,2,2,4,4,4,8,8,8,16,16],C=[1,2,4,8,1,2,4,8,2,4,8,2,4,8,4,8],q=[0,0,0,0,3,1,1,1,2,2,2,3,3,3,4,4],de=[0,1,2,3,0,1,2,3,1,2,3,1,2,3,2,3];d.slen1_tab=q,d.slen2_tab=de;function A(L,T){for(var y,v=T.tt[1][L],R=T.tt[0][L],O=0;O<i.scfsi_band.length-1;O++){for(y=i.scfsi_band[O];y<i.scfsi_band[O+1]&&!(R.scalefac[y]!=v.scalefac[y]&&v.scalefac[y]>=0);y++);if(y==i.scfsi_band[O+1]){for(y=i.scfsi_band[O];y<i.scfsi_band[O+1];y++)v.scalefac[y]=-1;T.scfsi[L][O]=1}}var K=0,se=0;for(y=0;y<11;y++)v.scalefac[y]!=-1&&(se++,K<v.scalefac[y]&&(K=v.scalefac[y]));for(var F=0,Q=0;y<o.SBPSY_l;y++)v.scalefac[y]!=-1&&(Q++,F<v.scalefac[y]&&(F=v.scalefac[y]));for(var O=0;O<16;O++)if(K<U[O]&&F<C[O]){var ue=q[O]*se+de[O]*Q;v.part2_length>ue&&(v.part2_length=ue,v.scalefac_compress=O)}}this.best_scalefac_store=function(L,T,y,v){var R=v.tt[T][y],O,K,se,F,Q=0;for(se=0,O=0;O<R.sfbmax;O++){var ue=R.width[O];for(se+=ue,F=-ue;F<0&&R.l3_enc[F+se]==0;F++);F==0&&(R.scalefac[O]=Q=-2)}if(R.scalefac_scale==0&&R.preflag==0){var ge=0;for(O=0;O<R.sfbmax;O++)R.scalefac[O]>0&&(ge|=R.scalefac[O]);if(!(ge&1)&&ge!=0){for(O=0;O<R.sfbmax;O++)R.scalefac[O]>0&&(R.scalefac[O]>>=1);R.scalefac_scale=Q=1}}if(R.preflag==0&&R.block_type!=o.SHORT_TYPE&&L.mode_gr==2){for(O=11;O<o.SBPSY_l&&!(R.scalefac[O]<l.pretab[O]&&R.scalefac[O]!=-2);O++);if(O==o.SBPSY_l){for(O=11;O<o.SBPSY_l;O++)R.scalefac[O]>0&&(R.scalefac[O]-=l.pretab[O]);R.preflag=Q=1}}for(K=0;K<4;K++)v.scfsi[y][K]=0;for(L.mode_gr==2&&T==1&&v.tt[0][y].block_type!=o.SHORT_TYPE&&v.tt[1][y].block_type!=o.SHORT_TYPE&&(A(y,v),Q=0),O=0;O<R.sfbmax;O++)R.scalefac[O]==-2&&(R.scalefac[O]=0);Q!=0&&(L.mode_gr==2?this.scale_bitcount(R):this.scale_bitcount_lsf(L,R))};function b(L,T){for(var y=0;y<T;++y)if(L[y]<0)return!1;return!0}var D=[0,18,36,54,54,36,54,72,54,72,90,72,90,108,108,126],I=[0,18,36,54,51,35,53,71,52,70,88,69,87,105,104,122],Y=[0,10,20,30,33,21,31,41,32,42,52,43,53,63,64,74];this.scale_bitcount=function(L){var T,y,v=0,R=0,O,K=L.scalefac;if(s(b(K,L.sfbmax)),L.block_type==o.SHORT_TYPE)O=D,L.mixed_block_flag!=0&&(O=I);else if(O=Y,L.preflag==0){for(y=11;y<o.SBPSY_l&&!(K[y]<l.pretab[y]);y++);if(y==o.SBPSY_l)for(L.preflag=1,y=11;y<o.SBPSY_l;y++)K[y]-=l.pretab[y]}for(y=0;y<L.sfbdivide;y++)v<K[y]&&(v=K[y]);for(;y<L.sfbmax;y++)R<K[y]&&(R=K[y]);for(L.part2_length=c.LARGE_BITS,T=0;T<16;T++)v<U[T]&&R<C[T]&&L.part2_length>O[T]&&(L.part2_length=O[T],L.scalefac_compress=T);return L.part2_length==c.LARGE_BITS};var V=[[15,15,7,7],[15,15,7,0],[7,3,0,0],[15,31,31,0],[7,7,7,0],[3,3,0,0]];this.scale_bitcount_lsf=function(L,T){var y,v,R,O,K,se,F,Q,ue=n(4),ge=T.scalefac;for(T.preflag!=0?y=2:y=0,F=0;F<4;F++)ue[F]=0;if(T.block_type==o.SHORT_TYPE){v=1;var ke=l.nr_of_sfb_block[y][v];for(Q=0,R=0;R<4;R++)for(O=ke[R]/3,F=0;F<O;F++,Q++)for(K=0;K<3;K++)ge[Q*3+K]>ue[R]&&(ue[R]=ge[Q*3+K])}else{v=0;var ke=l.nr_of_sfb_block[y][v];for(Q=0,R=0;R<4;R++)for(O=ke[R],F=0;F<O;F++,Q++)ge[Q]>ue[R]&&(ue[R]=ge[Q])}for(se=!1,R=0;R<4;R++)ue[R]>V[y][R]&&(se=!0);if(!se){var Re,Te,Se,Ce;for(T.sfb_partition_table=l.nr_of_sfb_block[y][v],R=0;R<4;R++)T.slen[R]=ee[ue[R]];switch(Re=T.slen[0],Te=T.slen[1],Se=T.slen[2],Ce=T.slen[3],y){case 0:T.scalefac_compress=(Re*5+Te<<4)+(Se<<2)+Ce;break;case 1:T.scalefac_compress=400+(Re*5+Te<<2)+Se;break;case 2:T.scalefac_compress=500+Re*3+Te;break;default:e.err.printf(`intensity stereo not implemented yet
|
|
193
|
+
`);break}}if(!se)for(s(T.sfb_partition_table!=null),T.part2_length=0,R=0;R<4;R++)T.part2_length+=T.slen[R]*T.sfb_partition_table[R];return se};var ee=[0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4];this.huffman_init=function(L){for(var T=2;T<=576;T+=2){for(var y=0,v;L.scalefac_band.l[++y]<T;);for(v=h[y][0];L.scalefac_band.l[v+1]>T;)v--;for(v<0&&(v=h[y][0]),L.bv_scf[T-2]=v,v=h[y][1];L.scalefac_band.l[v+L.bv_scf[T-2]+2]>T;)v--;v<0&&(v=h[y][1]),L.bv_scf[T-1]=v}}}return Qm=d,Qm}var e1,Zw;function l1(){if(Zw)return e1;Zw=1;var t=Zt,e=t.System,r=t.Arrays,n=t.new_byte,s=t.new_float_n,o=t.new_int,i=t.assert,a=g3(),c=c1,d=hr(),l=ou;u.EQ=function(h,p){return Math.abs(h)>Math.abs(p)?Math.abs(h-p)<=Math.abs(h)*1e-6:Math.abs(h-p)<=Math.abs(p)*1e-6},u.NEQ=function(h,p){return!u.EQ(h,p)};function u(){var h=u1(),p=this,g=32773,x=null,S=null,k=null,_=null;this.setModules=function(T,y,v,R){x=T,S=y,k=v,_=R};var m=null,$=0,f=0,E=0;this.getframebits=function(T){var y=T.internal_flags,v;y.bitrate_index!=0?v=c.bitrate_table[T.version][y.bitrate_index]:v=T.brate;var R=0|(T.version+1)*72e3*v/T.out_samplerate+y.padding;return 8*R};function N(T){e.arraycopy(T.header[T.w_ptr].buf,0,m,f,T.sideinfo_len),f+=T.sideinfo_len,$+=T.sideinfo_len*8,T.w_ptr=T.w_ptr+1&l.MAX_HEADER_BUF-1}function B(T,y,v){for(;v>0;){var R;E==0&&(E=8,f++,i(f<h.LAME_MAXMP3BUFFER),i(T.header[T.w_ptr].write_timing>=$),T.header[T.w_ptr].write_timing==$&&N(T),m[f]=0),R=Math.min(v,E),v-=R,E-=R,m[f]|=y>>v<<E,$+=R}}function U(T,y,v){for(;v>0;){var R;E==0&&(E=8,f++,i(f<h.LAME_MAXMP3BUFFER),m[f]=0),R=Math.min(v,E),v-=R,E-=R,m[f]|=y>>v<<E,$+=R}}function C(T,y){var v=T.internal_flags,R;if(y>=8&&(B(v,76,8),y-=8),y>=8&&(B(v,65,8),y-=8),y>=8&&(B(v,77,8),y-=8),y>=8&&(B(v,69,8),y-=8),y>=32){var O=k.getLameShortVersion();if(y>=32)for(R=0;R<O.length&&y>=8;++R)y-=8,B(v,O.charAt(R),8)}for(;y>=1;y-=1)B(v,v.ancillary_flag,1),v.ancillary_flag^=T.disable_reservoir?0:1}function q(T,y,v){for(var R=T.header[T.h_ptr].ptr;v>0;){var O=Math.min(v,8-(R&7));v-=O,T.header[T.h_ptr].buf[R>>3]|=y>>v<<8-(R&7)-O,R+=O}T.header[T.h_ptr].ptr=R}function de(T,y){T<<=8;for(var v=0;v<8;v++)T<<=1,y<<=1,(y^T)&65536&&(y^=g);return y}this.CRC_writeheader=function(T,y){var v=65535;v=de(y[2]&255,v),v=de(y[3]&255,v);for(var R=6;R<T.sideinfo_len;R++)v=de(y[R]&255,v);y[4]=byte(v>>8),y[5]=byte(v&255)};function A(T,y){var v=T.internal_flags,R,O,K;if(R=v.l3_side,v.header[v.h_ptr].ptr=0,r.fill(v.header[v.h_ptr].buf,0,v.sideinfo_len,0),T.out_samplerate<16e3?q(v,4094,12):q(v,4095,12),q(v,T.version,1),q(v,1,2),q(v,T.error_protection?0:1,1),q(v,v.bitrate_index,4),q(v,v.samplerate_index,2),q(v,v.padding,1),q(v,T.extension,1),q(v,T.mode.ordinal(),2),q(v,v.mode_ext,2),q(v,T.copyright,1),q(v,T.original,1),q(v,T.emphasis,2),T.error_protection&&q(v,0,16),T.version==1){for(i(R.main_data_begin>=0),q(v,R.main_data_begin,9),v.channels_out==2?q(v,R.private_bits,3):q(v,R.private_bits,5),K=0;K<v.channels_out;K++){var se;for(se=0;se<4;se++)q(v,R.scfsi[K][se],1)}for(O=0;O<2;O++)for(K=0;K<v.channels_out;K++){var F=R.tt[O][K];q(v,F.part2_3_length+F.part2_length,12),q(v,F.big_values/2,9),q(v,F.global_gain,8),q(v,F.scalefac_compress,4),F.block_type!=d.NORM_TYPE?(q(v,1,1),q(v,F.block_type,2),q(v,F.mixed_block_flag,1),F.table_select[0]==14&&(F.table_select[0]=16),q(v,F.table_select[0],5),F.table_select[1]==14&&(F.table_select[1]=16),q(v,F.table_select[1],5),q(v,F.subblock_gain[0],3),q(v,F.subblock_gain[1],3),q(v,F.subblock_gain[2],3)):(q(v,0,1),F.table_select[0]==14&&(F.table_select[0]=16),q(v,F.table_select[0],5),F.table_select[1]==14&&(F.table_select[1]=16),q(v,F.table_select[1],5),F.table_select[2]==14&&(F.table_select[2]=16),q(v,F.table_select[2],5),i(0<=F.region0_count&&F.region0_count<16),i(0<=F.region1_count&&F.region1_count<8),q(v,F.region0_count,4),q(v,F.region1_count,3)),q(v,F.preflag,1),q(v,F.scalefac_scale,1),q(v,F.count1table_select,1)}}else for(i(R.main_data_begin>=0),q(v,R.main_data_begin,8),q(v,R.private_bits,v.channels_out),O=0,K=0;K<v.channels_out;K++){var F=R.tt[O][K];q(v,F.part2_3_length+F.part2_length,12),q(v,F.big_values/2,9),q(v,F.global_gain,8),q(v,F.scalefac_compress,9),F.block_type!=d.NORM_TYPE?(q(v,1,1),q(v,F.block_type,2),q(v,F.mixed_block_flag,1),F.table_select[0]==14&&(F.table_select[0]=16),q(v,F.table_select[0],5),F.table_select[1]==14&&(F.table_select[1]=16),q(v,F.table_select[1],5),q(v,F.subblock_gain[0],3),q(v,F.subblock_gain[1],3),q(v,F.subblock_gain[2],3)):(q(v,0,1),F.table_select[0]==14&&(F.table_select[0]=16),q(v,F.table_select[0],5),F.table_select[1]==14&&(F.table_select[1]=16),q(v,F.table_select[1],5),F.table_select[2]==14&&(F.table_select[2]=16),q(v,F.table_select[2],5),i(0<=F.region0_count&&F.region0_count<16),i(0<=F.region1_count&&F.region1_count<8),q(v,F.region0_count,4),q(v,F.region1_count,3)),q(v,F.scalefac_scale,1),q(v,F.count1table_select,1)}T.error_protection&&CRC_writeheader(v,v.header[v.h_ptr].buf);{var Q=v.h_ptr;i(v.header[Q].ptr==v.sideinfo_len*8),v.h_ptr=Q+1&l.MAX_HEADER_BUF-1,v.header[v.h_ptr].write_timing=v.header[Q].write_timing+y,v.h_ptr==v.w_ptr&&e.err.println(`Error: MAX_HEADER_BUF too small in bitstream.c
|
|
194
|
+
`)}}function b(T,y){var v=c.ht[y.count1table_select+32],R,O=0,K=y.big_values,se=y.big_values;for(i(y.count1table_select<2),R=(y.count1-y.big_values)/4;R>0;--R){var F=0,Q=0,ue;ue=y.l3_enc[K+0],ue!=0&&(Q+=8,y.xr[se+0]<0&&F++),ue=y.l3_enc[K+1],ue!=0&&(Q+=4,F*=2,y.xr[se+1]<0&&F++),ue=y.l3_enc[K+2],ue!=0&&(Q+=2,F*=2,y.xr[se+2]<0&&F++),ue=y.l3_enc[K+3],ue!=0&&(Q++,F*=2,y.xr[se+3]<0&&F++),K+=4,se+=4,B(T,F+v.table[Q],v.hlen[Q]),O+=v.hlen[Q]}return O}function D(T,y,v,R,O){var K=c.ht[y],se=0;if(y==0)return se;for(var F=v;F<R;F+=2){var Q=0,ue=0,ge=K.xlen,ke=K.xlen,Re=0,Te=O.l3_enc[F],Se=O.l3_enc[F+1];if(Te!=0&&(O.xr[F]<0&&Re++,Q--),y>15){if(Te>14){var Ce=Te-15;i(Ce<=K.linmax),Re|=Ce<<1,ue=ge,Te=15}if(Se>14){var St=Se-15;i(St<=K.linmax),Re<<=ge,Re|=St,ue+=ge,Se=15}ke=16}Se!=0&&(Re<<=1,O.xr[F+1]<0&&Re++,Q--),Te=Te*ke+Se,ue-=Q,Q+=K.hlen[Te],B(T,K.table[Te],Q),B(T,Re,ue),se+=Q+ue}return se}function I(T,y){var v=3*T.scalefac_band.s[3];v>y.big_values&&(v=y.big_values);var R=D(T,y.table_select[0],0,v,y);return R+=D(T,y.table_select[1],v,y.big_values,y),R}function Y(T,y){var v,R,O,K;v=y.big_values;var se=y.region0_count+1;return i(se<T.scalefac_band.l.length),O=T.scalefac_band.l[se],se+=y.region1_count+1,i(se<T.scalefac_band.l.length),K=T.scalefac_band.l[se],O>v&&(O=v),K>v&&(K=v),R=D(T,y.table_select[0],0,O,y),R+=D(T,y.table_select[1],O,K,y),R+=D(T,y.table_select[2],K,v,y),R}function V(T){var y,v,R,O,K=0,se=T.internal_flags,F=se.l3_side;if(T.version==1)for(y=0;y<2;y++)for(v=0;v<se.channels_out;v++){var Q=F.tt[y][v],ue=a.slen1_tab[Q.scalefac_compress],ge=a.slen2_tab[Q.scalefac_compress];for(O=0,R=0;R<Q.sfbdivide;R++)Q.scalefac[R]!=-1&&(B(se,Q.scalefac[R],ue),O+=ue);for(;R<Q.sfbmax;R++)Q.scalefac[R]!=-1&&(B(se,Q.scalefac[R],ge),O+=ge);i(O==Q.part2_length),Q.block_type==d.SHORT_TYPE?O+=I(se,Q):O+=Y(se,Q),O+=b(se,Q),i(O==Q.part2_3_length+Q.part2_length),K+=O}else for(y=0,v=0;v<se.channels_out;v++){var Q=F.tt[y][v],ke,Re,Te=0;if(i(Q.sfb_partition_table!=null),O=0,R=0,Re=0,Q.block_type==d.SHORT_TYPE){for(;Re<4;Re++){var Se=Q.sfb_partition_table[Re]/3,Ce=Q.slen[Re];for(ke=0;ke<Se;ke++,R++)B(se,Math.max(Q.scalefac[R*3+0],0),Ce),B(se,Math.max(Q.scalefac[R*3+1],0),Ce),B(se,Math.max(Q.scalefac[R*3+2],0),Ce),Te+=3*Ce}O+=I(se,Q)}else{for(;Re<4;Re++){var Se=Q.sfb_partition_table[Re],Ce=Q.slen[Re];for(ke=0;ke<Se;ke++,R++)B(se,Math.max(Q.scalefac[R],0),Ce),Te+=Ce}O+=Y(se,Q)}O+=b(se,Q),i(O==Q.part2_3_length),i(Te==Q.part2_length),K+=Te+O}return K}function ee(){this.total=0}function L(T,y){var v=T.internal_flags,R,O,K,se,F;return F=v.w_ptr,se=v.h_ptr-1,se==-1&&(se=l.MAX_HEADER_BUF-1),R=v.header[se].write_timing-$,y.total=R,R>=0&&(O=1+se-F,se<F&&(O=1+se-F+l.MAX_HEADER_BUF),R-=O*8*v.sideinfo_len),K=p.getframebits(T),R+=K,y.total+=K,y.total%8!=0?y.total=1+y.total/8:y.total=y.total/8,y.total+=f+1,R<0&&e.err.println(`strange error flushing buffer ...
|
|
195
|
+
`),R}this.flush_bitstream=function(T){var y=T.internal_flags,v,R,O=y.h_ptr-1;if(O==-1&&(O=l.MAX_HEADER_BUF-1),v=y.l3_side,!((R=L(T,new ee))<0)){if(C(T,R),i(y.header[O].write_timing+this.getframebits(T)==$),y.ResvSize=0,v.main_data_begin=0,y.findReplayGain){var K=x.GetTitleGain(y.rgdata);i(NEQ(K,GainAnalysis.GAIN_NOT_ENOUGH_SAMPLES)),y.RadioGain=Math.floor(K*10+.5)|0}y.findPeakSample&&(y.noclipGainChange=Math.ceil(Math.log10(y.PeakSample/32767)*20*10)|0,y.noclipGainChange>0&&(EQ(T.scale,1)||EQ(T.scale,0))?y.noclipScale=Math.floor(32767/y.PeakSample*100)/100:y.noclipScale=-1)}},this.add_dummy_byte=function(T,y,v){for(var R=T.internal_flags,O;v-- >0;)for(U(R,y,8),O=0;O<l.MAX_HEADER_BUF;++O)R.header[O].write_timing+=8},this.format_bitstream=function(T){var y=T.internal_flags,v;v=y.l3_side;var R=this.getframebits(T);C(T,v.resvDrain_pre),A(T,R);var O=8*y.sideinfo_len;if(O+=V(T),C(T,v.resvDrain_post),O+=v.resvDrain_post,v.main_data_begin+=(R-O)/8,L(T,new ee)!=y.ResvSize&&e.err.println("Internal buffer inconsistency. flushbits <> ResvSize"),v.main_data_begin*8!=y.ResvSize&&(e.err.printf(`bit reservoir error:
|
|
196
|
+
l3_side.main_data_begin: %d
|
|
197
|
+
Resvoir size: %d
|
|
198
|
+
resv drain (post) %d
|
|
199
|
+
resv drain (pre) %d
|
|
200
|
+
header and sideinfo: %d
|
|
201
|
+
data bits: %d
|
|
202
|
+
total bits: %d (remainder: %d)
|
|
203
|
+
bitsperframe: %d
|
|
204
|
+
`,8*v.main_data_begin,y.ResvSize,v.resvDrain_post,v.resvDrain_pre,8*y.sideinfo_len,O-v.resvDrain_post-8*y.sideinfo_len,O,O%8,R),e.err.println("This is a fatal error. It has several possible causes:"),e.err.println("90%% LAME compiled with buggy version of gcc using advanced optimizations"),e.err.println(" 9%% Your system is overclocked"),e.err.println(" 1%% bug in LAME encoding library"),y.ResvSize=v.main_data_begin*8),$>1e9){var K;for(K=0;K<l.MAX_HEADER_BUF;++K)y.header[K].write_timing-=$;$=0}return 0},this.copy_buffer=function(T,y,v,R,O){var K=f+1;if(K<=0)return 0;if(R!=0&&K>R)return-1;if(e.arraycopy(m,0,y,v,K),f=-1,E=0,O!=0){var se=o(1);if(se[0]=T.nMusicCRC,_.updateMusicCRC(se,y,v,K),T.nMusicCRC=se[0],K>0&&(T.VBR_seek_table.nBytesWritten+=K),T.decode_on_the_fly){for(var F=s([2,1152]),Q=K,ue=-1,ge;ue!=0;)if(ue=S.hip_decode1_unclipped(T.hip,y,v,Q,F[0],F[1]),Q=0,ue==-1&&(ue=0),ue>0){if(T.findPeakSample){for(ge=0;ge<ue;ge++)F[0][ge]>T.PeakSample?T.PeakSample=F[0][ge]:-F[0][ge]>T.PeakSample&&(T.PeakSample=-F[0][ge]);if(T.channels_out>1)for(ge=0;ge<ue;ge++)F[1][ge]>T.PeakSample?T.PeakSample=F[1][ge]:-F[1][ge]>T.PeakSample&&(T.PeakSample=-F[1][ge])}if(T.findReplayGain&&x.AnalyzeSamples(T.rgdata,F[0],0,F[1],0,ue,T.channels_out)==GainAnalysis.GAIN_ANALYSIS_ERROR)return-6}}}return K},this.init_bit_stream_w=function(T){m=n(h.LAME_MAXMP3BUFFER),T.h_ptr=T.w_ptr=0,T.header[T.h_ptr].write_timing=0,f=-1,E=0,$=0}}return e1=u,e1}var t1,Bw;function u1(){if(Bw)return t1;Bw=1;var t=Zt,e=t.System,r=t.VbrMode,n=t.ShortBlock,s=t.new_float,o=t.new_int_n,i=t.new_short_n,a=t.assert,c=$z,d=Mz,l=ou,u=eI,h=rI,p=lI,g=l1(),x=c1,S=hr();function k(){var _=Da,m=this,$=128*1024;k.V9=410,k.V8=420,k.V7=430,k.V6=440,k.V5=450,k.V4=460,k.V3=470,k.V2=480,k.V1=490,k.V0=500,k.R3MIX=1e3,k.STANDARD=1001,k.EXTREME=1002,k.INSANE=1003,k.STANDARD_FAST=1004,k.EXTREME_FAST=1005,k.MEDIUM=1006,k.MEDIUM_FAST=1007;var f=16384+$;k.LAME_MAXMP3BUFFER=f;var E,N,B,U,C,q=new c,de,A,b;this.enc=new S,this.setModules=function(w,P,xe,Pe,Ge,He,Ne,ze,et){E=w,N=P,B=xe,U=Pe,C=Ge,de=He,A=ze,b=et,this.enc.setModules(N,q,U,de)};function D(){this.mask_adjust=0,this.mask_adjust_short=0,this.bo_l_weight=s(S.SBMAX_l),this.bo_s_weight=s(S.SBMAX_s)}function I(){this.lowerlimit=0}function Y(w,P){this.lowpass=P}var V=4294479419;function ee(w){var P;return w.class_id=V,P=w.internal_flags=new l,w.mode=_.NOT_SET,w.original=1,w.in_samplerate=44100,w.num_channels=2,w.num_samples=-1,w.bWriteVbrTag=!0,w.quality=-1,w.short_blocks=null,P.subblock_gain=-1,w.lowpassfreq=0,w.highpassfreq=0,w.lowpasswidth=-1,w.highpasswidth=-1,w.VBR=r.vbr_off,w.VBR_q=4,w.ATHcurve=-1,w.VBR_mean_bitrate_kbps=128,w.VBR_min_bitrate_kbps=0,w.VBR_max_bitrate_kbps=0,w.VBR_hard_min=0,P.VBR_min_bitrate=1,P.VBR_max_bitrate=13,w.quant_comp=-1,w.quant_comp_short=-1,w.msfix=-1,P.resample_ratio=1,P.OldValue[0]=180,P.OldValue[1]=180,P.CurrentStep[0]=4,P.CurrentStep[1]=4,P.masking_lower=1,P.nsPsy.attackthre=-1,P.nsPsy.attackthre_s=-1,w.scale=-1,w.athaa_type=-1,w.ATHtype=-1,w.athaa_loudapprox=-1,w.athaa_sensitivity=0,w.useTemporal=null,w.interChRatio=-1,P.mf_samples_to_encode=S.ENCDELAY+S.POSTDELAY,w.encoder_padding=0,P.mf_size=S.ENCDELAY-S.MDCTDELAY,w.findReplayGain=!1,w.decode_on_the_fly=!1,P.decode_on_the_fly=!1,P.findReplayGain=!1,P.findPeakSample=!1,P.RadioGain=0,P.AudiophileGain=0,P.noclipGainChange=0,P.noclipScale=-1,w.preset=0,w.write_id3tag_automatic=!0,0}this.lame_init=function(){var w=new d;return ee(w),w.lame_allocated_gfp=1,w};function L(w){return w>1?0:w<=0?1:Math.cos(Math.PI/2*w)}this.nearestBitrateFullIndex=function(w){var P=[8,16,24,32,40,48,56,64,80,96,112,128,160,192,224,256,320],xe=0,Pe=0,Ge=0,He=0;He=P[16],Ge=16,Pe=P[16],xe=16;for(var Ne=0;Ne<16;Ne++)if(Math.max(w,P[Ne+1])!=w){He=P[Ne+1],Ge=Ne+1,Pe=P[Ne],xe=Ne;break}return He-w>w-Pe?xe:Ge};function T(w,P){var xe=44100;return P>=48e3?xe=48e3:P>=44100?xe=44100:P>=32e3?xe=32e3:P>=24e3?xe=24e3:P>=22050?xe=22050:P>=16e3?xe=16e3:P>=12e3?xe=12e3:P>=11025?xe=11025:P>=8e3&&(xe=8e3),w==-1?xe:(w<=15960&&(xe=44100),w<=15250&&(xe=32e3),w<=11220&&(xe=24e3),w<=9970&&(xe=22050),w<=7230&&(xe=16e3),w<=5420&&(xe=12e3),w<=4510&&(xe=11025),w<=3970&&(xe=8e3),P<xe?P>44100?48e3:P>32e3?44100:P>24e3?32e3:P>22050?24e3:P>16e3?22050:P>12e3?16e3:P>11025?12e3:P>8e3?11025:8e3:xe)}function y(w,P){switch(w){case 44100:return P.version=1,0;case 48e3:return P.version=1,1;case 32e3:return P.version=1,2;case 22050:return P.version=0,0;case 24e3:return P.version=0,1;case 16e3:return P.version=0,2;case 11025:return P.version=0,0;case 12e3:return P.version=0,1;case 8e3:return P.version=0,2;default:return P.version=0,-1}}function v(w,P,xe){xe<16e3&&(P=2);for(var Pe=x.bitrate_table[P][1],Ge=2;Ge<=14;Ge++)x.bitrate_table[P][Ge]>0&&Math.abs(x.bitrate_table[P][Ge]-w)<Math.abs(Pe-w)&&(Pe=x.bitrate_table[P][Ge]);return Pe}function R(w,P,xe){xe<16e3&&(P=2);for(var Pe=0;Pe<=14;Pe++)if(x.bitrate_table[P][Pe]>0&&x.bitrate_table[P][Pe]==w)return Pe;return-1}function O(w,P){var xe=[new Y(8,2e3),new Y(16,3700),new Y(24,3900),new Y(32,5500),new Y(40,7e3),new Y(48,7500),new Y(56,1e4),new Y(64,11e3),new Y(80,13500),new Y(96,15100),new Y(112,15600),new Y(128,17e3),new Y(160,17500),new Y(192,18600),new Y(224,19400),new Y(256,19700),new Y(320,20500)],Pe=m.nearestBitrateFullIndex(P);w.lowerlimit=xe[Pe].lowpass}function K(w){var P=w.internal_flags,xe=32,Pe=-1;if(P.lowpass1>0){for(var Ge=999,He=0;He<=31;He++){var Ne=He/31;Ne>=P.lowpass2&&(xe=Math.min(xe,He)),P.lowpass1<Ne&&Ne<P.lowpass2&&(Ge=Math.min(Ge,He))}Ge==999?P.lowpass1=(xe-.75)/31:P.lowpass1=(Ge-.75)/31,P.lowpass2=xe/31}if(P.highpass2>0&&P.highpass2<.9*(.75/31)&&(P.highpass1=0,P.highpass2=0,e.err.println(`Warning: highpass filter disabled. highpass frequency too small
|
|
205
|
+
`)),P.highpass2>0){for(var ze=-1,He=0;He<=31;He++){var Ne=He/31;Ne<=P.highpass1&&(Pe=Math.max(Pe,He)),P.highpass1<Ne&&Ne<P.highpass2&&(ze=Math.max(ze,He))}P.highpass1=Pe/31,ze==-1?P.highpass2=(Pe+.75)/31:P.highpass2=(ze+.75)/31}for(var He=0;He<32;He++){var et,je,Ne=He/31;P.highpass2>P.highpass1?et=L((P.highpass2-Ne)/(P.highpass2-P.highpass1+1e-20)):et=1,P.lowpass2>P.lowpass1?je=L((Ne-P.lowpass1)/(P.lowpass2-P.lowpass1+1e-20)):je=1,P.amp_filter[He]=et*je}}function se(w){var P=w.internal_flags;switch(w.quality){default:case 9:P.psymodel=0,P.noise_shaping=0,P.noise_shaping_amp=0,P.noise_shaping_stop=0,P.use_best_huffman=0,P.full_outer_loop=0;break;case 8:w.quality=7;case 7:P.psymodel=1,P.noise_shaping=0,P.noise_shaping_amp=0,P.noise_shaping_stop=0,P.use_best_huffman=0,P.full_outer_loop=0;break;case 6:P.psymodel=1,P.noise_shaping==0&&(P.noise_shaping=1),P.noise_shaping_amp=0,P.noise_shaping_stop=0,P.subblock_gain==-1&&(P.subblock_gain=1),P.use_best_huffman=0,P.full_outer_loop=0;break;case 5:P.psymodel=1,P.noise_shaping==0&&(P.noise_shaping=1),P.noise_shaping_amp=0,P.noise_shaping_stop=0,P.subblock_gain==-1&&(P.subblock_gain=1),P.use_best_huffman=0,P.full_outer_loop=0;break;case 4:P.psymodel=1,P.noise_shaping==0&&(P.noise_shaping=1),P.noise_shaping_amp=0,P.noise_shaping_stop=0,P.subblock_gain==-1&&(P.subblock_gain=1),P.use_best_huffman=1,P.full_outer_loop=0;break;case 3:P.psymodel=1,P.noise_shaping==0&&(P.noise_shaping=1),P.noise_shaping_amp=1,P.noise_shaping_stop=1,P.subblock_gain==-1&&(P.subblock_gain=1),P.use_best_huffman=1,P.full_outer_loop=0;break;case 2:P.psymodel=1,P.noise_shaping==0&&(P.noise_shaping=1),P.substep_shaping==0&&(P.substep_shaping=2),P.noise_shaping_amp=1,P.noise_shaping_stop=1,P.subblock_gain==-1&&(P.subblock_gain=1),P.use_best_huffman=1,P.full_outer_loop=0;break;case 1:P.psymodel=1,P.noise_shaping==0&&(P.noise_shaping=1),P.substep_shaping==0&&(P.substep_shaping=2),P.noise_shaping_amp=2,P.noise_shaping_stop=1,P.subblock_gain==-1&&(P.subblock_gain=1),P.use_best_huffman=1,P.full_outer_loop=0;break;case 0:P.psymodel=1,P.noise_shaping==0&&(P.noise_shaping=1),P.substep_shaping==0&&(P.substep_shaping=2),P.noise_shaping_amp=2,P.noise_shaping_stop=1,P.subblock_gain==-1&&(P.subblock_gain=1),P.use_best_huffman=1,P.full_outer_loop=0;break}}function F(w){var P=w.internal_flags;w.frameNum=0,w.write_id3tag_automatic&&A.id3tag_write_v2(w),P.bitrate_stereoMode_Hist=o([16,5]),P.bitrate_blockType_Hist=o([16,6]),P.PeakSample=0,w.bWriteVbrTag&&de.InitVbrTag(w)}this.lame_init_params=function(w){var P=w.internal_flags;if(P.Class_ID=0,P.ATH==null&&(P.ATH=new u),P.PSY==null&&(P.PSY=new D),P.rgdata==null&&(P.rgdata=new h),P.channels_in=w.num_channels,P.channels_in==1&&(w.mode=_.MONO),P.channels_out=w.mode==_.MONO?1:2,P.mode_ext=S.MPG_MD_MS_LR,w.mode==_.MONO&&(w.force_ms=!1),w.VBR==r.vbr_off&&w.VBR_mean_bitrate_kbps!=128&&w.brate==0&&(w.brate=w.VBR_mean_bitrate_kbps),w.VBR==r.vbr_off||w.VBR==r.vbr_mtrh||w.VBR==r.vbr_mt||(w.free_format=!1),w.VBR==r.vbr_off&&w.brate==0&&g.EQ(w.compression_ratio,0)&&(w.compression_ratio=11.025),w.VBR==r.vbr_off&&w.compression_ratio>0&&(w.out_samplerate==0&&(w.out_samplerate=map2MP3Frequency(int(.97*w.in_samplerate))),w.brate=0|w.out_samplerate*16*P.channels_out/(1e3*w.compression_ratio),P.samplerate_index=y(w.out_samplerate,w),w.free_format||(w.brate=v(w.brate,w.version,w.out_samplerate))),w.out_samplerate!=0&&(w.out_samplerate<16e3?(w.VBR_mean_bitrate_kbps=Math.max(w.VBR_mean_bitrate_kbps,8),w.VBR_mean_bitrate_kbps=Math.min(w.VBR_mean_bitrate_kbps,64)):w.out_samplerate<32e3?(w.VBR_mean_bitrate_kbps=Math.max(w.VBR_mean_bitrate_kbps,8),w.VBR_mean_bitrate_kbps=Math.min(w.VBR_mean_bitrate_kbps,160)):(w.VBR_mean_bitrate_kbps=Math.max(w.VBR_mean_bitrate_kbps,32),w.VBR_mean_bitrate_kbps=Math.min(w.VBR_mean_bitrate_kbps,320))),w.lowpassfreq==0){var xe=16e3;switch(w.VBR){case r.vbr_off:{var Pe=new I;O(Pe,w.brate),xe=Pe.lowerlimit;break}case r.vbr_abr:{var Pe=new I;O(Pe,w.VBR_mean_bitrate_kbps),xe=Pe.lowerlimit;break}case r.vbr_rh:{var Ge=[19500,19e3,18600,18e3,17500,16e3,15600,14900,12500,1e4,3950];if(0<=w.VBR_q&&w.VBR_q<=9){var He=Ge[w.VBR_q],Ne=Ge[w.VBR_q+1],ze=w.VBR_q_frac;xe=linear_int(He,Ne,ze)}else xe=19500;break}default:{var Ge=[19500,19e3,18500,18e3,17500,16500,15500,14500,12500,9500,3950];if(0<=w.VBR_q&&w.VBR_q<=9){var He=Ge[w.VBR_q],Ne=Ge[w.VBR_q+1],ze=w.VBR_q_frac;xe=linear_int(He,Ne,ze)}else xe=19500}}w.mode==_.MONO&&(w.VBR==r.vbr_off||w.VBR==r.vbr_abr)&&(xe*=1.5),w.lowpassfreq=xe|0}if(w.out_samplerate==0&&(2*w.lowpassfreq>w.in_samplerate&&(w.lowpassfreq=w.in_samplerate/2),w.out_samplerate=T(w.lowpassfreq|0,w.in_samplerate)),w.lowpassfreq=Math.min(20500,w.lowpassfreq),w.lowpassfreq=Math.min(w.out_samplerate/2,w.lowpassfreq),w.VBR==r.vbr_off&&(w.compression_ratio=w.out_samplerate*16*P.channels_out/(1e3*w.brate)),w.VBR==r.vbr_abr&&(w.compression_ratio=w.out_samplerate*16*P.channels_out/(1e3*w.VBR_mean_bitrate_kbps)),w.bWriteVbrTag||(w.findReplayGain=!1,w.decode_on_the_fly=!1,P.findPeakSample=!1),P.findReplayGain=w.findReplayGain,P.decode_on_the_fly=w.decode_on_the_fly,P.decode_on_the_fly&&(P.findPeakSample=!0),P.findReplayGain&&E.InitGainAnalysis(P.rgdata,w.out_samplerate)==GainAnalysis.INIT_GAIN_ANALYSIS_ERROR)return w.internal_flags=null,-6;switch(P.decode_on_the_fly&&!w.decode_only&&(P.hip!=null&&b.hip_decode_exit(P.hip),P.hip=b.hip_decode_init()),P.mode_gr=w.out_samplerate<=24e3?1:2,w.framesize=576*P.mode_gr,w.encoder_delay=S.ENCDELAY,P.resample_ratio=w.in_samplerate/w.out_samplerate,w.VBR){case r.vbr_mt:case r.vbr_rh:case r.vbr_mtrh:{var et=[5.7,6.5,7.3,8.2,10,11.9,13,14,15,16.5];w.compression_ratio=et[w.VBR_q]}break;case r.vbr_abr:w.compression_ratio=w.out_samplerate*16*P.channels_out/(1e3*w.VBR_mean_bitrate_kbps);break;default:w.compression_ratio=w.out_samplerate*16*P.channels_out/(1e3*w.brate);break}if(w.mode==_.NOT_SET&&(w.mode=_.JOINT_STEREO),w.highpassfreq>0?(P.highpass1=2*w.highpassfreq,w.highpasswidth>=0?P.highpass2=2*(w.highpassfreq+w.highpasswidth):P.highpass2=1*2*w.highpassfreq,P.highpass1/=w.out_samplerate,P.highpass2/=w.out_samplerate):(P.highpass1=0,P.highpass2=0),w.lowpassfreq>0?(P.lowpass2=2*w.lowpassfreq,w.lowpasswidth>=0?(P.lowpass1=2*(w.lowpassfreq-w.lowpasswidth),P.lowpass1<0&&(P.lowpass1=0)):P.lowpass1=1*2*w.lowpassfreq,P.lowpass1/=w.out_samplerate,P.lowpass2/=w.out_samplerate):(P.lowpass1=0,P.lowpass2=0),K(w),P.samplerate_index=y(w.out_samplerate,w),P.samplerate_index<0)return w.internal_flags=null,-1;if(w.VBR==r.vbr_off){if(w.free_format)P.bitrate_index=0;else if(w.brate=v(w.brate,w.version,w.out_samplerate),P.bitrate_index=R(w.brate,w.version,w.out_samplerate),P.bitrate_index<=0)return w.internal_flags=null,-1}else P.bitrate_index=1;w.analysis&&(w.bWriteVbrTag=!1),P.pinfo!=null&&(w.bWriteVbrTag=!1),N.init_bit_stream_w(P);for(var je=P.samplerate_index+3*w.version+6*(w.out_samplerate<16e3?1:0),ve=0;ve<S.SBMAX_l+1;ve++)P.scalefac_band.l[ve]=U.sfBandIndex[je].l[ve];for(var ve=0;ve<S.PSFB21+1;ve++){var vt=(P.scalefac_band.l[22]-P.scalefac_band.l[21])/S.PSFB21,Yt=P.scalefac_band.l[21]+ve*vt;P.scalefac_band.psfb21[ve]=Yt}P.scalefac_band.psfb21[S.PSFB21]=576;for(var ve=0;ve<S.SBMAX_s+1;ve++)P.scalefac_band.s[ve]=U.sfBandIndex[je].s[ve];for(var ve=0;ve<S.PSFB12+1;ve++){var vt=(P.scalefac_band.s[13]-P.scalefac_band.s[12])/S.PSFB12,Yt=P.scalefac_band.s[12]+ve*vt;P.scalefac_band.psfb12[ve]=Yt}P.scalefac_band.psfb12[S.PSFB12]=192,w.version==1?P.sideinfo_len=P.channels_out==1?21:36:P.sideinfo_len=P.channels_out==1?13:21,w.error_protection&&(P.sideinfo_len+=2),F(w),P.Class_ID=V;{var pt;for(pt=0;pt<19;pt++)P.nsPsy.pefirbuf[pt]=700*P.mode_gr*P.channels_out;w.ATHtype==-1&&(w.ATHtype=4)}switch(a(w.VBR_q<=9),a(w.VBR_q>=0),w.VBR){case r.vbr_mt:w.VBR=r.vbr_mtrh;case r.vbr_mtrh:{w.useTemporal==null&&(w.useTemporal=!1),B.apply_preset(w,500-w.VBR_q*10,0),w.quality<0&&(w.quality=LAME_DEFAULT_QUALITY),w.quality<5&&(w.quality=0),w.quality>5&&(w.quality=5),P.PSY.mask_adjust=w.maskingadjust,P.PSY.mask_adjust_short=w.maskingadjust_short,w.experimentalY?P.sfb21_extra=!1:P.sfb21_extra=w.out_samplerate>44e3,P.iteration_loop=new VBRNewIterationLoop(C);break}case r.vbr_rh:{B.apply_preset(w,500-w.VBR_q*10,0),P.PSY.mask_adjust=w.maskingadjust,P.PSY.mask_adjust_short=w.maskingadjust_short,w.experimentalY?P.sfb21_extra=!1:P.sfb21_extra=w.out_samplerate>44e3,w.quality>6&&(w.quality=6),w.quality<0&&(w.quality=LAME_DEFAULT_QUALITY),P.iteration_loop=new VBROldIterationLoop(C);break}default:{var M;P.sfb21_extra=!1,w.quality<0&&(w.quality=LAME_DEFAULT_QUALITY),M=w.VBR,M==r.vbr_off&&(w.VBR_mean_bitrate_kbps=w.brate),B.apply_preset(w,w.VBR_mean_bitrate_kbps,0),w.VBR=M,P.PSY.mask_adjust=w.maskingadjust,P.PSY.mask_adjust_short=w.maskingadjust_short,M==r.vbr_off?P.iteration_loop=new p(C):P.iteration_loop=new ABRIterationLoop(C);break}}if(a(w.scale>=0),w.VBR!=r.vbr_off){if(P.VBR_min_bitrate=1,P.VBR_max_bitrate=14,w.out_samplerate<16e3&&(P.VBR_max_bitrate=8),w.VBR_min_bitrate_kbps!=0&&(w.VBR_min_bitrate_kbps=v(w.VBR_min_bitrate_kbps,w.version,w.out_samplerate),P.VBR_min_bitrate=R(w.VBR_min_bitrate_kbps,w.version,w.out_samplerate),P.VBR_min_bitrate<0)||w.VBR_max_bitrate_kbps!=0&&(w.VBR_max_bitrate_kbps=v(w.VBR_max_bitrate_kbps,w.version,w.out_samplerate),P.VBR_max_bitrate=R(w.VBR_max_bitrate_kbps,w.version,w.out_samplerate),P.VBR_max_bitrate<0))return-1;w.VBR_min_bitrate_kbps=x.bitrate_table[w.version][P.VBR_min_bitrate],w.VBR_max_bitrate_kbps=x.bitrate_table[w.version][P.VBR_max_bitrate],w.VBR_mean_bitrate_kbps=Math.min(x.bitrate_table[w.version][P.VBR_max_bitrate],w.VBR_mean_bitrate_kbps),w.VBR_mean_bitrate_kbps=Math.max(x.bitrate_table[w.version][P.VBR_min_bitrate],w.VBR_mean_bitrate_kbps)}return w.tune&&(P.PSY.mask_adjust+=w.tune_value_a,P.PSY.mask_adjust_short+=w.tune_value_a),se(w),a(w.scale>=0),w.athaa_type<0?P.ATH.useAdjust=3:P.ATH.useAdjust=w.athaa_type,P.ATH.aaSensitivityP=Math.pow(10,w.athaa_sensitivity/-10),w.short_blocks==null&&(w.short_blocks=n.short_block_allowed),w.short_blocks==n.short_block_allowed&&(w.mode==_.JOINT_STEREO||w.mode==_.STEREO)&&(w.short_blocks=n.short_block_coupled),w.quant_comp<0&&(w.quant_comp=1),w.quant_comp_short<0&&(w.quant_comp_short=0),w.msfix<0&&(w.msfix=0),w.exp_nspsytune=w.exp_nspsytune|1,w.internal_flags.nsPsy.attackthre<0&&(w.internal_flags.nsPsy.attackthre=c.NSATTACKTHRE),w.internal_flags.nsPsy.attackthre_s<0&&(w.internal_flags.nsPsy.attackthre_s=c.NSATTACKTHRE_S),a(w.scale>=0),w.scale<0&&(w.scale=1),w.ATHtype<0&&(w.ATHtype=4),w.ATHcurve<0&&(w.ATHcurve=4),w.athaa_loudapprox<0&&(w.athaa_loudapprox=2),w.interChRatio<0&&(w.interChRatio=0),w.useTemporal==null&&(w.useTemporal=!0),P.slot_lag=P.frac_SpF=0,w.VBR==r.vbr_off&&(P.slot_lag=P.frac_SpF=(w.version+1)*72e3*w.brate%w.out_samplerate|0),U.iteration_init(w),q.psymodel_init(w),a(w.scale>=0),0};function Q(w,P){(w.in_buffer_0==null||w.in_buffer_nsamples<P)&&(w.in_buffer_0=s(P),w.in_buffer_1=s(P),w.in_buffer_nsamples=P)}this.lame_encode_flush=function(w,P,xe,Pe){var Ge=w.internal_flags,He=i([2,1152]),Ne=0,ze,et,je,ve,vt=Ge.mf_samples_to_encode-S.POSTDELAY,Yt=ue(w);if(Ge.mf_samples_to_encode<1)return 0;for(ze=0,w.in_samplerate!=w.out_samplerate&&(vt+=16*w.out_samplerate/w.in_samplerate),je=w.framesize-vt%w.framesize,je<576&&(je+=w.framesize),w.encoder_padding=je,ve=(vt+je)/w.framesize;ve>0&&Ne>=0;){var pt=Yt-Ge.mf_size,M=w.frameNum;pt*=w.in_samplerate,pt/=w.out_samplerate,pt>1152&&(pt=1152),pt<1&&(pt=1),et=Pe-ze,Pe==0&&(et=0),Ne=this.lame_encode_buffer(w,He[0],He[1],pt,P,xe,et),xe+=Ne,ze+=Ne,ve-=M!=w.frameNum?1:0}if(Ge.mf_samples_to_encode=0,Ne<0||(et=Pe-ze,Pe==0&&(et=0),N.flush_bitstream(w),Ne=N.copy_buffer(Ge,P,xe,et,1),Ne<0))return Ne;if(xe+=Ne,ze+=Ne,et=Pe-ze,Pe==0&&(et=0),w.write_id3tag_automatic){if(A.id3tag_write_v1(w),Ne=N.copy_buffer(Ge,P,xe,et,0),Ne<0)return Ne;ze+=Ne}return ze},this.lame_encode_buffer=function(w,P,xe,Pe,Ge,He,Ne){var ze=w.internal_flags,et=[null,null];if(ze.Class_ID!=V)return-3;if(Pe==0)return 0;Q(ze,Pe),et[0]=ze.in_buffer_0,et[1]=ze.in_buffer_1;for(var je=0;je<Pe;je++)et[0][je]=P[je],ze.channels_in>1&&(et[1][je]=xe[je]);return ge(w,et[0],et[1],Pe,Ge,He,Ne)};function ue(w){var P=S.BLKSIZE+w.framesize-S.FFTOFFSET;return P=Math.max(P,512+w.framesize-32),P}function ge(w,P,xe,Pe,Ge,He,Ne){var ze=w.internal_flags,et=0,je,ve,vt,Yt,pt,M=[null,null],z=[null,null];if(ze.Class_ID!=V)return-3;if(Pe==0)return 0;if(pt=N.copy_buffer(ze,Ge,He,Ne,0),pt<0)return pt;if(He+=pt,et+=pt,z[0]=P,z[1]=xe,g.NEQ(w.scale,0)&&g.NEQ(w.scale,1))for(ve=0;ve<Pe;++ve)z[0][ve]*=w.scale,ze.channels_out==2&&(z[1][ve]*=w.scale);if(g.NEQ(w.scale_left,0)&&g.NEQ(w.scale_left,1))for(ve=0;ve<Pe;++ve)z[0][ve]*=w.scale_left;if(g.NEQ(w.scale_right,0)&&g.NEQ(w.scale_right,1))for(ve=0;ve<Pe;++ve)z[1][ve]*=w.scale_right;if(w.num_channels==2&&ze.channels_out==1)for(ve=0;ve<Pe;++ve)z[0][ve]=.5*(z[0][ve]+z[1][ve]),z[1][ve]=0;Yt=ue(w),M[0]=ze.mfbuf[0],M[1]=ze.mfbuf[1];for(var Z=0;Pe>0;){var H=[null,null],J=0,j=0;H[0]=z[0],H[1]=z[1];var X=new Re;if(Fr(w,M,H,Z,Pe,X),J=X.n_in,j=X.n_out,ze.findReplayGain&&!ze.decode_on_the_fly&&E.AnalyzeSamples(ze.rgdata,M[0],ze.mf_size,M[1],ze.mf_size,j,ze.channels_out)==GainAnalysis.GAIN_ANALYSIS_ERROR)return-6;if(Pe-=J,Z+=J,ze.channels_out==2,ze.mf_size+=j,a(ze.mf_size<=l.MFSIZE),ze.mf_samples_to_encode<1&&(ze.mf_samples_to_encode=S.ENCDELAY+S.POSTDELAY),ze.mf_samples_to_encode+=j,ze.mf_size>=Yt){var te=Ne-et;if(Ne==0&&(te=0),je=ke(w,M[0],M[1],Ge,He,te),je<0)return je;for(He+=je,et+=je,ze.mf_size-=w.framesize,ze.mf_samples_to_encode-=w.framesize,vt=0;vt<ze.channels_out;vt++)for(ve=0;ve<ze.mf_size;ve++)M[vt][ve]=M[vt][ve+w.framesize]}}return et}function ke(w,P,xe,Pe,Ge,He){var Ne=m.enc.lame_encode_mp3_frame(w,P,xe,Pe,Ge,He);return w.frameNum++,Ne}function Re(){this.n_in=0,this.n_out=0}function Te(){this.num_used=0}function Se(w,P){return P!=0?Se(P,w%P):w}function Ce(w,P,xe){var Pe=Math.PI*P;w/=xe,w<0&&(w=0),w>1&&(w=1);var Ge=w-.5,He=.42-.5*Math.cos(2*w*Math.PI)+.08*Math.cos(4*w*Math.PI);return Math.abs(Ge)<1e-9?Pe/Math.PI:He*Math.sin(xe*Pe*Ge)/(Math.PI*xe*Ge)}function St(w,P,xe,Pe,Ge,He,Ne,ze,et){var je=w.internal_flags,ve,vt=0,Yt,pt=w.out_samplerate/Se(w.out_samplerate,w.in_samplerate);pt>l.BPC&&(pt=l.BPC);var M=Math.abs(je.resample_ratio-Math.floor(.5+je.resample_ratio))<1e-4?1:0,z=1/je.resample_ratio;z>1&&(z=1);var Z=31;Z%2==0&&--Z,Z+=M;var H=Z+1;if(je.fill_buffer_resample_init==0){for(je.inbuf_old[0]=s(H),je.inbuf_old[1]=s(H),ve=0;ve<=2*pt;++ve)je.blackfilt[ve]=s(H);for(je.itime[0]=0,je.itime[1]=0,vt=0;vt<=2*pt;vt++){var J=0,j=(vt-pt)/(2*pt);for(ve=0;ve<=Z;ve++)J+=je.blackfilt[vt][ve]=Ce(ve-j,z,Z);for(ve=0;ve<=Z;ve++)je.blackfilt[vt][ve]/=J}je.fill_buffer_resample_init=1}var X=je.inbuf_old[et];for(Yt=0;Yt<Pe;Yt++){var te,W;if(te=Yt*je.resample_ratio,vt=0|Math.floor(te-je.itime[et]),Z+vt-Z/2>=Ne)break;var j=te-je.itime[et]-(vt+.5*(Z%2));W=0|Math.floor(j*2*pt+pt+.5);var oe=0;for(ve=0;ve<=Z;++ve){var re=0|ve+vt-Z/2,ie;ie=re<0?X[H+re]:Ge[He+re],oe+=ie*je.blackfilt[W][ve]}P[xe+Yt]=oe}if(ze.num_used=Math.min(Ne,Z+vt-Z/2),je.itime[et]+=ze.num_used-Yt*je.resample_ratio,ze.num_used>=H)for(ve=0;ve<H;ve++)X[ve]=Ge[He+ze.num_used+ve-H];else{var ye=H-ze.num_used;for(ve=0;ve<ye;++ve)X[ve]=X[ve+ze.num_used];for(vt=0;ve<H;++ve,++vt)X[ve]=Ge[He+vt];a(vt==ze.num_used)}return Yt}function Fr(w,P,xe,Pe,Ge,He){var Ne=w.internal_flags;if(Ne.resample_ratio<.9999||Ne.resample_ratio>1.0001)for(var ze=0;ze<Ne.channels_out;ze++){var et=new Te;He.n_out=St(w,P[ze],Ne.mf_size,w.framesize,xe[ze],Pe,Ge,et,ze),He.n_in=et.num_used}else{He.n_out=Math.min(w.framesize,Ge),He.n_in=He.n_out;for(var je=0;je<He.n_out;++je)P[0][Ne.mf_size+je]=xe[0][Pe+je],Ne.channels_out==2&&(P[1][Ne.mf_size+je]=xe[1][Pe+je])}}}return t1=k,t1}var uI=Zt,An=uI.VbrMode;function dI(){var t=u1();function e(l,u,h,p,g,x,S,k,_,m,$,f,E,N,B){this.vbr_q=l,this.quant_comp=u,this.quant_comp_s=h,this.expY=p,this.st_lrm=g,this.st_s=x,this.masking_adj=S,this.masking_adj_short=k,this.ath_lower=_,this.ath_curve=m,this.ath_sensitivity=$,this.interch=f,this.safejoint=E,this.sfb21mod=N,this.msfix=B}function r(l,u,h,p,g,x,S,k,_,m,$,f,E,N){this.quant_comp=u,this.quant_comp_s=h,this.safejoint=p,this.nsmsfix=g,this.st_lrm=x,this.st_s=S,this.nsbass=k,this.scale=_,this.masking_adj=m,this.ath_lower=$,this.ath_curve=f,this.interch=E,this.sfscale=N}var n;this.setModules=function(l){n=l};var s=[new e(0,9,9,0,5.2,125,-4.2,-6.3,4.8,1,0,0,2,21,.97),new e(1,9,9,0,5.3,125,-3.6,-5.6,4.5,1.5,0,0,2,21,1.35),new e(2,9,9,0,5.6,125,-2.2,-3.5,2.8,2,0,0,2,21,1.49),new e(3,9,9,1,5.8,130,-1.8,-2.8,2.6,3,-4,0,2,20,1.64),new e(4,9,9,1,6,135,-.7,-1.1,1.1,3.5,-8,0,2,0,1.79),new e(5,9,9,1,6.4,140,.5,.4,-7.5,4,-12,2e-4,0,0,1.95),new e(6,9,9,1,6.6,145,.67,.65,-14.7,6.5,-19,4e-4,0,0,2.3),new e(7,9,9,1,6.6,145,.8,.75,-19.7,8,-22,6e-4,0,0,2.7),new e(8,9,9,1,6.6,145,1.2,1.15,-27.5,10,-23,7e-4,0,0,0),new e(9,9,9,1,6.6,145,1.6,1.6,-36,11,-25,8e-4,0,0,0),new e(10,9,9,1,6.6,145,2,2,-36,12,-25,8e-4,0,0,0)],o=[new e(0,9,9,0,4.2,25,-7,-4,7.5,1,0,0,2,26,.97),new e(1,9,9,0,4.2,25,-5.6,-3.6,4.5,1.5,0,0,2,21,1.35),new e(2,9,9,0,4.2,25,-4.4,-1.8,2,2,0,0,2,18,1.49),new e(3,9,9,1,4.2,25,-3.4,-1.25,1.1,3,-4,0,2,15,1.64),new e(4,9,9,1,4.2,25,-2.2,.1,0,3.5,-8,0,2,0,1.79),new e(5,9,9,1,4.2,25,-1,1.65,-7.7,4,-12,2e-4,0,0,1.95),new e(6,9,9,1,4.2,25,-0,2.47,-7.7,6.5,-19,4e-4,0,0,2),new e(7,9,9,1,4.2,25,.5,2,-14.5,8,-22,6e-4,0,0,2),new e(8,9,9,1,4.2,25,1,2.4,-22,10,-23,7e-4,0,0,2),new e(9,9,9,1,4.2,25,1.5,2.95,-30,11,-25,8e-4,0,0,2),new e(10,9,9,1,4.2,25,2,2.95,-36,12,-30,8e-4,0,0,2)];function i(l,u,h){var p=l.VBR==An.vbr_rh?s:o,g=l.VBR_q_frac,x=p[u],S=p[u+1],k=x;x.st_lrm=x.st_lrm+g*(S.st_lrm-x.st_lrm),x.st_s=x.st_s+g*(S.st_s-x.st_s),x.masking_adj=x.masking_adj+g*(S.masking_adj-x.masking_adj),x.masking_adj_short=x.masking_adj_short+g*(S.masking_adj_short-x.masking_adj_short),x.ath_lower=x.ath_lower+g*(S.ath_lower-x.ath_lower),x.ath_curve=x.ath_curve+g*(S.ath_curve-x.ath_curve),x.ath_sensitivity=x.ath_sensitivity+g*(S.ath_sensitivity-x.ath_sensitivity),x.interch=x.interch+g*(S.interch-x.interch),x.msfix=x.msfix+g*(S.msfix-x.msfix),d(l,k.vbr_q),h!=0?l.quant_comp=k.quant_comp:Math.abs(l.quant_comp- -1)>0||(l.quant_comp=k.quant_comp),h!=0?l.quant_comp_short=k.quant_comp_s:Math.abs(l.quant_comp_short- -1)>0||(l.quant_comp_short=k.quant_comp_s),k.expY!=0&&(l.experimentalY=k.expY!=0),h!=0?l.internal_flags.nsPsy.attackthre=k.st_lrm:Math.abs(l.internal_flags.nsPsy.attackthre- -1)>0||(l.internal_flags.nsPsy.attackthre=k.st_lrm),h!=0?l.internal_flags.nsPsy.attackthre_s=k.st_s:Math.abs(l.internal_flags.nsPsy.attackthre_s- -1)>0||(l.internal_flags.nsPsy.attackthre_s=k.st_s),h!=0?l.maskingadjust=k.masking_adj:Math.abs(l.maskingadjust-0)>0||(l.maskingadjust=k.masking_adj),h!=0?l.maskingadjust_short=k.masking_adj_short:Math.abs(l.maskingadjust_short-0)>0||(l.maskingadjust_short=k.masking_adj_short),h!=0?l.ATHlower=-k.ath_lower/10:Math.abs(-l.ATHlower*10-0)>0||(l.ATHlower=-k.ath_lower/10),h!=0?l.ATHcurve=k.ath_curve:Math.abs(l.ATHcurve- -1)>0||(l.ATHcurve=k.ath_curve),h!=0?l.athaa_sensitivity=k.ath_sensitivity:Math.abs(l.athaa_sensitivity- -1)>0||(l.athaa_sensitivity=k.ath_sensitivity),k.interch>0&&(h!=0?l.interChRatio=k.interch:Math.abs(l.interChRatio- -1)>0||(l.interChRatio=k.interch)),k.safejoint>0&&(l.exp_nspsytune=l.exp_nspsytune|k.safejoint),k.sfb21mod>0&&(l.exp_nspsytune=l.exp_nspsytune|k.sfb21mod<<20),h!=0?l.msfix=k.msfix:Math.abs(l.msfix- -1)>0||(l.msfix=k.msfix),h==0&&(l.VBR_q=u,l.VBR_q_frac=g)}var a=[new r(8,9,9,0,0,6.6,145,0,.95,0,-30,11,.0012,1),new r(16,9,9,0,0,6.6,145,0,.95,0,-25,11,.001,1),new r(24,9,9,0,0,6.6,145,0,.95,0,-20,11,.001,1),new r(32,9,9,0,0,6.6,145,0,.95,0,-15,11,.001,1),new r(40,9,9,0,0,6.6,145,0,.95,0,-10,11,9e-4,1),new r(48,9,9,0,0,6.6,145,0,.95,0,-10,11,9e-4,1),new r(56,9,9,0,0,6.6,145,0,.95,0,-6,11,8e-4,1),new r(64,9,9,0,0,6.6,145,0,.95,0,-2,11,8e-4,1),new r(80,9,9,0,0,6.6,145,0,.95,0,0,8,7e-4,1),new r(96,9,9,0,2.5,6.6,145,0,.95,0,1,5.5,6e-4,1),new r(112,9,9,0,2.25,6.6,145,0,.95,0,2,4.5,5e-4,1),new r(128,9,9,0,1.95,6.4,140,0,.95,0,3,4,2e-4,1),new r(160,9,9,1,1.79,6,135,0,.95,-2,5,3.5,0,1),new r(192,9,9,1,1.49,5.6,125,0,.97,-4,7,3,0,0),new r(224,9,9,1,1.25,5.2,125,0,.98,-6,9,2,0,0),new r(256,9,9,1,.97,5.2,125,0,1,-8,10,1,0,0),new r(320,9,9,1,.9,5.2,125,0,1,-10,12,0,0,0)];function c(l,u,h){var p=u,g=n.nearestBitrateFullIndex(u);if(l.VBR=An.vbr_abr,l.VBR_mean_bitrate_kbps=p,l.VBR_mean_bitrate_kbps=Math.min(l.VBR_mean_bitrate_kbps,320),l.VBR_mean_bitrate_kbps=Math.max(l.VBR_mean_bitrate_kbps,8),l.brate=l.VBR_mean_bitrate_kbps,l.VBR_mean_bitrate_kbps>320&&(l.disable_reservoir=!0),a[g].safejoint>0&&(l.exp_nspsytune=l.exp_nspsytune|2),a[g].sfscale>0&&(l.internal_flags.noise_shaping=2),Math.abs(a[g].nsbass)>0){var x=int(a[g].nsbass*4);x<0&&(x+=64),l.exp_nspsytune=l.exp_nspsytune|x<<2}return h!=0?l.quant_comp=a[g].quant_comp:Math.abs(l.quant_comp- -1)>0||(l.quant_comp=a[g].quant_comp),h!=0?l.quant_comp_short=a[g].quant_comp_s:Math.abs(l.quant_comp_short- -1)>0||(l.quant_comp_short=a[g].quant_comp_s),h!=0?l.msfix=a[g].nsmsfix:Math.abs(l.msfix- -1)>0||(l.msfix=a[g].nsmsfix),h!=0?l.internal_flags.nsPsy.attackthre=a[g].st_lrm:Math.abs(l.internal_flags.nsPsy.attackthre- -1)>0||(l.internal_flags.nsPsy.attackthre=a[g].st_lrm),h!=0?l.internal_flags.nsPsy.attackthre_s=a[g].st_s:Math.abs(l.internal_flags.nsPsy.attackthre_s- -1)>0||(l.internal_flags.nsPsy.attackthre_s=a[g].st_s),h!=0?l.scale=a[g].scale:Math.abs(l.scale- -1)>0||(l.scale=a[g].scale),h!=0?l.maskingadjust=a[g].masking_adj:Math.abs(l.maskingadjust-0)>0||(l.maskingadjust=a[g].masking_adj),a[g].masking_adj>0?h!=0?l.maskingadjust_short=a[g].masking_adj*.9:Math.abs(l.maskingadjust_short-0)>0||(l.maskingadjust_short=a[g].masking_adj*.9):h!=0?l.maskingadjust_short=a[g].masking_adj*1.1:Math.abs(l.maskingadjust_short-0)>0||(l.maskingadjust_short=a[g].masking_adj*1.1),h!=0?l.ATHlower=-a[g].ath_lower/10:Math.abs(-l.ATHlower*10-0)>0||(l.ATHlower=-a[g].ath_lower/10),h!=0?l.ATHcurve=a[g].ath_curve:Math.abs(l.ATHcurve- -1)>0||(l.ATHcurve=a[g].ath_curve),h!=0?l.interChRatio=a[g].interch:Math.abs(l.interChRatio- -1)>0||(l.interChRatio=a[g].interch),u}this.apply_preset=function(l,u,h){switch(u){case t.R3MIX:{u=t.V3,l.VBR=An.vbr_mtrh;break}case t.MEDIUM:{u=t.V4,l.VBR=An.vbr_rh;break}case t.MEDIUM_FAST:{u=t.V4,l.VBR=An.vbr_mtrh;break}case t.STANDARD:{u=t.V2,l.VBR=An.vbr_rh;break}case t.STANDARD_FAST:{u=t.V2,l.VBR=An.vbr_mtrh;break}case t.EXTREME:{u=t.V0,l.VBR=An.vbr_rh;break}case t.EXTREME_FAST:{u=t.V0,l.VBR=An.vbr_mtrh;break}case t.INSANE:return u=320,l.preset=u,c(l,u,h),l.VBR=An.vbr_off,u}switch(l.preset=u,u){case t.V9:return i(l,9,h),u;case t.V8:return i(l,8,h),u;case t.V7:return i(l,7,h),u;case t.V6:return i(l,6,h),u;case t.V5:return i(l,5,h),u;case t.V4:return i(l,4,h),u;case t.V3:return i(l,3,h),u;case t.V2:return i(l,2,h),u;case t.V1:return i(l,1,h),u;case t.V0:return i(l,0,h),u}return 8<=u&&u<=320?c(l,u,h):(l.preset=0,u)};function d(l,u){var h=0;return 0>u&&(h=-1,u=0),9<u&&(h=-1,u=9),l.VBR_q=u,l.VBR_q_frac=0,h}}var fI=dI;function hI(){this.setModules=function(t,e){}}var pI=hI;function mI(){this.over_noise=0,this.tot_noise=0,this.max_noise=0,this.over_count=0,this.over_SSD=0,this.bits=0}var gI=mI,_3=Zt,qw=_3.new_float,_I=_3.new_int;function bI(){this.global_gain=0,this.sfb_count1=0,this.step=_I(39),this.noise=qw(39),this.noise_log=qw(39)}var yI=bI,hi=Zt,_s=hi.System,Vw=hi.VbrMode,r1=hi.Util,di=hi.Arrays,Aa=hi.new_float,Na=hi.assert,vI=pI,n1=gI,wI=yI,bt=hr(),Fw=o1,Hw=su;function xI(){var t;this.rv=null;var e;this.qupvt=null;var r,n=new vI,s;this.setModules=function(k,_,m,$){t=k,e=_,this.rv=_,r=m,this.qupvt=m,s=$,n.setModules(r,s)},this.ms_convert=function(k,_){for(var m=0;m<576;++m){var $=k.tt[_][0].xr[m],f=k.tt[_][1].xr[m];k.tt[_][0].xr[m]=($+f)*(r1.SQRT2*.5),k.tt[_][1].xr[m]=($-f)*(r1.SQRT2*.5)}};function o(k,_,m,$){$=0;for(var f=0;f<=m;++f){var E=Math.abs(k.xr[f]);$+=E,_[f]=Math.sqrt(E*Math.sqrt(E)),_[f]>k.xrpow_max&&(k.xrpow_max=_[f])}return $}this.init_xrpow=function(k,_,m){var $=0,f=0|_.max_nonzero_coeff;if(_.xrpow_max=0,di.fill(m,f,576,0),$=o(_,m,f,$),$>1e-20){var E=0;k.substep_shaping&2&&(E=1);for(var N=0;N<_.psymax;N++)k.pseudohalf[N]=E;return!0}return di.fill(_.l3_enc,0,576,0),!1};function i(k,_){var m=k.ATH,$=_.xr;if(_.block_type!=bt.SHORT_TYPE)for(var f=!1,E=bt.PSFB21-1;E>=0&&!f;E--){var N=k.scalefac_band.psfb21[E],B=k.scalefac_band.psfb21[E+1],U=r.athAdjust(m.adjust,m.psfb21[E],m.floor);k.nsPsy.longfact[21]>1e-12&&(U*=k.nsPsy.longfact[21]);for(var C=B-1;C>=N;C--)if(Math.abs($[C])<U)$[C]=0;else{f=!0;break}}else for(var q=0;q<3;q++)for(var f=!1,E=bt.PSFB12-1;E>=0&&!f;E--){var N=k.scalefac_band.s[12]*3+(k.scalefac_band.s[13]-k.scalefac_band.s[12])*q+(k.scalefac_band.psfb12[E]-k.scalefac_band.psfb12[0]),B=N+(k.scalefac_band.psfb12[E+1]-k.scalefac_band.psfb12[E]),de=r.athAdjust(m.adjust,m.psfb12[E],m.floor);k.nsPsy.shortfact[12]>1e-12&&(de*=k.nsPsy.shortfact[12]);for(var C=B-1;C>=N;C--)if(Math.abs($[C])<de)$[C]=0;else{f=!0;break}}}this.init_outer_loop=function(k,_){_.part2_3_length=0,_.big_values=0,_.count1=0,_.global_gain=210,_.scalefac_compress=0,_.table_select[0]=0,_.table_select[1]=0,_.table_select[2]=0,_.subblock_gain[0]=0,_.subblock_gain[1]=0,_.subblock_gain[2]=0,_.subblock_gain[3]=0,_.region0_count=0,_.region1_count=0,_.preflag=0,_.scalefac_scale=0,_.count1table_select=0,_.part2_length=0,_.sfb_lmax=bt.SBPSY_l,_.sfb_smin=bt.SBPSY_s,_.psy_lmax=k.sfb21_extra?bt.SBMAX_l:bt.SBPSY_l,_.psymax=_.psy_lmax,_.sfbmax=_.sfb_lmax,_.sfbdivide=11;for(var m=0;m<bt.SBMAX_l;m++)_.width[m]=k.scalefac_band.l[m+1]-k.scalefac_band.l[m],_.window[m]=3;if(_.block_type==bt.SHORT_TYPE){var $=Aa(576);_.sfb_smin=0,_.sfb_lmax=0,_.mixed_block_flag!=0&&(_.sfb_smin=3,_.sfb_lmax=k.mode_gr*2+4),_.psymax=_.sfb_lmax+3*((k.sfb21_extra?bt.SBMAX_s:bt.SBPSY_s)-_.sfb_smin),_.sfbmax=_.sfb_lmax+3*(bt.SBPSY_s-_.sfb_smin),_.sfbdivide=_.sfbmax-18,_.psy_lmax=_.sfb_lmax;var f=k.scalefac_band.l[_.sfb_lmax];_s.arraycopy(_.xr,0,$,0,576);for(var m=_.sfb_smin;m<bt.SBMAX_s;m++)for(var E=k.scalefac_band.s[m],N=k.scalefac_band.s[m+1],B=0;B<3;B++)for(var U=E;U<N;U++)_.xr[f++]=$[3*U+B];for(var C=_.sfb_lmax,m=_.sfb_smin;m<bt.SBMAX_s;m++)_.width[C]=_.width[C+1]=_.width[C+2]=k.scalefac_band.s[m+1]-k.scalefac_band.s[m],_.window[C]=0,_.window[C+1]=1,_.window[C+2]=2,C+=3}_.count1bits=0,_.sfb_partition_table=r.nr_of_sfb_block[0][0],_.slen[0]=0,_.slen[1]=0,_.slen[2]=0,_.slen[3]=0,_.max_nonzero_coeff=575,di.fill(_.scalefac,0),i(k,_)};function a(k){this.ordinal=k}a.BINSEARCH_NONE=new a(0),a.BINSEARCH_UP=new a(1),a.BINSEARCH_DOWN=new a(2);function c(k,_,m,$,f){var E,N=k.CurrentStep[$],B=!1,U=k.OldValue[$],C=a.BINSEARCH_NONE;for(_.global_gain=U,m-=_.part2_length;;){var q;if(E=s.count_bits(k,f,_,null),N==1||E==m)break;E>m?(C==a.BINSEARCH_DOWN&&(B=!0),B&&(N/=2),C=a.BINSEARCH_UP,q=N):(C==a.BINSEARCH_UP&&(B=!0),B&&(N/=2),C=a.BINSEARCH_DOWN,q=-N),_.global_gain+=q,_.global_gain<0&&(_.global_gain=0,B=!0),_.global_gain>255&&(_.global_gain=255,B=!0)}for(Na(_.global_gain>=0),Na(_.global_gain<256);E>m&&_.global_gain<255;)_.global_gain++,E=s.count_bits(k,f,_,null);return k.CurrentStep[$]=U-_.global_gain>=4?4:2,k.OldValue[$]=_.global_gain,_.part2_3_length=E,E}this.trancate_smallspectrums=function(k,_,m,$){var f=Aa(Hw.SFBMAX);if(!(!(k.substep_shaping&4)&&_.block_type==bt.SHORT_TYPE||k.substep_shaping&128)){r.calc_noise(_,m,f,new n1,null);for(var N=0;N<576;N++){var E=0;_.l3_enc[N]!=0&&(E=Math.abs(_.xr[N])),$[N]=E}var N=0,B=8;_.block_type==bt.SHORT_TYPE&&(B=6);do{var U,C,q,de,A=_.width[B];if(N+=A,!(f[B]>=1)&&(di.sort($,N-A,A),!BitStream.EQ($[N-1],0))){U=(1-f[B])*m[B],C=0,de=0;do{var b;for(q=1;de+q<A&&!BitStream.NEQ($[de+N-A],$[de+N+q-A]);q++);if(b=$[de+N-A]*$[de+N-A]*q,U<b){de!=0&&(C=$[de+N-A-1]);break}U-=b,de+=q}while(de<A);if(!BitStream.EQ(C,0))do Math.abs(_.xr[N-A])<=C&&(_.l3_enc[N-A]=0);while(--A>0)}}while(++B<_.psymax);_.part2_3_length=s.noquant_count_bits(k,_,null)}};function d(k){for(var _=0;_<k.sfbmax;_++)if(k.scalefac[_]+k.subblock_gain[k.window[_]]==0)return!1;return!0}function l(k){return r1.FAST_LOG10(.368+.632*k*k*k)}function u(k,_){for(var m=1e-37,$=0;$<_.psymax;$++)m+=l(k[$]);return Math.max(1e-20,m)}function h(k,_,m,$,f){var E;switch(k){default:case 9:{_.over_count>0?(E=m.over_SSD<=_.over_SSD,m.over_SSD==_.over_SSD&&(E=m.bits<_.bits)):E=m.max_noise<0&&m.max_noise*10+m.bits<=_.max_noise*10+_.bits;break}case 0:E=m.over_count<_.over_count||m.over_count==_.over_count&&m.over_noise<_.over_noise||m.over_count==_.over_count&&BitStream.EQ(m.over_noise,_.over_noise)&&m.tot_noise<_.tot_noise;break;case 8:m.max_noise=u(f,$);case 1:E=m.max_noise<_.max_noise;break;case 2:E=m.tot_noise<_.tot_noise;break;case 3:E=m.tot_noise<_.tot_noise&&m.max_noise<_.max_noise;break;case 4:E=m.max_noise<=0&&_.max_noise>.2||m.max_noise<=0&&_.max_noise<0&&_.max_noise>m.max_noise-.2&&m.tot_noise<_.tot_noise||m.max_noise<=0&&_.max_noise>0&&_.max_noise>m.max_noise-.2&&m.tot_noise<_.tot_noise+_.over_noise||m.max_noise>0&&_.max_noise>-.05&&_.max_noise>m.max_noise-.1&&m.tot_noise+m.over_noise<_.tot_noise+_.over_noise||m.max_noise>0&&_.max_noise>-.1&&_.max_noise>m.max_noise-.15&&m.tot_noise+m.over_noise+m.over_noise<_.tot_noise+_.over_noise+_.over_noise;break;case 5:E=m.over_noise<_.over_noise||BitStream.EQ(m.over_noise,_.over_noise)&&m.tot_noise<_.tot_noise;break;case 6:E=m.over_noise<_.over_noise||BitStream.EQ(m.over_noise,_.over_noise)&&(m.max_noise<_.max_noise||BitStream.EQ(m.max_noise,_.max_noise)&&m.tot_noise<=_.tot_noise);break;case 7:E=m.over_count<_.over_count||m.over_noise<_.over_noise;break}return _.over_count==0&&(E=E&&m.bits<_.bits),E}function p(k,_,m,$,f){var E=k.internal_flags,N;_.scalefac_scale==0?N=1.2968395546510096:N=1.6817928305074292;for(var B=0,U=0;U<_.sfbmax;U++)B<m[U]&&(B=m[U]);var C=E.noise_shaping_amp;switch(C==3&&(f?C=2:C=1),C){case 2:break;case 1:B>1?B=Math.pow(B,.5):B*=.95;break;case 0:default:B>1?B=1:B*=.95;break}for(var q=0,U=0;U<_.sfbmax;U++){var de=_.width[U],A;if(q+=de,!(m[U]<B)){if(E.substep_shaping&2&&(E.pseudohalf[U]=E.pseudohalf[U]==0?1:0,E.pseudohalf[U]==0&&E.noise_shaping_amp==2))return;for(_.scalefac[U]++,A=-de;A<0;A++)$[q+A]*=N,$[q+A]>_.xrpow_max&&(_.xrpow_max=$[q+A]);if(E.noise_shaping_amp==2)return}}}function g(k,_){for(var m=1.2968395546510096,$=0,f=0;f<k.sfbmax;f++){var E=k.width[f],N=k.scalefac[f];if(k.preflag!=0&&(N+=r.pretab[f]),$+=E,N&1){N++;for(var B=-E;B<0;B++)_[$+B]*=m,_[$+B]>k.xrpow_max&&(k.xrpow_max=_[$+B])}k.scalefac[f]=N>>1}k.preflag=0,k.scalefac_scale=1}function x(k,_,m){var $,f=_.scalefac;for($=0;$<_.sfb_lmax;$++)if(f[$]>=16)return!0;for(var E=0;E<3;E++){var N=0,B=0;for($=_.sfb_lmax+E;$<_.sfbdivide;$+=3)N<f[$]&&(N=f[$]);for(;$<_.sfbmax;$+=3)B<f[$]&&(B=f[$]);if(!(N<16&&B<8)){if(_.subblock_gain[E]>=7)return!0;_.subblock_gain[E]++;var U=k.scalefac_band.l[_.sfb_lmax];for($=_.sfb_lmax+E;$<_.sfbmax;$+=3){var C,q=_.width[$],de=f[$];if(de=de-(4>>_.scalefac_scale),de>=0){f[$]=de,U+=q*3;continue}f[$]=0;{var A=210+(de<<_.scalefac_scale+1);C=r.IPOW20(A)}U+=q*(E+1);for(var b=-q;b<0;b++)m[U+b]*=C,m[U+b]>_.xrpow_max&&(_.xrpow_max=m[U+b]);U+=q*(3-E-1)}{var C=r.IPOW20(202);U+=_.width[$]*(E+1);for(var b=-_.width[$];b<0;b++)m[U+b]*=C,m[U+b]>_.xrpow_max&&(_.xrpow_max=m[U+b])}}}return!1}function S(k,_,m,$,f){var E=k.internal_flags;p(k,_,m,$,f);var N=d(_);return N?!1:(E.mode_gr==2?N=s.scale_bitcount(_):N=s.scale_bitcount_lsf(E,_),N?(E.noise_shaping>1&&(di.fill(E.pseudohalf,0),_.scalefac_scale==0?(g(_,$),N=!1):_.block_type==bt.SHORT_TYPE&&E.subblock_gain>0&&(N=x(E,_,$)||d(_))),N||(E.mode_gr==2?N=s.scale_bitcount(_):N=s.scale_bitcount_lsf(E,_)),!N):!0)}this.outer_loop=function(k,_,m,$,f,E){var N=k.internal_flags,B=new Fw,U=Aa(576),C=Aa(Hw.SFBMAX),q=new n1,de,A=new wI,b=9999999,D=!1,I=!1,Y=0;if(c(N,_,E,f,$),N.noise_shaping==0)return 100;r.calc_noise(_,m,C,q,A),q.bits=_.part2_3_length,B.assign(_);var V=0;for(_s.arraycopy($,0,U,0,576);!D;){do{var ee=new n1,L,T=255;if(N.substep_shaping&2?L=20:L=3,N.sfb21_extra&&(C[B.sfbmax]>1||B.block_type==bt.SHORT_TYPE&&(C[B.sfbmax+1]>1||C[B.sfbmax+2]>1))||!S(k,B,C,$,I))break;B.scalefac_scale!=0&&(T=254);var y=E-B.part2_length;if(y<=0)break;for(;(B.part2_3_length=s.count_bits(N,$,B,A))>y&&B.global_gain<=T;)B.global_gain++;if(B.global_gain>T)break;if(q.over_count==0){for(;(B.part2_3_length=s.count_bits(N,$,B,A))>b&&B.global_gain<=T;)B.global_gain++;if(B.global_gain>T)break}if(r.calc_noise(B,m,C,ee,A),ee.bits=B.part2_3_length,_.block_type!=bt.SHORT_TYPE?de=k.quant_comp:de=k.quant_comp_short,de=h(de,q,ee,B,C)?1:0,de!=0)b=_.part2_3_length,q=ee,_.assign(B),V=0,_s.arraycopy($,0,U,0,576);else if(N.full_outer_loop==0&&(++V>L&&q.over_count==0||N.noise_shaping_amp==3&&I&&V>30||N.noise_shaping_amp==3&&I&&B.global_gain-Y>15))break}while(B.global_gain+B.scalefac_scale<255);N.noise_shaping_amp==3?I?D=!0:(B.assign(_),_s.arraycopy(U,0,$,0,576),V=0,Y=B.global_gain,I=!0):D=!0}return Na(_.global_gain+_.scalefac_scale<=255),k.VBR==Vw.vbr_rh||k.VBR==Vw.vbr_mtrh?_s.arraycopy(U,0,$,0,576):N.substep_shaping&1&&trancate_smallspectrums(N,_,m,$),q.over_count},this.iteration_finish_one=function(k,_,m){var $=k.l3_side,f=$.tt[_][m];s.best_scalefac_store(k,_,m,$),k.use_best_huffman==1&&s.best_huffman_divide(k,f),e.ResvAdjust(k,f)},this.VBR_encode_granule=function(k,_,m,$,f,E,N){var B=k.internal_flags,U=new Fw,C=Aa(576),q=N,de=N+1,A=(N+E)/2,b,D,I=0,Y=B.sfb21_extra;Na(q<=LameInternalFlags.MAX_BITS_PER_CHANNEL),di.fill(U.l3_enc,0);do A>q-42?B.sfb21_extra=!1:B.sfb21_extra=Y,D=outer_loop(k,_,m,$,f,A),D<=0?(I=1,de=_.part2_3_length,U.assign(_),_s.arraycopy($,0,C,0,576),N=de-32,b=N-E,A=(N+E)/2):(E=A+32,b=N-E,A=(N+E)/2,I!=0&&(I=2,_.assign(U),_s.arraycopy(C,0,$,0,576)));while(b>12);B.sfb21_extra=Y,I==2&&_s.arraycopy(U.l3_enc,0,_.l3_enc,0,576),Na(_.part2_3_length<=q)},this.get_framebits=function(k,_){var m=k.internal_flags;m.bitrate_index=m.VBR_min_bitrate;var $=t.getframebits(k);m.bitrate_index=1,$=t.getframebits(k);for(var f=1;f<=m.VBR_max_bitrate;f++){m.bitrate_index=f;var E=new MeanBits($);_[f]=e.ResvFrameBegin(k,E),$=E.bits}},this.VBR_old_prepare=function(k,_,m,$,f,E,N,B,U){var C=k.internal_flags,q,de=0,A=1,b=0;C.bitrate_index=C.VBR_max_bitrate;var D=e.ResvFrameBegin(k,new MeanBits(0))/C.mode_gr;get_framebits(k,E);for(var I=0;I<C.mode_gr;I++){var Y=r.on_pe(k,_,B[I],D,I,0);C.mode_ext==bt.MPG_MD_MS_LR&&(ms_convert(C.l3_side,I),r.reduce_side(B[I],m[I],D,Y));for(var V=0;V<C.channels_out;++V){var ee=C.l3_side.tt[I][V];ee.block_type!=bt.SHORT_TYPE?(de=1.28/(1+Math.exp(3.5-_[I][V]/300))-.05,q=C.PSY.mask_adjust-de):(de=2.56/(1+Math.exp(3.5-_[I][V]/300))-.14,q=C.PSY.mask_adjust_short-de),C.masking_lower=Math.pow(10,q*.1),init_outer_loop(C,ee),U[I][V]=r.calc_xmin(k,$[I][V],ee,f[I][V]),U[I][V]!=0&&(A=0),N[I][V]=126,b+=B[I][V]}}for(var I=0;I<C.mode_gr;I++)for(var V=0;V<C.channels_out;V++)b>E[C.VBR_max_bitrate]&&(B[I][V]*=E[C.VBR_max_bitrate],B[I][V]/=b),N[I][V]>B[I][V]&&(N[I][V]=B[I][V]);return A},this.bitpressure_strategy=function(k,_,m,$){for(var f=0;f<k.mode_gr;f++)for(var E=0;E<k.channels_out;E++){for(var N=k.l3_side.tt[f][E],B=_[f][E],U=0,C=0;C<N.psy_lmax;C++)B[U++]*=1+.029*C*C/bt.SBMAX_l/bt.SBMAX_l;if(N.block_type==bt.SHORT_TYPE)for(var C=N.sfb_smin;C<bt.SBMAX_s;C++)B[U++]*=1+.029*C*C/bt.SBMAX_s/bt.SBMAX_s,B[U++]*=1+.029*C*C/bt.SBMAX_s/bt.SBMAX_s,B[U++]*=1+.029*C*C/bt.SBMAX_s/bt.SBMAX_s;$[f][E]=0|Math.max(m[f][E],.9*$[f][E])}},this.VBR_new_prepare=function(k,_,m,$,f,E){var N=k.internal_flags,B=1,U=0,C=0,q;if(k.free_format){N.bitrate_index=0;var de=new MeanBits(U);q=e.ResvFrameBegin(k,de),U=de.bits,f[0]=q}else{N.bitrate_index=N.VBR_max_bitrate;var de=new MeanBits(U);e.ResvFrameBegin(k,de),U=de.bits,get_framebits(k,f),q=f[N.VBR_max_bitrate]}for(var A=0;A<N.mode_gr;A++){r.on_pe(k,_,E[A],U,A,0),N.mode_ext==bt.MPG_MD_MS_LR&&ms_convert(N.l3_side,A);for(var b=0;b<N.channels_out;++b){var D=N.l3_side.tt[A][b];N.masking_lower=Math.pow(10,N.PSY.mask_adjust*.1),init_outer_loop(N,D),r.calc_xmin(k,m[A][b],D,$[A][b])!=0&&(B=0),C+=E[A][b]}}for(var A=0;A<N.mode_gr;A++)for(var b=0;b<N.channels_out;b++)C>q&&(E[A][b]*=q,E[A][b]/=C);return B},this.calc_target_bits=function(k,_,m,$,f,E){var N=k.internal_flags,B=N.l3_side,U,C,q,de,A=0;N.bitrate_index=N.VBR_max_bitrate;var b=new MeanBits(A);for(E[0]=e.ResvFrameBegin(k,b),A=b.bits,N.bitrate_index=1,A=t.getframebits(k)-N.sideinfo_len*8,f[0]=A/(N.mode_gr*N.channels_out),A=k.VBR_mean_bitrate_kbps*k.framesize*1e3,N.substep_shaping&1&&(A*=1.09),A/=k.out_samplerate,A-=N.sideinfo_len*8,A/=N.mode_gr*N.channels_out,U=.93+.07*(11-k.compression_ratio)/(11-5.5),U<.9&&(U=.9),U>1&&(U=1),C=0;C<N.mode_gr;C++){var D=0;for(q=0;q<N.channels_out;q++){if($[C][q]=int(U*A),_[C][q]>700){var I=int((_[C][q]-700)/1.4),Y=B.tt[C][q];$[C][q]=int(U*A),Y.block_type==bt.SHORT_TYPE&&I<A/2&&(I=A/2),I>A*3/2?I=A*3/2:I<0&&(I=0),$[C][q]+=I}$[C][q]>LameInternalFlags.MAX_BITS_PER_CHANNEL&&($[C][q]=LameInternalFlags.MAX_BITS_PER_CHANNEL),D+=$[C][q]}if(D>LameInternalFlags.MAX_BITS_PER_GRANULE)for(q=0;q<N.channels_out;++q)$[C][q]*=LameInternalFlags.MAX_BITS_PER_GRANULE,$[C][q]/=D}if(N.mode_ext==bt.MPG_MD_MS_LR)for(C=0;C<N.mode_gr;C++)r.reduce_side($[C],m[C],A*N.channels_out,LameInternalFlags.MAX_BITS_PER_GRANULE);for(de=0,C=0;C<N.mode_gr;C++)for(q=0;q<N.channels_out;q++)$[C][q]>LameInternalFlags.MAX_BITS_PER_CHANNEL&&($[C][q]=LameInternalFlags.MAX_BITS_PER_CHANNEL),de+=$[C][q];if(de>E[0])for(C=0;C<N.mode_gr;C++)for(q=0;q<N.channels_out;q++)$[C][q]*=E[0],$[C][q]/=de}}var kI=xI,SI=Zt,Uw=SI.assert;function EI(){var t;this.setModules=function(e){t=e},this.ResvFrameBegin=function(e,r){var n=e.internal_flags,s,o=n.l3_side,i=t.getframebits(e);r.bits=(i-n.sideinfo_len*8)/n.mode_gr;var a=8*256*n.mode_gr-8;e.brate>320?s=8*int(e.brate*1e3/(e.out_samplerate/1152)/8+.5):(s=8*1440,e.strict_ISO&&(s=8*int(32e4/(e.out_samplerate/1152)/8+.5))),n.ResvMax=s-i,n.ResvMax>a&&(n.ResvMax=a),(n.ResvMax<0||e.disable_reservoir)&&(n.ResvMax=0);var c=r.bits*n.mode_gr+Math.min(n.ResvSize,n.ResvMax);return c>s&&(c=s),Uw(n.ResvMax%8==0),Uw(n.ResvMax>=0),o.resvDrain_pre=0,n.pinfo!=null&&(n.pinfo.mean_bits=r.bits/2,n.pinfo.resvsize=n.ResvSize),c},this.ResvMaxBits=function(e,r,n,s){var o=e.internal_flags,i,a=o.ResvSize,c=o.ResvMax;s!=0&&(a+=r),o.substep_shaping&1&&(c*=.9),n.bits=r,a*10>c*9?(i=a-c*9/10,n.bits+=i,o.substep_shaping|=128):(i=0,o.substep_shaping&=127,!e.disable_reservoir&&!(o.substep_shaping&1)&&(n.bits-=.1*r));var d=a<o.ResvMax*6/10?a:o.ResvMax*6/10;return d-=i,d<0&&(d=0),d},this.ResvAdjust=function(e,r){e.ResvSize-=r.part2_3_length+r.part2_length},this.ResvFrameEnd=function(e,r){var n,s=e.l3_side;e.ResvSize+=r*e.mode_gr;var o=0;s.resvDrain_post=0,s.resvDrain_pre=0,(n=e.ResvSize%8)!=0&&(o+=n),n=e.ResvSize-o-e.ResvMax,n>0&&(o+=n);{var i=Math.min(s.main_data_begin*8,o)/8;s.resvDrain_pre+=8*i,o-=8*i,e.ResvSize-=8*i,s.main_data_begin-=i}s.resvDrain_post+=o,e.ResvSize-=o}}var TI=EI;function $I(){var t="http://www.mp3dev.org/",e=3,r=98,n=4,s=0,o=93;this.getLameVersion=function(){return e+"."+r+"."+n},this.getLameShortVersion=function(){return e+"."+r+"."+n},this.getLameVeryShortVersion=function(){return"LAME"+e+"."+r+"r"},this.getPsyVersion=function(){return s+"."+o},this.getLameUrl=function(){return t},this.getLameOsBitness=function(){return"32bits"}}var RI=$I,pi=Zt,PI=pi.System,s1=pi.VbrMode,Gw=pi.ShortBlock,MI=pi.Arrays,ru=pi.new_byte,zI=pi.assert;Ca.NUMTOCENTRIES=100;Ca.MAXFRAMESIZE=2880;function Ca(){var t,e,r;this.setModules=function(A,b,D){t=A,e=b,r=D};var n=1,s=2,o=4,i=8,a=Ca.NUMTOCENTRIES,c=Ca.MAXFRAMESIZE,d=a+4+4+4+4+4,l=d+9+1+1+8+1+1+3+1+1+2+4+2+2,u=128,h=64,p=32,g=null,x="Xing",S="Info",k=[0,49345,49537,320,49921,960,640,49729,50689,1728,1920,51009,1280,50625,50305,1088,52225,3264,3456,52545,3840,53185,52865,3648,2560,51905,52097,2880,51457,2496,2176,51265,55297,6336,6528,55617,6912,56257,55937,6720,7680,57025,57217,8e3,56577,7616,7296,56385,5120,54465,54657,5440,55041,6080,5760,54849,53761,4800,4992,54081,4352,53697,53377,4160,61441,12480,12672,61761,13056,62401,62081,12864,13824,63169,63361,14144,62721,13760,13440,62529,15360,64705,64897,15680,65281,16320,16e3,65089,64001,15040,15232,64321,14592,63937,63617,14400,10240,59585,59777,10560,60161,11200,10880,59969,60929,11968,12160,61249,11520,60865,60545,11328,58369,9408,9600,58689,9984,59329,59009,9792,8704,58049,58241,9024,57601,8640,8320,57409,40961,24768,24960,41281,25344,41921,41601,25152,26112,42689,42881,26432,42241,26048,25728,42049,27648,44225,44417,27968,44801,28608,28288,44609,43521,27328,27520,43841,26880,43457,43137,26688,30720,47297,47489,31040,47873,31680,31360,47681,48641,32448,32640,48961,32e3,48577,48257,31808,46081,29888,30080,46401,30464,47041,46721,30272,29184,45761,45953,29504,45313,29120,28800,45121,20480,37057,37249,20800,37633,21440,21120,37441,38401,22208,22400,38721,21760,38337,38017,21568,39937,23744,23936,40257,24320,40897,40577,24128,23040,39617,39809,23360,39169,22976,22656,38977,34817,18624,18816,35137,19200,35777,35457,19008,19968,36545,36737,20288,36097,19904,19584,35905,17408,33985,34177,17728,34561,18368,18048,34369,33281,17088,17280,33601,16640,33217,32897,16448];function _(A,b){if(A.nVbrNumFrames++,A.sum+=b,A.seen++,!(A.seen<A.want)&&(A.pos<A.size&&(A.bag[A.pos]=A.sum,A.pos++,A.seen=0),A.pos==A.size)){for(var D=1;D<A.size;D+=2)A.bag[D/2]=A.bag[D];A.want*=2,A.pos/=2}}function m(A,b){if(!(A.pos<=0))for(var D=1;D<a;++D){var I=D/a,Y,V,ee=0|Math.floor(I*A.pos);ee>A.pos-1&&(ee=A.pos-1),Y=A.bag[ee],V=A.sum;var L=0|256*Y/V;L>255&&(L=255),b[D]=255&L}}this.addVbrFrame=function(A){var b=A.internal_flags,D=Tables.bitrate_table[A.version][b.bitrate_index];zI(b.VBR_seek_table.bag!=null),_(b.VBR_seek_table,D)};function $(A,b){var D=A[b+0]&255;return D<<=8,D|=A[b+1]&255,D<<=8,D|=A[b+2]&255,D<<=8,D|=A[b+3]&255,D}function f(A,b,D){A[b+0]=255&(D>>24&255),A[b+1]=255&(D>>16&255),A[b+2]=255&(D>>8&255),A[b+3]=255&(D&255)}function E(A,b,D){A[b+0]=255&(D>>8&255),A[b+1]=255&(D&255)}function N(A,b){return new String(A,b,x.length(),g).equals(x)||new String(A,b,S.length(),g).equals(S)}function B(A,b,D){return 255&(A<<b|D&~(-1<<b))}function U(A,b){var D=A.internal_flags;b[0]=B(b[0],8,255),b[1]=B(b[1],3,7),b[1]=B(b[1],1,A.out_samplerate<16e3?0:1),b[1]=B(b[1],1,A.version),b[1]=B(b[1],2,1),b[1]=B(b[1],1,A.error_protection?0:1),b[2]=B(b[2],4,D.bitrate_index),b[2]=B(b[2],2,D.samplerate_index),b[2]=B(b[2],1,0),b[2]=B(b[2],1,A.extension),b[3]=B(b[3],2,A.mode.ordinal()),b[3]=B(b[3],2,D.mode_ext),b[3]=B(b[3],1,A.copyright),b[3]=B(b[3],1,A.original),b[3]=B(b[3],2,A.emphasis),b[0]=255;var I=255&(b[1]&241),Y;A.version==1?Y=u:A.out_samplerate<16e3?Y=p:Y=h,A.VBR==s1.vbr_off&&(Y=A.brate);var V;A.free_format?V=0:V=255&16*t.BitrateIndex(Y,A.version,A.out_samplerate),A.version==1?(b[1]=255&(I|10),I=255&(b[2]&13),b[2]=255&(V|I)):(b[1]=255&(I|2),I=255&(b[2]&13),b[2]=255&(V|I))}this.getVbrTag=function(A){var b=new VBRTagData,D=0;b.flags=0;var I=A[D+1]>>3&1,Y=A[D+2]>>2&3,V=A[D+3]>>6&3,ee=A[D+2]>>4&15;if(ee=Tables.bitrate_table[I][ee],A[D+1]>>4==14?b.samprate=Tables.samplerate_table[2][Y]:b.samprate=Tables.samplerate_table[I][Y],I!=0?V!=3?D+=36:D+=21:V!=3?D+=21:D+=13,!N(A,D))return null;D+=4,b.hId=I;var L=b.flags=$(A,D);if(D+=4,L&n&&(b.frames=$(A,D),D+=4),L&s&&(b.bytes=$(A,D),D+=4),L&o){if(b.toc!=null)for(var T=0;T<a;T++)b.toc[T]=A[D+T];D+=a}b.vbrScale=-1,L&i&&(b.vbrScale=$(A,D),D+=4),b.headersize=(I+1)*72e3*ee/b.samprate,D+=21;var y=A[D+0]<<4;y+=A[D+1]>>4;var v=(A[D+1]&15)<<8;return v+=A[D+2]&255,(y<0||y>3e3)&&(y=-1),(v<0||v>3e3)&&(v=-1),b.encDelay=y,b.encPadding=v,b},this.InitVbrTag=function(A){var b=A.internal_flags,D;A.version==1?D=u:A.out_samplerate<16e3?D=p:D=h,A.VBR==s1.vbr_off&&(D=A.brate);var I=(A.version+1)*72e3*D/A.out_samplerate,Y=b.sideinfo_len+l;if(b.VBR_seek_table.TotalFrameSize=I,I<Y||I>c){A.bWriteVbrTag=!1;return}b.VBR_seek_table.nVbrNumFrames=0,b.VBR_seek_table.nBytesWritten=0,b.VBR_seek_table.sum=0,b.VBR_seek_table.seen=0,b.VBR_seek_table.want=1,b.VBR_seek_table.pos=0,b.VBR_seek_table.bag==null&&(b.VBR_seek_table.bag=new int[400],b.VBR_seek_table.size=400);var V=ru(c);U(A,V);for(var ee=b.VBR_seek_table.TotalFrameSize,L=0;L<ee;++L)e.add_dummy_byte(A,V[L]&255,1)};function C(A,b){var D=b^A;return b=b>>8^k[D&255],b}this.updateMusicCRC=function(A,b,D,I){for(var Y=0;Y<I;++Y)A[0]=C(b[D+Y],A[0])};function q(A,b,D,I,Y){var V=A.internal_flags,ee=0,L=A.encoder_delay,T=A.encoder_padding,y=100-10*A.VBR_q-A.quality,v=r.getLameVeryShortVersion(),R,O=0,K,se=[1,5,3,2,4,0,3],F=0|(A.lowpassfreq/100+.5>255?255:A.lowpassfreq/100+.5),Q=0,ue=0,ge=0,ke=A.internal_flags.noise_shaping,Re=0,Te=0,Se=0,Ce=0,St=0,Fr=(A.exp_nspsytune&1)!=0,w=(A.exp_nspsytune&2)!=0,P=!1,xe=!1,Pe=A.internal_flags.nogap_total,Ge=A.internal_flags.nogap_current,He=A.ATHtype,Ne=0,ze;switch(A.VBR){case vbr_abr:ze=A.VBR_mean_bitrate_kbps;break;case vbr_off:ze=A.brate;break;default:ze=A.VBR_min_bitrate_kbps}switch(A.VBR.ordinal()<se.length?R=se[A.VBR.ordinal()]:R=0,K=16*O+R,V.findReplayGain&&(V.RadioGain>510&&(V.RadioGain=510),V.RadioGain<-510&&(V.RadioGain=-510),ue=8192,ue|=3072,V.RadioGain>=0?ue|=V.RadioGain:(ue|=512,ue|=-V.RadioGain)),V.findPeakSample&&(Q=Math.abs(0|V.PeakSample/32767*Math.pow(2,23)+.5)),Pe!=-1&&(Ge>0&&(xe=!0),Ge<Pe-1&&(P=!0)),Ne=He+((Fr?1:0)<<4)+((w?1:0)<<5)+((P?1:0)<<6)+((xe?1:0)<<7),y<0&&(y=0),A.mode){case MONO:Re=0;break;case STEREO:Re=1;break;case DUAL_CHANNEL:Re=2;break;case JOINT_STEREO:A.force_ms?Re=4:Re=3;break;case NOT_SET:default:Re=7;break}A.in_samplerate<=32e3?Se=0:A.in_samplerate==48e3?Se=2:A.in_samplerate>48e3?Se=3:Se=1,(A.short_blocks==Gw.short_block_forced||A.short_blocks==Gw.short_block_dispensed||A.lowpassfreq==-1&&A.highpassfreq==-1||A.scale_left<A.scale_right||A.scale_left>A.scale_right||A.disable_reservoir&&A.brate<320||A.noATH||A.ATHonly||He==0||A.in_samplerate<=32e3)&&(Te=1),Ce=ke+(Re<<2)+(Te<<5)+(Se<<6),St=V.nMusicCRC,f(D,I+ee,y),ee+=4;for(var et=0;et<9;et++)D[I+ee+et]=255&v.charAt(et);ee+=9,D[I+ee]=255&K,ee++,D[I+ee]=255&F,ee++,f(D,I+ee,Q),ee+=4,E(D,I+ee,ue),ee+=2,E(D,I+ee,ge),ee+=2,D[I+ee]=255&Ne,ee++,ze>=255?D[I+ee]=255:D[I+ee]=255&ze,ee++,D[I+ee]=255&L>>4,D[I+ee+1]=255&(L<<4)+(T>>8),D[I+ee+2]=255&T,ee+=3,D[I+ee]=255&Ce,ee++,D[I+ee++]=0,E(D,I+ee,A.preset),ee+=2,f(D,I+ee,b),ee+=4,E(D,I+ee,St),ee+=2;for(var je=0;je<ee;je++)Y=C(D[I+je],Y);return E(D,I+ee,Y),ee+=2,ee}function de(A){A.seek(0);var b=ru(10);A.readFully(b);var D;return new String(b,"ISO-8859-1").startsWith("ID3")?D=0:D=((b[6]&127)<<21|(b[7]&127)<<14|(b[8]&127)<<7|b[9]&127)+b.length,D}this.getLameTagFrame=function(A,b){var D=A.internal_flags;if(!A.bWriteVbrTag||D.Class_ID!=Lame.LAME_ID||D.VBR_seek_table.pos<=0)return 0;if(b.length<D.VBR_seek_table.TotalFrameSize)return D.VBR_seek_table.TotalFrameSize;MI.fill(b,0,D.VBR_seek_table.TotalFrameSize,0),U(A,b);var I=ru(a);if(A.free_format)for(var Y=1;Y<a;++Y)I[Y]=255&255*Y/100;else m(D.VBR_seek_table,I);var V=D.sideinfo_len;A.error_protection&&(V-=2),A.VBR==s1.vbr_off?(b[V++]=255&S.charAt(0),b[V++]=255&S.charAt(1),b[V++]=255&S.charAt(2),b[V++]=255&S.charAt(3)):(b[V++]=255&x.charAt(0),b[V++]=255&x.charAt(1),b[V++]=255&x.charAt(2),b[V++]=255&x.charAt(3)),f(b,V,n+s+o+i),V+=4,f(b,V,D.VBR_seek_table.nVbrNumFrames),V+=4;var ee=D.VBR_seek_table.nBytesWritten+D.VBR_seek_table.TotalFrameSize;f(b,V,0|ee),V+=4,PI.arraycopy(I,0,b,V,I.length),V+=I.length,A.error_protection&&e.CRC_writeheader(D,b);for(var L=0,Y=0;Y<V;Y++)L=C(b[Y],L);return V+=q(A,ee,b,V,L),D.VBR_seek_table.TotalFrameSize},this.putVbrTag=function(A,b){var D=A.internal_flags;if(D.VBR_seek_table.pos<=0||(b.seek(b.length()),b.length()==0))return-1;var I=de(b);b.seek(I);var Y=ru(c),V=getLameTagFrame(A,Y);return V>Y.length?-1:(V<1||b.write(Y,0,V),0)}}var II=Ca,b3=Zt,Yw=b3.new_byte,OI=b3.assert,AI=u1(),NI=fI,CI=f3,jI=m3(),DI=kI,LI=g3(),ZI=TI,BI=Da,qI=l1();hr();var VI=RI,FI=II;function HI(){this.setModules=function(t,e){}}function UI(){this.setModules=function(t,e,r){}}function GI(){}function YI(){this.setModules=function(t,e){}}function XI(t,e,r){arguments.length!=3&&(console.error("WARN: Mp3Encoder(channels, samplerate, kbps) not specified"),t=1,e=44100,r=128);var n=new AI,s=new HI,o=new CI,i=new qI,a=new NI,c=new jI,d=new DI,l=new FI,u=new VI,h=new YI,p=new ZI,g=new LI,x=new UI,S=new GI;n.setModules(o,i,a,c,d,l,u,h,S),i.setModules(o,S,u,l),h.setModules(i,u),a.setModules(n),d.setModules(i,p,c,g),c.setModules(g,p,n.enc.psy),p.setModules(i),g.setModules(c),l.setModules(n,i,u),s.setModules(x,S),x.setModules(u,h,a);var k=n.lame_init();k.num_channels=t,k.in_samplerate=e,k.brate=r,k.mode=BI.STEREO,k.quality=3,k.bWriteVbrTag=!1,k.disable_reservoir=!0,k.write_id3tag_automatic=!1,n.lame_init_params(k);var _=1152,m=0|1.25*_+7200,$=Yw(m);this.encodeBuffer=function(f,E){t==1&&(E=f),OI(f.length==E.length),f.length>_&&(_=f.length,m=0|1.25*_+7200,$=Yw(m));var N=n.lame_encode_buffer(k,f,E,f.length,$,0,m);return new Int8Array($.subarray(0,N))},this.flush=function(){var f=n.lame_encode_flush(k,$,0,m);return new Int8Array($.subarray(0,f))}}function wn(){this.dataOffset=0,this.dataLen=0,this.channels=0,this.sampleRate=0}function iu(t){return t.charCodeAt(0)<<24|t.charCodeAt(1)<<16|t.charCodeAt(2)<<8|t.charCodeAt(3)}wn.RIFF=iu("RIFF");wn.WAVE=iu("WAVE");wn.fmt_=iu("fmt ");wn.data=iu("data");wn.readHeader=function(t){var e=new wn,r=t.getUint32(0,!1);if(wn.RIFF==r&&(t.getUint32(4,!0),wn.WAVE==t.getUint32(8,!1)&&wn.fmt_==t.getUint32(12,!1))){var n=t.getUint32(16,!0),s=20;switch(n){case 16:case 18:e.channels=t.getUint16(s+2,!0),e.sampleRate=t.getUint32(s+4,!0);break;default:throw"extended fmt chunk not implemented"}s+=n;for(var o=wn.data,i=0;o!=r&&(r=t.getUint32(s,!1),i=t.getUint32(s+4,!0),o!=r);)s+=i+8;return e.dataLen=i,e.dataOffset=s+8,e}};var y3=Xw.Mp3Encoder=XI,aq=Xw.WavHeader=wn;var mo=24e3;function d1(t){let e=Buffer.from(t);return new Int16Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/2))}function WI(t){let e=t.indexOf("data",0,"ascii"),r=e>=0?e+8:44;return d1(t.subarray(r))}var KI="Tone: friendly, clear, and natural \u2014 like a knowledgeable teacher explaining something they enjoy. Calm and encouraging, not theatrical.",JI="Delivery: a brisk, efficient speaking pace \u2014 energetic and moving forward, like a confident presenter who respects the listener's time. Clear pronunciation, but keep pauses between sentences short and don't linger. Keep ONE consistent voice throughout \u2014 the same character, gender, accent, and pitch on every line, as if it's one continuous recording by the same narrator. Do not change character or add dramatic, performative variation.";function QI(t){return process.env.FLOWCAST_TTS_INSTRUCTIONS?process.env.FLOWCAST_TTS_INSTRUCTIONS:`${t&&t.trim()?`Tone & delivery for this walkthrough: ${t.trim()}`:KI}
|
|
206
|
+
|
|
207
|
+
${JI}`}var eO={id:"openai",keyEnv:"OPENAI_API_KEY",hasKey:()=>!!process.env.OPENAI_API_KEY,async synth(t,e){let r=(process.env.OPENAI_BASE_URL||"https://api.openai.com/v1").replace(/\/$/,""),n=await fetch(`${r}/audio/speech`,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${process.env.OPENAI_API_KEY}`},body:JSON.stringify({model:process.env.FLOWCAST_TTS_MODEL||"gpt-4o-mini-tts",voice:process.env.FLOWCAST_TTS_VOICE||Ey(e.voiceName),input:t,response_format:"pcm",instructions:QI(e.voiceTone)})});if(!n.ok)throw new Error(`OpenAI TTS ${n.status}: ${(await n.text().catch(()=>"")).slice(0,200)}`);return d1(Buffer.from(await n.arrayBuffer()))}},tO={id:"elevenlabs",keyEnv:"ELEVENLABS_API_KEY",hasKey:()=>!!process.env.ELEVENLABS_API_KEY,async synth(t){let e=process.env.ELEVENLABS_VOICE_ID||"21m00Tcm4TlvDq8ikWAM",r=process.env.ELEVENLABS_MODEL||"eleven_turbo_v2_5",n=await fetch(`https://api.elevenlabs.io/v1/text-to-speech/${e}?output_format=pcm_24000`,{method:"POST",headers:{"content-type":"application/json","xi-api-key":process.env.ELEVENLABS_API_KEY},body:JSON.stringify({text:t,model_id:r})});if(!n.ok)throw new Error(`ElevenLabs TTS ${n.status}: ${(await n.text().catch(()=>"")).slice(0,200)}`);return d1(Buffer.from(await n.arrayBuffer()))}},rO={id:"google",keyEnv:"GOOGLE_TTS_API_KEY",hasKey:()=>!!process.env.GOOGLE_TTS_API_KEY,async synth(t){let e=process.env.GOOGLE_TTS_VOICE||"en-US-Neural2-D",r=e.split("-").slice(0,2).join("-")||"en-US",n=await fetch(`https://texttospeech.googleapis.com/v1/text:synthesize?key=${process.env.GOOGLE_TTS_API_KEY}`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({input:{text:t},voice:{languageCode:r,name:e},audioConfig:{audioEncoding:"LINEAR16",sampleRateHertz:mo}})});if(!n.ok)throw new Error(`Google TTS ${n.status}: ${(await n.text().catch(()=>"")).slice(0,200)}`);let{audioContent:s}=await n.json();if(!s)throw new Error("Google TTS: empty audioContent");return WI(Buffer.from(s,"base64"))}},au={openai:eO,elevenlabs:tO,google:rO};function v3(){let t=(process.env.VOICE_MODEL||"openai").trim().toLowerCase(),e=au[t];if(!e)throw new Error(`Unknown VOICE_MODEL "${t}". Use one of: ${Object.keys(au).join(", ")}.`);return e}async function nO(t){let e=v3();if(!e.hasKey())throw new Error(`Voice is required but no TTS key is configured. Set ${e.keyEnv} for the "${e.id}" provider, or choose another with VOICE_MODEL (openai | elevenlabs | google) and set that provider's key.`);let r={voiceName:t.voiceName,voiceTone:t.voiceTone},n=[],s=[];for(let o of t.steps){if(!o.say){s.push(void 0);continue}let i=await e.synth(o.say,r);n.push(i),s.push(Math.round(i.length/mo*1e3)+180)}return{clips:n,sayDurationsMs:s}}function w3(t,e,r){if(!e.length)return"";let n=Math.ceil(r/1e3*mo)+mo,s=new Int16Array(n);return t.forEach((o,i)=>{let a=e[i];if(!a)return;let c=Math.max(0,Math.round(o.t/1e3*mo));s.set(a.subarray(0,Math.max(0,Math.min(a.length,n-c))),c)}),"data:audio/mpeg;base64,"+iO(s)}var sO=40,oO=Math.max(sO,Math.min(128,Number(process.env.FLOWCAST_TTS_BITRATE)||48));function iO(t){let e=new y3(1,mo,oO),r=[],n=1152;for(let c=0;c<t.length;c+=n){let d=e.encodeBuffer(t.subarray(c,c+n));d.length&&r.push(d)}let s=e.flush();s.length&&r.push(s);let o=r.reduce((c,d)=>c+d.length,0),i=Buffer.allocUnsafe(o),a=0;for(let c of r)i.set(c,a),a+=c.length;return i.toString("base64")}async function x3(t){let e=await nO(t);return{clips:e.clips,sayDurationsMs:e.sayDurationsMs,voice:"embedded"}}async function f1(t,e){let r=t.makeBeat??(u=>({say:u})),n=_w(e.steps,e.title,e.intro,e.outro,r,t.forceOutro??!1),s={...e,steps:n},o=t.prepare?await t.prepare(s):{},{clips:i,sayDurationsMs:a,voice:c}=await x3(s),d=t.compile(s,{...a?{sayDurationsMs:a}:{},...o}),l=i?w3(d.captions??[],i,d.manifest.durationMs):"";return{html:xw(d,l),data:d,voice:c}}function k3(t){return t.trim().split(/\s+/).filter(Boolean).length}function cu(t){return t.length>40?`${t.slice(0,40)}\u2026`:t}function S3(t,e){let r=[];for(let n=t.indexOf(e);n>=0;n=t.indexOf(e,n+Math.max(1,e.length)))r.push(n);return r}function aO(t,e){t.forEach((r,n)=>{r.say&&k3(r.say)>18&&e.push({severity:"warn",code:"SAY_TOO_LONG",step:n+1,field:"say",message:`Narration is ${k3(r.say)} words \u2014 beats read best at 4\u201314 (one breath).`,suggestion:'Split it into two beats joined by a connector like "so" or "then".'})})}function cO(t,e){let r=t.files??[],n={},s=new Set;for(let a of r)n[a.path]=a.content??"",s.add(a.path);let o=r[0]?.path??null;t.steps.forEach((a,c)=>{let d=c+1,l=a.file??o??void 0;l&&(s.has(l)||(s.add(l),n[l]=n[l]??""),o=l);let u=l&&n[l]||"",h=l!=null&&a.code!=null,p=l!=null&&(a.edits?.length??0)>0;if(a.code!=null&&a.edits?.length&&e.push({severity:"error",code:"CODE_AND_EDITS",step:d,message:`Step ${d}: use either \`code\` or \`edits\`, not both.`}),h&&u.length>0&&!a.rewrite&&e.push({severity:"error",code:"CODE_ON_EXISTING",step:d,field:"code",message:`Step ${d}: "${l}" already has code \u2014 use \`edits\` to change it, or set \`rewrite: true\` for a deliberate full rewrite.`}),p&&u.length===0&&e.push({severity:"error",code:"EDITS_NO_TARGET",step:d,field:"edits",message:`Step ${d}: \`edits\` target "${l}" which has no code yet \u2014 introduce it first with \`files\` or a \`code\` step.`}),h&&l)n[l]=a.code;else if(p&&l){let g=u;for(let x of a.edits){let S=S3(g,x.find);if(S.length===0){e.push({severity:"error",code:"ANCHOR_NOT_FOUND",step:d,field:"edits",message:`Step ${d}: edit \`find\` not found: ${JSON.stringify(cu(x.find))}. It must match the file's current contents exactly.`});continue}let k=S[0];x.occurrence==null&&S.length>1?e.push({severity:"error",code:"ANCHOR_AMBIGUOUS",step:d,field:"edits",message:`Step ${d}: edit \`find\` ${JSON.stringify(cu(x.find))} appears ${S.length} times \u2014 set \`occurrence\` (1-based).`}):x.occurrence!=null&&(x.occurrence<1||x.occurrence>S.length?e.push({severity:"error",code:"ANCHOR_AMBIGUOUS",step:d,field:"edits",message:`Step ${d}: edit \`occurrence\` ${x.occurrence} is out of range \u2014 \`find\` appears ${S.length} time(s).`}):k=S[x.occurrence-1]),g=g.slice(0,k)+x.replace+g.slice(k+x.find.length)}n[l]=g}if(l&&a.highlightCode!=null){let g=S3(n[l]??"",a.highlightCode);g.length===0?e.push({severity:"error",code:"HIGHLIGHT_NOT_FOUND",step:d,field:"highlightCode",message:`Step ${d}: \`highlightCode\` snippet not found: ${JSON.stringify(cu(a.highlightCode))}.`}):g.length>1&&e.push({severity:"error",code:"HIGHLIGHT_AMBIGUOUS",step:d,field:"highlightCode",message:`Step ${d}: \`highlightCode\` snippet ${JSON.stringify(cu(a.highlightCode))} appears ${g.length} times \u2014 extend it until unique.`,suggestion:"Add surrounding characters until the snippet is unique in the file."})}})}function lu(t,e){let r=[];return t==="code"&&cO(e,r),aO(e.steps,r),r.sort((n,s)=>n.step-s.step||(n.severity===s.severity?0:n.severity==="error"?-1:1))}function lO(t,e,r){return t.split(e).join(r)}function E3(t,e){let r=t.steps.map((i,a)=>({step:{...i},order:a+1,deleted:!1})),n=i=>{let a=r.find(c=>c.order===i&&!c.deleted);if(!a)throw new Error(`No beat ${i} to edit (it may already be deleted or out of range).`);return a},s=0;for(let i of e)switch(i.op){case"updateStep":{Object.assign(n(i.step).step,i.set);break}case"deleteStep":{n(i.step).deleted=!0;break}case"replaceText":{let a=i.field??"say",c=i.step!=null?[n(i.step)]:r.filter(l=>!l.deleted),d=0;for(let l of c){let u=l.step[a];typeof u=="string"&&u.includes(i.find)&&(l.step[a]=lO(u,i.find,i.replace),d++)}if(d===0)throw new Error(`replaceText: ${JSON.stringify(i.find)} not found in ${i.step!=null?`beat ${i.step}`:"any beat"}'s \`${a}\`.`);break}case"insertStep":{r.push({step:{...i.value},order:i.after+ ++s*1e-6,deleted:!1});break}}let o=r.filter(i=>!i.deleted).sort((i,a)=>i.order-a.order).map(i=>i.step);return{...t,steps:o}}import{homedir as uO}from"node:os";import{join as T3}from"node:path";import{readFileSync as dO,writeFileSync as fO,mkdirSync as hO,chmodSync as pO}from"node:fs";function $3(){return process.env.FLOWCAST_CONFIG_DIR||T3(uO(),".flowcast")}function La(){return T3($3(),"config.json")}function h1(){try{let t=JSON.parse(dO(La(),"utf8"));return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}catch{return{}}}function R3(t){hO($3(),{recursive:!0}),fO(La(),JSON.stringify(t,null,2)+`
|
|
208
|
+
`);try{pO(La(),384)}catch{}}function P3(){for(let[t,e]of Object.entries(h1()))typeof e=="string"&&process.env[t]===void 0&&(process.env[t]=e)}import{createInterface as wO}from"node:readline/promises";import{stdin as A3,stdout as Vr}from"node:process";import{spawnSync as g1}from"node:child_process";import{existsSync as mi,readFileSync as mO,writeFileSync as gO,copyFileSync as _O,mkdirSync as bO}from"node:fs";import{homedir as z3}from"node:os";import{join as on,dirname as I3}from"node:path";var yO={command:"npx",args:["-y","@flowcast/mcp@latest"]};function p1(t){let e=process.platform==="win32"?g1("where",[t],{stdio:"ignore"}):g1("sh",["-c",`command -v ${t}`],{stdio:"ignore"});return!e.error&&e.status===0}function m1(t,e){let r=g1(t,e,{stdio:"inherit"});return!r.error&&r.status===0}function Za(t,e="mcpServers"){let r={};if(mi(t)){_O(t,`${t}.bak`);try{let o=JSON.parse(mO(t,"utf8"));o&&typeof o=="object"&&!Array.isArray(o)&&(r=o)}catch{}}else bO(I3(t),{recursive:!0});let n=r[e]&&typeof r[e]=="object"?r[e]:{},s="flowcast"in n;return r[e]={...n,flowcast:yO},gO(t,JSON.stringify(r,null,2)+`
|
|
209
|
+
`),s?"updated":"added"}function M3(){let t=z3();return process.platform==="darwin"?on(t,"Library","Application Support","Claude","claude_desktop_config.json"):process.platform==="win32"?on(process.env.APPDATA||on(t,"AppData","Roaming"),"Claude","claude_desktop_config.json"):on(t,".config","Claude","claude_desktop_config.json")}function vO(){let t=z3(),e=r=>{throw new Error(r)};return[{name:"Claude Code",detect:()=>p1("claude"),apply:()=>m1("claude",["mcp","add","-s","user","flowcast","--","npx","-y","@flowcast/mcp@latest"])?"added via `claude mcp add`":e("`claude mcp add` failed (already added? run it manually)")},{name:"Claude Desktop",detect:()=>mi(I3(M3())),apply:()=>`${Za(M3())} in claude_desktop_config.json`},{name:"Cursor",detect:()=>mi(on(t,".cursor")),apply:()=>`${Za(on(t,".cursor","mcp.json"))} in ~/.cursor/mcp.json`},{name:"Codex",detect:()=>p1("codex"),apply:()=>m1("codex",["mcp","add","flowcast","--","npx","-y","@flowcast/mcp@latest"])?"added via `codex mcp add`":e("`codex mcp add` failed (already added? run it manually)")},{name:"Kiro",detect:()=>mi(on(t,".kiro")),apply:()=>`${Za(on(t,".kiro","settings","mcp.json"))} in ~/.kiro/settings/mcp.json`},{name:"Windsurf",detect:()=>mi(on(t,".codeium")),apply:()=>`${Za(on(t,".codeium","windsurf","mcp_config.json"))} in ~/.codeium/windsurf/mcp_config.json`},{name:"Gemini CLI",detect:()=>mi(on(t,".gemini")),apply:()=>`${Za(on(t,".gemini","settings.json"))} in ~/.gemini/settings.json`},{name:"VS Code",detect:()=>p1("code"),apply:()=>m1("code",["--add-mcp",JSON.stringify({name:"flowcast",command:"npx",args:["-y","@flowcast/mcp@latest"]})])?"added via `code --add-mcp`":e("`code --add-mcp` failed (update VS Code, or add it manually)")}]}async function O3(t,e){let r=vO().filter(n=>n.detect());if(!r.length){e.write(`
|
|
210
|
+
No known MCP clients detected. Add FlowCast to your client manually:
|
|
211
|
+
`),e.write(` { "mcpServers": { "flowcast": { "command": "npx", "args": ["-y", "@flowcast/mcp@latest"] } } }
|
|
212
|
+
`);return}e.write(`
|
|
213
|
+
Register the FlowCast server with your tools (its config carries no secrets):
|
|
214
|
+
`);for(let n of r){let s=(await t.question(` \u2022 ${n.name} detected \u2014 add it? [Y/n]: `)).trim().toLowerCase();if(s==="n"||s==="no"){e.write(` skipped
|
|
215
|
+
`);continue}try{e.write(` \u2713 ${n.apply()}
|
|
216
|
+
`)}catch(o){e.write(` \u26A0\uFE0F ${o instanceof Error?o.message:String(o)}
|
|
217
|
+
`)}}}var N3={openai:{keyEnv:"OPENAI_API_KEY"},elevenlabs:{keyEnv:"ELEVENLABS_API_KEY",extra:[{env:"ELEVENLABS_VOICE_ID",prompt:"ElevenLabs voice id (leave blank for the account default)"}]},google:{keyEnv:"GOOGLE_TTS_API_KEY",extra:[{env:"GOOGLE_TTS_VOICE",prompt:"Google voice",default:"en-US-Neural2-D"}]}};function xO(t,e){return Promise.race([t,new Promise((r,n)=>setTimeout(()=>n(new Error(`timed out after ${e/1e3}s`)),e).unref())])}async function C3(){if(!A3.isTTY){Vr.write(`flowcast setup needs an interactive terminal.
|
|
218
|
+
Either run it directly in your shell, or skip the wizard and set your key via your MCP
|
|
219
|
+
client's \`env\` block (VOICE_MODEL + the provider key), or write ~/.flowcast/config.json.
|
|
220
|
+
`);return}let t=wO({input:A3,output:Vr});try{Vr.write(`
|
|
221
|
+
\u{1F399} FlowCast setup \u2014 configure spoken narration (voice is required).
|
|
222
|
+
|
|
223
|
+
`);let e=Object.keys(N3);Vr.write(`Voice providers:
|
|
224
|
+
`),e.forEach((d,l)=>Vr.write(` ${l+1}) ${d}
|
|
225
|
+
`));let r=(await t.question(`
|
|
226
|
+
Choose a provider [1-${e.length}] (1): `)).trim()||"1",n=e[Number(r)-1]??"openai",s=N3[n],o={...h1(),VOICE_MODEL:n},i=(await t.question(`
|
|
227
|
+
Paste your ${s.keyEnv}: `)).trim();if(!i){Vr.write(`
|
|
228
|
+
No key entered \u2014 nothing saved.
|
|
229
|
+
`);return}o[s.keyEnv]=i;for(let d of s.extra??[]){let l=d.default?`${d.prompt} (${d.default})`:d.prompt,h=(await t.question(`${l}: `)).trim()||d.default;h&&(o[d.env]=h)}Vr.write(`
|
|
230
|
+
Validating\u2026`);let a=!1,c="";try{for(let[l,u]of Object.entries(o))process.env[l]=u;a=(await xO(au[n].synth("Testing FlowCast voice.",{}),2e4)).length>0}catch(d){c=d instanceof Error?d.message:String(d)}if(a)Vr.write(` ok \u2713
|
|
231
|
+
`);else{Vr.write(c?`
|
|
232
|
+
\u26A0\uFE0F Could not validate the key: ${c}
|
|
233
|
+
`:`
|
|
234
|
+
\u26A0\uFE0F Got empty audio back.
|
|
235
|
+
`);let d=(await t.question("Save anyway? [y/N]: ")).trim().toLowerCase();if(d!=="y"&&d!=="yes"){Vr.write(`Aborted \u2014 nothing saved.
|
|
236
|
+
`);return}}R3(o),Vr.write(`
|
|
237
|
+
\u2713 Saved to ${La()} (private, owner-only).
|
|
238
|
+
`),await O3(t,Vr),Vr.write(`
|
|
239
|
+
Done! Restart any client that was already running so it picks up FlowCast.
|
|
240
|
+
|
|
241
|
+
`)}finally{t.close()}}process.argv[2]==="setup"&&(await C3(),process.exit(0));P3();function RO(t){return t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,60)||"walkthrough"}var PO=`Export a previously generated walkthrough HTML file to a caller-specified path.
|
|
242
|
+
|
|
243
|
+
Use this when create_walkthrough returned a ui:// resource that the client cannot render/read, or when the generated HTML was too large to inline. If uri is omitted, this exports the most recently generated walkthrough. outputPath is required and should normally be an absolute path in the user's workspace. /mnt/user-data/outputs/<file> is accepted and mapped to a writable local path by the server.`,ys=new Rl({name:"flowcast",version:"0.1.0"}),bs=new Map,MO=50,zO=0,b1=null;function B3(t){let e=t?t.replace(/^ui:\/\/flowcast\//,""):b1;if(!e)return null;let r=bs.get(e);return r?{id:e,entry:r}:null}function y1(t){let e=t.severity==="error"?"\u2717":"\u26A0",r=t.field?` (${t.field})`:"";return` ${e} beat ${t.step}${r} [${t.code}] ${t.message}${t.suggestion?` \u2192 ${t.suggestion}`:""}`}var du="/mnt/user-data/outputs",IO=Jt.dirname(TO(import.meta.url)),OO=Jt.resolve(IO,"../../..");function AO(t){try{return L3(t,{recursive:!0}),kO(t,SO.W_OK),!0}catch{return!1}}function NO(){return[process.env.FLOWCAST_OUTPUT_DIR,process.cwd()!==Jt.parse(process.cwd()).root?process.cwd():void 0,OO,Jt.join(j3(),"flowcast")].filter(e=>!!e).find(AO)??j3()}function D3(t,e){let r=Jt.relative(Jt.resolve(t),e);return r===""||!r.startsWith("..")&&!Jt.isAbsolute(r)}function CO(t){if(t===du||t.startsWith(`${du}/`)){let r=Jt.relative(du,t),n=NO(),s=Jt.resolve(n,r===""?"walkthrough.html":r);if(!D3(n,s))throw new Error(`outputPath escapes the output directory: ${t}`);return s}if(Jt.isAbsolute(t))return Jt.resolve(t);let e=Jt.resolve(process.cwd(),t);if(!D3(process.cwd(),e))throw new Error(`relative outputPath escapes the working directory: ${t} \u2014 pass an absolute path to write elsewhere`);return e}function q3(t,e){let r=CO(t);return L3(Jt.dirname(r),{recursive:!0}),EO(r,e,"utf8"),r}var _1=null;function jO(t,e){let r=new URL(t.url??"/","http://127.0.0.1").pathname,n=decodeURIComponent(r.replace(/^\/+/,"").replace(/\.html$/i,"")),s=n?bs.get(n):void 0;if(!s){e.writeHead(404,{"content-type":"text/plain; charset=utf-8"}),e.end("Walkthrough not found \u2014 it may have expired from memory. Regenerate it.");return}let o=Buffer.from(s.html,"utf8");e.writeHead(200,{"content-type":"text/html; charset=utf-8","content-length":o.length,"cache-control":"no-store"}),e.end(o)}function DO(t,e){return new Promise(r=>{let n=$O(jO);n.once("error",()=>r(!1)),n.listen(e,t,()=>{_1=n,_1.unref(),r(!0)})})}var uu=null;function LO(){return uu||(uu=(async()=>{if(process.env.FLOWCAST_NO_HTTP==="1")return null;let t="127.0.0.1",e=Number(process.env.FLOWCAST_PORT)||7616;for(let r=e;r<e+8;r++)if(await DO(t,r))return`http://${t}:${r}`;return null})(),uu)}ys.registerResource("walkthrough",new Pl("ui://flowcast/{id}",{list:void 0}),{title:"FlowCast walkthrough",description:"A rendered interactive code walkthrough (self-contained HTML).",mimeType:"text/html"},async(t,e)=>{let r=String(e.id),n=bs.get(r);if(!n)throw new Error(`Unknown walkthrough id: ${r}`);return{contents:[{uri:t.href,mimeType:"text/html",text:n.html}]}});ys.registerTool("export_walkthrough",{title:"Export generated walkthrough HTML",description:PO,inputSchema:{outputPath:G.string().describe("Required destination for the .html file. Prefer an absolute path in the user-visible workspace. /mnt/user-data/outputs/<file> is accepted and mapped to a writable local server path."),uri:G.string().optional().describe("Optional ui://flowcast/<id> resource returned by create_walkthrough. If omitted, exports the latest generated walkthrough.")}},async t=>{let e=String(t.outputPath),r=typeof t.uri=="string"?t.uri:void 0,n=r?r.replace(/^ui:\/\/flowcast\//,""):b1;if(!n)return{isError:!0,content:[{type:"text",text:"No walkthrough has been generated yet. Call create_walkthrough first."}]};let s=bs.get(n);if(!s)return{isError:!0,content:[{type:"text",text:`Unknown walkthrough id: ${n}`}]};try{let o=q3(e,s.html),i=o!==e&&e.startsWith(du)?` Requested sandbox path ${e} was mapped to this local MCP server path.`:"";return{content:[{type:"text",text:`Exported walkthrough to ${o} (${(s.bytes/1024).toFixed(0)} KB).${i} Open this local HTML file to view the artifact.`},{type:"resource_link",uri:Z3(o).href,name:`${s.slug}.html`,title:s.title,mimeType:"text/html",size:s.bytes,description:`Local HTML artifact for FlowCast walkthrough: ${s.title}`}]}}catch(o){return{isError:!0,content:[{type:"text",text:`Failed to export walkthrough: ${o instanceof Error?o.message:String(o)}`}]}}});async function V3(t){let{title:e,outputPath:r,html:n,data:s,kind:o,typeId:i,spec:a,diagnostics:c=[]}=t,d=RO(e),l=Buffer.byteLength(n),u=(l/1024).toFixed(0),h=`${d}-${(++zO).toString(36)}`;for(bs.set(h,{html:n,title:e,slug:d,bytes:l,typeId:i,spec:a,diagnostics:c}),b1=h;bs.size>MO;)bs.delete(bs.keys().next().value);let p=`ui://flowcast/${h}`,g=null;if(r)try{g=q3(r,n)}catch{}let x=await LO(),S=x?`${x}/${h}.html`:null,k=!S&&l<=9e5,_=`${o} ready \u2014 ${u} KB, ${s.events.length} events, ${Math.round(s.manifest.durationMs/1e3)}s. Narration audio embedded.`;S?_+=`
|
|
244
|
+
|
|
245
|
+
Give the user this link to open the interactive player in their browser (voice included):
|
|
246
|
+
${S}`:k?_+=`
|
|
247
|
+
|
|
248
|
+
No local server running. Save the self-contained HTML resource below to your outputs directory (e.g. /mnt/user-data/outputs/${d}.html) and present it as the artifact.`:_+=`
|
|
249
|
+
|
|
250
|
+
No local server and the page is large: read ${p} via resources/read to get the self-contained HTML, save it to your outputs directory, and present it.`;let m=c.filter($=>$.severity==="warn");return m.length&&(_+=`
|
|
251
|
+
|
|
252
|
+
${m.length} quality note(s) \u2014 fix targeted beats with revise_walkthrough (uri: ${p}):
|
|
253
|
+
${m.map(y1).join(`
|
|
254
|
+
`)}`),{content:[{type:"text",text:_},...S?[{type:"resource_link",uri:S,name:`${d}.html`,title:e,mimeType:"text/html",description:`Open in browser \u2014 interactive player on the user's machine: ${e}`}]:[],...k?[{type:"resource",resource:{uri:p,mimeType:"text/html",text:n}}]:[],...g?[{type:"resource_link",uri:Z3(g).href,name:`${d}.html`,title:e,mimeType:"text/html",size:l,description:`Saved HTML file: ${e}`}]:[],{type:"resource_link",uri:p,name:`${d}.html`,title:e,mimeType:"text/html",size:l,description:`FlowCast walkthrough (self-contained HTML via resources/read): ${e}`}]}}for(let t of Kl){let e=async n=>{let s=n;try{let{html:o,data:i,voice:a}=await f1(t,s),c=lu(t.id,s);return await V3({title:s.title,outputPath:s.outputPath,html:o,data:i,voice:a,kind:t.tool.title,typeId:t.id,spec:s,diagnostics:c})}catch(o){return{isError:!0,content:[{type:"text",text:`Failed to create ${t.id} cast: ${o instanceof Error?o.message:String(o)}`}]}}},r={title:t.tool.title,description:t.tool.description,inputSchema:t.schema};ys.registerTool(t.tool.name,r,e);for(let n of t.tool.aliases??[])ys.registerTool(n,r,e)}ys.registerTool("check_walkthrough",{title:"Check walkthrough quality",description:"Validate a previously generated walkthrough and return quality diagnostics \u2014 missing or ambiguous `highlightCode`/edit anchors, illegal code+edits combos, edits targeting an empty file, and over-long narration. Read-only: it produces no new file. Run it after create_* to see every issue at once, then fix the flagged beats with revise_walkthrough (cheaper than re-authoring the whole timeline).",inputSchema:{uri:G.string().optional().describe("ui://flowcast/<id> to check. Omit to check the most recently generated walkthrough."),severity:G.enum(["error","warn","all"]).optional().describe("Filter findings by severity (default 'all').")}},async t=>{let e=B3(typeof t.uri=="string"?t.uri:void 0);if(!e)return{isError:!0,content:[{type:"text",text:"No walkthrough found. Generate one with create_walkthrough first, or pass a valid ui://flowcast/<id>."}]};let{id:r,entry:n}=e,s=t.severity??"all",o=lu(n.typeId,n.spec).filter(d=>s==="all"||d.severity===s),i=o.filter(d=>d.severity==="error").length,a=o.filter(d=>d.severity==="warn").length,c=o.length?`${o.length} finding(s) in "${n.title}" \u2014 ${i} error(s), ${a} warning(s):
|
|
255
|
+
${o.map(y1).join(`
|
|
256
|
+
`)}
|
|
257
|
+
|
|
258
|
+
Fix the flagged beats with revise_walkthrough (uri: ui://flowcast/${r}).`:`\u2713 No issues found in "${n.title}".`;return{structuredContent:{uri:`ui://flowcast/${r}`,diagnostics:o},content:[{type:"text",text:c}]}});ys.registerTool("revise_walkthrough",{title:"Revise walkthrough",description:"Apply a handful of targeted edits to an existing walkthrough and re-render it, without re-sending the whole timeline. Ideal for fixing issues reported by check_walkthrough or tweaking a few beats. Edits use 1-based beat indices resolved against the ORIGINAL order, so numbers from a check pass stay valid across a batch. Ops: updateStep (overwrite fields on a beat), replaceText (find/replace in narration, one beat or all), deleteStep, insertStep. Returns a NEW ui:// id; the original is left intact. Rejected (without rendering) if the revised draft would have anchor errors.",inputSchema:{uri:G.string().optional().describe("ui://flowcast/<id> to revise. Omit to revise the most recent walkthrough."),outputPath:G.string().optional().describe("Optional path to also write the revised .html to (same mapping as create_*)."),edits:G.array(G.discriminatedUnion("op",[G.object({op:G.literal("updateStep"),step:G.number().int().min(1).describe("1-based beat index to modify."),set:G.object({say:G.string().optional(),highlightCode:G.string().optional(),holdMs:G.number().optional(),chapter:G.string().optional()}).describe("Fields to overwrite on the beat. Omitted fields are left untouched.")}),G.object({op:G.literal("replaceText"),find:G.string().min(1).describe("Exact text to find."),replace:G.string().describe("Replacement text."),step:G.number().int().min(1).optional().describe("Limit to one beat; omit to apply across all narration."),field:G.literal("say").optional().describe("Field to search (only 'say' for now).")}),G.object({op:G.literal("deleteStep"),step:G.number().int().min(1).describe("1-based beat index to remove.")}),G.object({op:G.literal("insertStep"),after:G.number().int().min(0).describe("Insert the new beat after this 1-based index (0 = before the first beat)."),value:G.record(G.any()).describe("A new step object, same shape as a create_* step.")})])).min(1).describe("Ordered patches applied to the stored authoring spec.")}},async t=>{let e=B3(typeof t.uri=="string"?t.uri:void 0);if(!e)return{isError:!0,content:[{type:"text",text:"No walkthrough found to revise. Generate one with create_walkthrough first, or pass a valid ui://flowcast/<id>."}]};let{entry:r}=e,n=Kl.find(a=>a.id===r.typeId);if(!n)return{isError:!0,content:[{type:"text",text:`Cannot revise: unknown cast type "${r.typeId}".`}]};let s;try{s=E3(r.spec,t.edits)}catch(a){return{isError:!0,content:[{type:"text",text:`Could not apply edits: ${a instanceof Error?a.message:String(a)}`}]}}let o=lu(n.id,s),i=o.filter(a=>a.severity==="error");if(i.length)return{isError:!0,content:[{type:"text",text:`Revision rejected \u2014 the edited draft has ${i.length} error(s). Fix these and retry:
|
|
259
|
+
${i.map(y1).join(`
|
|
260
|
+
`)}`}]};try{let{html:a,data:c,voice:d}=await f1(n,s),l=typeof t.outputPath=="string"?t.outputPath:void 0;return await V3({title:s.title,outputPath:l,html:a,data:c,voice:d,kind:`${n.tool.title} (revised)`,typeId:n.id,spec:s,diagnostics:o})}catch(a){return{isError:!0,content:[{type:"text",text:`Failed to render revised walkthrough: ${a instanceof Error?a.message:String(a)}`}]}}});ys.registerPrompt("new_walkthrough",{title:"New FlowCast walkthrough",description:"Start a FlowCast walkthrough \u2014 choose a format (code / whiteboard / map / 3D) and voice on/off, then build it.",argsSchema:{topic:G.string().optional().describe("Optional subject of the walkthrough.")}},({topic:t})=>({messages:[{role:"user",content:{type:"text",text:`I'd like to create a FlowCast walkthrough${t?` about: ${t}`:""}.
|
|
261
|
+
|
|
262
|
+
Before building it, ask me these two choices, then create it with the matching tool:
|
|
263
|
+
1. FORMAT \u2014 pick the one that best fits the topic:
|
|
264
|
+
`+Kl.map(e=>` ${e.promptLine}`).join(`
|
|
265
|
+
`)+'\n2. VOICE \u2014 narration ON (spoken aloud; needs OPENAI_API_KEY on the server) or OFF (synced captions only; set voice:false)? If ON, pick a `voiceTone` that fits the topic (e.g. upbeat for a beginner tutorial, calm and precise for a security deep-dive).\n\nOnce I answer, gather the content yourself and call the right tool with `voice` set accordingly. If WHITEBOARD: make it visual, not a plain mono board \u2014 give it a pastel color scheme (tones via `:::tone`/`class`, or `theme:"pastel"`), add `icons` to recognizable nodes, and `underline`/`highlight` the few most important terms. Reveal one node per beat so it animates as it builds.'}}]}));function F3(){try{_1?.close()}catch{}process.exit(0)}process.once("SIGINT",F3);process.once("SIGTERM",F3);await ys.connect(new zl);
|